linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / video / vesafb.c
index 2196448..8982e54 100644 (file)
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
+#include <linux/tty.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/screen_info.h>
 
 #include <video/vga.h>
 #include <asm/io.h>
@@ -51,13 +51,13 @@ static int             inverse   = 0;
 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 = 1; /* pmi for palette changes ??? */
+static int             pmi_setpal = 0; /* pmi for palette changes ??? */
 static int             ypan       = 0;  /* 0..nothing, 1..ypan, 2..ywrap */
 static unsigned short  *pmi_base  = NULL;
 static void            (*pmi_start)(void);
 static void            (*pmi_pal)(void);
 static int             depth;
-static int             vga_compat;
+
 /* --------------------------------------------------------------------- */
 
 static int vesafb_pan_display(struct fb_var_screeninfo *var,
@@ -80,30 +80,14 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var,
        return 0;
 }
 
-static int vesa_setpalette(int regno, unsigned red, unsigned green,
+static void vesa_setpalette(int regno, unsigned red, unsigned green,
                            unsigned blue)
 {
-       int shift = 16 - depth;
-       int err = -EINVAL;
-
-/*
- * Try VGA registers first...
- */
-       if (vga_compat) {
-               outb_p(regno,       dac_reg);
-               outb_p(red   >> shift, dac_val);
-               outb_p(green >> shift, dac_val);
-               outb_p(blue  >> shift, dac_val);
-               err = 0;
-       }
-
 #ifdef __i386__
-/*
- * Fallback to the PMI....
- */
-       if (err && pmi_setpal) {
-               struct { u_char blue, green, red, pad; } entry;
+       struct { u_char blue, green, red, pad; } entry;
+       int shift = 16 - depth;
 
+       if (pmi_setpal) {
                entry.red   = red   >> shift;
                entry.green = green >> shift;
                entry.blue  = blue  >> shift;
@@ -117,19 +101,20 @@ static int vesa_setpalette(int regno, unsigned red, unsigned green,
                   "d" (regno),          /* EDX */
                   "D" (&entry),         /* EDI */
                   "S" (&pmi_pal));      /* ESI */
-               err = 0;
+       } else {
+               /* without protected mode interface, try VGA registers... */
+               outb_p(regno,       dac_reg);
+               outb_p(red   >> shift, dac_val);
+               outb_p(green >> shift, dac_val);
+               outb_p(blue  >> shift, dac_val);
        }
 #endif
-
-       return err;
 }
 
 static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
                            unsigned blue, unsigned transp,
                            struct fb_info *info)
 {
-       int err = 0;
-
        /*
         *  Set a single color register. The values supplied are
         *  already rounded down to the hardware's capabilities
@@ -141,7 +126,7 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
                return 1;
 
        if (info->var.bits_per_pixel == 8)
-               err = vesa_setpalette(regno,red,green,blue);
+               vesa_setpalette(regno,red,green,blue);
        else if (regno < 16) {
                switch (info->var.bits_per_pixel) {
                case 16:
@@ -172,7 +157,7 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
                }
        }
 
-       return err;
+       return 0;
 }
 
 static struct fb_ops vesafb_ops = {
@@ -229,7 +214,6 @@ static int __init vesafb_probe(struct platform_device *dev)
        if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
                return -ENODEV;
 
-       vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
        vesafb_fix.smem_start = screen_info.lfb_base;
        vesafb_defined.bits_per_pixel = screen_info.lfb_depth;
        if (15 == vesafb_defined.bits_per_pixel)
@@ -334,12 +318,6 @@ static int __init vesafb_probe(struct platform_device *dev)
                }
        }
 
-       if (vesafb_defined.bits_per_pixel == 8 && !pmi_setpal && !vga_compat) {
-               printk(KERN_WARNING "vesafb: hardware palette is unchangeable,\n"
-                                   "        colors may be incorrect\n");
-               vesafb_fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
-       }
-
        vesafb_defined.xres_virtual = vesafb_defined.xres;
        vesafb_defined.yres_virtual = vesafb_fix.smem_len / vesafb_fix.line_length;
        if (ypan && vesafb_defined.yres_virtual > vesafb_defined.yres) {
@@ -376,8 +354,7 @@ static int __init vesafb_probe(struct platform_device *dev)
        printk(KERN_INFO "vesafb: %s: "
               "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
               (vesafb_defined.bits_per_pixel > 8) ?
-              "Truecolor" : (vga_compat || pmi_setpal) ?
-              "Pseudocolor" : "Static Pseudocolor",
+              "Truecolor" : "Pseudocolor",
               screen_info.rsvd_size,
               screen_info.red_size,
               screen_info.green_size,
@@ -468,7 +445,9 @@ static struct platform_driver vesafb_driver = {
        },
 };
 
-static struct platform_device *vesafb_device;
+static struct platform_device vesafb_device = {
+       .name   = "vesafb",
+};
 
 static int __init vesafb_init(void)
 {
@@ -481,19 +460,10 @@ static int __init vesafb_init(void)
        ret = platform_driver_register(&vesafb_driver);
 
        if (!ret) {
-               vesafb_device = platform_device_alloc("vesafb", 0);
-
-               if (vesafb_device)
-                       ret = platform_device_add(vesafb_device);
-               else
-                       ret = -ENOMEM;
-
-               if (ret) {
-                       platform_device_put(vesafb_device);
+               ret = platform_device_register(&vesafb_device);
+               if (ret)
                        platform_driver_unregister(&vesafb_driver);
-               }
        }
-
        return ret;
 }
 module_init(vesafb_init);