aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/parport/bw-qcam.c3
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c3
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c3
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c17
-rw-r--r--include/media/videobuf2-core.h10
5 files changed, 31 insertions, 5 deletions
diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
index cf2db63da3b1..8a0e84c7d495 100644
--- a/drivers/media/parport/bw-qcam.c
+++ b/drivers/media/parport/bw-qcam.c
@@ -674,6 +674,9 @@ static void buffer_finish(struct vb2_buffer *vb)
674 int size = vb->vb2_queue->plane_sizes[0]; 674 int size = vb->vb2_queue->plane_sizes[0];
675 int len; 675 int len;
676 676
677 if (!vb2_is_streaming(vb->vb2_queue))
678 return;
679
677 mutex_lock(&qcam->lock); 680 mutex_lock(&qcam->lock);
678 parport_claim_or_block(qcam->pdev); 681 parport_claim_or_block(qcam->pdev);
679 682
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index e66556cae7ea..bb11443ed63e 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -337,7 +337,8 @@ static void buffer_finish(struct vb2_buffer *vb)
337 list_del_init(&vip_buf->list); 337 list_del_init(&vip_buf->list);
338 spin_unlock(&vip->lock); 338 spin_unlock(&vip->lock);
339 339
340 vip_active_buf_next(vip); 340 if (vb2_is_streaming(vb->vb2_queue))
341 vip_active_buf_next(vip);
341} 342}
342 343
343static int start_streaming(struct vb2_queue *vq, unsigned int count) 344static int start_streaming(struct vb2_queue *vq, unsigned int count)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 26172cbcf096..6e92d2080255 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -113,7 +113,8 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
113 container_of(queue, struct uvc_streaming, queue); 113 container_of(queue, struct uvc_streaming, queue);
114 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); 114 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
115 115
116 uvc_video_clock_update(stream, &vb->v4l2_buf, buf); 116 if (vb->state == VB2_BUF_STATE_DONE)
117 uvc_video_clock_update(stream, &vb->v4l2_buf, buf);
117} 118}
118 119
119static void uvc_wait_prepare(struct vb2_queue *vq) 120static void uvc_wait_prepare(struct vb2_queue *vq)
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 2be3cfec2ac8..16ae66f5584f 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1929,9 +1929,22 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
1929 1929
1930 /* 1930 /*
1931 * Reinitialize all buffers for next use. 1931 * Reinitialize all buffers for next use.
1932 * Make sure to call buf_finish for any queued buffers. Normally
1933 * that's done in dqbuf, but that's not going to happen when we
1934 * cancel the whole queue. Note: this code belongs here, not in
1935 * __vb2_dqbuf() since in vb2_internal_dqbuf() there is a critical
1936 * call to __fill_v4l2_buffer() after buf_finish(). That order can't
1937 * be changed, so we can't move the buf_finish() to __vb2_dqbuf().
1932 */ 1938 */
1933 for (i = 0; i < q->num_buffers; ++i) 1939 for (i = 0; i < q->num_buffers; ++i) {
1934 __vb2_dqbuf(q->bufs[i]); 1940 struct vb2_buffer *vb = q->bufs[i];
1941
1942 if (vb->state != VB2_BUF_STATE_DEQUEUED) {
1943 vb->state = VB2_BUF_STATE_PREPARED;
1944 call_vb_qop(vb, buf_finish, vb);
1945 }
1946 __vb2_dqbuf(vb);
1947 }
1935} 1948}
1936 1949
1937static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) 1950static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 8d62a51cb7a0..2ffcb81aee9c 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -276,7 +276,15 @@ struct vb2_buffer {
276 * in driver; optional 276 * in driver; optional
277 * @buf_finish: called before every dequeue of the buffer back to 277 * @buf_finish: called before every dequeue of the buffer back to
278 * userspace; drivers may perform any operations required 278 * userspace; drivers may perform any operations required
279 * before userspace accesses the buffer; optional 279 * before userspace accesses the buffer; optional. The
280 * buffer state can be one of the following: DONE and
281 * ERROR occur while streaming is in progress, and the
282 * PREPARED state occurs when the queue has been canceled
283 * and all pending buffers are being returned to their
284 * default DEQUEUED state. Typically you only have to do
285 * something if the state is VB2_BUF_STATE_DONE, since in
286 * all other cases the buffer contents will be ignored
287 * anyway.
280 * @buf_cleanup: called once before the buffer is freed; drivers may 288 * @buf_cleanup: called once before the buffer is freed; drivers may
281 * perform any additional cleanup; optional 289 * perform any additional cleanup; optional
282 * @start_streaming: called once to enter 'streaming' state; the driver may 290 * @start_streaming: called once to enter 'streaming' state; the driver may