| M480 BSP V3.05.001 The Board Support Package for M480 Series

uac.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __INCLUDED_UAC_H__
10 #define __INCLUDED_UAC_H__
11
12
14
15 //#define UAC_DEBUG
16
17 /*
18 * Debug message
19 */
20 #define UAC_ERRMSG printf
21 #ifdef UAC_DEBUG
22 #define UAC_DBGMSG printf
23 #else
24 #define UAC_DBGMSG(...)
25 #endif
26
27 typedef enum
28 {
29 UAC_STATE_CONNECTING,
30 UAC_STATE_READY,
31 UAC_STATE_RUNNING,
32 UAC_STATE_DISCONNECTING,
33 } UAC_STATE_E;
34
35
36 /* Audio Interface Subclass Codes (A.2) */
37 #define SUBCLS_UNDEFINED 0x00
38 #define SUBCLS_AUDIOCONTROL 0x01
39 #define SUBCLS_AUDIOSTREAMING 0x02
40 #define SUBCLS_MIDISTREAMING 0x03
41
42 /* Audio Interface Protocol Code (A.3) */
43 #define PR_PROTOCOL_UNDEFINED 0x00
44
45 /* Audio Class-specific descritpor types (A.4) */
46 #define CS_UNDEFINED 0x20
47 #define CS_DEVICE 0x21
48 #define CS_CONFIGURATION 0x22
49 #define CS_STRING 0x23
50 #define CS_INTERFACE 0x24
51 #define CS_ENDPOINT 0x25
52
53 /* Audio Class-Specific AC Interface Descriptor Subtypes (A.5) */
54 #define AC_DESCRIPTOR_UNDEFINED 0x00
55 #define HEADER 0x01
56 #define INPUT_TERMINAL 0x02
57 #define OUTPUT_TERMINAL 0x03
58 #define MIXER_UNIT 0x04
59 #define SELECTOR_UNIT 0x05
60 #define FEATURE_UNIT 0x06
61 #define PROCESSING_UNIT 0x07
62 #define EXTENSION_UNIT 0x08
63
64 /* Audio Class-Specific AS Interface Descriptor Subtypes (A.6) */
65 #define AS_DESCRIPTOR_UNDEFINED 0x00
66 #define AS_GENERAL 0x01
67 #define FORMAT_TYPE 0x02
68 #define FORMAT_SPECIFIC 0x03
69
70 /* Processing Unit Process Types (A.7) */
71 #define PROCESS_UNDEFINED 0x00
72 #define UP_DOWNMIX_PROCESS 0x01
73 #define DOLBY_PROLOGIC_PROCESS 0x02
74 #define _3D_STEREO_EXTENDER_PROCESS 0x03
75 #define REVERBERATION_PROCESS 0x04
76 #define CHORUS_PROCESS 0x05
77 #define DYN_RANGE_COMP_PROCESS 0x06
78
79 /* Audio Class-Specific Endpoint Descriptor Subtypes (A.8) */
80 #define DESCRIPTOR_UNDEFINED 0x00
81 #define EP_GENERAL 0x01
82
83 /* Audio Class-Specific Request Codes (A.9) */
84 #define REQUEST_CODE_UNDEFINED 0x00
85 #define SET_CUR 0x01
86 #define GET_CUR 0x81
87 #define SET_MIN 0x02
88 #define GET_MIN 0x82
89 #define SET_MAX 0x03
90 #define GET_MAX 0x83
91 #define SET_RES 0x04
92 #define GET_RES 0x84
93 #define SET_MEM 0x05
94 #define GET_MEM 0x85
95 #define GET_STAT 0xFF
96
97 /* Terminal Control Selectors (A.10.1) */
98 #define TE_CONTROL_UNDEFINED 0x00
99 #define COPY_PROTECT_CONTROL 0x01
100
101 /* Feature Unit Control Selectors (A.10.2) */
102 #define FU_CONTROL_UNDEFINED 0x00
103 #define MUTE_CONTROL 0x01
104 #define VOLUME_CONTROL 0x02
105 #define BASS_CONTROL 0x03
106 #define MID_CONTROL 0x04
107 #define TREBLE_CONTROL 0x05
108 #define GRAPHIC_EQUALIZER_CONTROL 0x06
109 #define AUTOMATIC_GAIN_CONTROL 0x07
110 #define DELAY_CONTROL 0x08
111 #define BASS_BOOST_CONTROL 0x09
112 #define LOUDNESS_CONTROL 0x0A
113
114 /* Up/Down-mix Processing Unit Control Selectors (A.10.3.1) */
115 #define UD_CONTROL_UNDEFINED 0x00
116 #define UD_ENABLE_CONTROL 0x01
117 #define UD_MODE_SELECT_CONTROL 0x02
118
119 /* Dolby Prologic Processing Unit Control Selectors (A.10.3.2) */
120 #define DP_CONTROL_UNDEFINED 0x00
121 #define DP_ENABLE_CONTROL 0x01
122 #define DP_MODE_SELECT_CONTROL 0x02
123
124 /* 3D Stereo Extender Processing Unit Control Selectors (A.10.3.3) */
125 #define _3D_CONTROL_UNDEFINED 0x00
126 #define _3D_ENABLE_CONTROL 0x01
127 #define SPACIOUSNESS_CONTROL 0x03
128
129 /* Reverberation Processing Unit Control Selectors (A.10.3.4) */
130 #define RV_CONTROL_UNDEFINED 0x00
131 #define RV_ENABLE_CONTROL 0x01
132 #define REVERB_LEVEL_CONTROL 0x02
133 #define REVERB_TIME_CONTROL 0x03
134 #define REVERB_FEEDBACK_CONTROL 0x04
135
136 /* Chorus Processing Unit Control Selectors (A.10.3.5) */
137 #define CH_CONTROL_UNDEFINED 0x00
138 #define CH_ENABLE_CONTROL 0x01
139 #define CHORUS_LEVEL_CONTROL 0x02
140 #define CHORUS_RATE_CONTROL 0x03
141 #define CHORUS_DEPTH_CONTROL 0x04
142
143 /* Dynamic Range Compressor Processing Unit Control Selectors (A.10.3.6) */
144 #define DR_CONTROL_UNDEFINED 0x00
145 #define DR_ENABLE_CONTROL 0x01
146 #define COMPRESSION_RATE_CONTROL 0x02
147 #define MAXAMPL_CONTROL 0x03
148 #define THRESHOLD_CONTROL 0x04
149 #define ATTACK_TIME 0x05
150 #define RELEASE_TIME 0x06
151
152 /* Extension Unit Control Selectors (A.10.4) */
153 #define XU_CONTROL_UNDEFINED 0x00
154 #define XU_ENABLE_CONTROL 0x01
155
156 /* Endpoint Control Selectors (A.10.5) */
157 #define EP_CONTROL_UNDEFINED 0x00
158 #define SAMPLING_FREQ_CONTROL 0x01
159 #define PITCH_CONTROL 0x02
160
161 /* Format Type Codes of Format Type Descriptor bFormatType field */
162 #define FORMAT_TYPE_UNDEFINED 0x00
163 #define FORMAT_TYPE_I 0x01
164 #define FORMAT_TYPE_II 0x02
165 #define FORMAT_TYPE_III 0x03
166
167
168 /*-----------------------------------------------------------------------------------
169 * Audio Class Control Interface Descriptor header
170 */
171 #ifdef __ICCARM__
172 typedef struct cs_hdr_t
173 {
174 __packed uint8_t bLength;
175 __packed uint8_t bDescriptorType;
176 __packed uint8_t bDescriptorSubtype;
177 } CS_HDR_T;
178 #else
179 typedef struct __attribute__((__packed__)) cs_hdr_t
180 {
181 uint8_t bLength;
182 uint8_t bDescriptorType;
183 uint8_t bDescriptorSubtype;
184 } CS_HDR_T;
185 #endif
186
187 /*-----------------------------------------------------------------------------------
188 * Class-Specific AC Interface Header Descriptor (4.3.2)
189 */
190 #ifdef __ICCARM__
191 typedef struct ac_if_header
192 {
193 __packed uint8_t bLength;
194 __packed uint8_t bDescriptorType;
195 __packed uint8_t bDescriptorSubtype;
196 __packed uint16_t bcdADC;
197 __packed uint16_t wTotalLength;
200 __packed uint8_t bInCollection;
202 } AC_IF_HDR_T;
203 #else
204 typedef struct __attribute__((__packed__)) ac_if_header
205 {
206 uint8_t bLength;
207 uint8_t bDescriptorType;
208 uint8_t bDescriptorSubtype;
209 uint16_t bcdADC;
210 uint16_t wTotalLength;
213 uint8_t bInCollection;
215 } AC_IF_HDR_T;
216 #endif
217
218 /*-----------------------------------------------------------------------------------
219 * UAC Input Terminal Descriptor
220 */
221 #ifdef __ICCARM__
222 typedef struct ac_itd_t
223 {
224 __packed uint8_t bLength;
225 __packed uint8_t bDescriptorType;
226 __packed uint8_t bDescriptorSubtype;
227 __packed uint8_t bTerminalID;
228 __packed uint16_t wTerminalType;
229 __packed uint8_t bAssocTerminal;
230 __packed uint8_t bNrChannels;
231 __packed uint16_t wChannelConfig;
232 __packed uint8_t iChannelNames;
233 __packed uint8_t iTerminal;
234 } AC_IT_T;
235 #else
236 typedef struct __attribute__((__packed__)) ac_itd_t
237 {
238 uint8_t bLength;
239 uint8_t bDescriptorType;
240 uint8_t bDescriptorSubtype;
241 uint8_t bTerminalID;
242 uint16_t wTerminalType;
243 uint8_t bAssocTerminal;
244 uint8_t bNrChannels;
245 uint16_t wChannelConfig;
246 uint8_t iChannelNames;
247 uint8_t iTerminal;
248 } AC_IT_T;
249 #endif
250
251 /*-----------------------------------------------------------------------------------
252 * UAC Output Terminal Descriptor
253 */
254 #ifdef __ICCARM__
255 typedef struct ac_otd_t
256 {
257 __packed uint8_t bLength;
258 __packed uint8_t bDescriptorType;
259 __packed uint8_t bDescriptorSubtype;
260 __packed uint8_t bTerminalID;
261 __packed uint16_t wTerminalType;
262 __packed uint8_t bAssocTerminal;
263 __packed uint8_t bSourceID;
264 __packed uint8_t iTerminal;
265 } AC_OT_T;
266 #else
267 typedef struct __attribute__((__packed__)) ac_otd_t
268 {
269 uint8_t bLength;
270 uint8_t bDescriptorType;
271 uint8_t bDescriptorSubtype;
272 uint8_t bTerminalID;
273 uint16_t wTerminalType;
274 uint8_t bAssocTerminal;
275 uint8_t bSourceID;
276 uint8_t iTerminal;
277 } AC_OT_T;
278 #endif
279
280 /*---------------------------------*/
281 /* Terminal Types */
282 /*---------------------------------*/
283 /* USB Terminal Types */
284 #define UAC_TT_USB_UNDEFINED 0x0100 /* USB Terminal, undefined Type. */
285 #define UAC_TT_USB_STREAMING 0x0101 /* A Terminal dealing with a signal carried
286 over an endpoint in an AudioStreaming
287 interface. The AudioStreaming interface. */
288 #define UAC_TT_USB_VENDOR 0x01FF /* A Terminal dealing with a signal carried
289 over a vendor-specific interface. */
290 /* Input Terminal Types */
291 #define UAC_TT_INPUT_UNDEFINED 0x0200 /* Input Terminal, undefined Type. */
292 #define UAC_TT_MICROPHONE 0x0201 /* A generic microphone that does not fit
293 under any of the other classifications. */
294 #define UAC_TT_DESKTOP_MICROPHONE 0x0202 /* A microphone normally placed on the desktop
295 or integrated into the monitor. */
296 #define UAC_TT_PERSONAL_MICROPHONE 0x0203 /* A head-mounted or clip-on microphone. */
297 #define UAC_TT_OMNI_MICROPHONE 0x0204 /* A microphone designed to pick up voice from
298 more than one speaker at relatively long
299 ranges. */
300 #define UAC_TT_MICROPHONE_ARRAY 0x0205 /* An array of microphones designed for
301 directional processing using host-based
302 signal processing algorithms. */
303 /* Output Terminal Types */
304 #define UAC_TT_OUTPUT_UNDEFINED 0x0300 /* Output Terminal, undefined Type. */
305 #define UAC_TT_SPEAKER 0x0301 /* A generic speaker or set of speakers that
306 doe not fit under any of the other
307 classifications. */
308 #define UAC_TT_HEADPHONES 0x0302 /* A head-mounted audio output device. */
309 #define UAC_TT_HEAD_MOUNTED 0x0303 /* The audio part of a VR head mounted display.
310 The Associated Interfaces descriptor can
311 be used to reference the HID interface used
312 to report the position and orientation of
313 the HMD. */
314 #define UAC_TT_DESKTOP_SPEAKER 0x0304 /* Relatively small speaker or set of speakers
315 normally placed on the desktop or
316 integrated into the monitor. These speakers
317 are close to the user and have limited
318 stereo separation. */
319 #define UAC_TT_ROOM_SPEAKER 0x0305 /* Larger speaker or set of speakers that are
320 heard well anywhere in the room. */
321 #define UAC_TT_COMM_SPEAKER 0x0306 /* Speaker or set of speakers designed for
322 voice communication. */
323 #define UAC_TT_LFE_SPEAKER 0x0307 /* Speaker designed for low frequencies
324 (subwoofer). Not capable of reproducing
325 speech or music. */
326
327 /*----------------------------------------------------------------------------------------*/
328 /* UAC Mixer Unit Descriptor */
329 /*----------------------------------------------------------------------------------------*/
330 #ifdef __ICCARM__
331 typedef struct ac_mxr_t
332 {
333 __packed uint8_t bLength;
334 __packed uint8_t bDescriptorType;
335 __packed uint8_t bDescriptorSubtype;
336 __packed uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
337 __packed uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
338 } AC_MXR_T;
339 #else
340 typedef struct __attribute__((__packed__)) ac_mxr_t
341 {
342 uint8_t bLength;
343 uint8_t bDescriptorType;
344 uint8_t bDescriptorSubtype;
345 uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
346 uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
347 } AC_MXR_T;
348 #endif
349
350 /*-----------------------------------------------------------------------------------
351 * UAC Selector Unit Descriptor
352 */
353 #ifdef __ICCARM__
354 typedef struct ac_su_t
355 {
356 __packed uint8_t bLength;
357 __packed uint8_t bDescriptorType;
358 __packed uint8_t bDescriptorSubtype;
359 __packed uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
360 __packed uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
361 } AC_SU_T;
362 #else
363 typedef struct __attribute__((__packed__)) ac_su_t
364 {
365 uint8_t bLength;
366 uint8_t bDescriptorType;
367 uint8_t bDescriptorSubtype;
368 uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
369 uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
370 } AC_SU_T;
371 #endif
372
373 /*-----------------------------------------------------------------------------------
374 * UAC Feature Unit Descriptor
375 */
376 #ifdef __ICCARM__
377 typedef struct ac_fu_t
378 {
379 __packed uint8_t bLength;
380 __packed uint8_t bDescriptorType;
381 __packed uint8_t bDescriptorSubtype;
382 __packed uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
383 __packed uint8_t bSourceID; /* ID of the Unit or Terminal to which this Feature Unit is connected. */
384 __packed uint8_t bControlSize; /* Size in bytes of an element of the bmaControls() array: n */
385 } AC_FU_T;
386 #else
387 typedef struct __attribute__((__packed__)) ac_fu_t
388 {
389 uint8_t bLength;
390 uint8_t bDescriptorType;
391 uint8_t bDescriptorSubtype;
392 uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
393 uint8_t bSourceID; /* ID of the Unit or Terminal to which this Feature Unit is connected. */
394 uint8_t bControlSize; /* Size in bytes of an element of the bmaControls() array: n */
395 } AC_FU_T;
396 #endif
397
398 /* Feature Unit Control Selectors */
399 #define FU_CONTROL_UNDEFINED 0x00
400 #define MUTE_CONTROL 0x01 /* Feature Unit Descriptor bmaControls bit 0 */
401 #define VOLUME_CONTROL 0x02 /* Feature Unit Descriptor bmaControls bit 1 */
402 #define BASS_CONTROL 0x03 /* Feature Unit Descriptor bmaControls bit 2 */
403 #define MID_CONTROL 0x04
404 #define TREBLE_CONTROL 0x05
405 #define GRAPHIC_EQUALIZER_CONTROL 0x06
406 #define AUTOMATIC_GAIN_CONTROL 0x07
407 #define DELAY_CONTROL 0x08
408 #define BASS_BOOST_CONTROL 0x09
409 #define LOUDNESS_CONTROL 0x0A
410
411 /*-----------------------------------------------------------------------------------
412 * UAC AS Isochronous Audio Data Endpoint Descriptor
413 */
414 #ifdef __ICCARM__
415 typedef struct as_gen_t
416 {
417 __packed uint8_t bLength;
418 __packed uint8_t bDescriptorType;
419 __packed uint8_t bDescriptorSubtype;
420 __packed uint8_t bTerminalLink;
421 __packed uint8_t bDelay;
422 __packed uint16_t wFormatTag;
423 } AS_GEN_T;
424 #else
425 typedef struct __attribute__((__packed__)) as_gen_t
426 {
427 uint8_t bLength;
428 uint8_t bDescriptorType;
429 uint8_t bDescriptorSubtype;
430 uint8_t bTerminalLink;
431 uint8_t bDelay;
432 uint16_t wFormatTag;
433 } AS_GEN_T;
434 #endif
435
436 /*-----------------------------------------------------------------------------------
437 * UAC Processing Unit Descriptor
438 */
439 #ifdef __ICCARM__
440 typedef struct ac_pu_t
441 {
442 __packed uint8_t bLength;
443 __packed uint8_t bDescriptorType;
444 __packed uint8_t bDescriptorSubtype;
445 __packed uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
446 __packed uint16_t wProcessType; /* Constant identifying the type of processing this Unit is performing. */
447 __packed uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
448 } AC_PU_T;
449 #else
450 typedef struct __attribute__((__packed__)) ac_pu_t
451 {
452 uint8_t bLength;
453 uint8_t bDescriptorType;
454 uint8_t bDescriptorSubtype;
455 uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */
456 uint16_t wProcessType; /* Constant identifying the type of processing this Unit is performing. */
457 uint8_t bNrInPins; /* Number of Input Pins of this Unit: p */
458 } AC_PU_T;
459 #endif
460
461 /*-----------------------------------------------------------------------------------
462 * Class-Specific AS Isochronous Audio Data Endpoint Descriptor
463 */
464 #ifdef __ICCARM__
465 typedef struct cs_ep_t
466 {
467 __packed uint8_t bLength;
468 __packed uint8_t bDescriptorType;
469 __packed uint8_t bDescriptorSubtype;
470 __packed uint8_t bmAttributes;
471 __packed uint8_t bLockDelayUnits;
472 __packed uint16_t wLockDelay;
473 } CS_EP_T;
474 #else
475 typedef struct __attribute__((__packed__)) cs_ep_t
476 {
477 uint8_t bLength;
478 uint8_t bDescriptorType;
479 uint8_t bDescriptorSubtype;
480 uint8_t bmAttributes;
481 uint8_t bLockDelayUnits;
482 uint16_t wLockDelay;
483 } CS_EP_T;
484 #endif
485
486 /*-----------------------------------------------------------------------------------
487 * UAC Type I Format Type Descriptor
488 */
489 #ifdef __ICCARM__
490 typedef struct ac_ft1_t
491 {
492 __packed uint8_t bLength;
493 __packed uint8_t bDescriptorType;
494 __packed uint8_t bDescriptorSubtype;
495 __packed uint8_t bFormatType;
496 __packed uint8_t bNrChannels;
497 __packed uint8_t bSubframeSize;
498 __packed uint8_t bBitResolution;
499 __packed uint8_t bSamFreqType;
500 __packed uint8_t tSamFreq[16][3];
501 } AS_FT1_T;
502 #else
503 typedef struct __attribute__((__packed__)) ac_ft1_t
504 {
505 uint8_t bLength;
506 uint8_t bDescriptorType;
507 uint8_t bDescriptorSubtype;
508 uint8_t bFormatType;
509 uint8_t bNrChannels;
510 uint8_t bSubframeSize;
511 uint8_t bBitResolution;
512 uint8_t bSamFreqType;
513 uint8_t tSamFreq[16][3];
514 } AS_FT1_T;
515 #endif
516
517 /*-----------------------------------------------------------------------------------
518 * UAC Type 2 Format Type Descriptor
519 */
520 #ifdef __ICCARM__
521 typedef struct ac_ft2_t
522 {
523 __packed uint8_t bLength;
524 __packed uint8_t bDescriptorType;
525 __packed uint8_t bDescriptorSubtype;
526 __packed uint8_t bFormatType;
527 __packed uint16_t wMaxBitRate;
528 __packed uint16_t wSamplesPerFrame;
529 __packed uint8_t bSamFreqType;
530 } AS_FT2_T;
531 #else
532 typedef struct __attribute__((__packed__)) ac_ft2_t
533 {
534 uint8_t bLength;
535 uint8_t bDescriptorType;
536 uint8_t bDescriptorSubtype;
537 uint8_t bFormatType;
538 uint16_t wMaxBitRate;
539 uint16_t wSamplesPerFrame;
540 uint8_t bSamFreqType;
541 } AS_FT2_T;
542 #endif
543
544 /*-----------------------------------------------------------------------------------
545 * UAC Type 3 Format Type Descriptor
546 */
547 #ifdef __ICCARM__
548 typedef struct ac_ft3_t
549 {
550 __packed uint8_t bLength;
551 __packed uint8_t bDescriptorType;
552 __packed uint8_t bDescriptorSubtype;
553 __packed uint8_t bFormatType;
554 __packed uint8_t bNrChannels;
555 __packed uint8_t bSubframeSize;
556 __packed uint8_t bBitResolution;
557 __packed uint8_t bSamFreqType;
558 __packed uint8_t tLowerSamFreq[3];
559 __packed uint8_t tUpperSamFreq[3];
560 } AS_FT3_T;
561 #else
562 typedef struct __attribute__((__packed__)) ac_ft3_t
563 {
564 uint8_t bLength;
565 uint8_t bDescriptorType;
566 uint8_t bDescriptorSubtype;
567 uint8_t bFormatType;
568 uint8_t bNrChannels;
569 uint8_t bSubframeSize;
570 uint8_t bBitResolution;
571 uint8_t bSamFreqType;
572 uint8_t tLowerSamFreq[3];
573 uint8_t tUpperSamFreq[3];
574 } AS_FT3_T;
575 #endif
576
577
579
580
581 #endif /* __INCLUDED_UAC_H__ */
582
583 /*** (C) COPYRIGHT 2017 Nuvoton Technology Corp. ***/
584
__attribute__
void *__dso_handle __attribute__((weak))
Definition: _syscalls.c:35