Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3157819rwj; Mon, 19 Dec 2022 14:03:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXvT1yJsIl+ltxIOgjXsvX/WS2FWD5ZPm/CStjxNk7DzrvLscq8SOroL13SvN12cUGFaSsek X-Received: by 2002:a05:6a20:4b0a:b0:af:726c:2b68 with SMTP id fp10-20020a056a204b0a00b000af726c2b68mr11726222pzb.37.1671487416991; Mon, 19 Dec 2022 14:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671487416; cv=none; d=google.com; s=arc-20160816; b=tWOQQ2yC5lzn8o/XhN80alMQxcgUXKmJwFEUZFsEntM/aDSkonW6pLYRhz9IJ4hJx4 ElEjqwZBMqr95pFhfdJ4i7CSVz7w0k3hVkeVCsXiUxCdqiFurhdenSk9d8UmEPdz8WDY IKjboWVAT/lKVRyeeDRhRGk9HahqWARM4GSoUpkCkg9fnAbw0H6JOVopl+0MfklQV6Et l8y5iigrFEeYqhGGo/CKE1tJSpYElWnkDMWz2Y2JHW7Ug4+L7Xt82QRwM/Mtcsa6OE+V wdLoaz4mL+ePjCnSzWATN+bQHhGrW7fgJXqaPYxL+ZvbWHNhgHnS0hB61DFfKcupjLs8 Yo4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bUcJbVxMOaJY/dHHh8xvsq+/igbf7VEloWZtT9T4IzU=; b=nW+plMS9IHqy1rFpnkqBG5F4y0fhqSXMHWKi8ChRFbm53guAwcyslbkXR0jt4MIKZj eNuhxbEGZe3iA61siGRSBYE0CqdEQoLXITfcHuTWvDoPFM3ZAn4GmO9z6sdvRwibeo42 H1iGOHvyfvv4yzAoJmX8s5jJ7QSJoodH4ogQwkRG5QTqRvs2XuIOeDn8fGJL0fB+/+hu KTAeIUINkLMRPfn+l4a37DKAA9RrQmTEf9rqkmjLbiOqEky/xoKDm7/NgpEFYw2F5vG6 8x0o2d9tNMEPHjZV41YDOB0ASYk2H4ahP3IJ8CQ5K8eU5PX27t7uANhTscesQv21Isbd tv2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=rzxTEULu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 62-20020a630941000000b00476ca041d89si11783266pgj.790.2022.12.19.14.03.25; Mon, 19 Dec 2022 14:03:36 -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=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=rzxTEULu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232781AbiLSV3j (ORCPT + 71 others); Mon, 19 Dec 2022 16:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbiLSV3g (ORCPT ); Mon, 19 Dec 2022 16:29:36 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BF212759 for ; Mon, 19 Dec 2022 13:29:33 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id bf43so15675608lfb.6 for ; Mon, 19 Dec 2022 13:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bUcJbVxMOaJY/dHHh8xvsq+/igbf7VEloWZtT9T4IzU=; b=rzxTEULuNPC0Sk1BptH9+AxtBNYpQ4FvyVS+RZXbKY2D7sBHJ+hvBHwrVH0tDi7Rvz h4OqVfIgl0PXf8Ovl/2qSyZ/KoyDOz9b003uMNhVpm1J9JtBDCAKWeuWE15pPZW2gIIv h2chuLEfXiovnqiNG9l6ZAuMR5mFNmzXxnQB4SVLDVxbGW409nYMSJQ8Jmpb0JuRijyo okvz2kocRJ8wM8Iz2aai0aQ9EMHjWfEAQzNAt/EigCOd9aZW5+sIKW1ofP+jf5VWzLqc ANlZC/28G3mnTqMXI1dTNeDbeSi+5h4yy7kRA41V1CQcQkqDfSx4HNK+10KuUXPbxWgi 7jYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bUcJbVxMOaJY/dHHh8xvsq+/igbf7VEloWZtT9T4IzU=; b=pD+s09RCuNkSojW6wZIu88e3s+1Y8OWZHhtBZcjiuzmC/YAlD/kpp8kyynSChwpNeo iXy3rO9lj+ftIDVYCUh+rG/2RDfxIy/mWhdhwxDdt6JnuQq/Vkyf9ZrEW3ByZgZnZ0hn Yx0YxRvfqoVvcssMw0ak6UBwoCmXY7qJ3+09W6bEvlUCYgu5t51qBrhvy+HE5836ndl7 B4e/7yz6o80mAPfj7LYC0ml2sTT1DGJUR+AUYp1qKUourGbjoHZyxC2PwcT7D2gUi2HL Dkub6MoXmaj/CYhJBUG9evgld9CZhRiPY5KS8nF/eKv7IX4d/hBxu4qhQkJh0roS3ggd jFqg== X-Gm-Message-State: AFqh2kq/DJuM6cdbQqMyKvwUCjv2OtpEpluKI/A65GGGx4Nu0N2cI2bB Lr8erfIVUHL9BcE/ZF44nePd2XtV4cvj+azOIBj8bA== X-Received: by 2002:a05:6512:3f1e:b0:4c8:a047:8833 with SMTP id y30-20020a0565123f1e00b004c8a0478833mr206178lfa.653.1671485371730; Mon, 19 Dec 2022 13:29:31 -0800 (PST) MIME-Version: 1.0 References: <20221219155616.848690-1-benjamin.gaignard@collabora.com> <20221219155616.848690-4-benjamin.gaignard@collabora.com> <07747babe7f83a496f9cd82849c6c2386550ac28.camel@ndufresne.ca> In-Reply-To: <07747babe7f83a496f9cd82849c6c2386550ac28.camel@ndufresne.ca> From: Ezequiel Garcia Date: Mon, 19 Dec 2022 18:29:20 -0300 Message-ID: Subject: Re: [PATCH v1 3/9] media: verisilicon: Save bit depth for AV1 decoder To: Nicolas Dufresne Cc: Benjamin Gaignard , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 Bonjour Nicolas, On Mon, Dec 19, 2022 at 5:37 PM Nicolas Dufresne wro= te: > > Le lundi 19 d=C3=A9cembre 2022 =C3=A0 16:56 +0100, Benjamin Gaignard a = =C3=A9crit : > > Store bit depth information from AV1 sequence control. > > > > Signed-off-by: Benjamin Gaignard > > --- > > .../media/platform/verisilicon/hantro_drv.c | 26 +++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/= media/platform/verisilicon/hantro_drv.c > > index 4500e1fc0f2c..8e93710dcfed 100644 > > --- a/drivers/media/platform/verisilicon/hantro_drv.c > > +++ b/drivers/media/platform/verisilicon/hantro_drv.c > > @@ -324,6 +324,25 @@ static int hantro_vp9_s_ctrl(struct v4l2_ctrl *ctr= l) > > return 0; > > } > > > > +static int hantro_av1_s_ctrl(struct v4l2_ctrl *ctrl) > > +{ > > + struct hantro_ctx *ctx; > > + > > + ctx =3D container_of(ctrl->handler, > > + struct hantro_ctx, ctrl_handler); > > + > > + switch (ctrl->id) { > > + case V4L2_CID_STATELESS_AV1_SEQUENCE: > > + ctx->bit_depth =3D ctrl->p_new.p_av1_sequence->bit_depth; > > That seems a little be weak, what happens if you change the bit_depth wit= h a > non-request s_ctrl while its decoding ? To be this deserve a little bit o= f > protection, a something that validate and copy it at the start of the dec= oding. > Oh, nice catch. We need to return EBUSY, see https://www.kernel.org/doc/html/v5.0/media/uapi/v4l/buffer.html#interaction= s-between-formats-controls-and-buffers. There's already an API in the V4L2 control framework for drivers to use, see v4l2_ctrl_grab in https://www.kernel.org/doc/html/v5.0/media/kapi/v4l2-controls.html#active-a= nd-grabbed-controls. > p.s. I know, VP9 seems similar, though arguably that was copied from jpeg= , for > which it seems totally save to change the quality at run-time. > No, wasn't copied from JPEG :-) I just didn't realize this was an issue, but it is given the bit_depth affects the buffers so you are correct, it needs to be fixed for VP9 too. Thanks! Ezequiel > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + return 0; > > +} > > + > > + > > static const struct v4l2_ctrl_ops hantro_ctrl_ops =3D { > > .try_ctrl =3D hantro_try_ctrl, > > }; > > @@ -336,6 +355,12 @@ static const struct v4l2_ctrl_ops hantro_vp9_ctrl_= ops =3D { > > .s_ctrl =3D hantro_vp9_s_ctrl, > > }; > > > > +static const struct v4l2_ctrl_ops hantro_av1_ctrl_ops =3D { > > + .try_ctrl =3D hantro_try_ctrl, > > + .s_ctrl =3D hantro_av1_s_ctrl, > > +}; > > + > > + > > #define HANTRO_JPEG_ACTIVE_MARKERS (V4L2_JPEG_ACTIVE_MARKER_APP0 | \ > > V4L2_JPEG_ACTIVE_MARKER_COM | \ > > V4L2_JPEG_ACTIVE_MARKER_DQT | \ > > @@ -513,6 +538,7 @@ static const struct hantro_ctrl controls[] =3D { > > .codec =3D HANTRO_AV1_DECODER, > > .cfg =3D { > > .id =3D V4L2_CID_STATELESS_AV1_SEQUENCE, > > + .ops =3D &hantro_av1_ctrl_ops, > > }, > > }, { > > .codec =3D HANTRO_AV1_DECODER, >