Commit 80c2b40a authored by Benjamin Gaignard's avatar Benjamin Gaignard Committed by Hans Verkuil
Browse files

media: videobuf2: core: Rename min_buffers_needed field in vb2_queue



Rename min_buffers_needed into min_queued_buffers and update
the documentation about it.

Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: Drop the change where min_queued_buffers + 1 buffers would be]
[hverkuil: allocated. Now this patch only renames this field instead of making]
[hverkuil: a functional change as well.]
[hverkuil: Renamed 3 remaining min_buffers_needed occurrences.]
parent a3e28ea7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2546,7 +2546,7 @@ static const struct vb2_queue mxt_queue = {
	.ops = &mxt_queue_ops,
	.mem_ops = &vb2_vmalloc_memops,
	.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC,
	.min_buffers_needed = 1,
	.min_queued_buffers = 1,
};

static int mxt_vidioc_querycap(struct file *file, void *priv,
+1 −1
Original line number Diff line number Diff line
@@ -1124,7 +1124,7 @@ static const struct vb2_queue sur40_queue = {
	.ops = &sur40_queue_ops,
	.mem_ops = &vb2_dma_sg_memops,
	.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC,
	.min_buffers_needed = 3,
	.min_queued_buffers = 3,
};

static const struct v4l2_file_operations sur40_video_fops = {
+1 −1
Original line number Diff line number Diff line
@@ -387,7 +387,7 @@ int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev,
	q->gfp_flags = __GFP_DMA32;
	q->buf_struct_size = sizeof(struct saa7146_buf);
	q->lock = &dev->v4l2_lock;
	q->min_buffers_needed = 2;
	q->min_queued_buffers = 2;
	q->dev = &dev->pci->dev;
	err = vb2_queue_init(q);
	if (err)
+14 −14
Original line number Diff line number Diff line
@@ -865,7 +865,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, *count, q->min_queued_buffers);
	num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers);
	memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
	/*
@@ -917,7 +917,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_buffers_needed)
	if (allocated_buffers < q->min_queued_buffers)
		ret = -ENOMEM;

	/*
@@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(vb2_core_prepare_buf);
 * @q:		videobuf2 queue
 *
 * Attempt to start streaming. When this function is called there must be
 * at least q->min_buffers_needed buffers queued up (i.e. the minimum
 * at least q->min_queued_buffers queued up (i.e. the minimum
 * number of buffers required for the DMA engine to function). If the
 * @start_streaming op fails it is supposed to return all the driver-owned
 * buffers back to vb2 in state QUEUED. Check if that happened and if
@@ -1846,7 +1846,7 @@ int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb,
	 * then we can finally call start_streaming().
	 */
	if (q->streaming && !q->start_streaming_called &&
	    q->queued_count >= q->min_buffers_needed) {
	    q->queued_count >= q->min_queued_buffers) {
		ret = vb2_start_streaming(q);
		if (ret) {
			/*
@@ -2210,9 +2210,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
		return -EINVAL;
	}

	if (q_num_bufs < q->min_buffers_needed) {
		dprintk(q, 1, "need at least %u allocated buffers\n",
				q->min_buffers_needed);
	if (q_num_bufs < q->min_queued_buffers) {
		dprintk(q, 1, "need at least %u queued buffers\n",
			q->min_queued_buffers);
		return -EINVAL;
	}

@@ -2224,7 +2224,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
	 * Tell driver to start streaming provided sufficient buffers
	 * are available.
	 */
	if (q->queued_count >= q->min_buffers_needed) {
	if (q->queued_count >= q->min_queued_buffers) {
		ret = vb2_start_streaming(q);
		if (ret)
			goto unprepare;
@@ -2504,7 +2504,7 @@ int vb2_core_queue_init(struct vb2_queue *q)
		return -EINVAL;

	if (WARN_ON(q->max_num_buffers > MAX_BUFFER_INDEX) ||
	    WARN_ON(q->min_buffers_needed > q->max_num_buffers))
	    WARN_ON(q->min_queued_buffers > q->max_num_buffers))
		return -EINVAL;

	if (WARN_ON(q->requires_requests && !q->supports_requests))
@@ -2512,13 +2512,13 @@ int vb2_core_queue_init(struct vb2_queue *q)

	/*
	 * This combination is not allowed since a non-zero value of
	 * q->min_buffers_needed can cause vb2_core_qbuf() to fail if
	 * q->min_queued_buffers can cause vb2_core_qbuf() to fail if
	 * it has to call start_streaming(), and the Request API expects
	 * that queueing a request (and thus queueing a buffer contained
	 * in that request) will always succeed. There is no method of
	 * propagating an error back to userspace.
	 */
	if (WARN_ON(q->supports_requests && q->min_buffers_needed))
	if (WARN_ON(q->supports_requests && q->min_queued_buffers))
		return -EINVAL;

	INIT_LIST_HEAD(&q->queued_list);
@@ -2735,14 +2735,14 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
		return -EBUSY;

	/*
	 * Start with q->min_buffers_needed + 1, driver can increase it in
	 * Start with q->min_queued_buffers + 1, driver can increase it in
	 * queue_setup()
	 *
	 * 'min_buffers_needed' buffers need to be queued up before you
	 * 'min_queued_buffers' buffers need to be queued up before you
	 * can start streaming, plus 1 for userspace (or in this case,
	 * kernelspace) processing.
	 */
	count = max(2, q->min_buffers_needed + 1);
	count = max(2, q->min_queued_buffers + 1);

	dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
		(read) ? "read" : "write", count, q->fileio_read_once,
+1 −1
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int nonblocking)
	q->io_modes = VB2_MMAP;
	q->drv_priv = ctx;
	q->buf_struct_size = sizeof(struct dvb_buffer);
	q->min_buffers_needed = 1;
	q->min_queued_buffers = 1;
	q->ops = &dvb_vb2_qops;
	q->mem_ops = &vb2_vmalloc_memops;
	q->buf_ops = &dvb_vb2_buf_ops;
Loading