提交 025756ec 编写于 作者: M Mark Brown

ASoC: Factor out application of power for generic widgets

This is simple code motion, intended to support future refactoring of
the DAPM algorithms and (more immediately) the additon of events for
DACs and ADCs.
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 f4976116
......@@ -522,6 +522,65 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w,
}
EXPORT_SYMBOL_GPL(dapm_reg_event);
/* Standard power change method, used to apply power changes to most
* widgets.
*/
static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w)
{
int ret;
/* call any power change event handlers */
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 (w->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 (!w->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 && !w->power)
dapm_set_pga(w, w->power);
dapm_update_bits(w);
/* Raise PGA volume to reduce pops */
if (w->id == snd_soc_dapm_pga && w->power)
dapm_set_pga(w, w->power);
/* power up post event */
if (w->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 (!w->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;
}
return 0;
}
/*
* Scan a single DAPM widget for a complete audio path and update the
* power status appropriately.
......@@ -601,56 +660,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event,
if (!power_change)
return 0;
/* call any power change event handlers */
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;
}
return 0;
return dapm_generic_apply_power(w);
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册