⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uem_utility.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uem2drv_usb_config_action_convert
 * DESCRIPTION
 *  
 * PARAMETERS
 *  action      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_uint8 uem2drv_usb_config_action_convert(kal_uint8 action)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    USB_DEVICE_TYPE usb_action = (USB_DEVICE_TYPE) action;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch (usb_action)
    {
        case DEVUSB_CFG_ACTION_CDC_ACM:
            return USB_CDC_ACM;

        case DEVUSB_CFG_ACTION_MASS_STORAGE:
            return USB_MASS_STORAGE;

        case DEVUSB_CFG_ACTION_WEBCAM:
            return USB_VIDEO;

        case DEVUSB_CFG_ACTION_COMPOSITE:
            return USB_COMPOSITE;

        case DEVUSB_CFG_ACTION_STOP_MS:
            return USB_STOP_MS;

        case DEVUSB_CFG_ACTION_IRDBG:
            return USB_CDC_ACM_IRDBG;

        default:
            return USB_UNKOWN;
    }
}
#endif /* __USB_ENABLE__ */ 

#if defined(PLUTO_MMI)
/*****************************************************************************
*   Function 
*      is_status_matched
*   DESCRIPTION
*      
*   PARAMETERS
*      
*   RETURNS
*      
*   GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  is_status_matched
 * DESCRIPTION
 *  
 * PARAMETERS
 *  type        [IN]        
 * RETURNS
 *  
 *****************************************************************************/
kal_bool is_status_matched(uem_accessory_status_enum type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (FLAG_IS_ON(g_uem_cntx_p->acc_prev_state, type) == FLAG_IS_ON(g_uem_cntx_p->acc_latest_state, type))
    {
        return KAL_TRUE;
    }
    else
    {
        return KAL_FALSE;
    }
}
#endif /* defined(PLUTO_MMI) */ 

