Commit 4f872154 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: core: use less strict tests for dailink capabilities

Previous updates to set dailink capabilities and check dailink
capabilities were based on a flawed assumption that all dais support
the same capabilities as the dailink. This is true for TDM
configurations but existing configurations use an amplifier and a
capture device on the same dailink, and the tests would prevent the
card from probing.

This patch modifies the snd_soc_dai_link_set_capabilities()
helper so that the dpcm_playback (resp. dpcm_capture) dailink
capabilities are set if at least one dai supports playback (resp. capture).

Likewise the checks are modified so that an error is reported only
when dpcm_playback (resp. dpcm_capture) is set but none of the CPU
DAIs support playback (resp. capture).

Fixes: 25612477 ('ASoC: soc-dai: set dai_link dpcm_ flags with a helper')
Fixes: b73287f0 ('ASoC: soc-pcm: dpcm: fix playback/capture checks')
Suggested-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200723180533.220312-1-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 20196e0e
...@@ -400,28 +400,30 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link) ...@@ -400,28 +400,30 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
struct snd_soc_dai_link_component *codec; struct snd_soc_dai_link_component *codec;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
bool supported[SNDRV_PCM_STREAM_LAST + 1]; bool supported[SNDRV_PCM_STREAM_LAST + 1];
bool supported_cpu;
bool supported_codec;
int direction; int direction;
int i; int i;
for_each_pcm_streams(direction) { for_each_pcm_streams(direction) {
supported[direction] = true; supported_cpu = false;
supported_codec = false;
for_each_link_cpus(dai_link, i, cpu) { for_each_link_cpus(dai_link, i, cpu) {
dai = snd_soc_find_dai(cpu); dai = snd_soc_find_dai(cpu);
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) { if (dai && snd_soc_dai_stream_valid(dai, direction)) {
supported[direction] = false; supported_cpu = true;
break; break;
} }
} }
if (!supported[direction])
continue;
for_each_link_codecs(dai_link, i, codec) { for_each_link_codecs(dai_link, i, codec) {
dai = snd_soc_find_dai(codec); dai = snd_soc_find_dai(codec);
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) { if (dai && snd_soc_dai_stream_valid(dai, direction)) {
supported[direction] = false; supported_codec = true;
break; break;
} }
} }
supported[direction] = supported_cpu && supported_codec;
} }
dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK]; dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
......
...@@ -2802,30 +2802,36 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -2802,30 +2802,36 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
if (rtd->dai_link->dpcm_playback) { if (rtd->dai_link->dpcm_playback) {
stream = SNDRV_PCM_STREAM_PLAYBACK; stream = SNDRV_PCM_STREAM_PLAYBACK;
for_each_rtd_cpu_dais(rtd, i, cpu_dai) for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (!snd_soc_dai_stream_valid(cpu_dai, if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
stream)) { playback = 1;
dev_err(rtd->card->dev, break;
"CPU DAI %s for rtd %s does not support playback\n",
cpu_dai->name,
rtd->dai_link->stream_name);
return -EINVAL;
} }
playback = 1; }
if (!playback) {
dev_err(rtd->card->dev,
"No CPU DAIs support playback for stream %s\n",
rtd->dai_link->stream_name);
return -EINVAL;
}
} }
if (rtd->dai_link->dpcm_capture) { if (rtd->dai_link->dpcm_capture) {
stream = SNDRV_PCM_STREAM_CAPTURE; stream = SNDRV_PCM_STREAM_CAPTURE;
for_each_rtd_cpu_dais(rtd, i, cpu_dai) for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (!snd_soc_dai_stream_valid(cpu_dai, if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
stream)) { capture = 1;
dev_err(rtd->card->dev, break;
"CPU DAI %s for rtd %s does not support capture\n",
cpu_dai->name,
rtd->dai_link->stream_name);
return -EINVAL;
} }
capture = 1; }
if (!capture) {
dev_err(rtd->card->dev,
"No CPU DAIs support capture for stream %s\n",
rtd->dai_link->stream_name);
return -EINVAL;
}
} }
} else { } else {
/* Adapt stream for codec2codec links */ /* Adapt stream for codec2codec links */
......
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