PIXEL_BIT_MASK formats can have either less or more than four bytes per
pixel so lets fix the lfb_linelenght calculation when applying the
swapped width and height quirks.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Suggested-by: Thomas Zimmermann <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Melissa Wen <[email protected]>
zCc: [email protected]
Tested-by: Melissa Wen <[email protected]> # v3
---
 drivers/firmware/efi/sysfb_efi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
index 1d8b6966731c..997bbd2a2f33 100644
--- a/drivers/firmware/efi/sysfb_efi.c
+++ b/drivers/firmware/efi/sysfb_efi.c
@@ -357,8 +357,11 @@ __init void sysfb_apply_efi_quirks(void)
 
        if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI &&
            dmi_check_system(efifb_dmi_swap_width_height)) {
+               u32 lfb_depth = __screen_info_lfb_bits_per_pixel(&screen_info);
+
                swap(screen_info.lfb_width, screen_info.lfb_height);
-               screen_info.lfb_linelength = 4 * screen_info.lfb_width;
+               screen_info.lfb_linelength = lfb_depth * screen_info.lfb_width /
+                                            BITS_PER_BYTE;
        }
 }
 
-- 
2.51.1

Reply via email to