From patchwork Tue Oct 31 16:30:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 160202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp363935vqg; Tue, 31 Oct 2023 09:33:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHV/9/LLgoXWPaI4mRlBkBwf2y/8QryyP4gOHbCmVo5qF29HIMofAgZ5TDYriXvZyAohFuP X-Received: by 2002:a05:6358:7e12:b0:169:65a1:655c with SMTP id o18-20020a0563587e1200b0016965a1655cmr9652234rwm.18.1698770018700; Tue, 31 Oct 2023 09:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770018; cv=none; d=google.com; s=arc-20160816; b=V9OOKVr+K9NbmKCY932dqyCzGPsXw3QjB9/SYhS5oA083Uep/631r1QfOMs54l3rj4 w8uUtg+LbM0M5AdxawQ146E2LIDeyjquDH0VJ9mJi151c8EeJ2gIZgr5eDfHpfIk9igL fag9YO1biPCPhbLWJzFCHX6+JIJrfnYUg6v9ESSfBYZNGf6lKCMMl7N9eX6vcaPq0WQW kaYLP+VluyIqSs01WQIZ586sIP6LcpmoaMgad4buQkIqEpwFLMURqCj6PLFaYHUkTaAD vM7TpIZaOMWnM7b1RHwOyJPwA6CJiBNzDY+BiggBNVG2T+bqL8jnFIa1FJ5y8erX3066 JRCA== 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=fK24xR2X/J25Varz1gbRDc6OpGweyQO05x32Hb3s1QQ=; fh=CvL1xjq7cAmV80HKhOVeAebMHLceLC2GOvcrwdD6rg4=; b=z2VTw8ytC/cam0tiEisJuKl87Nsr+B/iij+Em3BSITh83ZE03ri7LEqi/CEDncffJx TZ9YkyTgbpC0p8LOurhKby+B7TGjkX/1KmwChQqFOrDXkASLvSftGiikEptO67mVK+gz 36A3B3LHPxlrzCZtiKojDRI7VEtWLvf70JLZY9QmJOvfj784XPdN7Q5tpSlokCEAabRi iqEGsEhyeAvLb58/lNY6JVxOgWWu2x0yQaH2UOqwY2W3j3hDSm2wTBZc9SjzWFDcFecp kggDtSYeCFwQB6urHfAkbXqfTr+Ukv3QItrLItALx0d4WSMtwOdjuAL06KUkDNlScPyJ O+BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NupF6qYu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id g191-20020a636bc8000000b00563d9ff5157si1225547pgc.547.2023.10.31.09.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NupF6qYu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 CEF2980E06B1; Tue, 31 Oct 2023 09:33:37 -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 S1345345AbjJaQdX (ORCPT + 33 others); Tue, 31 Oct 2023 12:33:23 -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 S1346208AbjJaQcb (ORCPT ); Tue, 31 Oct 2023 12:32:31 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B069010C8; Tue, 31 Oct 2023 09:31:58 -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 1216066073D8; Tue, 31 Oct 2023 16:31:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698769917; bh=0si/CGsRIyBb9jphgz7l+oPg0Kqq5VWdQXJtmyKQgDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NupF6qYuVRPHOrBXWL/+DZD0nfW+l767vEUYpKZtDV4kN1yPXjOXh5qn7dsixWCtf cAdRLIBHZsnti0PT1nm1pGlUjxV35+rHJlOzDftWug9DsuhPB17QOFn/bn5Xl33zu7 v3N2xuY/IfH+0+f2PEH6hkF+4Ie1GifqLDzrOEsJbGjlYvhvBUYVD/BRPqiQ/0Qyi0 RMWsL1+7zLiLmN1HIaSi1dHI8xY3o6K4HcwncKSYeSYuuypEIrHpvIdUhicZ0dyEFa z390EVAmw3YDvL8dtMfAvrgciZeLdX+JgxiDc9nl3AVmtuVYzpDti/oHVdQeBsiaBJ QArrWNVDeVLTg== 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 v14 28/56] media: nxp: Stop direct calls to queue num_buffers field Date: Tue, 31 Oct 2023 17:30:36 +0100 Message-Id: <20231031163104.112469-29-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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]); Tue, 31 Oct 2023 09:33:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781289470746317592 X-GMAIL-MSGID: 1781289470746317592 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: Rui Miguel Silva CC: Laurent Pinchart CC: Martin Kepplinger Reviewed-by: Andrzej Pietrasiewcz --- 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;