Skip to contentSkip to conversation

verisilicon: Get ride of useless structures

PATCH New Benjamin Gaignard 1 participant 3 messages Dec 1

Subsystems (3)
lore
Share & tools
lore

Benjamin Gaignard

author maintainer
#0 lore raw

cover verisilicon: Get ride of useless structures

Some fields are duplicated into multiple structures, move them into a common structure and remove structures which become useless.

Benjamin Gaignard (2):
media: verisilicon: Get ride of hantro_av1_decoded_buffer_info
structure
media: verisilicon: Get ride of hantro_vp9_decoded_buffer_info
structure

 drivers/media/platform/verisilicon/hantro.h   | 26 ++------
 .../platform/verisilicon/hantro_g2_vp9_dec.c  | 63 ++++++++-----------
 .../verisilicon/rockchip_vpu981_hw_av1_dec.c  | 34 +++-------
 3 files changed, 42 insertions(+), 81 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/2 media: verisilicon: Get ride of hantro_av1_decoded_buffer_info structure

Remove hantro_av1_decoded_buffer_info structure to simplify driver code. Only compute one luma, chroma and motion vectors addresses to avoid code duplication.

---
 drivers/media/platform/verisilicon/hantro.h   | 11 ++----
 .../verisilicon/rockchip_vpu981_hw_av1_dec.c  | 34 ++++++-------------
 2 files changed, 13 insertions(+), 32 deletions(-)
drivers/media/platform/verisilicon/hantro.h +3 -8
index 1efa032506e1..bf99187ba7c6 100644
@@ -332,19 +332,14 @@ struct hantro_vp9_decoded_buffer_info {
 	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;
-};
-
 struct hantro_decoded_buffer {
 	/* Must be the first field in this struct. */
 	struct v4l2_m2m_buffer base;
-
+	dma_addr_t luma_addr;
+	dma_addr_t chroma_addr;
+	dma_addr_t mv_addr;
 	union {
 		struct hantro_vp9_decoded_buffer_info vp9;
-		struct hantro_av1_decoded_buffer_info av1;
 	};
 };
 
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +10 -24
index f143df99cdb5..aea67c881ccf 100644
@@ -74,7 +74,6 @@ 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;
 	int cur_width = frame->frame_width_minus_1 + 1;
 	int cur_height = frame->frame_height_minus_1 + 1;
 	int scale_width =
@@ -130,13 +129,9 @@ 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_Y(ref), dst->luma_addr);
+	hantro_write_addr(vpu, AV1_REFERENCE_CB(ref), dst->chroma_addr);
+	hantro_write_addr(vpu, AV1_REFERENCE_MV(ref), dst->mv_addr);
 
 	return (scale_width != (1 << AV1_REF_SCALE_SHIFT)) ||
 		(scale_height != (1 << AV1_REF_SCALE_SHIFT));
@@ -190,15 +185,10 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
 		int idx = hantro_av1_get_frame_index(ctx, frame->primary_ref_frame);
 
 		if (idx != AV1_INVALID_IDX) {
-			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;
-
-			hantro_write_addr(vpu, AV1_SEGMENTATION, mv_addr);
+			hantro_write_addr(vpu, AV1_SEGMENTATION, seg->mv_addr);
 			hantro_reg_write(vpu, &av1_use_temporal3_mvs, 1);
 		}
 	}
@@ -1355,22 +1345,18 @@ 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;
 	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->luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
+	dst->chroma_addr = dst->luma_addr + cr_offset;
+	dst->mv_addr = dst->luma_addr + mv_offset;
 
-	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_LU, dst->luma_addr);
+	hantro_write_addr(vpu, AV1_TILE_OUT_CH, dst->chroma_addr);
+	hantro_write_addr(vpu, AV1_TILE_OUT_MV, dst->mv_addr);
 }
 
 int rockchip_vpu981_av1_dec_run(struct hantro_ctx *ctx)
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/2 media: verisilicon: Get ride of hantro_vp9_decoded_buffer_info structure

In reply to Benjamin Gaignard

Remove hantro_vp9_decoded_buffer_info structure to simplify driver code. Only compute once luma, chroma and motion vectors buffer addresses.

---
 drivers/media/platform/verisilicon/hantro.h   | 15 +----
 .../platform/verisilicon/hantro_g2_vp9_dec.c  | 63 ++++++++-----------
 2 files changed, 29 insertions(+), 49 deletions(-)
drivers/media/platform/verisilicon/hantro.h +3 -12
index bf99187ba7c6..08c85053cebe 100644
@@ -323,24 +323,15 @@ struct hantro_postproc_regs {
 	struct hantro_reg input_height_ext;
 };
 
-struct hantro_vp9_decoded_buffer_info {
-	/* Info needed when the decoded frame serves as a reference frame. */
-	unsigned short width;
-	unsigned short height;
-	size_t chroma_offset;
-	size_t mv_offset;
-	u32 bit_depth : 4;
-};
-
 struct hantro_decoded_buffer {
 	/* Must be the first field in this struct. */
 	struct v4l2_m2m_buffer base;
+	unsigned short width;
+	unsigned short height;
 	dma_addr_t luma_addr;
 	dma_addr_t chroma_addr;
 	dma_addr_t mv_addr;
-	union {
-		struct hantro_vp9_decoded_buffer_info vp9;
-	};
+	int bit_depth;
 };
 
 /* Logging helpers */
drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +26 -37

130 lines not on this page · raw message

Signature · 1 line
2.53.0