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 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_audio_streaming_type1_descriptor {
124 uByte bDescriptorType;
125 uByte bDescriptorSubtype;
129 uByte bBitResolution;
131 #define UA_SAMP_CONTNUOUS 0
133 #define UA_GETSAMP(p, n) ((uint32_t)((((p)->tSamFreq[((n)*3)+0]) | \
134 ((p)->tSamFreq[((n)*3)+1] << 8) | \
135 ((p)->tSamFreq[((n)*3)+2] << 16))))
136 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
137 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
140 struct usb_audio_cluster {
142 uWord wChannelConfig;
143 #define UA_CHANNEL_LEFT 0x0001
144 #define UA_CHANNEL_RIGHT 0x0002
145 #define UA_CHANNEL_CENTER 0x0004
146 #define UA_CHANNEL_LFE 0x0008
147 #define UA_CHANNEL_L_SURROUND 0x0010
148 #define UA_CHANNEL_R_SURROUND 0x0020
149 #define UA_CHANNEL_L_CENTER 0x0040
150 #define UA_CHANNEL_R_CENTER 0x0080
151 #define UA_CHANNEL_SURROUND 0x0100
152 #define UA_CHANNEL_L_SIDE 0x0200
153 #define UA_CHANNEL_R_SIDE 0x0400
154 #define UA_CHANNEL_TOP 0x0800
158 /* Shared by all units and terminals */
159 struct usb_audio_unit {
161 uByte bDescriptorType;
162 uByte bDescriptorSubtype;
166 /* UDESCSUB_AC_INPUT */
167 struct usb_audio_input_terminal {
169 uByte bDescriptorType;
170 uByte bDescriptorSubtype;
173 uByte bAssocTerminal;
175 uWord wChannelConfig;
177 /* uByte iTerminal; */
180 /* UDESCSUB_AC_OUTPUT */
181 struct usb_audio_output_terminal {
183 uByte bDescriptorType;
184 uByte bDescriptorSubtype;
187 uByte bAssocTerminal;
192 /* UDESCSUB_AC_MIXER */
193 struct usb_audio_mixer_unit_0 {
195 uByte bDescriptorType;
196 uByte bDescriptorSubtype;
199 uByte baSourceId[0]; /* [bNrInPins] */
200 /* struct usb_audio_mixer_unit_1 */
202 struct usb_audio_mixer_unit_1 {
204 uWord wChannelConfig;
206 uByte bmControls[0]; /* [see source code] */
210 /* UDESCSUB_AC_SELECTOR */
211 struct usb_audio_selector_unit {
213 uByte bDescriptorType;
214 uByte bDescriptorSubtype;
217 uByte baSourceId[0]; /* [bNrInPins] */
218 /* uByte iSelector; */
221 /* UDESCSUB_AC_FEATURE */
222 struct usb_audio_feature_unit {
224 uByte bDescriptorType;
225 uByte bDescriptorSubtype;
229 uByte bmaControls[0]; /* [bControlSize * x] */
230 /* uByte iFeature; */
233 /* UDESCSUB_AC_PROCESSING */
234 struct usb_audio_processing_unit_0 {
236 uByte bDescriptorType;
237 uByte bDescriptorSubtype;
241 uByte baSourceId[0]; /* [bNrInPins] */
242 /* struct usb_audio_processing_unit_1 */
244 struct usb_audio_processing_unit_1 {
246 uWord wChannelConfig;
249 uByte bmControls[0]; /* [bControlSize] */
250 #define UA_PROC_ENABLE_MASK 1
253 struct usb_audio_processing_unit_updown {
256 uWord waModes[0]; /* [bNrModes] */
259 /* UDESCSUB_AC_EXTENSION */
260 struct usb_audio_extension_unit_0 {
262 uByte bDescriptorType;
263 uByte bDescriptorSubtype;
265 uWord wExtensionCode;
267 uByte baSourceId[0]; /* [bNrInPins] */
268 /* struct usb_audio_extension_unit_1 */
271 struct usb_audio_extension_unit_1 {
273 uWord wChannelConfig;
276 uByte bmControls[0]; /* [bControlSize] */
277 #define UA_EXT_ENABLE_MASK 1
278 #define UA_EXT_ENABLE 1
279 /* uByte iExtension; */
282 /* USB terminal types */
283 #define UAT_UNDEFINED 0x0100
284 #define UAT_STREAM 0x0101
285 #define UAT_VENDOR 0x01ff
286 /* input terminal types */
287 #define UATI_UNDEFINED 0x0200
288 #define UATI_MICROPHONE 0x0201
289 #define UATI_DESKMICROPHONE 0x0202
290 #define UATI_PERSONALMICROPHONE 0x0203
291 #define UATI_OMNIMICROPHONE 0x0204
292 #define UATI_MICROPHONEARRAY 0x0205
293 #define UATI_PROCMICROPHONEARR 0x0206
294 /* output terminal types */
295 #define UATO_UNDEFINED 0x0300
296 #define UATO_SPEAKER 0x0301
297 #define UATO_HEADPHONES 0x0302
298 #define UATO_DISPLAYAUDIO 0x0303
299 #define UATO_DESKTOPSPEAKER 0x0304
300 #define UATO_ROOMSPEAKER 0x0305
301 #define UATO_COMMSPEAKER 0x0306
302 #define UATO_SUBWOOFER 0x0307
303 /* bidir terminal types */
304 #define UATB_UNDEFINED 0x0400
305 #define UATB_HANDSET 0x0401
306 #define UATB_HEADSET 0x0402
307 #define UATB_SPEAKERPHONE 0x0403
308 #define UATB_SPEAKERPHONEESUP 0x0404
309 #define UATB_SPEAKERPHONEECANC 0x0405
310 /* telephony terminal types */
311 #define UATT_UNDEFINED 0x0500
312 #define UATT_PHONELINE 0x0501
313 #define UATT_TELEPHONE 0x0502
314 #define UATT_DOWNLINEPHONE 0x0503
315 /* external terminal types */
316 #define UATE_UNDEFINED 0x0600
317 #define UATE_ANALOGCONN 0x0601
318 #define UATE_DIGITALAUIFC 0x0602
319 #define UATE_LINECONN 0x0603
320 #define UATE_LEGACYCONN 0x0604
321 #define UATE_SPDIF 0x0605
322 #define UATE_1394DA 0x0606
323 #define UATE_1394DV 0x0607
324 /* embedded function terminal types */
325 #define UATF_UNDEFINED 0x0700
326 #define UATF_CALIBNOISE 0x0701
327 #define UATF_EQUNOISE 0x0702
328 #define UATF_CDPLAYER 0x0703
329 #define UATF_DAT 0x0704
330 #define UATF_DCC 0x0705
331 #define UATF_MINIDISK 0x0706
332 #define UATF_ANALOGTAPE 0x0707
333 #define UATF_PHONOGRAPH 0x0708
334 #define UATF_VCRAUDIO 0x0709
335 #define UATF_VIDEODISCAUDIO 0x070a
336 #define UATF_DVDAUDIO 0x070b
337 #define UATF_TVTUNERAUDIO 0x070c
338 #define UATF_SATELLITE 0x070d
339 #define UATF_CABLETUNER 0x070e
340 #define UATF_DSS 0x070f
341 #define UATF_RADIORECV 0x0710
342 #define UATF_RADIOXMIT 0x0711
343 #define UATF_MULTITRACK 0x0712
344 #define UATF_SYNTHESIZER 0x0713
357 #define GET_STAT 0xff
359 #define MUTE_CONTROL 0x01
360 #define VOLUME_CONTROL 0x02
361 #define BASS_CONTROL 0x03
362 #define MID_CONTROL 0x04
363 #define TREBLE_CONTROL 0x05
364 #define GRAPHIC_EQUALIZER_CONTROL 0x06
365 #define AGC_CONTROL 0x07
366 #define DELAY_CONTROL 0x08
367 #define BASS_BOOST_CONTROL 0x09
368 #define LOUDNESS_CONTROL 0x0a
369 /* ==== USB audio v2.0 ==== */
370 #define INPUT_GAIN_CONTROL 0x0b
371 #define INPUT_GAIN_PAD_CONTROL 0x0c
372 #define PHASE_INVERTER_CONTROL 0x0d
373 #define UNDERFLOW_CONTROL 0x0e
374 #define OVERFLOW_CONTROL 0x0f
375 #define LATENCY_CONTROL 0x10
377 #define FU_MASK(u) (1 << ((u)-1))
379 #define MASTER_CHAN 0
382 #define FORMAT_TYPE 2
383 #define FORMAT_SPECIFIC 3
384 /* ==== USB audio v2.0 ==== */
385 #define FORMAT_ENCODER 3
386 #define FORMAT_DECODER 4
389 #define UA_FMT_PCM8 2
390 #define UA_FMT_IEEE_FLOAT 3
391 #define UA_FMT_ALAW 4
392 #define UA_FMT_MULAW 5
393 #define UA_FMT_MPEG 0x1001
394 #define UA_FMT_AC3 0x1002
396 #define SAMPLING_FREQ_CONTROL 0x01
397 #define PITCH_CONTROL 0x02
399 #define FORMAT_TYPE_UNDEFINED 0
400 #define FORMAT_TYPE_I 1
401 #define FORMAT_TYPE_II 2
402 #define FORMAT_TYPE_III 3
404 #define UA_PROC_MASK(n) (1<< ((n)-1))
405 #define PROCESS_UNDEFINED 0
406 #define XX_ENABLE_CONTROL 1
407 #define UPDOWNMIX_PROCESS 1
408 #define UD_ENABLE_CONTROL 1
409 #define UD_MODE_SELECT_CONTROL 2
410 #define DOLBY_PROLOGIC_PROCESS 2
411 #define DP_ENABLE_CONTROL 1
412 #define DP_MODE_SELECT_CONTROL 2
413 #define P3D_STEREO_EXTENDER_PROCESS 3
414 #define P3D_ENABLE_CONTROL 1
415 #define P3D_SPACIOUSNESS_CONTROL 2
416 #define REVERBATION_PROCESS 4
417 #define RV_ENABLE_CONTROL 1
418 #define RV_LEVEL_CONTROL 2
419 #define RV_TIME_CONTROL 3
420 #define RV_FEEDBACK_CONTROL 4
421 #define CHORUS_PROCESS 5
422 #define CH_ENABLE_CONTROL 1
423 #define CH_LEVEL_CONTROL 2
424 #define CH_RATE_CONTROL 3
425 #define CH_DEPTH_CONTROL 4
426 #define DYN_RANGE_COMP_PROCESS 6
427 #define DR_ENABLE_CONTROL 1
428 #define DR_COMPRESSION_RATE_CONTROL 2
429 #define DR_MAXAMPL_CONTROL 3
430 #define DR_THRESHOLD_CONTROL 4
431 #define DR_ATTACK_TIME_CONTROL 5
432 #define DR_RELEASE_TIME_CONTROL 6
434 /*------------------------------------------------------------------------*
435 * USB audio v2.0 definitions
436 *------------------------------------------------------------------------*/
438 struct usb_audio20_streaming_interface_descriptor {
440 uByte bDescriptorType;
441 uByte bDescriptorSubtype;
447 uDWord bmChannelConfig;
451 struct usb_audio20_encoder_descriptor {
453 uByte bDescriptorType;
454 uByte bDescriptorSubtype;
469 struct usb_audio20_streaming_endpoint_descriptor {
471 uByte bDescriptorType;
472 uByte bDescriptorSubtype;
474 #define UA20_MPS_ONLY 0x80
476 #define UA20_PITCH_CONTROL_MASK 0x03
477 #define UA20_DATA_OVERRUN_MASK 0x0C
478 #define UA20_DATA_UNDERRUN_MASK 0x30
479 uByte bLockDelayUnits;
483 struct usb_audio20_feedback_endpoint_descriptor {
485 uByte bDescriptorType;
486 uByte bEndpointAddress;
488 uWord wMaxPacketSize;
492 #define UA20_CS_CUR 0x01
493 #define UA20_CS_RANGE 0x02
494 #define UA20_CS_MEM 0x03
496 struct usb_audio20_cur1_parameter {
500 struct usb_audio20_ctl1_range_sub {
506 struct usb_audio20_ctl1_range {
508 struct usb_audio20_ctl1_range_sub sub[1];
511 struct usb_audio20_cur2_parameter {
515 struct usb_audio20_ctl2_range_sub {
521 struct usb_audio20_ctl2_range {
523 struct usb_audio20_ctl2_range_sub sub[1];
526 struct usb_audio20_cur4_parameter {
530 struct usb_audio20_ctl4_range_sub {
536 struct usb_audio20_ctl4_range {
538 struct usb_audio20_ctl4_range_sub sub[1];
541 struct usb_audio20_cc_cluster_descriptor {
543 uDWord bmChannelConfig;
547 struct usb_audio20_streaming_type1_descriptor {
549 uByte bDescriptorType;
550 uByte bDescriptorSubtype;
553 uByte bBitResolution;
556 #define UA20_EERROR_NONE 0
557 #define UA20_EERROR_MEMORY 1
558 #define UA20_EERROR_BANDWIDTH 2
559 #define UA20_EERROR_CPU 3
560 #define UA20_EERROR_FORMATFR_ER 4
561 #define UA20_EERROR_FORMATFR_SM 5
562 #define UA20_EERROR_FORMATFR_LG 6
563 #define UA20_EERROR_DATAFORMAT 7
564 #define UA20_EERROR_NUMCHANNELS 8
565 #define UA20_EERROR_SAMPLERATE 9
566 #define UA20_EERROR_BITRATE 10
567 #define UA20_EERROR_PARAM 11
568 #define UA20_EERROR_NREADY 12
569 #define UA20_EERROR_BUSY 13
571 struct usb_audio20_cc_alt_setting {
573 uDWord bmValidAltSettings;
576 struct usb_audio20_interrupt_message {
583 /* UDESCSUB_AC_CLOCK_SRC */
584 struct usb_audio20_clock_source_unit {
586 uByte bDescriptorType;
587 uByte bDescriptorSubtype;
591 uByte bAssocTerminal;
595 /* UDESCSUB_AC_CLOCK_SEL */
596 struct usb_audio20_clock_selector_unit_0 {
598 uByte bDescriptorType;
599 uByte bDescriptorSubtype;
602 uByte baCSourceId[0];
605 struct usb_audio20_clock_selector_unit_1 {
607 uByte iClockSelector;
610 /* UDESCSUB_AC_CLOCK_MUL */
611 struct usb_audio20_clock_multiplier_unit {
613 uByte bDescriptorType;
614 uByte bDescriptorSubtype;
618 uByte iClockMultiplier;
621 /* UDESCSUB_AC_INPUT */
622 struct usb_audio20_input_terminal {
624 uByte bDescriptorType;
625 uByte bDescriptorSubtype;
628 uByte bAssocTerminal;
631 uDWord bmChannelConfig;
637 /* UDESCSUB_AC_OUTPUT */
638 struct usb_audio20_output_terminal {
640 uByte bDescriptorType;
641 uByte bDescriptorSubtype;
644 uByte bAssocTerminal;
651 /* UDESCSUB_AC_MIXER */
652 struct usb_audio20_mixer_unit_0 {
654 uByte bDescriptorType;
655 uByte bDescriptorSubtype;
659 /* struct usb_audio20_mixer_unit_1 */
662 struct usb_audio20_mixer_unit_1 {
664 uDWord bmChannelConfig;
670 /* UDESCSUB_AC_SELECTOR */
671 struct usb_audio20_selector_unit {
673 uByte bDescriptorType;
674 uByte bDescriptorSubtype;
678 /* uByte iSelector; */
681 /* UDESCSUB_AC_FEATURE */
682 struct usb_audio20_feature_unit {
684 uByte bDescriptorType;
685 uByte bDescriptorSubtype;
688 uDWord bmaControls[0];
689 /* uByte iFeature; */
692 /* UDESCSUB_AC_SAMPLE_RT */
693 struct usb_audio20_sample_rate_unit {
695 uByte bDescriptorType;
696 uByte bDescriptorSubtype;
704 /* UDESCSUB_AC_EFFECT */
705 struct usb_audio20_effect_unit {
707 uByte bDescriptorType;
708 uByte bDescriptorSubtype;
712 uDWord bmaControls[0];
716 /* UDESCSUB_AC_PROCESSING_V2 */
717 struct usb_audio20_processing_unit_0 {
719 uByte bDescriptorType;
720 uByte bDescriptorSubtype;
724 uByte baSourceId[0]; /* [bNrInPins] */
727 struct usb_audio20_processing_unit_1 {
729 uDWord bmChannelConfig;
735 /* UDESCSUB_AC_EXTENSION_V2 */
736 struct usb_audio20_extension_unit_0 {
738 uByte bDescriptorType;
739 uByte bDescriptorSubtype;
741 uWord wExtensionCode;
746 struct usb_audio20_extension_unit_1 {
748 uDWord bmChannelConfig;
754 struct usb_audio20_cluster {
756 uDWord bmChannelConfig;
760 #define UA20_TF_UNDEFINED 0x00
761 #define UA20_TF_DESKTOP_SPEAKER 0x01
762 #define UA20_TF_HOME_THEATER 0x02
763 #define UA20_TF_MICROPHONE 0x03
764 #define UA20_TF_HEADSET 0x04
765 #define UA20_TF_TELEPHONE 0x05
766 #define UA20_TF_CONVERTER 0x06
767 #define UA20_TF_SOUND_RECORDER 0x07
768 #define UA20_TF_IO_BOX 0x08
769 #define UA20_TF_MUSICAL_INSTRUMENT 0x09
770 #define UA20_TF_PRO_AUDIO 0x0A
771 #define UA20_TF_AV 0x0B
772 #define UA20_TF_CONTROL_PANEL 0x0C
773 #define UA20_TF_OTHER 0xFF
775 #define UA20_CS_SAM_FREQ_CONTROL 0x01
776 #define UA20_CS_CLOCK_VALID_CONTROL 0x02
778 #define UA20_TE_COPY_PROTECT_CONTROL 0x01
779 #define UA20_TE_CONNECTOR_CONTROL 0x02
780 #define UA20_TE_OVERLOAD_CONTROL 0x03
781 #define UA20_TE_CLUSTER_CONTROL 0x04
782 #define UA20_TE_UNDERFLOW_CONTROL 0x05
783 #define UA20_TE_OVERFLOW_CONTROL 0x06
784 #define UA20_TE_LATENCY_CONTROL 0x07
786 #define UA20_MU_MIXER_CONTROL 0x01
787 #define UA20_MU_CLUSTER_CONTROL 0x02
788 #define UA20_MU_UNDERFLOW_CONTROL 0x03
789 #define UA20_MU_OVERFLOW_CONTROL 0x04
790 #define UA20_MU_LATENCY_CONTROL 0x05
792 #define UA20_FMT_PCM (1U << 0)
793 #define UA20_FMT_PCM8 (1U << 1)
794 #define UA20_FMT_FLOAT (1U << 2)
795 #define UA20_FMT_ALAW (1U << 3)
796 #define UA20_FMT_MULAW (1U << 4)
797 #define UA20_FMT_RAW (1U << 31)
799 #endif /* _UAUDIOREG_H_ */