blob: 501b3406c6d5584361676c0543d573f88e3f497a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * framebuffer driver for VBE 2.0 compliant graphic boards
3 *
4 * switching to graphics mode happens at boot time (while
5 * running in real mode, see arch/i386/boot/video.S).
6 *
7 * (c) 1998 Gerd Knorr <kraxel@goldbach.in-berlin.de>
8 *
9 */
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/delay.h>
17#include <linux/fb.h>
18#include <linux/ioport.h>
19#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010020#include <linux/platform_device.h>
Jon Smirla8f340e2006-07-10 04:44:12 -070021#include <linux/screen_info.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010022
Antonino A. Daplasd2d58382005-09-09 13:04:31 -070023#include <video/vga.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/io.h>
25#include <asm/mtrr.h>
26
27#define dac_reg (0x3c8)
28#define dac_val (0x3c9)
29
30/* --------------------------------------------------------------------- */
31
32static struct fb_var_screeninfo vesafb_defined __initdata = {
33 .activate = FB_ACTIVATE_NOW,
34 .height = -1,
35 .width = -1,
36 .right_margin = 32,
37 .upper_margin = 16,
38 .lower_margin = 4,
39 .vsync_len = 4,
40 .vmode = FB_VMODE_NONINTERLACED,
41};
42
43static struct fb_fix_screeninfo vesafb_fix __initdata = {
44 .id = "VESA VGA",
45 .type = FB_TYPE_PACKED_PIXELS,
46 .accel = FB_ACCEL_NONE,
47};
48
Helge Deller46703582006-12-08 02:40:30 -080049static int inverse __read_mostly;
50static int mtrr __read_mostly; /* disable mtrr */
51static int vram_remap __initdata; /* Set amount of memory to be used */
52static int vram_total __initdata; /* Set total amount of memory */
53static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
54static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
55static void (*pmi_start)(void) __read_mostly;
56static void (*pmi_pal) (void) __read_mostly;
57static int depth __read_mostly;
58static int vga_compat __read_mostly;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* --------------------------------------------------------------------- */
60
61static int vesafb_pan_display(struct fb_var_screeninfo *var,
62 struct fb_info *info)
63{
64#ifdef __i386__
65 int offset;
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4;
68
69 __asm__ __volatile__(
70 "call *(%%edi)"
71 : /* no return value */
72 : "a" (0x4f07), /* EAX */
73 "b" (0), /* EBX */
74 "c" (offset), /* ECX */
75 "d" (offset >> 16), /* EDX */
76 "D" (&pmi_start)); /* EDI */
77#endif
78 return 0;
79}
80
Antonino A. Daplas313ca222006-06-26 00:26:40 -070081static int vesa_setpalette(int regno, unsigned red, unsigned green,
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 unsigned blue)
83{
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -070084 int shift = 16 - depth;
Antonino A. Daplas313ca222006-06-26 00:26:40 -070085 int err = -EINVAL;
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -070086
Antonino A. Daplas6dbde382006-06-26 00:26:41 -070087/*
88 * Try VGA registers first...
89 */
90 if (vga_compat) {
91 outb_p(regno, dac_reg);
92 outb_p(red >> shift, dac_val);
93 outb_p(green >> shift, dac_val);
94 outb_p(blue >> shift, dac_val);
95 err = 0;
96 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Antonino A. Daplas6dbde382006-06-26 00:26:41 -070098#ifdef __i386__
99/*
100 * Fallback to the PMI....
101 */
102 if (err && pmi_setpal) {
103 struct { u_char blue, green, red, pad; } entry;
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 entry.red = red >> shift;
106 entry.green = green >> shift;
107 entry.blue = blue >> shift;
108 entry.pad = 0;
109 __asm__ __volatile__(
110 "call *(%%esi)"
111 : /* no return value */
112 : "a" (0x4f09), /* EAX */
113 "b" (0), /* EBX */
114 "c" (1), /* ECX */
115 "d" (regno), /* EDX */
116 "D" (&entry), /* EDI */
117 "S" (&pmi_pal)); /* ESI */
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700118 err = 0;
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700119 }
120#endif
121
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700122 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123}
124
125static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
126 unsigned blue, unsigned transp,
127 struct fb_info *info)
128{
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700129 int err = 0;
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 /*
132 * Set a single color register. The values supplied are
133 * already rounded down to the hardware's capabilities
134 * (according to the entries in the `var' structure). Return
135 * != 0 for invalid regno.
136 */
137
138 if (regno >= info->cmap.len)
139 return 1;
140
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800141 if (info->var.bits_per_pixel == 8)
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700142 err = vesa_setpalette(regno,red,green,blue);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800143 else if (regno < 16) {
144 switch (info->var.bits_per_pixel) {
145 case 16:
146 if (info->var.red.offset == 10) {
147 /* 1:5:5:5 */
148 ((u32*) (info->pseudo_palette))[regno] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 ((red & 0xf800) >> 1) |
150 ((green & 0xf800) >> 6) |
151 ((blue & 0xf800) >> 11);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800152 } else {
153 /* 0:5:6:5 */
154 ((u32*) (info->pseudo_palette))[regno] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 ((red & 0xf800) ) |
156 ((green & 0xfc00) >> 5) |
157 ((blue & 0xf800) >> 11);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800158 }
159 break;
160 case 24:
161 case 32:
162 red >>= 8;
163 green >>= 8;
164 blue >>= 8;
165 ((u32 *)(info->pseudo_palette))[regno] =
166 (red << info->var.red.offset) |
167 (green << info->var.green.offset) |
168 (blue << info->var.blue.offset);
169 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 }
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800171 }
172
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700173 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174}
175
Dave Airlie4410f392009-06-16 15:34:38 -0700176static void vesafb_destroy(struct fb_info *info)
177{
Daniel J Blueman3e86f1d2011-06-27 23:08:53 +0000178 fb_dealloc_cmap(&info->cmap);
Dave Airlie4410f392009-06-16 15:34:38 -0700179 if (info->screen_base)
180 iounmap(info->screen_base);
Marcin Slusarz1471ca92010-05-16 17:27:03 +0200181 release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
Dave Airlie4410f392009-06-16 15:34:38 -0700182 framebuffer_release(info);
183}
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185static struct fb_ops vesafb_ops = {
186 .owner = THIS_MODULE,
Dave Airlie4410f392009-06-16 15:34:38 -0700187 .fb_destroy = vesafb_destroy,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 .fb_setcolreg = vesafb_setcolreg,
189 .fb_pan_display = vesafb_pan_display,
190 .fb_fillrect = cfb_fillrect,
191 .fb_copyarea = cfb_copyarea,
192 .fb_imageblit = cfb_imageblit,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193};
194
195static int __init vesafb_setup(char *options)
196{
197 char *this_opt;
198
199 if (!options || !*options)
200 return 0;
201
202 while ((this_opt = strsep(&options, ",")) != NULL) {
203 if (!*this_opt) continue;
204
205 if (! strcmp(this_opt, "inverse"))
206 inverse=1;
207 else if (! strcmp(this_opt, "redraw"))
208 ypan=0;
209 else if (! strcmp(this_opt, "ypan"))
210 ypan=1;
211 else if (! strcmp(this_opt, "ywrap"))
212 ypan=2;
213 else if (! strcmp(this_opt, "vgapal"))
214 pmi_setpal=0;
215 else if (! strcmp(this_opt, "pmipal"))
216 pmi_setpal=1;
Antonino A. Daplas80625942005-07-29 14:03:31 -0700217 else if (! strncmp(this_opt, "mtrr:", 5))
218 mtrr = simple_strtoul(this_opt+5, NULL, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 else if (! strcmp(this_opt, "nomtrr"))
220 mtrr=0;
221 else if (! strncmp(this_opt, "vtotal:", 7))
222 vram_total = simple_strtoul(this_opt+7, NULL, 0);
223 else if (! strncmp(this_opt, "vremap:", 7))
224 vram_remap = simple_strtoul(this_opt+7, NULL, 0);
225 }
226 return 0;
227}
228
Jan Beulichfc95c6d2010-04-06 14:34:44 -0700229static int __init vesafb_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 struct fb_info *info;
232 int i, err;
233 unsigned int size_vmode;
234 unsigned int size_remap;
235 unsigned int size_total;
236
237 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
238 return -ENODEV;
239
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700240 vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 vesafb_fix.smem_start = screen_info.lfb_base;
242 vesafb_defined.bits_per_pixel = screen_info.lfb_depth;
243 if (15 == vesafb_defined.bits_per_pixel)
244 vesafb_defined.bits_per_pixel = 16;
245 vesafb_defined.xres = screen_info.lfb_width;
246 vesafb_defined.yres = screen_info.lfb_height;
247 vesafb_fix.line_length = screen_info.lfb_linelength;
248 vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ?
249 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
250
251 /* size_vmode -- that is the amount of memory needed for the
252 * used video mode, i.e. the minimum amount of
253 * memory we need. */
254 size_vmode = vesafb_defined.yres * vesafb_fix.line_length;
255
256 /* size_total -- all video memory we have. Used for mtrr
Justin P. Mattock8aed6282010-08-14 09:43:21 -0700257 * entries, resource allocation and bounds
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 * checking. */
259 size_total = screen_info.lfb_size * 65536;
260 if (vram_total)
261 size_total = vram_total * 1024 * 1024;
262 if (size_total < size_vmode)
263 size_total = size_vmode;
264
265 /* size_remap -- the amount of video memory we are going to
266 * use for vesafb. With modern cards it is no
267 * option to simply use size_total as that
268 * wastes plenty of kernel address space. */
269 size_remap = size_vmode * 2;
270 if (vram_remap)
271 size_remap = vram_remap * 1024 * 1024;
272 if (size_remap < size_vmode)
273 size_remap = size_vmode;
274 if (size_remap > size_total)
275 size_remap = size_total;
276 vesafb_fix.smem_len = size_remap;
277
278#ifndef __i386__
279 screen_info.vesapm_seg = 0;
280#endif
281
282 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
283 printk(KERN_WARNING
Gerd Knorr78c03712005-06-21 17:16:56 -0700284 "vesafb: cannot reserve video memory at 0x%lx\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 vesafb_fix.smem_start);
286 /* We cannot make this fatal. Sometimes this comes from magic
287 spaces our resource handlers simply don't know about */
288 }
289
290 info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
291 if (!info) {
Gerd Knorr78c03712005-06-21 17:16:56 -0700292 release_mem_region(vesafb_fix.smem_start, size_total);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 return -ENOMEM;
294 }
295 info->pseudo_palette = info->par;
296 info->par = NULL;
297
Dave Airlie4410f392009-06-16 15:34:38 -0700298 /* set vesafb aperture size for generic probing */
Marcin Slusarz1471ca92010-05-16 17:27:03 +0200299 info->apertures = alloc_apertures(1);
300 if (!info->apertures) {
301 err = -ENOMEM;
302 goto err;
303 }
304 info->apertures->ranges[0].base = screen_info.lfb_base;
305 info->apertures->ranges[0].size = size_total;
Dave Airlie4410f392009-06-16 15:34:38 -0700306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
308 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
309
310 if (screen_info.vesapm_seg) {
311 printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
312 screen_info.vesapm_seg,screen_info.vesapm_off);
313 }
314
315 if (screen_info.vesapm_seg < 0xc000)
316 ypan = pmi_setpal = 0; /* not available or some DOS TSR ... */
317
318 if (ypan || pmi_setpal) {
Helge Deller46703582006-12-08 02:40:30 -0800319 unsigned short *pmi_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
321 pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
322 pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
323 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
324 if (pmi_base[3]) {
325 printk(KERN_INFO "vesafb: pmi: ports = ");
326 for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++)
327 printk("%x ",pmi_base[i]);
328 printk("\n");
329 if (pmi_base[i] != 0xffff) {
330 /*
331 * memory areas not supported (yet?)
332 *
333 * Rules are: we have to set up a descriptor for the requested
334 * memory area and pass it in the ES register to the BIOS function.
335 */
336 printk(KERN_INFO "vesafb: can't handle memory requests, pmi disabled\n");
337 ypan = pmi_setpal = 0;
338 }
339 }
340 }
341
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700342 if (vesafb_defined.bits_per_pixel == 8 && !pmi_setpal && !vga_compat) {
343 printk(KERN_WARNING "vesafb: hardware palette is unchangeable,\n"
344 " colors may be incorrect\n");
345 vesafb_fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
346 }
347
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 vesafb_defined.xres_virtual = vesafb_defined.xres;
349 vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
350 if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
351 printk(KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n",
352 (ypan > 1) ? "ywrap" : "ypan",vesafb_defined.yres_virtual);
353 } else {
354 printk(KERN_INFO "vesafb: scrolling: redraw\n");
355 vesafb_defined.yres_virtual = vesafb_defined.yres;
356 ypan = 0;
357 }
358
359 /* some dummy values for timing to make fbset happy */
360 vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres;
361 vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8;
362 vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8;
363
364 vesafb_defined.red.offset = screen_info.red_pos;
365 vesafb_defined.red.length = screen_info.red_size;
366 vesafb_defined.green.offset = screen_info.green_pos;
367 vesafb_defined.green.length = screen_info.green_size;
368 vesafb_defined.blue.offset = screen_info.blue_pos;
369 vesafb_defined.blue.length = screen_info.blue_size;
370 vesafb_defined.transp.offset = screen_info.rsvd_pos;
371 vesafb_defined.transp.length = screen_info.rsvd_size;
372
373 if (vesafb_defined.bits_per_pixel <= 8) {
374 depth = vesafb_defined.green.length;
375 vesafb_defined.red.length =
376 vesafb_defined.green.length =
377 vesafb_defined.blue.length =
378 vesafb_defined.bits_per_pixel;
379 }
380
381 printk(KERN_INFO "vesafb: %s: "
382 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
383 (vesafb_defined.bits_per_pixel > 8) ?
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700384 "Truecolor" : (vga_compat || pmi_setpal) ?
385 "Pseudocolor" : "Static Pseudocolor",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 screen_info.rsvd_size,
387 screen_info.red_size,
388 screen_info.green_size,
389 screen_info.blue_size,
390 screen_info.rsvd_pos,
391 screen_info.red_pos,
392 screen_info.green_pos,
393 screen_info.blue_pos);
394
395 vesafb_fix.ypanstep = ypan ? 1 : 0;
396 vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0;
397
398 /* request failure does not faze us, as vgacon probably has this
399 * region already (FIXME) */
400 request_region(0x3c0, 32, "vesafb");
401
Jan Beulichf5f4917c2005-11-13 16:08:12 -0800402#ifdef CONFIG_MTRR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 if (mtrr) {
Gerd Knorr78c03712005-06-21 17:16:56 -0700404 unsigned int temp_size = size_total;
Antonino A. Daplas80625942005-07-29 14:03:31 -0700405 unsigned int type = 0;
Dave Jonesd7496cb2005-06-25 14:58:30 -0700406
Antonino A. Daplas80625942005-07-29 14:03:31 -0700407 switch (mtrr) {
408 case 1:
409 type = MTRR_TYPE_UNCACHABLE;
410 break;
411 case 2:
412 type = MTRR_TYPE_WRBACK;
413 break;
414 case 3:
415 type = MTRR_TYPE_WRCOMB;
416 break;
417 case 4:
418 type = MTRR_TYPE_WRTHROUGH;
419 break;
420 default:
421 type = 0;
422 break;
423 }
424
425 if (type) {
426 int rc;
427
428 /* Find the largest power-of-two */
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100429 temp_size = roundup_pow_of_two(temp_size);
Antonino A. Daplas80625942005-07-29 14:03:31 -0700430
431 /* Try and find a power of two to add */
432 do {
433 rc = mtrr_add(vesafb_fix.smem_start, temp_size,
434 type, 1);
435 temp_size >>= 1;
436 } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
438 }
Jan Beulichf5f4917c2005-11-13 16:08:12 -0800439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100441 switch (mtrr) {
442 case 1: /* uncachable */
443 info->screen_base = ioremap_nocache(vesafb_fix.smem_start, vesafb_fix.smem_len);
444 break;
445 case 2: /* write-back */
446 info->screen_base = ioremap_cache(vesafb_fix.smem_start, vesafb_fix.smem_len);
447 break;
448 case 3: /* write-combining */
449 info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len);
450 break;
451 case 4: /* write-through */
452 default:
453 info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
454 break;
455 }
456 if (!info->screen_base) {
457 printk(KERN_ERR
458 "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
459 vesafb_fix.smem_len, vesafb_fix.smem_start);
460 err = -EIO;
461 goto err;
462 }
463
464 printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, "
465 "using %dk, total %dk\n",
466 vesafb_fix.smem_start, info->screen_base,
467 size_remap/1024, size_total/1024);
468
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 info->fbops = &vesafb_ops;
470 info->var = vesafb_defined;
471 info->fix = vesafb_fix;
Dave Airlie4410f392009-06-16 15:34:38 -0700472 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
Roel Kluinb83734e2009-03-31 15:25:36 -0700473 (ypan ? FBINFO_HWACCEL_YPAN : 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474
Antonino A. Daplase53f87a2006-01-09 20:53:18 -0800475 if (!ypan)
476 info->fbops->fb_pan_display = NULL;
477
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
479 err = -ENOMEM;
480 goto err;
481 }
482 if (register_framebuffer(info)<0) {
483 err = -EINVAL;
484 fb_dealloc_cmap(&info->cmap);
485 goto err;
486 }
487 printk(KERN_INFO "fb%d: %s frame buffer device\n",
488 info->node, info->fix.id);
489 return 0;
490err:
Amol Ladb88a57c2006-12-08 02:40:02 -0800491 if (info->screen_base)
492 iounmap(info->screen_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 framebuffer_release(info);
494 release_mem_region(vesafb_fix.smem_start, size_total);
495 return err;
496}
497
Russell King3ae5eae2005-11-09 22:32:44 +0000498static struct platform_driver vesafb_driver = {
Russell King3ae5eae2005-11-09 22:32:44 +0000499 .driver = {
500 .name = "vesafb",
501 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502};
503
Antonino A. Daplas103edf02006-06-26 00:26:33 -0700504static struct platform_device *vesafb_device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506static int __init vesafb_init(void)
507{
508 int ret;
509 char *option = NULL;
510
511 /* ignore error return of fb_get_options */
512 fb_get_options("vesafb", &option);
513 vesafb_setup(option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
Jan Beulichfc95c6d2010-04-06 14:34:44 -0700515 vesafb_device = platform_device_alloc("vesafb", 0);
516 if (!vesafb_device)
517 return -ENOMEM;
518
519 ret = platform_device_add(vesafb_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 if (!ret) {
Jan Beulichfc95c6d2010-04-06 14:34:44 -0700521 ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
522 if (ret)
523 platform_device_del(vesafb_device);
524 }
Antonino A. Daplas103edf02006-06-26 00:26:33 -0700525
Jan Beulichfc95c6d2010-04-06 14:34:44 -0700526 if (ret) {
527 platform_device_put(vesafb_device);
528 vesafb_device = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 }
Antonino A. Daplas103edf02006-06-26 00:26:33 -0700530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 return ret;
532}
533module_init(vesafb_init);
534
535MODULE_LICENSE("GPL");