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

📄 uem_proc_msg.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    uem_bmt_struct bmt_status;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    uem_set_poweron_mode(POWER_ON_EXCEPTION);
    uem_get_bat_status(&bmt_status);
    l4cuem_power_on_ind(POWER_ON_EXCEPTION, uem_vbat_level_convert(bmt_status.volt));
    return;
}

/*****************************************************************************
*   Function 
*      uemdrv_pmic_ind
*   DESCRIPTION
*      The function is used to notify the battery status from PMIC driver.
*   PARAMETERS
*      alarm_status   IN   
*   RETURNS
*      void
*   GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uemdrv_pmic_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  status_type     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void uemdrv_pmic_ind(kal_uint8 status_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    uem_bmt_struct bmt_status;
    kal_uint8 vbat_level;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_UEM_PMIC_DETECT);
    /* reserve future to call back with message while the BMT indication notify */

    uem_get_bat_status(&bmt_status);

    if (status_type == PMIC_VBAT_STATUS)
    {
        vbat_level = custom_cfg_vbat_level_regulator(
                        bmt_status.volt,
                        &(g_uem_cntx_p->bmt_status.last_level),
                        &(g_uem_cntx_p->bmt_status.disp_level),
                        &(g_uem_cntx_p->bmt_status.hit_count));
    }
    else
    {
        vbat_level = g_uem_cntx_p->bmt_status.disp_level;
    }

    kal_prompt_trace(
        MOD_UEM,
        "[BAT_LV: %u] [BMT status:%d volt:%d last:%d disp:%d cnt:%d]",
        vbat_level,
        bmt_status.status,
        bmt_status.volt,
        g_uem_cntx_p->bmt_status.last_level,
        g_uem_cntx_p->bmt_status.disp_level,
        g_uem_cntx_p->bmt_status.hit_count);

    switch (status_type)
    {
        case PMIC_VBAT_STATUS:          /* Notify the battery voltage, pass */
        case PMIC_OVERVOLPROTECT:       /* The voltage of battery is too high, pass */
        case PMIC_OVERBATTEMP:          /* The temperature of battery is too high, pass */
        case PMIC_LOWBATTEMP:           /* The temperature of battery is too low, pass */
        case PMIC_OVERCHARGECURRENT:    /* Charge current is too large, pass */
        case PMIC_LOWCHARGECURRENT:     /* Charge current is too large, pass */
        case PMIC_CHARGE_COMPLETE:      /* Charge is completed, pass */
        case PMIC_INVALID_BATTERY:      /* invalid battery, pass */
        case PMIC_INVALID_CHARGER:      /* invalid charger, pass */
        case PMIC_CHARGING_TIMEOUT:     /* Bad battery, pass */
        case PMIC_CHARGE_BAD_CONTACT:   /* Charger Bad Contact, pass */
        case PMIC_BATTERY_BAD_CONTACT:  /* Battery Bad Contact, pass */
            l4cuem_battery_status_ind(status_type, vbat_level);
            break;

        case PMIC_USB_NO_CHARGER_OUT:   /* pass */
        case PMIC_USB_CHARGER_OUT:      /* USB Charger out */
        {
        #if defined(PLUTO_MMI)
            /* check if the accessory prev state is IN && it is not in progress */
            if (FLAG_IS_ON(g_uem_cntx_p->acc_prev_state, UEM_ACCESSORY_TYPE_USB_CHARGER) &&
                !FLAG_IS_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_USB_CHARGER))
            {
                l4cuem_battery_status_ind(status_type, vbat_level);     /* Notify MMI */

                /* Set in Progress */
                FLAG_SET_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_USB_CHARGER);
            }
            /* update the latest status */
            FLAG_SET_OFF(g_uem_cntx_p->acc_latest_state, UEM_ACCESSORY_TYPE_USB_CHARGER);
        #else /* defined(PLUTO_MMI) */ 
            l4cuem_battery_status_ind(status_type, vbat_level);
        #endif /* defined(PLUTO_MMI) */ 

            break;
        }
        case PMIC_USB_NO_CHARGER_IN:    /* pass */
        case PMIC_USB_CHARGER_IN:       /* USB Charger in */
        {
        #if defined(PLUTO_MMI)
            /* check if the accessory prev state is OUT && it is not in progress */
            if (!FLAG_IS_ON(g_uem_cntx_p->acc_prev_state, UEM_ACCESSORY_TYPE_USB_CHARGER) &&
                !FLAG_IS_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_USB_CHARGER))
            {

                l4cuem_battery_status_ind(status_type, vbat_level);     /* Notify MMI */

                /* Set in Progress */
                FLAG_SET_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_USB_CHARGER);
            }
            /* update the latest status */
            FLAG_SET_ON(g_uem_cntx_p->acc_latest_state, UEM_ACCESSORY_TYPE_USB_CHARGER);

            uem_pmic_power_on_if_needed(vbat_level);
        #else /* defined(PLUTO_MMI) */ 
            l4cuem_battery_status_ind(status_type, vbat_level);
            uem_pmic_power_on_if_needed(vbat_level);
        #endif /* defined(PLUTO_MMI) */ 
            break;
        }

        case PMIC_CHARGER_OUT:
        {
        #if defined(PLUTO_MMI)
            /* check if the accessory prev state is IN && it is not in progress */
            if (FLAG_IS_ON(g_uem_cntx_p->acc_prev_state, UEM_ACCESSORY_TYPE_CHARGER) &&
                !FLAG_IS_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_CHARGER))
            {
                l4cuem_battery_status_ind(status_type, vbat_level);     /* Notify MMI */

                /* Set in Progress */
                FLAG_SET_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_CHARGER);
            }
            /* update the latest status */
            FLAG_SET_OFF(g_uem_cntx_p->acc_latest_state, UEM_ACCESSORY_TYPE_CHARGER);
        #else /* defined(PLUTO_MMI) */ 
            l4cuem_battery_status_ind(status_type, vbat_level);
        #endif /* defined(PLUTO_MMI) */ 

            break;
        }

        case PMIC_CHARGER_IN:   /* Charger plug in */
        {
        #if defined(PLUTO_MMI)
            /* check if the accessory prev state is OUT && it is not in progress */
            if (!FLAG_IS_ON(g_uem_cntx_p->acc_prev_state, UEM_ACCESSORY_TYPE_CHARGER) &&
                !FLAG_IS_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_CHARGER))
            {
                /* Always send charger-in indication to avoid fast repeating charger in-out b4 power-on completes */
                l4cuem_battery_status_ind(status_type, vbat_level);

                /* Set in Progress */
                FLAG_SET_ON(g_uem_cntx_p->acc_progress, UEM_ACCESSORY_TYPE_CHARGER);
            }

            /* update the latest status */
            FLAG_SET_ON(g_uem_cntx_p->acc_latest_state, UEM_ACCESSORY_TYPE_CHARGER);

            uem_pmic_power_on_if_needed(vbat_level);
        #else /* defined(PLUTO_MMI) */ 
            l4cuem_battery_status_ind(status_type, vbat_level);
            uem_pmic_power_on_if_needed(vbat_level);
        #endif /* defined(PLUTO_MMI) */ 
            break;

        }

        default:
            break;
    }
}

