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

uac_core.c
Go to the documentation of this file.
1/**************************************************************************/
13#include <stdio.h>
14#include <string.h>
15
16#include "NUC472_442.h"
17#include "usbh_core.h"
18
19#include "usbh_uac.h"
20#include "uac.h"
21
22
46int32_t UAC_GetChannelNumber(UAC_DEV_T *audev, uint8_t target)
47{
48 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
49
50 if (uac_info == NULL)
51 return UAC_RET_IO_ERR;
52
53 if (target == UAC_SPEAKER)
54 {
55 if (!uac_info->ft_play)
56 return UAC_RET_DEV_NOT_SUPPORTED;
57 return uac_info->ft_play->bNrChannels;
58 }
59 else
60 {
61 if (!uac_info->ft_rec)
62 return UAC_RET_DEV_NOT_SUPPORTED;
63 return uac_info->ft_rec->bNrChannels;
64 }
65}
66
67
79int32_t UAC_GetBitResolution(UAC_DEV_T *audev, uint8_t target, uint8_t *byte_cnt)
80{
81 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
82
83 if (uac_info == NULL)
84 return UAC_RET_IO_ERR;
85
86 if (target == UAC_SPEAKER)
87 {
88 if (!uac_info->ft_play)
89 return UAC_RET_DEV_NOT_SUPPORTED;
90 *byte_cnt = uac_info->ft_play->bSubframeSize;
91 return uac_info->ft_play->bBitResolution;
92 }
93 else
94 {
95 if (!uac_info->it_microphone)
96 return UAC_RET_DEV_NOT_SUPPORTED;
97 *byte_cnt = uac_info->ft_rec->bSubframeSize;
98 return uac_info->ft_rec->bBitResolution;
99 }
100}
101
102
104
105uint32_t srate_to_u32(uint8_t *srate)
106{
107 return (srate[2] << 16) | (srate[1] << 8) | srate[0];
108}
109
111
112
130int32_t UAC_GetSamplingRate(UAC_DEV_T *audev, uint8_t target, uint32_t *srate_list,
131 int max_cnt, uint8_t *type)
132{
133 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
134 AC_FT1_T *ft;
135 int i;
136
137 if (target == UAC_SPEAKER)
138 ft = uac_info->ft_play;
139 else
140 ft = uac_info->ft_rec;
141
142 if (!ft)
143 return UAC_RET_DEV_NOT_SUPPORTED;
144
145 *type = ft->bSamFreqType;
146
147 if (*type == 0)
148 {
149 if (max_cnt < 2)
150 return UAC_RET_OUT_OF_MEMORY;
151
152 srate_list[0] = srate_to_u32(&ft->tSamFreq[0][0]);
153 srate_list[1] = srate_to_u32(&ft->tSamFreq[1][0]);
154 }
155 else
156 {
157 for (i = 0; i < *type; i++)
158 srate_list[i] = srate_to_u32(&ft->tSamFreq[i][0]);
159 }
160 return 0;
161}
162
163
184int32_t UAC_SamplingRateControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint32_t *srate)
185{
186 USB_DEV_T *udev = audev->udev;
187 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
188 USB_EP_DESC_T *ep;
189 int pipe, len;
190 uint8_t bmRequestType;
191 uint8_t tSampleFreq[3];
192
193 if (uac_info == NULL)
194 return UAC_RET_IO_ERR;
195
196 if (target == UAC_SPEAKER)
197 ep = uac_info->epd_play;
198 else
199 ep = uac_info->epd_rec;
200
201 if (ep == NULL)
202 return UAC_RET_DEV_NOT_SUPPORTED;
203
204 if (target == UAC_SPEAKER)
205 USBH_SetInterface(audev->udev, uac_info->ifd_play->bInterfaceNumber, uac_info->ifd_play->bAlternateSetting);
206
207 if (target == UAC_MICROPHONE)
208 USBH_SetInterface(audev->udev, uac_info->ifd_rec->bInterfaceNumber, uac_info->ifd_rec->bAlternateSetting);
209
210 tSampleFreq[0] = *srate & 0xff;
211 tSampleFreq[1] = (*srate >> 8) & 0xff;
212 tSampleFreq[2] = (*srate >> 16) & 0xff;
213
214 bmRequestType = USB_TYPE_CLASS | USB_RECIP_ENDPOINT;
215
216 if (req & 0x80)
217 {
218 pipe = usb_rcvctrlpipe(udev, 0);
219 bmRequestType |= 0x80;
220 }
221 else
222 {
223 pipe = usb_sndctrlpipe(udev, 0);
224 }
225
226 len = USBH_SendCtrlMsg(udev, pipe, req, bmRequestType,
227 (SAMPLING_FREQ_CONTROL << 8), // wValue
228 ep->bEndpointAddress, // wIndex
229 tSampleFreq, 3, UAC_REQ_TIMEOUT);
230 if (len == 3)
231 {
232 *srate = srate_to_u32(tSampleFreq);
233 return 0;
234 }
235
236 return UAC_RET_IO_ERR;
237}
238
239
240
269int32_t UAC_MuteControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *mute)
270{
271 USB_DEV_T *udev = audev->udev;
272 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
273 AC_FU_T *fu;
274 int pipe, len;
275 uint8_t bmRequestType;
276
277 if (uac_info == NULL)
278 return UAC_RET_IO_ERR;
279
280 if (target == UAC_SPEAKER)
281 fu = uac_info->fu_play;
282 else if (target == UAC_MICROPHONE)
283 fu = uac_info->fu_rec;
284 else
285 return UAC_RET_INVALID;
286
287 //if (uac_check_fu_ctrl(uac_info, target, chn, MUTE_CONTROL) != 0)
288 // return UAC_RET_DEV_NOT_SUPPORTED;
289
290 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
291
292 if (req & 0x80)
293 {
294 pipe = usb_rcvctrlpipe(udev, 0);
295 bmRequestType |= 0x80;
296 }
297 else
298 {
299 pipe = usb_sndctrlpipe(udev, 0);
300 }
301
302 len = USBH_SendCtrlMsg(udev, pipe, req, bmRequestType,
303 (MUTE_CONTROL << 8) | chn, // wValue
304 (fu->bUnitID << 8) | (audev->ctrl_ifnum), // wIndex
305 mute, 1, UAC_REQ_TIMEOUT);
306 if (len == 1)
307 return 0;
308 else
309 return -1;
310}
311
312
362int32_t UAC_VolumeControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint16_t *volume)
363{
364 USB_DEV_T *udev = audev->udev;
365 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
366 AC_FU_T *fu;
367 int pipe, len;
368 uint8_t bmRequestType;
369
370 if (uac_info == NULL)
371 return UAC_RET_IO_ERR;
372
373 if (target == UAC_SPEAKER)
374 fu = uac_info->fu_play;
375 else if (target == UAC_MICROPHONE)
376 fu = uac_info->fu_rec;
377 else
378 return UAC_RET_INVALID;
379
380 //if (uac_check_fu_ctrl(uac_info, target, chn, VOLUME_CONTROL) != 0)
381 // return UAC_RET_DEV_NOT_SUPPORTED;
382
383 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
384
385 if (req & 0x80)
386 {
387 pipe = usb_rcvctrlpipe(udev, 0);
388 bmRequestType |= 0x80;
389 }
390 else
391 {
392 pipe = usb_sndctrlpipe(udev, 0);
393 }
394
395
396 len = USBH_SendCtrlMsg(udev, pipe, req, bmRequestType,
397 (VOLUME_CONTROL << 8) | chn, // wValue
398 (fu->bUnitID << 8) | (audev->ctrl_ifnum), // wIndex
399 (uint8_t *)volume, 2, UAC_REQ_TIMEOUT);
400 if (len == 2)
401 return 0;
402 else
403 return -1;
404}
405
406
435int32_t UAC_AutoGainControl(UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *mute)
436{
437 USB_DEV_T *udev = audev->udev;
438 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
439 AC_FU_T *fu;
440 int pipe, len;
441 uint8_t bmRequestType;
442
443 if (uac_info == NULL)
444 return UAC_RET_IO_ERR;
445
446 if (target == UAC_SPEAKER)
447 fu = uac_info->fu_play;
448 else if (target == UAC_MICROPHONE)
449 fu = uac_info->fu_rec;
450 else
451 return UAC_RET_INVALID;
452
453 //if (uac_check_fu_ctrl(uac_info, target, chn, MUTE_CONTROL) != 0)
454 // return UAC_RET_DEV_NOT_SUPPORTED;
455
456 bmRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
457
458 if (req & 0x80)
459 {
460 pipe = usb_rcvctrlpipe(udev, 0);
461 bmRequestType |= 0x80;
462 }
463 else
464 {
465 pipe = usb_sndctrlpipe(udev, 0);
466 }
467
468 len = USBH_SendCtrlMsg(udev, pipe, req, bmRequestType,
469 (AUTOMATIC_GAIN_CONTROL << 8) | chn, // wValue
470 (fu->bUnitID << 8) | (audev->ctrl_ifnum), // wIndex
471 mute, 1, UAC_REQ_TIMEOUT);
472 if (len == 1)
473 return 0;
474 else
475 return -1;
476}
477
478
480
481 static void iso_in_irq(URB_T *urb)
482{
483 UAC_DEV_T *audev = (UAC_DEV_T *)urb->context;
484 uint8_t *buff;
485 int i, len, cp_len;
486 int status;
487
488 /* We don't want to do anything if we are about to be removed! */
489 if (!audev || !audev->udev)
490 return;
491
492 //printf("Iso in - SF=%d, EC=%d, L=%d.\n", urb->start_frame, urb->error_count, urb->actual_length);
493 //printf("IN: SF=%d, L=%d\n", urb->start_frame, urb->actual_length);
494
495 for (i = 0; i < urb->number_of_packets; i++)
496 {
497 len = urb->iso_frame_desc[i].actual_length;
498 if (!len)
499 continue;
500
501 buff = (uint8_t *)urb->transfer_buffer + i * AU_IN_MAX_PKTSZ;
502 cp_len = audev->au_in_bufsz - audev->au_in_bufidx;
503 if (cp_len > len)
504 cp_len = len;
505
506 memcpy(&(audev->au_in_buff[audev->au_in_bufidx]), buff, cp_len);
507 audev->au_in_func(audev, &(audev->au_in_buff[audev->au_in_bufidx]), cp_len);
508
509 audev->au_in_bufidx += cp_len;
510 len -= cp_len;
511
512 if (len)
513 {
514 buff += cp_len;
515 memcpy(audev->au_in_buff, buff+cp_len, len);
516 audev->au_in_func(audev, audev->au_in_buff, len);
517 audev->au_in_bufidx = len;
518 }
519 }
520
521 if (!audev->in_streaming)
522 return;
523
524 urb->transfer_flags = USB_ISO_ASAP;
525 urb->number_of_packets = ISO_FRAME_COUNT;
526 urb->transfer_buffer_length = AU_IN_MAX_PKTSZ * ISO_FRAME_COUNT;
527 urb->actual_length = 0;
528 for (i = 0; i < ISO_FRAME_COUNT; i++)
529 {
530 urb->iso_frame_desc[i].status = 0;
531 urb->iso_frame_desc[i].actual_length = 0;
532 urb->iso_frame_desc[i].offset = i * AU_IN_MAX_PKTSZ;
533 urb->iso_frame_desc[i].length = AU_IN_MAX_PKTSZ;
534 }
535
536 /* Submit URB */
537 status = USBH_SubmitUrb(urb);
538 if (status)
539 USBAS_DBGMSG("v: USBH_SubmitUrb ret %d\n", status);
540}
541
543
544
559int32_t UAC_InstallIsoInCbFun(UAC_DEV_T *audev, uint8_t *au_in_buff, int bufsiz, UAC_CB_FUNC *func)
560{
561 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
562 USB_EP_DESC_T *ep;
563
564 if (!func || !uac_info)
565 return UAC_RET_INVALID;
566
567 ep = uac_info->epd_rec;
568 if (!ep)
569 {
570 USBAS_DBGMSG("Isochronous-in endpoint not found in this device!\n");
571 return UAC_RET_DEV_NOT_SUPPORTED;
572 }
573
574 audev->au_in_func = func;
575 audev->au_in_buff = au_in_buff;
576 audev->au_in_bufsz = bufsiz;
577 audev->au_in_bufidx = 0;
578 return UAC_RET_OK;
579}
580
581
589int32_t UAC_StartIsoInPipe(UAC_DEV_T *audev)
590{
591 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
592 USB_EP_DESC_T *ep;
593 URB_T *urb;
594 int uidx, i, ret;
595
596 if (!uac_info || !audev->au_in_func || (audev->urbin[0]))
597 return UAC_RET_INVALID;
598
599 ep = uac_info->epd_rec;
600 if (!ep)
601 {
602 USBAS_DBGMSG("Isochronous-in endpoint not found in this device!\n");
603 return UAC_RET_DEV_NOT_SUPPORTED;
604 }
605
606 audev->au_in_bufidx = 0;
607
608 /* Set interface alternative settings */
609 if (USBH_SetInterface(audev->udev, uac_info->ifd_rec->bInterfaceNumber, uac_info->ifd_rec->bAlternateSetting) != 0)
610 return UAC_RET_IO_ERR;
611
612 for (uidx = 0; uidx < ISO_IN_URB_CNT; uidx++)
613 {
614 urb = USBH_AllocUrb();
615 if (urb == NULL)
616 {
617 USBAS_DBGMSG("Failed to allocated URB!\n");
618 ret = UAC_RET_OUT_OF_MEMORY;
619 goto err_out;
620 }
621
622 audev->urbin[uidx] = urb;
623 urb->dev = audev->udev;
624 urb->context = audev;
625 urb->pipe = usb_rcvisocpipe(audev->udev, ep->bEndpointAddress);
626 urb->transfer_flags = USB_ISO_ASAP;
627 urb->complete = iso_in_irq;
628 urb->interval = ep->bInterval;
629 urb->number_of_packets = ISO_FRAME_COUNT;
630 urb->transfer_buffer = &(audev->iso_inbuf[uidx][0]);
631 urb->transfer_buffer_length = AU_IN_MAX_PKTSZ * ISO_FRAME_COUNT;
632 urb->actual_length = 0;
633
634 for (i = 0; i < ISO_FRAME_COUNT; i++)
635 {
636 urb->iso_frame_desc[i].offset = i * AU_IN_MAX_PKTSZ;
637 urb->iso_frame_desc[i].length = AU_IN_MAX_PKTSZ;
638 }
639
640 ret = USBH_SubmitUrb(urb);
641 if (ret)
642 {
643 USBAS_DBGMSG("Error - failed to submit URB (%d)", ret);
644 ret = UAC_RET_IO_ERR;
645 goto err_out;
646 }
647 }
648 audev->in_streaming = 1;
649
650 return UAC_RET_OK;
651
652err_out:
653 for (i = 0; i < ISO_IN_URB_CNT; i++)
654 {
655 if (audev->urbin[i])
656 {
657 USBH_UnlinkUrb(audev->urbin[i]);
658 USBH_FreeUrb(audev->urbin[i]);
659 audev->urbin[i] = NULL;
660 }
661 }
662 audev->au_in_func = NULL;
663 return ret;
664}
665
666
674int32_t UAC_StopIsoInPipe(UAC_DEV_T *audev)
675{
676 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
677 int i;
678
679 audev->in_streaming = 0;
680
681 /* Set interface alternative settings */
682 USBH_SetInterface(audev->udev, uac_info->ifd_rec->bInterfaceNumber, 0);
683
684 for (i = 0; i < ISO_IN_URB_CNT; i++)
685 {
686 if (audev->urbin[i])
687 {
688 USBH_UnlinkUrb(audev->urbin[i]);
689 USBH_FreeUrb(audev->urbin[i]);
690 audev->urbin[i] = NULL;
691 }
692 }
693 return UAC_RET_OK;
694}
695
696
698
699 static void iso_out_irq(URB_T *urb)
700{
701 UAC_DEV_T *audev = (UAC_DEV_T *)urb->context;
702 USB_EP_DESC_T *ep;
703 int i, status;
704
705 /* We don't want to do anything if we are about to be removed! */
706 if (!audev || !audev->udev)
707 return;
708
709 ep = ((UAC_INFO_T *)audev->priv)->epd_play;
710
711 //printf("Iso out - SF=%d, EC=%d, L=%d.\n", urb->start_frame, urb->error_count, urb->actual_length);
712 //printf("OUT: SF=%d, L=%d\n", urb->start_frame, urb->actual_length);
713
714 if (!audev->out_streaming)
715 return;
716
717 urb->transfer_flags = USB_ISO_ASAP;
718 urb->number_of_packets = ISO_FRAME_COUNT;
719 urb->transfer_buffer_length = AU_OUT_MAX_PKTSZ * ISO_FRAME_COUNT;
720 urb->actual_length = 0;
721 for (i = 0; i < ISO_FRAME_COUNT; i++)
722 {
723 urb->iso_frame_desc[i].status = 0;
724 urb->iso_frame_desc[i].offset = i * AU_OUT_MAX_PKTSZ;
725 urb->iso_frame_desc[i].actual_length = audev->au_out_func(audev, (uint8_t *)urb->transfer_buffer + urb->iso_frame_desc[i].offset, ep->wMaxPacketSize);
726 urb->iso_frame_desc[i].length = urb->iso_frame_desc[i].actual_length;
727 urb->actual_length += urb->iso_frame_desc[i].actual_length;
728 }
729
730 /* Submit URB */
731 status = USBH_SubmitUrb(urb);
732 if (status)
733 USBAS_DBGMSG("v: USBH_SubmitUrb ret %d\n", status);
734}
735
737
738
749int32_t UAC_InstallIsoOutCbFun(UAC_DEV_T *audev, UAC_CB_FUNC *func)
750{
751 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
752 USB_EP_DESC_T *ep;
753
754 if (!func || !uac_info)
755 return UAC_RET_INVALID;
756
757 ep = uac_info->epd_play;
758 if (!ep)
759 {
760 USBAS_DBGMSG("Isochronous-out endpoint not found in this device!\n");
761 return UAC_RET_DEV_NOT_SUPPORTED;
762 }
763
764 audev->au_out_func = func;
765 return UAC_RET_OK;
766}
767
768
776int32_t UAC_StartIsoOutPipe(UAC_DEV_T *audev)
777{
778 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
779 USB_EP_DESC_T *ep;
780 URB_T *urb;
781 int uidx, i, ret;
782
783 if (!uac_info || !audev->au_out_func || (audev->urbout[0]))
784 return UAC_RET_INVALID;
785
786 ep = uac_info->epd_play;
787 if (!ep)
788 {
789 USBAS_DBGMSG("Isochronous-out endpoint not found in this device!\n");
790 return UAC_RET_DEV_NOT_SUPPORTED;
791 }
792
793 /* Set interface alternative settings */
794 if (USBH_SetInterface(audev->udev, uac_info->ifd_play->bInterfaceNumber, uac_info->ifd_play->bAlternateSetting) != 0)
795 return UAC_RET_IO_ERR;
796
797 for (uidx = 0; uidx < ISO_OUT_URB_CNT; uidx++)
798 {
799 urb = USBH_AllocUrb();
800 if (urb == NULL)
801 {
802 USBAS_DBGMSG("Failed to allocated URB!\n");
803 ret = UAC_RET_OUT_OF_MEMORY;
804 goto err_out;
805 }
806
807 audev->urbout[uidx] = urb;
808 urb->dev = audev->udev;
809 urb->context = audev;
810 urb->pipe = usb_sndisocpipe(audev->udev, ep->bEndpointAddress);
811 urb->transfer_flags = USB_ISO_ASAP;
812 urb->complete = iso_out_irq;
813 urb->interval = ep->bInterval;
814 urb->number_of_packets = ISO_FRAME_COUNT;
815 urb->transfer_buffer = &(audev->iso_outbuf[uidx][0]);
816 urb->transfer_buffer_length = AU_OUT_MAX_PKTSZ * ISO_FRAME_COUNT;
817 urb->actual_length = 0;
818
819 for (i = 0; i < ISO_FRAME_COUNT; i++)
820 {
821 urb->iso_frame_desc[i].offset = i * AU_OUT_MAX_PKTSZ;
822 urb->iso_frame_desc[i].length = audev->au_out_func(audev, (uint8_t *)urb->transfer_buffer + urb->iso_frame_desc[i].offset, ep->wMaxPacketSize);
823 if (urb->iso_frame_desc[i].length > ep->wMaxPacketSize)
824 {
825 USBAS_ERRMSG("Audio-out packet buffer overrun!\n");
826 return -1;
827 }
828 urb->iso_frame_desc[i].actual_length = urb->iso_frame_desc[i].length;
829 }
830
831 ret = USBH_SubmitUrb(urb);
832 if (ret)
833 {
834 USBAS_DBGMSG("Error - failed to submit URB (%d)", ret);
835 ret = UAC_RET_IO_ERR;
836 goto err_out;
837 }
838 }
839 audev->out_streaming = 1;
840
841 return UAC_RET_OK;
842
843err_out:
844 for (i = 0; i < ISO_OUT_URB_CNT; i++)
845 {
846 if (audev->urbout[i])
847 {
848 USBH_UnlinkUrb(audev->urbout[i]);
849 USBH_FreeUrb(audev->urbout[i]);
850 audev->urbout[i] = NULL;
851 }
852 }
853 audev->au_out_func = NULL;
854 return ret;
855}
856
857
865int32_t UAC_StopIsoOutPipe(UAC_DEV_T *audev)
866{
867 UAC_INFO_T *uac_info = (UAC_INFO_T *)audev->priv;
868 int i;
869
870 audev->out_streaming = 0;
871
872 /* Set interface alternative settings */
873 USBH_SetInterface(audev->udev, uac_info->ifd_play->bInterfaceNumber, 0);
874
875 for (i = 0; i < ISO_OUT_URB_CNT; i++)
876 {
877 if (audev->urbout[i])
878 {
879 USBH_UnlinkUrb(audev->urbout[i]);
880 USBH_FreeUrb(audev->urbout[i]);
881 audev->urbout[i] = NULL;
882 }
883 }
884 return UAC_RET_OK;
885}
886
887 /* end of group NUC472_442_USBH_AS_EXPORTED_FUNCTIONS */
889 /* end of group NUC472_442_USBH_AS_Driver */
891 /* end of group NUC472_442_Device_Driver */
893
894/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
895
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
UAC_MICROPHONE
#define UAC_MICROPHONE
Definition: usbh_uac.h:29
UAC_SPEAKER
#define UAC_SPEAKER
Definition: usbh_uac.h:28
ISO_OUT_URB_CNT
#define ISO_OUT_URB_CNT
Definition: usbh_uac.h:23
UAC_RET_INVALID
#define UAC_RET_INVALID
Definition: usbh_uac.h:38
UAC_RET_DEV_NOT_SUPPORTED
#define UAC_RET_DEV_NOT_SUPPORTED
Definition: usbh_uac.h:41
AU_IN_MAX_PKTSZ
#define AU_IN_MAX_PKTSZ
Definition: usbh_uac.h:24
UAC_REQ_TIMEOUT
#define UAC_REQ_TIMEOUT
Definition: usbh_uac.h:26
ISO_IN_URB_CNT
#define ISO_IN_URB_CNT
Definition: usbh_uac.h:22
UAC_RET_OUT_OF_MEMORY
#define UAC_RET_OUT_OF_MEMORY
Definition: usbh_uac.h:39
UAC_RET_OK
#define UAC_RET_OK
Definition: usbh_uac.h:35
UAC_RET_IO_ERR
#define UAC_RET_IO_ERR
Definition: usbh_uac.h:37
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_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_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_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_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_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_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_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
urb_t::transfer_buffer
void * transfer_buffer
Definition: usbh_core.h:545
USBH_SubmitUrb
int32_t USBH_SubmitUrb(URB_T *urb)
Submit an URB to USB core for transfer data.
Definition: usbh_core.c:218
urb_t::actual_length
int actual_length
Definition: usbh_core.h:547
urb_t::transfer_buffer_length
int transfer_buffer_length
Definition: usbh_core.h:546
urb_t::pipe
uint32_t pipe
Definition: usbh_core.h:542
urb_t::dev
struct usb_device * dev
Definition: usbh_core.h:541
urb_t::number_of_packets
int number_of_packets
Definition: usbh_core.h:550
USBH_UnlinkUrb
int32_t USBH_UnlinkUrb(URB_T *urb)
Cancel an URB which has been submit to USB core.
Definition: usbh_core.c:236
USBH_AllocUrb
URB_T * USBH_AllocUrb(void)
Allocate an URB from USB Core driver internal URB pool.
Definition: usbh_support.c:90
urb_t::transfer_flags
uint32_t transfer_flags
Definition: usbh_core.h:544
USBH_SetInterface
int32_t USBH_SetInterface(USB_DEV_T *dev, char interface, char alternate)
Set USB device interface.
Definition: usbh_core.c:948
USBH_FreeUrb
void USBH_FreeUrb(URB_T *)
Free the URB allocated from USBH_AllocUrb()
Definition: usbh_support.c:113
USBH_SendCtrlMsg
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.
Definition: usbh_core.c:378
urb_t::iso_frame_desc
ISO_PACKET_DESCRIPTOR_T iso_frame_desc[8]
Definition: usbh_core.h:556
urb_t::complete
void(* complete)(struct urb_t *)
Definition: usbh_core.h:555
urb_t::interval
int interval
Definition: usbh_core.h:551
urb_t::context
void * context
Definition: usbh_core.h:554
USB_DEV_T
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
USB_EP_DESC_T
USB_EP_DESC_T
Definition: usbh_core.h:300
NULL
#define NULL
NULL pointer.
Definition: NUC472_442.h:29018
uac_dev_t
Definition: usbh_uac.h:100
urb_t
Definition: usbh_core.h:537
uac.h
usbh_core.h
USB Host core driver header file.
usbh_uac.h