diff mbox series

[7/9] media: vb2: Add func that return buffer by timestamp

Message ID 20190209135427.20630-8-dafna3@gmail.com (mailing list archive)
State New, archived
Headers show
Series media: vicodec: add support to stateless decoder | expand

Commit Message

Dafna Hirschfeld Feb. 9, 2019, 1:54 p.m. UTC
Add the function 'vb2_find_timestamp_buf' that returns
the vb2 buffer that matches the given timestamp

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

Comments

Hans Verkuil Feb. 11, 2019, 10:11 a.m. UTC | #1
On 2/9/19 2:54 PM, Dafna Hirschfeld wrote:
> Add the function 'vb2_find_timestamp_buf' that returns
> the vb2 buffer that matches the given timestamp
> 
> Signed-off-by: Dafna Hirschfeld <dafna3@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);

There is no need for this function, I don't think it adds anything useful IMHO.

Regards,

	Hans

> +
>  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);
>  
>  /**
>
diff mbox series

Patch

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);
 
 /**