ASoC: soc-pcm.c: Clear DAIs parameters after stream_active is updated

DAIs parameters should be cleared if there's no active stream. Before,
we implemented it in soc_pcm_hw_free() by detecting stream_active. If
the running stream is the last active stream, we're going to clear
parameters.

However it will cause DAIs parameters never be cleared if there're
more than one stream. For example, we have stream1 and stream2 about
to stop. stream2 executes soc_pcm_hw_free() before stream1 executes
soc_pcm_close(). At the moment, stream2 should clear DAIs parameters.
Since stream_active is not yet updated by stream1 in soc_pcm_close(),
stream2 will not clear DAIs parameters. In result both stream1 and
stream2 don't clear the parameters.

This patch moves DAIs parameters cleanup after stream_active is
updated.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Link: https://lore.kernel.org/r/20221128060950.3540845-1-chancel.liu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Chancel Liu 2022-11-28 14:09:50 +08:00 committed by Mark Brown
parent 81ed7d9de1
commit 1da681e528
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -709,8 +709,17 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
snd_soc_dpcm_mutex_assert_held(rtd);
if (!rollback)
if (!rollback) {
snd_soc_runtime_deactivate(rtd, substream->stream);
/* clear the corresponding DAIs parameters when going to be inactive */
for_each_rtd_dais(rtd, i, dai) {
if (snd_soc_dai_active(dai) == 0)
soc_pcm_set_dai_params(dai, NULL);
if (snd_soc_dai_stream_active(dai, substream->stream) == 0)
snd_soc_dai_digital_mute(dai, 1, substream->stream);
}
}
for_each_rtd_dais(rtd, i, dai)
snd_soc_dai_shutdown(dai, substream, rollback);
@ -940,15 +949,6 @@ static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
snd_soc_dpcm_mutex_assert_held(rtd);
/* clear the corresponding DAIs parameters when going to be inactive */
for_each_rtd_dais(rtd, i, dai) {
if (snd_soc_dai_active(dai) == 1)
soc_pcm_set_dai_params(dai, NULL);
if (snd_soc_dai_stream_active(dai, substream->stream) == 1)
snd_soc_dai_digital_mute(dai, 1, substream->stream);
}
/* run the stream event */
snd_soc_dapm_stream_stop(rtd, substream->stream);