xref: /freebsd/sys/dev/sound/usb/uaudioreg.h (revision c0020399a650364d0134f79f3fa319f84064372d)
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 struct usb2_endpoint_descriptor */
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 } __packed usb2_endpoint_descriptor_audio_t;
75 
76 struct usb2_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 } __packed;
85 
86 struct usb2_audio_streaming_interface_descriptor {
87 	uByte	bLength;
88 	uByte	bDescriptorType;
89 	uByte	bDescriptorSubtype;
90 	uByte	bTerminalLink;
91 	uByte	bDelay;
92 	uWord	wFormatTag;
93 } __packed;
94 
95 struct usb2_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 } __packed;
106 
107 struct usb2_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[0];
118 #define	UA_GETSAMP(p, n) (((p)->tSamFreq[((n)*3)+0]) |	    \
119 			  ((p)->tSamFreq[((n)*3)+1] << 8) | \
120 			  ((p)->tSamFreq[((n)*3)+2] << 16))
121 #define	UA_SAMP_LO(p) UA_GETSAMP(p, 0)
122 #define	UA_SAMP_HI(p) UA_GETSAMP(p, 1)
123 } __packed;
124 
125 struct usb2_audio_cluster {
126 	uByte	bNrChannels;
127 	uWord	wChannelConfig;
128 #define	UA_CHANNEL_LEFT		0x0001
129 #define	UA_CHANNEL_RIGHT	0x0002
130 #define	UA_CHANNEL_CENTER	0x0004
131 #define	UA_CHANNEL_LFE		0x0008
132 #define	UA_CHANNEL_L_SURROUND	0x0010
133 #define	UA_CHANNEL_R_SURROUND	0x0020
134 #define	UA_CHANNEL_L_CENTER	0x0040
135 #define	UA_CHANNEL_R_CENTER	0x0080
136 #define	UA_CHANNEL_SURROUND	0x0100
137 #define	UA_CHANNEL_L_SIDE	0x0200
138 #define	UA_CHANNEL_R_SIDE	0x0400
139 #define	UA_CHANNEL_TOP		0x0800
140 	uByte	iChannelNames;
141 } __packed;
142 
143 /* Shared by all units and terminals */
144 struct usb2_audio_unit {
145 	uByte	bLength;
146 	uByte	bDescriptorType;
147 	uByte	bDescriptorSubtype;
148 	uByte	bUnitId;
149 };
150 
151 /* UDESCSUB_AC_INPUT */
152 struct usb2_audio_input_terminal {
153 	uByte	bLength;
154 	uByte	bDescriptorType;
155 	uByte	bDescriptorSubtype;
156 	uByte	bTerminalId;
157 	uWord	wTerminalType;
158 	uByte	bAssocTerminal;
159 	uByte	bNrChannels;
160 	uWord	wChannelConfig;
161 	uByte	iChannelNames;
162 /*	uByte		iTerminal; */
163 } __packed;
164 
165 /* UDESCSUB_AC_OUTPUT */
166 struct usb2_audio_output_terminal {
167 	uByte	bLength;
168 	uByte	bDescriptorType;
169 	uByte	bDescriptorSubtype;
170 	uByte	bTerminalId;
171 	uWord	wTerminalType;
172 	uByte	bAssocTerminal;
173 	uByte	bSourceId;
174 	uByte	iTerminal;
175 } __packed;
176 
177 /* UDESCSUB_AC_MIXER */
178 struct usb2_audio_mixer_unit_0 {
179 	uByte	bLength;
180 	uByte	bDescriptorType;
181 	uByte	bDescriptorSubtype;
182 	uByte	bUnitId;
183 	uByte	bNrInPins;
184 	uByte	baSourceId[0];		/* [bNrInPins] */
185 	/* struct usb2_audio_mixer_unit_1 */
186 } __packed;
187 struct usb2_audio_mixer_unit_1 {
188 	uByte	bNrChannels;
189 	uWord	wChannelConfig;
190 	uByte	iChannelNames;
191 	uByte	bmControls[0];		/* [see source code] */
192 	/* uByte		iMixer; */
193 } __packed;
194 
195 /* UDESCSUB_AC_SELECTOR */
196 struct usb2_audio_selector_unit {
197 	uByte	bLength;
198 	uByte	bDescriptorType;
199 	uByte	bDescriptorSubtype;
200 	uByte	bUnitId;
201 	uByte	bNrInPins;
202 	uByte	baSourceId[0];		/* [bNrInPins] */
203 	/* uByte	iSelector; */
204 } __packed;
205 
206 /* UDESCSUB_AC_FEATURE */
207 struct usb2_audio_feature_unit {
208 	uByte	bLength;
209 	uByte	bDescriptorType;
210 	uByte	bDescriptorSubtype;
211 	uByte	bUnitId;
212 	uByte	bSourceId;
213 	uByte	bControlSize;
214 	uByte	bmaControls[0];		/* [bControlSize * x] */
215 	/* uByte	iFeature; */
216 } __packed;
217 
218 /* UDESCSUB_AC_PROCESSING */
219 struct usb2_audio_processing_unit_0 {
220 	uByte	bLength;
221 	uByte	bDescriptorType;
222 	uByte	bDescriptorSubtype;
223 	uByte	bUnitId;
224 	uWord	wProcessType;
225 	uByte	bNrInPins;
226 	uByte	baSourceId[0];		/* [bNrInPins] */
227 	/* struct usb2_audio_processing_unit_1 */
228 } __packed;
229 struct usb2_audio_processing_unit_1 {
230 	uByte	bNrChannels;
231 	uWord	wChannelConfig;
232 	uByte	iChannelNames;
233 	uByte	bControlSize;
234 	uByte	bmControls[0];		/* [bControlSize] */
235 #define	UA_PROC_ENABLE_MASK 1
236 } __packed;
237 
238 struct usb2_audio_processing_unit_updown {
239 	uByte	iProcessing;
240 	uByte	bNrModes;
241 	uWord	waModes[0];		/* [bNrModes] */
242 } __packed;
243 
244 /* UDESCSUB_AC_EXTENSION */
245 struct usb2_audio_extension_unit_0 {
246 	uByte	bLength;
247 	uByte	bDescriptorType;
248 	uByte	bDescriptorSubtype;
249 	uByte	bUnitId;
250 	uWord	wExtensionCode;
251 	uByte	bNrInPins;
252 	uByte	baSourceId[0];		/* [bNrInPins] */
253 	/* struct usb2_audio_extension_unit_1 */
254 } __packed;
255 struct usb2_audio_extension_unit_1 {
256 	uByte	bNrChannels;
257 	uWord	wChannelConfig;
258 	uByte	iChannelNames;
259 	uByte	bControlSize;
260 	uByte	bmControls[0];		/* [bControlSize] */
261 #define	UA_EXT_ENABLE_MASK 1
262 #define	UA_EXT_ENABLE 1
263 	/* uByte		iExtension; */
264 } __packed;
265 
266 /* USB terminal types */
267 #define	UAT_UNDEFINED		0x0100
268 #define	UAT_STREAM		0x0101
269 #define	UAT_VENDOR		0x01ff
270 /* input terminal types */
271 #define	UATI_UNDEFINED		0x0200
272 #define	UATI_MICROPHONE		0x0201
273 #define	UATI_DESKMICROPHONE	0x0202
274 #define	UATI_PERSONALMICROPHONE	0x0203
275 #define	UATI_OMNIMICROPHONE	0x0204
276 #define	UATI_MICROPHONEARRAY	0x0205
277 #define	UATI_PROCMICROPHONEARR	0x0206
278 /* output terminal types */
279 #define	UATO_UNDEFINED		0x0300
280 #define	UATO_SPEAKER		0x0301
281 #define	UATO_HEADPHONES		0x0302
282 #define	UATO_DISPLAYAUDIO	0x0303
283 #define	UATO_DESKTOPSPEAKER	0x0304
284 #define	UATO_ROOMSPEAKER	0x0305
285 #define	UATO_COMMSPEAKER	0x0306
286 #define	UATO_SUBWOOFER		0x0307
287 /* bidir terminal types */
288 #define	UATB_UNDEFINED		0x0400
289 #define	UATB_HANDSET		0x0401
290 #define	UATB_HEADSET		0x0402
291 #define	UATB_SPEAKERPHONE	0x0403
292 #define	UATB_SPEAKERPHONEESUP	0x0404
293 #define	UATB_SPEAKERPHONEECANC	0x0405
294 /* telephony terminal types */
295 #define	UATT_UNDEFINED		0x0500
296 #define	UATT_PHONELINE		0x0501
297 #define	UATT_TELEPHONE		0x0502
298 #define	UATT_DOWNLINEPHONE	0x0503
299 /* external terminal types */
300 #define	UATE_UNDEFINED		0x0600
301 #define	UATE_ANALOGCONN		0x0601
302 #define	UATE_DIGITALAUIFC	0x0602
303 #define	UATE_LINECONN		0x0603
304 #define	UATE_LEGACYCONN		0x0604
305 #define	UATE_SPDIF		0x0605
306 #define	UATE_1394DA		0x0606
307 #define	UATE_1394DV		0x0607
308 /* embedded function terminal types */
309 #define	UATF_UNDEFINED		0x0700
310 #define	UATF_CALIBNOISE		0x0701
311 #define	UATF_EQUNOISE		0x0702
312 #define	UATF_CDPLAYER		0x0703
313 #define	UATF_DAT		0x0704
314 #define	UATF_DCC		0x0705
315 #define	UATF_MINIDISK		0x0706
316 #define	UATF_ANALOGTAPE		0x0707
317 #define	UATF_PHONOGRAPH		0x0708
318 #define	UATF_VCRAUDIO		0x0709
319 #define	UATF_VIDEODISCAUDIO	0x070a
320 #define	UATF_DVDAUDIO		0x070b
321 #define	UATF_TVTUNERAUDIO	0x070c
322 #define	UATF_SATELLITE		0x070d
323 #define	UATF_CABLETUNER		0x070e
324 #define	UATF_DSS		0x070f
325 #define	UATF_RADIORECV		0x0710
326 #define	UATF_RADIOXMIT		0x0711
327 #define	UATF_MULTITRACK		0x0712
328 #define	UATF_SYNTHESIZER	0x0713
329 
330 
331 #define	SET_CUR 0x01
332 #define	GET_CUR 0x81
333 #define	SET_MIN 0x02
334 #define	GET_MIN 0x82
335 #define	SET_MAX 0x03
336 #define	GET_MAX 0x83
337 #define	SET_RES 0x04
338 #define	GET_RES 0x84
339 #define	SET_MEM 0x05
340 #define	GET_MEM 0x85
341 #define	GET_STAT 0xff
342 
343 #define	MUTE_CONTROL	0x01
344 #define	VOLUME_CONTROL	0x02
345 #define	BASS_CONTROL	0x03
346 #define	MID_CONTROL	0x04
347 #define	TREBLE_CONTROL	0x05
348 #define	GRAPHIC_EQUALIZER_CONTROL	0x06
349 #define	AGC_CONTROL	0x07
350 #define	DELAY_CONTROL	0x08
351 #define	BASS_BOOST_CONTROL 0x09
352 #define	LOUDNESS_CONTROL 0x0a
353 
354 #define	FU_MASK(u) (1 << ((u)-1))
355 
356 #define	MASTER_CHAN	0
357 
358 #define	AS_GENERAL	1
359 #define	FORMAT_TYPE	2
360 #define	FORMAT_SPECIFIC 3
361 
362 #define	UA_FMT_PCM	1
363 #define	UA_FMT_PCM8	2
364 #define	UA_FMT_IEEE_FLOAT 3
365 #define	UA_FMT_ALAW	4
366 #define	UA_FMT_MULAW	5
367 #define	UA_FMT_MPEG	0x1001
368 #define	UA_FMT_AC3	0x1002
369 
370 #define	SAMPLING_FREQ_CONTROL	0x01
371 #define	PITCH_CONTROL		0x02
372 
373 #define	FORMAT_TYPE_UNDEFINED 0
374 #define	FORMAT_TYPE_I 1
375 #define	FORMAT_TYPE_II 2
376 #define	FORMAT_TYPE_III 3
377 
378 #define	UA_PROC_MASK(n) (1<< ((n)-1))
379 #define	PROCESS_UNDEFINED		0
380 #define	XX_ENABLE_CONTROL			1
381 #define	UPDOWNMIX_PROCESS		1
382 #define	UD_ENABLE_CONTROL			1
383 #define	UD_MODE_SELECT_CONTROL			2
384 #define	DOLBY_PROLOGIC_PROCESS		2
385 #define	DP_ENABLE_CONTROL			1
386 #define	DP_MODE_SELECT_CONTROL			2
387 #define	P3D_STEREO_EXTENDER_PROCESS	3
388 #define	P3D_ENABLE_CONTROL			1
389 #define	P3D_SPACIOUSNESS_CONTROL		2
390 #define	REVERBATION_PROCESS		4
391 #define	RV_ENABLE_CONTROL			1
392 #define	RV_LEVEL_CONTROL			2
393 #define	RV_TIME_CONTROL			3
394 #define	RV_FEEDBACK_CONTROL			4
395 #define	CHORUS_PROCESS			5
396 #define	CH_ENABLE_CONTROL			1
397 #define	CH_LEVEL_CONTROL			2
398 #define	CH_RATE_CONTROL			3
399 #define	CH_DEPTH_CONTROL			4
400 #define	DYN_RANGE_COMP_PROCESS		6
401 #define	DR_ENABLE_CONTROL			1
402 #define	DR_COMPRESSION_RATE_CONTROL		2
403 #define	DR_MAXAMPL_CONTROL			3
404 #define	DR_THRESHOLD_CONTROL			4
405 #define	DR_ATTACK_TIME_CONTROL			5
406 #define	DR_RELEASE_TIME_CONTROL		6
407