blob: 4f76781d024b4a3352df24d595a2bc4c33d08e23 [file] [log] [blame]
Caleb Connollyd3e01642021-10-29 21:17:02 +01001<!-- This file is provided as a reference for writing config files
2It does NOT represent any particular device and will NOT work on
3real hardware. You must create a file with the correct settings for
4your hardware, and the comments here will explain the layout of this
5file and expected content.
6On the target device this file must be located in /system/etc and named
7audio.<device>.xml, where <device> is the string returned by the system
8property ro.product.device
9-->
10
11<audiohal>
12
13 <!-- mixer element _must_ appear before any of the other definitions.
14 The ALSA card can be identified either by card number or by name.
15 Connect to ALSA card 0:
16 <mixer card="0">
17 Connect to ALSA card called "FooSound"
18 <mixer name="FooSound">
19 When the card is given by name, TinyHAL searches all /proc/asound/card*/id
20 files for a matching name.
21 -->
22 <mixer card="0"> <!-- <mixer name="sdm845" > -->
23
24 <!-- A pre_init element lists control settings that will cause new ALSA
25 controls to be added. Typically this is used to load firmware into a
26 DSP, causing new ALSA controls to be added for controls exported by the
27 firmware. After processing a pre_init element the ALSA controls are
28 reloaded to pick up any new controls. Other elements in the
29 configuration can then use those controls.
30 Multiple pre_init elements can be used, so that a pre_init can depend
31 on controls populated by a previous pre_init.
32 All pre_init elements must appear before the init element.
33 -->
34
35 <pre_init>
36 <!-- A list of ctl elements - see description of init element -->
37 <!-- <ctl name="DSP1 Preload Switch" val="1" /> -->
38 </pre_init>
39
40 <!-- An init element lists control settings required to initialize the
41 hardware and driver. These settings are applied only once when the
42 library is first loaded during boot.
43 -->
44
45 <init>
46
47 <!-- A sequence of ctl elements. Each entry sets a mixer
48 control to a given value. The entries are applied in the
49 order they are listed here.
50 Each entry _must_ have these attributes
51 name - name of the ALSA mixer control
52 val - value to set it to
53 It can also have an index attribute giving the numeric index
54 of the control value to set. This is used where a control
55 has multiple value slots (for example a volume control
56 with two values, one for left channel and one for right), If
57 an index attribute is not given the content of the val attribute
58 will be applied to all value slots of the control.
59 The numbers in val and index attributes can be given in either
60 decimal, or hex (hex is prefixed with 0x). For a control with
61 enumerated values the val attribute must be a string
62 BYTE ARRAYS: for controls that are a byte array val must be
63 a string of comma-separated byte values. This can be shorter
64 than the total size of the control, combined with the
65 optional index attribute this allows any subset of the byte
66 array to be changed. Alternatively, a file attribute can be given
67 instead of the val attribute, and the raw byte content of the file
68 will be copied into the control. Note that the bytes in the file
69 must already be correctly formatted for writing into the ALSA
70 control. The file is read once when TinyHAL starts and this
71 cached content is used every time this <ctl> element is invoked.
72 -->
73
74 <ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" val="1" />
75 <ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia2" val="1" />
76 <ctl name="MultiMedia3 Mixer SLIMBUS_0_TX" val="1" />
77 <ctl name="AIF1_CAP Mixer SLIM TX7" val="1" />
78 <ctl name="CDC_IF TX7 MUX" val="DEC7" />
79 <ctl name="SLIM RX0 MUX" val="AIF1_PB" />
80 <ctl name="SLIM RX1 MUX" val="AIF1_PB" />
81 <ctl name="SLIM RX2 MUX" val="AIF1_PB" />
82 <ctl name="SLIM RX3 MUX" val="AIF1_PB" />
83 <ctl name="SLIM RX4 MUX" val="ZERO" />
84 <ctl name="SLIM RX5 MUX" val="ZERO" />
85 <ctl name="SLIM RX6 MUX" val="ZERO" />
86 <ctl name="SLIM RX7 MUX" val="ZERO" />
87 <ctl name="RX INT7_1 MIX1 INP0" val="RX0" />
88 <ctl name="RX INT8_1 MIX1 INP0" val="RX1" />
89 <ctl name="RX INT1_2 MUX" val="RX0" />
90 <ctl name="RX INT2_2 MUX" val="RX1" />
91
92
93 </init>
94 </mixer>
95
96<!-- Next you must list all the devices supported by the hardware. The
97name attribute of the <device> element identifies the device. These names are
98recognized:
99 "global" dummy global device - see explanation below
100 "speaker" AUDIO_DEVICE_OUT_SPEAKER
101 "earpiece" AUDIO_DEVICE_OUT_EARPIECE
102 "headset" AUDIO_DEVICE_OUT_WIRED_HEADSET
103 "headset_in" AUDIO_DEVICE_IN_WIRED_HEADSET
104 "headphone" AUDIO_DEVICE_OUT_WIRED_HEADPHONE
105 "sco" AUDIO_DEVICE_OUT_ALL_SCO
106 "sco_in" AUDIO_DEVICE_IN_ALL_SCO
107 "a2dp" AUDIO_DEVICE_OUT_ALL_A2DP
108 "usb" AUDIO_DEVICE_OUT_ALL_USB
109 "mic" AUDIO_DEVICE_IN_BUILTIN_MIC
110 "back mic" AUDIO_DEVICE_IN_BACK_MIC
111 "voice" AUDIO_DEVICE_IN_VOICE_CALL
112 "aux" AUDIO_DEVICE_IN_AUX_DIGITAL
113Within the <device> element you can declare a number of "paths", each path
114defines a group of control settings to be applied. Each path is identified by
115a name. The "on" and "off" paths are special and list a global enable and
116disable setting for the device. Use of devices is reference-counted, when
117routing of a stream is changed to use a device that is currently disabled its
118"on" path will be applied. When no streams are using a device its "off"
119path will be applied.
120Other paths are user-defined and you can give them any name you choose.
121They are used to apply custom paths when required by a stream and will
122be used only when a stream is connected to or disconnected from a
123device if the <stream> element has an <enable> or <disable> element requesting
124that path.
125It is not mandatory to provide paths. You only need to define paths
126if there are specific control settings that must be applied. So for example
127if no controls need be applied to enable or disable a device then you
128do not need to define the "on" and "off" paths.
129The <ctl> elements within each path have the same format and behaviour
130as described under <mixer><init>.
131The "global" device is a special device the represents the audio system as a
132whole and is used to invoke mixer settings that are independent of any real
133device and which apply globally to the audio system. A stream is automatically
134connected to "global" when it is opened and disconnected when it is closed.
135The behaviour is identical to the way paths are invoked in any other <device>
136entry so the effect is
137 - the "on" path will be applied when a stream is opened and there are
138 no other streams already open. As an example this could be used to
139 bring the audio hardware out of a standby state
140 - the "off" path will be applied when the last open stream is closed.
141 As an example this could be used to put the audio hardware into a
142 standby state
143 - the custom paths will be applied when the stream that requests them
144 is opened or closed.
145-->
146
147 <device name="speaker">
148 <path name="on">
149 <!-- List of ctl element for control values to apply
150 when this device is enabled -->
151 <!-- <ctl name="Amp DSP Switch" val="1"/> -->
152 </path>
153
154 <path name="off">
155 <!-- List of ctl element for control values to apply
156 when this device is disabled -->
157 <!-- <ctl name="Amp DSP Switch" val="0"/> -->
158 </path>
159
160 <!-- Following paths are user-defined and are applied when a
161 <stream> elements' routing is changed to add or remove this
162 device. If the path name matches the name given in the <stream>
163 element it will be applied. A stream could be routed to multiple
164 inputs or outputs - the paths for connecting and disconnecting
165 a stream to a device must therefore have the same name in each
166 <device>.
167 It is not mandatory to declare custom paths - depending on your
168 hardware there may not be any specific action required to route
169 a stream to a particular device. Also you do not have to define
170 the path in every device, only the devices where some action must
171 be taken to connect or disconnect a stream.
172 For this example four custom paths are defined:
173 pcm_out_en = control setting to connect PCM output to this device
174 pcm_out_dis = control setting to disconnect PCM output from this device
175 -->
176
177 <path name="pcm_out_en">
178 <ctl name="I2S RX0 MUX" val="AIF1_PB" />
179 <ctl name="MI2S_RX Channels" val="One" />
180 <ctl name="CDC_IF RX0 MUX" val="I2S RX0" />
181 <ctl name="RX INT8_1 MIX1 INP0" val="RX0" />
182 <ctl name="COMP8 Switch" val="1" />
183 <ctl name="SpkrRight COMP Switch" val="1" />
184 <ctl name="SpkrRight BOOST Switch" val="1" />
185 <ctl name="SpkrRight VISENSE Switch" val="1" />
186 <ctl name="SpkrRight SWR DAC_Port Switch" val="1" />
187 </path>
188 <path name="pcm_out_dis">
189 </path>
190 </device>
191
192 <device name="headphone">
193 <!-- <path name="on">
194 <ctl name="SLIM RX2 MUX" val="AIF1_PB"/>
195 <ctl name="SLIM RX3 MUX" val="AIF1_PB"/>
196 <ctl name="RX INT1 DEM MUX" val="CLSH_DSM_OUT"/>
197 <ctl name="RX INT2 DEM MUX" val="CLSH_DSM_OUT"/>
198 <ctl name="RX INT1_1 MIX1 INP0" val="RX2"/>
199 <ctl name="RX INT2_1 MIX1 INP0" val="RX3"/>
200 <ctl name="RX INT1_1 INTERP" val="RX INT1_1 MI"/>
201 <ctl name="RX INT2_1 INTERP" val="RX INT2_1 MI"/>
202 <ctl name="RX0 Digital Volume" val="0"/>
203 <ctl name="RX1 Digital Volume" val="80"/>
204 <ctl name="RX2 Digital Volume" val="80"/>
205 </path>
206
207 <path name="off">
208 <ctl name="SLIM RX2 MUX" val="ZERO"/>
209 <ctl name="SLIM RX3 MUX" val="ZERO"/>
210 <ctl name="RX INT1 DEM MUX" val="ZERO"/>
211 <ctl name="RX INT2 DEM MUX" val="ZERO"/>
212 <ctl name="RX INT1_1 MIX1 INP0" val="ZERO"/>
213 <ctl name="RX INT2_1 MIX1 INP0" val="ZERO"/>
214 <ctl name="RX INT1_1 INTERP" val="ZERO"/>
215 <ctl name="RX INT2_1 INTERP" val="ZERO"/>
216 <ctl name="RX1 Digital Volume" val="0"/>
217 <ctl name="RX2 Digital Volume" val="0"/>
218 </path> -->
219
220
221 <path name="pcm_out_en">
222 <ctl name="SLIM RX2 MUX" val="AIF4_PB" />
223 <ctl name="SLIM RX3 MUX" val="AIF4_PB" />
224 <ctl name="RX INT1_2 MUX" val="RX2" />
225 <ctl name="RX INT2_2 MUX" val="RX3" />
226 </path>
227
228 <path name="pcm_out_dis">
229 <ctl name="SLIM RX2 MUX" val="ZERO" />
230 <ctl name="SLIM RX3 MUX" val="ZERO" />
231 <ctl name="RX INT1_2 MUX" val="ZERO" />
232 <ctl name="RX INT2_2 MUX" val="ZERO" />
233 </path>
234 </device>
235
236<!-- Following the device definitions there must be a <stream> entry
237for every output and input stream supported by the hardware. It is also
238possible to define a 'global' stream that is not associated with any particular
239audio input or output but instead can be used to handle actions that are
240global to the audio hardware.
241There are two types of stream that can be declared here:
242- anonymous streams, these will be used to supply playback and record
243 streams for AudioFlinger
244- named streams, which are mainly used to declare custom streams to handle
245 special routing use-cases that are external to the normal Android audio
246 path - typically where the audio is routed entirely in hardware without
247 being passed through Android, for example the baseband audio link or
248 FM radio.
249 The global stream is a special case of a named stream and must have the
250 name "global"
251For standard anonymous streams there are two that would normally be on
252any device: PCM input and PCM output. It is also possible to declare a stream
253as "compress" - this is intended for cases where a playback stream is
254decompressed in hardware, or a record stream provides raw compressed data that
255must be decompressed in software.
256Named streams can be declared as type "hw", to represent a hardware-hardware
257link.
258The "global" named stream can be used to handle events that are not specific
259to any particular stream. Typically this is used to implement usecase handlers
260(see below) to handle set_parameter messages sent to the HAL's global
261(struct audio_device*)->hw_device.set_parameters function (for example, the
262"orientation" parameter that is sent by Android.)
263Mandatory attributes for PCM and compressed streams:
264 type must be "pcm" or "compress"
265 dir direction of stream, either "in" (recording) or "out" (playback)
266Mandatory for named streams:
267 type must be "pcm", "compress" or "hw"
268 dir direction of stream, either "in" (recording) or "out" (playback)
269 name a custom name for a named stream. The name you choose here must
270 match the name your HAL will use to request this stream
271Mandatory for hw streams:
272 type must be "hw"
273 dir direction of stream, either "in" (recording) or "out" (playback)
274 name a custom name for the stream (hw streams must be named streams)
275Mandatory for the global stream:
276 type must be "hw"
277 name must be "global"
278Optional attributes:
279 card ALSA card number. If not given this defaults to 0
280 device ALSA device number. If not given this defaults to 0
281 instances limits the maximum number of instances of this stream, if not
282 specified the number of instances is unlimited
283 name a custom name for a named stream. The name you choose here must
284 match the name your HAL will use to request this stream
285Anonymous PCM streams should not normally have an instance limit.
286TinyHAL defines a specific named stream:
287"voice recognition" - a PCM or compressed stream for voice recognition input.
288 If a stream with this name is not defined TinyHAL will
289 use the normal PCM input stream for voice recognition audio.
290-->
291
292 <stream type="pcm" dir="out" card="0" device="0">
293 <!-- The <enable> and <disable> tags give the name of a path
294 to apply for each connected device when the stream is either connected
295 to (enable) or disconnected from (disable) that device.
296 The way this works is that when stream routing changes, the HAL will
297 look through the paths of each device this stream is connected to,
298 - for each device the stream is being disconnected from, if it
299 contains a path matching the path name in <disable>, that path
300 will be applied.
301 - for each device the stream is being connected to, if it
302 contains a path matching the path name in <enable>, that path
303 will be applied.
304 -->
305 <enable path="pcm_out_en"/>
306 <disable path="pcm_out_dis"/>
307
308 <!-- The optional usecase block allows you to define custom use-cases that
309 are triggered by set_parameter() calls to the HAL. The set_parameter()
310 is a string of the form <setting>=<value>. The HAL will search for a
311 usecase block whose name attribute matches <setting> and within that
312 a case block whose name attribute matches <value>. If a matching case
313 block is found the enclosed <ctl> blocks will be applied.
314 The example below defines a use case for switching a codec algorithm
315 between wideband and narrowband response. The two cases will be
316 triggered by a set_parameter() of "bandwidth=narrow" or "bandwidth=wide".
317 -->
318 <!-- <usecase name="bandwidth">
319 <case name="narrow">
320 <ctl name="Codec Wideband" val="0" />
321 </case>
322 <case name="wide">
323 <ctl name="Codec Wideband" val="1" />
324 </case>
325 </usecase> -->
326
327 <!-- Constant values. These allow setting named values that can
328 be read by the audio HAL at runtime. Values are 32-bit unsigned.
329 This is useful for setting HAL-specific or hardware-specific
330 information.
331 The names have no meaning to the config manager, and are
332 entirely defined by the audio HAL.
333 If you want to set constants that are global, rather than part
334 of a stream, define a hw stream called "global".
335 to hold the values.
336 -->
337 <!-- <set name="foo" val="42"/> -->
338
339 </stream>
340
341 <stream type="pcm" dir="out" card="0" device="1">
342 </stream>
343
344 <!-- Example named stream, in this case for an FM radio path . This will not
345 be available for standard AudioFlinger playback and record paths. It must
346 be explicitly requested by the audio HAL when FM radio is enabled
347 -->
348 <!-- control paths to be enabled when this stream is enabled or disabled -->
349 <!-- <stream name="FM radio" type="pcm" dir="in" card="0" device="0">
350
351 <enable path="fm_radio_en"/>
352 <disable path="fm_radio_dis"/>
353 </stream> -->
354
355</audiohal>