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)
}
}
/*
* 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)
static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
struct list_head *up_list,
struct list_head *down_list)
{
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;
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) {
case snd_soc_dapm_pre:
dapm_seq_insert(w, &down_list, false);
dapm_seq_insert(w, down_list, false);
break;
case snd_soc_dapm_post:
dapm_seq_insert(w, &up_list, true);
dapm_seq_insert(w, up_list, true);
break;
default:
if (!w->power_check)
continue;
break;
if (!w->force)
power = w->power_check(w);
......@@ -1248,11 +1218,10 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
if (power) {
d = w->dapm;
/* Supplies and micbiases only bring
* the context up to STANDBY as unless
* something else is active and
* passing audio they generally don't
* require full power.
/* Supplies and micbiases only bring the
* context up to STANDBY as unless something
* else is active and passing audio they
* generally don't require full power.
*/
switch (w->id) {
case snd_soc_dapm_supply:
......@@ -1267,18 +1236,57 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
}
if (w->power == power)
continue;
break;
trace_snd_soc_dapm_widget_power(w, power);
if (power)
dapm_seq_insert(w, &up_list, true);
dapm_seq_insert(w, up_list, true);
else
dapm_seq_insert(w, &down_list, false);
dapm_seq_insert(w, down_list, false);
w->power = power;
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
......
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