Commit 6c4b13b5 authored by Shreyas NC's avatar Shreyas NC Committed by Mark Brown

ASoC: Add dapm_add_valid_dai_widget helper

Adding a helper to connect widget for a specific cpu and codec dai
The helper will help dapm_connect_dai_link_widgets() to reduce indents.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarShreyas NC <shreyas.nc@intel.com>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20200225133917.21314-4-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 19bdcc7a
...@@ -4277,16 +4277,15 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) ...@@ -4277,16 +4277,15 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
return 0; return 0;
} }
static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, static void dapm_add_valid_dai_widget(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd) 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 *playback = NULL, *capture = NULL;
struct snd_soc_dapm_widget *codec, *playback_cpu, *capture_cpu; struct snd_soc_dapm_widget *codec, *playback_cpu, *capture_cpu;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct snd_pcm_str *streams = rtd->pcm->streams; struct snd_pcm_str *streams = rtd->pcm->streams;
int i;
if (rtd->dai_link->params) { if (rtd->dai_link->params) {
playback_cpu = cpu_dai->capture_widget; playback_cpu = cpu_dai->capture_widget;
...@@ -4298,67 +4297,75 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, ...@@ -4298,67 +4297,75 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
capture_cpu = capture; capture_cpu = capture;
} }
for_each_rtd_codec_dai(rtd, i, codec_dai) { /* connect BE DAI playback if widgets are valid */
/* connect BE DAI playback if widgets are valid */ codec = codec_dai->playback_widget;
codec = codec_dai->playback_widget;
if (playback_cpu && codec) {
if (playback_cpu && codec) { if (!playback) {
if (!playback) { substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream; playback = snd_soc_dapm_new_dai(card, substream,
playback = snd_soc_dapm_new_dai(card, substream, "playback");
"playback"); if (IS_ERR(playback)) {
if (IS_ERR(playback)) { dev_err(rtd->dev,
dev_err(rtd->dev, "ASoC: Failed to create DAI %s: %ld\n",
"ASoC: Failed to create DAI %s: %ld\n", codec_dai->name,
codec_dai->name, PTR_ERR(playback));
PTR_ERR(playback)); goto capture;
continue;
}
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
playback, NULL, NULL);
} }
dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", snd_soc_dapm_add_path(&card->dapm, playback_cpu,
cpu_dai->component->name, playback_cpu->name, playback, NULL, NULL);
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) { dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n",
/* connect BE DAI capture if widgets are valid */ cpu_dai->component->name, playback_cpu->name,
codec = codec_dai->capture_widget; codec_dai->component->name, codec->name);
if (codec && capture_cpu) { snd_soc_dapm_add_path(&card->dapm, playback, codec,
if (!capture) { NULL, NULL);
substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream; }
capture = snd_soc_dapm_new_dai(card, substream,
"capture"); capture:
if (IS_ERR(capture)) { /* connect BE DAI capture if widgets are valid */
dev_err(rtd->dev, codec = codec_dai->capture_widget;
"ASoC: Failed to create DAI %s: %ld\n",
codec_dai->name, if (codec && capture_cpu) {
PTR_ERR(capture)); if (!capture) {
continue; substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
} capture = snd_soc_dapm_new_dai(card, substream,
"capture");
snd_soc_dapm_add_path(&card->dapm, capture, if (IS_ERR(capture)) {
capture_cpu, NULL, NULL); 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", snd_soc_dapm_add_path(&card->dapm, capture,
codec_dai->component->name, codec->name, capture_cpu, NULL, NULL);
cpu_dai->component->name, capture_cpu->name);
snd_soc_dapm_add_path(&card->dapm, codec, capture,
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);
} }
} }
static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *codec_dai;
int i;
for_each_rtd_codec_dai(rtd, i, codec_dai)
dapm_add_valid_dai_widget(card, rtd,
codec_dai, rtd->cpu_dais[0]);
}
static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream, static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,
int event) int event)
{ {
......
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