Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: sysfb: move EFI quirks from efifb to sysfb

The EFI FB quirks from efifb.c are useful for simple-framebuffer devices
as well. Apply them by default so we can convert efifb.c to use
efi-framebuffer platform devices.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Link: http://lkml.kernel.org/r/1375445127-15480-5-git-send-email-dh.herrmann@gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

David Herrmann and committed by
H. Peter Anvin
2995e506 e3263ab3

+282 -227
+57
arch/x86/include/asm/sysfb.h
··· 15 15 #include <linux/platform_data/simplefb.h> 16 16 #include <linux/screen_info.h> 17 17 18 + enum { 19 + M_I17, /* 17-Inch iMac */ 20 + M_I20, /* 20-Inch iMac */ 21 + M_I20_SR, /* 20-Inch iMac (Santa Rosa) */ 22 + M_I24, /* 24-Inch iMac */ 23 + M_I24_8_1, /* 24-Inch iMac, 8,1th gen */ 24 + M_I24_10_1, /* 24-Inch iMac, 10,1th gen */ 25 + M_I27_11_1, /* 27-Inch iMac, 11,1th gen */ 26 + M_MINI, /* Mac Mini */ 27 + M_MINI_3_1, /* Mac Mini, 3,1th gen */ 28 + M_MINI_4_1, /* Mac Mini, 4,1th gen */ 29 + M_MB, /* MacBook */ 30 + M_MB_2, /* MacBook, 2nd rev. */ 31 + M_MB_3, /* MacBook, 3rd rev. */ 32 + M_MB_5_1, /* MacBook, 5th rev. */ 33 + M_MB_6_1, /* MacBook, 6th rev. */ 34 + M_MB_7_1, /* MacBook, 7th rev. */ 35 + M_MB_SR, /* MacBook, 2nd gen, (Santa Rosa) */ 36 + M_MBA, /* MacBook Air */ 37 + M_MBA_3, /* Macbook Air, 3rd rev */ 38 + M_MBP, /* MacBook Pro */ 39 + M_MBP_2, /* MacBook Pro 2nd gen */ 40 + M_MBP_2_2, /* MacBook Pro 2,2nd gen */ 41 + M_MBP_SR, /* MacBook Pro (Santa Rosa) */ 42 + M_MBP_4, /* MacBook Pro, 4th gen */ 43 + M_MBP_5_1, /* MacBook Pro, 5,1th gen */ 44 + M_MBP_5_2, /* MacBook Pro, 5,2th gen */ 45 + M_MBP_5_3, /* MacBook Pro, 5,3rd gen */ 46 + M_MBP_6_1, /* MacBook Pro, 6,1th gen */ 47 + M_MBP_6_2, /* MacBook Pro, 6,2th gen */ 48 + M_MBP_7_1, /* MacBook Pro, 7,1th gen */ 49 + M_MBP_8_2, /* MacBook Pro, 8,2nd gen */ 50 + M_UNKNOWN /* placeholder */ 51 + }; 52 + 53 + struct efifb_dmi_info { 54 + char *optname; 55 + unsigned long base; 56 + int stride; 57 + int width; 58 + int height; 59 + int flags; 60 + }; 61 + 62 + #ifdef CONFIG_EFI 63 + 64 + extern struct efifb_dmi_info efifb_dmi_list[]; 65 + void sysfb_apply_efi_quirks(void); 66 + 67 + #else /* CONFIG_EFI */ 68 + 69 + static inline void sysfb_apply_efi_quirks(void) 70 + { 71 + } 72 + 73 + #endif /* CONFIG_EFI */ 74 + 18 75 #ifdef CONFIG_X86_SYSFB 19 76 20 77 bool parse_mode(const struct screen_info *si,
+1
arch/x86/kernel/Makefile
··· 105 105 obj-$(CONFIG_UPROBES) += uprobes.o 106 106 obj-y += sysfb.o 107 107 obj-$(CONFIG_X86_SYSFB) += sysfb_simplefb.o 108 + obj-$(CONFIG_EFI) += sysfb_efi.o 108 109 109 110 obj-$(CONFIG_PERF_EVENTS) += perf_regs.o 110 111 obj-$(CONFIG_TRACING) += tracepoint.o
+3
arch/x86/kernel/sysfb.c
··· 47 47 bool compatible; 48 48 int ret; 49 49 50 + sysfb_apply_efi_quirks(); 51 + 50 52 /* try to create a simple-framebuffer device */ 51 53 compatible = parse_mode(si, &mode); 52 54 if (compatible) { ··· 70 68 return IS_ERR(pd) ? PTR_ERR(pd) : 0; 71 69 } 72 70 71 + /* must execute after PCI subsystem for EFI quirks */ 73 72 device_initcall(sysfb_init);
+214
arch/x86/kernel/sysfb_efi.c
··· 1 + /* 2 + * Generic System Framebuffers on x86 3 + * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com> 4 + * 5 + * EFI Quirks Copyright (c) 2006 Edgar Hucek <gimli@dark-green.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the Free 9 + * Software Foundation; either version 2 of the License, or (at your option) 10 + * any later version. 11 + */ 12 + 13 + /* 14 + * EFI Quirks 15 + * Several EFI systems do not correctly advertise their boot framebuffers. 16 + * Hence, we use this static table of known broken machines and fix up the 17 + * information so framebuffer drivers can load corectly. 18 + */ 19 + 20 + #include <linux/dmi.h> 21 + #include <linux/err.h> 22 + #include <linux/init.h> 23 + #include <linux/kernel.h> 24 + #include <linux/mm.h> 25 + #include <linux/pci.h> 26 + #include <linux/screen_info.h> 27 + #include <video/vga.h> 28 + #include <asm/sysfb.h> 29 + 30 + enum { 31 + OVERRIDE_NONE = 0x0, 32 + OVERRIDE_BASE = 0x1, 33 + OVERRIDE_STRIDE = 0x2, 34 + OVERRIDE_HEIGHT = 0x4, 35 + OVERRIDE_WIDTH = 0x8, 36 + }; 37 + 38 + struct efifb_dmi_info efifb_dmi_list[] = { 39 + [M_I17] = { "i17", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 40 + [M_I20] = { "i20", 0x80010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE }, /* guess */ 41 + [M_I20_SR] = { "imac7", 0x40010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE }, 42 + [M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, /* guess */ 43 + [M_I24_8_1] = { "imac8", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 44 + [M_I24_10_1] = { "imac10", 0xc0010000, 2048 * 4, 1920, 1080, OVERRIDE_NONE }, 45 + [M_I27_11_1] = { "imac11", 0xc0010000, 2560 * 4, 2560, 1440, OVERRIDE_NONE }, 46 + [M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768, OVERRIDE_NONE }, 47 + [M_MINI_3_1] = { "mini31", 0x40010000, 1024 * 4, 1024, 768, OVERRIDE_NONE }, 48 + [M_MINI_4_1] = { "mini41", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 49 + [M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 50 + [M_MB_5_1] = { "macbook51", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 51 + [M_MB_6_1] = { "macbook61", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 52 + [M_MB_7_1] = { "macbook71", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 53 + [M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 54 + /* 11" Macbook Air 3,1 passes the wrong stride */ 55 + [M_MBA_3] = { "mba3", 0, 2048 * 4, 0, 0, OVERRIDE_STRIDE }, 56 + [M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 57 + [M_MBP_2] = { "mbp2", 0, 0, 0, 0, OVERRIDE_NONE }, /* placeholder */ 58 + [M_MBP_2_2] = { "mbp22", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 59 + [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 60 + [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 61 + [M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 62 + [M_MBP_5_2] = { "mbp52", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 63 + [M_MBP_5_3] = { "mbp53", 0xd0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 64 + [M_MBP_6_1] = { "mbp61", 0x90030000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 65 + [M_MBP_6_2] = { "mbp62", 0x90030000, 2048 * 4, 1680, 1050, OVERRIDE_NONE }, 66 + [M_MBP_7_1] = { "mbp71", 0xc0010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 67 + [M_MBP_8_2] = { "mbp82", 0x90010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 68 + [M_UNKNOWN] = { NULL, 0, 0, 0, 0, OVERRIDE_NONE } 69 + }; 70 + 71 + #define choose_value(dmivalue, fwvalue, field, flags) ({ \ 72 + typeof(fwvalue) _ret_ = fwvalue; \ 73 + if ((flags) & (field)) \ 74 + _ret_ = dmivalue; \ 75 + else if ((fwvalue) == 0) \ 76 + _ret_ = dmivalue; \ 77 + _ret_; \ 78 + }) 79 + 80 + static int __init efifb_set_system(const struct dmi_system_id *id) 81 + { 82 + struct efifb_dmi_info *info = id->driver_data; 83 + 84 + if (info->base == 0 && info->height == 0 && info->width == 0 && 85 + info->stride == 0) 86 + return 0; 87 + 88 + /* Trust the bootloader over the DMI tables */ 89 + if (screen_info.lfb_base == 0) { 90 + #if defined(CONFIG_PCI) 91 + struct pci_dev *dev = NULL; 92 + int found_bar = 0; 93 + #endif 94 + if (info->base) { 95 + screen_info.lfb_base = choose_value(info->base, 96 + screen_info.lfb_base, OVERRIDE_BASE, 97 + info->flags); 98 + 99 + #if defined(CONFIG_PCI) 100 + /* make sure that the address in the table is actually 101 + * on a VGA device's PCI BAR */ 102 + 103 + for_each_pci_dev(dev) { 104 + int i; 105 + if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) 106 + continue; 107 + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 108 + resource_size_t start, end; 109 + 110 + start = pci_resource_start(dev, i); 111 + if (start == 0) 112 + break; 113 + end = pci_resource_end(dev, i); 114 + if (screen_info.lfb_base >= start && 115 + screen_info.lfb_base < end) { 116 + found_bar = 1; 117 + } 118 + } 119 + } 120 + if (!found_bar) 121 + screen_info.lfb_base = 0; 122 + #endif 123 + } 124 + } 125 + if (screen_info.lfb_base) { 126 + screen_info.lfb_linelength = choose_value(info->stride, 127 + screen_info.lfb_linelength, OVERRIDE_STRIDE, 128 + info->flags); 129 + screen_info.lfb_width = choose_value(info->width, 130 + screen_info.lfb_width, OVERRIDE_WIDTH, 131 + info->flags); 132 + screen_info.lfb_height = choose_value(info->height, 133 + screen_info.lfb_height, OVERRIDE_HEIGHT, 134 + info->flags); 135 + if (screen_info.orig_video_isVGA == 0) 136 + screen_info.orig_video_isVGA = VIDEO_TYPE_EFI; 137 + } else { 138 + screen_info.lfb_linelength = 0; 139 + screen_info.lfb_width = 0; 140 + screen_info.lfb_height = 0; 141 + screen_info.orig_video_isVGA = 0; 142 + return 0; 143 + } 144 + 145 + printk(KERN_INFO "efifb: dmi detected %s - framebuffer at 0x%08x " 146 + "(%dx%d, stride %d)\n", id->ident, 147 + screen_info.lfb_base, screen_info.lfb_width, 148 + screen_info.lfb_height, screen_info.lfb_linelength); 149 + 150 + return 1; 151 + } 152 + 153 + #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \ 154 + { \ 155 + efifb_set_system, \ 156 + name, \ 157 + { \ 158 + DMI_MATCH(DMI_BIOS_VENDOR, vendor), \ 159 + DMI_MATCH(DMI_PRODUCT_NAME, name) \ 160 + }, \ 161 + &efifb_dmi_list[enumid] \ 162 + } 163 + 164 + static const struct dmi_system_id efifb_dmi_system_table[] __initconst = { 165 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17), 166 + /* At least one of these two will be right; maybe both? */ 167 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20), 168 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac5,1", M_I20), 169 + /* At least one of these two will be right; maybe both? */ 170 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac6,1", M_I24), 171 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac6,1", M_I24), 172 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR), 173 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac8,1", M_I24_8_1), 174 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac10,1", M_I24_10_1), 175 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac11,1", M_I27_11_1), 176 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI), 177 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini3,1", M_MINI_3_1), 178 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini4,1", M_MINI_4_1), 179 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB), 180 + /* At least one of these two will be right; maybe both? */ 181 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook2,1", M_MB), 182 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook2,1", M_MB), 183 + /* At least one of these two will be right; maybe both? */ 184 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook3,1", M_MB), 185 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook3,1", M_MB), 186 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook4,1", M_MB), 187 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook5,1", M_MB_5_1), 188 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook6,1", M_MB_6_1), 189 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook7,1", M_MB_7_1), 190 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA), 191 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir3,1", M_MBA_3), 192 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP), 193 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2), 194 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,2", M_MBP_2_2), 195 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2), 196 + EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR), 197 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR), 198 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4), 199 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1), 200 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,2", M_MBP_5_2), 201 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,3", M_MBP_5_3), 202 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,1", M_MBP_6_1), 203 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,2", M_MBP_6_2), 204 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro7,1", M_MBP_7_1), 205 + EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro8,2", M_MBP_8_2), 206 + {}, 207 + }; 208 + 209 + __init void sysfb_apply_efi_quirks(void) 210 + { 211 + if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || 212 + !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS)) 213 + dmi_check_system(efifb_dmi_system_table); 214 + }
+7 -227
drivers/video/efifb.c
··· 15 15 #include <linux/dmi.h> 16 16 #include <linux/pci.h> 17 17 #include <video/vga.h> 18 + #include <asm/sysfb.h> 18 19 19 20 static bool request_mem_succeeded = false; 20 21 ··· 38 37 .accel = FB_ACCEL_NONE, 39 38 .visual = FB_VISUAL_TRUECOLOR, 40 39 }; 41 - 42 - enum { 43 - M_I17, /* 17-Inch iMac */ 44 - M_I20, /* 20-Inch iMac */ 45 - M_I20_SR, /* 20-Inch iMac (Santa Rosa) */ 46 - M_I24, /* 24-Inch iMac */ 47 - M_I24_8_1, /* 24-Inch iMac, 8,1th gen */ 48 - M_I24_10_1, /* 24-Inch iMac, 10,1th gen */ 49 - M_I27_11_1, /* 27-Inch iMac, 11,1th gen */ 50 - M_MINI, /* Mac Mini */ 51 - M_MINI_3_1, /* Mac Mini, 3,1th gen */ 52 - M_MINI_4_1, /* Mac Mini, 4,1th gen */ 53 - M_MB, /* MacBook */ 54 - M_MB_2, /* MacBook, 2nd rev. */ 55 - M_MB_3, /* MacBook, 3rd rev. */ 56 - M_MB_5_1, /* MacBook, 5th rev. */ 57 - M_MB_6_1, /* MacBook, 6th rev. */ 58 - M_MB_7_1, /* MacBook, 7th rev. */ 59 - M_MB_SR, /* MacBook, 2nd gen, (Santa Rosa) */ 60 - M_MBA, /* MacBook Air */ 61 - M_MBA_3, /* Macbook Air, 3rd rev */ 62 - M_MBP, /* MacBook Pro */ 63 - M_MBP_2, /* MacBook Pro 2nd gen */ 64 - M_MBP_2_2, /* MacBook Pro 2,2nd gen */ 65 - M_MBP_SR, /* MacBook Pro (Santa Rosa) */ 66 - M_MBP_4, /* MacBook Pro, 4th gen */ 67 - M_MBP_5_1, /* MacBook Pro, 5,1th gen */ 68 - M_MBP_5_2, /* MacBook Pro, 5,2th gen */ 69 - M_MBP_5_3, /* MacBook Pro, 5,3rd gen */ 70 - M_MBP_6_1, /* MacBook Pro, 6,1th gen */ 71 - M_MBP_6_2, /* MacBook Pro, 6,2th gen */ 72 - M_MBP_7_1, /* MacBook Pro, 7,1th gen */ 73 - M_MBP_8_2, /* MacBook Pro, 8,2nd gen */ 74 - M_UNKNOWN /* placeholder */ 75 - }; 76 - 77 - #define OVERRIDE_NONE 0x0 78 - #define OVERRIDE_BASE 0x1 79 - #define OVERRIDE_STRIDE 0x2 80 - #define OVERRIDE_HEIGHT 0x4 81 - #define OVERRIDE_WIDTH 0x8 82 - 83 - static struct efifb_dmi_info { 84 - char *optname; 85 - unsigned long base; 86 - int stride; 87 - int width; 88 - int height; 89 - int flags; 90 - } dmi_list[] __initdata = { 91 - [M_I17] = { "i17", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 92 - [M_I20] = { "i20", 0x80010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE }, /* guess */ 93 - [M_I20_SR] = { "imac7", 0x40010000, 1728 * 4, 1680, 1050, OVERRIDE_NONE }, 94 - [M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, /* guess */ 95 - [M_I24_8_1] = { "imac8", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 96 - [M_I24_10_1] = { "imac10", 0xc0010000, 2048 * 4, 1920, 1080, OVERRIDE_NONE }, 97 - [M_I27_11_1] = { "imac11", 0xc0010000, 2560 * 4, 2560, 1440, OVERRIDE_NONE }, 98 - [M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768, OVERRIDE_NONE }, 99 - [M_MINI_3_1] = { "mini31", 0x40010000, 1024 * 4, 1024, 768, OVERRIDE_NONE }, 100 - [M_MINI_4_1] = { "mini41", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 101 - [M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 102 - [M_MB_5_1] = { "macbook51", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 103 - [M_MB_6_1] = { "macbook61", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 104 - [M_MB_7_1] = { "macbook71", 0x80010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 105 - [M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 106 - /* 11" Macbook Air 3,1 passes the wrong stride */ 107 - [M_MBA_3] = { "mba3", 0, 2048 * 4, 0, 0, OVERRIDE_STRIDE }, 108 - [M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 109 - [M_MBP_2] = { "mbp2", 0, 0, 0, 0, OVERRIDE_NONE }, /* placeholder */ 110 - [M_MBP_2_2] = { "mbp22", 0x80010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 111 - [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 112 - [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 113 - [M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 114 - [M_MBP_5_2] = { "mbp52", 0xc0010000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 115 - [M_MBP_5_3] = { "mbp53", 0xd0010000, 2048 * 4, 1440, 900, OVERRIDE_NONE }, 116 - [M_MBP_6_1] = { "mbp61", 0x90030000, 2048 * 4, 1920, 1200, OVERRIDE_NONE }, 117 - [M_MBP_6_2] = { "mbp62", 0x90030000, 2048 * 4, 1680, 1050, OVERRIDE_NONE }, 118 - [M_MBP_7_1] = { "mbp71", 0xc0010000, 2048 * 4, 1280, 800, OVERRIDE_NONE }, 119 - [M_MBP_8_2] = { "mbp82", 0x90010000, 1472 * 4, 1440, 900, OVERRIDE_NONE }, 120 - [M_UNKNOWN] = { NULL, 0, 0, 0, 0, OVERRIDE_NONE } 121 - }; 122 - 123 - static int set_system(const struct dmi_system_id *id); 124 - 125 - #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \ 126 - { set_system, name, { \ 127 - DMI_MATCH(DMI_BIOS_VENDOR, vendor), \ 128 - DMI_MATCH(DMI_PRODUCT_NAME, name) }, \ 129 - &dmi_list[enumid] } 130 - 131 - static const struct dmi_system_id dmi_system_table[] __initconst = { 132 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17), 133 - /* At least one of these two will be right; maybe both? */ 134 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20), 135 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac5,1", M_I20), 136 - /* At least one of these two will be right; maybe both? */ 137 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac6,1", M_I24), 138 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac6,1", M_I24), 139 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR), 140 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac8,1", M_I24_8_1), 141 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac10,1", M_I24_10_1), 142 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac11,1", M_I27_11_1), 143 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI), 144 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini3,1", M_MINI_3_1), 145 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini4,1", M_MINI_4_1), 146 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB), 147 - /* At least one of these two will be right; maybe both? */ 148 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook2,1", M_MB), 149 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook2,1", M_MB), 150 - /* At least one of these two will be right; maybe both? */ 151 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook3,1", M_MB), 152 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook3,1", M_MB), 153 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook4,1", M_MB), 154 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook5,1", M_MB_5_1), 155 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook6,1", M_MB_6_1), 156 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook7,1", M_MB_7_1), 157 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA), 158 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir3,1", M_MBA_3), 159 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP), 160 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2), 161 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,2", M_MBP_2_2), 162 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2), 163 - EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR), 164 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR), 165 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4), 166 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1), 167 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,2", M_MBP_5_2), 168 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,3", M_MBP_5_3), 169 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,1", M_MBP_6_1), 170 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,2", M_MBP_6_2), 171 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro7,1", M_MBP_7_1), 172 - EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro8,2", M_MBP_8_2), 173 - {}, 174 - }; 175 - 176 - #define choose_value(dmivalue, fwvalue, field, flags) ({ \ 177 - typeof(fwvalue) _ret_ = fwvalue; \ 178 - if ((flags) & (field)) \ 179 - _ret_ = dmivalue; \ 180 - else if ((fwvalue) == 0) \ 181 - _ret_ = dmivalue; \ 182 - _ret_; \ 183 - }) 184 - 185 - static int set_system(const struct dmi_system_id *id) 186 - { 187 - struct efifb_dmi_info *info = id->driver_data; 188 - 189 - if (info->base == 0 && info->height == 0 && info->width == 0 190 - && info->stride == 0) 191 - return 0; 192 - 193 - /* Trust the bootloader over the DMI tables */ 194 - if (screen_info.lfb_base == 0) { 195 - #if defined(CONFIG_PCI) 196 - struct pci_dev *dev = NULL; 197 - int found_bar = 0; 198 - #endif 199 - if (info->base) { 200 - screen_info.lfb_base = choose_value(info->base, 201 - screen_info.lfb_base, OVERRIDE_BASE, 202 - info->flags); 203 - 204 - #if defined(CONFIG_PCI) 205 - /* make sure that the address in the table is actually 206 - * on a VGA device's PCI BAR */ 207 - 208 - for_each_pci_dev(dev) { 209 - int i; 210 - if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) 211 - continue; 212 - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 213 - resource_size_t start, end; 214 - 215 - start = pci_resource_start(dev, i); 216 - if (start == 0) 217 - break; 218 - end = pci_resource_end(dev, i); 219 - if (screen_info.lfb_base >= start && 220 - screen_info.lfb_base < end) { 221 - found_bar = 1; 222 - } 223 - } 224 - } 225 - if (!found_bar) 226 - screen_info.lfb_base = 0; 227 - #endif 228 - } 229 - } 230 - if (screen_info.lfb_base) { 231 - screen_info.lfb_linelength = choose_value(info->stride, 232 - screen_info.lfb_linelength, OVERRIDE_STRIDE, 233 - info->flags); 234 - screen_info.lfb_width = choose_value(info->width, 235 - screen_info.lfb_width, OVERRIDE_WIDTH, 236 - info->flags); 237 - screen_info.lfb_height = choose_value(info->height, 238 - screen_info.lfb_height, OVERRIDE_HEIGHT, 239 - info->flags); 240 - if (screen_info.orig_video_isVGA == 0) 241 - screen_info.orig_video_isVGA = VIDEO_TYPE_EFI; 242 - } else { 243 - screen_info.lfb_linelength = 0; 244 - screen_info.lfb_width = 0; 245 - screen_info.lfb_height = 0; 246 - screen_info.orig_video_isVGA = 0; 247 - return 0; 248 - } 249 - 250 - printk(KERN_INFO "efifb: dmi detected %s - framebuffer at 0x%08x " 251 - "(%dx%d, stride %d)\n", id->ident, 252 - screen_info.lfb_base, screen_info.lfb_width, 253 - screen_info.lfb_height, screen_info.lfb_linelength); 254 - 255 - 256 - return 1; 257 - } 258 40 259 41 static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green, 260 42 unsigned blue, unsigned transp, ··· 107 323 if (!*this_opt) continue; 108 324 109 325 for (i = 0; i < M_UNKNOWN; i++) { 110 - if (!strcmp(this_opt, dmi_list[i].optname) && 111 - dmi_list[i].base != 0) { 112 - screen_info.lfb_base = dmi_list[i].base; 113 - screen_info.lfb_linelength = dmi_list[i].stride; 114 - screen_info.lfb_width = dmi_list[i].width; 115 - screen_info.lfb_height = dmi_list[i].height; 326 + if (!strcmp(this_opt, efifb_dmi_list[i].optname) && 327 + efifb_dmi_list[i].base != 0) { 328 + screen_info.lfb_base = efifb_dmi_list[i].base; 329 + screen_info.lfb_linelength = efifb_dmi_list[i].stride; 330 + screen_info.lfb_width = efifb_dmi_list[i].width; 331 + screen_info.lfb_height = efifb_dmi_list[i].height; 116 332 } 117 333 } 118 334 if (!strncmp(this_opt, "base:", 5)) ··· 336 552 { 337 553 int ret; 338 554 char *option = NULL; 339 - 340 - if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || 341 - !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS)) 342 - dmi_check_system(dmi_system_table); 343 555 344 556 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) 345 557 return -ENODEV;