Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[pandora-kernel.git] / drivers / video / gbefb.c
index 5e25b98..f89c3cc 100644 (file)
@@ -9,7 +9,6 @@
  *  more details.
  */
 
-#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
@@ -87,7 +86,9 @@ static int gbe_revision;
 
 static int ypan, ywrap;
 
-static uint32_t pseudo_palette[256];
+static uint32_t pseudo_palette[16];
+static uint32_t gbe_cmap[256];
+static int gbe_turned_on; /* 0 turned off, 1 turned on */
 
 static char *mode_option __initdata = NULL;
 
@@ -184,8 +185,8 @@ static struct fb_videomode default_mode_LCD __initdata = {
        .vmode          = FB_VMODE_NONINTERLACED,
 };
 
-struct fb_videomode *default_mode = &default_mode_CRT;
-struct fb_var_screeninfo *default_var = &default_var_CRT;
+struct fb_videomode *default_mode __initdata = &default_mode_CRT;
+struct fb_var_screeninfo *default_var __initdata = &default_var_CRT;
 
 static int flat_panel_enabled = 0;
 
@@ -209,6 +210,8 @@ void gbe_turn_off(void)
        int i;
        unsigned int val, x, y, vpixen_off;
 
+       gbe_turned_on = 0;
+
        /* check if pixel counter is on */
        val = gbe->vt_xy;
        if (GET_GBE_FIELD(VT_XY, FREEZE, val) == 1)
@@ -372,6 +375,22 @@ static void gbe_turn_on(void)
        }
        if (i == 10000)
                printk(KERN_ERR "gbefb: turn on DMA timed out\n");
+
+       gbe_turned_on = 1;
+}
+
+static void gbe_loadcmap(void)
+{
+       int i, j;
+
+       for (i = 0; i < 256; i++) {
+               for (j = 0; j < 1000 && gbe->cm_fifo >= 63; j++)
+                       udelay(10);
+               if (j == 1000)
+                       printk(KERN_ERR "gbefb: cmap FIFO timeout\n");
+
+               gbe->cmap[i] = gbe_cmap[i];
+       }
 }
 
 /*
@@ -383,6 +402,7 @@ static int gbefb_blank(int blank, struct fb_info *info)
        switch (blank) {
        case FB_BLANK_UNBLANK:          /* unblank */
                gbe_turn_on();
+               gbe_loadcmap();
                break;
 
        case FB_BLANK_NORMAL:           /* blank */
@@ -797,16 +817,10 @@ static int gbefb_set_par(struct fb_info *info)
                gbe->gmap[i] = (i << 24) | (i << 16) | (i << 8);
 
        /* Initialize the color map */
-       for (i = 0; i < 256; i++) {
-               int j;
-
-               for (j = 0; j < 1000 && gbe->cm_fifo >= 63; j++)
-                       udelay(10);
-               if (j == 1000)
-                       printk(KERN_ERR "gbefb: cmap FIFO timeout\n");
+       for (i = 0; i < 256; i++)
+               gbe_cmap[i] = (i << 8) | (i << 16) | (i << 24);
 
-               gbe->cmap[i] = (i << 8) | (i << 16) | (i << 24);
-       }
+       gbe_loadcmap();
 
        return 0;
 }
@@ -855,33 +869,37 @@ static int gbefb_setcolreg(unsigned regno, unsigned red, unsigned green,
        green >>= 8;
        blue >>= 8;
 
-       switch (info->var.bits_per_pixel) {
-       case 8:
-               /* wait for the color map FIFO to have a free entry */
-               for (i = 0; i < 1000 && gbe->cm_fifo >= 63; i++)
-                       udelay(10);
-               if (i == 1000) {
-                       printk(KERN_ERR "gbefb: cmap FIFO timeout\n");
-                       return 1;
+       if (info->var.bits_per_pixel <= 8) {
+               gbe_cmap[regno] = (red << 24) | (green << 16) | (blue << 8);
+               if (gbe_turned_on) {
+                       /* wait for the color map FIFO to have a free entry */
+                       for (i = 0; i < 1000 && gbe->cm_fifo >= 63; i++)
+                               udelay(10);
+                       if (i == 1000) {
+                               printk(KERN_ERR "gbefb: cmap FIFO timeout\n");
+                               return 1;
+                       }
+                       gbe->cmap[regno] = gbe_cmap[regno];
+               }
+       } else if (regno < 16) {
+               switch (info->var.bits_per_pixel) {
+               case 15:
+               case 16:
+                       red >>= 3;
+                       green >>= 3;
+                       blue >>= 3;
+                       pseudo_palette[regno] =
+                               (red << info->var.red.offset) |
+                               (green << info->var.green.offset) |
+                               (blue << info->var.blue.offset);
+                       break;
+               case 32:
+                       pseudo_palette[regno] =
+                               (red << info->var.red.offset) |
+                               (green << info->var.green.offset) |
+                               (blue << info->var.blue.offset);
+                       break;
                }
-               gbe->cmap[regno] = (red << 24) | (green << 16) | (blue << 8);
-               break;
-       case 15:
-       case 16:
-               red >>= 3;
-               green >>= 3;
-               blue >>= 3;
-               pseudo_palette[regno] =
-                       (red << info->var.red.offset) |
-                       (green << info->var.green.offset) |
-                       (blue << info->var.blue.offset);
-               break;
-       case 32:
-               pseudo_palette[regno] =
-                       (red << info->var.red.offset) |
-                       (green << info->var.green.offset) |
-                       (blue << info->var.blue.offset);
-               break;
        }
 
        return 0;