1 // SPDX-License-Identifier: GPL-2.0
2
3 #include "../decoder/mtk_vcodec_dec_drv.h"
4 #include "../encoder/mtk_vcodec_enc_drv.h"
5 #include "mtk_vcodec_fw_priv.h"
6
mtk_vcodec_fw_select(void * priv,enum mtk_vcodec_fw_type type,enum mtk_vcodec_fw_use fw_use)7 struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
8 enum mtk_vcodec_fw_use fw_use)
9 {
10 struct platform_device *plat_dev;
11
12 if (fw_use == ENCODER)
13 plat_dev = ((struct mtk_vcodec_enc_dev *)priv)->plat_dev;
14 else
15 plat_dev = ((struct mtk_vcodec_dec_dev *)priv)->plat_dev;
16
17 switch (type) {
18 case VPU:
19 return mtk_vcodec_fw_vpu_init(priv, fw_use);
20 case SCP:
21 return mtk_vcodec_fw_scp_init(priv, fw_use);
22 default:
23 dev_err(&plat_dev->dev, "Invalid vcodec fw type");
24 return ERR_PTR(-EINVAL);
25 }
26 }
27 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_select);
28
mtk_vcodec_fw_release(struct mtk_vcodec_fw * fw)29 void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw)
30 {
31 fw->ops->release(fw);
32 }
33 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release);
34
mtk_vcodec_fw_load_firmware(struct mtk_vcodec_fw * fw)35 int mtk_vcodec_fw_load_firmware(struct mtk_vcodec_fw *fw)
36 {
37 return fw->ops->load_firmware(fw);
38 }
39 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_load_firmware);
40
mtk_vcodec_fw_get_vdec_capa(struct mtk_vcodec_fw * fw)41 unsigned int mtk_vcodec_fw_get_vdec_capa(struct mtk_vcodec_fw *fw)
42 {
43 return fw->ops->get_vdec_capa(fw);
44 }
45 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_get_vdec_capa);
46
mtk_vcodec_fw_get_venc_capa(struct mtk_vcodec_fw * fw)47 unsigned int mtk_vcodec_fw_get_venc_capa(struct mtk_vcodec_fw *fw)
48 {
49 return fw->ops->get_venc_capa(fw);
50 }
51 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_get_venc_capa);
52
mtk_vcodec_fw_map_dm_addr(struct mtk_vcodec_fw * fw,u32 mem_addr)53 void *mtk_vcodec_fw_map_dm_addr(struct mtk_vcodec_fw *fw, u32 mem_addr)
54 {
55 return fw->ops->map_dm_addr(fw, mem_addr);
56 }
57 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_map_dm_addr);
58
mtk_vcodec_fw_ipi_register(struct mtk_vcodec_fw * fw,int id,mtk_vcodec_ipi_handler handler,const char * name,void * priv)59 int mtk_vcodec_fw_ipi_register(struct mtk_vcodec_fw *fw, int id,
60 mtk_vcodec_ipi_handler handler,
61 const char *name, void *priv)
62 {
63 return fw->ops->ipi_register(fw, id, handler, name, priv);
64 }
65 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_ipi_register);
66
mtk_vcodec_fw_ipi_send(struct mtk_vcodec_fw * fw,int id,void * buf,unsigned int len,unsigned int wait)67 int mtk_vcodec_fw_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
68 unsigned int len, unsigned int wait)
69 {
70 return fw->ops->ipi_send(fw, id, buf, len, wait);
71 }
72 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_ipi_send);
73
mtk_vcodec_fw_get_type(struct mtk_vcodec_fw * fw)74 int mtk_vcodec_fw_get_type(struct mtk_vcodec_fw *fw)
75 {
76 return fw->type;
77 }
78 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_get_type);
79