[PATCH v1 1/2] media: verisilicon: Get ride of hantro_av1_decoded_buffer_info structure
Benjamin Gaignard
benjamin.gaignard at collabora.com
Tue Dec 1 08:54:41 PST 2026
Remove hantro_av1_decoded_buffer_info structure to simplify driver code.
Only compute one luma, chroma and motion vectors addresses to avoid code
duplication.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard at collabora.com>
---
drivers/media/platform/verisilicon/hantro.h | 11 ++----
.../verisilicon/rockchip_vpu981_hw_av1_dec.c | 34 ++++++-------------
2 files changed, 13 insertions(+), 32 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 1efa032506e1..bf99187ba7c6 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -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;
};
};
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
index f143df99cdb5..aea67c881ccf 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
@@ -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)
--
2.53.0
More information about the Linux-rockchip
mailing list