mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 15:43:35 -04:00
ASoC: soc-pcm: add soc_get_playback_capture() and simplify soc_new_pcm()
soc_new_pcm() implementation is very long / verbose / complex,
thus, it is very difficult to read.
If we read it carefully, we can notice that it is consisted by
int soc_new_pcm(...)
{
(1) judging playback/caputre part
(2) creating the PCM part
(3) setup pcm/rtd part
}
This patch adds new soc_get_playback_capture() for (1) part
and offload it from soc_new_pcm().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877do5aign.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
e04e7b8ccd
commit
7fc6bebd58
@@ -2631,15 +2631,11 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* create a new pcm */
|
||||
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||
static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
|
||||
int *playback, int *capture)
|
||||
{
|
||||
struct snd_soc_dai *codec_dai;
|
||||
struct snd_soc_dai *cpu_dai;
|
||||
struct snd_soc_component *component;
|
||||
struct snd_pcm *pcm;
|
||||
char new_name[64];
|
||||
int ret = 0, playback = 0, capture = 0;
|
||||
int stream;
|
||||
int i;
|
||||
|
||||
@@ -2655,12 +2651,11 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||
playback = 1;
|
||||
*playback = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playback) {
|
||||
if (!*playback) {
|
||||
dev_err(rtd->card->dev,
|
||||
"No CPU DAIs support playback for stream %s\n",
|
||||
rtd->dai_link->stream_name);
|
||||
@@ -2672,12 +2667,12 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||
capture = 1;
|
||||
*capture = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!capture) {
|
||||
if (!*capture) {
|
||||
dev_err(rtd->card->dev,
|
||||
"No CPU DAIs support capture for stream %s\n",
|
||||
rtd->dai_link->stream_name);
|
||||
@@ -2704,23 +2699,39 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||
|
||||
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
|
||||
snd_soc_dai_stream_valid(cpu_dai, cpu_playback))
|
||||
playback = 1;
|
||||
*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;
|
||||
*capture = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rtd->dai_link->playback_only) {
|
||||
playback = 1;
|
||||
capture = 0;
|
||||
*playback = 1;
|
||||
*capture = 0;
|
||||
}
|
||||
|
||||
if (rtd->dai_link->capture_only) {
|
||||
playback = 0;
|
||||
capture = 1;
|
||||
*playback = 0;
|
||||
*capture = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* create a new pcm */
|
||||
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||
{
|
||||
struct snd_soc_component *component;
|
||||
struct snd_pcm *pcm;
|
||||
char new_name[64];
|
||||
int ret = 0, playback = 0, capture = 0;
|
||||
int i;
|
||||
|
||||
ret = soc_get_playback_capture(rtd, &playback, &capture);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* create the PCM */
|
||||
if (rtd->dai_link->params) {
|
||||
snprintf(new_name, sizeof(new_name), "codec2codec(%s)",
|
||||
|
||||
Reference in New Issue
Block a user