From patchwork Thu Oct 19 12:51: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: 155509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp359053vqb; Thu, 19 Oct 2023 05:53:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwB5t1sLcAMPl37SzVcyN+xSimA0e7MA07fZkYLy/hz3F84iLOBcpS2Vf2JFSrefUfMuNx X-Received: by 2002:a05:6359:3219:b0:132:d333:4a5c with SMTP id rj25-20020a056359321900b00132d3334a5cmr1675012rwb.10.1697720010838; Thu, 19 Oct 2023 05:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720010; cv=none; d=google.com; s=arc-20160816; b=KYRfrE8tEKl33PzDpn6hxz/hhi3AJ9p9viaUMlV/SmfE2yj93VGT3A0aCvg42a+v6p kCyL9yvN6rEIBPBonDtEUxVViklLChDnJnoMxBbPrDbortQfZUd4M0J+b/w5LB1gyGFv HXM+iBNnQ1EFvp1rMS3J3pY83DSsmr65eeVbfAdaRiRObrgNvNLfTuwmXZcBK3jduLaF SFlAwASshqbQd/BLVQyco8aO8TBsGbWUoz6X4TYsL13gvdZ7elaEHFOCoAMYw+XAp6aa OHm/caBmY1OBFUVIOn4hY+tD36JBs06fnHgu6xB7ps5YG9OGnWzwdFo/5kyyKAXXU8bq s4Tw== 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=ZkzUmLRg7Xnu1pLEglSiK4xCI6tZYQt8wr3MwL9ylEY=; fh=YhVWgOX82fKLE5M+MoEX/CwrdcPd8SQ1dctjbZBk3rU=; b=m+cmc1BSdILseXvheYD+cBAtI5vDu0F39+zqFVDd9LbNJJNHVjliE9ijtmCo3vjeeE DAQrBEJLbJU41j7Iiyes4GitdEEod9GMTPYPGURYXjveDnHmeZsqeOlbEX1+Q9NxZNKR 6bu8PWI1p6HxWgcIM0NQP/CirfqIzUWCZiNzJgRsr7R9PCrqq2J2myvcR42anJE8CNgC xmpgNR45Hm4+xp5EMUhVAcNRgN928ZzIq+F1B336ejYSHLbeC69ntVOYiDB+hJdK6EF0 My0Qfw+M3SDPLoWA6JSUvErZTQB18mWkPTKFsm3y4m51Ak9t2hU3P96Hbh/WHQBsxcw9 yy4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kTPkF2AQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z19-20020a63e113000000b0057cbd803b30si4473744pgh.654.2023.10.19.05.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:53:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kTPkF2AQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 9A45582E297E; Thu, 19 Oct 2023 05:53:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345761AbjJSMxB (ORCPT + 25 others); Thu, 19 Oct 2023 08:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345735AbjJSMwi (ORCPT ); Thu, 19 Oct 2023 08:52:38 -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 3FFB8119; Thu, 19 Oct 2023 05:52:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:ccea:1fb5:34eb:239b]) (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 B3E2B6607345; Thu, 19 Oct 2023 13:52:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719956; bh=PuFoOUa6JL13sN6HuBrtSIThFlotKKJZbkNL+kdatwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTPkF2AQznyVYC8DaPRrFbF0ogUdZ1fQlt8GomTaaDRXpNDUcTUfevb96D5sZ/SAZ Yq+ZxuGcoZ+ftzW5buE7C719XceaEvpP3G/f5QEfsuvJgrUaItpChLGFuG5nsmNnGD auE1UFWhSI/bG9t3h5zRFfz6/Uim1byTGgq8kJcDNn4rNMXi+fn5vC2ubWymywUpcC Jwg0Gn2cYj5g9UL1zOUtCPP0saBhtmzCHj8BHV5Xx47KyjR2mWhkXReoM0uR9SOAib g9y5A5KzCgvrICbHPhQ4VxhtKrlNX4Dx7ezB/0d9Zmwd581ux94GdN19KzhmKYHBHU cYx1aCiYOj1cA== 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 , Zhou Peng Subject: [PATCH v13 10/56] media: amphion: Stop direct calls to queue num_buffers field Date: Thu, 19 Oct 2023 14:51:36 +0200 Message-Id: <20231019125222.21370-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019125222.21370-1-benjamin.gaignard@collabora.com> References: <20231019125222.21370-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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:53:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188458309443498 X-GMAIL-MSGID: 1780188458309443498 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: Ming Qian CC: Zhou Peng --- drivers/media/platform/amphion/vpu_dbg.c | 8 ++++---- drivers/media/platform/amphion/vpu_v4l2.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c index a462d6fe4ea9..940e5bda5fa3 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -87,7 +87,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num = scnprintf(str, sizeof(str), "output (%2d, %2d): fmt = %c%c%c%c %d x %d, %d;", vb2_is_streaming(vq), - vq->num_buffers, + vb2_get_num_buffers(vq), inst->out_format.pixfmt, inst->out_format.pixfmt >> 8, inst->out_format.pixfmt >> 16, @@ -111,7 +111,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num = scnprintf(str, sizeof(str), "capture(%2d, %2d): fmt = %c%c%c%c %d x %d, %d;", vb2_is_streaming(vq), - vq->num_buffers, + vb2_get_num_buffers(vq), inst->cap_format.pixfmt, inst->cap_format.pixfmt >> 8, inst->cap_format.pixfmt >> 16, @@ -139,7 +139,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) return 0; vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < vb2_get_num_buffers(vq); i++) { struct vb2_buffer *vb; struct vb2_v4l2_buffer *vbuf; @@ -161,7 +161,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) } vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < vb2_get_num_buffers(vq); i++) { struct vb2_buffer *vb; struct vb2_v4l2_buffer *vbuf; diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index 0f6e4c666440..87afb4a18d5d 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -439,7 +439,7 @@ int vpu_get_num_buffers(struct vpu_inst *inst, u32 type) else q = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - return q->num_buffers; + return vb2_get_num_buffers(q); } static void vpu_m2m_device_run(void *priv) @@ -587,7 +587,7 @@ static int vpu_vb2_start_streaming(struct vb2_queue *q, unsigned int count) fmt->sizeimage[0], fmt->bytesperline[0], fmt->sizeimage[1], fmt->bytesperline[1], fmt->sizeimage[2], fmt->bytesperline[2], - q->num_buffers); + vb2_get_num_buffers(q)); vb2_clear_last_buffer_dequeued(q); ret = call_vop(inst, start, q->type); if (ret)