diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-21 16:11:31 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:54 -0400 |
commit | 1df795370c1392a026c63816368108187aec2ec1 (patch) | |
tree | 3cdb3df8c2faee0521f9a15355774747b3f0ccf1 /drivers/media/video/usbvision/usbvision-video.c | |
parent | ab373190813a2e89f9ab7338c6b106804611f2b7 (diff) |
V4L/DVB (10692): usbvision: convert to v4l2_device/v4l2_subdev.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 334c77d9116f..cfa184d63c65 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -212,7 +212,7 @@ static ssize_t show_hue(struct device *cd, | |||
212 | ctrl.id = V4L2_CID_HUE; | 212 | ctrl.id = V4L2_CID_HUE; |
213 | ctrl.value = 0; | 213 | ctrl.value = 0; |
214 | if(usbvision->user) | 214 | if(usbvision->user) |
215 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 215 | call_all(usbvision, core, g_ctrl, &ctrl); |
216 | return sprintf(buf, "%d\n", ctrl.value); | 216 | return sprintf(buf, "%d\n", ctrl.value); |
217 | } | 217 | } |
218 | static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); | 218 | static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); |
@@ -227,7 +227,7 @@ static ssize_t show_contrast(struct device *cd, | |||
227 | ctrl.id = V4L2_CID_CONTRAST; | 227 | ctrl.id = V4L2_CID_CONTRAST; |
228 | ctrl.value = 0; | 228 | ctrl.value = 0; |
229 | if(usbvision->user) | 229 | if(usbvision->user) |
230 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 230 | call_all(usbvision, core, g_ctrl, &ctrl); |
231 | return sprintf(buf, "%d\n", ctrl.value); | 231 | return sprintf(buf, "%d\n", ctrl.value); |
232 | } | 232 | } |
233 | static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); | 233 | static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); |
@@ -242,7 +242,7 @@ static ssize_t show_brightness(struct device *cd, | |||
242 | ctrl.id = V4L2_CID_BRIGHTNESS; | 242 | ctrl.id = V4L2_CID_BRIGHTNESS; |
243 | ctrl.value = 0; | 243 | ctrl.value = 0; |
244 | if(usbvision->user) | 244 | if(usbvision->user) |
245 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 245 | call_all(usbvision, core, g_ctrl, &ctrl); |
246 | return sprintf(buf, "%d\n", ctrl.value); | 246 | return sprintf(buf, "%d\n", ctrl.value); |
247 | } | 247 | } |
248 | static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); | 248 | static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); |
@@ -257,7 +257,7 @@ static ssize_t show_saturation(struct device *cd, | |||
257 | ctrl.id = V4L2_CID_SATURATION; | 257 | ctrl.id = V4L2_CID_SATURATION; |
258 | ctrl.value = 0; | 258 | ctrl.value = 0; |
259 | if(usbvision->user) | 259 | if(usbvision->user) |
260 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 260 | call_all(usbvision, core, g_ctrl, &ctrl); |
261 | return sprintf(buf, "%d\n", ctrl.value); | 261 | return sprintf(buf, "%d\n", ctrl.value); |
262 | } | 262 | } |
263 | static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); | 263 | static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); |
@@ -622,8 +622,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
622 | usbvision->tvnormId=*id; | 622 | usbvision->tvnormId=*id; |
623 | 623 | ||
624 | mutex_lock(&usbvision->lock); | 624 | mutex_lock(&usbvision->lock); |
625 | call_i2c_clients(usbvision, VIDIOC_S_STD, | 625 | call_all(usbvision, tuner, s_std, usbvision->tvnormId); |
626 | &usbvision->tvnormId); | ||
627 | mutex_unlock(&usbvision->lock); | 626 | mutex_unlock(&usbvision->lock); |
628 | /* propagate the change to the decoder */ | 627 | /* propagate the change to the decoder */ |
629 | usbvision_muxsel(usbvision, usbvision->ctl_input); | 628 | usbvision_muxsel(usbvision, usbvision->ctl_input); |
@@ -645,7 +644,7 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
645 | strcpy(vt->name, "Television"); | 644 | strcpy(vt->name, "Television"); |
646 | } | 645 | } |
647 | /* Let clients fill in the remainder of this struct */ | 646 | /* Let clients fill in the remainder of this struct */ |
648 | call_i2c_clients(usbvision,VIDIOC_G_TUNER,vt); | 647 | call_all(usbvision, tuner, g_tuner, vt); |
649 | 648 | ||
650 | return 0; | 649 | return 0; |
651 | } | 650 | } |
@@ -659,7 +658,7 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
659 | if (!usbvision->have_tuner || vt->index) | 658 | if (!usbvision->have_tuner || vt->index) |
660 | return -EINVAL; | 659 | return -EINVAL; |
661 | /* let clients handle this */ | 660 | /* let clients handle this */ |
662 | call_i2c_clients(usbvision,VIDIOC_S_TUNER,vt); | 661 | call_all(usbvision, tuner, s_tuner, vt); |
663 | 662 | ||
664 | return 0; | 663 | return 0; |
665 | } | 664 | } |
@@ -690,7 +689,7 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
690 | return -EINVAL; | 689 | return -EINVAL; |
691 | 690 | ||
692 | usbvision->freq = freq->frequency; | 691 | usbvision->freq = freq->frequency; |
693 | call_i2c_clients(usbvision, VIDIOC_S_FREQUENCY, freq); | 692 | call_all(usbvision, tuner, s_frequency, freq); |
694 | 693 | ||
695 | return 0; | 694 | return 0; |
696 | } | 695 | } |
@@ -728,7 +727,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
728 | memset(ctrl,0,sizeof(*ctrl)); | 727 | memset(ctrl,0,sizeof(*ctrl)); |
729 | ctrl->id=id; | 728 | ctrl->id=id; |
730 | 729 | ||
731 | call_i2c_clients(usbvision, VIDIOC_QUERYCTRL, ctrl); | 730 | call_all(usbvision, core, queryctrl, ctrl); |
732 | 731 | ||
733 | if (!ctrl->type) | 732 | if (!ctrl->type) |
734 | return -EINVAL; | 733 | return -EINVAL; |
@@ -740,7 +739,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv, | |||
740 | struct v4l2_control *ctrl) | 739 | struct v4l2_control *ctrl) |
741 | { | 740 | { |
742 | struct usb_usbvision *usbvision = video_drvdata(file); | 741 | struct usb_usbvision *usbvision = video_drvdata(file); |
743 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); | 742 | call_all(usbvision, core, g_ctrl, ctrl); |
744 | 743 | ||
745 | return 0; | 744 | return 0; |
746 | } | 745 | } |
@@ -749,7 +748,7 @@ static int vidioc_s_ctrl (struct file *file, void *priv, | |||
749 | struct v4l2_control *ctrl) | 748 | struct v4l2_control *ctrl) |
750 | { | 749 | { |
751 | struct usb_usbvision *usbvision = video_drvdata(file); | 750 | struct usb_usbvision *usbvision = video_drvdata(file); |
752 | call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); | 751 | call_all(usbvision, core, s_ctrl, ctrl); |
753 | 752 | ||
754 | return 0; | 753 | return 0; |
755 | } | 754 | } |
@@ -900,10 +899,9 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
900 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | 899 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) |
901 | { | 900 | { |
902 | struct usb_usbvision *usbvision = video_drvdata(file); | 901 | struct usb_usbvision *usbvision = video_drvdata(file); |
903 | int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
904 | 902 | ||
905 | usbvision->streaming = Stream_On; | 903 | usbvision->streaming = Stream_On; |
906 | call_i2c_clients(usbvision,VIDIOC_STREAMON , &b); | 904 | call_all(usbvision, video, s_stream, 1); |
907 | 905 | ||
908 | return 0; | 906 | return 0; |
909 | } | 907 | } |
@@ -912,7 +910,6 @@ static int vidioc_streamoff(struct file *file, | |||
912 | void *priv, enum v4l2_buf_type type) | 910 | void *priv, enum v4l2_buf_type type) |
913 | { | 911 | { |
914 | struct usb_usbvision *usbvision = video_drvdata(file); | 912 | struct usb_usbvision *usbvision = video_drvdata(file); |
915 | int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
916 | 913 | ||
917 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 914 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
918 | return -EINVAL; | 915 | return -EINVAL; |
@@ -920,7 +917,7 @@ static int vidioc_streamoff(struct file *file, | |||
920 | if(usbvision->streaming == Stream_On) { | 917 | if(usbvision->streaming == Stream_On) { |
921 | usbvision_stream_interrupt(usbvision); | 918 | usbvision_stream_interrupt(usbvision); |
922 | /* Stop all video streamings */ | 919 | /* Stop all video streamings */ |
923 | call_i2c_clients(usbvision,VIDIOC_STREAMOFF , &b); | 920 | call_all(usbvision, video, s_stream, 0); |
924 | } | 921 | } |
925 | usbvision_empty_framequeues(usbvision); | 922 | usbvision_empty_framequeues(usbvision); |
926 | 923 | ||
@@ -1043,7 +1040,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1043 | if(usbvision->streaming != Stream_On) { | 1040 | if(usbvision->streaming != Stream_On) { |
1044 | /* no stream is running, make it running ! */ | 1041 | /* no stream is running, make it running ! */ |
1045 | usbvision->streaming = Stream_On; | 1042 | usbvision->streaming = Stream_On; |
1046 | call_i2c_clients(usbvision,VIDIOC_STREAMON , NULL); | 1043 | call_all(usbvision, video, s_stream, 1); |
1047 | } | 1044 | } |
1048 | 1045 | ||
1049 | /* Then, enqueue as many frames as possible | 1046 | /* Then, enqueue as many frames as possible |
@@ -1214,7 +1211,7 @@ static int usbvision_radio_open(struct file *file) | |||
1214 | 1211 | ||
1215 | // If so far no errors then we shall start the radio | 1212 | // If so far no errors then we shall start the radio |
1216 | usbvision->radio = 1; | 1213 | usbvision->radio = 1; |
1217 | call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); | 1214 | call_all(usbvision, tuner, s_radio); |
1218 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); | 1215 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); |
1219 | usbvision->user++; | 1216 | usbvision->user++; |
1220 | } | 1217 | } |
@@ -1427,7 +1424,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
1427 | } | 1424 | } |
1428 | *vdev = *vdev_template; | 1425 | *vdev = *vdev_template; |
1429 | // vdev->minor = -1; | 1426 | // vdev->minor = -1; |
1430 | vdev->parent = &usb_dev->dev; | 1427 | vdev->v4l2_dev = &usbvision->v4l2_dev; |
1431 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); | 1428 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); |
1432 | video_set_drvdata(vdev, usbvision); | 1429 | video_set_drvdata(vdev, usbvision); |
1433 | return vdev; | 1430 | return vdev; |
@@ -1548,33 +1545,30 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev) | |||
1548 | { | 1545 | { |
1549 | struct usb_usbvision *usbvision; | 1546 | struct usb_usbvision *usbvision; |
1550 | 1547 | ||
1551 | if ((usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL)) == | 1548 | usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL); |
1552 | NULL) { | 1549 | if (usbvision == NULL) |
1553 | goto err_exit; | 1550 | return NULL; |
1554 | } | ||
1555 | 1551 | ||
1556 | usbvision->dev = dev; | 1552 | usbvision->dev = dev; |
1553 | if (v4l2_device_register(&dev->dev, &usbvision->v4l2_dev)) | ||
1554 | goto err_free; | ||
1557 | 1555 | ||
1558 | mutex_init(&usbvision->lock); /* available */ | 1556 | mutex_init(&usbvision->lock); /* available */ |
1559 | 1557 | ||
1560 | // prepare control urb for control messages during interrupts | 1558 | // prepare control urb for control messages during interrupts |
1561 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); | 1559 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); |
1562 | if (usbvision->ctrlUrb == NULL) { | 1560 | if (usbvision->ctrlUrb == NULL) |
1563 | goto err_exit; | 1561 | goto err_unreg; |
1564 | } | ||
1565 | init_waitqueue_head(&usbvision->ctrlUrb_wq); | 1562 | init_waitqueue_head(&usbvision->ctrlUrb_wq); |
1566 | 1563 | ||
1567 | usbvision_init_powerOffTimer(usbvision); | 1564 | usbvision_init_powerOffTimer(usbvision); |
1568 | 1565 | ||
1569 | return usbvision; | 1566 | return usbvision; |
1570 | 1567 | ||
1571 | err_exit: | 1568 | err_unreg: |
1572 | if (usbvision && usbvision->ctrlUrb) { | 1569 | v4l2_device_unregister(&usbvision->v4l2_dev); |
1573 | usb_free_urb(usbvision->ctrlUrb); | 1570 | err_free: |
1574 | } | 1571 | kfree(usbvision); |
1575 | if (usbvision) { | ||
1576 | kfree(usbvision); | ||
1577 | } | ||
1578 | return NULL; | 1572 | return NULL; |
1579 | } | 1573 | } |
1580 | 1574 | ||
@@ -1604,6 +1598,7 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1604 | usb_free_urb(usbvision->ctrlUrb); | 1598 | usb_free_urb(usbvision->ctrlUrb); |
1605 | } | 1599 | } |
1606 | 1600 | ||
1601 | v4l2_device_unregister(&usbvision->v4l2_dev); | ||
1607 | kfree(usbvision); | 1602 | kfree(usbvision); |
1608 | 1603 | ||
1609 | PDEBUG(DBG_PROBE, "success"); | 1604 | PDEBUG(DBG_PROBE, "success"); |
@@ -1739,8 +1734,6 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1739 | usbvision->tuner_type = usbvision_device_data[model].TunerType; | 1734 | usbvision->tuner_type = usbvision_device_data[model].TunerType; |
1740 | } | 1735 | } |
1741 | 1736 | ||
1742 | usbvision->tuner_addr = ADDR_UNSET; | ||
1743 | |||
1744 | usbvision->DevModel = model; | 1737 | usbvision->DevModel = model; |
1745 | usbvision->remove_pending = 0; | 1738 | usbvision->remove_pending = 0; |
1746 | usbvision->iface = ifnum; | 1739 | usbvision->iface = ifnum; |