]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/vesafb.c
Pull mca-check-psp into release branch
[linux-2.6-omap-h63xx.git] / drivers / video / vesafb.c
index a272592b037391858ab28d31ad93171fc15be1bb..e25eae1a78c1de86e9f1f7f25103c12708c63a38 100644 (file)
@@ -19,6 +19,9 @@
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <video/vga.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
 
@@ -45,7 +48,7 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = {
 };
 
 static int             inverse   = 0;
-static int             mtrr      = 3; /* default to write-combining */
+static int             mtrr      = 0; /* disable mtrr */
 static int            vram_remap __initdata = 0; /* Set amount of memory to be used */
 static int            vram_total __initdata = 0; /* Set total amount of memory */
 static int             pmi_setpal = 0; /* pmi for palette changes ??? */
@@ -54,6 +57,7 @@ static unsigned short  *pmi_base  = NULL;
 static void            (*pmi_start)(void);
 static void            (*pmi_pal)(void);
 static int             depth;
+static int             vga_compat;
 
 /* --------------------------------------------------------------------- */
 
@@ -86,6 +90,37 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var,
        return 0;
 }
 
+static int vesafb_blank(int blank, struct fb_info *info)
+{
+       int err = 1;
+
+       if (vga_compat) {
+               int loop = 10000;
+               u8 seq = 0, crtc17 = 0;
+
+               if (blank == FB_BLANK_POWERDOWN) {
+                       seq = 0x20;
+                       crtc17 = 0x00;
+                       err = 0;
+               } else {
+                       seq = 0x00;
+                       crtc17 = 0x80;
+                       err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL;
+               }
+
+               vga_wseq(NULL, 0x00, 0x01);
+               seq |= vga_rseq(NULL, 0x01) & ~0x20;
+               vga_wseq(NULL, 0x00, seq);
+
+               crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80;
+               while (loop--);
+               vga_wcrt(NULL, 0x17, crtc17);
+               vga_wseq(NULL, 0x00, 0x03);
+       }
+
+       return err;
+}
+
 static void vesa_setpalette(int regno, unsigned red, unsigned green,
                            unsigned blue)
 {
@@ -131,55 +166,49 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
        if (regno >= info->cmap.len)
                return 1;
 
-       switch (info->var.bits_per_pixel) {
-       case 8:
+       if (info->var.bits_per_pixel == 8)
                vesa_setpalette(regno,red,green,blue);
-               break;
-       case 16:
-               if (info->var.red.offset == 10) {
-                       /* 1:5:5:5 */
-                       ((u32*) (info->pseudo_palette))[regno] =        
+       else if (regno < 16) {
+               switch (info->var.bits_per_pixel) {
+               case 16:
+                       if (info->var.red.offset == 10) {
+                               /* 1:5:5:5 */
+                               ((u32*) (info->pseudo_palette))[regno] =
                                        ((red   & 0xf800) >>  1) |
                                        ((green & 0xf800) >>  6) |
                                        ((blue  & 0xf800) >> 11);
-               } else {
-                       /* 0:5:6:5 */
-                       ((u32*) (info->pseudo_palette))[regno] =        
+                       } else {
+                               /* 0:5:6:5 */
+                               ((u32*) (info->pseudo_palette))[regno] =
                                        ((red   & 0xf800)      ) |
                                        ((green & 0xfc00) >>  5) |
                                        ((blue  & 0xf800) >> 11);
+                       }
+                       break;
+               case 24:
+               case 32:
+                       red   >>= 8;
+                       green >>= 8;
+                       blue  >>= 8;
+                       ((u32 *)(info->pseudo_palette))[regno] =
+                               (red   << info->var.red.offset)   |
+                               (green << info->var.green.offset) |
+                               (blue  << info->var.blue.offset);
+                       break;
                }
-               break;
-       case 24:
-               red   >>= 8;
-               green >>= 8;
-               blue  >>= 8;
-               ((u32 *)(info->pseudo_palette))[regno] =
-                       (red   << info->var.red.offset)   |
-                       (green << info->var.green.offset) |
-                       (blue  << info->var.blue.offset);
-               break;
-       case 32:
-               red   >>= 8;
-               green >>= 8;
-               blue  >>= 8;
-               ((u32 *)(info->pseudo_palette))[regno] =
-                       (red   << info->var.red.offset)   |
-                       (green << info->var.green.offset) |
-                       (blue  << info->var.blue.offset);
-               break;
-    }
-    return 0;
+       }
+
+       return 0;
 }
 
 static struct fb_ops vesafb_ops = {
        .owner          = THIS_MODULE,
        .fb_setcolreg   = vesafb_setcolreg,
        .fb_pan_display = vesafb_pan_display,
+       .fb_blank       = vesafb_blank,
        .fb_fillrect    = cfb_fillrect,
        .fb_copyarea    = cfb_copyarea,
        .fb_imageblit   = cfb_imageblit,
-       .fb_cursor      = soft_cursor,
 };
 
 static int __init vesafb_setup(char *options)
@@ -429,6 +458,10 @@ static int __init vesafb_probe(struct device *device)
        info->flags = FBINFO_FLAG_DEFAULT |
                (ypan) ? FBINFO_HWACCEL_YPAN : 0;
 
+       vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
+       printk("vesafb: Mode is %sVGA compatible\n",
+              (vga_compat) ? "" : "not ");
+
        if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
                err = -ENOMEM;
                goto err;