From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Tomasz Figa <tfiga@chromium.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Ezequiel Garcia <ezequiel@collabora.com>
Subject: [PATCH v2 1/8] videobuf2: Introduce vb2_find_buffer()
Date: Mon, 11 Jul 2022 18:11:34 -0300 [thread overview]
Message-ID: <20220711211141.349902-2-ezequiel@vanguardiasur.com.ar> (raw)
In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar>
From: Ezequiel Garcia <ezequiel@collabora.com>
All users of vb2_find_timestamp() combine it with vb2_get_buffer()
to retrieve a videobuf2 buffer, given a u64 timestamp.
Introduce an API for this use-case. Users will be converted to the new
API as follow-up commits.
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
---
drivers/media/common/videobuf2/videobuf2-v4l2.c | 12 ++++++++++++
include/media/videobuf2-v4l2.h | 10 ++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 075d24ebf44c..f26cb8586bd4 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -638,6 +638,18 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
}
EXPORT_SYMBOL_GPL(vb2_find_timestamp);
+struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp)
+{
+ unsigned int i;
+
+ for (i = 0; i < q->num_buffers; i++)
+ if (q->bufs[i]->copied_timestamp &&
+ q->bufs[i]->timestamp == timestamp)
+ return vb2_get_buffer(q, i);
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(vb2_find_buffer);
+
/*
* vb2_querybuf() - query video buffer information
* @q: videobuf queue
diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h
index d818d9707695..76e405c0b003 100644
--- a/include/media/videobuf2-v4l2.h
+++ b/include/media/videobuf2-v4l2.h
@@ -78,6 +78,16 @@ struct vb2_v4l2_buffer {
int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
unsigned int start_idx);
+/**
+ * vb2_find_buffer() - Find a buffer with given timestamp
+ *
+ * @q: pointer to &struct vb2_queue with videobuf2 queue.
+ * @timestamp: the timestamp to find.
+ *
+ * Returns the buffer with the given @timestamp, or NULL if not found.
+ */
+struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp);
+
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
/**
--
2.34.3
next prev parent reply other threads:[~2022-07-11 21:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 21:11 [PATCH v2 0/8] videobuf2: Replace vb2_find_timestamp() with vb2_find_buffer() Ezequiel Garcia
2022-07-11 21:11 ` Ezequiel Garcia [this message]
2022-07-12 7:03 ` [PATCH v2 1/8] videobuf2: Introduce vb2_find_buffer() Philipp Zabel
2022-07-11 21:11 ` [PATCH v2 2/8] mediatek: vcodec: Use vb2_find_buffer Ezequiel Garcia
2022-07-11 21:11 ` [PATCH v2 3/8] tegra-vde: " Ezequiel Garcia
2022-07-14 18:56 ` Dmitry Osipenko
2022-07-11 21:11 ` [PATCH v2 4/8] vicodec: " Ezequiel Garcia
2022-07-11 21:11 ` [PATCH v2 5/8] hantro: " Ezequiel Garcia
2022-07-12 7:03 ` Philipp Zabel
2022-07-11 21:11 ` [PATCH v2 6/8] rkvdec: " Ezequiel Garcia
2022-07-11 21:11 ` [PATCH v2 7/8] cedrus: " Ezequiel Garcia
2022-07-12 7:27 ` Paul Kocialkowski
2022-07-14 19:26 ` Nicolas Dufresne
2022-07-15 11:48 ` Ezequiel Garcia
2022-07-16 12:36 ` Jernej Škrabec
2022-07-16 14:55 ` Ezequiel Garcia
2022-07-18 15:56 ` Nicolas Dufresne
2022-07-11 21:11 ` [PATCH v2 8/8] videobuf2: Remove vb2_find_timestamp() Ezequiel Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220711211141.349902-2-ezequiel@vanguardiasur.com.ar \
--to=ezequiel@vanguardiasur.com.ar \
--cc=ezequiel@collabora.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®