diff mbox

[v2,5/5] ASoC: dapm: Simplify snd_soc_dapm_link_dai_widgets()

Message ID 1399472428-11034-5-git-send-email-lars@metafoo.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lars-Peter Clausen May 7, 2014, 2:20 p.m. UTC
If we find a widget who's stream name matches the name of a DAI widget then
thats the one it should be connected to. Based on the widget id we can say in
which direction the path should be. No need to go back to the DAI and check the
stream names.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/soc-dapm.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

Comments

Charles Keepax May 12, 2014, 2:37 p.m. UTC | #1
On Wed, May 07, 2014 at 04:20:28PM +0200, Lars-Peter Clausen wrote:
> If we find a widget who's stream name matches the name of a DAI widget then
> thats the one it should be connected to. Based on the widget id we can say in
> which direction the path should be. No need to go back to the DAI and check the
> stream names.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
>  sound/soc/soc-dapm.c | 27 +++++++++------------------
>  1 file changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index d7958f4..bed17a3 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -3334,6 +3334,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
>  int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
>  {
>  	struct snd_soc_dapm_widget *dai_w, *w;
> +	struct snd_soc_dapm_widget *src, *sink;
>  	struct snd_soc_dai *dai;

I think you have removed all the uses of this variable (dai) so you can
remove this as well.

Thanks,
Charles
Lars-Peter Clausen May 12, 2014, 2:38 p.m. UTC | #2
On 05/12/2014 04:37 PM, Charles Keepax wrote:
> On Wed, May 07, 2014 at 04:20:28PM +0200, Lars-Peter Clausen wrote:
>> If we find a widget who's stream name matches the name of a DAI widget then
>> thats the one it should be connected to. Based on the widget id we can say in
>> which direction the path should be. No need to go back to the DAI and check the
>> stream names.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>>   sound/soc/soc-dapm.c | 27 +++++++++------------------
>>   1 file changed, 9 insertions(+), 18 deletions(-)
>>
>> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
>> index d7958f4..bed17a3 100644
>> --- a/sound/soc/soc-dapm.c
>> +++ b/sound/soc/soc-dapm.c
>> @@ -3334,6 +3334,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
>>   int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
>>   {
>>   	struct snd_soc_dapm_widget *dai_w, *w;
>> +	struct snd_soc_dapm_widget *src, *sink;
>>   	struct snd_soc_dai *dai;
>
> I think you have removed all the uses of this variable (dai) so you can
> remove this as well.

It is still used in the dev_dbg() call.
Mark Brown May 12, 2014, 8:37 p.m. UTC | #3
On Wed, May 07, 2014 at 04:20:28PM +0200, Lars-Peter Clausen wrote:
> If we find a widget who's stream name matches the name of a DAI widget then
> thats the one it should be connected to. Based on the widget id we can say in
> which direction the path should be. No need to go back to the DAI and check the
> stream names.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d7958f4..bed17a3 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3334,6 +3334,7 @@  int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
 int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 {
 	struct snd_soc_dapm_widget *dai_w, *w;
+	struct snd_soc_dapm_widget *src, *sink;
 	struct snd_soc_dai *dai;
 
 	/* For each DAI widget... */
@@ -3364,25 +3365,15 @@  int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 			if (!w->sname || !strstr(w->sname, dai_w->name))
 				continue;
 
-			if (dai->driver->playback.stream_name &&
-			    strstr(w->sname,
-				   dai->driver->playback.stream_name)) {
-				dev_dbg(dai->dev, "%s -> %s\n",
-					 dai->playback_widget->name, w->name);
-
-				snd_soc_dapm_add_path(w->dapm,
-					dai->playback_widget, w, NULL, NULL);
-			}
-
-			if (dai->driver->capture.stream_name &&
-			    strstr(w->sname,
-				   dai->driver->capture.stream_name)) {
-				dev_dbg(dai->dev, "%s -> %s\n",
-					w->name, dai->capture_widget->name);
-
-				snd_soc_dapm_add_path(w->dapm, w,
-					dai->capture_widget, NULL, NULL);
+			if (dai_w->id == snd_soc_dapm_dai_in) {
+				src = dai_w;
+				sink = w;
+			} else {
+				src = w;
+				sink = dai_w;
 			}
+			dev_dbg(dai->dev, "%s -> %s\n", src->name, sink->name);
+			snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL);
 		}
 	}