From patchwork Fri Feb 3 09:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp731564wrn; Fri, 3 Feb 2023 01:24:29 -0800 (PST) X-Google-Smtp-Source: AK7set/KGLwL+NsDTsNYGUX504UV6fi/xDKtcXKfQblFiT8PqIQDFavvPw260QdjoZ2G5ckWavdn X-Received: by 2002:a17:906:fa89:b0:880:5ab7:cb76 with SMTP id lt9-20020a170906fa8900b008805ab7cb76mr8626233ejb.33.1675416268944; Fri, 03 Feb 2023 01:24:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416268; cv=none; d=google.com; s=arc-20160816; b=oZRAQdCN+Z+RwJoJ3plLDx6rDx5MeVa9bT6jji7OGwP/3S6BliBULyet62j5vuzUVl CvCziRN2874Gmy2ApkaJkDGI3AWB1P+wYf9vIN10ub1F+aotZWTg9gSA0SDSqfYV28Gl B+ZyW14X23qPuKKYucgdS0mRUEX8C5SZW+6br01mFGiSrsjZYD/g9zjbbGpa5GirCCE9 xmfavaalNas2ear1jEXYFwAPh2WzoBP7oYinMvzapPyO6f5j7kSPBLF5Ac1ZpShLR7ub LkSeN0IXrN6ZTu6sMiq1xpjwYRweYaluzQ6j8dJ4TapT+fXRNXYWSfwP/2135mcdrsoI dhaw== 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=oT70sixhcLgq3GdyeYhBuUdX95cKmEUJO8TD29YBT7iHX9gKZUdEAgvuRhe4iOhtX8 B9pOujarAXChp8RprGAAzZLkKKe5FCKcKv28bsHWkmSKkUdIhpbSQ11XTVfT/MlZ7NoH iguPDFB1yw3xLN559+qa3h59JCxjFP/YwuAJFvz/NbZWKA6TBrEM4qnS0Xkiuag2fMEc vMcfW5VMVF7Qvxfn13Y2mGGn38oMQDYyNWM6cVLLvy5yZ6ZsI6BoPyH2SjVhOOBgajyY gs1g2cVJ7ENJ6P853icmER9ExLQ8nCpxBz+lbfjSfmZq866LdyQwpjbMo4aNFWPL8hMc J4Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OuOaHVkf; 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 x9-20020a056402414900b004a2042e2117si2374138eda.574.2023.02.03.01.24.05; Fri, 03 Feb 2023 01:24:28 -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=OuOaHVkf; 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 S232805AbjBCJRY (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjBCJQ5 (ORCPT ); Fri, 3 Feb 2023 04:16:57 -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 5A93A991D8; Fri, 3 Feb 2023 01:16:37 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (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 C52986602F0B; Fri, 3 Feb 2023 09:16:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415796; bh=9xkh7Mz6B7KCpRaWkFO7AHPjQWKFgdQpvDXYN313zu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuOaHVkfD7N2ri3orPAhlLmTr4P/1eh10YjH1OTywBJCzllotOe5UewgtvKXwlKPy cNl0MCYXwP6C1s12znKZuKUBOHep7GdkILznBAEaqJkRdAAco7UQ0fkLIrjehM9lRN vz0CbEu+0fmPtMybzjb06hDGaJnXW1Q1mB5CSg8LhitTl6rgrg2N4GGXkMOzKQVlp2 h5dRmfG3+7tvq3X+6aDW8xl6hKsMxy+96qo2Lry1HcIXZB2a/rUoI/jblhto3OTA8J iM7HrgA1pnukYRms5gSZ8asSuPp2BMQTms2OpMJVvBc/DcCiyX2WkY/xWTNvSk68w6 7ppQx+NXPFGEQ== 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 v8 2/6] media: verisilicon: Do not use ctx fields as format storage when resetting Date: Fri, 3 Feb 2023 10:16:18 +0100 Message-Id: <20230203091622.127279-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-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?1756801289622639035?= X-GMAIL-MSGID: =?utf-8?q?1756801289622639035?= 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)