Add the function 'vb2_find_timestamp_buf' that returns
the vb2 buffer that matches the given timestamp

Signed-off-by: Dafna Hirschfeld <daf...@gmail.com>
---
 drivers/media/common/videobuf2/videobuf2-v4l2.c | 14 ++++++++++++++
 include/media/videobuf2-v4l2.h                  |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c 
b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 3aeaea3af42a..47c245a76561 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -598,6 +598,20 @@ static const struct vb2_buf_ops v4l2_buf_ops = {
        .copy_timestamp         = __copy_timestamp,
 };
 
+struct vb2_buffer *vb2_find_timestamp_buf(const struct vb2_queue *q,
+                                         u64 timestamp,
+                                         unsigned int start_idx)
+{
+       unsigned int i;
+
+       for (i = start_idx; i < q->num_buffers; i++) {
+               if (q->bufs[i]->timestamp == timestamp)
+                       return q->bufs[i];
+       }
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(vb2_find_timestamp_buf);
+
 int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
                       unsigned int start_idx)
 {
diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h
index 8a10889dc2fd..7fc2a235064e 100644
--- a/include/media/videobuf2-v4l2.h
+++ b/include/media/videobuf2-v4l2.h
@@ -71,6 +71,9 @@ struct vb2_v4l2_buffer {
 int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
                       unsigned int start_idx);
 
+struct vb2_buffer *vb2_find_timestamp_buf(const struct vb2_queue *q,
+                                         u64 timestamp,
+                                         unsigned int start_idx);
 int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
 
 /**
-- 
2.17.1

Reply via email to