Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / media / platform / mtk-vcodec / mtk_vcodec_fw_scp.c
blobd8e66b645bd84eb9237828a6e4729658e4cc7811
1 // SPDX-License-Identifier: GPL-2.0
3 #include "mtk_vcodec_fw_priv.h"
4 #include "mtk_vcodec_util.h"
5 #include "mtk_vcodec_drv.h"
7 static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
9 return rproc_boot(scp_get_rproc(fw->scp));
12 static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw)
14 return scp_get_vdec_hw_capa(fw->scp);
17 static unsigned int mtk_vcodec_scp_get_venc_capa(struct mtk_vcodec_fw *fw)
19 return scp_get_venc_hw_capa(fw->scp);
22 static void *mtk_vcodec_vpu_scp_dm_addr(struct mtk_vcodec_fw *fw,
23 u32 dtcm_dmem_addr)
25 return scp_mapping_dm_addr(fw->scp, dtcm_dmem_addr);
28 static int mtk_vcodec_scp_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
29 mtk_vcodec_ipi_handler handler,
30 const char *name, void *priv)
32 return scp_ipi_register(fw->scp, id, handler, priv);
35 static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
36 unsigned int len, unsigned int wait)
38 return scp_ipi_send(fw->scp, id, buf, len, wait);
41 static void mtk_vcodec_scp_release(struct mtk_vcodec_fw *fw)
43 scp_put(fw->scp);
46 static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = {
47 .load_firmware = mtk_vcodec_scp_load_firmware,
48 .get_vdec_capa = mtk_vcodec_scp_get_vdec_capa,
49 .get_venc_capa = mtk_vcodec_scp_get_venc_capa,
50 .map_dm_addr = mtk_vcodec_vpu_scp_dm_addr,
51 .ipi_register = mtk_vcodec_scp_set_ipi_register,
52 .ipi_send = mtk_vcodec_scp_ipi_send,
53 .release = mtk_vcodec_scp_release,
56 struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(struct mtk_vcodec_dev *dev)
58 struct mtk_vcodec_fw *fw;
59 struct mtk_scp *scp;
61 scp = scp_get(dev->plat_dev);
62 if (!scp) {
63 mtk_v4l2_err("could not get vdec scp handle");
64 return ERR_PTR(-EPROBE_DEFER);
67 fw = devm_kzalloc(&dev->plat_dev->dev, sizeof(*fw), GFP_KERNEL);
68 fw->type = SCP;
69 fw->ops = &mtk_vcodec_rproc_msg;
70 fw->scp = scp;
72 return fw;