1 /* $NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $ */
5 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
7 * Copyright (c) 1999 The NetBSD Foundation, Inc.
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Lennart Augustsson (lennart@augustsson.net) at
12 * Carlstedt Research & Technology.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
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.
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.
39 #define UAUDIO_VERSION 0x0100
40 #define UAUDIO_VERSION_20 0x0200
41 #define UAUDIO_VERSION_30 0x0300
43 #define UAUDIO_PROTOCOL_20 0x20
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
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
69 /* These macros check if the endpoint descriptor has additional fields */
71 #define UEP_HAS_REFRESH(ep) ((ep)->bLength >= 8)
72 #define UEP_HAS_SYNCADDR(ep) ((ep)->bLength >= 9)
74 /* The first fields are identical to struct usb_endpoint_descriptor */
77 uByte bDescriptorType;
78 uByte bEndpointAddress;
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? :-(
91 } __packed usb_endpoint_descriptor_audio_t;
93 struct usb_audio_control_descriptor {
95 uByte bDescriptorType;
96 uByte bDescriptorSubtype;
100 uByte baInterfaceNr[1];
103 struct usb_audio_streaming_interface_descriptor {
105 uByte bDescriptorType;
106 uByte bDescriptorSubtype;
112 struct usb_audio_streaming_endpoint_descriptor {
114 uByte bDescriptorType;
115 uByte bDescriptorSubtype;
117 #define UA_SED_FREQ_CONTROL 0x01
118 #define UA_SED_PITCH_CONTROL 0x02
119 #define UA_SED_MAXPACKETSONLY 0x80
120 uByte bLockDelayUnits;
124 struct usb_midi_streaming_endpoint_descriptor {
126 uByte bDescriptorType;
127 uByte bDescriptorSubtype;
128 uByte bNumEmbMIDIJack;
131 struct usb_audio_streaming_type1_descriptor {
133 uByte bDescriptorType;
134 uByte bDescriptorSubtype;
138 uByte bBitResolution;
140 #define UA_SAMP_CONTNUOUS 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)
149 struct usb_audio_cluster {
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
167 /* Shared by all units and terminals */
168 struct usb_audio_unit {
170 uByte bDescriptorType;
171 uByte bDescriptorSubtype;
175 /* UDESCSUB_AC_INPUT */
176 struct usb_audio_input_terminal {
178 uByte bDescriptorType;
179 uByte bDescriptorSubtype;
182 uByte bAssocTerminal;
184 uWord wChannelConfig;
186 /* uByte iTerminal; */
189 /* UDESCSUB_AC_OUTPUT */
190 struct usb_audio_output_terminal {
192 uByte bDescriptorType;
193 uByte bDescriptorSubtype;
196 uByte bAssocTerminal;
201 /* UDESCSUB_AC_MIXER */
202 struct usb_audio_mixer_unit_0 {
204 uByte bDescriptorType;
205 uByte bDescriptorSubtype;
208 uByte baSourceId[0]; /* [bNrInPins] */
209 /* struct usb_audio_mixer_unit_1 */
211 struct usb_audio_mixer_unit_1 {
213 uWord wChannelConfig;
215 uByte bmControls[0]; /* [see source code] */
219 /* UDESCSUB_AC_SELECTOR */
220 struct usb_audio_selector_unit {
222 uByte bDescriptorType;
223 uByte bDescriptorSubtype;
226 uByte baSourceId[0]; /* [bNrInPins] */
227 /* uByte iSelector; */
230 /* UDESCSUB_AC_FEATURE */
231 struct usb_audio_feature_unit {
233 uByte bDescriptorType;
234 uByte bDescriptorSubtype;
238 uByte bmaControls[0]; /* [bControlSize * x] */
239 /* uByte iFeature; */
242 /* UDESCSUB_AC_PROCESSING */
243 struct usb_audio_processing_unit_0 {
245 uByte bDescriptorType;
246 uByte bDescriptorSubtype;
250 uByte baSourceId[0]; /* [bNrInPins] */
251 /* struct usb_audio_processing_unit_1 */
253 struct usb_audio_processing_unit_1 {
255 uWord wChannelConfig;
258 uByte bmControls[0]; /* [bControlSize] */
259 #define UA_PROC_ENABLE_MASK 1
262 struct usb_audio_processing_unit_updown {
265 uWord waModes[0]; /* [bNrModes] */
268 /* UDESCSUB_AC_EXTENSION */
269 struct usb_audio_extension_unit_0 {
271 uByte bDescriptorType;
272 uByte bDescriptorSubtype;
274 uWord wExtensionCode;
276 uByte baSourceId[0]; /* [bNrInPins] */
277 /* struct usb_audio_extension_unit_1 */
280 struct usb_audio_extension_unit_1 {
282 uWord wChannelConfig;
285 uByte bmControls[0]; /* [bControlSize] */
286 #define UA_EXT_ENABLE_MASK 1
287 #define UA_EXT_ENABLE 1
288 /* uByte iExtension; */
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
366 #define GET_STAT 0xff
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
386 #define FU_MASK(u) (1 << ((u)-1))
388 #define MASTER_CHAN 0
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
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
406 #define SAMPLING_FREQ_CONTROL 0x01
407 #define PITCH_CONTROL 0x02
409 #define FORMAT_TYPE_UNDEFINED 0
410 #define FORMAT_TYPE_I 1
411 #define FORMAT_TYPE_II 2
412 #define FORMAT_TYPE_III 3
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
444 /*------------------------------------------------------------------------*
445 * USB audio v2.0 definitions
446 *------------------------------------------------------------------------*/
448 struct usb_audio20_streaming_interface_descriptor {
450 uByte bDescriptorType;
451 uByte bDescriptorSubtype;
457 uDWord bmChannelConfig;
461 struct usb_audio20_encoder_descriptor {
463 uByte bDescriptorType;
464 uByte bDescriptorSubtype;
479 struct usb_audio20_streaming_endpoint_descriptor {
481 uByte bDescriptorType;
482 uByte bDescriptorSubtype;
484 #define UA20_MPS_ONLY 0x80
486 #define UA20_PITCH_CONTROL_MASK 0x03
487 #define UA20_DATA_OVERRUN_MASK 0x0C
488 #define UA20_DATA_UNDERRUN_MASK 0x30
489 uByte bLockDelayUnits;
493 struct usb_audio20_feedback_endpoint_descriptor {
495 uByte bDescriptorType;
496 uByte bEndpointAddress;
498 uWord wMaxPacketSize;
502 #define UA20_CS_CUR 0x01
503 #define UA20_CS_RANGE 0x02
504 #define UA20_CS_MEM 0x03
506 struct usb_audio20_cur1_parameter {
510 struct usb_audio20_ctl1_range_sub {
516 struct usb_audio20_ctl1_range {
518 struct usb_audio20_ctl1_range_sub sub[1];
521 struct usb_audio20_cur2_parameter {
525 struct usb_audio20_ctl2_range_sub {
531 struct usb_audio20_ctl2_range {
533 struct usb_audio20_ctl2_range_sub sub[1];
536 struct usb_audio20_cur4_parameter {
540 struct usb_audio20_ctl4_range_sub {
546 struct usb_audio20_ctl4_range {
548 struct usb_audio20_ctl4_range_sub sub[1];
551 struct usb_audio20_cc_cluster_descriptor {
553 uDWord bmChannelConfig;
557 struct usb_audio20_streaming_type1_descriptor {
559 uByte bDescriptorType;
560 uByte bDescriptorSubtype;
563 uByte bBitResolution;
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
581 struct usb_audio20_cc_alt_setting {
583 uDWord bmValidAltSettings;
586 struct usb_audio20_interrupt_message {
593 /* UDESCSUB_AC_CLOCK_SRC */
594 struct usb_audio20_clock_source_unit {
596 uByte bDescriptorType;
597 uByte bDescriptorSubtype;
601 uByte bAssocTerminal;
605 /* UDESCSUB_AC_CLOCK_SEL */
606 struct usb_audio20_clock_selector_unit_0 {
608 uByte bDescriptorType;
609 uByte bDescriptorSubtype;
612 uByte baCSourceId[0];
615 struct usb_audio20_clock_selector_unit_1 {
617 uByte iClockSelector;
620 /* UDESCSUB_AC_CLOCK_MUL */
621 struct usb_audio20_clock_multiplier_unit {
623 uByte bDescriptorType;
624 uByte bDescriptorSubtype;
628 uByte iClockMultiplier;
631 /* UDESCSUB_AC_INPUT */
632 struct usb_audio20_input_terminal {
634 uByte bDescriptorType;
635 uByte bDescriptorSubtype;
638 uByte bAssocTerminal;
641 uDWord bmChannelConfig;
647 /* UDESCSUB_AC_OUTPUT */
648 struct usb_audio20_output_terminal {
650 uByte bDescriptorType;
651 uByte bDescriptorSubtype;
654 uByte bAssocTerminal;
661 /* UDESCSUB_AC_MIXER */
662 struct usb_audio20_mixer_unit_0 {
664 uByte bDescriptorType;
665 uByte bDescriptorSubtype;
669 /* struct usb_audio20_mixer_unit_1 */
672 struct usb_audio20_mixer_unit_1 {
674 uDWord bmChannelConfig;
680 /* UDESCSUB_AC_SELECTOR */
681 struct usb_audio20_selector_unit {
683 uByte bDescriptorType;
684 uByte bDescriptorSubtype;
688 /* uByte iSelector; */
691 /* UDESCSUB_AC_FEATURE */
692 struct usb_audio20_feature_unit {
694 uByte bDescriptorType;
695 uByte bDescriptorSubtype;
698 uDWord bmaControls[0];
699 /* uByte iFeature; */
702 /* UDESCSUB_AC_SAMPLE_RT */
703 struct usb_audio20_sample_rate_unit {
705 uByte bDescriptorType;
706 uByte bDescriptorSubtype;
714 /* UDESCSUB_AC_EFFECT */
715 struct usb_audio20_effect_unit {
717 uByte bDescriptorType;
718 uByte bDescriptorSubtype;
722 uDWord bmaControls[0];
726 /* UDESCSUB_AC_PROCESSING_V2 */
727 struct usb_audio20_processing_unit_0 {
729 uByte bDescriptorType;
730 uByte bDescriptorSubtype;
734 uByte baSourceId[0]; /* [bNrInPins] */
737 struct usb_audio20_processing_unit_1 {
739 uDWord bmChannelConfig;
745 /* UDESCSUB_AC_EXTENSION_V2 */
746 struct usb_audio20_extension_unit_0 {
748 uByte bDescriptorType;
749 uByte bDescriptorSubtype;
751 uWord wExtensionCode;
756 struct usb_audio20_extension_unit_1 {
758 uDWord bmChannelConfig;
764 struct usb_audio20_cluster {
766 uDWord bmChannelConfig;
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
785 #define UA20_CS_SAM_FREQ_CONTROL 0x01
786 #define UA20_CS_CLOCK_VALID_CONTROL 0x02
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
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
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)
809 #endif /* _UAUDIOREG_H_ */