X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fplanb.c;h=86d2884e16c688a5af9c43717f6f7b0a4f379b9b;hb=refs%2Fheads%2Fvserver;hp=f3fc361bec97b405e1f147b46ac46a56bb149728;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c index f3fc361be..86d2884e1 100644 --- a/drivers/media/video/planb.c +++ b/drivers/media/video/planb.c @@ -1,4 +1,4 @@ -/* +/* planb - PlanB frame grabber driver PlanB is used in the 7x00/8x00 series of PowerMacintosh @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ #include #include #include -#include +#include #include "planb.h" #include "saa7196.h" @@ -90,7 +91,7 @@ static void planb_close(struct video_device *); static int planb_ioctl(struct video_device *, unsigned int, void *); static int planb_init_done(struct video_device *); static int planb_mmap(struct video_device *, const char *, unsigned long); -static void planb_irq(int, void *, struct pt_regs *); +static void planb_irq(int, void *); static void release_planb(void); int init_planbs(struct video_init *); @@ -137,7 +138,7 @@ static int grabbuf_alloc(struct planb *pb) + MAX_LNUM #endif /* PLANB_GSCANLINE */ ); - if ((pb->rawbuf = (unsigned char**) kmalloc (npage + if ((pb->rawbuf = kmalloc(npage * sizeof(unsigned long), GFP_KERNEL)) == 0) return -ENOMEM; for (i = 0; i < npage; i++) { @@ -329,12 +330,12 @@ static volatile struct dbdma_cmd *cmd_geo_setup( static inline void planb_lock(struct planb *pb) { - down(&pb->lock); + mutex_lock(&pb->lock); } static inline void planb_unlock(struct planb *pb) { - up(&pb->lock); + mutex_unlock(&pb->lock); } /***************/ @@ -584,7 +585,7 @@ finish: wake_up_interruptible(&pb->suspendq); } -static void add_clip(struct planb *pb, struct video_clip *clip) +static void add_clip(struct planb *pb, struct video_clip *clip) { volatile unsigned char *base; int xc = clip->x, yc = clip->y; @@ -758,7 +759,7 @@ static void cmd_buff(struct planb *pb) PLANB_SET(CH_SYNC)); tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), PLANB_SET(DMA_ABORT)); - + /* odd field data: */ jump = virt_to_bus(c1 + nlines / 2); for (i=1; i < nlines; i += stepsize, c1++) @@ -1247,7 +1248,7 @@ static volatile struct dbdma_cmd *setup_grab_cmd(int fr, struct planb *pb) tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), PLANB_SET(DMA_ABORT)); - + /* odd field data: */ jump_addr = c1 + TAB_FACTOR * nlines / 2; jump = virt_to_bus(jump_addr); @@ -1315,7 +1316,7 @@ cmd_tab_data_end: return c1; } -static void planb_irq(int irq, void *dev_id, struct pt_regs * regs) +static void planb_irq(int irq, void *dev_id) { unsigned int stat, astat; struct planb *pb = (struct planb *)dev_id; @@ -1383,7 +1384,7 @@ static int planb_open(struct video_device *dev, int mode) pb->user++; DEBUG("PlanB: device opened\n"); - return 0; + return 0; } static void planb_close(struct video_device *dev) @@ -1424,9 +1425,9 @@ static long planb_write(struct video_device *v, const char *buf, static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) { struct planb *pb=(struct planb *)dev; - + switch (cmd) - { + { case VIDIOCGCAP: { struct video_capability b; @@ -1440,26 +1441,26 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) b.channels = 2; /* composite & svhs */ b.audios = 0; b.maxwidth = PLANB_MAXPIXELS; - b.maxheight = PLANB_MAXLINES; - b.minwidth = 32; /* wild guess */ - b.minheight = 32; - if (copy_to_user(arg,&b,sizeof(b))) - return -EFAULT; + b.maxheight = PLANB_MAXLINES; + b.minwidth = 32; /* wild guess */ + b.minheight = 32; + if (copy_to_user(arg,&b,sizeof(b))) + return -EFAULT; return 0; } case VIDIOCSFBUF: { - struct video_buffer v; + struct video_buffer v; unsigned short bpp; unsigned int fmt; DEBUG("PlanB: IOCTL VIDIOCSFBUF\n"); - if (!capable(CAP_SYS_ADMIN) + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EPERM; - if (copy_from_user(&v, arg,sizeof(v))) - return -EFAULT; + return -EPERM; + if (copy_from_user(&v, arg,sizeof(v))) + return -EFAULT; planb_lock(pb); switch(v.depth) { case 8: @@ -1478,7 +1479,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) break; default: planb_unlock(pb); - return -EINVAL; + return -EINVAL; } if (bpp * v.width > v.bytesperline) { planb_unlock(pb); @@ -1493,7 +1494,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) pb->win.bpl = pb->win.bpp * pb->win.swidth; pb->win.pad = v.bytesperline - pb->win.bpl; - DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d," + DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d," " bpl %d (+ %d)\n", v.base, v.width,v.height, pb->win.bpp, pb->win.bpl, pb->win.pad); @@ -1504,11 +1505,11 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) resume_overlay(pb); } planb_unlock(pb); - return 0; + return 0; } case VIDIOCGFBUF: { - struct video_buffer v; + struct video_buffer v; DEBUG("PlanB: IOCTL VIDIOCGFBUF\n"); @@ -1518,15 +1519,15 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) v.depth = pb->win.depth; v.bytesperline = pb->win.bpl + pb->win.pad; if (copy_to_user(arg, &v, sizeof(v))) - return -EFAULT; + return -EFAULT; return 0; } case VIDIOCCAPTURE: { int i; - if(copy_from_user(&i, arg, sizeof(i))) - return -EFAULT; + if(copy_from_user(&i, arg, sizeof(i))) + return -EFAULT; if(i==0) { DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n"); @@ -1695,7 +1696,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) struct video_window vw; struct video_clip clip; int i; - + DEBUG("PlanB: IOCTL VIDIOCSWIN\n"); if(copy_from_user(&vw,arg,sizeof(vw))) @@ -1749,7 +1750,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) return -EFAULT; return 0; } - case VIDIOCSYNC: { + case VIDIOCSYNC: { int i; IDEBUG("PlanB: IOCTL VIDIOCSYNC\n"); @@ -1759,42 +1760,42 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) IDEBUG("PlanB: sync to frame %d\n", i); - if(i > (MAX_GBUFFERS - 1) || i < 0) - return -EINVAL; + if(i > (MAX_GBUFFERS - 1) || i < 0) + return -EINVAL; chk_grab: - switch (pb->frame_stat[i]) { - case GBUFFER_UNUSED: - return -EINVAL; + switch (pb->frame_stat[i]) { + case GBUFFER_UNUSED: + return -EINVAL; case GBUFFER_GRABBING: IDEBUG("PlanB: waiting for grab" " done (%d)\n", i); - interruptible_sleep_on(&pb->capq); + interruptible_sleep_on(&pb->capq); if(signal_pending(current)) return -EINTR; goto chk_grab; - case GBUFFER_DONE: - pb->frame_stat[i] = GBUFFER_UNUSED; - break; - } - return 0; + case GBUFFER_DONE: + pb->frame_stat[i] = GBUFFER_UNUSED; + break; + } + return 0; } - case VIDIOCMCAPTURE: + case VIDIOCMCAPTURE: { - struct video_mmap vm; + struct video_mmap vm; volatile unsigned int status; IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n"); if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm))) return -EFAULT; - status = pb->frame_stat[vm.frame]; - if (status != GBUFFER_UNUSED) - return -EBUSY; + status = pb->frame_stat[vm.frame]; + if (status != GBUFFER_UNUSED) + return -EBUSY; - return vgrab(pb, &vm); + return vgrab(pb, &vm); } - + case VIDIOCGMBUF: { int i; @@ -1811,7 +1812,7 @@ chk_grab: return -EFAULT; return 0; } - + case PLANBIOCGSAAREGS: { struct planb_saa_regs preg; @@ -1828,7 +1829,7 @@ chk_grab: return -EFAULT; return 0; } - + case PLANBIOCSSAAREGS: { struct planb_saa_regs preg; @@ -1842,7 +1843,7 @@ chk_grab: saa_set (preg.addr, preg.val, pb); return 0; } - + case PLANBIOCGSTAT: { struct planb_stat_regs pstat; @@ -1859,7 +1860,7 @@ chk_grab: return -EFAULT; return 0; } - + case PLANBIOCSMODE: { int v; @@ -1985,10 +1986,10 @@ static int planb_mmap(struct vm_area_struct *vma, struct video_device *dev, cons { int i; struct planb *pb = (struct planb *)dev; - unsigned long start = (unsigned long)adr; + unsigned long start = (unsigned long)adr; if (size > MAX_GBUFFERS * PLANB_MAX_FBUF) - return -EINVAL; + return -EINVAL; if (!pb->rawbuf) { int err; if((err=grabbuf_alloc(pb))) @@ -2067,7 +2068,7 @@ static int init_planb(struct planb *pb) #endif pb->tab_size = PLANB_MAXLINES + 40; pb->suspend = 0; - init_MUTEX(&pb->lock); + mutex_init(&pb->lock); pb->ch1_cmd = 0; pb->ch2_cmd = 0; pb->mask = 0; @@ -2091,10 +2092,10 @@ static int init_planb(struct planb *pb) /* clear interrupt mask */ pb->intr_mask = PLANB_CLR_IRQ; - result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb); - if (result < 0) { - if (result==-EINVAL) - printk(KERN_ERR "PlanB: Bad irq number (%d) " + result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb); + if (result < 0) { + if (result==-EINVAL) + printk(KERN_ERR "PlanB: Bad irq number (%d) " "or handler\n", (int)pb->irq); else if (result==-EBUSY) printk(KERN_ERR "PlanB: I don't know why, " @@ -2102,7 +2103,7 @@ static int init_planb(struct planb *pb) return result; } disable_irq(pb->irq); - + /* Now add the template and register the device unit. */ memcpy(&pb->video_dev,&planb_template,sizeof(planb_template)); @@ -2143,7 +2144,7 @@ static int init_planb(struct planb *pb) } /* - * Scan for a PlanB controller, request the irq and map the io memory + * Scan for a PlanB controller, request the irq and map the io memory */ static int find_planb(void) @@ -2156,7 +2157,7 @@ static int find_planb(void) struct pci_dev *pdev; int rc; - if (_machine != _MACH_Pmac) + if (!machine_is(powermac)) return 0; planb_devices = find_devices("planb"); @@ -2171,9 +2172,9 @@ static int find_planb(void) pb = &planbs[0]; planb_num = 1; - if (planb_devices->n_addrs != 1) { - printk (KERN_WARNING "PlanB: expecting 1 address for planb " - "(got %d)", planb_devices->n_addrs); + if (planb_devices->n_addrs != 1) { + printk (KERN_WARNING "PlanB: expecting 1 address for planb " + "(got %d)", planb_devices->n_addrs); return 0; } @@ -2236,7 +2237,7 @@ static int find_planb(void) pb->planb_base = planb_regs; pb->planb_base_phys = (struct planb_registers *)new_base; pb->irq = irq; - + return planb_num; err_out_disable: @@ -2251,7 +2252,7 @@ static void release_planb(void) int i; struct planb *pb; - for (i=0;i