aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c105
1 files changed, 49 insertions, 56 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2c87061c2a6..820347c9ae4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -523,24 +523,6 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
continue;
}
- /* programmable gain/attenuation */
- if (w->id == snd_soc_dapm_pga) {
- int on;
- in = is_connected_input_ep(w);
- dapm_clear_walk(w->codec);
- out = is_connected_output_ep(w);
- dapm_clear_walk(w->codec);
- w->power = on = (out != 0 && in != 0) ? 1 : 0;
-
- if (!on)
- dapm_set_pga(w, on); /* lower volume to reduce pops */
- dapm_update_bits(w);
- if (on)
- dapm_set_pga(w, on); /* restore volume from zero */
-
- continue;
- }
-
/* pre and post event widgets */
if (w->id == snd_soc_dapm_pre) {
if (!w->event)
@@ -586,45 +568,56 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
power_change = (w->power == power) ? 0: 1;
w->power = power;
+ if (!power_change)
+ continue;
+
/* call any power change event handlers */
- if (power_change) {
- if (w->event) {
- pr_debug("power %s event for %s flags %x\n",
- w->power ? "on" : "off", w->name, w->event_flags);
- if (power) {
- /* power up event */
- if (w->event_flags & SND_SOC_DAPM_PRE_PMU) {
- ret = w->event(w,
- NULL, SND_SOC_DAPM_PRE_PMU);
- if (ret < 0)
- return ret;
- }
- dapm_update_bits(w);
- if (w->event_flags & SND_SOC_DAPM_POST_PMU){
- ret = w->event(w,
- NULL, SND_SOC_DAPM_POST_PMU);
- if (ret < 0)
- return ret;
- }
- } else {
- /* power down event */
- if (w->event_flags & SND_SOC_DAPM_PRE_PMD) {
- ret = w->event(w,
- NULL, SND_SOC_DAPM_PRE_PMD);
- if (ret < 0)
- return ret;
- }
- dapm_update_bits(w);
- if (w->event_flags & SND_SOC_DAPM_POST_PMD) {
- ret = w->event(w,
- NULL, SND_SOC_DAPM_POST_PMD);
- if (ret < 0)
- return ret;
- }
- }
- } else
- /* no event handler */
- dapm_update_bits(w);
+ if (w->event)
+ pr_debug("power %s event for %s flags %x\n",
+ w->power ? "on" : "off",
+ w->name, w->event_flags);
+
+ /* power up pre event */
+ if (power && w->event &&
+ (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
+ ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* power down pre event */
+ if (!power && w->event &&
+ (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
+ ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Lower PGA volume to reduce pops */
+ if (w->id == snd_soc_dapm_pga && !power)
+ dapm_set_pga(w, power);
+
+ dapm_update_bits(w);
+
+ /* Raise PGA volume to reduce pops */
+ if (w->id == snd_soc_dapm_pga && power)
+ dapm_set_pga(w, power);
+
+ /* power up post event */
+ if (power && w->event &&
+ (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
+ ret = w->event(w,
+ NULL, SND_SOC_DAPM_POST_PMU);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* power down post event */
+ if (!power && w->event &&
+ (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
+ ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
+ if (ret < 0)
+ return ret;
}
}
}