Skip to contentSkip to conversation

media: verisilicon: Simplification and clean up

PATCH In review Benjamin Gaignard 3 participants 8 messages Apr 15 – Apr 30

Subsystems (6)
lore
Share & tools
lore

Benjamin Gaignard

author maintainer
#0 lore raw

v3 cover media: verisilicon: Simplification and clean up

Simplify motion vectors and reference allocation with common helpers. Since it requires to move some of codecs specific functions and structure in codecs header files add a patch to finish the clean up.

Benjamin Gaignard (2):
media: verisilicon: Simplify motion vectors and rfc buffers allocation
media: verisilicon: Clean up messy include

 drivers/media/platform/verisilicon/hantro.h   |  31 +-
 .../media/platform/verisilicon/hantro_av1.c   |   7 -
 .../media/platform/verisilicon/hantro_av1.h   | 100 +++-
 .../platform/verisilicon/hantro_g1_h264_dec.c |   1 +
 .../verisilicon/hantro_g1_mpeg2_dec.c         |   2 +-
 .../platform/verisilicon/hantro_g1_vp8_dec.c  |   2 +-
 .../media/platform/verisilicon/hantro_g2.c    |  36 --
 .../platform/verisilicon/hantro_g2_hevc_dec.c |  26 +-
 .../platform/verisilicon/hantro_g2_vp9_dec.c  |  12 +-
 .../media/platform/verisilicon/hantro_h264.c  |   2 +-
 .../media/platform/verisilicon/hantro_h264.h  |  98 ++++
 .../media/platform/verisilicon/hantro_hevc.c  |  37 +-
 .../media/platform/verisilicon/hantro_hevc.h  |  82 ++++
 .../media/platform/verisilicon/hantro_hw.h    | 446 +-----------------
 .../media/platform/verisilicon/hantro_mpeg2.c |   1 +
 .../media/platform/verisilicon/hantro_mpeg2.h |  27 ++
 .../platform/verisilicon/hantro_postproc.c    |  29 +-
 .../media/platform/verisilicon/hantro_v4l2.c  | 262 +++++++++-
 .../media/platform/verisilicon/hantro_vp8.c   |   1 +
 .../media/platform/verisilicon/hantro_vp8.h   |  29 ++
 .../media/platform/verisilicon/hantro_vp9.h   | 104 ++++
 .../media/platform/verisilicon/imx8m_vpu_hw.c |   5 +
 .../verisilicon/rockchip_vpu2_hw_h264_dec.c   |   2 +-
 .../verisilicon/rockchip_vpu2_hw_mpeg2_dec.c  |   2 +-
 .../verisilicon/rockchip_vpu2_hw_vp8_dec.c    |   2 +-
 .../verisilicon/rockchip_vpu981_hw_av1_dec.c  |  16 +-
 .../platform/verisilicon/rockchip_vpu_hw.c    |   3 +
 .../platform/verisilicon/stm32mp25_vpu_hw.c   |   2 +
 .../media/platform/verisilicon/sunxi_vpu_hw.c |   1 +
 29 files changed, 796 insertions(+), 572 deletions(-)
 create mode 100644 drivers/media/platform/verisilicon/hantro_h264.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_hevc.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_mpeg2.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_vp8.h
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v3 1/2 media: verisilicon: Simplify motion vectors and rfc buffers allocation

Until now we reserve the space needed for motion vectors and reference frame compression at the end of the frame buffer. Disentanglement mv and rfc from frame buffers by allocating distinct buffers for each purpose.
That simplify the code by removing lot of offset computation.

---
 drivers/media/platform/verisilicon/hantro.h   |  17 +-
 .../media/platform/verisilicon/hantro_av1.c   |   7 -
 .../media/platform/verisilicon/hantro_av1.h   |  14 +-
 .../media/platform/verisilicon/hantro_g2.c    |  36 ---
 .../platform/verisilicon/hantro_g2_hevc_dec.c |  24 +-
 .../platform/verisilicon/hantro_g2_vp9_dec.c  |  12 +-
 .../media/platform/verisilicon/hantro_h264.h  |  33 +++
 .../media/platform/verisilicon/hantro_hevc.c  |  35 ++-
 .../media/platform/verisilicon/hantro_hevc.h  |  16 ++
 .../media/platform/verisilicon/hantro_hw.h    | 104 +------
 .../platform/verisilicon/hantro_postproc.c    |  29 +-
 .../media/platform/verisilicon/hantro_v4l2.c  | 255 ++++++++++++++++--
 .../media/platform/verisilicon/hantro_vp9.h   |  18 ++
 .../verisilicon/rockchip_vpu981_hw_av1_dec.c  |  16 +-
 14 files changed, 388 insertions(+), 228 deletions(-)
 create mode 100644 drivers/media/platform/verisilicon/hantro_h264.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_hevc.h
drivers/media/platform/verisilicon/hantro.h +15 -2
index 0353de154a1e..c4ceb9c99016 100644
@@ -31,6 +31,9 @@ struct hantro_ctx;
 struct hantro_codec_ops;
 struct hantro_postproc_ops;
 
+#define MAX_MV_BUFFERS	MAX_POSTPROC_BUFFERS
+#define MAX_RFC_BUFFERS	MAX_POSTPROC_BUFFERS
+
 #define HANTRO_JPEG_ENCODER	BIT(0)
 #define HANTRO_ENCODERS		0x0000ffff
 #define HANTRO_MPEG2_DECODER	BIT(16)