/*****************************************************************************
*   Function 
*      uem_send_msg_to_l4c
*   DESCRIPTION
*      
*   PARAMETERS
*      msg_name        IN
*      data_ptr        IN
*   RETURNS
*      void
*   GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uem_send_msg_to_l4c
 * DESCRIPTION
 *  
 * PARAMETERS
 *  msg_name        [IN]        
 *  data_ptr        [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void uem_send_msg_to_l4c(msg_type msg_name, void *data_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool ret_val = KAL_TRUE;
    ilm_struct *ilm_ptr = NULL;
    void *local_data_ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_UEM_SEND_MSG_TO_L4C);

    /* First allocate a memory for an interlayer message structure */
    ilm_ptr = allocate_ilm(MOD_UEM);

    ilm_ptr->msg_id = msg_name; /* Set the message id */
    /* there are no peer message to be sent to UEM. Hence this field is null. */
    ilm_ptr->peer_buff_ptr = NULL;

    switch (msg_name)
    {
            /* set profile confirm to L4c */
        case MSG_ID_L4CUEM_SET_PROFILE_CNF:
            local_data_ptr =
                (l4cuem_set_profile_cnf_struct*) construct_local_para(sizeof(l4cuem_set_profile_cnf_struct), TD_CTRL);
            ((l4cuem_set_profile_cnf_struct*) local_data_ptr)->src_id = LMMI_SRC;
            ((l4cuem_set_profile_cnf_struct*) local_data_ptr)->type = g_uem_cntx_p->func_id;

            if (g_uem_cntx_p->cause_id == NVRAM_IO_ERRNO_OK)
            {
                ((l4cuem_set_profile_cnf_struct*) local_data_ptr)->response = L4C_OK;
            }
            else
            {
                ((l4cuem_set_profile_cnf_struct*) local_data_ptr)->response = L4C_ERROR;
            }

            ((l4cuem_set_profile_cnf_struct*) local_data_ptr)->cause = g_uem_cntx_p->cause_id;

            ilm_ptr->local_para_ptr = (local_para_struct*) local_data_ptr;
            break;

        case MSG_ID_L4CUEM_SET_HW_LEVEL_CNF:
            local_data_ptr =
                (l4cuem_set_hw_level_cnf_struct*) construct_local_para(
                                                    sizeof(l4cuem_set_hw_level_cnf_struct),
                                                    TD_CTRL);
            ((l4cuem_set_hw_level_cnf_struct*) local_data_ptr)->src_id = g_uem_cntx_p->src_id;

            if (g_uem_cntx_p->cause_id == NVRAM_IO_ERRNO_OK)
            {
                ((l4cuem_set_hw_level_cnf_struct*) local_data_ptr)->response = L4C_OK;
            }
            else
            {
                ((l4cuem_set_hw_level_cnf_struct*) local_data_ptr)->response = L4C_ERROR;
            }

            ((l4cuem_set_hw_level_cnf_struct*) local_data_ptr)->cause = g_uem_cntx_p->cause_id;

            ilm_ptr->local_para_ptr = (local_para_struct*) local_data_ptr;
            break;

            /* set startup confirm to L4c */
        case MSG_ID_L4CUEM_STARTUP_CNF:
            local_data_ptr =
                (l4cuem_startup_cnf_struct*) construct_local_para(sizeof(l4cuem_startup_cnf_struct), TD_CTRL);
            ((l4cuem_startup_cnf_struct*) local_data_ptr)->src_id = LMMI_SRC;

            if (g_uem_cntx_p->cause_id == NVRAM_IO_ERRNO_OK)
            {
                ((l4cuem_startup_cnf_struct*) local_data_ptr)->response = L4C_OK;
            }
            else
            {
                ((l4cuem_startup_cnf_struct*) local_data_ptr)->response = L4C_ERROR;
            }

            ((l4cuem_startup_cnf_struct*) local_data_ptr)->cause = g_uem_cntx_p->cause_id;

            ilm_ptr->local_para_ptr = (local_para_struct*) local_data_ptr;
            break;

        case MSG_ID_L4CUEM_SET_AUDIO_PROFILE_CNF:
        case MSG_ID_L4CUEM_SET_AUDIO_PARAM_CNF:
        case MSG_ID_L4CUEM_AUDIO_PLAY_BY_NAME_CNF:
        case MSG_ID_L4CUEM_AUDIO_STOP_BY_NAME_CNF:
        case MSG_ID_L4CUEM_AUDIO_PLAY_BY_STRING_CNF:
        case MSG_ID_L4CUEM_AUDIO_STOP_BY_STRING_CNF:
            /* hold the local parameter struct and directly pass to L4c */
            hold_local_para((local_para_struct*) data_ptr);
            ilm_ptr->local_para_ptr = (local_para_struct*) data_ptr;
            break;

        case MSG_ID_L4CPS_EM_STATUS_IND:
            /* Engineering mode idication: send status to L4C-EM module */
        {
            peer_buff_struct *peer_ptr;
            l4cps_em_status_ind_struct *local_ptr;
            kal_uint16 len_pdu;
            uem_em_battery_info *l_uem_battery_info;
            uem_bmt_struct bmt_status;

            /* get the battery status */
            uem_get_bat_status(&bmt_status);

            /* fill the battery status */
            peer_ptr = (peer_buff_struct*) construct_peer_buff(sizeof(uem_em_battery_info), 0, 0, TD_CTRL);
            l_uem_battery_info = (uem_em_battery_info*) get_pdu_ptr(peer_ptr, &(len_pdu));
            l_uem_battery_info->adc_value = bmt_status.volt;
            l_uem_battery_info->battery_level = uem_vbat_level_convert(bmt_status.volt);
            l_uem_battery_info->battery_status = bmt_status.status;

            /* fill the UEM battery infomation indication */
            local_ptr =
                (l4cps_em_status_ind_struct*) construct_local_para(sizeof(l4cps_em_status_ind_struct), TD_CTRL);
            local_ptr->em_info = UEM_EM_BATTERY_INFO;

            /* fill the message */
            ilm_ptr->local_para_ptr = (local_para_struct*) local_ptr;
            ilm_ptr->peer_buff_ptr = (peer_buff_struct*) peer_ptr;
            break;
        }

        default:
            ret_val = KAL_FALSE;
            /* SME_ASSERT(KAL_FALSE, "Wrong message" ); */
            break;
    }   /* End Switch */
    /* Check whether that there were no errors while constructing the message.  */

    /* Send the message to the UEM module */
    if (ret_val == KAL_TRUE)
    {
        SEND_ILM(MOD_UEM, MOD_L4C, UEM_L4C_SAP, ilm_ptr);
    }

    return;
}

