1 /* $NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $ */
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 #define UAUDIO_VERSION_10 0x0100
38 #define UAUDIO_VERSION_20 0x0200
39 #define UAUDIO_VERSION_30 0x0300
41 #define UAUDIO_PROTOCOL_20 0x20
43 #define UDESC_CS_UNDEFINED 0x20
44 #define UDESC_CS_DEVICE 0x21
45 #define UDESC_CS_CONFIG 0x22
46 #define UDESC_CS_STRING 0x23
47 #define UDESC_CS_INTERFACE 0x24
48 #define UDESC_CS_ENDPOINT 0x25
50 #define UDESCSUB_AC_HEADER 1
51 #define UDESCSUB_AC_INPUT 2
52 #define UDESCSUB_AC_OUTPUT 3
53 #define UDESCSUB_AC_MIXER 4
54 #define UDESCSUB_AC_SELECTOR 5
55 #define UDESCSUB_AC_FEATURE 6
56 #define UDESCSUB_AC_PROCESSING 7
57 #define UDESCSUB_AC_EXTENSION 8
58 /* ==== USB audio v2.0 ==== */
59 #define UDESCSUB_AC_EFFECT 7
60 #define UDESCSUB_AC_PROCESSING_V2 8
61 #define UDESCSUB_AC_EXTENSION_V2 9
62 #define UDESCSUB_AC_CLOCK_SRC 10
63 #define UDESCSUB_AC_CLOCK_SEL 11
64 #define UDESCSUB_AC_CLOCK_MUL 12
65 #define UDESCSUB_AC_SAMPLE_RT 13
67 /* These macros check if the endpoint descriptor has additional fields */
69 #define UEP_HAS_REFRESH(ep) ((ep)->bLength >= 8)
70 #define UEP_HAS_SYNCADDR(ep) ((ep)->bLength >= 9)
72 /* The first fields are identical to struct usb_endpoint_descriptor */
75 uByte bDescriptorType;
76 uByte bEndpointAddress;
81 * The following two entries are only used by the Audio Class.
82 * And according to the specs the Audio Class is the only one
83 * allowed to extend the endpoint descriptor.
84 * Who knows what goes on in the minds of the people in the USB
85 * standardization? :-(
89 } __packed usb_endpoint_descriptor_audio_t;
91 struct usb_audio_control_descriptor {
93 uByte bDescriptorType;
94 uByte bDescriptorSubtype;
98 uByte baInterfaceNr[1];
101 struct usb_audio_streaming_interface_descriptor {
103 uByte bDescriptorType;
104 uByte bDescriptorSubtype;
110 struct usb_audio_streaming_endpoint_descriptor {
112 uByte bDescriptorType;
113 uByte bDescriptorSubtype;
115 #define UA_SED_FREQ_CONTROL 0x01
116 #define UA_SED_PITCH_CONTROL 0x02
117 #define UA_SED_MAXPACKETSONLY 0x80
118 uByte bLockDelayUnits;
122 struct usb_midi_streaming_endpoint_descriptor {
124 uByte bDescriptorType;
125 uByte bDescriptorSubtype;
126 uByte bNumEmbMIDIJack;
129 struct usb_audio_streaming_type1_descriptor {
131 uByte bDescriptorType;
132 uByte bDescriptorSubtype;
136 uByte bBitResolution;
138 #define UA_SAMP_CONTNUOUS 0
140 #define UA_GETSAMP(p, n) ((uint32_t)((((p)->tSamFreq[((n)*3)+0]) | \
141 ((p)->tSamFreq[((n)*3)+1] << 8) | \
142 ((p)->tSamFreq[((n)*3)+2] << 16))))
143 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
144 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
147 struct usb_audio_cluster {
149 uWord wChannelConfig;
150 #define UA_CHANNEL_LEFT 0x0001
151 #define UA_CHANNEL_RIGHT 0x0002
152 #define UA_CHANNEL_CENTER 0x0004
153 #define UA_CHANNEL_LFE 0x0008
154 #define UA_CHANNEL_L_SURROUND 0x0010
155 #define UA_CHANNEL_R_SURROUND 0x0020
156 #define UA_CHANNEL_L_CENTER 0x0040
157 #define UA_CHANNEL_R_CENTER 0x0080
158 #define UA_CHANNEL_SURROUND 0x0100
159 #define UA_CHANNEL_L_SIDE 0x0200
160 #define UA_CHANNEL_R_SIDE 0x0400
161 #define UA_CHANNEL_TOP 0x0800
165 /* Shared by all units and terminals */
166 struct usb_audio_unit {
168 uByte bDescriptorType;
169 uByte bDescriptorSubtype;
173 /* UDESCSUB_AC_INPUT */
174 struct usb_audio_input_terminal {
176 uByte bDescriptorType;
177 uByte bDescriptorSubtype;
180 uByte bAssocTerminal;
182 uWord wChannelConfig;
184 /* uByte iTerminal; */
187 /* UDESCSUB_AC_OUTPUT */
188 struct usb_audio_output_terminal {
190 uByte bDescriptorType;
191 uByte bDescriptorSubtype;
194 uByte bAssocTerminal;
199 /* UDESCSUB_AC_MIXER */
200 struct usb_audio_mixer_unit_0 {
202 uByte bDescriptorType;
203 uByte bDescriptorSubtype;
206 uByte baSourceId[0]; /* [bNrInPins] */
207 /* struct usb_audio_mixer_unit_1 */
209 struct usb_audio_mixer_unit_1 {
211 uWord wChannelConfig;
213 uByte bmControls[0]; /* [see source code] */
217 /* UDESCSUB_AC_SELECTOR */
218 struct usb_audio_selector_unit {
220 uByte bDescriptorType;
221 uByte bDescriptorSubtype;
224 uByte baSourceId[0]; /* [bNrInPins] */
225 /* uByte iSelector; */
228 /* UDESCSUB_AC_FEATURE */
229 struct usb_audio_feature_unit {
231 uByte bDescriptorType;
232 uByte bDescriptorSubtype;
236 uByte bmaControls[0]; /* [bControlSize * x] */
237 /* uByte iFeature; */
240 /* UDESCSUB_AC_PROCESSING */
241 struct usb_audio_processing_unit_0 {
243 uByte bDescriptorType;
244 uByte bDescriptorSubtype;
248 uByte baSourceId[0]; /* [bNrInPins] */
249 /* struct usb_audio_processing_unit_1 */
251 struct usb_audio_processing_unit_1 {
253 uWord wChannelConfig;
256 uByte bmControls[0]; /* [bControlSize] */
257 #define UA_PROC_ENABLE_MASK 1
260 struct usb_audio_processing_unit_updown {
263 uWord waModes[0]; /* [bNrModes] */
266 /* UDESCSUB_AC_EXTENSION */
267 struct usb_audio_extension_unit_0 {
269 uByte bDescriptorType;
270 uByte bDescriptorSubtype;
272 uWord wExtensionCode;
274 uByte baSourceId[0]; /* [bNrInPins] */
275 /* struct usb_audio_extension_unit_1 */
278 struct usb_audio_extension_unit_1 {
280 uWord wChannelConfig;
283 uByte bmControls[0]; /* [bControlSize] */
284 #define UA_EXT_ENABLE_MASK 1
285 #define UA_EXT_ENABLE 1
286 /* uByte iExtension; */
289 /* USB terminal types */
290 #define UAT_UNDEFINED 0x0100
291 #define UAT_STREAM 0x0101
292 #define UAT_VENDOR 0x01ff
293 /* input terminal types */
294 #define UATI_UNDEFINED 0x0200
295 #define UATI_MICROPHONE 0x0201
296 #define UATI_DESKMICROPHONE 0x0202
297 #define UATI_PERSONALMICROPHONE 0x0203
298 #define UATI_OMNIMICROPHONE 0x0204
299 #define UATI_MICROPHONEARRAY 0x0205
300 #define UATI_PROCMICROPHONEARR 0x0206
301 /* output terminal types */
302 #define UATO_UNDEFINED 0x0300
303 #define UATO_SPEAKER 0x0301
304 #define UATO_HEADPHONES 0x0302
305 #define UATO_DISPLAYAUDIO 0x0303
306 #define UATO_DESKTOPSPEAKER 0x0304
307 #define UATO_ROOMSPEAKER 0x0305
308 #define UATO_COMMSPEAKER 0x0306
309 #define UATO_SUBWOOFER 0x0307
310 /* bidir terminal types */
311 #define UATB_UNDEFINED 0x0400
312 #define UATB_HANDSET 0x0401
313 #define UATB_HEADSET 0x0402
314 #define UATB_SPEAKERPHONE 0x0403
315 #define UATB_SPEAKERPHONEESUP 0x0404
316 #define UATB_SPEAKERPHONEECANC 0x0405
317 /* telephony terminal types */
318 #define UATT_UNDEFINED 0x0500
319 #define UATT_PHONELINE 0x0501
320 #define UATT_TELEPHONE 0x0502
321 #define UATT_DOWNLINEPHONE 0x0503
322 /* external terminal types */
323 #define UATE_UNDEFINED 0x0600
324 #define UATE_ANALOGCONN 0x0601
325 #define UATE_DIGITALAUIFC 0x0602
326 #define UATE_LINECONN 0x0603
327 #define UATE_LEGACYCONN 0x0604
328 #define UATE_SPDIF 0x0605
329 #define UATE_1394DA 0x0606
330 #define UATE_1394DV 0x0607
331 /* embedded function terminal types */
332 #define UATF_UNDEFINED 0x0700
333 #define UATF_CALIBNOISE 0x0701
334 #define UATF_EQUNOISE 0x0702
335 #define UATF_CDPLAYER 0x0703
336 #define UATF_DAT 0x0704
337 #define UATF_DCC 0x0705
338 #define UATF_MINIDISK 0x0706
339 #define UATF_ANALOGTAPE 0x0707
340 #define UATF_PHONOGRAPH 0x0708
341 #define UATF_VCRAUDIO 0x0709
342 #define UATF_VIDEODISCAUDIO 0x070a
343 #define UATF_DVDAUDIO 0x070b
344 #define UATF_TVTUNERAUDIO 0x070c
345 #define UATF_SATELLITE 0x070d
346 #define UATF_CABLETUNER 0x070e
347 #define UATF_DSS 0x070f
348 #define UATF_RADIORECV 0x0710
349 #define UATF_RADIOXMIT 0x0711
350 #define UATF_MULTITRACK 0x0712
351 #define UATF_SYNTHESIZER 0x0713
364 #define GET_STAT 0xff
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
384 #define FU_MASK(u) (1 << ((u)-1))
386 #define MASTER_CHAN 0
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
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
404 #define SAMPLING_FREQ_CONTROL 0x01
405 #define PITCH_CONTROL 0x02
407 #define FORMAT_TYPE_UNDEFINED 0
408 #define FORMAT_TYPE_I 1
409 #define FORMAT_TYPE_II 2
410 #define FORMAT_TYPE_III 3
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
442 /*------------------------------------------------------------------------*
443 * USB audio v2.0 definitions
444 *------------------------------------------------------------------------*/
446 struct usb_audio20_streaming_interface_descriptor {
448 uByte bDescriptorType;
449 uByte bDescriptorSubtype;
455 uDWord bmChannelConfig;
459 struct usb_audio20_encoder_descriptor {
461 uByte bDescriptorType;
462 uByte bDescriptorSubtype;
477 struct usb_audio20_streaming_endpoint_descriptor {
479 uByte bDescriptorType;
480 uByte bDescriptorSubtype;
482 #define UA20_MPS_ONLY 0x80
484 #define UA20_PITCH_CONTROL_MASK 0x03
485 #define UA20_DATA_OVERRUN_MASK 0x0C
486 #define UA20_DATA_UNDERRUN_MASK 0x30
487 uByte bLockDelayUnits;
491 struct usb_audio20_feedback_endpoint_descriptor {
493 uByte bDescriptorType;
494 uByte bEndpointAddress;
496 uWord wMaxPacketSize;
500 #define UA20_CS_CUR 0x01
501 #define UA20_CS_RANGE 0x02
502 #define UA20_CS_MEM 0x03
504 struct usb_audio20_cur1_parameter {
508 struct usb_audio20_ctl1_range_sub {
514 struct usb_audio20_ctl1_range {
516 struct usb_audio20_ctl1_range_sub sub[1];
519 struct usb_audio20_cur2_parameter {
523 struct usb_audio20_ctl2_range_sub {
529 struct usb_audio20_ctl2_range {
531 struct usb_audio20_ctl2_range_sub sub[1];
534 struct usb_audio20_cur4_parameter {
538 struct usb_audio20_ctl4_range_sub {
544 struct usb_audio20_ctl4_range {
546 struct usb_audio20_ctl4_range_sub sub[1];
549 struct usb_audio20_cc_cluster_descriptor {
551 uDWord bmChannelConfig;
555 struct usb_audio20_streaming_type1_descriptor {
557 uByte bDescriptorType;
558 uByte bDescriptorSubtype;
561 uByte bBitResolution;
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
579 struct usb_audio20_cc_alt_setting {
581 uDWord bmValidAltSettings;
584 struct usb_audio20_interrupt_message {
591 /* UDESCSUB_AC_CLOCK_SRC */
592 struct usb_audio20_clock_source_unit {
594 uByte bDescriptorType;
595 uByte bDescriptorSubtype;
599 uByte bAssocTerminal;
603 /* UDESCSUB_AC_CLOCK_SEL */
604 struct usb_audio20_clock_selector_unit_0 {
606 uByte bDescriptorType;
607 uByte bDescriptorSubtype;
610 uByte baCSourceId[0];
613 struct usb_audio20_clock_selector_unit_1 {
615 uByte iClockSelector;
618 /* UDESCSUB_AC_CLOCK_MUL */
619 struct usb_audio20_clock_multiplier_unit {
621 uByte bDescriptorType;
622 uByte bDescriptorSubtype;
626 uByte iClockMultiplier;
629 /* UDESCSUB_AC_INPUT */
630 struct usb_audio20_input_terminal {
632 uByte bDescriptorType;
633 uByte bDescriptorSubtype;
636 uByte bAssocTerminal;
639 uDWord bmChannelConfig;
645 /* UDESCSUB_AC_OUTPUT */
646 struct usb_audio20_output_terminal {
648 uByte bDescriptorType;
649 uByte bDescriptorSubtype;
652 uByte bAssocTerminal;
659 /* UDESCSUB_AC_MIXER */
660 struct usb_audio20_mixer_unit_0 {
662 uByte bDescriptorType;
663 uByte bDescriptorSubtype;
667 /* struct usb_audio20_mixer_unit_1 */
670 struct usb_audio20_mixer_unit_1 {
672 uDWord bmChannelConfig;
678 /* UDESCSUB_AC_SELECTOR */
679 struct usb_audio20_selector_unit {
681 uByte bDescriptorType;
682 uByte bDescriptorSubtype;
686 /* uByte iSelector; */
689 /* UDESCSUB_AC_FEATURE */
690 struct usb_audio20_feature_unit {
692 uByte bDescriptorType;
693 uByte bDescriptorSubtype;
696 uDWord bmaControls[0];
697 /* uByte iFeature; */
700 /* UDESCSUB_AC_SAMPLE_RT */
701 struct usb_audio20_sample_rate_unit {
703 uByte bDescriptorType;
704 uByte bDescriptorSubtype;
712 /* UDESCSUB_AC_EFFECT */
713 struct usb_audio20_effect_unit {
715 uByte bDescriptorType;
716 uByte bDescriptorSubtype;
720 uDWord bmaControls[0];
724 /* UDESCSUB_AC_PROCESSING_V2 */
725 struct usb_audio20_processing_unit_0 {
727 uByte bDescriptorType;
728 uByte bDescriptorSubtype;
732 uByte baSourceId[0]; /* [bNrInPins] */
735 struct usb_audio20_processing_unit_1 {
737 uDWord bmChannelConfig;
743 /* UDESCSUB_AC_EXTENSION_V2 */
744 struct usb_audio20_extension_unit_0 {
746 uByte bDescriptorType;
747 uByte bDescriptorSubtype;
749 uWord wExtensionCode;
754 struct usb_audio20_extension_unit_1 {
756 uDWord bmChannelConfig;
762 struct usb_audio20_cluster {
764 uDWord bmChannelConfig;
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
783 #define UA20_CS_SAM_FREQ_CONTROL 0x01
784 #define UA20_CS_CLOCK_VALID_CONTROL 0x02
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
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
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)
807 #endif /* _UAUDIOREG_H_ */