Skip to content

Commit 4f87215

Browse files
plbossartbroonie
authored andcommitted
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: 2561247 ('ASoC: soc-dai: set dai_link dpcm_ flags with a helper') Fixes: b73287f ('ASoC: soc-pcm: dpcm: fix playback/capture checks') Suggested-by: Jerome Brunet <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 20196e0 commit 4f87215

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

sound/soc/soc-dai.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,28 +400,30 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
400400
struct snd_soc_dai_link_component *codec;
401401
struct snd_soc_dai *dai;
402402
bool supported[SNDRV_PCM_STREAM_LAST + 1];
403+
bool supported_cpu;
404+
bool supported_codec;
403405
int direction;
404406
int i;
405407

406408
for_each_pcm_streams(direction) {
407-
supported[direction] = true;
409+
supported_cpu = false;
410+
supported_codec = false;
408411

409412
for_each_link_cpus(dai_link, i, cpu) {
410413
dai = snd_soc_find_dai(cpu);
411-
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
412-
supported[direction] = false;
414+
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
415+
supported_cpu = true;
413416
break;
414417
}
415418
}
416-
if (!supported[direction])
417-
continue;
418419
for_each_link_codecs(dai_link, i, codec) {
419420
dai = snd_soc_find_dai(codec);
420-
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
421-
supported[direction] = false;
421+
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
422+
supported_codec = true;
422423
break;
423424
}
424425
}
426+
supported[direction] = supported_cpu && supported_codec;
425427
}
426428

427429
dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];

sound/soc/soc-pcm.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,30 +2802,36 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
28022802
if (rtd->dai_link->dpcm_playback) {
28032803
stream = SNDRV_PCM_STREAM_PLAYBACK;
28042804

2805-
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
2806-
if (!snd_soc_dai_stream_valid(cpu_dai,
2807-
stream)) {
2808-
dev_err(rtd->card->dev,
2809-
"CPU DAI %s for rtd %s does not support playback\n",
2810-
cpu_dai->name,
2811-
rtd->dai_link->stream_name);
2812-
return -EINVAL;
2805+
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2806+
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
2807+
playback = 1;
2808+
break;
28132809
}
2814-
playback = 1;
2810+
}
2811+
2812+
if (!playback) {
2813+
dev_err(rtd->card->dev,
2814+
"No CPU DAIs support playback for stream %s\n",
2815+
rtd->dai_link->stream_name);
2816+
return -EINVAL;
2817+
}
28152818
}
28162819
if (rtd->dai_link->dpcm_capture) {
28172820
stream = SNDRV_PCM_STREAM_CAPTURE;
28182821

2819-
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
2820-
if (!snd_soc_dai_stream_valid(cpu_dai,
2821-
stream)) {
2822-
dev_err(rtd->card->dev,
2823-
"CPU DAI %s for rtd %s does not support capture\n",
2824-
cpu_dai->name,
2825-
rtd->dai_link->stream_name);
2826-
return -EINVAL;
2822+
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2823+
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
2824+
capture = 1;
2825+
break;
28272826
}
2828-
capture = 1;
2827+
}
2828+
2829+
if (!capture) {
2830+
dev_err(rtd->card->dev,
2831+
"No CPU DAIs support capture for stream %s\n",
2832+
rtd->dai_link->stream_name);
2833+
return -EINVAL;
2834+
}
28292835
}
28302836
} else {
28312837
/* Adapt stream for codec2codec links */

0 commit comments

Comments
 (0)