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: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Shreyas NC <shreyas.nc@intel.com> Signed-off-by: Vinod Koul <vkoul@kernel.org> Link: https://lore.kernel.org/r/20200225133917.21314-4-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
19bdcc7aee
commit
6c4b13b51a
1 changed files with 60 additions and 53 deletions
|
@ -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,7 +4297,6 @@ 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;
|
||||||
|
|
||||||
|
@ -4312,7 +4310,7 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
|
||||||
"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));
|
||||||
continue;
|
goto capture;
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
|
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
|
||||||
|
@ -4326,9 +4324,8 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
|
||||||
snd_soc_dapm_add_path(&card->dapm, playback, codec,
|
snd_soc_dapm_add_path(&card->dapm, playback, codec,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for_each_rtd_codec_dai(rtd, i, codec_dai) {
|
capture:
|
||||||
/* connect BE DAI capture if widgets are valid */
|
/* connect BE DAI capture if widgets are valid */
|
||||||
codec = codec_dai->capture_widget;
|
codec = codec_dai->capture_widget;
|
||||||
|
|
||||||
|
@ -4342,7 +4339,7 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
|
||||||
"ASoC: Failed to create DAI %s: %ld\n",
|
"ASoC: Failed to create DAI %s: %ld\n",
|
||||||
codec_dai->name,
|
codec_dai->name,
|
||||||
PTR_ERR(capture));
|
PTR_ERR(capture));
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_soc_dapm_add_path(&card->dapm, capture,
|
snd_soc_dapm_add_path(&card->dapm, capture,
|
||||||
|
@ -4356,7 +4353,17 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
|
||||||
snd_soc_dapm_add_path(&card->dapm, codec, capture,
|
snd_soc_dapm_add_path(&card->dapm, codec, capture,
|
||||||
NULL, NULL);
|
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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue