audio.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * <linux/usb/audio.h> -- USB Audio definitions.
  4. *
  5. * Copyright (C) 2006 Thumtronics Pty Ltd.
  6. * Developed for Thumtronics by Grey Innovation
  7. * Ben Williamson <[email protected]>
  8. *
  9. * This software is distributed under the terms of the GNU General Public
  10. * License ("GPL") version 2, as published by the Free Software Foundation.
  11. *
  12. * This file holds USB constants and structures defined
  13. * by the USB Device Class Definition for Audio Devices.
  14. * Comments below reference relevant sections of that document:
  15. *
  16. * http://www.usb.org/developers/devclass_docs/audio10.pdf
  17. *
  18. * Types and defines in this file are either specific to version 1.0 of
  19. * this standard or common for newer versions.
  20. */
  21. #ifndef _UAPI__LINUX_USB_AUDIO_H
  22. #define _UAPI__LINUX_USB_AUDIO_H
  23. #include <linux/types.h>
  24. /* bInterfaceProtocol values to denote the version of the standard used */
  25. #define UAC_VERSION_1 0x00
  26. #define UAC_VERSION_2 0x20
  27. #define UAC_VERSION_3 0x30
  28. /* A.2 Audio Interface Subclass Codes */
  29. #define USB_SUBCLASS_AUDIOCONTROL 0x01
  30. #define USB_SUBCLASS_AUDIOSTREAMING 0x02
  31. #define USB_SUBCLASS_MIDISTREAMING 0x03
  32. /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
  33. #define UAC_HEADER 0x01
  34. #define UAC_INPUT_TERMINAL 0x02
  35. #define UAC_OUTPUT_TERMINAL 0x03
  36. #define UAC_MIXER_UNIT 0x04
  37. #define UAC_SELECTOR_UNIT 0x05
  38. #define UAC_FEATURE_UNIT 0x06
  39. #define UAC1_PROCESSING_UNIT 0x07
  40. #define UAC1_EXTENSION_UNIT 0x08
  41. /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
  42. #define UAC_AS_GENERAL 0x01
  43. #define UAC_FORMAT_TYPE 0x02
  44. #define UAC_FORMAT_SPECIFIC 0x03
  45. /* A.7 Processing Unit Process Types */
  46. #define UAC_PROCESS_UNDEFINED 0x00
  47. #define UAC_PROCESS_UP_DOWNMIX 0x01
  48. #define UAC_PROCESS_DOLBY_PROLOGIC 0x02
  49. #define UAC_PROCESS_STEREO_EXTENDER 0x03
  50. #define UAC_PROCESS_REVERB 0x04
  51. #define UAC_PROCESS_CHORUS 0x05
  52. #define UAC_PROCESS_DYN_RANGE_COMP 0x06
  53. /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
  54. #define UAC_EP_GENERAL 0x01
  55. /* A.9 Audio Class-Specific Request Codes */
  56. #define UAC_SET_ 0x00
  57. #define UAC_GET_ 0x80
  58. #define UAC__CUR 0x1
  59. #define UAC__MIN 0x2
  60. #define UAC__MAX 0x3
  61. #define UAC__RES 0x4
  62. #define UAC__MEM 0x5
  63. #define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
  64. #define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
  65. #define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
  66. #define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
  67. #define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
  68. #define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
  69. #define UAC_SET_RES (UAC_SET_ | UAC__RES)
  70. #define UAC_GET_RES (UAC_GET_ | UAC__RES)
  71. #define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
  72. #define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
  73. #define UAC_GET_STAT 0xff
  74. /* A.10 Control Selector Codes */
  75. /* A.10.1 Terminal Control Selectors */
  76. #define UAC_TERM_COPY_PROTECT 0x01
  77. /* A.10.2 Feature Unit Control Selectors */
  78. #define UAC_FU_MUTE 0x01
  79. #define UAC_FU_VOLUME 0x02
  80. #define UAC_FU_BASS 0x03
  81. #define UAC_FU_MID 0x04
  82. #define UAC_FU_TREBLE 0x05
  83. #define UAC_FU_GRAPHIC_EQUALIZER 0x06
  84. #define UAC_FU_AUTOMATIC_GAIN 0x07
  85. #define UAC_FU_DELAY 0x08
  86. #define UAC_FU_BASS_BOOST 0x09
  87. #define UAC_FU_LOUDNESS 0x0a
  88. #define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
  89. /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
  90. #define UAC_UD_ENABLE 0x01
  91. #define UAC_UD_MODE_SELECT 0x02
  92. /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
  93. #define UAC_DP_ENABLE 0x01
  94. #define UAC_DP_MODE_SELECT 0x02
  95. /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
  96. #define UAC_3D_ENABLE 0x01
  97. #define UAC_3D_SPACE 0x02
  98. /* A.10.3.4 Reverberation Processing Unit Control Selectors */
  99. #define UAC_REVERB_ENABLE 0x01
  100. #define UAC_REVERB_LEVEL 0x02
  101. #define UAC_REVERB_TIME 0x03
  102. #define UAC_REVERB_FEEDBACK 0x04
  103. /* A.10.3.5 Chorus Processing Unit Control Selectors */
  104. #define UAC_CHORUS_ENABLE 0x01
  105. #define UAC_CHORUS_LEVEL 0x02
  106. #define UAC_CHORUS_RATE 0x03
  107. #define UAC_CHORUS_DEPTH 0x04
  108. /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
  109. #define UAC_DCR_ENABLE 0x01
  110. #define UAC_DCR_RATE 0x02
  111. #define UAC_DCR_MAXAMPL 0x03
  112. #define UAC_DCR_THRESHOLD 0x04
  113. #define UAC_DCR_ATTACK_TIME 0x05
  114. #define UAC_DCR_RELEASE_TIME 0x06
  115. /* A.10.4 Extension Unit Control Selectors */
  116. #define UAC_XU_ENABLE 0x01
  117. /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
  118. #define UAC_MS_HEADER 0x01
  119. #define UAC_MIDI_IN_JACK 0x02
  120. #define UAC_MIDI_OUT_JACK 0x03
  121. /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
  122. #define UAC_MS_GENERAL 0x01
  123. /* Terminals - 2.1 USB Terminal Types */
  124. #define UAC_TERMINAL_UNDEFINED 0x100
  125. #define UAC_TERMINAL_STREAMING 0x101
  126. #define UAC_TERMINAL_VENDOR_SPEC 0x1FF
  127. /* Terminal Control Selectors */
  128. /* 4.3.2 Class-Specific AC Interface Descriptor */
  129. struct uac1_ac_header_descriptor {
  130. __u8 bLength; /* 8 + n */
  131. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  132. __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
  133. __le16 bcdADC; /* 0x0100 */
  134. __le16 wTotalLength; /* includes Unit and Terminal desc. */
  135. __u8 bInCollection; /* n */
  136. __u8 baInterfaceNr[]; /* [n] */
  137. } __attribute__ ((packed));
  138. #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
  139. /* As above, but more useful for defining your own descriptors: */
  140. #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
  141. struct uac1_ac_header_descriptor_##n { \
  142. __u8 bLength; \
  143. __u8 bDescriptorType; \
  144. __u8 bDescriptorSubtype; \
  145. __le16 bcdADC; \
  146. __le16 wTotalLength; \
  147. __u8 bInCollection; \
  148. __u8 baInterfaceNr[n]; \
  149. } __attribute__ ((packed))
  150. /* 4.3.2.1 Input Terminal Descriptor */
  151. struct uac_input_terminal_descriptor {
  152. __u8 bLength; /* in bytes: 12 */
  153. __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
  154. __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
  155. __u8 bTerminalID; /* Constant uniquely terminal ID */
  156. __le16 wTerminalType; /* USB Audio Terminal Types */
  157. __u8 bAssocTerminal; /* ID of the Output Terminal associated */
  158. __u8 bNrChannels; /* Number of logical output channels */
  159. __le16 wChannelConfig;
  160. __u8 iChannelNames;
  161. __u8 iTerminal;
  162. } __attribute__ ((packed));
  163. #define UAC_DT_INPUT_TERMINAL_SIZE 12
  164. /* Terminals - 2.2 Input Terminal Types */
  165. #define UAC_INPUT_TERMINAL_UNDEFINED 0x200
  166. #define UAC_INPUT_TERMINAL_MICROPHONE 0x201
  167. #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
  168. #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
  169. #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
  170. #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
  171. #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
  172. /* Terminals - control selectors */
  173. #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
  174. /* 4.3.2.2 Output Terminal Descriptor */
  175. struct uac1_output_terminal_descriptor {
  176. __u8 bLength; /* in bytes: 9 */
  177. __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
  178. __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
  179. __u8 bTerminalID; /* Constant uniquely terminal ID */
  180. __le16 wTerminalType; /* USB Audio Terminal Types */
  181. __u8 bAssocTerminal; /* ID of the Input Terminal associated */
  182. __u8 bSourceID; /* ID of the connected Unit or Terminal*/
  183. __u8 iTerminal;
  184. } __attribute__ ((packed));
  185. #define UAC_DT_OUTPUT_TERMINAL_SIZE 9
  186. /* Terminals - 2.3 Output Terminal Types */
  187. #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
  188. #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
  189. #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
  190. #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
  191. #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
  192. #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
  193. #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
  194. #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
  195. /* Terminals - 2.4 Bi-directional Terminal Types */
  196. #define UAC_BIDIR_TERMINAL_UNDEFINED 0x400
  197. #define UAC_BIDIR_TERMINAL_HANDSET 0x401
  198. #define UAC_BIDIR_TERMINAL_HEADSET 0x402
  199. #define UAC_BIDIR_TERMINAL_SPEAKER_PHONE 0x403
  200. #define UAC_BIDIR_TERMINAL_ECHO_SUPPRESSING 0x404
  201. #define UAC_BIDIR_TERMINAL_ECHO_CANCELING 0x405
  202. /* Set bControlSize = 2 as default setting */
  203. #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
  204. /* As above, but more useful for defining your own descriptors: */
  205. #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
  206. struct uac_feature_unit_descriptor_##ch { \
  207. __u8 bLength; \
  208. __u8 bDescriptorType; \
  209. __u8 bDescriptorSubtype; \
  210. __u8 bUnitID; \
  211. __u8 bSourceID; \
  212. __u8 bControlSize; \
  213. __le16 bmaControls[ch + 1]; \
  214. __u8 iFeature; \
  215. } __attribute__ ((packed))
  216. /* 4.3.2.3 Mixer Unit Descriptor */
  217. struct uac_mixer_unit_descriptor {
  218. __u8 bLength;
  219. __u8 bDescriptorType;
  220. __u8 bDescriptorSubtype;
  221. __u8 bUnitID;
  222. __u8 bNrInPins;
  223. __u8 baSourceID[];
  224. } __attribute__ ((packed));
  225. static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
  226. {
  227. return desc->baSourceID[desc->bNrInPins];
  228. }
  229. static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
  230. int protocol)
  231. {
  232. if (protocol == UAC_VERSION_1)
  233. return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
  234. desc->baSourceID[desc->bNrInPins + 1];
  235. else
  236. return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
  237. (desc->baSourceID[desc->bNrInPins + 3] << 16) |
  238. (desc->baSourceID[desc->bNrInPins + 2] << 8) |
  239. (desc->baSourceID[desc->bNrInPins + 1]);
  240. }
  241. static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
  242. int protocol)
  243. {
  244. return (protocol == UAC_VERSION_1) ?
  245. desc->baSourceID[desc->bNrInPins + 3] :
  246. desc->baSourceID[desc->bNrInPins + 5];
  247. }
  248. static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
  249. int protocol)
  250. {
  251. switch (protocol) {
  252. case UAC_VERSION_1:
  253. return &desc->baSourceID[desc->bNrInPins + 4];
  254. case UAC_VERSION_2:
  255. return &desc->baSourceID[desc->bNrInPins + 6];
  256. case UAC_VERSION_3:
  257. return &desc->baSourceID[desc->bNrInPins + 2];
  258. default:
  259. return NULL;
  260. }
  261. }
  262. static inline __u16 uac3_mixer_unit_wClusterDescrID(struct uac_mixer_unit_descriptor *desc)
  263. {
  264. return (desc->baSourceID[desc->bNrInPins + 1] << 8) |
  265. desc->baSourceID[desc->bNrInPins];
  266. }
  267. static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
  268. {
  269. __u8 *raw = (__u8 *) desc;
  270. return raw[desc->bLength - 1];
  271. }
  272. /* 4.3.2.4 Selector Unit Descriptor */
  273. struct uac_selector_unit_descriptor {
  274. __u8 bLength;
  275. __u8 bDescriptorType;
  276. __u8 bDescriptorSubtype;
  277. __u8 bUintID;
  278. __u8 bNrInPins;
  279. __u8 baSourceID[];
  280. } __attribute__ ((packed));
  281. static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
  282. {
  283. __u8 *raw = (__u8 *) desc;
  284. return raw[desc->bLength - 1];
  285. }
  286. /* 4.3.2.5 Feature Unit Descriptor */
  287. struct uac_feature_unit_descriptor {
  288. __u8 bLength;
  289. __u8 bDescriptorType;
  290. __u8 bDescriptorSubtype;
  291. __u8 bUnitID;
  292. __u8 bSourceID;
  293. __u8 bControlSize;
  294. __u8 bmaControls[]; /* variable length */
  295. } __attribute__((packed));
  296. static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
  297. {
  298. __u8 *raw = (__u8 *) desc;
  299. return raw[desc->bLength - 1];
  300. }
  301. /* 4.3.2.6 Processing Unit Descriptors */
  302. struct uac_processing_unit_descriptor {
  303. __u8 bLength;
  304. __u8 bDescriptorType;
  305. __u8 bDescriptorSubtype;
  306. __u8 bUnitID;
  307. __le16 wProcessType;
  308. __u8 bNrInPins;
  309. __u8 baSourceID[];
  310. } __attribute__ ((packed));
  311. static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
  312. {
  313. return desc->baSourceID[desc->bNrInPins];
  314. }
  315. static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
  316. int protocol)
  317. {
  318. if (protocol == UAC_VERSION_1)
  319. return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
  320. desc->baSourceID[desc->bNrInPins + 1];
  321. else
  322. return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
  323. (desc->baSourceID[desc->bNrInPins + 3] << 16) |
  324. (desc->baSourceID[desc->bNrInPins + 2] << 8) |
  325. (desc->baSourceID[desc->bNrInPins + 1]);
  326. }
  327. static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
  328. int protocol)
  329. {
  330. return (protocol == UAC_VERSION_1) ?
  331. desc->baSourceID[desc->bNrInPins + 3] :
  332. desc->baSourceID[desc->bNrInPins + 5];
  333. }
  334. static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
  335. int protocol)
  336. {
  337. switch (protocol) {
  338. case UAC_VERSION_1:
  339. return desc->baSourceID[desc->bNrInPins + 4];
  340. case UAC_VERSION_2:
  341. return 2; /* in UAC2, this value is constant */
  342. case UAC_VERSION_3:
  343. return 4; /* in UAC3, this value is constant */
  344. default:
  345. return 1;
  346. }
  347. }
  348. static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
  349. int protocol)
  350. {
  351. switch (protocol) {
  352. case UAC_VERSION_1:
  353. return &desc->baSourceID[desc->bNrInPins + 5];
  354. case UAC_VERSION_2:
  355. return &desc->baSourceID[desc->bNrInPins + 6];
  356. case UAC_VERSION_3:
  357. return &desc->baSourceID[desc->bNrInPins + 2];
  358. default:
  359. return NULL;
  360. }
  361. }
  362. static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
  363. int protocol)
  364. {
  365. __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
  366. switch (protocol) {
  367. case UAC_VERSION_1:
  368. case UAC_VERSION_2:
  369. default:
  370. return *(uac_processing_unit_bmControls(desc, protocol)
  371. + control_size);
  372. case UAC_VERSION_3:
  373. return 0; /* UAC3 does not have this field */
  374. }
  375. }
  376. static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
  377. int protocol)
  378. {
  379. __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
  380. switch (protocol) {
  381. case UAC_VERSION_1:
  382. case UAC_VERSION_2:
  383. default:
  384. return uac_processing_unit_bmControls(desc, protocol)
  385. + control_size + 1;
  386. case UAC_VERSION_3:
  387. return uac_processing_unit_bmControls(desc, protocol)
  388. + control_size;
  389. }
  390. }
  391. /*
  392. * Extension Unit (XU) has almost compatible layout with Processing Unit, but
  393. * on UAC2, it has a different bmControls size (bControlSize); it's 1 byte for
  394. * XU while 2 bytes for PU. The last iExtension field is a one-byte index as
  395. * well as iProcessing field of PU.
  396. */
  397. static inline __u8 uac_extension_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
  398. int protocol)
  399. {
  400. switch (protocol) {
  401. case UAC_VERSION_1:
  402. return desc->baSourceID[desc->bNrInPins + 4];
  403. case UAC_VERSION_2:
  404. return 1; /* in UAC2, this value is constant */
  405. case UAC_VERSION_3:
  406. return 4; /* in UAC3, this value is constant */
  407. default:
  408. return 1;
  409. }
  410. }
  411. static inline __u8 uac_extension_unit_iExtension(struct uac_processing_unit_descriptor *desc,
  412. int protocol)
  413. {
  414. __u8 control_size = uac_extension_unit_bControlSize(desc, protocol);
  415. switch (protocol) {
  416. case UAC_VERSION_1:
  417. case UAC_VERSION_2:
  418. default:
  419. return *(uac_processing_unit_bmControls(desc, protocol)
  420. + control_size);
  421. case UAC_VERSION_3:
  422. return 0; /* UAC3 does not have this field */
  423. }
  424. }
  425. /* 4.5.2 Class-Specific AS Interface Descriptor */
  426. struct uac1_as_header_descriptor {
  427. __u8 bLength; /* in bytes: 7 */
  428. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  429. __u8 bDescriptorSubtype; /* AS_GENERAL */
  430. __u8 bTerminalLink; /* Terminal ID of connected Terminal */
  431. __u8 bDelay; /* Delay introduced by the data path */
  432. __le16 wFormatTag; /* The Audio Data Format */
  433. } __attribute__ ((packed));
  434. #define UAC_DT_AS_HEADER_SIZE 7
  435. /* Formats - A.1.1 Audio Data Format Type I Codes */
  436. #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
  437. #define UAC_FORMAT_TYPE_I_PCM 0x1
  438. #define UAC_FORMAT_TYPE_I_PCM8 0x2
  439. #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
  440. #define UAC_FORMAT_TYPE_I_ALAW 0x4
  441. #define UAC_FORMAT_TYPE_I_MULAW 0x5
  442. struct uac_format_type_i_continuous_descriptor {
  443. __u8 bLength; /* in bytes: 8 + (ns * 3) */
  444. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  445. __u8 bDescriptorSubtype; /* FORMAT_TYPE */
  446. __u8 bFormatType; /* FORMAT_TYPE_1 */
  447. __u8 bNrChannels; /* physical channels in the stream */
  448. __u8 bSubframeSize; /* */
  449. __u8 bBitResolution;
  450. __u8 bSamFreqType;
  451. __u8 tLowerSamFreq[3];
  452. __u8 tUpperSamFreq[3];
  453. } __attribute__ ((packed));
  454. #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
  455. struct uac_format_type_i_discrete_descriptor {
  456. __u8 bLength; /* in bytes: 8 + (ns * 3) */
  457. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  458. __u8 bDescriptorSubtype; /* FORMAT_TYPE */
  459. __u8 bFormatType; /* FORMAT_TYPE_1 */
  460. __u8 bNrChannels; /* physical channels in the stream */
  461. __u8 bSubframeSize; /* */
  462. __u8 bBitResolution;
  463. __u8 bSamFreqType;
  464. __u8 tSamFreq[][3];
  465. } __attribute__ ((packed));
  466. #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
  467. struct uac_format_type_i_discrete_descriptor_##n { \
  468. __u8 bLength; \
  469. __u8 bDescriptorType; \
  470. __u8 bDescriptorSubtype; \
  471. __u8 bFormatType; \
  472. __u8 bNrChannels; \
  473. __u8 bSubframeSize; \
  474. __u8 bBitResolution; \
  475. __u8 bSamFreqType; \
  476. __u8 tSamFreq[n][3]; \
  477. } __attribute__ ((packed))
  478. #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
  479. struct uac_format_type_i_ext_descriptor {
  480. __u8 bLength;
  481. __u8 bDescriptorType;
  482. __u8 bDescriptorSubtype;
  483. __u8 bFormatType;
  484. __u8 bSubslotSize;
  485. __u8 bBitResolution;
  486. __u8 bHeaderLength;
  487. __u8 bControlSize;
  488. __u8 bSideBandProtocol;
  489. } __attribute__((packed));
  490. /* Formats - Audio Data Format Type I Codes */
  491. #define UAC_FORMAT_TYPE_II_MPEG 0x1001
  492. #define UAC_FORMAT_TYPE_II_AC3 0x1002
  493. struct uac_format_type_ii_discrete_descriptor {
  494. __u8 bLength;
  495. __u8 bDescriptorType;
  496. __u8 bDescriptorSubtype;
  497. __u8 bFormatType;
  498. __le16 wMaxBitRate;
  499. __le16 wSamplesPerFrame;
  500. __u8 bSamFreqType;
  501. __u8 tSamFreq[][3];
  502. } __attribute__((packed));
  503. struct uac_format_type_ii_ext_descriptor {
  504. __u8 bLength;
  505. __u8 bDescriptorType;
  506. __u8 bDescriptorSubtype;
  507. __u8 bFormatType;
  508. __le16 wMaxBitRate;
  509. __le16 wSamplesPerFrame;
  510. __u8 bHeaderLength;
  511. __u8 bSideBandProtocol;
  512. } __attribute__((packed));
  513. /* type III */
  514. #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
  515. #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
  516. #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
  517. #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
  518. #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
  519. #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
  520. /* Formats - A.2 Format Type Codes */
  521. #define UAC_FORMAT_TYPE_UNDEFINED 0x0
  522. #define UAC_FORMAT_TYPE_I 0x1
  523. #define UAC_FORMAT_TYPE_II 0x2
  524. #define UAC_FORMAT_TYPE_III 0x3
  525. #define UAC_EXT_FORMAT_TYPE_I 0x81
  526. #define UAC_EXT_FORMAT_TYPE_II 0x82
  527. #define UAC_EXT_FORMAT_TYPE_III 0x83
  528. struct uac_iso_endpoint_descriptor {
  529. __u8 bLength; /* in bytes: 7 */
  530. __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
  531. __u8 bDescriptorSubtype; /* EP_GENERAL */
  532. __u8 bmAttributes;
  533. __u8 bLockDelayUnits;
  534. __le16 wLockDelay;
  535. } __attribute__((packed));
  536. #define UAC_ISO_ENDPOINT_DESC_SIZE 7
  537. #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
  538. #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
  539. #define UAC_EP_CS_ATTR_FILL_MAX 0x80
  540. /* status word format (3.7.1.1) */
  541. #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
  542. #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
  543. #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
  544. #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
  545. #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
  546. #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
  547. struct uac1_status_word {
  548. __u8 bStatusType;
  549. __u8 bOriginator;
  550. } __attribute__((packed));
  551. #endif /* _UAPI__LINUX_USB_AUDIO_H */