Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,20 +2908,42 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
struct snd_pcm *pcm;
char new_name[64];
int ret = 0, playback = 0, capture = 0;
int stream;
int i;

if (rtd->dai_link->dynamic && rtd->num_cpus > 1) {
dev_err(rtd->dev,
"DPCM doesn't support Multi CPU for Front-Ends yet\n");
return -EINVAL;
}

if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) {
cpu_dai = asoc_rtd_to_cpu(rtd, 0);
if (rtd->num_cpus > 1) {
dev_err(rtd->dev,
"DPCM doesn't support Multi CPU yet\n");
return -EINVAL;
}
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {

if (rtd->dai_link->dpcm_playback) {
stream = SNDRV_PCM_STREAM_PLAYBACK;
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ASoC makes my head hurt again.

I don't quite get why "snd_soc_dai_stream_valid()==true" must apply for the first CPU DAI of the rtd, but for 2..N CPU DAIs, stream_valid check can fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea was to check that ALL cpu_dais in a dailink that says it can do playack can indeed do so. So my proposal is to bail if you encounter one DAI that doesn't support playback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart I was thinking of following sequence:

CPU DAI #1 capture only but dai_link->dpcm_playback is set for the rtd so we go to L2923
CPU DAI #2 playback -> ok, playback set as 1
CPU DAI #3 another capture DAI -> as playback was set, we will return error that "CPU DAI #3 does not support playback"

... I guess this is not a case that can practically happen. If you think this is ok, I'm ok as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, you're right this doesn't work in all cases.
Maybe the correct thing to do is just increment a counter for valid dais, and check after the look that they are all valid.

Copy link
Collaborator

@ranj063 ranj063 Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i this check is good to catch human errors with the dai drv array declaration in the driver.

playback = 1;
} else if (playback != 0) {
dev_err(rtd->card->dev,
"CPU DAI %s does not support playback\n",
cpu_dai->name);
return -EINVAL;
}
}

playback = rtd->dai_link->dpcm_playback &&
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK);
capture = rtd->dai_link->dpcm_capture &&
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE);
if (rtd->dai_link->dpcm_capture) {
stream = SNDRV_PCM_STREAM_CAPTURE;
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
capture = 1;
} else if (capture != 0) {
dev_err(rtd->card->dev,
"CPU DAI %s does not support capture\n",
cpu_dai->name);
return -EINVAL;
}
}
}
} else {
/* Adapt stream for codec2codec links */
int cpu_capture = rtd->dai_link->params ?
Expand Down