Commit b83bba24 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent aa3d17df
...@@ -1734,6 +1734,11 @@ static int uvc_register_video(struct uvc_device *dev, ...@@ -1734,6 +1734,11 @@ static int uvc_register_video(struct uvc_device *dev,
struct video_device *vdev; struct video_device *vdev;
int ret; int ret;
/* Initialize the video buffers queue. */
ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param);
if (ret)
return ret;
/* Initialize the streaming interface with default streaming /* Initialize the streaming interface with default streaming
* parameters. * parameters.
*/ */
...@@ -2008,14 +2013,13 @@ static int __uvc_resume(struct usb_interface *intf, int reset) ...@@ -2008,14 +2013,13 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
{ {
struct uvc_device *dev = usb_get_intfdata(intf); struct uvc_device *dev = usb_get_intfdata(intf);
struct uvc_streaming *stream; struct uvc_streaming *stream;
int ret = 0;
uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n",
intf->cur_altsetting->desc.bInterfaceNumber); intf->cur_altsetting->desc.bInterfaceNumber);
if (intf->cur_altsetting->desc.bInterfaceSubClass == if (intf->cur_altsetting->desc.bInterfaceSubClass ==
UVC_SC_VIDEOCONTROL) { UVC_SC_VIDEOCONTROL) {
int ret = 0;
if (reset) { if (reset) {
ret = uvc_ctrl_restore_values(dev); ret = uvc_ctrl_restore_values(dev);
if (ret < 0) if (ret < 0)
...@@ -2031,8 +2035,12 @@ static int __uvc_resume(struct usb_interface *intf, int reset) ...@@ -2031,8 +2035,12 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
} }
list_for_each_entry(stream, &dev->streams, list) { list_for_each_entry(stream, &dev->streams, list) {
if (stream->intf == intf) if (stream->intf == intf) {
return uvc_video_resume(stream, reset); ret = uvc_video_resume(stream, reset);
if (ret < 0)
uvc_queue_enable(&stream->queue, 0);
return ret;
}
} }
uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface " uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
......
...@@ -532,6 +532,7 @@ static int uvc_v4l2_release(struct file *file) ...@@ -532,6 +532,7 @@ static int uvc_v4l2_release(struct file *file)
/* Only free resources if this is a privileged handle. */ /* Only free resources if this is a privileged handle. */
if (uvc_has_privileges(handle)) { if (uvc_has_privileges(handle)) {
uvc_video_enable(stream, 0); uvc_video_enable(stream, 0);
uvc_queue_enable(&stream->queue, 0);
uvc_free_buffers(&stream->queue); uvc_free_buffers(&stream->queue);
} }
...@@ -766,7 +767,15 @@ static int uvc_ioctl_streamon(struct file *file, void *fh, ...@@ -766,7 +767,15 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
return -EBUSY; return -EBUSY;
mutex_lock(&stream->mutex); mutex_lock(&stream->mutex);
ret = uvc_queue_enable(&stream->queue, 1);
if (ret < 0)
goto done;
ret = uvc_video_enable(stream, 1); ret = uvc_video_enable(stream, 1);
if (ret < 0)
uvc_queue_enable(&stream->queue, 0);
done:
mutex_unlock(&stream->mutex); mutex_unlock(&stream->mutex);
return ret; return ret;
...@@ -777,7 +786,6 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh, ...@@ -777,7 +786,6 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
{ {
struct uvc_fh *handle = fh; struct uvc_fh *handle = fh;
struct uvc_streaming *stream = handle->stream; struct uvc_streaming *stream = handle->stream;
int ret;
if (type != stream->type) if (type != stream->type)
return -EINVAL; return -EINVAL;
...@@ -786,10 +794,11 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh, ...@@ -786,10 +794,11 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
return -EBUSY; return -EBUSY;
mutex_lock(&stream->mutex); mutex_lock(&stream->mutex);
ret = uvc_video_enable(stream, 0); uvc_video_enable(stream, 0);
uvc_queue_enable(&stream->queue, 0);
mutex_unlock(&stream->mutex); mutex_unlock(&stream->mutex);
return ret; return 0;
} }
static int uvc_ioctl_enum_input(struct file *file, void *fh, static int uvc_ioctl_enum_input(struct file *file, void *fh,
......
...@@ -1735,19 +1735,13 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset) ...@@ -1735,19 +1735,13 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
uvc_video_clock_reset(stream); uvc_video_clock_reset(stream);
ret = uvc_commit_video(stream, &stream->ctrl); ret = uvc_commit_video(stream, &stream->ctrl);
if (ret < 0) { if (ret < 0)
uvc_queue_enable(&stream->queue, 0);
return ret; return ret;
}
if (!uvc_queue_streaming(&stream->queue)) if (!uvc_queue_streaming(&stream->queue))
return 0; return 0;
ret = uvc_init_video(stream, GFP_NOIO); return uvc_init_video(stream, GFP_NOIO);
if (ret < 0)
uvc_queue_enable(&stream->queue, 0);
return ret;
} }
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
...@@ -1779,11 +1773,6 @@ int uvc_video_init(struct uvc_streaming *stream) ...@@ -1779,11 +1773,6 @@ int uvc_video_init(struct uvc_streaming *stream)
atomic_set(&stream->active, 0); atomic_set(&stream->active, 0);
/* Initialize the video buffers queue. */
ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param);
if (ret)
return ret;
/* Alternate setting 0 should be the default, yet the XBox Live Vision /* Alternate setting 0 should be the default, yet the XBox Live Vision
* Cam (and possibly other devices) crash or otherwise misbehave if * Cam (and possibly other devices) crash or otherwise misbehave if
* they don't receive a SET_INTERFACE request before any other video * 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,7 +1879,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
usb_clear_halt(stream->dev->udev, pipe); usb_clear_halt(stream->dev->udev, pipe);
} }
uvc_queue_enable(&stream->queue, 0);
uvc_video_clock_cleanup(stream); uvc_video_clock_cleanup(stream);
return 0; return 0;
} }
...@@ -1899,10 +1887,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) ...@@ -1899,10 +1887,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = uvc_queue_enable(&stream->queue, 1);
if (ret < 0)
goto error_queue;
/* Commit the streaming parameters. */ /* Commit the streaming parameters. */
ret = uvc_commit_video(stream, &stream->ctrl); ret = uvc_commit_video(stream, &stream->ctrl);
if (ret < 0) if (ret < 0)
...@@ -1917,8 +1901,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) ...@@ -1917,8 +1901,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
error_video: error_video:
usb_set_interface(stream->dev->udev, stream->intfnum, 0); usb_set_interface(stream->dev->udev, stream->intfnum, 0);
error_commit: error_commit:
uvc_queue_enable(&stream->queue, 0);
error_queue:
uvc_video_clock_cleanup(stream); uvc_video_clock_cleanup(stream);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment