Open
Conversation
084d282 to
02522af
Compare
kbader94
commented
Jun 13, 2025
Owner
Author
There was a problem hiding this comment.
NOTE: grub_video_fb_dispatch_blit falls back to unoptimized blitters
when rotation is enabled. Optimized blitters currently do not
support transformed coordinates.
Adds config support for setting framebuffer rotation
via the GRUB config.
- `util/grub-mkconfig.in`: exports `GRUB_FB_ROTATION`
- `util/grub.d/00_header.in`: evaluates the env var and sets rotation
- `util/grub.d/10_linux.in`: passes the rotation setting to Linux when
`GRUB_GFXPAYLOAD_LINUX=keep` is used
Supported values:
- Degrees: `90`, `180`, `270`
- Aliases: `right`, `inverted`, `left`
Signed-off-by: Kyle Bader <kyle.bader94@gmail.com>
GRUB previously tracked only vertical (Y-span) dirty regions,
causing entire pixel rows to be refreshed when even a small region
changed.
This patch introduces 2D rectangle-based tracking for screen updates,
allowing minimal partial updates and simplifying future work applying
rotation transformations to framebuffer drawing operations.
- Modifies `video_fb.c` to track (x, y, width, height) dirty rectangles
- Updates `doublebuf_*_update_screen()` to use the new region tracking
- Updates the `dirty` function signature to accept `x` and `width`
This patch is required to be applied first before other patches
in the Frambuffer Rotation patch series.
Signed-off-by: Kyle Bader <kyle.bader94@gmail.com>
Adds rotation-aware rendering to framebuffer drawing operations.
- Introduces `rotation`, `original_width`, and `original_height`
to `grub_video_mode_info`
- Updates all framebuffer operations (`blit`, `fill`, `scroll`, `dirty`)
to apply rotation transforms
Key implementation points:
- `grub_video_fb_create_render_target_from_pointer()` assumes the
target is the framebuffer and sets the configured rotation
- `grub_video_fb_create_render_target()` is used for off-screen
render targets and always disables rotation
- Off-screen render targets explicitly set `rotation = NONE`
TODO:
- `grub_video_fb_dispatch_blit' Uses unoptimized default(slow) blitter when rotation
env_var is provided. Optimized blitters currently do not support transformed coordinates.
Signed-off-by: Kyle Bader <kyle.bader94@gmail.com>
|
This should be considered to add. Many devices use mystery display module and this problem also troubled this community almost 12 years (from the first thread from arch forum). |
Owner
Author
|
@SteveZMTstudios I plan on resubmitting this feature to the GRUB mailing list after the next release, since GRUB is currently in a code freeze for this part of the release cycle. That's a tentative submission in November, and then hopefully it might be included in the next GRUB release. Thanks for your interest! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch series introduces framebuffer rotation support in GRUB,
intended for mobile, embedded, vertical-display systems, and weirdos
like me who have a primary screen in portrait orientation. It adds a
GRUB_FB_ROTATIONconfiguration variable, which applies rotationtransforms to all framebuffer drawing operations (blit, fill, scroll,
etc.) when rendering to the primary framebuffer target.
This functionality has been requested and discussed previously:
"Rotated menu on EFI?" — Michal Suchanek
https://lists.gnu.org/archive/html/grub-devel/2009-07/msg00438.html
Bug 61133 — "Support for rotated screen"
https://savannah.gnu.org/bugs/index.php?61133
How it works:
GRUB's graphical subsystem performs drawing operations on two types of
rendering targets: the framebuffer (the visible screen), and off-screen
buffers used for intermediate rendering (e.g., text composition).
Graphical operations, such as 'blit', 'fill', etc, are issued with a
grub_video_fbblit_infoparameter, which contains image data, along with a
grub_video_mode_infostructure describing the drawing context.This patch series extends
grub_video_mode_infowith the following fields:rotation: the current rotation mode (0, 90, 180, 270 degrees)original_width,original_height: the logical dimensions prior to rotationThe rotation variable from config is applied only to the framebuffer target.
Off-screen render targets explicitly set
rotation = GRUB_VIDEO_ROTATE_NONEtoprevent interference with text layout and other logical rendering.
Coordinate transformations are handled via new helper functions:
trans_x,trans_y, andgrub_video_transform_rectangle. These areapplied throughout GRUB’s drawing pipeline (
blit,fill,scroll,dirty) so that output appears correctly rotated in the final framebuffer.Patch summary:
[PATCH 1/3] video_fb: Support 2D dirty regions for partial updates
[PATCH 2/3] video_fb: Implement framebuffer rotation transforms
[PATCH 3/3] mkconfig: Add GRUB_FB_ROTATION configuration option
Known limitations:
grub_video_fb_dispatch_blit()bypassesoptimized blitters and uses a slower fallback. Optimized blitters do
not yet support rotated coordinate systems.
Tested on:
Changelog:
v2:
- Reformat echo statements in
00_header.infor readability- Improve inline documentation and comment clarity
- Additional testing