hantro: Add RK3399 VP8 decoding support
Subsystems (4)
cover hantro: Add RK3399 VP8 decoding support
This series adds VP8 decoding support on RK3399 SoC.
I'm including a set of commits from Boris' recent H264 series [1]. These commits add some helpers that are also useful for RK3399 VP8, and at the same time cleanup the driver nicely.
Finally, there's a fix by Francois Buergisser from Chromium team.
VP8 and MPEG-2 tested on RK3399 RockPi and RK3288 Rock2 boards.
[1] https://patchwork.kernel.org/cover/11003971/
Boris Brezillon (4):
media: hantro: Simplify the controls creation logic
media: hantro: Constify the control array
media: hantro: Add hantro_get_{src,dst}_buf() helpers
media: hantro: Add helpers to prepare/finish a run
Ezequiel Garcia (1):
media: hantro: Move VP8 common code
Francois Buergisser (1):
media: hantro: Set DMA max segment size
Jeffy Chen (1):
media: hantro: Support RK3399 VP8 decoding
drivers/staging/media/hantro/Makefile | 1 + drivers/staging/media/hantro/hantro.h | 15 +- drivers/staging/media/hantro/hantro_drv.c | 53 +- .../media/hantro/hantro_g1_mpeg2_dec.c | 14 +- .../staging/media/hantro/hantro_g1_vp8_dec.c | 34 +- .../staging/media/hantro/hantro_h1_jpeg_enc.c | 11 +- drivers/staging/media/hantro/hantro_hw.h | 7 + drivers/staging/media/hantro/hantro_vp8.c | 15 + drivers/staging/media/hantro/rk3399_vpu_hw.c | 22 +- .../media/hantro/rk3399_vpu_hw_jpeg_enc.c | 12 +- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 +- .../media/hantro/rk3399_vpu_hw_vp8_dec.c | 597 ++++++++++++++++++ 12 files changed, 711 insertions(+), 84 deletions(-) create mode 100644 drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
Signature · 1 line
2.22.0
PATCH 1/7 media: hantro: Set DMA max segment size
From: Francois Buergisser <[email protected]>
The Hantro codec is typically used in platforms with an IOMMU, so we need to set a proper DMA segment size. Devices without an IOMMU will still fallback to default 64KiB segments.
--- drivers/staging/media/hantro/hantro_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/hantro/hantro_drv.c +1 -0
@@ -731,6 +731,7 @@ static int hantro_probe(struct platform_device *pdev)dev_err (vpu->dev,"Could not set DMA coherent mask.\n" );return ret; } +vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 ));for (i =0 ; i < vpu->variant->num_irqs; i++) {const char *irq_name = vpu->variant->irqs[i].name;
Signature · 1 line
2.22.0
PATCH 2/7 media: hantro: Simplify the controls creation logic
In reply to Ezequiel GarciaFrom: Boris Brezillon <boris.brezillon-ZGY8ohtN/[email protected]>
v4l2_ctrl_new_custom() should work for any kind of control, including standard ones. With that change, we automatically get support for menu controls.
--- drivers/staging/media/hantro/hantro.h | 2 -- drivers/staging/media/hantro/hantro_drv.c | 28 +++++++---------------- 2 files changed, 8 insertions(+), 22 deletions(-)
drivers/staging/media/hantro/hantro.h +0 -2
@@ -113,12 +113,10 @@ enum hantro_codec_mode {/* * struct hantro_ctrl - helper type to declare supported controls -* @id: V4L2 control ID (V4L2_CID_xxx) * @codec: codec id this control belong to (HANTRO_JPEG_ENCODER, etc.) * @cfg: control configuration */ struct hantro_ctrl { -unsigned int id;unsigned int codec;struct v4l2_ctrl_config cfg; };
drivers/staging/media/hantro/hantro_drv.c +8 -20
@@ -264,31 +264,29 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {static struct hantro_ctrl controls[] = { { - .id =V4L2_CID_JPEG_COMPRESSION_QUALITY , .codec =HANTRO_JPEG_ENCODER , .cfg = { + .id =V4L2_CID_JPEG_COMPRESSION_QUALITY , .min =5 , .max =100 , .step =1 , .def =50 , + .ops = &hantro_ctrl_ops, }, }, { - .id =V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS , .codec =HANTRO_MPEG2_DECODER , .cfg = { - .elem_size =sizeof (struct v4l2_ctrl_mpeg2_slice_params ), + .id =V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS , }, }, { - .id =V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION , .codec =HANTRO_MPEG2_DECODER , .cfg = { - .elem_size =sizeof (struct v4l2_ctrl_mpeg2_quantization ), + .id =V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION , }, }, { - .id =V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER , .codec =HANTRO_VP8_DECODER , .cfg = { - .elem_size =sizeof (struct v4l2_ctrl_vp8_frame_header ), + .id =V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER , }, }, };
@@ -304,22 +302,12 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,for (i =0 ; i < num_ctrls; i++) {if (!(allowed_codecs & controls[i].codec))continue ; -if (!controls[i].cfg.elem_size) { -v4l2_ctrl_new_std (&ctx->ctrl_handler, - &hantro_ctrl_ops, - controls[i].id, controls[i].cfg.min, - controls[i].cfg.max, - controls[i].cfg.step, - controls[i].cfg.def); - }else { - controls[i].cfg.id = controls[i].id; -v4l2_ctrl_new_custom (&ctx->ctrl_handler, - &controls[i].cfg,NULL ); - } +v4l2_ctrl_new_custom (&ctx->ctrl_handler, + &controls[i].cfg,NULL );if (ctx->ctrl_handler.error) {vpu_err ("Adding control (%d) failed %d\n" , - controls[i].id, + controls[i].cfg.id, ctx->ctrl_handler.error);v4l2_ctrl_handler_free (&ctx->ctrl_handler);return ctx->ctrl_handler.error;
Signature · 1 line
2.22.0
PATCH 3/7 media: hantro: Constify the control array
In reply to Ezequiel GarciaFrom: Boris Brezillon <boris.brezillon-ZGY8ohtN/[email protected]>
controls[] is not supposed to be modified at runtime, let's make it explicit by adding a const specifier.
--- drivers/staging/media/hantro/hantro_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_drv.c +1 -1
@@ -262,7 +262,7 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = { .s_ctrl = hantro_s_ctrl, }; -static struct hantro_ctrl controls[] = { +static const struct hantro_ctrl controls[] = { { .codec =HANTRO_JPEG_ENCODER , .cfg = {
Signature · 1 line
2.22.0
PATCH 4/7 media: hantro: Add hantro_get_{src,dst}_buf() helpers
In reply to Ezequiel GarciaFrom: Boris Brezillon <boris.brezillon-ZGY8ohtN/[email protected]>
And replace all calls to v4l2_m2m_next_{src,dst}_buf() by hantro_get_{src,dst}_buf() one.
--- drivers/staging/media/hantro/hantro.h | 13 +++++++++++++ drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c | 4 ++-- drivers/staging/media/hantro/hantro_g1_vp8_dec.c | 8 ++++---- drivers/staging/media/hantro/hantro_h1_jpeg_enc.c | 4 ++-- .../staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c | 4 ++-- .../staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 4 ++-- 6 files changed, 25 insertions(+), 12 deletions(-)
drivers/staging/media/hantro/hantro.h +13 -0
@@ -20,6 +20,7 @@#include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> +#include <media/v4l2-mem2mem.h> #include <media/videobuf2-core.h> #include <media/videobuf2-dma-contig.h>
@@ -373,4 +374,16 @@ bool hantro_is_encoder_ctx(const struct hantro_ctx *ctx);void *hantro_get_ctrl (struct hantro_ctx *ctx,u32 id);dma_addr_t hantro_get_ref (struct vb2_queue *q,u64 ts); +static inline struct vb2_v4l2_buffer * +hantro_get_src_buf (struct hantro_ctx *ctx) +{ +return v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); +} + +static inline struct vb2_v4l2_buffer * +hantro_get_dst_buf (struct hantro_ctx *ctx) +{ +return v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); +} +#endif /* HANTRO_H_ */
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +2 -2
@@ -167,8 +167,8 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)const struct v4l2_mpeg2_picture *picture;u32 reg; - src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); - dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + src_buf =hantro_get_src_buf (ctx); + dst_buf =hantro_get_dst_buf (ctx);/* Apply request controls if any */ v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
drivers/staging/media/hantro/hantro_g1_vp8_dec.c +4 -4
@@ -260,7 +260,7 @@ static void cfg_parts(struct hantro_ctx *ctx,u32 count =0 ;unsigned int i; - vb2_src =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); + vb2_src =hantro_get_src_buf (ctx); src_dma =vb2_dma_contig_plane_dma_addr (&vb2_src->vb2_buf,0 );/*
@@ -391,7 +391,7 @@ static void cfg_ref(struct hantro_ctx *ctx,struct vb2_v4l2_buffer *vb2_dst;dma_addr_t ref; - vb2_dst =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + vb2_dst =hantro_get_dst_buf (ctx); ref =hantro_get_ref (cap_q, hdr->last_frame_ts);if (!ref)
@@ -424,7 +424,7 @@ static void cfg_buffers(struct hantro_ctx *ctx,dma_addr_t dst_dma;u32 reg; - vb2_dst =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + vb2_dst =hantro_get_dst_buf (ctx);/* Set probability table buffer address */ vdpu_write_relaxed(vpu, ctx->vp8_dec.prob_tbl.dma,
@@ -453,7 +453,7 @@ void hantro_g1_vp8_dec_run(struct hantro_ctx *ctx)u32 mb_width, mb_height;u32 reg; - vb2_src =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); + vb2_src =hantro_get_src_buf (ctx);v4l2_ctrl_request_setup (vb2_src->vb2_buf.req_obj.req, &ctx->ctrl_handler);
drivers/staging/media/hantro/hantro_h1_jpeg_enc.c +2 -2
@@ -84,8 +84,8 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx)struct hantro_jpeg_ctx jpeg_ctx;u32 reg; - src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); - dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + src_buf =hantro_get_src_buf (ctx); + dst_buf =hantro_get_dst_buf (ctx);memset (&jpeg_ctx,0 ,sizeof (jpeg_ctx)); jpeg_ctx.buffer =vb2_plane_vaddr (&dst_buf->vb2_buf,0 );
drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c +2 -2
@@ -116,8 +116,8 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx)struct media_request *src_req;u32 reg; - src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); - dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + src_buf =hantro_get_src_buf (ctx); + dst_buf =hantro_get_dst_buf (ctx); src_req = src_buf->vb2_buf.req_obj.req;v4l2_ctrl_request_setup (src_req, &ctx->ctrl_handler);
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +2 -2
@@ -169,8 +169,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)const struct v4l2_mpeg2_picture *picture;u32 reg; - src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); - dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); + src_buf =hantro_get_src_buf (ctx); + dst_buf =hantro_get_dst_buf (ctx);/* Apply request controls if any */ v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
Signature · 1 line
2.22.0
PATCH 5/7 media: hantro: Add helpers to prepare/finish a run
In reply to Ezequiel GarciaFrom: Boris Brezillon <boris.brezillon-ZGY8ohtN/[email protected]>
And use them where appropriate.
We might want to move hantro_{prepare,finish}_run() calls to device_run() and have a 2-step approach similar to cedrus (prepare + trigger) at some point, but let's keep that for later.
--- drivers/staging/media/hantro/hantro_drv.c | 22 +++++++++++++++++++ .../media/hantro/hantro_g1_mpeg2_dec.c | 10 ++------- .../staging/media/hantro/hantro_g1_vp8_dec.c | 9 ++------ .../staging/media/hantro/hantro_h1_jpeg_enc.c | 7 ++++-- drivers/staging/media/hantro/hantro_hw.h | 2 ++ .../media/hantro/rk3399_vpu_hw_jpeg_enc.c | 8 ++----- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 10 ++------- 7 files changed, 37 insertions(+), 31 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +22 -0
@@ -153,6 +153,28 @@ void hantro_watchdog(struct work_struct *work) } } +void hantro_prepare_run (struct hantro_ctx *ctx) +{ +struct vb2_v4l2_buffer *src_buf; + + src_buf =hantro_get_src_buf (ctx); +v4l2_ctrl_request_setup (src_buf->vb2_buf.req_obj.req, + &ctx->ctrl_handler); +} + +void hantro_finish_run (struct hantro_ctx *ctx) +{ +struct vb2_v4l2_buffer *src_buf; + + src_buf =hantro_get_src_buf (ctx); +v4l2_ctrl_request_complete (src_buf->vb2_buf.req_obj.req, + &ctx->ctrl_handler); + +/* Kick the watchdog. */ +schedule_delayed_work (&ctx->dev->watchdog_work, +msecs_to_jiffies (2000 )); +} +static void device_run (void *priv) {struct hantro_ctx *ctx = priv;
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c +2 -8
@@ -171,8 +171,7 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) dst_buf =hantro_get_dst_buf (ctx);/* Apply request controls if any */ -v4l2_ctrl_request_setup (src_buf->vb2_buf.req_obj.req, - &ctx->ctrl_handler); +hantro_prepare_run (ctx); slice_params =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS );
@@ -248,12 +247,7 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx) &dst_buf->vb2_buf, sequence, picture, slice_params); -/* Controls no longer in-use, we can complete them */ -v4l2_ctrl_request_complete (src_buf->vb2_buf.req_obj.req, - &ctx->ctrl_handler); - -/* Kick the watchdog and start decoding */ -schedule_delayed_work (&vpu->watchdog_work,msecs_to_jiffies (2000 )); +hantro_finish_run (ctx); reg =G1_REG_DEC_E (1 );vdpu_write (vpu, reg,G1_SWREG (1 ));
drivers/staging/media/hantro/hantro_g1_vp8_dec.c +2 -7
@@ -454,8 +454,7 @@ void hantro_g1_vp8_dec_run(struct hantro_ctx *ctx)u32 reg; vb2_src =hantro_get_src_buf (ctx); -v4l2_ctrl_request_setup (vb2_src->vb2_buf.req_obj.req, - &ctx->ctrl_handler); +hantro_prepare_run (ctx); hdr =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER );if (WARN_ON (!hdr))
@@ -516,11 +515,7 @@ void hantro_g1_vp8_dec_run(struct hantro_ctx *ctx)cfg_ref (ctx, hdr);cfg_buffers (ctx, hdr); -/* Controls no longer in-use, we can complete them */ -v4l2_ctrl_request_complete (vb2_src->vb2_buf.req_obj.req, - &ctx->ctrl_handler); - -schedule_delayed_work (&vpu->watchdog_work,msecs_to_jiffies (2000 )); +hantro_finish_run (ctx);vdpu_write (vpu,G1_REG_INTERRUPT_DEC_E ,G1_REG_INTERRUPT ); }
drivers/staging/media/hantro/hantro_h1_jpeg_enc.c +5 -2
@@ -87,6 +87,8 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx) src_buf =hantro_get_src_buf (ctx); dst_buf =hantro_get_dst_buf (ctx); +hantro_prepare_run (ctx); +memset (&jpeg_ctx,0 ,sizeof (jpeg_ctx)); jpeg_ctx.buffer =vb2_plane_vaddr (&dst_buf->vb2_buf,0 ); jpeg_ctx.width = ctx->dst_fmt.width;
@@ -119,7 +121,8 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx) | H1_REG_ENC_CTRL_ENC_MODE_JPEG |H1_REG_ENC_PIC_INTRA |H1_REG_ENC_CTRL_EN_BIT ; -/* Kick the watchdog and start encoding */ -schedule_delayed_work (&vpu->watchdog_work,msecs_to_jiffies (2000 )); + +hantro_finish_run (ctx); +vepu_write (vpu, reg,H1_REG_ENC_CTRL ); }
drivers/staging/media/hantro/hantro_hw.h +2 -0
@@ -97,6 +97,8 @@ void hantro_watchdog(struct work_struct *work);void hantro_run (struct hantro_ctx *ctx);void hantro_irq_done (struct hantro_dev *vpu,unsigned int bytesused,enum vb2_buffer_state result); +void hantro_prepare_run (struct hantro_ctx *ctx); +void hantro_finish_run (struct hantro_ctx *ctx);void hantro_h1_jpeg_enc_run (struct hantro_ctx *ctx);void rk3399_vpu_jpeg_enc_run (struct hantro_ctx *ctx);
drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c +2 -6
@@ -113,14 +113,12 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx)struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *src_buf, *dst_buf;struct hantro_jpeg_ctx jpeg_ctx; -struct media_request *src_req;u32 reg; src_buf =hantro_get_src_buf (ctx); dst_buf =hantro_get_dst_buf (ctx); - src_req = src_buf->vb2_buf.req_obj.req; -v4l2_ctrl_request_setup (src_req, &ctx->ctrl_handler); +hantro_prepare_run (ctx);memset (&jpeg_ctx,0 ,sizeof (jpeg_ctx)); jpeg_ctx.buffer =vb2_plane_vaddr (&dst_buf->vb2_buf,0 );
@@ -157,9 +155,7 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx) | VEPU_REG_ENCODE_FORMAT_JPEG |VEPU_REG_ENCODE_ENABLE ; -v4l2_ctrl_request_complete (src_req, &ctx->ctrl_handler); -/* Kick the watchdog and start encoding */ -schedule_delayed_work (&vpu->watchdog_work,msecs_to_jiffies (2000 )); +hantro_finish_run (ctx);vepu_write (vpu, reg,VEPU_REG_ENCODE_START ); }
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c +2 -8
@@ -172,9 +172,7 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) src_buf =hantro_get_src_buf (ctx); dst_buf =hantro_get_dst_buf (ctx); -/* Apply request controls if any */ -v4l2_ctrl_request_setup (src_buf->vb2_buf.req_obj.req, - &ctx->ctrl_handler); +hantro_prepare_run (ctx); slice_params =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS );
@@ -254,12 +252,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx) &dst_buf->vb2_buf, sequence, picture, slice_params); -/* Controls no longer in-use, we can complete them */ -v4l2_ctrl_request_complete (src_buf->vb2_buf.req_obj.req, - &ctx->ctrl_handler); -/* Kick the watchdog and start decoding */ -schedule_delayed_work (&vpu->watchdog_work,msecs_to_jiffies (2000 )); +hantro_finish_run (ctx); reg =vdpu_read (vpu,VDPU_SWREG (57 )) |VDPU_REG_DEC_E (1 );vdpu_write (vpu, reg,VDPU_SWREG (57 ));
Signature · 1 line
2.22.0
PATCH 6/7 media: hantro: Move VP8 common code
In reply to Ezequiel GarciaIn order to introduce support for RK3399 VP8 decoding, move some common VP8 code. This will be reused by the RK3399 implementation, reducing code duplication.
--- .../staging/media/hantro/hantro_g1_vp8_dec.c | 17 ----------------- drivers/staging/media/hantro/hantro_hw.h | 4 ++++ drivers/staging/media/hantro/hantro_vp8.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 17 deletions(-)
drivers/staging/media/hantro/hantro_g1_vp8_dec.c +0 -17
@@ -16,8 +16,6 @@#include "hantro.h" #include "hantro_g1_regs.h" -#define DEC_8190_ALIGN_MASK 0x07U -/* DCT partition base address regs */ static const struct hantro_reg vp8_dec_dct_base[8 ] = { {G1_REG_ADDR_STR ,0 ,0xffffffff },
@@ -131,21 +129,6 @@ static const struct hantro_reg vp8_dec_pred_bc_tap[8][4] = { }, }; -/* -* filter taps taken to 7-bit precision, -* reference RFC6386#Page-16, filters[8][6] -*/ -static const u32 vp8_dec_mc_filter[8 ][6 ] = { - {0 ,0 ,128 ,0 ,0 ,0 }, - {0 ,-6 ,123 ,12 ,-1 ,0 }, - {2 ,-11 ,108 ,36 ,-8 ,1 }, - {0 ,-9 ,93 ,50 ,-6 ,0 }, - {3 ,-16 ,77 ,77 ,-16 ,3 }, - {0 ,-6 ,50 ,93 ,-9 ,0 }, - {1 ,-8 ,36 ,108 ,-11 ,2 }, - {0 ,-1 ,12 ,123 ,-6 ,0 } -}; -/* * Set loop filters */
drivers/staging/media/hantro/hantro_hw.h +4 -0
@@ -15,6 +15,8 @@#include <media/vp8-ctrls.h> #include <media/videobuf2-core.h> +#define DEC_8190_ALIGN_MASK 0x07U +struct hantro_dev ;struct hantro_ctx ;struct hantro_buf ;
@@ -93,6 +95,8 @@ extern const struct hantro_variant rk3399_vpu_variant;extern const struct hantro_variant rk3328_vpu_variant;extern const struct hantro_variant rk3288_vpu_variant; +extern const u32 vp8_dec_mc_filter[8 ][6 ]; +void hantro_watchdog (struct work_struct *work);void hantro_run (struct hantro_ctx *ctx); void hantro_irq_done(struct hantro_dev *vpu, unsigned int bytesused,
drivers/staging/media/hantro/hantro_vp8.c +15 -0
@@ -31,6 +31,21 @@ struct vp8_prob_tbl_packed {u8 padding3[96 ]; }; +/* +* filter taps taken to 7-bit precision, +* reference RFC6386#Page-16, filters[8][6] +*/ +const u32 vp8_dec_mc_filter[8 ][6 ] = { + {0 ,0 ,128 ,0 ,0 ,0 }, + {0 ,-6 ,123 ,12 ,-1 ,0 }, + {2 ,-11 ,108 ,36 ,-8 ,1 }, + {0 ,-9 ,93 ,50 ,-6 ,0 }, + {3 ,-16 ,77 ,77 ,-16 ,3 }, + {0 ,-6 ,50 ,93 ,-9 ,0 }, + {1 ,-8 ,36 ,108 ,-11 ,2 }, + {0 ,-1 ,12 ,123 ,-6 ,0 } +}; +void hantro_vp8_prob_update (struct hantro_ctx *ctx,const struct v4l2_ctrl_vp8_frame_header *hdr) {
Signature · 1 line
2.22.0
PATCH 7/7 media: hantro: Support RK3399 VP8 decoding
In reply to Ezequiel GarciaFrom: Jeffy Chen <[email protected]>
Rockchip RK3399 SoC has the same Hantro G1 IP block as RK3288, but the registers are entirely different.
In a similar fashion as MPEG-2 decoding, it's simpler to just add a separate implementation.
--- drivers/staging/media/hantro/Makefile | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/rk3399_vpu_hw.c | 22 +- .../media/hantro/rk3399_vpu_hw_vp8_dec.c | 597 ++++++++++++++++++ 4 files changed, 620 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
drivers/staging/media/hantro/Makefile +1 -0
@@ -8,6 +8,7 @@ hantro-vpu-y += \ hantro_g1_vp8_dec.o \ rk3399_vpu_hw_jpeg_enc.o \ rk3399_vpu_hw_mpeg2_dec.o \ + rk3399_vpu_hw_vp8_dec.o \ hantro_jpeg.o \ hantro_mpeg2.o \ hantro_vp8.o
drivers/staging/media/hantro/hantro_hw.h +1 -0
@@ -117,6 +117,7 @@ int hantro_mpeg2_dec_init(struct hantro_ctx *ctx);void hantro_mpeg2_dec_exit (struct hantro_ctx *ctx);void hantro_g1_vp8_dec_run (struct hantro_ctx *ctx); +void rk3399_vpu_vp8_dec_run (struct hantro_ctx *ctx);int hantro_vp8_dec_init (struct hantro_ctx *ctx);void hantro_vp8_dec_exit (struct hantro_ctx *ctx); void hantro_vp8_prob_update(struct hantro_ctx *ctx,
drivers/staging/media/hantro/rk3399_vpu_hw.c +21 -1
@@ -73,6 +73,19 @@ static const struct hantro_fmt rk3399_vpu_dec_fmts[] = { .step_height = MPEG2_MB_DIM, }, }, + { + .fourcc = V4L2_PIX_FMT_VP8_FRAME, + .codec_mode = HANTRO_MODE_VP8_DEC, + .max_depth = 2, + .frmsize = { + .min_width = 48, + .max_width = 3840, + .step_width = VP8_MB_DIM, + .min_height = 48, + .max_height = 2160, + .step_height = VP8_MB_DIM, + }, + }, };static irqreturn_t rk3399_vepu_irq (int irq,void *dev_id)
@@ -154,6 +167,12 @@ static const struct hantro_codec_ops rk3399_vpu_codec_ops[] = { .init = hantro_mpeg2_dec_init, .exit = hantro_mpeg2_dec_exit, }, + [HANTRO_MODE_VP8_DEC] = { + .run = rk3399_vpu_vp8_dec_run, + .reset = rk3399_vpu_dec_reset, + .init = hantro_vp8_dec_init, + .exit = hantro_vp8_dec_exit, + }, };/*
@@ -176,7 +195,8 @@ const struct hantro_variant rk3399_vpu_variant = { .dec_offset = 0x400, .dec_fmts = rk3399_vpu_dec_fmts, .num_dec_fmts = ARRAY_SIZE(rk3399_vpu_dec_fmts), - .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER, + .codec =HANTRO_JPEG_ENCODER |HANTRO_MPEG2_DECODER | + HANTRO_VP8_DECODER, .codec_ops = rk3399_vpu_codec_ops, .irqs = rk3399_irqs, .num_irqs = ARRAY_SIZE(rk3399_irqs),
drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c new file +597 -0
597 lines not on this page · raw message
Signature · 1 line
2.22.0
Quoted 9 lines · Ezequiel Garcia
This series adds VP8 decoding support on RK3399 SoC.
I'm including a set of commits from Boris' recent H264 series [1]. These commits add some helpers that are also useful for RK3399 VP8, and at the same time cleanup the driver nicely.
Finally, there's a fix by Francois Buergisser from Chromium team.
VP8 and MPEG-2 tested on RK3399 RockPi and RK3288 Rock2 boards.
I get this when compiling:
/home/hans/work/build/media-git/drivers/staging/media/hantro/hantro_g1_vp8_dec.c: In function 'hantro_g1_vp8_dec_run':/home/hans/work/build/media-git/drivers/staging/media/hantro/hantro_g1_vp8_dec.c:435:26: warning: variable 'vb2_src' set but not used [-Wunused-but-set-variable]
struct vb2_v4l2_buffer *vb2_src;
^~~~~~~
CC drivers/staging/media/omap4iss/iss_csiphy.o
/home/hans/work/build/media-git/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c: In function 'rk3399_vpu_vp8_dec_run':
/home/hans/work/build/media-git/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c:515:26: warning: variable 'vb2_src' set but not used [-Wunused-but-set-variable]
struct vb2_v4l2_buffer *vb2_src;
^~~~~~~Can you take a look?
Thanks,
Hans
Quoted 33 lines
[1] https://patchwork.kernel.org/cover/11003971/
Boris Brezillon (4):
media: hantro: Simplify the controls creation logic
media: hantro: Constify the control array
media: hantro: Add hantro_get_{src,dst}_buf() helpers
media: hantro: Add helpers to prepare/finish a runEzequiel Garcia (1):
media: hantro: Move VP8 common codeFrancois Buergisser (1):
media: hantro: Set DMA max segment sizeJeffy Chen (1):
media: hantro: Support RK3399 VP8 decodingdrivers/staging/media/hantro/Makefile | 1 + drivers/staging/media/hantro/hantro.h | 15 +- drivers/staging/media/hantro/hantro_drv.c | 53 +- .../media/hantro/hantro_g1_mpeg2_dec.c | 14 +- .../staging/media/hantro/hantro_g1_vp8_dec.c | 34 +- .../staging/media/hantro/hantro_h1_jpeg_enc.c | 11 +- drivers/staging/media/hantro/hantro_hw.h | 7 + drivers/staging/media/hantro/hantro_vp8.c | 15 + drivers/staging/media/hantro/rk3399_vpu_hw.c | 22 +- .../media/hantro/rk3399_vpu_hw_jpeg_enc.c | 12 +- .../media/hantro/rk3399_vpu_hw_mpeg2_dec.c | 14 +- .../media/hantro/rk3399_vpu_hw_vp8_dec.c | 597 ++++++++++++++++++ 12 files changed, 711 insertions(+), 84 deletions(-) create mode 100644 drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
Quoted 18 lines · Hans Verkuil
Quoted 9 lines · Ezequiel Garcia
This series adds VP8 decoding support on RK3399 SoC.
I'm including a set of commits from Boris' recent H264 series [1]. These commits add some helpers that are also useful for RK3399 VP8, and at the same time cleanup the driver nicely.
Finally, there's a fix by Francois Buergisser from Chromium team.
VP8 and MPEG-2 tested on RK3399 RockPi and RK3288 Rock2 boards.
I get this when compiling:
/home/hans/work/build/media-git/drivers/staging/media/hantro/hantro_g1_vp8_dec.c: In function 'hantro_g1_vp8_dec_run':/home/hans/work/build/media-git/drivers/staging/media/hantro/hantro_g1_vp8_dec.c:435:26: warning: variable 'vb2_src' set but not used [-Wunused-but- set-variable]struct vb2_v4l2_buffer *vb2_src; ^~~~~~~
Quoted 9 lines
CC
drivers/staging/media/omap4iss/iss_csiphy.o/home/hans/work/build/media-git/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c: In function 'rk3399_vpu_vp8_dec_run':/home/hans/work/build/media-git/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c:515:26: warning: variable 'vb2_src' set but not used [-Wunused- but-set-variable]struct vb2_v4l2_buffer *vb2_src; ^~~~~~~Can you take a look?
Oops, I missed these warnings. I'll fix them and post a new version.
Thanks,
Eze