@@ -237,6 +240,9 @@ struct hantro_dev {
  * @need_postproc:	Set to true if the bitstream features require to
  *			use the post-processor.
  *
+ * @dec_mv:		motion vectors buffers for the context.
+ * @dec_rfc:		reference frame compression buffers for the context.
+ *
  * @codec_ops:		Set of operations related to codec mode.
  * @postproc:		Post-processing context.
  * @h264_dec:		H.264-decoding context.
@@ -264,6 +270,9 @@ struct hantro_ctx {
 	int jpeg_quality;
 	int bit_depth;
 
+	struct hantro_aux_buf dec_mv[MAX_MV_BUFFERS];
+	struct hantro_aux_buf dec_rfc[MAX_RFC_BUFFERS];
+
 	const struct hantro_codec_ops *codec_ops;
 	struct hantro_postproc_ctx postproc;
 	bool need_postproc;
@@ -334,14 +343,14 @@ struct hantro_vp9_decoded_buffer_info {
 	unsigned short width;
 	unsigned short height;
 	size_t chroma_offset;
-	size_t mv_offset;
+	dma_addr_t mv_addr;
 	u32 bit_depth : 4;
 };
 
 struct hantro_av1_decoded_buffer_info {
 	/* Info needed when the decoded frame serves as a reference frame. */
 	size_t chroma_offset;
-	size_t mv_offset;
+	dma_addr_t mv_addr;
 };
 
 struct hantro_decoded_buffer {
@@ -507,4 +516,8 @@ void hantro_postproc_free(struct hantro_ctx *ctx);
 int hanto_postproc_enum_framesizes(struct hantro_ctx *ctx,
 				   struct v4l2_frmsizeenum *fsize);
 
+dma_addr_t hantro_mv_get_buf_addr(struct hantro_ctx *ctx, int index);
+dma_addr_t hantro_rfc_get_luma_buf_addr(struct hantro_ctx *ctx, int index);
+dma_addr_t hantro_rfc_get_chroma_buf_addr(struct hantro_ctx *ctx, int index);
+
 #endif /* HANTRO_H_ */
drivers/media/platform/verisilicon/hantro_av1.c +0 -7
index 5a51ac877c9c..3a80a7994f67 100644
@@ -222,13 +222,6 @@ size_t hantro_av1_luma_size(struct hantro_ctx *ctx)
 	return ctx->ref_fmt.plane_fmt[0].bytesperline * ctx->ref_fmt.height;
 }
 
-size_t hantro_av1_chroma_size(struct hantro_ctx *ctx)
-{
-	size_t cr_offset = hantro_av1_luma_size(ctx);
-
-	return ALIGN((cr_offset * 3) / 2, 64);
-}
-
 static void hantro_av1_tiles_free(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
drivers/media/platform/verisilicon/hantro_av1.h +13 -1
index 4e2122b95cdd..bc4a0887f8e7 100644
@@ -41,7 +41,6 @@ int hantro_av1_get_order_hint(struct hantro_ctx *ctx, int ref);
 int hantro_av1_frame_ref(struct hantro_ctx *ctx, u64 timestamp);
 void hantro_av1_clean_refs(struct hantro_ctx *ctx);
 size_t hantro_av1_luma_size(struct hantro_ctx *ctx);
-size_t hantro_av1_chroma_size(struct hantro_ctx *ctx);
 void hantro_av1_exit(struct hantro_ctx *ctx);
 int hantro_av1_init(struct hantro_ctx *ctx);
 int hantro_av1_prepare_run(struct hantro_ctx *ctx);
@@ -59,4 +58,17 @@ void hantro_av1_set_prob(struct hantro_ctx *ctx);
 int hantro_av1_get_hardware_mcomp_filt_type(int interpolation_filter);
 int hantro_av1_get_hardware_tx_mode(enum v4l2_av1_tx_mode tx_mode);
 
+static inline unsigned short hantro_av1_num_sbs(unsigned short dimension)
+{
+	return DIV_ROUND_UP(dimension, 64);
+}
+
+static inline size_t
+hantro_av1_mv_size(unsigned int width, unsigned int height)
+{
+	size_t num_sbs = hantro_av1_num_sbs(width) * hantro_av1_num_sbs(height);
+
+	return ALIGN(num_sbs * 384, 16) * 2 + 512;
+}
+
 #endif
drivers/media/platform/verisilicon/hantro_g2.c +0 -36
index 318673b66da8..4ae7df53dcb1 100644
@@ -99,39 +99,3 @@ size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx)
 {
 	return ctx->ref_fmt.plane_fmt[0].bytesperline *	ctx->ref_fmt.height;
 }
-
-size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx)
-{
-	size_t cr_offset = hantro_g2_chroma_offset(ctx);
-
-	return ALIGN((cr_offset * 3) / 2, G2_ALIGN);
-}
-
-static size_t hantro_g2_mv_size(struct hantro_ctx *ctx)
-{
-	const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls;
-	const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;
-	unsigned int pic_width_in_ctbs, pic_height_in_ctbs;
-	unsigned int max_log2_ctb_size;
-
-	max_log2_ctb_size = sps->log2_min_luma_coding_block_size_minus3 + 3 +
-			    sps->log2_diff_max_min_luma_coding_block_size;
-	pic_width_in_ctbs = (sps->pic_width_in_luma_samples +
-			    (1 << max_log2_ctb_size) - 1) >> max_log2_ctb_size;
-	pic_height_in_ctbs = (sps->pic_height_in_luma_samples + (1 << max_log2_ctb_size) - 1)
-			     >> max_log2_ctb_size;
-
-	return pic_width_in_ctbs * pic_height_in_ctbs * (1 << (2 * (max_log2_ctb_size - 4))) * 16;
-}
-
-size_t hantro_g2_luma_compress_offset(struct hantro_ctx *ctx)
-{
-	return hantro_g2_motion_vectors_offset(ctx) +
-	       hantro_g2_mv_size(ctx);
-}
-
-size_t hantro_g2_chroma_compress_offset(struct hantro_ctx *ctx)
-{
-	return hantro_g2_luma_compress_offset(ctx) +
-	       hantro_hevc_luma_compressed_size(ctx->dst_fmt.width, ctx->dst_fmt.height);
-}
drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c +14 -10
index e8c2e83379de..d0af9fb882ba 100644
@@ -383,9 +383,6 @@ static int set_ref(struct hantro_ctx *ctx)
 	struct vb2_v4l2_buffer *vb2_dst;
 	struct hantro_decoded_buffer *dst;
 	size_t cr_offset = hantro_g2_chroma_offset(ctx);
-	size_t mv_offset = hantro_g2_motion_vectors_offset(ctx);
-	size_t compress_luma_offset = hantro_g2_luma_compress_offset(ctx);
-	size_t compress_chroma_offset = hantro_g2_chroma_compress_offset(ctx);
 	u32 max_ref_frames;
 	u16 dpb_longterm_e;
 	static const struct hantro_reg cur_poc[] = {
@@ -453,14 +450,17 @@ static int set_ref(struct hantro_ctx *ctx)
 	dpb_longterm_e = 0;
 	for (i = 0; i < decode_params->num_active_dpb_entries &&
 	     i < (V4L2_HEVC_DPB_ENTRIES_NUM_MAX - 1); i++) {
+		int index = hantro_hevc_get_ref_buf_index(ctx, dpb[i].pic_order_cnt_val);
 		luma_addr = hantro_hevc_get_ref_buf(ctx, dpb[i].pic_order_cnt_val);
 		if (!luma_addr)
 			return -ENOMEM;
 
 		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;
+		mv_addr = hantro_mv_get_buf_addr(ctx, index);
+		if (ctx->hevc_dec.use_compression) {
+			compress_luma_addr = hantro_rfc_get_luma_buf_addr(ctx, index);
+			compress_chroma_addr = hantro_rfc_get_chroma_buf_addr(ctx, index);
+		}
 
 		if (dpb[i].flags & V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE)
 			dpb_longterm_e |= BIT(V4L2_HEVC_DPB_ENTRIES_NUM_MAX - 1 - i);
@@ -478,13 +478,17 @@ static int set_ref(struct hantro_ctx *ctx)
 	if (!luma_addr)
 		return -ENOMEM;
 
-	if (hantro_hevc_add_ref_buf(ctx, decode_params->pic_order_cnt_val, luma_addr))
+	if (hantro_hevc_add_ref_buf(ctx, decode_params->pic_order_cnt_val, luma_addr, vb2_dst))
 		return -EINVAL;
 
 	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;
+	mv_addr = hantro_mv_get_buf_addr(ctx, dst->base.vb.vb2_buf.index);
+	if (ctx->hevc_dec.use_compression) {
+		compress_luma_addr =
+			hantro_rfc_get_luma_buf_addr(ctx, dst->base.vb.vb2_buf.index);
+		compress_chroma_addr =
+			hantro_rfc_get_chroma_buf_addr(ctx, dst->base.vb.vb2_buf.index);
+	}
 
 	hantro_write_addr(vpu, G2_REF_LUMA_ADDR(i), luma_addr);
 	hantro_write_addr(vpu, G2_REF_CHROMA_ADDR(i), chroma_addr);
drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +4 -8
index 56c79e339030..1e96d0fce72a 100644
@@ -129,7 +129,7 @@ static void config_output(struct hantro_ctx *ctx,
 			  struct hantro_decoded_buffer *dst,
 			  const struct v4l2_ctrl_vp9_frame *dec_params)
 {
-	dma_addr_t luma_addr, chroma_addr, mv_addr;
+	dma_addr_t luma_addr, chroma_addr;
 
 	hantro_reg_write(ctx->dev, &g2_out_dis, 0);
 	if (!ctx->dev->variant->legacy_regs)
@@ -142,9 +142,8 @@ static void config_output(struct hantro_ctx *ctx,
 	hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr);
 	dst->vp9.chroma_offset = hantro_g2_chroma_offset(ctx);
 
-	mv_addr = luma_addr + hantro_g2_motion_vectors_offset(ctx);
-	hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr);
-	dst->vp9.mv_offset = hantro_g2_motion_vectors_offset(ctx);
+	dst->vp9.mv_addr = hantro_mv_get_buf_addr(ctx, dst->base.vb.vb2_buf.index);
+	hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, dst->vp9.mv_addr);
 }
 
 struct hantro_vp9_ref_reg {
@@ -215,15 +214,12 @@ static void config_ref_registers(struct hantro_ctx *ctx,
 			.c_base = G2_REF_CHROMA_ADDR(5),
 		},
 	};
-	dma_addr_t mv_addr;
 
 	config_ref(ctx, dst, &ref_regs[0], dec_params, dec_params->last_frame_ts);
 	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 = hantro_get_dec_buf_addr(ctx, &mv_ref->base.vb.vb2_buf) +
-		  mv_ref->vp9.mv_offset;
-	hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr);
+	hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_ref->vp9.mv_addr);
 
 	hantro_reg_write(ctx->dev, &vp9_last_sign_bias,
 			 dec_params->ref_frame_sign_bias & V4L2_VP9_SIGN_BIAS_LAST ? 1 : 0);
