Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5919639rwl; Mon, 9 Jan 2023 01:28:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXswbo078rY7sank/+vaYn7wU91+NGpKwJpbw/D/b+vgWna5+qntooYtx8sxw9D+OdTwjxHH X-Received: by 2002:a17:907:6e16:b0:7e0:eed0:8beb with SMTP id sd22-20020a1709076e1600b007e0eed08bebmr75156675ejc.41.1673256517387; Mon, 09 Jan 2023 01:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673256517; cv=none; d=google.com; s=arc-20160816; b=FNUjzprPGRTf1ngV0GyEcBxh8OY6D7/I3qhU2UwnLcLNuremvCDvC9DNumrgwFLo7z CgJiDiJpF0jziIZLBYI3vVBvMa+2NHkoyq8OAAY0Kz4CDggS7GewWXHDY88q1PPgu+vd oYelkiE3a7+xho2tGLskEgGYTMXuwwSVAWQwweYlwF3x9II1ZJp2LsqceSFFRcJKJZsZ kfrVIeWnE1dhjMCsmhloaqxvU8JlWrxEQUT3fuI8ovwD9jX5cDhzYLRFQmxba8d8/IUp 6Vi6ukkqH0HT3B/3Xo58qvyIbWp6GHSh/X4nLaEbmNkEShXS0RpDlyj1aV1sA6jYqZDg QBJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=APJg8SoGIYYqT6O/lrsAgXZJ8myLa4E+HYqW3yrKidQ=; b=l00PMgCcEom2JxYoPAAqQTEUP++o8buNb/grCsioXhsIT85u6zPnkpnZMtNcFV1kTO +dcUmQB+vEmlw12PRTKGZmuZrlTkHlWnqP/Iqy3S8B6OL2lTsm8jhb4rHiL1tnjbEGHM 2qtDPqgKBP1cefASP0dYgWCX6p3iB08ip3rnVDJ4HvWc2tz6kCIhEYNeS9CFQY1+HfCR wddLkeOMzYJdXDzCkQeuA1L/QnLc0tgWGL5xpLaJxKnA7aYSZUhJnb7bfsLUyLQF3utA aoVUAgSu3PoDgyeko52KU1ScTK2Nwft+1vnjJyW5ezdeXvkndIVk4omGgCsWmUZnYi31 qNtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kN0y67jM; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt2-20020a170906ee8200b0084c45d8a688si9539840ejb.891.2023.01.09.01.28.23; Mon, 09 Jan 2023 01:28:37 -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=kN0y67jM; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236909AbjAIJL0 (ORCPT + 54 others); Mon, 9 Jan 2023 04:11:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236618AbjAIJKK (ORCPT ); Mon, 9 Jan 2023 04:10:10 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC7D216584; Mon, 9 Jan 2023 01:05:23 -0800 (PST) Received: from [IPV6:2a01:e0a:120:3210:ad7f:4e82:9389:686f] (unknown [IPv6:2a01:e0a:120:3210:ad7f:4e82:9389:686f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 DBE1E6601F10; Mon, 9 Jan 2023 09:05:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1673255122; bh=tRpKJLAiABOhpP2YUjpXF1Z+WYFDa3TbM92QViIdx+0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=kN0y67jMkHwsCGjUaBqn+id3yzmig1x92FvKi1Nge9aiEAel3a2j0NT4uQWJZb2Et oJVGqlXjB3ejkOkLS3gmIL7J3bNIHy4qT8pM6XfvU2qdsKEBAyHA7mAFeUpgB6HIJh +tOVSUZ7xeAx66b0QYHlooEGbji65ssLSh6vyIYVnxO5rH92dA9Q3kXMZ8LdnXCl9V 7WHbi6dPs/4/wIEUJTkUJ9xYKwX3y4poAVbgeYo61rBIXqahrN3LIV1gz7JXnZrgNZ 9sbxA/2SWFoEc6P+ob8mNBc8eDuO6pOaMnqgix7EFOEmOGuABZIZVz2Gmlqvck00u8 qHQFRoeyJxEqQ== Message-ID: <852e5269-cb3d-bd56-c7fd-0a1f461623de@collabora.com> Date: Mon, 9 Jan 2023 10:05:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 13/13] media: verisilicon: Conditionnaly ignore native formats To: Ezequiel Garcia Cc: p.zabel@pengutronix.de, mchehab@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, daniel.almeida@collabora.com, nicolas.dufresne@collabora.co.uk, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com References: <20230103170058.810597-1-benjamin.gaignard@collabora.com> <20230103170058.810597-14-benjamin.gaignard@collabora.com> Content-Language: en-US From: Benjamin Gaignard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 Le 08/01/2023 à 22:12, Ezequiel Garcia a écrit : > On Tue, Jan 3, 2023 at 2:01 PM Benjamin Gaignard > wrote: >> AV1 film grain feature requires to use the postprocessor to produce >> valid frames. In such case the driver shouldn't propose native pixels >> format but only post-processed pixels format. >> If a codec set need_postproc field in hantro_ctx structure to true >> native pixel formats will be ignored. >> >> Signed-off-by: Benjamin Gaignard >> --- >> drivers/media/platform/verisilicon/hantro.h | 3 ++ >> .../media/platform/verisilicon/hantro_drv.c | 5 ++ >> .../platform/verisilicon/hantro_postproc.c | 4 ++ >> .../media/platform/verisilicon/hantro_v4l2.c | 46 +++++++++++++------ >> 4 files changed, 45 insertions(+), 13 deletions(-) >> >> diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h >> index a98cb40a8d3b..7a5357e810fb 100644 >> --- a/drivers/media/platform/verisilicon/hantro.h >> +++ b/drivers/media/platform/verisilicon/hantro.h >> @@ -231,6 +231,8 @@ struct hantro_dev { >> * @ctrl_handler: Control handler used to register controls. >> * @jpeg_quality: User-specified JPEG compression quality. >> * @bit_depth: Bit depth of current frame >> + * @need_postproc: Set to true if the bitstream features require to >> + * use the post-processor. >> * >> * @codec_ops: Set of operations related to codec mode. >> * @postproc: Post-processing context. >> @@ -258,6 +260,7 @@ struct hantro_ctx { >> struct v4l2_ctrl_handler ctrl_handler; >> int jpeg_quality; >> int bit_depth; >> + bool need_postproc; >> >> const struct hantro_codec_ops *codec_ops; >> struct hantro_postproc_ctx postproc; >> diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c >> index 4fc6dea16ae6..8d7055c0bf3b 100644 >> --- a/drivers/media/platform/verisilicon/hantro_drv.c >> +++ b/drivers/media/platform/verisilicon/hantro_drv.c >> @@ -346,6 +346,11 @@ static int hantro_av1_s_ctrl(struct v4l2_ctrl *ctrl) >> return -EINVAL; >> >> ctx->bit_depth = bit_depth; >> + >> + if (ctrl->p_new.p_av1_sequence->flags >> + & V4L2_AV1_SEQUENCE_FLAG_FILM_GRAIN_PARAMS_PRESENT) >> + ctx->need_postproc = true; >> + >> break; >> default: >> return -EINVAL; >> diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c >> index 7dc39519a2ee..293e5612e2ce 100644 >> --- a/drivers/media/platform/verisilicon/hantro_postproc.c >> +++ b/drivers/media/platform/verisilicon/hantro_postproc.c >> @@ -57,6 +57,10 @@ bool hantro_needs_postproc(const struct hantro_ctx *ctx, >> { >> if (ctx->is_encoder) >> return false; >> + >> + if (ctx->need_postproc) >> + return true; >> + >> return fmt->postprocessed; >> } >> >> diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c >> index bbe79dbd2cd9..5c381766cca3 100644 >> --- a/drivers/media/platform/verisilicon/hantro_v4l2.c >> +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c >> @@ -38,6 +38,11 @@ hantro_get_formats(const struct hantro_ctx *ctx, unsigned int *num_fmts) >> { >> const struct hantro_fmt *formats; >> >> + if (ctx->need_postproc) { >> + *num_fmts = 0; >> + return NULL; >> + } >> + >> if (ctx->is_encoder) { >> formats = ctx->dev->variant->enc_fmts; >> *num_fmts = ctx->dev->variant->num_enc_fmts; >> @@ -132,6 +137,15 @@ hantro_get_default_fmt(const struct hantro_ctx *ctx, bool bitstream) >> hantro_check_depth_match(ctx, &formats[i])) >> return &formats[i]; >> } >> + >> + formats = hantro_get_postproc_formats(ctx, &num_fmts); >> + for (i = 0; i < num_fmts; i++) { >> + if (bitstream == (formats[i].codec_mode != >> + HANTRO_MODE_NONE) && >> + hantro_check_depth_match(ctx, &formats[i])) >> + return &formats[i]; >> + } >> + >> return NULL; >> } >> >> @@ -261,19 +275,6 @@ static int vidioc_g_fmt_out_mplane(struct file *file, void *priv, >> return 0; >> } >> >> -static int vidioc_g_fmt_cap_mplane(struct file *file, void *priv, >> - struct v4l2_format *f) >> -{ >> - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; >> - struct hantro_ctx *ctx = fh_to_ctx(priv); >> - >> - vpu_debug(4, "f->type = %d\n", f->type); >> - >> - *pix_mp = ctx->dst_fmt; >> - >> - return 0; >> -} >> - >> static int hantro_try_fmt(const struct hantro_ctx *ctx, >> struct v4l2_pix_format_mplane *pix_mp, >> enum v4l2_buf_type type) >> @@ -353,6 +354,25 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, >> return 0; >> } >> >> +static int vidioc_g_fmt_cap_mplane(struct file *file, void *priv, >> + struct v4l2_format *f) >> +{ >> + struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; >> + struct hantro_ctx *ctx = fh_to_ctx(priv); >> + int ret; >> + >> + vpu_debug(4, "f->type = %d\n", f->type); >> + >> + ret = hantro_try_fmt(ctx, pix_mp, f->type); >> + if (ret) >> + return ret; >> + >> + ctx->vpu_dst_fmt = hantro_find_format(ctx, pix_mp->pixelformat); >> + ctx->dst_fmt = *pix_mp; >> + > This looks like the g_fmt is setting some state in the context, > this looks incorrect. Indeed only a call to hantro_try_fmt() is needed here. I will fix that in v3. Benjamin > > Thanks, > Ezequiel