/*---------------------------------------------------------------------------* Project: Cafe 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. *---------------------------------------------------------------------------*/ /* * COS based UAC header * Created by Gunter M. Zieber, August 1st, 2013 * Based on NEC-E's PPC shim and IOP class driver stack */ ////////////////////////////////////////////////////////////////////////////// // Returned Error Codes ////////////////////////////////////////////////////////////////////////////// #define MAKE_UAC_ERROR(error) (error) #define COS_UAC_ERROR_OK (0) #define COS_UAC_ERROR_WAIT (COS_UAC_ERROR_OK+1) #define COS_UAC_ERROR_CANCEL MAKE_UAC_ERROR(-10) #define COS_UAC_ERROR_INVALID_ARG MAKE_UAC_ERROR(-100) #define COS_UAC_ERROR_NOTREADY MAKE_UAC_ERROR(-101) #define COS_UAC_ERROR_DEVICE_BUSY MAKE_UAC_ERROR(-102) #define COS_UAC_ERROR_DEVICE_NOTREADY MAKE_UAC_ERROR(-103) #define COS_UAC_ERROR_INVALID_DEVICE_HANDLE MAKE_UAC_ERROR(-104) #define COS_UAC_ERROR_BUFFER_SIZE MAKE_UAC_ERROR(-105) #define COS_UAC_ERROR_DATA_SIZE MAKE_UAC_ERROR(-106) #define COS_UAC_ERROR_UNSUPPORTED MAKE_UAC_ERROR(-107) #define COS_UAC_ERROR_FORMAT_TYPE MAKE_UAC_ERROR(-108) #define COS_UAC_ERROR_NO_DATA MAKE_UAC_ERROR(-110) #define COS_UAC_ERROR_NO_REQUEST MAKE_UAC_ERROR(-111) #define COS_UAC_ERROR_INVALID_UNIT MAKE_UAC_ERROR(-112) #define COS_UAC_ERROR_CTRL_BUSY MAKE_UAC_ERROR(-113) #define COS_UAC_ERROR_IFSET_BUSY MAKE_UAC_ERROR(-114) #define COS_UAC_ERROR_IFSET MAKE_UAC_ERROR(-115) #define COS_UAC_ERROR_INVALID_RM_CMD MAKE_UAC_ERROR(-121) #define COS_UAC_ERROR_INVALID_IOCTLV_CMD MAKE_UAC_ERROR(-122) #define COS_UAC_ERROR_CLIENT_PRIORITY MAKE_UAC_ERROR(-123) #define COS_UAC_ERROR_CLIENT_TXN_BUF_ERROR MAKE_UAC_ERROR(-124) #define COS_UAC_ERROR_MAX_QUEUE MAKE_UAC_ERROR(-125) #define COS_UAC_ERROR_NO_MEMORY MAKE_UAC_ERROR(-130) #define COS_UAC_ERROR_UNDEFINED MAKE_UAC_ERROR(-199) // usb_uac_request request value #define COS_UAC_REQ_COPY_PROTECT 0x01 // Copy Protect Control #define COS_UAC_REQ_MIXER 0x02 // Mixer Control Request #define COS_UAC_REQ_SELECTOR 0x03 // Selector Control Request #define COS_UAC_REQ_MUTE 0x04 // Mute Control Request #define COS_UAC_REQ_VOLUME 0x05 // Volume Control Request #define COS_UAC_REQ_BASS 0x06 // Bass Control Request #define COS_UAC_REQ_MID 0x07 // Mid Control Request #define COS_UAC_REQ_TREBLE 0x08 // Treble Control Request #define COS_UAC_REQ_GRAPHIC_EQUALIZER 0x09 // Graphic Equalizer Control Request #define COS_UAC_REQ_AUTOMATIC_GAIN 0x0a // Automatic Gain Control Request #define COS_UAC_REQ_DELAY 0x0b // Delay Control Request #define COS_UAC_REQ_BASS_BOOST 0x0c // Bass Boost Control Request #define COS_UAC_REQ_LOUDNESS 0x0d // Loudness Control Request #define COS_UAC_REQ_UP_DOWN_MIX_ENABLE 0x0e // Up/Down-mix Enable Control Request #define COS_UAC_REQ_UP_DOWN_MIX_MODE_SELECT 0x0f // Up/Down-mix Mode Select Control Request #define COS_UAC_REQ_DOLBY_PROLOGIC_ENABLE 0x10 // Dolby Prologic Enable Control Request #define COS_UAC_REQ_DOLBY_PROLOGIC_MODE_SELECT 0x11 // Dolby Prologic Mode Select Control Request #define COS_UAC_REQ_3D_STEREO_EXTENDER_ENABLE 0x12 // 3D Stereo Extender Enable Control Request #define COS_UAC_REQ_3D_STEREO_EXTENDER_SPACIOUSNESS 0x13 // 3D Stereo Extender Spaciousness Control Request #define COS_UAC_REQ_REVERBERATION_ENABLE 0x14 // Reverberation Enable Control Request #define COS_UAC_REQ_REVERBERATION_LEVEL 0x15 // Reverberation Level Control Request #define COS_UAC_REQ_REVERBERATION_TIME 0x16 // Reverberation Time Control Request #define COS_UAC_REQ_REVERBERATION_FEEDBACK 0x17 // Reverberation Feedback Control Request #define COS_UAC_REQ_CHORUS_ENABLE 0x18 // Chorus Enable Control Request #define COS_UAC_REQ_CHORUS_LEVEL 0x19 // Chorus Level Control Request #define COS_UAC_REQ_CHORUS_RATE 0x1a // Chorus Rate Control Request #define COS_UAC_REQ_CHORUS_DEPTH 0x1b // Chorus Depth Control Request #define COS_UAC_REQ_DRC_ENABLE 0x1c // Dynamic Range Compressor Enable Control Request #define COS_UAC_REQ_DRC_COMPRESSION_RATE 0x1d // Dynamic Range Compressor Compression Rate Control Request #define COS_UAC_REQ_DRC_MAXAMPL 0x1e // Dynamic Range Compressor MaxAmpl Control Request #define COS_UAC_REQ_DRC_THRESHOLD 0x1f // Dynamic Range Compressor Threshold Control Request #define COS_UAC_REQ_DRC_ATTACK_TIME 0x20 // Dynamic Range Compressor Attack Time Control Request #define COS_UAC_REQ_DRC_RELEASE_TIME 0x21 // Dynamic Range Compressor Release Time Control Request #define COS_UAC_REQ_EXTENSION_ENABLE 0x22 // Extension Enable Control Request #define COS_UAC_REQ_SAMPLING_FREQUENCY 0x30 // Sampling Frequency Control Request #define COS_UAC_REQ_PITCH 0x31 // Pitch Control Request #define COS_UAC_REQ_ENTITY_MEMORY 0x40 // Entity Memory Request #define COS_UAC_REQ_ENTITY_STATUS 0x41 // Entity Status Request #define COS_UAC_SET_FORMAT 0x80 // Set Format UAC_FORMAT_PCM or UAC_FORMAT_ULAW // usb_uac_request Code Value #define COS_UAC_SET_CUR 0x01 #define COS_UAC_SET_MIN 0x02 #define COS_UAC_SET_MAX 0x03 #define COS_UAC_SET_RES 0x04 #define COS_UAC_SET_MEM 0x05 #define COS_UAC_GET_CUR 0x81 #define COS_UAC_GET_MIN 0x82 #define COS_UAC_GET_MAX 0x83 #define COS_UAC_GET_RES 0x84 #define COS_UAC_GET_MEM 0x85 #define COS_UAC_GET_STAT 0xFF #define COS_UAC_GET_REQ_TYPE 0x80 // usb_uac_request Channel #define COS_UAC_ALL_CH 0xff /* device capability definitions */ /* sample formats */ #define FORMAT_PCM_8 (1 << 0) #define FORMAT_PCM_16 (1 << 1) #define FORMAT_U_LAW (1 << 2) #define FORMAT_A_LAW (1 << 3) /* channel designation */ #define CHANNELS_ONE (1 << 0) #define CHANNELS_TWO (1 << 1) /* sample rates */ #define RATE_8000 (1 << 0) #define RATE_11025 (1 << 1) #define RATE_16000 (1 << 2) #define RATE_22050 (1 << 3) #define RATE_24000 (1 << 4) #define RATE_32000 (1 << 5) #define RATE_44100 (1 << 6) #define RATE_48000 (1 << 7) typedef short int pcm_16_t; typedef char pcm_8_t; typedef struct { unsigned long int sample_formats; unsigned long int num_channels; unsigned long int sample_rates; unsigned long int buffer_size; unsigned long int dev_type; } cos_uac_dev_cap_base_t; #define COS_UAC_TYPE_MIC (0) #define COS_UAC_TYPE_OUT (1) #define COS_UAC_NUM_TYPE (2) typedef struct { cos_uac_dev_cap_base_t caps[COS_UAC_NUM_TYPE]; } cos_uac_dev_cap_t; #define MAX_HUB_HIERARCHY (8) typedef struct { unsigned long int udd; unsigned long int i_host; unsigned short int vid; unsigned short int pid; unsigned char a_port[MAX_HUB_HIERARCHY]; } cos_uac_dev_info_t; typedef enum { cos_uac_evt_attach, cos_uac_evt_detach, cos_uac_evt_init, cos_uac_evt_uninit, cos_uac_evt_error } cos_uac_event_type_t; typedef unsigned long int cos_uac_instance_t; typedef struct { cos_uac_event_type_t event; cos_uac_instance_t h_inst; int error; } cos_uac_event_data_t; typedef void (*cos_uac_event_t)(void*, cos_uac_event_data_t*, cos_uac_dev_info_t*, cos_uac_dev_cap_t*); typedef enum { e_input, e_output } cos_uac_target_stream_t; typedef struct { unsigned char request; unsigned char code; unsigned short int value; unsigned char* ret_buf; unsigned short int size; unsigned short int channel; } cos_uac_request_t; /* context, buffer, num iTD, per iTD, sequence #, mps, error */ typedef void (* cos_uac_xfer_complete_t)(void*, void*, unsigned int, long int*, unsigned long int, unsigned int, int); int cos_uac_submit_rc(cos_uac_instance_t, void*, unsigned int, unsigned int,long int*, void*, cos_uac_xfer_complete_t); int cos_uac_submit_tx(cos_uac_instance_t, void*, unsigned int, unsigned int,long int*, void*, cos_uac_xfer_complete_t); int cos_uac_request(cos_uac_instance_t, cos_uac_request_t*, cos_uac_target_stream_t); int cos_uac_start(cos_uac_instance_t, cos_uac_target_stream_t, unsigned long int); int cos_uac_stop(cos_uac_instance_t, cos_uac_target_stream_t); int cos_uac_check_bus(void); int cos_uac_class_query_init(unsigned int, unsigned int); int cos_uac_class_init(void*, cos_uac_event_t, void*, unsigned long int, unsigned int, unsigned int); int cos_uac_release_instance(cos_uac_instance_t); int cos_uac_class_exit(void);