2022-06-16 20:31:03

by Jernej Škrabec

[permalink] [raw]
Subject: [PATCH v2 0/7] media: hantro: Add 10-bit support

This series adds support for 10-bit format handling in Hantro driver.
Most patches adjust postproc behaviour to be more universal. There is
a lot of assumptions, which need to be replaced with more generalized.

Tested on Allwinner H6. Tested with vp92-2-20-10bit-yuv420.webm sample,
which produces correct checksum.

Please take a look.

Best regards,
Jernej

Changes from RFC:
- fixed typo in function name
- removed merged patch (P010 format)
- removed broken patch (sunxi frequency change)
- added new patch (media: hantro: postproc: Properly calculate chroma offset)
- added r-b from Ezequiel

Ezequiel Garcia (1):
media: Add P010 tiled format

Jernej Skrabec (6):
media: hantro: Support format filtering by depth
media: hantro: postproc: Fix buffer size calculation
media: hantro: postproc: Fix legacy regs configuration
media: hantro: postproc: Properly calculate chroma offset
media: hantro: Store VP9 bit depth in context
media: hantro: sunxi: Enable 10-bit decoding

drivers/media/v4l2-core/v4l2-common.c | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
drivers/staging/media/hantro/hantro.h | 4 ++
drivers/staging/media/hantro/hantro_drv.c | 23 +++++++++
.../staging/media/hantro/hantro_g2_vp9_dec.c | 8 ---
.../staging/media/hantro/hantro_postproc.c | 38 +++++++++++---
drivers/staging/media/hantro/hantro_v4l2.c | 50 +++++++++++++++++--
drivers/staging/media/hantro/hantro_v4l2.h | 3 ++
drivers/staging/media/hantro/sunxi_vpu_hw.c | 27 ++++++++++
include/uapi/linux/videodev2.h | 1 +
10 files changed, 136 insertions(+), 20 deletions(-)

--
2.36.1


2022-06-16 20:40:53

by Jernej Škrabec

[permalink] [raw]
Subject: [PATCH v2 5/7] media: hantro: postproc: Properly calculate chroma offset

Currently chroma offset calculation assumes only 1 byte per luma, with
no consideration for stride.

Take necessary information from destination pixel format which makes
calculation completely universal.

Signed-off-by: Jernej Skrabec <[email protected]>
---
drivers/staging/media/hantro/hantro_postproc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c
index 8933b4af73ed..a0928c508434 100644
--- a/drivers/staging/media/hantro/hantro_postproc.c
+++ b/drivers/staging/media/hantro/hantro_postproc.c
@@ -113,12 +113,14 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
{
struct hantro_dev *vpu = ctx->dev;
struct vb2_v4l2_buffer *dst_buf;
- size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height;
int down_scale = down_scale_factor(ctx);
+ size_t chroma_offset;
dma_addr_t dst_dma;

dst_buf = hantro_get_dst_buf(ctx);
dst_dma = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
+ chroma_offset = ctx->dst_fmt.plane_fmt[0].bytesperline *
+ ctx->dst_fmt.height;

if (down_scale) {
hantro_reg_write(vpu, &g2_down_scale_e, 1);
--
2.36.1

2022-06-16 20:59:37

by Jernej Škrabec

[permalink] [raw]
Subject: [PATCH v2 1/7] media: Add P010 tiled format

From: Ezequiel Garcia <[email protected]>

Add P010 tiled format

Signed-off-by: Ezequiel Garcia <[email protected]>
[rebased and updated pixel format name]
Signed-off-by: Jernej Skrabec <[email protected]>
---
drivers/media/v4l2-core/v4l2-common.c | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
3 files changed, 3 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 1e38ad8906a2..e0fbe6ba4b6c 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -278,6 +278,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)

/* Tiled YUV formats */
{ .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 },
+ { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 },

/* YUV planar formats, non contiguous variant */
{ .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 2 },
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index e2526701294e..e24d38c0a178 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1310,6 +1310,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_NV12_4L4: descr = "Y/CbCr 4:2:0 (4x4 Linear)"; break;
case V4L2_PIX_FMT_NV12_16L16: descr = "Y/CbCr 4:2:0 (16x16 Linear)"; break;
case V4L2_PIX_FMT_NV12_32L32: descr = "Y/CbCr 4:2:0 (32x32 Linear)"; break;
+ case V4L2_PIX_FMT_P010_4L4: descr = "P010 tiled"; break;
case V4L2_PIX_FMT_NV12M: descr = "Y/CbCr 4:2:0 (N-C)"; break;
case V4L2_PIX_FMT_NV21M: descr = "Y/CrCb 4:2:0 (N-C)"; break;
case V4L2_PIX_FMT_NV16M: descr = "Y/CbCr 4:2:2 (N-C)"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 5311ac4fde35..32bedeb04152 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -630,6 +630,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 4x4 tiles */
#define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 tiles */
#define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 32x32 tiles */
+#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0') /* 12 Y/CbCr 4:2:0 10-bit 4x4 macroblocks */

/* Tiled YUV formats, non contiguous planes */
#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 tiles */
--
2.36.1

2022-06-17 12:20:36

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH v2 0/7] media: hantro: Add 10-bit support


