From patchwork Tue Oct 17 14:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 154333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4188601vqb; Tue, 17 Oct 2023 07:51:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtB4HdGL8nHip9qnLgbayfp31ji2Kqm6tQo3WcMxCNEtHCpqyCbg5Nh+MuSYyBBShtLBFw X-Received: by 2002:a05:6a21:81a1:b0:16e:26fd:7c02 with SMTP id pd33-20020a056a2181a100b0016e26fd7c02mr2039187pzb.2.1697554316273; Tue, 17 Oct 2023 07:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697554316; cv=none; d=google.com; s=arc-20160816; b=O5sKhBudo6WnS4uttG0f4XcPrWxAwl9EzfxKmyJKhCCW0IpK4bQfpXQ6Pa2bEDLuIu 6FL4xJhJJ2vFBC5AfUTPe4N4ojJjEnqS0NEoiK0yqUTLj9i9JWKMtG3oxZ2nYkQdN0oC qH90SF6FP6a7pg3hQMQkKRU0t6lT2sO0KwzH6o1bRZ/pfchyI5KcK1ydrRnRZQ/fAfln 7wlNzVZJEUAZCaSczM2tO00yhJcFw8EWIcR+J7ZcP/iaaejfjRLn6B979isalO7P4XHo us0rzr+lMf8YS8x0Svcy0MBNYdopDHnG+Razz0KtKDj0l7Gzyu5iBvXjnwd1ou81rUWE fjTA== 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=UoDww2pjmIJlPGKeU3mW6oYKdYBerEz2yPdVq/oBEhg=; fh=CvL1xjq7cAmV80HKhOVeAebMHLceLC2GOvcrwdD6rg4=; b=F6N1ouEEhutlgkbxJBfszlYjnPDxtcXYRK3A4vl4oQJ6kdYJzPbXyxwZ8gmDTr1wpT dVGWihytk5fWpM+APLd8xKTcsWCpPK1wdqnvPTdwyBNwIDPyQaIeMXHg2KdgrwWpikLU Wbb3HS7ps9h9Ko7cqmuJHWQz/uYfnBgJTnJSSETZfq+LVLjJ2RwCm/41UInFFXYIMsZ2 T6nG9I4fEqIsky0gARdoKBiHBjoDTcB+HyZlPvMwkUG8rnYxGSYbK0zoSnVHJGppO6W1 1qjNI4ly6Y/TIbsVCOJVjz6sqxYz0Xdr5aL4U+ls93aVhfDC2ec5gvCfGc+Aa4Ho7Er7 o5gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Y8zewQ++; 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e8-20020a636908000000b00582dcfe3b41si216154pgc.374.2023.10.17.07.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:51:56 -0700 (PDT) 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=Y8zewQ++; 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 4D1A580293FD; Tue, 17 Oct 2023 07:51:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344524AbjJQOt3 (ORCPT + 20 others); Tue, 17 Oct 2023 10:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344250AbjJQOs1 (ORCPT ); Tue, 17 Oct 2023 10:48:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95051137; Tue, 17 Oct 2023 07:48:19 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7205:da49:a7e8:59f8]) (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 07BAF66072FB; Tue, 17 Oct 2023 15:48:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697554098; bh=tZ6YL5Kag5Wmq0rewNbqrl8NQzJoo9tTn4Lybls4JrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8zewQ++AjPy1+hJgoGWfX7PsNxICesqtzaKe/s0PKZD+SDWJQPa2sz7KqQ8jTc9n q5gZ3TQuTjkUcKi+DW8rPQer/jAu6TsnLEC3/0Ircj1/csJxg1Rj2SN/ohgSeW0Y5f wp33/Pc75r3sdhqIaA2UKXJ01tNOaNNF5rsOAxDXDxTTaVmaXAKT1Rr858oOeMpJ18 +y3MEqoBNkzlMxu1wzaHUY77HD87CJmW2pBH7jT0VYRN5XJdARbPKTgW3n8mKDJTjm SF5NGWS2shqEleLCjX2J3T+FhZfneji+v2H/qslHPDADCB1/+JAFI/vIqxslgQD1kO eeTBgMtfwLRHg== 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 , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger Subject: [PATCH v12 28/56] media: nxp: Stop direct calls to queue num_buffers field Date: Tue, 17 Oct 2023 16:47:28 +0200 Message-Id: <20231017144756.34719-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017144756.34719-1-benjamin.gaignard@collabora.com> References: <20231017144756.34719-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Tue, 17 Oct 2023 07:51:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780014714292855104 X-GMAIL-MSGID: 1780014714292855104 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 futur. Signed-off-by: Benjamin Gaignard CC: Rui Miguel Silva CC: Laurent Pinchart CC: Martin Kepplinger --- drivers/media/platform/nxp/imx7-media-csi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 15049c6aab37..4c467fb82789 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1245,6 +1245,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct v4l2_pix_format *pix = &csi->vdev_fmt; unsigned int count = *nbuffers; @@ -1254,14 +1255,14 @@ static int imx7_csi_video_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, IMX7_CSI_VIDEO_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;