Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 64 additions & 9 deletions arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};
};
};

/*
Expand All @@ -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";
Expand All @@ -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";
};
};

Expand Down
8 changes: 7 additions & 1 deletion sound/soc/apple/aop_spkr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,13 @@ pub(crate) struct SpeakerComponent {

impl SpeakerComponent {
pub(crate) fn register(aop: Arc<SndSocAopData>) -> Result<Self> {
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];
Expand Down
38 changes: 24 additions & 14 deletions sound/soc/apple/macaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) */
Expand Down
Loading