Ejemplo n.º 1
0
/*!
 * @brief This utility function sets the audio mode in Atlas and stereo emu headset
 *        pull up.
 *
 * @param mode - The headset mode
 *
 */
void emu_util_set_emu_headset_mode(MOTO_ACCY_HEADSET_MODE_T mode)
{
    switch(mode)
    {   
        case MOTO_ACCY_HEADSET_MODE_NONE:
            EMU_SET_REVERSE_MODE(false);

            /* Don't allow power management to suspend the phone while waiting for VBUS to settle. */
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] |= POWER_IC_EMU_REV_MODE_SLEEP;
            
            /* mdelay must be used here because the delay cannot be allowed to be longer than 20 ms. */
            mdelay(12);
            
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] &= ~(POWER_IC_EMU_REV_MODE_SLEEP);
            
            EMU_SET_EMU_CONN_MODE(POWER_IC_EMU_CONN_MODE_USB);
            EMU_SET_HEADSET_PULL_UP(0);
            /*Following is the work around for the emu headset send/end key*/
            EMU_SET_HS_SEND_END_REGS(1);
            EMU_SET_VUSB_INPUT_SOURCE(EMU_VREG_IN_VINBUS);
            break;
        
        case MOTO_ACCY_HEADSET_MODE_MONO:
            EMU_SET_VUSB_INPUT_SOURCE(EMU_VREG_IN_BPLUS);
            EMU_SET_HS_SEND_END_REGS(0);
            EMU_SET_EMU_CONN_MODE(POWER_IC_EMU_CONN_MODE_MONO_AUDIO);
            EMU_SET_HEADSET_PULL_UP(0);
            
            /* Don't allow power management to suspend the phone while waiting for D- to settle */
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] |= POWER_IC_EMU_DMINUS_MONO_SLEEP;
            msleep(10);
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] &= ~(POWER_IC_EMU_DMINUS_MONO_SLEEP);
            
            EMU_SET_REVERSE_MODE(true);
            break;
            
        case MOTO_ACCY_HEADSET_MODE_STEREO:
            EMU_SET_VUSB_INPUT_SOURCE(EMU_VREG_IN_BPLUS);
            EMU_SET_HS_SEND_END_REGS(0);
            EMU_SET_EMU_CONN_MODE(POWER_IC_EMU_CONN_MODE_STEREO_AUDIO);
            EMU_SET_HEADSET_PULL_UP(1);
            
            /* Don't allow power management to suspend the phone while waiting for D- to settle */
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] |= POWER_IC_EMU_DMINUS_STEREO_SLEEP;
            msleep(10);
            power_ic_pm_suspend_mask_tbl[POWER_IC_PM_MISC_SLEEPS] &= ~(POWER_IC_EMU_DMINUS_STEREO_SLEEP);
            
            EMU_SET_REVERSE_MODE(true);
            break;
        
        default:
            tracemsg(_k_d("EMU: Audio Mode %d not supported"), mode);
    }
}
Ejemplo n.º 2
0
/*!
 * @brief Used to determine what type of PPD this is initially.
 *
 * The event handler function reads the state of the D+ and D- lines to determine
 * what type of accessory is connected. The state is then changed to the
 * Connected state along with an indication of the identification of the accessory.
 *
 * @param polling_interval a return parameter that holds the "polling rate"
 *
 * @return next_state tells the state machine what the next EMU state is
 */
EMU_STATE_T pre_ppd_identify_handler(int *polling_interval)
{
    *polling_interval = EMU_POLL_CONTINUE;
    switch (get_bus_state(EMU_BUS_SIGNAL_DP_DM))
    {
        case EMU_BUS_SIGNAL_STATE_DP_DM_10:   

            tracemsg(_k_d("Set the GPIO for ST headset"));
            EMU_SET_HEADSET_PULL_UP(ENABLE);
            return EMU_STATE_CONNECTING__PPD_IDENTIFY;
            break;
              
        case EMU_BUS_SIGNAL_STATE_DP_DM_00:
        case EMU_BUS_SIGNAL_STATE_DP_DM_01:
        case EMU_BUS_SIGNAL_STATE_DP_DM_11:
        default:
            emu_current_device = MOTO_ACCY_TYPE_NOT_SUPPORTED;
            return EMU_STATE_CONNECTED__NOT_SUPPORTED;
            break;
    }
}