Skip to content

Commit 1b617bc

Browse files
well-disorderedThomas Zimmermann
authored andcommitted
firmware/sysfb: Fix VESA format selection
Some legacy BIOSes report no reserved bits in their 32-bit rgb mode, breaking the calculation of bits_per_pixel in commit f35cd3f ("firmware/sysfb: Fix EFI/VESA format selection"). However they report lfb_depth correctly for those modes. Keep the computation but set bits_per_pixel to lfb_depth if the latter is larger. v2 fixes the warnings from a max3() macro with arguments of different types; split the bits_per_pixel assignment to avoid uglyfing the code with too many typecasts. v3 fixes space and formatting blips pointed out by Javier, and change the bit_per_pixel assignment back to a single statement using two casts. v4 go back to v2 and use max_t() Signed-off-by: Pierre Asselin <[email protected]> Fixes: f35cd3f ("firmware/sysfb: Fix EFI/VESA format selection") Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Tested-by: Thomas Zimmermann <[email protected]> Signed-off-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c868769 commit 1b617bc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/firmware/sysfb_simplefb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
5151
*
5252
* It's not easily possible to fix this in struct screen_info,
5353
* as this could break UAPI. The best solution is to compute
54-
* bits_per_pixel here and ignore lfb_depth. In the loop below,
54+
* bits_per_pixel from the color bits, reserved bits and
55+
* reported lfb_depth, whichever is highest. In the loop below,
5556
* ignore simplefb formats with alpha bits, as EFI and VESA
5657
* don't specify alpha channels.
5758
*/
@@ -60,6 +61,7 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
6061
si->green_size + si->green_pos,
6162
si->blue_size + si->blue_pos),
6263
si->rsvd_size + si->rsvd_pos);
64+
bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth);
6365
} else {
6466
bits_per_pixel = si->lfb_depth;
6567
}

0 commit comments

Comments
 (0)