Skip to content

Commit

Permalink
ASoC: sapm: Automatically connect DAI link widgets in DAPM graph.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Liam Girdwood authored and Mark Brown committed Jan 8, 2014
1 parent bece9e9 commit b893ea5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sound/soc-dapm.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
struct snd_soc_dai *dai);
int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
const struct snd_soc_pcm_stream *params,
struct snd_soc_dapm_widget *source,
Expand Down
1 change: 1 addition & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
}

snd_soc_dapm_link_dai_widgets(card);
snd_soc_dapm_connect_dai_link_widgets(card);

if (card->controls)
snd_soc_add_card_controls(card, card->controls, card->num_controls);
Expand Down
49 changes: 49 additions & 0 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3634,6 +3634,55 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
return 0;
}

void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd = card->rtd;
struct snd_soc_dai *cpu_dai, *codec_dai;
struct snd_soc_dapm_route r;
int i;

memset(&r, 0, sizeof(r));

/* for each BE DAI link... */
for (i = 0; i < card->num_rtd; i++) {
rtd = &card->rtd[i];
cpu_dai = rtd->cpu_dai;
codec_dai = rtd->codec_dai;

/* dynamic FE links have no fixed DAI mapping */
if (rtd->dai_link->dynamic)
continue;

/* there is no point in connecting BE DAI links with dummies */
if (snd_soc_dai_is_dummy(codec_dai) ||
snd_soc_dai_is_dummy(cpu_dai))
continue;

/* connect BE DAI playback if widgets are valid */
if (codec_dai->playback_widget && cpu_dai->playback_widget) {
r.source = cpu_dai->playback_widget->name;
r.sink = codec_dai->playback_widget->name;
dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
cpu_dai->codec->name, r.source,
codec_dai->platform->name, r.sink);

snd_soc_dapm_add_route(&card->dapm, &r);
}

/* connect BE DAI capture if widgets are valid */
if (codec_dai->capture_widget && cpu_dai->capture_widget) {
r.source = codec_dai->capture_widget->name;
r.sink = cpu_dai->capture_widget->name;
dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
codec_dai->codec->name, r.source,
cpu_dai->platform->name, r.sink);

snd_soc_dapm_add_route(&card->dapm, &r);
}

}
}

static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
int event)
{
Expand Down

0 comments on commit b893ea5

Please sign in to comment.