diff --git a/Documentation/devicetree/bindings/sound/apple,macaudio.yaml b/Documentation/devicetree/bindings/sound/apple,macaudio.yaml index 37956f0a3a343..20cf622f3ed1f 100644 --- a/Documentation/devicetree/bindings/sound/apple,macaudio.yaml +++ b/Documentation/devicetree/bindings/sound/apple,macaudio.yaml @@ -52,6 +52,7 @@ properties: - apple,j715-macaudio-jack - apple,j773-macaudio - apple,j773-macaudio-jack + - apple,j773g-macaudio - apple,j813-macaudio - apple,j815-macaudio - apple,j873-macaudio diff --git a/Documentation/devicetree/bindings/sound/apple,t6041-aop-audio.yaml b/Documentation/devicetree/bindings/sound/apple,t6041-aop-audio.yaml index 8c0b1928ef207..292a66f15c297 100644 --- a/Documentation/devicetree/bindings/sound/apple,t6041-aop-audio.yaml +++ b/Documentation/devicetree/bindings/sound/apple,t6041-aop-audio.yaml @@ -70,6 +70,13 @@ properties: - const: sense - const: cout - const: cin + - description: + The speakers without V/I sense and the headset jack, on a Mac without + microphones + items: + - const: spkr + - const: cout + - const: cin - description: The microphones and the headset jack items: - const: dma diff --git a/arch/arm64/boot/dts/apple/t8132-j773g.dts b/arch/arm64/boot/dts/apple/t8132-j773g.dts index baf3e3ffcfecb..8d8278c299f87 100644 --- a/arch/arm64/boot/dts/apple/t8132-j773g.dts +++ b/arch/arm64/boot/dts/apple/t8132-j773g.dts @@ -32,6 +32,55 @@ gpios = <&pinctrl_ap 15 GPIO_ACTIVE_HIGH>; enable-active-high; }; + + /* + * The speaker: the AOP audio component's speaker back-end (DAI 3) to + * the SN012776. Its playback waits for a protection lease (macaudio). + */ + sound: sound { + compatible = "apple,j773g-macaudio", "apple,macaudio"; + model = "Mac mini J773g"; + #address-cells = <1>; + #size-cells = <0>; + + dai-link@0 { + reg = <0>; + link-name = "Speaker"; + + cpu { + sound-dai = <&aop_audio 3>; + }; + + codec { + sound-dai = <&speaker>; + }; + }; + }; + + /* + * The headphone jack: the AOP audio component's jack back-end (DAI 4) + * to the CS42L84 (ADT /arm-io/i2c1/audio-codec-output), a card of its + * own as on the M4 Pro Mac mini. + */ + sound_jack: sound-jack { + compatible = "apple,j773-macaudio-jack", "apple,macaudio"; + model = "Mac mini J773g Jack"; + #address-cells = <1>; + #size-cells = <0>; + + dai-link@0 { + reg = <0>; + link-name = "Headphone Jack"; + + cpu { + sound-dai = <&aop_audio 4>; + }; + + codec { + sound-dai = <&jack_codec>; + }; + }; + }; }; /* @@ -53,17 +102,24 @@ }; /* - * The AOP audio component always runs a microphone stream, and this Mac - * has no microphones (ADT iop-audio-controller has no audio-hp) and no - * speaker sense, so it has no sound card yet. The AOP registers its audio - * service by itself: without the node, no driver binds it. + * No microphones (ADT iop-audio-controller has no audio-hp): the speaker's + * stream, "spkr" on base-ns ADMAC channel 0 (ADT audio-speaker, which lists + * no RX channel, so no "sense"), and the jack's, "cout" and "cin" on + * channels 4 and 5 (ADT audio-codec-output and audio-codec-input), as on the + * M4 Pro Mac mini. Without a "dma" channel the AOP audio component attaches + * no PDM device. */ -/delete-node/ &aop_audio; +&aop_audio { + dmas = <&admac1 0>, <&admac1 4>, <&admac1 5>; + dma-names = "spkr", "cout", "cin"; + apple,chassis-name = "J773g"; + apple,machine-kind = "Mac mini"; +}; /* * The SN012776 speaker amp (ADT /arm-io/i2c3/audio-speaker at 0x38, mono, - * speaker-protection 0): interrupt on AP GPIO 14, level low. Disabled - * until the speaker has a sound card and a protection profile. + * speaker-protection 0): interrupt on AP GPIO 14, level low, held in + * hardware shutdown until the sound card enables it. */ &i2c3 { status = "okay"; @@ -75,11 +131,10 @@ apple,sdz-group-fail-closed; apple,deferred-shutdown; #sound-dai-cells = <0>; - sound-name-prefix = "Speaker"; + /* No sound-name-prefix: a mono speaker's controls go unprefixed (macaudio). */ interrupts-extended = <&pinctrl_ap 14 IRQ_TYPE_LEVEL_LOW>; ti,imon-slot-no = <0>; ti,vmon-slot-no = <2>; - status = "disabled"; }; }; diff --git a/sound/soc/apple/aop_spkr.rs b/sound/soc/apple/aop_spkr.rs index b01158a65ccd1..73167327fb580 100644 --- a/sound/soc/apple/aop_spkr.rs +++ b/sound/soc/apple/aop_spkr.rs @@ -1679,7 +1679,13 @@ pub(crate) struct SpeakerComponent { impl SpeakerComponent { pub(crate) fn register(aop: Arc) -> Result { - let spkr = Service::new(aop.clone(), AUDIO_DEV_SPKR, "spkr", PWRD_OUTPUT, true)?; + // A Mac whose speaker stream has no sense channel (the Mac mini: its ADT + // audio-speaker stream lists no RX channel) runs the speakers without the ring. + let has_sense = aop + .fwnode + .property_match_string(c_str!("dma-names"), c_str!("sense")) + .is_ok(); + let spkr = Service::new(aop.clone(), AUDIO_DEV_SPKR, "spkr", PWRD_OUTPUT, has_sense)?; let cout = Service::new(aop.clone(), AUDIO_DEV_COUT, "cout", PWRD_OUTPUT, false)?; let cin = Service::new(aop.clone(), AUDIO_DEV_CIN, "cin", PWRD_INPUT, false)?; let services = [&spkr, &cout, &cin]; diff --git a/sound/soc/apple/macaudio.c b/sound/soc/apple/macaudio.c index 16488315b3995..14a1f882c783b 100644 --- a/sound/soc/apple/macaudio.c +++ b/sound/soc/apple/macaudio.c @@ -184,10 +184,15 @@ struct macaudio_platform_cfg { */ bool spk_secondary_only; /* - * No voltage or current sense reaches the AP, so no protection daemon - * can govern the speakers: their SN012776 volumes stay under safe_vol, - * locked, unlocked or granted alike, and there is no sense PCM. A - * granted lease runs them at safe_vol, its operating gain. + * Keep SN012776 speaker volumes capped at safe_vol even under a + * granted lease, and omit the sense PCM, for models without a + * full-scale protection model. Models without V/I sense that leave + * this false (e.g. J773g) run at 0 dB under a granted lease while a + * feed-forward protection daemon governs the signal path in software + * and renews the lease; if the daemon dies or stops renewing, + * spk_lease_timer closes the start gate, spk_stop_worker stops active + * streams, and spk_expire_work returns the amp to the muted floor (0) + * within the lease window. */ bool spk_fixed_ceiling; }; @@ -2674,9 +2679,6 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma) } } ma->has_speakers = 1; - if (ma->cfg->amp != AMP_SSM3515 && ma->cfg->safe_vol != 0 && - !ma->cfg->spk_fixed_ceiling) - ma->has_sense = 1; } cpu = of_get_child_by_name(np, "cpu"); @@ -2756,6 +2758,13 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma) link_props->is_speakers = speakers; link_props->is_headphones = !speakers; + if (speakers && ma->cfg->amp != AMP_SSM3515 && + ma->cfg->safe_vol != 0 && !ma->cfg->spk_fixed_ceiling) { + if (!ma->cfg->fe_cpu_is_platform || + of_property_match_string(link->cpus->of_node, + "dma-names", "sense") >= 0) + ma->has_sense = 1; + } if (speakers && ma->cfg->spk_dai_fmt) link->dai_fmt = ma->cfg->spk_dai_fmt; @@ -4246,13 +4255,12 @@ struct macaudio_platform_cfg macaudio_j604_cfg = { }; /* - * J575c (Mac Studio, M4 Max): the J616s stream, six 32-bit playback and - * twelve 16-bit sense slots in the same 250-bit frame (the firmware runs it - * so, although the ADT's audio-speaker lists one playback slot), with one - * SN012776 on the first two playback slots (it downmixes them) and the - * first two sense slots (current, then voltage), which speakersafetyd's - * J575 model reads. The front-end carries all six channels; the last four - * are silent. + * J575c (Mac Studio, M4 Max) and J773g (Mac mini, M4): the J616s AOP speaker + * stream (six 32-bit playback slots in a 250-BCLK frame, with one SN012776 on + * the front slots). Whether V/I sense is exposed is derived from the speaker + * CPU DAI node's "sense" DMA channel: J575c provides it, while J773g has no + * sense channel and is governed under a lease by a feed-forward protection + * daemon. The headphone jack is a separate card. */ struct macaudio_platform_cfg macaudio_j575c_cfg = { .enable_speakers = true, @@ -4443,6 +4451,8 @@ static const struct of_device_id macaudio_snd_device_id[] = { { .compatible = "apple,j773-macaudio", .data = &macaudio_j575c_j773_cfg }, /* j773 - cs42l84 - the jack, a card of its own (AOP-fed) */ { .compatible = "apple,j773-macaudio-jack", .data = &macaudio_j616_jack_cfg }, + /* j773g - sn012776 15 1x 1W (AOP-fed, no V/I sense) */ + { .compatible = "apple,j773g-macaudio", .data = &macaudio_j575c_cfg }, /* j873 AID48 sn012776 15 1x 1W (AOP-fed, no protection) */ { .compatible = "apple,j873-macaudio", .data = &macaudio_j873_cfg }, /* j813 AID? sn012776 15 2x 1W+1T (AOP-fed, V/I sense) */