From patchwork Tue Jan 31 13:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2738814wrn; Tue, 31 Jan 2023 05:06:01 -0800 (PST) X-Google-Smtp-Source: AK7set9m96rwJiJ3KkDYPx3qidrAQ/zimDmiJBtI6pVJAByU44xKR/2CtLFvBnme+JCmVhBlxE7i X-Received: by 2002:a17:907:7287:b0:889:1eb1:7517 with SMTP id dt7-20020a170907728700b008891eb17517mr9331940ejc.30.1675170360833; Tue, 31 Jan 2023 05:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675170360; cv=none; d=google.com; s=arc-20160816; b=urrfn5mzHFWPnKQVefIVBjG932MHuQSGhKNH7h1vS6JO71+ufu8wbmuqj9ldpG8Px7 z7Pt0J2JkYyZa+ckws+DJEIwtyzwJGi7YuqCDwOJ/FQFBleN/X06gWBxhgb/1CatjqD5 r6x+Sbb/nWFUBxOzJyoUGT6cEIKPt6UyS4oDUdeKaPq2pD2XX1jceDis3rlg9LlQ9ixw u9EUDD4wbc9PwbhIaFEmBW8q6bsUPDahBEnYywvBG5Tf+WxI26wcV3OZp49czzQEm5Ep D22+IfDZX4IpfGQhZ5VULWZKRvBUllbTcln99ZFu9b5o4Ab8y4Gh87aLrmYXIjmRhYaS h5ZA== 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=ZXLC0AVn5zzssBRz+paos45vLc78DEwmZgsEi8I+thLSrLtz2F6hhY4UHkX0nYzQ2x 1/P4zpVdmw4/4KWt0qes9gLYwLcr4sB3tqEFz4XPxFWe/rRa6sWLthdTsgz0J7hFEi3v ggdN12CGyUnxoTkNIa3UzrddU/jiEtogUx0IjgAgOHPCgr4u4YMOj/Wb/WC1L9h0z1o8 P8FKOEQjTQ6oQTmpLJl3NzII0h52Cn+qJkV/88VK3k9n74bEoerfqJsLeN1Eyh5sQBfK DLRy8EI7L2fIlBfnldLTuAXTYG4oDWy6A5zg0St6+t3DGzbseXoz4UTgKLX50f5NBDab 6Uzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oipKafPz; 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 ce11-20020a170906b24b00b0087122fab4c0si17226258ejb.155.2023.01.31.05.05.36; Tue, 31 Jan 2023 05:06:00 -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=oipKafPz; 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 S231694AbjAaNDs (ORCPT + 99 others); Tue, 31 Jan 2023 08:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbjAaNDq (ORCPT ); Tue, 31 Jan 2023 08:03:46 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7171210A92; Tue, 31 Jan 2023 05:03:44 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d507:461a:a036:bf89]) (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 EBE026602EBE; Tue, 31 Jan 2023 13:03:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675170223; bh=9xkh7Mz6B7KCpRaWkFO7AHPjQWKFgdQpvDXYN313zu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oipKafPzVPw8hqVNYxENXzkcnaBChLBb9p5uLxcXowHc83se6TvPnTtuXiqOY6Pui PnCMBNyqLqSlduR19Hlh5SkhQskD+q8sby5zGWibidnDtFAPWxZZlfYc0e7FwMxs0y FQlK8CHH+Ag/FPnMNBuqJCGL5U5NybJ6uBkPRSGJcfqZ12JdR5Dzi+xMJ8axkxBnWW jJAkxMkp2Kc/IoZh3jAFYP3NEflBhGRM9k2SdQL1KcyNktMyXrMTJLWCBV+6/3vd2D 77KKDoBQtctUqfq2sM69aOl1uZCcKLT+dcof7L0pLjv1dGUSNGjbjLEBQNI7sMu+hf Phc63SR015EsA== 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 v7 2/5] media: verisilicon: Do not use ctx fields as format storage when resetting Date: Tue, 31 Jan 2023 14:03:24 +0100 Message-Id: <20230131130327.776899-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131130327.776899-1-benjamin.gaignard@collabora.com> References: <20230131130327.776899-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?1756543436269476018?= X-GMAIL-MSGID: =?utf-8?q?1756543436269476018?= 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)