drivers/media/platform/verisilicon/hantro_h264.h new file +33 -0
new file mode 100644
index 000000000000..89348203a712
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Hantro H264 codec driver
+ *
+ * Copyright (C) 2026 Collabora Ltd.
+ */
+
+static inline size_t
+hantro_h264_mv_size(unsigned int width, unsigned int height)
+{
+	/*
+	 * A decoded 8-bit 4:2:0 NV12 frame may need memory for up to
+	 * 448 bytes per macroblock with additional 32 bytes on
+	 * multi-core variants.
+	 *
+	 * The H264 decoder needs extra space on the output buffers
+	 * to store motion vectors. This is needed for reference
+	 * frames and only if the format is non-post-processed NV12.
+	 *
+	 * Memory layout is as follow:
+	 *
+	 * +---------------------------+
+	 * | Y-plane   256 bytes x MBs |
+	 * +---------------------------+
+	 * | UV-plane  128 bytes x MBs |
+	 * +---------------------------+
+	 * | MV buffer  64 bytes x MBs |
+	 * +---------------------------+
+	 * | MC sync          32 bytes |
+	 * +---------------------------+
+	 */
+	return 64 * MB_WIDTH(width) * MB_WIDTH(height) + 32;
+}
drivers/media/platform/verisilicon/hantro_hevc.c +27 -8
index 83cd12b0ddd6..eea4d9e6fde0 100644
@@ -44,30 +44,49 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,
 	int i;
 
 	/* Find the reference buffer in already known ones */
-	for (i = 0;  i < NUM_REF_PICTURES; i++) {
+	for (i = 0; i < NUM_REF_PICTURES; i++) {
 		if (hevc_dec->ref_bufs_poc[i] == poc) {
 			hevc_dec->ref_bufs_used |= 1 << i;
 			return hevc_dec->ref_bufs[i].dma;
 		}
 	}
-
 	return 0;
 }
 
-int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx, int poc, dma_addr_t addr)
+int hantro_hevc_get_ref_buf_index(struct hantro_ctx *ctx, s32 poc)
 {
 	struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec;
 	int i;
 
-	/* Add a new reference buffer */
+	/* Find the reference buffer in already known ones */
 	for (i = 0; i < NUM_REF_PICTURES; i++) {
-		if (!(hevc_dec->ref_bufs_used & 1 << i)) {
+		if (hevc_dec->ref_bufs_poc[i] == poc) {
 			hevc_dec->ref_bufs_used |= 1 << i;
-			hevc_dec->ref_bufs_poc[i] = poc;
-			hevc_dec->ref_bufs[i].dma = addr;
-			return 0;
+			return hevc_dec->ref_vb2[i]->vb2_buf.index;
 		}
 	}
+	return 0;
+}
+
+int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx,
+			    int poc,
+			    dma_addr_t addr,
+			    struct vb2_v4l2_buffer *vb2)
+{
+	struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec;
+	int i;
+
+	/* Add a new reference buffer */
+	for (i = 0; i < NUM_REF_PICTURES; i++) {
+		if (hevc_dec->ref_bufs_used & (1 << i))
+			continue;
+
+		hevc_dec->ref_bufs_used |= 1 << i;
+		hevc_dec->ref_bufs_poc[i] = poc;
+		hevc_dec->ref_bufs[i].dma = addr;
+		hevc_dec->ref_vb2[i] = vb2;
+		return 0;
+	}
 
 	return -EINVAL;
 }
