blob: 528fe917dd49473ecd64d81a97b2b1987ac3d913 [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>
Luis R. Rodriguez127b0c92015-06-04 09:44:48 -070022#include <linux/io.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010023
Antonino A. Daplasd2d58382005-09-09 13:04:31 -070024#include <video/vga.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#define dac_reg (0x3c8)
27#define dac_val (0x3c9)
28
29/* --------------------------------------------------------------------- */
30
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -070031struct vesafb_par {
32 u32 pseudo_palette[256];
33 int wc_cookie;
34};
35
David Herrmann2e5155e2013-08-02 14:05:25 +020036static struct fb_var_screeninfo vesafb_defined = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 .activate = FB_ACTIVATE_NOW,
38 .height = -1,
39 .width = -1,
40 .right_margin = 32,
41 .upper_margin = 16,
42 .lower_margin = 4,
43 .vsync_len = 4,
44 .vmode = FB_VMODE_NONINTERLACED,
45};
46
David Herrmann2e5155e2013-08-02 14:05:25 +020047static struct fb_fix_screeninfo vesafb_fix = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 .id = "VESA VGA",
49 .type = FB_TYPE_PACKED_PIXELS,
50 .accel = FB_ACCEL_NONE,
51};
52
Helge Deller46703582006-12-08 02:40:30 -080053static int inverse __read_mostly;
54static int mtrr __read_mostly; /* disable mtrr */
David Herrmann2e5155e2013-08-02 14:05:25 +020055static int vram_remap; /* Set amount of memory to be used */
56static int vram_total; /* Set total amount of memory */
Helge Deller46703582006-12-08 02:40:30 -080057static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
58static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
59static void (*pmi_start)(void) __read_mostly;
60static void (*pmi_pal) (void) __read_mostly;
61static int depth __read_mostly;
62static int vga_compat __read_mostly;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/* --------------------------------------------------------------------- */
64
65static int vesafb_pan_display(struct fb_var_screeninfo *var,
66 struct fb_info *info)
67{
68#ifdef __i386__
69 int offset;
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4;
72
73 __asm__ __volatile__(
74 "call *(%%edi)"
75 : /* no return value */
76 : "a" (0x4f07), /* EAX */
77 "b" (0), /* EBX */
78 "c" (offset), /* ECX */
79 "d" (offset >> 16), /* EDX */
80 "D" (&pmi_start)); /* EDI */
81#endif
82 return 0;
83}
84
Antonino A. Daplas313ca222006-06-26 00:26:40 -070085static int vesa_setpalette(int regno, unsigned red, unsigned green,
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 unsigned blue)
87{
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -070088 int shift = 16 - depth;
Antonino A. Daplas313ca222006-06-26 00:26:40 -070089 int err = -EINVAL;
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -070090
Antonino A. Daplas6dbde382006-06-26 00:26:41 -070091/*
92 * Try VGA registers first...
93 */
94 if (vga_compat) {
95 outb_p(regno, dac_reg);
96 outb_p(red >> shift, dac_val);
97 outb_p(green >> shift, dac_val);
98 outb_p(blue >> shift, dac_val);
99 err = 0;
100 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Antonino A. Daplas6dbde382006-06-26 00:26:41 -0700102#ifdef __i386__
103/*
104 * Fallback to the PMI....
105 */
106 if (err && pmi_setpal) {
107 struct { u_char blue, green, red, pad; } entry;
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 entry.red = red >> shift;
110 entry.green = green >> shift;
111 entry.blue = blue >> shift;
112 entry.pad = 0;
113 __asm__ __volatile__(
114 "call *(%%esi)"
115 : /* no return value */
116 : "a" (0x4f09), /* EAX */
117 "b" (0), /* EBX */
118 "c" (1), /* ECX */
119 "d" (regno), /* EDX */
120 "D" (&entry), /* EDI */
121 "S" (&pmi_pal)); /* ESI */
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700122 err = 0;
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700123 }
124#endif
125
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700126 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127}
128
129static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
130 unsigned blue, unsigned transp,
131 struct fb_info *info)
132{
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700133 int err = 0;
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 /*
136 * Set a single color register. The values supplied are
137 * already rounded down to the hardware's capabilities
138 * (according to the entries in the `var' structure). Return
139 * != 0 for invalid regno.
140 */
141
142 if (regno >= info->cmap.len)
143 return 1;
144
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800145 if (info->var.bits_per_pixel == 8)
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700146 err = vesa_setpalette(regno,red,green,blue);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800147 else if (regno < 16) {
148 switch (info->var.bits_per_pixel) {
149 case 16:
150 if (info->var.red.offset == 10) {
151 /* 1:5:5:5 */
152 ((u32*) (info->pseudo_palette))[regno] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 ((red & 0xf800) >> 1) |
154 ((green & 0xf800) >> 6) |
155 ((blue & 0xf800) >> 11);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800156 } else {
157 /* 0:5:6:5 */
158 ((u32*) (info->pseudo_palette))[regno] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 ((red & 0xf800) ) |
160 ((green & 0xfc00) >> 5) |
161 ((blue & 0xf800) >> 11);
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800162 }
163 break;
164 case 24:
165 case 32:
166 red >>= 8;
167 green >>= 8;
168 blue >>= 8;
169 ((u32 *)(info->pseudo_palette))[regno] =
170 (red << info->var.red.offset) |
171 (green << info->var.green.offset) |
172 (blue << info->var.blue.offset);
173 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 }
Antonino A. Daplaseba50852005-11-07 01:00:40 -0800175 }
176
Antonino A. Daplas313ca222006-06-26 00:26:40 -0700177 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178}
179
Dave Airlie4410f392009-06-16 15:34:38 -0700180static void vesafb_destroy(struct fb_info *info)
181{
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -0700182 struct vesafb_par *par = info->par;
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -0700183
Daniel J Blueman3e86f1d2011-06-27 23:08:53 +0000184 fb_dealloc_cmap(&info->cmap);
Luis R. Rodriguez127b0c92015-06-04 09:44:48 -0700185 arch_phys_wc_del(par->wc_cookie);
Dave Airlie4410f392009-06-16 15:34:38 -0700186 if (info->screen_base)
187 iounmap(info->screen_base);
Marcin Slusarz1471ca92010-05-16 17:27:03 +0200188 release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
Dave Airlie4410f392009-06-16 15:34:38 -0700189}
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191static struct fb_ops vesafb_ops = {
192 .owner = THIS_MODULE,
Dave Airlie4410f392009-06-16 15:34:38 -0700193 .fb_destroy = vesafb_destroy,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 .fb_setcolreg = vesafb_setcolreg,
195 .fb_pan_display = vesafb_pan_display,
196 .fb_fillrect = cfb_fillrect,
197 .fb_copyarea = cfb_copyarea,
198 .fb_imageblit = cfb_imageblit,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199};
200
David Herrmann2e5155e2013-08-02 14:05:25 +0200201static int vesafb_setup(char *options)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202{
203 char *this_opt;
204
205 if (!options || !*options)
206 return 0;
207
208 while ((this_opt = strsep(&options, ",")) != NULL) {
209 if (!*this_opt) continue;
210
211 if (! strcmp(this_opt, "inverse"))
212 inverse=1;
213 else if (! strcmp(this_opt, "redraw"))
214 ypan=0;
215 else if (! strcmp(this_opt, "ypan"))
216 ypan=1;
217 else if (! strcmp(this_opt, "ywrap"))
218 ypan=2;
219 else if (! strcmp(this_opt, "vgapal"))
220 pmi_setpal=0;
221 else if (! strcmp(this_opt, "pmipal"))
222 pmi_setpal=1;
Antonino A. Daplas80625942005-07-29 14:03:31 -0700223 else if (! strncmp(this_opt, "mtrr:", 5))
224 mtrr = simple_strtoul(this_opt+5, NULL, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 else if (! strcmp(this_opt, "nomtrr"))
226 mtrr=0;
227 else if (! strncmp(this_opt, "vtotal:", 7))
228 vram_total = simple_strtoul(this_opt+7, NULL, 0);
229 else if (! strncmp(this_opt, "vremap:", 7))
230 vram_remap = simple_strtoul(this_opt+7, NULL, 0);
231 }
232 return 0;
233}
234
David Herrmann2e5155e2013-08-02 14:05:25 +0200235static int vesafb_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 struct fb_info *info;
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -0700238 struct vesafb_par *par;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 int i, err;
240 unsigned int size_vmode;
241 unsigned int size_remap;
242 unsigned int size_total;
David Herrmann2e5155e2013-08-02 14:05:25 +0200243 char *option = NULL;
244
245 /* ignore error return of fb_get_options */
246 fb_get_options("vesafb", &option);
247 vesafb_setup(option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
250 return -ENODEV;
251
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700252 vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 vesafb_fix.smem_start = screen_info.lfb_base;
254 vesafb_defined.bits_per_pixel = screen_info.lfb_depth;
255 if (15 == vesafb_defined.bits_per_pixel)
256 vesafb_defined.bits_per_pixel = 16;
257 vesafb_defined.xres = screen_info.lfb_width;
258 vesafb_defined.yres = screen_info.lfb_height;
259 vesafb_fix.line_length = screen_info.lfb_linelength;
260 vesafb_fix.visual = (vesafb_defined.bits_per_pixel == 8) ?
261 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
262
263 /* size_vmode -- that is the amount of memory needed for the
264 * used video mode, i.e. the minimum amount of
265 * memory we need. */
266 size_vmode = vesafb_defined.yres * vesafb_fix.line_length;
267
268 /* size_total -- all video memory we have. Used for mtrr
Justin P. Mattock8aed6282010-08-14 09:43:21 -0700269 * entries, resource allocation and bounds
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 * checking. */
271 size_total = screen_info.lfb_size * 65536;
272 if (vram_total)
273 size_total = vram_total * 1024 * 1024;
274 if (size_total < size_vmode)
275 size_total = size_vmode;
276
277 /* size_remap -- the amount of video memory we are going to
278 * use for vesafb. With modern cards it is no
279 * option to simply use size_total as that
280 * wastes plenty of kernel address space. */
281 size_remap = size_vmode * 2;
282 if (vram_remap)
283 size_remap = vram_remap * 1024 * 1024;
284 if (size_remap < size_vmode)
285 size_remap = size_vmode;
286 if (size_remap > size_total)
287 size_remap = size_total;
288 vesafb_fix.smem_len = size_remap;
289
290#ifndef __i386__
291 screen_info.vesapm_seg = 0;
292#endif
293
294 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
295 printk(KERN_WARNING
Gerd Knorr78c03712005-06-21 17:16:56 -0700296 "vesafb: cannot reserve video memory at 0x%lx\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 vesafb_fix.smem_start);
298 /* We cannot make this fatal. Sometimes this comes from magic
299 spaces our resource handlers simply don't know about */
300 }
301
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -0700302 info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 if (!info) {
Gerd Knorr78c03712005-06-21 17:16:56 -0700304 release_mem_region(vesafb_fix.smem_start, size_total);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 return -ENOMEM;
306 }
David Herrmann60231da2014-01-23 15:14:56 +0100307 platform_set_drvdata(dev, info);
Luis R. Rodriguez6b41f272015-06-04 09:44:47 -0700308 par = info->par;
309 info->pseudo_palette = par->pseudo_palette;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
Dave Airlie4410f392009-06-16 15:34:38 -0700311 /* set vesafb aperture size for generic probing */
Marcin Slusarz1471ca92010-05-16 17:27:03 +0200312 info->apertures = alloc_apertures(1);
313 if (!info->apertures) {
314 err = -ENOMEM;
315 goto err;
316 }
317 info->apertures->ranges[0].base = screen_info.lfb_base;
318 info->apertures->ranges[0].size = size_total;
Dave Airlie4410f392009-06-16 15:34:38 -0700319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
321 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
322
323 if (screen_info.vesapm_seg) {
324 printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
325 screen_info.vesapm_seg,screen_info.vesapm_off);
326 }
327
328 if (screen_info.vesapm_seg < 0xc000)
329 ypan = pmi_setpal = 0; /* not available or some DOS TSR ... */
330
331 if (ypan || pmi_setpal) {
Helge Deller46703582006-12-08 02:40:30 -0800332 unsigned short *pmi_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
334 pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
335 pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
336 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
337 if (pmi_base[3]) {
338 printk(KERN_INFO "vesafb: pmi: ports = ");
339 for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++)
340 printk("%x ",pmi_base[i]);
341 printk("\n");
342 if (pmi_base[i] != 0xffff) {
343 /*
344 * memory areas not supported (yet?)
345 *
346 * Rules are: we have to set up a descriptor for the requested
347 * memory area and pass it in the ES register to the BIOS function.
348 */
349 printk(KERN_INFO "vesafb: can't handle memory requests, pmi disabled\n");
350 ypan = pmi_setpal = 0;
351 }
352 }
353 }
354
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700355 if (vesafb_defined.bits_per_pixel == 8 && !pmi_setpal && !vga_compat) {
356 printk(KERN_WARNING "vesafb: hardware palette is unchangeable,\n"
357 " colors may be incorrect\n");
358 vesafb_fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
359 }
360
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 vesafb_defined.xres_virtual = vesafb_defined.xres;
362 vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
363 if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
364 printk(KERN_INFO "vesafb: scrolling: %s using protected mode interface, yres_virtual=%d\n",
365 (ypan > 1) ? "ywrap" : "ypan",vesafb_defined.yres_virtual);
366 } else {
367 printk(KERN_INFO "vesafb: scrolling: redraw\n");
368 vesafb_defined.yres_virtual = vesafb_defined.yres;
369 ypan = 0;
370 }
371
372 /* some dummy values for timing to make fbset happy */
373 vesafb_defined.pixclock = 10000000 / vesafb_defined.xres * 1000 / vesafb_defined.yres;
374 vesafb_defined.left_margin = (vesafb_defined.xres / 8) & 0xf8;
375 vesafb_defined.hsync_len = (vesafb_defined.xres / 8) & 0xf8;
376
377 vesafb_defined.red.offset = screen_info.red_pos;
378 vesafb_defined.red.length = screen_info.red_size;
379 vesafb_defined.green.offset = screen_info.green_pos;
380 vesafb_defined.green.length = screen_info.green_size;
381 vesafb_defined.blue.offset = screen_info.blue_pos;
382 vesafb_defined.blue.length = screen_info.blue_size;
383 vesafb_defined.transp.offset = screen_info.rsvd_pos;
384 vesafb_defined.transp.length = screen_info.rsvd_size;
385
386 if (vesafb_defined.bits_per_pixel <= 8) {
387 depth = vesafb_defined.green.length;
388 vesafb_defined.red.length =
389 vesafb_defined.green.length =
390 vesafb_defined.blue.length =
391 vesafb_defined.bits_per_pixel;
392 }
393
394 printk(KERN_INFO "vesafb: %s: "
395 "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
396 (vesafb_defined.bits_per_pixel > 8) ?
Antonino A. Daplas89ec4c22006-04-10 22:55:48 -0700397 "Truecolor" : (vga_compat || pmi_setpal) ?
398 "Pseudocolor" : "Static Pseudocolor",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 screen_info.rsvd_size,
400 screen_info.red_size,
401 screen_info.green_size,
402 screen_info.blue_size,
403 screen_info.rsvd_pos,
404 screen_info.red_pos,
405 screen_info.green_pos,
406 screen_info.blue_pos);
407
408 vesafb_fix.ypanstep = ypan ? 1 : 0;
409 vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0;
410
411 /* request failure does not faze us, as vgacon probably has this
412 * region already (FIXME) */
413 request_region(0x3c0, 32, "vesafb");
414
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700415 if (mtrr == 3) {
Gerd Knorr78c03712005-06-21 17:16:56 -0700416 unsigned int temp_size = size_total;
Dave Jonesd7496cb2005-06-25 14:58:30 -0700417
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700418 /* Find the largest power-of-two */
419 temp_size = roundup_pow_of_two(temp_size);
Antonino A. Daplas80625942005-07-29 14:03:31 -0700420
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700421 /* Try and find a power of two to add */
422 do {
Luis R. Rodriguez127b0c92015-06-04 09:44:48 -0700423 par->wc_cookie =
424 arch_phys_wc_add(vesafb_fix.smem_start,
425 temp_size);
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700426 temp_size >>= 1;
Luis R. Rodriguez127b0c92015-06-04 09:44:48 -0700427 } while (temp_size >= PAGE_SIZE && par->wc_cookie < 0);
428
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100429 info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len);
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700430 } else {
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700431 if (mtrr && mtrr != 3)
432 WARN_ONCE(1, "Only MTRR_TYPE_WRCOMB (3) make sense\n");
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100433 info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100434 }
Luis R. Rodriguez87b81762015-06-04 09:44:46 -0700435
Thomas Schlichter803a4e12010-11-27 14:17:55 +0100436 if (!info->screen_base) {
437 printk(KERN_ERR
438 "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
439 vesafb_fix.smem_len, vesafb_fix.smem_start);
440 err = -EIO;
441 goto err;
442 }
443
444 printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, "
445 "using %dk, total %dk\n",
446 vesafb_fix.smem_start, info->screen_base,
447 size_remap/1024, size_total/1024);
448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 info->fbops = &vesafb_ops;
450 info->var = vesafb_defined;
451 info->fix = vesafb_fix;
Dave Airlie4410f392009-06-16 15:34:38 -0700452 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
Roel Kluinb83734e2009-03-31 15:25:36 -0700453 (ypan ? FBINFO_HWACCEL_YPAN : 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Antonino A. Daplase53f87a2006-01-09 20:53:18 -0800455 if (!ypan)
456 info->fbops->fb_pan_display = NULL;
457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
459 err = -ENOMEM;
460 goto err;
461 }
462 if (register_framebuffer(info)<0) {
463 err = -EINVAL;
464 fb_dealloc_cmap(&info->cmap);
465 goto err;
466 }
Joe Perches31b67802013-09-19 18:35:55 -0700467 fb_info(info, "%s frame buffer device\n", info->fix.id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 return 0;
469err:
Luis R. Rodriguez127b0c92015-06-04 09:44:48 -0700470 arch_phys_wc_del(par->wc_cookie);
Amol Ladb88a57c2006-12-08 02:40:02 -0800471 if (info->screen_base)
472 iounmap(info->screen_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 framebuffer_release(info);
474 release_mem_region(vesafb_fix.smem_start, size_total);
475 return err;
476}
477
David Herrmann60231da2014-01-23 15:14:56 +0100478static int vesafb_remove(struct platform_device *pdev)
479{
480 struct fb_info *info = platform_get_drvdata(pdev);
481
482 unregister_framebuffer(info);
483 framebuffer_release(info);
484
485 return 0;
486}
487
Russell King3ae5eae2005-11-09 22:32:44 +0000488static struct platform_driver vesafb_driver = {
David Herrmann2e5155e2013-08-02 14:05:25 +0200489 .driver = {
490 .name = "vesa-framebuffer",
Russell King3ae5eae2005-11-09 22:32:44 +0000491 },
David Herrmann2e5155e2013-08-02 14:05:25 +0200492 .probe = vesafb_probe,
David Herrmann60231da2014-01-23 15:14:56 +0100493 .remove = vesafb_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494};
495
David Herrmann2e5155e2013-08-02 14:05:25 +0200496module_platform_driver(vesafb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497MODULE_LICENSE("GPL");