Skip to content

Commit 2561247

Browse files
plbossartbroonie
authored andcommitted
ASoC: soc-dai: set dai_link dpcm_ flags with a helper
Add a helper to walk through all the DAIs and set dpcm_playback and dpcm_capture flags based on the DAIs capabilities, and use this helper to avoid setting these flags arbitrarily in generic cards. The commit referenced in the Fixes tag did not introduce the configuration issue but will prevent the card from probing when detecting invalid configurations. Fixes: b73287f ('ASoC: soc-pcm: dpcm: fix playback/capture checks') Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Guennadi Liakhovetski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 503ed52 commit 2561247

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

include/sound/soc-dai.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ void snd_soc_dai_resume(struct snd_soc_dai *dai);
161161
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
162162
struct snd_soc_pcm_runtime *rtd, int num);
163163
bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
164+
void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link);
164165
void snd_soc_dai_action(struct snd_soc_dai *dai,
165166
int stream, int action);
166167
static inline void snd_soc_dai_activate(struct snd_soc_dai *dai,

sound/soc/generic/audio-graph-card.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
317317
if (ret < 0)
318318
goto out_put_node;
319319

320-
dai_link->dpcm_playback = 1;
321-
dai_link->dpcm_capture = 1;
320+
snd_soc_dai_link_set_capabilities(dai_link);
321+
322322
dai_link->ops = &graph_ops;
323323
dai_link->init = asoc_simple_dai_init;
324324

sound/soc/generic/simple-card.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
231231
if (ret < 0)
232232
goto out_put_node;
233233

234-
dai_link->dpcm_playback = 1;
235-
dai_link->dpcm_capture = 1;
234+
snd_soc_dai_link_set_capabilities(dai_link);
235+
236236
dai_link->ops = &simple_ops;
237237
dai_link->init = asoc_simple_dai_init;
238238

sound/soc/soc-dai.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,44 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
391391
return stream->channels_min;
392392
}
393393

394+
/*
395+
* snd_soc_dai_link_set_capabilities() - set dai_link properties based on its DAIs
396+
*/
397+
void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
398+
{
399+
struct snd_soc_dai_link_component *cpu;
400+
struct snd_soc_dai_link_component *codec;
401+
struct snd_soc_dai *dai;
402+
bool supported[SNDRV_PCM_STREAM_LAST + 1];
403+
int direction;
404+
int i;
405+
406+
for_each_pcm_streams(direction) {
407+
supported[direction] = true;
408+
409+
for_each_link_cpus(dai_link, i, cpu) {
410+
dai = snd_soc_find_dai(cpu);
411+
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
412+
supported[direction] = false;
413+
break;
414+
}
415+
}
416+
if (!supported[direction])
417+
continue;
418+
for_each_link_codecs(dai_link, i, codec) {
419+
dai = snd_soc_find_dai(codec);
420+
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
421+
supported[direction] = false;
422+
break;
423+
}
424+
}
425+
}
426+
427+
dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
428+
dai_link->dpcm_capture = supported[SNDRV_PCM_STREAM_CAPTURE];
429+
}
430+
EXPORT_SYMBOL_GPL(snd_soc_dai_link_set_capabilities);
431+
394432
void snd_soc_dai_action(struct snd_soc_dai *dai,
395433
int stream, int action)
396434
{

0 commit comments

Comments
 (0)