Commit 8af294b4 authored by Mark Brown's avatar Mark Brown

ASoC: dapm: Fix handling of loops

Currently if a path loops back on itself we correctly skip over it to
avoid going into an infinite loop but this causes us to ignore the need
to power up the path as we don't count the loop for the purposes of
counting inputs and outputs. This means that internal loopbacks within a
device that have powered devices on them won't be powered up.

Fix this by treating any path that is currently in the process of being
recursed as having a single input or output so that it is counted for
the purposes of power decisions.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <liam.r.girdwood@linux.intel.com>
parent 19f949f5
...@@ -488,6 +488,7 @@ struct snd_soc_dapm_path { ...@@ -488,6 +488,7 @@ struct snd_soc_dapm_path {
/* status */ /* status */
u32 connect:1; /* source and sink widgets are connected */ u32 connect:1; /* source and sink widgets are connected */
u32 walked:1; /* path has been walked */ u32 walked:1; /* path has been walked */
u32 walking:1; /* path is in the process of being walked */
u32 weak:1; /* path ignored for power management */ u32 weak:1; /* path ignored for power management */
int (*connected)(struct snd_soc_dapm_widget *source, int (*connected)(struct snd_soc_dapm_widget *source,
......
...@@ -821,6 +821,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget, ...@@ -821,6 +821,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
(widget->id == snd_soc_dapm_line && (widget->id == snd_soc_dapm_line &&
!list_empty(&widget->sources))) { !list_empty(&widget->sources))) {
widget->outputs = snd_soc_dapm_suspend_check(widget); widget->outputs = snd_soc_dapm_suspend_check(widget);
path->walking = 0;
return widget->outputs; return widget->outputs;
} }
} }
...@@ -831,6 +832,9 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget, ...@@ -831,6 +832,9 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
if (path->weak) if (path->weak)
continue; continue;
if (path->walking)
return 1;
if (path->walked) if (path->walked)
continue; continue;
...@@ -838,6 +842,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget, ...@@ -838,6 +842,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
if (path->sink && path->connect) { if (path->sink && path->connect) {
path->walked = 1; path->walked = 1;
path->walking = 1;
/* do we need to add this widget to the list ? */ /* do we need to add this widget to the list ? */
if (list) { if (list) {
...@@ -847,11 +852,14 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget, ...@@ -847,11 +852,14 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
dev_err(widget->dapm->dev, dev_err(widget->dapm->dev,
"ASoC: could not add widget %s\n", "ASoC: could not add widget %s\n",
widget->name); widget->name);
path->walking = 0;
return con; return con;
} }
} }
con += is_connected_output_ep(path->sink, list); con += is_connected_output_ep(path->sink, list);
path->walking = 0;
} }
} }
...@@ -931,6 +939,9 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget, ...@@ -931,6 +939,9 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
if (path->weak) if (path->weak)
continue; continue;
if (path->walking)
return 1;
if (path->walked) if (path->walked)
continue; continue;
...@@ -938,6 +949,7 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget, ...@@ -938,6 +949,7 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
if (path->source && path->connect) { if (path->source && path->connect) {
path->walked = 1; path->walked = 1;
path->walking = 1;
/* do we need to add this widget to the list ? */ /* do we need to add this widget to the list ? */
if (list) { if (list) {
...@@ -947,11 +959,14 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget, ...@@ -947,11 +959,14 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
dev_err(widget->dapm->dev, dev_err(widget->dapm->dev,
"ASoC: could not add widget %s\n", "ASoC: could not add widget %s\n",
widget->name); widget->name);
path->walking = 0;
return con; return con;
} }
} }
con += is_connected_input_ep(path->source, list); con += is_connected_input_ep(path->source, list);
path->walking = 0;
} }
} }
......
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