Skip to content

Commit

Permalink
ASoC: soc-pcm: check symmetry after hw_params
Browse files Browse the repository at this point in the history
hw_params may be fixup by be_hw_params_fixup, calling
soc_pcm_params_symmetry() before hw_params will have issue
if there is hw_params changes in be_hw_params_fixup.

For example, with following use case
1. a dai-link which is able to convert sample rate on BE side
2. set BE playback and capture sample rate to 44100Hz
3. play a 48000Hz audio stream with this dai-link
4. record from this dai-link with 44100Hz sample rate

Got following error message when record starts
[  495.013527]  be_link_ak4613: ASoC: unmatched rate symmetry: 48000 - 44100
[  495.021729]  be_link_ak4613: ASoC: hw_params BE failed -22
[  495.028589]  rsnd_link0: ASoC: hw_params BE failed -22

Because in soc_pcm_hw_params(), FE rate is still having value before
it is fixup by be_hw_params_fixup(), when soc_pcm_params_symmetry() checks
symmetry, thus soc_pcm_params_symmetry() complains about the unmatched rate
between the active stream and the new stream tries to start.

This patch moves soc_pcm_params_symmetry() after hw_params to resolve the
above issue.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
jiada wang authored and Mark Brown committed Sep 20, 2017
1 parent 2bd6bf0 commit 957ce0c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
int i, ret = 0;

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

ret = soc_pcm_params_symmetry(substream, params);
if (ret)
goto out;

if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) {
ret = rtd->dai_link->ops->hw_params(substream, params);
if (ret < 0) {
Expand Down Expand Up @@ -930,6 +925,10 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
cpu_dai->sample_bits =
snd_pcm_format_physical_width(params_format(params));


ret = soc_pcm_params_symmetry(substream, params);
if (ret)
goto platform_err;
out:
mutex_unlock(&rtd->pcm_mutex);
return ret;
Expand Down

0 comments on commit 957ce0c

Please sign in to comment.