]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/sound/usb/uaudioreg.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / sound / usb / uaudioreg.h
1 /*      $NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $      */
2 /* $FreeBSD$ */
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_CONFIG         0x22
44 #define UDESC_CS_STRING         0x23
45 #define UDESC_CS_INTERFACE      0x24
46 #define UDESC_CS_ENDPOINT       0x25
47
48 #define UDESCSUB_AC_HEADER      1
49 #define UDESCSUB_AC_INPUT       2
50 #define UDESCSUB_AC_OUTPUT      3
51 #define UDESCSUB_AC_MIXER       4
52 #define UDESCSUB_AC_SELECTOR    5
53 #define UDESCSUB_AC_FEATURE     6
54 #define UDESCSUB_AC_PROCESSING  7
55 #define UDESCSUB_AC_EXTENSION   8
56
57 /* The first fields are identical to usb_endpoint_descriptor_t */
58 typedef struct {
59         uByte           bLength;
60         uByte           bDescriptorType;
61         uByte           bEndpointAddress;
62         uByte           bmAttributes;
63         uWord           wMaxPacketSize;
64         uByte           bInterval;
65         /*
66          * The following two entries are only used by the Audio Class.
67          * And according to the specs the Audio Class is the only one
68          * allowed to extend the endpoint descriptor.
69          * Who knows what goes on in the minds of the people in the USB
70          * standardization?  :-(
71          */
72         uByte           bRefresh;
73         uByte           bSynchAddress;
74 } UPACKED usb_endpoint_descriptor_audio_t;
75
76 struct usb_audio_control_descriptor {
77         uByte           bLength;
78         uByte           bDescriptorType;
79         uByte           bDescriptorSubtype;
80         uWord           bcdADC;
81         uWord           wTotalLength;
82         uByte           bInCollection;
83         uByte           baInterfaceNr[1];
84 } UPACKED;
85
86 struct usb_audio_streaming_interface_descriptor {
87         uByte           bLength;
88         uByte           bDescriptorType;
89         uByte           bDescriptorSubtype;
90         uByte           bTerminalLink;
91         uByte           bDelay;
92         uWord           wFormatTag;
93 } UPACKED;
94
95 struct usb_audio_streaming_endpoint_descriptor {
96         uByte           bLength;
97         uByte           bDescriptorType;
98         uByte           bDescriptorSubtype;
99         uByte           bmAttributes;
100 #define UA_SED_FREQ_CONTROL     0x01
101 #define UA_SED_PITCH_CONTROL    0x02
102 #define UA_SED_MAXPACKETSONLY   0x80
103         uByte           bLockDelayUnits;
104         uWord           wLockDelay;
105 } UPACKED;
106
107 struct usb_audio_streaming_type1_descriptor {
108         uByte           bLength;
109         uByte           bDescriptorType;
110         uByte           bDescriptorSubtype;
111         uByte           bFormatType;
112         uByte           bNrChannels;
113         uByte           bSubFrameSize;
114         uByte           bBitResolution;
115         uByte           bSamFreqType;
116 #define UA_SAMP_CONTNUOUS 0
117         uByte           tSamFreq[3*2]; /* room for low and high */
118 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
119 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
120 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
121 } UPACKED;
122
123 struct usb_audio_cluster {
124         uByte           bNrChannels;
125         uWord           wChannelConfig;
126 #define UA_CHANNEL_LEFT         0x0001
127 #define UA_CHANNEL_RIGHT        0x0002
128 #define UA_CHANNEL_CENTER       0x0004
129 #define UA_CHANNEL_LFE          0x0008
130 #define UA_CHANNEL_L_SURROUND   0x0010
131 #define UA_CHANNEL_R_SURROUND   0x0020
132 #define UA_CHANNEL_L_CENTER     0x0040
133 #define UA_CHANNEL_R_CENTER     0x0080
134 #define UA_CHANNEL_SURROUND     0x0100
135 #define UA_CHANNEL_L_SIDE       0x0200
136 #define UA_CHANNEL_R_SIDE       0x0400
137 #define UA_CHANNEL_TOP          0x0800
138         uByte           iChannelNames;
139 } UPACKED;
140
141 /* Shared by all units and terminals */
142 struct usb_audio_unit {
143         uByte           bLength;
144         uByte           bDescriptorType;
145         uByte           bDescriptorSubtype;
146         uByte           bUnitId;
147 };
148
149 /* UDESCSUB_AC_INPUT */
150 struct usb_audio_input_terminal {
151         uByte           bLength;
152         uByte           bDescriptorType;
153         uByte           bDescriptorSubtype;
154         uByte           bTerminalId;
155         uWord           wTerminalType;
156         uByte           bAssocTerminal;
157         uByte           bNrChannels;
158         uWord           wChannelConfig;
159         uByte           iChannelNames;
160         uByte           iTerminal;
161 } UPACKED;
162
163 /* UDESCSUB_AC_OUTPUT */
164 struct usb_audio_output_terminal {
165         uByte           bLength;
166         uByte           bDescriptorType;
167         uByte           bDescriptorSubtype;
168         uByte           bTerminalId;
169         uWord           wTerminalType;
170         uByte           bAssocTerminal;
171         uByte           bSourceId;
172         uByte           iTerminal;
173 } UPACKED;
174
175 /* UDESCSUB_AC_MIXER */
176 struct usb_audio_mixer_unit {
177         uByte           bLength;
178         uByte           bDescriptorType;
179         uByte           bDescriptorSubtype;
180         uByte           bUnitId;
181         uByte           bNrInPins;
182         uByte           baSourceId[255]; /* [bNrInPins] */
183         /* struct usb_audio_mixer_unit_1 */
184 } UPACKED;
185 struct usb_audio_mixer_unit_1 {
186         uByte           bNrChannels;
187         uWord           wChannelConfig;
188         uByte           iChannelNames;
189         uByte           bmControls[255]; /* [bNrChannels] */
190         /*uByte         iMixer;*/
191 } UPACKED;
192
193 /* UDESCSUB_AC_SELECTOR */
194 struct usb_audio_selector_unit {
195         uByte           bLength;
196         uByte           bDescriptorType;
197         uByte           bDescriptorSubtype;
198         uByte           bUnitId;
199         uByte           bNrInPins;
200         uByte           baSourceId[255]; /* [bNrInPins] */
201         /* uByte        iSelector; */
202 } UPACKED;
203
204 /* UDESCSUB_AC_FEATURE */
205 struct usb_audio_feature_unit {
206         uByte           bLength;
207         uByte           bDescriptorType;
208         uByte           bDescriptorSubtype;
209         uByte           bUnitId;
210         uByte           bSourceId;
211         uByte           bControlSize;
212         uByte           bmaControls[255]; /* size for more than enough */
213         /* uByte        iFeature; */
214 } UPACKED;
215
216 /* UDESCSUB_AC_PROCESSING */
217 struct usb_audio_processing_unit {
218         uByte           bLength;
219         uByte           bDescriptorType;
220         uByte           bDescriptorSubtype;
221         uByte           bUnitId;
222         uWord           wProcessType;
223         uByte           bNrInPins;
224         uByte           baSourceId[255]; /* [bNrInPins] */
225         /* struct usb_audio_processing_unit_1 */
226 } UPACKED;
227 struct usb_audio_processing_unit_1{
228         uByte           bNrChannels;
229         uWord           wChannelConfig;
230         uByte           iChannelNames;
231         uByte           bControlSize;
232         uByte           bmControls[255]; /* [bControlSize] */
233 #define UA_PROC_ENABLE_MASK 1
234 } UPACKED;
235
236 struct usb_audio_processing_unit_updown {
237         uByte           iProcessing;
238         uByte           bNrModes;
239         uWord           waModes[255]; /* [bNrModes] */
240 } UPACKED;
241
242 /* UDESCSUB_AC_EXTENSION */
243 struct usb_audio_extension_unit {
244         uByte           bLength;
245         uByte           bDescriptorType;
246         uByte           bDescriptorSubtype;
247         uByte           bUnitId;
248         uWord           wExtensionCode;
249         uByte           bNrInPins;
250         uByte           baSourceId[255]; /* [bNrInPins] */
251         /* struct usb_audio_extension_unit_1 */
252 } UPACKED;
253 struct usb_audio_extension_unit_1 {
254         uByte           bNrChannels;
255         uWord           wChannelConfig;
256         uByte           iChannelNames;
257         uByte           bControlSize;
258         uByte           bmControls[255]; /* [bControlSize] */
259 #define UA_EXT_ENABLE_MASK 1
260 #define UA_EXT_ENABLE 1
261         /*uByte         iExtension;*/
262 } UPACKED;
263
264 /* USB terminal types */
265 #define UAT_UNDEFINED           0x0100
266 #define UAT_STREAM              0x0101
267 #define UAT_VENDOR              0x01ff
268 /* input terminal types */
269 #define UATI_UNDEFINED          0x0200
270 #define UATI_MICROPHONE         0x0201
271 #define UATI_DESKMICROPHONE     0x0202
272 #define UATI_PERSONALMICROPHONE 0x0203
273 #define UATI_OMNIMICROPHONE     0x0204
274 #define UATI_MICROPHONEARRAY    0x0205
275 #define UATI_PROCMICROPHONEARR  0x0206
276 /* output terminal types */
277 #define UATO_UNDEFINED          0x0300
278 #define UATO_SPEAKER            0x0301
279 #define UATO_HEADPHONES         0x0302
280 #define UATO_DISPLAYAUDIO       0x0303
281 #define UATO_DESKTOPSPEAKER     0x0304
282 #define UATO_ROOMSPEAKER        0x0305
283 #define UATO_COMMSPEAKER        0x0306
284 #define UATO_SUBWOOFER          0x0307
285 /* bidir terminal types */
286 #define UATB_UNDEFINED          0x0400
287 #define UATB_HANDSET            0x0401
288 #define UATB_HEADSET            0x0402
289 #define UATB_SPEAKERPHONE       0x0403
290 #define UATB_SPEAKERPHONEESUP   0x0404
291 #define UATB_SPEAKERPHONEECANC  0x0405
292 /* telephony terminal types */
293 #define UATT_UNDEFINED          0x0500
294 #define UATT_PHONELINE          0x0501
295 #define UATT_TELEPHONE          0x0502
296 #define UATT_DOWNLINEPHONE      0x0503
297 /* external terminal types */
298 #define UATE_UNDEFINED          0x0600
299 #define UATE_ANALOGCONN         0x0601
300 #define UATE_DIGITALAUIFC       0x0602
301 #define UATE_LINECONN           0x0603
302 #define UATE_LEGACYCONN         0x0604
303 #define UATE_SPDIF              0x0605
304 #define UATE_1394DA             0x0606
305 #define UATE_1394DV             0x0607
306 /* embedded function terminal types */
307 #define UATF_UNDEFINED          0x0700
308 #define UATF_CALIBNOISE         0x0701
309 #define UATF_EQUNOISE           0x0702
310 #define UATF_CDPLAYER           0x0703
311 #define UATF_DAT                0x0704
312 #define UATF_DCC                0x0705
313 #define UATF_MINIDISK           0x0706
314 #define UATF_ANALOGTAPE         0x0707
315 #define UATF_PHONOGRAPH         0x0708
316 #define UATF_VCRAUDIO           0x0709
317 #define UATF_VIDEODISCAUDIO     0x070a
318 #define UATF_DVDAUDIO           0x070b
319 #define UATF_TVTUNERAUDIO       0x070c
320 #define UATF_SATELLITE          0x070d
321 #define UATF_CABLETUNER         0x070e
322 #define UATF_DSS                0x070f
323 #define UATF_RADIORECV          0x0710
324 #define UATF_RADIOXMIT          0x0711
325 #define UATF_MULTITRACK         0x0712
326 #define UATF_SYNTHESIZER        0x0713
327
328
329 #define SET_CUR 0x01
330 #define GET_CUR 0x81
331 #define SET_MIN 0x02
332 #define GET_MIN 0x82
333 #define SET_MAX 0x03
334 #define GET_MAX 0x83
335 #define SET_RES 0x04
336 #define GET_RES 0x84
337 #define SET_MEM 0x05
338 #define GET_MEM 0x85
339 #define GET_STAT 0xff
340
341 #define MUTE_CONTROL    0x01
342 #define VOLUME_CONTROL  0x02
343 #define BASS_CONTROL    0x03
344 #define MID_CONTROL     0x04
345 #define TREBLE_CONTROL  0x05
346 #define GRAPHIC_EQUALIZER_CONTROL       0x06
347 #define AGC_CONTROL     0x07
348 #define DELAY_CONTROL   0x08
349 #define BASS_BOOST_CONTROL 0x09
350 #define LOUDNESS_CONTROL 0x0a
351
352 #define FU_MASK(u) (1 << ((u)-1))
353
354 #define MASTER_CHAN     0
355
356 #define AS_GENERAL      1
357 #define FORMAT_TYPE     2
358 #define FORMAT_SPECIFIC 3
359
360 #define UA_FMT_PCM      1
361 #define UA_FMT_PCM8     2
362 #define UA_FMT_IEEE_FLOAT 3
363 #define UA_FMT_ALAW     4
364 #define UA_FMT_MULAW    5
365 #define UA_FMT_MPEG     0x1001
366 #define UA_FMT_AC3      0x1002
367
368 #define SAMPLING_FREQ_CONTROL   0x01
369 #define PITCH_CONTROL           0x02
370
371 #define FORMAT_TYPE_UNDEFINED 0
372 #define FORMAT_TYPE_I 1
373 #define FORMAT_TYPE_II 2
374 #define FORMAT_TYPE_III 3
375
376 #define UA_PROC_MASK(n) (1<< ((n)-1))
377 #define PROCESS_UNDEFINED               0
378 #define  XX_ENABLE_CONTROL                      1
379 #define UPDOWNMIX_PROCESS               1
380 #define  UD_ENABLE_CONTROL                      1
381 #define  UD_MODE_SELECT_CONTROL                 2
382 #define DOLBY_PROLOGIC_PROCESS          2
383 #define  DP_ENABLE_CONTROL                      1
384 #define  DP_MODE_SELECT_CONTROL                 2
385 #define P3D_STEREO_EXTENDER_PROCESS     3
386 #define  P3D_ENABLE_CONTROL                     1
387 #define  P3D_SPACIOUSNESS_CONTROL               2
388 #define REVERBATION_PROCESS             4
389 #define  RV_ENABLE_CONTROL                      1
390 #define  RV_LEVEL_CONTROL                       2
391 #define  RV_TIME_CONTROL                        3
392 #define  RV_FEEDBACK_CONTROL                    4
393 #define CHORUS_PROCESS                  5
394 #define  CH_ENABLE_CONTROL                      1
395 #define  CH_LEVEL_CONTROL                       2
396 #define  CH_RATE_CONTROL                        3
397 #define  CH_DEPTH_CONTROL                       4
398 #define DYN_RANGE_COMP_PROCESS          6
399 #define  DR_ENABLE_CONTROL                      1
400 #define  DR_COMPRESSION_RATE_CONTROL            2
401 #define  DR_MAXAMPL_CONTROL                     3
402 #define  DR_THRESHOLD_CONTROL                   4
403 #define  DR_ATTACK_TIME_CONTROL                 5
404 #define  DR_RELEASE_TIME_CONTROL                6