Le 16/06/2022 à 22:25, Jernej Skrabec a écrit :
> This series adds support for 10-bit format handling in Hantro driver.
> Most patches adjust postproc behaviour to be more universal. There is
> a lot of assumptions, which need to be replaced with more generalized.
>
> Tested on Allwinner H6. Tested with vp92-2-20-10bit-yuv420.webm sample,
> which produces correct checksum.
>
> Please take a look.

I have send a complementary series to this one to enable 10-bit
for HEVC on Hantro/G2 on IMX8MQ.
With these two patchset I'm able to decode all the 10-bit conformance
test files.

For this series:
Tested-by: Benjamin Gaignard <[email protected]>

>
> Best regards,
> Jernej
>
> Changes from RFC:
> - fixed typo in function name
> - removed merged patch (P010 format)
> - removed broken patch (sunxi frequency change)
> - added new patch (media: hantro: postproc: Properly calculate chroma offset)
> - added r-b from Ezequiel
>
> Ezequiel Garcia (1):
> media: Add P010 tiled format
>
> Jernej Skrabec (6):
> media: hantro: Support format filtering by depth
> media: hantro: postproc: Fix buffer size calculation
> media: hantro: postproc: Fix legacy regs configuration
> media: hantro: postproc: Properly calculate chroma offset
> media: hantro: Store VP9 bit depth in context
> media: hantro: sunxi: Enable 10-bit decoding
>
> drivers/media/v4l2-core/v4l2-common.c | 1 +
> drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
> drivers/staging/media/hantro/hantro.h | 4 ++
> drivers/staging/media/hantro/hantro_drv.c | 23 +++++++++
> .../staging/media/hantro/hantro_g2_vp9_dec.c | 8 ---
> .../staging/media/hantro/hantro_postproc.c | 38 +++++++++++---
> drivers/staging/media/hantro/hantro_v4l2.c | 50 +++++++++++++++++--
> drivers/staging/media/hantro/hantro_v4l2.h | 3 ++
> drivers/staging/media/hantro/sunxi_vpu_hw.c | 27 ++++++++++
> include/uapi/linux/videodev2.h | 1 +
> 10 files changed, 136 insertions(+), 20 deletions(-)
>

2022-06-28 19:16:53

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [PATCH v2 1/7] media: Add P010 tiled format

Hi Jernej,

Thanks for the patch.

On Thu, Jun 16, 2022 at 10:25:07PM +0200, Jernej Skrabec wrote:
> From: Ezequiel Garcia <[email protected]>
>
> Add P010 tiled format
>
> Signed-off-by: Ezequiel Garcia <[email protected]>
> [rebased and updated pixel format name]
> Signed-off-by: Jernej Skrabec <[email protected]>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 1 +
> drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
> include/uapi/linux/videodev2.h | 1 +

We also need to add the documentation in
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst.

See Benjamin's patch for reference:

commit 5374d8fb75f313294c7d97e85c22bead34d63f2b
Author: Benjamin Gaignard <[email protected]>
Date: Thu May 19 08:11:46 2022 +0100

media: Add P010 video format

P010 is a YUV format with 10-bits per component with interleaved UV.

> 3 files changed, 3 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 1e38ad8906a2..e0fbe6ba4b6c 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -278,6 +278,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
>
> /* Tiled YUV formats */
> { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 },
> + { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 },
>
> /* YUV planar formats, non contiguous variant */
> { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 2 },
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index e2526701294e..e24d38c0a178 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1310,6 +1310,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
> case V4L2_PIX_FMT_NV12_4L4: descr = "Y/CbCr 4:2:0 (4x4 Linear)"; break;
> case V4L2_PIX_FMT_NV12_16L16: descr = "Y/CbCr 4:2:0 (16x16 Linear)"; break;
> case V4L2_PIX_FMT_NV12_32L32: descr = "Y/CbCr 4:2:0 (32x32 Linear)"; break;
> + case V4L2_PIX_FMT_P010_4L4: descr = "P010 tiled"; break;

I would make this "10-bit Y/CbCr 4:2:0 (4x4 Linear)".

Thanks,
Ezequiel

2022-06-29 19:49:26

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [PATCH v2 5/7] media: hantro: postproc: Properly calculate chroma offset

Hi Jernej,

On Thu, Jun 16, 2022 at 10:25:11PM +0200, Jernej Skrabec wrote:
> Currently chroma offset calculation assumes only 1 byte per luma, with
> no consideration for stride.
>
> Take necessary information from destination pixel format which makes
> calculation completely universal.
>
> Signed-off-by: Jernej Skrabec <[email protected]>

Reviewed-by: Ezequiel Garcia <[email protected]>

Thanks,
Ezequiel

> ---
> drivers/staging/media/hantro/hantro_postproc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c
> index 8933b4af73ed..a0928c508434 100644
> --- a/drivers/staging/media/hantro/hantro_postproc.c
> +++ b/drivers/staging/media/hantro/hantro_postproc.c
> @@ -113,12 +113,14 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)
> {
> struct hantro_dev *vpu = ctx->dev;
> struct vb2_v4l2_buffer *dst_buf;
> - size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height;
> int down_scale = down_scale_factor(ctx);
> + size_t chroma_offset;
> dma_addr_t dst_dma;
>
> dst_buf = hantro_get_dst_buf(ctx);
> dst_dma = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
> + chroma_offset = ctx->dst_fmt.plane_fmt[0].bytesperline *
> + ctx->dst_fmt.height;
>
> if (down_scale) {
> hantro_reg_write(vpu, &g2_down_scale_e, 1);
> --
> 2.36.1
>