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