1<?xml version="1.0" encoding="UTF-8"?>
2<!-- Copyright (C) 2017 The Android Open Source Project
3
4         Licensed under the Apache License, Version 2.0 (the "License");
5         you may not use this file except in compliance with the License.
6         You may obtain a copy of the License at
7
8                    http://www.apache.org/licenses/LICENSE-2.0
9
10         Unless required by applicable law or agreed to in writing, software
11         distributed under the License is distributed on an "AS IS" BASIS,
12         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13         See the License for the specific language governing permissions and
14         limitations under the License.
15-->
16<!-- TODO: define a targetNamespace. Note that it will break retrocompatibility -->
17<xs:schema version="2.0"
18           elementFormDefault="qualified"
19           attributeFormDefault="unqualified"
20           xmlns:xs="http://www.w3.org/2001/XMLSchema">
21    <!-- List the config versions supported by audio policy. -->
22    <xs:simpleType name="version">
23        <xs:restriction base="xs:decimal">
24            <xs:enumeration value="1.0"/>
25        </xs:restriction>
26    </xs:simpleType>
27    <xs:simpleType name="halVersion">
28        <xs:annotation>
29            <xs:documentation xml:lang="en">
30                Version of the interface the hal implements.
31            </xs:documentation>
32        </xs:annotation>
33        <xs:restriction base="xs:decimal">
34            <!-- List of HAL versions supported by the framework. -->
35            <xs:enumeration value="2.0"/>
36            <xs:enumeration value="3.0"/>
37        </xs:restriction>
38    </xs:simpleType>
39    <xs:element name="audioPolicyConfiguration">
40        <xs:complexType>
41            <xs:sequence>
42                <xs:element name="globalConfiguration" type="globalConfiguration"/>
43                <xs:element name="modules" type="modules" maxOccurs="unbounded"/>
44                <xs:element name="volumes" type="volumes" maxOccurs="unbounded"/>
45                <xs:element name="surroundSound" type="surroundSound" minOccurs="0" />
46            </xs:sequence>
47            <xs:attribute name="version" type="version"/>
48        </xs:complexType>
49        <xs:key name="moduleNameKey">
50            <xs:selector xpath="modules/module"/>
51            <xs:field xpath="@name"/>
52        </xs:key>
53        <xs:unique name="volumeTargetUniqueness">
54            <xs:selector xpath="volumes/volume"/>
55            <xs:field xpath="@stream"/>
56            <xs:field xpath="@deviceCategory"/>
57        </xs:unique>
58        <xs:key name="volumeCurveNameKey">
59            <xs:selector xpath="volumes/reference"/>
60            <xs:field xpath="@name"/>
61        </xs:key>
62        <xs:keyref name="volumeCurveRef" refer="volumeCurveNameKey">
63            <xs:selector xpath="volumes/volume"/>
64            <xs:field xpath="@ref"/>
65        </xs:keyref>
66    </xs:element>
67    <xs:complexType name="globalConfiguration">
68        <xs:attribute name="speaker_drc_enabled" type="xs:boolean" use="required"/>
69    </xs:complexType>
70    <xs:complexType name="modules">
71        <xs:annotation>
72            <xs:documentation xml:lang="en">
73                There should be one section per audio HW module present on the platform.
74                Each <module/> contains two mandatory tags: “halVersion” and “name”.
75                The module "name" is the same as in previous .conf file.
76                Each module must contain the following sections:
77                 - <devicePorts/>: a list of device descriptors for all
78                   input and output devices accessible via this module.
79                   This contains both permanently attached devices and removable devices.
80                 - <mixPorts/>: listing all output and input streams exposed by the audio HAL
81                 - <routes/>: list of possible connections between input
82                   and output devices or between stream and devices.
83                   A <route/> is defined by a set of 3 attributes:
84                        -"type": mux|mix means all sources are mutual exclusive (mux) or can be mixed (mix)
85                        -"sink": the sink involved in this route
86                        -"sources": all the sources than can be connected to the sink via this route
87                 - <attachedDevices/>: permanently attached devices.
88                   The attachedDevices section is a list of devices names.
89                   Their names correspond to device names defined in "devicePorts" section.
90                 - <defaultOutputDevice/> is the device to be used when no policy rule applies
91            </xs:documentation>
92        </xs:annotation>
93        <xs:sequence>
94            <xs:element name="module" maxOccurs="unbounded">
95                <xs:complexType>
96                    <xs:sequence>
97                        <xs:element name="attachedDevices" type="attachedDevices" minOccurs="0">
98                            <xs:unique name="attachedDevicesUniqueness">
99                                <xs:selector xpath="item"/>
100                                <xs:field xpath="."/>
101                            </xs:unique>
102                        </xs:element>
103                        <xs:element name="defaultOutputDevice" type="xs:token" minOccurs="0"/>
104                        <xs:element name="mixPorts" type="mixPorts" minOccurs="0"/>
105                        <xs:element name="devicePorts" type="devicePorts" minOccurs="0"/>
106                        <xs:element name="routes" type="routes" minOccurs="0"/>
107                    </xs:sequence>
108                    <xs:attribute name="name" type="xs:string" use="required"/>
109                    <xs:attribute name="halVersion" type="halVersion" use="required"/>
110                </xs:complexType>
111                <xs:unique name="mixPortNameUniqueness">
112                    <xs:selector xpath="mixPorts/mixPort"/>
113                    <xs:field xpath="@name"/>
114                </xs:unique>
115                <xs:key name="devicePortNameKey">
116                    <xs:selector xpath="devicePorts/devicePort"/>
117                    <xs:field xpath="@tagName"/>
118                </xs:key>
119                <xs:unique name="devicePortUniqueness">
120                    <xs:selector xpath="devicePorts/devicePort"/>
121                    <xs:field xpath="@type"/>
122                    <xs:field xpath="@address"/>
123                </xs:unique>
124                <xs:keyref name="defaultOutputDeviceRef" refer="devicePortNameKey">
125                    <xs:selector xpath="defaultOutputDevice"/>
126                    <xs:field xpath="."/>
127                </xs:keyref>
128                <xs:keyref name="attachedDeviceRef" refer="devicePortNameKey">
129                    <xs:selector xpath="attachedDevices/item"/>
130                    <xs:field xpath="."/>
131                </xs:keyref>
132                <!-- The following 3 constraints try to make sure each sink port
133                     is reference in one an only one route. -->
134                <xs:key name="routeSinkKey">
135                    <!-- predicate [@type='sink'] does not work in xsd 1.0 -->
136                    <xs:selector xpath="devicePorts/devicePort|mixPorts/mixPort"/>
137                    <xs:field xpath="@tagName|@name"/>
138                </xs:key>
139                <xs:keyref name="routeSinkRef" refer="routeSinkKey">
140                    <xs:selector xpath="routes/route"/>
141                    <xs:field xpath="@sink"/>
142                </xs:keyref>
143                <xs:unique name="routeUniqueness">
144                    <xs:selector xpath="routes/route"/>
145                    <xs:field xpath="@sink"/>
146                </xs:unique>
147            </xs:element>
148        </xs:sequence>
149    </xs:complexType>
150    <xs:complexType name="attachedDevices">
151        <xs:sequence>
152            <xs:element name="item" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
153        </xs:sequence>
154    </xs:complexType>
155    <!-- TODO: separate values by space for better xsd validations. -->
156    <xs:simpleType name="audioInOutFlags">
157        <xs:annotation>
158            <xs:documentation xml:lang="en">
159                "|" separated list of audio_output_flags_t or audio_input_flags_t.
160            </xs:documentation>
161        </xs:annotation>
162        <xs:restriction base="xs:string">
163            <xs:pattern value="|[_A-Z]+(\|[_A-Z]+)*"/>
164        </xs:restriction>
165    </xs:simpleType>
166    <xs:simpleType name="role">
167        <xs:restriction base="xs:string">
168            <xs:enumeration value="sink"/>
169            <xs:enumeration value="source"/>
170        </xs:restriction>
171    </xs:simpleType>
172    <xs:complexType name="mixPorts">
173        <xs:sequence>
174            <xs:element name="mixPort" minOccurs="0" maxOccurs="unbounded">
175                <xs:complexType>
176                    <xs:sequence>
177                        <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
178                        <xs:element name="gains" type="gains" minOccurs="0"/>
179                    </xs:sequence>
180                    <xs:attribute name="name" type="xs:token" use="required"/>
181                    <xs:attribute name="role" type="role" use="required"/>
182                    <xs:attribute name="flags" type="audioInOutFlags"/>
183                    <xs:attribute name="maxOpenCount" type="xs:unsignedInt"/>
184                    <xs:attribute name="maxActiveCount" type="xs:unsignedInt"/>
185                    <xs:attribute name="preferredUsage" type="audioUsageList">
186                        <xs:annotation>
187                            <xs:documentation xml:lang="en">
188                                When choosing the mixPort of an audio track, the audioPolicy
189                                first considers the mixPorts with a preferredUsage including
190                                the track AudioUsage preferred .
191                                If non support the track format, the other mixPorts are considered.
192                                Eg: a <mixPort preferredUsage="AUDIO_USAGE_MEDIA" /> will receive
193                                    the audio of all apps playing with a MEDIA usage.
194                                    It may receive audio from ALARM if there are no audio compatible
195                                    <mixPort preferredUsage="AUDIO_USAGE_ALARM" />.
196                             </xs:documentation>
197                        </xs:annotation>
198                    </xs:attribute>
199                </xs:complexType>
200                <xs:unique name="mixPortProfileUniqueness">
201                    <xs:selector xpath="profile"/>
202                    <xs:field xpath="format"/>
203                    <xs:field xpath="samplingRate"/>
204                    <xs:field xpath="channelMasks"/>
205                </xs:unique>
206                <xs:unique name="mixPortGainUniqueness">
207                    <xs:selector xpath="gains/gain"/>
208                    <xs:field xpath="@name"/>
209                </xs:unique>
210            </xs:element>
211        </xs:sequence>
212    </xs:complexType>
213    <!-- Enum values of audio_device_t in audio.h
214         TODO: generate from hidl to avoid manual sync.
215         TODO: separate source and sink in the xml for better xsd validations. -->
216    <xs:simpleType name="audioDevice">
217        <xs:restriction base="xs:string">
218            <xs:enumeration value="AUDIO_DEVICE_NONE"/>
219
220            <xs:enumeration value="AUDIO_DEVICE_OUT_EARPIECE"/>
221            <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER"/>
222            <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADSET"/>
223            <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADPHONE"/>
224            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO"/>
225            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET"/>
226            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT"/>
227            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP"/>
228            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES"/>
229            <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER"/>
230            <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_DIGITAL"/>
231            <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI"/>
232            <xs:enumeration value="AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET"/>
233            <xs:enumeration value="AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET"/>
234            <xs:enumeration value="AUDIO_DEVICE_OUT_USB_ACCESSORY"/>
235            <xs:enumeration value="AUDIO_DEVICE_OUT_USB_DEVICE"/>
236            <xs:enumeration value="AUDIO_DEVICE_OUT_REMOTE_SUBMIX"/>
237            <xs:enumeration value="AUDIO_DEVICE_OUT_TELEPHONY_TX"/>
238            <xs:enumeration value="AUDIO_DEVICE_OUT_LINE"/>
239            <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI_ARC"/>
240            <xs:enumeration value="AUDIO_DEVICE_OUT_SPDIF"/>
241            <xs:enumeration value="AUDIO_DEVICE_OUT_FM"/>
242            <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_LINE"/>
243            <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER_SAFE"/>
244            <xs:enumeration value="AUDIO_DEVICE_OUT_IP"/>
245            <xs:enumeration value="AUDIO_DEVICE_OUT_BUS"/>
246            <xs:enumeration value="AUDIO_DEVICE_OUT_PROXY"/>
247            <xs:enumeration value="AUDIO_DEVICE_OUT_USB_HEADSET"/>
248            <xs:enumeration value="AUDIO_DEVICE_OUT_HEARING_AID"/>
249            <xs:enumeration value="AUDIO_DEVICE_OUT_ECHO_CANCELLER"/>
250            <xs:enumeration value="AUDIO_DEVICE_OUT_DEFAULT"/>
251            <xs:enumeration value="AUDIO_DEVICE_OUT_STUB"/>
252
253            <!-- Due to the xml format, IN types can not be a separated from OUT types -->
254            <xs:enumeration value="AUDIO_DEVICE_IN_COMMUNICATION"/>
255            <xs:enumeration value="AUDIO_DEVICE_IN_AMBIENT"/>
256            <xs:enumeration value="AUDIO_DEVICE_IN_BUILTIN_MIC"/>
257            <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET"/>
258            <xs:enumeration value="AUDIO_DEVICE_IN_WIRED_HEADSET"/>
259            <xs:enumeration value="AUDIO_DEVICE_IN_AUX_DIGITAL"/>
260            <xs:enumeration value="AUDIO_DEVICE_IN_HDMI"/>
261            <xs:enumeration value="AUDIO_DEVICE_IN_VOICE_CALL"/>
262            <xs:enumeration value="AUDIO_DEVICE_IN_TELEPHONY_RX"/>
263            <xs:enumeration value="AUDIO_DEVICE_IN_BACK_MIC"/>
264            <xs:enumeration value="AUDIO_DEVICE_IN_REMOTE_SUBMIX"/>
265            <xs:enumeration value="AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET"/>
266            <xs:enumeration value="AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET"/>
267            <xs:enumeration value="AUDIO_DEVICE_IN_USB_ACCESSORY"/>
268            <xs:enumeration value="AUDIO_DEVICE_IN_USB_DEVICE"/>
269            <xs:enumeration value="AUDIO_DEVICE_IN_FM_TUNER"/>
270            <xs:enumeration value="AUDIO_DEVICE_IN_TV_TUNER"/>
271            <xs:enumeration value="AUDIO_DEVICE_IN_LINE"/>
272            <xs:enumeration value="AUDIO_DEVICE_IN_SPDIF"/>
273            <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_A2DP"/>
274            <xs:enumeration value="AUDIO_DEVICE_IN_LOOPBACK"/>
275            <xs:enumeration value="AUDIO_DEVICE_IN_IP"/>
276            <xs:enumeration value="AUDIO_DEVICE_IN_BUS"/>
277            <xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/>
278            <xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/>
279            <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/>
280            <xs:enumeration value="AUDIO_DEVICE_IN_HDMI_ARC"/>
281            <xs:enumeration value="AUDIO_DEVICE_IN_ECHO_REFERENCE"/>
282            <xs:enumeration value="AUDIO_DEVICE_IN_DEFAULT"/>
283            <xs:enumeration value="AUDIO_DEVICE_IN_STUB"/>
284        </xs:restriction>
285    </xs:simpleType>
286    <xs:simpleType name="vendorExtension">
287        <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values.
288             Vendor are encouraged to namespace their module names to avoid conflicts.
289             Example for an hypothetical Google virtual reality device:
290                <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink">
291        -->
292        <xs:restriction base="xs:string">
293            <xs:pattern value="VX_[_a-zA-Z0-9]+"/>
294        </xs:restriction>
295    </xs:simpleType>
296    <xs:simpleType name="extendableAudioDevice">
297        <xs:union memberTypes="audioDevice vendorExtension"/>
298    </xs:simpleType>
299    <!-- Enum values of audio_format_t in audio.h
300         TODO: generate from hidl to avoid manual sync. -->
301    <xs:simpleType name="audioFormat">
302        <xs:restriction base="xs:string">
303            <xs:enumeration value="AUDIO_FORMAT_PCM_16_BIT" />
304            <xs:enumeration value="AUDIO_FORMAT_PCM_8_BIT"/>
305            <xs:enumeration value="AUDIO_FORMAT_PCM_32_BIT"/>
306            <xs:enumeration value="AUDIO_FORMAT_PCM_8_24_BIT"/>
307            <xs:enumeration value="AUDIO_FORMAT_PCM_FLOAT"/>
308            <xs:enumeration value="AUDIO_FORMAT_PCM_24_BIT_PACKED"/>
309            <xs:enumeration value="AUDIO_FORMAT_MP3"/>
310            <xs:enumeration value="AUDIO_FORMAT_AMR_NB"/>
311            <xs:enumeration value="AUDIO_FORMAT_AMR_WB"/>
312            <xs:enumeration value="AUDIO_FORMAT_AAC"/>
313            <xs:enumeration value="AUDIO_FORMAT_AAC_MAIN"/>
314            <xs:enumeration value="AUDIO_FORMAT_AAC_LC"/>
315            <xs:enumeration value="AUDIO_FORMAT_AAC_SSR"/>
316            <xs:enumeration value="AUDIO_FORMAT_AAC_LTP"/>
317            <xs:enumeration value="AUDIO_FORMAT_AAC_HE_V1"/>
318            <xs:enumeration value="AUDIO_FORMAT_AAC_SCALABLE"/>
319            <xs:enumeration value="AUDIO_FORMAT_AAC_ERLC"/>
320            <xs:enumeration value="AUDIO_FORMAT_AAC_LD"/>
321            <xs:enumeration value="AUDIO_FORMAT_AAC_HE_V2"/>
322            <xs:enumeration value="AUDIO_FORMAT_AAC_ELD"/>
323            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_MAIN"/>
324            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LC"/>
325            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SSR"/>
326            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LTP"/>
327            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V1"/>
328            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SCALABLE"/>
329            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ERLC"/>
330            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LD"/>
331            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V2"/>
332            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ELD"/>
333            <xs:enumeration value="AUDIO_FORMAT_VORBIS"/>
334            <xs:enumeration value="AUDIO_FORMAT_HE_AAC_V1"/>
335            <xs:enumeration value="AUDIO_FORMAT_HE_AAC_V2"/>
336            <xs:enumeration value="AUDIO_FORMAT_OPUS"/>
337            <xs:enumeration value="AUDIO_FORMAT_AC3"/>
338            <xs:enumeration value="AUDIO_FORMAT_E_AC3"/>
339            <xs:enumeration value="AUDIO_FORMAT_DTS"/>
340            <xs:enumeration value="AUDIO_FORMAT_DTS_HD"/>
341            <xs:enumeration value="AUDIO_FORMAT_IEC61937"/>
342            <xs:enumeration value="AUDIO_FORMAT_DOLBY_TRUEHD"/>
343            <xs:enumeration value="AUDIO_FORMAT_EVRC"/>
344            <xs:enumeration value="AUDIO_FORMAT_EVRCB"/>
345            <xs:enumeration value="AUDIO_FORMAT_EVRCWB"/>
346            <xs:enumeration value="AUDIO_FORMAT_EVRCNW"/>
347            <xs:enumeration value="AUDIO_FORMAT_AAC_ADIF"/>
348            <xs:enumeration value="AUDIO_FORMAT_WMA"/>
349            <xs:enumeration value="AUDIO_FORMAT_WMA_PRO"/>
350            <xs:enumeration value="AUDIO_FORMAT_AMR_WB_PLUS"/>
351            <xs:enumeration value="AUDIO_FORMAT_MP2"/>
352            <xs:enumeration value="AUDIO_FORMAT_QCELP"/>
353            <xs:enumeration value="AUDIO_FORMAT_DSD"/>
354            <xs:enumeration value="AUDIO_FORMAT_FLAC"/>
355            <xs:enumeration value="AUDIO_FORMAT_ALAC"/>
356            <xs:enumeration value="AUDIO_FORMAT_APE"/>
357            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS"/>
358            <xs:enumeration value="AUDIO_FORMAT_SBC"/>
359            <xs:enumeration value="AUDIO_FORMAT_APTX"/>
360            <xs:enumeration value="AUDIO_FORMAT_APTX_HD"/>
361            <xs:enumeration value="AUDIO_FORMAT_AC4"/>
362            <xs:enumeration value="AUDIO_FORMAT_LDAC"/>
363            <xs:enumeration value="AUDIO_FORMAT_E_AC3_JOC"/>
364            <xs:enumeration value="AUDIO_FORMAT_MAT_1_0"/>
365            <xs:enumeration value="AUDIO_FORMAT_MAT_2_0"/>
366            <xs:enumeration value="AUDIO_FORMAT_MAT_2_1"/>
367            <xs:enumeration value="AUDIO_FORMAT_AAC_XHE"/>
368            <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_XHE"/>
369            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM"/>
370            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_LC"/>
371            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V1"/>
372            <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V2"/>
373            <xs:enumeration value="AUDIO_FORMAT_CELT"/>
374            <xs:enumeration value="AUDIO_FORMAT_APTX_ADAPTIVE"/>
375            <xs:enumeration value="AUDIO_FORMAT_LHDC"/>
376            <xs:enumeration value="AUDIO_FORMAT_LHDC_LL"/>
377            <xs:enumeration value="AUDIO_FORMAT_APTX_TWSP"/>
378        </xs:restriction>
379    </xs:simpleType>
380    <xs:simpleType name="extendableAudioFormat">
381        <xs:union memberTypes="audioFormat vendorExtension"/>
382    </xs:simpleType>
383    <!-- Enum values of audio::common::4_0::AudioUsage
384         TODO: generate from HIDL to avoid manual sync. -->
385    <xs:simpleType name="audioUsage">
386        <xs:restriction base="xs:string">
387            <xs:enumeration value="AUDIO_USAGE_UNKNOWN" />
388            <xs:enumeration value="AUDIO_USAGE_MEDIA" />
389            <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION" />
390            <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING" />
391            <xs:enumeration value="AUDIO_USAGE_ALARM" />
392            <xs:enumeration value="AUDIO_USAGE_NOTIFICATION" />
393            <xs:enumeration value="AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE" />
394            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY" />
395            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE" />
396            <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_SONIFICATION" />
397            <xs:enumeration value="AUDIO_USAGE_GAME" />
398            <xs:enumeration value="AUDIO_USAGE_VIRTUAL_SOURCE" />
399            <xs:enumeration value="AUDIO_USAGE_ASSISTANT" />
400        </xs:restriction>
401    </xs:simpleType>
402    <xs:simpleType name="audioUsageList">
403        <xs:list itemType="audioUsage"/>
404    </xs:simpleType>
405    <!-- TODO: Change to a space separated list to xsd enforce correctness. -->
406    <xs:simpleType name="samplingRates">
407        <xs:restriction base="xs:string">
408            <xs:pattern value="[0-9]+(,[0-9]+)*"/>
409        </xs:restriction>
410    </xs:simpleType>
411    <!-- TODO: Change to a space separated list to xsd enforce correctness. -->
412    <xs:simpleType name="channelMask">
413        <xs:annotation>
414            <xs:documentation xml:lang="en">
415                Comma (",") separated list of channel flags
416                from audio_channel_mask_t.
417            </xs:documentation>
418        </xs:annotation>
419        <xs:restriction base="xs:string">
420            <xs:pattern value="[_A-Z][_A-Z0-9]*(,[_A-Z][_A-Z0-9]*)*"/>
421        </xs:restriction>
422    </xs:simpleType>
423    <xs:complexType name="profile">
424        <xs:attribute name="name" type="xs:token" use="optional"/>
425        <xs:attribute name="format" type="extendableAudioFormat" use="optional"/>
426        <xs:attribute name="samplingRates" type="samplingRates" use="optional"/>
427        <xs:attribute name="channelMasks" type="channelMask" use="optional"/>
428    </xs:complexType>
429    <xs:simpleType name="gainMode">
430        <xs:restriction base="xs:string">
431            <xs:enumeration value="AUDIO_GAIN_MODE_JOINT"/>
432            <xs:enumeration value="AUDIO_GAIN_MODE_CHANNELS"/>
433            <xs:enumeration value="AUDIO_GAIN_MODE_RAMP"/>
434        </xs:restriction>
435    </xs:simpleType>
436    <xs:complexType name="gains">
437        <xs:sequence>
438            <xs:element name="gain" minOccurs="0" maxOccurs="unbounded">
439                <xs:complexType>
440                    <xs:attribute name="name" type="xs:token" use="required"/>
441                    <xs:attribute name="mode" type="gainMode" use="required"/>
442                    <xs:attribute name="channel_mask" type="channelMask" use="optional"/>
443                    <xs:attribute name="minValueMB" type="xs:int" use="optional"/>
444                    <xs:attribute name="maxValueMB" type="xs:int" use="optional"/>
445                    <xs:attribute name="defaultValueMB" type="xs:int" use="optional"/>
446                    <xs:attribute name="stepValueMB" type="xs:int" use="optional"/>
447                    <xs:attribute name="minRampMs" type="xs:int" use="optional"/>
448                    <xs:attribute name="maxRampMs" type="xs:int" use="optional"/>
449                    <xs:attribute name="useForVolume" type="xs:boolean" use="optional"/>
450                </xs:complexType>
451            </xs:element>
452        </xs:sequence>
453    </xs:complexType>
454    <xs:complexType name="devicePorts">
455        <xs:sequence>
456            <xs:element name="devicePort" minOccurs="0" maxOccurs="unbounded">
457                <xs:complexType>
458                    <xs:sequence>
459                        <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
460                        <xs:element name="gains" type="gains" minOccurs="0"/>
461                    </xs:sequence>
462                    <xs:attribute name="tagName" type="xs:token" use="required"/>
463                    <xs:attribute name="type" type="extendableAudioDevice" use="required"/>
464                    <xs:attribute name="role" type="role" use="required"/>
465                    <xs:attribute name="address" type="xs:string" use="optional" default=""/>
466                    <!-- Note that XSD 1.0 can not check that a type only has one default. -->
467                    <xs:attribute name="default" type="xs:boolean" use="optional">
468                        <xs:annotation>
469                            <xs:documentation xml:lang="en">
470                                The default device will be used if multiple have the same type
471                                and no explicit route request exists for a specific device of
472                                that type.
473                            </xs:documentation>
474                        </xs:annotation>
475                    </xs:attribute>
476                    <xs:attribute name="encodedFormats" type="audioFormatsList" use="optional"
477                                  default="" />
478                </xs:complexType>
479                <xs:unique name="devicePortProfileUniqueness">
480                    <xs:selector xpath="profile"/>
481                    <xs:field xpath="format"/>
482                    <xs:field xpath="samplingRate"/>
483                    <xs:field xpath="channelMasks"/>
484                </xs:unique>
485                <xs:unique name="devicePortGainUniqueness">
486                    <xs:selector xpath="gains/gain"/>
487                    <xs:field xpath="@name"/>
488                </xs:unique>
489            </xs:element>
490        </xs:sequence>
491    </xs:complexType>
492    <xs:simpleType name="mixType">
493        <xs:restriction base="xs:string">
494            <xs:enumeration value="mix"/>
495            <xs:enumeration value="mux"/>
496        </xs:restriction>
497    </xs:simpleType>
498    <xs:complexType name="routes">
499        <xs:sequence>
500            <xs:element name="route" minOccurs="0" maxOccurs="unbounded">
501                <xs:annotation>
502                    <xs:documentation xml:lang="en">
503                        List all available sources for a given sink.
504                    </xs:documentation>
505                </xs:annotation>
506                <xs:complexType>
507                    <xs:attribute name="type" type="mixType" use="required"/>
508                    <xs:attribute name="sink" type="xs:string" use="required"/>
509                    <xs:attribute name="sources" type="xs:string" use="required"/>
510                </xs:complexType>
511            </xs:element>
512        </xs:sequence>
513    </xs:complexType>
514    <xs:complexType name="volumes">
515        <xs:sequence>
516            <xs:element name="volume" type="volume" minOccurs="0" maxOccurs="unbounded"/>
517            <xs:element name="reference" type="reference" minOccurs="0" maxOccurs="unbounded">
518            </xs:element>
519        </xs:sequence>
520    </xs:complexType>
521    <!-- TODO: Always require a ref for better xsd validations.
522               Currently a volume could have no points nor ref
523               as it can not be forbidden by xsd 1.0.-->
524    <xs:simpleType name="volumePoint">
525        <xs:annotation>
526            <xs:documentation xml:lang="en">
527                Comma separated pair of number.
528                The fist one is the framework level (between 0 and 100).
529                The second one is the volume to send to the HAL.
530                The framework will interpolate volumes not specified.
531                Their MUST be at least 2 points specified.
532            </xs:documentation>
533        </xs:annotation>
534        <xs:restriction base="xs:string">
535            <xs:pattern value="([0-9]{1,2}|100),-?[0-9]+"/>
536        </xs:restriction>
537    </xs:simpleType>
538    <!-- Enum values of audio_stream_type_t in audio-base.h
539         TODO: generate from hidl to avoid manual sync. -->
540    <xs:simpleType name="stream">
541        <xs:restriction base="xs:string">
542            <xs:enumeration value="AUDIO_STREAM_VOICE_CALL"/>
543            <xs:enumeration value="AUDIO_STREAM_SYSTEM"/>
544            <xs:enumeration value="AUDIO_STREAM_RING"/>
545            <xs:enumeration value="AUDIO_STREAM_MUSIC"/>
546            <xs:enumeration value="AUDIO_STREAM_ALARM"/>
547            <xs:enumeration value="AUDIO_STREAM_NOTIFICATION"/>
548            <xs:enumeration value="AUDIO_STREAM_BLUETOOTH_SCO"/>
549            <xs:enumeration value="AUDIO_STREAM_ENFORCED_AUDIBLE"/>
550            <xs:enumeration value="AUDIO_STREAM_DTMF"/>
551            <xs:enumeration value="AUDIO_STREAM_TTS"/>
552            <xs:enumeration value="AUDIO_STREAM_ACCESSIBILITY"/>
553            <xs:enumeration value="AUDIO_STREAM_REROUTING"/>
554            <xs:enumeration value="AUDIO_STREAM_PATCH"/>
555        </xs:restriction>
556    </xs:simpleType>
557    <!-- Enum values of device_category from Volume.h.
558         TODO: generate from hidl to avoid manual sync. -->
559    <xs:simpleType name="deviceCategory">
560        <xs:restriction base="xs:string">
561            <xs:enumeration value="DEVICE_CATEGORY_HEADSET"/>
562            <xs:enumeration value="DEVICE_CATEGORY_SPEAKER"/>
563            <xs:enumeration value="DEVICE_CATEGORY_EARPIECE"/>
564            <xs:enumeration value="DEVICE_CATEGORY_EXT_MEDIA"/>
565            <xs:enumeration value="DEVICE_CATEGORY_HEARING_AID"/>
566        </xs:restriction>
567    </xs:simpleType>
568    <xs:complexType name="volume">
569        <xs:annotation>
570            <xs:documentation xml:lang="en">
571                Volume section defines a volume curve for a given use case and device category.
572                It contains a list of points of this curve expressing the attenuation in Millibels
573                for a given volume index from 0 to 100.
574                <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER">
575                    <point>0,-9600</point>
576                    <point>100,0</point>
577                </volume>
578
579                It may also reference a reference/@name to avoid duplicating curves.
580                <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER"
581                        ref="DEFAULT_MEDIA_VOLUME_CURVE"/>
582                <reference name="DEFAULT_MEDIA_VOLUME_CURVE">
583                    <point>0,-9600</point>
584                    <point>100,0</point>
585                </reference>
586            </xs:documentation>
587        </xs:annotation>
588        <xs:sequence>
589            <xs:element name="point" type="volumePoint" minOccurs="0" maxOccurs="unbounded"/>
590        </xs:sequence>
591        <xs:attribute name="stream" type="stream"/>
592        <xs:attribute name="deviceCategory" type="deviceCategory"/>
593        <xs:attribute name="ref" type="xs:token" use="optional"/>
594    </xs:complexType>
595    <xs:complexType name="reference">
596        <xs:sequence>
597            <xs:element name="point" type="volumePoint" minOccurs="2" maxOccurs="unbounded"/>
598        </xs:sequence>
599        <xs:attribute name="name" type="xs:token" use="required"/>
600    </xs:complexType>
601    <xs:complexType name="surroundSound">
602        <xs:annotation>
603            <xs:documentation xml:lang="en">
604                Surround Sound section provides configuration related to handling of
605                multi-channel formats.
606            </xs:documentation>
607        </xs:annotation>
608        <xs:sequence>
609            <xs:element name="formats" type="surroundFormats"/>
610        </xs:sequence>
611    </xs:complexType>
612    <xs:simpleType name="audioFormatsList">
613        <xs:list itemType="audioFormat" />
614    </xs:simpleType>
615    <xs:complexType name="surroundFormats">
616        <xs:sequence>
617            <xs:element name="format" minOccurs="0" maxOccurs="unbounded">
618                <xs:complexType>
619                    <xs:attribute name="name" type="audioFormat" use="required"/>
620                    <xs:attribute name="subformats" type="audioFormatsList" />
621                </xs:complexType>
622            </xs:element>
623        </xs:sequence>
624    </xs:complexType>
625</xs:schema>
626