From patchwork Tue Oct 31 16:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 160191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp363409vqg; Tue, 31 Oct 2023 09:32:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMVh2WzMbblcC1yw04XWGmk8jAvnGh03btQdasv3+Gk/6Ngx+oFlkL93e8pcnbo4DTvOIw X-Received: by 2002:a17:902:f908:b0:1cc:4598:6f46 with SMTP id kw8-20020a170902f90800b001cc45986f46mr5170897plb.57.1698769960706; Tue, 31 Oct 2023 09:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698769960; cv=none; d=google.com; s=arc-20160816; b=yD8yjqEkx9yl+robDAjOHIljjBvk5wgqVIjRiibEZingtkRiCXfx4AHCDadi81OrgF Vm/kTGExxj7Y7wlfWamTckuUHRS/djPAewCwB+UE1YUwm665dvLPlsNS5unuWrlSQk1g wLc9ExHaFjFvqDpA1bRQP6shtI3qwhblyJRQ9snXhhywd1iEcoA8bZtkHLwMyzGVIEoo /J9N9YCz0CMhC7uWoS0c0Ssl6Gx73lhkKftXHls5uYcnTAs0fyHC91Gzh0BnDESU5/I8 BTqzUFW2pRBfH1vgjTkE7CkAReRMDxL+2xsTJSrTXYAL6QudH9+Gyiklcldt0OfagKKm i/7Q== 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=GRJJ9CgN3SEVL38hHcIspkhKKqyXGzc33T1qjErI2kwjBMtnuuIrCqjPg7O2W9zcge bd2iNpM92vBCnkLQXMqrsgPeP9obiaGwKLYPW83kwT8bZYnlroHwlP+5WUubTIonTn4/ FJ89W/mxlGhF+qhmPGMbWVlUiYJoG5YBzCXAVoSeGVddiXMflwvXOGA//7tjw1g+A8VP rSyje/S6FlD/RumYCMxnfL4W99Se7BCweSf7lVC7epn0mP4+WepEp80gzjvaqJx88a9/ nVIi22k65BN8jhNFLqPygseBA7Mk1kkVGzlDvAZnoDF1dVcpntgegHJLJOyJD1qPjjVm 0epw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="LBV7G/Xk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id i18-20020a170902c95200b001c6223663b3si1226961pla.369.2023.10.31.09.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:32:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="LBV7G/Xk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id BB31180C2558; Tue, 31 Oct 2023 09:32:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345365AbjJaQbw (ORCPT + 33 others); Tue, 31 Oct 2023 12:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345329AbjJaQbk (ORCPT ); Tue, 31 Oct 2023 12:31:40 -0400 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 03E78FC; Tue, 31 Oct 2023 09:31:25 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:c562:2ef4:80c0:92f]) (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 491E766073B1; Tue, 31 Oct 2023 16:31:24 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698769884; bh=lM3wXK65Q+RBpyeYExb53Y3bnLmIcGL+rErhrVO2B80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBV7G/XkwLwua2e5Y2YJbUzPBJuexj9N6DGPE+tGw4/SkIejERboDu/JeXAl8u2wq 8nKIsRKjYsKG+j+MpvC9fHL512qUv2u7CUjRBYMGaoBDbS1mT8FoQyHdMljRFf78dB 6QsPdEIOmwjp70VVp9nOqP8nrAxIf33FMIewKv8Cz/fqH/zDUldtUWrfQ4F5jm3ukY oOzFh8AAh6Jn+D4nZhCXCJFEBUNUcwzWO+b5dQmryDez0xdEu52KKXo2tyvCUDeDuu 4cQhTKMXIBe69oxZif4VeCfTmXAS1A482LIjlCYFUH+y1xSOOQyYkAZkLpdPUiYtTa H9PB/YoTWFbRA== 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 v14 07/56] media: videobuf2: Add helper to get queue number of buffers Date: Tue, 31 Oct 2023 17:30:15 +0100 Message-Id: <20231031163104.112469-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031163104.112469-1-benjamin.gaignard@collabora.com> References: <20231031163104.112469-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:32:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781289410463420616 X-GMAIL-MSGID: 1781289410463420616 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 Reviewed-by: Andrzej Pietrasiewicz --- 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; } /**