Skip to content

Commit ae19f32

Browse files
committed
Merge branch 'refs/heads/bits/070-audio' into asahi-wip
2 parents e3cd7fa + 591c4e4 commit ae19f32

29 files changed

Lines changed: 4559 additions & 273 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 <[email protected]>
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+
};

drivers/dma/apple-admac.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656

5757
#define REG_BUS_WIDTH(ch) (0x8040 + (ch) * 0x200)
5858

59+
#define BUS_WIDTH_WORD_SIZE GENMASK(3, 0)
60+
#define BUS_WIDTH_FRAME_SIZE GENMASK(7, 4)
5961
#define BUS_WIDTH_8BIT 0x00
6062
#define BUS_WIDTH_16BIT 0x01
6163
#define BUS_WIDTH_32BIT 0x02
@@ -739,7 +741,8 @@ static int admac_device_config(struct dma_chan *chan,
739741
struct admac_data *ad = adchan->host;
740742
bool is_tx = admac_chan_direction(adchan->no) == DMA_MEM_TO_DEV;
741743
int wordsize = 0;
742-
u32 bus_width = 0;
744+
u32 bus_width = readl_relaxed(ad->base + REG_BUS_WIDTH(adchan->no)) &
745+
~(BUS_WIDTH_WORD_SIZE | BUS_WIDTH_FRAME_SIZE);
743746

744747
switch (is_tx ? config->dst_addr_width : config->src_addr_width) {
745748
case DMA_SLAVE_BUSWIDTH_1_BYTE:

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
@@ -584,8 +584,14 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
584584
struct snd_ctl_elem_value *ucontrol);
585585
int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
586586
struct snd_ctl_elem_value *ucontrol);
587+
bool snd_soc_control_matches(struct snd_kcontrol *kcontrol,
588+
const char *pattern);
587589
int snd_soc_limit_volume(struct snd_soc_card *card,
588590
const char *name, int max);
591+
int snd_soc_deactivate_kctl(struct snd_soc_card *card,
592+
const char *name, int active);
593+
int snd_soc_set_enum_kctl(struct snd_soc_card *card,
594+
const char *name, const char *strval);
589595
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
590596
struct snd_ctl_elem_info *uinfo);
591597
int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
@@ -946,7 +952,7 @@ struct snd_soc_card {
946952

947953
int (*probe)(struct snd_soc_card *card);
948954
int (*late_probe)(struct snd_soc_card *card);
949-
void (*fixup_controls)(struct snd_soc_card *card);
955+
int (*fixup_controls)(struct snd_soc_card *card);
950956
int (*remove)(struct snd_soc_card *card);
951957

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

sound/core/control.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
124124
down_write(&card->controls_rwsem);
125125
list_for_each_entry(control, &card->controls, list)
126126
for (idx = 0; idx < control->count; idx++)
127-
if (control->vd[idx].owner == ctl)
127+
if (control->vd[idx].owner == ctl) {
128128
control->vd[idx].owner = NULL;
129+
if (control->unlock)
130+
control->unlock(control);
131+
}
129132
up_write(&card->controls_rwsem);
130133
snd_fasync_free(ctl->fasync);
131134
snd_ctl_empty_read_queue(ctl);
@@ -305,6 +308,8 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
305308
kctl->info = ncontrol->info;
306309
kctl->get = ncontrol->get;
307310
kctl->put = ncontrol->put;
311+
kctl->lock = ncontrol->lock;
312+
kctl->unlock = ncontrol->unlock;
308313
kctl->tlv.p = ncontrol->tlv.p;
309314

310315
kctl->private_value = ncontrol->private_value;
@@ -1378,8 +1383,11 @@ static int snd_ctl_elem_lock(struct snd_ctl_file *file,
13781383
if (vd->owner != NULL)
13791384
result = -EBUSY;
13801385
else {
1381-
vd->owner = file;
13821386
result = 0;
1387+
if (kctl->lock)
1388+
result = kctl->lock(kctl, file);
1389+
if (result >= 0)
1390+
vd->owner = file;
13831391
}
13841392
}
13851393
up_write(&card->controls_rwsem);
@@ -1409,6 +1417,8 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file,
14091417
result = -EPERM;
14101418
else {
14111419
vd->owner = NULL;
1420+
if (kctl->unlock)
1421+
kctl->unlock(kctl);
14121422
result = 0;
14131423
}
14141424
}

sound/core/pcm_dmaengine.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
359359
{
360360
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
361361

362+
/*
363+
* The PCM might have been closed while suspended, which would
364+
* skip the STOP trigger. Make sure we terminate.
365+
*/
366+
dmaengine_terminate_async(prtd->dma_chan);
362367
dmaengine_synchronize(prtd->dma_chan);
363368
kfree(prtd);
364369

sound/core/pcm_native.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,9 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
904904
goto unlock;
905905
result = do_hw_free(substream);
906906
snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
907-
cpu_latency_qos_remove_request(&substream->latency_pm_qos_req);
908-
unlock:
907+
if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req))
908+
cpu_latency_qos_remove_request(&substream->latency_pm_qos_req);
909+
unlock:
909910
snd_pcm_buffer_access_unlock(runtime);
910911
return result;
911912
}

sound/soc/apple/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,20 @@ config SND_SOC_APPLE_MCA
66
help
77
This option enables an ASoC platform driver for MCA peripherals found
88
on Apple Silicon SoCs.
9+
10+
config SND_SOC_APPLE_MACAUDIO
11+
tristate "Sound support for Apple Silicon Macs"
12+
depends on ARCH_APPLE || COMPILE_TEST
13+
select SND_SOC_APPLE_MCA
14+
select SND_SIMPLE_CARD_UTILS
15+
select APPLE_ADMAC
16+
select COMMON_CLK_APPLE_NCO if COMMON_CLK
17+
select SND_SOC_TAS2764
18+
select SND_SOC_TAS2770
19+
select SND_SOC_CS42L83
20+
select SND_SOC_CS42L84
21+
default ARCH_APPLE
22+
help
23+
This option enables an ASoC machine-level driver for Apple Silicon Macs
24+
and it also enables the required SoC and codec drivers for overall
25+
sound support on these machines.

0 commit comments

Comments
 (0)