devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/8] Enable video decoder & encoder for MT8189
@ 2025-10-16  6:07 Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 1/8] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

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 -j1 -t 90
     JVT-AVC_V1       94/135

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/20250811015922.32680-1-huayu.zong@mediatek.com/

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/20250510075357.11761-1-yunfei.dong@mediatek.com/
[2]
https://patchwork.linuxtv.org/project/linux-media/cover/20250814085642.17343-1-kyrie.wu@mediatek.com/

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 core-only 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 |  1 +
 .../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 | 32 ++++++++++++-------
 .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++++
 7 files changed, 50 insertions(+), 13 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 1/8] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189 Kyrie Wu
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

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. 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           | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
index 74e1d88d3056..248a9f6af5a6 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
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 1/8] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 3/8] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

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

Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 .../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
@@ -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,
+	},
 	{},
 };
 
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
@@ -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,
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 3/8] media: mediatek: vcodec: add profile and level supporting for MT8189
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 1/8] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189 Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support " Kyrie Wu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

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>
---
 .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c        | 4 ++++
 1 file changed, 4 insertions(+)

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..0a9bdc5316f9 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
@@ -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;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support for MT8189
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (2 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 3/8] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16 15:19   ` Nicolas Dufresne
  2025-10-16  6:07 ` [PATCH v4 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2 Kyrie Wu
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

Implemented core-only VP9 decoding functions for MT8189.

Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
---
 .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 27 +++++++++++--------
 1 file changed, 16 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..04197164fb82 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
@@ -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))
@@ -616,7 +617,10 @@ 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 = ((ctx->dev->chip_name == MTK_VDEC_MT8196) ||
+				       (ctx->dev->chip_name == MTK_VDEC_MT8189)) ?
+					VP9_PROB_BUF_4K_SIZE : VP9_PROB_BUF_SIZE;
+
 		if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
 			goto err;
 	}
@@ -696,21 +700,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 +1805,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 related	[flat|nested] 13+ messages in thread

