From patchwork Fri Feb 3 09:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp731630wrn; Fri, 3 Feb 2023 01:24:39 -0800 (PST) X-Google-Smtp-Source: AK7set9znFyieblT76yXm46phgwJnkoQCZMkj3FO2KwPn8N7xKgJ3bgK9qpwMc1BpJk3jEKj7ios X-Received: by 2002:a17:906:c411:b0:889:14ec:21ae with SMTP id u17-20020a170906c41100b0088914ec21aemr9785440ejz.32.1675416279294; Fri, 03 Feb 2023 01:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416279; cv=none; d=google.com; s=arc-20160816; b=owjU2oKZU3a+Clu/fKctHHlQAY4edb63xEdpFjAc24Yg0739VOG+f7et42j6i4FhxK ncOWnlorlZiInGywWHewSngNMXcpwzwKk1wvsdurJQH8Y1ZLfWicjFxZjBvssY8JId/G 3nnDXIKjdIUmZ6O6ApD5ugOG5JWYtu7+wMLYW+qXoYRhdf8d8k5haUjn6NJlCMWcvb84 CZDy55XsK2FAt0K+opBbl48LqdPAwN0HhC6AxC/xfd9WY/XUPihRPtriaChNlt5LBwOT fclirv+cFuboWg6TR/M2OqLNib/s9DC5Ozy7+F1+fXxRtHOKQjEHZbr7hG+PNzP0h3ID 8rsA== 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=Q9/nKjZTN8T+/8Na7Rls+w7nCVRsnVZN0vJMpDzvswVy4TmvZtUD6cHUD+2HH1xiQD 0ARD8s78m66y4rMbu1DvEpD1/TAylTJkswf/KwV7k4ddLFWXSDFEopYD7SlOkNABl25M fddyFcKexGd+5G9HlcRU37X1WO8rw6DM1WB3QbRWzDlOZPQR9MnH6Thw8okUDQJsk2TA K3ywQSBmnmIypvBeUoT80rwQt+6XPgyidRcseHF1WAlxxBW511ptDhBtj3uNzf7jBs7S G3xhmtBiK8qedD1aJA5MV4V2d2TFWf0eWXFt+EiCcOih6oKi28A2arAcjBuDW0b/vnAF P6og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=krTDlQ3U; 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 u27-20020a170906109b00b0087d0121def7si3324316eju.248.2023.02.03.01.24.15; Fri, 03 Feb 2023 01:24:39 -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=krTDlQ3U; 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 S232858AbjBCJR3 (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232701AbjBCJQ7 (ORCPT ); Fri, 3 Feb 2023 04:16:59 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5842A991D1; Fri, 3 Feb 2023 01:16:37 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4B5B66602F08; Fri, 3 Feb 2023 09:16:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415795; bh=WeghlRFY57k/XRhbZSebcHWkeNrEWgqxdzHNHRFL4B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=krTDlQ3UYuk65VZzTeSbLvrLvgLmqYPYXnfZRrtZLyf8H4jab9+9UueZ9fAJYMqjG U3YfkwlW2KqcsKGU/P2KlFuhZHav+2oByHo7CgdNaX+wwUmUHDYF+Z5qOhFkX5Je9N lCCw7A/X59NxP2oo7HviS3nees+4SbipjbHkdxW2UxZKOtnSKj4ErY9NyeUM2qLji6 FOLWwCGqfJ7M7QClzl8MDIRTFRk8NKeDVpoQ9NPfFNDePWoTOWI8Io/7RlSxwLS2KZ n7noqfkXp664quBYN0DC49PPLgaZTyjEMnwV1moTs66+h4BpwJOW61eaMw1w8sYAlB 2FCW/45YK2Ktw== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v8 1/6] media: verisilicon: Do not set context src/dst formats in reset functions Date: Fri, 3 Feb 2023 10:16:17 +0100 Message-Id: <20230203091622.127279-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801300249961397?= X-GMAIL-MSGID: =?utf-8?q?1756801300249961397?= 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 Fri Feb 3 09:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp731564wrn; Fri, 3 Feb 2023 01:24:29 -0800 (PST) X-Google-Smtp-Source: AK7set/KGLwL+NsDTsNYGUX504UV6fi/xDKtcXKfQblFiT8PqIQDFavvPw260QdjoZ2G5ckWavdn X-Received: by 2002:a17:906:fa89:b0:880:5ab7:cb76 with SMTP id lt9-20020a170906fa8900b008805ab7cb76mr8626233ejb.33.1675416268944; Fri, 03 Feb 2023 01:24:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416268; cv=none; d=google.com; s=arc-20160816; b=oZRAQdCN+Z+RwJoJ3plLDx6rDx5MeVa9bT6jji7OGwP/3S6BliBULyet62j5vuzUVl CvCziRN2874Gmy2ApkaJkDGI3AWB1P+wYf9vIN10ub1F+aotZWTg9gSA0SDSqfYV28Gl B+ZyW14X23qPuKKYucgdS0mRUEX8C5SZW+6br01mFGiSrsjZYD/g9zjbbGpa5GirCCE9 xmfavaalNas2ear1jEXYFwAPh2WzoBP7oYinMvzapPyO6f5j7kSPBLF5Ac1ZpShLR7ub LkSeN0IXrN6ZTu6sMiq1xpjwYRweYaluzQ6j8dJ4TapT+fXRNXYWSfwP/2135mcdrsoI dhaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ud7/S02vaGDHLDDt3yAeK975uGNtBrEJ2wBuvjyFmUI=; b=oT70sixhcLgq3GdyeYhBuUdX95cKmEUJO8TD29YBT7iHX9gKZUdEAgvuRhe4iOhtX8 B9pOujarAXChp8RprGAAzZLkKKe5FCKcKv28bsHWkmSKkUdIhpbSQ11XTVfT/MlZ7NoH iguPDFB1yw3xLN559+qa3h59JCxjFP/YwuAJFvz/NbZWKA6TBrEM4qnS0Xkiuag2fMEc vMcfW5VMVF7Qvxfn13Y2mGGn38oMQDYyNWM6cVLLvy5yZ6ZsI6BoPyH2SjVhOOBgajyY gs1g2cVJ7ENJ6P853icmER9ExLQ8nCpxBz+lbfjSfmZq866LdyQwpjbMo4aNFWPL8hMc J4Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OuOaHVkf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a056402414900b004a2042e2117si2374138eda.574.2023.02.03.01.24.05; Fri, 03 Feb 2023 01:24:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OuOaHVkf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232805AbjBCJRY (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjBCJQ5 (ORCPT ); Fri, 3 Feb 2023 04:16:57 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A93A991D8; Fri, 3 Feb 2023 01:16:37 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C52986602F0B; Fri, 3 Feb 2023 09:16:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415796; bh=9xkh7Mz6B7KCpRaWkFO7AHPjQWKFgdQpvDXYN313zu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuOaHVkfD7N2ri3orPAhlLmTr4P/1eh10YjH1OTywBJCzllotOe5UewgtvKXwlKPy cNl0MCYXwP6C1s12znKZuKUBOHep7GdkILznBAEaqJkRdAAco7UQ0fkLIrjehM9lRN vz0CbEu+0fmPtMybzjb06hDGaJnXW1Q1mB5CSg8LhitTl6rgrg2N4GGXkMOzKQVlp2 h5dRmfG3+7tvq3X+6aDW8xl6hKsMxy+96qo2Lry1HcIXZB2a/rUoI/jblhto3OTA8J iM7HrgA1pnukYRms5gSZ8asSuPp2BMQTms2OpMJVvBc/DcCiyX2WkY/xWTNvSk68w6 7ppQx+NXPFGEQ== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v8 2/6] media: verisilicon: Do not use ctx fields as format storage when resetting Date: Fri, 3 Feb 2023 10:16:18 +0100 Message-Id: <20230203091622.127279-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801289622639035?= X-GMAIL-MSGID: =?utf-8?q?1756801289622639035?= Source and destination pixel formats fields of context structure should not be used as storage when resetting the format. Use local variables instead and let hantro_set_fmt_out() and hantro_set_fmt_cap() set them correctly later. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 33cb865238de..e60151a8a401 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -377,47 +377,43 @@ static void hantro_reset_encoded_fmt(struct hantro_ctx *ctx) { const struct hantro_fmt *vpu_fmt; - struct v4l2_pix_format_mplane *fmt; + struct v4l2_pix_format_mplane fmt; vpu_fmt = hantro_get_default_fmt(ctx, true); + if (!vpu_fmt) + return; + hantro_reset_fmt(&fmt, vpu_fmt); + fmt.width = vpu_fmt->frmsize.min_width; + fmt.height = vpu_fmt->frmsize.min_height; if (ctx->is_encoder) - fmt = &ctx->dst_fmt; - else - fmt = &ctx->src_fmt; - - hantro_reset_fmt(fmt, vpu_fmt); - fmt->width = vpu_fmt->frmsize.min_width; - fmt->height = vpu_fmt->frmsize.min_height; - if (ctx->is_encoder) - hantro_set_fmt_cap(ctx, fmt); + hantro_set_fmt_cap(ctx, &fmt); else - hantro_set_fmt_out(ctx, fmt); + hantro_set_fmt_out(ctx, &fmt); } static void hantro_reset_raw_fmt(struct hantro_ctx *ctx) { const struct hantro_fmt *raw_vpu_fmt; - struct v4l2_pix_format_mplane *raw_fmt, *encoded_fmt; + struct v4l2_pix_format_mplane raw_fmt, *encoded_fmt; raw_vpu_fmt = hantro_get_default_fmt(ctx, false); + if (!raw_vpu_fmt) + return; - if (ctx->is_encoder) { - raw_fmt = &ctx->src_fmt; + if (ctx->is_encoder) encoded_fmt = &ctx->dst_fmt; - } else { - raw_fmt = &ctx->dst_fmt; + else encoded_fmt = &ctx->src_fmt; - } - hantro_reset_fmt(raw_fmt, raw_vpu_fmt); - raw_fmt->width = encoded_fmt->width; - raw_fmt->height = encoded_fmt->height; + hantro_reset_fmt(&raw_fmt, raw_vpu_fmt); + raw_fmt.width = encoded_fmt->width; + raw_fmt.height = encoded_fmt->height; if (ctx->is_encoder) - hantro_set_fmt_out(ctx, raw_fmt); + hantro_set_fmt_out(ctx, &raw_fmt); else - hantro_set_fmt_cap(ctx, raw_fmt); + hantro_set_fmt_cap(ctx, &raw_fmt); } void hantro_reset_fmts(struct hantro_ctx *ctx) From patchwork Fri Feb 3 09:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp732008wrn; Fri, 3 Feb 2023 01:25:55 -0800 (PST) X-Google-Smtp-Source: AK7set+HNy4JWiEAknxJxezMWEBq0Evkym7G44OcfDXp7UlPR19LABZBlS3bA2C7VVQfH7YJ2c4B X-Received: by 2002:a17:907:6e22:b0:889:729b:5a9d with SMTP id sd34-20020a1709076e2200b00889729b5a9dmr1188885ejc.38.1675416355098; Fri, 03 Feb 2023 01:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416355; cv=none; d=google.com; s=arc-20160816; b=rGcB7sGzvuJO+wNmD2524IjTyy8X71WH594+v6j5bhIvRNGJjCXyJGak4rEN2InFIm vvTBJk7nQaFIKlIG920zWeQslin3lByM6cDHw5a5IiUM3anOyok7A8IYUnp34DOwafv5 i2XCGiY6TzPO4owJPRLn3pSA8GRT4JMV8cpDigt24fEYPbIWkGINMzucv6YCKlhBtk/3 wesX97oBrgvQ1CTT5Z0mPp9QwQT1XPH5UlSZRFih1QisopEqub1j8CnXxMxIzoJ+NPIZ 07C/IsRdunb+GF9paMZG+330ioSP9n75mgM05WaE6jcvCiOjbBtriTVY4PzZlPlx9BLQ TAdA== 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=DdcyO2PzpOiyvLgPamwbq6S+cXrCSiNUCZRgklkBJLU=; b=By7r+mz15YABJGwOX2JbHptx2tN1iHVcF5VRi/lA2YQDMXFgu/NrW5OGHGEWOe8UVp MhSv/ioPgI3Ijhy5e+E/f44jabDPH8+cVg4l26eGL+LIgDpxHUMZZu0TklWsIaa4jQL0 p1sg8f2FmzzqdOJpBvBeVtUllfk4mUGxNmNds4KHrdu43Zg/G1f5xz2bJHLnQV81Puoy nBf/vhhivVU4qdkrr0SmrS+HNzY05xM9nq2fvxMDokH4P/vIJZKhQDBqugE08QHbSD/D mF2HnM0m3NZZnJunKEWY3XWUd6XCvHve7qkTjhafQCR3kb/DE1Xt3YNnzytgG1ZbNFH0 X7yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CFSvYdot; 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 14-20020a170906004e00b00880f2099b12si3277294ejg.226.2023.02.03.01.25.31; Fri, 03 Feb 2023 01:25:55 -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=CFSvYdot; 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 S232716AbjBCJRc (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232695AbjBCJQ7 (ORCPT ); Fri, 3 Feb 2023 04:16:59 -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 CAB4E991F3; Fri, 3 Feb 2023 01:16:37 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 45E836602F0E; Fri, 3 Feb 2023 09:16:36 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415796; bh=XkoUCITE8h1soeO51L0cqguHb/kDm/X/DMUUXHPEMvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CFSvYdotWp7taqLyWxCkOcF2cgzFwo1c4wPNGGegBjxBOvXki5QvrFps6xL4yoMSF OJ80+PgWaRdG0Eaer3uja6uIFhv4xJV7DfQD/dwD2hKT+gMf15R0kIlCAhWGuctvCP xX7En04caQ9GRmosrgy9cT292T24zJ/6awv0tCs0m2zntbWqmpqFV5bwXLo92hz/tB vPHtlD0evqErzQS+CU+OMDR7eBeO2KUkoS2lxvm12sS5WmBkYOiT9YqMPEEuWgcQFK OqZqiR1tg0H3kcdgAgfYj6tddnk/NpIb7yLYxAc6UgmlDKL5gWDcKbKdWXS1K4IHwL nwdOu/Cfq5vAg== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v8 3/6] media: verisilicon: Do not set ctx->bit_depth in hantro_try_ctrl() Date: Fri, 3 Feb 2023 10:16:19 +0100 Message-Id: <20230203091622.127279-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801380082887008?= X-GMAIL-MSGID: =?utf-8?q?1756801380082887008?= 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 | 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 8cb4a68c9119..6d8bc55ea627 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 Fri Feb 3 09:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp731640wrn; Fri, 3 Feb 2023 01:24:40 -0800 (PST) X-Google-Smtp-Source: AK7set/9pwvbkDyachUT3w1AvtmkEJwBTC7BvqEgAL+GIVv1kqDgUxxMU6q2T1nXyUyCBioVnPIw X-Received: by 2002:a17:906:538f:b0:879:284:cd2a with SMTP id g15-20020a170906538f00b008790284cd2amr9461149ejo.30.1675416280529; Fri, 03 Feb 2023 01:24:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416280; cv=none; d=google.com; s=arc-20160816; b=EPXRFaBWFxlyvHTNQgWL7hxF+a2EdinEeT1TokO+Xgm91fmkVQ2ZEzsh08hGtatAxF ntcnfJWmvzc9kmnX8OdMCv0lKjuTUv5Cf7tGTR0xoIYTmpk06rxIH2Ml6CNClNDioyhY XQSjlm431VSaDbWUtN6woKQDFYCdeLHDM6ATn1wmu37+Ov11l1gk1isxHJsdTShayXIm 7AHs12zTO1GPCZWSrmJ/g0ccR6k9x0vUcTbMwXYXEZlGrNIE4BGcVcv+FRaIzBoeDSFm jPuTe5dnXu8yfPTTAslY0K8Cy6MsipfyJTDIZgxAy2yLfTFl0NEzlU5SlcF+FSSsdJxn W92g== 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=Bcfc9mIJreIVzH7TLqsUtu6u6hbvjYIRjRTAly5pvfg=; b=Cowa4uhvnlHDaRIiGDOZxa2466w7hWKoRbdxb5GYyTA8qrrSgJ10v5si1029z6xzNO UrcYNGA2YX/ClM6u1shuxlUYkGMuVL3r+BEQvD+z+LP7BvkVJiy/W/0lSR98BwFFMpmj 6nZjTny2g7zTMiD1++/MbQKmfyVadg6x3cetZzHyU3D5W4G+Eebv8PCrHCTHRB4z32WW oFpXeSmVirNi7v+ira/VNr9UslcjjWxj8DQ+bhfHTa1agK/MnYR0CMgCBt7P6MzqVO2F kkrWrSquqkb1hI1bkYsA3fAG2/oDT2pi8SHwQ/UHk8OvAKYxkvoURRLQpf6IjWnVLsVB dOKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QPye5Chw; 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 uh10-20020a170906b38a00b008785abba122si2175971ejc.165.2023.02.03.01.24.16; Fri, 03 Feb 2023 01:24:40 -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=QPye5Chw; 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 S232585AbjBCJRf (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbjBCJRA (ORCPT ); Fri, 3 Feb 2023 04:17: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 4D2F88E48F; Fri, 3 Feb 2023 01:16:38 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id BC2CA6602F09; Fri, 3 Feb 2023 09:16:36 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415797; bh=752HZ4uVvStIIcKhagF9QnoB41yMeC5WhBi80T4vY4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPye5ChwJZQIwKMhEAB6eYd6hBKf5bzEvSW5oRdm1w3xs27rbebEafNS21Mn8D956 yn5FffOiHb97z0DM8DpfREs6UQ6il8wj48rv9pgiXcXJFwmuIKFr1pbGVY9j8noUcP 782LI7vKB4rcYj8MgQYYAdkO73hX65baxbvePIKv8J3i8kAjL5vMYQCXZrPX/Gcz9u Uj+yS+F7xl4YksAOJbd5VzM6It//LlhNlTKQjKwheY7QkPCFAQORhkJOnM7nu8JYA4 EQs/At8jt+qKJqczVJlCX9SAO/JJYrYCZD30GY/QSGGUQnZH3aGcTVWpzUg3gXSqI2 gX+2htfE22TVw== 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 v8 4/6] media: verisilicon: Do not change context bit depth before validating the format Date: Fri, 3 Feb 2023 10:16:20 +0100 Message-Id: <20230203091622.127279-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801301372279149?= X-GMAIL-MSGID: =?utf-8?q?1756801301372279149?= 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 | 51 ++++++++++--------- .../media/platform/verisilicon/hantro_v4l2.h | 3 +- 3 files changed, 30 insertions(+), 26 deletions(-) version 8: - Set HANTRO_DEFAULT_BIT_DEPTH to 8 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..7c9a04171b45 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; @@ -203,7 +200,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 +220,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 +288,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 +376,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 +389,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; @@ -411,15 +409,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 @@ -519,7 +522,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 +585,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 Fri Feb 3 09:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp731683wrn; Fri, 3 Feb 2023 01:24:50 -0800 (PST) X-Google-Smtp-Source: AK7set+4bTK8FRMlyiYbkErpqd8z3SrjHNPKhZROlrRRt/ieDZ0FycWLYG+0+TghB8gJUkJDQEyQ X-Received: by 2002:a17:907:7094:b0:88a:72bf:9670 with SMTP id yj20-20020a170907709400b0088a72bf9670mr9594800ejb.50.1675416290278; Fri, 03 Feb 2023 01:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416290; cv=none; d=google.com; s=arc-20160816; b=PX6sI+QuNv8t07Rzc5nTv1ifBh6bGDtDk7/beNArbJLzfparS9ne5qIANhPnS7CH9t zmE/rRJW9Zy6jbtSlx08F0QvG3NXJfm7jiwE0l8kZyGWkZZPm6M+4HGSElEb4fIzdx3x TnB634G71OC95Xy0tYndtl1ccOzVV8yFlWDVRfMEjYHqp4hCQd3dM39McdNK6nwh+b+S oeHb4x6AGOnN0jRNWXAtyX2CGIMl2FXYYVzx1O4TVcDMq+bcDL/mNDkmRnaJn7rhzpy5 5S/Q8B6Ziq+/poJ8SD7BqaL9m+pvTNye2YtEZSOsxmC0jJ5PoZe6xNHdzDJ0Jb9kVsmU 6EeQ== 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=perwqVqIKRYCXBszYxe5vNivHemwlUeXVsh8WBzvg3s=; b=rQQSkGK7zydMf2SCOhswQmN66rvgm53BjUbP2GJQo0WH3uCs+xDF3H7r92eE933PnC 5B2jFA+L8tUVMKSIy5nKC4lSgAmgcp/mbcMo7cPrT+U0JFh1BPYt12bJ/Ft+QcsxjMeS biDHqqxIAUkn/X72bxqwjaXaMgxrd7i3R/ZvekcdrsNvuWIQEXUkoHFG6Xkli2tiCem7 ng5uJN1M2lLtDf3tcULvxFAvWpsU0IQS5FOONYbuaGhI3wsSlR/5LQRaWVBF5vRwnHSI Y5tj2/S2MKAVFP18ul0Tie4rjk61yht6QXvlJz0vveYwEJOuMu76NtRQHbx4sa9X2IqE r47Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Wr61kx/j"; 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 we22-20020a170907235600b00870e366aa27si2424048ejb.99.2023.02.03.01.24.25; Fri, 03 Feb 2023 01:24:50 -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="Wr61kx/j"; 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 S232637AbjBCJRw (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjBCJRS (ORCPT ); Fri, 3 Feb 2023 04:17:18 -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 A9590991EC; Fri, 3 Feb 2023 01:16:57 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 42B336602F13; Fri, 3 Feb 2023 09:16:37 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415797; bh=nidu6T02emPBRdNskapMOIyau6nCKMPVCYROcQaB4E8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wr61kx/jAol3M4xSJeQj2og6/DDn7TkNQwJsaeQ6B3y1ytmlAVO0e+WB2ae23w2KK RZbC41NgrVdVOP9X9zBwN5QXBNJ/bJkELqU2J/Aogg4cnJ/Yem/kUflJ0jRCK/clCf pbEo9hZfw4FTZJRRf+n4QEPTH/yEx6UUVYq4t9JmLESeWHaVUXV/CzBnQpiAWFfmwh EKIlNnUfrdyHOay7blUUSRXXxRcLK1Bz+Hwh3zIcJURuvS4/0f0U3Ls4mLd0I0L5fh ChhyTvPeSCr5Fln/te6CTwOlC6kWqKLhXpy7COviGa1pK6GHVoqU2re1dVqDP+Z25I FrsRR1lVxMO/g== 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 v8 5/6] media: verisilicon: HEVC: Only propose 10 bits compatible pixels formats Date: Fri, 3 Feb 2023 10:16:21 +0100 Message-Id: <20230203091622.127279-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801311652407924?= X-GMAIL-MSGID: =?utf-8?q?1756801311652407924?= 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 | 11 +++++++++-- drivers/media/platform/verisilicon/imx8m_vpu_hw.c | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 6d8bc55ea627..fa31b200b097 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -326,8 +326,15 @@ 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; + + 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 Fri Feb 3 09:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 52424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp732324wrn; Fri, 3 Feb 2023 01:26:55 -0800 (PST) X-Google-Smtp-Source: AK7set8KgA2sZPi/6ZdqFnhsSR8LBIe2KEBJZOorYsJWDxx256/ezD2b/Bbk3JgUcfrF013AEIWH X-Received: by 2002:a17:907:a706:b0:88c:a14a:d039 with SMTP id vw6-20020a170907a70600b0088ca14ad039mr11903095ejc.69.1675416415233; Fri, 03 Feb 2023 01:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675416415; cv=none; d=google.com; s=arc-20160816; b=NzPoXUAozw1ayLlgSxwn43BGfjCJAjS/oFMXSfDHx0XJWbCdq2W8duwWZqBdeLUPnO BxZKmE/h9CDg1cQzVtbh6vFX1TMvoAfRNZSUTEiX3bcMWMUgptEkTpA0rNlFETbhXhsZ VTEyWlLgyovvuvm5Umm64uapB9qckiy0gB8kUf71ZSCh57QX+jJA6o7SzueuNWQ9E1hb Toej43B85wc737HF20CXi8Bgie28uUmxKjkKvodtG77UJk7RgEXruoj40/n+5RYEug0b kfeDOfjhu85TAJkcLm3ZB1M6+gpCTo6pCaXKrNdwd9dUQVRG1DA2mlGZ2SaMjfYU7VHr HatQ== 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=/yhDcEEaVochtBC/9ZAKe6I8B/kD29DZ9J6cpsm3p80=; b=AQWuC0FbbgzeZPTsTt80AVvUYeg9qqoHSjm5SxUmilco6PmxOfr+Qpw/I0bbZ9G88o ttUBHRFnxLaWFwixDVstoWMHtPq5dv9f3rqVj5PZgsZfB+ucOho0dYyPM5x0J/iEFdK/ J1xzrqQqfIorwHJtZnaaBDMKQpgcz70AeZ56YKYzAvKOmCK3ibkVAm8bsQaXrrcZnoyp 9t8O7/7GlAXfuh55q1ZSfQeQo8azwfICCMr7yMmub+JS08WVcsPA5d5rpGB83Kkb01tF sbI7OEkNWrPOa5CVEfNHoEkM0NjhKlm3cYjEqZNvYk6cCVMbUrZrwhLtBBooM1PYxu5m 4+fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="W60lwyM/"; 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 n20-20020a17090673d400b0088e899e04f7si2828709ejl.482.2023.02.03.01.26.30; Fri, 03 Feb 2023 01:26:55 -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="W60lwyM/"; 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 S232564AbjBCJRz (ORCPT + 99 others); Fri, 3 Feb 2023 04:17:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbjBCJRS (ORCPT ); Fri, 3 Feb 2023 04:17:18 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A73991CD; Fri, 3 Feb 2023 01:16:57 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d413:5f9c:fc3a:208d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id B621D6602F16; Fri, 3 Feb 2023 09:16:37 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675415798; bh=/fZ2ALvuScrtz8aAPnoLovGKMZcYgk0hx4olwjLRTA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W60lwyM/fIAqN4VdY6txRltfCyqurO225+2II7kNOsqVuiJRpkPUU54d5c7x3AR2j heu3XjIwrYJvny5no8lXojB3AUyDOr8LmDCwwvG0ZTu8BnCABoecEvKLhSMQ/jAxZ1 2Zdl12sHiLUnakZx1r+WBMImQgfTGY90tElVnz9RxN+ZBVVzSMkw0urJe5ATaMCy9j fASrdoiT9JSTV5DVOqcOL78w12l8Lvc/7L3RquN2bdMCyNXIAg2klr18481DepKNy1 2iw9i+vf27LIS6dt7xOGTFoE785HiD+VXsmoyn91R4ZZ9+pUJPX+K7CaLNu073VUSn Tz+O9hbbczv7Q== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v8 6/6] media: verisilicon: VP9: Only propose 10 bits compatible pixels formats Date: Fri, 3 Feb 2023 10:16:22 +0100 Message-Id: <20230203091622.127279-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203091622.127279-1-benjamin.gaignard@collabora.com> References: <20230203091622.127279-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756801442549989749?= X-GMAIL-MSGID: =?utf-8?q?1756801442549989749?= 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. Fixes: dc39473d0340 ("media: hantro: imx8m: Enable 10bit decoding") Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_drv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index fa31b200b097..1c4b90c905ea 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -308,8 +308,14 @@ static int hantro_vp9_s_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_STATELESS_VP9_FRAME: - ctx->bit_depth = ctrl->p_new.p_vp9_frame->bit_depth; - break; + { + 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; }