Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ASoC: pcm: do no 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>
  • Loading branch information
ranj063 committed Jun 24, 2018
commit 337e4f273add60a9f4a8dec37adf7dcd88306a4f
40 changes: 40 additions & 0 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,9 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_component *component;
struct snd_soc_rtdcom_list *rtdcom;
struct snd_pcm_substream *substream;
struct snd_pcm *pcm;
int stream_dir;
char new_name[64];
int ret = 0, playback = 0, capture = 0;
int i;
Expand Down Expand Up @@ -3150,6 +3152,44 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
playback, capture, &pcm);
} else {

/*
* for virtual FE dai links, there is no need
* to register PCM device. So only allocate memory for
* pcm device and substream for the requested direction
*/
if (rtd->dai_link->virtual) {
struct snd_pcm_str *pstr;

if (rtd->dai_link->dpcm_playback)
stream_dir = SNDRV_PCM_STREAM_PLAYBACK;

pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
if (!pcm)
return -ENOMEM;

pstr = &pcm->streams[stream_dir];

substream = kzalloc(sizeof(*substream), GFP_KERNEL);
if (!substream)
return -ENOMEM;

substream->pcm = pcm;
substream->pstr = pstr;
substream->number = 0;
substream->stream = stream_dir;
sprintf(substream->name, "subdevice #%i", 0);
substream->buffer_bytes_max = UINT_MAX;

pstr->substream = substream;

pcm->nonatomic = rtd->dai_link->nonatomic;
rtd->pcm = pcm;
pcm->private_data = rtd;

goto out;
}

if (rtd->dai_link->dynamic)
snprintf(new_name, sizeof(new_name), "%s (*)",
rtd->dai_link->stream_name);
Expand Down