Skip to content

Add speaker and headset jack support for Apple Silicon Macs

James Calligeros asahi linux-arm-kernel linux-devicetree linux-mediatek linux-sound lkml 4 versions – In review

Get series with b4
b4 am [email protected] change-id 20260915-macaudio-33c1c4f304da

Versions newest first

  1. v4 Latest22 patches 10 repliesIn review
  2. v321 patches 3 repliesSuperseded
  3. v221 patches 29 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v128 patches26 repliesSuperseded

Changes in v4 from the cover letter

- Allow additional properties from dai-common in CS42L42 and CS42L84
- Extend base tdm-slot.yaml idle mode props instead of defining bespoke ones
- Clean up macaudio binding formatting
- Give CS42L83 regulators unique node names
- Drop useless reg property from macaudio dai-link, replace with named nodes for headphone and speaker links
- Fix up snd_soc_set_enum_kctl declaration to match altered argument names
- Set TDM idle mode/mask for single-codec machines
- Put card and jack back on the heap; not having these around causes more problems than it solves
- Prevent headphones from routing to the secondary mux, and speakers from routing to the primary mux as the primary mux cannot drive the speakers anyway
- Avoid leaking OF node references on failed driver probes
- Replace platform_remove with devres release action to cancel enqueued work
- Use str_has_prefix for checking speaker link name
- Link to v3: https://patch.msgid.link/[email protected]

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22ASoC: dt-bindings: cs42l84: Allow referenced dai-common propertiesDocumentation/devicetree/bindings/sound/cirrus,cs42l84.yaml+4 -42 replies
2/22ASoC: dt-bindings: cs42l42: Allow referenced dai-common propertiesDocumentation/devicetree/bindings/sound/cirrus,cs42l42.yaml+4 -14 replies
3/22ASoC: dt-bindings: tdm-slot: Allow indexed TDM idle propertiesDocumentation/devicetree/bindings/sound/tdm-slot.yaml+18 -160 replies
4/22ASoC: dt-bindings: Add binding for Apple Silicon Mac audioDocumentation/devicetree/bindings/sound/apple,macaudio.yaml+195 -00 replies
5/22ASoC: ops: Introduce 'snd_soc_ctl_activate'include/sound/soc.h sound/soc/soc-ops.c+34 -01 reply
6/22ASoC: ops: Introduce 'soc_set_enum_kctl'include/sound/soc.h sound/soc/soc-ops.c+69 -01 reply
7/22ASoC: card: Let 'fixup_controls' return errorsinclude/sound/soc-card.h include/sound/soc.h sound/soc/mediatek/mt8188/mt8188-mt6359.c +2 more+18 -70 replies
8/22ASoC: tas2770: Add compatible for TAS5770Lsound/soc/codecs/tas2770.c+1 -00 replies
9/22ASoC: apple: Add macaudio machine driversound/soc/apple/Kconfig sound/soc/apple/Makefile sound/soc/apple/macaudio.c+1756 -01 reply
10/22arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supplyarch/arm64/boot/dts/apple/t8103-jxxx.dtsi+32 -00 replies
11/22arm64: dts: apple: t8103-j274: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8103-j274.dts+70 -00 replies
12/22arm64: dts: apple: t8103-j313: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8103-j313.dts+85 -00 replies
13/22arm64: dts: apple: t8103-j293: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8103-j293.dts+114 -00 replies
14/22arm64: dts: apple: t8103-j45x: Add headset jack nodesarch/arm64/boot/dts/apple/t8103-j456.dts arch/arm64/boot/dts/apple/t8103-j457.dts+86 -00 replies
15/22arm64: dts: apple: t8112-j413: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8112-j413.dts+104 -00 replies
16/22arm64: dts: apple: t8112-j415: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8112-j415.dts+128 -00 replies
17/22arm64: dts: apple: t8112-j473: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8112-j473.dts+58 -00 replies
18/22arm64: dts: apple: t8112-j493: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t8112-j493.dts+104 -00 replies
19/22arm64: dts: apple: t600x-j31x: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t6000-j314s.dts arch/arm64/boot/dts/apple/t6000-j316s.dts arch/arm64/boot/dts/apple/t6001-j314c.dts +2 more+151 -00 replies
20/22arm64: dts: apple: t600x-j375: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t6001-j375c.dts arch/arm64/boot/dts/apple/t6002-j375d.dts arch/arm64/boot/dts/apple/t600x-j375.dtsi+71 -00 replies
21/22arm64: dts: apple: t602x-j41x: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t6020-j414s.dts arch/arm64/boot/dts/apple/t6020-j416s.dts arch/arm64/boot/dts/apple/t6021-j414c.dts +2 more+55 -00 replies
22/22arm64: dts: apple: t602x-j47x: Add speaker/headset jack nodesarch/arm64/boot/dts/apple/t6020-j474s.dts arch/arm64/boot/dts/apple/t6021-j475c.dts arch/arm64/boot/dts/apple/t6022-j475d.dts +1 more+25 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 00/22] Add speaker and headset jack support for Apple Silicon Macs

