aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-10-13 09:11:35 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-25 05:39:14 -0500
commitb83bba24a29c44b696b5977e3874bc07b13dc3c0 (patch)
tree0379cb6f3b164dc253713c14e9246d7acee5af43 /drivers/media
parentaa3d17df6470338223f7ae6893647453e8f8e98e (diff)
[media] uvcvideo: Separate video and queue enable/disable operations
In order to make use of the vb2 queue start/stop_streaming operations the video and queue enable/disable operations need to be split, as the vb2 queue will need to enable and disable video instead of the other way around. Also move buffer queue disable outside of uvc_video_resume() to remove all queue disable operations out of uvc_video.c. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c16
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c15
-rw-r--r--drivers/media/usb/uvc/uvc_video.c22
3 files changed, 26 insertions, 27 deletions
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 30163432a711..ab1e2fd0a599 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1734,6 +1734,11 @@ static int uvc_register_video(struct uvc_device *dev,
1734 struct video_device *vdev; 1734 struct video_device *vdev;
1735 int ret; 1735 int ret;
1736 1736
1737 /* Initialize the video buffers queue. */
1738 ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param);
1739 if (ret)
1740 return ret;
1741
1737 /* Initialize the streaming interface with default streaming 1742 /* Initialize the streaming interface with default streaming
1738 * parameters. 1743 * parameters.
1739 */ 1744 */
@@ -2008,14 +2013,13 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
2008{ 2013{
2009 struct uvc_device *dev = usb_get_intfdata(intf); 2014 struct uvc_device *dev = usb_get_intfdata(intf);
2010 struct uvc_streaming *stream; 2015 struct uvc_streaming *stream;
2016 int ret = 0;
2011 2017
2012 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", 2018 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n",
2013 intf->cur_altsetting->desc.bInterfaceNumber); 2019 intf->cur_altsetting->desc.bInterfaceNumber);
2014 2020
2015 if (intf->cur_altsetting->desc.bInterfaceSubClass == 2021 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2016 UVC_SC_VIDEOCONTROL) { 2022 UVC_SC_VIDEOCONTROL) {
2017 int ret = 0;
2018
2019 if (reset) { 2023 if (reset) {
2020 ret = uvc_ctrl_restore_values(dev); 2024 ret = uvc_ctrl_restore_values(dev);
2021 if (ret < 0) 2025 if (ret < 0)
@@ -2031,8 +2035,12 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
2031 } 2035 }
2032 2036
2033 list_for_each_entry(stream, &dev->streams, list) { 2037 list_for_each_entry(stream, &dev->streams, list) {
2034 if (stream->intf == intf) 2038 if (stream->intf == intf) {
2035 return uvc_video_resume(stream, reset); 2039 ret = uvc_video_resume(stream, reset);
2040 if (ret < 0)
2041 uvc_queue_enable(&stream->queue, 0);
2042 return ret;
2043 }
2036 } 2044 }
2037 2045
2038 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface " 2046 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index a16fe2167976..e8bf4f149a26 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -532,6 +532,7 @@ static int uvc_v4l2_release(struct file *file)
532 /* Only free resources if this is a privileged handle. */ 532 /* Only free resources if this is a privileged handle. */
533 if (uvc_has_privileges(handle)) { 533 if (uvc_has_privileges(handle)) {
534 uvc_video_enable(stream, 0); 534 uvc_video_enable(stream, 0);
535 uvc_queue_enable(&stream->queue, 0);
535 uvc_free_buffers(&stream->queue); 536 uvc_free_buffers(&stream->queue);
536 } 537 }
537 538
@@ -766,7 +767,15 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
766 return -EBUSY; 767 return -EBUSY;
767 768
768 mutex_lock(&stream->mutex); 769 mutex_lock(&stream->mutex);
770 ret = uvc_queue_enable(&stream->queue, 1);
771 if (ret < 0)
772 goto done;
773
769 ret = uvc_video_enable(stream, 1); 774 ret = uvc_video_enable(stream, 1);
775 if (ret < 0)
776 uvc_queue_enable(&stream->queue, 0);
777
778done:
770 mutex_unlock(&stream->mutex); 779 mutex_unlock(&stream->mutex);
771 780
772 return ret; 781 return ret;
@@ -777,7 +786,6 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
777{ 786{
778 struct uvc_fh *handle = fh; 787 struct uvc_fh *handle = fh;
779 struct uvc_streaming *stream = handle->stream; 788 struct uvc_streaming *stream = handle->stream;
780 int ret;
781 789
782 if (type != stream->type) 790 if (type != stream->type)
783 return -EINVAL; 791 return -EINVAL;
@@ -786,10 +794,11 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
786 return -EBUSY; 794 return -EBUSY;
787 795
788 mutex_lock(&stream->mutex); 796 mutex_lock(&stream->mutex);
789 ret = uvc_video_enable(stream, 0); 797 uvc_video_enable(stream, 0);
798 uvc_queue_enable(&stream->queue, 0);
790 mutex_unlock(&stream->mutex); 799 mutex_unlock(&stream->mutex);
791 800
792 return ret; 801 return 0;
793} 802}
794 803
795static int uvc_ioctl_enum_input(struct file *file, void *fh, 804static int uvc_ioctl_enum_input(struct file *file, void *fh,
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index b9c7dee8e7b3..9637e8b86949 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1735,19 +1735,13 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
1735 uvc_video_clock_reset(stream); 1735 uvc_video_clock_reset(stream);
1736 1736
1737 ret = uvc_commit_video(stream, &stream->ctrl); 1737 ret = uvc_commit_video(stream, &stream->ctrl);
1738 if (ret < 0) { 1738 if (ret < 0)
1739 uvc_queue_enable(&stream->queue, 0);
1740 return ret; 1739 return ret;
1741 }
1742 1740
1743 if (!uvc_queue_streaming(&stream->queue)) 1741 if (!uvc_queue_streaming(&stream->queue))
1744 return 0; 1742 return 0;
1745 1743
1746 ret = uvc_init_video(stream, GFP_NOIO); 1744 return uvc_init_video(stream, GFP_NOIO);
1747 if (ret < 0)
1748 uvc_queue_enable(&stream->queue, 0);
1749
1750 return ret;
1751} 1745}
1752 1746
1753/* ------------------------------------------------------------------------ 1747/* ------------------------------------------------------------------------
@@ -1779,11 +1773,6 @@ int uvc_video_init(struct uvc_streaming *stream)
1779 1773
1780 atomic_set(&stream->active, 0); 1774 atomic_set(&stream->active, 0);
1781 1775
1782 /* Initialize the video buffers queue. */
1783 ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param);
1784 if (ret)
1785 return ret;
1786
1787 /* Alternate setting 0 should be the default, yet the XBox Live Vision 1776 /* Alternate setting 0 should be the default, yet the XBox Live Vision
1788 * Cam (and possibly other devices) crash or otherwise misbehave if 1777 * Cam (and possibly other devices) crash or otherwise misbehave if
1789 * they don't receive a SET_INTERFACE request before any other video 1778 * they don't receive a SET_INTERFACE request before any other video
@@ -1890,7 +1879,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1890 usb_clear_halt(stream->dev->udev, pipe); 1879 usb_clear_halt(stream->dev->udev, pipe);
1891 } 1880 }
1892 1881
1893 uvc_queue_enable(&stream->queue, 0);
1894 uvc_video_clock_cleanup(stream); 1882 uvc_video_clock_cleanup(stream);
1895 return 0; 1883 return 0;
1896 } 1884 }
@@ -1899,10 +1887,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1899 if (ret < 0) 1887 if (ret < 0)
1900 return ret; 1888 return ret;
1901 1889
1902 ret = uvc_queue_enable(&stream->queue, 1);
1903 if (ret < 0)
1904 goto error_queue;
1905
1906 /* Commit the streaming parameters. */ 1890 /* Commit the streaming parameters. */
1907 ret = uvc_commit_video(stream, &stream->ctrl); 1891 ret = uvc_commit_video(stream, &stream->ctrl);
1908 if (ret < 0) 1892 if (ret < 0)
@@ -1917,8 +1901,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1917error_video: 1901error_video:
1918 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1902 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1919error_commit: 1903error_commit:
1920 uvc_queue_enable(&stream->queue, 0);
1921error_queue:
1922 uvc_video_clock_cleanup(stream); 1904 uvc_video_clock_cleanup(stream);
1923 1905
1924 return ret; 1906 return ret;