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 | * Tone_Drv.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * MTK Feature Phone |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * DTMF tone driver |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================== |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 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 | * |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * |
| 97 | * removed! |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * |
| 101 | * removed! |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * removed! |
| 119 | * |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * removed! |
| 127 | * |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * |
| 136 | * removed! |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * |
| 140 | * removed! |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * |
| 144 | * removed! |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * |
| 148 | * removed! |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * |
| 152 | * removed! |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * removed! |
| 159 | * |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * removed! |
| 163 | * |
| 164 | * removed! |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * |
| 168 | * removed! |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * |
| 172 | * removed! |
| 173 | * removed! |
| 174 | * removed! |
| 175 | * |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * removed! |
| 179 | * |
| 180 | * removed! |
| 181 | * removed! |
| 182 | * removed! |
| 183 | * removed! |
| 184 | * removed! |
| 185 | * removed! |
| 186 | * removed! |
| 187 | * removed! |
| 188 | * removed! |
| 189 | * removed! |
| 190 | * removed! |
| 191 | * removed! |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * removed! |
| 195 | * removed! |
| 196 | * removed! |
| 197 | * removed! |
| 198 | * removed! |
| 199 | * removed! |
| 200 | * removed! |
| 201 | * removed! |
| 202 | * removed! |
| 203 | * removed! |
| 204 | * removed! |
| 205 | * removed! |
| 206 | * removed! |
| 207 | * removed! |
| 208 | * removed! |
| 209 | * removed! |
| 210 | * removed! |
| 211 | * removed! |
| 212 | * removed! |
| 213 | * removed! |
| 214 | * removed! |
| 215 | * removed! |
| 216 | * removed! |
| 217 | * removed! |
| 218 | * removed! |
| 219 | * removed! |
| 220 | * removed! |
| 221 | * removed! |
| 222 | * removed! |
| 223 | *------------------------------------------------------------------------------ |
| 224 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 225 | *============================================================================== |
| 226 | *******************************************************************************/ |
| 227 | |
| 228 | #include "kal_public_api.h" |
| 229 | #include "kal_general_types.h" |
| 230 | #include "kal_trace.h" |
| 231 | #include "dcl.h" |
| 232 | #include "reg_base.h" |
| 233 | #include "sync_data.h" |
| 234 | |
| 235 | //#include "l1d_reg.h" |
| 236 | #include "l1aud_common_def.h" |
| 237 | #include "l1audio.h" |
| 238 | #include "media.h" |
| 239 | #include "afe.h" |
| 240 | #include "afe_def.h" |
| 241 | #include "am.h" |
| 242 | #include "speech_def.h" |
| 243 | // #include "audio_def.h" |
| 244 | #include "afe_def.h" |
| 245 | #include "l1audio_trace_utmd.h" |
| 246 | #include "l1sp_trc.h" |
| 247 | #include "tone_drv.h" |
| 248 | #include "sal_exp.h" |
| 249 | |
| 250 | #if defined(__CVSD_CODEC_SUPPORT__) |
| 251 | #include "bt_sco_drv.h" |
| 252 | #endif |
| 253 | |
| 254 | //#pragma arm section code="SECONDARY_ROCODE" |
| 255 | |
| 256 | typedef struct _st_DTMF_DSP |
| 257 | { |
| 258 | kal_uint32 uGPT; |
| 259 | const L1SP_Tones *pToneList; |
| 260 | const L1SP_QTMF *pCurrQtmf; |
| 261 | kal_uint16 uCurrentNode; |
| 262 | DTMF_DSP_STATE uState; |
| 263 | kal_bool fIsQTMF; |
| 264 | } st_DTMF_DSP; |
| 265 | |
| 266 | typedef struct _st_tone |
| 267 | { |
| 268 | const L1SP_Tones *pToneList; |
| 269 | const L1SP_QTMF *pCurrQtmf; |
| 270 | kal_uint16 uAudId; |
| 271 | kal_uint16 amp; |
| 272 | void (*fpHandler)(void); |
| 273 | //kal_bool fDspToneRunning; |
| 274 | //kal_bool fMcuToneRunning; |
| 275 | kal_bool fToneRunning; |
| 276 | #if 0 |
| 277 | /* under construction !*/ |
| 278 | /* under construction !*/ |
| 279 | #endif //#if 0 |
| 280 | kal_int8 digital_gain_index; |
| 281 | TONE_TYPE type; |
| 282 | kal_bool fIsQTMF; |
| 283 | } st_tone; |
| 284 | |
| 285 | typedef struct _st_keytone |
| 286 | { |
| 287 | L1SP_Tones dtmf; |
| 288 | kal_uint16 uAudId; |
| 289 | kal_uint8 lock; |
| 290 | #if 0 |
| 291 | /* under construction !*/ |
| 292 | /* under construction !*/ |
| 293 | #endif //#if 0 |
| 294 | kal_int8 digital_gain_index; |
| 295 | kal_uint32 gain; |
| 296 | //kal_bool fDspToneRunning; |
| 297 | //kal_bool fMcuToneRunning; |
| 298 | kal_bool fToneRunning; |
| 299 | |
| 300 | TONE_TYPE type; |
| 301 | kal_bool fIsQTMF; |
| 302 | } st_keytone; |
| 303 | |
| 304 | static st_DTMF_DSP DTMF_DSP; |
| 305 | static st_tone tone[TOTAL_TONE_NUM]; |
| 306 | static st_keytone keytone[TOTAL_TONE_NUM]; |
| 307 | |
| 308 | |
| 309 | #define DSP_TONE_IDLE 0 |
| 310 | #define DSP_TONE_START 1 |
| 311 | #define DSP_TONE_RUNING 2 |
| 312 | #define DSP_TONE_STOP 4 |
| 313 | |
| 314 | #define DSP_WAIT_TIME 10 //ms |
| 315 | #define DSP_STOP_AND_WAIT_MAX_TICK 40 //tick |
| 316 | /* |
| 317 | #define DSP_QTMF_FREQ(f1,f2,f3,f4) { SAL_KT2_FREQ1 = (f1); \ |
| 318 | SAL_KT2_FREQ2 = (f2); \ |
| 319 | SAL_KT1_FREQ1 = (DTMF_DSP.fIsQTMF)?(f3):0; \ |
| 320 | SAL_KT1_FREQ2 = (DTMF_DSP.fIsQTMF)?(f4):0; \ |
| 321 | Data_Sync_Barrier(); } |
| 322 | */ |
| 323 | // temp remove for fix build warning |
| 324 | // static void dtmf_dsp_PlayOn( void *data ); |
| 325 | static void dtmf_dsp_PlayOff( void *data ); |
| 326 | |
| 327 | #if 0 |
| 328 | /* under construction !*/ |
| 329 | /* under construction !*/ |
| 330 | /* under construction !*/ |
| 331 | /* under construction !*/ |
| 332 | #if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 333 | /* under construction !*/ |
| 334 | /* under construction !*/ |
| 335 | /* under construction !*/ |
| 336 | /* under construction !*/ |
| 337 | /* under construction !*/ |
| 338 | /* under construction !*/ |
| 339 | /* under construction !*/ |
| 340 | /* under construction !*/ |
| 341 | /* under construction !*/ |
| 342 | #else |
| 343 | /* under construction !*/ |
| 344 | #endif |
| 345 | /* under construction !*/ |
| 346 | #endif |
| 347 | /* |
| 348 | // temp remove for fix build warning |
| 349 | static const L1SP_QTMF *dtmf_dsp_GetNextTone(const L1SP_Tones *ppToneList, const L1SP_QTMF *pCurrQTMF, kal_bool fIsQTMF) |
| 350 | { |
| 351 | const L1SP_QTMF *pNextQTMF; |
| 352 | if(fIsQTMF) |
| 353 | { |
| 354 | pNextQTMF = (L1SP_QTMF *)ppToneList + pCurrQTMF->next_tone; |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | pNextQTMF = (L1SP_QTMF *)(ppToneList + pCurrQTMF->next_tone); |
| 359 | } |
| 360 | return pNextQTMF; |
| 361 | } |
| 362 | */ |
| 363 | |
| 364 | |
| 365 | static void dtmf_dsp_SetTimer(kal_uint32 uMsec, void(*fpCallback)( void *pData )) |
| 366 | { |
| 367 | kal_uint16 uDur = uMsec / 10; |
| 368 | if(uDur) |
| 369 | { |
| 370 | SGPT_CTRL_START_T start; |
| 371 | start.u2Tick = uDur; |
| 372 | start.pfCallback = fpCallback; |
| 373 | start.vPara = NULL; |
| 374 | DclSGPT_Control( DTMF_DSP.uGPT, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | static void dtmf_dsp_StopTimer() |
| 379 | { |
| 380 | DclSGPT_Control(DTMF_DSP.uGPT ,SGPT_CMD_STOP, 0); |
| 381 | } |
| 382 | |
| 383 | static void dtmf_dsp_TurnOffDSP(kal_uint32 arg1, void* arg2) |
| 384 | { |
| 385 | |
| 386 | if(DTMF_DSP.uState != DTMF_DSP_STATE_ENDING) |
| 387 | { |
| 388 | return; |
| 389 | } |
| 390 | if(keytone[DSP_TONE].fToneRunning) |
| 391 | { |
| 392 | AM_KeyToneOff(); |
| 393 | // SAL_KT_ATT_GAIN = 0; |
| 394 | // Data_Sync_Barrier(); |
| 395 | keytone[DSP_TONE].fToneRunning = KAL_FALSE; |
| 396 | L1Audio_ClearFlag( keytone[DSP_TONE].uAudId ); |
| 397 | } |
| 398 | else if(tone[DSP_TONE].fToneRunning) |
| 399 | { |
| 400 | AM_ToneOff(); |
| 401 | // SAL_KT_ATT_GAIN = 0; |
| 402 | // Data_Sync_Barrier(); |
| 403 | tone[DSP_TONE].fToneRunning = KAL_FALSE; |
| 404 | L1Audio_ClearFlag( tone[DSP_TONE].uAudId ); |
| 405 | } |
| 406 | DTMF_DSP.uState = DTMF_DSP_STATE_IDLE; |
| 407 | |
| 408 | #if 0 |
| 409 | /* under construction !*/ |
| 410 | /* under construction !*/ |
| 411 | /* under construction !*/ |
| 412 | /* under construction !*/ |
| 413 | /* under construction !*/ |
| 414 | /* under construction !*/ |
| 415 | /* under construction !*/ |
| 416 | /* under construction !*/ |
| 417 | /* under construction !*/ |
| 418 | /* under construction !*/ |
| 419 | /* under construction !*/ |
| 420 | /* under construction !*/ |
| 421 | /* under construction !*/ |
| 422 | /* under construction !*/ |
| 423 | /* under construction !*/ |
| 424 | /* under construction !*/ |
| 425 | /* under construction !*/ |
| 426 | /* under construction !*/ |
| 427 | /* under construction !*/ |
| 428 | /* under construction !*/ |
| 429 | /* under construction !*/ |
| 430 | #endif |
| 431 | } |
| 432 | |
| 433 | static void dtmf_dsp_end( void *fWait ) |
| 434 | { |
| 435 | if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE) |
| 436 | { |
| 437 | return; |
| 438 | } |
| 439 | dtmf_dsp_StopTimer(); |
| 440 | // if(SAL_KT1_FSM == DSP_TONE_RUNING) |
| 441 | // { |
| 442 | // SAL_KT1_FSM = DSP_TONE_STOP; |
| 443 | // Data_Sync_Barrier(); |
| 444 | // } |
| 445 | // if(SAL_KT2_FSM == DSP_TONE_RUNING) |
| 446 | // { |
| 447 | // SAL_KT2_FSM = DSP_TONE_STOP; |
| 448 | // Data_Sync_Barrier(); |
| 449 | // } |
| 450 | // if(SAL_KT1_FSM != DSP_TONE_IDLE || SAL_KT2_FSM != DSP_TONE_IDLE) |
| 451 | // { |
| 452 | // dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_end); |
| 453 | // } |
| 454 | // else |
| 455 | // { |
| 456 | // DTMF_DSP.uState = DTMF_DSP_STATE_ENDING; |
| 457 | // } |
| 458 | |
| 459 | if(fWait) //in task, stop and wait |
| 460 | { |
| 461 | kal_int32 I =0; |
| 462 | while(DTMF_DSP.uState != DTMF_DSP_STATE_ENDING && DTMF_DSP.uState != DTMF_DSP_STATE_IDLE ) |
| 463 | { |
| 464 | |
| 465 | //kal_uint16 TONE_CTRL1, TONE_CTRL2; //unused |
| 466 | //TONE_CTRL1 = SAL_KT1_FSM; |
| 467 | //TONE_CTRL2 = SAL_KT2_FSM; |
| 468 | kal_sleep_task( AUD_1TICK(1) ); |
| 469 | //kal_prompt_trace(MOD_L1SP,"dtmf_dsp_end, TONE_CTRL1[%d]: %d, TONE_CTRL2[%d]: %d", (kal_uint32)DSP_TONE_CTRL1, TONE_CTRL1, (kal_uint32)DSP_TONE_CTRL2, TONE_CTRL2 ); |
| 470 | ASSERT(I < DSP_STOP_AND_WAIT_MAX_TICK); |
| 471 | I++; |
| 472 | } |
| 473 | dtmf_dsp_TurnOffDSP(0, NULL); |
| 474 | } |
| 475 | else if(DTMF_DSP.uState == DTMF_DSP_STATE_ENDING) // in timer isr |
| 476 | { |
| 477 | L1Audio_InProcCall(dtmf_dsp_TurnOffDSP, 0, NULL); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | /* |
| 482 | // temp remove for fix build warning |
| 483 | static void dtmf_dsp_PlayOn( void *data ) |
| 484 | { |
| 485 | MD_TRC_DTMF_DSP_PLAYON_ENTER(); |
| 486 | if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE) |
| 487 | { |
| 488 | return; |
| 489 | } |
| 490 | DTMF_DSP.pCurrQtmf = dtmf_dsp_GetNextTone( DTMF_DSP.pToneList, DTMF_DSP.pCurrQtmf, DTMF_DSP.fIsQTMF); |
| 491 | // if(SAL_KT1_FSM == DSP_TONE_IDLE && SAL_KT2_FSM == DSP_TONE_IDLE) |
| 492 | // { |
| 493 | // kal_trace( TRACE_FUNC,DTMF_DSP_PLAYON_1); |
| 494 | // //DSP_QTMF_FREQ( DTMF_DSP.pCurrQtmf->freq1, DTMF_DSP.pCurrQtmf->freq2, DTMF_DSP.pCurrQtmf->freq3, DTMF_DSP.pCurrQtmf->freq4 ); |
| 495 | // SAL_KT1_FSM = DSP_TONE_START; |
| 496 | // SAL_KT2_FSM = DSP_TONE_START; |
| 497 | // Data_Sync_Barrier(); |
| 498 | // dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->on_duration, dtmf_dsp_PlayOff); |
| 499 | // } |
| 500 | // else |
| 501 | // { kal_trace( TRACE_FUNC,DTMF_DSP_PLAYON_2); |
| 502 | // dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_PlayOn); |
| 503 | // } |
| 504 | MD_TRC_DTMF_DSP_PLAYON_LEAVE(); |
| 505 | } |
| 506 | */ |
| 507 | |
| 508 | static void dtmf_dsp_PlayOff( void *data ) |
| 509 | { |
| 510 | MD_TRC_DTMF_DSP_PLAYOFF_ENTER(); |
| 511 | if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE) |
| 512 | { |
| 513 | return; |
| 514 | } |
| 515 | // if(SAL_KT1_FSM == DSP_TONE_RUNING && SAL_KT2_FSM == DSP_TONE_RUNING) |
| 516 | // { |
| 517 | // SAL_KT1_FSM = DSP_TONE_STOP; |
| 518 | // SAL_KT2_FSM = DSP_TONE_STOP; |
| 519 | // Data_Sync_Barrier(); |
| 520 | // if(DTMF_DSP.pCurrQtmf->off_duration) |
| 521 | // { |
| 522 | // kal_trace( TRACE_FUNC,DTMF_DSP_PLAYOFF_1); |
| 523 | // dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->off_duration, dtmf_dsp_PlayOn); |
| 524 | // DTMF_DSP.uCurrentNode = DTMF_DSP.pCurrQtmf->next_tone; |
| 525 | // } |
| 526 | // else |
| 527 | // { |
| 528 | // kal_trace( TRACE_FUNC,DTMF_DSP_PLAYOFF_2); |
| 529 | // dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_end); |
| 530 | // } |
| 531 | // } |
| 532 | // else |
| 533 | // { |
| 534 | // dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_PlayOff); |
| 535 | // } |
| 536 | MD_TRC_DTMF_DSP_PLAYOFF_LEAVE(); |
| 537 | } |
| 538 | |
| 539 | static void dtmf_dsp_Start() |
| 540 | { |
| 541 | MD_TRC_DTMF_DSP_START_ENTER(); |
| 542 | dtmf_dsp_StopTimer(); |
| 543 | ASSERT(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE); |
| 544 | DTMF_DSP.uState = DTMF_DSP_STATE_PLAYING; |
| 545 | DTMF_DSP.uCurrentNode = 0; |
| 546 | //DSP_QTMF_FREQ( DTMF_DSP.pCurrQtmf->freq1, DTMF_DSP.pCurrQtmf->freq2, DTMF_DSP.pCurrQtmf->freq3, DTMF_DSP.pCurrQtmf->freq4 ); |
| 547 | // SAL_KT1_FSM = DSP_TONE_START; |
| 548 | // SAL_KT2_FSM = DSP_TONE_START; |
| 549 | // Data_Sync_Barrier(); |
| 550 | dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->on_duration, dtmf_dsp_PlayOff); |
| 551 | MD_TRC_DTMF_DSP_START_LEAVE(); |
| 552 | } |
| 553 | |
| 554 | |
| 555 | static void DTMF_DSP_Play( const L1SP_Tones *pToneList, kal_bool fIsQtmf, kal_bool fIsKeytone ) |
| 556 | { |
| 557 | #if 1 |
| 558 | MD_TRC_DTMF_DSP_PLAY_ENTER(); |
| 559 | KT_StopAndWait(); |
| 560 | TONE_StopAndWait(); |
| 561 | DTMF_DSP.fIsQTMF = fIsQtmf; |
| 562 | DTMF_DSP.pCurrQtmf = (const L1SP_QTMF *)pToneList; |
| 563 | if(fIsKeytone) |
| 564 | { |
| 565 | L1Audio_SetFlag( keytone[DSP_TONE].uAudId ); |
| 566 | } |
| 567 | else |
| 568 | { |
| 569 | L1Audio_SetFlag( tone[DSP_TONE].uAudId ); |
| 570 | if( AM_IsSpeechOn() ) //only apply on tone |
| 571 | { |
| 572 | // SAL_KT_ATT_GAIN = 0x4000; |
| 573 | // Data_Sync_Barrier(); |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | #if defined(__BT_SUPPORT__) |
| 578 | if( L1SP_IsBluetoothOn() ) |
| 579 | { |
| 580 | // SAL_KT1_AMP = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */ |
| 581 | // SAL_KT2_AMP = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */ |
| 582 | // Data_Sync_Barrier(); |
| 583 | // *DP_VSBT_CTRL |= 0x1; // output to both BT and voice DAC |
| 584 | } |
| 585 | else |
| 586 | #endif |
| 587 | { |
| 588 | // SAL_KT1_AMP = tone[DSP_TONE].amp; |
| 589 | // SAL_KT2_AMP = tone[DSP_TONE].amp; |
| 590 | // Data_Sync_Barrier(); |
| 591 | } |
| 592 | if(fIsKeytone) |
| 593 | { |
| 594 | keytone[DSP_TONE].fToneRunning = KAL_TRUE; |
| 595 | AM_KeyToneOn(); |
| 596 | } |
| 597 | else |
| 598 | { |
| 599 | tone[DSP_TONE].fToneRunning = KAL_TRUE; |
| 600 | AM_ToneOn(); |
| 601 | } |
| 602 | dtmf_dsp_Start(); |
| 603 | MD_TRC_DTMF_DSP_PLAY_LEAVE(); |
| 604 | #else |
| 605 | /* under construction !*/ |
| 606 | /* under construction !*/ |
| 607 | /* under construction !*/ |
| 608 | /* under construction !*/ |
| 609 | /* under construction !*/ |
| 610 | /* under construction !*/ |
| 611 | /* under construction !*/ |
| 612 | /* under construction !*/ |
| 613 | /* under construction !*/ |
| 614 | /* under construction !*/ |
| 615 | /* under construction !*/ |
| 616 | /* under construction !*/ |
| 617 | /* under construction !*/ |
| 618 | /* under construction !*/ |
| 619 | /* under construction !*/ |
| 620 | /* under construction !*/ |
| 621 | /* under construction !*/ |
| 622 | /* under construction !*/ |
| 623 | /* under construction !*/ |
| 624 | #if defined(__BT_SUPPORT__) |
| 625 | /* under construction !*/ |
| 626 | /* under construction !*/ |
| 627 | /* under construction !*/ |
| 628 | /* under construction !*/ |
| 629 | /* under construction !*/ |
| 630 | /* under construction !*/ |
| 631 | /* under construction !*/ |
| 632 | /* under construction !*/ |
| 633 | #endif |
| 634 | /* under construction !*/ |
| 635 | /* under construction !*/ |
| 636 | /* under construction !*/ |
| 637 | /* under construction !*/ |
| 638 | /* under construction !*/ |
| 639 | /* under construction !*/ |
| 640 | /* under construction !*/ |
| 641 | /* under construction !*/ |
| 642 | /* under construction !*/ |
| 643 | /* under construction !*/ |
| 644 | /* under construction !*/ |
| 645 | /* under construction !*/ |
| 646 | /* under construction !*/ |
| 647 | /* under construction !*/ |
| 648 | /* under construction !*/ |
| 649 | /* under construction !*/ |
| 650 | /* under construction !*/ |
| 651 | #endif |
| 652 | } |
| 653 | |
| 654 | static void DTMF_DSP_Stop( kal_bool fWait) |
| 655 | { |
| 656 | dtmf_dsp_end( (void*)fWait ); |
| 657 | } |
| 658 | |
| 659 | void toneInit( uint16 uAudId, uint16 id_num ) |
| 660 | { |
| 661 | ASSERT( id_num < TOTAL_TONE_NUM ); |
| 662 | |
| 663 | tone[id_num].type = id_num; |
| 664 | |
| 665 | if(id_num == DSP_TONE) |
| 666 | { |
| 667 | DTMF_DSP.uGPT = DclSGPT_Open( DCL_GPT_CB ,0 ); |
| 668 | tone[DSP_TONE].uAudId = uAudId; |
| 669 | tone[DSP_TONE].amp = TONE_INIT_AMP; |
| 670 | // SAL_KT_ATT_GAIN = 0; |
| 671 | // SAL_KT1_FSM = 0; |
| 672 | // SAL_KT2_FSM = 0; |
| 673 | // Data_Sync_Barrier(); |
| 674 | #if 0 |
| 675 | /* under construction !*/ |
| 676 | /* under construction !*/ |
| 677 | #endif //#if 0 |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | tone[id_num].uAudId = uAudId; |
| 682 | tone[id_num].amp = TONE_INIT_AMP; |
| 683 | } |
| 684 | /* DTMF_DSP.uGPT = DclSGPT_Open( DCL_GPT_CB ,0 ); |
| 685 | tone.uAudId = uAudId; |
| 686 | tone.amp = TONE_INIT_AMP; |
| 687 | SAL_KT_ATT_GAIN = 0; |
| 688 | SAL_KT1_FSM = 0; |
| 689 | SAL_KT2_FSM = 0; |
| 690 | Data_Sync_Barrier(); |
| 691 | #ifdef ANALOG_AFE_PATH_EXIST |
| 692 | AFE_TurnOnFIR( L1SP_TONE ); |
| 693 | #endif */ |
| 694 | } |
| 695 | |
| 696 | void ktInit( uint16 uAudId, uint16 id_num ) |
| 697 | { |
| 698 | ASSERT( id_num < TOTAL_TONE_NUM ); |
| 699 | |
| 700 | keytone[id_num].type = id_num; |
| 701 | |
| 702 | if(id_num == DSP_TONE) |
| 703 | { |
| 704 | keytone[DSP_TONE].uAudId = uAudId; |
| 705 | keytone[DSP_TONE].lock = 0; |
| 706 | #if 0 |
| 707 | /* under construction !*/ |
| 708 | /* under construction !*/ |
| 709 | #endif //#if 0 |
| 710 | keytone[DSP_TONE].gain = 0; |
| 711 | keytone[DSP_TONE].digital_gain_index = 0; |
| 712 | // SAL_KT2_AMP = KT_INIT_AMP; |
| 713 | // Data_Sync_Barrier(); |
| 714 | #if 0 |
| 715 | /* under construction !*/ |
| 716 | /* under construction !*/ |
| 717 | #endif //#if 0 |
| 718 | } |
| 719 | else |
| 720 | { |
| 721 | keytone[id_num].uAudId = uAudId; |
| 722 | keytone[id_num].lock = 0; |
| 723 | #if 0 |
| 724 | /* under construction !*/ |
| 725 | /* under construction !*/ |
| 726 | #endif //#if 0 |
| 727 | keytone[id_num].gain = 0; |
| 728 | keytone[id_num].digital_gain_index = 0; |
| 729 | } |
| 730 | /* keytone.uAudId = uAudId; |
| 731 | keytone.lock = 0; |
| 732 | #ifdef ANALOG_AFE_PATH_EXIST |
| 733 | keytone.volume1 = 160; |
| 734 | #endif |
| 735 | keytone.gain = 0; |
| 736 | keytone.digital_gain_index = 0; |
| 737 | SAL_KT2_AMP = KT_INIT_AMP; |
| 738 | Data_Sync_Barrier(); |
| 739 | #ifdef ANALOG_AFE_PATH_EXIST |
| 740 | AFE_TurnOnFIR( L1SP_KEYTONE ); |
| 741 | #endif */ |
| 742 | } |
| 743 | |
| 744 | void ktLock( void ) |
| 745 | { |
| 746 | ASSERT( keytone[DSP_TONE].lock < DTMF_KEYTONE_LOCK_MAX_COUNT ); |
| 747 | |
| 748 | keytone[DSP_TONE].lock++; |
| 749 | } |
| 750 | |
| 751 | void ktUnlock( void ) |
| 752 | { |
| 753 | ASSERT( keytone[DSP_TONE].lock > 0 ); |
| 754 | |
| 755 | keytone[DSP_TONE].lock--; |
| 756 | } |
| 757 | |
| 758 | void TONE_SetOutputDevice( uint8 device ) |
| 759 | { |
| 760 | //DTMF_MCU_StopAndWait(); |
| 761 | #if 0 |
| 762 | /* under construction !*/ |
| 763 | /* under construction !*/ |
| 764 | #endif //#if 0 |
| 765 | } |
| 766 | |
| 767 | void TONE_SetOutputVolume( uint8 volume1, int8 digital_gain_index ) |
| 768 | { |
| 769 | #if 0 |
| 770 | /* under construction !*/ |
| 771 | /* under construction !*/ |
| 772 | #endif //#if 0 |
| 773 | tone[DSP_TONE].digital_gain_index = digital_gain_index; |
| 774 | } |
| 775 | |
| 776 | void TONE_SetOutputGainControl( uint32 gain ) |
| 777 | { |
| 778 | #if defined(__GAIN_TABLE_SUPPORT__) |
| 779 | //AFE_SetOutputGainControl( L1SP_TONE, gain ); |
| 780 | #endif |
| 781 | } |
| 782 | |
| 783 | kal_bool TONE_DspPlayable(void) |
| 784 | { |
| 785 | |
| 786 | // kal_uint8 iDigiGainIndex; |
| 787 | |
| 788 | if(/*AM_IsAVsyncOn() || AM_IsDAIMode() ||*/ AM_IsAudioPlaybackOn() != -1) |
| 789 | return KAL_FALSE; |
| 790 | if(tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning ) |
| 791 | return KAL_FALSE; |
| 792 | if(keytone[DSP_TONE].lock) |
| 793 | return KAL_FALSE; |
| 794 | |
| 795 | // RIMIND: if uVolume == 0 (mute, the function return KAL_FALSE; |
| 796 | /* |
| 797 | #ifdef ANALOG_AFE_PATH_EXIST |
| 798 | { |
| 799 | kal_uint8 uVolume; |
| 800 | AFE_GetOutputVolume(L1SP_TONE, &uVolume, &iDigiGainIndex); |
| 801 | } |
| 802 | #else //#if 0 |
| 803 | AFE_DigitalOnly_GetOutputVolume(L1SP_TONE, &iDigiGainIndex ); |
| 804 | #endif //#if 0 |
| 805 | |
| 806 | #ifdef ANALOG_AFE_PATH_EXIST |
| 807 | if(0 == uVolume || tone[DSP_TONE].volume1 == 0) |
| 808 | return KAL_FALSE; |
| 809 | #endif |
| 810 | */ |
| 811 | return KAL_TRUE; |
| 812 | } |
| 813 | |
| 814 | void TONE_Play( const L1SP_Tones *pToneList, TONE_TYPE type) |
| 815 | { |
| 816 | ASSERT( type < TOTAL_TONE_NUM ); |
| 817 | |
| 818 | #if defined(__AUDIO_NOT_SUPPORTED__) |
| 819 | return; |
| 820 | #endif |
| 821 | |
| 822 | #ifndef __VOLTE_SUPPORT__ |
| 823 | return; |
| 824 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 825 | |
| 826 | |
| 827 | // if(AM_IsAfeOn()) return; |
| 828 | MD_TRC_TONEPLAY(0); |
| 829 | |
| 830 | if(type == DSP_TONE) |
| 831 | { |
| 832 | |
| 833 | // [RIMIND]for idel DSP tone play, please remind to set digital gain |
| 834 | // AFE_DigitalOnly_SetDigitalGain( L1SP_TONE, tone[DSP_TONE].digital_gain_index ); |
| 835 | |
| 836 | |
| 837 | MD_TRC_TONEPLAY(1); |
| 838 | if(!TONE_DspPlayable()) |
| 839 | { |
| 840 | MD_TRC_TONEPLAY(2); |
| 841 | return; |
| 842 | } |
| 843 | DTMF_DSP.fIsQTMF = KAL_FALSE; |
| 844 | tone[DSP_TONE].fIsQTMF = KAL_FALSE; |
| 845 | DTMF_DSP.uCurrentNode = 0; |
| 846 | DTMF_DSP.pToneList = pToneList; |
| 847 | tone[DSP_TONE].fToneRunning = KAL_TRUE; |
| 848 | DTMF_DSP_Play((const L1SP_Tones *)pToneList, tone[DSP_TONE].fIsQTMF/*DTMF_DSP.fIsQTMF*/, KAL_FALSE); |
| 849 | MD_TRC_TONEPLAY(3); |
| 850 | } |
| 851 | else |
| 852 | { |
| 853 | tone[type].fIsQTMF = KAL_FALSE; |
| 854 | |
| 855 | //tone[type].type = type; |
| 856 | |
| 857 | MD_TRC_TONEPLAY(5); |
| 858 | tone[type].fToneRunning = KAL_TRUE; |
| 859 | DTMF_MCU_Play((const L1SP_Tones *)pToneList, tone[type].fIsQTMF/*DTMF_DSP.fIsQTMF*/, KAL_FALSE); |
| 860 | |
| 861 | //AM_ToneOn(); |
| 862 | |
| 863 | MD_TRC_TONEPLAY(6); |
| 864 | } |
| 865 | |
| 866 | |
| 867 | #if 0 |
| 868 | /* under construction !*/ |
| 869 | /* under construction !*/ |
| 870 | /* under construction !*/ |
| 871 | /* under construction !*/ |
| 872 | /* under construction !*/ |
| 873 | /* under construction !*/ |
| 874 | /* under construction !*/ |
| 875 | /* under construction !*/ |
| 876 | /* under construction !*/ |
| 877 | /* under construction !*/ |
| 878 | /* under construction !*/ |
| 879 | /* under construction !*/ |
| 880 | /* under construction !*/ |
| 881 | /* under construction !*/ |
| 882 | /* under construction !*/ |
| 883 | /* under construction !*/ |
| 884 | /* under construction !*/ |
| 885 | /* under construction !*/ |
| 886 | /* under construction !*/ |
| 887 | /* under construction !*/ |
| 888 | /* under construction !*/ |
| 889 | /* under construction !*/ |
| 890 | /* under construction !*/ |
| 891 | /* under construction !*/ |
| 892 | /* under construction !*/ |
| 893 | /* under construction !*/ |
| 894 | /* under construction !*/ |
| 895 | /* under construction !*/ |
| 896 | /* under construction !*/ |
| 897 | /* under construction !*/ |
| 898 | /* under construction !*/ |
| 899 | /* under construction !*/ |
| 900 | /* under construction !*/ |
| 901 | /* under construction !*/ |
| 902 | /* under construction !*/ |
| 903 | /* under construction !*/ |
| 904 | #endif /*#if 0*/ |
| 905 | } |
| 906 | |
| 907 | void TONE_PlayQTMF( const L1SP_QTMF *pToneList ) |
| 908 | { |
| 909 | //DTMF_DSP.fIsQTMF = KAL_TRUE; |
| 910 | //TONE_Play((const L1SP_Tones *)pToneList); |
| 911 | } |
| 912 | |
| 913 | |
| 914 | void TONE_Stop( TONE_TYPE type ) |
| 915 | { |
| 916 | #ifndef __VOLTE_SUPPORT__ |
| 917 | return; |
| 918 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 919 | |
| 920 | MD_TRC_TONESTOP(); |
| 921 | |
| 922 | if(type == DSP_TONE) |
| 923 | { |
| 924 | if(tone[DSP_TONE].fToneRunning) |
| 925 | { |
| 926 | DTMF_DSP_Stop(KAL_FALSE); |
| 927 | } |
| 928 | } |
| 929 | else |
| 930 | { |
| 931 | if(tone[type].fToneRunning) |
| 932 | { |
| 933 | DTMF_MCU_Stop(KAL_FALSE); |
| 934 | tone[type].fToneRunning = KAL_FALSE; |
| 935 | } |
| 936 | } |
| 937 | /* if(tone.fDspToneRunning) |
| 938 | { |
| 939 | DTMF_DSP_Stop(KAL_FALSE); |
| 940 | } |
| 941 | else if(tone.fMcuToneRunning) |
| 942 | { |
| 943 | DTMF_MCU_Stop(KAL_FALSE); |
| 944 | tone.fMcuToneRunning = KAL_FALSE; |
| 945 | }*/ |
| 946 | } |
| 947 | |
| 948 | void TONE_StopAndWait( void ) |
| 949 | { |
| 950 | #ifndef __VOLTE_SUPPORT__ |
| 951 | return; |
| 952 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 953 | |
| 954 | if(!tone[DSP_TONE].fToneRunning) |
| 955 | { |
| 956 | return; |
| 957 | } |
| 958 | AM_FlushQFunction(); |
| 959 | DTMF_DSP_Stop(KAL_TRUE); |
| 960 | } |
| 961 | |
| 962 | void TONE_SetAmplitude( int16 amp ) |
| 963 | { |
| 964 | //tone.amp = (uint16)amp; |
| 965 | tone[DSP_TONE].amp = (uint16)amp; |
| 966 | } |
| 967 | |
| 968 | void TONE_SetFIR( bool enable ) |
| 969 | { |
| 970 | if( enable ) |
| 971 | { |
| 972 | #if 0 |
| 973 | /* under construction !*/ |
| 974 | /* under construction !*/ |
| 975 | #endif //#if 0 |
| 976 | } |
| 977 | else |
| 978 | { |
| 979 | #if 0 |
| 980 | /* under construction !*/ |
| 981 | /* under construction !*/ |
| 982 | #endif //#if 0 |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | void TONE_SetHandler( void (*fpHandler)(void), TONE_TYPE type ) |
| 987 | { |
| 988 | //tone.fpHandler = fpHandler; //callback when tone stop done |
| 989 | tone[type].fpHandler = fpHandler; //callback when tone stop done |
| 990 | } |
| 991 | |
| 992 | kal_bool KT_DspPlayable(void) |
| 993 | { |
| 994 | |
| 995 | // kal_uint8 iDigiGainIndex; |
| 996 | |
| 997 | if(/*AM_IsAVsyncOn() || AM_IsDAIMode() || */AM_IsAudioPlaybackOn() != -1) |
| 998 | return KAL_FALSE; |
| 999 | if(tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning ) |
| 1000 | return KAL_FALSE; |
| 1001 | if(keytone[DSP_TONE].lock) |
| 1002 | return KAL_FALSE; |
| 1003 | |
| 1004 | |
| 1005 | // REMIND, if keytone volume is 0 (mute). it should return KAL_FALSE |
| 1006 | |
| 1007 | /* |
| 1008 | AFE_DigitalOnly_GetOutputVolume(L1SP_KEYTONE, &iDigiGainIndex ); |
| 1009 | */ |
| 1010 | |
| 1011 | /* |
| 1012 | #ifdef ANALOG_AFE_PATH_EXIST |
| 1013 | if(0 == uVolume || keytone[DSP_TONE].volume1 == 0) |
| 1014 | return KAL_FALSE; |
| 1015 | #endif |
| 1016 | */ |
| 1017 | |
| 1018 | return KAL_TRUE; |
| 1019 | } |
| 1020 | |
| 1021 | void KT_SetOutputDevice( uint8 device ) |
| 1022 | { |
| 1023 | #ifndef __VOLTE_SUPPORT__ |
| 1024 | return; |
| 1025 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 1026 | |
| 1027 | KT_StopAndWait(); |
| 1028 | if(DTMF_MCU_IsKeytonePlaying()) // && device != AFE_GetOutputDevice(L1SP_KEYTONE)) single output |
| 1029 | { |
| 1030 | DTMF_MCU_StopAndWait(); |
| 1031 | } |
| 1032 | #if 0 |
| 1033 | /* under construction !*/ |
| 1034 | /* under construction !*/ |
| 1035 | #endif //#if 0 |
| 1036 | } |
| 1037 | |
| 1038 | void KT_SetOutputVolume( uint8 volume1, int8 digital_gain_index ) |
| 1039 | { |
| 1040 | #if 0 |
| 1041 | /* under construction !*/ |
| 1042 | /* under construction !*/ |
| 1043 | #endif //#if 0 |
| 1044 | keytone[DSP_TONE].digital_gain_index = digital_gain_index; |
| 1045 | } |
| 1046 | |
| 1047 | bool PcmSink_IsAudioRuning() |
| 1048 | { |
| 1049 | return false; |
| 1050 | } |
| 1051 | |
| 1052 | void KT_SetOutputGainControl( uint32 gain ) |
| 1053 | { |
| 1054 | #if defined(__GAIN_TABLE_SUPPORT__) |
| 1055 | //keytone.gain = gain; |
| 1056 | keytone[DSP_TONE].gain = gain; |
| 1057 | AFE_SetOutputGainControl(L1SP_KEYTONE, gain); |
| 1058 | #endif |
| 1059 | } |
| 1060 | |
| 1061 | void KT_Play( kal_uint16 freq1, kal_uint16 freq2, kal_uint16 duration, TONE_TYPE type) //duration in msec |
| 1062 | { |
| 1063 | #ifndef __VOLTE_SUPPORT__ |
| 1064 | return; |
| 1065 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 1066 | |
| 1067 | MD_TRC_KTPLAY(0); |
| 1068 | #if defined(KEYTONE_DEBUG) |
| 1069 | Keytone_Debug_Entry(freq1, freq2); |
| 1070 | return; |
| 1071 | #endif |
| 1072 | #if defined(__AUDIO_NOT_SUPPORTED__) |
| 1073 | return; |
| 1074 | #endif |
| 1075 | |
| 1076 | |
| 1077 | if(type == DSP_TONE) |
| 1078 | { |
| 1079 | MD_TRC_KTPLAY(1); |
| 1080 | |
| 1081 | // [RIMIND]for idel DSP tone play, please remind to set digital gain |
| 1082 | // AFE_DigitalOnly_SetDigitalGain( L1SP_KEYTONE, keytone[DSP_TONE].digital_gain_index ); |
| 1083 | |
| 1084 | if(!KT_DspPlayable()) |
| 1085 | { |
| 1086 | MD_TRC_KTPLAY(2); |
| 1087 | return; |
| 1088 | } |
| 1089 | |
| 1090 | keytone[DSP_TONE].dtmf.freq1 = freq1; |
| 1091 | keytone[DSP_TONE].dtmf.freq2 = freq2; |
| 1092 | keytone[DSP_TONE].dtmf.on_duration = duration; |
| 1093 | keytone[DSP_TONE].dtmf.off_duration = 0; |
| 1094 | //keytone[DSP_TONE].type = type; |
| 1095 | MD_TRC_KTPLAY(3); |
| 1096 | |
| 1097 | DTMF_DSP_Play((const L1SP_Tones *)&keytone[DSP_TONE].dtmf, KAL_FALSE, KAL_TRUE); |
| 1098 | MD_TRC_KTPLAY(4); |
| 1099 | } |
| 1100 | else |
| 1101 | { |
| 1102 | #if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1103 | if(PcmSink_IsAudioRuning() || DTMF_MCU_IsTonePlaying() /*|| AM_IsAfeOn()*/) |
| 1104 | { |
| 1105 | return; //disable keytone during audio playback |
| 1106 | } |
| 1107 | #endif //defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1108 | |
| 1109 | MD_TRC_KTPLAY(5); |
| 1110 | keytone[type].dtmf.freq1 = freq1; |
| 1111 | keytone[type].dtmf.freq2 = freq2; |
| 1112 | keytone[type].dtmf.on_duration = duration; |
| 1113 | keytone[type].dtmf.off_duration = 0; |
| 1114 | //keytone[DSP_TONE].type = type; |
| 1115 | |
| 1116 | MD_TRC_KTPLAY(6); |
| 1117 | keytone[type].fToneRunning = KAL_TRUE; |
| 1118 | DTMF_MCU_Play((const L1SP_Tones *)&keytone[type].dtmf, KAL_FALSE, KAL_TRUE); |
| 1119 | |
| 1120 | MD_TRC_KTPLAY(7); |
| 1121 | } |
| 1122 | |
| 1123 | #if 0 |
| 1124 | #if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1125 | /* under construction !*/ |
| 1126 | /* under construction !*/ |
| 1127 | /* under construction !*/ |
| 1128 | /* under construction !*/ |
| 1129 | #endif //defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1130 | /* under construction !*/ |
| 1131 | /* under construction !*/ |
| 1132 | /* under construction !*/ |
| 1133 | /* under construction !*/ |
| 1134 | /* under construction !*/ |
| 1135 | /* under construction !*/ |
| 1136 | /* under construction !*/ |
| 1137 | /* under construction !*/ |
| 1138 | /* under construction !*/ |
| 1139 | /* under construction !*/ |
| 1140 | /* under construction !*/ |
| 1141 | /* under construction !*/ |
| 1142 | /* under construction !*/ |
| 1143 | /* under construction !*/ |
| 1144 | /* under construction !*/ |
| 1145 | /* under construction !*/ |
| 1146 | /* under construction !*/ |
| 1147 | /* under construction !*/ |
| 1148 | /* under construction !*/ |
| 1149 | /* under construction !*/ |
| 1150 | /* under construction !*/ |
| 1151 | /* under construction !*/ |
| 1152 | /* under construction !*/ |
| 1153 | /* under construction !*/ |
| 1154 | /* under construction !*/ |
| 1155 | /* under construction !*/ |
| 1156 | /* under construction !*/ |
| 1157 | /* under construction !*/ |
| 1158 | /* under construction !*/ |
| 1159 | /* under construction !*/ |
| 1160 | /* under construction !*/ |
| 1161 | /* under construction !*/ |
| 1162 | /* under construction !*/ |
| 1163 | /* under construction !*/ |
| 1164 | /* under construction !*/ |
| 1165 | /* under construction !*/ |
| 1166 | /* under construction !*/ |
| 1167 | /* under construction !*/ |
| 1168 | /* under construction !*/ |
| 1169 | /* under construction !*/ |
| 1170 | #endif /*#if 1*/ |
| 1171 | } |
| 1172 | |
| 1173 | void KT_Stop( TONE_TYPE type ) |
| 1174 | { |
| 1175 | #ifndef __VOLTE_SUPPORT__ |
| 1176 | return; |
| 1177 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 1178 | |
| 1179 | MD_TRC_KTSTOP(); |
| 1180 | |
| 1181 | if(type == DSP_TONE) |
| 1182 | { |
| 1183 | if(keytone[DSP_TONE].fToneRunning) |
| 1184 | { |
| 1185 | DTMF_DSP_Stop(KAL_FALSE); |
| 1186 | } |
| 1187 | } |
| 1188 | else |
| 1189 | { |
| 1190 | if(keytone[type].fToneRunning) |
| 1191 | { |
| 1192 | DTMF_MCU_Stop(KAL_TRUE); |
| 1193 | keytone[type].fToneRunning = KAL_FALSE; |
| 1194 | } |
| 1195 | } |
| 1196 | return; |
| 1197 | |
| 1198 | /* if(keytone.fDspToneRunning) |
| 1199 | { |
| 1200 | DTMF_DSP_Stop(KAL_FALSE); |
| 1201 | }else |
| 1202 | if(keytone.fMcuToneRunning) |
| 1203 | { |
| 1204 | DTMF_MCU_Stop(KAL_TRUE); |
| 1205 | keytone.fMcuToneRunning = KAL_FALSE; |
| 1206 | } |
| 1207 | return;*/ |
| 1208 | } |
| 1209 | |
| 1210 | void KT_StopAndWait() |
| 1211 | { |
| 1212 | |
| 1213 | |
| 1214 | #ifndef __VOLTE_SUPPORT__ |
| 1215 | return; |
| 1216 | #endif //#ifndef __VOLTE_SUPPORT__ |
| 1217 | |
| 1218 | //if(!keytone.fDspToneRunning) |
| 1219 | if(!keytone[DSP_TONE].fToneRunning) |
| 1220 | { |
| 1221 | return; |
| 1222 | } |
| 1223 | AM_FlushQFunction(); |
| 1224 | DTMF_DSP_Stop(KAL_TRUE); |
| 1225 | } |
| 1226 | |
| 1227 | void KT_SetAmplitude( int16 amp ) |
| 1228 | { |
| 1229 | // SAL_KT2_AMP = amp; |
| 1230 | // Data_Sync_Barrier(); |
| 1231 | } |
| 1232 | |
| 1233 | void KT_SetFIR( bool enable ) |
| 1234 | { |
| 1235 | if( enable ) |
| 1236 | { |
| 1237 | #if 0 |
| 1238 | /* under construction !*/ |
| 1239 | /* under construction !*/ |
| 1240 | #endif //#if 0 |
| 1241 | } |
| 1242 | else |
| 1243 | { |
| 1244 | #if 0 |
| 1245 | /* under construction !*/ |
| 1246 | /* under construction !*/ |
| 1247 | #endif //#if 0 |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | kal_bool KT_IsPlayable(void) |
| 1252 | { |
| 1253 | // kal_uint8 uVolume; |
| 1254 | // kal_int8 iDigiGainIndex; |
| 1255 | if(keytone[DSP_TONE].fToneRunning)//(dtmf_dsp_DspToneCase()) |
| 1256 | { |
| 1257 | return KT_DspPlayable(); |
| 1258 | } |
| 1259 | else |
| 1260 | { |
| 1261 | #if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1262 | if(PcmSink_IsAudioRuning() || tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning) |
| 1263 | { |
| 1264 | return KAL_FALSE; //disable keytone during audio playback |
| 1265 | } |
| 1266 | #endif |
| 1267 | #if 0 |
| 1268 | /* under construction !*/ |
| 1269 | /* under construction !*/ |
| 1270 | /* under construction !*/ |
| 1271 | /* under construction !*/ |
| 1272 | /* under construction !*/ |
| 1273 | /* under construction !*/ |
| 1274 | #endif //#if 0 |
| 1275 | } |
| 1276 | return KAL_FALSE; |
| 1277 | |
| 1278 | /* |
| 1279 | kal_uint8 uVolume; |
| 1280 | kal_int8 iDigiGainIndex; |
| 1281 | if( DSP_TONE == keytone.type )//(dtmf_dsp_DspToneCase()) |
| 1282 | { |
| 1283 | return KT_DspPlayable(); |
| 1284 | } |
| 1285 | else |
| 1286 | { |
| 1287 | #if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM ) |
| 1288 | if(PcmSink_IsAudioRuning() || tone.fDspToneRunning || keytone.fDspToneRunning) |
| 1289 | { |
| 1290 | return KAL_FALSE; //disable keytone during audio playback |
| 1291 | } |
| 1292 | |
| 1293 | #endif |
| 1294 | AFE_GetOutputVolume(L1SP_KEYTONE, &uVolume, &iDigiGainIndex); |
| 1295 | #ifdef ANALOG_AFE_PATH_EXIST |
| 1296 | if(0 == uVolume || keytone.volume1 == 0) |
| 1297 | { |
| 1298 | return KAL_FALSE; |
| 1299 | } |
| 1300 | #endif |
| 1301 | } |
| 1302 | */ |
| 1303 | } |
| 1304 | |
| 1305 | //#pragma arm section |
| 1306 | |