xref: /haiku/headers/os/drivers/usb/USB_audio.h (revision cda5b8808fd0262f0fac472f6cfa809f846a83cf)
1 #ifndef USB_AUDIO_H
2 #define USB_AUDIO_H
3 
4 // (Partial) USB Class Definitions for Audio Devices, version 1.0
5 // Reference: http://www.usb.org/developers/devclass_docs/audio10.pdf
6 
7 #include <BeBuild.h>	// for _PACKED definition
8 
9 #define USB_AUDIO_DEVICE_CLASS 			0x01
10 #define USB_AUDIO_CLASS_VERSION			0x0100
11 
12 enum {
13 	USB_AUDIO_INTERFACE_AUDIO_CLASS		= 0x01
14 };
15 
16 enum { // Audio Interface Subclasses
17 	USB_AUDIO_INTERFACE_AUDIOCONTROL_SUBCLASS =	0x01,	//
18 	USB_AUDIO_INTERFACE_AUDIOSTREAMING_SUBCLASS,		//
19 	USB_AUDIO_INTERFACE_MIDISTREAMING_SUBCLASS			//
20 };
21 
22 enum { // Audio Class-Specific AudioControl Interface descriptor subtypes
23 	USB_AUDIO_AC_DESCRIPTOR_UNDEFINED				= 0x00,
24 	USB_AUDIO_AC_HEADER						= 0x01,
25 	USB_AUDIO_AC_INPUT_TERMINAL,
26 	USB_AUDIO_AC_OUTPUT_TERMINAL,
27 	USB_AUDIO_AC_MIXER_UNIT,
28 	USB_AUDIO_AC_SELECTOR_UNIT,
29 	USB_AUDIO_AC_FEATURE_UNIT,
30 	USB_AUDIO_AC_PROCESSING_UNIT,
31 	USB_AUDIO_AC_EXTENSION_UNIT
32 };
33 
34 enum { // Audio Class-Specific AudioStreaming Interface descriptor subtypes
35 	USB_AUDIO_AS_GENERAL						= 0x01,
36 	USB_AUDIO_AS_FORMAT_TYPE,
37 	USB_AUDIO_AS_FORMAT_SPECIFIC
38 };
39 
40 enum { // Processing Unit Process Types  (for USB_AUDIO_AC_PROCESSING_UNIT)
41 	USB_AUDIO_UPDOWNMIX_PROCESS	= 0x01,
42 	USB_AUDIO_DOLBY_PROLOGIC_PROCESS,
43 	USB_AUDIO_3D_STEREO_EXTENDER_PROCESS,
44 	USB_AUDIO_REVERBERATION_PROCESS,
45 	USB_AUDIO_CHORUS_PROCESS,
46 	USB_AUDIO_DYN_RANGE_COMP_PROCESS
47 };
48 
49 // AudioControl request codes
50 #define USB_AUDIO_SET_CURRENT 	0x01
51 #define USB_AUDIO_GET_CURRENT	0x81
52 #define USB_AUDIO_SET_MIN 		0x02
53 #define USB_AUDIO_GET_MIN 		0x82
54 #define USB_AUDIO_SET_MAX 		0x03
55 #define USB_AUDIO_GET_MAX 		0x83
56 #define USB_AUDIO_SET_RES 		0x04
57 #define USB_AUDIO_GET_RES 		0x84
58 #define USB_AUDIO_SET_MEM 		0x05
59 #define USB_AUDIO_GET_MEM 		0x85
60 #define USB_AUDIO_GET_STATUS 	0xFF
61 
62 enum { // Terminal Control Selectors
63 	USB_AUDIO_COPY_PROTECT_CONTROL = 0x01
64 };
65 
66 /* A.10.2 Feature Unit Control Selectors */
67 #define AC_FU_CONTROL_UNDEFINED 0x00
68 #define USB_AUDIO_MUTE_CONTROL 0x01
69 #define USB_AUDIO_VOLUME_CONTROL 0x02
70 #define USB_AUDIO_BASS_CONTROL 0x03
71 #define USB_AUDIO_MID_CONTROL 0x04
72 #define USB_AUDIO_TREBLE_CONTROL 0x05
73 #define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
74 #define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
75 #define USB_AUDIO_DELAY_CONTROL 0x08
76 #define USB_AUDIO_BASS_BOOST_CONTROL 0x09
77 #define USB_AUDIO_LOUDNESS_CONTROL 0x0A
78 
79 /* A.10.3.1 Up/Down-mix Processing Unit Control Selectors */
80 #define USB_AUDIO_UD_CONTROL_UNDEFINED 0x00
81 #define USB_AUDIO_UD_ENABLED_CONTROL 0x01
82 #define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
83 
84 /* A.10.3.2 Dolby Prologic(tm) Processing Unit Control Selectors */
85 #define USB_AUDIO_DP_CONTROL_UNDEFINED 0x00
86 #define USB_AUDIO_DP_ENABLE_CONTROL 0x01
87 #define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
88 
89 /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
90 #define USB_AUDIO_3D_CONTROL_UNDEFINED 0x00
91 #define USB_AUDIO_3D_ENABLED_CONTROL 0x01
92 #define USB_AUDIO_3D_SPACIOUSNESS_CONTROL 0x03
93 
94 /* A.10.3.4 Reverberation Processing Unit Control Selectors */
95 #define USB_AUDIO_RV_CONTROL_UNDEFINED 0x00
96 #define USB_AUDIO_RV_ENABLE_CONTROL 0x01
97 #define USB_AUDIO_RV_REVERB_LEVEL_CONTROL 0x02
98 #define USB_AUDIO_RV_REVERB_TIME_CONTROL 0x03
99 #define USB_AUDIO_RV_REVERB_FEEDBACK_CONTROL 0x04
100 
101 /* A.10.3.5 Chorus Processing Unit Control Selectors */
102 #define USB_AUDIO_CH_CONTROL_UNDEFINED 0x00
103 #define USB_AUDIO_CH_ENABLE_CONTROL 0x01
104 #define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
105 #define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
106 #define USB_AUDIO_CHORUS_DETH_CONTROL 0x04
107 
108 /* A.10.3.6 Dynamic Range Compressor Processing Unit Control Selectors */
109 #define USB_AUDIO_DR_CONTROL_UNDEFINED 0x00
110 #define USB_AUDIO_DR_ENABLE_CONTROL 0x01
111 #define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
112 #define USB_AUDIO_MAXAMPL_CONTROL 0x03
113 #define USB_AUDIO_THRESHOLD_CONTROL 0x04
114 #define USB_AUDIO_ATTACK_TIME 0x05
115 #define USB_AUDIO_RELEASE_TIME 0x06
116 
117 /* A.10.4 Extension Unit Control Selectors */
118 #define USB_AUDIO_XU_CONTROL_UNDEFINED 0x00
119 #define USB_AUDIO_XU_ENABLE_CONTROL 0x01
120 
121 /* A.10.5 Endpoint Control Selectors */
122 #define USB_AUDIO_EP_CONTROL_UNDEFINED 0x00
123 #define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
124 #define USB_AUDIO_PITCH_CONTROL 0x02
125 
126 typedef struct
127 {
128 	uint8 length;
129 	uint8 type;
130 	uint8 subtype;
131 	uint8 unit_id;
132 	uint8 source_id;
133 	uint8 control_size;
134 	uint16 controls[0];
135 } _PACKED usb_audio_feature_unit_descriptor;
136 
137 typedef struct {
138 	uint8 length;
139 	uint8 type;
140 	uint8 subtype;
141 	uint8 format_type;
142 	uint8 num_channels;
143 	uint8 subframe_size;
144 	uint8 bit_resolution;
145 	uint8 sample_freq_type;
146 	uint8 sample_freq[3];	// [0] + [1] << 8 + [2] << 16
147 	//  if sample_freq_type != 1,
148 	// (sample_freq_type - 1) x uint8 sample_freq[3] follows...
149 } _PACKED usb_audio_format_type_descriptor;
150 
151 #define USB_AUDIO_FORMAT_TYPE_UNDEFINED	0x00
152 #define USB_AUDIO_FORMAT_TYPE_I			0x01
153 #define USB_AUDIO_FORMAT_TYPE_II		0x02
154 #define USB_AUDIO_FORMAT_TYPE_III		0x03
155 
156 #endif	// USB_AUDIO_H
157