From nobody Thu Nov 14 05:31:07 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 1F66AE784AC for ; Mon, 2 Oct 2023 12:08:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237129AbjJBMIR (ORCPT ); Mon, 2 Oct 2023 08:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237090AbjJBMG7 (ORCPT ); Mon, 2 Oct 2023 08:06:59 -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 BABC8F0; Mon, 2 Oct 2023 05:06:44 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:9537:67ca:c85e:d0ae]) (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 2BE926607370; Mon, 2 Oct 2023 13:06:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696248403; bh=c7kOTl+JvLUci3Ybxp5I5uKTMKcI7MOYLdh4Vrq/z0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OqQZxAT2LVLAeYL7eD5YA4yi8beiRC+4tzCcRUVjLzDntG5YUk5tqsDEr6BLF3PnY yR4Le+RHAkhUioczN5CSMpRFW3Pf1wV18AwCBSCsaNwoLJ4AuYkA2213vzH3iyrzfr vdh/X53Hthpu28asm/Gzec+nFZTD3tbJkGO3rBGWcx4bK3CFyAeSrC8tki/Cz6fqYj k1NcWYItpEG+yqf7VBcA8fjeJwtK/mjnwevFP4ltuhdRf1fKgSnpbmOoscXfsmcc4e tt5yJd8Ma+kLhTY0P6qksrg7UFC9WVLER6t7t0WtuFJYG4pmvesIYXFf3TJO8qWvwb CNfBqfYQMFSzw== 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 Subject: [PATCH v9 35/53] media: ti: Use queue min_buffers_needed field to set the min number of buffers Date: Mon, 2 Oct 2023 14:05:59 +0200 Message-Id: <20231002120617.119602-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002120617.119602-1-benjamin.gaignard@collabora.com> References: <20231002120617.119602-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" When queue min_buffers_needed field is correctly set vb2 queue_setup() does take care of it and we can remove the checks from drivers. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/ti/am437x/am437x-vpfe.c | 7 ++----- drivers/media/platform/ti/cal/cal-video.c | 5 +---- drivers/media/platform/ti/davinci/vpif_capture.c | 5 +---- drivers/media/platform/ti/davinci/vpif_display.c | 5 +---- drivers/media/platform/ti/omap/omap_vout.c | 5 +++-- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media= /platform/ti/am437x/am437x-vpfe.c index 63092013d476..a12c93f8b40e 100644 --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c @@ -1776,9 +1776,6 @@ static int vpfe_queue_setup(struct vb2_queue *vq, struct vpfe_device *vpfe =3D vb2_get_drv_priv(vq); unsigned size =3D vpfe->fmt.fmt.pix.sizeimage; =20 - if (vq->num_buffers + *nbuffers < 3) - *nbuffers =3D 3 - vq->num_buffers; - if (*nplanes) { if (sizes[0] < size) return -EINVAL; @@ -1789,7 +1786,7 @@ static int vpfe_queue_setup(struct vb2_queue *vq, sizes[0] =3D size; =20 vpfe_dbg(1, vpfe, - "nbuffers=3D%d, size=3D%u\n", *nbuffers, sizes[0]); + "nbuffers=3D%u, size=3D%u\n", vb2_get_num_buffers(vq), sizes[0]); =20 /* Calculate field offset */ vpfe_calculate_offsets(vpfe); @@ -2237,7 +2234,7 @@ static int vpfe_probe_complete(struct vpfe_device *vp= fe) q->buf_struct_size =3D sizeof(struct vpfe_cap_buffer); q->timestamp_flags =3D V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->lock =3D &vpfe->lock; - q->min_buffers_needed =3D 1; + q->min_buffers_needed =3D 3; q->dev =3D vpfe->pdev; =20 err =3D vb2_queue_init(q); diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/plat= form/ti/cal/cal-video.c index a8abcd0fee17..924465b37e5f 100644 --- a/drivers/media/platform/ti/cal/cal-video.c +++ b/drivers/media/platform/ti/cal/cal-video.c @@ -604,9 +604,6 @@ static int cal_queue_setup(struct vb2_queue *vq, struct cal_ctx *ctx =3D vb2_get_drv_priv(vq); unsigned int size =3D ctx->v_fmt.fmt.pix.sizeimage; =20 - if (vq->num_buffers + *nbuffers < 3) - *nbuffers =3D 3 - vq->num_buffers; - if (*nplanes) { if (sizes[0] < size) return -EINVAL; @@ -616,7 +613,7 @@ static int cal_queue_setup(struct vb2_queue *vq, *nplanes =3D 1; sizes[0] =3D size; =20 - ctx_dbg(3, ctx, "nbuffers=3D%d, size=3D%d\n", *nbuffers, sizes[0]); + ctx_dbg(3, ctx, "nbuffers=3D%d, size=3D%d\n", vb2_get_num_buffers(vq), si= zes[0]); =20 return 0; } diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/med= ia/platform/ti/davinci/vpif_capture.c index 99fae8830c41..8a4cc62cf562 100644 --- a/drivers/media/platform/ti/davinci/vpif_capture.c +++ b/drivers/media/platform/ti/davinci/vpif_capture.c @@ -122,9 +122,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size =3D sizes[0]; } =20 - if (vq->num_buffers + *nbuffers < 3) - *nbuffers =3D 3 - vq->num_buffers; - *nplanes =3D 1; sizes[0] =3D size; =20 @@ -1428,7 +1425,7 @@ static int vpif_probe_complete(void) q->mem_ops =3D &vb2_dma_contig_memops; q->buf_struct_size =3D sizeof(struct vpif_cap_buffer); q->timestamp_flags =3D V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed =3D 1; + q->min_buffers_needed =3D 3; q->lock =3D &common->lock; q->dev =3D vpif_dev; =20 diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/med= ia/platform/ti/davinci/vpif_display.c index f8ec2991c667..6fc32314cf9c 100644 --- a/drivers/media/platform/ti/davinci/vpif_display.c +++ b/drivers/media/platform/ti/davinci/vpif_display.c @@ -122,9 +122,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size =3D sizes[0]; } =20 - if (vq->num_buffers + *nbuffers < 3) - *nbuffers =3D 3 - vq->num_buffers; - *nplanes =3D 1; sizes[0] =3D size; =20 @@ -1168,7 +1165,7 @@ static int vpif_probe_complete(void) q->mem_ops =3D &vb2_dma_contig_memops; q->buf_struct_size =3D sizeof(struct vpif_disp_buffer); q->timestamp_flags =3D V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed =3D 1; + q->min_buffers_needed =3D 3; q->lock =3D &common->lock; q->dev =3D vpif_dev; err =3D vb2_queue_init(q); diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/pla= tform/ti/omap/omap_vout.c index 4143274089c3..72ce903717d3 100644 --- a/drivers/media/platform/ti/omap/omap_vout.c +++ b/drivers/media/platform/ti/omap/omap_vout.c @@ -944,10 +944,11 @@ static int omap_vout_vb2_queue_setup(struct vb2_queue= *vq, struct device *alloc_devs[]) { struct omap_vout_device *vout =3D vb2_get_drv_priv(vq); + unsigned int q_num_bufs =3D vb2_get_num_buffers(vq); int size =3D vout->pix.sizeimage; =20 - if (is_rotation_enabled(vout) && vq->num_buffers + *nbufs > VRFB_NUM_BUFS= ) { - *nbufs =3D VRFB_NUM_BUFS - vq->num_buffers; + if (is_rotation_enabled(vout) && q_num_bufs + *nbufs > VRFB_NUM_BUFS) { + *nbufs =3D VRFB_NUM_BUFS - q_num_bufs; if (*nbufs =3D=3D 0) return -EINVAL; } --=20 2.39.2