Skip to content

Commit d338342

Browse files
Nicolin Chenbroonie
authored andcommitted
ASoC: soc-pcm: move DAIs parameters cleaning into hw_free()
We're now applying soc_hw_params_symmetry() to reject unmatched parameters while we clear parameters in soc_pcm_close(). So here's a use case might be broken by this mechanism: aplay -Dhw:0 44100.wav 48000.wav 32000.wav In this case, we call soc_pcm_open()->soc_pcm_hw_params()->soc_pcm_hw_free() ->soc_pcm_hw_params()->soc_pcm_hw_free()->soc_pcm_close() in order. As we only clear parameters in soc_pcm_close(). The parameters would be remained in the system even if the playback of 44100.wav is finished. Thus, this patch is trying to move parameters cleaning into hw_free() so that the system can continue to serve this kind of use case. Also, since we set them in hw_params(), it should be better to clear them in hw_free() for symmetry. Signed-off-by: Nicolin Chen <b42378@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent 3635bf0 commit d338342

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

‎sound/soc/soc-pcm.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
450450
codec_dai->active--;
451451
codec->active--;
452452

453-
/* clear the corresponding DAIs rate when inactive */
454-
if (!cpu_dai->active) {
455-
cpu_dai->rate = 0;
456-
cpu_dai->channels = 0;
457-
cpu_dai->sample_bits = 0;
458-
}
459-
460-
if (!codec_dai->active) {
461-
codec_dai->rate = 0;
462-
codec_dai->channels = 0;
463-
codec_dai->sample_bits = 0;
464-
}
465-
466453
/* Muting the DAC suppresses artifacts caused during digital
467454
* shutdown, for example from stopping clocks.
468455
*/
@@ -682,6 +669,19 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
682669

683670
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
684671

672+
/* clear the corresponding DAIs parameters when going to be inactive */
673+
if (cpu_dai->active == 1) {
674+
cpu_dai->rate = 0;
675+
cpu_dai->channels = 0;
676+
cpu_dai->sample_bits = 0;
677+
}
678+
679+
if (codec_dai->active == 1) {
680+
codec_dai->rate = 0;
681+
codec_dai->channels = 0;
682+
codec_dai->sample_bits = 0;
683+
}
684+
685685
/* apply codec digital mute */
686686
if (!codec->active)
687687
snd_soc_dai_digital_mute(codec_dai, 1, substream->stream);

0 commit comments

Comments
 (0)