Skip to content

Commit

Permalink
ASoC: pcm: do not register pcm device for virtual FE dai links
Browse files Browse the repository at this point in the history
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 27, 2018
1 parent b829c2b commit bd1132f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3098,6 +3098,55 @@ static int soc_rtdcom_mmap(struct snd_pcm_substream *substream,
return -EINVAL;
}

/*
* for virtual FE dai links, there is no need
* to register PCM device. So only allocate memory for
* the dummy pcm device and substreams to be used for
* codec startup
*/
static int setup_virtual_fe(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm *pcm)
{
struct snd_pcm_substream *substream;
struct snd_pcm_str *pstr;
int stream_dir;

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

/* set up playback/capture substream */
if (rtd->dai_link->dpcm_playback)
stream_dir = SNDRV_PCM_STREAM_PLAYBACK;
else
stream_dir = SNDRV_PCM_STREAM_CAPTURE;

pstr = &pcm->streams[stream_dir];

/* allocate memory for substream */
substream = kzalloc(sizeof(*substream), GFP_KERNEL);
if (!substream)
return -ENOMEM;

/* define substream */
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;

/* set pcm substream */
pstr->substream = substream;

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

return 0;
}

/* create a new pcm */
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
{
Expand Down Expand Up @@ -3145,6 +3194,13 @@ 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 {

/* set up virtual FE dai link */
if (rtd->dai_link->dynamic && rtd->dai_link->no_pcm) {
setup_virtual_fe(rtd, pcm);
goto out;
}

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

0 comments on commit bd1132f

Please sign in to comment.