Skip to content

Commit

Permalink
ASoC: Add multiple CPU DAI support in DAPM
Browse files Browse the repository at this point in the history
DAPM handles DAIs during soc_dapm_stream_event() and during addition
and creation of DAI widgets i.e., dapm_add_valid_dai_widget() and
dapm_connect_dai_link_widgets().

Extend these functions to handle multiple cpu dai.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
  • Loading branch information
shreyasnc1 authored and bardliao committed Dec 20, 2019
1 parent 1ff4cb9 commit 8f63a25
Showing 1 changed file with 66 additions and 54 deletions.
120 changes: 66 additions & 54 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4274,16 +4274,15 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
return 0;
}

static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd)
static void dapm_add_valid_dai_widget(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *codec_dai,
struct snd_soc_dai *cpu_dai)
{
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_dai *codec_dai;
struct snd_soc_dapm_widget *playback = NULL, *capture = NULL;
struct snd_soc_dapm_widget *codec, *playback_cpu, *capture_cpu;
struct snd_pcm_substream *substream;
struct snd_pcm_str *streams = rtd->pcm->streams;
int i;

if (rtd->dai_link->params) {
playback_cpu = cpu_dai->capture_widget;
Expand All @@ -4295,63 +4294,74 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
capture_cpu = capture;
}

for_each_rtd_codec_dai(rtd, i, codec_dai) {
/* connect BE DAI playback if widgets are valid */
codec = codec_dai->playback_widget;

if (playback_cpu && codec) {
if (!playback) {
substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
playback = snd_soc_dapm_new_dai(card, substream,
"playback");
if (IS_ERR(playback)) {
/* connect BE DAI playback if widgets are valid */
codec = codec_dai->playback_widget;

if (playback_cpu && codec) {
if (!playback) {
substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
playback = snd_soc_dapm_new_dai(card, substream,
"playback");
if (IS_ERR(playback)) {
dev_err(rtd->dev,
"ASoC: Failed to create DAI %s: %ld\n",
codec_dai->name,
PTR_ERR(playback));
continue;
}

snd_soc_dapm_add_path(&card->dapm, playback_cpu,
playback, NULL, NULL);
"ASoC: Failed to create DAI %s: %ld\n",
codec_dai->name,
PTR_ERR(playback));
return;
}

dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
cpu_dai->component->name, playback_cpu->name,
codec_dai->component->name, codec->name);

snd_soc_dapm_add_path(&card->dapm, playback, codec,
NULL, NULL);
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
playback, NULL, NULL);
}

dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
cpu_dai->component->name, playback_cpu->name,
codec_dai->component->name, codec->name);

snd_soc_dapm_add_path(&card->dapm, playback, codec,
NULL, NULL);
}

for_each_rtd_codec_dai(rtd, i, codec_dai) {
/* connect BE DAI capture if widgets are valid */
codec = codec_dai->capture_widget;

if (codec && capture_cpu) {
if (!capture) {
substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
capture = snd_soc_dapm_new_dai(card, substream,
"capture");
if (IS_ERR(capture)) {
dev_err(rtd->dev,
"ASoC: Failed to create DAI %s: %ld\n",
codec_dai->name,
PTR_ERR(capture));
continue;
}

snd_soc_dapm_add_path(&card->dapm, capture,
capture_cpu, NULL, NULL);
/* connect BE DAI capture if widgets are valid */
codec = codec_dai->capture_widget;

if (codec && capture_cpu) {
if (!capture) {
substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
capture = snd_soc_dapm_new_dai(card, substream,
"capture");
if (IS_ERR(capture)) {
dev_err(rtd->dev,
"ASoC: Failed to create DAI %s: %ld\n",
codec_dai->name,
PTR_ERR(capture));
return;
}

dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
codec_dai->component->name, codec->name,
cpu_dai->component->name, capture_cpu->name);
snd_soc_dapm_add_path(&card->dapm, capture,
capture_cpu, NULL, NULL);
}

dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
codec_dai->component->name, codec->name,
cpu_dai->component->name, capture_cpu->name);

snd_soc_dapm_add_path(&card->dapm, codec, capture,
NULL, NULL);
}
}

snd_soc_dapm_add_path(&card->dapm, codec, capture,
NULL, NULL);
static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
int i, j;

for_each_rtd_codec_dai(rtd, i, codec_dai) {
for_each_rtd_cpu_dai(rtd, j, cpu_dai) {
dapm_add_valid_dai_widget(card, rtd,
codec_dai, cpu_dai);
}
}
}
Expand Down Expand Up @@ -4417,9 +4427,11 @@ static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
int event)
{
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
int i;

soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event);
for_each_rtd_cpu_dai(rtd, i, cpu_dai)
soc_dapm_dai_stream_event(cpu_dai, stream, event);
for_each_rtd_codec_dai(rtd, i, codec_dai)
soc_dapm_dai_stream_event(codec_dai, stream, event);

Expand Down

0 comments on commit 8f63a25

Please sign in to comment.