Hi folks,

This series adds the machine driver and related bindings for the primary audio subsystem on Apple Silicon Macs. The macaudio machine driver is based on an RFC sent many years ago by Martin Povišer[1].

The driver uses the DPCM model to dynamically
glue a backend DAI (combination of MCA ports and codecs) to a frontend PCM. While this theoretically allows us to route any backend to any frontend, this is not used in practice; the "Primary" frontend is always used for the headset codec and the "Secondary" is always used for the speakers.

The audio subsystem on Apple Silicon Macs is rather complicated and the speaker arrangement is highly variable; some machines have a single mono woofer while others pull together multiple woofers and tweeters into a single stereo pair. Every machine also includes a headset jack, and some also have their own builtin microphones which are handled by a separate coprocessor with its own driver.

Many functions which are handled by firmware on other platforms must be handled by the kernel or by userspace. Most notably, speaker protection is handled by speakersafetyd[2], a userspace daemon. Speaker protection is handled in userspace due to the expensive floating point calculations and amount of per-machine configuration data required.

The machine driver facilitates this by exposing a capture PCM from which the voltage and current across each speaker's voice coil can be read. Given that there are absolutely no hardware or firmware level failsafes preventing permanent damage to the fragile speakers found on these machines, the driver also implements a failsafe that will significantly attenuate and lock the gains of every connected speaker unless speakersafetyd is running.

Version 2 of this series drops numerous fixes and semi-related patches that are not strictly necessary for the machine driver to function correctly. These will be resubmitted at a later date.

Adding the required Devicetree updates for M3 series devices would have bloated this series to an unreasonable size as they are still missing most prerequisite hardware nodes. They will be added in a future series.

Regards,
James

[1] https://lore.kernel.org/asahi/[email protected]/
[2] https://github.com/AsahiLinux/speakersafetyd

---
Changes in v4:
- Allow additional properties from dai-common in CS42L42 and CS42L84
- Extend base tdm-slot.yaml idle mode props instead of defining bespoke ones
- Clean up macaudio binding formatting
- Give CS42L83 regulators unique node names
- Drop useless reg property from macaudio dai-link, replace with named nodes for headphone and speaker links
- Fix up snd_soc_set_enum_kctl declaration to match altered argument names
- Set TDM idle mode/mask for single-codec machines
- Put card and jack back on the heap; not having these around causes more problems than it solves
- Prevent headphones from routing to the secondary mux, and speakers from routing to the primary mux as the primary mux cannot drive the speakers anyway
- Avoid leaking OF node references on failed driver probes
- Replace platform_remove with devres release action to cancel enqueued work
- Use str_has_prefix for checking speaker link name
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Add TAS5770L compatible to TAS2770 driver to match binding
- Fix incorrect Right Tweeter prefix on J415
- Make reference to dai-common.yaml in cs42l{42,84} bindings for common properties
- Fix Devicetree binding formatting in macaudio binding
- Sort macaudio compatible list by fallback compatible
- Add references to fixed regulators for machines with CS42L83
- Fix iMac model compatibles (they are compatible with each other)
- Fix Mac Mini J474 name
- Rework kctl activate/deactivate to be a more pure wrapper of snd_ctl_activate_id
- Check for kctl->put before iterating in soc_set_enum_kctl
- Allocate structs on heap in soc_set_enum_kctl
- Rework snd_soc_set_enum_kctl to be neater
- Refactor snd_soc_set_enum_kctl to eliminate ret assignment
- Set evalue.id and info.id in soc_set_enum_kctl
- Guard against pointer arithmetic errors/null pointer deref in volume limiter
- Replace stored snd_soc_card with static struct
- Mark speaker BEs/FEs as nonatomic
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Drop patches that are only tangentially related (will be submitted later)
- Drop wildcard-matching API for kctls
- Relabel J473 sound model to Mac mini
- Align Devicetree changes with upstream bindings
- Relax Cirrus CS42L42 required properties to keep DT style checker happy
- Define missing properties in CS42L{42,84} bindings
- Fix mistyped DT properties
- Improve macaudio DT binding description
- Drop generic fallback compatible for apple,macaudio
- Drop now-redundant descriptions from other compatibles
- Constrain DAI link link-name property with an enum of valid values
- Drop MCA node from macaudio binding example
- Fix heading comment style in macaudio
- Drop obsolete module parameter
- Replace string functions with safer variants
- Replace dropped wildcard API with searching for full kctl name
- Rework idle props parsing to better surface errors/invalid Devicetree entries
- Add additional locking to backend setup
- Take controls_rwsem when safety functions are called from workqueues
- Replace all mutex{,un}lock calls with guard/scoped_guard
- Fix incorrect amp gain value for j37x config struct
- static const-ify all config structs
- Cancel control lock update workqueue on teardown
- Drop unused DAPM widget
- Fix commented-out safe volume calculations
- Drop speaker lock kcontrol ownership checks and related core API extension
- Link to v1: https://patch.msgid.link/[email protected]

