Commit 7c81beb0 authored by Mark Brown's avatar Mark Brown

ASoC: Factor out per-widget DAPM power checks

The indentation is getting a little deep. Should be straight code motion,
no functional changes.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent de02d078
...@@ -1191,54 +1191,24 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie) ...@@ -1191,54 +1191,24 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
} }
} }
/* static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
* Scan each dapm widget for complete audio path. struct list_head *up_list,
* A complete path is a route that has valid endpoints i.e.:- struct list_head *down_list)
*
* o DAC to output pin.
* o Input Pin to ADC.
* o Input pin to Output pin (bypass, sidetone)
* o DAC to ADC (loopback).
*/
static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
{ {
struct snd_soc_card *card = dapm->card;
struct snd_soc_dapm_widget *w;
struct snd_soc_dapm_context *d; struct snd_soc_dapm_context *d;
LIST_HEAD(up_list);
LIST_HEAD(down_list);
LIST_HEAD(async_domain);
enum snd_soc_bias_level bias;
int power; int power;
trace_snd_soc_dapm_start(card);
list_for_each_entry(d, &card->dapm_list, list) {
if (d->n_widgets || d->codec == NULL) {
if (d->idle_bias_off)
d->target_bias_level = SND_SOC_BIAS_OFF;
else
d->target_bias_level = SND_SOC_BIAS_STANDBY;
}
}
memset(&card->dapm_stats, 0, sizeof(card->dapm_stats));
/* Check which widgets we need to power and store them in
* lists indicating if they should be powered up or down.
*/
list_for_each_entry(w, &card->widgets, list) {
switch (w->id) { switch (w->id) {
case snd_soc_dapm_pre: case snd_soc_dapm_pre:
dapm_seq_insert(w, &down_list, false); dapm_seq_insert(w, down_list, false);
break; break;
case snd_soc_dapm_post: case snd_soc_dapm_post:
dapm_seq_insert(w, &up_list, true); dapm_seq_insert(w, up_list, true);
break; break;
default: default:
if (!w->power_check) if (!w->power_check)
continue; break;
if (!w->force) if (!w->force)
power = w->power_check(w); power = w->power_check(w);
...@@ -1248,11 +1218,10 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) ...@@ -1248,11 +1218,10 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
if (power) { if (power) {
d = w->dapm; d = w->dapm;
/* Supplies and micbiases only bring /* Supplies and micbiases only bring the
* the context up to STANDBY as unless * context up to STANDBY as unless something
* something else is active and * else is active and passing audio they
* passing audio they generally don't * generally don't require full power.
* require full power.
*/ */
switch (w->id) { switch (w->id) {
case snd_soc_dapm_supply: case snd_soc_dapm_supply:
...@@ -1267,18 +1236,57 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) ...@@ -1267,18 +1236,57 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
} }
if (w->power == power) if (w->power == power)
continue; break;
trace_snd_soc_dapm_widget_power(w, power); trace_snd_soc_dapm_widget_power(w, power);
if (power) if (power)
dapm_seq_insert(w, &up_list, true); dapm_seq_insert(w, up_list, true);
else else
dapm_seq_insert(w, &down_list, false); dapm_seq_insert(w, down_list, false);
w->power = power; w->power = power;
break; break;
} }
}
/*
* Scan each dapm widget for complete audio path.
* A complete path is a route that has valid endpoints i.e.:-
*
* o DAC to output pin.
* o Input Pin to ADC.
* o Input pin to Output pin (bypass, sidetone)
* o DAC to ADC (loopback).
*/
static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
{
struct snd_soc_card *card = dapm->card;
struct snd_soc_dapm_widget *w;
struct snd_soc_dapm_context *d;
LIST_HEAD(up_list);
LIST_HEAD(down_list);
LIST_HEAD(async_domain);
enum snd_soc_bias_level bias;
trace_snd_soc_dapm_start(card);
list_for_each_entry(d, &card->dapm_list, list) {
if (d->n_widgets || d->codec == NULL) {
if (d->idle_bias_off)
d->target_bias_level = SND_SOC_BIAS_OFF;
else
d->target_bias_level = SND_SOC_BIAS_STANDBY;
}
}
memset(&card->dapm_stats, 0, sizeof(card->dapm_stats));
/* Check which widgets we need to power and store them in
* lists indicating if they should be powered up or down.
*/
list_for_each_entry(w, &card->widgets, list) {
dapm_power_one_widget(w, &up_list, &down_list);
} }
/* If there are no DAPM widgets then try to figure out power from the /* If there are no DAPM widgets then try to figure out power from the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment