Linux 2.6.33-rc2
[pohmelfs.git] / include / linux / usb / audio.h
blobeaf9dffe0a01bea235e5b4be98aa3d49b4120e59
1 /*
2 * <linux/usb/audio.h> -- USB Audio definitions.
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
11 * This file holds USB constants and structures defined
12 * by the USB Device Class Definition for Audio Devices.
13 * Comments below reference relevant sections of that document:
15 * http://www.usb.org/developers/devclass_docs/audio10.pdf
18 #ifndef __LINUX_USB_AUDIO_H
19 #define __LINUX_USB_AUDIO_H
21 #include <linux/types.h>
23 /* A.2 Audio Interface Subclass Codes */
24 #define USB_SUBCLASS_AUDIOCONTROL 0x01
25 #define USB_SUBCLASS_AUDIOSTREAMING 0x02
26 #define USB_SUBCLASS_MIDISTREAMING 0x03
28 /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
29 #define UAC_HEADER 0x01
30 #define UAC_INPUT_TERMINAL 0x02
31 #define UAC_OUTPUT_TERMINAL 0x03
32 #define UAC_MIXER_UNIT 0x04
33 #define UAC_SELECTOR_UNIT 0x05
34 #define UAC_FEATURE_UNIT 0x06
35 #define UAC_PROCESSING_UNIT 0x07
36 #define UAC_EXTENSION_UNIT 0x08
38 /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
39 #define UAC_AS_GENERAL 0x01
40 #define UAC_FORMAT_TYPE 0x02
41 #define UAC_FORMAT_SPECIFIC 0x03
43 /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
44 #define UAC_EP_GENERAL 0x01
46 /* A.9 Audio Class-Specific Request Codes */
47 #define UAC_SET_ 0x00
48 #define UAC_GET_ 0x80
50 #define UAC__CUR 0x1
51 #define UAC__MIN 0x2
52 #define UAC__MAX 0x3
53 #define UAC__RES 0x4
54 #define UAC__MEM 0x5
56 #define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
57 #define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
58 #define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
59 #define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
60 #define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
61 #define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
62 #define UAC_SET_RES (UAC_SET_ | UAC__RES)
63 #define UAC_GET_RES (UAC_GET_ | UAC__RES)
64 #define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
65 #define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
67 #define UAC_GET_STAT 0xff
69 /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
70 #define UAC_MS_HEADER 0x01
71 #define UAC_MIDI_IN_JACK 0x02
72 #define UAC_MIDI_OUT_JACK 0x03
74 /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
75 #define UAC_MS_GENERAL 0x01
77 /* Terminals - 2.1 USB Terminal Types */
78 #define UAC_TERMINAL_UNDEFINED 0x100
79 #define UAC_TERMINAL_STREAMING 0x101
80 #define UAC_TERMINAL_VENDOR_SPEC 0x1FF
82 /* Terminal Control Selectors */
83 /* 4.3.2 Class-Specific AC Interface Descriptor */
84 struct uac_ac_header_descriptor {
85 __u8 bLength; /* 8 + n */
86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
88 __le16 bcdADC; /* 0x0100 */
89 __le16 wTotalLength; /* includes Unit and Terminal desc. */
90 __u8 bInCollection; /* n */
91 __u8 baInterfaceNr[]; /* [n] */
92 } __attribute__ ((packed));
94 #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
96 /* As above, but more useful for defining your own descriptors: */
97 #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
98 struct uac_ac_header_descriptor_##n { \
99 __u8 bLength; \
100 __u8 bDescriptorType; \
101 __u8 bDescriptorSubtype; \
102 __le16 bcdADC; \
103 __le16 wTotalLength; \
104 __u8 bInCollection; \
105 __u8 baInterfaceNr[n]; \
106 } __attribute__ ((packed))
108 /* 4.3.2.1 Input Terminal Descriptor */
109 struct uac_input_terminal_descriptor {
110 __u8 bLength; /* in bytes: 12 */
111 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
112 __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
113 __u8 bTerminalID; /* Constant uniquely terminal ID */
114 __le16 wTerminalType; /* USB Audio Terminal Types */
115 __u8 bAssocTerminal; /* ID of the Output Terminal associated */
116 __u8 bNrChannels; /* Number of logical output channels */
117 __le16 wChannelConfig;
118 __u8 iChannelNames;
119 __u8 iTerminal;
120 } __attribute__ ((packed));
122 #define UAC_DT_INPUT_TERMINAL_SIZE 12
124 /* Terminals - 2.2 Input Terminal Types */
125 #define UAC_INPUT_TERMINAL_UNDEFINED 0x200
126 #define UAC_INPUT_TERMINAL_MICROPHONE 0x201
127 #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
128 #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
129 #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
130 #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
131 #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
133 /* 4.3.2.2 Output Terminal Descriptor */
134 struct uac_output_terminal_descriptor {
135 __u8 bLength; /* in bytes: 9 */
136 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
137 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
138 __u8 bTerminalID; /* Constant uniquely terminal ID */
139 __le16 wTerminalType; /* USB Audio Terminal Types */
140 __u8 bAssocTerminal; /* ID of the Input Terminal associated */
141 __u8 bSourceID; /* ID of the connected Unit or Terminal*/
142 __u8 iTerminal;
143 } __attribute__ ((packed));
145 #define UAC_DT_OUTPUT_TERMINAL_SIZE 9
147 /* Terminals - 2.3 Output Terminal Types */
148 #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
149 #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
150 #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
151 #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
152 #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
153 #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
154 #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
155 #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
157 /* Set bControlSize = 2 as default setting */
158 #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
160 /* As above, but more useful for defining your own descriptors: */
161 #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
162 struct uac_feature_unit_descriptor_##ch { \
163 __u8 bLength; \
164 __u8 bDescriptorType; \
165 __u8 bDescriptorSubtype; \
166 __u8 bUnitID; \
167 __u8 bSourceID; \
168 __u8 bControlSize; \
169 __le16 bmaControls[ch + 1]; \
170 __u8 iFeature; \
171 } __attribute__ ((packed))
173 /* 4.5.2 Class-Specific AS Interface Descriptor */
174 struct uac_as_header_descriptor {
175 __u8 bLength; /* in bytes: 7 */
176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
177 __u8 bDescriptorSubtype; /* AS_GENERAL */
178 __u8 bTerminalLink; /* Terminal ID of connected Terminal */
179 __u8 bDelay; /* Delay introduced by the data path */
180 __le16 wFormatTag; /* The Audio Data Format */
181 } __attribute__ ((packed));
183 #define UAC_DT_AS_HEADER_SIZE 7
185 /* Formats - A.1.1 Audio Data Format Type I Codes */
186 #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
187 #define UAC_FORMAT_TYPE_I_PCM 0x1
188 #define UAC_FORMAT_TYPE_I_PCM8 0x2
189 #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
190 #define UAC_FORMAT_TYPE_I_ALAW 0x4
191 #define UAC_FORMAT_TYPE_I_MULAW 0x5
193 struct uac_format_type_i_continuous_descriptor {
194 __u8 bLength; /* in bytes: 8 + (ns * 3) */
195 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
196 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
197 __u8 bFormatType; /* FORMAT_TYPE_1 */
198 __u8 bNrChannels; /* physical channels in the stream */
199 __u8 bSubframeSize; /* */
200 __u8 bBitResolution;
201 __u8 bSamFreqType;
202 __u8 tLowerSamFreq[3];
203 __u8 tUpperSamFreq[3];
204 } __attribute__ ((packed));
206 #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
208 struct uac_format_type_i_discrete_descriptor {
209 __u8 bLength; /* in bytes: 8 + (ns * 3) */
210 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
211 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
212 __u8 bFormatType; /* FORMAT_TYPE_1 */
213 __u8 bNrChannels; /* physical channels in the stream */
214 __u8 bSubframeSize; /* */
215 __u8 bBitResolution;
216 __u8 bSamFreqType;
217 __u8 tSamFreq[][3];
218 } __attribute__ ((packed));
220 #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
221 struct uac_format_type_i_discrete_descriptor_##n { \
222 __u8 bLength; \
223 __u8 bDescriptorType; \
224 __u8 bDescriptorSubtype; \
225 __u8 bFormatType; \
226 __u8 bNrChannels; \
227 __u8 bSubframeSize; \
228 __u8 bBitResolution; \
229 __u8 bSamFreqType; \
230 __u8 tSamFreq[n][3]; \
231 } __attribute__ ((packed))
233 #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
235 /* Formats - A.2 Format Type Codes */
236 #define UAC_FORMAT_TYPE_UNDEFINED 0x0
237 #define UAC_FORMAT_TYPE_I 0x1
238 #define UAC_FORMAT_TYPE_II 0x2
239 #define UAC_FORMAT_TYPE_III 0x3
241 struct uac_iso_endpoint_descriptor {
242 __u8 bLength; /* in bytes: 7 */
243 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
244 __u8 bDescriptorSubtype; /* EP_GENERAL */
245 __u8 bmAttributes;
246 __u8 bLockDelayUnits;
247 __le16 wLockDelay;
249 #define UAC_ISO_ENDPOINT_DESC_SIZE 7
251 #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
252 #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
253 #define UAC_EP_CS_ATTR_FILL_MAX 0x80
255 /* A.10.2 Feature Unit Control Selectors */
256 #define UAC_FU_CONTROL_UNDEFINED 0x00
257 #define UAC_MUTE_CONTROL 0x01
258 #define UAC_VOLUME_CONTROL 0x02
259 #define UAC_BASS_CONTROL 0x03
260 #define UAC_MID_CONTROL 0x04
261 #define UAC_TREBLE_CONTROL 0x05
262 #define UAC_GRAPHIC_EQUALIZER_CONTROL 0x06
263 #define UAC_AUTOMATIC_GAIN_CONTROL 0x07
264 #define UAC_DELAY_CONTROL 0x08
265 #define UAC_BASS_BOOST_CONTROL 0x09
266 #define UAC_LOUDNESS_CONTROL 0x0a
268 #define UAC_FU_MUTE (1 << (UAC_MUTE_CONTROL - 1))
269 #define UAC_FU_VOLUME (1 << (UAC_VOLUME_CONTROL - 1))
270 #define UAC_FU_BASS (1 << (UAC_BASS_CONTROL - 1))
271 #define UAC_FU_MID (1 << (UAC_MID_CONTROL - 1))
272 #define UAC_FU_TREBLE (1 << (UAC_TREBLE_CONTROL - 1))
273 #define UAC_FU_GRAPHIC_EQ (1 << (UAC_GRAPHIC_EQUALIZER_CONTROL - 1))
274 #define UAC_FU_AUTO_GAIN (1 << (UAC_AUTOMATIC_GAIN_CONTROL - 1))
275 #define UAC_FU_DELAY (1 << (UAC_DELAY_CONTROL - 1))
276 #define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1))
277 #define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1))
279 #ifdef __KERNEL__
281 struct usb_audio_control {
282 struct list_head list;
283 const char *name;
284 u8 type;
285 int data[5];
286 int (*set)(struct usb_audio_control *con, u8 cmd, int value);
287 int (*get)(struct usb_audio_control *con, u8 cmd);
290 struct usb_audio_control_selector {
291 struct list_head list;
292 struct list_head control;
293 u8 id;
294 const char *name;
295 u8 type;
296 struct usb_descriptor_header *desc;
299 #endif /* __KERNEL__ */
301 #endif /* __LINUX_USB_AUDIO_H */