rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * sp_enhance.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * MAUI |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * speech enhancement functions (moved from am.c) |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * ------- |
| 54 | * |
| 55 | *============================================================================== |
| 56 | * HISTORY |
| 57 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 58 | *------------------------------------------------------------------------------ |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * removed! |
| 105 | * |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * removed! |
| 109 | * |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * removed! |
| 113 | * |
| 114 | * removed! |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * |
| 118 | * removed! |
| 119 | * removed! |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * removed! |
| 127 | * removed! |
| 128 | * removed! |
| 129 | * |
| 130 | * removed! |
| 131 | * removed! |
| 132 | * removed! |
| 133 | * |
| 134 | * removed! |
| 135 | * removed! |
| 136 | * removed! |
| 137 | * |
| 138 | * |
| 139 | *------------------------------------------------------------------------------ |
| 140 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 141 | *============================================================================== |
| 142 | *******************************************************************************/ |
| 143 | |
| 144 | #include "kal_public_api.h" |
| 145 | |
| 146 | |
| 147 | |
| 148 | #include "kal_general_types.h" |
| 149 | #include "sync_data.h" |
| 150 | |
| 151 | // #include "reg_base.h" |
| 152 | |
| 153 | #include "l1audio.h" |
| 154 | |
| 155 | #include "kal_trace.h" |
| 156 | #include "l1sp_trc.h" |
| 157 | |
| 158 | #include "sp_enhance.h" |
| 159 | #include "sp_drv.h" |
| 160 | #include "am.h" |
| 161 | #include "media.h" |
| 162 | #include "afe.h" |
| 163 | |
| 164 | |
| 165 | #include "ddload.h" |
| 166 | |
| 167 | |
| 168 | #include "sal_def.h" |
| 169 | #include "sal_exp.h" |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | const unsigned short Common_Param_Default[72] = { 0, 0xB , 0x1010 ,0 ,0 ,0,0,0 , |
| 179 | 0xC , 0x64,0xDABD,0x7918,0x2A00,0x8001,0x0,0x0,0x0,0x0,0x0,0x0,0x0 , |
| 180 | 0x10 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, |
| 181 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 182 | 0xB0B, 0 ,0, 0 |
| 183 | }; |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | const unsigned short DMNR_Param_Default[1468] = { 0 , 0xC , 0x1010,0,0, 0,0,0 , |
| 190 | 0x1001, 44 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0 , |
| 191 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 , |
| 192 | 0x1002, 44 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0 , |
| 193 | 0x0,0x0,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0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 206 | }; |
| 207 | |
| 208 | const unsigned short MagiClarity_Param_Default[75] = { 0, 0xD, 0x1010,0,0, 0,0,0, |
| 209 | 32, 0xFF73,0x01C3,0x01DC,0x0240,0x026E,0x022B,0x0156,0xFFE5,0xFDEB,0xFB89,0xF8E6,0xF60E,0xF2C3,0xEDFB,0xE38B,0xAE09,0x51F7,0x1C75,0x1205,0x0D3D,0x09F2,0x071A,0x0477,0x0215,0x001B,0xFEAA,0xFDD5,0xFD92,0xFDC0,0xFE24,0xFE3D,0x008D , 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 210 | 0xD0D, 0 ,0, 0 |
| 211 | }; |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | const unsigned short Speech_Param_Default[418 + 134] = |
| 217 | { 0, 0xA, 0x1010,0,0, 0,0,0, 0x1001, |
| 218 | 64, 0x60,0xFD,0x4004,0x1F,0xE107,0x231F,0x195,0x40,0x110,0xC5,0x262,0x0,0x4008,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 219 | 90, 0x7FFF,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0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x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3BB,0x2, |
| 224 | 42, 0x7A90,0xC524,0x8001,0x4000,0x7F54,0xC090,0x800A,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3BB,0x2, |
| 225 | 90, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 226 | 42, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0, |
| 227 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 228 | 0xA0A, 0,0,0 |
| 229 | }; |
| 230 | |
| 231 | const unsigned short Param_Default[2167] = { 0 }; |
| 232 | |
| 233 | |
| 234 | short Speech_All_Pass_MAG_CLARITY[32] = |
| 235 | { /* All pass filter */ |
| 236 | 32767, 0, 0, 0, 0, |
| 237 | 0, 0, 0, 0, 0, |
| 238 | 0, 0, 0, 0, 0, |
| 239 | 0, 0, 0, 0, 0, |
| 240 | 0, 0, 0, 0, 0, |
| 241 | 0, 0, 0, 0, 0, |
| 242 | 0, 0 |
| 243 | }; |
| 244 | |
| 245 | const unsigned short Speech_Common_Para[12] = |
| 246 | { |
| 247 | 0, 55997, 31000, 10752, 32769, 0, 0, 0, 0, 0, |
| 248 | 0, 0 |
| 249 | }; |
| 250 | const unsigned short Debug_Info_Para[16] = |
| 251 | { |
| 252 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 253 | 0, 0, 0, 0, 0, 0 |
| 254 | }; |
| 255 | |
| 256 | |
| 257 | #if defined(_SPE_ENH_MD_PARSE_) |
| 258 | #define Par_Speech_Common 0 //Volume Dependent ,speech unit : ModePar,FIR in,Fir out |
| 259 | #define Par_GSM_NB_SpeechUnit 1 |
| 260 | #define Par_GSM_WB_SpeechUnit 2 |
| 261 | #define Par_WCDMA_NB_SpeechUnit 3 |
| 262 | #define Par_WCDMA_WB_SpeechUnit 4 |
| 263 | #define Par_CDMA_NB_SpeechUnit 5 |
| 264 | #define Par_CDMA_WB_SpeechUnit 6 |
| 265 | #define Par_VOLTE_NB_SpeechUnit 7 |
| 266 | #define Par_VOLTE_WB_SpeechUnit 8 |
| 267 | #define Par_C2K_NB_SpeechUnit 9 |
| 268 | #define Par_C2K_WB_SpeechUnit 10 |
| 269 | #define Par_VOLTE_SWB_SpeechUnit 11 |
| 270 | #endif |
| 271 | kal_enhmutexid spe_enh_mutex; |
| 272 | |
| 273 | // #define TOTAL_NUM_SPH_MODE (NUM_SPH_MODE+2) // new 1 for HAC, 1 for USB |
| 274 | // #define TOTAL_NUM_SPH_INPUT_FIR (NUM_SPH_INPUT_FIR+2) // new 1 for HAC, 1 for USB |
| 275 | // #define TOTAL_NUM_SPH_OUTPUT_FIR (NUM_SPH_OUTPUT_FIR+2) // new 1 for HAC, 1 for USB |
| 276 | typedef struct |
| 277 | { |
| 278 | // uint8 sph_mode; |
| 279 | bool spe_flag; |
| 280 | bool EMI_isExist; |
| 281 | bool spe_isFweOn; |
| 282 | |
| 283 | uint8 sph_SPE_path; // ul_only=0,dl_only=1,ul+dl=2 |
| 284 | // uint16 spe_state; // record which enhancement is open |
| 285 | |
| 286 | // uint16 spe_usr_sub_mask; // record the usage of enhancement sub feature. Sync with Sal_Enh_Dynamic_t definition. Ex. phonecall should be turned on DMNR, but users can decide whether turn on or not.please do not update the mask directly, please use function l1sp_updateUsrSubMask() to update |
| 287 | uint16 spe_usr_enh_ctrl; // bit0=DMNR,bit1=TDDNC,bit2=magi con |
| 288 | bool spe_is_update_enh_ctrl; |
| 289 | #if defined(_SPE_ENH_MD_PARSE_) |
| 290 | int16 sph_dmnr_para[NUM_DMNR_PARAM]; |
| 291 | int16 sph_wb_dmnr_para[NUM_WB_DMNR_PARAM]; |
| 292 | int16 sph_swb_dmnr_para[NUM_SWB_DMNR_PARAM]; |
| 293 | int16 sph_lspk_dmnr_para[NUM_DMNR_PARAM]; |
| 294 | int16 sph_lspk_wb_dmnr_para[NUM_WB_DMNR_PARAM]; |
| 295 | int16 sph_lspk_swb_dmnr_para[NUM_SWB_DMNR_PARAM]; |
| 296 | |
| 297 | // short sph_magi_clarity_para[NUM_MAGI_CLARITY_PARAM]; |
| 298 | uint16 sph_magicConParam[NUM_MODE_PARAS]; |
| 299 | uint16 sph_magicConWbParam[NUM_MODE_PARAS]; |
| 300 | #endif |
| 301 | uint32 sph_EMI_Info_offset; |
| 302 | uint32 sph_EMI_Info_len; |
| 303 | bool isMagiConOn; |
| 304 | |
| 305 | bool isHacModeNeeded; // if AP send Hac paramters and FIRs to MD, the flag will be set. |
| 306 | bool isSPE_Enable; // check SPE already enable or not |
| 307 | // uint8 spe_Path; |
| 308 | // bool isReDDL; |
| 309 | #if defined(_SPE_ENH_MD_PARSE_) |
| 310 | // --NB-- |
| 311 | uint16 sph_ModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 312 | int16 sph_InFirCoeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 313 | int16 sph_OutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 314 | int16 sph_InIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 315 | int16 sph_OutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 316 | int16 sph_Mic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 317 | int16 sph_Mic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 318 | // --WB-- |
| 319 | uint16 sph_WbModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 320 | int16 sph_WbInFirCoeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 321 | int16 sph_WbOutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 322 | int16 sph_WbInIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 323 | int16 sph_WbOutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 324 | int16 sph_WbMic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 325 | int16 sph_WbMic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 326 | // --SWB-- |
| 327 | uint16 sph_SWbModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 328 | int16 sph_SWbInFirCoeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 329 | int16 sph_SWbOutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 330 | int16 sph_SWbInIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 331 | int16 sph_SWbOutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 332 | int16 sph_SWbMic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 333 | int16 sph_SWbMic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 334 | #endif |
| 335 | bool ctm_spe_status; |
| 336 | |
| 337 | } _SPE_T; |
| 338 | |
| 339 | static _SPE_T gSpe; |
| 340 | |
| 341 | void l1sp_SetParEMIInfo(uint32 offset,uint32 len) |
| 342 | { |
| 343 | gSpe.sph_EMI_Info_offset = offset ; |
| 344 | gSpe.sph_EMI_Info_len = len ; |
| 345 | |
| 346 | MD_TRC_L1SP_SPE_SET_EMI_INFO(0,gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len); |
| 347 | } |
| 348 | void l1sp_setCtmSpeStatus(bool s){ |
| 349 | gSpe.ctm_spe_status = s; |
| 350 | } |
| 351 | |
| 352 | bool l1sp_getCtmSpeStatus(){ |
| 353 | return (gSpe.ctm_spe_status); |
| 354 | } |
| 355 | |
| 356 | |
| 357 | /* ========================================================================= */ |
| 358 | #if defined(_SPE_ENH_MD_PARSE_) |
| 359 | void l1sp_setAllSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length) |
| 360 | { |
| 361 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length); |
| 362 | memcpy(gSpe.sph_ModePara, speech_mode_para, |
| 363 | TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 364 | } |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | void l1sp_setAllSpeechFirCoeff_InputOnly(kal_int16 *speech_input_FIR_coeffs, kal_int16 length) |
| 371 | { |
| 372 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS) == length); |
| 373 | memcpy(gSpe.sph_InFirCoeff, speech_input_FIR_coeffs, |
| 374 | TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16)); |
| 375 | |
| 376 | } |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | void l1sp_setAllSpeechFirCoeff_OutputOnly(kal_int16 *speech_output_FIR_coeffs, kal_int16 length) |
| 382 | { |
| 383 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS) == length); |
| 384 | memcpy(gSpe.sph_OutFirCoeff, speech_output_FIR_coeffs, |
| 385 | TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16)); |
| 386 | } |
| 387 | //IIR |
| 388 | void l1sp_setAllSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length) |
| 389 | { |
| 390 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 391 | memcpy(gSpe.sph_InIirCoeff, speech_input_IIR_coeffs, |
| 392 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 393 | |
| 394 | } |
| 395 | |
| 396 | |
| 397 | void l1sp_setAllSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length) |
| 398 | { |
| 399 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 400 | memcpy(gSpe.sph_OutIirCoeff, speech_output_IIR_coeffs, |
| 401 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 402 | } |
| 403 | |
| 404 | void l1sp_setAllSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length) |
| 405 | { |
| 406 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length); |
| 407 | memcpy(gSpe.sph_Mic1IirCoeff, speech_output_Mic1_IIR_coeffs, |
| 408 | TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 409 | } |
| 410 | void l1sp_setAllSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length) |
| 411 | { |
| 412 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length); |
| 413 | memcpy(gSpe.sph_Mic2IirCoeff, speech_output_Mic2_IIR_coeffs, |
| 414 | TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 415 | } |
| 416 | //--------------- WB ---------------- |
| 417 | void l1sp_setAllWbSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length) |
| 418 | { |
| 419 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length); |
| 420 | |
| 421 | memcpy(gSpe.sph_WbModePara, speech_mode_para, |
| 422 | TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 423 | } |
| 424 | void l1sp_setAllSWbSpeechModePara(kal_uint16 * speech_mode_para,kal_int16 length) |
| 425 | { |
| 426 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length); |
| 427 | |
| 428 | memcpy(gSpe.sph_SWbModePara, speech_mode_para, |
| 429 | TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 430 | |
| 431 | } |
| 432 | void spe_setMagiCon(void) |
| 433 | { |
| 434 | |
| 435 | gSpe.isMagiConOn = true; |
| 436 | gSpe.spe_isFweOn = true; |
| 437 | } |
| 438 | |
| 439 | void spe_DisableMagiCon(void) |
| 440 | { |
| 441 | gSpe.isMagiConOn = false; |
| 442 | gSpe.spe_isFweOn = false; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | void l1sp_setAllWbSpeechFirCoeff_InputOnly( |
| 447 | kal_int16 *speech_input_FIR_coeffs, kal_int16 length) |
| 448 | { |
| 449 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS) == length); |
| 450 | memcpy(gSpe.sph_WbInFirCoeff, speech_input_FIR_coeffs, |
| 451 | length*sizeof(int16)); |
| 452 | } |
| 453 | |
| 454 | void l1sp_setAllSWbSpeechFirCoeff_InputOnly( |
| 455 | kal_int16 *speech_input_FIR_coeffs, kal_int16 length) |
| 456 | { |
| 457 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS) == length); |
| 458 | memcpy(gSpe.sph_SWbInFirCoeff, speech_input_FIR_coeffs, |
| 459 | length*sizeof(int16)); |
| 460 | |
| 461 | } |
| 462 | |
| 463 | |
| 464 | void l1sp_setAllWbSpeechFirCoeff_OutputOnly( |
| 465 | kal_int16 *speech_output_FIR_coeffs, kal_int16 length) |
| 466 | { |
| 467 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS) == length); |
| 468 | memcpy(gSpe.sph_WbOutFirCoeff, speech_output_FIR_coeffs, |
| 469 | length*sizeof(int16)); |
| 470 | } |
| 471 | |
| 472 | void l1sp_setAllSWbSpeechFirCoeff_OutputOnly( |
| 473 | kal_int16 *speech_output_FIR_coeffs, kal_int16 length) |
| 474 | { |
| 475 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS) == length); |
| 476 | memcpy(gSpe.sph_SWbOutFirCoeff, speech_output_FIR_coeffs, |
| 477 | length*sizeof(int16)); |
| 478 | } |
| 479 | |
| 480 | //IIR |
| 481 | void l1sp_setAllWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length) |
| 482 | { |
| 483 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 484 | memcpy(gSpe.sph_WbInIirCoeff, speech_input_IIR_coeffs, |
| 485 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 486 | |
| 487 | } |
| 488 | void l1sp_setAllWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length) |
| 489 | { |
| 490 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 491 | memcpy(gSpe.sph_WbOutIirCoeff, speech_output_IIR_coeffs, |
| 492 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 493 | } |
| 494 | void l1sp_setAllWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length) |
| 495 | { |
| 496 | |
| 497 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length); |
| 498 | memcpy(gSpe.sph_WbMic1IirCoeff, speech_output_Mic1_IIR_coeffs, |
| 499 | TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 500 | |
| 501 | } |
| 502 | void l1sp_setAllWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length) |
| 503 | { |
| 504 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length); |
| 505 | memcpy(gSpe.sph_WbMic2IirCoeff, speech_output_Mic2_IIR_coeffs, |
| 506 | TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 507 | |
| 508 | } |
| 509 | void l1sp_setAllSWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length) |
| 510 | { |
| 511 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 512 | memcpy(gSpe.sph_SWbInIirCoeff, speech_input_IIR_coeffs, |
| 513 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 514 | |
| 515 | } |
| 516 | void l1sp_setAllSWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length) |
| 517 | { |
| 518 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length); |
| 519 | memcpy(gSpe.sph_SWbOutIirCoeff, speech_output_IIR_coeffs, |
| 520 | TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 521 | } |
| 522 | void l1sp_setAllSWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length) |
| 523 | { |
| 524 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length); |
| 525 | memcpy(gSpe.sph_SWbMic1IirCoeff, speech_output_Mic1_IIR_coeffs, |
| 526 | TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 527 | } |
| 528 | void l1sp_setAllSWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length) |
| 529 | { |
| 530 | ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length); |
| 531 | memcpy(gSpe.sph_SWbMic2IirCoeff, speech_output_Mic2_IIR_coeffs, |
| 532 | TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 533 | } |
| 534 | //--------------- DMNR ---------------- |
| 535 | |
| 536 | |
| 537 | /** |
| 538 | Not support parameter rewirte under application begin runnning |
| 539 | */ |
| 540 | void L1SP_SetDMNRPara( const kal_int16 DMNR_para[NUM_DMNR_PARAM] ) |
| 541 | { |
| 542 | |
| 543 | memcpy(&gSpe.sph_dmnr_para, DMNR_para, NUM_DMNR_PARAM*sizeof(uint16)); |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | Not support parameter rewirte under application begin runnning |
| 548 | */ |
| 549 | void L1SP_SetWbDMNRPara( const kal_int16 WB_DMNR_para[NUM_WB_DMNR_PARAM] ) |
| 550 | { |
| 551 | memcpy(&gSpe.sph_wb_dmnr_para, WB_DMNR_para, NUM_WB_DMNR_PARAM*sizeof(uint16)); |
| 552 | } |
| 553 | void L1SP_SetSWbDMNRPara( const kal_int16 SWB_DMNR_para[NUM_SWB_DMNR_PARAM] ) |
| 554 | { |
| 555 | memcpy(&gSpe.sph_swb_dmnr_para, SWB_DMNR_para, NUM_SWB_DMNR_PARAM*sizeof(uint16)); |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | Not support parameter rewirte under application begin runnning |
| 560 | */ |
| 561 | void L1SP_SetLSpkDMNRPara( const kal_int16 LSpk_DMNR_para[NUM_DMNR_PARAM] ) |
| 562 | { |
| 563 | memcpy(&gSpe.sph_lspk_dmnr_para, LSpk_DMNR_para, NUM_DMNR_PARAM*sizeof(uint16)); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | /** |
| 568 | Not support parameter rewirte under application begin runnning |
| 569 | */ |
| 570 | void L1SP_SetLSpkWbDMNRPara( const kal_int16 LSpk_Wb_DMNR_para[NUM_WB_DMNR_PARAM] ) |
| 571 | { |
| 572 | memcpy(&gSpe.sph_lspk_wb_dmnr_para, LSpk_Wb_DMNR_para, NUM_WB_DMNR_PARAM*sizeof(uint16)); |
| 573 | } |
| 574 | void L1SP_SetLSpkSWbDMNRPara( const kal_int16 LSpk_SWb_DMNR_para[NUM_SWB_DMNR_PARAM] ) |
| 575 | { |
| 576 | memcpy(&gSpe.sph_lspk_swb_dmnr_para, LSpk_SWb_DMNR_para, NUM_SWB_DMNR_PARAM*sizeof(uint16)); |
| 577 | } |
| 578 | |
| 579 | |
| 580 | //--------------- MagiCon (Loudspeaker mode) --------------------- |
| 581 | |
| 582 | bool spe_isSpeFweOn(void) |
| 583 | { |
| 584 | return gSpe.spe_isFweOn; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | //--------------- New Modes --------------------- |
| 589 | |
| 590 | void spe_setHacModeNeeded(bool isNeed) |
| 591 | { |
| 592 | gSpe.isHacModeNeeded = isNeed; |
| 593 | } |
| 594 | #endif |
| 595 | //--------------- viberation speaker ---------------- |
| 596 | |
| 597 | void spe_setNotchFilterParam(int16 *param, bool is2In1Spk) |
| 598 | { |
| 599 | AM_SetNotchFilterParam(param); |
| 600 | } |
| 601 | |
| 602 | |
| 603 | /* ========================================================================= */ |
| 604 | /* |
| 605 | void L1SP_MagiClarityData(const short MAGI_CLARITY_PAR[NUM_MAGI_CLARITY_PARAM]) |
| 606 | { |
| 607 | memcpy(&gSpe.sph_magi_clarity_para, MAGI_CLARITY_PAR, NUM_MAGI_CLARITY_PARAM*sizeof(short)); |
| 608 | } |
| 609 | */ |
| 610 | /* |
| 611 | void L1SP_Reload_MagiClarity_Para( void ) |
| 612 | { |
| 613 | SPE_MagiClarityData(gSpe.sph_magi_clarity_para); |
| 614 | } |
| 615 | */ |
| 616 | /** |
| 617 | Use currect information inside gSpe to decide the mode paramters. |
| 618 | @m_para: nb para result |
| 619 | @m_para_wb: wb para result |
| 620 | */ |
| 621 | |
| 622 | |
| 623 | |
| 624 | void spe_setSpeechMode( uint8 afterSalDevMode, uint8 after_sph_mode) |
| 625 | { |
| 626 | // kal_bool preIsLSP; |
| 627 | // kal_bool afterIsLsp; |
| 628 | |
| 629 | // uint8 prev_sph_mode = gSpe.sph_mode; |
| 630 | |
| 631 | #if defined( MTK_SLEEP_ENABLE ) |
| 632 | // kal_uint16 aud_id = L1SP_GetAudID(); |
| 633 | kal_uint16 aud_id = L1Audio_GetAudioID(); |
| 634 | L1Audio_SetFlag( aud_id ); |
| 635 | #endif |
| 636 | |
| 637 | |
| 638 | //------------------------------------------------------ |
| 639 | // Changing |
| 640 | //------------------------------------------------------ |
| 641 | // gSpe.sph_mode = after_sph_mode; |
| 642 | |
| 643 | //------------------------------------------------------ |
| 644 | // Turn on |
| 645 | //------------------------------------------------------ |
| 646 | |
| 647 | |
| 648 | SetSpeechEnhancement( true ); |
| 649 | |
| 650 | //------------------------------------------------------ |
| 651 | #if defined( MTK_SLEEP_ENABLE ) |
| 652 | L1Audio_ClearFlag( aud_id ); |
| 653 | L1Audio_FreeAudioID( aud_id ); |
| 654 | #endif |
| 655 | |
| 656 | } |
| 657 | |
| 658 | |
| 659 | #if defined(_SPE_ENH_MD_PARSE_) |
| 660 | |
| 661 | void SetSpeechEnhancement( bool ec ) |
| 662 | { |
| 663 | |
| 664 | // For hosted dongle, speech enhancment is not existing by default. |
| 665 | // For RNDIS, speech is useless, so don't care. |
| 666 | // For super dongle, speech is useful. |
| 667 | // As the result, condition is: (chip list) && (data card case without spe enable) |
| 668 | |
| 669 | #if defined(SPH_CHIP_BACK_PHONECALL_USE) |
| 670 | return; |
| 671 | #endif // SPH_CHIP_BACK_PHONECALL_USE |
| 672 | |
| 673 | kal_prompt_trace(MOD_L1SP, "[CTM][SPE] l1sp_getCtmSpeStatus() = %d",l1sp_getCtmSpeStatus()); |
| 674 | // speech is not working. |
| 675 | if ((!AM_IsAmInSpeechState()) || (!gSpe.spe_flag) || (!l1sp_getCtmSpeStatus())) |
| 676 | return; |
| 677 | |
| 678 | // kal_trace( TRACE_INFO, L1SP_APPLY_MODE, (ec)?1:0, gSpe.sph_mode, -1, 0 ); |
| 679 | if( ec ) { |
| 680 | |
| 681 | //==================================== |
| 682 | |
| 683 | MD_TRC_SPE_SETDYNAMIC_SM(0); |
| 684 | MD_TRC_L1SP_SPE_CTRL_UPDATE(gSpe.spe_usr_enh_ctrl, gSpe.sph_SPE_path, AM_GetNetworkRate()); |
| 685 | SAL_ENH_SetULPath(gSpe.sph_SPE_path!=SpeechEnh_DL); |
| 686 | SAL_ENH_SetDLPath(gSpe.sph_SPE_path!=SpeechEnh_UL); |
| 687 | |
| 688 | kal_take_enh_mutex (spe_enh_mutex); |
| 689 | |
| 690 | while(1){ |
| 691 | MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 692 | if(SAL_ENH_IsParMemAvailable()){ |
| 693 | SAL_ENH_OccupyParMem(); |
| 694 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 695 | break; |
| 696 | } |
| 697 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 698 | } |
| 699 | kal_give_enh_mutex (spe_enh_mutex); |
| 700 | MD_TRC_SPE_SETDYNAMIC_SM(1); |
| 701 | if(gSpe.spe_is_update_enh_ctrl) |
| 702 | { |
| 703 | SPE_ENHCtrlSwitch(gSpe.spe_usr_enh_ctrl); |
| 704 | } |
| 705 | |
| 706 | //==========write the parameters to DSP========================== |
| 707 | |
| 708 | |
| 709 | uint16 *c_param ; |
| 710 | uint16 *m_param ; |
| 711 | uint16 *m_param_wb ; |
| 712 | c_param = Sp_GetCommonSpeechPara(); |
| 713 | m_param = Sp_GetSpeechPara(); |
| 714 | m_param_wb = Sp_GetWbSpeechPara(); |
| 715 | |
| 716 | //1. set Common par. |
| 717 | if(gSpe.isSPE_Enable == false) |
| 718 | { |
| 719 | SPE_LoadSpeechPara(c_param, NULL, NULL, NULL); |
| 720 | } |
| 721 | //MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 722 | //2. Set Mode par.FIR par.IIR par. |
| 723 | if(AM_GetNetworkRate() == RAT_2G_MODE) |
| 724 | { |
| 725 | Set2GDynPar(); |
| 726 | } |
| 727 | else if(AM_GetNetworkRate()== RAT_3G_MODE || AM_GetNetworkRate()==RAT_3G324M_MODE ) |
| 728 | { |
| 729 | Set3GDynPar(); |
| 730 | } |
| 731 | else if(AM_GetNetworkRate()== RAT_4G_MODE ) |
| 732 | { |
| 733 | Set4GDynPar(); |
| 734 | } |
| 735 | else if(AM_GetNetworkRate()== RAT_C2K_MODE) |
| 736 | { |
| 737 | SetC2KDynPar(); |
| 738 | } |
| 739 | else |
| 740 | { |
| 741 | Set2GDynPar(); |
| 742 | } |
| 743 | |
| 744 | |
| 745 | //MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 746 | //3. set echo ref info ==> move to scheduler |
| 747 | // SPE_SetActiveEchoRefInfo(gSpe.sph_mode); |
| 748 | //4. set magiclarity par. (Remove) |
| 749 | // SPE_MagiClarityData(gSpe.sph_magi_clarity_para); |
| 750 | //5. set DMNR par . |
| 751 | |
| 752 | if(((gSpe.spe_usr_enh_ctrl & SPE_DMNR_SUPPORT)!=0)) |
| 753 | { |
| 754 | SPE_LoadDmnrLspCoeffs(gSpe.sph_lspk_dmnr_para); |
| 755 | SPE_LoadWbDmnrLspCoeffs(gSpe.sph_lspk_wb_dmnr_para); |
| 756 | SPE_LoadSWbLspDmnrCoeffs(gSpe.sph_lspk_swb_dmnr_para); |
| 757 | SPE_LoadDmnrCoeffs(gSpe.sph_dmnr_para); |
| 758 | SPE_LoadWbDmnrCoeffs(gSpe.sph_wb_dmnr_para); |
| 759 | SPE_LoadSWbDmnrCoeffs(gSpe.sph_swb_dmnr_para); |
| 760 | } |
| 761 | |
| 762 | MD_TRC_SPE_SETDYNAMIC_SM(3); |
| 763 | SPE_SetDynamicStatemachine(); |
| 764 | if(gSpe.isSPE_Enable == false) |
| 765 | { |
| 766 | SPE_Enable_DLL_Entry(); |
| 767 | } |
| 768 | //SPE_WaitSPEDynReady(); |
| 769 | //MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 770 | SAL_ENH_ReleaseParMem(); |
| 771 | MD_TRC_SPE_SETDYNAMIC_SM(4); |
| 772 | MD_TRC_L1SP_SPEECH_ENHANCEMENT(*m_param, *(m_param+1), *c_param, *(c_param+11)); |
| 773 | MD_TRC_SPE_SETSPEECHENHANCEMENT_C_PARAM(); |
| 774 | MD_TRC_L1SP_MODE_VALUE(c_param[0], c_param[1], c_param[2], c_param[3], c_param[4], c_param[5], c_param[6], c_param[7], c_param[8], c_param[9], c_param[10], c_param[11], c_param[12], c_param[13], c_param[14], c_param[15]); |
| 775 | MD_TRC_SPE_SETSPEECHENHANCEMENT_M_PARAM(); |
| 776 | MD_TRC_L1SP_MODE_VALUE(m_param[0], m_param[1], m_param[2], m_param[3], m_param[4], m_param[5], m_param[6], m_param[7], m_param[8], m_param[9], m_param[10], m_param[11], m_param[12], m_param[13], m_param[14], m_param[15]); |
| 777 | MD_TRC_L1SP_MODE_VALUE(m_param[16], m_param[17], m_param[18], m_param[19], m_param[20], m_param[21], m_param[22], m_param[23], m_param[24], m_param[25], m_param[26], m_param[27], m_param[28], m_param[29], m_param[30], m_param[31]); |
| 778 | MD_TRC_L1SP_MODE_VALUE(m_param[32], m_param[33], m_param[34], m_param[35], m_param[36], m_param[37], m_param[38], m_param[39], m_param[40], m_param[41], m_param[42], m_param[43], m_param[44], m_param[45], m_param[46], m_param[47]); |
| 779 | MD_TRC_SPE_SETSPEECHENHANCEMENT_M_PARAM_WB(); |
| 780 | MD_TRC_L1SP_MODE_VALUE(m_param_wb[0], m_param_wb[1], m_param_wb[2], m_param_wb[3], m_param_wb[4], m_param_wb[5], m_param_wb[6], m_param_wb[7], m_param_wb[8], m_param_wb[9], m_param_wb[10], m_param_wb[11], m_param_wb[12], m_param_wb[13], m_param_wb[14], m_param_wb[15]); |
| 781 | MD_TRC_L1SP_MODE_VALUE(m_param_wb[16], m_param_wb[17], m_param_wb[18], m_param_wb[19], m_param_wb[20], m_param_wb[21], m_param_wb[22], m_param_wb[23], m_param_wb[24], m_param_wb[25], m_param_wb[26], m_param_wb[27], m_param_wb[28], m_param_wb[29], m_param_wb[30], m_param_wb[31]); |
| 782 | MD_TRC_L1SP_MODE_VALUE(m_param_wb[32], m_param_wb[33], m_param_wb[34], m_param_wb[35], m_param_wb[36], m_param_wb[37], m_param_wb[38], m_param_wb[39], m_param_wb[40], m_param_wb[41], m_param_wb[42], m_param_wb[43], m_param_wb[44], m_param_wb[45], m_param_wb[46], m_param_wb[47]); |
| 783 | gSpe.isSPE_Enable = true; |
| 784 | gSpe.spe_is_update_enh_ctrl = false; |
| 785 | } |
| 786 | else { |
| 787 | |
| 788 | |
| 789 | kal_take_enh_mutex (spe_enh_mutex); |
| 790 | MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 791 | SPE_ENHCtrlSwitch(0); |
| 792 | SPE_Clear_DLL_Entry(); |
| 793 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 794 | kal_give_enh_mutex (spe_enh_mutex); |
| 795 | gSpe.isSPE_Enable = false; |
| 796 | // gSpe.spe_state = 0; |
| 797 | gSpe.spe_is_update_enh_ctrl = true; |
| 798 | |
| 799 | |
| 800 | #if defined(__TC01_VOICE_ENGINE__) |
| 801 | VC_Stop(); |
| 802 | VS_Stop(); |
| 803 | #endif |
| 804 | } |
| 805 | |
| 806 | } |
| 807 | |
| 808 | |
| 809 | #else // for 95,97 |
| 810 | |
| 811 | |
| 812 | void SetSpeechEnhancement( bool ec ) |
| 813 | { |
| 814 | // For hosted dongle, speech enhancment is not existing by default. |
| 815 | // For RNDIS, speech is useless, so don't care. |
| 816 | // For super dongle, speech is useful. |
| 817 | // As the result, condition is: (chip list) && (data card case without spe enable) |
| 818 | |
| 819 | #if defined(SPH_CHIP_BACK_PHONECALL_USE) |
| 820 | return; |
| 821 | #endif // SPH_CHIP_BACK_PHONECALL_USE |
| 822 | |
| 823 | kal_prompt_trace(MOD_L1SP, "[SPE] l1sp_getCtmSpeStatus() = %d, gSpe.EMI_isExist__0--0 =%d",l1sp_getCtmSpeStatus(),gSpe.EMI_isExist); |
| 824 | // speech is not working. |
| 825 | if ((!AM_IsAmInSpeechState()) || (!gSpe.spe_flag) || (!l1sp_getCtmSpeStatus()) || (!gSpe.EMI_isExist)) |
| 826 | return; |
| 827 | |
| 828 | // kal_trace( TRACE_INFO, L1SP_APPLY_MODE, (ec)?1:0, gSpe.sph_mode, -1, 0 ); |
| 829 | if( ec ) { |
| 830 | |
| 831 | //==================================== |
| 832 | |
| 833 | // notify FDD/TDD info to uSip |
| 834 | kal_prompt_trace(MOD_L1SP, "[SPE]SP3G_Rab_State() = %x,L1SP_GetSIMStatus()=%x",SP3G_Rab_State(),L1SP_GetSIMStatus()); |
| 835 | if( SP3G_Rab_State() ) |
| 836 | { |
| 837 | switch(L1SP_GetSIMStatus()) { |
| 838 | case SP_3G_SIM_FDD_ACTIVE: |
| 839 | SAL_ENH_Set3GNetworkType(0); |
| 840 | break; |
| 841 | case SP_3G_SIM_TDD_ACTIVE: |
| 842 | SAL_ENH_Set3GNetworkType(1); |
| 843 | break; |
| 844 | default: |
| 845 | break; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | MD_TRC_SPE_SETDYNAMIC_SM(0); |
| 850 | MD_TRC_L1SP_SPE_CTRL_UPDATE(gSpe.spe_usr_enh_ctrl, gSpe.sph_SPE_path, AM_GetNetworkRate()); |
| 851 | SAL_ENH_SetULPath(gSpe.sph_SPE_path!=SpeechEnh_DL); |
| 852 | SAL_ENH_SetDLPath(gSpe.sph_SPE_path!=SpeechEnh_UL); |
| 853 | |
| 854 | kal_take_enh_mutex (spe_enh_mutex); |
| 855 | |
| 856 | while(1){ |
| 857 | MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 858 | if(SAL_ENH_IsParMemAvailable()){ |
| 859 | SAL_ENH_OccupyParMem(); |
| 860 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 861 | break; |
| 862 | } |
| 863 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 864 | } |
| 865 | kal_give_enh_mutex (spe_enh_mutex); |
| 866 | |
| 867 | MD_TRC_SPE_SETDYNAMIC_SM(1); |
| 868 | if(gSpe.spe_is_update_enh_ctrl) |
| 869 | { |
| 870 | SPE_ENHCtrlSwitch(gSpe.spe_usr_enh_ctrl); |
| 871 | } |
| 872 | |
| 873 | //==========write the parameters to DSP========================== |
| 874 | |
| 875 | |
| 876 | uint16 *c_param ; |
| 877 | c_param = Sp_GetCommonSpeechPara(); |
| 878 | |
| 879 | MD_TRC_SPE_SETDYNAMIC_SM(3); |
| 880 | MD_TRC_L1SP_SPE_SET_EMI_INFO(1,gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len); |
| 881 | SPE_SetDynamicStatemachine(gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len); |
| 882 | if(gSpe.isSPE_Enable == false) |
| 883 | { |
| 884 | SPE_Enable_DLL_Entry(); |
| 885 | } |
| 886 | SAL_ENH_ReleaseParMem(); |
| 887 | MD_TRC_SPE_SETDYNAMIC_SM(4); |
| 888 | MD_TRC_SPE_SETSPEECHENHANCEMENT_C_PARAM(); |
| 889 | MD_TRC_L1SP_MODE_VALUE(c_param[0], c_param[1], c_param[2], c_param[3], c_param[4], c_param[5], c_param[6], c_param[7], c_param[8], c_param[9], c_param[10], c_param[11], c_param[12], c_param[13], c_param[14], c_param[15]); |
| 890 | gSpe.isSPE_Enable = true; |
| 891 | gSpe.spe_is_update_enh_ctrl = false; |
| 892 | } |
| 893 | else { |
| 894 | kal_take_enh_mutex (spe_enh_mutex); |
| 895 | MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 896 | SPE_ENHCtrlSwitch(0); |
| 897 | SPE_Clear_DLL_Entry(); |
| 898 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 899 | kal_give_enh_mutex (spe_enh_mutex); |
| 900 | gSpe.isSPE_Enable = false; |
| 901 | // gSpe.spe_state = 0; |
| 902 | gSpe.spe_is_update_enh_ctrl = true; |
| 903 | |
| 904 | |
| 905 | #if defined(__TC01_VOICE_ENGINE__) |
| 906 | VC_Stop(); |
| 907 | VS_Stop(); |
| 908 | #endif |
| 909 | } |
| 910 | |
| 911 | } |
| 912 | |
| 913 | |
| 914 | #endif |
| 915 | |
| 916 | static void spe_getFirMappingByScene(const uint32 scene, |
| 917 | uint8 *devMode, uint8 *enhMode, |
| 918 | uint8 *inFir, uint8 *outFir) |
| 919 | { |
| 920 | uint8 tempDevMode = 0xff; |
| 921 | uint8 tempEnhMode = 0xff; |
| 922 | uint8 tempInFir = 0xff; |
| 923 | uint8 tempOutFir = 0xff; |
| 924 | |
| 925 | switch(scene) { |
| 926 | case SPH_ENH_AND_FIR_SCENE_NORMAL: |
| 927 | tempDevMode = SAL_DEV_NORMAL; // SPH_MODE_NORMAL; |
| 928 | tempEnhMode = SPH_MODE_NORMAL; |
| 929 | tempInFir = SPH_FIR_COEFF_NORMAL; |
| 930 | tempOutFir = SPH_FIR_COEFF_NORMAL; |
| 931 | |
| 932 | break; |
| 933 | case SPH_ENH_AND_FIR_SCENE_EARPHONE: |
| 934 | case SPH_ENH_AND_FIR_SCENE_LOUDSPK: |
| 935 | tempDevMode = scene; // SAL_DEV_EARPHONE or SAL_DEV_LOUDSPK |
| 936 | tempEnhMode = scene; |
| 937 | tempInFir = scene; |
| 938 | tempOutFir = scene; |
| 939 | break; |
| 940 | // #if defined(__BT_SUPPORT__) |
| 941 | case SPH_ENH_AND_FIR_SCENE_BT_EARPHONE: |
| 942 | case SPH_ENH_AND_FIR_SCENE_BT_CARKIT: |
| 943 | tempDevMode = SAL_DEV_BT_EARPHONE_NB; //scene; |
| 944 | tempEnhMode = scene; |
| 945 | tempInFir = SPH_FIR_COEFF_BT; |
| 946 | tempOutFir = SPH_FIR_COEFF_BT; |
| 947 | break; |
| 948 | |
| 949 | case SPH_ENH_AND_FIR_SCENE_BT_CORDLESS: |
| 950 | tempDevMode = SAL_DEV_BT_CORDLESS; //scene; |
| 951 | tempEnhMode = scene; |
| 952 | tempInFir = SPH_FIR_COEFF_BT; |
| 953 | tempOutFir = SPH_FIR_COEFF_BT; |
| 954 | break; |
| 955 | //#endif |
| 956 | case SPH_ENH_AND_FIR_SCENE_AUX1: // AUX is use to loud speaker mode |
| 957 | tempDevMode = SAL_DEV_LOUDSPK; //scene |
| 958 | tempEnhMode = SPH_MODE_AUX1; //scene |
| 959 | tempInFir = SPH_FIR_COEFF_HANDFREE; |
| 960 | tempOutFir = SPH_FIR_COEFF_HANDFREE; |
| 961 | break; |
| 962 | case SPH_ENH_AND_FIR_SCENE_AUX2: |
| 963 | tempDevMode = SPH_MODE_NORMAL; |
| 964 | tempEnhMode = SPH_MODE_AUX2; |
| 965 | tempInFir = SPH_FIR_COEFF_NORMAL; |
| 966 | tempOutFir = SPH_FIR_COEFF_NORMAL; |
| 967 | break; |
| 968 | |
| 969 | case SPH_ENH_AND_FIR_SCENE_HAC: |
| 970 | ASSERT(true == gSpe.isHacModeNeeded); // is AP did not set the mode parameter. assert it directly! |
| 971 | |
| 972 | tempDevMode = SPH_MODE_NORMAL; |
| 973 | tempEnhMode = SPH_MODE_HAC; |
| 974 | tempInFir = SPH_FIR_COEFF_HAC; |
| 975 | tempOutFir = SPH_FIR_COEFF_HAC; |
| 976 | break; |
| 977 | case SPH_ENH_AND_FIR_SCENE_USB: // similar to earphone |
| 978 | tempDevMode = SPH_MODE_EARPHONE; |
| 979 | tempEnhMode = SPH_MODE_USB; |
| 980 | tempInFir = SPH_FIR_COEFF_USB; |
| 981 | tempOutFir = SPH_FIR_COEFF_USB; |
| 982 | break; |
| 983 | default: |
| 984 | { |
| 985 | ASSERT(0); |
| 986 | } |
| 987 | |
| 988 | } |
| 989 | |
| 990 | *devMode = tempDevMode; |
| 991 | *enhMode = tempEnhMode; |
| 992 | *inFir = tempInFir; |
| 993 | *outFir = tempOutFir; |
| 994 | |
| 995 | } |
| 996 | |
| 997 | /** |
| 998 | new interface to replace L1SP_SetSpeechMode(), L1SP_Write_Audio_Coefficients(), |
| 999 | L1SP_Write_WB_Audio_Coefficients() in the same time. |
| 1000 | |
| 1001 | if you want to use personal configuration, you can use original interfaces. |
| 1002 | |
| 1003 | @scene: [Input] scenario for different enhancement and fir combination. |
| 1004 | */ |
| 1005 | void L1SP_SetSpeechEnhanceAndFir(uint32 scene, uint32 updatedCoeff) |
| 1006 | |
| 1007 | { |
| 1008 | uint8 modeIndex = 0; |
| 1009 | uint8 inFirIndex = 0; |
| 1010 | uint8 outFirIndex = 0; |
| 1011 | uint8 devModeIndex = 0; |
| 1012 | |
| 1013 | |
| 1014 | //speech mode |
| 1015 | //----------------- original scenario --------------- |
| 1016 | if(scene <SPH_MODE_UNDEFINED) |
| 1017 | { //keeping the original scenario |
| 1018 | |
| 1019 | spe_getFirMappingByScene(scene, &devModeIndex, &modeIndex, |
| 1020 | &inFirIndex, &outFirIndex); |
| 1021 | |
| 1022 | if((updatedCoeff == 0) |
| 1023 | || (updatedCoeff&SPH_ENH_AND_FIR_UPDATE_TYPE_NB_ENH_MODE)!=0 |
| 1024 | || (updatedCoeff&SPH_ENH_AND_FIR_UPDATE_TYPE_WB_ENH_MODE)!=0) |
| 1025 | spe_setSpeechMode(devModeIndex, modeIndex); |
| 1026 | |
| 1027 | |
| 1028 | } |
| 1029 | //---------------------- undefined cases -------------------- |
| 1030 | else { // undefined cases. |
| 1031 | MD_TRC_L1SP_USELESS_SET(scene, 0, 0); |
| 1032 | } |
| 1033 | |
| 1034 | //kal_trace( TRACE_INFO, L1SP_SET_ENH_FIR, scene, modeIndex, inFirIndex, outFirIndex, l1sp.spe_usr_mask, l1sp.spe_app_mask); |
| 1035 | MD_TRC_L1SP_SET_ENH_FIR(scene, modeIndex, inFirIndex, outFirIndex, 0,0); |
| 1036 | |
| 1037 | } |
| 1038 | |
| 1039 | // ---------------------------------------------------------------------------- |
| 1040 | // speech parameter loading |
| 1041 | // ---------------------------------------------------------------------------- |
| 1042 | extern kal_bool setCommonPara; |
| 1043 | extern uint16 commonPara_0; |
| 1044 | |
| 1045 | void SPE_LoadCommonPara( uint16 c_para[NUM_COMMON_PARAS]) |
| 1046 | { |
| 1047 | uint16 *para; |
| 1048 | volatile uint16* dsp_ptr; |
| 1049 | int I; |
| 1050 | if(c_para) |
| 1051 | { |
| 1052 | para = c_para; |
| 1053 | dsp_ptr = SAL_CommonPar_GetBuf(); |
| 1054 | for(I = SAL_PARAMETERLEN_COMMON; --I >= 0 ; ) |
| 1055 | *dsp_ptr++ = *para++; |
| 1056 | } |
| 1057 | |
| 1058 | if(setCommonPara) |
| 1059 | { |
| 1060 | dsp_ptr = SAL_CommonPar_GetBuf(); |
| 1061 | *dsp_ptr = commonPara_0; |
| 1062 | } |
| 1063 | |
| 1064 | } |
| 1065 | |
| 1066 | |
| 1067 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1068 | |
| 1069 | void SPE_LoadSpeechPara( uint16 c_para[NUM_COMMON_PARAS], uint16 m_para[NUM_MODE_PARAS], |
| 1070 | uint16 m_paraWb[NUM_MODE_PARAS],uint16 m_paraSWb[NUM_MODE_PARAS]) |
| 1071 | { |
| 1072 | uint16 *para; |
| 1073 | volatile uint16* dsp_ptr; |
| 1074 | int I; |
| 1075 | |
| 1076 | if(c_para) |
| 1077 | { |
| 1078 | para = c_para; |
| 1079 | dsp_ptr = SAL_CommonPar_GetBuf(); |
| 1080 | for(I = SAL_PARAMETERLEN_COMMON; --I >= 0 ; ) |
| 1081 | *dsp_ptr++ = *para++; |
| 1082 | } |
| 1083 | |
| 1084 | if(setCommonPara) |
| 1085 | { |
| 1086 | dsp_ptr = SAL_CommonPar_GetBuf(); |
| 1087 | *dsp_ptr = commonPara_0; |
| 1088 | } |
| 1089 | |
| 1090 | if(m_para) |
| 1091 | { |
| 1092 | para = m_para; |
| 1093 | dsp_ptr = SAL_ModePar_GetBuf_NB(); |
| 1094 | for(I = NUM_MODE_PARAS; --I >= 0 ; ) // remind to change SAL_PARAMETERLEN_MODE_NB |
| 1095 | { |
| 1096 | *dsp_ptr++ = *para++; |
| 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | if(m_paraWb) |
| 1101 | { |
| 1102 | para = m_paraWb; |
| 1103 | dsp_ptr = SAL_ModePar_GetBuf_WB(); |
| 1104 | for(I = NUM_MODE_PARAS; --I >= 0 ; ) |
| 1105 | *dsp_ptr++ = *para++; |
| 1106 | } |
| 1107 | |
| 1108 | if(m_paraSWb) |
| 1109 | { |
| 1110 | para = m_paraSWb; |
| 1111 | dsp_ptr = SAL_ModePar_GetBuf_SWB(); |
| 1112 | for(I = NUM_MODE_PARAS; --I >= 0 ; ) |
| 1113 | { |
| 1114 | *dsp_ptr++ = *para++; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | Data_Sync_Barrier(); |
| 1119 | } |
| 1120 | #endif |
| 1121 | /* |
| 1122 | void SPE_MagiClarityData(short MagiClarityData[32]) |
| 1123 | { |
| 1124 | |
| 1125 | int i; |
| 1126 | volatile uint16* dsp_ptr; |
| 1127 | dsp_ptr = SAL_FS_GetFltCoefAddr(); |
| 1128 | for( i = 0; i<32; i++) { |
| 1129 | *dsp_ptr++ = MagiClarityData[i]; |
| 1130 | } |
| 1131 | |
| 1132 | |
| 1133 | } |
| 1134 | */ |
| 1135 | |
| 1136 | |
| 1137 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1138 | |
| 1139 | void SPE_LoadDmnrCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM]) |
| 1140 | { |
| 1141 | |
| 1142 | int i; |
| 1143 | volatile uint16* dsp_ptr; |
| 1144 | |
| 1145 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_NB(); |
| 1146 | |
| 1147 | |
| 1148 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_NB; i++) { |
| 1149 | *dsp_ptr++ = dmnr_para[i]; |
| 1150 | } |
| 1151 | |
| 1152 | Data_Sync_Barrier(); |
| 1153 | } |
| 1154 | void SPE_LoadDmnrLspCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM]) |
| 1155 | { |
| 1156 | int i; |
| 1157 | volatile uint16* dsp_ptr; |
| 1158 | |
| 1159 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_NB(); |
| 1160 | |
| 1161 | |
| 1162 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_NB; i++) { |
| 1163 | *dsp_ptr++ = dmnr_para[i]; |
| 1164 | } |
| 1165 | |
| 1166 | Data_Sync_Barrier(); |
| 1167 | } |
| 1168 | void SPE_LoadWbDmnrCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM]) |
| 1169 | { |
| 1170 | |
| 1171 | int i; |
| 1172 | volatile uint16* dsp_ptr; |
| 1173 | |
| 1174 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_WB(); |
| 1175 | |
| 1176 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_WB; i++) { |
| 1177 | *dsp_ptr++ = wb_dmnr_para[i]; |
| 1178 | } |
| 1179 | |
| 1180 | Data_Sync_Barrier(); |
| 1181 | } |
| 1182 | void SPE_LoadWbDmnrLspCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM]) |
| 1183 | { |
| 1184 | int i; |
| 1185 | volatile uint16* dsp_ptr; |
| 1186 | |
| 1187 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_WB(); |
| 1188 | |
| 1189 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_WB; i++) { |
| 1190 | *dsp_ptr++ = wb_dmnr_para[i]; |
| 1191 | } |
| 1192 | |
| 1193 | Data_Sync_Barrier(); |
| 1194 | } |
| 1195 | void SPE_LoadSWbDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM]) |
| 1196 | { |
| 1197 | int i; |
| 1198 | volatile uint16* dsp_ptr; |
| 1199 | |
| 1200 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_SWB(); |
| 1201 | |
| 1202 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_SWB; i++) { |
| 1203 | *dsp_ptr++ = swb_dmnr_para[i]; |
| 1204 | } |
| 1205 | Data_Sync_Barrier(); |
| 1206 | } |
| 1207 | void SPE_LoadSWbLspDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM]) |
| 1208 | { |
| 1209 | |
| 1210 | int i; |
| 1211 | volatile uint16* dsp_ptr; |
| 1212 | |
| 1213 | dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_SWB(); |
| 1214 | |
| 1215 | for( i = 0; i<SAL_FLTCOEFLEN_DMNR_SWB; i++) { |
| 1216 | *dsp_ptr++ = swb_dmnr_para[i]; |
| 1217 | } |
| 1218 | Data_Sync_Barrier(); |
| 1219 | } |
| 1220 | #endif |
| 1221 | |
| 1222 | void L1SP_EnableSpeechEnhancement( bool enable ) |
| 1223 | { |
| 1224 | if(enable) |
| 1225 | { |
| 1226 | gSpe.spe_flag = true; |
| 1227 | SetSpeechEnhancement(true); |
| 1228 | } |
| 1229 | else |
| 1230 | { |
| 1231 | SetSpeechEnhancement(false); |
| 1232 | gSpe.spe_flag = false; |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | void L1SP_EnhancementCtrlSupport( uint16 value ) |
| 1237 | { |
| 1238 | |
| 1239 | gSpe.spe_usr_enh_ctrl = value; |
| 1240 | SetSpeechEnhancement(true); |
| 1241 | } |
| 1242 | |
| 1243 | /* ========================================================================= */ |
| 1244 | |
| 1245 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1246 | extern const unsigned short Speech_Normal_Mode_Para[16]; |
| 1247 | extern const unsigned short WB_Speech_Normal_Mode_Para[16]; |
| 1248 | #endif |
| 1249 | // extern const unsigned short Speech_Vol_Para[4]; |
| 1250 | |
| 1251 | void SPE_Init( void ) |
| 1252 | { |
| 1253 | |
| 1254 | |
| 1255 | #if !defined(_SPE_ENH_MD_PARSE_) // for 95,97 |
| 1256 | uint32 spe_emi_default_par_offset; |
| 1257 | gSpe.sph_EMI_Info_offset = 0; |
| 1258 | gSpe.sph_EMI_Info_len = EMI_MD_DEFAULT_LEN; //set EMI default len |
| 1259 | |
| 1260 | #endif |
| 1261 | gSpe.spe_flag = true; |
| 1262 | gSpe.isSPE_Enable = false; |
| 1263 | // gSpe.isReDDL = false; |
| 1264 | gSpe.sph_SPE_path=SpeechEnh_All; |
| 1265 | |
| 1266 | gSpe.spe_isFweOn = false; |
| 1267 | |
| 1268 | |
| 1269 | //default set the DMNR on |
| 1270 | // gSpe.spe_usr_sub_mask = 0x023E; // default value to turn on , [bit6]HF DMNR is default off. [bit7] DRC2.0 is default off. sync with Sal_Enh_Dynamic_t bit wise definition |
| 1271 | gSpe.spe_usr_enh_ctrl = 0x0003; // bit0=DMNR,bit1=TDDNC,bit2=magi con |
| 1272 | gSpe.spe_is_update_enh_ctrl = true; |
| 1273 | // gSpe.isNotchFitOn = false; |
| 1274 | |
| 1275 | |
| 1276 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1277 | memset(gSpe.sph_ModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 1278 | memset(gSpe.sph_InFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16)); |
| 1279 | memset(gSpe.sph_OutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16)); |
| 1280 | memset(gSpe.sph_InIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1281 | memset(gSpe.sph_OutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1282 | memset(gSpe.sph_Mic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 1283 | memset(gSpe.sph_Mic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 1284 | |
| 1285 | memset(gSpe.sph_WbModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 1286 | memset(gSpe.sph_WbInFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS*sizeof(int16)); |
| 1287 | memset(gSpe.sph_WbOutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS*sizeof(int16)); |
| 1288 | memset(gSpe.sph_WbInIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1289 | memset(gSpe.sph_WbOutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1290 | memset(gSpe.sph_WbMic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 1291 | memset(gSpe.sph_WbMic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 1292 | memset(gSpe.sph_SWbModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16)); |
| 1293 | memset(gSpe.sph_SWbInFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS*sizeof(int16)); |
| 1294 | memset(gSpe.sph_SWbOutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS*sizeof(int16)); |
| 1295 | memset(gSpe.sph_SWbInIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1296 | memset(gSpe.sph_SWbOutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16)); |
| 1297 | memset(gSpe.sph_SWbMic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16)); |
| 1298 | memset(gSpe.sph_SWbMic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16)); |
| 1299 | // SPE_MagiClarityData(Speech_All_Pass_MAG_CLARITY); |
| 1300 | |
| 1301 | memset(&gSpe.sph_dmnr_para, 0, NUM_DMNR_PARAM*sizeof(uint16)); |
| 1302 | memset(&gSpe.sph_lspk_dmnr_para, 0, NUM_DMNR_PARAM*sizeof(uint16)); |
| 1303 | memset(&gSpe.sph_wb_dmnr_para, 0, NUM_WB_DMNR_PARAM*sizeof(uint16)); |
| 1304 | memset(&gSpe.sph_lspk_wb_dmnr_para, 0, NUM_WB_DMNR_PARAM*sizeof(uint16)); |
| 1305 | |
| 1306 | |
| 1307 | gSpe.isMagiConOn = false; |
| 1308 | memset(gSpe.sph_magicConParam, 0, NUM_MODE_PARAS*sizeof(uint16)); |
| 1309 | memset(gSpe.sph_magicConWbParam, 0, NUM_MODE_PARAS*sizeof(uint16)); |
| 1310 | |
| 1311 | |
| 1312 | // init the AGC as off in every channal |
| 1313 | // _write_enh_internalPar_(SPE_INTERNALPAR_INDEX_AGC, 0) |
| 1314 | |
| 1315 | SPE_LoadSpeechPara((uint16 *)Speech_Common_Para, (uint16 *)Speech_Normal_Mode_Para, (uint16 *)WB_Speech_Normal_Mode_Para,(uint16 *)WB_Speech_Normal_Mode_Para ); |
| 1316 | |
| 1317 | #else //for 95,97 |
| 1318 | L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para); |
| 1319 | L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para); |
| 1320 | SAL_ENH_Set3GNetworkType(0); |
| 1321 | // EMI layout |
| 1322 | // EMI layout |
| 1323 | spe_emi_default_par_offset = EMI_NEED_3K_0 + EMI_GUARD_PATTERN + MD_PRIVATE; |
| 1324 | if(SP_GetSphParamBufAddr() == NULL) |
| 1325 | { |
| 1326 | gSpe.EMI_isExist = false; |
| 1327 | } |
| 1328 | else |
| 1329 | { |
| 1330 | gSpe.EMI_isExist = true; |
| 1331 | memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset, &(Common_Param_Default), sizeof(unsigned short) * 72); |
| 1332 | memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+72, &(DMNR_Param_Default), sizeof(unsigned short) * 1468); |
| 1333 | memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+1540, &(MagiClarity_Param_Default), sizeof(unsigned short) * 75); |
| 1334 | memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+1615, &(Speech_Param_Default), sizeof(unsigned short) * (418+134)); |
| 1335 | memset(((unsigned short *)(SP_GetSphParamBufAddr())), 0, EMI_NEED_3K_0*sizeof(unsigned short)); //3K |
| 1336 | } |
| 1337 | #endif |
| 1338 | if (! spe_enh_mutex) |
| 1339 | { |
| 1340 | spe_enh_mutex = kal_create_enh_mutex("spe_enh_mutex"); |
| 1341 | } |
| 1342 | gSpe.ctm_spe_status = true; |
| 1343 | } |
| 1344 | |
| 1345 | |
| 1346 | /* ========================================================================= */ |
| 1347 | /* ========================================================================= */ |
| 1348 | /* EC/AEC/EES control Functions */ |
| 1349 | /* ========================================================================= */ |
| 1350 | #define FLAG_EC_SUPP 1 |
| 1351 | #define FLAG_DDL_UL_ENTRY 2 |
| 1352 | #define FLAG_DDL_DL_ENTRY 4 |
| 1353 | |
| 1354 | #define SPE_IDLE_STATE 0 /* MCU: 0 -> 1 */ |
| 1355 | #define SPE_READY_STATE 1 /* DSP: 1 -> 2 */ |
| 1356 | #define SPE_WORKING_STATE 2 /* MCU: 2 -> 3 */ |
| 1357 | #define SPE_STOP_STATE 3 /* DSP: 3 -> 0 */ |
| 1358 | |
| 1359 | |
| 1360 | #define _wait_for_ready_( enh_mod ) \ |
| 1361 | { \ |
| 1362 | uint32 I; \ |
| 1363 | for( I = 0; ; I++ ) { \ |
| 1364 | if( SAL_ENH_IsReady(enh_mod)) \ |
| 1365 | break; \ |
| 1366 | ASSERT_REBOOT( I < 20 ); \ |
| 1367 | kal_sleep_task( AUD_1TICK(2) ); \ |
| 1368 | } \ |
| 1369 | } |
| 1370 | |
| 1371 | #define _wait_for_idle_( enh_mod ) \ |
| 1372 | { \ |
| 1373 | uint32 I; \ |
| 1374 | for( I = 0; ; I++ ) { \ |
| 1375 | if( SAL_ENH_IsIdle(enh_mod)) \ |
| 1376 | break; \ |
| 1377 | ASSERT_REBOOT( I < 20 ); \ |
| 1378 | kal_sleep_task( AUD_1TICK(2) ); \ |
| 1379 | } \ |
| 1380 | } |
| 1381 | |
| 1382 | |
| 1383 | void SPE_ENHCtrlSwitch(uint16 state) |
| 1384 | { |
| 1385 | |
| 1386 | SAL_ENH_SetDMNR(((state & SPE_DMNR_SUPPORT)!=0)); |
| 1387 | SAL_ENH_SetTDNC(((state & SPE_TDNC_SUPPORT)!=0)); |
| 1388 | SAL_ENH_SetMagicConference(((state & SPE_MAGI_CON_SUPPORT)!=0)); |
| 1389 | } |
| 1390 | |
| 1391 | |
| 1392 | |
| 1393 | void SPE_Clear_DLL_Entry() |
| 1394 | { |
| 1395 | SAL_ENH_SetMainSwitch(false); |
| 1396 | } |
| 1397 | |
| 1398 | |
| 1399 | void SPE_Enable_DLL_Entry(void) |
| 1400 | { |
| 1401 | SAL_ENH_SetMainSwitch(true); |
| 1402 | } |
| 1403 | |
| 1404 | |
| 1405 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1406 | void SPE_SetDynamicStatemachine(void) |
| 1407 | { |
| 1408 | |
| 1409 | SAL_ENH_ParUpdState_SetUpd(); |
| 1410 | MD_TRC_SPE_SETDYNAMIC_SM(0); |
| 1411 | |
| 1412 | |
| 1413 | } |
| 1414 | |
| 1415 | #else //for 95,97 |
| 1416 | void SPE_SetDynamicStatemachine(kal_uint32 Offset, kal_uint32 Len) |
| 1417 | { |
| 1418 | |
| 1419 | SAL_ENH_ParUpdState_SetUpd_Offset(Offset,Len); |
| 1420 | MD_TRC_SPE_SETDYNAMIC_SM(0); |
| 1421 | } |
| 1422 | #endif |
| 1423 | |
| 1424 | void SPE_WaitSPEDynReady(void) |
| 1425 | { |
| 1426 | |
| 1427 | uint32 I; |
| 1428 | for( I = 0; ; I++ ) { |
| 1429 | if( SAL_ENH_ParUpdPState_IsIdle()) |
| 1430 | break; |
| 1431 | //ASSERT_REBOOT( I < 20 ); |
| 1432 | if(I>20) |
| 1433 | { |
| 1434 | ASSERT(0); |
| 1435 | } |
| 1436 | kal_sleep_task(AUD_1TICK(2)); //kal_sleep_task( 2 ); |
| 1437 | |
| 1438 | } |
| 1439 | MD_TRC_SPE_SETDYNAMIC_SM(1); |
| 1440 | } |
| 1441 | |
| 1442 | |
| 1443 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1444 | void SetDynamicParToDSP(uint32 IDnumber) |
| 1445 | { |
| 1446 | #if defined( MTK_SLEEP_ENABLE ) |
| 1447 | kal_uint16 aud_id = L1SP_GetAudID(); |
| 1448 | #endif |
| 1449 | |
| 1450 | kal_take_enh_mutex (spe_enh_mutex); |
| 1451 | MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT); |
| 1452 | switch (IDnumber) { |
| 1453 | |
| 1454 | case Par_GSM_NB_SpeechUnit: |
| 1455 | { |
| 1456 | SP_SetSpeechPara(gSpe.sph_ModePara[0]); |
| 1457 | SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[0], NULL, NULL); |
| 1458 | AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[0], gSpe.sph_OutFirCoeff[0] ); |
| 1459 | AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[0], gSpe.sph_OutIirCoeff[0],gSpe.sph_Mic1IirCoeff[0],gSpe.sph_Mic2IirCoeff[0]); |
| 1460 | |
| 1461 | } |
| 1462 | break; |
| 1463 | case Par_GSM_WB_SpeechUnit: |
| 1464 | { |
| 1465 | SP_SetWbSpeechPara(gSpe.sph_WbModePara[0]); |
| 1466 | SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[0], NULL ); |
| 1467 | AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]); |
| 1468 | AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[0],gSpe.sph_WbOutIirCoeff[0],gSpe.sph_WbMic1IirCoeff[0],gSpe.sph_WbMic2IirCoeff[0]); |
| 1469 | |
| 1470 | } |
| 1471 | break; |
| 1472 | |
| 1473 | #if !defined( __UMTS_TDD128_MODE__ ) |
| 1474 | case Par_WCDMA_NB_SpeechUnit: |
| 1475 | { |
| 1476 | SP_SetSpeechPara(gSpe.sph_ModePara[1]); |
| 1477 | SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[1], NULL, NULL); |
| 1478 | AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[1], gSpe.sph_OutFirCoeff[1] ); |
| 1479 | AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[1], gSpe.sph_OutIirCoeff[1],gSpe.sph_Mic1IirCoeff[1],gSpe.sph_Mic2IirCoeff[1]); |
| 1480 | |
| 1481 | //set speech nb mode flag, fir nb in flag,fir out nb flag |
| 1482 | } |
| 1483 | break; |
| 1484 | case Par_WCDMA_WB_SpeechUnit: |
| 1485 | { |
| 1486 | SP_SetWbSpeechPara(gSpe.sph_WbModePara[1]); |
| 1487 | SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[1], NULL ); |
| 1488 | AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[1],gSpe.sph_WbOutFirCoeff[1]); |
| 1489 | AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[1],gSpe.sph_WbOutIirCoeff[1],gSpe.sph_WbMic1IirCoeff[1],gSpe.sph_WbMic2IirCoeff[1]); |
| 1490 | |
| 1491 | } |
| 1492 | break; |
| 1493 | #else //CDMA |
| 1494 | case Par_CDMA_NB_SpeechUnit: |
| 1495 | { |
| 1496 | SP_SetSpeechPara(gSpe.sph_ModePara[2]); |
| 1497 | SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[2], NULL, NULL); |
| 1498 | AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[2], gSpe.sph_OutFirCoeff[2] ); |
| 1499 | AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[2], gSpe.sph_OutIirCoeff[2],gSpe.sph_Mic1IirCoeff[2],gSpe.sph_Mic2IirCoeff[2]); |
| 1500 | } |
| 1501 | break; |
| 1502 | case Par_CDMA_WB_SpeechUnit: |
| 1503 | { |
| 1504 | SP_SetWbSpeechPara((kal_uint16*)gSpe.sph_WbModePara[2]); |
| 1505 | SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[2], NULL ); |
| 1506 | AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[2],gSpe.sph_WbOutFirCoeff[2]); |
| 1507 | AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[2],gSpe.sph_WbOutIirCoeff[2],gSpe.sph_WbMic1IirCoeff[2],gSpe.sph_WbMic2IirCoeff[2]); |
| 1508 | |
| 1509 | } |
| 1510 | break; |
| 1511 | |
| 1512 | #endif |
| 1513 | case Par_VOLTE_NB_SpeechUnit: |
| 1514 | { |
| 1515 | |
| 1516 | SP_SetSpeechPara(gSpe.sph_ModePara[3]); |
| 1517 | SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[3], NULL, NULL); |
| 1518 | AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[3], gSpe.sph_OutFirCoeff[3] ); |
| 1519 | AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[3], gSpe.sph_OutIirCoeff[3],gSpe.sph_Mic1IirCoeff[3],gSpe.sph_Mic2IirCoeff[3]); |
| 1520 | |
| 1521 | } |
| 1522 | break; |
| 1523 | case Par_VOLTE_WB_SpeechUnit: |
| 1524 | { |
| 1525 | |
| 1526 | SP_SetWbSpeechPara(gSpe.sph_WbModePara[3]); |
| 1527 | SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[3], NULL); |
| 1528 | AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[3],gSpe.sph_WbOutFirCoeff[3]); |
| 1529 | AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[3],gSpe.sph_WbOutIirCoeff[3],gSpe.sph_WbMic1IirCoeff[3],gSpe.sph_WbMic2IirCoeff[3]); |
| 1530 | } |
| 1531 | break; |
| 1532 | case Par_VOLTE_SWB_SpeechUnit: |
| 1533 | { |
| 1534 | SP_SetSWbSpeechPara(gSpe.sph_SWbModePara[3]); |
| 1535 | SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_SWbModePara[3] ); |
| 1536 | AM_WriteSWbFirCoeffs(gSpe.sph_SWbInFirCoeff[3],gSpe.sph_SWbOutFirCoeff[3]); |
| 1537 | AM_WriteSWbIirCoeffs(gSpe.sph_SWbInIirCoeff[3],gSpe.sph_SWbOutIirCoeff[3],gSpe.sph_SWbMic1IirCoeff[3],gSpe.sph_SWbMic2IirCoeff[3]); |
| 1538 | |
| 1539 | } |
| 1540 | break; |
| 1541 | case Par_C2K_NB_SpeechUnit: |
| 1542 | { |
| 1543 | |
| 1544 | SP_SetSpeechPara(gSpe.sph_ModePara[4]); |
| 1545 | SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[4], NULL, NULL); // l1sp.sph_v_para no one use it. |
| 1546 | AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[4], gSpe.sph_OutFirCoeff[4] ); |
| 1547 | AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[4], gSpe.sph_OutIirCoeff[4],gSpe.sph_Mic1IirCoeff[4],gSpe.sph_Mic2IirCoeff[4]); |
| 1548 | |
| 1549 | |
| 1550 | } |
| 1551 | break; |
| 1552 | case Par_C2K_WB_SpeechUnit: |
| 1553 | { |
| 1554 | |
| 1555 | SP_SetWbSpeechPara(gSpe.sph_WbModePara[4]); |
| 1556 | SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[4] ); // l1sp.sph_v_para no one use it. |
| 1557 | AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[4],gSpe.sph_WbOutFirCoeff[4]); |
| 1558 | AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[4],gSpe.sph_WbOutIirCoeff[4],gSpe.sph_WbMic1IirCoeff[4],gSpe.sph_WbMic2IirCoeff[4]); |
| 1559 | |
| 1560 | } |
| 1561 | break; |
| 1562 | |
| 1563 | |
| 1564 | |
| 1565 | default: |
| 1566 | { |
| 1567 | MD_TRC_SPE_SETDYNAMICPARTOMD_NOT_FIND(IDnumber); |
| 1568 | break; |
| 1569 | } |
| 1570 | } |
| 1571 | MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock); |
| 1572 | kal_give_enh_mutex (spe_enh_mutex); |
| 1573 | #if defined( MTK_SLEEP_ENABLE ) |
| 1574 | L1SP_FreeAudID(aud_id); |
| 1575 | #endif |
| 1576 | |
| 1577 | } |
| 1578 | void Set2GDynPar(void) |
| 1579 | { |
| 1580 | SetDynamicParToDSP(Par_GSM_NB_SpeechUnit); |
| 1581 | SetDynamicParToDSP(Par_GSM_WB_SpeechUnit); |
| 1582 | |
| 1583 | } |
| 1584 | |
| 1585 | void Set3GDynPar(void) |
| 1586 | { |
| 1587 | #if !defined( __UMTS_TDD128_MODE__ ) |
| 1588 | |
| 1589 | SetDynamicParToDSP(Par_WCDMA_NB_SpeechUnit); |
| 1590 | SetDynamicParToDSP(Par_WCDMA_WB_SpeechUnit); |
| 1591 | #else |
| 1592 | SetDynamicParToDSP(Par_CDMA_NB_SpeechUnit); |
| 1593 | SetDynamicParToDSP(Par_CDMA_WB_SpeechUnit); |
| 1594 | |
| 1595 | #endif |
| 1596 | |
| 1597 | } |
| 1598 | |
| 1599 | void Set4GDynPar(void) |
| 1600 | { |
| 1601 | SetDynamicParToDSP(Par_VOLTE_NB_SpeechUnit); |
| 1602 | SetDynamicParToDSP(Par_VOLTE_WB_SpeechUnit); |
| 1603 | SetDynamicParToDSP(Par_VOLTE_SWB_SpeechUnit); |
| 1604 | |
| 1605 | } |
| 1606 | |
| 1607 | void SetC2KDynPar(void) |
| 1608 | { |
| 1609 | SetDynamicParToDSP(Par_C2K_NB_SpeechUnit); |
| 1610 | SetDynamicParToDSP(Par_C2K_WB_SpeechUnit); |
| 1611 | |
| 1612 | } |
| 1613 | #endif |
| 1614 | |
| 1615 | |
| 1616 | |
| 1617 | |
| 1618 | void SetSPEnhancePath(uint8 path) |
| 1619 | { |
| 1620 | if(path == SpeechEnh_All) |
| 1621 | { |
| 1622 | gSpe.sph_SPE_path=SpeechEnh_All; |
| 1623 | } |
| 1624 | else if(path == SpeechEnh_UL) |
| 1625 | { |
| 1626 | gSpe.sph_SPE_path=SpeechEnh_UL; |
| 1627 | } |
| 1628 | else if(path == SpeechEnh_DL) |
| 1629 | { |
| 1630 | gSpe.sph_SPE_path=SpeechEnh_DL; |
| 1631 | } |
| 1632 | else |
| 1633 | { |
| 1634 | ASSERT(0); |
| 1635 | } |
| 1636 | |
| 1637 | SetSpeechEnhancement(true); |
| 1638 | |
| 1639 | } |
| 1640 | |