[PATCH v4 3/6] media: iris: add iris4 specific H265 line buffer calculation
From: Vikash Garodia
Date: Thu Oct 01 2026 - 11:28:54 EST
The H265 decoder line buffer size calculation for iris4 (VPU4) was
previously reusing the iris3 formula. While this works for most
resolutions, certain configurations require a larger buffer size on
iris4, causing firmware errors during decode. This resolves firmware
failures seen with specific test vectors on kaanapali (iris4), and fixes
the following failing fluster tests
- PICSIZE_C_Bossen_1
- WPP_E_ericsson_MAIN_2
10bit tests
- DBLK_A_MAIN10_VIXS_4
- INITQP_B_Main10_Sony_1
- WP_A_MAIN10_Toshiba_3
- WP_MAIN10_B_Toshiba_3
- WPP_A_ericsson_MAIN10_2
- WPP_B_ericsson_MAIN10_2
- WPP_C_ericsson_MAIN10_2
- WPP_E_ericsson_MAIN10_2
- WPP_F_ericsson_MAIN10_2
Co-developed-by: Vishnu Reddy <busanna.reddy@xxxxxxxxxxxxxxxx>
Signed-off-by: Vishnu Reddy <busanna.reddy@xxxxxxxxxxxxxxxx>
Signed-off-by: Vikash Garodia <vikash.garodia@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 59 +++++++++++++++++++++-
drivers/media/platform/qcom/iris/iris_vpu_buffer.h | 16 ++++++
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
index faebb54728660cc621f8822dabf2e44ce8c55c58..a99b8030e3dd052da1b7f70b9701f88c8ae50e74 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
+++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
@@ -1814,6 +1814,63 @@ static u32 hfi_vpu4x_buffer_line_vp9d(u32 frame_width, u32 frame_height, u32 _yu
return lb_size + dpb_obp_size;
}
+static u32 hfi_vpu4x_buffer_line_h265d(u32 frame_width, u32 frame_height, bool is_opb,
+ u32 num_vpp_pipes)
+{
+ u32 num_lcu_per_pipe, se_left_lb, vsp_left_lb, top_lb, qp_size;
+ u32 fe_left_lb = 0, dpb_obp = 0, lcu_size = LCU_SIZE_16;
+ int i;
+
+ for (i = 0; i < num_vpp_pipes; i++) {
+ num_lcu_per_pipe = (DIV_ROUND_UP(frame_height, lcu_size) / num_vpp_pipes);
+ if (i == 0)
+ num_lcu_per_pipe += (DIV_ROUND_UP(frame_height, lcu_size) % num_vpp_pipes);
+
+ fe_left_lb += DMA_ALIGNMENT * FE_LFT_CTRL_BYTES_PER_PACKETS * num_lcu_per_pipe *
+ FE_LFT_CTRL_LINE_NUMBERS;
+ fe_left_lb += DMA_ALIGNMENT * FE_LFT_DB_LUMA_CHROMA_BYTES_PER_PACKETS *
+ num_lcu_per_pipe * FE_LFT_DB_DATA_LINE_NUMBERS;
+ fe_left_lb += DMA_ALIGNMENT * FE_LFT_SAO_LUMA_BYTES_PER_PACKETS *
+ num_lcu_per_pipe;
+ fe_left_lb += DMA_ALIGNMENT * FE_LFT_SAO_CHROMA_BYTES_PER_PACKETS *
+ num_lcu_per_pipe;
+ fe_left_lb += DMA_ALIGNMENT * FE_LFT_LR_LUMA_CHROMA_BYTES_PER_PACKETS *
+ num_lcu_per_pipe * FE_LFT_LR_DATA_LINE_NUMBERS;
+ }
+
+ if (is_opb)
+ dpb_obp = size_dpb_opb(frame_height, lcu_size) * num_vpp_pipes;
+
+ se_left_lb = max3(((frame_height + LCU_SIZE_16 - 1) / H265_MIN_SE_CTRL_BLOCK_SIZE) *
+ MAX_SE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE,
+ ((frame_height + LCU_SIZE_32 - 1) / H265_MIN_SE_CTRL_BLOCK_SIZE) *
+ MAX_SE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE,
+ ((frame_height + LCU_SIZE_64 - 1) / H265_MIN_SE_CTRL_BLOCK_SIZE) *
+ MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE);
+
+ vsp_left_lb = ALIGN(DIV_ROUND_UP(frame_height, LCU_SIZE_64) *
+ H265_NUM_TILE_ROW, DMA_ALIGNMENT);
+
+ top_lb = DMA_ALIGNMENT * FE_TOP_CTRL_BYTES_PER_PACKETS *
+ DIV_ROUND_UP(frame_width, lcu_size) * FE_TOP_CTRL_LINE_NUMBERS;
+ top_lb += DMA_ALIGNMENT * FE_TOP_LUMA_BYTES_PER_PACKETS *
+ DIV_ROUND_UP(frame_width, lcu_size) * FE_TOP_DATA_LUMA_LINE_NUMBERS;
+ top_lb += DMA_ALIGNMENT * FE_TOP_CHROMA_BYTES_PER_PACKETS *
+ (DIV_ROUND_UP(frame_width, lcu_size) + 1) * FE_TOP_DATA_CHROMA_LINE_NUMBERS;
+ top_lb += ALIGN(((frame_width + LCU_SIZE_64 - 1) / H265_MIN_SE_CTRL_BLOCK_SIZE) *
+ MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE, DMA_ALIGNMENT);
+ top_lb += ALIGN(ALIGN(frame_width, LCU_SIZE_64) * PE_TOP_RECON_DATA_BYTES_PER_PACKETS,
+ DMA_ALIGNMENT);
+ top_lb += size_h265d_lb_vsp_top(frame_width, frame_height);
+
+ qp_size = size_h265d_qp(frame_width, frame_height);
+
+ return ((ALIGN(dpb_obp, DMA_ALIGNMENT) + ALIGN(se_left_lb, DMA_ALIGNMENT) +
+ ALIGN(vsp_left_lb, DMA_ALIGNMENT)) * num_vpp_pipes) +
+ ALIGN(fe_left_lb, DMA_ALIGNMENT) + ALIGN(top_lb, DMA_ALIGNMENT) +
+ ALIGN(qp_size, DMA_ALIGNMENT);
+}
+
static u32 iris_vpu4x_dec_line_size(struct iris_inst *inst)
{
u32 num_vpp_pipes = inst->core->iris_platform_data->num_vpp_pipe;
@@ -1829,7 +1886,7 @@ static u32 iris_vpu4x_dec_line_size(struct iris_inst *inst)
if (inst->codec == V4L2_PIX_FMT_H264)
return hfi_buffer_line_h264d(width, height, is_opb, num_vpp_pipes);
else if (inst->codec == V4L2_PIX_FMT_HEVC)
- return hfi_buffer_line_h265d(width, height, is_opb, num_vpp_pipes);
+ return hfi_vpu4x_buffer_line_h265d(width, height, is_opb, num_vpp_pipes);
else if (inst->codec == V4L2_PIX_FMT_VP9)
return hfi_vpu4x_buffer_line_vp9d(width, height, out_min_count, is_opb,
num_vpp_pipes);
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
index 8c0d6b7b5de85f7d7aaa8fc36218e8d095419569..d482906712243ecb8b5478a4419fc16cb9efd6ce 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
+++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
@@ -150,6 +150,22 @@ struct iris_inst;
#define BITS_PER_CTRL_PACK 128
#define NUM_CTRL_PACK_LCU 10
+#define LCU_SIZE_16 16
+#define LCU_SIZE_32 32
+#define LCU_SIZE_64 64
+
+#define H265_MIN_SE_CTRL_BLOCK_SIZE 8
+#define FE_LFT_CTRL_BYTES_PER_PACKETS 1
+#define FE_LFT_DB_LUMA_CHROMA_BYTES_PER_PACKETS 2
+#define FE_LFT_SAO_LUMA_BYTES_PER_PACKETS 1
+#define FE_LFT_SAO_CHROMA_BYTES_PER_PACKETS 2
+#define FE_LFT_LR_LUMA_CHROMA_BYTES_PER_PACKETS 8
+
+#define FE_TOP_CTRL_BYTES_PER_PACKETS 1
+#define FE_TOP_LUMA_BYTES_PER_PACKETS 2
+#define FE_TOP_CHROMA_BYTES_PER_PACKETS 2
+#define PE_TOP_RECON_DATA_BYTES_PER_PACKETS 6
+
static inline u32 size_h264d_lb_fe_top_data(u32 frame_width)
{
return MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE * ALIGN(frame_width, 16) * 3;
--
2.34.1