From patchwork Thu Nov 9 16:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp555719vqs; Thu, 9 Nov 2023 08:33:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8JBEGWWO5RerlPy/jXjC/g0AYgJDfRNa1CJY+9JhO1O/T82TTD51ruOGdZDfPR7mT+AvJ X-Received: by 2002:a05:6a20:96d1:b0:180:d33d:9256 with SMTP id hq17-20020a056a2096d100b00180d33d9256mr4372173pzc.58.1699547610788; Thu, 09 Nov 2023 08:33:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699547610; cv=none; d=google.com; s=arc-20160816; b=PYOQe1OzAtRsgLOlDwpZVAtL1j57vrb3DLmZuXDYcwlupfWfdkcfIV0xO12nvik67r JcLYftRQ/VovqE8B0wM/XmoiJhMR7Ywc/WCwhkp/5rBSF4S8DKpRNDo8e7CsexDXnXTy DOnPza5eIdYkH5IPCCUnpMWFZQufZFDKoHTznEyHWTvbA3TbL+fUuNoblrf6H5ixoxga lLb4PTAfmAfSuWrnWCfKDX0HW2FtH2ZlGiYduwtnbcQZVJZNRo/22XoCuEkHr8wMx2uT wQPMM2ES/kAhaPCsviogQ3kcavll/ggTY281zLZFzKMMQIuv8mr14oi9k6u8VOw77efD uiVg== 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=MwUqa5HdF8CXo9llbsa9/qBISHufFoE9to4waBbzjLM=; fh=+cz7VFn5lXwyEkr8YqQHlm8vP6/A+SqznlOaRcZfgps=; b=cPYgAwr5o9VU+Rdotq2Rsp4vwVJ5yQExfLxdFnEcV/jK53AjZqtsw0KxkA2UZOfi4l OGfQp1EJbAsvUWNx7BMhDfgsCeX7p2GGod5Kim6isJoCfUN+DVGigWTy7oVbsFHqZRRt JAiOJySNatHCb2EvJrcCBxSmhVPOZ+Xvws5X/kFDBS9a8TE0y0sxv02ZWPXw70SsAA1H GHAGhKQN3lhI1L2EzEqGK1HGrQNvJg7D4TJGrFN5HY2DE7gQwXrxKj7JBPNOSzZOiz6W /COjmoUUR3WUOY5qQA2al8vGeu3eM1DBpAsr0LW9WnVxV9tsYY/XM6p4+7weM4rQbhzw b/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fb4PLgLz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id b11-20020a170902d40b00b001c60783985esi4909256ple.93.2023.11.09.08.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fb4PLgLz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 BDB54832A77C; Thu, 9 Nov 2023 08:33:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344206AbjKIQdO (ORCPT + 31 others); Thu, 9 Nov 2023 11:33:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjKIQcy (ORCPT ); Thu, 9 Nov 2023 11:32:54 -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 AAC6935B8; Thu, 9 Nov 2023 08:32:47 -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 6B59066076AC; Thu, 9 Nov 2023 16:32:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547566; bh=HIlfDDc1yt0AkEeBwOv0mebU/q9oPujB/yaRxbJKFEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fb4PLgLzYiJkPvCBtHHF8dH8qT8cEJHNQvf8/8aa9TTftdKdATmuxa9tIIyLGKVHB 15c8Dig7sOncURHuDW+o7X9HGNRPAhrvhZ5B3yurwe6lyfrJKiJL/OL0zdLfTL4l2w Fc1UU/1HeyFbTP7ZPhQXHILHNY/R6K4dm2K99z4WxjJJwHAPL8n54kGjNlnVSH0BqH SsEbwN4wwkWFO+VaaQfJU7FwzSnmc+NHongcNY18/UcK17tYtCYUnwiMMnXhfGvq2G liZpxpRAPCA50qeVQ0Hd7Clan8L/SX4sUMmsHtp3IfFT+ZVOYahEcv2ZMnttGWfE11 /isYB6WRIHaOA== 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 , Zhou Peng Subject: [PATCH v15 10/56] media: amphion: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:29:22 +0100 Message-Id: <20231109163008.179152-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163008.179152-1-benjamin.gaignard@collabora.com> References: <20231109163008.179152-1-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 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:33:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782104835498793407 X-GMAIL-MSGID: 1782104835498793407 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: 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)