diff options
| author | Mark Brown <broonie@kernel.org> | 2021-03-01 23:31:49 +0000 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2021-03-10 13:08:30 +0000 |
| commit | 4ea62149dc62d06dc39eb4870e04fda1a34360c3 (patch) | |
| tree | 40e9a3a4fac30fec7af9c754d57d1b4d330ac949 | |
| parent | 029448a8560f92e235ba7d30ff0b1fb458d279de (diff) | |
| parent | 4fe28461e289e7209dc969d5878997069f5be157 (diff) | |
Merge series "soc-pcm: tidyup snd_pcm_hardware setup for FE/BE" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
Hi Mark
These patches tidyup snd_pcm_hardware setup for FE/BE.
[1/5] changes behavior, but I think it is bug-fix.
Kuninori Morimoto (5):
ASoC: soc-pcm: remove strange format storing
ASoC: soc-pcm: unpack dpcm_init_runtime_hw()
ASoC: soc-pcm: add dpcm_runtime_setup_fe()
ASoC: soc-pcm: add dpcm_runtime_setup()
ASoC: soc-pcm: unpack dpcm_set_fe_runtime()
sound/soc/soc-pcm.c | 79 +++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 43 deletions(-)
--
2.25.1
| -rw-r--r-- | sound/soc/soc-pcm.c | 79 |
1 files changed, 36 insertions, 43 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 14d85ca1e435..511c9218308a 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1526,23 +1526,40 @@ unwind: return err; } -static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime, - struct snd_soc_pcm_stream *stream) +static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; + struct snd_soc_dai *dai; + int stream = substream->stream; + int i; + + soc_pcm_hw_init(hw); + + for_each_rtd_cpu_dais(fe, i, dai) { + struct snd_soc_pcm_stream *cpu_stream; + + /* + * Skip CPUs which don't support the current stream + * type. See soc_pcm_init_runtime_hw() for more details + */ + if (!snd_soc_dai_stream_valid(dai, stream)) + continue; + + cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); + + soc_pcm_hw_update_rate(hw, cpu_stream); + soc_pcm_hw_update_chan(hw, cpu_stream); + soc_pcm_hw_update_format(hw, cpu_stream); + } - soc_pcm_hw_update_rate(hw, stream); - soc_pcm_hw_update_chan(hw, stream); - if (runtime->hw.formats) - runtime->hw.formats &= stream->formats; - else - runtime->hw.formats = stream->formats; } -static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream, - struct snd_pcm_runtime *runtime) +static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; struct snd_soc_dpcm *dpcm; struct snd_soc_dai *dai; @@ -1576,10 +1593,10 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream, } } -static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream, - struct snd_pcm_runtime *runtime) +static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; struct snd_soc_dpcm *dpcm; int stream = substream->stream; @@ -1624,10 +1641,10 @@ static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream, } } -static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream, - struct snd_pcm_runtime *runtime) +static void dpcm_runtime_setup_be_rate(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; struct snd_soc_dpcm *dpcm; int stream = substream->stream; @@ -1661,34 +1678,6 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream, } } -static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_pcm_hardware *hw = &runtime->hw; - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai; - int i; - - soc_pcm_hw_init(hw); - - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - /* - * Skip CPUs which don't support the current stream - * type. See soc_pcm_init_runtime_hw() for more details - */ - if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) - continue; - - dpcm_init_runtime_hw(runtime, - snd_soc_dai_get_pcm_stream(cpu_dai, - substream->stream)); - } - - dpcm_runtime_merge_format(substream, runtime); - dpcm_runtime_merge_chan(substream, runtime); - dpcm_runtime_merge_rate(substream, runtime); -} - static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream, int stream) { @@ -1768,7 +1757,11 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream) fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; - dpcm_set_fe_runtime(fe_substream); + dpcm_runtime_setup_fe(fe_substream); + + dpcm_runtime_setup_be_format(fe_substream); + dpcm_runtime_setup_be_chan(fe_substream); + dpcm_runtime_setup_be_rate(fe_substream); ret = dpcm_apply_symmetry(fe_substream, stream); if (ret < 0) |
