uaudioreg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /* $NetBSD: uaudioreg.h,v 1.15.38.1 2012/06/02 11:09:29 mrg Exp $ */
  2. /*
  3. * Copyright (c) 1999 The NetBSD Foundation, Inc.
  4. * All rights reserved.
  5. *
  6. * This code is derived from software contributed to The NetBSD Foundation
  7. * by Lennart Augustsson (lennart@augustsson.net) at
  8. * Carlstedt Research & Technology.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  21. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  23. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include <rtdef.h>
  32. #include <stdint.h>
  33. typedef uint8_t uByte;
  34. typedef uint16_t uWord;
  35. #define UPACKED __attribute__ ((packed))
  36. #define UAUDIO_VERSION 0x100
  37. #define USB_SUBCLASS_AUDIOCONTROL 1
  38. #define USB_SUBCLASS_AUDIOSTREAMING 2
  39. #define USB_SUBCLASS_AUDIOMIDISTREAM 3
  40. #define UDESC_CS_CONFIG 0x22
  41. #define UDESC_CS_STRING 0x23
  42. #define UDESC_CS_INTERFACE 0x24
  43. #define UDESC_CS_ENDPOINT 0x25
  44. #define UDESCSUB_AC_HEADER 1
  45. #define UDESCSUB_AC_INPUT 2
  46. #define UDESCSUB_AC_OUTPUT 3
  47. #define UDESCSUB_AC_MIXER 4
  48. #define UDESCSUB_AC_SELECTOR 5
  49. #define UDESCSUB_AC_FEATURE 6
  50. #define UDESCSUB_AC_PROCESSING 7
  51. #define UDESCSUB_AC_EXTENSION 8
  52. #ifndef AUFMT_MAX_FREQUENCIES
  53. #define AUFMT_MAX_FREQUENCIES 1
  54. #endif
  55. /* The first fields are identical to usb_endpoint_descriptor_t */
  56. typedef struct {
  57. uByte bLength;
  58. uByte bDescriptorType;
  59. uByte bEndpointAddress;
  60. uByte bmAttributes;
  61. uWord wMaxPacketSize;
  62. uByte bInterval;
  63. /*
  64. * The following two entries are only used by the Audio Class.
  65. * And according to the specs the Audio Class is the only one
  66. * allowed to extend the endpoint descriptor.
  67. * Who knows what goes on in the minds of the people in the USB
  68. * standardization? :-(
  69. */
  70. uByte bRefresh;
  71. uByte bSynchAddress;
  72. } UPACKED usb_endpoint_descriptor_audio_t;
  73. /* generic, for iteration */
  74. typedef struct {
  75. uByte bLength;
  76. uByte bDescriptorType;
  77. uByte bDescriptorSubtype;
  78. } UPACKED uaudio_cs_descriptor_t;
  79. struct usb_audio_control_descriptor {
  80. uByte bLength;
  81. uByte bDescriptorType;
  82. uByte bDescriptorSubtype;
  83. uWord bcdADC;
  84. uWord wTotalLength;
  85. uByte bInCollection;
  86. uByte baInterfaceNr[1];
  87. } UPACKED;
  88. struct usb_audio_streaming_interface_descriptor {
  89. uByte bLength;
  90. uByte bDescriptorType;
  91. uByte bDescriptorSubtype;
  92. uByte bTerminalLink;
  93. uByte bDelay;
  94. uWord wFormatTag;
  95. } UPACKED;
  96. struct usb_audio_streaming_endpoint_descriptor {
  97. uByte bLength;
  98. uByte bDescriptorType;
  99. uByte bDescriptorSubtype;
  100. uByte bmAttributes;
  101. #define UA_SED_FREQ_CONTROL 0x01
  102. #define UA_SED_PITCH_CONTROL 0x02
  103. #define UA_SED_MAXPACKETSONLY 0x80
  104. uByte bLockDelayUnits;
  105. uWord wLockDelay;
  106. } UPACKED;
  107. struct usb_audio_streaming_type1_descriptor {
  108. uByte bLength;
  109. uByte bDescriptorType;
  110. uByte bDescriptorSubtype;
  111. uByte bFormatType;
  112. uByte bNrChannels;
  113. uByte bSubFrameSize;
  114. uByte bBitResolution;
  115. uByte bSamFreqType;
  116. #define UA_SAMP_CONTNUOUS 0
  117. uByte tSamFreq[3*AUFMT_MAX_FREQUENCIES];
  118. #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
  119. #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
  120. #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
  121. } UPACKED;
  122. struct usb_audio_cluster {
  123. uByte bNrChannels;
  124. uWord wChannelConfig;
  125. #define UA_CHANNEL_LEFT 0x0001
  126. #define UA_CHANNEL_RIGHT 0x0002
  127. #define UA_CHANNEL_CENTER 0x0004
  128. #define UA_CHANNEL_LFE 0x0008
  129. #define UA_CHANNEL_L_SURROUND 0x0010
  130. #define UA_CHANNEL_R_SURROUND 0x0020
  131. #define UA_CHANNEL_L_CENTER 0x0040
  132. #define UA_CHANNEL_R_CENTER 0x0080
  133. #define UA_CHANNEL_SURROUND 0x0100
  134. #define UA_CHANNEL_L_SIDE 0x0200
  135. #define UA_CHANNEL_R_SIDE 0x0400
  136. #define UA_CHANNEL_TOP 0x0800
  137. uByte iChannelNames;
  138. } UPACKED;
  139. /* Shared by all units and terminals */
  140. struct usb_audio_unit {
  141. uByte bLength;
  142. uByte bDescriptorType;
  143. uByte bDescriptorSubtype;
  144. uByte bUnitId;
  145. };
  146. /* UDESCSUB_AC_INPUT */
  147. struct usb_audio_input_terminal {
  148. uByte bLength;
  149. uByte bDescriptorType;
  150. uByte bDescriptorSubtype;
  151. uByte bTerminalId;
  152. uWord wTerminalType;
  153. uByte bAssocTerminal;
  154. uByte bNrChannels;
  155. uWord wChannelConfig;
  156. uByte iChannelNames;
  157. uByte iTerminal;
  158. } UPACKED;
  159. /* UDESCSUB_AC_OUTPUT */
  160. struct usb_audio_output_terminal {
  161. uByte bLength;
  162. uByte bDescriptorType;
  163. uByte bDescriptorSubtype;
  164. uByte bTerminalId;
  165. uWord wTerminalType;
  166. uByte bAssocTerminal;
  167. uByte bSourceId;
  168. uByte iTerminal;
  169. } UPACKED;
  170. /* UDESCSUB_AC_MIXER */
  171. struct usb_audio_mixer_unit {
  172. uByte bLength;
  173. uByte bDescriptorType;
  174. uByte bDescriptorSubtype;
  175. uByte bUnitId;
  176. uByte bNrInPins;
  177. uByte baSourceId[255]; /* [bNrInPins] */
  178. /* struct usb_audio_mixer_unit_1 */
  179. } UPACKED;
  180. struct usb_audio_mixer_unit_1 {
  181. uByte bNrChannels;
  182. uWord wChannelConfig;
  183. uByte iChannelNames;
  184. uByte bmControls[255]; /* [bNrChannels] */
  185. /*uByte iMixer;*/
  186. } UPACKED;
  187. /* UDESCSUB_AC_SELECTOR */
  188. struct usb_audio_selector_unit {
  189. uByte bLength;
  190. uByte bDescriptorType;
  191. uByte bDescriptorSubtype;
  192. uByte bUnitId;
  193. uByte bNrInPins;
  194. uByte baSourceId[255]; /* [bNrInPins] */
  195. /* uByte iSelector; */
  196. } UPACKED;
  197. /* UDESCSUB_AC_FEATURE */
  198. struct usb_audio_feature_unit {
  199. uByte bLength;
  200. uByte bDescriptorType;
  201. uByte bDescriptorSubtype;
  202. uByte bUnitId;
  203. uByte bSourceId;
  204. uByte bControlSize;
  205. uByte bmaControls[2]; /* size for more than enough */
  206. /* uByte iFeature; */
  207. } UPACKED;
  208. /* UDESCSUB_AC_PROCESSING */
  209. struct usb_audio_processing_unit {
  210. uByte bLength;
  211. uByte bDescriptorType;
  212. uByte bDescriptorSubtype;
  213. uByte bUnitId;
  214. uWord wProcessType;
  215. uByte bNrInPins;
  216. uByte baSourceId[255]; /* [bNrInPins] */
  217. /* struct usb_audio_processing_unit_1 */
  218. } UPACKED;
  219. struct usb_audio_processing_unit_1{
  220. uByte bNrChannels;
  221. uWord wChannelConfig;
  222. uByte iChannelNames;
  223. uByte bControlSize;
  224. uByte bmControls[255]; /* [bControlSize] */
  225. #define UA_PROC_ENABLE_MASK 1
  226. } UPACKED;
  227. struct usb_audio_processing_unit_updown {
  228. uByte iProcessing;
  229. uByte bNrModes;
  230. uWord waModes[255]; /* [bNrModes] */
  231. } UPACKED;
  232. /* UDESCSUB_AC_EXTENSION */
  233. struct usb_audio_extension_unit {
  234. uByte bLength;
  235. uByte bDescriptorType;
  236. uByte bDescriptorSubtype;
  237. uByte bUnitId;
  238. uWord wExtensionCode;
  239. uByte bNrInPins;
  240. uByte baSourceId[255]; /* [bNrInPins] */
  241. /* struct usb_audio_extension_unit_1 */
  242. } UPACKED;
  243. struct usb_audio_extension_unit_1 {
  244. uByte bNrChannels;
  245. uWord wChannelConfig;
  246. uByte iChannelNames;
  247. uByte bControlSize;
  248. uByte bmControls[255]; /* [bControlSize] */
  249. #define UA_EXT_ENABLE_MASK 1
  250. #define UA_EXT_ENABLE 1
  251. /*uByte iExtension;*/
  252. } UPACKED;
  253. /* USB terminal types */
  254. #define UAT_UNDEFINED 0x0100
  255. #define UAT_STREAM 0x0101
  256. #define UAT_VENDOR 0x01ff
  257. /* input terminal types */
  258. #define UATI_UNDEFINED 0x0200
  259. #define UATI_MICROPHONE 0x0201
  260. #define UATI_DESKMICROPHONE 0x0202
  261. #define UATI_PERSONALMICROPHONE 0x0203
  262. #define UATI_OMNIMICROPHONE 0x0204
  263. #define UATI_MICROPHONEARRAY 0x0205
  264. #define UATI_PROCMICROPHONEARR 0x0206
  265. /* output terminal types */
  266. #define UATO_UNDEFINED 0x0300
  267. #define UATO_SPEAKER 0x0301
  268. #define UATO_HEADPHONES 0x0302
  269. #define UATO_DISPLAYAUDIO 0x0303
  270. #define UATO_DESKTOPSPEAKER 0x0304
  271. #define UATO_ROOMSPEAKER 0x0305
  272. #define UATO_COMMSPEAKER 0x0306
  273. #define UATO_SUBWOOFER 0x0307
  274. /* bidir terminal types */
  275. #define UATB_UNDEFINED 0x0400
  276. #define UATB_HANDSET 0x0401
  277. #define UATB_HEADSET 0x0402
  278. #define UATB_SPEAKERPHONE 0x0403
  279. #define UATB_SPEAKERPHONEESUP 0x0404
  280. #define UATB_SPEAKERPHONEECANC 0x0405
  281. /* telephony terminal types */
  282. #define UATT_UNDEFINED 0x0500
  283. #define UATT_PHONELINE 0x0501
  284. #define UATT_TELEPHONE 0x0502
  285. #define UATT_DOWNLINEPHONE 0x0503
  286. /* external terminal types */
  287. #define UATE_UNDEFINED 0x0600
  288. #define UATE_ANALOGCONN 0x0601
  289. #define UATE_DIGITALAUIFC 0x0602
  290. #define UATE_LINECONN 0x0603
  291. #define UATE_LEGACYCONN 0x0604
  292. #define UATE_SPDIF 0x0605
  293. #define UATE_1394DA 0x0606
  294. #define UATE_1394DV 0x0607
  295. /* embedded function terminal types */
  296. #define UATF_UNDEFINED 0x0700
  297. #define UATF_CALIBNOISE 0x0701
  298. #define UATF_EQUNOISE 0x0702
  299. #define UATF_CDPLAYER 0x0703
  300. #define UATF_DAT 0x0704
  301. #define UATF_DCC 0x0705
  302. #define UATF_MINIDISK 0x0706
  303. #define UATF_ANALOGTAPE 0x0707
  304. #define UATF_PHONOGRAPH 0x0708
  305. #define UATF_VCRAUDIO 0x0709
  306. #define UATF_VIDEODISCAUDIO 0x070a
  307. #define UATF_DVDAUDIO 0x070b
  308. #define UATF_TVTUNERAUDIO 0x070c
  309. #define UATF_SATELLITE 0x070d
  310. #define UATF_CABLETUNER 0x070e
  311. #define UATF_DSS 0x070f
  312. #define UATF_RADIORECV 0x0710
  313. #define UATF_RADIOXMIT 0x0711
  314. #define UATF_MULTITRACK 0x0712
  315. #define UATF_SYNTHESIZER 0x0713
  316. #define SET_CUR 0x01
  317. #define GET_CUR 0x81
  318. #define SET_MIN 0x02
  319. #define GET_MIN 0x82
  320. #define SET_MAX 0x03
  321. #define GET_MAX 0x83
  322. #define SET_RES 0x04
  323. #define GET_RES 0x84
  324. #define SET_MEM 0x05
  325. #define GET_MEM 0x85
  326. #define GET_STAT 0xff
  327. #define MUTE_CONTROL 0x01
  328. #define VOLUME_CONTROL 0x02
  329. #define BASS_CONTROL 0x03
  330. #define MID_CONTROL 0x04
  331. #define TREBLE_CONTROL 0x05
  332. #define GRAPHIC_EQUALIZER_CONTROL 0x06
  333. #define AGC_CONTROL 0x07
  334. #define DELAY_CONTROL 0x08
  335. #define BASS_BOOST_CONTROL 0x09
  336. #define LOUDNESS_CONTROL 0x0a
  337. #define FU_MASK(u) (1 << ((u)-1))
  338. #define MASTER_CHAN 0
  339. #define AS_GENERAL 1
  340. #define FORMAT_TYPE 2
  341. #define FORMAT_SPECIFIC 3
  342. #define UA_FMT_PCM 1
  343. #define UA_FMT_PCM8 2
  344. #define UA_FMT_IEEE_FLOAT 3
  345. #define UA_FMT_ALAW 4
  346. #define UA_FMT_MULAW 5
  347. #define UA_FMT_MPEG 0x1001
  348. #define UA_FMT_AC3 0x1002
  349. #define SAMPLING_FREQ_CONTROL 0x01
  350. #define PITCH_CONTROL 0x02
  351. #define FORMAT_TYPE_UNDEFINED 0
  352. #define FORMAT_TYPE_I 1
  353. #define FORMAT_TYPE_II 2
  354. #define FORMAT_TYPE_III 3
  355. #define UA_PROC_MASK(n) (1<< ((n)-1))
  356. #define PROCESS_UNDEFINED 0
  357. #define XX_ENABLE_CONTROL 1
  358. #define UPDOWNMIX_PROCESS 1
  359. #define UD_ENABLE_CONTROL 1
  360. #define UD_MODE_SELECT_CONTROL 2
  361. #define DOLBY_PROLOGIC_PROCESS 2
  362. #define DP_ENABLE_CONTROL 1
  363. #define DP_MODE_SELECT_CONTROL 2
  364. #define P3D_STEREO_EXTENDER_PROCESS 3
  365. #define P3D_ENABLE_CONTROL 1
  366. #define P3D_SPACIOUSNESS_CONTROL 2
  367. #define REVERBATION_PROCESS 4
  368. #define RV_ENABLE_CONTROL 1
  369. #define RV_LEVEL_CONTROL 2
  370. #define RV_TIME_CONTROL 3
  371. #define RV_FEEDBACK_CONTROL 4
  372. #define CHORUS_PROCESS 5
  373. #define CH_ENABLE_CONTROL 1
  374. #define CH_LEVEL_CONTROL 2
  375. #define CH_RATE_CONTROL 3
  376. #define CH_DEPTH_CONTROL 4
  377. #define DYN_RANGE_COMP_PROCESS 6
  378. #define DR_ENABLE_CONTROL 1
  379. #define DR_COMPRESSION_RATE_CONTROL 2
  380. #define DR_MAXAMPL_CONTROL 3
  381. #define DR_THRESHOLD_CONTROL 4
  382. #define DR_ATTACK_TIME_CONTROL 5
  383. #define DR_RELEASE_TIME_CONTROL 6