48 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
55 if (!uac_info->ft_play)
57 return uac_info->ft_play->bNrChannels;
61 if (!uac_info->ft_rec)
63 return uac_info->ft_rec->bNrChannels;
81 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
88 if (!uac_info->ft_play)
90 *byte_cnt = uac_info->ft_play->bSubframeSize;
91 return uac_info->ft_play->bBitResolution;
95 if (!uac_info->it_microphone)
97 *byte_cnt = uac_info->ft_rec->bSubframeSize;
98 return uac_info->ft_rec->bBitResolution;
105uint32_t srate_to_u32(uint8_t *srate)
107 return (srate[2] << 16) | (srate[1] << 8) | srate[0];
131 int max_cnt, uint8_t *type)
133 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
138 ft = uac_info->ft_play;
140 ft = uac_info->ft_rec;
145 *type = ft->bSamFreqType;
152 srate_list[0] = srate_to_u32(&ft->tSamFreq[0][0]);
153 srate_list[1] = srate_to_u32(&ft->tSamFreq[1][0]);
157 for (i = 0; i < *type; i++)
158 srate_list[i] = srate_to_u32(&ft->tSamFreq[i][0]);
187 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
190 uint8_t bmRequestType;
191 uint8_t tSampleFreq[3];
193 if (uac_info ==
NULL)
197 ep = uac_info->epd_play;
199 ep = uac_info->epd_rec;
205 USBH_SetInterface(audev->
udev, uac_info->ifd_play->bInterfaceNumber, uac_info->ifd_play->bAlternateSetting);
208 USBH_SetInterface(audev->
udev, uac_info->ifd_rec->bInterfaceNumber, uac_info->ifd_rec->bAlternateSetting);
210 tSampleFreq[0] = *srate & 0xff;
211 tSampleFreq[1] = (*srate >> 8) & 0xff;
212 tSampleFreq[2] = (*srate >> 16) & 0xff;
214 bmRequestType = USB_TYPE_CLASS | USB_RECIP_ENDPOINT;
218 pipe = usb_rcvctrlpipe(udev, 0);
219 bmRequestType |= 0x80;
223 pipe = usb_sndctrlpipe(udev, 0);
227 (SAMPLING_FREQ_CONTROL << 8),
228 ep->bEndpointAddress,
232 *srate = srate_to_u32(tSampleFreq);
272 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
275 uint8_t bmRequestType;
277 if (uac_info ==
NULL)
281 fu = uac_info->fu_play;
283 fu = uac_info->fu_rec;
290 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
294 pipe = usb_rcvctrlpipe(udev, 0);
295 bmRequestType |= 0x80;
299 pipe = usb_sndctrlpipe(udev, 0);
303 (MUTE_CONTROL << 8) | chn,
365 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
368 uint8_t bmRequestType;
370 if (uac_info ==
NULL)
374 fu = uac_info->fu_play;
376 fu = uac_info->fu_rec;
383 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
387 pipe = usb_rcvctrlpipe(udev, 0);
388 bmRequestType |= 0x80;
392 pipe = usb_sndctrlpipe(udev, 0);
397 (VOLUME_CONTROL << 8) | chn,
438 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
441 uint8_t bmRequestType;
443 if (uac_info ==
NULL)
447 fu = uac_info->fu_play;
449 fu = uac_info->fu_rec;
456 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
460 pipe = usb_rcvctrlpipe(udev, 0);
461 bmRequestType |= 0x80;
465 pipe = usb_sndctrlpipe(udev, 0);
469 (AUTOMATIC_GAIN_CONTROL << 8) | chn,
481static void iso_in_irq(
URB_T *urb)
489 if (!audev || !audev->
udev)
539 USBAS_DBGMSG(
"v: USBH_SubmitUrb ret %d\n", status);
561 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
564 if (!func || !uac_info)
567 ep = uac_info->epd_rec;
570 USBAS_DBGMSG(
"Isochronous-in endpoint not found in this device!\n");
591 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
599 ep = uac_info->epd_rec;
602 USBAS_DBGMSG(
"Isochronous-in endpoint not found in this device!\n");
609 if (
USBH_SetInterface(audev->
udev, uac_info->ifd_rec->bInterfaceNumber, uac_info->ifd_rec->bAlternateSetting) != 0)
617 USBAS_DBGMSG(
"Failed to allocated URB!\n");
622 audev->
urbin[uidx] = urb;
625 urb->
pipe = usb_rcvisocpipe(audev->
udev, ep->bEndpointAddress);
643 USBAS_DBGMSG(
"Error - failed to submit URB (%d)", ret);
676 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
699static void iso_out_irq(
URB_T *urb)
706 if (!audev || !audev->
udev)
709 ep = ((UAC_INFO_T *)audev->
priv)->epd_play;
733 USBAS_DBGMSG(
"v: USBH_SubmitUrb ret %d\n", status);
751 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
754 if (!func || !uac_info)
757 ep = uac_info->epd_play;
760 USBAS_DBGMSG(
"Isochronous-out endpoint not found in this device!\n");
778 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
786 ep = uac_info->epd_play;
789 USBAS_DBGMSG(
"Isochronous-out endpoint not found in this device!\n");
794 if (
USBH_SetInterface(audev->
udev, uac_info->ifd_play->bInterfaceNumber, uac_info->ifd_play->bAlternateSetting) != 0)
802 USBAS_DBGMSG(
"Failed to allocated URB!\n");
807 audev->
urbout[uidx] = urb;
810 urb->
pipe = usb_sndisocpipe(audev->
udev, ep->bEndpointAddress);
825 USBAS_ERRMSG(
"Audio-out packet buffer overrun!\n");
834 USBAS_DBGMSG(
"Error - failed to submit URB (%d)", ret);
867 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->
priv;
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define UAC_RET_DEV_NOT_SUPPORTED
#define UAC_RET_OUT_OF_MEMORY
int32_t UAC_StartIsoOutPipe(UAC_DEV_T *audev)
Start to send audio data to UAC device via isochronous out pipe.
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.
int32_t UAC_StopIsoOutPipe(UAC_DEV_T *audev)
Stop UAC device audio out data stream.
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.
int32_t UAC_GetChannelNumber(UAC_DEV_T *audev, uint8_t target)
Obtain Audio Class device's channel number.
int32_t UAC_GetBitResolution(UAC_DEV_T *audev, uint8_t target, uint8_t *val8)
Obtain Audio Class device subframe bit resolution..
UAC_CB_FUNC * au_out_func
uint8_t iso_outbuf[ISO_OUT_URB_CNT][AU_OUT_MAX_PKTSZ *ISO_FRAME_COUNT]
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.
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...
int32_t UAC_SamplingRateControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint32_t *srate)
Set sampling rate frequency.
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.
int32_t UAC_StopIsoInPipe(UAC_DEV_T *audev)
Stop UAC device audio in data stream.
URB_T * urbout[ISO_OUT_URB_CNT]
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...
uint8_t iso_inbuf[ISO_IN_URB_CNT][AU_IN_MAX_PKTSZ *ISO_FRAME_COUNT]
URB_T * urbin[ISO_IN_URB_CNT]
int32_t UAC_StartIsoInPipe(UAC_DEV_T *audev)
Start to receive audio data from UAC device via isochronous in pipe.
int() UAC_CB_FUNC(struct uac_dev_t *dev, uint8_t *data, int len)
int32_t USBH_SubmitUrb(URB_T *urb)
Submit an URB to USB core for transfer data.
int transfer_buffer_length
int32_t USBH_UnlinkUrb(URB_T *urb)
Cancel an URB which has been submit to USB core.
URB_T * USBH_AllocUrb(void)
Allocate an URB from USB Core driver internal URB pool.
int32_t USBH_SetInterface(USB_DEV_T *dev, char interface, char alternate)
Set USB device interface.
void USBH_FreeUrb(URB_T *)
Free the URB allocated from USBH_AllocUrb()
int32_t USBH_SendCtrlMsg(USB_DEV_T *dev, uint32_t pipe, uint8_t request, uint8_t requesttype, uint16_t value, uint16_t index, void *data, uint16_t size, int timeout)
Execute a control transfer.
ISO_PACKET_DESCRIPTOR_T iso_frame_desc[8]
void(* complete)(struct urb_t *)
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
#define NULL
NULL pointer.
USB Host core driver header file.