Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
ce0eff01 f888ae7e

+8 -3
+8 -3
drivers/media/v4l2-core/videobuf2-core.c
··· 182 182 V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE) 183 183 184 184 static void __vb2_queue_cancel(struct vb2_queue *q); 185 + static void __enqueue_in_driver(struct vb2_buffer *vb); 185 186 186 187 /** 187 188 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer ··· 1154 1153 /** 1155 1154 * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished 1156 1155 * @vb: vb2_buffer returned from the driver 1157 - * @state: either VB2_BUF_STATE_DONE if the operation finished successfully 1158 - * or VB2_BUF_STATE_ERROR if the operation finished with an error. 1156 + * @state: either VB2_BUF_STATE_DONE if the operation finished successfully, 1157 + * VB2_BUF_STATE_ERROR if the operation finished with an error or 1158 + * VB2_BUF_STATE_QUEUED if the driver wants to requeue buffers. 1159 1159 * If start_streaming fails then it should return buffers with state 1160 1160 * VB2_BUF_STATE_QUEUED to put them back into the queue. 1161 1161 * ··· 1207 1205 atomic_dec(&q->owned_by_drv_count); 1208 1206 spin_unlock_irqrestore(&q->done_lock, flags); 1209 1207 1210 - if (state == VB2_BUF_STATE_QUEUED) 1208 + if (state == VB2_BUF_STATE_QUEUED) { 1209 + if (q->start_streaming_called) 1210 + __enqueue_in_driver(vb); 1211 1211 return; 1212 + } 1212 1213 1213 1214 /* Inform any processes that may be waiting for buffers */ 1214 1215 wake_up(&q->done_wq);