You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.3 KiB
83 lines
2.3 KiB
#include "dmcu_adapt.h"
|
|
#include "soc_osal.h"
|
|
#include "dmcu_dbg.h"
|
|
|
|
dmcu_send_cmd_para g_dmcu_send_cmd_para[] = {
|
|
dmcu_send_bundle_def(DMCU_CMD_VAM_ALLOC, TD_TRUE, TD_TRUE),
|
|
dmcu_send_bundle_def(DMCU_CMD_VAM_FREE, TD_TRUE, TD_TRUE),
|
|
dmcu_send_bundle_def(DMCU_CMD_MEM_INIT, TD_TRUE, TD_TRUE),
|
|
dmcu_send_bundle_def(DMCU_CMD_STARTUP, TD_FALSE, TD_FALSE),
|
|
};
|
|
|
|
td_void dmcu_init_send_msg(ipcm_msg *msg, dmcu_send_cmd_para *cmd_para, td_void *args, td_u32 length)
|
|
{
|
|
msg->head.cmd = cmd_para->cmd;
|
|
msg->head.option.need_ack = cmd_para->need_ack;
|
|
msg->head.option.need_data = cmd_para->need_data;
|
|
msg->data.data_len = length;
|
|
msg->data.para_data = (td_u64)(td_uintptr_t)args;
|
|
return;
|
|
}
|
|
|
|
static td_s32 get_cmd_index(dmcu_ctrl_cmd cmd)
|
|
{
|
|
td_u32 cmd_num = sizeof(g_dmcu_send_cmd_para) / sizeof(dmcu_send_cmd_para);
|
|
td_u32 i;
|
|
td_s32 index = -1;
|
|
|
|
for (i = 0; i < cmd_num; i++) {
|
|
if (cmd == g_dmcu_send_cmd_para[i].cmd) {
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
return index;
|
|
}
|
|
|
|
td_s32 dmcu_client_send_process(dmcu_ctrl_cmd cmd, td_void *args, td_u32 length)
|
|
{
|
|
td_s32 cmd_idx = -1;
|
|
ipcm_msg msg = { { 0 }, { 0 } };
|
|
|
|
if (cmd >= DMCU_CMD_CTRL_MAX) {
|
|
soc_log_err("check ctrl cmd fail. cmd:%d!\n", cmd);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
cmd_idx = get_cmd_index(cmd);
|
|
if (cmd_idx == -1) {
|
|
osal_printk("get ctrl index fail. cmd:%d\n", cmd);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
dmcu_init_send_msg(&msg, &g_dmcu_send_cmd_para[cmd_idx], args, length);
|
|
return drv_ipcm_send_msg(IPCM_CTRL, &msg);
|
|
}
|
|
|
|
td_s32 dmcu_adapt_init(td_void)
|
|
{
|
|
td_s32 ret;
|
|
mcu_dmcu_status *mcu_status = get_mcu_status();
|
|
ret = drv_ipcm_init(IPCM_DMCU);
|
|
if (ret != TD_SUCCESS) {
|
|
osal_printk("drv_ipcm_init fail\n");
|
|
return TD_FAILURE;
|
|
}
|
|
mcu_status->bit.drv_ipcm_init = 1;
|
|
|
|
ret = drv_ipcm_open(IPCM_CTRL, DMCU_IPCM_CTRL_SIZE);
|
|
if (ret != TD_SUCCESS) {
|
|
osal_printk("drv_ipcm_open fail\n");
|
|
drv_ipcm_deinit();
|
|
return TD_FAILURE;
|
|
}
|
|
mcu_status->bit.drv_ipcm_open = 1;
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 dmcu_adapt_deinit(td_void)
|
|
{
|
|
drv_ipcm_deinit();
|
|
drv_ipcm_close(IPCM_CTRL);
|
|
return TD_SUCCESS;
|
|
} |