From nobody Thu Nov 14 05:27:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 428B6CDB474 for ; Tue, 17 Oct 2023 14:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344553AbjJQOtq (ORCPT ); Tue, 17 Oct 2023 10:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344227AbjJQOs2 (ORCPT ); Tue, 17 Oct 2023 10:48:28 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17084187; Tue, 17 Oct 2023 07:48:21 -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 1B47F6607327; Tue, 17 Oct 2023 15:48:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697554099; bh=cgIhLamoTAyrHf1n6hVviu5qBhkc77pi21oIGVMTz4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Et2qh0exhWd+EQxNVR3PEaRMzhYiXeO7ZzstQXALbwT5VQHa5+89tWDYQ6zYV/E89 +YjYtbLLr+7J4e6bn5+Y1TsvQVQyRhPuPmJACmuy2U4H4RYH5Lri0q3zRzlo0rw/zI U0sRy7xI9uI2AW7gVUSjDE2J3pxDOCbpwl8sjY21KJkHkqTfVrqiI0iNlHGUYKSIMY aqrSa78+xTx36HkYx6PtD6op5kwIdCn2sbS4BebZZ4RZ0oclvWMK00KVJ2FTBr6B7p Md8IbVQzDcqxepRFOdHQc17EnixHJ6S2B0Rco5zFhY11YcwxvQRHz4U8ak8uJr0J7d CQX4ThT1XVNhA== 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 , Daniel Almeida Subject: [PATCH v12 30/56] media: test-drivers: Stop direct calls to queue num_buffers field Date: Tue, 17 Oct 2023 16:47:30 +0200 Message-Id: <20231017144756.34719-31-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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. If 'min_buffers_needed' is set remove useless checks in queue setup functions. Signed-off-by: Benjamin Gaignard CC: Daniel Almeida --- drivers/media/test-drivers/visl/visl-dec.c | 4 ++-- drivers/media/test-drivers/vivid/vivid-meta-cap.c | 3 --- drivers/media/test-drivers/vivid/vivid-meta-out.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-touch-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vbi-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vbi-out.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vid-out.c | 5 +---- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/tes= t-drivers/visl/visl-dec.c index ba20ea998d19..4672dc5e52bb 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -287,7 +287,7 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct = visl_run *run) frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf); =20 len =3D 0; - for (i =3D 0; i < out_q->num_buffers; i++) { + for (i =3D 0; i < vb2_get_num_buffers(out_q); i++) { char entry[] =3D "index: %u, state: %s, request_fd: %d, "; u32 old_len =3D len; struct vb2_buffer *vb2; @@ -347,7 +347,7 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct = visl_run *run) frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf); =20 len =3D 0; - for (i =3D 0; i < cap_q->num_buffers; i++) { + for (i =3D 0; i < vb2_get_num_buffers(cap_q); i++) { u32 old_len =3D len; struct vb2_buffer *vb2; char *q_status; diff --git a/drivers/media/test-drivers/vivid/vivid-meta-cap.c b/drivers/me= dia/test-drivers/vivid/vivid-meta-cap.c index 780f96860a6d..0a718d037e59 100644 --- a/drivers/media/test-drivers/vivid/vivid-meta-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-meta-cap.c @@ -30,9 +30,6 @@ static int meta_cap_queue_setup(struct vb2_queue *vq, uns= igned int *nbuffers, sizes[0] =3D size; } =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; - *nplanes =3D 1; return 0; } diff --git a/drivers/media/test-drivers/vivid/vivid-meta-out.c b/drivers/me= dia/test-drivers/vivid/vivid-meta-out.c index 95835b52b58f..4a569a6e58be 100644 --- a/drivers/media/test-drivers/vivid/vivid-meta-out.c +++ b/drivers/media/test-drivers/vivid/vivid-meta-out.c @@ -18,6 +18,7 @@ static int meta_out_queue_setup(struct vb2_queue *vq, uns= igned int *nbuffers, struct device *alloc_devs[]) { struct vivid_dev *dev =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); unsigned int size =3D sizeof(struct vivid_meta_out_buf); =20 if (!vivid_is_webcam(dev)) @@ -30,8 +31,8 @@ static int meta_out_queue_setup(struct vb2_queue *vq, uns= igned int *nbuffers, sizes[0] =3D size; } =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers =3D 2 - q_num_bufs; =20 *nplanes =3D 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-touch-cap.c b/drivers/m= edia/test-drivers/vivid/vivid-touch-cap.c index c7f6e23df51e..4b3c6ea0afde 100644 --- a/drivers/media/test-drivers/vivid/vivid-touch-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-touch-cap.c @@ -13,6 +13,7 @@ static int touch_cap_queue_setup(struct vb2_queue *vq, un= signed int *nbuffers, struct device *alloc_devs[]) { struct vivid_dev *dev =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); struct v4l2_pix_format *f =3D &dev->tch_format; unsigned int size =3D f->sizeimage; =20 @@ -23,8 +24,8 @@ static int touch_cap_queue_setup(struct vb2_queue *vq, un= signed int *nbuffers, sizes[0] =3D size; } =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers =3D 2 - q_num_bufs; =20 *nplanes =3D 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vbi-cap.c b/drivers/med= ia/test-drivers/vivid/vivid-vbi-cap.c index b65b02eeeb97..fcd7f40385e9 100644 --- a/drivers/media/test-drivers/vivid/vivid-vbi-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-vbi-cap.c @@ -124,6 +124,7 @@ static int vbi_cap_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); bool is_60hz =3D dev->std_cap[dev->input] & V4L2_STD_525_60; unsigned size =3D vq->type =3D=3D V4L2_BUF_TYPE_SLICED_VBI_CAPTURE ? 36 * sizeof(struct v4l2_sliced_vbi_data) : @@ -134,8 +135,8 @@ static int vbi_cap_queue_setup(struct vb2_queue *vq, =20 sizes[0] =3D size; =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers =3D 2 - q_num_bufs; =20 *nplanes =3D 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vbi-out.c b/drivers/med= ia/test-drivers/vivid/vivid-vbi-out.c index cd56476902a2..8f0da5d88bcc 100644 --- a/drivers/media/test-drivers/vivid/vivid-vbi-out.c +++ b/drivers/media/test-drivers/vivid/vivid-vbi-out.c @@ -20,6 +20,7 @@ static int vbi_out_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); bool is_60hz =3D dev->std_out & V4L2_STD_525_60; unsigned size =3D vq->type =3D=3D V4L2_BUF_TYPE_SLICED_VBI_OUTPUT ? 36 * sizeof(struct v4l2_sliced_vbi_data) : @@ -30,8 +31,8 @@ static int vbi_out_queue_setup(struct vb2_queue *vq, =20 sizes[0] =3D size; =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers =3D 2 - q_num_bufs; =20 *nplanes =3D 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/med= ia/test-drivers/vivid/vivid-vid-cap.c index 3a06df35a2d7..0cc7602b9fb2 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c @@ -77,6 +77,7 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); unsigned buffers =3D tpg_g_buffers(&dev->tpg); unsigned h =3D dev->fmt_cap_rect.height; unsigned p; @@ -117,8 +118,8 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, dev->fmt_cap->data_offset[p]; } =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers =3D 2 - q_num_bufs; =20 *nplanes =3D buffers; =20 diff --git a/drivers/media/test-drivers/vivid/vivid-vid-out.c b/drivers/med= ia/test-drivers/vivid/vivid-vid-out.c index 184a6df2c29f..24c6dc896255 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-out.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-out.c @@ -73,12 +73,9 @@ static int vid_out_queue_setup(struct vb2_queue *vq, vfmt->data_offset[p] : size; } =20 - if (vq->num_buffers + *nbuffers < 2) - *nbuffers =3D 2 - vq->num_buffers; - *nplanes =3D planes; =20 - dprintk(dev, 1, "%s: count=3D%d\n", __func__, *nbuffers); + dprintk(dev, 1, "%s: count=3D%u\n", __func__, vb2_get_num_buffers(vq)); for (p =3D 0; p < planes; p++) dprintk(dev, 1, "%s: size[%u]=3D%u\n", __func__, p, sizes[p]); return 0; --=20 2.39.2