1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) Nintendo. All rights reserved. 4 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 11 *---------------------------------------------------------------------------*/ 12 /* 13 * USB UAC Microphone Driver Defines, Types, and Prototypes 14 * Created by Gunter M. Zieber, September 13, 2011 15 * Modified for USB UAC Gunter M. Zieber 11/11/11 16 */ 17 #ifndef __USB_UAC_MIC__ 18 #define __USB_UAC_MIC__ 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #include <cafe/mem_res.h> 25 26 typedef short int usb_mic_pcm_sample_t; 27 typedef long int usb_mic_handle_t; 28 29 typedef enum { 30 usb_mic_state_sample_rate, 31 usb_mic_state_gain_db, 32 usb_mic_state_gain_min, 33 usb_mic_state_gain_max, 34 usb_mic_state_gain_step, 35 usb_mic_state_mute, 36 usb_mic_state_digital_gain_db, 37 usb_mic_state_queue_depth, 38 usb_mic_state_xfer_per_entry, 39 usb_mic_state_queue_depth_out, 40 usb_mic_state_xfer_per_entry_out, 41 usb_mic_state_max_queue_depth, 42 usb_mic_state_max_xfer_per_entry, 43 usb_mic_state_core 44 } usb_mic_state_t; 45 46 typedef struct { 47 unsigned long int modulus; /* in sample size: num_chan * sizeof(s16) */ 48 usb_mic_pcm_sample_t* base; 49 } usb_mic_ringbuffer_t; 50 51 typedef struct { 52 unsigned long int flags; 53 unsigned long int available; 54 unsigned long int read_idx; 55 } usb_mic_status_t; 56 57 #define MIC_STATUS_FLAG_PCM16 (1 << 0) 58 59 typedef enum { 60 usb_uac_attach, 61 usb_uac_detach, 62 usb_uac_error 63 } usb_event_type_t; 64 65 typedef struct { 66 unsigned long int host; 67 unsigned long int port; 68 unsigned long int vid; 69 unsigned long int pid; 70 usb_mic_handle_t h_inst; 71 } usb_event_data_t; 72 73 typedef struct { 74 unsigned long int num_channels; 75 unsigned long int sample_rates; 76 } usb_dev_attr_t; 77 78 typedef struct { 79 usb_event_data_t evt_data; 80 unsigned long int cap_flags; 81 usb_dev_attr_t input_attr; 82 usb_dev_attr_t output_attr; 83 } usb_event_data_ex_t; 84 85 #define UAC_CAPS_INPUT (1 << 0) 86 #define UAC_CAPS_OUTPUT (1 << 1) 87 88 #define UAC_SAMPLE_RATE_32K (1 << 5) 89 #define UAC_SAMPLE_RATE_48K (1 << 7) 90 91 typedef struct OSEvent* p_os_event; 92 typedef void (*usb_event_handler_t)(void*, usb_event_type_t, usb_event_data_t*, int); 93 /* 94 * Error Codes 95 */ 96 #define USB_MIC_ERROR_NONE 0 97 #define USB_MIC_ERROR_NOT_SUP (-1) 98 #define USB_MIC_ERROR_INV_ARG (-2) 99 #define USB_MIC_ERROR_INV_STATE (-3) 100 #define USB_MIC_ERROR_NO_MEM (-4) 101 #define USB_MIC_ERROR_ALREADY_OPEN (-5) 102 #define USB_MIC_ERROR_NOT_OPEN (-6) 103 #define USB_MIC_ERROR_DEVICE (-7) 104 /* 105 * API Function Prototypes 106 */ 107 int UACInit(void* pv_cx, usb_event_handler_t pfn_event); 108 int UACUninit(void); 109 int UACOpenQuery(usb_mic_handle_t h_inst, mem_res_query_t* p_res_query); 110 int UACOpen(usb_mic_handle_t h_mic, mem_res_t* p_mem_res, usb_mic_ringbuffer_t* prb); 111 int UACClose(usb_mic_handle_t h_mic); 112 int UACINStart(usb_mic_handle_t h_mic); 113 int UACINStartExt(usb_mic_handle_t h_mic, p_os_event p_wait_event, unsigned int delay_us); 114 int UACINStop(usb_mic_handle_t h_mic); 115 int UACINGetStatus(usb_mic_handle_t h_mic, usb_mic_status_t* p_status); 116 int UACINSetDataConsumed(usb_mic_handle_t h_mic, unsigned int c_samples); 117 int UACSetState(usb_mic_handle_t h_mic, usb_mic_state_t state, unsigned int value); 118 int UACGetState(usb_mic_handle_t h_mic, usb_mic_state_t state, unsigned int* p_value); 119 int UACOUTStart(usb_mic_handle_t h_mic, usb_mic_ringbuffer_t* p_rb, unsigned int sample_rate); 120 int UACOUTStartExt(usb_mic_handle_t h_mic, p_os_event p_wait_event, unsigned int delay_us, usb_mic_ringbuffer_t* p_rb, unsigned int sample_rate); 121 int UACOUTStop(usb_mic_handle_t h_mic); 122 int UACOUTGetStatus(usb_mic_handle_t h_mic, usb_mic_status_t* p_status); 123 int UACOUTSetDataConsumed(usb_mic_handle_t h_mic, unsigned int c_samples); 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif // __USB_UAC_MIC__ 130