mirror of
https://github.com/torvalds/linux.git
synced 2024-12-14 07:02:23 +00:00
ASoC: minor cleanup for soc_get_playback_capture()
Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>: This is minor cleanup patches for soc_get_playback_capture().
This commit is contained in:
commit
d0c76d9430
@ -2730,48 +2730,50 @@ open_end:
|
||||
static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
|
||||
int *playback, int *capture)
|
||||
{
|
||||
struct snd_soc_dai_link *dai_link = rtd->dai_link;
|
||||
struct snd_soc_dai *cpu_dai;
|
||||
int has_playback = 0;
|
||||
int has_capture = 0;
|
||||
int i;
|
||||
|
||||
if (rtd->dai_link->dynamic && rtd->dai_link->num_cpus > 1) {
|
||||
dev_err(rtd->dev,
|
||||
"DPCM doesn't support Multi CPU for Front-Ends yet\n");
|
||||
if (dai_link->dynamic && dai_link->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) {
|
||||
if (dai_link->dynamic || dai_link->no_pcm) {
|
||||
int stream;
|
||||
|
||||
if (rtd->dai_link->dpcm_playback) {
|
||||
if (dai_link->dpcm_playback) {
|
||||
stream = SNDRV_PCM_STREAM_PLAYBACK;
|
||||
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||
*playback = 1;
|
||||
has_playback = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!*playback) {
|
||||
if (!has_playback) {
|
||||
dev_err(rtd->card->dev,
|
||||
"No CPU DAIs support playback for stream %s\n",
|
||||
rtd->dai_link->stream_name);
|
||||
dai_link->stream_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (rtd->dai_link->dpcm_capture) {
|
||||
if (dai_link->dpcm_capture) {
|
||||
stream = SNDRV_PCM_STREAM_CAPTURE;
|
||||
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||
*capture = 1;
|
||||
has_capture = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*capture) {
|
||||
if (!has_capture) {
|
||||
dev_err(rtd->card->dev,
|
||||
"No CPU DAIs support capture for stream %s\n",
|
||||
rtd->dai_link->stream_name);
|
||||
dai_link->stream_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
@ -2779,15 +2781,15 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_soc_dai *codec_dai;
|
||||
|
||||
/* Adapt stream for codec2codec links */
|
||||
int cpu_capture = rtd->dai_link->c2c_params ?
|
||||
int cpu_capture = dai_link->c2c_params ?
|
||||
SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
|
||||
int cpu_playback = rtd->dai_link->c2c_params ?
|
||||
int cpu_playback = dai_link->c2c_params ?
|
||||
SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
|
||||
|
||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||
if (rtd->dai_link->num_cpus == 1) {
|
||||
if (dai_link->num_cpus == 1) {
|
||||
cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
||||
} else if (rtd->dai_link->num_cpus == rtd->dai_link->num_codecs) {
|
||||
} else if (dai_link->num_cpus == dai_link->num_codecs) {
|
||||
cpu_dai = asoc_rtd_to_cpu(rtd, i);
|
||||
} else {
|
||||
dev_err(rtd->card->dev,
|
||||
@ -2797,22 +2799,28 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
|
||||
|
||||
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
|
||||
snd_soc_dai_stream_valid(cpu_dai, cpu_playback))
|
||||
*playback = 1;
|
||||
has_playback = 1;
|
||||
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
|
||||
snd_soc_dai_stream_valid(cpu_dai, cpu_capture))
|
||||
*capture = 1;
|
||||
has_capture = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rtd->dai_link->playback_only) {
|
||||
*playback = 1;
|
||||
*capture = 0;
|
||||
if (dai_link->playback_only)
|
||||
has_capture = 0;
|
||||
|
||||
if (dai_link->capture_only)
|
||||
has_playback = 0;
|
||||
|
||||
if (!has_playback && !has_capture) {
|
||||
dev_err(rtd->dev, "substream %s has no playback, no capture\n",
|
||||
dai_link->stream_name);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (rtd->dai_link->capture_only) {
|
||||
*playback = 0;
|
||||
*capture = 1;
|
||||
}
|
||||
*playback = has_playback;
|
||||
*capture = has_capture;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user