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