From patchwork Tue Oct 3 08:06:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929117vqb; Tue, 3 Oct 2023 01:09:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZWsNCyAas4cou+mQmItzoPPy5jREUU09RCJPyeP3t5Or08yi9VoaB1V7j/hSFW5rq+nA3 X-Received: by 2002:a05:6a20:2589:b0:14e:43b0:5f99 with SMTP id k9-20020a056a20258900b0014e43b05f99mr13307002pzd.52.1696320587123; Tue, 03 Oct 2023 01:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320587; cv=none; d=google.com; s=arc-20160816; b=tRD2XSnoav7pMMDO/wwhOgQ6ht8GGA9Y7fUuyB530bh/w4iyRjyy3e8CnswnOw7sc9 g3uST5tkgSIrkS3Dx2/sHEogL+Eg03lh7VgnzrdTA9+o7xJ8Gio6PALZZfh9OovfpNgD t6JdmolZp69tRKiHcLu9CLRTU/rPZngdnjI/AMZTdzs2oMrpnKFAR0616ag2Pc7S2sfb HljHDyhyIbDjmyPC5UTduGkUoyx4igGDWmYSnmLiOPNMyudVf/dBwiNExDQGLJhskNwT V1AClEugeqPzF5z0dptd3V1Xp2CILMREU+XlZoGBGmG+7Gu/5lu99HkFvLGqQHPZD1fd ShKQ== 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=wH2S6ZMYTSuMBfj/bSmXs0tW3siNrN6r9Aflom22WvI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=OE/84ZDaF7FWSDx82EK7Pez/T+ZICR4Pr+56lJ7cH130AA3ZiWdRoch2hRvXOklT88 m9WAOO9RKUMuumMEK4A3TaeHhP7MpY4vAesS2TDCNKaGxeTWLpmHHLtwqQuK7qPSHHFL OsySyDsAHuvLW8W+b8nYv99e04m6r8QA9ETof+aTHk/fpmyFk5AvoT82aTK5/8IVnwir sWZMjep+onpnoKvv8WmNWetusxr7WS6Av2K2+RsE+3jgpLpX7UdKmRu2jELLDS0QAqIN jgwaAN/uY2SzEWeakmi2w9JuE7QoDh2KGFrxmCyad/exlhHSok6QlcuwTb+1eP3L6Mh/ s5Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ous9vBJX; 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 by27-20020a056a02059b00b0056c297d163asi1024679pgb.523.2023.10.03.01.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:47 -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=Ous9vBJX; 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 546B6814E353; Tue, 3 Oct 2023 01:09:46 -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 S240003AbjJCIJq (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239490AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -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 A1EAD1B4; Tue, 3 Oct 2023 01:07:32 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 139D16607372; Tue, 3 Oct 2023 09:07:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320451; bh=N6G4XfbycDnQUCOa7KuKCVKXaGxpGnmE1Di5qhpdnGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ous9vBJXl4Is8k+bDEceHHXnDJnaHLB7Oorw/14K8akp/zMks9AqOP3lRsd126Kt9 +EjWLKH/FSWgP1v18KVxw/UzaiqPXWG6kbv88zNYQYAEVq1cw2wEEIwWcRfgCh88qz 0A+b9vCH5C0fzq2ZqoqC08JOCQJnBbuA7ywbPPQQGub8YfO8qkRVX+LbCTH4+Hclyr BqXIrPFwN9G8alXmaWZe52HupIqpPx7WgnsjaWFWRl92cX/pmM65fYxNwnCs9E9BVz mXW/gQPptwYNpMIXqPP9ti0tjIEugxEyaaOhVhRbyXJDbDlzn4kBpioDuhAqipTwoW 06/bGG5815YrA== 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 v10 35/54] media: ti: Use queue min_buffers_needed field to set the min number of buffers Date: Tue, 3 Oct 2023 10:06:44 +0200 Message-Id: <20231003080704.43911-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-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, 03 Oct 2023 01:09:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721055747775690 X-GMAIL-MSGID: 1778721055747775690 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 5fa2ea9025d9..80a74ee59bb9 100644 --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c @@ -1772,9 +1772,6 @@ static int vpfe_queue_setup(struct vb2_queue *vq, struct vpfe_device *vpfe = vb2_get_drv_priv(vq); unsigned size = vpfe->fmt.fmt.pix.sizeimage; - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - if (*nplanes) { if (sizes[0] < size) return -EINVAL; @@ -1785,7 +1782,7 @@ static int vpfe_queue_setup(struct vb2_queue *vq, sizes[0] = size; vpfe_dbg(1, vpfe, - "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); + "nbuffers=%u, size=%u\n", vb2_get_num_buffers(vq), sizes[0]); /* Calculate field offset */ vpfe_calculate_offsets(vpfe); @@ -2233,7 +2230,7 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe) q->buf_struct_size = sizeof(struct vpfe_cap_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->lock = &vpfe->lock; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->dev = vpfe->pdev; err = vb2_queue_init(q); diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/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 = vb2_get_drv_priv(vq); unsigned int size = ctx->v_fmt.fmt.pix.sizeimage; - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 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 = 1; sizes[0] = size; - ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", *nbuffers, sizes[0]); + ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/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 = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - *nplanes = 1; sizes[0] = size; @@ -1428,7 +1425,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_cap_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->lock = &common->lock; q->dev = vpif_dev; diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/media/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 = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - *nplanes = 1; sizes[0] = size; @@ -1168,7 +1165,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_disp_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->lock = &common->lock; q->dev = vpif_dev; err = vb2_queue_init(q); diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/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 = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); int size = vout->pix.sizeimage; - if (is_rotation_enabled(vout) && vq->num_buffers + *nbufs > VRFB_NUM_BUFS) { - *nbufs = VRFB_NUM_BUFS - vq->num_buffers; + if (is_rotation_enabled(vout) && q_num_bufs + *nbufs > VRFB_NUM_BUFS) { + *nbufs = VRFB_NUM_BUFS - q_num_bufs; if (*nbufs == 0) return -EINVAL; }