From nobody Fri Dec 19 07:49:56 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A09F1C4167B for ; Wed, 6 Dec 2023 08:56:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377133AbjLFI4p (ORCPT ); Wed, 6 Dec 2023 03:56:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377229AbjLFI4R (ORCPT ); Wed, 6 Dec 2023 03:56:17 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A6841B716; Wed, 6 Dec 2023 00:56:19 -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 8DDE8660732A; Wed, 6 Dec 2023 08:56:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701852978; bh=FTU8KzPND5ID0Hx3E+vk2e0gEDIDzN1LiyjU+EkE4jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BvOo3pMftWfEYWWSJy44jD9zyzsPKAfR3zznUSvGY8ng4kAP8EMdKakgLzIBUVqlD xtr7Fcmu7+Z8ZfMWYwBVDFUwNewL5gaTkqJLK/lFnUMf420Nfs/6049NCBizwY3Jg3 26JxiCzrYHzMu7Csl521xeSPP3UIcK8aiTQFDDgwCCAwm0zyzZiR3rfZ4lh9eYGUU8 4VS+trLgkXcaSK01byLLNoodwoTmO7ta8eVRFDTPOdTcIFxG/MfujGg2MvzYf7WAPL elFDWvaDyenPG2qAYdi0b3eQGdZGBS5vm/lHbieOZ1EKvHPm/ONESn5efRoScwEVnG jQxJp5ngvuJpg== From: Benjamin Gaignard To: hverkuil@xs4all.nl, mchehab@kernel.org, tfiga@chromium.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v3 2/2] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Date: Wed, 6 Dec 2023 09:56:08 +0100 Message-Id: <20231206085608.33246-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206085608.33246-1-benjamin.gaignard@collabora.com> References: <20231206085608.33246-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 'min_reqbufs_allocation' field in vb2_queue structure so drivers can specificy the minimum number of buffers to allocate when calling VIDIOC_REQBUFS. If used this minimum should be higher than the minimum number of queued buffers needed to start streaming. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-core.c | 1 + include/media/videobuf2-core.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 7b6d89641e66..3bc30d107308 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_memo= ry memory, * Make sure the requested values and current defaults are sane. */ num_buffers =3D max_t(unsigned int, *count, q->min_queued_buffers); + num_buffers =3D max_t(unsigned int, num_buffers, q->min_reqbufs_allocatio= n); num_buffers =3D 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 6d11cb724e95..252d34cc47d3 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -550,6 +550,11 @@ 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. + * If min_queued_buffers < min_queued_buffers then min_queued_buffers + * is the minimum. */ /* * Private elements (won't appear at the uAPI book): @@ -615,6 +620,7 @@ struct vb2_queue { u32 timestamp_flags; gfp_t gfp_flags; u32 min_queued_buffers; + u32 min_reqbufs_allocation; =20 struct device *alloc_devs[VB2_MAX_PLANES]; =20 --=20 2.39.2