[v15,15/56] media: visl: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231109163512.179524-16-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp558456vqs; Thu, 9 Nov 2023 08:38:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLdnzS0urQcr81gHYEcy8iVtO2Ba0BGD4LXTjK1zfTQbwe0cegR6f1q11/md+zhHIbveuX X-Received: by 2002:a17:903:24f:b0:1c3:4b24:d89d with SMTP id j15-20020a170903024f00b001c34b24d89dmr6087130plh.40.1699547883974; Thu, 09 Nov 2023 08:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699547883; cv=none; d=google.com; s=arc-20160816; b=IMDFohEpZDpM/cX8ryTCVBnnjGd8UwxkhEP4ieWpDJ94nK7wmLXbe8Qt2nVBMleMxa /nQ1TzUvSVA9f32mz50QlPCGCqLNOY5Ey5YECOIZQ4x15u+udiKDxhL+pGMCVOjlM2Ju XbbdjNzCF6WZAMK19h+O6/Y/gU7/APBg3a3MsqDEJF5sfHKyWCHDzx55fGdVv9/lvxci vN7XX8HTz7Tg7x+vi0LsxSEL6BZcdSFepHSWB8o9m4k3HSqqWcZVPaxzNyWKRe/geL8U cA9qyj1plkBC+JYvEBqBL7XlavUjpXdUsGkPMWvZ1qM0nke/AHN0iC5scyvO1GfSUuiy CetA== 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=+NTBfGp59n0PnYtf31rUtCQAcpuxX8N7AbBeAm+gbVk=; fh=0feO+dijs1n0Ajx6t/8nTJTnUNVDBwlnbcoSUECkE5E=; b=Oam5G00Y1NmtP2OeUN/ei482d6nWoKNUumpRWybjVEP3QjBvHvprg1bpBNwd+Q+UNP m/F/wIoYOfv/rZ7NmiBBXdnbUc74k261Qw3kh2M5c0BRg3l6MiwW/oISUUCLttto71d4 X+vPGroGUg+VSzePDQcxdzAkH4RQnrH14n6nuph+ywrAbqDfTnlqqUHYLzuiRlndZP5A w5W+1swemWwwhHc/dVypXk+1lIelT40ResU6FlR4vS7dWJBjQTTvGBfZmOoUl/0z1oqg P+6xTb+Yk2Dg+wvfGpTxYHhq4GJlzKcVotCYhHJ6ycCAUYbTX/L+X8VzRJMiP6K7GjQB CLIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Sp+r3h8s; 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 e11-20020a170902744b00b001c9fe071f2esi5049699plt.128.2023.11.09.08.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:38:03 -0800 (PST) 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=Sp+r3h8s; 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 E30B7831334A; Thu, 9 Nov 2023 08:38:02 -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 S234691AbjKIQhs (ORCPT <rfc822;lhua1029@gmail.com> + 31 others); Thu, 9 Nov 2023 11:37:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344186AbjKIQho (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Nov 2023 11:37:44 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32E003840; Thu, 9 Nov 2023 08:37:42 -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 0EA2B66076A9; Thu, 9 Nov 2023 16:37:40 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547861; bh=GMdrS9H73jEXIx3NI8elWR0CS7o8SzXLjp+XU4A5h/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sp+r3h8s/RGpyXGZiS9XR0J7Ap4gS7YYgP3zGz8sCUWO6HvaiJdHnswvVnn8im5Mn NQKAT3pvKigJz4cOm9XToadxJunpggXfZMFV8kO2NysCupJzoqPTe6+L9pQipxFbHC 2tuB5RgHdsJUD7bzSjNuUUBUyMABRwrtiVB4Yvq08LszRcA9X4QJJqLl/WPes+mVqT fwGAo8TmFqFhoCgEbIqPVO8fb5XojLeC10AuoF843QrwrK1C5M5Ftd5t7YywLyrF3+ Ntx0Kzn17bAMOueZyb0IJUqGc3DfjF5BCEdJEfl5DMyMXQt1RxLTnocHeTZywjV1Og +R6g0BmOgr3AQ== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> 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 <benjamin.gaignard@collabora.com>, Andrzej Pietrasiewicz <andrzej.p@collabora.com>, Daniel Almeida <daniel.almeida@collabora.com> Subject: [PATCH v15 15/56] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 9 Nov 2023 17:34:31 +0100 Message-Id: <20231109163512.179524-16-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163512.179524-14-benjamin.gaignard@collabora.com> References: <20231109163512.179524-14-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> 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:38:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105122010418160 X-GMAIL-MSGID: 1782105122010418160 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Nov. 9, 2023, 4:34 p.m. UTC
Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array. This allows us to change the type of the bufs in the future. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> CC: Daniel Almeida <daniel.almeida@collabora.com> CC: Mauro Carvalho Chehab <mchehab@kernel.org> --- drivers/media/test-drivers/visl/visl-dec.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index 318d675e5668..ba20ea998d19 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) for (i = 0; i < out_q->num_buffers; i++) { char entry[] = "index: %u, state: %s, request_fd: %d, "; u32 old_len = len; - char *q_status = visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(out_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, entry, i, q_status, - to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd); + to_vb2_v4l2_buffer(vb2)->request_fd); - len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len += visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); @@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) len = 0; for (i = 0; i < cap_q->num_buffers; i++) { u32 old_len = len; - char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(cap_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, "index: %u, status: %s, timestamp: %llu, is_held: %d", - cap_q->bufs[i]->index, q_status, - cap_q->bufs[i]->timestamp, - to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held); + vb2->index, q_status, + vb2->timestamp, + to_vb2_v4l2_buffer(vb2)->is_held); tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]);