[v13,15/56] media: visl: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231019125222.21370-16-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp360734vqb; Thu, 19 Oct 2023 05:56:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgB4AjSJGcPcYI84mSZrlQmNIq0HC9YR/pi9OJ59MwEVojVxg2VkeN4T/I9zxeasMTpD96 X-Received: by 2002:a05:6359:3015:b0:15a:ca3b:5fc with SMTP id rf21-20020a056359301500b0015aca3b05fcmr1746885rwb.27.1697720215795; Thu, 19 Oct 2023 05:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720215; cv=none; d=google.com; s=arc-20160816; b=kGq4gNwxkn8f+RsD9G07PmJ8PaN9vfIEeqkTPU1zfVAp05TLJUPl3W7RJtn6gdvvL6 SSksWVvgNNvbMyNWVtReaTnPPvIc2I/x5wY4MgS0YhyHY6iDHz9xz2u1vgPpZ+cCaF/b toH+MQ5MtJnDq8tLnLqGeELjqYXQkH3rtU6sk2/2Wtti/rFWa9aQmMKdIunNbcpYd0E0 M0Izx9GESxmt4iTit5nfVOzwP06y1PVWPoCxKjJTdeDULIH9oBq26Ga76ZklWr9GAaWE l2X4wT6jpyREWqtPkIfxy+fc9r14vat8ws18ruPzAFVzbajzJYnxMYx/1HcL2+4dwdus XG9Q== 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=NyJ7BF1AH0Xaf2XOQr0Ummtk6Obj50YB13wLLlG1vAk=; fh=R7B7Bon9pv+GFCDou9bQ9Fb3T633P/NGL4WG9w9NtOc=; b=UaRkcirvAwLqrgSiwAfEw890OzdQ5RPVDc08ByvY7Xsny31eKb5fafbH0HlrGqZiyD Y9kMUflRKG0V4xBBgIHwasJjhk2l8sI4aVNTEBVE4TscUw8SY8ckrdyn7PBeYSs/4xcm nDKxO7tRW5IRwTxT7XVb12ZjzhIbo9DmTZuYnrbm3qqonQIGOzNqFDquzVblLlCDnOBK RiP8ISQ5IgHruhUzdf8jpYoJWQQKUlFkQxoHE6y0mqK9z5flDtO497cxCbE8Xet9x9fK D+7ZwEPJyvFvTEyjyj9Sf+Bd5A5lQdryfzb4Ggc1xk70w5pyrpTClNDYKgeWLzqxCQRc 4Xog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JjdLclCP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e10-20020a656bca000000b00578a56baebesi4475729pgw.674.2023.10.19.05.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JjdLclCP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 869AE807600C; Thu, 19 Oct 2023 05:55:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235319AbjJSMyc (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Thu, 19 Oct 2023 08:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345784AbjJSMwp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Oct 2023 08:52:45 -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 D096411B; Thu, 19 Oct 2023 05:52:39 -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 4C7E36607352; Thu, 19 Oct 2023 13:52:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719958; bh=b1HWvospKm41+ZR+lTHAwjFMrNIUi+qp4QEOx4PbCAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JjdLclCPhiIu7h9Loc+gRj84QPiQ0S7q7I6geT+3m/JHqRLoATk6ddtT7afJsn3dV igvqQ2BXlAzmG8++HlmmvxlYXxv8Monev0Urfau7bmsVa3Lj01Y+4Mz7t3Oi9CnEcc 5saCCcwl2HQjLolj6ZFswqO3se408sBv+T4px2MdkIBkEcjYPUP0pbD0NDcI+2Dfo+ LfgDCRuFR31xt3543oqp3TGuWz5s+09ciPDFjZNfnen5a1AUla7FCDUwcXtCA/4i5i 7Fmz1d0jW2P7KRoOU8q4jv/UHcqvYczu7NA/lMUjOlDATD0fQfEGF+Qh33O18JR51T C1sDZ/GOt4rkg== 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>, Daniel Almeida <daniel.almeida@collabora.com> Subject: [PATCH v13 15/56] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 19 Oct 2023 14:51:41 +0200 Message-Id: <20231019125222.21370-16-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 Content-Transfer-Encoding: 8bit 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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:55:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188672978654880 X-GMAIL-MSGID: 1780188672978654880 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 19, 2023, 12:51 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>
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]);