From: James Calligeros <jcalligeros99@gmail.com>
To: "David Rhodes" <david.rhodes@cirrus.com>,
"Richard Fitzgerald" <rf@opensource.cirrus.com>,
"Martin Povišer" <povik+lin@cutebit.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>
Cc: asahi@lists.linux.dev, linux-sound@vger.kernel.org,
patches@opensource.cirrus.com, linux-kernel@vger.kernel.org,
James Calligeros <jcalligeros99@gmail.com>
Subject: [PATCH v2] ASoC: codecs: cs42l84: set up PLL for more sample rates
Date: Sat, 14 Mar 2026 10:27:11 +1000 [thread overview]
Message-ID: <20260314-cs42l84-rates-v2-1-ea8a5af52542@gmail.com> (raw)
Previously, this driver only advertised support for 48 kHz and
96 kHz sample rates, as there was no PLL configuration data
specified for any other sample rate/BCLK.
The CS42L84 is an Apple-specific variant of CS42L42. The PLL
configuration parameters for a variety of common BCLKs are
available in the latter's datasheet. What happens if we just
use those? As it turns out, they work just fine.
Fill out more PLL config parameters in the PLL config lookup
table, and advertise the corresponding sample rates to userspace.
This enables 44.1, 88.2, 176.4 and 192 kHz output and input.
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
Changes in v2:
- Added explicit handling of new MCLK values to MCLK_F config
- Added comment explaining the MCLK_F config process
- Link to v1: https://lore.kernel.org/r/20260307-cs42l84-rates-v1-1-1c55a5673031@gmail.com
---
sound/soc/codecs/cs42l84.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/cs42l84.c b/sound/soc/codecs/cs42l84.c
index 1e1307a16f81..e590a43559e4 100644
--- a/sound/soc/codecs/cs42l84.c
+++ b/sound/soc/codecs/cs42l84.c
@@ -357,8 +357,11 @@ struct cs42l84_pll_params {
* Common PLL Settings for given BCLK
*/
static const struct cs42l84_pll_params pll_ratio_table[] = {
+ { 2822400, 1, 0, 0x40, 0x000000, 0x03, 0x10, 11289600},
{ 3072000, 1, 0, 0x40, 0x000000, 0x03, 0x10, 12288000},
+ { 5644800, 1, 0, 0x40, 0x000000, 0x03, 0x10, 11289600},
{ 6144000, 1, 1, 0x40, 0x000000, 0x03, 0x10, 12288000},
+ { 11289600, 0, 0, 0, 0, 0, 0, 11289600},
{ 12288000, 0, 0, 0, 0, 0, 0, 12288000},
{ 24576000, 1, 3, 0x40, 0x000000, 0x03, 0x10, 12288000},
};
@@ -408,11 +411,18 @@ static int cs42l84_pll_config(struct snd_soc_component *component)
CS42L84_ASP_FSYNC_CTL3_BCLK_PERIOD_HI,
FIELD_PREP(CS42L84_ASP_FSYNC_CTL3_BCLK_PERIOD_HI, fsync >> 7));
- /* Save what the MCLK will be */
+ /*
+ * MCLK values are binned into 12 or 24 MHz regions. If MCLK is exactly
+ * 12 or 24 MHz, the high bit of CCM_CTL1_MCLK_F is set. If MCLK
+ * is in the region of 24 MHz, the low bit is set. This seemingly
+ * corresponds to CS42L42's documented INTERNAL_FS and MCLKDIV
+ * behaviour respectively.
+ */
switch (pll_ratio_table[i].mclk_int) {
case 12000000:
cs42l84->pll_mclk_f = CS42L84_CCM_CTL1_MCLK_F_12MHZ;
break;
+ case 11289600:
case 12288000:
cs42l84->pll_mclk_f = CS42L84_CCM_CTL1_MCLK_F_12_288KHZ;
break;
@@ -670,14 +680,18 @@ static struct snd_soc_dai_driver cs42l84_dai = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 2,
- .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000,
+ .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+ SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
+ SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
.formats = CS42L84_FORMATS,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 1,
- .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000,
+ .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+ SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
+ SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
.formats = CS42L84_FORMATS,
},
.symmetric_rate = 1,
---
base-commit: c40816209b5768d45aabb81f9c6ff8296ec58c32
change-id: 20260307-cs42l84-rates-c9e23e20209d
Best regards,
--
James Calligeros <jcalligeros99@gmail.com>
next reply other threads:[~2026-03-14 0:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 0:27 James Calligeros [this message]
2026-03-17 18:16 ` Mark Brown
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=20260314-cs42l84-rates-v2-1-ea8a5af52542@gmail.com \
--to=jcalligeros99@gmail.com \
--cc=asahi@lists.linux.dev \
--cc=broonie@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=povik+lin@cutebit.org \
--cc=rf@opensource.cirrus.com \
--cc=tiwai@suse.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
all inboxes | Powered by JetHome®