diff options
Diffstat (limited to 'include/linux/usb/audio.h')
-rw-r--r-- | include/linux/usb/audio.h | 227 |
1 files changed, 173 insertions, 54 deletions
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h index 4d3e450e2b03..c0ef18dc2da7 100644 --- a/include/linux/usb/audio.h +++ b/include/linux/usb/audio.h | |||
@@ -13,6 +13,9 @@ | |||
13 | * Comments below reference relevant sections of that document: | 13 | * Comments below reference relevant sections of that document: |
14 | * | 14 | * |
15 | * http://www.usb.org/developers/devclass_docs/audio10.pdf | 15 | * http://www.usb.org/developers/devclass_docs/audio10.pdf |
16 | * | ||
17 | * Types and defines in this file are either specific to version 1.0 of | ||
18 | * this standard or common for newer versions. | ||
16 | */ | 19 | */ |
17 | 20 | ||
18 | #ifndef __LINUX_USB_AUDIO_H | 21 | #ifndef __LINUX_USB_AUDIO_H |
@@ -20,14 +23,15 @@ | |||
20 | 23 | ||
21 | #include <linux/types.h> | 24 | #include <linux/types.h> |
22 | 25 | ||
26 | /* bInterfaceProtocol values to denote the version of the standard used */ | ||
27 | #define UAC_VERSION_1 0x00 | ||
28 | #define UAC_VERSION_2 0x20 | ||
29 | |||
23 | /* A.2 Audio Interface Subclass Codes */ | 30 | /* A.2 Audio Interface Subclass Codes */ |
24 | #define USB_SUBCLASS_AUDIOCONTROL 0x01 | 31 | #define USB_SUBCLASS_AUDIOCONTROL 0x01 |
25 | #define USB_SUBCLASS_AUDIOSTREAMING 0x02 | 32 | #define USB_SUBCLASS_AUDIOSTREAMING 0x02 |
26 | #define USB_SUBCLASS_MIDISTREAMING 0x03 | 33 | #define USB_SUBCLASS_MIDISTREAMING 0x03 |
27 | 34 | ||
28 | #define UAC_VERSION_1 0x00 | ||
29 | #define UAC_VERSION_2 0x20 | ||
30 | |||
31 | /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ | 35 | /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ |
32 | #define UAC_HEADER 0x01 | 36 | #define UAC_HEADER 0x01 |
33 | #define UAC_INPUT_TERMINAL 0x02 | 37 | #define UAC_INPUT_TERMINAL 0x02 |
@@ -38,15 +42,6 @@ | |||
38 | #define UAC_PROCESSING_UNIT_V1 0x07 | 42 | #define UAC_PROCESSING_UNIT_V1 0x07 |
39 | #define UAC_EXTENSION_UNIT_V1 0x08 | 43 | #define UAC_EXTENSION_UNIT_V1 0x08 |
40 | 44 | ||
41 | /* UAC v2.0 types */ | ||
42 | #define UAC_EFFECT_UNIT 0x07 | ||
43 | #define UAC_PROCESSING_UNIT_V2 0x08 | ||
44 | #define UAC_EXTENSION_UNIT_V2 0x09 | ||
45 | #define UAC_CLOCK_SOURCE 0x0a | ||
46 | #define UAC_CLOCK_SELECTOR 0x0b | ||
47 | #define UAC_CLOCK_MULTIPLIER 0x0c | ||
48 | #define UAC_SAMPLE_RATE_CONVERTER 0x0d | ||
49 | |||
50 | /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ | 45 | /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ |
51 | #define UAC_AS_GENERAL 0x01 | 46 | #define UAC_AS_GENERAL 0x01 |
52 | #define UAC_FORMAT_TYPE 0x02 | 47 | #define UAC_FORMAT_TYPE 0x02 |
@@ -78,10 +73,6 @@ | |||
78 | 73 | ||
79 | #define UAC_GET_STAT 0xff | 74 | #define UAC_GET_STAT 0xff |
80 | 75 | ||
81 | /* Audio class v2.0 handles all the parameter calls differently */ | ||
82 | #define UAC2_CS_CUR 0x01 | ||
83 | #define UAC2_CS_RANGE 0x02 | ||
84 | |||
85 | /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ | 76 | /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ |
86 | #define UAC_MS_HEADER 0x01 | 77 | #define UAC_MS_HEADER 0x01 |
87 | #define UAC_MIDI_IN_JACK 0x02 | 78 | #define UAC_MIDI_IN_JACK 0x02 |
@@ -190,6 +181,156 @@ struct uac_feature_unit_descriptor_##ch { \ | |||
190 | __u8 iFeature; \ | 181 | __u8 iFeature; \ |
191 | } __attribute__ ((packed)) | 182 | } __attribute__ ((packed)) |
192 | 183 | ||
184 | /* 4.3.2.3 Mixer Unit Descriptor */ | ||
185 | struct uac_mixer_unit_descriptor { | ||
186 | __u8 bLength; | ||
187 | __u8 bDescriptorType; | ||
188 | __u8 bDescriptorSubtype; | ||
189 | __u8 bUnitID; | ||
190 | __u8 bNrInPins; | ||
191 | __u8 baSourceID[]; | ||
192 | } __attribute__ ((packed)); | ||
193 | |||
194 | static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) | ||
195 | { | ||
196 | return desc->baSourceID[desc->bNrInPins]; | ||
197 | } | ||
198 | |||
199 | static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc, | ||
200 | int protocol) | ||
201 | { | ||
202 | if (protocol == UAC_VERSION_1) | ||
203 | return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
204 | desc->baSourceID[desc->bNrInPins + 1]; | ||
205 | else | ||
206 | return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | ||
207 | (desc->baSourceID[desc->bNrInPins + 3] << 16) | | ||
208 | (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
209 | (desc->baSourceID[desc->bNrInPins + 1]); | ||
210 | } | ||
211 | |||
212 | static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc, | ||
213 | int protocol) | ||
214 | { | ||
215 | return (protocol == UAC_VERSION_1) ? | ||
216 | desc->baSourceID[desc->bNrInPins + 3] : | ||
217 | desc->baSourceID[desc->bNrInPins + 5]; | ||
218 | } | ||
219 | |||
220 | static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc, | ||
221 | int protocol) | ||
222 | { | ||
223 | return (protocol == UAC_VERSION_1) ? | ||
224 | &desc->baSourceID[desc->bNrInPins + 4] : | ||
225 | &desc->baSourceID[desc->bNrInPins + 6]; | ||
226 | } | ||
227 | |||
228 | static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc) | ||
229 | { | ||
230 | __u8 *raw = (__u8 *) desc; | ||
231 | return raw[desc->bLength - 1]; | ||
232 | } | ||
233 | |||
234 | /* 4.3.2.4 Selector Unit Descriptor */ | ||
235 | struct uac_selector_unit_descriptor { | ||
236 | __u8 bLength; | ||
237 | __u8 bDescriptorType; | ||
238 | __u8 bDescriptorSubtype; | ||
239 | __u8 bUintID; | ||
240 | __u8 bNrInPins; | ||
241 | __u8 baSourceID[]; | ||
242 | } __attribute__ ((packed)); | ||
243 | |||
244 | static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) | ||
245 | { | ||
246 | __u8 *raw = (__u8 *) desc; | ||
247 | return raw[9 + desc->bLength - 1]; | ||
248 | } | ||
249 | |||
250 | /* 4.3.2.5 Feature Unit Descriptor */ | ||
251 | struct uac_feature_unit_descriptor { | ||
252 | __u8 bLength; | ||
253 | __u8 bDescriptorType; | ||
254 | __u8 bDescriptorSubtype; | ||
255 | __u8 bUnitID; | ||
256 | __u8 bSourceID; | ||
257 | __u8 bControlSize; | ||
258 | __u8 bmaControls[0]; /* variable length */ | ||
259 | } __attribute__((packed)); | ||
260 | |||
261 | static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) | ||
262 | { | ||
263 | __u8 *raw = (__u8 *) desc; | ||
264 | return raw[desc->bLength - 1]; | ||
265 | } | ||
266 | |||
267 | /* 4.3.2.6 Processing Unit Descriptors */ | ||
268 | struct uac_processing_unit_descriptor { | ||
269 | __u8 bLength; | ||
270 | __u8 bDescriptorType; | ||
271 | __u8 bDescriptorSubtype; | ||
272 | __u8 bUnitID; | ||
273 | __u16 wProcessType; | ||
274 | __u8 bNrInPins; | ||
275 | __u8 baSourceID[]; | ||
276 | } __attribute__ ((packed)); | ||
277 | |||
278 | static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) | ||
279 | { | ||
280 | return desc->baSourceID[desc->bNrInPins]; | ||
281 | } | ||
282 | |||
283 | static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc, | ||
284 | int protocol) | ||
285 | { | ||
286 | if (protocol == UAC_VERSION_1) | ||
287 | return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
288 | desc->baSourceID[desc->bNrInPins + 1]; | ||
289 | else | ||
290 | return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | ||
291 | (desc->baSourceID[desc->bNrInPins + 3] << 16) | | ||
292 | (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
293 | (desc->baSourceID[desc->bNrInPins + 1]); | ||
294 | } | ||
295 | |||
296 | static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc, | ||
297 | int protocol) | ||
298 | { | ||
299 | return (protocol == UAC_VERSION_1) ? | ||
300 | desc->baSourceID[desc->bNrInPins + 3] : | ||
301 | desc->baSourceID[desc->bNrInPins + 5]; | ||
302 | } | ||
303 | |||
304 | static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc, | ||
305 | int protocol) | ||
306 | { | ||
307 | return (protocol == UAC_VERSION_1) ? | ||
308 | desc->baSourceID[desc->bNrInPins + 4] : | ||
309 | desc->baSourceID[desc->bNrInPins + 6]; | ||
310 | } | ||
311 | |||
312 | static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc, | ||
313 | int protocol) | ||
314 | { | ||
315 | return (protocol == UAC_VERSION_1) ? | ||
316 | &desc->baSourceID[desc->bNrInPins + 5] : | ||
317 | &desc->baSourceID[desc->bNrInPins + 7]; | ||
318 | } | ||
319 | |||
320 | static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc, | ||
321 | int protocol) | ||
322 | { | ||
323 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | ||
324 | return desc->baSourceID[desc->bNrInPins + control_size]; | ||
325 | } | ||
326 | |||
327 | static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, | ||
328 | int protocol) | ||
329 | { | ||
330 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | ||
331 | return &desc->baSourceID[desc->bNrInPins + control_size + 1]; | ||
332 | } | ||
333 | |||
193 | /* 4.5.2 Class-Specific AS Interface Descriptor */ | 334 | /* 4.5.2 Class-Specific AS Interface Descriptor */ |
194 | struct uac_as_header_descriptor_v1 { | 335 | struct uac_as_header_descriptor_v1 { |
195 | __u8 bLength; /* in bytes: 7 */ | 336 | __u8 bLength; /* in bytes: 7 */ |
@@ -200,19 +341,6 @@ struct uac_as_header_descriptor_v1 { | |||
200 | __le16 wFormatTag; /* The Audio Data Format */ | 341 | __le16 wFormatTag; /* The Audio Data Format */ |
201 | } __attribute__ ((packed)); | 342 | } __attribute__ ((packed)); |
202 | 343 | ||
203 | struct uac_as_header_descriptor_v2 { | ||
204 | __u8 bLength; | ||
205 | __u8 bDescriptorType; | ||
206 | __u8 bDescriptorSubtype; | ||
207 | __u8 bTerminalLink; | ||
208 | __u8 bmControls; | ||
209 | __u8 bFormatType; | ||
210 | __u32 bmFormats; | ||
211 | __u8 bNrChannels; | ||
212 | __u32 bmChannelConfig; | ||
213 | __u8 iChannelNames; | ||
214 | } __attribute__((packed)); | ||
215 | |||
216 | #define UAC_DT_AS_HEADER_SIZE 7 | 344 | #define UAC_DT_AS_HEADER_SIZE 7 |
217 | 345 | ||
218 | /* Formats - A.1.1 Audio Data Format Type I Codes */ | 346 | /* Formats - A.1.1 Audio Data Format Type I Codes */ |
@@ -277,7 +405,6 @@ struct uac_format_type_i_ext_descriptor { | |||
277 | __u8 bSideBandProtocol; | 405 | __u8 bSideBandProtocol; |
278 | } __attribute__((packed)); | 406 | } __attribute__((packed)); |
279 | 407 | ||
280 | |||
281 | /* Formats - Audio Data Format Type I Codes */ | 408 | /* Formats - Audio Data Format Type I Codes */ |
282 | 409 | ||
283 | #define UAC_FORMAT_TYPE_II_MPEG 0x1001 | 410 | #define UAC_FORMAT_TYPE_II_MPEG 0x1001 |
@@ -329,38 +456,15 @@ struct uac_iso_endpoint_descriptor { | |||
329 | __u8 bmAttributes; | 456 | __u8 bmAttributes; |
330 | __u8 bLockDelayUnits; | 457 | __u8 bLockDelayUnits; |
331 | __le16 wLockDelay; | 458 | __le16 wLockDelay; |
332 | }; | 459 | } __attribute__((packed)); |
333 | #define UAC_ISO_ENDPOINT_DESC_SIZE 7 | 460 | #define UAC_ISO_ENDPOINT_DESC_SIZE 7 |
334 | 461 | ||
335 | #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 | 462 | #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 |
336 | #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 | 463 | #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 |
337 | #define UAC_EP_CS_ATTR_FILL_MAX 0x80 | 464 | #define UAC_EP_CS_ATTR_FILL_MAX 0x80 |
338 | 465 | ||
339 | /* Audio class v2.0: CLOCK_SOURCE descriptor */ | ||
340 | |||
341 | struct uac_clock_source_descriptor { | ||
342 | __u8 bLength; | ||
343 | __u8 bDescriptorType; | ||
344 | __u8 bDescriptorSubtype; | ||
345 | __u8 bClockID; | ||
346 | __u8 bmAttributes; | ||
347 | __u8 bmControls; | ||
348 | __u8 bAssocTerminal; | ||
349 | __u8 iClockSource; | ||
350 | } __attribute__((packed)); | ||
351 | |||
352 | /* A.10.2 Feature Unit Control Selectors */ | 466 | /* A.10.2 Feature Unit Control Selectors */ |
353 | 467 | ||
354 | struct uac_feature_unit_descriptor { | ||
355 | __u8 bLength; | ||
356 | __u8 bDescriptorType; | ||
357 | __u8 bDescriptorSubtype; | ||
358 | __u8 bUnitID; | ||
359 | __u8 bSourceID; | ||
360 | __u8 bControlSize; | ||
361 | __u8 controls[0]; /* variable length */ | ||
362 | } __attribute__((packed)); | ||
363 | |||
364 | #define UAC_FU_CONTROL_UNDEFINED 0x00 | 468 | #define UAC_FU_CONTROL_UNDEFINED 0x00 |
365 | #define UAC_MUTE_CONTROL 0x01 | 469 | #define UAC_MUTE_CONTROL 0x01 |
366 | #define UAC_VOLUME_CONTROL 0x02 | 470 | #define UAC_VOLUME_CONTROL 0x02 |
@@ -384,6 +488,21 @@ struct uac_feature_unit_descriptor { | |||
384 | #define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1)) | 488 | #define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1)) |
385 | #define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1)) | 489 | #define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1)) |
386 | 490 | ||
491 | /* status word format (3.7.1.1) */ | ||
492 | |||
493 | #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f | ||
494 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 | ||
495 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 | ||
496 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 | ||
497 | |||
498 | #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) | ||
499 | #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) | ||
500 | |||
501 | struct uac1_status_word { | ||
502 | __u8 bStatusType; | ||
503 | __u8 bOriginator; | ||
504 | } __attribute__((packed)); | ||
505 | |||
387 | #ifdef __KERNEL__ | 506 | #ifdef __KERNEL__ |
388 | 507 | ||
389 | struct usb_audio_control { | 508 | struct usb_audio_control { |