Skip to content

Commit ce0eff0

Browse files
Hans Verkuilmchehab
authored andcommitted
[media] vb2: allow requeuing buffers while streaming
vb2_buffer_done() already allows STATE_QUEUED, but currently only when not streaming. It is useful to allow it while streaming as well, as this makes it possible for drivers to requeue buffers while waiting for a stable video signal. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent f888ae7 commit ce0eff0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/media/v4l2-core/videobuf2-core.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ module_param(debug, int, 0644);
182182
V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE)
183183

184184
static void __vb2_queue_cancel(struct vb2_queue *q);
185+
static void __enqueue_in_driver(struct vb2_buffer *vb);
185186

186187
/**
187188
* __vb2_buf_mem_alloc() - allocate video memory for the given buffer
@@ -1153,8 +1154,9 @@ EXPORT_SYMBOL_GPL(vb2_plane_cookie);
11531154
/**
11541155
* vb2_buffer_done() - inform videobuf that an operation on a buffer is finished
11551156
* @vb: vb2_buffer returned from the driver
1156-
* @state: either VB2_BUF_STATE_DONE if the operation finished successfully
1157-
* or VB2_BUF_STATE_ERROR if the operation finished with an error.
1157+
* @state: either VB2_BUF_STATE_DONE if the operation finished successfully,
1158+
* VB2_BUF_STATE_ERROR if the operation finished with an error or
1159+
* VB2_BUF_STATE_QUEUED if the driver wants to requeue buffers.
11581160
* If start_streaming fails then it should return buffers with state
11591161
* VB2_BUF_STATE_QUEUED to put them back into the queue.
11601162
*
@@ -1205,8 +1207,11 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
12051207
atomic_dec(&q->owned_by_drv_count);
12061208
spin_unlock_irqrestore(&q->done_lock, flags);
12071209

1208-
if (state == VB2_BUF_STATE_QUEUED)
1210+
if (state == VB2_BUF_STATE_QUEUED) {
1211+
if (q->start_streaming_called)
1212+
__enqueue_in_driver(vb);
12091213
return;
1214+
}
12101215

12111216
/* Inform any processes that may be waiting for buffers */
12121217
wake_up(&q->done_wq);

0 commit comments

Comments
 (0)