VP9 codec V4L2 control interface
Subsystems (4)
v4 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 v3 series [1].
In this new 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://www.spinics.net/lists/arm-kernel/msg913433.html
[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]/
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
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.
Andrzej Pietrasiewicz (4):
media: uapi: Add VP9 stateless decoder controls
media: Add VP9 v4l2 library
media: hantro: Prepare for other G2 codecs
media: hantro: Support VP9 on the G2 core
Boris Brezillon (1):
media: rkvdec: Add the VP9 backend
Ezequiel Garcia (5):
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
media: hantro: Support NV12 on the G2 core
.../userspace-api/media/v4l/biblio.rst | 10 + .../media/v4l/ext-ctrls-codec-stateless.rst | 545 +++++ .../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 | 18 +- 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 | 104 + .../staging/media/hantro/hantro_g2_vp9_dec.c | 978 +++++++++ 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 | 437 ++++ include/uapi/linux/videodev2.h | 6 + 37 files changed, 6118 insertions(+), 71 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: ee49938e86dab00e884fd2675d5004999dc467c7
Signature · 1 line
2.17.1
PATCH v4 1/10 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 v4 2/10 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 v4 3/10 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 v4 4/10 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 v4 5/10 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 | 545 ++++++++++++++++++ .../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 | 437 ++++++++++++++ include/uapi/linux/videodev2.h | 6 + 12 files changed, 1228 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 +545 -0
548 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 +437 -0
443 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 v4 6/10 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 v4 7/10 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
PATCH v4 8/10 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_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 ++ 6 files changed, 44 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_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 , 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 v4 9/10 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 | 978 ++++++++++++++++++ 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, 1560 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 +978 -0
978 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 v4 10/10 media: hantro: Support NV12 on the G2 core
In reply to Andrzej PietrasiewiczFrom: Ezequiel Garcia <[email protected]>
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.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_ADDR_DST , 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_REG_DMV_REF (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_RASTER_SCAN , dst_dma); +hantro_write_addr (vpu,G2_RASTER_SCAN_CHR , 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