linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec
@ 2022-06-17 11:57 Benjamin Gaignard
  2022-06-17 11:57 ` [PATCH 1/7] media: hantro: Store HEVC bit depth in context Benjamin Gaignard
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:57 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

This series is based on top of Jernej series: "media: hantro: Add 10-bit
support" v2.
Jernej series is focusing on VP9 and hardware block with legacy regs.
This one add 10bits support for newer hardware blocks (i.e without
legacy regs) and for HEVC codec.

It based tested on IMX8MQ with HEVC conformance tests.
The results are that all 10bits bitstreams are OK.

Benjamin Gaignard (7):
  media: hantro: Store HEVC bit depth in context
  media: hantro: HEVC: Fix auxilary buffer size calculation
  media: hantro: HEVC: Fix chroma offset computation
  media: hantro: postproc: Configure output regs to support 10bit
  media: Hantro: HEVC: Allows 10-bit bitstream
  media: hantro: imx8m: Enable 10bit decoding
  media: hantro: Allows luma and chroma depth to be different

 .../staging/media/hantro/hantro_g2_hevc_dec.c |  4 +--
 drivers/staging/media/hantro/hantro_hevc.c    | 13 +++++----
 .../staging/media/hantro/hantro_postproc.c    |  7 ++++-
 drivers/staging/media/hantro/imx8m_vpu_hw.c   | 27 +++++++++++++++++++
 4 files changed, 40 insertions(+), 11 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/7] media: hantro: Store HEVC bit depth in context
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
@ 2022-06-17 11:57 ` Benjamin Gaignard
  2022-06-30 17:30   ` Ezequiel Garcia
  2022-06-17 11:57 ` [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation Benjamin Gaignard
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:57 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

Store HEVC bit depth in context.
Bit depth is equal to hevc sps bit_depth_luma_minus8 + 8.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_hevc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
index 5984c5fa6f83..dcb5c8703b6e 100644
--- a/drivers/staging/media/hantro/hantro_hevc.c
+++ b/drivers/staging/media/hantro/hantro_hevc.c
@@ -163,6 +163,8 @@ int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc
 		/* Only 8-bit is supported */
 		return -EINVAL;
 
+	ctx->bit_depth = sps->bit_depth_luma_minus8 + 8;
+
 	/*
 	 * for tile pixel format check if the width and height match
 	 * hardware constraints
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
  2022-06-17 11:57 ` [PATCH 1/7] media: hantro: Store HEVC bit depth in context Benjamin Gaignard
@ 2022-06-17 11:57 ` Benjamin Gaignard
  2022-06-30 17:33   ` Ezequiel Garcia
  2022-06-17 11:57 ` [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation Benjamin Gaignard
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:57 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

SAO and FILTER buffers size depend of the bit depth.
Make sure we have enough space for 10bit bitstreams.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_hevc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
index dcb5c8703b6e..e06837108a09 100644
--- a/drivers/staging/media/hantro/hantro_hevc.c
+++ b/drivers/staging/media/hantro/hantro_hevc.c
@@ -104,7 +104,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
 		hevc_dec->tile_bsd.cpu = NULL;
 	}
 
-	size = VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1);
+	size = (VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
 	hevc_dec->tile_filter.cpu = dma_alloc_coherent(vpu->dev, size,
 						       &hevc_dec->tile_filter.dma,
 						       GFP_KERNEL);
@@ -112,7 +112,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
 		goto err_free_tile_buffers;
 	hevc_dec->tile_filter.size = size;
 
-	size = VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1);
+	size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
 	hevc_dec->tile_sao.cpu = dma_alloc_coherent(vpu->dev, size,
 						    &hevc_dec->tile_sao.dma,
 						    GFP_KERNEL);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
  2022-06-17 11:57 ` [PATCH 1/7] media: hantro: Store HEVC bit depth in context Benjamin Gaignard
  2022-06-17 11:57 ` [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation Benjamin Gaignard
@ 2022-06-17 11:57 ` Benjamin Gaignard
  2022-06-30 17:34   ` Ezequiel Garcia
  2022-07-01  8:47   ` Paul Kocialkowski
  2022-06-17 11:57 ` [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit Benjamin Gaignard
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:57 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

The chroma offset depends of the bitstream depth.
Make sure that ctx->bit_depth is used to compute it.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
index 9eac133bda68..8407ad45b7b7 100644
--- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
+++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
@@ -12,7 +12,7 @@
 
 static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx)
 {
-	return ctx->dst_fmt.width * ctx->dst_fmt.height;
+	return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8;
 }
 
 static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
                   ` (2 preceding siblings ...)
  2022-06-17 11:57 ` [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation Benjamin Gaignard
@ 2022-06-17 11:57 ` Benjamin Gaignard
  2022-06-30 17:35   ` Ezequiel Garcia
  2022-06-17 11:58 ` [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream Benjamin Gaignard
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:57 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

Move output format setting in postproc and make sure that
8/10bit configuration is correctly set.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 --
 drivers/staging/media/hantro/hantro_postproc.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
index 8407ad45b7b7..c929f2974a01 100644
--- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
+++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
@@ -167,8 +167,6 @@ static void set_params(struct hantro_ctx *ctx)
 	hantro_reg_write(vpu, &g2_bit_depth_y_minus8, sps->bit_depth_luma_minus8);
 	hantro_reg_write(vpu, &g2_bit_depth_c_minus8, sps->bit_depth_chroma_minus8);
 
-	hantro_reg_write(vpu, &g2_output_8_bits, 0);
-
 	hantro_reg_write(vpu, &g2_hdr_skip_length, compute_header_skip_lenght(ctx));
 
 	min_log2_cb_size = sps->log2_min_luma_coding_block_size_minus3 + 3;
diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c
index a0928c508434..09d8cf942689 100644
--- a/drivers/staging/media/hantro/hantro_postproc.c
+++ b/drivers/staging/media/hantro/hantro_postproc.c
@@ -114,6 +114,7 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
 	struct hantro_dev *vpu = ctx->dev;
 	struct vb2_v4l2_buffer *dst_buf;
 	int down_scale = down_scale_factor(ctx);
+	int out_depth;
 	size_t chroma_offset;
 	dma_addr_t dst_dma;
 
@@ -132,8 +133,9 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
 		hantro_write_addr(vpu, G2_RS_OUT_LUMA_ADDR, dst_dma);
 		hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma + chroma_offset);
 	}
+
+	out_depth = hantro_get_format_depth(ctx->dst_fmt.pixelformat);
 	if (ctx->dev->variant->legacy_regs) {
-		int out_depth = hantro_get_format_depth(ctx->dst_fmt.pixelformat);
 		u8 pp_shift = 0;
 
 		if (out_depth > 8)
@@ -141,6 +143,9 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
 
 		hantro_reg_write(ctx->dev, &g2_rs_out_bit_depth, out_depth);
 		hantro_reg_write(ctx->dev, &g2_pp_pix_shift, pp_shift);
+	} else {
+		hantro_reg_write(vpu, &g2_output_8_bits, out_depth > 8 ? 0 : 1);
+		hantro_reg_write(vpu, &g2_output_format, out_depth > 8 ? 1 : 0);
 	}
 	hantro_reg_write(vpu, &g2_out_rs_e, 1);
 }
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
                   ` (3 preceding siblings ...)
  2022-06-17 11:57 ` [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit Benjamin Gaignard
@ 2022-06-17 11:58 ` Benjamin Gaignard
  2022-06-30 17:38   ` Ezequiel Garcia
  2022-06-17 11:58 ` [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding Benjamin Gaignard
  2022-06-17 11:58 ` [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different Benjamin Gaignard
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:58 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

Stop limiting HEVC support to 8-bits bitstreams also
accept 10-bits bitstreams.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_hevc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
index e06837108a09..85688a4df166 100644
--- a/drivers/staging/media/hantro/hantro_hevc.c
+++ b/drivers/staging/media/hantro/hantro_hevc.c
@@ -159,8 +159,8 @@ int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc
 	if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
 		/* Luma and chroma bit depth mismatch */
 		return -EINVAL;
-	if (sps->bit_depth_luma_minus8 != 0)
-		/* Only 8-bit is supported */
+	if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
+		/* Only 8-bit and 10-bit is supported */
 		return -EINVAL;
 
 	ctx->bit_depth = sps->bit_depth_luma_minus8 + 8;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
                   ` (4 preceding siblings ...)
  2022-06-17 11:58 ` [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream Benjamin Gaignard
@ 2022-06-17 11:58 ` Benjamin Gaignard
  2022-06-30 17:40   ` Ezequiel Garcia
  2022-06-17 11:58 ` [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different Benjamin Gaignard
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:58 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

Expose 10bit pixel formats to enable 10bit decoding in IMX8M SoCs.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/imx8m_vpu_hw.c | 27 +++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/staging/media/hantro/imx8m_vpu_hw.c b/drivers/staging/media/hantro/imx8m_vpu_hw.c
index 77f574fdfa77..b390228fd3b4 100644
--- a/drivers/staging/media/hantro/imx8m_vpu_hw.c
+++ b/drivers/staging/media/hantro/imx8m_vpu_hw.c
@@ -162,12 +162,39 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = {
 			.step_height = MB_DIM,
 		},
 	},
+	{
+		.fourcc = V4L2_PIX_FMT_P010,
+		.codec_mode = HANTRO_MODE_NONE,
+		.postprocessed = true,
+		.frmsize = {
+			.min_width = FMT_MIN_WIDTH,
+			.max_width = FMT_UHD_WIDTH,
+			.step_width = MB_DIM,
+			.min_height = FMT_MIN_HEIGHT,
+			.max_height = FMT_UHD_HEIGHT,
+			.step_height = MB_DIM,
+		},
+	},
 };
 
 static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = {
 	{
 		.fourcc = V4L2_PIX_FMT_NV12_4L4,
 		.codec_mode = HANTRO_MODE_NONE,
+		.match_depth = true,
+		.frmsize = {
+			.min_width = FMT_MIN_WIDTH,
+			.max_width = FMT_UHD_WIDTH,
+			.step_width = TILE_MB_DIM,
+			.min_height = FMT_MIN_HEIGHT,
+			.max_height = FMT_UHD_HEIGHT,
+			.step_height = TILE_MB_DIM,
+		},
+	},
+	{
+		.fourcc = V4L2_PIX_FMT_P010_4L4,
+		.codec_mode = HANTRO_MODE_NONE,
+		.match_depth = true,
 		.frmsize = {
 			.min_width = FMT_MIN_WIDTH,
 			.max_width = FMT_UHD_WIDTH,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different
  2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
                   ` (5 preceding siblings ...)
  2022-06-17 11:58 ` [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding Benjamin Gaignard
@ 2022-06-17 11:58 ` Benjamin Gaignard
  2022-06-30 17:40   ` Ezequiel Garcia
  6 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-06-17 11:58 UTC (permalink / raw)
  To: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard,
	paul.kocialkowski, wens, jernej.skrabec, samuel,
	nicolas.dufresne, andrzej.p
  Cc: linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel, Benjamin Gaignard

Luma and chroma depth are set on different hardware registers.
Even if they aren't identical the bitstream can be compliant
to HEVC specifications and decoded by the hardware.

With this patch TSUNEQBD_A_MAIN10_Technicolor_2 conformance test
is successfully decoded.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/staging/media/hantro/hantro_hevc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
index 85688a4df166..26b1329893f7 100644
--- a/drivers/staging/media/hantro/hantro_hevc.c
+++ b/drivers/staging/media/hantro/hantro_hevc.c
@@ -156,9 +156,6 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
 
 int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc_sps *sps)
 {
-	if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
-		/* Luma and chroma bit depth mismatch */
-		return -EINVAL;
 	if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
 		/* Only 8-bit and 10-bit is supported */
 		return -EINVAL;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/7] media: hantro: Store HEVC bit depth in context
  2022-06-17 11:57 ` [PATCH 1/7] media: hantro: Store HEVC bit depth in context Benjamin Gaignard
@ 2022-06-30 17:30   ` Ezequiel Garcia
  0 siblings, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:30 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

Thanks for the patch.

On Fri, Jun 17, 2022 at 01:57:56PM +0200, Benjamin Gaignard wrote:
> Store HEVC bit depth in context.
> Bit depth is equal to hevc sps bit_depth_luma_minus8 + 8.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
>  drivers/staging/media/hantro/hantro_hevc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
> index 5984c5fa6f83..dcb5c8703b6e 100644
> --- a/drivers/staging/media/hantro/hantro_hevc.c
> +++ b/drivers/staging/media/hantro/hantro_hevc.c
> @@ -163,6 +163,8 @@ int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc
>  		/* Only 8-bit is supported */
>  		return -EINVAL;
>  
> +	ctx->bit_depth = sps->bit_depth_luma_minus8 + 8;
> +

This should set in hantro_hevc_s_ctrl.

Thanks!
Ezequiel

>  	/*
>  	 * for tile pixel format check if the width and height match
>  	 * hardware constraints
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation
  2022-06-17 11:57 ` [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation Benjamin Gaignard
@ 2022-06-30 17:33   ` Ezequiel Garcia
  0 siblings, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:33 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

On Fri, Jun 17, 2022 at 01:57:57PM +0200, Benjamin Gaignard wrote:
> SAO and FILTER buffers size depend of the bit depth.
> Make sure we have enough space for 10bit bitstreams.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Thanks,
Ezequiel

> ---
>  drivers/staging/media/hantro/hantro_hevc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
> index dcb5c8703b6e..e06837108a09 100644
> --- a/drivers/staging/media/hantro/hantro_hevc.c
> +++ b/drivers/staging/media/hantro/hantro_hevc.c
> @@ -104,7 +104,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
>  		hevc_dec->tile_bsd.cpu = NULL;
>  	}
>  
> -	size = VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1);
> +	size = (VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
>  	hevc_dec->tile_filter.cpu = dma_alloc_coherent(vpu->dev, size,
>  						       &hevc_dec->tile_filter.dma,
>  						       GFP_KERNEL);
> @@ -112,7 +112,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
>  		goto err_free_tile_buffers;
>  	hevc_dec->tile_filter.size = size;
>  
> -	size = VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1);
> +	size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
>  	hevc_dec->tile_sao.cpu = dma_alloc_coherent(vpu->dev, size,
>  						    &hevc_dec->tile_sao.dma,
>  						    GFP_KERNEL);
> -- 
> 2.32.0

> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation
  2022-06-17 11:57 ` [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation Benjamin Gaignard
@ 2022-06-30 17:34   ` Ezequiel Garcia
  2022-07-01  8:47   ` Paul Kocialkowski
  1 sibling, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:34 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

On Fri, Jun 17, 2022 at 01:57:58PM +0200, Benjamin Gaignard wrote:
> The chroma offset depends of the bitstream depth.
> Make sure that ctx->bit_depth is used to compute it.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Thanks,
Ezequiel

> ---
>  drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> index 9eac133bda68..8407ad45b7b7 100644
> --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> @@ -12,7 +12,7 @@
>  
>  static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx)
>  {
> -	return ctx->dst_fmt.width * ctx->dst_fmt.height;
> +	return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8;
>  }
>  
>  static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx)
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit
  2022-06-17 11:57 ` [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit Benjamin Gaignard
@ 2022-06-30 17:35   ` Ezequiel Garcia
  0 siblings, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:35 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

On Fri, Jun 17, 2022 at 01:57:59PM +0200, Benjamin Gaignard wrote:
> Move output format setting in postproc and make sure that
> 8/10bit configuration is correctly set.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Thanks,
Ezequiel

> ---
>  drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 --
>  drivers/staging/media/hantro/hantro_postproc.c    | 7 ++++++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> index 8407ad45b7b7..c929f2974a01 100644
> --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> @@ -167,8 +167,6 @@ static void set_params(struct hantro_ctx *ctx)
>  	hantro_reg_write(vpu, &g2_bit_depth_y_minus8, sps->bit_depth_luma_minus8);
>  	hantro_reg_write(vpu, &g2_bit_depth_c_minus8, sps->bit_depth_chroma_minus8);
>  
> -	hantro_reg_write(vpu, &g2_output_8_bits, 0);
> -
>  	hantro_reg_write(vpu, &g2_hdr_skip_length, compute_header_skip_lenght(ctx));
>  
>  	min_log2_cb_size = sps->log2_min_luma_coding_block_size_minus3 + 3;
> diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c
> index a0928c508434..09d8cf942689 100644
> --- a/drivers/staging/media/hantro/hantro_postproc.c
> +++ b/drivers/staging/media/hantro/hantro_postproc.c
> @@ -114,6 +114,7 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
>  	struct hantro_dev *vpu = ctx->dev;
>  	struct vb2_v4l2_buffer *dst_buf;
>  	int down_scale = down_scale_factor(ctx);
> +	int out_depth;
>  	size_t chroma_offset;
>  	dma_addr_t dst_dma;
>  
> @@ -132,8 +133,9 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
>  		hantro_write_addr(vpu, G2_RS_OUT_LUMA_ADDR, dst_dma);
>  		hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma + chroma_offset);
>  	}
> +
> +	out_depth = hantro_get_format_depth(ctx->dst_fmt.pixelformat);
>  	if (ctx->dev->variant->legacy_regs) {
> -		int out_depth = hantro_get_format_depth(ctx->dst_fmt.pixelformat);
>  		u8 pp_shift = 0;
>  
>  		if (out_depth > 8)
> @@ -141,6 +143,9 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
>  
>  		hantro_reg_write(ctx->dev, &g2_rs_out_bit_depth, out_depth);
>  		hantro_reg_write(ctx->dev, &g2_pp_pix_shift, pp_shift);
> +	} else {
> +		hantro_reg_write(vpu, &g2_output_8_bits, out_depth > 8 ? 0 : 1);
> +		hantro_reg_write(vpu, &g2_output_format, out_depth > 8 ? 1 : 0);
>  	}
>  	hantro_reg_write(vpu, &g2_out_rs_e, 1);
>  }
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream
  2022-06-17 11:58 ` [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream Benjamin Gaignard
@ 2022-06-30 17:38   ` Ezequiel Garcia
  0 siblings, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:38 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

