Skip to contentSkip to conversation

Enable video decoder & encoder for MT8189

PATCH Superseded Kyrie Wu 2 participants 27 messages Nov 6, 2025 – Nov 18, 2025

Subsystems (4)

v5 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Kyrie Wu

author
#0 lore raw

v5 cover Enable video decoder & encoder for MT8189

This series have the follow changing:
Firstly add mt8189 video decoder compatible, profile and level to support MT8189 kernel driver.
Secondly fix some bugs, including vp 4K profile2 and media device node number bug.
Lastly, add mt8189 video encoder compatible.

This series has been tested with MT8189 tast test. Encoding and decoding worked for this chip.

Patches 1-2 Add decoder compatible. Patches 3 Add profile and level supporting. Patches 4 Add core-only VP9 decoding supporting. Patches 5-6 fix some bugs.
Patches 7-8 Adds encoder compatible.

---
H264 test results:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90
JVT-AVC_V1 Ran 96/135 tests successfully

VP9 test results:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90
VP9-TEST-VECTORS Ran 276/305 tests successfully

v4l2-compliance test results:
Compliance test for mtk-vcodec-enc device /dev/video2:
Total for mtk-vcodec-enc device /dev/video2: 47, Succeeded: 46, Failed: 1, Warnings: 0 Compliance test for mtk-vcodec-dec device /dev/video3:
Total for mtk-vcodec-dec device /dev/video3: 48, Succeeded: 48, Failed: 0, Warnings: 0

scp upstream link:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
dtsi upstream link:
https://lore.kernel.org/linux-mediatek/[email protected]/T/#m847e35de0a5b18fac0ca0624a8559d84964ad5c7

Changes compared with v4:
--update H264 & vp9 fluster test results
--update vp9 single core decoder prob size setting and commit messages

Changes compared with v3:
--add reviewer to commit messages --Rebased on top of the latest media tree

Changes compared with v2:
--add H264 fluster test results
--reorder compatible string for dt-bindings

Changes compared with v1:
--add v4l2-compliance test results
--add scp upstream link
--add HW difference discriptions for dt-bindings commit messages

This series patches dependent on:
[1]
https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/
[2]
https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Kyrie Wu (8):
dt-bindings: media: mediatek: decoder: Add MT8189
mediatek,vcodec-decoder
media: mediatek: vcodec: add decoder compatible to support MT8189
media: mediatek: vcodec: add profile and level supporting for MT8189
media: mediatek: vcodec: Add single core VP9 decoding support for

    MT8189

media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
media: mediatek: vcodec: fix media device node number
dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
media: mediatek: encoder: Add MT8189 encoder compatible data

 .../media/mediatek,vcodec-encoder.yaml        |  2 +
 .../media/mediatek,vcodec-subdev-decoder.yaml |  5 +-
 .../vcodec/decoder/mtk_vcodec_dec_drv.c       |  9 +++-
 .../vcodec/decoder/mtk_vcodec_dec_drv.h       |  1 +
 .../vcodec/decoder/mtk_vcodec_dec_stateless.c |  4 ++
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 48 ++++++++++++++-----
 .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++
 7 files changed, 68 insertions(+), 15 deletions(-)
Signature · 1 line
2.45.2
author
#1 lore raw

PATCH v5 1/8 dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder

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.

---
 .../bindings/media/mediatek,vcodec-subdev-decoder.yaml       | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +3 -2
index 74e1d88d3056..ee2bbbdb2d50 100644
@@ -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:
Signature · 1 line
2.45.2
author
#2 lore raw

PATCH v5 2/8 media: mediatek: vcodec: add decoder compatible to support MT8189

In reply to Kyrie Wu

MT8189 is pure single core architecture. Support its compatible and use mtk_vdec_single_core_pdata to initialize platform data.

---
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c   | 6 ++++++
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h   | 1 +
 2 files changed, 7 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +6 -0
index 6fb05bb00641..fca60e81e3c7 100644
@@ -347,6 +347,8 @@ static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev)
 		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 if (of_device_is_compatible(dev->of_node, "mediatek,mt8189-vcodec-dec"))
+		vdec_dev->chip_name = MTK_VDEC_MT8189;
 	else
 		vdec_dev->chip_name = MTK_VDEC_INVAL;
 }
@@ -574,6 +576,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
 		.compatible = "mediatek,mt8196-vcodec-dec",
 		.data = &mtk_lat_sig_core_pdata,
 	},
+	{
+		.compatible = "mediatek,mt8189-vcodec-dec",
+		.data = &mtk_vdec_single_core_pdata,
+	},
 	{},
 };
 
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +1 -0
index 429b32952194..9421fd4fda1d 100644
@@ -25,6 +25,7 @@ enum mtk_vcodec_dec_chip_name {
 	MTK_VDEC_MT8183 = 8183,
 	MTK_VDEC_MT8186 = 8186,
 	MTK_VDEC_MT8188 = 8188,
+	MTK_VDEC_MT8189 = 8189,
 	MTK_VDEC_MT8192 = 8192,
 	MTK_VDEC_MT8195 = 8195,
 	MTK_VDEC_MT8196 = 8196,
Signature · 1 line
2.45.2
#3 lore raw

Re: [PATCH v5 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189

Hi,

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 24 lines

MT8189 is pure single core architecture. Support its compatible and use mtk_vdec_single_core_pdata to initialize platform data.

---
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c   | 6 ++++++ .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h   | 1 +

 2 files changed, 7 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +2 -0
index 6fb05bb00641..fca60e81e3c7 100644
@@ -347,6 +347,8 @@ static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev)
  		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 if (of_device_is_compatible(dev->of_node, "mediatek,mt8189-vcodec-dec"))
+		vdec_dev->chip_name = MTK_VDEC_MT8189;

  else
  vdec_dev->chip_name = MTK_VDEC_INVAL; }

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c static const struct of_device_id mtk_vcodec_match[] = { · line 582

Quoted 7 lines
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +4 -0
@@ -574,6 +576,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
  		.compatible = "mediatek,mt8196-vcodec-dec",
  		.data = &mtk_lat_sig_core_pdata,
  	},
+	{
+		.compatible = "mediatek,mt8189-vcodec-dec",
+		.data = &mtk_vdec_single_core_pdata,
+	},

Maybe its just me, but its annoying that you match the compatible twice. It is of course more work to add yet another indirection for the chip_name, but considering you do 2 soc / year (and sometimes more) this will keep growing.

Opinions ? I'd don't want to block this forever, but I'd like to see some cleanup of this driver happening in the long term.

