* [PATCH v1, 0/3] support mt8186 decoder @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Firstly, add mt8186 compatible and private data, then add document for compatible "mediatek,mt8186-vcodec-dec". For mt8186 is single core architecture, need to add new interface for h264 hardware decoder. Patche 1 add mt8186 compatible and private data. Patche 2 add mt8186 compatible document. Patche 3 add h264 single core driver. --- This patch depends on "support for MT8192 decoder"[1] [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220122035316.18179-1-yunfei.dong@mediatek.com/ --- Yunfei Dong (3): mtk-vcodec: Support MT8186 dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 mtk-vcodec: add h264 decoder driver for mt8186 .../media/mediatek,vcodec-subdev-decoder.yaml | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 + .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 ++ .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 7 files changed, 196 insertions(+), 2 deletions(-) -- 2.25.1 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1, 0/3] support mt8186 decoder @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: Irui Wang, George Sun, Dafna Hirschfeld, srv_heupstream, devicetree, Project_Global_Chrome_Upstream_Group, linux-kernel, dri-devel, Xiaoyong Lu, linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Steve Cho, linux-media, linux-arm-kernel, AngeloGioacchino Del Regno Firstly, add mt8186 compatible and private data, then add document for compatible "mediatek,mt8186-vcodec-dec". For mt8186 is single core architecture, need to add new interface for h264 hardware decoder. Patche 1 add mt8186 compatible and private data. Patche 2 add mt8186 compatible document. Patche 3 add h264 single core driver. --- This patch depends on "support for MT8192 decoder"[1] [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220122035316.18179-1-yunfei.dong@mediatek.com/ --- Yunfei Dong (3): mtk-vcodec: Support MT8186 dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 mtk-vcodec: add h264 decoder driver for mt8186 .../media/mediatek,vcodec-subdev-decoder.yaml | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 + .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 ++ .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 7 files changed, 196 insertions(+), 2 deletions(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1, 0/3] support mt8186 decoder @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Firstly, add mt8186 compatible and private data, then add document for compatible "mediatek,mt8186-vcodec-dec". For mt8186 is single core architecture, need to add new interface for h264 hardware decoder. Patche 1 add mt8186 compatible and private data. Patche 2 add mt8186 compatible document. Patche 3 add h264 single core driver. --- This patch depends on "support for MT8192 decoder"[1] [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220122035316.18179-1-yunfei.dong@mediatek.com/ --- Yunfei Dong (3): mtk-vcodec: Support MT8186 dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 mtk-vcodec: add h264 decoder driver for mt8186 .../media/mediatek,vcodec-subdev-decoder.yaml | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 + .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 ++ .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 7 files changed, 196 insertions(+), 2 deletions(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1, 0/3] support mt8186 decoder @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Firstly, add mt8186 compatible and private data, then add document for compatible "mediatek,mt8186-vcodec-dec". For mt8186 is single core architecture, need to add new interface for h264 hardware decoder. Patche 1 add mt8186 compatible and private data. Patche 2 add mt8186 compatible document. Patche 3 add h264 single core driver. --- This patch depends on "support for MT8192 decoder"[1] [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220122035316.18179-1-yunfei.dong@mediatek.com/ --- Yunfei Dong (3): mtk-vcodec: Support MT8186 dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 mtk-vcodec: add h264 decoder driver for mt8186 .../media/mediatek,vcodec-subdev-decoder.yaml | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 + .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 ++ .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 7 files changed, 196 insertions(+), 2 deletions(-) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1, 1/3] mtk-vcodec: Support MT8186 2022-01-22 7:56 ` Yunfei Dong (?) (?) @ 2022-01-22 7:56 ` Yunfei Dong -1 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds MT8186's compatible "mediatek,mt8186-vcodec-dec". Adds MT8186's device private data mtk_vdec_single_core_pdata. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 ++++ .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h index 66cd6d2242c3..4572f92826f2 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h @@ -69,6 +69,7 @@ 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_lat_sig_core_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata; /* diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 6b52eaeedafa..2d21d0010c9c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -464,6 +464,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8192-vcodec-dec", .data = &mtk_lat_sig_core_pdata, }, + { + .compatible = "mediatek,mt8186-vcodec-dec", + .data = &mtk_vdec_single_core_pdata, + }, {}, }; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c index 3770e8117488..4b83f00a8857 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c @@ -522,3 +522,22 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = { .is_subdev_supported = true, .hw_arch = MTK_VDEC_LAT_SINGLE_CORE, }; + +const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = { + .init_vdec_params = mtk_init_vdec_params, + .ctrls_setup = mtk_vcodec_dec_ctrls_setup, + .vdec_vb2_ops = &mtk_vdec_request_vb2_ops, + .vdec_formats = mtk_video_formats, + .num_formats = &num_formats, + .default_out_fmt = &default_out_format, + .default_cap_fmt = &default_cap_format, + .vdec_framesizes = mtk_vdec_framesizes, + .num_framesizes = &num_framesizes, + .uses_stateless_api = true, + .worker = mtk_vdec_worker, + .flush_decoder = mtk_vdec_flush_decoder, + .cap_to_disp = mtk_vdec_stateless_cap_to_disp, + .get_cap_buffer = vdec_get_cap_buffer, + .is_subdev_supported = true, + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, +}; -- 2.25.1 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 1/3] mtk-vcodec: Support MT8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: Irui Wang, George Sun, Dafna Hirschfeld, srv_heupstream, devicetree, Project_Global_Chrome_Upstream_Group, linux-kernel, dri-devel, Xiaoyong Lu, linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Steve Cho, linux-media, linux-arm-kernel, AngeloGioacchino Del Regno Adds MT8186's compatible "mediatek,mt8186-vcodec-dec". Adds MT8186's device private data mtk_vdec_single_core_pdata. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 ++++ .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h index 66cd6d2242c3..4572f92826f2 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h @@ -69,6 +69,7 @@ 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_lat_sig_core_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata; /* diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 6b52eaeedafa..2d21d0010c9c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -464,6 +464,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8192-vcodec-dec", .data = &mtk_lat_sig_core_pdata, }, + { + .compatible = "mediatek,mt8186-vcodec-dec", + .data = &mtk_vdec_single_core_pdata, + }, {}, }; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c index 3770e8117488..4b83f00a8857 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c @@ -522,3 +522,22 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = { .is_subdev_supported = true, .hw_arch = MTK_VDEC_LAT_SINGLE_CORE, }; + +const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = { + .init_vdec_params = mtk_init_vdec_params, + .ctrls_setup = mtk_vcodec_dec_ctrls_setup, + .vdec_vb2_ops = &mtk_vdec_request_vb2_ops, + .vdec_formats = mtk_video_formats, + .num_formats = &num_formats, + .default_out_fmt = &default_out_format, + .default_cap_fmt = &default_cap_format, + .vdec_framesizes = mtk_vdec_framesizes, + .num_framesizes = &num_framesizes, + .uses_stateless_api = true, + .worker = mtk_vdec_worker, + .flush_decoder = mtk_vdec_flush_decoder, + .cap_to_disp = mtk_vdec_stateless_cap_to_disp, + .get_cap_buffer = vdec_get_cap_buffer, + .is_subdev_supported = true, + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, +}; -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 1/3] mtk-vcodec: Support MT8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds MT8186's compatible "mediatek,mt8186-vcodec-dec". Adds MT8186's device private data mtk_vdec_single_core_pdata. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 ++++ .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h index 66cd6d2242c3..4572f92826f2 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h @@ -69,6 +69,7 @@ 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_lat_sig_core_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata; /* diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 6b52eaeedafa..2d21d0010c9c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -464,6 +464,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8192-vcodec-dec", .data = &mtk_lat_sig_core_pdata, }, + { + .compatible = "mediatek,mt8186-vcodec-dec", + .data = &mtk_vdec_single_core_pdata, + }, {}, }; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c index 3770e8117488..4b83f00a8857 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c @@ -522,3 +522,22 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = { .is_subdev_supported = true, .hw_arch = MTK_VDEC_LAT_SINGLE_CORE, }; + +const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = { + .init_vdec_params = mtk_init_vdec_params, + .ctrls_setup = mtk_vcodec_dec_ctrls_setup, + .vdec_vb2_ops = &mtk_vdec_request_vb2_ops, + .vdec_formats = mtk_video_formats, + .num_formats = &num_formats, + .default_out_fmt = &default_out_format, + .default_cap_fmt = &default_cap_format, + .vdec_framesizes = mtk_vdec_framesizes, + .num_framesizes = &num_framesizes, + .uses_stateless_api = true, + .worker = mtk_vdec_worker, + .flush_decoder = mtk_vdec_flush_decoder, + .cap_to_disp = mtk_vdec_stateless_cap_to_disp, + .get_cap_buffer = vdec_get_cap_buffer, + .is_subdev_supported = true, + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, +}; -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 1/3] mtk-vcodec: Support MT8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds MT8186's compatible "mediatek,mt8186-vcodec-dec". Adds MT8186's device private data mtk_vdec_single_core_pdata. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../platform/mtk-vcodec/mtk_vcodec_dec.h | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 ++++ .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h index 66cd6d2242c3..4572f92826f2 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h @@ -69,6 +69,7 @@ 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_lat_sig_core_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata; /* diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 6b52eaeedafa..2d21d0010c9c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -464,6 +464,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8192-vcodec-dec", .data = &mtk_lat_sig_core_pdata, }, + { + .compatible = "mediatek,mt8186-vcodec-dec", + .data = &mtk_vdec_single_core_pdata, + }, {}, }; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c index 3770e8117488..4b83f00a8857 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c @@ -522,3 +522,22 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = { .is_subdev_supported = true, .hw_arch = MTK_VDEC_LAT_SINGLE_CORE, }; + +const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = { + .init_vdec_params = mtk_init_vdec_params, + .ctrls_setup = mtk_vcodec_dec_ctrls_setup, + .vdec_vb2_ops = &mtk_vdec_request_vb2_ops, + .vdec_formats = mtk_video_formats, + .num_formats = &num_formats, + .default_out_fmt = &default_out_format, + .default_cap_fmt = &default_cap_format, + .vdec_framesizes = mtk_vdec_framesizes, + .num_framesizes = &num_framesizes, + .uses_stateless_api = true, + .worker = mtk_vdec_worker, + .flush_decoder = mtk_vdec_flush_decoder, + .cap_to_disp = mtk_vdec_stateless_cap_to_disp, + .get_cap_buffer = vdec_get_cap_buffer, + .is_subdev_supported = true, + .hw_arch = MTK_VDEC_PURE_SINGLE_CORE, +}; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 2022-01-22 7:56 ` Yunfei Dong (?) (?) @ 2022-01-22 7:56 ` Yunfei Dong -1 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds decoder dt-bindings for mt8186. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml index d587fc3e39fb..6415c9f29130 100644 --- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml @@ -47,7 +47,9 @@ description: | properties: compatible: - const: mediatek,mt8192-vcodec-dec + enum: + - mediatek,mt8192-vcodec-dec + - mediatek,mt8186-vcodec-dec reg: maxItems: 1 -- 2.25.1 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: Irui Wang, George Sun, Dafna Hirschfeld, srv_heupstream, devicetree, Project_Global_Chrome_Upstream_Group, linux-kernel, dri-devel, Xiaoyong Lu, linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Steve Cho, linux-media, linux-arm-kernel, AngeloGioacchino Del Regno Adds decoder dt-bindings for mt8186. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml index d587fc3e39fb..6415c9f29130 100644 --- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml @@ -47,7 +47,9 @@ description: | properties: compatible: - const: mediatek,mt8192-vcodec-dec + enum: + - mediatek,mt8192-vcodec-dec + - mediatek,mt8186-vcodec-dec reg: maxItems: 1 -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds decoder dt-bindings for mt8186. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml index d587fc3e39fb..6415c9f29130 100644 --- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml @@ -47,7 +47,9 @@ description: | properties: compatible: - const: mediatek,mt8192-vcodec-dec + enum: + - mediatek,mt8192-vcodec-dec + - mediatek,mt8186-vcodec-dec reg: maxItems: 1 -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Adds decoder dt-bindings for mt8186. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml index d587fc3e39fb..6415c9f29130 100644 --- a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml @@ -47,7 +47,9 @@ description: | properties: compatible: - const: mediatek,mt8192-vcodec-dec + enum: + - mediatek,mt8192-vcodec-dec + - mediatek,mt8186-vcodec-dec reg: maxItems: 1 -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 2022-01-22 7:56 ` Yunfei Dong (?) (?) @ 2022-02-09 3:02 ` Rob Herring -1 siblings, 0 replies; 20+ messages in thread From: Rob Herring @ 2022-02-09 3:02 UTC (permalink / raw) To: Yunfei Dong Cc: Dafna Hirschfeld, George Sun, dri-devel, linux-kernel, Daniel Vetter, linux-mediatek, Tomasz Figa, Mauro Carvalho Chehab, AngeloGioacchino Del Regno, Hans Verkuil, Tiffany Lin, Xiaoyong Lu, Hsin-Yi Wang, Alexandre Courbot, Rob Herring, Project_Global_Chrome_Upstream_Group, linux-media, Irui Wang, Andrew-CT Chen, devicetree, linux-arm-kernel, Steve Cho, srv_heupstream, Tzung-Bi Shih, Matthias Brugger, Benjamin Gaignard, Fritz Koenig On Sat, 22 Jan 2022 15:56:05 +0800, Yunfei Dong wrote: > Adds decoder dt-bindings for mt8186. > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Acked-by: Rob Herring <robh@kernel.org> _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-02-09 3:02 ` Rob Herring 0 siblings, 0 replies; 20+ messages in thread From: Rob Herring @ 2022-02-09 3:02 UTC (permalink / raw) To: Yunfei Dong Cc: Andrew-CT Chen, Dafna Hirschfeld, dri-devel, Xiaoyong Lu, Steve Cho, Irui Wang, George Sun, Benjamin Gaignard, Project_Global_Chrome_Upstream_Group, Fritz Koenig, linux-media, devicetree, Tzung-Bi Shih, Mauro Carvalho Chehab, Tomasz Figa, Rob Herring, linux-mediatek, Hsin-Yi Wang, Matthias Brugger, Tiffany Lin, linux-arm-kernel, AngeloGioacchino Del Regno, srv_heupstream, Alexandre Courbot, linux-kernel, Hans Verkuil On Sat, 22 Jan 2022 15:56:05 +0800, Yunfei Dong wrote: > Adds decoder dt-bindings for mt8186. > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-02-09 3:02 ` Rob Herring 0 siblings, 0 replies; 20+ messages in thread From: Rob Herring @ 2022-02-09 3:02 UTC (permalink / raw) To: Yunfei Dong Cc: Dafna Hirschfeld, George Sun, dri-devel, linux-kernel, Daniel Vetter, linux-mediatek, Tomasz Figa, Mauro Carvalho Chehab, AngeloGioacchino Del Regno, Hans Verkuil, Tiffany Lin, Xiaoyong Lu, Hsin-Yi Wang, Alexandre Courbot, Rob Herring, Project_Global_Chrome_Upstream_Group, linux-media, Irui Wang, Andrew-CT Chen, devicetree, linux-arm-kernel, Steve Cho, srv_heupstream, Tzung-Bi Shih, Matthias Brugger, Benjamin Gaignard, Fritz Koenig On Sat, 22 Jan 2022 15:56:05 +0800, Yunfei Dong wrote: > Adds decoder dt-bindings for mt8186. > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 @ 2022-02-09 3:02 ` Rob Herring 0 siblings, 0 replies; 20+ messages in thread From: Rob Herring @ 2022-02-09 3:02 UTC (permalink / raw) To: Yunfei Dong Cc: Dafna Hirschfeld, George Sun, dri-devel, linux-kernel, Daniel Vetter, linux-mediatek, Tomasz Figa, Mauro Carvalho Chehab, AngeloGioacchino Del Regno, Hans Verkuil, Tiffany Lin, Xiaoyong Lu, Hsin-Yi Wang, Alexandre Courbot, Rob Herring, Project_Global_Chrome_Upstream_Group, linux-media, Irui Wang, Andrew-CT Chen, devicetree, linux-arm-kernel, Steve Cho, srv_heupstream, Tzung-Bi Shih, Matthias Brugger, Benjamin Gaignard, Fritz Koenig On Sat, 22 Jan 2022 15:56:05 +0800, Yunfei Dong wrote: > Adds decoder dt-bindings for mt8186. > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Acked-by: Rob Herring <robh@kernel.org> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1, 3/3] mtk-vcodec: add h264 decoder driver for mt8186 2022-01-22 7:56 ` Yunfei Dong (?) (?) @ 2022-01-22 7:56 ` Yunfei Dong -1 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Add h264 decode driver to support mt8186. For the architecture is single core, need to add new interface to decode. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 3 files changed, 169 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c index 1567dbc63e95..5541edbafed2 100644 --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c @@ -137,6 +137,9 @@ struct vdec_h264_slice_share_info { * @vsi : vsi used for lat * @vsi_core : vsi used for core * + * @vsi_ctx : Local VSI data for this decoding context + * @h264_slice_param : the parameters that hardware use to decode + * * @resolution_changed : resolution changed * @realloc_mv_buf : reallocate mv buffer * @cap_num_planes : number of capture queue plane @@ -152,6 +155,9 @@ struct vdec_h264_slice_inst { struct vdec_h264_slice_vsi *vsi; struct vdec_h264_slice_vsi *vsi_core; + struct vdec_h264_slice_vsi vsi_ctx; + struct vdec_h264_slice_lat_dec_param h264_slice_param; + unsigned int resolution_changed; unsigned int realloc_mv_buf; unsigned int cap_num_planes; @@ -196,6 +202,61 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i return 0; } +static int get_vdec_sig_decode_parameters(struct vdec_h264_slice_inst *inst) +{ + const struct v4l2_ctrl_h264_decode_params *dec_params; + const struct v4l2_ctrl_h264_sps *sps; + const struct v4l2_ctrl_h264_pps *pps; + const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; + struct vdec_h264_slice_lat_dec_param *slice_param = &inst->h264_slice_param; + struct v4l2_h264_reflist_builder reflist_builder; + u8 *p0_reflist = slice_param->decode_params.ref_pic_list_p0; + u8 *b0_reflist = slice_param->decode_params.ref_pic_list_b0; + u8 *b1_reflist = slice_param->decode_params.ref_pic_list_b1; + + dec_params = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_DECODE_PARAMS); + if (IS_ERR(dec_params)) + return PTR_ERR(dec_params); + + sps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SPS); + if (IS_ERR(sps)) + return PTR_ERR(sps); + + pps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_PPS); + if (IS_ERR(pps)) + return PTR_ERR(pps); + + scaling_matrix = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX); + if (IS_ERR(scaling_matrix)) + return PTR_ERR(scaling_matrix); + + mtk_vdec_h264_update_dpb(dec_params, inst->dpb); + + mtk_vdec_h264_copy_sps_params(&slice_param->sps, sps); + mtk_vdec_h264_copy_pps_params(&slice_param->pps, pps); + mtk_vdec_h264_copy_scaling_matrix(&slice_param->scaling_matrix, scaling_matrix); + + mtk_vdec_h264_copy_decode_params(&slice_param->decode_params, dec_params, inst->dpb); + mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params, + slice_param->h264_dpb_info); + + /* Build the reference lists */ + v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps, inst->dpb); + v4l2_h264_build_p_ref_list(&reflist_builder, p0_reflist); + + v4l2_h264_build_b_ref_lists(&reflist_builder, b0_reflist, b1_reflist); + /* Adapt the built lists to the firmware's expectations */ + mtk_vdec_h264_fixup_ref_list(p0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b1_reflist, reflist_builder.num_valid); + memcpy(&inst->vsi_ctx.h264_slice_params, slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + + return 0; +} + static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *inst, struct vdec_h264_slice_lat_dec_param *slice_param, struct vdec_h264_slice_share_info *share_info) @@ -584,6 +645,102 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return err; } +static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = (struct vdec_h264_slice_inst *)h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info, *dst_buf_info; + struct vdec_fb *fb; + unsigned char *buf; + unsigned int nal_start_idx, data[2], i; + u64 y_fb_dma, c_fb_dma; + struct mtk_vcodec_mem *mem; + int err; + + /* bs NULL means flush decoder */ + if (!bs) + return vpu_dec_reset(vpu); + + fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + + y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=0x%llx", + inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma, (u64)fb); + + inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; + inst->vsi_ctx.dec.bs_buf_size = bs->size; + inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; + inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, + &dst_buf_info->m2m_buf.vb, true); + err = get_vdec_sig_decode_parameters(inst); + if (err) + goto err_free_fb_out; + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vcodec_debug(inst, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + } + } + + memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + err = vpu_dec_start(vpu, data, 2); + if (err) + goto err_free_fb_out; + + /* wait decoder done interrupt */ + err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (err) + mtk_vcodec_err(inst, "core decode timeout: pic_%d", + inst->ctx->decoded_frame_cnt); + + inst->vsi->dec.timeout = !!err; + err = vpu_dec_end(vpu); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + inst->ctx->decoded_frame_cnt, + inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], + inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], + inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], + inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); +err_free_fb_out: + inst->ctx->dev->vdec_pdata->cap_to_disp(inst->ctx, fb, err); + mtk_vcodec_debug(inst, "dec frame number: %d err: %d", + inst->ctx->decoded_frame_cnt, err); + inst->ctx->decoded_frame_cnt++; + + return err; +} + static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out) { @@ -612,3 +769,10 @@ const struct vdec_common_if vdec_h264_slice_lat_if = { .get_param = vdec_h264_slice_get_param, .deinit = vdec_h264_slice_deinit, }; + +const struct vdec_common_if vdec_h264_slice_single_if = { + .init = vdec_h264_slice_init, + .decode = vdec_h264_slice_single_decode, + .get_param = vdec_h264_slice_get_param, + .deinit = vdec_h264_slice_deinit, +}; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c index 2d3a45781359..e22b577d692a 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c @@ -21,7 +21,10 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc) switch (fourcc) { case V4L2_PIX_FMT_H264_SLICE: if (ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) { - ctx->dec_if = &vdec_h264_slice_if; + if (ctx->dev->vdec_pdata->is_subdev_supported) + ctx->dec_if = &vdec_h264_slice_single_if; + else + ctx->dec_if = &vdec_h264_slice_if; ctx->hw_id = MTK_VDEC_CORE; } else { ctx->dec_if = &vdec_h264_slice_lat_if; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h index e383a04db7b8..991c04e65c79 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h @@ -57,6 +57,7 @@ struct vdec_fb_node { extern const struct vdec_common_if vdec_h264_if; extern const struct vdec_common_if vdec_h264_slice_if; extern const struct vdec_common_if vdec_h264_slice_lat_if; +extern const struct vdec_common_if vdec_h264_slice_single_if; extern const struct vdec_common_if vdec_vp8_if; extern const struct vdec_common_if vdec_vp8_slice_if; extern const struct vdec_common_if vdec_vp9_if; -- 2.25.1 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 3/3] mtk-vcodec: add h264 decoder driver for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: Irui Wang, George Sun, Dafna Hirschfeld, srv_heupstream, devicetree, Project_Global_Chrome_Upstream_Group, linux-kernel, dri-devel, Xiaoyong Lu, linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Steve Cho, linux-media, linux-arm-kernel, AngeloGioacchino Del Regno Add h264 decode driver to support mt8186. For the architecture is single core, need to add new interface to decode. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 3 files changed, 169 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c index 1567dbc63e95..5541edbafed2 100644 --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c @@ -137,6 +137,9 @@ struct vdec_h264_slice_share_info { * @vsi : vsi used for lat * @vsi_core : vsi used for core * + * @vsi_ctx : Local VSI data for this decoding context + * @h264_slice_param : the parameters that hardware use to decode + * * @resolution_changed : resolution changed * @realloc_mv_buf : reallocate mv buffer * @cap_num_planes : number of capture queue plane @@ -152,6 +155,9 @@ struct vdec_h264_slice_inst { struct vdec_h264_slice_vsi *vsi; struct vdec_h264_slice_vsi *vsi_core; + struct vdec_h264_slice_vsi vsi_ctx; + struct vdec_h264_slice_lat_dec_param h264_slice_param; + unsigned int resolution_changed; unsigned int realloc_mv_buf; unsigned int cap_num_planes; @@ -196,6 +202,61 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i return 0; } +static int get_vdec_sig_decode_parameters(struct vdec_h264_slice_inst *inst) +{ + const struct v4l2_ctrl_h264_decode_params *dec_params; + const struct v4l2_ctrl_h264_sps *sps; + const struct v4l2_ctrl_h264_pps *pps; + const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; + struct vdec_h264_slice_lat_dec_param *slice_param = &inst->h264_slice_param; + struct v4l2_h264_reflist_builder reflist_builder; + u8 *p0_reflist = slice_param->decode_params.ref_pic_list_p0; + u8 *b0_reflist = slice_param->decode_params.ref_pic_list_b0; + u8 *b1_reflist = slice_param->decode_params.ref_pic_list_b1; + + dec_params = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_DECODE_PARAMS); + if (IS_ERR(dec_params)) + return PTR_ERR(dec_params); + + sps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SPS); + if (IS_ERR(sps)) + return PTR_ERR(sps); + + pps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_PPS); + if (IS_ERR(pps)) + return PTR_ERR(pps); + + scaling_matrix = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX); + if (IS_ERR(scaling_matrix)) + return PTR_ERR(scaling_matrix); + + mtk_vdec_h264_update_dpb(dec_params, inst->dpb); + + mtk_vdec_h264_copy_sps_params(&slice_param->sps, sps); + mtk_vdec_h264_copy_pps_params(&slice_param->pps, pps); + mtk_vdec_h264_copy_scaling_matrix(&slice_param->scaling_matrix, scaling_matrix); + + mtk_vdec_h264_copy_decode_params(&slice_param->decode_params, dec_params, inst->dpb); + mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params, + slice_param->h264_dpb_info); + + /* Build the reference lists */ + v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps, inst->dpb); + v4l2_h264_build_p_ref_list(&reflist_builder, p0_reflist); + + v4l2_h264_build_b_ref_lists(&reflist_builder, b0_reflist, b1_reflist); + /* Adapt the built lists to the firmware's expectations */ + mtk_vdec_h264_fixup_ref_list(p0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b1_reflist, reflist_builder.num_valid); + memcpy(&inst->vsi_ctx.h264_slice_params, slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + + return 0; +} + static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *inst, struct vdec_h264_slice_lat_dec_param *slice_param, struct vdec_h264_slice_share_info *share_info) @@ -584,6 +645,102 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return err; } +static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = (struct vdec_h264_slice_inst *)h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info, *dst_buf_info; + struct vdec_fb *fb; + unsigned char *buf; + unsigned int nal_start_idx, data[2], i; + u64 y_fb_dma, c_fb_dma; + struct mtk_vcodec_mem *mem; + int err; + + /* bs NULL means flush decoder */ + if (!bs) + return vpu_dec_reset(vpu); + + fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + + y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=0x%llx", + inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma, (u64)fb); + + inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; + inst->vsi_ctx.dec.bs_buf_size = bs->size; + inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; + inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, + &dst_buf_info->m2m_buf.vb, true); + err = get_vdec_sig_decode_parameters(inst); + if (err) + goto err_free_fb_out; + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vcodec_debug(inst, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + } + } + + memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + err = vpu_dec_start(vpu, data, 2); + if (err) + goto err_free_fb_out; + + /* wait decoder done interrupt */ + err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (err) + mtk_vcodec_err(inst, "core decode timeout: pic_%d", + inst->ctx->decoded_frame_cnt); + + inst->vsi->dec.timeout = !!err; + err = vpu_dec_end(vpu); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + inst->ctx->decoded_frame_cnt, + inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], + inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], + inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], + inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); +err_free_fb_out: + inst->ctx->dev->vdec_pdata->cap_to_disp(inst->ctx, fb, err); + mtk_vcodec_debug(inst, "dec frame number: %d err: %d", + inst->ctx->decoded_frame_cnt, err); + inst->ctx->decoded_frame_cnt++; + + return err; +} + static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out) { @@ -612,3 +769,10 @@ const struct vdec_common_if vdec_h264_slice_lat_if = { .get_param = vdec_h264_slice_get_param, .deinit = vdec_h264_slice_deinit, }; + +const struct vdec_common_if vdec_h264_slice_single_if = { + .init = vdec_h264_slice_init, + .decode = vdec_h264_slice_single_decode, + .get_param = vdec_h264_slice_get_param, + .deinit = vdec_h264_slice_deinit, +}; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c index 2d3a45781359..e22b577d692a 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c @@ -21,7 +21,10 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc) switch (fourcc) { case V4L2_PIX_FMT_H264_SLICE: if (ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) { - ctx->dec_if = &vdec_h264_slice_if; + if (ctx->dev->vdec_pdata->is_subdev_supported) + ctx->dec_if = &vdec_h264_slice_single_if; + else + ctx->dec_if = &vdec_h264_slice_if; ctx->hw_id = MTK_VDEC_CORE; } else { ctx->dec_if = &vdec_h264_slice_lat_if; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h index e383a04db7b8..991c04e65c79 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h @@ -57,6 +57,7 @@ struct vdec_fb_node { extern const struct vdec_common_if vdec_h264_if; extern const struct vdec_common_if vdec_h264_slice_if; extern const struct vdec_common_if vdec_h264_slice_lat_if; +extern const struct vdec_common_if vdec_h264_slice_single_if; extern const struct vdec_common_if vdec_vp8_if; extern const struct vdec_common_if vdec_vp8_slice_if; extern const struct vdec_common_if vdec_vp9_if; -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 3/3] mtk-vcodec: add h264 decoder driver for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Add h264 decode driver to support mt8186. For the architecture is single core, need to add new interface to decode. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 3 files changed, 169 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c index 1567dbc63e95..5541edbafed2 100644 --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c @@ -137,6 +137,9 @@ struct vdec_h264_slice_share_info { * @vsi : vsi used for lat * @vsi_core : vsi used for core * + * @vsi_ctx : Local VSI data for this decoding context + * @h264_slice_param : the parameters that hardware use to decode + * * @resolution_changed : resolution changed * @realloc_mv_buf : reallocate mv buffer * @cap_num_planes : number of capture queue plane @@ -152,6 +155,9 @@ struct vdec_h264_slice_inst { struct vdec_h264_slice_vsi *vsi; struct vdec_h264_slice_vsi *vsi_core; + struct vdec_h264_slice_vsi vsi_ctx; + struct vdec_h264_slice_lat_dec_param h264_slice_param; + unsigned int resolution_changed; unsigned int realloc_mv_buf; unsigned int cap_num_planes; @@ -196,6 +202,61 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i return 0; } +static int get_vdec_sig_decode_parameters(struct vdec_h264_slice_inst *inst) +{ + const struct v4l2_ctrl_h264_decode_params *dec_params; + const struct v4l2_ctrl_h264_sps *sps; + const struct v4l2_ctrl_h264_pps *pps; + const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; + struct vdec_h264_slice_lat_dec_param *slice_param = &inst->h264_slice_param; + struct v4l2_h264_reflist_builder reflist_builder; + u8 *p0_reflist = slice_param->decode_params.ref_pic_list_p0; + u8 *b0_reflist = slice_param->decode_params.ref_pic_list_b0; + u8 *b1_reflist = slice_param->decode_params.ref_pic_list_b1; + + dec_params = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_DECODE_PARAMS); + if (IS_ERR(dec_params)) + return PTR_ERR(dec_params); + + sps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SPS); + if (IS_ERR(sps)) + return PTR_ERR(sps); + + pps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_PPS); + if (IS_ERR(pps)) + return PTR_ERR(pps); + + scaling_matrix = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX); + if (IS_ERR(scaling_matrix)) + return PTR_ERR(scaling_matrix); + + mtk_vdec_h264_update_dpb(dec_params, inst->dpb); + + mtk_vdec_h264_copy_sps_params(&slice_param->sps, sps); + mtk_vdec_h264_copy_pps_params(&slice_param->pps, pps); + mtk_vdec_h264_copy_scaling_matrix(&slice_param->scaling_matrix, scaling_matrix); + + mtk_vdec_h264_copy_decode_params(&slice_param->decode_params, dec_params, inst->dpb); + mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params, + slice_param->h264_dpb_info); + + /* Build the reference lists */ + v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps, inst->dpb); + v4l2_h264_build_p_ref_list(&reflist_builder, p0_reflist); + + v4l2_h264_build_b_ref_lists(&reflist_builder, b0_reflist, b1_reflist); + /* Adapt the built lists to the firmware's expectations */ + mtk_vdec_h264_fixup_ref_list(p0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b1_reflist, reflist_builder.num_valid); + memcpy(&inst->vsi_ctx.h264_slice_params, slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + + return 0; +} + static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *inst, struct vdec_h264_slice_lat_dec_param *slice_param, struct vdec_h264_slice_share_info *share_info) @@ -584,6 +645,102 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return err; } +static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = (struct vdec_h264_slice_inst *)h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info, *dst_buf_info; + struct vdec_fb *fb; + unsigned char *buf; + unsigned int nal_start_idx, data[2], i; + u64 y_fb_dma, c_fb_dma; + struct mtk_vcodec_mem *mem; + int err; + + /* bs NULL means flush decoder */ + if (!bs) + return vpu_dec_reset(vpu); + + fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + + y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=0x%llx", + inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma, (u64)fb); + + inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; + inst->vsi_ctx.dec.bs_buf_size = bs->size; + inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; + inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, + &dst_buf_info->m2m_buf.vb, true); + err = get_vdec_sig_decode_parameters(inst); + if (err) + goto err_free_fb_out; + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vcodec_debug(inst, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + } + } + + memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + err = vpu_dec_start(vpu, data, 2); + if (err) + goto err_free_fb_out; + + /* wait decoder done interrupt */ + err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (err) + mtk_vcodec_err(inst, "core decode timeout: pic_%d", + inst->ctx->decoded_frame_cnt); + + inst->vsi->dec.timeout = !!err; + err = vpu_dec_end(vpu); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + inst->ctx->decoded_frame_cnt, + inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], + inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], + inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], + inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); +err_free_fb_out: + inst->ctx->dev->vdec_pdata->cap_to_disp(inst->ctx, fb, err); + mtk_vcodec_debug(inst, "dec frame number: %d err: %d", + inst->ctx->decoded_frame_cnt, err); + inst->ctx->decoded_frame_cnt++; + + return err; +} + static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out) { @@ -612,3 +769,10 @@ const struct vdec_common_if vdec_h264_slice_lat_if = { .get_param = vdec_h264_slice_get_param, .deinit = vdec_h264_slice_deinit, }; + +const struct vdec_common_if vdec_h264_slice_single_if = { + .init = vdec_h264_slice_init, + .decode = vdec_h264_slice_single_decode, + .get_param = vdec_h264_slice_get_param, + .deinit = vdec_h264_slice_deinit, +}; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c index 2d3a45781359..e22b577d692a 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c @@ -21,7 +21,10 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc) switch (fourcc) { case V4L2_PIX_FMT_H264_SLICE: if (ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) { - ctx->dec_if = &vdec_h264_slice_if; + if (ctx->dev->vdec_pdata->is_subdev_supported) + ctx->dec_if = &vdec_h264_slice_single_if; + else + ctx->dec_if = &vdec_h264_slice_if; ctx->hw_id = MTK_VDEC_CORE; } else { ctx->dec_if = &vdec_h264_slice_lat_if; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h index e383a04db7b8..991c04e65c79 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h @@ -57,6 +57,7 @@ struct vdec_fb_node { extern const struct vdec_common_if vdec_h264_if; extern const struct vdec_common_if vdec_h264_slice_if; extern const struct vdec_common_if vdec_h264_slice_lat_if; +extern const struct vdec_common_if vdec_h264_slice_single_if; extern const struct vdec_common_if vdec_vp8_if; extern const struct vdec_common_if vdec_vp8_slice_if; extern const struct vdec_common_if vdec_vp9_if; -- 2.25.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v1, 3/3] mtk-vcodec: add h264 decoder driver for mt8186 @ 2022-01-22 7:56 ` Yunfei Dong 0 siblings, 0 replies; 20+ messages in thread From: Yunfei Dong @ 2022-01-22 7:56 UTC (permalink / raw) To: Yunfei Dong, Alexandre Courbot, Hans Verkuil, Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen, Mauro Carvalho Chehab, Rob Herring, Matthias Brugger, Tomasz Figa Cc: George Sun, Xiaoyong Lu, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard, Daniel Vetter, dri-devel, Irui Wang, AngeloGioacchino Del Regno, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek, Project_Global_Chrome_Upstream_Group Add h264 decode driver to support mt8186. For the architecture is single core, need to add new interface to decode. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c | 164 ++++++++++++++++++ .../media/platform/mtk-vcodec/vdec_drv_if.c | 5 +- .../media/platform/mtk-vcodec/vdec_drv_if.h | 1 + 3 files changed, 169 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c index 1567dbc63e95..5541edbafed2 100644 --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_multi_if.c @@ -137,6 +137,9 @@ struct vdec_h264_slice_share_info { * @vsi : vsi used for lat * @vsi_core : vsi used for core * + * @vsi_ctx : Local VSI data for this decoding context + * @h264_slice_param : the parameters that hardware use to decode + * * @resolution_changed : resolution changed * @realloc_mv_buf : reallocate mv buffer * @cap_num_planes : number of capture queue plane @@ -152,6 +155,9 @@ struct vdec_h264_slice_inst { struct vdec_h264_slice_vsi *vsi; struct vdec_h264_slice_vsi *vsi_core; + struct vdec_h264_slice_vsi vsi_ctx; + struct vdec_h264_slice_lat_dec_param h264_slice_param; + unsigned int resolution_changed; unsigned int realloc_mv_buf; unsigned int cap_num_planes; @@ -196,6 +202,61 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i return 0; } +static int get_vdec_sig_decode_parameters(struct vdec_h264_slice_inst *inst) +{ + const struct v4l2_ctrl_h264_decode_params *dec_params; + const struct v4l2_ctrl_h264_sps *sps; + const struct v4l2_ctrl_h264_pps *pps; + const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; + struct vdec_h264_slice_lat_dec_param *slice_param = &inst->h264_slice_param; + struct v4l2_h264_reflist_builder reflist_builder; + u8 *p0_reflist = slice_param->decode_params.ref_pic_list_p0; + u8 *b0_reflist = slice_param->decode_params.ref_pic_list_b0; + u8 *b1_reflist = slice_param->decode_params.ref_pic_list_b1; + + dec_params = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_DECODE_PARAMS); + if (IS_ERR(dec_params)) + return PTR_ERR(dec_params); + + sps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SPS); + if (IS_ERR(sps)) + return PTR_ERR(sps); + + pps = mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_PPS); + if (IS_ERR(pps)) + return PTR_ERR(pps); + + scaling_matrix = + mtk_vdec_h264_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX); + if (IS_ERR(scaling_matrix)) + return PTR_ERR(scaling_matrix); + + mtk_vdec_h264_update_dpb(dec_params, inst->dpb); + + mtk_vdec_h264_copy_sps_params(&slice_param->sps, sps); + mtk_vdec_h264_copy_pps_params(&slice_param->pps, pps); + mtk_vdec_h264_copy_scaling_matrix(&slice_param->scaling_matrix, scaling_matrix); + + mtk_vdec_h264_copy_decode_params(&slice_param->decode_params, dec_params, inst->dpb); + mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params, + slice_param->h264_dpb_info); + + /* Build the reference lists */ + v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps, inst->dpb); + v4l2_h264_build_p_ref_list(&reflist_builder, p0_reflist); + + v4l2_h264_build_b_ref_lists(&reflist_builder, b0_reflist, b1_reflist); + /* Adapt the built lists to the firmware's expectations */ + mtk_vdec_h264_fixup_ref_list(p0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b0_reflist, reflist_builder.num_valid); + mtk_vdec_h264_fixup_ref_list(b1_reflist, reflist_builder.num_valid); + memcpy(&inst->vsi_ctx.h264_slice_params, slice_param, + sizeof(inst->vsi_ctx.h264_slice_params)); + + return 0; +} + static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *inst, struct vdec_h264_slice_lat_dec_param *slice_param, struct vdec_h264_slice_share_info *share_info) @@ -584,6 +645,102 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, return err; } +static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, + struct vdec_fb *unused, bool *res_chg) +{ + struct vdec_h264_slice_inst *inst = (struct vdec_h264_slice_inst *)h_vdec; + struct vdec_vpu_inst *vpu = &inst->vpu; + struct mtk_video_dec_buf *src_buf_info, *dst_buf_info; + struct vdec_fb *fb; + unsigned char *buf; + unsigned int nal_start_idx, data[2], i; + u64 y_fb_dma, c_fb_dma; + struct mtk_vcodec_mem *mem; + int err; + + /* bs NULL means flush decoder */ + if (!bs) + return vpu_dec_reset(vpu); + + fb = inst->ctx->dev->vdec_pdata->get_cap_buffer(inst->ctx); + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + dst_buf_info = container_of(fb, struct mtk_video_dec_buf, frame_buffer); + + y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; + c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; + mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=0x%llx", + inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma, (u64)fb); + + inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr; + inst->vsi_ctx.dec.bs_buf_size = bs->size; + inst->vsi_ctx.dec.y_fb_dma = y_fb_dma; + inst->vsi_ctx.dec.c_fb_dma = c_fb_dma; + inst->vsi_ctx.dec.vdec_fb_va = (u64)(uintptr_t)fb; + + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, + &dst_buf_info->m2m_buf.vb, true); + err = get_vdec_sig_decode_parameters(inst); + if (err) + goto err_free_fb_out; + + buf = (unsigned char *)bs->va; + nal_start_idx = mtk_vdec_h264_find_start_code(buf, bs->size); + if (nal_start_idx < 0) { + err = -EINVAL; + goto err_free_fb_out; + } + inst->vsi_ctx.dec.nal_info = buf[nal_start_idx]; + + *res_chg = inst->resolution_changed; + if (inst->resolution_changed) { + mtk_vcodec_debug(inst, "- resolution changed -"); + if (inst->realloc_mv_buf) { + err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo); + inst->realloc_mv_buf = false; + if (err) + goto err_free_fb_out; + } + inst->resolution_changed = false; + + for (i = 0; i < H264_MAX_MV_NUM; i++) { + mem = &inst->mv_buf[i]; + inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr; + } + } + + memcpy(inst->vpu.vsi, &inst->vsi_ctx, sizeof(inst->vsi_ctx)); + err = vpu_dec_start(vpu, data, 2); + if (err) + goto err_free_fb_out; + + /* wait decoder done interrupt */ + err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, + WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE); + if (err) + mtk_vcodec_err(inst, "core decode timeout: pic_%d", + inst->ctx->decoded_frame_cnt); + + inst->vsi->dec.timeout = !!err; + err = vpu_dec_end(vpu); + if (err) + goto err_free_fb_out; + + memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx)); + mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", + inst->ctx->decoded_frame_cnt, + inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1], + inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3], + inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5], + inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]); +err_free_fb_out: + inst->ctx->dev->vdec_pdata->cap_to_disp(inst->ctx, fb, err); + mtk_vcodec_debug(inst, "dec frame number: %d err: %d", + inst->ctx->decoded_frame_cnt, err); + inst->ctx->decoded_frame_cnt++; + + return err; +} + static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out) { @@ -612,3 +769,10 @@ const struct vdec_common_if vdec_h264_slice_lat_if = { .get_param = vdec_h264_slice_get_param, .deinit = vdec_h264_slice_deinit, }; + +const struct vdec_common_if vdec_h264_slice_single_if = { + .init = vdec_h264_slice_init, + .decode = vdec_h264_slice_single_decode, + .get_param = vdec_h264_slice_get_param, + .deinit = vdec_h264_slice_deinit, +}; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c index 2d3a45781359..e22b577d692a 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.c @@ -21,7 +21,10 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc) switch (fourcc) { case V4L2_PIX_FMT_H264_SLICE: if (ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_PURE_SINGLE_CORE) { - ctx->dec_if = &vdec_h264_slice_if; + if (ctx->dev->vdec_pdata->is_subdev_supported) + ctx->dec_if = &vdec_h264_slice_single_if; + else + ctx->dec_if = &vdec_h264_slice_if; ctx->hw_id = MTK_VDEC_CORE; } else { ctx->dec_if = &vdec_h264_slice_lat_if; diff --git a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h index e383a04db7b8..991c04e65c79 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_drv_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_drv_if.h @@ -57,6 +57,7 @@ struct vdec_fb_node { extern const struct vdec_common_if vdec_h264_if; extern const struct vdec_common_if vdec_h264_slice_if; extern const struct vdec_common_if vdec_h264_slice_lat_if; +extern const struct vdec_common_if vdec_h264_slice_single_if; extern const struct vdec_common_if vdec_vp8_if; extern const struct vdec_common_if vdec_vp8_slice_if; extern const struct vdec_common_if vdec_vp9_if; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2022-02-09 3:08 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-22 7:56 [PATCH v1, 0/3] support mt8186 decoder Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` [PATCH v1, 1/3] mtk-vcodec: Support MT8186 Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` [PATCH v1, 2/3] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8186 Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-02-09 3:02 ` Rob Herring 2022-02-09 3:02 ` Rob Herring 2022-02-09 3:02 ` Rob Herring 2022-02-09 3:02 ` Rob Herring 2022-01-22 7:56 ` [PATCH v1, 3/3] mtk-vcodec: add h264 decoder driver " Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong 2022-01-22 7:56 ` Yunfei Dong
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.