/*****************************************************************************
*   Function 
*      uem_send_msg_to_nvram
*   DESCRIPTION
*      
*   PARAMETERS
*      msg_name        IN
*      ef_id           IN
*      data_ptr        IN
*      length        IN
*   RETURNS
*      void
*   GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uem_send_msg_to_nvram
 * DESCRIPTION
 *  
 * PARAMETERS
 *  msg_name        [IN]        
 *  ef_id           [IN]        
 *  data_ptr        [?]         
 *  length          [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void uem_send_msg_to_nvram(msg_type msg_name, kal_uint16 ef_id, void *data_ptr, kal_uint16 length)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool ret_val = KAL_TRUE;
    ilm_struct *ilm_ptr = NULL;
    peer_buff_struct *data_stream;
    local_para_struct *parm_stream;
    kal_uint16 pdu_len;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_UEM_SEND_MSG_TO_NVRAM);

    /* First allocate a memory for an interlayer message structure */
    ilm_ptr = allocate_ilm(MOD_UEM);

    ilm_ptr->msg_id = msg_name; /* Set the message id */
    /* there are no peer message to be sent to UEM. Hence this field is null. */
    ilm_ptr->peer_buff_ptr = NULL;
    /* there are no peer message to be sent to UEM. Hence this field is null. */
    ilm_ptr->local_para_ptr = NULL;
    switch (msg_name)
    {
        case MSG_ID_NVRAM_WRITE_REQ:
            switch (ef_id)
            {
                case NVRAM_EF_UEM_RMI_DATA_LID:
                case NVRAM_EF_CUST_HW_LEVEL_TBL_LID:
                    parm_stream = construct_local_para(sizeof(nvram_write_req_struct), TD_CTRL);
                    data_stream = construct_peer_buff(length, 0, 0, TD_CTRL);

                    ((nvram_write_req_struct*) parm_stream)->file_idx = (kal_uint8) ef_id;
                    ((nvram_write_req_struct*) parm_stream)->para = 1;
                    /* keep the function id in NVRAM message from UEM */
                    ((nvram_write_req_struct*) parm_stream)->access_id = g_uem_cntx_p->func_id;

                    pdu_len = length;
                    kal_mem_cpy(get_pdu_ptr(data_stream, &pdu_len), data_ptr, length);

                    ilm_ptr->local_para_ptr = (local_para_struct*) parm_stream;
                    ilm_ptr->peer_buff_ptr = (peer_buff_struct*) data_stream;
                    break;
                default:
                    /* error write */
                    break;
            }
            break;

        case MSG_ID_NVRAM_READ_REQ:
            switch (ef_id)
            {
                case NVRAM_EF_UEM_RMI_DATA_LID:
                case NVRAM_EF_UEM_MANUFACTURE_DATA_LID:
                case NVRAM_EF_CUST_HW_LEVEL_TBL_LID:
                    parm_stream = construct_local_para(sizeof(nvram_read_req_struct), TD_CTRL);

                    ((nvram_read_req_struct*) parm_stream)->file_idx = (kal_uint8) ef_id;
                    ((nvram_read_req_struct*) parm_stream)->para = 1;

                    ilm_ptr->local_para_ptr = (local_para_struct*) parm_stream;
                    break;

                default:
                    /* error read */
                    break;
            }
            break;

        default:
            ret_val = KAL_FALSE;
            /* SME_ASSERT(KAL_FALSE, "Wrong message" ); */
            break;
    }   /* End Switch */
    /* Check whether that there were no errors while constructing the message.  */

    /* Send the message to the NVRAM module */
    if (ret_val == KAL_TRUE)
    {
        SEND_ILM(MOD_UEM, MOD_NVRAM, PS_NVRAM_SAP, ilm_ptr);
    }

    return;
}

/*****************************************************************************
*   Function 
*      uem_send_msg_to_sat
*   DESCRIPTION
* 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -