VP9 codec V4L2 control interface
Subsystems (4)
v7 cover VP9 codec V4L2 control interface
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.
GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/
The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.html
Rebased onto latest media_tree.
Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)
Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)
Changes related to v4:
- removed unused enum v4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation features
Changes related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:
V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs
- moved tx_mode to v4l2_ctrl_vp9_compressed_hdr
- fixed enum v4l2_vp9_ref_frame_sign_bias values (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enums
Apply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that the v4l2_ctrl_vp9_compressed_hdr control is optional and implemented only by drivers which need it
Changes related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'struct v4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanups
Andrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 core
Boris Brezillon (1):
media: rkvdec: Add the VP9 backend
Ezequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce struct hantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format
.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 drivers/staging/media/hantro/hantro_g2.c create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c create mode 100644 include/media/v4l2-vp9.h
base-commit: e4e737bb5c170df6135a127739a9e6148ee3da82
Signature · 1 line
2.17.1
PATCH v7 1/11 hantro: postproc: Fix motion vector space size
From: Ezequiel Garcia <[email protected]>
When the post-processor hardware block is enabled, the driver allocates an internal queue of buffers for the decoder enginer, and uses the vb2 queue for the post-processor engine.
For instance, on a G1 core, the decoder engine produces NV12 buffers and the post-processor engine can produce YUY2 buffers. The decoder engine expects motion vectors to be appended to the NV12 buffers, but this is only required for CODECs that need motion vectors, such as H.264.
Fix the post-processor logic accordingly.
--- drivers/staging/media/hantro/hantro_postproc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/hantro/hantro_postproc.c +4 -3
@@ -132,9 +132,10 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)unsigned int num_buffers = cap_queue->num_buffers;unsigned int i, buf_size; - buf_size = ctx->dst_fmt.plane_fmt[0 ].sizeimage + -hantro_h264_mv_size (ctx->dst_fmt.width, - ctx->dst_fmt.height); + buf_size = ctx->dst_fmt.plane_fmt[0 ].sizeimage; +if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) + buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, + ctx->dst_fmt.height);for (i =0 ; i < num_buffers; ++i) {struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];
Signature · 1 line
2.17.1
PATCH v7 2/11 hantro: postproc: Introduce struct hantro_postproc_ops
In reply to Andrzej PietrasiewiczFrom: Ezequiel Garcia <[email protected]>
Turns out the post-processor block on the G2 core is substantially different from the one on the G1 core. Introduce hantro_postproc_ops with .enable and .disable methods, which will allow to support the G2 post-processor cleanly.
--- drivers/staging/media/hantro/hantro.h | 5 +-- drivers/staging/media/hantro/hantro_hw.h | 13 +++++++- .../staging/media/hantro/hantro_postproc.c | 33 ++++++++++++++----- drivers/staging/media/hantro/imx8m_vpu_hw.c | 2 +- .../staging/media/hantro/rockchip_vpu_hw.c | 6 ++-- .../staging/media/hantro/sama5d4_vdec_hw.c | 2 +- 6 files changed, 44 insertions(+), 17 deletions(-)
drivers/staging/media/hantro/hantro.h +3 -2
@@ -28,6 +28,7 @@struct hantro_ctx ;struct hantro_codec_ops ; +struct hantro_postproc_ops ;#define HANTRO_JPEG_ENCODER BIT(0)#define HANTRO_ENCODERS 0x0000ffff
@@ -59,6 +60,7 @@ struct hantro_irq {* @num_dec_fmts: Number of decoder formats. * @postproc_fmts: Post-processor formats. * @num_postproc_fmts: Number of post-processor formats. +* @postproc_ops: Post-processor ops. * @codec: Supported codecs * @codec_ops: Codec ops. * @init: Initialize hardware, optional.
@@ -69,7 +71,6 @@ struct hantro_irq {* @num_clocks: number of clocks in the array * @reg_names: array of register range names * @num_regs: number of register range names in the array -* @postproc_regs: &struct hantro_postproc_regs pointer */ struct hantro_variant {unsigned int enc_offset;
@@ -80,6 +81,7 @@ struct hantro_variant {unsigned int num_dec_fmts;const struct hantro_fmt *postproc_fmts;unsigned int num_postproc_fmts; +const struct hantro_postproc_ops *postproc_ops;unsigned int codec;const struct hantro_codec_ops *codec_ops;int (*init)(struct hantro_dev *vpu);
@@ -90,7 +92,6 @@ struct hantro_variant {int num_clocks;const char *const *reg_names;int num_regs; -const struct hantro_postproc_regs *postproc_regs; };/**
drivers/staging/media/hantro/hantro_hw.h +12 -1
@@ -170,6 +170,17 @@ struct hantro_postproc_ctx {struct hantro_aux_buf dec_q[VB2_MAX_FRAME ]; }; +/** +* struct hantro_postproc_ops - post-processor operations +* +* @enable: Enable the post-processor block. Optional. +* @disable: Disable the post-processor block. Optional. +*/ +struct hantro_postproc_ops { +void (*enable)(struct hantro_ctx *ctx); +void (*disable)(struct hantro_ctx *ctx); +}; +/** * struct hantro_codec_ops - codec mode specific operations *
@@ -217,7 +228,7 @@ extern const struct hantro_variant rk3328_vpu_variant;extern const struct hantro_variant rk3399_vpu_variant;extern const struct hantro_variant sama5d4_vdec_variant; -extern const struct hantro_postproc_regs hantro_g1_postproc_regs; +extern const struct hantro_postproc_ops hantro_g1_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];
drivers/staging/media/hantro/hantro_postproc.c +24 -9
@@ -15,14 +15,14 @@#define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \ hantro_reg_write(vpu, \ - &(vpu)->variant->postproc_regs->reg_name, \ + &hantro_g1_postproc_regs.reg_name, \ val); \ }#define HANTRO_PP_REG_WRITE_S (vpu, reg_name, val) \ { \ hantro_reg_write_s(vpu, \ - &(vpu)->variant->postproc_regs->reg_name, \ + &hantro_g1_postproc_regs.reg_name, \ val); \ }
@@ -64,16 +64,13 @@ bool hantro_needs_postproc(const struct hantro_ctx *ctx,return fmt->fourcc !=V4L2_PIX_FMT_NV12 ; } -void hantro_postproc_enable (struct hantro_ctx *ctx) +static void hantro_postproc_g1_enable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *dst_buf;u32 src_pp_fmt, dst_pp_fmt;dma_addr_t dst_dma; -if (!vpu->variant->postproc_regs) -return ; -/* Turn on pipeline mode. Must be done first. */ HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x1 );
@@ -154,12 +151,30 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)return 0 ; } +static void hantro_postproc_g1_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev; -if (!vpu->variant->postproc_regs) -return ; +if (vpu->variant->postproc_ops && vpu->variant->postproc_ops->disable) + vpu->variant->postproc_ops->disable (ctx); +} -HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); +void hantro_postproc_enable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +if (vpu->variant->postproc_ops && vpu->variant->postproc_ops->enable) + vpu->variant->postproc_ops->enable (ctx); } + +const struct hantro_postproc_ops hantro_g1_postproc_ops = { + .enable = hantro_postproc_g1_enable, + .disable = hantro_postproc_g1_disable, +};
drivers/staging/media/hantro/imx8m_vpu_hw.c +1 -1
@@ -262,7 +262,7 @@ const struct hantro_variant imx8mq_vpu_variant = { .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_dec_fmts), .postproc_fmts = imx8m_vpu_postproc_fmts, .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_postproc_fmts), - .postproc_regs = &hantro_g1_postproc_regs, + .postproc_ops = &hantro_g1_postproc_ops, .codec =HANTRO_MPEG2_DECODER |HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = imx8mq_vpu_codec_ops,
drivers/staging/media/hantro/rockchip_vpu_hw.c +3 -3
@@ -460,7 +460,7 @@ const struct hantro_variant rk3036_vpu_variant = { .num_dec_fmts = ARRAY_SIZE(rk3066_vpu_dec_fmts), .postproc_fmts = rockchip_vpu1_postproc_fmts, .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), - .postproc_regs = &hantro_g1_postproc_regs, + .postproc_ops = &hantro_g1_postproc_ops, .codec =HANTRO_MPEG2_DECODER |HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = rk3036_vpu_codec_ops,
@@ -485,7 +485,7 @@ const struct hantro_variant rk3066_vpu_variant = { .num_dec_fmts = ARRAY_SIZE(rk3066_vpu_dec_fmts), .postproc_fmts = rockchip_vpu1_postproc_fmts, .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), - .postproc_regs = &hantro_g1_postproc_regs, + .postproc_ops = &hantro_g1_postproc_ops, .codec =HANTRO_JPEG_ENCODER |HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = rk3066_vpu_codec_ops,
@@ -505,7 +505,7 @@ const struct hantro_variant rk3288_vpu_variant = { .num_dec_fmts = ARRAY_SIZE(rk3288_vpu_dec_fmts), .postproc_fmts = rockchip_vpu1_postproc_fmts, .num_postproc_fmts = ARRAY_SIZE(rockchip_vpu1_postproc_fmts), - .postproc_regs = &hantro_g1_postproc_regs, + .postproc_ops = &hantro_g1_postproc_ops, .codec =HANTRO_JPEG_ENCODER |HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = rk3288_vpu_codec_ops,
drivers/staging/media/hantro/sama5d4_vdec_hw.c +1 -1
@@ -100,7 +100,7 @@ const struct hantro_variant sama5d4_vdec_variant = { .num_dec_fmts = ARRAY_SIZE(sama5d4_vdec_fmts), .postproc_fmts = sama5d4_vdec_postproc_fmts, .num_postproc_fmts = ARRAY_SIZE(sama5d4_vdec_postproc_fmts), - .postproc_regs = &hantro_g1_postproc_regs, + .postproc_ops = &hantro_g1_postproc_ops, .codec =HANTRO_MPEG2_DECODER |HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = sama5d4_vdec_codec_ops,
Signature · 1 line
2.17.1
PATCH v7 3/11 hantro: Simplify postprocessor
In reply to Andrzej PietrasiewiczFrom: Ezequiel Garcia <[email protected]>
Add a 'postprocessed' boolean property to struct hantro_fmt to signal that a format is produced by the post-processor. This will allow to introduce the G2 post-processor in a simple way.
--- drivers/staging/media/hantro/hantro.h | 2 ++ drivers/staging/media/hantro/hantro_postproc.c | 8 +------- drivers/staging/media/hantro/imx8m_vpu_hw.c | 1 + drivers/staging/media/hantro/rockchip_vpu_hw.c | 1 + drivers/staging/media/hantro/sama5d4_vdec_hw.c | 1 + 5 files changed, 6 insertions(+), 7 deletions(-)
drivers/staging/media/hantro/hantro.h +2 -0
@@ -263,6 +263,7 @@ struct hantro_ctx {* @max_depth: Maximum depth, for bitstream formats * @enc_fmt: Format identifier for encoder registers. * @frmsize: Supported range of frame sizes (only for bitstream formats). +* @postprocessed: Indicates if this format needs the post-processor. */ struct hantro_fmt {char *name;
@@ -272,6 +273,7 @@ struct hantro_fmt {int max_depth;enum hantro_enc_fmt enc_fmt;struct v4l2_frmsize_stepwise frmsize; +bool postprocessed; };struct hantro_reg {
drivers/staging/media/hantro/hantro_postproc.c +1 -7
@@ -53,15 +53,9 @@ const struct hantro_postproc_regs hantro_g1_postproc_regs = {bool hantro_needs_postproc (const struct hantro_ctx *ctx,const struct hantro_fmt *fmt) { -struct hantro_dev *vpu = ctx->dev; -if (ctx->is_encoder)return false; - -if (!vpu->variant->postproc_fmts) -return false; - -return fmt->fourcc !=V4L2_PIX_FMT_NV12 ; +return fmt->postprocessed; }static void hantro_postproc_g1_enable (struct hantro_ctx *ctx)
drivers/staging/media/hantro/imx8m_vpu_hw.c +1 -0
@@ -82,6 +82,7 @@ static const struct hantro_fmt imx8m_vpu_postproc_fmts[] = { { .fourcc = V4L2_PIX_FMT_YUYV, .codec_mode = HANTRO_MODE_NONE, + .postprocessed = true, }, };
drivers/staging/media/hantro/rockchip_vpu_hw.c +1 -0
@@ -62,6 +62,7 @@ static const struct hantro_fmt rockchip_vpu1_postproc_fmts[] = { { .fourcc = V4L2_PIX_FMT_YUYV, .codec_mode = HANTRO_MODE_NONE, + .postprocessed = true, }, };
drivers/staging/media/hantro/sama5d4_vdec_hw.c +1 -0
@@ -15,6 +15,7 @@ static const struct hantro_fmt sama5d4_vdec_postproc_fmts[] = { { .fourcc = V4L2_PIX_FMT_YUYV, .codec_mode = HANTRO_MODE_NONE, + .postprocessed = true, }, };
Signature · 1 line
2.17.1
PATCH v7 4/11 hantro: Add quirk for NV12/NV12_4L4 capture format
In reply to Andrzej PietrasiewiczFrom: Ezequiel Garcia <[email protected]>
The G2 core decoder engine produces NV12_4L4 format, which is a simple NV12 4x4 tiled format. The driver currently hides this format by always enabling the post-processor engine, and therefore offering NV12 directly.
This is done without using the logic in hantro_postproc.c and therefore makes it difficult to add VP9 cleanly.
Since fixing this is not easy, add a small quirk to force NV12 if HEVC was configured, but otherwise declare NV12_4L4 as the pixel format in imx8mq_vpu_g2_variant.dec_fmts.
This will be used by the VP9 decoder which will be added soon.
--- drivers/staging/media/hantro/hantro_v4l2.c | 14 ++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_v4l2.c +14 -0
@@ -150,6 +150,20 @@ static int vidioc_enum_fmt(struct file *file, void *priv,unsigned int num_fmts, i, j =0 ;bool skip_mode_none; +/* +* The HEVC decoder on the G2 core needs a little quirk to offer NV12 +* only on the capture side. Once the post-processor logic is used, +* we will be able to expose NV12_4L4 and NV12 as the other cases, +* and therefore remove this quirk. +*/ +if (capture && ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_HEVC_SLICE ) { +if (f->index ==0 ) { + f->pixelformat =V4L2_PIX_FMT_NV12 ; +return 0 ; + } +return -EINVAL ; + } +/* * When dealing with an encoder: * - on the capture side we want to filter out all MODE_NONE formats.
drivers/staging/media/hantro/imx8m_vpu_hw.c +1 -1
@@ -134,7 +134,7 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[] = {static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { - .fourcc =V4L2_PIX_FMT_NV12 , + .fourcc =V4L2_PIX_FMT_NV12_4L4 , .codec_mode =HANTRO_MODE_NONE , }, {
Signature · 1 line
2.17.1
PATCH v7 5/11 media: uapi: Add VP9 stateless decoder controls
In reply to Andrzej PietrasiewiczAdd the VP9 stateless decoder controls plus the documentation that goes with it.
--- .../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 ++++++++++++++++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/media/v4l2-ctrls.h | 4 + include/uapi/linux/v4l2-controls.h | 284 +++++++++ include/uapi/linux/videodev2.h | 6 + 12 files changed, 1103 insertions(+)
Documentation/userspace-api/media/v4l/biblio.rst +10 -0
@@ -417,3 +417,13 @@ VP8 :title: RFC 6386: "VP8 Data Format and Decoding Guide" :author: J. Bankoski et al. + +.. _vp9: + +VP9 +=== + + +:title: VP9 Bitstream & Decoding Process Specification + +:author: Adrian Grange (Google), Peter de Rivaz (Argon Design), Jonathan Hunt (Argon Design)
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +573 -0
576 lines not on this page · raw message
Documentation/userspace-api/media/v4l/pixfmt-compressed.rst +15 -0
@@ -172,6 +172,21 @@ Compressed Formats - VP9 compressed video frame. The encoder generates one compressed frame per buffer, and the decoder requires one compressed frame per buffer. + * .. _V4L2-PIX-FMT-VP9-FRAME: + + - ``V4L2_PIX_FMT_VP9_FRAME`` + - 'VP9F' + - VP9 parsed frame, including the frame header, as extracted from the container. + This format is adapted for stateless video decoders that implement a + VP9 pipeline with the :ref:`stateless_decoder`. + Metadata associated with the frame to decode is required to be passed + through the ``V4L2_CID_STATELESS_VP9_FRAME`` and + the ``V4L2_CID_STATELESS_VP9_COMPRESSED_HDR`` controls. + See the :ref:`associated Codec Control IDs <v4l2-codec-stateless-vp9>`. + Exactly one output and one capture buffer must be provided for use with + this pixel format. The output buffer must contain the appropriate number + of macroblocks to decode a full corresponding frame to the matching + capture buffer. * .. _V4L2-PIX-FMT-HEVC: - ``V4L2_PIX_FMT_HEVC``
Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +8 -0
@@ -233,6 +233,14 @@ still cause this situation. - ``p_mpeg2_quantisation`` - A pointer to a struct :c:type:`v4l2_ctrl_mpeg2_quantisation`. Valid if this control is of type ``V4L2_CTRL_TYPE_MPEG2_QUANTISATION``. + * - struct :c:type:`v4l2_ctrl_vp9_compressed_hdr` * + - ``p_vp9_compressed_hdr_probs`` + - A pointer to a struct :c:type:`v4l2_ctrl_vp9_compressed_hdr`. Valid if this + control is of type ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR``. + * - struct :c:type:`v4l2_ctrl_vp9_frame` * + - ``p_vp9_frame`` + - A pointer to a struct :c:type:`v4l2_ctrl_vp9_frame`. Valid if this + control is of type ``V4L2_CTRL_TYPE_VP9_FRAME``. * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` * - ``p_hdr10_cll`` - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +12 -0
@@ -507,6 +507,18 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_hevc_decode_params`, containing HEVC decoding parameters for stateless video decoders. + * - ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_vp9_compressed_hdr`, containing VP9 + probabilities updates for stateless video decoders. + * - ``V4L2_CTRL_TYPE_VP9_FRAME`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_vp9_frame`, containing VP9 + frame decode parameters for stateless video decoders. .. raw:: latex
Documentation/userspace-api/media/videodev2.h.rst.exceptions +2 -0
@@ -149,6 +149,8 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_VP9_FRAME :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HDR10_CLL_INFO :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY :c:type:`v4l2_ctrl_type`
drivers/media/v4l2-core/v4l2-ctrls-core.c +180 -0
204 lines not on this page · raw message
drivers/media/v4l2-core/v4l2-ctrls-defs.c +8 -0
@@ -1175,6 +1175,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_STATELESS_MPEG2_SEQUENCE :return "MPEG-2 Sequence Header" ;case V4L2_CID_STATELESS_MPEG2_PICTURE :return "MPEG-2 Picture Header" ;case V4L2_CID_STATELESS_MPEG2_QUANTISATION :return "MPEG-2 Quantisation Matrices" ; +case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR :return "VP9 Probabilities Updates" ; +case V4L2_CID_STATELESS_VP9_FRAME :return "VP9 Frame Decode Parameters" ;/* Colorimetry controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1493,6 +1495,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS : *type =V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS ;break ; +case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR : + *type =V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR ; +break ; +case V4L2_CID_STATELESS_VP9_FRAME : + *type =V4L2_CTRL_TYPE_VP9_FRAME ; +break ;case V4L2_CID_UNIT_CELL_SIZE : *type =V4L2_CTRL_TYPE_AREA ; *flags |=V4L2_CTRL_FLAG_READ_ONLY ;
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1394,6 +1394,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP8_FRAME : descr ="VP8 Frame" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break ; +case V4L2_PIX_FMT_VP9_FRAME : descr ="VP9 Frame" ;break ;case V4L2_PIX_FMT_HEVC : descr ="HEVC" ;break ;/* aka H.265 */ case V4L2_PIX_FMT_HEVC_SLICE : descr ="HEVC Parsed Slice Data" ;break ;case V4L2_PIX_FMT_FWHT : descr ="FWHT" ;break ;/* used in vicodec */
include/media/v4l2-ctrls.h +4 -0
@@ -50,6 +50,8 @@ struct video_device;* @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params. * @p_h264_pred_weights: Pointer to a struct v4l2_ctrl_h264_pred_weights. * @p_vp8_frame: Pointer to a VP8 frame params structure. +* @p_vp9_compressed_hdr_probs: Pointer to a VP9 frame compressed header probs structure. +* @p_vp9_frame: Pointer to a VP9 frame params structure. * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure. * @p_hevc_pps: Pointer to an HEVC picture parameter set structure. * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
@@ -80,6 +82,8 @@ union v4l2_ctrl_ptr {struct v4l2_ctrl_hevc_sps *p_hevc_sps;struct v4l2_ctrl_hevc_pps *p_hevc_pps;struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; +struct v4l2_ctrl_vp9_compressed_hdr *p_vp9_compressed_hdr_probs; +struct v4l2_ctrl_vp9_frame *p_vp9_frame;struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;struct v4l2_area *p_area;
include/uapi/linux/v4l2-controls.h +284 -0
290 lines not on this page · raw message
include/uapi/linux/videodev2.h +6 -0
@@ -703,6 +703,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')/* VP8 parsed frame */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F')/* VP9 parsed frame */ #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C')/* HEVC aka H.265 */ #define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T')/* Fast Walsh Hadamard Transform (vicodec) */ #define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H')/* Stateless FWHT (vicodec) */
@@ -1755,6 +1756,8 @@ struct v4l2_ext_control {struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence;struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture;struct v4l2_ctrl_mpeg2_quantisation __user *p_mpeg2_quantisation; +struct v4l2_ctrl_vp9_compressed_hdr __user *p_vp9_compressed_hdr_probs; +struct v4l2_ctrl_vp9_frame __user *p_vp9_frame;void __user *ptr; }; } __attribute__ ((packed));
@@ -1819,6 +1822,9 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_MPEG2_QUANTISATION =0x0250 ,V4L2_CTRL_TYPE_MPEG2_SEQUENCE =0x0251 ,V4L2_CTRL_TYPE_MPEG2_PICTURE =0x0252 , + +V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR =0x0260 , + V4L2_CTRL_TYPE_VP9_FRAME = 0x0261, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 1 line
2.17.1
PATCH v7 6/11 media: Add VP9 v4l2 library
In reply to Andrzej PietrasiewiczProvide code common to vp9 drivers in one central location.
--- drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 ++++++++++++++++++++++++++++ include/media/v4l2-vp9.h | 182 +++ 4 files changed, 2037 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 include/media/v4l2-vp9.h
drivers/media/v4l2-core/Kconfig +4 -0
@@ -52,6 +52,10 @@ config V4L2_JPEG_HELPER config V4L2_H264 tristate +# Used by drivers that need v4l2-vp9.ko +config V4L2_VP9 + tristate + # Used by drivers that need v4l2-mem2mem.ko config V4L2_MEM2MEM_DEV tristate
drivers/media/v4l2-core/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o obj-$(CONFIG_V4L2_H264) += v4l2-h264.o +obj-$(CONFIG_V4L2_VP9) += v4l2-vp9.o obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o
drivers/media/v4l2-core/v4l2-vp9.c new file +1850 -0
1,850 lines not on this page · raw message
include/media/v4l2-vp9.h new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v7 7/11 media: rkvdec: Add the VP9 backend
In reply to Andrzej PietrasiewiczFrom: Boris Brezillon <[email protected]>
The Rockchip VDEC supports VP9 profile 0 up to 4096x2304@30fps. Add a backend for this new format.
--- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 +++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- 5 files changed, 1137 insertions(+), 8 deletions(-) create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c
drivers/staging/media/rkvdec/Kconfig +1 -0
@@ -9,6 +9,7 @@ config VIDEO_ROCKCHIP_VDEC select VIDEOBUF2_VMALLOC select V4L2_MEM2MEM_DEV select V4L2_H264 + select V4L2_VP9 help Support for the Rockchip Video Decoder IP present on Rockchip SoCs, which accelerates video decoding.
drivers/staging/media/rkvdec/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o -rockchip-vdec-y += rkvdec.o rkvdec-h264.o +rockchip-vdec-y += rkvdec.o rkvdec-h264.o rkvdec-vp9.o
drivers/staging/media/rkvdec/rkvdec-vp9.c new file +1078 -0
1,078 lines not on this page · raw message
drivers/staging/media/rkvdec/rkvdec.c +48 -4
79 lines not on this page · raw message
drivers/staging/media/rkvdec/rkvdec.h +9 -3
@@ -42,14 +42,18 @@ struct rkvdec_run {struct rkvdec_vp9_decoded_buffer_info {/* Info needed when the decoded frame serves as a reference frame. */ -u16 width; -u16 height; -u32 bit_depth :4 ; +unsigned short width; +unsigned short height; +unsigned int bit_depth :4 ; };struct rkvdec_decoded_buffer {/* Must be the first field in this struct. */ struct v4l2_m2m_buffer base; + +union { +struct rkvdec_vp9_decoded_buffer_info vp9; + }; }; static inline struct rkvdec_decoded_buffer *
@@ -116,4 +120,6 @@ void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);void rkvdec_run_postamble (struct rkvdec_ctx *ctx,struct rkvdec_run *run);extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops; +extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; +#endif /* RKVDEC_H_ */
Signature · 1 line
2.17.1
Re: [PATCH v7 07/11] media: rkvdec: Add the VP9 backend
Hi,
Quoted 20 lines · Andrzej Pietrasiewicz
From: Boris Brezillon <[email protected]>
The Rockchip VDEC supports VP9 profile 0 up to 4096x2304@30fps. Add a backend for this new format.
Signed-off-by Boris Brezillon <[email protected]>Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Adrian Ratiu <[email protected]>Co-developed-by Andrzej Pietrasiewicz <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 +++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- 5 files changed, 1137 insertions(+), 8 deletions(-) create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c
[...]
Quoted 4 lines
drivers/staging/media/rkvdec/rkvdec.c +0
-0
[...]
Quoted 11 lines
drivers/staging/media/rkvdec/rkvdec.c +1
-1@@ -319,7 +354,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;const struct rkvdec_coded_fmt_desc *desc;struct v4l2_format *cap_fmt; -struct vb2_queue *peer_vq; +struct vb2_queue *peer_vq, *vq;int ret;/* @@ -331,6 +366,15 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,if (vb2_is_busy (peer_vq))
drivers/staging/media/rkvdec/rkvdec.c static int rkvdec_s_output_fmt(struct file *file, void *priv, · line 376
Quoted 10 lines
drivers/staging/media/rkvdec/rkvdec.c +8
-0return -EBUSY ; +/* +* Some codecs like VP9 can contain dynamic resolution changes which +* are currently not supported by the V4L2 API or driver, so return +* an error if userspace tries to reconfigure the output format. +*/ + vq =v4l2_m2m_get_vq (m2m_ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ); +if (vb2_is_busy (vq)) +return -EINVAL ;
This check is already done in rkvdec_s_fmt(), though it returns -EBUSY instead. And I don't see similar changes to Hantro, so maybe this isn't an API limitation as described in the comment? My recent patch [1] also loosens the restrictions on this.
ChenYu
Quoted 4 lines
drivers/staging/media/rkvdec/rkvdec.c +1
-0+ ret =rkvdec_s_fmt (file, priv, f, rkvdec_try_output_fmt);if (ret)return ret;
Re: [PATCH v7 07/11] media: rkvdec: Add the VP9 backend
In reply to Andrzej PietrasiewiczHi Andrzej,
Am 29.09.21 um 18:04 schrieb Andrzej Pietrasiewicz:
Quoted 1,129 lines
From: Boris Brezillon <[email protected]>
The Rockchip VDEC supports VP9 profile 0 up to 4096x2304@30fps. Add a backend for this new format.
Signed-off-by Boris Brezillon <[email protected]>Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Adrian Ratiu <[email protected]>Co-developed-by Andrzej Pietrasiewicz <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 +++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- 5 files changed, 1137 insertions(+), 8 deletions(-)create mode 100644
drivers/staging/media/rkvdec/rkvdec-vp9.cdrivers/staging/media/rkvdec/Kconfig +1
-0@@ -9,6 +9,7 @@ config VIDEO_ROCKCHIP_VDEC select VIDEOBUF2_VMALLOC select V4L2_MEM2MEM_DEV select V4L2_H264 + select V4L2_VP9 help Support for the Rockchip Video Decoder IP present on Rockchip SoCs, which accelerates video decoding.drivers/staging/media/rkvdec/Makefile +1
-1@@ -1,3 +1,3 @@ obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o -rockchip-vdec-y += rkvdec.o rkvdec-h264.o +rockchip-vdec-y += rkvdec.o rkvdec-h264.o rkvdec-vp9.odrivers/staging/media/rkvdec/rkvdec-vp9.c new file +1078
-0@@ -0,0 +1,1078 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Rockchip Video Decoder VP9 backend +* +* Copyright (C) 2019 Collabora, Ltd. +* Boris Brezillon <[email protected]> +* Copyright (C) 2021 Collabora, Ltd. +* Andrzej Pietrasiewicz <[email protected]> +* +* Copyright (C) 2016 Rockchip Electronics Co., Ltd. +* Alpha Lin <[email protected]> +*/ + +/* +* For following the vp9 spec please start reading this driver +* code from rkvdec_vp9_run() followed by rkvdec_vp9_done(). +*/ + +#include <linux/kernel.h> +#include <linux/vmalloc.h> +#include <media/v4l2-mem2mem.h> +#include <media/v4l2-vp9.h> + +#include "rkvdec.h" +#include "rkvdec-regs.h" + +#define RKVDEC_VP9_PROBE_SIZE 4864 +#define RKVDEC_VP9_COUNT_SIZE 13232 +#define RKVDEC_VP9_MAX_SEGMAP_SIZE 73728 + +struct rkvdec_vp9_intra_mode_probs { +u8 y_mode[105 ]; +u8 uv_mode[23 ]; +}; + +struct rkvdec_vp9_intra_only_frame_probs { +u8 coef_intra[4 ][2 ][128 ]; +struct rkvdec_vp9_intra_mode_probs intra_mode[10 ]; +}; + +struct rkvdec_vp9_inter_frame_probs { +u8 y_mode[4 ][9 ]; +u8 comp_mode[5 ]; +u8 comp_ref[5 ]; +u8 single_ref[5 ][2 ]; +u8 inter_mode[7 ][3 ]; +u8 interp_filter[4 ][2 ]; +u8 padding0[11 ]; +u8 coef[2 ][4 ][2 ][128 ]; +u8 uv_mode_0_2[3 ][9 ]; +u8 padding1[5 ]; +u8 uv_mode_3_5[3 ][9 ]; +u8 padding2[5 ]; +u8 uv_mode_6_8[3 ][9 ]; +u8 padding3[5 ]; +u8 uv_mode_9[9 ]; +u8 padding4[7 ]; +u8 padding5[16 ]; +struct { +u8 joint[3 ]; +u8 sign[2 ]; +u8 classes[2 ][10 ]; +u8 class0_bit[2 ]; +u8 bits[2 ][10 ]; +u8 class0_fr[2 ][2 ][3 ]; +u8 fr[2 ][3 ]; +u8 class0_hp[2 ]; +u8 hp[2 ]; + } mv; +}; + +struct rkvdec_vp9_probs { +u8 partition[16 ][3 ]; +u8 pred[3 ]; +u8 tree[7 ]; +u8 skip[3 ]; +u8 tx32[2 ][3 ]; +u8 tx16[2 ][2 ]; +u8 tx8[2 ][1 ]; +u8 is_inter[4 ]; +/* 128 bit alignment */ +u8 padding0[3 ]; +union { +struct rkvdec_vp9_inter_frame_probs inter; +struct rkvdec_vp9_intra_only_frame_probs intra_only; + }; +}; + +/* Data structure describing auxiliary buffer format. */ +struct rkvdec_vp9_priv_tbl { +struct rkvdec_vp9_probs probs; +u8 segmap[2 ][RKVDEC_VP9_MAX_SEGMAP_SIZE ]; +}; + +struct rkvdec_vp9_refs_counts { +u32 eob[2 ]; +u32 coeff[3 ]; +}; + +struct rkvdec_vp9_inter_frame_symbol_counts { +u32 partition[16 ][4 ]; +u32 skip[3 ][2 ]; +u32 inter[4 ][2 ]; +u32 tx32p[2 ][4 ]; +u32 tx16p[2 ][4 ]; +u32 tx8p[2 ][2 ]; +u32 y_mode[4 ][10 ]; +u32 uv_mode[10 ][10 ]; +u32 comp[5 ][2 ]; +u32 comp_ref[5 ][2 ]; +u32 single_ref[5 ][2 ][2 ]; +u32 mv_mode[7 ][4 ]; +u32 filter[4 ][3 ]; +u32 mv_joint[4 ]; +u32 sign[2 ][2 ]; +/* add 1 element for align */ +u32 classes[2 ][11 +1 ]; +u32 class0[2 ][2 ]; +u32 bits[2 ][10 ][2 ]; +u32 class0_fp[2 ][2 ][4 ]; +u32 fp[2 ][4 ]; +u32 class0_hp[2 ][2 ]; +u32 hp[2 ][2 ]; +struct rkvdec_vp9_refs_counts ref_cnt[2 ][4 ][2 ][6 ][6 ]; +}; + +struct rkvdec_vp9_intra_frame_symbol_counts { +u32 partition[4 ][4 ][4 ]; +u32 skip[3 ][2 ]; +u32 intra[4 ][2 ]; +u32 tx32p[2 ][4 ]; +u32 tx16p[2 ][4 ]; +u32 tx8p[2 ][2 ]; +struct rkvdec_vp9_refs_counts ref_cnt[2 ][4 ][2 ][6 ][6 ]; +}; + +struct rkvdec_vp9_run { +struct rkvdec_run base; +const struct v4l2_ctrl_vp9_frame *decode_params; +}; + +struct rkvdec_vp9_frame_info { +u32 valid :1 ; +u32 segmapid :1 ; +u32 frame_context_idx :2 ; +u32 reference_mode :2 ; +u32 tx_mode :3 ; +u32 interpolation_filter :3 ; +u32 flags; +u64 timestamp; +struct v4l2_vp9_segmentation seg; +struct v4l2_vp9_loop_filter lf; +}; + +struct rkvdec_vp9_ctx { +struct rkvdec_aux_buf priv_tbl; +struct rkvdec_aux_buf count_tbl; +struct v4l2_vp9_frame_symbol_counts inter_cnts; +struct v4l2_vp9_frame_symbol_counts intra_cnts; +struct v4l2_vp9_frame_context probability_tables; +struct v4l2_vp9_frame_context frame_context[4 ]; +struct rkvdec_vp9_frame_info cur; +struct rkvdec_vp9_frame_info last; +}; + +static void write_coeff_plane (const u8 coef[6 ][6 ][3 ],u8 *coeff_plane) +{ +unsigned int idx =0 , byte_count =0 ; +int k, m, n; +u8 p; + +for (k =0 ; k <6 ; k++) { +for (m =0 ; m <6 ; m++) { +for (n =0 ; n <3 ; n++) { + p = coef[k][m][n]; + coeff_plane[idx++] = p; + byte_count++; +if (byte_count ==27 ) { + idx +=5 ; + byte_count =0 ; + } + } + } + } +} + +static void init_intra_only_probs (struct rkvdec_ctx *ctx, +const struct rkvdec_vp9_run *run) +{ +const struct v4l2_ctrl_vp9_frame *dec_params; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_vp9_priv_tbl *tbl = vp9_ctx->priv_tbl.cpu; +struct rkvdec_vp9_intra_only_frame_probs *rkprobs; +const struct v4l2_vp9_frame_context *probs; +unsigned int i, j, k, m; + + rkprobs = &tbl->probs.intra_only; + dec_params = run->decode_params; + probs = &vp9_ctx->probability_tables; + +/* +* intra only 149 x 128 bits ,aligned to 152 x 128 bits coeff related +* prob 64 x 128 bits +*/ +for (i =0 ; i <ARRAY_SIZE (probs->coef); i++) { +for (j =0 ; j <ARRAY_SIZE (probs->coef[0 ]); j++) +write_coeff_plane (probs->coef[i][j][0 ], + rkprobs->coef_intra[i][j]); + } + +/* intra mode prob 80 x 128 bits */ +for (i =0 ; i <ARRAY_SIZE (v4l2_vp9_kf_y_mode_prob); i++) { +unsigned int byte_count =0 ; +int idx =0 ; + +/* vp9_kf_y_mode_prob */ +for (j =0 ; j <ARRAY_SIZE (v4l2_vp9_kf_y_mode_prob[0 ]); j++) { +for (k =0 ; k <ARRAY_SIZE (v4l2_vp9_kf_y_mode_prob[0 ][0 ]); + k++) { +u8 val = v4l2_vp9_kf_y_mode_prob[i][j][k]; + + rkprobs->intra_mode[i].y_mode[idx++] = val; + byte_count++; +if (byte_count ==27 ) { + byte_count =0 ; + idx +=5 ; + } + } + } + + idx =0 ; +if (i <4 ) { +for (m =0 ; m < (i <3 ?23 :21 ); m++) { +const u8 *ptr = (const u8 *)v4l2_vp9_kf_uv_mode_prob; + + rkprobs->intra_mode[i].uv_mode[idx++] = ptr[i *23 + m]; + } + } + } +} + +static void init_inter_probs (struct rkvdec_ctx *ctx, +const struct rkvdec_vp9_run *run) +{ +const struct v4l2_ctrl_vp9_frame *dec_params; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_vp9_priv_tbl *tbl = vp9_ctx->priv_tbl.cpu; +struct rkvdec_vp9_inter_frame_probs *rkprobs; +const struct v4l2_vp9_frame_context *probs; +unsigned int i, j, k; + + rkprobs = &tbl->probs.inter; + dec_params = run->decode_params; + probs = &vp9_ctx->probability_tables; + +/* +* inter probs +* 151 x 128 bits, aligned to 152 x 128 bits +* inter only +* intra_y_mode & inter_block info 6 x 128 bits +*/ + +memcpy (rkprobs->y_mode, probs->y_mode,sizeof (rkprobs->y_mode)); +memcpy (rkprobs->comp_mode, probs->comp_mode, +sizeof (rkprobs->comp_mode)); +memcpy (rkprobs->comp_ref, probs->comp_ref, +sizeof (rkprobs->comp_ref)); +memcpy (rkprobs->single_ref, probs->single_ref, +sizeof (rkprobs->single_ref)); +memcpy (rkprobs->inter_mode, probs->inter_mode, +sizeof (rkprobs->inter_mode)); +memcpy (rkprobs->interp_filter, probs->interp_filter, +sizeof (rkprobs->interp_filter)); + +/* 128 x 128 bits coeff related */ +for (i =0 ; i <ARRAY_SIZE (probs->coef); i++) { +for (j =0 ; j <ARRAY_SIZE (probs->coef[0 ]); j++) { +for (k =0 ; k <ARRAY_SIZE (probs->coef[0 ][0 ]); k++) +write_coeff_plane (probs->coef[i][j][k], + rkprobs->coef[k][i][j]); + } + } + +/* intra uv mode 6 x 128 */ +memcpy (rkprobs->uv_mode_0_2, &probs->uv_mode[0 ], +sizeof (rkprobs->uv_mode_0_2)); +memcpy (rkprobs->uv_mode_3_5, &probs->uv_mode[3 ], +sizeof (rkprobs->uv_mode_3_5)); +memcpy (rkprobs->uv_mode_6_8, &probs->uv_mode[6 ], +sizeof (rkprobs->uv_mode_6_8)); +memcpy (rkprobs->uv_mode_9, &probs->uv_mode[9 ], +sizeof (rkprobs->uv_mode_9)); + +/* mv related 6 x 128 */ +memcpy (rkprobs->mv.joint, probs->mv.joint, +sizeof (rkprobs->mv.joint)); +memcpy (rkprobs->mv.sign, probs->mv.sign, +sizeof (rkprobs->mv.sign)); +memcpy (rkprobs->mv.classes, probs->mv.classes, +sizeof (rkprobs->mv.classes)); +memcpy (rkprobs->mv.class0_bit, probs->mv.class0_bit, +sizeof (rkprobs->mv.class0_bit)); +memcpy (rkprobs->mv.bits, probs->mv.bits, +sizeof (rkprobs->mv.bits)); +memcpy (rkprobs->mv.class0_fr, probs->mv.class0_fr, +sizeof (rkprobs->mv.class0_fr)); +memcpy (rkprobs->mv.fr, probs->mv.fr, +sizeof (rkprobs->mv.fr)); +memcpy (rkprobs->mv.class0_hp, probs->mv.class0_hp, +sizeof (rkprobs->mv.class0_hp)); +memcpy (rkprobs->mv.hp, probs->mv.hp, +sizeof (rkprobs->mv.hp)); +} + +static void init_probs (struct rkvdec_ctx *ctx, +const struct rkvdec_vp9_run *run) +{ +const struct v4l2_ctrl_vp9_frame *dec_params; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_vp9_priv_tbl *tbl = vp9_ctx->priv_tbl.cpu; +struct rkvdec_vp9_probs *rkprobs = &tbl->probs; +const struct v4l2_vp9_segmentation *seg; +const struct v4l2_vp9_frame_context *probs; +bool intra_only; + + dec_params = run->decode_params; + probs = &vp9_ctx->probability_tables; + seg = &dec_params->seg; + +memset (rkprobs,0 ,sizeof (*rkprobs)); + + intra_only = !!(dec_params->flags & + (V4L2_VP9_FRAME_FLAG_KEY_FRAME | +V4L2_VP9_FRAME_FLAG_INTRA_ONLY )); + +/* sb info 5 x 128 bit */ +memcpy (rkprobs->partition, + intra_only ? v4l2_vp9_kf_partition_probs : probs->partition, +sizeof (rkprobs->partition)); + +memcpy (rkprobs->pred, seg->pred_probs,sizeof (rkprobs->pred)); +memcpy (rkprobs->tree, seg->tree_probs,sizeof (rkprobs->tree)); +memcpy (rkprobs->skip, probs->skip,sizeof (rkprobs->skip)); +memcpy (rkprobs->tx32, probs->tx32,sizeof (rkprobs->tx32)); +memcpy (rkprobs->tx16, probs->tx16,sizeof (rkprobs->tx16)); +memcpy (rkprobs->tx8, probs->tx8,sizeof (rkprobs->tx8)); +memcpy (rkprobs->is_inter, probs->is_inter,sizeof (rkprobs->is_inter)); + +if (intra_only) +init_intra_only_probs (ctx, run); +else +init_inter_probs (ctx, run); +} + +struct rkvdec_vp9_ref_reg { +u32 reg_frm_size; +u32 reg_hor_stride; +u32 reg_y_stride; +u32 reg_yuv_stride; +u32 reg_ref_base; +}; + +static struct rkvdec_vp9_ref_reg ref_regs[] = { + { + .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (0 ), + .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (0 ), + .reg_y_stride =RKVDEC_VP9_LAST_FRAME_YSTRIDE , + .reg_yuv_stride =RKVDEC_VP9_LAST_FRAME_YUVSTRIDE , + .reg_ref_base =RKVDEC_REG_VP9_LAST_FRAME_BASE , + }, + { + .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (1 ), + .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (1 ), + .reg_y_stride =RKVDEC_VP9_GOLDEN_FRAME_YSTRIDE , + .reg_yuv_stride =0 , + .reg_ref_base =RKVDEC_REG_VP9_GOLDEN_FRAME_BASE , + }, + { + .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (2 ), + .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (2 ), + .reg_y_stride =RKVDEC_VP9_ALTREF_FRAME_YSTRIDE , + .reg_yuv_stride =0 , + .reg_ref_base =RKVDEC_REG_VP9_ALTREF_FRAME_BASE , + } +}; + +static struct rkvdec_decoded_buffer * +get_ref_buf (struct rkvdec_ctx *ctx,struct vb2_v4l2_buffer *dst,u64 timestamp) +{ +struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; +struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; +int buf_idx; + +/* +* If a ref is unused or invalid, address of current destination +* buffer is returned. +*/ + buf_idx =vb2_find_timestamp (cap_q, timestamp,0 ); +if (buf_idx <0 ) +return vb2_to_rkvdec_decoded_buf (&dst->vb2_buf); + +return vb2_to_rkvdec_decoded_buf (vb2_get_buffer (cap_q, buf_idx)); +} + +static dma_addr_t get_mv_base_addr (struct rkvdec_decoded_buffer *buf) +{ +unsigned int aligned_pitch, aligned_height, yuv_len; + + aligned_height =round_up (buf->vp9.height,64 ); + aligned_pitch =round_up (buf->vp9.width * buf->vp9.bit_depth,512 ) /8 ; + yuv_len = (aligned_height * aligned_pitch *3 ) /2 ; + +return vb2_dma_contig_plane_dma_addr (&buf->base.vb.vb2_buf,0 ) + + yuv_len; +} + +static void config_ref_registers (struct rkvdec_ctx *ctx, +const struct rkvdec_vp9_run *run, +struct rkvdec_decoded_buffer *ref_buf, +struct rkvdec_vp9_ref_reg *ref_reg) +{ +unsigned int aligned_pitch, aligned_height, y_len, yuv_len; +struct rkvdec_dev *rkvdec = ctx->dev; + + aligned_height =round_up (ref_buf->vp9.height,64 ); +writel_relaxed (RKVDEC_VP9_FRAMEWIDTH (ref_buf->vp9.width) | +RKVDEC_VP9_FRAMEHEIGHT (ref_buf->vp9.height), + rkvdec->regs + ref_reg->reg_frm_size); + +writel_relaxed (vb2_dma_contig_plane_dma_addr (&ref_buf->base.vb.vb2_buf,0 ), + rkvdec->regs + ref_reg->reg_ref_base); + +if (&ref_buf->base.vb == run->base.bufs.dst) +return ; + + aligned_pitch =round_up (ref_buf->vp9.width * ref_buf->vp9.bit_depth,512 ) /8 ; + y_len = aligned_height * aligned_pitch; + yuv_len = (y_len *3 ) /2 ; + +writel_relaxed (RKVDEC_HOR_Y_VIRSTRIDE (aligned_pitch /16 ) | +RKVDEC_HOR_UV_VIRSTRIDE (aligned_pitch /16 ), + rkvdec->regs + ref_reg->reg_hor_stride); +writel_relaxed (RKVDEC_VP9_REF_YSTRIDE (y_len /16 ), + rkvdec->regs + ref_reg->reg_y_stride); + +if (!ref_reg->reg_yuv_stride) +return ; + +writel_relaxed (RKVDEC_VP9_REF_YUVSTRIDE (yuv_len /16 ), + rkvdec->regs + ref_reg->reg_yuv_stride); +} + +static void config_seg_registers (struct rkvdec_ctx *ctx,unsigned int segid) +{ +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +const struct v4l2_vp9_segmentation *seg; +struct rkvdec_dev *rkvdec = ctx->dev; +s16 feature_val; +int feature_id; +u32 val =0 ; + + seg = vp9_ctx->last.valid ? &vp9_ctx->last.seg : &vp9_ctx->cur.seg; + feature_id =V4L2_VP9_SEG_LVL_ALT_Q ; +if (v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid)) { + feature_val = seg->feature_data[segid][feature_id]; + val |=RKVDEC_SEGID_FRAME_QP_DELTA_EN (1 ) | +RKVDEC_SEGID_FRAME_QP_DELTA (feature_val); + } + + feature_id =V4L2_VP9_SEG_LVL_ALT_L ; +if (v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid)) { + feature_val = seg->feature_data[segid][feature_id]; + val |=RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE_EN (1 ) | +RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE (feature_val); + } + + feature_id =V4L2_VP9_SEG_LVL_REF_FRAME ; +if (v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid)) { + feature_val = seg->feature_data[segid][feature_id]; + val |=RKVDEC_SEGID_REFERINFO_EN (1 ) | +RKVDEC_SEGID_REFERINFO (feature_val); + } + + feature_id =V4L2_VP9_SEG_LVL_SKIP ; +if (v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid)) + val |=RKVDEC_SEGID_FRAME_SKIP_EN (1 ); + +if (!segid && + (seg->flags &V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE )) + val |=RKVDEC_SEGID_ABS_DELTA (1 ); + +writel_relaxed (val, rkvdec->regs +RKVDEC_VP9_SEGID_GRP (segid)); +} + +static void update_dec_buf_info (struct rkvdec_decoded_buffer *buf, +const struct v4l2_ctrl_vp9_frame *dec_params) +{ + buf->vp9.width = dec_params->frame_width_minus_1 +1 ; + buf->vp9.height = dec_params->frame_height_minus_1 +1 ; + buf->vp9.bit_depth = dec_params->bit_depth; +} + +static void update_ctx_cur_info (struct rkvdec_vp9_ctx *vp9_ctx, +struct rkvdec_decoded_buffer *buf, +const struct v4l2_ctrl_vp9_frame *dec_params) +{ + vp9_ctx->cur.valid = true; + vp9_ctx->cur.reference_mode = dec_params->reference_mode; + vp9_ctx->cur.interpolation_filter = dec_params->interpolation_filter; + vp9_ctx->cur.flags = dec_params->flags; + vp9_ctx->cur.timestamp = buf->base.vb.vb2_buf.timestamp; + vp9_ctx->cur.seg = dec_params->seg; + vp9_ctx->cur.lf = dec_params->lf; +} + +static void update_ctx_last_info (struct rkvdec_vp9_ctx *vp9_ctx) +{ + vp9_ctx->last = vp9_ctx->cur; +} + +static void config_registers (struct rkvdec_ctx *ctx, +const struct rkvdec_vp9_run *run) +{ +unsigned int y_len, uv_len, yuv_len, bit_depth, aligned_height, aligned_pitch, stream_len; +const struct v4l2_ctrl_vp9_frame *dec_params; +struct rkvdec_decoded_buffer *ref_bufs[3 ]; +struct rkvdec_decoded_buffer *dst, *last, *mv_ref; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +u32 val, last_frame_info =0 ; +const struct v4l2_vp9_segmentation *seg; +struct rkvdec_dev *rkvdec = ctx->dev; +dma_addr_t addr; +bool intra_only; +unsigned int i; + + dec_params = run->decode_params; + dst =vb2_to_rkvdec_decoded_buf (&run->base.bufs.dst->vb2_buf); + ref_bufs[0 ] =get_ref_buf (ctx, &dst->base.vb, dec_params->last_frame_ts); + ref_bufs[1 ] =get_ref_buf (ctx, &dst->base.vb, dec_params->golden_frame_ts); + ref_bufs[2 ] =get_ref_buf (ctx, &dst->base.vb, dec_params->alt_frame_ts); + +if (vp9_ctx->last.valid) + last =get_ref_buf (ctx, &dst->base.vb, vp9_ctx->last.timestamp); +else + last = dst; + +update_dec_buf_info (dst, dec_params); +update_ctx_cur_info (vp9_ctx, dst, dec_params); + seg = &dec_params->seg; + + intra_only = !!(dec_params->flags & + (V4L2_VP9_FRAME_FLAG_KEY_FRAME | +V4L2_VP9_FRAME_FLAG_INTRA_ONLY )); + +writel_relaxed (RKVDEC_MODE (RKVDEC_MODE_VP9 ), + rkvdec->regs +RKVDEC_REG_SYSCTRL ); + + bit_depth = dec_params->bit_depth; + aligned_height =round_up (ctx->decoded_fmt.fmt.pix_mp.height,64 ); + + aligned_pitch =round_up (ctx->decoded_fmt.fmt.pix_mp.width * + bit_depth, +512 ) /8 ; + y_len = aligned_height * aligned_pitch; + uv_len = y_len /2 ; + yuv_len = y_len + uv_len; + +writel_relaxed (RKVDEC_Y_HOR_VIRSTRIDE (aligned_pitch /16 ) | +RKVDEC_UV_HOR_VIRSTRIDE (aligned_pitch /16 ), + rkvdec->regs +RKVDEC_REG_PICPAR ); +writel_relaxed (RKVDEC_Y_VIRSTRIDE (y_len /16 ), + rkvdec->regs +RKVDEC_REG_Y_VIRSTRIDE ); +writel_relaxed (RKVDEC_YUV_VIRSTRIDE (yuv_len /16 ), + rkvdec->regs +RKVDEC_REG_YUV_VIRSTRIDE ); + + stream_len =vb2_get_plane_payload (&run->base.bufs.src->vb2_buf,0 ); +writel_relaxed (RKVDEC_STRM_LEN (stream_len), + rkvdec->regs +RKVDEC_REG_STRM_LEN ); + +/* +* Reset count buffer, because decoder only output intra related syntax +* counts when decoding intra frame, but update entropy need to update +* all the probabilities. +*/ +if (intra_only) +memset (vp9_ctx->count_tbl.cpu,0 , vp9_ctx->count_tbl.size); + + vp9_ctx->cur.segmapid = vp9_ctx->last.segmapid; +if (!intra_only && + !(dec_params->flags &V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT ) && + (!(seg->flags &V4L2_VP9_SEGMENTATION_FLAG_ENABLED ) || + (seg->flags &V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP ))) + vp9_ctx->cur.segmapid++; + +for (i =0 ; i <ARRAY_SIZE (ref_bufs); i++) +config_ref_registers (ctx, run, ref_bufs[i], &ref_regs[i]); + +for (i =0 ; i <8 ; i++) +config_seg_registers (ctx, i); + +writel_relaxed (RKVDEC_VP9_TX_MODE (vp9_ctx->cur.tx_mode) | +RKVDEC_VP9_FRAME_REF_MODE (dec_params->reference_mode), + rkvdec->regs +RKVDEC_VP9_CPRHEADER_CONFIG ); + +if (!intra_only) { +const struct v4l2_vp9_loop_filter *lf; +s8 delta; + +if (vp9_ctx->last.valid) + lf = &vp9_ctx->last.lf; +else + lf = &vp9_ctx->cur.lf; + + val =0 ; +for (i =0 ; i <ARRAY_SIZE (lf->ref_deltas); i++) { + delta = lf->ref_deltas[i]; + val |=RKVDEC_REF_DELTAS_LASTFRAME (i, delta); + } + +writel_relaxed (val, + rkvdec->regs +RKVDEC_VP9_REF_DELTAS_LASTFRAME ); + +for (i =0 ; i <ARRAY_SIZE (lf->mode_deltas); i++) { + delta = lf->mode_deltas[i]; + last_frame_info |=RKVDEC_MODE_DELTAS_LASTFRAME (i, + delta); + } + } + +if (vp9_ctx->last.valid && !intra_only && + vp9_ctx->last.seg.flags &V4L2_VP9_SEGMENTATION_FLAG_ENABLED ) + last_frame_info |=RKVDEC_SEG_EN_LASTFRAME ; + +if (vp9_ctx->last.valid && + vp9_ctx->last.flags &V4L2_VP9_FRAME_FLAG_SHOW_FRAME ) + last_frame_info |=RKVDEC_LAST_SHOW_FRAME ; + +if (vp9_ctx->last.valid && + vp9_ctx->last.flags & + (V4L2_VP9_FRAME_FLAG_KEY_FRAME |V4L2_VP9_FRAME_FLAG_INTRA_ONLY )) + last_frame_info |=RKVDEC_LAST_INTRA_ONLY ; + +if (vp9_ctx->last.valid && + last->vp9.width == dst->vp9.width && + last->vp9.height == dst->vp9.height) + last_frame_info |=RKVDEC_LAST_WIDHHEIGHT_EQCUR ; + +writel_relaxed (last_frame_info, + rkvdec->regs +RKVDEC_VP9_INFO_LASTFRAME ); + +writel_relaxed (stream_len - dec_params->compressed_header_size - + dec_params->uncompressed_header_size, + rkvdec->regs +RKVDEC_VP9_LASTTILE_SIZE ); + +for (i =0 ; !intra_only && i <ARRAY_SIZE (ref_bufs); i++) { +unsigned int refw = ref_bufs[i]->vp9.width; +unsigned int refh = ref_bufs[i]->vp9.height; +u32 hscale, vscale; + + hscale = (refw <<14 ) / dst->vp9.width; + vscale = (refh <<14 ) / dst->vp9.height; +writel_relaxed (RKVDEC_VP9_REF_HOR_SCALE (hscale) | +RKVDEC_VP9_REF_VER_SCALE (vscale), + rkvdec->regs +RKVDEC_VP9_REF_SCALE (i)); + } + + addr =vb2_dma_contig_plane_dma_addr (&dst->base.vb.vb2_buf,0 ); +writel_relaxed (addr, rkvdec->regs +RKVDEC_REG_DECOUT_BASE ); + addr =vb2_dma_contig_plane_dma_addr (&run->base.bufs.src->vb2_buf,0 ); +writel_relaxed (addr, rkvdec->regs +RKVDEC_REG_STRM_RLC_BASE ); +writel_relaxed (vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , probs), + rkvdec->regs +RKVDEC_REG_CABACTBL_PROB_BASE ); +writel_relaxed (vp9_ctx->count_tbl.dma, + rkvdec->regs +RKVDEC_REG_VP9COUNT_BASE ); + +writel_relaxed (vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , segmap) + + (RKVDEC_VP9_MAX_SEGMAP_SIZE * vp9_ctx->cur.segmapid), + rkvdec->regs +RKVDEC_REG_VP9_SEGIDCUR_BASE ); +writel_relaxed (vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , segmap) + + (RKVDEC_VP9_MAX_SEGMAP_SIZE * (!vp9_ctx->cur.segmapid)), + rkvdec->regs +RKVDEC_REG_VP9_SEGIDLAST_BASE ); + +if (!intra_only && + !(dec_params->flags &V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT ) && + vp9_ctx->last.valid) + mv_ref = last; +else + mv_ref = dst; + +writel_relaxed (get_mv_base_addr (mv_ref), + rkvdec->regs +RKVDEC_VP9_REF_COLMV_BASE ); + +writel_relaxed (ctx->decoded_fmt.fmt.pix_mp.width | + (ctx->decoded_fmt.fmt.pix_mp.height <<16 ), + rkvdec->regs +RKVDEC_REG_PERFORMANCE_CYCLE ); +} + +static int validate_dec_params (struct rkvdec_ctx *ctx, +const struct v4l2_ctrl_vp9_frame *dec_params) +{ +unsigned int aligned_width, aligned_height; + +/* We only support profile 0. */ +if (dec_params->profile !=0 ) { +dev_err (ctx->dev->dev,"unsupported profile %d\n" , + dec_params->profile); +return -EINVAL ; + } + + aligned_width =round_up (dec_params->frame_width_minus_1 +1 ,64 ); + aligned_height =round_up (dec_params->frame_height_minus_1 +1 ,64 ); + +/* +* Userspace should update the capture/decoded format when the +* resolution changes. +*/ +if (aligned_width != ctx->decoded_fmt.fmt.pix_mp.width || + aligned_height != ctx->decoded_fmt.fmt.pix_mp.height) { +dev_err (ctx->dev->dev, +"unexpected bitstream resolution %dx%d\n" , + dec_params->frame_width_minus_1 +1 , + dec_params->frame_height_minus_1 +1 ); +return -EINVAL ; + } + +return 0 ; +} + +static int rkvdec_vp9_run_preamble (struct rkvdec_ctx *ctx, +struct rkvdec_vp9_run *run) +{ +const struct v4l2_ctrl_vp9_frame *dec_params; +const struct v4l2_ctrl_vp9_compressed_hdr *prob_updates; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct v4l2_ctrl *ctrl; +unsigned int fctx_idx; +int ret; + +/* v4l2-specific stuff */ +rkvdec_run_preamble (ctx, &run->base); + + ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl, +V4L2_CID_STATELESS_VP9_FRAME ); +if (WARN_ON (!ctrl)) +return -EINVAL ; + dec_params = ctrl->p_cur.p; + + ret =validate_dec_params (ctx, dec_params); +if (ret) +return ret; + + run->decode_params = dec_params; + + ctrl =v4l2_ctrl_find (&ctx->ctrl_hdl,V4L2_CID_STATELESS_VP9_COMPRESSED_HDR ); +if (WARN_ON (!ctrl)) +return -EINVAL ; + prob_updates = ctrl->p_cur.p; + vp9_ctx->cur.tx_mode = prob_updates->tx_mode; + +/* +* vp9 stuff +* +* by this point the userspace has done all parts of 6.2 uncompressed_header() +* except this fragment: +* if ( FrameIsIntra || error_resilient_mode ) { +* setup_past_independence ( ) +* if ( frame_type == KEY_FRAME || error_resilient_mode == 1 || +* reset_frame_context == 3 ) { +* for ( i = 0; i < 4; i ++ ) { +* save_probs( i ) +* } +* } else if ( reset_frame_context == 2 ) { +* save_probs( frame_context_idx ) +* } +* frame_context_idx = 0 +* } +*/ + fctx_idx =v4l2_vp9_reset_frame_ctx (dec_params, vp9_ctx->frame_context); + vp9_ctx->cur.frame_context_idx = fctx_idx; + +/* 6.1 frame(sz): load_probs() and load_probs2() */ + vp9_ctx->probability_tables = vp9_ctx->frame_context[fctx_idx]; + +/* +* The userspace has also performed 6.3 compressed_header(), but handling the +* probs in a special way. All probs which need updating, except MV-related, +* have been read from the bitstream and translated through inv_map_table[], +* but no 6.3.6 inv_recenter_nonneg(v, m) has been performed. The values passed +* by userspace are either translated values (there are no 0 values in +* inv_map_table[]), or zero to indicate no update. All MV-related probs which need +* updating have been read from the bitstream and (mv_prob << 1) | 1 has been +* performed. The values passed by userspace are either new values +* to replace old ones (the above mentioned shift and bitwise or never result in +* a zero) or zero to indicate no update. +* fw_update_probs() performs actual probs updates or leaves probs as-is +* for values for which a zero was passed from userspace. +*/ +v4l2_vp9_fw_update_probs (&vp9_ctx->probability_tables, prob_updates, dec_params); + +return 0 ; +} + +static int rkvdec_vp9_run (struct rkvdec_ctx *ctx) +{ +struct rkvdec_dev *rkvdec = ctx->dev; +struct rkvdec_vp9_run run = { }; +int ret; + + ret =rkvdec_vp9_run_preamble (ctx, &run); +if (ret) { +rkvdec_run_postamble (ctx, &run.base); +return ret; + } + +/* Prepare probs. */ +init_probs (ctx, &run); + +/* Configure hardware registers. */ +config_registers (ctx, &run); + +rkvdec_run_postamble (ctx, &run.base); + +schedule_delayed_work (&rkvdec->watchdog_work,msecs_to_jiffies (2000 )); + +writel (1 , rkvdec->regs +RKVDEC_REG_PREF_LUMA_CACHE_COMMAND ); +writel (1 , rkvdec->regs +RKVDEC_REG_PREF_CHR_CACHE_COMMAND ); + +writel (0xe , rkvdec->regs +RKVDEC_REG_STRMD_ERR_EN ); +/* Start decoding! */ +writel (RKVDEC_INTERRUPT_DEC_E |RKVDEC_CONFIG_DEC_CLK_GATE_E | +RKVDEC_TIMEOUT_E |RKVDEC_BUF_EMPTY_E , + rkvdec->regs +RKVDEC_REG_INTERRUPT ); + +return 0 ; +} + +#define copy_tx_and_skip (p1, p2) \ +do { \ + memcpy((p1)->tx8, (p2)->tx8, sizeof((p1)->tx8)); \ + memcpy((p1)->tx16, (p2)->tx16, sizeof((p1)->tx16)); \ + memcpy((p1)->tx32, (p2)->tx32, sizeof((p1)->tx32)); \ + memcpy((p1)->skip, (p2)->skip, sizeof((p1)->skip)); \ +} while (0) + +static void rkvdec_vp9_done (struct rkvdec_ctx *ctx, +struct vb2_v4l2_buffer *src_buf, +struct vb2_v4l2_buffer *dst_buf, +enum vb2_buffer_state result) +{ +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +unsigned int fctx_idx; + +/* v4l2-specific stuff */ +if (result ==VB2_BUF_STATE_ERROR ) + goto out_update_last; + +/* +* vp9 stuff +* +* 6.1.2 refresh_probs() +* +* In the spec a complementary condition goes last in 6.1.2 refresh_probs(), +* but it makes no sense to perform all the activities from the first "if" +* there if we actually are not refreshing the frame context. On top of that, +* because of 6.2 uncompressed_header() whenever error_resilient_mode == 1, +* refresh_frame_context == 0. Consequently, if we don't jump to out_update_last +* it means error_resilient_mode must be 0. +*/ +if (!(vp9_ctx->cur.flags &V4L2_VP9_FRAME_FLAG_REFRESH_FRAME_CTX )) + goto out_update_last; + + fctx_idx = vp9_ctx->cur.frame_context_idx; + +if (!(vp9_ctx->cur.flags &V4L2_VP9_FRAME_FLAG_PARALLEL_DEC_MODE )) { +/* error_resilient_mode == 0 && frame_parallel_decoding_mode == 0 */ +struct v4l2_vp9_frame_context *probs = &vp9_ctx->probability_tables; +bool frame_is_intra = vp9_ctx->cur.flags & + (V4L2_VP9_FRAME_FLAG_KEY_FRAME |V4L2_VP9_FRAME_FLAG_INTRA_ONLY ); +struct tx_and_skip { +u8 tx8[2 ][1 ]; +u8 tx16[2 ][2 ]; +u8 tx32[2 ][3 ]; +u8 skip[3 ]; + } _tx_skip, *tx_skip = &_tx_skip; +struct v4l2_vp9_frame_symbol_counts *counts; + +/* buffer the forward-updated TX and skip probs */ +if (frame_is_intra) +copy_tx_and_skip (tx_skip, probs); + +/* 6.1.2 refresh_probs(): load_probs() and load_probs2() */ + *probs = vp9_ctx->frame_context[fctx_idx]; + +/* if FrameIsIntra then undo the effect of load_probs2() */ +if (frame_is_intra) +copy_tx_and_skip (probs, tx_skip); + + counts = frame_is_intra ? &vp9_ctx->intra_cnts : &vp9_ctx->inter_cnts; +v4l2_vp9_adapt_coef_probs (probs, counts, + !vp9_ctx->last.valid || + vp9_ctx->last.flags &V4L2_VP9_FRAME_FLAG_KEY_FRAME , + frame_is_intra); +if (!frame_is_intra) { +const struct rkvdec_vp9_inter_frame_symbol_counts *inter_cnts; +u32 classes[2 ][11 ]; +int i; + + inter_cnts = vp9_ctx->count_tbl.cpu; +for (i =0 ; i <ARRAY_SIZE (classes); ++i) +memcpy (classes[i], inter_cnts->classes[i],sizeof (classes[0 ])); + counts->classes = &classes; + +/* load_probs2() already done */ +v4l2_vp9_adapt_noncoef_probs (&vp9_ctx->probability_tables, counts, + vp9_ctx->cur.reference_mode, + vp9_ctx->cur.interpolation_filter, + vp9_ctx->cur.tx_mode, vp9_ctx->cur.flags); + } + } + +/* 6.1.2 refresh_probs(): save_probs(fctx_idx) */ + vp9_ctx->frame_context[fctx_idx] = vp9_ctx->probability_tables; + +out_update_last: +update_ctx_last_info (vp9_ctx); +} + +static void rkvdec_init_v4l2_vp9_count_tbl (struct rkvdec_ctx *ctx) +{ +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu; +struct rkvdec_vp9_inter_frame_symbol_counts *inter_cnts = vp9_ctx->count_tbl.cpu; +int i, j, k, l, m; + + vp9_ctx->inter_cnts.partition = &inter_cnts->partition; + vp9_ctx->inter_cnts.skip = &inter_cnts->skip; + vp9_ctx->inter_cnts.intra_inter = &inter_cnts->inter; + vp9_ctx->inter_cnts.tx32p = &inter_cnts->tx32p; + vp9_ctx->inter_cnts.tx16p = &inter_cnts->tx16p; + vp9_ctx->inter_cnts.tx8p = &inter_cnts->tx8p; + + vp9_ctx->intra_cnts.partition = (u32 (*)[16 ][4 ])(&intra_cnts->partition); + vp9_ctx->intra_cnts.skip = &intra_cnts->skip; + vp9_ctx->intra_cnts.intra_inter = &intra_cnts->intra; + vp9_ctx->intra_cnts.tx32p = &intra_cnts->tx32p; + vp9_ctx->intra_cnts.tx16p = &intra_cnts->tx16p; + vp9_ctx->intra_cnts.tx8p = &intra_cnts->tx8p; + + vp9_ctx->inter_cnts.y_mode = &inter_cnts->y_mode; + vp9_ctx->inter_cnts.uv_mode = &inter_cnts->uv_mode; + vp9_ctx->inter_cnts.comp = &inter_cnts->comp; + vp9_ctx->inter_cnts.comp_ref = &inter_cnts->comp_ref; + vp9_ctx->inter_cnts.single_ref = &inter_cnts->single_ref; + vp9_ctx->inter_cnts.mv_mode = &inter_cnts->mv_mode; + vp9_ctx->inter_cnts.filter = &inter_cnts->filter; + vp9_ctx->inter_cnts.mv_joint = &inter_cnts->mv_joint; + vp9_ctx->inter_cnts.sign = &inter_cnts->sign; +/* +* rk hardware actually uses "u32 classes[2][11 + 1];" +* instead of "u32 classes[2][11];", so this must be explicitly +* copied into vp9_ctx->classes when passing the data to the +* vp9 library function +*/ + vp9_ctx->inter_cnts.class0 = &inter_cnts->class0; + vp9_ctx->inter_cnts.bits = &inter_cnts->bits; + vp9_ctx->inter_cnts.class0_fp = &inter_cnts->class0_fp; + vp9_ctx->inter_cnts.fp = &inter_cnts->fp; + vp9_ctx->inter_cnts.class0_hp = &inter_cnts->class0_hp; + vp9_ctx->inter_cnts.hp = &inter_cnts->hp; + +#define INNERMOST_LOOP \ + do { \ + for (m = 0; m < ARRAY_SIZE(vp9_ctx->inter_cnts.coeff[0][0][0][0]); ++m) {\ + vp9_ctx->inter_cnts.coeff[i][j][k][l][m] = \ + &inter_cnts->ref_cnt[k][i][j][l][m].coeff; \ + vp9_ctx->inter_cnts.eob[i][j][k][l][m][0] = \ + &inter_cnts->ref_cnt[k][i][j][l][m].eob[0]; \ + vp9_ctx->inter_cnts.eob[i][j][k][l][m][1] = \ + &inter_cnts->ref_cnt[k][i][j][l][m].eob[1]; \ + \ + vp9_ctx->intra_cnts.coeff[i][j][k][l][m] = \ + &intra_cnts->ref_cnt[k][i][j][l][m].coeff; \ + vp9_ctx->intra_cnts.eob[i][j][k][l][m][0] = \ + &intra_cnts->ref_cnt[k][i][j][l][m].eob[0]; \ + vp9_ctx->intra_cnts.eob[i][j][k][l][m][1] = \ + &intra_cnts->ref_cnt[k][i][j][l][m].eob[1]; \ + } \ + } while (0) + +for (i =0 ; i <ARRAY_SIZE (vp9_ctx->inter_cnts.coeff); ++i) +for (j =0 ; j <ARRAY_SIZE (vp9_ctx->inter_cnts.coeff[0 ]); ++j) +for (k =0 ; k <ARRAY_SIZE (vp9_ctx->inter_cnts.coeff[0 ][0 ]); ++k) +for (l =0 ; l <ARRAY_SIZE (vp9_ctx->inter_cnts.coeff[0 ][0 ][0 ]); ++l) +INNERMOST_LOOP ; +#undef INNERMOST_LOOP +} + +static int rkvdec_vp9_start (struct rkvdec_ctx *ctx) +{ +struct rkvdec_dev *rkvdec = ctx->dev; +struct rkvdec_vp9_priv_tbl *priv_tbl; +struct rkvdec_vp9_ctx *vp9_ctx; +unsigned char *count_tbl; +int ret; + + vp9_ctx =kzalloc (sizeof (*vp9_ctx),GFP_KERNEL ); +if (!vp9_ctx) +return -ENOMEM ; + + ctx->priv = vp9_ctx; + + priv_tbl =dma_alloc_coherent (rkvdec->dev,sizeof (*priv_tbl), + &vp9_ctx->priv_tbl.dma,GFP_KERNEL ); +if (!priv_tbl) { + ret = -ENOMEM ; + goto err_free_ctx; + } + + vp9_ctx->priv_tbl.size =sizeof (*priv_tbl); + vp9_ctx->priv_tbl.cpu = priv_tbl; +memset (priv_tbl,0 ,sizeof (*priv_tbl)); + + count_tbl =dma_alloc_coherent (rkvdec->dev,RKVDEC_VP9_COUNT_SIZE , + &vp9_ctx->count_tbl.dma,GFP_KERNEL ); +if (!count_tbl) { + ret = -ENOMEM ; + goto err_free_priv_tbl; + } + + vp9_ctx->count_tbl.size =RKVDEC_VP9_COUNT_SIZE ; + vp9_ctx->count_tbl.cpu = count_tbl; +memset (count_tbl,0 ,sizeof (*count_tbl)); +rkvdec_init_v4l2_vp9_count_tbl (ctx); + +return 0 ; + +err_free_priv_tbl: +dma_free_coherent (rkvdec->dev, vp9_ctx->priv_tbl.size, + vp9_ctx->priv_tbl.cpu, vp9_ctx->priv_tbl.dma); + +err_free_ctx: +kfree (vp9_ctx); +return ret; +} + +static void rkvdec_vp9_stop (struct rkvdec_ctx *ctx) +{ +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_dev *rkvdec = ctx->dev; + +dma_free_coherent (rkvdec->dev, vp9_ctx->count_tbl.size, + vp9_ctx->count_tbl.cpu, vp9_ctx->count_tbl.dma); +dma_free_coherent (rkvdec->dev, vp9_ctx->priv_tbl.size, + vp9_ctx->priv_tbl.cpu, vp9_ctx->priv_tbl.dma); +kfree (vp9_ctx); +} + +static int rkvdec_vp9_adjust_fmt (struct rkvdec_ctx *ctx, +struct v4l2_format *f) +{ +struct v4l2_pix_format_mplane *fmt = &f->fmt.pix_mp; + + fmt->num_planes =1 ; +if (!fmt->plane_fmt[0 ].sizeimage) + fmt->plane_fmt[0 ].sizeimage = fmt->width * fmt->height *2 ; +return 0 ; +} + +const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops = { + .adjust_fmt = rkvdec_vp9_adjust_fmt, + .start = rkvdec_vp9_start, + .stop = rkvdec_vp9_stop, + .run = rkvdec_vp9_run, + .done = rkvdec_vp9_done, +};drivers/staging/media/rkvdec/rkvdec.c +0
-0
drivers/staging/media/rkvdec/rkvdec.c static const struct rkvdec_ctrls rkvdec_h264_ctrls = { · line 103
Quoted 6 lines
drivers/staging/media/rkvdec/rkvdec.c +1
-1@@ -99,10 +99,30 @@ static const struct rkvdec_ctrls rkvdec_h264_ctrls = { .num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs), }; -static const u32 rkvdec_h264_decoded_fmts[] = { +static const u32 rkvdec_h264_vp9_decoded_fmts[] = {V4L2_PIX_FMT_NV12 ,
For H.264 rkvdec HW supports additional formats: V4L2_PIX_FMT_NV15, V4L2_PIX_FMT_NV16 and V4L2_PIX_FMT_NV20. Not all of those are upstreamed yet and thus not supported by rkvdec driver - but I think we should introduce a seperate rkvdec_vp9_decoded_fmts already a this point. (To avoid unnecessary diff afterwards)
Quoted 34 lines
drivers/staging/media/rkvdec/rkvdec.c +23
-2}; +static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = { + { + .cfg.id =V4L2_CID_STATELESS_VP9_FRAME , + }, + { + .cfg.id =V4L2_CID_STATELESS_VP9_COMPRESSED_HDR , + }, + { + .cfg.id =V4L2_CID_MPEG_VIDEO_VP9_PROFILE , + .cfg.min =V4L2_MPEG_VIDEO_VP9_PROFILE_0 , + .cfg.max =V4L2_MPEG_VIDEO_VP9_PROFILE_0 , + .cfg.def =V4L2_MPEG_VIDEO_VP9_PROFILE_0 , + }, +}; + +static const struct rkvdec_ctrls rkvdec_vp9_ctrls = { + .ctrls = rkvdec_vp9_ctrl_descs, + .num_ctrls =ARRAY_SIZE (rkvdec_vp9_ctrl_descs), +}; +static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { { .fourcc =V4L2_PIX_FMT_H264_SLICE ,@@ -116,8 +136,23 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { }, .ctrls = &rkvdec_h264_ctrls, .ops = &rkvdec_h264_fmt_ops, - .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts), - .decoded_fmts = rkvdec_h264_decoded_fmts, + .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts), + .decoded_fmts = rkvdec_h264_vp9_decoded_fmts, + },
drivers/staging/media/rkvdec/rkvdec.c static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { · line 151
Quoted 10 lines
drivers/staging/media/rkvdec/rkvdec.c +10
-0+ { + .fourcc = V4L2_PIX_FMT_VP9_FRAME, + .frmsize = { + .min_width = 64, + .max_width = 4096, + .step_width = 64, + .min_height = 64, + .max_height = 2304, + .step_height = 64, + },
I checked (available) documentation and couldn't find any hint to the .step_width and .step_height, but I'm not sure that's correct: taking
this values here neither framesize of 3840x2160 nor 1280x720 would be possible - but the HW seems to have no problem with those, i.e. decoding works fine.
Given the output format is the same as the (only) currently supported H.264 output format (NV12) and those steps are usually for alignment purposes need by the HW , I strongly guess .step_height and .step_width are the same as V4L2_PIX_FMT_H264_SLICE has.
Regards,
Alex
Quoted 66 lines
drivers/staging/media/rkvdec/rkvdec.c +14
-1+ .ctrls = &rkvdec_vp9_ctrls, + .ops = &rkvdec_vp9_fmt_ops, + .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts), + .decoded_fmts = rkvdec_h264_vp9_decoded_fmts, } };@@ -319,7 +354,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;const struct rkvdec_coded_fmt_desc *desc;struct v4l2_format *cap_fmt; -struct vb2_queue *peer_vq; +struct vb2_queue *peer_vq, *vq;int ret;/* @@ -331,6 +366,15 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,if (vb2_is_busy (peer_vq))return -EBUSY ; +/* +* Some codecs like VP9 can contain dynamic resolution changes which +* are currently not supported by the V4L2 API or driver, so return +* an error if userspace tries to reconfigure the output format. +*/ + vq =v4l2_m2m_get_vq (m2m_ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ); +if (vb2_is_busy (vq)) +return -EINVAL ; + ret =rkvdec_s_fmt (file, priv, f, rkvdec_try_output_fmt);if (ret)return ret;drivers/staging/media/rkvdec/rkvdec.h +9
-3@@ -42,14 +42,18 @@ struct rkvdec_run {struct rkvdec_vp9_decoded_buffer_info {/* Info needed when the decoded frame serves as a reference frame. */ -u16 width; -u16 height; -u32 bit_depth :4 ; +unsigned short width; +unsigned short height; +unsigned int bit_depth :4 ; };struct rkvdec_decoded_buffer {/* Must be the first field in this struct. */ struct v4l2_m2m_buffer base; + +union { +struct rkvdec_vp9_decoded_buffer_info vp9; + }; }; static inline struct rkvdec_decoded_buffer *@@ -116,4 +120,6 @@ void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);void rkvdec_run_postamble (struct rkvdec_ctx *ctx,struct rkvdec_run *run);extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops; +extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; +#endif /* RKVDEC_H_ */
Re: [PATCH v7 07/11] media: rkvdec: Add the VP9 backend
Hi Alex,
W dniu 20.10.2021 o 01:24, Alex Bee pisze:
Quoted 21 lines
Hi Andrzej,
Am 29.09.21 um 18:04 schrieb Andrzej Pietrasiewicz:
Quoted 18 lines
From: Boris Brezillon <[email protected]>
The Rockchip VDEC supports VP9 profile 0 up to 4096x2304@30fps. Add a backend for this new format.
Signed-off-by Boris Brezillon <[email protected]>Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Adrian Ratiu <[email protected]>Co-developed-by Andrzej Pietrasiewicz <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>---
drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +-drivers/staging/media/rkvdec/rkvdec-vp9.c| 1078 +++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +-5 files changed, 1137 insertions(+), 8 deletions(-)create mode 100644
drivers/staging/media/rkvdec/rkvdec-vp9.c
<snip>
Quoted 4 lines
Quoted 4 lines
drivers/staging/media/rkvdec/rkvdec.c +0
-0
Quoted 8 lines
drivers/staging/media/rkvdec/rkvdec.c static const struct rkvdec_ctrls rkvdec_h264_ctrls = { · line 102
Quoted 6 lines
drivers/staging/media/rkvdec/rkvdec.c +1
-1@@ -99,10 +99,30 @@ static const struct rkvdec_ctrls rkvdec_h264_ctrls = { .num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs), }; -static const u32 rkvdec_h264_decoded_fmts[] = { +static const u32 rkvdec_h264_vp9_decoded_fmts[] = { V4L2_PIX_FMT_NV12,For H.264 rkvdec HW supports additional formats:
V4L2_PIX_FMT_NV15,V4L2_PIX_FMT_NV16andV4L2_PIX_FMT_NV20. Not all of those are upstreamed yet and thus not supported by rkvdec driver - but I think we should introduce a seperaterkvdec_vp9_decoded_fmtsalready a this point. (To avoid unnecessary diff afterwards)
I will do it if I get to re-spinning the series for other reasons.
Quoted 40 lines
Quoted 40 lines
drivers/staging/media/rkvdec/rkvdec.c +28
-2}; +static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = { + { + .cfg.id = V4L2_CID_STATELESS_VP9_FRAME, + }, + { + .cfg.id = V4L2_CID_STATELESS_VP9_COMPRESSED_HDR, + }, + { + .cfg.id = V4L2_CID_MPEG_VIDEO_VP9_PROFILE, + .cfg.min = V4L2_MPEG_VIDEO_VP9_PROFILE_0, + .cfg.max = V4L2_MPEG_VIDEO_VP9_PROFILE_0, + .cfg.def = V4L2_MPEG_VIDEO_VP9_PROFILE_0, + }, +}; + +static const struct rkvdec_ctrls rkvdec_vp9_ctrls = { + .ctrls = rkvdec_vp9_ctrl_descs, + .num_ctrls = ARRAY_SIZE(rkvdec_vp9_ctrl_descs), +}; + static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { { .fourcc = V4L2_PIX_FMT_H264_SLICE,@@ -116,8 +136,23 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { }, .ctrls = &rkvdec_h264_ctrls, .ops = &rkvdec_h264_fmt_ops, - .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts), - .decoded_fmts = rkvdec_h264_decoded_fmts, + .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts), + .decoded_fmts = rkvdec_h264_vp9_decoded_fmts, + }, + { + .fourcc = V4L2_PIX_FMT_VP9_FRAME, + .frmsize = { + .min_width = 64, + .max_width = 4096,
Quoted 9 lines
drivers/staging/media/rkvdec/rkvdec.c static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { · line 151
Quoted 5 lines
drivers/staging/media/rkvdec/rkvdec.c +5
-0+ .step_width = 64, + .min_height = 64, + .max_height = 2304, + .step_height = 64, + },I checked (available) documentation and couldn't find any hint to the .step_width and .step_height, but I'm not sure that's correct: taking
this values here neither framesize of 3840x2160 nor 1280x720 would be possible - but the HW seems to have no problem with those, i.e. decoding works fine.
Given the output format is the same as the (only) currently supported H.264 output format (NV12) and those steps are usually for alignment purposes need by the HW , I strongly guess .step_height and .step_width are the same asV4L2_PIX_FMT_H264_SLICEhas.
Aren't these used primarily by v4l2_apply_frmsize_constraints()? Doesn't this merely mean that even though userspace requests, say, 48x48, it will get 64x64 instead?
I tried decoding a 720p video with gstreamer and it worked fine (I got a properly sized 1280x720 output).
Regards,
Andrzej
PATCH v7 8/11 media: hantro: Rename registers
In reply to Andrzej PietrasiewiczAdd more consistency in the way registers are named.
--- .../staging/media/hantro/hantro_g2_hevc_dec.c | 38 +++++++++---------- drivers/staging/media/hantro/hantro_g2_regs.h | 28 +++++++------- 2 files changed, 33 insertions(+), 33 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +19 -19
@@ -448,9 +448,9 @@ static int set_ref(struct hantro_ctx *ctx)if (dpb[i].rps ==V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR ) dpb_longterm_e |=BIT (V4L2_HEVC_DPB_ENTRIES_NUM_MAX -1 - i); -hantro_write_addr (vpu,G2_REG_ADDR_REF (i), luma_addr); -hantro_write_addr (vpu,G2_REG_CHR_REF (i), chroma_addr); -hantro_write_addr (vpu,G2_REG_DMV_REF (i), mv_addr); +hantro_write_addr (vpu,G2_REF_LUMA_ADDR (i), luma_addr); +hantro_write_addr (vpu,G2_REF_CHROMA_ADDR (i), chroma_addr); +hantro_write_addr (vpu,G2_REF_MV_ADDR (i), mv_addr); } luma_addr =hantro_hevc_get_ref_buf (ctx, decode_params->pic_order_cnt_val);
@@ -460,20 +460,20 @@ static int set_ref(struct hantro_ctx *ctx) chroma_addr = luma_addr + cr_offset; mv_addr = luma_addr + mv_offset; -hantro_write_addr (vpu,G2_REG_ADDR_REF (i), luma_addr); -hantro_write_addr (vpu,G2_REG_CHR_REF (i), chroma_addr); -hantro_write_addr (vpu,G2_REG_DMV_REF (i++), mv_addr); +hantro_write_addr (vpu,G2_REF_LUMA_ADDR (i), luma_addr); +hantro_write_addr (vpu,G2_REF_CHROMA_ADDR (i), chroma_addr); +hantro_write_addr (vpu,G2_REF_MV_ADDR (i++), mv_addr); -hantro_write_addr (vpu,G2_ADDR_DST , luma_addr); -hantro_write_addr (vpu,G2_ADDR_DST_CHR , chroma_addr); -hantro_write_addr (vpu,G2_ADDR_DST_MV , mv_addr); +hantro_write_addr (vpu,G2_OUT_LUMA_ADDR , luma_addr); +hantro_write_addr (vpu,G2_OUT_CHROMA_ADDR , chroma_addr); +hantro_write_addr (vpu,G2_OUT_MV_ADDR , mv_addr);hantro_hevc_ref_remove_unused (ctx);for (; i <V4L2_HEVC_DPB_ENTRIES_NUM_MAX ; i++) { -hantro_write_addr (vpu,G2_REG_ADDR_REF (i),0 ); -hantro_write_addr (vpu,G2_REG_CHR_REF (i),0 ); -hantro_write_addr (vpu,G2_REG_DMV_REF (i),0 ); +hantro_write_addr (vpu,G2_REF_LUMA_ADDR (i),0 ); +hantro_write_addr (vpu,G2_REF_CHROMA_ADDR (i),0 ); +hantro_write_addr (vpu,G2_REF_MV_ADDR (i),0 ); }hantro_reg_write (vpu, &g2_refer_lterm_e, dpb_longterm_e);
@@ -499,7 +499,7 @@ static void set_buffers(struct hantro_ctx *ctx) src_len =vb2_get_plane_payload (&src_buf->vb2_buf,0 ); src_buf_len =vb2_plane_size (&src_buf->vb2_buf,0 ); -hantro_write_addr (vpu,G2_ADDR_STR , src_dma); +hantro_write_addr (vpu,G2_STREAM_ADDR , src_dma);hantro_reg_write (vpu, &g2_stream_len, src_len);hantro_reg_write (vpu, &g2_strm_buffer_len, src_buf_len);hantro_reg_write (vpu, &g2_strm_start_offset,0 );
@@ -508,12 +508,12 @@ static void set_buffers(struct hantro_ctx *ctx)/* Destination (decoded frame) buffer. */ dst_dma =hantro_get_dec_buf_addr (ctx, &dst_buf->vb2_buf); -hantro_write_addr (vpu,G2_RASTER_SCAN , dst_dma); -hantro_write_addr (vpu,G2_RASTER_SCAN_CHR , dst_dma + cr_offset); -hantro_write_addr (vpu,G2_ADDR_TILE_SIZE , ctx->hevc_dec.tile_sizes.dma); -hantro_write_addr (vpu,G2_TILE_FILTER , ctx->hevc_dec.tile_filter.dma); -hantro_write_addr (vpu,G2_TILE_SAO , ctx->hevc_dec.tile_sao.dma); -hantro_write_addr (vpu,G2_TILE_BSD , ctx->hevc_dec.tile_bsd.dma); +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); +hantro_write_addr (vpu,G2_RS_OUT_CHROMA_ADDR , dst_dma + cr_offset); +hantro_write_addr (vpu,G2_TILE_SIZES_ADDR , ctx->hevc_dec.tile_sizes.dma); +hantro_write_addr (vpu,G2_TILE_FILTER_ADDR , ctx->hevc_dec.tile_filter.dma); +hantro_write_addr (vpu,G2_TILE_SAO_ADDR , ctx->hevc_dec.tile_sao.dma); +hantro_write_addr (vpu,G2_TILE_BSD_ADDR , ctx->hevc_dec.tile_bsd.dma); }static void hantro_g2_check_idle (struct hantro_dev *vpu)
drivers/staging/media/hantro/hantro_g2_regs.h +14 -14
@@ -177,20 +177,20 @@#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17) -#define G2_ADDR_DST (G2_SWREG(65)) -#define G2_REG_ADDR_REF (i) (G2_SWREG(67) + ((i) * 0x8)) -#define G2_ADDR_DST_CHR (G2_SWREG(99)) -#define G2_REG_CHR_REF (i) (G2_SWREG(101) + ((i) * 0x8)) -#define G2_ADDR_DST_MV (G2_SWREG(133)) -#define G2_REG_DMV_REF (i) (G2_SWREG(135) + ((i) * 0x8)) -#define G2_ADDR_TILE_SIZE (G2_SWREG(167)) -#define G2_ADDR_STR (G2_SWREG(169)) -#define HEVC_SCALING_LIST (G2_SWREG(171)) -#define G2_RASTER_SCAN (G2_SWREG(175)) -#define G2_RASTER_SCAN_CHR (G2_SWREG(177)) -#define G2_TILE_FILTER (G2_SWREG(179)) -#define G2_TILE_SAO (G2_SWREG(181)) -#define G2_TILE_BSD (G2_SWREG(183)) +#define G2_OUT_LUMA_ADDR (G2_SWREG(65)) +#define G2_REF_LUMA_ADDR (i) (G2_SWREG(67) + ((i) * 0x8)) +#define G2_OUT_CHROMA_ADDR (G2_SWREG(99)) +#define G2_REF_CHROMA_ADDR (i) (G2_SWREG(101) + ((i) * 0x8)) +#define G2_OUT_MV_ADDR (G2_SWREG(133)) +#define G2_REF_MV_ADDR (i) (G2_SWREG(135) + ((i) * 0x8)) +#define G2_TILE_SIZES_ADDR (G2_SWREG(167)) +#define G2_STREAM_ADDR (G2_SWREG(169)) +#define G2_HEVC_SCALING_LIST_ADDR (G2_SWREG(171)) +#define G2_RS_OUT_LUMA_ADDR (G2_SWREG(175)) +#define G2_RS_OUT_CHROMA_ADDR (G2_SWREG(177)) +#define G2_TILE_FILTER_ADDR (G2_SWREG(179)) +#define G2_TILE_SAO_ADDR (G2_SWREG(181)) +#define G2_TILE_BSD_ADDR (G2_SWREG(183))#define g2_strm_buffer_len G2_DEC_REG(258, 0, 0xffffffff)#define g2_strm_start_offset G2_DEC_REG(259, 0, 0xffffffff)
Signature · 1 line
2.17.1
PATCH v7 9/11 media: hantro: Prepare for other G2 codecs
In reply to Andrzej PietrasiewiczVeriSilicon Hantro G2 core supports other codecs besides hevc. Factor out some common code in preparation for vp9 support.
--- drivers/staging/media/hantro/Makefile | 1 + drivers/staging/media/hantro/hantro.h | 7 +++++ drivers/staging/media/hantro/hantro_drv.c | 5 +++ drivers/staging/media/hantro/hantro_g2.c | 27 ++++++++++++++++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 31 ------------------- drivers/staging/media/hantro/hantro_g2_regs.h | 7 +++++ drivers/staging/media/hantro/hantro_hw.h | 2 ++ 7 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 drivers/staging/media/hantro/hantro_g2.c
drivers/staging/media/hantro/Makefile +1 -0
@@ -12,6 +12,7 @@ hantro-vpu-y += \ hantro_g1_mpeg2_dec.o \ hantro_g2_hevc_dec.o \ hantro_g1_vp8_dec.o \ + hantro_g2.o \ rockchip_vpu2_hw_jpeg_enc.o \ rockchip_vpu2_hw_h264_dec.o \ rockchip_vpu2_hw_mpeg2_dec.o \
drivers/staging/media/hantro/hantro.h +7 -0
@@ -369,6 +369,13 @@ static inline void vdpu_write(struct hantro_dev *vpu, u32 val, u32 reg)writel (val, vpu->dec_base + reg); } +static inline void hantro_write_addr (struct hantro_dev *vpu, +unsigned long offset, +dma_addr_t addr) +{ +vdpu_write (vpu, addr &0xffffffff , offset); +} +static inline u32 vdpu_read (struct hantro_dev *vpu,u32 reg) {u32 val =readl (vpu->dec_base + reg);
drivers/staging/media/hantro/hantro_drv.c +5 -0
@@ -905,6 +905,11 @@ static int hantro_probe(struct platform_device *pdev) vpu->enc_base = vpu->reg_bases[0 ] + vpu->variant->enc_offset; vpu->dec_base = vpu->reg_bases[0 ] + vpu->variant->dec_offset; +/** +* TODO: Eventually allow taking advantage of full 64-bit address space. +* Until then we assume the MSB portion of buffers' base addresses is +* always 0 due to this masking operation. +*/ ret =dma_set_coherent_mask (vpu->dev,DMA_BIT_MASK (32 ));if (ret) {dev_err (vpu->dev,"Could not set DMA coherent mask.\n" );
drivers/staging/media/hantro/hantro_g2.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Hantro VPU codec driver +* +* Copyright (C) 2021 Collabora Ltd, Andrzej Pietrasiewicz <[email protected]> +*/ + +#include "hantro_hw.h" +#include "hantro_g2_regs.h" + +void hantro_g2_check_idle (struct hantro_dev *vpu) +{ +int i; + +for (i =0 ; i <3 ; i++) { +u32 status; + +/* Make sure the VPU is idle */ + status =vdpu_read (vpu,G2_REG_INTERRUPT ); +if (status &G2_REG_INTERRUPT_DEC_E ) { +dev_warn (vpu->dev,"device still running, aborting" ); + status |=G2_REG_INTERRUPT_DEC_ABORT_E |G2_REG_INTERRUPT_DEC_IRQ_DIS ; +vdpu_write (vpu, status,G2_REG_INTERRUPT ); + } + } +} +
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +0 -31
@@ -8,20 +8,6 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" -#define HEVC_DEC_MODE 0xC - -#define BUS_WIDTH_32 0 -#define BUS_WIDTH_64 1 -#define BUS_WIDTH_128 2 -#define BUS_WIDTH_256 3 - -static inline void hantro_write_addr (struct hantro_dev *vpu, -unsigned long offset, -dma_addr_t addr) -{ -vdpu_write (vpu, addr &0xffffffff , offset); -} -static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
@@ -516,23 +502,6 @@ static void set_buffers(struct hantro_ctx *ctx)hantro_write_addr (vpu,G2_TILE_BSD_ADDR , ctx->hevc_dec.tile_bsd.dma); } -static void hantro_g2_check_idle (struct hantro_dev *vpu) -{ -int i; - -for (i =0 ; i <3 ; i++) { -u32 status; - -/* Make sure the VPU is idle */ - status =vdpu_read (vpu,G2_REG_INTERRUPT ); -if (status &G2_REG_INTERRUPT_DEC_E ) { -dev_warn (vpu->dev,"device still running, aborting" ); - status |=G2_REG_INTERRUPT_DEC_ABORT_E |G2_REG_INTERRUPT_DEC_IRQ_DIS ; -vdpu_write (vpu, status,G2_REG_INTERRUPT ); - } - } -} -int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
drivers/staging/media/hantro/hantro_g2_regs.h +7 -0
@@ -27,6 +27,13 @@#define G2_REG_INTERRUPT_DEC_IRQ_DIS BIT(4)#define G2_REG_INTERRUPT_DEC_E BIT(0) +#define HEVC_DEC_MODE 0xc + +#define BUS_WIDTH_32 0 +#define BUS_WIDTH_64 1 +#define BUS_WIDTH_128 2 +#define BUS_WIDTH_256 3 +#define g2_strm_swap G2_DEC_REG(2, 28, 0xf)#define g2_dirmv_swap G2_DEC_REG(2, 20, 0xf)
drivers/staging/media/hantro/hantro_hw.h +2 -0
@@ -308,4 +308,6 @@ void hantro_vp8_dec_exit(struct hantro_ctx *ctx);void hantro_vp8_prob_update (struct hantro_ctx *ctx,const struct v4l2_ctrl_vp8_frame *hdr); +void hantro_g2_check_idle (struct hantro_dev *vpu); +#endif /* HANTRO_HW_H_ */
Signature · 1 line
2.17.1
PATCH v7 10/11 media: hantro: Support VP9 on the G2 core
In reply to Andrzej PietrasiewiczVeriSilicon Hantro G2 core supports VP9 codec.
--- drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 6 +- drivers/staging/media/hantro/hantro.h | 26 + drivers/staging/media/hantro/hantro_drv.c | 18 +- drivers/staging/media/hantro/hantro_g2_regs.h | 97 ++ .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 ++++++++++++++++++ drivers/staging/media/hantro/hantro_hw.h | 67 ++ drivers/staging/media/hantro/hantro_v4l2.c | 6 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++++ drivers/staging/media/hantro/hantro_vp9.h | 103 ++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 22 +- 11 files changed, 1562 insertions(+), 4 deletions(-) create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h
drivers/staging/media/hantro/Kconfig +1 -0
@@ -9,6 +9,7 @@ config VIDEO_HANTRO select VIDEOBUF2_VMALLOC select V4L2_MEM2MEM_DEV select V4L2_H264 + select V4L2_VP9 help Support for the Hantro IP based Video Processing Units present on Rockchip and NXP i.MX8M SoCs, which accelerate video and image
drivers/staging/media/hantro/Makefile +4 -2
@@ -10,9 +10,10 @@ hantro-vpu-y += \ hantro_g1.o \ hantro_g1_h264_dec.o \ hantro_g1_mpeg2_dec.o \ - hantro_g2_hevc_dec.o \ hantro_g1_vp8_dec.o \ hantro_g2.o \ + hantro_g2_hevc_dec.o \ + hantro_g2_vp9_dec.o \ rockchip_vpu2_hw_jpeg_enc.o \ rockchip_vpu2_hw_h264_dec.o \ rockchip_vpu2_hw_mpeg2_dec.o \
@@ -21,7 +22,8 @@ hantro-vpu-y += \ hantro_h264.o \ hantro_hevc.o \ hantro_mpeg2.o \ - hantro_vp8.o + hantro_vp8.o \ + hantro_vp9.o hantro-vpu-$(CONFIG_VIDEO_HANTRO_IMX8M) += \ imx8m_vpu_hw.o
drivers/staging/media/hantro/hantro.h +26 -0
@@ -36,6 +36,7 @@ struct hantro_postproc_ops;#define HANTRO_VP8_DECODER BIT(17)#define HANTRO_H264_DECODER BIT(18)#define HANTRO_HEVC_DECODER BIT(19) +#define HANTRO_VP9_DECODER BIT(20)#define HANTRO_DECODERS 0xffff0000/**
@@ -110,6 +111,7 @@ enum hantro_codec_mode {HANTRO_MODE_MPEG2_DEC ,HANTRO_MODE_VP8_DEC ,HANTRO_MODE_HEVC_DEC , + HANTRO_MODE_VP9_DEC, };/*
@@ -223,6 +225,7 @@ struct hantro_dev {* @mpeg2_dec: MPEG-2-decoding context. * @vp8_dec: VP8-decoding context. * @hevc_dec: HEVC-decoding context. +* @vp9_dec: VP9-decoding context. */ struct hantro_ctx {struct hantro_dev *dev;
@@ -250,6 +253,7 @@ struct hantro_ctx {struct hantro_mpeg2_dec_hw_ctx mpeg2_dec;struct hantro_vp8_dec_hw_ctx vp8_dec;struct hantro_hevc_dec_hw_ctx hevc_dec; +struct hantro_vp9_dec_hw_ctx vp9_dec; }; };
@@ -299,6 +303,22 @@ struct hantro_postproc_regs {struct hantro_reg display_width; }; +struct hantro_vp9_decoded_buffer_info { +/* Info needed when the decoded frame serves as a reference frame. */ +unsigned short width; +unsigned short height; +u32 bit_depth :4 ; +}; + +struct hantro_decoded_buffer { +/* Must be the first field in this struct. */ +struct v4l2_m2m_buffer base; + +union { +struct hantro_vp9_decoded_buffer_info vp9; + }; +}; +/* Logging helpers */ /**
@@ -436,6 +456,12 @@ hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb)return vb2_dma_contig_plane_dma_addr (vb,0 ); } +static inline struct hantro_decoded_buffer * +vb2_to_hantro_decoded_buf (struct vb2_buffer *buf) +{ + return container_of(buf, struct hantro_decoded_buffer, base.vb.vb2_buf); +} +void hantro_postproc_disable (struct hantro_ctx *ctx);void hantro_postproc_enable (struct hantro_ctx *ctx);void hantro_postproc_free (struct hantro_ctx *ctx);
drivers/staging/media/hantro/hantro_drv.c +17 -1
@@ -232,7 +232,7 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) dst_vq->io_modes =VB2_MMAP |VB2_DMABUF ; dst_vq->drv_priv = ctx; dst_vq->ops = &hantro_queue_ops; - dst_vq->buf_struct_size =sizeof (struct v4l2_m2m_buffer ); + dst_vq->buf_struct_size =sizeof (struct hantro_decoded_buffer ); dst_vq->timestamp_flags =V4L2_BUF_FLAG_TIMESTAMP_COPY ; dst_vq->lock = &ctx->dev->vpu_mutex; dst_vq->dev = ctx->dev->v4l2_dev.dev;
@@ -266,6 +266,12 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl)if (sps->flags &V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED )/* No scaling support */ return -EINVAL ; + }else if (ctrl->id ==V4L2_CID_STATELESS_VP9_FRAME ) { +const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame; + +/* We only support profile 0 */ +if (dec_params->profile !=0 ) +return -EINVAL ; }return 0 ; }
@@ -459,6 +465,16 @@ static const struct hantro_ctrl controls[] = { .step = 1, .ops = &hantro_hevc_ctrl_ops, }, + }, { + .codec = HANTRO_VP9_DECODER, + .cfg = { + .id = V4L2_CID_STATELESS_VP9_FRAME, + }, + }, { + .codec = HANTRO_VP9_DECODER, + .cfg = { + .id = V4L2_CID_STATELESS_VP9_COMPRESSED_HDR, + }, }, };
drivers/staging/media/hantro/hantro_g2_regs.h +97 -0
145 lines not on this page · raw message
drivers/staging/media/hantro/hantro_g2_vp9_dec.c new file +980 -0
980 lines not on this page · raw message
drivers/staging/media/hantro/hantro_hw.h +67 -0
91 lines not on this page · raw message
drivers/staging/media/hantro/hantro_v4l2.c +6 -0
@@ -299,6 +299,11 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, pix_mp->plane_fmt[0 ].sizeimage +=hantro_h264_mv_size (pix_mp->width, pix_mp->height); + else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_VP9_FRAME && + !hantro_needs_postproc(ctx, fmt)) + pix_mp->plane_fmt[0].sizeimage += + hantro_vp9_mv_size(pix_mp->width, + pix_mp->height); }else if (!pix_mp->plane_fmt[0 ].sizeimage) {/* * For coded formats the application can specify
@@ -407,6 +412,7 @@ hantro_update_requires_request(struct hantro_ctx *ctx, u32 fourcc)case V4L2_PIX_FMT_VP8_FRAME :case V4L2_PIX_FMT_H264_SLICE :case V4L2_PIX_FMT_HEVC_SLICE : +case V4L2_PIX_FMT_VP9_FRAME : ctx->fh.m2m_ctx->out_q_ctx.q.requires_requests = true;break ;default :
drivers/staging/media/hantro/hantro_vp9.c new file +240 -0
240 lines not on this page · raw message
drivers/staging/media/hantro/hantro_vp9.h new file +103 -0
103 lines not on this page · raw message
drivers/staging/media/hantro/imx8m_vpu_hw.c +21 -1
@@ -150,6 +150,19 @@ static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { .step_height = MB_DIM, }, }, + { + .fourcc = V4L2_PIX_FMT_VP9_FRAME, + .codec_mode = HANTRO_MODE_VP9_DEC, + .max_depth = 2, + .frmsize = { + .min_width = 48, + .max_width = 3840, + .step_width = MB_DIM, + .min_height = 48, + .max_height = 2160, + .step_height = MB_DIM, + }, + }, };static irqreturn_t imx8m_vpu_g1_irq (int irq,void *dev_id)
@@ -241,6 +254,13 @@ static const struct hantro_codec_ops imx8mq_vpu_g2_codec_ops[] = { .init = hantro_hevc_dec_init, .exit = hantro_hevc_dec_exit, }, + [HANTRO_MODE_VP9_DEC] = { + .run = hantro_g2_vp9_dec_run, + .done = hantro_g2_vp9_dec_done, + .reset = imx8m_vpu_g2_reset, + .init = hantro_vp9_dec_init, + .exit = hantro_vp9_dec_exit, + }, };/*
@@ -281,7 +301,7 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), - .codec = HANTRO_HEVC_DECODER, + .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init, .runtime_resume = imx8mq_runtime_resume,
Signature · 1 line
2.17.1
PATCH v7 11/11 media: hantro: Support NV12 on the G2 core
In reply to Andrzej PietrasiewiczThe G2 decoder block produces NV12 4x4 tiled format (NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.
The logic in hantro_postproc.c is leveraged to take care of allocating the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.
--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +3 -3
@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr =vb2_dma_contig_plane_dma_addr (&dst->base.vb.vb2_buf,0 ); + luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);
@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &ref_reg->hor_scale, (refw <<14 ) / dst->vp9.width);hantro_reg_write (ctx->dev, &ref_reg->ver_scale, (refh <<14 ) / dst->vp9.height); - luma_addr =vb2_dma_contig_plane_dma_addr (&buf->base.vb.vb2_buf,0 ); + luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);
@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx *ctx,config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params->golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params->alt_frame_ts); - mv_addr =vb2_dma_contig_plane_dma_addr (&mv_ref->base.vb.vb2_buf,0 ) + + mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);hantro_write_addr (ctx->dev,G2_REF_MV_ADDR (0 ), mv_addr);
drivers/staging/media/hantro/hantro_hw.h +1 -0
@@ -274,6 +274,7 @@ extern const struct hantro_variant rk3399_vpu_variant;extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];
drivers/staging/media/hantro/hantro_postproc.c +31 -0
@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h" #define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \
@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +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; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); +hantro_write_addr (vpu,G2_RS_OUT_CHROMA_ADDR , dst_dma + chroma_offset); +hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx->dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx->dst_fmt.height);for (i =0 ; i < num_buffers; ++i) {struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];
@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct hantro_ctx *ctx)HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); } +static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
@@ -172,3 +198,8 @@ const struct hantro_postproc_ops hantro_g1_postproc_ops = { .enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};
drivers/staging/media/hantro/imx8m_vpu_hw.c +11 -0
@@ -132,6 +132,14 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[] = { }, }; +static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,
@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init,
Signature · 1 line
2.17.1
Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care of allocating the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.
Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs some driver changes), I get frames out of order. If I use native NV12 tiled format, frames are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this general issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of short scenes. It's pretty obvious when frames are out of order.
However, given that frames themself are correctly decoded and without postprocessing in right order, that shouldn't block merging previous patches. I tried few different videos and frames were all decoded correctly.
Best regards,
Jernej
drivers/
Quoted 11 lines
Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)drivers/ renamed from drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0
staging/media/hantro/hantro_g2_vp9_dec.c
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_output(struct hantro_ctx *ctx, · line 155
Quoted 8 lines
index
7f827b9f0133..1a26be72c878100644drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf,
0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 191
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx, hantro_reg_write(ctx->dev, &ref_reg->hor_scale, (refw << 14) /
dst->vp9.width);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 192
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_reg_write(ctx->dev, &ref_reg->ver_scale, (refh << 14) /
dst->vp9.height);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 193
Quoted 2 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1- luma_addr = vb2_dma_contig_plane_dma_addr(&buf->base.vb.vb2_buf,
0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx *ctx, · line 241
Quoted 11 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-1+ luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx *ctx,config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params- golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params- alt_frame_ts); - mv_addr = vb2_dma_contig_plane_dma_addr(&mv_ref->base.vb.vb2_buf,
0) +
drivers/staging/
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_write_addr (ctx->dev,G2_REF_MV_ADDR (0 ), mv_addr);drivers/staging/ renamed from drivers/staging/media/hantro/hantro_hw.h +0
-0
media/hantro/hantro_hw.h
drivers/
Quoted 12 lines
index
2961d399fd60..3d4a5dc1e6d5100644drivers/staging/media/hantro/hantro_hw.h +1
-0@@ -274,6 +274,7 @@ extern const struct hantro_variant rk3399_vpu_variant;extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];drivers/ renamed from drivers/staging/media/hantro/hantro_postproc.c +0
-0
staging/media/hantro/hantro_postproc.c
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx
Quoted 12 lines
index
4549aec08feb..79a66d001738100644drivers/staging/media/hantro/hantro_postproc.c +1
-0@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h" #define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct hantro_ctx
*ctx)
Quoted 5 lines
drivers/staging/media/hantro/hantro_postproc.c +2
-0HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +static void hantro_postproc_g2_enable (struct hantro_ctx *ctx) +{
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
Quoted 10 lines
drivers/staging/media/hantro/hantro_postproc.c +10
-0+struct hantro_dev *vpu = ctx->dev; +struct vb2_v4l2_buffer *dst_buf; +size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); + hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma +
chroma_offset);
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_disable(struct
Quoted 19 lines
drivers/staging/media/hantro/hantro_postproc.c +6
-0+hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx- dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx- dst_fmt.height);drivers/staging/media/hantro/hantro_postproc.c +0
-0for (i =0 ; i < num_buffers; ++i) {struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct
hantro_ctx *ctx)
drivers/staging/media/hantro/hantro_postproc.c const struct hantro_postproc_ops hantro_g1_postproc_ops
Quoted 14 lines
drivers/staging/media/hantro/hantro_postproc.c +7
-0HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); } +static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -172,3 +198,8 @@ const struct hantro_postproc_ops hantro_g1_postproc_ops
= {
drivers/staging/
Quoted 9 lines
drivers/staging/media/hantro/hantro_postproc.c +5
-0.enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};drivers/staging/ renamed from drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0
media/hantro/imx8m_vpu_hw.c
Quoted 32 lines
index
455a107ffb02..1a43f6fceef9100644drivers/staging/media/hantro/imx8m_vpu_hw.c +11
-0@@ -132,6 +132,14 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[] = { }, }; +static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init,Signature · 1 line
2.17.1
Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Hi Jernej,
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 16 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care of allocating the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs some driver changes), I get frames out of order. If I use native NV12 tiled format, frames are ordered correctly.
Quoted 7 lines
Currently I'm not sure if this is issue with my changes or is this general issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of short scenes. It's pretty obvious when frames are out of order.
I checked on imx8 and cannot observe any such artifacts.
Andrzej
Quoted 179 lines
However, given that frames themself are correctly decoded and without postprocessing in right order, that shouldn't block merging previous patches. I tried few different videos and frames were all decoded correctly.
Best regards,
Jernejdrivers/
Quoted 11 lines
Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)drivers/ renamed from drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0
staging/media/hantro/hantro_g2_vp9_dec.cdrivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_output(struct hantro_ctx *ctx, · line 155
Quoted 8 lines
index
7f827b9f0133..1a26be72c878100644drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 191
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx, hantro_reg_write(ctx->dev, &ref_reg->hor_scale, (refw << 14) /
dst->vp9.width);drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 192
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_reg_write(ctx->dev, &ref_reg->ver_scale, (refh << 14) /
dst->vp9.height);drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 193
Quoted 2 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1- luma_addr = vb2_dma_contig_plane_dma_addr(&buf->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx *ctx, · line 241
Quoted 11 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-1+ luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx *ctx,config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params- golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params- alt_frame_ts); - mv_addr = vb2_dma_contig_plane_dma_addr(&mv_ref->base.vb.vb2_buf,0) +
drivers/staging/
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr);drivers/staging/ renamed from drivers/staging/media/hantro/hantro_hw.h +0
-0
media/hantro/hantro_hw.hdrivers/
Quoted 12 lines
index
2961d399fd60..3d4a5dc1e6d5100644drivers/staging/media/hantro/hantro_hw.h +1
-0@@ -274,6 +274,7 @@ extern const struct hantro_variant rk3399_vpu_variant;extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];drivers/ renamed from drivers/staging/media/hantro/hantro_postproc.c +0
-0
staging/media/hantro/hantro_postproc.cdrivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx
Quoted 12 lines
index
4549aec08feb..79a66d001738100644drivers/staging/media/hantro/hantro_postproc.c +1
-0@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h" #define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct hantro_ctx*ctx)
Quoted 5 lines
drivers/staging/media/hantro/hantro_postproc.c +2
-0HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +static void hantro_postproc_g2_enable (struct hantro_ctx *ctx) +{drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
Quoted 10 lines
drivers/staging/media/hantro/hantro_postproc.c +10
-0+struct hantro_dev *vpu = ctx->dev; +struct vb2_v4l2_buffer *dst_buf; +size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); + hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma +
chroma_offset);drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_disable(struct
Quoted 19 lines
drivers/staging/media/hantro/hantro_postproc.c +6
-0+hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx- dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx- dst_fmt.height);for (i = 0; i < num_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];drivers/staging/media/hantro/hantro_postproc.c +0
-0@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct
hantro_ctx*ctx)drivers/staging/media/hantro/hantro_postproc.c const struct hantro_postproc_ops hantro_g1_postproc_ops
Quoted 14 lines
drivers/staging/media/hantro/hantro_postproc.c +7
-0HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); } +static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -172,3 +198,8 @@ const struct hantro_postproc_ops hantro_g1_postproc_ops= {
drivers/staging/
Quoted 9 lines
drivers/staging/media/hantro/hantro_postproc.c +5
-0.enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};drivers/staging/ renamed from drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0
media/hantro/imx8m_vpu_hw.cQuoted 32 lines
index
455a107ffb02..1a43f6fceef9100644drivers/staging/media/hantro/imx8m_vpu_hw.c +11
-0@@ -132,6 +132,14 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[] = { }, }; +static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init,Signature · 1 line
2.17.1
Re: Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Hi Andrzej!
Dne petek, 15. oktober 2021 ob 19:19:47 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 17 lines
Hi Jernej,
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 14 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care of allocating the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs some driver changes), I get frames out of order. If I use native NV12 tiled format,
frames
Quoted 7 lines
Quoted 7 lines
are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this general issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of
short
Quoted 4 lines
Quoted 2 lines
scenes. It's pretty obvious when frames are out of order.
I checked on imx8 and cannot observe any such artifacts.
I finally found the issue. As you mentioned on Slack, register write order once already affected decoding. Well, it's the case again. I made hacky test and moved postproc enable call after output buffers are set and it worked. So, this is actually core quirk which is obviously fixed in newer variants.
This makes this series with minor adaptations completely working on H6. I see no reason not to merge whole series.
Thanks for testing.
Best regards,
Jernej
Quoted 5 lines
Andrzej
Quoted 2 lines
However, given that frames themself are correctly decoded and without postprocessing in right order, that shouldn't block merging previous
patches.
Quoted 36 lines
Quoted 36 lines
I tried few different videos and frames were all decoded correctly.
Best regards,
Jernejdrivers/
Quoted 11 lines
Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)drivers/ renamed from drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0
staging/media/hantro/hantro_g2_vp9_dec.cdrivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_output(struct hantro_ctx *ctx, · line 155
Quoted 8 lines
index
7f827b9f0133..1a26be72c878100644drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 191
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx, hantro_reg_write(ctx->dev, &ref_reg->hor_scale, (refw << 14) /
dst->vp9.width);drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 192
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_reg_write(ctx->dev, &ref_reg->ver_scale, (refh << 14) /
dst->vp9.height);Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1- luma_addr = vb2_dma_contig_plane_dma_addr(&buf->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx
*ctx,
Quoted 11 lines
Quoted 11 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx · line 241
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params- golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params- alt_frame_ts); - mv_addr = vb2_dma_contig_plane_dma_addr(&mv_ref->base.vb.vb2_buf,0) +
Quoted 4 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr);
Quoted 6 lines
Quoted 6 lines
drivers/staging/
Quoted 1 line
drivers/staging/ renamed from drivers/staging/media/hantro/hantro_hw.h +0
-0
media/hantro/hantro_hw.hdrivers/staging/media/hantro/hantro_hw.h extern const struct hantro_variant
Quoted 4 lines
index
2961d399fd60..3d4a5dc1e6d5100644drivers/staging/media/hantro/hantro_hw.h +0
-0@@ -274,6 +274,7 @@ extern const struct hantro_variant
rk3399_vpu_variant;
Quoted 18 lines
Quoted 18 lines
drivers/
Quoted 8 lines
drivers/staging/media/hantro/hantro_hw.h +1
-0extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];drivers/ renamed from drivers/staging/media/hantro/hantro_postproc.c +0
-0
staging/media/hantro/hantro_postproc.cQuoted 9 lines
index
4549aec08feb..79a66d001738100644drivers/staging/media/hantro/hantro_postproc.c +1
-0@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h"
Quoted 3 lines
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0#define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct
hantro_ctx
Quoted 40 lines
Quoted 40 lines
*ctx)
Quoted 5 lines
drivers/staging/media/hantro/hantro_postproc.c +2
-0HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +static void hantro_postproc_g2_enable (struct hantro_ctx *ctx) +{drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
Quoted 10 lines
drivers/staging/media/hantro/hantro_postproc.c +10
-0+struct hantro_dev *vpu = ctx->dev; +struct vb2_v4l2_buffer *dst_buf; +size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); + hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma +
chroma_offset);drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_disable(struct
Quoted 19 lines
drivers/staging/media/hantro/hantro_postproc.c +6
-0+hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx- dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx- dst_fmt.height);for (i = 0; i < num_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];drivers/staging/media/hantro/hantro_postproc.c +0
-0@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct
hantro_ctx*ctx)Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); }
Quoted 11 lines
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c const struct hantro_postproc_ops
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c +7
-0+static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -172,3 +198,8 @@ const struct hantro_postproc_ops
hantro_g1_postproc_ops
Quoted 10 lines
Quoted 10 lines
= {
drivers/
Quoted 9 lines
drivers/staging/media/hantro/hantro_postproc.c +5
-0.enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};drivers/ renamed from drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0
staging/
Quoted 5 lines
Quoted 5 lines
media/hantro/imx8m_vpu_hw.cdrivers/staging/media/hantro/imx8m_vpu_hw.c static const struct hantro_fmt imx8m_vpu_dec_fmts[]
Quoted 4 lines
index
455a107ffb02..1a43f6fceef9100644drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0@@ -132,6 +132,14 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[]
= {
Quoted 32 lines
Quoted 30 lines
Quoted 28 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +11
-0}, }; +static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init,Signature · 1 line
2.17.1
Re: Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Hi Jernej,
Quoted 34 lines · Jernej Škrabec
Hi Andrzej!
Dne petek, 15. oktober 2021 ob 19:19:47 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 17 lines
Hi Jernej,
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 14 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care of allocating the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs some driver changes), I get frames out of order. If I use native NV12 tiled format,frames
Quoted 7 lines
Quoted 7 lines
are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this general issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of
short
Quoted 3 lines
Quoted 2 lines
scenes. It's pretty obvious when frames are out of order.
Quoted 7 lines
Quoted 1 line
I checked on imx8 and cannot observe any such artifacts.
I finally found the issue. As you mentioned on Slack, register write order once already affected decoding. Well, it's the case again. I made hacky test and moved postproc enable call after output buffers are set and it worked. So, this is actually core quirk which is obviously fixed in newer variants.
Ugh, good catch.
What happens if you move all the calls to HANTRO_PP_REG_WRITE_S (HANTRO_PP_REG_WRITE does a relaxed write)?
Or what happens if the HANTRO_PP_REG_WRITE(vpu, out_luma_base, dst_dma) is moved to be done after all the other registers?
Quoted 3 lines
This makes this series with minor adaptations completely working on H6. I see no reason not to merge whole series.
Do you have plans to submit your H6 work on top of this?
Thanks,
Ezequiel
Quoted 198 lines
Thanks for testing.
Best regards,
JernejQuoted 5 lines
Andrzej
Quoted 2 lines
However, given that frames themself are correctly decoded and without postprocessing in right order, that shouldn't block merging previous
patches.
Quoted 36 lines
Quoted 36 lines
I tried few different videos and frames were all decoded correctly.
Best regards,
Jernejdrivers/
Quoted 11 lines
Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)drivers/ renamed from drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0
staging/media/hantro/hantro_g2_vp9_dec.cdrivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_output(struct hantro_ctx *ctx, · line 155
Quoted 8 lines
index
7f827b9f0133..1a26be72c878100644drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 191
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx, hantro_reg_write(ctx->dev, &ref_reg->hor_scale, (refw << 14) /
dst->vp9.width);drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 192
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_reg_write(ctx->dev, &ref_reg->ver_scale, (refh << 14) /
dst->vp9.height);Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
-
luma_addr= vb2_dma_contig_plane_dma_addr(&buf->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx*ctx,
Quoted 11 lines
Quoted 11 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx · line 241
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params- golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params- alt_frame_ts); - mv_addr = vb2_dma_contig_plane_dma_addr(&mv_ref->base.vb.vb2_buf,0) +
Quoted 4 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr);Quoted 6 lines
Quoted 6 lines
drivers/staging/
Quoted 1 line
drivers/staging/ renamed from drivers/staging/media/hantro/hantro_hw.h +0
-0
media/hantro/hantro_hw.hdrivers/staging/media/hantro/hantro_hw.h extern const struct hantro_variant
Quoted 4 lines
index
2961d399fd60..3d4a5dc1e6d5100644drivers/staging/media/hantro/hantro_hw.h +0
-0@@ -274,6 +274,7 @@ extern const struct hantro_variant
rk3399_vpu_variant;Quoted 18 lines
Quoted 18 lines
drivers/
Quoted 8 lines
drivers/staging/media/hantro/hantro_hw.h +1
-0extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];drivers/ renamed from drivers/staging/media/hantro/hantro_postproc.c +0
-0
staging/media/hantro/hantro_postproc.cQuoted 9 lines
index
4549aec08feb..79a66d001738100644drivers/staging/media/hantro/hantro_postproc.c +1
-0@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h" Quoted 3 lines
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0#define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct
hantro_ctxQuoted 40 lines
Quoted 40 lines
*ctx)
Quoted 5 lines
drivers/staging/media/hantro/hantro_postproc.c +2
-0HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +static void hantro_postproc_g2_enable (struct hantro_ctx *ctx) +{drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
Quoted 10 lines
drivers/staging/media/hantro/hantro_postproc.c +10
-0+struct hantro_dev *vpu = ctx->dev; +struct vb2_v4l2_buffer *dst_buf; +size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); + hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma +
chroma_offset);drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_disable(struct
Quoted 19 lines
drivers/staging/media/hantro/hantro_postproc.c +6
-0+hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx- dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx- dst_fmt.height);for (i = 0; i < num_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];drivers/staging/media/hantro/hantro_postproc.c +0
-0@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct
hantro_ctx*ctx)Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); }Quoted 11 lines
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c const struct hantro_postproc_ops
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c +7
-0+static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -172,3 +198,8 @@ const struct hantro_postproc_ops
hantro_g1_postproc_opsQuoted 10 lines
Quoted 10 lines
= {
drivers/
Quoted 9 lines
drivers/staging/media/hantro/hantro_postproc.c +5
-0.enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};drivers/ renamed from drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0staging/
Quoted 5 lines
Quoted 5 lines
media/hantro/imx8m_vpu_hw.cdrivers/staging/media/hantro/imx8m_vpu_hw.c static const struct hantro_fmt imx8m_vpu_dec_fmts[]
Quoted 4 lines
index
455a107ffb02..1a43f6fceef9100644drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0@@ -132,6 +132,14 @@ static const struct hantro_fmt imx8m_vpu_dec_fmts[]= {
Quoted 32 lines
Quoted 30 lines
Quoted 28 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +11
-1}, }; +static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init, --2.17.1
Re: Re: Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Dne sreda, 20. oktober 2021 ob 13:06:59 CEST je Ezequiel Garcia napisal(a):
Quoted 3 lines
Hi Jernej,
On Tue, 19 Oct 2021 at 13:38, Jernej Škrabec <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Hi Andrzej!
Dne petek, 15. oktober 2021 ob 19:19:47 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
Hi Jernej,
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 3 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej
Pietrasiewicz
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
napisal(a):
Quoted 4 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care of
allocating
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.
Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs some
driver
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
changes), I get frames out of order. If I use native NV12 tiled
format,
Quoted 4 lines
Quoted 4 lines
frames
Quoted 3 lines
Quoted 3 lines
are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this
general
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines
issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of
short
Quoted 4 lines
Quoted 2 lines
scenes. It's pretty obvious when frames are out of order.
I checked on imx8 and cannot observe any such artifacts.
I finally found the issue. As you mentioned on Slack, register write order
once
Quoted 2 lines
Quoted 2 lines
already affected decoding. Well, it's the case again. I made hacky test and moved postproc enable call after output buffers are set and it worked. So,
this
Quoted 10 lines
Quoted 2 lines
is actually core quirk which is obviously fixed in newer variants.
Ugh, good catch.
What happens if you move all the calls to
HANTRO_PP_REG_WRITE_S(HANTRO_PP_REG_WRITEdoes a relaxed write)?Or what happens if the
HANTRO_PP_REG_WRITE(vpu, out_luma_base, dst_dma)is moved to be done after all the other registers?
Those two macros aren't used on G2. Andrzej introduced new postproc helpers for G2.
This commit solves issue for H6:
https://github.com/jernejsk/linux-1/commit/a783a977c0843bb4b555dc9d0b5d64915cd219e7
Quoted 2 lines
Quoted 2 lines
This makes this series with minor adaptations completely working on H6. I
see
Quoted 4 lines
Quoted 2 lines
no reason not to merge whole series.
Do you have plans to submit your H6 work on top of this?
Of course, why would I work on this otherwise? :) But before I do that, I have to clean up and split one commit, which adapts VP9 G2 code for H6 variant.
If you're interested in changes, take a look here:
https://github.com/jernejsk/linux-1/commits/vp9
Best regards,
Jernej
Quoted 28 lines
Thanks,
EzequielQuoted 23 lines
Thanks for testing.
Best regards,
JernejQuoted 5 lines
Andrzej
Quoted 2 lines
However, given that frames themself are correctly decoded and without postprocessing in right order, that shouldn't block merging previous
patches.
Quoted 12 lines
Quoted 12 lines
I tried few different videos and frames were all decoded correctly.
Best regards,
JernejQuoted 7 lines
Signed-off-by Ezequiel Garcia <[email protected]>Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- .../staging/media/hantro/hantro_g2_vp9_dec.c | 6 ++-- drivers/staging/media/hantro/hantro_hw.h | 1 + .../staging/media/hantro/hantro_postproc.c | 31 ++++++++++++++++
+++
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 +++++++ 4 files changed, 46 insertions(+), 3 deletions(-)(quoted diff) renamed from drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0
drivers/
Quoted 33 lines
Quoted 33 lines
Quoted 20 lines
Quoted 20 lines
staging/media/hantro/hantro_g2_vp9_dec.cdrivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_output(struct hantro_ctx *ctx, · line 155
Quoted 8 lines
index
7f827b9f0133..1a26be72c878100644drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1@@ -152,7 +152,7 @@ static void config_output(struct hantro_ctx *ctx,hantro_reg_write (ctx->dev, &g2_out_dis,0 );hantro_reg_write (ctx->dev, &g2_output_format,0 ); - luma_addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 191
Quoted 6 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &dst->base.vb.vb2_buf);hantro_write_addr (ctx->dev,G2_OUT_LUMA_ADDR , luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -191,7 +191,7 @@ static void config_ref(struct hantro_ctx *ctx, hantro_reg_write(ctx->dev, &ref_reg->hor_scale, (refw << 14) /
dst->vp9.width);drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref(struct hantro_ctx *ctx, · line 192
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0hantro_reg_write(ctx->dev, &ref_reg->ver_scale, (refh << 14) /
dst->vp9.height);Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
-
luma_addr= vb2_dma_contig_plane_dma_addr(&buf->base.vb.vb2_buf,0);
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ luma_addr =hantro_get_dec_buf_addr (ctx, &buf->base.vb.vb2_buf);hantro_write_addr (ctx->dev, ref_reg->y_base, luma_addr); chroma_addr = luma_addr +chroma_offset (ctx, dec_params);@@ -236,7 +236,7 @@ static void config_ref_registers(struct hantro_ctx*ctx,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-0config_ref (ctx, dst, &ref_regs[1 ], dec_params, dec_params- golden_frame_ts);config_ref (ctx, dst, &ref_regs[2 ], dec_params, dec_params- alt_frame_ts);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c static void config_ref_registers(struct hantro_ctx · line 241
Quoted 1 line
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0
-1- mv_addr = vb2_dma_contig_plane_dma_addr(&mv_ref->base.vb.vb2_buf,0) +
drivers/
Quoted 5 lines
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +1
-0+ mv_addr =hantro_get_dec_buf_addr (ctx, &mv_ref->base.vb.vb2_buf) +mv_offset (ctx, dec_params);hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr);drivers/ renamed from drivers/staging/media/hantro/hantro_hw.h +0
-0
staging/
Quoted 91 lines
Quoted 91 lines
Quoted 5 lines
Quoted 5 lines
media/hantro/hantro_hw.hdrivers/staging/media/hantro/hantro_hw.h extern const struct hantro_variant
Quoted 4 lines
index
2961d399fd60..3d4a5dc1e6d5100644drivers/staging/media/hantro/hantro_hw.h +0
-0@@ -274,6 +274,7 @@ extern const struct hantro_variant
rk3399_vpu_variant;Quoted 18 lines
Quoted 18 lines
drivers/
Quoted 8 lines
drivers/staging/media/hantro/hantro_hw.h +1
-0extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_postproc_ops hantro_g1_postproc_ops; +extern const struct hantro_postproc_ops hantro_g2_postproc_ops;extern const u32 hantro_vp8_dec_mc_filter[8 ][6 ];drivers/ renamed from drivers/staging/media/hantro/hantro_postproc.c +0
-0
staging/media/hantro/hantro_postproc.cQuoted 9 lines
index
4549aec08feb..79a66d001738100644drivers/staging/media/hantro/hantro_postproc.c +1
-0@@ -11,6 +11,7 @@#include "hantro.h" #include "hantro_hw.h" #include "hantro_g1_regs.h" +#include "hantro_g2_regs.h" Quoted 3 lines
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct
Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0#define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \@@ -99,6 +100,21 @@ static void hantro_postproc_g1_enable(struct
hantro_ctxQuoted 40 lines
Quoted 40 lines
*ctx)
Quoted 5 lines
drivers/staging/media/hantro/hantro_postproc.c +2
-0HANTRO_PP_REG_WRITE (vpu, display_width, ctx->dst_fmt.width); } +static void hantro_postproc_g2_enable (struct hantro_ctx *ctx) +{drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_enable(struct hantro_ctx *ctx)
Quoted 10 lines
drivers/staging/media/hantro/hantro_postproc.c +10
-0+struct hantro_dev *vpu = ctx->dev; +struct vb2_v4l2_buffer *dst_buf; +size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height; +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 ); + +hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma); + hantro_write_addr(vpu, G2_RS_OUT_CHROMA_ADDR, dst_dma +
chroma_offset);drivers/staging/media/hantro/hantro_postproc.c static void hantro_postproc_g1_disable(struct
Quoted 19 lines
drivers/staging/media/hantro/hantro_postproc.c +6
-0+hantro_reg_write (vpu, &g2_out_rs_e,1 ); +} +void hantro_postproc_free (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -127,6 +143,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, ctx- dst_fmt.height); +else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) + buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, + ctx- dst_fmt.height);for (i = 0; i < num_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];drivers/staging/media/hantro/hantro_postproc.c +0
-0@@ -152,6 +171,13 @@ static void hantro_postproc_g1_disable(struct
hantro_ctx*ctx)Quoted 3 lines
drivers/staging/media/hantro/hantro_postproc.c +0
-0HANTRO_PP_REG_WRITE_S (vpu, pipeline_en,0x0 ); }Quoted 11 lines
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c const struct hantro_postproc_ops
Quoted 11 lines
drivers/staging/media/hantro/hantro_postproc.c +7
-0+static void hantro_postproc_g2_disable (struct hantro_ctx *ctx) +{ +struct hantro_dev *vpu = ctx->dev; + +hantro_reg_write (vpu, &g2_out_rs_e,0 ); +} +void hantro_postproc_disable (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;@@ -172,3 +198,8 @@ const struct hantro_postproc_ops
hantro_g1_postproc_opsQuoted 10 lines
Quoted 10 lines
= {
drivers/
Quoted 9 lines
drivers/staging/media/hantro/hantro_postproc.c +5
-0.enable = hantro_postproc_g1_enable, .disable = hantro_postproc_g1_disable, }; + +const struct hantro_postproc_ops hantro_g2_postproc_ops = { + .enable = hantro_postproc_g2_enable, + .disable = hantro_postproc_g2_disable, +};drivers/ renamed from drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0staging/
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
media/hantro/imx8m_vpu_hw.cdrivers/staging/media/hantro/imx8m_vpu_hw.c static const struct hantro_fmt
Quoted 4 lines
index
455a107ffb02..1a43f6fceef9100644drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0@@ -132,6 +132,14 @@ static const struct hantro_fmt
imx8m_vpu_dec_fmts[]
Quoted 4 lines
Quoted 4 lines
= {
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +0
-0}, };
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +4
-0+static const struct hantro_fmt imx8m_vpu_g2_postproc_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE ,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c const struct hantro_variant imx8mq_vpu_g2_variant
Quoted 8 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +4
-0+ .postprocessed = true, + }, +}; +static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12_4L4 ,@@ -301,6 +309,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant
= {
Quoted 20 lines
Quoted 19 lines
Quoted 17 lines
Quoted 15 lines
Quoted 13 lines
drivers/staging/media/hantro/imx8m_vpu_hw.c +3
-1.dec_offset = 0x0, .dec_fmts = imx8m_vpu_g2_dec_fmts, .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), + .postproc_fmts = imx8m_vpu_g2_postproc_fmts, + .num_postproc_fmts = ARRAY_SIZE(imx8m_vpu_g2_postproc_fmts), + .postproc_ops = &hantro_g2_postproc_ops, .codec = HANTRO_HEVC_DECODER | HANTRO_VP9_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, .init = imx8mq_vpu_hw_init, --2.17.1
Re: Re: Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Quoted 57 lines · Jernej Škrabec
Dne sreda, 20. oktober 2021 ob 13:06:59 CEST je Ezequiel Garcia napisal(a):
Quoted 3 lines
Hi Jernej,
On Tue, 19 Oct 2021 at 13:38, Jernej Škrabec <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Hi Andrzej!
Dne petek, 15. oktober 2021 ob 19:19:47 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 6 lines
Hi Jernej,
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 3 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej
Pietrasiewicz
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
napisal(a):
Quoted 4 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular NV12.The logic in
hantro_postproc.cis leveraged to take care ofallocating
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.
Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs somedriver
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
changes), I get frames out of order. If I use native NV12 tiled
format,
Quoted 4 lines
Quoted 4 lines
frames
Quoted 3 lines
Quoted 3 lines
are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this
general
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines
issue.
I would be grateful if anyone can test frame order with and without postprocessing enabled on imx8. Take some dynamic video with a lot of
short
Quoted 4 lines
Quoted 2 lines
scenes. It's pretty obvious when frames are out of order.
I checked on imx8 and cannot observe any such artifacts.
I finally found the issue. As you mentioned on Slack, register write order
once
Quoted 2 lines
Quoted 2 lines
already affected decoding. Well, it's the case again. I made hacky test and moved postproc enable call after output buffers are set and it worked. So,
this
Quoted 5 lines
Quoted 2 lines
is actually core quirk which is obviously fixed in newer variants.
Ugh, good catch.
Quoted 9 lines
Quoted 5 lines
What happens if you move all the calls to
HANTRO_PP_REG_WRITE_S(HANTRO_PP_REG_WRITEdoes a relaxed write)?Or what happens if the
HANTRO_PP_REG_WRITE(vpu, out_luma_base, dst_dma)is moved to be done after all the other registers?Those two macros aren't used on G2. Andrzej introduced new postproc helpers for G2.
Ah, so the issue is specific on the G2 post-processor.
Quoted 4 lines
This commit solves issue for H6:
https://github.com/jernejsk/linux-1/commit/a783a977c0843bb4b555dc9d0b5d64915cd219e7
Right, but see this comment:
/* Turn on pipeline mode. Must be done first. */
HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x1);I have vague recollection of why we have that comment, but I'm reluctant to move post-proc enable to the end. (or at least not do it on G1?).
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
This makes this series with minor adaptations completely working on H6. I
see
Quoted 4 lines
Quoted 2 lines
no reason not to merge whole series.
Do you have plans to submit your H6 work on top of this?
Of course, why would I work on this otherwise? :) But before I do that, I have to clean up and split one commit, which adapts VP9 G2 code for H6 variant.
OK, sounds good.
Quoted 3 lines
If you're interested in changes, take a look here:
https://github.com/jernejsk/linux-1/commits/vp9
Will take a look.
Thanks,
Ezequiel
Re: Re: Re: Re: [PATCH v7 11/11] media: hantro: Support NV12 on the G2 core
Dne sreda, 20. oktober 2021 ob 17:25:40 CEST je Ezequiel Garcia napisal(a):
Quoted 1 line
On Wed, 20 Oct 2021 at 12:04, Jernej Škrabec <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Dne sreda, 20. oktober 2021 ob 13:06:59 CEST je Ezequiel Garcia
napisal(a):
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Hi Jernej,
On Tue, 19 Oct 2021 at 13:38, Jernej Škrabec <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines
Hi Andrzej!
Dne petek, 15. oktober 2021 ob 19:19:47 CEST je Andrzej Pietrasiewicz napisal(a):
Quoted 2 lines
Hi Jernej,
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
W dniu 14.10.2021 o 19:42, Jernej Škrabec pisze:
Quoted 3 lines
Hi Andrzej!
Dne sreda, 29. september 2021 ob 18:04:39 CEST je Andrzej
Pietrasiewicz
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
napisal(a):
Quoted 2 lines
The G2 decoder block produces NV12 4x4 tiled format (
NV12_4L4). Enable the G2 post-processor block, in order to produce regular
NV12.
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The logic in
hantro_postproc.cis leveraged to take care ofallocating
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
the extra buffers and configure the post-processor, which is significantly simpler than the one on the G1.
Quick summary of discussion on LibreELEC Slack:
When using NV12 format on Allwinner H6 variant of G2 (needs somedriver
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
changes), I get frames out of order. If I use native NV12 tiled
format,
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
frames
Quoted 3 lines
Quoted 3 lines
are ordered correctly.
Currently I'm not sure if this is issue with my changes or is this
general
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
issue.
I would be grateful if anyone can test frame order with and
without
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
postprocessing enabled on imx8. Take some dynamic video with a lot
of
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
short
Quoted 4 lines
Quoted 2 lines
scenes. It's pretty obvious when frames are out of order.
I checked on imx8 and cannot observe any such artifacts.
I finally found the issue. As you mentioned on Slack, register write
order
Quoted 2 lines
Quoted 2 lines
once
Quoted 1 line
Quoted 1 line
already affected decoding. Well, it's the case again. I made hacky test
and
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
moved postproc enable call after output buffers are set and it worked.
So,
Quoted 6 lines
Quoted 6 lines
this
Quoted 5 lines
Quoted 2 lines
is actually core quirk which is obviously fixed in newer variants.
Ugh, good catch.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
What happens if you move all the calls to
HANTRO_PP_REG_WRITE_S(HANTRO_PP_REG_WRITEdoes a relaxed write)?Or what happens if the
HANTRO_PP_REG_WRITE(vpu, out_luma_base, dst_dma)is moved to be done after all the other registers?Those two macros aren't used on G2. Andrzej introduced new postproc
helpers
Quoted 4 lines
Quoted 2 lines
for G2.
Ah, so the issue is specific on the G2 post-processor.
To be more precise, issue is specific only to old G2 post-processor, found in Allwinner H6. Andrzej tested code with newer G2 core and both locations worked fine.
Quoted 6 lines
Quoted 5 lines
This commit solves issue for H6:
https://github.com/jernejsk/linux-1/commit/a783a977c0843bb4b555dc9d0b5d64915cd219e7
Quoted 8 lines
Right, but see this comment:
/* Turn on pipeline mode. Must be done first. */ HANTRO_PP_REG_WRITE_S(vpu, pipeline_en, 0x1);I have vague recollection of why we have that comment, but I'm reluctant to move post-proc enable to the end. (or at least not do it on G1?).
I missed that. Any idea what would be the cleanest way to move code for G2 only? I can only think of quirk flag in platform specific structure.
Best regards,
Jernej
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
This makes this series with minor adaptations completely working on
H6. I
Quoted 7 lines
Quoted 7 lines
see
Quoted 4 lines
Quoted 2 lines
no reason not to merge whole series.
Do you have plans to submit your H6 work on top of this?
Of course, why would I work on this otherwise? :) But before I do that, I
have
Quoted 14 lines
Quoted 2 lines
to clean up and split one commit, which adapts VP9 G2 code for H6 variant.
OK, sounds good.
Quoted 3 lines
If you're interested in changes, take a look here:
https://github.com/jernejsk/linux-1/commits/vp9Will take a look.
Thanks,
Ezequiel
Hi everyone,
Quoted 16 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Quoted 9 lines
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
I took another look at this, and I'm fairly happy with it.
I'd just like to have an A-b or R-b from Nicolas Dufresne and Daniel Almeida, given they've done a lot of work on the client side of the API.
Another option would be to wait until Jernej finishes the work on Allwinner H6, so we have another hardware supported.
Thanks,
Ezequiel
Quoted 132 lines
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 drivers/staging/media/hantro/hantro_g2.c create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c create mode 100644 include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82--
2.17.1
Hi all,
Andrzej, Jernej, Nicolas, if none of you (or anyone else for that matter) objects, then I'll make a PR for this early next week.
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 drivers/staging/media/hantro/hantro_g2.c create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c create mode 100644 include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Hi Hans,
Le jeudi 11 novembre 2021 à 15:44 +0100, Hans Verkuil a écrit :
Quoted 4 lines
Hi all,
Andrzej, Jernej, Nicolas, if none of you (or anyone else for that matter) objects, then I'll make a PR for this early next week.
I have no objection. I've myself delayed replying as we have been digging a lot into our compliance failures, but I believe we have explained most of them by now and nothing seems to be related to the API.
regards,
Nicolas
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 drivers/staging/media/hantro/hantro_g2.c create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c create mode 100644 include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Hi Hans,
W dniu 12.11.2021 o 16:27, Nicolas Dufresne pisze:
Quoted 8 lines
Hi Hans,
Le jeudi 11 novembre 2021 à 15:44 +0100, Hans Verkuil a écrit :
Quoted 4 lines
Hi all,
Andrzej, Jernej, Nicolas, if none of you (or anyone else for that matter) objects, then I'll make a PR for this early next week.
Quoted 6 lines
I have no objection. I've myself delayed replying as we have been digging a lot into our compliance failures, but I believe we have explained most of them by now and nothing seems to be related to the API.
regards,
Nicolas
I'm fine with making a PR, too.
Andrzej
Quoted 163 lines
Quoted 162 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Hi Hans,
Let me clarify:
W dniu 15.11.2021 o 13:56, Andrzej Pietrasiewicz pisze:
Quoted 11 lines
Hi Hans,
W dniu 12.11.2021 o 16:27, Nicolas Dufresne pisze:
Quoted 8 lines
Hi Hans,
Le jeudi 11 novembre 2021 à 15:44 +0100, Hans Verkuil a écrit :
Quoted 4 lines
Hi all,
Andrzej, Jernej, Nicolas, if none of you (or anyone else for that matter) objects, then I'll make a PR for this early next week.
Quoted 7 lines
Quoted 6 lines
I have no objection. I've myself delayed replying as we have been digging a lot into our compliance failures, but I believe we have explained most of them by now and nothing seems to be related to the API.
regards,
NicolasI'm fine with making a PR, too.
What I meant was this: "I'm fine with you making a PR."
Quoted 170 lines
Andrzej
Quoted 166 lines
Quoted 165 lines
Regards,
Hans
Quoted 157 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation
featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:
V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS =>V4L2_CTRL_TYPE_VP9_COMPRESSED_HDRv4l2_ctrl_vp9_compressed_hdr_probs=>v4l2_ctrl_vp9_compressed_hdrv4l2_vp9_mv_compressed_hdr_probs=>v4l2_vp9_mv_probs
- movedtx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 +
.../staging/media/hantro/hantro_g2_hevc_dec.c| 69 +-drivers/staging/media/hantro/hantro_g2_regs.h| 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 +37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-vp9.c create mode 100644 drivers/staging/media/hantro/hantro_g2.c create mode 100644 drivers/staging/media/hantro/hantro_g2_vp9_dec.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.c create mode 100644 drivers/staging/media/hantro/hantro_vp9.h create mode 100644 drivers/staging/media/rkvdec/rkvdec-vp9.c create mode 100644 include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
Regards,
Andrzej
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Quoted 5 lines · Andrzej Pietrasiewicz
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 2 lines
Andrzej,
Quoted 8 lines
Quoted 4 lines
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
sparse:rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.c hantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?
smatch:rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] rkvdec/rkvdec-vp9.c: rkvdec/rkvdec-vp9.c:236 init_intra_only_probs() error: buffer overflow 'ptr' 90 <= 91 hantro/hantro_g2_vp9_dec.c: hantro/hantro_g2_vp9_dec.c:670 config_probs() error: memcpy() 'adaptive->inter_mode[i]' too small (4 vs 21) hantro/hantro_g2_vp9_dec.c: hantro/hantro_g2_vp9_dec.c:670 config_probs() error: memcpy() 'probs->inter_mode[i]' too small (3 vs 21
Also a bunch of kerneldoc warnings:
include/media/v4l2-vp9.h:30: warning: Function parameter or member 'joint' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_bit' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_fr' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'fr' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:30: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_mv_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx8' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx16' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx32' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'coef' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'inter_mode' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'interp_filter' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'is_inter' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_mode' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:58: warning: Function parameter or member 'mv' not described in 'v4l2_vp9_frame_context' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'intra_inter' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx32p' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx16p' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx8p' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_mode' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'filter' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_joint' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_fp' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'fp' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'coeff' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:93: warning: Function parameter or member 'eob' not described in 'v4l2_vp9_frame_symbol_counts' include/media/v4l2-vp9.h:166: warning: expecting prototype for v4l2_vp9_adapt_coef_probs(). Prototype was for v4l2_vp9_adapt_noncoef_probs() insteaddrivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'vp_clk_pol' not described in 'isp_ccp2_cfg' drivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'lanecfg' not described in 'isp_ccp2_cfg' drivers/media/platform/qcom/venus/core.h:202: warning: Function parameter or member 'sys_err_done' not described in 'venus_core' drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'fw_min_cnt' not described in 'venus_inst' drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'flags' not described in 'venus_inst' drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'dpb_ids' not described in 'venus_inst' drivers/staging/media/hantro/hantro.h:115: warning: Enum value 'HANTRO_MODE_VP9_DEC' not described in enum 'hantro_codec_mode' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_edge' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'misc' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cnts' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'probability_tables' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'frame_context' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cur' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'bsd_ctrl_offset' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map_size' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'ctx_counters_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_info_offset' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_r_info' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_c_info' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_r' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_c' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_r' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_c' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'active_segment' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_enabled' not described in 'hantro_vp9_dec_hw_ctx' drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_data' not described in 'hantro_vp9_dec_hw_ctx'
You can test kerneldoc yourself with: scripts/kernel-doc -none include/media/v4l2-vp9.h
Regards,
Hans
Quoted 168 lines
Regards,
Andrzej
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.
Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.h
which are not touched by the series.
Regards,
Andrzej
Quoted 270 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'adaptive->inter_mode[i]' too small (4 vs 21)hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'probs->inter_mode[i]' too small (3 vs 21Also a bunch of kerneldoc warnings:
include/media/v4l2-vp9.h:30: warning: Function parameter or member 'joint' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_bit' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx8' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx16' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx32' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'coef' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'inter_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'interp_filter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'is_inter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'mv' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'intra_inter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx32p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx16p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx8p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'filter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_joint' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'coeff' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'eob' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:166: warning: expecting prototype forv4l2_vp9_adapt_coef_probs(). Prototype was forv4l2_vp9_adapt_noncoef_probs()insteaddrivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'vp_clk_pol' not described in 'isp_ccp2_cfg'drivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'lanecfg' not described in 'isp_ccp2_cfg'drivers/media/platform/qcom/venus/core.h:202: warning: Function parameter or member 'sys_err_done' not described in 'venus_core'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'fw_min_cnt' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'flags' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'dpb_ids' not described in 'venus_inst'drivers/staging/media/hantro/hantro.h:115: warning: Enum value 'HANTRO_MODE_VP9_DEC' not described in enum 'hantro_codec_mode'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_edge' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'misc' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cnts' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'probability_tables' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'frame_context' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cur' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'bsd_ctrl_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map_size' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'ctx_counters_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_info_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_r_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_c_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'active_segment' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_enabled' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_data' not described in 'hantro_vp9_dec_hw_ctx'You can test kerneldoc yourself with:
scripts/kernel-doc-noneinclude/media/v4l2-vp9.hRegards,
Hans
Quoted 168 lines
Regards,
Andrzej
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Quoted 18 lines · Andrzej Pietrasiewicz
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 15 lines · Andrzej Pietrasiewicz
Quoted 13 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
Quoted 8 lines
Quoted 2 lines
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.h
Ah, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Regards,
Hans
Quoted 278 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 270 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'adaptive->inter_mode[i]' too small (4 vs 21)hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'probs->inter_mode[i]' too small (3 vs 21Also a bunch of kerneldoc warnings:
include/media/v4l2-vp9.h:30: warning: Function parameter or member 'joint' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_bit' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx8' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx16' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx32' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'coef' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'inter_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'interp_filter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'is_inter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'mv' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'intra_inter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx32p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx16p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx8p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'filter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_joint' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'coeff' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'eob' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:166: warning: expecting prototype forv4l2_vp9_adapt_coef_probs(). Prototype was forv4l2_vp9_adapt_noncoef_probs()insteaddrivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'vp_clk_pol' not described in 'isp_ccp2_cfg'drivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'lanecfg' not described in 'isp_ccp2_cfg'drivers/media/platform/qcom/venus/core.h:202: warning: Function parameter or member 'sys_err_done' not described in 'venus_core'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'fw_min_cnt' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'flags' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'dpb_ids' not described in 'venus_inst'drivers/staging/media/hantro/hantro.h:115: warning: Enum value 'HANTRO_MODE_VP9_DEC' not described in enum 'hantro_codec_mode'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_edge' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'misc' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cnts' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'probability_tables' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'frame_context' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cur' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'bsd_ctrl_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map_size' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'ctx_counters_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_info_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_r_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_c_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'active_segment' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_enabled' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_data' not described in 'hantro_vp9_dec_hw_ctx'You can test kerneldoc yourself with:
scripts/kernel-doc-noneinclude/media/v4l2-vp9.hRegards,
Hans
Quoted 168 lines
Regards,
Andrzej
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 573 +++++ .../media/v4l/pixfmt-compressed.rst | 15 + .../media/v4l/vidioc-g-ext-ctrls.rst | 8 + .../media/v4l/vidioc-queryctrl.rst | 12 + .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 180 ++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-vp9.c | 1850 +++++++++++++++++ drivers/staging/media/hantro/Kconfig | 1 + drivers/staging/media/hantro/Makefile | 7 +- drivers/staging/media/hantro/hantro.h | 40 +- drivers/staging/media/hantro/hantro_drv.c | 23 +- drivers/staging/media/hantro/hantro_g2.c | 27 + .../staging/media/hantro/hantro_g2_hevc_dec.c | 69 +- drivers/staging/media/hantro/hantro_g2_regs.h | 132 +- .../staging/media/hantro/hantro_g2_vp9_dec.c | 980 +++++++++ drivers/staging/media/hantro/hantro_hw.h | 83 +- .../staging/media/hantro/hantro_postproc.c | 79 +- drivers/staging/media/hantro/hantro_v4l2.c | 20 + drivers/staging/media/hantro/hantro_vp9.c | 240 +++ drivers/staging/media/hantro/hantro_vp9.h | 103 + drivers/staging/media/hantro/imx8m_vpu_hw.c | 38 +- .../staging/media/hantro/rockchip_vpu_hw.c | 7 +- .../staging/media/hantro/sama5d4_vdec_hw.c | 3 +- drivers/staging/media/rkvdec/Kconfig | 1 + drivers/staging/media/rkvdec/Makefile | 2 +- drivers/staging/media/rkvdec/rkvdec-vp9.c | 1078 ++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 52 +- drivers/staging/media/rkvdec/rkvdec.h | 12 +- include/media/v4l2-ctrls.h | 4 + include/media/v4l2-vp9.h | 182 ++ include/uapi/linux/v4l2-controls.h | 284 +++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6033 insertions(+), 104 deletions(-)create mode 100644
drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Hi,
W dniu 16.11.2021 o 09:21, Hans Verkuil pisze:
Quoted 25 lines · Andrzej Pietrasiewicz
Quoted 24 lines
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
Quoted 7 lines
Quoted 2 lines
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.hAh, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Sure, no problem. Also please see below.
Quoted 21 lines
Regards,
Hans
Quoted 16 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 9 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91
this looks a false positive.
A portion of memory pointed to by ptr is indexed with i * 23 + m, where i ranges from 0 to 3, inclusive, and m ranges from 0 to 22, inclusive if i < 3, otherwise m ranges from 0 to 20, inclusive. So the largest index value we compute equals 89 (3 * 23 + 20). Because ptr points to something that is at least 90 bytes large, 89 is a valid index and no greater index will be ever computed.
Quoted 263 lines
Quoted 262 lines
Quoted 261 lines
hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'adaptive->inter_mode[i]' too small (4 vs 21)hantro/hantro_g2_vp9_dec.c:hantro/hantro_g2_vp9_dec.c:670config_probs()error:memcpy()'probs->inter_mode[i]' too small (3 vs 21Also a bunch of kerneldoc warnings:
include/media/v4l2-vp9.h:30: warning: Function parameter or member 'joint' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_bit' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'fr' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:30: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_mv_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx8' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx16' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'tx32' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'coef' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'inter_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'interp_filter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'is_inter' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:58: warning: Function parameter or member 'mv' not described in 'v4l2_vp9_frame_context'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'partition' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'skip' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'intra_inter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx32p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx16p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'tx8p' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'y_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'uv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'comp_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'single_ref' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_mode' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'filter' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'mv_joint' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'sign' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'classes' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'bits' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'fp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'class0_hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'hp' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'coeff' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:93: warning: Function parameter or member 'eob' not described in 'v4l2_vp9_frame_symbol_counts'include/media/v4l2-vp9.h:166: warning: expecting prototype forv4l2_vp9_adapt_coef_probs(). Prototype was forv4l2_vp9_adapt_noncoef_probs()insteaddrivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'vp_clk_pol' not described in 'isp_ccp2_cfg'drivers/media/platform/omap3isp/omap3isp.h:107: warning: Function parameter or member 'lanecfg' not described in 'isp_ccp2_cfg'drivers/media/platform/qcom/venus/core.h:202: warning: Function parameter or member 'sys_err_done' not described in 'venus_core'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'fw_min_cnt' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'flags' not described in 'venus_inst'drivers/media/platform/qcom/venus/core.h:462: warning: Function parameter or member 'dpb_ids' not described in 'venus_inst'drivers/staging/media/hantro/hantro.h:115: warning: Enum value 'HANTRO_MODE_VP9_DEC' not described in enum 'hantro_codec_mode'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_edge' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'misc' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cnts' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'probability_tables' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'frame_context' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'cur' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'bsd_ctrl_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'segment_map_size' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'ctx_counters_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_info_offset' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_r_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'tile_c_info' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_tile_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_r' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'last_sbs_c' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'active_segment' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_enabled' not described in 'hantro_vp9_dec_hw_ctx'drivers/staging/media/hantro/hantro_hw.h:211: warning: Function parameter or member 'feature_data' not described in 'hantro_vp9_dec_hw_ctx'You can test kerneldoc yourself with:
scripts/kernel-doc-noneinclude/media/v4l2-vp9.hRegards,
Hans
Quoted 168 lines
Regards,
Andrzej
Quoted 161 lines
Regards,
Hans
Quoted 154 lines · Andrzej Pietrasiewicz
Dear all,
This patch series adds VP9 codec V4L2 control interface and two drivers using the new controls. It is a follow-up of previous v6 series [1].
In this iteration, we've implemented VP9 hardware decoding on two devices:
Rockchip VDEC and Hantro G2, and tested on RK3399, i.MX8MQ and i.MX8MP. The i.MX8M driver needs proper power domains support, though, which is a subject of a different effort, but in all 3 cases we were able to run the drivers.GStreamer support is also available, the needed changes have been submitted by Daniel Almeida [2]. This MR is ready to be merged, and just needs the VP9 V4L2 controls to be merged and released.
Both rkvdec and hantro drivers are passing a significant number of VP9 tests using Fluster[3]. There are still a few tests that are not passing, due to dynamic frame resize (not yet supported by V4L2) and small size videos (due to IP block limitations).
The series adds the VP9 codec V4L2 control API as uAPI, so it aims at being merged without passing through staging, as agreed[4]. The ABI has been checked for padding and verified to contain no holes.
[1] https://patchwork.linuxtv.org/project/linux-media/list/?series=6377
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2144
[3] https://github.com/fluendo/fluster
[4] https://lore.kernel.org/linux-media/[email protected]/The series depends on the YUV tiled format support prepared by Ezequiel:
https://www.spinics.net/lists/linux-media/msg197047.htmlRebased onto latest
media_tree.Changes related to v6:
- moved setting tile filter and tile bsd auxiliary buffer addresses so that they are always set, even if no tiles are used (thanks, Jernej)
- added a comment near the place where the 32-bit DMA mask is applied (thanks, Nicolas)
- improved consistency in register names (thanks, Nicolas)Changes related to v5:
- improved the doc comments as per Ezequiel's review (thanks, Ezequiel)
- improved pdf output of documentation
- added Benjamin's Reviewed-by (thanks, Benjamin)Changes related to v4:
- removed unused enumv4l2_vp9_intra_prediction_mode
- converted remaining enums to defines to follow the convention
- improved the documentation, in particular better documented how to use segmentation featuresChanges related to v3:
Apply suggestions from Jernej's review (thanks, Jernej):
- renamed a control and two structs:V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR_PROBS => V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR v4l2_ctrl_vp9_compressed_hdr_probs => v4l2_ctrl_vp9_compressed_hdr v4l2_vp9_mv_compressed_hdr_probs => v4l2_vp9_mv_probs- moved
tx_modetov4l2_ctrl_vp9_compressed_hdr
- fixed enumv4l2_vp9_ref_frame_sign_biasvalues (which are used to test a bitfield)
- explicitly assigned values to all other vp9 enumsApply suggestion from Nicolas's review (thanks, Nicolas):
- explicitly stated that thev4l2_ctrl_vp9_compressed_hdrcontrol is optional and implemented only by drivers which need itChanges related to the RFC v2:
- added another driver including a postprocessor to de-tile codec-specific tiling
- reworked uAPI structs layout to follow VP8 style
- changed validation of loop filter params
- changed validation of segmentation params
- changed validation of VP9 frame params
- removed level lookup array from loop filter struct
(can be computed by drivers)
- renamed some enum values to match the spec more closely
- V4L2 VP9 library changed the 'eob' member of
'structv4l2_vp9_frame_symbol_counts' so that it is an array of pointers instead of an array of pointers to arrays (IPs such as g2 creatively pass parts of the 'eob' counts in the 'coeff' counts)
- factored out several repeated portions of code
- minor nitpicks and cleanupsAndrzej Pietrasiewicz (6):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Rename registers
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
media: hantro: Support NV12 on the G2 coreBoris Brezillon (1):
media: rkvdec: Add the VP9 backendEzequiel Garcia (4):
hantro: postproc: Fix motion vector space size
hantro: postproc: Introduce structhantro_postproc_ops
hantro: Simplify postprocessor
hantro: Add quirk for NV12/NV12_4L4 capture format
.../userspace-api/media/v4l/biblio.rst| 10 +
.../media/v4l/ext-ctrls-codec-stateless.rst| 573 +++++
.../media/v4l/pixfmt-compressed.rst| 15 +
.../media/v4l/vidioc-g-ext-ctrls.rst| 8 +
.../media/v4l/vidioc-queryctrl.rst| 12 +
.../media/videodev2.h.rst.exceptions | 2 +
drivers/media/v4l2-core/Kconfig| 4 +
drivers/media/v4l2-core/Makefile| 1 +
drivers/media/v4l2-core/v4l2-ctrls-core.c| 180 ++
drivers/media/v4l2-core/v4l2-ctrls-defs.c| 8 +
drivers/media/v4l2-core/v4l2-ioctl.c| 1 +
drivers/media/v4l2-core/v4l2-vp9.c| 1850 +++++++++++++++++
drivers/staging/media/hantro/Kconfig| 1 +
drivers/staging/media/hantro/Makefile| 7 +-
drivers/staging/media/hantro/hantro.h| 40 +-
drivers/staging/media/hantro/hantro_drv.c| 23 +-
drivers/staging/media/hantro/hantro_g2.c| 27 +
.../staging/media/hantro/hantro_g2_hevc_dec.c| 69 +-
drivers/staging/media/hantro/hantro_g2_regs.h| 132 +-.../staging/media/hantro/hantro_g2_vp9_dec.c| 980 +++++++++
drivers/staging/media/hantro/hantro_hw.h| 83 +-
.../staging/media/hantro/hantro_postproc.c| 79 +-
drivers/staging/media/hantro/hantro_v4l2.c| 20 +
drivers/staging/media/hantro/hantro_vp9.c| 240 +++
drivers/staging/media/hantro/hantro_vp9.h| 103 +
drivers/staging/media/hantro/imx8m_vpu_hw.c| 38 +-
.../staging/media/hantro/rockchip_vpu_hw.c| 7 +-
.../staging/media/hantro/sama5d4_vdec_hw.c| 3 +-
drivers/staging/media/rkvdec/Kconfig| 1 +
drivers/staging/media/rkvdec/Makefile| 2 +-
drivers/staging/media/rkvdec/rkvdec-vp9.c| 1078 ++++++++++
drivers/staging/media/rkvdec/rkvdec.c| 52 +-
drivers/staging/media/rkvdec/rkvdec.h| 12 +-
include/media/v4l2-ctrls.h| 4 +
include/media/v4l2-vp9.h| 182 ++
include/uapi/linux/v4l2-controls.h| 284 +++
include/uapi/linux/videodev2.h| 6 +
37 files changed, 6033 insertions(+), 104 deletions(-) create mode 100644drivers/media/v4l2-core/v4l2-vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_g2.ccreate mode 100644drivers/staging/media/hantro/hantro_g2_vp9_dec.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.ccreate mode 100644drivers/staging/media/hantro/hantro_vp9.hcreate mode 100644drivers/staging/media/rkvdec/rkvdec-vp9.ccreate mode 100644include/media/v4l2-vp9.hbase-commit:
e4e737bb5c170df6135a127739a9e6148ee3da82
Quoted 60 lines · Andrzej Pietrasiewicz
Hi,
W dniu 16.11.2021 o 09:21, Hans Verkuil pisze:
Quoted 25 lines · Andrzej Pietrasiewicz
Quoted 24 lines
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
Quoted 7 lines
Quoted 2 lines
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.hAh, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Sure, no problem. Also please see below.
Quoted 21 lines
Regards,
Hans
Quoted 16 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 9 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91
Quoted 8 lines
this looks a false positive.
A portion of memory pointed to by ptr is indexed with i * 23 + m, where i ranges from 0 to 3, inclusive, and m ranges from 0 to 22, inclusive if i < 3, otherwise m ranges from 0 to 20, inclusive. So the largest index value we compute equals 89 (3 * 23 + 20). Because ptr points to something that is at least 90 bytes large, 89 is a valid index and no greater index will be ever computed.
But we do need to get rid of this smatch warning, otherwise it will pollute the list of smatch warnings.
I was looking at the code and wonder if it wouldn't make more sense to move writing to rkprobs->intra_mode[i].uv_mode[] into a separate for loop:
for (i = 0; i < ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++)
rkprobs->intra_mode[i / 23].uv_mode[i % 23] = v4l2_vp9_kf_uv_mode_prob[i];Wouldn't that do the same as the current code? It looks simpler as well.
Regards,
Hans
Hi,
W dniu 17.11.2021 o 10:59, Hans Verkuil pisze:
Quoted 73 lines · Andrzej Pietrasiewicz
Quoted 60 lines
Hi,
W dniu 16.11.2021 o 09:21, Hans Verkuil pisze:
Quoted 25 lines · Andrzej Pietrasiewicz
Quoted 24 lines
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
Quoted 7 lines
Quoted 2 lines
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.hAh, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Sure, no problem. Also please see below.
Quoted 21 lines
Regards,
Hans
Quoted 16 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 9 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91Quoted 8 lines
this looks a false positive.
A portion of memory pointed to by ptr is indexed with i * 23 + m, where i ranges from 0 to 3, inclusive, and m ranges from 0 to 22, inclusive if i < 3, otherwise m ranges from 0 to 20, inclusive. So the largest index value we compute equals 89 (3 * 23 + 20). Because ptr points to something that is at least 90 bytes large, 89 is a valid index and no greater index will be ever computed.
But we do need to get rid of this smatch warning, otherwise it will pollute the list of smatch warnings.
Quoted 8 lines
I was looking at the code and wonder if it wouldn't make more sense to move writing to rkprobs->intra_mode[i].uv_mode[] into a separate for loop:
for (i = 0; i < ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) rkprobs->intra_mode[i / 23].uv_mode[i % 23] = v4l2_vp9_kf_uv_mode_prob[i];Wouldn't that do the same as the current code? It looks simpler as well.
I think it would, but I would slightly change the loop:
for (i = 0; i < ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) {
const u8 *ptr = (const u8 *)v4l2_vp9_kf_uv_mode_prob;
rkprobs->intra_mode[i / 23].uv_mode[i % 23] = ptr[i];
}because v4l2_vp9_kf_uv_mode_prob is actually a u8[10][9].
I will make such a change locally and test whether it causes regressions.
Once I confirm it works (and I expect I will) would you like me to post a v9,
only reply to the changed patch with its updated version or do you want to make this change yourself?
Andrzej
Hi again,
W dniu 17.11.2021 o 11:49, Andrzej Pietrasiewicz pisze:
Quoted 82 lines
Hi,
W dniu 17.11.2021 o 10:59, Hans Verkuil pisze:
Quoted 79 lines · Andrzej Pietrasiewicz
Quoted 60 lines
Hi,
W dniu 16.11.2021 o 09:21, Hans Verkuil pisze:
Quoted 25 lines · Andrzej Pietrasiewicz
Quoted 24 lines
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
Quoted 7 lines
Quoted 2 lines
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.hAh, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Sure, no problem. Also please see below.
Quoted 21 lines
Regards,
Hans
Quoted 16 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 9 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91Quoted 8 lines
this looks a false positive.
A portion of memory pointed to by ptr is indexed with i * 23 + m, where i ranges from 0 to 3, inclusive, and m ranges from 0 to 22, inclusive if i < 3, otherwise m ranges from 0 to 20, inclusive. So the largest index value we compute equals 89 (3 * 23 + 20). Because ptr points to something that is at least 90 bytes large, 89 is a valid index and no greater index will be ever computed.
But we do need to get rid of this smatch warning, otherwise it will pollute the list of smatch warnings.
I was looking at the code and wonder if it wouldn't make more sense to move writing to rkprobs->intra_mode[i].uv_mode[] into a separate for loop:
for (i = 0; i <
ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) rkprobs->intra_mode[i / 23].uv_mode[i % 23] = v4l2_vp9_kf_uv_mode_prob[i];
Quoted 6 lines
Quoted 2 lines
Wouldn't that do the same as the current code? It looks simpler as well.
I think it would, but I would slightly change the loop:
for (i = 0; i <
ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) {
actually, sizeof(v4l2_vp9_kf_uv_mode_prob)
Quoted 13 lines
const u8 *ptr = (const u8 *)v4l2_vp9_kf_uv_mode_prob;
rkprobs->intra_mode[i / 23].uv_mode[i % 23] = ptr[i]; }
because
v4l2_vp9_kf_uv_mode_probis actually a u8[10][9].I will make such a change locally and test whether it causes regressions.
Once I confirm it works (and I expect I will) would you like me to post a v9,
only reply to the changed patch with its updated version or do you want to make this change yourself?Andrzej
Hi Hans,
W dniu 17.11.2021 o 11:51, Andrzej Pietrasiewicz pisze:
Quoted 85 lines
Hi again,
W dniu 17.11.2021 o 11:49, Andrzej Pietrasiewicz pisze:
Quoted 82 lines
Hi,
W dniu 17.11.2021 o 10:59, Hans Verkuil pisze:
Quoted 79 lines · Andrzej Pietrasiewicz
Quoted 60 lines
Hi,
W dniu 16.11.2021 o 09:21, Hans Verkuil pisze:
Quoted 25 lines · Andrzej Pietrasiewicz
Quoted 24 lines
Hi Hans,
W dniu 15.11.2021 o 22:16, Hans Verkuil pisze:
Quoted 11 lines · Andrzej Pietrasiewicz
Quoted 10 lines
Hi Hans,
W dniu 15.11.2021 o 16:07, Hans Verkuil pisze:
Quoted 6 lines
Andrzej,
Can you rebase this series on top of the master branch of
https://git.linuxtv.org/media_stage.git/ ? Unfortunately this v7 no longer applies. Specifically "rkvdec: Add the VP9 backend" failed in a non-trivial manner.Quoted 6 lines
Quoted 3 lines
This is a branch for you:
https://gitlab.collabora.com/linux/for-upstream/-/tree/vp9-uapi
I'm getting a bunch of sparse/smatch warnings:
Thanks for finding this, I will re-create the branch and let you know on irc. Some of the below are "false positives, namely:
Quoted 7 lines
Quoted 2 lines
drivers/media/platform/omap3isp/omap3isp.hdrivers/media/platform/qcom/venus/core.hAh, sorry, I though I had filtered those out. Obviously you can ignore those.
Please post a v8. That way the series is archived on lore. And it works better with patchwork.
Sure, no problem. Also please see below.
Quoted 21 lines
Regards,
Hans
Quoted 16 lines
which are not touched by the series.
Regards,
Andrzej
Quoted 9 lines
sparse:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable] SPARSE:hantro/hantro_postproc.chantro/hantro_postproc.c:37:35: warning: symbol 'hantro_g1_postproc_regs' was not declared. Should it be static?smatch:
rkvdec/rkvdec-vp9.c:190:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:245:43: warning: variable 'dec_params' set but not used [-Wunused-but-set-variable]rkvdec/rkvdec-vp9.c:rkvdec/rkvdec-vp9.c:236init_intra_only_probs()error: buffer overflow 'ptr' 90 <= 91Quoted 8 lines
this looks a false positive.
A portion of memory pointed to by ptr is indexed with i * 23 + m, where i ranges from 0 to 3, inclusive, and m ranges from 0 to 22, inclusive if i < 3, otherwise m ranges from 0 to 20, inclusive. So the largest index value we compute equals 89 (3 * 23 + 20). Because ptr points to something that is at least 90 bytes large, 89 is a valid index and no greater index will be ever computed.
But we do need to get rid of this smatch warning, otherwise it will pollute the list of smatch warnings.
I was looking at the code and wonder if it wouldn't make more sense to move writing to rkprobs->intra_mode[i].uv_mode[] into a separate for loop:
for (i = 0; i <
ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) rkprobs->intra_mode[i / 23].uv_mode[i % 23] = v4l2_vp9_kf_uv_mode_prob[i];
Quoted 19 lines
Quoted 6 lines
Quoted 2 lines
Wouldn't that do the same as the current code? It looks simpler as well.
I think it would, but I would slightly change the loop:
for (i = 0; i <
ARRAY_SIZE(v4l2_vp9_kf_uv_mode_prob); i++) {actually,
sizeof(v4l2_vp9_kf_uv_mode_prob)Quoted 8 lines
const u8 *ptr = (const u8 *)v4l2_vp9_kf_uv_mode_prob;
rkprobs->intra_mode[i / 23].uv_mode[i % 23] = ptr[i]; }
because
v4l2_vp9_kf_uv_mode_probis actually a u8[10][9].I will make such a change locally and test whether it causes regressions.
This worked, no regressions:
for (i = 0; i < sizeof(v4l2_vp9_kf_uv_mode_prob); ++i) {
const u8 *ptr = (const u8 *)v4l2_vp9_kf_uv_mode_prob;
rkprobs->intra_mode[i / 23].uv_mode[i % 23] = ptr[i];
}Andrzej