Skip to content

Commit f0320d9

Browse files
committed
Merge branch 'bits/070-audio' into asahi-wip
2 parents 27a51b5 + 7366392 commit f0320d9

32 files changed

Lines changed: 4673 additions & 278 deletions
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/apple,macaudio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Apple Silicon Macs integrated sound peripherals
8+
9+
description:
10+
This binding represents the overall machine-level integration of sound
11+
peripherals on 'Apple Silicon' machines by Apple.
12+
13+
maintainers:
14+
- Martin Povišer <povik+lin@cutebit.org>
15+
16+
properties:
17+
compatible:
18+
items:
19+
- enum:
20+
- apple,j274-macaudio
21+
- apple,j293-macaudio
22+
- apple,j314-macaudio
23+
- const: apple,macaudio
24+
25+
"#address-cells":
26+
const: 1
27+
28+
"#size-cells":
29+
const: 0
30+
31+
model:
32+
description:
33+
Model name for presentation to users
34+
$ref: /schemas/types.yaml#/definitions/string
35+
36+
patternProperties:
37+
"^dai-link(@[0-9a-f]+)?$":
38+
description: |
39+
Node for each sound peripheral such as the speaker array, headphones jack,
40+
or microphone.
41+
type: object
42+
43+
additionalProperties: false
44+
45+
properties:
46+
reg:
47+
maxItems: 1
48+
49+
link-name:
50+
description: |
51+
Name for the peripheral, expecting 'Speaker' or 'Speakers' if this is
52+
the speaker array.
53+
$ref: /schemas/types.yaml#/definitions/string
54+
55+
cpu:
56+
type: object
57+
58+
properties:
59+
sound-dai:
60+
description: |
61+
DAI list with CPU-side I2S ports involved in this peripheral.
62+
minItems: 1
63+
maxItems: 2
64+
65+
required:
66+
- sound-dai
67+
68+
codec:
69+
type: object
70+
71+
properties:
72+
sound-dai:
73+
minItems: 1
74+
maxItems: 8
75+
description: |
76+
DAI list with the CODEC-side DAIs connected to the above CPU-side
77+
DAIs and involved in this sound peripheral.
78+
79+
The list is in left/right order if applicable. If there are more
80+
than one CPU-side DAIs (there can be two), the CODECs must be
81+
listed first those connected to the first CPU, then those
82+
connected to the second.
83+
84+
In addition, on some machines with many speaker codecs, the CODECs
85+
are listed in this fixed order:
86+
87+
J293: Left Front, Left Rear, Right Front, Right Rear
88+
J314: Left Woofer 1, Left Tweeter, Left Woofer 2,
89+
Right Woofer 1, Right Tweeter, Right Woofer 2
90+
91+
required:
92+
- sound-dai
93+
94+
required:
95+
- reg
96+
- cpu
97+
- codec
98+
99+
required:
100+
- compatible
101+
- model
102+
103+
additionalProperties: false
104+
105+
examples:
106+
- |
107+
mca: mca@9b600000 {
108+
compatible = "apple,t6000-mca", "apple,mca";
109+
reg = <0x9b600000 0x10000>,
110+
<0x9b500000 0x20000>;
111+
112+
clocks = <&nco 0>, <&nco 1>, <&nco 2>, <&nco 3>;
113+
power-domains = <&ps_audio_p>, <&ps_mca0>, <&ps_mca1>,
114+
<&ps_mca2>, <&ps_mca3>;
115+
dmas = <&admac 0>, <&admac 1>, <&admac 2>, <&admac 3>,
116+
<&admac 4>, <&admac 5>, <&admac 6>, <&admac 7>,
117+
<&admac 8>, <&admac 9>, <&admac 10>, <&admac 11>,
118+
<&admac 12>, <&admac 13>, <&admac 14>, <&admac 15>;
119+
dma-names = "tx0a", "rx0a", "tx0b", "rx0b",
120+
"tx1a", "rx1a", "tx1b", "rx1b",
121+
"tx2a", "rx2a", "tx2b", "rx2b",
122+
"tx3a", "rx3a", "tx3b", "rx3b";
123+
124+
#sound-dai-cells = <1>;
125+
};
126+
127+
sound {
128+
compatible = "apple,j314-macaudio", "apple,macaudio";
129+
model = "MacBook Pro J314 integrated audio";
130+
131+
#address-cells = <1>;
132+
#size-cells = <0>;
133+
134+
dai-link@0 {
135+
reg = <0>;
136+
link-name = "Speakers";
137+
138+
cpu {
139+
sound-dai = <&mca 0>, <&mca 1>;
140+
};
141+
codec {
142+
sound-dai = <&speaker_left_woof1>,
143+
<&speaker_left_tweet>,
144+
<&speaker_left_woof2>,
145+
<&speaker_right_woof1>,
146+
<&speaker_right_tweet>,
147+
<&speaker_right_woof2>;
148+
};
149+
};
150+
151+
dai-link@1 {
152+
reg = <1>;
153+
link-name = "Headphones Jack";
154+
155+
cpu {
156+
sound-dai = <&mca 2>;
157+
};
158+
codec {
159+
sound-dai = <&jack_codec>;
160+
};
161+
};
162+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/cirrus,cs42l84.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Cirrus Logic CS42L84 audio CODEC
8+
9+
maintainers:
10+
- Martin Povišer <povik+lin@cutebit.org>
11+
12+
description: |
13+
The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded
14+
in personal computers sold by Apple. It was first seen in 2021 Macbook
15+
Pro models. It has stereo DAC for playback, mono ADC for capture, and
16+
is somewhat similar to CS42L42 but with a different regmap.
17+
18+
properties:
19+
compatible:
20+
enum:
21+
- cirrus,cs42l84
22+
23+
reg:
24+
maxItems: 1
25+
26+
reset-gpios:
27+
maxItems: 1
28+
29+
interrupts:
30+
maxItems: 1
31+
32+
'#sound-dai-cells':
33+
const: 0
34+
35+
required:
36+
- compatible
37+
- reg
38+
39+
additionalProperties: false
40+
41+
examples:
42+
- |
43+
#include <dt-bindings/gpio/gpio.h>
44+
#include <dt-bindings/interrupt-controller/irq.h>
45+
i2c {
46+
#address-cells = <1>;
47+
#size-cells = <0>;
48+
49+
jack_codec: codec@4b {
50+
compatible = "cirrus,cs42l84";
51+
reg = <0x4b>;
52+
reset-gpios = <&pinctrl_nub 4 GPIO_ACTIVE_LOW>;
53+
interrupts-extended = <&pinctrl_ap 180 IRQ_TYPE_LEVEL_LOW>;
54+
#sound-dai-cells = <0>;
55+
};
56+
};

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,9 +2126,11 @@ L: asahi@lists.linux.dev
21262126
L: linux-sound@vger.kernel.org
21272127
S: Maintained
21282128
F: Documentation/devicetree/bindings/sound/adi,ssm3515.yaml
2129+
F: Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml
21292130
F: Documentation/devicetree/bindings/sound/apple,*
21302131
F: sound/soc/apple/*
21312132
F: sound/soc/codecs/cs42l83-i2c.c
2133+
F: sound/soc/codecs/cs42l84.*
21322134
F: sound/soc/codecs/ssm3515.c
21332135

21342136
ARM/APPLE MACHINE SUPPORT

drivers/dma/apple-admac.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static struct dma_async_tx_descriptor *admac_prep_dma_cyclic(
254254
size_t period_len, enum dma_transfer_direction direction,
255255
unsigned long flags)
256256
{
257-
struct admac_chan *adchan = container_of(chan, struct admac_chan, chan);
257+
struct admac_chan *adchan = to_admac_chan(chan);
258258
struct admac_tx *adtx;
259259

260260
if (direction != admac_chan_direction(adchan->no))
@@ -936,6 +936,7 @@ static void admac_remove(struct platform_device *pdev)
936936
}
937937

938938
static const struct of_device_id admac_of_match[] = {
939+
{ .compatible = "apple,admac2", },
939940
{ .compatible = "apple,admac", },
940941
{ }
941942
};

drivers/soc/apple/rtkit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum {
2222
APPLE_RTKIT_EP_DEBUG = 3,
2323
APPLE_RTKIT_EP_IOREPORT = 4,
2424
APPLE_RTKIT_EP_OSLOG = 8,
25+
APPLE_RTKIT_EP_TRACEKIT = 0xa,
2526
};
2627

2728
#define APPLE_RTKIT_MGMT_TYPE GENMASK_ULL(59, 52)
@@ -192,6 +193,7 @@ static void apple_rtkit_management_rx_epmap(struct apple_rtkit *rtk, u64 msg)
192193
case APPLE_RTKIT_EP_DEBUG:
193194
case APPLE_RTKIT_EP_IOREPORT:
194195
case APPLE_RTKIT_EP_OSLOG:
196+
case APPLE_RTKIT_EP_TRACEKIT:
195197
dev_dbg(rtk->dev,
196198
"RTKit: Starting system endpoint 0x%02x\n", ep);
197199
apple_rtkit_start_ep(rtk, ep);
@@ -639,6 +641,12 @@ int apple_rtkit_poll(struct apple_rtkit *rtk)
639641
}
640642
EXPORT_SYMBOL_GPL(apple_rtkit_poll);
641643

644+
bool apple_rtkit_has_endpoint(struct apple_rtkit *rtk, u8 ep)
645+
{
646+
return test_bit(ep, rtk->endpoints);
647+
}
648+
EXPORT_SYMBOL_GPL(apple_rtkit_has_endpoint);
649+
642650
int apple_rtkit_start_ep(struct apple_rtkit *rtk, u8 endpoint)
643651
{
644652
u64 msg;

include/linux/soc/apple/rtkit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,12 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message,
179179
*/
180180
int apple_rtkit_poll(struct apple_rtkit *rtk);
181181

182+
/*
183+
* Checks if an endpoint with a given index exists
184+
*
185+
* @rtk: RTKit reference
186+
* @ep: endpoint to check for
187+
*/
188+
bool apple_rtkit_has_endpoint(struct apple_rtkit *rtk, u8 ep);
189+
182190
#endif /* _LINUX_APPLE_RTKIT_H_ */

include/sound/control.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
#define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data)
1515

1616
struct snd_kcontrol;
17+
struct snd_ctl_file;
1718
typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo);
1819
typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
1920
typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
21+
typedef int (snd_kcontrol_lock_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_file *owner);
22+
typedef void (snd_kcontrol_unlock_t) (struct snd_kcontrol * kcontrol);
2023
typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol,
2124
int op_flag, /* SNDRV_CTL_TLV_OP_XXX */
2225
unsigned int size,
@@ -55,6 +58,8 @@ struct snd_kcontrol_new {
5558
snd_kcontrol_info_t *info;
5659
snd_kcontrol_get_t *get;
5760
snd_kcontrol_put_t *put;
61+
snd_kcontrol_lock_t *lock;
62+
snd_kcontrol_unlock_t *unlock;
5863
union {
5964
snd_kcontrol_tlv_rw_t *c;
6065
const unsigned int *p;
@@ -74,6 +79,8 @@ struct snd_kcontrol {
7479
snd_kcontrol_info_t *info;
7580
snd_kcontrol_get_t *get;
7681
snd_kcontrol_put_t *put;
82+
snd_kcontrol_lock_t *lock;
83+
snd_kcontrol_unlock_t *unlock;
7784
union {
7885
snd_kcontrol_tlv_rw_t *c;
7986
const unsigned int *p;

include/sound/cs42l42.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
#define CS42L42_INTERNAL_FS_MASK (1 << CS42L42_INTERNAL_FS_SHIFT)
6363

6464
#define CS42L42_SFTRAMP_RATE (CS42L42_PAGE_10 + 0x0A)
65+
#define CS42L42_SFTRAMP_ASR_RATE_MASK GENMASK(7, 4)
66+
#define CS42L42_SFTRAMP_ASR_RATE_SHIFT 4
67+
#define CS42L42_SFTRAMP_DSR_RATE_MASK GENMASK(3, 0)
68+
#define CS42L42_SFTRAMP_DSR_RATE_SHIFT 0
6569
#define CS42L42_SLOW_START_ENABLE (CS42L42_PAGE_10 + 0x0B)
6670
#define CS42L42_SLOW_START_EN_MASK GENMASK(6, 4)
6771
#define CS42L42_SLOW_START_EN_SHIFT 4

include/sound/soc-card.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int snd_soc_card_resume_post(struct snd_soc_card *card);
4444

4545
int snd_soc_card_probe(struct snd_soc_card *card);
4646
int snd_soc_card_late_probe(struct snd_soc_card *card);
47-
void snd_soc_card_fixup_controls(struct snd_soc_card *card);
47+
int snd_soc_card_fixup_controls(struct snd_soc_card *card);
4848
int snd_soc_card_remove(struct snd_soc_card *card);
4949

5050
int snd_soc_card_set_bias_level(struct snd_soc_card *card,

include/sound/soc.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,14 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
607607
struct snd_ctl_elem_value *ucontrol);
608608
int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
609609
struct snd_ctl_elem_value *ucontrol);
610+
bool snd_soc_control_matches(struct snd_kcontrol *kcontrol,
611+
const char *pattern);
610612
int snd_soc_limit_volume(struct snd_soc_card *card,
611613
const char *name, int max);
614+
int snd_soc_deactivate_kctl(struct snd_soc_card *card,
615+
const char *name, int active);
616+
int snd_soc_set_enum_kctl(struct snd_soc_card *card,
617+
const char *name, const char *strval);
612618
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
613619
struct snd_ctl_elem_info *uinfo);
614620
int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
@@ -1029,7 +1035,7 @@ struct snd_soc_card {
10291035

10301036
int (*probe)(struct snd_soc_card *card);
10311037
int (*late_probe)(struct snd_soc_card *card);
1032-
void (*fixup_controls)(struct snd_soc_card *card);
1038+
int (*fixup_controls)(struct snd_soc_card *card);
10331039
int (*remove)(struct snd_soc_card *card);
10341040

10351041
/* the pre and post PM functions are used to do any PM work before and

0 commit comments

Comments
 (0)