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
,
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
)
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
;
61 scp
= scp_get(dev
->plat_dev
);
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
);
69 fw
->ops
= &mtk_vcodec_rproc_msg
;