Skip to content

Commit bd1132f

Browse files
committed
ASoC: pcm: do not register pcm device for virtual FE dai links
Virtual FE dai links do not need to register the pcm device. So just create the empty pcm device and substream in the requested direction. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent b829c2b commit bd1132f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

sound/soc/soc-pcm.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,6 +3098,55 @@ static int soc_rtdcom_mmap(struct snd_pcm_substream *substream,
30983098
return -EINVAL;
30993099
}
31003100

3101+
/*
3102+
* for virtual FE dai links, there is no need
3103+
* to register PCM device. So only allocate memory for
3104+
* the dummy pcm device and substreams to be used for
3105+
* codec startup
3106+
*/
3107+
static int setup_virtual_fe(struct snd_soc_pcm_runtime *rtd,
3108+
struct snd_pcm *pcm)
3109+
{
3110+
struct snd_pcm_substream *substream;
3111+
struct snd_pcm_str *pstr;
3112+
int stream_dir;
3113+
3114+
/* create pcm */
3115+
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
3116+
if (!pcm)
3117+
return -ENOMEM;
3118+
3119+
/* set up playback/capture substream */
3120+
if (rtd->dai_link->dpcm_playback)
3121+
stream_dir = SNDRV_PCM_STREAM_PLAYBACK;
3122+
else
3123+
stream_dir = SNDRV_PCM_STREAM_CAPTURE;
3124+
3125+
pstr = &pcm->streams[stream_dir];
3126+
3127+
/* allocate memory for substream */
3128+
substream = kzalloc(sizeof(*substream), GFP_KERNEL);
3129+
if (!substream)
3130+
return -ENOMEM;
3131+
3132+
/* define substream */
3133+
substream->pcm = pcm;
3134+
substream->pstr = pstr;
3135+
substream->number = 0;
3136+
substream->stream = stream_dir;
3137+
sprintf(substream->name, "subdevice #%i", 0);
3138+
substream->buffer_bytes_max = UINT_MAX;
3139+
3140+
/* set pcm substream */
3141+
pstr->substream = substream;
3142+
3143+
pcm->nonatomic = rtd->dai_link->nonatomic;
3144+
rtd->pcm = pcm;
3145+
pcm->private_data = rtd;
3146+
3147+
return 0;
3148+
}
3149+
31013150
/* create a new pcm */
31023151
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
31033152
{
@@ -3145,6 +3194,13 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
31453194
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
31463195
playback, capture, &pcm);
31473196
} else {
3197+
3198+
/* set up virtual FE dai link */
3199+
if (rtd->dai_link->dynamic && rtd->dai_link->no_pcm) {
3200+
setup_virtual_fe(rtd, pcm);
3201+
goto out;
3202+
}
3203+
31483204
if (rtd->dai_link->dynamic)
31493205
snprintf(new_name, sizeof(new_name), "%s (*)",
31503206
rtd->dai_link->stream_name);

0 commit comments

Comments
 (0)