media: videobuf2: Add min_reqbufs_allocation field to vb2_queue structure
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Thu, 14 Mar 2024 15:32:19 +0000 (16:32 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 25 Mar 2024 11:00:44 +0000 (12:00 +0100)
commit6662edcd32ccf939849cd1cd4ff04733a20ef97a
tree804fdc0b78086b9cf9f8bd58f994cf7cdb9f4413
parentd7cdb5946f6394c92916ea9502393b7ffe11fed9
media: videobuf2: Add min_reqbufs_allocation field to vb2_queue structure

Add 'min_reqbufs_allocation' field in the vb2_queue structure so drivers
can specify the minimum number of buffers to allocate when calling
VIDIOC_REQBUFS.
When initializing the queue, v4l2 core makes sure that the following
constraints are respected:
- the minimum number of buffers to allocate must be at least 2 because
one buffer is used by the hardware while the other is being processed
by userspace.
-if the driver needs 'min_queued_buffers' in the queue before calling
start_streaming(), then the minimum requirement is 'min_queued_buffers + 1'
to keep at least one buffer available for userspace.

Simplify __vb2_init_fileio() by using 'min_reqbufs_allocation' directly
to avoid duplicating the minimum number of buffers to allocate computation.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/common/videobuf2/videobuf2-core.c
include/media/videobuf2-core.h