aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Girdwood <liam.r.girdwood@linux.intel.com>2014-01-08 05:40:19 -0500
committerMark Brown <broonie@linaro.org>2014-01-08 07:07:18 -0500
commitb893ea5f1cd1adbbd7e0794d16d47bbb46f80733 (patch)
tree73c522c3f59e68262ac4551001ca84f887a631a3
parentbece9e957cbfb37f12488b24166364307e39f5b0 (diff)
ASoC: sapm: Automatically connect DAI link widgets in DAPM graph.
Connect the DAPM graph through each BE DAI link to the componnent(s) on the other side of the BE DAI link. This allows the graph to be walked on both sides of the link when graph changes are made. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc-dapm.h1
-rw-r--r--sound/soc/soc-core.c1
-rw-r--r--sound/soc/soc-dapm.c49
3 files changed, 51 insertions, 0 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 2037c45adfe6..a5de124d2f9d 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -411,6 +411,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
411int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, 411int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
412 struct snd_soc_dai *dai); 412 struct snd_soc_dai *dai);
413int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card); 413int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
414void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
414int snd_soc_dapm_new_pcm(struct snd_soc_card *card, 415int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
415 const struct snd_soc_pcm_stream *params, 416 const struct snd_soc_pcm_stream *params,
416 struct snd_soc_dapm_widget *source, 417 struct snd_soc_dapm_widget *source,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4e53d87e881d..7d9c0660ab24 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1728,6 +1728,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1728 } 1728 }
1729 1729
1730 snd_soc_dapm_link_dai_widgets(card); 1730 snd_soc_dapm_link_dai_widgets(card);
1731 snd_soc_dapm_connect_dai_link_widgets(card);
1731 1732
1732 if (card->controls) 1733 if (card->controls)
1733 snd_soc_add_card_controls(card, card->controls, card->num_controls); 1734 snd_soc_add_card_controls(card, card->controls, card->num_controls);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 67e63ab1f11e..51b4c192f41a 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3634,6 +3634,55 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
3634 return 0; 3634 return 0;
3635} 3635}
3636 3636
3637void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
3638{
3639 struct snd_soc_pcm_runtime *rtd = card->rtd;
3640 struct snd_soc_dai *cpu_dai, *codec_dai;
3641 struct snd_soc_dapm_route r;
3642 int i;
3643
3644 memset(&r, 0, sizeof(r));
3645
3646 /* for each BE DAI link... */
3647 for (i = 0; i < card->num_rtd; i++) {
3648 rtd = &card->rtd[i];
3649 cpu_dai = rtd->cpu_dai;
3650 codec_dai = rtd->codec_dai;
3651
3652 /* dynamic FE links have no fixed DAI mapping */
3653 if (rtd->dai_link->dynamic)
3654 continue;
3655
3656 /* there is no point in connecting BE DAI links with dummies */
3657 if (snd_soc_dai_is_dummy(codec_dai) ||
3658 snd_soc_dai_is_dummy(cpu_dai))
3659 continue;
3660
3661 /* connect BE DAI playback if widgets are valid */
3662 if (codec_dai->playback_widget && cpu_dai->playback_widget) {
3663 r.source = cpu_dai->playback_widget->name;
3664 r.sink = codec_dai->playback_widget->name;
3665 dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
3666 cpu_dai->codec->name, r.source,
3667 codec_dai->platform->name, r.sink);
3668
3669 snd_soc_dapm_add_route(&card->dapm, &r);
3670 }
3671
3672 /* connect BE DAI capture if widgets are valid */
3673 if (codec_dai->capture_widget && cpu_dai->capture_widget) {
3674 r.source = codec_dai->capture_widget->name;
3675 r.sink = cpu_dai->capture_widget->name;
3676 dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
3677 codec_dai->codec->name, r.source,
3678 cpu_dai->platform->name, r.sink);
3679
3680 snd_soc_dapm_add_route(&card->dapm, &r);
3681 }
3682
3683 }
3684}
3685
3637static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, 3686static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3638 int event) 3687 int event)
3639{ 3688{