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,