| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

usbh_uac.h
Go to the documentation of this file.
1#ifndef __INCLUDED_USBHUAC_H__
2#define __INCLUDED_USBHUAC_H__
3
4#include "usbh_core.h"
5
19#define CONFIG_AU_MAX_DEV 1
20#define MAX_CFG_DESC_SIZE 336
21#define MAX_FEATURE_UNIT 8
22#define ISO_IN_URB_CNT 2
23#define ISO_OUT_URB_CNT 2
24#define AU_IN_MAX_PKTSZ 256
25#define AU_OUT_MAX_PKTSZ 256
26#define UAC_REQ_TIMEOUT 10000
28#define UAC_SPEAKER 1
29#define UAC_MICROPHONE 2
32/*
33 * Constants
34 */
35#define UAC_RET_OK 0
36#define UAC_RET_DEV_NOT_FOUND -9
37#define UAC_RET_IO_ERR -11
38#define UAC_RET_INVALID -13
39#define UAC_RET_OUT_OF_MEMORY -15
40#define UAC_RET_DRV_NOT_SUPPORTED -17
41#define UAC_RET_DEV_NOT_SUPPORTED -19
44/*
45 * Audio Class-Specific Request Codes
46 */
47#define UAC_SET_CUR 0x01
48#define UAC_GET_CUR 0x81
49#define UAC_SET_MIN 0x02
50#define UAC_GET_MIN 0x82
51#define UAC_SET_MAX 0x03
52#define UAC_GET_MAX 0x83
53#define UAC_SET_RES 0x04
54#define UAC_GET_RES 0x84
55#define UAC_GET_STAT 0xFF
57/*
58 * Audio Class-Specific Channel selection
59 */
60#define UAC_CH_MASTER 0
61#define UAC_CH_LEFT_FRONT 1
62#define UAC_CH_RIGHT_FRONT 2
63#define UAC_CH_CENTER_FRONT 3
64#define UAC_CH_LOW_FREQ_EN 4
65#define UAC_CH_LEFT_SRN 5
66#define UAC_CH_RIGHT_SRN 6
67#define UAC_CH_LEFT_OF_CENTER 7
68#define UAC_CH_RIGHT_OF_CENTER 8
69#define UAC_CH_SURROUND 9
70#define UAC_CH_SIDE_LEFT 10
71#define UAC_CH_SIDE_RIGHT 11
72#define UAC_CH_TOP 12 /* end of group NUC472_442_USBH_AS_EXPORTED_CONSTANTS */
77
78struct uac_dev_t;
79
80
85 typedef int (UAC_CB_FUNC)(struct uac_dev_t *dev, uint8_t *data, int len); /* end of group NUC472_442_USBH_AS_EXPORTED_TYPEDEFS */
89
90
95/*-----------------------------------------------------------------------------------
96 * Audio Class device
97 */
99 typedef struct uac_dev_t
100{
101 USB_DEV_T *udev;
102 int ctrl_ifnum;
103 int au_in_ifnum;
104 int au_out_ifnum;
105 void *priv;
106 struct uac_dev_t *next;
108 /*
109 * The followings are used for audio streaming.
110 */
111 EP_INFO_T *ep_au_in;
112 EP_INFO_T *ep_au_out;
113 URB_T * urbin[ISO_IN_URB_CNT];
114 URB_T * urbout[ISO_OUT_URB_CNT];
115 uint8_t iso_inbuf[ISO_IN_URB_CNT][AU_IN_MAX_PKTSZ*ISO_FRAME_COUNT];
116 uint8_t iso_outbuf[ISO_OUT_URB_CNT][AU_OUT_MAX_PKTSZ*ISO_FRAME_COUNT];
117 uint8_t in_streaming;
118 uint8_t out_streaming;
120 /*
121 * The followings are used for interworking with user application.
122 */
123 UAC_CB_FUNC *au_in_func;
124 UAC_CB_FUNC *au_out_func;
125 uint8_t *au_in_buff;
126 int au_in_bufsz;
127 int au_in_bufidx;
128} UAC_DEV_T; /* end of group NUC472_442_USBH_AS_EXPORTED_STRUCTURES */
132
133
134#ifdef __cplusplus
135extern "C" {
136#endif
137
142void UAC_Init(void);
143 UAC_DEV_T * UAC_GetDeviceList(void);
144
145int32_t UAC_GetChannelNumber(UAC_DEV_T *audev, uint8_t target);
146int32_t UAC_GetBitResolution(UAC_DEV_T *audev, uint8_t target, uint8_t *val8);
147int32_t UAC_GetSamplingRate(UAC_DEV_T *audev, uint8_t target, uint32_t *srate_list, int max_cnt, uint8_t *type);
148int32_t UAC_MuteControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *data);
149int32_t UAC_VolumeControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint16_t *volume);
150int32_t UAC_AutoGainControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *gain);
151int32_t UAC_SamplingRateControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint32_t *srate);
152
153int32_t UAC_InstallIsoInCbFun(UAC_DEV_T *audev, uint8_t *au_in_buff, int bufsiz, UAC_CB_FUNC *func);
154int32_t UAC_StartIsoInPipe(UAC_DEV_T *audev);
155int32_t UAC_StopIsoInPipe(UAC_DEV_T *audev);
156
157int32_t UAC_InstallIsoOutCbFun(UAC_DEV_T *audev, UAC_CB_FUNC *func);
158int32_t UAC_StartIsoOutPipe(UAC_DEV_T *audev);
159int32_t UAC_StopIsoOutPipe(UAC_DEV_T *audev);
160
161 /* end of group NUC472_442_USBH_AS_EXPORTED_FUNCTIONS */
163 /* end of group NUC472_442_USBH_AS_Driver */
165 /* end of group NUC472_442_Device_Driver */
167
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* __INCLUDED_USBHUAC_H__ */
174
175/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
176
ISO_OUT_URB_CNT
#define ISO_OUT_URB_CNT
Definition: usbh_uac.h:23
AU_IN_MAX_PKTSZ
#define AU_IN_MAX_PKTSZ
Definition: usbh_uac.h:24
ISO_IN_URB_CNT
#define ISO_IN_URB_CNT
Definition: usbh_uac.h:22
AU_OUT_MAX_PKTSZ
#define AU_OUT_MAX_PKTSZ
Definition: usbh_uac.h:25
uac_dev_t::ctrl_ifnum
int ctrl_ifnum
Definition: usbh_uac.h:102
UAC_StartIsoOutPipe
int32_t UAC_StartIsoOutPipe(UAC_DEV_T *audev)
Start to send audio data to UAC device via isochronous out pipe.
Definition: uac_core.c:776
uac_dev_t::au_in_bufsz
int au_in_bufsz
Definition: usbh_uac.h:126
uac_dev_t::ep_au_out
EP_INFO_T * ep_au_out
Definition: usbh_uac.h:112
UAC_AutoGainControl
int32_t UAC_AutoGainControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *gain)
Audio Class device automatic gain control.
Definition: uac_core.c:435
UAC_StopIsoOutPipe
int32_t UAC_StopIsoOutPipe(UAC_DEV_T *audev)
Stop UAC device audio out data stream.
Definition: uac_core.c:865
uac_dev_t::ep_au_in
EP_INFO_T * ep_au_in
Definition: usbh_uac.h:111
UAC_MuteControl
int32_t UAC_MuteControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *data)
Control Audio Class device mute on/off.
Definition: uac_core.c:269
UAC_GetChannelNumber
int32_t UAC_GetChannelNumber(UAC_DEV_T *audev, uint8_t target)
Obtain Audio Class device's channel number.
Definition: uac_core.c:46
uac_dev_t::priv
void * priv
Definition: usbh_uac.h:105
UAC_GetBitResolution
int32_t UAC_GetBitResolution(UAC_DEV_T *audev, uint8_t target, uint8_t *val8)
Obtain Audio Class device subframe bit resolution..
Definition: uac_core.c:79
uac_dev_t::au_out_ifnum
int au_out_ifnum
Definition: usbh_uac.h:104
uac_dev_t::au_out_func
UAC_CB_FUNC * au_out_func
Definition: usbh_uac.h:124
uac_dev_t::au_in_bufidx
int au_in_bufidx
Definition: usbh_uac.h:127
uac_dev_t::udev
USB_DEV_T * udev
Definition: usbh_uac.h:101
uac_dev_t::iso_outbuf
uint8_t iso_outbuf[ISO_OUT_URB_CNT][AU_OUT_MAX_PKTSZ *ISO_FRAME_COUNT]
Definition: usbh_uac.h:116
uac_dev_t::next
struct uac_dev_t * next
Definition: usbh_uac.h:106
UAC_Init
void UAC_Init(void)
Initialize this USB Audio Class driver.
Definition: uac_driver.c:261
UAC_GetSamplingRate
int32_t UAC_GetSamplingRate(UAC_DEV_T *audev, uint8_t target, uint32_t *srate_list, int max_cnt, uint8_t *type)
Get a list of sampling rate frequences supported by the UAC device.
Definition: uac_core.c:130
uac_dev_t::out_streaming
uint8_t out_streaming
Definition: usbh_uac.h:118
UAC_InstallIsoOutCbFun
int32_t UAC_InstallIsoOutCbFun(UAC_DEV_T *audev, UAC_CB_FUNC *func)
Install isochronous-out (speaker) callback function. The UAC driver will call the callback function t...
Definition: uac_core.c:749
uac_dev_t::au_in_buff
uint8_t * au_in_buff
Definition: usbh_uac.h:125
UAC_SamplingRateControl
int32_t UAC_SamplingRateControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint32_t *srate)
Set sampling rate frequency.
Definition: uac_core.c:184
uac_dev_t::in_streaming
uint8_t in_streaming
Definition: usbh_uac.h:117
UAC_VolumeControl
int32_t UAC_VolumeControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint16_t *volume)
Audio Class device volume control.
Definition: uac_core.c:362
UAC_StopIsoInPipe
int32_t UAC_StopIsoInPipe(UAC_DEV_T *audev)
Stop UAC device audio in data stream.
Definition: uac_core.c:674
uac_dev_t::urbout
URB_T * urbout[ISO_OUT_URB_CNT]
Definition: usbh_uac.h:114
uac_dev_t::au_in_ifnum
int au_in_ifnum
Definition: usbh_uac.h:103
UAC_InstallIsoInCbFun
int32_t UAC_InstallIsoInCbFun(UAC_DEV_T *audev, uint8_t *au_in_buff, int bufsiz, UAC_CB_FUNC *func)
Install isochronous-in (microphone) callback function. Received audio data from UAC device will be de...
Definition: uac_core.c:559
UAC_GetDeviceList
UAC_DEV_T * UAC_GetDeviceList(void)
Get a list of currently connected USB Audio Class devices.
Definition: uac_driver.c:277
uac_dev_t::au_in_func
UAC_CB_FUNC * au_in_func
Definition: usbh_uac.h:123
uac_dev_t::iso_inbuf
uint8_t iso_inbuf[ISO_IN_URB_CNT][AU_IN_MAX_PKTSZ *ISO_FRAME_COUNT]
Definition: usbh_uac.h:115
uac_dev_t::urbin
URB_T * urbin[ISO_IN_URB_CNT]
Definition: usbh_uac.h:113
UAC_StartIsoInPipe
int32_t UAC_StartIsoInPipe(UAC_DEV_T *audev)
Start to receive audio data from UAC device via isochronous in pipe.
Definition: uac_core.c:589
UAC_DEV_T
struct uac_dev_t UAC_DEV_T
UAC_CB_FUNC
int() UAC_CB_FUNC(struct uac_dev_t *dev, uint8_t *data, int len)
Definition: usbh_uac.h:85
ISO_FRAME_COUNT
#define ISO_FRAME_COUNT
Definition: usbh_config.h:59
USB_DEV_T
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
uac_dev_t
Definition: usbh_uac.h:100
urb_t
Definition: usbh_core.h:537
usbh_core.h
USB Host core driver header file.