[PATCH v9 4/9] media: mediatek: vcodec: Add VP9 Probability Size Configuration

Kyrie Wu
2026-04-24T03:05:44Z

Introduce support for using different probability buffer sizes for
different stateless decoders: in particular, the VP9 decoder can use
a different size on different SoCs because of different
hardware capabilities.

Move the hardcoded single probability buffer size value to
decoder params, introduce a new VP9_4K_PROB_BUF_SIZE and assign:
- VP9_PROB_BUF_SIZE (2560 lines) to legacy SoCs;
- VP9_4K_PROB_BUF_SIZE (3840 lines) to newer SoCs (MT8196, MT8189).

Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 2 ++
.../mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
.../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c | 9 +++++++++
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 4 ++--
4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
index 4ffc0eae855b..43dc0b22fdb0 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
@@ -82,10 +82,12 @@ struct vdec_pic_info {
* struct mtk_vcodec_dec_params - decoder supported parameters
* @level: decoder supported vcodec level
* @profile: decoder supported vcodec profile
+ * @prob_size: vp9 decoder probability size
*/
struct mtk_vcodec_dec_params {
s64 level;
s64 profile;
+ size_t prob_size;
};

/**
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
index 64f32976d15e..5dcbe6550419 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c
@@ -630,5 +630,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ .prob_size = 2560,
},
};
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
index efcd28f5f289..783a988b894a 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
@@ -10,6 +10,9 @@
#include "mtk_vcodec_dec_pm.h"
#include "vdec_drv_if.h"

+#define VP9_PROB_BUF_SIZE 2560
+#define VP9_4K_PROB_BUF_SIZE 3840
+
/**
* struct mtk_stateless_control - CID control type
* @cfg: control configuration
@@ -890,6 +893,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ .prob_size = VP9_PROB_BUF_SIZE,
},
};

@@ -941,6 +945,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ .prob_size = VP9_PROB_BUF_SIZE,
},
};

@@ -959,6 +964,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ .prob_size = VP9_PROB_BUF_SIZE,
},
};

@@ -977,6 +983,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ .prob_size = VP9_PROB_BUF_SIZE,
},
};

@@ -995,6 +1002,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ .prob_size = VP9_4K_PROB_BUF_SIZE,
},
};

@@ -1030,5 +1038,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ .prob_size = VP9_PROB_BUF_SIZE,
},
};
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
index 3f4b70526754..e02dcf81b3cb 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
@@ -22,7 +22,6 @@
#define VP9_RESET_FRAME_CONTEXT_ALL 3

#define VP9_TILE_BUF_SIZE 4096
-#define VP9_PROB_BUF_SIZE 2560
#define VP9_COUNTS_BUF_SIZE 16384

#define HDR_FLAG(x) (!!((hdr)->flags & V4L2_VP9_FRAME_FLAG_##x))
@@ -551,6 +550,7 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i
struct vdec_vp9_slice_vsi *vsi)
{
struct mtk_vcodec_dec_ctx *ctx = instance->ctx;
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
enum vdec_vp9_slice_resolution_level level;
/* super blocks */
unsigned int max_sb_w;
@@ -621,7 +621,7 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i
}

if (!instance->prob.va) {
- instance->prob.size = VP9_PROB_BUF_SIZE;
+ instance->prob.size = pdev->vdec_pdata->vp9_params.prob_size;
if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
goto err;
}
--
2.45.2