Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
To: nicolas.dufresne@collabora.com, p.zabel@pengutronix.de,
	mchehab@kernel.org, heiko@sntech.de
Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>
Subject: [PATCH v1 1/2] media: verisilicon: Get ride of hantro_av1_decoded_buffer_info structure
Date: Tue,  1 Dec 2026 17:54:41 +0100	[thread overview]
Message-ID: <20261201165442.235578-2-benjamin.gaignard@collabora.com> (raw)
In-Reply-To: <20261201165442.235578-1-benjamin.gaignard@collabora.com>

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@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



       reply	other threads:[~2026-12-01 16:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261201165442.235578-1-benjamin.gaignard@collabora.com>
2026-12-01 16:54 ` Benjamin Gaignard [this message]
2026-12-01 16:54 ` [PATCH v1 2/2] media: verisilicon: Get ride of hantro_vp9_decoded_buffer_info structure Benjamin Gaignard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201165442.235578-2-benjamin.gaignard@collabora.com \
    --to=benjamin.gaignard@collabora.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox