Skip to content

Commit 7f2f1fd

Browse files
Tvrtko Ursulinardbiesheuvel
authored andcommitted
efi: sysfb_efi: Convert swap width and height quirk to a callback
Convert the swapping of width and height quirk to a callback. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Suggested-by: Ard Biesheuvel <ardb@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Melissa Wen <mwen@igalia.com> Cc: linux-efi@vger.kernel.org Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Melissa Wen <mwen@igalia.com> # v3 [ardb: use local var to refer to screen_info] Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 449b87e commit 7f2f1fd

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

drivers/firmware/efi/sysfb_efi.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
231231
{},
232232
};
233233

234+
static int __init efifb_swap_width_height(const struct dmi_system_id *id)
235+
{
236+
struct screen_info *si = &screen_info;
237+
u32 bpp = __screen_info_lfb_bits_per_pixel(si);
238+
239+
swap(si->lfb_width, si->lfb_height);
240+
si->lfb_linelength = bpp * si->lfb_width / BITS_PER_BYTE;
241+
242+
return 1;
243+
}
244+
234245
/*
235246
* Some devices have a portrait LCD but advertise a landscape resolution (and
236247
* pitch). We simply swap width and height for these devices so that we can
@@ -248,6 +259,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
248259
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"),
249260
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1HCN44WW"),
250261
},
262+
.callback = efifb_swap_width_height,
251263
},
252264
{
253265
/* Lenovo MIIX 320-10ICR with 800x1280 portrait screen */
@@ -256,6 +268,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
256268
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
257269
"Lenovo MIIX 320-10ICR"),
258270
},
271+
.callback = efifb_swap_width_height,
259272
},
260273
{
261274
/* Lenovo D330 with 800x1280 or 1200x1920 portrait screen */
@@ -264,6 +277,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
264277
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
265278
"Lenovo ideapad D330-10IGM"),
266279
},
280+
.callback = efifb_swap_width_height,
267281
},
268282
{
269283
/* Lenovo IdeaPad Duet 3 10IGL5 with 1200x1920 portrait screen */
@@ -272,6 +286,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
272286
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
273287
"IdeaPad Duet 3 10IGL5"),
274288
},
289+
.callback = efifb_swap_width_height,
275290
},
276291
{
277292
/* Lenovo Yoga Book X91F / X91L */
@@ -280,6 +295,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
280295
/* Non exact match to match F + L versions */
281296
DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"),
282297
},
298+
.callback = efifb_swap_width_height,
283299
},
284300
{},
285301
};
@@ -355,14 +371,8 @@ __init void sysfb_apply_efi_quirks(void)
355371
!(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
356372
dmi_check_system(efifb_dmi_system_table);
357373

358-
if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI &&
359-
dmi_check_system(efifb_dmi_swap_width_height)) {
360-
u32 bpp = __screen_info_lfb_bits_per_pixel(&screen_info);
361-
362-
swap(screen_info.lfb_width, screen_info.lfb_height);
363-
screen_info.lfb_linelength = bpp * screen_info.lfb_width /
364-
BITS_PER_BYTE;
365-
}
374+
if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI)
375+
dmi_check_system(efifb_dmi_swap_width_height);
366376
}
367377

368378
__init void sysfb_set_efifb_fwnode(struct platform_device *pd)

0 commit comments

Comments
 (0)