Skip to content

Commit 327eacd

Browse files
committed
Merge branch 'bits/070-audio' into asahi-wip
2 parents a1a6edc + d4d4544 commit 327eacd

31 files changed

Lines changed: 4722 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
@@ -2035,9 +2035,11 @@ L: asahi@lists.linux.dev
20352035
L: alsa-devel@alsa-project.org (moderated for non-subscribers)
20362036
S: Maintained
20372037
F: Documentation/devicetree/bindings/sound/adi,ssm3515.yaml
2038+
F: Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml
20382039
F: Documentation/devicetree/bindings/sound/apple,*
20392040
F: sound/soc/apple/*
20402041
F: sound/soc/codecs/cs42l83-i2c.c
2042+
F: sound/soc/codecs/cs42l84.*
20412043
F: sound/soc/codecs/ssm3515.c
20422044

20432045
ARM/APPLE MACHINE SUPPORT

drivers/dma/apple-admac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static struct dma_async_tx_descriptor *admac_prep_dma_cyclic(
252252
size_t period_len, enum dma_transfer_direction direction,
253253
unsigned long flags)
254254
{
255-
struct admac_chan *adchan = container_of(chan, struct admac_chan, chan);
255+
struct admac_chan *adchan = to_admac_chan(chan);
256256
struct admac_tx *adtx;
257257

258258
if (direction != admac_chan_direction(adchan->no))

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
@@ -46,7 +46,7 @@ int snd_soc_card_resume_post(struct snd_soc_card *card);
4646

4747
int snd_soc_card_probe(struct snd_soc_card *card);
4848
int snd_soc_card_late_probe(struct snd_soc_card *card);
49-
void snd_soc_card_fixup_controls(struct snd_soc_card *card);
49+
int snd_soc_card_fixup_controls(struct snd_soc_card *card);
5050
int snd_soc_card_remove(struct snd_soc_card *card);
5151

5252
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,
@@ -1028,7 +1034,7 @@ struct snd_soc_card {
10281034

10291035
int (*probe)(struct snd_soc_card *card);
10301036
int (*late_probe)(struct snd_soc_card *card);
1031-
void (*fixup_controls)(struct snd_soc_card *card);
1037+
int (*fixup_controls)(struct snd_soc_card *card);
10321038
int (*remove)(struct snd_soc_card *card);
10331039

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

sound/core/control.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
123123
scoped_guard(rwsem_write, &card->controls_rwsem) {
124124
list_for_each_entry(control, &card->controls, list)
125125
for (idx = 0; idx < control->count; idx++)
126-
if (control->vd[idx].owner == ctl)
126+
if (control->vd[idx].owner == ctl) {
127127
control->vd[idx].owner = NULL;
128+
if (control->unlock)
129+
control->unlock(control);
130+
}
128131
}
129-
130132
snd_fasync_free(ctl->fasync);
131133
snd_ctl_empty_read_queue(ctl);
132134
put_pid(ctl->pid);
@@ -303,6 +305,8 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
303305
kctl->info = ncontrol->info;
304306
kctl->get = ncontrol->get;
305307
kctl->put = ncontrol->put;
308+
kctl->lock = ncontrol->lock;
309+
kctl->unlock = ncontrol->unlock;
306310
kctl->tlv.p = ncontrol->tlv.p;
307311

308312
kctl->private_value = ncontrol->private_value;
@@ -1392,6 +1396,12 @@ static int snd_ctl_elem_lock(struct snd_ctl_file *file,
13921396
vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
13931397
if (vd->owner)
13941398
return -EBUSY;
1399+
1400+
if (kctl->lock) {
1401+
int err = kctl->lock(kctl, file);
1402+
if (err < 0)
1403+
return err;
1404+
}
13951405
vd->owner = file;
13961406
return 0;
13971407
}
@@ -1416,6 +1426,8 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file,
14161426
if (vd->owner != file)
14171427
return -EPERM;
14181428
vd->owner = NULL;
1429+
if (kctl->unlock)
1430+
kctl->unlock(kctl);
14191431
return 0;
14201432
}
14211433

0 commit comments

Comments
 (0)