Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 f35cd3fa7729
("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 <pa@panix.com>
Fixes: f35cd3fa7729 ("firmware/sysfb: Fix EFI/VESA format selection")
Link: https://lore.kernel.org/r/4Psm6B6Lqkz1QXM@panix3.panix.com
Link: https://lore.kernel.org/r/20230412150225.3757223-1-javierm@redhat.com
Tested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230419044834.10816-1-pa@panix.com

authored by

Pierre Asselin and committed by
Thomas Zimmermann
1b617bc9 c8687694

+3 -1
+3 -1
drivers/firmware/sysfb_simplefb.c
··· 51 51 * 52 52 * It's not easily possible to fix this in struct screen_info, 53 53 * 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, 55 56 * ignore simplefb formats with alpha bits, as EFI and VESA 56 57 * don't specify alpha channels. 57 58 */ ··· 61 60 si->green_size + si->green_pos, 62 61 si->blue_size + si->blue_pos), 63 62 si->rsvd_size + si->rsvd_pos); 63 + bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth); 64 64 } else { 65 65 bits_per_pixel = si->lfb_depth; 66 66 }