xref: /freebsd/sys/dev/sound/usb/uaudioreg.h (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1 /*	$NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-2-Clause
5  *
6  * Copyright (c) 1999 The NetBSD Foundation, Inc.
7  * All rights reserved.
8  *
9  * This code is derived from software contributed to The NetBSD Foundation
10  * by Lennart Augustsson (lennart@augustsson.net) at
11  * Carlstedt Research & Technology.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _UAUDIOREG_H_
36 #define	_UAUDIOREG_H_
37 
38 #define	UAUDIO_VERSION_10	0x0100
39 #define	UAUDIO_VERSION_20	0x0200
40 #define	UAUDIO_VERSION_30	0x0300
41 
42 #define	UAUDIO_PROTOCOL_20	0x20
43 
44 #define	UDESC_CS_UNDEFINED	0x20
45 #define	UDESC_CS_DEVICE		0x21
46 #define	UDESC_CS_CONFIG		0x22
47 #define	UDESC_CS_STRING		0x23
48 #define	UDESC_CS_INTERFACE	0x24
49 #define	UDESC_CS_ENDPOINT	0x25
50 
51 #define	UDESCSUB_AC_HEADER	1
52 #define	UDESCSUB_AC_INPUT	2
53 #define	UDESCSUB_AC_OUTPUT	3
54 #define	UDESCSUB_AC_MIXER	4
55 #define	UDESCSUB_AC_SELECTOR	5
56 #define	UDESCSUB_AC_FEATURE	6
57 #define	UDESCSUB_AC_PROCESSING	7
58 #define	UDESCSUB_AC_EXTENSION	8
59 /* ==== USB audio v2.0 ==== */
60 #define	UDESCSUB_AC_EFFECT	7
61 #define	UDESCSUB_AC_PROCESSING_V2 8
62 #define	UDESCSUB_AC_EXTENSION_V2 9
63 #define	UDESCSUB_AC_CLOCK_SRC	10
64 #define	UDESCSUB_AC_CLOCK_SEL	11
65 #define	UDESCSUB_AC_CLOCK_MUL	12
66 #define	UDESCSUB_AC_SAMPLE_RT	13
67 
68 /* These macros check if the endpoint descriptor has additional fields */
69 #define	UEP_MINSIZE	7
70 #define	UEP_HAS_REFRESH(ep)	((ep)->bLength >= 8)
71 #define	UEP_HAS_SYNCADDR(ep)	((ep)->bLength >= 9)
72 
73 /* The first fields are identical to struct usb_endpoint_descriptor */
74 typedef struct {
75 	uByte	bLength;
76 	uByte	bDescriptorType;
77 	uByte	bEndpointAddress;
78 	uByte	bmAttributes;
79 	uWord	wMaxPacketSize;
80 	uByte	bInterval;
81 	/*
82 	 * The following two entries are only used by the Audio Class.
83 	 * And according to the specs the Audio Class is the only one
84 	 * allowed to extend the endpoint descriptor.
85 	 * Who knows what goes on in the minds of the people in the USB
86 	 * standardization?  :-(
87 	 */
88 	uByte	bRefresh;
89 	uByte	bSynchAddress;
90 } __packed usb_endpoint_descriptor_audio_t;
91 
92 struct usb_audio_control_descriptor {
93 	uByte	bLength;
94 	uByte	bDescriptorType;
95 	uByte	bDescriptorSubtype;
96 	uWord	bcdADC;
97 	uWord	wTotalLength;
98 	uByte	bInCollection;
99 	uByte	baInterfaceNr[1];
100 } __packed;
101 
102 struct usb_audio_streaming_interface_descriptor {
103 	uByte	bLength;
104 	uByte	bDescriptorType;
105 	uByte	bDescriptorSubtype;
106 	uByte	bTerminalLink;
107 	uByte	bDelay;
108 	uWord	wFormatTag;
109 } __packed;
110 
111 struct usb_audio_streaming_endpoint_descriptor {
112 	uByte	bLength;
113 	uByte	bDescriptorType;
114 	uByte	bDescriptorSubtype;
115 	uByte	bmAttributes;
116 #define	UA_SED_FREQ_CONTROL	0x01
117 #define	UA_SED_PITCH_CONTROL	0x02
118 #define	UA_SED_MAXPACKETSONLY	0x80
119 	uByte	bLockDelayUnits;
120 	uWord	wLockDelay;
121 } __packed;
122 
123 struct usb_midi_streaming_endpoint_descriptor {
124 	uByte	bLength;
125 	uByte	bDescriptorType;
126 	uByte	bDescriptorSubtype;
127 	uByte	bNumEmbMIDIJack;
128 } __packed;
129 
130 struct usb_audio_streaming_type1_descriptor {
131 	uByte	bLength;
132 	uByte	bDescriptorType;
133 	uByte	bDescriptorSubtype;
134 	uByte	bFormatType;
135 	uByte	bNrChannels;
136 	uByte	bSubFrameSize;
137 	uByte	bBitResolution;
138 	uByte	bSamFreqType;
139 #define	UA_SAMP_CONTNUOUS 0
140 	uByte	tSamFreq[0];
141 #define	UA_GETSAMP(p, n) ((uint32_t)((((p)->tSamFreq[((n)*3)+0]) | \
142 			  ((p)->tSamFreq[((n)*3)+1] << 8) | \
143 			  ((p)->tSamFreq[((n)*3)+2] << 16))))
144 #define	UA_SAMP_LO(p) UA_GETSAMP(p, 0)
145 #define	UA_SAMP_HI(p) UA_GETSAMP(p, 1)
146 } __packed;
147 
148 struct usb_audio_cluster {
149 	uByte	bNrChannels;
150 	uWord	wChannelConfig;
151 #define	UA_CHANNEL_LEFT		0x0001
152 #define	UA_CHANNEL_RIGHT	0x0002
153 #define	UA_CHANNEL_CENTER	0x0004
154 #define	UA_CHANNEL_LFE		0x0008
155 #define	UA_CHANNEL_L_SURROUND	0x0010
156 #define	UA_CHANNEL_R_SURROUND	0x0020
157 #define	UA_CHANNEL_L_CENTER	0x0040
158 #define	UA_CHANNEL_R_CENTER	0x0080
159 #define	UA_CHANNEL_SURROUND	0x0100
160 #define	UA_CHANNEL_L_SIDE	0x0200
161 #define	UA_CHANNEL_R_SIDE	0x0400
162 #define	UA_CHANNEL_TOP		0x0800
163 	uByte	iChannelNames;
164 } __packed;
165 
166 /* Shared by all units and terminals */
167 struct usb_audio_unit {
168 	uByte	bLength;
169 	uByte	bDescriptorType;
170 	uByte	bDescriptorSubtype;
171 	uByte	bUnitId;
172 };
173 
174 /* UDESCSUB_AC_INPUT */
175 struct usb_audio_input_terminal {
176 	uByte	bLength;
177 	uByte	bDescriptorType;
178 	uByte	bDescriptorSubtype;
179 	uByte	bTerminalId;
180 	uWord	wTerminalType;
181 	uByte	bAssocTerminal;
182 	uByte	bNrChannels;
183 	uWord	wChannelConfig;
184 	uByte	iChannelNames;
185 /*	uByte		iTerminal; */
186 } __packed;
187 
188 /* UDESCSUB_AC_OUTPUT */
189 struct usb_audio_output_terminal {
190 	uByte	bLength;
191 	uByte	bDescriptorType;
192 	uByte	bDescriptorSubtype;
193 	uByte	bTerminalId;
194 	uWord	wTerminalType;
195 	uByte	bAssocTerminal;
196 	uByte	bSourceId;
197 	uByte	iTerminal;
198 } __packed;
199 
200 /* UDESCSUB_AC_MIXER */
201 struct usb_audio_mixer_unit_0 {
202 	uByte	bLength;
203 	uByte	bDescriptorType;
204 	uByte	bDescriptorSubtype;
205 	uByte	bUnitId;
206 	uByte	bNrInPins;
207 	uByte	baSourceId[0];		/* [bNrInPins] */
208 	/* struct usb_audio_mixer_unit_1 */
209 } __packed;
210 struct usb_audio_mixer_unit_1 {
211 	uByte	bNrChannels;
212 	uWord	wChannelConfig;
213 	uByte	iChannelNames;
214 	uByte	bmControls[0];		/* [see source code] */
215 	/* uByte		iMixer; */
216 } __packed;
217 
218 /* UDESCSUB_AC_SELECTOR */
219 struct usb_audio_selector_unit {
220 	uByte	bLength;
221 	uByte	bDescriptorType;
222 	uByte	bDescriptorSubtype;
223 	uByte	bUnitId;
224 	uByte	bNrInPins;
225 	uByte	baSourceId[0];		/* [bNrInPins] */
226 	/* uByte	iSelector; */
227 } __packed;
228 
229 /* UDESCSUB_AC_FEATURE */
230 struct usb_audio_feature_unit {
231 	uByte	bLength;
232 	uByte	bDescriptorType;
233 	uByte	bDescriptorSubtype;
234 	uByte	bUnitId;
235 	uByte	bSourceId;
236 	uByte	bControlSize;
237 	uByte	bmaControls[0];		/* [bControlSize * x] */
238 	/* uByte	iFeature; */
239 } __packed;
240 
241 /* UDESCSUB_AC_PROCESSING */
242 struct usb_audio_processing_unit_0 {
243 	uByte	bLength;
244 	uByte	bDescriptorType;
245 	uByte	bDescriptorSubtype;
246 	uByte	bUnitId;
247 	uWord	wProcessType;
248 	uByte	bNrInPins;
249 	uByte	baSourceId[0];		/* [bNrInPins] */
250 	/* struct usb_audio_processing_unit_1 */
251 } __packed;
252 struct usb_audio_processing_unit_1 {
253 	uByte	bNrChannels;
254 	uWord	wChannelConfig;
255 	uByte	iChannelNames;
256 	uByte	bControlSize;
257 	uByte	bmControls[0];		/* [bControlSize] */
258 #define	UA_PROC_ENABLE_MASK 1
259 } __packed;
260 
261 struct usb_audio_processing_unit_updown {
262 	uByte	iProcessing;
263 	uByte	bNrModes;
264 	uWord	waModes[0];		/* [bNrModes] */
265 } __packed;
266 
267 /* UDESCSUB_AC_EXTENSION */
268 struct usb_audio_extension_unit_0 {
269 	uByte	bLength;
270 	uByte	bDescriptorType;
271 	uByte	bDescriptorSubtype;
272 	uByte	bUnitId;
273 	uWord	wExtensionCode;
274 	uByte	bNrInPins;
275 	uByte	baSourceId[0];		/* [bNrInPins] */
276 	/* struct usb_audio_extension_unit_1 */
277 } __packed;
278 
279 struct usb_audio_extension_unit_1 {
280 	uByte	bNrChannels;
281 	uWord	wChannelConfig;
282 	uByte	iChannelNames;
283 	uByte	bControlSize;
284 	uByte	bmControls[0];		/* [bControlSize] */
285 #define	UA_EXT_ENABLE_MASK 1
286 #define	UA_EXT_ENABLE 1
287 	/* uByte		iExtension; */
288 } __packed;
289 
290 /* USB terminal types */
291 #define	UAT_UNDEFINED		0x0100
292 #define	UAT_STREAM		0x0101
293 #define	UAT_VENDOR		0x01ff
294 /* input terminal types */
295 #define	UATI_UNDEFINED		0x0200
296 #define	UATI_MICROPHONE		0x0201
297 #define	UATI_DESKMICROPHONE	0x0202
298 #define	UATI_PERSONALMICROPHONE	0x0203
299 #define	UATI_OMNIMICROPHONE	0x0204
300 #define	UATI_MICROPHONEARRAY	0x0205
301 #define	UATI_PROCMICROPHONEARR	0x0206
302 /* output terminal types */
303 #define	UATO_UNDEFINED		0x0300
304 #define	UATO_SPEAKER		0x0301
305 #define	UATO_HEADPHONES		0x0302
306 #define	UATO_DISPLAYAUDIO	0x0303
307 #define	UATO_DESKTOPSPEAKER	0x0304
308 #define	UATO_ROOMSPEAKER	0x0305
309 #define	UATO_COMMSPEAKER	0x0306
310 #define	UATO_SUBWOOFER		0x0307
311 /* bidir terminal types */
312 #define	UATB_UNDEFINED		0x0400
313 #define	UATB_HANDSET		0x0401
314 #define	UATB_HEADSET		0x0402
315 #define	UATB_SPEAKERPHONE	0x0403
316 #define	UATB_SPEAKERPHONEESUP	0x0404
317 #define	UATB_SPEAKERPHONEECANC	0x0405
318 /* telephony terminal types */
319 #define	UATT_UNDEFINED		0x0500
320 #define	UATT_PHONELINE		0x0501
321 #define	UATT_TELEPHONE		0x0502
322 #define	UATT_DOWNLINEPHONE	0x0503
323 /* external terminal types */
324 #define	UATE_UNDEFINED		0x0600
325 #define	UATE_ANALOGCONN		0x0601
326 #define	UATE_DIGITALAUIFC	0x0602
327 #define	UATE_LINECONN		0x0603
328 #define	UATE_LEGACYCONN		0x0604
329 #define	UATE_SPDIF		0x0605
330 #define	UATE_1394DA		0x0606
331 #define	UATE_1394DV		0x0607
332 /* embedded function terminal types */
333 #define	UATF_UNDEFINED		0x0700
334 #define	UATF_CALIBNOISE		0x0701
335 #define	UATF_EQUNOISE		0x0702
336 #define	UATF_CDPLAYER		0x0703
337 #define	UATF_DAT		0x0704
338 #define	UATF_DCC		0x0705
339 #define	UATF_MINIDISK		0x0706
340 #define	UATF_ANALOGTAPE		0x0707
341 #define	UATF_PHONOGRAPH		0x0708
342 #define	UATF_VCRAUDIO		0x0709
343 #define	UATF_VIDEODISCAUDIO	0x070a
344 #define	UATF_DVDAUDIO		0x070b
345 #define	UATF_TVTUNERAUDIO	0x070c
346 #define	UATF_SATELLITE		0x070d
347 #define	UATF_CABLETUNER		0x070e
348 #define	UATF_DSS		0x070f
349 #define	UATF_RADIORECV		0x0710
350 #define	UATF_RADIOXMIT		0x0711
351 #define	UATF_MULTITRACK		0x0712
352 #define	UATF_SYNTHESIZER	0x0713
353 
354 #define	SET_CUR 0x01
355 #define	GET_CUR 0x81
356 #define	SET_MIN 0x02
357 #define	GET_MIN 0x82
358 #define	SET_MAX 0x03
359 #define	GET_MAX 0x83
360 #define	SET_RES 0x04
361 #define	GET_RES 0x84
362 #define	SET_MEM 0x05
363 #define	GET_MEM 0x85
364 #define	GET_STAT 0xff
365 
366 #define	MUTE_CONTROL	0x01
367 #define	VOLUME_CONTROL	0x02
368 #define	BASS_CONTROL	0x03
369 #define	MID_CONTROL	0x04
370 #define	TREBLE_CONTROL	0x05
371 #define	GRAPHIC_EQUALIZER_CONTROL	0x06
372 #define	AGC_CONTROL	0x07
373 #define	DELAY_CONTROL	0x08
374 #define	BASS_BOOST_CONTROL 0x09
375 #define	LOUDNESS_CONTROL 0x0a
376 /* ==== USB audio v2.0 ==== */
377 #define	INPUT_GAIN_CONTROL 0x0b
378 #define	INPUT_GAIN_PAD_CONTROL 0x0c
379 #define	PHASE_INVERTER_CONTROL 0x0d
380 #define	UNDERFLOW_CONTROL 0x0e
381 #define	OVERFLOW_CONTROL 0x0f
382 #define	LATENCY_CONTROL 0x10
383 
384 #define	FU_MASK(u) (1 << ((u)-1))
385 
386 #define	MASTER_CHAN	0
387 
388 #define	MS_GENERAL	1
389 #define	AS_GENERAL	1
390 #define	FORMAT_TYPE	2
391 #define	FORMAT_SPECIFIC 3
392 /* ==== USB audio v2.0 ==== */
393 #define	FORMAT_ENCODER	3
394 #define	FORMAT_DECODER	4
395 
396 #define	UA_FMT_PCM	1
397 #define	UA_FMT_PCM8	2
398 #define	UA_FMT_IEEE_FLOAT 3
399 #define	UA_FMT_ALAW	4
400 #define	UA_FMT_MULAW	5
401 #define	UA_FMT_MPEG	0x1001
402 #define	UA_FMT_AC3	0x1002
403 
404 #define	SAMPLING_FREQ_CONTROL	0x01
405 #define	PITCH_CONTROL		0x02
406 
407 #define	FORMAT_TYPE_UNDEFINED 0
408 #define	FORMAT_TYPE_I 1
409 #define	FORMAT_TYPE_II 2
410 #define	FORMAT_TYPE_III 3
411 
412 #define	UA_PROC_MASK(n) (1<< ((n)-1))
413 #define	PROCESS_UNDEFINED		0
414 #define	XX_ENABLE_CONTROL			1
415 #define	UPDOWNMIX_PROCESS		1
416 #define	UD_ENABLE_CONTROL			1
417 #define	UD_MODE_SELECT_CONTROL			2
418 #define	DOLBY_PROLOGIC_PROCESS		2
419 #define	DP_ENABLE_CONTROL			1
420 #define	DP_MODE_SELECT_CONTROL			2
421 #define	P3D_STEREO_EXTENDER_PROCESS	3
422 #define	P3D_ENABLE_CONTROL			1
423 #define	P3D_SPACIOUSNESS_CONTROL		2
424 #define	REVERBATION_PROCESS		4
425 #define	RV_ENABLE_CONTROL			1
426 #define	RV_LEVEL_CONTROL			2
427 #define	RV_TIME_CONTROL			3
428 #define	RV_FEEDBACK_CONTROL			4
429 #define	CHORUS_PROCESS			5
430 #define	CH_ENABLE_CONTROL			1
431 #define	CH_LEVEL_CONTROL			2
432 #define	CH_RATE_CONTROL			3
433 #define	CH_DEPTH_CONTROL			4
434 #define	DYN_RANGE_COMP_PROCESS		6
435 #define	DR_ENABLE_CONTROL			1
436 #define	DR_COMPRESSION_RATE_CONTROL		2
437 #define	DR_MAXAMPL_CONTROL			3
438 #define	DR_THRESHOLD_CONTROL			4
439 #define	DR_ATTACK_TIME_CONTROL			5
440 #define	DR_RELEASE_TIME_CONTROL		6
441 
442 /*------------------------------------------------------------------------*
443  * USB audio v2.0 definitions
444  *------------------------------------------------------------------------*/
445 
446 struct usb_audio20_streaming_interface_descriptor {
447 	uByte	bLength;
448 	uByte	bDescriptorType;
449 	uByte	bDescriptorSubtype;
450 	uByte	bTerminalLink;
451 	uByte	bmControls;
452 	uByte	bFormatType;
453 	uDWord	bmFormats;
454 	uByte	bNrChannels;
455 	uDWord	bmChannelConfig;
456 	uByte	iChannelNames;
457 } __packed;
458 
459 struct usb_audio20_encoder_descriptor {
460 	uByte	bLength;
461 	uByte	bDescriptorType;
462 	uByte	bDescriptorSubtype;
463 	uByte	bEncoderID;
464 	uByte	bEncoder;
465 	uDWord	bmControls;
466 	uByte	iParam1;
467 	uByte	iParam2;
468 	uByte	iParam3;
469 	uByte	iParam4;
470 	uByte	iParam5;
471 	uByte	iParam6;
472 	uByte	iParam7;
473 	uByte	iParam8;
474 	uByte	iEncoder;
475 } __packed;
476 
477 struct usb_audio20_streaming_endpoint_descriptor {
478 	uByte	bLength;
479 	uByte	bDescriptorType;
480 	uByte	bDescriptorSubtype;
481 	uByte	bmAttributes;
482 #define	UA20_MPS_ONLY		0x80
483 	uByte	bmControls;
484 #define	UA20_PITCH_CONTROL_MASK	0x03
485 #define	UA20_DATA_OVERRUN_MASK	0x0C
486 #define	UA20_DATA_UNDERRUN_MASK	0x30
487 	uByte	bLockDelayUnits;
488 	uWord	wLockDelay;
489 } __packed;
490 
491 struct usb_audio20_feedback_endpoint_descriptor {
492 	uByte	bLength;
493 	uByte	bDescriptorType;
494 	uByte	bEndpointAddress;
495 	uByte	bmAttributes;
496 	uWord	wMaxPacketSize;
497 	uByte	bInterval;
498 } __packed;
499 
500 #define	UA20_CS_CUR	0x01
501 #define	UA20_CS_RANGE	0x02
502 #define	UA20_CS_MEM	0x03
503 
504 struct usb_audio20_cur1_parameter {
505 	uByte	bCur;
506 } __packed;
507 
508 struct usb_audio20_ctl1_range_sub {
509 	uByte	bMIN;
510 	uByte	bMAX;
511 	uByte	bRES;
512 } __packed;
513 
514 struct usb_audio20_ctl1_range {
515 	uWord	wNumSubRanges;
516 	struct usb_audio20_ctl1_range_sub sub[1];
517 } __packed;
518 
519 struct usb_audio20_cur2_parameter {
520 	uWord	wCur;
521 } __packed;
522 
523 struct usb_audio20_ctl2_range_sub {
524 	uWord	wMIN;
525 	uWord	wMAX;
526 	uWord	wRES;
527 } __packed;
528 
529 struct usb_audio20_ctl2_range {
530 	uWord	wNumSubRanges;
531 	struct usb_audio20_ctl2_range_sub sub[1];
532 } __packed;
533 
534 struct usb_audio20_cur4_parameter {
535 	uDWord	dCur;
536 } __packed;
537 
538 struct usb_audio20_ctl4_range_sub {
539 	uDWord	dMIN;
540 	uDWord	dMAX;
541 	uDWord	dRES;
542 } __packed;
543 
544 struct usb_audio20_ctl4_range {
545 	uWord	wNumSubRanges;
546 	struct usb_audio20_ctl4_range_sub sub[1];
547 } __packed;
548 
549 struct usb_audio20_cc_cluster_descriptor {
550 	uByte	bNrChannels;
551 	uDWord	bmChannelConfig;
552 	uByte	iChannelNames;
553 } __packed;
554 
555 struct usb_audio20_streaming_type1_descriptor {
556 	uByte	bLength;
557 	uByte	bDescriptorType;
558 	uByte	bDescriptorSubtype;
559 	uByte	bFormatType;
560 	uByte	bSubslotSize;
561 	uByte	bBitResolution;
562 } __packed;
563 
564 #define	UA20_EERROR_NONE	0
565 #define	UA20_EERROR_MEMORY	1
566 #define	UA20_EERROR_BANDWIDTH	2
567 #define	UA20_EERROR_CPU		3
568 #define	UA20_EERROR_FORMATFR_ER	4
569 #define	UA20_EERROR_FORMATFR_SM	5
570 #define	UA20_EERROR_FORMATFR_LG	6
571 #define	UA20_EERROR_DATAFORMAT	7
572 #define	UA20_EERROR_NUMCHANNELS	8
573 #define	UA20_EERROR_SAMPLERATE	9
574 #define	UA20_EERROR_BITRATE	10
575 #define	UA20_EERROR_PARAM	11
576 #define	UA20_EERROR_NREADY	12
577 #define	UA20_EERROR_BUSY	13
578 
579 struct usb_audio20_cc_alt_setting {
580 	uByte	bControlSize;
581 	uDWord	bmValidAltSettings;
582 } __packed;
583 
584 struct usb_audio20_interrupt_message {
585 	uByte	bInfo;
586 	uByte	bAttribute;
587 	uDWord	wValue;
588 	uDWord	wIndex;
589 } __packed;
590 
591 /* UDESCSUB_AC_CLOCK_SRC */
592 struct usb_audio20_clock_source_unit {
593 	uByte	bLength;
594 	uByte	bDescriptorType;
595 	uByte	bDescriptorSubtype;
596 	uByte	bClockId;
597 	uByte	bmAttributes;
598 	uByte	bmControls;
599 	uByte	bAssocTerminal;
600 	uByte	iClockSource;
601 } __packed;
602 
603 /* UDESCSUB_AC_CLOCK_SEL */
604 struct usb_audio20_clock_selector_unit_0 {
605 	uByte	bLength;
606 	uByte	bDescriptorType;
607 	uByte	bDescriptorSubtype;
608 	uByte	bClockId;
609 	uByte	bNrInPins;
610 	uByte	baCSourceId[0];
611 } __packed;
612 
613 struct usb_audio20_clock_selector_unit_1 {
614 	uByte	bmControls;
615 	uByte	iClockSelector;
616 } __packed;
617 
618 /* UDESCSUB_AC_CLOCK_MUL */
619 struct usb_audio20_clock_multiplier_unit {
620 	uByte	bLength;
621 	uByte	bDescriptorType;
622 	uByte	bDescriptorSubtype;
623 	uByte	bClockId;
624 	uByte	bCSourceId;
625 	uByte	bmControls;
626 	uByte	iClockMultiplier;
627 } __packed;
628 
629 /* UDESCSUB_AC_INPUT */
630 struct usb_audio20_input_terminal {
631 	uByte	bLength;
632 	uByte	bDescriptorType;
633 	uByte	bDescriptorSubtype;
634 	uByte	bTerminalId;
635 	uWord	wTerminalType;
636 	uByte	bAssocTerminal;
637 	uByte	bCSourceId;
638 	uByte	bNrChannels;
639 	uDWord	bmChannelConfig;
640 	uByte	iCHannelNames;
641 	uWord	bmControls;
642 	uByte	iTerminal;
643 } __packed;
644 
645 /* UDESCSUB_AC_OUTPUT */
646 struct usb_audio20_output_terminal {
647 	uByte	bLength;
648 	uByte	bDescriptorType;
649 	uByte	bDescriptorSubtype;
650 	uByte	bTerminalId;
651 	uWord	wTerminalType;
652 	uByte	bAssocTerminal;
653 	uByte	bSourceId;
654 	uByte	bCSourceId;
655 	uWord	bmControls;
656 	uByte	iTerminal;
657 } __packed;
658 
659 /* UDESCSUB_AC_MIXER */
660 struct usb_audio20_mixer_unit_0 {
661 	uByte	bLength;
662 	uByte	bDescriptorType;
663 	uByte	bDescriptorSubtype;
664 	uByte	bUnitId;
665 	uByte	bNrInPins;
666 	uByte	baSourceId[0];
667 	/* struct usb_audio20_mixer_unit_1 */
668 } __packed;
669 
670 struct usb_audio20_mixer_unit_1 {
671 	uByte	bNrChannels;
672 	uDWord	bmChannelConfig;
673 	uByte	iChannelNames;
674 	uByte	bmControls[0];
675 	/* uByte	iMixer; */
676 } __packed;
677 
678 /* UDESCSUB_AC_SELECTOR */
679 struct usb_audio20_selector_unit {
680 	uByte	bLength;
681 	uByte	bDescriptorType;
682 	uByte	bDescriptorSubtype;
683 	uByte	bUnitId;
684 	uByte	bNrInPins;
685 	uByte	baSourceId[0];
686 	/* uByte	iSelector; */
687 } __packed;
688 
689 /* UDESCSUB_AC_FEATURE */
690 struct usb_audio20_feature_unit {
691 	uByte	bLength;
692 	uByte	bDescriptorType;
693 	uByte	bDescriptorSubtype;
694 	uByte	bUnitId;
695 	uByte	bSourceId;
696 	uDWord	bmaControls[0];
697 	/* uByte	iFeature; */
698 } __packed;
699 
700 /* UDESCSUB_AC_SAMPLE_RT */
701 struct usb_audio20_sample_rate_unit {
702 	uByte	bLength;
703 	uByte	bDescriptorType;
704 	uByte	bDescriptorSubtype;
705 	uByte	bUnitId;
706 	uByte	bSourceId;
707 	uByte	bSourceInId;
708 	uByte	bSourceOutId;
709 	uByte	iSrc;
710 } __packed;
711 
712 /* UDESCSUB_AC_EFFECT */
713 struct usb_audio20_effect_unit {
714 	uByte	bLength;
715 	uByte	bDescriptorType;
716 	uByte	bDescriptorSubtype;
717 	uByte	bUnitId;
718 	uWord	wEffectType;
719 	uByte	bSourceId;
720 	uDWord	bmaControls[0];
721 	uByte	iEffects;
722 } __packed;
723 
724 /* UDESCSUB_AC_PROCESSING_V2 */
725 struct usb_audio20_processing_unit_0 {
726 	uByte	bLength;
727 	uByte	bDescriptorType;
728 	uByte	bDescriptorSubtype;
729 	uByte	bUnitId;
730 	uWord	wProcessType;
731 	uByte	bNrInPins;
732 	uByte	baSourceId[0];		/* [bNrInPins] */
733 } __packed;
734 
735 struct usb_audio20_processing_unit_1 {
736 	uByte	bNrChannels;
737 	uDWord	bmChannelConfig;
738 	uByte	iChannelNames;
739 	uWord	bmControls;
740 	uByte	iProcessing;
741 } __packed;
742 
743 /* UDESCSUB_AC_EXTENSION_V2 */
744 struct usb_audio20_extension_unit_0 {
745 	uByte	bLength;
746 	uByte	bDescriptorType;
747 	uByte	bDescriptorSubtype;
748 	uByte	bUnitId;
749 	uWord	wExtensionCode;
750 	uByte	bNrInPins;
751 	uByte	baSourceId[0];
752 } __packed;
753 
754 struct usb_audio20_extension_unit_1 {
755 	uByte	bNrChannels;
756 	uDWord	bmChannelConfig;
757 	uByte	iChannelNames;
758 	uByte	bmControls;
759 	uByte	iExtension;
760 } __packed;
761 
762 struct usb_audio20_cluster {
763 	uByte	bNrChannels;
764 	uDWord	bmChannelConfig;
765 	uByte	iChannelNames;
766 } __packed;
767 
768 #define	UA20_TF_UNDEFINED		0x00
769 #define	UA20_TF_DESKTOP_SPEAKER		0x01
770 #define	UA20_TF_HOME_THEATER		0x02
771 #define	UA20_TF_MICROPHONE		0x03
772 #define	UA20_TF_HEADSET			0x04
773 #define	UA20_TF_TELEPHONE		0x05
774 #define	UA20_TF_CONVERTER		0x06
775 #define	UA20_TF_SOUND_RECORDER		0x07
776 #define	UA20_TF_IO_BOX			0x08
777 #define	UA20_TF_MUSICAL_INSTRUMENT	0x09
778 #define	UA20_TF_PRO_AUDIO		0x0A
779 #define	UA20_TF_AV			0x0B
780 #define	UA20_TF_CONTROL_PANEL		0x0C
781 #define	UA20_TF_OTHER			0xFF
782 
783 #define	UA20_CS_SAM_FREQ_CONTROL	0x01
784 #define	UA20_CS_CLOCK_VALID_CONTROL 	0x02
785 
786 #define	UA20_TE_COPY_PROTECT_CONTROL	0x01
787 #define	UA20_TE_CONNECTOR_CONTROL	0x02
788 #define	UA20_TE_OVERLOAD_CONTROL	0x03
789 #define	UA20_TE_CLUSTER_CONTROL		0x04
790 #define	UA20_TE_UNDERFLOW_CONTROL	0x05
791 #define	UA20_TE_OVERFLOW_CONTROL	0x06
792 #define	UA20_TE_LATENCY_CONTROL		0x07
793 
794 #define	UA20_MU_MIXER_CONTROL		0x01
795 #define	UA20_MU_CLUSTER_CONTROL		0x02
796 #define	UA20_MU_UNDERFLOW_CONTROL	0x03
797 #define	UA20_MU_OVERFLOW_CONTROL	0x04
798 #define	UA20_MU_LATENCY_CONTROL		0x05
799 
800 #define	UA20_FMT_PCM	(1U << 0)
801 #define	UA20_FMT_PCM8	(1U << 1)
802 #define	UA20_FMT_FLOAT	(1U << 2)
803 #define	UA20_FMT_ALAW	(1U << 3)
804 #define	UA20_FMT_MULAW	(1U << 4)
805 #define	UA20_FMT_RAW	(1U << 31)
806 
807 #endif					/* _UAUDIOREG_H_ */
808