Enable video decoder & encoder for MT8189
Subsystems (4)
v12 cover Enable video decoder & encoder for MT8189
From: Kyrie Wu (吴晗) <[email protected]>
This series enables the MT8189 video decoder and encoder. It adds the decoder and encoder bindings and compatible data, updates decoder capability data, and fixes two existing decoder issues. Patch 3 moves decoder firmware selection from optional DT properties into platform data, matching the encoder implementation.
Patch layout:
1 Add the MT8189 decoder binding. 2 Add decoder platform-data support. 3 Move decoder firmware selection to platform data. 4-5 Refactor decoder profile, level, and VP9 probability-size data. 6 Fix VP9 4K profile-2 decoding. 7 Add the MT8189 decoder compatible data. 8 Fix the media-device node number.
9-10 Add the MT8189 encoder binding and compatible data.
This series depends on:
[1] MT8196 decoder series v9, preceded by its VCP remoteproc prerequisite, which was used as the base for this export.
[2] MT8196 encoder v8.
[1] https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/
[2] https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/
H.264:
./fluster.py run -d GStreamer-H.264-V4L2SL-Gst1.0 -j2 -t 90
JVT-AVC_V1: 96/135 tests passed
VP9:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -j2 -t 90
VP9-TEST-VECTORS: 276/305 tests passed
v4l2-compliance:
mtk-vcodec-enc (/dev/video2): 46/47 passed, 1 failed, 0 warnings mtk-vcodec-dec (/dev/video3): 48/48 passed, 0 failed, 0 warnings
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 v11:
- Rebased on mainline 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4, using the published MT8196 decoder v9 and its VCP prerequisite.
- Require two MT8189 decoder child clocks named soc-vdec and vdec. Correct the clock description and remove Rob Herring's withdrawn Acked-by from patch 1.
Changes compared with v10:
- Rebased on the latest media tree.
Changes compared with v9:
- Rebased on the latest media tree.
- Reordered the compatible string for DT bindings.
Changes compared with v1:
- Added v4l2-compliance test results.
- Added the SCP upstream link.
- Added hardware difference descriptions to the DT binding commit messages.
Kyrie Wu (10):
dt-bindings: media: mediatek: decoder: Add MT8189
mediatek,vcodec-decoder
media: mediatek: decoder: Add a new platform data member
media: mediatek: decoder: Move firmware selection to platform data
media: mediatek: vcodec: Refactor Decoder profile & level Handling
media: mediatek: vcodec: Add VP9 Probability Size Configuration
media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2
media: mediatek: vcodec: add decoder compatible to support MT8189
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 | 24 +- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 2 +- .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 6 + .../vcodec/decoder/mtk_vcodec_dec_drv.c | 64 ++--- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 42 +-- .../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +- .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 16 ++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 253 ++++++++++++------ .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 14 +- .../vcodec/encoder/mtk_vcodec_enc_drv.c | 17 ++ 11 files changed, 298 insertions(+), 144 deletions(-)
base-commit: 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4
prerequisite-patch-id: 9f5a680ff9c58918d53c09c15d48e6ac33c643fc
prerequisite-patch-id: af540a1d2093ff0b635f96f3257fbf768302925e
prerequisite-patch-id: dee8633604fd7528e9ebcb9de25a3e42231f1f80
prerequisite-patch-id: f464ff9a2860b4fc07c051961e26c10047a1731d
prerequisite-patch-id: 1b9295ecd3895c60f6d5ab690f9c05987e1a551f
prerequisite-patch-id: a4abfe16fb9cfd55e44707491259f72f50783a33
prerequisite-patch-id: 472784c2603c63038b064dd36d867b9105a23eda
prerequisite-patch-id: 3e9f9d5336485e4bd3be2a8726d2c2428619e286
prerequisite-patch-id: 973ab0b15402c2096428453296d88f34fda6a700
prerequisite-patch-id: 051092a8424afa3002442799fb016651eb80f79f
prerequisite-patch-id: b04e354244d9eccb8355fc5a12426d762751de39
prerequisite-patch-id: e3c85085bf36c880690336d216901ffeb5c4e9ec
prerequisite-patch-id: d8a3b0e7f634d02d3ef0625a9ad0d7f2fcc20b31
prerequisite-patch-id: 2129e8aec7acd498dd7badbaa5610d03df7dc52d
prerequisite-patch-id: 9501dc5e63b8120861f9a1e61958e3bac18e5b33
prerequisite-patch-id: 7d41207a5d2d040ef77700c1d8a8bfca933ce040
prerequisite-patch-id: 1e5eb8ffad8ac92cea848342d2dec1b73683e75a
prerequisite-patch-id: 4489e714c6a152266194fdef803ba5fb48a685c6
prerequisite-patch-id: 341fd7d3230b150b3e17f298d1c06cfb2ad3ad5a
prerequisite-patch-id: de717dc84d8be3c25942021a48b8c26ba714a432
prerequisite-patch-id: b663c493b16bb7a21ad04ed6972b90bd5ed4960d
prerequisite-patch-id: 2b0b00b672f448f333e9def6b9864afc11df991a
prerequisite-patch-id: 9fbf014b290db330f44f6702777acdef8ed5d76f
prerequisite-patch-id: acac610274fe76d67cedcd2d9729659132ab891f
prerequisite-patch-id: afa01b367b18eebac4bded1729931f4b1d1fc2ae
prerequisite-patch-id: 2844bb2bbd9328add841f4b13bdbdd3c120ffa5f
prerequisite-patch-id: e7405e261fde65f2cbe4f9d78d15fd411fb749bb
Signature · 1 line
2.51.0.windows.2
PATCH v12 1/10 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 uses two clocks named soc-vdec and vdec. At the same time, the decoder supports the vp9 decoding protocol for the first time in single IC.
--- .../media/mediatek,vcodec-subdev-decoder.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +22 -2
@@ -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
@@ -137,11 +138,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:
@@ -184,6 +185,25 @@ then: - interrupts allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8189-vcodec-dec + + then: + patternProperties: + '^video-codec@[0-9a-f]+$': + properties: + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: soc-vdec + - const: vdec + - if: properties: compatible:
Signature · 1 line
2.51.0.windows.2
Rob Herring
maintainerRe: [PATCH v12 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
Quoted 7 lines · Kyrie Wu
Add compatible for video decoder on MT8189 platform. Compared with former ICs, the MT8189 decoder use iommu to instead of smmu, and use scp architecture, the frequency is only 406MHZ, and cannot reach more than 700MHZ. It uses two clocks named soc-vdec and vdec. At the same time, the decoder supports the vp9 decoding protocol for the first time in single IC.
Quoted 6 lines
Signed-off-by Kyrie Wu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by Nicolas Dufresne <[email protected]>--- .../media/mediatek,vcodec-subdev-decoder.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
This patch should be based on this one:
https://lore.kernel.org/[email protected]
Rob
Re: [PATCH v12 01/10] dt-bindings: media: mediatek: decoder: Add MT8189 mediatek,vcodec-decoder
Le mercredi 18 novembre 2026 à 09:20 -0600, Rob Herring a écrit :
Quoted 15 lines · Kyrie Wu
Quoted 7 lines
Add compatible for video decoder on MT8189 platform. Compared with former ICs, the MT8189 decoder use iommu to instead of smmu, and use scp architecture, the frequency is only 406MHZ, and cannot reach more than 700MHZ. It uses two clocks named soc-vdec and vdec. At the same time, the decoder supports the vp9 decoding protocol for the first time in single IC.
Quoted 6 lines
Signed-off-by Kyrie Wu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by Nicolas Dufresne <[email protected]>--- .../media/mediatek,vcodec-subdev-decoder.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
Quoted 3 lines
This patch should be based on this one:
Ack.
Quoted 2 lines
Rob
PATCH v12 2/10 media: mediatek: decoder: Add a new platform data member
In reply to Kyrie WuMove the chip model information into the codec match data and remove the second compatible matching code.
--- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 2 +- .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 5 + .../vcodec/decoder/mtk_vcodec_dec_drv.c | 40 ++----- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 17 +-- .../vcodec/decoder/mtk_vcodec_dec_hw.c | 2 +- .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 + .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 104 +++++++++++++----- 7 files changed, 96 insertions(+), 75 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +1 -1
@@ -263,7 +263,7 @@ static int vidioc_vdec_querycap(struct file *file, void *priv,struct device *dev = &ctx->dev->plat_dev->dev;strscpy (cap->driver, dev->driver->name,sizeof (cap->driver)); -snprintf (cap->card,sizeof (cap->card),"MT%d video decoder" , ctx->dev->chip_name); +snprintf (cap->card,sizeof (cap->card),"MT%d video decoder" , ctx->dev->chip_model);return 0 ; }
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h +5 -0
@@ -69,6 +69,11 @@ extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;extern const struct media_device_ops mtk_vcodec_media_ops;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata;extern const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata;
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +9 -31
@@ -331,26 +331,9 @@ static const struct v4l2_file_operations mtk_vcodec_fops = { .mmap = v4l2_m2m_fop_mmap, }; -static void mtk_vcodec_dec_get_chip_name (struct mtk_vcodec_dec_dev *vdec_dev) +static void mtk_vcodec_dec_get_chip_model (struct mtk_vcodec_dec_dev *vdec_dev) { -struct device *dev = &vdec_dev->plat_dev->dev; - -if (of_device_is_compatible (dev->of_node,"mediatek,mt8173-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8173 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8183-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8183 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8192-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8192 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8195-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8195 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8186-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8186 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8188-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8188 ; -else if (of_device_is_compatible (dev->of_node,"mediatek,mt8196-vcodec-dec" )) - vdec_dev->chip_name =MTK_VDEC_MT8196 ; -else - vdec_dev->chip_name =MTK_VDEC_INVAL ; + vdec_dev->chip_model = vdec_dev->vdec_pdata->chip_model; }static int mtk_vcodec_probe (struct platform_device *pdev)
@@ -367,13 +350,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)INIT_LIST_HEAD (&dev->ctx_list); dev->plat_dev = pdev; -mtk_vcodec_dec_get_chip_name (dev); -if (dev->chip_name ==MTK_VDEC_INVAL ) { -dev_err (&pdev->dev,"Failed to get decoder chip name" ); -return -EINVAL ; - } - dev->vdec_pdata =of_device_get_match_data (&pdev->dev); +mtk_vcodec_dec_get_chip_model (dev);if (!of_property_read_u32 (pdev->dev.of_node,"mediatek,vpu" , &rproc_phandle)) { dev->fw_init = mtk_vcodec_fw_vpu_init;
@@ -388,7 +366,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)return -ENODEV ; }dma_set_max_seg_size (&pdev->dev,UINT_MAX ); -if (dev->chip_name ==MTK_VDEC_MT8196 ) { +if (dev->chip_model ==8196 ) { ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (36 ));if (ret) {dev_err (&pdev->dev,"Failed to enable 36-bit DMA: %d\n" , ret);
@@ -557,23 +535,23 @@ static const struct of_device_id mtk_vcodec_match[] = { }, { .compatible = "mediatek,mt8192-vcodec-dec", - .data = &mtk_lat_sig_core_pdata, + .data = &mtk_vdec_8192_pdata, }, { .compatible = "mediatek,mt8186-vcodec-dec", - .data = &mtk_vdec_single_core_pdata, + .data = &mtk_vdec_8186_pdata, }, { .compatible = "mediatek,mt8195-vcodec-dec", - .data = &mtk_lat_sig_core_pdata, + .data = &mtk_vdec_8195_pdata, }, { .compatible = "mediatek,mt8188-vcodec-dec", - .data = &mtk_lat_sig_core_pdata, + .data = &mtk_vdec_8188_pdata, }, { .compatible = "mediatek,mt8196-vcodec-dec", - .data = &mtk_lat_sig_core_pdata, + .data = &mtk_vdec_8196_pdata, }, {}, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +4 -13
@@ -21,17 +21,6 @@#define IS_VDEC_INNER_RACING (capability) ((capability) & MTK_VCODEC_INNER_RACING)#define IS_VDEC_SUPPORT_EXT (capability) ((capability) & MTK_VDEC_IS_SUPPORT_EXT) -enum mtk_vcodec_dec_chip_name { -MTK_VDEC_INVAL =0 , -MTK_VDEC_MT8173 =8173 , -MTK_VDEC_MT8183 =8183 , -MTK_VDEC_MT8186 =8186 , -MTK_VDEC_MT8188 =8188 , -MTK_VDEC_MT8192 =8192 , -MTK_VDEC_MT8195 =8195 , -MTK_VDEC_MT8196 =8196 , -}; -/* * enum mtk_vdec_format_types - Structure used to get supported * format types according to decoder capability
@@ -108,6 +97,7 @@ struct vdec_pic_info {* * @is_subdev_supported: whether support parent-node architecture(subdev) * @uses_stateless_api: whether the decoder uses the stateless API with requests +* @chip_model: platforms configuration values */ struct mtk_vcodec_dec_pdata {void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
@@ -129,6 +119,7 @@ struct mtk_vcodec_dec_pdata {bool is_subdev_supported;bool uses_stateless_api; +unsigned int chip_model; };/**
@@ -277,7 +268,7 @@ struct mtk_vcodec_dec_ctx {* @dec_racing_info_mutex: mutex lock used for inner racing mode * @dbgfs: debug log related information * -* @chip_name: used to distinguish platforms and select the correct codec configuration values +* @chip_model: used to distinguish platforms and select the correct codec configuration values */ struct mtk_vcodec_dec_dev {struct v4l2_device v4l2_dev;
@@ -321,7 +312,7 @@ struct mtk_vcodec_dec_dev {struct mutex dec_racing_info_mutex;struct mtk_vcodec_dbgfs dbgfs; -enum mtk_vcodec_dec_chip_name chip_name; +unsigned int chip_model; };static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx (struct v4l2_fh *fh)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c +1 -1
@@ -77,7 +77,7 @@ static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev)unsigned long flags;u32 val, mask, addr =VDEC_XPC_CLEAN_ADDR ; -if (dev->main_dev->chip_name !=MTK_VDEC_MT8196 ) +if (dev->main_dev->chip_model !=8196 )return ; val = dev->hw_idx ==MTK_VDEC_LAT0 ?VDEC_XPC_LAT_VAL :VDEC_XPC_CORE_VAL ;
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c +1 -0
@@ -618,4 +618,5 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = { .flush_decoder = mtk_vdec_flush_decoder, .is_subdev_supported = false, .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, + .chip_model = 8173, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +75 -29
165 lines not on this page · raw message
Signature · 1 line
2.51.0.windows.2
PATCH v12 3/10 media: mediatek: decoder: Move firmware selection to platform data
In reply to Kyrie WuThe decoder currently selects its firmware backend by testing optional mediatek,vpu, mediatek,scp, and mediatek,vcp properties in the device tree. The firmware backend is, however, fixed by the decoder compatible.
Add the firmware type and initialization callback to the decoder platform data, initialize them for each supported SoC, and use the callback from the platform data at probe time. This matches the existing encoder platform-data design and removes the DT-property dependency.
--- .../vcodec/decoder/mtk_vcodec_dec_drv.c | 17 ++--------------- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 7 +++++-- .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 2 ++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 12 ++++++++++++ 4 files changed, 21 insertions(+), 17 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +2 -15
@@ -340,7 +340,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev) {struct mtk_vcodec_dec_dev *dev;struct video_device *vfd_dec; -phandle rproc_phandle;int i, ret; dev =devm_kzalloc_obj (&pdev->dev, *dev);
@@ -352,19 +351,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev) dev->vdec_pdata =of_device_get_match_data (&pdev->dev);mtk_vcodec_dec_get_chip_model (dev); -if (!of_property_read_u32 (pdev->dev.of_node,"mediatek,vpu" , - &rproc_phandle)) { - dev->fw_init = mtk_vcodec_fw_vpu_init; - }else if (!of_property_read_u32 (pdev->dev.of_node,"mediatek,scp" , - &rproc_phandle)) { - dev->fw_init = mtk_vcodec_fw_scp_init; - }else if (!of_property_read_u32 (pdev->dev.of_node,"mediatek,vcp" , - &rproc_phandle)) { - dev->fw_init = mtk_vcodec_fw_vcp_init; - }else { -dev_dbg (&pdev->dev,"Could not get vdec IPI device" ); -return -ENODEV ; - }dma_set_max_seg_size (&pdev->dev,UINT_MAX );if (dev->chip_model ==8196 ) { ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (36 ));
@@ -374,7 +360,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev) } } - dev->fw_handler =mtk_vcodec_fw_select (dev,DECODER , dev->fw_init); + dev->fw_handler =mtk_vcodec_fw_select (dev,DECODER , + dev->vdec_pdata->fw_init);if (IS_ERR (dev->fw_handler))return PTR_ERR (dev->fw_handler);
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +5 -2
@@ -97,6 +97,8 @@ struct vdec_pic_info {* * @is_subdev_supported: whether support parent-node architecture(subdev) * @uses_stateless_api: whether the decoder uses the stateless API with requests +* @fw_type: firmware type (VPU, SCP, or VCP) +* @fw_init: firmware-specific initialization callback * @chip_model: platforms configuration values */ struct mtk_vcodec_dec_pdata {
@@ -119,6 +121,9 @@ struct mtk_vcodec_dec_pdata {bool is_subdev_supported;bool uses_stateless_api; +enum mtk_vcodec_fw_type fw_type; +struct mtk_vcodec_fw *(*fw_init)(void *priv, +enum mtk_vcodec_fw_use fw_use);unsigned int chip_model; };
@@ -243,7 +248,6 @@ struct mtk_vcodec_dec_ctx {* @vdecsys_regmap: VDEC_SYS register space passed through syscon * * @fw_handler: used to communicate with the firmware. -* @fw_init: firmware-specific init callback selected at probe time * @id_counter: used to identify current opened instance * * @dec_mutex: decoder hardware lock
@@ -285,7 +289,6 @@ struct mtk_vcodec_dec_dev {struct regmap *vdecsys_regmap;struct mtk_vcodec_fw *fw_handler; -struct mtk_vcodec_fw *(*fw_init)(void *priv,enum mtk_vcodec_fw_use fw_use);u64 id_counter;/* decoder hardware mutex lock */
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c +2 -0
@@ -618,5 +618,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = { .flush_decoder = mtk_vdec_flush_decoder, .is_subdev_supported = false, .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, + .fw_type = VPU, + .fw_init = mtk_vcodec_fw_vpu_init, .chip_model = 8173, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +12 -0
@@ -935,6 +935,8 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = { .get_cap_buffer = vdec_get_cap_buffer, .is_subdev_supported = false, .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, + .fw_type = SCP, + .fw_init = mtk_vcodec_fw_scp_init, .chip_model = 8183, };
@@ -974,24 +976,32 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = {MTK_STATELESS_DEC_DATA , .hw_arch =MTK_VDEC_LAT_SINGLE_CORE , + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, .chip_model =8188 , };const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = {MTK_STATELESS_DEC_DATA , .hw_arch =MTK_VDEC_LAT_SINGLE_CORE , + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, .chip_model =8192 , };const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = {MTK_STATELESS_DEC_DATA , .hw_arch =MTK_VDEC_LAT_SINGLE_CORE , + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, .chip_model =8195 , };const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = {MTK_STATELESS_DEC_DATA , .hw_arch =MTK_VDEC_LAT_SINGLE_CORE , + .fw_type =VCP , + .fw_init = mtk_vcodec_fw_vcp_init, .chip_model =8196 , };
@@ -1015,5 +1025,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = {MTK_STATELESS_DEC_DATA , .hw_arch =MTK_VDEC_PURE_SINGLE_CORE , + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, .chip_model =8186 , };
Signature · 1 line
2.51.0.windows.2
PATCH v12 4/10 media: mediatek: vcodec: Refactor Decoder profile & level Handling
In reply to Kyrie WuThis commit refactors the handling of decoder parameters for H264, H265, and VP9 codecs by introducing a new structure to standardize supported level and profile information. By leveraging this change, chipset-specific conditional logic in the codec configuration functions is significantly reduced.
--- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 16 ++ .../vcodec/decoder/mtk_vcodec_dec_stateful.c | 12 ++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 165 ++++++++++-------- 3 files changed, 118 insertions(+), 75 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +16 -0
@@ -78,6 +78,16 @@ struct vdec_pic_info {unsigned int reserved; }; +/** +* struct mtk_vcodec_dec_params - decoder supported parameters +* @level: decoder supported vcodec level +* @profile: decoder supported vcodec profile +*/ +struct mtk_vcodec_dec_params { +s64 level; +s64 profile; +}; +/** * struct mtk_vcodec_dec_pdata - compatible data for each IC * @init_vdec_params: init vdec params
@@ -100,6 +110,9 @@ struct vdec_pic_info {* @fw_type: firmware type (VPU, SCP, or VCP) * @fw_init: firmware-specific initialization callback * @chip_model: platforms configuration values +* @h264_params: H264 decoder default supported params +* @h265_params: H265 decoder default supported params +* @vp9_params: VP9 decoder default supported params */ struct mtk_vcodec_dec_pdata {void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
@@ -125,6 +138,9 @@ struct mtk_vcodec_dec_pdata {struct mtk_vcodec_fw *(*fw_init)(void *priv,enum mtk_vcodec_fw_use fw_use);unsigned int chip_model; +struct mtk_vcodec_dec_params h264_params; +struct mtk_vcodec_dec_params h265_params; +struct mtk_vcodec_dec_params vp9_params; };/**
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c +12 -0
@@ -621,4 +621,16 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = { .fw_type = VPU, .fw_init = mtk_vcodec_fw_vpu_init, .chip_model = 8173, + .h264_params = { + .level = V4L2_MPEG_VIDEO_H264_LEVEL_4_1, + .profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + }, + .h265_params = { + .level = V4L2_MPEG_VIDEO_HEVC_LEVEL_4, + .profile = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE, + }, + .vp9_params = { + .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0, + .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1, + }, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +90 -75
230 lines not on this page · raw message
Signature · 1 line
2.51.0.windows.2
PATCH v12 5/10 media: mediatek: vcodec: Add VP9 Probability Size Configuration
In reply to Kyrie WuIntroduce support for using different probability buffer sizes for different stateless decoders: in particular, the VP9 decoder can use a different size on different SoCs because of different hardware capabilities.
Move the hardcoded single probability buffer size value to decoder params, introduce a new VP9_4K_PROB_BUF_SIZE and assign:
- VP9_PROB_BUF_SIZE (2560 lines) to legacy SoCs;
- VP9_4K_PROB_BUF_SIZE (3840 lines) to newer SoCs (MT8196, MT8189).
--- .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 2 ++ .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c | 1 + .../mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c | 9 +++++++++ .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +2 -0
@@ -82,10 +82,12 @@ struct vdec_pic_info {* struct mtk_vcodec_dec_params - decoder supported parameters * @level: decoder supported vcodec level * @profile: decoder supported vcodec profile +* @prob_size: vp9 decoder probability size */ struct mtk_vcodec_dec_params {s64 level;s64 profile; +size_t prob_size; };/**
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateful.c +1 -0
@@ -632,5 +632,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1, + .prob_size = 2560, }, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +9 -0
@@ -10,6 +10,9 @@#include "mtk_vcodec_dec_pm.h" #include "vdec_drv_if.h" +#define VP9_PROB_BUF_SIZE 2560 +#define VP9_4K_PROB_BUF_SIZE 3840 +/** * struct mtk_stateless_control - CID control type * @cfg: control configuration
@@ -892,6 +895,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1, + .prob_size = VP9_PROB_BUF_SIZE, }, };
@@ -945,6 +949,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2, + .prob_size = VP9_PROB_BUF_SIZE, }, };
@@ -965,6 +970,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2, + .prob_size = VP9_PROB_BUF_SIZE, }, };
@@ -985,6 +991,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1, + .prob_size = VP9_PROB_BUF_SIZE, }, };
@@ -1005,6 +1012,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_2, + .prob_size = VP9_4K_PROB_BUF_SIZE, }, };
@@ -1042,5 +1050,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = { .vp9_params = { .level = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1, .profile = V4L2_MPEG_VIDEO_VP9_PROFILE_1, + .prob_size = VP9_PROB_BUF_SIZE, }, };
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +2 -2
@@ -22,7 +22,6 @@#define VP9_RESET_FRAME_CONTEXT_ALL 3#define VP9_TILE_BUF_SIZE 4096 -#define VP9_PROB_BUF_SIZE 2560#define VP9_COUNTS_BUF_SIZE 16384#define HDR_FLAG (x) (!!((hdr)->flags & V4L2_VP9_FRAME_FLAG_##x))
@@ -551,6 +550,7 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i struct vdec_vp9_slice_vsi *vsi) {struct mtk_vcodec_dec_ctx *ctx = instance->ctx; +struct mtk_vcodec_dec_dev *pdev = ctx->dev;enum vdec_vp9_slice_resolution_level level;/* super blocks */ unsigned int max_sb_w;
@@ -621,7 +621,7 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i }if (!instance->prob.va) { - instance->prob.size =VP9_PROB_BUF_SIZE ; + instance->prob.size = pdev->vdec_pdata->vp9_params.prob_size;if (mtk_vcodec_mem_alloc (ctx, &instance->prob)) goto err; }
Signature · 1 line
2.51.0.windows.2
PATCH v12 6/10 media: mediatek: vcodec: Fix vp9 4096x2176 fail for profile2
In reply to Kyrie WuThe DRAM address of the VP9 decoder tile info buffers may require as much as 36bits for 4096x2176 resolution. Fold the 4 most significant bits into the lower (padding) four bits of address.
--- .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +9 -1
@@ -1134,9 +1134,17 @@ static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *instreturn -EINVAL ; } tiles->size[i][j] = size; +/* +* If the system supports 64-bit DMA addresses, the upper 4 bits +* of the address are also encoded into the buffer entry. +* The buffer pointer (tb) is incremented after each entry is written. +*/ if (tiles->mi_rows[i]) { *tb++ = (size <<3 ) + ((offset <<3 ) &0x7f ); - *tb++ = pa & ~0xf ; + *tb = pa &GENMASK (31 ,4 ); +if (IS_ENABLED (CONFIG_ARCH_DMA_ADDR_T_64BIT )) + *tb |= (pa >>32 ) &GENMASK (3 ,0 ); + tb++; *tb++ = (pa <<3 ) &0x7f ; mi_row = (tiles->mi_rows[i] -1 ) &0x1ff ; mi_col = (tiles->mi_cols[j] -1 ) &0x3f ;
Signature · 1 line
2.51.0.windows.2
PATCH v12 7/10 media: mediatek: vcodec: add decoder compatible to support MT8189
In reply to Kyrie WuMT8189 is pure single core architecture. Add its compatible to initialize platform data.
--- .../mediatek/vcodec/decoder/mtk_vcodec_dec.h | 1 + .../vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 21 +++++++++++++++++++ 3 files changed, 26 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h +1 -0
@@ -71,6 +71,7 @@ extern const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8188_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8192_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8195_pdata;extern const struct mtk_vcodec_dec_pdata mtk_vdec_8196_pdata;
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +4 -0
@@ -540,6 +540,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8196-vcodec-dec", .data = &mtk_vdec_8196_pdata, }, + { + .compatible = "mediatek,mt8189-vcodec-dec", + .data = &mtk_vdec_8189_pdata, + }, {}, };
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +21 -0
@@ -1053,3 +1053,24 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8186_pdata = { .prob_size = VP9_PROB_BUF_SIZE, }, }; + +const struct mtk_vcodec_dec_pdata mtk_vdec_8189_pdata = { +MTK_STATELESS_DEC_DATA , + .hw_arch =MTK_VDEC_PURE_SINGLE_CORE , + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, + .chip_model =8189 , + .h264_params = { + .level =V4L2_MPEG_VIDEO_H264_LEVEL_5_2 , + .profile =V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10 , + }, + .h265_params = { + .level =V4L2_MPEG_VIDEO_HEVC_LEVEL_4 , + .profile =V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE , + }, + .vp9_params = { + .level =V4L2_MPEG_VIDEO_VP9_LEVEL_5_2 , + .profile =V4L2_MPEG_VIDEO_VP9_PROFILE_2 , + .prob_size =VP9_4K_PROB_BUF_SIZE , + }, +};
Signature · 1 line
2.51.0.windows.2
PATCH v12 8/10 media: mediatek: vcodec: Fix media device node number
In reply to Kyrie Wuchange media register device node number to a correct value. The vfd minor is used to record the number of registered video device nodes. The mdev_dec.devnode minor counter is used to record the number of registered media device nodes.
--- .../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
@@ -480,7 +480,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.51.0.windows.2
PATCH v12 9/10 dt-bindings: media: Add MT8189 mediatek,vcodec-encoder
In reply to Kyrie WuAdd 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
@@ -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
@@ -105,6 +106,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.51.0.windows.2
PATCH v12 10/10 media: mediatek: encoder: Add MT8189 encoder compatible data
In reply to Kyrie Wuadd MT8189 compatible data to initialize platform data for encoder.
--- .../vcodec/encoder/mtk_vcodec_enc_drv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c +17 -0
@@ -483,6 +483,22 @@ static const struct mtk_vcodec_enc_pdata mt8196_pdata = { .ipi_id = VCP_IPI_ENCODER, }; +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, + .fw_type =SCP , + .fw_init = mtk_vcodec_fw_scp_init, + .ipi_id =SCP_IPI_VENC_H264 , +}; +static const struct of_device_id mtk_vcodec_enc_match[] = { {.compatible ="mediatek,mt8173-vcodec-enc" , .data = &mt8173_avc_pdata},
@@ -493,6 +509,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.51.0.windows.2