On Fri, Jun 17, 2022 at 01:58:00PM +0200, Benjamin Gaignard wrote:
> Stop limiting HEVC support to 8-bits bitstreams also
> accept 10-bits bitstreams.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
>  drivers/staging/media/hantro/hantro_hevc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
> index e06837108a09..85688a4df166 100644
> --- a/drivers/staging/media/hantro/hantro_hevc.c
> +++ b/drivers/staging/media/hantro/hantro_hevc.c
> @@ -159,8 +159,8 @@ int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc

I'd like to go back to checking the SPS control directly
in hantro_try_ctrl. I believe the best and most reasonable
place to validate the controls would be TRY_CTRL.

See https://patchwork.linuxtv.org/project/linux-media/patch/20220629195624.45745-2-ezequiel@vanguardiasur.com.ar/.

>  	if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
>  		/* Luma and chroma bit depth mismatch */
>  		return -EINVAL;
> -	if (sps->bit_depth_luma_minus8 != 0)
> -		/* Only 8-bit is supported */
> +	if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
> +		/* Only 8-bit and 10-bit is supported */

Having said that, the change looks good:

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Thanks,
Ezequiel

>  		return -EINVAL;
>  
>  	ctx->bit_depth = sps->bit_depth_luma_minus8 + 8;
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding
  2022-06-17 11:58 ` [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding Benjamin Gaignard
@ 2022-06-30 17:40   ` Ezequiel Garcia
  2022-07-01  7:01     ` Benjamin Gaignard
  0 siblings, 1 reply; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:40 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

Hi Benjamin,

On Fri, Jun 17, 2022 at 01:58:01PM +0200, Benjamin Gaignard wrote:
> Expose 10bit pixel formats to enable 10bit decoding in IMX8M SoCs.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

Looks good to me.

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Have you checked Fluster tests passess using both P010 and P010_4L4?
It would be good to double-check.

Thanks a lot,
Ezequiel

> ---
>  drivers/staging/media/hantro/imx8m_vpu_hw.c | 27 +++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/staging/media/hantro/imx8m_vpu_hw.c b/drivers/staging/media/hantro/imx8m_vpu_hw.c
> index 77f574fdfa77..b390228fd3b4 100644
> --- a/drivers/staging/media/hantro/imx8m_vpu_hw.c
> +++ b/drivers/staging/media/hantro/imx8m_vpu_hw.c
> @@ -162,12 +162,39 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = {
>  			.step_height = MB_DIM,
>  		},
>  	},
> +	{
> +		.fourcc = V4L2_PIX_FMT_P010,
> +		.codec_mode = HANTRO_MODE_NONE,
> +		.postprocessed = true,
> +		.frmsize = {
> +			.min_width = FMT_MIN_WIDTH,
> +			.max_width = FMT_UHD_WIDTH,
> +			.step_width = MB_DIM,
> +			.min_height = FMT_MIN_HEIGHT,
> +			.max_height = FMT_UHD_HEIGHT,
> +			.step_height = MB_DIM,
> +		},
> +	},
>  };
>  
>  static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = {
>  	{
>  		.fourcc = V4L2_PIX_FMT_NV12_4L4,
>  		.codec_mode = HANTRO_MODE_NONE,
> +		.match_depth = true,
> +		.frmsize = {
> +			.min_width = FMT_MIN_WIDTH,
> +			.max_width = FMT_UHD_WIDTH,
> +			.step_width = TILE_MB_DIM,
> +			.min_height = FMT_MIN_HEIGHT,
> +			.max_height = FMT_UHD_HEIGHT,
> +			.step_height = TILE_MB_DIM,
> +		},
> +	},
> +	{
> +		.fourcc = V4L2_PIX_FMT_P010_4L4,
> +		.codec_mode = HANTRO_MODE_NONE,
> +		.match_depth = true,
>  		.frmsize = {
>  			.min_width = FMT_MIN_WIDTH,
>  			.max_width = FMT_UHD_WIDTH,
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different
  2022-06-17 11:58 ` [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different Benjamin Gaignard
@ 2022-06-30 17:40   ` Ezequiel Garcia
  0 siblings, 0 replies; 19+ messages in thread
From: Ezequiel Garcia @ 2022-06-30 17:40 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel

On Fri, Jun 17, 2022 at 01:58:02PM +0200, Benjamin Gaignard wrote:
> Luma and chroma depth are set on different hardware registers.
> Even if they aren't identical the bitstream can be compliant
> to HEVC specifications and decoded by the hardware.
> 
> With this patch TSUNEQBD_A_MAIN10_Technicolor_2 conformance test
> is successfully decoded.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

Thanks,
Ezequiel

> ---
>  drivers/staging/media/hantro/hantro_hevc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_hevc.c b/drivers/staging/media/hantro/hantro_hevc.c
> index 85688a4df166..26b1329893f7 100644
> --- a/drivers/staging/media/hantro/hantro_hevc.c
> +++ b/drivers/staging/media/hantro/hantro_hevc.c
> @@ -156,9 +156,6 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
>  
>  int hantro_hevc_validate_sps(struct hantro_ctx *ctx, const struct v4l2_ctrl_hevc_sps *sps)
>  {
> -	if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
> -		/* Luma and chroma bit depth mismatch */
> -		return -EINVAL;
>  	if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
>  		/* Only 8-bit and 10-bit is supported */
>  		return -EINVAL;
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding
  2022-06-30 17:40   ` Ezequiel Garcia
@ 2022-07-01  7:01     ` Benjamin Gaignard
  2022-07-04 15:43       ` Nicolas Dufresne
  0 siblings, 1 reply; 19+ messages in thread
From: Benjamin Gaignard @ 2022-07-01  7:01 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, nicolas.dufresne, andrzej.p,
	linux-media, linux-kernel, linux-rockchip, linux-staging,
	linux-arm-kernel, linux-sunxi, kernel


Le 30/06/2022 à 19:40, Ezequiel Garcia a écrit :
> Hi Benjamin,
>
> On Fri, Jun 17, 2022 at 01:58:01PM +0200, Benjamin Gaignard wrote:
>> Expose 10bit pixel formats to enable 10bit decoding in IMX8M SoCs.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> Looks good to me.
>
> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
>
> Have you checked Fluster tests passess using both P010 and P010_4L4?
> It would be good to double-check.

It isn't possible to check P010_4L4 with fluster because GStreamer
videoconvert element doesn't support this format.

Regards,
Benjamin

>
> Thanks a lot,
> Ezequiel
>
>> ---
>>   drivers/staging/media/hantro/imx8m_vpu_hw.c | 27 +++++++++++++++++++++
>>   1 file changed, 27 insertions(+)
>>
>> diff --git a/drivers/staging/media/hantro/imx8m_vpu_hw.c b/drivers/staging/media/hantro/imx8m_vpu_hw.c
>> index 77f574fdfa77..b390228fd3b4 100644
>> --- a/drivers/staging/media/hantro/imx8m_vpu_hw.c
>> +++ b/drivers/staging/media/hantro/imx8m_vpu_hw.c
>> @@ -162,12 +162,39 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = {
>>   			.step_height = MB_DIM,
>>   		},
>>   	},
>> +	{
>> +		.fourcc = V4L2_PIX_FMT_P010,
>> +		.codec_mode = HANTRO_MODE_NONE,
>> +		.postprocessed = true,
>> +		.frmsize = {
>> +			.min_width = FMT_MIN_WIDTH,
>> +			.max_width = FMT_UHD_WIDTH,
>> +			.step_width = MB_DIM,
>> +			.min_height = FMT_MIN_HEIGHT,
>> +			.max_height = FMT_UHD_HEIGHT,
>> +			.step_height = MB_DIM,
>> +		},
>> +	},
>>   };
>>   
>>   static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = {
>>   	{
>>   		.fourcc = V4L2_PIX_FMT_NV12_4L4,
>>   		.codec_mode = HANTRO_MODE_NONE,
>> +		.match_depth = true,
>> +		.frmsize = {
>> +			.min_width = FMT_MIN_WIDTH,
>> +			.max_width = FMT_UHD_WIDTH,
>> +			.step_width = TILE_MB_DIM,
>> +			.min_height = FMT_MIN_HEIGHT,
>> +			.max_height = FMT_UHD_HEIGHT,
>> +			.step_height = TILE_MB_DIM,
>> +		},
>> +	},
>> +	{
>> +		.fourcc = V4L2_PIX_FMT_P010_4L4,
>> +		.codec_mode = HANTRO_MODE_NONE,
>> +		.match_depth = true,
>>   		.frmsize = {
>>   			.min_width = FMT_MIN_WIDTH,
>>   			.max_width = FMT_UHD_WIDTH,
>> -- 
>> 2.32.0
>>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation
  2022-06-17 11:57 ` [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation Benjamin Gaignard
  2022-06-30 17:34   ` Ezequiel Garcia
@ 2022-07-01  8:47   ` Paul Kocialkowski
  2022-07-01  9:03     ` Benjamin Gaignard
  1 sibling, 1 reply; 19+ messages in thread
From: Paul Kocialkowski @ 2022-07-01  8:47 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard, wens,
	jernej.skrabec, samuel, nicolas.dufresne, andrzej.p, linux-media,
	linux-kernel, linux-rockchip, linux-staging, linux-arm-kernel,
	linux-sunxi, kernel

[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]

Hi Benjamin,

On Fri 17 Jun 22, 13:57, Benjamin Gaignard wrote:
> The chroma offset depends of the bitstream depth.
> Make sure that ctx->bit_depth is used to compute it.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
>  drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> index 9eac133bda68..8407ad45b7b7 100644
> --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
> @@ -12,7 +12,7 @@
>  
>  static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx)
>  {
> -	return ctx->dst_fmt.width * ctx->dst_fmt.height;
> +	return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8;

Is this a case for DIV_ROUND_UP or are you sure the rounded-down size is always
sufficient?

Cheers,

Paul

>  }
>  
>  static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx)
> -- 
> 2.32.0
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation
  2022-07-01  8:47   ` Paul Kocialkowski
@ 2022-07-01  9:03     ` Benjamin Gaignard
  0 siblings, 0 replies; 19+ messages in thread
From: Benjamin Gaignard @ 2022-07-01  9:03 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: mchehab, hverkuil, ezequiel, p.zabel, gregkh, mripard, wens,
	jernej.skrabec, samuel, nicolas.dufresne, andrzej.p, linux-media,
	linux-kernel, linux-rockchip, linux-staging, linux-arm-kernel,
	linux-sunxi, kernel


Le 01/07/2022 à 10:47, Paul Kocialkowski a écrit :
> Hi Benjamin,
>
> On Fri 17 Jun 22, 13:57, Benjamin Gaignard wrote:
>> The chroma offset depends of the bitstream depth.
>> Make sure that ctx->bit_depth is used to compute it.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
>> ---
>>   drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
>> index 9eac133bda68..8407ad45b7b7 100644
>> --- a/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
>> +++ b/drivers/staging/media/hantro/hantro_g2_hevc_dec.c
>> @@ -12,7 +12,7 @@
>>   
>>   static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx)
>>   {
>> -	return ctx->dst_fmt.width * ctx->dst_fmt.height;
>> +	return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8;
> Is this a case for DIV_ROUND_UP or are you sure the rounded-down size is always
> sufficient?

No need of DIV_ROUND_UP here because it could affect the chroma offset when
using decoder tiled format and add extra bytes between luma and chroma planes.

Regards,
Benjamin

> Cheers,
>
> Paul
>
>>   }
>>   
>>   static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx)
>> -- 
>> 2.32.0
>>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding
  2022-07-01  7:01     ` Benjamin Gaignard
@ 2022-07-04 15:43       ` Nicolas Dufresne
  0 siblings, 0 replies; 19+ messages in thread
