vserver 1.9.3
[linux-2.6.git] / drivers / video / fbmem.c
1 /*
2  *  linux/drivers/video/fbmem.c
3  *
4  *  Copyright (C) 1994 Martin Schaller
5  *
6  *      2001 - Documented with DocBook
7  *      - Brad Douglas <brad@neruo.com>
8  *
9  * This file is subject to the terms and conditions of the GNU General Public
10  * License.  See the file COPYING in the main directory of this archive
11  * for more details.
12  */
13
14 #include <linux/config.h>
15 #include <linux/module.h>
16
17 #include <linux/types.h>
18 #include <linux/errno.h>
19 #include <linux/sched.h>
20 #include <linux/smp_lock.h>
21 #include <linux/kernel.h>
22 #include <linux/major.h>
23 #include <linux/slab.h>
24 #include <linux/mm.h>
25 #include <linux/mman.h>
26 #include <linux/tty.h>
27 #include <linux/init.h>
28 #include <linux/linux_logo.h>
29 #include <linux/proc_fs.h>
30 #include <linux/console.h>
31 #ifdef CONFIG_KMOD
32 #include <linux/kmod.h>
33 #endif
34 #include <linux/devfs_fs_kernel.h>
35 #include <linux/err.h>
36 #include <linux/kernel.h>
37 #include <linux/device.h>
38
39 #if defined(__mc68000__) || defined(CONFIG_APUS)
40 #include <asm/setup.h>
41 #endif
42
43 #include <asm/io.h>
44 #include <asm/uaccess.h>
45 #include <asm/page.h>
46 #include <asm/pgtable.h>
47
48 #include <linux/fb.h>
49
50     /*
51      *  Frame buffer device initialization and setup routines
52      */
53
54 #define FBPIXMAPSIZE    16384
55
56 static struct notifier_block *fb_notifier_list;
57 struct fb_info *registered_fb[FB_MAX];
58 int num_registered_fb;
59
60 /*
61  * Helpers
62  */
63
64 int fb_get_color_depth(struct fb_info *info)
65 {
66         struct fb_var_screeninfo *var = &info->var;
67
68         if (var->green.length == var->blue.length &&
69             var->green.length == var->red.length &&
70             !var->green.offset && !var->blue.offset &&
71             !var->red.offset)
72                 return var->green.length;
73         else
74                 return (var->green.length + var->red.length +
75                         var->blue.length);
76 }
77 EXPORT_SYMBOL(fb_get_color_depth);
78
79 /*
80  * Drawing helpers.
81  */
82 void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
83                            u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
84                            u32 height)
85 {
86         int i;
87
88         for (i = height; i--; ) {
89                 buf->outbuf(info, dst, src, s_pitch);
90                 src += s_pitch;
91                 dst += d_pitch;
92         }
93 }
94
95 void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
96                             u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
97                             u32 height)
98 {
99         int i, j;
100
101         for (i = height; i--; ) {
102                 for (j = 0; j < s_pitch; j++)
103                         dst[j] = src[j];
104                 src += s_pitch;
105                 dst += d_pitch;
106         }
107 }
108
109 void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
110                              u8 *dst, u32 d_pitch, u8 *src, u32 idx,
111                              u32 height, u32 shift_high, u32 shift_low,
112                              u32 mod)
113 {
114         u8 mask = (u8) (0xfff << shift_high), tmp;
115         int i, j;
116
117         for (i = height; i--; ) {
118                 for (j = 0; j < idx; j++) {
119                         tmp = buf->inbuf(info, dst+j);
120                         tmp &= mask;
121                         tmp |= *src >> shift_low;
122                         buf->outbuf(info, dst+j, &tmp, 1);
123                         tmp = *src << shift_high;
124                         buf->outbuf(info, dst+j+1, &tmp, 1);
125                         src++;
126                 }
127                 tmp = buf->inbuf(info, dst+idx);
128                 tmp &= mask;
129                 tmp |= *src >> shift_low;
130                 buf->outbuf(info, dst+idx, &tmp, 1);
131                 if (shift_high < mod) {
132                         tmp = *src << shift_high;
133                         buf->outbuf(info, dst+idx+1, &tmp, 1);
134                 }       
135                 src++;
136                 dst += d_pitch;
137         }
138 }
139
140 void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
141                               u8 *dst, u32 d_pitch, u8 *src, u32 idx,
142                               u32 height, u32 shift_high, u32 shift_low,
143                               u32 mod)
144 {
145         u8 mask = (u8) (0xfff << shift_high), tmp;
146         int i, j;
147
148         for (i = height; i--; ) {
149                 for (j = 0; j < idx; j++) {
150                         tmp = dst[j];
151                         tmp &= mask;
152                         tmp |= *src >> shift_low;
153                         dst[j] = tmp;
154                         tmp = *src << shift_high;
155                         dst[j+1] = tmp;
156                         src++;
157                 }
158                 tmp = dst[idx];
159                 tmp &= mask;
160                 tmp |= *src >> shift_low;
161                 dst[idx] = tmp;
162                 if (shift_high < mod) {
163                         tmp = *src << shift_high;
164                         dst[idx+1] = tmp;
165                 }
166                 src++;
167                 dst += d_pitch;
168         }
169 }
170
171 /*
172  * we need to lock this section since fb_cursor
173  * may use fb_imageblit()
174  */
175 char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
176 {
177         u32 align = buf->buf_align - 1, offset;
178         char *addr = buf->addr;
179
180         /* If IO mapped, we need to sync before access, no sharing of
181          * the pixmap is done
182          */
183         if (buf->flags & FB_PIXMAP_IO) {
184                 if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
185                         info->fbops->fb_sync(info);
186                 return addr;
187         }
188
189         /* See if we fit in the remaining pixmap space */
190         offset = buf->offset + align;
191         offset &= ~align;
192         if (offset + size > buf->size) {
193                 /* We do not fit. In order to be able to re-use the buffer,
194                  * we must ensure no asynchronous DMA'ing or whatever operation
195                  * is in progress, we sync for that.
196                  */
197                 if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
198                         info->fbops->fb_sync(info);
199                 offset = 0;
200         }
201         buf->offset = offset + size;
202         addr += offset;
203
204         return addr;
205 }
206
207 #ifdef CONFIG_LOGO
208 #include <linux/linux_logo.h>
209
210 static inline unsigned safe_shift(unsigned d, int n)
211 {
212         return n < 0 ? d >> -n : d << n;
213 }
214
215 static void fb_set_logocmap(struct fb_info *info,
216                                    const struct linux_logo *logo)
217 {
218         struct fb_cmap palette_cmap;
219         u16 palette_green[16];
220         u16 palette_blue[16];
221         u16 palette_red[16];
222         int i, j, n;
223         const unsigned char *clut = logo->clut;
224
225         palette_cmap.start = 0;
226         palette_cmap.len = 16;
227         palette_cmap.red = palette_red;
228         palette_cmap.green = palette_green;
229         palette_cmap.blue = palette_blue;
230         palette_cmap.transp = NULL;
231
232         for (i = 0; i < logo->clutsize; i += n) {
233                 n = logo->clutsize - i;
234                 /* palette_cmap provides space for only 16 colors at once */
235                 if (n > 16)
236                         n = 16;
237                 palette_cmap.start = 32 + i;
238                 palette_cmap.len = n;
239                 for (j = 0; j < n; ++j) {
240                         palette_cmap.red[j] = clut[0] << 8 | clut[0];
241                         palette_cmap.green[j] = clut[1] << 8 | clut[1];
242                         palette_cmap.blue[j] = clut[2] << 8 | clut[2];
243                         clut += 3;
244                 }
245                 fb_set_cmap(&palette_cmap, info);
246         }
247 }
248
249 static void  fb_set_logo_truepalette(struct fb_info *info,
250                                             const struct linux_logo *logo,
251                                             u32 *palette)
252 {
253         unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
254         unsigned char redmask, greenmask, bluemask;
255         int redshift, greenshift, blueshift;
256         int i;
257         const unsigned char *clut = logo->clut;
258
259         /*
260          * We have to create a temporary palette since console palette is only
261          * 16 colors long.
262          */
263         /* Bug: Doesn't obey msb_right ... (who needs that?) */
264         redmask   = mask[info->var.red.length   < 8 ? info->var.red.length   : 8];
265         greenmask = mask[info->var.green.length < 8 ? info->var.green.length : 8];
266         bluemask  = mask[info->var.blue.length  < 8 ? info->var.blue.length  : 8];
267         redshift   = info->var.red.offset   - (8 - info->var.red.length);
268         greenshift = info->var.green.offset - (8 - info->var.green.length);
269         blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
270
271         for ( i = 0; i < logo->clutsize; i++) {
272                 palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
273                                  safe_shift((clut[1] & greenmask), greenshift) |
274                                  safe_shift((clut[2] & bluemask), blueshift));
275                 clut += 3;
276         }
277 }
278
279 static void fb_set_logo_directpalette(struct fb_info *info,
280                                              const struct linux_logo *logo,
281                                              u32 *palette)
282 {
283         int redshift, greenshift, blueshift;
284         int i;
285
286         redshift = info->var.red.offset;
287         greenshift = info->var.green.offset;
288         blueshift = info->var.blue.offset;
289
290         for (i = 32; i < logo->clutsize; i++)
291                 palette[i] = i << redshift | i << greenshift | i << blueshift;
292 }
293
294 static void fb_set_logo(struct fb_info *info,
295                                const struct linux_logo *logo, u8 *dst,
296                                int depth)
297 {
298         int i, j, k, fg = 1;
299         const u8 *src = logo->data;
300         u8 d, xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
301
302         if (fb_get_color_depth(info) == 3)
303                 fg = 7;
304
305         switch (depth) {
306         case 4:
307                 for (i = 0; i < logo->height; i++)
308                         for (j = 0; j < logo->width; src++) {
309                                 *dst++ = *src >> 4;
310                                 j++;
311                                 if (j < logo->width) {
312                                         *dst++ = *src & 0x0f;
313                                         j++;
314                                 }
315                         }
316                 break;
317         case 1:
318                 for (i = 0; i < logo->height; i++) {
319                         for (j = 0; j < logo->width; src++) {
320                                 d = *src ^ xor;
321                                 for (k = 7; k >= 0; k--) {
322                                         *dst++ = ((d >> k) & 1) ? fg : 0;
323                                         j++;
324                                 }
325                         }
326                 }
327                 break;
328         }
329 }
330
331 /*
332  * Three (3) kinds of logo maps exist.  linux_logo_clut224 (>16 colors),
333  * linux_logo_vga16 (16 colors) and linux_logo_mono (2 colors).  Depending on
334  * the visual format and color depth of the framebuffer, the DAC, the
335  * pseudo_palette, and the logo data will be adjusted accordingly.
336  *
337  * Case 1 - linux_logo_clut224:
338  * Color exceeds the number of console colors (16), thus we set the hardware DAC
339  * using fb_set_cmap() appropriately.  The "needs_cmapreset"  flag will be set.
340  *
341  * For visuals that require color info from the pseudo_palette, we also construct
342  * one for temporary use. The "needs_directpalette" or "needs_truepalette" flags
343  * will be set.
344  *
345  * Case 2 - linux_logo_vga16:
346  * The number of colors just matches the console colors, thus there is no need
347  * to set the DAC or the pseudo_palette.  However, the bitmap is packed, ie,
348  * each byte contains color information for two pixels (upper and lower nibble).
349  * To be consistent with fb_imageblit() usage, we therefore separate the two
350  * nibbles into separate bytes. The "depth" flag will be set to 4.
351  *
352  * Case 3 - linux_logo_mono:
353  * This is similar with Case 2.  Each byte contains information for 8 pixels.
354  * We isolate each bit and expand each into a byte. The "depth" flag will
355  * be set to 1.
356  */
357 static struct logo_data {
358         int depth;
359         int needs_directpalette;
360         int needs_truepalette;
361         int needs_cmapreset;
362         const struct linux_logo *logo;
363 } fb_logo;
364
365 int fb_prepare_logo(struct fb_info *info)
366 {
367         int depth = fb_get_color_depth(info);
368
369         memset(&fb_logo, 0, sizeof(struct logo_data));
370
371         if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
372                 depth = info->var.blue.length;
373                 if (info->var.red.length < depth)
374                         depth = info->var.red.length;
375                 if (info->var.green.length < depth)
376                         depth = info->var.green.length;
377         }
378
379         if (depth >= 8) {
380                 switch (info->fix.visual) {
381                 case FB_VISUAL_TRUECOLOR:
382                         fb_logo.needs_truepalette = 1;
383                         break;
384                 case FB_VISUAL_DIRECTCOLOR:
385                         fb_logo.needs_directpalette = 1;
386                         fb_logo.needs_cmapreset = 1;
387                         break;
388                 case FB_VISUAL_PSEUDOCOLOR:
389                         fb_logo.needs_cmapreset = 1;
390                         break;
391                 }
392         }
393
394         /* Return if no suitable logo was found */
395         fb_logo.logo = fb_find_logo(depth);
396         
397         if (!fb_logo.logo || fb_logo.logo->height > info->var.yres) {
398                 fb_logo.logo = NULL;
399                 return 0;
400         }
401         /* What depth we asked for might be different from what we get */
402         if (fb_logo.logo->type == LINUX_LOGO_CLUT224)
403                 fb_logo.depth = 8;
404         else if (fb_logo.logo->type == LINUX_LOGO_VGA16)
405                 fb_logo.depth = 4;
406         else
407                 fb_logo.depth = 1;              
408         return fb_logo.logo->height;
409 }
410
411 int fb_show_logo(struct fb_info *info)
412 {
413         u32 *palette = NULL, *saved_pseudo_palette = NULL;
414         unsigned char *logo_new = NULL;
415         struct fb_image image;
416         int x;
417
418         /* Return if the frame buffer is not mapped or suspended */
419         if (fb_logo.logo == NULL || info->state != FBINFO_STATE_RUNNING)
420                 return 0;
421
422         image.depth = 8;
423         image.data = fb_logo.logo->data;
424
425         if (fb_logo.needs_cmapreset)
426                 fb_set_logocmap(info, fb_logo.logo);
427
428         if (fb_logo.needs_truepalette || 
429             fb_logo.needs_directpalette) {
430                 palette = kmalloc(256 * 4, GFP_KERNEL);
431                 if (palette == NULL)
432                         return 0;
433
434                 if (fb_logo.needs_truepalette)
435                         fb_set_logo_truepalette(info, fb_logo.logo, palette);
436                 else
437                         fb_set_logo_directpalette(info, fb_logo.logo, palette);
438
439                 saved_pseudo_palette = info->pseudo_palette;
440                 info->pseudo_palette = palette;
441         }
442
443         if (fb_logo.depth <= 4) {
444                 logo_new = kmalloc(fb_logo.logo->width * fb_logo.logo->height, 
445                                    GFP_KERNEL);
446                 if (logo_new == NULL) {
447                         if (palette)
448                                 kfree(palette);
449                         if (saved_pseudo_palette)
450                                 info->pseudo_palette = saved_pseudo_palette;
451                         return 0;
452                 }
453                 image.data = logo_new;
454                 fb_set_logo(info, fb_logo.logo, logo_new, fb_logo.depth);
455         }
456
457         image.width = fb_logo.logo->width;
458         image.height = fb_logo.logo->height;
459         image.dy = 0;
460
461         for (x = 0; x < num_online_cpus() * (fb_logo.logo->width + 8) &&
462              x <= info->var.xres-fb_logo.logo->width; x += (fb_logo.logo->width + 8)) {
463                 image.dx = x;
464                 info->fbops->fb_imageblit(info, &image);
465         }
466         
467         if (palette != NULL)
468                 kfree(palette);
469         if (saved_pseudo_palette != NULL)
470                 info->pseudo_palette = saved_pseudo_palette;
471         if (logo_new != NULL)
472                 kfree(logo_new);
473         return fb_logo.logo->height;
474 }
475 #else
476 int fb_prepare_logo(struct fb_info *info) { return 0; }
477 int fb_show_logo(struct fb_info *info) { return 0; }
478 #endif /* CONFIG_LOGO */
479
480 static int fbmem_read_proc(char *buf, char **start, off_t offset,
481                            int len, int *eof, void *private)
482 {
483         struct fb_info **fi;
484         int clen;
485
486         clen = 0;
487         for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
488                 if (*fi)
489                         clen += sprintf(buf + clen, "%d %s\n",
490                                         (*fi)->node,
491                                         (*fi)->fix.id);
492         *start = buf + offset;
493         if (clen > offset)
494                 clen -= offset;
495         else
496                 clen = 0;
497         return clen < len ? clen : len;
498 }
499
500 static ssize_t
501 fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
502 {
503         unsigned long p = *ppos;
504         struct inode *inode = file->f_dentry->d_inode;
505         int fbidx = iminor(inode);
506         struct fb_info *info = registered_fb[fbidx];
507         u32 *buffer, *dst, *src;
508         int c, i, cnt = 0, err = 0;
509         unsigned long total_size;
510
511         if (!info || ! info->screen_base)
512                 return -ENODEV;
513
514         if (info->state != FBINFO_STATE_RUNNING)
515                 return -EPERM;
516
517         if (info->fbops->fb_read)
518                 return info->fbops->fb_read(file, buf, count, ppos);
519         
520         total_size = info->screen_size;
521         if (total_size == 0)
522                 total_size = info->fix.smem_len;
523
524         if (p >= total_size)
525             return 0;
526         if (count >= total_size)
527             count = total_size;
528         if (count + p > total_size)
529                 count = total_size - p;
530
531         cnt = 0;
532         buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
533                          GFP_KERNEL);
534         if (!buffer)
535                 return -ENOMEM;
536
537         src = (u32 *) (info->screen_base + p);
538
539         if (info->fbops->fb_sync)
540                 info->fbops->fb_sync(info);
541
542         while (count) {
543                 c  = (count > PAGE_SIZE) ? PAGE_SIZE : count;
544                 dst = buffer;
545                 for (i = c >> 2; i--; )
546                         *dst++ = fb_readl(src++);
547                 if (c & 3) {
548                         u8 *dst8 = (u8 *) dst;
549                         u8 *src8 = (u8 *) src;
550
551                         for (i = c & 3; i--;)
552                                 *dst8++ = fb_readb(src8++);
553
554                         src = (u32 *) src8;
555                 }
556
557                 if (copy_to_user(buf, buffer, c)) {
558                         err = -EFAULT;
559                         break;
560                 }
561                 *ppos += c;
562                 buf += c;
563                 cnt += c;
564                 count -= c;
565         }
566
567         kfree(buffer);
568         return (err) ? err : cnt;
569 }
570
571 static ssize_t
572 fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
573 {
574         unsigned long p = *ppos;
575         struct inode *inode = file->f_dentry->d_inode;
576         int fbidx = iminor(inode);
577         struct fb_info *info = registered_fb[fbidx];
578         u32 *buffer, *dst, *src;
579         int c, i, cnt = 0, err;
580         unsigned long total_size;
581
582         if (!info || !info->screen_base)
583                 return -ENODEV;
584
585         if (info->state != FBINFO_STATE_RUNNING)
586                 return -EPERM;
587
588         if (info->fbops->fb_write)
589                 return info->fbops->fb_write(file, buf, count, ppos);
590         
591         total_size = info->screen_size;
592         if (total_size == 0)
593                 total_size = info->fix.smem_len;
594
595         if (p > total_size)
596             return -ENOSPC;
597         if (count >= total_size)
598             count = total_size;
599         err = 0;
600         if (count + p > total_size) {
601             count = total_size - p;
602             err = -ENOSPC;
603         }
604         cnt = 0;
605         buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
606                          GFP_KERNEL);
607         if (!buffer)
608                 return -ENOMEM;
609
610         dst = (u32 *) (info->screen_base + p);
611
612         if (info->fbops->fb_sync)
613                 info->fbops->fb_sync(info);
614
615         while (count) {
616                 c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
617                 src = buffer;
618                 if (copy_from_user(src, buf, c)) {
619                         err = -EFAULT;
620                         break;
621                 }
622                 for (i = c >> 2; i--; )
623                         fb_writel(*src++, dst++);
624                 if (c & 3) {
625                         u8 *src8 = (u8 *) src;
626                         u8 *dst8 = (u8 *) dst;
627
628                         for (i = c & 3; i--; )
629                                 fb_writeb(*src8++, dst8++);
630
631                         dst = (u32 *) dst8;
632                 }
633                 *ppos += c;
634                 buf += c;
635                 cnt += c;
636                 count -= c;
637         }
638         kfree(buffer);
639
640         return (err) ? err : cnt;
641 }
642
643 #ifdef CONFIG_KMOD
644 static void try_to_load(int fb)
645 {
646         request_module("fb%d", fb);
647 }
648 #endif /* CONFIG_KMOD */
649
650 void
651 fb_load_cursor_image(struct fb_info *info)
652 {
653         unsigned int width = (info->cursor.image.width + 7) >> 3;
654         u8 *data = (u8 *) info->cursor.image.data;
655
656         if (info->sprite.outbuf)
657             info->sprite.outbuf(info, info->sprite.addr, data, width);
658         else
659             memcpy(info->sprite.addr, data, width);
660 }
661
662 int
663 fb_cursor(struct fb_info *info, struct fb_cursor_user __user *sprite)
664 {
665         struct fb_cursor_user cursor_user;
666         struct fb_cursor cursor;
667         char *data = NULL, *mask = NULL, *info_mask = NULL;
668         u16 *red = NULL, *green = NULL, *blue = NULL, *transp = NULL;
669         int err = -EINVAL;
670         
671         if (copy_from_user(&cursor_user, sprite, sizeof(struct fb_cursor_user)))
672                 return -EFAULT;
673
674         memcpy(&cursor, &cursor_user, sizeof(cursor_user));
675         cursor.mask = info->cursor.mask;
676         cursor.image.data = info->cursor.image.data;
677         cursor.image.cmap.red = info->cursor.image.cmap.red;
678         cursor.image.cmap.green = info->cursor.image.cmap.green;
679         cursor.image.cmap.blue = info->cursor.image.cmap.blue;
680         cursor.image.cmap.transp = info->cursor.image.cmap.transp;
681         cursor.data = NULL;
682
683         if (cursor.set & FB_CUR_SETCUR)
684                 info->cursor.enable = 1;
685         
686         if (cursor.set & FB_CUR_SETCMAP) {
687                 unsigned len = cursor.image.cmap.len;
688                 if ((int)len <= 0)
689                         goto out;
690                 len *= 2;
691                 err = -ENOMEM;
692                 red = kmalloc(len, GFP_USER);
693                 green = kmalloc(len, GFP_USER);
694                 blue = kmalloc(len, GFP_USER);
695                 if (!red || !green || !blue)
696                         goto out;
697                 if (cursor_user.image.cmap.transp) {
698                         transp = kmalloc(len, GFP_USER);
699                         if (!transp)
700                                 goto out;
701                 }
702                 err = -EFAULT;
703                 if (copy_from_user(red, cursor_user.image.cmap.red, len))
704                         goto out;
705                 if (copy_from_user(green, cursor_user.image.cmap.green, len))
706                         goto out;
707                 if (copy_from_user(blue, cursor_user.image.cmap.blue, len))
708                         goto out;
709                 if (transp) {
710                         if (copy_from_user(transp,
711                                            cursor_user.image.cmap.transp, len))
712                                 goto out;
713                 }
714                 cursor.image.cmap.red = red;
715                 cursor.image.cmap.green = green;
716                 cursor.image.cmap.blue = blue;
717                 cursor.image.cmap.transp = transp;
718         }
719         
720         if (cursor.set & FB_CUR_SETSHAPE) {
721                 int size = ((cursor.image.width + 7) >> 3) * cursor.image.height;               
722
723                 if ((cursor.image.height != info->cursor.image.height) ||
724                     (cursor.image.width != info->cursor.image.width))
725                         cursor.set |= FB_CUR_SETSIZE;
726                 
727                 err = -ENOMEM;
728                 data = kmalloc(size, GFP_USER);
729                 mask = kmalloc(size, GFP_USER);
730                 if (!mask || !data)
731                         goto out;
732                 
733                 err = -EFAULT;
734                 if (copy_from_user(data, cursor_user.image.data, size) ||
735                     copy_from_user(mask, cursor_user.mask, size))
736                         goto out;
737                 
738                 cursor.image.data = data;
739                 cursor.mask = mask;
740                 info_mask = (char *) info->cursor.mask;
741                 info->cursor.mask = mask;
742         }
743         info->cursor.set = cursor.set;
744         info->cursor.rop = cursor.rop;
745         err = info->fbops->fb_cursor(info, &cursor);
746 out:
747         kfree(data);
748         kfree(mask);
749         kfree(red);
750         kfree(green);
751         kfree(blue);
752         kfree(transp);
753         if (info_mask)
754                 info->cursor.mask = info_mask;
755         return err;
756 }
757
758 int
759 fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
760 {
761         int xoffset = var->xoffset;
762         int yoffset = var->yoffset;
763         int err;
764
765         if (xoffset < 0 || yoffset < 0 || !info->fbops->fb_pan_display ||
766             xoffset + info->var.xres > info->var.xres_virtual ||
767             yoffset + info->var.yres > info->var.yres_virtual)
768                 return -EINVAL;
769         if ((err = info->fbops->fb_pan_display(var, info)))
770                 return err;
771         info->var.xoffset = var->xoffset;
772         info->var.yoffset = var->yoffset;
773         if (var->vmode & FB_VMODE_YWRAP)
774                 info->var.vmode |= FB_VMODE_YWRAP;
775         else
776                 info->var.vmode &= ~FB_VMODE_YWRAP;
777         return 0;
778 }
779
780 int
781 fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
782 {
783         int err;
784
785         if (var->activate & FB_ACTIVATE_INV_MODE) {
786                 struct fb_videomode mode1, mode2;
787                 int ret = 0;
788
789                 fb_var_to_videomode(&mode1, var);
790                 fb_var_to_videomode(&mode2, &info->var);
791                 /* make sure we don't delete the videomode of current var */
792                 ret = fb_mode_is_equal(&mode1, &mode2);
793
794                 if (!ret) {
795                     struct fb_event event;
796
797                     event.info = info;
798                     event.data = &mode1;
799                     ret = notifier_call_chain(&fb_notifier_list,
800                                               FB_EVENT_MODE_DELETE, &event);
801                 }
802
803                 if (!ret)
804                     fb_delete_videomode(&mode1, &info->modelist);
805
806                 return ret;
807         }
808
809         if ((var->activate & FB_ACTIVATE_FORCE) ||
810             memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
811                 if (!info->fbops->fb_check_var) {
812                         *var = info->var;
813                         return 0;
814                 }
815
816                 if ((err = info->fbops->fb_check_var(var, info)))
817                         return err;
818
819                 if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
820                         struct fb_videomode mode;
821                         info->var = *var;
822
823                         if (info->fbops->fb_set_par)
824                                 info->fbops->fb_set_par(info);
825
826                         fb_pan_display(info, &info->var);
827
828                         fb_set_cmap(&info->cmap, info);
829
830                         fb_var_to_videomode(&mode, &info->var);
831                         fb_add_videomode(&mode, &info->modelist);
832
833                         if (info->flags & FBINFO_MISC_MODECHANGEUSER) {
834                                 struct fb_event event;
835
836                                 info->flags &= ~FBINFO_MISC_MODECHANGEUSER;
837                                 event.info = info;
838                                 notifier_call_chain(&fb_notifier_list,
839                                                     FB_EVENT_MODE_CHANGE, &event);
840                         }
841                 }
842         }
843         return 0;
844 }
845
846 int
847 fb_blank(struct fb_info *info, int blank)
848 {       
849         /* ??? Variable sized stack allocation.  */
850         u16 black[info->cmap.len];
851         struct fb_cmap cmap;
852         
853         if (info->fbops->fb_blank && !info->fbops->fb_blank(blank, info))
854                 return 0;
855         if (blank) { 
856                 memset(black, 0, info->cmap.len * sizeof(u16));
857                 cmap.red = cmap.green = cmap.blue = black;
858                 cmap.transp = info->cmap.transp ? black : NULL;
859                 cmap.start = info->cmap.start;
860                 cmap.len = info->cmap.len;
861         } else
862                 cmap = info->cmap;
863         return fb_set_cmap(&cmap, info);
864 }
865
866 static int 
867 fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
868          unsigned long arg)
869 {
870         int fbidx = iminor(inode);
871         struct fb_info *info = registered_fb[fbidx];
872         struct fb_ops *fb = info->fbops;
873         struct fb_var_screeninfo var;
874         struct fb_fix_screeninfo fix;
875         struct fb_con2fbmap con2fb;
876         struct fb_cmap_user cmap;
877         struct fb_event event;
878         void __user *argp = (void __user *)arg;
879         int i;
880         
881         if (!fb)
882                 return -ENODEV;
883         switch (cmd) {
884         case FBIOGET_VSCREENINFO:
885                 return copy_to_user(argp, &info->var,
886                                     sizeof(var)) ? -EFAULT : 0;
887         case FBIOPUT_VSCREENINFO:
888                 if (copy_from_user(&var, argp, sizeof(var)))
889                         return -EFAULT;
890                 acquire_console_sem();
891                 info->flags |= FBINFO_MISC_MODECHANGEUSER;
892                 i = fb_set_var(info, &var);
893                 info->flags &= ~FBINFO_MISC_MODECHANGEUSER;
894                 release_console_sem();
895                 if (i) return i;
896                 if (copy_to_user(argp, &var, sizeof(var)))
897                         return -EFAULT;
898                 return 0;
899         case FBIOGET_FSCREENINFO:
900                 return copy_to_user(argp, &info->fix,
901                                     sizeof(fix)) ? -EFAULT : 0;
902         case FBIOPUTCMAP:
903                 if (copy_from_user(&cmap, argp, sizeof(cmap)))
904                         return -EFAULT;
905                 return (fb_set_user_cmap(&cmap, info));
906         case FBIOGETCMAP:
907                 if (copy_from_user(&cmap, argp, sizeof(cmap)))
908                         return -EFAULT;
909                 return fb_cmap_to_user(&info->cmap, &cmap);
910         case FBIOPAN_DISPLAY:
911                 if (copy_from_user(&var, argp, sizeof(var)))
912                         return -EFAULT;
913                 acquire_console_sem();
914                 i = fb_pan_display(info, &var);
915                 release_console_sem();
916                 if (i)
917                         return i;
918                 if (copy_to_user(argp, &var, sizeof(var)))
919                         return -EFAULT;
920                 return 0;
921         case FBIO_CURSOR:
922                 acquire_console_sem();
923                 i = fb_cursor(info, argp);
924                 release_console_sem();
925                 return i;
926         case FBIOGET_CON2FBMAP:
927                 if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
928                         return -EFAULT;
929                 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
930                     return -EINVAL;
931                 con2fb.framebuffer = -1;
932                 event.info = info;
933                 event.data = &con2fb;
934                 notifier_call_chain(&fb_notifier_list,
935                                     FB_EVENT_GET_CONSOLE_MAP, &event);
936                 return copy_to_user(argp, &con2fb,
937                                     sizeof(con2fb)) ? -EFAULT : 0;
938         case FBIOPUT_CON2FBMAP:
939                 if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
940                         return - EFAULT;
941                 if (con2fb.console < 0 || con2fb.console > MAX_NR_CONSOLES)
942                     return -EINVAL;
943                 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
944                     return -EINVAL;
945 #ifdef CONFIG_KMOD
946                 if (!registered_fb[con2fb.framebuffer])
947                     try_to_load(con2fb.framebuffer);
948 #endif /* CONFIG_KMOD */
949                 if (!registered_fb[con2fb.framebuffer])
950                     return -EINVAL;
951                 if (con2fb.console > 0 && con2fb.console < MAX_NR_CONSOLES) {
952                         event.info = info;
953                         event.data = &con2fb;
954                         return notifier_call_chain(&fb_notifier_list,
955                                                    FB_EVENT_SET_CONSOLE_MAP,
956                                                    &event);
957                 }
958                 return -EINVAL;
959         case FBIOBLANK:
960                 acquire_console_sem();
961                 i = fb_blank(info, arg);
962                 release_console_sem();
963                 return i;
964         default:
965                 if (fb->fb_ioctl == NULL)
966                         return -EINVAL;
967                 return fb->fb_ioctl(inode, file, cmd, arg, info);
968         }
969 }
970
971 static int 
972 fb_mmap(struct file *file, struct vm_area_struct * vma)
973 {
974         int fbidx = iminor(file->f_dentry->d_inode);
975         struct fb_info *info = registered_fb[fbidx];
976         struct fb_ops *fb = info->fbops;
977         unsigned long off;
978 #if !defined(__sparc__) || defined(__sparc_v9__)
979         unsigned long start;
980         u32 len;
981 #endif
982
983         if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
984                 return -EINVAL;
985         off = vma->vm_pgoff << PAGE_SHIFT;
986         if (!fb)
987                 return -ENODEV;
988         if (fb->fb_mmap) {
989                 int res;
990                 lock_kernel();
991                 res = fb->fb_mmap(info, file, vma);
992                 unlock_kernel();
993                 return res;
994         }
995
996 #if defined(__sparc__) && !defined(__sparc_v9__)
997         /* Should never get here, all fb drivers should have their own
998            mmap routines */
999         return -EINVAL;
1000 #else
1001         /* !sparc32... */
1002         lock_kernel();
1003
1004         /* frame buffer memory */
1005         start = info->fix.smem_start;
1006         len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
1007         if (off >= len) {
1008                 /* memory mapped io */
1009                 off -= len;
1010                 if (info->var.accel_flags) {
1011                         unlock_kernel();
1012                         return -EINVAL;
1013                 }
1014                 start = info->fix.mmio_start;
1015                 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
1016         }
1017         unlock_kernel();
1018         start &= PAGE_MASK;
1019         if ((vma->vm_end - vma->vm_start + off) > len)
1020                 return -EINVAL;
1021         off += start;
1022         vma->vm_pgoff = off >> PAGE_SHIFT;
1023         /* This is an IO map - tell maydump to skip this VMA */
1024         vma->vm_flags |= VM_IO;
1025 #if defined(__sparc_v9__)
1026         vma->vm_flags |= (VM_SHM | VM_LOCKED);
1027         if (io_remap_page_range(vma, vma->vm_start, off,
1028                                 vma->vm_end - vma->vm_start, vma->vm_page_prot, 0))
1029                 return -EAGAIN;
1030 #else
1031 #if defined(__mc68000__)
1032 #if defined(CONFIG_SUN3)
1033         pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
1034 #elif defined(CONFIG_MMU)
1035         if (CPU_IS_020_OR_030)
1036                 pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030;
1037         if (CPU_IS_040_OR_060) {
1038                 pgprot_val(vma->vm_page_prot) &= _CACHEMASK040;
1039                 /* Use no-cache mode, serialized */
1040                 pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S;
1041         }
1042 #endif
1043 #elif defined(__powerpc__)
1044         pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
1045 #elif defined(__alpha__)
1046         /* Caching is off in the I/O space quadrant by design.  */
1047 #elif defined(__i386__) || defined(__x86_64__)
1048         if (boot_cpu_data.x86 > 3)
1049                 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
1050 #elif defined(__mips__)
1051         vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1052 #elif defined(__hppa__)
1053         pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
1054 #elif defined(__ia64__) || defined(__arm__) || defined(__sh__)
1055         vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
1056 #else
1057 #warning What do we have to do here??
1058 #endif
1059         if (io_remap_page_range(vma, vma->vm_start, off,
1060                              vma->vm_end - vma->vm_start, vma->vm_page_prot))
1061                 return -EAGAIN;
1062 #endif /* !__sparc_v9__ */
1063         return 0;
1064 #endif /* !sparc32 */
1065 }
1066
1067 static int
1068 fb_open(struct inode *inode, struct file *file)
1069 {
1070         int fbidx = iminor(inode);
1071         struct fb_info *info;
1072         int res = 0;
1073
1074         if (fbidx >= FB_MAX)
1075                 return -ENODEV;
1076 #ifdef CONFIG_KMOD
1077         if (!(info = registered_fb[fbidx]))
1078                 try_to_load(fbidx);
1079 #endif /* CONFIG_KMOD */
1080         if (!(info = registered_fb[fbidx]))
1081                 return -ENODEV;
1082         if (!try_module_get(info->fbops->owner))
1083                 return -ENODEV;
1084         if (info->fbops->fb_open) {
1085                 res = info->fbops->fb_open(info,1);
1086                 if (res)
1087                         module_put(info->fbops->owner);
1088         }
1089         return res;
1090 }
1091
1092 static int 
1093 fb_release(struct inode *inode, struct file *file)
1094 {
1095         int fbidx = iminor(inode);
1096         struct fb_info *info;
1097
1098         lock_kernel();
1099         info = registered_fb[fbidx];
1100         if (info->fbops->fb_release)
1101                 info->fbops->fb_release(info,1);
1102         module_put(info->fbops->owner);
1103         unlock_kernel();
1104         return 0;
1105 }
1106
1107 static struct file_operations fb_fops = {
1108         .owner =        THIS_MODULE,
1109         .read =         fb_read,
1110         .write =        fb_write,
1111         .ioctl =        fb_ioctl,
1112         .mmap =         fb_mmap,
1113         .open =         fb_open,
1114         .release =      fb_release,
1115 #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
1116         .get_unmapped_area = get_fb_unmapped_area,
1117 #endif
1118 };
1119
1120 static struct class_simple *fb_class;
1121
1122 /**
1123  *      register_framebuffer - registers a frame buffer device
1124  *      @fb_info: frame buffer info structure
1125  *
1126  *      Registers a frame buffer device @fb_info.
1127  *
1128  *      Returns negative errno on error, or zero for success.
1129  *
1130  */
1131
1132 int
1133 register_framebuffer(struct fb_info *fb_info)
1134 {
1135         int i;
1136         struct class_device *c;
1137         struct fb_event event;
1138
1139         if (num_registered_fb == FB_MAX)
1140                 return -ENXIO;
1141         num_registered_fb++;
1142         for (i = 0 ; i < FB_MAX; i++)
1143                 if (!registered_fb[i])
1144                         break;
1145         fb_info->node = i;
1146
1147         c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
1148         if (IS_ERR(c)) {
1149                 /* Not fatal */
1150                 printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c));
1151         }
1152         
1153         if (fb_info->pixmap.addr == NULL) {
1154                 fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
1155                 if (fb_info->pixmap.addr) {
1156                         fb_info->pixmap.size = FBPIXMAPSIZE;
1157                         fb_info->pixmap.buf_align = 1;
1158                         fb_info->pixmap.scan_align = 1;
1159                         fb_info->pixmap.access_align = 4;
1160                         fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
1161                 }
1162         }       
1163         fb_info->pixmap.offset = 0;
1164
1165         if (fb_info->sprite.addr == NULL) {
1166                 fb_info->sprite.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
1167                 if (fb_info->sprite.addr) {
1168                         fb_info->sprite.size = FBPIXMAPSIZE;
1169                         fb_info->sprite.buf_align = 1;
1170                         fb_info->sprite.scan_align = 1;
1171                         fb_info->sprite.access_align = 4;
1172                         fb_info->sprite.flags = FB_PIXMAP_DEFAULT;
1173                 }
1174         }
1175         fb_info->sprite.offset = 0;
1176
1177         if (!fb_info->modelist.prev ||
1178             !fb_info->modelist.next ||
1179             list_empty(&fb_info->modelist)) {
1180                 struct fb_videomode mode;
1181
1182                 INIT_LIST_HEAD(&fb_info->modelist);
1183                 fb_var_to_videomode(&mode, &fb_info->var);
1184                 fb_add_videomode(&mode, &fb_info->modelist);
1185         }
1186
1187         registered_fb[i] = fb_info;
1188
1189         devfs_mk_cdev(MKDEV(FB_MAJOR, i),
1190                         S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i);
1191         event.info = fb_info;
1192         notifier_call_chain(&fb_notifier_list,
1193                             FB_EVENT_FB_REGISTERED, &event);
1194         return 0;
1195 }
1196
1197
1198 /**
1199  *      unregister_framebuffer - releases a frame buffer device
1200  *      @fb_info: frame buffer info structure
1201  *
1202  *      Unregisters a frame buffer device @fb_info.
1203  *
1204  *      Returns negative errno on error, or zero for success.
1205  *
1206  */
1207
1208 int
1209 unregister_framebuffer(struct fb_info *fb_info)
1210 {
1211         int i;
1212
1213         i = fb_info->node;
1214         if (!registered_fb[i])
1215                 return -EINVAL;
1216         devfs_remove("fb/%d", i);
1217
1218         if (fb_info->pixmap.addr && (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
1219                 kfree(fb_info->pixmap.addr);
1220         if (fb_info->sprite.addr && (fb_info->sprite.flags & FB_PIXMAP_DEFAULT))
1221                 kfree(fb_info->sprite.addr);
1222         fb_destroy_modelist(&fb_info->modelist);
1223         registered_fb[i]=NULL;
1224         num_registered_fb--;
1225         class_simple_device_remove(MKDEV(FB_MAJOR, i));
1226         return 0;
1227 }
1228
1229 /**
1230  *      fb_register_client - register a client notifier
1231  *      @nb: notifier block to callback on events
1232  */
1233 int fb_register_client(struct notifier_block *nb)
1234 {
1235         return notifier_chain_register(&fb_notifier_list, nb);
1236 }
1237
1238 /**
1239  *      fb_unregister_client - unregister a client notifier
1240  *      @nb: notifier block to callback on events
1241  */
1242 int fb_unregister_client(struct notifier_block *nb)
1243 {
1244         return notifier_chain_unregister(&fb_notifier_list, nb);
1245 }
1246
1247 /**
1248  *      fb_set_suspend - low level driver signals suspend
1249  *      @info: framebuffer affected
1250  *      @state: 0 = resuming, !=0 = suspending
1251  *
1252  *      This is meant to be used by low level drivers to
1253  *      signal suspend/resume to the core & clients.
1254  *      It must be called with the console semaphore held
1255  */
1256 void fb_set_suspend(struct fb_info *info, int state)
1257 {
1258         struct fb_event event;
1259
1260         event.info = info;
1261         if (state) {
1262                 notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, &event);
1263                 info->state = FBINFO_STATE_SUSPENDED;
1264         } else {
1265                 info->state = FBINFO_STATE_RUNNING;
1266                 notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, &event);
1267         }
1268 }
1269
1270 /**
1271  *      fbmem_init - init frame buffer subsystem
1272  *
1273  *      Initialize the frame buffer subsystem.
1274  *
1275  *      NOTE: This function is _only_ to be called by drivers/char/mem.c.
1276  *
1277  */
1278
1279 int __init
1280 fbmem_init(void)
1281 {
1282         create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL);
1283
1284         devfs_mk_dir("fb");
1285         if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
1286                 printk("unable to get major %d for fb devs\n", FB_MAJOR);
1287
1288         fb_class = class_simple_create(THIS_MODULE, "graphics");
1289         if (IS_ERR(fb_class)) {
1290                 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
1291                 fb_class = NULL;
1292         }
1293         return 0;
1294 }
1295 module_init(fbmem_init);
1296
1297 #define NR_FB_DRIVERS 64
1298 static char *video_options[NR_FB_DRIVERS];
1299 static int ofonly;
1300
1301 /**
1302  * fb_get_options - get kernel boot parameters
1303  * @name - framebuffer name as it would appear in
1304  *         the boot parameter line
1305  *         (video=<name>:<options>)
1306  *
1307  * NOTE: Needed to maintain backwards compatibility
1308  */
1309 int fb_get_options(char *name, char **option)
1310 {
1311         char *opt, *options = NULL;
1312         int opt_len, retval = 0;
1313         int name_len = strlen(name), i;
1314
1315         if (name_len && ofonly && strncmp(name, "offb", 4))
1316                 retval = 1;
1317
1318         if (name_len && !retval) {
1319                 for (i = 0; i < NR_FB_DRIVERS; i++) {
1320                         if (video_options[i] == NULL)
1321                                 continue;
1322                         opt_len = strlen(video_options[i]);
1323                         if (!opt_len)
1324                                 continue;
1325                         opt = video_options[i];
1326                         if (!strncmp(name, opt, name_len) &&
1327                             opt[name_len] == ':')
1328                                 options = opt + name_len + 1;
1329                 }
1330         }
1331         if (options && !strncmp(options, "off", 3))
1332                 retval = 1;
1333
1334         if (option)
1335                 *option = options;
1336
1337         return retval;
1338 }
1339
1340 /**
1341  *      video_setup - process command line options
1342  *      @options: string of options
1343  *
1344  *      Process command line options for frame buffer subsystem.
1345  *
1346  *      NOTE: This function is a __setup and __init function.
1347  *            It only stores the options.  Drivers have to call
1348  *            fb_get_options() as necessary.
1349  *
1350  *      Returns zero.
1351  *
1352  */
1353
1354 int __init video_setup(char *options)
1355 {
1356         int i;
1357
1358         if (!options || !*options)
1359                 return 0;
1360
1361         for (i = 0; i < NR_FB_DRIVERS; i++) {
1362                 if (!strncmp(options, "ofonly", 6))
1363                         ofonly = 1;
1364                 if (video_options[i] == NULL) {
1365                         video_options[i] = options;
1366                         break;
1367                 }
1368         }
1369
1370         return 0;
1371 }
1372 __setup("video=", video_setup);
1373
1374     /*
1375      *  Visible symbols for modules
1376      */
1377
1378 EXPORT_SYMBOL(register_framebuffer);
1379 EXPORT_SYMBOL(unregister_framebuffer);
1380 EXPORT_SYMBOL(num_registered_fb);
1381 EXPORT_SYMBOL(registered_fb);
1382 EXPORT_SYMBOL(fb_prepare_logo);
1383 EXPORT_SYMBOL(fb_show_logo);
1384 EXPORT_SYMBOL(fb_set_var);
1385 EXPORT_SYMBOL(fb_blank);
1386 EXPORT_SYMBOL(fb_pan_display);
1387 EXPORT_SYMBOL(fb_get_buffer_offset);
1388 EXPORT_SYMBOL(fb_iomove_buf_unaligned);
1389 EXPORT_SYMBOL(fb_iomove_buf_aligned);
1390 EXPORT_SYMBOL(fb_sysmove_buf_unaligned);
1391 EXPORT_SYMBOL(fb_sysmove_buf_aligned);
1392 EXPORT_SYMBOL(fb_load_cursor_image);
1393 EXPORT_SYMBOL(fb_set_suspend);
1394 EXPORT_SYMBOL(fb_register_client);
1395 EXPORT_SYMBOL(fb_unregister_client);
1396 EXPORT_SYMBOL(fb_get_options);
1397
1398 MODULE_LICENSE("GPL");