audio.h 17 KB

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