efifb.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /*
  2. * Framebuffer driver for EFI/UEFI based system
  3. *
  4. * (c) 2006 Edgar Hucek <gimli@dark-green.com>
  5. * Original efi driver written by Gerd Knorr <kraxel@goldbach.in-berlin.de>
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/fb.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/screen_info.h>
  14. #include <linux/dmi.h>
  15. #include <linux/pci.h>
  16. #include <video/vga.h>
  17. static struct fb_var_screeninfo efifb_defined __devinitdata = {
  18. .activate = FB_ACTIVATE_NOW,
  19. .height = -1,
  20. .width = -1,
  21. .right_margin = 32,
  22. .upper_margin = 16,
  23. .lower_margin = 4,
  24. .vsync_len = 4,
  25. .vmode = FB_VMODE_NONINTERLACED,
  26. };
  27. static struct fb_fix_screeninfo efifb_fix __devinitdata = {
  28. .id = "EFI VGA",
  29. .type = FB_TYPE_PACKED_PIXELS,
  30. .accel = FB_ACCEL_NONE,
  31. .visual = FB_VISUAL_TRUECOLOR,
  32. };
  33. enum {
  34. M_I17, /* 17-Inch iMac */
  35. M_I20, /* 20-Inch iMac */
  36. M_I20_SR, /* 20-Inch iMac (Santa Rosa) */
  37. M_I24, /* 24-Inch iMac */
  38. M_I24_8_1, /* 24-Inch iMac, 8,1th gen */
  39. M_I24_10_1, /* 24-Inch iMac, 10,1th gen */
  40. M_I27_11_1, /* 27-Inch iMac, 11,1th gen */
  41. M_MINI, /* Mac Mini */
  42. M_MINI_3_1, /* Mac Mini, 3,1th gen */
  43. M_MINI_4_1, /* Mac Mini, 4,1th gen */
  44. M_MB, /* MacBook */
  45. M_MB_2, /* MacBook, 2nd rev. */
  46. M_MB_3, /* MacBook, 3rd rev. */
  47. M_MB_5_1, /* MacBook, 5th rev. */
  48. M_MB_6_1, /* MacBook, 6th rev. */
  49. M_MB_7_1, /* MacBook, 7th rev. */
  50. M_MB_SR, /* MacBook, 2nd gen, (Santa Rosa) */
  51. M_MBA, /* MacBook Air */
  52. M_MBP, /* MacBook Pro */
  53. M_MBP_2, /* MacBook Pro 2nd gen */
  54. M_MBP_2_2, /* MacBook Pro 2,2nd gen */
  55. M_MBP_SR, /* MacBook Pro (Santa Rosa) */
  56. M_MBP_4, /* MacBook Pro, 4th gen */
  57. M_MBP_5_1, /* MacBook Pro, 5,1th gen */
  58. M_MBP_5_2, /* MacBook Pro, 5,2th gen */
  59. M_MBP_5_3, /* MacBook Pro, 5,3rd gen */
  60. M_MBP_6_1, /* MacBook Pro, 6,1th gen */
  61. M_MBP_6_2, /* MacBook Pro, 6,2th gen */
  62. M_MBP_7_1, /* MacBook Pro, 7,1th gen */
  63. M_MBP_8_2, /* MacBook Pro, 8,2nd gen */
  64. M_UNKNOWN /* placeholder */
  65. };
  66. static struct efifb_dmi_info {
  67. char *optname;
  68. unsigned long base;
  69. int stride;
  70. int width;
  71. int height;
  72. } dmi_list[] __initdata = {
  73. [M_I17] = { "i17", 0x80010000, 1472 * 4, 1440, 900 },
  74. [M_I20] = { "i20", 0x80010000, 1728 * 4, 1680, 1050 }, /* guess */
  75. [M_I20_SR] = { "imac7", 0x40010000, 1728 * 4, 1680, 1050 },
  76. [M_I24] = { "i24", 0x80010000, 2048 * 4, 1920, 1200 }, /* guess */
  77. [M_I24_8_1] = { "imac8", 0xc0060000, 2048 * 4, 1920, 1200 },
  78. [M_I24_10_1] = { "imac10", 0xc0010000, 2048 * 4, 1920, 1080 },
  79. [M_I27_11_1] = { "imac11", 0xc0010000, 2560 * 4, 2560, 1440 },
  80. [M_MINI]= { "mini", 0x80000000, 2048 * 4, 1024, 768 },
  81. [M_MINI_3_1] = { "mini31", 0x40010000, 1024 * 4, 1024, 768 },
  82. [M_MINI_4_1] = { "mini41", 0xc0010000, 2048 * 4, 1920, 1200 },
  83. [M_MB] = { "macbook", 0x80000000, 2048 * 4, 1280, 800 },
  84. [M_MB_5_1] = { "macbook51", 0x80010000, 2048 * 4, 1280, 800 },
  85. [M_MB_6_1] = { "macbook61", 0x80010000, 2048 * 4, 1280, 800 },
  86. [M_MB_7_1] = { "macbook71", 0x80010000, 2048 * 4, 1280, 800 },
  87. [M_MBA] = { "mba", 0x80000000, 2048 * 4, 1280, 800 },
  88. [M_MBP] = { "mbp", 0x80010000, 1472 * 4, 1440, 900 },
  89. [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */
  90. [M_MBP_2_2] = { "mbp22", 0x80010000, 1472 * 4, 1440, 900 },
  91. [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 },
  92. [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 },
  93. [M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900 },
  94. [M_MBP_5_2] = { "mbp52", 0xc0010000, 2048 * 4, 1920, 1200 },
  95. [M_MBP_5_3] = { "mbp53", 0xd0010000, 2048 * 4, 1440, 900 },
  96. [M_MBP_6_1] = { "mbp61", 0x90030000, 2048 * 4, 1920, 1200 },
  97. [M_MBP_6_2] = { "mbp62", 0x90030000, 2048 * 4, 1680, 1050 },
  98. [M_MBP_7_1] = { "mbp71", 0xc0010000, 2048 * 4, 1280, 800 },
  99. [M_MBP_8_2] = { "mbp82", 0x90010000, 1472 * 4, 1440, 900 },
  100. [M_UNKNOWN] = { NULL, 0, 0, 0, 0 }
  101. };
  102. static int set_system(const struct dmi_system_id *id);
  103. #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \
  104. { set_system, name, { \
  105. DMI_MATCH(DMI_BIOS_VENDOR, vendor), \
  106. DMI_MATCH(DMI_PRODUCT_NAME, name) }, \
  107. &dmi_list[enumid] }
  108. static const struct dmi_system_id dmi_system_table[] __initconst = {
  109. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17),
  110. /* At least one of these two will be right; maybe both? */
  111. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20),
  112. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac5,1", M_I20),
  113. /* At least one of these two will be right; maybe both? */
  114. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac6,1", M_I24),
  115. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac6,1", M_I24),
  116. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac7,1", M_I20_SR),
  117. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac8,1", M_I24_8_1),
  118. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac10,1", M_I24_10_1),
  119. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "iMac11,1", M_I27_11_1),
  120. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "Macmini1,1", M_MINI),
  121. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini3,1", M_MINI_3_1),
  122. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "Macmini4,1", M_MINI_4_1),
  123. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook1,1", M_MB),
  124. /* At least one of these two will be right; maybe both? */
  125. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook2,1", M_MB),
  126. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook2,1", M_MB),
  127. /* At least one of these two will be right; maybe both? */
  128. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBook3,1", M_MB),
  129. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook3,1", M_MB),
  130. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook4,1", M_MB),
  131. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook5,1", M_MB_5_1),
  132. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook6,1", M_MB_6_1),
  133. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBook7,1", M_MB_7_1),
  134. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookAir1,1", M_MBA),
  135. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro1,1", M_MBP),
  136. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,1", M_MBP_2),
  137. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro2,2", M_MBP_2_2),
  138. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro2,1", M_MBP_2),
  139. EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR),
  140. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR),
  141. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4),
  142. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1),
  143. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,2", M_MBP_5_2),
  144. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,3", M_MBP_5_3),
  145. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,1", M_MBP_6_1),
  146. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro6,2", M_MBP_6_2),
  147. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro7,1", M_MBP_7_1),
  148. EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro8,2", M_MBP_8_2),
  149. {},
  150. };
  151. static int set_system(const struct dmi_system_id *id)
  152. {
  153. struct efifb_dmi_info *info = id->driver_data;
  154. if (info->base == 0)
  155. return 0;
  156. printk(KERN_INFO "efifb: dmi detected %s - framebuffer at %p "
  157. "(%dx%d, stride %d)\n", id->ident,
  158. (void *)info->base, info->width, info->height,
  159. info->stride);
  160. /* Trust the bootloader over the DMI tables */
  161. if (screen_info.lfb_base == 0) {
  162. #if defined(CONFIG_PCI)
  163. struct pci_dev *dev = NULL;
  164. int found_bar = 0;
  165. #endif
  166. screen_info.lfb_base = info->base;
  167. #if defined(CONFIG_PCI)
  168. /* make sure that the address in the table is actually on a
  169. * VGA device's PCI BAR */
  170. for_each_pci_dev(dev) {
  171. int i;
  172. if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
  173. continue;
  174. for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
  175. resource_size_t start, end;
  176. start = pci_resource_start(dev, i);
  177. if (start == 0)
  178. break;
  179. end = pci_resource_end(dev, i);
  180. if (screen_info.lfb_base >= start &&
  181. screen_info.lfb_base < end) {
  182. found_bar = 1;
  183. }
  184. }
  185. }
  186. if (!found_bar)
  187. screen_info.lfb_base = 0;
  188. #endif
  189. }
  190. if (screen_info.lfb_base) {
  191. if (screen_info.lfb_linelength == 0)
  192. screen_info.lfb_linelength = info->stride;
  193. if (screen_info.lfb_width == 0)
  194. screen_info.lfb_width = info->width;
  195. if (screen_info.lfb_height == 0)
  196. screen_info.lfb_height = info->height;
  197. if (screen_info.orig_video_isVGA == 0)
  198. screen_info.orig_video_isVGA = VIDEO_TYPE_EFI;
  199. } else {
  200. screen_info.lfb_linelength = 0;
  201. screen_info.lfb_width = 0;
  202. screen_info.lfb_height = 0;
  203. screen_info.orig_video_isVGA = 0;
  204. return 0;
  205. }
  206. return 1;
  207. }
  208. static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
  209. unsigned blue, unsigned transp,
  210. struct fb_info *info)
  211. {
  212. /*
  213. * Set a single color register. The values supplied are
  214. * already rounded down to the hardware's capabilities
  215. * (according to the entries in the `var' structure). Return
  216. * != 0 for invalid regno.
  217. */
  218. if (regno >= info->cmap.len)
  219. return 1;
  220. if (regno < 16) {
  221. red >>= 8;
  222. green >>= 8;
  223. blue >>= 8;
  224. ((u32 *)(info->pseudo_palette))[regno] =
  225. (red << info->var.red.offset) |
  226. (green << info->var.green.offset) |
  227. (blue << info->var.blue.offset);
  228. }
  229. return 0;
  230. }
  231. static void efifb_destroy(struct fb_info *info)
  232. {
  233. if (info->screen_base)
  234. iounmap(info->screen_base);
  235. release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
  236. framebuffer_release(info);
  237. }
  238. static struct fb_ops efifb_ops = {
  239. .owner = THIS_MODULE,
  240. .fb_destroy = efifb_destroy,
  241. .fb_setcolreg = efifb_setcolreg,
  242. .fb_fillrect = cfb_fillrect,
  243. .fb_copyarea = cfb_copyarea,
  244. .fb_imageblit = cfb_imageblit,
  245. };
  246. static int __init efifb_setup(char *options)
  247. {
  248. char *this_opt;
  249. int i;
  250. if (!options || !*options)
  251. return 0;
  252. while ((this_opt = strsep(&options, ",")) != NULL) {
  253. if (!*this_opt) continue;
  254. for (i = 0; i < M_UNKNOWN; i++) {
  255. if (!strcmp(this_opt, dmi_list[i].optname) &&
  256. dmi_list[i].base != 0) {
  257. screen_info.lfb_base = dmi_list[i].base;
  258. screen_info.lfb_linelength = dmi_list[i].stride;
  259. screen_info.lfb_width = dmi_list[i].width;
  260. screen_info.lfb_height = dmi_list[i].height;
  261. }
  262. }
  263. if (!strncmp(this_opt, "base:", 5))
  264. screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
  265. else if (!strncmp(this_opt, "stride:", 7))
  266. screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
  267. else if (!strncmp(this_opt, "height:", 7))
  268. screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
  269. else if (!strncmp(this_opt, "width:", 6))
  270. screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
  271. }
  272. return 0;
  273. }
  274. static int __devinit efifb_probe(struct platform_device *dev)
  275. {
  276. struct fb_info *info;
  277. int err;
  278. unsigned int size_vmode;
  279. unsigned int size_remap;
  280. unsigned int size_total;
  281. int request_succeeded = 0;
  282. if (!screen_info.lfb_depth)
  283. screen_info.lfb_depth = 32;
  284. if (!screen_info.pages)
  285. screen_info.pages = 1;
  286. if (!screen_info.lfb_base) {
  287. printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
  288. return -ENODEV;
  289. }
  290. printk(KERN_INFO "efifb: probing for efifb\n");
  291. /* just assume they're all unset if any are */
  292. if (!screen_info.blue_size) {
  293. screen_info.blue_size = 8;
  294. screen_info.blue_pos = 0;
  295. screen_info.green_size = 8;
  296. screen_info.green_pos = 8;
  297. screen_info.red_size = 8;
  298. screen_info.red_pos = 16;
  299. screen_info.rsvd_size = 8;
  300. screen_info.rsvd_pos = 24;
  301. }
  302. efifb_fix.smem_start = screen_info.lfb_base;
  303. efifb_defined.bits_per_pixel = screen_info.lfb_depth;
  304. efifb_defined.xres = screen_info.lfb_width;
  305. efifb_defined.yres = screen_info.lfb_height;
  306. efifb_fix.line_length = screen_info.lfb_linelength;
  307. /* size_vmode -- that is the amount of memory needed for the
  308. * used video mode, i.e. the minimum amount of
  309. * memory we need. */
  310. size_vmode = efifb_defined.yres * efifb_fix.line_length;
  311. /* size_total -- all video memory we have. Used for
  312. * entries, ressource allocation and bounds
  313. * checking. */
  314. size_total = screen_info.lfb_size;
  315. if (size_total < size_vmode)
  316. size_total = size_vmode;
  317. /* size_remap -- the amount of video memory we are going to
  318. * use for efifb. With modern cards it is no
  319. * option to simply use size_total as that
  320. * wastes plenty of kernel address space. */
  321. size_remap = size_vmode * 2;
  322. if (size_remap > size_total)
  323. size_remap = size_total;
  324. if (size_remap % PAGE_SIZE)
  325. size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
  326. efifb_fix.smem_len = size_remap;
  327. if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
  328. request_succeeded = 1;
  329. } else {
  330. /* We cannot make this fatal. Sometimes this comes from magic
  331. spaces our resource handlers simply don't know about */
  332. printk(KERN_WARNING
  333. "efifb: cannot reserve video memory at 0x%lx\n",
  334. efifb_fix.smem_start);
  335. }
  336. info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
  337. if (!info) {
  338. printk(KERN_ERR "efifb: cannot allocate framebuffer\n");
  339. err = -ENOMEM;
  340. goto err_release_mem;
  341. }
  342. info->pseudo_palette = info->par;
  343. info->par = NULL;
  344. info->apertures = alloc_apertures(1);
  345. if (!info->apertures) {
  346. err = -ENOMEM;
  347. goto err_release_fb;
  348. }
  349. info->apertures->ranges[0].base = efifb_fix.smem_start;
  350. info->apertures->ranges[0].size = size_remap;
  351. info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len);
  352. if (!info->screen_base) {
  353. printk(KERN_ERR "efifb: abort, cannot ioremap video memory "
  354. "0x%x @ 0x%lx\n",
  355. efifb_fix.smem_len, efifb_fix.smem_start);
  356. err = -EIO;
  357. goto err_release_fb;
  358. }
  359. printk(KERN_INFO "efifb: framebuffer at 0x%lx, mapped to 0x%p, "
  360. "using %dk, total %dk\n",
  361. efifb_fix.smem_start, info->screen_base,
  362. size_remap/1024, size_total/1024);
  363. printk(KERN_INFO "efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
  364. efifb_defined.xres, efifb_defined.yres,
  365. efifb_defined.bits_per_pixel, efifb_fix.line_length,
  366. screen_info.pages);
  367. efifb_defined.xres_virtual = efifb_defined.xres;
  368. efifb_defined.yres_virtual = efifb_fix.smem_len /
  369. efifb_fix.line_length;
  370. printk(KERN_INFO "efifb: scrolling: redraw\n");
  371. efifb_defined.yres_virtual = efifb_defined.yres;
  372. /* some dummy values for timing to make fbset happy */
  373. efifb_defined.pixclock = 10000000 / efifb_defined.xres *
  374. 1000 / efifb_defined.yres;
  375. efifb_defined.left_margin = (efifb_defined.xres / 8) & 0xf8;
  376. efifb_defined.hsync_len = (efifb_defined.xres / 8) & 0xf8;
  377. efifb_defined.red.offset = screen_info.red_pos;
  378. efifb_defined.red.length = screen_info.red_size;
  379. efifb_defined.green.offset = screen_info.green_pos;
  380. efifb_defined.green.length = screen_info.green_size;
  381. efifb_defined.blue.offset = screen_info.blue_pos;
  382. efifb_defined.blue.length = screen_info.blue_size;
  383. efifb_defined.transp.offset = screen_info.rsvd_pos;
  384. efifb_defined.transp.length = screen_info.rsvd_size;
  385. printk(KERN_INFO "efifb: %s: "
  386. "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
  387. "Truecolor",
  388. screen_info.rsvd_size,
  389. screen_info.red_size,
  390. screen_info.green_size,
  391. screen_info.blue_size,
  392. screen_info.rsvd_pos,
  393. screen_info.red_pos,
  394. screen_info.green_pos,
  395. screen_info.blue_pos);
  396. efifb_fix.ypanstep = 0;
  397. efifb_fix.ywrapstep = 0;
  398. info->fbops = &efifb_ops;
  399. info->var = efifb_defined;
  400. info->fix = efifb_fix;
  401. info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
  402. if ((err = fb_alloc_cmap(&info->cmap, 256, 0)) < 0) {
  403. printk(KERN_ERR "efifb: cannot allocate colormap\n");
  404. goto err_unmap;
  405. }
  406. if ((err = register_framebuffer(info)) < 0) {
  407. printk(KERN_ERR "efifb: cannot register framebuffer\n");
  408. goto err_fb_dealoc;
  409. }
  410. printk(KERN_INFO "fb%d: %s frame buffer device\n",
  411. info->node, info->fix.id);
  412. return 0;
  413. err_fb_dealoc:
  414. fb_dealloc_cmap(&info->cmap);
  415. err_unmap:
  416. iounmap(info->screen_base);
  417. err_release_fb:
  418. framebuffer_release(info);
  419. err_release_mem:
  420. if (request_succeeded)
  421. release_mem_region(efifb_fix.smem_start, size_total);
  422. return err;
  423. }
  424. static struct platform_driver efifb_driver = {
  425. .probe = efifb_probe,
  426. .driver = {
  427. .name = "efifb",
  428. },
  429. };
  430. static struct platform_device efifb_device = {
  431. .name = "efifb",
  432. };
  433. static int __init efifb_init(void)
  434. {
  435. int ret;
  436. char *option = NULL;
  437. dmi_check_system(dmi_system_table);
  438. if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
  439. return -ENODEV;
  440. if (fb_get_options("efifb", &option))
  441. return -ENODEV;
  442. efifb_setup(option);
  443. /* We don't get linelength from UGA Draw Protocol, only from
  444. * EFI Graphics Protocol. So if it's not in DMI, and it's not
  445. * passed in from the user, we really can't use the framebuffer.
  446. */
  447. if (!screen_info.lfb_linelength)
  448. return -ENODEV;
  449. ret = platform_driver_register(&efifb_driver);
  450. if (!ret) {
  451. ret = platform_device_register(&efifb_device);
  452. if (ret)
  453. platform_driver_unregister(&efifb_driver);
  454. }
  455. return ret;
  456. }
  457. module_init(efifb_init);
  458. MODULE_LICENSE("GPL");