Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AudioClassCommon.h 44KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief Common definitions and declarations for the library USB Audio 1.0 Class driver.
  28. *
  29. * Common definitions and declarations for the library USB Audio 1.0 Class driver.
  30. *
  31. * \note This file should not be included directly. It is automatically included as needed by the USB module driver
  32. * dispatch header located in LUFA/Drivers/USB.h.
  33. */
  34. /** \ingroup Group_USBClassAudio
  35. * \defgroup Group_USBClassAudioCommon Common Class Definitions
  36. *
  37. * \section Sec_USBClassAudioCommon_ModDescription Module Description
  38. * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
  39. * Audio 1.0 Class.
  40. *
  41. * @{
  42. */
  43. #ifndef _AUDIO_CLASS_COMMON_H_
  44. #define _AUDIO_CLASS_COMMON_H_
  45. /* Includes: */
  46. #include "../../Core/StdDescriptors.h"
  47. /* Enable C linkage for C++ Compilers: */
  48. #if defined(__cplusplus)
  49. extern "C" {
  50. #endif
  51. /* Preprocessor Checks: */
  52. #if !defined(__INCLUDE_FROM_AUDIO_DRIVER)
  53. #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
  54. #endif
  55. /* Macros: */
  56. /** \name Audio Channel Masks */
  57. //@{
  58. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  59. #define AUDIO_CHANNEL_LEFT_FRONT (1 << 0)
  60. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  61. #define AUDIO_CHANNEL_RIGHT_FRONT (1 << 1)
  62. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  63. #define AUDIO_CHANNEL_CENTER_FRONT (1 << 2)
  64. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  65. #define AUDIO_CHANNEL_LOW_FREQ_ENHANCE (1 << 3)
  66. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  67. #define AUDIO_CHANNEL_LEFT_SURROUND (1 << 4)
  68. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  69. #define AUDIO_CHANNEL_RIGHT_SURROUND (1 << 5)
  70. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  71. #define AUDIO_CHANNEL_LEFT_OF_CENTER (1 << 6)
  72. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  73. #define AUDIO_CHANNEL_RIGHT_OF_CENTER (1 << 7)
  74. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  75. #define AUDIO_CHANNEL_SURROUND (1 << 8)
  76. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  77. #define AUDIO_CHANNEL_SIDE_LEFT (1 << 9)
  78. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  79. #define AUDIO_CHANNEL_SIDE_RIGHT (1 << 10)
  80. /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
  81. #define AUDIO_CHANNEL_TOP (1 << 11)
  82. //@}
  83. /** \name Audio Feature Masks */
  84. //@{
  85. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  86. #define AUDIO_FEATURE_MUTE (1 << 0)
  87. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  88. #define AUDIO_FEATURE_VOLUME (1 << 1)
  89. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  90. #define AUDIO_FEATURE_BASS (1 << 2)
  91. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  92. #define AUDIO_FEATURE_MID (1 << 3)
  93. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  94. #define AUDIO_FEATURE_TREBLE (1 << 4)
  95. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  96. #define AUDIO_FEATURE_GRAPHIC_EQUALIZER (1 << 5)
  97. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  98. #define AUDIO_FEATURE_AUTOMATIC_GAIN (1 << 6)
  99. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  100. #define AUDIO_FEATURE_DELAY (1 << 7)
  101. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  102. #define AUDIO_FEATURE_BASS_BOOST (1 << 8)
  103. /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
  104. #define AUDIO_FEATURE_BASS_LOUDNESS (1 << 9)
  105. //@}
  106. /** \name Audio Terminal Types */
  107. //@{
  108. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  109. #define AUDIO_TERMINAL_UNDEFINED 0x0100
  110. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  111. #define AUDIO_TERMINAL_STREAMING 0x0101
  112. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  113. #define AUDIO_TERMINAL_VENDOR 0x01FF
  114. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  115. #define AUDIO_TERMINAL_IN_UNDEFINED 0x0200
  116. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  117. #define AUDIO_TERMINAL_IN_MIC 0x0201
  118. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  119. #define AUDIO_TERMINAL_IN_DESKTOP_MIC 0x0202
  120. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  121. #define AUDIO_TERMINAL_IN_PERSONAL_MIC 0x0203
  122. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  123. #define AUDIO_TERMINAL_IN_OMNIDIR_MIC 0x0204
  124. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  125. #define AUDIO_TERMINAL_IN_MIC_ARRAY 0x0205
  126. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  127. #define AUDIO_TERMINAL_IN_PROCESSING_MIC 0x0206
  128. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  129. #define AUDIO_TERMINAL_IN_OUT_UNDEFINED 0x0300
  130. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  131. #define AUDIO_TERMINAL_OUT_SPEAKER 0x0301
  132. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  133. #define AUDIO_TERMINAL_OUT_HEADPHONES 0x0302
  134. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  135. #define AUDIO_TERMINAL_OUT_HEAD_MOUNTED 0x0303
  136. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  137. #define AUDIO_TERMINAL_OUT_DESKTOP 0x0304
  138. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  139. #define AUDIO_TERMINAL_OUT_ROOM 0x0305
  140. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  141. #define AUDIO_TERMINAL_OUT_COMMUNICATION 0x0306
  142. /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
  143. #define AUDIO_TERMINAL_OUT_LOWFREQ 0x0307
  144. //@}
  145. /** Convenience macro to fill a 24-bit \ref USB_Audio_SampleFreq_t structure with the given sample rate as a 24-bit number.
  146. *
  147. * \param[in] freq Required audio sampling frequency in HZ
  148. */
  149. #define AUDIO_SAMPLE_FREQ(freq) {.Byte1 = ((uint32_t)freq & 0xFF), .Byte2 = (((uint32_t)freq >> 8) & 0xFF), .Byte3 = (((uint32_t)freq >> 16) & 0xFF)}
  150. /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint
  151. * accepts only filled endpoint packets of audio samples.
  152. */
  153. #define AUDIO_EP_FULL_PACKETS_ONLY (1 << 7)
  154. /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint
  155. * will accept partially filled endpoint packets of audio samples.
  156. */
  157. #define AUDIO_EP_ACCEPTS_SMALL_PACKETS (0 << 7)
  158. /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint
  159. * allows for sampling frequency adjustments to be made via control requests directed at the endpoint.
  160. */
  161. #define AUDIO_EP_SAMPLE_FREQ_CONTROL (1 << 0)
  162. /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint
  163. * allows for pitch adjustments to be made via control requests directed at the endpoint.
  164. */
  165. #define AUDIO_EP_PITCH_CONTROL (1 << 1)
  166. /* Enums: */
  167. /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Audio
  168. * device class.
  169. */
  170. enum Audio_Descriptor_ClassSubclassProtocol_t
  171. {
  172. AUDIO_CSCP_AudioClass = 0x01, /**< Descriptor Class value indicating that the device or
  173. * interface belongs to the USB Audio 1.0 class.
  174. */
  175. AUDIO_CSCP_ControlSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or
  176. * interface belongs to the Audio Control subclass.
  177. */
  178. AUDIO_CSCP_ControlProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or
  179. * interface belongs to the Audio Control protocol.
  180. */
  181. AUDIO_CSCP_AudioStreamingSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or
  182. * interface belongs to the MIDI Streaming subclass.
  183. */
  184. AUDIO_CSCP_MIDIStreamingSubclass = 0x03, /**< Descriptor Subclass value indicating that the device or
  185. * interface belongs to the Audio streaming subclass.
  186. */
  187. AUDIO_CSCP_StreamingProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or
  188. * interface belongs to the Streaming Audio protocol.
  189. */
  190. };
  191. /** Audio class specific interface description subtypes, for the Audio Control interface. */
  192. enum Audio_CSInterface_AC_SubTypes_t
  193. {
  194. AUDIO_DSUBTYPE_CSInterface_Header = 0x01, /**< Audio class specific control interface header. */
  195. AUDIO_DSUBTYPE_CSInterface_InputTerminal = 0x02, /**< Audio class specific control interface Input Terminal. */
  196. AUDIO_DSUBTYPE_CSInterface_OutputTerminal = 0x03, /**< Audio class specific control interface Output Terminal. */
  197. AUDIO_DSUBTYPE_CSInterface_Mixer = 0x04, /**< Audio class specific control interface Mixer Unit. */
  198. AUDIO_DSUBTYPE_CSInterface_Selector = 0x05, /**< Audio class specific control interface Selector Unit. */
  199. AUDIO_DSUBTYPE_CSInterface_Feature = 0x06, /**< Audio class specific control interface Feature Unit. */
  200. AUDIO_DSUBTYPE_CSInterface_Processing = 0x07, /**< Audio class specific control interface Processing Unit. */
  201. AUDIO_DSUBTYPE_CSInterface_Extension = 0x08, /**< Audio class specific control interface Extension Unit. */
  202. };
  203. /** Audio class specific interface description subtypes, for the Audio Streaming interface. */
  204. enum Audio_CSInterface_AS_SubTypes_t
  205. {
  206. AUDIO_DSUBTYPE_CSInterface_General = 0x01, /**< Audio class specific streaming interface general descriptor. */
  207. AUDIO_DSUBTYPE_CSInterface_FormatType = 0x02, /**< Audio class specific streaming interface format type descriptor. */
  208. AUDIO_DSUBTYPE_CSInterface_FormatSpecific = 0x03, /**< Audio class specific streaming interface format information descriptor. */
  209. };
  210. /** Audio class specific endpoint description subtypes, for the Audio Streaming interface. */
  211. enum Audio_CSEndpoint_SubTypes_t
  212. {
  213. AUDIO_DSUBTYPE_CSEndpoint_General = 0x01, /**< Audio class specific endpoint general descriptor. */
  214. };
  215. /** Enum for the Audio class specific control requests that can be issued by the USB bus host. */
  216. enum Audio_ClassRequests_t
  217. {
  218. AUDIO_REQ_SetCurrent = 0x01, /**< Audio class-specific request to set the current value of a parameter within the device. */
  219. AUDIO_REQ_SetMinimum = 0x02, /**< Audio class-specific request to set the minimum value of a parameter within the device. */
  220. AUDIO_REQ_SetMaximum = 0x03, /**< Audio class-specific request to set the maximum value of a parameter within the device. */
  221. AUDIO_REQ_SetResolution = 0x04, /**< Audio class-specific request to set the resolution value of a parameter within the device. */
  222. AUDIO_REQ_SetMemory = 0x05, /**< Audio class-specific request to set the memory value of a parameter within the device. */
  223. AUDIO_REQ_GetCurrent = 0x81, /**< Audio class-specific request to get the current value of a parameter within the device. */
  224. AUDIO_REQ_GetMinimum = 0x82, /**< Audio class-specific request to get the minimum value of a parameter within the device. */
  225. AUDIO_REQ_GetMaximum = 0x83, /**< Audio class-specific request to get the maximum value of a parameter within the device. */
  226. AUDIO_REQ_GetResolution = 0x84, /**< Audio class-specific request to get the resolution value of a parameter within the device. */
  227. AUDIO_REQ_GetMemory = 0x85, /**< Audio class-specific request to get the memory value of a parameter within the device. */
  228. AUDIO_REQ_GetStatus = 0xFF, /**< Audio class-specific request to get the device status. */
  229. };
  230. /** Enum for Audio class specific Endpoint control modifiers which can be set and retrieved by a USB host, if the corresponding
  231. * endpoint control is indicated to be supported in the Endpoint's Audio-class specific endpoint descriptor.
  232. */
  233. enum Audio_EndpointControls_t
  234. {
  235. AUDIO_EPCONTROL_SamplingFreq = 0x01, /**< Sampling frequency adjustment of the endpoint. */
  236. AUDIO_EPCONTROL_Pitch = 0x02, /**< Pitch adjustment of the endpoint. */
  237. };
  238. /* Type Defines: */
  239. /** \brief Audio class-specific Input Terminal Descriptor (LUFA naming conventions).
  240. *
  241. * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device
  242. * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example,
  243. * a USB endpoint). See the USB Audio specification for more details.
  244. *
  245. * \see \ref USB_Audio_StdDescriptor_InputTerminal_t for the version of this type with standard element names.
  246. *
  247. * \note Regardless of CPU architecture, these values should be stored as little endian.
  248. */
  249. typedef struct
  250. {
  251. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  252. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  253. * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal.
  254. */
  255. uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
  256. uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */
  257. uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals
  258. * such as the speaker and microphone of a phone handset.
  259. */
  260. uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */
  261. uint16_t ChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */
  262. uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device. */
  263. uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
  264. } ATTR_PACKED USB_Audio_Descriptor_InputTerminal_t;
  265. /** \brief Audio class-specific Input Terminal Descriptor (USB-IF naming conventions).
  266. *
  267. * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device
  268. * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example,
  269. * a USB endpoint). See the USB Audio specification for more details.
  270. *
  271. * \see \ref USB_Audio_Descriptor_InputTerminal_t for the version of this type with non-standard LUFA specific
  272. * element names.
  273. *
  274. * \note Regardless of CPU architecture, these values should be stored as little endian.
  275. */
  276. typedef struct
  277. {
  278. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  279. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  280. * given by the specific class.
  281. */
  282. uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  283. * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal.
  284. */
  285. uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
  286. uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */
  287. uint8_t bAssocTerminal; /**< ID of associated output terminal, for physically grouped terminals
  288. * such as the speaker and microphone of a phone handset.
  289. */
  290. uint8_t bNrChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */
  291. uint16_t wChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */
  292. uint8_t iChannelNames; /**< Index of a string descriptor describing this channel within the device. */
  293. uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */
  294. } ATTR_PACKED USB_Audio_StdDescriptor_InputTerminal_t;
  295. /** \brief Audio class-specific Output Terminal Descriptor (LUFA naming conventions).
  296. *
  297. * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device
  298. * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example,
  299. * a USB endpoint). See the USB Audio specification for more details.
  300. *
  301. * \see \ref USB_Audio_StdDescriptor_OutputTerminal_t for the version of this type with standard element names.
  302. *
  303. * \note Regardless of CPU architecture, these values should be stored as little endian.
  304. */
  305. typedef struct
  306. {
  307. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  308. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  309. * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal.
  310. */
  311. uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
  312. uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */
  313. uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals
  314. * such as the speaker and microphone of a phone handset.
  315. */
  316. uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from. */
  317. uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
  318. } ATTR_PACKED USB_Audio_Descriptor_OutputTerminal_t;
  319. /** \brief Audio class-specific Output Terminal Descriptor (USB-IF naming conventions).
  320. *
  321. * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device
  322. * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example,
  323. * a USB endpoint). See the USB Audio specification for more details.
  324. *
  325. * \see \ref USB_Audio_Descriptor_OutputTerminal_t for the version of this type with non-standard LUFA specific
  326. * element names.
  327. *
  328. * \note Regardless of CPU architecture, these values should be stored as little endian.
  329. */
  330. typedef struct
  331. {
  332. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  333. uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors,
  334. * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal.
  335. */
  336. uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  337. * a value from the \ref Audio_CSInterface_AC_SubTypes_t enum.
  338. */
  339. uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
  340. uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */
  341. uint8_t bAssocTerminal; /**< ID of associated input terminal, for physically grouped terminals
  342. * such as the speaker and microphone of a phone handset.
  343. */
  344. uint8_t bSourceID; /**< ID value of the unit this terminal's audio is sourced from. */
  345. uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */
  346. } ATTR_PACKED USB_Audio_StdDescriptor_OutputTerminal_t;
  347. /** \brief Audio class-specific Interface Descriptor (LUFA naming conventions).
  348. *
  349. * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to
  350. * supply extra information about the audio device's layout to the host. See the USB Audio specification for more
  351. * details.
  352. *
  353. * \see \ref USB_Audio_StdDescriptor_Interface_AC_t for the version of this type with standard element names.
  354. *
  355. * \note Regardless of CPU architecture, these values should be stored as little endian.
  356. */
  357. typedef struct
  358. {
  359. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  360. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  361. * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
  362. */
  363. uint16_t ACSpecification; /**< Binary Coded Decimal value, indicating the supported Audio Class specification version.
  364. *
  365. * \see \ref VERSION_BCD() utility macro.
  366. */
  367. uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
  368. uint8_t InCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */
  369. uint8_t InterfaceNumber; /**< Interface number of the associated Audio Streaming interface. */
  370. } ATTR_PACKED USB_Audio_Descriptor_Interface_AC_t;
  371. /** \brief Audio class-specific Interface Descriptor (USB-IF naming conventions).
  372. *
  373. * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to
  374. * supply extra information about the audio device's layout to the host. See the USB Audio specification for more
  375. * details.
  376. *
  377. * \see \ref USB_Audio_Descriptor_Interface_AC_t for the version of this type with non-standard LUFA specific
  378. * element names.
  379. *
  380. * \note Regardless of CPU architecture, these values should be stored as little endian.
  381. */
  382. typedef struct
  383. {
  384. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  385. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  386. * given by the specific class.
  387. */
  388. uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors,
  389. * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
  390. */
  391. uint16_t bcdADC; /**< Binary coded decimal value, indicating the supported Audio Class specification version.
  392. *
  393. * \see \ref VERSION_BCD() utility macro.
  394. */
  395. uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
  396. uint8_t bInCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */
  397. uint8_t bInterfaceNumbers; /**< Interface number of the associated Audio Streaming interface. */
  398. } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AC_t;
  399. /** \brief Audio class-specific Feature Unit Descriptor (LUFA naming conventions).
  400. *
  401. * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features
  402. * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio
  403. * specification for more details.
  404. *
  405. * \see \ref USB_Audio_StdDescriptor_FeatureUnit_t for the version of this type with standard element names.
  406. *
  407. * \note Regardless of CPU architecture, these values should be stored as little endian.
  408. */
  409. typedef struct
  410. {
  411. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  412. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  413. * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.
  414. */
  415. uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device. */
  416. uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit. */
  417. uint8_t ControlSize; /**< Size of each element in the \c ChannelControls array. */
  418. uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */
  419. uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
  420. } ATTR_PACKED USB_Audio_Descriptor_FeatureUnit_t;
  421. /** \brief Audio class-specific Feature Unit Descriptor (USB-IF naming conventions).
  422. *
  423. * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features
  424. * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio
  425. * specification for more details.
  426. *
  427. * \see \ref USB_Audio_Descriptor_FeatureUnit_t for the version of this type with non-standard LUFA specific
  428. * element names.
  429. *
  430. * \note Regardless of CPU architecture, these values should be stored as little endian.
  431. */
  432. typedef struct
  433. {
  434. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  435. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  436. * given by the specific class.
  437. */
  438. uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  439. * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.
  440. */
  441. uint8_t bUnitID; /**< ID value of this feature unit - must be a unique value within the device. */
  442. uint8_t bSourceID; /**< Source ID value of the audio source input into this feature unit. */
  443. uint8_t bControlSize; /**< Size of each element in the \c ChannelControls array. */
  444. uint8_t bmaControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */
  445. uint8_t iFeature; /**< Index of a string descriptor describing this descriptor within the device. */
  446. } ATTR_PACKED USB_Audio_StdDescriptor_FeatureUnit_t;
  447. /** \brief Audio class-specific Streaming Audio Interface Descriptor (LUFA naming conventions).
  448. *
  449. * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host
  450. * how audio streams within the device are formatted. See the USB Audio specification for more details.
  451. *
  452. * \see \ref USB_Audio_StdDescriptor_Interface_AS_t for the version of this type with standard element names.
  453. *
  454. * \note Regardless of CPU architecture, these values should be stored as little endian.
  455. */
  456. typedef struct
  457. {
  458. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  459. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  460. * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
  461. */
  462. uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing. */
  463. uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */
  464. uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification. */
  465. } ATTR_PACKED USB_Audio_Descriptor_Interface_AS_t;
  466. /** \brief Audio class-specific Streaming Audio Interface Descriptor (USB-IF naming conventions).
  467. *
  468. * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host
  469. * how audio streams within the device are formatted. See the USB Audio specification for more details.
  470. *
  471. * \see \ref USB_Audio_Descriptor_Interface_AS_t for the version of this type with non-standard LUFA specific
  472. * element names.
  473. *
  474. * \note Regardless of CPU architecture, these values should be stored as little endian.
  475. */
  476. typedef struct
  477. {
  478. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  479. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  480. * given by the specific class.
  481. */
  482. uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  483. * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
  484. */
  485. uint8_t bTerminalLink; /**< ID value of the output terminal this descriptor is describing. */
  486. uint8_t bDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */
  487. uint16_t wFormatTag; /**< Format of the audio stream, see Audio Device Formats specification. */
  488. } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AS_t;
  489. /** \brief Audio class-specific Format Descriptor (LUFA naming conventions).
  490. *
  491. * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details
  492. * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used
  493. * in the device's audio streams. See the USB Audio specification for more details.
  494. *
  495. * \attention This descriptor <b>must</b> be followed by one or more \ref USB_Audio_SampleFreq_t elements containing
  496. * the continuous or discrete sample frequencies.
  497. *
  498. * \see \ref USB_Audio_StdDescriptor_Format_t for the version of this type with standard element names.
  499. *
  500. * \note Regardless of CPU architecture, these values should be stored as little endian.
  501. */
  502. typedef struct
  503. {
  504. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  505. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  506. * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType.
  507. */
  508. uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification. */
  509. uint8_t Channels; /**< Total number of discrete channels in the stream. */
  510. uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */
  511. uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream. */
  512. uint8_t TotalDiscreteSampleRates; /**< Total number of discrete sample frequencies supported by the device. When
  513. * zero, this must be followed by the lower and upper continuous sampling
  514. * frequencies supported by the device; otherwise, this must be followed
  515. * by the given number of discrete sampling frequencies supported.
  516. */
  517. } ATTR_PACKED USB_Audio_Descriptor_Format_t;
  518. /** \brief 24-Bit Audio Frequency Structure.
  519. *
  520. * Type define for a 24-bit audio sample frequency structure. As GCC does not contain a built in 24-bit datatype,
  521. * this this structure is used to build up the value instead. Fill this structure with the \ref AUDIO_SAMPLE_FREQ() macro.
  522. *
  523. * \note Regardless of CPU architecture, these values should be stored as little endian.
  524. */
  525. typedef struct
  526. {
  527. uint8_t Byte1; /**< Lowest 8 bits of the 24-bit value. */
  528. uint8_t Byte2; /**< Middle 8 bits of the 24-bit value. */
  529. uint8_t Byte3; /**< Upper 8 bits of the 24-bit value. */
  530. } ATTR_PACKED USB_Audio_SampleFreq_t;
  531. /** \brief Audio class-specific Format Descriptor (USB-IF naming conventions).
  532. *
  533. * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details
  534. * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used
  535. * in the device's audio streams. See the USB Audio specification for more details.
  536. *
  537. * \attention This descriptor <b>must</b> be followed by one or more 24-bit integer elements containing the continuous
  538. * or discrete sample frequencies.
  539. *
  540. * \see \ref USB_Audio_Descriptor_Format_t for the version of this type with non-standard LUFA specific
  541. * element names.
  542. *
  543. * \note Regardless of CPU architecture, these values should be stored as little endian.
  544. */
  545. typedef struct
  546. {
  547. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  548. uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors,
  549. * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType.
  550. */
  551. uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors,
  552. * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
  553. */
  554. uint8_t bFormatType; /**< Format of the audio stream, see Audio Device Formats specification. */
  555. uint8_t bNrChannels; /**< Total number of discrete channels in the stream. */
  556. uint8_t bSubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */
  557. uint8_t bBitResolution; /**< Bits of resolution of each channel's samples in the stream. */
  558. uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. When
  559. * zero, this must be followed by the lower and upper continuous sampling
  560. * frequencies supported by the device; otherwise, this must be followed
  561. * by the given number of discrete sampling frequencies supported.
  562. */
  563. } ATTR_PACKED USB_Audio_StdDescriptor_Format_t;
  564. /** \brief Audio class-specific Streaming Endpoint Descriptor (LUFA naming conventions).
  565. *
  566. * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
  567. * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.
  568. *
  569. * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Std_t for the version of this type with standard element names.
  570. *
  571. * \note Regardless of CPU architecture, these values should be stored as little endian.
  572. */
  573. typedef struct
  574. {
  575. USB_Descriptor_Endpoint_t Endpoint; /**< Standard endpoint descriptor describing the audio endpoint. */
  576. uint8_t Refresh; /**< Always set to zero for Audio class devices. */
  577. uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */
  578. } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Std_t;
  579. /** \brief Audio class-specific Streaming Endpoint Descriptor (USB-IF naming conventions).
  580. *
  581. * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
  582. * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.
  583. *
  584. * \see \ref USB_Audio_Descriptor_StreamEndpoint_Std_t for the version of this type with non-standard LUFA specific
  585. * element names.
  586. *
  587. * \note Regardless of CPU architecture, these values should be stored as little endian.
  588. */
  589. typedef struct
  590. {
  591. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  592. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
  593. * value given by the specific class.
  594. */
  595. uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
  596. * configuration, including direction mask.
  597. */
  598. uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (\c EP_TYPE_*)
  599. * and attributes (\c ENDPOINT_ATTR_*) masks.
  600. */
  601. uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
  602. * that the endpoint can receive at a time.
  603. */
  604. uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
  605. * ISOCHRONOUS type.
  606. */
  607. uint8_t bRefresh; /**< Always set to zero for Audio class devices. */
  608. uint8_t bSynchAddress; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */
  609. } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Std_t;
  610. /** \brief Audio class-specific Extended Endpoint Descriptor (LUFA naming conventions).
  611. *
  612. * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information
  613. * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio
  614. * class-specific extended endpoint descriptor. See the USB Audio specification for more details.
  615. *
  616. * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Spc_t for the version of this type with standard element names.
  617. *
  618. * \note Regardless of CPU architecture, these values should be stored as little endian.
  619. */
  620. typedef struct
  621. {
  622. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  623. uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  624. * a value from the \ref Audio_CSEndpoint_SubTypes_t enum.
  625. */
  626. uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */
  627. uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */
  628. uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */
  629. } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Spc_t;
  630. /** \brief Audio class-specific Extended Endpoint Descriptor (USB-IF naming conventions).
  631. *
  632. * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information
  633. * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio
  634. * class-specific extended endpoint descriptor. See the USB Audio specification for more details.
  635. *
  636. * \see \ref USB_Audio_Descriptor_StreamEndpoint_Spc_t for the version of this type with non-standard LUFA specific
  637. * element names.
  638. *
  639. * \note Regardless of CPU architecture, these values should be stored as little endian.
  640. */
  641. typedef struct
  642. {
  643. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  644. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  645. * given by the specific class.
  646. */
  647. uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
  648. * a value from the \ref Audio_CSEndpoint_SubTypes_t enum.
  649. */
  650. uint8_t bmAttributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */
  651. uint8_t bLockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */
  652. uint16_t wLockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */
  653. } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Spc_t;
  654. /* Disable C linkage for C++ Compilers: */
  655. #if defined(__cplusplus)
  656. }
  657. #endif
  658. #endif
  659. /** @} */