/*****************************************************************************
*   Function 
*      uemdrv_gpio_detect_ind
*   DESCRIPTION
*      The function is used to detect the GPIO device including hand-free, and earphone. 
*      When the driver detect any earphone is plugged in, it will callback this function 
*      to notify MMI, if the driver detect the earphone is plugged out, it will callback 
*      this function to notify MMI too.
*   PARAMETERS
*      gpio_device      IN
*     on_off         IN
*   RETURNS
*      void
*   GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uemdrv_gpio_detect_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ext_gpio_device     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void uemdrv_gpio_detect_ind(kal_uint8 ext_gpio_device)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    /* the gpio plug in */
    switch (ext_gpio_device)
    {
        case EXT_DEV_NONE:
        {
            /* set output path, audio_mode has been change at uemdrv_aux_id_hdlr() */
            uem_send_msg_to_aud(MSG_ID_L4AUD_GPIO_DETECT_IND, (kal_uint32) ext_gpio_device);
            l4cuem_gpio_detect_ind(g_uem_cntx_p->ext_dev_status, KAL_FALSE);
            g_uem_cntx_p->ext_dev_status = EXT_DEV_NONE;
            /* l4cuem_gpio_detect_ind(EXT_DEV_NONE, KAL_FALSE); */
            break;
        }

        case EXT_DEV_HANDFREE:
        case EXT_DEV_EARPHONE:
        case EXT_DEV_CARKIT:
            /* set output path, audio_mode has been change at uemdrv_aux_id_hdlr() */
            uem_send_msg_to_aud(MSG_ID_L4AUD_GPIO_DETECT_IND, (kal_uint32) ext_gpio_device);
        case EXT_DEV_UART:
            /* Only accessory plug in/out change context */
            g_uem_cntx_p->ext_dev_status = ext_gpio_device;
        case EXT_DEV_KEY_1:
        case EXT_DEV_KEY_2:
        case EXT_DEV_CLAM_OPEN:
        case EXT_DEV_CLAM_CLOSE:
            l4cuem_gpio_detect_ind(ext_gpio_device, KAL_TRUE);
            break;

        default:
            break;
    }
}

