Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp835887rdb; Wed, 6 Dec 2023 00:57:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9/PoXTklrzGigiOp/GjOY6+c7TOECFEd2ZXv+13A+2JtWlUr7halvCEv/8N6W6MQhDgx7 X-Received: by 2002:a17:90a:e7c2:b0:285:8a2a:173f with SMTP id kb2-20020a17090ae7c200b002858a2a173fmr288239pjb.0.1701853037261; Wed, 06 Dec 2023 00:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701853037; cv=none; d=google.com; s=arc-20160816; b=GN21kI+r8yRwEp2AoFIxZKme21wGtlKype+YUs0TF+GT+u5rkAHj0cvIMcRIbLLCMS 5xq4ZgKbWQ9u6kh7po1X7nZncmA+Ha8f0kHgx8+U+NdlGdMi0VTYVg9Zawy+QncYDEoS naOXo2OAgwrvxgS42jwECL1zoCrDWE9KmOLIDwpfvEQxYxjD07cX7G2Oz59zGOUXRu8b ZrUvAQzaiVZHj1A2Q3F7v0iC/tlJq5UVohCFP/HzMBevL4vPqrJcwi7814P1ucyDoVFb b63GcXb0ndKcK8pt/aYsRGoql2IQF8fbk32p9jqa/yHxrjJbkq5CBlxl3b+4k+oTldcX e3jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bkTK/UiHpkShofMOA2UtUsA44JdTzrKPH3TetUDhWm8=; fh=Bvp/56eZOrbqzmJuIHMC6JSO7g66DtUk/AQajmlEcfQ=; b=JkjM3DetyT0nvFoZxm3bN2qn+j0oINhPHh4tVoUy8XCSVSnao4I/7dnSJnNbOTn7Bs xvF8vqH61n2xz4J2mT2Wa824vqtIW0oLzo2WpNJjnwx35OqEUvOInHQCZNLr41K5TWd1 L/+oU9I3mEn0J3ACP2hy5raje4HrQJbz1krwibtw6RkCKYBtUrMcDpeZq3qAYJlPS/Lt 1UJ7ZMok4FcFTHHGjxV+RJN8Pf/QrfcQRawA4O8gBbXllttKv3a5jzsOCdtc1v+qb4y8 fsL7UycPzQQ5s82QZBOtZjRKi50qet9AD30pokgDZwO1hgB+IpUroPPo7OtpE8dwH50J s5pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BvOo3pMf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pd13-20020a17090b1dcd00b0027763ca82e9si3367080pjb.91.2023.12.06.00.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:57:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BvOo3pMf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DD6AB8022EBD; Wed, 6 Dec 2023 00:57:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377115AbjLFI4n (ORCPT + 99 others); Wed, 6 Dec 2023 03:56:43 -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: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:57:14 -0800 (PST) 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/media/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_memory memory, * Make sure the requested values and current defaults are sane. */ num_buffers = max_t(unsigned int, *count, q->min_queued_buffers); + 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 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; struct device *alloc_devs[VB2_MAX_PLANES]; -- 2.39.2