summarylogtreecommitdiffstats
path: root/conf.d_amd-soundwire_ASUSTeK-ProArtPX13.conf
blob: 7d5a98e6feb8cb8ff701f405fe499cac45c8c7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# UCM override for ASUS ProArt PX13 (HN7306EA/HN7306EAC) on AMD ACP70.
#
# Installed as a conf.d LongName-specific override (confd1 in alsa-ucm-conf's
# ucm.conf), beating the driver-default conf.d/amd-soundwire/amd-soundwire.conf
# trampoline (a symlink to sof-soundwire/sof-soundwire.conf) for our card only.
# Other amd-soundwire machines are untouched.
#
# Body is a verbatim copy of alsa-ucm-conf's sof-soundwire/sof-soundwire.conf
# plus two PX13 deltas:
#
#   1. If.spk filter regex gains tas2783(-1)? so /codecs/tas2783/init.conf loads
#      (alsa-ucm-conf has no tas2783 codec support).
#   2. fix_acp_dmic: on AMD ACP70 the card advertises "mic:dmic" but the DMIC PCM
#      is acp-dmic-codec (device 4), not Intel's "DMIC ". The stock dmic.conf
#      find-device regex='DMIC ' then matches nothing and aborts the whole UCM
#      import (no HiFi profile -> card falls to stereo-fallback -> silence).
#      Redirect MicCodec1 dmic->acp-dmic before the *CodecFile vars are derived,
#      so mic init loads /codecs/acp-dmic/init.conf and HiFi pulls
#      /sof-soundwire/acp-dmic.conf (CapturePCM hw:${CardId},4).
#
# We inline the master rather than <include> it because the deltas must run after
# the components-driven DefineRegex but before HiFi.conf's deferred parse; an
# <include> evaluates HiFi inside the nested scope before any outer override can
# take effect. RE-SYNC this body whenever alsa-ucm-conf updates sof-soundwire.conf
# (upstream renamed/added variables like SpeakerCodecFile; a stale copy aborts the
# import). No alsa-ucm-conf files are modified.
Syntax 8

SectionUseCase."HiFi" {
	File "/sof-soundwire/HiFi.conf"
	Comment "Play HiFi quality Music"
}

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

Define {
	SpeakerCodec1 ""
	SpeakerChannels1 "2"
	SpeakerAmps1 "0"
	HeadsetCodec1 ""
	MicCodec1 ""
	Mics1 "0"
	Iec61937Pcms1 ""
	MultiCodec1 ""
	MultiCodecRegex "rt712|rt713|rt721|rt722|rt1320"
}

DefineRegex {
	SpeakerCodec {
		Regex " spk:([a-z0-9]+((-sdca)|(-spk)|(-bridge))?(\\+[a-z0-9]+((-spk)?))?)"
		String "${CardComponents}"
	}
	SpeakerChannels {
		Regex " cfg-spk:([0-9]+)"
		String "${CardComponents}"
	}
	SpeakerAmps {
		Regex " cfg-amp:([0-9]+)"
		String "${CardComponents}"
	}
	HeadsetCodec {
		Regex " hs:([a-z0-9]+(-sdca)?)"
		String "${CardComponents}"
	}
	MicCodec {
		Regex " mic:([a-z0-9]+(-dmic)?+(-sdca)?)"
		String "${CardComponents}"
	}
	Mics {
		Regex " cfg-mics:([1-9][0-9]*)"
		String "${CardComponents}"
	}
	Iec61937Pcms {
		Regex "iec61937-pcm:(([0-9]+(,))*[0-9]+)"
		String "${CardComponents}"
	}
	MultiCodec {
		Regex "(${var:MultiCodecRegex})"
		String "${var:SpeakerCodec1} ${var:HeadsetCodec1} ${var:MicCodec1}"
	}
}

