am_c_utilities.c
来自「Motorola synergy audio component」· C语言 代码 · 共 1,431 行 · 第 1/5 页
C
1,431 行
AM_HW_VA_REC_USB_MIC_TABLE , AM_HW_VA_REC_SAP_MIC_TABLE , AM_HW_VA_REC_SMART_AUDIO_MIC_TABLE , AM_HW_VR_INT_MIC_TABLE , AM_HW_VR_PANTHER_INT_MIC_TABLE , AM_HW_VR_BOOM_MIC_TABLE , AM_HW_VR_CE_DEVICE_MIC_TABLE , AM_HW_VR_CLIP_ON_SPEAKERPHONE_MIC_TABLE , AM_HW_VR_INT_SPEAKERPHONE_MIC_TABLE , AM_HW_VR_USB_MIC_TABLE , AM_HW_VR_SAP_MIC_TABLE , AM_HW_VR_SMART_AUDIO_MIC_TABLE , AM_HW_TONE_GEN_TO_VA_REC_TABLE , AM_HW_TONE_GEN_TO_UPLINK_SPEECH_TABLE , AM_HW_HS_INT_MULTIMEDIA_MIC_TABLE, AM_HW_HF_BOOM_MULTIMEDIA_MIC_TABLE, AM_HW_HF_EXT_MULTIMEDIA_MIC_TABLE } ;#endif/*================================================================================================== LOCAL MACROS==================================================================================================*//*================================================================================================== LOCAL VARIABLES==================================================================================================*/static DL_DB_FEATURE_ID_T am_volume_step_feature_id = DL_DB_FEATURE_ID_HANDSET_VOICE_VOLUME ;#if (MAKE_NEPTUNE_CHIPSET == TRUE)/* variable to indicate whether a call is pending, indicating to use different gains */static BOOL am_is_call_pending;#endif /*(MAKE_NEPTUNE_CHIPSET == TRUE)*//*================================================================================================== GLOBAL VARIABLES==================================================================================================*/GAIN_STRUCT gain_struct ;static BOOL am_ptt_session_state ;static BOOL am_is_coder_on_allowed = TRUE;extern BOOL am_bt_dual_routing ;SU_TIMER_HANDLE am_hardware_delay_timer_handle;SU_TASK_HANDLE am_task_handle;SU_EVMASK am_event_mask;SU_EVNUM am_event_number;/*================================================================================================== LOCAL FUNCTIONS==================================================================================================*//*================================================================================================== GLOBAL FUNCTIONS==================================================================================================*//*==================================================================================================FUNCTION: void get_gainDESCRIPTION: Returns the DSP, hardware speaker, and hardware mic audio gains.ARGUMENTS PASSED: device - The currently active device, i.e., handset, boom headset, etc. source - The source of the audio to be routed by the DSP. destination - The destination of the audio to be routed by the DSP. path_type - The path type determined by the tone. volume - The current volume bar level setting. in_call - A boolean where TRUE=1=in call, FALSE=0=out of call. RETURN VALUE: gain_struct - A pointer to a structure holding the hardware and DSP gains.PRE-CONDITIONS: None POST-CONDITIONS: NoneIMPORTANT NOTES: 1) This interface is written in C, rather than C++ so that it can be called by the Test Task, as well as by the Audio Manager. Any changes must be agreed to by both the Audio Manager and Test Task groups. 2) get_gain only returns gains for one direction per call, for example, a microphone or a speaker, but not both. It is the callers responsibility to call this function twice and then the hardware gains MUST be bitwise OR'd together before using them. Please note that the caller must save the gains after each call or they will be overwritten!==================================================================================================*/GAIN_STRUCT * get_gain (UINT8 device,UINT8 source,UINT8 destination,UINT8 path_type,UINT8 volume,BOOL in_call){ UINT8 mic_or_speaker; volatile UINT8 gain_table_index; static const UINT8 mic_vs_spkr[MATRIX_SOURCE_MAX+1][MATRIX_DESTINATION_MAX+1] = {/****************************************************************** * 0 = AM_HW_INVALID_GAIN_TYPE - This table deselects a path. * * 1 = AM_HW_SPKR_GAIN_TYPE * * 2 = AM_HW_MIC_GAIN_TYPE * * * * D E S T I N A T I O N S * * ================================== * * U C U S S S V V D * * P O S A A A A R S * * L D B P P P C * * I E R | * * N C S T T T E | S * * K P X X X C | P * * S E | E * * S P A S S S | | A * * P E K L L L | | K * * E A E O O O | | E * * E K R T T T | | R * * C E | | * * H R | 1 2 3 | | | * * ________|___|___|___|___|___|___| * * 0 1 2 3 4 5 6 7 8 * ******************************|***|***|***|***|***|***|***|***|***//* | 0 DOWNLINK_SPEECH*/ { 0, 1, 1, 1, 0, 0, 1, 1, 0 },/* S | 1 CODEC_MIC */ { 2, 0, 0, 0, 0, 0, 2, 2, 0 },/* O | 2 USB_MIC */ { 2, 0, 0, 0, 0, 0, 2, 2, 0 },/* U | 3 SAP_RX_SLOT_1 */ { 2, 1, 1, 1, 0, 0, 2, 2, 0 },/* R | 4 SAP_RX_SLOT_2 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },/* C | 5 SAP_RX_SLOT_3 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },/* E | 6 VA_PLAYBACK */ { 2, 1, 1, 1, 0, 0, 0, 0, 0 },/* S | 7 VR_PROMPTS */ { 2, 1, 1, 1, 0, 0, 0, 0, 0 },/* | 8 DSC_MIC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },/* | 9 TONE_GENERATOR */ { 0, 1, 1, 1, 0, 0, 1, 1, 0 },/* | A MEDIA_ENGINE */ { 0, 1, 1, 1, 0, 0, 1, 1, 0 }}; /* Determine whether we are looking for a mic or speaker gain table. */ mic_or_speaker = mic_vs_spkr[source][destination]; /* Find the gain table index based on the device type, tone path type * and if mic or spkr. * The volume has been added so that in the case of the accessory connect * tone we can select a special, higher amplitude tone table capable * of allowing left channel detection in the case of a stereo headset. */ gain_table_index = determine_gain_table ( device, path_type, in_call, mic_or_speaker ); /* Compute the dsp gain(s) with the passed in volume level and the gain table * index found above. The first gain is always a matrix gain. * The second gain is the matrix sidetone gain for the handset and analog * headsets, OR the common tone generator (CTG) gain for DSP * generated tones, OR undefined otherwise. * Technical Marketing decided the way to mute non-voice tones was to make the * gain for the zero volume step equal to zero, effectively muting the output. */ /* Default the DSP matrix gain. */ gain_struct.dsp_gain_1 = (UINT16) MUTE_DSP_AUDIO; /* Mute DSP generated keypad and UI tones to the speaker * if the volume step is zero, and we're not in a call. * - So if either the volume is non-zero * OR we're in a PTT call * OR we're in a call OR the device is a mic * OR the tone is an alert AND silent details are accessible * OR playing an alert AND weve flexed alerts to be audible at level zero * OR we've been requested to play either a network tone * OR if the audio is voice * THEN overwrite the default mute gain with the required gain. */ if ( ( volume > 0 ) || ( am_get_ptt_session_state() == TRUE ) || ( in_call == TRUE ) || ( mic_or_speaker == AM_HW_MIC_GAIN_TYPE ) || ((( path_type == AM_AUDIO_PATH_ID_ALERT_LITE )|| (path_type == AM_AUDIO_PATH_ID_MULTIMEDIA_ALERT))#if (MAKE_NEPTUNE_CHIPSET == TRUE) && ( ! DL_DbGetFeatureAvailability( DL_DB_FEATURE_ID_ALERTS_SILENT_AT_ZERO_AVAILABLE))#endif /* we do NOT want to play anything of alert path when ringer profile is SILENT */ && (am_app_feature_server_read_state(DL_DB_FEATURE_ID_CURRENT_ALERT_TYPE) != DL_DB_FEATURE_STATE_ALERT_SILENT) && (am_app_feature_server_read_state(DL_DB_FEATURE_ID_CURRENT_ALERT_TYPE) != DL_DB_FEATURE_STATE_ALERT_VIBRATE)) || ( path_type == AM_AUDIO_PATH_ID_NETWORK_LITE ) || ( path_type == AM_AUDIO_PATH_ID_VOICE ) || ( path_type == AM_AUDIO_PATH_ID_MULTIMEDIA_MFT_VIB )#if ( (MAKE_FTR_VR == TRUE) || (MAKE_FTR_VA == TRUE) ) || ( path_type == AM_AUDIO_PATH_ID_VA_VR_OUTPUT ) #endif ) { AUD_LOG_SCO_STATE_T am_sco_info; gain_struct.dsp_gain_1 = get_dsp_gains( source, destination, volume, gain_table_index, AM_C_DSP_MATRIX_GAIN ); /* If there is something to play, set the sco state to on. We shouldn't set the SCO on when we are playing some silent audio, since it will cause Entertainment Mute on the BT carkit. We don't need to set the sco state on in-call, since dl_audio already does it. */ /* The 'semaphore' am_bt_dual_routing was added to make sure that when we * set up the speakerphone for the BT alert dual routing case, that we don't * shut down the SCO link because the device type is internal speakerphone. * am_bt_dual_routing is set to TRUE in set_alert_path() just before calling * get_gain() with a device type of internal speakerphone and set to FALSE * immediately after. */ if ( ( device == DL_ACC_DM_BT_HEADSET ) || ( device == DL_ACC_DM_BT_HANDSFREE ) || ( am_bt_dual_routing == TRUE ) ) { if (!in_call) { // Request that the Bluetooth audio link (SCO) be set up. DL_AccSetScoState(SCO_STATE_ON); // For data logging, record the SCO state as on/true, from code location #2. am_sco_info.sco_state_is_on = TRUE; am_sco_info.code_location = 2; am_send_log_data( (UINT32) AUD_LOG_SCO_STATE, (char *) & am_sco_info, sizeof( AUD_LOG_SCO_STATE_T ) ); } } else { // Send a message to DL to request that the SCO link be torn down. DL_AccSetScoState( SCO_STATE_OFF ); // For data logging, record the SCO state as off/false, from code location #3. am_sco_info.sco_state_is_on = FALSE; am_sco_info.code_location = 3; am_send_log_data( (UINT32) AUD_LOG_SCO_STATE, (char *) & am_sco_info, sizeof( AUD_LOG_SCO_STATE_T ) ); } } gain_struct.dsp_gain_2 = get_dsp_gains ( source, destination, volume, gain_table_index, AM_C_DSP_AUX_GAIN ) ; /* Compute the hardware gain for the appropriate device and direction, i.e., RX or TX. */ gain_struct.hardware_gain = get_hardware_gains ( volume, gain_table_index ) ; return ( &gain_struct ) ;}/*==================================================================================================FUNCTION: DESCRIPTION: Function to determine the PCAP IC register gain and path bits for a passed in gain table index and volume step. The gain tables just have the gain for volume step zero. To compute the gain adjusted for any given volume step, we need to index the volume step table using the volume step index associated with the base (zero volume gain) and the passed in volume step, and add the indexed volume step gain to the base gain.ARGUMENTS PASSED: gain_table_index - An offset to the appropriate gain table. volume - The current volume bar level. RETURN VALUE: hardware_gain_ret_val - The hardware path and gain register bits to set the proper gains in the GCAP for GSM and TDMA, or the CCAP for CDMA.PRE-CONDITIONS: None POST-CONDITIONS: NoneIMPORTANT NOTES: None. ==================================================================================================*/UINT32get_pcap_gains ( UINT8 volume, UINT8 gain_table_index ){ return (0) ;}/*==================================================================================================FUNCTION: DESCRIPTION: Function to determine the SEAWEED IC register gain and path bits
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?