aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/uvc/uvc_queue.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-10-21 12:03:08 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-25 05:40:08 -0500
commita11a03e50b73234444f7d439fb8ee6eaec3cffd1 (patch)
treedc0d201f4b84a90de7faf132ccc61e4271829cc0 /drivers/media/usb/uvc/uvc_queue.c
parentbc75d5a0097b4100b4a4e06db62b2afb80d96393 (diff)
[media] uvcvideo: Implement vb2 queue start and stop stream operations
To work propertly the videobuf2 core code needs to be in charge of stream start/stop control. Implement the start_streaming and stop_streaming vb2 operations and move video enable/disable code to them. 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/uvc/uvc_queue.c')
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 97036559bb92..758247048ee1 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -135,6 +135,29 @@ static void uvc_wait_finish(struct vb2_queue *vq)
135 mutex_lock(&queue->mutex); 135 mutex_lock(&queue->mutex);
136} 136}
137 137
138static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
139{
140 struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
141 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
142
143 queue->buf_used = 0;
144
145 return uvc_video_enable(stream, 1);
146}
147
148static void uvc_stop_streaming(struct vb2_queue *vq)
149{
150 struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
151 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
152 unsigned long flags;
153
154 uvc_video_enable(stream, 0);
155
156 spin_lock_irqsave(&queue->irqlock, flags);
157 INIT_LIST_HEAD(&queue->irqqueue);
158 spin_unlock_irqrestore(&queue->irqlock, flags);
159}
160
138static struct vb2_ops uvc_queue_qops = { 161static struct vb2_ops uvc_queue_qops = {
139 .queue_setup = uvc_queue_setup, 162 .queue_setup = uvc_queue_setup,
140 .buf_prepare = uvc_buffer_prepare, 163 .buf_prepare = uvc_buffer_prepare,
@@ -142,6 +165,8 @@ static struct vb2_ops uvc_queue_qops = {
142 .buf_finish = uvc_buffer_finish, 165 .buf_finish = uvc_buffer_finish,
143 .wait_prepare = uvc_wait_prepare, 166 .wait_prepare = uvc_wait_prepare,
144 .wait_finish = uvc_wait_finish, 167 .wait_finish = uvc_wait_finish,
168 .start_streaming = uvc_start_streaming,
169 .stop_streaming = uvc_stop_streaming,
145}; 170};
146 171
147int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, 172int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
@@ -310,27 +335,15 @@ int uvc_queue_allocated(struct uvc_video_queue *queue)
310 */ 335 */
311int uvc_queue_enable(struct uvc_video_queue *queue, int enable) 336int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
312{ 337{
313 unsigned long flags;
314 int ret; 338 int ret;
315 339
316 mutex_lock(&queue->mutex); 340 mutex_lock(&queue->mutex);
317 if (enable) {
318 ret = vb2_streamon(&queue->queue, queue->queue.type);
319 if (ret < 0)
320 goto done;
321 341
322 queue->buf_used = 0; 342 if (enable)
323 } else { 343 ret = vb2_streamon(&queue->queue, queue->queue.type);
344 else
324 ret = vb2_streamoff(&queue->queue, queue->queue.type); 345 ret = vb2_streamoff(&queue->queue, queue->queue.type);
325 if (ret < 0)
326 goto done;
327
328 spin_lock_irqsave(&queue->irqlock, flags);
329 INIT_LIST_HEAD(&queue->irqqueue);
330 spin_unlock_irqrestore(&queue->irqlock, flags);
331 }
332 346
333done:
334 mutex_unlock(&queue->mutex); 347 mutex_unlock(&queue->mutex);
335 return ret; 348 return ret;
336} 349}