/*****************************************************************************
*  Function 
*     uemdrv_audio_play_finish_ind
*  DESCRIPTION
*     ...
*  PARAMETERS
*  
*  
*  RETURNS
*     void
*  GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uemdrv_audio_play_finish_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  result          [IN]        
 *  identifier      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void uemdrv_audio_play_finish_ind(kal_uint8 result, kal_uint16 identifier)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    l4cuem_audio_play_finish_ind(result, identifier);
}

#ifdef __USB_ENABLE__
/*****************************************************************************
*  Function 
*     uemdrv_usb_power_on_ind
*  DESCRIPTION
*     ...
*  PARAMETERS
*  
*  
*  RETURNS
*     void
*  GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uemdrv_usb_power_on_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void uemdrv_usb_power_on_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    uem_set_poweron_mode(POWER_ON_USB);

   /***  2004/05/28 Robin
     *   Postpone latch power to uemdrv_usb_detect_ind() because driver will send power on indication
     * before SW debounce time finish. If user plug out usb device during the SW debounce time,
     * driver will not send out USB_DETECT_IND/plugout so wil not able to  power off
   ***/
#ifndef __NVRAM_IN_USB_MS__
    l4cuem_usb_power_on_ind();
#endif 
    return;
}

/*****************************************************************************
*  Function 
*     uemdrv_usb_detect_ind
*  DESCRIPTION
*     ...
*  PARAMETERS
*  
*  
*  RETURNS
*     void
*  GLOBALS AFFECTED
*****************************************************************************/


/*****************************************************************************
 * FUNCTION
 *  uemdrv_usb_detect_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  action      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void uemdrv_usb_detect_ind(kal_uint8 action)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (action == DEVUSB_DETECT_ACTION_PLUGOUT)
    {
    #ifndef __NVRAM_IN_USB_MS__
        if (uem_get_poweron_mode() == POWER_ON_USB)
        {
            DRV_POWEROFF();
        #if (defined(MT6318) || defined(MT6305))
            DRV_RESET();
        #endif 
            return;
        }
    #endif /* __NVRAM_IN_USB_MS__ */ 

    #if defined(__USB_IN_NORMAL_MODE__) && defined (APPMEM_SUPPORT)
        if (uem_normal_ms_buffer)
        {
            kal_app_mem_free(uem_normal_ms_buffer);
            uem_normal_ms_buffer = NULL;
        }
    #endif /* defined(__USB_IN_NORMAL_MODE__) && defined (APPMEM_SUPPORT) */ 
    }

⌨️ 快捷键说明

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