Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / sound / usb / uaudioreg.h
1 /*      $NetBSD: uaudioreg.h,v 1.7 2000/12/28 00:29:58 augustss Exp $   */
2 /* $FreeBSD: src/sys/dev/sound/usb/uaudioreg.h,v 1.1.2.2 2002/11/06 21:40:31 joe Exp $ */
3
4 /*
5  * Copyright (c) 1999 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Lennart Augustsson (lennart@augustsson.net) at
10  * Carlstedt Research & Technology.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *        This product includes software developed by the NetBSD
23  *        Foundation, Inc. and its contributors.
24  * 4. Neither the name of The NetBSD Foundation nor the names of its
25  *    contributors may be used to endorse or promote products derived
26  *    from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  */
40
41 #define UAUDIO_VERSION          0x100
42
43 #define UDESC_CS_DEVICE         0x21
44 #define UDESC_CS_CONFIG         0x22
45 #define UDESC_CS_STRING         0x23
46 #define UDESC_CS_INTERFACE      0x24
47 #define UDESC_CS_ENDPOINT       0x25
48
49 #define UDESCSUB_AC_HEADER      1
50 #define UDESCSUB_AC_INPUT       2
51 #define UDESCSUB_AC_OUTPUT      3
52 #define UDESCSUB_AC_MIXER       4
53 #define UDESCSUB_AC_SELECTOR    5
54 #define UDESCSUB_AC_FEATURE     6
55 #define UDESCSUB_AC_PROCESSING  7
56 #define UDESCSUB_AC_EXTENSION   8
57
58 /* The first fields are identical to usb_endpoint_descriptor_t */
59 typedef struct {
60         uByte           bLength;
61         uByte           bDescriptorType;
62         uByte           bEndpointAddress;
63         uByte           bmAttributes;
64         uWord           wMaxPacketSize;
65         uByte           bInterval;
66         /* 
67          * The following two entries are only used by the Audio Class.
68          * And according to the specs the Audio Class is the only one
69          * allowed to extend the endpoint descriptor.
70          * Who knows what goes on in the minds of the people in the USB
71          * standardization?  :-(
72          */
73         uByte           bRefresh;
74         uByte           bSynchAddress;
75 } UPACKED usb_endpoint_descriptor_audio_t;
76
77 struct usb_audio_control_descriptor {
78         uByte           bLength;
79         uByte           bDescriptorType;
80         uByte           bDescriptorSubtype;
81         uWord           bcdADC;
82         uWord           wTotalLength;
83         uByte           bInCollection;
84         uByte           baInterfaceNr[1];
85 } UPACKED;
86
87 struct usb_audio_streaming_interface_descriptor {
88         uByte           bLength;
89         uByte           bDescriptorType;
90         uByte           bDescriptorSubtype;
91         uByte           bTerminalLink;
92         uByte           bDelay;
93         uWord           wFormatTag;
94 } UPACKED;
95
96 struct usb_audio_streaming_endpoint_descriptor {
97         uByte           bLength;
98         uByte           bDescriptorType;
99         uByte           bDescriptorSubtype;
100         uByte           bmAttributes;
101         uByte           bLockDelayUnits;
102         uWord           wLockDelay;
103 } UPACKED;
104
105 struct usb_audio_streaming_type1_descriptor {
106         uByte           bLength;
107         uByte           bDescriptorType;
108         uByte           bDescriptorSubtype;
109         uByte           bFormatType;
110         uByte           bNrChannels;
111         uByte           bSubFrameSize;
112         uByte           bBitResolution;
113         uByte           bSamFreqType;
114 #define UA_SAMP_CONTNUOUS 0
115         uByte           tSamFreq[3*2]; /* room for low and high */
116 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
117 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
118 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
119 } UPACKED;
120
121 struct usb_audio_cluster {
122         uByte           bNrChannels;
123         uWord           wChannelConfig;
124         uByte           iChannelNames;
125 } UPACKED;
126
127 /* UDESCSUB_AC_INPUT */
128 struct usb_audio_input_terminal {
129         uByte           bLength;
130         uByte           bDescriptorType;
131         uByte           bDescriptorSubtype;
132         uByte           bTerminalId;
133         uWord           wTerminalType;
134         uByte           bAssocTerminal;
135         uByte           bNrChannels;
136         uWord           wChannelConfig;
137         uByte           iChannelNames;
138         uByte           iTerminal;
139 } UPACKED;
140
141 /* UDESCSUB_AC_OUTPUT */
142 struct usb_audio_output_terminal {
143         uByte           bLength;
144         uByte           bDescriptorType;
145         uByte           bDescriptorSubtype;
146         uByte           bTerminalId;
147         uWord           wTerminalType;
148         uByte           bAssocTerminal;
149         uByte           bSourceId;
150         uByte           iTerminal;
151 } UPACKED;
152
153 /* UDESCSUB_AC_MIXER */
154 struct usb_audio_mixer_unit {
155         uByte           bLength;
156         uByte           bDescriptorType;
157         uByte           bDescriptorSubtype;
158         uByte           bUnitId;
159         uByte           bNrInPins;
160         uByte           baSourceId[255]; /* [bNrInPins] */
161         /* struct usb_audio_mixer_unit_1 */
162 } UPACKED;
163 struct usb_audio_mixer_unit_1 {
164         uByte           bNrChannels;
165         uWord           wChannelConfig;
166         uByte           iChannelNames;
167         uByte           bmControls[255]; /* [bNrChannels] */
168         /*uByte         iMixer;*/
169 } UPACKED;
170
171 /* UDESCSUB_AC_SELECTOR */
172 struct usb_audio_selector_unit {
173         uByte           bLength;
174         uByte           bDescriptorType;
175         uByte           bDescriptorSubtype;
176         uByte           bUnitId;
177         uByte           bNrInPins;
178         uByte           baSourceId[255]; /* [bNrInPins] */
179         /* uByte        iSelector; */
180 } UPACKED;
181
182 /* UDESCSUB_AC_FEATURE */
183 struct usb_audio_feature_unit {
184         uByte           bLength;
185         uByte           bDescriptorType;
186         uByte           bDescriptorSubtype;
187         uByte           bUnitId;
188         uByte           bSourceId;
189         uByte           bControlSize;
190         uByte           bmaControls[255]; /* size for more than enough */
191         /* uByte        iFeature; */
192 } UPACKED;
193
194 /* UDESCSUB_AC_PROCESSING */
195 struct usb_audio_processing_unit {
196         uByte           bLength;
197         uByte           bDescriptorType;
198         uByte           bDescriptorSubtype;
199         uByte           bUnitId;
200         uWord           wProcessType;
201         uByte           bNrInPins;
202         uByte           baSourceId[255]; /* [bNrInPins] */
203         /* struct usb_audio_processing_unit_1 */
204 } UPACKED;
205 struct usb_audio_processing_unit_1{
206         uByte           bNrChannels;
207         uWord           wChannelConfig;
208         uByte           iChannelNames;
209         uByte           bControlSize;
210         uByte           bmControls[255]; /* [bControlSize] */
211 #define UA_PROC_ENABLE_MASK 1
212 } UPACKED;
213
214 struct usb_audio_processing_unit_updown {
215         uByte           iProcessing;
216         uByte           bNrModes;
217         uWord           waModes[255]; /* [bNrModes] */
218 } UPACKED;
219
220 /* UDESCSUB_AC_EXTENSION */
221 struct usb_audio_extension_unit {
222         uByte           bLength;
223         uByte           bDescriptorType;
224         uByte           bDescriptorSubtype;
225         uByte           bUnitId;
226         uWord           wExtensionCode;
227         uByte           bNrInPins;
228         uByte           baSourceId[255]; /* [bNrInPins] */
229         /* struct usb_audio_extension_unit_1 */
230 } UPACKED;
231 struct usb_audio_extension_unit_1 {
232         uByte           bNrChannels;
233         uWord           wChannelConfig;
234         uByte           iChannelNames;
235         uByte           bControlSize;
236         uByte           bmControls[255]; /* [bControlSize] */
237 #define UA_EXT_ENABLE_MASK 1
238 #define UA_EXT_ENABLE 1
239         /*uByte         iExtension;*/
240 } UPACKED;
241
242 /* USB terminal types */
243 #define UAT_UNDEFINED           0x0100
244 #define UAT_STREAM              0x0101
245 #define UAT_VENDOR              0x01ff
246 /* input terminal types */
247 #define UATI_UNDEFINED          0x0200
248 #define UATI_MICROPHONE         0x0201
249 #define UATI_DESKMICROPHONE     0x0202
250 #define UATI_PERSONALMICROPHONE 0x0203
251 #define UATI_OMNIMICROPHONE     0x0204
252 #define UATI_MICROPHONEARRAY    0x0205
253 #define UATI_PROCMICROPHONEARR  0x0206
254 /* output terminal types */
255 #define UATO_UNDEFINED          0x0300
256 #define UATO_SPEAKER            0x0301
257 #define UATO_HEADPHONES         0x0302
258 #define UATO_DISPLAYAUDIO       0x0303
259 #define UATO_DESKTOPSPEAKER     0x0304
260 #define UATO_ROOMSPEAKER        0x0305
261 #define UATO_COMMSPEAKER        0x0306
262 #define UATO_SUBWOOFER          0x0307
263 /* bidir terminal types */
264 #define UATB_UNDEFINED          0x0400
265 #define UATB_HANDSET            0x0401
266 #define UATB_HEADSET            0x0402
267 #define UATB_SPEAKERPHONE       0x0403
268 #define UATB_SPEAKERPHONEESUP   0x0404
269 #define UATB_SPEAKERPHONEECANC  0x0405
270 /* telephony terminal types */
271 #define UATT_UNDEFINED          0x0500
272 #define UATT_PHONELINE          0x0501
273 #define UATT_TELEPHONE          0x0502
274 #define UATT_DOWNLINEPHONE      0x0503
275 /* external terminal types */
276 #define UATE_UNDEFINED          0x0600
277 #define UATE_ANALOGCONN         0x0601
278 #define UATE_DIGITALAUIFC       0x0602
279 #define UATE_LINECONN           0x0603
280 #define UATE_LEGACYCONN         0x0604
281 #define UATE_SPDIF              0x0605
282 #define UATE_1394DA             0x0606
283 #define UATE_1394DV             0x0607
284 /* embedded function terminal types */
285 #define UATF_UNDEFINED          0x0700
286 #define UATF_CALIBNOISE         0x0701
287 #define UATF_EQUNOISE           0x0702
288 #define UATF_CDPLAYER           0x0703
289 #define UATF_DAT                0x0704
290 #define UATF_DCC                0x0705
291 #define UATF_MINIDISK           0x0706
292 #define UATF_ANALOGTAPE         0x0707
293 #define UATF_PHONOGRAPH         0x0708
294 #define UATF_VCRAUDIO           0x0709
295 #define UATF_VIDEODISCAUDIO     0x070a
296 #define UATF_DVDAUDIO           0x070b
297 #define UATF_TVTUNERAUDIO       0x070c
298 #define UATF_SATELLITE          0x070d
299 #define UATF_CABLETUNER         0x070e
300 #define UATF_DSS                0x070f
301 #define UATF_RADIORECV          0x0710
302 #define UATF_RADIOXMIT          0x0711
303 #define UATF_MULTITRACK         0x0712
304 #define UATF_SYNTHESIZER        0x0713
305
306
307 #define SET_CUR 0x01
308 #define GET_CUR 0x81
309 #define SET_MIN 0x02
310 #define GET_MIN 0x82
311 #define SET_MAX 0x03
312 #define GET_MAX 0x83
313 #define SET_RES 0x04
314 #define GET_RES 0x84
315 #define SET_MEM 0x05
316 #define GET_MEM 0x85
317 #define GET_STAT 0xff
318
319 #define MUTE_CONTROL    0x01
320 #define VOLUME_CONTROL  0x02
321 #define BASS_CONTROL    0x03
322 #define MID_CONTROL     0x04
323 #define TREBLE_CONTROL  0x05
324 #define GRAPHIC_EQUALIZER_CONTROL       0x06
325 #define AGC_CONTROL     0x07
326 #define DELAY_CONTROL   0x08
327 #define BASS_BOOST_CONTROL 0x09
328 #define LOUDNESS_CONTROL 0x0a
329
330 #define FU_MASK(u) (1 << ((u)-1))
331
332 #define MASTER_CHAN     0
333
334 #define AS_GENERAL      1
335 #define FORMAT_TYPE     2
336 #define FORMAT_SPECIFIC 3
337
338 #define UA_FMT_PCM      1
339 #define UA_FMT_PCM8     2
340 #define UA_FMT_IEEE_FLOAT 3
341 #define UA_FMT_ALAW     4
342 #define UA_FMT_MULAW    5
343
344 #define SAMPLING_FREQ_CONTROL 0x01
345
346 #define FORMAT_TYPE_UNDEFINED 0
347 #define FORMAT_TYPE_I 1
348 #define FORMAT_TYPE_II 2
349 #define FORMAT_TYPE_III 3
350
351 #define UA_PROC_MASK(n) (1<< ((n)-1))
352 #define PROCESS_UNDEFINED               0
353 #define  XX_ENABLE_CONTROL                      1
354 #define UPDOWNMIX_PROCESS               1
355 #define  UD_ENABLE_CONTROL                      1
356 #define  UD_MODE_SELECT_CONTROL                 2
357 #define DOLBY_PROLOGIC_PROCESS          2
358 #define  DP_ENABLE_CONTROL                      1
359 #define  DP_MODE_SELECT_CONTROL                 2
360 #define P3D_STEREO_EXTENDER_PROCESS     3
361 #define  P3D_ENABLE_CONTROL                     1
362 #define  P3D_SPACIOUSNESS_CONTROL               2
363 #define REVERBATION_PROCESS             4
364 #define  RV_ENABLE_CONTROL                      1
365 #define  RV_LEVEL_CONTROL                       2
366 #define  RV_TIME_CONTROL                        3
367 #define  RV_FEEDBACK_CONTROL                    4
368 #define CHORUS_PROCESS                  5
369 #define  CH_ENABLE_CONTROL                      1
370 #define  CH_LEVEL_CONTROL                       2
371 #define  CH_RATE_CONTROL                        3
372 #define  CH_DEPTH_CONTROL                       4
373 #define DYN_RANGE_COMP_PROCESS          6
374 #define  DR_ENABLE_CONTROL                      1
375 #define  DR_COMPRESSION_RATE_CONTROL            2
376 #define  DR_MAXAMPL_CONTROL                     3
377 #define  DR_THRESHOLD_CONTROL                   4
378 #define  DR_ATTACK_TIME_CONTROL                 5
379 #define  DR_RELEASE_TIME_CONTROL                6
380