From patchwork Wed Sep 27 15:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 145660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3002324vqu; Wed, 27 Sep 2023 18:13:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1xAezzh5/wfV00MEmLYzkDRcKOfxEakhgDeG7hyweIsP7WwbhxNvSpF8YaUOvfxs1pBfE X-Received: by 2002:a17:902:e74c:b0:1bc:56c3:ebb6 with SMTP id p12-20020a170902e74c00b001bc56c3ebb6mr6548861plf.8.1695863616489; Wed, 27 Sep 2023 18:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695863616; cv=none; d=google.com; s=arc-20160816; b=z8Q6KUs+vgEemoDb1T+z3WuW5hUUBhdE/NBgLtkqONclJ0ZzrGnjsnUHulMMUvnhzQ RBT+KWGwMxNdAaAwNKFWjhrLqfE8Dvjz8CY15yIi6igkINb/QCe7jNmS5qMEqwX/TeJy MTQaWijEAAS3rn9EsoXkbX+Ysp0cymGSOAD+GOpzwdPWL9IV0ByvgfafjrmQifOHGwfD UR+/2DbrKECfyRvd2Erc1ySA6KwcyLpghguFNChaG29dU5h4+LK5qMa7mPmZEQAR29JR 2QhvSi4vmtYzVWY6DmSjTwQOHHOqt7tJSbkSKUvThjNN0YQIyyUKQQONvO9iZE8RvwDo 5Nrw== 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=tmQ8B48fS653lsNUZPmdnMwdIC6Yd6jLqjKhmYRUJKw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=XO37Ps1Q6ZVXaB3v4rkqyahnZQ0/8ONtIli3TS7/u/CwmsCpNhM88WtdtDdw4PKy09 YP0XcR2JD9GKzfbIvR+0svLWbxCrVRp0ruiB80oDJJE3B38YGqUiifRKntGXGrA6h1J7 9ljs9RFdIbofjDGxvODkCylj82QABbuBGY7RUzOE40zx/rqGcOw/e3h7+nvuGlc3FotW HDF4U7rpJotd3UbAPzr6qGuqGF4ExigPN0uyUVro92DLdUeWeeQWbZvlOuMP1fRDQU61 27aFS2BLOwrkD+VddS4E/7GyPmhMkZbywU1d4nkisYVBHe7QL5MQQ56X6yXgaRstVbwx x9Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MJGhnJH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id iw10-20020a170903044a00b001c45cb1d770si15935145plb.280.2023.09.27.18.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MJGhnJH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id F1AC3801B650; Wed, 27 Sep 2023 08:38:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233066AbjI0Pij (ORCPT + 19 others); Wed, 27 Sep 2023 11:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbjI0Pge (ORCPT ); Wed, 27 Sep 2023 11:36:34 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEFB41B8; Wed, 27 Sep 2023 08:36:30 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:672:46bd:3ec7:6cdf]) (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 2296A6607376; Wed, 27 Sep 2023 16:36:29 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695828989; bh=qUxQMObFxpiy3pFolAat/Lsgv4wZ2hZHcdle7SRl8Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJGhnJH7QCZeXAMK4RxX+U5d4DufSL7rrACPblJTpXUxaovUCbzqlJ91cvZLCoRI7 i8MwxVQHPE+ePg6yZ+dg6YYDtMtjk6UmjsdOFs/b6yXIOMZx3FmDSZOEUYwH9BP/+P EIIiv24NiBf4WQ4hPRVnPQGx1uqiCUc0Fcwqfjv7qwCJPPTVtBu1opfOqhooSYzEkk Rp8pPVC9cJS6K4fNKjaUNUGhbwyO3XASYZ21tREL0iWiWMXHtpI/7WHPpLGz6Aee0u aNL0lwIebq3DriUDtGR5JcE732iONCK+rPVj1WaxMXDdl9nmvk6nwoJmtTMzCJTGwe FhgEPTsXzDu+w== 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 v8 44/53] media: meson: vdec: Stop direct calls to queue num_buffers field Date: Wed, 27 Sep 2023 17:35:49 +0200 Message-Id: <20230927153558.159278-45-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927153558.159278-1-benjamin.gaignard@collabora.com> References: <20230927153558.159278-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 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:39:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778241887097463580 X-GMAIL-MSGID: 1778241887097463580 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/meson/vdec/vdec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c index 219185aaa588..1e2369f104c8 100644 --- a/drivers/staging/media/meson/vdec/vdec.c +++ b/drivers/staging/media/meson/vdec/vdec.c @@ -167,22 +167,23 @@ static void process_num_buffers(struct vb2_queue *q, bool is_reqbufs) { const struct amvdec_format *fmt_out = sess->fmt_out; - unsigned int buffers_total = q->num_buffers + *num_buffers; + unsigned int q_num_bufs = vb2_get_num_buffers(q); + unsigned int buffers_total = q_num_bufs + *num_buffers; u32 min_buf_capture = v4l2_ctrl_g_ctrl(sess->ctrl_min_buf_capture); - if (q->num_buffers + *num_buffers < min_buf_capture) - *num_buffers = min_buf_capture - q->num_buffers; + if (q_num_bufs + *num_buffers < min_buf_capture) + *num_buffers = min_buf_capture - q_num_bufs; if (is_reqbufs && buffers_total < fmt_out->min_buffers) - *num_buffers = fmt_out->min_buffers - q->num_buffers; + *num_buffers = fmt_out->min_buffers - q_num_bufs; if (buffers_total > fmt_out->max_buffers) - *num_buffers = fmt_out->max_buffers - q->num_buffers; + *num_buffers = fmt_out->max_buffers - q_num_bufs; /* We need to program the complete CAPTURE buffer list * in registers during start_streaming, and the firmwares * are free to choose any of them to write frames to. As such, * we need all of them to be queued into the driver */ - sess->num_dst_bufs = q->num_buffers + *num_buffers; + sess->num_dst_bufs = q_num_bufs + *num_buffers; q->min_buffers_needed = max(fmt_out->min_buffers, sess->num_dst_bufs); }