Add speaker and headset jack support for Apple Silicon Macs
Subsystems (8)
v4 cover 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]>
PATCH v4 1/22 ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many and set #sound-dai-cells. Allow this by allowing referenced properties from dai-common.yaml.
--- Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +4 -4
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC maintainers: - Martin Povišer <[email protected]> +allOf: + - $ref: dai-common.yaml# + description: | The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded in personal computers sold by Apple. It was first seen in 2021 Macbook
@@ -29,14 +32,11 @@ properties: interrupts: maxItems: 1 - '#sound-dai-cells': - const: 0 - required: - compatible - reg -additionalProperties: false +unevaluatedProperties: false examples: - |
Signature · 1 line
2.56.0
PATCH v4 2/22 ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
In reply to James CalligerosWe may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Allow this by refrencing dai-common.yaml and allowing its properties to be used.
--- Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +4 -1
@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected] +allOf: + - $ref: dai-common.yaml# + description: The CS42L42 is a low-power audio codec designed for portable applications. It provides a high-dynamic range, stereo DAC for audio playback and a mono
@@ -193,7 +196,7 @@ required: - VL-supply - VA-supply -additionalProperties: false +unevaluatedProperties: false examples: - |
Signature · 1 line
2.56.0
PATCH v4 3/22 ASoC: dt-bindings: tdm-slot: Allow indexed TDM idle properties
In reply to James CalligerosSome consumers may wish to configure a codec's TDM idle properties at runtime based on specific dai-link-level conditions. This could be achieved by doing something like
dai-link@0 {
dai-tdm-idle-mode = "pulldown";
dai-tdm-slot-tx-idle-mask = <0xf0f0>;
cpu {
sound-dai = <&some_cpu>;
};
codec {
sound-dai = <&some_codec>;
};
};But what if we have a dai-link with multiple codecs across multiple CPUs? What if the machine driver parsing the dai-link only expects idle properties for specific codecs? We can extend the idle properties with an index, allowing unique idle configurations for specific components in the dai-link:
dai-link@1 {
dai-tdm-idle-mode-0 = "zero";
dai-tdm-idle-mode-2 = "zero";
dai-tdm-slot-tx-idle-mask-0 = <0xf0f0>;
dai-tdm-slot-tx-idle-mask-2 = <0x0f0f>;
cpu {
sound-dai = <&some_cpu0>, <&some_cpu2>;
};
codec {
sound-dai = <&some_codec0>, <&some_codec1>,
<&some_codec2>, <&some_codec3>;
};
};Extend the TDM idle properties to optionally allow this indexing.
--- .../devicetree/bindings/sound/tdm-slot.yaml | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-)
Documentation/devicetree/bindings/sound/tdm-slot.yaml +18 -16
@@ -20,20 +20,6 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 description: Width, in bits, of each slot - dai-tdm-idle-mode: - $ref: /schemas/types.yaml#/definitions/string - enum: - - none - - off - - zero - - pulldown - - hiz - - pullup - - drivehigh - description: Drive mode for inactive/idle TDM slots. For hardware that - implements .set_tdm_idle(). Optional. "None" represents undefined - behaviour and is the same as not setting this property. - patternProperties: '^dai-tdm-slot-[rt]x-mask$': $ref: /schemas/types.yaml#/definitions/uint32-array
@@ -44,9 +30,25 @@ patternProperties: a mask. The first element of the array is slot 0 (LSB). Any nonzero value will be treated as 1. - '^dai-tdm-slot-[rt]x-idle-mask$': + '^dai-tdm-slot-[rt]x-idle-mask(-[0-9]+)?$': $ref: /schemas/types.yaml#/definitions/uint32 description: Idle slot mask. Optional. A bit being set to 1 indicates - that the corresponding TDM slot is inactive/idle. + that the corresponding TDM slot is inactive/idle. Can be defined on + a per-component basis. + + '^dai-tdm-idle-mode(-[0-9]+)?$': + $ref: /schemas/types.yaml#/definitions/string + enum: + - none + - off + - zero + - pulldown + - hiz + - pullup + - drivehigh + description: Drive mode for inactive/idle TDM slots. For hardware that + implements .set_tdm_idle(). Optional. "None" represents undefined + behaviour and is the same as not setting this property. Can be defined + on a per-component basis. additionalProperties: true
Signature · 1 line
2.56.0
PATCH v4 4/22 ASoC: dt-bindings: Add binding for Apple Silicon Mac audio
In reply to James CalligerosFrom: Martin Povišer <[email protected]>
Add a binding for the primary audio subsystem found on Apple Silicon Macs. This binding integrates the codecs and SoC I2S peripheral used for driving the headset jack and speaker arrays on all Apple Silicon Macs. The internal microphones on this platform are connected to a distinct coprocessor and are not part of this "main" audio subsystem.
--- .../devicetree/bindings/sound/apple,macaudio.yaml | 195 +++++++++++++++++++++ 1 file changed, 195 insertions(+)
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +195 -0
@@ -0,0 +1,195 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/apple,macaudio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sound peripheral integration for Apple Silicon Macs + +description: + The speakers and headphone jack on Apple Silicon Macs are part of an + integrated audio subsystem comprising of Apple's I2S peripheral (MCA) and a + series of codecs. The machines have a wide variety of topologies ranging + from a simple mono speaker in the desktops to complex stereo arrays with + dual-opposed woofers and tweeters all driven by their own mono amplifiers. + This arrangement can be expressed as a set of DAI links, where the MCA ports + each codec is connected to are represented by the CPU side of the link. + +maintainers: + - James Calligeros <[email protected]> + +properties: + compatible: + oneOf: + - items: + - enum: + - apple,j180-macaudio + - apple,j274-macaudio + - apple,j293-macaudio + - apple,j313-macaudio + - apple,j314-macaudio + - apple,j316-macaudio + - apple,j375-macaudio + - apple,j413-macaudio + - apple,j415-macaudio + - apple,j456-macaudio + - apple,j473-macaudio + - items: + - enum: + - apple,j493-macaudio + - const: apple,j293-macaudio + - items: + - enum: + - apple,j414-macaudio + - apple,j504-macaudio + - apple,j514-macaudio + - const: apple,j314-macaudio + - items: + - enum: + - apple,j416-macaudio + - apple,j516-macaudio + - const: apple,j316-macaudio + - items: + - enum: + - apple,j475-macaudio + - apple,j575-macaudio + - const: apple,j375-macaudio + - items: + - enum: + - apple,j613-macaudio + - const: apple,j413-macaudio + - items: + - enum: + - apple,j615-macaudio + - const: apple,j415-macaudio + - items: + - enum: + - apple,j457-macaudio + - const: apple,j456-macaudio + - items: + - enum: + - apple,j474-macaudio + - const: apple,j473-macaudio + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + model: + description: + Model name for presentation to users + $ref: /schemas/types.yaml#/definitions/string + +patternProperties: + "^([a-z]+-)?dai-link$": + description: Node for each sound peripheral such as the speaker array, + headphones jack, or microphone. + type: object + $ref: tdm-slot.yaml# + unevaluatedProperties: false + + properties: + link-name: + description: Name for the peripheral + enum: [ Headphone Jack, Speaker, Speakers ] + $ref: /schemas/types.yaml#/definitions/string + + codec: + type: object + additionalProperties: false + + properties: + sound-dai: + minItems: 1 + maxItems: 8 + description: | + DAI list with the CODEC-side DAIs connected to the above CPU-side + DAIs and involved in this sound peripheral. + + The list is in left/right order if applicable. If there are more + than one CPU-side DAIs (there can be two), the CODECs must be + listed first those connected to the first CPU, then those + connected to the second. + + In addition, on some machines with many speaker codecs, the CODECs + are listed in this fixed order: + + Four speakers: Left Front, Left Rear, Right Front, Right Rear + Six speakers: Left Woofer 1, Left Tweeter, Left Woofer 2, + Right Woofer 1, Right Tweeter, Right Woofer 2 + + required: + - sound-dai + + cpu: + type: object + additionalProperties: false + + properties: + sound-dai: + minItems: 1 + maxItems: 2 + description: | + DAI list with CPU-side I2S ports involved in this peripheral. + + required: + - sound-dai + + required: + - link-name + - codec + - cpu + +required: + - '#address-cells' + - '#size-cells' + - compatible + - model + +additionalProperties: false + +examples: + - | + sound { + compatible = "apple,j416-macaudio", "apple,j316-macaudio"; + model = "MacBook Pro J416"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + link-name = "Speakers"; + + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-3 = "zero"; + dai-tdm-slot-tx-idle-mask-0 = <0xf0f0f0>; + dai-tdm-slot-tx-idle-mask-3 = <0x0f0f0f>; + + codec { + sound-dai = <&speaker_left_woof1>, + <&speaker_left_tweet>, + <&speaker_left_woof2>, + <&speaker_right_woof1>, + <&speaker_right_tweet>, + <&speaker_right_woof2>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + };
Signature · 1 line
2.56.0
PATCH v4 5/22 ASoC: ops: Introduce 'snd_soc_ctl_activate'
In reply to James CalligerosFrom: Martin Povišer <[email protected]>
This function mirrors wraps the sound/core 'snd_ctl_activate_id' for ASoC. Machine drivers may call it to lock down kcontrols during fixup_controls.
--- include/sound/soc.h | 2 ++ sound/soc/soc-ops.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
include/sound/soc.h +2 -0
@@ -565,6 +565,8 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_limit_volume (struct snd_soc_card *card,const char *name,int max); +int snd_soc_ctl_activate (struct snd_soc_card *card, +const char *name,int active);int snd_soc_bytes_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo); int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
sound/soc/soc-ops.c +32 -0
@@ -473,6 +473,38 @@ int snd_soc_limit_volume(struct snd_soc_card *card, const char *name, int max) }EXPORT_SYMBOL_GPL (snd_soc_limit_volume); +/** +* snd_soc_ctl_activate - Activate/deactivate a control matching a name +* +* @card: where to look for the control +* @name: name +* @active: zero to deactivate, nonzero to activate +* +* Return: 0 if unchanged, 1 if changed, or a negative error code on failure. +*/ +int snd_soc_ctl_activate (struct snd_soc_card *card, +const char *name,int active) +{ +struct snd_kcontrol *kctl; +int ret = -EINVAL ; + +if (!name) +return ret; + + kctl =snd_soc_card_get_kcontrol (card, name); + +if (kctl) { + ret =snd_ctl_activate_id (card->snd_card, &kctl->id, active); +if (ret <0 ) +return ret; + }else { +dev_dbg (card->dev,"Tried to de/activate unknown control '%s'\n" , name); + } + +return ret; +} +EXPORT_SYMBOL_GPL (snd_soc_ctl_activate); +int snd_soc_bytes_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) {
Signature · 1 line
2.56.0
PATCH v4 6/22 ASoC: ops: Introduce 'soc_set_enum_kctl'
In reply to James CalligerosFrom: Martin Povišer <[email protected]>
The new function is to be used to set enumerated controls to desired values. It is something a machine driver may call in fixup_controls.
--- include/sound/soc.h | 2 ++ sound/soc/soc-ops.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+)
include/sound/soc.h +2 -0
@@ -567,6 +567,8 @@ int snd_soc_limit_volume(struct snd_soc_card *card, const char *name, int max);int snd_soc_ctl_activate (struct snd_soc_card *card,const char *name,int active); +int snd_soc_set_enum_kctl (struct snd_soc_card *card, +const char *name,const char *value);int snd_soc_bytes_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo); int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
sound/soc/soc-ops.c +67 -0
73 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v4 7/22 ASoC: card: Let 'fixup_controls' return errors
In reply to James CalligerosFrom: Martin Povišer <[email protected]>
Let the 'fixup_controls' card method return error values which will roll back the half-done binding of the card.
--- include/sound/soc-card.h | 2 +- include/sound/soc.h | 2 +- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 4 +++- sound/soc/soc-card.c | 12 +++++++++--- sound/soc/soc-core.c | 5 ++++- 5 files changed, 18 insertions(+), 7 deletions(-)
include/sound/soc-card.h +1 -1
@@ -44,7 +44,7 @@ int snd_soc_card_resume_post(struct snd_soc_card *card);int snd_soc_card_probe (struct snd_soc_card *card);int snd_soc_card_late_probe (struct snd_soc_card *card); -void snd_soc_card_fixup_controls (struct snd_soc_card *card); +int snd_soc_card_fixup_controls (struct snd_soc_card *card);int snd_soc_card_remove (struct snd_soc_card *card);void snd_soc_card_set_topology_name (struct snd_soc_card *card,const char *preifx);
include/sound/soc.h +1 -1
@@ -992,7 +992,7 @@ struct snd_soc_card {int (*probe)(struct snd_soc_card *card);int (*late_probe)(struct snd_soc_card *card); -void (*fixup_controls)(struct snd_soc_card *card); +int (*fixup_controls)(struct snd_soc_card *card);int (*remove)(struct snd_soc_card *card);/* the pre and post PM functions are used to do any PM work before and
sound/soc/mediatek/mt8188/mt8188-mt6359.c +3 -1
@@ -1283,7 +1283,7 @@ static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = { }, }; -static void mt8188_fixup_controls (struct snd_soc_card *card) +static int mt8188_fixup_controls (struct snd_soc_card *card) {struct mtk_soc_card_data *soc_card_data =snd_soc_card_get_drvdata (card);struct mtk_platform_card_data *card_data = soc_card_data->card_data;
@@ -1305,6 +1305,8 @@ static void mt8188_fixup_controls(struct snd_soc_card *card)else dev_warn (card->dev,"Cannot find ctl : Headphone Switch\n" ); } + +return 0 ; }static struct snd_soc_card mt8188_mt6359_soc_card = {
sound/soc/soc-card.c +9 -3
@@ -184,10 +184,16 @@ int snd_soc_card_late_probe(struct snd_soc_card *card)return 0 ; } -void snd_soc_card_fixup_controls (struct snd_soc_card *card) +int snd_soc_card_fixup_controls (struct snd_soc_card *card) { -if (card->fixup_controls) - card->fixup_controls (card); +if (card->fixup_controls) { +int ret = card->fixup_controls (card); + +if (ret <0 ) +return soc_card_ret (card, ret); + } + +return 0 ; }int snd_soc_card_remove (struct snd_soc_card *card)
sound/soc/soc-core.c +4 -1
@@ -1845,7 +1845,10 @@ static int snd_soc_bind_card(struct snd_soc_card *card)if (ret <0 ) goto probe_end; } -snd_soc_card_fixup_controls (card); + + ret =snd_soc_card_fixup_controls (card); +if (ret <0 ) + goto probe_end; ret =snd_card_register (card->snd_card);if (ret <0 ) {
Signature · 1 line
2.56.0
PATCH v4 8/22 ASoC: tas2770: Add compatible for TAS5770L
In reply to James CalligerosTAS5770L is an Apple-specific variant of TAS2770 found in a number of first-generation Apple Silicon Macs. Add a compatible for it.
--- sound/soc/codecs/tas2770.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/tas2770.c +1 -0
@@ -987,6 +987,7 @@ MODULE_DEVICE_TABLE(i2c, tas2770_i2c_id);#if defined(CONFIG_OF )static const struct of_device_id tas2770_of_match[] = { { .compatible ="ti,tas2770" }, + { .compatible ="ti,tas5770l" },/* Apple variant */ {}, };MODULE_DEVICE_TABLE (of, tas2770_of_match);
Signature · 1 line
2.56.0
PATCH v4 9/22 ASoC: apple: Add macaudio machine driver
In reply to James CalligerosFrom: Martin Povišer <[email protected]>
Apple Silicon Macs have a complex audio subsystem consisting of an I2S peripheral (MCA) and multiple codecs of various models and capabilities. Some machines have a basic mono speaker with hardware downmix, while others have a very intricate stereo system consisting of multiple codecs and drivers per L/R channel. Some machines report voice coil voltage and current information back to the SoC, and others do not. All machines have a headset jack.
Add an ASoC machine driver for this platform.
To express all of this sanely, we initialise the correct combinations of codecs/I2S ports as DAI backends and link them to a synthetic frontend. Each frontend is linked to a PCM, one for the headset codec and one for the speaker system on the target machine.
--- sound/soc/apple/Kconfig | 18 + sound/soc/apple/Makefile | 4 + sound/soc/apple/macaudio.c | 1734 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1756 insertions(+)
sound/soc/apple/Kconfig +18 -0
@@ -9,4 +9,22 @@ config SND_SOC_APPLE_MCA This option enables an ASoC platform driver for MCA peripherals found on Apple Silicon SoCs. +config SND_SOC_APPLE_MACAUDIO + tristate "Sound support for Apple Silicon Macs" + depends on ARCH_APPLE || COMPILE_TEST + select SND_SOC_APPLE_MCA + select APPLE_ADMAC if DMADEVICES + select COMMON_CLK_APPLE_NCO if COMMON_CLK + select SND_SOC_TAS2764 if I2C + select SND_SOC_TAS2770 if I2C + select SND_SOC_CS42L83 if I2C + select SND_SOC_CS42L84 if I2C + help + This option enables an ASoC machine-level driver for Apple Silicon Macs + and it also enables the required SoC and codec drivers for overall + sound support on these machines. Say Y here if you have an Apple Silicon + Mac. + + This driver can also be compiled as a module. If so, it will be called + snd-soc-macaudio. endmenu
sound/soc/apple/Makefile +4 -0
@@ -2,3 +2,7 @@ snd-soc-apple-mca-y := mca.o obj-$(CONFIG_SND_SOC_APPLE_MCA) += snd-soc-apple-mca.o + +snd-soc-macaudio-y := macaudio.o + +obj-$(CONFIG_SND_SOC_APPLE_MACAUDIO) += snd-soc-macaudio.o
sound/soc/apple/macaudio.c new file +1734 -0
1,734 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v4 10/22 arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply
In reply to James CalligerosThe CS42L83 codec found on M1 series Apple Silicon Macs gets its voltages from fixed regulators managed by the platform. Add these to the template Devicetree so that they can be referenced on the relevant devices.
We do not (officially) know how the power is delivered to the chip (voltage rail names, commoned pins, physical regulators, etc.) so the regulators expressed here are just stand-ins.
--- arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +32 -0
@@ -38,6 +38,38 @@ memory@800000000 { device_type = "memory"; reg = <0x8 0 0x2 0>; /* To be filled by loader */ }; + + /* + * The CS42L83 found on all T8103 boards requires VA, VCP, VCP_FILT, + * VL, VD and VP regulators. We don't (officially) know how power + * gets to the codec, so these fixed regulators are stand-ins. + */ + jack_va_reg: regulator-codec-va { + compatible = "regulator-fixed"; + regulator-name = "jack-va"; + }; + + /* CS42L83 VCP and VCP_FILT */ + jack_vcp_reg: regulator-codec-vcp { + compatible = "regulator-fixed"; + regulator-name = "jack-vcp"; + }; + + jack_vl_reg: regulator-codec-vl { + compatible = "regulator-fixed"; + regulator-name = "jack-vl"; + }; + + /* VD_FILT */ + jack_vd_reg: regulator-codec-vd { + compatible = "regulator-fixed"; + regulator-name = "jack-vd"; + }; + + jack_vp_reg: regulator-codec-vp { + compatible = "regulator-fixed"; + regulator-name = "jack-vp"; + }; }; &serial0 {
Signature · 1 line
2.56.0
PATCH v4 11/22 arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes
In reply to James CalligerosThe M1 Mac mini integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8103-j274.dts | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
arch/arm64/boot/dts/apple/t8103-j274.dts +70 -0
@@ -75,4 +75,74 @@ &i2c2 { status = "okay"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker: codec@31 { + compatible = "ti,tas5770l"; + reg = <0x31>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; +}; + +&i2c2 { + status = "okay"; + + jack_codec: codec@48 { + compatible = "cirrus,cs42l83"; + reg = <0x48>; + VA-supply = <&jack_va_reg>; + VCP-supply = <&jack_vcp_reg>; + VD_FILT-supply = <&jack_vd_reg>; + VL-supply = <&jack_vl_reg>; + VP-supply = <&jack_vp_reg>; + + interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>; + + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + cirrus,ts-inv = <1>; + }; +}; + +/ { + sound: sound { + compatible = "apple,j274-macaudio"; + model = "Mac mini J274"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + link-name = "Speaker"; + + codec { + sound-dai = <&speaker>; + }; + + cpu { + sound-dai = <&mca 0>; + }; + }; + }; +}; + #include "hwmon-mini.dtsi"
Signature · 1 line
2.56.0
PATCH v4 12/22 arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
In reply to James CalligerosThe M1 MacBook Air integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8103-j313.dts | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
arch/arm64/boot/dts/apple/t8103-j313.dts +85 -0
@@ -55,4 +55,89 @@ &typec1 { label = "USB-C Left-front"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker_left: codec@31 { + compatible = "ti,tas5770l"; + reg = <0x31>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left"; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; +}; + +&i2c3 { + status = "okay"; + + speaker_right: codec@34 { + compatible = "ti,tas5770l"; + reg = <0x34>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right"; + ti,imon-slot-no = <4>; + ti,vmon-slot-no = <6>; + }; + + jack_codec: codec@48 { + compatible = "cirrus,cs42l83"; + reg = <0x48>; + VA-supply = <&jack_va_reg>; + VCP-supply = <&jack_vcp_reg>; + VD_FILT-supply = <&jack_vd_reg>; + VL-supply = <&jack_vl_reg>; + VP-supply = <&jack_vp_reg>; + + interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>; + + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + cirrus,ts-inv = <1>; + }; +}; + +/ { + sound: sound { + compatible = "apple,j313-macaudio"; + model = "MacBook Air J313"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-1 = "zero"; + + link-name = "Speakers"; + + codec { + sound-dai = <&speaker_left>, <&speaker_right>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + }; +}; + #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
PATCH v4 13/22 arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes
In reply to James CalligerosThe M1 MacBook Pro integrates Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8103-j293.dts | 114 +++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
arch/arm64/boot/dts/apple/t8103-j293.dts +114 -0
@@ -133,5 +133,119 @@ &displaydfr_dart { status = "okay"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker_left_rear: codec@31 { + compatible = "ti,tas5770l"; + reg = <0x31>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Rear"; + ti,imon-slot-no = <8>; + ti,vmon-slot-no = <10>; + }; + + speaker_left_front: codec@32 { + compatible = "ti,tas5770l"; + reg = <0x32>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Front"; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; +}; + +&i2c2 { + status = "okay"; + + jack_codec: codec@48 { + compatible = "cirrus,cs42l83"; + reg = <0x48>; + VA-supply = <&jack_va_reg>; + VCP-supply = <&jack_vcp_reg>; + VD_FILT-supply = <&jack_vd_reg>; + VL-supply = <&jack_vl_reg>; + VP-supply = <&jack_vp_reg>; + + interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>; + + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + cirrus,ts-inv = <1>; + }; +}; + +&i2c3 { + status = "okay"; + + speaker_right_rear: codec@34 { + compatible = "ti,tas5770l"; + reg = <0x34>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Rear"; + ti,imon-slot-no = <12>; + ti,vmon-slot-no = <14>; + }; + + speaker_right_front: codec@35 { + compatible = "ti,tas5770l"; + reg = <0x35>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Front"; + ti,imon-slot-no = <4>; + ti,vmon-slot-no = <6>; + }; +}; + +/ { + sound: sound { + compatible = "apple,j293-macaudio"; + model = "MacBook Pro J293"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "pulldown"; + dai-tdm-idle-mode-2 = "pulldown"; + + link-name = "Speakers"; + + codec { + sound-dai = <&speaker_left_front>, + <&speaker_left_rear>, + <&speaker_right_front>, + <&speaker_right_rear>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + }; +}; + #include "hwmon-laptop.dtsi" #include "hwmon-fan.dtsi"
Signature · 1 line
2.56.0
PATCH v4 14/22 arm64: dts: apple: t8103-j45x: Add headset jack nodes
In reply to James CalligerosThe M1 iMacs integrate Apple-specific variants of the TI TAS2770 and Cirrus CS42L42. Since it is not yet safe to expose the speakers on these machines, add the headset jack nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8103-j456.dts | 43 ++++++++++++++++++++++++++++++++ arch/arm64/boot/dts/apple/t8103-j457.dts | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+)
arch/arm64/boot/dts/apple/t8103-j456.dts +43 -0
@@ -88,3 +88,46 @@ &pcie0_dart_1 { &pcie0_dart_2 { status = "okay"; }; + +&i2c1 { + status = "okay"; + + jack_codec: codec@48 { + compatible = "cirrus,cs42l83"; + reg = <0x48>; + VA-supply = <&jack_va_reg>; + VCP-supply = <&jack_vcp_reg>; + VD_FILT-supply = <&jack_vd_reg>; + VL-supply = <&jack_vl_reg>; + VP-supply = <&jack_vp_reg>; + + interrupts-extended = <&pinctrl_ap 183 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 11 GPIO_ACTIVE_HIGH>; + + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + cirrus,ts-inv = <1>; + }; +}; + +/ { + sound: sound { + compatible = "apple,j456-macaudio"; + model = "iMac J456"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + }; +};
arch/arm64/boot/dts/apple/t8103-j457.dts +43 -0
46 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v4 15/22 arm64: dts: apple: t8112-j413: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 MacBook Air integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8112-j413.dts | 104 +++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+)
arch/arm64/boot/dts/apple/t8112-j413.dts +104 -0
@@ -92,4 +92,108 @@ &fpwm1 { status = "okay"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker_left_woof: codec@38 { + compatible = "ti,sn012776"; + reg = <0x38>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Woofer"; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; + + speaker_left_tweet: codec@39 { + compatible = "ti,sn012776"; + reg = <0x39>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Tweeter"; + ti,imon-slot-no = <8>; + ti,vmon-slot-no = <10>; + }; +}; + +&i2c3 { + status = "okay"; + + speaker_right_woof: codec@3b { + compatible = "ti,sn012776"; + reg = <0x3b>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Woofer"; + ti,imon-slot-no = <4>; + ti,vmon-slot-no = <6>; + }; + + speaker_right_tweet: codec@3c { + compatible = "ti,sn012776"; + reg = <0x3c>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Tweeter"; + ti,imon-slot-no = <12>; + ti,vmon-slot-no = <14>; + }; + + jack_codec: codec@4b { + compatible = "cirrus,cs42l84"; + reg = <0x4b>; + interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + }; +}; + +/ { + sound: sound { + compatible = "apple,j413-macaudio"; + model = "MacBook Air J413"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-2 = "zero"; + dai-tdm-slot-tx-idle-mask-0 = <0xf0f0>; + dai-tdm-slot-tx-idle-mask-2 = <0x0f0f>; + + link-name = "Speakers"; + + codec { + sound-dai = <&speaker_left_woof>, + <&speaker_left_tweet>, + <&speaker_right_woof>, + <&speaker_right_tweet>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + }; +}; + #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
PATCH v4 16/22 arm64: dts: apple: t8112-j415: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 MacBook Air integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8112-j415.dts | 128 +++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+)
arch/arm64/boot/dts/apple/t8112-j415.dts +128 -0
@@ -92,4 +92,132 @@ &fpwm1 { status = "okay"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker_left_woof1: codec@38 { + compatible = "ti,sn012776"; + reg = <0x38>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Woofer 1"; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; + + speaker_left_tweet: codec@39 { + compatible = "ti,sn012776"; + reg = <0x39>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Tweeter"; + ti,imon-slot-no = <8>; + ti,vmon-slot-no = <10>; + }; + + speaker_left_woof2: codec@3a { + compatible = "ti,sn012776"; + reg = <0x3a>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Woofer 2"; + ti,imon-slot-no = <16>; + ti,vmon-slot-no = <18>; + }; +}; + +&i2c3 { + status = "okay"; + + speaker_right_woof1: codec@3b { + compatible = "ti,sn012776"; + reg = <0x3b>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Woofer 1"; + ti,imon-slot-no = <4>; + ti,vmon-slot-no = <6>; + }; + + speaker_right_tweet: codec@3c { + compatible = "ti,sn012776"; + reg = <0x3c>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Tweeter"; + ti,imon-slot-no = <12>; + ti,vmon-slot-no = <14>; + }; + + speaker_right_woof2: codec@3d { + compatible = "ti,sn012776"; + reg = <0x3d>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Woofer 2"; + ti,imon-slot-no = <20>; + ti,vmon-slot-no = <22>; + }; + + jack_codec: codec@4b { + compatible = "cirrus,cs42l84"; + reg = <0x4b>; + interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + }; +}; + +/ { + sound: sound { + compatible = "apple,j415-macaudio"; + model = "MacBook Air J415"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-3 = "zero"; + dai-tdm-slot-tx-idle-mask-0 = <0xf0f0f0>; + dai-tdm-slot-tx-idle-mask-3 = <0x0f0f0f>; + + link-name = "Speakers"; + + codec { + sound-dai = <&speaker_left_woof1>, + <&speaker_left_tweet>, + <&speaker_left_woof2>, + <&speaker_right_woof1>, + <&speaker_right_tweet>, + <&speaker_right_woof2>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + }; +}; + #include "hwmon-laptop.dtsi"
Signature · 1 line
2.56.0
PATCH v4 17/22 arm64: dts: apple: t8112-j473: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 Mac mini integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8112-j473.dts | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/apple/t8112-j473.dts +58 -0
@@ -85,4 +85,62 @@ &typec1 { label = "USB-C Back-right"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker: codec@38 { + compatible = "ti,sn012776"; + reg = <0x38>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; + + jack_codec: codec@4b { + compatible = "cirrus,cs42l84"; + reg = <0x4b>; + interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + }; +}; + +/ { + sound: sound { + compatible = "apple,j473-macaudio"; + model = "Mac mini J473"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + link-name = "Speakers"; + + codec { + sound-dai = <&speaker>; + }; + + cpu { + sound-dai = <&mca 0>; + }; + }; + }; +}; + #include "hwmon-mini.dtsi"
Signature · 1 line
2.56.0
PATCH v4 18/22 arm64: dts: apple: t8112-j493: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 MacBook Pro integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t8112-j493.dts | 104 +++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+)
arch/arm64/boot/dts/apple/t8112-j493.dts +104 -0
@@ -147,5 +147,109 @@ touchbar0: touchbar@0 { }; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker_left_rear: codec@38 { + compatible = "ti,sn012776"; + reg = <0x38>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Rear"; + ti,imon-slot-no = <8>; + ti,vmon-slot-no = <10>; + }; + + speaker_left_front: codec@39 { + compatible = "ti,sn012776"; + reg = <0x39>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Left Front"; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; +}; + +&i2c3 { + status = "okay"; + + speaker_right_rear: codec@3b { + compatible = "ti,sn012776"; + reg = <0x3b>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Rear"; + ti,imon-slot-no = <12>; + ti,vmon-slot-no = <14>; + }; + + speaker_right_front: codec@3c { + compatible = "ti,sn012776"; + reg = <0x3c>; + interrupts-extended = <&pinctrl_ap 11 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 88 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Right Front"; + ti,imon-slot-no = <4>; + ti,vmon-slot-no = <6>; + }; + + jack_codec: codec@4b { + compatible = "cirrus,cs42l84"; + reg = <0x4b>; + interrupts-extended = <&pinctrl_ap 149 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 12 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + sound-name-prefix = "Jack"; + }; +}; + +/ { + sound: sound { + compatible = "apple,j493-macaudio", "apple,j293-macaudio"; + model = "MacBook Pro J493"; + + #address-cells = <1>; + #size-cells = <0>; + + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>; + }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-2 = "zero"; + dai-tdm-slot-tx-idle-mask-0 = <0xf0f0>; + dai-tdm-slot-tx-idle-mask-2 = <0x0f0f>; + + link-name = "Speakers"; + + codec { + sound-dai = <&speaker_left_front>, + <&speaker_left_rear>, + <&speaker_right_front>, + <&speaker_right_rear>; + }; + + cpu { + sound-dai = <&mca 0>, <&mca 1>; + }; + }; + }; +}; + #include "hwmon-laptop.dtsi" #include "hwmon-fan.dtsi"
Signature · 1 line
2.56.0
PATCH v4 19/22 arm64: dts: apple: t600x-j31x: Add speaker/headset jack nodes
In reply to James CalligerosThe M1 Pro/Max MacBooks integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- 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/t600x-j314-j316.dtsi | 131 +++++++++++++++++++++++++ 5 files changed, 151 insertions(+)
arch/arm64/boot/dts/apple/t6000-j314s.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,maldives"; }; + +&sound { + compatible = "apple,j314-macaudio"; + model = "MacBook Pro J314"; +};
arch/arm64/boot/dts/apple/t6000-j316s.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,madagascar"; }; + +&sound { + compatible = "apple,j316-macaudio"; + model = "MacBook Pro J316"; +};
arch/arm64/boot/dts/apple/t6001-j314c.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,maldives"; }; + +&sound { + compatible = "apple,j314-macaudio"; + model = "MacBook Pro J314"; +};
arch/arm64/boot/dts/apple/t6001-j316c.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,madagascar"; }; + +&sound { + compatible = "apple,j316-macaudio"; + model = "MacBook Pro J316"; +};
arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi +131 -0
143 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v4 20/22 arm64: dts: apple: t600x-j375: Add speaker/headset jack nodes
In reply to James CalligerosThe M1 Max/Ultra Mac Studio integrates Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t6001-j375c.dts | 5 +++ arch/arm64/boot/dts/apple/t6002-j375d.dts | 5 +++ arch/arm64/boot/dts/apple/t600x-j375.dtsi | 61 +++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
arch/arm64/boot/dts/apple/t6001-j375c.dts +5 -0
@@ -25,4 +25,9 @@ &bluetooth0 { brcm,board-type = "apple,okinawa"; }; +&sound { + compatible = "apple,j375-macaudio"; + model = "Mac Studio J375"; +}; + #include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t6002-j375d.dts +5 -0
@@ -184,6 +184,11 @@ atcphy5_usb3: endpoint { }; }; +&sound { + compatible = "apple,j375-macaudio"; + model = "Mac Studio J375"; +}; + #include "hwmon-fan-dual.dtsi" /* delete unused USB nodes on die 1 */
arch/arm64/boot/dts/apple/t600x-j375.dtsi +61 -0
71 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v4 21/22 arm64: dts: apple: t602x-j41x: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 Pro/Max MacBooks integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t6020-j414s.dts | 5 ++++ arch/arm64/boot/dts/apple/t6020-j416s.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/t602x-j414-j416.dtsi | 35 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+)
arch/arm64/boot/dts/apple/t6020-j414s.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,tokara"; }; + +&sound { + compatible = "apple,j414-macaudio", "apple,j314-macaudio"; + model = "MacBook Pro J414"; +};
arch/arm64/boot/dts/apple/t6020-j416s.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,amami"; }; + +&sound { + compatible = "apple,j416-macaudio", "apple,j316-macaudio"; + model = "MacBook Pro J416"; +};
arch/arm64/boot/dts/apple/t6021-j414c.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,tokara"; }; + +&sound { + compatible = "apple,j414-macaudio", "apple,j314-macaudio"; + model = "MacBook Pro J414"; +};
arch/arm64/boot/dts/apple/t6021-j416c.dts +5 -0
@@ -24,3 +24,8 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,amami"; }; + +&sound { + compatible = "apple,j416-macaudio", "apple,j316-macaudio"; + model = "MacBook Pro J416"; +};
arch/arm64/boot/dts/apple/t602x-j414-j416.dtsi +35 -0
@@ -43,3 +43,38 @@ &wifi0 { &bluetooth0 { compatible = "pci14e4,5f72"; }; + +&speaker_left_tweet { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&speaker_left_woof1 { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&speaker_left_woof2 { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&speaker_right_tweet { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&speaker_right_woof1 { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&speaker_right_woof2 { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&jack_codec { + interrupts-extended = <&pinctrl_ap 59 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 8 GPIO_ACTIVE_HIGH>; +};
Signature · 1 line
2.56.0
PATCH v4 22/22 arm64: dts: apple: t602x-j47x: Add speaker/headset jack nodes
In reply to James CalligerosThe M2 Pro/Max/Ultra Mac mini and Mac Studio integrate Apple-specific variants of the TI TAS2764 and Cirrus CS42L42. Add these nodes and advertise them to the machine driver via the sound node.
--- arch/arm64/boot/dts/apple/t6020-j474s.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-j474-j475.dtsi | 10 ++++++++++ 4 files changed, 25 insertions(+)
arch/arm64/boot/dts/apple/t6020-j474s.dts +5 -0
@@ -46,4 +46,9 @@ &pcie0 { <0x300 &pcie0_dart_3 1 1>; }; +&sound { + compatible = "apple,j474-macaudio", "apple,j473-macaudio"; + model = "Mac mini J474"; +}; + #include "hwmon-mini.dtsi"
arch/arm64/boot/dts/apple/t6021-j475c.dts +5 -0
@@ -36,4 +36,9 @@ &pcie0_dart_1 { status = "okay"; }; +&sound { + compatible = "apple,j475-macaudio", "apple,j375-macaudio"; + model = "Mac Studio J475"; +}; + #include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t6022-j475d.dts +5 -0
@@ -73,3 +73,8 @@ &bluetooth0 { compatible = "pci14e4,5f72"; brcm,board-type = "apple,canary"; }; + +&sound { + compatible = "apple,j475-macaudio", "apple,j375-macaudio"; + model = "Mac Studio J475"; +};
arch/arm64/boot/dts/apple/t602x-j474-j475.dtsi +10 -0
@@ -36,3 +36,13 @@ &hpm2 { &hpm3 { interrupts = <44 IRQ_TYPE_LEVEL_LOW>; }; + +&speaker { + interrupts-extended = <&pinctrl_ap 58 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 57 GPIO_ACTIVE_HIGH>; +}; + +&jack_codec { + interrupts-extended = <&pinctrl_ap 59 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_nub 8 GPIO_ACTIVE_HIGH>; +};
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ASoC: dt-bindings: cs42l42: unconstrained #sound-dai-cells property --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ASoC: dt-bindings: cs42l42: unconstrained #sound-dai-cells property --
commit f47243ba9c859acd0c0960da3d01089789ab4531
Author: James Calligeros <[email protected]>
ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
This patch updates the cirrus,cs42l42 DT binding schema to reference dai-common.yaml and switch to unevaluatedProperties: false so that #sound-dai-cells and sound-name-prefix can be used.
Quoted 15 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected] +allOf: + - $ref: dai-common.yaml# + description: The CS42L42 is a low-power audio codec designed for portable applications. It provides a high-dynamic range, stereo DAC for audio playback and a mono
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml required: · line 199
Quoted 5 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +1
-1@@ -193,7 +196,7 @@ required: - VL-supply - VA-supply -additionalProperties: false +unevaluatedProperties: false
[Severity: Low]
As reported by Krzysztof Kozlowski on v3 [1], should #sound-dai-cells be constrained to const: 0 under properties in Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml?
Because Documentation/devicetree/bindings/sound/dai-common.yaml only defines #sound-dai-cells: true as a generic placeholder, referencing dai-common.yaml# in allOf with unevaluatedProperties: false without listing #sound-dai-cells under properties leaves the cell count unconstrained during schema validation.
Meanwhile, cs42l42_common_probe() in sound/soc/codecs/cs42l42.c registers a single DAI via devm_snd_soc_register_component(cs42l42->dev, component_drv, dai, 1) and cs42l42_soc_component does not implement .of_xlate_dai_name, so only #sound-dai-cells = <0> is supported by the driver.
[1] https://lore.kernel.org/r/20261019-overjoyed-outgoing-wren-4fdcc7@quoll
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v4 01/22] ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ASoC: dt-bindings: cs42l84: loss of #sound-dai-cells const: 0 constraint --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ASoC: dt-bindings: cs42l84: loss of #sound-dai-cells const: 0 constraint --
commit 51c8f9a50da0d86d550f375ea1f80d7bccc11075
Author: James Calligeros <[email protected]>
ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
This patch updates the cirrus,cs42l84 Devicetree binding schema to reference dai-common.yaml, switches additionalProperties to unevaluatedProperties, and removes the explicit #sound-dai-cells property definition.
Quoted 23 lines
ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many and set #sound-dai-cells. Allow this by allowing referenced properties from
dai-common.yaml.Signed-off-by James Calligeros <[email protected]>Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC maintainers: - Martin Povišer <[email protected]> +allOf: + - $ref: dai-common.yaml# + description: | The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded in personal computers sold by Apple. It was first seen in 2021 Macbook
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml properties: · line 34
Quoted 6 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +0
-3@@ -29,14 +32,11 @@ properties: interrupts: maxItems: 1 - '#sound-dai-cells': - const: 0 -
[Severity: Low]
Does removing the const: 0 constraint on #sound-dai-cells weaken schema validation for cirrus,cs42l84 nodes?
Documentation/devicetree/bindings/sound/dai-common.yaml only sets:
properties:
'#sound-dai-cells': true
However, the CS42L84 driver in sound/soc/codecs/cs42l84.c registers only a single DAI in cs42l84_i2c_probe():
ret = devm_snd_soc_register_component(&i2c_client->dev,
&soc_component_dev_cs42l84, &cs42l84_dai, 1);
Without const: 0 in cirrus,cs42l84.yaml, dtbs_check will allow non-zero #sound-dai-cells values even though the codec only supports 0 cells.
Also, since cirrus,cs42l84.yaml already permitted #sound-dai-cells prior to this change, should the commit message be updated so it does not claim that referencing dai-common.yaml is needed to allow setting #sound-dai-cells, and should '#sound-dai-cells': const: 0 be retained here?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH v4 04/22] ASoC: dt-bindings: Add binding for Apple Silicon Mac audio
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ASoC: dt-bindings: apple,macaudio: drop unnecessary #address-cells/#size-cells --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ASoC: dt-bindings: apple,macaudio: drop unnecessary #address-cells/#size-cells --
commit 7babcc38fd08c53ef9be38d7c4acfca64730a1a5
Author: Martin Povišer <[email protected]>
ASoC: dt-bindings: Add binding for Apple Silicon Mac audio
This commit adds a Devicetree binding schema for the primary audio subsystem found on Apple Silicon Macs, integrating the SoC I2S peripheral and codecs for the headphone jack and speaker arrays.
Quoted 6 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +0
-0@@ -0,0 +1,195 @@
[ ... ]
Quoted 18 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +18
-0+ "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + model: + description: + Model name for presentation to users + $ref: /schemas/types.yaml#/definitions/string + +patternProperties: + "^([a-z]+-)?dai-link$": + description: Node for each sound peripheral such as the speaker array, + headphones jack, or microphone. + type: object + $ref: tdm-slot.yaml# + unevaluatedProperties: false
[ ... ]
Documentation/devicetree/bindings/sound/apple,macaudio.yaml line 149
Quoted 5 lines
Documentation/devicetree/bindings/sound/apple,macaudio.yaml new file +5
-0+required: + - '#address-cells' + - '#size-cells' + - compatible + - model
[Severity: Low]
Are #address-cells and #size-cells needed in this binding?
The only child nodes permitted under the sound node match the pattern ^([a-z]+-)?dai-link$ with unevaluatedProperties: false, which forbids unit addresses in the child node names and disallows reg and ranges properties on the child nodes. The parent sound node also sets additionalProperties:
false without allowing ranges or dma-ranges.
Because these properties are marked as required, any conforming devicetree source file will trigger a dtc avoid_unnecessary_addr_size warning when compiled with W=1 in scripts/dtc/checks.c:check_avoid_unnecessary_addr_size():
FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" or \"ranges\" property");
Should #address-cells and #size-cells be dropped from properties, required, and examples in Documentation/devicetree/bindings/sound/apple,macaudio.yaml?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v4 06/22] ASoC: ops: Introduce 'soc_set_enum_kctl'
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] ASoC: ops: return value mismatch with kernel-doc in snd_soc_set_enum_kctl() - [Low] ASoC: ops…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ASoC: ops: return value mismatch with kernel-doc in snd_soc_set_enum_kctl()
- [Low] ASoC: ops: commit subject names static helper instead of snd_soc_set_enum_kctl() --
commit 2c9f602d361cf2e55c7e8d05183ffda527ff209d
Author: Martin Povišer <[email protected]>
ASoC: ops: Introduce 'soc_set_enum_kctl'
This commit introduces snd_soc_set_enum_kctl() and its internal helper soc_set_enum_kctl() so machine drivers can set enumerated ALSA controls to a desired string value, such as during fixup_controls.
Quoted 7 lines
ASoC: ops: Introduce '
soc_set_enum_kctl'The new function is to be used to set enumerated controls to desired values. It is something a machine driver may call in
fixup_controls.Signed-off-by Martin Povišer <[email protected]>Signed-off-by James Calligeros <[email protected]>
[Severity: Low]
Should the commit subject refer to snd_soc_set_enum_kctl instead of soc_set_enum_kctl?
In sound/soc/soc-ops.c, soc_set_enum_kctl() is a file-local static helper, whereas snd_soc_set_enum_kctl() is the exported function declared in include/sound/soc.h for machine drivers to call in fixup_controls.
Quoted 10 lines
sound/soc/soc-ops.c +2
-0@@ -505,6 +505,73 @@ int snd_soc_ctl_activate(struct snd_soc_card *card, }EXPORT_SYMBOL_GPL (snd_soc_ctl_activate); +static int soc_set_enum_kctl (struct snd_kcontrol *kctl,const char *value) +{
[ ... ]
Quoted 18 lines
sound/soc/soc-ops.c +18
-0+for (i =0 ; i < info->count; i++) + evalue->value.enumerated.item[i] = sel; + +return kctl->put (kctl, evalue); +} + +/** +* snd_soc_set_enum_kctl - Set enumerated control matching a name +* +* @card: where to look for the controls +* @name: name +* @value: string value to set the controls to +* +* Return 0 on success, else error. +*/ +int snd_soc_set_enum_kctl (struct snd_soc_card *card, +const char *name,const char *value) +{
sound/soc/soc-ops.c int snd_soc_ctl_activate(struct snd_soc_card *card, · line 572
Quoted 10 lines
sound/soc/soc-ops.c +10
-0+struct snd_kcontrol *kctl; + + kctl =snd_soc_card_get_kcontrol (card, name); +if (!kctl) { +dev_dbg (card->dev,"Tried to set unknown control '%s' to '%s'\n" , name, value); +return -EINVAL ; + } + +return soc_set_enum_kctl (kctl, value); +}
[Severity: Medium]
Does snd_soc_set_enum_kctl() return 1 instead of 0 when the control value is updated, contradicting its kernel-doc comment?
When snd_soc_set_enum_kctl() calls soc_set_enum_kctl() to change an enumerated control to a value different from its current state, soc_set_enum_kctl() directly returns the result of kctl->put(kctl, evalue). In ALSA and ASoC, snd_kcontrol_put_t callbacks such as snd_soc_put_enum_double() and snd_soc_dapm_put_enum_double() return 1 when the control value changes, 0 when it is unchanged, and a negative error code on failure. Any caller checking for a non-zero return value based on the documented contract would treat a changed control value as an error.
In the same file, snd_soc_clip_to_platform_max() normalizes the kctl->put() return value to 0:
sound/soc/soc-ops.c:snd_soc_clip_to_platform_max() {
...
ret = kctl->put(kctl, uctl);
if (ret < 0)
return ret;
return 0;
}whereas snd_soc_ctl_activate() documents the tri-state return value with a colon after Return as expected by kernel-doc:
* Return: 0 if unchanged, 1 if changed, or a negative error code on failure.
Should soc_set_enum_kctl() clamp non-negative returns from kctl->put() to 0, or should the kernel-doc Return: section for snd_soc_set_enum_kctl() document that it returns 0 if unchanged, 1 if changed, or a negative error code on failure?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH v4 11/22] arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] arm64: dts: apple: t8103-j274: unnecessary #address-cells/#size-cells in sound - [Low] arm64: dts…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] arm64: dts: apple: t8103-j274: unnecessary #address-cells/#size-cells in sound
- [Low] arm64: dts: apple: t8103-j274: duplicate &i2c2 and root node blocks --
commit 5f98a7f1339930a19f607ba0ee5a326410be0b76
Author: James Calligeros <[email protected]>
arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes
This commit adds the TI TAS5770L speaker amplifier and Cirrus CS42L83 headset jack codec nodes to the M1 Mac mini (J274) device tree, along with the sound node linking them to the MCA controller.
Quoted 27 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +19
-0@@ -75,4 +75,74 @@ &i2c2 { status = "okay"; }; +/* Audio codecs */ +&i2c1 { + status = "okay"; + + speaker: codec@31 { + compatible = "ti,tas5770l"; + reg = <0x31>; + interrupts-extended = <&pinctrl_ap 182 IRQ_TYPE_LEVEL_LOW>; + shutdown-gpios = <&pinctrl_ap 181 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; +}; + +&i2c2 { + status = "okay"; + + jack_codec: codec@48 {
[ ... ]
arch/arm64/boot/dts/apple/t8103-j274.dts &i2c2 { · line 114
Quoted 4 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +4
-0+ }; +}; + +/ {
[Severity: Low]
As reported by Sashiko on v3 [1], arch/arm64/boot/dts/apple/t8103-j274.dts already has an &i2c2 block just above &i2c1 that sets status = "okay", as well as a root / { ... }; node at the top of the file:
/ {
compatible = "apple,j274", "apple,t8103", "apple,arm-platform";
model = "Apple Mac mini (M1, 2020)";
chassis-type = "desktop";
aliases {
ethernet0 = ðernet0;
};
};Could jack_codec be placed inside the existing &i2c2 block (or replace the earlier stub) and the sound node be placed inside the existing root / node instead of opening duplicate &i2c2 and / blocks in the same file?
arch/arm64/boot/dts/apple/t8103-j274.dts &i2c2 { · line 120
Quoted 6 lines
arch/arm64/boot/dts/apple/t8103-j274.dts +6
-0+ sound: sound { + compatible = "apple,j274-macaudio"; + model = "Mac mini J274"; + + #address-cells = <1>; + #size-cells = <0>;
[Severity: Low]
Does defining #address-cells and #size-cells in the sound node trigger a dtc avoid_unnecessary_addr_size warning when building dtbs with W=1?
Neither the sound node nor its headphone-dai-link and speaker-dai-link child nodes define reg, ranges, or dma-ranges properties, which causes check_avoid_unnecessary_addr_size() in scripts/dtc/checks.c to warn:
FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" or \"ranges\" property");
Should #address-cells and #size-cells be removed from both the sound node here and Documentation/devicetree/bindings/sound/apple,macaudio.yaml?
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
[email protected]
AI reviewRe: [PATCH v4 09/22] ASoC: apple: Add macaudio machine driver
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [High] ASoC: apple: macaudio: AB-BA deadlock in macaudio_vlimit_update() - [High] ASoC: apple: macaudio…
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] ASoC: apple: macaudio: AB-BA deadlock in macaudio_vlimit_update()
- [High] ASoC: apple: macaudio: UAF from canceling works after card teardown
- [High] ASoC: apple: macaudio: zeroing rate in macaudio_dpcm_hw_params()
- [High] ASoC: apple: macaudio: sleeping mutex lock in DMA tasklet via nonatomic links
- [Medium] ASoC: apple: macaudio: leak of DAI link OF nodes on unbind and error
- [Medium] ASoC: apple: macaudio: overwritten error in macaudio_be_assign_tdm()
- [Medium] ASoC: apple: macaudio: timeout race with cancel_delayed_work() --
commit 2cdf88f52057f61693fcf4754466c5850f0fe004
Author: Martin Povišer <[email protected]>
ASoC: apple: Add macaudio machine driver
This commit adds an ASoC machine driver for Apple Silicon Macs, linking MCA I2S ports and multiple speaker/headset codecs as DPCM backends to synthetic frontends, along with speaker volume safety limiting and jack detection.
Quoted 5 lines
sound/soc/apple/macaudio.c new file +0
-0
[ ... ]
Quoted 13 lines
sound/soc/apple/macaudio.c new file +13
-0+static void macaudio_vlimit_update (struct macaudio_snd_data *ma,bool take_rwsem) +{ +bool unlock = true; +const char *reason; + +/* Do nothing if there is no safety configured */ +if (!ma->has_safety) +return ; + +/* Check that the control has been pinged within the timeout */ +if (ma->speaker_lock_remain <=0 ) { + reason ="Lock timeout" ; + unlock = false;
sound/soc/apple/macaudio.c line 307
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+ } + +/* +* If this has been called from either of the safety interlock +* workqueues, the core API has not taken controls_rwsem for us. +* Take the write semaphore since macaudio_vlimit_unlock writes +* to the kcontrols. +*/ +if (take_rwsem) +down_write (&ma->card.snd_card->controls_rwsem);
[Severity: High]
As reported by Sashiko on v3 [1], can this lock ordering in macaudio_vlimit_update() cause an AB-BA deadlock between the ALSA control write path and the speaker volume-limit workqueue handlers?
When userspace writes to the Speaker Volume Unlock mixer control via snd_ctl_elem_write(), the ALSA core acquires controls_rwsem for write before calling macaudio_slk_put(), which then acquires ma->volume_lock_mutex:
snd_ctl_elem_write()
down_write(&card->controls_rwsem)
macaudio_slk_put()
guard(mutex)(&ma->volume_lock_mutex)Conversely, when macaudio_vlimit_enable_timeout(), macaudio_vlimit_disable_timeout(), or macaudio_vlimit_timeout_work() runs from workqueue context, each function acquires ma->volume_lock_mutex first and then calls macaudio_vlimit_update(ma, true), which takes controls_rwsem:
macaudio_vlimit_timeout_work()
guard(mutex)(&ma->volume_lock_mutex)
macaudio_vlimit_update(ma, true)
down_write(&ma->card.snd_card->controls_rwsem)If a control write races with either workqueue handler, could the two threads deadlock waiting on each other's lock?
Quoted 18 lines
sound/soc/apple/macaudio.c new file +18
-0+ +if (unlock != ma->speaker_volume_unlocked) { +if (unlock) { +dev_info (ma->card.dev,"Speaker volumes unlocked\n" ); + }else { +dev_info (ma->card.dev,"Speaker volumes locked: %s\n" , reason); + ma->speaker_volume_was_locked = true; + } + +macaudio_vlimit_unlock (ma, unlock); + ma->speaker_volume_unlocked = unlock; +snd_ctl_notify (ma->card.snd_card,SNDRV_CTL_EVENT_MASK_VALUE , + &ma->speaker_lock_kctl->id); + } + +if (take_rwsem) +up_write (&ma->card.snd_card->controls_rwsem); +}
[ ... ]
Quoted 26 lines
sound/soc/apple/macaudio.c new file +26
-0+static void macaudio_vlimit_disable_timeout (struct macaudio_snd_data *ma) +{ +ktime_t now; + +guard (mutex)(&ma->volume_lock_mutex); + +if (!ma->speaker_lock_timeout_enabled) { +return ; + } + + now =ktime_get (); + +cancel_delayed_work (&ma->lock_timeout_work); + +if (ktime_after (now, ma->speaker_lock_timeout)) + ma->speaker_lock_remain =0 ; +else if (ma->speaker_lock_remain >0 ) + ma->speaker_lock_remain =ktime_sub (ma->speaker_lock_timeout, now); + +dev_dbg (ma->card.dev,"Disabling volume limit timeout: %ld us left\n" , + (long )ktime_to_us (ma->speaker_lock_remain)); + +macaudio_vlimit_update (ma, true); + + ma->speaker_lock_timeout_enabled = false; +}
sound/soc/apple/macaudio.c line 383
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+ +static void macaudio_vlimit_timeout_work (struct work_struct *wrk) +{ +struct macaudio_snd_data *ma =container_of (to_delayed_work (wrk), + struct macaudio_snd_data, lock_timeout_work); + +guard (mutex)(&ma->volume_lock_mutex); + ma->speaker_lock_remain =0 ; +macaudio_vlimit_update (ma, true); +}
[Severity: Medium]
As reported by Sashiko on v3 [2], what happens if lock_timeout_work expires just as macaudio_slk_put() or macaudio_vlimit_disable_timeout() acquires ma->volume_lock_mutex?
If macaudio_vlimit_timeout_work() has already been dispatched and is waiting on guard(mutex)(&ma->volume_lock_mutex), the non-synchronous cancel_delayed_work(&ma->lock_timeout_work) calls in macaudio_slk_put() and macaudio_vlimit_disable_timeout() will not stop it.
Once macaudio_slk_put() refreshes ma->speaker_lock_remain and releases ma->volume_lock_mutex (or macaudio_vlimit_disable_timeout() disables the timeout and releases the mutex), wouldn't macaudio_vlimit_timeout_work() immediately acquire ma->volume_lock_mutex, unconditionally zero ma->speaker_lock_remain, and lock the speaker volumes?
[ ... ]
Quoted 22 lines
sound/soc/apple/macaudio.c new file +22
-0+static int macaudio_dpcm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream); +struct macaudio_snd_data *ma =snd_soc_card_get_drvdata (rtd->card); +struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id]; +struct snd_soc_dai *cpu_dai =snd_soc_rtd_to_cpu (rtd,0 ); +struct snd_interval *rate =hw_param_interval (params, +SNDRV_PCM_HW_PARAM_RATE ); +int bclk_ratio =macaudio_get_runtime_bclk_ratio (substream); +int i; + +if (props->is_sense) { +/* +* The sense FE is opened exclusively by speakersafetyd in blocking +* mode. At the time of opening, this sample rate may be 0 if the +* speaker BE is not running. This does not matter, as speakersafetyd +* only cares about the active sample rate exported to the virtual +* sample rate kcontrol below. +*/ + rate->min = rate->max = cpu_dai->symmetric_rate; +return 0 ;
sound/soc/apple/macaudio.c line 819
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+ } + +/* Speakers BE */ +if (props->is_speakers) { +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE ) { +/* Sense PCM: keep the existing BE rate (0 if not already running) */ + rate->min = rate->max = cpu_dai->symmetric_rate; + +return 0 ; + }
[Severity: High]
As reported by Mark Brown on v1 [3], can setting rate->min = rate->max = cpu_dai->symmetric_rate on the Speaker Sense capture paths corrupt the PCM runtime rate and fail when speaker playback is not active?
First, on the Speaker BE capture path (props->is_speakers && substream->stream == SNDRV_PCM_STREAM_CAPTURE), if speaker playback is not running yet, cpu_dai->symmetric_rate is 0. Overwriting the BE hw_params rate with 0 causes the codec hw_params callback (such as tas2764_hw_params() or tas2770_hw_params()) to see params_rate(params) == 0 and fail with -EINVAL.
Second, on the Speaker Sense FE path (props->is_sense), macaudio_fe_hw_params() passes the FE substream's struct snd_pcm_hw_params directly to macaudio_dpcm_hw_params(). Because the Sense FE's CPU DAI (mca-pcm-2) is capture-only and distinct from the Speaker BE CPU DAI, its cpu_dai->symmetric_rate remains 0 even when speaker playback is running.
When dpcm_fe_dai_hw_params() returns to snd_pcm_hw_params(), doesn't runtime->rate = params_rate(params) set runtime->rate to 0, triggering snd_BUG_ON(!rate) in snd_pcm_timer_resolution_change() and a division by zero in snd_pcm_post_start() at (runtime->buffer_size * HZ) / runtime->rate?
[ ... ]
sound/soc/apple/macaudio.c line 952
Quoted 9 lines
sound/soc/apple/macaudio.c new file +9
-0+static int macaudio_be_trigger (struct snd_pcm_substream *substream,int cmd) +{ +struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream); +struct macaudio_snd_data *ma =snd_soc_card_get_drvdata (rtd->card); +struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id]; + +/* Speaker link is marked nonatomic */ +if (props->is_speakers && substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + scoped_guard(mutex, &ma->be_link_mutex) {
[Severity: High]
As reported by Ajay Kumar Nandam on v2 [4], does marking the Secondary FE, Speaker Sense FE, and Speaker BE DAI links as nonatomic cause sleeping in atomic context during DMA completion?
In macaudio_fe_links and macaudio_parse_of(), .nonatomic = 1 is set on these DAI links, which causes soc_new_pcm() to set pcm->nonatomic = true. However, the MCA platform driver (sound/soc/apple/mca.c) uses generic dmaengine PCM with the Apple ADMAC controller (drivers/dma/apple-admac.c), which invokes dmaengine_pcm_dma_complete() from admac_chan_tasklet() in softirq context:
admac_chan_tasklet() [softirq]
dmaengine_pcm_dma_complete()
snd_pcm_period_elapsed()
_snd_pcm_stream_lock_irqsave()
mutex_lock(&substream->self_group.mutex)Furthermore, if an XRUN or drain stop occurs inside snd_pcm_period_elapsed_under_stream_lock(), it triggers the PCM stop path from that same tasklet, which calls macaudio_be_trigger() and acquires ma->be_link_mutex in softirq context.
Should the DAI links remain atomic and macaudio_be_trigger() avoid sleeping locks, or how should this interact with ADMAC's tasklet completion path?
Quoted 22 lines
sound/soc/apple/macaudio.c new file +22
-0+switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_RESUME : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : + ma->bes_active |=BIT (rtd->dai_link->id); +break ; +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_STOP : + ma->bes_active &= ~BIT (rtd->dai_link->id); +break ; +default : +return -EINVAL ; + } + } + +if (ma->has_safety) +schedule_work (&ma->lock_update_work); + } + +return 0 ; +}
[ ... ]
Quoted 19 lines
sound/soc/apple/macaudio.c new file +19
-0+static int macaudio_be_assign_tdm (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_card *card = rtd->card; +struct macaudio_snd_data *ma =snd_soc_card_get_drvdata (card); +struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id]; +struct snd_soc_dai *dai; +unsigned int mask; +int nslots, ret, i; + +if (!props->tdm_mask) +return 0 ; + + mask = props->tdm_mask; + nslots =__fls (mask) +1 ; + +if (rtd->dai_link->num_codecs ==1 ) { + dai =snd_soc_rtd_to_codec (rtd,0 ); + ret =snd_soc_dai_set_tdm_slot (dai, mask,0 , nslots,MACAUDIO_SLOTWIDTH ); +
sound/soc/apple/macaudio.c line 1017
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+/* +* Headphones get a pass on -ENOTSUPP (see the comment +* around bclk_ratio value for primary FE). +*/ +if (ret == -ENOTSUPP && props->is_headphones) +return 0 ; + +if (props->codecs[0 ].idle_mode) { + ret =snd_soc_dai_set_tdm_idle (dai, props->codecs[0 ].idle_mask, +0 , props->codecs[0 ].idle_mode,0 );
[Severity: Medium]
In macaudio_be_assign_tdm(), when rtd->dai_link->num_codecs == 1 and snd_soc_dai_set_tdm_slot() returns an error other than -ENOTSUPP on headphones, shouldn't this return ret before checking props->codecs[0].idle_mode?
As written, if props->codecs[0].idle_mode is set, the error in ret from snd_soc_dai_set_tdm_slot() is overwritten by snd_soc_dai_set_tdm_idle().
[ ... ]
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+static void macaudio_devm_release (void *data) +{ +struct macaudio_snd_data *ma = data; + +cancel_work_sync (&ma->lock_update_work); +cancel_delayed_work_sync (&ma->lock_timeout_work); +} + +static int macaudio_snd_platform_probe (struct platform_device *pdev) +{
[ ... ]
Quoted 6 lines
sound/soc/apple/macaudio.c new file +6
-0+INIT_WORK (&data->lock_update_work, macaudio_vlimit_update_work); +INIT_DELAYED_WORK (&data->lock_timeout_work, macaudio_vlimit_timeout_work); + + ret =devm_add_action (dev, macaudio_devm_release, data); +if (ret) +return ret;
sound/soc/apple/macaudio.c line 1717
Quoted 10 lines
sound/soc/apple/macaudio.c new file +10
-0+ + ret =devm_snd_soc_register_card (dev, &data->card); +if (ret) { +for_each_card_prelinks (&data->card, i, link) { +snd_soc_of_put_dai_link_codecs (link); +snd_soc_of_put_dai_link_cpus (link); + } + +return ret; + }
[Severity: High]
As reported by Sashiko on v3 [5], can registering macaudio_devm_release() before devm_snd_soc_register_card() lead to a use-after-free or NULL pointer dereference of ma->card.snd_card and ma->speaker_lock_kctl in workqueue context during card teardown?
Because devres actions run in reverse order on driver unbind (and devm_snd_soc_bind_card() registers devm_card_bind_release() when the card binds), soc_cleanup_card_resources() runs before macaudio_devm_release() cancels lock_update_work and lock_timeout_work. Similarly, if a component device unbinds while macaudio stays bound, snd_soc_unbind_card() runs soc_cleanup_card_resources() without triggering macaudio_devm_release() at all.
During soc_cleanup_card_resources(), snd_card_disconnect_sync() stops active PCM streams, which calls macaudio_be_trigger() with SNDRV_PCM_TRIGGER_STOP and schedules ma->lock_update_work. soc_cleanup_card_resources() then frees all kcontrols (including ma->speaker_lock_kctl), frees card->snd_card, and sets card->snd_card = NULL.
If lock_update_work or lock_timeout_work executes before macaudio_devm_release() runs, won't macaudio_vlimit_update() and macaudio_vlimit_unlock() dereference ma->card.snd_card and ma->speaker_lock_kctl after they have been freed?
[Severity: Medium]
As reported by Sashiko on v3 [6], does macaudio_snd_platform_probe() leak the backend CPU and CODEC device_node references acquired in macaudio_parse_of_component() when the driver is later unbound or if devm_add_action() fails?
In macaudio_snd_platform_probe(), snd_soc_of_put_dai_link_codecs() and snd_soc_of_put_dai_link_cpus() are only called when devm_snd_soc_register_card() fails, and are not called in macaudio_devm_release() or on the devm_add_action() error path.
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]
[4] https://lore.kernel.org/r/[email protected]
[5] https://lore.kernel.org/r/[email protected]
[6] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
[email protected]
AI reviewRe: [PATCH v4 12/22] arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] ASoC: apple: macaudio: OF ref leak and devres order in macaudio_devm_release() - [Medium] ASoC…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] ASoC: apple: macaudio: OF ref leak and devres order in macaudio_devm_release()
- [Medium] ASoC: tas2770: tas2770_set_dai_tdm_idle() treats positive return as error
- [Medium] ASoC: apple: macaudio: macaudio_be_assign_tdm() overwrites slot error
- [Low] arm64: dts: apple: t8103-j313: unused #address-cells/#size-cells in sound --
commit dd4cb33fc5a853fd54101899a161b5d0c84f160e
Author: James Calligeros <[email protected]>
arm64: dts: apple: t8103-j313: Add speaker/headset jack nodes
This commit adds the TI TAS5770L speaker amplifier and Cirrus CS42L83 headset jack codec device tree nodes for the M1 MacBook Air (J313), along with the sound node advertising them to the macaudio machine driver.
Quoted 5 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +0
-0@@ -55,4 +55,89 @@ &typec1 {
[ ... ]
arch/arm64/boot/dts/apple/t8103-j313.dts &typec1 { · line 109
Quoted 4 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +4
-0+/ { + sound: sound { + compatible = "apple,j313-macaudio"; + model = "MacBook Air J313";
[Severity: High]
As reported by Sashiko on v3 [1], when this apple,j313-macaudio node binds to macaudio_snd_driver, does macaudio_snd_platform_probe() in sound/soc/apple/macaudio.c leak the backend DAI link CPU and CODEC device_node references on unbind or if devm_add_action() fails, and can the devres registration order cause macaudio_vlimit_update() to dereference a NULL ma->card.snd_card during unbind?
During probe, macaudio_parse_of() -> macaudio_parse_of_be_dai_link() -> macaudio_parse_of_component() acquires device_node references via of_parse_phandle_with_args() for the CPU and CODEC DAIs. In macaudio_snd_platform_probe():
sound/soc/apple/macaudio.c:macaudio_snd_platform_probe() {
...
ret = devm_add_action(dev, macaudio_devm_release, data);
if (ret)
return ret;
ret = devm_snd_soc_register_card(dev, &data->card);
if (ret) {
for_each_card_prelinks(&data->card, i, link) {
snd_soc_of_put_dai_link_codecs(link);
snd_soc_of_put_dai_link_cpus(link);
}
return ret;
}
}If devm_add_action() fails, macaudio_snd_platform_probe() returns without releasing the DAI link CPU and CODEC device_node references. Likewise, when probe succeeds and the device is later unbound, neither ASoC core teardown nor macaudio_devm_release() calls snd_soc_of_put_dai_link_codecs() and snd_soc_of_put_dai_link_cpus():
sound/soc/apple/macaudio.c:macaudio_devm_release() {
struct macaudio_snd_data *ma = data;
cancel_work_sync(&ma->lock_update_work);
cancel_delayed_work_sync(&ma->lock_timeout_work);
}In addition, because devm_add_action(dev, macaudio_devm_release, data) is registered before devm_snd_soc_register_card(), devres LIFO teardown runs devm_card_bind_release() -> snd_soc_unregister_card() -> soc_cleanup_card_resources() first, which frees card->snd_card and sets it to NULL before macaudio_devm_release() cancels lock_update_work and lock_timeout_work. If either work item runs during teardown, macaudio_vlimit_update() accesses ma->card.snd_card->controls_rwsem:
sound/soc/apple/macaudio.c:macaudio_vlimit_update() {
...
if (take_rwsem)
down_write(&ma->card.snd_card->controls_rwsem);
}arch/arm64/boot/dts/apple/t8103-j313.dts &typec1 { · line 112
Quoted 3 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +3
-0+ + #address-cells = <1>; + #size-cells = <0>;
[Severity: Low]
Will defining #address-cells and #size-cells on the sound node trigger a dtc avoid_unnecessary_addr_size warning when building with W=1?
Neither headphone-dai-link nor speaker-dai-link uses a reg or ranges property (and Documentation/devicetree/bindings/sound/apple,macaudio.yaml does not define reg on child dai-link nodes despite listing #address-cells and #size-cells in required), which causes check_avoid_unnecessary_addr_size() in scripts/dtc/checks.c to warn under W=1.
Also, since arch/arm64/boot/dts/apple/t8103-j313.dts already has a root / { ... }; block at the top of the file, should the sound node be placed in that existing root node block rather than opening a second / { ... }; block after the phandle overrides?
Quoted 6 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +6
-0+ + headphone-dai-link { + link-name = "Headphone Jack"; + + codec { + sound-dai = <&jack_codec>;
arch/arm64/boot/dts/apple/t8103-j313.dts &typec1 { · line 128
Quoted 10 lines
arch/arm64/boot/dts/apple/t8103-j313.dts +10
-0+ }; + + cpu { + sound-dai = <&mca 2>; + }; + }; + + speaker-dai-link { + dai-tdm-idle-mode-0 = "zero"; + dai-tdm-idle-mode-1 = "zero";
[Severity: Medium]
When speaker-dai-link sets dai-tdm-idle-mode-0 and dai-tdm-idle-mode-1 to "zero" for the two ti,tas5770l codecs, will tas2770_set_dai_tdm_idle() fail to complete the TDM idle setup and cause macaudio_be_assign_tdm() to fail?
During backend initialization, macaudio_be_init() -> macaudio_be_assign_tdm() calls snd_soc_dai_set_tdm_idle() with SND_SOC_DAI_TDM_IDLE_ZERO, which dispatches to tas2770_set_dai_tdm_idle() in sound/soc/codecs/tas2770.c:
sound/soc/codecs/tas2770.c:tas2770_set_dai_tdm_idle() {
...
case SND_SOC_DAI_TDM_IDLE_ZERO:
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG4,
TAS2770_TDM_CFG_REG4_TX_KEEPER,
TAS2770_TDM_CFG_REG4_TX_KEEPER);
if (ret)
return ret;
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG4,
TAS2770_TDM_CFG_REG4_TX_FILL, 0);
if (ret)
return ret;
break;
}Because snd_soc_component_update_bits() returns 1 when the register value changes, 0 when unchanged, and a negative errno on error, setting TAS2770_TDM_CFG_REG4_TX_KEEPER after reset returns 1. Checking if (ret) instead of if (ret < 0) causes tas2770_set_dai_tdm_idle() to return 1 early without clearing TAS2770_TDM_CFG_REG4_TX_FILL or updating tas2770->idle_tx_mode.
In sound/soc/apple/macaudio.c, macaudio_be_assign_tdm() then checks if (ret) on the return value of snd_soc_dai_set_tdm_idle():
sound/soc/apple/macaudio.c:macaudio_be_assign_tdm() {
...
if (props->codecs[0].idle_mode) {
ret = snd_soc_dai_set_tdm_idle(dai, props->codecs[0].idle_mask,
0, props->codecs[0].idle_mode, 0);
if (ret) {
dev_err(card->dev, "Failed to set idle props for codec\n");
return ret;
}
}
}Won't this treat the positive return value 1 as an error and log "Failed to set idle props for codec" when initializing speaker_left and speaker_right?
[Severity: Medium]
In the same single-codec branch of macaudio_be_assign_tdm() in sound/soc/apple/macaudio.c (used for each of the two CPU/CODEC pairs in speaker-dai-link), can a failure from snd_soc_dai_set_tdm_slot() be overwritten when props->codecs[0].idle_mode is set?
Looking at macaudio_be_assign_tdm():
sound/soc/apple/macaudio.c:macaudio_be_assign_tdm() {
if (rtd->dai_link->num_codecs == 1) {
dai = snd_soc_rtd_to_codec(rtd, 0);
ret = snd_soc_dai_set_tdm_slot(dai, mask, 0, nslots, MACAUDIO_SLOTWIDTH);
/*
* Headphones get a pass on -ENOTSUPP (see the comment
* around bclk_ratio value for primary FE).
*/
if (ret == -ENOTSUPP && props->is_headphones)
return 0;
if (props->codecs[0].idle_mode) {
ret = snd_soc_dai_set_tdm_idle(dai, props->codecs[0].idle_mask,
0, props->codecs[0].idle_mode, 0);
if (ret) {
dev_err(card->dev, "Failed to set idle props for codec\n");
return ret;
}
}
return ret;
}
}Unlike the multi-codec loop below it (which checks if (ret) return ret; immediately after snd_soc_dai_set_tdm_slot()), the num_codecs == 1 path does not check ret before entering if (props->codecs[0].idle_mode), so snd_soc_dai_set_tdm_idle() overwrites any negative error returned by snd_soc_dai_set_tdm_slot().
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
[email protected]
AI reviewRe: [PATCH v4 13/22] arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes
In reply to James CalligerosThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] arm64: dts: apple: unnecessary #address-cells/#size-cells in j293 sound node - [Low] arm64: dts…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] arm64: dts: apple: unnecessary #address-cells/#size-cells in j293 sound node
- [Low] arm64: dts: apple: duplicate &i2c2 and root node blocks in t8103-j293.dts --
commit 7afed482bafffba735ddfd1d14a91b354bbef084
Author: James Calligeros <[email protected]>
arm64: dts: apple: t8103-j293: Add speaker/headset jack nodes
This commit adds device tree nodes for the TI TAS5770L speaker amplifiers and Cirrus Logic CS42L83 headset jack codec on the M1 MacBook Pro (J293), and wires them up to the macaudio sound card node.
Quoted 5 lines
arch/arm64/boot/dts/apple/t8103-j293.dts +0
-0@@ -133,5 +133,119 @@ &displaydfr_dart {
[ ... ]
arch/arm64/boot/dts/apple/t8103-j293.dts &displaydfr_dart { · line 166
Quoted 4 lines
+&i2c2 {
arch/arm64/boot/dts/apple/t8103-j293.dts +3
-0+ status = "okay"; + + jack_codec: codec@48 {
[Severity: Low]
This isn't a bug, but arch/arm64/boot/dts/apple/t8103-j293.dts already has an earlier &i2c2 reference that sets status = "okay", as well as an existing root / node at the top of the file:
arch/arm64/boot/dts/apple/t8103-j293.dts:
/ {
compatible = "apple,j293", "apple,t8103", "apple,arm-platform";
...
};
...
&i2c2 {
status = "okay";
};Could the earlier &i2c2 block be merged with this one and the sound node placed into the existing root node to avoid duplicating both blocks in the same file?
[ ... ]
arch/arm64/boot/dts/apple/t8103-j293.dts &displaydfr_dart { · line 216
Quoted 7 lines
arch/arm64/boot/dts/apple/t8103-j293.dts +7
-0+/ { + sound: sound { + compatible = "apple,j293-macaudio"; + model = "MacBook Pro J293"; + + #address-cells = <1>; + #size-cells = <0>;
[Severity: Low]
Does defining #address-cells and #size-cells in the sound node trigger a dtc avoid_unnecessary_addr_size warning when building DTBs with W=1?
Although Documentation/devicetree/bindings/sound/apple,macaudio.yaml lists #address-cells and #size-cells on the sound node, the child nodes (headphone-dai-link and speaker-dai-link) do not have reg or ranges properties, so check_avoid_unnecessary_addr_size() in scripts/dtc/checks.c warns on this node under W=1.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Re: [PATCH v4 01/22] ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
In reply to James CalligerosQuoted 24 lines · James Calligeros
Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many and set #sound-dai-cells. Allow this by allowing referenced properties from
dai-common.yaml.Signed-off-by James Calligeros <[email protected]>--- Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC maintainers: - Martin Povišer <[email protected]> +allOf: + - $ref: dai-common.yaml# + description: | The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded in personal computers sold by Apple. It was first seen in 2021 Macbook
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml properties: · line 33
Quoted 5 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +0
-2@@ -29,14 +32,11 @@ properties: interrupts: maxItems: 1 - '#sound-dai-cells': - const: 0
This should not be removed. Why cells of 1 would be correct? If so, explain in commit msg.
Best regards,
Krzysztof
Re: [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
In reply to James CalligerosQuoted 24 lines · James Calligeros
We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Allow this by refrencing
dai-common.yamland allowing its properties to be used.Signed-off-by James Calligeros <[email protected]>--- Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected] +allOf: + - $ref: dai-common.yaml# + description: The CS42L42 is a low-power audio codec designed for portable applications. It provides a high-dynamic range, stereo DAC for audio playback and a mono
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml required: · line 197
Quoted 2 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +0
-0@@ -193,7 +196,7 @@ required: - VL-supply - VA-supply
Missing dai-cells constraint
Best regards,
Krzysztof
Re: [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
Quoted 18 lines · Krzysztof Kozlowski
Quoted 17 lines · James Calligeros
We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Allow this by refrencing
dai-common.yamland allowing its properties to be used.Signed-off-by James Calligeros <[email protected]>--- Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +0
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected]
Quoted 11 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml required: · line 197
Quoted 9 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3
-0+allOf: + - $ref: dai-common.yaml# + description: The CS42L42 is a low-power audio codec designed for portable applications. It provides a high-dynamic range, stereo DAC for audio playback and a mono@@ -193,7 +196,7 @@ required: - VL-supply - VA-supplyMissing dai-cells constraint
Heh, I already asked for this two weeks ago.
I do not see how you responded to my comment, dropping everything from DT patchwork.
Best regards,
Krzysztof
Re: [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
Quoted 39 lines · Australian Eastern Standard Time Krzysztof Kozlowski
Quoted 32 lines · Krzysztof Kozlowski
Quoted 31 lines · James Calligeros
We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Allow this by refrencing
dai-common.yamland allowing its properties to be used.Signed-off-by James Calligeros <[email protected]>---
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/sound/cirrus,cs42l42.yamlindexab4c7d22dc0e..4ac0af34c464100644Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected] +allOf: + - $ref: dai-common.yaml# + description:The CS42L42 is a low-power audio codec designed for portable applications.
It provides a high-dynamic range, stereo DAC for audio playback and a monoQuoted 5 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml required: · line 197
Quoted 3 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +0
-0@@ -193,7 +196,7 @@ required: - VL-supply - VA-supplyMissing dai-cells constraint
Quoted 7 lines
Heh, I already asked for this two weeks ago.
I do not see how you responded to my comment, dropping everything from DT patchwork.
Best regards,
Krzysztof
Given that the binding did not have a constraint for this originally, it was my impression that adding one would best go in another patch unrelated to this series. If you think it's fine to add here then I can simply fix this for v5.
Re: [PATCH v4 01/22] ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties
In reply to Krzysztof KozlowskiQuoted 34 lines · Australian Eastern Standard Time Krzysztof Kozlowski
Quoted 33 lines · James Calligeros
Some consumers may wish to prepend the codec's name with a known value to identify a specific codec among many and set #sound-dai-cells. Allow this by allowing referenced properties from
dai-common.yaml.Signed-off-by James Calligeros <[email protected]>---
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/sound/cirrus,cs42l84.yamlindex94062c1d9d45..66cae8b7db5d100644Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L84 audio CODEC maintainers: - Martin Povišer <[email protected]> +allOf: + - $ref: dai-common.yaml# + description: |The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded in personal computers sold by Apple. It was first seen in 2021 Macbook
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +0
-0@@ -29,14 +32,11 @@ properties: interrupts: maxItems: 1
Quoted 5 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml properties: · line 33
Quoted 2 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml +0
-2- '#sound-dai-cells': - const: 0This should not be removed. Why cells of 1 would be correct? If so, explain in commit msg.
This was unintentional, already fixed for v5.
Quoted 3 lines
Best regards,
Krzysztof
James
Re: [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: Allow referenced dai-common properties
In reply to James CalligerosQuoted 46 lines · James Calligeros
Quoted 44 lines · Australian Eastern Standard Time Krzysztof Kozlowski
Quoted 32 lines · Krzysztof Kozlowski
Quoted 31 lines · James Calligeros
We may need to define both #sound-dai-cells and sound-name-prefix on some machines where this codec is part of a simple DAI. Allow this by refrencing
dai-common.yamland allowing its properties to be used.Signed-off-by James Calligeros <[email protected]>---
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/sound/cirrus,cs42l42.yamlindexab4c7d22dc0e..4ac0af34c464100644Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +3
-0@@ -9,6 +9,9 @@ title: Cirrus Logic CS42L42 audio CODEC maintainers: - [email protected] +allOf: + - $ref: dai-common.yaml# + description:The CS42L42 is a low-power audio codec designed for portable applications.
It provides a high-dynamic range, stereo DAC for audio playback and a monoQuoted 5 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml required: · line 197
Quoted 3 lines
Documentation/devicetree/bindings/sound/cirrus,cs42l42.yaml +0
-0@@ -193,7 +196,7 @@ required: - VL-supply - VA-supplyMissing dai-cells constraint
Heh, I already asked for this two weeks ago.
I do not see how you responded to my comment, dropping everything from DT patchwork.
Quoted 7 lines
Quoted 2 lines
Best regards,
KrzysztofGiven that the binding did not have a constraint for this originally, it was my impression that adding one would best go in another patch unrelated to this series. If you think it's fine to add here then I can simply fix this for v5.
Can be separate patch preceding this one, because adding constraint later would be an ABI break/impact.
Best regards,
Krzysztof
Mark Brown
maintainerRe: [PATCH v4 09/22] ASoC: apple: Add macaudio machine driver
In reply to James CalligerosQuoted 10 lines
Apple Silicon Macs have a complex audio subsystem consisting of an I2S peripheral (MCA) and multiple codecs of various models and capabilities. Some machines have a basic mono speaker with hardware downmix, while others have a very intricate stereo system consisting of multiple codecs and drivers per L/R channel. Some machines report voice coil voltage and current information back to the SoC, and others do not. All machines have a headset jack.
+#include <
sound/simple_card_utils.h>
This is unused.
sound/soc/apple/macaudio.c line 307
Quoted 13 lines
sound/soc/apple/macaudio.c new file +12
-0+static void macaudio_vlimit_update (struct macaudio_snd_data *ma,bool take_rwsem) +{ +bool unlock = true; +const char *reason; +/* +* If this has been called from either of the safety interlock +* workqueues, the core API has not taken controls_rwsem for us. +* Take the write semaphore since macaudio_vlimit_unlock writes +* to the kcontrols. +*/ +if (take_rwsem) +down_write (&ma->card.snd_card->controls_rwsem);
The callers with take_rwsem all have volume_lock_mutex. macaudio_slk_put() is called from snd_ctl_elem_write() which has controls_rwsem already so we end up with an ABBA deadlock.
sound/soc/apple/macaudio.c line 429
Quoted 11 lines
sound/soc/apple/macaudio.c new file +11
-0+static int macaudio_parse_of_component (struct device_node *node,int index, +struct snd_soc_dai_link_component *comp) +{ +struct of_phandle_args args; +int ret; + + ret =of_parse_phandle_with_args (node,"sound-dai" ,"#sound-dai-cells" , + index, &args); +if (ret) +return ret; + comp->of_node = args.np;
This gets cleaned up on failure but not on success.
sound/soc/apple/macaudio.c line 1014
Quoted 11 lines
sound/soc/apple/macaudio.c new file +10
-0+if (rtd->dai_link->num_codecs ==1 ) { + dai =snd_soc_rtd_to_codec (rtd,0 ); + ret =snd_soc_dai_set_tdm_slot (dai, mask,0 , nslots,MACAUDIO_SLOTWIDTH ); +/* +* Headphones get a pass on -ENOTSUPP (see the comment +* around bclk_ratio value for primary FE). +*/ +if (ret == -ENOTSUPP && props->is_headphones) +return 0 ; +
We don't otherwise check the return value before we start overwriting it.
sound/soc/apple/macaudio.c line 1623
Quoted 2 lines
sound/soc/apple/macaudio.c new file +2
-0+/* Fallback, jack only */ + { .compatible = "apple,macaudio"},
The cover letter said this was dropped and the binding did so.
sound/soc/apple/macaudio.c line 1634
Quoted 7 lines
sound/soc/apple/macaudio.c new file +7
-0+static void macaudio_devm_release (void *data) +{ +struct macaudio_snd_data *ma = data; + +cancel_work_sync (&ma->lock_update_work); +cancel_delayed_work_sync (&ma->lock_timeout_work); +}
This is registered before we register the card with devm but these work items use the card, they need to be stopped first.
sound/soc/apple/macaudio.c line 1717
Quoted 13 lines
sound/soc/apple/macaudio.c new file +13
-0+ ret =devm_add_action (dev, macaudio_devm_release, data); +if (ret) +return ret; + + ret =devm_snd_soc_register_card (dev, &data->card); +if (ret) { +for_each_card_prelinks (&data->card, i, link) { +snd_soc_of_put_dai_link_codecs (link); +snd_soc_of_put_dai_link_cpus (link); + } + +return ret; + }
The action registration doesn't do the unwind that the card registration does.
Signature · 1 line
Mark Brown <[email protected]>
Mark Brown
maintainerRe: [PATCH v4 06/22] ASoC: ops: Introduce 'soc_set_enum_kctl'
In reply to James CalligerosQuoted 2 lines
The new function is to be used to set enumerated controls to desired values. It is something a machine driver may call in
fixup_controls.
The subject has soc_set_enum_kctl() but the code has snd_soc_set_enum_kctl().
Quoted 6 lines
sound/soc/soc-ops.c +6
-0+/** +* snd_soc_set_enum_kctl - Set enumerated control matching a name +* +* @card: where to look for the controls +* @name: name +* @value: string value to set the controls to
sound/soc/soc-ops.c int snd_soc_ctl_activate(struct snd_soc_card *card, · line 569
Quoted 10 lines
sound/soc/soc-ops.c +8
-0+* +* Return 0 on success, else error. +*/ +for (i =0 ; i < info->count; i++) + evalue->value.enumerated.item[i] = sel; + +return kctl->put (kctl, evalue); +}
put() returns 1 on change which is not what the kerneldoc says, the code is the better choice here.
Signature · 1 line
Mark Brown <[email protected]>
Mark Brown
maintainerRe: [PATCH v4 05/22] ASoC: ops: Introduce 'snd_soc_ctl_activate'
In reply to James CalligerosQuoted 5 lines
This function mirrors wraps the
sound/core'snd_ctl_activate_id' for ASoC. Machine drivers may call it to lock down kcontrols duringfixup_controls.sound/soc/soc-ops.c +1
-0+int snd_soc_ctl_activate(struct snd_soc_card *card,
sound/soc/soc-ops.c int snd_soc_limit_volume(struct snd_soc_card *card, const char *name, int max) · line 498
Quoted 10 lines
sound/soc/soc-ops.c +9
-0+ const char *name, int active) +{ +struct snd_kcontrol *kctl; +int ret = -EINVAL ; + kctl =snd_soc_card_get_kcontrol (card, name); + +if (kctl) { + ret =snd_ctl_activate_id (card->snd_card, &kctl->id, active); +if (ret <0 )
As Cezary pointed out this return is redundant, we could just exit above if there's no kctl.
Signature · 1 line
Mark Brown <[email protected]>
Mark Brown
maintainerQuoted 6 lines
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].
This needs a rebase against current code.
Signature · 1 line
Mark Brown <[email protected]>