To: David Rhodes <[email protected]>
To: Richard Fitzgerald <[email protected]>
To: Martin Povišer <[email protected]>
To: Liam Girdwood <[email protected]>
To: Mark Brown <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: James Calligeros <[email protected]>
To: Jaroslav Kysela <[email protected]>
To: Takashi Iwai <[email protected]>
To: Matthias Brugger <[email protected]>
To: AngeloGioacchino Del Regno <[email protected]>
To: Shenghao Ding <[email protected]>
To: Kevin Lu <[email protected]>
To: Baojun Xu <[email protected]>
To: Sen Wang <[email protected]>
To: Sven Peter <[email protected]>
To: Janne Grunau <[email protected]>
To: Neal Gompa <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
James Calligeros (17):
ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
ASoC: dt-bindings: tdm-slot: Allow indexed TDM idle properties
ASoC: tas2770: Add compatible for TAS5770L
arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply
arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes
arm64: dts: apple: t8103-j45x: Add headset jack nodes
arm64: dts: apple: t8112-j413: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j415: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j473: Add speaker/headset jack nodes
arm64: dts: apple: t8112-j493: Add speaker/headset jack nodes
arm64: dts: apple: t600x-j31x: Add speaker/headset jack nodes
arm64: dts: apple: t600x-j375: Add speaker/headset jack nodes
arm64: dts: apple: t602x-j41x: Add speaker/headset jack nodes
arm64: dts: apple: t602x-j47x: Add speaker/headset jack nodes

Martin Povišer (5):
ASoC: dt-bindings: Add binding for Apple Silicon Mac audio
ASoC: ops: Introduce 'snd_soc_ctl_activate'
ASoC: ops: Introduce 'soc_set_enum_kctl'
ASoC: card: Let 'fixup_controls' return errors
ASoC: apple: Add macaudio machine driver

 .../devicetree/bindings/sound/apple,macaudio.yaml  |  195 +++
 .../devicetree/bindings/sound/cirrus,cs42l42.yaml  |    5 +-
 .../devicetree/bindings/sound/cirrus,cs42l84.yaml  |    8 +-
 .../devicetree/bindings/sound/tdm-slot.yaml        |   34 +-
 arch/arm64/boot/dts/apple/t6000-j314s.dts          |    5 +
 arch/arm64/boot/dts/apple/t6000-j316s.dts          |    5 +
 arch/arm64/boot/dts/apple/t6001-j314c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6001-j316c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6001-j375c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6002-j375d.dts          |    5 +
 arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi     |  131 ++
 arch/arm64/boot/dts/apple/t600x-j375.dtsi          |   61 +
 arch/arm64/boot/dts/apple/t6020-j414s.dts          |    5 +
 arch/arm64/boot/dts/apple/t6020-j416s.dts          |    5 +
 arch/arm64/boot/dts/apple/t6020-j474s.dts          |    5 +
 arch/arm64/boot/dts/apple/t6021-j414c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6021-j416c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6021-j475c.dts          |    5 +
 arch/arm64/boot/dts/apple/t6022-j475d.dts          |    5 +
 arch/arm64/boot/dts/apple/t602x-j414-j416.dtsi     |   35 +
 arch/arm64/boot/dts/apple/t602x-j474-j475.dtsi     |   10 +
 arch/arm64/boot/dts/apple/t8103-j274.dts           |   70 +
 arch/arm64/boot/dts/apple/t8103-j293.dts           |  114 ++
 arch/arm64/boot/dts/apple/t8103-j313.dts           |   85 +
 arch/arm64/boot/dts/apple/t8103-j456.dts           |   43 +
 arch/arm64/boot/dts/apple/t8103-j457.dts           |   43 +
 arch/arm64/boot/dts/apple/t8103-jxxx.dtsi          |   32 +
 arch/arm64/boot/dts/apple/t8112-j413.dts           |  104 ++
 arch/arm64/boot/dts/apple/t8112-j415.dts           |  128 ++
 arch/arm64/boot/dts/apple/t8112-j473.dts           |   58 +
 arch/arm64/boot/dts/apple/t8112-j493.dts           |  104 ++
 include/sound/soc-card.h                           |    2 +-
 include/sound/soc.h                                |    6 +-
 sound/soc/apple/Kconfig                            |   18 +
 sound/soc/apple/Makefile                           |    4 +
 sound/soc/apple/macaudio.c                         | 1734 ++++++++++++++++++++
 sound/soc/codecs/tas2770.c                         |    1 +
 sound/soc/mediatek/mt8188/mt8188-mt6359.c          |    4 +-
 sound/soc/soc-card.c                               |   12 +-
 sound/soc/soc-core.c                               |    5 +-
 sound/soc/soc-ops.c                                |   99 ++
 41 files changed, 3182 insertions(+), 28 deletions(-)

---
base-commit: f308b528e539c2a14dc7d59201cff45d89b00ab2
change-id: 20260915-macaudio-33c1c4f304da

Best regards,

Signature · 1 line
James Calligeros <[email protected]>