mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 10:13:57 +08:00
ASoC: Split DAPM power checks from sequencing of power changes
DAPM has always applied any changes to the power state of widgets as soon as it has determined that they are required. Instead of doing this store all the changes that are required on lists of widgets to power up and down, then iterate over those lists and apply the changes. This changes the sequence in which changes are implemented, doing all power downs before power ups and always using the up/down sequences (previously they were only used when changes were due to DAC/ADC power events). The error handling is also changed so that we continue attempting to power widgets if some changes fail. The main benefit of this is to allow future changes to do optimisations over the whole power sequence and to reduce the number of walks of the widget graph required to check the power status of widgets. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
b7a755a8a1
commit
6d3ddc81f5
@ -385,6 +385,9 @@ struct snd_soc_dapm_widget {
|
|||||||
/* widget input and outputs */
|
/* widget input and outputs */
|
||||||
struct list_head sources;
|
struct list_head sources;
|
||||||
struct list_head sinks;
|
struct list_head sinks;
|
||||||
|
|
||||||
|
/* used during DAPM updates */
|
||||||
|
struct list_head power_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -372,6 +372,8 @@ struct snd_soc_codec {
|
|||||||
enum snd_soc_bias_level bias_level;
|
enum snd_soc_bias_level bias_level;
|
||||||
enum snd_soc_bias_level suspend_bias_level;
|
enum snd_soc_bias_level suspend_bias_level;
|
||||||
struct delayed_work delayed_work;
|
struct delayed_work delayed_work;
|
||||||
|
struct list_head up_list;
|
||||||
|
struct list_head down_list;
|
||||||
|
|
||||||
/* codec DAI's */
|
/* codec DAI's */
|
||||||
struct snd_soc_dai *dai;
|
struct snd_soc_dai *dai;
|
||||||
|
@ -658,7 +658,7 @@ static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
|
|||||||
static int dapm_power_widget(struct snd_soc_codec *codec, int event,
|
static int dapm_power_widget(struct snd_soc_codec *codec, int event,
|
||||||
struct snd_soc_dapm_widget *w)
|
struct snd_soc_dapm_widget *w)
|
||||||
{
|
{
|
||||||
int power, ret;
|
int ret;
|
||||||
|
|
||||||
switch (w->id) {
|
switch (w->id) {
|
||||||
case snd_soc_dapm_pre:
|
case snd_soc_dapm_pre:
|
||||||
@ -696,18 +696,8 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!w->power_check)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
power = w->power_check(w);
|
|
||||||
if (w->power == power)
|
|
||||||
return 0;
|
|
||||||
w->power = power;
|
|
||||||
|
|
||||||
return dapm_generic_apply_power(w);
|
return dapm_generic_apply_power(w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -722,27 +712,68 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event,
|
|||||||
static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
|
static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
|
||||||
{
|
{
|
||||||
struct snd_soc_dapm_widget *w;
|
struct snd_soc_dapm_widget *w;
|
||||||
int i, c = 1, *seq = NULL, ret = 0;
|
int ret = 0;
|
||||||
|
int i, power;
|
||||||
|
|
||||||
/* do we have a sequenced stream event */
|
INIT_LIST_HEAD(&codec->up_list);
|
||||||
if (event == SND_SOC_DAPM_STREAM_START) {
|
INIT_LIST_HEAD(&codec->down_list);
|
||||||
c = ARRAY_SIZE(dapm_up_seq);
|
|
||||||
seq = dapm_up_seq;
|
/* Check which widgets we need to power and store them in
|
||||||
} else if (event == SND_SOC_DAPM_STREAM_STOP) {
|
* lists indicating if they should be powered up or down.
|
||||||
c = ARRAY_SIZE(dapm_down_seq);
|
*/
|
||||||
seq = dapm_down_seq;
|
list_for_each_entry(w, &codec->dapm_widgets, list) {
|
||||||
|
switch (w->id) {
|
||||||
|
case snd_soc_dapm_pre:
|
||||||
|
list_add_tail(&codec->down_list, &w->power_list);
|
||||||
|
break;
|
||||||
|
case snd_soc_dapm_post:
|
||||||
|
list_add_tail(&codec->up_list, &w->power_list);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (!w->power_check)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
power = w->power_check(w);
|
||||||
|
if (w->power == power)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (power)
|
||||||
|
list_add_tail(&w->power_list, &codec->up_list);
|
||||||
|
else
|
||||||
|
list_add_tail(&w->power_list,
|
||||||
|
&codec->down_list);
|
||||||
|
|
||||||
|
w->power = power;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < c; i++) {
|
/* Power down widgets first; try to avoid amplifying pops. */
|
||||||
list_for_each_entry(w, &codec->dapm_widgets, list) {
|
for (i = 0; i < ARRAY_SIZE(dapm_down_seq); i++) {
|
||||||
|
list_for_each_entry(w, &codec->down_list, power_list) {
|
||||||
/* is widget in stream order */
|
/* is widget in stream order */
|
||||||
if (seq && seq[i] && w->id != seq[i])
|
if (w->id != dapm_down_seq[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = dapm_power_widget(codec, event, w);
|
ret = dapm_power_widget(codec, event, w);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
pr_err("Failed to power down %s: %d\n",
|
||||||
|
w->name, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now power up. */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) {
|
||||||
|
list_for_each_entry(w, &codec->up_list, power_list) {
|
||||||
|
/* is widget in stream order */
|
||||||
|
if (w->id != dapm_up_seq[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret = dapm_power_widget(codec, event, w);
|
||||||
|
if (ret != 0)
|
||||||
|
pr_err("Failed to power up %s: %d\n",
|
||||||
|
w->name, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user