uaudioreg.h revision 1.4 1 /* $NetBSD: uaudioreg.h,v 1.4 2000/01/16 09:32:56 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Author: Lennart Augustsson <augustss (at) carlstedt.se>
8 * Carlstedt Research & Technology
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #define UAUDIO_VERSION 0x100
40
41 #define UDESC_CS_DEVICE 0x21
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 } usb_endpoint_descriptor_audio_t;
74
75 struct usb_audio_control_descriptor {
76 uByte bLength;
77 uByte bDescriptorType;
78 uByte bDescriptorSubtype;
79 uWord bcdADC;
80 uWord wTotalLength;
81 uByte bInCollection;
82 uByte baInterfaceNr[1];
83 };
84
85 struct usb_audio_streaming_interface_descriptor {
86 uByte bLength;
87 uByte bDescriptorType;
88 uByte bDescriptorSubtype;
89 uByte bTerminalLink;
90 uByte bDelay;
91 uWord wFormatTag;
92 };
93
94 struct usb_audio_streaming_endpoint_descriptor {
95 uByte bLength;
96 uByte bDescriptorType;
97 uByte bDescriptorSubtype;
98 uByte bmAttributes;
99 uByte bLockDelayUnits;
100 uWord wLockDelay;
101 };
102
103 struct usb_audio_streaming_type1_descriptor {
104 uByte bLength;
105 uByte bDescriptorType;
106 uByte bDescriptorSubtype;
107 uByte bFormatType;
108 uByte bNrChannels;
109 uByte bSubFrameSize;
110 uByte bBitResolution;
111 uByte bSamFreqType;
112 #define UA_SAMP_CONTNUOUS 0
113 uByte tSamFreq[3*2]; /* room for low and high */
114 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
115 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
116 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
117 };
118
119 struct usb_audio_cluster {
120 uByte bNrChannels;
121 uWord wChannelConfig;
122 uByte iChannelNames;
123 };
124
125 /* UDESCSUB_AC_INPUT */
126 struct usb_audio_input_terminal {
127 uByte bLength;
128 uByte bDescriptorType;
129 uByte bDescriptorSubtype;
130 uByte bTerminalId;
131 uWord wTerminalType;
132 uByte bAssocTerminal;
133 uByte bNrChannels;
134 uWord wChannelConfig;
135 uByte iChannelNames;
136 uByte iTerminal;
137 };
138
139 /* UDESCSUB_AC_OUTPUT */
140 struct usb_audio_output_terminal {
141 uByte bLength;
142 uByte bDescriptorType;
143 uByte bDescriptorSubtype;
144 uByte bTerminalId;
145 uWord wTerminalType;
146 uByte bAssocTerminal;
147 uByte bSourceId;
148 uByte iTerminal;
149 };
150
151 /* UDESCSUB_AC_MIXER */
152 struct usb_audio_mixer_unit {
153 uByte bLength;
154 uByte bDescriptorType;
155 uByte bDescriptorSubtype;
156 uByte bUnitId;
157 uByte bNrInPins;
158 uByte baSourceId[255]; /* [bNrInPins] */
159 /* struct usb_audio_mixer_unit_1 */
160 };
161 struct usb_audio_mixer_unit_1 {
162 uByte bNrChannels;
163 uWord wChannelConfig;
164 uByte iChannelNames;
165 uByte bmControls[255]; /* [bNrChannels] */
166 /*uByte iMixer;*/
167 };
168
169 /* UDESCSUB_AC_SELECTOR */
170 struct usb_audio_selector_unit {
171 uByte bLength;
172 uByte bDescriptorType;
173 uByte bDescriptorSubtype;
174 uByte bUnitId;
175 uByte bNrInPins;
176 uByte baSourceId[255]; /* [bNrInPins] */
177 /* uByte iSelector; */
178 };
179
180 /* UDESCSUB_AC_FEATURE */
181 struct usb_audio_feature_unit {
182 uByte bLength;
183 uByte bDescriptorType;
184 uByte bDescriptorSubtype;
185 uByte bUnitId;
186 uByte bSourceId;
187 uByte bControlSize;
188 uByte bmaControls[255]; /* size for more than enough */
189 /* uByte iFeature; */
190 };
191
192 /* UDESCSUB_AC_PROCESSING */
193 struct usb_audio_processing_unit {
194 uByte bLength;
195 uByte bDescriptorType;
196 uByte bDescriptorSubtype;
197 uByte bUnitId;
198 uWord wProcessType;
199 uByte bNrInPins;
200 uByte baSourceId[255]; /* [bNrInPins] */
201 /* struct usb_audio_processing_unit_1 */
202 };
203 struct usb_audio_processing_unit_1{
204 uByte bNrChannels;
205 uWord wChannelConfig;
206 uByte iChannelNames;
207 uByte bControlSize;
208 uByte bmControls[255]; /* [bControlSize] */
209 #define UA_PROC_ENABLE_MASK 1
210 };
211
212 struct usb_audio_processing_unit_updown {
213 uByte iProcessing;
214 uByte bNrModes;
215 uWord waModes[255]; /* [bNrModes] */
216 };
217
218 /* UDESCSUB_AC_EXTENSION */
219 struct usb_audio_extension_unit {
220 uByte bLength;
221 uByte bDescriptorType;
222 uByte bDescriptorSubtype;
223 uByte bUnitId;
224 uWord wExtensionCode;
225 uByte bNrInPins;
226 uByte baSourceId[255]; /* [bNrInPins] */
227 /* struct usb_audio_extension_unit_1 */
228 };
229 struct usb_audio_extension_unit_1 {
230 uByte bNrChannels;
231 uWord wChannelConfig;
232 uByte iChannelNames;
233 uByte bControlSize;
234 uByte bmControls[255]; /* [bControlSize] */
235 #define UA_EXT_ENABLE_MASK 1
236 #define UA_EXT_ENABLE 1
237 /*uByte iExtension;*/
238 };
239
240 #define UAT_STREAM 0x0101
241
242 #define SET_CUR 0x01
243 #define GET_CUR 0x81
244 #define SET_MIN 0x02
245 #define GET_MIN 0x82
246 #define SET_MAX 0x03
247 #define GET_MAX 0x83
248 #define SET_RES 0x04
249 #define GET_RES 0x84
250 #define SET_MEM 0x05
251 #define GET_MEM 0x85
252 #define GET_STAT 0xff
253
254 #define MUTE_CONTROL 0x01
255 #define VOLUME_CONTROL 0x02
256 #define BASS_CONTROL 0x03
257 #define MID_CONTROL 0x04
258 #define TREBLE_CONTROL 0x05
259 #define GRAPHIC_EQUALIZER_CONTROL 0x06
260 #define AGC_CONTROL 0x07
261 #define DELAY_CONTROL 0x08
262 #define BASS_BOOST_CONTROL 0x09
263 #define LOUDNESS_CONTROL 0x0a
264
265 #define FU_MASK(u) (1 << ((u)-1))
266
267 #define MASTER_CHAN 0
268
269 #define AS_GENERAL 1
270 #define FORMAT_TYPE 2
271 #define FORMAT_SPECIFIC 3
272
273 #define UA_FMT_PCM 1
274 #define UA_FMT_PCM8 2
275 #define UA_FMT_IEEE_FLOAT 3
276 #define UA_FMT_ALAW 4
277 #define UA_FMT_MULAW 5
278
279 #define SAMPLING_FREQ_CONTROL 0x01
280
281 #define FORMAT_TYPE_UNDEFINED 0
282 #define FORMAT_TYPE_I 1
283 #define FORMAT_TYPE_II 2
284 #define FORMAT_TYPE_III 3
285
286 #define UA_PROC_MASK(n) (1<< ((n)-1))
287 #define PROCESS_UNDEFINED 0
288 #define XX_ENABLE_CONTROL 1
289 #define UPDOWNMIX_PROCESS 1
290 #define UD_ENABLE_CONTROL 1
291 #define UD_MODE_SELECT_CONTROL 2
292 #define DOLBY_PROLOGIC_PROCESS 2
293 #define DP_ENABLE_CONTROL 1
294 #define DP_MODE_SELECT_CONTROL 2
295 #define P3D_STEREO_EXTENDER_PROCESS 3
296 #define P3D_ENABLE_CONTROL 1
297 #define P3D_SPACIOUSNESS_CONTROL 2
298 #define REVERBATION_PROCESS 4
299 #define RV_ENABLE_CONTROL 1
300 #define RV_LEVEL_CONTROL 2
301 #define RV_TIME_CONTROL 3
302 #define RV_FEEDBACK_CONTROL 4
303 #define CHORUS_PROCESS 5
304 #define CH_ENABLE_CONTROL 1
305 #define CH_LEVEL_CONTROL 2
306 #define CH_RATE_CONTROL 3
307 #define CH_DEPTH_CONTROL 4
308 #define DYN_RANGE_COMP_PROCESS 6
309 #define DR_ENABLE_CONTROL 1
310 #define DR_COMPRESSION_RATE_CONTROL 2
311 #define DR_MAXAMPL_CONTROL 3
312 #define DR_THRESHOLD_CONTROL 4
313 #define DR_ATTACK_TIME_CONTROL 5
314 #define DR_RELEASE_TIME_CONTROL 6
315