aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-10-21 15:19:04 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-25 05:42:01 -0500
commit0da4ab984b1753b160b5fa840ae98b87228ac3dc (patch)
tree0e729c8d972d1e6ce63f32e903b2425ff382645f /drivers/media/usb
parent1b7f9c989ee7684dc70f0a75a037ecb1d437d3c2 (diff)
[media] uvcvideo: Rename and split uvc_queue_enable to uvc_queue_stream(on|off)
This brings the function name in line with the V4L2 API terminology and allows removing the duplicate queue type check. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c3
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c53
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c10
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h5
4 files changed, 30 insertions, 41 deletions
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index ab1e2fd0a599..6a4b0b8cd270 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2038,7 +2038,8 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
2038 if (stream->intf == intf) { 2038 if (stream->intf == intf) {
2039 ret = uvc_video_resume(stream, reset); 2039 ret = uvc_video_resume(stream, reset);
2040 if (ret < 0) 2040 if (ret < 0)
2041 uvc_queue_enable(&stream->queue, 0); 2041 uvc_queue_streamoff(&stream->queue,
2042 stream->queue.queue.type);
2042 return ret; 2043 return ret;
2043 } 2044 }
2044 } 2045 }
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 5c11de0df4b6..c295c5c719c8 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -263,6 +263,28 @@ int uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf,
263 return ret; 263 return ret;
264} 264}
265 265
266int uvc_queue_streamon(struct uvc_video_queue *queue, enum v4l2_buf_type type)
267{
268 int ret;
269
270 mutex_lock(&queue->mutex);
271 ret = vb2_streamon(&queue->queue, type);
272 mutex_unlock(&queue->mutex);
273
274 return ret;
275}
276
277int uvc_queue_streamoff(struct uvc_video_queue *queue, enum v4l2_buf_type type)
278{
279 int ret;
280
281 mutex_lock(&queue->mutex);
282 ret = vb2_streamoff(&queue->queue, type);
283 mutex_unlock(&queue->mutex);
284
285 return ret;
286}
287
266int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) 288int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
267{ 289{
268 int ret; 290 int ret;
@@ -318,37 +340,6 @@ int uvc_queue_allocated(struct uvc_video_queue *queue)
318} 340}
319 341
320/* 342/*
321 * Enable or disable the video buffers queue.
322 *
323 * The queue must be enabled before starting video acquisition and must be
324 * disabled after stopping it. This ensures that the video buffers queue
325 * state can be properly initialized before buffers are accessed from the
326 * interrupt handler.
327 *
328 * Enabling the video queue returns -EBUSY if the queue is already enabled.
329 *
330 * Disabling the video queue cancels the queue and removes all buffers from
331 * the main queue.
332 *
333 * This function can't be called from interrupt context. Use
334 * uvc_queue_cancel() instead.
335 */
336int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
337{
338 int ret;
339
340 mutex_lock(&queue->mutex);
341
342 if (enable)
343 ret = vb2_streamon(&queue->queue, queue->queue.type);
344 else
345 ret = vb2_streamoff(&queue->queue, queue->queue.type);
346
347 mutex_unlock(&queue->mutex);
348 return ret;
349}
350
351/*
352 * Cancel the video buffers queue. 343 * Cancel the video buffers queue.
353 * 344 *
354 * Cancelling the queue marks all buffers on the irq queue as erroneous, 345 * Cancelling the queue marks all buffers on the irq queue as erroneous,
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 5ba023be3926..9c5cbcf16529 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -757,14 +757,11 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
757 struct uvc_streaming *stream = handle->stream; 757 struct uvc_streaming *stream = handle->stream;
758 int ret; 758 int ret;
759 759
760 if (type != stream->type)
761 return -EINVAL;
762
763 if (!uvc_has_privileges(handle)) 760 if (!uvc_has_privileges(handle))
764 return -EBUSY; 761 return -EBUSY;
765 762
766 mutex_lock(&stream->mutex); 763 mutex_lock(&stream->mutex);
767 ret = uvc_queue_enable(&stream->queue, 1); 764 ret = uvc_queue_streamon(&stream->queue, type);
768 mutex_unlock(&stream->mutex); 765 mutex_unlock(&stream->mutex);
769 766
770 return ret; 767 return ret;
@@ -776,14 +773,11 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
776 struct uvc_fh *handle = fh; 773 struct uvc_fh *handle = fh;
777 struct uvc_streaming *stream = handle->stream; 774 struct uvc_streaming *stream = handle->stream;
778 775
779 if (type != stream->type)
780 return -EINVAL;
781
782 if (!uvc_has_privileges(handle)) 776 if (!uvc_has_privileges(handle))
783 return -EBUSY; 777 return -EBUSY;
784 778
785 mutex_lock(&stream->mutex); 779 mutex_lock(&stream->mutex);
786 uvc_queue_enable(&stream->queue, 0); 780 uvc_queue_streamoff(&stream->queue, type);
787 mutex_unlock(&stream->mutex); 781 mutex_unlock(&stream->mutex);
788 782
789 return 0; 783 return 0;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 2dc247a0ce34..f0a04b532ede 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -634,7 +634,10 @@ extern int uvc_queue_buffer(struct uvc_video_queue *queue,
634 struct v4l2_buffer *v4l2_buf); 634 struct v4l2_buffer *v4l2_buf);
635extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, 635extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
636 struct v4l2_buffer *v4l2_buf, int nonblocking); 636 struct v4l2_buffer *v4l2_buf, int nonblocking);
637extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable); 637extern int uvc_queue_streamon(struct uvc_video_queue *queue,
638 enum v4l2_buf_type type);
639extern int uvc_queue_streamoff(struct uvc_video_queue *queue,
640 enum v4l2_buf_type type);
638extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); 641extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
639extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, 642extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
640 struct uvc_buffer *buf); 643 struct uvc_buffer *buf);