Loading sound/soc/codecs/msm8x10-wcd.c +66 −25 Original line number Diff line number Diff line Loading @@ -167,6 +167,10 @@ static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = { "cdc-vdda-cp", }; static int on_demand_regulator_control(struct on_demand_supply *supply, bool enable, u8 shift); struct msm8x10_wcd_priv { struct snd_soc_codec *codec; u32 adc_count; Loading Loading @@ -784,6 +788,39 @@ err: return NULL; } static int on_demand_regulator_control(struct on_demand_supply *supply, bool enable, u8 shift) { int ret = 0; if (!supply || !supply->supply) return 0; if (enable) { if (atomic_inc_return(&supply->ref) == 1) ret = regulator_enable(supply->supply); if (ret) pr_err("%s: Failed to enable %s\n", __func__, on_demand_supply_name[shift]); } else { if (atomic_read(&supply->ref) == 0) { pr_debug("%s: %s supply has been disabled.\n", __func__, on_demand_supply_name[shift]); return 0; } if (atomic_dec_return(&supply->ref) == 0) ret = regulator_disable(supply->supply); if (ret) pr_err("%s: Failed to disable %s\n", __func__, on_demand_supply_name[shift]); } return ret; } static int msm8x10_wcd_codec_enable_on_demand_supply( struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) Loading @@ -809,25 +846,14 @@ static int msm8x10_wcd_codec_enable_on_demand_supply( switch (event) { case SND_SOC_DAPM_PRE_PMU: if (atomic_inc_return(&supply->ref) == 1) ret = regulator_enable(supply->supply); if (ret) dev_err(codec->dev, "%s: Failed to enable %s\n", __func__, on_demand_supply_name[w->shift]); ret = on_demand_regulator_control(supply, true, w->shift); break; case SND_SOC_DAPM_POST_PMD: if (atomic_read(&supply->ref) == 0) { dev_dbg(codec->dev, "%s: %s supply has been disabled.\n", __func__, on_demand_supply_name[w->shift]); goto out; } if (atomic_dec_return(&supply->ref) == 0) ret = regulator_disable(supply->supply); if (ret) dev_err(codec->dev, "%s: Failed to disable %s\n", __func__, on_demand_supply_name[w->shift]); ret = on_demand_regulator_control(supply, false, w->shift); break; default: break; Loading Loading @@ -2737,10 +2763,12 @@ static void msm8x10_wcd_mbhc_txfe(struct snd_soc_codec *codec, bool on) } static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec, bool turn_on) bool turn_on, bool use_dapm) { int ret = 0; if (use_dapm) { if (turn_on) ret = snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS_REGULATOR"); Loading @@ -2749,6 +2777,19 @@ static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec, "MICBIAS_REGULATOR"); snd_soc_dapm_sync(&codec->dapm); } else { struct on_demand_supply *supply; struct msm8x10_wcd_priv *msm8x10_wcd = snd_soc_codec_get_drvdata(codec); supply = &msm8x10_wcd->on_demand_list[ON_DEMAND_MICBIAS]; if (!supply || !supply->supply || !msm8x10_wcd) return 0; ret = on_demand_regulator_control(supply, turn_on, ON_DEMAND_MICBIAS); } if (ret) dev_err(codec->dev, "%s: Failed to %s external micbias source\n", Loading sound/soc/codecs/wcd9xxx-mbhc.c +4 −4 Original line number Diff line number Diff line Loading @@ -1157,7 +1157,7 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc, btn_det = WCD9XXX_MBHC_CAL_BTN_DET_PTR(mbhc->mbhc_cfg->calibration); /* Enable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true); mbhc->mbhc_cb->enable_mb_source(codec, true, true); /* * setup internal micbias if codec uses internal micbias for Loading Loading @@ -1300,7 +1300,7 @@ static void wcd9xxx_cleanup_hs_polling(struct wcd9xxx_mbhc *mbhc) /* Disable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(mbhc->codec, false); mbhc->mbhc_cb->enable_mb_source(mbhc->codec, false, true); mbhc->polling_active = false; mbhc->mbhc_state = MBHC_STATE_NONE; Loading Loading @@ -3872,7 +3872,7 @@ static void wcd9xxx_mbhc_cal(struct wcd9xxx_mbhc *mbhc) * turn on the external voltage source for Calibration. */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true); mbhc->mbhc_cb->enable_mb_source(codec, true, false); cfilt_mode = snd_soc_read(codec, mbhc->mbhc_bias_regs.cfilt_ctl); if (mbhc->mbhc_cb && mbhc->mbhc_cb->cfilt_fast_mode) Loading Loading @@ -3994,7 +3994,7 @@ static void wcd9xxx_mbhc_cal(struct wcd9xxx_mbhc *mbhc) usleep_range(100, 100); if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, false); mbhc->mbhc_cb->enable_mb_source(codec, false, false); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); Loading sound/soc/codecs/wcd9xxx-mbhc.h +1 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ struct wcd9xxx_mbhc_cb { enum mbhc_impedance_detect_stages stage); void (*compute_impedance) (s16 *, s16 *, uint32_t *, uint32_t *); void (*enable_mbhc_txfe) (struct snd_soc_codec *, bool); int (*enable_mb_source) (struct snd_soc_codec *, bool); int (*enable_mb_source) (struct snd_soc_codec *, bool, bool); void (*setup_int_rbias) (struct snd_soc_codec *, bool); void (*pull_mb_to_vddio) (struct snd_soc_codec *, bool); }; Loading Loading
sound/soc/codecs/msm8x10-wcd.c +66 −25 Original line number Diff line number Diff line Loading @@ -167,6 +167,10 @@ static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = { "cdc-vdda-cp", }; static int on_demand_regulator_control(struct on_demand_supply *supply, bool enable, u8 shift); struct msm8x10_wcd_priv { struct snd_soc_codec *codec; u32 adc_count; Loading Loading @@ -784,6 +788,39 @@ err: return NULL; } static int on_demand_regulator_control(struct on_demand_supply *supply, bool enable, u8 shift) { int ret = 0; if (!supply || !supply->supply) return 0; if (enable) { if (atomic_inc_return(&supply->ref) == 1) ret = regulator_enable(supply->supply); if (ret) pr_err("%s: Failed to enable %s\n", __func__, on_demand_supply_name[shift]); } else { if (atomic_read(&supply->ref) == 0) { pr_debug("%s: %s supply has been disabled.\n", __func__, on_demand_supply_name[shift]); return 0; } if (atomic_dec_return(&supply->ref) == 0) ret = regulator_disable(supply->supply); if (ret) pr_err("%s: Failed to disable %s\n", __func__, on_demand_supply_name[shift]); } return ret; } static int msm8x10_wcd_codec_enable_on_demand_supply( struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) Loading @@ -809,25 +846,14 @@ static int msm8x10_wcd_codec_enable_on_demand_supply( switch (event) { case SND_SOC_DAPM_PRE_PMU: if (atomic_inc_return(&supply->ref) == 1) ret = regulator_enable(supply->supply); if (ret) dev_err(codec->dev, "%s: Failed to enable %s\n", __func__, on_demand_supply_name[w->shift]); ret = on_demand_regulator_control(supply, true, w->shift); break; case SND_SOC_DAPM_POST_PMD: if (atomic_read(&supply->ref) == 0) { dev_dbg(codec->dev, "%s: %s supply has been disabled.\n", __func__, on_demand_supply_name[w->shift]); goto out; } if (atomic_dec_return(&supply->ref) == 0) ret = regulator_disable(supply->supply); if (ret) dev_err(codec->dev, "%s: Failed to disable %s\n", __func__, on_demand_supply_name[w->shift]); ret = on_demand_regulator_control(supply, false, w->shift); break; default: break; Loading Loading @@ -2737,10 +2763,12 @@ static void msm8x10_wcd_mbhc_txfe(struct snd_soc_codec *codec, bool on) } static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec, bool turn_on) bool turn_on, bool use_dapm) { int ret = 0; if (use_dapm) { if (turn_on) ret = snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS_REGULATOR"); Loading @@ -2749,6 +2777,19 @@ static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec, "MICBIAS_REGULATOR"); snd_soc_dapm_sync(&codec->dapm); } else { struct on_demand_supply *supply; struct msm8x10_wcd_priv *msm8x10_wcd = snd_soc_codec_get_drvdata(codec); supply = &msm8x10_wcd->on_demand_list[ON_DEMAND_MICBIAS]; if (!supply || !supply->supply || !msm8x10_wcd) return 0; ret = on_demand_regulator_control(supply, turn_on, ON_DEMAND_MICBIAS); } if (ret) dev_err(codec->dev, "%s: Failed to %s external micbias source\n", Loading
sound/soc/codecs/wcd9xxx-mbhc.c +4 −4 Original line number Diff line number Diff line Loading @@ -1157,7 +1157,7 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc, btn_det = WCD9XXX_MBHC_CAL_BTN_DET_PTR(mbhc->mbhc_cfg->calibration); /* Enable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true); mbhc->mbhc_cb->enable_mb_source(codec, true, true); /* * setup internal micbias if codec uses internal micbias for Loading Loading @@ -1300,7 +1300,7 @@ static void wcd9xxx_cleanup_hs_polling(struct wcd9xxx_mbhc *mbhc) /* Disable external voltage source to micbias if present */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(mbhc->codec, false); mbhc->mbhc_cb->enable_mb_source(mbhc->codec, false, true); mbhc->polling_active = false; mbhc->mbhc_state = MBHC_STATE_NONE; Loading Loading @@ -3872,7 +3872,7 @@ static void wcd9xxx_mbhc_cal(struct wcd9xxx_mbhc *mbhc) * turn on the external voltage source for Calibration. */ if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, true); mbhc->mbhc_cb->enable_mb_source(codec, true, false); cfilt_mode = snd_soc_read(codec, mbhc->mbhc_bias_regs.cfilt_ctl); if (mbhc->mbhc_cb && mbhc->mbhc_cb->cfilt_fast_mode) Loading Loading @@ -3994,7 +3994,7 @@ static void wcd9xxx_mbhc_cal(struct wcd9xxx_mbhc *mbhc) usleep_range(100, 100); if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(codec, false); mbhc->mbhc_cb->enable_mb_source(codec, false, false); wcd9xxx_enable_irq(mbhc->resmgr->core_res, mbhc->intr_ids->dce_est_complete); Loading
sound/soc/codecs/wcd9xxx-mbhc.h +1 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ struct wcd9xxx_mbhc_cb { enum mbhc_impedance_detect_stages stage); void (*compute_impedance) (s16 *, s16 *, uint32_t *, uint32_t *); void (*enable_mbhc_txfe) (struct snd_soc_codec *, bool); int (*enable_mb_source) (struct snd_soc_codec *, bool); int (*enable_mb_source) (struct snd_soc_codec *, bool, bool); void (*setup_int_rbias) (struct snd_soc_codec *, bool); void (*pull_mb_to_vddio) (struct snd_soc_codec *, bool); }; Loading