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