From acdfc4c15316937e3e0053396bd7ec604448882a Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 17 Nov 2026 00:30:54 +0000 Subject: [PATCH 1/3] ASoC: apple: mca: sample J613 speaker sense on the opposite BCLK edge On J613 the inverted I2S link selects rising-edge SDOUT launch on the TAS2764-class speaker amplifiers. The nominal MCA receive polarity puts speaker V/I sense sampling at that launch boundary, corrupting raw signed samples and preventing speakersafetyd from protecting normal playback. Invert RX polarity only for cluster 2 on apple,j613, retaining the one-bit I2S offset and the existing TX polarity. Hardware capture comparisons show that this opposite-edge window restores quiet samples and isolated bipolar per-amplifier tones without sample masking or gain conversion. Playback sampling and all other boards retain their existing configuration. The same change on a 30.14-based J613 kernel passes protected playback, stop-to-floor and suspend/resume through a fail-closed daemon warm restart. The rebased commit is arm64 compile-tested separately. No timing-chain regression commit has been established, so omit a Fixes tag. Signed-off-by: Satya Benson --- sound/soc/apple/mca.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c index 9dfb329f46201..1b9ddcb93698b 100644 --- a/sound/soc/apple/mca.c +++ b/sound/soc/apple/mca.c @@ -594,6 +594,9 @@ static int mca_fe_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) mca_modify(cl, CLUSTER_TX_OFF + REG_TX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); + /* J613 sense SDOUT is launched on the rising edge, not sampled there. */ + if (of_machine_is_compatible("apple,j613") && cl->no == 2) + serdes_conf ^= SERDES_CONF_BCLK_POL; mca_modify(cl, CLUSTER_RX_OFF + REG_RX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); writel_relaxed(bitstart, From 3022449fad53e6e23c3f3e66e67f7a95109f4901 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Thu, 19 Nov 2026 06:32:00 -0500 Subject: [PATCH 2/3] dt-bindings: sound: apple,mca: describe RX BCLK inversion Describe which MCA receive clusters sample on the opposite bit clock edge from the DAI format. The transmit polarity stays as configured. Signed-off-by: Satya Benson Co-Authored-By: Claude Fable 5.2 --- .../devicetree/bindings/sound/apple,mca.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/apple,mca.yaml b/Documentation/devicetree/bindings/sound/apple,mca.yaml index 2d6300c12831d..06094f3ac063b 100644 --- a/Documentation/devicetree/bindings/sound/apple,mca.yaml +++ b/Documentation/devicetree/bindings/sound/apple,mca.yaml @@ -110,6 +110,17 @@ properties: '#sound-dai-cells': const: 1 + apple,rx-bclk-inverted-clusters: + description: + Indices of clusters whose receive serializers sample on the opposite + bit clock edge to the one selected by the DAI format. The transmit + serializers keep the edge specified by the DAI format. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 6 + items: + maximum: 5 + required: - compatible - reg From 062f321c2f4c6e9d5cfeb7e6d9a6e2ae89ac69a0 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Thu, 19 Nov 2026 06:32:00 -0500 Subject: [PATCH 3/3] ASoC: apple: mca: read the receive BCLK edge from the device tree Read the MCA clusters whose receive serializers use the opposite BCLK edge from the DAI format. The J613 speaker sense frontend still uses cluster 2 with inverted receive polarity, while the transmit edge and DAI format remain the same. Signed-off-by: Satya Benson Co-Authored-By: Claude Fable 5.2 --- arch/arm64/boot/dts/apple/t8122-j613.dts | 5 +++++ sound/soc/apple/mca.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8122-j613.dts b/arch/arm64/boot/dts/apple/t8122-j613.dts index 1c503729a3101..d2326056944d9 100644 --- a/arch/arm64/boot/dts/apple/t8122-j613.dts +++ b/arch/arm64/boot/dts/apple/t8122-j613.dts @@ -390,6 +390,11 @@ }; }; +&mca { + /* Speaker-sense SDOUT is launched on the nominal RX sample edge. */ + apple,rx-bclk-inverted-clusters = <2>; +}; + / { sound { compatible = "apple,j613-macaudio", "apple,j413-macaudio", "apple,macaudio"; diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c index 1b9ddcb93698b..74f6f61f7ee03 100644 --- a/sound/soc/apple/mca.c +++ b/sound/soc/apple/mca.c @@ -140,6 +140,7 @@ struct mca_cluster { struct dma_chan *dma_chans[SNDRV_PCM_STREAM_LAST + 1]; bool clk_provider; + bool rx_bclk_inverted; bool port_clk_started[SNDRV_PCM_STREAM_LAST + 1]; int port_clk_driver; /* The cluster driving this cluster's port */ @@ -594,8 +595,7 @@ static int mca_fe_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) mca_modify(cl, CLUSTER_TX_OFF + REG_TX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); - /* J613 sense SDOUT is launched on the rising edge, not sampled there. */ - if (of_machine_is_compatible("apple,j613") && cl->no == 2) + if (cl->rx_bclk_inverted) serdes_conf ^= SERDES_CONF_BCLK_POL; mca_modify(cl, CLUSTER_RX_OFF + REG_RX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); @@ -1310,6 +1310,7 @@ static int apple_mca_probe(struct platform_device *pdev) struct snd_soc_dai_driver *dai_drivers; struct resource *res; void __iomem *base; + u32 rx_bclk_cluster; int nclusters; int ret, i; @@ -1331,6 +1332,14 @@ static int apple_mca_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mca); clusters = mca->clusters; + of_property_for_each_u32(pdev->dev.of_node, "apple,rx-bclk-inverted-clusters", + rx_bclk_cluster) { + if (rx_bclk_cluster >= nclusters) + return dev_err_probe(&pdev->dev, -EINVAL, + "invalid RX BCLK cluster %u\n", rx_bclk_cluster); + clusters[rx_bclk_cluster].rx_bclk_inverted = true; + } + mca->switch_base = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(mca->switch_base))