18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Generic System Framebuffers on x86
48c2ecf20Sopenharmony_ci * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * EFI Quirks Copyright (c) 2006 Edgar Hucek <gimli@dark-green.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci * EFI Quirks
118c2ecf20Sopenharmony_ci * Several EFI systems do not correctly advertise their boot framebuffers.
128c2ecf20Sopenharmony_ci * Hence, we use this static table of known broken machines and fix up the
138c2ecf20Sopenharmony_ci * information so framebuffer drivers can load corectly.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/dmi.h>
178c2ecf20Sopenharmony_ci#include <linux/err.h>
188c2ecf20Sopenharmony_ci#include <linux/efi.h>
198c2ecf20Sopenharmony_ci#include <linux/init.h>
208c2ecf20Sopenharmony_ci#include <linux/kernel.h>
218c2ecf20Sopenharmony_ci#include <linux/mm.h>
228c2ecf20Sopenharmony_ci#include <linux/pci.h>
238c2ecf20Sopenharmony_ci#include <linux/screen_info.h>
248c2ecf20Sopenharmony_ci#include <video/vga.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <asm/efi.h>
278c2ecf20Sopenharmony_ci#include <asm/sysfb.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum {
308c2ecf20Sopenharmony_ci	OVERRIDE_NONE = 0x0,
318c2ecf20Sopenharmony_ci	OVERRIDE_BASE = 0x1,
328c2ecf20Sopenharmony_ci	OVERRIDE_STRIDE = 0x2,
338c2ecf20Sopenharmony_ci	OVERRIDE_HEIGHT = 0x4,
348c2ecf20Sopenharmony_ci	OVERRIDE_WIDTH = 0x8,
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistruct efifb_dmi_info efifb_dmi_list[] = {
388c2ecf20Sopenharmony_ci	[M_I17] = { "i17", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE },
398c2ecf20Sopenharmony_ci	[M_I20] = { "i20", 0x80010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE }, /* guess */
408c2ecf20Sopenharmony_ci	[M_I20_SR] = { "imac7", 0x40010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE },
418c2ecf20Sopenharmony_ci	[M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, /* guess */
428c2ecf20Sopenharmony_ci	[M_I24_8_1] = { "imac8", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE },
438c2ecf20Sopenharmony_ci	[M_I24_10_1] = { "imac10", 0xc0010000, 2048 * 4, 1920, 1080, OVERRIDE_NONE },
448c2ecf20Sopenharmony_ci	[M_I27_11_1] = { "imac11", 0xc0010000, 2560 * 4, 2560, 1440, OVERRIDE_NONE },
458c2ecf20Sopenharmony_ci	[M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768, OVERRIDE_NONE },
468c2ecf20Sopenharmony_ci	[M_MINI_3_1] = { "mini31", 0x40010000, 1024 * 4, 1024, 768, OVERRIDE_NONE },
478c2ecf20Sopenharmony_ci	[M_MINI_4_1] = { "mini41", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE },
488c2ecf20Sopenharmony_ci	[M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
498c2ecf20Sopenharmony_ci	[M_MB_5_1] = { "macbook51", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
508c2ecf20Sopenharmony_ci	[M_MB_6_1] = { "macbook61", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
518c2ecf20Sopenharmony_ci	[M_MB_7_1] = { "macbook71", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
528c2ecf20Sopenharmony_ci	[M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
538c2ecf20Sopenharmony_ci	/* 11" Macbook Air 3,1 passes the wrong stride */
548c2ecf20Sopenharmony_ci	[M_MBA_3] = { "mba3", 0, 2048 * 4, 0, 0, OVERRIDE_STRIDE },
558c2ecf20Sopenharmony_ci	[M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE },
568c2ecf20Sopenharmony_ci	[M_MBP_2] = { "mbp2", 0, 0, 0, 0, OVERRIDE_NONE }, /* placeholder */
578c2ecf20Sopenharmony_ci	[M_MBP_2_2] = { "mbp22", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE },
588c2ecf20Sopenharmony_ci	[M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900, OVERRIDE_NONE },
598c2ecf20Sopenharmony_ci	[M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE },
608c2ecf20Sopenharmony_ci	[M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE },
618c2ecf20Sopenharmony_ci	[M_MBP_5_2] = { "mbp52", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE },
628c2ecf20Sopenharmony_ci	[M_MBP_5_3] = { "mbp53", 0xd0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE },
638c2ecf20Sopenharmony_ci	[M_MBP_6_1] = { "mbp61", 0x90030000, 2048 * 4, 1920, 1200, OVERRIDE_NONE },
648c2ecf20Sopenharmony_ci	[M_MBP_6_2] = { "mbp62", 0x90030000, 2048 * 4, 1680, 1050, OVERRIDE_NONE },
658c2ecf20Sopenharmony_ci	[M_MBP_7_1] = { "mbp71", 0xc0010000, 2048 * 4, 1280, 800, OVERRIDE_NONE },
668c2ecf20Sopenharmony_ci	[M_MBP_8_2] = { "mbp82", 0x90010000, 1472 * 4, 1440, 900, OVERRIDE_NONE },
678c2ecf20Sopenharmony_ci	[M_UNKNOWN] = { NULL, 0, 0, 0, 0, OVERRIDE_NONE }
688c2ecf20Sopenharmony_ci};
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_civoid efifb_setup_from_dmi(struct screen_info *si, const char *opt)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	int i;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	for (i = 0; i < M_UNKNOWN; i++) {
758c2ecf20Sopenharmony_ci		if (efifb_dmi_list[i].base != 0 &&
768c2ecf20Sopenharmony_ci		    !strcmp(opt, efifb_dmi_list[i].optname)) {
778c2ecf20Sopenharmony_ci			si->lfb_base = efifb_dmi_list[i].base;
788c2ecf20Sopenharmony_ci			si->lfb_linelength = efifb_dmi_list[i].stride;
798c2ecf20Sopenharmony_ci			si->lfb_width = efifb_dmi_list[i].width;
808c2ecf20Sopenharmony_ci			si->lfb_height = efifb_dmi_list[i].height;
818c2ecf20Sopenharmony_ci		}
828c2ecf20Sopenharmony_ci	}
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define choose_value(dmivalue, fwvalue, field, flags) ({	\
868c2ecf20Sopenharmony_ci		typeof(fwvalue) _ret_ = fwvalue;		\
878c2ecf20Sopenharmony_ci		if ((flags) & (field))				\
888c2ecf20Sopenharmony_ci			_ret_ = dmivalue;			\
898c2ecf20Sopenharmony_ci		else if ((fwvalue) == 0)			\
908c2ecf20Sopenharmony_ci			_ret_ = dmivalue;			\
918c2ecf20Sopenharmony_ci		_ret_;						\
928c2ecf20Sopenharmony_ci	})
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistatic int __init efifb_set_system(const struct dmi_system_id *id)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci	struct efifb_dmi_info *info = id->driver_data;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	if (info->base == 0 && info->height == 0 && info->width == 0 &&
998c2ecf20Sopenharmony_ci	    info->stride == 0)
1008c2ecf20Sopenharmony_ci		return 0;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	/* Trust the bootloader over the DMI tables */
1038c2ecf20Sopenharmony_ci	if (screen_info.lfb_base == 0) {
1048c2ecf20Sopenharmony_ci#if defined(CONFIG_PCI)
1058c2ecf20Sopenharmony_ci		struct pci_dev *dev = NULL;
1068c2ecf20Sopenharmony_ci		int found_bar = 0;
1078c2ecf20Sopenharmony_ci#endif
1088c2ecf20Sopenharmony_ci		if (info->base) {
1098c2ecf20Sopenharmony_ci			screen_info.lfb_base = choose_value(info->base,
1108c2ecf20Sopenharmony_ci				screen_info.lfb_base, OVERRIDE_BASE,
1118c2ecf20Sopenharmony_ci				info->flags);
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#if defined(CONFIG_PCI)
1148c2ecf20Sopenharmony_ci			/* make sure that the address in the table is actually
1158c2ecf20Sopenharmony_ci			 * on a VGA device's PCI BAR */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci			for_each_pci_dev(dev) {
1188c2ecf20Sopenharmony_ci				int i;
1198c2ecf20Sopenharmony_ci				if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
1208c2ecf20Sopenharmony_ci					continue;
1218c2ecf20Sopenharmony_ci				for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
1228c2ecf20Sopenharmony_ci					resource_size_t start, end;
1238c2ecf20Sopenharmony_ci					unsigned long flags;
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci					flags = pci_resource_flags(dev, i);
1268c2ecf20Sopenharmony_ci					if (!(flags & IORESOURCE_MEM))
1278c2ecf20Sopenharmony_ci						continue;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci					if (flags & IORESOURCE_UNSET)
1308c2ecf20Sopenharmony_ci						continue;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci					if (pci_resource_len(dev, i) == 0)
1338c2ecf20Sopenharmony_ci						continue;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci					start = pci_resource_start(dev, i);
1368c2ecf20Sopenharmony_ci					end = pci_resource_end(dev, i);
1378c2ecf20Sopenharmony_ci					if (screen_info.lfb_base >= start &&
1388c2ecf20Sopenharmony_ci					    screen_info.lfb_base < end) {
1398c2ecf20Sopenharmony_ci						found_bar = 1;
1408c2ecf20Sopenharmony_ci						break;
1418c2ecf20Sopenharmony_ci					}
1428c2ecf20Sopenharmony_ci				}
1438c2ecf20Sopenharmony_ci			}
1448c2ecf20Sopenharmony_ci			if (!found_bar)
1458c2ecf20Sopenharmony_ci				screen_info.lfb_base = 0;
1468c2ecf20Sopenharmony_ci#endif
1478c2ecf20Sopenharmony_ci		}
1488c2ecf20Sopenharmony_ci	}
1498c2ecf20Sopenharmony_ci	if (screen_info.lfb_base) {
1508c2ecf20Sopenharmony_ci		screen_info.lfb_linelength = choose_value(info->stride,
1518c2ecf20Sopenharmony_ci			screen_info.lfb_linelength, OVERRIDE_STRIDE,
1528c2ecf20Sopenharmony_ci			info->flags);
1538c2ecf20Sopenharmony_ci		screen_info.lfb_width = choose_value(info->width,
1548c2ecf20Sopenharmony_ci			screen_info.lfb_width, OVERRIDE_WIDTH,
1558c2ecf20Sopenharmony_ci			info->flags);
1568c2ecf20Sopenharmony_ci		screen_info.lfb_height = choose_value(info->height,
1578c2ecf20Sopenharmony_ci			screen_info.lfb_height, OVERRIDE_HEIGHT,
1588c2ecf20Sopenharmony_ci			info->flags);
1598c2ecf20Sopenharmony_ci		if (screen_info.orig_video_isVGA == 0)
1608c2ecf20Sopenharmony_ci			screen_info.orig_video_isVGA = VIDEO_TYPE_EFI;
1618c2ecf20Sopenharmony_ci	} else {
1628c2ecf20Sopenharmony_ci		screen_info.lfb_linelength = 0;
1638c2ecf20Sopenharmony_ci		screen_info.lfb_width = 0;
1648c2ecf20Sopenharmony_ci		screen_info.lfb_height = 0;
1658c2ecf20Sopenharmony_ci		screen_info.orig_video_isVGA = 0;
1668c2ecf20Sopenharmony_ci		return 0;
1678c2ecf20Sopenharmony_ci	}
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	printk(KERN_INFO "efifb: dmi detected %s - framebuffer at 0x%08x "
1708c2ecf20Sopenharmony_ci			 "(%dx%d, stride %d)\n", id->ident,
1718c2ecf20Sopenharmony_ci			 screen_info.lfb_base, screen_info.lfb_width,
1728c2ecf20Sopenharmony_ci			 screen_info.lfb_height, screen_info.lfb_linelength);
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	return 1;
1758c2ecf20Sopenharmony_ci}
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid)		\
1788c2ecf20Sopenharmony_ci	{							\
1798c2ecf20Sopenharmony_ci		efifb_set_system,				\
1808c2ecf20Sopenharmony_ci		name,						\
1818c2ecf20Sopenharmony_ci		{						\
1828c2ecf20Sopenharmony_ci			DMI_MATCH(DMI_BIOS_VENDOR, vendor),	\
1838c2ecf20Sopenharmony_ci			DMI_MATCH(DMI_PRODUCT_NAME, name)	\
1848c2ecf20Sopenharmony_ci		},						\
1858c2ecf20Sopenharmony_ci		&efifb_dmi_list[enumid]				\
1868c2ecf20Sopenharmony_ci	}
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cistatic const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
1898c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17),
1908c2ecf20Sopenharmony_ci	/* At least one of these two will be right; maybe both? */
1918c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20),
1928c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac5,1", M_I20),
1938c2ecf20Sopenharmony_ci	/* At least one of these two will be right; maybe both? */
1948c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac6,1", M_I24),
1958c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac6,1", M_I24),
1968c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR),
1978c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac8,1", M_I24_8_1),
1988c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac10,1", M_I24_10_1),
1998c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac11,1", M_I27_11_1),
2008c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI),
2018c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini3,1", M_MINI_3_1),
2028c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini4,1", M_MINI_4_1),
2038c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB),
2048c2ecf20Sopenharmony_ci	/* At least one of these two will be right; maybe both? */
2058c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook2,1", M_MB),
2068c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook2,1", M_MB),
2078c2ecf20Sopenharmony_ci	/* At least one of these two will be right; maybe both? */
2088c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook3,1", M_MB),
2098c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook3,1", M_MB),
2108c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook4,1", M_MB),
2118c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook5,1", M_MB_5_1),
2128c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook6,1", M_MB_6_1),
2138c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook7,1", M_MB_7_1),
2148c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA),
2158c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir3,1", M_MBA_3),
2168c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP),
2178c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2),
2188c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,2", M_MBP_2_2),
2198c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2),
2208c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR),
2218c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR),
2228c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4),
2238c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1),
2248c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,2", M_MBP_5_2),
2258c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,3", M_MBP_5_3),
2268c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,1", M_MBP_6_1),
2278c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,2", M_MBP_6_2),
2288c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro7,1", M_MBP_7_1),
2298c2ecf20Sopenharmony_ci	EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro8,2", M_MBP_8_2),
2308c2ecf20Sopenharmony_ci	{},
2318c2ecf20Sopenharmony_ci};
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci/*
2348c2ecf20Sopenharmony_ci * Some devices have a portrait LCD but advertise a landscape resolution (and
2358c2ecf20Sopenharmony_ci * pitch). We simply swap width and height for these devices so that we can
2368c2ecf20Sopenharmony_ci * correctly deal with some of them coming with multiple resolutions.
2378c2ecf20Sopenharmony_ci */
2388c2ecf20Sopenharmony_cistatic const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
2398c2ecf20Sopenharmony_ci	{
2408c2ecf20Sopenharmony_ci		/*
2418c2ecf20Sopenharmony_ci		 * Lenovo MIIX310-10ICR, only some batches have the troublesome
2428c2ecf20Sopenharmony_ci		 * 800x1280 portrait screen. Luckily the portrait version has
2438c2ecf20Sopenharmony_ci		 * its own BIOS version, so we match on that.
2448c2ecf20Sopenharmony_ci		 */
2458c2ecf20Sopenharmony_ci		.matches = {
2468c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2478c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"),
2488c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1HCN44WW"),
2498c2ecf20Sopenharmony_ci		},
2508c2ecf20Sopenharmony_ci	},
2518c2ecf20Sopenharmony_ci	{
2528c2ecf20Sopenharmony_ci		/* Lenovo MIIX 320-10ICR with 800x1280 portrait screen */
2538c2ecf20Sopenharmony_ci		.matches = {
2548c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2558c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
2568c2ecf20Sopenharmony_ci					"Lenovo MIIX 320-10ICR"),
2578c2ecf20Sopenharmony_ci		},
2588c2ecf20Sopenharmony_ci	},
2598c2ecf20Sopenharmony_ci	{
2608c2ecf20Sopenharmony_ci		/* Lenovo D330 with 800x1280 or 1200x1920 portrait screen */
2618c2ecf20Sopenharmony_ci		.matches = {
2628c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2638c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
2648c2ecf20Sopenharmony_ci					"Lenovo ideapad D330-10IGM"),
2658c2ecf20Sopenharmony_ci		},
2668c2ecf20Sopenharmony_ci	},
2678c2ecf20Sopenharmony_ci	{
2688c2ecf20Sopenharmony_ci		/* Lenovo IdeaPad Duet 3 10IGL5 with 1200x1920 portrait screen */
2698c2ecf20Sopenharmony_ci		.matches = {
2708c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2718c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
2728c2ecf20Sopenharmony_ci					"IdeaPad Duet 3 10IGL5"),
2738c2ecf20Sopenharmony_ci		},
2748c2ecf20Sopenharmony_ci	},
2758c2ecf20Sopenharmony_ci	{
2768c2ecf20Sopenharmony_ci		/* Lenovo Yoga Book X91F / X91L */
2778c2ecf20Sopenharmony_ci		.matches = {
2788c2ecf20Sopenharmony_ci			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2798c2ecf20Sopenharmony_ci			/* Non exact match to match F + L versions */
2808c2ecf20Sopenharmony_ci			DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"),
2818c2ecf20Sopenharmony_ci		},
2828c2ecf20Sopenharmony_ci	},
2838c2ecf20Sopenharmony_ci	{},
2848c2ecf20Sopenharmony_ci};
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci__init void sysfb_apply_efi_quirks(void)
2878c2ecf20Sopenharmony_ci{
2888c2ecf20Sopenharmony_ci	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI ||
2898c2ecf20Sopenharmony_ci	    !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
2908c2ecf20Sopenharmony_ci		dmi_check_system(efifb_dmi_system_table);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI &&
2938c2ecf20Sopenharmony_ci	    dmi_check_system(efifb_dmi_swap_width_height)) {
2948c2ecf20Sopenharmony_ci		u16 temp = screen_info.lfb_width;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci		screen_info.lfb_width = screen_info.lfb_height;
2978c2ecf20Sopenharmony_ci		screen_info.lfb_height = temp;
2988c2ecf20Sopenharmony_ci		screen_info.lfb_linelength = 4 * screen_info.lfb_width;
2998c2ecf20Sopenharmony_ci	}
3008c2ecf20Sopenharmony_ci}
301