From: Nicolas Dufresne @ 2022-07-04 15:43 UTC (permalink / raw)
  To: Benjamin Gaignard, Ezequiel Garcia
  Cc: mchehab, hverkuil, p.zabel, gregkh, mripard, paul.kocialkowski,
	wens, jernej.skrabec, samuel, andrzej.p, linux-media,
	linux-kernel, linux-rockchip, linux-staging, linux-arm-kernel,
	linux-sunxi, kernel

Le vendredi 01 juillet 2022 à 09:01 +0200, Benjamin Gaignard a écrit :
> Le 30/06/2022 à 19:40, Ezequiel Garcia a écrit :
> > Hi Benjamin,
> > 
> > On Fri, Jun 17, 2022 at 01:58:01PM +0200, Benjamin Gaignard wrote:
> > > Expose 10bit pixel formats to enable 10bit decoding in IMX8M SoCs.
> > > 
> > > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> > Looks good to me.
> > 
> > Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> > 
> > Have you checked Fluster tests passess using both P010 and P010_4L4?
> > It would be good to double-check.
> 
> It isn't possible to check P010_4L4 with fluster because GStreamer
> videoconvert element doesn't support this format.

I can offert to work on this. If you can send me offline some picture dump, so I
can validate, that would help.

> 
> Regards,
> Benjamin
> 
> > 
> > Thanks a lot,
> > Ezequiel
> > 
> > > ---
> > >   drivers/staging/media/hantro/imx8m_vpu_hw.c | 27 +++++++++++++++++++++
> > >   1 file changed, 27 insertions(+)
> > > 
> > > diff --git a/drivers/staging/media/hantro/imx8m_vpu_hw.c b/drivers/staging/media/hantro/imx8m_vpu_hw.c
> > > index 77f574fdfa77..b390228fd3b4 100644
> > > --- a/drivers/staging/media/hantro/imx8m_vpu_hw.c
> > > +++ b/drivers/staging/media/hantro/imx8m_vpu_hw.c
> > > @@ -162,12 +162,39 @@ static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = {
> > >   			.step_height = MB_DIM,
> > >   		},
> > >   	},
> > > +	{
> > > +		.fourcc = V4L2_PIX_FMT_P010,
> > > +		.codec_mode = HANTRO_MODE_NONE,
> > > +		.postprocessed = true,
> > > +		.frmsize = {
> > > +			.min_width = FMT_MIN_WIDTH,
> > > +			.max_width = FMT_UHD_WIDTH,
> > > +			.step_width = MB_DIM,
> > > +			.min_height = FMT_MIN_HEIGHT,
> > > +			.max_height = FMT_UHD_HEIGHT,
> > > +			.step_height = MB_DIM,
> > > +		},
> > > +	},
> > >   };
> > >   
> > >   static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = {
> > >   	{
> > >   		.fourcc = V4L2_PIX_FMT_NV12_4L4,
> > >   		.codec_mode = HANTRO_MODE_NONE,
> > > +		.match_depth = true,
> > > +		.frmsize = {
> > > +			.min_width = FMT_MIN_WIDTH,
> > > +			.max_width = FMT_UHD_WIDTH,
> > > +			.step_width = TILE_MB_DIM,
> > > +			.min_height = FMT_MIN_HEIGHT,
> > > +			.max_height = FMT_UHD_HEIGHT,
> > > +			.step_height = TILE_MB_DIM,
> > > +		},
> > > +	},
> > > +	{
> > > +		.fourcc = V4L2_PIX_FMT_P010_4L4,
> > > +		.codec_mode = HANTRO_MODE_NONE,
> > > +		.match_depth = true,
> > >   		.frmsize = {
> > >   			.min_width = FMT_MIN_WIDTH,
> > >   			.max_width = FMT_UHD_WIDTH,
> > > -- 
> > > 2.32.0
> > > 


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-07-04 15:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 11:57 [PATCH 0/7] Enable 10bits bitstream for Hantro/G2 HEVC codec Benjamin Gaignard
2022-06-17 11:57 ` [PATCH 1/7] media: hantro: Store HEVC bit depth in context Benjamin Gaignard
2022-06-30 17:30   ` Ezequiel Garcia
2022-06-17 11:57 ` [PATCH 2/7] media: hantro: HEVC: Fix auxilary buffer size calculation Benjamin Gaignard
2022-06-30 17:33   ` Ezequiel Garcia
2022-06-17 11:57 ` [PATCH 3/7] media: hantro: HEVC: Fix chroma offset computation Benjamin Gaignard
2022-06-30 17:34   ` Ezequiel Garcia
2022-07-01  8:47   ` Paul Kocialkowski
2022-07-01  9:03     ` Benjamin Gaignard
2022-06-17 11:57 ` [PATCH 4/7] media: hantro: postproc: Configure output regs to support 10bit Benjamin Gaignard
2022-06-30 17:35   ` Ezequiel Garcia
2022-06-17 11:58 ` [PATCH 5/7] media: Hantro: HEVC: Allows 10-bit bitstream Benjamin Gaignard
2022-06-30 17:38   ` Ezequiel Garcia
2022-06-17 11:58 ` [PATCH 6/7] media: hantro: imx8m: Enable 10bit decoding Benjamin Gaignard
2022-06-30 17:40   ` Ezequiel Garcia
2022-07-01  7:01     ` Benjamin Gaignard
2022-07-04 15:43       ` Nicolas Dufresne
2022-06-17 11:58 ` [PATCH 7/7] media: hantro: Allows luma and chroma depth to be different Benjamin Gaignard
2022-06-30 17:40   ` Ezequiel Garcia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).