From patchwork Mon Jan 30 13:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2191095wrn; Mon, 30 Jan 2023 05:58:59 -0800 (PST) X-Google-Smtp-Source: AK7set+hC2xx0UIHE593tLAiHssqCf96Gnkhei2QwFZG308C2vGPBxBjS35YWbf9p3hQ2O+Hsbdq X-Received: by 2002:a05:6a00:3685:b0:593:bc80:2d36 with SMTP id dw5-20020a056a00368500b00593bc802d36mr3651067pfb.18.1675087139366; Mon, 30 Jan 2023 05:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675087139; cv=none; d=google.com; s=arc-20160816; b=a+zh8u83yoho+nw+matdpf2P3UOiqgDRoNuWZvgwOadgzvPquSrlN7SeAwWNm3ubaZ 3SN1Z53wijCNRZfrtkIzYSounbks/AAINd/JWozvbqKuAeq2vLsPv9vfUBFZC2C7+eLB hJhkjvf0qb4PVAAUX6plPaHctK0Ob4/VK59SOzUG96/N3zC7DvYao97bLNMR5terey/7 N4/PxzfPa9tDCPlw5X2yJFMhZl+Ub6GRIVMPr3qFzlEhu2N0x+NljRYOv05GjQHBRjP/ fheY5sLeY2VPzEpXQuiHgvJVU1M4nfI9gehtJMPje0od0gz8NSC8z6jcarOGN3zVITyO wsBw== 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=FWFw2akwC7evxp9bghungt84Kr1yPe38PxNHWnTCsp0=; b=rK+OivgJ0M3isUB39BQwtyfqKLBaVAPdozfMEPmU8i70Czft8GHOvho+NLOBKs8bYf qzfpNEwRLUDLhY9zfwm9sxnmhl2x2vb61me6frG1yIUPyux1mYFxon3/oRNu4ayYpobK NKvYptZaGhxWh4DM/+8Ojtf3xa0o00oqye8v6trniMf3tZ1+LwCUUbpH7gKPGNL1UiOq RDC6U5jh6Pr5ud2VS2Vm0XfqUOHmKbap9+z0YRvdN52bTxpR7WwIlMv7GSKS4fFOzwKM HfhOcb99CzzEJalVXeVbV/nqSuACKiiBlXOGcKE30XccMWhkTQTjHe9MR+PRxiUQTNL/ 0EOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="hGHd/1fI"; 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 e20-20020aa79814000000b0059261b044b1si10475177pfl.217.2023.01.30.05.58.47; Mon, 30 Jan 2023 05:58: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="hGHd/1fI"; 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 S236798AbjA3N6g (ORCPT + 99 others); Mon, 30 Jan 2023 08:58:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjA3N6c (ORCPT ); Mon, 30 Jan 2023 08:58:32 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8C43A869; Mon, 30 Jan 2023 05:58:13 -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 A18BB6602E28; Mon, 30 Jan 2023 13:58:11 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675087092; bh=WeghlRFY57k/XRhbZSebcHWkeNrEWgqxdzHNHRFL4B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hGHd/1fIa/fiHQw+gZPozUKn1REan6qdtb2P6kIlNO4kg+or97jIq2XqgEUwU975u XEdyIDwriPgCR3LD2apWphe27j+VO3ltuVg+lxcA2aI+gkpP2187UK29+Mh/eTTrM6 t2CPcDF6Yxb2+vm58ObPFWOVkyJBenqtaXQ4lsTvu1Y9SjdKeKho+n2a8tu5G5TuLb /ABGmjrSfiOJkJd6uV3eLVFKlAiyIWsE4d58j3AHTugp1LaCXyYEdf5y6bqk2WU08g +HuHpVhNRrWP7Lmph1kBwARKm8K8ULuKVEIAuBFumRk8Ax1g+31VFuh2gva4L+scvK 7zqI/LGJDUj8w== 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 1/5] media: verisilicon: Do not set context src/dst formats in reset functions Date: Mon, 30 Jan 2023 14:57:58 +0100 Message-Id: <20230130135802.744743-2-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?1756456172677577044?= X-GMAIL-MSGID: =?utf-8?q?1756456172677577044?= 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. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard --- 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 2c7a805289e7..33cb865238de 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -381,13 +381,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; @@ -407,11 +404,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 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) From patchwork Mon Jan 30 13:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2191701wrn; Mon, 30 Jan 2023 06:00:18 -0800 (PST) X-Google-Smtp-Source: AK7set/i0PUnGJbxcP1hHFpjTXct29uSEpxXeR2UFa2TMsmHKwGCYcv0duQ27kgyFArfOkSHJAUz X-Received: by 2002:a17:902:dac8:b0:196:59a0:bffe with SMTP id q8-20020a170902dac800b0019659a0bffemr14575920plx.17.1675087217512; Mon, 30 Jan 2023 06:00:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675087217; cv=none; d=google.com; s=arc-20160816; b=CrS/cgxQvqiT6J3bREMjQKTaNemXdYdKOG8IL4YyCgfLpAQEci1ITyXQLfS+dF3Cqj w+kzrpRWf5c17TyYF8T1ZSx6zqXFm/5YLH/8hdx+gNl0HWGU19uNjLOXlZbwY8eqjkW5 D6Bx8qAuRN20lAsiRX8gRnEWqBHa+9y0RtJFtPwcOS+1UCfPJ/zkzOtP6qajvzHJsURZ dW/ghbeMVblq4g9DI+H/kPvnBwRMfBE3w5JxpOPt8Ufh4p4pVD+1XqNoUBkJO6md62Ai 1VEReUMF74rtF2QUhhOlXsQfYR8lFmhjYEoAfqXXqnP5uV2x4ZUM+1RNy+tux3kP95xs 67kQ== 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=MlO1WEtrBzqToM2JVr8ePy+FeisXNgf5vThBB+85vtU=; b=rE2IIzlWxoV+KVNUNA5/ZYquTDrxYiyGprubKWmyOhsFbulsaz700KB3ZdX5C29GcJ WG9/9+89JV2r9fjMS6aLhXlYVXHhu3Pu8Wlz37byf+e/Fad3KgoVMEf3mTf2nxewwRCn yPxa3DJmZGp9uCtBCxMrn3u8ooc5abyhKWtdrFZy7d/9zWRFivB7oaxzSTXBmdTkoP22 uUV1WGc9TrzS6zy92jgfCRXKj/fX0izzg9QdqEyPpSZfyWl98qIGVErPPTQjYgskBoXh 9uL7XROaVZN84r2GJJ+1V3dtZzRfx3Lex6YZsGlb81ljgibKA1gXMfN+jxNUBnKDbuVf jppQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SfUSiJ2w; 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 m4-20020a637d44000000b004dfaea494e3si11320769pgn.839.2023.01.30.06.00.04; Mon, 30 Jan 2023 06:00:17 -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=SfUSiJ2w; 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 S236791AbjA3N6k (ORCPT + 99 others); Mon, 30 Jan 2023 08:58:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236722AbjA3N6e (ORCPT ); Mon, 30 Jan 2023 08:58:34 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B3F2799E; 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 99C456602ECB; 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=1675087093; bh=C/QAyRDA/waqPf4kFAS8tK6asJ/IhGRhX08Vka5WQCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfUSiJ2wJQ24d6ulRQN2KZk741WuDEwIFzdvGLpIrVhYp0K9qLF3a3YKV+fxA313D 9umQx9ogVFNwH31/1Uh1VVmbwyQICualFayd0be7aPpbtW6EED/+12WNMzVF3R+BRz rhkm0iTWl1bBNf6OMt3E19vu5DM76y2MxuYKUO0yX/dProNS+SxIQsH+BjB59KmqSR j1L0YvApI6cAviPm8YvkwvCkWJTkavUiBwD/GHCSdhfROXL1WrBUlCz/QV0V8QndOs e5LdNh4r6oXwkw1tr1U8eIFZyue8SQv3gXv8K5ucNbv3b6TlLbqmknOBs34Y1JLP3x 4EHxw5Hj8KzJg== 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 3/5] media: verisilicon: Do not set ctx->bit_depth in hantro_try_ctrl() Date: Mon, 30 Jan 2023 14:58:00 +0100 Message-Id: <20230130135802.744743-4-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?1756456253902464321?= X-GMAIL-MSGID: =?utf-8?q?1756456253902464321?= 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. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_drv.c | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 8cb4a68c9119..715075f15596 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -274,8 +274,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 +322,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 +352,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 +491,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 Jan 30 13:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2191244wrn; Mon, 30 Jan 2023 05:59:22 -0800 (PST) X-Google-Smtp-Source: AK7set8masspNaiGZvDi9+mjpXqPhQ2Mvf+bmzUj3mGmZrcEXCLlaeMWisn50JkRj/vpBnU6r80a X-Received: by 2002:a05:6a20:3949:b0:be:a55a:890b with SMTP id r9-20020a056a20394900b000bea55a890bmr1588374pzg.4.1675087162268; 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=Hop8P/8zcZjEnBw1GD9Xv7fpBTZL3NzLO5PhydkAFHq/r3JU3siSX6pNlo96z0ZDah jJTsR0WY50gNQFgOLnJeyPVOfVwHT9oeaIIQkcKe2I2NxrELxDTBbH40cXJF4Tx0SIf2 R9K1/CoHU2Xbv64aPMdOIz2/OmllWDH0z4P9W0DHlsParnD/TGu1T7X1yxqcnt424gBc RpFTsK/ECZmUCFuy80jNUCap20ic6F0E92b6Q+p6HwfqJa2exLLNZGOPPR7B7oOXSkvB b5D8wjrGBxHsaHeKtGyZBB5pFdAtNBwYUQfMkHfbIKl6OrfzAvbYCT7rln2S1iuwGoJ9 jBGQ== 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=yyVWavdT2l42BLxg4w0E3oVF3o/SiZ4vlz2nVL5DWJ8=; b=yYOHCtIwwrUkq6YTSq3fIYGXoVTQjCfPAjq8LE76yprFj+tVjZPMyJvNwnQNdlYLgZ RvdYA7ZZPn+wXcxHzWP9EVicGjwa5QtTByed398sme5f0YctYIoopoGjy1SSPqwtOLGR C95+sMz0TmeiFeBDzX2qWGSeTzL4yAyEaIS0SJ+7i76IQ7IVEhqql35bgQ1UwJ4r43XV PXHu62hJJbXeybKPglpphNysA6jvDCr4rlJQTUQXNlrvYKqM4bpu/dmfghjoTclTs7LT y0HKj8l03mPvP6OEl6GbQ+iT0yhCoNrX5Rkg0svr9RhJHTXVcRI0JmaHwDMaaZ7ReMSG iLJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=P3xuiRZq; 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 s2-20020a639242000000b004d0b91d7f1asi12853665pgn.43.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=P3xuiRZq; 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 S236850AbjA3N6q (ORCPT + 99 others); Mon, 30 Jan 2023 08:58:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236773AbjA3N6g (ORCPT ); Mon, 30 Jan 2023 08:58:36 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77FAF2B600; Mon, 30 Jan 2023 05:58:16 -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 1C14A6602EEA; Mon, 30 Jan 2023 13:58:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675087093; bh=hF/60MRYbbN9kX2Ov6nveGWMmChcDBlxRYTbNT3U1dU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3xuiRZqM1Uds2OoQ5WhKk+Taubq9oJe3xdLqCwnFVQLTTjj7eWiHXlHgaOpsFi+1 uc+Ko3HPM1GFSv+x/SQlkvPp6Qm3slx9fAfAlHP/ElHD3XYNzyjWrJbC7Js+CzMy6Z f+ildvh5maleEPtXCgwz06yQ7BZTO6vnc8xwNLar1+897ipydFnK6JdTXURlD4nDkD ukBaELAMFR8ATFojskaKgHTyMb7UF6I591ljseOCA6NGYcfxS9uMju8MiBfm9BoXK9 519NfToaLg4EOoZKrBL8nhLxetXQ93swbShAARk4BBZfIiWPzIUD5q1tPFBE4CtoxH pvTegi7yzOeHA== 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 , Nicolas Dufresne Subject: [PATCH v6 4/5] media: verisilicon: Do not change context bit depth before validating the format Date: Mon, 30 Jan 2023 14:58:01 +0100 Message-Id: <20230130135802.744743-5-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?1756456196288418182?= X-GMAIL-MSGID: =?utf-8?q?1756456196288418182?= 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. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard Reviewed-by: Nicolas Dufresne --- .../platform/verisilicon/hantro_postproc.c | 2 +- .../media/platform/verisilicon/hantro_v4l2.c | 45 ++++++++++--------- .../media/platform/verisilicon/hantro_v4l2.h | 3 +- 3 files changed, 26 insertions(+), 24 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 e60151a8a401..6c5f4351b257 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 0 + 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,17 +78,16 @@ 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, depth = 8; if (!fmt->match_depth && !fmt->postprocessed) return true; /* 0 means default depth, which is 8 */ - if (ctx->bit_depth) - ctx_depth = ctx->bit_depth; + if (bit_depth) + depth = bit_depth; fmt_depth = hantro_get_format_depth(fmt->fourcc); @@ -95,9 +96,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 <= depth; - return fmt_depth == ctx_depth; + return fmt_depth == depth; } static const struct hantro_fmt * @@ -119,7 +120,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 +129,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; @@ -203,7 +204,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; @@ -223,7 +224,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; @@ -291,7 +292,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; } @@ -379,7 +380,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; @@ -392,15 +393,15 @@ 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; - 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; @@ -411,15 +412,15 @@ 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); + return hantro_set_fmt_out(ctx, &raw_fmt); else - hantro_set_fmt_cap(ctx, &raw_fmt); + return hantro_set_fmt_cap(ctx, &raw_fmt); } 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 @@ -519,7 +520,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; @@ -582,7 +583,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 Jan 30 13:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 50297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2191460wrn; Mon, 30 Jan 2023 05:59:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXs8ArdKvnED7pZ0TxpJpBdDDn3FXg/8xx1+4Cy1eVcdSYgeUVSeABnc0Y4UwOHcASb/1teO X-Received: by 2002:a05:6a20:1611:b0:b4:6f9:ef7d with SMTP id l17-20020a056a20161100b000b406f9ef7dmr64974380pzj.35.1675087192352; Mon, 30 Jan 2023 05:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675087192; cv=none; d=google.com; s=arc-20160816; b=lTm5Rjbs/4q3S6WORmxhGcwQkpbvfgKw7j0/mVKbNwPkIcG3G807/CjoucejAk5Zgf C1gaT6PMB12PKZo75kCN1N/1PbGYUrGrmqAalKGMZYz86v45j3T5p665I2WEAbwB+zKG ru7EQXWk+VSxhX8m3Jahd6ip7Ebwp0NOsmDtWGpkWBqew+6t6W8BM9wBuAVo1K6Foevg G0xZqINfsuaYj4hfExXwimgmB+Sz77u8NJwjS9hHOY1EGPoGnDMMvZEBO/Em4/Ea7nVs Zc36f20lPJ4e1QaO1NHulrKfw2pn2CCD9WxU0u5WWQAhByM7Izmm701HrajtHxxaCb54 ymJw== 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=R8+NmgehGRZs8dDM/0o29Rb29uJ5QgrfIfBSGwdLfTU=; b=Yuirr6Ms6KpQBZm+SYKo//Pk4d+WWq7asdkacq51/EGvIvWglwS1f3ewnzpKhLKhfa fgpff8VdyIqCDWkzHEi2XCPDKTrj8W8eGMbPP5JQNwu3wMLAqBGNqx8U0ChlbolmswHl iF7FX0dxb84wWm/rpjaIOyWkLfcK9pwq+QIdCkU75/J36NOzqnHpTNIAZ7xlpRAx3H8o O6DavtshuxO+nMifROM61wJePhbpPT/zL+B+MnkDPvVN5X+lI5jAmuRW+KvfEAQRrVag Y8df7IcSkcEEX5zcktyxusZwTLzmt3rvBvI4MLh6yo/iPBzIKfTeA9QrSjP5V8qlBilY bVdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UbeFUDJN; 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 z2-20020a1709028f8200b00188d892999esi12206970plo.521.2023.01.30.05.59.40; Mon, 30 Jan 2023 05:59:52 -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=UbeFUDJN; 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 S236925AbjA3N7H (ORCPT + 99 others); Mon, 30 Jan 2023 08:59:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236800AbjA3N65 (ORCPT ); Mon, 30 Jan 2023 08:58: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 4EE4B36FEA; Mon, 30 Jan 2023 05:58:37 -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 996E96602F10; Mon, 30 Jan 2023 13:58:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675087094; bh=R5a/mEpnxaqGwC3EbPKXrQNBPFEzTc0n/5f90KTNBzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UbeFUDJNjH+boCT1h8uJhzuLeqp2wTx96eCbu0JLaU1/SUDFSJmZWNun3sKp/eTq4 Z9JlKRyaD57WcD78uF34AkuL4sOnpO5Z3MVZlamrTDr3tmzPTyw1YWl+KIXuCgTAI6 7lb3WaYZMzVrkEqbZnpujWMWiVShNEVwqWfIJrQiEqXE97N6tfcj43R564dC3ItQcx zmy2wZlIUVs8qj+36vV8mwiqHQsXgvKW60WolHykjBDgCSiOPQDdciKy+YeU2pzgMn 6GkT3nEOV3N1sa53CZ1kdGaYOR+kP0PBQDNN6853mzqZbgKcxeOgP7l8+EIpYjtX4E PszSStAJgWSZg== 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 , Nicolas Dufresne Subject: [PATCH v6 5/5] media: verisilicon: HEVC: Only propose 10 bitscompatible pixels formats Date: Mon, 30 Jan 2023 14:58:02 +0100 Message-Id: <20230130135802.744743-6-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?1756456227948630767?= X-GMAIL-MSGID: =?utf-8?q?1756456227948630767?= 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. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard Reviewed-by: Nicolas Dufresne --- drivers/media/platform/verisilicon/hantro_drv.c | 16 ++++++++++++++-- .../media/platform/verisilicon/imx8m_vpu_hw.c | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 715075f15596..e3656649c717 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -331,8 +331,20 @@ static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_STATELESS_HEVC_SPS: - ctx->bit_depth = ctrl->p_new.p_hevc_sps->bit_depth_luma_minus8 + 8; - break; + { + const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; + int bit_depth = sps->bit_depth_luma_minus8 + 8; + int ret; + + if (ctx->bit_depth == bit_depth) + return 0; + + ret = hantro_reset_raw_fmt(ctx, bit_depth); + if (!ret) + ctx->bit_depth = bit_depth; + + return ret; + } 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,