include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / video / cg6.c
index 8000bcc..6d0fcb4 100644 (file)
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/mm.h>
+#include <linux/of_device.h>
 
 #include <asm/io.h>
-#include <asm/of_device.h>
 #include <asm/fbio.h>
 
 #include "sbuslib.h"
@@ -34,10 +33,11 @@ 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 void cg6_copyarea(struct fb_info *info, const struct fb_copyarea *area);
 static int cg6_sync(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);
-static void cg6_copyarea(struct fb_info *info, const struct fb_copyarea *area);
+static int cg6_pan_display(struct fb_var_screeninfo *, struct fb_info *);
 
 /*
  *  Frame buffer operations
@@ -47,6 +47,7 @@ static struct fb_ops cg6_ops = {
        .owner                  = THIS_MODULE,
        .fb_setcolreg           = cg6_setcolreg,
        .fb_blank               = cg6_blank,
+       .fb_pan_display         = cg6_pan_display,
        .fb_fillrect            = cg6_fillrect,
        .fb_copyarea            = cg6_copyarea,
        .fb_imageblit           = cg6_imageblit,
@@ -161,6 +162,7 @@ static struct fb_ops cg6_ops = {
 #define CG6_THC_MISC_INT_ENAB          (1 << 5)
 #define CG6_THC_MISC_INT               (1 << 4)
 #define CG6_THC_MISC_INIT              0x9f
+#define CG6_THC_CURSOFF                        ((65536-32) | ((65536-32) << 16))
 
 /* The contents are unknown */
 struct cg6_tec {
@@ -260,9 +262,7 @@ struct cg6_par {
        u32                     flags;
 #define CG6_FLAG_BLANKED       0x00000001
 
-       unsigned long           physbase;
        unsigned long           which_io;
-       unsigned long           fbsize;
 };
 
 static int cg6_sync(struct fb_info *info)
@@ -280,6 +280,33 @@ static int cg6_sync(struct fb_info *info)
        return 0;
 }
 
+static void cg6_switch_from_graph(struct cg6_par *par)
+{
+       struct cg6_thc __iomem *thc = par->thc;
+       unsigned long flags;
+
+       spin_lock_irqsave(&par->lock, flags);
+
+       /* Hide the cursor. */
+       sbus_writel(CG6_THC_CURSOFF, &thc->thc_cursxy);
+
+       spin_unlock_irqrestore(&par->lock, flags);
+}
+
+static int cg6_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+       struct cg6_par *par = (struct cg6_par *)info->par;
+
+       /* We just use this to catch switches out of
+        * graphics mode.
+        */
+       cg6_switch_from_graph(par);
+
+       if (var->xoffset || var->yoffset || var->vmode)
+               return -EINVAL;
+       return 0;
+}
+
 /**
  *     cg6_fillrect -  Draws a rectangle on the screen.
  *
@@ -566,16 +593,14 @@ static int cg6_mmap(struct fb_info *info, struct vm_area_struct *vma)
        struct cg6_par *par = (struct cg6_par *)info->par;
 
        return sbusfb_mmap_helper(cg6_mmap_map,
-                                 par->physbase, par->fbsize,
+                                 info->fix.smem_start, info->fix.smem_len,
                                  par->which_io, vma);
 }
 
 static int cg6_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 {
-       struct cg6_par *par = (struct cg6_par *)info->par;
-
        return sbusfb_ioctl_helper(cmd, arg, info,
-                                  FBTYPE_SUNFAST_COLOR, 8, par->fbsize);
+                                  FBTYPE_SUNFAST_COLOR, 8, info->fix.smem_len);
 }
 
 /*
@@ -601,12 +626,12 @@ static void __devinit cg6_init_fix(struct fb_info *info, int linebytes)
                break;
        };
        if (((conf >> CG6_FHC_REV_SHIFT) & CG6_FHC_REV_MASK) >= 11) {
-               if (par->fbsize <= 0x100000)
+               if (info->fix.smem_len <= 0x100000)
                        cg6_card_name = "TGX";
                else
                        cg6_card_name = "TGX+";
        } else {
-               if (par->fbsize <= 0x100000)
+               if (info->fix.smem_len <= 0x100000)
                        cg6_card_name = "GX";
                else
                        cg6_card_name = "GX+";
@@ -643,9 +668,13 @@ static void __devinit cg6_chip_init(struct fb_info *info)
        struct cg6_par *par = (struct cg6_par *)info->par;
        struct cg6_tec __iomem *tec = par->tec;
        struct cg6_fbc __iomem *fbc = par->fbc;
+       struct cg6_thc __iomem *thc = par->thc;
        u32 rev, conf, mode;
        int i;
 
+       /* Hide the cursor. */
+       sbus_writel(CG6_THC_CURSOFF, &thc->thc_cursxy);
+
        /* Turn off stuff in the Transform Engine. */
        sbus_writel(0, &tec->tec_matrix);
        sbus_writel(0, &tec->tec_clip);
@@ -704,7 +733,8 @@ static void cg6_unmap_regs(struct of_device *op, struct fb_info *info,
                of_iounmap(&op->resource[0], par->fhc, sizeof(u32));
 
        if (info->screen_base)
-               of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
+               of_iounmap(&op->resource[0], info->screen_base,
+                          info->fix.smem_len);
 }
 
 static int __devinit cg6_probe(struct of_device *op,
@@ -725,21 +755,21 @@ static int __devinit cg6_probe(struct of_device *op,
 
        spin_lock_init(&par->lock);
 
-       par->physbase = op->resource[0].start;
+       info->fix.smem_start = op->resource[0].start;
        par->which_io = op->resource[0].flags & IORESOURCE_BITS;
 
-       sbusfb_fill_var(&info->var, dp->node, 8);
+       sbusfb_fill_var(&info->var, dp, 8);
        info->var.red.length = 8;
        info->var.green.length = 8;
        info->var.blue.length = 8;
 
        linebytes = of_getintprop_default(dp, "linebytes",
                                          info->var.xres);
-       par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
+       info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres);
 
        dblbuf = of_getintprop_default(dp, "dblbuf", 0);
        if (dblbuf)
-               par->fbsize *= 4;
+               info->fix.smem_len *= 4;
 
        par->fbc = of_ioremap(&op->resource[0], CG6_FBC_OFFSET,
                                4096, "cgsix fbc");
@@ -758,7 +788,7 @@ static int __devinit cg6_probe(struct of_device *op,
        info->fbops = &cg6_ops;
 
        info->screen_base = of_ioremap(&op->resource[0], CG6_RAM_OFFSET,
-                                       par->fbsize, "cgsix ram");
+                                       info->fix.smem_len, "cgsix ram");
        if (!par->fbc || !par->tec || !par->thc ||
            !par->bt || !par->fhc || !info->screen_base)
                goto out_unmap_regs;
@@ -783,7 +813,7 @@ static int __devinit cg6_probe(struct of_device *op,
 
        printk(KERN_INFO "%s: CGsix [%s] at %lx:%lx\n",
               dp->full_name, info->fix.id,
-              par->which_io, par->physbase);
+              par->which_io, info->fix.smem_start);
 
        return 0;
 
@@ -814,7 +844,7 @@ static int __devexit cg6_remove(struct of_device *op)
        return 0;
 }
 
-static struct of_device_id cg6_match[] = {
+static const struct of_device_id cg6_match[] = {
        {
                .name = "cgsix",
        },