[PATCH master 3/3] efi: gop: report and use framebuffer stride
Ahmad Fatoum
a.fatoum at barebox.org
Sat Jun 27 02:55:41 PDT 2026
Both barebox and EFI GOP differentiate between the width of a line on
screen and in memory.
The EFI GOP driver we had imported from U-Boot loses that distinction
and reports PixelsPerScanLine to be identical to the visible horizontal
resolution. Pass the framebuffer line length instead to fix potential
issues when they differ.
Assisted-by: Codex:gpt-5.5
Fixes: d040f49ad0b3 ("efi: loader: protocol: add graphical output protocol support")
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
efi/loader/protocols/gop.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/efi/loader/protocols/gop.c b/efi/loader/protocols/gop.c
index 03995d9eee29..fbbcace83eef 100644
--- a/efi/loader/protocols/gop.c
+++ b/efi/loader/protocols/gop.c
@@ -174,7 +174,7 @@ static __always_inline efi_status_t gop_blt_int(struct efi_graphics_output_proto
break;
case EFI_BLT_VIDEO_TO_BLT_BUFFER:
case EFI_BLT_VIDEO_TO_VIDEO:
- swidth = gopobj->info.horizontal_resolution;
+ swidth = gopobj->info.pixels_per_scan_line;
if (!vid_bpp)
return EFI_UNSUPPORTED;
break;
@@ -187,7 +187,7 @@ static __always_inline efi_status_t gop_blt_int(struct efi_graphics_output_proto
case EFI_BLT_BUFFER_TO_VIDEO:
case EFI_BLT_VIDEO_FILL:
case EFI_BLT_VIDEO_TO_VIDEO:
- dwidth = gopobj->info.horizontal_resolution;
+ dwidth = gopobj->info.pixels_per_scan_line;
if (!vid_bpp)
return EFI_UNSUPPORTED;
break;
@@ -489,6 +489,7 @@ static efi_status_t efi_gop_register(void *data)
struct fb_info *fbi;
struct screen *sc;
struct efi_pixel_bitmask *pixel_information;
+ u32 bytes_per_pixel, pixels_per_scan_line;
sc = fb_open(fbdev);
if (IS_ERR(sc)) {
@@ -510,6 +511,14 @@ static efi_status_t efi_gop_register(void *data)
return EFI_UNSUPPORTED;
}
+ bytes_per_pixel = fbi->bits_per_pixel / BITS_PER_BYTE;
+ if (fbi->line_length % bytes_per_pixel)
+ return EFI_UNSUPPORTED;
+
+ pixels_per_scan_line = fbi->line_length / bytes_per_pixel;
+ if (pixels_per_scan_line < col)
+ return EFI_UNSUPPORTED;
+
gopobj = calloc(1, sizeof(*gopobj));
if (!gopobj) {
pr_err("Out of memory\n");
@@ -566,7 +575,7 @@ static efi_status_t efi_gop_register(void *data)
pixel_information->green_mask = 0x07e0;
pixel_information->blue_mask = 0x001f;
}
- gopobj->info.pixels_per_scan_line = col;
+ gopobj->info.pixels_per_scan_line = pixels_per_scan_line;
gopobj->fb = fbi->screen_base;
gopobj->fbi = fbi;
--
2.47.3
More information about the barebox
mailing list