From 037ed99798d9ebf9b99b45552715f7b57e56c1d8 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 06:35:34 +0800 Subject: [PATCH 1/2] ASoC: cs42l75: Start again when the CLP does not boot, record 16-bit On the iPhone XR the speaker protection DSP often does not boot on the first start (state 08), at boot as on a reload; a reset and another start of the codec bring it up, so retry the whole start up to three times. The codec sends 24-bit samples, but the A12's MCA receives only their top 16 bits correctly so far: 24 and 32-bit captures came out as garbage. Offer 16-bit capture only, which records cleanly. Assisted-by: LLM Signed-off-by: Henrik Klee --- sound/soc/codecs/cs42l75.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/cs42l75.c b/sound/soc/codecs/cs42l75.c index 6f24a89cef00d5..8d77fb007569b5 100644 --- a/sound/soc/codecs/cs42l75.c +++ b/sound/soc/codecs/cs42l75.c @@ -725,7 +725,11 @@ static struct snd_soc_dai_driver cs42l75_dai = { .channels_min = 1, .channels_max = 4, .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + /* + * The codec sends 24 bits; the A12's MCA receives only their top 16 + * correctly so far (24 and 32-bit captures came out as garbage). + */ + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, }; @@ -760,23 +764,28 @@ static int cs42l75_probe(struct spi_device *spi) * The speaker path runs through the CLP, which drives ASP1, the * amplifiers' bus; it takes its firmware once the codec runs on MCLK * with its power up. Right after boot the codec has been seen to lose - * the bus as it leaves its oscillator for MCLK; a reset and a second - * start bring it up. + * the bus as it leaves its oscillator for MCLK, and the CLP not to + * boot (state 08) when the codec starts right after the AOP, whose + * MCLK2 it needs: a reset and another start bring both up. */ for (try = 0; try < 3; try++) { + if (try) + msleep(200); ret = cs42l75_wake(cs); if (ret) return dev_err_probe(dev, ret, "no CS42L75\n"); ret = cs42l75_run(cs, cs42l75_power_ops, ARRAY_SIZE(cs42l75_power_ops)); - if (!ret) + if (ret) { + dev_dbg(dev, "codec start failed (%d), starting again\n", ret); + continue; + } + ret = cs42l75_clp_boot(cs); + if (ret != -ETIMEDOUT) break; - msleep(50); + dev_info(dev, "CLP did not boot, starting the codec again\n"); } if (ret) - return dev_err_probe(dev, ret, "codec start\n"); - ret = cs42l75_clp_boot(cs); - if (ret) - return dev_err_probe(dev, ret, "CLP (%s)\n", CLP_FW_NAME); + return dev_err_probe(dev, ret, "codec start (%s)\n", CLP_FW_NAME); ret = cs42l75_run(cs, cs42l75_speaker_ops, ARRAY_SIZE(cs42l75_speaker_ops)); if (ret) return dev_err_probe(dev, ret, "speaker path\n"); From fa7db3ba5fa5fa2bb894b67e3fca0b5c1e84bbeb Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 06:35:34 +0800 Subject: [PATCH 2/2] ASoC: apple: t8020-speakers: Offer only the codecs' sample formats The MCA front end offers 16, 24 and 32-bit samples, the amplifiers take 16 and 24 bits and the codec records 16: PipeWire opened the speakers at 32 bits and the amplifier refused them (-EINVAL). Merge the back ends' formats into the front ends'. Assisted-by: LLM Signed-off-by: Henrik Klee --- sound/soc/apple/t8020-speakers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/apple/t8020-speakers.c b/sound/soc/apple/t8020-speakers.c index dbd1f43be04ada..21a013de6d2ab0 100644 --- a/sound/soc/apple/t8020-speakers.c +++ b/sound/soc/apple/t8020-speakers.c @@ -204,6 +204,8 @@ static int t8020_mic_links(struct device *dev, struct t8020_speakers *sp) fe->init = t8020_mic_fe_init; fe->ops = &t8020_speakers_fe_ops; fe->trigger[1] = SND_SOC_DPCM_TRIGGER_POST; + /* offer only the sample formats the codec sends (24 bits in 32) */ + fe->dpcm_merged_format = 1; be->name = "Microphone Codec"; be->cpus = &mic->be_cpu; @@ -318,6 +320,8 @@ static int t8020_speakers_probe(struct platform_device *pdev) fe->init = t8020_speakers_fe_init; fe->ops = &t8020_speakers_fe_ops; fe->trigger[0] = SND_SOC_DPCM_TRIGGER_POST; + /* offer only the sample formats the amplifiers take (16 and 24 bits) */ + fe->dpcm_merged_format = 1; be = &sp->links[1]; be->name = "Speaker Amplifiers";