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