@@ -923,7 +923,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_reqbufs_allocation);
+ num_buffers = max_t(unsigned int, *count, q->rec_num_buffers);
num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);
memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
/*
@@ -974,7 +974,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
* There is no point in continuing if we can't allocate the minimum
* number of buffers needed by this vb2_queue.
*/
- if (allocated_buffers < q->min_reqbufs_allocation)
+ if (allocated_buffers < q->rec_num_buffers)
ret = -ENOMEM;
/*
@@ -2647,10 +2647,10 @@ int vb2_core_queue_init(struct vb2_queue *q)
* 'min_queued_buffers + 1' to keep at least one buffer available
* for userspace.
*/
- if (q->min_reqbufs_allocation < q->min_queued_buffers + 1)
- q->min_reqbufs_allocation = q->min_queued_buffers + 1;
+ if (q->rec_num_buffers < q->min_queued_buffers + 1)
+ q->rec_num_buffers = q->min_queued_buffers + 1;
- if (WARN_ON(q->min_reqbufs_allocation > q->max_num_buffers))
+ if (WARN_ON(q->rec_num_buffers > q->max_num_buffers))
return -EINVAL;
/* Either both or none are set */
@@ -2874,7 +2874,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
return -EBUSY;
dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
- (read) ? "read" : "write", q->min_reqbufs_allocation, q->fileio_read_once,
+ (read) ? "read" : "write", q->rec_num_buffers, q->fileio_read_once,
q->fileio_write_immediately);
fileio = kzalloc(sizeof(*fileio), GFP_KERNEL);
@@ -2888,7 +2888,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
* Request buffers and use MMAP type to force driver
* to allocate buffers by itself.
*/
- fileio->count = q->min_reqbufs_allocation;
+ fileio->count = q->rec_num_buffers;
fileio->memory = VB2_MEMORY_MMAP;
fileio->type = q->type;
q->fileio = fileio;
@@ -705,7 +705,7 @@ static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
}
if (min_num_bufs && rec_num_bufs) {
*min_num_bufs = q->min_queued_buffers + 1;
- *rec_num_bufs = q->min_reqbufs_allocation;
+ *rec_num_bufs = q->rec_num_buffers;
*caps |= V4L2_BUF_CAP_SUPPORTS_MIN_REC_NUM_BUFFERS;
}
}
@@ -1709,7 +1709,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
if (ctx->is_enc) {
src_vq->lock = &ctx->dev->stateful_enc.mutex;
- src_vq->min_reqbufs_allocation = VICODEC_REC_BUFS;
+ src_vq->rec_num_buffers = VICODEC_REC_BUFS;
} else if (ctx->is_stateless) {
src_vq->lock = &ctx->dev->stateless_dec.mutex;
} else {
@@ -1733,7 +1733,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = src_vq->lock;
if (!ctx->is_stateless && !ctx->is_enc)
- dst_vq->min_reqbufs_allocation = VICODEC_REC_BUFS;
+ dst_vq->rec_num_buffers = VICODEC_REC_BUFS;
return vb2_queue_init(dst_vq);
}
@@ -427,7 +427,7 @@ static struct vimc_ent_device *vimc_capture_add(struct vimc_device *vimc,
q->mem_ops = vimc_allocator == VIMC_ALLOCATOR_DMA_CONTIG
? &vb2_dma_contig_memops : &vb2_vmalloc_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
- q->min_reqbufs_allocation = 2;
+ q->rec_num_buffers = 2;
q->lock = &vcapture->lock;
q->dev = v4l2_dev->dev;
@@ -887,7 +887,7 @@ static const struct media_device_ops vivid_media_ops = {
static int vivid_create_queue(struct vivid_dev *dev,
struct vb2_queue *q,
u32 buf_type,
- unsigned int min_reqbufs_allocation,
+ unsigned int rec_num_buffers,
const struct vb2_ops *ops)
{
if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->multiplanar)
@@ -924,7 +924,7 @@ static int vivid_create_queue(struct vivid_dev *dev,
q->mem_ops = allocators[dev->inst] == 1 ? &vb2_dma_contig_memops :
&vb2_vmalloc_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
- q->min_reqbufs_allocation = min_reqbufs_allocation;
+ q->rec_num_buffers = rec_num_buffers;
q->lock = &dev->mutex;
q->dev = dev->v4l2_dev.dev;
q->supports_requests = supports_requests[dev->inst];
@@ -555,14 +555,16 @@ struct vb2_buf_ops {
* VIDIOC_REQBUFS will ensure at least @min_queued_buffers + 1
* buffers will be allocated. Note that VIDIOC_CREATE_BUFS will not
* modify the requested buffer count.
- * @min_reqbufs_allocation: the minimum number of buffers to be allocated when
- * calling VIDIOC_REQBUFS. Note that VIDIOC_CREATE_BUFS will *not*
- * modify the requested buffer count and does not use this field.
+ * @rec_num_buffers: the recommended number of buffers to allocate for this
+ * queue. This value is used when calling VIDIOC_REQBUFS: it will
+ * allocate at least this many buffersa
+ * Note that VIDIOC_CREATE_BUFS will *not* modify the requested
+ * buffer count and it does not use this field.
* Drivers can set this if there has to be a certain number of
* buffers available for the hardware to work effectively.
* This allows calling VIDIOC_REQBUFS with a buffer count of 1 and
* it will be automatically adjusted to a workable buffer count.
- * If set, then @min_reqbufs_allocation must be larger than
+ * If set, then @rec_num_buffers must be larger than
* @min_queued_buffers + 1.
* If this field is > 3, then it is highly recommended that the
* driver implements the V4L2_CID_MIN_BUFFERS_FOR_CAPTURE/OUTPUT
@@ -638,7 +640,7 @@ struct vb2_queue {
u32 timestamp_flags;
gfp_t gfp_flags;
u32 min_queued_buffers;
- u32 min_reqbufs_allocation;
+ u32 rec_num_buffers;
struct device *alloc_devs[VB2_MAX_PLANES];
The name 'rec_num_buffers' matches what struct v4l2_create_buffers uses, and 'recommended number of buffers' is a much more descriptive name. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> --- drivers/media/common/videobuf2/videobuf2-core.c | 14 +++++++------- drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +- drivers/media/test-drivers/vicodec/vicodec-core.c | 4 ++-- drivers/media/test-drivers/vimc/vimc-capture.c | 2 +- drivers/media/test-drivers/vivid/vivid-core.c | 4 ++-- include/media/videobuf2-core.h | 12 +++++++----- 6 files changed, 20 insertions(+), 18 deletions(-)