Additional features for Hantro HEVC
Subsystems (4)
v4 cover Additional features for Hantro HEVC
version 4:
- Log file descriptor in trace point.
- Add documentation about how use the trace points in Hantro driver.
- Fix typos.
- Make sure that 10 bits output format (i.e. P010) is only enumerated when encoded input stream is 10 bits.
- Create ops structure for variant to store their specific functions.
- Rename scaling ops to enumare_framesizes
Run fluster on this version: the results are the same 70 over 147 streams OK. Test streams with embedded scaling list are now decoded and the output is correct for our eyes but the values of the pixels (y, u and V) are different from the values of the reference (decoded for FFMPEG) so the stream of still KO. When decoded with GStreamer or vendor stack the pixels values are the same but not matching with FFMPEG.
Compressed help to increase the performance of the whole stack, it could
be up to 50 fps (against 45 fps) on IMX8MQ.
The impact of compressed frames is confirmed when using perf to monitor
the number of memory accesses with or without compression feature.
The following command
perf stat -a -e imx8_ddr0/cycles/,imx8_ddr0/read-cycles/,imx8_ddr0/write-cycles/ gst-launch-1.0 filesrc location=Jockey_3840x2160_120fps_420_8bit_HEVC_RAW.hevc ! queue ! h265parse ! v4l2slh265dec ! fakesink
give us these results
without compression feature:
Performance counter stats for 'system wide':
14965816743 imx8_ddr0/cycles/
889197312 imx8_ddr0/read-cycles/
1819348862 imx8_ddr0/write-cycles/ 18.707373001 seconds time elapsed
with compression feature:
Performance counter stats for 'system wide':
13750218243 imx8_ddr0/cycles/
402428744 imx8_ddr0/read-cycles/
1255676693 imx8_ddr0/write-cycles/ 17.188320061 seconds time elapsed
As expected the number of read/write cycles are really lower when compression is used.
Thanks to Chris for perf command line :-)
version 3:
- Change trace file name to hantro_trace.h
version 2:
- Fix structure name in ext-ctrls-codec.rst
- Define the value for compression storage size
- Add comments about registers usage
- Add documentation about P010 padding
Basic HEVC support has been added to Hantro driver in this pull request:
https://www.spinics.net/lists/linux-media/msg193744.html
Thanks to that it is now possible to support more features for this driver.
The first patch allow to log the hardware performance per macroblock. The second patch makes the driver use compressed reference frames to reduce memory bandwidth consumption.
Patches 3 to 5 allow to decode and produce 10-bits P010 frames. Patch 6 make usage of G2 post processor to scale down the frames. Patches 7 and 8 add the support of HEVC scaling matrix by adding a new control.
All these patches enhance the HEVC support for Hantro (G2) hardware. Unluckily they almost all touch the same pieces of code, where buffer size, offset and addresses are set, so they have to be in this order. They depend of the series pushed in this pull request:
https://www.spinics.net/lists/linux-media/msg193744.html
Benjamin
Benjamin Gaignard (9):
media: hantro: Trace hevc hw cycles performance register
media: hantro: Add support of compressed reference buffers
media: hantro: hevc: Allow 10-bits encoded streams
media: Add P010 video format
media: hantro: hevc: Allow to produce 10-bit frames
media: hantro: create ops for variants
media: hantro: enumerate scaled output formats
media: hevc: Add scaling matrix control
media: hantro: Add scaling lists feature
Documentation/admin-guide/media/hantro.rst | 14 ++ .../admin-guide/media/v4l-drivers.rst | 1 + .../media/v4l/ext-ctrls-codec.rst | 45 +++++ .../media/v4l/pixfmt-yuv-planar.rst | 78 +++++++- .../media/v4l/vidioc-queryctrl.rst | 6 + drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ctrls-core.c | 6 + drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/staging/media/hantro/hantro.h | 21 +- drivers/staging/media/hantro/hantro_drv.c | 22 ++- .../staging/media/hantro/hantro_g2_hevc_dec.c | 186 ++++++++++++++++-- drivers/staging/media/hantro/hantro_g2_regs.h | 12 ++ drivers/staging/media/hantro/hantro_hevc.c | 69 ++++++- drivers/staging/media/hantro/hantro_hw.h | 8 + drivers/staging/media/hantro/hantro_trace.h | 41 ++++ drivers/staging/media/hantro/hantro_v4l2.c | 41 +++- drivers/staging/media/hantro/imx8m_vpu_hw.c | 22 ++- .../staging/media/hantro/rockchip_vpu_hw.c | 30 ++- .../staging/media/hantro/sama5d4_vdec_hw.c | 6 +- include/media/hevc-ctrls.h | 11 ++ include/uapi/linux/videodev2.h | 1 + 22 files changed, 580 insertions(+), 46 deletions(-) create mode 100644 Documentation/admin-guide/media/hantro.rst create mode 100644 drivers/staging/media/hantro/hantro_trace.h
Signature · 1 line
2.25.1
PATCH v4 1/9 media: hantro: Trace hevc hw cycles performance register
After each hevc decoded frame trace the hardware performance. It provides the number of hw cycles spend per decoded macroblock.
---
version 4:
- Log file descriptor in trace point.
- Add documentation about how use the trace points in Hantro driver.
version 3:
- Change trace file name to hantro_trace.h
Documentation/admin-guide/media/hantro.rst | 14 +++++++ .../admin-guide/media/v4l-drivers.rst | 1 + drivers/staging/media/hantro/hantro_drv.c | 3 ++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 16 ++++++++ drivers/staging/media/hantro/hantro_g2_regs.h | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/hantro_trace.h | 41 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 1 + 8 files changed, 78 insertions(+) create mode 100644 Documentation/admin-guide/media/hantro.rst create mode 100644 drivers/staging/media/hantro/hantro_trace.h
Documentation/admin-guide/media/hantro.rst new file +14 -0
@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================= +The hantro driver +================= + +Trace +~~~~~ + +You can trace the hardware decoding performances by using event tracing:: + + # echo hantro_hevc_perf >> /sys/kernel/debug/tracing/set_event + +That will keep a log of the number of hardware cycles spend per decoded macroblock
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
@@ -15,6 +15,7 @@ Video4Linux (V4L) driver-specific documentation cx88 davinci-vpbe fimc + hantro imx imx7 ipu3
drivers/staging/media/hantro/hantro_drv.c +3 -0
@@ -28,6 +28,9 @@#include "hantro.h" #include "hantro_hw.h" +#define CREATE_TRACE_POINTS +#include "hantro_trace.h" +#define DRIVER_NAME "hantro-vpu"int hantro_debug;
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +16 -0
@@ -7,6 +7,7 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" +#include "hantro_trace.h" #define HEVC_DEC_MODE 0xC
@@ -22,6 +23,21 @@ static inline void hantro_write_addr(struct hantro_dev *vpu,vdpu_write (vpu, addr &0xffffffff , offset); } +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx) +{ +const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; +const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; +struct hantro_dev *vpu = ctx->dev; +u32 hw_cycles =0 ; +u32 mbs = (sps->pic_width_in_luma_samples * + sps->pic_height_in_luma_samples) >>8 ; + +if (mbs) + hw_cycles =vdpu_read (vpu,G2_HW_PERFORMANCE ) / mbs; + +trace_hantro_hevc_perf (ctx, hw_cycles); +} +static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
drivers/staging/media/hantro/hantro_g2_regs.h +1 -0
@@ -177,6 +177,7 @@#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17) +#define G2_HW_PERFORMANCE (G2_SWREG(63))#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))
drivers/staging/media/hantro/hantro_hw.h +1 -0
@@ -242,6 +242,7 @@ void hantro_h264_dec_exit(struct hantro_ctx *ctx);int hantro_hevc_dec_init (struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx); +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);
drivers/staging/media/hantro/hantro_trace.h new file +41 -0
41 lines not on this page · raw message
drivers/staging/media/hantro/imx8m_vpu_hw.c +1 -0
@@ -253,6 +253,7 @@ static const struct hantro_codec_ops imx8mq_vpu_g2_codec_ops[] = { .reset = imx8m_vpu_g2_reset, .init = hantro_hevc_dec_init, .exit = hantro_hevc_dec_exit, + .done = hantro_g2_hevc_dec_done, }, };
Signature · 1 line
2.25.1
PATCH v4 2/9 media: hantro: Add support of compressed reference buffers
In reply to Benjamin GaignardReference frame compression is a feature added in G2 decoder to compress frame buffers so that the bandwidth of storing/loading reference frames can be reduced, especially when the resolution of decoded stream is of high definition.
---
version 4:
- Fix typos
version 2:
- Define the value for compression storage size
- Add comments about registers usage
.../staging/media/hantro/hantro_g2_hevc_dec.c | 31 ++++++++++++-- drivers/staging/media/hantro/hantro_g2_regs.h | 4 ++ drivers/staging/media/hantro/hantro_hevc.c | 41 ++++++++++++++++++- drivers/staging/media/hantro/hantro_hw.h | 2 + 4 files changed, 74 insertions(+), 4 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +28 -3
@@ -382,10 +382,12 @@ static int set_ref(struct hantro_ctx *ctx)const struct v4l2_ctrl_hevc_pps *pps = ctrls->pps;const struct v4l2_ctrl_hevc_decode_params *decode_params = ctrls->decode_params;const struct v4l2_hevc_dpb_entry *dpb = decode_params->dpb; -dma_addr_t luma_addr, chroma_addr, mv_addr =0 ; +dma_addr_t luma_addr, chroma_addr, mv_addr, compress_luma_addr, compress_chroma_addr =0 ;struct hantro_dev *vpu = ctx->dev;size_t cr_offset =hantro_hevc_chroma_offset (sps);size_t mv_offset =hantro_hevc_motion_vectors_offset (sps); +size_t compress_luma_offset =hantro_hevc_luma_compress_offset (sps); +size_t compress_chroma_offset =hantro_hevc_chroma_compress_offset (sps);u32 max_ref_frames;u16 dpb_longterm_e;static const struct hantro_reg cur_poc[] = {
@@ -458,15 +460,28 @@ static int set_ref(struct hantro_ctx *ctx)if (!luma_addr)return -ENOMEM ; +/* +* An allocated frame stores Y and UV planes, motion vectors and +* compressed Y and UV planes. Compute all these offsets given +* the frame resolution and the pixel format. +*/ chroma_addr = luma_addr + cr_offset; mv_addr = luma_addr + mv_offset; + compress_luma_addr = luma_addr + compress_luma_offset; + compress_chroma_addr = luma_addr + compress_chroma_offset;if (dpb[i].rps ==V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR ) dpb_longterm_e |=BIT (V4L2_HEVC_DPB_ENTRIES_NUM_MAX -1 - i); +/* +* For each reference frame Y, UV, motion vector and +* compressed Y, UV buffers addresses must be set. +*/ 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_COMP_ADDR_REF (i), compress_luma_addr); +hantro_write_addr (vpu,G2_COMP_CHR_REF (i), compress_chroma_addr); } luma_addr =hantro_hevc_get_ref_buf (ctx, decode_params->pic_order_cnt_val);
@@ -475,7 +490,12 @@ static int set_ref(struct hantro_ctx *ctx) chroma_addr = luma_addr + cr_offset; mv_addr = luma_addr + mv_offset; + compress_luma_addr = luma_addr + compress_luma_offset; + compress_chroma_addr = luma_addr + compress_chroma_offset; +/* The next decoded frame as to be put as the last reference frame entry */ +hantro_write_addr (vpu,G2_COMP_ADDR_REF (i), compress_luma_addr); +hantro_write_addr (vpu,G2_COMP_CHR_REF (i), compress_chroma_addr);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);
@@ -483,13 +503,18 @@ static int set_ref(struct hantro_ctx *ctx)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_COMP_ADDR_DST , compress_luma_addr); +hantro_write_addr (vpu,G2_COMP_CHR , compress_chroma_addr);hantro_hevc_ref_remove_unused (ctx); +/* Unused reference frames entries most be cleared */ 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_COMP_ADDR_REF (i),0 ); +hantro_write_addr (vpu,G2_COMP_CHR_REF (i),0 ); }hantro_reg_write (vpu, &g2_refer_lterm_e, dpb_longterm_e);
@@ -580,8 +605,8 @@ int hantro_g2_hevc_dec_run(struct hantro_ctx *ctx)/* Don't disable output */ hantro_reg_write (vpu, &g2_out_dis,0 ); -/* Don't compress buffers */ -hantro_reg_write (vpu, &g2_ref_compress_bypass,1 ); +/* Compress buffers */ +hantro_reg_write (vpu, &g2_ref_compress_bypass,0 );/* use NV12 as output format */ hantro_reg_write (vpu, &g2_out_rs_e,1 );
drivers/staging/media/hantro/hantro_g2_regs.h +4 -0
@@ -192,6 +192,10 @@#define G2_TILE_FILTER (G2_SWREG(179))#define G2_TILE_SAO (G2_SWREG(181))#define G2_TILE_BSD (G2_SWREG(183)) +#define G2_COMP_ADDR_DST (G2_SWREG(190)) +#define G2_COMP_ADDR_REF (i) (G2_SWREG(192) + ((i) * 0x8)) +#define G2_COMP_CHR (G2_SWREG(224)) +#define G2_COMP_CHR_REF (i) (G2_SWREG(226) + ((i) * 0x8))#define g2_strm_buffer_len G2_DEC_REG(258, 0, 0xffffffff)#define g2_strm_start_offset G2_DEC_REG(259, 0, 0xffffffff)
drivers/staging/media/hantro/hantro_hevc.c +40 -1
58 lines not on this page · raw message
drivers/staging/media/hantro/hantro_hw.h +2 -0
@@ -248,6 +248,8 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx, int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);size_t hantro_hevc_chroma_offset (const struct v4l2_ctrl_hevc_sps *sps);size_t hantro_hevc_motion_vectors_offset (const struct v4l2_ctrl_hevc_sps *sps); +size_t hantro_hevc_luma_compress_offset (const struct v4l2_ctrl_hevc_sps *sps); +size_t hantro_hevc_chroma_compress_offset (const struct v4l2_ctrl_hevc_sps *sps);static inline size_t hantro_h264_mv_size (unsigned int width,unsigned int height)
Signature · 1 line
2.25.1
PATCH v4 3/9 media: hantro: hevc: Allow 10-bits encoded streams
In reply to Benjamin GaignardAllow to use 10-bits encoded streams but force the output to remain in 8-bits.
Add a function to get chroma offset for the output since it may now not match with internal reference buffers chroma offset.
--- drivers/staging/media/hantro/hantro_drv.c | 5 ++-- .../staging/media/hantro/hantro_g2_hevc_dec.c | 29 +++++++++++++++---- drivers/staging/media/hantro/hantro_g2_regs.h | 1 + drivers/staging/media/hantro/hantro_hevc.c | 5 ++-- 4 files changed, 31 insertions(+), 9 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +3 -2
@@ -263,8 +263,9 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl)if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)/* Luma and chroma bit depth mismatch */ return -EINVAL ; -if (sps->bit_depth_luma_minus8 !=0 ) -/* Only 8-bit is supported */ +if (sps->bit_depth_luma_minus8 !=0 && + sps->bit_depth_luma_minus8 !=2 ) +/* Only 8-bit or 10-bit is supported */ return -EINVAL ;if (sps->flags &V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED )/* No scaling support */
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +24 -5
@@ -133,6 +133,16 @@ static void prepare_tile_info_buffer(struct hantro_ctx *ctx)vpu_debug (1 ,"%s: no chroma!\n" , __func__); } +static bool is_8bit_dst_format (struct hantro_ctx *ctx) +{ +switch (ctx->vpu_dst_fmt->fourcc) { +case V4L2_PIX_FMT_NV12 : +return true; +default : +return false; + } +} +static void set_params (struct hantro_ctx *ctx) {const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls;
@@ -148,7 +158,8 @@ static void set_params(struct hantro_ctx *ctx)hantro_reg_write (vpu, &g2_bit_depth_y_minus8, sps->bit_depth_luma_minus8);hantro_reg_write (vpu, &g2_bit_depth_c_minus8, sps->bit_depth_chroma_minus8); -hantro_reg_write (vpu, &g2_output_8_bits,0 ); +hantro_reg_write (vpu, &g2_output_8_bits,1 ); +hantro_reg_write (vpu, &g2_output_format,0 );hantro_reg_write (vpu, &g2_hdr_skip_length, ctrls->hevc_hdr_skip_length);
@@ -522,13 +533,21 @@ static int set_ref(struct hantro_ctx *ctx)return 0 ; } +static size_t hantro_hevc_output_chroma_offset (struct hantro_ctx *ctx) +{ +const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; +const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; +int bytes_per_pixel =is_8bit_dst_format (ctx) ?1 :2 ; + +return sps->pic_width_in_luma_samples * + sps->pic_height_in_luma_samples * bytes_per_pixel; +} +static void set_buffers (struct hantro_ctx *ctx) {struct vb2_v4l2_buffer *src_buf, *dst_buf;struct hantro_dev *vpu = ctx->dev; -const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; -const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; -size_t cr_offset =hantro_hevc_chroma_offset (sps); +size_t output_cr_offset =hantro_hevc_output_chroma_offset (ctx);dma_addr_t src_dma, dst_dma;u32 src_len, src_buf_len;
@@ -550,7 +569,7 @@ static void set_buffers(struct hantro_ctx *ctx) 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_RASTER_SCAN_CHR , dst_dma + output_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);
drivers/staging/media/hantro/hantro_g2_regs.h +1 -0
@@ -77,6 +77,7 @@#define g2_bit_depth_y_minus8 G2_DEC_REG(8, 6, 0x3)#define g2_bit_depth_c_minus8 G2_DEC_REG(8, 4, 0x3)#define g2_output_8_bits G2_DEC_REG(8, 3, 0x1) +#define g2_output_format G2_DEC_REG(8, 0, 0x7)#define g2_refidx1_active G2_DEC_REG(9, 19, 0x1f)#define g2_refidx0_active G2_DEC_REG(9, 14, 0x1f)
drivers/staging/media/hantro/hantro_hevc.c +3 -2
@@ -204,6 +204,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;unsigned int num_tile_cols = pps->num_tile_columns_minus1 +1 ;unsigned int height64 = (sps->pic_height_in_luma_samples +63 ) & ~63 ; +unsigned int pixel_depth = sps->bit_depth_luma_minus8 ==0 ?8 :10 ;unsigned int size; if (num_tile_cols <= 1 ||
@@ -232,7 +233,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx) hevc_dec->tile_bsd.cpu =NULL ; } - size =VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols -1 ); + size = (VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols -1 ) * pixel_depth) /8 ; hevc_dec->tile_filter.cpu =dma_alloc_coherent (vpu->dev, size, &hevc_dec->tile_filter.dma,GFP_KERNEL );
@@ -240,7 +241,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx) goto err_free_tile_buffers; hevc_dec->tile_filter.size = size; - size =VERT_SAO_RAM_SIZE * height64 * (num_tile_cols -1 ); + size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols -1 ) * pixel_depth) /8 ; hevc_dec->tile_sao.cpu =dma_alloc_coherent (vpu->dev, size, &hevc_dec->tile_sao.dma,GFP_KERNEL );
Signature · 1 line
2.25.1
PATCH v4 4/9 media: Add P010 video format
In reply to Benjamin GaignardP010 is a YUV format with 10-bits per pixel with interleaved UV.
---
Note that P010 is already known in GStreamer, only the mapping with v4l2 pixel format is missing.
version 2:
- Add documentation about P010 padding
- Fix the number of bits per component (16)
.../media/v4l/pixfmt-yuv-planar.rst | 78 ++++++++++++++++++- drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 4 files changed, 79 insertions(+), 2 deletions(-)
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +76 -2
@@ -100,8 +100,13 @@ All components are stored with the same number of bits per component. - Cb, Cr - No - 64x32 macroblocks - - Horizontal Z order + * - V4L2_PIX_FMT_P010 + - 'P010' + - 16 + - 4:2:0 + - Cb, Cr + - No + - Linear * - V4L2_PIX_FMT_NV12MT_16X16 - 'VM12' - 8
@@ -171,6 +176,7 @@ horizontally. .. _V4L2-PIX-FMT-NV21: .. _V4L2-PIX-FMT-NV12M: .. _V4L2-PIX-FMT-NV21M: +.. _V4L2-PIX-FMT-P010: NV12, NV21, NV12M and NV21M ---------------------------
@@ -470,6 +476,74 @@ number of lines as the luma plane. - Cb\ :sub:`33` - Cr\ :sub:`33` +.. _V4L2_PIX_FMT_P010: + +P010 +---- + +The number of bytes in one luminance row must be divisible by 16, +which means there will be padded 0 in the right edge when necessary. + +.. raw:: latex + + \begingroup + \small + \setlength{\tabcolsep}{2pt} + +.. tabularcolumns:: |p{2.6cm}|p{0.70cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}| + +.. flat-table:: P010 16 Bits per component + :header-rows: 2 + :stub-columns: 0 + + * - Identifier + - Code + - :cspan:`7` Byte 0 in memory + + - :cspan:`7` Byte 1 + * - + - + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + * - ``V4L2_PIX_FMT_P010`` + - 'P010' + + - Y\ :sub:`9` + - Y\ :sub:`8` + - Y\ :sub:`7` + - Y\ :sub:`6` + - Y\ :sub:`5` + - Y\ :sub:`4` + - Y\ :sub:`3` + - Y\ :sub:`2` + + - Y\ :sub:`1` + - Y\ :sub:`0` + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + +.. raw:: latex + + \endgroup Fully Planar YUV Formats ========================
drivers/media/v4l2-core/v4l2-common.c +1 -0
@@ -266,6 +266,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_NV61, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV24, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV42, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_YUV410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 }, { .format = V4L2_PIX_FMT_YVU410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 },
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1282,6 +1282,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_NV61 : descr ="Y/CrCb 4:2:2" ;break ;case V4L2_PIX_FMT_NV24 : descr ="Y/CbCr 4:4:4" ;break ;case V4L2_PIX_FMT_NV42 : descr ="Y/CrCb 4:4:4" ;break ; +case V4L2_PIX_FMT_P010 : descr ="10-bit Y/CrCb 4:2:0" ;break ;case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ;
include/uapi/linux/videodev2.h +1 -0
@@ -602,6 +602,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4')/* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2')/* 24 Y/CrCb 4:4:4 */ #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2')/* 8 YUV 4:2:0 16x16 macroblocks */ +#define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0')/* 15 Y/CbCr 4:2:0 10-bit per pixel*/ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */
Signature · 1 line
2.25.1
Re: [PATCH v4 4/9] media: Add P010 video format
Hi Benjamin,
Quoted 125 lines · Benjamin Gaignard
P010 is a YUV format with 10-bits per pixel with interleaved UV.
Signed-off-by Benjamin Gaignard <[email protected]>---
Note that P010 is already known in GStreamer, only the mapping with v4l2 pixel format is missing.version 2:
- Add documentation about P010 padding
- Fix the number of bits per component (16).../media/v4l/pixfmt-yuv-planar.rst | 78 ++++++++++++++++++- drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 4 files changed, 79 insertions(+), 2 deletions(-)Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +76
-2@@ -100,8 +100,13 @@ All components are stored with the same number of bits per component. - Cb, Cr - No - 64x32 macroblocks - - Horizontal Z order + * - V4L2_PIX_FMT_P010 + - 'P010' + - 16 + - 4:2:0 + - Cb, Cr + - No + - Linear * - V4L2_PIX_FMT_NV12MT_16X16 - 'VM12' - 8@@ -171,6 +176,7 @@ horizontally. .. _V4L2-PIX-FMT-NV21: .. _V4L2-PIX-FMT-NV12M: .. _V4L2-PIX-FMT-NV21M: +.. _V4L2-PIX-FMT-P010: NV12, NV21, NV12M and NV21M ---------------------------@@ -470,6 +476,74 @@ number of lines as the luma plane. - Cb\ :sub:`33` - Cr\ :sub:`33` +.. _V4L2_PIX_FMT_P010: + +P010 +---- + +The number of bytes in one luminance row must be divisible by 16, +which means there will be padded 0 in the right edge when necessary. + +.. raw:: latex + + \begingroup + \small + \setlength{\tabcolsep}{2pt} + +.. tabularcolumns:: |p{2.6cm}|p{0.70cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}| + +.. flat-table:: P010 16 Bits per component + :header-rows: 2 + :stub-columns: 0 + + * - Identifier + - Code + - :cspan:`7` Byte 0 in memory + + - :cspan:`7` Byte 1 + * - + - + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + * - ``V4L2_PIX_FMT_P010`` + - 'P010' + + - Y\ :sub:`9` + - Y\ :sub:`8` + - Y\ :sub:`7` + - Y\ :sub:`6` + - Y\ :sub:`5` + - Y\ :sub:`4` + - Y\ :sub:`3` + - Y\ :sub:`2` + + - Y\ :sub:`1` + - Y\ :sub:`0` + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + +.. raw:: latex + + \endgroup Fully Planar YUV Formats ========================drivers/media/v4l2-core/v4l2-common.c +0
-0
drivers/media/v4l2-core/v4l2-common.c const struct v4l2_format_info *v4l2_format_info(u32 format) · line 269
Quoted 4 lines
drivers/media/v4l2-core/v4l2-common.c +1
-0@@ -266,6 +266,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_NV61, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV24, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV42, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 },
Just stumbled on this. Shouldn't the bpp be 2, 4 (instead of 2,2) and the vdiv also 2, given that it's basically NV12 with 10bit data contained in 16bit values [1]? Or did I miss something?
[1] https://docs.kernel.org/userspace-api/media/v4l/pixfmt-yuv-planar.html#p010-and-tiled-p010
Sincerely
Sven
Quoted 27 lines
drivers/media/v4l2-core/v4l2-common.c +0
-0{ .format = V4L2_PIX_FMT_YUV410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 }, { .format = V4L2_PIX_FMT_YVU410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 },drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1282,6 +1282,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_NV61 : descr ="Y/CrCb 4:2:2" ;break ;case V4L2_PIX_FMT_NV24 : descr ="Y/CbCr 4:4:4" ;break ;case V4L2_PIX_FMT_NV42 : descr ="Y/CrCb 4:4:4" ;break ; +case V4L2_PIX_FMT_P010 : descr ="10-bit Y/CrCb 4:2:0" ;break ;case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ;include/uapi/linux/videodev2.h +1
-0@@ -602,6 +602,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4')/* 24 Y/CbCr 4:4:4 */ #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2')/* 24 Y/CrCb 4:4:4 */ #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2')/* 8 YUV 4:2:0 16x16 macroblocks */ +#define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0')/* 15 Y/CbCr 4:2:0 10-bit per pixel*/ /* two non contiguous planes - one Y, one Cr + Cb interleaved */ #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 */
PATCH v4 5/9 media: hantro: hevc: Allow to produce 10-bit frames
In reply to Benjamin GaignardIf Hantro driver receive an 10-bit encoded bitstream allow it to produce 10-bit frames.
Check that we are not try to produce 10-bit frames from a 8-bit encoded bitstream.
---
version 4:
- Make sure that 10 bits output format (i.e. P010) is only enumerated when encoded input stream is 10 bits.
.../staging/media/hantro/hantro_g2_hevc_dec.c | 18 ++++++++--- drivers/staging/media/hantro/hantro_hevc.c | 2 +- drivers/staging/media/hantro/hantro_v4l2.c | 31 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 4 +++ 4 files changed, 50 insertions(+), 5 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +14 -4
@@ -143,6 +143,16 @@ static bool is_8bit_dst_format(struct hantro_ctx *ctx) } } +static int get_dst_format (struct hantro_ctx *ctx) +{ +switch (ctx->vpu_dst_fmt->fourcc) { +case V4L2_PIX_FMT_P010 : +return 0x1 ; +default : +return 0x0 ; + } +} +static void set_params (struct hantro_ctx *ctx) {const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls;
@@ -158,8 +168,8 @@ static void set_params(struct hantro_ctx *ctx)hantro_reg_write (vpu, &g2_bit_depth_y_minus8, sps->bit_depth_luma_minus8);hantro_reg_write (vpu, &g2_bit_depth_c_minus8, sps->bit_depth_chroma_minus8); -hantro_reg_write (vpu, &g2_output_8_bits,1 ); -hantro_reg_write (vpu, &g2_output_format,0 ); +hantro_reg_write (vpu, &g2_output_8_bits,is_8bit_dst_format (ctx)); +hantro_reg_write (vpu, &g2_output_format,get_dst_format (ctx));hantro_reg_write (vpu, &g2_hdr_skip_length, ctrls->hevc_hdr_skip_length);
@@ -540,7 +550,7 @@ static size_t hantro_hevc_output_chroma_offset(struct hantro_ctx *ctx)int bytes_per_pixel =is_8bit_dst_format (ctx) ?1 :2 ;return sps->pic_width_in_luma_samples * - sps->pic_height_in_luma_samples * bytes_per_pixel; + sps->pic_height_in_luma_samples * bytes_per_pixel; }static void set_buffers (struct hantro_ctx *ctx)
@@ -627,7 +637,7 @@ int hantro_g2_hevc_dec_run(struct hantro_ctx *ctx)/* Compress buffers */ hantro_reg_write (vpu, &g2_ref_compress_bypass,0 ); -/* use NV12 as output format */ +/* Use raster-scan as output format */ hantro_reg_write (vpu, &g2_out_rs_e,1 );/* Bus width and max burst */
drivers/staging/media/hantro/hantro_hevc.c +1 -1
@@ -25,7 +25,7 @@#define UNUSED_REF -1 -#define G2_ALIGN 16 +#define G2_ALIGN 16#define CBS_SIZE 16/* compression table size in bytes */ #define CBS_LUMA 8/* luminance CBS is composed of 1 8x8 coded block */
drivers/staging/media/hantro/hantro_v4l2.c +31 -0
@@ -141,6 +141,34 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,return 0 ; } +static bool hantro_hevc_check_possible_formats (struct hantro_ctx *ctx, +const struct hantro_fmt *fmt) +{ +const struct v4l2_ctrl_hevc_sps *sps; + +/* +* For HEVC check if the format is allowed given the luma depth +* because the hardware can only produce 10 bits output frames +* from 10 bits inputs streams. +* It possible to produce 8 bits output frames from 10 bits inputs +* streams. +*/ +if (ctx->vpu_src_fmt->fourcc !=V4L2_PIX_FMT_HEVC_SLICE ) +return true; + + sps =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_HEVC_SPS ); +if (!sps) +return false; + +if (sps->bit_depth_luma_minus8 ==2 ) +return true; + +if (fmt->fourcc ==V4L2_PIX_FMT_P010 ) +return false; + +return true; +} +static int vidioc_enum_fmt (struct file *file,void *priv,struct v4l2_fmtdesc *f,bool capture)
@@ -168,6 +196,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,if (skip_mode_none == mode_none)continue ; +if (capture && + !hantro_hevc_check_possible_formats (ctx, &formats[i])) +continue ;if (j == f->index) { fmt = &formats[i]; f->pixelformat = fmt->fourcc;
drivers/staging/media/hantro/imx8m_vpu_hw.c +4 -0
@@ -135,6 +135,10 @@ static const struct hantro_fmt imx8m_vpu_g2_dec_fmts[] = { .fourcc = V4L2_PIX_FMT_NV12, .codec_mode = HANTRO_MODE_NONE, }, + { + .fourcc = V4L2_PIX_FMT_P010, + .codec_mode = HANTRO_MODE_NONE, + }, { .fourcc = V4L2_PIX_FMT_HEVC_SLICE, .codec_mode = HANTRO_MODE_HEVC_DEC,
Signature · 1 line
2.25.1
PATCH v4 6/9 media: hantro: create ops for variants
In reply to Benjamin GaignardMove init() and runtime_resume() prototypes from struct hantro_variant to the new struct hantro_variant_ops.
That will allow to add more variant dedicated operations in cleaner way.
--- drivers/staging/media/hantro/hantro.h | 17 ++++++++--- drivers/staging/media/hantro/hantro_drv.c | 6 ++-- drivers/staging/media/hantro/imx8m_vpu_hw.c | 11 ++++--- .../staging/media/hantro/rockchip_vpu_hw.c | 30 +++++++++++++------ .../staging/media/hantro/sama5d4_vdec_hw.c | 6 +++- 5 files changed, 49 insertions(+), 21 deletions(-)
drivers/staging/media/hantro/hantro.h +13 -4
@@ -49,6 +49,17 @@ struct hantro_irq {irqreturn_t (*handler)(int irq,void *priv); }; +/** +* struct hantro_variant_ops - variant operations +* +* @init: Initialize hardware. +* @runtime_resume: reenable hardware after power gating +*/ +struct hantro_variant_ops { +int (*init)(struct hantro_dev *vpu); +int (*runtime_resume)(struct hantro_dev *vpu); +}; +/** * struct hantro_variant - information about VPU hardware variant *
@@ -62,8 +73,6 @@ struct hantro_irq {* @num_postproc_fmts: Number of post-processor formats. * @codec: Supported codecs * @codec_ops: Codec ops. -* @init: Initialize hardware. -* @runtime_resume: reenable hardware after power gating * @irqs: array of irq names and interrupt handlers * @num_irqs: number of irqs in the array * @clk_names: array of clock names
@@ -71,6 +80,7 @@ struct hantro_irq {* @reg_names: array of register range names * @num_regs: number of register range names in the array * @postproc_regs: &struct hantro_postproc_regs pointer +* @ops: variant operations */ struct hantro_variant {unsigned int enc_offset;
@@ -83,8 +93,6 @@ struct hantro_variant {unsigned int num_postproc_fmts;unsigned int codec;const struct hantro_codec_ops *codec_ops; -int (*init)(struct hantro_dev *vpu); -int (*runtime_resume)(struct hantro_dev *vpu);const struct hantro_irq *irqs;int num_irqs;const char *const *clk_names;
@@ -92,6 +100,7 @@ struct hantro_variant {const char *const *reg_names;int num_regs;const struct hantro_postproc_regs *postproc_regs; +struct hantro_variant_ops *ops; };/**
drivers/staging/media/hantro/hantro_drv.c +3 -3
@@ -946,7 +946,7 @@ static int hantro_probe(struct platform_device *pdev) } } - ret = vpu->variant->init (vpu); + ret = vpu->variant->ops->init (vpu);if (ret) {dev_err (&pdev->dev,"Failed to init VPU hardware\n" );return ret;
@@ -1043,8 +1043,8 @@ static int hantro_runtime_resume(struct device *dev) {struct hantro_dev *vpu =dev_get_drvdata (dev); -if (vpu->variant->runtime_resume) -return vpu->variant->runtime_resume (vpu); +if (vpu->variant->ops->runtime_resume) +return vpu->variant->ops->runtime_resume (vpu);return 0 ; }
drivers/staging/media/hantro/imx8m_vpu_hw.c +7 -4
@@ -275,6 +275,11 @@ static const struct hantro_irq imx8mq_g2_irqs[] = {static const char *const imx8mq_clk_names[] = {"g1" ,"g2" ,"bus" }; +static struct hantro_variant_ops imx8mq_vpu_variant_ops = { + .init = imx8mq_vpu_hw_init, + .runtime_resume = imx8mq_runtime_resume, +}; +const struct hantro_variant imx8mq_vpu_variant = { .dec_fmts = imx8m_vpu_dec_fmts, .num_dec_fmts =ARRAY_SIZE (imx8m_vpu_dec_fmts),
@@ -284,12 +289,11 @@ const struct hantro_variant imx8mq_vpu_variant = { .codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = imx8mq_vpu_codec_ops, - .init = imx8mq_vpu_hw_init, - .runtime_resume = imx8mq_runtime_resume, .irqs = imx8mq_irqs, .num_irqs = ARRAY_SIZE(imx8mq_irqs), .clk_names = imx8mq_clk_names, .num_clocks = ARRAY_SIZE(imx8mq_clk_names), + .ops = &imx8mq_vpu_variant_ops, };const struct hantro_variant imx8mq_vpu_g2_variant = {
@@ -298,10 +302,9 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .num_dec_fmts = ARRAY_SIZE(imx8m_vpu_g2_dec_fmts), .codec = HANTRO_HEVC_DECODER, .codec_ops = imx8mq_vpu_g2_codec_ops, - .init = imx8mq_vpu_hw_init, - .runtime_resume = imx8mq_runtime_resume, .irqs = imx8mq_g2_irqs, .num_irqs = ARRAY_SIZE(imx8mq_g2_irqs), .clk_names = imx8mq_clk_names, .num_clocks = ARRAY_SIZE(imx8mq_clk_names), + .ops = &imx8mq_vpu_variant_ops, };
drivers/staging/media/hantro/rockchip_vpu_hw.c +21 -9
@@ -433,6 +433,10 @@ static const char * const rockchip_vpu_clk_names[] = {"aclk" ,"hclk" }; +static struct hantro_variant_ops rk3036_vpu_variant_ops = { + .init = rk3036_vpu_hw_init, +}; +const struct hantro_variant rk3036_vpu_variant = { .dec_offset =0x400 , .dec_fmts = rk3066_vpu_dec_fmts,
@@ -445,9 +449,13 @@ const struct hantro_variant rk3036_vpu_variant = { .codec_ops = rk3036_vpu_codec_ops, .irqs = rockchip_vdpu1_irqs, .num_irqs = ARRAY_SIZE(rockchip_vdpu1_irqs), - .init = rk3036_vpu_hw_init, .clk_names = rockchip_vpu_clk_names, - .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names) + .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names), + .ops = &rk3036_vpu_variant_ops, +}; + +static struct hantro_variant_ops rk3066_vpu_variant_ops = { + .init = rk3066_vpu_hw_init, };/*
@@ -470,9 +478,13 @@ const struct hantro_variant rk3066_vpu_variant = { .codec_ops = rk3066_vpu_codec_ops, .irqs = rockchip_vpu1_irqs, .num_irqs = ARRAY_SIZE(rockchip_vpu1_irqs), - .init = rk3066_vpu_hw_init, .clk_names = rk3066_vpu_clk_names, - .num_clocks = ARRAY_SIZE(rk3066_vpu_clk_names) + .num_clocks = ARRAY_SIZE(rk3066_vpu_clk_names), + .ops = &rk3066_vpu_variant_ops, +}; + +static struct hantro_variant_ops rk33xx_vpu_variant_ops = { + .init = rockchip_vpu_hw_init, };const struct hantro_variant rk3288_vpu_variant = {
@@ -490,9 +502,9 @@ const struct hantro_variant rk3288_vpu_variant = { .codec_ops = rk3288_vpu_codec_ops, .irqs = rockchip_vpu1_irqs, .num_irqs = ARRAY_SIZE(rockchip_vpu1_irqs), - .init = rockchip_vpu_hw_init, .clk_names = rockchip_vpu_clk_names, - .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names) + .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names), + .ops = &rk33xx_vpu_variant_ops, };const struct hantro_variant rk3328_vpu_variant = {
@@ -503,9 +515,9 @@ const struct hantro_variant rk3328_vpu_variant = { .codec_ops = rk3399_vpu_codec_ops, .irqs = rockchip_vdpu2_irqs, .num_irqs = ARRAY_SIZE(rockchip_vdpu2_irqs), - .init = rockchip_vpu_hw_init, .clk_names = rockchip_vpu_clk_names, .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names), + .ops = &rk33xx_vpu_variant_ops, };const struct hantro_variant rk3399_vpu_variant = {
@@ -520,7 +532,7 @@ const struct hantro_variant rk3399_vpu_variant = { .codec_ops = rk3399_vpu_codec_ops, .irqs = rockchip_vpu2_irqs, .num_irqs = ARRAY_SIZE(rockchip_vpu2_irqs), - .init = rockchip_vpu_hw_init, .clk_names = rockchip_vpu_clk_names, - .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names) + .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names), + .ops = &rk33xx_vpu_variant_ops, };
drivers/staging/media/hantro/sama5d4_vdec_hw.c +5 -1
@@ -100,6 +100,10 @@ static const struct hantro_irq sama5d4_irqs[] = {static const char *const sama5d4_clk_names[] = {"vdec_clk" }; +static struct hantro_variant_ops sama5d4_vdec_variant_ops = { + .init = sama5d4_hw_init, +}; +const struct hantro_variant sama5d4_vdec_variant = { .dec_fmts = sama5d4_vdec_fmts, .num_dec_fmts =ARRAY_SIZE (sama5d4_vdec_fmts),
@@ -109,9 +113,9 @@ const struct hantro_variant sama5d4_vdec_variant = { .codec = HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = sama5d4_vdec_codec_ops, - .init = sama5d4_hw_init, .irqs = sama5d4_irqs, .num_irqs = ARRAY_SIZE(sama5d4_irqs), .clk_names = sama5d4_clk_names, .num_clocks = ARRAY_SIZE(sama5d4_clk_names), + .ops = &sama5d4_vdec_variant_ops, };
Signature · 1 line
2.25.1
PATCH v4 7/9 media: hantro: enumerate scaled output formats
In reply to Benjamin GaignardWhen enumerating the output formats take care of the hardware scaling capabilities.
For a given input size G2 hardware block is capable of down scale the output by 2, 4 or 8 factor. When decoding 4K streams that to be could helpful to save memory bandwidth.
---
version 4:
- rename ops scaling to enum_framesizes
drivers/staging/media/hantro/hantro.h | 4 ++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 46 ++++++++++++++++++- drivers/staging/media/hantro/hantro_g2_regs.h | 6 +++ drivers/staging/media/hantro/hantro_hw.h | 2 + drivers/staging/media/hantro/hantro_v4l2.c | 10 ++-- drivers/staging/media/hantro/imx8m_vpu_hw.c | 8 +++- 6 files changed, 70 insertions(+), 6 deletions(-)
drivers/staging/media/hantro/hantro.h +4 -0
@@ -54,10 +54,14 @@ struct hantro_irq {* * @init: Initialize hardware. * @runtime_resume: reenable hardware after power gating +* @enum_framesizes: Enumerate possible scaled output formats. +* Returns zero if OK, a negative value in error cases. +* Optional. */ struct hantro_variant_ops {int (*init)(struct hantro_dev *vpu);int (*runtime_resume)(struct hantro_dev *vpu); +int (*enum_framesizes)(struct hantro_ctx *ctx,struct v4l2_frmsizeenum *fsize); };/**
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +44 -2
70 lines not on this page · raw message
drivers/staging/media/hantro/hantro_g2_regs.h +6 -0
@@ -174,6 +174,10 @@#define g2_buswidth G2_DEC_REG(58, 8, 0x7)#define g2_max_burst G2_DEC_REG(58, 0, 0xff) +#define g2_down_scale_e G2_DEC_REG(184, 7, 0x1) +#define g2_down_scale_y G2_DEC_REG(184, 2, 0x3) +#define g2_down_scale_x G2_DEC_REG(184, 0, 0x3) +#define G2_REG_CONFIG G2_SWREG(58)#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17)
@@ -193,6 +197,8 @@#define G2_TILE_FILTER (G2_SWREG(179))#define G2_TILE_SAO (G2_SWREG(181))#define G2_TILE_BSD (G2_SWREG(183)) +#define G2_DS_DST (G2_SWREG(186)) +#define G2_DS_DST_CHR (G2_SWREG(188))#define G2_COMP_ADDR_DST (G2_SWREG(190))#define G2_COMP_ADDR_REF (i) (G2_SWREG(192) + ((i) * 0x8))#define G2_COMP_CHR (G2_SWREG(224))
drivers/staging/media/hantro/hantro_hw.h +2 -0
@@ -243,6 +243,8 @@ int hantro_hevc_dec_init(struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx);void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx); +int hantro_g2_dec_enum_framesizes (struct hantro_ctx *ctx, +struct v4l2_frmsizeenum *fsize);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);
drivers/staging/media/hantro/hantro_v4l2.c +7 -3
@@ -118,7 +118,7 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,struct hantro_ctx *ctx =fh_to_ctx (priv);const struct hantro_fmt *fmt; -if (fsize->index !=0 ) { +if (fsize->index !=0 && !ctx->dev->variant->ops->enum_framesizes) {vpu_debug (0 ,"invalid frame size index (expected 0, got %d)\n" , fsize->index);return -EINVAL ;
@@ -131,9 +131,13 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,return -EINVAL ; } -/* This only makes sense for coded formats */ -if (fmt->codec_mode ==HANTRO_MODE_NONE ) +/* For non-coded formats check if scaling is possible */ +if (fmt->codec_mode ==HANTRO_MODE_NONE ) { +if (ctx->dev->variant->ops->enum_framesizes) +return ctx->dev->variant->ops->enum_framesizes (ctx, fsize); +return -EINVAL ; + } fsize->type =V4L2_FRMSIZE_TYPE_STEPWISE ; fsize->stepwise = fmt->frmsize;
drivers/staging/media/hantro/imx8m_vpu_hw.c +7 -1
@@ -280,6 +280,12 @@ static struct hantro_variant_ops imx8mq_vpu_variant_ops = { .runtime_resume = imx8mq_runtime_resume, }; +static struct hantro_variant_ops imx8mq_vpu_g2_variant_ops = { + .init = imx8mq_vpu_hw_init, + .runtime_resume = imx8mq_runtime_resume, + .enum_framesizes = hantro_g2_dec_enum_framesizes, +}; +const struct hantro_variant imx8mq_vpu_variant = { .dec_fmts = imx8m_vpu_dec_fmts, .num_dec_fmts =ARRAY_SIZE (imx8m_vpu_dec_fmts),
@@ -306,5 +312,5 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .num_irqs = ARRAY_SIZE(imx8mq_g2_irqs), .clk_names = imx8mq_clk_names, .num_clocks = ARRAY_SIZE(imx8mq_clk_names), - .ops = &imx8mq_vpu_variant_ops, + .ops = &imx8mq_vpu_g2_variant_ops, };
Signature · 1 line
2.25.1
PATCH v4 8/9 media: hevc: Add scaling matrix control
In reply to Benjamin GaignardHEVC scaling lists are used for the scaling process for transform coefficients.V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED has to set when they are encoded in the bitstream.
---
Note: V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED is not change by this patch. There is a thread about the naming/usage of this flag here:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
but that doesn't concern the scaling matrix control by itself.
version 2:
- Fix structure name in ext-ctrls-codec.rst
.../media/v4l/ext-ctrls-codec.rst | 45 +++++++++++++++++++ .../media/v4l/vidioc-queryctrl.rst | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-core.c | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 ++ include/media/hevc-ctrls.h | 11 +++++ 5 files changed, 72 insertions(+)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +45 -0
@@ -3071,6 +3071,51 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - \normalsize +``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)`` + Specifies the HEVC scaling matrix parameters used for the scaling process + for transform coefficients. + These matrix and parameters are defined according to :ref:`hevc`. + They are described in section 7.4.5 "Scaling list data semantics" of + the specification. + +.. c:type:: v4l2_ctrl_hevc_scaling_matrix + +.. raw:: latex + + \scriptsize + +.. tabularcolumns:: |p{5.4cm}|p{6.8cm}|p{5.1cm}| + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``scaling_list_4x4[6][16]`` + - + * - __u8 + - ``scaling_list_8x8[6][64]`` + - + * - __u8 + - ``scaling_list_16x16[6][64]`` + - + * - __u8 + - ``scaling_list_32x32[2][64]`` + - + * - __u8 + - ``scaling_list_dc_coef_16x16[6]`` + - + * - __u8 + - ``scaling_list_dc_coef_32x32[2]`` + - + +.. raw:: latex + + \normalsize + .. c:type:: v4l2_hevc_dpb_entry .. raw:: latex
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +6 -0
@@ -495,6 +495,12 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_hevc_slice_params`, containing HEVC slice parameters for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_scaling_matrix`, containing HEVC + scaling matrix for stateless video decoders. * - ``V4L2_CTRL_TYPE_VP8_FRAME`` - n/a - n/a
drivers/media/v4l2-core/v4l2-ctrls-core.c +6 -0
@@ -687,6 +687,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,break ; +case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX : +break ; +case V4L2_CTRL_TYPE_AREA : area = p;if (!area->width || !area->height)
@@ -1240,6 +1243,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS : elem_size =sizeof (struct v4l2_ctrl_hevc_slice_params );break ; +case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX : + elem_size =sizeof (struct v4l2_ctrl_hevc_scaling_matrix ); +break ;case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS : elem_size =sizeof (struct v4l2_ctrl_hevc_decode_params );break ;
drivers/media/v4l2-core/v4l2-ctrls-defs.c +4 -0
@@ -996,6 +996,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_HEVC_SPS :return "HEVC Sequence Parameter Set" ;case V4L2_CID_MPEG_VIDEO_HEVC_PPS :return "HEVC Picture Parameter Set" ;case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS :return "HEVC Slice Parameters" ; +case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX :return "HEVC Scaling Matrix" ;case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS :return "HEVC Decode Parameters" ;case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE :return "HEVC Decode Mode" ;case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE :return "HEVC Start Code" ;
@@ -1488,6 +1489,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS : *type =V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS ;break ; +case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX : + *type =V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX ; +break ;case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS : *type =V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS ;break ;
include/media/hevc-ctrls.h +11 -0
@@ -19,6 +19,7 @@#define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_CODEC_BASE + 1008)#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_CODEC_BASE + 1009)#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_BASE + 1010) +#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_CODEC_BASE + 1011)#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS (V4L2_CID_CODEC_BASE + 1012)#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_CODEC_BASE + 1015)#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_CODEC_BASE + 1016)
@@ -27,6 +28,7 @@#define V4L2_CTRL_TYPE_HEVC_SPS 0x0120#define V4L2_CTRL_TYPE_HEVC_PPS 0x0121#define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122 +#define V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX 0x0123#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124enum v4l2_mpeg_video_hevc_decode_mode {
@@ -225,6 +227,15 @@ struct v4l2_ctrl_hevc_decode_params {__u64 flags; }; +struct v4l2_ctrl_hevc_scaling_matrix { +__u8 scaling_list_4x4[6 ][16 ]; +__u8 scaling_list_8x8[6 ][64 ]; +__u8 scaling_list_16x16[6 ][64 ]; +__u8 scaling_list_32x32[2 ][64 ]; +__u8 scaling_list_dc_coef_16x16[6 ]; +__u8 scaling_list_dc_coef_32x32[2 ]; +}; +/* MPEG-class control IDs specific to the Hantro driver as defined by V4L2 */ #define V4L2_CID_CODEC_HANTRO_BASE (V4L2_CTRL_CLASS_CODEC | 0x1200)/*
Signature · 1 line
2.25.1
Re: [PATCH v4 8/9] media: hevc: Add scaling matrix control
Hi Benjamin,
I believe the scaling matrix uAPI patch(es) and the support in Hantro G2 could be moved to its own series and maybe merged sooner than the rest (which may need more discussion).
Couple remarks below.
Quoted 5 lines · Benjamin Gaignard
HEVC scaling lists are used for the scaling process for transform coefficients.
V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLEDhas to set when they are encoded in the bitstream.
Quoted 7 lines
Signed-off-by Benjamin Gaignard <[email protected]>---
Note:V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLEDis not change by this patch. There is a thread about the naming/usage of this flag here:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
but that doesn't concern the scaling matrix control by itself.
If I am reading the spec correctly, we have fields in SPS (scaling_list_enabled_flag, scaling_list_data_present_flag) and PPS (scaling_list_data_present_flag).
We don't need all that, since all a driver needs to know is whether a scaling list is to be applied for the current frame.
Would you mind adding a patch moving the flag to the PPS?
Quoted 17 lines
version 2:
- Fix structure name inext-ctrls-codec.rst.../media/v4l/ext-ctrls-codec.rst | 45 +++++++++++++++++++ .../media/v4l/vidioc-queryctrl.rst | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-core.c | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 ++ include/media/hevc-ctrls.h | 11 +++++
5 files changed, 72 insertions(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-0@@ -3071,6 +3071,51 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
\normalsize
Quoted 8 lines
+``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
+ Specifies the HEVC scaling matrix parameters used for the scaling process + for transform coefficients.
+ These matrix and parameters are defined according to :ref:hevc. + They are described in section 7.4.5 "Scaling list data semantics" of + the specification.
+
This needs some additional documentation about the order of the lists. See the docs that we've added for the scaling_list_{} fields in V4L2_CID_STATELESS_H264_SCALING_MATRIX.
Thanks!
Signature · 2 lines
Kindly, Ezequiel
Re: [PATCH v4 8/9] media: hevc: Add scaling matrix control
Le 13/07/2021 à 00:21, Ezequiel Garcia a écrit :
Quoted 21 lines
Hi Benjamin,
I believe the scaling matrix uAPI patch(es) and the support in Hantro G2 could be moved to its own series and maybe merged sooner than the rest (which may need more discussion).
Couple remarks below.
Quoted 5 lines · Benjamin Gaignard
HEVC scaling lists are used for the scaling process for transform coefficients.
V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLEDhas to set when they are encoded in the bitstream.Quoted 7 lines
Signed-off-by Benjamin Gaignard <[email protected]>---
Note:V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLEDis not change by this patch. There is a thread about the naming/usage of this flag here:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
but that doesn't concern the scaling matrix control by itself.
Quoted 8 lines
If I am reading the spec correctly, we have fields in SPS (
scaling_list_enabled_flag,scaling_list_data_present_flag) and PPS (scaling_list_data_present_flag).We don't need all that, since all a driver needs to know is whether a scaling list is to be applied for the current frame.
Would you mind adding a patch moving the flag to the PPS?
Extract from the spec:
- scaling_list_enabled_flag equal 1 specifies that a scaling list is used for scaling process for transform coefficients.
- sps_scaling_list_data_present_flag equal to 1 specifies that the scaling_list_data( ) syntax structure is present in the SPS.
- pps_scaling_list_data_present_flag equal to 1 specifies that parameters are present in the PPS to modify the scaling lists specified by the active SPS.
For me V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED represent scaling_list_enabled_flag while the other are used to build the scaling lists values. So it is good named from my point of view.
Quoted 19 lines
Quoted 19 lines
version 2:
- Fix structure name inext-ctrls-codec.rst.../media/v4l/ext-ctrls-codec.rst | 45 +++++++++++++++++++ .../media/v4l/vidioc-queryctrl.rst | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-core.c | 6 +++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 ++ include/media/hevc-ctrls.h | 11 +++++ 5 files changed, 72 insertions(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-0@@ -3071,6 +3071,51 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - \normalsize
Quoted 10 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst enum v4l2_mpeg_video_hevc_size_of_length_field - · line 3080
Quoted 7 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +7
-0+``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)`` + Specifies the HEVC scaling matrix parameters used for the scaling process + for transform coefficients. + These matrix and parameters are defined according to :ref:`hevc`. + They are described in section 7.4.5 "Scaling list data semantics" of + the specification. +This needs some additional documentation about the order of the lists. See the docs that we've added for the scaling_list_{} fields in
V4L2_CID_STATELESS_H264_SCALING_MATRIX.
I will do dedicated patches for scaling lists feature and add that.
Benjamin
Quoted 2 lines
Thanks!
PATCH v4 9/9 media: hantro: Add scaling lists feature
In reply to Benjamin GaignardIf the bitstream embedded scaling lists allow the driver to use them for decode the frames.
The scaling lists are expected to be in raster scan order (i.e. not up right diagonal scan order)
Allocate the memory needed to store lists.
--- drivers/staging/media/hantro/hantro_drv.c | 8 +-- .../staging/media/hantro/hantro_g2_hevc_dec.c | 52 +++++++++++++++++++ drivers/staging/media/hantro/hantro_hevc.c | 21 ++++++++ drivers/staging/media/hantro/hantro_hw.h | 3 ++ 4 files changed, 81 insertions(+), 3 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +5 -3
@@ -267,9 +267,6 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) sps->bit_depth_luma_minus8 != 2)/* Only 8-bit or 10-bit is supported */ return -EINVAL ; -if (sps->flags &V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED ) -/* No scaling support */ -return -EINVAL ; }return 0 ; }
@@ -451,6 +448,11 @@ static const struct hantro_ctrl controls[] = { .cfg = { .id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS, }, + }, { + .codec = HANTRO_HEVC_DECODER, + .cfg = { + .id = V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX, + }, }, { .codec = HANTRO_HEVC_DECODER, .cfg = {
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +52 -0
64 lines not on this page · raw message
drivers/staging/media/hantro/hantro_hevc.c +21 -0
@@ -20,6 +20,8 @@/* tile border coefficients of filter */ #define VERT_SAO_RAM_SIZE 48/* bytes per pixel */ +#define SCALING_LIST_SIZE (16 * 64) +#define MAX_TILE_COLS 20#define MAX_TILE_ROWS 22
@@ -296,6 +298,11 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ctx)if (WARN_ON (!ctrls->decode_params))return -EINVAL ; + ctrls->scaling = +hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX ); +if (WARN_ON (!ctrls->scaling)) +return -EINVAL ; + ctrls->sps =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_HEVC_SPS );if (WARN_ON (!ctrls->sps))
@@ -324,6 +331,12 @@ void hantro_hevc_dec_exit(struct hantro_ctx *ctx) hevc_dec->tile_sizes.dma); hevc_dec->tile_sizes.cpu =NULL ; +if (hevc_dec->scaling_lists.cpu) +dma_free_coherent (vpu->dev, hevc_dec->scaling_lists.size, + hevc_dec->scaling_lists.cpu, + hevc_dec->scaling_lists.dma); + hevc_dec->scaling_lists.cpu =NULL ; +if (hevc_dec->tile_filter.cpu) dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, hevc_dec->tile_filter.cpu,
@@ -367,6 +380,14 @@ int hantro_hevc_dec_init(struct hantro_ctx *ctx) hevc_dec->tile_sizes.size = size; + hevc_dec->scaling_lists.cpu =dma_alloc_coherent (vpu->dev,SCALING_LIST_SIZE , + &hevc_dec->scaling_lists.dma, +GFP_KERNEL ); +if (!hevc_dec->scaling_lists.cpu) +return -ENOMEM ; + + hevc_dec->scaling_lists.size =SCALING_LIST_SIZE ; +hantro_hevc_ref_init (ctx);return 0 ;
drivers/staging/media/hantro/hantro_hw.h +3 -0
@@ -108,6 +108,7 @@ struct hantro_h264_dec_hw_ctx {*/ struct hantro_hevc_dec_ctrls {const struct v4l2_ctrl_hevc_decode_params *decode_params; +const struct v4l2_ctrl_hevc_scaling_matrix *scaling;const struct v4l2_ctrl_hevc_sps *sps;const struct v4l2_ctrl_hevc_pps *pps;u32 hevc_hdr_skip_length;
@@ -120,6 +121,7 @@ struct hantro_hevc_dec_ctrls {* @tile_sao: Tile SAO buffer * @tile_bsd: Tile BSD control buffer * @ref_bufs: Internal reference buffers +* @scaling_lists: Scaling lists buffer * @ref_bufs_poc: Internal reference buffers picture order count * @ref_bufs_used: Bitfield of used reference buffers * @ctrls: V4L2 controls attached to a run
@@ -131,6 +133,7 @@ struct hantro_hevc_dec_hw_ctx {struct hantro_aux_buf tile_sao;struct hantro_aux_buf tile_bsd;struct hantro_aux_buf ref_bufs[NUM_REF_PICTURES ]; +struct hantro_aux_buf scaling_lists;int ref_bufs_poc[NUM_REF_PICTURES ];u32 ref_bufs_used;struct hantro_hevc_dec_ctrls ctrls;
Signature · 1 line
2.25.1