diff options
author | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2018-10-24 06:51:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-01-07 13:19:48 -0500 |
commit | 245ede423b43a6e081e94e0e5d4e895bd1f31228 (patch) | |
tree | ac7bbb0d68e33af0c5edc24a1c63e0b5c6a56099 /drivers/media/common | |
parent | c2eb8effb265ac5cdd960d8e61ecb931e9c767cd (diff) |
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>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-v4l2.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 3a0ca2f9854f..75ea90e795d8 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c | |||
@@ -143,7 +143,7 @@ static void __copy_timestamp(struct vb2_buffer *vb, const void *pb) | |||
143 | * and the timecode field and flag if needed. | 143 | * and the timecode field and flag if needed. |
144 | */ | 144 | */ |
145 | if (q->copy_timestamp) | 145 | if (q->copy_timestamp) |
146 | vb->timestamp = timeval_to_ns(&b->timestamp); | 146 | vb->timestamp = v4l2_timeval_to_ns(&b->timestamp); |
147 | vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; | 147 | vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; |
148 | if (b->flags & V4L2_BUF_FLAG_TIMECODE) | 148 | if (b->flags & V4L2_BUF_FLAG_TIMECODE) |
149 | vbuf->timecode = b->timecode; | 149 | vbuf->timecode = b->timecode; |
@@ -589,6 +589,23 @@ static const struct vb2_buf_ops v4l2_buf_ops = { | |||
589 | .copy_timestamp = __copy_timestamp, | 589 | .copy_timestamp = __copy_timestamp, |
590 | }; | 590 | }; |
591 | 591 | ||
592 | int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, | ||
593 | unsigned int start_idx) | ||
594 | { | ||
595 | unsigned int i; | ||
596 | |||
597 | for (i = start_idx; i < q->num_buffers; i++) { | ||
598 | struct vb2_buffer *vb = q->bufs[i]; | ||
599 | |||
600 | if ((vb->state == VB2_BUF_STATE_DEQUEUED || | ||
601 | vb->state == VB2_BUF_STATE_DONE) && | ||
602 | vb->timestamp == timestamp) | ||
603 | return i; | ||
604 | } | ||
605 | return -1; | ||
606 | } | ||
607 | EXPORT_SYMBOL_GPL(vb2_find_timestamp); | ||
608 | |||
592 | /* | 609 | /* |
593 | * vb2_querybuf() - query video buffer information | 610 | * vb2_querybuf() - query video buffer information |
594 | * @q: videobuf queue | 611 | * @q: videobuf queue |