Skip to content

Commit 566f3c0

Browse files
committed
sof-soundwire: cleanups for codecs with multiple functions
The load mechanism assumed only one multi-codec in the system, but we saw in alsa-project#774 multiple instances of those codecs (rt1320 and rt713). Make the load mechanism straight: - introduce file variables - remove shadow variables - probe multi-codecs separately and modify the file variables - test for duplicate file inclusion (in both sof-soundwire / HiFi configs) - merge dmic configs for rt712,rt713 to one file This change also removes filters for speaker/headset/mic init includes. The file variables + multi-codec probe replaces this functionality and if the driver reports an "unknown" codec, UCM config should be updated anyway. Link: alsa-project#774 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent f846a8b commit 566f3c0

14 files changed

Lines changed: 289 additions & 192 deletions

File tree

ucm2/codecs/rt1320/init.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If.spk_init_rt1320 {
1616
Condition {
1717
Type String
1818
Needle "rt1320"
19-
Haystack "${var:MultiSpeakerShadow}"
19+
Haystack "${var:SpeakerCodec1}"
2020
}
2121
True {
2222
Macro.num1.rt1320spkled { ForAmps "[12]" Amp 1 }
@@ -83,7 +83,7 @@ If.mic_init_rt1320 {
8383
Condition {
8484
Type String
8585
Needle "rt1320"
86-
Haystack "${var:MultiMicShadow}"
86+
Haystack "${var:MicCodec1}"
8787
}
8888
True {
8989
Macro.num1.rt1320micled { ForMics "[12]" Mic 1 }

ucm2/codecs/rt712-dmic/init.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

ucm2/codecs/rt712/init.conf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ BootSequence [
77
cset "name='rt712 FU0F Capture Switch' 1"
88
]
99

10+
If.rt712dmic_init {
11+
Condition {
12+
Type String
13+
String1 "rt712-dmic"
14+
String2 "${var:MicCodec1}"
15+
}
16+
True.BootSequence [
17+
cset "name='rt712-dmic ADC 25 Mux' 'DMIC1'"
18+
cset "name='rt712-dmic FU1E Capture Switch' 1"
19+
]
20+
}
21+
1022
If.rt712vb_init {
1123
Condition {
1224
Type RegexMatch
1325
Regex "(rt712(-sdca)?)"
14-
String "${var:MultiMicShadow}"
26+
String "${var:MicCodec1}"
1527
}
1628
True.BootSequence [
1729
# RT712-VB integrated with DMIC

ucm2/codecs/rt713-dmic/init.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

ucm2/codecs/rt713/init.conf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ BootSequence [
77
cset "name='rt713 FU0F Capture Switch' 1"
88
]
99

10+
If.rt713dmic_init {
11+
Condition {
12+
Type String
13+
String1 "rt713-dmic"
14+
String2 "${var:MicCodec1}"
15+
}
16+
True.BootSequence [
17+
cset "name='rt713-dmic ADC 25 Mux' 'DMIC1'"
18+
cset "name='rt713-dmic FU1E Capture Switch' 1"
19+
]
20+
}
21+
1022
If.rt713vb_init {
1123
Condition {
1224
Type String
1325
String1 "rt713"
14-
String2 "${var:MultiMicShadow}"
26+
String2 "${var:MicCodec1}"
1527
}
1628
True.BootSequence [
1729
# RT713-VB integrated with DMIC

ucm2/sof-soundwire/HiFi.conf

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,43 @@ SectionVerb {
88
Value.TQ "HiFi"
99
}
1010

11-
If.multicodec {
11+
If.spk {
1212
Condition {
1313
Type String
14-
Empty "${var:MultiCodec1}"
14+
Empty "${var:SpeakerCodecFile}"
1515
}
16-
False.Include.multicodec.File "/sof-soundwire/${var:MultiCodec1}.conf"
16+
False.Include.a.File "/sof-soundwire/${var:SpeakerCodecFile}.conf"
1717
}
1818

19-
If.spkdev {
19+
If.mic {
2020
Condition {
2121
Type String
22-
Empty "${var:SpeakerCodec1}"
22+
Empty "${var:MicCodecFile}"
2323
}
24-
False.Include.spkdev.File "/sof-soundwire/${var:SpeakerCodec1}.conf"
25-
}
26-
27-
If.micdev {
28-
Condition {
29-
Type String
30-
Empty "${var:MicCodec1}"
24+
False.If.dup {
25+
Condition {
26+
Type String
27+
String1 "${var:MicCodecFile}"
28+
String2 "${var:SpeakerCodecFile}"
29+
}
30+
False.Include.a.File "/sof-soundwire/${var:MicCodecFile}.conf"
3131
}
32-
False.Include.micdev.File "/sof-soundwire/${var:MicCodec1}.conf"
3332
}
3433

35-
If.hsdev {
34+
If.headset {
3635
Condition {
3736
Type String
38-
Empty "${var:HeadsetCodec1}"
37+
Empty "${var:HeadsetCodecFile}"
38+
}
39+
False.If.dup {
40+
Condition {
41+
Type String
42+
# guard with "=" to avoid empty string matching
43+
Needle "=${var:HeadsetCodecFile}="
44+
Haystack "=${var:SpeakerCodecFile}=${var:MicCodecFile}="
45+
}
46+
False.Include.a.File "/sof-soundwire/${var:HeadsetCodecFile}.conf"
3947
}
40-
False.Include.hsdev.File "/sof-soundwire/${var:HeadsetCodec1}.conf"
4148
}
4249

4350
<sof-soundwire/Hdmi.conf>

ucm2/sof-soundwire/rt1320.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ If.codecmic {
7171
Condition {
7272
Type String
7373
Needle "rt1320"
74-
Haystack "${var:MultiMicShadow}"
74+
Haystack "${var:MicCodec1}"
7575
}
7676
True {
7777
SectionDevice."Mic" {

ucm2/sof-soundwire/rt712-dmic.conf

Lines changed: 0 additions & 21 deletions
This file was deleted.

ucm2/sof-soundwire/rt712.conf

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Use case Configuration for sof-soundwire card
22

3-
If.codecspk {
3+
If.codec_spk {
44
Condition {
55
Type RegexMatch
66
Regex "(rt712(-sdca)?)"
7-
String "${var:MultiSpeakerShadow}"
7+
String "${var:SpeakerCodec1}"
88
}
99
True {
1010
SectionDevice."Speaker" {
@@ -47,50 +47,88 @@ If.codecspk {
4747
}
4848
}
4949

50-
SectionDevice."Headphones" {
51-
Comment "Headphones"
50+
If.codec_hs {
51+
Condition {
52+
Type RegexMatch
53+
Regex "(rt712(-sdca)?)"
54+
String "${var:HeadsetCodec1}"
55+
}
56+
True {
57+
SectionDevice."Headphones" {
58+
Comment "Headphones"
59+
60+
EnableSequence [
61+
cset "name='Headphone Switch' on"
62+
]
63+
64+
DisableSequence [
65+
cset "name='Headphone Switch' off"
66+
]
5267

53-
EnableSequence [
54-
cset "name='Headphone Switch' on"
55-
]
68+
Value {
69+
PlaybackPriority 200
70+
PlaybackPCM "hw:${CardId}"
71+
JackControl "Headphone Jack"
72+
}
73+
}
74+
75+
SectionDevice."Headset" {
76+
Comment "Headset Mono Microphone"
77+
78+
EnableSequence [
79+
cset "name='rt712 FU0F Capture Switch' on"
80+
]
5681

57-
DisableSequence [
58-
cset "name='Headphone Switch' off"
59-
]
82+
DisableSequence [
83+
cset "name='rt712 FU0F Capture Switch' off"
84+
]
6085

61-
Value {
62-
PlaybackPriority 200
63-
PlaybackPCM "hw:${CardId}"
64-
JackControl "Headphone Jack"
86+
Value {
87+
CapturePriority 300
88+
CapturePCM "hw:${CardId},1"
89+
CaptureSwitch "rt712 FU0F Capture Switch"
90+
CaptureVolume "rt712 FU0F Capture Volume"
91+
CaptureMixerElem "rt712 FU0F"
92+
JackControl "Headset Mic Jack"
93+
}
94+
}
6595
}
6696
}
6797

68-
SectionDevice."Headset" {
69-
Comment "Headset Mono Microphone"
98+
If.codec_dmic {
99+
Condition {
100+
Type String
101+
String1 "rt712-dmic"
102+
String2 "${var:MicCodec1}"
103+
}
104+
True {
105+
SectionDevice."Mic" {
106+
Comment "SoundWire microphones"
70107

71-
EnableSequence [
72-
cset "name='rt712 FU0F Capture Switch' on"
73-
]
108+
EnableSequence [
109+
cset "name='rt712-dmic FU1E Capture Switch' 1"
110+
]
74111

75-
DisableSequence [
76-
cset "name='rt712 FU0F Capture Switch' off"
77-
]
112+
DisableSequence [
113+
cset "name='rt712-dmic FU1E Capture Switch' 0"
114+
]
78115

79-
Value {
80-
CapturePriority 300
81-
CapturePCM "hw:${CardId},1"
82-
CaptureSwitch "rt712 FU0F Capture Switch"
83-
CaptureVolume "rt712 FU0F Capture Volume"
84-
CaptureMixerElem "rt712 FU0F"
85-
JackControl "Headset Mic Jack"
116+
Value {
117+
CapturePriority 100
118+
CapturePCM "hw:${CardId},4"
119+
CaptureSwitch "rt712-dmic FU1E Capture Switch"
120+
CaptureVolume "rt712-dmic FU1E Capture Volume"
121+
CaptureMixerElem "rt712-dmic FU1E"
122+
}
123+
}
86124
}
87125
}
88126

89-
If.codecmic {
127+
If.codec_mic {
90128
Condition {
91129
Type RegexMatch
92130
Regex "(rt712(-sdca)?)"
93-
String "${var:MultiMicShadow}"
131+
String "${var:MicCodec1}"
94132
}
95133
True {
96134
SectionDevice."Mic" {

ucm2/sof-soundwire/rt713-dmic.conf

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)