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