aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/arv.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c6
-rw-r--r--drivers/media/video/c-qcam.c2
-rw-r--r--drivers/media/video/cafe_ccic.c10
-rw-r--r--drivers/media/video/compat_ioctl32.c3
-rw-r--r--drivers/media/video/cpia.c6
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c2
-rw-r--r--drivers/media/video/cx18/cx18-driver.c28
-rw-r--r--drivers/media/video/cx18/cx18-driver.h20
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c23
-rw-r--r--drivers/media/video/cx18/cx18-dvb.h1
-rw-r--r--drivers/media/video/cx18/cx18-io.c17
-rw-r--r--drivers/media/video/cx18/cx18-io.h21
-rw-r--r--drivers/media/video/cx18/cx18-irq.c96
-rw-r--r--drivers/media/video/cx18/cx18-irq.h4
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.c6
-rw-r--r--drivers/media/video/cx18/cx18-queue.c14
-rw-r--r--drivers/media/video/cx18/cx18-scb.h40
-rw-r--r--drivers/media/video/cx18/cx18-streams.c36
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c2
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c14
-rw-r--r--drivers/media/video/cx88/cx88-cards.c4
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c16
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c2
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c33
-rw-r--r--drivers/media/video/cx88/cx88-video.c16
-rw-r--r--drivers/media/video/cx88/cx88.h1
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c33
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c58
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c10
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c140
-rw-r--r--drivers/media/video/em28xx/em28xx.h6
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c24
-rw-r--r--drivers/media/video/gspca/Kconfig144
-rw-r--r--drivers/media/video/gspca/conex.c3
-rw-r--r--drivers/media/video/gspca/finepix.c8
-rw-r--r--drivers/media/video/gspca/gspca.c56
-rw-r--r--drivers/media/video/gspca/gspca.h6
-rw-r--r--drivers/media/video/gspca/pac7311.c3
-rw-r--r--drivers/media/video/gspca/spca501.c3
-rw-r--r--drivers/media/video/gspca/spca505.c4
-rw-r--r--drivers/media/video/gspca/spca561.c3
-rw-r--r--drivers/media/video/gspca/vc032x.c3
-rw-r--r--drivers/media/video/gspca/zc3xx.c15
-rw-r--r--drivers/media/video/ivtv/Kconfig5
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c38
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.h3
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c4
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c17
-rw-r--r--drivers/media/video/pwc/pwc-if.c2
-rw-r--r--drivers/media/video/s2255drv.c2
-rw-r--r--drivers/media/video/saa7110.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c2
-rw-r--r--drivers/media/video/se401.c2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c24
-rw-r--r--drivers/media/video/stk-webcam.c4
-rw-r--r--drivers/media/video/stv680.c3
-rw-r--r--drivers/media/video/tvaudio.c231
-rw-r--r--drivers/media/video/usbvideo/ibmcam.c12
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c2
-rw-r--r--drivers/media/video/usbvideo/vicam.c3
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c12
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c12
-rw-r--r--drivers/media/video/v4l1-compat.c221
-rw-r--r--drivers/media/video/v4l2-int-device.c5
-rw-r--r--drivers/media/video/v4l2-ioctl.c19
-rw-r--r--drivers/media/video/videobuf-dvb.c52
-rw-r--r--drivers/media/video/vivi.c6
-rw-r--r--drivers/media/video/w9968cf.c16
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c24
-rw-r--r--drivers/media/video/zr364xx.c2
79 files changed, 999 insertions, 715 deletions
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 218754b4906a..e09b00693230 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -866,7 +866,7 @@ static int __init ar_init(void)
866 } 866 }
867 867
868 printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n", 868 printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",
869 ar->vdev->minor, M32R_IRQ_INT3, freq); 869 ar->vdev->num, M32R_IRQ_INT3, freq);
870 870
871 return 0; 871 return 0;
872 872
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 5858bf5ff41c..9ec4cec2e52d 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -4246,7 +4246,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4246 video_nr[btv->c.nr]) < 0) 4246 video_nr[btv->c.nr]) < 0)
4247 goto err; 4247 goto err;
4248 printk(KERN_INFO "bttv%d: registered device video%d\n", 4248 printk(KERN_INFO "bttv%d: registered device video%d\n",
4249 btv->c.nr,btv->video_dev->minor & 0x1f); 4249 btv->c.nr, btv->video_dev->num);
4250 if (device_create_file(&btv->video_dev->dev, 4250 if (device_create_file(&btv->video_dev->dev,
4251 &dev_attr_card)<0) { 4251 &dev_attr_card)<0) {
4252 printk(KERN_ERR "bttv%d: device_create_file 'card' " 4252 printk(KERN_ERR "bttv%d: device_create_file 'card' "
@@ -4263,7 +4263,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4263 vbi_nr[btv->c.nr]) < 0) 4263 vbi_nr[btv->c.nr]) < 0)
4264 goto err; 4264 goto err;
4265 printk(KERN_INFO "bttv%d: registered device vbi%d\n", 4265 printk(KERN_INFO "bttv%d: registered device vbi%d\n",
4266 btv->c.nr,btv->vbi_dev->minor & 0x1f); 4266 btv->c.nr, btv->vbi_dev->num);
4267 4267
4268 if (!btv->has_radio) 4268 if (!btv->has_radio)
4269 return 0; 4269 return 0;
@@ -4275,7 +4275,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4275 radio_nr[btv->c.nr]) < 0) 4275 radio_nr[btv->c.nr]) < 0)
4276 goto err; 4276 goto err;
4277 printk(KERN_INFO "bttv%d: registered device radio%d\n", 4277 printk(KERN_INFO "bttv%d: registered device radio%d\n",
4278 btv->c.nr,btv->radio_dev->minor & 0x1f); 4278 btv->c.nr, btv->radio_dev->num);
4279 4279
4280 /* all done */ 4280 /* all done */
4281 return 0; 4281 return 0;
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 17aa0adb3467..0f930d351466 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -815,7 +815,7 @@ static int init_cqcam(struct parport *port)
815 } 815 }
816 816
817 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n", 817 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
818 qcam->vdev.minor, qcam->pport->name); 818 qcam->vdev.num, qcam->pport->name);
819 819
820 qcams[num_cams++] = qcam; 820 qcams[num_cams++] = qcam;
821 821
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index fc9497bdd322..1740b9ebdcef 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -1476,12 +1476,9 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
1476{ 1476{
1477 struct cafe_camera *cam; 1477 struct cafe_camera *cam;
1478 1478
1479 lock_kernel();
1480 cam = cafe_find_dev(iminor(inode)); 1479 cam = cafe_find_dev(iminor(inode));
1481 if (cam == NULL) { 1480 if (cam == NULL)
1482 unlock_kernel();
1483 return -ENODEV; 1481 return -ENODEV;
1484 }
1485 filp->private_data = cam; 1482 filp->private_data = cam;
1486 1483
1487 mutex_lock(&cam->s_mutex); 1484 mutex_lock(&cam->s_mutex);
@@ -1493,7 +1490,6 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
1493 } 1490 }
1494 (cam->users)++; 1491 (cam->users)++;
1495 mutex_unlock(&cam->s_mutex); 1492 mutex_unlock(&cam->s_mutex);
1496 unlock_kernel();
1497 return 0; 1493 return 0;
1498} 1494}
1499 1495
@@ -2059,10 +2055,10 @@ static void cafe_dfs_cam_setup(struct cafe_camera *cam)
2059 2055
2060 if (!cafe_dfs_root) 2056 if (!cafe_dfs_root)
2061 return; 2057 return;
2062 sprintf(fname, "regs-%d", cam->v4ldev.minor); 2058 sprintf(fname, "regs-%d", cam->v4ldev.num);
2063 cam->dfs_regs = debugfs_create_file(fname, 0444, cafe_dfs_root, 2059 cam->dfs_regs = debugfs_create_file(fname, 0444, cafe_dfs_root,
2064 cam, &cafe_dfs_reg_ops); 2060 cam, &cafe_dfs_reg_ops);
2065 sprintf(fname, "cam-%d", cam->v4ldev.minor); 2061 sprintf(fname, "cam-%d", cam->v4ldev.num);
2066 cam->dfs_cam_regs = debugfs_create_file(fname, 0444, cafe_dfs_root, 2062 cam->dfs_cam_regs = debugfs_create_file(fname, 0444, cafe_dfs_root,
2067 cam, &cafe_dfs_cam_ops); 2063 cam, &cafe_dfs_cam_ops);
2068} 2064}
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index bd5d9de5a008..e6ca4012b5f0 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -867,6 +867,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
867 case VIDIOC_STREAMON32: 867 case VIDIOC_STREAMON32:
868 case VIDIOC_STREAMOFF32: 868 case VIDIOC_STREAMOFF32:
869 case VIDIOC_G_PARM: 869 case VIDIOC_G_PARM:
870 case VIDIOC_S_PARM:
870 case VIDIOC_G_STD: 871 case VIDIOC_G_STD:
871 case VIDIOC_S_STD: 872 case VIDIOC_S_STD:
872 case VIDIOC_G_TUNER: 873 case VIDIOC_G_TUNER:
@@ -885,6 +886,8 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
885 case VIDIOC_S_INPUT32: 886 case VIDIOC_S_INPUT32:
886 case VIDIOC_TRY_FMT32: 887 case VIDIOC_TRY_FMT32:
887 case VIDIOC_S_HW_FREQ_SEEK: 888 case VIDIOC_S_HW_FREQ_SEEK:
889 case VIDIOC_ENUM_FRAMESIZES:
890 case VIDIOC_ENUM_FRAMEINTERVALS:
888 ret = do_video_ioctl(file, cmd, arg); 891 ret = do_video_ioctl(file, cmd, arg);
889 break; 892 break;
890 893
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 1798b779a25a..16c094f77852 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -1347,7 +1347,7 @@ static void create_proc_cpia_cam(struct cam_data *cam)
1347 if (!cpia_proc_root || !cam) 1347 if (!cpia_proc_root || !cam)
1348 return; 1348 return;
1349 1349
1350 snprintf(name, sizeof(name), "video%d", cam->vdev.minor); 1350 snprintf(name, sizeof(name), "video%d", cam->vdev.num);
1351 1351
1352 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root); 1352 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root);
1353 if (!ent) 1353 if (!ent)
@@ -1372,7 +1372,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam)
1372 if (!cam || !cam->proc_entry) 1372 if (!cam || !cam->proc_entry)
1373 return; 1373 return;
1374 1374
1375 snprintf(name, sizeof(name), "video%d", cam->vdev.minor); 1375 snprintf(name, sizeof(name), "video%d", cam->vdev.num);
1376 remove_proc_entry(name, cpia_proc_root); 1376 remove_proc_entry(name, cpia_proc_root);
1377 cam->proc_entry = NULL; 1377 cam->proc_entry = NULL;
1378} 1378}
@@ -4005,7 +4005,7 @@ void cpia_unregister_camera(struct cam_data *cam)
4005 } 4005 }
4006 4006
4007#ifdef CONFIG_PROC_FS 4007#ifdef CONFIG_PROC_FS
4008 DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor); 4008 DBG("destroying /proc/cpia/video%d\n", cam->vdev.num);
4009 destroy_proc_cpia_cam(cam); 4009 destroy_proc_cpia_cam(cam);
4010#endif 4010#endif
4011 if (!cam->open_count) { 4011 if (!cam->open_count) {
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 897e8d1a5c3c..1c6bd633f193 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -1973,7 +1973,7 @@ void cpia2_unregister_camera(struct camera_data *cam)
1973 } else { 1973 } else {
1974 LOG("/dev/video%d removed while open, " 1974 LOG("/dev/video%d removed while open, "
1975 "deferring video_unregister_device\n", 1975 "deferring video_unregister_device\n",
1976 cam->vdev->minor); 1976 cam->vdev->num);
1977 } 1977 }
1978} 1978}
1979 1979
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 085121c2b47f..7874d9790a51 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -448,7 +448,14 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
448 mutex_init(&cx->gpio_lock); 448 mutex_init(&cx->gpio_lock);
449 449
450 spin_lock_init(&cx->lock); 450 spin_lock_init(&cx->lock);
451 spin_lock_init(&cx->dma_reg_lock); 451
452 cx->work_queue = create_singlethread_workqueue(cx->name);
453 if (cx->work_queue == NULL) {
454 CX18_ERR("Could not create work queue\n");
455 return -1;
456 }
457
458 INIT_WORK(&cx->work, cx18_work_handler);
452 459
453 /* start counting open_id at 1 */ 460 /* start counting open_id at 1 */
454 cx->open_id = 1; 461 cx->open_id = 1;
@@ -581,10 +588,10 @@ static void cx18_load_and_init_modules(struct cx18 *cx)
581 588
582#ifdef MODULE 589#ifdef MODULE
583 /* load modules */ 590 /* load modules */
584#ifndef CONFIG_MEDIA_TUNER 591#ifdef CONFIG_MEDIA_TUNER_MODULE
585 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); 592 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER);
586#endif 593#endif
587#ifndef CONFIG_VIDEO_CS5345 594#ifdef CONFIG_VIDEO_CS5345_MODULE
588 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); 595 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345);
589#endif 596#endif
590#endif 597#endif
@@ -613,6 +620,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
613 const struct pci_device_id *pci_id) 620 const struct pci_device_id *pci_id)
614{ 621{
615 int retval = 0; 622 int retval = 0;
623 int i;
616 int vbi_buf_size; 624 int vbi_buf_size;
617 u32 devtype; 625 u32 devtype;
618 struct cx18 *cx; 626 struct cx18 *cx;
@@ -698,7 +706,8 @@ static int __devinit cx18_probe(struct pci_dev *dev,
698 706
699 /* active i2c */ 707 /* active i2c */
700 CX18_DEBUG_INFO("activating i2c...\n"); 708 CX18_DEBUG_INFO("activating i2c...\n");
701 if (init_cx18_i2c(cx)) { 709 retval = init_cx18_i2c(cx);
710 if (retval) {
702 CX18_ERR("Could not initialize i2c\n"); 711 CX18_ERR("Could not initialize i2c\n");
703 goto free_map; 712 goto free_map;
704 } 713 }
@@ -830,14 +839,18 @@ free_map:
830free_mem: 839free_mem:
831 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 840 release_mem_region(cx->base_addr, CX18_MEM_SIZE);
832free_workqueue: 841free_workqueue:
842 destroy_workqueue(cx->work_queue);
833err: 843err:
834 if (retval == 0) 844 if (retval == 0)
835 retval = -ENODEV; 845 retval = -ENODEV;
836 CX18_ERR("Error %d on initialization\n", retval); 846 CX18_ERR("Error %d on initialization\n", retval);
837 cx18_log_statistics(cx); 847 cx18_log_statistics(cx);
838 848
839 kfree(cx18_cards[cx18_cards_active]); 849 i = cx->num;
840 cx18_cards[cx18_cards_active] = NULL; 850 spin_lock(&cx18_cards_lock);
851 kfree(cx18_cards[i]);
852 cx18_cards[i] = NULL;
853 spin_unlock(&cx18_cards_lock);
841 return retval; 854 return retval;
842} 855}
843 856
@@ -927,6 +940,9 @@ static void cx18_remove(struct pci_dev *pci_dev)
927 940
928 cx18_halt_firmware(cx); 941 cx18_halt_firmware(cx);
929 942
943 flush_workqueue(cx->work_queue);
944 destroy_workqueue(cx->work_queue);
945
930 cx18_streams_cleanup(cx, 1); 946 cx18_streams_cleanup(cx, 1);
931 947
932 exit_cx18_i2c(cx); 948 exit_cx18_i2c(cx);
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index a4b1708fafe7..bbdd5f25041d 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -199,12 +199,15 @@ struct cx18_options {
199#define CX18_F_S_APPL_IO 8 /* this stream is used read/written by an application */ 199#define CX18_F_S_APPL_IO 8 /* this stream is used read/written by an application */
200 200
201/* per-cx18, i_flags */ 201/* per-cx18, i_flags */
202#define CX18_F_I_LOADED_FW 0 /* Loaded the firmware the first time */ 202#define CX18_F_I_LOADED_FW 0 /* Loaded firmware 1st time */
203#define CX18_F_I_EOS 4 /* End of encoder stream reached */ 203#define CX18_F_I_EOS 4 /* End of encoder stream */
204#define CX18_F_I_RADIO_USER 5 /* The radio tuner is selected */ 204#define CX18_F_I_RADIO_USER 5 /* radio tuner is selected */
205#define CX18_F_I_ENC_PAUSED 13 /* the encoder is paused */ 205#define CX18_F_I_ENC_PAUSED 13 /* the encoder is paused */
206#define CX18_F_I_INITED 21 /* set after first open */ 206#define CX18_F_I_HAVE_WORK 15 /* there is work to be done */
207#define CX18_F_I_FAILED 22 /* set if first open failed */ 207#define CX18_F_I_WORK_HANDLER_DVB 18 /* work to be done for DVB */
208#define CX18_F_I_INITED 21 /* set after first open */
209#define CX18_F_I_FAILED 22 /* set if first open failed */
210#define CX18_F_I_WORK_INITED 23 /* worker thread initialized */
208 211
209/* These are the VBI types as they appear in the embedded VBI private packets. */ 212/* These are the VBI types as they appear in the embedded VBI private packets. */
210#define CX18_SLICED_TYPE_TELETEXT_B (1) 213#define CX18_SLICED_TYPE_TELETEXT_B (1)
@@ -402,8 +405,6 @@ struct cx18 {
402 spinlock_t lock; /* lock access to this struct */ 405 spinlock_t lock; /* lock access to this struct */
403 int search_pack_header; 406 int search_pack_header;
404 407
405 spinlock_t dma_reg_lock; /* lock access to DMA engine registers */
406
407 int open_id; /* incremented each time an open occurs, used as 408 int open_id; /* incremented each time an open occurs, used as
408 unique ID. Starts at 1, so 0 can be used as 409 unique ID. Starts at 1, so 0 can be used as
409 uninitialized value in the stream->id. */ 410 uninitialized value in the stream->id. */
@@ -433,6 +434,9 @@ struct cx18 {
433 /* when the current DMA is finished this queue is woken up */ 434 /* when the current DMA is finished this queue is woken up */
434 wait_queue_head_t dma_waitq; 435 wait_queue_head_t dma_waitq;
435 436
437 struct workqueue_struct *work_queue;
438 struct work_struct work;
439
436 /* i2c */ 440 /* i2c */
437 struct i2c_adapter i2c_adap[2]; 441 struct i2c_adapter i2c_adap[2];
438 struct i2c_algo_bit_data i2c_algo[2]; 442 struct i2c_algo_bit_data i2c_algo[2];
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index afc694e7bdb2..4542e2e5e3d7 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -23,6 +23,8 @@
23#include "cx18-dvb.h" 23#include "cx18-dvb.h"
24#include "cx18-io.h" 24#include "cx18-io.h"
25#include "cx18-streams.h" 25#include "cx18-streams.h"
26#include "cx18-queue.h"
27#include "cx18-scb.h"
26#include "cx18-cards.h" 28#include "cx18-cards.h"
27#include "s5h1409.h" 29#include "s5h1409.h"
28#include "mxl5005s.h" 30#include "mxl5005s.h"
@@ -300,3 +302,24 @@ static int dvb_register(struct cx18_stream *stream)
300 302
301 return ret; 303 return ret;
302} 304}
305
306void cx18_dvb_work_handler(struct cx18 *cx)
307{
308 struct cx18_buffer *buf;
309 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_TS];
310
311 while ((buf = cx18_dequeue(s, &s->q_full)) != NULL) {
312 if (s->dvb.enabled)
313 dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
314 buf->bytesused);
315
316 cx18_enqueue(s, buf, &s->q_free);
317 cx18_buf_sync_for_device(s, buf);
318 if (s->handle == CX18_INVALID_TASK_HANDLE) /* FIXME: improve */
319 continue;
320
321 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
322 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
323 1, buf->id, s->buf_size);
324 }
325}
diff --git a/drivers/media/video/cx18/cx18-dvb.h b/drivers/media/video/cx18/cx18-dvb.h
index bf8d8f6f5455..bbdcefc87f28 100644
--- a/drivers/media/video/cx18/cx18-dvb.h
+++ b/drivers/media/video/cx18/cx18-dvb.h
@@ -23,3 +23,4 @@
23 23
24int cx18_dvb_register(struct cx18_stream *stream); 24int cx18_dvb_register(struct cx18_stream *stream);
25void cx18_dvb_unregister(struct cx18_stream *stream); 25void cx18_dvb_unregister(struct cx18_stream *stream);
26void cx18_dvb_work_handler(struct cx18 *cx);
diff --git a/drivers/media/video/cx18/cx18-io.c b/drivers/media/video/cx18/cx18-io.c
index 700ab9439c16..220fae8d4ad7 100644
--- a/drivers/media/video/cx18/cx18-io.c
+++ b/drivers/media/video/cx18/cx18-io.c
@@ -88,6 +88,19 @@ void cx18_writel_retry(struct cx18 *cx, u32 val, void __iomem *addr)
88 cx18_log_write_retries(cx, i, addr); 88 cx18_log_write_retries(cx, i, addr);
89} 89}
90 90
91void _cx18_writel_expect(struct cx18 *cx, u32 val, void __iomem *addr,
92 u32 eval, u32 mask)
93{
94 int i;
95 eval &= mask;
96 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
97 cx18_writel_noretry(cx, val, addr);
98 if (eval == (cx18_readl_noretry(cx, addr) & mask))
99 break;
100 }
101 cx18_log_write_retries(cx, i, addr);
102}
103
91void cx18_writew_retry(struct cx18 *cx, u16 val, void __iomem *addr) 104void cx18_writew_retry(struct cx18 *cx, u16 val, void __iomem *addr)
92{ 105{
93 int i; 106 int i;
@@ -218,7 +231,7 @@ void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
218void cx18_sw1_irq_enable(struct cx18 *cx, u32 val) 231void cx18_sw1_irq_enable(struct cx18 *cx, u32 val)
219{ 232{
220 u32 r; 233 u32 r;
221 cx18_write_reg(cx, val, SW1_INT_STATUS); 234 cx18_write_reg_expect(cx, val, SW1_INT_STATUS, ~val, val);
222 r = cx18_read_reg(cx, SW1_INT_ENABLE_PCI); 235 r = cx18_read_reg(cx, SW1_INT_ENABLE_PCI);
223 cx18_write_reg(cx, r | val, SW1_INT_ENABLE_PCI); 236 cx18_write_reg(cx, r | val, SW1_INT_ENABLE_PCI);
224} 237}
@@ -233,7 +246,7 @@ void cx18_sw1_irq_disable(struct cx18 *cx, u32 val)
233void cx18_sw2_irq_enable(struct cx18 *cx, u32 val) 246void cx18_sw2_irq_enable(struct cx18 *cx, u32 val)
234{ 247{
235 u32 r; 248 u32 r;
236 cx18_write_reg(cx, val, SW2_INT_STATUS); 249 cx18_write_reg_expect(cx, val, SW2_INT_STATUS, ~val, val);
237 r = cx18_read_reg(cx, SW2_INT_ENABLE_PCI); 250 r = cx18_read_reg(cx, SW2_INT_ENABLE_PCI);
238 cx18_write_reg(cx, r | val, SW2_INT_ENABLE_PCI); 251 cx18_write_reg(cx, r | val, SW2_INT_ENABLE_PCI);
239} 252}
diff --git a/drivers/media/video/cx18/cx18-io.h b/drivers/media/video/cx18/cx18-io.h
index 197d4fbd9f95..425244453ea7 100644
--- a/drivers/media/video/cx18/cx18-io.h
+++ b/drivers/media/video/cx18/cx18-io.h
@@ -39,7 +39,7 @@ static inline void cx18_io_delay(struct cx18 *cx)
39 39
40/* Statistics gathering */ 40/* Statistics gathering */
41static inline 41static inline
42void cx18_log_write_retries(struct cx18 *cx, int i, const void *addr) 42void cx18_log_write_retries(struct cx18 *cx, int i, const void __iomem *addr)
43{ 43{
44 if (i > CX18_MAX_MMIO_RETRIES) 44 if (i > CX18_MAX_MMIO_RETRIES)
45 i = CX18_MAX_MMIO_RETRIES; 45 i = CX18_MAX_MMIO_RETRIES;
@@ -48,7 +48,7 @@ void cx18_log_write_retries(struct cx18 *cx, int i, const void *addr)
48} 48}
49 49
50static inline 50static inline
51void cx18_log_read_retries(struct cx18 *cx, int i, const void *addr) 51void cx18_log_read_retries(struct cx18 *cx, int i, const void __iomem *addr)
52{ 52{
53 if (i > CX18_MAX_MMIO_RETRIES) 53 if (i > CX18_MAX_MMIO_RETRIES)
54 i = CX18_MAX_MMIO_RETRIES; 54 i = CX18_MAX_MMIO_RETRIES;
@@ -133,6 +133,8 @@ static inline void cx18_writel(struct cx18 *cx, u32 val, void __iomem *addr)
133 cx18_writel_noretry(cx, val, addr); 133 cx18_writel_noretry(cx, val, addr);
134} 134}
135 135
136void _cx18_writel_expect(struct cx18 *cx, u32 val, void __iomem *addr,
137 u32 eval, u32 mask);
136 138
137static inline 139static inline
138void cx18_writew_noretry(struct cx18 *cx, u16 val, void __iomem *addr) 140void cx18_writew_noretry(struct cx18 *cx, u16 val, void __iomem *addr)
@@ -271,6 +273,21 @@ static inline void cx18_write_reg(struct cx18 *cx, u32 val, u32 reg)
271 cx18_write_reg_noretry(cx, val, reg); 273 cx18_write_reg_noretry(cx, val, reg);
272} 274}
273 275
276static inline void _cx18_write_reg_expect(struct cx18 *cx, u32 val, u32 reg,
277 u32 eval, u32 mask)
278{
279 _cx18_writel_expect(cx, val, cx->reg_mem + reg, eval, mask);
280}
281
282static inline void cx18_write_reg_expect(struct cx18 *cx, u32 val, u32 reg,
283 u32 eval, u32 mask)
284{
285 if (cx18_retry_mmio)
286 _cx18_write_reg_expect(cx, val, reg, eval, mask);
287 else
288 cx18_write_reg_noretry(cx, val, reg);
289}
290
274 291
275static inline u32 cx18_read_reg_noretry(struct cx18 *cx, u32 reg) 292static inline u32 cx18_read_reg_noretry(struct cx18 *cx, u32 reg)
276{ 293{
diff --git a/drivers/media/video/cx18/cx18-irq.c b/drivers/media/video/cx18/cx18-irq.c
index 360330f5463f..5fbfbd0f1493 100644
--- a/drivers/media/video/cx18/cx18-irq.c
+++ b/drivers/media/video/cx18/cx18-irq.c
@@ -29,8 +29,20 @@
29#include "cx18-mailbox.h" 29#include "cx18-mailbox.h"
30#include "cx18-vbi.h" 30#include "cx18-vbi.h"
31#include "cx18-scb.h" 31#include "cx18-scb.h"
32#include "cx18-dvb.h"
32 33
33#define DMA_MAGIC_COOKIE 0x000001fe 34void cx18_work_handler(struct work_struct *work)
35{
36 struct cx18 *cx = container_of(work, struct cx18, work);
37 if (test_and_clear_bit(CX18_F_I_WORK_INITED, &cx->i_flags)) {
38 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
39 /* This thread must use the FIFO scheduler as it
40 * is realtime sensitive. */
41 sched_setscheduler(current, SCHED_FIFO, &param);
42 }
43 if (test_and_clear_bit(CX18_F_I_WORK_HANDLER_DVB, &cx->i_flags))
44 cx18_dvb_work_handler(cx);
45}
34 46
35static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb) 47static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb)
36{ 48{
@@ -67,17 +79,11 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb)
67 if (buf) { 79 if (buf) {
68 cx18_buf_sync_for_cpu(s, buf); 80 cx18_buf_sync_for_cpu(s, buf);
69 if (s->type == CX18_ENC_STREAM_TYPE_TS && s->dvb.enabled) { 81 if (s->type == CX18_ENC_STREAM_TYPE_TS && s->dvb.enabled) {
70 /* process the buffer here */ 82 CX18_DEBUG_HI_DMA("TS recv bytesused = %d\n",
71 CX18_DEBUG_HI_DMA("TS recv and sent bytesused=%d\n",
72 buf->bytesused);
73
74 dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
75 buf->bytesused); 83 buf->bytesused);
76 84
77 cx18_buf_sync_for_device(s, buf); 85 set_bit(CX18_F_I_WORK_HANDLER_DVB, &cx->i_flags);
78 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, 86 set_bit(CX18_F_I_HAVE_WORK, &cx->i_flags);
79 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
80 1, buf->id, s->buf_size);
81 } else 87 } else
82 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); 88 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags);
83 } else { 89 } else {
@@ -109,7 +115,7 @@ static void epu_debug(struct cx18 *cx, struct cx18_mailbox *mb)
109 CX18_INFO("FW version: %s\n", p - 1); 115 CX18_INFO("FW version: %s\n", p - 1);
110} 116}
111 117
112static void hpu_cmd(struct cx18 *cx, u32 sw1) 118static void epu_cmd(struct cx18 *cx, u32 sw1)
113{ 119{
114 struct cx18_mailbox mb; 120 struct cx18_mailbox mb;
115 121
@@ -125,12 +131,31 @@ static void hpu_cmd(struct cx18 *cx, u32 sw1)
125 epu_debug(cx, &mb); 131 epu_debug(cx, &mb);
126 break; 132 break;
127 default: 133 default:
128 CX18_WARN("Unexpected mailbox command %08x\n", mb.cmd); 134 CX18_WARN("Unknown CPU_TO_EPU mailbox command %#08x\n",
135 mb.cmd);
129 break; 136 break;
130 } 137 }
131 } 138 }
132 if (sw1 & (IRQ_APU_TO_EPU | IRQ_HPU_TO_EPU)) 139
133 CX18_WARN("Unexpected interrupt %08x\n", sw1); 140 if (sw1 & IRQ_APU_TO_EPU) {
141 cx18_memcpy_fromio(cx, &mb, &cx->scb->apu2epu_mb, sizeof(mb));
142 CX18_WARN("Unknown APU_TO_EPU mailbox command %#08x\n", mb.cmd);
143 }
144
145 if (sw1 & IRQ_HPU_TO_EPU) {
146 cx18_memcpy_fromio(cx, &mb, &cx->scb->hpu2epu_mb, sizeof(mb));
147 CX18_WARN("Unknown HPU_TO_EPU mailbox command %#08x\n", mb.cmd);
148 }
149}
150
151static void xpu_ack(struct cx18 *cx, u32 sw2)
152{
153 if (sw2 & IRQ_CPU_TO_EPU_ACK)
154 wake_up(&cx->mb_cpu_waitq);
155 if (sw2 & IRQ_APU_TO_EPU_ACK)
156 wake_up(&cx->mb_apu_waitq);
157 if (sw2 & IRQ_HPU_TO_EPU_ACK)
158 wake_up(&cx->mb_hpu_waitq);
134} 159}
135 160
136irqreturn_t cx18_irq_handler(int irq, void *dev_id) 161irqreturn_t cx18_irq_handler(int irq, void *dev_id)
@@ -140,43 +165,36 @@ irqreturn_t cx18_irq_handler(int irq, void *dev_id)
140 u32 sw2, sw2_mask; 165 u32 sw2, sw2_mask;
141 u32 hw2, hw2_mask; 166 u32 hw2, hw2_mask;
142 167
143 spin_lock(&cx->dma_reg_lock); 168 sw1_mask = cx18_read_reg(cx, SW1_INT_ENABLE_PCI);
144 169 sw1 = cx18_read_reg(cx, SW1_INT_STATUS) & sw1_mask;
170 sw2_mask = cx18_read_reg(cx, SW2_INT_ENABLE_PCI);
171 sw2 = cx18_read_reg(cx, SW2_INT_STATUS) & sw2_mask;
145 hw2_mask = cx18_read_reg(cx, HW2_INT_MASK5_PCI); 172 hw2_mask = cx18_read_reg(cx, HW2_INT_MASK5_PCI);
146 hw2 = cx18_read_reg(cx, HW2_INT_CLR_STATUS) & hw2_mask; 173 hw2 = cx18_read_reg(cx, HW2_INT_CLR_STATUS) & hw2_mask;
147 sw2_mask = cx18_read_reg(cx, SW2_INT_ENABLE_PCI) | IRQ_EPU_TO_HPU_ACK;
148 sw2 = cx18_read_reg(cx, SW2_INT_STATUS) & sw2_mask;
149 sw1_mask = cx18_read_reg(cx, SW1_INT_ENABLE_PCI) | IRQ_EPU_TO_HPU;
150 sw1 = cx18_read_reg(cx, SW1_INT_STATUS) & sw1_mask;
151 174
152 cx18_write_reg(cx, sw2&sw2_mask, SW2_INT_STATUS); 175 if (sw1)
153 cx18_write_reg(cx, sw1&sw1_mask, SW1_INT_STATUS); 176 cx18_write_reg_expect(cx, sw1, SW1_INT_STATUS, ~sw1, sw1);
154 cx18_write_reg(cx, hw2&hw2_mask, HW2_INT_CLR_STATUS); 177 if (sw2)
178 cx18_write_reg_expect(cx, sw2, SW2_INT_STATUS, ~sw2, sw2);
179 if (hw2)
180 cx18_write_reg_expect(cx, hw2, HW2_INT_CLR_STATUS, ~hw2, hw2);
155 181
156 if (sw1 || sw2 || hw2) 182 if (sw1 || sw2 || hw2)
157 CX18_DEBUG_HI_IRQ("SW1: %x SW2: %x HW2: %x\n", sw1, sw2, hw2); 183 CX18_DEBUG_HI_IRQ("SW1: %x SW2: %x HW2: %x\n", sw1, sw2, hw2);
158 184
159 /* To do: interrupt-based I2C handling 185 /* To do: interrupt-based I2C handling
160 if (hw2 & 0x00c00000) { 186 if (hw2 & (HW2_I2C1_INT|HW2_I2C2_INT)) {
161 } 187 }
162 */ 188 */
163 189
164 if (sw2) { 190 if (sw2)
165 if (sw2 & (cx18_readl(cx, &cx->scb->cpu2hpu_irq_ack) | 191 xpu_ack(cx, sw2);
166 cx18_readl(cx, &cx->scb->cpu2epu_irq_ack)))
167 wake_up(&cx->mb_cpu_waitq);
168 if (sw2 & (cx18_readl(cx, &cx->scb->apu2hpu_irq_ack) |
169 cx18_readl(cx, &cx->scb->apu2epu_irq_ack)))
170 wake_up(&cx->mb_apu_waitq);
171 if (sw2 & cx18_readl(cx, &cx->scb->epu2hpu_irq_ack))
172 wake_up(&cx->mb_epu_waitq);
173 if (sw2 & cx18_readl(cx, &cx->scb->hpu2epu_irq_ack))
174 wake_up(&cx->mb_hpu_waitq);
175 }
176 192
177 if (sw1) 193 if (sw1)
178 hpu_cmd(cx, sw1); 194 epu_cmd(cx, sw1);
179 spin_unlock(&cx->dma_reg_lock); 195
196 if (test_and_clear_bit(CX18_F_I_HAVE_WORK, &cx->i_flags))
197 queue_work(cx->work_queue, &cx->work);
180 198
181 return (hw2 | sw1 | sw2) ? IRQ_HANDLED : IRQ_NONE; 199 return (sw1 || sw2 || hw2) ? IRQ_HANDLED : IRQ_NONE;
182} 200}
diff --git a/drivers/media/video/cx18/cx18-irq.h b/drivers/media/video/cx18/cx18-irq.h
index 379f704f5cba..6173ca3bc9e4 100644
--- a/drivers/media/video/cx18/cx18-irq.h
+++ b/drivers/media/video/cx18/cx18-irq.h
@@ -32,6 +32,4 @@
32 32
33irqreturn_t cx18_irq_handler(int irq, void *dev_id); 33irqreturn_t cx18_irq_handler(int irq, void *dev_id);
34 34
35void cx18_irq_work_handler(struct work_struct *work); 35void cx18_work_handler(struct work_struct *work);
36void cx18_dma_stream_dec_prepare(struct cx18_stream *s, u32 offset, int lock);
37void cx18_unfinished_dma(unsigned long arg);
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c
index 9d18dd22de76..acff7dfb60df 100644
--- a/drivers/media/video/cx18/cx18-mailbox.c
+++ b/drivers/media/video/cx18/cx18-mailbox.c
@@ -83,7 +83,7 @@ static const struct cx18_api_info api_info[] = {
83 API_ENTRY(CPU, CX18_CPU_DE_SET_MDL_ACK, 0), 83 API_ENTRY(CPU, CX18_CPU_DE_SET_MDL_ACK, 0),
84 API_ENTRY(CPU, CX18_CPU_DE_SET_MDL, API_FAST), 84 API_ENTRY(CPU, CX18_CPU_DE_SET_MDL, API_FAST),
85 API_ENTRY(CPU, CX18_APU_RESETAI, API_FAST), 85 API_ENTRY(CPU, CX18_APU_RESETAI, API_FAST),
86 API_ENTRY(CPU, CX18_CPU_DE_RELEASE_MDL, 0), 86 API_ENTRY(CPU, CX18_CPU_DE_RELEASE_MDL, API_SLOW),
87 API_ENTRY(0, 0, 0), 87 API_ENTRY(0, 0, 0),
88}; 88};
89 89
@@ -176,7 +176,7 @@ long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb)
176 176
177 cx18_setup_page(cx, SCB_OFFSET); 177 cx18_setup_page(cx, SCB_OFFSET);
178 cx18_write_sync(cx, mb->request, &ack_mb->ack); 178 cx18_write_sync(cx, mb->request, &ack_mb->ack);
179 cx18_write_reg(cx, ack_irq, SW2_INT_SET); 179 cx18_write_reg_expect(cx, ack_irq, SW2_INT_SET, ack_irq, ack_irq);
180 return 0; 180 return 0;
181} 181}
182 182
@@ -225,7 +225,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
225 } 225 }
226 if (info->flags & API_FAST) 226 if (info->flags & API_FAST)
227 timeout /= 2; 227 timeout /= 2;
228 cx18_write_reg(cx, irq, SW1_INT_SET); 228 cx18_write_reg_expect(cx, irq, SW1_INT_SET, irq, irq);
229 229
230 while (!sig && cx18_readl(cx, &mb->ack) != cx18_readl(cx, &mb->request) 230 while (!sig && cx18_readl(cx, &mb->ack) != cx18_readl(cx, &mb->request)
231 && cnt < 660) { 231 && cnt < 660) {
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index a33ba04a2686..174682c2582f 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -88,15 +88,13 @@ struct cx18_buffer *cx18_queue_get_buf_irq(struct cx18_stream *s, u32 id,
88 88
89 if (buf->id != id) 89 if (buf->id != id)
90 continue; 90 continue;
91
91 buf->bytesused = bytesused; 92 buf->bytesused = bytesused;
92 /* the transport buffers are handled differently, 93 atomic_dec(&s->q_free.buffers);
93 they are not moved to the full queue */ 94 atomic_inc(&s->q_full.buffers);
94 if (s->type != CX18_ENC_STREAM_TYPE_TS) { 95 s->q_full.bytesused += buf->bytesused;
95 atomic_dec(&s->q_free.buffers); 96 list_move_tail(&buf->list, &s->q_full.list);
96 atomic_inc(&s->q_full.buffers); 97
97 s->q_full.bytesused += buf->bytesused;
98 list_move_tail(&buf->list, &s->q_full.list);
99 }
100 spin_unlock(&s->qlock); 98 spin_unlock(&s->qlock);
101 return buf; 99 return buf;
102 } 100 }
diff --git a/drivers/media/video/cx18/cx18-scb.h b/drivers/media/video/cx18/cx18-scb.h
index 86b4cb15d163..594713bbed68 100644
--- a/drivers/media/video/cx18/cx18-scb.h
+++ b/drivers/media/video/cx18/cx18-scb.h
@@ -128,22 +128,22 @@ struct cx18_scb {
128 u32 apu2cpu_irq; 128 u32 apu2cpu_irq;
129 /* Value to write to register SW2 register set (0xC7003140) after the 129 /* Value to write to register SW2 register set (0xC7003140) after the
130 command is cleared */ 130 command is cleared */
131 u32 apu2cpu_irq_ack; 131 u32 cpu2apu_irq_ack;
132 u32 reserved2[13]; 132 u32 reserved2[13];
133 133
134 u32 hpu2cpu_mb_offset; 134 u32 hpu2cpu_mb_offset;
135 u32 hpu2cpu_irq; 135 u32 hpu2cpu_irq;
136 u32 hpu2cpu_irq_ack; 136 u32 cpu2hpu_irq_ack;
137 u32 reserved3[13]; 137 u32 reserved3[13];
138 138
139 u32 ppu2cpu_mb_offset; 139 u32 ppu2cpu_mb_offset;
140 u32 ppu2cpu_irq; 140 u32 ppu2cpu_irq;
141 u32 ppu2cpu_irq_ack; 141 u32 cpu2ppu_irq_ack;
142 u32 reserved4[13]; 142 u32 reserved4[13];
143 143
144 u32 epu2cpu_mb_offset; 144 u32 epu2cpu_mb_offset;
145 u32 epu2cpu_irq; 145 u32 epu2cpu_irq;
146 u32 epu2cpu_irq_ack; 146 u32 cpu2epu_irq_ack;
147 u32 reserved5[13]; 147 u32 reserved5[13];
148 u32 reserved6[8]; 148 u32 reserved6[8];
149 149
@@ -153,22 +153,22 @@ struct cx18_scb {
153 u32 reserved11[7]; 153 u32 reserved11[7];
154 u32 cpu2apu_mb_offset; 154 u32 cpu2apu_mb_offset;
155 u32 cpu2apu_irq; 155 u32 cpu2apu_irq;
156 u32 cpu2apu_irq_ack; 156 u32 apu2cpu_irq_ack;
157 u32 reserved12[13]; 157 u32 reserved12[13];
158 158
159 u32 hpu2apu_mb_offset; 159 u32 hpu2apu_mb_offset;
160 u32 hpu2apu_irq; 160 u32 hpu2apu_irq;
161 u32 hpu2apu_irq_ack; 161 u32 apu2hpu_irq_ack;
162 u32 reserved13[13]; 162 u32 reserved13[13];
163 163
164 u32 ppu2apu_mb_offset; 164 u32 ppu2apu_mb_offset;
165 u32 ppu2apu_irq; 165 u32 ppu2apu_irq;
166 u32 ppu2apu_irq_ack; 166 u32 apu2ppu_irq_ack;
167 u32 reserved14[13]; 167 u32 reserved14[13];
168 168
169 u32 epu2apu_mb_offset; 169 u32 epu2apu_mb_offset;
170 u32 epu2apu_irq; 170 u32 epu2apu_irq;
171 u32 epu2apu_irq_ack; 171 u32 apu2epu_irq_ack;
172 u32 reserved15[13]; 172 u32 reserved15[13];
173 u32 reserved16[8]; 173 u32 reserved16[8];
174 174
@@ -178,22 +178,22 @@ struct cx18_scb {
178 u32 reserved21[7]; 178 u32 reserved21[7];
179 u32 cpu2hpu_mb_offset; 179 u32 cpu2hpu_mb_offset;
180 u32 cpu2hpu_irq; 180 u32 cpu2hpu_irq;
181 u32 cpu2hpu_irq_ack; 181 u32 hpu2cpu_irq_ack;
182 u32 reserved22[13]; 182 u32 reserved22[13];
183 183
184 u32 apu2hpu_mb_offset; 184 u32 apu2hpu_mb_offset;
185 u32 apu2hpu_irq; 185 u32 apu2hpu_irq;
186 u32 apu2hpu_irq_ack; 186 u32 hpu2apu_irq_ack;
187 u32 reserved23[13]; 187 u32 reserved23[13];
188 188
189 u32 ppu2hpu_mb_offset; 189 u32 ppu2hpu_mb_offset;
190 u32 ppu2hpu_irq; 190 u32 ppu2hpu_irq;
191 u32 ppu2hpu_irq_ack; 191 u32 hpu2ppu_irq_ack;
192 u32 reserved24[13]; 192 u32 reserved24[13];
193 193
194 u32 epu2hpu_mb_offset; 194 u32 epu2hpu_mb_offset;
195 u32 epu2hpu_irq; 195 u32 epu2hpu_irq;
196 u32 epu2hpu_irq_ack; 196 u32 hpu2epu_irq_ack;
197 u32 reserved25[13]; 197 u32 reserved25[13];
198 u32 reserved26[8]; 198 u32 reserved26[8];
199 199
@@ -203,22 +203,22 @@ struct cx18_scb {
203 u32 reserved31[7]; 203 u32 reserved31[7];
204 u32 cpu2ppu_mb_offset; 204 u32 cpu2ppu_mb_offset;
205 u32 cpu2ppu_irq; 205 u32 cpu2ppu_irq;
206 u32 cpu2ppu_irq_ack; 206 u32 ppu2cpu_irq_ack;
207 u32 reserved32[13]; 207 u32 reserved32[13];
208 208
209 u32 apu2ppu_mb_offset; 209 u32 apu2ppu_mb_offset;
210 u32 apu2ppu_irq; 210 u32 apu2ppu_irq;
211 u32 apu2ppu_irq_ack; 211 u32 ppu2apu_irq_ack;
212 u32 reserved33[13]; 212 u32 reserved33[13];
213 213
214 u32 hpu2ppu_mb_offset; 214 u32 hpu2ppu_mb_offset;
215 u32 hpu2ppu_irq; 215 u32 hpu2ppu_irq;
216 u32 hpu2ppu_irq_ack; 216 u32 ppu2hpu_irq_ack;
217 u32 reserved34[13]; 217 u32 reserved34[13];
218 218
219 u32 epu2ppu_mb_offset; 219 u32 epu2ppu_mb_offset;
220 u32 epu2ppu_irq; 220 u32 epu2ppu_irq;
221 u32 epu2ppu_irq_ack; 221 u32 ppu2epu_irq_ack;
222 u32 reserved35[13]; 222 u32 reserved35[13];
223 u32 reserved36[8]; 223 u32 reserved36[8];
224 224
@@ -228,22 +228,22 @@ struct cx18_scb {
228 u32 reserved41[7]; 228 u32 reserved41[7];
229 u32 cpu2epu_mb_offset; 229 u32 cpu2epu_mb_offset;
230 u32 cpu2epu_irq; 230 u32 cpu2epu_irq;
231 u32 cpu2epu_irq_ack; 231 u32 epu2cpu_irq_ack;
232 u32 reserved42[13]; 232 u32 reserved42[13];
233 233
234 u32 apu2epu_mb_offset; 234 u32 apu2epu_mb_offset;
235 u32 apu2epu_irq; 235 u32 apu2epu_irq;
236 u32 apu2epu_irq_ack; 236 u32 epu2apu_irq_ack;
237 u32 reserved43[13]; 237 u32 reserved43[13];
238 238
239 u32 hpu2epu_mb_offset; 239 u32 hpu2epu_mb_offset;
240 u32 hpu2epu_irq; 240 u32 hpu2epu_irq;
241 u32 hpu2epu_irq_ack; 241 u32 epu2hpu_irq_ack;
242 u32 reserved44[13]; 242 u32 reserved44[13];
243 243
244 u32 ppu2epu_mb_offset; 244 u32 ppu2epu_mb_offset;
245 u32 ppu2epu_irq; 245 u32 ppu2epu_irq;
246 u32 ppu2epu_irq_ack; 246 u32 epu2ppu_irq_ack;
247 u32 reserved45[13]; 247 u32 reserved45[13];
248 u32 reserved46[8]; 248 u32 reserved46[8];
249 249
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 0c8e7542cf60..e5ff7705b7a1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -200,16 +200,18 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
200/* Initialize v4l2 variables and register v4l2 devices */ 200/* Initialize v4l2 variables and register v4l2 devices */
201int cx18_streams_setup(struct cx18 *cx) 201int cx18_streams_setup(struct cx18 *cx)
202{ 202{
203 int type; 203 int type, ret;
204 204
205 /* Setup V4L2 Devices */ 205 /* Setup V4L2 Devices */
206 for (type = 0; type < CX18_MAX_STREAMS; type++) { 206 for (type = 0; type < CX18_MAX_STREAMS; type++) {
207 /* Prepare device */ 207 /* Prepare device */
208 if (cx18_prep_dev(cx, type)) 208 ret = cx18_prep_dev(cx, type);
209 if (ret < 0)
209 break; 210 break;
210 211
211 /* Allocate Stream */ 212 /* Allocate Stream */
212 if (cx18_stream_alloc(&cx->streams[type])) 213 ret = cx18_stream_alloc(&cx->streams[type]);
214 if (ret < 0)
213 break; 215 break;
214 } 216 }
215 if (type == CX18_MAX_STREAMS) 217 if (type == CX18_MAX_STREAMS)
@@ -217,14 +219,14 @@ int cx18_streams_setup(struct cx18 *cx)
217 219
218 /* One or more streams could not be initialized. Clean 'em all up. */ 220 /* One or more streams could not be initialized. Clean 'em all up. */
219 cx18_streams_cleanup(cx, 0); 221 cx18_streams_cleanup(cx, 0);
220 return -ENOMEM; 222 return ret;
221} 223}
222 224
223static int cx18_reg_dev(struct cx18 *cx, int type) 225static int cx18_reg_dev(struct cx18 *cx, int type)
224{ 226{
225 struct cx18_stream *s = &cx->streams[type]; 227 struct cx18_stream *s = &cx->streams[type];
226 int vfl_type = cx18_stream_info[type].vfl_type; 228 int vfl_type = cx18_stream_info[type].vfl_type;
227 int num; 229 int num, ret;
228 230
229 /* TODO: Shouldn't this be a VFL_TYPE_TRANSPORT or something? 231 /* TODO: Shouldn't this be a VFL_TYPE_TRANSPORT or something?
230 * We need a VFL_TYPE_TS defined. 232 * We need a VFL_TYPE_TS defined.
@@ -233,9 +235,10 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
233 /* just return if no DVB is supported */ 235 /* just return if no DVB is supported */
234 if ((cx->card->hw_all & CX18_HW_DVB) == 0) 236 if ((cx->card->hw_all & CX18_HW_DVB) == 0)
235 return 0; 237 return 0;
236 if (cx18_dvb_register(s) < 0) { 238 ret = cx18_dvb_register(s);
239 if (ret < 0) {
237 CX18_ERR("DVB failed to register\n"); 240 CX18_ERR("DVB failed to register\n");
238 return -EINVAL; 241 return ret;
239 } 242 }
240 } 243 }
241 244
@@ -252,12 +255,13 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
252 } 255 }
253 256
254 /* Register device. First try the desired minor, then any free one. */ 257 /* Register device. First try the desired minor, then any free one. */
255 if (video_register_device(s->v4l2dev, vfl_type, num)) { 258 ret = video_register_device(s->v4l2dev, vfl_type, num);
259 if (ret < 0) {
256 CX18_ERR("Couldn't register v4l2 device for %s kernel number %d\n", 260 CX18_ERR("Couldn't register v4l2 device for %s kernel number %d\n",
257 s->name, num); 261 s->name, num);
258 video_device_release(s->v4l2dev); 262 video_device_release(s->v4l2dev);
259 s->v4l2dev = NULL; 263 s->v4l2dev = NULL;
260 return -ENOMEM; 264 return ret;
261 } 265 }
262 num = s->v4l2dev->num; 266 num = s->v4l2dev->num;
263 267
@@ -290,18 +294,22 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
290int cx18_streams_register(struct cx18 *cx) 294int cx18_streams_register(struct cx18 *cx)
291{ 295{
292 int type; 296 int type;
293 int err = 0; 297 int err;
298 int ret = 0;
294 299
295 /* Register V4L2 devices */ 300 /* Register V4L2 devices */
296 for (type = 0; type < CX18_MAX_STREAMS; type++) 301 for (type = 0; type < CX18_MAX_STREAMS; type++) {
297 err |= cx18_reg_dev(cx, type); 302 err = cx18_reg_dev(cx, type);
303 if (err && ret == 0)
304 ret = err;
305 }
298 306
299 if (err == 0) 307 if (ret == 0)
300 return 0; 308 return 0;
301 309
302 /* One or more streams could not be initialized. Clean 'em all up. */ 310 /* One or more streams could not be initialized. Clean 'em all up. */
303 cx18_streams_cleanup(cx, 1); 311 cx18_streams_cleanup(cx, 1);
304 return -ENOMEM; 312 return ret;
305} 313}
306 314
307/* Unregister v4l2 devices */ 315/* Unregister v4l2 devices */
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 395c11fa47ce..00831f3ef8f5 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1815,7 +1815,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
1815 cx23885_mc417_init(dev); 1815 cx23885_mc417_init(dev);
1816 1816
1817 printk(KERN_INFO "%s: registered device video%d [mpeg]\n", 1817 printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
1818 dev->name, dev->v4l_device->minor & 0x1f); 1818 dev->name, dev->v4l_device->num);
1819 1819
1820 return 0; 1820 return 0;
1821} 1821}
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index ab3110d6046c..c742a10be5cb 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -1543,7 +1543,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
1543 goto fail_unreg; 1543 goto fail_unreg;
1544 } 1544 }
1545 printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n", 1545 printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
1546 dev->name, dev->video_dev->minor & 0x1f); 1546 dev->name, dev->video_dev->num);
1547 /* initial device configuration */ 1547 /* initial device configuration */
1548 mutex_lock(&dev->lock); 1548 mutex_lock(&dev->lock);
1549 cx23885_set_tvnorm(dev, dev->tvnorm); 1549 cx23885_set_tvnorm(dev, dev->tvnorm);
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index e71369754305..d3ae5b4dfca7 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1078,7 +1078,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 if (blackbird_initialize_codec(dev) < 0) { 1081 if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) {
1082 if (drv) 1082 if (drv)
1083 drv->request_release(drv); 1083 drv->request_release(drv);
1084 unlock_kernel(); 1084 unlock_kernel();
@@ -1109,6 +1109,8 @@ static int mpeg_open(struct inode *inode, struct file *file)
1109 fh->mpegq.field); 1109 fh->mpegq.field);
1110 unlock_kernel(); 1110 unlock_kernel();
1111 1111
1112 atomic_inc(&dev->core->mpeg_users);
1113
1112 return 0; 1114 return 0;
1113} 1115}
1114 1116
@@ -1118,7 +1120,7 @@ static int mpeg_release(struct inode *inode, struct file *file)
1118 struct cx8802_dev *dev = fh->dev; 1120 struct cx8802_dev *dev = fh->dev;
1119 struct cx8802_driver *drv = NULL; 1121 struct cx8802_driver *drv = NULL;
1120 1122
1121 if (dev->mpeg_active) 1123 if (dev->mpeg_active && atomic_read(&dev->core->mpeg_users) == 1)
1122 blackbird_stop_codec(dev); 1124 blackbird_stop_codec(dev);
1123 1125
1124 cx8802_cancel_buffers(fh->dev); 1126 cx8802_cancel_buffers(fh->dev);
@@ -1138,6 +1140,8 @@ static int mpeg_release(struct inode *inode, struct file *file)
1138 if (drv) 1140 if (drv)
1139 drv->request_release(drv); 1141 drv->request_release(drv);
1140 1142
1143 atomic_dec(&dev->core->mpeg_users);
1144
1141 return 0; 1145 return 0;
1142} 1146}
1143 1147
@@ -1158,6 +1162,10 @@ static unsigned int
1158mpeg_poll(struct file *file, struct poll_table_struct *wait) 1162mpeg_poll(struct file *file, struct poll_table_struct *wait)
1159{ 1163{
1160 struct cx8802_fh *fh = file->private_data; 1164 struct cx8802_fh *fh = file->private_data;
1165 struct cx8802_dev *dev = fh->dev;
1166
1167 if (!dev->mpeg_active)
1168 blackbird_start_codec(file, fh);
1161 1169
1162 return videobuf_poll_stream(file, &fh->mpegq, wait); 1170 return videobuf_poll_stream(file, &fh->mpegq, wait);
1163} 1171}
@@ -1285,7 +1293,7 @@ static int blackbird_register_video(struct cx8802_dev *dev)
1285 return err; 1293 return err;
1286 } 1294 }
1287 printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n", 1295 printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
1288 dev->core->name,dev->mpeg_dev->minor & 0x1f); 1296 dev->core->name, dev->mpeg_dev->num);
1289 return 0; 1297 return 0;
1290} 1298}
1291 1299
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index fbc224f46e0e..5bcbb4cc7c2a 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -3044,8 +3044,8 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3044 3044
3045 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); 3045 memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board));
3046 3046
3047 if (!core->board.num_frontends) 3047 if (!core->board.num_frontends && (core->board.mpeg & CX88_MPEG_DVB))
3048 core->board.num_frontends=1; 3048 core->board.num_frontends = 1;
3049 3049
3050 info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n", 3050 info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n",
3051 pci->subsystem_vendor, pci->subsystem_device, core->board.name, 3051 pci->subsystem_vendor, pci->subsystem_device, core->board.name,
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 6968ab0181aa..309ca5e68063 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -598,6 +598,11 @@ static int dvb_register(struct cx8802_dev *dev)
598 struct videobuf_dvb_frontend *fe0, *fe1 = NULL; 598 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
599 int mfe_shared = 0; /* bus not shared by default */ 599 int mfe_shared = 0; /* bus not shared by default */
600 600
601 if (0 != core->i2c_rc) {
602 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
603 goto frontend_detach;
604 }
605
601 /* Get the first frontend */ 606 /* Get the first frontend */
602 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 607 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
603 if (!fe0) 608 if (!fe0)
@@ -789,7 +794,7 @@ static int dvb_register(struct cx8802_dev *dev)
789 if (fe0->dvb.frontend) 794 if (fe0->dvb.frontend)
790 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 795 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
791 if (attach_xc3028(0x61, dev) < 0) 796 if (attach_xc3028(0x61, dev) < 0)
792 return -EINVAL; 797 goto frontend_detach;
793 break; 798 break;
794 case CX88_BOARD_PCHDTV_HD3000: 799 case CX88_BOARD_PCHDTV_HD3000:
795 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 800 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
@@ -1058,7 +1063,6 @@ static int dvb_register(struct cx8802_dev *dev)
1058 goto frontend_detach; 1063 goto frontend_detach;
1059 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; 1064 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1060 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1065 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1061
1062 } 1066 }
1063 } 1067 }
1064 break; 1068 break;
@@ -1110,10 +1114,7 @@ static int dvb_register(struct cx8802_dev *dev)
1110 &dev->pci->dev, adapter_nr, mfe_shared); 1114 &dev->pci->dev, adapter_nr, mfe_shared);
1111 1115
1112frontend_detach: 1116frontend_detach:
1113 if (fe0->dvb.frontend) { 1117 videobuf_dvb_dealloc_frontends(&dev->frontends);
1114 dvb_frontend_detach(fe0->dvb.frontend);
1115 fe0->dvb.frontend = NULL;
1116 }
1117 return -EINVAL; 1118 return -EINVAL;
1118} 1119}
1119 1120
@@ -1246,8 +1247,11 @@ fail_core:
1246 1247
1247static int cx8802_dvb_remove(struct cx8802_driver *drv) 1248static int cx8802_dvb_remove(struct cx8802_driver *drv)
1248{ 1249{
1250 struct cx88_core *core = drv->core;
1249 struct cx8802_dev *dev = drv->core->dvbdev; 1251 struct cx8802_dev *dev = drv->core->dvbdev;
1250 1252
1253 dprintk( 1, "%s\n", __func__);
1254
1251 videobuf_dvb_unregister_bus(&dev->frontends); 1255 videobuf_dvb_unregister_bus(&dev->frontends);
1252 1256
1253 vp3054_i2c_remove(dev); 1257 vp3054_i2c_remove(dev);
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 01de23007095..1ab691d20692 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -116,8 +116,10 @@ static int detach_inform(struct i2c_client *client)
116 116
117void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) 117void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
118{ 118{
119#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
119 struct videobuf_dvb_frontends *f = &core->dvbdev->frontends; 120 struct videobuf_dvb_frontends *f = &core->dvbdev->frontends;
120 struct videobuf_dvb_frontend *fe = NULL; 121 struct videobuf_dvb_frontend *fe = NULL;
122#endif
121 if (0 != core->i2c_rc) 123 if (0 != core->i2c_rc)
122 return; 124 return;
123 125
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 6df5cf314186..3ebdcd1d83f8 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -768,8 +768,7 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
768{ 768{
769 struct cx8802_dev *dev; 769 struct cx8802_dev *dev;
770 struct cx88_core *core; 770 struct cx88_core *core;
771 struct videobuf_dvb_frontend *demod; 771 int err;
772 int err,i;
773 772
774 /* general setup */ 773 /* general setup */
775 core = cx88_core_get(pci_dev); 774 core = cx88_core_get(pci_dev);
@@ -782,11 +781,6 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
782 if (!core->board.mpeg) 781 if (!core->board.mpeg)
783 goto fail_core; 782 goto fail_core;
784 783
785 if (!core->board.num_frontends) {
786 printk(KERN_ERR "%s() .num_frontends should be non-zero, err = %d\n", __func__, err);
787 goto fail_core;
788 }
789
790 err = -ENOMEM; 784 err = -ENOMEM;
791 dev = kzalloc(sizeof(*dev),GFP_KERNEL); 785 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
792 if (NULL == dev) 786 if (NULL == dev)
@@ -801,19 +795,28 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
801 INIT_LIST_HEAD(&dev->drvlist); 795 INIT_LIST_HEAD(&dev->drvlist);
802 list_add_tail(&dev->devlist,&cx8802_devlist); 796 list_add_tail(&dev->devlist,&cx8802_devlist);
803 797
798#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
804 mutex_init(&dev->frontends.lock); 799 mutex_init(&dev->frontends.lock);
805 INIT_LIST_HEAD(&dev->frontends.felist); 800 INIT_LIST_HEAD(&dev->frontends.felist);
806 801
807 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, core->board.num_frontends); 802 if (core->board.num_frontends) {
808 803 struct videobuf_dvb_frontend *fe;
809 for (i = 1; i <= core->board.num_frontends; i++) { 804 int i;
810 demod = videobuf_dvb_alloc_frontend(&dev->frontends, i); 805
811 if(demod == NULL) { 806 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
812 printk(KERN_ERR "%s() failed to alloc\n", __func__); 807 core->board.num_frontends);
813 err = -ENOMEM; 808 for (i = 1; i <= core->board.num_frontends; i++) {
814 goto fail_free; 809 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
810 if(fe == NULL) {
811 printk(KERN_ERR "%s() failed to alloc\n",
812 __func__);
813 videobuf_dvb_dealloc_frontends(&dev->frontends);
814 err = -ENOMEM;
815 goto fail_free;
816 }
815 } 817 }
816 } 818 }
819#endif
817 820
818 /* Maintain a reference so cx88-video can query the 8802 device. */ 821 /* Maintain a reference so cx88-video can query the 8802 device. */
819 core->dvbdev = dev; 822 core->dvbdev = dev;
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 3904b73f52ee..b96ce991d968 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1216,8 +1216,12 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1216 struct cx8800_fh *fh = priv; 1216 struct cx8800_fh *fh = priv;
1217 struct cx8800_dev *dev = fh->dev; 1217 struct cx8800_dev *dev = fh->dev;
1218 1218
1219 if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) 1219 /* We should remember that this driver also supports teletext, */
1220 /* so we have to test if the v4l2_buf_type is VBI capture data. */
1221 if (unlikely((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
1222 (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)))
1220 return -EINVAL; 1223 return -EINVAL;
1224
1221 if (unlikely(i != fh->type)) 1225 if (unlikely(i != fh->type))
1222 return -EINVAL; 1226 return -EINVAL;
1223 1227
@@ -1232,8 +1236,10 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1232 struct cx8800_dev *dev = fh->dev; 1236 struct cx8800_dev *dev = fh->dev;
1233 int err, res; 1237 int err, res;
1234 1238
1235 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1239 if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
1240 (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))
1236 return -EINVAL; 1241 return -EINVAL;
1242
1237 if (i != fh->type) 1243 if (i != fh->type)
1238 return -EINVAL; 1244 return -EINVAL;
1239 1245
@@ -1911,7 +1917,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1911 goto fail_unreg; 1917 goto fail_unreg;
1912 } 1918 }
1913 printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n", 1919 printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
1914 core->name,dev->video_dev->minor & 0x1f); 1920 core->name, dev->video_dev->num);
1915 1921
1916 dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); 1922 dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
1917 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, 1923 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
@@ -1922,7 +1928,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1922 goto fail_unreg; 1928 goto fail_unreg;
1923 } 1929 }
1924 printk(KERN_INFO "%s/0: registered device vbi%d\n", 1930 printk(KERN_INFO "%s/0: registered device vbi%d\n",
1925 core->name,dev->vbi_dev->minor & 0x1f); 1931 core->name, dev->vbi_dev->num);
1926 1932
1927 if (core->board.radio.type == CX88_RADIO) { 1933 if (core->board.radio.type == CX88_RADIO) {
1928 dev->radio_dev = cx88_vdev_init(core,dev->pci, 1934 dev->radio_dev = cx88_vdev_init(core,dev->pci,
@@ -1935,7 +1941,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1935 goto fail_unreg; 1941 goto fail_unreg;
1936 } 1942 }
1937 printk(KERN_INFO "%s/0: registered device radio%d\n", 1943 printk(KERN_INFO "%s/0: registered device radio%d\n",
1938 core->name,dev->radio_dev->minor & 0x1f); 1944 core->name, dev->radio_dev->num);
1939 } 1945 }
1940 1946
1941 /* everything worked */ 1947 /* everything worked */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 76207c2856b7..f4240965be32 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -352,6 +352,7 @@ struct cx88_core {
352 /* various v4l controls */ 352 /* various v4l controls */
353 u32 freq; 353 u32 freq;
354 atomic_t users; 354 atomic_t users;
355 atomic_t mpeg_users;
355 356
356 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 357 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
357 struct cx8802_dev *dvbdev; 358 struct cx8802_dev *dvbdev;
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index ac3292d7646c..7a8d49ef646e 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -62,7 +62,7 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev)
62 62
63 dprintk("Stopping isoc\n"); 63 dprintk("Stopping isoc\n");
64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { 64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
65 usb_kill_urb(dev->adev->urb[i]); 65 usb_unlink_urb(dev->adev->urb[i]);
66 usb_free_urb(dev->adev->urb[i]); 66 usb_free_urb(dev->adev->urb[i]);
67 dev->adev->urb[i] = NULL; 67 dev->adev->urb[i] = NULL;
68 } 68 }
@@ -75,7 +75,6 @@ static void em28xx_audio_isocirq(struct urb *urb)
75 struct em28xx *dev = urb->context; 75 struct em28xx *dev = urb->context;
76 int i; 76 int i;
77 unsigned int oldptr; 77 unsigned int oldptr;
78 unsigned long flags;
79 int period_elapsed = 0; 78 int period_elapsed = 0;
80 int status; 79 int status;
81 unsigned char *cp; 80 unsigned char *cp;
@@ -96,9 +95,21 @@ static void em28xx_audio_isocirq(struct urb *urb)
96 if (!length) 95 if (!length)
97 continue; 96 continue;
98 97
99 spin_lock_irqsave(&dev->adev->slock, flags);
100
101 oldptr = dev->adev->hwptr_done_capture; 98 oldptr = dev->adev->hwptr_done_capture;
99 if (oldptr + length >= runtime->buffer_size) {
100 unsigned int cnt =
101 runtime->buffer_size - oldptr;
102 memcpy(runtime->dma_area + oldptr * stride, cp,
103 cnt * stride);
104 memcpy(runtime->dma_area, cp + cnt * stride,
105 length * stride - cnt * stride);
106 } else {
107 memcpy(runtime->dma_area + oldptr * stride, cp,
108 length * stride);
109 }
110
111 snd_pcm_stream_lock(substream);
112
102 dev->adev->hwptr_done_capture += length; 113 dev->adev->hwptr_done_capture += length;
103 if (dev->adev->hwptr_done_capture >= 114 if (dev->adev->hwptr_done_capture >=
104 runtime->buffer_size) 115 runtime->buffer_size)
@@ -113,19 +124,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
113 period_elapsed = 1; 124 period_elapsed = 1;
114 } 125 }
115 126
116 spin_unlock_irqrestore(&dev->adev->slock, flags); 127 snd_pcm_stream_unlock(substream);
117
118 if (oldptr + length >= runtime->buffer_size) {
119 unsigned int cnt =
120 runtime->buffer_size - oldptr;
121 memcpy(runtime->dma_area + oldptr * stride, cp,
122 cnt * stride);
123 memcpy(runtime->dma_area, cp + cnt * stride,
124 length * stride - cnt * stride);
125 } else {
126 memcpy(runtime->dma_area + oldptr * stride, cp,
127 length * stride);
128 }
129 } 128 }
130 if (period_elapsed) 129 if (period_elapsed)
131 snd_pcm_period_elapsed(substream); 130 snd_pcm_period_elapsed(substream);
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 5d837c16ee22..15e2b525310d 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -69,19 +69,33 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
69 int ret, byte; 69 int ret, byte;
70 70
71 if (dev->state & DEV_DISCONNECTED) 71 if (dev->state & DEV_DISCONNECTED)
72 return(-ENODEV); 72 return -ENODEV;
73
74 if (len > URB_MAX_CTRL_SIZE)
75 return -EINVAL;
73 76
74 em28xx_regdbg("req=%02x, reg=%02x ", req, reg); 77 em28xx_regdbg("req=%02x, reg=%02x ", req, reg);
75 78
79 mutex_lock(&dev->ctrl_urb_lock);
76 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 80 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 81 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78 0x0000, reg, buf, len, HZ); 82 0x0000, reg, dev->urb_buf, len, HZ);
83 if (ret < 0) {
84 if (reg_debug)
85 printk(" failed!\n");
86 mutex_unlock(&dev->ctrl_urb_lock);
87 return ret;
88 }
89
90 if (len)
91 memcpy(buf, dev->urb_buf, len);
92
93 mutex_unlock(&dev->ctrl_urb_lock);
79 94
80 if (reg_debug) { 95 if (reg_debug) {
81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); 96 printk("%02x values: ", ret);
82 for (byte = 0; byte < len; byte++) 97 for (byte = 0; byte < len; byte++)
83 printk(" %02x", (unsigned char)buf[byte]); 98 printk(" %02x", (unsigned char)buf[byte]);
84
85 printk("\n"); 99 printk("\n");
86 } 100 }
87 101
@@ -102,16 +116,20 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
102 116
103 em28xx_regdbg("req=%02x, reg=%02x:", req, reg); 117 em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
104 118
119 mutex_lock(&dev->ctrl_urb_lock);
105 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 120 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
106 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 121 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
107 0x0000, reg, &val, 1, HZ); 122 0x0000, reg, dev->urb_buf, 1, HZ);
108 123 val = dev->urb_buf[0];
109 if (reg_debug) 124 mutex_unlock(&dev->ctrl_urb_lock);
110 printk(ret < 0 ? " failed!\n" :
111 "%02x\n", (unsigned char) val);
112 125
113 if (ret < 0) 126 if (ret < 0) {
127 printk(" failed!\n");
114 return ret; 128 return ret;
129 }
130
131 if (reg_debug)
132 printk("%02x\n", (unsigned char) val);
115 133
116 return val; 134 return val;
117} 135}
@@ -130,19 +148,13 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
130{ 148{
131 int ret; 149 int ret;
132 150
133 /*usb_control_msg seems to expect a kmalloced buffer */
134 unsigned char *bufs;
135
136 if (dev->state & DEV_DISCONNECTED) 151 if (dev->state & DEV_DISCONNECTED)
137 return -ENODEV; 152 return -ENODEV;
138 153
139 if (len < 1) 154 if ((len < 1) || (len > URB_MAX_CTRL_SIZE))
140 return -EINVAL; 155 return -EINVAL;
141 156
142 bufs = kmalloc(len, GFP_KERNEL);
143
144 em28xx_regdbg("req=%02x reg=%02x:", req, reg); 157 em28xx_regdbg("req=%02x reg=%02x:", req, reg);
145
146 if (reg_debug) { 158 if (reg_debug) {
147 int i; 159 int i;
148 for (i = 0; i < len; ++i) 160 for (i = 0; i < len; ++i)
@@ -150,16 +162,16 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
150 printk("\n"); 162 printk("\n");
151 } 163 }
152 164
153 if (!bufs) 165 mutex_lock(&dev->ctrl_urb_lock);
154 return -ENOMEM; 166 memcpy(dev->urb_buf, buf, len);
155 memcpy(bufs, buf, len);
156 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, 167 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req,
157 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 168 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
158 0x0000, reg, bufs, len, HZ); 169 0x0000, reg, dev->urb_buf, len, HZ);
170 mutex_unlock(&dev->ctrl_urb_lock);
171
159 if (dev->wait_after_write) 172 if (dev->wait_after_write)
160 msleep(dev->wait_after_write); 173 msleep(dev->wait_after_write);
161 174
162 kfree(bufs);
163 return ret; 175 return ret;
164} 176}
165 177
@@ -270,6 +282,8 @@ static int em28xx_set_audio_source(struct em28xx *dev)
270 break; 282 break;
271 case EM28XX_AMUX_LINE_IN: 283 case EM28XX_AMUX_LINE_IN:
272 input = EM28XX_AUDIO_SRC_LINE; 284 input = EM28XX_AUDIO_SRC_LINE;
285 video = disable;
286 line = enable;
273 break; 287 break;
274 case EM28XX_AMUX_AC97_VIDEO: 288 case EM28XX_AMUX_AC97_VIDEO:
275 input = EM28XX_AUDIO_SRC_LINE; 289 input = EM28XX_AUDIO_SRC_LINE;
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 3bab56b997fc..2360c61ddca9 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -337,9 +337,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
337 /* Check if board has eeprom */ 337 /* Check if board has eeprom */
338 err = i2c_master_recv(&dev->i2c_client, &buf, 0); 338 err = i2c_master_recv(&dev->i2c_client, &buf, 0);
339 if (err < 0) { 339 if (err < 0) {
340 em28xx_errdev("%s: i2c_master_recv failed! err [%d]\n", 340 em28xx_errdev("board has no eeprom\n");
341 __func__, err); 341 memset(eedata, 0, len);
342 return err; 342 return -ENODEV;
343 } 343 }
344 344
345 buf = 0; 345 buf = 0;
@@ -609,14 +609,16 @@ int em28xx_i2c_register(struct em28xx *dev)
609 dev->i2c_client.adapter = &dev->i2c_adap; 609 dev->i2c_client.adapter = &dev->i2c_adap;
610 610
611 retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); 611 retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
612 if (retval < 0) { 612 if ((retval < 0) && (retval != -ENODEV)) {
613 em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", 613 em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n",
614 __func__, retval); 614 __func__, retval);
615
615 return retval; 616 return retval;
616 } 617 }
617 618
618 if (i2c_scan) 619 if (i2c_scan)
619 em28xx_do_i2c_scan(dev); 620 em28xx_do_i2c_scan(dev);
621
620 return 0; 622 return 0;
621} 623}
622 624
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index c53649e5315b..610f535a257c 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -73,6 +73,7 @@ MODULE_DESCRIPTION(DRIVER_DESC);
73MODULE_LICENSE("GPL"); 73MODULE_LICENSE("GPL");
74 74
75static LIST_HEAD(em28xx_devlist); 75static LIST_HEAD(em28xx_devlist);
76static DEFINE_MUTEX(em28xx_devlist_mutex);
76 77
77static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; 78static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
78static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; 79static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
@@ -1519,7 +1520,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1519 struct em28xx_fh *fh; 1520 struct em28xx_fh *fh;
1520 enum v4l2_buf_type fh_type = 0; 1521 enum v4l2_buf_type fh_type = 0;
1521 1522
1522 lock_kernel(); 1523 mutex_lock(&em28xx_devlist_mutex);
1523 list_for_each_entry(h, &em28xx_devlist, devlist) { 1524 list_for_each_entry(h, &em28xx_devlist, devlist) {
1524 if (h->vdev->minor == minor) { 1525 if (h->vdev->minor == minor) {
1525 dev = h; 1526 dev = h;
@@ -1535,10 +1536,11 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1535 dev = h; 1536 dev = h;
1536 } 1537 }
1537 } 1538 }
1538 if (NULL == dev) { 1539 mutex_unlock(&em28xx_devlist_mutex);
1539 unlock_kernel(); 1540 if (NULL == dev)
1540 return -ENODEV; 1541 return -ENODEV;
1541 } 1542
1543 mutex_lock(&dev->lock);
1542 1544
1543 em28xx_videodbg("open minor=%d type=%s users=%d\n", 1545 em28xx_videodbg("open minor=%d type=%s users=%d\n",
1544 minor, v4l2_type_names[fh_type], dev->users); 1546 minor, v4l2_type_names[fh_type], dev->users);
@@ -1547,10 +1549,9 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1547 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); 1549 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
1548 if (!fh) { 1550 if (!fh) {
1549 em28xx_errdev("em28xx-video.c: Out of memory?!\n"); 1551 em28xx_errdev("em28xx-video.c: Out of memory?!\n");
1550 unlock_kernel(); 1552 mutex_unlock(&dev->lock);
1551 return -ENOMEM; 1553 return -ENOMEM;
1552 } 1554 }
1553 mutex_lock(&dev->lock);
1554 fh->dev = dev; 1555 fh->dev = dev;
1555 fh->radio = radio; 1556 fh->radio = radio;
1556 fh->type = fh_type; 1557 fh->type = fh_type;
@@ -1584,7 +1585,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1584 sizeof(struct em28xx_buffer), fh); 1585 sizeof(struct em28xx_buffer), fh);
1585 1586
1586 mutex_unlock(&dev->lock); 1587 mutex_unlock(&dev->lock);
1587 unlock_kernel();
1588 1588
1589 return errCode; 1589 return errCode;
1590} 1590}
@@ -1871,6 +1871,7 @@ int em28xx_register_extension(struct em28xx_ops *ops)
1871{ 1871{
1872 struct em28xx *dev = NULL; 1872 struct em28xx *dev = NULL;
1873 1873
1874 mutex_lock(&em28xx_devlist_mutex);
1874 mutex_lock(&em28xx_extension_devlist_lock); 1875 mutex_lock(&em28xx_extension_devlist_lock);
1875 list_add_tail(&ops->next, &em28xx_extension_devlist); 1876 list_add_tail(&ops->next, &em28xx_extension_devlist);
1876 list_for_each_entry(dev, &em28xx_devlist, devlist) { 1877 list_for_each_entry(dev, &em28xx_devlist, devlist) {
@@ -1879,6 +1880,7 @@ int em28xx_register_extension(struct em28xx_ops *ops)
1879 } 1880 }
1880 printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); 1881 printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name);
1881 mutex_unlock(&em28xx_extension_devlist_lock); 1882 mutex_unlock(&em28xx_extension_devlist_lock);
1883 mutex_unlock(&em28xx_devlist_mutex);
1882 return 0; 1884 return 0;
1883} 1885}
1884EXPORT_SYMBOL(em28xx_register_extension); 1886EXPORT_SYMBOL(em28xx_register_extension);
@@ -1887,6 +1889,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1887{ 1889{
1888 struct em28xx *dev = NULL; 1890 struct em28xx *dev = NULL;
1889 1891
1892 mutex_lock(&em28xx_devlist_mutex);
1890 list_for_each_entry(dev, &em28xx_devlist, devlist) { 1893 list_for_each_entry(dev, &em28xx_devlist, devlist) {
1891 if (dev) 1894 if (dev)
1892 ops->fini(dev); 1895 ops->fini(dev);
@@ -1896,6 +1899,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1896 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); 1899 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name);
1897 list_del(&ops->next); 1900 list_del(&ops->next);
1898 mutex_unlock(&em28xx_extension_devlist_lock); 1901 mutex_unlock(&em28xx_extension_devlist_lock);
1902 mutex_unlock(&em28xx_devlist_mutex);
1899} 1903}
1900EXPORT_SYMBOL(em28xx_unregister_extension); 1904EXPORT_SYMBOL(em28xx_unregister_extension);
1901 1905
@@ -1921,6 +1925,60 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1921} 1925}
1922 1926
1923 1927
1928static int register_analog_devices(struct em28xx *dev)
1929{
1930 int ret;
1931
1932 /* allocate and fill video video_device struct */
1933 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
1934 if (!dev->vdev) {
1935 em28xx_errdev("cannot allocate video_device.\n");
1936 return -ENODEV;
1937 }
1938
1939 /* register v4l2 video video_device */
1940 ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
1941 video_nr[dev->devno]);
1942 if (ret) {
1943 em28xx_errdev("unable to register video device (error=%i).\n",
1944 ret);
1945 return ret;
1946 }
1947
1948 /* Allocate and fill vbi video_device struct */
1949 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi");
1950
1951 /* register v4l2 vbi video_device */
1952 ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1953 vbi_nr[dev->devno]);
1954 if (ret < 0) {
1955 em28xx_errdev("unable to register vbi device\n");
1956 return ret;
1957 }
1958
1959 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) {
1960 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio");
1961 if (!dev->radio_dev) {
1962 em28xx_errdev("cannot allocate video_device.\n");
1963 return -ENODEV;
1964 }
1965 ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
1966 radio_nr[dev->devno]);
1967 if (ret < 0) {
1968 em28xx_errdev("can't register radio device\n");
1969 return ret;
1970 }
1971 em28xx_info("Registered radio device as /dev/radio%d\n",
1972 dev->radio_dev->num);
1973 }
1974
1975 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
1976 dev->vdev->num, dev->vbi_dev->num);
1977
1978 return 0;
1979}
1980
1981
1924/* 1982/*
1925 * em28xx_init_dev() 1983 * em28xx_init_dev()
1926 * allocates and inits the device structs, registers i2c bus and v4l device 1984 * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1936,6 +1994,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1936 1994
1937 dev->udev = udev; 1995 dev->udev = udev;
1938 mutex_init(&dev->lock); 1996 mutex_init(&dev->lock);
1997 mutex_init(&dev->ctrl_urb_lock);
1939 spin_lock_init(&dev->slock); 1998 spin_lock_init(&dev->slock);
1940 init_waitqueue_head(&dev->open); 1999 init_waitqueue_head(&dev->open);
1941 init_waitqueue_head(&dev->wait_frame); 2000 init_waitqueue_head(&dev->wait_frame);
@@ -1953,8 +2012,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1953 errCode = em28xx_config(dev); 2012 errCode = em28xx_config(dev);
1954 if (errCode) { 2013 if (errCode) {
1955 em28xx_errdev("error configuring device\n"); 2014 em28xx_errdev("error configuring device\n");
1956 em28xx_devused &= ~(1<<dev->devno);
1957 kfree(dev);
1958 return -ENOMEM; 2015 return -ENOMEM;
1959 } 2016 }
1960 2017
@@ -2001,50 +2058,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2001 return errCode; 2058 return errCode;
2002 } 2059 }
2003 2060
2004 list_add_tail(&dev->devlist, &em28xx_devlist);
2005
2006 /* allocate and fill video video_device struct */
2007 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
2008 if (NULL == dev->vdev) {
2009 em28xx_errdev("cannot allocate video_device.\n");
2010 goto fail_unreg;
2011 }
2012
2013 /* register v4l2 video video_device */
2014 retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
2015 video_nr[dev->devno]);
2016 if (retval) {
2017 em28xx_errdev("unable to register video device (error=%i).\n",
2018 retval);
2019 goto fail_unreg;
2020 }
2021
2022 /* Allocate and fill vbi video_device struct */
2023 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi");
2024 /* register v4l2 vbi video_device */
2025 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
2026 vbi_nr[dev->devno]) < 0) {
2027 em28xx_errdev("unable to register vbi device\n");
2028 retval = -ENODEV;
2029 goto fail_unreg;
2030 }
2031
2032 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) {
2033 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio");
2034 if (NULL == dev->radio_dev) {
2035 em28xx_errdev("cannot allocate video_device.\n");
2036 goto fail_unreg;
2037 }
2038 retval = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
2039 radio_nr[dev->devno]);
2040 if (retval < 0) {
2041 em28xx_errdev("can't register radio device\n");
2042 goto fail_unreg;
2043 }
2044 em28xx_info("Registered radio device as /dev/radio%d\n",
2045 dev->radio_dev->minor & 0x1f);
2046 }
2047
2048 /* init video dma queues */ 2061 /* init video dma queues */
2049 INIT_LIST_HEAD(&dev->vidq.active); 2062 INIT_LIST_HEAD(&dev->vidq.active);
2050 INIT_LIST_HEAD(&dev->vidq.queued); 2063 INIT_LIST_HEAD(&dev->vidq.queued);
@@ -2071,8 +2084,14 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2071 2084
2072 video_mux(dev, 0); 2085 video_mux(dev, 0);
2073 2086
2074 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", 2087 mutex_lock(&em28xx_devlist_mutex);
2075 dev->vdev->num, dev->vbi_dev->num); 2088 list_add_tail(&dev->devlist, &em28xx_devlist);
2089 retval = register_analog_devices(dev);
2090 if (retval < 0) {
2091 em28xx_release_resources(dev);
2092 mutex_unlock(&em28xx_devlist_mutex);
2093 goto fail_reg_devices;
2094 }
2076 2095
2077 mutex_lock(&em28xx_extension_devlist_lock); 2096 mutex_lock(&em28xx_extension_devlist_lock);
2078 if (!list_empty(&em28xx_extension_devlist)) { 2097 if (!list_empty(&em28xx_extension_devlist)) {
@@ -2082,13 +2101,12 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2082 } 2101 }
2083 } 2102 }
2084 mutex_unlock(&em28xx_extension_devlist_lock); 2103 mutex_unlock(&em28xx_extension_devlist_lock);
2104 mutex_unlock(&em28xx_devlist_mutex);
2085 2105
2086 return 0; 2106 return 0;
2087 2107
2088fail_unreg: 2108fail_reg_devices:
2089 em28xx_release_resources(dev);
2090 mutex_unlock(&dev->lock); 2109 mutex_unlock(&dev->lock);
2091 kfree(dev);
2092 return retval; 2110 return retval;
2093} 2111}
2094 2112
@@ -2231,8 +2249,12 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2231 2249
2232 /* allocate device struct */ 2250 /* allocate device struct */
2233 retval = em28xx_init_dev(&dev, udev, nr); 2251 retval = em28xx_init_dev(&dev, udev, nr);
2234 if (retval) 2252 if (retval) {
2253 em28xx_devused &= ~(1<<dev->devno);
2254 kfree(dev);
2255
2235 return retval; 2256 return retval;
2257 }
2236 2258
2237 em28xx_info("Found %s\n", em28xx_boards[dev->model].name); 2259 em28xx_info("Found %s\n", em28xx_boards[dev->model].name);
2238 2260
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 82781178e0a3..5956e9b3062f 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -102,6 +102,9 @@
102#define EM28XX_MIN_BUF 4 102#define EM28XX_MIN_BUF 4
103#define EM28XX_DEF_BUF 8 103#define EM28XX_DEF_BUF 8
104 104
105/*Limits the max URB message size */
106#define URB_MAX_CTRL_SIZE 80
107
105/* Params for validated field */ 108/* Params for validated field */
106#define EM28XX_BOARD_NOT_VALIDATED 1 109#define EM28XX_BOARD_NOT_VALIDATED 1
107#define EM28XX_BOARD_VALIDATED 0 110#define EM28XX_BOARD_VALIDATED 0
@@ -430,6 +433,7 @@ struct em28xx {
430 433
431 /* locks */ 434 /* locks */
432 struct mutex lock; 435 struct mutex lock;
436 struct mutex ctrl_urb_lock; /* protects urb_buf */
433 /* spinlock_t queue_lock; */ 437 /* spinlock_t queue_lock; */
434 struct list_head inqueue, outqueue; 438 struct list_head inqueue, outqueue;
435 wait_queue_head_t open, wait_frame, wait_stream; 439 wait_queue_head_t open, wait_frame, wait_stream;
@@ -451,6 +455,8 @@ struct em28xx {
451 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 455 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
452 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ 456 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
453 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ 457 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
458 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
459
454 /* helper funcs that call usb_control_msg */ 460 /* helper funcs that call usb_control_msg */
455 int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, 461 int (*em28xx_write_regs) (struct em28xx *dev, u16 reg,
456 char *buf, int len); 462 char *buf, int len);
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 7a85c41b0eea..9d0ef96c23ff 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -588,7 +588,7 @@ static int et61x251_stream_interrupt(struct et61x251_device* cam)
588 cam->state |= DEV_MISCONFIGURED; 588 cam->state |= DEV_MISCONFIGURED;
589 DBG(1, "URB timeout reached. The camera is misconfigured. To " 589 DBG(1, "URB timeout reached. The camera is misconfigured. To "
590 "use it, close and open /dev/video%d again.", 590 "use it, close and open /dev/video%d again.",
591 cam->v4ldev->minor); 591 cam->v4ldev->num);
592 return -EIO; 592 return -EIO;
593 } 593 }
594 594
@@ -1195,7 +1195,7 @@ static void et61x251_release_resources(struct kref *kref)
1195 1195
1196 cam = container_of(kref, struct et61x251_device, kref); 1196 cam = container_of(kref, struct et61x251_device, kref);
1197 1197
1198 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); 1198 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
1199 video_set_drvdata(cam->v4ldev, NULL); 1199 video_set_drvdata(cam->v4ldev, NULL);
1200 video_unregister_device(cam->v4ldev); 1200 video_unregister_device(cam->v4ldev);
1201 usb_put_dev(cam->usbdev); 1201 usb_put_dev(cam->usbdev);
@@ -1237,7 +1237,7 @@ static int et61x251_open(struct inode* inode, struct file* filp)
1237 1237
1238 if (cam->users) { 1238 if (cam->users) {
1239 DBG(2, "Device /dev/video%d is already in use", 1239 DBG(2, "Device /dev/video%d is already in use",
1240 cam->v4ldev->minor); 1240 cam->v4ldev->num);
1241 DBG(3, "Simultaneous opens are not supported"); 1241 DBG(3, "Simultaneous opens are not supported");
1242 if ((filp->f_flags & O_NONBLOCK) || 1242 if ((filp->f_flags & O_NONBLOCK) ||
1243 (filp->f_flags & O_NDELAY)) { 1243 (filp->f_flags & O_NDELAY)) {
@@ -1280,7 +1280,7 @@ static int et61x251_open(struct inode* inode, struct file* filp)
1280 cam->frame_count = 0; 1280 cam->frame_count = 0;
1281 et61x251_empty_framequeues(cam); 1281 et61x251_empty_framequeues(cam);
1282 1282
1283 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); 1283 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
1284 1284
1285out: 1285out:
1286 mutex_unlock(&cam->open_mutex); 1286 mutex_unlock(&cam->open_mutex);
@@ -1304,7 +1304,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1304 cam->users--; 1304 cam->users--;
1305 wake_up_interruptible_nr(&cam->wait_open, 1); 1305 wake_up_interruptible_nr(&cam->wait_open, 1);
1306 1306
1307 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); 1307 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
1308 1308
1309 kref_put(&cam->kref, et61x251_release_resources); 1309 kref_put(&cam->kref, et61x251_release_resources);
1310 1310
@@ -1845,7 +1845,7 @@ et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg)
1845 cam->state |= DEV_MISCONFIGURED; 1845 cam->state |= DEV_MISCONFIGURED;
1846 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To " 1846 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
1847 "use the camera, close and open /dev/video%d again.", 1847 "use the camera, close and open /dev/video%d again.",
1848 cam->v4ldev->minor); 1848 cam->v4ldev->num);
1849 return -EIO; 1849 return -EIO;
1850 } 1850 }
1851 1851
@@ -1858,7 +1858,7 @@ et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg)
1858 cam->state |= DEV_MISCONFIGURED; 1858 cam->state |= DEV_MISCONFIGURED;
1859 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To " 1859 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
1860 "use the camera, close and open /dev/video%d again.", 1860 "use the camera, close and open /dev/video%d again.",
1861 cam->v4ldev->minor); 1861 cam->v4ldev->num);
1862 return -ENOMEM; 1862 return -ENOMEM;
1863 } 1863 }
1864 1864
@@ -2068,7 +2068,7 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
2068 cam->state |= DEV_MISCONFIGURED; 2068 cam->state |= DEV_MISCONFIGURED;
2069 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To " 2069 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
2070 "use the camera, close and open /dev/video%d again.", 2070 "use the camera, close and open /dev/video%d again.",
2071 cam->v4ldev->minor); 2071 cam->v4ldev->num);
2072 return -EIO; 2072 return -EIO;
2073 } 2073 }
2074 2074
@@ -2080,7 +2080,7 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
2080 cam->state |= DEV_MISCONFIGURED; 2080 cam->state |= DEV_MISCONFIGURED;
2081 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To " 2081 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
2082 "use the camera, close and open /dev/video%d again.", 2082 "use the camera, close and open /dev/video%d again.",
2083 cam->v4ldev->minor); 2083 cam->v4ldev->num);
2084 return -ENOMEM; 2084 return -ENOMEM;
2085 } 2085 }
2086 2086
@@ -2128,7 +2128,7 @@ et61x251_vidioc_s_jpegcomp(struct et61x251_device* cam, void __user * arg)
2128 cam->state |= DEV_MISCONFIGURED; 2128 cam->state |= DEV_MISCONFIGURED;
2129 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware " 2129 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
2130 "problems. To use the camera, close and open " 2130 "problems. To use the camera, close and open "
2131 "/dev/video%d again.", cam->v4ldev->minor); 2131 "/dev/video%d again.", cam->v4ldev->num);
2132 return -EIO; 2132 return -EIO;
2133 } 2133 }
2134 2134
@@ -2605,7 +2605,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2605 goto fail; 2605 goto fail;
2606 } 2606 }
2607 2607
2608 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); 2608 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
2609 2609
2610 cam->module_param.force_munmap = force_munmap[dev_nr]; 2610 cam->module_param.force_munmap = force_munmap[dev_nr];
2611 cam->module_param.frame_timeout = frame_timeout[dev_nr]; 2611 cam->module_param.frame_timeout = frame_timeout[dev_nr];
@@ -2658,7 +2658,7 @@ static void et61x251_usb_disconnect(struct usb_interface* intf)
2658 if (cam->users) { 2658 if (cam->users) {
2659 DBG(2, "Device /dev/video%d is open! Deregistration and " 2659 DBG(2, "Device /dev/video%d is open! Deregistration and "
2660 "memory deallocation are deferred.", 2660 "memory deallocation are deferred.",
2661 cam->v4ldev->minor); 2661 cam->v4ldev->num);
2662 cam->state |= DEV_MISCONFIGURED; 2662 cam->state |= DEV_MISCONFIGURED;
2663 et61x251_stop_transfer(cam); 2663 et61x251_stop_transfer(cam);
2664 cam->state |= DEV_DISCONNECTED; 2664 cam->state |= DEV_DISCONNECTED;
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig
index 4d0817471c9f..6b557c057fac 100644
--- a/drivers/media/video/gspca/Kconfig
+++ b/drivers/media/video/gspca/Kconfig
@@ -3,16 +3,16 @@ menuconfig USB_GSPCA
3 depends on VIDEO_V4L2 3 depends on VIDEO_V4L2
4 default m 4 default m
5 ---help--- 5 ---help---
6 Say Y here if you want to enable selecting webcams based 6 Say Y here if you want to enable selecting webcams based
7 on the GSPCA framework. 7 on the GSPCA framework.
8 8
9 See <file:Documentation/video4linux/gspca.txt> for more info. 9 See <file:Documentation/video4linux/gspca.txt> for more info.
10 10
11 This driver uses the Video For Linux API. You must say Y or M to 11 This driver uses the Video For Linux API. You must say Y or M to
12 "Video For Linux" to use this driver. 12 "Video For Linux" to use this driver.
13 13
14 To compile this driver as modules, choose M here: the 14 To compile this driver as modules, choose M here: the
15 modules will be called gspca_main. 15 modules will be called gspca_main.
16 16
17 17
18if USB_GSPCA && VIDEO_V4L2 18if USB_GSPCA && VIDEO_V4L2
@@ -23,190 +23,190 @@ config USB_GSPCA_CONEX
23 tristate "Conexant Camera Driver" 23 tristate "Conexant Camera Driver"
24 depends on VIDEO_V4L2 && USB_GSPCA 24 depends on VIDEO_V4L2 && USB_GSPCA
25 help 25 help
26 Say Y here if you want support for cameras based on the Conexant chip. 26 Say Y here if you want support for cameras based on the Conexant chip.
27 27
28 To compile this driver as a module, choose M here: the 28 To compile this driver as a module, choose M here: the
29 module will be called gspca_conex. 29 module will be called gspca_conex.
30 30
31config USB_GSPCA_ETOMS 31config USB_GSPCA_ETOMS
32 tristate "Etoms USB Camera Driver" 32 tristate "Etoms USB Camera Driver"
33 depends on VIDEO_V4L2 && USB_GSPCA 33 depends on VIDEO_V4L2 && USB_GSPCA
34 help 34 help
35 Say Y here if you want support for cameras based on the Etoms chip. 35 Say Y here if you want support for cameras based on the Etoms chip.
36 36
37 To compile this driver as a module, choose M here: the 37 To compile this driver as a module, choose M here: the
38 module will be called gspca_etoms. 38 module will be called gspca_etoms.
39 39
40config USB_GSPCA_FINEPIX 40config USB_GSPCA_FINEPIX
41 tristate "Fujifilm FinePix USB V4L2 driver" 41 tristate "Fujifilm FinePix USB V4L2 driver"
42 depends on VIDEO_V4L2 && USB_GSPCA 42 depends on VIDEO_V4L2 && USB_GSPCA
43 help 43 help
44 Say Y here if you want support for cameras based on the FinePix chip. 44 Say Y here if you want support for cameras based on the FinePix chip.
45 45
46 To compile this driver as a module, choose M here: the 46 To compile this driver as a module, choose M here: the
47 module will be called gspca_finepix. 47 module will be called gspca_finepix.
48 48
49config USB_GSPCA_MARS 49config USB_GSPCA_MARS
50 tristate "Mars USB Camera Driver" 50 tristate "Mars USB Camera Driver"
51 depends on VIDEO_V4L2 && USB_GSPCA 51 depends on VIDEO_V4L2 && USB_GSPCA
52 help 52 help
53 Say Y here if you want support for cameras based on the Mars chip. 53 Say Y here if you want support for cameras based on the Mars chip.
54 54
55 To compile this driver as a module, choose M here: the 55 To compile this driver as a module, choose M here: the
56 module will be called gspca_mars. 56 module will be called gspca_mars.
57 57
58config USB_GSPCA_OV519 58config USB_GSPCA_OV519
59 tristate "OV519 USB Camera Driver" 59 tristate "OV519 USB Camera Driver"
60 depends on VIDEO_V4L2 && USB_GSPCA 60 depends on VIDEO_V4L2 && USB_GSPCA
61 help 61 help
62 Say Y here if you want support for cameras based on the OV519 chip. 62 Say Y here if you want support for cameras based on the OV519 chip.
63 63
64 To compile this driver as a module, choose M here: the 64 To compile this driver as a module, choose M here: the
65 module will be called gspca_ov519. 65 module will be called gspca_ov519.
66 66
67config USB_GSPCA_PAC207 67config USB_GSPCA_PAC207
68 tristate "Pixart PAC207 USB Camera Driver" 68 tristate "Pixart PAC207 USB Camera Driver"
69 depends on VIDEO_V4L2 && USB_GSPCA 69 depends on VIDEO_V4L2 && USB_GSPCA
70 help 70 help
71 Say Y here if you want support for cameras based on the PAC207 chip. 71 Say Y here if you want support for cameras based on the PAC207 chip.
72 72
73 To compile this driver as a module, choose M here: the 73 To compile this driver as a module, choose M here: the
74 module will be called gspca_pac207. 74 module will be called gspca_pac207.
75 75
76config USB_GSPCA_PAC7311 76config USB_GSPCA_PAC7311
77 tristate "Pixart PAC7311 USB Camera Driver" 77 tristate "Pixart PAC7311 USB Camera Driver"
78 depends on VIDEO_V4L2 && USB_GSPCA 78 depends on VIDEO_V4L2 && USB_GSPCA
79 help 79 help
80 Say Y here if you want support for cameras based on the PAC7311 chip. 80 Say Y here if you want support for cameras based on the PAC7311 chip.
81 81
82 To compile this driver as a module, choose M here: the 82 To compile this driver as a module, choose M here: the
83 module will be called gspca_pac7311. 83 module will be called gspca_pac7311.
84 84
85config USB_GSPCA_SONIXB 85config USB_GSPCA_SONIXB
86 tristate "SN9C102 USB Camera Driver" 86 tristate "SN9C102 USB Camera Driver"
87 depends on VIDEO_V4L2 && USB_GSPCA 87 depends on VIDEO_V4L2 && USB_GSPCA
88 help 88 help
89 Say Y here if you want support for cameras based on the SONIXB chip. 89 Say Y here if you want support for cameras based on the SONIXB chip.
90 90
91 To compile this driver as a module, choose M here: the 91 To compile this driver as a module, choose M here: the
92 module will be called gspca_sonixb. 92 module will be called gspca_sonixb.
93 93
94config USB_GSPCA_SONIXJ 94config USB_GSPCA_SONIXJ
95 tristate "SONIX JPEG USB Camera Driver" 95 tristate "SONIX JPEG USB Camera Driver"
96 depends on VIDEO_V4L2 && USB_GSPCA 96 depends on VIDEO_V4L2 && USB_GSPCA
97 help 97 help
98 Say Y here if you want support for cameras based on the SONIXJ chip. 98 Say Y here if you want support for cameras based on the SONIXJ chip.
99 99
100 To compile this driver as a module, choose M here: the 100 To compile this driver as a module, choose M here: the
101 module will be called gspca_sonixj 101 module will be called gspca_sonixj
102 102
103config USB_GSPCA_SPCA500 103config USB_GSPCA_SPCA500
104 tristate "SPCA500 USB Camera Driver" 104 tristate "SPCA500 USB Camera Driver"
105 depends on VIDEO_V4L2 && USB_GSPCA 105 depends on VIDEO_V4L2 && USB_GSPCA
106 help 106 help
107 Say Y here if you want support for cameras based on the SPCA500 chip. 107 Say Y here if you want support for cameras based on the SPCA500 chip.
108 108
109 To compile this driver as a module, choose M here: the 109 To compile this driver as a module, choose M here: the
110 module will be called gspca_spca500. 110 module will be called gspca_spca500.
111 111
112config USB_GSPCA_SPCA501 112config USB_GSPCA_SPCA501
113 tristate "SPCA501 USB Camera Driver" 113 tristate "SPCA501 USB Camera Driver"
114 depends on VIDEO_V4L2 && USB_GSPCA 114 depends on VIDEO_V4L2 && USB_GSPCA
115 help 115 help
116 Say Y here if you want support for cameras based on the SPCA501 chip. 116 Say Y here if you want support for cameras based on the SPCA501 chip.
117 117
118 To compile this driver as a module, choose M here: the 118 To compile this driver as a module, choose M here: the
119 module will be called gspca_spca501. 119 module will be called gspca_spca501.
120 120
121config USB_GSPCA_SPCA505 121config USB_GSPCA_SPCA505
122 tristate "SPCA505 USB Camera Driver" 122 tristate "SPCA505 USB Camera Driver"
123 depends on VIDEO_V4L2 && USB_GSPCA 123 depends on VIDEO_V4L2 && USB_GSPCA
124 help 124 help
125 Say Y here if you want support for cameras based on the SPCA505 chip. 125 Say Y here if you want support for cameras based on the SPCA505 chip.
126 126
127 To compile this driver as a module, choose M here: the 127 To compile this driver as a module, choose M here: the
128 module will be called gspca_spca505. 128 module will be called gspca_spca505.
129 129
130config USB_GSPCA_SPCA506 130config USB_GSPCA_SPCA506
131 tristate "SPCA506 USB Camera Driver" 131 tristate "SPCA506 USB Camera Driver"
132 depends on VIDEO_V4L2 && USB_GSPCA 132 depends on VIDEO_V4L2 && USB_GSPCA
133 help 133 help
134 Say Y here if you want support for cameras based on the SPCA506 chip. 134 Say Y here if you want support for cameras based on the SPCA506 chip.
135 135
136 To compile this driver as a module, choose M here: the 136 To compile this driver as a module, choose M here: the
137 module will be called gspca_spca506. 137 module will be called gspca_spca506.
138 138
139config USB_GSPCA_SPCA508 139config USB_GSPCA_SPCA508
140 tristate "SPCA508 USB Camera Driver" 140 tristate "SPCA508 USB Camera Driver"
141 depends on VIDEO_V4L2 && USB_GSPCA 141 depends on VIDEO_V4L2 && USB_GSPCA
142 help 142 help
143 Say Y here if you want support for cameras based on the SPCA508 chip. 143 Say Y here if you want support for cameras based on the SPCA508 chip.
144 144
145 To compile this driver as a module, choose M here: the 145 To compile this driver as a module, choose M here: the
146 module will be called gspca_spca508. 146 module will be called gspca_spca508.
147 147
148config USB_GSPCA_SPCA561 148config USB_GSPCA_SPCA561
149 tristate "SPCA561 USB Camera Driver" 149 tristate "SPCA561 USB Camera Driver"
150 depends on VIDEO_V4L2 && USB_GSPCA 150 depends on VIDEO_V4L2 && USB_GSPCA
151 help 151 help
152 Say Y here if you want support for cameras based on the SPCA561 chip. 152 Say Y here if you want support for cameras based on the SPCA561 chip.
153 153
154 To compile this driver as a module, choose M here: the 154 To compile this driver as a module, choose M here: the
155 module will be called gspca_spca561. 155 module will be called gspca_spca561.
156 156
157config USB_GSPCA_STK014 157config USB_GSPCA_STK014
158 tristate "Syntek DV4000 (STK014) USB Camera Driver" 158 tristate "Syntek DV4000 (STK014) USB Camera Driver"
159 depends on VIDEO_V4L2 && USB_GSPCA 159 depends on VIDEO_V4L2 && USB_GSPCA
160 help 160 help
161 Say Y here if you want support for cameras based on the STK014 chip. 161 Say Y here if you want support for cameras based on the STK014 chip.
162 162
163 To compile this driver as a module, choose M here: the 163 To compile this driver as a module, choose M here: the
164 module will be called gspca_stk014. 164 module will be called gspca_stk014.
165 165
166config USB_GSPCA_SUNPLUS 166config USB_GSPCA_SUNPLUS
167 tristate "SUNPLUS USB Camera Driver" 167 tristate "SUNPLUS USB Camera Driver"
168 depends on VIDEO_V4L2 && USB_GSPCA 168 depends on VIDEO_V4L2 && USB_GSPCA
169 help 169 help
170 Say Y here if you want support for cameras based on the Sunplus 170 Say Y here if you want support for cameras based on the Sunplus
171 SPCA504(abc) SPCA533 SPCA536 chips. 171 SPCA504(abc) SPCA533 SPCA536 chips.
172 172
173 To compile this driver as a module, choose M here: the 173 To compile this driver as a module, choose M here: the
174 module will be called gspca_spca5xx. 174 module will be called gspca_spca5xx.
175 175
176config USB_GSPCA_T613 176config USB_GSPCA_T613
177 tristate "T613 (JPEG Compliance) USB Camera Driver" 177 tristate "T613 (JPEG Compliance) USB Camera Driver"
178 depends on VIDEO_V4L2 && USB_GSPCA 178 depends on VIDEO_V4L2 && USB_GSPCA
179 help 179 help
180 Say Y here if you want support for cameras based on the T613 chip. 180 Say Y here if you want support for cameras based on the T613 chip.
181 181
182 To compile this driver as a module, choose M here: the 182 To compile this driver as a module, choose M here: the
183 module will be called gspca_t613. 183 module will be called gspca_t613.
184 184
185config USB_GSPCA_TV8532 185config USB_GSPCA_TV8532
186 tristate "TV8532 USB Camera Driver" 186 tristate "TV8532 USB Camera Driver"
187 depends on VIDEO_V4L2 && USB_GSPCA 187 depends on VIDEO_V4L2 && USB_GSPCA
188 help 188 help
189 Say Y here if you want support for cameras based on the TV8531 chip. 189 Say Y here if you want support for cameras based on the TV8531 chip.
190 190
191 To compile this driver as a module, choose M here: the 191 To compile this driver as a module, choose M here: the
192 module will be called gspca_tv8532. 192 module will be called gspca_tv8532.
193 193
194config USB_GSPCA_VC032X 194config USB_GSPCA_VC032X
195 tristate "VC032X USB Camera Driver" 195 tristate "VC032X USB Camera Driver"
196 depends on VIDEO_V4L2 && USB_GSPCA 196 depends on VIDEO_V4L2 && USB_GSPCA
197 help 197 help
198 Say Y here if you want support for cameras based on the VC032X chip. 198 Say Y here if you want support for cameras based on the VC032X chip.
199 199
200 To compile this driver as a module, choose M here: the 200 To compile this driver as a module, choose M here: the
201 module will be called gspca_vc032x. 201 module will be called gspca_vc032x.
202 202
203config USB_GSPCA_ZC3XX 203config USB_GSPCA_ZC3XX
204 tristate "VC3xx USB Camera Driver" 204 tristate "ZC3XX USB Camera Driver"
205 depends on VIDEO_V4L2 && USB_GSPCA 205 depends on VIDEO_V4L2 && USB_GSPCA
206 help 206 help
207 Say Y here if you want support for cameras based on the ZC3XX chip. 207 Say Y here if you want support for cameras based on the ZC3XX chip.
208 208
209 To compile this driver as a module, choose M here: the 209 To compile this driver as a module, choose M here: the
210 module will be called gspca_zc3xx. 210 module will be called gspca_zc3xx.
211 211
212endif 212endif
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index a9d51ba7c57c..de28354ea5ba 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -846,10 +846,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
846 return 0; 846 return 0;
847} 847}
848 848
849/* called on streamoff with alt 0 and on disconnect */
849static void sd_stop0(struct gspca_dev *gspca_dev) 850static void sd_stop0(struct gspca_dev *gspca_dev)
850{ 851{
851 int retry = 50; 852 int retry = 50;
852 853
854 if (!gspca_dev->present)
855 return;
853 reg_w_val(gspca_dev, 0x0000, 0x00); 856 reg_w_val(gspca_dev, 0x0000, 0x00);
854 reg_r(gspca_dev, 0x0002, 1); 857 reg_r(gspca_dev, 0x0002, 1);
855 reg_w_val(gspca_dev, 0x0053, 0x00); 858 reg_w_val(gspca_dev, 0x0053, 0x00);
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 65d3cbfe6b27..607942fd7970 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -276,6 +276,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
276 /* Stop the state machine */ 276 /* Stop the state machine */
277 if (dev->state != FPIX_NOP) 277 if (dev->state != FPIX_NOP)
278 wait_for_completion(&dev->can_close); 278 wait_for_completion(&dev->can_close);
279}
280
281/* called on streamoff with alt 0 and disconnect */
282static void sd_stop0(struct gspca_dev *gspca_dev)
283{
284 struct usb_fpix *dev = (struct usb_fpix *) gspca_dev;
279 285
280 usb_free_urb(dev->control_urb); 286 usb_free_urb(dev->control_urb);
281 dev->control_urb = NULL; 287 dev->control_urb = NULL;
@@ -385,6 +391,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
385error: 391error:
386 /* Free the ressources */ 392 /* Free the ressources */
387 sd_stopN(gspca_dev); 393 sd_stopN(gspca_dev);
394 sd_stop0(gspca_dev);
388 return ret; 395 return ret;
389} 396}
390 397
@@ -425,6 +432,7 @@ static const struct sd_desc sd_desc = {
425 .init = sd_init, 432 .init = sd_init,
426 .start = sd_start, 433 .start = sd_start,
427 .stopN = sd_stopN, 434 .stopN = sd_stopN,
435 .stop0 = sd_stop0,
428}; 436};
429 437
430/* -- device connect -- */ 438/* -- device connect -- */
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index e48fbfc8ad05..748a87e82e44 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -646,15 +646,14 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev)
646{ 646{
647 gspca_dev->streaming = 0; 647 gspca_dev->streaming = 0;
648 atomic_set(&gspca_dev->nevent, 0); 648 atomic_set(&gspca_dev->nevent, 0);
649 if (gspca_dev->present) { 649 if (gspca_dev->present
650 if (gspca_dev->sd_desc->stopN) 650 && gspca_dev->sd_desc->stopN)
651 gspca_dev->sd_desc->stopN(gspca_dev); 651 gspca_dev->sd_desc->stopN(gspca_dev);
652 destroy_urbs(gspca_dev); 652 destroy_urbs(gspca_dev);
653 gspca_set_alt0(gspca_dev); 653 gspca_set_alt0(gspca_dev);
654 if (gspca_dev->sd_desc->stop0) 654 if (gspca_dev->sd_desc->stop0)
655 gspca_dev->sd_desc->stop0(gspca_dev); 655 gspca_dev->sd_desc->stop0(gspca_dev);
656 PDEBUG(D_STREAM, "stream off OK"); 656 PDEBUG(D_STREAM, "stream off OK");
657 }
658} 657}
659 658
660static void gspca_set_default_mode(struct gspca_dev *gspca_dev) 659static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
@@ -863,7 +862,7 @@ static int dev_open(struct inode *inode, struct file *file)
863 int ret; 862 int ret;
864 863
865 PDEBUG(D_STREAM, "%s open", current->comm); 864 PDEBUG(D_STREAM, "%s open", current->comm);
866 gspca_dev = (struct gspca_dev *) video_devdata(file); 865 gspca_dev = video_drvdata(file);
867 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 866 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
868 return -ERESTARTSYS; 867 return -ERESTARTSYS;
869 if (!gspca_dev->present) { 868 if (!gspca_dev->present) {
@@ -875,6 +874,13 @@ static int dev_open(struct inode *inode, struct file *file)
875 ret = -EBUSY; 874 ret = -EBUSY;
876 goto out; 875 goto out;
877 } 876 }
877
878 /* protect the subdriver against rmmod */
879 if (!try_module_get(gspca_dev->module)) {
880 ret = -ENODEV;
881 goto out;
882 }
883
878 gspca_dev->users++; 884 gspca_dev->users++;
879 885
880 /* one more user */ 886 /* one more user */
@@ -884,10 +890,10 @@ static int dev_open(struct inode *inode, struct file *file)
884#ifdef GSPCA_DEBUG 890#ifdef GSPCA_DEBUG
885 /* activate the v4l2 debug */ 891 /* activate the v4l2 debug */
886 if (gspca_debug & D_V4L2) 892 if (gspca_debug & D_V4L2)
887 gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL 893 gspca_dev->vdev->debug |= V4L2_DEBUG_IOCTL
888 | V4L2_DEBUG_IOCTL_ARG; 894 | V4L2_DEBUG_IOCTL_ARG;
889 else 895 else
890 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL 896 gspca_dev->vdev->debug &= ~(V4L2_DEBUG_IOCTL
891 | V4L2_DEBUG_IOCTL_ARG); 897 | V4L2_DEBUG_IOCTL_ARG);
892#endif 898#endif
893 ret = 0; 899 ret = 0;
@@ -921,6 +927,7 @@ static int dev_close(struct inode *inode, struct file *file)
921 gspca_dev->memory = GSPCA_MEMORY_NO; 927 gspca_dev->memory = GSPCA_MEMORY_NO;
922 } 928 }
923 file->private_data = NULL; 929 file->private_data = NULL;
930 module_put(gspca_dev->module);
924 mutex_unlock(&gspca_dev->queue_lock); 931 mutex_unlock(&gspca_dev->queue_lock);
925 932
926 PDEBUG(D_STREAM, "close done"); 933 PDEBUG(D_STREAM, "close done");
@@ -1748,11 +1755,6 @@ out:
1748 return ret; 1755 return ret;
1749} 1756}
1750 1757
1751static void dev_release(struct video_device *vfd)
1752{
1753 /* nothing */
1754}
1755
1756static struct file_operations dev_fops = { 1758static struct file_operations dev_fops = {
1757 .owner = THIS_MODULE, 1759 .owner = THIS_MODULE,
1758 .open = dev_open, 1760 .open = dev_open,
@@ -1800,7 +1802,7 @@ static struct video_device gspca_template = {
1800 .name = "gspca main driver", 1802 .name = "gspca main driver",
1801 .fops = &dev_fops, 1803 .fops = &dev_fops,
1802 .ioctl_ops = &dev_ioctl_ops, 1804 .ioctl_ops = &dev_ioctl_ops,
1803 .release = dev_release, /* mandatory */ 1805 .release = video_device_release,
1804 .minor = -1, 1806 .minor = -1,
1805}; 1807};
1806 1808
@@ -1869,17 +1871,18 @@ int gspca_dev_probe(struct usb_interface *intf,
1869 init_waitqueue_head(&gspca_dev->wq); 1871 init_waitqueue_head(&gspca_dev->wq);
1870 1872
1871 /* init video stuff */ 1873 /* init video stuff */
1872 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); 1874 gspca_dev->vdev = video_device_alloc();
1873 gspca_dev->vdev.parent = &dev->dev; 1875 memcpy(gspca_dev->vdev, &gspca_template, sizeof gspca_template);
1874 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); 1876 gspca_dev->vdev->parent = &dev->dev;
1875 gspca_dev->vdev.fops = &gspca_dev->fops; 1877 gspca_dev->module = module;
1876 gspca_dev->fops.owner = module; /* module protection */
1877 gspca_dev->present = 1; 1878 gspca_dev->present = 1;
1878 ret = video_register_device(&gspca_dev->vdev, 1879 video_set_drvdata(gspca_dev->vdev, gspca_dev);
1880 ret = video_register_device(gspca_dev->vdev,
1879 VFL_TYPE_GRABBER, 1881 VFL_TYPE_GRABBER,
1880 video_nr); 1882 video_nr);
1881 if (ret < 0) { 1883 if (ret < 0) {
1882 err("video_register_device err %d", ret); 1884 err("video_register_device err %d", ret);
1885 video_device_release(gspca_dev->vdev);
1883 goto out; 1886 goto out;
1884 } 1887 }
1885 1888
@@ -1887,7 +1890,8 @@ int gspca_dev_probe(struct usb_interface *intf,
1887 PDEBUG(D_PROBE, "probe ok"); 1890 PDEBUG(D_PROBE, "probe ok");
1888 return 0; 1891 return 0;
1889out: 1892out:
1890 kref_put(&gspca_dev->kref, gspca_delete); 1893 kfree(gspca_dev->usb_buf);
1894 kfree(gspca_dev);
1891 return ret; 1895 return ret;
1892} 1896}
1893EXPORT_SYMBOL(gspca_dev_probe); 1897EXPORT_SYMBOL(gspca_dev_probe);
@@ -1905,7 +1909,7 @@ void gspca_disconnect(struct usb_interface *intf)
1905 usb_set_intfdata(intf, NULL); 1909 usb_set_intfdata(intf, NULL);
1906 1910
1907/* We don't want people trying to open up the device */ 1911/* We don't want people trying to open up the device */
1908 video_unregister_device(&gspca_dev->vdev); 1912 video_unregister_device(gspca_dev->vdev);
1909 1913
1910 gspca_dev->present = 0; 1914 gspca_dev->present = 0;
1911 gspca_dev->streaming = 0; 1915 gspca_dev->streaming = 0;
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 1d9dc90b4791..d25e8d69373b 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -97,7 +97,7 @@ struct sd_desc {
97 cam_pkt_op pkt_scan; 97 cam_pkt_op pkt_scan;
98/* optional operations */ 98/* optional operations */
99 cam_v_op stopN; /* called on stream off - main alt */ 99 cam_v_op stopN; /* called on stream off - main alt */
100 cam_v_op stop0; /* called on stream off - alt 0 */ 100 cam_v_op stop0; /* called on stream off & disconnect - alt 0 */
101 cam_v_op dq_callback; /* called when a frame has been dequeued */ 101 cam_v_op dq_callback; /* called when a frame has been dequeued */
102 cam_jpg_op get_jcomp; 102 cam_jpg_op get_jcomp;
103 cam_jpg_op set_jcomp; 103 cam_jpg_op set_jcomp;
@@ -120,8 +120,8 @@ struct gspca_frame {
120}; 120};
121 121
122struct gspca_dev { 122struct gspca_dev {
123 struct video_device vdev; /* !! must be the first item */ 123 struct video_device *vdev;
124 struct file_operations fops; 124 struct module *module; /* subdriver handling the device */
125 struct usb_device *dev; 125 struct usb_device *dev;
126 struct kref kref; 126 struct kref kref;
127 struct file *capt_file; /* file doing video capture */ 127 struct file *capt_file; /* file doing video capture */
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index e5ff9a6199ef..fbd45e235d97 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -749,10 +749,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ 749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
750} 750}
751 751
752/* called on streamoff with alt 0 and on disconnect */
752static void sd_stop0(struct gspca_dev *gspca_dev) 753static void sd_stop0(struct gspca_dev *gspca_dev)
753{ 754{
754 struct sd *sd = (struct sd *) gspca_dev; 755 struct sd *sd = (struct sd *) gspca_dev;
755 756
757 if (!gspca_dev->present)
758 return;
756 if (sd->sensor == SENSOR_PAC7302) { 759 if (sd->sensor == SENSOR_PAC7302) {
757 reg_w(gspca_dev, 0xff, 0x01); 760 reg_w(gspca_dev, 0xff, 0x01);
758 reg_w(gspca_dev, 0x78, 0x40); 761 reg_w(gspca_dev, 0x78, 0x40);
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index b742f260c7ca..e29954c1c38c 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -2022,8 +2022,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); 2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00);
2023} 2023}
2024 2024
2025/* called on streamoff with alt 0 and on disconnect */
2025static void sd_stop0(struct gspca_dev *gspca_dev) 2026static void sd_stop0(struct gspca_dev *gspca_dev)
2026{ 2027{
2028 if (!gspca_dev->present)
2029 return;
2027 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); 2030 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00);
2028} 2031}
2029 2032
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index b345749213cf..895b9fe4018c 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -742,8 +742,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); 742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
743} 743}
744 744
745/* called on streamoff with alt 0 and on disconnect */
745static void sd_stop0(struct gspca_dev *gspca_dev) 746static void sd_stop0(struct gspca_dev *gspca_dev)
746{ 747{
748 if (!gspca_dev->present)
749 return;
750
747 /* This maybe reset or power control */ 751 /* This maybe reset or power control */
748 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); 752 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20);
749 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); 753 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0);
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 020a03c466c1..c3de4e44123d 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -766,10 +766,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
766 } 766 }
767} 767}
768 768
769/* called on streamoff with alt 0 and on disconnect */
769static void sd_stop0(struct gspca_dev *gspca_dev) 770static void sd_stop0(struct gspca_dev *gspca_dev)
770{ 771{
771 struct sd *sd = (struct sd *) gspca_dev; 772 struct sd *sd = (struct sd *) gspca_dev;
772 773
774 if (!gspca_dev->present)
775 return;
773 if (sd->chip_revision == Rev012A) { 776 if (sd->chip_revision == Rev012A) {
774 reg_w_val(gspca_dev->dev, 0x8118, 0x29); 777 reg_w_val(gspca_dev->dev, 0x8118, 0x29);
775 reg_w_val(gspca_dev->dev, 0x8114, 0x08); 778 reg_w_val(gspca_dev->dev, 0x8114, 0x08);
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index be46d9232540..17af353ddd1c 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -1633,10 +1633,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1633 reg_w(dev, 0xa0, 0x09, 0xb003); 1633 reg_w(dev, 0xa0, 0x09, 0xb003);
1634} 1634}
1635 1635
1636/* called on streamoff with alt 0 and on disconnect */
1636static void sd_stop0(struct gspca_dev *gspca_dev) 1637static void sd_stop0(struct gspca_dev *gspca_dev)
1637{ 1638{
1638 struct usb_device *dev = gspca_dev->dev; 1639 struct usb_device *dev = gspca_dev->dev;
1639 1640
1641 if (!gspca_dev->present)
1642 return;
1640 reg_w(dev, 0x89, 0xffff, 0xffff); 1643 reg_w(dev, 0x89, 0xffff, 0xffff);
1641} 1644}
1642 1645
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index d0a4451dc46f..0befacf49855 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -2266,7 +2266,7 @@ static const struct usb_action hdcs2020b_NoFliker[] = {
2266 {} 2266 {}
2267}; 2267};
2268 2268
2269static const struct usb_action hv7131bxx_Initial[] = { 2269static const struct usb_action hv7131bxx_Initial[] = { /* 320x240 */
2270 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, 2270 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
2271 {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, 2271 {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
2272 {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT}, 2272 {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -2290,7 +2290,7 @@ static const struct usb_action hv7131bxx_Initial[] = {
2290 {0xaa, 0x14, 0x0001}, 2290 {0xaa, 0x14, 0x0001},
2291 {0xaa, 0x15, 0x00e8}, 2291 {0xaa, 0x15, 0x00e8},
2292 {0xaa, 0x16, 0x0002}, 2292 {0xaa, 0x16, 0x0002},
2293 {0xaa, 0x17, 0x0086}, 2293 {0xaa, 0x17, 0x0086}, /* 00,17,88,aa */
2294 {0xaa, 0x31, 0x0038}, 2294 {0xaa, 0x31, 0x0038},
2295 {0xaa, 0x32, 0x0038}, 2295 {0xaa, 0x32, 0x0038},
2296 {0xaa, 0x33, 0x0038}, 2296 {0xaa, 0x33, 0x0038},
@@ -2309,7 +2309,7 @@ static const struct usb_action hv7131bxx_Initial[] = {
2309 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05}, 2309 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
2310 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, 2310 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
2311 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, 2311 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
2312 {0xaa, 0x02, 0x0080}, /* {0xaa, 0x02, 0x0090}; */ 2312 {0xaa, 0x02, 0x0090}, /* 00,02,80,aa */
2313 {0xa1, 0x01, 0x0002}, 2313 {0xa1, 0x01, 0x0002},
2314 {0xa0, 0x00, ZC3XX_R092_I2CADDRESSSELECT}, 2314 {0xa0, 0x00, ZC3XX_R092_I2CADDRESSSELECT},
2315 {0xa0, 0x02, ZC3XX_R090_I2CCOMMAND}, 2315 {0xa0, 0x02, ZC3XX_R090_I2CCOMMAND},
@@ -2374,7 +2374,7 @@ static const struct usb_action hv7131bxx_Initial[] = {
2374 {} 2374 {}
2375}; 2375};
2376 2376
2377static const struct usb_action hv7131bxx_InitialScale[] = { 2377static const struct usb_action hv7131bxx_InitialScale[] = { /* 640x480*/
2378 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, 2378 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
2379 {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT}, 2379 {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
2380 {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT}, 2380 {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -6388,6 +6388,8 @@ static void setbrightness(struct gspca_dev *gspca_dev)
6388/*fixme: is it really write to 011d and 018d for all other sensors? */ 6388/*fixme: is it really write to 011d and 018d for all other sensors? */
6389 brightness = sd->brightness; 6389 brightness = sd->brightness;
6390 reg_w(gspca_dev->dev, brightness, 0x011d); 6390 reg_w(gspca_dev->dev, brightness, 0x011d);
6391 if (sd->sensor == SENSOR_HV7131B)
6392 return;
6391 if (brightness < 0x70) 6393 if (brightness < 0x70)
6392 brightness += 0x10; 6394 brightness += 0x10;
6393 else 6395 else
@@ -6529,6 +6531,7 @@ static void setquality(struct gspca_dev *gspca_dev)
6529 6531
6530 switch (sd->sensor) { 6532 switch (sd->sensor) {
6531 case SENSOR_GC0305: 6533 case SENSOR_GC0305:
6534 case SENSOR_HV7131B:
6532 case SENSOR_OV7620: 6535 case SENSOR_OV7620:
6533 case SENSOR_PO2030: 6536 case SENSOR_PO2030:
6534 return; 6537 return;
@@ -7209,7 +7212,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
7209 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 7212 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
7210 zc3_init = init_tb[(int) sd->sensor][mode]; 7213 zc3_init = init_tb[(int) sd->sensor][mode];
7211 switch (sd->sensor) { 7214 switch (sd->sensor) {
7212 case SENSOR_HV7131B:
7213 case SENSOR_HV7131C: 7215 case SENSOR_HV7131C:
7214 zcxx_probeSensor(gspca_dev); 7216 zcxx_probeSensor(gspca_dev);
7215 break; 7217 break;
@@ -7334,10 +7336,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
7334 return 0; 7336 return 0;
7335} 7337}
7336 7338
7339/* called on streamoff with alt 0 and on disconnect */
7337static void sd_stop0(struct gspca_dev *gspca_dev) 7340static void sd_stop0(struct gspca_dev *gspca_dev)
7338{ 7341{
7339 struct sd *sd = (struct sd *) gspca_dev; 7342 struct sd *sd = (struct sd *) gspca_dev;
7340 7343
7344 if (!gspca_dev->present)
7345 return;
7341 send_unknown(gspca_dev->dev, sd->sensor); 7346 send_unknown(gspca_dev->dev, sd->sensor);
7342} 7347}
7343 7348
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index 0069898bddab..c46bfb1569e3 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && PCI && I2C
4 depends on INPUT # due to VIDEO_IR 4 depends on INPUT # due to VIDEO_IR
5 select I2C_ALGOBIT 5 select I2C_ALGOBIT
6 select VIDEO_IR 6 select VIDEO_IR
@@ -12,7 +12,6 @@ config VIDEO_IVTV
12 select VIDEO_SAA711X 12 select VIDEO_SAA711X
13 select VIDEO_SAA717X 13 select VIDEO_SAA717X
14 select VIDEO_SAA7127 14 select VIDEO_SAA7127
15 select VIDEO_TVAUDIO
16 select VIDEO_CS53L32A 15 select VIDEO_CS53L32A
17 select VIDEO_M52790 16 select VIDEO_M52790
18 select VIDEO_WM8775 17 select VIDEO_WM8775
@@ -32,7 +31,7 @@ config VIDEO_IVTV
32 31
33config VIDEO_FB_IVTV 32config VIDEO_FB_IVTV
34 tristate "Conexant cx23415 framebuffer support" 33 tristate "Conexant cx23415 framebuffer support"
35 depends on VIDEO_IVTV && FB && EXPERIMENTAL 34 depends on VIDEO_IVTV && FB
36 select FB_CFB_FILLRECT 35 select FB_CFB_FILLRECT
37 select FB_CFB_COPYAREA 36 select FB_CFB_COPYAREA
38 select FB_CFB_IMAGEBLIT 37 select FB_CFB_IMAGEBLIT
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index aeaa13f6cb36..b69cc1d55e5b 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -875,43 +875,43 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
875 875
876#ifdef MODULE 876#ifdef MODULE
877 /* load modules */ 877 /* load modules */
878#ifndef CONFIG_MEDIA_TUNER 878#ifdef CONFIG_MEDIA_TUNER_MODULE
879 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); 879 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
880#endif 880#endif
881#ifndef CONFIG_VIDEO_CX25840 881#ifdef CONFIG_VIDEO_CX25840_MODULE
882 hw = ivtv_request_module(itv, hw, "cx25840", IVTV_HW_CX25840); 882 hw = ivtv_request_module(itv, hw, "cx25840", IVTV_HW_CX25840);
883#endif 883#endif
884#ifndef CONFIG_VIDEO_SAA711X 884#ifdef CONFIG_VIDEO_SAA711X_MODULE
885 hw = ivtv_request_module(itv, hw, "saa7115", IVTV_HW_SAA711X); 885 hw = ivtv_request_module(itv, hw, "saa7115", IVTV_HW_SAA711X);
886#endif 886#endif
887#ifndef CONFIG_VIDEO_SAA7127 887#ifdef CONFIG_VIDEO_SAA7127_MODULE
888 hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127); 888 hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127);
889#endif 889#endif
890#ifndef CONFIG_VIDEO_SAA717X 890#ifdef CONFIG_VIDEO_SAA717X_MODULE
891 hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X); 891 hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X);
892#endif 892#endif
893#ifndef CONFIG_VIDEO_UPD64031A 893#ifdef CONFIG_VIDEO_UPD64031A_MODULE
894 hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A); 894 hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A);
895#endif 895#endif
896#ifndef CONFIG_VIDEO_UPD64083 896#ifdef CONFIG_VIDEO_UPD64083_MODULE
897 hw = ivtv_request_module(itv, hw, "upd64083", IVTV_HW_UPD6408X); 897 hw = ivtv_request_module(itv, hw, "upd64083", IVTV_HW_UPD6408X);
898#endif 898#endif
899#ifndef CONFIG_VIDEO_MSP3400 899#ifdef CONFIG_VIDEO_MSP3400_MODULE
900 hw = ivtv_request_module(itv, hw, "msp3400", IVTV_HW_MSP34XX); 900 hw = ivtv_request_module(itv, hw, "msp3400", IVTV_HW_MSP34XX);
901#endif 901#endif
902#ifndef CONFIG_VIDEO_VP27SMPX 902#ifdef CONFIG_VIDEO_VP27SMPX_MODULE
903 hw = ivtv_request_module(itv, hw, "vp27smpx", IVTV_HW_VP27SMPX); 903 hw = ivtv_request_module(itv, hw, "vp27smpx", IVTV_HW_VP27SMPX);
904#endif 904#endif
905#ifndef CONFIG_VIDEO_WM8775 905#ifdef CONFIG_VIDEO_WM8775_MODULE
906 hw = ivtv_request_module(itv, hw, "wm8775", IVTV_HW_WM8775); 906 hw = ivtv_request_module(itv, hw, "wm8775", IVTV_HW_WM8775);
907#endif 907#endif
908#ifndef CONFIG_VIDEO_WM8739 908#ifdef CONFIG_VIDEO_WM8739_MODULE
909 hw = ivtv_request_module(itv, hw, "wm8739", IVTV_HW_WM8739); 909 hw = ivtv_request_module(itv, hw, "wm8739", IVTV_HW_WM8739);
910#endif 910#endif
911#ifndef CONFIG_VIDEO_CS53L32A 911#ifdef CONFIG_VIDEO_CS53L32A_MODULE
912 hw = ivtv_request_module(itv, hw, "cs53l32a", IVTV_HW_CS53L32A); 912 hw = ivtv_request_module(itv, hw, "cs53l32a", IVTV_HW_CS53L32A);
913#endif 913#endif
914#ifndef CONFIG_VIDEO_M52790 914#ifdef CONFIG_VIDEO_M52790_MODULE
915 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); 915 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
916#endif 916#endif
917#endif 917#endif
@@ -1211,6 +1211,10 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1211 1211
1212 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { 1212 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1213 ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std); 1213 ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std);
1214 /* Turn off the output signal. The mpeg decoder is not yet
1215 active so without this you would get a green image until the
1216 mpeg decoder becomes active. */
1217 ivtv_saa7127(itv, VIDIOC_STREAMOFF, NULL);
1214 } 1218 }
1215 1219
1216 /* clear interrupt mask, effectively disabling interrupts */ 1220 /* clear interrupt mask, effectively disabling interrupts */
@@ -1330,6 +1334,10 @@ int ivtv_init_on_first_open(struct ivtv *itv)
1330 ivtv_s_frequency(NULL, &fh, &vf); 1334 ivtv_s_frequency(NULL, &fh, &vf);
1331 1335
1332 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { 1336 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
1337 /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes
1338 the mpeg decoder so now the saa7127 receives a proper
1339 signal. */
1340 ivtv_saa7127(itv, VIDIOC_STREAMON, NULL);
1333 ivtv_init_mpeg_decoder(itv); 1341 ivtv_init_mpeg_decoder(itv);
1334 } 1342 }
1335 ivtv_s_std(NULL, &fh, &itv->tuner_std); 1343 ivtv_s_std(NULL, &fh, &itv->tuner_std);
@@ -1366,6 +1374,10 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1366 1374
1367 /* Stop all decoding */ 1375 /* Stop all decoding */
1368 IVTV_DEBUG_INFO("Stopping decoding\n"); 1376 IVTV_DEBUG_INFO("Stopping decoding\n");
1377
1378 /* Turn off the TV-out */
1379 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
1380 ivtv_saa7127(itv, VIDIOC_STREAMOFF, NULL);
1369 if (atomic_read(&itv->decoding) > 0) { 1381 if (atomic_read(&itv->decoding) > 0) {
1370 int type; 1382 int type;
1371 1383
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 24700c211d52..41dbbe9621a1 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -726,6 +726,7 @@ int ivtv_saa7127(struct ivtv *itv, unsigned int cmd, void *arg)
726{ 726{
727 return ivtv_call_i2c_client(itv, IVTV_SAA7127_I2C_ADDR, cmd, arg); 727 return ivtv_call_i2c_client(itv, IVTV_SAA7127_I2C_ADDR, cmd, arg);
728} 728}
729EXPORT_SYMBOL(ivtv_saa7127);
729 730
730int ivtv_saa717x(struct ivtv *itv, unsigned int cmd, void *arg) 731int ivtv_saa717x(struct ivtv *itv, unsigned int cmd, void *arg)
731{ 732{
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 208fb54842f2..4bae38d21ef6 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1756,12 +1756,12 @@ static int ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1756 return 0; 1756 return 0;
1757} 1757}
1758 1758
1759static int ivtv_serialized_ioctl(struct ivtv *itv, struct inode *inode, struct file *filp, 1759static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
1760 unsigned int cmd, unsigned long arg) 1760 unsigned int cmd, unsigned long arg)
1761{ 1761{
1762 struct video_device *vfd = video_devdata(filp); 1762 struct video_device *vfd = video_devdata(filp);
1763 struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; 1763 struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
1764 int ret; 1764 long ret;
1765 1765
1766 /* Filter dvb ioctls that cannot be handled by the v4l ioctl framework */ 1766 /* Filter dvb ioctls that cannot be handled by the v4l ioctl framework */
1767 switch (cmd) { 1767 switch (cmd) {
@@ -1830,20 +1830,19 @@ static int ivtv_serialized_ioctl(struct ivtv *itv, struct inode *inode, struct f
1830 1830
1831 if (ivtv_debug & IVTV_DBGFLG_IOCTL) 1831 if (ivtv_debug & IVTV_DBGFLG_IOCTL)
1832 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; 1832 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
1833 ret = video_ioctl2(inode, filp, cmd, arg); 1833 ret = __video_ioctl2(filp, cmd, arg);
1834 vfd->debug = 0; 1834 vfd->debug = 0;
1835 return ret; 1835 return ret;
1836} 1836}
1837 1837
1838int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 1838long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1839 unsigned long arg)
1840{ 1839{
1841 struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; 1840 struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
1842 struct ivtv *itv = id->itv; 1841 struct ivtv *itv = id->itv;
1843 int res; 1842 long res;
1844 1843
1845 mutex_lock(&itv->serialize_lock); 1844 mutex_lock(&itv->serialize_lock);
1846 res = ivtv_serialized_ioctl(itv, inode, filp, cmd, arg); 1845 res = ivtv_serialized_ioctl(itv, filp, cmd, arg);
1847 mutex_unlock(&itv->serialize_lock); 1846 mutex_unlock(&itv->serialize_lock);
1848 return res; 1847 return res;
1849} 1848}
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h
index 70188588b4f4..58f003412afd 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.h
+++ b/drivers/media/video/ivtv/ivtv-ioctl.h
@@ -30,7 +30,6 @@ void ivtv_set_funcs(struct video_device *vdev);
30int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std); 30int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std);
31int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); 31int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
32int ivtv_s_input(struct file *file, void *fh, unsigned int inp); 32int ivtv_s_input(struct file *file, void *fh, unsigned int inp);
33int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 33long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
34 unsigned long arg);
35 34
36#endif 35#endif
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 5bbf31e39304..9b7aa79eb267 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -48,7 +48,7 @@ static const struct file_operations ivtv_v4l2_enc_fops = {
48 .read = ivtv_v4l2_read, 48 .read = ivtv_v4l2_read,
49 .write = ivtv_v4l2_write, 49 .write = ivtv_v4l2_write,
50 .open = ivtv_v4l2_open, 50 .open = ivtv_v4l2_open,
51 .ioctl = ivtv_v4l2_ioctl, 51 .unlocked_ioctl = ivtv_v4l2_ioctl,
52 .compat_ioctl = v4l_compat_ioctl32, 52 .compat_ioctl = v4l_compat_ioctl32,
53 .release = ivtv_v4l2_close, 53 .release = ivtv_v4l2_close,
54 .poll = ivtv_v4l2_enc_poll, 54 .poll = ivtv_v4l2_enc_poll,
@@ -59,7 +59,7 @@ static const struct file_operations ivtv_v4l2_dec_fops = {
59 .read = ivtv_v4l2_read, 59 .read = ivtv_v4l2_read,
60 .write = ivtv_v4l2_write, 60 .write = ivtv_v4l2_write,
61 .open = ivtv_v4l2_open, 61 .open = ivtv_v4l2_open,
62 .ioctl = ivtv_v4l2_ioctl, 62 .unlocked_ioctl = ivtv_v4l2_ioctl,
63 .compat_ioctl = v4l_compat_ioctl32, 63 .compat_ioctl = v4l_compat_ioctl32,
64 .release = ivtv_v4l2_close, 64 .release = ivtv_v4l2_close,
65 .poll = ivtv_v4l2_dec_poll, 65 .poll = ivtv_v4l2_dec_poll,
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index 8a4a150b12fb..921e281876f8 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -48,6 +48,7 @@
48#endif 48#endif
49 49
50#include "ivtv-driver.h" 50#include "ivtv-driver.h"
51#include "ivtv-i2c.h"
51#include "ivtv-udma.h" 52#include "ivtv-udma.h"
52#include "ivtv-mailbox.h" 53#include "ivtv-mailbox.h"
53 54
@@ -894,11 +895,16 @@ static int ivtvfb_blank(int blank_mode, struct fb_info *info)
894 switch (blank_mode) { 895 switch (blank_mode) {
895 case FB_BLANK_UNBLANK: 896 case FB_BLANK_UNBLANK:
896 ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, 1); 897 ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, 1);
898 ivtv_saa7127(itv, VIDIOC_STREAMON, NULL);
897 break; 899 break;
898 case FB_BLANK_NORMAL: 900 case FB_BLANK_NORMAL:
899 case FB_BLANK_HSYNC_SUSPEND: 901 case FB_BLANK_HSYNC_SUSPEND:
900 case FB_BLANK_VSYNC_SUSPEND: 902 case FB_BLANK_VSYNC_SUSPEND:
903 ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, 0);
904 ivtv_saa7127(itv, VIDIOC_STREAMON, NULL);
905 break;
901 case FB_BLANK_POWERDOWN: 906 case FB_BLANK_POWERDOWN:
907 ivtv_saa7127(itv, VIDIOC_STREAMOFF, NULL);
902 ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, 0); 908 ivtv_vapi(itv, CX2341X_OSD_SET_STATE, 1, 0);
903 break; 909 break;
904 } 910 }
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index a1252d673b41..273d2a1aa220 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -402,6 +402,10 @@ static int pvr2_encoder_prep_config(struct pvr2_hdw *hdw)
402 ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 0,3,0,0); 402 ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 0,3,0,0);
403 ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4,15,0,0,0); 403 ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4,15,0,0,0);
404 404
405 /* prevent the PTSs from slowly drifting away in the generated
406 MPEG stream */
407 ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC, 2, 4, 1);
408
405 return ret; 409 return ret;
406} 410}
407 411
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 94265bd3d926..5b81ba469641 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -60,7 +60,6 @@ static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
60static DEFINE_MUTEX(pvr2_unit_mtx); 60static DEFINE_MUTEX(pvr2_unit_mtx);
61 61
62static int ctlchg; 62static int ctlchg;
63static int initusbreset = 1;
64static int procreload; 63static int procreload;
65static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 }; 64static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 };
66static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 }; 65static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
@@ -71,8 +70,6 @@ module_param(ctlchg, int, S_IRUGO|S_IWUSR);
71MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value"); 70MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value");
72module_param(init_pause_msec, int, S_IRUGO|S_IWUSR); 71module_param(init_pause_msec, int, S_IRUGO|S_IWUSR);
73MODULE_PARM_DESC(init_pause_msec, "hardware initialization settling delay"); 72MODULE_PARM_DESC(init_pause_msec, "hardware initialization settling delay");
74module_param(initusbreset, int, S_IRUGO|S_IWUSR);
75MODULE_PARM_DESC(initusbreset, "Do USB reset device on probe");
76module_param(procreload, int, S_IRUGO|S_IWUSR); 73module_param(procreload, int, S_IRUGO|S_IWUSR);
77MODULE_PARM_DESC(procreload, 74MODULE_PARM_DESC(procreload,
78 "Attempt init failure recovery with firmware reload"); 75 "Attempt init failure recovery with firmware reload");
@@ -1967,9 +1964,6 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1967 } 1964 }
1968 hdw->fw1_state = FW1_STATE_OK; 1965 hdw->fw1_state = FW1_STATE_OK;
1969 1966
1970 if (initusbreset) {
1971 pvr2_hdw_device_reset(hdw);
1972 }
1973 if (!pvr2_hdw_dev_ok(hdw)) return; 1967 if (!pvr2_hdw_dev_ok(hdw)) return;
1974 1968
1975 for (idx = 0; idx < hdw->hdw_desc->client_modules.cnt; idx++) { 1969 for (idx = 0; idx < hdw->hdw_desc->client_modules.cnt; idx++) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index f048d80b77e5..97ed95957992 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -168,7 +168,7 @@ static const char *get_v4l_name(int v4l_type)
168 * This is part of Video 4 Linux API. The procedure handles ioctl() calls. 168 * This is part of Video 4 Linux API. The procedure handles ioctl() calls.
169 * 169 *
170 */ 170 */
171static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, 171static int __pvr2_v4l2_do_ioctl(struct file *file,
172 unsigned int cmd, void *arg) 172 unsigned int cmd, void *arg)
173{ 173{
174 struct pvr2_v4l2_fh *fh = file->private_data; 174 struct pvr2_v4l2_fh *fh = file->private_data;
@@ -863,8 +863,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
863#endif 863#endif
864 864
865 default : 865 default :
866 ret = v4l_compat_translate_ioctl(inode,file,cmd, 866 ret = v4l_compat_translate_ioctl(file, cmd,
867 arg,pvr2_v4l2_do_ioctl); 867 arg, __pvr2_v4l2_do_ioctl);
868 } 868 }
869 869
870 pvr2_hdw_commit_ctl(hdw); 870 pvr2_hdw_commit_ctl(hdw);
@@ -890,10 +890,15 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
890 return ret; 890 return ret;
891} 891}
892 892
893static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
894 unsigned int cmd, void *arg)
895{
896 return __pvr2_v4l2_do_ioctl(file, cmd, arg);
897}
893 898
894static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip) 899static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
895{ 900{
896 int minor_id = dip->devbase.minor; 901 int num = dip->devbase.num;
897 struct pvr2_hdw *hdw = dip->v4lp->channel.mc_head->hdw; 902 struct pvr2_hdw *hdw = dip->v4lp->channel.mc_head->hdw;
898 enum pvr2_config cfg = dip->config; 903 enum pvr2_config cfg = dip->config;
899 int v4l_type = dip->v4l_type; 904 int v4l_type = dip->v4l_type;
@@ -909,7 +914,7 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
909 video_unregister_device(&dip->devbase); 914 video_unregister_device(&dip->devbase);
910 915
911 printk(KERN_INFO "pvrusb2: unregistered device %s%u [%s]\n", 916 printk(KERN_INFO "pvrusb2: unregistered device %s%u [%s]\n",
912 get_v4l_name(v4l_type),minor_id & 0x1f, 917 get_v4l_name(v4l_type), num,
913 pvr2_config_get_name(cfg)); 918 pvr2_config_get_name(cfg));
914 919
915} 920}
@@ -1310,7 +1315,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1310 } 1315 }
1311 1316
1312 printk(KERN_INFO "pvrusb2: registered device %s%u [%s]\n", 1317 printk(KERN_INFO "pvrusb2: registered device %s%u [%s]\n",
1313 get_v4l_name(dip->v4l_type),dip->devbase.minor & 0x1f, 1318 get_v4l_name(dip->v4l_type), dip->devbase.num,
1314 pvr2_config_get_name(dip->config)); 1319 pvr2_config_get_name(dip->config));
1315 1320
1316 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 1321 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index ab28389b4cda..f3897a3fdb75 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1795,7 +1795,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1795 goto err; 1795 goto err;
1796 } 1796 }
1797 else { 1797 else {
1798 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); 1798 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->num);
1799 } 1799 }
1800 1800
1801 /* occupy slot */ 1801 /* occupy slot */
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 5272926db73e..3c3f8cf73108 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -192,7 +192,7 @@ struct s2255_dmaqueue {
192#define S2255_FW_FAILED 3 192#define S2255_FW_FAILED 3
193#define S2255_FW_DISCONNECTING 4 193#define S2255_FW_DISCONNECTING 4
194 194
195#define S2255_FW_MARKER 0x22552f2f 195#define S2255_FW_MARKER cpu_to_le32(0x22552f2f)
196/* 2255 read states */ 196/* 2255 read states */
197#define S2255_READ_IDLE 0 197#define S2255_READ_IDLE 0
198#define S2255_READ_FRAME 1 198#define S2255_READ_FRAME 1
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index adf2ba79496a..37860698f782 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -47,7 +47,7 @@ module_param(debug, int, 0);
47MODULE_PARM_DESC(debug, "Debug level (0-1)"); 47MODULE_PARM_DESC(debug, "Debug level (0-1)");
48 48
49#define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ 49#define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */
50#define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ 50#define SAA7110_MAX_OUTPUT 1 /* 1 YUV */
51 51
52#define SAA7110_NR_REG 0x35 52#define SAA7110_NR_REG 0x35
53 53
@@ -327,7 +327,7 @@ saa7110_command (struct i2c_client *client,
327 327
328 case DECODER_SET_INPUT: 328 case DECODER_SET_INPUT:
329 v = *(int *) arg; 329 v = *(int *) arg;
330 if (v < 0 || v > SAA7110_MAX_INPUT) { 330 if (v < 0 || v >= SAA7110_MAX_INPUT) {
331 v4l_dbg(1, debug, client, "input=%d not available\n", v); 331 v4l_dbg(1, debug, client, "input=%d not available\n", v);
332 return -EINVAL; 332 return -EINVAL;
333 } 333 }
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index b686bfabbde0..dfbe08a9ad9b 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -941,7 +941,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
941 dev->name,(unsigned long long)pci_resource_start(pci_dev,0)); 941 dev->name,(unsigned long long)pci_resource_start(pci_dev,0));
942 goto fail1; 942 goto fail1;
943 } 943 }
944 dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000); 944 dev->lmmio = ioremap(pci_resource_start(pci_dev, 0),
945 pci_resource_len(pci_dev, 0));
945 dev->bmmio = (__u8 __iomem *)dev->lmmio; 946 dev->bmmio = (__u8 __iomem *)dev->lmmio;
946 if (NULL == dev->lmmio) { 947 if (NULL == dev->lmmio) {
947 err = -EIO; 948 err = -EIO;
@@ -996,7 +997,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
996 goto fail4; 997 goto fail4;
997 } 998 }
998 printk(KERN_INFO "%s: registered device video%d [v4l2]\n", 999 printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
999 dev->name,dev->video_dev->minor & 0x1f); 1000 dev->name, dev->video_dev->num);
1000 1001
1001 dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi"); 1002 dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi");
1002 1003
@@ -1005,7 +1006,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1005 if (err < 0) 1006 if (err < 0)
1006 goto fail4; 1007 goto fail4;
1007 printk(KERN_INFO "%s: registered device vbi%d\n", 1008 printk(KERN_INFO "%s: registered device vbi%d\n",
1008 dev->name,dev->vbi_dev->minor & 0x1f); 1009 dev->name, dev->vbi_dev->num);
1009 1010
1010 if (card_has_radio(dev)) { 1011 if (card_has_radio(dev)) {
1011 dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio"); 1012 dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio");
@@ -1014,7 +1015,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1014 if (err < 0) 1015 if (err < 0)
1015 goto fail4; 1016 goto fail4;
1016 printk(KERN_INFO "%s: registered device radio%d\n", 1017 printk(KERN_INFO "%s: registered device radio%d\n",
1017 dev->name,dev->radio_dev->minor & 0x1f); 1018 dev->name, dev->radio_dev->num);
1018 } 1019 }
1019 1020
1020 /* everything worked */ 1021 /* everything worked */
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 9a8766a78a0c..7f40511bcc04 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -534,7 +534,7 @@ static int empress_init(struct saa7134_dev *dev)
534 return err; 534 return err;
535 } 535 }
536 printk(KERN_INFO "%s: registered device video%d [mpeg]\n", 536 printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
537 dev->name,dev->empress_dev->minor & 0x1f); 537 dev->name, dev->empress_dev->num);
538 538
539 videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops, 539 videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,
540 &dev->pci->dev, &dev->slock, 540 &dev->pci->dev, &dev->slock,
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index ae3949180c4e..044a2e94c34d 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -1412,7 +1412,7 @@ static int se401_probe(struct usb_interface *intf,
1412 return -EIO; 1412 return -EIO;
1413 } 1413 }
1414 dev_info(&intf->dev, "registered new video device: video%d\n", 1414 dev_info(&intf->dev, "registered new video device: video%d\n",
1415 se401->vdev.minor); 1415 se401->vdev.num);
1416 1416
1417 usb_set_intfdata (intf, se401); 1417 usb_set_intfdata (intf, se401);
1418 return 0; 1418 return 0;
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 20e30bd9364b..fcd2b62f92c4 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1008,7 +1008,7 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
1008 cam->state |= DEV_MISCONFIGURED; 1008 cam->state |= DEV_MISCONFIGURED;
1009 DBG(1, "URB timeout reached. The camera is misconfigured. " 1009 DBG(1, "URB timeout reached. The camera is misconfigured. "
1010 "To use it, close and open /dev/video%d again.", 1010 "To use it, close and open /dev/video%d again.",
1011 cam->v4ldev->minor); 1011 cam->v4ldev->num);
1012 return -EIO; 1012 return -EIO;
1013 } 1013 }
1014 1014
@@ -1734,7 +1734,7 @@ static void sn9c102_release_resources(struct kref *kref)
1734 1734
1735 cam = container_of(kref, struct sn9c102_device, kref); 1735 cam = container_of(kref, struct sn9c102_device, kref);
1736 1736
1737 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); 1737 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
1738 video_set_drvdata(cam->v4ldev, NULL); 1738 video_set_drvdata(cam->v4ldev, NULL);
1739 video_unregister_device(cam->v4ldev); 1739 video_unregister_device(cam->v4ldev);
1740 usb_put_dev(cam->usbdev); 1740 usb_put_dev(cam->usbdev);
@@ -1792,7 +1792,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1792 1792
1793 if (cam->users) { 1793 if (cam->users) {
1794 DBG(2, "Device /dev/video%d is already in use", 1794 DBG(2, "Device /dev/video%d is already in use",
1795 cam->v4ldev->minor); 1795 cam->v4ldev->num);
1796 DBG(3, "Simultaneous opens are not supported"); 1796 DBG(3, "Simultaneous opens are not supported");
1797 /* 1797 /*
1798 open() must follow the open flags and should block 1798 open() must follow the open flags and should block
@@ -1845,7 +1845,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1845 cam->frame_count = 0; 1845 cam->frame_count = 0;
1846 sn9c102_empty_framequeues(cam); 1846 sn9c102_empty_framequeues(cam);
1847 1847
1848 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); 1848 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
1849 1849
1850out: 1850out:
1851 mutex_unlock(&cam->open_mutex); 1851 mutex_unlock(&cam->open_mutex);
@@ -1870,7 +1870,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp)
1870 cam->users--; 1870 cam->users--;
1871 wake_up_interruptible_nr(&cam->wait_open, 1); 1871 wake_up_interruptible_nr(&cam->wait_open, 1);
1872 1872
1873 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); 1873 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
1874 1874
1875 kref_put(&cam->kref, sn9c102_release_resources); 1875 kref_put(&cam->kref, sn9c102_release_resources);
1876 1876
@@ -2432,7 +2432,7 @@ sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
2432 cam->state |= DEV_MISCONFIGURED; 2432 cam->state |= DEV_MISCONFIGURED;
2433 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To " 2433 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
2434 "use the camera, close and open /dev/video%d again.", 2434 "use the camera, close and open /dev/video%d again.",
2435 cam->v4ldev->minor); 2435 cam->v4ldev->num);
2436 return -EIO; 2436 return -EIO;
2437 } 2437 }
2438 2438
@@ -2445,7 +2445,7 @@ sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
2445 cam->state |= DEV_MISCONFIGURED; 2445 cam->state |= DEV_MISCONFIGURED;
2446 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To " 2446 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
2447 "use the camera, close and open /dev/video%d again.", 2447 "use the camera, close and open /dev/video%d again.",
2448 cam->v4ldev->minor); 2448 cam->v4ldev->num);
2449 return -ENOMEM; 2449 return -ENOMEM;
2450 } 2450 }
2451 2451
@@ -2689,7 +2689,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2689 cam->state |= DEV_MISCONFIGURED; 2689 cam->state |= DEV_MISCONFIGURED;
2690 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To " 2690 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
2691 "use the camera, close and open /dev/video%d again.", 2691 "use the camera, close and open /dev/video%d again.",
2692 cam->v4ldev->minor); 2692 cam->v4ldev->num);
2693 return -EIO; 2693 return -EIO;
2694 } 2694 }
2695 2695
@@ -2701,7 +2701,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2701 cam->state |= DEV_MISCONFIGURED; 2701 cam->state |= DEV_MISCONFIGURED;
2702 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To " 2702 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
2703 "use the camera, close and open /dev/video%d again.", 2703 "use the camera, close and open /dev/video%d again.",
2704 cam->v4ldev->minor); 2704 cam->v4ldev->num);
2705 return -ENOMEM; 2705 return -ENOMEM;
2706 } 2706 }
2707 2707
@@ -2748,7 +2748,7 @@ sn9c102_vidioc_s_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2748 cam->state |= DEV_MISCONFIGURED; 2748 cam->state |= DEV_MISCONFIGURED;
2749 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware " 2749 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
2750 "problems. To use the camera, close and open " 2750 "problems. To use the camera, close and open "
2751 "/dev/video%d again.", cam->v4ldev->minor); 2751 "/dev/video%d again.", cam->v4ldev->num);
2752 return -EIO; 2752 return -EIO;
2753 } 2753 }
2754 2754
@@ -3348,7 +3348,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3348 goto fail; 3348 goto fail;
3349 } 3349 }
3350 3350
3351 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); 3351 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
3352 3352
3353 video_set_drvdata(cam->v4ldev, cam); 3353 video_set_drvdata(cam->v4ldev, cam);
3354 cam->module_param.force_munmap = force_munmap[dev_nr]; 3354 cam->module_param.force_munmap = force_munmap[dev_nr];
@@ -3402,7 +3402,7 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf)
3402 if (cam->users) { 3402 if (cam->users) {
3403 DBG(2, "Device /dev/video%d is open! Deregistration and " 3403 DBG(2, "Device /dev/video%d is open! Deregistration and "
3404 "memory deallocation are deferred.", 3404 "memory deallocation are deferred.",
3405 cam->v4ldev->minor); 3405 cam->v4ldev->num);
3406 cam->state |= DEV_MISCONFIGURED; 3406 cam->state |= DEV_MISCONFIGURED;
3407 sn9c102_stop_transfer(cam); 3407 sn9c102_stop_transfer(cam);
3408 cam->state |= DEV_DISCONNECTED; 3408 cam->state |= DEV_DISCONNECTED;
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index edaea4964513..e9eb6d754d5c 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1331,7 +1331,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1331 STK_ERROR("v4l registration failed\n"); 1331 STK_ERROR("v4l registration failed\n");
1332 else 1332 else
1333 STK_INFO("Syntek USB2.0 Camera is now controlling video device" 1333 STK_INFO("Syntek USB2.0 Camera is now controlling video device"
1334 " /dev/video%d\n", dev->vdev.minor); 1334 " /dev/video%d\n", dev->vdev.num);
1335 return err; 1335 return err;
1336} 1336}
1337 1337
@@ -1426,7 +1426,7 @@ static void stk_camera_disconnect(struct usb_interface *interface)
1426 stk_remove_sysfs_files(&dev->vdev); 1426 stk_remove_sysfs_files(&dev->vdev);
1427 1427
1428 STK_INFO("Syntek USB2.0 Camera release resources " 1428 STK_INFO("Syntek USB2.0 Camera release resources "
1429 "video device /dev/video%d\n", dev->vdev.minor); 1429 "video device /dev/video%d\n", dev->vdev.num);
1430 1430
1431 video_unregister_device(&dev->vdev); 1431 video_unregister_device(&dev->vdev);
1432} 1432}
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 9c549d935994..328c41b1517d 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1470,7 +1470,8 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1470 retval = -EIO; 1470 retval = -EIO;
1471 goto error_vdev; 1471 goto error_vdev;
1472 } 1472 }
1473 PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor); 1473 PDEBUG(0, "STV(i): registered new video device: video%d",
1474 stv680->vdev->num);
1474 1475
1475 usb_set_intfdata (intf, stv680); 1476 usb_set_intfdata (intf, stv680);
1476 retval = stv680_create_sysfs_files(stv680->vdev); 1477 retval = stv680_create_sysfs_files(stv680->vdev);
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index b59e47272abf..3720f0e03a16 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * experimental driver for simple i2c audio chips. 2 * Driver for simple i2c audio chips.
3 * 3 *
4 * Copyright (c) 2000 Gerd Knorr 4 * Copyright (c) 2000 Gerd Knorr
5 * based on code by: 5 * based on code by:
@@ -7,6 +7,10 @@
7 * Steve VanDeBogart (vandebo@uclink.berkeley.edu) 7 * Steve VanDeBogart (vandebo@uclink.berkeley.edu)
8 * Greg Alexander (galexand@acm.org) 8 * Greg Alexander (galexand@acm.org)
9 * 9 *
10 * Copyright(c) 2005-2008 Mauro Carvalho Chehab
11 * - Some cleanups, code fixes, etc
12 * - Convert it to V4L2 API
13 *
10 * This code is placed under the terms of the GNU General Public License 14 * This code is placed under the terms of the GNU General Public License
11 * 15 *
12 * OPTIONS: 16 * OPTIONS:
@@ -30,6 +34,7 @@
30 34
31#include <media/tvaudio.h> 35#include <media/tvaudio.h>
32#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
33#include <media/v4l2-chip-ident.h> 38#include <media/v4l2-chip-ident.h>
34#include <media/v4l2-i2c-drv-legacy.h> 39#include <media/v4l2-i2c-drv-legacy.h>
35 40
@@ -58,7 +63,6 @@ typedef int (*checkit)(struct CHIPSTATE*);
58typedef int (*initialize)(struct CHIPSTATE*); 63typedef int (*initialize)(struct CHIPSTATE*);
59typedef int (*getmode)(struct CHIPSTATE*); 64typedef int (*getmode)(struct CHIPSTATE*);
60typedef void (*setmode)(struct CHIPSTATE*, int mode); 65typedef void (*setmode)(struct CHIPSTATE*, int mode);
61typedef void (*checkmode)(struct CHIPSTATE*);
62 66
63/* i2c command */ 67/* i2c command */
64typedef struct AUDIOCMD { 68typedef struct AUDIOCMD {
@@ -79,6 +83,7 @@ struct CHIPDESC {
79#define CHIP_HAS_VOLUME 1 83#define CHIP_HAS_VOLUME 1
80#define CHIP_HAS_BASSTREBLE 2 84#define CHIP_HAS_BASSTREBLE 2
81#define CHIP_HAS_INPUTSEL 4 85#define CHIP_HAS_INPUTSEL 4
86#define CHIP_NEED_CHECKMODE 8
82 87
83 /* various i2c command sequences */ 88 /* various i2c command sequences */
84 audiocmd init; 89 audiocmd init;
@@ -96,23 +101,20 @@ struct CHIPDESC {
96 getmode getmode; 101 getmode getmode;
97 setmode setmode; 102 setmode setmode;
98 103
99 /* check / autoswitch audio after channel switches */
100 checkmode checkmode;
101
102 /* input switch register + values for v4l inputs */ 104 /* input switch register + values for v4l inputs */
103 int inputreg; 105 int inputreg;
104 int inputmap[4]; 106 int inputmap[4];
105 int inputmute; 107 int inputmute;
106 int inputmask; 108 int inputmask;
107}; 109};
108static struct CHIPDESC chiplist[];
109 110
110/* current state of the chip */ 111/* current state of the chip */
111struct CHIPSTATE { 112struct CHIPSTATE {
112 struct i2c_client *c; 113 struct i2c_client *c;
113 114
114 /* index into CHIPDESC array */ 115 /* chip-specific description - should point to
115 int type; 116 an entry at CHIPDESC table */
117 struct CHIPDESC *desc;
116 118
117 /* shadow register set */ 119 /* shadow register set */
118 audiocmd shadow; 120 audiocmd shadow;
@@ -152,7 +154,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
152{ 154{
153 unsigned char buffer[2]; 155 unsigned char buffer[2];
154 156
155 if (-1 == subaddr) { 157 if (subaddr < 0) {
156 v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", 158 v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n",
157 chip->c->name, val); 159 chip->c->name, val);
158 chip->shadow.bytes[1] = val; 160 chip->shadow.bytes[1] = val;
@@ -163,6 +165,13 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
163 return -1; 165 return -1;
164 } 166 }
165 } else { 167 } else {
168 if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
169 v4l_info(chip->c,
170 "Tried to access a non-existent register: %d\n",
171 subaddr);
172 return -EINVAL;
173 }
174
166 v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", 175 v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n",
167 chip->c->name, subaddr, val); 176 chip->c->name, subaddr, val);
168 chip->shadow.bytes[subaddr+1] = val; 177 chip->shadow.bytes[subaddr+1] = val;
@@ -177,12 +186,20 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
177 return 0; 186 return 0;
178} 187}
179 188
180static int chip_write_masked(struct CHIPSTATE *chip, int subaddr, int val, int mask) 189static int chip_write_masked(struct CHIPSTATE *chip,
190 int subaddr, int val, int mask)
181{ 191{
182 if (mask != 0) { 192 if (mask != 0) {
183 if (-1 == subaddr) { 193 if (subaddr < 0) {
184 val = (chip->shadow.bytes[1] & ~mask) | (val & mask); 194 val = (chip->shadow.bytes[1] & ~mask) | (val & mask);
185 } else { 195 } else {
196 if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
197 v4l_info(chip->c,
198 "Tried to access a non-existent register: %d\n",
199 subaddr);
200 return -EINVAL;
201 }
202
186 val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); 203 val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask);
187 } 204 }
188 } 205 }
@@ -228,6 +245,15 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
228 if (0 == cmd->count) 245 if (0 == cmd->count)
229 return 0; 246 return 0;
230 247
248 if (cmd->count + cmd->bytes[0] - 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
249 v4l_info(chip->c,
250 "Tried to access a non-existent register range: %d to %d\n",
251 cmd->bytes[0] + 1, cmd->bytes[0] + cmd->count - 1);
252 return -EINVAL;
253 }
254
255 /* FIXME: it seems that the shadow bytes are wrong bellow !*/
256
231 /* update our shadow register set; print bytes if (debug > 0) */ 257 /* update our shadow register set; print bytes if (debug > 0) */
232 v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", 258 v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:",
233 chip->c->name, name,cmd->bytes[0]); 259 chip->c->name, name,cmd->bytes[0]);
@@ -263,7 +289,8 @@ static void chip_thread_wake(unsigned long data)
263static int chip_thread(void *data) 289static int chip_thread(void *data)
264{ 290{
265 struct CHIPSTATE *chip = data; 291 struct CHIPSTATE *chip = data;
266 struct CHIPDESC *desc = chiplist + chip->type; 292 struct CHIPDESC *desc = chip->desc;
293 int mode;
267 294
268 v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); 295 v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name);
269 set_freezable(); 296 set_freezable();
@@ -282,7 +309,26 @@ static int chip_thread(void *data)
282 continue; 309 continue;
283 310
284 /* have a look what's going on */ 311 /* have a look what's going on */
285 desc->checkmode(chip); 312 mode = desc->getmode(chip);
313 if (mode == chip->prevmode)
314 continue;
315
316 /* chip detected a new audio mode - set it */
317 v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n",
318 chip->c->name);
319
320 chip->prevmode = mode;
321
322 if (mode & V4L2_TUNER_MODE_STEREO)
323 desc->setmode(chip, V4L2_TUNER_MODE_STEREO);
324 if (mode & V4L2_TUNER_MODE_LANG1_LANG2)
325 desc->setmode(chip, V4L2_TUNER_MODE_STEREO);
326 else if (mode & V4L2_TUNER_MODE_LANG1)
327 desc->setmode(chip, V4L2_TUNER_MODE_LANG1);
328 else if (mode & V4L2_TUNER_MODE_LANG2)
329 desc->setmode(chip, V4L2_TUNER_MODE_LANG2);
330 else
331 desc->setmode(chip, V4L2_TUNER_MODE_MONO);
286 332
287 /* schedule next check */ 333 /* schedule next check */
288 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 334 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
@@ -292,29 +338,6 @@ static int chip_thread(void *data)
292 return 0; 338 return 0;
293} 339}
294 340
295static void generic_checkmode(struct CHIPSTATE *chip)
296{
297 struct CHIPDESC *desc = chiplist + chip->type;
298 int mode = desc->getmode(chip);
299
300 if (mode == chip->prevmode)
301 return;
302
303 v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", chip->c->name);
304 chip->prevmode = mode;
305
306 if (mode & V4L2_TUNER_MODE_STEREO)
307 desc->setmode(chip,V4L2_TUNER_MODE_STEREO);
308 if (mode & V4L2_TUNER_MODE_LANG1_LANG2)
309 desc->setmode(chip,V4L2_TUNER_MODE_STEREO);
310 else if (mode & V4L2_TUNER_MODE_LANG1)
311 desc->setmode(chip,V4L2_TUNER_MODE_LANG1);
312 else if (mode & V4L2_TUNER_MODE_LANG2)
313 desc->setmode(chip,V4L2_TUNER_MODE_LANG2);
314 else
315 desc->setmode(chip,V4L2_TUNER_MODE_MONO);
316}
317
318/* ---------------------------------------------------------------------- */ 341/* ---------------------------------------------------------------------- */
319/* audio chip descriptions - defines+functions for tda9840 */ 342/* audio chip descriptions - defines+functions for tda9840 */
320 343
@@ -777,7 +800,7 @@ static struct tda9874a_MODES {
777 char *name; 800 char *name;
778 audiocmd cmd; 801 audiocmd cmd;
779} tda9874a_modelist[9] = { 802} tda9874a_modelist[9] = {
780 { "A2, B/G", 803 { "A2, B/G", /* default */
781 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, 804 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} },
782 { "A2, M (Korea)", 805 { "A2, M (Korea)",
783 { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, 806 { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} },
@@ -791,7 +814,7 @@ static struct tda9874a_MODES {
791 { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, 814 { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} },
792 { "NICAM, B/G", 815 { "NICAM, B/G",
793 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, 816 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} },
794 { "NICAM, D/K", /* default */ 817 { "NICAM, D/K",
795 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, 818 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} },
796 { "NICAM, L", 819 { "NICAM, L",
797 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } 820 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} }
@@ -981,7 +1004,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip)
981{ 1004{
982 if (tda9874a_SIF > 2) 1005 if (tda9874a_SIF > 2)
983 tda9874a_SIF = 1; 1006 tda9874a_SIF = 1;
984 if (tda9874a_STD > 8) 1007 if (tda9874a_STD >= ARRAY_SIZE(tda9874a_modelist))
985 tda9874a_STD = 0; 1008 tda9874a_STD = 0;
986 if(tda9874a_AMSEL > 1) 1009 if(tda9874a_AMSEL > 1)
987 tda9874a_AMSEL = 0; 1010 tda9874a_AMSEL = 0;
@@ -1089,7 +1112,7 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; }
1089 1112
1090static int tda8425_initialize(struct CHIPSTATE *chip) 1113static int tda8425_initialize(struct CHIPSTATE *chip)
1091{ 1114{
1092 struct CHIPDESC *desc = chiplist + chip->type; 1115 struct CHIPDESC *desc = chip->desc;
1093 int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, 1116 int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
1094 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; 1117 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF};
1095 1118
@@ -1259,27 +1282,28 @@ static struct CHIPDESC chiplist[] = {
1259 .addr_lo = I2C_ADDR_TDA9840 >> 1, 1282 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1260 .addr_hi = I2C_ADDR_TDA9840 >> 1, 1283 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1261 .registers = 5, 1284 .registers = 5,
1285 .flags = CHIP_NEED_CHECKMODE,
1262 1286
1287 /* callbacks */
1263 .checkit = tda9840_checkit, 1288 .checkit = tda9840_checkit,
1264 .getmode = tda9840_getmode, 1289 .getmode = tda9840_getmode,
1265 .setmode = tda9840_setmode, 1290 .setmode = tda9840_setmode,
1266 .checkmode = generic_checkmode,
1267 1291
1268 .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN 1292 .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN
1269 /* ,TDA9840_SW, TDA9840_MONO */} } 1293 /* ,TDA9840_SW, TDA9840_MONO */} }
1270 }, 1294 },
1271 { 1295 {
1272 .name = "tda9873h", 1296 .name = "tda9873h",
1273 .checkit = tda9873_checkit,
1274 .insmodopt = &tda9873, 1297 .insmodopt = &tda9873,
1275 .addr_lo = I2C_ADDR_TDA985x_L >> 1, 1298 .addr_lo = I2C_ADDR_TDA985x_L >> 1,
1276 .addr_hi = I2C_ADDR_TDA985x_H >> 1, 1299 .addr_hi = I2C_ADDR_TDA985x_H >> 1,
1277 .registers = 3, 1300 .registers = 3,
1278 .flags = CHIP_HAS_INPUTSEL, 1301 .flags = CHIP_HAS_INPUTSEL | CHIP_NEED_CHECKMODE,
1279 1302
1303 /* callbacks */
1304 .checkit = tda9873_checkit,
1280 .getmode = tda9873_getmode, 1305 .getmode = tda9873_getmode,
1281 .setmode = tda9873_setmode, 1306 .setmode = tda9873_setmode,
1282 .checkmode = generic_checkmode,
1283 1307
1284 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, 1308 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } },
1285 .inputreg = TDA9873_SW, 1309 .inputreg = TDA9873_SW,
@@ -1290,15 +1314,16 @@ static struct CHIPDESC chiplist[] = {
1290 }, 1314 },
1291 { 1315 {
1292 .name = "tda9874h/a", 1316 .name = "tda9874h/a",
1293 .checkit = tda9874a_checkit,
1294 .initialize = tda9874a_initialize,
1295 .insmodopt = &tda9874a, 1317 .insmodopt = &tda9874a,
1296 .addr_lo = I2C_ADDR_TDA9874 >> 1, 1318 .addr_lo = I2C_ADDR_TDA9874 >> 1,
1297 .addr_hi = I2C_ADDR_TDA9874 >> 1, 1319 .addr_hi = I2C_ADDR_TDA9874 >> 1,
1320 .flags = CHIP_NEED_CHECKMODE,
1298 1321
1322 /* callbacks */
1323 .initialize = tda9874a_initialize,
1324 .checkit = tda9874a_checkit,
1299 .getmode = tda9874a_getmode, 1325 .getmode = tda9874a_getmode,
1300 .setmode = tda9874a_setmode, 1326 .setmode = tda9874a_setmode,
1301 .checkmode = generic_checkmode,
1302 }, 1327 },
1303 { 1328 {
1304 .name = "tda9850", 1329 .name = "tda9850",
@@ -1324,10 +1349,11 @@ static struct CHIPDESC chiplist[] = {
1324 .rightreg = TDA9855_VR, 1349 .rightreg = TDA9855_VR,
1325 .bassreg = TDA9855_BA, 1350 .bassreg = TDA9855_BA,
1326 .treblereg = TDA9855_TR, 1351 .treblereg = TDA9855_TR,
1352
1353 /* callbacks */
1327 .volfunc = tda9855_volume, 1354 .volfunc = tda9855_volume,
1328 .bassfunc = tda9855_bass, 1355 .bassfunc = tda9855_bass,
1329 .treblefunc = tda9855_treble, 1356 .treblefunc = tda9855_treble,
1330
1331 .getmode = tda985x_getmode, 1357 .getmode = tda985x_getmode,
1332 .setmode = tda985x_setmode, 1358 .setmode = tda985x_setmode,
1333 1359
@@ -1348,6 +1374,8 @@ static struct CHIPDESC chiplist[] = {
1348 .rightreg = TEA6300_VL, 1374 .rightreg = TEA6300_VL,
1349 .bassreg = TEA6300_BA, 1375 .bassreg = TEA6300_BA,
1350 .treblereg = TEA6300_TR, 1376 .treblereg = TEA6300_TR,
1377
1378 /* callbacks */
1351 .volfunc = tea6300_shift10, 1379 .volfunc = tea6300_shift10,
1352 .bassfunc = tea6300_shift12, 1380 .bassfunc = tea6300_shift12,
1353 .treblefunc = tea6300_shift12, 1381 .treblefunc = tea6300_shift12,
@@ -1358,7 +1386,6 @@ static struct CHIPDESC chiplist[] = {
1358 }, 1386 },
1359 { 1387 {
1360 .name = "tea6320", 1388 .name = "tea6320",
1361 .initialize = tea6320_initialize,
1362 .insmodopt = &tea6320, 1389 .insmodopt = &tea6320,
1363 .addr_lo = I2C_ADDR_TEA6300 >> 1, 1390 .addr_lo = I2C_ADDR_TEA6300 >> 1,
1364 .addr_hi = I2C_ADDR_TEA6300 >> 1, 1391 .addr_hi = I2C_ADDR_TEA6300 >> 1,
@@ -1369,6 +1396,9 @@ static struct CHIPDESC chiplist[] = {
1369 .rightreg = TEA6320_V, 1396 .rightreg = TEA6320_V,
1370 .bassreg = TEA6320_BA, 1397 .bassreg = TEA6320_BA,
1371 .treblereg = TEA6320_TR, 1398 .treblereg = TEA6320_TR,
1399
1400 /* callbacks */
1401 .initialize = tea6320_initialize,
1372 .volfunc = tea6320_volume, 1402 .volfunc = tea6320_volume,
1373 .bassfunc = tea6320_shift11, 1403 .bassfunc = tea6320_shift11,
1374 .treblefunc = tea6320_shift11, 1404 .treblefunc = tea6320_shift11,
@@ -1401,16 +1431,18 @@ static struct CHIPDESC chiplist[] = {
1401 .rightreg = TDA8425_VR, 1431 .rightreg = TDA8425_VR,
1402 .bassreg = TDA8425_BA, 1432 .bassreg = TDA8425_BA,
1403 .treblereg = TDA8425_TR, 1433 .treblereg = TDA8425_TR,
1434
1435 /* callbacks */
1436 .initialize = tda8425_initialize,
1404 .volfunc = tda8425_shift10, 1437 .volfunc = tda8425_shift10,
1405 .bassfunc = tda8425_shift12, 1438 .bassfunc = tda8425_shift12,
1406 .treblefunc = tda8425_shift12, 1439 .treblefunc = tda8425_shift12,
1440 .setmode = tda8425_setmode,
1407 1441
1408 .inputreg = TDA8425_S1, 1442 .inputreg = TDA8425_S1,
1409 .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, 1443 .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 },
1410 .inputmute = TDA8425_S1_OFF, 1444 .inputmute = TDA8425_S1_OFF,
1411 1445
1412 .setmode = tda8425_setmode,
1413 .initialize = tda8425_initialize,
1414 }, 1446 },
1415 { 1447 {
1416 .name = "pic16c54 (PV951)", 1448 .name = "pic16c54 (PV951)",
@@ -1434,10 +1466,11 @@ static struct CHIPDESC chiplist[] = {
1434 .addr_lo = I2C_ADDR_TDA9840 >> 1, 1466 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1435 .addr_hi = I2C_ADDR_TDA9840 >> 1, 1467 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1436 .registers = 2, 1468 .registers = 2,
1469 .flags = CHIP_NEED_CHECKMODE,
1437 1470
1471 /* callbacks */
1438 .getmode = ta8874z_getmode, 1472 .getmode = ta8874z_getmode,
1439 .setmode = ta8874z_setmode, 1473 .setmode = ta8874z_setmode,
1440 .checkmode = generic_checkmode,
1441 1474
1442 .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, 1475 .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}},
1443 }, 1476 },
@@ -1481,6 +1514,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1481 } 1514 }
1482 if (desc->name == NULL) { 1515 if (desc->name == NULL) {
1483 v4l_dbg(1, debug, client, "no matching chip description found\n"); 1516 v4l_dbg(1, debug, client, "no matching chip description found\n");
1517 kfree(chip);
1484 return -EIO; 1518 return -EIO;
1485 } 1519 }
1486 v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); 1520 v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name);
@@ -1494,7 +1528,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1494 /* fill required data structures */ 1528 /* fill required data structures */
1495 if (!id) 1529 if (!id)
1496 strlcpy(client->name, desc->name, I2C_NAME_SIZE); 1530 strlcpy(client->name, desc->name, I2C_NAME_SIZE);
1497 chip->type = desc-chiplist; 1531 chip->desc = desc;
1498 chip->shadow.count = desc->registers+1; 1532 chip->shadow.count = desc->registers+1;
1499 chip->prevmode = -1; 1533 chip->prevmode = -1;
1500 chip->audmode = V4L2_TUNER_MODE_LANG1; 1534 chip->audmode = V4L2_TUNER_MODE_LANG1;
@@ -1506,20 +1540,49 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1506 chip_cmd(chip,"init",&desc->init); 1540 chip_cmd(chip,"init",&desc->init);
1507 1541
1508 if (desc->flags & CHIP_HAS_VOLUME) { 1542 if (desc->flags & CHIP_HAS_VOLUME) {
1509 chip->left = desc->leftinit ? desc->leftinit : 65535; 1543 if (!desc->volfunc) {
1510 chip->right = desc->rightinit ? desc->rightinit : 65535; 1544 /* This shouldn't be happen. Warn user, but keep working
1511 chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); 1545 without volume controls
1512 chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); 1546 */
1547 v4l_info(chip->c, "volume callback undefined!\n");
1548 desc->flags &= ~CHIP_HAS_VOLUME;
1549 } else {
1550 chip->left = desc->leftinit ? desc->leftinit : 65535;
1551 chip->right = desc->rightinit ? desc->rightinit : 65535;
1552 chip_write(chip, desc->leftreg,
1553 desc->volfunc(chip->left));
1554 chip_write(chip, desc->rightreg,
1555 desc->volfunc(chip->right));
1556 }
1513 } 1557 }
1514 if (desc->flags & CHIP_HAS_BASSTREBLE) { 1558 if (desc->flags & CHIP_HAS_BASSTREBLE) {
1515 chip->treble = desc->trebleinit ? desc->trebleinit : 32768; 1559 if (!desc->bassfunc || !desc->treblefunc) {
1516 chip->bass = desc->bassinit ? desc->bassinit : 32768; 1560 /* This shouldn't be happen. Warn user, but keep working
1517 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); 1561 without bass/treble controls
1518 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1562 */
1563 v4l_info(chip->c, "bass/treble callbacks undefined!\n");
1564 desc->flags &= ~CHIP_HAS_BASSTREBLE;
1565 } else {
1566 chip->treble = desc->trebleinit ?
1567 desc->trebleinit : 32768;
1568 chip->bass = desc->bassinit ?
1569 desc->bassinit : 32768;
1570 chip_write(chip, desc->bassreg,
1571 desc->bassfunc(chip->bass));
1572 chip_write(chip, desc->treblereg,
1573 desc->treblefunc(chip->treble));
1574 }
1519 } 1575 }
1520 1576
1521 chip->thread = NULL; 1577 chip->thread = NULL;
1522 if (desc->checkmode) { 1578 if (desc->flags & CHIP_NEED_CHECKMODE) {
1579 if (!desc->getmode || !desc->setmode) {
1580 /* This shouldn't be happen. Warn user, but keep working
1581 without kthread
1582 */
1583 v4l_info(chip->c, "set/get mode callbacks undefined!\n");
1584 return 0;
1585 }
1523 /* start async thread */ 1586 /* start async thread */
1524 init_timer(&chip->wt); 1587 init_timer(&chip->wt);
1525 chip->wt.function = chip_thread_wake; 1588 chip->wt.function = chip_thread_wake;
@@ -1552,7 +1615,7 @@ static int chip_remove(struct i2c_client *client)
1552static int tvaudio_get_ctrl(struct CHIPSTATE *chip, 1615static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1553 struct v4l2_control *ctrl) 1616 struct v4l2_control *ctrl)
1554{ 1617{
1555 struct CHIPDESC *desc = chiplist + chip->type; 1618 struct CHIPDESC *desc = chip->desc;
1556 1619
1557 switch (ctrl->id) { 1620 switch (ctrl->id) {
1558 case V4L2_CID_AUDIO_MUTE: 1621 case V4L2_CID_AUDIO_MUTE:
@@ -1576,13 +1639,13 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1576 return 0; 1639 return 0;
1577 } 1640 }
1578 case V4L2_CID_AUDIO_BASS: 1641 case V4L2_CID_AUDIO_BASS:
1579 if (desc->flags & CHIP_HAS_BASSTREBLE) 1642 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1580 break; 1643 break;
1581 ctrl->value = chip->bass; 1644 ctrl->value = chip->bass;
1582 return 0; 1645 return 0;
1583 case V4L2_CID_AUDIO_TREBLE: 1646 case V4L2_CID_AUDIO_TREBLE:
1584 if (desc->flags & CHIP_HAS_BASSTREBLE) 1647 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1585 return -EINVAL; 1648 break;
1586 ctrl->value = chip->treble; 1649 ctrl->value = chip->treble;
1587 return 0; 1650 return 0;
1588 } 1651 }
@@ -1592,7 +1655,7 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1592static int tvaudio_set_ctrl(struct CHIPSTATE *chip, 1655static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1593 struct v4l2_control *ctrl) 1656 struct v4l2_control *ctrl)
1594{ 1657{
1595 struct CHIPDESC *desc = chiplist + chip->type; 1658 struct CHIPDESC *desc = chip->desc;
1596 1659
1597 switch (ctrl->id) { 1660 switch (ctrl->id) {
1598 case V4L2_CID_AUDIO_MUTE: 1661 case V4L2_CID_AUDIO_MUTE:
@@ -1642,16 +1705,15 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1642 return 0; 1705 return 0;
1643 } 1706 }
1644 case V4L2_CID_AUDIO_BASS: 1707 case V4L2_CID_AUDIO_BASS:
1645 if (desc->flags & CHIP_HAS_BASSTREBLE) 1708 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1646 break; 1709 break;
1647 chip->bass = ctrl->value; 1710 chip->bass = ctrl->value;
1648 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); 1711 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass));
1649 1712
1650 return 0; 1713 return 0;
1651 case V4L2_CID_AUDIO_TREBLE: 1714 case V4L2_CID_AUDIO_TREBLE:
1652 if (desc->flags & CHIP_HAS_BASSTREBLE) 1715 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1653 return -EINVAL; 1716 break;
1654
1655 chip->treble = ctrl->value; 1717 chip->treble = ctrl->value;
1656 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1718 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble));
1657 1719
@@ -1668,9 +1730,12 @@ static int chip_command(struct i2c_client *client,
1668 unsigned int cmd, void *arg) 1730 unsigned int cmd, void *arg)
1669{ 1731{
1670 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1732 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1671 struct CHIPDESC *desc = chiplist + chip->type; 1733 struct CHIPDESC *desc = chip->desc;
1672 1734
1673 v4l_dbg(1, debug, chip->c, "%s: chip_command 0x%x\n", chip->c->name, cmd); 1735 if (debug > 0) {
1736 v4l_i2c_print_ioctl(chip->c, cmd);
1737 printk("\n");
1738 }
1674 1739
1675 switch (cmd) { 1740 switch (cmd) {
1676 case AUDC_SET_RADIO: 1741 case AUDC_SET_RADIO:
@@ -1695,7 +1760,7 @@ static int chip_command(struct i2c_client *client,
1695 break; 1760 break;
1696 case V4L2_CID_AUDIO_BASS: 1761 case V4L2_CID_AUDIO_BASS:
1697 case V4L2_CID_AUDIO_TREBLE: 1762 case V4L2_CID_AUDIO_TREBLE:
1698 if (desc->flags & CHIP_HAS_BASSTREBLE) 1763 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1699 return -EINVAL; 1764 return -EINVAL;
1700 break; 1765 break;
1701 default: 1766 default:
@@ -1792,12 +1857,20 @@ static int chip_command(struct i2c_client *client,
1792 break; 1857 break;
1793 case VIDIOC_S_FREQUENCY: 1858 case VIDIOC_S_FREQUENCY:
1794 chip->mode = 0; /* automatic */ 1859 chip->mode = 0; /* automatic */
1795 if (desc->checkmode && desc->setmode) { 1860
1861 /* For chips that provide getmode and setmode, and doesn't
1862 automatically follows the stereo carrier, a kthread is
1863 created to set the audio standard. In this case, when then
1864 the video channel is changed, tvaudio starts on MONO mode.
1865 After waiting for 2 seconds, the kernel thread is called,
1866 to follow whatever audio standard is pointed by the
1867 audio carrier.
1868 */
1869 if (chip->thread) {
1796 desc->setmode(chip,V4L2_TUNER_MODE_MONO); 1870 desc->setmode(chip,V4L2_TUNER_MODE_MONO);
1797 if (chip->prevmode != V4L2_TUNER_MODE_MONO) 1871 if (chip->prevmode != V4L2_TUNER_MODE_MONO)
1798 chip->prevmode = -1; /* reset previous mode */ 1872 chip->prevmode = -1; /* reset previous mode */
1799 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 1873 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
1800 /* the thread will call checkmode() later */
1801 } 1874 }
1802 break; 1875 break;
1803 1876
@@ -1836,9 +1909,3 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1836 .legacy_probe = chip_legacy_probe, 1909 .legacy_probe = chip_legacy_probe,
1837 .id_table = chip_id, 1910 .id_table = chip_id,
1838}; 1911};
1839
1840/*
1841 * Local variables:
1842 * c-basic-offset: 8
1843 * End:
1844 */
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c
index 28421d386f1e..c710bcd1df48 100644
--- a/drivers/media/video/usbvideo/ibmcam.c
+++ b/drivers/media/video/usbvideo/ibmcam.c
@@ -3695,7 +3695,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3695 unsigned char video_ep = 0; 3695 unsigned char video_ep = 0;
3696 3696
3697 if (debug >= 1) 3697 if (debug >= 1)
3698 dev_info(&uvd->dev->dev, "ibmcam_probe(%p,%u.)\n", intf, ifnum); 3698 dev_info(&dev->dev, "ibmcam_probe(%p,%u.)\n", intf, ifnum);
3699 3699
3700 /* We don't handle multi-config cameras */ 3700 /* We don't handle multi-config cameras */
3701 if (dev->descriptor.bNumConfigurations != 1) 3701 if (dev->descriptor.bNumConfigurations != 1)
@@ -3746,7 +3746,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3746 brand = "IBM PC Camera"; /* a.k.a. Xirlink C-It */ 3746 brand = "IBM PC Camera"; /* a.k.a. Xirlink C-It */
3747 break; 3747 break;
3748 } 3748 }
3749 dev_info(&uvd->dev->dev, 3749 dev_info(&dev->dev,
3750 "%s USB camera found (model %d, rev. 0x%04x)\n", 3750 "%s USB camera found (model %d, rev. 0x%04x)\n",
3751 brand, model, le16_to_cpu(dev->descriptor.bcdDevice)); 3751 brand, model, le16_to_cpu(dev->descriptor.bcdDevice));
3752 } while (0); 3752 } while (0);
@@ -3754,7 +3754,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3754 /* Validate found interface: must have one ISO endpoint */ 3754 /* Validate found interface: must have one ISO endpoint */
3755 nas = intf->num_altsetting; 3755 nas = intf->num_altsetting;
3756 if (debug > 0) 3756 if (debug > 0)
3757 dev_info(&uvd->dev->dev, "Number of alternate settings=%d.\n", 3757 dev_info(&dev->dev, "Number of alternate settings=%d.\n",
3758 nas); 3758 nas);
3759 if (nas < 2) { 3759 if (nas < 2) {
3760 err("Too few alternate settings for this camera!"); 3760 err("Too few alternate settings for this camera!");
@@ -3799,7 +3799,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3799 actInterface = i; 3799 actInterface = i;
3800 maxPS = le16_to_cpu(endpoint->wMaxPacketSize); 3800 maxPS = le16_to_cpu(endpoint->wMaxPacketSize);
3801 if (debug > 0) 3801 if (debug > 0)
3802 dev_info(&uvd->dev->dev, 3802 dev_info(&dev->dev,
3803 "Active setting=%d. " 3803 "Active setting=%d. "
3804 "maxPS=%d.\n", i, maxPS); 3804 "maxPS=%d.\n", i, maxPS);
3805 } else 3805 } else
@@ -3840,7 +3840,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3840 RESTRICT_TO_RANGE(framerate, 0, 5); 3840 RESTRICT_TO_RANGE(framerate, 0, 5);
3841 break; 3841 break;
3842 default: 3842 default:
3843 dev_info(&uvd->dev->dev, "IBM camera: using 320x240\n"); 3843 dev_info(&dev->dev, "IBM camera: using 320x240\n");
3844 size = SIZE_320x240; 3844 size = SIZE_320x240;
3845 /* No break here */ 3845 /* No break here */
3846 case SIZE_320x240: 3846 case SIZE_320x240:
@@ -3869,7 +3869,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3869 canvasY = 120; 3869 canvasY = 120;
3870 break; 3870 break;
3871 default: 3871 default:
3872 dev_info(&uvd->dev->dev, "IBM NetCamera: using 176x144\n"); 3872 dev_info(&dev->dev, "IBM NetCamera: using 176x144\n");
3873 size = SIZE_176x144; 3873 size = SIZE_176x144;
3874 /* No break here */ 3874 /* No break here */
3875 case SIZE_176x144: 3875 case SIZE_176x144:
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 07cd87d16f69..7c575bb8184f 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -1059,7 +1059,7 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
1059 1059
1060 dev_info(&uvd->dev->dev, "%s on /dev/video%d: canvas=%s videosize=%s\n", 1060 dev_info(&uvd->dev->dev, "%s on /dev/video%d: canvas=%s videosize=%s\n",
1061 (uvd->handle != NULL) ? uvd->handle->drvName : "???", 1061 (uvd->handle != NULL) ? uvd->handle->drvName : "???",
1062 uvd->vdev.minor, tmp2, tmp1); 1062 uvd->vdev.num, tmp2, tmp1);
1063 1063
1064 usb_get_dev(uvd->dev); 1064 usb_get_dev(uvd->dev);
1065 return 0; 1065 return 0;
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 7a127d6bfdee..8e2d58bec481 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -877,7 +877,8 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
877 return -EIO; 877 return -EIO;
878 } 878 }
879 879
880 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor); 880 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",
881 cam->vdev.num);
881 882
882 usb_set_intfdata (intf, cam); 883 usb_set_intfdata (intf, cam);
883 884
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 92427fdc1459..9907b9aff2b9 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -236,7 +236,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
236 sizeof(struct i2c_client)); 236 sizeof(struct i2c_client));
237 237
238 sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name), 238 sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name),
239 " #%d", usbvision->vdev->minor & 0x1f); 239 " #%d", usbvision->vdev->num);
240 PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name); 240 PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name);
241 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; 241 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
242 242
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 77aeb39b2750..d185b57fdcd0 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1440,7 +1440,7 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
1440 // vbi Device: 1440 // vbi Device:
1441 if (usbvision->vbi) { 1441 if (usbvision->vbi) {
1442 PDEBUG(DBG_PROBE, "unregister /dev/vbi%d [v4l2]", 1442 PDEBUG(DBG_PROBE, "unregister /dev/vbi%d [v4l2]",
1443 usbvision->vbi->minor & 0x1f); 1443 usbvision->vbi->num);
1444 if (usbvision->vbi->minor != -1) { 1444 if (usbvision->vbi->minor != -1) {
1445 video_unregister_device(usbvision->vbi); 1445 video_unregister_device(usbvision->vbi);
1446 } else { 1446 } else {
@@ -1452,7 +1452,7 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
1452 // Radio Device: 1452 // Radio Device:
1453 if (usbvision->rdev) { 1453 if (usbvision->rdev) {
1454 PDEBUG(DBG_PROBE, "unregister /dev/radio%d [v4l2]", 1454 PDEBUG(DBG_PROBE, "unregister /dev/radio%d [v4l2]",
1455 usbvision->rdev->minor & 0x1f); 1455 usbvision->rdev->num);
1456 if (usbvision->rdev->minor != -1) { 1456 if (usbvision->rdev->minor != -1) {
1457 video_unregister_device(usbvision->rdev); 1457 video_unregister_device(usbvision->rdev);
1458 } else { 1458 } else {
@@ -1464,7 +1464,7 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
1464 // Video Device: 1464 // Video Device:
1465 if (usbvision->vdev) { 1465 if (usbvision->vdev) {
1466 PDEBUG(DBG_PROBE, "unregister /dev/video%d [v4l2]", 1466 PDEBUG(DBG_PROBE, "unregister /dev/video%d [v4l2]",
1467 usbvision->vdev->minor & 0x1f); 1467 usbvision->vdev->num);
1468 if (usbvision->vdev->minor != -1) { 1468 if (usbvision->vdev->minor != -1) {
1469 video_unregister_device(usbvision->vdev); 1469 video_unregister_device(usbvision->vdev);
1470 } else { 1470 } else {
@@ -1490,7 +1490,7 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
1490 goto err_exit; 1490 goto err_exit;
1491 } 1491 }
1492 printk(KERN_INFO "USBVision[%d]: registered USBVision Video device /dev/video%d [v4l2]\n", 1492 printk(KERN_INFO "USBVision[%d]: registered USBVision Video device /dev/video%d [v4l2]\n",
1493 usbvision->nr,usbvision->vdev->minor & 0x1f); 1493 usbvision->nr, usbvision->vdev->num);
1494 1494
1495 // Radio Device: 1495 // Radio Device:
1496 if (usbvision_device_data[usbvision->DevModel].Radio) { 1496 if (usbvision_device_data[usbvision->DevModel].Radio) {
@@ -1507,7 +1507,7 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
1507 goto err_exit; 1507 goto err_exit;
1508 } 1508 }
1509 printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device /dev/radio%d [v4l2]\n", 1509 printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device /dev/radio%d [v4l2]\n",
1510 usbvision->nr, usbvision->rdev->minor & 0x1f); 1510 usbvision->nr, usbvision->rdev->num);
1511 } 1511 }
1512 // vbi Device: 1512 // vbi Device:
1513 if (usbvision_device_data[usbvision->DevModel].vbi) { 1513 if (usbvision_device_data[usbvision->DevModel].vbi) {
@@ -1523,7 +1523,7 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
1523 goto err_exit; 1523 goto err_exit;
1524 } 1524 }
1525 printk(KERN_INFO "USBVision[%d]: registered USBVision VBI device /dev/vbi%d [v4l2] (Not Working Yet!)\n", 1525 printk(KERN_INFO "USBVision[%d]: registered USBVision VBI device /dev/vbi%d [v4l2] (Not Working Yet!)\n",
1526 usbvision->nr,usbvision->vbi->minor & 0x1f); 1526 usbvision->nr, usbvision->vbi->num);
1527 } 1527 }
1528 // all done 1528 // all done
1529 return 0; 1529 return 0;
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 78e4c4e09d89..758dfefaba8d 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -464,7 +464,7 @@ static int uvc_v4l2_release(struct inode *inode, struct file *file)
464 return 0; 464 return 0;
465} 465}
466 466
467static int uvc_v4l2_do_ioctl(struct inode *inode, struct file *file, 467static int __uvc_v4l2_do_ioctl(struct file *file,
468 unsigned int cmd, void *arg) 468 unsigned int cmd, void *arg)
469{ 469{
470 struct video_device *vdev = video_devdata(file); 470 struct video_device *vdev = video_devdata(file);
@@ -978,8 +978,8 @@ static int uvc_v4l2_do_ioctl(struct inode *inode, struct file *file,
978 return uvc_xu_ctrl_query(video, arg, 1); 978 return uvc_xu_ctrl_query(video, arg, 1);
979 979
980 default: 980 default:
981 if ((ret = v4l_compat_translate_ioctl(inode, file, cmd, arg, 981 if ((ret = v4l_compat_translate_ioctl(file, cmd, arg,
982 uvc_v4l2_do_ioctl)) == -ENOIOCTLCMD) 982 __uvc_v4l2_do_ioctl)) == -ENOIOCTLCMD)
983 uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", 983 uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n",
984 cmd); 984 cmd);
985 return ret; 985 return ret;
@@ -988,6 +988,12 @@ static int uvc_v4l2_do_ioctl(struct inode *inode, struct file *file,
988 return ret; 988 return ret;
989} 989}
990 990
991static int uvc_v4l2_do_ioctl(struct inode *inode, struct file *file,
992 unsigned int cmd, void *arg)
993{
994 return __uvc_v4l2_do_ioctl(file, cmd, arg);
995}
996
991static int uvc_v4l2_ioctl(struct inode *inode, struct file *file, 997static int uvc_v4l2_ioctl(struct inode *inode, struct file *file,
992 unsigned int cmd, unsigned long arg) 998 unsigned int cmd, unsigned long arg)
993{ 999{
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 928cb4037372..f13c0a9d684f 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -57,8 +57,7 @@ MODULE_LICENSE("GPL");
57 */ 57 */
58 58
59static int 59static int
60get_v4l_control(struct inode *inode, 60get_v4l_control(struct file *file,
61 struct file *file,
62 int cid, 61 int cid,
63 v4l2_kioctl drv) 62 v4l2_kioctl drv)
64{ 63{
@@ -67,12 +66,12 @@ get_v4l_control(struct inode *inode,
67 int err; 66 int err;
68 67
69 qctrl2.id = cid; 68 qctrl2.id = cid;
70 err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); 69 err = drv(file, VIDIOC_QUERYCTRL, &qctrl2);
71 if (err < 0) 70 if (err < 0)
72 dprintk("VIDIOC_QUERYCTRL: %d\n", err); 71 dprintk("VIDIOC_QUERYCTRL: %d\n", err);
73 if (err == 0 && !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) { 72 if (err == 0 && !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) {
74 ctrl2.id = qctrl2.id; 73 ctrl2.id = qctrl2.id;
75 err = drv(inode, file, VIDIOC_G_CTRL, &ctrl2); 74 err = drv(file, VIDIOC_G_CTRL, &ctrl2);
76 if (err < 0) { 75 if (err < 0) {
77 dprintk("VIDIOC_G_CTRL: %d\n", err); 76 dprintk("VIDIOC_G_CTRL: %d\n", err);
78 return 0; 77 return 0;
@@ -85,8 +84,7 @@ get_v4l_control(struct inode *inode,
85} 84}
86 85
87static int 86static int
88set_v4l_control(struct inode *inode, 87set_v4l_control(struct file *file,
89 struct file *file,
90 int cid, 88 int cid,
91 int value, 89 int value,
92 v4l2_kioctl drv) 90 v4l2_kioctl drv)
@@ -96,7 +94,7 @@ set_v4l_control(struct inode *inode,
96 int err; 94 int err;
97 95
98 qctrl2.id = cid; 96 qctrl2.id = cid;
99 err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); 97 err = drv(file, VIDIOC_QUERYCTRL, &qctrl2);
100 if (err < 0) 98 if (err < 0)
101 dprintk("VIDIOC_QUERYCTRL: %d\n", err); 99 dprintk("VIDIOC_QUERYCTRL: %d\n", err);
102 if (err == 0 && 100 if (err == 0 &&
@@ -114,7 +112,7 @@ set_v4l_control(struct inode *inode,
114 + 32767) 112 + 32767)
115 / 65535; 113 / 65535;
116 ctrl2.value += qctrl2.minimum; 114 ctrl2.value += qctrl2.minimum;
117 err = drv(inode, file, VIDIOC_S_CTRL, &ctrl2); 115 err = drv(file, VIDIOC_S_CTRL, &ctrl2);
118 if (err < 0) 116 if (err < 0)
119 dprintk("VIDIOC_S_CTRL: %d\n", err); 117 dprintk("VIDIOC_S_CTRL: %d\n", err);
120 } 118 }
@@ -222,7 +220,6 @@ static int poll_one(struct file *file, struct poll_wqueues *pwq)
222} 220}
223 221
224static int count_inputs( 222static int count_inputs(
225 struct inode *inode,
226 struct file *file, 223 struct file *file,
227 v4l2_kioctl drv) 224 v4l2_kioctl drv)
228{ 225{
@@ -232,14 +229,13 @@ static int count_inputs(
232 for (i = 0;; i++) { 229 for (i = 0;; i++) {
233 memset(&input2, 0, sizeof(input2)); 230 memset(&input2, 0, sizeof(input2));
234 input2.index = i; 231 input2.index = i;
235 if (0 != drv(inode, file, VIDIOC_ENUMINPUT, &input2)) 232 if (0 != drv(file, VIDIOC_ENUMINPUT, &input2))
236 break; 233 break;
237 } 234 }
238 return i; 235 return i;
239} 236}
240 237
241static int check_size( 238static int check_size(
242 struct inode *inode,
243 struct file *file, 239 struct file *file,
244 v4l2_kioctl drv, 240 v4l2_kioctl drv,
245 int *maxw, 241 int *maxw,
@@ -252,14 +248,14 @@ static int check_size(
252 memset(&fmt2, 0, sizeof(fmt2)); 248 memset(&fmt2, 0, sizeof(fmt2));
253 249
254 desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 250 desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
255 if (0 != drv(inode, file, VIDIOC_ENUM_FMT, &desc2)) 251 if (0 != drv(file, VIDIOC_ENUM_FMT, &desc2))
256 goto done; 252 goto done;
257 253
258 fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 254 fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
259 fmt2.fmt.pix.width = 10000; 255 fmt2.fmt.pix.width = 10000;
260 fmt2.fmt.pix.height = 10000; 256 fmt2.fmt.pix.height = 10000;
261 fmt2.fmt.pix.pixelformat = desc2.pixelformat; 257 fmt2.fmt.pix.pixelformat = desc2.pixelformat;
262 if (0 != drv(inode, file, VIDIOC_TRY_FMT, &fmt2)) 258 if (0 != drv(file, VIDIOC_TRY_FMT, &fmt2))
263 goto done; 259 goto done;
264 260
265 *maxw = fmt2.fmt.pix.width; 261 *maxw = fmt2.fmt.pix.width;
@@ -273,7 +269,6 @@ done:
273 269
274static noinline int v4l1_compat_get_capabilities( 270static noinline int v4l1_compat_get_capabilities(
275 struct video_capability *cap, 271 struct video_capability *cap,
276 struct inode *inode,
277 struct file *file, 272 struct file *file,
278 v4l2_kioctl drv) 273 v4l2_kioctl drv)
279{ 274{
@@ -289,13 +284,13 @@ static noinline int v4l1_compat_get_capabilities(
289 memset(cap, 0, sizeof(*cap)); 284 memset(cap, 0, sizeof(*cap));
290 memset(&fbuf, 0, sizeof(fbuf)); 285 memset(&fbuf, 0, sizeof(fbuf));
291 286
292 err = drv(inode, file, VIDIOC_QUERYCAP, cap2); 287 err = drv(file, VIDIOC_QUERYCAP, cap2);
293 if (err < 0) { 288 if (err < 0) {
294 dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err); 289 dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err);
295 goto done; 290 goto done;
296 } 291 }
297 if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { 292 if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) {
298 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); 293 err = drv(file, VIDIOC_G_FBUF, &fbuf);
299 if (err < 0) { 294 if (err < 0) {
300 dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err); 295 dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err);
301 memset(&fbuf, 0, sizeof(fbuf)); 296 memset(&fbuf, 0, sizeof(fbuf));
@@ -317,8 +312,8 @@ static noinline int v4l1_compat_get_capabilities(
317 if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING) 312 if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING)
318 cap->type |= VID_TYPE_CLIPPING; 313 cap->type |= VID_TYPE_CLIPPING;
319 314
320 cap->channels = count_inputs(inode, file, drv); 315 cap->channels = count_inputs(file, drv);
321 check_size(inode, file, drv, 316 check_size(file, drv,
322 &cap->maxwidth, &cap->maxheight); 317 &cap->maxwidth, &cap->maxheight);
323 cap->audios = 0; /* FIXME */ 318 cap->audios = 0; /* FIXME */
324 cap->minwidth = 48; /* FIXME */ 319 cap->minwidth = 48; /* FIXME */
@@ -331,7 +326,6 @@ done:
331 326
332static noinline int v4l1_compat_get_frame_buffer( 327static noinline int v4l1_compat_get_frame_buffer(
333 struct video_buffer *buffer, 328 struct video_buffer *buffer,
334 struct inode *inode,
335 struct file *file, 329 struct file *file,
336 v4l2_kioctl drv) 330 v4l2_kioctl drv)
337{ 331{
@@ -341,7 +335,7 @@ static noinline int v4l1_compat_get_frame_buffer(
341 memset(buffer, 0, sizeof(*buffer)); 335 memset(buffer, 0, sizeof(*buffer));
342 memset(&fbuf, 0, sizeof(fbuf)); 336 memset(&fbuf, 0, sizeof(fbuf));
343 337
344 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); 338 err = drv(file, VIDIOC_G_FBUF, &fbuf);
345 if (err < 0) { 339 if (err < 0) {
346 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); 340 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err);
347 goto done; 341 goto done;
@@ -386,7 +380,6 @@ done:
386 380
387static noinline int v4l1_compat_set_frame_buffer( 381static noinline int v4l1_compat_set_frame_buffer(
388 struct video_buffer *buffer, 382 struct video_buffer *buffer,
389 struct inode *inode,
390 struct file *file, 383 struct file *file,
391 v4l2_kioctl drv) 384 v4l2_kioctl drv)
392{ 385{
@@ -415,7 +408,7 @@ static noinline int v4l1_compat_set_frame_buffer(
415 break; 408 break;
416 } 409 }
417 fbuf.fmt.bytesperline = buffer->bytesperline; 410 fbuf.fmt.bytesperline = buffer->bytesperline;
418 err = drv(inode, file, VIDIOC_S_FBUF, &fbuf); 411 err = drv(file, VIDIOC_S_FBUF, &fbuf);
419 if (err < 0) 412 if (err < 0)
420 dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err); 413 dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err);
421 return err; 414 return err;
@@ -423,7 +416,6 @@ static noinline int v4l1_compat_set_frame_buffer(
423 416
424static noinline int v4l1_compat_get_win_cap_dimensions( 417static noinline int v4l1_compat_get_win_cap_dimensions(
425 struct video_window *win, 418 struct video_window *win,
426 struct inode *inode,
427 struct file *file, 419 struct file *file,
428 v4l2_kioctl drv) 420 v4l2_kioctl drv)
429{ 421{
@@ -438,7 +430,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions(
438 memset(win, 0, sizeof(*win)); 430 memset(win, 0, sizeof(*win));
439 431
440 fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 432 fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
441 err = drv(inode, file, VIDIOC_G_FMT, fmt); 433 err = drv(file, VIDIOC_G_FMT, fmt);
442 if (err < 0) 434 if (err < 0)
443 dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err); 435 dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err);
444 if (err == 0) { 436 if (err == 0) {
@@ -453,7 +445,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions(
453 } 445 }
454 446
455 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 447 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
456 err = drv(inode, file, VIDIOC_G_FMT, fmt); 448 err = drv(file, VIDIOC_G_FMT, fmt);
457 if (err < 0) { 449 if (err < 0) {
458 dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err); 450 dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err);
459 goto done; 451 goto done;
@@ -472,7 +464,6 @@ done:
472 464
473static noinline int v4l1_compat_set_win_cap_dimensions( 465static noinline int v4l1_compat_set_win_cap_dimensions(
474 struct video_window *win, 466 struct video_window *win,
475 struct inode *inode,
476 struct file *file, 467 struct file *file,
477 v4l2_kioctl drv) 468 v4l2_kioctl drv)
478{ 469{
@@ -485,8 +476,8 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
485 return err; 476 return err;
486 } 477 }
487 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 478 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
488 drv(inode, file, VIDIOC_STREAMOFF, &fmt->type); 479 drv(file, VIDIOC_STREAMOFF, &fmt->type);
489 err1 = drv(inode, file, VIDIOC_G_FMT, fmt); 480 err1 = drv(file, VIDIOC_G_FMT, fmt);
490 if (err1 < 0) 481 if (err1 < 0)
491 dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1); 482 dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1);
492 if (err1 == 0) { 483 if (err1 == 0) {
@@ -494,7 +485,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
494 fmt->fmt.pix.height = win->height; 485 fmt->fmt.pix.height = win->height;
495 fmt->fmt.pix.field = V4L2_FIELD_ANY; 486 fmt->fmt.pix.field = V4L2_FIELD_ANY;
496 fmt->fmt.pix.bytesperline = 0; 487 fmt->fmt.pix.bytesperline = 0;
497 err = drv(inode, file, VIDIOC_S_FMT, fmt); 488 err = drv(file, VIDIOC_S_FMT, fmt);
498 if (err < 0) 489 if (err < 0)
499 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", 490 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n",
500 err); 491 err);
@@ -511,7 +502,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
511 fmt->fmt.win.chromakey = win->chromakey; 502 fmt->fmt.win.chromakey = win->chromakey;
512 fmt->fmt.win.clips = (void __user *)win->clips; 503 fmt->fmt.win.clips = (void __user *)win->clips;
513 fmt->fmt.win.clipcount = win->clipcount; 504 fmt->fmt.win.clipcount = win->clipcount;
514 err2 = drv(inode, file, VIDIOC_S_FMT, fmt); 505 err2 = drv(file, VIDIOC_S_FMT, fmt);
515 if (err2 < 0) 506 if (err2 < 0)
516 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2); 507 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2);
517 508
@@ -525,7 +516,6 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
525 516
526static noinline int v4l1_compat_turn_preview_on_off( 517static noinline int v4l1_compat_turn_preview_on_off(
527 int *on, 518 int *on,
528 struct inode *inode,
529 struct file *file, 519 struct file *file,
530 v4l2_kioctl drv) 520 v4l2_kioctl drv)
531{ 521{
@@ -536,9 +526,9 @@ static noinline int v4l1_compat_turn_preview_on_off(
536 /* dirty hack time. But v4l1 has no STREAMOFF 526 /* dirty hack time. But v4l1 has no STREAMOFF
537 * equivalent in the API, and this one at 527 * equivalent in the API, and this one at
538 * least comes close ... */ 528 * least comes close ... */
539 drv(inode, file, VIDIOC_STREAMOFF, &captype); 529 drv(file, VIDIOC_STREAMOFF, &captype);
540 } 530 }
541 err = drv(inode, file, VIDIOC_OVERLAY, on); 531 err = drv(file, VIDIOC_OVERLAY, on);
542 if (err < 0) 532 if (err < 0)
543 dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err); 533 dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err);
544 return err; 534 return err;
@@ -546,7 +536,6 @@ static noinline int v4l1_compat_turn_preview_on_off(
546 536
547static noinline int v4l1_compat_get_input_info( 537static noinline int v4l1_compat_get_input_info(
548 struct video_channel *chan, 538 struct video_channel *chan,
549 struct inode *inode,
550 struct file *file, 539 struct file *file,
551 v4l2_kioctl drv) 540 v4l2_kioctl drv)
552{ 541{
@@ -556,7 +545,7 @@ static noinline int v4l1_compat_get_input_info(
556 545
557 memset(&input2, 0, sizeof(input2)); 546 memset(&input2, 0, sizeof(input2));
558 input2.index = chan->channel; 547 input2.index = chan->channel;
559 err = drv(inode, file, VIDIOC_ENUMINPUT, &input2); 548 err = drv(file, VIDIOC_ENUMINPUT, &input2);
560 if (err < 0) { 549 if (err < 0) {
561 dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " 550 dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: "
562 "channel=%d err=%d\n", chan->channel, err); 551 "channel=%d err=%d\n", chan->channel, err);
@@ -578,7 +567,7 @@ static noinline int v4l1_compat_get_input_info(
578 break; 567 break;
579 } 568 }
580 chan->norm = 0; 569 chan->norm = 0;
581 err = drv(inode, file, VIDIOC_G_STD, &sid); 570 err = drv(file, VIDIOC_G_STD, &sid);
582 if (err < 0) 571 if (err < 0)
583 dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n", err); 572 dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n", err);
584 if (err == 0) { 573 if (err == 0) {
@@ -595,14 +584,13 @@ done:
595 584
596static noinline int v4l1_compat_set_input( 585static noinline int v4l1_compat_set_input(
597 struct video_channel *chan, 586 struct video_channel *chan,
598 struct inode *inode,
599 struct file *file, 587 struct file *file,
600 v4l2_kioctl drv) 588 v4l2_kioctl drv)
601{ 589{
602 int err; 590 int err;
603 v4l2_std_id sid = 0; 591 v4l2_std_id sid = 0;
604 592
605 err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel); 593 err = drv(file, VIDIOC_S_INPUT, &chan->channel);
606 if (err < 0) 594 if (err < 0)
607 dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err); 595 dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err);
608 switch (chan->norm) { 596 switch (chan->norm) {
@@ -617,7 +605,7 @@ static noinline int v4l1_compat_set_input(
617 break; 605 break;
618 } 606 }
619 if (0 != sid) { 607 if (0 != sid) {
620 err = drv(inode, file, VIDIOC_S_STD, &sid); 608 err = drv(file, VIDIOC_S_STD, &sid);
621 if (err < 0) 609 if (err < 0)
622 dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err); 610 dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err);
623 } 611 }
@@ -626,7 +614,6 @@ static noinline int v4l1_compat_set_input(
626 614
627static noinline int v4l1_compat_get_picture( 615static noinline int v4l1_compat_get_picture(
628 struct video_picture *pict, 616 struct video_picture *pict,
629 struct inode *inode,
630 struct file *file, 617 struct file *file,
631 v4l2_kioctl drv) 618 v4l2_kioctl drv)
632{ 619{
@@ -639,19 +626,19 @@ static noinline int v4l1_compat_get_picture(
639 return err; 626 return err;
640 } 627 }
641 628
642 pict->brightness = get_v4l_control(inode, file, 629 pict->brightness = get_v4l_control(file,
643 V4L2_CID_BRIGHTNESS, drv); 630 V4L2_CID_BRIGHTNESS, drv);
644 pict->hue = get_v4l_control(inode, file, 631 pict->hue = get_v4l_control(file,
645 V4L2_CID_HUE, drv); 632 V4L2_CID_HUE, drv);
646 pict->contrast = get_v4l_control(inode, file, 633 pict->contrast = get_v4l_control(file,
647 V4L2_CID_CONTRAST, drv); 634 V4L2_CID_CONTRAST, drv);
648 pict->colour = get_v4l_control(inode, file, 635 pict->colour = get_v4l_control(file,
649 V4L2_CID_SATURATION, drv); 636 V4L2_CID_SATURATION, drv);
650 pict->whiteness = get_v4l_control(inode, file, 637 pict->whiteness = get_v4l_control(file,
651 V4L2_CID_WHITENESS, drv); 638 V4L2_CID_WHITENESS, drv);
652 639
653 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 640 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
654 err = drv(inode, file, VIDIOC_G_FMT, fmt); 641 err = drv(file, VIDIOC_G_FMT, fmt);
655 if (err < 0) { 642 if (err < 0) {
656 dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err); 643 dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err);
657 goto done; 644 goto done;
@@ -669,7 +656,6 @@ done:
669 656
670static noinline int v4l1_compat_set_picture( 657static noinline int v4l1_compat_set_picture(
671 struct video_picture *pict, 658 struct video_picture *pict,
672 struct inode *inode,
673 struct file *file, 659 struct file *file,
674 v4l2_kioctl drv) 660 v4l2_kioctl drv)
675{ 661{
@@ -685,15 +671,15 @@ static noinline int v4l1_compat_set_picture(
685 } 671 }
686 memset(&fbuf, 0, sizeof(fbuf)); 672 memset(&fbuf, 0, sizeof(fbuf));
687 673
688 set_v4l_control(inode, file, 674 set_v4l_control(file,
689 V4L2_CID_BRIGHTNESS, pict->brightness, drv); 675 V4L2_CID_BRIGHTNESS, pict->brightness, drv);
690 set_v4l_control(inode, file, 676 set_v4l_control(file,
691 V4L2_CID_HUE, pict->hue, drv); 677 V4L2_CID_HUE, pict->hue, drv);
692 set_v4l_control(inode, file, 678 set_v4l_control(file,
693 V4L2_CID_CONTRAST, pict->contrast, drv); 679 V4L2_CID_CONTRAST, pict->contrast, drv);
694 set_v4l_control(inode, file, 680 set_v4l_control(file,
695 V4L2_CID_SATURATION, pict->colour, drv); 681 V4L2_CID_SATURATION, pict->colour, drv);
696 set_v4l_control(inode, file, 682 set_v4l_control(file,
697 V4L2_CID_WHITENESS, pict->whiteness, drv); 683 V4L2_CID_WHITENESS, pict->whiteness, drv);
698 /* 684 /*
699 * V4L1 uses this ioctl to set both memory capture and overlay 685 * V4L1 uses this ioctl to set both memory capture and overlay
@@ -703,7 +689,7 @@ static noinline int v4l1_compat_set_picture(
703 */ 689 */
704 690
705 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 691 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
706 err = drv(inode, file, VIDIOC_G_FMT, fmt); 692 err = drv(file, VIDIOC_G_FMT, fmt);
707 /* If VIDIOC_G_FMT failed, then the driver likely doesn't 693 /* If VIDIOC_G_FMT failed, then the driver likely doesn't
708 support memory capture. Trying to set the memory capture 694 support memory capture. Trying to set the memory capture
709 parameters would be pointless. */ 695 parameters would be pointless. */
@@ -714,13 +700,13 @@ static noinline int v4l1_compat_set_picture(
714 palette_to_pixelformat(pict->palette)) { 700 palette_to_pixelformat(pict->palette)) {
715 fmt->fmt.pix.pixelformat = palette_to_pixelformat( 701 fmt->fmt.pix.pixelformat = palette_to_pixelformat(
716 pict->palette); 702 pict->palette);
717 mem_err = drv(inode, file, VIDIOC_S_FMT, fmt); 703 mem_err = drv(file, VIDIOC_S_FMT, fmt);
718 if (mem_err < 0) 704 if (mem_err < 0)
719 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", 705 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",
720 mem_err); 706 mem_err);
721 } 707 }
722 708
723 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); 709 err = drv(file, VIDIOC_G_FBUF, &fbuf);
724 /* If VIDIOC_G_FBUF failed, then the driver likely doesn't 710 /* If VIDIOC_G_FBUF failed, then the driver likely doesn't
725 support overlay. Trying to set the overlay parameters 711 support overlay. Trying to set the overlay parameters
726 would be quite pointless. */ 712 would be quite pointless. */
@@ -731,7 +717,7 @@ static noinline int v4l1_compat_set_picture(
731 palette_to_pixelformat(pict->palette)) { 717 palette_to_pixelformat(pict->palette)) {
732 fbuf.fmt.pixelformat = palette_to_pixelformat( 718 fbuf.fmt.pixelformat = palette_to_pixelformat(
733 pict->palette); 719 pict->palette);
734 ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf); 720 ovl_err = drv(file, VIDIOC_S_FBUF, &fbuf);
735 if (ovl_err < 0) 721 if (ovl_err < 0)
736 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", 722 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",
737 ovl_err); 723 ovl_err);
@@ -752,7 +738,6 @@ static noinline int v4l1_compat_set_picture(
752 738
753static noinline int v4l1_compat_get_tuner( 739static noinline int v4l1_compat_get_tuner(
754 struct video_tuner *tun, 740 struct video_tuner *tun,
755 struct inode *inode,
756 struct file *file, 741 struct file *file,
757 v4l2_kioctl drv) 742 v4l2_kioctl drv)
758{ 743{
@@ -762,7 +747,7 @@ static noinline int v4l1_compat_get_tuner(
762 v4l2_std_id sid; 747 v4l2_std_id sid;
763 748
764 memset(&tun2, 0, sizeof(tun2)); 749 memset(&tun2, 0, sizeof(tun2));
765 err = drv(inode, file, VIDIOC_G_TUNER, &tun2); 750 err = drv(file, VIDIOC_G_TUNER, &tun2);
766 if (err < 0) { 751 if (err < 0) {
767 dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err); 752 dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err);
768 goto done; 753 goto done;
@@ -778,7 +763,7 @@ static noinline int v4l1_compat_get_tuner(
778 for (i = 0; i < 64; i++) { 763 for (i = 0; i < 64; i++) {
779 memset(&std2, 0, sizeof(std2)); 764 memset(&std2, 0, sizeof(std2));
780 std2.index = i; 765 std2.index = i;
781 if (0 != drv(inode, file, VIDIOC_ENUMSTD, &std2)) 766 if (0 != drv(file, VIDIOC_ENUMSTD, &std2))
782 break; 767 break;
783 if (std2.id & V4L2_STD_PAL) 768 if (std2.id & V4L2_STD_PAL)
784 tun->flags |= VIDEO_TUNER_PAL; 769 tun->flags |= VIDEO_TUNER_PAL;
@@ -788,7 +773,7 @@ static noinline int v4l1_compat_get_tuner(
788 tun->flags |= VIDEO_TUNER_SECAM; 773 tun->flags |= VIDEO_TUNER_SECAM;
789 } 774 }
790 775
791 err = drv(inode, file, VIDIOC_G_STD, &sid); 776 err = drv(file, VIDIOC_G_STD, &sid);
792 if (err < 0) 777 if (err < 0)
793 dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n", err); 778 dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n", err);
794 if (err == 0) { 779 if (err == 0) {
@@ -811,7 +796,6 @@ done:
811 796
812static noinline int v4l1_compat_select_tuner( 797static noinline int v4l1_compat_select_tuner(
813 struct video_tuner *tun, 798 struct video_tuner *tun,
814 struct inode *inode,
815 struct file *file, 799 struct file *file,
816 v4l2_kioctl drv) 800 v4l2_kioctl drv)
817{ 801{
@@ -821,7 +805,7 @@ static noinline int v4l1_compat_select_tuner(
821 805
822 t.index = tun->tuner; 806 t.index = tun->tuner;
823 807
824 err = drv(inode, file, VIDIOC_S_INPUT, &t); 808 err = drv(file, VIDIOC_S_INPUT, &t);
825 if (err < 0) 809 if (err < 0)
826 dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err); 810 dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err);
827 return err; 811 return err;
@@ -829,7 +813,6 @@ static noinline int v4l1_compat_select_tuner(
829 813
830static noinline int v4l1_compat_get_frequency( 814static noinline int v4l1_compat_get_frequency(
831 unsigned long *freq, 815 unsigned long *freq,
832 struct inode *inode,
833 struct file *file, 816 struct file *file,
834 v4l2_kioctl drv) 817 v4l2_kioctl drv)
835{ 818{
@@ -838,7 +821,7 @@ static noinline int v4l1_compat_get_frequency(
838 memset(&freq2, 0, sizeof(freq2)); 821 memset(&freq2, 0, sizeof(freq2));
839 822
840 freq2.tuner = 0; 823 freq2.tuner = 0;
841 err = drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); 824 err = drv(file, VIDIOC_G_FREQUENCY, &freq2);
842 if (err < 0) 825 if (err < 0)
843 dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err); 826 dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err);
844 if (0 == err) 827 if (0 == err)
@@ -848,7 +831,6 @@ static noinline int v4l1_compat_get_frequency(
848 831
849static noinline int v4l1_compat_set_frequency( 832static noinline int v4l1_compat_set_frequency(
850 unsigned long *freq, 833 unsigned long *freq,
851 struct inode *inode,
852 struct file *file, 834 struct file *file,
853 v4l2_kioctl drv) 835 v4l2_kioctl drv)
854{ 836{
@@ -856,9 +838,9 @@ static noinline int v4l1_compat_set_frequency(
856 struct v4l2_frequency freq2; 838 struct v4l2_frequency freq2;
857 memset(&freq2, 0, sizeof(freq2)); 839 memset(&freq2, 0, sizeof(freq2));
858 840
859 drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); 841 drv(file, VIDIOC_G_FREQUENCY, &freq2);
860 freq2.frequency = *freq; 842 freq2.frequency = *freq;
861 err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2); 843 err = drv(file, VIDIOC_S_FREQUENCY, &freq2);
862 if (err < 0) 844 if (err < 0)
863 dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err); 845 dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err);
864 return err; 846 return err;
@@ -866,7 +848,6 @@ static noinline int v4l1_compat_set_frequency(
866 848
867static noinline int v4l1_compat_get_audio( 849static noinline int v4l1_compat_get_audio(
868 struct video_audio *aud, 850 struct video_audio *aud,
869 struct inode *inode,
870 struct file *file, 851 struct file *file,
871 v4l2_kioctl drv) 852 v4l2_kioctl drv)
872{ 853{
@@ -876,7 +857,7 @@ static noinline int v4l1_compat_get_audio(
876 struct v4l2_tuner tun2; 857 struct v4l2_tuner tun2;
877 memset(&aud2, 0, sizeof(aud2)); 858 memset(&aud2, 0, sizeof(aud2));
878 859
879 err = drv(inode, file, VIDIOC_G_AUDIO, &aud2); 860 err = drv(file, VIDIOC_G_AUDIO, &aud2);
880 if (err < 0) { 861 if (err < 0) {
881 dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err); 862 dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err);
882 goto done; 863 goto done;
@@ -886,27 +867,27 @@ static noinline int v4l1_compat_get_audio(
886 aud->name[sizeof(aud->name) - 1] = 0; 867 aud->name[sizeof(aud->name) - 1] = 0;
887 aud->audio = aud2.index; 868 aud->audio = aud2.index;
888 aud->flags = 0; 869 aud->flags = 0;
889 i = get_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, drv); 870 i = get_v4l_control(file, V4L2_CID_AUDIO_VOLUME, drv);
890 if (i >= 0) { 871 if (i >= 0) {
891 aud->volume = i; 872 aud->volume = i;
892 aud->flags |= VIDEO_AUDIO_VOLUME; 873 aud->flags |= VIDEO_AUDIO_VOLUME;
893 } 874 }
894 i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, drv); 875 i = get_v4l_control(file, V4L2_CID_AUDIO_BASS, drv);
895 if (i >= 0) { 876 if (i >= 0) {
896 aud->bass = i; 877 aud->bass = i;
897 aud->flags |= VIDEO_AUDIO_BASS; 878 aud->flags |= VIDEO_AUDIO_BASS;
898 } 879 }
899 i = get_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, drv); 880 i = get_v4l_control(file, V4L2_CID_AUDIO_TREBLE, drv);
900 if (i >= 0) { 881 if (i >= 0) {
901 aud->treble = i; 882 aud->treble = i;
902 aud->flags |= VIDEO_AUDIO_TREBLE; 883 aud->flags |= VIDEO_AUDIO_TREBLE;
903 } 884 }
904 i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, drv); 885 i = get_v4l_control(file, V4L2_CID_AUDIO_BALANCE, drv);
905 if (i >= 0) { 886 if (i >= 0) {
906 aud->balance = i; 887 aud->balance = i;
907 aud->flags |= VIDEO_AUDIO_BALANCE; 888 aud->flags |= VIDEO_AUDIO_BALANCE;
908 } 889 }
909 i = get_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, drv); 890 i = get_v4l_control(file, V4L2_CID_AUDIO_MUTE, drv);
910 if (i >= 0) { 891 if (i >= 0) {
911 if (i) 892 if (i)
912 aud->flags |= VIDEO_AUDIO_MUTE; 893 aud->flags |= VIDEO_AUDIO_MUTE;
@@ -914,13 +895,13 @@ static noinline int v4l1_compat_get_audio(
914 } 895 }
915 aud->step = 1; 896 aud->step = 1;
916 qctrl2.id = V4L2_CID_AUDIO_VOLUME; 897 qctrl2.id = V4L2_CID_AUDIO_VOLUME;
917 if (drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2) == 0 && 898 if (drv(file, VIDIOC_QUERYCTRL, &qctrl2) == 0 &&
918 !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) 899 !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED))
919 aud->step = qctrl2.step; 900 aud->step = qctrl2.step;
920 aud->mode = 0; 901 aud->mode = 0;
921 902
922 memset(&tun2, 0, sizeof(tun2)); 903 memset(&tun2, 0, sizeof(tun2));
923 err = drv(inode, file, VIDIOC_G_TUNER, &tun2); 904 err = drv(file, VIDIOC_G_TUNER, &tun2);
924 if (err < 0) { 905 if (err < 0) {
925 dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err); 906 dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err);
926 err = 0; 907 err = 0;
@@ -939,7 +920,6 @@ done:
939 920
940static noinline int v4l1_compat_set_audio( 921static noinline int v4l1_compat_set_audio(
941 struct video_audio *aud, 922 struct video_audio *aud,
942 struct inode *inode,
943 struct file *file, 923 struct file *file,
944 v4l2_kioctl drv) 924 v4l2_kioctl drv)
945{ 925{
@@ -951,24 +931,24 @@ static noinline int v4l1_compat_set_audio(
951 memset(&tun2, 0, sizeof(tun2)); 931 memset(&tun2, 0, sizeof(tun2));
952 932
953 aud2.index = aud->audio; 933 aud2.index = aud->audio;
954 err = drv(inode, file, VIDIOC_S_AUDIO, &aud2); 934 err = drv(file, VIDIOC_S_AUDIO, &aud2);
955 if (err < 0) { 935 if (err < 0) {
956 dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err); 936 dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err);
957 goto done; 937 goto done;
958 } 938 }
959 939
960 set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, 940 set_v4l_control(file, V4L2_CID_AUDIO_VOLUME,
961 aud->volume, drv); 941 aud->volume, drv);
962 set_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, 942 set_v4l_control(file, V4L2_CID_AUDIO_BASS,
963 aud->bass, drv); 943 aud->bass, drv);
964 set_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, 944 set_v4l_control(file, V4L2_CID_AUDIO_TREBLE,
965 aud->treble, drv); 945 aud->treble, drv);
966 set_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, 946 set_v4l_control(file, V4L2_CID_AUDIO_BALANCE,
967 aud->balance, drv); 947 aud->balance, drv);
968 set_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, 948 set_v4l_control(file, V4L2_CID_AUDIO_MUTE,
969 !!(aud->flags & VIDEO_AUDIO_MUTE), drv); 949 !!(aud->flags & VIDEO_AUDIO_MUTE), drv);
970 950
971 err = drv(inode, file, VIDIOC_G_TUNER, &tun2); 951 err = drv(file, VIDIOC_G_TUNER, &tun2);
972 if (err < 0) 952 if (err < 0)
973 dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n", err); 953 dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n", err);
974 if (err == 0) { 954 if (err == 0) {
@@ -985,7 +965,7 @@ static noinline int v4l1_compat_set_audio(
985 tun2.audmode = V4L2_TUNER_MODE_LANG2; 965 tun2.audmode = V4L2_TUNER_MODE_LANG2;
986 break; 966 break;
987 } 967 }
988 err = drv(inode, file, VIDIOC_S_TUNER, &tun2); 968 err = drv(file, VIDIOC_S_TUNER, &tun2);
989 if (err < 0) 969 if (err < 0)
990 dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err); 970 dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err);
991 } 971 }
@@ -996,7 +976,6 @@ done:
996 976
997static noinline int v4l1_compat_capture_frame( 977static noinline int v4l1_compat_capture_frame(
998 struct video_mmap *mm, 978 struct video_mmap *mm,
999 struct inode *inode,
1000 struct file *file, 979 struct file *file,
1001 v4l2_kioctl drv) 980 v4l2_kioctl drv)
1002{ 981{
@@ -1013,7 +992,7 @@ static noinline int v4l1_compat_capture_frame(
1013 memset(&buf, 0, sizeof(buf)); 992 memset(&buf, 0, sizeof(buf));
1014 993
1015 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 994 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1016 err = drv(inode, file, VIDIOC_G_FMT, fmt); 995 err = drv(file, VIDIOC_G_FMT, fmt);
1017 if (err < 0) { 996 if (err < 0) {
1018 dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err); 997 dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err);
1019 goto done; 998 goto done;
@@ -1029,7 +1008,7 @@ static noinline int v4l1_compat_capture_frame(
1029 palette_to_pixelformat(mm->format); 1008 palette_to_pixelformat(mm->format);
1030 fmt->fmt.pix.field = V4L2_FIELD_ANY; 1009 fmt->fmt.pix.field = V4L2_FIELD_ANY;
1031 fmt->fmt.pix.bytesperline = 0; 1010 fmt->fmt.pix.bytesperline = 0;
1032 err = drv(inode, file, VIDIOC_S_FMT, fmt); 1011 err = drv(file, VIDIOC_S_FMT, fmt);
1033 if (err < 0) { 1012 if (err < 0) {
1034 dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err); 1013 dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err);
1035 goto done; 1014 goto done;
@@ -1037,17 +1016,17 @@ static noinline int v4l1_compat_capture_frame(
1037 } 1016 }
1038 buf.index = mm->frame; 1017 buf.index = mm->frame;
1039 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1018 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1040 err = drv(inode, file, VIDIOC_QUERYBUF, &buf); 1019 err = drv(file, VIDIOC_QUERYBUF, &buf);
1041 if (err < 0) { 1020 if (err < 0) {
1042 dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err); 1021 dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err);
1043 goto done; 1022 goto done;
1044 } 1023 }
1045 err = drv(inode, file, VIDIOC_QBUF, &buf); 1024 err = drv(file, VIDIOC_QBUF, &buf);
1046 if (err < 0) { 1025 if (err < 0) {
1047 dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err); 1026 dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err);
1048 goto done; 1027 goto done;
1049 } 1028 }
1050 err = drv(inode, file, VIDIOC_STREAMON, &captype); 1029 err = drv(file, VIDIOC_STREAMON, &captype);
1051 if (err < 0) 1030 if (err < 0)
1052 dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err); 1031 dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err);
1053done: 1032done:
@@ -1057,7 +1036,6 @@ done:
1057 1036
1058static noinline int v4l1_compat_sync( 1037static noinline int v4l1_compat_sync(
1059 int *i, 1038 int *i,
1060 struct inode *inode,
1061 struct file *file, 1039 struct file *file,
1062 v4l2_kioctl drv) 1040 v4l2_kioctl drv)
1063{ 1041{
@@ -1069,7 +1047,7 @@ static noinline int v4l1_compat_sync(
1069 memset(&buf, 0, sizeof(buf)); 1047 memset(&buf, 0, sizeof(buf));
1070 buf.index = *i; 1048 buf.index = *i;
1071 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1049 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1072 err = drv(inode, file, VIDIOC_QUERYBUF, &buf); 1050 err = drv(file, VIDIOC_QUERYBUF, &buf);
1073 if (err < 0) { 1051 if (err < 0) {
1074 /* No such buffer */ 1052 /* No such buffer */
1075 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); 1053 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
@@ -1082,7 +1060,7 @@ static noinline int v4l1_compat_sync(
1082 } 1060 }
1083 1061
1084 /* make sure capture actually runs so we don't block forever */ 1062 /* make sure capture actually runs so we don't block forever */
1085 err = drv(inode, file, VIDIOC_STREAMON, &captype); 1063 err = drv(file, VIDIOC_STREAMON, &captype);
1086 if (err < 0) { 1064 if (err < 0) {
1087 dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err); 1065 dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err);
1088 goto done; 1066 goto done;
@@ -1096,7 +1074,7 @@ static noinline int v4l1_compat_sync(
1096 if (err < 0 || /* error or sleep was interrupted */ 1074 if (err < 0 || /* error or sleep was interrupted */
1097 err == 0) /* timeout? Shouldn't occur. */ 1075 err == 0) /* timeout? Shouldn't occur. */
1098 break; 1076 break;
1099 err = drv(inode, file, VIDIOC_QUERYBUF, &buf); 1077 err = drv(file, VIDIOC_QUERYBUF, &buf);
1100 if (err < 0) 1078 if (err < 0)
1101 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); 1079 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
1102 } 1080 }
@@ -1104,7 +1082,7 @@ static noinline int v4l1_compat_sync(
1104 if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ 1082 if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */
1105 goto done; 1083 goto done;
1106 do { 1084 do {
1107 err = drv(inode, file, VIDIOC_DQBUF, &buf); 1085 err = drv(file, VIDIOC_DQBUF, &buf);
1108 if (err < 0) 1086 if (err < 0)
1109 dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err); 1087 dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err);
1110 } while (err == 0 && buf.index != *i); 1088 } while (err == 0 && buf.index != *i);
@@ -1114,7 +1092,6 @@ done:
1114 1092
1115static noinline int v4l1_compat_get_vbi_format( 1093static noinline int v4l1_compat_get_vbi_format(
1116 struct vbi_format *fmt, 1094 struct vbi_format *fmt,
1117 struct inode *inode,
1118 struct file *file, 1095 struct file *file,
1119 v4l2_kioctl drv) 1096 v4l2_kioctl drv)
1120{ 1097{
@@ -1128,7 +1105,7 @@ static noinline int v4l1_compat_get_vbi_format(
1128 } 1105 }
1129 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1106 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
1130 1107
1131 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 1108 err = drv(file, VIDIOC_G_FMT, fmt2);
1132 if (err < 0) { 1109 if (err < 0) {
1133 dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); 1110 dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err);
1134 goto done; 1111 goto done;
@@ -1153,7 +1130,6 @@ done:
1153 1130
1154static noinline int v4l1_compat_set_vbi_format( 1131static noinline int v4l1_compat_set_vbi_format(
1155 struct vbi_format *fmt, 1132 struct vbi_format *fmt,
1156 struct inode *inode,
1157 struct file *file, 1133 struct file *file,
1158 v4l2_kioctl drv) 1134 v4l2_kioctl drv)
1159{ 1135{
@@ -1179,7 +1155,7 @@ static noinline int v4l1_compat_set_vbi_format(
1179 fmt2->fmt.vbi.start[1] = fmt->start[1]; 1155 fmt2->fmt.vbi.start[1] = fmt->start[1];
1180 fmt2->fmt.vbi.count[1] = fmt->count[1]; 1156 fmt2->fmt.vbi.count[1] = fmt->count[1];
1181 fmt2->fmt.vbi.flags = fmt->flags; 1157 fmt2->fmt.vbi.flags = fmt->flags;
1182 err = drv(inode, file, VIDIOC_TRY_FMT, fmt2); 1158 err = drv(file, VIDIOC_TRY_FMT, fmt2);
1183 if (err < 0) { 1159 if (err < 0) {
1184 dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); 1160 dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err);
1185 goto done; 1161 goto done;
@@ -1196,7 +1172,7 @@ static noinline int v4l1_compat_set_vbi_format(
1196 err = -EINVAL; 1172 err = -EINVAL;
1197 goto done; 1173 goto done;
1198 } 1174 }
1199 err = drv(inode, file, VIDIOC_S_FMT, fmt2); 1175 err = drv(file, VIDIOC_S_FMT, fmt2);
1200 if (err < 0) 1176 if (err < 0)
1201 dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); 1177 dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err);
1202done: 1178done:
@@ -1208,8 +1184,7 @@ done:
1208 * This function is exported. 1184 * This function is exported.
1209 */ 1185 */
1210int 1186int
1211v4l_compat_translate_ioctl(struct inode *inode, 1187v4l_compat_translate_ioctl(struct file *file,
1212 struct file *file,
1213 int cmd, 1188 int cmd,
1214 void *arg, 1189 void *arg,
1215 v4l2_kioctl drv) 1190 v4l2_kioctl drv)
@@ -1218,64 +1193,64 @@ v4l_compat_translate_ioctl(struct inode *inode,
1218 1193
1219 switch (cmd) { 1194 switch (cmd) {
1220 case VIDIOCGCAP: /* capability */ 1195 case VIDIOCGCAP: /* capability */
1221 err = v4l1_compat_get_capabilities(arg, inode, file, drv); 1196 err = v4l1_compat_get_capabilities(arg, file, drv);
1222 break; 1197 break;
1223 case VIDIOCGFBUF: /* get frame buffer */ 1198 case VIDIOCGFBUF: /* get frame buffer */
1224 err = v4l1_compat_get_frame_buffer(arg, inode, file, drv); 1199 err = v4l1_compat_get_frame_buffer(arg, file, drv);
1225 break; 1200 break;
1226 case VIDIOCSFBUF: /* set frame buffer */ 1201 case VIDIOCSFBUF: /* set frame buffer */
1227 err = v4l1_compat_set_frame_buffer(arg, inode, file, drv); 1202 err = v4l1_compat_set_frame_buffer(arg, file, drv);
1228 break; 1203 break;
1229 case VIDIOCGWIN: /* get window or capture dimensions */ 1204 case VIDIOCGWIN: /* get window or capture dimensions */
1230 err = v4l1_compat_get_win_cap_dimensions(arg, inode, file, drv); 1205 err = v4l1_compat_get_win_cap_dimensions(arg, file, drv);
1231 break; 1206 break;
1232 case VIDIOCSWIN: /* set window and/or capture dimensions */ 1207 case VIDIOCSWIN: /* set window and/or capture dimensions */
1233 err = v4l1_compat_set_win_cap_dimensions(arg, inode, file, drv); 1208 err = v4l1_compat_set_win_cap_dimensions(arg, file, drv);
1234 break; 1209 break;
1235 case VIDIOCCAPTURE: /* turn on/off preview */ 1210 case VIDIOCCAPTURE: /* turn on/off preview */
1236 err = v4l1_compat_turn_preview_on_off(arg, inode, file, drv); 1211 err = v4l1_compat_turn_preview_on_off(arg, file, drv);
1237 break; 1212 break;
1238 case VIDIOCGCHAN: /* get input information */ 1213 case VIDIOCGCHAN: /* get input information */
1239 err = v4l1_compat_get_input_info(arg, inode, file, drv); 1214 err = v4l1_compat_get_input_info(arg, file, drv);
1240 break; 1215 break;
1241 case VIDIOCSCHAN: /* set input */ 1216 case VIDIOCSCHAN: /* set input */
1242 err = v4l1_compat_set_input(arg, inode, file, drv); 1217 err = v4l1_compat_set_input(arg, file, drv);
1243 break; 1218 break;
1244 case VIDIOCGPICT: /* get tone controls & partial capture format */ 1219 case VIDIOCGPICT: /* get tone controls & partial capture format */
1245 err = v4l1_compat_get_picture(arg, inode, file, drv); 1220 err = v4l1_compat_get_picture(arg, file, drv);
1246 break; 1221 break;
1247 case VIDIOCSPICT: /* set tone controls & partial capture format */ 1222 case VIDIOCSPICT: /* set tone controls & partial capture format */
1248 err = v4l1_compat_set_picture(arg, inode, file, drv); 1223 err = v4l1_compat_set_picture(arg, file, drv);
1249 break; 1224 break;
1250 case VIDIOCGTUNER: /* get tuner information */ 1225 case VIDIOCGTUNER: /* get tuner information */
1251 err = v4l1_compat_get_tuner(arg, inode, file, drv); 1226 err = v4l1_compat_get_tuner(arg, file, drv);
1252 break; 1227 break;
1253 case VIDIOCSTUNER: /* select a tuner input */ 1228 case VIDIOCSTUNER: /* select a tuner input */
1254 err = v4l1_compat_select_tuner(arg, inode, file, drv); 1229 err = v4l1_compat_select_tuner(arg, file, drv);
1255 break; 1230 break;
1256 case VIDIOCGFREQ: /* get frequency */ 1231 case VIDIOCGFREQ: /* get frequency */
1257 err = v4l1_compat_get_frequency(arg, inode, file, drv); 1232 err = v4l1_compat_get_frequency(arg, file, drv);
1258 break; 1233 break;
1259 case VIDIOCSFREQ: /* set frequency */ 1234 case VIDIOCSFREQ: /* set frequency */
1260 err = v4l1_compat_set_frequency(arg, inode, file, drv); 1235 err = v4l1_compat_set_frequency(arg, file, drv);
1261 break; 1236 break;
1262 case VIDIOCGAUDIO: /* get audio properties/controls */ 1237 case VIDIOCGAUDIO: /* get audio properties/controls */
1263 err = v4l1_compat_get_audio(arg, inode, file, drv); 1238 err = v4l1_compat_get_audio(arg, file, drv);
1264 break; 1239 break;
1265 case VIDIOCSAUDIO: /* set audio controls */ 1240 case VIDIOCSAUDIO: /* set audio controls */
1266 err = v4l1_compat_set_audio(arg, inode, file, drv); 1241 err = v4l1_compat_set_audio(arg, file, drv);
1267 break; 1242 break;
1268 case VIDIOCMCAPTURE: /* capture a frame */ 1243 case VIDIOCMCAPTURE: /* capture a frame */
1269 err = v4l1_compat_capture_frame(arg, inode, file, drv); 1244 err = v4l1_compat_capture_frame(arg, file, drv);
1270 break; 1245 break;
1271 case VIDIOCSYNC: /* wait for a frame */ 1246 case VIDIOCSYNC: /* wait for a frame */
1272 err = v4l1_compat_sync(arg, inode, file, drv); 1247 err = v4l1_compat_sync(arg, file, drv);
1273 break; 1248 break;
1274 case VIDIOCGVBIFMT: /* query VBI data capture format */ 1249 case VIDIOCGVBIFMT: /* query VBI data capture format */
1275 err = v4l1_compat_get_vbi_format(arg, inode, file, drv); 1250 err = v4l1_compat_get_vbi_format(arg, file, drv);
1276 break; 1251 break;
1277 case VIDIOCSVBIFMT: 1252 case VIDIOCSVBIFMT:
1278 err = v4l1_compat_set_vbi_format(arg, inode, file, drv); 1253 err = v4l1_compat_set_vbi_format(arg, file, drv);
1279 break; 1254 break;
1280 default: 1255 default:
1281 err = -ENOIOCTLCMD; 1256 err = -ENOIOCTLCMD;
diff --git a/drivers/media/video/v4l2-int-device.c b/drivers/media/video/v4l2-int-device.c
index 0e4549922f26..a935bae538ef 100644
--- a/drivers/media/video/v4l2-int-device.c
+++ b/drivers/media/video/v4l2-int-device.c
@@ -32,7 +32,7 @@
32static DEFINE_MUTEX(mutex); 32static DEFINE_MUTEX(mutex);
33static LIST_HEAD(int_list); 33static LIST_HEAD(int_list);
34 34
35static void v4l2_int_device_try_attach_all(void) 35void v4l2_int_device_try_attach_all(void)
36{ 36{
37 struct v4l2_int_device *m, *s; 37 struct v4l2_int_device *m, *s;
38 38
@@ -66,6 +66,7 @@ static void v4l2_int_device_try_attach_all(void)
66 } 66 }
67 } 67 }
68} 68}
69EXPORT_SYMBOL_GPL(v4l2_int_device_try_attach_all);
69 70
70static int ioctl_sort_cmp(const void *a, const void *b) 71static int ioctl_sort_cmp(const void *a, const void *b)
71{ 72{
@@ -144,6 +145,7 @@ int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd)
144 find_ioctl(d->u.slave, cmd, 145 find_ioctl(d->u.slave, cmd,
145 (v4l2_int_ioctl_func *)no_such_ioctl_0))(d); 146 (v4l2_int_ioctl_func *)no_such_ioctl_0))(d);
146} 147}
148EXPORT_SYMBOL_GPL(v4l2_int_ioctl_0);
147 149
148static int no_such_ioctl_1(struct v4l2_int_device *d, void *arg) 150static int no_such_ioctl_1(struct v4l2_int_device *d, void *arg)
149{ 151{
@@ -156,5 +158,6 @@ int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg)
156 find_ioctl(d->u.slave, cmd, 158 find_ioctl(d->u.slave, cmd,
157 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg); 159 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg);
158} 160}
161EXPORT_SYMBOL_GPL(v4l2_int_ioctl_1);
159 162
160MODULE_LICENSE("GPL"); 163MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 155c9d77a463..710e1a40c422 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -625,13 +625,13 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type)
625 return -EINVAL; 625 return -EINVAL;
626} 626}
627 627
628static int __video_do_ioctl(struct inode *inode, struct file *file, 628static int __video_do_ioctl(struct file *file,
629 unsigned int cmd, void *arg) 629 unsigned int cmd, void *arg)
630{ 630{
631 struct video_device *vfd = video_devdata(file); 631 struct video_device *vfd = video_devdata(file);
632 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; 632 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
633 void *fh = file->private_data; 633 void *fh = file->private_data;
634 int ret = -EINVAL; 634 int ret = -EINVAL;
635 635
636 if ((vfd->debug & V4L2_DEBUG_IOCTL) && 636 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
637 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { 637 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
@@ -675,7 +675,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
675 V4L2 ioctls. 675 V4L2 ioctls.
676 ********************************************************/ 676 ********************************************************/
677 if (_IOC_TYPE(cmd) == 'v' && _IOC_NR(cmd) < BASE_VIDIOCPRIVATE) 677 if (_IOC_TYPE(cmd) == 'v' && _IOC_NR(cmd) < BASE_VIDIOCPRIVATE)
678 return v4l_compat_translate_ioctl(inode, file, cmd, arg, 678 return v4l_compat_translate_ioctl(file, cmd, arg,
679 __video_do_ioctl); 679 __video_do_ioctl);
680#endif 680#endif
681 681
@@ -1768,7 +1768,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1768 return ret; 1768 return ret;
1769} 1769}
1770 1770
1771int video_ioctl2(struct inode *inode, struct file *file, 1771int __video_ioctl2(struct file *file,
1772 unsigned int cmd, unsigned long arg) 1772 unsigned int cmd, unsigned long arg)
1773{ 1773{
1774 char sbuf[128]; 1774 char sbuf[128];
@@ -1832,7 +1832,7 @@ int video_ioctl2(struct inode *inode, struct file *file,
1832 } 1832 }
1833 1833
1834 /* Handles IOCTL */ 1834 /* Handles IOCTL */
1835 err = __video_do_ioctl(inode, file, cmd, parg); 1835 err = __video_do_ioctl(file, cmd, parg);
1836 if (err == -ENOIOCTLCMD) 1836 if (err == -ENOIOCTLCMD)
1837 err = -EINVAL; 1837 err = -EINVAL;
1838 if (is_ext_ctrl) { 1838 if (is_ext_ctrl) {
@@ -1860,4 +1860,11 @@ out:
1860 kfree(mbuf); 1860 kfree(mbuf);
1861 return err; 1861 return err;
1862} 1862}
1863EXPORT_SYMBOL(__video_ioctl2);
1864
1865int video_ioctl2(struct inode *inode, struct file *file,
1866 unsigned int cmd, unsigned long arg)
1867{
1868 return __video_ioctl2(file, cmd, arg);
1869}
1863EXPORT_SYMBOL(video_ioctl2); 1870EXPORT_SYMBOL(video_ioctl2);
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c
index 917277d36605..0e7dcba8e4ae 100644
--- a/drivers/media/video/videobuf-dvb.c
+++ b/drivers/media/video/videobuf-dvb.c
@@ -296,29 +296,7 @@ EXPORT_SYMBOL(videobuf_dvb_register_bus);
296 296
297void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f) 297void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f)
298{ 298{
299 struct list_head *list, *q; 299 videobuf_dvb_dealloc_frontends(f);
300 struct videobuf_dvb_frontend *fe;
301
302 mutex_lock(&f->lock);
303 list_for_each_safe(list, q, &f->felist) {
304 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
305 if (fe->dvb.net.dvbdev) {
306 dvb_net_release(&fe->dvb.net);
307 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
308 &fe->dvb.fe_mem);
309 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
310 &fe->dvb.fe_hw);
311 dvb_dmxdev_release(&fe->dvb.dmxdev);
312 dvb_dmx_release(&fe->dvb.demux);
313 dvb_unregister_frontend(fe->dvb.frontend);
314 }
315 if (fe->dvb.frontend)
316 /* always allocated, may have been reset */
317 dvb_frontend_detach(fe->dvb.frontend);
318 list_del(list);
319 kfree(fe);
320 }
321 mutex_unlock(&f->lock);
322 300
323 dvb_unregister_adapter(&f->adapter); 301 dvb_unregister_adapter(&f->adapter);
324} 302}
@@ -389,3 +367,31 @@ fail_alloc:
389 return fe; 367 return fe;
390} 368}
391EXPORT_SYMBOL(videobuf_dvb_alloc_frontend); 369EXPORT_SYMBOL(videobuf_dvb_alloc_frontend);
370
371void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f)
372{
373 struct list_head *list, *q;
374 struct videobuf_dvb_frontend *fe;
375
376 mutex_lock(&f->lock);
377 list_for_each_safe(list, q, &f->felist) {
378 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
379 if (fe->dvb.net.dvbdev) {
380 dvb_net_release(&fe->dvb.net);
381 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
382 &fe->dvb.fe_mem);
383 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
384 &fe->dvb.fe_hw);
385 dvb_dmxdev_release(&fe->dvb.dmxdev);
386 dvb_dmx_release(&fe->dvb.demux);
387 dvb_unregister_frontend(fe->dvb.frontend);
388 }
389 if (fe->dvb.frontend)
390 /* always allocated, may have been reset */
391 dvb_frontend_detach(fe->dvb.frontend);
392 list_del(list); /* remove list entry */
393 kfree(fe); /* free frontend allocation */
394 }
395 mutex_unlock(&f->lock);
396}
397EXPORT_SYMBOL(videobuf_dvb_dealloc_frontends);
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 7d7e51def461..e15e48f04be7 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -1163,11 +1163,11 @@ static int vivi_release(void)
1163 1163
1164 if (-1 != dev->vfd->minor) { 1164 if (-1 != dev->vfd->minor) {
1165 printk(KERN_INFO "%s: unregistering /dev/video%d\n", 1165 printk(KERN_INFO "%s: unregistering /dev/video%d\n",
1166 VIVI_MODULE_NAME, dev->vfd->minor); 1166 VIVI_MODULE_NAME, dev->vfd->num);
1167 video_unregister_device(dev->vfd); 1167 video_unregister_device(dev->vfd);
1168 } else { 1168 } else {
1169 printk(KERN_INFO "%s: releasing /dev/video%d\n", 1169 printk(KERN_INFO "%s: releasing /dev/video%d\n",
1170 VIVI_MODULE_NAME, dev->vfd->minor); 1170 VIVI_MODULE_NAME, dev->vfd->num);
1171 video_device_release(dev->vfd); 1171 video_device_release(dev->vfd);
1172 } 1172 }
1173 1173
@@ -1307,7 +1307,7 @@ static int __init vivi_init(void)
1307 1307
1308 dev->vfd = vfd; 1308 dev->vfd = vfd;
1309 printk(KERN_INFO "%s: V4L2 device registered as /dev/video%d\n", 1309 printk(KERN_INFO "%s: V4L2 device registered as /dev/video%d\n",
1310 VIVI_MODULE_NAME, vfd->minor); 1310 VIVI_MODULE_NAME, vfd->num);
1311 } 1311 }
1312 1312
1313 if (ret < 0) { 1313 if (ret < 0) {
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index dcd45dbd82dc..4dfb43bd1846 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -2398,7 +2398,7 @@ error:
2398 cam->sensor = CC_UNKNOWN; 2398 cam->sensor = CC_UNKNOWN;
2399 DBG(1, "Image sensor initialization failed for %s (/dev/video%d). " 2399 DBG(1, "Image sensor initialization failed for %s (/dev/video%d). "
2400 "Try to detach and attach this device again", 2400 "Try to detach and attach this device again",
2401 symbolic(camlist, cam->id), cam->v4ldev->minor) 2401 symbolic(camlist, cam->id), cam->v4ldev->num)
2402 return err; 2402 return err;
2403} 2403}
2404 2404
@@ -2644,7 +2644,7 @@ static void w9968cf_release_resources(struct w9968cf_device* cam)
2644{ 2644{
2645 mutex_lock(&w9968cf_devlist_mutex); 2645 mutex_lock(&w9968cf_devlist_mutex);
2646 2646
2647 DBG(2, "V4L device deregistered: /dev/video%d", cam->v4ldev->minor) 2647 DBG(2, "V4L device deregistered: /dev/video%d", cam->v4ldev->num)
2648 2648
2649 video_unregister_device(cam->v4ldev); 2649 video_unregister_device(cam->v4ldev);
2650 list_del(&cam->v4llist); 2650 list_del(&cam->v4llist);
@@ -2679,7 +2679,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2679 DBG(2, "No supported image sensor has been detected by the " 2679 DBG(2, "No supported image sensor has been detected by the "
2680 "'ovcamchip' module for the %s (/dev/video%d). Make " 2680 "'ovcamchip' module for the %s (/dev/video%d). Make "
2681 "sure it is loaded *before* (re)connecting the camera.", 2681 "sure it is loaded *before* (re)connecting the camera.",
2682 symbolic(camlist, cam->id), cam->v4ldev->minor) 2682 symbolic(camlist, cam->id), cam->v4ldev->num)
2683 mutex_unlock(&cam->dev_mutex); 2683 mutex_unlock(&cam->dev_mutex);
2684 up_read(&w9968cf_disconnect); 2684 up_read(&w9968cf_disconnect);
2685 return -ENODEV; 2685 return -ENODEV;
@@ -2687,7 +2687,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2687 2687
2688 if (cam->users) { 2688 if (cam->users) {
2689 DBG(2, "%s (/dev/video%d) has been already occupied by '%s'", 2689 DBG(2, "%s (/dev/video%d) has been already occupied by '%s'",
2690 symbolic(camlist, cam->id),cam->v4ldev->minor,cam->command) 2690 symbolic(camlist, cam->id), cam->v4ldev->num, cam->command)
2691 if ((filp->f_flags & O_NONBLOCK)||(filp->f_flags & O_NDELAY)) { 2691 if ((filp->f_flags & O_NONBLOCK)||(filp->f_flags & O_NDELAY)) {
2692 mutex_unlock(&cam->dev_mutex); 2692 mutex_unlock(&cam->dev_mutex);
2693 up_read(&w9968cf_disconnect); 2693 up_read(&w9968cf_disconnect);
@@ -2709,7 +2709,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2709 } 2709 }
2710 2710
2711 DBG(5, "Opening '%s', /dev/video%d ...", 2711 DBG(5, "Opening '%s', /dev/video%d ...",
2712 symbolic(camlist, cam->id), cam->v4ldev->minor) 2712 symbolic(camlist, cam->id), cam->v4ldev->num)
2713 2713
2714 cam->streaming = 0; 2714 cam->streaming = 0;
2715 cam->misconfigured = 0; 2715 cam->misconfigured = 0;
@@ -2947,7 +2947,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2947 .minheight = cam->minheight, 2947 .minheight = cam->minheight,
2948 }; 2948 };
2949 sprintf(cap.name, "W996[87]CF USB Camera #%d", 2949 sprintf(cap.name, "W996[87]CF USB Camera #%d",
2950 cam->v4ldev->minor); 2950 cam->v4ldev->num);
2951 cap.maxwidth = (cam->upscaling && w9968cf_vpp) 2951 cap.maxwidth = (cam->upscaling && w9968cf_vpp)
2952 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 2952 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
2953 : cam->maxwidth; 2953 : cam->maxwidth;
@@ -3567,7 +3567,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3567 goto fail; 3567 goto fail;
3568 } 3568 }
3569 3569
3570 DBG(2, "V4L device registered as /dev/video%d", cam->v4ldev->minor) 3570 DBG(2, "V4L device registered as /dev/video%d", cam->v4ldev->num)
3571 3571
3572 /* Set some basic constants */ 3572 /* Set some basic constants */
3573 w9968cf_configure_camera(cam, udev, mod_id, dev_nr); 3573 w9968cf_configure_camera(cam, udev, mod_id, dev_nr);
@@ -3618,7 +3618,7 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf)
3618 DBG(2, "The device is open (/dev/video%d)! " 3618 DBG(2, "The device is open (/dev/video%d)! "
3619 "Process name: %s. Deregistration and memory " 3619 "Process name: %s. Deregistration and memory "
3620 "deallocation are deferred on close.", 3620 "deallocation are deferred on close.",
3621 cam->v4ldev->minor, cam->command) 3621 cam->v4ldev->num, cam->command)
3622 cam->misconfigured = 1; 3622 cam->misconfigured = 1;
3623 w9968cf_stop_transfer(cam); 3623 w9968cf_stop_transfer(cam);
3624 wake_up_interruptible(&cam->wait_queue); 3624 wake_up_interruptible(&cam->wait_queue);
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 6a0902bcba6b..9fc581707638 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -539,7 +539,7 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
539 cam->state |= DEV_MISCONFIGURED; 539 cam->state |= DEV_MISCONFIGURED;
540 DBG(1, "URB timeout reached. The camera is misconfigured. To " 540 DBG(1, "URB timeout reached. The camera is misconfigured. To "
541 "use it, close and open /dev/video%d again.", 541 "use it, close and open /dev/video%d again.",
542 cam->v4ldev->minor); 542 cam->v4ldev->num);
543 return -EIO; 543 return -EIO;
544 } 544 }
545 545
@@ -640,7 +640,7 @@ static void zc0301_release_resources(struct kref *kref)
640{ 640{
641 struct zc0301_device *cam = container_of(kref, struct zc0301_device, 641 struct zc0301_device *cam = container_of(kref, struct zc0301_device,
642 kref); 642 kref);
643 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); 643 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
644 video_set_drvdata(cam->v4ldev, NULL); 644 video_set_drvdata(cam->v4ldev, NULL);
645 video_unregister_device(cam->v4ldev); 645 video_unregister_device(cam->v4ldev);
646 usb_put_dev(cam->usbdev); 646 usb_put_dev(cam->usbdev);
@@ -679,7 +679,7 @@ static int zc0301_open(struct inode* inode, struct file* filp)
679 } 679 }
680 680
681 if (cam->users) { 681 if (cam->users) {
682 DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->minor); 682 DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->num);
683 DBG(3, "Simultaneous opens are not supported"); 683 DBG(3, "Simultaneous opens are not supported");
684 if ((filp->f_flags & O_NONBLOCK) || 684 if ((filp->f_flags & O_NONBLOCK) ||
685 (filp->f_flags & O_NDELAY)) { 685 (filp->f_flags & O_NDELAY)) {
@@ -722,7 +722,7 @@ static int zc0301_open(struct inode* inode, struct file* filp)
722 cam->frame_count = 0; 722 cam->frame_count = 0;
723 zc0301_empty_framequeues(cam); 723 zc0301_empty_framequeues(cam);
724 724
725 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); 725 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
726 726
727out: 727out:
728 mutex_unlock(&cam->open_mutex); 728 mutex_unlock(&cam->open_mutex);
@@ -746,7 +746,7 @@ static int zc0301_release(struct inode* inode, struct file* filp)
746 cam->users--; 746 cam->users--;
747 wake_up_interruptible_nr(&cam->wait_open, 1); 747 wake_up_interruptible_nr(&cam->wait_open, 1);
748 748
749 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); 749 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
750 750
751 kref_put(&cam->kref, zc0301_release_resources); 751 kref_put(&cam->kref, zc0301_release_resources);
752 752
@@ -1275,7 +1275,7 @@ zc0301_vidioc_s_crop(struct zc0301_device* cam, void __user * arg)
1275 cam->state |= DEV_MISCONFIGURED; 1275 cam->state |= DEV_MISCONFIGURED;
1276 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To " 1276 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
1277 "use the camera, close and open /dev/video%d again.", 1277 "use the camera, close and open /dev/video%d again.",
1278 cam->v4ldev->minor); 1278 cam->v4ldev->num);
1279 return -EIO; 1279 return -EIO;
1280 } 1280 }
1281 1281
@@ -1288,7 +1288,7 @@ zc0301_vidioc_s_crop(struct zc0301_device* cam, void __user * arg)
1288 cam->state |= DEV_MISCONFIGURED; 1288 cam->state |= DEV_MISCONFIGURED;
1289 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To " 1289 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
1290 "use the camera, close and open /dev/video%d again.", 1290 "use the camera, close and open /dev/video%d again.",
1291 cam->v4ldev->minor); 1291 cam->v4ldev->num);
1292 return -ENOMEM; 1292 return -ENOMEM;
1293 } 1293 }
1294 1294
@@ -1470,7 +1470,7 @@ zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
1470 cam->state |= DEV_MISCONFIGURED; 1470 cam->state |= DEV_MISCONFIGURED;
1471 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To " 1471 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
1472 "use the camera, close and open /dev/video%d again.", 1472 "use the camera, close and open /dev/video%d again.",
1473 cam->v4ldev->minor); 1473 cam->v4ldev->num);
1474 return -EIO; 1474 return -EIO;
1475 } 1475 }
1476 1476
@@ -1482,7 +1482,7 @@ zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
1482 cam->state |= DEV_MISCONFIGURED; 1482 cam->state |= DEV_MISCONFIGURED;
1483 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To " 1483 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
1484 "use the camera, close and open /dev/video%d again.", 1484 "use the camera, close and open /dev/video%d again.",
1485 cam->v4ldev->minor); 1485 cam->v4ldev->num);
1486 return -ENOMEM; 1486 return -ENOMEM;
1487 } 1487 }
1488 1488
@@ -1529,7 +1529,7 @@ zc0301_vidioc_s_jpegcomp(struct zc0301_device* cam, void __user * arg)
1529 cam->state |= DEV_MISCONFIGURED; 1529 cam->state |= DEV_MISCONFIGURED;
1530 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware " 1530 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
1531 "problems. To use the camera, close and open " 1531 "problems. To use the camera, close and open "
1532 "/dev/video%d again.", cam->v4ldev->minor); 1532 "/dev/video%d again.", cam->v4ldev->num);
1533 return -EIO; 1533 return -EIO;
1534 } 1534 }
1535 1535
@@ -2005,7 +2005,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2005 goto fail; 2005 goto fail;
2006 } 2006 }
2007 2007
2008 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); 2008 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
2009 2009
2010 cam->module_param.force_munmap = force_munmap[dev_nr]; 2010 cam->module_param.force_munmap = force_munmap[dev_nr];
2011 cam->module_param.frame_timeout = frame_timeout[dev_nr]; 2011 cam->module_param.frame_timeout = frame_timeout[dev_nr];
@@ -2044,7 +2044,7 @@ static void zc0301_usb_disconnect(struct usb_interface* intf)
2044 if (cam->users) { 2044 if (cam->users) {
2045 DBG(2, "Device /dev/video%d is open! Deregistration and " 2045 DBG(2, "Device /dev/video%d is open! Deregistration and "
2046 "memory deallocation are deferred.", 2046 "memory deallocation are deferred.",
2047 cam->v4ldev->minor); 2047 cam->v4ldev->num);
2048 cam->state |= DEV_MISCONFIGURED; 2048 cam->state |= DEV_MISCONFIGURED;
2049 zc0301_stop_transfer(cam); 2049 zc0301_stop_transfer(cam);
2050 cam->state |= DEV_DISCONNECTED; 2050 cam->state |= DEV_DISCONNECTED;
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 7cdac99deea6..a1d81ed44c7c 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -885,7 +885,7 @@ static int zr364xx_probe(struct usb_interface *intf,
885 usb_set_intfdata(intf, cam); 885 usb_set_intfdata(intf, cam);
886 886
887 dev_info(&udev->dev, DRIVER_DESC " controlling video device %d\n", 887 dev_info(&udev->dev, DRIVER_DESC " controlling video device %d\n",
888 cam->vdev->minor); 888 cam->vdev->num);
889 return 0; 889 return 0;
890} 890}
891 891