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 | * spc_drv.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * MAUI |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * MD speech control |
| 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 | * removed! |
| 66 | * |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * |
| 96 | * removed! |
| 97 | * removed! |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * removed! |
| 102 | * |
| 103 | * removed! |
| 104 | * removed! |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * removed! |
| 109 | * |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * removed! |
| 119 | * removed! |
| 120 | * |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * |
| 126 | * removed! |
| 127 | * removed! |
| 128 | * removed! |
| 129 | * |
| 130 | * removed! |
| 131 | * removed! |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * |
| 135 | * removed! |
| 136 | * removed! |
| 137 | * removed! |
| 138 | * |
| 139 | * removed! |
| 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 | * removed! |
| 168 | * |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * removed! |
| 172 | * removed! |
| 173 | * |
| 174 | * removed! |
| 175 | * removed! |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * |
| 179 | >>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c#11 |
| 180 | ==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c#12 |
| 181 | * removed! |
| 182 | * removed! |
| 183 | * removed! |
| 184 | ==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c |
| 185 | * removed! |
| 186 | * removed! |
| 187 | * removed! |
| 188 | * removed! |
| 189 | * |
| 190 | * removed! |
| 191 | * removed! |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * |
| 195 | * removed! |
| 196 | * removed! |
| 197 | * removed! |
| 198 | * removed! |
| 199 | <<<< |
| 200 | * |
| 201 | * removed! |
| 202 | * removed! |
| 203 | * removed! |
| 204 | * |
| 205 | * removed! |
| 206 | * removed! |
| 207 | * removed! |
| 208 | * |
| 209 | * removed! |
| 210 | * removed! |
| 211 | * removed! |
| 212 | * |
| 213 | * removed! |
| 214 | * removed! |
| 215 | * removed! |
| 216 | * |
| 217 | * removed! |
| 218 | * removed! |
| 219 | * removed! |
| 220 | * |
| 221 | * removed! |
| 222 | * removed! |
| 223 | * removed! |
| 224 | * removed! |
| 225 | * |
| 226 | * removed! |
| 227 | * removed! |
| 228 | * removed! |
| 229 | * |
| 230 | * removed! |
| 231 | * removed! |
| 232 | * removed! |
| 233 | * |
| 234 | * removed! |
| 235 | * removed! |
| 236 | * removed! |
| 237 | * |
| 238 | * removed! |
| 239 | * removed! |
| 240 | * removed! |
| 241 | * |
| 242 | * removed! |
| 243 | * removed! |
| 244 | * removed! |
| 245 | * |
| 246 | * removed! |
| 247 | * removed! |
| 248 | * removed! |
| 249 | * |
| 250 | * removed! |
| 251 | * removed! |
| 252 | * removed! |
| 253 | * |
| 254 | * removed! |
| 255 | * removed! |
| 256 | * removed! |
| 257 | * |
| 258 | * removed! |
| 259 | * removed! |
| 260 | * removed! |
| 261 | * removed! |
| 262 | * |
| 263 | * removed! |
| 264 | * removed! |
| 265 | * removed! |
| 266 | * removed! |
| 267 | * |
| 268 | * removed! |
| 269 | * removed! |
| 270 | * removed! |
| 271 | * |
| 272 | * removed! |
| 273 | * removed! |
| 274 | * removed! |
| 275 | * |
| 276 | * removed! |
| 277 | * removed! |
| 278 | * removed! |
| 279 | * |
| 280 | * removed! |
| 281 | * removed! |
| 282 | * removed! |
| 283 | * |
| 284 | * removed! |
| 285 | * removed! |
| 286 | * removed! |
| 287 | * |
| 288 | * removed! |
| 289 | * removed! |
| 290 | * removed! |
| 291 | * |
| 292 | * removed! |
| 293 | * removed! |
| 294 | * removed! |
| 295 | * |
| 296 | * removed! |
| 297 | * removed! |
| 298 | * removed! |
| 299 | * |
| 300 | * removed! |
| 301 | * removed! |
| 302 | * removed! |
| 303 | * |
| 304 | * removed! |
| 305 | * removed! |
| 306 | * removed! |
| 307 | * |
| 308 | * removed! |
| 309 | * removed! |
| 310 | * removed! |
| 311 | * removed! |
| 312 | * |
| 313 | * removed! |
| 314 | * removed! |
| 315 | * removed! |
| 316 | * removed! |
| 317 | * removed! |
| 318 | * removed! |
| 319 | * removed! |
| 320 | * |
| 321 | * removed! |
| 322 | * removed! |
| 323 | * removed! |
| 324 | * removed! |
| 325 | * removed! |
| 326 | * |
| 327 | * removed! |
| 328 | * removed! |
| 329 | * removed! |
| 330 | * |
| 331 | * removed! |
| 332 | * removed! |
| 333 | * removed! |
| 334 | * removed! |
| 335 | * |
| 336 | * removed! |
| 337 | * removed! |
| 338 | * removed! |
| 339 | * removed! |
| 340 | * |
| 341 | * removed! |
| 342 | * removed! |
| 343 | * removed! |
| 344 | * |
| 345 | * removed! |
| 346 | * removed! |
| 347 | * removed! |
| 348 | * removed! |
| 349 | * |
| 350 | * removed! |
| 351 | * removed! |
| 352 | * removed! |
| 353 | * |
| 354 | * removed! |
| 355 | * removed! |
| 356 | * removed! |
| 357 | * |
| 358 | * removed! |
| 359 | * removed! |
| 360 | * removed! |
| 361 | * removed! |
| 362 | * |
| 363 | * removed! |
| 364 | * removed! |
| 365 | * removed! |
| 366 | * |
| 367 | * removed! |
| 368 | * removed! |
| 369 | * removed! |
| 370 | * |
| 371 | * removed! |
| 372 | * removed! |
| 373 | * removed! |
| 374 | * |
| 375 | * removed! |
| 376 | * removed! |
| 377 | * removed! |
| 378 | * |
| 379 | * removed! |
| 380 | * removed! |
| 381 | * removed! |
| 382 | * |
| 383 | * removed! |
| 384 | * removed! |
| 385 | * removed! |
| 386 | * |
| 387 | * removed! |
| 388 | * removed! |
| 389 | * removed! |
| 390 | * |
| 391 | * removed! |
| 392 | * removed! |
| 393 | * removed! |
| 394 | * |
| 395 | * removed! |
| 396 | * removed! |
| 397 | * removed! |
| 398 | * removed! |
| 399 | * removed! |
| 400 | * removed! |
| 401 | * removed! |
| 402 | * |
| 403 | * removed! |
| 404 | * removed! |
| 405 | * removed! |
| 406 | * removed! |
| 407 | * removed! |
| 408 | * |
| 409 | * removed! |
| 410 | * removed! |
| 411 | * removed! |
| 412 | * removed! |
| 413 | |
| 414 | * removed! |
| 415 | * removed! |
| 416 | * removed! |
| 417 | * removed! |
| 418 | * removed! |
| 419 | * |
| 420 | *------------------------------------------------------------------------------ |
| 421 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 422 | *============================================================================== |
| 423 | *******************************************************************************/ |
| 424 | |
| 425 | #include "kal_public_api.h" |
| 426 | #include "kal_general_types.h" |
| 427 | #include "stack_config.h" |
| 428 | #include "reg_base.h" |
| 429 | #include "kal_trace.h" |
| 430 | #include "string.h" |
| 431 | #include "fsal.h" |
| 432 | #include "sp_cc.h" |
| 433 | #include "event_info_utility.h" // for MODEM_WARNING_MESSAGE |
| 434 | |
| 435 | #include "audio_enum.h" |
| 436 | #include "am.h" |
| 437 | #include "afe.h" |
| 438 | #include "media.h" |
| 439 | #include "l1sp_trc.h" |
| 440 | #include "audcoeff_default.h" |
| 441 | #include "dcl.h" |
| 442 | #include "extcodec.h" |
| 443 | |
| 444 | #if defined(__L5_SUPPORT__) |
| 445 | |
| 446 | #include "l1audio.h" |
| 447 | |
| 448 | #include "drv_sap.h" |
| 449 | #include "l5_msgid.h" |
| 450 | #endif |
| 451 | |
| 452 | |
| 453 | #include "med_spcio.h" |
| 454 | #include "audio_em_struct.h" |
| 455 | // #include "aud_common_config.h" // for DEFAULT_SPEECH_COMMON_PARA. in customer folder |
| 456 | |
| 457 | |
| 458 | #include "spc_drv.h" // including "sp_drv.h" |
| 459 | #include "sp_enhance.h" |
| 460 | #include "sp_daca.h" |
| 461 | #include "pcm4way.h" |
| 462 | // #include "pcmrec.h" |
| 463 | #include "rawpcmrec.h" |
| 464 | #include "bgSnd.h" |
| 465 | #include "pcmRouter.h" |
| 466 | #include "ctm_drv.h" |
| 467 | #include "vm.h" |
| 468 | #include "pcmMixer.h" |
| 469 | #include "pcmMixer3.h" |
| 470 | // #include "mml1_rf_global.h" |
| 471 | |
| 472 | #if defined(__CVSD_CODEC_SUPPORT__) |
| 473 | #include "bt_sco_drv.h" |
| 474 | #endif |
| 475 | |
| 476 | #include "sp_dsptone_drv.h" |
| 477 | #include "sal_exp.h" |
| 478 | |
| 479 | // ---------------------------------------------------------------------------- |
| 480 | void Spc_AcousticLoopback(bool enable, kal_uint8 uParam, kal_uint8 extraParam); |
| 481 | #if defined(_SPE_ENH_MD_PARSE_) |
| 482 | uint16 spc_dynamicParameterParser_dispatcher(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 483 | kal_uint16 *procLen, kal_uint16 *newOffset); |
| 484 | #endif |
| 485 | void Spc_SpeechRouterOn(kal_bool enable); |
| 486 | void Spc_SpeechOnForDaca( kal_uint8 RAT_Mode, kal_bool enable); |
| 487 | void spc_SpeechOnForCallHold(kal_bool isGen); |
| 488 | kal_bool spc_endApp(void); |
| 489 | |
| 490 | void spc_gain_UlMuteSet(kal_bool on, kal_bool byPassCheck); |
| 491 | void spc_gain_DlMuteSet(kal_bool on, kal_bool byPassCheck); |
| 492 | void spc_gain_UlEnhResultMuteSet(kal_bool on, kal_bool byPassCheck); |
| 493 | void spc_gain_UlSourceMuteSet(kal_bool on, kal_bool byPassCheck); |
| 494 | void spc_gain_DlMuteCodecSet(kal_bool on, kal_bool byPassCheck); |
| 495 | void spc_gain_DlMuteSet_PrePcmMixer(kal_bool on, kal_bool byPassCheck); |
| 496 | |
| 497 | // ---------------------------------------------------------------------------- |
| 498 | |
| 499 | #if defined(__ECALL_SUPPORT__) |
| 500 | void aud_ecall_event_callback(eCall_Modem_Event event, void *param); |
| 501 | #endif |
| 502 | |
| 503 | extern _PCMEX_T pcmEx; |
| 504 | typedef enum { |
| 505 | SPC_APP_SPEECH_USAGE = 0, |
| 506 | SPC_APP_PCMNWAY_USAGE, |
| 507 | SPC_APP_OLD_RECORD_USAGE, // either "SPC_APP_RECORD_USAGE" or "SPC_APP_PCM_REC_USAGE & SPC_APP_VM_REC_USAGE" usage, remove from 93md |
| 508 | SPC_APP_BGSND_USAGE, |
| 509 | |
| 510 | SPC_APP_CTM_USAGE, |
| 511 | SPC_APP_ACLOOPBACK_USAGE, |
| 512 | |
| 513 | SPC_APP_OLD_PCM_REC_USAGE, // 6, add from MT6582 chip, remove from 93md |
| 514 | SPC_APP_VM_REC_USAGE, |
| 515 | |
| 516 | SPC_APP_HOLD_USAGE, // cannot mix with other speech application |
| 517 | SPC_APP_HOSTED_USAGE, |
| 518 | SPC_APP_PCMROUTER_USAGE, |
| 519 | |
| 520 | //We can't enable all record function, only following selections are acceptable: |
| 521 | //1. SPC_APP_OLD_RECORD_USAGE |
| 522 | //2. SPC_APP_OLD_PCM_REC_USAGE |
| 523 | //3. SPC_APP_OLD_PCM_REC_USAGE + SPC_APP_VM_REC_USAGE |
| 524 | //4. SPC_APP_RAW_PCM_REC_USAGE |
| 525 | //5. SPC_APP_RAW_PCM_REC_USAGE + SPC_APP_VM_REC_USAGE |
| 526 | SPC_APP_RAW_PCM_REC_USAGE, //11, add from MT6752 chip |
| 527 | |
| 528 | SPC_APP_MERGE_SPH_USAGE, // 12 |
| 529 | SPC_APP_MIXER_USAGE, // 13 |
| 530 | SPC_APP_MIXER3_USAGE, // 14 |
| 531 | SPC_APP_MAX = 16 // due to spcAppUsage is uint16. so only 16 application can existing. |
| 532 | } MSG_SPC_APP_T; |
| 533 | |
| 534 | typedef enum{ |
| 535 | SPC_EM_INIT_COMMON = 0, |
| 536 | SPC_EM_INIT_NB, |
| 537 | SPC_EM_INIT_WB, |
| 538 | SPC_EM_INIT_SWB, |
| 539 | SPC_EM_INIT_DMNR, |
| 540 | SPC_EM_INIT_LSPK_DMNR, |
| 541 | SPC_EM_INIT_IIR, |
| 542 | |
| 543 | SPC_EM_INIT_MAX = 16 // due to spcEmInit is unit16, so only 16 em data message can existing. |
| 544 | } SPC_EM_INIT_T; |
| 545 | |
| 546 | typedef struct _SPC_T_ |
| 547 | { |
| 548 | kal_uint16 spcGetEpofTimes; |
| 549 | kal_uint16 spcAppUsage; //Please reference MSG_SPC_APP_T for bit definition |
| 550 | |
| 551 | kal_uint16 spcEmInit; |
| 552 | |
| 553 | // DSP mute |
| 554 | kal_bool spcMuteUl; |
| 555 | kal_bool spcMuteDl; |
| 556 | |
| 557 | kal_bool spcMuteUlEnhResult; |
| 558 | kal_bool spcMuteUlSource; |
| 559 | |
| 560 | kal_uint16 spcRampAck; |
| 561 | #if defined(__ECALL_SUPPORT__) |
| 562 | kal_uint8 eCall_LIB_Status; //0:disable ecall,1:only enable SDT,2:enable ecall |
| 563 | kal_uint8 eCall_Ctrl_Seq_Switch; |
| 564 | #endif |
| 565 | } _SPC_T; |
| 566 | |
| 567 | #if defined(__ECALL_SUPPORT__) |
| 568 | typedef signed short int Int16; /* 16 bit signed variable */ |
| 569 | |
| 570 | extern Int16 eCall_TX_CTRL_SEQ_State[800]; |
| 571 | extern Int16 eCall_TX_CTRL_SEQ_dlData[800]; |
| 572 | extern Int16 eCall_TX_CTRL_SEQ_dlMetric[800]; |
| 573 | extern Int16 eCall_RX_CTRL_SEQ_State[800]; |
| 574 | extern Int16 eCall_RX_CTRL_SEQ_dlData[800]; |
| 575 | extern Int16 eCall_RX_CTRL_SEQ_dlMetric[800]; |
| 576 | kal_uint8 eCall_Msd[140]; |
| 577 | // Speech Recognition Feature for Eu spec |
| 578 | #endif |
| 579 | |
| 580 | typedef struct spcEMIParInfoStruct |
| 581 | { |
| 582 | uint32 EMI_Offset; |
| 583 | uint32 EMI_Len; |
| 584 | uint32 Common_Offset; |
| 585 | uint32 Dbg_Info_Offset; |
| 586 | |
| 587 | } spcEMIParInfo; |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | #if defined(_SPE_ENH_MD_PARSE_) |
| 598 | typedef struct spcDynParHeaderStruct |
| 599 | { |
| 600 | uint16 SphParserVer; |
| 601 | uint16 NumLayer; |
| 602 | uint16 NumEachLayer; |
| 603 | uint16 Param_Header_Layer1; |
| 604 | uint16 Param_Header_Layer2; |
| 605 | uint16 Param_Header_Layer3; |
| 606 | uint16 Param_Header_Layer4; |
| 607 | uint16 SphUnitMagiNum; |
| 608 | } spcDynParHeader; |
| 609 | |
| 610 | |
| 611 | typedef struct spcDynParNBDataStruct |
| 612 | { |
| 613 | unsigned short speech_Mode_para[NUM_MODE_PARAS]; |
| 614 | short speech_NB_FIR_IN_para[NUM_FIR_COEFFS]; |
| 615 | short speech_NB_FIR_OUT_para[NUM_FIR_COEFFS]; |
| 616 | } spcDynParNBData; |
| 617 | |
| 618 | |
| 619 | typedef struct spcDynParNBDataStruct_V10 // need remover later |
| 620 | { |
| 621 | unsigned short speech_Mode_para[NUM_MODE_PARAS]; |
| 622 | short speech_NB_FIR_IN_para[45]; |
| 623 | short speech_NB_FIR_OUT_para[45]; |
| 624 | } spcDynParNBData_V10; |
| 625 | |
| 626 | |
| 627 | |
| 628 | typedef struct spcDynParNBIIRDataStruct |
| 629 | { |
| 630 | short speech_NB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS]; |
| 631 | short speech_NB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS]; |
| 632 | short speech_NB_IIR_IN_para[NUM_IIR_COEFFS]; |
| 633 | short speech_NB_IIR_OUT_para[NUM_IIR_COEFFS]; |
| 634 | } spcDynParNBIIRData; |
| 635 | typedef struct spcDynParWBDataStruct |
| 636 | { |
| 637 | |
| 638 | unsigned short speech_Mode_para[NUM_MODE_PARAS]; |
| 639 | short speech_WB_FIR_IN_para[NUM_WB_FIR_COEFFS]; |
| 640 | short speech_WB_FIR_OUT_para[NUM_WB_FIR_COEFFS]; |
| 641 | } spcDynParWBData; |
| 642 | typedef struct spcDynParWBIIRDataStruct |
| 643 | { |
| 644 | short speech_WB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS]; |
| 645 | short speech_WB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS]; |
| 646 | short speech_WB_IIR_IN_para[NUM_IIR_COEFFS]; |
| 647 | short speech_WB_IIR_OUT_para[NUM_IIR_COEFFS]; |
| 648 | |
| 649 | } spcDynParWBIIRData; |
| 650 | typedef struct spcDynParSWBDataStruct |
| 651 | { |
| 652 | |
| 653 | unsigned short speech_Mode_para[NUM_MODE_PARAS]; |
| 654 | short speech_SWB_FIR_IN_para[NUM_SWB_FIR_COEFFS]; |
| 655 | short speech_SWB_FIR_OUT_para[NUM_SWB_FIR_COEFFS]; |
| 656 | } spcDynParSWBData; |
| 657 | typedef struct spcDynParSWBIIRDataStruct |
| 658 | { |
| 659 | short speech_SWB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS]; |
| 660 | short speech_SWB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS]; |
| 661 | short speech_SWB_IIR_IN_para[NUM_IIR_COEFFS]; |
| 662 | short speech_SWB_IIR_OUT_para[NUM_IIR_COEFFS]; |
| 663 | } spcDynParSWBIIRData; |
| 664 | typedef struct spcMagiClarityDataStruct |
| 665 | { |
| 666 | short MagiClarity_Para[32]; |
| 667 | } spcMagiClarityData; |
| 668 | |
| 669 | typedef struct spcCommonDataStruct |
| 670 | { |
| 671 | |
| 672 | unsigned short Common_Para[NUM_COMMON_PARAS]; |
| 673 | unsigned short Debug_info_para[NUM_DEBUG_INFO]; |
| 674 | |
| 675 | } spcCommonData; |
| 676 | #endif |
| 677 | |
| 678 | typedef struct spcDynParEchoRefForUsbAudioStruct |
| 679 | { |
| 680 | |
| 681 | bool isEchoRefForUsbAudioOn; |
| 682 | short chip_delay_with_switch; |
| 683 | short mic_index; // bit wise definition ordered from main mic to reference mic. Only one bit is set!! bit 0: o17, bit 1: o18, bit 2: o23, bit 3: o24, bit 4: o25, |
| 684 | |
| 685 | } spcDynParEchoRefForUsbAudio_T; |
| 686 | |
| 687 | #if defined(_SPE_ENH_MD_PARSE_) |
| 688 | short DMNR_NB_REC[NUM_DMNR_PARAM]; |
| 689 | short DMNR_NB_LoudSpk[NUM_DMNR_PARAM]; |
| 690 | short DMNR_WB_REC[NUM_WB_DMNR_PARAM]; |
| 691 | short DMNR_WB_LoudSpk[NUM_WB_DMNR_PARAM]; |
| 692 | short DMNR_SWB_REC[NUM_SWB_DMNR_PARAM]; |
| 693 | short DMNR_SWB_LoudSpk[NUM_SWB_DMNR_PARAM]; |
| 694 | //DMNR header |
| 695 | #define Header_DMNR_NB_REC 0x0011 |
| 696 | #define Header_DMNR_NB_LSP 0x0012 |
| 697 | #define Header_DMNR_WB_REC 0x0021 |
| 698 | #define Header_DMNR_WB_LSP 0x0022 |
| 699 | #define Header_DMNR_SWB_REC 0x0031 |
| 700 | #define Header_DMNR_SWB_LSP 0x0032 |
| 701 | |
| 702 | |
| 703 | //define data header - voice band |
| 704 | #define NB_Par 0x10 |
| 705 | #define WB_Par 0x20 |
| 706 | #define SWB_Par 0x30 |
| 707 | //define param header- voice band |
| 708 | #define VoiceBand_NB (1 << 1) |
| 709 | #define VoiceBand_WB (1 << 2) |
| 710 | #define VoiceBand_SWB 0x04 |
| 711 | #define VoiceBand_FB 0x08 |
| 712 | |
| 713 | |
| 714 | |
| 715 | //define data header -network |
| 716 | |
| 717 | #define GSM_NETWORK 0x01 |
| 718 | #define WCDMA_NETWORK 0x02 |
| 719 | #define CDMA_NETWORK 0x03 |
| 720 | #define VOLTE_NETWORK 0x04 |
| 721 | #define C2K_NETWORK 0x05 |
| 722 | #define DONT_CARE_NETWORK 0x0F |
| 723 | |
| 724 | |
| 725 | unsigned short Temp_speech_NB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 726 | short Temp_speech_NB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 727 | short Temp_speech_NB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 728 | short Temp_speech_NB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 729 | short Temp_speech_NB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 730 | short Temp_speech_NB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 731 | short Temp_speech_NB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 732 | |
| 733 | unsigned short Temp_speech_WB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 734 | short Temp_speech_WB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 735 | short Temp_speech_WB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 736 | short Temp_speech_WB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 737 | short Temp_speech_WB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 738 | short Temp_speech_WB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 739 | short Temp_speech_WB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 740 | |
| 741 | unsigned short Temp_speech_SWB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 742 | short Temp_speech_SWB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 743 | short Temp_speech_SWB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 744 | short Temp_speech_SWB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 745 | short Temp_speech_SWB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 746 | short Temp_speech_SWB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 747 | short Temp_speech_SWB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 748 | #endif |
| 749 | extern const unsigned short Speech_Common_Para[12] ; |
| 750 | extern const unsigned short Debug_Info_Para[16] ; |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | // ---------------------------------------------------------------------------- |
| 758 | // Global Variable |
| 759 | // ---------------------------------------------------------------------------- |
| 760 | |
| 761 | static _SPC_T gSpc; |
| 762 | |
| 763 | __attribute__((aligned (4)))static kal_uint8 emDataBuf[4096]; |
| 764 | |
| 765 | |
| 766 | static uint16 gSpc_networkStatus = 0xFF; |
| 767 | |
| 768 | // ---------------------------------------------------------------------------- |
| 769 | // Macro function |
| 770 | // ---------------------------------------------------------------------------- |
| 771 | |
| 772 | #define IS_SPC_APP_USED(app) ((gSpc.spcAppUsage & (1 << (app))) != 0) |
| 773 | #define SET_SPC_APP_USAGE(app) (gSpc.spcAppUsage |= (1 << (app))) |
| 774 | #define CLR_SPC_APP_USAGE(app) (gSpc.spcAppUsage &= (~(1 << (app)))) |
| 775 | |
| 776 | |
| 777 | #define IS_SPC_EM_INIT(emPara) ((gSpc.spcEmInit& (1 << (emPara))) != 0) |
| 778 | #define SET_SPC_EM_INIT(emPara) (gSpc.spcEmInit |= (1 << (emPara))) |
| 779 | |
| 780 | #define IS_SPC_RAMP_WAIT_ACK(point) ((gSpc.spcRampAck & (1 << (point))) != 0) |
| 781 | #define SET_SPC_RAMP_WAIT_ACK(point) (gSpc.spcRampAck |= (1 << (point))) |
| 782 | #define CLR_SPC_RAMP_WAIT_ACK(point) (gSpc.spcRampAck &= (~(1 << (point)))) |
| 783 | |
| 784 | #define SPC_CODEC_INFO_STRCAT(dest, src) strncat((dest), (src), strlen((src)) < SPC_PROP_CODEC_LEN-strlen((dest)) ? strlen((src)) : SPC_PROP_CODEC_LEN-strlen((dest))) |
| 785 | |
| 786 | /* |
| 787 | #if ((defined(MT6280) || defined(MT6290)) && (defined(__SMART_PHONE_MODEM__))) || defined(SPH_CHIP_BACK_PHONECALL_USE) |
| 788 | // for super dongle project on data card chip, MD reset scenario is useless |
| 789 | // So the protection is unnecessary and un-sync with AP side, so the request is always done |
| 790 | #define IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE (true) |
| 791 | #else |
| 792 | #define IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE (IS_SPC_EM_INIT(SPC_EM_INIT_COMMON)) // using comm parameter data notify as EM data request ack |
| 793 | #endif |
| 794 | */ |
| 795 | |
| 796 | // ---------------------------------------------------------------------------- |
| 797 | // Internal Init Related |
| 798 | // ---------------------------------------------------------------------------- |
| 799 | #if defined(_SPE_ENH_MD_PARSE_) |
| 800 | // following constant inside ./custom/driver/common/aud_common.c |
| 801 | extern const unsigned short Speech_Normal_Mode_Para[16]; |
| 802 | extern const unsigned short Speech_Earphone_Mode_Para[16]; |
| 803 | extern const unsigned short Speech_LoudSpk_Mode_Para[16]; |
| 804 | extern const unsigned short Speech_BT_Earphone_Mode_Para[16]; |
| 805 | extern const unsigned short Speech_BT_Cordless_Mode_Para[16]; |
| 806 | extern const unsigned short Speech_CARKIT_Mode_Para[16]; |
| 807 | extern const unsigned short Speech_AUX1_Mode_Para[16]; |
| 808 | extern const unsigned short Speech_AUX2_Mode_Para[16]; |
| 809 | extern const unsigned short WB_Speech_Normal_Mode_Para[16]; |
| 810 | extern const unsigned short WB_Speech_Earphone_Mode_Para[16]; |
| 811 | extern const unsigned short WB_Speech_LoudSpk_Mode_Para[16]; |
| 812 | extern const unsigned short WB_Speech_BT_Earphone_Mode_Para[16]; |
| 813 | extern const unsigned short WB_Speech_BT_Cordless_Mode_Para[16]; |
| 814 | extern const unsigned short WB_Speech_CARKIT_Mode_Para[16]; |
| 815 | extern const unsigned short WB_Speech_AUX1_Mode_Para[16]; |
| 816 | extern const unsigned short WB_Speech_AUX2_Mode_Para[16]; |
| 817 | |
| 818 | |
| 819 | extern const signed short WB_DMNR_Para[76]; |
| 820 | extern const signed short LSpk_WB_DMNR_Para[76]; |
| 821 | extern const signed short DMNR_Para[44]; |
| 822 | extern const signed short LSpk_DMNR_Para[44]; |
| 823 | |
| 824 | |
| 825 | |
| 826 | /** |
| 827 | |
| 828 | */ |
| 829 | extern const signed short Speech_All_Pass_IIR_Coeff[42] ; |
| 830 | extern const signed short Sph_Mic1_IIR_In[20] ; |
| 831 | extern const signed short Sph_Mic2_IIR_In[20] ; |
| 832 | unsigned short default_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 833 | signed short default_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 834 | signed short default_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS]; |
| 835 | signed short default_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 836 | signed short default_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 837 | signed short default_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 838 | signed short default_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 839 | unsigned short default_WB_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 840 | signed short default_WB_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 841 | signed short default_WB_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS]; |
| 842 | signed short default_WB_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 843 | signed short default_WB_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 844 | signed short default_WB_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 845 | signed short default_WB_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 846 | unsigned short default_SWB_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS]; |
| 847 | signed short default_SWB_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 848 | signed short default_SWB_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS]; |
| 849 | signed short default_SWB_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 850 | signed short default_SWB_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS]; |
| 851 | signed short default_SWB_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS]; |
| 852 | signed short default_SWB_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS]; |
| 853 | #endif |
| 854 | |
| 855 | |
| 856 | |
| 857 | #if defined(_SPE_ENH_MD_PARSE_) |
| 858 | |
| 859 | void spc_EmInit(kal_bool isNeedBasic, kal_bool isNeedNb,kal_bool isNeedWb,kal_bool isNeedSWb, kal_bool isNeedDmnr, kal_bool isNeedLspkDmnr,kal_bool isNeedIIR) |
| 860 | { |
| 861 | MD_TRC_SPC_EM_DEFAULT_INIT(isNeedBasic, isNeedNb,isNeedWb, isNeedSWb,isNeedDmnr, isNeedLspkDmnr,isNeedIIR); |
| 862 | |
| 863 | // ====== parameters from EM ======= |
| 864 | if(isNeedBasic){ |
| 865 | // common parameter |
| 866 | uint16 commonP[] = DEFAULT_SPEECH_COMMON_PARA; |
| 867 | L1SP_LoadCommonSpeechPara(commonP); |
| 868 | |
| 869 | } |
| 870 | if(isNeedNb){ |
| 871 | |
| 872 | // mode parameter , default use normal mode,GSM,NB |
| 873 | uint8 count; |
| 874 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 875 | { |
| 876 | memcpy(default_speech_mode_para[count], Speech_Normal_Mode_Para, 16*sizeof(uint16)) ; |
| 877 | } |
| 878 | l1sp_setAllSpeechModePara((kal_uint16 *)default_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 879 | // SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[0], NULL, NULL); // l1sp.sph_v_para no one use it. |
| 880 | |
| 881 | |
| 882 | // FIR , default use normal mode,GSM,NB |
| 883 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 884 | { |
| 885 | memcpy(default_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_FIR_COEFFS*sizeof(int16)) ; |
| 886 | } |
| 887 | l1sp_setAllSpeechFirCoeff_InputOnly((int16 *)default_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS); |
| 888 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 889 | { |
| 890 | memcpy(default_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_FIR_COEFFS*sizeof(int16)) ; |
| 891 | } |
| 892 | l1sp_setAllSpeechFirCoeff_OutputOnly((int16 *)default_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS); |
| 893 | //AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[0], gSpe.sph_OutFirCoeff[0] ); |
| 894 | |
| 895 | } |
| 896 | if(isNeedWb){ |
| 897 | // WB FIR |
| 898 | |
| 899 | // in customer folder's Audcoeff.c |
| 900 | uint8 count; |
| 901 | |
| 902 | |
| 903 | // WB mode parameter , default use normal mode,GSM,NB |
| 904 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 905 | { |
| 906 | memcpy(default_WB_speech_mode_para[count], WB_Speech_Normal_Mode_Para, 16*sizeof(uint16)) ; |
| 907 | } |
| 908 | l1sp_setAllWbSpeechModePara((kal_uint16* )default_WB_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 909 | //SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[0] ); |
| 910 | |
| 911 | |
| 912 | extern const signed short WB_Speech_Input_FIR_Coeff[6][90]; |
| 913 | extern const signed short WB_Speech_Output_FIR_Coeff[6][90]; |
| 914 | |
| 915 | |
| 916 | |
| 917 | // WB FIR , default use normal mode,GSM,NB |
| 918 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 919 | { |
| 920 | memcpy(default_WB_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_WB_FIR_COEFFS*sizeof(int16)) ; |
| 921 | } |
| 922 | |
| 923 | l1sp_setAllWbSpeechFirCoeff_InputOnly((kal_int16 *)default_WB_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS); |
| 924 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 925 | { |
| 926 | memcpy(default_WB_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_WB_FIR_COEFFS*sizeof(int16)) ; |
| 927 | } |
| 928 | l1sp_setAllWbSpeechFirCoeff_OutputOnly((int16 *)default_WB_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS); |
| 929 | //AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]); |
| 930 | } |
| 931 | if(isNeedSWb){ |
| 932 | // SWB FIR |
| 933 | // SWB mode parameter , default use normal mode,GSM,NB |
| 934 | uint8 count; |
| 935 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 936 | { |
| 937 | memcpy(default_SWB_speech_mode_para[count], WB_Speech_Normal_Mode_Para, 16*sizeof(uint16)) ; |
| 938 | } |
| 939 | l1sp_setAllSWbSpeechModePara((kal_uint16* )default_SWB_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 940 | //SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[0] ); |
| 941 | |
| 942 | |
| 943 | extern const signed short WB_Speech_Input_FIR_Coeff[6][90]; |
| 944 | extern const signed short WB_Speech_Output_FIR_Coeff[6][90]; |
| 945 | |
| 946 | |
| 947 | |
| 948 | // WB FIR , default use normal mode,GSM,NB |
| 949 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 950 | { |
| 951 | memcpy(default_SWB_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_SWB_FIR_COEFFS*sizeof(int16)) ; |
| 952 | } |
| 953 | l1sp_setAllSWbSpeechFirCoeff_InputOnly((kal_int16 *)default_SWB_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS); |
| 954 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 955 | { |
| 956 | memcpy(default_SWB_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_SWB_FIR_COEFFS*sizeof(int16)) ; |
| 957 | } |
| 958 | l1sp_setAllSWbSpeechFirCoeff_OutputOnly((int16 *)default_SWB_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS); |
| 959 | //AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]); |
| 960 | |
| 961 | |
| 962 | } |
| 963 | if(isNeedIIR){ |
| 964 | //IIR |
| 965 | uint8 count; |
| 966 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 967 | { |
| 968 | memcpy(default_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 969 | } |
| 970 | l1sp_setAllSpeechIirCoeff_InputOnly((int16 *)default_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 971 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 972 | { |
| 973 | memcpy(default_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 974 | } |
| 975 | l1sp_setAllSpeechIirCoeff_OutputOnly((int16 *)default_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 976 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 977 | { |
| 978 | memcpy(default_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ; |
| 979 | } |
| 980 | l1sp_setAllSpeechMic1IirCoeff((int16 *)default_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS); |
| 981 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 982 | { |
| 983 | memcpy(default_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ; |
| 984 | } |
| 985 | l1sp_setAllSpeechMic2IirCoeff((int16 *)default_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS); |
| 986 | |
| 987 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 988 | { |
| 989 | memcpy(default_WB_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 990 | } |
| 991 | l1sp_setAllWBSpeechIirCoeff_InputOnly((int16 *)default_WB_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 992 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 993 | { |
| 994 | memcpy(default_WB_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 995 | } |
| 996 | l1sp_setAllWBSpeechIirCoeff_OutputOnly((int16 *)default_WB_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 997 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 998 | { |
| 999 | memcpy(default_WB_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ; |
| 1000 | } |
| 1001 | l1sp_setAllWBSpeechMic1IirCoeff((int16 *)default_WB_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS); |
| 1002 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 1003 | { |
| 1004 | memcpy(default_WB_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ; |
| 1005 | } |
| 1006 | l1sp_setAllWBSpeechMic2IirCoeff((int16 *)default_WB_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS); |
| 1007 | |
| 1008 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 1009 | { |
| 1010 | memcpy(default_SWB_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 1011 | } |
| 1012 | l1sp_setAllSWBSpeechIirCoeff_InputOnly((int16 *)default_SWB_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 1013 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 1014 | { |
| 1015 | memcpy(default_SWB_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ; |
| 1016 | } |
| 1017 | l1sp_setAllSWBSpeechIirCoeff_OutputOnly((int16 *)default_SWB_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS); |
| 1018 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 1019 | { |
| 1020 | memcpy(default_SWB_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ; |
| 1021 | } |
| 1022 | l1sp_setAllSWBSpeechMic1IirCoeff((int16 *)default_SWB_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS); |
| 1023 | for(count=0; count<TOTAL_NETWORK_NUMBER; count++) |
| 1024 | { |
| 1025 | memcpy(default_SWB_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ; |
| 1026 | } |
| 1027 | l1sp_setAllSWBSpeechMic2IirCoeff((int16 *)default_SWB_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS); |
| 1028 | |
| 1029 | } |
| 1030 | |
| 1031 | if(isNeedDmnr){ |
| 1032 | L1SP_SetWbDMNRPara(WB_DMNR_Para); |
| 1033 | L1SP_SetDMNRPara(DMNR_Para); |
| 1034 | } |
| 1035 | |
| 1036 | if(isNeedLspkDmnr){ // load param when begin run |
| 1037 | L1SP_SetLSpkWbDMNRPara(LSpk_WB_DMNR_Para); |
| 1038 | L1SP_SetLSpkDMNRPara(LSpk_DMNR_Para); |
| 1039 | } |
| 1040 | |
| 1041 | // loading!! |
| 1042 | // if(isNeedBasic || isNeedWb) { |
| 1043 | // L1SP_LoadSpeechPara(); |
| 1044 | // } |
| 1045 | } |
| 1046 | |
| 1047 | #endif |
| 1048 | /** |
| 1049 | @app: app to be enable |
| 1050 | @return: check result, true for pass, false for fail |
| 1051 | */ |
| 1052 | bool spc_mainAppOnCheck(MSG_SPC_APP_T app) |
| 1053 | { |
| 1054 | // other related check |
| 1055 | if(SPC_APP_SPEECH_USAGE != app && SPC_APP_MERGE_SPH_USAGE != app) { |
| 1056 | if(IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) { |
| 1057 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, gSpc.spcAppUsage); |
| 1058 | |
| 1059 | ASSERT(0); |
| 1060 | |
| 1061 | return false; |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | if(SPC_APP_ACLOOPBACK_USAGE != app) { |
| 1066 | if(IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE)) { |
| 1067 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_ACLOOPBACK_USAGE, SPC_APP_ACLOOPBACK_USAGE, gSpc.spcAppUsage); |
| 1068 | |
| 1069 | ASSERT(0); |
| 1070 | |
| 1071 | return false; |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | |
| 1076 | |
| 1077 | if(SPC_APP_HOLD_USAGE != app) { |
| 1078 | if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)) { |
| 1079 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, gSpc.spcAppUsage); |
| 1080 | |
| 1081 | ASSERT(0); |
| 1082 | |
| 1083 | return false; |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | if(SPC_APP_HOSTED_USAGE != app) { |
| 1088 | if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) { |
| 1089 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, gSpc.spcAppUsage); |
| 1090 | |
| 1091 | ASSERT(0); |
| 1092 | |
| 1093 | return false; |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | if(SPC_APP_PCMROUTER_USAGE != app) { |
| 1098 | if(IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) { |
| 1099 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_PCMROUTER_USAGE, SPC_APP_PCMROUTER_USAGE, gSpc.spcAppUsage); |
| 1100 | |
| 1101 | ASSERT(0); |
| 1102 | |
| 1103 | return false; |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | if(SPC_APP_MERGE_SPH_USAGE != app && SPC_APP_SPEECH_USAGE != app) { |
| 1108 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) { |
| 1109 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, gSpc.spcAppUsage); |
| 1110 | |
| 1111 | ASSERT(0); |
| 1112 | |
| 1113 | return false; |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | return true; |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | // ---------------------------------------------------------------------------- |
| 1122 | // Codec Related |
| 1123 | // ---------------------------------------------------------------------------- |
| 1124 | /* |
| 1125 | #define CODEC_INFO_PROP_CODEC "codec=" |
| 1126 | #define CODEC_INFO_PROP_ISHDV "isHdV=" |
| 1127 | #define CODEC_INFO_PROP_HDVOP "HDVOp=" |
| 1128 | #define CODEC_INFO_PROP_SR "sr=" |
| 1129 | #define CODEC_INFO_PROP_BR "br=" |
| 1130 | #define CODEC_INFO_PROP_FS "fs=" |
| 1131 | #define CODEC_INFO_PROP_RR "rr=" |
| 1132 | #define CODEC_INFO_PROP_SEPERATER ";" |
| 1133 | |
| 1134 | |
| 1135 | #define CODEC_INFO_PROP_CODEC_VALUE_FR "FR" |
| 1136 | #define CODEC_INFO_PROP_CODEC_VALUE_HR "HR" |
| 1137 | #define CODEC_INFO_PROP_CODEC_VALUE_EFR "EFR" |
| 1138 | #define CODEC_INFO_PROP_CODEC_VALUE_AMR "AMR" |
| 1139 | #define CODEC_INFO_PROP_CODEC_VALUE_AWB "AWB" |
| 1140 | |
| 1141 | #define CODEC_INFO_PROP_ISHDV_VALUE_Y "Y" |
| 1142 | #define CODEC_INFO_PROP_ISHDV_VALUE_N "N" |
| 1143 | */ |
| 1144 | |
| 1145 | #define SPC_PROP_CODEC_LEN 92 |
| 1146 | |
| 1147 | typedef struct { |
| 1148 | char codecInfo[SPC_PROP_CODEC_LEN]; |
| 1149 | char codecOp[SPC_PROP_CODEC_LEN]; |
| 1150 | } SPC_CODEC_INFO_STRUCT; |
| 1151 | |
| 1152 | static struct { |
| 1153 | uint32 curSpeechMode; |
| 1154 | uint16 curRateInSoCodec; |
| 1155 | SPC_CODEC_INFO_STRUCT info; |
| 1156 | } gSpc_codec_info; |
| 1157 | |
| 1158 | void spc_codecInfoInit(void) |
| 1159 | { |
| 1160 | gSpc_codec_info.curSpeechMode = 0xffffffff; |
| 1161 | gSpc_codec_info.curRateInSoCodec = 0xffff; |
| 1162 | memset(&(gSpc_codec_info.info), '\0', sizeof(SPC_CODEC_INFO_STRUCT)); |
| 1163 | } |
| 1164 | |
| 1165 | void spc_sendCodecInfoNotify(void) |
| 1166 | { |
| 1167 | spcBufInfo info; |
| 1168 | |
| 1169 | info.syncWord = 0x1234; |
| 1170 | info.type = AUD_CCCI_STRMBUF_TYPE_NW_CODEC_INFO; |
| 1171 | info.length = sizeof(SPC_CODEC_INFO_STRUCT); // currently, fix the buffer size in WB |
| 1172 | |
| 1173 | SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 1174 | &(gSpc_codec_info.info), sizeof(SPC_CODEC_INFO_STRUCT), NULL, 0, |
| 1175 | SPCIO_MSG_FROM_SPC_NW_CODEC_INFO_NOTIFY); |
| 1176 | MD_TRC_SPC_CODEC_NOTIFY_TO_AP(gSpc_codec_info.info.codecInfo, gSpc_codec_info.info.codecOp); |
| 1177 | } |
| 1178 | |
| 1179 | void spc_codecInfoNotify(uint32 codec) |
| 1180 | { |
| 1181 | |
| 1182 | MD_TRC_SPC_CODEC_NOTIFY_IN(gSpc_codec_info.curSpeechMode, codec); |
| 1183 | |
| 1184 | if(false == IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)){ |
| 1185 | // just leave log and return |
| 1186 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, 1); |
| 1187 | return; |
| 1188 | } |
| 1189 | |
| 1190 | // if codec&rate did not change, just return |
| 1191 | if(codec== gSpc_codec_info.curSpeechMode) { |
| 1192 | return; |
| 1193 | } |
| 1194 | |
| 1195 | // prepare codec sending |
| 1196 | memset(&(gSpc_codec_info.info), 0, sizeof(SPC_CODEC_INFO_STRUCT)); |
| 1197 | |
| 1198 | if(0 == codec) { // FR, |
| 1199 | |
| 1200 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=FR;sr=8k;"); |
| 1201 | |
| 1202 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1203 | } else if (1 == codec) { |
| 1204 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=HR;sr=8k;"); |
| 1205 | |
| 1206 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1207 | } else if (2 == codec) { |
| 1208 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EFR;sr=8k;"); |
| 1209 | |
| 1210 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1211 | } else if ((codec >= 0x20 && codec<=0x28) ||(codec >= 0xD0 && codec <= 0xDF)) { // AWB, EVS-AWB |
| 1212 | uint8 bitRate = (codec&0xF); |
| 1213 | if(codec >= 0x20 && codec<=0x28) { // AWB |
| 1214 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=AWB;sr=16k;"); |
| 1215 | } else { //EVS-AWB |
| 1216 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVSAWB;sr=16k;"); |
| 1217 | } |
| 1218 | |
| 1219 | // bit rate |
| 1220 | if ( 0x0 == bitRate) { // 6.60 |
| 1221 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=6.60;"); |
| 1222 | } else if ( 0x1 == bitRate) { // 8.85 |
| 1223 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=8.85;"); |
| 1224 | } else if ( 0x2 == bitRate) { // 12.65 |
| 1225 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=12.65;"); |
| 1226 | } else if ( 0x3 == bitRate) { // 14.25 |
| 1227 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=14.25;"); |
| 1228 | } else if ( 0x4 == bitRate) { // 15.85 |
| 1229 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=15.85;"); |
| 1230 | } else if ( 0x5 == bitRate) { // 18.25 |
| 1231 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=18.25;"); |
| 1232 | } else if ( 0x6 == bitRate) { // 19.85 |
| 1233 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=19.85;"); |
| 1234 | } else if ( 0x7 == bitRate) { // 23.05 |
| 1235 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=23.05;"); |
| 1236 | } else if ( 0x8 == bitRate) { // 23.85 |
| 1237 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=23.85;"); |
| 1238 | } else { // unkonw codec |
| 1239 | MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 1); |
| 1240 | } |
| 1241 | |
| 1242 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1243 | } else if(codec >=3 && codec <= 0xA) { // from 3~0x1f, AMR |
| 1244 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=AMR;sr=8k;"); |
| 1245 | |
| 1246 | // bit rate |
| 1247 | if (3 == codec) { // 12.2k |
| 1248 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=12.20;"); |
| 1249 | } else if (4 == codec) { // 10.2K |
| 1250 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=10.20;"); |
| 1251 | } else if (5 == codec) { // 7.95K |
| 1252 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.95;"); |
| 1253 | } else if (6 == codec) { // 7.4K |
| 1254 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.40;"); |
| 1255 | } else if (7 == codec) { // 6.7K |
| 1256 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=6.70;"); |
| 1257 | } else if (8 == codec) { // 5.9K |
| 1258 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=5.90;"); |
| 1259 | } else if (9 == codec) { // 5.15K |
| 1260 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=5.15;"); |
| 1261 | } else if (0xA == codec) { // 4.75K |
| 1262 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=4.75;"); |
| 1263 | } else { // unkonw codec |
| 1264 | MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 2); |
| 1265 | } |
| 1266 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1267 | }else if(codec >= 0x80 && codec <= 0xBF) { // EVS |
| 1268 | uint8 bitRate = (codec&0xF); |
| 1269 | |
| 1270 | if ( codec < 0x90 ) { |
| 1271 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=8k;"); |
| 1272 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1273 | } else if ( codec < 0xA0 ) { |
| 1274 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=16k;"); |
| 1275 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1276 | } else if ( codec < 0xB0 ) { |
| 1277 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=32k;"); |
| 1278 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1279 | } else { |
| 1280 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=48k;"); |
| 1281 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1282 | } |
| 1283 | |
| 1284 | // bit rate |
| 1285 | if ( 0x0 == bitRate) { // 2.80 |
| 1286 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=2.80;"); |
| 1287 | } else if ( 0x1 == bitRate) { // 7.20 |
| 1288 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.20;"); |
| 1289 | } else if ( 0x2 == bitRate) { // 8.00 |
| 1290 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=8.00;"); |
| 1291 | } else if ( 0x3 == bitRate) { // 9.60 |
| 1292 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=9.60"); |
| 1293 | } else if ( 0x4 == bitRate) { // 13.20 |
| 1294 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=13.20;"); |
| 1295 | } else if ( 0x5 == bitRate) { // 16.40 |
| 1296 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=16.40;"); |
| 1297 | } else if ( 0x6 == bitRate) { // 24.40 |
| 1298 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=24.40;"); |
| 1299 | } else if ( 0x7 == bitRate) { // 32.00 |
| 1300 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=32.00;"); |
| 1301 | } else if ( 0x8 == bitRate) { // 48.00 |
| 1302 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=48.00;"); |
| 1303 | } else if ( 0x9 == bitRate) { // 64.00 |
| 1304 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=64.00;"); |
| 1305 | } else if ( 0xA == bitRate) { // 96.00 |
| 1306 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=96.00;"); |
| 1307 | } else if ( 0xB == bitRate) { // 128.00 |
| 1308 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=128.00;"); |
| 1309 | } else { // unkonw codec |
| 1310 | MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 3); |
| 1311 | } |
| 1312 | |
| 1313 | } else if ( 0x60 == codec ) { // g711 |
| 1314 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G711;sr=8k;"); |
| 1315 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1316 | } else if ( 0x61 == codec ) { // 722 |
| 1317 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G722;sr=16k;"); |
| 1318 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1319 | } else if ( 0x62 == codec ) { // g732.1 |
| 1320 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G723_1;sr=8k;"); |
| 1321 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1322 | } else if ( 0x63 == codec ) { // g726 |
| 1323 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G726;sr=8k;"); |
| 1324 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1325 | } else if ( 0x64 == codec ) { // g729, |
| 1326 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G729;sr=8k;"); |
| 1327 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1328 | } else if (codec >= 0x30 && codec <= 0x35) { |
| 1329 | |
| 1330 | if( 0x30 == codec ) { // SAL_C2K_COD_QCELP8K |
| 1331 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S01;"); |
| 1332 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1333 | } else if ( 0x31 == codec ) { // SAL_C2K_COD_QCELP13K |
| 1334 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S017;"); |
| 1335 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1336 | } else if ( 0x32 == codec ) { // SAL_C2K_COD_EVRCA |
| 1337 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S03;"); |
| 1338 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1339 | } else if ( 0x33 == codec ) { // SAL_C2K_COD_EVRCB |
| 1340 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S068;"); |
| 1341 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1342 | } else if ( 0x34 == codec ) { // SAL_C2K_COD_EVRCNW_NB |
| 1343 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S073;"); |
| 1344 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;"); |
| 1345 | } else if ( 0x35 == codec ) { // SAL_C2K_COD_EVRCNW_WB |
| 1346 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S073;"); |
| 1347 | SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;"); |
| 1348 | } |
| 1349 | |
| 1350 | gSpc_codec_info.curRateInSoCodec = 0xffff; // reset only when SO codec change. |
| 1351 | |
| 1352 | } |
| 1353 | else { |
| 1354 | MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 4); |
| 1355 | } |
| 1356 | |
| 1357 | // send to AP |
| 1358 | spc_sendCodecInfoNotify(); |
| 1359 | |
| 1360 | // update codec |
| 1361 | gSpc_codec_info.curSpeechMode = codec; |
| 1362 | |
| 1363 | } |
| 1364 | |
| 1365 | void spc_codecInfoNotify_soRateUpdate(uint16 newRate) |
| 1366 | { |
| 1367 | if (gSpc_codec_info.curSpeechMode >= 0x30 && gSpc_codec_info.curSpeechMode <= 0x35) { |
| 1368 | |
| 1369 | // if codec&rate did not change, just return |
| 1370 | if(newRate == gSpc_codec_info.curRateInSoCodec) { |
| 1371 | return; |
| 1372 | } |
| 1373 | |
| 1374 | switch(newRate){ |
| 1375 | case 0: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=0;"); break; |
| 1376 | case 1: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=1;"); break; |
| 1377 | case 2: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=2;"); break; |
| 1378 | case 3: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=3;"); break; |
| 1379 | case 4: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=4;"); break; |
| 1380 | case 5: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=5;"); break; |
| 1381 | case 6: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=6;"); break; |
| 1382 | case 7: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=7;"); break; |
| 1383 | default: break; |
| 1384 | } |
| 1385 | |
| 1386 | gSpc_codec_info.curRateInSoCodec = newRate; |
| 1387 | |
| 1388 | // send to AP |
| 1389 | spc_sendCodecInfoNotify(); |
| 1390 | } else { |
| 1391 | MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(gSpc_codec_info.curSpeechMode, newRate, 5); |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | |
| 1396 | // ---------------------------------------------------------------------------- |
| 1397 | // Phone Call Related |
| 1398 | // ---------------------------------------------------------------------------- |
| 1399 | typedef enum { |
| 1400 | SPH_ON_APPLICATION_NORMAL = 0, |
| 1401 | SPH_ON_APPLICATION_VT_CALL, |
| 1402 | SPH_ON_APPLICATION_LOOPBACK, |
| 1403 | SPH_ON_APPLICATION_ROUTER, |
| 1404 | SPH_ON_APPLICATION_DACA, |
| 1405 | SPH_ON_APPLICATION_HOLD_CALL, |
| 1406 | SPH_ON_APPLICATION_ENCRYPTION, |
| 1407 | }spc_sph_on_application_t; |
| 1408 | |
| 1409 | typedef enum { |
| 1410 | SPH_ON_BTINFO_BT_OFF, |
| 1411 | SPH_ON_BTINFO_BT_PCM, /* via Modem PCM hardware */ |
| 1412 | SPH_ON_BTINFO_BT_CVSD_MSBC, /* via software BT codec */ |
| 1413 | SPH_ON_BTINFO_BT_CVSD, |
| 1414 | SPH_ON_BTINFO_BT_MSBC |
| 1415 | }spc_sph_on_bt_info_t; |
| 1416 | |
| 1417 | typedef enum { |
| 1418 | SPH_ON_SAMPLE_RATE_08K = 0, |
| 1419 | SPH_ON_SAMPLE_RATE_16K, |
| 1420 | SPH_ON_SAMPLE_RATE_32K, |
| 1421 | SPH_ON_SAMPLE_RATE_48K, |
| 1422 | SPH_ON_SAMPLE_RATE_MAX |
| 1423 | }spc_sph_on_sample_rate_t; |
| 1424 | |
| 1425 | typedef enum { |
| 1426 | SPH_ON_PARAM_VIA_PAYLOAD = 0, /* speech param is written in payload */ |
| 1427 | SPH_ON_PARAM_VIA_SHM /* speech param is written in share memory */ |
| 1428 | }spc_sph_on_param_path_t; |
| 1429 | |
| 1430 | typedef enum { |
| 1431 | SPH_ON_EXT_DEV_INFO_DEFULAT = 0, |
| 1432 | SPH_ON_EXT_DEV_INFO_VIBRATION_RECEIVER, // vibration receiver (3-in-1) |
| 1433 | SPH_ON_EXT_DEV_INFO_VIBRATION_SPEAKER, // speaker (2-in-1 or 3-in-1) |
| 1434 | SPH_ON_EXT_DEV_INFO_SMARTPA_SPEAKER, // speaker with smart-PA which need echo reference path |
| 1435 | SPH_ON_EXT_DEV_INFO_SMARTPA_VIBRATION_SPEAKER, // vibration speaker with smart-PA which need echo reference path |
| 1436 | SPH_ON_EXT_DEV_INFO_USB_AUDIO, // usb audio device, which needs echo reference path |
| 1437 | SPH_ON_EXT_DEV_INFO_EARPHONE, // earphone audio device |
| 1438 | }spc_sph_on_ext_dev_info_t; |
| 1439 | |
| 1440 | typedef enum { |
| 1441 | SPH_ON_LOOPBACK_INFO_FLAG_DISABLE_BT_CODEC = (1<<0), // 1'b == BT Loopback with BT codec / 0'b == BT Loopback without BT Codec, only support when SPH_ON_BTINFO_BT_CVSD_MSBC |
| 1442 | SPH_ON_LOOPBACK_INFO_FLAG_DELAY_SETTING = (1<<1), // delay setting for normal loopback, i.e. speech mode is not BT cases. 0==Use modem default delay value/ 1== use AP gives delay value in loopback_delay |
| 1443 | }spc_sph_on_loopback_info_flag; |
| 1444 | |
| 1445 | typedef struct { |
| 1446 | kal_uint8 loopback_flag; |
| 1447 | kal_uint8 loopback_delay; /* spc_sph_on_loopback_info_flag */ |
| 1448 | }spc_sph_on_loopback_info_t; |
| 1449 | |
| 1450 | typedef enum { |
| 1451 | SPH_ON_MUTE_BIT_UL = (1<<0), |
| 1452 | SPH_ON_MUTE_BIT_DL = (1<<1), |
| 1453 | SPH_ON_MUTE_BIT_UL_ENH_RESULT = (1<<2), |
| 1454 | SPH_ON_MUTE_BIT_UL_SOURCE = (1<<3), |
| 1455 | SPH_ON_MUTE_BIT_DL_CODEC = (1<<4), |
| 1456 | SPH_ON_MUTE_BIT_DL_PRE_PCM_MIXER = (1<<5), |
| 1457 | }spc_sph_on_mute_bit; |
| 1458 | |
| 1459 | typedef struct { |
| 1460 | kal_uint8 application; /* spc_sph_on_application_t */ |
| 1461 | kal_uint8 bt_info; /* spc_sph_on_bt_info_t */ |
| 1462 | kal_uint8 sample_rate_enum; /* spc_sph_on_sample_rate_t */ |
| 1463 | kal_uint8 opendsp_flag; /* 0: internal SPE, 1: OpenDSP */ |
| 1464 | |
| 1465 | kal_uint8 param_path; /* spc_sph_on_param_path_t */ |
| 1466 | kal_uint8 param_shm_valid; /* SPH_ON_PARAM_VIA_SHM only. 0: invalid, 1: valid */ |
| 1467 | kal_uint16 param_size; /* Max 65535 bytes */ |
| 1468 | |
| 1469 | kal_uint16 param_idx; |
| 1470 | kal_uint16 ext_dev_info; /* spc_sph_on_ext_dev_info_t */ |
| 1471 | |
| 1472 | kal_uint8 loopback_flag; |
| 1473 | kal_uint8 loopback_delay; /* spc_sph_on_loopback_info_flag */ |
| 1474 | kal_uint16 echo_ref_delay_ms; /* echo reference data delay, unit is ms */ |
| 1475 | |
| 1476 | kal_uint8 mic_delay_ms; /* UL0 data delay, unit is ms */ |
| 1477 | kal_uint8 mute_mask; /* bit-wise define in spc_sph_on_mute_bit. 0: unmute, 1: mute */ |
| 1478 | kal_uint16 enh_crtl_support; |
| 1479 | |
| 1480 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1481 | kal_uint8 reserve_at_32byte[12]; |
| 1482 | kal_uint8 reserve_at_48byte[16]; |
| 1483 | kal_uint8 reserve_at_64byte[16]; |
| 1484 | #else |
| 1485 | |
| 1486 | kal_uint32 param_usip_len; // 95MD support EMI par. |
| 1487 | |
| 1488 | kal_uint32 param_usip_index; // 95MD support EMI par. |
| 1489 | kal_uint16 common_param[12]; /* param for driver/scheduler */ |
| 1490 | kal_uint16 debug_info[16]; /* param for driver/scheduler */ |
| 1491 | |
| 1492 | kal_uint8 smartPA_config; |
| 1493 | |
| 1494 | #if defined(MT6890) |
| 1495 | kal_uint8 dtmf_rm_support; /* 0: Disable DTMF removal, 1: Enable DTMF removal */ |
| 1496 | kal_uint8 reserve_at_128byte[42]; |
| 1497 | #else |
| 1498 | kal_uint8 reserve_at_128byte[43]; |
| 1499 | #endif |
| 1500 | |
| 1501 | |
| 1502 | #endif |
| 1503 | |
| 1504 | |
| 1505 | |
| 1506 | } spc_sph_on_info_t; /* 64 bytes */ |
| 1507 | |
| 1508 | static spc_sph_on_info_t gSpc_sphOnInfo; |
| 1509 | |
| 1510 | #define SPC_CUST_ENH 0 |
| 1511 | #if SPC_CUST_ENH |
| 1512 | #define PROCESS_BLK_SIZE 320 |
| 1513 | static uint16 gSpc_DV_PCM_UL1_BUF[PROCESS_BLK_SIZE]; |
| 1514 | static uint16 gSpc_DV_PCM_UL2_BUF[PROCESS_BLK_SIZE]; |
| 1515 | static uint16 gSpc_DV_PCM_IN_BUF[PROCESS_BLK_SIZE]; |
| 1516 | static uint16 gSpc_DV_PCM_DL_BUF[PROCESS_BLK_SIZE]; |
| 1517 | static uint16 gSpc_DV_PCM_OUT_BUF[PROCESS_BLK_SIZE]; |
| 1518 | static uint16 DV_dl_audioid; |
| 1519 | static uint16 DV_ul_audioid; |
| 1520 | |
| 1521 | void DV_init(void) |
| 1522 | { |
| 1523 | // Do DV initialize |
| 1524 | return; |
| 1525 | } |
| 1526 | |
| 1527 | void DV_Release(void) |
| 1528 | { |
| 1529 | // Do DV destroy |
| 1530 | } |
| 1531 | |
| 1532 | void DV_UL_process() |
| 1533 | { |
| 1534 | // do speech enahncment for uplink |
| 1535 | // gSpc_DV_PCM_IN_BUF = ulProcess(gSpc_DV_PCM_UL1_BUF, gSpc_DV_PCM_UL2_BUF); |
| 1536 | } |
| 1537 | |
| 1538 | void DV_DL_process() |
| 1539 | { |
| 1540 | // do speech enahncment for downlink |
| 1541 | // gSpc_DV_PCM_OUT_BUF = dlProcess(gSpc_DV_PCM_DL_BUF); |
| 1542 | memcpy(gSpc_DV_PCM_OUT_BUF, gSpc_DV_PCM_DL_BUF, 640); |
| 1543 | |
| 1544 | spc_customDump(320, gSpc_DV_PCM_OUT_BUF); |
| 1545 | } |
| 1546 | |
| 1547 | void DV_PCM4WAY_DL_HisrHdl() |
| 1548 | { |
| 1549 | |
| 1550 | PCM4WAY_GetFromSD(gSpc_DV_PCM_DL_BUF); |
| 1551 | |
| 1552 | PCM4WAY_PutToSpk(gSpc_DV_PCM_OUT_BUF); |
| 1553 | |
| 1554 | L1Audio_SetEvent(DV_dl_audioid, NULL); |
| 1555 | |
| 1556 | } |
| 1557 | |
| 1558 | void DV_PCM4WAY_UL_HisrHdl() |
| 1559 | { |
| 1560 | |
| 1561 | |
| 1562 | PcmEx_GetFromMic1(gSpc_DV_PCM_UL1_BUF); |
| 1563 | PcmEx_GetFromMic2(gSpc_DV_PCM_UL2_BUF); |
| 1564 | |
| 1565 | |
| 1566 | |
| 1567 | PCM4WAY_PutToSE(gSpc_DV_PCM_IN_BUF); |
| 1568 | |
| 1569 | L1Audio_SetEvent(DV_ul_audioid, NULL); |
| 1570 | } |
| 1571 | #endif // SPC_CUST_ENH |
| 1572 | |
| 1573 | void Spc_SpeechOn( kal_uint8 RAT_Mode ) |
| 1574 | { |
| 1575 | |
| 1576 | if(false == spc_mainAppOnCheck(SPC_APP_SPEECH_USAGE)) |
| 1577 | return; |
| 1578 | |
| 1579 | ASSERT(RAT_Mode <= RAT_3G324M_MODE); |
| 1580 | |
| 1581 | |
| 1582 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1583 | // checking speech useage parameter. if Not, use the default value. |
| 1584 | spc_EmInit(!IS_SPC_EM_INIT(SPC_EM_INIT_COMMON),!IS_SPC_EM_INIT(SPC_EM_INIT_NB), |
| 1585 | !IS_SPC_EM_INIT(SPC_EM_INIT_WB),!IS_SPC_EM_INIT(SPC_EM_INIT_SWB), |
| 1586 | !IS_SPC_EM_INIT(SPC_EM_INIT_DMNR), |
| 1587 | !IS_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR), |
| 1588 | !IS_SPC_EM_INIT(SPC_EM_INIT_IIR)); |
| 1589 | #endif |
| 1590 | |
| 1591 | // rate setting |
| 1592 | #if defined(__UMTS_RAT__) |
| 1593 | if( RAT_Mode != RAT_3G324M_MODE ) |
| 1594 | RAT_Mode = RAT_3G_MODE; // Force initial 3G |
| 1595 | #else |
| 1596 | RAT_Mode = RAT_2G_MODE; |
| 1597 | #endif |
| 1598 | |
| 1599 | MD_TRC_SPC_SPEECH_ON(RAT_Mode); |
| 1600 | |
| 1601 | |
| 1602 | // reset codec before speechOn. |
| 1603 | spc_codecInfoInit(); |
| 1604 | gSpc_networkStatus = 0xFF; |
| 1605 | |
| 1606 | L1SP_Speech_On( RAT_Mode ); |
| 1607 | |
| 1608 | SET_SPC_APP_USAGE(SPC_APP_SPEECH_USAGE); |
| 1609 | |
| 1610 | |
| 1611 | #if SPC_CUST_ENH |
| 1612 | DV_init(); |
| 1613 | Del_PcmEx_Start(DV_PCM4WAY_DL_HisrHdl, NULL, //DV_PCM4WAY_UL_HisrHdl, |
| 1614 | NULL, //USE_D2M_PATH + USE_M2D_PATH, |
| 1615 | NULL, //USE_D2M_PATH + USE_M2D_PATH, |
| 1616 | NULL, //USE_D2M_PATH + USE_M2D_PATH, |
| 1617 | NULL, //USE_D2M_PATH + USE_M2D_PATH, |
| 1618 | USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH); |
| 1619 | #endif |
| 1620 | } |
| 1621 | |
| 1622 | kal_uint16 Spc_SpeechOn_withData(kal_uint16 offset, kal_uint16 length, const SPC_MSG_FROM_T comeFrom) |
| 1623 | { |
| 1624 | spcBufInfo header; |
| 1625 | spc_sph_on_info_t info; |
| 1626 | kal_uint16 totalProcLen = 0; |
| 1627 | kal_bool check; |
| 1628 | |
| 1629 | #if defined(_SPE_ENH_DSP_PARSE_) |
| 1630 | kal_uint32 EMI_Offset; |
| 1631 | //unsigned short Common_Para[NUM_COMMON_PARAS]; |
| 1632 | //unsigned short Dbg_Para[16]; |
| 1633 | #endif |
| 1634 | |
| 1635 | memset(&info, 0, sizeof(spc_sph_on_info_t)); |
| 1636 | if(length == (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) { |
| 1637 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1638 | } else if ((length < (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) && (length > sizeof(spcBufInfo))) { |
| 1639 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1640 | MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t)); |
| 1641 | } else if (length > (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) { |
| 1642 | SpcIO_GetDataFromAp_inOneTime(offset, (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t)), sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1643 | MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t)); |
| 1644 | }else { |
| 1645 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 2); |
| 1646 | return totalProcLen; |
| 1647 | } |
| 1648 | |
| 1649 | check = (header.syncWord == 0xA2A2); |
| 1650 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow syncWord"); |
| 1651 | if(!check) |
| 1652 | goto leaveSphOn; |
| 1653 | check = (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO); |
| 1654 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow type"); |
| 1655 | if(!check) |
| 1656 | goto leaveSphOn; |
| 1657 | check = (header.length == (length - sizeof(spcBufInfo))); |
| 1658 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow length"); |
| 1659 | if(!check) |
| 1660 | goto leaveSphOn; |
| 1661 | |
| 1662 | MD_TRC_SPC_SPEECH_ON_PAYLOAD( |
| 1663 | info.application, info.bt_info, info.sample_rate_enum, info.opendsp_flag, |
| 1664 | info.param_path, info.param_shm_valid, info.param_size, info.param_idx, info.ext_dev_info, |
| 1665 | info.mute_mask); |
| 1666 | |
| 1667 | if(false == spc_mainAppOnCheck(SPC_APP_MERGE_SPH_USAGE)) { |
| 1668 | return info.param_size; |
| 1669 | } |
| 1670 | |
| 1671 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) { |
| 1672 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 1); |
| 1673 | return info.param_size; |
| 1674 | } |
| 1675 | |
| 1676 | memcpy(&gSpc_sphOnInfo, &info, sizeof(spc_sph_on_info_t)); |
| 1677 | |
| 1678 | // set device |
| 1679 | SP_SetDevicePath(info.bt_info, info.sample_rate_enum); |
| 1680 | SP_SetExtraDevInfo(info.bt_info, info.ext_dev_info, info.smartPA_config, info.echo_ref_delay_ms, info.mic_delay_ms); |
| 1681 | // Set Enh |
| 1682 | L1SP_EnhancementCtrlSupport(info.enh_crtl_support); |
| 1683 | |
| 1684 | #if defined(MT6890) |
| 1685 | MD_TRC_SPC_SPEECH_ON_DTMF_SUPPORT(info.dtmf_rm_support); |
| 1686 | if (info.dtmf_rm_support == 0) { |
| 1687 | SAL_DTMF_Removal_Ctrl(SAL_DTMF_REMOVAL_UL_PRE_EN, false); |
| 1688 | } else { |
| 1689 | SAL_DTMF_Removal_Ctrl(SAL_DTMF_REMOVAL_UL_PRE_EN, true); |
| 1690 | } |
| 1691 | #endif |
| 1692 | |
| 1693 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1694 | if(SPH_ON_PARAM_VIA_SHM == info.param_path) { |
| 1695 | if(1 == info.param_shm_valid) { |
| 1696 | kal_uint16 procLen = 0; |
| 1697 | kal_uint16 curOffset = info.param_idx; |
| 1698 | |
| 1699 | while (totalProcLen < info.param_size ) { |
| 1700 | kal_uint16 newOffset; |
| 1701 | spc_dynamicParameterParser_dispatcher(curOffset, info.param_size-totalProcLen, |
| 1702 | SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset); |
| 1703 | |
| 1704 | totalProcLen += procLen; |
| 1705 | curOffset = newOffset; |
| 1706 | } |
| 1707 | } |
| 1708 | } else { |
| 1709 | // Via stream. Not implement yet |
| 1710 | kal_prompt_trace(MOD_L1SP, "SphO. param data from payload!!"); |
| 1711 | } |
| 1712 | |
| 1713 | #else // for _SPE_ENH_DSP_PARSE_ |
| 1714 | |
| 1715 | // mute position apply |
| 1716 | spc_gain_UlMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL)!=0, KAL_TRUE); |
| 1717 | spc_gain_DlMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_DL)!=0, KAL_TRUE); |
| 1718 | // spc_gain_UlEnhResultMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL_ENH_RESULT)!=0, KAL_TRUE); |
| 1719 | spc_gain_UlSourceMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL_SOURCE)!=0, KAL_TRUE); |
| 1720 | spc_gain_DlMuteCodecSet((info.mute_mask&SPH_ON_MUTE_BIT_DL_CODEC)!=0, KAL_TRUE); |
| 1721 | spc_gain_DlMuteSet_PrePcmMixer((info.mute_mask&SPH_ON_MUTE_BIT_DL_PRE_PCM_MIXER)!=0,KAL_TRUE); |
| 1722 | |
| 1723 | MD_TRC_SPC_SPE_CHECK_EMI_COMMON_PAR(info.common_param[0], info.common_param[1], info.common_param[2], info.common_param[3], info.common_param[4], info.common_param[5], info.common_param[6], info.common_param[7], info.common_param[8], info.common_param[9], info.common_param[10], info.common_param[11]); |
| 1724 | MD_TRC_SPC_SPE_CHECK_EMI_DBG_PAR(info.debug_info[0], info.debug_info[1], info.debug_info[2], info.debug_info[3], info.debug_info[4], info.debug_info[5], info.debug_info[6], info.debug_info[7], info.debug_info[8], info.debug_info[9], info.debug_info[10], info.debug_info[11]); |
| 1725 | L1SP_LoadCommonSpeechPara((uint16 *) info.common_param); |
| 1726 | L1Audio_SetDebugInfo((uint16 *) info.debug_info); |
| 1727 | VMREC_ConfigEpl(); |
| 1728 | spc_dev_LoopbackPoint_DVT(info.debug_info[15]); |
| 1729 | |
| 1730 | |
| 1731 | MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(0,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path); |
| 1732 | EMI_Offset=0; |
| 1733 | if(info.param_path == 2 && info.param_shm_valid ==1 ) |
| 1734 | { |
| 1735 | EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ; |
| 1736 | //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS); |
| 1737 | //memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16); |
| 1738 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_COMMON_PAR,Common_Para[0],Common_Para[1],Common_Para[2],Common_Para[3],Common_Para[4],Common_Para[5],Common_Para[6],Common_Para[7],Common_Para[8],Common_Para[9],Common_Para[10],Common_Para[11]); |
| 1739 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_DBG_PAR,Dbg_Para[0],Dbg_Para[1],Dbg_Para[2],Dbg_Para[3],Dbg_Para[4],Dbg_Para[5],Dbg_Para[6],Dbg_Para[7],Dbg_Para[8],Dbg_Para[9],Dbg_Para[10],Dbg_Para[11]); |
| 1740 | //L1SP_LoadCommonSpeechPara(Common_Para); |
| 1741 | //L1Audio_SetDebugInfo((uint16 *)Dbg_Para); |
| 1742 | l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len); |
| 1743 | SetSpeechEnhancement(true); |
| 1744 | |
| 1745 | }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par. |
| 1746 | { |
| 1747 | SetSpeechEnhancement(true); |
| 1748 | } |
| 1749 | else |
| 1750 | { |
| 1751 | // need use MD default par |
| 1752 | l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN); |
| 1753 | // L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para); |
| 1754 | // L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para); |
| 1755 | SetSpeechEnhancement(true); |
| 1756 | } |
| 1757 | #endif |
| 1758 | |
| 1759 | L1SP_SetOpenDSPFlag(info.opendsp_flag); |
| 1760 | if(SPH_ON_APPLICATION_NORMAL == info.application) { |
| 1761 | Spc_SpeechOn(RAT_3G_MODE); |
| 1762 | } else if (SPH_ON_APPLICATION_VT_CALL == info.application) { |
| 1763 | // phase out from ap side |
| 1764 | Spc_SpeechOn(RAT_3G324M_MODE); |
| 1765 | } else if (SPH_ON_APPLICATION_LOOPBACK == info.application) { |
| 1766 | Spc_AcousticLoopback(true, info.loopback_flag, info.loopback_delay); |
| 1767 | } else if (SPH_ON_APPLICATION_ROUTER == info.application) { |
| 1768 | Spc_SpeechRouterOn(true); |
| 1769 | } else if (SPH_ON_APPLICATION_DACA == info.application) { |
| 1770 | Spc_SpeechOnForDaca(0, true); |
| 1771 | } else if (SPH_ON_APPLICATION_HOLD_CALL == info.application) { |
| 1772 | spc_SpeechOnForCallHold(true); |
| 1773 | } |
| 1774 | |
| 1775 | SET_SPC_APP_USAGE(SPC_APP_MERGE_SPH_USAGE); |
| 1776 | |
| 1777 | leaveSphOn: |
| 1778 | return totalProcLen; |
| 1779 | } |
| 1780 | |
| 1781 | |
| 1782 | void Spc_SpeechOff( void ) |
| 1783 | { |
| 1784 | kal_bool isAppOn=false; |
| 1785 | |
| 1786 | MD_TRC_SPC_SPEECH_OFF(); |
| 1787 | |
| 1788 | // check app status |
| 1789 | isAppOn = spc_endApp(); |
| 1790 | MODEM_WARNING_MESSAGE((false==isAppOn), "Spc_SpeechOff: with app=%x", gSpc.spcAppUsage); |
| 1791 | // ASSERT(0==IS_SPC_APP_USED(SPC_APP_RECORD_USAGE)); removed from 93md |
| 1792 | // ASSERT(0==IS_SPC_APP_USED(SPC_APP_PCM_REC_USAGE)); removed from 93md |
| 1793 | |
| 1794 | if(!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)){ |
| 1795 | // just leave log and return |
| 1796 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, 0); |
| 1797 | return; |
| 1798 | } |
| 1799 | |
| 1800 | #if SPC_CUST_ENH |
| 1801 | PcmEx_Stop(); |
| 1802 | DV_Release(); |
| 1803 | #endif |
| 1804 | |
| 1805 | |
| 1806 | // close speech |
| 1807 | L1SP_Speech_Off(); |
| 1808 | CLR_SPC_APP_USAGE(SPC_APP_SPEECH_USAGE); |
| 1809 | |
| 1810 | } |
| 1811 | |
| 1812 | void Spc_SpeechOff_Merge( void) |
| 1813 | { |
| 1814 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) { |
| 1815 | if(SPH_ON_APPLICATION_NORMAL == gSpc_sphOnInfo.application) { |
| 1816 | Spc_SpeechOff(); |
| 1817 | } else if (SPH_ON_APPLICATION_VT_CALL == gSpc_sphOnInfo.application) { |
| 1818 | Spc_SpeechOff(); |
| 1819 | } else if (SPH_ON_APPLICATION_LOOPBACK == gSpc_sphOnInfo.application) { |
| 1820 | Spc_AcousticLoopback(false,0,0); |
| 1821 | } else if (SPH_ON_APPLICATION_ROUTER == gSpc_sphOnInfo.application) { |
| 1822 | Spc_SpeechRouterOn(false); |
| 1823 | } else if (SPH_ON_APPLICATION_DACA == gSpc_sphOnInfo.application) { |
| 1824 | Spc_SpeechOnForDaca(0, false); |
| 1825 | } else if (SPH_ON_APPLICATION_HOLD_CALL == gSpc_sphOnInfo.application) { |
| 1826 | spc_SpeechOnForCallHold(false); |
| 1827 | } |
| 1828 | |
| 1829 | CLR_SPC_APP_USAGE(SPC_APP_MERGE_SPH_USAGE); |
| 1830 | } else { |
| 1831 | Spc_SpeechOff(); |
| 1832 | } |
| 1833 | |
| 1834 | } |
| 1835 | |
| 1836 | // MSG_A2M_SPH_DEV_CHANGE |
| 1837 | kal_uint16 Spc_SpeechDeviceChange(kal_uint16 offset, kal_uint16 length, const SPC_MSG_FROM_T comeFrom) |
| 1838 | { |
| 1839 | spcBufInfo header; |
| 1840 | spc_sph_on_info_t info; |
| 1841 | kal_uint16 totalProcLen = 0; |
| 1842 | kal_bool check; |
| 1843 | |
| 1844 | #if defined(_SPE_ENH_DSP_PARSE_)//for 95,97 |
| 1845 | kal_uint32 EMI_Offset; |
| 1846 | //unsigned short Common_Para[NUM_COMMON_PARAS]; |
| 1847 | //unsigned short Dbg_Para[16]; |
| 1848 | #endif |
| 1849 | memset(&info, 0, sizeof(spc_sph_on_info_t)); |
| 1850 | if(length == (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) { |
| 1851 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1852 | } else if ((length < (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) && (length > sizeof(spcBufInfo))) { |
| 1853 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1854 | MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t)); |
| 1855 | } else if (length > (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) { |
| 1856 | SpcIO_GetDataFromAp_inOneTime(offset, (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t)), sizeof(spcBufInfo), &header, &info, comeFrom); |
| 1857 | MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t)); |
| 1858 | }else { |
| 1859 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 3); |
| 1860 | goto leaveDevChange; |
| 1861 | } |
| 1862 | |
| 1863 | check = (header.syncWord == 0xA2A2); |
| 1864 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow syncWord"); |
| 1865 | if(!check) |
| 1866 | goto leaveDevChange; |
| 1867 | check = (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO); |
| 1868 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow type"); |
| 1869 | if(!check) |
| 1870 | goto leaveDevChange; |
| 1871 | check = (header.length == (length - sizeof(spcBufInfo))); |
| 1872 | MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow length"); |
| 1873 | if(!check) |
| 1874 | goto leaveDevChange; |
| 1875 | |
| 1876 | MD_TRC_SPC_SPEECH_ON_PAYLOAD( |
| 1877 | info.application, info.bt_info, info.sample_rate_enum, info.opendsp_flag, |
| 1878 | info.param_path, info.param_shm_valid, info.param_size, info.param_idx, info.ext_dev_info, |
| 1879 | info.mute_mask); |
| 1880 | |
| 1881 | // set device |
| 1882 | SP_SetDevicePath(info.bt_info, info.sample_rate_enum); |
| 1883 | SP_SetExtraDevInfo(info.bt_info, info.ext_dev_info, info.smartPA_config, info.echo_ref_delay_ms, info.mic_delay_ms); |
| 1884 | gSpc_sphOnInfo.sample_rate_enum = info.sample_rate_enum; |
| 1885 | gSpc_sphOnInfo.bt_info = info.bt_info; |
| 1886 | gSpc_sphOnInfo.ext_dev_info = info.ext_dev_info; |
| 1887 | gSpc_sphOnInfo.echo_ref_delay_ms = info.echo_ref_delay_ms; |
| 1888 | gSpc_sphOnInfo.mic_delay_ms = info.mic_delay_ms; |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | |
| 1893 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1894 | // apply the parameter |
| 1895 | if(SPH_ON_PARAM_VIA_SHM == info.param_path) { |
| 1896 | if(1 == info.param_shm_valid) { |
| 1897 | kal_uint16 procLen = 0; |
| 1898 | kal_uint16 curOffset = info.param_idx; |
| 1899 | |
| 1900 | while (totalProcLen < info.param_size ) { |
| 1901 | kal_uint16 newOffset; |
| 1902 | spc_dynamicParameterParser_dispatcher(curOffset, info.param_size-totalProcLen, |
| 1903 | SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset); |
| 1904 | |
| 1905 | totalProcLen += procLen; |
| 1906 | curOffset = newOffset; |
| 1907 | } |
| 1908 | } |
| 1909 | } else { |
| 1910 | // Via stream. Not implement yet |
| 1911 | kal_prompt_trace(MOD_L1SP, "DEV change. param data from payload!!"); |
| 1912 | } |
| 1913 | |
| 1914 | #else |
| 1915 | MD_TRC_SPC_SPE_CHECK_EMI_COMMON_PAR(info.common_param[0], info.common_param[1], info.common_param[2], info.common_param[3], info.common_param[4], info.common_param[5], info.common_param[6], info.common_param[7], info.common_param[8], info.common_param[9], info.common_param[10], info.common_param[11]); |
| 1916 | MD_TRC_SPC_SPE_CHECK_EMI_DBG_PAR(info.debug_info[0], info.debug_info[1], info.debug_info[2], info.debug_info[3], info.debug_info[4], info.debug_info[5], info.debug_info[6], info.debug_info[7], info.debug_info[8], info.debug_info[9], info.debug_info[10], info.debug_info[11]); |
| 1917 | L1SP_LoadCommonSpeechPara((uint16 *) info.common_param); |
| 1918 | L1Audio_SetDebugInfo((uint16 *) info.debug_info); |
| 1919 | VMREC_ConfigEpl(); |
| 1920 | spc_dev_LoopbackPoint_DVT(info.debug_info[15]); |
| 1921 | |
| 1922 | MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(1,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path); |
| 1923 | EMI_Offset=0; |
| 1924 | if(info.param_path == 2 && info.param_shm_valid ==1 ) |
| 1925 | { |
| 1926 | EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ; |
| 1927 | //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS); |
| 1928 | //memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16); |
| 1929 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_COMMON_PAR,Common_Para[0],Common_Para[1],Common_Para[2],Common_Para[3],Common_Para[4],Common_Para[5],Common_Para[6],Common_Para[7],Common_Para[8],Common_Para[9],Common_Para[10],Common_Para[11]); |
| 1930 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_DBG_PAR,Dbg_Para[0],Dbg_Para[1],Dbg_Para[2],Dbg_Para[3],Dbg_Para[4],Dbg_Para[5],Dbg_Para[6],Dbg_Para[7],Dbg_Para[8],Dbg_Para[9],Dbg_Para[10],Dbg_Para[11]); |
| 1931 | //L1SP_LoadCommonSpeechPara((uint16 *)Common_Para); |
| 1932 | //L1Audio_SetDebugInfo((uint16 *)Dbg_Para); |
| 1933 | l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len); |
| 1934 | SetSpeechEnhancement(true); |
| 1935 | |
| 1936 | }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par. |
| 1937 | { |
| 1938 | |
| 1939 | SetSpeechEnhancement(true); |
| 1940 | } |
| 1941 | else |
| 1942 | { |
| 1943 | // need use MD default par |
| 1944 | l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN); |
| 1945 | // L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para); |
| 1946 | //L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para); |
| 1947 | SetSpeechEnhancement(true); |
| 1948 | } |
| 1949 | |
| 1950 | #endif |
| 1951 | |
| 1952 | leaveDevChange: |
| 1953 | return totalProcLen; |
| 1954 | } |
| 1955 | |
| 1956 | |
| 1957 | void spc_DebugPrint(void) |
| 1958 | { |
| 1959 | uint16 *m_para; |
| 1960 | |
| 1961 | m_para = Sp_GetCommonSpeechPara(); // size NUM_COMMON_PARAS |
| 1962 | MD_TRC_L1SP_COMMON_PARAM_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11]); |
| 1963 | |
| 1964 | #if defined(_SPE_ENH_MD_PARSE_) |
| 1965 | m_para = Sp_GetSpeechPara(); // size NUM_MODE_PARAS |
| 1966 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 1967 | |
| 1968 | m_para = Sp_GetWbSpeechPara(); // size NUM_MODE_PARAS |
| 1969 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 1970 | #endif |
| 1971 | } |
| 1972 | |
| 1973 | |
| 1974 | /** |
| 1975 | MED(AUDL) task |
| 1976 | codec: em_speech_info_SpeechCodecType. in "em_public_struct.h" |
| 1977 | */ |
| 1978 | void spc_notify_network_status(uint32 codec) |
| 1979 | { |
| 1980 | uint16 tmp; |
| 1981 | uint8 band = 0; // default 8k |
| 1982 | uint32 RAT = AM_GetNetworkRate(); |
| 1983 | uint8 Network = 0xF; |
| 1984 | |
| 1985 | if( (0x61 == codec ) || ((codec >= 0x20) && (codec <= 0x28)) |
| 1986 | || ((codec >= 0x90) && (codec <= 0x9F)) |
| 1987 | || ((codec >= 0xD0) && (codec <= 0xDF)) ){ // 16k |
| 1988 | band = 1; |
| 1989 | |
| 1990 | } else if((codec >= 0xA0) && (codec <= 0xAF)) { // 32k |
| 1991 | band = 2; |
| 1992 | } else if((codec >= 0xB0) && (codec <= 0xBF)) { // 48k |
| 1993 | band = 3; |
| 1994 | } |
| 1995 | |
| 1996 | if(RAT == RAT_4G_MODE) |
| 1997 | { |
| 1998 | Network = NETWORK_VOLTE; |
| 1999 | } |
| 2000 | else if(RAT == RAT_3G_MODE) |
| 2001 | { |
| 2002 | Network = NETWORK_WCDMA_FDD; |
| 2003 | #if defined( __UMTS_RAT__ ) |
| 2004 | switch(L1SP_GetSIMStatus()){ |
| 2005 | case SP_3G_SIM_FDD_ACTIVE: |
| 2006 | Network = NETWORK_WCDMA_FDD; |
| 2007 | break; |
| 2008 | case SP_3G_SIM_TDD_ACTIVE: |
| 2009 | Network = NETWORK_WCDMA_TDD; |
| 2010 | break; |
| 2011 | default: |
| 2012 | Network = NETWORK_WCDMA_FDD; |
| 2013 | break; |
| 2014 | } |
| 2015 | #endif |
| 2016 | } |
| 2017 | else if(RAT == RAT_2G_MODE) |
| 2018 | { |
| 2019 | Network = NETWORK_GSM; |
| 2020 | } |
| 2021 | else if(RAT == RAT_C2K_MODE) |
| 2022 | { |
| 2023 | Network = NETWORK_C2K; |
| 2024 | } |
| 2025 | |
| 2026 | tmp = (kal_uint16)((band) << 4 | (Network & 0xF) | ( 0x1 << 15 )); |
| 2027 | // tmp = (kal_uint16)( (band << 3) | (RAT & 0x7)); |
| 2028 | |
| 2029 | if(gSpc_networkStatus != tmp){ |
| 2030 | MD_TRC_SPC_NOTIFY_NETWORK_STATUS_INFO(tmp, band, RAT); |
| 2031 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_NETWORK_STATUS_NOTIFY, (kal_uint16)tmp, 0); |
| 2032 | MD_TRC_SPC_NOTIFY_NETWORK_STATUS(gSpc_networkStatus, tmp); |
| 2033 | gSpc_networkStatus = tmp; |
| 2034 | }else{ |
| 2035 | MD_TRC_SPC_NOTIFY_NETWORK_STATUS_SKIP(tmp); |
| 2036 | } |
| 2037 | |
| 2038 | spc_codecInfoNotify(codec); |
| 2039 | } |
| 2040 | |
| 2041 | //AUDIO task |
| 2042 | #include "em_audio_public_struct.h" |
| 2043 | void spc_send_network_status_notify(em_speech_info_SpeechCodecType codec) |
| 2044 | { |
| 2045 | SpcIO_MsgQueuePut(SPC_ID_NETWORK_STATUS_NOTIFY, codec, 0, SPC_MSG_FROM_AUDHISR); |
| 2046 | } |
| 2047 | |
| 2048 | void spc_ReceiveNwCodecInfoReadDone(void) |
| 2049 | { |
| 2050 | l1sp_send_codec_status_notify(AM_GetSpeechMode()); |
| 2051 | } |
| 2052 | /** |
| 2053 | @isGen: true for trun on, false for turn off |
| 2054 | */ |
| 2055 | void spc_SpeechOnForCallHold(kal_bool isGen) |
| 2056 | { |
| 2057 | |
| 2058 | |
| 2059 | if(isGen){ // turn on |
| 2060 | |
| 2061 | if(false == spc_mainAppOnCheck(SPC_APP_HOLD_USAGE)) |
| 2062 | return; |
| 2063 | |
| 2064 | // turn on speech and mute |
| 2065 | |
| 2066 | L1SP_Speech_On(RAT_3G_MODE); |
| 2067 | SP_MuteUlFromDiffPos(true, SP_MIC_MUTE_POS_FROM_SPC); |
| 2068 | |
| 2069 | SET_SPC_APP_USAGE(SPC_APP_HOLD_USAGE); |
| 2070 | } else { // turn off |
| 2071 | |
| 2072 | if(!IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)) { // sid generation not in use |
| 2073 | // just leave the log and return |
| 2074 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, 0); |
| 2075 | return; |
| 2076 | } |
| 2077 | |
| 2078 | // turn off |
| 2079 | SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_SPC); |
| 2080 | L1SP_Speech_Off(); |
| 2081 | CLR_SPC_APP_USAGE(SPC_APP_HOLD_USAGE); |
| 2082 | } |
| 2083 | |
| 2084 | } |
| 2085 | |
| 2086 | // ---------------------------------------------------------------------------- |
| 2087 | // Loopback |
| 2088 | // ---------------------------------------------------------------------------- |
| 2089 | #define ACLOOPBACK_USING_P2W 1 |
| 2090 | |
| 2091 | #define ACLOOPBACK_FRAME_BUF_NO (64) // REMIND: should be pow of 2 |
| 2092 | #define ACLOOPBACK_NB_FRAME_SIZE (160) |
| 2093 | #define ACLOOPBACK_DELAY 12 // unit is 20ms |
| 2094 | |
| 2095 | #if ACLOOPBACK_USING_P2W |
| 2096 | static uint16 gSpc_acLoopback_PCM_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE]; |
| 2097 | #else |
| 2098 | // static uint16 gSpc_acLoopback_PCM_UL_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE]; |
| 2099 | static uint16 gSpc_acLoopback_PCM_UL_BUF[ACLOOPBACK_NB_FRAME_SIZE]; |
| 2100 | static uint16 gSpc_acLoopback_PCM_DL_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE]; |
| 2101 | #endif |
| 2102 | |
| 2103 | typedef struct |
| 2104 | { |
| 2105 | uint32 delay; |
| 2106 | uint8 isLoopback; |
| 2107 | |
| 2108 | #if ACLOOPBACK_USING_P2W |
| 2109 | uint32 tmp_w; |
| 2110 | uint32 tmp_r; |
| 2111 | #else |
| 2112 | // uint32 UL_tmp_w; |
| 2113 | // uint32 UL_tmp_r; |
| 2114 | uint32 DL_tmp_w; |
| 2115 | uint32 DL_tmp_r; |
| 2116 | #endif |
| 2117 | |
| 2118 | } _SPC_ACOUSTIC_LOOPBACK_T; |
| 2119 | |
| 2120 | static _SPC_ACOUSTIC_LOOPBACK_T gSpc_acLoopback; |
| 2121 | void spc_setAcLoopbackState(bool b) |
| 2122 | { |
| 2123 | gSpc_acLoopback.isLoopback = b; |
| 2124 | } |
| 2125 | |
| 2126 | bool spc_isAcLoopback() |
| 2127 | { |
| 2128 | return gSpc_acLoopback.isLoopback; |
| 2129 | } |
| 2130 | |
| 2131 | |
| 2132 | #if ACLOOPBACK_USING_P2W |
| 2133 | void AcousticLoopback_PCM2WAY_UL_HisrHdl() |
| 2134 | #else |
| 2135 | void AcousticLoopback_PCM4WAY_UL_HisrHdl() |
| 2136 | #endif |
| 2137 | { |
| 2138 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 2139 | #if ACLOOPBACK_USING_P2W |
| 2140 | |
| 2141 | /* P2W */ |
| 2142 | if( (gSpc_acLoopback.tmp_w - gSpc_acLoopback.tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){ |
| 2143 | PCM2WAY_GetFromMic((uint16*)gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2144 | MD_TRC_SPC_AC_LOOPBACK_FROM_MIC( |
| 2145 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2146 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2147 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2148 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2149 | (gSpc_acLoopback.tmp_w)++; |
| 2150 | }else{ |
| 2151 | MD_TRC_SPC_AC_LOOPBACK_SKIP_MIC(); |
| 2152 | } |
| 2153 | |
| 2154 | #else |
| 2155 | /* P4W UL with delay |
| 2156 | if( (gSpc_acLoopback.UL_tmp_w - gSpc_acLoopback.UL_tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){ |
| 2157 | PCM4WAY_GetFromMic((uint16*)gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2158 | MD_TRC_SPC_AC_LOOPBACK_FROM_MIC( |
| 2159 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2160 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2161 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2162 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2163 | (gSpc_acLoopback.UL_tmp_w)++; |
| 2164 | }else{ |
| 2165 | MD_TRC_SPC_AC_LOOPBACK_SKIP_MIC(); |
| 2166 | } |
| 2167 | |
| 2168 | if( (gSpc_acLoopback.UL_tmp_w - gSpc_acLoopback.UL_tmp_r) >= gSpc_acLoopback.delay ){ |
| 2169 | PCM4WAY_PutToSE(gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2170 | MD_TRC_SPC_AC_LOOPBACK_TO_SE( |
| 2171 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2172 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2173 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2174 | gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2175 | (gSpc_acLoopback.UL_tmp_r)++; |
| 2176 | }else{ |
| 2177 | MD_TRC_SPC_AC_LOOPBACK_FILL_SE(); |
| 2178 | PCM4WAY_FillSE(0); |
| 2179 | } |
| 2180 | */ |
| 2181 | |
| 2182 | // P4W UL without delay |
| 2183 | PCM4WAY_GetFromMic(gSpc_acLoopback_PCM_UL_BUF); |
| 2184 | MD_TRC_SPC_AC_LOOPBACK_FROM_MIC( |
| 2185 | gSpc_acLoopback_PCM_UL_BUF[0], |
| 2186 | gSpc_acLoopback_PCM_UL_BUF[1], |
| 2187 | gSpc_acLoopback_PCM_UL_BUF[2], |
| 2188 | gSpc_acLoopback_PCM_UL_BUF[3]); |
| 2189 | |
| 2190 | PCM4WAY_PutToSE(gSpc_acLoopback_PCM_UL_BUF); |
| 2191 | MD_TRC_SPC_AC_LOOPBACK_TO_SE( |
| 2192 | gSpc_acLoopback_PCM_UL_BUF[0], |
| 2193 | gSpc_acLoopback_PCM_UL_BUF[1], |
| 2194 | gSpc_acLoopback_PCM_UL_BUF[2], |
| 2195 | gSpc_acLoopback_PCM_UL_BUF[3]); |
| 2196 | |
| 2197 | #endif |
| 2198 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 2199 | } |
| 2200 | |
| 2201 | #if ACLOOPBACK_USING_P2W |
| 2202 | void AcousticLoopback_PCM2WAY_DL_HisrHdl() |
| 2203 | #else |
| 2204 | void AcousticLoopback_PCM4WAY_DL_HisrHdl() |
| 2205 | #endif |
| 2206 | { |
| 2207 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 2208 | #if ACLOOPBACK_USING_P2W |
| 2209 | /* P2W */ |
| 2210 | if( (gSpc_acLoopback.tmp_w - gSpc_acLoopback.tmp_r) >= gSpc_acLoopback.delay){ |
| 2211 | PCM2WAY_PutToSpk(gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2212 | MD_TRC_SPC_AC_LOOPBACK_TO_SPK( |
| 2213 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2214 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2215 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2216 | gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2217 | (gSpc_acLoopback.tmp_r)++; |
| 2218 | }else{ |
| 2219 | MD_TRC_SPC_AC_LOOPBACK_FILL_SPK(); |
| 2220 | PCM2WAY_FillSpk(0); |
| 2221 | } |
| 2222 | |
| 2223 | MD_TRC_SPC_AC_LOOPBACK_UL_DL_INDEX( |
| 2224 | gSpc_acLoopback.tmp_w, gSpc_acLoopback.tmp_r, 0, 0); |
| 2225 | #else |
| 2226 | |
| 2227 | |
| 2228 | if( (gSpc_acLoopback.DL_tmp_w - gSpc_acLoopback.DL_tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){ |
| 2229 | PCM4WAY_GetFromSD((uint16*)gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2230 | MD_TRC_SPC_AC_LOOPBACK_FROM_SD( |
| 2231 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2232 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2233 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2234 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2235 | (gSpc_acLoopback.DL_tmp_w)++; |
| 2236 | }else{ |
| 2237 | MD_TRC_SPC_AC_LOOPBACK_SKIP_SD(); |
| 2238 | } |
| 2239 | |
| 2240 | |
| 2241 | |
| 2242 | if( (gSpc_acLoopback.DL_tmp_w - gSpc_acLoopback.DL_tmp_r) >= gSpc_acLoopback.delay){ |
| 2243 | PCM4WAY_PutToSpk(gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]); |
| 2244 | |
| 2245 | MD_TRC_SPC_AC_LOOPBACK_TO_SPK( |
| 2246 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0], |
| 2247 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1], |
| 2248 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2], |
| 2249 | gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]); |
| 2250 | (gSpc_acLoopback.DL_tmp_r)++; |
| 2251 | |
| 2252 | }else{ |
| 2253 | MD_TRC_SPC_AC_LOOPBACK_FILL_SPK(); |
| 2254 | |
| 2255 | PCM4WAY_FillSpk(0); |
| 2256 | } |
| 2257 | |
| 2258 | |
| 2259 | MD_TRC_SPC_AC_LOOPBACK_UL_DL_INDEX( |
| 2260 | /* gSpc_acLoopback.DL_tmp_w, gSpc_acLoopback.DL_tmp_r, gSpc_acLoopback.UL_tmp_w, gSpc_acLoopback.UL_tmp_r);*/ |
| 2261 | gSpc_acLoopback.DL_tmp_w, gSpc_acLoopback.DL_tmp_r, 0, 0); |
| 2262 | |
| 2263 | #endif |
| 2264 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 2265 | |
| 2266 | } |
| 2267 | |
| 2268 | /** |
| 2269 | @uParam: reference spc_sph_on_loopback_info_flag |
| 2270 | Bit 0: Pre-condiftion is speech mode equals to SPH_MODE_BT_EARPHONE(3) or SPH_MODE_BT_CCARITE(5). 1== BT Loopback without BT codec / 0 == BT Loopback with BT Codec. Only support CVSD&MSBC |
| 2271 | Bit 1: delay setting for normal loopback, i.e. speech mode is not BT cases. 0==Use modem default delay value/ 1== use AP gives delay value in msgId32 bit[0:7] |
| 2272 | @extraParam: |
| 2273 | Bit[7:0]: Delay time in uint8. Unit is 20ms. Take effect when msgId16 bit[2] == 1. For example: when bit[7:0] = 0xf, then the delay time is 15*20 == 300 ms. |
| 2274 | */ |
| 2275 | void Spc_AcousticLoopback(bool enable, kal_uint8 uParam, kal_uint8 extraParam) |
| 2276 | { |
| 2277 | // kal_bool enable = uParam & 0x1; // bit(0): on/off bit(1): disable/enable BT SW codec |
| 2278 | |
| 2279 | MD_TRC_SPC_AC_LOOPBACK_INFO(enable, uParam, extraParam); |
| 2280 | |
| 2281 | if(enable){ |
| 2282 | |
| 2283 | if(false == spc_mainAppOnCheck(SPC_APP_ACLOOPBACK_USAGE)) // remind to skip EM check if necessary |
| 2284 | return; |
| 2285 | |
| 2286 | if(IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ |
| 2287 | // just leave log and return |
| 2288 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(SPC_APP_ACLOOPBACK_USAGE, SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, gSpc.spcAppUsage); |
| 2289 | return; |
| 2290 | } |
| 2291 | |
| 2292 | // special case for BT loopback |
| 2293 | #if defined(__CVSD_CODEC_SUPPORT__) |
| 2294 | |
| 2295 | if( SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD_MSBC |
| 2296 | || SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD |
| 2297 | || SP_GetDevInfo() == SPH_DEVINFO_BT_MSBC) |
| 2298 | { // for SW BT platform, BT loopback does not related to speech and DSP. |
| 2299 | |
| 2300 | kal_uint8 voice8kMode = SP_GetDevSamplingRate(); |
| 2301 | if( (voice8kMode==0) || (voice8kMode==1) ) { |
| 2302 | |
| 2303 | SET_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE); |
| 2304 | BT_SCO_Loopback_ON( (uParam&SPH_ON_LOOPBACK_INFO_FLAG_DISABLE_BT_CODEC) ,(voice8kMode == 1)); |
| 2305 | return; // REMIND!!! |
| 2306 | |
| 2307 | } else { |
| 2308 | MODEM_WARNING_MESSAGE((voice8kMode==0), "Spc_AcousticLoopback(bt): incorrect Voice8kMode, %d", voice8kMode); |
| 2309 | MODEM_WARNING_MESSAGE((voice8kMode==1), "Spc_AcousticLoopback(bt): incorrect Voice8kMode, %d", voice8kMode); |
| 2310 | return; |
| 2311 | } |
| 2312 | } |
| 2313 | #endif |
| 2314 | |
| 2315 | // setup |
| 2316 | gSpc_acLoopback.delay = ACLOOPBACK_DELAY; |
| 2317 | if((uParam & SPH_ON_LOOPBACK_INFO_FLAG_DELAY_SETTING) !=0) { // using bit[1] for check delay |
| 2318 | kal_uint8 givenDelay = (extraParam & 0xFF); //use msg32 bit [7:0] for delay setting |
| 2319 | ASSERT(givenDelay<= ACLOOPBACK_FRAME_BUF_NO); |
| 2320 | gSpc_acLoopback.delay = givenDelay; |
| 2321 | } |
| 2322 | #if ACLOOPBACK_USING_P2W |
| 2323 | gSpc_acLoopback.tmp_w = 0; |
| 2324 | gSpc_acLoopback.tmp_r = 0; |
| 2325 | #else |
| 2326 | // gSpc_acLoopback.UL_tmp_w = 0; |
| 2327 | // gSpc_acLoopback.UL_tmp_r = 0; |
| 2328 | gSpc_acLoopback.DL_tmp_w = 0; |
| 2329 | gSpc_acLoopback.DL_tmp_r = 0; |
| 2330 | #endif |
| 2331 | |
| 2332 | //clean memory |
| 2333 | #if ACLOOPBACK_USING_P2W |
| 2334 | memset(gSpc_acLoopback_PCM_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE); |
| 2335 | #else |
| 2336 | // memset(gSpc_acLoopback_PCM_UL_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE); |
| 2337 | memset(gSpc_acLoopback_PCM_UL_BUF, 0, sizeof(uint16)*ACLOOPBACK_NB_FRAME_SIZE); |
| 2338 | memset(gSpc_acLoopback_PCM_DL_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE); |
| 2339 | #endif |
| 2340 | spc_setAcLoopbackState(1); |
| 2341 | #if ACLOOPBACK_USING_P2W |
| 2342 | /* P2W */ |
| 2343 | Idle_PcmEx_Start(AcousticLoopback_PCM2WAY_DL_HisrHdl, AcousticLoopback_PCM2WAY_UL_HisrHdl, |
| 2344 | USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul1 |
| 2345 | USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul2 |
| 2346 | USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul3 |
| 2347 | USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul4 |
| 2348 | USE_M2D_PATH, |
| 2349 | PCMEX_BAND_NB, PCMEX_IDLE_ENH_SETTING_WITH); |
| 2350 | #else |
| 2351 | // enable |
| 2352 | L1SP_Speech_On(RAT_2G_MODE); |
| 2353 | |
| 2354 | #if ACLOOPBACK_USING_ExtCodec |
| 2355 | Extcodec_Set_Delay(gSpc_acLoopback.delay); |
| 2356 | Extcodec_Call_Open(); |
| 2357 | |
| 2358 | #else |
| 2359 | L1SP_SpeechLoopBackEnable(KAL_TRUE); //dsp codec loopback |
| 2360 | |
| 2361 | Del_PcmEx_Start(AcousticLoopback_PCM4WAY_DL_HisrHdl, AcousticLoopback_PCM4WAY_UL_HisrHdl, |
| 2362 | USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, |
| 2363 | USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, |
| 2364 | USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, |
| 2365 | USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, |
| 2366 | USE_D2M_PATH + USE_M2D_PATH); |
| 2367 | #endif//ACLOOPBACK_USING_ExtCodec |
| 2368 | #endif//ACLOOPBACK_USING_P2W |
| 2369 | |
| 2370 | |
| 2371 | SET_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE); |
| 2372 | |
| 2373 | } else { |
| 2374 | |
| 2375 | if(!IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE)){ |
| 2376 | // just leave log and return |
| 2377 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_ACLOOPBACK_USAGE, SPC_APP_ACLOOPBACK_USAGE, 0); |
| 2378 | return; |
| 2379 | } |
| 2380 | |
| 2381 | #if defined(__CVSD_CODEC_SUPPORT__) |
| 2382 | if( BT_SCO_IS_SPEECH_ON() ) |
| 2383 | { // for SW BT platform, BT loopback does not related to speech and DSP. |
| 2384 | BT_SCO_Loopback_OFF(); |
| 2385 | CLR_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE); |
| 2386 | return; |
| 2387 | } |
| 2388 | #endif |
| 2389 | |
| 2390 | |
| 2391 | #if ACLOOPBACK_USING_P2W |
| 2392 | /* P2W */ |
| 2393 | // SetSpeechEnhancement(false); |
| 2394 | PcmEx_Stop(); |
| 2395 | /*mute after loopback*/ |
| 2396 | |
| 2397 | SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_ALL); |
| 2398 | L1SP_MuteSpeaker(false); |
| 2399 | #else |
| 2400 | |
| 2401 | // Extended_PCM4WAY_Stop(P4W_APP_TYPE_UNDER_CALL); |
| 2402 | #if ACLOOPBACK_USING_ExtCodec |
| 2403 | Extcodec_Call_Close(); |
| 2404 | #else |
| 2405 | PcmEx_Stop(); |
| 2406 | #endif//ACLOOPBACK_USING_ExtCodec |
| 2407 | |
| 2408 | |
| 2409 | L1SP_SpeechLoopBackEnable(KAL_FALSE); |
| 2410 | L1SP_Speech_Off(); |
| 2411 | spc_setAcLoopbackState(0); |
| 2412 | |
| 2413 | |
| 2414 | #endif//ACLOOPBACK_USING_P2W |
| 2415 | |
| 2416 | CLR_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE); |
| 2417 | |
| 2418 | } |
| 2419 | |
| 2420 | return; |
| 2421 | } |
| 2422 | |
| 2423 | // ---------------------------------------------------------------------------- |
| 2424 | // Speech on for Hosted Dongle |
| 2425 | // ---------------------------------------------------------------------------- |
| 2426 | #define SPC_DACA_SIZE 320 // 16*20 words, currently fix 16k |
| 2427 | #define SPC_DACA_SIZE_IN_BYTE 640 |
| 2428 | |
| 2429 | typedef struct _SPC_DACA_T_{ |
| 2430 | |
| 2431 | kal_bool dacaIsMicBufWaiting; |
| 2432 | kal_bool dacaIsSpkBufWaiting; |
| 2433 | |
| 2434 | }_SPC_DACA_T; |
| 2435 | |
| 2436 | static _SPC_DACA_T gSpc_Daca; |
| 2437 | static kal_uint16 gSpc_Daca_spkBuf[SPC_DACA_SIZE]; |
| 2438 | static kal_uint16 gSpc_Daca_micBuf[SPC_DACA_SIZE]; |
| 2439 | |
| 2440 | /** |
| 2441 | MD -> AP, Run under AUDL/MED |
| 2442 | */ |
| 2443 | void spc_daca_sendDlData(void) |
| 2444 | { |
| 2445 | kal_bool sendResult = KAL_TRUE; |
| 2446 | spcBufInfo info; |
| 2447 | |
| 2448 | if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ // prevent data sending after DACA is off |
| 2449 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 3); |
| 2450 | return; |
| 2451 | } |
| 2452 | |
| 2453 | info.syncWord = 0x2A2A; |
| 2454 | info.type = AUD_CCCI_STRMBUF_TYPE_DACA_GetSpk; |
| 2455 | info.length = SPC_DACA_SIZE_IN_BYTE; // currently, fix the buffer size in WB |
| 2456 | |
| 2457 | sendResult = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 2458 | gSpc_Daca_spkBuf, SPC_DACA_SIZE_IN_BYTE, NULL, 0, |
| 2459 | SPCIO_MSG_FROM_SPC_DACA_DLDATA_NOTIFY)); |
| 2460 | |
| 2461 | if(KAL_TRUE != sendResult) { |
| 2462 | //clean up the read waiting flag when send fail to prevent blocking. |
| 2463 | gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE; |
| 2464 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 0); |
| 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | void spc_daca_sendDlDataDone(void) |
| 2469 | { |
| 2470 | |
| 2471 | if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ |
| 2472 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 4); |
| 2473 | return; |
| 2474 | } |
| 2475 | gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE; |
| 2476 | } |
| 2477 | |
| 2478 | |
| 2479 | /** |
| 2480 | MD -> AP, Run under AUDL/MED |
| 2481 | */ |
| 2482 | void spc_daca_requestUlData(void) |
| 2483 | { |
| 2484 | kal_int32 sendResult; |
| 2485 | |
| 2486 | if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ // prevent data sending after DACA is off |
| 2487 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 5); |
| 2488 | return; |
| 2489 | } |
| 2490 | |
| 2491 | sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DACA_ULDATA_REQUEST, SPC_DACA_SIZE, 0); |
| 2492 | |
| 2493 | if(sendResult<0){ //clean waiting flag of speaker to prevent message blocking |
| 2494 | gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE; |
| 2495 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1); |
| 2496 | } |
| 2497 | } |
| 2498 | |
| 2499 | void spc_daca_writeUlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom) |
| 2500 | { |
| 2501 | |
| 2502 | spcBufInfo info; |
| 2503 | kal_uint16 curOffSet; |
| 2504 | kal_bool check; |
| 2505 | |
| 2506 | if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ |
| 2507 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 6); |
| 2508 | return; |
| 2509 | } |
| 2510 | |
| 2511 | check = (length>=sizeof(spcBufInfo)); |
| 2512 | MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: length=%d small then sizeof(spcBufInfo)", length); |
| 2513 | if(!check) |
| 2514 | goto leaveDacaUlDone; |
| 2515 | curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom); |
| 2516 | |
| 2517 | |
| 2518 | //header checking |
| 2519 | check = (info.syncWord == 0xA2A2); |
| 2520 | MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow syncWord"); |
| 2521 | if(!check) |
| 2522 | goto leaveDacaUlDone; |
| 2523 | check = (info.type == AUD_CCCI_STRMBUF_TYPE_DACA_FillMic); |
| 2524 | MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow type"); |
| 2525 | if(!check) |
| 2526 | goto leaveDacaUlDone; |
| 2527 | check = (info.length == (length - sizeof(spcBufInfo))); |
| 2528 | MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow length"); |
| 2529 | if(!check) |
| 2530 | goto leaveDacaUlDone; |
| 2531 | |
| 2532 | if(info.length >0){ |
| 2533 | check = (info.length == SPC_DACA_SIZE_IN_BYTE); |
| 2534 | MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: info.length=%d", info.length); |
| 2535 | if(!check) |
| 2536 | goto leaveDacaUlDone; |
| 2537 | SpcIo_GetDataFromAp(curOffSet, SPC_DACA_SIZE_IN_BYTE, gSpc_Daca_micBuf, comeFrom); |
| 2538 | } |
| 2539 | |
| 2540 | leaveDacaUlDone: |
| 2541 | gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE; |
| 2542 | } |
| 2543 | |
| 2544 | void spc_dacaDl_handler(void) |
| 2545 | { |
| 2546 | if( gSpc_Daca.dacaIsSpkBufWaiting == KAL_TRUE){ |
| 2547 | MD_TRC_SPC_M2A_DROP(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 0); |
| 2548 | return; |
| 2549 | } |
| 2550 | |
| 2551 | // speaker buffer comes from SD |
| 2552 | DACA_GetFromSD((uint16 *)gSpc_Daca_spkBuf); |
| 2553 | |
| 2554 | // Transfer to AUDL |
| 2555 | // Send notification |
| 2556 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_DACA_DL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 2557 | |
| 2558 | gSpc_Daca.dacaIsSpkBufWaiting = KAL_TRUE; |
| 2559 | |
| 2560 | } |
| 2561 | |
| 2562 | void spc_dacaUl_handler(void) |
| 2563 | { |
| 2564 | if( gSpc_Daca.dacaIsMicBufWaiting == KAL_TRUE){ |
| 2565 | MD_TRC_SPC_M2A_DROP(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1); |
| 2566 | return; |
| 2567 | } |
| 2568 | |
| 2569 | // mic buffer put to SE. |
| 2570 | DACA_PutToSE((const uint16 *)gSpc_Daca_micBuf); |
| 2571 | |
| 2572 | |
| 2573 | // Transfer to AUDL |
| 2574 | // Send notification |
| 2575 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_DACA_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 2576 | |
| 2577 | gSpc_Daca.dacaIsMicBufWaiting = KAL_TRUE; |
| 2578 | } |
| 2579 | |
| 2580 | /** |
| 2581 | @RAT_Mode: 0 for 2G, 1 for 3G, 2 for 3G324 |
| 2582 | @enable: true for daca speech on, false for daca speech off |
| 2583 | */ |
| 2584 | void Spc_SpeechOnForDaca( kal_uint8 RAT_Mode, kal_bool enable) |
| 2585 | { |
| 2586 | if(true == enable){ // speech on with DACA |
| 2587 | |
| 2588 | if(false == spc_mainAppOnCheck(SPC_APP_HOSTED_USAGE)) { |
| 2589 | return; |
| 2590 | } |
| 2591 | |
| 2592 | |
| 2593 | // disable speech enhancment, due to path is too long, enhancment is meaningless |
| 2594 | L1SP_EnableSpeechEnhancement(false); |
| 2595 | |
| 2596 | // clean up setting |
| 2597 | gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE; |
| 2598 | gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE; |
| 2599 | |
| 2600 | // turn on |
| 2601 | #if defined(__UMTS_RAT__) // rate setting |
| 2602 | if( RAT_Mode != RAT_3G324M_MODE ) |
| 2603 | RAT_Mode = RAT_3G_MODE; // Force initial 3G |
| 2604 | #else |
| 2605 | RAT_Mode = RAT_2G_MODE; |
| 2606 | #endif |
| 2607 | MD_TRC_SPC_SPEECH_ON(RAT_Mode); |
| 2608 | L1SP_Speech_On(RAT_Mode); |
| 2609 | DACA_Start(spc_dacaDl_handler, spc_dacaUl_handler, DACA_APP_TYPE_ACTIVE_UL_DL_WB); // fix wb due to USB protocal |
| 2610 | |
| 2611 | SET_SPC_APP_USAGE(SPC_APP_HOSTED_USAGE); |
| 2612 | |
| 2613 | } else { // speech off with DACA |
| 2614 | |
| 2615 | // status checking |
| 2616 | if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ |
| 2617 | // just leave log and return |
| 2618 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1); |
| 2619 | return; |
| 2620 | } |
| 2621 | |
| 2622 | // turn off |
| 2623 | DACA_Stop(DACA_APP_TYPE_ACTIVE_UL_DL_WB); |
| 2624 | L1SP_Speech_Off(); |
| 2625 | |
| 2626 | // speech enhancment back to normal |
| 2627 | L1SP_EnableSpeechEnhancement(false); |
| 2628 | |
| 2629 | CLR_SPC_APP_USAGE(SPC_APP_HOSTED_USAGE); |
| 2630 | } |
| 2631 | } |
| 2632 | // ---------------------------------------------------------------------------- |
| 2633 | // DSP PCM ROUTER |
| 2634 | // ---------------------------------------------------------------------------- |
| 2635 | void Spc_SpeechRouterOn(kal_bool enable) |
| 2636 | { |
| 2637 | if(enable) { |
| 2638 | |
| 2639 | // status check |
| 2640 | if(false == spc_mainAppOnCheck(SPC_APP_PCMROUTER_USAGE)){ |
| 2641 | return; |
| 2642 | } |
| 2643 | |
| 2644 | //set solution ver before application start. |
| 2645 | |
| 2646 | // application enable |
| 2647 | PcmRouterStart(); |
| 2648 | SET_SPC_APP_USAGE(SPC_APP_PCMROUTER_USAGE); |
| 2649 | |
| 2650 | } else { |
| 2651 | |
| 2652 | // status checking |
| 2653 | if(!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) { |
| 2654 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMROUTER_USAGE, SPC_APP_PCMROUTER_USAGE, 1); |
| 2655 | |
| 2656 | return; |
| 2657 | } |
| 2658 | |
| 2659 | |
| 2660 | // application disable |
| 2661 | PcmRouterStop(); |
| 2662 | CLR_SPC_APP_USAGE(SPC_APP_PCMROUTER_USAGE); |
| 2663 | |
| 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | // ---------------------------------------------------------------------------- |
| 2668 | // RECORD |
| 2669 | // ---------------------------------------------------------------------------- |
| 2670 | #if 0 |
| 2671 | /* under construction !*/ |
| 2672 | /* under construction !*/ |
| 2673 | /* under construction !*/ |
| 2674 | /* under construction !*/ |
| 2675 | /* under construction !*/ |
| 2676 | /* under construction !*/ |
| 2677 | /* under construction !*/ |
| 2678 | /* under construction !*/ |
| 2679 | /* under construction !*/ |
| 2680 | /* under construction !*/ |
| 2681 | /* under construction !*/ |
| 2682 | /* under construction !*/ |
| 2683 | /* under construction !*/ |
| 2684 | /* under construction !*/ |
| 2685 | /* under construction !*/ |
| 2686 | /* under construction !*/ |
| 2687 | /* under construction !*/ |
| 2688 | /* under construction !*/ |
| 2689 | /* under construction !*/ |
| 2690 | /* under construction !*/ |
| 2691 | /* under construction !*/ |
| 2692 | /* under construction !*/ |
| 2693 | /* under construction !*/ |
| 2694 | #endif |
| 2695 | |
| 2696 | typedef struct |
| 2697 | { |
| 2698 | bool isRecordDataWaiting; |
| 2699 | |
| 2700 | } _SPC_VM_RECORD_T; |
| 2701 | |
| 2702 | typedef struct |
| 2703 | { |
| 2704 | bool isRecordDataWaiting; |
| 2705 | } _SPC_RAW_PCM_RECORD_T; |
| 2706 | |
| 2707 | // static _SPC_PCM_RECORD_T gSpc_PcmRecord; |
| 2708 | static _SPC_VM_RECORD_T gSpc_VmRecord; |
| 2709 | static _SPC_RAW_PCM_RECORD_T gSpc_RawPcmRecord; |
| 2710 | // static SPC_REC_FORMAT gSpc_Record_format; // only use under record command containing vm/pcm |
| 2711 | /* |
| 2712 | static kal_uint8 tempMicDataCnt = 0; |
| 2713 | static kal_uint16 tempMicData[320] |
| 2714 | // = { 0x4808,0x85, 0x156,0, 0x4,0, 0x146,0x9000, |
| 2715 | = { |
| 2716 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 2717 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 2718 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 2719 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2720 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 2721 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 2722 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 2723 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2724 | |
| 2725 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 2726 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 2727 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 2728 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2729 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 2730 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 2731 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 2732 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2733 | |
| 2734 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 2735 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 2736 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 2737 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2738 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 2739 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 2740 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 2741 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2742 | |
| 2743 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 2744 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 2745 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 2746 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 2747 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 2748 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 2749 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 2750 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575 |
| 2751 | |
| 2752 | }; |
| 2753 | */ |
| 2754 | |
| 2755 | void spc_RawPcmRec_sendDataDone(void) |
| 2756 | { |
| 2757 | if(!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){ |
| 2758 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 1); |
| 2759 | return; |
| 2760 | } |
| 2761 | |
| 2762 | gSpc_RawPcmRecord.isRecordDataWaiting = false; |
| 2763 | } |
| 2764 | |
| 2765 | |
| 2766 | /** |
| 2767 | run under AUDL/MED, when process message "SPC_ID_AUDIO_STRM_RAWPCMREC_DATA_NOTIFY" |
| 2768 | */ |
| 2769 | void spc_record_sendRawPcmData(void) |
| 2770 | { |
| 2771 | kal_uint32 add1, add2; |
| 2772 | kal_uint16 len1, len2; |
| 2773 | spcBufInfo info; |
| 2774 | bool sendResult = true; |
| 2775 | |
| 2776 | if( (!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)) ){ // prevent pcm data sending to AP after record off |
| 2777 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 4); |
| 2778 | return; |
| 2779 | } |
| 2780 | |
| 2781 | RawPcmRec_GetMicDataBufs(&add1, &len1, &add2, &len2); |
| 2782 | |
| 2783 | MD_TRC_RAWPCMREC_GET_DATA_BUFS(add1, len1, add2, len2); |
| 2784 | |
| 2785 | // change the len to unit of byte |
| 2786 | len1 <<=1; |
| 2787 | len2 <<=1; |
| 2788 | |
| 2789 | if(len1 == 0){ |
| 2790 | gSpc_RawPcmRecord.isRecordDataWaiting = false; |
| 2791 | MD_TRC_RAWPCMREC_GET_EMPTY_DATA(); |
| 2792 | } else { |
| 2793 | info.syncWord = 0x2A2A; |
| 2794 | info.type = AUD_CCCI_STRMBUF_TYPE_RAW_PCM_TYPE; |
| 2795 | info.length = len1 + len2; |
| 2796 | |
| 2797 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 2798 | (void *)add1, len1, (void *)add2, len2, |
| 2799 | SPCIO_MSG_FROM_SPC_RAW_PCM_REC_DATA_NOTIFY); |
| 2800 | |
| 2801 | if(sendResult == false) { |
| 2802 | gSpc_RawPcmRecord.isRecordDataWaiting = false; |
| 2803 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0); |
| 2804 | } |
| 2805 | } |
| 2806 | } |
| 2807 | |
| 2808 | #if 0 |
| 2809 | /* under construction !*/ |
| 2810 | /* under construction !*/ |
| 2811 | /* under construction !*/ |
| 2812 | /* under construction !*/ |
| 2813 | /* under construction !*/ |
| 2814 | /* under construction !*/ |
| 2815 | /* under construction !*/ |
| 2816 | /* under construction !*/ |
| 2817 | /* under construction !*/ |
| 2818 | /* under construction !*/ |
| 2819 | /* under construction !*/ |
| 2820 | /* under construction !*/ |
| 2821 | /* under construction !*/ |
| 2822 | /* under construction !*/ |
| 2823 | /* under construction !*/ |
| 2824 | /* under construction !*/ |
| 2825 | /* under construction !*/ |
| 2826 | /* under construction !*/ |
| 2827 | /* under construction !*/ |
| 2828 | /* under construction !*/ |
| 2829 | /* under construction !*/ |
| 2830 | /* under construction !*/ |
| 2831 | /* under construction !*/ |
| 2832 | /* under construction !*/ |
| 2833 | /* under construction !*/ |
| 2834 | /* under construction !*/ |
| 2835 | /* under construction !*/ |
| 2836 | /* under construction !*/ |
| 2837 | /* under construction !*/ |
| 2838 | /* under construction !*/ |
| 2839 | /* under construction !*/ |
| 2840 | /* under construction !*/ |
| 2841 | /* under construction !*/ |
| 2842 | /* under construction !*/ |
| 2843 | /* under construction !*/ |
| 2844 | /* under construction !*/ |
| 2845 | /* under construction !*/ |
| 2846 | /* under construction !*/ |
| 2847 | /* under construction !*/ |
| 2848 | #endif |
| 2849 | |
| 2850 | |
| 2851 | /** |
| 2852 | Send notification to AUDL/MED, prepare to get the recording data |
| 2853 | */ |
| 2854 | void spc_RawPcmRec_handler(void) |
| 2855 | { |
| 2856 | if( gSpc_RawPcmRecord.isRecordDataWaiting == true){ |
| 2857 | MD_TRC_SPC_M2A_DROP(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0); |
| 2858 | return; |
| 2859 | } |
| 2860 | |
| 2861 | gSpc_RawPcmRecord.isRecordDataWaiting = true; |
| 2862 | // Send notification to AUDL to begin data transfer |
| 2863 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_RAWPCMREC_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 2864 | |
| 2865 | |
| 2866 | return; |
| 2867 | } |
| 2868 | |
| 2869 | void spc_RawPcmRec_On(kal_uint8 dlPosition) |
| 2870 | { |
| 2871 | // RAW PCM Record |
| 2872 | gSpc_RawPcmRecord.isRecordDataWaiting = false; |
| 2873 | |
| 2874 | RAWPCMREC_Start(spc_RawPcmRec_handler, dlPosition); |
| 2875 | } |
| 2876 | |
| 2877 | void spc_RawPcmRec_Off(void) |
| 2878 | { |
| 2879 | RAWPCMREC_Stop(); |
| 2880 | } |
| 2881 | |
| 2882 | bool spc_RawPcmRec_getDataWaiting(void) |
| 2883 | { |
| 2884 | return(gSpc_RawPcmRecord.isRecordDataWaiting); |
| 2885 | } |
| 2886 | |
| 2887 | |
| 2888 | void spc_vmRec_sendMicDataDone(void) |
| 2889 | { |
| 2890 | if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){ |
| 2891 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1); |
| 2892 | return; |
| 2893 | } |
| 2894 | |
| 2895 | gSpc_VmRecord.isRecordDataWaiting = false; |
| 2896 | } |
| 2897 | |
| 2898 | |
| 2899 | /** |
| 2900 | run under AUDL/MED, when process message "SPC_ID_AUDIO_STRM_VMREC_DATA_NOTIFY" |
| 2901 | */ |
| 2902 | void spc_record_sendVmData(void) |
| 2903 | { |
| 2904 | |
| 2905 | kal_uint32 add1, add2; |
| 2906 | kal_uint16 len1, len2; |
| 2907 | kal_uint16 totalLenInWord; |
| 2908 | spcBufInfo info; |
| 2909 | bool sendResult = true; |
| 2910 | |
| 2911 | if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){ // prevent sening vm data to AP after record off |
| 2912 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 5); |
| 2913 | return; |
| 2914 | } |
| 2915 | |
| 2916 | // get data, length is word!! |
| 2917 | VmRec_GetReadBufs(&add1, &len1, &add2, &len2); |
| 2918 | totalLenInWord = len1+len2; |
| 2919 | |
| 2920 | MD_TRC_VM_SENDVMDATA_INFO(add1, len1, add2, len2); |
| 2921 | |
| 2922 | // change the len to unit of byte |
| 2923 | len1 <<= 1; |
| 2924 | len2 <<= 1; |
| 2925 | |
| 2926 | if(len1 == 0){ |
| 2927 | gSpc_VmRecord.isRecordDataWaiting = false; |
| 2928 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1); |
| 2929 | |
| 2930 | } else { |
| 2931 | info.syncWord = 0x2A2A; |
| 2932 | info.type = AUD_CCCI_STRMBUF_TYPE_VM_TYPE; |
| 2933 | info.length = len1 + len2; |
| 2934 | |
| 2935 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 2936 | (void *)add1, len1, (void *)add2, len2, |
| 2937 | SPCIO_MSG_FROM_SPC_VM_REC_DATA_NOTIFY); |
| 2938 | |
| 2939 | VmRec_ReadDataDone(totalLenInWord); |
| 2940 | |
| 2941 | if(sendResult == false) { |
| 2942 | gSpc_VmRecord.isRecordDataWaiting = false; |
| 2943 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 2);; |
| 2944 | } |
| 2945 | } |
| 2946 | } |
| 2947 | |
| 2948 | void spc_vmRec_handler(void) |
| 2949 | { |
| 2950 | if( gSpc_VmRecord.isRecordDataWaiting == true){ |
| 2951 | MD_TRC_SPC_M2A_DROP(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1); |
| 2952 | return; |
| 2953 | } |
| 2954 | |
| 2955 | gSpc_VmRecord.isRecordDataWaiting = true; |
| 2956 | |
| 2957 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_VMREC_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 2958 | |
| 2959 | return; |
| 2960 | } |
| 2961 | |
| 2962 | void spc_vmRec_On(void) |
| 2963 | { |
| 2964 | VMREC_Start(spc_vmRec_handler, false); |
| 2965 | |
| 2966 | gSpc_VmRecord.isRecordDataWaiting = false; |
| 2967 | } |
| 2968 | |
| 2969 | void spc_vmRec_Off(void) |
| 2970 | { |
| 2971 | gSpc_VmRecord.isRecordDataWaiting = true; |
| 2972 | |
| 2973 | VMREC_Stop(false); |
| 2974 | } |
| 2975 | |
| 2976 | // ---- Entry Points and Checking ----- |
| 2977 | |
| 2978 | /** |
| 2979 | @return: true for pass checking, flase for fail checking |
| 2980 | */ |
| 2981 | bool spc_recordStartCheck(MSG_SPC_APP_T app) |
| 2982 | { |
| 2983 | /* |
| 2984 | if(!IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE){ // prevent record on before EM data sending |
| 2985 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(app, app, 0); |
| 2986 | return false; |
| 2987 | } |
| 2988 | */ |
| 2989 | if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)){ // under SID generation state, record function is not provided |
| 2990 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, gSpc.spcAppUsage); |
| 2991 | |
| 2992 | ASSERT(0); |
| 2993 | |
| 2994 | return false; |
| 2995 | } |
| 2996 | |
| 2997 | // system is under idle state, we do not provide record function. |
| 2998 | if((!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) |
| 2999 | && (!IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE)) |
| 3000 | && (!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)) |
| 3001 | && (!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) |
| 3002 | && (!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) |
| 3003 | ){ |
| 3004 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(app, app, 3); |
| 3005 | |
| 3006 | // REMOVE |
| 3007 | // ASSERT(0); |
| 3008 | |
| 3009 | return false; |
| 3010 | } |
| 3011 | |
| 3012 | // defualt |
| 3013 | return true; |
| 3014 | } |
| 3015 | |
| 3016 | |
| 3017 | /** |
| 3018 | Open vm logging to AP side. This can concurrency with PCM record (spc_PcmRecordStart) |
| 3019 | */ |
| 3020 | void spc_VmRecordStart(void) |
| 3021 | { |
| 3022 | if(true!= spc_recordStartCheck(SPC_APP_VM_REC_USAGE)){ |
| 3023 | return; |
| 3024 | } |
| 3025 | |
| 3026 | // prevent re-entry |
| 3027 | if(IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){ |
| 3028 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 2); |
| 3029 | return; |
| 3030 | } |
| 3031 | |
| 3032 | spc_vmRec_On(); |
| 3033 | |
| 3034 | SET_SPC_APP_USAGE(SPC_APP_VM_REC_USAGE); |
| 3035 | } |
| 3036 | |
| 3037 | /** |
| 3038 | Pair with spc_VmRecordStart(), to close vm logging. |
| 3039 | */ |
| 3040 | void spc_VmRecordStop(void) |
| 3041 | { |
| 3042 | if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){ |
| 3043 | // just leave log and return |
| 3044 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1); |
| 3045 | return; |
| 3046 | } |
| 3047 | |
| 3048 | spc_vmRec_Off(); |
| 3049 | CLR_SPC_APP_USAGE(SPC_APP_VM_REC_USAGE); |
| 3050 | } |
| 3051 | |
| 3052 | |
| 3053 | /** |
| 3054 | Open RAW PCM record. This can concurrency with VM record (spc_VmRecordStart) |
| 3055 | Only support speech on record!! (Speech on for daca is NOT support) |
| 3056 | */ |
| 3057 | void spc_RawPcmRecordStart(kal_uint8 dlPosition) |
| 3058 | { |
| 3059 | if(true != spc_recordStartCheck(SPC_APP_RAW_PCM_REC_USAGE)){ |
| 3060 | return; |
| 3061 | } |
| 3062 | |
| 3063 | if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) // PCM record is not allow on DACA |
| 3064 | { |
| 3065 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 4); |
| 3066 | ASSERT(0); |
| 3067 | return; |
| 3068 | } |
| 3069 | |
| 3070 | // prevent re-entry |
| 3071 | if(IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){ |
| 3072 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 2); |
| 3073 | return; |
| 3074 | } |
| 3075 | |
| 3076 | #if 0 |
| 3077 | /* under construction !*/ |
| 3078 | /* under construction !*/ |
| 3079 | /* under construction !*/ |
| 3080 | /* under construction !*/ |
| 3081 | /* under construction !*/ |
| 3082 | /* under construction !*/ |
| 3083 | #endif |
| 3084 | |
| 3085 | spc_RawPcmRec_On(dlPosition); |
| 3086 | SET_SPC_APP_USAGE(SPC_APP_RAW_PCM_REC_USAGE); |
| 3087 | } |
| 3088 | |
| 3089 | |
| 3090 | void spc_RawPcmRecordStop(void) |
| 3091 | { |
| 3092 | if(!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){ |
| 3093 | // just leave log and return |
| 3094 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0); |
| 3095 | return; |
| 3096 | } |
| 3097 | |
| 3098 | spc_RawPcmRec_Off(); |
| 3099 | CLR_SPC_APP_USAGE(SPC_APP_RAW_PCM_REC_USAGE); |
| 3100 | } |
| 3101 | |
| 3102 | |
| 3103 | // ---------------------------------------------------------------------------- |
| 3104 | // PCMNWAY |
| 3105 | // ---------------------------------------------------------------------------- |
| 3106 | #define SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF 960 // unit is 16bit(word) |
| 3107 | #define SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF 960 // unit is 16bit(word), max = 48*20 = 960 |
| 3108 | #define SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF 1922 // unit is 16bit(word), max = 960*2 +2(agc use) |
| 3109 | #define SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF 960 // unit is 16bit(word) |
| 3110 | |
| 3111 | |
| 3112 | #define SPC_PNW_MSG_BUFFER_SE 1 // Bit 0 |
| 3113 | #define SPC_PNW_MSG_BUFFER_SPK 2 // Bit 1 |
| 3114 | #define SPC_PNW_MSG_BUFFER_MIC 4 // Bit 2 |
| 3115 | #define SPC_PNW_MSG_BUFFER_SD 8 // Bit 3 |
| 3116 | |
| 3117 | #define SPC_PNW_MSG_BIT_BAND 4 |
| 3118 | |
| 3119 | typedef enum |
| 3120 | { |
| 3121 | |
| 3122 | SPC_PCMNWAY_APP_TYPE_NONE = 0, |
| 3123 | #if 0 |
| 3124 | /* under construction !*/ |
| 3125 | /* under construction !*/ |
| 3126 | #endif |
| 3127 | |
| 3128 | SPC_PCMNWAY_APP_TYPE_UNSET = 0xffff, |
| 3129 | } SPC_PCMNWAY_APP_TYPE_T; |
| 3130 | |
| 3131 | typedef enum { |
| 3132 | SPC_PCMNWAY_FORMAT_P2W_NORMAL = 0, |
| 3133 | SPC_PCMNWAY_FORMAT_P2W_VOIP, |
| 3134 | SPC_PCMNWAY_FORMAT_P2W_CAL, //calibration |
| 3135 | SPC_PCMNWAY_FORMAT_P2W_WB_CAL, //wb calibration |
| 3136 | SPC_PCMNWAY_FORMAT_P2W_WB_NORMAL, //normal usage for WB p2w |
| 3137 | |
| 3138 | SPC_PCMNWAY_FORMAT_UNSET = 0xffff, |
| 3139 | }SPC_PCMNWAY_Format; |
| 3140 | |
| 3141 | |
| 3142 | typedef struct _SPC_PCMNWAY_T_ |
| 3143 | { |
| 3144 | kal_uint8 pnwBufInfo; //ref to SPC_PNW_MSG_BUFFER_x |
| 3145 | kal_uint8 pnwBand; //0: for narrow band, 1: for wide band |
| 3146 | // kal_uint16 pnwAppType; |
| 3147 | |
| 3148 | kal_bool pnwIsMicBufWaiting; |
| 3149 | kal_bool pnwIsSpkBufWaiting; |
| 3150 | |
| 3151 | kal_uint32 micBufSize; // unit is byte (8bit) |
| 3152 | kal_uint32 spkBufSize; // unit is byte (8bit) |
| 3153 | kal_uint32 seBufSize; |
| 3154 | kal_uint32 sdBufSize; |
| 3155 | |
| 3156 | |
| 3157 | }_SPC_PCMNWAY_T; |
| 3158 | |
| 3159 | static _SPC_PCMNWAY_T gSpc_Pcmnway; |
| 3160 | static kal_uint16 gSpc_Pcmnway_seBuf[SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF]; |
| 3161 | static kal_uint16 gSpc_Pcmnway_spkBuf[SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF]; |
| 3162 | static kal_uint16 gSpc_Pcmnway_micBuf[SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF]; |
| 3163 | static kal_uint16 gSpc_Pcmnway_sdBuf[SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF]; |
| 3164 | |
| 3165 | /* |
| 3166 | __attribute__ ((section ("NONCACHEDZI"))) static kal_uint16 tempUlData[179] |
| 3167 | // = { 0x4808,0x85, 0x156,0, 0x4,0, 0x146,0x9000, |
| 3168 | = { 0,0, 0,0, 0,0, 0,0, |
| 3169 | 1, 2, 3, 4, 5, 6, 7, 8, |
| 3170 | 0x2A2A, 0x2, 0x140, |
| 3171 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 3172 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 3173 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 3174 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 3175 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 3176 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 3177 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 3178 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575, |
| 3179 | |
| 3180 | 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, |
| 3181 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, |
| 3182 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, |
| 3183 | 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, |
| 3184 | 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78, |
| 3185 | 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b, |
| 3186 | 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588, |
| 3187 | 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575 |
| 3188 | }; |
| 3189 | */ |
| 3190 | |
| 3191 | /** |
| 3192 | MD -> AP, Run under AUDL/MED |
| 3193 | */ |
| 3194 | void spc_pcmNWay_sendUlData(void) |
| 3195 | { |
| 3196 | kal_bool sendResultMic = KAL_TRUE; |
| 3197 | kal_bool sendResultSd = KAL_TRUE; |
| 3198 | spcBufInfo info; |
| 3199 | |
| 3200 | if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ // prevent data sending after PCMNWAY is off |
| 3201 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 4); |
| 3202 | return; |
| 3203 | } |
| 3204 | |
| 3205 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) { |
| 3206 | info.syncWord = 0x2A2A; |
| 3207 | info.type = AUD_CCCI_STRMBUF_TYPE_PCM_GetFromMic; |
| 3208 | #if 0 //defined(__ENABLE_SPEECH_DVT__) |
| 3209 | /* under construction !*/ |
| 3210 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 3211 | info.length = gSpc_Pcmnway.micBufSize; |
| 3212 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3213 | |
| 3214 | // for debug |
| 3215 | /* |
| 3216 | sendResultMic = spcIO_sendDataViaCCCI( |
| 3217 | SPCIO_CCCI_MSG_CONSTRCUT_DATA_CMD(MSG_M2A_DATA_NOTIFY_PNW_ULREAD, 326), |
| 3218 | &(tempUlData[8]), 342); |
| 3219 | */ |
| 3220 | |
| 3221 | #if 0 //defined(__ENABLE_SPEECH_DVT__) |
| 3222 | /* under construction !*/ |
| 3223 | /* under construction !*/ |
| 3224 | /* under construction !*/ |
| 3225 | /* under construction !*/ |
| 3226 | /* under construction !*/ |
| 3227 | /* under construction !*/ |
| 3228 | /* under construction !*/ |
| 3229 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3230 | { |
| 3231 | sendResultMic = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 3232 | gSpc_Pcmnway_micBuf, gSpc_Pcmnway.micBufSize, NULL, 0, |
| 3233 | SPCIO_MSG_FROM_SPC_PNW_ULDATA_NOTIFY)); |
| 3234 | } |
| 3235 | |
| 3236 | } |
| 3237 | |
| 3238 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SD) { |
| 3239 | info.syncWord = 0x2A2A; |
| 3240 | info.type = AUD_CCCI_STRMBUF_TYPE_PCM_GetfromSD; |
| 3241 | info.length = gSpc_Pcmnway.sdBufSize; |
| 3242 | |
| 3243 | sendResultSd = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 3244 | gSpc_Pcmnway_sdBuf, gSpc_Pcmnway.sdBufSize, NULL, 0, |
| 3245 | SPCIO_MSG_FROM_SPC_PNW_ULDATA_NOTIFY)); |
| 3246 | } |
| 3247 | |
| 3248 | if((KAL_TRUE != sendResultMic) || (KAL_TRUE != sendResultSd)) { |
| 3249 | //clean up the read waiting flag when send fail to prevent blocking. |
| 3250 | gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE; |
| 3251 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 0); |
| 3252 | } |
| 3253 | } |
| 3254 | |
| 3255 | void spc_pcmNWay_sendUlDataDone(void) |
| 3256 | { |
| 3257 | |
| 3258 | if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ |
| 3259 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1); |
| 3260 | return; |
| 3261 | } |
| 3262 | gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE; |
| 3263 | |
| 3264 | } |
| 3265 | |
| 3266 | /** |
| 3267 | MD -> AP |
| 3268 | */ |
| 3269 | // void spc_pcmNWay_requestDlData(uint16 bufLength) |
| 3270 | void spc_pcmNWay_requestDlData(void) |
| 3271 | { |
| 3272 | kal_int32 sendResult; |
| 3273 | |
| 3274 | if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ // prevent data sending after PCMNWAY is off |
| 3275 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 5); |
| 3276 | return; |
| 3277 | } |
| 3278 | |
| 3279 | #if 0 // defined(__ENABLE_SPEECH_DVT__) |
| 3280 | /* under construction !*/ |
| 3281 | /* under construction !*/ |
| 3282 | /* under construction !*/ |
| 3283 | /* under construction !*/ |
| 3284 | /* under construction !*/ |
| 3285 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3286 | { |
| 3287 | sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_DLDATA_REQUEST, gSpc_Pcmnway.spkBufSize, 0); |
| 3288 | } |
| 3289 | // SPCIO_CCCI_MSG_ORG_CONSTRCUT_CMD(MSG_M2A_DATA_REQUEST_PNW_DLDATA, gSpc_Pcmnway.spkBufSize)); |
| 3290 | |
| 3291 | if(sendResult<0){ //clean waiting flag of speaker to prevent message blocking |
| 3292 | gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE; |
| 3293 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1); |
| 3294 | } |
| 3295 | } |
| 3296 | |
| 3297 | void spc_pcmNWay_writeDlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom) |
| 3298 | { |
| 3299 | |
| 3300 | spcBufInfo info; |
| 3301 | kal_uint16 curOffSet; |
| 3302 | kal_bool check; |
| 3303 | |
| 3304 | if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ |
| 3305 | MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 5); |
| 3306 | return; |
| 3307 | } |
| 3308 | |
| 3309 | check = (length>=sizeof(spcBufInfo)); |
| 3310 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: length=%d small then sizeof(spcBufInfo)", length); |
| 3311 | if(!check) |
| 3312 | goto leavePnwDlDone; |
| 3313 | curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom); |
| 3314 | |
| 3315 | |
| 3316 | //header checking |
| 3317 | check = (info.syncWord == 0xA2A2); |
| 3318 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord"); |
| 3319 | if(!check) |
| 3320 | goto leavePnwDlDone; |
| 3321 | check = ( (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSE) || (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSpk) ); |
| 3322 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord"); |
| 3323 | if(!check) |
| 3324 | goto leavePnwDlDone; |
| 3325 | check = (info.length == (length - sizeof(spcBufInfo))); |
| 3326 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord"); |
| 3327 | if(!check) |
| 3328 | goto leavePnwDlDone; |
| 3329 | |
| 3330 | if(info.length >0){ |
| 3331 | if (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSE) { //SE |
| 3332 | check = (info.length == gSpc_Pcmnway.seBufSize); |
| 3333 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: (se)info.length=%d", info.length); |
| 3334 | if(!check) |
| 3335 | goto leavePnwDlDone; |
| 3336 | SpcIo_GetDataFromAp(curOffSet, gSpc_Pcmnway.seBufSize, gSpc_Pcmnway_seBuf, comeFrom); |
| 3337 | } else { //SPK |
| 3338 | check = (info.length == gSpc_Pcmnway.spkBufSize); |
| 3339 | MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: (spk)info.length=%d", info.length); |
| 3340 | if(!check) |
| 3341 | goto leavePnwDlDone; |
| 3342 | SpcIo_GetDataFromAp(curOffSet, gSpc_Pcmnway.spkBufSize, gSpc_Pcmnway_spkBuf, comeFrom); |
| 3343 | |
| 3344 | } |
| 3345 | } |
| 3346 | |
| 3347 | leavePnwDlDone: |
| 3348 | gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE; |
| 3349 | } |
| 3350 | |
| 3351 | |
| 3352 | void spc_pcm4way_handler( void ) |
| 3353 | { |
| 3354 | // spc_pcm4wayDl_handler(); |
| 3355 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 3356 | if(pcmEx.running == 0){ |
| 3357 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3358 | return; |
| 3359 | } |
| 3360 | if( gSpc_Pcmnway.pnwIsSpkBufWaiting == KAL_TRUE){ |
| 3361 | MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 4); |
| 3362 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3363 | return; |
| 3364 | } |
| 3365 | |
| 3366 | // SE buffer |
| 3367 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SE) { |
| 3368 | gSpc_Pcmnway.seBufSize = ((PCM4WAY_PutToSE((const uint16*)gSpc_Pcmnway_seBuf)) << 1); |
| 3369 | } |
| 3370 | |
| 3371 | // Speaker buffer |
| 3372 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SPK) { |
| 3373 | gSpc_Pcmnway.spkBufSize = ((PCM4WAY_PutToSpk((const uint16*)gSpc_Pcmnway_spkBuf)) << 1); |
| 3374 | } |
| 3375 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3376 | // Transfer to AUDL |
| 3377 | // Send notification |
| 3378 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3379 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 3380 | if(pcmEx.running == 0){ |
| 3381 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3382 | return; |
| 3383 | } |
| 3384 | gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_TRUE; |
| 3385 | |
| 3386 | // -------------------------------------------------------------- |
| 3387 | // spc_pcm4wayUl_handler(); |
| 3388 | if( gSpc_Pcmnway.pnwIsMicBufWaiting == KAL_TRUE){ |
| 3389 | MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 3); |
| 3390 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3391 | return; |
| 3392 | } |
| 3393 | |
| 3394 | |
| 3395 | // Microphone buffer |
| 3396 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) { |
| 3397 | gSpc_Pcmnway.micBufSize = ((PCM4WAY_GetFromMic((uint16*)gSpc_Pcmnway_micBuf))<<1); |
| 3398 | } |
| 3399 | |
| 3400 | // SD buffer |
| 3401 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SD) { |
| 3402 | gSpc_Pcmnway.sdBufSize = ((PCM4WAY_GetFromSD((uint16*)gSpc_Pcmnway_sdBuf))<<1); |
| 3403 | } |
| 3404 | |
| 3405 | // Transfer to AUDL |
| 3406 | // Send notification |
| 3407 | gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_TRUE; |
| 3408 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3409 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_UL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3410 | |
| 3411 | |
| 3412 | } |
| 3413 | |
| 3414 | void spc_pcm2wayUl_handler( void ) |
| 3415 | { |
| 3416 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 3417 | if(pcmEx.running == 0){ |
| 3418 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3419 | return; |
| 3420 | } |
| 3421 | #if defined(__ENABLE_SPEECH_DVT__) |
| 3422 | kal_uint16 bufLen; |
| 3423 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3424 | |
| 3425 | if( gSpc_Pcmnway.pnwIsMicBufWaiting == KAL_TRUE){ |
| 3426 | MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1); |
| 3427 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3428 | return; |
| 3429 | } |
| 3430 | |
| 3431 | // Microphone buffer |
| 3432 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) { |
| 3433 | #if 0 //defined(__ENABLE_SPEECH_DVT__) |
| 3434 | /* under construction !*/ |
| 3435 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 3436 | gSpc_Pcmnway.micBufSize = ((PCM2WAY_GetFromMic((uint16*)gSpc_Pcmnway_micBuf))<<1); |
| 3437 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3438 | } |
| 3439 | gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_TRUE; |
| 3440 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3441 | // Transfer to AUDL |
| 3442 | // Send notification |
| 3443 | #if 0 // defined(__ENABLE_SPEECH_DVT__) |
| 3444 | /* under construction !*/ |
| 3445 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 3446 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_UL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3447 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3448 | |
| 3449 | |
| 3450 | } |
| 3451 | |
| 3452 | void spc_pcm2wayDl_handler( void ) |
| 3453 | { |
| 3454 | kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT); |
| 3455 | if(pcmEx.running == 0){ |
| 3456 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3457 | return; |
| 3458 | } |
| 3459 | #if 0 //defined(__ENABLE_SPEECH_DVT__) |
| 3460 | /* under construction !*/ |
| 3461 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3462 | |
| 3463 | if( gSpc_Pcmnway.pnwIsSpkBufWaiting == KAL_TRUE){ |
| 3464 | MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 2); |
| 3465 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3466 | return; |
| 3467 | } |
| 3468 | |
| 3469 | // Speaker buffer |
| 3470 | if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SPK) { |
| 3471 | #if 0 //defined(__ENABLE_SPEECH_DVT__) |
| 3472 | /* under construction !*/ |
| 3473 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 3474 | gSpc_Pcmnway.spkBufSize = ((PCM2WAY_PutToSpk((const uint16*)gSpc_Pcmnway_spkBuf))<<1); |
| 3475 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3476 | } |
| 3477 | gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_TRUE; |
| 3478 | kal_give_spinlock(pcmEx.PCMEXspinLockID); |
| 3479 | // Transfer to AUDL |
| 3480 | // Send notification |
| 3481 | #if 0 // defined(__ENABLE_SPEECH_DVT__) |
| 3482 | /* under construction !*/ |
| 3483 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 3484 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3485 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 3486 | |
| 3487 | |
| 3488 | } |
| 3489 | |
| 3490 | |
| 3491 | void spc_pcm2way_handler( void ) |
| 3492 | { |
| 3493 | spc_pcm2wayDl_handler(); |
| 3494 | spc_pcm2wayUl_handler(); |
| 3495 | } |
| 3496 | |
| 3497 | |
| 3498 | /** |
| 3499 | @param: |
| 3500 | [0:3] pcmnway buffer infor, please ref SPC_PNW_MSG_BUFFER_x |
| 3501 | [4]: band information: 0 narrow band, 1 wide band, |
| 3502 | @format: please reference SPC_PCMNWAY_Format. If its value is 0xFFFF(undefine), we decide it by band information. |
| 3503 | @appType: application type using in PCMNWAY. If its value is 0xFFFF(undefine), we will choose by ourself |
| 3504 | */ |
| 3505 | void spc_PcmNWayStart(kal_uint32 param, SPC_PCMNWAY_Format format) // , SPC_PCMNWAY_APP_TYPE_T appType) |
| 3506 | { |
| 3507 | uint32 cfgUL1 , cfgUL2, cfgUL3, cfgUL4, cfgDL; |
| 3508 | |
| 3509 | if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE) || IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ |
| 3510 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 3); |
| 3511 | |
| 3512 | ASSERT(0); |
| 3513 | |
| 3514 | return; |
| 3515 | } |
| 3516 | |
| 3517 | |
| 3518 | gSpc_Pcmnway.pnwBufInfo = (param & 0xf); // i.e. param & (SPC_PNW_MSG_BUFFER_SE|SPC_PNW_MSG_BUFFER_SPK|SPC_PNW_MSG_BUFFER_MIC|SPC_PNW_MSG_BUFFER_SD) |
| 3519 | gSpc_Pcmnway.pnwBand = ((param >> SPC_PNW_MSG_BIT_BAND) & 0x1); |
| 3520 | |
| 3521 | ASSERT(gSpc_Pcmnway.pnwBufInfo != 0); |
| 3522 | |
| 3523 | |
| 3524 | // buffer rest |
| 3525 | memset( (kal_uint8 *)gSpc_Pcmnway_seBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF*sizeof(uint16) ); |
| 3526 | memset( (kal_uint8 *)gSpc_Pcmnway_spkBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF*sizeof(uint16) ); |
| 3527 | memset( (kal_uint8 *)gSpc_Pcmnway_micBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF*sizeof(uint16) ); |
| 3528 | memset( (kal_uint8 *)gSpc_Pcmnway_sdBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF*sizeof(uint16) ); |
| 3529 | gSpc_Pcmnway.micBufSize = 0; |
| 3530 | gSpc_Pcmnway.spkBufSize = 0; |
| 3531 | gSpc_Pcmnway.seBufSize = 0; |
| 3532 | gSpc_Pcmnway.sdBufSize = 0; |
| 3533 | |
| 3534 | // reset wating |
| 3535 | gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE; |
| 3536 | gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE; |
| 3537 | |
| 3538 | |
| 3539 | // UL1 path |
| 3540 | cfgUL1 =DATA_SELECT_AFTER_ENH; |
| 3541 | if(SPC_PNW_MSG_BUFFER_MIC & gSpc_Pcmnway.pnwBufInfo ) { |
| 3542 | cfgUL1 |= USE_D2M_PATH; |
| 3543 | } |
| 3544 | if(SPC_PNW_MSG_BUFFER_SE & gSpc_Pcmnway.pnwBufInfo ) { |
| 3545 | cfgUL1 |= USE_M2D_PATH; |
| 3546 | } |
| 3547 | |
| 3548 | //UL2 path |
| 3549 | cfgUL2=DATA_SELECT_AFTER_ENH; |
| 3550 | //UL3 path |
| 3551 | cfgUL3=DATA_SELECT_AFTER_ENH; |
| 3552 | //UL4 path |
| 3553 | cfgUL4=DATA_SELECT_AFTER_ENH; |
| 3554 | |
| 3555 | // DL path |
| 3556 | cfgDL = 0; |
| 3557 | if(SPC_PNW_MSG_BUFFER_SD & gSpc_Pcmnway.pnwBufInfo ) { |
| 3558 | cfgDL |= USE_D2M_PATH; |
| 3559 | } |
| 3560 | if(SPC_PNW_MSG_BUFFER_SPK & gSpc_Pcmnway.pnwBufInfo ) { |
| 3561 | cfgDL |= USE_M2D_PATH; |
| 3562 | } |
| 3563 | |
| 3564 | if (IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) { // in call |
| 3565 | if( (SPC_PNW_MSG_BUFFER_SPK|SPC_PNW_MSG_BUFFER_MIC) == gSpc_Pcmnway.pnwBufInfo) { // 2way |
| 3566 | Del_PcmEx_Start(spc_pcm2wayDl_handler, spc_pcm2wayUl_handler, |
| 3567 | cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL); |
| 3568 | } else { |
| 3569 | Del_PcmEx_Start(spc_pcm4way_handler, NULL, |
| 3570 | cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL); |
| 3571 | } |
| 3572 | |
| 3573 | |
| 3574 | } else { // idle |
| 3575 | |
| 3576 | PCMEX_BAND band = PCMEX_BAND_UNSET; |
| 3577 | PCMEX_IDLE_ENH_SETTING enhSetting = PCMEX_IDLE_ENH_SETTING_WITH; // default with |
| 3578 | |
| 3579 | band = ((gSpc_Pcmnway.pnwBufInfo == 0)? PCMEX_BAND_NB : PCMEX_BAND_WB); |
| 3580 | #if 0 |
| 3581 | /* under construction !*/ |
| 3582 | /* under construction !*/ |
| 3583 | /* under construction !*/ |
| 3584 | /* under construction !*/ |
| 3585 | /* under construction !*/ |
| 3586 | #endif |
| 3587 | if( (SPC_PNW_MSG_BUFFER_SPK|SPC_PNW_MSG_BUFFER_MIC) == gSpc_Pcmnway.pnwBufInfo) { // 2way |
| 3588 | Idle_PcmEx_Start(spc_pcm2wayDl_handler, spc_pcm2wayUl_handler, |
| 3589 | cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL, |
| 3590 | band, enhSetting); |
| 3591 | } else { |
| 3592 | Idle_PcmEx_Start(spc_pcm4way_handler, NULL, |
| 3593 | cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL, |
| 3594 | band, enhSetting); |
| 3595 | } |
| 3596 | |
| 3597 | } |
| 3598 | |
| 3599 | |
| 3600 | // record the spc application usage status |
| 3601 | SET_SPC_APP_USAGE(SPC_APP_PCMNWAY_USAGE); |
| 3602 | |
| 3603 | } |
| 3604 | |
| 3605 | void spc_PcmNWayStop() |
| 3606 | { |
| 3607 | |
| 3608 | if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ |
| 3609 | // just leave log and return |
| 3610 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 0); |
| 3611 | return; |
| 3612 | } |
| 3613 | |
| 3614 | PcmEx_Stop(); |
| 3615 | |
| 3616 | // clear buffer |
| 3617 | gSpc_Pcmnway.pnwBufInfo = 0; |
| 3618 | gSpc_Pcmnway.pnwBand = 0; |
| 3619 | gSpc_Pcmnway.micBufSize = 0; |
| 3620 | gSpc_Pcmnway.spkBufSize = 0; |
| 3621 | gSpc_Pcmnway.seBufSize = 0; |
| 3622 | gSpc_Pcmnway.sdBufSize = 0; |
| 3623 | |
| 3624 | CLR_SPC_APP_USAGE(SPC_APP_PCMNWAY_USAGE); |
| 3625 | |
| 3626 | } |
| 3627 | |
| 3628 | // ---------------------------------------------------------------------------- |
| 3629 | // PCMMIXER |
| 3630 | // ---------------------------------------------------------------------------- |
| 3631 | typedef struct _SPC_PCMMIXER_T_ |
| 3632 | { |
| 3633 | kal_bool isUlBufWaiting; |
| 3634 | kal_bool isDlBufWaiting; |
| 3635 | }_SPC_PCMMIXER_T; |
| 3636 | |
| 3637 | static _SPC_PCMMIXER_T gSpc_PCMMixer; |
| 3638 | |
| 3639 | void spc_PCMMixer_UL_handler( void ) |
| 3640 | { |
| 3641 | #if 0 |
| 3642 | /* under construction !*/ |
| 3643 | /* under construction !*/ |
| 3644 | /* under construction !*/ |
| 3645 | /* under construction !*/ |
| 3646 | /* under construction !*/ |
| 3647 | /* under construction !*/ |
| 3648 | /* under construction !*/ |
| 3649 | /* under construction !*/ |
| 3650 | /* under construction !*/ |
| 3651 | /* under construction !*/ |
| 3652 | /* under construction !*/ |
| 3653 | /* under construction !*/ |
| 3654 | /* under construction !*/ |
| 3655 | /* under construction !*/ |
| 3656 | /* under construction !*/ |
| 3657 | /* under construction !*/ |
| 3658 | /* under construction !*/ |
| 3659 | /* under construction !*/ |
| 3660 | #endif |
| 3661 | |
| 3662 | // Send notification |
| 3663 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3664 | } |
| 3665 | |
| 3666 | void spc_PCMMixer_DL_handler( void ) |
| 3667 | { |
| 3668 | if(gSpc_PCMMixer.isDlBufWaiting){ |
| 3669 | MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 0); |
| 3670 | return; |
| 3671 | } |
| 3672 | gSpc_PCMMixer.isDlBufWaiting = KAL_TRUE; |
| 3673 | // Send notification |
| 3674 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3675 | } |
| 3676 | |
| 3677 | |
| 3678 | void spc_PCMMixerConfig(kal_bool isUlMix, kal_bool isDlMix, uint8 ulGainLevel, uint8 dlGainLevel) |
| 3679 | { |
| 3680 | PcmMixer_ConfigUl(isUlMix, ulGainLevel); |
| 3681 | PcmMixer_ConfigDl(isDlMix, dlGainLevel); |
| 3682 | } |
| 3683 | |
| 3684 | void spc_PCMMixerStart(kal_bool isUlMix, kal_bool isDlMix, uint8 ulGainLevel, uint8 dlGainLevel) |
| 3685 | { |
| 3686 | if(IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // application re-entry |
| 3687 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 5); |
| 3688 | return; |
| 3689 | } |
| 3690 | |
| 3691 | if((!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE))){ // bg sound on without any speech |
| 3692 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 3); |
| 3693 | return; |
| 3694 | } |
| 3695 | |
| 3696 | gSpc_PCMMixer.isDlBufWaiting = KAL_FALSE; |
| 3697 | PcmMixer_ConfigUl(isUlMix, ulGainLevel); |
| 3698 | PcmMixer_ConfigDl(isDlMix, dlGainLevel); |
| 3699 | |
| 3700 | PcmMixer_Start(spc_PCMMixer_DL_handler); |
| 3701 | SET_SPC_APP_USAGE(SPC_APP_MIXER_USAGE); |
| 3702 | } |
| 3703 | |
| 3704 | void spc_PCMMixerStop() |
| 3705 | { |
| 3706 | if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // application re-entry |
| 3707 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_PCMNWAY_USAGE, 0); |
| 3708 | return; |
| 3709 | } |
| 3710 | |
| 3711 | gSpc_PCMMixer.isDlBufWaiting = KAL_TRUE; |
| 3712 | PcmMixer_Stop(); |
| 3713 | |
| 3714 | CLR_SPC_APP_USAGE(SPC_APP_MIXER_USAGE); |
| 3715 | } |
| 3716 | |
| 3717 | void spc_pcmMixer_requestDlData(void) |
| 3718 | { |
| 3719 | kal_bool sendResult; |
| 3720 | if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // prevent data sending after mixer is off |
| 3721 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 1); |
| 3722 | return; |
| 3723 | } |
| 3724 | |
| 3725 | sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_DL_DATA_REQUEST, ((PcmMixer_QueryDlBufLen())<<1) , 0); |
| 3726 | if(KAL_FALSE == sendResult){ //clean waiting flag of speaker to prevent message blocking |
| 3727 | gSpc_PCMMixer.isDlBufWaiting = KAL_FALSE; |
| 3728 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 1); |
| 3729 | } |
| 3730 | |
| 3731 | } |
| 3732 | |
| 3733 | |
| 3734 | void spc_PCMMixer_writeDlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom) |
| 3735 | { |
| 3736 | spcBufInfo info; |
| 3737 | kal_bool check; |
| 3738 | |
| 3739 | if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ |
| 3740 | MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 5); |
| 3741 | return; |
| 3742 | } |
| 3743 | |
| 3744 | ASSERT(length>=sizeof(spcBufInfo)); |
| 3745 | |
| 3746 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom); |
| 3747 | |
| 3748 | |
| 3749 | //header checking |
| 3750 | check = (info.syncWord == 0xA2A2); |
| 3751 | MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow syncWord"); |
| 3752 | if(!check) |
| 3753 | goto leave; |
| 3754 | check = (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_MIXER_DL); |
| 3755 | MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow type"); |
| 3756 | if(!check) |
| 3757 | goto leave; |
| 3758 | check = (info.length == (length - sizeof(spcBufInfo))); |
| 3759 | MODEM_WARNING_MESSAGE(check, "PcmMixer: incorrect length"); |
| 3760 | if(!check) |
| 3761 | goto leave; |
| 3762 | |
| 3763 | PcmMixer_writeDlBuf((uint16 *)emDataBuf, info.length>>1); |
| 3764 | |
| 3765 | leave: |
| 3766 | gSpc_PCMMixer.isDlBufWaiting = false; |
| 3767 | } |
| 3768 | |
| 3769 | |
| 3770 | |
| 3771 | // ---------------------------------------------------------------------------- |
| 3772 | // ---------------------------------------------------------------------------- |
| 3773 | // PCMMIXER3 |
| 3774 | // ---------------------------------------------------------------------------- |
| 3775 | typedef struct _SPC_PCMMIXER3_T_ |
| 3776 | { |
| 3777 | kal_bool isUlBufWaiting; |
| 3778 | }_SPC_PCMMIXER3_T; |
| 3779 | |
| 3780 | static _SPC_PCMMIXER3_T gSpc_PCMMixer3; |
| 3781 | |
| 3782 | void spc_PCMMixer3_UL_handler( void ) |
| 3783 | { |
| 3784 | if(gSpc_PCMMixer3.isUlBufWaiting){ |
| 3785 | MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 0); |
| 3786 | return; |
| 3787 | } |
| 3788 | gSpc_PCMMixer3.isUlBufWaiting = KAL_TRUE; |
| 3789 | // Send notification |
| 3790 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER3_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3791 | } |
| 3792 | |
| 3793 | |
| 3794 | void spc_PCMMixer3Config(kal_bool isUlMix, uint8 ulGainLevel) |
| 3795 | { |
| 3796 | PcmMixer3_ConfigUl(isUlMix, ulGainLevel); |
| 3797 | } |
| 3798 | |
| 3799 | void spc_PCMMixer3Start(kal_bool isUlMix, uint8 ulGainLevel) |
| 3800 | { |
| 3801 | if(IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // application re-entry |
| 3802 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 5); |
| 3803 | return; |
| 3804 | } |
| 3805 | |
| 3806 | if((!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE))){ // bg sound on without any speech |
| 3807 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 3); |
| 3808 | return; |
| 3809 | } |
| 3810 | |
| 3811 | gSpc_PCMMixer3.isUlBufWaiting = KAL_FALSE; |
| 3812 | PcmMixer3_ConfigUl(isUlMix, ulGainLevel); |
| 3813 | //PcmMixer3_ConfigDl(isDlMix, dlGainLevel); |
| 3814 | |
| 3815 | PcmMixer3_Start(spc_PCMMixer3_UL_handler); |
| 3816 | SET_SPC_APP_USAGE(SPC_APP_MIXER3_USAGE); |
| 3817 | } |
| 3818 | |
| 3819 | void spc_PCMMixer3Stop() |
| 3820 | { |
| 3821 | if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // application re-entry |
| 3822 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_PCMNWAY_USAGE, 0); |
| 3823 | return; |
| 3824 | } |
| 3825 | |
| 3826 | gSpc_PCMMixer3.isUlBufWaiting = KAL_TRUE; |
| 3827 | PcmMixer3_Stop(); |
| 3828 | |
| 3829 | CLR_SPC_APP_USAGE(SPC_APP_MIXER3_USAGE); |
| 3830 | } |
| 3831 | |
| 3832 | void spc_pcmMixer3_requestUlData(void) |
| 3833 | { |
| 3834 | kal_bool sendResult; |
| 3835 | if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // prevent data sending after mixer is off |
| 3836 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 1); |
| 3837 | return; |
| 3838 | } |
| 3839 | |
| 3840 | sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_UL_DATA_REQUEST, ((PcmMixer3_QueryUlBufLen())<<1) , 0); |
| 3841 | if(KAL_FALSE == sendResult){ //clean waiting flag of speaker to prevent message blocking |
| 3842 | gSpc_PCMMixer3.isUlBufWaiting = KAL_FALSE; |
| 3843 | MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 1); |
| 3844 | } |
| 3845 | |
| 3846 | } |
| 3847 | |
| 3848 | void spc_PCMMixer3_writeUlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom) |
| 3849 | { |
| 3850 | spcBufInfo info; |
| 3851 | kal_bool check; |
| 3852 | |
| 3853 | if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ |
| 3854 | MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 5); |
| 3855 | return; |
| 3856 | } |
| 3857 | |
| 3858 | ASSERT(length>=sizeof(spcBufInfo)); |
| 3859 | |
| 3860 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom); |
| 3861 | |
| 3862 | |
| 3863 | //header checking |
| 3864 | check = (info.syncWord == 0xA2A2); |
| 3865 | MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow syncWord"); |
| 3866 | if(!check) |
| 3867 | goto leave; |
| 3868 | check = (info.type == AUD_CCCI_STRMBUF_TYPE_TELEPHONYTX_UL); |
| 3869 | MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow type"); |
| 3870 | if(!check) |
| 3871 | goto leave; |
| 3872 | check = (info.length == (length - sizeof(spcBufInfo))); |
| 3873 | MODEM_WARNING_MESSAGE(check, "PcmMixer: incorrect length"); |
| 3874 | if(!check) |
| 3875 | goto leave; |
| 3876 | |
| 3877 | PcmMixer3_writeUlBuf((uint16 *)emDataBuf, info.length>>1); |
| 3878 | |
| 3879 | leave: |
| 3880 | gSpc_PCMMixer3.isUlBufWaiting = false; |
| 3881 | } |
| 3882 | |
| 3883 | |
| 3884 | |
| 3885 | // ---------------------------------------------------------------------------- |
| 3886 | // Background Sound |
| 3887 | // ---------------------------------------------------------------------------- |
| 3888 | typedef struct _SPC_BGSND_T_ |
| 3889 | { |
| 3890 | kal_uint8 ulGainLevel; |
| 3891 | kal_uint8 dlGainLevel; |
| 3892 | |
| 3893 | kal_bool isDataWaiting; |
| 3894 | kal_uint32 id; |
| 3895 | }_SPC_BGSND_T; |
| 3896 | |
| 3897 | static _SPC_BGSND_T gSpc_bgSnd; |
| 3898 | |
| 3899 | /** |
| 3900 | Run under MED/AUDL Thread |
| 3901 | */ |
| 3902 | void spc_bgSnd_writeDataDone(kal_uint16 offset, kal_uint16 length, SPC_MSG_FROM_T comeFrom) |
| 3903 | { |
| 3904 | spcBufInfo info; |
| 3905 | kal_bool check; |
| 3906 | |
| 3907 | if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // prevent data sending after background sound is off |
| 3908 | MD_TRC_SPC_M2A_DROP(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 1); |
| 3909 | return; |
| 3910 | } |
| 3911 | |
| 3912 | MD_TRC_SPC_BGSND_WRITEDATADONE_ENTER(); |
| 3913 | |
| 3914 | check = (length >= sizeof(spcBufInfo)); |
| 3915 | MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: small data size"); |
| 3916 | if(!check) |
| 3917 | goto bgsLeave; |
| 3918 | |
| 3919 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom); |
| 3920 | |
| 3921 | //header check |
| 3922 | check = (info.syncWord == 0xA2A2); |
| 3923 | MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow syncWord"); |
| 3924 | if(!check) |
| 3925 | goto bgsLeave; |
| 3926 | check = (info.type == AUD_CCCI_STRMBUF_TYPE_BGS_TYPE); |
| 3927 | MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow type"); |
| 3928 | if(!check) |
| 3929 | goto bgsLeave; |
| 3930 | check = (info.length == (length-6)); |
| 3931 | MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow length"); |
| 3932 | if(!check) |
| 3933 | goto bgsLeave; |
| 3934 | |
| 3935 | if(info.length>0){ |
| 3936 | EXT_BGSND_WriteSrcBuffer(gSpc_bgSnd.id, emDataBuf, (kal_int32) info.length, BGSND_DL_PROCESS); |
| 3937 | EXT_BGSND_WriteSrcBuffer(gSpc_bgSnd.id, emDataBuf, (kal_int32) info.length, BGSND_UL_PROCESS); |
| 3938 | } |
| 3939 | |
| 3940 | bgsLeave: |
| 3941 | gSpc_bgSnd.isDataWaiting = KAL_FALSE; |
| 3942 | |
| 3943 | MD_TRC_SPC_BGSND_WRITEDATADONE_LEAVE(); |
| 3944 | } |
| 3945 | |
| 3946 | /** |
| 3947 | Run under MED/AUDL Thread |
| 3948 | */ |
| 3949 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| 3950 | void spc_bgSnd_requestData(void) |
| 3951 | { |
| 3952 | int32 bLen; |
| 3953 | MD_TRC_SPC_BGSND_REQUESTDATA_ENTER(); |
| 3954 | if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // prevent data sending after background sound is off |
| 3955 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 1); |
| 3956 | return; |
| 3957 | } |
| 3958 | |
| 3959 | if(gSpc_bgSnd.isDataWaiting){ |
| 3960 | MD_TRC_SPC_M2A_DROP(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 0); |
| 3961 | return; |
| 3962 | } |
| 3963 | bLen = MIN( EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_UL_PROCESS), EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS)); |
| 3964 | //bLen = BGSND_GetFreeSpace(); //unit is 16bit in BGSND_GetFreeSpace() return |
| 3965 | // bLen &= ~0x1; |
| 3966 | MD_TRC_SPC_BGSND_REQUESTDATA_INFO(bLen, BGSND_RB_DEFAULT_THRESHOLD); |
| 3967 | |
| 3968 | if( bLen >= BGSND_RB_DEFAULT_THRESHOLD ) { |
| 3969 | |
| 3970 | // send data request to AP |
| 3971 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_BGS_DATA_REQUEST, (bLen<<1) , 0); |
| 3972 | gSpc_bgSnd.isDataWaiting = KAL_TRUE; |
| 3973 | |
| 3974 | } |
| 3975 | MD_TRC_SPC_BGSND_REQUESTDATA_LEAVE(); |
| 3976 | |
| 3977 | } |
| 3978 | |
| 3979 | /** |
| 3980 | Call back handler from HISR |
| 3981 | */ |
| 3982 | void spc_BGSND_DLHdr(void) |
| 3983 | { |
| 3984 | MD_TRC_SPC_BGSND_DLHDR_ENTER(); |
| 3985 | EXT_BGSND_WriteExtBuffer(gSpc_bgSnd.id, 1, BGSND_DL_PROCESS); |
| 3986 | EXT_BGSND_WriteExtBuffer(gSpc_bgSnd.id, 1, BGSND_UL_PROCESS); |
| 3987 | |
| 3988 | if(KAL_FALSE == gSpc_bgSnd.isDataWaiting) { |
| 3989 | int bLen = MIN( EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS), EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS)); |
| 3990 | if( (bLen >= BGSND_RB_DEFAULT_THRESHOLD) && (EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS) == EXT_SRC_STATE_RUN) ) { |
| 3991 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_BGSND_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 3992 | } |
| 3993 | } |
| 3994 | MD_TRC_SPC_BGSND_DLHDR_LEAVE(); |
| 3995 | } |
| 3996 | |
| 3997 | /** |
| 3998 | Call back handler from AUDIO task when bgSnd is off |
| 3999 | */ |
| 4000 | void spc_bgSnd_closeHandler(void) |
| 4001 | { |
| 4002 | |
| 4003 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_CONTROL_BGSND_CLOSE, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 4004 | } |
| 4005 | |
| 4006 | void spc_BgSndStart(void) |
| 4007 | { |
| 4008 | #ifdef SPH_CHIP_BACK_PHONECALL_USE |
| 4009 | return; |
| 4010 | #endif |
| 4011 | |
| 4012 | |
| 4013 | if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // application re-entry |
| 4014 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 5); |
| 4015 | return; |
| 4016 | } |
| 4017 | |
| 4018 | /* |
| 4019 | if(!IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE){ // prevent background sound on before EM data sending |
| 4020 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 4); |
| 4021 | return; |
| 4022 | } |
| 4023 | */ |
| 4024 | if((!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) && (!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE))){ // bg sound on without any speech |
| 4025 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 3); |
| 4026 | return; |
| 4027 | } |
| 4028 | |
| 4029 | if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)){ |
| 4030 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 2); |
| 4031 | |
| 4032 | ASSERT(0); |
| 4033 | |
| 4034 | return; |
| 4035 | } |
| 4036 | MD_TRC_SPC_BGSNDSTART_ENTER(); |
| 4037 | gSpc_bgSnd.isDataWaiting = KAL_FALSE; |
| 4038 | gSpc_bgSnd.id = EXT_BGSND_Start(spc_bgSnd_closeHandler, spc_BGSND_DLHdr, NULL, gSpc_bgSnd.dlGainLevel, gSpc_bgSnd.ulGainLevel); |
| 4039 | SET_SPC_APP_USAGE(SPC_APP_BGSND_USAGE); |
| 4040 | MD_TRC_SPC_BGSNDSTART_LEAVE(); |
| 4041 | } |
| 4042 | |
| 4043 | void spc_BgSndStop(void) |
| 4044 | { |
| 4045 | |
| 4046 | if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ |
| 4047 | // just leave log and return, |
| 4048 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 0); |
| 4049 | |
| 4050 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0); |
| 4051 | return; |
| 4052 | } |
| 4053 | |
| 4054 | // to avoid to many data request |
| 4055 | gSpc_bgSnd.isDataWaiting = KAL_TRUE; |
| 4056 | MD_TRC_SPC_BGSNDSTOP_ENTER(); |
| 4057 | EXT_BGSND_Flush(gSpc_bgSnd.id); |
| 4058 | MD_TRC_SPC_BGSNDSTOP_LEAVE(); |
| 4059 | } |
| 4060 | |
| 4061 | void spc_BgSndForceClose(void) |
| 4062 | { |
| 4063 | if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // due to AP close process may interrupt by EPOF command, so the checked is need |
| 4064 | // just leave log and return, |
| 4065 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 6); |
| 4066 | |
| 4067 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0); |
| 4068 | return; |
| 4069 | } |
| 4070 | |
| 4071 | EXT_BGSND_Close(gSpc_bgSnd.id); |
| 4072 | CLR_SPC_APP_USAGE(SPC_APP_BGSND_USAGE); |
| 4073 | } |
| 4074 | |
| 4075 | void spc_BgSndClose(void) |
| 4076 | { |
| 4077 | spc_BgSndForceClose(); |
| 4078 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0); |
| 4079 | } |
| 4080 | |
| 4081 | |
| 4082 | /** |
| 4083 | @ulGainLevel: 0~7 levels, mapping to 0~32767 |
| 4084 | @dlGainLevel: 0~7 levels, mapping to 0~32767 |
| 4085 | */ |
| 4086 | void spc_BgSndConfig(kal_uint8 ulGainLevel, kal_uint8 dlGainLevel) |
| 4087 | { |
| 4088 | MD_TRC_SPC_BGSNDCONFIG_ENTER(); |
| 4089 | gSpc_bgSnd.ulGainLevel = ulGainLevel; |
| 4090 | gSpc_bgSnd.dlGainLevel = dlGainLevel; |
| 4091 | |
| 4092 | // when application is running, update hte gain directly |
| 4093 | if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ |
| 4094 | EXT_BGSND_ConfigMixer(gSpc_bgSnd.id, KAL_TRUE, gSpc_bgSnd.dlGainLevel, BGSND_DL_PROCESS); |
| 4095 | EXT_BGSND_ConfigMixer(gSpc_bgSnd.id, KAL_TRUE, gSpc_bgSnd.ulGainLevel, BGSND_UL_PROCESS); |
| 4096 | } |
| 4097 | MD_TRC_SPC_BGSNDCONFIG_LEAVE(); |
| 4098 | } |
| 4099 | // ---------------------------------------------------------------------------- |
| 4100 | // CTM |
| 4101 | // ---------------------------------------------------------------------------- |
| 4102 | |
| 4103 | #ifdef __CTM_SUPPORT__ |
| 4104 | |
| 4105 | #if defined(__CCCI_OVER_SDIO_SUPPORT__) |
| 4106 | #define SPC_CTM_DUMP_DEBUG_BUF_SIZE (165 *4 ) |
| 4107 | #else |
| 4108 | #define SPC_CTM_DUMP_DEBUG_BUF_SIZE (163 *4 ) |
| 4109 | #endif |
| 4110 | |
| 4111 | typedef struct _SPC_CTM_T_ |
| 4112 | { |
| 4113 | kal_bool isDumpDebugFile; |
| 4114 | kal_bool isDumpDataWaiting; |
| 4115 | kal_uint16 dumpDebugBuf[SPC_CTM_DUMP_DEBUG_BUF_SIZE]; |
| 4116 | kal_uint16 dumpDebugBufPtr; |
| 4117 | kal_uint16 mode; |
| 4118 | kal_bool isPCM; |
| 4119 | }_SPC_CTM_T; |
| 4120 | |
| 4121 | |
| 4122 | #define SPC_CTM_BUFFER_SIZE 44600 // 44596 |
| 4123 | __attribute__((aligned (4)))static kal_uint8 gSpc_Ctm_buf[SPC_CTM_BUFFER_SIZE]; |
| 4124 | |
| 4125 | static _SPC_CTM_T gSpc_ctm; |
| 4126 | |
| 4127 | |
| 4128 | void spc_ctm_sendDumpDebugData(void) |
| 4129 | { |
| 4130 | kal_bool sendResult; |
| 4131 | |
| 4132 | if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){ // prevent data sending after CTM is off |
| 4133 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 1); |
| 4134 | return; |
| 4135 | } |
| 4136 | |
| 4137 | |
| 4138 | #if defined(__CCCI_OVER_SDIO_SUPPORT__) |
| 4139 | { |
| 4140 | uint8 *ptr = (uint8 *)gSpc_ctm.dumpDebugBuf; |
| 4141 | spcExtendedBufInfo *pinfo; |
| 4142 | int i, len; |
| 4143 | |
| 4144 | sendResult=true; |
| 4145 | for(i=1; i<=4; i++){ |
| 4146 | pinfo = (spcExtendedBufInfo *)ptr; |
| 4147 | ASSERT(pinfo->syncWord == 0x1234); |
| 4148 | // ASSERT(pinfo->curIdx == i); |
| 4149 | // ASSERT(pinfo->totalIdx == 4); |
| 4150 | |
| 4151 | len = sizeof(spcExtendedBufInfo)+ pinfo->length; |
| 4152 | sendResult &= SpcIO_WriteDataToAp(NULL, 0, ptr, (len), NULL, 0, SPCIO_MSG_FROM_SPC_CTM_DEBUG_DATA_NOTIFY); |
| 4153 | |
| 4154 | ptr += len; |
| 4155 | } |
| 4156 | |
| 4157 | if(KAL_TRUE != sendResult) { |
| 4158 | gSpc_ctm.dumpDebugBufPtr = 0; |
| 4159 | gSpc_ctm.isDumpDataWaiting = KAL_FALSE; |
| 4160 | |
| 4161 | } |
| 4162 | } |
| 4163 | #else |
| 4164 | sendResult = (SpcIO_WriteDataToAp(NULL, 0, |
| 4165 | gSpc_ctm.dumpDebugBuf, ((gSpc_ctm.dumpDebugBufPtr)<<1), NULL, 0, |
| 4166 | SPCIO_MSG_FROM_SPC_CTM_DEBUG_DATA_NOTIFY)); |
| 4167 | |
| 4168 | if(KAL_TRUE != sendResult) { |
| 4169 | //clean up the read waiting flag when send fail to prevent blocking. |
| 4170 | gSpc_ctm.dumpDebugBufPtr = 0; |
| 4171 | gSpc_ctm.isDumpDataWaiting = KAL_FALSE; |
| 4172 | |
| 4173 | } |
| 4174 | #endif |
| 4175 | } |
| 4176 | |
| 4177 | void spc_ctm_sendDumpDebugDataDone(void) |
| 4178 | { |
| 4179 | if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){ |
| 4180 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 2); |
| 4181 | return; |
| 4182 | } |
| 4183 | gSpc_ctm.dumpDebugBufPtr = 0; |
| 4184 | gSpc_ctm.isDumpDataWaiting = false; |
| 4185 | } |
| 4186 | |
| 4187 | static void spc_ctm_handler(L1Ctm_Event event, void *param) |
| 4188 | { |
| 4189 | |
| 4190 | } |
| 4191 | |
| 4192 | /** |
| 4193 | This function is running under L1audioTask, as a callback function |
| 4194 | @length: length of buffer unit in 16bit. |
| 4195 | */ |
| 4196 | void spc_Ctm_DebugCallback(uint16 pos, uint16 *buffer, uint16 length, bool isDone) |
| 4197 | { |
| 4198 | |
| 4199 | if(gSpc_ctm.isDumpDebugFile == false) |
| 4200 | { |
| 4201 | return; |
| 4202 | } |
| 4203 | |
| 4204 | |
| 4205 | if(true == isDone ){ |
| 4206 | |
| 4207 | if( KAL_TRUE == gSpc_ctm.isDumpDataWaiting){ |
| 4208 | MD_TRC_SPC_M2A_DROP(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 1); |
| 4209 | return; |
| 4210 | } |
| 4211 | |
| 4212 | // send request to MED |
| 4213 | SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_CTM_DUMP_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR); |
| 4214 | gSpc_ctm.isDumpDataWaiting = KAL_TRUE; |
| 4215 | |
| 4216 | } else { |
| 4217 | #if defined(__CCCI_OVER_SDIO_SUPPORT__) |
| 4218 | spcExtendedBufInfo info; |
| 4219 | #else |
| 4220 | spcBufInfo info; |
| 4221 | #endif |
| 4222 | if( KAL_TRUE == gSpc_ctm.isDumpDataWaiting){ |
| 4223 | MD_TRC_SPC_M2A_DROP(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 0); |
| 4224 | return; |
| 4225 | } |
| 4226 | #if defined(__CCCI_OVER_SDIO_SUPPORT__) |
| 4227 | info.syncWord = 0x1234; |
| 4228 | #else |
| 4229 | info.syncWord = 0x2A2A; |
| 4230 | #endif |
| 4231 | info.length = length*sizeof(uint16); |
| 4232 | |
| 4233 | switch(pos){ |
| 4234 | case UL_IN_WRITE_FILE_REQUEST: // 1 |
| 4235 | info.type = AUD_CCCI_STRMBUF_TYPE_CTM_UL_IN; |
| 4236 | break; |
| 4237 | case DL_IN_WRITE_FILE_REQUEST: // 2 |
| 4238 | info.type = AUD_CCCI_STRMBUF_TYPE_CTM_DL_IN; |
| 4239 | break; |
| 4240 | case UL_OUT_WRITE_FILE_REQUEST: // 3 |
| 4241 | info.type = AUD_CCCI_STRMBUF_TYPE_CTM_UL_OUT; |
| 4242 | break; |
| 4243 | case DL_OUT_WRITE_FILE_REQUEST: // 4 |
| 4244 | info.type = AUD_CCCI_STRMBUF_TYPE_CTM_DL_OUT; |
| 4245 | break; |
| 4246 | default: |
| 4247 | ASSERT(0); |
| 4248 | } |
| 4249 | |
| 4250 | #if defined(__CCCI_OVER_SDIO_SUPPORT__) |
| 4251 | info.curIdx = 1; |
| 4252 | info.totalIdx = 1; |
| 4253 | memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), &info, sizeof(spcExtendedBufInfo)); |
| 4254 | |
| 4255 | gSpc_ctm.dumpDebugBufPtr += 5; // header= sizeof(spcBufInfo) |
| 4256 | #else |
| 4257 | memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), &info, sizeof(spcBufInfo)); |
| 4258 | gSpc_ctm.dumpDebugBufPtr += 3; // header= sizeof(spcBufInfo) |
| 4259 | #endif |
| 4260 | |
| 4261 | memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), buffer, length*sizeof(uint16)); |
| 4262 | gSpc_ctm.dumpDebugBufPtr +=length; |
| 4263 | |
| 4264 | ASSERT(gSpc_ctm.dumpDebugBufPtr <= SPC_CTM_DUMP_DEBUG_BUF_SIZE); // overflow protection |
| 4265 | } |
| 4266 | } |
| 4267 | |
| 4268 | /** |
| 4269 | @mode: 0: DIRECT_MODE, 1: BAUDOT_MODE |
| 4270 | */ |
| 4271 | void spc_NormalCtmStart(kal_uint16 mode){ |
| 4272 | if (L1Ctm_GetMemReq() > SPC_CTM_BUFFER_SIZE) |
| 4273 | ASSERT(0); |
| 4274 | |
| 4275 | gSpc_ctm.isDumpDataWaiting = false; |
| 4276 | memset(gSpc_ctm.dumpDebugBuf, 0, sizeof(uint16)*SPC_CTM_DUMP_DEBUG_BUF_SIZE); |
| 4277 | gSpc_ctm.dumpDebugBufPtr=0; |
| 4278 | |
| 4279 | L1Ctm_Open( mode, spc_ctm_handler, gSpc_Ctm_buf, SPC_CTM_BUFFER_SIZE, spc_Ctm_DebugCallback); |
| 4280 | SET_SPC_APP_USAGE(SPC_APP_CTM_USAGE); |
| 4281 | } |
| 4282 | void spc_C2KCtmStart(kal_uint16 mode){ |
| 4283 | if(FULL_MODE == mode){ |
| 4284 | SAL_C2K_SetTTYStatus(true, true); |
| 4285 | l1sp_setCtmSpeStatus(1); |
| 4286 | kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__); |
| 4287 | SetSpeechEnhancement(false); |
| 4288 | l1sp_setCtmSpeStatus(0); |
| 4289 | } |
| 4290 | else if(VCO_MODE == mode){ |
| 4291 | SAL_C2K_SetTTYStatus(false, true); |
| 4292 | l1sp_setCtmSpeStatus(1); |
| 4293 | kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__); |
| 4294 | SetSPEnhancePath(SpeechEnh_UL); |
| 4295 | } |
| 4296 | else if(HCO_MODE == mode){ |
| 4297 | SAL_C2K_SetTTYStatus(true, false); |
| 4298 | l1sp_setCtmSpeStatus(1); |
| 4299 | kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__); |
| 4300 | SetSPEnhancePath(SpeechEnh_DL); |
| 4301 | } |
| 4302 | gSpc_ctm.isPCM = false; |
| 4303 | } |
| 4304 | kal_uint16 spc_getCtmMode(){ |
| 4305 | return gSpc_ctm.mode; |
| 4306 | } |
| 4307 | |
| 4308 | kal_bool spc_isPCM(){ |
| 4309 | kal_prompt_trace(MOD_L1SP, "spc_isPCM = %d",gSpc_ctm.isPCM); |
| 4310 | return gSpc_ctm.isPCM; |
| 4311 | } |
| 4312 | |
| 4313 | void spc_CtmStart(kal_uint16 mode) |
| 4314 | { |
| 4315 | gSpc_ctm.mode = mode; |
| 4316 | if(L1SP_STATE_C2K_SPEECH_ON == L1SP_GetState()){ |
| 4317 | spc_C2KCtmStart(mode); |
| 4318 | } |
| 4319 | else{ |
| 4320 | spc_NormalCtmStart(mode); |
| 4321 | gSpc_ctm.isPCM = true; |
| 4322 | } |
| 4323 | } |
| 4324 | |
| 4325 | void spc_NormalCtmStop(void){ |
| 4326 | |
| 4327 | if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){ |
| 4328 | // just leave log and return |
| 4329 | MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 0); |
| 4330 | return; |
| 4331 | } |
| 4332 | |
| 4333 | L1Ctm_Stop(); |
| 4334 | |
| 4335 | CLR_SPC_APP_USAGE(SPC_APP_CTM_USAGE); |
| 4336 | } |
| 4337 | void spc_CtmStop(void) |
| 4338 | { |
| 4339 | l1sp_setCtmSpeStatus(1); |
| 4340 | SetSpeechEnhancement(true); |
| 4341 | SAL_C2K_SetTTYStatus(false, false); |
| 4342 | |
| 4343 | if(!gSpc_ctm.isPCM){ |
| 4344 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, 0, 0); |
| 4345 | } |
| 4346 | else{ |
| 4347 | spc_NormalCtmStop(); |
| 4348 | } |
| 4349 | |
| 4350 | gSpc_ctm.isPCM = false; |
| 4351 | gSpc_ctm.mode = 0; |
| 4352 | } |
| 4353 | |
| 4354 | void spc_CtmClose(void) |
| 4355 | { |
| 4356 | kal_prompt_trace(MOD_L1SP, "[spc_CtmClose] Enter"); |
| 4357 | L1Ctm_Close(); |
| 4358 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, 0, 0); |
| 4359 | kal_prompt_trace(MOD_L1SP, "[spc_CtmClose] Leave"); |
| 4360 | } |
| 4361 | |
| 4362 | void spc_RttConfig(uint16 type){ |
| 4363 | |
| 4364 | kal_prompt_trace(MOD_L1SP, "[spc_RttConfig] %d", type); |
| 4365 | if(type==1) |
| 4366 | L1Ctm_RTTOpen(); |
| 4367 | else |
| 4368 | L1Ctm_RTTClose(); |
| 4369 | } |
| 4370 | |
| 4371 | |
| 4372 | /* |
| 4373 | [REMIND] This function "L1Ctm_StartNegotiation" is not called from AP side. |
| 4374 | The actual user is L1D in modem. So phase it out. |
| 4375 | |
| 4376 | void spc_CtmNegotiation(void) |
| 4377 | { |
| 4378 | L1Ctm_StartNegotiation(); |
| 4379 | } |
| 4380 | */ |
| 4381 | |
| 4382 | void spc_CtmDebugConfig(kal_bool turnOn) |
| 4383 | { |
| 4384 | gSpc_ctm.isDumpDebugFile = turnOn; |
| 4385 | } |
| 4386 | |
| 4387 | #endif // __CTM_SUPPORT__ |
| 4388 | |
| 4389 | // ---------------------------------------------------------------------------- |
| 4390 | // Parameter Setting like EM |
| 4391 | // ---------------------------------------------------------------------------- |
| 4392 | |
| 4393 | #if 0 |
| 4394 | /* under construction !*/ |
| 4395 | /* under construction !*/ |
| 4396 | /* under construction !*/ |
| 4397 | /* under construction !*/ |
| 4398 | /* under construction !*/ |
| 4399 | /* under construction !*/ |
| 4400 | /* under construction !*/ |
| 4401 | /* under construction !*/ |
| 4402 | /* under construction !*/ |
| 4403 | /* under construction !*/ |
| 4404 | /* under construction !*/ |
| 4405 | /* under construction !*/ |
| 4406 | /* under construction !*/ |
| 4407 | /* under construction !*/ |
| 4408 | /* under construction !*/ |
| 4409 | /* under construction !*/ |
| 4410 | /* under construction !*/ |
| 4411 | /* under construction !*/ |
| 4412 | /* under construction !*/ |
| 4413 | /* under construction !*/ |
| 4414 | /* under construction !*/ |
| 4415 | /* under construction !*/ |
| 4416 | /* under construction !*/ |
| 4417 | /* under construction !*/ |
| 4418 | /* under construction !*/ |
| 4419 | /* under construction !*/ |
| 4420 | /* under construction !*/ |
| 4421 | /* under construction !*/ |
| 4422 | /* under construction !*/ |
| 4423 | /* under construction !*/ |
| 4424 | /* under construction !*/ |
| 4425 | #endif |
| 4426 | |
| 4427 | |
| 4428 | void spc_ReceiveViberationSpkParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom) |
| 4429 | { |
| 4430 | spcBufInfo info; |
| 4431 | AUDIO_VIBSPK_PARAMETER_STRUCT *vibSpkParam; //buffer reuse |
| 4432 | |
| 4433 | vibSpkParam = (AUDIO_VIBSPK_PARAMETER_STRUCT *)(&emDataBuf); //buffer reuse |
| 4434 | |
| 4435 | //get data |
| 4436 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, vibSpkParam, comeFrom); |
| 4437 | |
| 4438 | //header checking |
| 4439 | ASSERT(info.syncWord == 0xA2A2); |
| 4440 | ASSERT(info.type== AUD_CCCI_STRMBUF_TYPE_VIBSPK_PARAM); //just use the bit[0:3] to inidicate the type. |
| 4441 | ASSERT(info.length == (length-6)); |
| 4442 | |
| 4443 | |
| 4444 | // copy coefficient |
| 4445 | spe_setNotchFilterParam(vibSpkParam->notch_filter_para, vibSpkParam->is2In1Spk); |
| 4446 | |
| 4447 | |
| 4448 | } |
| 4449 | |
| 4450 | void spc_ReceiveNxpSmartPaParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom) |
| 4451 | { |
| 4452 | spcBufInfo info; |
| 4453 | AUDIO_NXP_SMARTPA_PARAMETER_STRUCT *nxpPaParam; //buffer reuse |
| 4454 | |
| 4455 | nxpPaParam = (AUDIO_NXP_SMARTPA_PARAMETER_STRUCT *)(&emDataBuf); //buffer reuse |
| 4456 | |
| 4457 | //get data |
| 4458 | SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, nxpPaParam, comeFrom); |
| 4459 | |
| 4460 | //[REMOVE] header checking |
| 4461 | // ASSERT(info.syncWord == 0xA2A2); |
| 4462 | // ASSERT(info.type== AUD_CCCI_STRMBUF_TYPE_NXP_SMARTPA_PARAM); //just use the bit[0:3] to inidicate the type. |
| 4463 | // ASSERT(info.length == (length-6)); |
| 4464 | |
| 4465 | // SPE_SetEchoRefInfo(nxpPaParam->isNxpFeatureOptOn, nxpPaParam->mic_index, nxpPaParam->chip_delay_with_switch, SPH_MODE_LOUDSPK); |
| 4466 | |
| 4467 | } |
| 4468 | #if defined(_SPE_ENH_MD_PARSE_) |
| 4469 | |
| 4470 | kal_uint16 spc_ReceiveDynamicParameter_viaStructShm(const kal_uint16 offset,const kal_uint16 length,SPC_MSG_FROM_T comeFrom) |
| 4471 | { |
| 4472 | // spcBufInfo header; |
| 4473 | // spc_sph_on_info_t info; |
| 4474 | kal_uint16 totalProcLen = 0; |
| 4475 | kal_uint16 curOffset = offset; |
| 4476 | #if 0 |
| 4477 | /* under construction !*/ |
| 4478 | /* under construction !*/ |
| 4479 | /* under construction !*/ |
| 4480 | /* under construction !*/ |
| 4481 | /* under construction !*/ |
| 4482 | /* under construction !*/ |
| 4483 | /* under construction !*/ |
| 4484 | /* under construction !*/ |
| 4485 | /* under construction !*/ |
| 4486 | /* under construction !*/ |
| 4487 | /* under construction !*/ |
| 4488 | /* under construction !*/ |
| 4489 | /* under construction !*/ |
| 4490 | /* under construction !*/ |
| 4491 | /* under construction !*/ |
| 4492 | /* under construction !*/ |
| 4493 | /* under construction !*/ |
| 4494 | /* under construction !*/ |
| 4495 | /* under construction !*/ |
| 4496 | /* under construction !*/ |
| 4497 | /* under construction !*/ |
| 4498 | /* under construction !*/ |
| 4499 | /* under construction !*/ |
| 4500 | /* under construction !*/ |
| 4501 | /* under construction !*/ |
| 4502 | /* under construction !*/ |
| 4503 | /* under construction !*/ |
| 4504 | /* under construction !*/ |
| 4505 | /* under construction !*/ |
| 4506 | #endif |
| 4507 | |
| 4508 | while(totalProcLen < length) { |
| 4509 | kal_uint16 procLen = 0; |
| 4510 | kal_uint16 newOffset; |
| 4511 | spc_dynamicParameterParser_dispatcher(curOffset, length, SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset); |
| 4512 | totalProcLen += procLen; |
| 4513 | curOffset = newOffset; |
| 4514 | } |
| 4515 | return totalProcLen; |
| 4516 | |
| 4517 | } |
| 4518 | #endif |
| 4519 | |
| 4520 | |
| 4521 | |
| 4522 | // ---------------------------------------------------------------------------- |
| 4523 | // Volume Setting |
| 4524 | // ---------------------------------------------------------------------------- |
| 4525 | /** |
| 4526 | @digiGain: unit is 0.25 dB |
| 4527 | */ |
| 4528 | void spc_gain_DlDigiGainSet(kal_uint16 digiGain) |
| 4529 | { |
| 4530 | spGain_SetDigitalGain( (kal_int16)digiGain, false ); |
| 4531 | // l1sp_digiOnly_SetOutputVolume((kal_int16)digiGain); |
| 4532 | } |
| 4533 | |
| 4534 | /** |
| 4535 | @refDigiGain: unit is 0.25 dB |
| 4536 | */ |
| 4537 | void spc_gain_DlEnhRefDigiGainSet(kal_uint16 refDigiGain) |
| 4538 | { |
| 4539 | spGain_SetEnhRefDigitalGain((kal_int16)refDigiGain, false); |
| 4540 | //l1sp_digiOnly_SetEnhRefOutputVolume((kal_int16)refDigiGain); |
| 4541 | } |
| 4542 | |
| 4543 | /** |
| 4544 | @digiGain: unit is 0.25 dB, but for DSP, only 1 db step range. mean while if you send 1.25 dB and 1.5 dB, they are the same |
| 4545 | */ |
| 4546 | void spc_gain_UlDigiGainSet(kal_uint16 digiGain) |
| 4547 | { |
| 4548 | spGain_SetMicrophoneVolume((kal_int16)digiGain, false); |
| 4549 | // l1sp_digiOnly_SetMicrophoneVolume((kal_int16)digiGain); |
| 4550 | } |
| 4551 | |
| 4552 | /** |
| 4553 | @on: 1 for turn on mute, 0 for turn off mute |
| 4554 | @byPassCheck: 1 for by pass check, 0 for normal check |
| 4555 | */ |
| 4556 | void spc_gain_UlMuteSet(kal_bool on, kal_bool byPassCheck) |
| 4557 | { |
| 4558 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE) |
| 4559 | || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE) |
| 4560 | || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE) |
| 4561 | || KAL_TRUE == byPassCheck) { |
| 4562 | gSpc.spcMuteUl = on; |
| 4563 | SP_MuteUlFromDiffPos(on, SP_MIC_MUTE_POS_FROM_SPC); // L1SP_MuteMicrophone(on); |
| 4564 | } else { |
| 4565 | MD_TRC_SPC_SET_DROP_UL_MUTE(); |
| 4566 | #if defined(__SMART_PHONE_MODEM__) |
| 4567 | spc_sendRampDoneAck(SAL_RAMP_UL_POS_EN); |
| 4568 | #endif |
| 4569 | } |
| 4570 | } |
| 4571 | |
| 4572 | void spc_gain_DlMuteSet(kal_bool on, kal_bool byPassCheck) |
| 4573 | { |
| 4574 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE) |
| 4575 | || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE) |
| 4576 | || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE) |
| 4577 | || KAL_TRUE == byPassCheck){ |
| 4578 | gSpc.spcMuteDl = on; |
| 4579 | L1SP_MuteSpeaker(on); |
| 4580 | } else { |
| 4581 | MD_TRC_SPC_SET_DROP_DL_MUTE(); |
| 4582 | #if defined(__SMART_PHONE_MODEM__) |
| 4583 | spc_sendRampDoneAck(SAL_RAMP_DL_PRE_DACA); |
| 4584 | #endif |
| 4585 | } |
| 4586 | } |
| 4587 | |
| 4588 | void spc_gain_UlSourceMuteSet(kal_bool on, kal_bool byPassCheck) |
| 4589 | { |
| 4590 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE) |
| 4591 | ||IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE) |
| 4592 | || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE) |
| 4593 | || KAL_TRUE == byPassCheck) { |
| 4594 | gSpc.spcMuteUlSource = on; |
| 4595 | SP_MuteUlSource(on); |
| 4596 | } else { |
| 4597 | MD_TRC_SPC_SET_DROP_UL_SOURCE_MUTE(); |
| 4598 | #if defined(__SMART_PHONE_MODEM__) |
| 4599 | spc_sendRampDoneAck(SAL_RAMP_UL_PRE_EN); |
| 4600 | #endif |
| 4601 | } |
| 4602 | } |
| 4603 | |
| 4604 | /** |
| 4605 | run under AUDL/MED, when process message "MSG_ID_AUDIO_M2M_RAMP_DONE" |
| 4606 | */ |
| 4607 | |
| 4608 | void spc_sendRampDoneAck(uint16 ramp_point) |
| 4609 | { |
| 4610 | MD_TRC_SPC_MUTE_DSP_RAMP_ACK_POINT(gSpc.spcRampAck, ramp_point); |
| 4611 | if(!IS_SPC_RAMP_WAIT_ACK(ramp_point)) { |
| 4612 | MD_TRC_SPC_MUTE_DSP_RAMP_NO_ACK(); |
| 4613 | return; |
| 4614 | } |
| 4615 | CLR_SPC_RAMP_WAIT_ACK(ramp_point); |
| 4616 | switch(ramp_point){ |
| 4617 | case SAL_RAMP_UL_POS_EN: |
| 4618 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ACK, 0, 0); |
| 4619 | break; |
| 4620 | case SAL_RAMP_UL_PRE_EN: |
| 4621 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_SOURCE_ACK, 0, 0); |
| 4622 | break; |
| 4623 | case SAL_RAMP_DL_PRE_DACA: |
| 4624 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_ACK, 0, 0); |
| 4625 | break; |
| 4626 | case SAL_RAMP_DL_PRE_MIXER2: |
| 4627 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_DYNAMIC_ACK, 0, 0); |
| 4628 | break; |
| 4629 | default: |
| 4630 | ASSERT(0); |
| 4631 | } |
| 4632 | } |
| 4633 | void spc_gain_DlMuteCodecSet(kal_bool on, kal_bool byPassCheck) |
| 4634 | { |
| 4635 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE) |
| 4636 | ||IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE) |
| 4637 | || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE) |
| 4638 | || KAL_TRUE == byPassCheck) { |
| 4639 | L1SP_SetCodecMuteByAp(on); |
| 4640 | } else { |
| 4641 | MD_TRC_SPC_SET_DROP_DL_CODEC_MUTE(); |
| 4642 | } |
| 4643 | } |
| 4644 | |
| 4645 | void spc_gain_DlMuteSet_PrePcmMixer(kal_bool on, kal_bool byPassCheck) |
| 4646 | { |
| 4647 | if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE) |
| 4648 | || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE) |
| 4649 | || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE) |
| 4650 | || KAL_TRUE == byPassCheck) { |
| 4651 | SP_MuteDl_beforePcmMixer(on); |
| 4652 | } else { |
| 4653 | MD_TRC_SPC_SET_DROP_DL_MUTE_WITH_POS(); |
| 4654 | #if defined(__SMART_PHONE_MODEM__) |
| 4655 | spc_sendRampDoneAck(SAL_RAMP_DL_PRE_MIXER2); |
| 4656 | #endif |
| 4657 | } |
| 4658 | } |
| 4659 | |
| 4660 | |
| 4661 | // ---------------------------------------------------------------------------- |
| 4662 | // Device Related Setting |
| 4663 | // ---------------------------------------------------------------------------- |
| 4664 | |
| 4665 | void spc_dev_SamplingRateSet(kal_uint16 sampleRate) |
| 4666 | { |
| 4667 | switch(sampleRate){ |
| 4668 | case 0: |
| 4669 | AFE_SetVoice8KMode(2); //default 32000, case 0: reset |
| 4670 | break; |
| 4671 | case 8000: |
| 4672 | AFE_SetVoice8KMode(0); |
| 4673 | break; |
| 4674 | case 16000: |
| 4675 | AFE_SetVoice8KMode(1); |
| 4676 | break; |
| 4677 | case 32000: |
| 4678 | AFE_SetVoice8KMode(2); |
| 4679 | break; |
| 4680 | case 48000: |
| 4681 | AFE_SetVoice8KMode(3); |
| 4682 | break; |
| 4683 | default: |
| 4684 | ASSERT(0); |
| 4685 | } |
| 4686 | } |
| 4687 | |
| 4688 | // ---------------------------------------------------------------------------- |
| 4689 | // AUDL running functions Related |
| 4690 | // ---------------------------------------------------------------------------- |
| 4691 | |
| 4692 | void spc_A2M_MsgHandler(kal_uint32 ccciMsg, kal_uint32 ccciResv, SPC_MSG_FROM_T comeFrom) |
| 4693 | { |
| 4694 | kal_uint16 cmd, msgData16; |
| 4695 | kal_uint16 msgData32; |
| 4696 | uint16 type16 = 0; |
| 4697 | |
| 4698 | cmd = SPCIO_CCCI_MSG_CMD(ccciMsg); |
| 4699 | msgData16 = SPCIO_CCCI_MSG_DATA16(ccciMsg); |
| 4700 | msgData32 = ccciResv; |
| 4701 | |
| 4702 | switch(cmd){ |
| 4703 | case MSG_A2M_SPH_DL_DIGIT_VOLUME: |
| 4704 | spc_gain_DlDigiGainSet(msgData16); |
| 4705 | break; |
| 4706 | case MSG_A2M_SPH_UL_DIGIT_VOLUME: |
| 4707 | spc_gain_UlDigiGainSet(msgData16); |
| 4708 | break; |
| 4709 | case MSG_A2M_MUTE_SPH_UL: |
| 4710 | SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_UL_POS_EN); |
| 4711 | spc_gain_UlMuteSet( (kal_bool)(msgData16&1), KAL_FALSE); |
| 4712 | break; |
| 4713 | case MSG_A2M_MUTE_SPH_DL: |
| 4714 | SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_DL_PRE_DACA); |
| 4715 | spc_gain_DlMuteSet( (kal_bool)(msgData16&1), KAL_FALSE); |
| 4716 | break; |
| 4717 | // case MSG_A2M_SIDETONE_VOLUME: break; |
| 4718 | case MSG_A2M_SPH_DL_ENH_REF_DIGIT_VOLUME: |
| 4719 | spc_gain_DlEnhRefDigiGainSet(msgData16); |
| 4720 | break; |
| 4721 | // case MSG_A2M_SIDETONE_CONFIG: break; |
| 4722 | case MSG_A2M_MUTE_SPH_UL_ENH_RESULT: |
| 4723 | // spc_gain_UlEnhResultMuteSet((kal_bool)(msgData16&1), KAL_FALSE); |
| 4724 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ENH_RESULT_ACK, 0, 0); |
| 4725 | break; |
| 4726 | case MSG_A2M_MUTE_SPH_UL_SOURCE: |
| 4727 | SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_UL_PRE_EN); |
| 4728 | spc_gain_UlSourceMuteSet((kal_bool)(msgData16&1), KAL_FALSE); |
| 4729 | break; |
| 4730 | case MSG_A2M_MUTE_SPH_DL_CODEC: |
| 4731 | spc_gain_DlMuteCodecSet((kal_bool)(msgData16&1), KAL_FALSE); |
| 4732 | break; |
| 4733 | case MSG_A2M_MUTE_SPH_DL_DYNAMIC: |
| 4734 | SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_DL_PRE_MIXER2); |
| 4735 | spc_gain_DlMuteSet_PrePcmMixer((kal_bool)(msgData16&1), KAL_FALSE); |
| 4736 | break; |
| 4737 | |
| 4738 | // --------- [0x10] device related ----------- |
| 4739 | case MSG_A2M_SET_SAMPLE_RATE: |
| 4740 | spc_dev_SamplingRateSet(msgData16); |
| 4741 | break; |
| 4742 | // case MSG_A2M_SET_DUAL_MIC: break; |
| 4743 | case MSG_A2M_SET_LPBK_POINT_DVT: |
| 4744 | spc_dev_LoopbackPoint_DVT(msgData16); |
| 4745 | break; |
| 4746 | |
| 4747 | // --------- [0x20] speech control ----------- |
| 4748 | case MSG_A2M_SPH_ON: |
| 4749 | { |
| 4750 | if(SPC_MSG_FROM_CCCI_STREAM == comeFrom) { |
| 4751 | type16 = Spc_SpeechOn_withData((kal_uint16)msgData32, msgData16, comeFrom); |
| 4752 | } else { |
| 4753 | Spc_SpeechOn((kal_uint8) msgData16); |
| 4754 | } |
| 4755 | |
| 4756 | #if defined(__ECALL_SUPPORT__) |
| 4757 | spc_eCall_SDT_Open(); |
| 4758 | #endif |
| 4759 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_ACK, type16, 0); |
| 4760 | } |
| 4761 | break; |
| 4762 | case MSG_A2M_SPH_OFF: |
| 4763 | { |
| 4764 | #if defined(__ECALL_SUPPORT__) |
| 4765 | spc_eCall_SDT_Close(); |
| 4766 | #endif |
| 4767 | // Spc_SpeechOff(); |
| 4768 | Spc_SpeechOff_Merge(); |
| 4769 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_OFF_ACK, 0, 0); |
| 4770 | } |
| 4771 | break; |
| 4772 | case MSG_A2M_SET_SPH_MODE: |
| 4773 | { |
| 4774 | // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) msgData16 ); |
| 4775 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_SPH_MODE_ACK, msgData16, 0); |
| 4776 | } |
| 4777 | break; |
| 4778 | case MSG_A2M_CTRL_SPH_ENH: |
| 4779 | { |
| 4780 | // add condition checking when turn speech enhancment on/off |
| 4781 | if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) { |
| 4782 | MD_TRC_SPC_DROP_SET(ccciMsg, cmd, cmd, msgData16, msgData32); |
| 4783 | } else { |
| 4784 | L1SP_EnableSpeechEnhancement((msgData16!=0)); |
| 4785 | } |
| 4786 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTRL_SPH_ENH_ACK, msgData16, 0); |
| 4787 | } |
| 4788 | break; |
| 4789 | case MSG_A2M_CONFIG_SPH_ENH: |
| 4790 | { |
| 4791 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CONFIG_SPH_ENH_ACK, msgData16, 0); |
| 4792 | } |
| 4793 | break; |
| 4794 | case MSG_A2M_SET_ACOUSTIC_LOOPBACK: |
| 4795 | { |
| 4796 | #if defined(__ENABLE_SPEECH_DVT__) |
| 4797 | Spc_PCMNWay_DVT_Test((kal_uint8) msgData16 ); |
| 4798 | #else // defined(__ENABLE_SPEECH_DVT__) |
| 4799 | Spc_AcousticLoopback((msgData16&1), (kal_uint8)(msgData16>>1), (kal_uint8)(msgData32&0xff)); |
| 4800 | #endif // defined(__ENABLE_SPEECH_DVT__) |
| 4801 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_ACOUSTIC_LOOPBACK_ACK, msgData16, msgData32); |
| 4802 | } |
| 4803 | break; |
| 4804 | case MSG_A2M_PRINT_SPH_COEFF: |
| 4805 | { |
| 4806 | spc_DebugPrint(); |
| 4807 | // ack is: SPCIO_MSG_FROM_SPC_PRINT_SPH_COEFF_ACK --> MSG_M2A_PRINT_SPH_COEFF_ACK |
| 4808 | } |
| 4809 | break; |
| 4810 | case MSG_A2M_SPH_ON_FOR_HOLD_CALL: |
| 4811 | { |
| 4812 | // [REMIND] No application can be on under this application |
| 4813 | spc_SpeechOnForCallHold((msgData16 == 1)); // bit 0, 0 for off, 1 for on |
| 4814 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_FOR_HOLD_CALL_ACK, 0, 0); |
| 4815 | } |
| 4816 | break; |
| 4817 | case MSG_A2M_SPH_ON_FOR_DACA: |
| 4818 | { |
| 4819 | Spc_SpeechOnForDaca((kal_uint8) msgData16, (kal_bool)(msgData16 >> 8)); |
| 4820 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_FOR_DACA_ACK, msgData16, 0); |
| 4821 | } |
| 4822 | break; |
| 4823 | |
| 4824 | case MSG_A2M_SPH_ROUTER_ON: |
| 4825 | { |
| 4826 | Spc_SpeechRouterOn((msgData16&1)==1); |
| 4827 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ROUTER_ON_ACK, msgData16, 0); |
| 4828 | } |
| 4829 | break; |
| 4830 | case MSG_A2M_SET_VOICE_ENCRYPTION: |
| 4831 | { |
| 4832 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_VOICE_ENCRYPTION_ACK, msgData16, 0); |
| 4833 | } |
| 4834 | break; |
| 4835 | case MSG_A2M_SPH_DEV_CHANGE: |
| 4836 | { |
| 4837 | type16 = Spc_SpeechDeviceChange((kal_uint16)msgData32, msgData16, comeFrom); |
| 4838 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_DEV_CHANGE_ACK, type16, 0); |
| 4839 | } |
| 4840 | break; |
| 4841 | case MSG_A2M_ENH_CTRL_SUPPORT: |
| 4842 | { |
| 4843 | L1SP_EnhancementCtrlSupport(msgData16); |
| 4844 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_ENH_CTRL_SUPPORT_ACK, type16, 0); |
| 4845 | } |
| 4846 | break; |
| 4847 | // --------- [0x30] speech control ----------- |
| 4848 | case MSG_A2M_PNW_ON: // normal use always narrow band/decided by network |
| 4849 | { |
| 4850 | spc_PcmNWayStart(msgData16, SPC_PCMNWAY_FORMAT_UNSET) ; // , SPC_PCMNWAY_APP_TYPE_UNSET); |
| 4851 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_ON_ACK, msgData16, 0); |
| 4852 | // SPCIO_CCCI_MSG_CONSTRCUT_CMD(MSG_M2A_PNW_ON_ACK, msgData16)); |
| 4853 | } |
| 4854 | break; |
| 4855 | case MSG_A2M_PNW_OFF: |
| 4856 | { |
| 4857 | spc_PcmNWayStop(); |
| 4858 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_OFF_ACK, msgData16, 0); |
| 4859 | // SPCIO_CCCI_MSG_CONSTRCUT_CMD(MSG_M2A_PNW_OFF_ACK, msgData16)); |
| 4860 | } |
| 4861 | break; |
| 4862 | /* |
| 4863 | case MSG_A2M_RECORD_ON: // spc_RecordStart |
| 4864 | break; |
| 4865 | case MSG_A2M_RECORD_OFF: // spc_RecordStop |
| 4866 | break; |
| 4867 | case MSG_A2M_DMNR_RECPLAY_ON: |
| 4868 | break; |
| 4869 | case MSG_A2M_DMNR_RECPLAY_OFF: |
| 4870 | break; |
| 4871 | case MSG_A2M_DMNR_REC_ONLY_ON: |
| 4872 | break; |
| 4873 | case MSG_A2M_DMNR_REC_ONLY_OFF: |
| 4874 | break; |
| 4875 | case MSG_A2M_PCM_REC_ON: // spc_PcmRecordStart |
| 4876 | break; |
| 4877 | case MSG_A2M_PCM_REC_OFF: // spc_PcmRecordStop |
| 4878 | break; |
| 4879 | */ |
| 4880 | case MSG_A2M_VM_REC_ON: |
| 4881 | { |
| 4882 | spc_VmRecordStart(); |
| 4883 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VM_REC_ON_ACK, msgData16, 0); |
| 4884 | } |
| 4885 | break; |
| 4886 | case MSG_A2M_VM_REC_OFF: |
| 4887 | { |
| 4888 | spc_VmRecordStop(); |
| 4889 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VM_REC_OFF_ACK, msgData16, 0); |
| 4890 | } |
| 4891 | break; |
| 4892 | case MSG_A2M_RECORD_RAW_PCM_ON: |
| 4893 | { |
| 4894 | // data16 bit[0:3] is position info |
| 4895 | spc_RawPcmRecordStart((kal_uint8)(msgData16&0xF)); |
| 4896 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_ON_ACK, msgData16, 0); |
| 4897 | } |
| 4898 | break; |
| 4899 | case MSG_A2M_RECORD_RAW_PCM_OFF: |
| 4900 | { |
| 4901 | spc_RawPcmRecordStop(); |
| 4902 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_OFF_ACK, msgData16, 0); |
| 4903 | } |
| 4904 | break; |
| 4905 | case MSG_A2M_PCMMIXER_ON: |
| 4906 | { |
| 4907 | //bit 0: isDlMix: 0 is replace, 1 is mix |
| 4908 | //bit 2: isUlMix: 0 is replace, 1 is mix |
| 4909 | spc_PCMMixerStart((msgData16&4)==4, (msgData16&1)==1, 0, 7); |
| 4910 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_ON_ACK, msgData16, 0); |
| 4911 | } |
| 4912 | break; |
| 4913 | case MSG_A2M_PCMMIXER_OFF: |
| 4914 | { |
| 4915 | spc_PCMMixerStop(); |
| 4916 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_OFF_ACK, msgData16, 0); |
| 4917 | } |
| 4918 | break; |
| 4919 | case MSG_A2M_TELEPHONY_TX_ON: |
| 4920 | { |
| 4921 | //bit 0: isUlMix: 0 is replace, 1 is mix |
| 4922 | spc_PCMMixer3Start(msgData16&1, 7); |
| 4923 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_ON_ACK, msgData16, 0); |
| 4924 | } |
| 4925 | break; |
| 4926 | case MSG_A2M_TELEPHONY_TX_OFF: |
| 4927 | { |
| 4928 | spc_PCMMixer3Stop(); |
| 4929 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_OFF_ACK, msgData16, 0); |
| 4930 | } |
| 4931 | break; |
| 4932 | // --------- [0x40] other control function ----------- |
| 4933 | #ifdef __CTM_SUPPORT__ |
| 4934 | case MSG_A2M_CTM_ON: |
| 4935 | spc_CtmStart(msgData16); |
| 4936 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_ON_ACK, msgData16, 0); |
| 4937 | break; |
| 4938 | case MSG_A2M_CTM_OFF: |
| 4939 | spc_CtmStop(); |
| 4940 | //SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, msgData16, 0); |
| 4941 | break; |
| 4942 | case MSG_A2M_CTM_DUMP_DEBUG_FILE: |
| 4943 | spc_CtmDebugConfig(msgData16!=0); |
| 4944 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_DUMP_DEBUG_FILE_ACK, msgData16, 0); |
| 4945 | break; |
| 4946 | #endif // __CTM_SUPPORT__ |
| 4947 | |
| 4948 | case MSG_A2M_BGSND_ON: |
| 4949 | spc_BgSndStart(); |
| 4950 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_ON_ACK, msgData16, 0); |
| 4951 | break; |
| 4952 | case MSG_A2M_BGSND_OFF: |
| 4953 | spc_BgSndStop(); |
| 4954 | // SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, msgData16, 0); |
| 4955 | break; |
| 4956 | case MSG_A2M_BGSND_CONFIG: |
| 4957 | // msgData16, [15:8] ulGainLevel from 0 ~ 255, [7:0] dlGainLevel from 0 ~ 255 |
| 4958 | // we mapping the value into 0~7 levels. so right shift 5 |
| 4959 | // spc_BgSndConfig((msgData16>>8)>>5, (msgData16&0xff)>>5); |
| 4960 | spc_BgSndConfig((msgData16>>13), ((msgData16&0xff)>>5)); |
| 4961 | break; // SPCIO_MSG_FROM_SPC_BGSND_CONFIG_ACK-- > MSG_M2A_BGSND_CONFIG_ACK |
| 4962 | case MSG_A2M_RTT_CONFIG: |
| 4963 | spc_RttConfig(msgData16); |
| 4964 | break; |
| 4965 | case MSG_A2M_PCMMIXER_CONFIG: |
| 4966 | //bit 0: isDlMix: 0 is replace, 1 is mix |
| 4967 | //bit 2: isUlMix: 0 is replace, 1 is mix |
| 4968 | spc_PCMMixerConfig((msgData16&4)==4,(msgData16&1)==1,0,7); |
| 4969 | break; |
| 4970 | case MSG_A2M_TELEPHONY_TX_CONFIG: |
| 4971 | //bit 0: isDlMix: 0 is replace, 1 is mix |
| 4972 | spc_PCMMixer3Config((msgData16&1)==1,7); |
| 4973 | break; |
| 4974 | // --------- [0x50] Recevie DATA notify ----------- |
| 4975 | case MSG_A2M_PNW_DLDATA_NOTIFY: |
| 4976 | spc_pcmNWay_writeDlDataDone((kal_uint16)msgData32, msgData16, comeFrom); |
| 4977 | break; |
| 4978 | case MSG_A2M_BGSND_DATA_NOTIFY: |
| 4979 | spc_bgSnd_writeDataDone( (kal_uint16)msgData32, msgData16, comeFrom); |
| 4980 | break; |
| 4981 | case MSG_A2M_CTM_DATA_NOTIFY: break; |
| 4982 | case MSG_A2M_DACA_UL_DATA_NOTIFY: |
| 4983 | spc_daca_writeUlDataDone((kal_uint16)msgData32, msgData16, comeFrom); |
| 4984 | break; |
| 4985 | // MSG_A2M_ECALL_MSD, |
| 4986 | // MSG_A2M_SPC_UL_ENC, |
| 4987 | // MSG_A2M_SPC_DL_DEC, |
| 4988 | case MSG_A2M_PCMMIXER_DLDATA_NOTIFY: |
| 4989 | spc_PCMMixer_writeDlDataDone((kal_uint16)msgData32, msgData16, comeFrom); |
| 4990 | break; |
| 4991 | case MSG_A2M_PCMMIXER_ULDATA_NOTIFY: |
| 4992 | break; |
| 4993 | case MSG_A2M_TELEPHONY_TX_ULDATA_NOTIFY: |
| 4994 | spc_PCMMixer3_writeUlDataDone((kal_uint16)msgData32, msgData16, comeFrom); |
| 4995 | break; |
| 4996 | // --------- [0x60] Send DATA Ack --------------- |
| 4997 | case MSG_A2M_PNW_ULDATA_READ_ACK: |
| 4998 | spc_pcmNWay_sendUlDataDone(); |
| 4999 | break; |
| 5000 | case MSG_A2M_REC_DATA_READ_ACK: // removed from 93md |
| 5001 | // spc_record_sendMicDataDone(); |
| 5002 | break; |
| 5003 | #ifdef __CTM_SUPPORT__ |
| 5004 | case MSG_A2M_CTM_DEBUG_DATA_READ_ACK: |
| 5005 | spc_ctm_sendDumpDebugDataDone(); |
| 5006 | break; |
| 5007 | #endif |
| 5008 | case MSG_A2M_PCM_REC_DATA_READ_ACK: // removed from 93md |
| 5009 | // spc_pcmRec_sendMicDataDone(); |
| 5010 | break; |
| 5011 | case MSG_A2M_VM_REC_DATA_READ_ACK: |
| 5012 | spc_vmRec_sendMicDataDone(); |
| 5013 | break; |
| 5014 | case MSG_A2M_DACA_DL_DATA_READ_ACK: |
| 5015 | spc_daca_sendDlDataDone(); |
| 5016 | break; |
| 5017 | case MSG_A2M_RAW_PCM_REC_DATA_READ_ACK: |
| 5018 | spc_RawPcmRec_sendDataDone(); |
| 5019 | break; |
| 5020 | |
| 5021 | // --------- [0x70] EM related -------------------- |
| 5022 | // case MSG_A2M_EM_INCALL: break; |
| 5023 | // case MSG_A2M_EM_DMNR: break; |
| 5024 | // case MSG_A2M_EM_WB: break; |
| 5025 | // case MSG_A2M_EM_MAGICON: break; |
| 5026 | case MSG_A2M_NETWORK_STATUS_ACK: |
| 5027 | break; |
| 5028 | /* |
| 5029 | case MSG_A2M_QUERY_RF_INFO: |
| 5030 | // spc_notify_rf_info(); |
| 5031 | break; |
| 5032 | case MSG_A2M_EM_HAC: |
| 5033 | break; |
| 5034 | */ |
| 5035 | case MSG_A2M_DYNAMIC_PAR: |
| 5036 | |
| 5037 | #if defined(_SPE_ENH_MD_PARSE_) |
| 5038 | type16 = spc_ReceiveDynamicParameter((kal_uint16)msgData32, msgData16, comeFrom); |
| 5039 | #endif |
| 5040 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_ACK, type16, 0 ); |
| 5041 | break; |
| 5042 | case MSG_A2M_SPH_ENH_CORE: |
| 5043 | // use for OPEN DSP?? |
| 5044 | break; |
| 5045 | case MSG_A2M_DYNAMIC_PAR_IN_STRUCT_SHM: |
| 5046 | |
| 5047 | #if defined(_SPE_ENH_MD_PARSE_) |
| 5048 | type16 = spc_ReceiveDynamicParameter_viaStructShm((kal_uint16)msgData32, msgData16, comeFrom); |
| 5049 | #else // for 95,97 |
| 5050 | spc_ReceiveEMIParInfo(msgData32, msgData16, comeFrom); |
| 5051 | #endif |
| 5052 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_IN_STRUCT_SHM_ACK, type16, 0 ); |
| 5053 | break; |
| 5054 | |
| 5055 | |
| 5056 | // --------- [0x80] New feature data related -------------------- |
| 5057 | case MSG_A2M_VIBSPK_PARAMETER: |
| 5058 | spc_ReceiveViberationSpkParameter((kal_uint16)msgData32, msgData16, comeFrom); |
| 5059 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VIBSPK_PARAMETER_ACK, 0, 0 ); |
| 5060 | break; |
| 5061 | |
| 5062 | case MSG_A2M_NXP_SMARTPA_PARAMETER: |
| 5063 | spc_ReceiveNxpSmartPaParameter((kal_uint16)msgData32, msgData16, comeFrom); |
| 5064 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_NXP_SMARTPA_PARAMETER_ACK, 0, 0 ); |
| 5065 | break; |
| 5066 | |
| 5067 | // --------- [0x90] New feature data related -------------------- |
| 5068 | case MSG_A2M_NW_CODEC_INFO_READ_ACK: |
| 5069 | spc_ReceiveNwCodecInfoReadDone(); |
| 5070 | break; |
| 5071 | |
| 5072 | // --------- [0xA0] Alive related -------------------- |
| 5073 | case MSG_A2M_AUD_ALIVE_READ_ACK: |
| 5074 | break; |
| 5075 | |
| 5076 | |
| 5077 | // --------- [0xB0] Telematics feature -------------------- |
| 5078 | case MSG_A2M_IVS_SWITCH: |
| 5079 | #if defined(__ECALL_SUPPORT__) |
| 5080 | if(msgData16 == 1) |
| 5081 | { |
| 5082 | spc_eCall_IVS_Open(); |
| 5083 | } |
| 5084 | else if(msgData16 == 0) |
| 5085 | { |
| 5086 | spc_eCall_IVS_Close(); |
| 5087 | } |
| 5088 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_IVS_SWITCH_ACK, 0, 0); |
| 5089 | #endif |
| 5090 | break; |
| 5091 | case MSG_A2M_PSAP_SWITCH: |
| 5092 | #if defined(__ECALL_SUPPORT__) |
| 5093 | if(msgData16 == 1) |
| 5094 | { |
| 5095 | spc_eCall_PSAP_Open(); |
| 5096 | } |
| 5097 | else if(msgData16 == 0) |
| 5098 | { |
| 5099 | spc_eCall_PSAP_Close(); |
| 5100 | } |
| 5101 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_PSAP_SWITCH_ACK, 0, 0); |
| 5102 | #endif |
| 5103 | break; |
| 5104 | case MSG_A2M_IVS_SEND: |
| 5105 | #if defined(__ECALL_SUPPORT__) |
| 5106 | eCall_IVS_SendStart(); |
| 5107 | #endif |
| 5108 | break; |
| 5109 | case MSG_A2M_PSAP_SEND: |
| 5110 | #if defined(__ECALL_SUPPORT__) |
| 5111 | eCall_PSAP_SendStart(); |
| 5112 | #endif |
| 5113 | break; |
| 5114 | case MSG_A2M_ECALL_CTL_SEQ_SWITCH: |
| 5115 | #if defined(__ECALL_SUPPORT__) |
| 5116 | Set_eCall_Par_Crtl_Switch((kal_uint8)msgData16); |
| 5117 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_ECALL_CTL_SEQ_SWITCH_ACK, 0, 0); |
| 5118 | #endif |
| 5119 | break; |
| 5120 | |
| 5121 | #if defined(__ECALL_SUPPORT__) |
| 5122 | case MSG_A2M_ECALL_MSD: |
| 5123 | spc_eCall_Msd_Data((kal_uint16)msgData32, msgData16,comeFrom); |
| 5124 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_MSD_DATA_ACK, 0, 0); |
| 5125 | break; |
| 5126 | #endif |
| 5127 | case MSG_A2M_ECALL_TX_CTRL_PAR: |
| 5128 | #if defined(__ECALL_SUPPORT__) |
| 5129 | spc_eCall_TX_CTRL_Data((kal_uint16)msgData32, msgData16,comeFrom); |
| 5130 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_ECALL_TX_CTRL_PAR_ACK, 0, 0); |
| 5131 | #endif |
| 5132 | break; |
| 5133 | case MSG_A2M_ECALL_RX_CTRL_PAR: |
| 5134 | #if defined(__ECALL_SUPPORT__) |
| 5135 | #endif |
| 5136 | break; |
| 5137 | |
| 5138 | default: |
| 5139 | if(SPC_MSG_FROM_CCCI == comeFrom) |
| 5140 | SpcIO_unknownMsgAckToAp(cmd, 0, 0); |
| 5141 | MD_TRC_SPCIO_INVALID_MSG(SPC_ID_AUDIO_A2M_CCCI, ccciMsg, ccciResv); |
| 5142 | |
| 5143 | } |
| 5144 | } |
| 5145 | |
| 5146 | |
| 5147 | // ---------------------------------------------------------------------------- |
| 5148 | // Init Related |
| 5149 | // ---------------------------------------------------------------------------- |
| 5150 | |
| 5151 | #ifndef TK6291_FAKE_COMPILE |
| 5152 | extern unsigned short L1D_Audio_ChkDspInitDone(); |
| 5153 | #endif //#ifndef TK6291_FAKE_COMPILE |
| 5154 | /** |
| 5155 | Function owner is EL1. |
| 5156 | @return: true all rat init done, else is false |
| 5157 | */ |
| 5158 | /* |
| 5159 | #ifndef TK6291_FAKE_COMPILE |
| 5160 | extern kal_bool MML1_RF_CHECK_RF_INIT_STATUS(void); |
| 5161 | #endif //#ifndef TK6291_FAKE_COMPILE |
| 5162 | */ |
| 5163 | |
| 5164 | void Spc_Init_B4_Scheduling(void) |
| 5165 | { |
| 5166 | // all data inside gSpc are 0 when boot up |
| 5167 | gSpc.spcGetEpofTimes = 0; |
| 5168 | |
| 5169 | // ====== Initial needed by other application ======= |
| 5170 | //background sound |
| 5171 | gSpc_bgSnd.ulGainLevel = 5; |
| 5172 | gSpc_bgSnd.dlGainLevel = 5; |
| 5173 | } |
| 5174 | |
| 5175 | void Spc_Init(void) { |
| 5176 | |
| 5177 | /* |
| 5178 | // for MT6752 MD1, due to RF K needs 1.5 second, please wait for it. |
| 5179 | #if (defined(MT6752) && defined (__MD1__)) || defined(MT6595) || defined(MT6735) |
| 5180 | #ifndef TK6291_FAKE_COMPILE |
| 5181 | while( false == MML1_RF_CHECK_RF_INIT_STATUS()) { |
| 5182 | MD_TRC_SPC_AUDIOTASK_WAIT_EL1_RF_INIT(tick); |
| 5183 | kal_sleep_task( AUD_1TICK(1) ); |
| 5184 | tick++; |
| 5185 | } |
| 5186 | #endif //#ifndef TK6291_FAKE_COMPILE |
| 5187 | #endif |
| 5188 | */ |
| 5189 | gSpc_acLoopback.isLoopback = 0; // set loopback state = 0 |
| 5190 | // ---------------------- |
| 5191 | #if SPC_CUST_ENH |
| 5192 | // add IDs for DV process |
| 5193 | DV_dl_audioid = L1Audio_GetAudioID(); |
| 5194 | L1Audio_SetEventHandler(DV_dl_audioid, (L1Audio_EventHandler)DV_DL_process); |
| 5195 | DV_ul_audioid = L1Audio_GetAudioID(); |
| 5196 | L1Audio_SetEventHandler(DV_ul_audioid, (L1Audio_EventHandler)DV_UL_process); |
| 5197 | #endif |
| 5198 | #if defined(__ECALL_SUPPORT__) |
| 5199 | gSpc.eCall_Ctrl_Seq_Switch = 0; |
| 5200 | spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE); |
| 5201 | memset(eCall_Msd, 0, 140*sizeof(kal_uint8)); |
| 5202 | #endif |
| 5203 | } |
| 5204 | |
| 5205 | |
| 5206 | kal_bool spc_endApp(void) |
| 5207 | { |
| 5208 | kal_bool isAppOn=false; |
| 5209 | |
| 5210 | if(IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)) { |
| 5211 | spc_PcmNWayStop(); |
| 5212 | isAppOn=true; |
| 5213 | } |
| 5214 | |
| 5215 | #if 0 |
| 5216 | /* under construction !*/ |
| 5217 | /* under construction !*/ |
| 5218 | /* under construction !*/ |
| 5219 | #endif |
| 5220 | |
| 5221 | if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)) { |
| 5222 | if(EXT_SRC_STATE_RUN == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS) ){ |
| 5223 | // force close without ack |
| 5224 | spc_BgSndForceClose(); |
| 5225 | |
| 5226 | } else if (EXT_SRC_STATE_FLUSHING == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS) |
| 5227 | || EXT_SRC_STATE_FLUSHING_OVER == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS)) { |
| 5228 | // AP has send close request, as the result we need to send ack to AP |
| 5229 | spc_BgSndClose(); |
| 5230 | } // else is idle |
| 5231 | isAppOn=true; |
| 5232 | } |
| 5233 | |
| 5234 | |
| 5235 | if(IS_SPC_APP_USED(SPC_APP_CTM_USAGE)) { |
| 5236 | #ifdef __CTM_SUPPORT__ |
| 5237 | spc_CtmStop(); |
| 5238 | #endif |
| 5239 | isAppOn=true; |
| 5240 | } |
| 5241 | |
| 5242 | #if 0 |
| 5243 | /* under construction !*/ |
| 5244 | /* under construction !*/ |
| 5245 | /* under construction !*/ |
| 5246 | #endif |
| 5247 | |
| 5248 | if(IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)) { |
| 5249 | spc_VmRecordStop(); |
| 5250 | isAppOn=true; |
| 5251 | } |
| 5252 | |
| 5253 | if(IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)) { |
| 5254 | spc_RawPcmRecordStop(); |
| 5255 | isAppOn=true; |
| 5256 | } |
| 5257 | |
| 5258 | return isAppOn; |
| 5259 | } |
| 5260 | void Spc_ForceEndAllApp(void) // AP send ETOF to MD L4C. L4C will send ILM to MED and invoke this function |
| 5261 | { |
| 5262 | kal_bool is_factory_mode = SpcIO_isFactoryBoot(); |
| 5263 | gSpc.spcGetEpofTimes |= ENUM_EPOF_DO_FORCEENDALLAPP; |
| 5264 | |
| 5265 | MD_TRC_SPC_EPOF_NOTIFY(gSpc.spcAppUsage); |
| 5266 | |
| 5267 | SP_DSPTone_ForceEnd(); |
| 5268 | |
| 5269 | spc_endApp(); |
| 5270 | |
| 5271 | // main app |
| 5272 | if(IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) { |
| 5273 | // Spc_SpeechOff(); |
| 5274 | Spc_SpeechOff_Merge(); |
| 5275 | } |
| 5276 | |
| 5277 | if(IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) { |
| 5278 | Spc_SpeechRouterOn(false); |
| 5279 | } |
| 5280 | #if defined( __SMART_PHONE_MODEM__ ) |
| 5281 | if(is_factory_mode != true) |
| 5282 | { |
| 5283 | SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_EPOF_NOTIFY, (kal_uint16)0, 0); |
| 5284 | MD_TRC_SPC_EPOF_SPC_FORCEENDALLAPP_NOTIFY_AP(); |
| 5285 | } |
| 5286 | #endif //#if defined( __SMART_PHONE_MODEM__ ) |
| 5287 | if(is_factory_mode == true) |
| 5288 | { |
| 5289 | //Notify L4C: speech driver enter EPOF done |
| 5290 | msg_send6(MOD_MED, MOD_L4C, AUDIO_SAP, MSG_ID_AUDIO_L4C_EPOF_ACK, (local_para_struct *)NULL, NULL); |
| 5291 | kal_prompt_trace(MOD_L1SP, "[EPOF]Spc_ForceEndAllApp notify L4C done at factory mode"); |
| 5292 | } |
| 5293 | |
| 5294 | } |
| 5295 | |
| 5296 | #if defined(_SPE_ENH_MD_PARSE_) |
| 5297 | |
| 5298 | spcDynParNBData NBParData; |
| 5299 | spcDynParNBData_V10 NBParData_v10; //need remove later |
| 5300 | spcDynParWBData WBParData; |
| 5301 | spcDynParSWBData SWBParData; |
| 5302 | spcDynParNBIIRData NBIIRParData; |
| 5303 | spcDynParWBIIRData WBIIRParData; |
| 5304 | spcDynParSWBIIRData SWBIIRParData; |
| 5305 | |
| 5306 | kal_uint16 spc_dynamicParameterParser_volInUnit(AUD_SPC_DYNAMIC_PARAM_MAGICNUM_T unit, |
| 5307 | const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5308 | kal_uint16 *procLen) |
| 5309 | { |
| 5310 | kal_uint16 curOffset; |
| 5311 | kal_uint16 Data_Header; |
| 5312 | |
| 5313 | kal_uint16 tempProclen = 0; |
| 5314 | |
| 5315 | MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(unit, length, comeFrom); |
| 5316 | |
| 5317 | kal_prompt_trace(MOD_L1SP, "where am I? %x", offset); |
| 5318 | curOffset = SpcIo_GetDataFromAp(offset, sizeof(Data_Header), &Data_Header, comeFrom); |
| 5319 | tempProclen += sizeof(Data_Header); |
| 5320 | |
| 5321 | kal_prompt_trace(MOD_L1SP, "where am I?? %x", curOffset); |
| 5322 | |
| 5323 | if((Data_Header&0x0F) == 0xF) |
| 5324 | { |
| 5325 | switch(unit) { |
| 5326 | case Vol_in_general_unit: |
| 5327 | { |
| 5328 | spcCommonData *CommonParData; |
| 5329 | uint16 *m_para; // debug print |
| 5330 | |
| 5331 | CommonParData = (spcCommonData *)emDataBuf; |
| 5332 | // reuse the emDataBuf to get data |
| 5333 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcCommonData), CommonParData, comeFrom); |
| 5334 | tempProclen += sizeof(spcCommonData); |
| 5335 | |
| 5336 | L1SP_LoadCommonSpeechPara(CommonParData->Common_Para); |
| 5337 | |
| 5338 | // debug Print |
| 5339 | m_para = CommonParData->Common_Para; // size NUM_COMMON_PARAS |
| 5340 | MD_TRC_L1SP_COMMON_PARAM_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11]); |
| 5341 | |
| 5342 | L1Audio_SetDebugInfo(CommonParData->Debug_info_para); |
| 5343 | VMREC_ConfigEpl(); |
| 5344 | spc_dev_LoopbackPoint_DVT(CommonParData->Debug_info_para[15]); |
| 5345 | |
| 5346 | // debug Print |
| 5347 | m_para = CommonParData->Debug_info_para; |
| 5348 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5349 | |
| 5350 | SET_SPC_EM_INIT(SPC_EM_INIT_COMMON); |
| 5351 | } |
| 5352 | break; |
| 5353 | case Vol_in_MagiClarity: |
| 5354 | { |
| 5355 | spcMagiClarityData *MagiClarityData; |
| 5356 | MagiClarityData = (spcMagiClarityData *)emDataBuf; |
| 5357 | |
| 5358 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcMagiClarityData), MagiClarityData, comeFrom); |
| 5359 | tempProclen += sizeof(spcMagiClarityData); |
| 5360 | |
| 5361 | // L1SP_MagiClarityData(MagiClarityData->MagiClarity_Para); |
| 5362 | |
| 5363 | } |
| 5364 | break; |
| 5365 | case Vol_in_echoRefforUsbAudio: |
| 5366 | { |
| 5367 | spcDynParEchoRefForUsbAudio_T *usbAudioParam; |
| 5368 | usbAudioParam = (spcDynParEchoRefForUsbAudio_T *)(&emDataBuf); //buffer reuse |
| 5369 | |
| 5370 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParEchoRefForUsbAudio_T), usbAudioParam, comeFrom); |
| 5371 | tempProclen += sizeof(spcDynParEchoRefForUsbAudio_T); |
| 5372 | |
| 5373 | // [remove] |
| 5374 | // SPE_SetEchoRefInfo(usbAudioParam->isEchoRefForUsbAudioOn, usbAudioParam->mic_index, usbAudioParam->chip_delay_with_switch, SPH_MODE_USB); |
| 5375 | } |
| 5376 | break; |
| 5377 | default: |
| 5378 | break; |
| 5379 | } |
| 5380 | |
| 5381 | |
| 5382 | } |
| 5383 | else |
| 5384 | { |
| 5385 | MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,unit,0); |
| 5386 | ASSERT(0); // Not support the Header |
| 5387 | } |
| 5388 | |
| 5389 | *procLen = tempProclen; |
| 5390 | return curOffset; |
| 5391 | |
| 5392 | } |
| 5393 | |
| 5394 | kal_uint16 spc_dynamicParameterParser_dmnrUnit(spcDynParHeader *Header, |
| 5395 | const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5396 | kal_uint16 *procLen) |
| 5397 | { |
| 5398 | kal_uint16 DynamicParCount; |
| 5399 | kal_uint16 i; |
| 5400 | kal_uint16 Data_Header; |
| 5401 | kal_uint16 curOffset = offset; |
| 5402 | kal_uint16 tempProclen = 0; |
| 5403 | |
| 5404 | int16 *m_para; // debug print |
| 5405 | |
| 5406 | // kal_trace( TRACE_FUNC,SPC_SPE_RECEIVEDYNAMICPARAMETER4); |
| 5407 | MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(Vol_in_DMNR, length, comeFrom); |
| 5408 | DynamicParCount = (((Header->NumEachLayer)&0xF0)>>4) * ((Header->NumEachLayer)&0x0F); |
| 5409 | |
| 5410 | |
| 5411 | for(i=0;i<DynamicParCount;i++) |
| 5412 | { |
| 5413 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom); |
| 5414 | tempProclen += sizeof(Data_Header); |
| 5415 | MD_TRC_SPC_SPE_DMNR_HEADER(Data_Header); |
| 5416 | if(Data_Header==Header_DMNR_NB_REC) |
| 5417 | { |
| 5418 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_NB_REC), &DMNR_NB_REC, comeFrom); |
| 5419 | tempProclen += sizeof(DMNR_NB_REC); |
| 5420 | L1SP_SetDMNRPara(DMNR_NB_REC); |
| 5421 | SET_SPC_EM_INIT(SPC_EM_INIT_DMNR); |
| 5422 | |
| 5423 | m_para = DMNR_NB_REC; |
| 5424 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5425 | m_para = &(DMNR_NB_REC[16]); |
| 5426 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5427 | m_para = &(DMNR_NB_REC[32]); |
| 5428 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], 0,0,0,0); |
| 5429 | |
| 5430 | } |
| 5431 | else if(Data_Header == Header_DMNR_WB_REC) |
| 5432 | { |
| 5433 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_WB_REC), &DMNR_WB_REC, comeFrom); |
| 5434 | tempProclen += sizeof(DMNR_WB_REC); |
| 5435 | L1SP_SetWbDMNRPara(DMNR_WB_REC); |
| 5436 | SET_SPC_EM_INIT(SPC_EM_INIT_DMNR); |
| 5437 | |
| 5438 | m_para = DMNR_WB_REC; |
| 5439 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5440 | m_para = &(DMNR_WB_REC[16]); |
| 5441 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5442 | m_para = &(DMNR_WB_REC[32]); |
| 5443 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5444 | m_para = &(DMNR_WB_REC[48]); |
| 5445 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5446 | m_para = &(DMNR_WB_REC[64]); |
| 5447 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], 0,0,0,0); |
| 5448 | } |
| 5449 | else if(Data_Header == Header_DMNR_NB_LSP) |
| 5450 | { |
| 5451 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_NB_LoudSpk), &DMNR_NB_LoudSpk, comeFrom); |
| 5452 | tempProclen += sizeof(DMNR_NB_LoudSpk); |
| 5453 | L1SP_SetLSpkDMNRPara(DMNR_NB_LoudSpk); |
| 5454 | SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR); |
| 5455 | |
| 5456 | m_para = DMNR_NB_LoudSpk; |
| 5457 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5458 | m_para = &(DMNR_NB_LoudSpk[16]); |
| 5459 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5460 | m_para = &(DMNR_NB_LoudSpk[32]); |
| 5461 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], 0,0,0,0); |
| 5462 | |
| 5463 | } |
| 5464 | |
| 5465 | else if(Data_Header == Header_DMNR_WB_LSP) |
| 5466 | { |
| 5467 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_WB_LoudSpk), &DMNR_WB_LoudSpk, comeFrom); |
| 5468 | tempProclen += sizeof(DMNR_WB_LoudSpk); |
| 5469 | L1SP_SetLSpkWbDMNRPara(DMNR_WB_LoudSpk); |
| 5470 | SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR); |
| 5471 | |
| 5472 | m_para = DMNR_WB_LoudSpk; |
| 5473 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5474 | m_para = &(DMNR_WB_LoudSpk[16]); |
| 5475 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5476 | m_para = &(DMNR_WB_LoudSpk[32]); |
| 5477 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5478 | m_para = &(DMNR_WB_LoudSpk[48]); |
| 5479 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5480 | m_para = &(DMNR_WB_LoudSpk[64]); |
| 5481 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], 0,0,0,0); |
| 5482 | } |
| 5483 | else if((Data_Header == Header_DMNR_SWB_REC) ) |
| 5484 | { |
| 5485 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_SWB_REC), &DMNR_SWB_REC, comeFrom); |
| 5486 | tempProclen += sizeof(DMNR_SWB_REC); |
| 5487 | L1SP_SetSWbDMNRPara(DMNR_SWB_REC); |
| 5488 | SET_SPC_EM_INIT(SPC_EM_INIT_DMNR); |
| 5489 | m_para = DMNR_SWB_REC; |
| 5490 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5491 | m_para = &(DMNR_SWB_REC[16]); |
| 5492 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5493 | m_para = &(DMNR_SWB_REC[32]); |
| 5494 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5495 | m_para = &(DMNR_SWB_REC[48]); |
| 5496 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5497 | m_para = &(DMNR_SWB_REC[64]); |
| 5498 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5499 | m_para = &(DMNR_SWB_REC[80]); |
| 5500 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5501 | m_para = &(DMNR_SWB_REC[96]); |
| 5502 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5503 | m_para = &(DMNR_SWB_REC[112]); |
| 5504 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], 0, 0,0,0, 0, 0, 0); |
| 5505 | } |
| 5506 | else if((Data_Header == Header_DMNR_SWB_LSP) ) |
| 5507 | { |
| 5508 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_SWB_LoudSpk), &DMNR_SWB_LoudSpk, comeFrom); |
| 5509 | tempProclen += sizeof(DMNR_SWB_LoudSpk); |
| 5510 | L1SP_SetLSpkSWbDMNRPara(DMNR_SWB_LoudSpk); |
| 5511 | SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR); |
| 5512 | m_para = DMNR_SWB_LoudSpk; |
| 5513 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5514 | m_para = &(DMNR_SWB_LoudSpk[16]); |
| 5515 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5516 | m_para = &(DMNR_SWB_LoudSpk[32]); |
| 5517 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5518 | m_para = &(DMNR_SWB_LoudSpk[48]); |
| 5519 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5520 | m_para = &(DMNR_SWB_LoudSpk[64]); |
| 5521 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5522 | m_para = &(DMNR_SWB_LoudSpk[80]); |
| 5523 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5524 | m_para = &(DMNR_SWB_LoudSpk[96]); |
| 5525 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], m_para[9], m_para[10], m_para[11], m_para[12], m_para[13], m_para[14], m_para[15]); |
| 5526 | m_para = &(DMNR_SWB_LoudSpk[112]); |
| 5527 | MD_TRC_L1SP_MODE_VALUE(m_para[0], m_para[1], m_para[2], m_para[3], m_para[4], m_para[5], m_para[6], m_para[7], m_para[8], 0, 0,0,0, 0, 0, 0); |
| 5528 | } |
| 5529 | else |
| 5530 | { |
| 5531 | MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,Vol_in_DMNR,0); |
| 5532 | ASSERT(0);//not support the dataheader |
| 5533 | } |
| 5534 | // SetSpeechEnhancement(false); |
| 5535 | // SetSpeechEnhancement(true); |
| 5536 | } |
| 5537 | |
| 5538 | |
| 5539 | *procLen = tempProclen; |
| 5540 | return curOffset; |
| 5541 | } |
| 5542 | |
| 5543 | |
| 5544 | kal_uint16 spc_dynamicParameterParser_volDeUnit_ver10(kal_uint16 DynamicParCount, |
| 5545 | const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5546 | kal_uint16 *procLen) |
| 5547 | { |
| 5548 | kal_uint16 Data_Header; |
| 5549 | kal_uint16 tempProclen = 0; |
| 5550 | kal_uint16 curOffset = offset; |
| 5551 | |
| 5552 | kal_uint16 i,Network,k; |
| 5553 | |
| 5554 | for(i = 0 ; i < DynamicParCount ; i ++) |
| 5555 | { |
| 5556 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom); |
| 5557 | tempProclen += sizeof(Data_Header); |
| 5558 | |
| 5559 | if(((Data_Header&0xF000)>>8)==NB_Par) |
| 5560 | { |
| 5561 | |
| 5562 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData_V10), &NBParData_v10, comeFrom); |
| 5563 | tempProclen += sizeof(spcDynParNBData_V10); |
| 5564 | |
| 5565 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5566 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5567 | if((Network>>12)==DONT_CARE_NETWORK) |
| 5568 | { |
| 5569 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5570 | { |
| 5571 | memcpy(Temp_speech_NB_Mode_para[k], NBParData_v10.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5572 | memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData_v10.speech_NB_FIR_IN_para, 45*sizeof(uint16)) ; |
| 5573 | memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData_v10.speech_NB_FIR_OUT_para, 45*sizeof(uint16)) ; |
| 5574 | } |
| 5575 | } |
| 5576 | else |
| 5577 | { |
| 5578 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5579 | { |
| 5580 | if(((Network>>k)&0x1)) |
| 5581 | { |
| 5582 | memcpy(Temp_speech_NB_Mode_para[k], NBParData_v10.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5583 | memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData_v10.speech_NB_FIR_IN_para, 45*sizeof(uint16)) ; |
| 5584 | memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData_v10.speech_NB_FIR_OUT_para, 45*sizeof(uint16)) ; |
| 5585 | } |
| 5586 | } |
| 5587 | } |
| 5588 | |
| 5589 | SET_SPC_EM_INIT(SPC_EM_INIT_NB); |
| 5590 | } |
| 5591 | else if((((Data_Header&0xF000)>>8)==WB_Par)) |
| 5592 | { |
| 5593 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom); |
| 5594 | tempProclen += sizeof(spcDynParWBData); |
| 5595 | |
| 5596 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5597 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5598 | if((Network>>12)==DONT_CARE_NETWORK) |
| 5599 | { |
| 5600 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5601 | { |
| 5602 | memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5603 | memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5604 | memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5605 | } |
| 5606 | } |
| 5607 | else |
| 5608 | { |
| 5609 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5610 | { |
| 5611 | if(((Network>>k)&0x1)) |
| 5612 | { |
| 5613 | memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5614 | memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5615 | memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5616 | } |
| 5617 | } |
| 5618 | } |
| 5619 | SET_SPC_EM_INIT(SPC_EM_INIT_WB); |
| 5620 | } |
| 5621 | else if((((Data_Header&0xF000)>>8)==SWB_Par)) |
| 5622 | { |
| 5623 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom); |
| 5624 | tempProclen += sizeof(spcDynParSWBData); |
| 5625 | |
| 5626 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5627 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5628 | if((Network>>12)==DONT_CARE_NETWORK) |
| 5629 | { |
| 5630 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5631 | { |
| 5632 | memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5633 | memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5634 | memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5635 | } |
| 5636 | } |
| 5637 | else |
| 5638 | { |
| 5639 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5640 | { |
| 5641 | if(((Network>>k)&0x1)) |
| 5642 | { |
| 5643 | memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5644 | memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5645 | memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5646 | } |
| 5647 | } |
| 5648 | } |
| 5649 | SET_SPC_EM_INIT(SPC_EM_INIT_SWB); |
| 5650 | } |
| 5651 | else |
| 5652 | { |
| 5653 | //Not suppot bandover |
| 5654 | MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0); |
| 5655 | ASSERT(0); |
| 5656 | } |
| 5657 | } |
| 5658 | |
| 5659 | *procLen = tempProclen; |
| 5660 | return curOffset; |
| 5661 | } |
| 5662 | |
| 5663 | kal_uint16 spc_dynamicParameterParser_volDeUnit_ver20(kal_uint16 DynamicParCount, |
| 5664 | const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5665 | kal_uint16 *procLen) |
| 5666 | { |
| 5667 | kal_uint16 Data_Header; |
| 5668 | kal_uint16 tempProclen = 0; |
| 5669 | kal_uint16 curOffset = offset; |
| 5670 | |
| 5671 | kal_uint16 i,Network,k; |
| 5672 | |
| 5673 | for(i = 0 ; i < DynamicParCount ; i ++) |
| 5674 | { |
| 5675 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom); |
| 5676 | tempProclen += sizeof(Data_Header); |
| 5677 | |
| 5678 | if(((Data_Header&0xF000)>>8)==NB_Par) |
| 5679 | { |
| 5680 | |
| 5681 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData), &NBParData, comeFrom); |
| 5682 | tempProclen += sizeof(spcDynParNBData); |
| 5683 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBIIRData), &NBIIRParData, comeFrom); |
| 5684 | tempProclen += sizeof(spcDynParNBIIRData); |
| 5685 | |
| 5686 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5687 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5688 | if(Network==0x0FFF) // all network use same par. |
| 5689 | { |
| 5690 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5691 | { |
| 5692 | memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5693 | memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5694 | memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5695 | memcpy(Temp_speech_NB_IIR_IN_para[k], NBIIRParData.speech_NB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5696 | memcpy(Temp_speech_NB_IIR_OUT_para[k], NBIIRParData.speech_NB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5697 | memcpy(Temp_speech_NB_MIC1_IIR_para[k], NBIIRParData.speech_NB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5698 | memcpy(Temp_speech_NB_MIC2_IIR_para[k], NBIIRParData.speech_NB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5699 | } |
| 5700 | } |
| 5701 | else |
| 5702 | { |
| 5703 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5704 | { |
| 5705 | if(((Network>>k)&0x1)) |
| 5706 | { |
| 5707 | memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5708 | memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5709 | memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5710 | memcpy(Temp_speech_NB_IIR_IN_para[k], NBIIRParData.speech_NB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5711 | memcpy(Temp_speech_NB_IIR_OUT_para[k], NBIIRParData.speech_NB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5712 | memcpy(Temp_speech_NB_MIC1_IIR_para[k], NBIIRParData.speech_NB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5713 | memcpy(Temp_speech_NB_MIC2_IIR_para[k], NBIIRParData.speech_NB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5714 | } |
| 5715 | } |
| 5716 | } |
| 5717 | |
| 5718 | SET_SPC_EM_INIT(SPC_EM_INIT_NB); |
| 5719 | } |
| 5720 | else if((((Data_Header&0xF000)>>8)==WB_Par)) |
| 5721 | { |
| 5722 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom); |
| 5723 | tempProclen += sizeof(spcDynParWBData); |
| 5724 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBIIRData), &WBIIRParData, comeFrom); |
| 5725 | tempProclen += sizeof(spcDynParWBIIRData); |
| 5726 | |
| 5727 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5728 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5729 | if(Network==0x0FFF) // all network use same par. |
| 5730 | { |
| 5731 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5732 | { |
| 5733 | memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5734 | memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5735 | memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5736 | memcpy(Temp_speech_WB_IIR_IN_para[k], WBIIRParData.speech_WB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5737 | memcpy(Temp_speech_WB_IIR_OUT_para[k], WBIIRParData.speech_WB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5738 | memcpy(Temp_speech_WB_MIC1_IIR_para[k], WBIIRParData.speech_WB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5739 | memcpy(Temp_speech_WB_MIC2_IIR_para[k], WBIIRParData.speech_WB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5740 | } |
| 5741 | } |
| 5742 | else |
| 5743 | { |
| 5744 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5745 | { |
| 5746 | if(((Network>>k)&0x1)) |
| 5747 | { |
| 5748 | memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5749 | memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5750 | memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5751 | memcpy(Temp_speech_WB_IIR_IN_para[k], WBIIRParData.speech_WB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5752 | memcpy(Temp_speech_WB_IIR_OUT_para[k], WBIIRParData.speech_WB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5753 | memcpy(Temp_speech_WB_MIC1_IIR_para[k], WBIIRParData.speech_WB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5754 | memcpy(Temp_speech_WB_MIC2_IIR_para[k], WBIIRParData.speech_WB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5755 | } |
| 5756 | } |
| 5757 | } |
| 5758 | SET_SPC_EM_INIT(SPC_EM_INIT_WB); |
| 5759 | } |
| 5760 | else if((((Data_Header&0xF000)>>8)==SWB_Par)) |
| 5761 | { |
| 5762 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom); |
| 5763 | tempProclen += sizeof(spcDynParSWBData); |
| 5764 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBIIRData), &SWBIIRParData, comeFrom); |
| 5765 | tempProclen += sizeof(spcDynParSWBIIRData); |
| 5766 | |
| 5767 | Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K |
| 5768 | MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network); |
| 5769 | if(Network==0x0FFF) // all network use same par. |
| 5770 | { |
| 5771 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5772 | { |
| 5773 | memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5774 | memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5775 | memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5776 | memcpy(Temp_speech_SWB_IIR_IN_para[k], SWBIIRParData.speech_SWB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5777 | memcpy(Temp_speech_SWB_IIR_OUT_para[k], SWBIIRParData.speech_SWB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5778 | memcpy(Temp_speech_SWB_MIC1_IIR_para[k], SWBIIRParData.speech_SWB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5779 | memcpy(Temp_speech_SWB_MIC2_IIR_para[k], SWBIIRParData.speech_SWB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5780 | } |
| 5781 | } |
| 5782 | else |
| 5783 | { |
| 5784 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5785 | { |
| 5786 | if(((Network>>k)&0x1)) |
| 5787 | { |
| 5788 | memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5789 | memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5790 | memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5791 | memcpy(Temp_speech_SWB_IIR_IN_para[k], SWBIIRParData.speech_SWB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5792 | memcpy(Temp_speech_SWB_IIR_OUT_para[k], SWBIIRParData.speech_SWB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16)); |
| 5793 | memcpy(Temp_speech_SWB_MIC1_IIR_para[k], SWBIIRParData.speech_SWB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16)); |
| 5794 | memcpy(Temp_speech_SWB_MIC2_IIR_para[k], SWBIIRParData.speech_SWB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16)); |
| 5795 | } |
| 5796 | } |
| 5797 | } |
| 5798 | SET_SPC_EM_INIT(SPC_EM_INIT_SWB); |
| 5799 | } |
| 5800 | else |
| 5801 | { |
| 5802 | //Not suppot bandover |
| 5803 | MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0); |
| 5804 | ASSERT(0); |
| 5805 | } |
| 5806 | } |
| 5807 | SET_SPC_EM_INIT(SPC_EM_INIT_IIR); |
| 5808 | *procLen = tempProclen; |
| 5809 | return curOffset; |
| 5810 | } |
| 5811 | |
| 5812 | kal_uint16 spc_dynamicParameterParser_volDeUnit_ver00(kal_uint16 DynamicParCount, |
| 5813 | const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5814 | kal_uint16 *procLen) |
| 5815 | { |
| 5816 | kal_uint16 Data_Header; |
| 5817 | kal_uint16 tempProclen = 0; |
| 5818 | kal_uint16 curOffset = offset; |
| 5819 | |
| 5820 | kal_uint16 i,Network,k; |
| 5821 | |
| 5822 | for(i = 0 ; i < DynamicParCount ; i ++) |
| 5823 | { |
| 5824 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom); |
| 5825 | tempProclen = tempProclen + sizeof(Data_Header); |
| 5826 | |
| 5827 | if(((Data_Header&0xF0)==NB_Par)) |
| 5828 | { |
| 5829 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData), &NBParData, comeFrom); |
| 5830 | tempProclen = tempProclen + sizeof(spcDynParNBData); |
| 5831 | |
| 5832 | Network = (Data_Header&0x0F); |
| 5833 | if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK) |
| 5834 | { |
| 5835 | memcpy(Temp_speech_NB_Mode_para[Network-1], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5836 | memcpy(Temp_speech_NB_FIR_IN_para[Network-1], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5837 | memcpy(Temp_speech_NB_FIR_OUT_para[Network-1], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5838 | } |
| 5839 | else if(Network==DONT_CARE_NETWORK) |
| 5840 | { |
| 5841 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5842 | { |
| 5843 | memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5844 | memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5845 | memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ; |
| 5846 | } |
| 5847 | } |
| 5848 | else |
| 5849 | { |
| 5850 | // not support the network info |
| 5851 | MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0); |
| 5852 | ASSERT(0); |
| 5853 | |
| 5854 | } |
| 5855 | SET_SPC_EM_INIT(SPC_EM_INIT_NB); |
| 5856 | } |
| 5857 | else if(((Data_Header&0xF0)==WB_Par)) |
| 5858 | { |
| 5859 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom); |
| 5860 | tempProclen = tempProclen + sizeof(spcDynParWBData); |
| 5861 | |
| 5862 | Network = (Data_Header&0x0F); |
| 5863 | if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK) |
| 5864 | { |
| 5865 | memcpy(Temp_speech_WB_Mode_para[Network-1], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5866 | memcpy(Temp_speech_WB_FIR_IN_para[Network-1], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5867 | memcpy(Temp_speech_WB_FIR_OUT_para[Network-1], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5868 | } |
| 5869 | else if(Network==DONT_CARE_NETWORK) |
| 5870 | { |
| 5871 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5872 | { |
| 5873 | memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5874 | memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5875 | memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ; |
| 5876 | } |
| 5877 | } |
| 5878 | else |
| 5879 | { |
| 5880 | // not support the network info |
| 5881 | MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0); |
| 5882 | ASSERT(0); |
| 5883 | } |
| 5884 | SET_SPC_EM_INIT(SPC_EM_INIT_WB); |
| 5885 | } |
| 5886 | else if(((Data_Header&0xF0)==SWB_Par)) |
| 5887 | { |
| 5888 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom); |
| 5889 | tempProclen = tempProclen + sizeof(spcDynParSWBData); |
| 5890 | |
| 5891 | Network = (Data_Header&0x0F); |
| 5892 | if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK) |
| 5893 | { |
| 5894 | memcpy(Temp_speech_SWB_Mode_para[Network-1], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5895 | memcpy(Temp_speech_SWB_FIR_IN_para[Network-1], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5896 | memcpy(Temp_speech_SWB_FIR_OUT_para[Network-1], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5897 | } |
| 5898 | else if(Network==DONT_CARE_NETWORK) |
| 5899 | { |
| 5900 | for(k = 0; k < TOTAL_NETWORK_NUMBER; k++) |
| 5901 | { |
| 5902 | memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ; |
| 5903 | memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5904 | memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ; |
| 5905 | } |
| 5906 | } |
| 5907 | else |
| 5908 | { |
| 5909 | // not support the network info |
| 5910 | MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0); |
| 5911 | ASSERT(0); |
| 5912 | } |
| 5913 | SET_SPC_EM_INIT(SPC_EM_INIT_SWB); |
| 5914 | } |
| 5915 | else |
| 5916 | { |
| 5917 | //Not suppot bandover |
| 5918 | MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0); |
| 5919 | ASSERT(0); |
| 5920 | } |
| 5921 | } |
| 5922 | |
| 5923 | *procLen = tempProclen; |
| 5924 | return curOffset; |
| 5925 | } |
| 5926 | |
| 5927 | |
| 5928 | |
| 5929 | /** |
| 5930 | @return: magic |
| 5931 | @procLen: [OUTPUT] process length |
| 5932 | */ |
| 5933 | |
| 5934 | uint16 spc_dynamicParameterParser_dispatcher(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom, |
| 5935 | kal_uint16 *procLen, kal_uint16 *newOffset) |
| 5936 | { |
| 5937 | spcDynParHeader Header; |
| 5938 | kal_uint16 curOffset; |
| 5939 | uint16 unProcLen = length; |
| 5940 | |
| 5941 | memset(&Header, 0, sizeof(spcDynParHeader)); |
| 5942 | curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcDynParHeader), &Header, comeFrom); |
| 5943 | unProcLen = unProcLen - sizeof(spcDynParHeader); |
| 5944 | |
| 5945 | kal_prompt_trace(MOD_L1SP, "where am I dispatcher: %x, %x, %x, %d", offset, curOffset, length, comeFrom); |
| 5946 | |
| 5947 | |
| 5948 | switch(Header.SphUnitMagiNum){ |
| 5949 | case 0: |
| 5950 | { |
| 5951 | // when curOffset == offset, it also means cannot get data from AP param_shm |
| 5952 | // cannot get data from AP |
| 5953 | unProcLen = 0; |
| 5954 | |
| 5955 | } |
| 5956 | break; |
| 5957 | case Vol_de_speech_unit: |
| 5958 | { |
| 5959 | kal_uint16 DynamicParCount = 0; //initialize |
| 5960 | kal_uint16 SpeechIndex; // bit1: Volume index, bit0: Mode |
| 5961 | // kal_uint16 Data_Header; |
| 5962 | kal_uint16 Mode; |
| 5963 | kal_uint16 count; |
| 5964 | |
| 5965 | //Param_Header_Layer1; Network |
| 5966 | //Param_Header_Layer2; VoiceBand |
| 5967 | // kal_trace( TRACE_FUNC,SPC_SPE_RECEIVEDYNAMICPARAMETER1); |
| 5968 | MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(Vol_de_speech_unit, length, comeFrom); |
| 5969 | if(Header.NumLayer == 0x2) |
| 5970 | { |
| 5971 | DynamicParCount = (((Header.NumEachLayer)&0x00F0)>>4) * ((Header.NumEachLayer)&0x000F); |
| 5972 | } |
| 5973 | else if(Header.NumLayer == 0x1) |
| 5974 | { |
| 5975 | DynamicParCount = ((Header.NumEachLayer)&0x000F); |
| 5976 | } |
| 5977 | else |
| 5978 | { |
| 5979 | //Not suppot over 2 Layer |
| 5980 | MD_TRC_SPC_SPE_ASSERT_CHECK(Header.NumLayer,0,0); |
| 5981 | ASSERT(0); |
| 5982 | } |
| 5983 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(SpeechIndex), &SpeechIndex, comeFrom); |
| 5984 | unProcLen = unProcLen - sizeof(SpeechIndex); |
| 5985 | |
| 5986 | Mode = (SpeechIndex&0x0F); |
| 5987 | SpeechIndex = (((SpeechIndex)&0xF0)>>4); |
| 5988 | MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER2(Mode,SpeechIndex,Header.Param_Header_Layer3); |
| 5989 | |
| 5990 | if(Header.Param_Header_Layer3== 0x10) // Version 1.0. |
| 5991 | { |
| 5992 | kal_uint16 procLen=0; |
| 5993 | curOffset = spc_dynamicParameterParser_volDeUnit_ver10(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen); |
| 5994 | unProcLen = unProcLen - procLen; |
| 5995 | } |
| 5996 | else if(Header.Param_Header_Layer3== 0x20) // Version 2.0. |
| 5997 | { |
| 5998 | kal_uint16 procLen=0; |
| 5999 | curOffset = spc_dynamicParameterParser_volDeUnit_ver20(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen); |
| 6000 | unProcLen = unProcLen - procLen; |
| 6001 | |
| 6002 | } |
| 6003 | else //Version 0.0 |
| 6004 | { |
| 6005 | kal_uint16 procLen=0; |
| 6006 | curOffset = spc_dynamicParameterParser_volDeUnit_ver00(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen); |
| 6007 | unProcLen = unProcLen - procLen; |
| 6008 | } |
| 6009 | l1sp_setAllSpeechModePara((kal_uint16 *) Temp_speech_NB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 6010 | l1sp_setAllSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_NB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_FIR_COEFFS); |
| 6011 | l1sp_setAllSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_NB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_FIR_COEFFS); |
| 6012 | l1sp_setAllWbSpeechModePara((kal_uint16 *)Temp_speech_WB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 6013 | l1sp_setAllWbSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_WB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_WB_FIR_COEFFS); |
| 6014 | l1sp_setAllWbSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_WB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_WB_FIR_COEFFS); |
| 6015 | l1sp_setAllSWbSpeechModePara((kal_uint16 *)Temp_speech_SWB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS); |
| 6016 | l1sp_setAllSWbSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_SWB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_SWB_FIR_COEFFS); |
| 6017 | l1sp_setAllSWbSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_SWB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_SWB_FIR_COEFFS); |
| 6018 | |
| 6019 | for(count=0;count<TOTAL_NETWORK_NUMBER;count++) |
| 6020 | { |
| 6021 | MD_TRC_SPC_SPE_CHECK_NB_MODE_PAR(count,Temp_speech_NB_Mode_para[count][0],Temp_speech_NB_Mode_para[count][1],Temp_speech_NB_Mode_para[count][2],Temp_speech_NB_Mode_para[count][3],Temp_speech_NB_Mode_para[count][4]); |
| 6022 | MD_TRC_SPC_SPE_CHECK_NB_FIR_IN_PAR(count,Temp_speech_NB_FIR_IN_para[count][0],Temp_speech_NB_FIR_IN_para[count][1],Temp_speech_NB_FIR_IN_para[count][2],Temp_speech_NB_FIR_IN_para[count][3],Temp_speech_NB_FIR_IN_para[count][4]); |
| 6023 | MD_TRC_SPC_SPE_CHECK_NB_FIR_OUT_PAR(count,Temp_speech_NB_FIR_OUT_para[count][0],Temp_speech_NB_FIR_OUT_para[count][1],Temp_speech_NB_FIR_OUT_para[count][2],Temp_speech_NB_FIR_OUT_para[count][3],Temp_speech_NB_FIR_OUT_para[count][4]); |
| 6024 | MD_TRC_SPC_SPE_CHECK_WB_MODE_PAR(count,Temp_speech_WB_Mode_para[count][0],Temp_speech_WB_Mode_para[count][1],Temp_speech_WB_Mode_para[count][2],Temp_speech_WB_Mode_para[count][3],Temp_speech_WB_Mode_para[count][4]); |
| 6025 | MD_TRC_SPC_SPE_CHECK_WB_FIR_IN_PAR(count,Temp_speech_WB_FIR_IN_para[count][0],Temp_speech_WB_FIR_IN_para[count][1],Temp_speech_WB_FIR_IN_para[count][2],Temp_speech_WB_FIR_IN_para[count][3],Temp_speech_WB_FIR_IN_para[count][4]); |
| 6026 | MD_TRC_SPC_SPE_CHECK_WB_FIR_OUT_PAR(count,Temp_speech_WB_FIR_OUT_para[count][0],Temp_speech_WB_FIR_OUT_para[count][1],Temp_speech_WB_FIR_OUT_para[count][2],Temp_speech_WB_FIR_OUT_para[count][3],Temp_speech_WB_FIR_OUT_para[count][4]); |
| 6027 | MD_TRC_SPC_SPE_CHECK_SWB_MODE_PAR(count,Temp_speech_SWB_Mode_para[count][0],Temp_speech_SWB_Mode_para[count][1],Temp_speech_SWB_Mode_para[count][2],Temp_speech_SWB_Mode_para[count][3],Temp_speech_SWB_Mode_para[count][4]); |
| 6028 | MD_TRC_SPC_SPE_CHECK_SWB_FIR_IN_PAR(count,Temp_speech_SWB_FIR_IN_para[count][0],Temp_speech_SWB_FIR_IN_para[count][1],Temp_speech_SWB_FIR_IN_para[count][2],Temp_speech_SWB_FIR_IN_para[count][3],Temp_speech_SWB_FIR_IN_para[count][4]); |
| 6029 | MD_TRC_SPC_SPE_CHECK_SWB_FIR_OUT_PAR(count,Temp_speech_SWB_FIR_OUT_para[count][0],Temp_speech_SWB_FIR_OUT_para[count][1],Temp_speech_SWB_FIR_OUT_para[count][2],Temp_speech_SWB_FIR_OUT_para[count][3],Temp_speech_SWB_FIR_OUT_para[count][4]); |
| 6030 | } |
| 6031 | |
| 6032 | if(Header.Param_Header_Layer3== 0x20) // Version 2.0. |
| 6033 | { |
| 6034 | l1sp_setAllSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_NB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6035 | l1sp_setAllSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_NB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6036 | l1sp_setAllSpeechMic1IirCoeff((kal_int16 *)Temp_speech_NB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS); |
| 6037 | l1sp_setAllSpeechMic2IirCoeff((kal_int16 *)Temp_speech_NB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS); |
| 6038 | l1sp_setAllWBSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_WB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6039 | l1sp_setAllWBSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_WB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6040 | l1sp_setAllWBSpeechMic1IirCoeff((kal_int16 *)Temp_speech_WB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS); |
| 6041 | l1sp_setAllWBSpeechMic2IirCoeff((kal_int16 *)Temp_speech_WB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS); |
| 6042 | l1sp_setAllSWBSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_SWB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6043 | l1sp_setAllSWBSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_SWB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS); |
| 6044 | l1sp_setAllSWBSpeechMic1IirCoeff((kal_int16 *)Temp_speech_SWB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS); |
| 6045 | l1sp_setAllSWBSpeechMic2IirCoeff((kal_int16 *)Temp_speech_SWB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS); |
| 6046 | // l1sp_set par |
| 6047 | for(count=0;count<TOTAL_NETWORK_NUMBER;count++) |
| 6048 | { |
| 6049 | MD_TRC_SPC_SPE_CHECK_NB_IIR_IN_PAR(count,Temp_speech_NB_IIR_IN_para[count][0],Temp_speech_NB_IIR_IN_para[count][1],Temp_speech_NB_IIR_IN_para[count][2],Temp_speech_NB_IIR_IN_para[count][3],Temp_speech_NB_IIR_IN_para[count][4]); |
| 6050 | MD_TRC_SPC_SPE_CHECK_NB_IIR_OUT_PAR(count,Temp_speech_NB_IIR_OUT_para[count][0],Temp_speech_NB_IIR_OUT_para[count][1],Temp_speech_NB_IIR_OUT_para[count][2],Temp_speech_NB_IIR_OUT_para[count][3],Temp_speech_NB_IIR_OUT_para[count][4]); |
| 6051 | MD_TRC_SPC_SPE_CHECK_NB_MIC1_IIR_PAR(count,Temp_speech_NB_MIC1_IIR_para[count][0],Temp_speech_NB_MIC1_IIR_para[count][1],Temp_speech_NB_MIC1_IIR_para[count][2],Temp_speech_NB_MIC1_IIR_para[count][3],Temp_speech_NB_MIC1_IIR_para[count][4]); |
| 6052 | MD_TRC_SPC_SPE_CHECK_NB_MIC2_IIR_PAR(count,Temp_speech_NB_MIC2_IIR_para[count][0],Temp_speech_NB_MIC2_IIR_para[count][1],Temp_speech_NB_MIC2_IIR_para[count][2],Temp_speech_NB_MIC2_IIR_para[count][3],Temp_speech_NB_MIC2_IIR_para[count][4]); |
| 6053 | MD_TRC_SPC_SPE_CHECK_WB_IIR_IN_PAR(count,Temp_speech_WB_IIR_IN_para[count][0],Temp_speech_WB_IIR_IN_para[count][1],Temp_speech_WB_IIR_IN_para[count][2],Temp_speech_WB_IIR_IN_para[count][3],Temp_speech_WB_IIR_IN_para[count][4]); |
| 6054 | MD_TRC_SPC_SPE_CHECK_WB_IIR_OUT_PAR(count,Temp_speech_WB_IIR_OUT_para[count][0],Temp_speech_WB_IIR_OUT_para[count][1],Temp_speech_WB_IIR_OUT_para[count][2],Temp_speech_WB_IIR_OUT_para[count][3],Temp_speech_WB_IIR_OUT_para[count][4]); |
| 6055 | MD_TRC_SPC_SPE_CHECK_WB_MIC1_IIR_PAR(count,Temp_speech_WB_MIC1_IIR_para[count][0],Temp_speech_WB_MIC1_IIR_para[count][1],Temp_speech_WB_MIC1_IIR_para[count][2],Temp_speech_WB_MIC1_IIR_para[count][3],Temp_speech_WB_MIC1_IIR_para[count][4]); |
| 6056 | MD_TRC_SPC_SPE_CHECK_WB_MIC2_IIR_PAR(count,Temp_speech_WB_MIC2_IIR_para[count][0],Temp_speech_WB_MIC2_IIR_para[count][1],Temp_speech_WB_MIC2_IIR_para[count][2],Temp_speech_WB_MIC2_IIR_para[count][3],Temp_speech_WB_MIC2_IIR_para[count][4]); |
| 6057 | MD_TRC_SPC_SPE_CHECK_SWB_IIR_IN_PAR(count,Temp_speech_SWB_IIR_IN_para[count][0],Temp_speech_SWB_IIR_IN_para[count][1],Temp_speech_SWB_IIR_IN_para[count][2],Temp_speech_SWB_IIR_IN_para[count][3],Temp_speech_SWB_IIR_IN_para[count][4]); |
| 6058 | MD_TRC_SPC_SPE_CHECK_SWB_IIR_OUT_PAR(count,Temp_speech_SWB_IIR_OUT_para[count][0],Temp_speech_SWB_IIR_OUT_para[count][1],Temp_speech_SWB_IIR_OUT_para[count][2],Temp_speech_SWB_IIR_OUT_para[count][3],Temp_speech_SWB_IIR_OUT_para[count][4]); |
| 6059 | MD_TRC_SPC_SPE_CHECK_SWB_MIC1_IIR_PAR(count,Temp_speech_SWB_MIC1_IIR_para[count][0],Temp_speech_SWB_MIC1_IIR_para[count][1],Temp_speech_SWB_MIC1_IIR_para[count][2],Temp_speech_SWB_MIC1_IIR_para[count][3],Temp_speech_SWB_MIC1_IIR_para[count][4]); |
| 6060 | MD_TRC_SPC_SPE_CHECK_SWB_MIC2_IIR_PAR(count,Temp_speech_SWB_MIC2_IIR_para[count][0],Temp_speech_SWB_MIC2_IIR_para[count][1],Temp_speech_SWB_MIC2_IIR_para[count][2],Temp_speech_SWB_MIC2_IIR_para[count][3],Temp_speech_SWB_MIC2_IIR_para[count][4]); |
| 6061 | |
| 6062 | } |
| 6063 | |
| 6064 | } |
| 6065 | |
| 6066 | #if defined(__SPEECH_WW_OPERATOR_SCORE_ENHANCE__) |
| 6067 | spe_setMagiCon(); |
| 6068 | if(Mode!=0xF) |
| 6069 | { |
| 6070 | if(Mode == SPH_MODE_HAC) |
| 6071 | { |
| 6072 | spe_setHacModeNeeded(true); |
| 6073 | } |
| 6074 | else if(Mode == SPH_MODE_AUX1) //Magi con |
| 6075 | { |
| 6076 | Mode = SPH_MODE_LOUDSPK; |
| 6077 | } |
| 6078 | // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) Mode ); |
| 6079 | L1SP_SetSpeechEnhanceAndFir(Mode, SPH_ENH_AND_FIR_UPDATE_TYPE_ALL); |
| 6080 | } |
| 6081 | else |
| 6082 | { |
| 6083 | |
| 6084 | SetSpeechEnhancement(true); |
| 6085 | |
| 6086 | } |
| 6087 | |
| 6088 | #else |
| 6089 | spe_DisableMagiCon(); |
| 6090 | if(Mode!=0xF) |
| 6091 | { |
| 6092 | |
| 6093 | if(Mode == SPH_MODE_HAC) |
| 6094 | { |
| 6095 | spe_setHacModeNeeded(true); |
| 6096 | } |
| 6097 | else if(Mode == SPH_MODE_EARPHONE) |
| 6098 | { |
| 6099 | spe_setMagiCon(); |
| 6100 | } |
| 6101 | else if(Mode == SPH_MODE_AUX1) //Magi con |
| 6102 | { |
| 6103 | Mode = SPH_MODE_LOUDSPK; |
| 6104 | spe_setMagiCon(); |
| 6105 | |
| 6106 | } |
| 6107 | // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) Mode ); |
| 6108 | L1SP_SetSpeechEnhanceAndFir(Mode, SPH_ENH_AND_FIR_UPDATE_TYPE_ALL); |
| 6109 | } |
| 6110 | else |
| 6111 | { |
| 6112 | |
| 6113 | SetSpeechEnhancement(true); |
| 6114 | |
| 6115 | } |
| 6116 | #endif |
| 6117 | } |
| 6118 | |
| 6119 | break; |
| 6120 | |
| 6121 | case Vol_in_general_unit: |
| 6122 | { |
| 6123 | kal_uint16 procLen=0; |
| 6124 | curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_general_unit, curOffset, unProcLen, comeFrom, &procLen); |
| 6125 | unProcLen = unProcLen - procLen; |
| 6126 | SetSpeechEnhancement(false); |
| 6127 | SetSpeechEnhancement(true); |
| 6128 | } |
| 6129 | break; |
| 6130 | |
| 6131 | case Vol_in_DMNR: |
| 6132 | { |
| 6133 | kal_uint16 procLen=0; |
| 6134 | curOffset = spc_dynamicParameterParser_dmnrUnit(&Header, curOffset, unProcLen, comeFrom, &procLen); |
| 6135 | unProcLen = unProcLen - procLen; |
| 6136 | |
| 6137 | SetSpeechEnhancement(false); |
| 6138 | SetSpeechEnhancement(true); |
| 6139 | } |
| 6140 | break; |
| 6141 | case Vol_in_MagiClarity: |
| 6142 | { |
| 6143 | kal_uint16 procLen=0; |
| 6144 | curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_MagiClarity, curOffset, unProcLen, comeFrom, &procLen); |
| 6145 | unProcLen = unProcLen - procLen; |
| 6146 | } |
| 6147 | break; |
| 6148 | case Vol_in_echoRefforUsbAudio: |
| 6149 | { |
| 6150 | kal_uint16 procLen=0; |
| 6151 | curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_echoRefforUsbAudio, curOffset, unProcLen, comeFrom, &procLen); |
| 6152 | unProcLen = unProcLen - procLen; |
| 6153 | } |
| 6154 | break; |
| 6155 | default: |
| 6156 | |
| 6157 | MD_TRC_SPC_SPE_ASSERT_CHECK(Header.SphUnitMagiNum,0,0); |
| 6158 | ASSERT(0); //NOT SUPPORT THE MAGIC NUM |
| 6159 | break; |
| 6160 | } |
| 6161 | |
| 6162 | kal_prompt_trace(MOD_L1SP, "unProclen=%d with SphUnitMagiNum=%x", unProcLen, Header.SphUnitMagiNum); |
| 6163 | |
| 6164 | if(NULL!=newOffset) { |
| 6165 | *newOffset = curOffset; |
| 6166 | } |
| 6167 | if(NULL!=procLen) { |
| 6168 | *procLen = (length - unProcLen); |
| 6169 | } |
| 6170 | return Header.SphUnitMagiNum; |
| 6171 | |
| 6172 | } |
| 6173 | |
| 6174 | uint16 spc_ReceiveDynamicParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom) |
| 6175 | { |
| 6176 | kal_uint16 curOffset; |
| 6177 | |
| 6178 | |
| 6179 | // Header Check |
| 6180 | spcBufInfo info; |
| 6181 | curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom); |
| 6182 | |
| 6183 | |
| 6184 | ASSERT(info.syncWord == 0xA2A2); |
| 6185 | ASSERT((info.type) == AUD_CCCI_STRMBUF_TYPE_DYNAMCI_PAR_TYPE); //just use the bit[0:3] to inidicate the type. |
| 6186 | ASSERT(info.length == (length-6)); |
| 6187 | |
| 6188 | return spc_dynamicParameterParser_dispatcher(curOffset, length-sizeof(spcBufInfo), comeFrom, NULL, NULL); |
| 6189 | } |
| 6190 | #endif |
| 6191 | |
| 6192 | |
| 6193 | kal_uint16 get_spcGetEpofTimes(enum_EPOF_event EPOF_event) |
| 6194 | { |
| 6195 | return( (gSpc.spcGetEpofTimes) & EPOF_event ); |
| 6196 | } |
| 6197 | |
| 6198 | void set_spcGetEpofTimes(enum_EPOF_event EPOF_event, int on) |
| 6199 | { |
| 6200 | if(on) |
| 6201 | gSpc.spcGetEpofTimes |= EPOF_event; |
| 6202 | else |
| 6203 | gSpc.spcGetEpofTimes &= (~EPOF_event); |
| 6204 | } |
| 6205 | |
| 6206 | |
| 6207 | // ============================================================================ |
| 6208 | #define ILM_SPC_CUST_DUMP_BUF_LEN 2560 |
| 6209 | typedef struct{ |
| 6210 | LOCAL_PARA_HDR |
| 6211 | //raw information from eMAC |
| 6212 | uint16 dumpLen; |
| 6213 | uint16 dumpBuf[ILM_SPC_CUST_DUMP_BUF_LEN]; |
| 6214 | }ilm_spc_cust_dump_t; |
| 6215 | |
| 6216 | void spc_customDump(uint16 bufLen, uint16 *dumpBuf) |
| 6217 | { |
| 6218 | |
| 6219 | ilm_spc_cust_dump_t *ilm; |
| 6220 | uint16 len = bufLen; |
| 6221 | uint16 idx = 0; |
| 6222 | |
| 6223 | // static int32 i=0; |
| 6224 | |
| 6225 | if ( 0 == bufLen) |
| 6226 | return; |
| 6227 | |
| 6228 | while(len > ILM_SPC_CUST_DUMP_BUF_LEN) { |
| 6229 | ilm = (ilm_spc_cust_dump_t *)construct_local_para( sizeof(ilm_spc_cust_dump_t), TD_CTRL); |
| 6230 | ilm->dumpLen = ILM_SPC_CUST_DUMP_BUF_LEN; |
| 6231 | memcpy((ilm->dumpBuf), &(dumpBuf[idx]), sizeof(uint16)*ILM_SPC_CUST_DUMP_BUF_LEN); |
| 6232 | msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_CUST_DUMP_REQ, (local_para_struct *)ilm, NULL); |
| 6233 | |
| 6234 | idx = idx + ILM_SPC_CUST_DUMP_BUF_LEN; |
| 6235 | len = len - ILM_SPC_CUST_DUMP_BUF_LEN; |
| 6236 | |
| 6237 | // i++; |
| 6238 | } |
| 6239 | |
| 6240 | |
| 6241 | ilm = (ilm_spc_cust_dump_t *)construct_local_para( sizeof(ilm_spc_cust_dump_t), TD_CTRL); |
| 6242 | ilm->dumpLen = len; |
| 6243 | memcpy((ilm->dumpBuf), &(dumpBuf[idx]), sizeof(uint16)*len); |
| 6244 | msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_CUST_DUMP_REQ, (local_para_struct *)ilm, NULL); |
| 6245 | |
| 6246 | // i++; |
| 6247 | |
| 6248 | // kal_prompt_trace(MOD_L1SP, "spc_customDump' i=%d", i); |
| 6249 | } |
| 6250 | |
| 6251 | void spc_sendCustomDump(void *ilm) |
| 6252 | { |
| 6253 | uint16 bufLen; |
| 6254 | uint16 *dumpBuf; |
| 6255 | uint16 lenInByte; |
| 6256 | spcBufInfo info; |
| 6257 | bool sendResult = true; |
| 6258 | |
| 6259 | // static int32 j=0; |
| 6260 | |
| 6261 | bufLen = ((ilm_spc_cust_dump_t *)(ilm))->dumpLen; |
| 6262 | dumpBuf = ((ilm_spc_cust_dump_t *)(ilm))->dumpBuf; |
| 6263 | |
| 6264 | if(NULL == dumpBuf || 0 == bufLen) |
| 6265 | return; |
| 6266 | |
| 6267 | lenInByte = (bufLen <<1); |
| 6268 | |
| 6269 | #if 0 |
| 6270 | /* under construction !*/ |
| 6271 | /* under construction !*/ |
| 6272 | /* under construction !*/ |
| 6273 | /* under construction !*/ |
| 6274 | /* under construction !*/ |
| 6275 | /* under construction !*/ |
| 6276 | /* under construction !*/ |
| 6277 | /* under construction !*/ |
| 6278 | /* under construction !*/ |
| 6279 | /* under construction !*/ |
| 6280 | /* under construction !*/ |
| 6281 | /* under construction !*/ |
| 6282 | /* under construction !*/ |
| 6283 | /* under construction !*/ |
| 6284 | /* under construction !*/ |
| 6285 | /* under construction !*/ |
| 6286 | #endif |
| 6287 | |
| 6288 | |
| 6289 | info.syncWord = 0x2A2A; |
| 6290 | info.type = AUD_CCCI_STRMBUF_TYPE_CUST_DUMP; |
| 6291 | info.length = lenInByte; |
| 6292 | |
| 6293 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), |
| 6294 | (void *)(dumpBuf), lenInByte, NULL, 0, |
| 6295 | SPCIO_MSG_FROM_SPC_CUST_DUMP_NOTIFY); |
| 6296 | |
| 6297 | if(false == sendResult) { |
| 6298 | // leave log here |
| 6299 | MD_TRC_SPC_CUST_DUMP_DROP(); |
| 6300 | } |
| 6301 | |
| 6302 | } |
| 6303 | |
| 6304 | // Remind: DebugInfo[15] also control this. loopback point |
| 6305 | void spc_dev_LoopbackPoint_DVT(kal_uint16 point){ |
| 6306 | switch(point){ |
| 6307 | |
| 6308 | case 0: |
| 6309 | AFE_SetConn0(0x54321076); //default value, case 0 : reset |
| 6310 | break; |
| 6311 | case 1: |
| 6312 | AFE_SetConn0(0x54321010); // O17, O18 |
| 6313 | break; |
| 6314 | case 2: |
| 6315 | AFE_SetConn0(0x54321032); // O23, O24 |
| 6316 | break; |
| 6317 | case 3: |
| 6318 | AFE_SetConn0(0x54321054); // O25 |
| 6319 | break; |
| 6320 | case 4: |
| 6321 | AFE_SetConn0(0x54321045); // O25_swap |
| 6322 | break; |
| 6323 | case 5: |
| 6324 | AFE_SetConn0(0x54327676); // DL -> UL |
| 6325 | break; |
| 6326 | default: |
| 6327 | kal_prompt_trace(MOD_L1SP, "[LPBK_DVT] invalid value, set 0x54321076"); |
| 6328 | AFE_SetConn0(0x54321076); |
| 6329 | } |
| 6330 | } |
| 6331 | |
| 6332 | #if defined(__ECALL_SUPPORT__) |
| 6333 | void spc_eCall_SDT_Open(void) |
| 6334 | { |
| 6335 | spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY); |
| 6336 | eCall_IVS_Open(aud_ecall_event_callback); |
| 6337 | eCall_IVS_PutMSD(eCall_Msd,140,0); // DEFAULT PAR |
| 6338 | } |
| 6339 | |
| 6340 | void spc_eCall_SDT_Close(void) |
| 6341 | { |
| 6342 | eCall_IVS_Close(); |
| 6343 | spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE); |
| 6344 | } |
| 6345 | |
| 6346 | void spc_eCall_IVS_Open(void) |
| 6347 | { |
| 6348 | eCall_IVS_Close(); |
| 6349 | spc_Set_Ecall_Lib_Status(SPC_ECALL_ENABLE); |
| 6350 | eCall_IVS_Open(aud_ecall_event_callback); |
| 6351 | eCall_IVS_PutMSD(eCall_Msd,140,0); |
| 6352 | } |
| 6353 | |
| 6354 | void spc_eCall_IVS_Close(void) |
| 6355 | { |
| 6356 | eCall_IVS_Close(); |
| 6357 | spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY); |
| 6358 | eCall_IVS_Open(aud_ecall_event_callback); |
| 6359 | } |
| 6360 | |
| 6361 | void spc_eCall_PSAP_Open(void) |
| 6362 | { |
| 6363 | eCall_IVS_Close(); |
| 6364 | spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE); // Set ivs ststus=disable |
| 6365 | eCall_PSAP_Open(aud_ecall_event_callback); |
| 6366 | } |
| 6367 | |
| 6368 | void spc_eCall_PSAP_Close(void) |
| 6369 | { |
| 6370 | eCall_PSAP_Close(); |
| 6371 | spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY);// Set ivs ststus=SDT detect |
| 6372 | eCall_IVS_Open(aud_ecall_event_callback); |
| 6373 | } |
| 6374 | |
| 6375 | void spc_eCall_Msd_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom) |
| 6376 | { |
| 6377 | spcBufInfo info; |
| 6378 | kal_uint16 curOffSet; |
| 6379 | |
| 6380 | curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info,comeFrom); |
| 6381 | |
| 6382 | ASSERT(info.syncWord == 0xA2A2); |
| 6383 | ASSERT(info.type == AUD_CCCI_ECALL_MSD_TYPE); |
| 6384 | |
| 6385 | //ASSERT(info.length == (length - sizeof(spcBufInfo))); |
| 6386 | SpcIo_GetDataFromAp(curOffSet, 140, eCall_Msd,comeFrom); |
| 6387 | eCall_IVS_PutMSD(eCall_Msd,140,1); |
| 6388 | |
| 6389 | |
| 6390 | } |
| 6391 | |
| 6392 | void spc_eCall_TX_CTRL_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom) |
| 6393 | { |
| 6394 | spcBufInfo info; |
| 6395 | kal_uint16 curOffSet; |
| 6396 | uint32 i; |
| 6397 | Int16 eCall_TX_Temp[800]; |
| 6398 | |
| 6399 | |
| 6400 | if(gSpc.eCall_Ctrl_Seq_Switch == 0) |
| 6401 | { |
| 6402 | return; |
| 6403 | } |
| 6404 | |
| 6405 | |
| 6406 | curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom); |
| 6407 | ASSERT(info.syncWord == 0xA2A2); |
| 6408 | ASSERT(info.type == AUD_CCCI_ECALL_MSD_TYPE); |
| 6409 | //ASSERT(info.length == (length - sizeof(spcBufInfo))); |
| 6410 | memset(eCall_TX_Temp, 0, 800*sizeof(short)); |
| 6411 | curOffSet = SpcIo_GetDataFromAp(curOffSet, 1600, &eCall_TX_Temp, comeFrom); |
| 6412 | |
| 6413 | MD_TRC_SPC_ECALL_CHECK_TX_CTRL_HEADER(eCall_TX_Temp[0]); |
| 6414 | if(eCall_TX_Temp[0] == 0xAA) |
| 6415 | { |
| 6416 | memset(eCall_TX_CTRL_SEQ_State, 0, 800*sizeof(int16)); |
| 6417 | memcpy(eCall_TX_CTRL_SEQ_State, eCall_TX_Temp, 800*sizeof(int16)); |
| 6418 | |
| 6419 | for(i=0;i<30;i++) |
| 6420 | { |
| 6421 | MD_TRC_ECALL_TX_CTRL_STATE(i*5,eCall_TX_CTRL_SEQ_State[i*5],i*5+1,eCall_TX_CTRL_SEQ_State[i*5+1],i*5+2,eCall_TX_CTRL_SEQ_State[i*5+2],i*5+3,eCall_TX_CTRL_SEQ_State[i*5+3],i*5+4,eCall_TX_CTRL_SEQ_State[i*5+4]); |
| 6422 | } |
| 6423 | } |
| 6424 | else if(eCall_TX_Temp[0] == 0xBB) |
| 6425 | { |
| 6426 | memset(eCall_TX_CTRL_SEQ_dlData, 0, 800*sizeof(int16)); |
| 6427 | memcpy(eCall_TX_CTRL_SEQ_dlData, eCall_TX_Temp, 800*sizeof(int16)); |
| 6428 | for(i=0;i<30;i++) |
| 6429 | { |
| 6430 | MD_TRC_ECALL_TX_CTRL_DATA(i*5,eCall_TX_CTRL_SEQ_dlData[i*5],i*5+1,eCall_TX_CTRL_SEQ_dlData[i*5+1],i*5+2,eCall_TX_CTRL_SEQ_dlData[i*5+2],i*5+3,eCall_TX_CTRL_SEQ_dlData[i*5+3],i*5+4,eCall_TX_CTRL_SEQ_dlData[i*5+4]); |
| 6431 | } |
| 6432 | } |
| 6433 | else if(eCall_TX_Temp[0] == 0xCC) |
| 6434 | { |
| 6435 | memset(eCall_TX_CTRL_SEQ_dlMetric, 0, 800*sizeof(short)); |
| 6436 | memcpy(eCall_TX_CTRL_SEQ_dlMetric, eCall_TX_Temp, 800*sizeof(int16)); |
| 6437 | for(i=0;i<30;i++) |
| 6438 | { |
| 6439 | MD_TRC_ECALL_TX_CTRL_METRIC(i*5,eCall_TX_CTRL_SEQ_dlMetric[i*5],i*5+1,eCall_TX_CTRL_SEQ_dlMetric[i*5+1],i*5+2,eCall_TX_CTRL_SEQ_dlMetric[i*5+2],i*5+3,eCall_TX_CTRL_SEQ_dlMetric[i*5+3],i*5+4,eCall_TX_CTRL_SEQ_dlMetric[i*5+4]); |
| 6440 | } |
| 6441 | } |
| 6442 | |
| 6443 | |
| 6444 | } |
| 6445 | |
| 6446 | void Set_eCall_Par_Crtl_Switch(kal_uint8 Switch) |
| 6447 | { |
| 6448 | |
| 6449 | gSpc.eCall_Ctrl_Seq_Switch = Switch; |
| 6450 | MD_TRC_ECALL_IVS_SEND_PAR_CTRL_SWITCH(gSpc.eCall_Ctrl_Seq_Switch); |
| 6451 | } |
| 6452 | |
| 6453 | void spc_eCall_RX_CTRL_Data(uint16 header) |
| 6454 | { |
| 6455 | |
| 6456 | spcBufInfo info; |
| 6457 | bool sendResult = true; |
| 6458 | info.syncWord = 0x2A2A; |
| 6459 | info.type = AUD_CCCI_ECALL_MSD_TYPE; |
| 6460 | info.length = 1600; |
| 6461 | uint32 i; |
| 6462 | |
| 6463 | if(gSpc.eCall_Ctrl_Seq_Switch == 0) |
| 6464 | { |
| 6465 | return; |
| 6466 | } |
| 6467 | |
| 6468 | if(header == 0xDD ) |
| 6469 | { |
| 6470 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_State, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY); |
| 6471 | for(i=0;i<30;i++) |
| 6472 | { |
| 6473 | MD_TRC_ECALL_RX_CTRL_STATE(i*5,eCall_RX_CTRL_SEQ_State[i*5],i*5+1,eCall_RX_CTRL_SEQ_State[i*5+1],i*5+2,eCall_RX_CTRL_SEQ_State[i*5+2],i*5+3,eCall_RX_CTRL_SEQ_State[i*5+3],i*5+4,eCall_RX_CTRL_SEQ_State[i*5+4]); |
| 6474 | } |
| 6475 | } |
| 6476 | else if(header == 0xEE) |
| 6477 | { |
| 6478 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_dlData, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY); |
| 6479 | for(i=0;i<30;i++) |
| 6480 | { |
| 6481 | MD_TRC_ECALL_RX_CTRL_DATA(i*5,eCall_RX_CTRL_SEQ_dlData[i*5],i*5+1,eCall_RX_CTRL_SEQ_dlData[i*5+1],i*5+2,eCall_RX_CTRL_SEQ_dlData[i*5+2],i*5+3,eCall_RX_CTRL_SEQ_dlData[i*5+3],i*5+4,eCall_RX_CTRL_SEQ_dlData[i*5+4]); |
| 6482 | } |
| 6483 | } |
| 6484 | else if (header == 0xFF) |
| 6485 | { |
| 6486 | sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_dlMetric, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY); |
| 6487 | for(i=0;i<30;i++) |
| 6488 | { |
| 6489 | MD_TRC_ECALL_RX_CTRL_METRIC(i*5,eCall_RX_CTRL_SEQ_dlMetric[i*5],i*5+1,eCall_RX_CTRL_SEQ_dlMetric[i*5+1],i*5+2,eCall_RX_CTRL_SEQ_dlMetric[i*5+2],i*5+3,eCall_RX_CTRL_SEQ_dlMetric[i*5+3],i*5+4,eCall_RX_CTRL_SEQ_dlMetric[i*5+4]); |
| 6490 | } |
| 6491 | } |
| 6492 | |
| 6493 | if(sendResult == false) { |
| 6494 | MD_TRC_SPC_SEND_DATA_TO_AP_FAIL(); |
| 6495 | } |
| 6496 | } |
| 6497 | |
| 6498 | void spc_eCall_Handshake_Info_Notify (uint16 header,uint32 data) |
| 6499 | { |
| 6500 | MD_TRC_ECALL_IVS_ECALL_HANDSHAKE_INFO_NOTIFY(header,data); |
| 6501 | SpcIO_SendMsgToAp( SPCIO_MSG_FROM_ECALL_HANDSHAKE_INFO_ACK, header, data); |
| 6502 | } |
| 6503 | |
| 6504 | void spc_Set_Ecall_Lib_Status(uint8 status) |
| 6505 | { |
| 6506 | gSpc.eCall_LIB_Status = status; |
| 6507 | } |
| 6508 | |
| 6509 | uint8 spc_Get_Ecall_Lib_Status(void) |
| 6510 | { |
| 6511 | return gSpc.eCall_LIB_Status; |
| 6512 | } |
| 6513 | |
| 6514 | #if defined(__L5_SUPPORT__) |
| 6515 | void spc_L5ECALL_Status_Info_Callback(kal_uint16 status, kal_uint32 data){ |
| 6516 | ilm_SP_L5ECALL_Status_INFO_t *local_para; |
| 6517 | local_para = (ilm_SP_L5ECALL_Status_INFO_t *) construct_local_para( sizeof(ilm_SP_L5ECALL_Status_INFO_t), TD_CTRL ); |
| 6518 | local_para->Status = status; |
| 6519 | local_para->Data = data; |
| 6520 | msg_send6(MOD_L1SP, MOD_L5UECALL, L1SP_L5UECALL_SAP, MSG_ID_L5UECALL_L1SP_ECALL_STATUS_IND, (local_para_struct *)local_para, NULL); |
| 6521 | } |
| 6522 | #endif |
| 6523 | #endif |
| 6524 | |
| 6525 | #if defined(_SPE_ENH_DSP_PARSE_) |
| 6526 | |
| 6527 | void spc_ReceiveEMIParInfo(const kal_uint32 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom) |
| 6528 | { |
| 6529 | |
| 6530 | //kal_int16 procLen; |
| 6531 | kal_uint16 curOffset; |
| 6532 | spcBufInfo header; |
| 6533 | spc_sph_on_info_t info; |
| 6534 | kal_uint32 EMI_Offset; |
| 6535 | |
| 6536 | |
| 6537 | //unsigned short Common_Para[NUM_COMMON_PARAS]; |
| 6538 | //unsigned short Dbg_Para[16]; |
| 6539 | |
| 6540 | #if defined(SPH_CHIP_BACK_PHONECALL_USE) |
| 6541 | return; |
| 6542 | #endif // SPH_CHIP_BACK_PHONECALL_USE |
| 6543 | |
| 6544 | //header |
| 6545 | curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &header, comeFrom); |
| 6546 | //header checking |
| 6547 | |
| 6548 | ASSERT(header.syncWord == 0xA2A2); |
| 6549 | ASSERT( (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO) ); |
| 6550 | ASSERT(header.length == (length - sizeof(spcBufInfo))); |
| 6551 | |
| 6552 | curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spc_sph_on_info_t), &info, comeFrom); |
| 6553 | MD_TRC_SPC_SPE_CHECK_EMI_COMMON_PAR(info.common_param[0], info.common_param[1], info.common_param[2], info.common_param[3], info.common_param[4], info.common_param[5], info.common_param[6], info.common_param[7], info.common_param[8], info.common_param[9], info.common_param[10], info.common_param[11]); |
| 6554 | MD_TRC_SPC_SPE_CHECK_EMI_DBG_PAR(info.debug_info[0], info.debug_info[1], info.debug_info[2], info.debug_info[3], info.debug_info[4], info.debug_info[5], info.debug_info[6], info.debug_info[7], info.debug_info[8], info.debug_info[9], info.debug_info[10], info.debug_info[11]); |
| 6555 | L1SP_LoadCommonSpeechPara((uint16 *) info.common_param); |
| 6556 | L1Audio_SetDebugInfo((uint16 *) info.debug_info); |
| 6557 | VMREC_ConfigEpl(); |
| 6558 | spc_dev_LoopbackPoint_DVT(info.debug_info[15]); |
| 6559 | MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(2,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path); |
| 6560 | EMI_Offset =0; |
| 6561 | if(info.param_path == 2 && info.param_shm_valid ==1 ) |
| 6562 | { |
| 6563 | EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ; |
| 6564 | //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS); |
| 6565 | // memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16); |
| 6566 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_COMMON_PAR,Common_Para[0],Common_Para[1],Common_Para[2],Common_Para[3],Common_Para[4],Common_Para[5],Common_Para[6],Common_Para[7],Common_Para[8],Common_Para[9],Common_Para[10],Common_Para[11]); |
| 6567 | //kal_trace( TRACE_FUNC,SPC_SPE_CHECK_EMI_DBG_PAR,Dbg_Para[0],Dbg_Para[1],Dbg_Para[2],Dbg_Para[3],Dbg_Para[4],Dbg_Para[5],Dbg_Para[6],Dbg_Para[7],Dbg_Para[8],Dbg_Para[9],Dbg_Para[10],Dbg_Para[11]); |
| 6568 | // L1SP_LoadCommonSpeechPara((uint16 *)Common_Para); |
| 6569 | //L1Audio_SetDebugInfo((uint16 *)Dbg_Para); |
| 6570 | l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len); |
| 6571 | SetSpeechEnhancement(true); |
| 6572 | }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par. |
| 6573 | { |
| 6574 | SetSpeechEnhancement(true); |
| 6575 | } |
| 6576 | else |
| 6577 | { |
| 6578 | // need use MD default par |
| 6579 | l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN); |
| 6580 | //L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para); |
| 6581 | // L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para); |
| 6582 | SetSpeechEnhancement(true); |
| 6583 | |
| 6584 | } |
| 6585 | |
| 6586 | } |
| 6587 | |
| 6588 | #endif |
| 6589 | |
| 6590 | void spc_setLoopback_dl_ul(kal_bool enable){ |
| 6591 | kal_prompt_trace(MOD_L1SP, "[set_spcLoopback_dl_ul] %d", enable); |
| 6592 | |
| 6593 | ilm_SPC_SETLOOPBACK_DL_UL_t *local_para; |
| 6594 | |
| 6595 | local_para = (ilm_SPC_SETLOOPBACK_DL_UL_t *) construct_local_para( sizeof(ilm_SPC_SETLOOPBACK_DL_UL_t), TD_CTRL ); |
| 6596 | local_para -> enable = enable; |
| 6597 | |
| 6598 | msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SPC_SETLOOPBACK_DL_UL, (local_para_struct *)local_para, NULL); |
| 6599 | |
| 6600 | } |