diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-07-02 04:51:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:36:00 -0400 |
commit | 2e43dec0eeb6bca13212b583e750b0aed1c51cd1 (patch) | |
tree | 57f36781791a7dcec7ee912ad0ad45d18479b2ac /drivers/media | |
parent | cc4b7e7f5755d304ffbfc1d44c11ba8e981347b0 (diff) |
[media] pwc: use the new vb2 helpers
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 171 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-v4l.c | 140 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc.h | 3 |
3 files changed, 26 insertions, 288 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index ec4e2ef54e65..de7c7ba99ef4 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -136,19 +136,13 @@ static int leds[2] = { 100, 0 }; | |||
136 | 136 | ||
137 | /***/ | 137 | /***/ |
138 | 138 | ||
139 | static int pwc_video_close(struct file *file); | ||
140 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | ||
141 | size_t count, loff_t *ppos); | ||
142 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); | ||
143 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); | ||
144 | |||
145 | static const struct v4l2_file_operations pwc_fops = { | 139 | static const struct v4l2_file_operations pwc_fops = { |
146 | .owner = THIS_MODULE, | 140 | .owner = THIS_MODULE, |
147 | .open = v4l2_fh_open, | 141 | .open = v4l2_fh_open, |
148 | .release = pwc_video_close, | 142 | .release = vb2_fop_release, |
149 | .read = pwc_video_read, | 143 | .read = vb2_fop_read, |
150 | .poll = pwc_video_poll, | 144 | .poll = vb2_fop_poll, |
151 | .mmap = pwc_video_mmap, | 145 | .mmap = vb2_fop_mmap, |
152 | .unlocked_ioctl = video_ioctl2, | 146 | .unlocked_ioctl = video_ioctl2, |
153 | }; | 147 | }; |
154 | static struct video_device pwc_template = { | 148 | static struct video_device pwc_template = { |
@@ -562,17 +556,6 @@ static const char *pwc_sensor_type_to_string(unsigned int sensor_type) | |||
562 | /***************************************************************************/ | 556 | /***************************************************************************/ |
563 | /* Video4Linux functions */ | 557 | /* Video4Linux functions */ |
564 | 558 | ||
565 | int pwc_test_n_set_capt_file(struct pwc_device *pdev, struct file *file) | ||
566 | { | ||
567 | if (pdev->capt_file != NULL && | ||
568 | pdev->capt_file != file) | ||
569 | return -EBUSY; | ||
570 | |||
571 | pdev->capt_file = file; | ||
572 | |||
573 | return 0; | ||
574 | } | ||
575 | |||
576 | static void pwc_video_release(struct v4l2_device *v) | 559 | static void pwc_video_release(struct v4l2_device *v) |
577 | { | 560 | { |
578 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); | 561 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); |
@@ -583,113 +566,6 @@ static void pwc_video_release(struct v4l2_device *v) | |||
583 | kfree(pdev); | 566 | kfree(pdev); |
584 | } | 567 | } |
585 | 568 | ||
586 | static int pwc_video_close(struct file *file) | ||
587 | { | ||
588 | struct pwc_device *pdev = video_drvdata(file); | ||
589 | |||
590 | /* | ||
591 | * If we're still streaming vb2_queue_release will call stream_stop | ||
592 | * so we must take both the v4l2_lock and the vb_queue_lock. | ||
593 | */ | ||
594 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
595 | return -ERESTARTSYS; | ||
596 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) { | ||
597 | mutex_unlock(&pdev->v4l2_lock); | ||
598 | return -ERESTARTSYS; | ||
599 | } | ||
600 | |||
601 | if (pdev->capt_file == file) { | ||
602 | vb2_queue_release(&pdev->vb_queue); | ||
603 | pdev->capt_file = NULL; | ||
604 | } | ||
605 | |||
606 | mutex_unlock(&pdev->vb_queue_lock); | ||
607 | mutex_unlock(&pdev->v4l2_lock); | ||
608 | |||
609 | return v4l2_fh_release(file); | ||
610 | } | ||
611 | |||
612 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | ||
613 | size_t count, loff_t *ppos) | ||
614 | { | ||
615 | struct pwc_device *pdev = video_drvdata(file); | ||
616 | int lock_v4l2 = 0; | ||
617 | ssize_t ret; | ||
618 | |||
619 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
620 | return -ERESTARTSYS; | ||
621 | |||
622 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
623 | if (ret) | ||
624 | goto out; | ||
625 | |||
626 | /* stream_start will get called so we must take the v4l2_lock */ | ||
627 | if (pdev->vb_queue.fileio == NULL) | ||
628 | lock_v4l2 = 1; | ||
629 | |||
630 | /* Use try_lock, since we're taking the locks in the *wrong* order! */ | ||
631 | if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) { | ||
632 | ret = -ERESTARTSYS; | ||
633 | goto out; | ||
634 | } | ||
635 | ret = vb2_read(&pdev->vb_queue, buf, count, ppos, | ||
636 | file->f_flags & O_NONBLOCK); | ||
637 | if (lock_v4l2) | ||
638 | mutex_unlock(&pdev->v4l2_lock); | ||
639 | out: | ||
640 | mutex_unlock(&pdev->vb_queue_lock); | ||
641 | return ret; | ||
642 | } | ||
643 | |||
644 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | ||
645 | { | ||
646 | struct pwc_device *pdev = video_drvdata(file); | ||
647 | struct vb2_queue *q = &pdev->vb_queue; | ||
648 | unsigned long req_events = poll_requested_events(wait); | ||
649 | unsigned int ret = POLL_ERR; | ||
650 | int lock_v4l2 = 0; | ||
651 | |||
652 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
653 | return POLL_ERR; | ||
654 | |||
655 | /* Will this start fileio and thus call start_stream? */ | ||
656 | if ((req_events & (POLLIN | POLLRDNORM)) && | ||
657 | q->num_buffers == 0 && !q->streaming && q->fileio == NULL) { | ||
658 | if (pwc_test_n_set_capt_file(pdev, file)) | ||
659 | goto out; | ||
660 | lock_v4l2 = 1; | ||
661 | } | ||
662 | |||
663 | /* Use try_lock, since we're taking the locks in the *wrong* order! */ | ||
664 | if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) | ||
665 | goto out; | ||
666 | ret = vb2_poll(&pdev->vb_queue, file, wait); | ||
667 | if (lock_v4l2) | ||
668 | mutex_unlock(&pdev->v4l2_lock); | ||
669 | |||
670 | out: | ||
671 | if (!pdev->udev) | ||
672 | ret |= POLLHUP; | ||
673 | mutex_unlock(&pdev->vb_queue_lock); | ||
674 | return ret; | ||
675 | } | ||
676 | |||
677 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | ||
678 | { | ||
679 | struct pwc_device *pdev = video_drvdata(file); | ||
680 | int ret; | ||
681 | |||
682 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
683 | return -ERESTARTSYS; | ||
684 | |||
685 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
686 | if (ret == 0) | ||
687 | ret = vb2_mmap(&pdev->vb_queue, vma); | ||
688 | |||
689 | mutex_unlock(&pdev->vb_queue_lock); | ||
690 | return ret; | ||
691 | } | ||
692 | |||
693 | /***************************************************************************/ | 569 | /***************************************************************************/ |
694 | /* Videobuf2 operations */ | 570 | /* Videobuf2 operations */ |
695 | 571 | ||
@@ -782,6 +658,8 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) | |||
782 | if (!pdev->udev) | 658 | if (!pdev->udev) |
783 | return -ENODEV; | 659 | return -ENODEV; |
784 | 660 | ||
661 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
662 | return -ERESTARTSYS; | ||
785 | /* Turn on camera and set LEDS on */ | 663 | /* Turn on camera and set LEDS on */ |
786 | pwc_camera_power(pdev, 1); | 664 | pwc_camera_power(pdev, 1); |
787 | pwc_set_leds(pdev, leds[0], leds[1]); | 665 | pwc_set_leds(pdev, leds[0], leds[1]); |
@@ -794,6 +672,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) | |||
794 | /* And cleanup any queued bufs!! */ | 672 | /* And cleanup any queued bufs!! */ |
795 | pwc_cleanup_queued_bufs(pdev); | 673 | pwc_cleanup_queued_bufs(pdev); |
796 | } | 674 | } |
675 | mutex_unlock(&pdev->v4l2_lock); | ||
797 | 676 | ||
798 | return r; | 677 | return r; |
799 | } | 678 | } |
@@ -802,6 +681,8 @@ static int stop_streaming(struct vb2_queue *vq) | |||
802 | { | 681 | { |
803 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | 682 | struct pwc_device *pdev = vb2_get_drv_priv(vq); |
804 | 683 | ||
684 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
685 | return -ERESTARTSYS; | ||
805 | if (pdev->udev) { | 686 | if (pdev->udev) { |
806 | pwc_set_leds(pdev, 0, 0); | 687 | pwc_set_leds(pdev, 0, 0); |
807 | pwc_camera_power(pdev, 0); | 688 | pwc_camera_power(pdev, 0); |
@@ -809,22 +690,11 @@ static int stop_streaming(struct vb2_queue *vq) | |||
809 | } | 690 | } |
810 | 691 | ||
811 | pwc_cleanup_queued_bufs(pdev); | 692 | pwc_cleanup_queued_bufs(pdev); |
693 | mutex_unlock(&pdev->v4l2_lock); | ||
812 | 694 | ||
813 | return 0; | 695 | return 0; |
814 | } | 696 | } |
815 | 697 | ||
816 | static void wait_prepare(struct vb2_queue *vq) | ||
817 | { | ||
818 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | ||
819 | mutex_unlock(&pdev->vb_queue_lock); | ||
820 | } | ||
821 | |||
822 | static void wait_finish(struct vb2_queue *vq) | ||
823 | { | ||
824 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | ||
825 | mutex_lock(&pdev->vb_queue_lock); | ||
826 | } | ||
827 | |||
828 | static struct vb2_ops pwc_vb_queue_ops = { | 698 | static struct vb2_ops pwc_vb_queue_ops = { |
829 | .queue_setup = queue_setup, | 699 | .queue_setup = queue_setup, |
830 | .buf_init = buffer_init, | 700 | .buf_init = buffer_init, |
@@ -834,8 +704,8 @@ static struct vb2_ops pwc_vb_queue_ops = { | |||
834 | .buf_queue = buffer_queue, | 704 | .buf_queue = buffer_queue, |
835 | .start_streaming = start_streaming, | 705 | .start_streaming = start_streaming, |
836 | .stop_streaming = stop_streaming, | 706 | .stop_streaming = stop_streaming, |
837 | .wait_prepare = wait_prepare, | 707 | .wait_prepare = vb2_ops_wait_prepare, |
838 | .wait_finish = wait_finish, | 708 | .wait_finish = vb2_ops_wait_finish, |
839 | }; | 709 | }; |
840 | 710 | ||
841 | /***************************************************************************/ | 711 | /***************************************************************************/ |
@@ -1136,6 +1006,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1136 | /* Init video_device structure */ | 1006 | /* Init video_device structure */ |
1137 | memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1007 | memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); |
1138 | strcpy(pdev->vdev.name, name); | 1008 | strcpy(pdev->vdev.name, name); |
1009 | pdev->vdev.queue = &pdev->vb_queue; | ||
1010 | pdev->vdev.queue->lock = &pdev->vb_queue_lock; | ||
1139 | set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags); | 1011 | set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags); |
1140 | video_set_drvdata(&pdev->vdev, pdev); | 1012 | video_set_drvdata(&pdev->vdev, pdev); |
1141 | 1013 | ||
@@ -1190,15 +1062,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1190 | pdev->vdev.v4l2_dev = &pdev->v4l2_dev; | 1062 | pdev->vdev.v4l2_dev = &pdev->v4l2_dev; |
1191 | pdev->vdev.lock = &pdev->v4l2_lock; | 1063 | pdev->vdev.lock = &pdev->v4l2_lock; |
1192 | 1064 | ||
1193 | /* | ||
1194 | * Don't take v4l2_lock for these ioctls. This improves latency if | ||
1195 | * v4l2_lock is taken for a long time, e.g. when changing a control | ||
1196 | * value, and a new frame is ready to be dequeued. | ||
1197 | */ | ||
1198 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_DQBUF); | ||
1199 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_QBUF); | ||
1200 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_QUERYBUF); | ||
1201 | |||
1202 | rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1); | 1065 | rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1); |
1203 | if (rc < 0) { | 1066 | if (rc < 0) { |
1204 | PWC_ERROR("Failed to register as video device (%d).\n", rc); | 1067 | PWC_ERROR("Failed to register as video device (%d).\n", rc); |
@@ -1253,20 +1116,18 @@ static void usb_pwc_disconnect(struct usb_interface *intf) | |||
1253 | struct v4l2_device *v = usb_get_intfdata(intf); | 1116 | struct v4l2_device *v = usb_get_intfdata(intf); |
1254 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); | 1117 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); |
1255 | 1118 | ||
1256 | mutex_lock(&pdev->v4l2_lock); | ||
1257 | |||
1258 | mutex_lock(&pdev->vb_queue_lock); | 1119 | mutex_lock(&pdev->vb_queue_lock); |
1120 | mutex_lock(&pdev->v4l2_lock); | ||
1259 | /* No need to keep the urbs around after disconnection */ | 1121 | /* No need to keep the urbs around after disconnection */ |
1260 | if (pdev->vb_queue.streaming) | 1122 | if (pdev->vb_queue.streaming) |
1261 | pwc_isoc_cleanup(pdev); | 1123 | pwc_isoc_cleanup(pdev); |
1262 | pdev->udev = NULL; | 1124 | pdev->udev = NULL; |
1263 | pwc_cleanup_queued_bufs(pdev); | 1125 | pwc_cleanup_queued_bufs(pdev); |
1264 | mutex_unlock(&pdev->vb_queue_lock); | ||
1265 | 1126 | ||
1266 | v4l2_device_disconnect(&pdev->v4l2_dev); | 1127 | v4l2_device_disconnect(&pdev->v4l2_dev); |
1267 | video_unregister_device(&pdev->vdev); | 1128 | video_unregister_device(&pdev->vdev); |
1268 | |||
1269 | mutex_unlock(&pdev->v4l2_lock); | 1129 | mutex_unlock(&pdev->v4l2_lock); |
1130 | mutex_unlock(pdev->vb_queue.lock); | ||
1270 | 1131 | ||
1271 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV | 1132 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV |
1272 | if (pdev->button_dev) | 1133 | if (pdev->button_dev) |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index c691e29cc36e..114ae41bc4af 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -468,17 +468,8 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | |||
468 | if (ret < 0) | 468 | if (ret < 0) |
469 | return ret; | 469 | return ret; |
470 | 470 | ||
471 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | 471 | if (vb2_is_busy(&pdev->vb_queue)) |
472 | return -ERESTARTSYS; | 472 | return -EBUSY; |
473 | |||
474 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
475 | if (ret) | ||
476 | goto leave; | ||
477 | |||
478 | if (pdev->vb_queue.streaming) { | ||
479 | ret = -EBUSY; | ||
480 | goto leave; | ||
481 | } | ||
482 | 473 | ||
483 | pixelformat = f->fmt.pix.pixelformat; | 474 | pixelformat = f->fmt.pix.pixelformat; |
484 | 475 | ||
@@ -496,8 +487,6 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | |||
496 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); | 487 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); |
497 | 488 | ||
498 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); | 489 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); |
499 | leave: | ||
500 | mutex_unlock(&pdev->vb_queue_lock); | ||
501 | return ret; | 490 | return ret; |
502 | } | 491 | } |
503 | 492 | ||
@@ -933,104 +922,6 @@ static int pwc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format * | |||
933 | return pwc_vidioc_try_fmt(pdev, f); | 922 | return pwc_vidioc_try_fmt(pdev, f); |
934 | } | 923 | } |
935 | 924 | ||
936 | static int pwc_reqbufs(struct file *file, void *fh, | ||
937 | struct v4l2_requestbuffers *rb) | ||
938 | { | ||
939 | struct pwc_device *pdev = video_drvdata(file); | ||
940 | int ret; | ||
941 | |||
942 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
943 | return -ERESTARTSYS; | ||
944 | |||
945 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
946 | if (ret == 0) | ||
947 | ret = vb2_reqbufs(&pdev->vb_queue, rb); | ||
948 | |||
949 | mutex_unlock(&pdev->vb_queue_lock); | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | static int pwc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
954 | { | ||
955 | struct pwc_device *pdev = video_drvdata(file); | ||
956 | int ret; | ||
957 | |||
958 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
959 | return -ERESTARTSYS; | ||
960 | |||
961 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
962 | if (ret == 0) | ||
963 | ret = vb2_querybuf(&pdev->vb_queue, buf); | ||
964 | |||
965 | mutex_unlock(&pdev->vb_queue_lock); | ||
966 | return ret; | ||
967 | } | ||
968 | |||
969 | static int pwc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
970 | { | ||
971 | struct pwc_device *pdev = video_drvdata(file); | ||
972 | int ret; | ||
973 | |||
974 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
975 | return -ERESTARTSYS; | ||
976 | |||
977 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
978 | if (ret == 0) | ||
979 | ret = vb2_qbuf(&pdev->vb_queue, buf); | ||
980 | |||
981 | mutex_unlock(&pdev->vb_queue_lock); | ||
982 | return ret; | ||
983 | } | ||
984 | |||
985 | static int pwc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
986 | { | ||
987 | struct pwc_device *pdev = video_drvdata(file); | ||
988 | int ret; | ||
989 | |||
990 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
991 | return -ERESTARTSYS; | ||
992 | |||
993 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
994 | if (ret == 0) | ||
995 | ret = vb2_dqbuf(&pdev->vb_queue, buf, | ||
996 | file->f_flags & O_NONBLOCK); | ||
997 | |||
998 | mutex_unlock(&pdev->vb_queue_lock); | ||
999 | return ret; | ||
1000 | } | ||
1001 | |||
1002 | static int pwc_streamon(struct file *file, void *fh, enum v4l2_buf_type i) | ||
1003 | { | ||
1004 | struct pwc_device *pdev = video_drvdata(file); | ||
1005 | int ret; | ||
1006 | |||
1007 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
1008 | return -ERESTARTSYS; | ||
1009 | |||
1010 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
1011 | if (ret == 0) | ||
1012 | ret = vb2_streamon(&pdev->vb_queue, i); | ||
1013 | |||
1014 | mutex_unlock(&pdev->vb_queue_lock); | ||
1015 | return ret; | ||
1016 | } | ||
1017 | |||
1018 | static int pwc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i) | ||
1019 | { | ||
1020 | struct pwc_device *pdev = video_drvdata(file); | ||
1021 | int ret; | ||
1022 | |||
1023 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
1024 | return -ERESTARTSYS; | ||
1025 | |||
1026 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
1027 | if (ret == 0) | ||
1028 | ret = vb2_streamoff(&pdev->vb_queue, i); | ||
1029 | |||
1030 | mutex_unlock(&pdev->vb_queue_lock); | ||
1031 | return ret; | ||
1032 | } | ||
1033 | |||
1034 | static int pwc_enum_framesizes(struct file *file, void *fh, | 925 | static int pwc_enum_framesizes(struct file *file, void *fh, |
1035 | struct v4l2_frmsizeenum *fsize) | 926 | struct v4l2_frmsizeenum *fsize) |
1036 | { | 927 | { |
@@ -1119,25 +1010,14 @@ static int pwc_s_parm(struct file *file, void *fh, | |||
1119 | fps = parm->parm.capture.timeperframe.denominator / | 1010 | fps = parm->parm.capture.timeperframe.denominator / |
1120 | parm->parm.capture.timeperframe.numerator; | 1011 | parm->parm.capture.timeperframe.numerator; |
1121 | 1012 | ||
1122 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | 1013 | if (vb2_is_busy(&pdev->vb_queue)) |
1123 | return -ERESTARTSYS; | 1014 | return -EBUSY; |
1124 | |||
1125 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
1126 | if (ret) | ||
1127 | goto leave; | ||
1128 | |||
1129 | if (pdev->vb_queue.streaming) { | ||
1130 | ret = -EBUSY; | ||
1131 | goto leave; | ||
1132 | } | ||
1133 | 1015 | ||
1134 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, | 1016 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, |
1135 | fps, &compression, 0); | 1017 | fps, &compression, 0); |
1136 | 1018 | ||
1137 | pwc_g_parm(file, fh, parm); | 1019 | pwc_g_parm(file, fh, parm); |
1138 | 1020 | ||
1139 | leave: | ||
1140 | mutex_unlock(&pdev->vb_queue_lock); | ||
1141 | return ret; | 1021 | return ret; |
1142 | } | 1022 | } |
1143 | 1023 | ||
@@ -1150,12 +1030,12 @@ const struct v4l2_ioctl_ops pwc_ioctl_ops = { | |||
1150 | .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap, | 1030 | .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap, |
1151 | .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap, | 1031 | .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap, |
1152 | .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap, | 1032 | .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap, |
1153 | .vidioc_reqbufs = pwc_reqbufs, | 1033 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1154 | .vidioc_querybuf = pwc_querybuf, | 1034 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1155 | .vidioc_qbuf = pwc_qbuf, | 1035 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1156 | .vidioc_dqbuf = pwc_dqbuf, | 1036 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1157 | .vidioc_streamon = pwc_streamon, | 1037 | .vidioc_streamon = vb2_ioctl_streamon, |
1158 | .vidioc_streamoff = pwc_streamoff, | 1038 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1159 | .vidioc_log_status = v4l2_ctrl_log_status, | 1039 | .vidioc_log_status = v4l2_ctrl_log_status, |
1160 | .vidioc_enum_framesizes = pwc_enum_framesizes, | 1040 | .vidioc_enum_framesizes = pwc_enum_framesizes, |
1161 | .vidioc_enum_frameintervals = pwc_enum_frameintervals, | 1041 | .vidioc_enum_frameintervals = pwc_enum_frameintervals, |
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index d6b5b216b9d6..7a6a0d39c2c6 100644 --- a/drivers/media/video/pwc/pwc.h +++ b/drivers/media/video/pwc/pwc.h | |||
@@ -239,7 +239,6 @@ struct pwc_device | |||
239 | int features; /* feature bits */ | 239 | int features; /* feature bits */ |
240 | 240 | ||
241 | /*** Video data ***/ | 241 | /*** Video data ***/ |
242 | struct file *capt_file; /* file doing video capture */ | ||
243 | int vendpoint; /* video isoc endpoint */ | 242 | int vendpoint; /* video isoc endpoint */ |
244 | int vcinterface; /* video control interface */ | 243 | int vcinterface; /* video control interface */ |
245 | int valternate; /* alternate interface needed */ | 244 | int valternate; /* alternate interface needed */ |
@@ -355,8 +354,6 @@ struct pwc_device | |||
355 | extern int pwc_trace; | 354 | extern int pwc_trace; |
356 | #endif | 355 | #endif |
357 | 356 | ||
358 | int pwc_test_n_set_capt_file(struct pwc_device *pdev, struct file *file); | ||
359 | |||
360 | /** Functions in pwc-misc.c */ | 357 | /** Functions in pwc-misc.c */ |
361 | /* sizes in pixels */ | 358 | /* sizes in pixels */ |
362 | extern const int pwc_image_sizes[PSZ_MAX][2]; | 359 | extern const int pwc_image_sizes[PSZ_MAX][2]; |