From patchwork Mon Feb 20 10:48:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1239464wrn; Mon, 20 Feb 2023 02:52:19 -0800 (PST) X-Google-Smtp-Source: AK7set8InWLBqDDuLFHWXE/+hfK0cdsTm3Z1Kl+P4rreQxozS4g6Xw8zKDVCEBSepJmy1PfYGalG X-Received: by 2002:a17:902:f983:b0:19b:76fb:c6f with SMTP id ky3-20020a170902f98300b0019b76fb0c6fmr1331566plb.68.1676890338749; Mon, 20 Feb 2023 02:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676890338; cv=none; d=google.com; s=arc-20160816; b=k4hfWybh4FPPrd2MrypkwdNK4gRJA+MURi93zw//kJXBb1tNL2F08833tpl+6tOnO2 o6yf0yUWzidNVgwvDDh/dAhnhqfQ5V6VKLwBRf0+c/63IAigC7DYAKKNhfUz9dIF2bUz tbppb0u29rxPVm/0mD0iDh1NqIZ77B4dU0UcNznxuoX4/mmwN92YHIG4pdFrtkgUkD+Y 66stcN1TBgm4wfZyWx972KYTY3DJi+RWwW6PeXF8lw1dvLj4sXHZbvIJ6GAdju91hzln 8F1weXck2nl9KYNu2XUcSNuVZZAFEQUxd7LNIAki0OVx/igpXCD7wbYsVAzho2UZPZnY vbXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iw2sAiwTWkkXP2xcbTGi/L2eUKFmjnlsbsN2iOF/8pA=; b=gV1EmLvhMjB+jETig89S8A0TOHxVtHSRnbYTBEbwD8WzBGRNQBfEOErxWvjfVFrBl+ sfVVocmhO6e6T2EDKvY0d7GtghVBF9GH/FqeJSyfNkpF7ahBNIJDnAJXLVX+xTVitsoy A9QEbPbf/utkaJnrnc0Fu43bllwqc6mxUy/d7yGlhrYcNLY5F3f4DqmF8CYw6LGn/GmJ Z8JO54zChlVySf7+ScIw5OTryNxzKowJiu/lbZOJ49b+RQEV1/rgZc/P9kKd0o9qUOmG CNewOoIoRWicZwHjz8PYNAGprIdo5RioGYSjgsUvb4FLvr87bUSBOkdKgNVN9R29bcQE B8xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RTS9a73w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170902ebd200b0019a9f8bdb8csi2668313plg.209.2023.02.20.02.52.06; Mon, 20 Feb 2023 02:52:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RTS9a73w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjBTKtK (ORCPT + 99 others); Mon, 20 Feb 2023 05:49:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231665AbjBTKtB (ORCPT ); Mon, 20 Feb 2023 05:49:01 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60BE3BB84; Mon, 20 Feb 2023 02:49:00 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:d30c:b155:96fb:dcc]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id B1E046602165; Mon, 20 Feb 2023 10:48:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676890139; bh=Qylc8lXBZUribdIoDlAmLesNbqqMKmI6fMRr3vIkG8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RTS9a73wcPX9uhMzv6NCAE206e9RJ/YFkz5NBcy2CCC36Lf3d9YYmafphVugIkBsU zuPq1m2nx4sHw9IGMwPoAerygmBjVzzZXzOOfbMf01BFAHRcg2tOs12DzfBTz6XuRM wtP94UOj9U1zrqsEsChXB3a0UJsL8DOK4faVjr7VtTh1yhe5XB3vIs7Niv5cCZHP9A kdHCKxeqZbS/KeLx1OWsD47xDniYkyojHRkuLnROtqqE3OlJzLGp3dtFOgWu0+gRPa CwL31tTSltEwAd0zf9edW4FR314xL+LhJ9vXCHqB9c8aGOzqOHnztWisNDqfRAFlUH rdJE7Wdi+VqRg== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.co.uk, robert.mader@collabora.com Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v9 3/6] media: verisilicon: Do not set ctx->bit_depth in hantro_try_ctrl() Date: Mon, 20 Feb 2023 11:48:46 +0100 Message-Id: <20230220104849.398203-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220104849.398203-1-benjamin.gaignard@collabora.com> References: <20230220104849.398203-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758346963843839640?= X-GMAIL-MSGID: =?utf-8?q?1758346963843839640?= In hantro_try_ctrl() we should only check the values inside control parameters and not set ctx->bit_depth. That must be done in controls set function. Create a set control function for hevc where ctx->bit_depth is set at the right time. Signed-off-by: Benjamin Gaignard Reviewed-by: Ezequiel Garcia --- .../media/platform/verisilicon/hantro_drv.c | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index b0aeedae7b65..c237253803f4 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -251,11 +251,6 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) { - struct hantro_ctx *ctx; - - ctx = container_of(ctrl->handler, - struct hantro_ctx, ctrl_handler); - if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; @@ -274,8 +269,6 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2) /* Only 8-bit and 10-bit are supported */ return -EINVAL; - - ctx->bit_depth = sps->bit_depth_luma_minus8 + 8; } else if (ctrl->id == V4L2_CID_STATELESS_VP9_FRAME) { const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame; @@ -324,6 +317,24 @@ static int hantro_vp9_s_ctrl(struct v4l2_ctrl *ctrl) return 0; } +static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct hantro_ctx *ctx; + + ctx = container_of(ctrl->handler, + struct hantro_ctx, ctrl_handler); + + switch (ctrl->id) { + case V4L2_CID_STATELESS_HEVC_SPS: + ctx->bit_depth = ctrl->p_new.p_hevc_sps->bit_depth_luma_minus8 + 8; + break; + default: + return -EINVAL; + } + + return 0; +} + static const struct v4l2_ctrl_ops hantro_ctrl_ops = { .try_ctrl = hantro_try_ctrl, }; @@ -336,6 +347,11 @@ static const struct v4l2_ctrl_ops hantro_vp9_ctrl_ops = { .s_ctrl = hantro_vp9_s_ctrl, }; +static const struct v4l2_ctrl_ops hantro_hevc_ctrl_ops = { + .try_ctrl = hantro_try_ctrl, + .s_ctrl = hantro_hevc_s_ctrl, +}; + #define HANTRO_JPEG_ACTIVE_MARKERS (V4L2_JPEG_ACTIVE_MARKER_APP0 | \ V4L2_JPEG_ACTIVE_MARKER_COM | \ V4L2_JPEG_ACTIVE_MARKER_DQT | \ @@ -470,7 +486,7 @@ static const struct hantro_ctrl controls[] = { .codec = HANTRO_HEVC_DECODER, .cfg = { .id = V4L2_CID_STATELESS_HEVC_SPS, - .ops = &hantro_ctrl_ops, + .ops = &hantro_hevc_ctrl_ops, }, }, { .codec = HANTRO_HEVC_DECODER,