From patchwork Thu Nov 9 16:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp560378vqs; Thu, 9 Nov 2023 08:41:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPJgVrSSfC1mSz+veRJzBWu4gtr7algTRdCXn2g/u0aGKYeEyGFFbdHPIvZCw9DgFgITZD X-Received: by 2002:a17:903:186:b0:1cc:50ea:d5c5 with SMTP id z6-20020a170903018600b001cc50ead5c5mr6848366plg.24.1699548087719; Thu, 09 Nov 2023 08:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699548087; cv=none; d=google.com; s=arc-20160816; b=QR6k1mbr0OEMn08EeaVrpg1M6Z3X9A68Bl40cbqILLzAH2JWkUoi2Gqm0YXK7vXAVJ 62qUKjPqIT8Pm+bWWEMVPazTkNT25JE0b6U3yJNeemcje0w91lPMhfL+L/1mkNCUtALv EZIn5azdxaL3mwHE3XTIiwxOTxZiKTF/WbLm9l8zxGH91dakC7mexP0auNFnLMWF2LKF 1Xed3FxIsiUV6ZkqecpxuR0FNAOX09L4tG0SaZdAcWnl76LYQoO0sEdJmuhGXJrZ7PF2 uK8UMJTK9TwrsCUUaq41yCQMnv636JlRoC7J9Qp5VWEz4zDuqi9BXlFIPU1Odr8k3z4/ qG4w== 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=jv/kOyk7UXT4LRJ6UApG/l96JquUrJSEfPSP8BkGnrA=; fh=XtzzZd1/uBHMj8bc0wlsKn3p1KXiDvqXgKqHiQ4uF8g=; b=DZ0HMTWrViWYa0vp2axkrhi4ch7QOw/4iI56SgARYJv6jceD/VG5BuL5NoCfqw1+d3 PlPDLs7yC1QJwWrltQ/mTsIIiyR9aOeJr9WirnjIkwDee2n3QjF9/0+zZEX1YIPiLap8 kWgngEDCTbvFZM1702Pt53k8Jsds3/sK5adzVkTfnr3tRXm+e5FTIYxY+1/+AOQ4Mtb7 PoPLsohsmebyTdY1kWU6+8miuoQkcbNADO0hyi/lVSthVq2nr3D5gIC/7m0/zX3HMn57 C4iwe0SWASAkAZAPL0eVlwCxnEVAmzS894TTX07uuTFyL6VibygR6sQ8Di8pGarUMhtC 7L6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ohor7riN; 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 q6-20020a170902dac600b001cc5ada2b94si5687484plx.366.2023.11.09.08.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:41:27 -0800 (PST) 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=ohor7riN; 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 732428098428; Thu, 9 Nov 2023 08:40:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344597AbjKIQjR (ORCPT + 31 others); Thu, 9 Nov 2023 11:39:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344781AbjKIQia (ORCPT ); Thu, 9 Nov 2023 11:38:30 -0500 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 BA1BA4226; Thu, 9 Nov 2023 08:38:10 -0800 (PST) Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (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 8577566076A8; Thu, 9 Nov 2023 16:38:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547889; bh=NAD1Tg9V4Lk9LHSgDODg7rCyFDgRGStknZMuyq9WdTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ohor7riNt8UFwWBNJE387utTfyykBXgclwnYnsDEqCTA961Rkjf8Fj8zRgF7/5LH1 29Ylo/K9GxPlBxgIjFm6pXG7atsNz2pavF2tPsuZz42Hc75qnc8aOTvvW7HvtCnfLX ezf5fvl91U8j8Sd/ZSKSfA+5Hg0lCSsfxFLjJ08fcTDNh1m4ZdZfCRSyNeEINdd3Xe giuiZX8P/tLpVM492KUW0akcryKRY3CjVCBV2FZgTKVXMJ7BsFumDrlzWU3t6f8mNP pAf0ZhdF2HO5ZAEWD8sifo5Y8a6JL2yiuZJV06uvTcLL+6g6935GyvYTQeH1CLWE9f gBEWUoDbkhogQ== 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 , Andrzej Pietrasiewicz , Steve Longerbeam Subject: [PATCH v15 31/56] media: imx: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:47 +0100 Message-Id: <20231109163512.179524-32-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163512.179524-14-benjamin.gaignard@collabora.com> References: <20231109163512.179524-14-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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]); Thu, 09 Nov 2023 08:40:15 -0800 (PST) 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105335440544120 X-GMAIL-MSGID: 1782105335440544120 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 Reviewed-by: Andrzej Pietrasiewicz CC: Steve Longerbeam CC: Philipp Zabel --- 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;