fbdev: move FBIO_WAITFORVSYNC to linux/fb.h
[safe/jmp/linux-2.6] / drivers / video / leo.c
index 465459e..3d78953 100644 (file)
@@ -11,7 +11,6 @@
 #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>
@@ -33,6 +32,7 @@ static int leo_blank(int, struct fb_info *);
 
 static int leo_mmap(struct fb_info *, struct vm_area_struct *);
 static int leo_ioctl(struct fb_info *, unsigned int, unsigned long);
+static int leo_pan_display(struct fb_var_screeninfo *, struct fb_info *);
 
 /*
  *  Frame buffer operations
@@ -42,6 +42,7 @@ static struct fb_ops leo_ops = {
        .owner                  = THIS_MODULE,
        .fb_setcolreg           = leo_setcolreg,
        .fb_blank               = leo_blank,
+       .fb_pan_display         = leo_pan_display,
        .fb_fillrect            = cfb_fillrect,
        .fb_copyarea            = cfb_copyarea,
        .fb_imageblit           = cfb_imageblit,
@@ -189,9 +190,7 @@ struct leo_par {
        u32                     flags;
 #define LEO_FLAG_BLANKED       0x00000001
 
-       unsigned long           physbase;
        unsigned long           which_io;
-       unsigned long           fbsize;
 };
 
 static void leo_wait(struct leo_lx_krn __iomem *lx_krn)
@@ -206,6 +205,60 @@ static void leo_wait(struct leo_lx_krn __iomem *lx_krn)
        return;
 }
 
+static void leo_switch_from_graph(struct fb_info *info)
+{
+       struct leo_par *par = (struct leo_par *) info->par;
+       struct leo_ld_ss0 __iomem *ss = par->ld_ss0;
+       struct leo_cursor __iomem *cursor = par->cursor;
+       unsigned long flags;
+       u32 val;
+
+       spin_lock_irqsave(&par->lock, flags);
+
+       par->extent = ((info->var.xres - 1) |
+                      ((info->var.yres - 1) << 16));
+
+       sbus_writel(0xffffffff, &ss->wid);
+       sbus_writel(0xffff, &ss->wmask);
+       sbus_writel(0, &ss->vclipmin);
+       sbus_writel(par->extent, &ss->vclipmax);
+       sbus_writel(0, &ss->fg);
+       sbus_writel(0xff000000, &ss->planemask);
+       sbus_writel(0x310850, &ss->rop);
+       sbus_writel(0, &ss->widclip);
+       sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11),
+                   &par->lc_ss0_usr->extent);
+       sbus_writel(4, &par->lc_ss0_usr->addrspace);
+       sbus_writel(0x80000000, &par->lc_ss0_usr->fill);
+       sbus_writel(0, &par->lc_ss0_usr->fontt);
+       do {
+               val = sbus_readl(&par->lc_ss0_usr->csr);
+       } while (val & 0x20000000);
+
+       /* setup screen buffer for cfb_* functions */
+       sbus_writel(1, &ss->wid);
+       sbus_writel(0x00ffffff, &ss->planemask);
+       sbus_writel(0x310b90, &ss->rop);
+       sbus_writel(0, &par->lc_ss0_usr->addrspace);
+
+       /* hide cursor */
+       sbus_writel(sbus_readl(&cursor->cur_misc) & ~LEO_CUR_ENABLE, &cursor->cur_misc);
+
+       spin_unlock_irqrestore(&par->lock, flags);
+}
+
+static int leo_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+       /* We just use this to catch switches out of
+        * graphics mode.
+        */
+       leo_switch_from_graph(info);
+
+       if (var->xoffset || var->yoffset || var->vmode)
+               return -EINVAL;
+       return 0;
+}
+
 /**
  *      leo_setcolreg - Optional function. Sets a color register.
  *      @regno: boolean, 0 copy local, 1 get_user() function
@@ -364,16 +417,14 @@ static int leo_mmap(struct fb_info *info, struct vm_area_struct *vma)
        struct leo_par *par = (struct leo_par *)info->par;
 
        return sbusfb_mmap_helper(leo_mmap_map,
-                                 par->physbase, par->fbsize,
+                                 info->fix.smem_start, info->fix.smem_len,
                                  par->which_io, vma);
 }
 
 static int leo_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 {
-       struct leo_par *par = (struct leo_par *) info->par;
-
        return sbusfb_ioctl_helper(cmd, arg, info,
-                                  FBTYPE_SUNLEO, 32, par->fbsize);
+                                  FBTYPE_SUNLEO, 32, info->fix.smem_len);
 }
 
 /*
@@ -454,44 +505,6 @@ static void leo_init_wids(struct fb_info *info)
        leo_wid_put(info, &wl);
 }
 
-static void leo_switch_from_graph(struct fb_info *info)
-{
-       struct leo_par *par = (struct leo_par *) info->par;
-       struct leo_ld_ss0 __iomem *ss = par->ld_ss0;
-       unsigned long flags;
-       u32 val;
-
-       spin_lock_irqsave(&par->lock, flags);
-
-       par->extent = ((info->var.xres - 1) |
-                      ((info->var.yres - 1) << 16));
-
-       sbus_writel(0xffffffff, &ss->wid);
-       sbus_writel(0xffff, &ss->wmask);
-       sbus_writel(0, &ss->vclipmin);
-       sbus_writel(par->extent, &ss->vclipmax);
-       sbus_writel(0, &ss->fg);
-       sbus_writel(0xff000000, &ss->planemask);
-       sbus_writel(0x310850, &ss->rop);
-       sbus_writel(0, &ss->widclip);
-       sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11),
-                   &par->lc_ss0_usr->extent);
-       sbus_writel(4, &par->lc_ss0_usr->addrspace);
-       sbus_writel(0x80000000, &par->lc_ss0_usr->fill);
-       sbus_writel(0, &par->lc_ss0_usr->fontt);
-       do {
-               val = sbus_readl(&par->lc_ss0_usr->csr);
-       } while (val & 0x20000000);
-
-       /* setup screen buffer for cfb_* functions */
-       sbus_writel(1, &ss->wid);
-       sbus_writel(0x00ffffff, &ss->planemask);
-       sbus_writel(0x310b90, &ss->rop);
-       sbus_writel(0, &par->lc_ss0_usr->addrspace);
-
-       spin_unlock_irqrestore(&par->lock, flags);
-}
-
 static void leo_init_hw(struct fb_info *info)
 {
        struct leo_par *par = (struct leo_par *) info->par;
@@ -551,7 +564,7 @@ static int __devinit leo_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, 32);
@@ -559,7 +572,7 @@ static int __devinit leo_probe(struct of_device *op,
 
        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);
 
        par->lc_ss0_usr =
                of_ioremap(&op->resource[0], LEO_OFF_LC_SS0_USR,
@@ -609,7 +622,7 @@ static int __devinit leo_probe(struct of_device *op,
 
        printk(KERN_INFO "%s: leo at %lx:%lx\n",
               dp->full_name,
-              par->which_io, par->physbase);
+              par->which_io, info->fix.smem_start);
 
        return 0;
 
@@ -650,8 +663,11 @@ static const struct of_device_id leo_match[] = {
 MODULE_DEVICE_TABLE(of, leo_match);
 
 static struct of_platform_driver leo_driver = {
-       .name           = "leo",
-       .match_table    = leo_match,
+       .driver = {
+               .name = "leo",
+               .owner = THIS_MODULE,
+               .of_match_table = leo_match,
+       },
        .probe          = leo_probe,
        .remove         = __devexit_p(leo_remove),
 };