From patchwork Mon Jan 30 13:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2191242wrn; Mon, 30 Jan 2023 05:59:22 -0800 (PST) X-Google-Smtp-Source: AK7set/dpf3qUQ2Q0mzBmzQ0e17n3EuNXjVG7wSYez9/eboYXdkqNypQBUFYwu146FlhIccAMoKv X-Received: by 2002:a17:902:e2c5:b0:196:86ce:ab6b with SMTP id l5-20020a170902e2c500b0019686ceab6bmr2637862plc.3.1675087162205; Mon, 30 Jan 2023 05:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675087162; cv=none; d=google.com; s=arc-20160816; b=UJecT9jo8/+iTO2upmG/QK54wX4D/hwIiRtFYZiB3BXaj9yS3cr0tLUWb16w0pMrpk PNUvUUHqLuhz5nWwNkGyKZ3lqfUhfQTjPjtBqEVxiC+Ja1gYGUpaiu0L1ffHsPzOtbks K0f0HKe7dXBoE9KBCww2VdV0mIzroxMxF6eev9JjWUoLQf1rFODHypriAOp5lXBm2iiS Y0CjwssQHgeuIaSUT+A5acEE4IfWHjSh9nFN4YUzhylB+0mg5Y7RID/99Eo4fNi/R/Du JphNHcGvGWLn1hape2xg8gLR3bGE/BS2sX2TKlTj76PeUNFkuayXGgK+k856zLcB76IH 05ag== 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=ud7/S02vaGDHLDDt3yAeK975uGNtBrEJ2wBuvjyFmUI=; b=F4iGu945ZWY6SW+TJvEoPneTsH7P38sctlLoMEbdHm+ymHwGTeLQXxzPifSJKOPD1v zd+qCJsOo627BYM+pPUHisa8silJBFjq6A8BPWty+BT2Hc1Y1mmRfz8bq5pW1TVIrCdg M566YFAfSLA012EIqGDOIHRRAnTkPx1wzMvavr5sbOIEwL5h1Iv6Zah4p0TtScVdcqIH RYWtuBt8MPOf5lZffYfw1M7MlmB00iz0wI8PxWWbFi7NqY7cbf4FSJSDysC01xYslbH4 rajfadqJvQimJNBgvlnVkrPJNu4wDjzFnl9SChIlxSeqpvZOAnmO1yZuPWbNAKyutd05 ouBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cnTtZu1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a637112000000b004df4af6841asi11744386pgc.84.2023.01.30.05.59.09; Mon, 30 Jan 2023 05:59:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cnTtZu1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236841AbjA3N6n (ORCPT + 99 others); Mon, 30 Jan 2023 08:58:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236768AbjA3N6e (ORCPT ); Mon, 30 Jan 2023 08:58:34 -0500 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 D935D39CC6; Mon, 30 Jan 2023 05:58:15 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:e655:2335:9172:6e39]) (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 24DD66602EAD; Mon, 30 Jan 2023 13:58:12 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675087092; bh=9xkh7Mz6B7KCpRaWkFO7AHPjQWKFgdQpvDXYN313zu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cnTtZu1hrqPWEMA3JwJqr9UaY0ZzHDvJMFG2FJf7q/36pTxODy+Lrk/qMxbD+gacX RlFDGf6NVTuzRv7WgQRvyZAhN5EhJszH0Vyu146xLTwcDG7KQxy31or25pJNcNWysJ D05ME96oZD2YVvV+cZa9aRtTXyKaoYCzVewZa8Yt+A+QU8qzctIB/Icd78LYEDNviI /mAxVIlYjyE0fhcSryqhpOIptPT3y4vW8gPrltMzwiwMgwEh+Cxo4GRP1/HihD3z6Y LhJfgUhBQ9TYrSsG4OIaYCKaMq17EATBBvXXPtWyH2Zr0GtObJL1r0NJrs67iSoIaO wD8BGWv/gLo4g== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v6 2/5] media: verisilicon: Do not use ctx fields as format storage when resetting Date: Mon, 30 Jan 2023 14:57:59 +0100 Message-Id: <20230130135802.744743-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230130135802.744743-1-benjamin.gaignard@collabora.com> References: <20230130135802.744743-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,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756456196100775522?= X-GMAIL-MSGID: =?utf-8?q?1756456196100775522?= Source and destination pixel formats fields of context structure should not be used as storage when resetting the format. Use local variables instead and let hantro_set_fmt_out() and hantro_set_fmt_cap() set them correctly later. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 33cb865238de..e60151a8a401 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -377,47 +377,43 @@ static void hantro_reset_encoded_fmt(struct hantro_ctx *ctx) { const struct hantro_fmt *vpu_fmt; - struct v4l2_pix_format_mplane *fmt; + struct v4l2_pix_format_mplane fmt; vpu_fmt = hantro_get_default_fmt(ctx, true); + if (!vpu_fmt) + return; + hantro_reset_fmt(&fmt, vpu_fmt); + fmt.width = vpu_fmt->frmsize.min_width; + fmt.height = vpu_fmt->frmsize.min_height; if (ctx->is_encoder) - fmt = &ctx->dst_fmt; - else - fmt = &ctx->src_fmt; - - hantro_reset_fmt(fmt, vpu_fmt); - fmt->width = vpu_fmt->frmsize.min_width; - fmt->height = vpu_fmt->frmsize.min_height; - if (ctx->is_encoder) - hantro_set_fmt_cap(ctx, fmt); + hantro_set_fmt_cap(ctx, &fmt); else - hantro_set_fmt_out(ctx, fmt); + hantro_set_fmt_out(ctx, &fmt); } static void hantro_reset_raw_fmt(struct hantro_ctx *ctx) { const struct hantro_fmt *raw_vpu_fmt; - struct v4l2_pix_format_mplane *raw_fmt, *encoded_fmt; + struct v4l2_pix_format_mplane raw_fmt, *encoded_fmt; raw_vpu_fmt = hantro_get_default_fmt(ctx, false); + if (!raw_vpu_fmt) + return; - if (ctx->is_encoder) { - raw_fmt = &ctx->src_fmt; + if (ctx->is_encoder) encoded_fmt = &ctx->dst_fmt; - } else { - raw_fmt = &ctx->dst_fmt; + else encoded_fmt = &ctx->src_fmt; - } - hantro_reset_fmt(raw_fmt, raw_vpu_fmt); - raw_fmt->width = encoded_fmt->width; - raw_fmt->height = encoded_fmt->height; + hantro_reset_fmt(&raw_fmt, raw_vpu_fmt); + raw_fmt.width = encoded_fmt->width; + raw_fmt.height = encoded_fmt->height; if (ctx->is_encoder) - hantro_set_fmt_out(ctx, raw_fmt); + hantro_set_fmt_out(ctx, &raw_fmt); else - hantro_set_fmt_cap(ctx, raw_fmt); + hantro_set_fmt_cap(ctx, &raw_fmt); } void hantro_reset_fmts(struct hantro_ctx *ctx)