Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp247282rdg; Thu, 12 Oct 2023 04:47:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDIcO3ruOxvUHg2QOI4CCpxhmMzAIEGP/Qc5NL4amgx2FZBVGX2vs2NLFjNMnbShD4YZE7 X-Received: by 2002:a05:6a00:198e:b0:690:d0d4:b757 with SMTP id d14-20020a056a00198e00b00690d0d4b757mr28164772pfl.20.1697111236563; Thu, 12 Oct 2023 04:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111236; cv=none; d=google.com; s=arc-20160816; b=I7RWMIWb9pjqUtyqMiIafwnqFSwp6Z2PQM87WU/UrAqlcs1qk/G9qSvBcwUhv0zBSv boCPuxxyzAX/9VsPtjgUPLxQX9cfpt8V6/efYOrOqktPB5d6pWM4L/Y1Ga0bGPFYd94O Uq+OPBplMgn+4pdLkqezqcmxraonkRp0c0Y5eyFoG58eWo8Gb7Se++f4ytVBCzJYLjON SK4PUAhPhJQjeN5lNBqBfuIrUuV7d9KjPDWgJ9xutpaB4U2ub35qC7BYInKChqSzn3xn ZiWRsBvv9KAhmj0h+dMQ5HZIBhSoXT2jZhZATNAeJ7dHTzmY9+CLQjro8ylnNNxJEhg4 9OOg== 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=UcK1M6ba+qPsIpOiLnurj5VZil6Dh9wjABNphkn5ocE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=t3Xwrh26GV0MsuTG58KHA4Wv4RdZCCKxX6Nm6C0J5NXpaFBOf2cpPvjBWNNCsD2U8W IkJvDn8km0RK9krO5i09t2WGKYnpOnprsDoiHvFPd2xKec6qCPyvEzY+uz6h40e7PsVr 0UV7rgTEfXDUbNSEC3/dsO0BkMTALfbhk/xmprCje+WngsbSyaeGOOHozHFgQtGVfiGB Zxf+aJLP80JfFjrQUDo2kE6HTB/onwBHGt8s/kbhKxRCbKbxWzv06+yxdZp6G8Z+eZXo 355qlpxFQ+HI5UIHuE/TlVS4L76OzPkRacGEEt2IjRe+/pdCYNYhrLYC62joZ0GXvusR sNHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cgcyRpJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z21-20020a637e15000000b0056679c8e70csi2004780pgc.272.2023.10.12.04.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cgcyRpJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8D165822CB6B; Thu, 12 Oct 2023 04:47:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378513AbjJLLrH (ORCPT + 99 others); Thu, 12 Oct 2023 07:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347190AbjJLLqz (ORCPT ); Thu, 12 Oct 2023 07:46:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A786BE; Thu, 12 Oct 2023 04:46:54 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 EF28A6607350; Thu, 12 Oct 2023 12:46:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111213; bh=lM3wXK65Q+RBpyeYExb53Y3bnLmIcGL+rErhrVO2B80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgcyRpJVkzZnipPZ8a0wBHk4u4e5u/VyFtdTKHoQQNPvYdMqr55oBWzpZfHTh0e3a giMKZFpip9opPC9lVsURFcU9P3Wj9XWNpC70hS6dpQ/r/WdgvcfN3HfOnj1OUc7CRt lRpBSRFtvqaM58EaOSI2bJuIp6/U0sbtw6oyvepdoOf1EJr7aCkFzNg2gDCtVE+Kua 0LwWWKKKOOWsZALkqnbAtULrnrj8X8jT/sMTjNq1V3CFj1LZFhLSLr1lKWGxOCkUqO RL2gN7+WDWiHGkxWzKUVdHEngBMOu03bnHiTG4kZD2u6Ifn2FRLFSaUTF1ye1+qWdW gvmt79KyABSZg== From: Benjamin Gaignard To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v11 07/56] media: videobuf2: Add helper to get queue number of buffers Date: Thu, 12 Oct 2023 13:45:53 +0200 Message-Id: <20231012114642.19040-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:14 -0700 (PDT) In the future a side effect of introducing DELETE_BUFS ioctl is the create of 'holes' (i.e. unused buffers) in bufs arrays. To know which entries of the bufs arrays are used a bitmap will be added in struct vb2_queue. That will also mean that the number of buffers will be computed given the number of bit set in this bitmap. To smoothly allow this evolution all drives must stop using directly num_buffers field from struct vb2_queue. Signed-off-by: Benjamin Gaignard --- include/media/videobuf2-core.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index cd3ff1cd759d..8f9d9e4af5b1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1139,6 +1139,15 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) return q->fileio; } +/** + * vb2_get_num_buffers() - get the number of buffer in a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + */ +static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q) +{ + return q->num_buffers; +} + /** * vb2_is_busy() - return busy status of the queue. * @q: pointer to &struct vb2_queue with videobuf2 queue. @@ -1147,7 +1156,7 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) */ static inline bool vb2_is_busy(struct vb2_queue *q) { - return (q->num_buffers > 0); + return vb2_get_num_buffers(q) > 0; } /** -- 2.39.2