am_c_utilities.c

来自「Motorola synergy audio component」· C语言 代码 · 共 1,431 行 · 第 1/5 页

C
1,431
字号
    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_seaweed_gains ( UINT8 volume, UINT8 gain_table_index ){    return (0) ;}/*==================================================================================================FUNCTION:     get_dsp_gainsDESCRIPTION:    Indexes the correct gain table to get the base DSP gain and volume step multiplier    to compute the correct gain.ARGUMENTS PASSED:    source           - The source of the audio to be routed by the DSP.    destination      - The destination of the audio to be routed by the DSP.    volume           - The current volume bar level.    gain_table_index - An index to the appropriate gain table.    RETURN VALUE:    dsp_gain_ret_val - The DSP gain for a given volume step and device, in 4.11 format.PRE-CONDITIONS:    None POST-CONDITIONS:    NoneIMPORTANT NOTES:    None. ==================================================================================================*/INT16get_dsp_gains ( UINT8 source, UINT8 destination, UINT8 volume, UINT8 gain_table_index, UINT8 gain_index ){    /*  Initialize the dsp gain with the value used to undo the audio path. */    INT32  dsp_gain_ret_val = 0x00000000 ;    /*  This value indexes a multiplier table used to convert a base gain     *  to the gain corresponding to the passed in volume step.     */    UINT8  dsp_mult_index = 0 ;    if ( gain_index == AM_C_DSP_MATRIX_GAIN )    {        /*  The first dsp gain is always a matrix gain. */        dsp_gain_ret_val = am_hw_gain_table[ gain_table_index ].dsp_base_gain_1 ;        dsp_mult_index   = am_hw_gain_table[ gain_table_index ].dsp_mult_index_1 ;    }    else    if ( gain_index == AM_C_DSP_AUX_GAIN )    {        /*  The second dsp gain can be a matrix gain in the sidetone case,         *  or a CTG gain when playing tones, or is sometimes unused.         */        dsp_gain_ret_val = am_hw_gain_table[ gain_table_index ].dsp_base_gain_2 ;        dsp_mult_index   = am_hw_gain_table[ gain_table_index ].dsp_mult_index_2 ;    }    /*  Multiply the base DSP gain by the multiplier for the current volume step. */    dsp_gain_ret_val *= am_hw_vol_step_table[ dsp_mult_index ][ volume ] ;    /*  Divide the result by 2 ** 11 to get the correct value. */    dsp_gain_ret_val  = ( dsp_gain_ret_val >> AM_HW_4_11_SHIFT ) ;    return ( (INT16) dsp_gain_ret_val ) ;}/*==================================================================================================FUNCTION: DESCRIPTION:    Function to determine the hardware 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_hardware_gains ( UINT8 volume, UINT8 gain_table_index ){    UINT32 hardware_gain_ret_val = 0x00000000 ;    UINT8  hardware_table_index  = 0;    /*  Extract the index to the correct volume step table from the gain table. */    hardware_table_index = am_hw_gain_table[ gain_table_index ].hw_index_1 ;    /*  Get the four bit GCAP gain, or the CDMA CODEC and OUTPUTAMPCTL bits,     *  and add the offset (indexed by the type of table and volume step),     *  and store the resulting gain in the least significant word.     */    hardware_gain_ret_val = ( am_hw_gain_table[ gain_table_index ].hw_base_gain_1                             + am_hw_vol_step_table[ hardware_table_index ][ volume ] ) ;    return ( hardware_gain_ret_val ) ;}/*==================================================================================================FUNCTION:     determine_gain_tableDESCRIPTION:    Uses device and tone path info to return the appropriate gain table index.ARGUMENTS PASSED:    device           - The handset or active accessory.    path_type        - The path associated with the tone type be played.    in_call          - TRUE = phone is in a call, FALSE = not in a call.    mic_or_speaker   - Determines if the gain table is for a mic or a speaker.     RETURN VALUE:    gain_table_index - An index to the appropriate gain table.PRE-CONDITIONS:    None POST-CONDITIONS:    NoneIMPORTANT NOTES:    None. ==================================================================================================*/UINT8determine_gain_table ( UINT8  device,                       UINT8  path_type,                       BOOL   in_call,                       UINT8  mic_or_speaker ){    /*  This holds the return value, an index to the appropriate gain table. */     UINT8 gain_table_index;#if (MAKE_NEPTUNE_CHIPSET == TRUE)    /* This will be used to get battery level reading, to determine different gain table for high B+ cases */    UINT8 batt_lvl;#endif /*(MAKE_NEPTUNE_CHIPSET == TRUE)*/    /*  Determine if the phone has an internal speakerphone */    BOOL speakerphone = DL_AccGetConnectionStatus(DL_ACC_DM_INTERNAL_SPEAKER_PHONE);     /* No check is done for an invalid mic_or_spkr value, THIS MAY NOT BE CORRECT */    gain_table_index = 0;    /*  See if the gain is a speaker gain. */    if ( mic_or_speaker == AM_HW_SPKR_GAIN_TYPE )    {        /*  The default case is to shut off the RX audio gains and path. */        gain_table_index = AM_HW_INACTIVE_GAIN_SPEAKER_TABLE;        if ((device == DL_ACC_DM_HEADSET )             /* Analog 'BOOM' cable headset. */#if (STEREO_HEADSET_SUPPORTED == TRUE)            ||  (device == DL_ACC_DM_STEREO_HEADSET) #endif#if (MAKE_TTY == TRUE)            ||   ( device == DL_ACC_DM_DIG_TTY )                /* Digital TTY           */#endif            )        {            switch ( path_type )            {                case AM_AUDIO_PATH_ID_UI_LITE:                case AM_AUDIO_PATH_ID_KEY_LITE:                case AM_AUDIO_PATH_ID_NETWORK_LITE:                    /*  For all UI, Keypress and network tones EXCEPT the accessory                      *  connect tone for a wired headset, use the normal headset gains.                     */                    gain_table_index = AM_HW_DTMF_BOOM_SPEAKER_TABLE;                    break;                case AM_AUDIO_PATH_ID_ALERT_LITE:                case AM_AUDIO_PATH_ID_MULTIMEDIA_ALERT:                    /*  Because we want the user to hear alerts when tempprarily                     *  taking off the headset, use the transducer.                     */                    #if (MAKE_NEPTUNE_CHIPSET == TRUE)  #if (MAKE_HDW_BB_IC == MAKE_HDW_NEPTUNE_LTS)                    gain_table_index = AM_HW_ALERT_INT_SPEAKERPHONE_SPEAKER_TABLE;                    break;#elif (MAKE_HDW_BB_IC == MAKE_HDW_NEPTUNE_LT)                      /* check if battery level >= 2 bars in standby or >= 3 bars in-call to increase loudness                     * for high B+ voltages. We're not using the in_call variable, since it doesn't cover all                     * we need. Instead we use a flag that's raised before the call setup and lowered when ended                     */                    batt_lvl = SBCM_DISPLAY_get_batt_lvl();                                        if ((am_is_call_pending == FALSE) && (batt_lvl >= SBCM_DISPLAY_BATT_LVL_3))                    {                        gain_table_index = AM_HW_ALERT_INT_SPEAKERPHONE_HIGH_BPLUS_SPEAKER_TABLE;                    }                    else if ((am_is_call_pending == TRUE) && (batt_lvl == SBCM_DISPLAY_BATT_LVL_4))                    {                        gain_table_index = AM_HW_ALERT_INT_SPEAKERPHONE_HIGH_BPLUS_SPEAKER_TABLE;                    }                    else                     {                        gain_table_index = AM_HW_ALERT_INT_SPEAKERPHONE_SPEAKER_TABLE;                    }                    break;#endif#else                        if(speakerphone)                    {                        gain_table_index = AM_HW_ALERT_INT_SPEAKERPHONE_SPEAKER_TABLE;                    }                    else                    {                        gain_table_index = AM_HW_ALERT_TRANSDUCER_TABLE;                    }                    break;#endif /*end of #IF (MAKE_NEPTUNE_CHIPSET) == TRUE*/                case AM_AUDIO_PATH_ID_VOICE:                    gain_table_index = AM_HW_VOICE_BOOM_SPEAKER_TABLE;                    #if (MAKE_TTY == TRUE)                         if ( (am_event_tty_mode == AM_HW_TTY_MODE_FULL)                        ||   (am_event_tty_mode == AM_HW_TTY_MODE_VCO) )                        {                            gain_table_index = AM_HW_TTY_FULL_OR_VCO_BOOM_SPEAKER_TABLE;                        }                     #endif                    break;#if ( (MAKE_FTR_VR == TRUE) || (MAKE_FTR_VA == TRUE) )                case AM_AUDIO_PATH_ID_VA_VR_OUTPUT:                    gain_table_index = AM_HW_VA_PLAYBACK_BOOM_SPEAKER_TABLE;                    break;  #endif                case AM_AUDIO_PATH_ID_MULTIMEDIA_PLAY:                case AM_AUDIO_PATH_ID_MULTIMEDIA_UI:                    #if (AUDIO_RAINBOW == TRUE)                    gain_table_index = AM_HW_MULTIMEDIA_SPEAKER_TABLE;#elif (MAKE_FTR_VA == TRUE)                    gain_table_index = AM_HW_VA_PLAYBACK_BOOM_SPEAKER_TABLE;#endif                    break;                case AM_AUDIO_PATH_ID_FUNLIGHTS :#if ( (MAKE_FTR_VR == TRUE) || (MAKE_FTR_VA == TRUE) )                case AM_AUDIO_PATH_ID_VA_VR_IO :                case AM_AUDIO_PATH_ID_VR_IO:                case AM_AUDIO_PATH_ID_VA_IO:

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?