From aecb827dc96189efebf2d01a175caf46453e17d2 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 04:46:48 +0800 Subject: [PATCH 1/2] ASoC: cs42l75: Record from all four microphones As iOS records a video: mic bias 1-4, ADC1-4 powered with iOS's ADC2-4 setup, the four ADCs in ASP2 TX channels 0-3 (24-bit at clocks 0, 24, 48 and 72 of the 96-clock frame). A mono capture still takes the main microphone, ADC1 in slot 0. Assisted-by: LLM Signed-off-by: Henrik Klee --- sound/soc/codecs/cs42l75.c | 53 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/cs42l75.c b/sound/soc/codecs/cs42l75.c index b3c8c43112f043..6f24a89cef00d5 100644 --- a/sound/soc/codecs/cs42l75.c +++ b/sound/soc/codecs/cs42l75.c @@ -577,10 +577,13 @@ static int cs42l75_clp_boot(struct cs42l75 *cs) } /* - * Recording from the main microphone (imic, on ADC1), as iOS records a - * voice memo: 48 kHz on ASP2, the codec providing its clocks, the samples - * 24-bit in slot 0 of a 96-clock frame, which the SoC's MCA takes on - * switch port 4. + * Recording from the four microphones, each on its own ADC, as iOS records + * a video: 48 kHz on ASP2, the codec providing its clocks, the samples + * 24-bit in slots 0-3 (ADC1-4) of a 96-clock frame, which the SoC's MCA + * takes on switch port 4. On the iPhone XR: ADC1 the main microphone + * (bottom, left of the connector), ADC2 the rear one by the camera, ADC3 + * the front one at the earpiece, ADC4 the one by the loudspeaker. A voice + * memo uses only the main microphone, ADC1 in slot 0. */ struct cs42l75_reg { u32 reg; @@ -589,6 +592,12 @@ struct cs42l75_reg { /* What iOS has in the ADC and filter pages while it records (gain, HPF) */ static const struct cs42l75_reg cs42l75_record_regs[] = { + /* ADC2-4, as iOS sets them up for a video */ + { 0x030004, 0xf0 }, + { 0x030019, 0x03 }, + { 0x030023, 0x03 }, + { 0x030027, 0x10 }, + { 0x030049, 0x1f }, { 0x140002, 0x3c }, { 0x140004, 0x70 }, { 0x140005, 0x3c }, @@ -637,12 +646,12 @@ static int cs42l75_micbias_event(struct snd_soc_dapm_widget *w, struct cs42l75 *cs = cs42l75_from_widget(w); if (SND_SOC_DAPM_EVENT_ON(event)) { - int ret = cs42l75_update(cs, 0x01000a, 0x03, 0x02); /* bias 1 */ + int ret = cs42l75_write(cs, 0x01000a, 0xaa); /* bias 1-4 */ usleep_range(10000, 11000); return ret; } - return cs42l75_update(cs, 0x01000a, 0x03, 0x00); + return cs42l75_write(cs, 0x01000a, 0x00); } static int cs42l75_adc_event(struct snd_soc_dapm_widget *w, @@ -652,13 +661,13 @@ static int cs42l75_adc_event(struct snd_soc_dapm_widget *w, int i, ret; if (!SND_SOC_DAPM_EVENT_ON(event)) - return cs42l75_update(cs, 0x010003, 0x01, 0x01); /* ADC1 down */ + return cs42l75_update(cs, 0x010003, 0x0f, 0x0f); /* ADC1-4 down */ for (i = 0; i < ARRAY_SIZE(cs42l75_record_regs); i++) { ret = cs42l75_write(cs, cs42l75_record_regs[i].reg, cs42l75_record_regs[i].val); if (ret) return ret; } - return cs42l75_update(cs, 0x010003, 0x01, 0x00); /* ADC1 up */ + return cs42l75_update(cs, 0x010003, 0x0f, 0x00); /* ADC1-4 up */ } static int cs42l75_asp2_event(struct snd_soc_dapm_widget *w, @@ -668,34 +677,38 @@ static int cs42l75_asp2_event(struct snd_soc_dapm_widget *w, struct cs42l75 *cs = cs42l75_from_widget(w); int i, ret = 0; - if (!SND_SOC_DAPM_EVENT_ON(event)) - return cs42l75_write(cs, 0x32000a, 0x00) ?: - cs42l75_update(cs, 0x010009, 0x08, 0x00); + if (!SND_SOC_DAPM_EVENT_ON(event)) { + for (i = 0; !ret && i < 4; i++) + ret = cs42l75_write(cs, 0x32000a + i, 0x00); + return ret ?: cs42l75_update(cs, 0x010009, 0x08, 0x00); + } /* ASP2: N/M 0x30/0x7d of 12 MHz, 96 clocks a frame, the codec master */ for (i = 0; !ret && i < ARRAY_SIZE(setup); i++) ret = cs42l75_write(cs, 0x020007 + i, setup[i]); + /* TX ch0-3 at clocks 0, 24, 48, 72, 24-bit, from ADC1-4 */ + for (i = 0; !ret && i < 4; i++) + ret = cs42l75_write(cs, 0x420000 + i, 24 * i) ?: + cs42l75_write(cs, 0x42000a + i, 0x06) ?: + cs42l75_write(cs, 0x32000a + i, 0x04 + i); return ret ?: - cs42l75_write(cs, 0x420000, 0x00) ?: /* TX ch0 at clock 0 */ - cs42l75_write(cs, 0x42000a, 0x06) ?: /* 24-bit, enabled */ - cs42l75_write(cs, 0x32000a, 0x04) ?: /* <- ADC1 (imic) */ cs42l75_update(cs, 0x420014, 0x04, 0x04) ?: cs42l75_update(cs, 0x010009, 0x08, 0x08); /* ASP2 data out */ } static const struct snd_soc_dapm_widget cs42l75_widgets[] = { - SND_SOC_DAPM_INPUT("IMIC"), - SND_SOC_DAPM_SUPPLY("MICBIAS1", SND_SOC_NOPM, 0, 0, cs42l75_micbias_event, + SND_SOC_DAPM_INPUT("MICS"), + SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, cs42l75_micbias_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("ADC1", NULL, SND_SOC_NOPM, 0, 0, cs42l75_adc_event, + SND_SOC_DAPM_ADC_E("ADCS", NULL, SND_SOC_NOPM, 0, 0, cs42l75_adc_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_AIF_OUT_E("ASP2 TX", "Capture", 0, SND_SOC_NOPM, 0, 0, cs42l75_asp2_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route cs42l75_routes[] = { - { "ADC1", NULL, "IMIC" }, - { "ADC1", NULL, "MICBIAS1" }, - { "ASP2 TX", NULL, "ADC1" }, + { "ADCS", NULL, "MICS" }, + { "ADCS", NULL, "MICBIAS" }, + { "ASP2 TX", NULL, "ADCS" }, }; static const struct snd_soc_component_driver cs42l75_component = { From 753e0c96d46ee079241eb76423c6a45dde8f135d Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 04:46:48 +0800 Subject: [PATCH 2/2] arm64: dts: apple: t8020-n841: Record all four microphones The card takes slots 0-3 of the codec's ASP2, one microphone each; a capture of fewer channels takes the first slots, so mono stays the main microphone. Assisted-by: LLM Signed-off-by: Henrik Klee --- arch/arm64/boot/dts/apple/t8020-n841.dts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8020-n841.dts b/arch/arm64/boot/dts/apple/t8020-n841.dts index 6af848c46c2352..b7cb6cda3e0643 100644 --- a/arch/arm64/boot/dts/apple/t8020-n841.dts +++ b/arch/arm64/boot/dts/apple/t8020-n841.dts @@ -168,8 +168,10 @@ }; /* - * The main microphone, as iOS records: the codec's ASP2 on switch - * port 4 into cluster 1, 24-bit in slot 0 of a 96-clock frame. + * The microphones, as iOS records: the codec's ASP2 on switch + * port 4 into cluster 1, 24-bit in slots 0-3 (ADC1-4) of a 96-clock + * frame: 0 main (bottom left), 1 rear (camera), 2 front (earpiece), + * 3 by the loudspeaker; a mono capture takes the main microphone. */ mic { apple,bclk-ratio = <96>; @@ -178,7 +180,7 @@ cpu { sound-dai = <&mca 7>, <&mca 4>; - dai-tdm-slot-rx-mask = <1 0 0 0>; + dai-tdm-slot-rx-mask = <1 1 1 1>; }; codec {