1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de> 4 * 5 * This file holds USB constants and structures defined 6 * by the USB Device Class Definition for Audio Devices in version 2.0. 7 * Comments below reference relevant sections of the documents contained 8 * in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip 9 */ 10 11 #ifndef __LINUX_USB_AUDIO_V2_H 12 #define __LINUX_USB_AUDIO_V2_H 13 14 #include <linux/types.h> 15 16 /* v1.0 and v2.0 of this standard have many things in common. For the rest 17 * of the definitions, please refer to audio.h */ 18 19 /* 20 * bmControl field decoders 21 * 22 * From the USB Audio spec v2.0: 23 * 24 * bmaControls() is a (ch+1)-element array of 4-byte bitmaps, 25 * each containing a set of bit pairs. If a Control is present, 26 * it must be Host readable. If a certain Control is not 27 * present then the bit pair must be set to 0b00. 28 * If a Control is present but read-only, the bit pair must be 29 * set to 0b01. If a Control is also Host programmable, the bit 30 * pair must be set to 0b11. The value 0b10 is not allowed. 31 * 32 */ 33 34 static inline bool uac_v2v3_control_is_readable(u32 bmControls, u8 control) 35 { 36 return (bmControls >> ((control - 1) * 2)) & 0x1; 37 } 38 39 static inline bool uac_v2v3_control_is_writeable(u32 bmControls, u8 control) 40 { 41 return (bmControls >> ((control - 1) * 2)) & 0x2; 42 } 43 44 /* 4.7.2 Class-Specific AC Interface Descriptor */ 45 struct uac2_ac_header_descriptor { 46 __u8 bLength; /* 9 */ 47 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 48 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ 49 __le16 bcdADC; /* 0x0200 */ 50 __u8 bCategory; 51 __le16 wTotalLength; /* includes Unit and Terminal desc. */ 52 __u8 bmControls; 53 } __packed; 54 55 /* 2.3.1.6 Type I Format Type Descriptor (Frmts20 final.pdf)*/ 56 struct uac2_format_type_i_descriptor { 57 __u8 bLength; /* in bytes: 6 */ 58 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 59 __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 60 __u8 bFormatType; /* FORMAT_TYPE_1 */ 61 __u8 bSubslotSize; /* {1,2,3,4} */ 62 __u8 bBitResolution; 63 } __packed; 64 65 /* 4.7.2.1 Clock Source Descriptor */ 66 67 struct uac_clock_source_descriptor { 68 __u8 bLength; 69 __u8 bDescriptorType; 70 __u8 bDescriptorSubtype; 71 __u8 bClockID; 72 __u8 bmAttributes; 73 __u8 bmControls; 74 __u8 bAssocTerminal; 75 __u8 iClockSource; 76 } __attribute__((packed)); 77 78 /* bmAttribute fields */ 79 #define UAC_CLOCK_SOURCE_TYPE_EXT 0x0 80 #define UAC_CLOCK_SOURCE_TYPE_INT_FIXED 0x1 81 #define UAC_CLOCK_SOURCE_TYPE_INT_VAR 0x2 82 #define UAC_CLOCK_SOURCE_TYPE_INT_PROG 0x3 83 #define UAC_CLOCK_SOURCE_SYNCED_TO_SOF (1 << 2) 84 85 /* 4.7.2.2 Clock Selector Descriptor */ 86 87 struct uac_clock_selector_descriptor { 88 __u8 bLength; 89 __u8 bDescriptorType; 90 __u8 bDescriptorSubtype; 91 __u8 bClockID; 92 __u8 bNrInPins; 93 __u8 baCSourceID[]; 94 /* bmControls and iClockSelector omitted */ 95 } __attribute__((packed)); 96 97 /* 4.7.2.3 Clock Multiplier Descriptor */ 98 99 struct uac_clock_multiplier_descriptor { 100 __u8 bLength; 101 __u8 bDescriptorType; 102 __u8 bDescriptorSubtype; 103 __u8 bClockID; 104 __u8 bCSourceID; 105 __u8 bmControls; 106 __u8 iClockMultiplier; 107 } __attribute__((packed)); 108 109 /* 4.7.2.4 Input terminal descriptor */ 110 111 struct uac2_input_terminal_descriptor { 112 __u8 bLength; 113 __u8 bDescriptorType; 114 __u8 bDescriptorSubtype; 115 __u8 bTerminalID; 116 __le16 wTerminalType; 117 __u8 bAssocTerminal; 118 __u8 bCSourceID; 119 __u8 bNrChannels; 120 __le32 bmChannelConfig; 121 __u8 iChannelNames; 122 __le16 bmControls; 123 __u8 iTerminal; 124 } __attribute__((packed)); 125 126 /* 4.7.2.5 Output terminal descriptor */ 127 128 struct uac2_output_terminal_descriptor { 129 __u8 bLength; 130 __u8 bDescriptorType; 131 __u8 bDescriptorSubtype; 132 __u8 bTerminalID; 133 __le16 wTerminalType; 134 __u8 bAssocTerminal; 135 __u8 bSourceID; 136 __u8 bCSourceID; 137 __le16 bmControls; 138 __u8 iTerminal; 139 } __attribute__((packed)); 140 141 142 143 /* 4.7.2.8 Feature Unit Descriptor */ 144 145 struct uac2_feature_unit_descriptor { 146 __u8 bLength; 147 __u8 bDescriptorType; 148 __u8 bDescriptorSubtype; 149 __u8 bUnitID; 150 __u8 bSourceID; 151 /* bmaControls is actually u32, 152 * but u8 is needed for the hybrid parser */ 153 __u8 bmaControls[]; /* variable length */ 154 } __attribute__((packed)); 155 156 #define UAC2_DT_FEATURE_UNIT_SIZE(ch) (6 + ((ch) + 1) * 4) 157 158 /* As above, but more useful for defining your own descriptors: */ 159 #define DECLARE_UAC2_FEATURE_UNIT_DESCRIPTOR(ch) \ 160 struct uac2_feature_unit_descriptor_##ch { \ 161 __u8 bLength; \ 162 __u8 bDescriptorType; \ 163 __u8 bDescriptorSubtype; \ 164 __u8 bUnitID; \ 165 __u8 bSourceID; \ 166 __le32 bmaControls[ch + 1]; \ 167 __u8 iFeature; \ 168 } __packed 169 170 /* 4.7.2.10 Effect Unit Descriptor */ 171 172 struct uac2_effect_unit_descriptor { 173 __u8 bLength; 174 __u8 bDescriptorType; 175 __u8 bDescriptorSubtype; 176 __u8 bUnitID; 177 __le16 wEffectType; 178 __u8 bSourceID; 179 __u8 bmaControls[]; /* variable length */ 180 } __attribute__((packed)); 181 182 /* 4.9.2 Class-Specific AS Interface Descriptor */ 183 184 struct uac2_as_header_descriptor { 185 __u8 bLength; 186 __u8 bDescriptorType; 187 __u8 bDescriptorSubtype; 188 __u8 bTerminalLink; 189 __u8 bmControls; 190 __u8 bFormatType; 191 __le32 bmFormats; 192 __u8 bNrChannels; 193 __le32 bmChannelConfig; 194 __u8 iChannelNames; 195 } __attribute__((packed)); 196 197 #define UAC2_FORMAT_TYPE_I_RAW_DATA (1 << 31) 198 199 /* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */ 200 201 struct uac2_iso_endpoint_descriptor { 202 __u8 bLength; /* in bytes: 8 */ 203 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ 204 __u8 bDescriptorSubtype; /* EP_GENERAL */ 205 __u8 bmAttributes; 206 __u8 bmControls; 207 __u8 bLockDelayUnits; 208 __le16 wLockDelay; 209 } __attribute__((packed)); 210 211 #define UAC2_CONTROL_PITCH (3 << 0) 212 #define UAC2_CONTROL_DATA_OVERRUN (3 << 2) 213 #define UAC2_CONTROL_DATA_UNDERRUN (3 << 4) 214 215 /* 5.2.5.4.2 Connector Control Parameter Block */ 216 struct uac2_connectors_ctl_blk { 217 __u8 bNrChannels; 218 __le32 bmChannelConfig; 219 __u8 iChannelNames; 220 } __attribute__((packed)); 221 222 /* 6.1 Interrupt Data Message */ 223 224 #define UAC2_INTERRUPT_DATA_MSG_VENDOR (1 << 0) 225 #define UAC2_INTERRUPT_DATA_MSG_EP (1 << 1) 226 227 struct uac2_interrupt_data_msg { 228 __u8 bInfo; 229 __u8 bAttribute; 230 __le16 wValue; 231 __le16 wIndex; 232 } __attribute__((packed)); 233 234 /* A.7 Audio Function Category Codes */ 235 #define UAC2_FUNCTION_SUBCLASS_UNDEFINED 0x00 236 #define UAC2_FUNCTION_DESKTOP_SPEAKER 0x01 237 #define UAC2_FUNCTION_HOME_THEATER 0x02 238 #define UAC2_FUNCTION_MICROPHONE 0x03 239 #define UAC2_FUNCTION_HEADSET 0x04 240 #define UAC2_FUNCTION_TELEPHONE 0x05 241 #define UAC2_FUNCTION_CONVERTER 0x06 242 #define UAC2_FUNCTION_SOUND_RECORDER 0x07 243 #define UAC2_FUNCTION_IO_BOX 0x08 244 #define UAC2_FUNCTION_MUSICAL_INSTRUMENT 0x09 245 #define UAC2_FUNCTION_PRO_AUDIO 0x0a 246 #define UAC2_FUNCTION_AUDIO_VIDEO 0x0b 247 #define UAC2_FUNCTION_CONTROL_PANEL 0x0c 248 #define UAC2_FUNCTION_OTHER 0xff 249 250 /* A.9 Audio Class-Specific AC Interface Descriptor Subtypes */ 251 /* see audio.h for the rest, which is identical to v1 */ 252 #define UAC2_EFFECT_UNIT 0x07 253 #define UAC2_PROCESSING_UNIT_V2 0x08 254 #define UAC2_EXTENSION_UNIT_V2 0x09 255 #define UAC2_CLOCK_SOURCE 0x0a 256 #define UAC2_CLOCK_SELECTOR 0x0b 257 #define UAC2_CLOCK_MULTIPLIER 0x0c 258 #define UAC2_SAMPLE_RATE_CONVERTER 0x0d 259 260 /* A.10 Audio Class-Specific AS Interface Descriptor Subtypes */ 261 /* see audio.h for the rest, which is identical to v1 */ 262 #define UAC2_ENCODER 0x03 263 #define UAC2_DECODER 0x04 264 265 /* A.11 Effect Unit Effect Types */ 266 #define UAC2_EFFECT_UNDEFINED 0x00 267 #define UAC2_EFFECT_PARAM_EQ 0x01 268 #define UAC2_EFFECT_REVERB 0x02 269 #define UAC2_EFFECT_MOD_DELAY 0x03 270 #define UAC2_EFFECT_DYN_RANGE_COMP 0x04 271 272 /* A.12 Processing Unit Process Types */ 273 #define UAC2_PROCESS_UNDEFINED 0x00 274 #define UAC2_PROCESS_UP_DOWNMIX 0x01 275 #define UAC2_PROCESS_DOLBY_PROLOCIC 0x02 276 #define UAC2_PROCESS_STEREO_EXTENDER 0x03 277 278 /* A.14 Audio Class-Specific Request Codes */ 279 #define UAC2_CS_CUR 0x01 280 #define UAC2_CS_RANGE 0x02 281 #define UAC2_CS_MEM 0x03 282 283 /* A.15 Encoder Type Codes */ 284 #define UAC2_ENCODER_UNDEFINED 0x00 285 #define UAC2_ENCODER_OTHER 0x01 286 #define UAC2_ENCODER_MPEG 0x02 287 #define UAC2_ENCODER_AC3 0x03 288 #define UAC2_ENCODER_WMA 0x04 289 #define UAC2_ENCODER_DTS 0x05 290 291 /* A.16 Decoder Type Codes */ 292 #define UAC2_DECODER_UNDEFINED 0x00 293 #define UAC2_DECODER_OTHER 0x01 294 #define UAC2_DECODER_MPEG 0x02 295 #define UAC2_DECODER_AC3 0x03 296 #define UAC2_DECODER_WMA 0x04 297 #define UAC2_DECODER_DTS 0x05 298 299 /* A.17.1 Clock Source Control Selectors */ 300 #define UAC2_CS_UNDEFINED 0x00 301 #define UAC2_CS_CONTROL_SAM_FREQ 0x01 302 #define UAC2_CS_CONTROL_CLOCK_VALID 0x02 303 304 /* A.17.2 Clock Selector Control Selectors */ 305 #define UAC2_CX_UNDEFINED 0x00 306 #define UAC2_CX_CLOCK_SELECTOR 0x01 307 308 /* A.17.3 Clock Multiplier Control Selectors */ 309 #define UAC2_CM_UNDEFINED 0x00 310 #define UAC2_CM_NUMERATOR 0x01 311 #define UAC2_CM_DENOMINTATOR 0x02 312 313 /* A.17.4 Terminal Control Selectors */ 314 #define UAC2_TE_UNDEFINED 0x00 315 #define UAC2_TE_COPY_PROTECT 0x01 316 #define UAC2_TE_CONNECTOR 0x02 317 #define UAC2_TE_OVERLOAD 0x03 318 #define UAC2_TE_CLUSTER 0x04 319 #define UAC2_TE_UNDERFLOW 0x05 320 #define UAC2_TE_OVERFLOW 0x06 321 #define UAC2_TE_LATENCY 0x07 322 323 /* A.17.5 Mixer Control Selectors */ 324 #define UAC2_MU_UNDEFINED 0x00 325 #define UAC2_MU_MIXER 0x01 326 #define UAC2_MU_CLUSTER 0x02 327 #define UAC2_MU_UNDERFLOW 0x03 328 #define UAC2_MU_OVERFLOW 0x04 329 #define UAC2_MU_LATENCY 0x05 330 331 /* A.17.6 Selector Control Selectors */ 332 #define UAC2_SU_UNDEFINED 0x00 333 #define UAC2_SU_SELECTOR 0x01 334 #define UAC2_SU_LATENCY 0x02 335 336 /* A.17.7 Feature Unit Control Selectors */ 337 /* see audio.h for the rest, which is identical to v1 */ 338 #define UAC2_FU_INPUT_GAIN 0x0b 339 #define UAC2_FU_INPUT_GAIN_PAD 0x0c 340 #define UAC2_FU_PHASE_INVERTER 0x0d 341 #define UAC2_FU_UNDERFLOW 0x0e 342 #define UAC2_FU_OVERFLOW 0x0f 343 #define UAC2_FU_LATENCY 0x10 344 345 /* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */ 346 #define UAC2_PE_UNDEFINED 0x00 347 #define UAC2_PE_ENABLE 0x01 348 #define UAC2_PE_CENTERFREQ 0x02 349 #define UAC2_PE_QFACTOR 0x03 350 #define UAC2_PE_GAIN 0x04 351 #define UAC2_PE_UNDERFLOW 0x05 352 #define UAC2_PE_OVERFLOW 0x06 353 #define UAC2_PE_LATENCY 0x07 354 355 /* A.17.8.2 Reverberation Effect Unit Control Selectors */ 356 #define UAC2_RV_UNDEFINED 0x00 357 #define UAC2_RV_ENABLE 0x01 358 #define UAC2_RV_TYPE 0x02 359 #define UAC2_RV_LEVEL 0x03 360 #define UAC2_RV_TIME 0x04 361 #define UAC2_RV_FEEDBACK 0x05 362 #define UAC2_RV_PREDELAY 0x06 363 #define UAC2_RV_DENSITY 0x07 364 #define UAC2_RV_HIFREQ_ROLLOFF 0x08 365 #define UAC2_RV_UNDERFLOW 0x09 366 #define UAC2_RV_OVERFLOW 0x0a 367 #define UAC2_RV_LATENCY 0x0b 368 369 /* A.17.8.3 Modulation Delay Effect Control Selectors */ 370 #define UAC2_MD_UNDEFINED 0x00 371 #define UAC2_MD_ENABLE 0x01 372 #define UAC2_MD_BALANCE 0x02 373 #define UAC2_MD_RATE 0x03 374 #define UAC2_MD_DEPTH 0x04 375 #define UAC2_MD_TIME 0x05 376 #define UAC2_MD_FEEDBACK 0x06 377 #define UAC2_MD_UNDERFLOW 0x07 378 #define UAC2_MD_OVERFLOW 0x08 379 #define UAC2_MD_LATENCY 0x09 380 381 /* A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors */ 382 #define UAC2_DR_UNDEFINED 0x00 383 #define UAC2_DR_ENABLE 0x01 384 #define UAC2_DR_COMPRESSION_RATE 0x02 385 #define UAC2_DR_MAXAMPL 0x03 386 #define UAC2_DR_THRESHOLD 0x04 387 #define UAC2_DR_ATTACK_TIME 0x05 388 #define UAC2_DR_RELEASE_TIME 0x06 389 #define UAC2_DR_UNDEFLOW 0x07 390 #define UAC2_DR_OVERFLOW 0x08 391 #define UAC2_DR_LATENCY 0x09 392 393 /* A.17.9.1 Up/Down-mix Processing Unit Control Selectors */ 394 #define UAC2_UD_UNDEFINED 0x00 395 #define UAC2_UD_ENABLE 0x01 396 #define UAC2_UD_MODE_SELECT 0x02 397 #define UAC2_UD_CLUSTER 0x03 398 #define UAC2_UD_UNDERFLOW 0x04 399 #define UAC2_UD_OVERFLOW 0x05 400 #define UAC2_UD_LATENCY 0x06 401 402 /* A.17.9.2 Dolby Prologic[tm] Processing Unit Control Selectors */ 403 #define UAC2_DP_UNDEFINED 0x00 404 #define UAC2_DP_ENABLE 0x01 405 #define UAC2_DP_MODE_SELECT 0x02 406 #define UAC2_DP_CLUSTER 0x03 407 #define UAC2_DP_UNDERFFLOW 0x04 408 #define UAC2_DP_OVERFLOW 0x05 409 #define UAC2_DP_LATENCY 0x06 410 411 /* A.17.9.3 Stereo Expander Processing Unit Control Selectors */ 412 #define UAC2_ST_EXT_UNDEFINED 0x00 413 #define UAC2_ST_EXT_ENABLE 0x01 414 #define UAC2_ST_EXT_WIDTH 0x02 415 #define UAC2_ST_EXT_UNDEFLOW 0x03 416 #define UAC2_ST_EXT_OVERFLOW 0x04 417 #define UAC2_ST_EXT_LATENCY 0x05 418 419 /* A.17.10 Extension Unit Control Selectors */ 420 #define UAC2_XU_UNDEFINED 0x00 421 #define UAC2_XU_ENABLE 0x01 422 #define UAC2_XU_CLUSTER 0x02 423 #define UAC2_XU_UNDERFLOW 0x03 424 #define UAC2_XU_OVERFLOW 0x04 425 #define UAC2_XU_LATENCY 0x05 426 427 /* A.17.11 AudioStreaming Interface Control Selectors */ 428 #define UAC2_AS_UNDEFINED 0x00 429 #define UAC2_AS_ACT_ALT_SETTING 0x01 430 #define UAC2_AS_VAL_ALT_SETTINGS 0x02 431 #define UAC2_AS_AUDIO_DATA_FORMAT 0x03 432 433 /* A.17.12 Encoder Control Selectors */ 434 #define UAC2_EN_UNDEFINED 0x00 435 #define UAC2_EN_BIT_RATE 0x01 436 #define UAC2_EN_QUALITY 0x02 437 #define UAC2_EN_VBR 0x03 438 #define UAC2_EN_TYPE 0x04 439 #define UAC2_EN_UNDERFLOW 0x05 440 #define UAC2_EN_OVERFLOW 0x06 441 #define UAC2_EN_ENCODER_ERROR 0x07 442 #define UAC2_EN_PARAM1 0x08 443 #define UAC2_EN_PARAM2 0x09 444 #define UAC2_EN_PARAM3 0x0a 445 #define UAC2_EN_PARAM4 0x0b 446 #define UAC2_EN_PARAM5 0x0c 447 #define UAC2_EN_PARAM6 0x0d 448 #define UAC2_EN_PARAM7 0x0e 449 #define UAC2_EN_PARAM8 0x0f 450 451 /* A.17.13.1 MPEG Decoder Control Selectors */ 452 #define UAC2_MPEG_UNDEFINED 0x00 453 #define UAC2_MPEG_DUAL_CHANNEL 0x01 454 #define UAC2_MPEG_SECOND_STEREO 0x02 455 #define UAC2_MPEG_MULTILINGUAL 0x03 456 #define UAC2_MPEG_DYN_RANGE 0x04 457 #define UAC2_MPEG_SCALING 0x05 458 #define UAC2_MPEG_HILO_SCALING 0x06 459 #define UAC2_MPEG_UNDERFLOW 0x07 460 #define UAC2_MPEG_OVERFLOW 0x08 461 #define UAC2_MPEG_DECODER_ERROR 0x09 462 463 /* A17.13.2 AC3 Decoder Control Selectors */ 464 #define UAC2_AC3_UNDEFINED 0x00 465 #define UAC2_AC3_MODE 0x01 466 #define UAC2_AC3_DYN_RANGE 0x02 467 #define UAC2_AC3_SCALING 0x03 468 #define UAC2_AC3_HILO_SCALING 0x04 469 #define UAC2_AC3_UNDERFLOW 0x05 470 #define UAC2_AC3_OVERFLOW 0x06 471 #define UAC2_AC3_DECODER_ERROR 0x07 472 473 /* A17.13.3 WMA Decoder Control Selectors */ 474 #define UAC2_WMA_UNDEFINED 0x00 475 #define UAC2_WMA_UNDERFLOW 0x01 476 #define UAC2_WMA_OVERFLOW 0x02 477 #define UAC2_WMA_DECODER_ERROR 0x03 478 479 /* A17.13.4 DTS Decoder Control Selectors */ 480 #define UAC2_DTS_UNDEFINED 0x00 481 #define UAC2_DTS_UNDERFLOW 0x01 482 #define UAC2_DTS_OVERFLOW 0x02 483 #define UAC2_DTS_DECODER_ERROR 0x03 484 485 /* A17.14 Endpoint Control Selectors */ 486 #define UAC2_EP_CS_UNDEFINED 0x00 487 #define UAC2_EP_CS_PITCH 0x01 488 #define UAC2_EP_CS_DATA_OVERRUN 0x02 489 #define UAC2_EP_CS_DATA_UNDERRUN 0x03 490 491 #endif /* __LINUX_USB_AUDIO_V2_H */ 492 493
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.