Commit 1b617bc9 authored by Pierre Asselin's avatar Pierre Asselin Committed by Thomas Zimmermann

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 f35cd3fa
("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: default avatarPierre Asselin <pa@panix.com>
Fixes: f35cd3fa ("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.comTested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230419044834.10816-1-pa@panix.com
parent c8687694
...@@ -51,7 +51,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si, ...@@ -51,7 +51,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
* *
* It's not easily possible to fix this in struct screen_info, * It's not easily possible to fix this in struct screen_info,
* as this could break UAPI. The best solution is to compute * as this could break UAPI. The best solution is to compute
* bits_per_pixel here and ignore lfb_depth. In the loop below, * bits_per_pixel from the color bits, reserved bits and
* reported lfb_depth, whichever is highest. In the loop below,
* ignore simplefb formats with alpha bits, as EFI and VESA * ignore simplefb formats with alpha bits, as EFI and VESA
* don't specify alpha channels. * don't specify alpha channels.
*/ */
...@@ -60,6 +61,7 @@ __init bool sysfb_parse_mode(const struct screen_info *si, ...@@ -60,6 +61,7 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
si->green_size + si->green_pos, si->green_size + si->green_pos,
si->blue_size + si->blue_pos), si->blue_size + si->blue_pos),
si->rsvd_size + si->rsvd_pos); si->rsvd_size + si->rsvd_pos);
bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth);
} else { } else {
bits_per_pixel = si->lfb_depth; bits_per_pixel = si->lfb_depth;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment