[PATCH] fbcon: Break up bit_putcs into its component functions
[safe/jmp/linux-2.6] / drivers / video / fbmem.c
index 25f460c..70be700 100644 (file)
@@ -62,84 +62,40 @@ int num_registered_fb;
  * Helpers
  */
 
-int fb_get_color_depth(struct fb_var_screeninfo *var)
+int fb_get_color_depth(struct fb_var_screeninfo *var,
+                      struct fb_fix_screeninfo *fix)
 {
-       if (var->green.length == var->blue.length &&
-           var->green.length == var->red.length &&
-           !var->green.offset && !var->blue.offset &&
-           !var->red.offset)
-               return var->green.length;
-       else
-               return (var->green.length + var->red.length +
-                       var->blue.length);
+       int depth = 0;
+
+       if (fix->visual == FB_VISUAL_MONO01 ||
+           fix->visual == FB_VISUAL_MONO10)
+               depth = 1;
+       else {
+               if (var->green.length == var->blue.length &&
+                   var->green.length == var->red.length &&
+                   var->green.offset == var->blue.offset &&
+                   var->green.offset == var->red.offset)
+                       depth = var->green.length;
+               else
+                       depth = var->green.length + var->red.length +
+                               var->blue.length;
+       }
+
+       return depth;
 }
 EXPORT_SYMBOL(fb_get_color_depth);
 
 /*
- * Drawing helpers.
+ * Data padding functions.
  */
-void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
-                          u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
-                          u32 height)
+void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height)
 {
-       int i;
-
-       for (i = height; i--; ) {
-               buf->outbuf(info, dst, src, s_pitch);
-               src += s_pitch;
-               dst += d_pitch;
-       }
+       __fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, height);
 }
+EXPORT_SYMBOL(fb_pad_aligned_buffer);
 
-void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
-                           u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
-                           u32 height)
-{
-       int i, j;
-
-       for (i = height; i--; ) {
-               for (j = 0; j < s_pitch; j++)
-                       dst[j] = src[j];
-               src += s_pitch;
-               dst += d_pitch;
-       }
-}
-
-void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
-                            u8 *dst, u32 d_pitch, u8 *src, u32 idx,
-                            u32 height, u32 shift_high, u32 shift_low,
-                            u32 mod)
-{
-       u8 mask = (u8) (0xfff << shift_high), tmp;
-       int i, j;
-
-       for (i = height; i--; ) {
-               for (j = 0; j < idx; j++) {
-                       tmp = buf->inbuf(info, dst+j);
-                       tmp &= mask;
-                       tmp |= *src >> shift_low;
-                       buf->outbuf(info, dst+j, &tmp, 1);
-                       tmp = *src << shift_high;
-                       buf->outbuf(info, dst+j+1, &tmp, 1);
-                       src++;
-               }
-               tmp = buf->inbuf(info, dst+idx);
-               tmp &= mask;
-               tmp |= *src >> shift_low;
-               buf->outbuf(info, dst+idx, &tmp, 1);
-               if (shift_high < mod) {
-                       tmp = *src << shift_high;
-                       buf->outbuf(info, dst+idx+1, &tmp, 1);
-               }       
-               src++;
-               dst += d_pitch;
-       }
-}
-
-void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
-                             u8 *dst, u32 d_pitch, u8 *src, u32 idx,
-                             u32 height, u32 shift_high, u32 shift_low,
-                             u32 mod)
+void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
+                               u32 shift_high, u32 shift_low, u32 mod)
 {
        u8 mask = (u8) (0xfff << shift_high), tmp;
        int i, j;
@@ -166,6 +122,7 @@ void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
                dst += d_pitch;
        }
 }
+EXPORT_SYMBOL(fb_pad_unaligned_buffer);
 
 /*
  * we need to lock this section since fb_cursor
@@ -294,13 +251,18 @@ static void fb_set_logo(struct fb_info *info,
                               const struct linux_logo *logo, u8 *dst,
                               int depth)
 {
-       int i, j, k, fg = 1;
+       int i, j, k;
        const u8 *src = logo->data;
-       u8 d, xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
+       u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
+       u8 fg = 1, d;
 
-       if (fb_get_color_depth(&info->var) == 3)
+       if (fb_get_color_depth(&info->var, &info->fix) == 3)
                fg = 7;
 
+       if (info->fix.visual == FB_VISUAL_MONO01 ||
+           info->fix.visual == FB_VISUAL_MONO10)
+               fg = ~((u8) (0xfff << info->var.green.length));
+
        switch (depth) {
        case 4:
                for (i = 0; i < logo->height; i++)
@@ -363,7 +325,7 @@ static struct logo_data {
 
 int fb_prepare_logo(struct fb_info *info)
 {
-       int depth = fb_get_color_depth(&info->var);
+       int depth = fb_get_color_depth(&info->var, &info->fix);
 
        memset(&fb_logo, 0, sizeof(struct logo_data));
 
@@ -673,7 +635,7 @@ fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
 int
 fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 {
-       int err;
+       int err, flags = info->flags;
 
        if (var->activate & FB_ACTIVATE_INV_MODE) {
                struct fb_videomode mode1, mode2;
@@ -727,13 +689,15 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
                            !list_empty(&info->modelist))
                                err = fb_add_videomode(&mode, &info->modelist);
 
-                       if (!err && info->flags & FBINFO_MISC_USEREVENT) {
+                       if (!err && (flags & FBINFO_MISC_USEREVENT)) {
                                struct fb_event event;
+                               int evnt = (var->activate & FB_ACTIVATE_ALL) ?
+                                       FB_EVENT_MODE_CHANGE_ALL :
+                                       FB_EVENT_MODE_CHANGE;
 
                                info->flags &= ~FBINFO_MISC_USEREVENT;
                                event.info = info;
-                               notifier_call_chain(&fb_notifier_list,
-                                                   FB_EVENT_MODE_CHANGE,
+                               notifier_call_chain(&fb_notifier_list, evnt,
                                                    &event);
                        }
                }
@@ -1040,7 +1004,7 @@ static struct file_operations fb_fops = {
 #endif
 };
 
-static struct class_simple *fb_class;
+static struct class *fb_class;
 
 /**
  *     register_framebuffer - registers a frame buffer device
@@ -1057,6 +1021,7 @@ register_framebuffer(struct fb_info *fb_info)
 {
        int i;
        struct fb_event event;
+       struct fb_videomode mode;
 
        if (num_registered_fb == FB_MAX)
                return -ENXIO;
@@ -1066,7 +1031,7 @@ register_framebuffer(struct fb_info *fb_info)
                        break;
        fb_info->node = i;
 
-       fb_info->class_device = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i),
+       fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i),
                                    fb_info->device, "fb%d", i);
        if (IS_ERR(fb_info->class_device)) {
                /* Not fatal */
@@ -1081,22 +1046,17 @@ register_framebuffer(struct fb_info *fb_info)
                        fb_info->pixmap.size = FBPIXMAPSIZE;
                        fb_info->pixmap.buf_align = 1;
                        fb_info->pixmap.scan_align = 1;
-                       fb_info->pixmap.access_align = 4;
+                       fb_info->pixmap.access_align = 32;
                        fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
                }
        }       
        fb_info->pixmap.offset = 0;
 
-       if (!fb_info->modelist.prev ||
-           !fb_info->modelist.next ||
-           list_empty(&fb_info->modelist)) {
-               struct fb_videomode mode;
-
+       if (!fb_info->modelist.prev || !fb_info->modelist.next)
                INIT_LIST_HEAD(&fb_info->modelist);
-               fb_var_to_videomode(&mode, &fb_info->var);
-               fb_add_videomode(&mode, &fb_info->modelist);
-       }
 
+       fb_var_to_videomode(&mode, &fb_info->var);
+       fb_add_videomode(&mode, &fb_info->modelist);
        registered_fb[i] = fb_info;
 
        devfs_mk_cdev(MKDEV(FB_MAJOR, i),
@@ -1134,7 +1094,7 @@ unregister_framebuffer(struct fb_info *fb_info)
        registered_fb[i]=NULL;
        num_registered_fb--;
        fb_cleanup_class_device(fb_info);
-       class_simple_device_remove(MKDEV(FB_MAJOR, i));
+       class_device_destroy(fb_class, MKDEV(FB_MAJOR, i));
        return 0;
 }
 
@@ -1197,7 +1157,7 @@ fbmem_init(void)
        if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
                printk("unable to get major %d for fb devs\n", FB_MAJOR);
 
-       fb_class = class_simple_create(THIS_MODULE, "graphics");
+       fb_class = class_create(THIS_MODULE, "graphics");
        if (IS_ERR(fb_class)) {
                printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
                fb_class = NULL;
@@ -1210,7 +1170,8 @@ module_init(fbmem_init);
 static void __exit
 fbmem_exit(void)
 {
-       class_simple_destroy(fb_class);
+       class_destroy(fb_class);
+       unregister_chrdev(FB_MAJOR, "fb");
 }
 
 module_exit(fbmem_exit);
@@ -1257,6 +1218,8 @@ int fb_new_modelist(struct fb_info *info)
 static char *video_options[FB_MAX];
 static int ofonly;
 
+extern const char *global_mode_option;
+
 /**
  * fb_get_options - get kernel boot parameters
  * @name:   framebuffer name as it would appear in
@@ -1297,9 +1260,6 @@ int fb_get_options(char *name, char **option)
        return retval;
 }
 
-
-extern const char *global_mode_option;
-
 /**
  *     video_setup - process command line options
  *     @options: string of options
@@ -1313,7 +1273,7 @@ extern const char *global_mode_option;
  *     Returns zero.
  *
  */
-int __init video_setup(char *options)
+static int __init video_setup(char *options)
 {
        int i, global = 0;
 
@@ -1358,10 +1318,6 @@ EXPORT_SYMBOL(fb_set_var);
 EXPORT_SYMBOL(fb_blank);
 EXPORT_SYMBOL(fb_pan_display);
 EXPORT_SYMBOL(fb_get_buffer_offset);
-EXPORT_SYMBOL(fb_iomove_buf_unaligned);
-EXPORT_SYMBOL(fb_iomove_buf_aligned);
-EXPORT_SYMBOL(fb_sysmove_buf_unaligned);
-EXPORT_SYMBOL(fb_sysmove_buf_aligned);
 EXPORT_SYMBOL(fb_set_suspend);
 EXPORT_SYMBOL(fb_register_client);
 EXPORT_SYMBOL(fb_unregister_client);