[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231208103908.85874-3-benjamin.gaignard@collabora.com>
Date: Fri, 8 Dec 2023 11:39:08 +0100
From: Benjamin Gaignard <benjamin.gaignard@...labora.com>
To: hverkuil@...all.nl, mchehab@...nel.org, tfiga@...omium.org
Cc: linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
linux-staging@...ts.linux.dev, kernel@...labora.com,
Benjamin Gaignard <benjamin.gaignard@...labora.com>
Subject: [PATCH v4 2/2] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
Add 'min_reqbufs_allocation' field in vb2_queue structure so drivers
can specificy the minimum number of buffers to allocate when calling
VIDIOC_REQBUFS.
If used this minimum should be higher than the minimum number of
queued buffers needed to start streaming.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
---
drivers/media/common/videobuf2/videobuf2-core.c | 1 +
include/media/videobuf2-core.h | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 7b6d89641e66..3bc30d107308 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -866,6 +866,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
* Make sure the requested values and current defaults are sane.
*/
num_buffers = max_t(unsigned int, *count, q->min_queued_buffers);
+ num_buffers = max_t(unsigned int, num_buffers, q->min_reqbufs_allocation);
num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);
memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
/*
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 6d11cb724e95..252d34cc47d3 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -550,6 +550,11 @@ struct vb2_buf_ops {
* @start_streaming can be called. Used when a DMA engine
* cannot be started unless at least this number of buffers
* have been queued into the driver.
+ * @min_reqbufs_allocation: the minimum number of buffers allocated when
+ * calling VIDIOC_REQBUFS. Used when drivers need a to
+ * specify a minimum buffers allocation before setup a queue.
+ * If min_queued_buffers < min_queued_buffers then min_queued_buffers
+ * is the minimum.
*/
/*
* Private elements (won't appear at the uAPI book):
@@ -615,6 +620,7 @@ struct vb2_queue {
u32 timestamp_flags;
gfp_t gfp_flags;
u32 min_queued_buffers;
+ u32 min_reqbufs_allocation;
struct device *alloc_devs[VB2_MAX_PLANES];
--
2.39.2
Powered by blists - more mailing lists