/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ /* * USB UAC Microphone Driver Defines, Types, and Prototypes * Created by Gunter M. Zieber, September 13, 2011 * Modified for USB UAC Gunter M. Zieber 11/11/11 */ #ifndef __USB_UAC_MIC__ #define __USB_UAC_MIC__ #ifdef __cplusplus extern "C" { #endif #include typedef short int usb_mic_pcm_sample_t; typedef long int usb_mic_handle_t; typedef enum { usb_mic_state_sample_rate, usb_mic_state_gain_db, usb_mic_state_gain_min, usb_mic_state_gain_max, usb_mic_state_gain_step, usb_mic_state_mute, usb_mic_state_digital_gain_db, usb_mic_state_queue_depth, usb_mic_state_xfer_per_entry, usb_mic_state_max_queue_depth, usb_mic_state_max_xfer_per_entry, usb_mic_state_core } usb_mic_state_t; typedef struct { unsigned long int modulus; /* in sample size: num_chan * sizeof(s16) */ usb_mic_pcm_sample_t* base; } usb_mic_ringbuffer_t; typedef struct { unsigned long int flags; unsigned long int available; unsigned long int read_idx; } usb_mic_status_t; #define MIC_STATUS_FLAG_PCM16 (1 << 0) typedef enum { usb_uac_attach, usb_uac_detach, usb_uac_error } usb_event_type_t; typedef struct { unsigned long int host; unsigned long int port; unsigned long int vid; unsigned long int pid; usb_mic_handle_t h_inst; } usb_event_data_t; typedef struct { unsigned long int num_channels; unsigned long int sample_rates; } usb_dev_attr_t; typedef struct { usb_event_data_t evt_data; unsigned long int cap_flags; usb_dev_attr_t input_attr; usb_dev_attr_t output_attr; } usb_event_data_ex_t; #define UAC_CAPS_INPUT (1 << 0) #define UAC_CAPS_OUTPUT (1 << 1) #define UAC_SAMPLE_RATE_32K (1 << 5) #define UAC_SAMPLE_RATE_48K (1 << 7) typedef void (*usb_event_handler_t)(void*, usb_event_type_t, usb_event_data_t*, int); typedef struct OSEvent* p_os_event; /* * Error Codes */ #define USB_MIC_ERROR_NONE 0 #define USB_MIC_ERROR_NOT_SUP (-1) #define USB_MIC_ERROR_INV_ARG (-2) #define USB_MIC_ERROR_INV_STATE (-3) #define USB_MIC_ERROR_NO_MEM (-4) #define USB_MIC_ERROR_ALREADY_OPEN (-5) #define USB_MIC_ERROR_NOT_OPEN (-6) #define USB_MIC_ERROR_DEVICE (-7) /* * API Function Prototypes */ int USBMICInit(void* pv_cx, usb_event_handler_t pfn_event); int USBMICUninit(void); int USBMICOpenQuery(usb_mic_handle_t h_inst, mem_res_query_t* p_res_query); int USBMICOpen(usb_mic_handle_t h_mic, mem_res_t* p_mem_res, usb_mic_ringbuffer_t* prb); int USBMICClose(usb_mic_handle_t h_mic); int USBMICStart(usb_mic_handle_t h_mic); int USBMICStartExt(usb_mic_handle_t h_mic, p_os_event p_wait_event, unsigned int delay_us); int USBMICStop(usb_mic_handle_t h_mic); int USBMICGetStatus(usb_mic_handle_t h_mic, usb_mic_status_t* p_status); int USBMICSetDataConsumed(usb_mic_handle_t h_mic, unsigned int c_samples); int USBMICSetState(usb_mic_handle_t h_mic, usb_mic_state_t state, unsigned int value); int USBMICGetState(usb_mic_handle_t h_mic, usb_mic_state_t state, unsigned int* p_value); int UACOUTStart(usb_mic_handle_t h_mic, usb_mic_ringbuffer_t* p_rb, unsigned int sample_rate); int UACOUTStop(usb_mic_handle_t h_mic); int UACOUTGetStatus(usb_mic_handle_t h_mic, usb_mic_status_t* p_status); int UACOUTSetDataConsumed(usb_mic_handle_t h_mic, unsigned int c_samples); #ifdef __cplusplus } #endif #endif // __USB_UAC_MIC__