From patchwork Mon Dec 4 13:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 13478396 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="RX7xrmq4" Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F27E210C1; Mon, 4 Dec 2023 05:24:05 -0800 (PST) Received: from benjamin-XPS-13-9310.. (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 530C5660715D; Mon, 4 Dec 2023 13:24:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701696244; bh=7RGpb9eXUi6lQdxW/1vzQwvC1+GPAwIhQ8xVVzZPHxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX7xrmq4GvDpj91MiwF1uNjqVz+SU/11KD+Xm+ywaqLks0X9rMkTF7m/RG8XRMzrJ WfiCHUFrHW417ILh7VWCUvx2L9hp1ykHPTLwD75nyB/iJIQJdOtae6nOhBaOeYtARk fwxUz5tSA164f+bkA+2V+CB0VsEvs8m/VJt6wy4eGjBenoGp3gfqM861pwIBleDBz1 YjLORInZGn4FnY77jh6RfCJ5QASWOM7YVm+3pbVdFe0ZUdLa6N0lmbWlk0ddd1Xmbz mLNhisE1aNKveXIFGwSH+AYBbmdBUVNSJ2jZOzPauBiY6j6vvy16YWly9BBsFCA5T2 P+YtjxCcm+9oQ== From: Benjamin Gaignard To: hverkuil@xs4all.nl, mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, matt.ranostay@konsulko.com Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v2 16/36] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Date: Mon, 4 Dec 2023 14:23:03 +0100 Message-Id: <20231204132323.22811-17-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231204132323.22811-1-benjamin.gaignard@collabora.com> References: <20231204132323.22811-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- drivers/media/common/videobuf2/videobuf2-core.c | 1 + include/media/videobuf2-core.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 8c1df829745b..c224d13b3105 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_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)); /* diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 5557d78b6f20..17cacd696ab4 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -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];