ASoC: soc-pcm: fix hw param limits calculation for multi-DAI
authorKai Vehmanen <kai.vehmanen@linux.intel.com>
Tue, 16 Feb 2021 17:22:51 +0000 (19:22 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 17 Feb 2021 18:04:40 +0000 (18:04 +0000)
In case DPCM runtime has multiple CPU DAIs, dpcm_init_runtime_hw() is
called multiple times, once for each CPU DAI. This will lead to
ignoring hw limits of all but the last DAI.

Fix this by moving soc_pcm_hw_init() up by one level to
dpcm_init_runtime_hw().

Fixes: 140f553d1298 ("ASoC: soc-pcm: fix hwparams min/max init for dpcm")
Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210216172251.3023723-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-pcm.c

index 37094ae..14d85ca 100644 (file)
@@ -1531,10 +1531,12 @@ static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
 {
        struct snd_pcm_hardware *hw = &runtime->hw;
 
-       soc_pcm_hw_init(hw);
        soc_pcm_hw_update_rate(hw, stream);
        soc_pcm_hw_update_chan(hw, stream);
-       soc_pcm_hw_update_format(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,
@@ -1662,10 +1664,13 @@ 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