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