media: verisilicon: HEVC: Only propose 10 bits compatible pixels formats
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Mon, 20 Feb 2023 10:48:48 +0000 (10:48 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 10 Apr 2023 13:18:57 +0000 (14:18 +0100)
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.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/verisilicon/hantro_drv.c
drivers/media/platform/verisilicon/imx8m_vpu_hw.c

index c237253803f4273bb0570739000b780be6ec4283..7d452f1afaaea4d9f10bc675ad661e1b513cb08b 100644 (file)
@@ -325,9 +325,15 @@ static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl)
                           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;
+       case V4L2_CID_STATELESS_HEVC_SPS: {
+               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;
        }
index b390228fd3b4afb0666798c3cbf705897c74e122..f850d8bddef6bc5426e96aa49803f7de37f83908 100644 (file)
@@ -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,