media: vb2: add vb2_find_timestamp()

Use v4l2_timeval_to_ns instead of timeval_to_ns to ensure that
both kernelspace and userspace will use the same conversion
function.

Next add a new vb2_find_timestamp() function to find buffers
with a specific timestamp.

This function will only look at DEQUEUED and DONE buffers, i.e.
buffers that are already processed.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Hans Verkuil
2018-10-24 06:51:01 -04:00
committed by Mauro Carvalho Chehab
parent c2eb8effb2
commit 245ede423b
2 changed files with 35 additions and 1 deletions

View File

@@ -55,6 +55,23 @@ struct vb2_v4l2_buffer {
#define to_vb2_v4l2_buffer(vb) \
container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
/**
* 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.
* @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
* by setting @start_idx to the previously found index + 1.
*
* Returns the buffer index of the buffer with the given @timestamp, or
* -1 if no buffer with @timestamp was found.
*/
int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
unsigned int start_idx);
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
/**