From patchwork Tue Oct 31 16:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 160210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp364671vqg; Tue, 31 Oct 2023 09:34:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGERaeG2OBA5/vKgFkfnoDICPAA70sgK6340Ui2QNWVPjW31sYRzEHGLvdZrKj00S8qHhaM X-Received: by 2002:a05:6358:903:b0:168:e958:a4b with SMTP id r3-20020a056358090300b00168e9580a4bmr11581845rwi.21.1698770098587; Tue, 31 Oct 2023 09:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770098; cv=none; d=google.com; s=arc-20160816; b=mHbZB1eu53NuWcNG8gYGsWUojf9UW+Y5G6fU9sIXgLmIalXfK+n0+VhGTWu9v2uxU3 qsN9gf9FV+Yz+sAxS1BLDPuaEqX4gXXB/wToIe/8nC0aBG1i9c7jGYZFVOpHdCriff7f s+b/UCXWjXrRYo4vlsyTSd69C5mnQx2G0ZjMKu6pPJmC6t4QFL8bPs2qkwyHhlk106/S rs/vlLnaVgcXCCuGyAb3Ukp4BCybpQRVHCReDWDIqeqQcyuxiMa0sBR831yHMR8xONxz Mirci7dL/uxIHso18EZmDB87Qu3hihwOPURB/iYqLjRnucBoZZg75FkkNPdlEzVVfcAs OFnQ== 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=Puy0NuCUoizD9tUXGoeztaPEYZUcHsDAGMF7ZhtLfh4=; fh=171ZbtLkqTQvfc21XcAM+Vd/toNFohdADskHHVOkNqQ=; b=bqKohYNtJw2C2IyS1MQ/9W/fMXecVEcS+mLs/uZuLd7dj84joqm8XLZpvDVPxvb1J3 12jmgvKfy2CsnBGu0SFt8tAjGy4jspAk/slh2ucdnYOtodOmiTO9K6TWQY+Fqh/bq6p6 FwGXvGEDGmBejilDZGvLgq0Qm0fTh0JOEOmCMKWI3SULtv9j0Owo83yQRzkKBlTBki7U lj2hhCSij/kVwQxa8h33qhWIeguvoc/21tozUlh6RUn2rVA2QSLx0oODzLc8Ur6tYPY1 WJOS2x3pcv4aWMn8yvsAqtwUBW2Bvqo8kd3pc7+gvoFUGp1dbjg4W9ckWGDwnvlo/LxN LkiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IywCB4dB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a5-20020a656405000000b00578d026e2eesi1198726pgv.283.2023.10.31.09.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:34:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IywCB4dB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 19B2A80BC508; Tue, 31 Oct 2023 09:34:52 -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 S1346327AbjJaQdu (ORCPT + 33 others); Tue, 31 Oct 2023 12:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346083AbjJaQdB (ORCPT ); Tue, 31 Oct 2023 12:33:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0982A1707; Tue, 31 Oct 2023 09:32:04 -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 6E9BF66073CD; Tue, 31 Oct 2023 16:32:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698769922; bh=5BKm2pXhsA2CwROeeB4gGq1coubFRjY0WIZn0P61OpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IywCB4dBTA9zDzRW3J7elinUB07Jf8JcOY3gAOI2Kpa20M/7Bgj+Gd7/S/vM0ctkj Tfe0lwLdPNOnt0haXoYXXaNKnaoJXtNAw/EwDz3R/FRc+Z591yD0U5/hj4KPWQaEBs F+LRYrrK4cK4oyLhEPrwMm4FmCHBCF10zR1Bnk8MexyPR/L12JyeTLNRSENXqaecKD Fbofk700kX37LhAgHO7Fh4aZSpukej5JKzjyI/N7IoJcr3bAz+w70ReiA19AfOgpHC SmQzcN/RGWCpcMeFB9B+9Fu/I7bGIQT04b6Rf9jZBq+EvwXMMDQeHbnvoLzqoOf+J0 bmeJ+U0Ndd/Pw== 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 , Steve Longerbeam Subject: [PATCH v14 31/56] media: imx: Stop direct calls to queue num_buffers field Date: Tue, 31 Oct 2023 17:30:39 +0100 Message-Id: <20231031163104.112469-32-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:34:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781289554619366717 X-GMAIL-MSGID: 1781289554619366717 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. This allows us to change how the number of buffers is computed in the future. Signed-off-by: Benjamin Gaignard CC: Steve Longerbeam CC: Philipp Zabel Reviewed-by: Andrzej Pietrasiewicz --- drivers/staging/media/imx/imx-media-capture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 4846078315ff..ce02199e7b1b 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -605,6 +605,7 @@ static int capture_queue_setup(struct vb2_queue *vq, { struct capture_priv *priv = vb2_get_drv_priv(vq); struct v4l2_pix_format *pix = &priv->vdev.fmt; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -613,14 +614,14 @@ static int capture_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count;