# PX13 delta: AMD ACP70 advertises "mic:dmic" but the DMIC PCM is acp-dmic-codec
# (device 4), not Intel's "DMIC ". Redirect the mic codec to acp-dmic before the
# *CodecFile vars are derived, so mic init loads /codecs/acp-dmic/init.conf and
# HiFi pulls /sof-soundwire/acp-dmic.conf.
If.fix_acp_dmic {
	Condition {
		Type RegexMatch
		Regex "dmic"
		String "${var:MicCodec1}"
	}
	True.Define.MicCodec1 "acp-dmic"
}

# set default file variables after regex evaluation
If.codec_default.Append.Define {
	SpeakerCodecFile "${var:SpeakerCodec1}"
	MicCodecFile "${var:MicCodec1}"
	HeadsetCodecFile "${var:HeadsetCodec1}"
}

# check to keep compatibility with older kernels that have two separate spk: tags
If.old_multi_spk {
	Condition {
		Type RegexMatch
		Regex "(spk:cs42l43-spk .*spk:cs35l56( |$))|(spk:cs35l56 .*spk:cs42l43-spk( |$))"
		String "${CardComponents}"
	}
	True.Define.SpeakerCodec1 "cs42l43-spk+cs35l56"
}

DefineMacro.MultiCodecInit.If.a {
	Condition {
		Type String
		# guard with "=" to not match the codec name in the middle
		Haystack "=${var:SpeakerCodec1}=${var:HeadsetCodec1}=${var:MicCodec1}"
		Needle "=${var:__CodecId}"
	}
	True {
		If.spk {
			Condition {
				Type RegexMatch
				# guard with "=" to avoid empty string matching
				Regex "=(${var:__CodecId}(-sdca)?)="
				String "=${var:SpeakerCodec1}="
			}
			True.Define.SpeakerCodecFile "${var:__CodecId}"
		}
		If.headset {
			Condition {
				Type RegexMatch
				# guard with "=" to avoid empty string matching
				Regex "=(${var:__CodecId}(-sdca)?)="
				String "=${var:HeadsetCodec1}="
			}
			True.Define.HeadsetCodecFile "${var:__CodecId}"
		}
		If.mic {
			Condition {
				Type RegexMatch
				# guard with "=" to avoid empty string matching
				Regex "=(${var:__CodecId}(-sdca|-dmic)?)="
				String "=${var:MicCodec1}="
			}
			True.Define.MicCodecFile "${var:__CodecId}"
		}
	}
}

# probe codecs with multiple functions, modify file variables
If.multi_init {
	Condition {
		Type String
		Empty "${var:MultiCodec1}"
	}
	False {
		Macro.rt712.MultiCodecInit "CodecId=rt712"
		Macro.rt713.MultiCodecInit "CodecId=rt713"
		Macro.rt721.MultiCodecInit "CodecId=rt721"
		Macro.rt722.MultiCodecInit "CodecId=rt722"
		Macro.rt1320.MultiCodecInit "CodecId=rt1320"
	}
}

If.spk {
	Condition {
		Type String
		Empty "${var:SpeakerCodecFile}"
	}
	False.If.filter {
		Condition {
			Type RegexMatch
			Regex "(${var:MultiCodecRegex}|rt1318|cs42l43-spk(\\+cs35l56)?|cs35l56((-bridge)|(\\+cs42l43-spk))?|tas2783(-1)?)"
			String "${var:SpeakerCodecFile}"
		}
		True.Include.a.File "/codecs/${var:SpeakerCodecFile}/init.conf"
	}
}

If.mic {
	Condition {
		Type String
		Empty "${var:MicCodecFile}"
	}
	False.If.dup {
		Condition {
			Type String
			String1 "${var:MicCodecFile}"
			String2 "${var:SpeakerCodecFile}"
		}
		False.If.filter {
			Condition {
				Type RegexMatch
				Regex "(${var:MultiCodecRegex}|(acp|cs42l43|cs42l45|cs47l47)-dmic|rt715(-sdca)?)"
				String "${var:MicCodecFile}"
			}
			True.Include.a.File "/codecs/${var:MicCodecFile}/init.conf"
		}
	}
}

