uaudioreg.h revision 1.6 1 /* $NetBSD: uaudioreg.h,v 1.6 2000/05/30 10:10:17 augustss 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_DEVICE 0x21
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 uByte bLockDelayUnits;
101 uWord wLockDelay;
102 } UPACKED;
103
104 struct usb_audio_streaming_type1_descriptor {
105 uByte bLength;
106 uByte bDescriptorType;
107 uByte bDescriptorSubtype;
108 uByte bFormatType;
109 uByte bNrChannels;
110 uByte bSubFrameSize;
111 uByte bBitResolution;
112 uByte bSamFreqType;
113 #define UA_SAMP_CONTNUOUS 0
114 uByte tSamFreq[3*2]; /* room for low and high */
115 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
116 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
117 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
118 } UPACKED;
119
120 struct usb_audio_cluster {
121 uByte bNrChannels;
122 uWord wChannelConfig;
123 uByte iChannelNames;
124 } UPACKED;
125
126 /* UDESCSUB_AC_INPUT */
127 struct usb_audio_input_terminal {
128 uByte bLength;
129 uByte bDescriptorType;
130 uByte bDescriptorSubtype;
131 uByte bTerminalId;
132 uWord wTerminalType;
133 uByte bAssocTerminal;
134 uByte bNrChannels;
135 uWord wChannelConfig;
136 uByte iChannelNames;
137 uByte iTerminal;
138 } UPACKED;
139
140 /* UDESCSUB_AC_OUTPUT */
141 struct usb_audio_output_terminal {
142 uByte bLength;
143 uByte bDescriptorType;
144 uByte bDescriptorSubtype;
145 uByte bTerminalId;
146 uWord wTerminalType;
147 uByte bAssocTerminal;
148 uByte bSourceId;
149 uByte iTerminal;
150 } UPACKED;
151
152 /* UDESCSUB_AC_MIXER */
153 struct usb_audio_mixer_unit {
154 uByte bLength;
155 uByte bDescriptorType;
156 uByte bDescriptorSubtype;
157 uByte bUnitId;
158 uByte bNrInPins;
159 uByte baSourceId[255]; /* [bNrInPins] */
160 /* struct usb_audio_mixer_unit_1 */
161 } UPACKED;
162 struct usb_audio_mixer_unit_1 {
163 uByte bNrChannels;
164 uWord wChannelConfig;
165 uByte iChannelNames;
166 uByte bmControls[255]; /* [bNrChannels] */
167 /*uByte iMixer;*/
168 } UPACKED;
169
170 /* UDESCSUB_AC_SELECTOR */
171 struct usb_audio_selector_unit {
172 uByte bLength;
173 uByte bDescriptorType;
174 uByte bDescriptorSubtype;
175 uByte bUnitId;
176 uByte bNrInPins;
177 uByte baSourceId[255]; /* [bNrInPins] */
178 /* uByte iSelector; */
179 } UPACKED;
180
181 /* UDESCSUB_AC_FEATURE */
182 struct usb_audio_feature_unit {
183 uByte bLength;
184 uByte bDescriptorType;
185 uByte bDescriptorSubtype;
186 uByte bUnitId;
187 uByte bSourceId;
188 uByte bControlSize;
189 uByte bmaControls[255]; /* size for more than enough */
190 /* uByte iFeature; */
191 } UPACKED;
192
193 /* UDESCSUB_AC_PROCESSING */
194 struct usb_audio_processing_unit {
195 uByte bLength;
196 uByte bDescriptorType;
197 uByte bDescriptorSubtype;
198 uByte bUnitId;
199 uWord wProcessType;
200 uByte bNrInPins;
201 uByte baSourceId[255]; /* [bNrInPins] */
202 /* struct usb_audio_processing_unit_1 */
203 } UPACKED;
204 struct usb_audio_processing_unit_1{
205 uByte bNrChannels;
206 uWord wChannelConfig;
207 uByte iChannelNames;
208 uByte bControlSize;
209 uByte bmControls[255]; /* [bControlSize] */
210 #define UA_PROC_ENABLE_MASK 1
211 } UPACKED;
212
213 struct usb_audio_processing_unit_updown {
214 uByte iProcessing;
215 uByte bNrModes;
216 uWord waModes[255]; /* [bNrModes] */
217 } UPACKED;
218
219 /* UDESCSUB_AC_EXTENSION */
220 struct usb_audio_extension_unit {
221 uByte bLength;
222 uByte bDescriptorType;
223 uByte bDescriptorSubtype;
224 uByte bUnitId;
225 uWord wExtensionCode;
226 uByte bNrInPins;
227 uByte baSourceId[255]; /* [bNrInPins] */
228 /* struct usb_audio_extension_unit_1 */
229 } UPACKED;
230 struct usb_audio_extension_unit_1 {
231 uByte bNrChannels;
232 uWord wChannelConfig;
233 uByte iChannelNames;
234 uByte bControlSize;
235 uByte bmControls[255]; /* [bControlSize] */
236 #define UA_EXT_ENABLE_MASK 1
237 #define UA_EXT_ENABLE 1
238 /*uByte iExtension;*/
239 } UPACKED;
240
241 #define UAT_STREAM 0x0101
242
243 #define SET_CUR 0x01
244 #define GET_CUR 0x81
245 #define SET_MIN 0x02
246 #define GET_MIN 0x82
247 #define SET_MAX 0x03
248 #define GET_MAX 0x83
249 #define SET_RES 0x04
250 #define GET_RES 0x84
251 #define SET_MEM 0x05
252 #define GET_MEM 0x85
253 #define GET_STAT 0xff
254
255 #define MUTE_CONTROL 0x01
256 #define VOLUME_CONTROL 0x02
257 #define BASS_CONTROL 0x03
258 #define MID_CONTROL 0x04
259 #define TREBLE_CONTROL 0x05
260 #define GRAPHIC_EQUALIZER_CONTROL 0x06
261 #define AGC_CONTROL 0x07
262 #define DELAY_CONTROL 0x08
263 #define BASS_BOOST_CONTROL 0x09
264 #define LOUDNESS_CONTROL 0x0a
265
266 #define FU_MASK(u) (1 << ((u)-1))
267
268 #define MASTER_CHAN 0
269
270 #define AS_GENERAL 1
271 #define FORMAT_TYPE 2
272 #define FORMAT_SPECIFIC 3
273
274 #define UA_FMT_PCM 1
275 #define UA_FMT_PCM8 2
276 #define UA_FMT_IEEE_FLOAT 3
277 #define UA_FMT_ALAW 4
278 #define UA_FMT_MULAW 5
279
280 #define SAMPLING_FREQ_CONTROL 0x01
281
282 #define FORMAT_TYPE_UNDEFINED 0
283 #define FORMAT_TYPE_I 1
284 #define FORMAT_TYPE_II 2
285 #define FORMAT_TYPE_III 3
286
287 #define UA_PROC_MASK(n) (1<< ((n)-1))
288 #define PROCESS_UNDEFINED 0
289 #define XX_ENABLE_CONTROL 1
290 #define UPDOWNMIX_PROCESS 1
291 #define UD_ENABLE_CONTROL 1
292 #define UD_MODE_SELECT_CONTROL 2
293 #define DOLBY_PROLOGIC_PROCESS 2
294 #define DP_ENABLE_CONTROL 1
295 #define DP_MODE_SELECT_CONTROL 2
296 #define P3D_STEREO_EXTENDER_PROCESS 3
297 #define P3D_ENABLE_CONTROL 1
298 #define P3D_SPACIOUSNESS_CONTROL 2
299 #define REVERBATION_PROCESS 4
300 #define RV_ENABLE_CONTROL 1
301 #define RV_LEVEL_CONTROL 2
302 #define RV_TIME_CONTROL 3
303 #define RV_FEEDBACK_CONTROL 4
304 #define CHORUS_PROCESS 5
305 #define CH_ENABLE_CONTROL 1
306 #define CH_LEVEL_CONTROL 2
307 #define CH_RATE_CONTROL 3
308 #define CH_DEPTH_CONTROL 4
309 #define DYN_RANGE_COMP_PROCESS 6
310 #define DR_ENABLE_CONTROL 1
311 #define DR_COMPRESSION_RATE_CONTROL 2
312 #define DR_MAXAMPL_CONTROL 3
313 #define DR_THRESHOLD_CONTROL 4
314 #define DR_ATTACK_TIME_CONTROL 5
315 #define DR_RELEASE_TIME_CONTROL 6
316