Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / video / cg6.c
index be87a66..7aab91e 100644 (file)
@@ -36,9 +36,8 @@ static int cg6_blank(int, struct fb_info *);
 static void cg6_imageblit(struct fb_info *, const struct fb_image *);
 static void cg6_fillrect(struct fb_info *, const struct fb_fillrect *);
 static int cg6_sync(struct fb_info *);
-static int cg6_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
-static int cg6_ioctl(struct inode *, struct file *, unsigned int,
-                    unsigned long, struct fb_info *);
+static int cg6_mmap(struct fb_info *, struct vm_area_struct *);
+static int cg6_ioctl(struct fb_info *, unsigned int, unsigned long);
 
 /*
  *  Frame buffer operations
@@ -54,7 +53,9 @@ static struct fb_ops cg6_ops = {
        .fb_sync                = cg6_sync,
        .fb_mmap                = cg6_mmap,
        .fb_ioctl               = cg6_ioctl,
-       .fb_cursor              = soft_cursor,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* Offset of interesting structures in the OBIO space */
@@ -250,11 +251,11 @@ struct bt_regs {
 
 struct cg6_par {
        spinlock_t              lock;
-       struct bt_regs          *bt;
-       struct cg6_fbc          *fbc;
-       struct cg6_thc          *thc;
-       struct cg6_tec          *tec;
-       volatile u32            *fhc;
+       struct bt_regs          __iomem *bt;
+       struct cg6_fbc          __iomem *fbc;
+       struct cg6_thc          __iomem *thc;
+       struct cg6_tec          __iomem *tec;
+       volatile u32            __iomem *fhc;
 
        u32                     flags;
 #define CG6_FLAG_BLANKED       0x00000001
@@ -263,13 +264,12 @@ struct cg6_par {
        unsigned long           fbsize;
 
        struct sbus_dev         *sdev;
-       struct list_head        list;
 };
 
 static int cg6_sync(struct fb_info *info)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct cg6_fbc *fbc = par->fbc;
+       struct cg6_fbc __iomem *fbc = par->fbc;
        int limit = 10000;
 
        do {
@@ -292,7 +292,7 @@ static int cg6_sync(struct fb_info *info)
 static void cg6_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct cg6_fbc *fbc = par->fbc;
+       struct cg6_fbc __iomem *fbc = par->fbc;
        unsigned long flags;
        s32 val;
 
@@ -327,7 +327,7 @@ static void cg6_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 static void cg6_imageblit(struct fb_info *info, const struct fb_image *image)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct cg6_fbc *fbc = par->fbc;
+       struct cg6_fbc __iomem *fbc = par->fbc;
        const u8 *data = image->data;
        unsigned long flags;
        u32 x, y;
@@ -418,7 +418,7 @@ static int cg6_setcolreg(unsigned regno,
                         unsigned transp, struct fb_info *info)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct bt_regs *bt = par->bt;
+       struct bt_regs __iomem *bt = par->bt;
        unsigned long flags;
 
        if (regno >= 256)
@@ -449,24 +449,24 @@ static int
 cg6_blank(int blank, struct fb_info *info)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct cg6_thc *thc = par->thc;
+       struct cg6_thc __iomem *thc = par->thc;
        unsigned long flags;
        u32 val;
 
        spin_lock_irqsave(&par->lock, flags);
 
        switch (blank) {
-       case 0: /* Unblanking */
+       case FB_BLANK_UNBLANK: /* Unblanking */
                val = sbus_readl(&thc->thc_misc);
                val |= CG6_THC_MISC_VIDEO;
                sbus_writel(val, &thc->thc_misc);
                par->flags &= ~CG6_FLAG_BLANKED;
                break;
 
-       case 1: /* Normal blanking */
-       case 2: /* VESA blank (vsync off) */
-       case 3: /* VESA blank (hsync off) */
-       case 4: /* Poweroff */
+       case FB_BLANK_NORMAL: /* Normal blanking */
+       case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
+       case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
+       case FB_BLANK_POWERDOWN: /* Poweroff */
                val = sbus_readl(&thc->thc_misc);
                val &= ~CG6_THC_MISC_VIDEO;
                sbus_writel(val, &thc->thc_misc);
@@ -523,7 +523,7 @@ static struct sbus_mmap_map cg6_mmap_map[] = {
        { .size = 0 }
 };
 
-static int cg6_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma)
+static int cg6_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
        struct cg6_par *par = (struct cg6_par *)info->par;
 
@@ -533,8 +533,7 @@ static int cg6_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
                                  vma);
 }
 
-static int cg6_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                    unsigned long arg, struct fb_info *info)
+static int cg6_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
 
