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