From patchwork Tue Oct 17 14:47:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 154314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4187100vqb; Tue, 17 Oct 2023 07:49:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfV42iAN8i6P0kHUqlqniEIfp+Wjlm8noY5/vM/sZXXdQcmbNkNH6np8zdWCtpgH9A9UTl X-Received: by 2002:a92:340d:0:b0:345:e438:7381 with SMTP id b13-20020a92340d000000b00345e4387381mr2544211ila.2.1697554163831; Tue, 17 Oct 2023 07:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697554163; cv=none; d=google.com; s=arc-20160816; b=evyNd+DfksD7My59UbrF8N4SANSL4/ZoqtPw7ewIPbxurMWeNMYCextNpzBtaWBtgb i5WBGEfS2aAUQgGqokiIaEGIjcj75qAL8KXyHMf51O+HdPwK/A8Nv4K3mJL/x/7mCakM jeuWz3uN3ac7hPDOlY4LtKUoSp6x1Rf+wu1wSIbF57IfuCbHd6UOOwZTAfiNX7Ui10dt HKVtrDPRODo9Nu27xCTTzSBgAoOfqgdpXoXYEYOKiHWjQc92yyxs7Wct86H/WMddW8vi 0SHtMZ5cul6xU+M5gd3KBc3sHt8+pb5WwYEou1aMf76zF9U8uFZanIDKPICzw7fCkV8R 3Puw== 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=UJv/P+Nh4e+8wRHjmCC/WaUSE57Oe6GM9ULEWpvlXDU=; fh=YhVWgOX82fKLE5M+MoEX/CwrdcPd8SQ1dctjbZBk3rU=; b=y7feMjhtTaNFz0Q2OvByFGxEJED7S0wYdcRFkLBzxppqltn1Z58xEq6tNzd3fVVEoe 5YM/FDStC4Gmxed8MW3ayxyfIH9pGGsexmk/PbSAzfLG8Tm7O98nJYeAaGhxP30+KxxH of1DK2t1Ywy6YZlBDgoDnQyRxLGVpSUaNNCaXO32pi16zEXLUHlJJwxUoIjl+Rl9IeE9 3p+iKzVj9G2iP4uU5FhnEQvCvBDrnZ3bGsBz/Bn2+M2QNkhF7yAUzSZEC77bBr5SyPY7 v8MtpMT/RVk8U58z854Sn8Fs1pnzvZ9041v71wv2O7HUHhKQQGDpgVDyYXlLFIh8+8C3 Ee3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=O2WZLl5m; 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 h11-20020a056a00230b00b006b798c24276si1868303pfh.348.2023.10.17.07.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:49:23 -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=O2WZLl5m; 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 E8C0A80E06AF; Tue, 17 Oct 2023 07:49:22 -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 S1344215AbjJQOtK (ORCPT + 20 others); Tue, 17 Oct 2023 10:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344145AbjJQOsM (ORCPT ); Tue, 17 Oct 2023 10:48:12 -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 DB532FC; Tue, 17 Oct 2023 07:48:09 -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 47CE9660732E; Tue, 17 Oct 2023 15:48:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697554088; bh=QK6vBd/Ng3qHGes+E88MCZd+SSvPo4pf23W9jWiexEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2WZLl5m09B0lLkU9IyEDTOiRlVLRPRRG1tUgYxmOaM7ZD5dvJ44K96gMRsMzLhHi X0PQzRtc6NYw9Osq8WFIPVpUU1fH2vRZMJ8mgF+mfjmOtSIWwL8LbUiFhzpRFGf2ic 44Phe09NfUdEclc0w2PnmL1xDPrEIkuUzL7CCYyo0Sxj9Vbntbqhe/yzuzoloaYBjE 1aUzjcG/coRQiEw+6hPqRiWTsxoUe8cDofeeBRKlfNDtd8CIF/ML0G1+MOSE/nQRkQ W7tLGe2V+gT5TS1HeYPentYZ1t+dvNUbD2u8BT7KQZs5EPB9hfT4SFt2fXtz1IiB4C tgc/Se5JUT0MA== 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 v12 10/56] media: amphion: Stop direct calls to queue num_buffers field Date: Tue, 17 Oct 2023 16:47:10 +0200 Message-Id: <20231017144756.34719-11-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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, 17 Oct 2023 07:49:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780014554888956192 X-GMAIL-MSGID: 1780014554888956192 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: 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)