@@ -593,7 +592,7 @@ cg6_init_fix(struct fb_info *info, int linebytes)
 /* Initialize Brooktree DAC */
 static void cg6_bt_init(struct cg6_par *par)
 {
-       struct bt_regs *bt = par->bt;
+       struct bt_regs __iomem *bt = par->bt;
 
        sbus_writel(0x04 << 24, &bt->addr);         /* color planes */
        sbus_writel(0xff << 24, &bt->control);
@@ -608,9 +607,9 @@ static void cg6_bt_init(struct cg6_par *par)
 static void cg6_chip_init(struct fb_info *info)
 {
        struct cg6_par *par = (struct cg6_par *) info->par;
-       struct cg6_tec *tec = par->tec;
-       struct cg6_fbc *fbc = par->fbc;
-       u32 rev, conf, mode, tmp;
+       struct cg6_tec __iomem *tec = par->tec;
+       struct cg6_fbc __iomem *fbc = par->fbc;
+       u32 rev, conf, mode;
        int i;
        
        /* Turn off stuff in the Transform Engine. */
@@ -654,12 +653,6 @@ static void cg6_chip_init(struct fb_info *info)
        sbus_writel(0, &fbc->clipminy);
        sbus_writel(info->var.xres - 1, &fbc->clipmaxx);
        sbus_writel(info->var.yres - 1, &fbc->clipmaxy);
-
-       /* Disable cursor in Brooktree DAC. */
-       sbus_writel(0x06 << 24, &par->bt->addr);
-       tmp = sbus_readl(&par->bt->control);
-       tmp &= ~(0x03 << 24);
-       sbus_writel(tmp, &par->bt->control);
 }
 
 struct all_info {
@@ -689,6 +682,9 @@ static void cg6_init_one(struct sbus_dev *sdev)
        all->par.physbase = sdev->reg_addrs[0].phys_addr;
 
        sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
+       all->info.var.red.length = 8;
+       all->info.var.green.length = 8;
+       all->info.var.blue.length = 8;
 
        linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
                                       all->info.var.xres);
@@ -696,34 +692,28 @@ static void cg6_init_one(struct sbus_dev *sdev)
        if (prom_getbool(sdev->prom_node, "dblbuf"))
                all->par.fbsize *= 4;
 
-       all->par.fbc = (struct cg6_fbc *)
-               sbus_ioremap(&sdev->resource[0], CG6_FBC_OFFSET,
+       all->par.fbc = sbus_ioremap(&sdev->resource[0], CG6_FBC_OFFSET,
                             4096, "cgsix fbc");
-       all->par.tec = (struct cg6_tec *)
-               sbus_ioremap(&sdev->resource[0], CG6_TEC_OFFSET,
+       all->par.tec = sbus_ioremap(&sdev->resource[0], CG6_TEC_OFFSET,
                             sizeof(struct cg6_tec), "cgsix tec");
-       all->par.thc = (struct cg6_thc *)
-               sbus_ioremap(&sdev->resource[0], CG6_THC_OFFSET,
+       all->par.thc = sbus_ioremap(&sdev->resource[0], CG6_THC_OFFSET,
                             sizeof(struct cg6_thc), "cgsix thc");
-       all->par.bt = (struct bt_regs *)
-               sbus_ioremap(&sdev->resource[0], CG6_BROOKTREE_OFFSET,
+       all->par.bt = sbus_ioremap(&sdev->resource[0], CG6_BROOKTREE_OFFSET,
                             sizeof(struct bt_regs), "cgsix dac");
-       all->par.fhc = (u32 *)
-               sbus_ioremap(&sdev->resource[0], CG6_FHC_OFFSET,
+       all->par.fhc = sbus_ioremap(&sdev->resource[0], CG6_FHC_OFFSET,
                             sizeof(u32), "cgsix fhc");
 
        all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_IMAGEBLIT |
                           FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
        all->info.fbops = &cg6_ops;
 #ifdef CONFIG_SPARC32
-       all->info.screen_base = (char *)
+       all->info.screen_base = (char __iomem *)
                prom_getintdefault(sdev->prom_node, "address", 0);
 #endif
        if (!all->info.screen_base)
-               all->info.screen_base = (char *)
+               all->info.screen_base = 
                        sbus_ioremap(&sdev->resource[0], CG6_RAM_OFFSET,
                                     all->par.fbsize, "cgsix ram");
-       all->info.currcon = -1;
        all->info.par = &all->par;
 
        all->info.var.accel_flags = FB_ACCELF_TEXT;
@@ -738,6 +728,7 @@ static void cg6_init_one(struct sbus_dev *sdev)
                return;
        }
 
+       fb_set_cmap(&all->info.cmap, &all->info);
        cg6_init_fix(&all->info, linebytes);
 
        if (register_framebuffer(&all->info) < 0) {