2 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de>
4 * This software is distributed under the terms of the GNU General Public
5 * License ("GPL") version 2, as published by the Free Software Foundation.
7 * This file holds USB constants and structures defined
8 * by the USB Device Class Definition for Audio Devices in version 2.0.
9 * Comments below reference relevant sections of the documents contained
10 * in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip
13 #ifndef __LINUX_USB_AUDIO_V2_H
14 #define __LINUX_USB_AUDIO_V2_H
16 #include <linux/types.h>
18 /* v1.0 and v2.0 of this standard have many things in common. For the rest
19 * of the definitions, please refer to audio.h */
22 * bmControl field decoders
24 * From the USB Audio spec v2.0:
26 * bmaControls() is a (ch+1)-element array of 4-byte bitmaps,
27 * each containing a set of bit pairs. If a Control is present,
28 * it must be Host readable. If a certain Control is not
29 * present then the bit pair must be set to 0b00.
30 * If a Control is present but read-only, the bit pair must be
31 * set to 0b01. If a Control is also Host programmable, the bit
32 * pair must be set to 0b11. The value 0b10 is not allowed.
36 static inline bool uac2_control_is_readable(u32 bmControls
, u8 control
)
38 return (bmControls
>> (control
* 2)) & 0x1;
41 static inline bool uac2_control_is_writeable(u32 bmControls
, u8 control
)
43 return (bmControls
>> (control
* 2)) & 0x2;
46 /* 4.7.2.1 Clock Source Descriptor */
48 struct uac_clock_source_descriptor
{
51 __u8 bDescriptorSubtype
;
57 } __attribute__((packed
));
59 /* bmAttribute fields */
60 #define UAC_CLOCK_SOURCE_TYPE_EXT 0x0
61 #define UAC_CLOCK_SOURCE_TYPE_INT_FIXED 0x1
62 #define UAC_CLOCK_SOURCE_TYPE_INT_VAR 0x2
63 #define UAC_CLOCK_SOURCE_TYPE_INT_PROG 0x3
64 #define UAC_CLOCK_SOURCE_SYNCED_TO_SOF (1 << 2)
66 /* 4.7.2.2 Clock Source Descriptor */
68 struct uac_clock_selector_descriptor
{
71 __u8 bDescriptorSubtype
;
75 /* bmControls, bAssocTerminal and iClockSource omitted */
76 } __attribute__((packed
));
78 /* 4.7.2.3 Clock Multiplier Descriptor */
80 struct uac_clock_multiplier_descriptor
{
83 __u8 bDescriptorSubtype
;
87 __u8 iClockMultiplier
;
88 } __attribute__((packed
));
90 /* 4.7.2.4 Input terminal descriptor */
92 struct uac2_input_terminal_descriptor
{
95 __u8 bDescriptorSubtype
;
101 __u32 bmChannelConfig
;
105 } __attribute__((packed
));
107 /* 4.7.2.5 Output terminal descriptor */
109 struct uac2_output_terminal_descriptor
{
111 __u8 bDescriptorType
;
112 __u8 bDescriptorSubtype
;
120 } __attribute__((packed
));
124 /* 4.7.2.8 Feature Unit Descriptor */
126 struct uac2_feature_unit_descriptor
{
128 __u8 bDescriptorType
;
129 __u8 bDescriptorSubtype
;
132 /* bmaControls is actually u32,
133 * but u8 is needed for the hybrid parser */
134 __u8 bmaControls
[0]; /* variable length */
135 } __attribute__((packed
));
137 /* 4.9.2 Class-Specific AS Interface Descriptor */
139 struct uac2_as_header_descriptor
{
141 __u8 bDescriptorType
;
142 __u8 bDescriptorSubtype
;
148 __u32 bmChannelConfig
;
150 } __attribute__((packed
));
152 /* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */
154 struct uac2_iso_endpoint_descriptor
{
155 __u8 bLength
; /* in bytes: 8 */
156 __u8 bDescriptorType
; /* USB_DT_CS_ENDPOINT */
157 __u8 bDescriptorSubtype
; /* EP_GENERAL */
160 __u8 bLockDelayUnits
;
162 } __attribute__((packed
));
164 #define UAC2_CONTROL_PITCH (3 << 0)
165 #define UAC2_CONTROL_DATA_OVERRUN (3 << 2)
166 #define UAC2_CONTROL_DATA_UNDERRUN (3 << 4)
168 /* 6.1 Interrupt Data Message */
170 #define UAC2_INTERRUPT_DATA_MSG_VENDOR (1 << 0)
171 #define UAC2_INTERRUPT_DATA_MSG_EP (1 << 1)
173 struct uac2_interrupt_data_msg
{
178 } __attribute__((packed
));
180 /* A.7 Audio Function Category Codes */
181 #define UAC2_FUNCTION_SUBCLASS_UNDEFINED 0x00
182 #define UAC2_FUNCTION_DESKTOP_SPEAKER 0x01
183 #define UAC2_FUNCTION_HOME_THEATER 0x02
184 #define UAC2_FUNCTION_MICROPHONE 0x03
185 #define UAC2_FUNCTION_HEADSET 0x04
186 #define UAC2_FUNCTION_TELEPHONE 0x05
187 #define UAC2_FUNCTION_CONVERTER 0x06
188 #define UAC2_FUNCTION_SOUND_RECORDER 0x07
189 #define UAC2_FUNCTION_IO_BOX 0x08
190 #define UAC2_FUNCTION_MUSICAL_INSTRUMENT 0x09
191 #define UAC2_FUNCTION_PRO_AUDIO 0x0a
192 #define UAC2_FUNCTION_AUDIO_VIDEO 0x0b
193 #define UAC2_FUNCTION_CONTROL_PANEL 0x0c
194 #define UAC2_FUNCTION_OTHER 0xff
196 /* A.9 Audio Class-Specific AC Interface Descriptor Subtypes */
197 /* see audio.h for the rest, which is identical to v1 */
198 #define UAC2_EFFECT_UNIT 0x07
199 #define UAC2_PROCESSING_UNIT_V2 0x08
200 #define UAC2_EXTENSION_UNIT_V2 0x09
201 #define UAC2_CLOCK_SOURCE 0x0a
202 #define UAC2_CLOCK_SELECTOR 0x0b
203 #define UAC2_CLOCK_MULTIPLIER 0x0c
204 #define UAC2_SAMPLE_RATE_CONVERTER 0x0d
206 /* A.10 Audio Class-Specific AS Interface Descriptor Subtypes */
207 /* see audio.h for the rest, which is identical to v1 */
208 #define UAC2_ENCODER 0x03
209 #define UAC2_DECODER 0x04
211 /* A.11 Effect Unit Effect Types */
212 #define UAC2_EFFECT_UNDEFINED 0x00
213 #define UAC2_EFFECT_PARAM_EQ 0x01
214 #define UAC2_EFFECT_REVERB 0x02
215 #define UAC2_EFFECT_MOD_DELAY 0x03
216 #define UAC2_EFFECT_DYN_RANGE_COMP 0x04
218 /* A.12 Processing Unit Process Types */
219 #define UAC2_PROCESS_UNDEFINED 0x00
220 #define UAC2_PROCESS_UP_DOWNMIX 0x01
221 #define UAC2_PROCESS_DOLBY_PROLOCIC 0x02
222 #define UAC2_PROCESS_STEREO_EXTENDER 0x03
224 /* A.14 Audio Class-Specific Request Codes */
225 #define UAC2_CS_CUR 0x01
226 #define UAC2_CS_RANGE 0x02
227 #define UAC2_CS_MEM 0x03
229 /* A.15 Encoder Type Codes */
230 #define UAC2_ENCODER_UNDEFINED 0x00
231 #define UAC2_ENCODER_OTHER 0x01
232 #define UAC2_ENCODER_MPEG 0x02
233 #define UAC2_ENCODER_AC3 0x03
234 #define UAC2_ENCODER_WMA 0x04
235 #define UAC2_ENCODER_DTS 0x05
237 /* A.16 Decoder Type Codes */
238 #define UAC2_DECODER_UNDEFINED 0x00
239 #define UAC2_DECODER_OTHER 0x01
240 #define UAC2_DECODER_MPEG 0x02
241 #define UAC2_DECODER_AC3 0x03
242 #define UAC2_DECODER_WMA 0x04
243 #define UAC2_DECODER_DTS 0x05
245 /* A.17.1 Clock Source Control Selectors */
246 #define UAC2_CS_UNDEFINED 0x00
247 #define UAC2_CS_CONTROL_SAM_FREQ 0x01
248 #define UAC2_CS_CONTROL_CLOCK_VALID 0x02
250 /* A.17.2 Clock Selector Control Selectors */
251 #define UAC2_CX_UNDEFINED 0x00
252 #define UAC2_CX_CLOCK_SELECTOR 0x01
254 /* A.17.3 Clock Multiplier Control Selectors */
255 #define UAC2_CM_UNDEFINED 0x00
256 #define UAC2_CM_NUMERATOR 0x01
257 #define UAC2_CM_DENOMINTATOR 0x02
259 /* A.17.4 Terminal Control Selectors */
260 #define UAC2_TE_UNDEFINED 0x00
261 #define UAC2_TE_COPY_PROTECT 0x01
262 #define UAC2_TE_CONNECTOR 0x02
263 #define UAC2_TE_OVERLOAD 0x03
264 #define UAC2_TE_CLUSTER 0x04
265 #define UAC2_TE_UNDERFLOW 0x05
266 #define UAC2_TE_OVERFLOW 0x06
267 #define UAC2_TE_LATENCY 0x07
269 /* A.17.5 Mixer Control Selectors */
270 #define UAC2_MU_UNDEFINED 0x00
271 #define UAC2_MU_MIXER 0x01
272 #define UAC2_MU_CLUSTER 0x02
273 #define UAC2_MU_UNDERFLOW 0x03
274 #define UAC2_MU_OVERFLOW 0x04
275 #define UAC2_MU_LATENCY 0x05
277 /* A.17.6 Selector Control Selectors */
278 #define UAC2_SU_UNDEFINED 0x00
279 #define UAC2_SU_SELECTOR 0x01
280 #define UAC2_SU_LATENCY 0x02
282 /* A.17.7 Feature Unit Control Selectors */
283 /* see audio.h for the rest, which is identical to v1 */
284 #define UAC2_FU_INPUT_GAIN 0x0b
285 #define UAC2_FU_INPUT_GAIN_PAD 0x0c
286 #define UAC2_FU_PHASE_INVERTER 0x0d
287 #define UAC2_FU_UNDERFLOW 0x0e
288 #define UAC2_FU_OVERFLOW 0x0f
289 #define UAC2_FU_LATENCY 0x10
291 /* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */
292 #define UAC2_PE_UNDEFINED 0x00
293 #define UAC2_PE_ENABLE 0x01
294 #define UAC2_PE_CENTERFREQ 0x02
295 #define UAC2_PE_QFACTOR 0x03
296 #define UAC2_PE_GAIN 0x04
297 #define UAC2_PE_UNDERFLOW 0x05
298 #define UAC2_PE_OVERFLOW 0x06
299 #define UAC2_PE_LATENCY 0x07
301 /* A.17.8.2 Reverberation Effect Unit Control Selectors */
302 #define UAC2_RV_UNDEFINED 0x00
303 #define UAC2_RV_ENABLE 0x01
304 #define UAC2_RV_TYPE 0x02
305 #define UAC2_RV_LEVEL 0x03
306 #define UAC2_RV_TIME 0x04
307 #define UAC2_RV_FEEDBACK 0x05
308 #define UAC2_RV_PREDELAY 0x06
309 #define UAC2_RV_DENSITY 0x07
310 #define UAC2_RV_HIFREQ_ROLLOFF 0x08
311 #define UAC2_RV_UNDERFLOW 0x09
312 #define UAC2_RV_OVERFLOW 0x0a
313 #define UAC2_RV_LATENCY 0x0b
315 /* A.17.8.3 Modulation Delay Effect Control Selectors */
316 #define UAC2_MD_UNDEFINED 0x00
317 #define UAC2_MD_ENABLE 0x01
318 #define UAC2_MD_BALANCE 0x02
319 #define UAC2_MD_RATE 0x03
320 #define UAC2_MD_DEPTH 0x04
321 #define UAC2_MD_TIME 0x05
322 #define UAC2_MD_FEEDBACK 0x06
323 #define UAC2_MD_UNDERFLOW 0x07
324 #define UAC2_MD_OVERFLOW 0x08
325 #define UAC2_MD_LATENCY 0x09
327 /* A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors */
328 #define UAC2_DR_UNDEFINED 0x00
329 #define UAC2_DR_ENABLE 0x01
330 #define UAC2_DR_COMPRESSION_RATE 0x02
331 #define UAC2_DR_MAXAMPL 0x03
332 #define UAC2_DR_THRESHOLD 0x04
333 #define UAC2_DR_ATTACK_TIME 0x05
334 #define UAC2_DR_RELEASE_TIME 0x06
335 #define UAC2_DR_UNDEFLOW 0x07
336 #define UAC2_DR_OVERFLOW 0x08
337 #define UAC2_DR_LATENCY 0x09
339 /* A.17.9.1 Up/Down-mix Processing Unit Control Selectors */
340 #define UAC2_UD_UNDEFINED 0x00
341 #define UAC2_UD_ENABLE 0x01
342 #define UAC2_UD_MODE_SELECT 0x02
343 #define UAC2_UD_CLUSTER 0x03
344 #define UAC2_UD_UNDERFLOW 0x04
345 #define UAC2_UD_OVERFLOW 0x05
346 #define UAC2_UD_LATENCY 0x06
348 /* A.17.9.2 Dolby Prologic[tm] Processing Unit Control Selectors */
349 #define UAC2_DP_UNDEFINED 0x00
350 #define UAC2_DP_ENABLE 0x01
351 #define UAC2_DP_MODE_SELECT 0x02
352 #define UAC2_DP_CLUSTER 0x03
353 #define UAC2_DP_UNDERFFLOW 0x04
354 #define UAC2_DP_OVERFLOW 0x05
355 #define UAC2_DP_LATENCY 0x06
357 /* A.17.9.3 Stereo Expander Processing Unit Control Selectors */
358 #define UAC2_ST_EXT_UNDEFINED 0x00
359 #define UAC2_ST_EXT_ENABLE 0x01
360 #define UAC2_ST_EXT_WIDTH 0x02
361 #define UAC2_ST_EXT_UNDEFLOW 0x03
362 #define UAC2_ST_EXT_OVERFLOW 0x04
363 #define UAC2_ST_EXT_LATENCY 0x05
365 /* A.17.10 Extension Unit Control Selectors */
366 #define UAC2_XU_UNDEFINED 0x00
367 #define UAC2_XU_ENABLE 0x01
368 #define UAC2_XU_CLUSTER 0x02
369 #define UAC2_XU_UNDERFLOW 0x03
370 #define UAC2_XU_OVERFLOW 0x04
371 #define UAC2_XU_LATENCY 0x05
373 /* A.17.11 AudioStreaming Interface Control Selectors */
374 #define UAC2_AS_UNDEFINED 0x00
375 #define UAC2_AS_ACT_ALT_SETTING 0x01
376 #define UAC2_AS_VAL_ALT_SETTINGS 0x02
377 #define UAC2_AS_AUDIO_DATA_FORMAT 0x03
379 /* A.17.12 Encoder Control Selectors */
380 #define UAC2_EN_UNDEFINED 0x00
381 #define UAC2_EN_BIT_RATE 0x01
382 #define UAC2_EN_QUALITY 0x02
383 #define UAC2_EN_VBR 0x03
384 #define UAC2_EN_TYPE 0x04
385 #define UAC2_EN_UNDERFLOW 0x05
386 #define UAC2_EN_OVERFLOW 0x06
387 #define UAC2_EN_ENCODER_ERROR 0x07
388 #define UAC2_EN_PARAM1 0x08
389 #define UAC2_EN_PARAM2 0x09
390 #define UAC2_EN_PARAM3 0x0a
391 #define UAC2_EN_PARAM4 0x0b
392 #define UAC2_EN_PARAM5 0x0c
393 #define UAC2_EN_PARAM6 0x0d
394 #define UAC2_EN_PARAM7 0x0e
395 #define UAC2_EN_PARAM8 0x0f
397 /* A.17.13.1 MPEG Decoder Control Selectors */
398 #define UAC2_MPEG_UNDEFINED 0x00
399 #define UAC2_MPEG_DUAL_CHANNEL 0x01
400 #define UAC2_MPEG_SECOND_STEREO 0x02
401 #define UAC2_MPEG_MULTILINGUAL 0x03
402 #define UAC2_MPEG_DYN_RANGE 0x04
403 #define UAC2_MPEG_SCALING 0x05
404 #define UAC2_MPEG_HILO_SCALING 0x06
405 #define UAC2_MPEG_UNDERFLOW 0x07
406 #define UAC2_MPEG_OVERFLOW 0x08
407 #define UAC2_MPEG_DECODER_ERROR 0x09
409 /* A17.13.2 AC3 Decoder Control Selectors */
410 #define UAC2_AC3_UNDEFINED 0x00
411 #define UAC2_AC3_MODE 0x01
412 #define UAC2_AC3_DYN_RANGE 0x02
413 #define UAC2_AC3_SCALING 0x03
414 #define UAC2_AC3_HILO_SCALING 0x04
415 #define UAC2_AC3_UNDERFLOW 0x05
416 #define UAC2_AC3_OVERFLOW 0x06
417 #define UAC2_AC3_DECODER_ERROR 0x07
419 /* A17.13.3 WMA Decoder Control Selectors */
420 #define UAC2_WMA_UNDEFINED 0x00
421 #define UAC2_WMA_UNDERFLOW 0x01
422 #define UAC2_WMA_OVERFLOW 0x02
423 #define UAC2_WMA_DECODER_ERROR 0x03
425 /* A17.13.4 DTS Decoder Control Selectors */
426 #define UAC2_DTS_UNDEFINED 0x00
427 #define UAC2_DTS_UNDERFLOW 0x01
428 #define UAC2_DTS_OVERFLOW 0x02
429 #define UAC2_DTS_DECODER_ERROR 0x03
431 /* A17.14 Endpoint Control Selectors */
432 #define UAC2_EP_CS_UNDEFINED 0x00
433 #define UAC2_EP_CS_PITCH 0x01
434 #define UAC2_EP_CS_DATA_OVERRUN 0x02
435 #define UAC2_EP_CS_DATA_UNDERRUN 0x03
437 #endif /* __LINUX_USB_AUDIO_V2_H */