@@ -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_buffers_needed);
+ 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));
/*
@@ -550,6 +550,9 @@ 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.
*/
/*
* Private elements (won't appear at the uAPI book):
@@ -615,6 +618,7 @@ struct vb2_queue {
u32 timestamp_flags;
gfp_t gfp_flags;
u32 min_buffers_needed;
+ u32 min_reqbufs_allocation;
struct device *alloc_devs[VB2_MAX_PLANES];
Add 'min_reqbufs_allocation' field in vb2_queue structure so drivers can specificy the minimum number of buffers to allocate when calling VIDIOC_REQBUFS. Later that will help to distinguish the minimum number of buffers needed to start streaming versus the minimum allocation requirement. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> --- drivers/media/common/videobuf2/videobuf2-core.c | 1 + include/media/videobuf2-core.h | 4 ++++ 2 files changed, 5 insertions(+)