Commit 03535e7a authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vb2: vb2_find_timestamp: drop restriction on buffer state

There really is no reason why vb2_find_timestamp can't just find
buffers in any state. Drop that part of the test.

This also means that vb->timestamp should only be set to 0 when
the driver doesn't copy timestamps.

This change allows for more efficient pipelining (i.e. you can use
a buffer for a reference frame even when it is queued).
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 04bde674
......@@ -567,7 +567,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, struct vb2_plane *planes)
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
unsigned int plane;
if (!vb->vb2_queue->is_output || !vb->vb2_queue->copy_timestamp)
if (!vb->vb2_queue->copy_timestamp)
vb->timestamp = 0;
for (plane = 0; plane < vb->num_planes; ++plane) {
......@@ -594,14 +594,9 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
{
unsigned int i;
for (i = start_idx; i < q->num_buffers; i++) {
struct vb2_buffer *vb = q->bufs[i];
if ((vb->state == VB2_BUF_STATE_DEQUEUED ||
vb->state == VB2_BUF_STATE_DONE) &&
vb->timestamp == timestamp)
for (i = start_idx; i < q->num_buffers; i++)
if (q->bufs[i]->timestamp == timestamp)
return i;
}
return -1;
}
EXPORT_SYMBOL_GPL(vb2_find_timestamp);
......
......@@ -59,8 +59,7 @@ struct vb2_v4l2_buffer {
* vb2_find_timestamp() - Find buffer with given timestamp in the queue
*
* @q: pointer to &struct vb2_queue with videobuf2 queue.
* @timestamp: the timestamp to find. Only buffers in state DEQUEUED or DONE
* are considered.
* @timestamp: the timestamp to find.
* @start_idx: the start index (usually 0) in the buffer array to start
* searching from. Note that there may be multiple buffers
* with the same timestamp value, so you can restart the search
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment