From patchwork Mon Feb 20 10:48: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: 59368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239712wrn; Mon, 20 Feb 2023 02:53:09 -0800 (PST) X-Google-Smtp-Source: AK7set8P9w9o7qmw/JHPqmnudLrEoTkL4DVWsgyqFlQNUSO5kHFCMy5DtMLGGvgApHiIzHiErfYB X-Received: by 2002:a17:90a:305:b0:233:d5ea:53c1 with SMTP id 5-20020a17090a030500b00233d5ea53c1mr2398636pje.29.1676890389573; Mon, 20 Feb 2023 02:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890389; cv=none; d=google.com; s=arc-20160816; b=tHGvdGptHfIX0QtF7MfW5dHw8VUhPx+6svUD1lGIAIC7DNVNd5YuExWoR98R69AnMk /xqcGmMl+t1HCHpLP0cobXsPQqYDCamqDPwZlAN1NDhFy+Aughi12Lw6WolTtEaz7aRe Y9drRkWibqpjZcH5PczwBtOhASl7+TrNSBKToPQP3s0W9Tbj/ZKNPGhj+zOTOPPVfEDu Wtr4Hc1sCFmmw/Rhe6F/iNsNKgVFCIvfGvykbevHMlB84dgWFR/zhs2hHG+3SWG17aYv eSvExpDXt4ZawMSR7bti9j6ViPBha57xZIBT/Niv+KOUJQzTuY9yRlXU/g//mXtdFoQh RgwA== 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=KlmyNzm3zbLkrzn/ntH75mOMsJhUuAY/0UMULtfxk04=; b=GLL6OC4u/OCHn/7qvOWXSMQA82Cb9+NCGHsSYwY3x+OoO82nEESUktqZHrF9B8BG2A J9K94aFgzZANcTb9f5CVNtcundpt21imJm3m+GgE2qQxpjQ/DpHRlTrX8j0O+S+NGCF7 VS1xUUTrzIaxE7Q3UE46c5iHJqEAYfdgxFSZyrQ6spn0oUnhsvTzQs8osMtkhwMi312u RqMdUoscXJa9p9TxNYVzIBTEBxcrzDPIMDhPvKljB7hd+lncOAUdWPN0mgNkMcCInXrX hTi0V3t3tHhRFbC2FhCD4zCSwtixR2Ws2CGcOKvGKgCJfIJ7aovYjuwpdG4v+OiU9FiP j5sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hAfqO2zp; 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 y2-20020a17090ad70200b00234bc923a16si12529511pju.148.2023.02.20.02.52.57; Mon, 20 Feb 2023 02:53:09 -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=hAfqO2zp; 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 S231673AbjBTKtC (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjBTKtA (ORCPT ); Mon, 20 Feb 2023 05:49:00 -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 7F5BFAD0D; Mon, 20 Feb 2023 02:48:59 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 A41796602135; Mon, 20 Feb 2023 10:48:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890138; bh=mU6dx4hn+cwCgHPnwybSeD67XSVlGhz85RqJ+3iMsW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAfqO2zphslE1XZvxsSv+wFSwQhqwzKxh9Q7tQbrLqNKyvhEdb81v1OPRszY8PjRP hVTDcMTwz2MRa7IrTbdz9G152y1AI8h5F9wAljx/fKMskyczSQX4zeZtM2REANUFgv hEp4dXxdLy+/UMN9v9+w/COy6OdT1XUcvFLfvd8Y8nYcuccYdgIoQ2ynV+m4aO4gA4 fVDzIp3VCY9476oE36M/61O70q1iYTHWV10wGduc5M6oGvjDeSXRDi664JPbibvpcK VTZvyYMvag6I1XF+aPzKRfdx5Wk855nDnx1KMlyekOGrnVaXfaCH+B4CE589MAewaP NichsQwCaqt2w== 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, robert.mader@collabora.com 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 v9 1/6] media: verisilicon: Do not set context src/dst formats in reset functions Date: Mon, 20 Feb 2023 11:48:44 +0100 Message-Id: <20230220104849.398203-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758347017232714095?= X-GMAIL-MSGID: =?utf-8?q?1758347017232714095?= Setting context source and destination formats should only be done in hantro_set_fmt_out() and hantro_set_fmt_cap() after check that the targeted queue is not busy. Remove these calls from hantro_reset_encoded_fmt() and hantro_reset_raw_fmt() to clean the driver. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia Tested-by: Marek Szyprowski --- drivers/media/platform/verisilicon/hantro_v4l2.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index c0d427956210..d8aa42bd4cd4 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -382,13 +382,10 @@ hantro_reset_encoded_fmt(struct hantro_ctx *ctx) vpu_fmt = hantro_get_default_fmt(ctx, true); - if (ctx->is_encoder) { - ctx->vpu_dst_fmt = vpu_fmt; + if (ctx->is_encoder) fmt = &ctx->dst_fmt; - } else { - ctx->vpu_src_fmt = vpu_fmt; + else fmt = &ctx->src_fmt; - } hantro_reset_fmt(fmt, vpu_fmt); fmt->width = vpu_fmt->frmsize.min_width; @@ -408,11 +405,9 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx) raw_vpu_fmt = hantro_get_default_fmt(ctx, false); if (ctx->is_encoder) { - ctx->vpu_src_fmt = raw_vpu_fmt; raw_fmt = &ctx->src_fmt; encoded_fmt = &ctx->dst_fmt; } else { - ctx->vpu_dst_fmt = raw_vpu_fmt; raw_fmt = &ctx->dst_fmt; encoded_fmt = &ctx->src_fmt; } From patchwork Mon Feb 20 10:48:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239678wrn; Mon, 20 Feb 2023 02:52:59 -0800 (PST) X-Google-Smtp-Source: AK7set+Irjsom4tDS54Jnso4Og7g3G0CIItb0VWEVpeEs1o2koMhoM9fHZVSSDS2jLh87cU/NDDt X-Received: by 2002:a17:902:e890:b0:199:2a4f:be84 with SMTP id w16-20020a170902e89000b001992a4fbe84mr3799919plg.58.1676890379688; Mon, 20 Feb 2023 02:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890379; cv=none; d=google.com; s=arc-20160816; b=b5oJ72/Wvutu1TxYWxapQ4vQCUNpACQn07fjYT/t0nRQDg5Tj+67ABXUQEpIbw8OWB b5WbXXdoKAJn5IIHhCP6rrIlvZMJMK/ManAZQbyMGAM36OuyxCiyN0MoCEwIFwJd7BoV okN5egYikjyyne1qVp48gCso+bxUL6MkGLatrhe8YCX4GHVrBvBjmUWrGklaVnI4h7C1 rUEKWYR1D6KhiYoKoQBOM3hQJTlga/BVkK24TbtcaOmylY4jbdbUsmJ0oivL6InNJ4K1 uDGFjia/weBwkoCW0Yg/PmKEmuobwOlpLL+8kz06SUy9C+e5A3ac6Q6jmfI6GMb4foVb cJ0Q== 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=91rQZmNxQbWafvwmNl2fHvupW1z5sKT2M6yJDqhHEhA=; b=WrRnkT/Jc883+C5/UblW2h+Z3VdgJZDZXfuB040Qy2fDTjvtMWD2vybXYV4d/LGCtW 8Gwa9O5QiVl0s8mNxw4XgShr5xxthDVbJuollnNUxVNfSTZRIRx1m5Zb/PDWPfotbkaZ G+s4nSqCfH02eRY8CuIsqRZM/y+lZ57TH3QfItQucO0JfYYwC2IuEoGg0hZf0/dXHRLp uhbvkD3hZydjU4uKmaWSXOSFJOrR4grTVMp7EtZ0Z93A4jqoNuczK5+MpSVdT7gDN/R1 IaQqkwxaa10uKssaSrprzApGg9Ov391jJyWFTe0hc18v+m4zNbZ9Dn/ydKfh3GkbuWm9 VZqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="CHnsD/NN"; 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 ky11-20020a170902f98b00b00194df2022dfsi4194302plb.440.2023.02.20.02.52.46; Mon, 20 Feb 2023 02:52:59 -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="CHnsD/NN"; 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 S231689AbjBTKtF (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231643AbjBTKtB (ORCPT ); Mon, 20 Feb 2023 05:49:01 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD1F1B77E; Mon, 20 Feb 2023 02:48:59 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 362366602149; Mon, 20 Feb 2023 10:48:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890138; bh=nAuFKvKMZ2YBTXOWwp+TuprTbhS3UMLPUmAFqn4ND1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CHnsD/NNj+DyMumjt9VtCfdS16dVMvfR3ArcmpJYFx/Jz0vIJYEWJzw8uxZoSTHXU l9Aw7fyj34YpCyfsKPVsAWnK7DyBfWDrEcsxFLMG1SN+cmPb91FhILwC4lA+sKwoVm KaatgDdQUjx7HjZw7iUY7nleWSw8vNZiB1+hohhq7gjPuhFrCmj9iGPzvOl3Hw4vVz /9mkuooij25y5/TAGjlIB4OM5RPxqMouecSXpetfUwMrkIqW/NuS1kL039IfoUJORo ThLaJ29gaVwZ49vMEU8E7p93XSe6noqvgODtt4S88ZauIK59Q41mmBL3oPZBq2p5Uy kg2/RzwBo06ww== 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, robert.mader@collabora.com 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 v9 2/6] media: verisilicon: Do not use ctx fields as format storage when resetting Date: Mon, 20 Feb 2023 11:48:45 +0100 Message-Id: <20230220104849.398203-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758347006722475263?= X-GMAIL-MSGID: =?utf-8?q?1758347006722475263?= 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. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia --- .../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 d8aa42bd4cd4..d94c99f875c8 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -378,47 +378,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) From patchwork Mon Feb 20 10:48:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239464wrn; Mon, 20 Feb 2023 02:52:19 -0800 (PST) X-Google-Smtp-Source: AK7set8InWLBqDDuLFHWXE/+hfK0cdsTm3Z1Kl+P4rreQxozS4g6Xw8zKDVCEBSepJmy1PfYGalG X-Received: by 2002:a17:902:f983:b0:19b:76fb:c6f with SMTP id ky3-20020a170902f98300b0019b76fb0c6fmr1331566plb.68.1676890338749; Mon, 20 Feb 2023 02:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890338; cv=none; d=google.com; s=arc-20160816; b=k4hfWybh4FPPrd2MrypkwdNK4gRJA+MURi93zw//kJXBb1tNL2F08833tpl+6tOnO2 o6yf0yUWzidNVgwvDDh/dAhnhqfQ5V6VKLwBRf0+c/63IAigC7DYAKKNhfUz9dIF2bUz tbppb0u29rxPVm/0mD0iDh1NqIZ77B4dU0UcNznxuoX4/mmwN92YHIG4pdFrtkgUkD+Y 66stcN1TBgm4wfZyWx972KYTY3DJi+RWwW6PeXF8lw1dvLj4sXHZbvIJ6GAdju91hzln 8F1weXck2nl9KYNu2XUcSNuVZZAFEQUxd7LNIAki0OVx/igpXCD7wbYsVAzho2UZPZnY vbXA== 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=iw2sAiwTWkkXP2xcbTGi/L2eUKFmjnlsbsN2iOF/8pA=; b=gV1EmLvhMjB+jETig89S8A0TOHxVtHSRnbYTBEbwD8WzBGRNQBfEOErxWvjfVFrBl+ sfVVocmhO6e6T2EDKvY0d7GtghVBF9GH/FqeJSyfNkpF7ahBNIJDnAJXLVX+xTVitsoy A9QEbPbf/utkaJnrnc0Fu43bllwqc6mxUy/d7yGlhrYcNLY5F3f4DqmF8CYw6LGn/GmJ Z8JO54zChlVySf7+ScIw5OTryNxzKowJiu/lbZOJ49b+RQEV1/rgZc/P9kKd0o9qUOmG CNewOoIoRWicZwHjz8PYNAGprIdo5RioGYSjgsUvb4FLvr87bUSBOkdKgNVN9R29bcQE B8xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RTS9a73w; 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 p18-20020a170902ebd200b0019a9f8bdb8csi2668313plg.209.2023.02.20.02.52.06; Mon, 20 Feb 2023 02:52:18 -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=RTS9a73w; 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 S229991AbjBTKtK (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231665AbjBTKtB (ORCPT ); Mon, 20 Feb 2023 05:49:01 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60BE3BB84; Mon, 20 Feb 2023 02:49:00 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 B1E046602165; Mon, 20 Feb 2023 10:48:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890139; bh=Qylc8lXBZUribdIoDlAmLesNbqqMKmI6fMRr3vIkG8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RTS9a73wcPX9uhMzv6NCAE206e9RJ/YFkz5NBcy2CCC36Lf3d9YYmafphVugIkBsU zuPq1m2nx4sHw9IGMwPoAerygmBjVzzZXzOOfbMf01BFAHRcg2tOs12DzfBTz6XuRM wtP94UOj9U1zrqsEsChXB3a0UJsL8DOK4faVjr7VtTh1yhe5XB3vIs7Niv5cCZHP9A kdHCKxeqZbS/KeLx1OWsD47xDniYkyojHRkuLnROtqqE3OlJzLGp3dtFOgWu0+gRPa CwL31tTSltEwAd0zf9edW4FR314xL+LhJ9vXCHqB9c8aGOzqOHnztWisNDqfRAFlUH rdJE7Wdi+VqRg== 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, robert.mader@collabora.com 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 v9 3/6] media: verisilicon: Do not set ctx->bit_depth in hantro_try_ctrl() Date: Mon, 20 Feb 2023 11:48:46 +0100 Message-Id: <20230220104849.398203-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758346963843839640?= X-GMAIL-MSGID: =?utf-8?q?1758346963843839640?= In hantro_try_ctrl() we should only check the values inside control parameters and not set ctx->bit_depth. That must be done in controls set function. Create a set control function for hevc where ctx->bit_depth is set at the right time. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia --- .../media/platform/verisilicon/hantro_drv.c | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index b0aeedae7b65..c237253803f4 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -251,11 +251,6 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) { - struct hantro_ctx *ctx; - - ctx = container_of(ctrl->handler, - struct hantro_ctx, ctrl_handler); - if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; @@ -274,8 +269,6 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2) /* Only 8-bit and 10-bit are supported */ return -EINVAL; - - ctx->bit_depth = sps->bit_depth_luma_minus8 + 8; } else if (ctrl->id == V4L2_CID_STATELESS_VP9_FRAME) { const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame; @@ -324,6 +317,24 @@ static int hantro_vp9_s_ctrl(struct v4l2_ctrl *ctrl) return 0; } +static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct hantro_ctx *ctx; + + ctx = container_of(ctrl->handler, + struct hantro_ctx, ctrl_handler); + + switch (ctrl->id) { + case V4L2_CID_STATELESS_HEVC_SPS: + ctx->bit_depth = ctrl->p_new.p_hevc_sps->bit_depth_luma_minus8 + 8; + break; + default: + return -EINVAL; + } + + return 0; +} + static const struct v4l2_ctrl_ops hantro_ctrl_ops = { .try_ctrl = hantro_try_ctrl, }; @@ -336,6 +347,11 @@ static const struct v4l2_ctrl_ops hantro_vp9_ctrl_ops = { .s_ctrl = hantro_vp9_s_ctrl, }; +static const struct v4l2_ctrl_ops hantro_hevc_ctrl_ops = { + .try_ctrl = hantro_try_ctrl, + .s_ctrl = hantro_hevc_s_ctrl, +}; + #define HANTRO_JPEG_ACTIVE_MARKERS (V4L2_JPEG_ACTIVE_MARKER_APP0 | \ V4L2_JPEG_ACTIVE_MARKER_COM | \ V4L2_JPEG_ACTIVE_MARKER_DQT | \ @@ -470,7 +486,7 @@ static const struct hantro_ctrl controls[] = { .codec = HANTRO_HEVC_DECODER, .cfg = { .id = V4L2_CID_STATELESS_HEVC_SPS, - .ops = &hantro_ctrl_ops, + .ops = &hantro_hevc_ctrl_ops, }, }, { .codec = HANTRO_HEVC_DECODER, From patchwork Mon Feb 20 10:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239467wrn; Mon, 20 Feb 2023 02:52:19 -0800 (PST) X-Google-Smtp-Source: AK7set9Ko9O0nE/MZq1O7kpnLMk3YmFionc1TPyOUJGhZY8VaqXLf4VvhCvmBrOSqUf4fApYN4JZ X-Received: by 2002:a17:903:2441:b0:196:5bac:e319 with SMTP id l1-20020a170903244100b001965bace319mr1385543pls.35.1676890339548; Mon, 20 Feb 2023 02:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890339; cv=none; d=google.com; s=arc-20160816; b=GgErQXdaZ07yrTDuKbuvblr1xmlactaTBq7Ba9Or8COOeaIczfjmEWSgX7CCiLWFdD CLXolt2dtOwMOvIpg6oEzv9bgx+XZcyYLku0yX49p2WvYwXmwVMaDPDPabanF+RcZSEs 5uHKLi5aJvVmZaRU7jOLvSUNQFAa8jvN+VJ9qjsZBCOXqELVjVHCYBR6JWihfoTj3Fwn D3wpXHjiyE9tetX4ZShvkyfbms43ztLJ7pBohti3SOm0HIsyvs5xQTDBK6GeZ2Lf4yzm SrJAerah8pju+bxu/KIGK+2+I+ZKPp4ablENiK8FtfomgbM6aUN0nhBWEgXocCuI28F8 r2NA== 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=1kV/5lzAmyuAT4NCsVxyhJ/pG5aAibd7FKlVFhWnDJY=; b=sZqlbhyHvdYavkzTQh1nu+UL8Wc0K81DLf2mcVm60SlIcZbL7IbOEJpa+UeIqcwokK 4cYOcflaS7c3W30S9Va+0DoHpN6sU+GELAL7HDNtUJgBCjn9FHq2S+iP6/KvompxI54L UVKtC2oR1PoHJPn24kgS9OtRutSnu5MdYyLPvoE0EmnUSuz75oy+v93SxkZ3Jzz/oEJN NELpKkGxu+XS2FlzjBk8p1RRwvc5r8wdl97gNh9ERiCOfmspcvrR/gkAXaANML+KCakc dj0xClt/1mOCu4wfiyQNxFwVwlPmCrdj6O8jLMNMZvV24nO/orl4EDNothbrLmqErMxe i+oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HVIizSRM; 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 v10-20020a63610a000000b004fba35db0a7si15955841pgb.160.2023.02.20.02.52.07; Mon, 20 Feb 2023 02:52:19 -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=HVIizSRM; 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 S231708AbjBTKtM (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231674AbjBTKtC (ORCPT ); Mon, 20 Feb 2023 05:49:02 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA67BB8C; Mon, 20 Feb 2023 02:49:00 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 35FD6660213E; Mon, 20 Feb 2023 10:48:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890139; bh=2xaNocEAF4qvDyOTrQtHPsoGywHnve83vDJYytz3whU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVIizSRM6iS0VMRitcUVQDPtRkF7uHKIILgHsO799PkW3NTyM1hB6jFH+9GY214vI GEZgweR2KsZo0rTCPF26hE0vhfc2IVJlWrIzOcNdQTCkivd0ccnWk5y4LraF2wy0dr NQDpQRs0ZBpiwHutqHKrA7n7Ma6JJ9sKv++AxvhCVMfFL4xfFzzl+C/Y92QDUnPJj9 CmENkqkCubhJiBnpEl+jWL5vB6aBhkfi5/ppSTSX0A+vTsakNfpNjKFn8STdICauMw Opc178TdEtFYvKw1l4t+QRTnT1lNW5r/gucal4+rGHSa/1rwR3IWfxPDNwilgYRCYt gh77Hd2iTCCBQ== 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, robert.mader@collabora.com 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 , Nicolas Dufresne Subject: [PATCH v9 4/6] media: verisilicon: Do not change context bit depth before validating the format Date: Mon, 20 Feb 2023 11:48:47 +0100 Message-Id: <20230220104849.398203-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758346964460367773?= X-GMAIL-MSGID: =?utf-8?q?1758346964460367773?= It is needed to check if the proposed pixels format is valid before updating context bit depth and other internal states. Stop using ctx->bit_depth to check format depth match and return result to the caller. Signed-off-by: Benjamin Gaignard Reviewed-by: Nicolas Dufresne Reviewed-by: Ezequiel Garcia --- .../platform/verisilicon/hantro_postproc.c | 2 +- .../media/platform/verisilicon/hantro_v4l2.c | 51 ++++++++++--------- .../media/platform/verisilicon/hantro_v4l2.h | 3 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c index 09d8cf942689..6437423ccf3a 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -197,7 +197,7 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx) unsigned int i, buf_size; /* this should always pick native format */ - fmt = hantro_get_default_fmt(ctx, false); + fmt = hantro_get_default_fmt(ctx, false, ctx->bit_depth); if (!fmt) return -EINVAL; v4l2_fill_pixfmt_mp(&pix_mp, fmt->fourcc, ctx->src_fmt.width, diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index d94c99f875c8..d238d407f986 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -28,6 +28,8 @@ #include "hantro_hw.h" #include "hantro_v4l2.h" +#define HANTRO_DEFAULT_BIT_DEPTH 8 + static int hantro_set_fmt_out(struct hantro_ctx *ctx, struct v4l2_pix_format_mplane *pix_mp); static int hantro_set_fmt_cap(struct hantro_ctx *ctx, @@ -76,18 +78,13 @@ int hantro_get_format_depth(u32 fourcc) } static bool -hantro_check_depth_match(const struct hantro_ctx *ctx, - const struct hantro_fmt *fmt) +hantro_check_depth_match(const struct hantro_fmt *fmt, int bit_depth) { - int fmt_depth, ctx_depth = 8; + int fmt_depth; if (!fmt->match_depth && !fmt->postprocessed) return true; - /* 0 means default depth, which is 8 */ - if (ctx->bit_depth) - ctx_depth = ctx->bit_depth; - fmt_depth = hantro_get_format_depth(fmt->fourcc); /* @@ -95,9 +92,9 @@ hantro_check_depth_match(const struct hantro_ctx *ctx, * It may be possible to relax that on some HW. */ if (!fmt->match_depth) - return fmt_depth <= ctx_depth; + return fmt_depth <= bit_depth; - return fmt_depth == ctx_depth; + return fmt_depth == bit_depth; } static const struct hantro_fmt * @@ -119,7 +116,7 @@ hantro_find_format(const struct hantro_ctx *ctx, u32 fourcc) } const struct hantro_fmt * -hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream) +hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream, int bit_depth) { const struct hantro_fmt *formats; unsigned int i, num_fmts; @@ -128,7 +125,7 @@ hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream) for (i = 0; i < num_fmts; i++) { if (bitstream == (formats[i].codec_mode != HANTRO_MODE_NONE) && - hantro_check_depth_match(ctx, &formats[i])) + hantro_check_depth_match(&formats[i], bit_depth)) return &formats[i]; } return NULL; @@ -204,7 +201,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv, if (skip_mode_none == mode_none) continue; - if (!hantro_check_depth_match(ctx, fmt)) + if (!hantro_check_depth_match(fmt, ctx->bit_depth)) continue; if (j == f->index) { f->pixelformat = fmt->fourcc; @@ -224,7 +221,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv, for (i = 0; i < num_fmts; i++) { fmt = &formats[i]; - if (!hantro_check_depth_match(ctx, fmt)) + if (!hantro_check_depth_match(fmt, ctx->bit_depth)) continue; if (j == f->index) { f->pixelformat = fmt->fourcc; @@ -292,7 +289,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, fmt = hantro_find_format(ctx, pix_mp->pixelformat); if (!fmt) { - fmt = hantro_get_default_fmt(ctx, coded); + fmt = hantro_get_default_fmt(ctx, coded, HANTRO_DEFAULT_BIT_DEPTH); pix_mp->pixelformat = fmt->fourcc; } @@ -380,7 +377,7 @@ hantro_reset_encoded_fmt(struct hantro_ctx *ctx) const struct hantro_fmt *vpu_fmt; struct v4l2_pix_format_mplane fmt; - vpu_fmt = hantro_get_default_fmt(ctx, true); + vpu_fmt = hantro_get_default_fmt(ctx, true, HANTRO_DEFAULT_BIT_DEPTH); if (!vpu_fmt) return; @@ -393,15 +390,16 @@ hantro_reset_encoded_fmt(struct hantro_ctx *ctx) hantro_set_fmt_out(ctx, &fmt); } -static void -hantro_reset_raw_fmt(struct hantro_ctx *ctx) +int +hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth) { const struct hantro_fmt *raw_vpu_fmt; struct v4l2_pix_format_mplane raw_fmt, *encoded_fmt; + int ret; - raw_vpu_fmt = hantro_get_default_fmt(ctx, false); + raw_vpu_fmt = hantro_get_default_fmt(ctx, false, bit_depth); if (!raw_vpu_fmt) - return; + return -EINVAL; if (ctx->is_encoder) encoded_fmt = &ctx->dst_fmt; @@ -412,15 +410,20 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx) raw_fmt.width = encoded_fmt->width; raw_fmt.height = encoded_fmt->height; if (ctx->is_encoder) - hantro_set_fmt_out(ctx, &raw_fmt); + ret = hantro_set_fmt_out(ctx, &raw_fmt); else - hantro_set_fmt_cap(ctx, &raw_fmt); + ret = hantro_set_fmt_cap(ctx, &raw_fmt); + + if (!ret) + ctx->bit_depth = bit_depth; + + return ret; } void hantro_reset_fmts(struct hantro_ctx *ctx) { hantro_reset_encoded_fmt(ctx); - hantro_reset_raw_fmt(ctx); + hantro_reset_raw_fmt(ctx, HANTRO_DEFAULT_BIT_DEPTH); } static void @@ -520,7 +523,7 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, * changes to the raw format. */ if (!ctx->is_encoder) - hantro_reset_raw_fmt(ctx); + hantro_reset_raw_fmt(ctx, hantro_get_format_depth(pix_mp->pixelformat)); /* Colorimetry information are always propagated. */ ctx->dst_fmt.colorspace = pix_mp->colorspace; @@ -583,7 +586,7 @@ static int hantro_set_fmt_cap(struct hantro_ctx *ctx, * changes to the raw format. */ if (ctx->is_encoder) - hantro_reset_raw_fmt(ctx); + hantro_reset_raw_fmt(ctx, HANTRO_DEFAULT_BIT_DEPTH); /* Colorimetry information are always propagated. */ ctx->src_fmt.colorspace = pix_mp->colorspace; diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.h b/drivers/media/platform/verisilicon/hantro_v4l2.h index 64f6f57e9d7a..9ea2fef57dcd 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.h +++ b/drivers/media/platform/verisilicon/hantro_v4l2.h @@ -21,9 +21,10 @@ extern const struct v4l2_ioctl_ops hantro_ioctl_ops; extern const struct vb2_ops hantro_queue_ops; +int hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth); void hantro_reset_fmts(struct hantro_ctx *ctx); int hantro_get_format_depth(u32 fourcc); const struct hantro_fmt * -hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream); +hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream, int bit_depth); #endif /* HANTRO_V4L2_H_ */ From patchwork Mon Feb 20 10:48:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239493wrn; Mon, 20 Feb 2023 02:52:24 -0800 (PST) X-Google-Smtp-Source: AK7set8NuMuMK6j/dsB1xyIzoyll4ZlaCR4akIN8hf5eEXZ6gkuStPxZTUVzmeG50UtL08P3zodS X-Received: by 2002:a17:90a:341:b0:236:75d3:fedc with SMTP id 1-20020a17090a034100b0023675d3fedcmr692530pjf.8.1676890343879; Mon, 20 Feb 2023 02:52:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890343; cv=none; d=google.com; s=arc-20160816; b=nbGDuDAb4Lv1eYTCbSud1noAz+LAuWKQNkwdP19YubIZ5CJEeuUCynpl/dUGe/a4eX pK5kPbYCmlNhl5YJV9lTJ2sMQKkVGQzCA8OJ3DCii8A3xZDQImfNBDOseP0M5ODW28g1 bMuLltVPEMNhScnxoUMMcbLNWiHl5vula4qF2pTVFzM+1Sj0B0N/UQ2j5/ZycbccxGN5 cuWesa6bghhmSo/1cy/kjJHkKS8ewUmwsF/1W8W+gb/vf6WDQbirI3IhAnqM/TGl7miw n52nzj30Z89JmM+wboplnYrdmBNiDGK6EWiGVXqyHg61ugI6HLW7xbtVERa59mUZDp6I dvFw== 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=EpN41LjAUX0qsWSvKb+3Tn5xpsaW1aYU8UF8olZa064=; b=r0I4NOXNknFLbwdhtflMiGoYC9ZjKxmlW9OM6ceihD3yht9WzqnDqHWwzEzoa3nYeE 0MuROQ8JdQLM34hYbaF/jNnDFUMVKOquJYV+C4QUbEIRYRXonNU9VbOjTIrMWGL/VVIb cqvWM2YffKG6Crm34xVRnb7J4hjY4MMsoMpNBohUfAjPf4uNZUrNWJ8TZYvynLKiWgmk e3g1Oea4y99lhg57YCdzQ0rB2qfyo5gAb+bFEcyQNIHP0b0T/GUK4a9DfFbMJwEQQmmK Uua6XQoZQN7RoU5kdswtB76wKhAoBfnugHkEXtqKSjqSvEerShJm5y1xojsZbfp5lSDb xFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z8il/20V"; 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 fr10-20020a17090ae2ca00b002311ef542bdsi48793pjb.103.2023.02.20.02.52.11; Mon, 20 Feb 2023 02:52:23 -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="Z8il/20V"; 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 S231506AbjBTKtP (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231676AbjBTKtC (ORCPT ); Mon, 20 Feb 2023 05:49:02 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A3E7AD0D; Mon, 20 Feb 2023 02:49:01 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 B5CEE6602142; Mon, 20 Feb 2023 10:48:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890140; bh=SxFS3sgxVfXOtyOQNwLjMDuu7K/g1eyIum+Nn/+YN6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8il/20VIKq6sJsWP5TMNUgVLnXgtrZetPbZoe0LpXmDIBGOuXk1dVfgwHrQ5JvhX p01Uk7bpBhcy4RWEwXoCYGJjsuKG8IYVBpbAuBhCoFHQAtMWE1HRxDhA5DJHmpzwdt YgmzvCnPEWUWPYWhDx8PB+8ZsL/IlUJPfe1Od8z5t7Z95pknu1MdvTa8lP2Kqmnjee pYt1FnRgo8ZV9WR5hDROXpTs0LQ6FwVuj09Q95sEnTJuZyGgxZ9fMFA+9orZBCv0Xi +3tnSn1QAzhUalkmPbpaxIRuWe3Rwu/GJFJMIQL0GtjHcFUtKn5290gvgENv5uXufX a+pJSqGVKt1Gg== 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, robert.mader@collabora.com 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 , Nicolas Dufresne Subject: [PATCH v9 5/6] media: verisilicon: HEVC: Only propose 10 bits compatible pixels formats Date: Mon, 20 Feb 2023 11:48:48 +0100 Message-Id: <20230220104849.398203-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758346969264344779?= X-GMAIL-MSGID: =?utf-8?q?1758346969264344779?= When decoding a 10bits bitstreams HEVC driver should only expose 10bits pixel formats. To fulfill this requirement it is needed to call hantro_reset_raw_fmt() when bit depth change and to correctly set match_depth in pixel formats enumeration. Signed-off-by: Benjamin Gaignard Reviewed-by: Nicolas Dufresne Reviewed-by: Ezequiel Garcia --- version 9: - Fix brackets drivers/media/platform/verisilicon/hantro_drv.c | 12 +++++++++--- drivers/media/platform/verisilicon/imx8m_vpu_hw.c | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index c237253803f4..7d452f1afaae 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -325,9 +325,15 @@ static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl) struct hantro_ctx, ctrl_handler); switch (ctrl->id) { - case V4L2_CID_STATELESS_HEVC_SPS: - ctx->bit_depth = ctrl->p_new.p_hevc_sps->bit_depth_luma_minus8 + 8; - break; + case V4L2_CID_STATELESS_HEVC_SPS: { + const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; + int bit_depth = sps->bit_depth_luma_minus8 + 8; + + if (ctx->bit_depth == bit_depth) + return 0; + + return hantro_reset_raw_fmt(ctx, bit_depth); + } default: return -EINVAL; } diff --git a/drivers/media/platform/verisilicon/imx8m_vpu_hw.c b/drivers/media/platform/verisilicon/imx8m_vpu_hw.c index b390228fd3b4..f850d8bddef6 100644 --- a/drivers/media/platform/verisilicon/imx8m_vpu_hw.c +++ b/drivers/media/platform/verisilicon/imx8m_vpu_hw.c @@ -152,6 +152,7 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { { .fourcc = V4L2_PIX_FMT_NV12, .codec_mode = HANTRO_MODE_NONE, + .match_depth = true, .postprocessed = true, .frmsize = { .min_width = FMT_MIN_WIDTH, @@ -165,6 +166,7 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { { .fourcc = V4L2_PIX_FMT_P010, .codec_mode = HANTRO_MODE_NONE, + .match_depth = true, .postprocessed = true, .frmsize = { .min_width = FMT_MIN_WIDTH, From patchwork Mon Feb 20 10:48: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: 59369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239790wrn; Mon, 20 Feb 2023 02:53:25 -0800 (PST) X-Google-Smtp-Source: AK7set8Z5I60c7peYtmj3gQEPq4WLlXJ0MU8ndj3ORGbn3vuwGL4NlNa67n+EC/VXwS8IvBzIxbb X-Received: by 2002:aa7:8bdb:0:b0:5a8:b37e:bb5 with SMTP id s27-20020aa78bdb000000b005a8b37e0bb5mr2227975pfd.12.1676890405636; Mon, 20 Feb 2023 02:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890405; cv=none; d=google.com; s=arc-20160816; b=TGAc4ZAicfmU9nwsHs3KpaYkTg7Nu2rfdrjL2mWXO6TJqFfqlWBoC2U4c0WZJ9vAeN zVIrljtdYdybKzwKbvAxO7Six0zCuH5u6rd9bWkhbT7g+AR+xak6gMALr9xZ4getYpE7 QyE48tBQQ2BxJCYXP7b17RpVxGHojRQ0sc4DjKESNqRgXYtylTpdnPMtada/xr3eVB2J QtqHZEvxxjVy7Flo+NvqNj4AQUgc8FLvPO/ZWUhvdioOFXXSQwYYUW6kby2UwHj8jdjq HCwG+tMtceACjyNfkDgeAQmYOlAhYGhnI5oDw3R+FH8Iuem9RMV91QGft8PcVBX9gzqg Y8rw== 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=ee21mlckjAumj77F4902THfQPQZSX/w3iGwzBxpFyjI=; b=M5xkJAvvf8ZO+x64sIiUMVSKecqbY3FpeYI0ILPKVg+b0kbQ93pkWFz6haae8f8eci NycCsMdl9raMBUMjk1jXajp2hx4ewRgS6viqb5mpX6iKBRsTu6erMMcKlvRZfVl72u+/ 7e9ATUQpxgR00B79MBqB4UqD68EVjF1orXuVYK7oOYmDgoRBmNV/r64pKd8cVJqcq7up dsebK8IWiy9yePxaAexCzqUONyatO5aX6vHBesE/dxncxI9XRkiYXHLxN5jssZ1WJbFQ a+PVZVKjvwUpNf6+I+0rLwOdOoWtqUxByYlSCZ5BHtlqqOCVJkKAMveYptikK4ccxQ4i NsgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="WsfFgn/L"; 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 f13-20020a056a001acd00b0056cb4662b9csi15168374pfv.16.2023.02.20.02.53.13; Mon, 20 Feb 2023 02:53:25 -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="WsfFgn/L"; 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 S231714AbjBTKtS (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjBTKtC (ORCPT ); Mon, 20 Feb 2023 05:49:02 -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 ED522A5F2; Mon, 20 Feb 2023 02:49:01 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (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 465BF6602173; Mon, 20 Feb 2023 10:49:00 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890140; bh=tiJU1XPfasKdiChhkAX5L0vI56X8ZEAvctUJUjANgAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WsfFgn/LAzRHgba5r4let4PikDJEKi3nz7x+JN032GIebw38U8b7q4/jfMgEUcc7E 9pEIGIASB0M7KVFEIhKtCEJGOrTBmNzE3jBC+D4eAv2if/fA3fu3s3pPGJN0HjUqqN 9qeKO3HLaWIKZw9ZnsKztmlrgYTqiYVCckpDNgKuuQmxQZtCp1IlMyVMP/HTCAKOYE 7+bWt8KZjpOSxJWK2DcIWE3KbWCg4wPPMOfbVpi0MVHZXHKSdJHLxJg72AekvkLkWF Bm8o+RgflIzQxHd7NjTg3gMoBco76PBfzJhGfUEsPlO/a82027p/MJZ7Dio+14xo8b rsf7MsWy4/GXA== 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, robert.mader@collabora.com 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 v9 6/6] media: verisilicon: VP9: Only propose 10 bits compatible pixels formats Date: Mon, 20 Feb 2023 11:48:49 +0100 Message-Id: <20230220104849.398203-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-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?1758347033831394941?= X-GMAIL-MSGID: =?utf-8?q?1758347033831394941?= When decoding a 10bits bitstreams VP9 driver should only expose 10bits pixel formats. To fulfill this requirement it is needed to call hantro_reset_raw_fmt() when bit depth change and to correctly set match_depth in pixel formats enumeration. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia --- version 9: - Fix brackets drivers/media/platform/verisilicon/hantro_drv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 7d452f1afaae..d20e62c025ae 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -307,9 +307,14 @@ static int hantro_vp9_s_ctrl(struct v4l2_ctrl *ctrl) struct hantro_ctx, ctrl_handler); switch (ctrl->id) { - case V4L2_CID_STATELESS_VP9_FRAME: - ctx->bit_depth = ctrl->p_new.p_vp9_frame->bit_depth; - break; + case V4L2_CID_STATELESS_VP9_FRAME: { + int bit_depth = ctrl->p_new.p_vp9_frame->bit_depth; + + if (ctx->bit_depth == bit_depth) + return 0; + + return hantro_reset_raw_fmt(ctx, bit_depth); + } default: return -EINVAL; }