X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fzr36120.c;h=6ac3b67400895c489ca2612d0debbc3813b4adf4;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=9b55341baf4099dfa522b9cf3ada64003f7026ce;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c index 9b55341ba..6ac3b6740 100644 --- a/drivers/media/video/zr36120.c +++ b/drivers/media/video/zr36120.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -69,10 +70,10 @@ MODULE_AUTHOR("Pauline Middelink "); MODULE_DESCRIPTION("Zoran ZR36120 based framegrabber"); MODULE_LICENSE("GPL"); -MODULE_PARM(triton1,"i"); -MODULE_PARM(cardtype,"1-" __MODULE_STRING(ZORAN_MAX) "i"); -MODULE_PARM(video_nr,"i"); -MODULE_PARM(vbi_nr,"i"); +module_param(triton1, uint, 0); +module_param_array(cardtype, uint, NULL, 0); +module_param(video_nr, int, 0); +module_param(vbi_nr, int, 0); static int zoran_cards; static struct zoran zorans[ZORAN_MAX]; @@ -145,14 +146,11 @@ static struct { const char name[8]; uint mode; uint bpp; } palette2fmt[] = { static void __init handle_chipset(void) { - struct pci_dev *dev = NULL; - /* Just in case some nut set this to something dangerous */ if (triton1) triton1 = ZORAN_VDC_TRICOM; - while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, dev))) - { + if (pci_pci_problems & PCIPCI_TRITON) { printk(KERN_INFO "zoran: Host bridge 82437FX Triton PIIX\n"); triton1 = ZORAN_VDC_TRICOM; } @@ -318,7 +316,7 @@ DEBUG(printk(CARD_DEBUG "%p added to queue\n",CARD,item)); item->status = FBUFFER_BUSY; if (!lastitem) ztv->workqueue = item; - else + else lastitem->next = item; lastitem = item; } @@ -341,7 +339,7 @@ void zoran_irq(int irq, void *dev_id, struct pt_regs * regs) { u32 stat,estat; int count = 0; - struct zoran *ztv = (struct zoran *)dev_id; + struct zoran *ztv = dev_id; UNUSED(irq); UNUSED(regs); for (;;) { @@ -518,7 +516,7 @@ DEBUG(printk(KERN_DEBUG " %d: clip(%d,%d,%d,%d)\n", i,vp->x,vp->y,vp->widt zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR); } -struct tvnorm +struct tvnorm { u16 Wt, Wa, Ht, Ha, HStart, VStart; }; @@ -662,7 +660,7 @@ DEBUG(printk(KERN_DEBUG " Y: scale=0, start=%d, end=%d\n", Hstart, Hend)); int HorDcm = 64-X; int hcrop1 = 2*(Wa-We)/4; /* - * BUGFIX: Juha Nurmela + * BUGFIX: Juha Nurmela * found the solution to the color phase shift. * See ChangeLog for the full explanation) */ @@ -778,7 +776,7 @@ static int zoran_open(struct video_device *dev, int flags) memset(ztv->fbuffer,0,ZORAN_MAX_FBUFSIZE); if (!ztv->overinfo.overlay) - ztv->overinfo.overlay = (void*)kmalloc(1024*1024/8, GFP_KERNEL); + ztv->overinfo.overlay = kmalloc(1024*1024/8, GFP_KERNEL); if (!ztv->overinfo.overlay) { /* could not get an overlay buffer, bail out */ bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE); @@ -814,20 +812,17 @@ void zoran_close(struct video_device* dev) zoran_common_close(ztv); - /* - * This is sucky but right now I can't find a good way to - * be sure its safe to free the buffer. We wait 5-6 fields - * which is more than sufficient to be sure. - */ - current->state = TASK_UNINTERRUPTIBLE; - schedule_timeout(HZ/10); /* Wait 1/10th of a second */ + /* + * This is sucky but right now I can't find a good way to + * be sure its safe to free the buffer. We wait 5-6 fields + * which is more than sufficient to be sure. + */ + msleep(100); /* Wait 1/10th of a second */ /* free the allocated framebuffer */ - if (ztv->fbuffer) - bfree( ztv->fbuffer, ZORAN_MAX_FBUFSIZE ); + bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE); ztv->fbuffer = 0; - if (ztv->overinfo.overlay) - kfree( ztv->overinfo.overlay ); + kfree(ztv->overinfo.overlay); ztv->overinfo.overlay = 0; } @@ -903,12 +898,11 @@ long zoran_read(struct video_device* dev, char* buf, unsigned long count, int no zoran_cap(ztv, 1); /* wait till this buffer gets grabbed */ - while (unused->status == FBUFFER_BUSY) { - interruptible_sleep_on(&ztv->grabq); - /* see if a signal did it */ - if (signal_pending(current)) - return -EINTR; - } + wait_event_interruptible(ztv->grabq, + (unused->status != FBUFFER_BUSY)); + /* see if a signal did it */ + if (signal_pending(current)) + return -EINTR; done = unused; } else @@ -1330,12 +1324,11 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg) return -EINVAL; case FBUFFER_BUSY: /* wait till this buffer gets grabbed */ - while (ztv->grabinfo[i].status == FBUFFER_BUSY) { - interruptible_sleep_on(&ztv->grabq); - /* see if a signal did it */ - if (signal_pending(current)) - return -EINTR; - } + wait_event_interruptible(ztv->grabq, + (ztv->grabinfo[i].status != FBUFFER_BUSY)); + /* see if a signal did it */ + if (signal_pending(current)) + return -EINTR; /* don't fall through; a DONE buffer is not UNUSED */ break; case FBUFFER_DONE: @@ -1443,7 +1436,7 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg) /* Why isn't this in the API? * And why doesn't it take a buffer number? - case BTTV_FIELDNR: + case BTTV_FIELDNR: { unsigned long v = ztv->lastfieldnr; if (copy_to_user(arg,&v,sizeof(v))) @@ -1475,8 +1468,8 @@ int zoran_mmap(struct vm_area_struct *vma, struct video_device* dev, const char* /* start mapping the whole shabang to user memory */ pos = (unsigned long)ztv->fbuffer; while (size>0) { - unsigned long page = virt_to_phys((void*)pos); - if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) + unsigned long pfn = virt_to_phys((void*)pos) >> PAGE_SHIFT; + if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED)) return -EAGAIN; start += PAGE_SIZE; pos += PAGE_SIZE; @@ -1497,6 +1490,7 @@ static struct video_device zr36120_template= .write = zoran_write, .poll = zoran_poll, .ioctl = zoran_ioctl, + .compat_ioctl = v4l_compat_ioctl32, .mmap = zoran_mmap, .minor = -1, }; @@ -1504,7 +1498,7 @@ static struct video_device zr36120_template= static int vbi_open(struct video_device *dev, int flags) { - struct zoran *ztv = (struct zoran*)dev->priv; + struct zoran *ztv = dev->priv; struct vidinfo* item; DEBUG(printk(CARD_DEBUG "vbi_open(dev,%d)\n",CARD,flags)); @@ -1553,7 +1547,7 @@ int vbi_open(struct video_device *dev, int flags) static void vbi_close(struct video_device *dev) { - struct zoran *ztv = (struct zoran*)dev->priv; + struct zoran *ztv = dev->priv; struct vidinfo* item; DEBUG(printk(CARD_DEBUG "vbi_close(dev)\n",CARD)); @@ -1563,13 +1557,12 @@ void vbi_close(struct video_device *dev) zoran_common_close(ztv); - /* - * This is sucky but right now I can't find a good way to - * be sure its safe to free the buffer. We wait 5-6 fields - * which is more than sufficient to be sure. - */ - current->state = TASK_UNINTERRUPTIBLE; - schedule_timeout(HZ/10); /* Wait 1/10th of a second */ + /* + * This is sucky but right now I can't find a good way to + * be sure its safe to free the buffer. We wait 5-6 fields + * which is more than sufficient to be sure. + */ + msleep(100); /* Wait 1/10th of a second */ for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++) { @@ -1590,7 +1583,7 @@ void vbi_close(struct video_device *dev) static long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonblock) { - struct zoran *ztv = (struct zoran*)dev->priv; + struct zoran *ztv = dev->priv; unsigned long max; struct vidinfo* unused = 0; struct vidinfo* done = 0; @@ -1627,7 +1620,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb write_unlock_irq(&ztv->lock); return -EWOULDBLOCK; } - + /* mark the unused buffer as wanted */ unused->status = FBUFFER_BUSY; unused->next = 0; @@ -1645,12 +1638,11 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb zoran_cap(ztv, 1); /* wait till this buffer gets grabbed */ - while (unused->status == FBUFFER_BUSY) { - interruptible_sleep_on(&ztv->vbiq); - /* see if a signal did it */ - if (signal_pending(current)) - return -EINTR; - } + wait_event_interruptible(ztv->vbiq, + (unused->status != FBUFFER_BUSY)); + /* see if a signal did it */ + if (signal_pending(current)) + return -EINTR; done = unused; } else @@ -1679,7 +1671,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb if (count == 2*19*2048) { /* * Extreme HACK, old VBI programs expect 2048 points - * of data, and we only got 864 orso. Double each + * of data, and we only got 864 orso. Double each * datapoint and clear the rest of the line. * This way we have appear to have a * sample_frequency of 29.5 Mc. @@ -1745,7 +1737,7 @@ out: static unsigned int vbi_poll(struct video_device *dev, struct file *file, poll_table *wait) { - struct zoran *ztv = (struct zoran*)dev->priv; + struct zoran *ztv = dev->priv; struct vidinfo* item; unsigned int mask = 0; @@ -1766,7 +1758,7 @@ unsigned int vbi_poll(struct video_device *dev, struct file *file, poll_table *w static int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg) { - struct zoran* ztv = (struct zoran*)dev->priv; + struct zoran* ztv = dev->priv; switch (cmd) { case VIDIOCGVBIFMT: @@ -1866,7 +1858,7 @@ int __init find_zoran(void) DEBUG(printk(KERN_DEBUG "zoran: mapped-memory at 0x%p\n",ztv->zoran_mem)); result = request_irq(dev->irq, zoran_irq, - SA_SHIRQ|SA_INTERRUPT,"zoran",(void *)ztv); + SA_SHIRQ|SA_INTERRUPT,"zoran", ztv); if (result==-EINVAL) { iounmap(ztv->zoran_mem); @@ -1955,7 +1947,7 @@ int __init init_zoran(int card) ztv->tuner_type = 0; ztv->running = 0; ztv->users = 0; - ztv->lock = RW_LOCK_UNLOCKED; + rwlock_init(&ztv->lock); ztv->workqueue = 0; ztv->fieldnr = 0; ztv->lastfieldnr = 0; @@ -1964,7 +1956,7 @@ int __init init_zoran(int card) zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC); /* external FL determines TOP frame */ - zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC); + zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC); /* set HSpol */ if (ztv->card->hsync_pos) @@ -2020,7 +2012,7 @@ void release_zoran(int max) struct zoran *ztv; int i; - for (i=0;idev->irq,ztv); - + /* unregister i2c_bus */ i2c_unregister_bus((&ztv->i2c)); @@ -2058,7 +2050,7 @@ void __exit zr36120_exit(void) int __init zr36120_init(void) { int card; - + handle_chipset(); zoran_cards = find_zoran(); if (zoran_cards<0) @@ -2071,7 +2063,7 @@ int __init zr36120_init(void) /* only release the zorans we have registered */ release_zoran(card); return -EIO; - } + } } return 0; }