]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
efi: sysfb_efi: Fix lfb_linelength calculation when applying quirks
authorTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Mon, 8 Dec 2025 19:39:23 +0000 (20:39 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 16 Dec 2025 13:12:43 +0000 (14:12 +0100)
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 <tvrtko.ursulin@igalia.com>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Melissa Wen <mwen@igalia.com>
Cc: linux-efi@vger.kernel.org
Tested-by: Melissa Wen <mwen@igalia.com> # v3
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/sysfb_efi.c

index 1d8b6966731c3f4f0ee44a150868a2c1d7ac39fa..60495eb3441c30beaee3a1fc8df03082a1b41d8d 100644 (file)
@@ -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 bpp = __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 = bpp * screen_info.lfb_width /
+                                            BITS_PER_BYTE;
        }
 }