Skip to content

Commit 89a7244

Browse files
ujfalusilgirdwood
authored andcommitted
ASoC: soc-pcm: Allocate be_substream->runtime for compressed streams
With DPCM when compr is used on FE side, the BE is still running as 'normal' PCM. It is expected that the be_substream->runtime on the BE is not NULL, for example some codec drivers expect to have the substream->runtime valid, to store configuration for example. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent a29bd0d commit 89a7244

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

sound/soc/soc-pcm.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,8 @@ void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream,
17901790
}
17911791

17921792
__soc_pcm_close(be, be_substream);
1793+
if (fe->fe_compr)
1794+
kfree(be_substream->runtime);
17931795
be_substream->runtime = NULL;
17941796
be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
17951797
}
@@ -1837,18 +1839,26 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
18371839
dev_dbg(be->dev, "ASoC: open %s BE %s\n",
18381840
snd_pcm_direction_name(stream), be->dai_link->name);
18391841

1840-
be_substream->runtime = fe_substream->runtime;
1842+
if (!fe->fe_compr) {
1843+
be_substream->runtime = fe_substream->runtime;
1844+
} else {
1845+
be_substream->runtime = kzalloc(sizeof(*be_substream->runtime),
1846+
GFP_KERNEL);
1847+
if (!be_substream->runtime) {
1848+
err = -ENOMEM;
1849+
goto unwind;
1850+
}
1851+
}
1852+
18411853
err = __soc_pcm_open(be, be_substream);
18421854
if (err < 0) {
1843-
be->dpcm[stream].users--;
1844-
if (be->dpcm[stream].users < 0)
1845-
dev_err(be->dev, "ASoC: no users %s at unwind %s\n",
1846-
snd_pcm_direction_name(stream),
1847-
dpcm_state_string(be->dpcm[stream].state));
1848-
1849-
be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
1855+
if (fe->fe_compr) {
1856+
kfree(be_substream->runtime);
1857+
be_substream->runtime = NULL;
1858+
}
18501859
goto unwind;
18511860
}
1861+
18521862
be->dpcm[stream].be_start = 0;
18531863
be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
18541864
count++;
@@ -1857,6 +1867,14 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
18571867
return count;
18581868

18591869
unwind:
1870+
be->dpcm[stream].users--;
1871+
if (be->dpcm[stream].users < 0)
1872+
dev_err(be->dev, "ASoC: no users %s at unwind %s\n",
1873+
snd_pcm_direction_name(stream),
1874+
dpcm_state_string(be->dpcm[stream].state));
1875+
1876+
be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
1877+
18601878
dpcm_be_dai_startup_rollback(fe, stream, dpcm);
18611879

18621880
return soc_pcm_ret(fe, err);

0 commit comments

Comments
 (0)