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