Skip to content

Commit 29f140f

Browse files
committed
HDA: Handle better Bass speaker including 4 channel mode
Create 'Speaker 4ch' virtual mixer controls for this purpose. 'Syntax 8' is required (alsa-lib 1.2.14). Link: alsa-project#410 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent db6932f commit 29f140f

5 files changed

Lines changed: 263 additions & 53 deletions

File tree

ucm2/HDA/HDA.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Syntax 6
1+
Syntax 8
22

33
Define.Use "" # a non-empty string to use UCM configuration for HDA devices
44
Define.Done "" # a non-empty string to skip the end error
@@ -50,6 +50,7 @@ If.use {
5050
}
5151
True {
5252
Include.led.File "/common/ctl/led.conf"
53+
Include.card-init.File "/lib/card-init.conf"
5354
Include.init.File "/HDA/init.conf"
5455

5556
Macro [

ucm2/HDA/HiFi-analog.conf

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -82,52 +82,7 @@ SectionDevice."Headphones" {
8282
}
8383
}
8484

85-
If.spk {
86-
Condition {
87-
Type ControlExists
88-
Control "name='Speaker Playback Switch'"
89-
}
90-
True.SectionDevice."Speaker" {
91-
Comment "Speaker"
92-
93-
If.seq {
94-
Condition {
95-
Type ControlExists
96-
Control "name='Bass Speaker Playback Switch'"
97-
}
98-
True {
99-
EnableSequence [
100-
cset "name='Speaker Playback Switch' on"
101-
cset "name='Bass Speaker Playback Switch' on"
102-
]
103-
104-
DisableSequence [
105-
cset "name='Speaker Playback Switch' off"
106-
cset "name='Bass Speaker Playback Switch' off"
107-
]
108-
}
109-
False {
110-
EnableSequence [
111-
cset "name='Speaker Playback Switch' on"
112-
]
113-
114-
DisableSequence [
115-
cset "name='Speaker Playback Switch' off"
116-
]
117-
}
118-
}
119-
120-
Value {
121-
PlaybackPriority 100
122-
PlaybackPCM "hw:${CardId}"
123-
PlaybackMixerElem "Speaker"
124-
PlaybackMasterElem "Master"
125-
PlaybackVolume "Speaker Playback Volume"
126-
PlaybackSwitch "Speaker Playback Switch"
127-
}
128-
}
129-
}
130-
85+
Include.hifi-spk.File "/HDA/HiFi-spk.conf"
13186
Include.hifi-mic.File "/HDA/HiFi-mic.conf"
13287

13388
If.line {

ucm2/HDA/HiFi-spk.conf

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# HDA Speaker configuration
2+
3+
Define.SpkDevice "Speaker"
4+
5+
If.spk4ch {
6+
Condition {
7+
Type String
8+
Empty "${var:Speaker4chBass}"
9+
}
10+
False.Define.SpkDevice "Speaker1"
11+
}
12+
13+
If.spk {
14+
Condition {
15+
Type String
16+
Empty "${var:HasSpeaker}"
17+
}
18+
False.SectionDevice."${var:SpkDevice}" {
19+
Comment "Speaker"
20+
21+
EnableSequence [
22+
cset "name='Speaker Playback Switch' on"
23+
]
24+
25+
DisableSequence [
26+
cset "name='Speaker Playback Switch' off"
27+
]
28+
29+
If.seq {
30+
Condition {
31+
Type String
32+
Empty "${var:Speaker4chBass}"
33+
}
34+
False {
35+
EnableSequence [
36+
cset "name='Speaker 4ch SyncSw Playback Switch' on"
37+
cset "name='Bass Speaker Playback Switch' on"
38+
]
39+
40+
DisableSequence [
41+
cset "name='Bass Speaker Playback Switch' off"
42+
cset "name='Speaker 4ch SyncSw Playback Switch' off"
43+
]
44+
45+
If.sync_vol {
46+
Condition {
47+
Type String
48+
Empty "${var:SpeakerSyncVol}"
49+
}
50+
False {
51+
EnableSequence [
52+
cset "name='Speaker 4ch SyncVol Playback Switch' on"
53+
]
54+
55+
DisableSequence [
56+
cset "name='Speaker 4ch SyncVol Playback Switch' off"
57+
]
58+
}
59+
}
60+
}
61+
}
62+
63+
Value {
64+
PlaybackPriority 110
65+
PlaybackPCM "hw:${CardId}"
66+
PlaybackMixer "default:${CardId}"
67+
PlaybackMasterElem "Master"
68+
PlaybackMixerElem "Speaker"
69+
PlaybackVolume "Speaker Playback Volume"
70+
PlaybackSwitch "Speaker Playback Switch"
71+
}
72+
}
73+
}
74+
75+
If.spk4ch {
76+
Condition {
77+
Type String
78+
Empty "${var:Speaker4chBass}"
79+
}
80+
False.SectionDevice."Speaker2" {
81+
Comment "Speaker (4 channels)"
82+
83+
ConflictingDevice [
84+
"Speaker1"
85+
]
86+
87+
EnableSequence [
88+
cset "name='Speaker 4ch Playback Switch' on"
89+
cset "name='Speaker 4ch SyncSw Playback Switch' off"
90+
]
91+
92+
DisableSequence [
93+
cset "name='Speaker 4ch Playback Switch' off"
94+
cset "name='Speaker 4ch SyncSw Playback Switch' off"
95+
]
96+
97+
If.sync_vol {
98+
Condition {
99+
Type String
100+
Empty "${var:SpeakerSyncVol}"
101+
}
102+
False {
103+
EnableSequence [
104+
cset "name='Speaker 4ch SyncVol Playback Switch' off"
105+
]
106+
107+
DisableSequence [
108+
cset "name='Speaker 4ch SyncVol Playback Switch' off"
109+
]
110+
}
111+
}
112+
113+
Value {
114+
PlaybackPriority 100
115+
PlaybackPCM "hw:${CardId}"
116+
PlaybackChannels 4
117+
PlaybackMixer "default:${CardId}"
118+
PlaybackMasterElem "Master"
119+
PlaybackMixerElem "Speaker 4ch"
120+
PlaybackVolume "Speaker 4ch Playback Volume"
121+
PlaybackSwitch "Speaker 4ch Playback Switch"
122+
}
123+
}
124+
}

ucm2/HDA/init.conf

Lines changed: 135 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Define.HasSpeaker ""
2+
13
If.amute {
24
Condition {
35
Type ControlExists
@@ -22,12 +24,51 @@ If.master {
2224
If.speaker {
2325
Condition {
2426
Type ControlExists
25-
Control "name='Speaker Playback Volume'"
27+
Control "name='Speaker Playback Switch'"
28+
}
29+
True {
30+
Define.HasSpeaker "switch"
31+
BootSequence [
32+
cset "name='Speaker Playback Switch' off"
33+
]
34+
If.v {
35+
Condition {
36+
Type ControlExists
37+
Control "name='Speaker Playback Volume'"
38+
}
39+
True {
40+
Define.HasSpeaker "volume"
41+
BootSequence [
42+
cset "name='Speaker Playback Volume' 60%"
43+
]
44+
}
45+
}
46+
}
47+
}
48+
49+
If.bass-speaker {
50+
Condition {
51+
Type ControlExists
52+
Control "name='Bass Speaker Playback Switch'"
53+
}
54+
True {
55+
Define.HasBassSpeaker "switch"
56+
BootSequence [
57+
cset "name='Bass Speaker Playback Switch' off"
58+
]
59+
If.v {
60+
Condition {
61+
Type ControlExists
62+
Control "name='Bass Speaker Playback Volume'"
63+
}
64+
True {
65+
Define.HasBassSpeaker "volume"
66+
BootSequence [
67+
cset "name='Bass Speaker Playback Volume' 60%"
68+
]
69+
}
70+
}
2671
}
27-
True.BootSequence [
28-
cset "name='Speaker Playback Volume' 60%"
29-
cset "name='Speaker Playback Switch' off"
30-
]
3172
}
3273

3374
If.headphone {
@@ -50,3 +91,92 @@ If.capture {
5091
cset "name='Capture Volume' 60%"
5192
]
5293
}
94+
95+
#
96+
# Bass (four) Speakers
97+
#
98+
99+
Define.Speaker4chBass ""
100+
101+
If.bass-spk-switch {
102+
Condition {
103+
Type String
104+
Empty "${var:HasBassSpeaker}"
105+
}
106+
False {
107+
Include.ctl-remap.File "/lib/ctl-remap.conf"
108+
109+
LibraryConfig.remap.Config {
110+
ctl.default.sync {
111+
speaker_bass_sync_switch {
112+
switch "name='Speaker 4ch SyncSw Playback Switch'"
113+
controls [
114+
"name='Speaker Playback Switch'"
115+
"name='Bass Speaker Playback Switch'"
116+
]
117+
}
118+
}
119+
ctl.default.map {
120+
"name='Speaker 4ch Playback Switch'" {
121+
"name='Speaker Playback Switch'" { vindex.0 0 vindex.1 1 }
122+
"name='Bass Speaker Playback Switch'" { vindex.2 0 vindex.3 1 }
123+
}
124+
}
125+
}
126+
127+
Define.Speaker4chBass "y"
128+
Define.SpeakerSyncVol ""
129+
130+
If.vol {
131+
Condition {
132+
Type String
133+
Haystack "${var:HasSpeaker}"
134+
Needle "volume"
135+
}
136+
True {
137+
Define.SpeakerSyncVol "y"
138+
If.bass-vol {
139+
Condition {
140+
Type String
141+
Heystack "${var:HasBassSpeaker}"
142+
Needle "volume"
143+
}
144+
False.LibraryConfig.remap.Config {
145+
# remap may be better
146+
ctl.default.sync {
147+
speaker_bass_sync_volume {
148+
switch "name='Speaker 4ch SyncVol Playback Switch'"
149+
controls [
150+
"name='Speaker Playback Volume'"
151+
]
152+
}
153+
}
154+
ctl.default.map {
155+
# FIXME
156+
"name='Speaker 4ch Playback Volume'" {
157+
"name='Speaker Playback Volume'" { vindex.0 0 vindex.1 1 vindex.2 0 vindex.3 1 }
158+
}
159+
}
160+
}
161+
True.LibraryConfig.remap.Config {
162+
ctl.default.sync {
163+
speaker_bass_sync_volume {
164+
switch "name='Speaker 4ch SyncVol Playback Switch'"
165+
controls [
166+
"name='Speaker Playback Volume'"
167+
"name='Bass Speaker Playback Volume'"
168+
]
169+
}
170+
}
171+
ctl.default.map {
172+
"name='Speaker 4ch Playback Volume'" {
173+
"name='Speaker Playback Volume'" { vindex.0 0 vindex.1 1 }
174+
"name='Bass Speaker Playback Volume'" { vindex.2 0 vindex.3 1 }
175+
}
176+
}
177+
}
178+
}
179+
}
180+
}
181+
}
182+
}

ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Syntax 7
1+
Syntax 8
22

33
Include.led.File "/common/ctl/led.conf"
44
Include.card-init.File "/lib/card-init.conf"

0 commit comments

Comments
 (0)