From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: "Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Zhu Ning" <zhuning0077@gmail.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
"Charles Keepax" <ckeepax@opensource.cirrus.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"David Yang" <yangxiaohua@everest-semi.com>,
"Daniel Drake" <drake@endlessm.com>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
alsa-devel@alsa-project.org, kernel@collabora.com
Subject: [PATCH 2/3] ASoC: es8316: Do not set rate constraints for unsupported MCLKs
Date: Wed, 24 May 2023 10:41:55 +0300 [thread overview]
Message-ID: <20230524074156.147387-3-cristian.ciocaltea@collabora.com> (raw)
In-Reply-To: <20230524074156.147387-1-cristian.ciocaltea@collabora.com>
When using the codec through the generic audio graph card, there are at
least two calls of es8316_set_dai_sysclk(), with the effect of limiting
the allowed sample rates according to the MCLK/LRCK ratios supported by
the codec:
1. During audio card setup, to set the initial MCLK - see
asoc_simple_init_dai().
2. Before opening a stream, to update MCLK, according to the stream
sample rate and the multiplication factor - see
asoc_simple_hw_params().
In some cases the initial MCLK might be set to a frequency that doesn't
match any of the supported ratios, e.g. 12287999 instead of 12288000,
which is only 1 Hz below the supported clock, as that is what the
hardware reports. This creates an empty list of rate constraints, which
is further passed to snd_pcm_hw_constraint_list() via
es8316_pcm_startup(), and causes the following error on the very first
access of the sound card:
$ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
Note that all subsequent retries succeed thanks to the updated MCLK set
at point 2 above, which uses a computed frequency value instead of a
reading from the hardware registers. Normally this would have mitigated
the issue, but es8316_pcm_startup() executes before the 2nd call to
es8316_set_dai_sysclk(), hence it cannot make use of the updated
constraints.
Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
against the stream sample rate and the supported MCLK/LRCK ratios, fix
the issue by ensuring that sysclk_constraints list is only set when at
least one supported sample rate is autodetected by the codec.
Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
sound/soc/codecs/es8316.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index 773c94fd3547..a78c0049a30c 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -386,7 +386,7 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
es8316->allowed_rates[count++] = freq / ratio;
}
- es8316->sysclk_constraints.list = es8316->allowed_rates;
+ es8316->sysclk_constraints.list = count ? es8316->allowed_rates : NULL;
es8316->sysclk_constraints.count = count;
return 0;
--
2.40.1
next prev parent reply other threads:[~2023-05-24 7:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 7:41 [PATCH 0/3] ES8316 audio codec fixes on Rock5B Cristian Ciocaltea
2023-05-24 7:41 ` [PATCH 1/3] ASoC: es8316: Increment max value for ALC Capture Target Volume control Cristian Ciocaltea
2023-05-24 10:30 ` Mark Brown
2023-05-24 13:49 ` Cristian Ciocaltea
2023-05-24 13:59 ` Mark Brown
2023-05-26 18:11 ` Cristian Ciocaltea
2023-05-30 11:36 ` Mark Brown
2023-05-30 12:52 ` Cristian Ciocaltea
2023-05-30 12:55 ` Mark Brown
2023-05-24 7:41 ` Cristian Ciocaltea [this message]
2023-05-24 10:36 ` [PATCH 2/3] ASoC: es8316: Do not set rate constraints for unsupported MCLKs Mark Brown
2023-05-24 7:41 ` [PATCH 3/3] arm64: dts: rockchip: Assign ES8316 MCLK rate on rk3588-rock-5b Cristian Ciocaltea
2023-05-24 10:39 ` Mark Brown
2023-05-24 14:21 ` Cristian Ciocaltea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230524074156.147387-3-cristian.ciocaltea@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=drake@endlessm.com \
--cc=heiko@sntech.de \
--cc=kernel@collabora.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=yangxiaohua@everest-semi.com \
--cc=zhuning0077@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).