47 if (g_uac_dev[i].udev ==
NULL)
49 memset((
char *)&g_uac_dev[i], 0,
sizeof(
UAC_DEV_T));
56 static void free_uac_device(
UAC_DEV_T *uac)
70 if (g_uac_dev[i].udev == udev)
79 static int uac_probe(IFACE_T *iface)
81 UDEV_T *udev = iface->udev;
82 ALT_IFACE_T *aif = iface->aif;
85 uint8_t bAlternateSetting;
91 if (ifd->bInterfaceClass != USB_CLASS_AUDIO)
94 if ((ifd->bInterfaceSubClass != SUBCLS_AUDIOCONTROL) &&
95 (ifd->bInterfaceSubClass != SUBCLS_AUDIOSTREAMING))
97 UAC_ERRMSG(
"Audio class interface, but sub-class %x not supported!\n", ifd->bInterfaceSubClass);
101 UAC_DBGMSG(
"\nuac_probe - device (vid=0x%x, pid=0x%x), interface %d, type: %s\n",
102 udev->descriptor.idVendor, udev->descriptor.idProduct, iface->if_num, (ifd->bInterfaceSubClass == SUBCLS_AUDIOCONTROL) ?
"CONTROL" :
"STREAM");
104 uac = find_uac_device(udev);
109 uac = alloc_uac_device();
114 uac->
state = UAC_STATE_CONNECTING;
118 if (g_uac_list ==
NULL)
130 iface->context = (
void *)uac;
132 if (ifd->bInterfaceSubClass == SUBCLS_AUDIOSTREAMING)
134 if ((usbh_uac_find_max_alt(iface, EP_ADDR_DIR_IN, EP_ATTR_TT_ISO, &bAlternateSetting) == 0) ||
135 (usbh_uac_find_max_alt(iface, EP_ADDR_DIR_OUT, EP_ATTR_TT_ISO, &bAlternateSetting) == 0))
137 ret = usbh_set_interface(iface, bAlternateSetting);
140 UAC_ERRMSG(
"Failed to set interface %d, %d! (%d)\n", iface->if_num, bAlternateSetting, ret);
146 UAC_ERRMSG(
"Cannot find audio stream endpoints!\n");
150 ret = uac_parse_streaming_interface(uac, iface, bAlternateSetting);
154 else if (ifd->bInterfaceSubClass == SUBCLS_AUDIOCONTROL)
156 ret = uac_parse_control_interface(uac, iface);
161 UAC_DBGMSG(
"UAC device 0x%x ==>\n", (
int)uac);
162 UAC_DBGMSG(
" CONTROL IFACE: 0x%x\n", (
int)uac->
acif.
iface);
163 UAC_DBGMSG(
" STREAM IN IFACE: 0x%x\n", (
int)uac->
asif_in.
iface);
164 UAC_DBGMSG(
" STREAM OUT IFACE: 0x%x\n", (
int)uac->
asif_out.
iface);
169 static void uac_disconnect(IFACE_T *iface)
177 uac->
state = UAC_STATE_DISCONNECTING;
179 UAC_DBGMSG(
"uac_disconnect - device (vid=0x%x, pid=0x%x), interface %d removed.\n",
180 uac->
udev->descriptor.idVendor, uac->
udev->descriptor.idProduct, iface->if_num);
187 if (g_uac_dev[i].udev == iface->udev)
213 if (uac == g_uac_list)
215 g_uac_list = g_uac_list->
next;
219 for (p = g_uac_list; p !=
NULL; p = p->
next)
228 UAC_DBGMSG(
"uac_disconnect - device (vid=0x%x, pid=0x%x), UAC device removed.\n",
229 uac->
udev->descriptor.idVendor, uac->
udev->descriptor.idProduct);
230 free_uac_device(uac);
235 UDEV_DRV_T uac_driver =
252 memset((
char *)&g_uac_dev[0], 0,
sizeof(g_uac_dev));
254 usbh_register_driver(&uac_driver);
struct uac_dev_t * usbh_uac_get_device_list(void)
Get a list of currently connected USB Audio Class devices.
USB Host UAC class driver header file.
#define UAC_RET_DEV_NOT_FOUND
int usbh_uac_stop_audio_in(struct uac_dev_t *audev)
Stop UAC device audio in data stream.
NuMicro peripheral access layer header file.
M480 MCU USB Host Audio Class header file.
USB Host library exported header file.
#define UAC_RET_OUT_OF_MEMORY
HIDDEN_SYMBOLS void usbh_uac_init(void)
Initialize USB Audio Class driver.
int usbh_uac_stop_audio_out(struct uac_dev_t *audev)
Stop UAC device audio out data stream.
#define CONFIG_UAC_MAX_DEV
USB Host library header file.
#define NULL
NULL pointer.
#define USBH_ERR_NOT_MATCHED