* [PATCH v4 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (3 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support " Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 6/8] media: mediatek: vcodec: fix media device node number Kyrie Wu
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

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")

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       | 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 04197164fb82..416d8c0c04ce 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
@@ -1140,7 +1140,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;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 6/8] media: mediatek: vcodec: fix media device node number
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (4 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2 Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 7/8] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder Kyrie Wu
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

change media register device node number to a correct value

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 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
@@ -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);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 7/8] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (5 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 6/8] media: mediatek: vcodec: fix media device node number Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16  6:07 ` [PATCH v4 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data Kyrie Wu
  2025-10-16 14:42 ` [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Nicolas Dufresne
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz, 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 related	[flat|nested] 13+ messages in thread

* [PATCH v4 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (6 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 7/8] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder Kyrie Wu
@ 2025-10-16  6:07 ` Kyrie Wu
  2025-10-16 14:42 ` [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Nicolas Dufresne
  8 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu @ 2025-10-16  6:07 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, Christophe JAILLET, Sebastian Fricke,
	Nathan Hebert, Arnd Bergmann, Irui Wang, George Sun, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

add compatible data to support MT8189 encoding.

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 related	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 0/8] Enable video decoder & encoder for MT8189
  2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
                   ` (7 preceding siblings ...)
  2025-10-16  6:07 ` [PATCH v4 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data Kyrie Wu
@ 2025-10-16 14:42 ` Nicolas Dufresne
  2025-10-22  2:41   ` Kyrie Wu (吴晗)
  8 siblings, 1 reply; 13+ messages in thread
From: Nicolas Dufresne @ 2025-10-16 14:42 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, Christophe JAILLET, Sebastian Fricke, Nathan Hebert,
	Arnd Bergmann, Irui Wang, George Sun, linux-media, devicetree,
	linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

[-- Attachment #1: Type: text/plain, Size: 3485 bytes --]

Hi,

Le jeudi 16 octobre 2025 à 14:07 +0800, Kyrie Wu a écrit :
> 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 -j1 -t 90
>      JVT-AVC_V1       94/135

Your set indicates that this SoC supports more then H.264, any reason to omit
other codecs ? Also, why not -j2, does it mean concurrent decoding is broken ?
> 
> 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/20250811015922.32680-1-huayu.zong@mediatek.com/
> 
> 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/20250510075357.11761-1-yunfei.dong@mediatek.com/
> [2]
> https://patchwork.linuxtv.org/project/linux-media/cover/20250814085642.17343-1-kyrie.wu@mediatek.com/

It could be nice to quote the subjects, so we can decide to open the links or
not. I suppose you opted for sending the DTS separately, I don't have the HW,
but if my chances someone wanted to test that, he's need a these, can you link
them please ?

Nicolas

> 
> 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 core-only 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 |  1 +
>  .../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 | 32 ++++++++++++-------
>  .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++++
>  7 files changed, 50 insertions(+), 13 deletions(-)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support for MT8189
  2025-10-16  6:07 ` [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support " Kyrie Wu
@ 2025-10-16 15:19   ` Nicolas Dufresne
  2025-10-22  5:45     ` Kyrie Wu (吴晗)
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Dufresne @ 2025-10-16 15: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, Christophe JAILLET, Sebastian Fricke, Nathan Hebert,
	Arnd Bergmann, Irui Wang, George Sun, linux-media, devicetree,
	linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Neil Armstrong, Andrzej Pietrasiewicz

[-- Attachment #1: Type: text/plain, Size: 3664 bytes --]

Hi,

Le jeudi 16 octobre 2025 à 14:07 +0800, Kyrie Wu a écrit :
> Implemented core-only VP9 decoding functions for MT8189.

What does "core-only" means ? Did you mean single core ?

> 
> Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> ---
>  .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 27 +++++++++++--------
>  1 file changed, 16 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..04197164fb82 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
> @@ -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))
> @@ -616,7 +617,10 @@ 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 = ((ctx->dev->chip_name ==
> MTK_VDEC_MT8196) ||
> +				       (ctx->dev->chip_name ==
> MTK_VDEC_MT8189)) ?
> +					VP9_PROB_BUF_4K_SIZE :
> VP9_PROB_BUF_SIZE;

I feel like this will keep growing, then you'll move to 8K and it will continue.
You already match every SoC in the driver, you should come up with SoC
configuration data structure so you don't have to add doc check conditions all
over the place. This change is also not reflected in the commit message.

> +
>  		if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
>  			goto err;
>  	}
> @@ -696,21 +700,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 +1805,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);

This entire change is not explained in the commit message at all. Explain why
this is needed, what difference it makes. There is no clear indication we are in
an MT8189 code path, so this change could have a incidence on all single core
SoC (if any).

Nicolas

>  	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] 13+ messages in thread

* Re: [PATCH v4 0/8] Enable video decoder & encoder for MT8189
  2025-10-16 14:42 ` [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Nicolas Dufresne
@ 2025-10-22  2:41   ` Kyrie Wu (吴晗)
  0 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-10-22  2:41 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	George Sun (孙林),
	Tiffany Lin (林慧珊), nhebert@chromium.org,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	mchehab@kernel.org, nicolas.dufresne@collabora.com,
	hverkuil@xs4all.nl, Kyrie Wu (吴晗),
	Yunfei Dong (董云飞), conor+dt@kernel.org,
	Irui Wang (王瑞), robh@kernel.org,
	sebastian.fricke@collabora.com,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com,
	christophe.jaillet@wanadoo.fr, krzk+dt@kernel.org, arnd@arndb.de,
	Andrew-CT Chen (陳智迪),
	AngeloGioacchino Del Regno
  Cc: andrzejtp2010@gmail.com, neil.armstrong@linaro.org

On Thu, 2025-10-16 at 10:42 -0400, Nicolas Dufresne wrote:
> Hi,
> 
> Le jeudi 16 octobre 2025 à 14:07 +0800, Kyrie Wu a écrit :
> > 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 -j1 -t 90
> >      JVT-AVC_V1       94/135
> 
> Your set indicates that this SoC supports more then H.264, any reason
> to omit
> other codecs ? Also, why not -j2, does it mean concurrent decoding is
> broken ?
Dear Nicolas,

I will update the H264 and vp9 concurrent decoding test results in the
next version.

Thanks.
> > 
> > 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/20250811015922.32680-1-huayu.zong@mediatek.com/
> > 
> > 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/20250510075357.11761-1-yunfei.dong@mediatek.com/
> > [2]
> > 
https://patchwork.linuxtv.org/project/linux-media/cover/20250814085642.17343-1-kyrie.wu@mediatek.com/
> 
> It could be nice to quote the subjects, so we can decide to open the
> links or
> not. I suppose you opted for sending the DTS separately, I don't have
> the HW,
> but if my chances someone wanted to test that, he's need a these, can
> you link
> them please ?
> 
> Nicolas

In the coming version, I will attach the dts patch link.

Thanks.

Regards,
Kyrie.
> 
> > 
> > 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 core-only 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 |  1 +
> >  .../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 | 32 ++++++++++++---
> > ----
> >  .../vcodec/encoder/mtk_vcodec_enc_drv.c       | 14 ++++++++
> >  7 files changed, 50 insertions(+), 13 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support for MT8189
  2025-10-16 15:19   ` Nicolas Dufresne
@ 2025-10-22  5:45     ` Kyrie Wu (吴晗)
  0 siblings, 0 replies; 13+ messages in thread
From: Kyrie Wu (吴晗) @ 2025-10-22  5:45 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	George Sun (孙林),
	Tiffany Lin (林慧珊), nhebert@chromium.org,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	mchehab@kernel.org, nicolas.dufresne@collabora.com,
	hverkuil@xs4all.nl, Kyrie Wu (吴晗),
	Yunfei Dong (董云飞), conor+dt@kernel.org,
	Irui Wang (王瑞), robh@kernel.org,
	sebastian.fricke@collabora.com,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com,
	christophe.jaillet@wanadoo.fr, krzk+dt@kernel.org, arnd@arndb.de,
	Andrew-CT Chen (陳智迪),
	AngeloGioacchino Del Regno
  Cc: andrzejtp2010@gmail.com, neil.armstrong@linaro.org

On Thu, 2025-10-16 at 11:19 -0400, Nicolas Dufresne wrote:
> Hi,
> 
> Le jeudi 16 octobre 2025 à 14:07 +0800, Kyrie Wu a écrit :
> > Implemented core-only VP9 decoding functions for MT8189.
> 
> What does "core-only" means ? Did you mean single core ?
Dear Nicolas,

Yes, it's a right thinking. I will change to "single core" to remove
the missing understanding.

Thanks.
> 
> > 
> > Signed-off-by: Kyrie Wu <kyrie.wu@mediatek.com>
> > ---
> >  .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 27 +++++++++++--
> > ------
> >  1 file changed, 16 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..04197164fb82 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
> > @@ -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))
> > @@ -616,7 +617,10 @@ 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 = ((ctx->dev->chip_name ==
> > MTK_VDEC_MT8196) ||
> > +				       (ctx->dev->chip_name ==
> > MTK_VDEC_MT8189)) ?
> > +					VP9_PROB_BUF_4K_SIZE :
> > VP9_PROB_BUF_SIZE;
> 
> I feel like this will keep growing, then you'll move to 8K and it
> will continue.
> You already match every SoC in the driver, you should come up with
> SoC
> configuration data structure so you don't have to add doc check
> conditions all
> over the place. This change is also not reflected in the commit
> message.

The prob size is independent with resolution. Based on feedback from
hardware designer, this size won't increase. Different ICs will only
choose between 4096 and 2560. However, as more ICs are added, redundant
code will become increasingly common. I'm considering adding a function
to handle this, as shown below:

static int mtk_vcodec_get_vp9_prob_size(int chip_name)
{
	switch (chip_name) {
		case MTK_VDEC_MT8189:
		case MTK_VDEC_MT8189:
			return VP9_PROB_BUF_4K_SIZE;
		default:
			return VP9_PROB_BUF_SIZE;
	}
}

the prob size is set like that:
instance->prob.size =
mtk_vcodec_get_vp9_prob_size(...)

Could you please give further comments for above solution?

Thanks.

> 
> > +
> >  		if (mtk_vcodec_mem_alloc(ctx, &instance->prob))
> >  			goto err;
> >  	}
> > @@ -696,21 +700,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 +1805,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);
> 
> This entire change is not explained in the commit message at all.
> Explain why
> this is needed, what difference it makes. There is no clear
> indication we are in
> an MT8189 code path, so this change could have a incidence on all
> single core
> SoC (if any).
> 
> Nicolas

In the decoding software flow, the app queue src or dst buffer to the
driver will try to schedule the decoding software flow by queuing the
work queue. At this time, only one of the src or dst buffer can be
obtained. However, in the original software flow, calling the
vdec_vp9_slice_setup_single_from_src_to_dst function using
v4l2_m2m_next_src_buf to get the src and dst buffers will return
-EINVAL, interrupting the decoding pipeline. Therefore, this interface
needs to be modified to set both src and dst buffer to set metadata.

Thanks.

Regards,
Kyrie.
> 
> >  	if (ret)
> >  		goto err;
> >  

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-10-22  5:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16  6:07 [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 1/8] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 2/8] media: mediatek: vcodec: add decoder compatible to support MT8189 Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 3/8] media: mediatek: vcodec: add profile and level supporting for MT8189 Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 4/8] media: mediatek: vcodec: Add core-only VP9 decoding support " Kyrie Wu
2025-10-16 15:19   ` Nicolas Dufresne
2025-10-22  5:45     ` Kyrie Wu (吴晗)
2025-10-16  6:07 ` [PATCH v4 5/8] media: mediatek: vcodec: fix vp9 4096x2176 fail for profile2 Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 6/8] media: mediatek: vcodec: fix media device node number Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 7/8] dt-bindings: media: Add MT8189 mediatek,vcodec-encoder Kyrie Wu
2025-10-16  6:07 ` [PATCH v4 8/8] media: mediatek: encoder: Add MT8189 encoder compatible data Kyrie Wu
2025-10-16 14:42 ` [PATCH v4 0/8] Enable video decoder & encoder for MT8189 Nicolas Dufresne
2025-10-22  2:41   ` Kyrie Wu (吴晗)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).