drivers/media/platform/verisilicon/hantro_hevc.h new file +16 -0
new file mode 100644
index 000000000000..cfaeb8662473
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Hantro H264 codec driver
+ *
+ * Copyright (C) 2026 Collabora Ltd.
+ */
+
+static inline size_t
+hantro_hevc_mv_size(unsigned int width, unsigned int height, int depth)
+{
+	/*
+	 * A CTB can be 64x64, 32x32 or 16x16.
+	 * Allocated memory for the "worse" case: 16x16
+	 */
+	return DIV_ROUND_UP(width * height * depth / 8, 16);
+}
drivers/media/platform/verisilicon/hantro_hw.h +5 -99

120 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_postproc.c +2 -27
index e94d1ba5ef10..2409353c16e4 100644
@@ -196,36 +196,11 @@ void hantro_postproc_free(struct hantro_ctx *ctx)
 	}
 }
 
-static unsigned int hantro_postproc_buffer_size(struct hantro_ctx *ctx)
-{
-	unsigned int buf_size;
-
-	buf_size = ctx->ref_fmt.plane_fmt[0].sizeimage;
-	if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_H264_SLICE)
-		buf_size += hantro_h264_mv_size(ctx->ref_fmt.width,
-						ctx->ref_fmt.height);
-	else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_VP9_FRAME)
-		buf_size += hantro_vp9_mv_size(ctx->ref_fmt.width,
-					       ctx->ref_fmt.height);
-	else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_HEVC_SLICE) {
-		buf_size += hantro_hevc_mv_size(ctx->ref_fmt.width,
-						ctx->ref_fmt.height);
-		if (ctx->hevc_dec.use_compression)
-			buf_size += hantro_hevc_compressed_size(ctx->ref_fmt.width,
-								ctx->ref_fmt.height);
-	}
-	else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_AV1_FRAME)
-		buf_size += hantro_av1_mv_size(ctx->ref_fmt.width,
-					       ctx->ref_fmt.height);
-
-	return buf_size;
-}
-
 static int hantro_postproc_alloc(struct hantro_ctx *ctx, int index)
 {
 	struct hantro_dev *vpu = ctx->dev;
 	struct hantro_aux_buf *priv = &ctx->postproc.dec_q[index];
-	unsigned int buf_size = hantro_postproc_buffer_size(ctx);
+	unsigned int buf_size = ctx->ref_fmt.plane_fmt[0].sizeimage;
 
 	if (!buf_size)
 		return -EINVAL;
@@ -267,7 +242,7 @@ dma_addr_t
 hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index)
 {
 	struct hantro_aux_buf *priv = &ctx->postproc.dec_q[index];
-	unsigned int buf_size = hantro_postproc_buffer_size(ctx);
+	unsigned int buf_size = ctx->ref_fmt.plane_fmt[0].sizeimage;
 	struct hantro_dev *vpu = ctx->dev;
 	int ret;
 
drivers/media/platform/verisilicon/hantro_v4l2.c +235 -20

284 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_vp9.h +18 -0
index 26b69275f098..fcdad2242f78 100644
@@ -100,3 +100,21 @@ struct symbol_counts {
 
 	u32 count_eobs[4][2][2][6][6];
 };
+
+static inline unsigned short hantro_vp9_num_sbs(unsigned short dimension)
+{
+	return (dimension + 63) / 64;
+}
+
+static inline size_t
+hantro_vp9_mv_size(unsigned int width, unsigned int height)
+{
+	int num_ctbs;
+
+	/*
+	 * There can be up to (CTBs x 64) number of blocks,
+	 * and the motion vector for each block needs 16 bytes.
+	 */
+	num_ctbs = hantro_vp9_num_sbs(width) * hantro_vp9_num_sbs(height);
+	return (num_ctbs * 64) * 16;
+}
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +6 -10
index 990a5e6b5531..2cf4233d6888 100644
@@ -62,7 +62,7 @@ rockchip_vpu981_av1_dec_set_ref(struct hantro_ctx *ctx, int ref, int idx,
 	const struct v4l2_ctrl_av1_frame *frame = ctrls->frame;
 	struct hantro_dev *vpu = ctx->dev;
 	struct hantro_decoded_buffer *dst;
-	dma_addr_t luma_addr, chroma_addr, mv_addr = 0;
+	dma_addr_t luma_addr, chroma_addr = 0;
 	int cur_width = frame->frame_width_minus_1 + 1;
 	int cur_height = frame->frame_height_minus_1 + 1;
 	int scale_width =
@@ -120,11 +120,10 @@ rockchip_vpu981_av1_dec_set_ref(struct hantro_ctx *ctx, int ref, int idx,
 	dst = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
 	luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
 	chroma_addr = luma_addr + dst->av1.chroma_offset;
-	mv_addr = luma_addr + dst->av1.mv_offset;
 
 	hantro_write_addr(vpu, AV1_REFERENCE_Y(ref), luma_addr);
 	hantro_write_addr(vpu, AV1_REFERENCE_CB(ref), chroma_addr);
-	hantro_write_addr(vpu, AV1_REFERENCE_MV(ref), mv_addr);
+	hantro_write_addr(vpu, AV1_REFERENCE_MV(ref), dst->av1.mv_addr);
 
 	return (scale_width != (1 << AV1_REF_SCALE_SHIFT)) ||
 		(scale_height != (1 << AV1_REF_SCALE_SHIFT));
@@ -180,11 +179,10 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
 		if (idx >= 0) {
 			dma_addr_t luma_addr, mv_addr = 0;
 			struct hantro_decoded_buffer *seg;
-			size_t mv_offset = hantro_av1_chroma_size(ctx);
 
 			seg = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
 			luma_addr = hantro_get_dec_buf_addr(ctx, &seg->base.vb.vb2_buf);
-			mv_addr = luma_addr + mv_offset;
+			mv_addr = hantro_mv_get_buf_addr(ctx, seg->base.vb.vb2_buf.index);
 
 			hantro_write_addr(vpu, AV1_SEGMENTATION, mv_addr);
 			hantro_reg_write(vpu, &av1_use_temporal3_mvs, 1);
@@ -1345,22 +1343,20 @@ rockchip_vpu981_av1_dec_set_output_buffer(struct hantro_ctx *ctx)
 	struct hantro_dev *vpu = ctx->dev;
 	struct hantro_decoded_buffer *dst;
 	struct vb2_v4l2_buffer *vb2_dst;
-	dma_addr_t luma_addr, chroma_addr, mv_addr = 0;
+	dma_addr_t luma_addr, chroma_addr = 0;
 	size_t cr_offset = hantro_av1_luma_size(ctx);
-	size_t mv_offset = hantro_av1_chroma_size(ctx);
 
 	vb2_dst = av1_dec->frame_refs[av1_dec->current_frame_index].vb2_ref;
 	dst = vb2_to_hantro_decoded_buf(&vb2_dst->vb2_buf);
 	luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
 	chroma_addr = luma_addr + cr_offset;
-	mv_addr = luma_addr + mv_offset;
 
 	dst->av1.chroma_offset = cr_offset;
-	dst->av1.mv_offset = mv_offset;
+	dst->av1.mv_addr = hantro_mv_get_buf_addr(ctx, dst->base.vb.vb2_buf.index);
 
 	hantro_write_addr(vpu, AV1_TILE_OUT_LU, luma_addr);
 	hantro_write_addr(vpu, AV1_TILE_OUT_CH, chroma_addr);
-	hantro_write_addr(vpu, AV1_TILE_OUT_MV, mv_addr);
+	hantro_write_addr(vpu, AV1_TILE_OUT_MV, dst->av1.mv_addr);
 }
 
 int rockchip_vpu981_av1_dec_run(struct hantro_ctx *ctx)
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH v3 1/2] media: verisilicon: Simplify motion vectors and rfc buffers allocation

Quoted 5 lines · Benjamin Gaignard

Until now we reserve the space needed for motion vectors and reference frame compression at the end of the frame buffer. Disentanglement mv and rfc from frame buffers by allocating distinct buffers for each purpose.
That simplify the code by removing lot of offset computation.

Can you try split to more small and straight forward patches, for example

for example create patch just move hantro_h264_mv_size() to header file,

...

Quoted 4 lines

+++ b/drivers/media/platform/verisilicon/hantro_hevc.c

drivers/media/platform/verisilicon/hantro_hevc.c +0 -0
@@ -44,30 +44,49 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,
 	int i;
 

drivers/media/platform/verisilicon/hantro_hevc.c dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx, · line 53

Quoted 10 lines
drivers/media/platform/verisilicon/hantro_hevc.c +1 -2
 	/* Find the reference buffer in already known ones */
-	for (i = 0;  i < NUM_REF_PICTURES; i++) {
+	for (i = 0; i < NUM_REF_PICTURES; i++) {
 		if (hevc_dec->ref_bufs_poc[i] == poc) {
 			hevc_dec->ref_bufs_used |= 1 << i;
 			return hevc_dec->ref_bufs[i].dma;
 		}
 	}
-
 	return 0;

Move this code style change to new patches.

Frank

maintainer
#3 lore raw

Re: [PATCH v3 1/2] media: verisilicon: Simplify motion vectors and rfc buffers allocation

Hi Benjamin,

Le vendredi 17 avril 2026 à 06:54 -0400, Frank Li a écrit :

Quoted 10 lines · Benjamin Gaignard
Quoted 5 lines

Until now we reserve the space needed for motion vectors and reference frame compression at the end of the frame buffer. Disentanglement mv and rfc from frame buffers by allocating distinct buffers for each purpose.
That simplify the code by removing lot of offset computation.

Can you try split to more small and straight forward patches, for example

for example create patch just move hantro_h264_mv_size() to header file,

Marking this has Change Requested, as I completely agree with Frank that a split of this giant will help proper review.

Nicolas

Quoted 20 lines

...

Quoted 4 lines

+++ b/drivers/media/platform/verisilicon/hantro_hevc.c

drivers/media/platform/verisilicon/hantro_hevc.c +0 -0
@@ -44,30 +44,49 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,
  	int i;
 

drivers/media/platform/verisilicon/hantro_hevc.c dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx, · line 53

Quoted 10 lines
drivers/media/platform/verisilicon/hantro_hevc.c +1 -2
  	/* Find the reference buffer in already known ones */
-	for (i = 0;  i < NUM_REF_PICTURES; i++) {
+	for (i = 0; i < NUM_REF_PICTURES; i++) {
  		if (hevc_dec->ref_bufs_poc[i] == poc) {
  			hevc_dec->ref_bufs_used |= 1 << i;
  			return hevc_dec->ref_bufs[i].dma;
  		}
  	}
-
  	return 0;

Move this code style change to new patches.

Frank

author maintainer
#4 lore raw

Re: [PATCH v3 1/2] media: verisilicon: Simplify motion vectors and rfc buffers allocation

Le 29/04/2026 à 20:11, Nicolas Dufresne a écrit :

Quoted 9 lines

Hi Benjamin,

Le vendredi 17 avril 2026 à 06:54 -0400, Frank Li a écrit :

Quoted 6 lines · Benjamin Gaignard
Quoted 5 lines

Until now we reserve the space needed for motion vectors and reference frame compression at the end of the frame buffer. Disentanglement mv and rfc from frame buffers by allocating distinct buffers for each purpose.
That simplify the code by removing lot of offset computation.

Quoted 5 lines
Quoted 3 lines

Can you try split to more small and straight forward patches, for example

for example create patch just move hantro_h264_mv_size() to header file,

Marking this has Change Requested, as I completely agree with Frank that a split of this giant will help proper review.

I will cut the series in two: one clean up series (which will come after av1 lib series been merged) and buffer simplification patch after that.

Benjamin

Quoted 21 lines

Nicolas

Quoted 18 lines

...

Quoted 4 lines

+++ b/drivers/media/platform/verisilicon/hantro_hevc.c

drivers/media/platform/verisilicon/hantro_hevc.c +0 -0
@@ -44,30 +44,49 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,
  	int i;
 

drivers/media/platform/verisilicon/hantro_hevc.c dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx, · line 53

Quoted 10 lines
drivers/media/platform/verisilicon/hantro_hevc.c +1 -2
  	/* Find the reference buffer in already known ones */
-	for (i = 0;  i < NUM_REF_PICTURES; i++) {
+	for (i = 0; i < NUM_REF_PICTURES; i++) {
  		if (hevc_dec->ref_bufs_poc[i] == poc) {
  			hevc_dec->ref_bufs_used |= 1 << i;
  			return hevc_dec->ref_bufs[i].dma;
  		}
  	}
-
  	return 0;

Move this code style change to new patches.

Frank

author maintainer
#5 lore raw

PATCH v3 2/2 media: verisilicon: Clean up messy include

In reply to Benjamin Gaignard

Over time all codecs specific functions and structures have been added in hantro_hw.h file.
Moving them into dedicated files clean up hantro_hw.h where only hardware specific functions should remain and, while at it, reorder them.

---
 drivers/media/platform/verisilicon/hantro.h   |  14 +-
 .../media/platform/verisilicon/hantro_av1.h   |  86 +++++
 .../platform/verisilicon/hantro_g1_h264_dec.c |   1 +
 .../verisilicon/hantro_g1_mpeg2_dec.c         |   2 +-
 .../platform/verisilicon/hantro_g1_vp8_dec.c  |   2 +-
 .../platform/verisilicon/hantro_g2_hevc_dec.c |   2 +-
 .../media/platform/verisilicon/hantro_h264.c  |   2 +-
 .../media/platform/verisilicon/hantro_h264.h  |  65 ++++
 .../media/platform/verisilicon/hantro_hevc.c  |   2 +-
 .../media/platform/verisilicon/hantro_hevc.h  |  66 ++++
 .../media/platform/verisilicon/hantro_hw.h    | 352 +-----------------
 .../media/platform/verisilicon/hantro_mpeg2.c |   1 +
 .../media/platform/verisilicon/hantro_mpeg2.h |  27 ++
 .../media/platform/verisilicon/hantro_v4l2.c  |   7 +-
 .../media/platform/verisilicon/hantro_vp8.c   |   1 +
 .../media/platform/verisilicon/hantro_vp8.h   |  29 ++
 .../media/platform/verisilicon/hantro_vp9.h   |  86 +++++
 .../media/platform/verisilicon/imx8m_vpu_hw.c |   5 +
 .../verisilicon/rockchip_vpu2_hw_h264_dec.c   |   2 +-
 .../verisilicon/rockchip_vpu2_hw_mpeg2_dec.c  |   2 +-
 .../verisilicon/rockchip_vpu2_hw_vp8_dec.c    |   2 +-
 .../platform/verisilicon/rockchip_vpu_hw.c    |   3 +
 .../platform/verisilicon/stm32mp25_vpu_hw.c   |   2 +
 .../media/platform/verisilicon/sunxi_vpu_hw.c |   1 +
 24 files changed, 413 insertions(+), 349 deletions(-)
 create mode 100644 drivers/media/platform/verisilicon/hantro_mpeg2.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_vp8.h
drivers/media/platform/verisilicon/hantro.h +13 -1
index c4ceb9c99016..91e04df6463e 100644
@@ -25,7 +25,12 @@
 #include <media/videobuf2-core.h>
 #include <media/videobuf2-dma-contig.h>
 
-#include "hantro_hw.h"
+#include "hantro_av1.h"
+#include "hantro_h264.h"
+#include "hantro_hevc.h"
+#include "hantro_mpeg2.h"
+#include "hantro_vp8.h"
+#include "hantro_vp9.h"
 
 struct hantro_ctx;
 struct hantro_codec_ops;
@@ -520,4 +525,11 @@ dma_addr_t hantro_mv_get_buf_addr(struct hantro_ctx *ctx, int index);
 dma_addr_t hantro_rfc_get_luma_buf_addr(struct hantro_ctx *ctx, int index);
 dma_addr_t hantro_rfc_get_chroma_buf_addr(struct hantro_ctx *ctx, int index);
 
+void hantro_watchdog(struct work_struct *work);
+void hantro_run(struct hantro_ctx *ctx);
+void hantro_irq_done(struct hantro_dev *vpu,
+		     enum vb2_buffer_state result);
+void hantro_start_prepare_run(struct hantro_ctx *ctx);
+void hantro_end_prepare_run(struct hantro_ctx *ctx);
+
 #endif /* HANTRO_H_ */
drivers/media/platform/verisilicon/hantro_av1.h +86 -0

98 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_g1_h264_dec.c +1 -0
index ad5c1a6634f5..a1da2adda5eb 100644
@@ -16,6 +16,7 @@
 #include <media/v4l2-mem2mem.h>
 
 #include "hantro_g1_regs.h"
+#include "hantro_h264.h"
 #include "hantro_hw.h"
 #include "hantro_v4l2.h"
 
drivers/media/platform/verisilicon/hantro_g1_mpeg2_dec.c +1 -1
index e0d6bd0a6e44..7c2f0697295d 100644
@@ -9,8 +9,8 @@
 #include <linux/bitfield.h>
 #include <media/v4l2-mem2mem.h>
 #include "hantro.h"
-#include "hantro_hw.h"
 #include "hantro_g1_regs.h"
+#include "hantro_mpeg2.h"
 
 #define G1_SWREG(nr)			((nr) * 4)
 
drivers/media/platform/verisilicon/hantro_g1_vp8_dec.c +1 -1
index 851eb67f19f5..e155d9868b32 100644
@@ -11,9 +11,9 @@
 
 #include <media/v4l2-mem2mem.h>
 
-#include "hantro_hw.h"
 #include "hantro.h"
 #include "hantro_g1_regs.h"
+#include "hantro_vp8.h"
 
 /* DCT partition base address regs */
 static const struct hantro_reg vp8_dec_dct_base[8] = {
drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c +1 -1
index d0af9fb882ba..39f271e570f7 100644
@@ -5,7 +5,7 @@
  * Copyright (C) 2020 Safran Passenger Innovations LLC
  */
 
-#include "hantro_hw.h"
+#include "hantro_hevc.h"
 #include "hantro_g2_regs.h"
 
 static void prepare_tile_info_buffer(struct hantro_ctx *ctx)
drivers/media/platform/verisilicon/hantro_h264.c +1 -1
index 2414782f1eb6..5e684389f04f 100644
@@ -15,7 +15,7 @@
 #include <media/v4l2-mem2mem.h>
 
 #include "hantro.h"
-#include "hantro_hw.h"
+#include "hantro_h264.h"
 
 /* Size with u32 units. */
 #define CABAC_INIT_BUFFER_SIZE		(460 * 2)
drivers/media/platform/verisilicon/hantro_h264.h +65 -0

74 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_hevc.c +1 -1
index eea4d9e6fde0..04a694cd19f9 100644
@@ -9,7 +9,7 @@
 #include <media/v4l2-mem2mem.h>
 
 #include "hantro.h"
-#include "hantro_hw.h"
+#include "hantro_hevc.h"
 
 #define VERT_FILTER_RAM_SIZE 8 /* bytes per pixel row */
 /*
drivers/media/platform/verisilicon/hantro_hevc.h +66 -0

75 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_hw.h +13 -339

388 lines not on this page · raw message

drivers/media/platform/verisilicon/hantro_mpeg2.c +1 -0
index 04e545eb0a83..e6ad39a2d18c 100644
@@ -6,6 +6,7 @@
  */
 
 #include "hantro.h"
+#include "hantro_mpeg2.h"
 
 static const u8 zigzag[64] = {
 	0,   1,  8, 16,  9,  2,  3, 10,
drivers/media/platform/verisilicon/hantro_mpeg2.h new file +27 -0
new file mode 100644
index 000000000000..df86f5be3152
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Hantro MPEG2 codec driver
+ *
+ * Copyright (C) 2026 Collabora Ltd.
+ */
+
+#ifndef _HANTRO_MPEG2_H_
+#define _HANTRO_MPEG2_H_
+
+#include "hantro_hw.h"
+
+/**
+ * struct hantro_mpeg2_dec_hw_ctx
+ *
+ * @qtable:		Quantization table
+ */
+struct hantro_mpeg2_dec_hw_ctx {
+	struct hantro_aux_buf qtable;
+};
+
+void hantro_mpeg2_dec_copy_qtable(u8 *qtable,
+				  const struct v4l2_ctrl_mpeg2_quantisation *ctrl);
+int hantro_mpeg2_dec_init(struct hantro_ctx *ctx);
+void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx);
+
+#endif
drivers/media/platform/verisilicon/hantro_v4l2.c +6 -1
index bbc1e9e2840e..fdb15a8a85f2 100644
@@ -26,13 +26,18 @@
 
 #include "hantro.h"
 #include "hantro_av1.h"
-#include "hantro_hw.h"
 #include "hantro_h264.h"
 #include "hantro_hevc.h"
 #include "hantro_v4l2.h"
 #include "hantro_vp9.h"
 
 #define  HANTRO_DEFAULT_BIT_DEPTH 8
+#define CBS_SIZE	16	/* compression table size in bytes */
+#define CBS_LUMA	8	/* luminance CBS is composed of 1 8x8 coded block */
+#define CBS_CHROMA_W	(8 * 2)	/* chrominance CBS is composed of two 8x4 coded
+				 * blocks, with Cb CB first then Cr CB following
+				 */
+#define CBS_CHROMA_H	4
 
 static int hantro_set_fmt_out(struct hantro_ctx *ctx,
 			      struct v4l2_pix_format_mplane *pix_mp,
drivers/media/platform/verisilicon/hantro_vp8.c +1 -0
index 381bc1d3bfda..e03ab933c9a3 100644
@@ -6,6 +6,7 @@
  */
 
 #include "hantro.h"
+#include "hantro_vp8.h"
 
 /*
  * probs table with packed
drivers/media/platform/verisilicon/hantro_vp8.h new file +29 -0
new file mode 100644
index 000000000000..0307d78380d2
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Hantro VP8 codec driver
+ *
+ * Copyright (C) 2026 Collabora Ltd.
+ */
+#ifndef _HANTRO_VP8_H_
+#define _HANTRO_VP8_H_
+
+#include "hantro_hw.h"
+
+extern const u32 hantro_vp8_dec_mc_filter[8][6];
+
+/**
+ * struct hantro_vp8_dec_hw_ctx
+ *
+ * @segment_map:	Segment map buffer.
+ * @prob_tbl:		Probability table buffer.
+ */
+struct hantro_vp8_dec_hw_ctx {
+	struct hantro_aux_buf segment_map;
+	struct hantro_aux_buf prob_tbl;
+};
+
+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,
+			    const struct v4l2_ctrl_vp8_frame *hdr);
+#endif
drivers/media/platform/verisilicon/hantro_vp9.h +86 -0

101 lines not on this page · raw message

drivers/media/platform/verisilicon/imx8m_vpu_hw.c +5 -0
index fa4224de4b99..406a755634bc 100644
@@ -12,6 +12,11 @@
 #include "hantro_jpeg.h"
 #include "hantro_g1_regs.h"
 #include "hantro_g2_regs.h"
+#include "hantro_h264.h"
+#include "hantro_hevc.h"
+#include "hantro_mpeg2.h"
+#include "hantro_vp8.h"
+#include "hantro_vp9.h"
 
 #define CTRL_SOFT_RESET		0x00
 #define RESET_G1		BIT(1)
drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c +1 -1
index 6da87f5184bc..0d86490a3a6e 100644
@@ -15,7 +15,7 @@
 
 #include <media/v4l2-mem2mem.h>
 
-#include "hantro_hw.h"
+#include "hantro_h264.h"
 #include "hantro_v4l2.h"
 
 #define VDPU_SWREG(nr)			((nr) * 4)
drivers/media/platform/verisilicon/rockchip_vpu2_hw_mpeg2_dec.c +1 -1
index 50a3a3eeaa00..355c4d7697a3 100644
@@ -9,7 +9,7 @@
 #include <linux/bitfield.h>
 #include <media/v4l2-mem2mem.h>
 #include "hantro.h"
-#include "hantro_hw.h"
+#include "hantro_mpeg2.h"
 
 #define VDPU_SWREG(nr)			((nr) * 4)
 
drivers/media/platform/verisilicon/rockchip_vpu2_hw_vp8_dec.c +1 -1
index d079075448c9..819967de8e96 100644
@@ -14,9 +14,9 @@
 
 #include <media/v4l2-mem2mem.h>
 
-#include "hantro_hw.h"
 #include "hantro.h"
 #include "hantro_g1_regs.h"
+#include "hantro_vp8.h"
 
 #define VDPU_REG_DEC_CTRL0			0x0c8
 #define VDPU_REG_STREAM_LEN			0x0cc
drivers/media/platform/verisilicon/rockchip_vpu_hw.c +3 -0
index f50a3e38097e..42176b0fd83c 100644
@@ -13,6 +13,9 @@
 #include "hantro_jpeg.h"
 #include "hantro_g1_regs.h"
 #include "hantro_h1_regs.h"
+#include "hantro_h264.h"
+#include "hantro_mpeg2.h"
+#include "hantro_vp8.h"
 #include "rockchip_vpu2_regs.h"
 #include "rockchip_vpu981_regs.h"
 
drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c +2 -0
index 833821120b20..1d317942daa5 100644
@@ -11,6 +11,8 @@
 #include "hantro.h"
 #include "hantro_jpeg.h"
 #include "hantro_h1_regs.h"
+#include "hantro_h264.h"
+#include "hantro_vp8.h"
 
 /*
  * Supported formats.
drivers/media/platform/verisilicon/sunxi_vpu_hw.c +1 -0
index 02ce8b064a8f..2f95f9a681ee 100644
@@ -8,6 +8,7 @@
 #include <linux/clk.h>
 
 #include "hantro.h"
+#include "hantro_vp9.h"
 
 static const struct hantro_fmt sunxi_vpu_postproc_fmts[] = {
 	{
Signature · 1 line
2.43.0
author maintainer
#6 lore raw
In reply to Benjamin Gaignard

Le 15/04/2026 à 16:04, Benjamin Gaignard a écrit :

Quoted 3 lines

Simplify motion vectors and reference allocation with common helpers. Since it requires to move some of codecs specific functions and structure in codecs header files add a patch to finish the clean up.

I forgot to mention that this series depends on
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Quoted 40 lines

Benjamin Gaignard (2):
media: verisilicon: Simplify motion vectors and rfc buffers allocation
media: verisilicon: Clean up messy include

  drivers/media/platform/verisilicon/hantro.h   |  31 +-
  .../media/platform/verisilicon/hantro_av1.c   |   7 -
  .../media/platform/verisilicon/hantro_av1.h   | 100 +++-
  .../platform/verisilicon/hantro_g1_h264_dec.c |   1 +
  .../verisilicon/hantro_g1_mpeg2_dec.c         |   2 +-
  .../platform/verisilicon/hantro_g1_vp8_dec.c  |   2 +-
  .../media/platform/verisilicon/hantro_g2.c    |  36 --
  .../platform/verisilicon/hantro_g2_hevc_dec.c |  26 +-
  .../platform/verisilicon/hantro_g2_vp9_dec.c  |  12 +-
  .../media/platform/verisilicon/hantro_h264.c  |   2 +-
  .../media/platform/verisilicon/hantro_h264.h  |  98 ++++
  .../media/platform/verisilicon/hantro_hevc.c  |  37 +-
  .../media/platform/verisilicon/hantro_hevc.h  |  82 ++++
  .../media/platform/verisilicon/hantro_hw.h    | 446 +-----------------
  .../media/platform/verisilicon/hantro_mpeg2.c |   1 +
  .../media/platform/verisilicon/hantro_mpeg2.h |  27 ++
  .../platform/verisilicon/hantro_postproc.c    |  29 +-
  .../media/platform/verisilicon/hantro_v4l2.c  | 262 +++++++++-
  .../media/platform/verisilicon/hantro_vp8.c   |   1 +
  .../media/platform/verisilicon/hantro_vp8.h   |  29 ++
  .../media/platform/verisilicon/hantro_vp9.h   | 104 ++++
  .../media/platform/verisilicon/imx8m_vpu_hw.c |   5 +
  .../verisilicon/rockchip_vpu2_hw_h264_dec.c   |   2 +-
  .../verisilicon/rockchip_vpu2_hw_mpeg2_dec.c  |   2 +-
  .../verisilicon/rockchip_vpu2_hw_vp8_dec.c    |   2 +-
  .../verisilicon/rockchip_vpu981_hw_av1_dec.c  |  16 +-
  .../platform/verisilicon/rockchip_vpu_hw.c    |   3 +
  .../platform/verisilicon/stm32mp25_vpu_hw.c   |   2 +
  .../media/platform/verisilicon/sunxi_vpu_hw.c |   1 +
  29 files changed, 796 insertions(+), 572 deletions(-)

create mode 100644 drivers/media/platform/verisilicon/hantro_h264.h create mode 100644 drivers/media/platform/verisilicon/hantro_hevc.h create mode 100644 drivers/media/platform/verisilicon/hantro_mpeg2.h create mode 100644 drivers/media/platform/verisilicon/hantro_vp8.h

maintainer
#7 lore raw
In reply to Benjamin Gaignard
Quoted 4 lines · Benjamin Gaignard

Simplify motion vectors and reference allocation with common helpers. Since it requires to move some of codecs specific functions and structure in codecs header files add a patch to finish the clean up.

Already V3:
where the change log?

Frank

Quoted 42 lines

Benjamin Gaignard (2):
media: verisilicon: Simplify motion vectors and rfc buffers allocation
media: verisilicon: Clean up messy include

 drivers/media/platform/verisilicon/hantro.h   |  31 +-
 .../media/platform/verisilicon/hantro_av1.c   |   7 -
 .../media/platform/verisilicon/hantro_av1.h   | 100 +++-
 .../platform/verisilicon/hantro_g1_h264_dec.c |   1 +
 .../verisilicon/hantro_g1_mpeg2_dec.c         |   2 +-
 .../platform/verisilicon/hantro_g1_vp8_dec.c  |   2 +-
 .../media/platform/verisilicon/hantro_g2.c    |  36 --
 .../platform/verisilicon/hantro_g2_hevc_dec.c |  26 +-
 .../platform/verisilicon/hantro_g2_vp9_dec.c  |  12 +-
 .../media/platform/verisilicon/hantro_h264.c  |   2 +-
 .../media/platform/verisilicon/hantro_h264.h  |  98 ++++
 .../media/platform/verisilicon/hantro_hevc.c  |  37 +-
 .../media/platform/verisilicon/hantro_hevc.h  |  82 ++++
 .../media/platform/verisilicon/hantro_hw.h    | 446 +-----------------
 .../media/platform/verisilicon/hantro_mpeg2.c |   1 +
 .../media/platform/verisilicon/hantro_mpeg2.h |  27 ++
 .../platform/verisilicon/hantro_postproc.c    |  29 +-
 .../media/platform/verisilicon/hantro_v4l2.c  | 262 +++++++++-
 .../media/platform/verisilicon/hantro_vp8.c   |   1 +
 .../media/platform/verisilicon/hantro_vp8.h   |  29 ++
 .../media/platform/verisilicon/hantro_vp9.h   | 104 ++++
 .../media/platform/verisilicon/imx8m_vpu_hw.c |   5 +
 .../verisilicon/rockchip_vpu2_hw_h264_dec.c   |   2 +-
 .../verisilicon/rockchip_vpu2_hw_mpeg2_dec.c  |   2 +-
 .../verisilicon/rockchip_vpu2_hw_vp8_dec.c    |   2 +-
 .../verisilicon/rockchip_vpu981_hw_av1_dec.c  |  16 +-
 .../platform/verisilicon/rockchip_vpu_hw.c    |   3 +
 .../platform/verisilicon/stm32mp25_vpu_hw.c   |   2 +
 .../media/platform/verisilicon/sunxi_vpu_hw.c |   1 +
 29 files changed, 796 insertions(+), 572 deletions(-)
 create mode 100644 drivers/media/platform/verisilicon/hantro_h264.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_hevc.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_mpeg2.h
 create mode 100644 drivers/media/platform/verisilicon/hantro_vp8.h

--
2.43.0