X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fvideo%2Fcg14.c;h=63b6c79c8a0a98195c00a59cfed6387d57f61f15;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=40d28baf46c200ee018637f92fcdb26e565dd6c0;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c index 40d28baf4..63b6c79c8 100644 --- a/drivers/video/cg14.c +++ b/drivers/video/cg14.c @@ -31,9 +31,8 @@ static int cg14_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); -static int cg14_mmap(struct fb_info *, struct file *, struct vm_area_struct *); -static int cg14_ioctl(struct inode *, struct file *, unsigned int, - unsigned long, struct fb_info *); +static int cg14_mmap(struct fb_info *, struct vm_area_struct *); +static int cg14_ioctl(struct fb_info *, unsigned int, unsigned long); static int cg14_pan_display(struct fb_var_screeninfo *, struct fb_info *); /* @@ -49,7 +48,9 @@ static struct fb_ops cg14_ops = { .fb_imageblit = cfb_imageblit, .fb_mmap = cg14_mmap, .fb_ioctl = cg14_ioctl, - .fb_cursor = soft_cursor, +#ifdef CONFIG_COMPAT + .fb_compat_ioctl = sbusfb_compat_ioctl, +#endif }; #define CG14_MCR_INTENABLE_SHIFT 7 @@ -188,9 +189,9 @@ struct cg14_clut { struct cg14_par { spinlock_t lock; - struct cg14_regs *regs; - struct cg14_clut *clut; - struct cg14_cursor *cursor; + struct cg14_regs __iomem *regs; + struct cg14_clut __iomem *clut; + struct cg14_cursor __iomem *cursor; u32 flags; #define CG14_FLAG_BLANKED 0x00000001 @@ -204,12 +205,11 @@ struct cg14_par { int mode; int ramsize; struct sbus_dev *sdev; - struct list_head list; }; static void __cg14_reset(struct cg14_par *par) { - struct cg14_regs *regs = par->regs; + struct cg14_regs __iomem *regs = par->regs; u8 val; val = sbus_readb(®s->mcr); @@ -248,13 +248,16 @@ static int cg14_setcolreg(unsigned regno, unsigned transp, struct fb_info *info) { struct cg14_par *par = (struct cg14_par *) info->par; - struct cg14_clut *clut = par->clut; + struct cg14_clut __iomem *clut = par->clut; unsigned long flags; u32 val; if (regno >= 256) return 1; + red >>= 8; + green >>= 8; + blue >>= 8; val = (red | (green << 8) | (blue << 16)); spin_lock_irqsave(&par->lock, flags); @@ -264,7 +267,7 @@ static int cg14_setcolreg(unsigned regno, return 0; } -static int cg14_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma) +static int cg14_mmap(struct fb_info *info, struct vm_area_struct *vma) { struct cg14_par *par = (struct cg14_par *) info->par; @@ -273,12 +276,11 @@ static int cg14_mmap(struct fb_info *info, struct file *file, struct vm_area_str par->iospace, vma); } -static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, - unsigned long arg, struct fb_info *info) +static int cg14_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { struct cg14_par *par = (struct cg14_par *) info->par; - struct cg14_regs *regs = par->regs; - struct mdi_cfginfo kmdi, *mdii; + struct cg14_regs __iomem *regs = par->regs; + struct mdi_cfginfo kmdi, __user *mdii; unsigned long flags; int cur_mode, mode, ret = 0; @@ -301,13 +303,13 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, kmdi.mdi_size = par->ramsize; spin_unlock_irqrestore(&par->lock, flags); - mdii = (struct mdi_cfginfo *) arg; + mdii = (struct mdi_cfginfo __user *) arg; if (copy_to_user(mdii, &kmdi, sizeof(kmdi))) ret = -EFAULT; break; case MDI_SET_PIXELMODE: - if (get_user(mode, (int *) arg)) { + if (get_user(mode, (int __user *) arg)) { ret = -EFAULT; break; } @@ -322,7 +324,8 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, break; case MDI_16_PIX: - cur_mode |= 0x20; + cur_mode |= (CG14_MCR_PIXMODE_16 << + CG14_MCR_PIXMODE_SHIFT); break; case MDI_8_PIX: @@ -341,7 +344,7 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, default: ret = sbusfb_ioctl_helper(cmd, arg, info, - FBTYPE_MDICOLOR, 24, par->fbsize); + FBTYPE_MDICOLOR, 8, par->fbsize); break; }; @@ -355,11 +358,16 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static void cg14_init_fix(struct fb_info *info, int linebytes) { struct cg14_par *par = (struct cg14_par *)info->par; + const char *name; - strlcpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id)); + name = "cgfourteen"; + if (par->sdev) + name = par->sdev->prom_name; + + strlcpy(info->fix.id, name, sizeof(info->fix.id)); info->fix.type = FB_TYPE_PACKED_PIXELS; - info->fix.visual = FB_VISUAL_TRUECOLOR; + info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.line_length = linebytes; @@ -460,9 +468,9 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) int is_8mb, linebytes, i; if (!sdev) { - prom_getproperty(node, "address", - (char *) &bases[0], sizeof(bases)); - if (!bases[0]) { + if (prom_getproperty(node, "address", + (char *) &bases[0], sizeof(bases)) <= 0 + || !bases[0]) { printk(KERN_ERR "cg14: Device is not mapped.\n"); return; } @@ -484,8 +492,11 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) spin_lock_init(&all->par.lock); sbusfb_fill_var(&all->info.var, 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", + linebytes = prom_getintdefault(node, "linebytes", all->info.var.xres); all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); @@ -495,33 +506,29 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) all->par.physbase = phys = sdev->reg_addrs[1].phys_addr; all->par.iospace = sdev->reg_addrs[0].which_io; - all->par.regs = (struct cg14_regs *) - sbus_ioremap(&sdev->resource[0], 0, + all->par.regs = sbus_ioremap(&sdev->resource[0], 0, sizeof(struct cg14_regs), "cg14 regs"); - all->par.clut = (struct cg14_clut *) - sbus_ioremap(&sdev->resource[0], CG14_CLUT1, + all->par.clut = sbus_ioremap(&sdev->resource[0], CG14_CLUT1, sizeof(struct cg14_clut), "cg14 clut"); - all->par.cursor = (struct cg14_cursor *) - sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS, + all->par.cursor = sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS, sizeof(struct cg14_cursor), "cg14 cursor"); - all->info.screen_base = (char *) - sbus_ioremap(&sdev->resource[1], 0, + all->info.screen_base = sbus_ioremap(&sdev->resource[1], 0, all->par.fbsize, "cg14 ram"); } else { rphys = __get_phys(bases[0]); all->par.physbase = phys = __get_phys(bases[1]); all->par.iospace = __get_iospace(bases[0]); - all->par.regs = (struct cg14_regs *)(unsigned long)bases[0]; - all->par.clut = (struct cg14_clut *)((unsigned long)bases[0] + + all->par.regs = (struct cg14_regs __iomem *)(unsigned long)bases[0]; + all->par.clut = (struct cg14_clut __iomem *)((unsigned long)bases[0] + CG14_CLUT1); all->par.cursor = - (struct cg14_cursor *)((unsigned long)bases[0] + + (struct cg14_cursor __iomem *)((unsigned long)bases[0] + CG14_CURSORREGS); - all->info.screen_base = (char *)(unsigned long)bases[1]; + all->info.screen_base = (char __iomem *)(unsigned long)bases[1]; } prom_getproperty(node, "reg", (char *) &bases[0], sizeof(bases)); @@ -550,9 +557,8 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) all->par.mode = MDI_8_PIX; all->par.ramsize = (is_8mb ? 0x800000 : 0x400000); - all->info.flags = FBINFO_FLAG_DEFAULT; + all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; all->info.fbops = &cg14_ops; - all->info.currcon = -1; all->info.par = &all->par; __cg14_reset(&all->par); @@ -562,6 +568,7 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) kfree(all); return; } + fb_set_cmap(&all->info.cmap, &all->info); cg14_init_fix(&all->info, linebytes); @@ -574,8 +581,8 @@ static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node) list_add(&all->list, &cg14_list); - printk("cg14: cgfourteen at %lx:%lx\n", - all->par.physbase, all->par.iospace); + printk("cg14: cgfourteen at %lx:%lx, %dMB\n", + all->par.iospace, all->par.physbase, all->par.ramsize >> 20); } @@ -584,6 +591,9 @@ int __init cg14_init(void) struct sbus_bus *sbus; struct sbus_dev *sdev; + if (fb_get_options("cg14fb", NULL)) + return -ENODEV; + #ifdef CONFIG_SPARC32 { int root, node; @@ -626,8 +636,9 @@ cg14_setup(char *arg) return 0; } -#ifdef MODULE module_init(cg14_init); + +#ifdef MODULE module_exit(cg14_exit); #endif