Nicolas

Quoted 15 lines
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +0 -0
  	{},
  };

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +1 -0
index 429b32952194..9421fd4fda1d 100644
@@ -25,6 +25,7 @@ enum mtk_vcodec_dec_chip_name {
  	MTK_VDEC_MT8183 = 8183,
  	MTK_VDEC_MT8186 = 8186,
  	MTK_VDEC_MT8188 = 8188,
+	MTK_VDEC_MT8189 = 8189,
  	MTK_VDEC_MT8192 = 8192,
  	MTK_VDEC_MT8195 = 8195,
  	MTK_VDEC_MT8196 = 8196,
#4 lore raw

Re: [PATCH v5 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189

Quoted 56 lines · Nicolas Dufresne

Hi,

Quoted 37 lines · Kyrie Wu

MT8189 is pure single core architecture. Support its compatible and use mtk_vdec_single_core_pdata to initialize platform data.

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c   | 6
++++++
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h   | 1 +
 2 files changed, 7 insertions(+)

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..fca60e81e3c7 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

(quoted diff) +2 -0
@@ -347,6 +347,8 @@ static void mtk_vcodec_dec_get_chip_name(struct
 mtk_vcodec_dec_dev *vdec_dev)
 		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 if (of_device_is_compatible(dev->of_node,
 "mediatek,mt8189-vcodec-dec"))
+		vdec_dev->chip_name = MTK_VDEC_MT8189;
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +0 -0
 	else
 		vdec_dev->chip_name = MTK_VDEC_INVAL;
 }

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c static const struct of_device_id · line 583

Quoted 8 lines
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +4 -0
@@ -574,6 +576,10 @@ static const struct of_device_id
 mtk_vcodec_match[] = {
 		.compatible = "mediatek,mt8196-vcodec-dec",
 		.data = &mtk_lat_sig_core_pdata,
 	},
+	{
+		.compatible = "mediatek,mt8189-vcodec-dec",
+		.data = &mtk_vdec_single_core_pdata,
+	},

Maybe its just me, but its annoying that you match the compatible twice. It is
of course more work to add yet another indirection for the chip_name, but
considering you do 2 soc / year (and sometimes more) this will keep growing.

Quoted 5 lines

Opinions ? I'd don't want to block this forever, but I'd like to see some
cleanup of this driver happening in the long term.

Nicolas

Dear Nicolas,

I will add this setting to compitable pdata in the next version.

Thanks.

Regards,
Kyrie

Quoted 24 lines
Quoted 24 lines
(quoted diff) +0 -0
 	{},
 };

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..9421fd4fda1d 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

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +1 -0
@@ -25,6 +25,7 @@ enum mtk_vcodec_dec_chip_name {
 	MTK_VDEC_MT8183 = 8183,
 	MTK_VDEC_MT8186 = 8186,
 	MTK_VDEC_MT8188 = 8188,
+	MTK_VDEC_MT8189 = 8189,
 	MTK_VDEC_MT8192 = 8192,
 	MTK_VDEC_MT8195 = 8195,
 	MTK_VDEC_MT8196 = 8196,
author
#5 lore raw

PATCH v5 3/8 media: mediatek: vcodec: add profile and level supporting for MT8189

In reply to Kyrie Wu

add profile and level supporting for H264 and vp9 of MT8189

---
 .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c        | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +4 -0
index c1cef78471a9..0a9bdc5316f9 100644
@@ -552,6 +552,7 @@ static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg,
 	switch (ctx->dev->chip_name) {
 	case MTK_VDEC_MT8192:
 	case MTK_VDEC_MT8188:
+	case MTK_VDEC_MT8189:
 		cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_5_2;
 		break;
 	case MTK_VDEC_MT8195:
@@ -573,6 +574,7 @@ static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg,
 {
 	switch (ctx->dev->chip_name) {
 	case MTK_VDEC_MT8188:
+	case MTK_VDEC_MT8189:
 	case MTK_VDEC_MT8195:
 	case MTK_VDEC_MT8196:
 		cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;
@@ -623,6 +625,7 @@ static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg,
 	case MTK_VDEC_MT8188:
 		cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1;
 		break;
+	case MTK_VDEC_MT8189:
 	case MTK_VDEC_MT8195:
 	case MTK_VDEC_MT8196:
 		cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2;
@@ -641,6 +644,7 @@ static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2_ctrl_config *cfg,
 {
 	switch (ctx->dev->chip_name) {
 	case MTK_VDEC_MT8188:
+	case MTK_VDEC_MT8189:
 	case MTK_VDEC_MT8195:
 	case MTK_VDEC_MT8196:
 		cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;
Signature · 1 line
2.45.2
#6 lore raw

Re: [PATCH v5 3/8] media: mediatek: vcodec: add profile and level supporting for MT8189

Hi,

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 17 lines

add profile and level supporting for H264 and vp9 of MT8189

---
 .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c        | 4 ++++

 1 file changed, 4 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +0 -0
index c1cef78471a9..0a9bdc5316f9 100644
@@ -552,6 +552,7 @@ static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg,
  	switch (ctx->dev->chip_name) {

  case MTK_VDEC_MT8192:
  case MTK_VDEC_MT8188:

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +1 -0
+	case MTK_VDEC_MT8189:
Quoted 1 line

  cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_5_2;

Please consider my suggestion in 2/8, you could then move all of this into the static compatible data structure.

Nicolas

Quoted 26 lines

  break;
  case MTK_VDEC_MT8195:

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +0 -0
@@ -573,6 +574,7 @@ static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg,
  {
  	switch (ctx->dev->chip_name) {

  case MTK_VDEC_MT8188:

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +1 -0
+	case MTK_VDEC_MT8189:

  case MTK_VDEC_MT8195:
  case MTK_VDEC_MT8196:
  cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10;

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +0 -0
@@ -623,6 +625,7 @@ static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg,

  case MTK_VDEC_MT8188:
  cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1; break;

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +1 -0
+	case MTK_VDEC_MT8189:

  case MTK_VDEC_MT8195:
  case MTK_VDEC_MT8196:
  cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2;

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +0 -0
@@ -641,6 +644,7 @@ static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2_ctrl_config *cfg,
  {
  	switch (ctx->dev->chip_name) {

  case MTK_VDEC_MT8188:

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +1 -0
+	case MTK_VDEC_MT8189:

  case MTK_VDEC_MT8195:
  case MTK_VDEC_MT8196:
  cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2;

author
#7 lore raw

PATCH v5 4/8 media: mediatek: vcodec: Add single core VP9 decoding support for MT8189

In reply to Kyrie Wu

1. add config to support 4K prob size;
2. 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.

---
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 43 ++++++++++++++-----
 1 file changed, 32 insertions(+), 11 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +32 -11
index fa0f406f7726..d966914db4b9 100644
@@ -23,6 +23,7 @@
 
 #define VP9_TILE_BUF_SIZE 4096
 #define VP9_PROB_BUF_SIZE 2560
+#define VP9_PROB_BUF_4K_SIZE 3840
 #define VP9_COUNTS_BUF_SIZE 16384
 
 #define HDR_FLAG(x) (!!((hdr)->flags & V4L2_VP9_FRAME_FLAG_##x))
@@ -542,6 +543,23 @@ static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance
 	return ret;
 }
 
+static size_t mtk_vcodec_get_vp9_prob_size(enum mtk_vcodec_dec_chip_name chip_name)
+{
+	size_t prob_size;
+
+	switch (chip_name) {
+	case MTK_VDEC_MT8189:
+	case MTK_VDEC_MT8196:
+		prob_size = VP9_PROB_BUF_4K_SIZE;
+		break;
+	default:
+		prob_size = VP9_PROB_BUF_SIZE;
+		break;
+	}
+
+	return prob_size;
+}
+
 static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *instance,
 					       struct vdec_vp9_slice_vsi *vsi)
 {
@@ -616,7 +634,9 @@ 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 =
+			mtk_vcodec_get_vp9_prob_size(ctx->dev->chip_name);
+
 		if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
 			goto err;
 	}
@@ -696,21 +716,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 +1821,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;
 
Signature · 1 line
2.45.2
#8 lore raw

Re: [PATCH v5 4/8] media: mediatek: vcodec: Add single core VP9 decoding support for MT8189

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 6 lines

1. add config to support 4K prob size;
2. 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.

Please avoid using bullets in commit messages. Everyone will assume that if you have two bullets, you should have two patches. And I think they would be right for this patch.

Quoted 28 lines

---
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 43 ++++++++++++++-----

 1 file changed, 32 insertions(+), 11 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
index fa0f406f7726..d966914db4b9 100644
@@ -23,6 +23,7 @@


 #define VP9_TILE_BUF_SIZE 4096
 #define VP9_PROB_BUF_SIZE 2560
+#define VP9_PROB_BUF_4K_SIZE 3840
 #define VP9_COUNTS_BUF_SIZE 16384

 #define HDR_FLAG(x) (!!((hdr)->flags & V4L2_VP9_FRAME_FLAG_##x))

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
@@ -542,6 +543,23 @@ static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance
  	return ret;
  }

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +6 -0
+static size_t mtk_vcodec_get_vp9_prob_size(enum mtk_vcodec_dec_chip_name chip_name)
+{
+	size_t prob_size;
+
+	switch (chip_name) {
+	case MTK_VDEC_MT8189:

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance · line 561

Quoted 10 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +10 -0
+	case MTK_VDEC_MT8196:
+		prob_size = VP9_PROB_BUF_4K_SIZE;
+		break;
+	default:
+		prob_size = VP9_PROB_BUF_SIZE;
+		break;
+	}
+
+	return prob_size;
+}

This is another example of something that could be in the static compatible data.

Quoted 51 lines

+
 static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *instance, struct vdec_vp9_slice_vsi *vsi) {

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
@@ -616,7 +634,9 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i
  	}


  if (!instance->prob.va) {

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +3 -1
-		instance->prob.size = VP9_PROB_BUF_SIZE;
+		instance->prob.size =
+			mtk_vcodec_get_vp9_prob_size(ctx->dev->chip_name);
+

  if (mtk_vcodec_mem_alloc(ctx, &instance->prob)) goto err;
  }

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
@@ -696,21 +716,22 @@ static int vdec_vp9_slice_tile_offset(int idx, int mi_num, int tile_log2)
  	return min(offset, mi_num);
  }

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +3 -2
-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)

 {

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -2
-	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;

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -2
-	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;

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -2
-	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;

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +1 -1
-	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;
 }

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
@@ -1800,7 +1821,7 @@ static int vdec_vp9_slice_setup_single(struct vdec_vp9_slice_instance *instance,
  	struct vdec_vp9_slice_vsi *vsi = &pfc->vsi;
  	int ret;

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_setup_single(struct vdec_vp9_slice_instance *instance, · line 1824

Quoted 2 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +1 -1
-	ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance);
+	ret = vdec_vp9_slice_setup_single_from_src_to_dst(instance, bs, fb);

I don't see a direct correlation betwen the buffer size change and this change. Please split. Changes looks good, the commit message isn't very clear though.

Nicolas

Quoted 3 lines

  if (ret)
  goto err;

#9 lore raw

Re: [PATCH v5 4/8] media: mediatek: vcodec: Add single core VP9 decoding support for MT8189

Quoted 9 lines · Nicolas Dufresne
Quoted 7 lines · Kyrie Wu

1. add config to support 4K prob size;
2. 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.

Quoted 6 lines

Please avoid using bullets in commit messages. Everyone will assume that if you
have two bullets, you should have two patches. And I think they would be right
for this patch.

Dear Nicolas,

Thanks for your suggestion. I will change it in the next version.

Quoted 46 lines
Quoted 46 lines
---
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 43 ++++++++++++++-
----
 1 file changed, 32 insertions(+), 11 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..d966914db4b9 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

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +1 -0
@@ -23,6 +23,7 @@
 
 #define VP9_TILE_BUF_SIZE 4096
 #define VP9_PROB_BUF_SIZE 2560
+#define VP9_PROB_BUF_4K_SIZE 3840
 #define VP9_COUNTS_BUF_SIZE 16384
 
 #define HDR_FLAG(x) (!!((hdr)->flags & V4L2_VP9_FRAME_FLAG_##x))
@@ -542,6 +543,23 @@ static int

vdec_vp9_slice_init_default_frame_ctx(struct
vdec_vp9_slice_instance

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +1 -0
 	return ret;
 }
 
+static size_t mtk_vcodec_get_vp9_prob_size(enum

mtk_vcodec_dec_chip_name chip_name)

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +11 -0
+{
+	size_t prob_size;
+
+	switch (chip_name) {
+	case MTK_VDEC_MT8189:
+	case MTK_VDEC_MT8196:
+		prob_size = VP9_PROB_BUF_4K_SIZE;
+		break;
+	default:
+		prob_size = VP9_PROB_BUF_SIZE;
+		break;
Quoted 9 lines

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance · line 561

Quoted 4 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +4 -0
+	}
+
+	return prob_size;
+}

This is another example of something that could be in the static compatible
data.

This will reply in 2/8.

Thanks.

Quoted 74 lines
Quoted 61 lines

+
static int vdec_vp9_slice_alloc_working_buffer(struct
vdec_vp9_slice_instance *instance,
struct
vdec_vp9_slice_vsi *vsi)
{

(quoted diff) +0 -0
@@ -616,7 +634,9 @@ static int

vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -1
 	}
 
 	if (!instance->prob.va) {
-		instance->prob.size = VP9_PROB_BUF_SIZE;
+		instance->prob.size =
+			mtk_vcodec_get_vp9_prob_size(ctx->dev-
Quoted 1 line

chip_name);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +9 -8
+
 		if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
 			goto err;
 	}
@@ -696,21 +716,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);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -1
+	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);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
 	return 0;
 }

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_setup_single(struct · line 1826

Quoted 7 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +1 -1
@@ -1800,7 +1821,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);

I don't see a direct correlation betwen the buffer size change and this change.
Please split. Changes looks good, the commit message isn't very clear though.

Quoted 1 line

Nicolas

Thanks. I will split this in two: the one is set tile buffer, and the other is setup src to dst buffer.

Regards,
Kyrie

Quoted 4 lines
Quoted 4 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
 	if (ret)

goto err;

author
#10 lore raw

PATCH v5 5/8 media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

In reply to Kyrie Wu

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless VP9 decoding")
---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c       | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +4 -1
index d966914db4b9..91c563c049bd 100644
@@ -1156,7 +1156,10 @@ static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *inst
 			tiles->size[i][j] = size;
 			if (tiles->mi_rows[i]) {
 				*tb++ = (size << 3) + ((offset << 3) & 0x7f);
-				*tb++ = pa & ~0xf;
+				*tb = pa & ~0xf;
+				if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+					*tb |= (pa >> 32) & 0xf;
+				tb++;
 				*tb++ = (pa << 3) & 0x7f;
 				mi_row = (tiles->mi_rows[i] - 1) & 0x1ff;
 				mi_col = (tiles->mi_cols[j] - 1) & 0x3f;
Signature · 1 line
2.45.2
#11 lore raw

Re: [PATCH v5 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

Hi,

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 4 lines

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

Please rework that commit message. Perhaps:

The DRAM address of the VP9 decoder mode info (MI) buffers may require as much as 36bits for 4096x2176 resolution. Fold the 4 most significant bits into the lower (padding) four bits of address.

Quoted 14 lines
Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless VP9 decoding")

---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c       | 5 ++++-

 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
index d966914db4b9..91c563c049bd 100644

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_setup_tile_buffer:q(struct vdec_vp9_slice_instance *inst · line 1162

Quoted 8 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +4 -1
@@ -1156,7 +1156,10 @@ static int vdec_vp9_slice_setup_tile_buffer:q(struct vdec_vp9_slice_instance *inst
  			tiles->size[i][j] = size;
  			if (tiles->mi_rows[i]) {
  				*tb++ = (size << 3) + ((offset << 3) & 0x7f);
-				*tb++ = pa & ~0xf;
+				*tb = pa & ~0xf;
+				if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+					*tb |= (pa >> 32) & 0xf;
+				tb++;

You are following the style here, so no complaints, though the macros GENMASK(3, 0) instead of 0xf and GENMASK(31, 4) instead of ~0xf is another way to write this code.

Since this is not always obvious when the alignment padding of an address is being reused to extend the number of bits of an address, it would be nice if you add a comment explaining in words what his is doing.

cheers,
Nicolas

Quoted 3 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
  				*tb++ = (pa << 3) & 0x7f;
  				mi_row = (tiles->mi_rows[i] - 1) & 0x1ff;
  				mi_col = (tiles->mi_cols[j] - 1) & 0x3f;
#12 lore raw

Re: [PATCH v5 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

Quoted 8 lines · Nicolas Dufresne

Hi,

Quoted 4 lines · Kyrie Wu

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

Quoted 8 lines

Please rework that commit message. Perhaps:

The DRAM address of the VP9 decoder mode info (MI) buffers may
require
as much as 36bits for 4096x2176 resolution. Fold the 4 most
significant
bits into the lower (padding) four bits of address.

Dear Nicolas,

Thanks for your guidance, I will change the commit message in the next version.

Quoted 34 lines
Quoted 34 lines
Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless

VP9 decoding")

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c       | 5
++++-
 1 file changed, 4 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 d966914db4b9..91c563c049bd 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

(quoted diff) +0 -0
@@ -1156,7 +1156,10 @@ static int

vdec_vp9_slice_setup_tile_buffer:q(struct vdec_vp9_slice_instance *inst

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
 			tiles->size[i][j] = size;
 			if (tiles->mi_rows[i]) {
 				*tb++ = (size << 3) + ((offset << 3) &

0x7f);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -1
-				*tb++ = pa & ~0xf;
+				*tb = pa & ~0xf;
+				if
Quoted 8 lines

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *inst · line 1162

Quoted 3 lines

(IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -0
+					*tb |= (pa >> 32) & 0xf;
+				tb++;

You are following the style here, so no complaints, though the macros GENMASK(3, 0) instead of 0xf and GENMASK(31, 4) instead of ~0xf is another way
to write this code.

Thanks. I will use GENMASK(3, 0)/GENMASK(31, 4) to replace 0xf/~0xf in the next version.

Quoted 9 lines

Since this is not always obvious when the alignment padding of an address is
being reused to extend the number of bits of an address, it would be nice if you
add a comment explaining in words what his is doing.

cheers,
Nicolas

OK, I will add comment before the line of if (tiles->mi_rows[i]) { ...

Regards,
Kyrie

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -0
 				*tb++ = (pa << 3) & 0x7f;
 				mi_row = (tiles->mi_rows[i] - 1) &

0x1ff;
mi_col = (tiles->mi_cols[j] - 1) &
0x3f;

#13 lore raw

Re: [PATCH v5 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

In reply to Kyrie Wu

Hi,

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 4 lines

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

An after thought, I don't see any call to vb2_dma_contig_set_max_seg_size() or dma_set_coherent_mask() with DMA_BIT_MASK(32)/DMA_BIT_MASK(36) in this driver. How do you control this ?

Nicolas

Quoted 32 lines
Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless VP9

decoding")

Reviewed-by AngeloGioacchino Del Regno

<[email protected]>
---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c       | 5 ++++-

 1 file changed, 4 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 d966914db4b9..91c563c049bd 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

(quoted diff) +0 -0
@@ -1156,7 +1156,10 @@ static int vdec_vp9_slice_setup_tile_buffer(struct

vdec_vp9_slice_instance *inst
  tiles->size[i][j] = size;
  if (tiles->mi_rows[i]) {
  *tb++ = (size << 3) + ((offset << 3) & 0x7f);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +4 -1
-				*tb++ = pa & ~0xf;
+				*tb = pa & ~0xf;
+				if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+					*tb |= (pa >> 32) & 0xf;
+				tb++;

  *tb++ = (pa << 3) & 0x7f; mi_row = (tiles->mi_rows[i] - 1) & 0x1ff; mi_col = (tiles->mi_cols[j] - 1) & 0x3f;

#14 lore raw

Re: [PATCH v5 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

Quoted 8 lines · Nicolas Dufresne

Hi,

Quoted 4 lines · Kyrie Wu

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

Quoted 7 lines

An after thought, I don't see any call to vb2_dma_contig_set_max_seg_size() or dma_set_coherent_mask() with DMA_BIT_MASK(32)/DMA_BIT_MASK(36) in this driver.
How do you control this ?

Nicolas

Dear Nicolas,

The tile buffer is handled in VCP, not in kernel driver. We only get the full correct address in kernel.

Thanks.

Regards,
Kyrie

Quoted 44 lines
Quoted 44 lines
Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless

VP9
decoding")

Reviewed-by AngeloGioacchino Del Regno

<[email protected]>

---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c       | 5
++++-
 1 file changed, 4 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 d966914db4b9..91c563c049bd 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

(quoted diff) +0 -0
@@ -1156,7 +1156,10 @@ static int

vdec_vp9_slice_setup_tile_buffer(struct
vdec_vp9_slice_instance *inst

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +0 -0
 			tiles->size[i][j] = size;
 			if (tiles->mi_rows[i]) {
 				*tb++ = (size << 3) + ((offset << 3) &

0x7f);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -1
-				*tb++ = pa & ~0xf;
+				*tb = pa & ~0xf;
+				if

(IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -0
+					*tb |= (pa >> 32) & 0xf;
+				tb++;
 				*tb++ = (pa << 3) & 0x7f;
 				mi_row = (tiles->mi_rows[i] - 1) &

0x1ff;
mi_col = (tiles->mi_cols[j] - 1) &
0x3f;

#15 lore raw

Re: [PATCH v5 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2

Hi Kyrie,

make sure to reply in plain text, I know the mailing list may drop messaged in HTML form.

Le lundi 17 novembre 2025 à 07:36 +0000, Kyrie Wu (吴晗) a écrit :

Quoted 16 lines · Nicolas Dufresne
Quoted 14 lines

Hi,

Quoted 4 lines · Kyrie Wu

The dram addr of vp9 decoder tile number, which use dram mode to set tile information, may reach to 36bits for 4096x2176. It needs to get the highest 4bit of tile buffer address to set tile buffer address.

An after thought, I don't see any call to vb2_dma_contig_set_max_seg_size() or dma_set_coherent_mask() with DMA_BIT_MASK(32)/DMA_BIT_MASK(36) in this driver.
How do you control this ?

Quoted 6 lines
Quoted 1 line

Nicolas

Dear Nicolas,

The tile buffer is handled in VCP, not in kernel driver. We only get the full correct address in kernel.

Thank you, I could not figure-out otherwise.

Nicolas

Quoted 64 lines

Thanks.

Regards,
Kyrie

Quoted 36 lines
Quoted 36 lines
Fixes 5d418351ca8f1 ("media: mediatek: vcodec: support stateless

VP9
decoding")

Reviewed-by AngeloGioacchino Del Regno

<[email protected]>
---
 .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 5
++++-

 1 file changed, 4 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 d966914db4b9..91c563c049bd 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

(quoted diff) +0 -0
@@ -1156,7 +1156,10 @@ static int

vdec_vp9_slice_setup_tile_buffer(struct
vdec_vp9_slice_instance *inst
 tiles->size[i][j] = size;
 if (tiles->mi_rows[i]) {
 *tb++ = (size << 3) + ((offset << 3) &
0x7f);

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -1
-*tb++ = pa & ~0xf;
+*tb = pa & ~0xf;
+if
Quoted 8 lines
Quoted 8 lines

(IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -0
+*tb |= (pa >> 32) & 0xf;
+tb++;

 *tb++ = (pa << 3) & 0x7f;
 mi_row = (tiles->mi_rows[i] - 1) &
0x1ff;
 mi_col = (tiles->mi_cols[j] - 1) &
0x3f;

************* MEDIATEK Confidentiality Notice
 ********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

author
#16 lore raw

PATCH v5 6/8 media: mediatek: vcodec: fix media device node number

In reply to Kyrie Wu

change media register device node number to a correct value

Fixes 41f03c673cb7b ("media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message")
---
 .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +2 -1
index fca60e81e3c7..f3e49597602a 100644
@@ -516,7 +516,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);
Signature · 1 line
2.45.2
#17 lore raw

Re: [PATCH v5 6/8] media: mediatek: vcodec: fix media device node number

Hi,

fix -> Fix

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 1 line

change media register device node number to a correct value

You already say that in the subject, the description should explain why vfd_dec-

Quoted 1 line

minor was wrong.

Nicolas

Quoted 26 lines
Fixes 41f03c673cb7b ("media: mediatek: vcodec: replace pr_* with dev_* for

v4l2 debug message")

---
 .../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 fca60e81e3c7..f3e49597602a 100644

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +0 -0
@@ -516,7 +516,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
  			goto err_media_reg;
  		}

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +0 -1
-		dev_dbg(&pdev->dev, "media registered as /dev/media%d",

vfd_dec->minor);

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +2 -0
+		dev_dbg(&pdev->dev, "media registered as /dev/media%d",
+			dev->mdev_dec.devnode->minor);

  }

  mtk_vcodec_dbgfs_init(dev, false);

#18 lore raw

Re: [PATCH v5 6/8] media: mediatek: vcodec: fix media device node number

Quoted 4 lines · Nicolas Dufresne

Hi,

fix -> Fix

Quoted 8 lines
Quoted 1 line · Kyrie Wu

change media register device node number to a correct value

You already say that in the subject, the description should explain why vfd_dec-

Quoted 1 line

minor was wrong.

Nicolas

Dear Nicolas,

I will explain it in the next version.

Thanks.

Regards,
Kyrie

Quoted 37 lines
Quoted 37 lines
Fixes 41f03c673cb7b ("media: mediatek: vcodec: replace pr_* with

dev_* for
v4l2 debug message")

---
 .../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 fca60e81e3c7..f3e49597602a 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

drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +2 -1
@@ -516,7 +516,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);

author
#19 lore raw

PATCH v5 7/8 dt-bindings: media: Add MT8189 mediatek,vcodec-encoder

In reply to Kyrie Wu

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.

---
 .../devicetree/bindings/media/mediatek,vcodec-encoder.yaml      | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml +2 -0
index bb4dbf23ccc5..7f355470b63c 100644
@@ -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
 
Signature · 1 line
2.45.2
author
#20 lore raw

PATCH v5 8/8 media: mediatek: encoder: Add MT8189 encoder compatible data

In reply to Kyrie Wu

add compatible data to support MT8189 encoding.

---
 .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +14 -0
index 6b3d2e72fad9..2cc92a8f7a0d 100644
@@ -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);
Signature · 1 line
2.45.2
#21 lore raw

Re: [PATCH v5 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 1 line

add compatible data to support MT8189 encoding.

Don't copy your subject, briefly describe the configuration instead.

Nicolas

Quoted 43 lines
Reviewed-by AngeloGioacchino Del Regno

<[email protected]>
---
 .../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

drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +0 -0
@@ -467,6 +467,19 @@ static const struct mtk_vcodec_enc_pdata mt8196_pdata = {
  	.set_dma_bit_mask = true,
  };

drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +13 -0
+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},

drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +1 -0
@@ -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);

#22 lore raw

Re: [PATCH v5 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data

Quoted 7 lines · Nicolas Dufresne
Quoted 1 line · Kyrie Wu

add compatible data to support MT8189 encoding.

Don't copy your subject, briefly describe the configuration instead.

Nicolas

Dear Nicolas,

Thanks for your reminding, I will fix the subject and commit messages in the coming version.

Thanks.

Regards,
Kyrie

Quoted 57 lines
Quoted 57 lines
Reviewed-by AngeloGioacchino Del Regno

<[email protected]>

---
 .../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

drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +13 -0
@@ -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[] = {
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +0 -0
 	{.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},

(quoted diff) +1 -0
+	{.compatible = "mediatek,mt8189-vcodec-enc", .data =

&mt8189_pdata},
{},
};
MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);

#23 lore raw
In reply to Kyrie Wu

Hi,

Le jeudi 06 novembre 2025 à 14:13 +0800, Kyrie Wu a écrit :

Quoted 21 lines

This series have the follow changing:
Firstly add mt8189 video decoder compatible, profile and level to support MT8189 kernel driver.
Secondly fix some bugs, including vp 4K profile2 and media device node number bug.
Lastly, add mt8189 video encoder compatible.

This series has been tested with MT8189 tast test. Encoding and decoding worked for this chip.

Patches 1-2 Add decoder compatible. Patches 3 Add profile and level supporting. Patches 4 Add core-only VP9 decoding supporting. Patches 5-6 fix some bugs.
Patches 7-8 Adds encoder compatible.

---
H264 test results:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90
    JVT-AVC_V1 Ran 96/135 tests successfully

Quoted 7 lines

VP9 test results:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90
VP9-TEST-VECTORS Ran 276/305 tests successfully

v4l2-compliance test results:
Compliance test for mtk-vcodec-enc device /dev/video2:
Total for mtk-vcodec-enc device /dev/video2: 47, Succeeded: 46, Failed: 1, Warnings: 0

There is one fail, can you explain it ?

Nicolas

Quoted 51 lines

Compliance test for mtk-vcodec-dec device /dev/video3:
Total for mtk-vcodec-dec device /dev/video3: 48, Succeeded: 48, Failed: 0, Warnings: 0

scp upstream link:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
dtsi upstream link:
https://lore.kernel.org/linux-mediatek/[email protected]/T/#m847e35de0a5b18fac0ca0624a8559d84964ad5c7

Changes compared with v4:
--update H264 & vp9 fluster test results
--update vp9 single core decoder prob size setting and commit messages

Changes compared with v3:
--add reviewer to commit messages --Rebased on top of the latest media tree

Changes compared with v2:
--add H264 fluster test results
--reorder compatible string for dt-bindings

Changes compared with v1:
--add v4l2-compliance test results
--add scp upstream link
--add HW difference discriptions for dt-bindings commit messages

This series patches dependent on:
[1]
https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/
[2]
https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Kyrie Wu (8):
  dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
  media: mediatek: vcodec: add decoder compatible to support MT8189
  media: mediatek: vcodec: add profile and level supporting for MT8189
  media: mediatek: vcodec: Add single core VP9 decoding support for MT8189
  media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
  media: mediatek: vcodec: fix media device node number
  dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
  media: mediatek: encoder: Add MT8189 encoder compatible data

 .../media/mediatek,vcodec-encoder.yaml        |  2 + .../media/mediatek,vcodec-subdev-decoder.yaml |  5 +- .../vcodec/decoder/mtk_vcodec_dec_drv.c       |  9 +++- .../vcodec/decoder/mtk_vcodec_dec_drv.h       |  1 + .../vcodec/decoder/mtk_vcodec_dec_stateless.c |  4 ++ .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 48 ++++++++++++++----- .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++

 7 files changed, 68 insertions(+), 15 deletions(-)
#24 lore raw
Quoted 30 lines · Nicolas Dufresne

Hi,

Quoted 27 lines · Kyrie Wu

This series have the follow changing:
Firstly add mt8189 video decoder compatible, profile and level to support
MT8189 kernel driver.
Secondly fix some bugs, including vp 4K profile2 and media device node
number bug.
Lastly, add mt8189 video encoder compatible.

This series has been tested with MT8189 tast test. Encoding and decoding worked for this chip.

Patches 1-2 Add decoder compatible.
Patches 3 Add profile and level supporting.
Patches 4 Add core-only VP9 decoding supporting.
Patches 5-6 fix some bugs.
Patches 7-8 Adds encoder compatible.

---
H264 test results:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90
JVT-AVC_V1 Ran 96/135 tests successfully

VP9 test results:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90
VP9-TEST-VECTORS Ran 276/305 tests successfully

Quoted 8 lines
Quoted 4 lines

v4l2-compliance test results:
Compliance test for mtk-vcodec-enc device /dev/video2:
Total for mtk-vcodec-enc device /dev/video2: 47, Succeeded: 46,
Failed: 1, Warnings: 0

There is one fail, can you explain it ?

Nicolas

Dear Nicolas,

The failure is caused by subscribed event/dqevent. Our encoder driver didn't register those apis, which caused this failure. Here is the fail log, which is samed as MT8196:

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
fail: v4l2-test-controls.cpp(1171): node->codec_mask &
STATEFUL_ENCODER
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 16 Private Controls: 0

Thanks.

Regards,
Kyrie.

Quoted 7 lines
Quoted 7 lines

Compliance test for mtk-vcodec-dec device /dev/video3:
Total for mtk-vcodec-dec device /dev/video3: 48, Succeeded: 48,
Failed: 0, Warnings: 0

scp upstream link:

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Quoted 2 lines
Quoted 2 lines

dtsi upstream link:

https://lore.kernel.org/linux-mediatek/[email protected]/T/#m847e35de0a5b18fac0ca0624a8559d84964ad5c7

Quoted 14 lines
Quoted 14 lines

Changes compared with v4:
--update H264 & vp9 fluster test results
--update vp9 single core decoder prob size setting and commit messages

Changes compared with v3:
--add reviewer to commit messages
--Rebased on top of the latest media tree

Changes compared with v2:
--add H264 fluster test results
--reorder compatible string for dt-bindings

Quoted 8 lines
Quoted 8 lines

Changes compared with v1:
--add v4l2-compliance test results
--add scp upstream link
--add HW difference discriptions for dt-bindings commit messages

This series patches dependent on:
[1]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 2 lines
Quoted 2 lines

[2]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 23 lines
Quoted 23 lines

Kyrie Wu (8):
dt-bindings: media: mediatek: decoder: Add MT8189
mediatek,vcodec-decoder
media: mediatek: vcodec: add decoder compatible to support MT8189
media: mediatek: vcodec: add profile and level supporting for
MT8189
media: mediatek: vcodec: Add single core VP9 decoding support for

    MT8189

media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
media: mediatek: vcodec: fix media device node number
dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
media: mediatek: encoder: Add MT8189 encoder compatible data

 .../media/mediatek,vcodec-encoder.yaml        |  2 +
 .../media/mediatek,vcodec-subdev-decoder.yaml |  5 +-
 .../vcodec/decoder/mtk_vcodec_dec_drv.c       |  9 +++-
 .../vcodec/decoder/mtk_vcodec_dec_drv.h       |  1 +
 .../vcodec/decoder/mtk_vcodec_dec_stateless.c |  4 ++
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 48 ++++++++++++++-
----
 .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++
 7 files changed, 68 insertions(+), 15 deletions(-)
#25 lore raw

Le lundi 10 novembre 2025 à 02:32 +0000, Kyrie Wu (吴晗) a écrit :

Quoted 49 lines · Nicolas Dufresne
Quoted 30 lines

Hi,

Quoted 27 lines · Kyrie Wu

This series have the follow changing:
Firstly add mt8189 video decoder compatible, profile and level to support
MT8189 kernel driver.
Secondly fix some bugs, including vp 4K profile2 and media device node
number bug.
Lastly, add mt8189 video encoder compatible.

This series has been tested with MT8189 tast test. Encoding and decoding worked for this chip.

Patches 1-2 Add decoder compatible.
Patches 3 Add profile and level supporting.
Patches 4 Add core-only VP9 decoding supporting.
Patches 5-6 fix some bugs.
Patches 7-8 Adds encoder compatible.

---
H264 test results:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90 JVT-AVC_V1Ran 96/135 tests successfully

VP9 test results:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90 VP9-TEST-VECTORSRan 276/305 tests successfully

Quoted 8 lines
Quoted 4 lines

v4l2-compliance test results:
Compliance test for mtk-vcodec-enc device /dev/video2:
Total for mtk-vcodec-enc device /dev/video2: 47, Succeeded: 46,
Failed: 1, Warnings: 0

There is one fail, can you explain it ?

Nicolas

Dear Nicolas,

The failure is caused by subscribed event/dqevent. Our encoder driver didn't register those apis, which caused this failure. Here is the fail log, which is samed as MT8196:

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 10 lines

Control ioctls:
        test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
        test VIDIOC_QUERYCTRL: OK
        test VIDIOC_G/S_CTRL: OK
        test VIDIOC_G/S/TRY_EXT_CTRLS: OK
                fail: v4l2-test-controls.cpp(1171): node->codec_mask & STATEFUL_ENCODER
        test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
        test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 16 Private Controls: 0

The spec says:

For backwards compatibility, the encoder will signal a V4L2_EVENT_EOS event when the last frame has been encoded and all frames are ready to be dequeued.

In practice, we test for that on every m2m, see the test code:

	if (node->is_m2m) {
		node_m2m_cap->g_fmt(fmt_q, m2m_q.g_type());
		if (node_m2m_cap->buftype_pixfmts[m2m_q.g_type()][fmt_q.g_pixelformat()] &
			V4L2_FMT_FLAG_COMPRESSED)
			valid_output_flags = V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TSTAMP_SRC_MASK;

		struct v4l2_event_subscription sub = { 0 };

		sub.type = V4L2_EVENT_EOS;
		if (node->codec_mask & (STATEFUL_ENCODER | STATEFUL_DECODER))
			doioctl(node, VIDIOC_SUBSCRIBE_EVENT, &sub);
	}

please fix,
Nicolas

Quoted 81 lines

Thanks.

Regards,
Kyrie.

Quoted 7 lines
Quoted 7 lines

Compliance test for mtk-vcodec-dec device /dev/video3:
Total for mtk-vcodec-dec device /dev/video3: 48, Succeeded: 48,
Failed: 0, Warnings: 0

scp upstream link:

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Quoted 2 lines
Quoted 2 lines

dtsi upstream link:

https://lore.kernel.org/linux-mediatek/[email protected]/T/#m847e35de0a5b18fac0ca0624a8559d84964ad5c7

Quoted 14 lines
Quoted 14 lines

Changes compared with v4:
--update H264 & vp9 fluster test results
--update vp9 single core decoder prob size setting and commit messages

Changes compared with v3:
--add reviewer to commit messages
--Rebased on top of the latest media tree

Changes compared with v2:
--add H264 fluster test results
--reorder compatible string for dt-bindings

Quoted 8 lines
Quoted 8 lines

Changes compared with v1:
--add v4l2-compliance test results
--add scp upstream link
--add HW difference discriptions for dt-bindings commit messages

This series patches dependent on:
[1]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 2 lines
Quoted 2 lines

[2]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 14 lines
Quoted 14 lines

Kyrie Wu (8):
  dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
  media: mediatek: vcodec: add decoder compatible to support MT8189
  media: mediatek: vcodec: add profile and level supporting for MT8189
  media: mediatek: vcodec: Add single core VP9 decoding support for MT8189
  media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
  media: mediatek: vcodec: fix media device node number
  dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
  media: mediatek: encoder: Add MT8189 encoder compatible data

Quoted 9 lines
Quoted 9 lines
 .../media/mediatek,vcodec-encoder.yaml        |  2 +
 .../media/mediatek,vcodec-subdev-decoder.yaml |  5 +-
 .../vcodec/decoder/mtk_vcodec_dec_drv.c       |  9 +++-
 .../vcodec/decoder/mtk_vcodec_dec_drv.h       |  1 +
 .../vcodec/decoder/mtk_vcodec_dec_stateless.c |  4 ++
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 48 ++++++++++++++-
----
 .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++
 7 files changed, 68 insertions(+), 15 deletions(-)

************* MEDIATEK Confidentiality Notice
 ********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

#26 lore raw
Quoted 44 lines · Nicolas Dufresne
Quoted 43 lines · Kyrie Wu (吴晗)
Quoted 40 lines · Nicolas Dufresne

Hi,

Quoted 25 lines · Kyrie Wu

This series have the follow changing:
Firstly add mt8189 video decoder compatible, profile and level to
support
MT8189 kernel driver.
Secondly fix some bugs, including vp 4K profile2 and media device
node
number bug.
Lastly, add mt8189 video encoder compatible.

This series has been tested with MT8189 tast test. Encoding and decoding worked for this chip.

Patches 1-2 Add decoder compatible.
Patches 3 Add profile and level supporting.
Patches 4 Add core-only VP9 decoding supporting.
Patches 5-6 fix some bugs.
Patches 7-8 Adds encoder compatible.

---
H264 test results:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90
JVT-AVC_V1Ran 96/135 tests successfully

Quoted 8 lines

VP9 test results:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90 VP9-TEST-VECTORSRan 276/305 tests successfully

v4l2-compliance test results:
Compliance test for mtk-vcodec-enc device /dev/video2:
Total for mtk-vcodec-enc device /dev/video2: 47, Succeeded: 46,
Failed: 1, Warnings: 0

There is one fail, can you explain it ?

Nicolas

Quoted 8 lines
Quoted 8 lines

Dear Nicolas,

The failure is caused by subscribed event/dqevent. Our encoder driver
didn't register those apis, which caused this failure. Here is the fail log, which is samed as MT8196:

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 41 lines
Quoted 7 lines

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
fail: v4l2-test-controls.cpp(1171): node-

Quoted 5 lines
Quoted 1 line

codec_mask &

STATEFUL_ENCODER
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 16 Private Controls: 0

The spec says:

For backwards compatibility, the encoder will signal a
V4L2_EVENT_EOS event when
the last frame has been encoded and all frames are ready to be
dequeued.

In practice, we test for that on every m2m, see the test code:

	if (node->is_m2m) {
		node_m2m_cap->g_fmt(fmt_q, m2m_q.g_type());
		if (node_m2m_cap-
Quoted 1 line

buftype_pixfmts[m2m_q.g_type()][fmt_q.g_pixelformat()] &

V4L2_FMT_FLAG_COMPRESSED) valid_output_flags = V4L2_BUF_FLAG_TIMECODE |
V4L2_BUF_FLAG_TSTAMP_SRC_MASK;

		struct v4l2_event_subscription sub = { 0 };

		sub.type = V4L2_EVENT_EOS;
		if (node->codec_mask & (STATEFUL_ENCODER |
STATEFUL_DECODER))
			doioctl(node, VIDIOC_SUBSCRIBE_EVENT, &sub);
	}
Quoted 9 lines

please fix,
Nicolas

Quoted 6 lines

Thanks.

Regards,
Kyrie.

Dear Nicolas,

Thanks for introduction for this, and I will send a new patch to fix it. But I think the patch is different with this series, Is it appropriate to send a single patch, excluding it from this series?

Thanks.

Regards,
Kyrie.

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines

Compliance test for mtk-vcodec-dec device /dev/video3:
Total for mtk-vcodec-dec device /dev/video3: 48, Succeeded: 48,
Failed: 0, Warnings: 0

scp upstream link:

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

dtsi upstream link:

https://lore.kernel.org/linux-mediatek/[email protected]/T/#m847e35de0a5b18fac0ca0624a8559d84964ad5c7

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

Changes compared with v4:
--update H264 & vp9 fluster test results
--update vp9 single core decoder prob size setting and commit messages

Changes compared with v3:
--add reviewer to commit messages
--Rebased on top of the latest media tree

Changes compared with v2:
--add H264 fluster test results
--reorder compatible string for dt-bindings

Changes compared with v1:
--add v4l2-compliance test results
--add scp upstream link
--add HW difference discriptions for dt-bindings commit messages

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

This series patches dependent on:
[1]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

[2]

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

Quoted 49 lines
Quoted 49 lines
Quoted 16 lines
Quoted 16 lines

Kyrie Wu (8):
dt-bindings: media: mediatek: decoder: Add MT8189
mediatek,vcodec-decoder
media: mediatek: vcodec: add decoder compatible to support
MT8189
media: mediatek: vcodec: add profile and level supporting for
MT8189
media: mediatek: vcodec: Add single core VP9 decoding support
for

    MT8189

media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
media: mediatek: vcodec: fix media device node number
dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
media: mediatek: encoder: Add MT8189 encoder compatible data

Quoted 10 lines
Quoted 10 lines
 .../media/mediatek,vcodec-encoder.yaml        |  2 +
 .../media/mediatek,vcodec-subdev-decoder.yaml |  5 +-
 .../vcodec/decoder/mtk_vcodec_dec_drv.c       |  9 +++-
 .../vcodec/decoder/mtk_vcodec_dec_drv.h       |  1 +
 .../vcodec/decoder/mtk_vcodec_dec_stateless.c |  4 ++
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 48
++++++++++++++-
----
 .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++
 7 files changed, 68 insertions(+), 15 deletions(-)

************* MEDIATEK Confidentiality Notice
********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe

that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!