ASoC: rsnd: core: Check convert rate in rsnd_hw_params
authorMikhail Durnev <mikhail_durnev@mentor.com>
Tue, 16 Mar 2021 04:47:35 +0000 (14:47 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:12:52 +0000 (10:12 +0200)
commit879a96d817ed7268712ed65e6551ed4654d86ce8
tree9c1a5724c8866ef2f6436cc2a4813418913e7ee9
parenta2aeb5de26c1800e530b29e9a157c92c5a827293
ASoC: rsnd: core: Check convert rate in rsnd_hw_params

[ Upstream commit 19c6a63ced5e07e40f3a5255cb1f0fe0d3be7b14 ]

snd_pcm_hw_params_set_rate_near can return incorrect sample rate in
some cases, e.g. when the backend output rate is set to some value higher
than 48000 Hz and the input rate is 8000 Hz. So passing the value returned
by snd_pcm_hw_params_set_rate_near to snd_pcm_hw_params will result in
"FSO/FSI ratio error" and playing no audio at all while the userland
is not properly notified about the issue.

If SRC is unable to convert the requested sample rate to the sample rate
the backend is using, then the requested sample rate should be adjusted in
rsnd_hw_params. The userland will be notified about that change in the
returned hw_params structure.

Signed-off-by: Mikhail Durnev <mikhail_durnev@mentor.com>
Link: https://lore.kernel.org/r/1615870055-13954-1-git-send-email-mikhail_durnev@mentor.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/sh/rcar/core.c