void doubleshot_snddev_fmspk_pamp_on(int en) { pr_aud_info("%s %d\n", __func__, en); if (en) { /* enable rx route */ switch (system_rev) { case XA_DEV: gpio_set_value(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_SPK_ENO), 1); break; case XB_DEV: case XC_DEV: default: gpio_set_value(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_HANDSET_ENO), 1); set_speaker_amp(1); break; } if (!atomic_read(&aic3254_ctl)) curr_rx_mode |= BIT_FM_SPK; } else { /* disable rx route */ switch (system_rev) { case XA_DEV: gpio_set_value(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_SPK_ENO), 0); break; case XB_DEV: case XC_DEV: default: set_speaker_amp(0); gpio_set_value(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_HANDSET_ENO), 0); break; } if (!atomic_read(&aic3254_ctl)) curr_rx_mode &= ~BIT_FM_SPK; }}
void speedy_snddev_poweramp_on(int en) { pr_info("%s %d\n", __func__, en); if (en) { pm8058_spkr_gpio_cfg(1); mdelay(30); set_speaker_amp(1); } else { set_speaker_amp(0); pm8058_spkr_gpio_cfg(0); } }
void holiday_snddev_fmspk_pamp_on(int en) { pr_aud_info("%s %d\n", __func__, en); if (en) { gpio_set_value(PM8058_GPIO_PM_TO_SYS(HOLIDAY_AUD_HANDSET_ENO), 1); set_speaker_amp(1); if (!atomic_read(&aic3254_ctl)) curr_rx_mode |= BIT_FM_SPK; } else { set_speaker_amp(0); gpio_set_value(PM8058_GPIO_PM_TO_SYS(HOLIDAY_AUD_HANDSET_ENO), 0); if (!atomic_read(&aic3254_ctl)) curr_rx_mode &= ~BIT_FM_SPK; } }
void supersonic_speaker_enable(int en) { struct spkr_config_mode scm; memset(&scm, 0, sizeof(scm)); D("%s %d\n", __func__, en); if (en) { scm.is_right_chan_en = 0; scm.is_left_chan_en = 1; scm.is_stereo_en = 0; scm.is_hpf_en = 1; pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_set_spkr_configuration(&scm); pmic_spkr_en(LEFT_SPKR, 1); /* unmute */ pmic_spkr_en_mute(LEFT_SPKR, 1); } else { pmic_spkr_en_mute(LEFT_SPKR, 0); pmic_spkr_en(LEFT_SPKR, 0); pmic_set_spkr_configuration(&scm); } set_speaker_amp(en); }
void doubleshot_snddev_poweramp_on(int en) { pr_aud_info("%s %d\n", __func__, en); if (en) { msleep(50); gpio_direction_output(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_HP_EN), 1); set_speaker_amp(1); if (!atomic_read(&aic3254_ctl)) curr_rx_mode |= BIT_SPEAKER; } else { set_speaker_amp(0); gpio_direction_output(PM8058_GPIO_PM_TO_SYS(DOUBLESHOT_AUD_HP_EN), 0); if (!atomic_read(&aic3254_ctl)) curr_rx_mode &= ~BIT_SPEAKER; } }
void pyramid_snddev_fmspk_pamp_on(int en) { pr_aud_info("%s %d\n", __func__, en); if (en) { gpio_request(PM8058_GPIO_PM_TO_SYS(PYRAMID_AUD_HP_EN), "AUD_HP_EN"); gpio_direction_output(PM8058_GPIO_PM_TO_SYS(PYRAMID_AUD_HP_EN), 1); set_speaker_amp(1); if (!atomic_read(&aic3254_ctl)) curr_rx_mode |= BIT_FM_SPK; } else { set_speaker_amp(0); gpio_request(PM8058_GPIO_PM_TO_SYS(PYRAMID_AUD_HP_EN), "AUD_HP_EN"); gpio_direction_output(PM8058_GPIO_PM_TO_SYS(PYRAMID_AUD_HP_EN), 0); if (!atomic_read(&aic3254_ctl)) curr_rx_mode &= ~BIT_FM_SPK; } }
static void msm8960_ext_spk_power_amp_on(u32 spk) { pr_info("%s: enable external amp %x\n", __func__, spk); if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { pr_debug("%s() External Bottom Speaker Ampl already " "turned on. spk = 0x%08x\n", __func__, spk); return; } msm8960_ext_bottom_spk_pamp |= spk; if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { gpio_direction_output(TPA2051_PAMP_GPIO, 1); if (system_rev < 3) set_speaker_amp(1); pr_debug("%s: slepping 4 ms after turning on external " " Bottom Speaker Ampl\n", __func__); usleep_range(4000, 4000); } } else if (spk & (USB_EXT_AMP_POS | USB_EXT_AMP_NEG)) { if ((msm8960_ext_usb_aud_pamp & USB_EXT_AMP_POS) && (msm8960_ext_usb_aud_pamp & USB_EXT_AMP_NEG)) { pr_debug("%s() External USB Audio Ampl already" "turned on. spk = 0x%08x\n", __func__, spk); return; } msm8960_ext_usb_aud_pamp |= spk; if ((msm8960_ext_usb_aud_pamp & USB_EXT_AMP_POS) && (msm8960_ext_usb_aud_pamp & USB_EXT_AMP_NEG)) { gpio_direction_output(TPA2051_PAMP_GPIO, 1); if (system_rev < 3) set_usb_audio_amp(1); pr_debug("%s: sleeping 4 ms after turning on " " external USB Audio Ampl\n", __func__); usleep_range(4000, 4000); } } else { pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", __func__, spk); return; } }
static void msm8960_ext_spk_power_amp_off(u32 spk) { pr_aud_info("%s: disable external amp %x\n", __func__, spk); #ifdef CONFIG_AUDIO_USAGE_FOR_POWER_CONSUMPTION g_spk_flag = 0; g_spk_end_time = current_kernel_time(); g_spk_total_time += (g_spk_end_time.tv_sec - g_spk_start_time.tv_sec); #endif if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { if (!msm8960_ext_bottom_spk_pamp) return; if (system_rev < 3) set_speaker_amp(0); gpio_direction_output(TPA2051_PAMP_GPIO, 0); msm8960_ext_bottom_spk_pamp = 0; pr_debug("%s: sleeping 4 ms after turning off external Bottom" " Speaker Ampl\n", __func__); usleep_range(4000, 4000); } else if (spk & (USB_EXT_AMP_POS | USB_EXT_AMP_NEG)) { if (!msm8960_ext_usb_aud_pamp) return; if (system_rev < 3) set_usb_audio_amp(0); gpio_direction_output(TPA2051_PAMP_GPIO, 0); msm8960_ext_usb_aud_pamp = 0; pr_debug("%s: sleeping 4 ms after turning off external Top" " Spkaker Ampl\n", __func__); usleep_range(4000, 4000); } else { pr_aud_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", __func__, spk); return; } }
static void msm8960_ext_spk_power_amp_off(u32 spk) { pr_info("%s, spk = %d\n", __func__, spk); if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { if (!msm8960_ext_bottom_spk_pamp) return; if (system_rev < 3) set_speaker_amp(0); gpio_direction_output(TPA2051_PAMP_GPIO, 0); msm8960_ext_bottom_spk_pamp = 0; pr_debug("%s: sleeping 4 ms after turning off external Bottom" " Speaker Ampl\n", __func__); usleep_range(4000, 4000); } else if (spk & (USB_EXT_AMP_POS | USB_EXT_AMP_NEG)) { if (!msm8960_ext_usb_aud_pamp) return; if (system_rev < 3) set_usb_audio_amp(0); gpio_direction_output(TPA2051_PAMP_GPIO, 0); msm8960_ext_usb_aud_pamp = 0; pr_debug("%s: sleeping 4 ms after turning off external Top" " Spkaker Ampl\n", __func__); usleep_range(4000, 4000); } else { pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", __func__, spk); return; } }
static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) { int ret = 0; struct pm_gpio param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 1, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_S4, .out_strength = PM_GPIO_STRENGTH_MED, .function = PM_GPIO_FUNC_NORMAL, }; if (spk_amp_gpio == bottom_spk_pamp_gpio) { ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP"); if (ret) { pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n", __func__, bottom_spk_pamp_gpio); return; } ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m); if (ret) pr_err("%s: Failed to configure Bottom Spk Ampl" " gpio %u\n", __func__, bottom_spk_pamp_gpio); else { pr_debug("%s: enable Bottom spkr amp gpio\n", __func__); gpio_direction_output(bottom_spk_pamp_gpio, 1); if (system_rev < 3) set_speaker_amp(1); } } else if (spk_amp_gpio == top_spk_pamp_gpio) { ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP"); if (ret) { pr_err("%s: Error requesting GPIO %d\n", __func__, top_spk_pamp_gpio); return; } ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m); if (ret) pr_err("%s: Failed to configure Top Spk Ampl" " gpio %u\n", __func__, top_spk_pamp_gpio); else { pr_debug("%s: enable Top spkr amp gpio\n", __func__); gpio_direction_output(top_spk_pamp_gpio, 1); } } else { pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO." " gpio = %u\n", __func__, spk_amp_gpio); return; } } static void msm_ext_spk_power_amp_on(u32 spk) { if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { pr_debug("%s() External Bottom Speaker Ampl already " "turned on. spk = 0x%08x\n", __func__, spk); return; } msm_ext_bottom_spk_pamp |= spk; if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { msm_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio); pr_debug("%s: slepping 4 ms after turning on external " " Bottom Speaker Ampl\n", __func__); usleep_range(4000, 4000); } } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", __func__, msm_ext_top_spk_pamp, spk); if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { pr_debug("%s() External Top Speaker Ampl already" "turned on. spk = 0x%08x\n", __func__, spk); return; } msm_ext_top_spk_pamp |= spk; if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { msm_enable_ext_spk_amp_gpio(top_spk_pamp_gpio); pr_debug("%s: sleeping 4 ms after turning on " " external Top Speaker Ampl\n", __func__); usleep_range(4000, 4000); } } else { pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", __func__, spk); return; } } static void msm_ext_spk_power_amp_off(u32 spk) { if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { if (!msm_ext_bottom_spk_pamp) return; gpio_direction_output(bottom_spk_pamp_gpio, 0); gpio_free(bottom_spk_pamp_gpio); msm_ext_bottom_spk_pamp = 0; if (system_rev < 3) set_speaker_amp(0); pr_debug("%s: sleeping 4 ms after turning off external Bottom" " Speaker Ampl\n", __func__); usleep_range(4000, 4000); } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", __func__, msm_ext_top_spk_pamp, spk); if (!msm_ext_top_spk_pamp) return; if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) { msm_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG)); } else if (spk & TOP_SPK_AMP) { msm_ext_top_spk_pamp &= ~TOP_SPK_AMP; } if (msm_ext_top_spk_pamp) return; gpio_direction_output(top_spk_pamp_gpio, 0); gpio_free(top_spk_pamp_gpio); msm_ext_top_spk_pamp = 0; pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n", __func__); usleep_range(4000, 4000); } else { pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", __func__, spk); return; } } static void msm_ext_control(struct snd_soc_codec *codec) { struct snd_soc_dapm_context *dapm = &codec->dapm; mutex_lock(&dapm->codec->mutex); pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); if (msm_spk_control == MSM_SPK_ON) { snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); } else { snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); } snd_soc_dapm_sync(dapm); mutex_unlock(&dapm->codec->mutex); } static int msm_get_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); ucontrol->value.integer.value[0] = msm_spk_control; return 0; }