media: mtk-vcodec: fix builds when remoteproc is disabled
Subsystems (2)
v4 cover media: mtk-vcodec: fix builds when remoteproc is disabled
No functional changes since v3, but it does the job at fixing the build breakage. :) Please kindly take a look.
Changes since v3:
* Removed obsolete Acked-bys
* Fixed indentation in Kconfig file
Changes since v2:
* Use the FOO || !FOO magic suggested by Hans to ensure a built-in module does not try to link against symbols in a module,
* Added a patch to split the VPU and SCP ops into their own source files and make the optional build cleaner,
* Control the build of firmware implementations using two new transparent Kconfig symbols.
Changes since v1:
* Added Acked-by from Randy.
* Fixed typo in Kconfig description.
Alexandre Courbot (2):
media: mtk-vcodec: move firmware implementations into their own files
media: mtk-vcodec: fix build breakage when one of VPU or SCP is
enabled
drivers/media/platform/Kconfig | 28 ++- drivers/media/platform/mtk-vcodec/Makefile | 10 +- .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 2 +- .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 +- .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 174 +----------------- .../media/platform/mtk-vcodec/mtk_vcodec_fw.h | 7 +- .../platform/mtk-vcodec/mtk_vcodec_fw_priv.h | 52 ++++++ .../platform/mtk-vcodec/mtk_vcodec_fw_scp.c | 73 ++++++++ .../platform/mtk-vcodec/mtk_vcodec_fw_vpu.c | 109 +++++++++++ 9 files changed, 277 insertions(+), 180 deletions(-) create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_priv.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_scp.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c
--
2.29.0.rc1.297.gfa9743e501-goog
PATCH v4 1/2 media: mtk-vcodec: move firmware implementations into their own files
mtk-vcodec supports two kinds of firmware, VPU and SCP. Both were supported from the same source files, but this is clearly unclean and makes it more difficult to disable support for one or the other.
Move these implementations into their own file, after adding the necessary private interfaces.
--- drivers/media/platform/mtk-vcodec/Makefile | 4 +- .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 2 +- .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 +- .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 174 +----------------- .../media/platform/mtk-vcodec/mtk_vcodec_fw.h | 7 +- .../platform/mtk-vcodec/mtk_vcodec_fw_priv.h | 34 ++++ .../platform/mtk-vcodec/mtk_vcodec_fw_scp.c | 73 ++++++++ .../platform/mtk-vcodec/mtk_vcodec_fw_vpu.c | 109 +++++++++++ 8 files changed, 232 insertions(+), 173 deletions(-) create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_priv.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_scp.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c
drivers/media/platform/mtk-vcodec/Makefile +3 -1
@@ -24,4 +24,6 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \ mtk-vcodec-common-y := mtk_vcodec_intr.o \ mtk_vcodec_util.o \ - mtk_vcodec_fw.o + mtk_vcodec_fw.o \ + mtk_vcodec_fw_vpu.o \ + mtk_vcodec_fw_scp.o
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +1 -1
@@ -241,7 +241,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) }dma_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); - dev->fw_handler =mtk_vcodec_fw_select (dev, fw_type,VPU_RST_DEC ); + dev->fw_handler =mtk_vcodec_fw_select (dev, fw_type,DECODER );if (IS_ERR (dev->fw_handler))return PTR_ERR (dev->fw_handler);
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c +1 -1
@@ -293,7 +293,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) }dma_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); - dev->fw_handler =mtk_vcodec_fw_select (dev, fw_type,VPU_RST_ENC ); + dev->fw_handler =mtk_vcodec_fw_select (dev, fw_type,ENCODER );if (IS_ERR (dev->fw_handler))return PTR_ERR (dev->fw_handler);
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c +5 -169
198 lines not on this page · raw message
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h +6 -1
@@ -15,6 +15,11 @@ enum mtk_vcodec_fw_type { SCP, }; +enum mtk_vcodec_fw_use { +DECODER , +ENCODER , +}; +struct mtk_vcodec_fw ; typedef void (*mtk_vcodec_ipi_handler) (void *data,
@@ -22,7 +27,7 @@ typedef void (*mtk_vcodec_ipi_handler) (void *data,struct mtk_vcodec_fw *mtk_vcodec_fw_select (struct mtk_vcodec_dev *dev,enum mtk_vcodec_fw_type type, -enum rst_id rst_id); +enum mtk_vcodec_fw_use fw_use);void mtk_vcodec_fw_release (struct mtk_vcodec_fw *fw);int mtk_vcodec_fw_load_firmware (struct mtk_vcodec_fw *fw);
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_priv.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _MTK_VCODEC_FW_PRIV_H_ +#define _MTK_VCODEC_FW_PRIV_H_ + +#include "mtk_vcodec_fw.h" + +struct mtk_vcodec_dev ; + +struct mtk_vcodec_fw { +enum mtk_vcodec_fw_type type; +const struct mtk_vcodec_fw_ops *ops; +struct platform_device *pdev; +struct mtk_scp *scp; +}; + +struct mtk_vcodec_fw_ops { +int (*load_firmware)(struct mtk_vcodec_fw *fw); +unsigned int (*get_vdec_capa)(struct mtk_vcodec_fw *fw); +unsigned int (*get_venc_capa)(struct mtk_vcodec_fw *fw); +void *(*map_dm_addr)(struct mtk_vcodec_fw *fw,u32 dtcm_dmem_addr); +int (*ipi_register)(struct mtk_vcodec_fw *fw,int id, +mtk_vcodec_ipi_handler handler,const char *name, +void *priv); +int (*ipi_send)(struct mtk_vcodec_fw *fw,int id,void *buf, +unsigned int len,unsigned int wait); +void (*release)(struct mtk_vcodec_fw *fw); +}; + +struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init (struct mtk_vcodec_dev *dev, +enum mtk_vcodec_fw_use fw_use); +struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init (struct mtk_vcodec_dev *dev); + +#endif /* _MTK_VCODEC_FW_PRIV_H_ */
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_scp.c new file +73 -0
73 lines not on this page · raw message
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
Re: [PATCH v4 1/2] media: mtk-vcodec: move firmware implementations into their own files
Quoted 9 lines · Alexandre Courbot
mtk-vcodec supports two kinds of firmware, VPU and SCP. Both were supported from the same source files, but this is clearly unclean and makes it more difficult to disable support for one or the other.
Move these implementations into their own file, after adding the necessary private interfaces.
Signed-off-by Alexandre Courbot <[email protected]>
This should also have included a
Sorry for the omission.
PATCH v4 2/2 media: mtk-vcodec: fix build breakage when one of VPU or SCP is enabled
In reply to Alexandre CourbotThe addition of MT8183 support added a dependency on the SCP remoteproc module. However the initial patch used the "select" Kconfig directive, which may result in the SCP module to not be compiled if remoteproc was disabled. In such a case, mtk-vcodec would try to link against non-existent SCP symbols. "select" was clearly misused here as explained in kconfig-language.txt.
Replace this by a "depends" directive on at least one of the VPU and SCP modules, to allow the driver to be compiled as long as one of these is enabled, and adapt the code to support this new scenario.
Also adapt the Kconfig text to explain the extra requirements for MT8173 and MT8183.
--- drivers/media/platform/Kconfig | 28 ++++++++++++++----- drivers/media/platform/mtk-vcodec/Makefile | 10 +++++-- .../platform/mtk-vcodec/mtk_vcodec_fw_priv.h | 18 ++++++++++++ 3 files changed, 47 insertions(+), 9 deletions(-)
drivers/media/platform/Kconfig +21 -7
@@ -253,17 +253,31 @@ config VIDEO_MEDIATEK_VCODEC depends on MTK_IOMMU || COMPILE_TEST depends on VIDEO_DEV && VIDEO_V4L2 depends on ARCH_MEDIATEK || COMPILE_TEST + depends on VIDEO_MEDIATEK_VPU || MTK_SCP + # The two following lines ensure we have the same state ("m" or "y") as + # our dependencies, to avoid missing symbols during link. + depends on VIDEO_MEDIATEK_VPU || !VIDEO_MEDIATEK_VPU + depends on MTK_SCP || !MTK_SCP select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV - select VIDEO_MEDIATEK_VPU - select MTK_SCP + select VIDEO_MEDIATEK_VCODEC_VPU if VIDEO_MEDIATEK_VPU + select VIDEO_MEDIATEK_VCODEC_SCP if MTK_SCP help - Mediatek video codec driver provides HW capability to - encode and decode in a range of video formats - This driver rely on VPU driver to communicate with VPU. + Mediatek video codec driver provides HW capability to + encode and decode in a range of video formats on MT8173 + and MT8183. + + Note that support for MT8173 requires VIDEO_MEDIATEK_VPU to + also be selected. Support for MT8183 depends on MTK_SCP. + + To compile this driver as modules, choose M here: the + modules will be called mtk-vcodec-dec and mtk-vcodec-enc. + +config VIDEO_MEDIATEK_VCODEC_VPU + bool - To compile this driver as modules, choose M here: the - modules will be called mtk-vcodec-dec and mtk-vcodec-enc. +config VIDEO_MEDIATEK_VCODEC_SCP + bool config VIDEO_MEM2MEM_DEINTERLACE tristate "Deinterlace support"
drivers/media/platform/mtk-vcodec/Makefile +8 -2
@@ -25,5 +25,11 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \ mtk-vcodec-common-y := mtk_vcodec_intr.o \ mtk_vcodec_util.o \ mtk_vcodec_fw.o \ - mtk_vcodec_fw_vpu.o \ - mtk_vcodec_fw_scp.o + +ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_VPU),) +mtk-vcodec-common-y += mtk_vcodec_fw_vpu.o +endif + +ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP),) +mtk-vcodec-common-y += mtk_vcodec_fw_scp.o +endif
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_priv.h +18 -0
@@ -27,8 +27,26 @@ struct mtk_vcodec_fw_ops { void (*release)(struct mtk_vcodec_fw *fw); }; +#if IS_ENABLED (CONFIG_VIDEO_MEDIATEK_VCODEC_VPU )struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init (struct mtk_vcodec_dev *dev,enum mtk_vcodec_fw_use fw_use); +#else +static inline struct mtk_vcodec_fw * +mtk_vcodec_fw_vpu_init (struct mtk_vcodec_dev *dev, +enum mtk_vcodec_fw_use fw_use) +{ +return ERR_PTR (-ENODEV ); +} +#endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_VPU */ + +#if IS_ENABLED (CONFIG_VIDEO_MEDIATEK_VCODEC_SCP )struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init (struct mtk_vcodec_dev *dev); +#else +static inline struct mtk_vcodec_fw * +mtk_vcodec_fw_scp_init (struct mtk_vcodec_dev *dev) +{ +return ERR_PTR (-ENODEV ); +} +#endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_SCP */ #endif /* _MTK_VCODEC_FW_PRIV_H_ */
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
Re: [PATCH v4 2/2] media: mtk-vcodec: fix build breakage when one of VPU or SCP is enabled
Quoted 12 lines · Alexandre Courbot
The addition of MT8183 support added a dependency on the SCP remoteproc module. However the initial patch used the "select"
Kconfigdirective, which may result in the SCP module to not be compiled if remoteproc was disabled. In such a case, mtk-vcodec would try to link against non-existent SCP symbols. "select" was clearly misused here as explained in kconfig-language.txt.Replace this by a "depends" directive on at least one of the VPU and SCP modules, to allow the driver to be compiled as long as one of these is enabled, and adapt the code to support this new scenario.
Quoted 5 lines
Also adapt the
Kconfigtext to explain the extra requirements for MT8173 and MT8183.Reported-by Sakari Ailus <[email protected]>Signed-off-by Alexandre Courbot <[email protected]>
Gentle ping about this - we are already well into the 5.10 cycle so we don't have much time left if we want to merge this build breakage fix...
Quoted 39 lines · Alexandre Courbot
No functional changes since v3, but it does the job at fixing the build breakage. :) Please kindly take a look.
Changes since v3:
* Removed obsolete Acked-bys
* Fixed indentation inKconfigfileChanges since v2:
* Use the FOO || !FOO magic suggested by Hans to ensure a built-in module does not try to link against symbols in a module,
* Added a patch to split the VPU and SCP ops into their own source files and make the optional build cleaner,
* Control the build of firmware implementations using two new transparentKconfigsymbols.Changes since v1:
* Added Acked-by from Randy.
* Fixed typo inKconfigdescription.Alexandre Courbot (2):
media: mtk-vcodec: move firmware implementations into their own files
media: mtk-vcodec: fix build breakage when one of VPU or SCP is
enableddrivers/media/platform/Kconfig | 28 ++- drivers/media/platform/mtk-vcodec/Makefile | 10 +- .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 2 +- .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 +- .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 174 +----------------- .../media/platform/mtk-vcodec/mtk_vcodec_fw.h | 7 +- .../platform/mtk-vcodec/mtk_vcodec_fw_priv.h | 52 ++++++ .../platform/mtk-vcodec/mtk_vcodec_fw_scp.c | 73 ++++++++ .../platform/mtk-vcodec/mtk_vcodec_fw_vpu.c | 109 +++++++++++ 9 files changed, 277 insertions(+), 180 deletions(-) create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_priv.h create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_scp.c create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c
Quoted 3 lines
--
2.29.0.rc1.297.gfa9743e501-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Sakari Ailus
Acked-byQuoted 3 lines · Alexandre Courbot
Gentle ping about this - we are already well into the 5.10 cycle so we don't have much time left if we want to merge this build breakage fix...
Thanks for the ping.
For the set:
Signature · 1 line
Sakari Ailus
Quoted 11 lines · Sakari Ailus
Quoted 3 lines · Alexandre Courbot
Gentle ping about this - we are already well into the 5.10 cycle so we don't have much time left if we want to merge this build breakage fix...
Thanks for the ping.
For the set:
Acked-by Sakari Ailus <[email protected]>
Ah, just saw these patches included in Mauro's latest pull request. Seems all is good, thanks! :)