If.headset {
	Condition {
		Type String
		Empty "${var:HeadsetCodecFile}"
	}
	False.If.dup {
		Condition {
			Type String
			# guard with "=" to avoid empty string matching
			Needle "=${var:HeadsetCodecFile}="
			Haystack "=${var:SpeakerCodecFile}=${var:MicCodecFile}="
		}
		False.If.filter {
			Condition {
				Type RegexMatch
				Regex "(${var:MultiCodecRegex}|cs42l43|cs42l45|cs47l47|rt5682|rt700|rt711)"
				String "${var:HeadsetCodecFile}"
			}
			True.Include.a.File "/codecs/${var:HeadsetCodecFile}/init.conf"
		}
	}
}

If.mic_init_rt715 {
	Condition {
		Type String
		Needle "rt715"
		Haystack "${var:MicCodec1}"
	}
	True.Macro [{ SetLED { LED="mic" Action="detach" CtlId="PGA5.0 5 Master Capture Switch" } }]
}

If.pga_init_pga2 {
	Condition {
		Type ControlExists
		Control "name='PGA2.0 2 Master Capture Switch'"
	}
	True.BootSequence [
		cset "name='PGA2.0 2 Master Capture Switch' 1"
	]
}

If.pga_init_pga5 {
	Condition {
		Type ControlExists
		Control "name='PGA5.0 5 Master Capture Switch'"
	}
	True.BootSequence [
		cset "name='PGA5.0 5 Master Capture Switch' 1"
	]
}

If.pga_init_pga30 {
	Condition {
		Type ControlExists
		Control "name='PGA30.0 30 Playback Volume'"
	}
	True.BootSequence [
		cset "name='PGA30.0 30 Playback Volume' 32,32"
	]
}

If.mics-array {
	Condition {
		Type String
		Empty "${var:Mics1}"
	}
	False.FixedBootSequence [
		# dmic array info
		exec "-nhlt-dmic-info -o ${var:LibDir}/dmics-nhlt.json"
	]
}

Include.hdmi-pcm.File "/common/pcm/hdmi.conf"

Macro.0.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 5 Idx 0 }
Macro.1.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 6 Idx 1 }
Macro.2.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 7 Idx 2 }

If.HdmiIec61937 {
	Condition {
		Type RegexMatch
		Regex "((^|,)[567](,|$))"
		String "${var:Iec61937Pcms1}"
	}
	True.Macro.save_hdmi_cfg.HdmiPCMSave { Name "42-sof-hdmi" }
}

# Define macros to set up processing controls
Include.dsp-variables.File "/Intel/sof-hda-dsp/dsp.conf"

# Set BootSequence and FixedBootSequence for drc, eqiir, eqfir
Macro.SpeakerDrc.SofDrcBootSetup "endpoint='PostMixerSpeaker' direction='Playback'"
Macro.SpeakerIir.SofEqBootSetup "endpoint='PostMixerSpeaker' direction='Playback' eqtype='Iir'"
Macro.SpeakerFir.SofEqBootSetup "endpoint='PostMixerSpeaker' direction='Playback' eqtype='Fir'"

# Set BootSequence and FixedBootSequence for Mic array eqiir, tdfb, drc
Macro.MicArrayIir.SofEqBootSetup "endpoint='MicArray' direction='Capture' eqtype='Iir'"
Macro.MicArrayDrc.SofDrcBootSetup "endpoint='MicArray' direction='Capture'"
Macro.MicarrayTdfb.SofBeamformerBootSetup "endpoint='MicArray' direction='Capture'"

# For SoundWire PC with PCH-DMIC set BootSequence and FixedBootSequence for eqiir, tdfb, drc
Macro.Dmic0ArrayIir.SofEqBootSetup "endpoint='Dmic0' direction='Capture' eqtype='Iir'"
Macro.Dmic0ArrayDrc.SofDrcBootSetup "endpoint='Dmic0' direction='Capture'"
Macro.Dmic0ArrayTdfb.SofBeamformerBootSetup "endpoint='Dmic0' direction='Capture'"