* [PATCH v10 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
@ 2026-09-23 8:12 ` Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Kyrie Wu @ 2026-09-23 8:12 UTC (permalink / raw)
To: Tiffany Lin, Andrew-CT Chen, Yunfei Dong, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Kyrie Wu, Hans Verkuil,
Nicolas Dufresne, Nathan Hebert, Arnd Bergmann, Irui Wang,
George Sun, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
Add compatible for video decoder on MT8189 platform. Compared with
former ICs, the MT8189 decoder use iommu to instead of smmu, and
use scp architecture, the frequency is only 406MHZ, and cannot reach
more than 700MHZ. It uses only one clock. At the same time, the decoder
supports the vp9 decoding protocol for the first time in single IC.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
.../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
index 618be8c52429..6c30b070535c 100644
--- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
+++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
@@ -75,6 +75,7 @@ properties:
- mediatek,mt8192-vcodec-dec
- mediatek,mt8186-vcodec-dec
- mediatek,mt8188-vcodec-dec
+ - mediatek,mt8189-vcodec-dec
- mediatek,mt8195-vcodec-dec
- mediatek,mt8196-vcodec-dec
@@ -138,11 +139,11 @@ patternProperties:
Refer to bindings/iommu/mediatek,iommu.yaml.
clocks:
- minItems: 4
+ minItems: 1
maxItems: 5
clock-names:
- minItems: 4
+ minItems: 1
maxItems: 5
assigned-clocks:
--
2.51.0.windows.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
@ 2026-09-23 8:12 ` Kyrie Wu
2026-09-23 9:49 ` AngeloGioacchino Del Regno
2026-09-23 8:12 ` [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data Kyrie Wu
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Kyrie Wu @ 2026-09-23 8:12 UTC (permalink / raw)
To: Tiffany Lin, Andrew-CT Chen, Yunfei Dong, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Kyrie Wu, Hans Verkuil,
Nicolas Dufresne, Nathan Hebert, Arnd Bergmann, Irui Wang,
George Sun, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
Move the chip model information into the codec match data
and remove the second compatible matching code.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 2 +-
.../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 +
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 40 ++-----
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 17 +--
.../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +-
.../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 104 +++++++++++++-----
7 files changed, 96 insertions(+), 75 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
index d76e891f784b..13d70acda88b 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
@@ -263,7 +263,7 @@ static int vidioc_vdec_querycap(struct file *file, void *priv,
struct device *dev = &ctx->dev->plat_dev->dev;
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
- snprintf(cap->card, sizeof(cap->card), "MT%d video decoder", ctx->dev->chip_name);
+ snprintf(cap->card, sizeof(cap->card), "MT%d video decoder", ctx->dev->chip_model);
return 0;
}
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
index 1af075fc0194..80cb46f1cded 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
@@ -69,6 +69,11 @@ extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
extern const struct media_device_ops mtk_vcodec_media_ops;
extern const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata;
extern const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata;
extern const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata;
extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata;
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
index 4d65c1025c97..8642947af7e5 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
@@ -331,26 +331,9 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
.mmap = v4l2_m2m_fop_mmap,
};
-static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev)
+static void mtk_vcodec_dec_get_chip_model(struct mtk_vcodec_dec_dev *vdec_dev)
{
- struct device *dev = &vdec_dev->plat_dev->dev;
-
- if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8173;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8183;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8192-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8192;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8195-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8195;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8186-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8186;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8188;
- else if (of_device_is_compatible(dev->of_node, "mediatek,mt8196-vcodec-dec"))
- vdec_dev->chip_name = MTK_VDEC_MT8196;
- else
- vdec_dev->chip_name = MTK_VDEC_INVAL;
+ vdec_dev->chip_model = vdec_dev->vdec_pdata->chip_model;
}
static int mtk_vcodec_probe(struct platform_device *pdev)
@@ -368,13 +351,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&dev->ctx_list);
dev->plat_dev = pdev;
- mtk_vcodec_dec_get_chip_name(dev);
- if (dev->chip_name == MTK_VDEC_INVAL) {
- dev_err(&pdev->dev, "Failed to get decoder chip name");
- return -EINVAL;
- }
-
dev->vdec_pdata = of_device_get_match_data(&pdev->dev);
+ mtk_vcodec_dec_get_chip_model(dev);
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
&rproc_phandle)) {
fw_type = VPU;
@@ -392,7 +370,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
return -ENODEV;
}
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
- if (dev->chip_name == MTK_VDEC_MT8196) {
+ if (dev->chip_model == 8196) {
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(36));
if (ret) {
dev_err(&pdev->dev, "Failed to enable 36-bit DMA: %d\n", ret);
@@ -561,23 +539,23 @@ static const struct of_device_id mtk_vcodec_match[] = {
},
{
.compatible = "mediatek,mt8192-vcodec-dec",
- .data = &mtk_lat_sig_core_pdata,
+ .data = &mtk_vdec_8192_pdata,
},
{
.compatible = "mediatek,mt8186-vcodec-dec",
- .data = &mtk_vdec_single_core_pdata,
+ .data = &mtk_vdec_8186_pdata,
},
{
.compatible = "mediatek,mt8195-vcodec-dec",
- .data = &mtk_lat_sig_core_pdata,
+ .data = &mtk_vdec_8195_pdata,
},
{
.compatible = "mediatek,mt8188-vcodec-dec",
- .data = &mtk_lat_sig_core_pdata,
+ .data = &mtk_vdec_8188_pdata,
},
{
.compatible = "mediatek,mt8196-vcodec-dec",
- .data = &mtk_lat_sig_core_pdata,
+ .data = &mtk_vdec_8196_pdata,
},
{},
};
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 53d1708b012b..153c617df78d 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
@@ -21,17 +21,6 @@
#define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
#define IS_VDEC_SUPPORT_EXT(capability) ((capability) & MTK_VDEC_IS_SUPPORT_EXT)
-enum mtk_vcodec_dec_chip_name {
- MTK_VDEC_INVAL = 0,
- MTK_VDEC_MT8173 = 8173,
- MTK_VDEC_MT8183 = 8183,
- MTK_VDEC_MT8186 = 8186,
- MTK_VDEC_MT8188 = 8188,
- MTK_VDEC_MT8192 = 8192,
- MTK_VDEC_MT8195 = 8195,
- MTK_VDEC_MT8196 = 8196,
-};
-
/*
* enum mtk_vdec_format_types - Structure used to get supported
* format types according to decoder capability
@@ -108,6 +97,7 @@ struct vdec_pic_info {
*
* @is_subdev_supported: whether support parent-node architecture(subdev)
* @uses_stateless_api: whether the decoder uses the stateless API with requests
+ * @chip_model: platforms configuration values
*/
struct mtk_vcodec_dec_pdata {
void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
@@ -129,6 +119,7 @@ struct mtk_vcodec_dec_pdata {
bool is_subdev_supported;
bool uses_stateless_api;
+ unsigned int chip_model;
};
/**
@@ -277,7 +268,7 @@ struct mtk_vcodec_dec_ctx {
* @dec_racing_info_mutex: mutex lock used for inner racing mode
* @dbgfs: debug log related information
*
- * @chip_name: used to distinguish platforms and select the correct codec configuration values
+ * @chip_model: used to distinguish platforms and select the correct codec configuration values
*/
struct mtk_vcodec_dec_dev {
struct v4l2_device v4l2_dev;
@@ -321,7 +312,7 @@ struct mtk_vcodec_dec_dev {
struct mutex dec_racing_info_mutex;
struct mtk_vcodec_dbgfs dbgfs;
- enum mtk_vcodec_dec_chip_name chip_name;
+ unsigned int chip_model;
};
static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
index 46ac3e41c401..5e5b8539a08b 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
@@ -77,7 +77,7 @@ static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev)
unsigned long flags;
u32 val, mask, addr = VDEC_XPC_CLEAN_ADDR;
- if (dev->main_dev->chip_name != MTK_VDEC_MT8196)
+ if (dev->main_dev->chip_model != 8196)
return;
val = dev->hw_idx == MTK_VDEC_LAT0 ? VDEC_XPC_LAT_VAL : VDEC_XPC_CORE_VAL;
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 aa9bdee7a96c..0e702d6a43ed 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
@@ -618,4 +618,5 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .chip_model = 8173,
};
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 472ece5713a5..5ecbfc169805 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
@@ -571,17 +571,17 @@ static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = {
static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8192:
- case MTK_VDEC_MT8188:
+ switch (ctx->dev->chip_model) {
+ case 8192:
+ case 8188:
cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_5_2;
break;
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_6_0;
break;
- case MTK_VDEC_MT8183:
- case MTK_VDEC_MT8186:
+ case 8183:
+ case 8186:
cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_4_2;
break;
default:
@@ -593,10 +593,10 @@ static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg,
static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8188:
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ switch (ctx->dev->chip_model) {
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
break;
default:
@@ -608,12 +608,12 @@ static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg,
static void mtk_vcodec_dec_fill_h265_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8188:
+ switch (ctx->dev->chip_model) {
+ case 8188:
cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1;
break;
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2;
break;
default:
@@ -625,10 +625,10 @@ static void mtk_vcodec_dec_fill_h265_level(struct v4l2_ctrl_config *cfg,
static void mtk_vcodec_dec_fill_h265_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8188:
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ switch (ctx->dev->chip_model) {
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10;
break;
default:
@@ -640,16 +640,16 @@ static void mtk_vcodec_dec_fill_h265_profile(struct v4l2_ctrl_config *cfg,
static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8192:
- case MTK_VDEC_MT8188:
+ switch (ctx->dev->chip_model) {
+ case 8192:
+ case 8188:
cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1;
break;
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2;
break;
- case MTK_VDEC_MT8186:
+ case 8186:
cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1;
break;
default:
@@ -661,10 +661,10 @@ static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg,
static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_name) {
- case MTK_VDEC_MT8188:
- case MTK_VDEC_MT8195:
- case MTK_VDEC_MT8196:
+ switch (ctx->dev->chip_model) {
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
break;
default:
@@ -935,6 +935,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.get_cap_buffer = vdec_get_cap_buffer,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .chip_model = 8183,
};
/* This platform data is used for one lat and one core architecture. */
@@ -955,6 +956,45 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
};
+#define MTK_STATELESS_DEC_DATA \
+ .init_vdec_params = mtk_init_vdec_params, \
+ .ctrls_setup = mtk_vcodec_dec_ctrls_setup, \
+ .vdec_vb2_ops = &mtk_vdec_request_vb2_ops, \
+ .vdec_formats = mtk_video_formats, \
+ .num_formats = &num_formats, \
+ .default_out_fmt = &default_out_format, \
+ .default_cap_fmt = &default_cap_format, \
+ .uses_stateless_api = true, \
+ .worker = mtk_vdec_worker, \
+ .flush_decoder = mtk_vdec_flush_decoder, \
+ .cap_to_disp = mtk_vdec_stateless_cap_to_disp, \
+ .get_cap_buffer = vdec_get_cap_buffer, \
+ .is_subdev_supported = true
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_model = 8188,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_model = 8192,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_model = 8195,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_model = 8196,
+};
+
const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
.init_vdec_params = mtk_init_vdec_params,
.ctrls_setup = mtk_vcodec_dec_ctrls_setup,
@@ -971,3 +1011,9 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .chip_model = 8186,
+};
--
2.51.0.windows.2
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member
2026-09-23 8:12 ` [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
@ 2026-09-23 9:49 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-23 9:49 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Hans Verkuil, Nicolas Dufresne,
Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
On 9/23/26 10:12, Kyrie Wu wrote:
> Move the chip model information into the codec match data
> and remove the second compatible matching code.
>
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 2 +-
> .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 +
> .../vcodec/decoder/mtk_vcodec_dec_drv.c | 40 ++-----
> .../vcodec/decoder/mtk_vcodec_dec_drv.h | 17 +--
> .../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +-
> .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
> .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 104 +++++++++++++-----
> 7 files changed, 96 insertions(+), 75 deletions(-)
>
..snip..
> 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 53d1708b012b..153c617df78d 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
> @@ -21,17 +21,6 @@
> #define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
> #define IS_VDEC_SUPPORT_EXT(capability) ((capability) & MTK_VDEC_IS_SUPPORT_EXT)
>
> -enum mtk_vcodec_dec_chip_name {
> - MTK_VDEC_INVAL = 0,
> - MTK_VDEC_MT8173 = 8173,
> - MTK_VDEC_MT8183 = 8183,
> - MTK_VDEC_MT8186 = 8186,
> - MTK_VDEC_MT8188 = 8188,
> - MTK_VDEC_MT8192 = 8192,
> - MTK_VDEC_MT8195 = 8195,
> - MTK_VDEC_MT8196 = 8196,
> -};
> -
> /*
> * enum mtk_vdec_format_types - Structure used to get supported
> * format types according to decoder capability
> @@ -108,6 +97,7 @@ struct vdec_pic_info {
> *
> * @is_subdev_supported: whether support parent-node architecture(subdev)
> * @uses_stateless_api: whether the decoder uses the stateless API with requests
> + * @chip_model: platforms configuration values
> */
> struct mtk_vcodec_dec_pdata {
> void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> @@ -129,6 +119,7 @@ struct mtk_vcodec_dec_pdata {
>
> bool is_subdev_supported;
> bool uses_stateless_api;
> + unsigned int chip_model;
I already gave my R-b but I just noticed:
Please use u16 here, 16 bits are way more than enough for this.
> };
>
> /**
> @@ -277,7 +268,7 @@ struct mtk_vcodec_dec_ctx {
> * @dec_racing_info_mutex: mutex lock used for inner racing mode
> * @dbgfs: debug log related information
> *
> - * @chip_name: used to distinguish platforms and select the correct codec configuration values
> + * @chip_model: used to distinguish platforms and select the correct codec configuration values
> */
> struct mtk_vcodec_dec_dev {
> struct v4l2_device v4l2_dev;
> @@ -321,7 +312,7 @@ struct mtk_vcodec_dec_dev {
> struct mutex dec_racing_info_mutex;
> struct mtk_vcodec_dbgfs dbgfs;
>
> - enum mtk_vcodec_dec_chip_name chip_name;
> + unsigned int chip_model;
same here
Cheers,
Angelo
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
@ 2026-09-23 8:12 ` Kyrie Wu
2026-09-23 9:49 ` AngeloGioacchino Del Regno
2026-09-23 8:12 ` [PATCH v10 04/10] media: mediatek: vcodec: Refactor Decoder profile & level Handling Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 05/10] media: mediatek: vcodec: Add VP9 Probability Size Configuration Kyrie Wu
4 siblings, 1 reply; 8+ messages in thread
From: Kyrie Wu @ 2026-09-23 8:12 UTC (permalink / raw)
To: Tiffany Lin, Andrew-CT Chen, Yunfei Dong, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Kyrie Wu, Hans Verkuil,
Nicolas Dufresne, Nathan Hebert, Arnd Bergmann, Irui Wang,
George Sun, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
The decoder currently selects its firmware backend by testing optional
mediatek,vpu, mediatek,scp, and mediatek,vcp properties in the device
tree. The firmware backend is, however, fixed by the decoder compatible.
Add the firmware type and initialization callback to the decoder platform
data, initialize them for each supported SoC, and use the callback from
the platform data at probe time. This matches the existing encoder
platform-data design and removes the DT-property dependency.
Fixes: bf1d556ad4e0 ("media: mtk-vcodec: abstract firmware interface")
Fixes: c7244811b1c9 ("media: mtk-vcodec: add SCP firmware ops")
Fixes: c3da5e939cbc ("media: mediatek: vcodec: support vcp architecture")
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 21 ++-----------------
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 7 +++++--
.../vcodec/decoder/mtk_vcodec_dec_stateful.c | 2 ++
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 12 +++++++++++
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
index 8642947af7e5..62e7bbbe95c3 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
@@ -340,8 +340,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
{
struct mtk_vcodec_dec_dev *dev;
struct video_device *vfd_dec;
- phandle rproc_phandle;
- enum mtk_vcodec_fw_type fw_type;
int i, ret;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -353,22 +351,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
dev->vdec_pdata = of_device_get_match_data(&pdev->dev);
mtk_vcodec_dec_get_chip_model(dev);
- if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
- &rproc_phandle)) {
- fw_type = VPU;
- dev->fw_init = mtk_vcodec_fw_vpu_init;
- } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
- &rproc_phandle)) {
- fw_type = SCP;
- dev->fw_init = mtk_vcodec_fw_scp_init;
- } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vcp",
- &rproc_phandle)) {
- fw_type = VCP;
- dev->fw_init = mtk_vcodec_fw_vcp_init;
- } else {
- dev_dbg(&pdev->dev, "Could not get vdec IPI device");
- return -ENODEV;
- }
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
if (dev->chip_model == 8196) {
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(36));
@@ -378,7 +360,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
}
- dev->fw_handler = mtk_vcodec_fw_select(dev, DECODER, dev->fw_init);
+ dev->fw_handler = mtk_vcodec_fw_select(dev, DECODER,
+ dev->vdec_pdata->fw_init);
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
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 153c617df78d..d7ed7bfe7d50 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
@@ -97,6 +97,8 @@ struct vdec_pic_info {
*
* @is_subdev_supported: whether support parent-node architecture(subdev)
* @uses_stateless_api: whether the decoder uses the stateless API with requests
+ * @fw_type: firmware type (VPU, SCP, or VCP)
+ * @fw_init: firmware-specific initialization callback
* @chip_model: platforms configuration values
*/
struct mtk_vcodec_dec_pdata {
@@ -119,6 +121,9 @@ struct mtk_vcodec_dec_pdata {
bool is_subdev_supported;
bool uses_stateless_api;
+ enum mtk_vcodec_fw_type fw_type;
+ struct mtk_vcodec_fw *(*fw_init)(void *priv,
+ enum mtk_vcodec_fw_use fw_use);
unsigned int chip_model;
};
@@ -243,7 +248,6 @@ struct mtk_vcodec_dec_ctx {
* @vdecsys_regmap: VDEC_SYS register space passed through syscon
*
* @fw_handler: used to communicate with the firmware.
- * @fw_init: firmware-specific init callback selected at probe time
* @id_counter: used to identify current opened instance
*
* @dec_mutex: decoder hardware lock
@@ -285,7 +289,6 @@ struct mtk_vcodec_dec_dev {
struct regmap *vdecsys_regmap;
struct mtk_vcodec_fw *fw_handler;
- struct mtk_vcodec_fw *(*fw_init)(void *priv, enum mtk_vcodec_fw_use fw_use);
u64 id_counter;
/* decoder hardware mutex lock */
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 0e702d6a43ed..e7ae90e8238e 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
@@ -618,5 +618,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = VPU,
+ .fw_init = mtk_vcodec_fw_vpu_init,
.chip_model = 8173,
};
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 5ecbfc169805..2a03395ab30b 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
@@ -935,6 +935,8 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.get_cap_buffer = vdec_get_cap_buffer,
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8183,
};
@@ -974,24 +976,32 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8188,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8192,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8195,
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .fw_type = VCP,
+ .fw_init = mtk_vcodec_fw_vcp_init,
.chip_model = 8196,
};
@@ -1015,5 +1025,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
MTK_STATELESS_DEC_DATA,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .fw_type = SCP,
+ .fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8186,
};
--
2.51.0.windows.2
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data
2026-09-23 8:12 ` [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data Kyrie Wu
@ 2026-09-23 9:49 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-23 9:49 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, Hans Verkuil, Nicolas Dufresne,
Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
On 9/23/26 10:12, Kyrie Wu wrote:
> The decoder currently selects its firmware backend by testing optional
> mediatek,vpu, mediatek,scp, and mediatek,vcp properties in the device
> tree. The firmware backend is, however, fixed by the decoder compatible.
>
> Add the firmware type and initialization callback to the decoder platform
> data, initialize them for each supported SoC, and use the callback from
> the platform data at probe time. This matches the existing encoder
> platform-data design and removes the DT-property dependency.
>
> Fixes: bf1d556ad4e0 ("media: mtk-vcodec: abstract firmware interface")
> Fixes: c7244811b1c9 ("media: mtk-vcodec: add SCP firmware ops")
> Fixes: c3da5e939cbc ("media: mediatek: vcodec: support vcp architecture")
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v10 04/10] media: mediatek: vcodec: Refactor Decoder profile & level Handling
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (2 preceding siblings ...)
2026-09-23 8:12 ` [PATCH v10 03/10] media: mediatek: decoder: Move firmware selection to platform data Kyrie Wu
@ 2026-09-23 8:12 ` Kyrie Wu
2026-09-23 8:12 ` [PATCH v10 05/10] media: mediatek: vcodec: Add VP9 Probability Size Configuration Kyrie Wu
4 siblings, 0 replies; 8+ messages in thread
From: Kyrie Wu @ 2026-09-23 8:12 UTC (permalink / raw)
To: Tiffany Lin, Andrew-CT Chen, Yunfei Dong, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Kyrie Wu, Hans Verkuil,
Nicolas Dufresne, Nathan Hebert, Arnd Bergmann, Irui Wang,
George Sun, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
This commit refactors the handling of decoder parameters for H264,
H265, and VP9 codecs by introducing a new structure to standardize
supported level and profile information. By leveraging this change,
chipset-specific conditional logic in the codec configuration
functions is significantly reduced.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 16 ++
.../vcodec/decoder/mtk_vcodec_dec_stateful.c | 12 ++
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 165 ++++++++++--------
3 files changed, 118 insertions(+), 75 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 d7ed7bfe7d50..bbfa6954d616 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
@@ -78,6 +78,16 @@ struct vdec_pic_info {
unsigned int reserved;
};
+/**
+ * struct mtk_vcodec_dec_params - decoder supported parameters
+ * @level: decoder supported vcodec level
+ * @profile: decoder supported vcodec profile
+ */
+struct mtk_vcodec_dec_params {
+ s64 level;
+ s64 profile;
+};
+
/**
* struct mtk_vcodec_dec_pdata - compatible data for each IC
* @init_vdec_params: init vdec params
@@ -100,6 +110,9 @@ struct vdec_pic_info {
* @fw_type: firmware type (VPU, SCP, or VCP)
* @fw_init: firmware-specific initialization callback
* @chip_model: platforms configuration values
+ * @h264_params: H264 decoder default supported params
+ * @h265_params: H265 decoder default supported params
+ * @vp9_params: VP9 decoder default supported params
*/
struct mtk_vcodec_dec_pdata {
void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
@@ -125,6 +138,9 @@ struct mtk_vcodec_dec_pdata {
struct mtk_vcodec_fw *(*fw_init)(void *priv,
enum mtk_vcodec_fw_use fw_use);
unsigned int chip_model;
+ struct mtk_vcodec_dec_params h264_params;
+ struct mtk_vcodec_dec_params h265_params;
+ struct mtk_vcodec_dec_params vp9_params;
};
/**
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 e7ae90e8238e..bf3569e6b559 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
@@ -621,4 +621,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.fw_type = VPU,
.fw_init = mtk_vcodec_fw_vpu_init,
.chip_model = 8173,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_4_1,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_4,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ },
};
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 2a03395ab30b..cbea445e5c2b 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
@@ -571,106 +571,49 @@ static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = {
static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8192:
- case 8188:
- cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_5_2;
- break;
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_6_0;
- break;
- case 8183:
- case 8186:
- cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_4_2;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_4_1;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->h264_params.level;
}
static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8188:
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->h264_params.profile;
}
static void mtk_vcodec_dec_fill_h265_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8188:
- cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1;
- break;
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_4;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->h265_params.level;
}
static void mtk_vcodec_dec_fill_h265_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8188:
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->h265_params.profile;
}
static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8192:
- case 8188:
- cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1;
- break;
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2;
- break;
- case 8186:
- cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->vp9_params.level;
}
static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2_ctrl_config *cfg,
struct mtk_vcodec_dec_ctx *ctx)
{
- switch (ctx->dev->chip_model) {
- case 8188:
- case 8195:
- case 8196:
- cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
- break;
- default:
- cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_1;
- break;
- }
+ struct mtk_vcodec_dec_dev *pdev = ctx->dev;
+
+ cfg->max = pdev->vdec_pdata->vp9_params.profile;
}
static void mtk_vcodec_dec_reset_controls(struct v4l2_ctrl_config *cfg,
@@ -938,6 +881,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.fw_type = SCP,
.fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8183,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_4,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ },
};
/* This platform data is used for one lat and one core architecture. */
@@ -979,6 +934,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
.fw_type = SCP,
.fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8188,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
@@ -987,6 +954,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
.fw_type = SCP,
.fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8192,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_4,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
@@ -995,6 +974,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
.fw_type = SCP,
.fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8195,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_6_0,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
@@ -1003,6 +994,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
.fw_type = VCP,
.fw_init = mtk_vcodec_fw_vcp_init,
.chip_model = 8196,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_6_0,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
@@ -1028,4 +1031,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
.fw_type = SCP,
.fw_init = mtk_vcodec_fw_scp_init,
.chip_model = 8186,
+ .h264_params = {
+ .level = V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
+ .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+ },
+ .h265_params = {
+ .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_4,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1,
+ },
};
--
2.51.0.windows.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v10 05/10] media: mediatek: vcodec: Add VP9 Probability Size Configuration
2026-09-23 8:12 [PATCH v10 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (3 preceding siblings ...)
2026-09-23 8:12 ` [PATCH v10 04/10] media: mediatek: vcodec: Refactor Decoder profile & level Handling Kyrie Wu
@ 2026-09-23 8:12 ` Kyrie Wu
4 siblings, 0 replies; 8+ messages in thread
From: Kyrie Wu @ 2026-09-23 8:12 UTC (permalink / raw)
To: Tiffany Lin, Andrew-CT Chen, Yunfei Dong, Mauro Carvalho Chehab,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Kyrie Wu, Hans Verkuil,
Nicolas Dufresne, Nathan Hebert, Arnd Bergmann, Irui Wang,
George Sun, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Neil Armstrong, Andrzej Pietrasiewicz, Yilong Zhou
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 bbfa6954d616..0bde1c5b5aa0 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 bf3569e6b559..bfa62974b1a7 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
@@ -632,5 +632,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 cbea445e5c2b..56656222d0f1 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
@@ -892,6 +895,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,
},
};
@@ -945,6 +949,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,
},
};
@@ -965,6 +970,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,
},
};
@@ -985,6 +991,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,
},
};
@@ -1005,6 +1012,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,
},
};
@@ -1042,5 +1050,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 ee4d1cd82426..d08be051d0ab 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.51.0.windows.2
^ permalink raw reply [flat|nested] 8+ messages in thread