* [PATCH v6 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
` (8 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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 used 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>
---
.../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 74e1d88d3056..ee2bbbdb2d50 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
@@ -132,11 +133,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.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:11 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 03/10] media: mediatek: vcodec: add decoder compatible to support MT8189 Kyrie Wu
` (7 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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 a new platform data member to indicate each decoder IC
to avoid the chip name definition keep growing.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 +
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 35 +----
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 15 +-
.../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +-
.../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 137 +++++++++++++++---
6 files changed, 131 insertions(+), 64 deletions(-)
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 6fb05bb00641..d7a269045fd6 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,24 +331,7 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
static void mtk_vcodec_dec_get_chip_name(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_name = vdec_dev->vdec_pdata->chip_name;
}
static int mtk_vcodec_probe(struct platform_device *pdev)
@@ -367,10 +350,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
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);
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
@@ -387,7 +366,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_name == 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);
@@ -556,23 +535,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 429b32952194..2dbde8d00e6f 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
@@ -19,17 +19,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
@@ -106,6 +95,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_name: platforms configuration values
*/
struct mtk_vcodec_dec_pdata {
void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
@@ -127,6 +117,7 @@ struct mtk_vcodec_dec_pdata {
bool is_subdev_supported;
bool uses_stateless_api;
+ unsigned int chip_name;
};
/**
@@ -307,7 +298,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_name;
};
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 e4e527fe54dc..a926dc14d39d 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
@@ -76,7 +76,7 @@ static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev)
{
u32 val, mask, addr = VDEC_XPC_CLEAN_ADDR;
- if (dev->main_dev->chip_name != MTK_VDEC_MT8196)
+ if (dev->main_dev->chip_name != 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..8ddb61670dc6 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_name = 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 c1cef78471a9..d249a8774948 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
@@ -550,16 +550,16 @@ 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:
+ 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:
@@ -572,9 +572,9 @@ 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:
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
break;
default:
@@ -587,11 +587,11 @@ 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:
+ 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:
@@ -604,9 +604,9 @@ 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:
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10;
break;
default:
@@ -619,15 +619,15 @@ 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:
+ 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:
@@ -640,9 +640,9 @@ 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:
+ case 8188:
+ case 8195:
+ case 8196:
cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
break;
default:
@@ -886,6 +886,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_name = 8183,
};
/* This platform data is used for one lat and one core architecture. */
@@ -906,6 +907,78 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
};
+const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
+ .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,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_name = 8188,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
+ .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,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_name = 8192,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
+ .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,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_name = 8195,
+};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
+ .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,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_name = 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,
@@ -922,3 +995,21 @@ 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 = {
+ .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,
+ .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .chip_name = 8186,
+};
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member
2025-12-02 7:40 ` [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
@ 2025-12-11 20:11 ` Nicolas Dufresne
2025-12-25 7:26 ` Kyrie Wu (吴晗)
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:11 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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
[-- Attachment #1: Type: text/plain, Size: 16902 bytes --]
Hi,
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> Add a new platform data member to indicate each decoder IC
> to avoid the chip name definition keep growing.
>
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> ---
> .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 +
> .../vcodec/decoder/mtk_vcodec_dec_drv.c | 35 +----
> .../vcodec/decoder/mtk_vcodec_dec_drv.h | 15 +-
> .../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +-
> .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
> .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 137 +++++++++++++++---
> 6 files changed, 131 insertions(+), 64 deletions(-)
>
> 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 6fb05bb00641..d7a269045fd6 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,24 +331,7 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
>
> static void mtk_vcodec_dec_get_chip_name(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_name = vdec_dev->vdec_pdata->chip_name;
> }
>
> static int mtk_vcodec_probe(struct platform_device *pdev)
> @@ -367,10 +350,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
> 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);
> if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> @@ -387,7 +366,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_name == 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);
> @@ -556,23 +535,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 429b32952194..2dbde8d00e6f 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
> @@ -19,17 +19,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
> @@ -106,6 +95,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_name: platforms configuration values
> */
> struct mtk_vcodec_dec_pdata {
> void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> @@ -127,6 +117,7 @@ struct mtk_vcodec_dec_pdata {
>
> bool is_subdev_supported;
> bool uses_stateless_api;
> + unsigned int chip_name;
> };
>
> /**
> @@ -307,7 +298,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_name;
> };
>
> 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 e4e527fe54dc..a926dc14d39d 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
> @@ -76,7 +76,7 @@ static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev)
> {
> u32 val, mask, addr = VDEC_XPC_CLEAN_ADDR;
>
> - if (dev->main_dev->chip_name != MTK_VDEC_MT8196)
> + if (dev->main_dev->chip_name != 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..8ddb61670dc6 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_name = 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 c1cef78471a9..d249a8774948 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
> @@ -550,16 +550,16 @@ 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:
> + 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:
> @@ -572,9 +572,9 @@ 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:
> + case 8188:
> + case 8195:
> + case 8196:
> cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
> break;
> default:
> @@ -587,11 +587,11 @@ 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:
> + 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:
> @@ -604,9 +604,9 @@ 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:
> + case 8188:
> + case 8195:
> + case 8196:
> cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10;
> break;
> default:
> @@ -619,15 +619,15 @@ 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:
> + 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:
> @@ -640,9 +640,9 @@ 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:
> + case 8188:
> + case 8195:
> + case 8196:
> cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
> break;
> default:
> @@ -886,6 +886,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_name = 8183,
> };
>
> /* This platform data is used for one lat and one core architecture. */
> @@ -906,6 +907,78 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
> .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> };
>
> +const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
> + .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,
> + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> + .chip_name = 8188,
> +};
> +
> +const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
> + .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,
> + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> + .chip_name = 8192,
> +};
I really like the change overall, but this adds a lot of code duplication.
Perhaps you could do something like:
+#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_8192_pdata = {
+ MTK_STATELESS_DEC_DATA,
+ .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
+ .chip_name = 8192,
+};
The other method also used in various drivers is to embed a pointer to another
structure. The benefit of this second method is that it reduce the driver binary
size. With one solution to the copy paste issue implemented, the patch looks
good.
regards,
Nicolas
> +
> +const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> + .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,
> + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> + .chip_name = 8195,
> +};
> +
> +const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
> + .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,
> + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> + .chip_name = 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,
> @@ -922,3 +995,21 @@ 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 = {
> + .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,
> + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> + .chip_name = 8186,
> +};
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member
2025-12-11 20:11 ` Nicolas Dufresne
@ 2025-12-25 7:26 ` Kyrie Wu (吴晗)
0 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-12-25 7:26 UTC (permalink / raw)
To: linux-kernel, linux-mediatek, George Sun (孙林),
Tiffany Lin (林慧珊),
nhebert, linux-media, devicetree, mchehab, nicolas.dufresne,
hverkuil, Kyrie Wu (吴晗),
Yunfei Dong (董云飞),
conor+dt, Irui Wang (王瑞),
robh, linux-arm-kernel, matthias.bgg, krzk+dt, arnd,
Andrew-CT Chen (陳智迪),
AngeloGioacchino Del Regno
Cc: andrzejtp2010, neil.armstrong, Yilong Zhou (周易龙)
On Thu, 2025-12-11 at 15:11 -0500, Nicolas Dufresne wrote:
> Hi,
>
> Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> > Add a new platform data member to indicate each decoder IC
> > to avoid the chip name definition keep growing.
> >
> > Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> > ---
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 +
> > .../vcodec/decoder/mtk_vcodec_dec_drv.c | 35 +----
> > .../vcodec/decoder/mtk_vcodec_dec_drv.h | 15 +-
> > .../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +-
> > .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 +
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 137
> > +++++++++++++++---
> > 6 files changed, 131 insertions(+), 64 deletions(-)
> >
> > 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 6fb05bb00641..d7a269045fd6 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,24 +331,7 @@ static const struct v4l2_file_operations
> > mtk_vcodec_fops = {
> >
> > static void mtk_vcodec_dec_get_chip_name(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_name = vdec_dev->vdec_pdata->chip_name;
> > }
> >
> > static int mtk_vcodec_probe(struct platform_device *pdev)
> > @@ -367,10 +350,6 @@ static int mtk_vcodec_probe(struct
> > platform_device *pdev)
> > 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);
> > if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
> > @@ -387,7 +366,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_name == 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);
> > @@ -556,23 +535,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 429b32952194..2dbde8d00e6f 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
> > @@ -19,17 +19,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
> > @@ -106,6 +95,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_name: platforms configuration values
> > */
> > struct mtk_vcodec_dec_pdata {
> > void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> > @@ -127,6 +117,7 @@ struct mtk_vcodec_dec_pdata {
> >
> > bool is_subdev_supported;
> > bool uses_stateless_api;
> > + unsigned int chip_name;
> > };
> >
> > /**
> > @@ -307,7 +298,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_name;
> > };
> >
> > 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 e4e527fe54dc..a926dc14d39d 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
> > @@ -76,7 +76,7 @@ static void mtk_vdec_hw_clean_xpc(struct
> > mtk_vdec_hw_dev *dev)
> > {
> > u32 val, mask, addr = VDEC_XPC_CLEAN_ADDR;
> >
> > - if (dev->main_dev->chip_name != MTK_VDEC_MT8196)
> > + if (dev->main_dev->chip_name != 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_sta
> > teful.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > index aa9bdee7a96c..8ddb61670dc6 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.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_name = 8173,
> > };
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > index c1cef78471a9..d249a8774948 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > @@ -550,16 +550,16 @@ 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:
> > + 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:
> > @@ -572,9 +572,9 @@ 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:
> > + case 8188:
> > + case 8195:
> > + case 8196:
> > cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
> > break;
> > default:
> > @@ -587,11 +587,11 @@ 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:
> > + 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:
> > @@ -604,9 +604,9 @@ 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:
> > + case 8188:
> > + case 8195:
> > + case 8196:
> > cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10;
> > break;
> > default:
> > @@ -619,15 +619,15 @@ 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:
> > + 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:
> > @@ -640,9 +640,9 @@ 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:
> > + case 8188:
> > + case 8195:
> > + case 8196:
> > cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
> > break;
> > default:
> > @@ -886,6 +886,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_name = 8183,
> > };
> >
> > /* This platform data is used for one lat and one core
> > architecture. */
> > @@ -906,6 +907,78 @@ const struct mtk_vcodec_dec_pdata
> > mtk_lat_sig_core_pdata = {
> > .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > };
> >
> > +const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
> > + .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,
> > + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > + .chip_name = 8188,
> > +};
> > +
> > +const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
> > + .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,
> > + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > + .chip_name = 8192,
> > +};
>
> I really like the change overall, but this adds a lot of code
> duplication.
> Perhaps you could do something like:
>
> +#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_8192_pdata = {
> + MTK_STATELESS_DEC_DATA,
> + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> + .chip_name = 8192,
> +};
>
> The other method also used in various drivers is to embed a pointer
> to another
> structure. The benefit of this second method is that it reduce the
> driver binary
> size. With one solution to the copy paste issue implemented, the
> patch looks
> good.
>
> regards,
> Nicolas
Dear Nicolas,
Thanks for your suggestions. I will refine this patch.
Regards,
Kyrie.
>
> > +
> > +const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> > + .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,
> > + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > + .chip_name = 8195,
> > +};
> > +
> > +const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
> > + .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,
> > + .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > + .chip_name = 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,
> > @@ -922,3 +995,21 @@ 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 = {
> > + .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,
> > + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> > + .chip_name = 8186,
> > +};
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 03/10] media: mediatek: vcodec: add decoder compatible to support MT8189
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 02/10] media: mediatek: decoder: Add a new platform data member Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
` (6 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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
MT8189 is pure single core architecture. Add its compatible to
initialize platform data.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 1 +
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++++
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 18 ++++++++++++++++++
3 files changed, 23 insertions(+)
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 80cb46f1cded..2bde871c0224 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
@@ -71,6 +71,7 @@ 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_8189_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;
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 d7a269045fd6..2d1a545e727c 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
@@ -553,6 +553,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
.compatible = "mediatek,mt8196-vcodec-dec",
.data = &mtk_vdec_8196_pdata,
},
+ {
+ .compatible = "mediatek,mt8189-vcodec-dec",
+ .data = &mtk_vdec_8189_pdata,
+ },
{},
};
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 d249a8774948..9e43c54f8c4d 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
@@ -1013,3 +1013,21 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
.chip_name = 8186,
};
+
+const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
+ .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,
+ .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
+ .chip_name = 8189,
+};
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (2 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 03/10] media: mediatek: vcodec: add decoder compatible to support MT8189 Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:19 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder Kyrie Wu
` (5 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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 profile and level supporting for H264 and vp9 of MT8189
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 | 177 ++++++++++--------
3 files changed, 130 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 2dbde8d00e6f..a8baeab98477 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
@@ -76,6 +76,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
@@ -96,6 +106,9 @@ 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_name: 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);
@@ -118,6 +131,9 @@ struct mtk_vcodec_dec_pdata {
bool is_subdev_supported;
bool uses_stateless_api;
unsigned int chip_name;
+ 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 8ddb61670dc6..a47906b9d717 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
@@ -619,4 +619,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
.chip_name = 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 9e43c54f8c4d..dc3e9a2ccc2c 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
@@ -549,106 +549,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_name) {
- 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_name) {
- 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_name) {
- 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_name) {
- 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_name) {
- 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_name) {
- 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,
@@ -887,6 +830,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.is_subdev_supported = false,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
.chip_name = 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. */
@@ -923,6 +878,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
.chip_name = 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 = {
@@ -941,6 +908,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
.chip_name = 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_1,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
@@ -959,6 +938,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
.chip_name = 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_2,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
@@ -977,6 +968,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
.chip_name = 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 = {
@@ -1012,6 +1015,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
.chip_name = 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,
+ },
};
const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
@@ -1030,4 +1045,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
.is_subdev_supported = true,
.hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
.chip_name = 8189,
+ .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_4,
+ .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
+ },
+ .vp9_params = {
+ .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
+ .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ },
};
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189
2025-12-02 7:40 ` [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
@ 2025-12-11 20:19 ` Nicolas Dufresne
2025-12-25 7:28 ` Kyrie Wu (吴晗)
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:19 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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
[-- Attachment #1: Type: text/plain, Size: 11990 bytes --]
Hi,
in the subject, supporting -> suppport.
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> add profile and level supporting for H264 and vp9 of MT8189
You already said that, perhaps say:
The MT8189 SoC support H.264 up to high-10 at level 5.2, HEVC up to profile
main-still at level 4 and VP9 profile 2 up to level 5.2.
>
> 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 | 177 ++++++++++--------
> 3 files changed, 130 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 2dbde8d00e6f..a8baeab98477 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
> @@ -76,6 +76,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
> @@ -96,6 +106,9 @@ 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_name: 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);
> @@ -118,6 +131,9 @@ struct mtk_vcodec_dec_pdata {
> bool is_subdev_supported;
> bool uses_stateless_api;
> unsigned int chip_name;
> + 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 8ddb61670dc6..a47906b9d717 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
> @@ -619,4 +619,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
> .is_subdev_supported = false,
> .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> .chip_name = 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 9e43c54f8c4d..dc3e9a2ccc2c 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
> @@ -549,106 +549,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_name) {
> - 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;
> }
Only remaining issue is that this is two changes. Please refactor first, and add
the configuration after. This is a nice cleanup.
regards,
Nicolas
>
> 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 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_name) {
> - 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_name) {
> - 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_name) {
> - 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_name) {
> - 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,
> @@ -887,6 +830,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
> .is_subdev_supported = false,
> .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> .chip_name = 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. */
> @@ -923,6 +878,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> .chip_name = 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 = {
> @@ -941,6 +908,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> .chip_name = 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_1,
> + },
> };
>
> const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> @@ -959,6 +938,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> .chip_name = 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_2,
> + .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> + },
> };
>
> const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
> @@ -977,6 +968,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> .chip_name = 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 = {
> @@ -1012,6 +1015,18 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata =
> {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> .chip_name = 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,
> + },
> };
>
> const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
> @@ -1030,4 +1045,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata =
> {
> .is_subdev_supported = true,
> .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> .chip_name = 8189,
> + .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_4,
> + .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
> + },
> + .vp9_params = {
> + .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> + .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> + },
> };
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189
2025-12-11 20:19 ` Nicolas Dufresne
@ 2025-12-25 7:28 ` Kyrie Wu (吴晗)
0 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-12-25 7:28 UTC (permalink / raw)
To: linux-kernel, linux-mediatek, George Sun (孙林),
Tiffany Lin (林慧珊),
nhebert, linux-media, devicetree, mchehab, nicolas.dufresne,
hverkuil, Kyrie Wu (吴晗),
Yunfei Dong (董云飞),
conor+dt, Irui Wang (王瑞),
robh, linux-arm-kernel, matthias.bgg, krzk+dt, arnd,
Andrew-CT Chen (陳智迪),
AngeloGioacchino Del Regno
Cc: andrzejtp2010, neil.armstrong, Yilong Zhou (周易龙)
On Thu, 2025-12-11 at 15:19 -0500, Nicolas Dufresne wrote:
> Hi,
>
> in the subject, supporting -> suppport.
>
> Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> > add profile and level supporting for H264 and vp9 of MT8189
>
> You already said that, perhaps say:
>
>
> The MT8189 SoC support H.264 up to high-10 at level 5.2, HEVC up
> to profile
> main-still at level 4 and VP9 profile 2 up to level 5.2.
>
> >
> > 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 | 177 ++++++++++--
> > ------
> > 3 files changed, 130 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 2dbde8d00e6f..a8baeab98477 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
> > @@ -76,6 +76,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
> > @@ -96,6 +106,9 @@ 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_name: 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);
> > @@ -118,6 +131,9 @@ struct mtk_vcodec_dec_pdata {
> > bool is_subdev_supported;
> > bool uses_stateless_api;
> > unsigned int chip_name;
> > + 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_sta
> > teful.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > index 8ddb61670dc6..a47906b9d717 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > @@ -619,4 +619,16 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8173_pdata = {
> > .is_subdev_supported = false,
> > .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> > .chip_name = 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_sta
> > teless.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > index 9e43c54f8c4d..dc3e9a2ccc2c 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > @@ -549,106 +549,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_name) {
> > - 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;
> > }
>
> Only remaining issue is that this is two changes. Please refactor
> first, and add
> the configuration after. This is a nice cleanup.
>
> regards,
> Nicolas
>
Dear Nicolas,
I will split this patch to two.
Thanks.
Regards,
Kyrie.
> >
> > 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 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_name) {
> > - 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_name) {
> > - 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_name) {
> > - 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_name) {
> > - 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,
> > @@ -887,6 +830,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8183_pdata = {
> > .is_subdev_supported = false,
> > .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> > .chip_name = 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. */
> > @@ -923,6 +878,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8188_pdata = {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > .chip_name = 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 = {
> > @@ -941,6 +908,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8192_pdata = {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > .chip_name = 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_1,
> > + },
> > };
> >
> > const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> > @@ -959,6 +938,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8195_pdata = {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > .chip_name = 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_2,
> > + .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> > + },
> > };
> >
> > const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {
> > @@ -977,6 +968,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8196_pdata = {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
> > .chip_name = 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 = {
> > @@ -1012,6 +1015,18 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8186_pdata =
> > {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> > .chip_name = 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,
> > + },
> > };
> >
> > const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
> > @@ -1030,4 +1045,16 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8189_pdata =
> > {
> > .is_subdev_supported = true,
> > .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
> > .chip_name = 8189,
> > + .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_4,
> > + .profile =
> > V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE,
> > + },
> > + .vp9_params = {
> > + .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> > + .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> > + },
> > };
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (3 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 04/10] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:29 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting " Kyrie Wu
` (4 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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
Previously, calling vdec_vp9_slice_setup_single_from_src_to_dst
with v4l2_m2m_next_src_buf to obtain both buffers resulted in -EINVAL,
interrupting the decoding process. To resolve this,
the interface should be updated to set both src and dst buffers
for metadata configuration.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
.../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 21 ++++++++++---------
1 file changed, 11 insertions(+), 10 deletions(-)
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 fa0f406f7726..9513ddde7c7c 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
@@ -696,21 +696,22 @@ static int vdec_vp9_slice_tile_offset(int idx, int mi_num, int tile_log2)
return min(offset, mi_num);
}
-static
-int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance *instance)
+static int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance *instance,
+ struct mtk_vcodec_mem *bs,
+ struct vdec_fb *fb)
{
- struct vb2_v4l2_buffer *src;
- struct vb2_v4l2_buffer *dst;
+ struct mtk_video_dec_buf *src_buf_info;
+ struct mtk_video_dec_buf *dst_buf_info;
- src = v4l2_m2m_next_src_buf(instance->ctx->m2m_ctx);
- if (!src)
+ src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
+ if (!src_buf_info)
return -EINVAL;
- dst = v4l2_m2m_next_dst_buf(instance->ctx->m2m_ctx);
- if (!dst)
+ dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
+ if (!dst_buf_info)
return -EINVAL;
- v4l2_m2m_buf_copy_metadata(src, dst, true);
+ v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &dst_buf_info->m2m_buf.vb, true);
return 0;
}
@@ -1800,7 +1801,7 @@ static int vdec_vp9_slice_setup_single(struct vdec_vp9_slice_instance *instance,
struct vdec_vp9_slice_vsi *vsi = &pfc->vsi;
int ret;
- ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance);
+ ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance, bs, fb);
if (ret)
goto err;
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder
2025-12-02 7:40 ` [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder Kyrie Wu
@ 2025-12-11 20:29 ` Nicolas Dufresne
2025-12-25 9:55 ` Kyrie Wu (吴晗)
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:29 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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
[-- Attachment #1: Type: text/plain, Size: 3054 bytes --]
Hi,
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> Previously, calling vdec_vp9_slice_setup_single_from_src_to_dst
> with v4l2_m2m_next_src_buf to obtain both buffers resulted in -EINVAL,
> interrupting the decoding process. To resolve this,
> the interface should be updated to set both src and dst buffers
> for metadata configuration.
I'm haven't figure-out why this happens, perhaps you can add more details ?
>
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> ---
> .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 21 ++++++++++---------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> 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 fa0f406f7726..9513ddde7c7c 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
> @@ -696,21 +696,22 @@ static int vdec_vp9_slice_tile_offset(int idx, int mi_num, int tile_log2)
> return min(offset, mi_num);
> }
>
> -static
> -int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance *instance)
> +static int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance *instance,
> + struct mtk_vcodec_mem *bs,
> + struct vdec_fb *fb)
> {
> - struct vb2_v4l2_buffer *src;
> - struct vb2_v4l2_buffer *dst;
> + struct mtk_video_dec_buf *src_buf_info;
> + struct mtk_video_dec_buf *dst_buf_info;
>
> - src = v4l2_m2m_next_src_buf(instance->ctx->m2m_ctx);
My concern is that vdec_vp9_slice_setup_lat_from_src_buf() also depends on the
tip of the OUTPUT queue, why it this problem with limited to single core ?
Can you apply the manual completion fixes, and check if the problem still
appear? Is that something you reproduce every time ? Perhaps it should be kept
out of this serie ?
> - if (!src)
> + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
> + if (!src_buf_info)
> return -EINVAL;
Its a bit of a concern in term of memory lifetime / possible use after free.
Who's holding on the buffer if its not in the queue ?
Nicolas
>
> - dst = v4l2_m2m_next_dst_buf(instance->ctx->m2m_ctx);
> - if (!dst)
> + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer);
> + if (!dst_buf_info)
> return -EINVAL;
>
> - v4l2_m2m_buf_copy_metadata(src, dst, true);
> + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &dst_buf_info->m2m_buf.vb, true);
>
> return 0;
> }
> @@ -1800,7 +1801,7 @@ static int vdec_vp9_slice_setup_single(struct vdec_vp9_slice_instance *instance,
> struct vdec_vp9_slice_vsi *vsi = &pfc->vsi;
> int ret;
>
> - ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance);
> + ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance, bs, fb);
> if (ret)
> goto err;
>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder
2025-12-11 20:29 ` Nicolas Dufresne
@ 2025-12-25 9:55 ` Kyrie Wu (吴晗)
0 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-12-25 9:55 UTC (permalink / raw)
To: linux-kernel, linux-mediatek, George Sun (孙林),
Tiffany Lin (林慧珊),
nhebert, linux-media, devicetree, mchehab, nicolas.dufresne,
hverkuil, Kyrie Wu (吴晗),
Yunfei Dong (董云飞),
conor+dt, Irui Wang (王瑞),
robh, linux-arm-kernel, matthias.bgg, krzk+dt, arnd,
Andrew-CT Chen (陳智迪),
AngeloGioacchino Del Regno
Cc: andrzejtp2010, neil.armstrong, Yilong Zhou (周易龙)
On Thu, 2025-12-11 at 15:29 -0500, Nicolas Dufresne wrote:
> Hi,
>
> Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> > Previously, calling vdec_vp9_slice_setup_single_from_src_to_dst
> > with v4l2_m2m_next_src_buf to obtain both buffers resulted in
> > -EINVAL,
> > interrupting the decoding process. To resolve this,
> > the interface should be updated to set both src and dst buffers
> > for metadata configuration.
>
> I'm haven't figure-out why this happens, perhaps you can add more
> details ?
>
> >
> > Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> > ---
> > .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 21 ++++++++++-----
> > ----
> > 1 file changed, 11 insertions(+), 10 deletions(-)
> >
> > 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 fa0f406f7726..9513ddde7c7c 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
> > @@ -696,21 +696,22 @@ static int vdec_vp9_slice_tile_offset(int
> > idx, int mi_num, int tile_log2)
> > return min(offset, mi_num);
> > }
> >
> > -static
> > -int vdec_vp9_slice_setup_single_from_src_to_dst(struct
> > vdec_vp9_slice_instance *instance)
> > +static int vdec_vp9_slice_setup_single_from_src_to_dst(struct
> > vdec_vp9_slice_instance *instance,
> > + struct
> > mtk_vcodec_mem *bs,
> > + struct vdec_fb
> > *fb)
> > {
> > - struct vb2_v4l2_buffer *src;
> > - struct vb2_v4l2_buffer *dst;
> > + struct mtk_video_dec_buf *src_buf_info;
> > + struct mtk_video_dec_buf *dst_buf_info;
> >
> > - src = v4l2_m2m_next_src_buf(instance->ctx->m2m_ctx);
>
> My concern is that vdec_vp9_slice_setup_lat_from_src_buf() also
> depends on the
> tip of the OUTPUT queue, why it this problem with limited to single
> core ?
>
> Can you apply the manual completion fixes, and check if the problem
> still
> appear? Is that something you reproduce every time ? Perhaps it
> should be kept
> out of this serie ?
>
>
> > - if (!src)
> > + src_buf_info = container_of(bs, struct mtk_video_dec_buf,
> > bs_buffer);
> > + if (!src_buf_info)
> > return -EINVAL;
>
> Its a bit of a concern in term of memory lifetime / possible use
> after free.
> Who's holding on the buffer if its not in the queue ?
>
> Nicolas
Dear Nicolas,
Thanks for your reminding, I think this patch could abandon.
I will update the patch set in the next version.
Thanks.
Kyrie.
>
> >
> > - dst = v4l2_m2m_next_dst_buf(instance->ctx->m2m_ctx);
> > - if (!dst)
> > + dst_buf_info = container_of(fb, struct mtk_video_dec_buf,
> > frame_buffer);
> > + if (!dst_buf_info)
> > return -EINVAL;
> >
> > - v4l2_m2m_buf_copy_metadata(src, dst, true);
> > + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb,
> > &dst_buf_info->m2m_buf.vb, true);
> >
> > return 0;
> > }
> > @@ -1800,7 +1801,7 @@ static int vdec_vp9_slice_setup_single(struct
> > vdec_vp9_slice_instance *instance,
> > struct vdec_vp9_slice_vsi *vsi = &pfc->vsi;
> > int ret;
> >
> > - ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance);
> > + ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance, bs,
> > fb);
> > if (ret)
> > goto err;
> >
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting for VP9 decoder
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (4 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 05/10] media: mediatek: vcodec: refactor setup dst buffer metadata interface for VP9 decoder Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:31 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 07/10] media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2 Kyrie Wu
` (3 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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, Kyrie Wu
From: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
add config to support prob size both 3840 and 2560.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
---
.../platform/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 | 7 +++++++
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 4 ++--
4 files changed, 12 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 a8baeab98477..ecf0d7ad0d54 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
@@ -80,10 +80,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 prob 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 a47906b9d717..99c252e0a2e1 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 dc3e9a2ccc2c..f18aafd08c76 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
@@ -841,6 +841,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 = 2560,
},
};
@@ -889,6 +890,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 = 2560,
},
};
@@ -919,6 +921,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_1,
+ .prob_size = 2560,
},
};
@@ -949,6 +952,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ .prob_size = 2560,
},
};
@@ -979,6 +983,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 = 3840,
},
};
@@ -1026,6 +1031,7 @@ 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 = 2560,
},
};
@@ -1056,5 +1062,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = {
.vp9_params = {
.level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
.profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+ .prob_size = 3840,
},
};
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 9513ddde7c7c..36a87b455d11 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))
@@ -546,6 +545,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;
@@ -616,7 +616,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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting for VP9 decoder
2025-12-02 7:40 ` [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting " Kyrie Wu
@ 2025-12-11 20:31 ` Nicolas Dufresne
2025-12-25 7:30 ` Kyrie Wu (吴晗)
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:31 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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, Kyrie Wu
[-- Attachment #1: Type: text/plain, Size: 5743 bytes --]
Hi,
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> From: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
I don't think you meant to commit with your Google partner email ?
>
> add config to support prob size both 3840 and 2560.
Prob mean probability ? Commit message is the place to you full words. Can you
extend why the difference, and use defines instead of magic number?
>
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
Or even sign it ?
Nicolas
> ---
> .../platform/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 | 7 +++++++
> .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 4 ++--
> 4 files changed, 12 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 a8baeab98477..ecf0d7ad0d54 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
> @@ -80,10 +80,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 prob 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 a47906b9d717..99c252e0a2e1 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 dc3e9a2ccc2c..f18aafd08c76 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
> @@ -841,6 +841,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 = 2560,
> },
> };
>
> @@ -889,6 +890,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 = 2560,
> },
> };
>
> @@ -919,6 +921,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_1,
> + .prob_size = 2560,
> },
> };
>
> @@ -949,6 +952,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {
> .vp9_params = {
> .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> + .prob_size = 2560,
> },
> };
>
> @@ -979,6 +983,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 = 3840,
> },
> };
>
> @@ -1026,6 +1031,7 @@ 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 = 2560,
> },
> };
>
> @@ -1056,5 +1062,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata =
> {
> .vp9_params = {
> .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> + .prob_size = 3840,
> },
> };
> 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 9513ddde7c7c..36a87b455d11 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))
> @@ -546,6 +545,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;
> @@ -616,7 +616,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;
> }
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting for VP9 decoder
2025-12-11 20:31 ` Nicolas Dufresne
@ 2025-12-25 7:30 ` Kyrie Wu (吴晗)
0 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-12-25 7:30 UTC (permalink / raw)
To: linux-kernel, linux-mediatek, George Sun (孙林),
Tiffany Lin (林慧珊),
nhebert, linux-media, devicetree, mchehab, nicolas.dufresne,
hverkuil, Kyrie Wu (吴晗),
Yunfei Dong (董云飞),
conor+dt, Irui Wang (王瑞),
robh, linux-arm-kernel, matthias.bgg, krzk+dt, arnd,
Andrew-CT Chen (陳智迪),
AngeloGioacchino Del Regno
Cc: kyrie.wu, andrzejtp2010, neil.armstrong,
Yilong Zhou (周易龙)
On Thu, 2025-12-11 at 15:31 -0500, Nicolas Dufresne wrote:
> Hi,
>
> Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> > From: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
>
> I don't think you meant to commit with your Google partner email ?
>
> >
> > add config to support prob size both 3840 and 2560.
>
> Prob mean probability ? Commit message is the place to you full
> words. Can you
> extend why the difference, and use defines instead of magic number?
>
> >
> > Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.corp-partner.google.com>
>
> Or even sign it ?
>
> Nicolas
>
Dear Nicolas,
Sorry for this mistake, I will fix it. Thanks.
Regards,
Kyrie.
> > ---
> > .../platform/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 | 7
> > +++++++
> > .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 4 ++-
> > -
> > 4 files changed, 12 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 a8baeab98477..ecf0d7ad0d54 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
> > @@ -80,10 +80,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 prob 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_sta
> > teful.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > index a47906b9d717..99c252e0a2e1 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teful.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_sta
> > teless.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > index dc3e9a2ccc2c..f18aafd08c76 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > @@ -841,6 +841,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 = 2560,
> > },
> > };
> >
> > @@ -889,6 +890,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 = 2560,
> > },
> > };
> >
> > @@ -919,6 +921,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_1,
> > + .prob_size = 2560,
> > },
> > };
> >
> > @@ -949,6 +952,7 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8195_pdata = {
> > .vp9_params = {
> > .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> > .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> > + .prob_size = 2560,
> > },
> > };
> >
> > @@ -979,6 +983,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 = 3840,
> > },
> > };
> >
> > @@ -1026,6 +1031,7 @@ 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 = 2560,
> > },
> > };
> >
> > @@ -1056,5 +1062,6 @@ const struct mtk_vcodec_dec_pdata
> > mtk_vdec_8189_pdata =
> > {
> > .vp9_params = {
> > .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2,
> > .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
> > + .prob_size = 3840,
> > },
> > };
> > 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 9513ddde7c7c..36a87b455d11 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))
> > @@ -546,6 +545,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;
> > @@ -616,7 +616,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;
> > }
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 07/10] media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (5 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 06/10] media: mediatek: vcodec: Add 4K prob size supporting " Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:32 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 08/10] media: mediatek: vcodec: Fix media device node number Kyrie Wu
` (2 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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 DRAM address of the VP9 decoder tile info buffers may require
as much as 36bits for 4096x2176 resolution. Fold the 4 most significant
bits into the lower (padding) four bits of address.
Fixes: 5d418351ca8f1 ("media: mediatek: vcodec: support stateless VP9 decoding")
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
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 36a87b455d11..eca6280098be 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
@@ -1134,9 +1134,17 @@ static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *inst
return -EINVAL;
}
tiles->size[i][j] = size;
+ /*
+ * If the system supports 64-bit DMA addresses, the upper 4 bits
+ * of the address are also encoded into the buffer entry.
+ * The buffer pointer (tb) is incremented after each entry is written.
+ */
if (tiles->mi_rows[i]) {
*tb++ = (size << 3) + ((offset << 3) & 0x7f);
- *tb++ = pa & ~0xf;
+ *tb = pa & GENMASK(31, 4);
+ if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+ *tb |= (pa >> 32) & GENMASK(3, 0);
+ tb++;
*tb++ = (pa << 3) & 0x7f;
mi_row = (tiles->mi_rows[i] - 1) & 0x1ff;
mi_col = (tiles->mi_cols[j] - 1) & 0x3f;
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 07/10] media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2
2025-12-02 7:40 ` [PATCH v6 07/10] media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2 Kyrie Wu
@ 2025-12-11 20:32 ` Nicolas Dufresne
0 siblings, 0 replies; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:32 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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
[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> The DRAM address of the VP9 decoder tile info buffers may require
> as much as 36bits for 4096x2176 resolution. Fold the 4 most significant
> bits into the lower (padding) four bits of address.
>
> Fixes: 5d418351ca8f1 ("media: mediatek: vcodec: support stateless VP9 decoding")
>
> 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/vdec/vdec_vp9_req_lat_if.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> 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 36a87b455d11..eca6280098be 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
> @@ -1134,9 +1134,17 @@ static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *inst
> return -EINVAL;
> }
> tiles->size[i][j] = size;
> + /*
> + * If the system supports 64-bit DMA addresses, the upper 4 bits
> + * of the address are also encoded into the buffer entry.
> + * The buffer pointer (tb) is incremented after each entry is written.
> + */
> if (tiles->mi_rows[i]) {
> *tb++ = (size << 3) + ((offset << 3) & 0x7f);
> - *tb++ = pa & ~0xf;
> + *tb = pa & GENMASK(31, 4);
> + if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
> + *tb |= (pa >> 32) & GENMASK(3, 0);
> + tb++;
> *tb++ = (pa << 3) & 0x7f;
> mi_row = (tiles->mi_rows[i] - 1) & 0x1ff;
> mi_col = (tiles->mi_cols[j] - 1) & 0x3f;
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 08/10] media: mediatek: vcodec: Fix media device node number
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (6 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 07/10] media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2 Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-11 20:33 ` Nicolas Dufresne
2025-12-02 7:40 ` [PATCH v6 09/10] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 10/10] media: mediatek: encoder: Add MT8189 encoder compatible data Kyrie Wu
9 siblings, 1 reply; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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
change media register device node number to a correct value.
The vfd minor is used to record the number of registered
video device nodes. The mdev_dec.devnode minor counter is
used to record the number of registered media device nodes.
Fixes: 41f03c673cb7b ("media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message")
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
.../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 2d1a545e727c..bf6e792283a1 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
@@ -493,7 +493,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_media_reg;
}
- dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor);
+ dev_dbg(&pdev->dev, "media registered as /dev/media%d",
+ dev->mdev_dec.devnode->minor);
}
mtk_vcodec_dbgfs_init(dev, false);
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v6 08/10] media: mediatek: vcodec: Fix media device node number
2025-12-02 7:40 ` [PATCH v6 08/10] media: mediatek: vcodec: Fix media device node number Kyrie Wu
@ 2025-12-11 20:33 ` Nicolas Dufresne
0 siblings, 0 replies; 21+ messages in thread
From: Nicolas Dufresne @ 2025-12-11 20:33 UTC (permalink / raw)
To: Kyrie Wu, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Hans Verkuil, 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
[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]
Le mardi 02 décembre 2025 à 15:40 +0800, Kyrie Wu a écrit :
> change media register device node number to a correct value.
> The vfd minor is used to record the number of registered
> video device nodes. The mdev_dec.devnode minor counter is
> used to record the number of registered media device nodes.
>
> Fixes: 41f03c673cb7b ("media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message")
>
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> 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 2d1a545e727c..bf6e792283a1 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
> @@ -493,7 +493,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
> goto err_media_reg;
> }
>
> - dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor);
> + dev_dbg(&pdev->dev, "media registered as /dev/media%d",
> + dev->mdev_dec.devnode->minor);
> }
>
> mtk_vcodec_dbgfs_init(dev, false);
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v6 09/10] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (7 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 08/10] media: mediatek: vcodec: Fix media device node number Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
2025-12-02 7:40 ` [PATCH v6 10/10] media: mediatek: encoder: Add MT8189 encoder compatible data Kyrie Wu
9 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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, Krzysztof Kozlowski
Add MT8189 encoder compatible string to distinguish former ICs
MTK's. Compared with MT8196, the maximum resolution of MT8189
encoder is only 4K, and the fps is only 30, which cannot reach
the highest parameter of MT8196: level6.2, 8K@60fps.
Compared with MT8188, the level can only support 5.1, which is less
than 5.2 of MT8188. But the maximum bitrate is 100Mbps, which is twice
that of MT8188. And MT8189 could support NBM mode.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../devicetree/bindings/media/mediatek,vcodec-encoder.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml
index bb4dbf23ccc5..7f355470b63c 100644
--- a/Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml
+++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml
@@ -22,6 +22,7 @@ properties:
- mediatek,mt8173-vcodec-enc
- mediatek,mt8183-vcodec-enc
- mediatek,mt8188-vcodec-enc
+ - mediatek,mt8189-vcodec-enc
- mediatek,mt8192-vcodec-enc
- mediatek,mt8195-vcodec-enc
- mediatek,mt8196-vcodec-enc
@@ -100,6 +101,7 @@ allOf:
enum:
- mediatek,mt8183-vcodec-enc
- mediatek,mt8188-vcodec-enc
+ - mediatek,mt8189-vcodec-enc
- mediatek,mt8192-vcodec-enc
- mediatek,mt8195-vcodec-enc
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH v6 10/10] media: mediatek: encoder: Add MT8189 encoder compatible data
2025-12-02 7:40 [PATCH v6 00/10] Enable video decoder & encoder for MT8189 Kyrie Wu
` (8 preceding siblings ...)
2025-12-02 7:40 ` [PATCH v6 09/10] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder Kyrie Wu
@ 2025-12-02 7:40 ` Kyrie Wu
9 siblings, 0 replies; 21+ messages in thread
From: Kyrie Wu @ 2025-12-02 7:40 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 MT8189 compatible data to initialize platform data for encoder.
Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
index 6b3d2e72fad9..2cc92a8f7a0d 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
@@ -467,6 +467,19 @@ static const struct mtk_vcodec_enc_pdata mt8196_pdata = {
.set_dma_bit_mask = true,
};
+static const struct mtk_vcodec_enc_pdata mt8189_pdata = {
+ .venc_model_num = 8189,
+ .capture_formats = mtk_video_formats_capture_h264,
+ .num_capture_formats = ARRAY_SIZE(mtk_video_formats_capture_h264),
+ .output_formats = mtk_video_formats_output,
+ .num_output_formats = ARRAY_SIZE(mtk_video_formats_output),
+ .min_bitrate = 64,
+ .max_bitrate = 100000000,
+ .core_id = VENC_SYS,
+ .uses_common_fw_iface = true,
+ .set_dma_bit_mask = true,
+};
+
static const struct of_device_id mtk_vcodec_enc_match[] = {
{.compatible = "mediatek,mt8173-vcodec-enc",
.data = &mt8173_avc_pdata},
@@ -477,6 +490,7 @@ static const struct of_device_id mtk_vcodec_enc_match[] = {
{.compatible = "mediatek,mt8192-vcodec-enc", .data = &mt8192_pdata},
{.compatible = "mediatek,mt8195-vcodec-enc", .data = &mt8195_pdata},
{.compatible = "mediatek,mt8196-vcodec-enc", .data = &mt8196_pdata},
+ {.compatible = "mediatek,mt8189-vcodec-enc", .data = &mt8189_pdata},
{},
};
MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);
--
2.45.2
^ permalink raw reply [flat|nested] 21+ messages in thread