fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / video / tridentfb.c
index 42e18fd..55e8aa4 100644 (file)
@@ -15,7 +15,6 @@
  *     TGUI acceleration       
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/fb.h>
 #include <linux/init.h>
@@ -31,7 +30,7 @@ struct tridentfb_par {
        void __iomem * io_virt; //iospace virtual memory address
 };
 
-unsigned char eng_oper;                //engine operation...
+static unsigned char eng_oper;         //engine operation...
 static struct fb_ops tridentfb_ops;
 
 static struct tridentfb_par default_par;
@@ -91,7 +90,7 @@ module_param(crt, int, 0);
 static int chip3D;
 static int chipcyber;
 
-int is3Dchip(int id)
+static int is3Dchip(int id)
 {
        return  ((id == BLADE3D) || (id == CYBERBLADEE4) ||
                 (id == CYBERBLADEi7) || (id == CYBERBLADEi7D) ||
@@ -104,7 +103,7 @@ int is3Dchip(int id)
                 (id == CYBERBLADEXPAi1));
 }
 
-int iscyber(int id)
+static int iscyber(int id)
 {
        switch (id) {
                case CYBER9388:         
@@ -454,13 +453,16 @@ static struct accel_switch accel_image = {
 static void tridentfb_fillrect(struct fb_info * info, const struct fb_fillrect *fr)
 {
        int bpp = info->var.bits_per_pixel;
-       int col;
+       int col = 0;
        
        switch (bpp) {
                default:
-               case 8: col = fr->color;
+               case 8: col |= fr->color;
+                       col |= col << 8;
+                       col |= col << 16;
                        break;
                case 16: col = ((u32 *)(info->pseudo_palette))[fr->color];
+                       
                         break;
                case 32: col = ((u32 *)(info->pseudo_palette))[fr->color];
                         break;
@@ -548,7 +550,7 @@ static inline void enable_mmio(void)
 #define crtc_unlock()  write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F)
 
 /*  Return flat panel's maximum x resolution */
-static int __init get_nativex(void)
+static int __devinit get_nativex(void)
 {
        int x,y,tmp;
 
@@ -655,7 +657,7 @@ static void set_number_of_lines(int lines)
  * If we see that FP is active we assume we have one.
  * Otherwise we have a CRT display.User can override.
  */
-static unsigned int __init get_displaytype(void)
+static unsigned int __devinit get_displaytype(void)
 {
        if (fp)
                return DISPLAY_FP;
@@ -665,7 +667,7 @@ static unsigned int __init get_displaytype(void)
 }
 
 /* Try detecting the video memory size */
-static unsigned int __init get_memsize(void)
+static unsigned int __devinit get_memsize(void)
 {
        unsigned char tmp, tmp2;
        unsigned int k;
@@ -882,8 +884,9 @@ static int tridentfb_set_par(struct fb_info *info)
 
        write3X4(GraphEngReg, 0x80);    //enable GE for text acceleration
 
-//     if (info->var.accel_flags & FB_ACCELF_TEXT)
-//FIXME                acc->init_accel(info->var.xres,bpp);
+#ifdef CONFIG_FB_TRIDENT_ACCEL 
+       acc->init_accel(info->var.xres,bpp);
+#endif
        
        switch (bpp) {
                case 8:  tmp = 0x00; break;
@@ -900,7 +903,7 @@ static int tridentfb_set_par(struct fb_info *info)
        write3X4(DRAMControl, tmp);     //both IO,linear enable
 
        write3X4(InterfaceSel, read3X4(InterfaceSel) | 0x40);
-       write3X4(Performance,0x20);
+       write3X4(Performance,0x92);
        write3X4(PCIReg,0x07);          //MMIO & PCI read and write burst enable
 
        /* convert from picoseconds to MHz */
@@ -981,12 +984,14 @@ static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green,
                t_outb(green>>10,0x3C9);
                t_outb(blue>>10,0x3C9);
 
-       } else
-       if (bpp == 16)                  /* RGB 565 */
-                       ((u32*)info->pseudo_palette)[regno] = (red & 0xF800) |
-                       ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
-       else
-       if (bpp == 32)          /* ARGB 8888 */
+       } else if (bpp == 16) { /* RGB 565 */
+               u32 col;
+
+               col = (red & 0xF800) | ((green & 0xFC00) >> 5) |
+                       ((blue & 0xF800) >> 11);
+               col |= col << 16;       
+               ((u32 *)(info->pseudo_palette))[regno] = col;
+       } else if (bpp == 32)           /* ARGB 8888 */
                ((u32*)info->pseudo_palette)[regno] =
                        ((transp & 0xFF00) <<16)        |
                        ((red & 0xFF00) << 8)           |
@@ -1055,6 +1060,11 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
 
        chip_id = id->device;
 
+       if(chip_id == CYBERBLADEi1)
+               output("*** Please do use cyblafb, Cyberblade/i1 support "
+                      "will soon be removed from tridentfb!\n");
+
+
        /* If PCI id is 0x9660 then further detect chip type */
        
        if (chip_id == TGUI9660) {
@@ -1120,7 +1130,8 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        
        if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) {
                debug("request_mem_region failed!\n");
-               return -1;
+               err = -1;
+               goto out_unmap;
        }
 
        fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,
@@ -1129,7 +1140,8 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        if (!fb_info.screen_base) {
                release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
                debug("ioremap failed\n");
-               return -1;
+               err = -1;
+               goto out_unmap;
        }
 
        output("%s board found\n", pci_name(dev));
@@ -1152,8 +1164,10 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
 #endif
        fb_info.pseudo_palette = pseudo_pal;
 
-       if (!fb_find_mode(&default_var,&fb_info,mode,NULL,0,NULL,bpp))
-               return -EINVAL;
+       if (!fb_find_mode(&default_var,&fb_info,mode,NULL,0,NULL,bpp)) {
+               err = -EINVAL;
+               goto out_unmap;
+       }
        fb_alloc_cmap(&fb_info.cmap,256,0);
        if (defaultaccel && acc)
                default_var.accel_flags |= FB_ACCELF_TEXT;
@@ -1163,13 +1177,21 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
        fb_info.var = default_var;
        fb_info.device = &dev->dev;
        if (register_framebuffer(&fb_info) < 0) {
-               output("Could not register Trident framebuffer\n");
-               return -EINVAL;
+               printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n");
+               err = -EINVAL;
+               goto out_unmap;
        }
        output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
           fb_info.node, fb_info.fix.id,default_var.xres,
           default_var.yres,default_var.bits_per_pixel);
        return 0;
+
+out_unmap:
+       if (default_par.io_virt)
+               iounmap(default_par.io_virt);
+       if (fb_info.screen_base)
+               iounmap(fb_info.screen_base);
+       return err;
 }
 
 static void __devexit trident_pci_remove(struct pci_dev * dev)
@@ -1216,33 +1238,13 @@ static struct pci_driver tridentfb_pci_driver = {
        .remove         = __devexit_p(trident_pci_remove)
 };
 
-int tridentfb_setup(char *options);
-
-int __init tridentfb_init(void)
-{
-#ifndef MODULE
-       char *option = NULL;
-
-       if (fb_get_options("tridentfb", &option))
-               return -ENODEV;
-       tridentfb_setup(option);
-#endif
-       output("Trident framebuffer %s initializing\n", VERSION);
-       return pci_module_init(&tridentfb_pci_driver);
-}
-
-void __exit tridentfb_exit(void)
-{
-       pci_unregister_driver(&tridentfb_pci_driver);
-}
-
-
 /*
  * Parse user specified options (`video=trident:')
  * example:
  *     video=trident:800x600,bpp=16,noaccel
  */
-int tridentfb_setup(char *options)
+#ifndef MODULE
+static int tridentfb_setup(char *options)
 {
        char * opt;
        if (!options || !*options)
@@ -1272,6 +1274,25 @@ int tridentfb_setup(char *options)
        }
        return 0;
 }
+#endif
+
+static int __init tridentfb_init(void)
+{
+#ifndef MODULE
+       char *option = NULL;
+
+       if (fb_get_options("tridentfb", &option))
+               return -ENODEV;
+       tridentfb_setup(option);
+#endif
+       output("Trident framebuffer %s initializing\n", VERSION);
+       return pci_register_driver(&tridentfb_pci_driver);
+}
+
+static void __exit tridentfb_exit(void)
+{
+       pci_unregister_driver(&tridentfb_pci_driver);
+}
 
 static struct fb_ops tridentfb_ops = {
        .owner  = THIS_MODULE,
@@ -1283,7 +1304,6 @@ static struct fb_ops tridentfb_ops = {
        .fb_fillrect = tridentfb_fillrect,
        .fb_copyarea= tridentfb_copyarea,
        .fb_imageblit = cfb_imageblit,
-       .fb_cursor = soft_cursor,
 };
 
 module_init(tridentfb_init);