[PATCH] ASoC: apple: mca: Fix clock selection for clock consumer FEs
From: Janne Grunau
Date: Tue Nov 10 2026 - 11:52:33 EST
In commit 00309bfb1f54 ("ASoC: apple: mca: Support FEs being clock
consumers") the syncgen clock selection was misunderstood resulting in
selecting a random clock. In the capture on multiple BEs for IV sense
data use case the configuration worked partially by sheer luck. On
Macbook Pro's with 6 speakers it could result in desync IV sense data
triggered likely by sample rate changes.
When the FE is a clock consumer select the clock of first used BE as
SYNCGEN_MCLK.
Add function like macros to determine the clock index based on the FE or
BE number.
This is functionally equivalent to the state sent in v2 of "ASoC: apple:
mca: support simultaneous I2S capture on the frontend" in [1].
Link: https://lore.kernel.org/all/20260628-apple-audio-redux-v2-4-6328269c9652@xxxxxxxxx/ [1]
Fixes: 00309bfb1f54 ("ASoC: apple: mca: Support FEs being clock consumers")
Fixes: 108a14b20f95 ("ASoC: apple: mca: Support capture on multiples BEs")
Signed-off-by: Janne Grunau <j@xxxxxxxxxx>
---
sound/soc/apple/mca.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 26022a42a95e..5e644b596854 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -53,6 +53,8 @@
#define SYNCGEN_STATUS_EN BIT(0)
#define REG_SYNCGEN_MCLK_SEL 0x104
#define SYNCGEN_MCLK_SEL GENMASK(3, 0)
+#define SYNCGEN_MCLK_FE_CLK(n) ((n) + 1)
+#define SYNCGEN_MCLK_BE_CLK(n) ((n) + 7)
#define REG_SYNCGEN_HI_PERIOD 0x108
#define REG_SYNCGEN_LO_PERIOD 0x10c
@@ -313,7 +315,8 @@ static int mca_fe_enable_clocks(struct mca_cluster *cl)
return -EINVAL;
}
- writel_relaxed(cl->no + 1, cl->base + REG_SYNCGEN_MCLK_SEL);
+ writel_relaxed(SYNCGEN_MCLK_FE_CLK(cl->no),
+ cl->base + REG_SYNCGEN_MCLK_SEL);
mca_modify(cl, REG_SYNCGEN_STATUS, SYNCGEN_STATUS_EN,
SYNCGEN_STATUS_EN);
mca_modify(cl, REG_STATUS, STATUS_MCLK_EN, STATUS_MCLK_EN);
@@ -390,7 +393,7 @@ static int mca_fe_prepare(struct snd_pcm_substream *substream,
/* Turn on the cluster power domain if not already in use */
if (!cl->syncgen_in_use) {
- int port = ffs(mca_fe_get_portmask(substream));
+ int port = ffs(mca_fe_get_portmask(substream)) - 1;
cl->pd_link = device_link_add(mca->dev, cl->pd_dev,
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
@@ -401,7 +404,8 @@ static int mca_fe_prepare(struct snd_pcm_substream *substream,
return -EINVAL;
}
- mca_modify(cl, REG_SYNCGEN_MCLK_SEL, SYNCGEN_MCLK_SEL, BIT(port));
+ mca_modify(cl, REG_SYNCGEN_MCLK_SEL, SYNCGEN_MCLK_SEL,
+ SYNCGEN_MCLK_BE_CLK(port));
mca_modify(cl, REG_SYNCGEN_STATUS, SYNCGEN_STATUS_EN,
SYNCGEN_STATUS_EN);
}
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261110-snd-soc-apple-mca-capture-multiple-be-834365f52db3
Best regards,
--
Janne Grunau <j@xxxxxxxxxx>