[Feature][Modem]Update MTK MODEM V1.6 baseline version: MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6
MTK modem version: MT2735_IVT_MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6.tar.gz
RF modem version: NA
Change-Id: I45a4c2752fa9d1a618beacd5d40737fb39ab64fb
diff --git a/mcu/driver/audio/src/v1/DTMF_drv.c b/mcu/driver/audio/src/v1/DTMF_drv.c
new file mode 100644
index 0000000..588098e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/DTMF_drv.c
@@ -0,0 +1,813 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * DTMF_drv.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * ARM DTMF driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+*******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "l1audio.h"
+// #include "audio_def.h"
+#include "l1sp_trc.h"
+#include "am.h"
+//#include "med_utility.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "tone_drv.h"
+
+
+
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+
+//#include "pcmsink.h"
+#include "dtmf_exp.h"
+
+#define DTMF_MAX_DURATION (0xFFFFFFFF)
+//#define DTMF_DEFALUT_SAMPLE_RATE (16000)
+#define DTMF_DEFALUT_SAMPLE_RATE (32000)
+#define DTMF_BUFFERED_FRAME_NUMBER (4)
+#define DTMF_MAX_FRAME (0xFFFF)
+#define DTMF_MIN_FRAME (3) // 5 * 20 msec
+#define DTMF_FRAME_LEN (20) // 20 msec
+#define DTMF_STOP_WAIT_TICK (80)//((DTMF_FRAME_LEN*DTMF_BUFFERED_FRAME_NUMBER+2)/4)
+//#define DTMF_FLUSH_FRAME_NUMBER ((PCM_SOUND_FILLDATA_THRESHOLD/DTMF_FRAME_LEN)+1)
+//#pragma arm section code="SECONDARY_ROCODE"
+
+static kal_uint32 DTMF_FLUSH_FRAME_NUMBER = 3;
+//static kal_uint32 uDtmfMuteLength1 = 6;
+//static kal_uint32 uDtmfMuteLength2 = 0;//13;
+//static kal_uint32 uDtmfMuteLength3 = 1;
+//static kal_uint32 uDtmfMuteLength4 = 3;
+//static kal_uint32 uMuteLength = 150;//60;
+static kal_uint32 uPreSilenceLength= 3;
+kal_enhmutexid MCUTONEMUTEXID;
+kal_spinlockid MCUTONESpinLockID;
+
+static struct {
+ const L1SP_QTMF *pCurrQTMF;
+ const L1SP_Tones *pToneList;
+ void *pHandle;
+
+ kal_uint32 uRemainDuration[3];
+ kal_uint32 uTotalDuration[3];
+ kal_bool fIsQTMF[3];
+ kal_bool fIsOn[3];
+ kal_bool fEnable[3];
+
+ //buffer
+ AUD_RB_INFO RingBuffer;
+ kal_uint32 uFrameByte;
+
+ //Current Tone
+ kal_bool fNewDTMF;
+ kal_bool fClearDTMF;
+ kal_bool fIsToneListQTMF;
+ kal_bool fEnding;
+
+ kal_uint16 uAudId;
+ kal_uint16 uSampleRate;
+ kal_uint8 uCurIdx;
+
+ kal_bool fIsKeytonePlaying;
+ kal_bool fIsTonePlaying;
+ kal_uint8 uFlushSilenceCount;
+ kal_bool fForceStop;
+}DTMF_SW;
+
+
+
+
+
+
+static kal_uint32 dtmf_mcu_CheckDuration(kal_uint16 uDuration)
+{
+ if(uDuration)
+ {
+ return ((uDuration+DTMF_FRAME_LEN-1)/DTMF_FRAME_LEN);
+
+ }
+
+ return DTMF_MAX_DURATION;
+
+}
+
+static kal_bool dtmf_mcu_IsPlaying()
+{
+ if( DTMF_SW.fEnable[0] || DTMF_SW.fEnable[1] || DTMF_SW.fEnable[2] )
+ {
+ return KAL_TRUE;
+ }
+ return KAL_FALSE;
+}
+
+static void dtmf_mcu_GetKeyID(kal_uint32 uIndex, DTMF_KEY *uKey1, DTMF_KEY *uKey2 )
+{
+ ASSERT(uIndex<3);
+ if(uIndex==0)
+ {
+ *uKey1 = DTMFKEY_Ext0;
+ *uKey2 = DTMFKEY_Ext1;
+ }
+ else if(uIndex==1)
+ {
+ *uKey1 = DTMFKEY_Ext2;
+ *uKey2 = DTMFKEY_Ext3;
+ }
+ else if(uIndex==2)
+ {
+ *uKey1 = DTMFKEY_Ext4;
+ *uKey2 = DTMFKEY_Ext5;
+ }
+}
+
+static void dtmf_mcu_GetPreIndex(kal_uint32 uCurIndex, kal_uint32 *uPreIndex1, kal_uint32 *uPreIndex2 )
+{
+ ASSERT(uCurIndex<3);
+ if(uCurIndex==0)
+ {
+ *uPreIndex1 = 2;
+ *uPreIndex2 = 1;
+ }
+ else if(uCurIndex==1)
+ {
+ *uPreIndex1 = 0;
+ *uPreIndex2 = 2;
+ }
+ else
+ {
+ *uPreIndex1 = 1;
+ *uPreIndex2 = 0;
+ }
+}
+
+static void dtmf_mcu_DeActivatAllKey()
+{
+ kal_uint32 I = 0;
+ for(I=0;I<3;I++)
+ {
+ if(DTMF_SW.fEnable[I])
+ {
+ if(DTMF_SW.fIsOn[I] == KAL_FALSE)
+ {
+ DTMF_SW.fEnable[I] = KAL_FALSE;
+ }
+ DTMF_SW.uRemainDuration[I] = 1;
+ }
+ }
+}
+
+static void dtmf_mcu_ActivatNewKey()
+{
+ DTMF_KEY uKey1, uKey2;
+ kal_uint32 uPreIndex1, uPreIndex2;
+ kal_uint32 uCurrentDur;
+ DTMF_SW.uCurIdx++;
+ if(DTMF_SW.uCurIdx > 2)
+ {
+ DTMF_SW.uCurIdx = 0;
+ }
+ dtmf_mcu_GetPreIndex(DTMF_SW.uCurIdx, &uPreIndex1, &uPreIndex2);
+ dtmf_mcu_GetKeyID(DTMF_SW.uCurIdx, &uKey1, &uKey2);
+ DTMF_SetKey( DTMF_SW.pHandle, uKey1, (kal_int32)DTMF_SW.pCurrQTMF->freq1, (kal_int32)DTMF_SW.pCurrQTMF->freq2);
+ DTMF_SetKey( DTMF_SW.pHandle, uKey2, (kal_int32)DTMF_SW.pCurrQTMF->freq3, (kal_int32)DTMF_SW.pCurrQTMF->freq4);
+ uCurrentDur = dtmf_mcu_CheckDuration(DTMF_SW.pCurrQTMF->on_duration);
+ DTMF_SW.uRemainDuration[DTMF_SW.uCurIdx] = DTMF_SW.uTotalDuration[DTMF_SW.uCurIdx] = uCurrentDur;
+ DTMF_SW.fIsQTMF[DTMF_SW.uCurIdx] = DTMF_SW.fIsToneListQTMF;
+ DTMF_SW.fEnable[DTMF_SW.uCurIdx] = KAL_TRUE;
+ DTMF_SW.fIsOn[DTMF_SW.uCurIdx] = KAL_TRUE;
+ if(DTMF_SW.fEnable[uPreIndex2])
+ {
+ MD_TRC_MCU_DTMF_NEWKEY_FORCE_END_2(uPreIndex2, DTMF_SW.uRemainDuration[uPreIndex2], DTMF_SW.uTotalDuration[uPreIndex2]);
+ DTMF_SW.uRemainDuration[uPreIndex2] = 1;
+ }
+ if(DTMF_SW.fEnable[uPreIndex1])
+ {
+ MD_TRC_MCU_DTMF_NEWKEY_FORCE_END_1(uPreIndex1, DTMF_SW.uRemainDuration[uPreIndex1], DTMF_SW.uTotalDuration[uPreIndex1]);
+ if(DTMF_SW.uTotalDuration[uPreIndex1] > DTMF_MIN_FRAME)
+ {
+ kal_uint32 uPlayedDur = DTMF_SW.uTotalDuration[uPreIndex1]-DTMF_SW.uRemainDuration[uPreIndex1];
+ if(uPlayedDur >= DTMF_MIN_FRAME )
+ {
+ DTMF_SW.uRemainDuration[uPreIndex1] = 1;
+ }
+ else
+ {
+ DTMF_SW.uRemainDuration[uPreIndex1] = DTMF_MIN_FRAME - uPlayedDur;
+ }
+ }
+ if(DTMF_SW.uRemainDuration[uPreIndex1] > uCurrentDur)
+ {
+ DTMF_SW.uRemainDuration[uPreIndex1] = uCurrentDur;
+ }
+ }
+ MD_TRC_MCU_DTMF_NEWKEY(DTMF_SW.uCurIdx, uCurrentDur, DTMF_SW.fIsToneListQTMF, DTMF_SW.pCurrQTMF->freq1, DTMF_SW.pCurrQTMF->freq2, DTMF_SW.pCurrQTMF->freq3, DTMF_SW.pCurrQTMF->freq4);
+}
+
+static void dtmf_mcu_PrepareTone(kal_uint32 uIndex)
+{
+ DTMF_KEY uKey1, uKey2;
+ if(!DTMF_SW.fEnable[uIndex])
+ {
+ return;
+ }
+ dtmf_mcu_GetKeyID(uIndex, &uKey1, &uKey2);
+ if(DTMF_SW.uRemainDuration[uIndex] == DTMF_SW.uTotalDuration[uIndex])
+ {
+ if(DTMF_SW.fIsOn[uIndex] == KAL_FALSE)
+ {
+ DTMF_Tone(DTMF_SW.pHandle, uKey1, 0);
+ DTMF_Tone(DTMF_SW.pHandle, uKey2, 0);
+ }
+ else if(DTMF_SW.fIsQTMF[uIndex])
+ {
+ DTMF_Tone(DTMF_SW.pHandle, uKey1, 1);
+ DTMF_Tone(DTMF_SW.pHandle, uKey2, 1);
+ }
+ else
+ {
+ DTMF_Tone(DTMF_SW.pHandle, uKey1, 1);
+ DTMF_Tone(DTMF_SW.pHandle, uKey2, 0);
+ }
+ }
+ else if(DTMF_SW.uRemainDuration[uIndex] == 1)
+ {
+ DTMF_Tone(DTMF_SW.pHandle, uKey1, 0);
+ DTMF_Tone(DTMF_SW.pHandle, uKey2, 0);
+ }
+}
+
+static void dtmf_mcu_UpdateTone(kal_uint32 uIndex)
+{
+ DTMF_KEY uKey1, uKey2;
+ if(!DTMF_SW.fEnable[uIndex])
+ {
+ return;
+ }
+ dtmf_mcu_GetKeyID(uIndex, &uKey1, &uKey2);
+ DTMF_SW.uRemainDuration[uIndex]--;
+ if(DTMF_SW.uRemainDuration[uIndex] == 0)
+ {
+ if(DTMF_SW.uCurIdx != uIndex)
+ {
+ MD_TRC_MCU_DTMF_UPDATE_TONE_PREV_END(uIndex);
+ DTMF_SW.fEnable[uIndex] = KAL_FALSE;
+ }
+ else
+ {
+ if(DTMF_SW.fIsOn[uIndex])
+ {
+ if( DTMF_SW.pCurrQTMF->off_duration == 0 || DTMF_SW.fClearDTMF)
+ {
+ MD_TRC_MCU_DTMF_UPDATE_TONE_CURR_END(uIndex);
+ DTMF_SW.fEnable[uIndex] = KAL_FALSE;
+ }
+ else
+ {
+ MD_TRC_MCU_DTMF_UPDATE_TONE_CURR_OFF(uIndex);
+ DTMF_SW.fIsOn[uIndex] = KAL_FALSE;
+ DTMF_SW.uRemainDuration[uIndex] = DTMF_SW.uTotalDuration[uIndex] = dtmf_mcu_CheckDuration(DTMF_SW.pCurrQTMF->off_duration);
+ if(DTMF_SW.pCurrQTMF->off_duration)
+ {
+ if(DTMF_SW.fIsToneListQTMF)
+ {
+ DTMF_SW.pCurrQTMF = (L1SP_QTMF *)DTMF_SW.pToneList + DTMF_SW.pCurrQTMF->next_tone;
+ }
+ else
+ {
+ DTMF_SW.pCurrQTMF = (L1SP_QTMF *)(DTMF_SW.pToneList + DTMF_SW.pCurrQTMF->next_tone);
+ }
+ }
+ }
+ }
+ else
+ {
+ MD_TRC_MCU_DTMF_UPDATE_TONE_CURR_ON(uIndex);
+ DTMF_SetKey( DTMF_SW.pHandle, uKey1, (kal_int32)DTMF_SW.pCurrQTMF->freq1, (kal_int32)DTMF_SW.pCurrQTMF->freq2);
+ DTMF_SetKey( DTMF_SW.pHandle, uKey2, (kal_int32)DTMF_SW.pCurrQTMF->freq3, (kal_int32)DTMF_SW.pCurrQTMF->freq4);
+ DTMF_SW.uRemainDuration[DTMF_SW.uCurIdx] = DTMF_SW.uTotalDuration[DTMF_SW.uCurIdx] = dtmf_mcu_CheckDuration(DTMF_SW.pCurrQTMF->on_duration);
+ DTMF_SW.fIsOn[uIndex] = KAL_TRUE;
+ }
+ }
+ }
+ else if(DTMF_SW.uRemainDuration[uIndex] == 1 && DTMF_SW.fIsOn[uIndex])
+ { //ramp down
+ MD_TRC_MCU_DTMF_UPDATE_TONE_RAMPDOWN(uIndex);
+ DTMF_Tone(DTMF_SW.pHandle, uKey1, 0);
+ DTMF_Tone(DTMF_SW.pHandle, uKey2, 0);
+ }
+}
+
+static void dtmf_mcu_Destroy(kal_uint32 arg1, void* arg2)
+{
+
+ //kal_bool fIsAudioRunning = false;//PcmSink_IsAudioRuning() || PcmSink_IsMixerRuning();
+ MD_TRC_MCU_DTMF_DESTROY(DTMF_SW.pHandle, DTMF_SW.fNewDTMF, DTMF_SW.fEnding, DTMF_SW.fForceStop);
+ if(DTMF_SW.pHandle == NULL)
+ {
+ return;
+ }
+ if((DTMF_SW.fNewDTMF == KAL_FALSE && DTMF_SW.fEnding == KAL_TRUE) || DTMF_SW.fForceStop)
+ {
+ {
+ {
+// void AM_SWToneOff( void );
+// AM_SWToneOff();
+ }
+ }
+ kal_take_spinlock(MCUTONESpinLockID, KAL_INFINITE_WAIT);
+ DTMF_SW.pHandle = NULL;
+ DTMF_SW.RingBuffer.rb_base = NULL;
+ memset(&DTMF_SW, 0, sizeof(DTMF_SW));
+ kal_give_spinlock(MCUTONESpinLockID);
+ L1Audio_ClearFlag( DTMF_SW.uAudId);
+ L1Audio_FreeAudioID(DTMF_SW.uAudId);
+ //audio_free_mem( (void **) &DTMF_SW.RingBuffer.rb_base);//
+
+ //if(fIsAudioRunning)
+ // {
+////! PcmSink_Mute(KAL_TRUE, PCMSINK_MUTE_TONE);
+ //kal_sleep_task( AUD_1TICK(uDtmfMuteLength3) );
+ //}
+ //if(DTMF_SW.fIsKeytonePlaying)
+ //{
+////! PcmSink_StopSound(PCM_FUNC_KEYTONE);
+ //}
+ //else if(DTMF_SW.fIsTonePlaying)
+ //{
+////! PcmSink_StopSound(PCM_FUNC_TONE);
+ //}
+ //else
+ //{
+ //ASSERT(0);
+ //}
+
+ //if(fIsAudioRunning)
+ //{
+ //kal_sleep_task( AUD_1TICK(uDtmfMuteLength4) );
+ //}
+////! PcmSink_DepopUnMute( NULL );
+////! PcmSink_Mute(KAL_FALSE, PCMSINK_MUTE_TONE);
+ }
+}
+
+static kal_bool dtmf_mcu_Process_Internal()
+{
+ kal_uint32 uPreIndex1, uPreIndex2, uBufLen, uCurrentData;
+ kal_uint8 *pBuf;
+ kal_bool fIsPlaying = KAL_TRUE;
+ MD_TRC_MCU_DTMF_MCU_PROCESS_INTERNAL_ENTER();
+ kal_take_enh_mutex(MCUTONEMUTEXID);
+ if(DTMF_SW.pHandle == NULL)
+ {
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ return KAL_FALSE;
+ }
+ rbGetWriteBuffer(&DTMF_SW.RingBuffer, &pBuf, &uBufLen);
+ MD_TRC_MCU_DTMF_PROCESS_ENTRY(DTMF_SW.fNewDTMF, DTMF_SW.fClearDTMF, DTMF_SW.fEnding, uBufLen);
+ if(DTMF_SW.fClearDTMF)
+ {
+ dtmf_mcu_DeActivatAllKey();
+ if(!dtmf_mcu_IsPlaying())
+ {
+ DTMF_SW.fClearDTMF = KAL_FALSE;
+ }
+ }
+ if(uBufLen < DTMF_SW.uFrameByte || (DTMF_SW.fEnding && !DTMF_SW.fNewDTMF) )
+ {
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ return KAL_FALSE;
+ }
+ dtmf_mcu_GetPreIndex(DTMF_SW.uCurIdx, &uPreIndex1, &uPreIndex2);
+ if(DTMF_SW.fNewDTMF)
+ {
+ dtmf_mcu_ActivatNewKey(uPreIndex1, uPreIndex2);
+ DTMF_SW.fNewDTMF = KAL_FALSE;
+ }
+ else
+ { //flush data
+ fIsPlaying = dtmf_mcu_IsPlaying();
+ uCurrentData = rbGetDataCount(&DTMF_SW.RingBuffer);
+ MD_TRC_MCU_DTMF_PROCESS_STATUS(fIsPlaying, uCurrentData, DTMF_SW.uFlushSilenceCount);
+ if(!fIsPlaying && DTMF_SW.uFlushSilenceCount<DTMF_FLUSH_FRAME_NUMBER)
+ {
+ DTMF_Gen(DTMF_SW.pHandle, pBuf);
+ rbWriteDataDone(&DTMF_SW.RingBuffer, DTMF_SW.uFrameByte);
+ DTMF_SW.uFlushSilenceCount++;
+ }
+ if(!fIsPlaying && uCurrentData==0 && !DTMF_SW.fEnding)
+ {
+////! PcmSink_Mute(KAL_TRUE, PCMSINK_MUTE_TONE);
+ DTMF_SW.fEnding = KAL_TRUE;
+ L1Audio_InProcCall(dtmf_mcu_Destroy, 0, NULL);
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ return KAL_FALSE;
+ }
+ }
+ if(fIsPlaying)
+ {
+ dtmf_mcu_PrepareTone(0);
+ dtmf_mcu_PrepareTone(1);
+ dtmf_mcu_PrepareTone(2);
+ DTMF_Gen(DTMF_SW.pHandle, pBuf);
+ rbWriteDataDone(&DTMF_SW.RingBuffer, DTMF_SW.uFrameByte);
+ dtmf_mcu_UpdateTone(0);
+ dtmf_mcu_UpdateTone(1);
+ dtmf_mcu_UpdateTone(2);
+ DTMF_SW.fClearDTMF = KAL_FALSE;
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ return KAL_TRUE;
+ }
+ MD_TRC_MCU_DTMF_MCU_PROCESS_INTERNAL_LEAVE();
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ return KAL_FALSE;
+}
+
+static void dtmf_mcu_Process(void *pData)
+{
+ kal_bool fContinue;
+ do
+ {
+ fContinue = dtmf_mcu_Process_Internal();
+ }while(fContinue);
+}
+
+
+#define DTMF_MCU_BUFFER_SIZE (19000/4)
+unsigned int dtmf_mcu_buffer[DTMF_MCU_BUFFER_SIZE];
+static void dtmf_mcu_Init(kal_uint16 uSampleRate)
+{
+ kal_uint32 uIntBufSize=0, uPcmBufSize=0, uTotalBufferSize=0;
+ kal_uint8 *pAllocBuf;
+ DTMF_SR uSr=0;
+ memset(&DTMF_SW, 0, sizeof(DTMF_SW));
+ DTMF_SW.uSampleRate = uSampleRate;
+ switch (DTMF_SW.uSampleRate)
+ {
+ case 8000:
+ uSr = DTMF_8K;
+ break;
+ case 11025:
+ uSr = DTMF_11K;
+ break;
+ case 12000:
+ uSr = DTMF_12K;
+ break;
+ case 16000:
+ uSr = DTMF_16K;
+ break;
+ case 22050:
+ uSr = DTMF_22K;
+ break;
+ case 24000:
+ uSr = DTMF_24K;
+ break;
+ case 32000:
+ uSr = DTMF_32K;
+ break;
+ case 44100:
+ uSr = DTMF_44K;
+ break;
+ case 48000:
+ uSr = DTMF_48K;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ DTMF_GetBufferSize(&uIntBufSize, &uPcmBufSize, uSr, DTMF_MONO);
+ uTotalBufferSize = uIntBufSize + uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER;
+ MD_TRC_MCU_DTMF_INIT(uSampleRate, uPcmBufSize, uTotalBufferSize);
+ //pAllocBuf = (kal_uint8 *)audio_alloc_mem(uTotalBufferSize);
+ //ASSERT(pAllocBuf);
+ if( (DTMF_MCU_BUFFER_SIZE<<2) < uTotalBufferSize )
+ {
+ MD_TRC_MCU_DTMF_INIT(uSampleRate, (DTMF_MCU_BUFFER_SIZE<<2), uTotalBufferSize);
+ ASSERT(0);
+ }
+ pAllocBuf = (kal_uint8 *)dtmf_mcu_buffer;
+ ASSERT(uIntBufSize);
+ ASSERT(uPcmBufSize);
+ DTMF_SW.uFrameByte = uPcmBufSize;
+ DTMF_SW.RingBuffer.rb_base = (kal_uint8*)pAllocBuf;
+ DTMF_SW.RingBuffer.rb_size = uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER;
+ DTMF_SW.RingBuffer.write = uPcmBufSize * uPreSilenceLength; //fill a silence to prevent pop up noise
+ DTMF_SW.RingBuffer.read=0;
+ pAllocBuf += uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER;
+ DTMF_SW.pHandle = DTMF_Init( (void *)pAllocBuf, DTMF_CONTINUOUS, uSr, DTMF_MONO);
+ ASSERT(DTMF_SW.pHandle);
+ DTMF_SW.uAudId = L1Audio_GetAudioID();
+ L1Audio_SetFlag( DTMF_SW.uAudId );
+ L1Audio_SetEventHandler( DTMF_SW.uAudId, dtmf_mcu_Process );
+}
+
+kal_bool DTMF_MCU_IsPlaying()
+{
+ if(DTMF_SW.pHandle)
+ {
+ return KAL_TRUE;
+ }
+ else
+ {
+ return KAL_FALSE;
+ }
+}
+
+kal_bool DTMF_MCU_IsKeytonePlaying()
+{
+ return DTMF_SW.fIsKeytonePlaying;
+}
+
+kal_bool DTMF_MCU_IsTonePlaying()
+{
+ return DTMF_SW.fIsTonePlaying;
+}
+
+void DTMF_MCU_ReadDataDone(kal_uint32 uDataWord)
+{
+ MD_TRC_MCU_DTMF_READ_DATA_DONE(uDataWord);
+ if(DTMF_SW.pHandle)
+ {
+ rbReadDataDone(&DTMF_SW.RingBuffer, uDataWord<<1);
+ }
+}
+
+void DTMF_MCU_GetReadBuffer(kal_int16 **pBuf_16b, kal_uint32 *uDataWord)
+{
+ *pBuf_16b = NULL;
+ *uDataWord = 0;
+ if(DTMF_SW.pHandle)
+ {
+ kal_uint32 uDataByte;
+ kal_uint8 *pBuf_8b;
+ rbGetReadBuffer(&DTMF_SW.RingBuffer, &pBuf_8b, &uDataByte);
+ ASSERT(!((kal_uint32)pBuf_8b & 0x1));
+ *pBuf_16b = (kal_int16*)pBuf_8b;
+ *uDataWord = uDataByte >> 1;
+ }
+ MD_TRC_MCU_DTMF_GET_REAR_BUFFER(*uDataWord);
+}
+
+kal_uint32 DTMF_MCU_GetDataCount()
+{
+ kal_uint32 uDataWord = 0;
+ if(DTMF_SW.pHandle)
+ {
+ uDataWord = (rbGetDataCount(&DTMF_SW.RingBuffer))>>1;
+ }
+ MD_TRC_MCU_DTMF_GET_DATA_COUNT(uDataWord);
+ return uDataWord;
+}
+
+void DTMF_MCU_DataRequestCallback()
+{
+ MD_TRC_MCU_DTMF_DATA_REQUEST(DTMF_SW.pHandle);
+ if(DTMF_SW.pHandle)
+ {
+ //Although dtmf_stop may cause pHandle =NULL, dtmf_mcu_internal_process check pHandle=NULL will return
+ L1Audio_SetEvent( DTMF_SW.uAudId, NULL );
+ }
+}
+
+void DTMF_MCU_StopAndWait()
+{
+ kal_int32 I=0;
+ kal_take_enh_mutex(MCUTONEMUTEXID);
+ DTMF_SW.fNewDTMF = KAL_FALSE;
+ DTMF_SW.fForceStop = KAL_FALSE;
+ if(DTMF_SW.pHandle)
+ {
+ DTMF_SW.fClearDTMF = KAL_TRUE;
+ DTMF_MCU_DataRequestCallback();
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ while(1)
+ {
+ ////! if(DTMF_SW.fEnding == KAL_TRUE || AM_IsAudioPlaybackOn() == -1 || !PcmSink_IsSoundRuning())
+ if(DTMF_SW.fEnding == KAL_TRUE)
+ {
+ DTMF_SW.fForceStop = KAL_TRUE;
+ dtmf_mcu_Destroy(0, NULL);
+ break;
+ }
+ kal_sleep_task( AUD_1TICK(1) );
+ I++;
+ ASSERT(I<DTMF_STOP_WAIT_TICK);
+ }
+ }
+ else
+ {
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ }
+
+}
+
+void DTMF_MCU_Stop(kal_bool fIsKeytone)
+{
+ MD_TRC_MCU_DTMF_STOP(DTMF_SW.pHandle);
+ if( (DTMF_SW.fIsKeytonePlaying && !fIsKeytone) || (DTMF_SW.fIsTonePlaying && fIsKeytone) )
+ {
+ return;
+ }
+ kal_take_enh_mutex(MCUTONEMUTEXID);
+ DTMF_SW.fNewDTMF = KAL_FALSE;
+ if(DTMF_SW.pHandle)
+ {
+ DTMF_SW.fClearDTMF = KAL_TRUE;
+ DTMF_MCU_DataRequestCallback();
+ }
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+}
+
+
+void DTMF_MCU_lockInit()
+{
+ MCUTONEMUTEXID= kal_create_enh_mutex( "MCU_TONE_MUTEX" );
+ MCUTONESpinLockID= kal_create_spinlock( "MCU_TONE_LOCK" );
+
+}
+
+void DTMF_MCU_Play( const L1SP_Tones *pToneList, kal_bool fIsQTMF, kal_bool fIsKeytone)
+{
+ //kal_uint32 uSaveMask;
+ //kal_bool fIsAudioRunning = false;//PcmSink_IsAudioRuning() || PcmSink_IsMixerRuning();
+ MD_TRC_MCU_DTMF_PLAY(DTMF_SW.pHandle);
+ if( (DTMF_SW.fIsKeytonePlaying && !fIsKeytone) || (DTMF_SW.fIsTonePlaying && fIsKeytone) )
+ {
+ DTMF_MCU_StopAndWait();
+ }
+ kal_take_enh_mutex(MCUTONEMUTEXID);
+ if(DTMF_SW.pHandle == NULL)
+ {
+ kal_uint16 uSampleRate;
+ //kal_uint8 uChannelNumber;
+////! PcmSink_GetCurrentPcmInfo(&uSampleRate, &uChannelNumber);
+ uSampleRate = 0;
+ //uChannelNumber = 1;
+ if(uSampleRate == 0)
+ {
+ uSampleRate = DTMF_DEFALUT_SAMPLE_RATE;
+ }
+ dtmf_mcu_Init(uSampleRate);
+////! PcmSink_Mute(KAL_TRUE, PCMSINK_MUTE_TONE);
+////! if(fIsAudioRunning)
+////! {
+////! PcmSink_DepopMute(uMuteLength);
+////! if(uDtmfMuteLength1)
+////! {
+////! kal_sleep_task( AUD_1TICK(uDtmfMuteLength1) );
+////! }
+////! }
+ }
+ DTMF_SW.pToneList = pToneList;
+ DTMF_SW.pCurrQTMF = (const L1SP_QTMF *)pToneList;
+ DTMF_SW.fIsToneListQTMF = fIsQTMF;
+ DTMF_SW.fNewDTMF = KAL_TRUE;
+ DTMF_SW.fEnding = KAL_FALSE;
+ DTMF_SW.uFlushSilenceCount = 0;
+ DTMF_MCU_DataRequestCallback();
+
+ if(fIsKeytone && !DTMF_SW.fIsKeytonePlaying)
+ {
+ DTMF_SW.fIsKeytonePlaying = KAL_TRUE;
+////! PcmSink_StartSound(PCM_FUNC_KEYTONE, DTMF_SW.uSampleRate, 2);
+////! if(fIsAudioRunning && uDtmfMuteLength2)
+////! {
+////! kal_sleep_task( AUD_1TICK(uDtmfMuteLength2) );
+////! }
+ }
+ else if(!fIsKeytone && !DTMF_SW.fIsTonePlaying)
+ {
+ DTMF_SW.fIsTonePlaying = KAL_TRUE;
+////! PcmSink_StartSound(PCM_FUNC_TONE, DTMF_SW.uSampleRate, 2);
+////! if(fIsAudioRunning && uDtmfMuteLength2)
+////! {
+////! kal_sleep_task( AUD_1TICK(uDtmfMuteLength2) );
+////! }
+ }
+ kal_give_enh_mutex(MCUTONEMUTEXID);
+ {
+// void AM_SWToneOn( void );
+// AM_SWToneOn();
+ }
+////! PcmSink_Mute(KAL_FALSE, PCMSINK_MUTE_TONE);
+}
+
+//#pragma arm section
+
+#else
+
+void DTMF_MCU_Play( const L1SP_Tones *pToneList, kal_bool fIsQTMF, kal_bool fIsKeytone){}
+void DTMF_MCU_Stop(kal_bool fIsKeytone){}
+void DTMF_MCU_StopAndWait(){}
+void DTMF_MCU_DataRequestCallback(){}
+kal_uint32 DTMF_MCU_GetDataCount(){return 0;}
+void DTMF_MCU_GetReadBuffer(kal_int16 **pBuf_16b, kal_uint32 *uDataWord){}
+void DTMF_MCU_ReadDataDone(kal_uint32 uDataWord){}
+kal_bool DTMF_MCU_IsPlaying(){return KAL_FALSE;}
+kal_bool DTMF_MCU_IsKeytonePlaying(){return KAL_FALSE;}
+
+#endif
+
diff --git a/mcu/driver/audio/src/v1/ExtBgSnd.c b/mcu/driver/audio/src/v1/ExtBgSnd.c
new file mode 100644
index 0000000..5b1b0fc
--- /dev/null
+++ b/mcu/driver/audio/src/v1/ExtBgSnd.c
@@ -0,0 +1,880 @@
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "sync_data.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+
+#include "l1audio.h"
+#include "am.h"
+//#include "speech_def.h"
+//#include "afe_def.h" // for output device setting
+//#include "sp_drv.h"
+
+#include "sal_exp.h"
+#include "bgSnd.h"
+
+//#define DSP_BGS_UP_DOWN_INT_SEPERATE
+
+
+#define BGSND_BUFFER_LEN_NB (160) //unit is sample (16bit)
+#define BGSND_BUFFER_LEN_WB (320) //unit is sample (16bit)
+#define BGSND_BUFFER_LEN_SWB (640) //unit is sample (16bit)
+#define BGSND_BUFFER_LEN_FB (960) //unit is sample (16bit)
+
+#define BGSND_BUFFER_LEN (BGSND_BUFFER_LEN_SWB)
+
+#define MAX_NUM_BGSND_PROCESS (2)
+
+
+//================= DSP BGSND INTERFACE ====================
+
+typedef enum {
+ DSP_BGSND_STATE_IDLE = 0,
+ DSP_BGSND_STATE_RUN,
+ DSP_BGSND_STATE_STOPPING,
+}DSP_BGSND_STATE_TYPE;
+
+typedef struct{
+ DSP_BGSND_STATE_TYPE state;
+
+ bool fSph[MAX_NUM_BGSND_PROCESS];
+ uint16 gain[MAX_NUM_BGSND_PROCESS];
+
+ void (*Ext_Hisr[MAX_NUM_BGSND_PROCESS])(void);
+}DSP_BKGSND_T;
+
+DSP_BKGSND_T DSP_BGSnd;
+
+//================= Extended BGSND INTERFACE ====================
+#define MAX_SIZE_EXT_BGSND_SRC (2) // AP bkgsnd + VoLTE UL bkgsnd
+#define EXT_BGSND_BUF_PTR_DIFF (2)
+#define EXT_BGSND_SRC_BUF_SIZE ((BGSND_BUFFER_LEN) * 2 + EXT_BGSND_BUF_PTR_DIFF) //buffering 2 frames
+
+
+#define MAX_LEVEL_EXT_BGSND_GAIN (7)
+
+typedef struct{
+ EXT_SRC_STATE_TYPE state[MAX_NUM_BGSND_PROCESS];
+ void (*offHdr)();//(int id); //TODO Trigger MED to close DSP bgsnd
+ void (*Hdr[MAX_NUM_BGSND_PROCESS])(void); // under HISR
+ uint16 dspLastSample[MAX_NUM_BGSND_PROCESS];
+
+ uint32 len_WriteSrcBuffer_this_time;
+ //event handling
+ //void (*EventHandler)(void);
+ //void *event_data;
+
+ //gain handling
+ bool fSph[MAX_NUM_BGSND_PROCESS];
+ uint16 gain[MAX_NUM_BGSND_PROCESS];
+
+ //buffer handling
+ uint32 bufSize[MAX_NUM_BGSND_PROCESS], bufRead[MAX_NUM_BGSND_PROCESS], bufWrite[MAX_NUM_BGSND_PROCESS];
+ uint32 bufDataCount[MAX_NUM_BGSND_PROCESS];
+ uint16 buffer[MAX_NUM_BGSND_PROCESS][EXT_BGSND_SRC_BUF_SIZE];
+
+}EXT_BGSND_SRC_T;
+
+typedef struct{
+ bool is_used[MAX_SIZE_EXT_BGSND_SRC];
+ bool is_send_event[MAX_SIZE_EXT_BGSND_SRC];
+ EXT_BGSND_SRC_T src[MAX_SIZE_EXT_BGSND_SRC];
+ uint16 num_src_used;
+
+ uint16 buffer[MAX_NUM_BGSND_PROCESS][BGSND_BUFFER_LEN]; //accumulate all sources multiplied by gains into this buffer
+
+ uint16 aud_id;
+ bool skip_hisr;
+ kal_spinlockid bgs_spinlockID;
+}EXT_BGSND_T;
+
+static EXT_BGSND_T Ext_BGSnd;
+
+void EXT_BGSND_Hisr(BGSND_PROCESS_TYPE type);
+
+/*
+int has_ul = 0;
+int has_dl = 0;
+int ul_data[320], dl_data[320];*/
+
+
+static void DSP_BGSND_INIT()
+{
+ MD_TRC_DSP_BGSND_INIT_ENTER();
+ memset(&DSP_BGSnd, 0, sizeof(DSP_BKGSND_T));
+ //has_ul = has_dl = 0;
+ MD_TRC_DSP_BGSND_INIT_LEAVE();
+}
+
+static void DSP_BGSND_ConfigMixer(kal_bool bSPHFlag, kal_int8 SNDGain, BGSND_PROCESS_TYPE type)
+{
+ MD_TRC_DSP_BGSND_CONFIGMIXER_ENTER();
+ MD_TRC_DSP_BGSND_CONFIGMIXER_BGSND_PROCESS_TYPE(type, bSPHFlag, SNDGain);
+
+ ASSERT(SNDGain>=0 && SNDGain<=7);
+ if( SNDGain == 0)
+ DSP_BGSnd.gain[type] = 0;
+ else {
+ DSP_BGSnd.gain[type] = (kal_int16)(32767 >> (7 - SNDGain));
+ }
+ DSP_BGSnd.fSph[type] = bSPHFlag;
+ MD_TRC_DSP_BGSND_CONFIGMIXER_LEAVE();
+}
+
+static void DSP_BGSND_UpdateMixer() // private
+{
+ MD_TRC_DSP_BGSND_UPDATEMIXER_ENTER();
+ if ( AM_IsSpeechOn() || AM_IsVoIPOn()) {
+ SAL_Bgsnd_Config(DSP_BGSnd.gain[BGSND_UL_PROCESS], DSP_BGSnd.gain[BGSND_DL_PROCESS], DSP_BGSnd.fSph[BGSND_UL_PROCESS], DSP_BGSnd.fSph[BGSND_DL_PROCESS]);
+ } else {
+ //When enable BT, spe_setSpeechMode() will do Speech Off and Speech On. This function may run between Off and ON, so do not use ASSERT().
+ //ASSERT(false);
+ SAL_Bgsnd_Config(DSP_BGSnd.gain[BGSND_UL_PROCESS], DSP_BGSnd.gain[BGSND_DL_PROCESS], 0, 0);
+ }
+ MD_TRC_DSP_BGSND_UPDATEMIXER_LEAVE();
+}
+
+
+void DSP_BGSND_Stop(void)
+{
+ MD_TRC_DSP_BGSND_STOP_ENTER();
+ DSP_BGSnd.state = DSP_BGSND_STATE_STOPPING;
+ { //turn off DSP BGSND
+ uint32 I;
+ if(SAL_Bgsnd_IsRunning())
+ SAL_Bgsnd_SetFinal();
+ for ( I = 0; ; I++ ) {
+ if ( SAL_Bgsnd_IsIdle()) /* DSP returns to idle state */
+ break;
+ ASSERT_REBOOT( I < 20 );
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+
+ AM_SND_PlaybackOff( true );
+ }
+
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL);
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_UL);
+#else
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL);
+#endif
+ DSP_BGSnd.state = DSP_BGSND_STATE_IDLE;
+ MD_TRC_DSP_BGSND_STOP_LEAVE();
+}
+
+
+/*
+static kal_uint16 tempMicData[320]
+ // = { 0x4808,0x85, 0x156,0, 0x4,0, 0x146,0x9000,
+ = {
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575
+
+};*/
+
+
+void DSP_BGSND_Hisr(void * param)
+{
+ int i;
+ uint16 *src_buf;
+ volatile uint16 *dst_buf;
+
+ BGSND_PROCESS_TYPE type = (BGSND_PROCESS_TYPE) param;
+
+ MD_TRC_DSP_BGSND_HISR_ENTER();
+
+ MD_TRC_DSP_BGSND_HISR_BGSND_PROCESS_TYPE(type, DSP_BGSnd.state);
+
+ ASSERT( type == BGSND_DL_PROCESS || type == BGSND_UL_PROCESS );
+
+ if ((DSP_BGSND_STATE_RUN != DSP_BGSnd.state)){
+ return;
+ }
+
+ if(!SAL_Bgsnd_IsRunning())
+ return;
+
+ DSP_BGSnd.Ext_Hisr[type]();
+ src_buf = Ext_BGSnd.buffer[type];
+
+ dst_buf = src_buf;
+ //set up the DSP address and pointers
+ switch(type){
+ case BGSND_DL_PROCESS:
+ //dst_buf_len = SAL_Bgsnd_GetDataLen_DL();
+ dst_buf = SAL_Bgsnd_GetBuf_DL();
+ break;
+ case BGSND_UL_PROCESS:
+ //dst_buf_len = SAL_Bgsnd_GetDataLen_UL();
+ dst_buf = SAL_Bgsnd_GetBuf_UL();
+ break;
+ }
+
+ for(i=0; i<BGSND_BUFFER_LEN_SWB; i++){
+ //*dst_buf++ = *src_buf++;
+ dst_buf[i] = src_buf[i];
+ }
+ Data_Sync_Barrier();
+
+ MD_TRC_DSP_BGSND_HISR_LEAVE();
+}
+#if !defined(DSP_BGS_UP_DOWN_INT_SEPERATE)
+void DSP_BGSND_Shared_Hisr_DL_UL(void * param)
+{
+ MD_TRC_DSP_BGSND_SHARED_HISR_DL_UL_ENTER();
+ DSP_BGSND_Hisr((void * )BGSND_UL_PROCESS);
+ DSP_BGSND_Hisr((void * )BGSND_DL_PROCESS);
+ MD_TRC_DSP_BGSND_SHARED_HISR_DL_UL_LEAVE();
+}
+#endif
+
+static void DSP_BGSND_Start(void (*Ext_DLHisr)(void),
+ void (*Ext_ULHisr)(void))
+{
+ MD_TRC_DSP_BGSND_START_ENTER();
+ ASSERT(AM_IsSpeechOn() || AM_IsVoIPOn());
+
+ DSP_BGSnd.Ext_Hisr[BGSND_DL_PROCESS] = Ext_DLHisr;
+ DSP_BGSnd.Ext_Hisr[BGSND_UL_PROCESS] = Ext_ULHisr;
+
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL, DSP_BGSND_Hisr, (void *)BGSND_DL_PROCESS);
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_UL, DSP_BGSND_Hisr, (void *)BGSND_UL_PROCESS);
+#else
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL, DSP_BGSND_Shared_Hisr_DL_UL, 0);
+#endif
+
+ // gain setting and update
+ // Although these settings are allowed to modify during run time,
+ // extended bgsnd should be fixed because the changes of volume from
+ // each sources are calculated in MCU side.
+ DSP_BGSND_ConfigMixer(KAL_TRUE, 7, BGSND_UL_PROCESS);
+ DSP_BGSND_ConfigMixer(KAL_TRUE, 7, BGSND_DL_PROCESS);
+
+ DSP_BGSND_UpdateMixer();
+ { //turn on DSP BGSND
+ uint32 I;
+ AM_SND_PlaybackOn();
+ SAL_Bgsnd_SetInit();
+ for( I = 0; ; I++ ) {
+ if(SAL_Bgsnd_IsRunning())
+ break;
+ ASSERT_REBOOT( I < 20 );
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ }
+
+ DSP_BGSnd.state = DSP_BGSND_STATE_RUN;
+ MD_TRC_DSP_BGSND_START_LEAVE();
+}
+/*=============== Ext BGSND interface ========= */
+
+uint32 EXT_BGSND_init()
+{
+ MD_TRC_EXT_BGSND_INIT_ENTER();
+ DSP_BGSND_INIT();
+ memset((void *)&Ext_BGSnd, 0, sizeof(EXT_BGSND_T));
+ // get audio ID
+ Ext_BGSnd.aud_id = L1Audio_GetAudioID();
+ Ext_BGSnd.skip_hisr = 0;
+ Ext_BGSnd.bgs_spinlockID = kal_create_spinlock("bgs_spinlock");
+ MD_TRC_EXT_BGSND_INIT_LEAVE();
+// L1Audio_SetEventHandler( Ext_BGSnd.aud_id, (L1Audio_EventHandler) EXT_BGSND_EventHandler );
+ return 0;
+}
+
+void EXT_BGSND_DLHisr(void);
+void EXT_BGSND_ULHisr(void);
+
+
+uint32 EXT_BGSND_Start(void (*offHdr)(void),
+ void (*DLHisr)(void), //move data from src -> ext
+ void (*ULHisr)(void), //move data from src -> ext
+ kal_int8 DLSNDGain,
+ kal_int8 ULSNDGain /*,
+ void (*EventHandler)(void)*/)
+{
+ int i, j;
+
+ Ext_BGSnd.skip_hisr = 0;
+ MD_TRC_EXT_BGSND_START_ENTER();
+
+ ASSERT(!(NULL==DLHisr && NULL==ULHisr));
+ ASSERT(NULL!=offHdr); //without this, we cannot stop DSP BGSND
+
+ for(i=0; i<MAX_SIZE_EXT_BGSND_SRC; i++){
+ MD_TRC_EXT_BGSND_START_DEBUG1(i);
+ if(!Ext_BGSnd.is_used[i]){
+ MD_TRC_EXT_BGSND_START_DEBUG2(i);
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[i];
+ memset(pSrc, 0, sizeof(EXT_BGSND_SRC_T));
+
+ pSrc->Hdr[BGSND_DL_PROCESS] = DLHisr;
+ pSrc->Hdr[BGSND_UL_PROCESS] = ULHisr;
+ pSrc->offHdr = offHdr;
+ for(j=0; j<MAX_NUM_BGSND_PROCESS; j++){//TODO temp solution
+
+ pSrc->state[j] = EXT_SRC_STATE_RUN;
+ //pSrc->fSph[j] = true; //TODO
+ //pSrc->gain[j] = 7; //TODO
+
+ // buffer reset
+ memset(pSrc->buffer[j], 0, sizeof(kal_uint16)*EXT_BGSND_SRC_BUF_SIZE);
+ pSrc->bufSize[j] = EXT_BGSND_SRC_BUF_SIZE;
+ pSrc->bufRead[j] = 0;
+ pSrc->bufWrite[j] = EXT_BGSND_BUF_PTR_DIFF;
+ pSrc->bufDataCount[j] = 0;
+ }
+ if(AM_IsSpeechOn() || AM_IsVoIPOn()){
+ EXT_BGSND_ConfigMixer(i, true, DLSNDGain, BGSND_DL_PROCESS);
+ EXT_BGSND_ConfigMixer(i, true, ULSNDGain, BGSND_UL_PROCESS);
+ }else{
+ EXT_BGSND_ConfigMixer(i, false, DLSNDGain, BGSND_DL_PROCESS);
+ EXT_BGSND_ConfigMixer(i, false, ULSNDGain, BGSND_UL_PROCESS);
+ }
+ Ext_BGSnd.is_used[i] = true;
+ if( 0 == Ext_BGSnd.num_src_used++){
+ MD_TRC_EXT_BGSND_START_SELECTED_SRC(i, Ext_BGSnd.num_src_used);
+ // lock DSP for sherif writing.
+ L1Audio_SetFlag( Ext_BGSnd.aud_id ); // REIMIND: Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag1
+ DSP_BGSND_Start(EXT_BGSND_DLHisr, EXT_BGSND_ULHisr);
+ }
+ MD_TRC_EXT_BGSND_START_DEBUG3(i);
+ break;
+ }
+ MD_TRC_EXT_BGSND_START_DEBUG4(i);
+ }
+ MD_TRC_EXT_BGSND_START_DEBUG5(i);
+ ASSERT(i < MAX_SIZE_EXT_BGSND_SRC);
+
+ MD_TRC_EXT_BGSND_START_LEAVE();
+ return i;
+}
+
+void EXT_BGSND_Flush(uint32 id) //under MED Task, triggered by the AP message, BGSND_OFF
+{ //flush buffer first, and then close it ; HISR will consume the buffer until it is empty.
+ int j;
+ MD_TRC_EXT_BGSND_FLUSH_ENTER();
+ ASSERT(Ext_BGSnd.is_used[id]);
+
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+ MD_TRC_EXT_BGSND_FLUSH_ID(id);
+
+ for(j=0; j<MAX_NUM_BGSND_PROCESS; j++){
+ if(EXT_SRC_STATE_RUN == pSrc->state[j]){
+ pSrc->state[j] = EXT_SRC_STATE_FLUSHING;
+ }else{//prevent double entry to the procedure of flushing
+ MD_TRC_EXT_BGSND_FLUSH_STATE(pSrc->state[j]);
+ }
+ }
+ MD_TRC_EXT_BGSND_FLUSH_LEAVE();
+}
+
+// under MED Task, triggered by the EXT_HISR when UL/DL buffer flushes completely.
+// Even if many src would like to close DSP BGSND, we don't think about the race condition since the request of closing is processed by MED's queue.
+// Due to it may force close. so status check nees to remove.
+void EXT_BGSND_Close(uint32 id)
+{
+ MD_TRC_EXT_BGSND_CLOSE_ENTER();
+ ASSERT(Ext_BGSnd.is_used[id]);
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+
+ // ASSERT(EXT_SRC_STATE_FLUSHING_OVER==pSrc->state[BGSND_DL_PROCESS]);
+ // ASSERT(EXT_SRC_STATE_FLUSHING_OVER==pSrc->state[BGSND_UL_PROCESS]);
+ MD_TRC_EXT_BGSND_CLOSE_SELECTED_SRC(id, Ext_BGSnd.num_src_used);
+
+ { //flush buffer first, and then close it // buffer reset
+ Ext_BGSnd.is_used[id] = false; // [IMPORTANT] HISR using the information to check BGS is under use or not. so put the line before clean all information.
+ Ext_BGSnd.num_src_used--;
+ }
+
+ pSrc->state[BGSND_DL_PROCESS] = pSrc->state[BGSND_UL_PROCESS] = EXT_SRC_STATE_STOPPING;
+
+ if( 0 == Ext_BGSnd.num_src_used){
+ DSP_BGSND_Stop();
+ L1Audio_ClearFlag( Ext_BGSnd.aud_id );
+
+ }
+ pSrc->state[BGSND_DL_PROCESS] = pSrc->state[BGSND_UL_PROCESS] = EXT_SRC_STATE_IDLE;
+ MD_TRC_EXT_BGSND_CLOSE_LEAVE();
+}
+
+void EXT_BGSND_DLHisr(void)
+{
+ MD_TRC_EXT_BGSND_DLHISR_ENTER();
+ EXT_BGSND_Hisr(BGSND_DL_PROCESS);
+ MD_TRC_EXT_BGSND_DLHISR_LEAVE();
+}
+
+void EXT_BGSND_ULHisr(void)
+{
+ MD_TRC_EXT_BGSND_ULHISR_ENTER();
+ EXT_BGSND_Hisr(BGSND_UL_PROCESS);
+ MD_TRC_EXT_BGSND_ULHISR_LEAVE();
+}
+
+/*static*/ int32 EXT_BGSND_GetDataCount(uint32 id, BGSND_PROCESS_TYPE type)
+{
+ int32 count = 0;
+ MD_TRC_EXT_BGSND_GETDATACOUNT_ENTER();
+
+ ASSERT( type == BGSND_DL_PROCESS || type == BGSND_UL_PROCESS );
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+
+ count = pSrc->bufDataCount[type];
+/* for(j=0; j<MAX_BGSND_BUFFER_PROCESS_BIT; j++){
+ if(type & (1<<j)){
+ type = 1<<j;
+ if(pSrc->bufWrite[type]<pSrc->bufRead[type]){
+ count = (pSrc->bufSize[type] - EXT_BGSND_BUF_PTR_DIFF)+pSrc->bufWrite[type] - pSrc->bufRead[type];
+ } else {
+ count = pSrc->bufWrite[type] - pSrc->bufRead[type];
+ }
+ }
+ }
+
+ if( count > EXT_BGSND_BUF_PTR_DIFF) {
+ count -= EXT_BGSND_BUF_PTR_DIFF;
+ } else {
+ count = 0;
+ }
+
+ if(count&1){
+ count = count -1;
+ }*/
+ MD_TRC_EXT_BGSND_GETDATACOUNT_COUNT(count);
+ MD_TRC_EXT_BGSND_GETDATACOUNT_LEAVE();
+ return count;
+}
+
+void EXT_BGSND_Hisr(BGSND_PROCESS_TYPE type)
+{
+ int i;
+ if(Ext_BGSnd.skip_hisr){
+ return;
+ }
+
+ MD_TRC_EXT_BGSND_HISR_ENTER();
+ MD_TRC_EXT_BGSND_HISR_BGSND_PROCESS_TYPE(type);
+
+ //reset buffer data
+ if( BGSND_DL_PROCESS == type){// align DL timing
+ for(i=0; i<BGSND_BUFFER_LEN; i++){ // To do , reduce computation
+ Ext_BGSnd.buffer[BGSND_DL_PROCESS][i] = 0;
+ }
+ for(i=0; i<BGSND_BUFFER_LEN; i++){
+ Ext_BGSnd.buffer[BGSND_UL_PROCESS][i] = 0;
+ }
+ }
+ DSP_BGSND_UpdateMixer();
+ for(i=0; i<MAX_SIZE_EXT_BGSND_SRC; i++){
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[i];
+ if(Ext_BGSnd.is_used[i]){
+ MD_TRC_EXT_BGSND_HISR_SELECTED_SRC(i, pSrc->state[type]);
+
+ //point 1
+ if(pSrc->Hdr[type]){ // Point1 must be before point2 since it is expected that in pSrc->Hdr[type](), len_WriteSrcBuffer_this_time will be updated by EXT_BGSND_WriteSrcBuffer
+ pSrc->Hdr[type](); // Each Hdr should update buffer[BGSND_ L_PROCESS] by EXT_BGSND_Buf_Add
+ }
+
+ //point 2
+ if(EXT_SRC_STATE_FLUSHING == pSrc->state[type]){ // FLUSHING --> FLUSHING_OVER
+ //if(EXT_BGSND_GetDataCount(i, type) <= EXT_BGSND_BUF_PTR_DIFF){
+ if( (0 == pSrc->len_WriteSrcBuffer_this_time) && (EXT_BGSND_GetDataCount(i, type) < BGSND_BUFFER_LEN) ){
+ MD_TRC_EXT_BGSND_HISR_EXT_SRC_STATE_FLUSHING_OVER(i, type);
+ pSrc->state[type] = EXT_SRC_STATE_FLUSHING_OVER;
+ if(EXT_SRC_STATE_FLUSHING_OVER == pSrc->state[1-type]){ // 1-type is just for the opposite. DL <-> UL
+ MD_TRC_EXT_BGSND_HISR_ENTER_SRC_OFFHDR(i);
+ Ext_BGSnd.skip_hisr = 1;
+ pSrc->offHdr(); //FLUSHING_OVER --> STOPPING
+ MD_TRC_EXT_BGSND_HISR_LEAVE_SRC_OFFHDR(i);
+ MD_TRC_EXT_BGSND_HISR_FLUSH_SRC_OFFHDR_COMPLETELY(i);
+ }else{//wait DL's flushing
+ MD_TRC_EXT_BGSND_HISR_WAIT_SRC_HDR_TO_FLUSH_COMPLETELY(i);
+ }
+ }else{
+ MD_TRC_EXT_BGSND_HISR_FLUSHING(i, type, EXT_BGSND_GetDataCount(i, type));
+ }
+ }else{
+ MD_TRC_EXT_BGSND_HISR_NOT_FLUSHING(i, type, pSrc->state[type]);
+ }
+
+
+
+ }else{
+ MD_TRC_EXT_BGSND_HISR_HDR_IS_NOT_USED(i);
+ }
+ pSrc->len_WriteSrcBuffer_this_time = 0;
+ }
+ MD_TRC_EXT_BGSND_HISR_LEAVE();
+}
+
+/*
+void EXT_BGSND_Buf_Add(uint32 id, uint16* src_buf, int src_len, BGSND_PROCESS_TYPE type) // write into ext buffer
+{
+ int i;
+ uint16 *dst_buf;
+ EXT_BGSND_SRC_T *pSrc;
+
+ MD_TRC_BGSND_DSP_BGSND_BUF_ADD(id, src_len, type);
+
+ ASSERT(Ext_BGSnd.is_used[id]);
+ pSrc = &Ext_BGSnd.src[id];
+
+ ASSERT( BGSND_BUFFER_LEN == src_len);//must be wb
+ ASSERT( type == BGSND_DL_PROCESS || type == BGSND_UL_PROCESS );
+
+ { // DL
+ dst_buf = Ext_BGSnd.buffer[type];
+
+ for(i=0; i<src_len; i++){//accumulate DSP_DLBuffer
+ if( src_buf[i] < (0x1111111111111111 - dst_buf[i])){ //limiter
+ dst_buf[i] += src_buf[i];
+ }else{
+ MD_TRC_BKGSND_DSP_BUF_ADD_BUF(i, src_buf[i], i, dst_buf[i]);
+ }
+ }
+ }
+}*/
+
+/*
+uint32 EXT_BGSND_SetEvent(uint32 id, void *data )
+{
+ ASSERT(Ext_BGSnd.is_used[id] && Ext_BGSnd.src[id].EventHandler);
+ is_send_event[id] = true;
+ Ext_BGSnd.src[i].event_data = data;
+ L1Audio_SetEvent(Ext_BGSnd.src.aud_id, NULL);
+}
+
+void EXT_BGSND_EventHandler(void)
+{
+ for(i=0; i<MAX_SIZE_EXT_BGSND_SRC; i++){//dispatch the event
+ if(Ext_BGSnd.is_send_event[i] && Ext_BGSnd.src[i].EventHandler){
+ Ext_BGSnd.src[i].EventHandler(Ext_BGSnd.src[i].event_data);
+ Ext_BGSnd.is_send_event[i] = false;
+ }
+ }
+}
+*/
+
+void EXT_BGSND_WriteSrcBuffer(uint32 id, kal_uint8 *srcBuf, kal_int32 bufLen, BGSND_PROCESS_TYPE type)
+{
+ int32 freeLen;
+ int32 srcBufLen = bufLen >> 1; // unit: 8bits -> 16bits
+ int32 currentRead;
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+
+ MD_TRC_EXT_BGSND_WRITESRCBUFFER_ENTER();
+ kal_take_spinlock(Ext_BGSnd.bgs_spinlockID, KAL_INFINITE_WAIT);
+ currentRead = pSrc->bufRead[type];
+
+ pSrc->len_WriteSrcBuffer_this_time = bufLen;
+
+ if(currentRead > pSrc->bufWrite[type]) { // one segment
+
+ freeLen = pSrc->bufSize[type] - pSrc->bufDataCount[type] - EXT_BGSND_BUF_PTR_DIFF;
+
+ MD_TRC_L1SND_WRITE_DATA(1, id, type, srcBufLen, freeLen, pSrc->bufRead[type], pSrc->bufWrite[type]+srcBufLen); /* using write information which is after memory copy*/
+
+ ASSERT(srcBufLen <= freeLen); // unit is 2 byte
+ memcpy(pSrc->buffer[type]+pSrc->bufWrite[type], srcBuf, srcBufLen*sizeof(uint16));
+
+ pSrc->bufWrite[type] += srcBufLen;
+ pSrc->bufDataCount[type] += srcBufLen;
+ }else { // two segment
+ int32 segment;
+ kal_uint8 *p2SrcBuf;
+
+ freeLen = pSrc->bufSize[type] - pSrc->bufDataCount[type] - EXT_BGSND_BUF_PTR_DIFF;
+
+ MD_TRC_L1SND_WRITE_DATA(2, id, type, srcBufLen, freeLen, 0, 0);
+ ASSERT(srcBufLen <= freeLen);
+
+ p2SrcBuf = srcBuf;
+ segment = pSrc->bufSize[type] - pSrc->bufWrite[type]; // bug
+ if(segment > srcBufLen){
+ segment = srcBufLen;
+ }
+
+ if(segment>0) { //first segment
+ memcpy(pSrc->buffer[type]+pSrc->bufWrite[type], p2SrcBuf, segment*sizeof(kal_uint16));
+ //update pointer
+ p2SrcBuf = srcBuf + segment*sizeof(kal_uint16);
+ pSrc->bufWrite[type] += segment;
+ pSrc->bufDataCount[type] += segment;
+ if(pSrc->bufWrite[type]>=pSrc->bufSize[type]){
+ pSrc->bufWrite[type] = 0;
+ }
+ MD_TRC_L1SND_WRITE_DATA(3, id, type, 0, 0, pSrc->bufRead[type], pSrc->bufWrite[type]);
+
+ segment = srcBufLen - segment;
+ }
+
+ if(segment>0) { //second segement
+ memcpy(pSrc->buffer[type], p2SrcBuf, segment*sizeof(kal_uint16));
+ pSrc->bufWrite[type] = segment;
+ pSrc->bufDataCount[type] += segment;
+
+ MD_TRC_L1SND_WRITE_DATA(4, id, type, 0, 0, pSrc->bufRead[type], pSrc->bufWrite[type]);
+ }
+ }
+ kal_give_spinlock(Ext_BGSnd.bgs_spinlockID);
+ MD_TRC_EXT_BGSND_WRITESRCBUFFER_LEAVE();
+}
+
+//from DL Src buffer -> DL ext buffer, multiplied by gain
+//from UL Src buffer -> UL ext buffer
+void EXT_BGSND_WriteExtBuffer(uint32 id, int gain, BGSND_PROCESS_TYPE type) // ToDo
+{
+ volatile uint16 *toPtr;
+ int32 count, segment, i;
+ uint16 *dataPtr;
+ uint16 gainFactor;
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_ENTER();
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_SELECTED_SRC(id, type);
+ ASSERT( type == BGSND_DL_PROCESS || type == BGSND_UL_PROCESS );
+ kal_take_spinlock(Ext_BGSnd.bgs_spinlockID, KAL_INFINITE_WAIT);
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_FSPH(pSrc->fSph[type], pSrc->gain[type]);
+
+ gainFactor = pSrc->gain[type];
+
+ count = EXT_BGSND_GetDataCount(id, type);
+ toPtr = Ext_BGSnd.buffer[type];
+
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_COUNT(count);
+
+ if (count > BGSND_BUFFER_LEN)
+ count = BGSND_BUFFER_LEN;
+
+
+ if(count > 0) {
+ /* First Segemnt */
+ if(pSrc->bufWrite[type] < pSrc->bufRead[type]) {
+ segment = (pSrc->bufSize[type] - pSrc->bufRead[type]);
+ } else {
+ segment = (pSrc->bufWrite[type] - pSrc->bufRead[type]);
+ }
+
+ if(segment&1){ // keep two sample alight
+ segment =segment - 1;
+ }
+
+ if (segment > count)
+ segment = count;
+
+ if (segment > 0) {
+ dataPtr = &(pSrc->buffer[type][pSrc->bufRead[type]]);
+
+ if(pSrc->fSph[type] && MAX_LEVEL_EXT_BGSND_GAIN!=gainFactor){
+ for (i=0; i<segment; i++) {
+
+ kal_int16 x = (*dataPtr>>gainFactor);
+ kal_int16 y = (kal_int16)(*toPtr);
+ kal_int16 result = x + y;
+
+ if (((x ^ y) >= 0) && (x ^ result) < 0) {
+ if (x < 0)
+ result = 0x8000;
+ else
+ result = 0x7FFF;
+ kal_prompt_trace(MOD_L1SP, "[EXT_BGSND_WriteExtBuffer] Saturation1 %d %d", x, y);
+
+ }
+ *toPtr = result;
+ toPtr++;
+ dataPtr++;
+ }
+ pSrc->dspLastSample[type] = *(toPtr-1);
+ }else{
+ toPtr += segment;
+ dataPtr += segment;
+
+ pSrc->dspLastSample[type] = 0;
+ }
+
+ pSrc->bufRead[type] += segment;
+ pSrc->bufDataCount[type] -= segment;
+ if (pSrc->bufRead[type] >= pSrc->bufSize[type])
+ pSrc->bufRead[type] = (pSrc->bufRead[type]-pSrc->bufSize[type]);
+
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_FILLED_TO_DSP(1, segment, pSrc->bufRead[type], pSrc->bufWrite[type]);
+ }
+
+ segment = count - segment;
+
+ if (segment > 0) {
+ dataPtr = &(pSrc->buffer[type][pSrc->bufRead[type]]);
+ if(pSrc->fSph[type] && MAX_LEVEL_EXT_BGSND_GAIN!=gainFactor){
+ for (i=0; i<segment; i++) {
+
+ kal_int16 x = (*dataPtr>>gainFactor);
+ kal_int16 y = (kal_int16)(*toPtr);
+ kal_int16 result = x + y;
+
+ if (((x ^ y) >= 0) && ((x ^ result) < 0)) {
+ if (x < 0)
+ result = 0x8000;
+ else
+ result = 0x7FFF;
+ kal_prompt_trace(MOD_L1SP, "[EXT_BGSND_WriteExtBuffer] Saturation2 %d, %d",x ,y);
+
+ }
+ *toPtr = result;
+ toPtr++;
+ dataPtr++;
+ }
+ pSrc->dspLastSample[type] = *(dataPtr-1);
+ }else{
+ toPtr += segment;
+ dataPtr += segment;
+
+ pSrc->dspLastSample[type] = 0;
+ }
+
+ pSrc->bufRead[type] += segment;
+ pSrc->bufDataCount[type] -= segment;
+ if (pSrc->bufRead[type] >= pSrc->bufSize[type])
+ pSrc->bufRead[type] = (pSrc->bufRead[type]-pSrc->bufSize[type]);
+
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_FILLED_TO_DSP(2, segment, pSrc->bufRead[type], pSrc->bufWrite[type]);
+ }
+ }
+
+ /* Put silence (last sample) if MCU buffer is empty */
+ if (count > 0 && count < BGSND_BUFFER_LEN && EXT_SRC_STATE_RUN == pSrc->state[type]) {
+ kal_uint16 last_sample = pSrc->dspLastSample[type];
+ // segment = dsp_buf_len - count;
+ segment = BGSND_BUFFER_LEN - count;
+ //for (i=0; i<segment; i++)) {
+ // *toPtr++ = last_sample;
+ //}
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_FILLED_TO_DSP_WITH_LAST_SAMPLE(segment, last_sample);
+ if(pSrc->fSph[type] && MAX_LEVEL_EXT_BGSND_GAIN!=gainFactor){
+ for (i=0; i<segment; i++) {
+ //*toPtr++ = *dataPtr++;
+ kal_int16 x = (last_sample>>gainFactor);
+ kal_int16 y = (kal_int16)(*toPtr);
+ kal_int16 result = x + y;
+
+ if (((x ^ y) >= 0) && ((x ^ result) < 0)) {
+ if (x < 0)
+ result = 0x8000;
+ else
+ result = 0x7FFF;
+ kal_prompt_trace(MOD_L1SP, "[EXT_BGSND_WriteExtBuffer] Saturation3 %d %d",x,y);
+
+ }
+
+ *toPtr = result;
+ toPtr++;
+ }
+ }else{
+ toPtr += segment;
+ }
+ }//else{ //it means no data should be played, so we don't append to the size of a frame any more
+ // kal_trace( TRACE_FUNC, EXT_BGSND_WRITEEXTBUFFER_SKIP_TO_DSP, count, pSrc->state[type]);
+ //}
+
+/* {
+ //just for debugging
+ int i;
+ for(i=0; i<10; i++){
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER(
+ Ext_BGSnd.buffer[type][0],Ext_BGSnd.buffer[type][1],
+ Ext_BGSnd.buffer[type][2],Ext_BGSnd.buffer[type][3],
+ Ext_BGSnd.buffer[type][4],Ext_BGSnd.buffer[type][5],
+ Ext_BGSnd.buffer[type][6],Ext_BGSnd.buffer[type][7],
+ Ext_BGSnd.buffer[type][8],Ext_BGSnd.buffer[type][9]
+);
+
+ }
+ }*/
+ kal_give_spinlock(Ext_BGSnd.bgs_spinlockID);
+ MD_TRC_EXT_BGSND_WRITEEXTBUFFER_LEAVE();
+}
+
+int32 EXT_BGSND_GetFreeSpace(uint32 id, BGSND_PROCESS_TYPE type)
+{
+
+ ASSERT( type == BGSND_DL_PROCESS || type == BGSND_UL_PROCESS );
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+
+ MD_TRC_EXT_BGSND_GETFREESPACE_ENTER();
+ MD_TRC_EXT_BGSND_GETFREESPACE_INFO(pSrc->bufSize[type], pSrc->bufRead[type], pSrc->bufWrite[type]);
+
+
+
+ MD_TRC_EXT_BGSND_GETFREESPACE_LEAVE();
+ return (pSrc->bufSize[type] - EXT_BGSND_BUF_PTR_DIFF - pSrc->bufDataCount[type]);
+}
+
+
+void EXT_BGSND_ConfigMixer(int id, kal_bool bSPHFlag, kal_int8 SNDGain, BGSND_PROCESS_TYPE type)
+{
+ EXT_BGSND_SRC_T *pSrc = &Ext_BGSnd.src[id];
+ MD_TRC_EXT_BGSND_CONFIGMIXER_ENTER();
+ ASSERT(SNDGain>=0 && SNDGain<=MAX_LEVEL_EXT_BGSND_GAIN);
+ MD_TRC_EXT_BGSND_CONFIGMIXER_BSPHFLAG(bSPHFlag, SNDGain);
+ pSrc->fSph[type] = bSPHFlag;
+ pSrc->gain[type] = MAX_LEVEL_EXT_BGSND_GAIN-SNDGain;
+ MD_TRC_EXT_BGSND_CONFIGMIXER_LEAVE();
+ /*
+ SNDGain = 7 --> Volume >> 0
+ SNDGain = 6 --> Volume >> 1
+ SNDGain = 5 --> Volume >> 2
+
+ SNDGain = 0 --> Volume * 0 = 0
+ */
+}
+
+
+EXT_SRC_STATE_TYPE EXT_BGSND_GetStatus(int id, BGSND_PROCESS_TYPE enULDL)
+{
+ ASSERT( id < MAX_SIZE_EXT_BGSND_SRC );
+ ASSERT( enULDL < MAX_NUM_BGSND_PROCESS );
+ return(Ext_BGSnd.src[id].state[enULDL]);
+}
+
+
+//================= Extended SPC BGSND INTERFACE ====================
+
+
+
+
+
diff --git a/mcu/driver/audio/src/v1/L/am_L.c b/mcu/driver/audio/src/v1/L/am_L.c
new file mode 100644
index 0000000..80e45a3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/L/am_L.c
@@ -0,0 +1,1056 @@
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_hrt_api.h"
+#include "intrCtrl.h"
+#include "syscomp_config.h"
+#include "kal_public_defs.h"
+#include "sync_data.h"
+
+#include "cache_sw.h" //? ask SS, it ought not be exposed from RCU_MEMORY_SIZE
+#include "mmu.h"
+#include "l1sp_trc.h"
+#include "audio_cc.h"
+#include "audio_ringbuf.h"
+#include "cc_irq_public.h"
+//#include "l1audio_trace_l1core.h"
+//#include "common_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio_trace_utmd.h"
+#include "us_timer.h"
+#include "audio_msgid.h"
+#include "drv_sap.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+//#include "uas_export_api.h"
+#include "csr_export_api.h"
+#include "sp_drv.h"
+#include "sp_ps.h"
+
+#define AUD_1TICK(tick) (tick * ((KAL_TICKS_10_MSEC) >> 1)) /* New Tick Transfer 1tick */
+#define AUD_10TICK(tick) (tick * (KAL_TICKS_50_MSEC)) /* New Tick Transfer 10tick */
+
+#define true (kal_bool)(1==1)
+#define false (kal_bool)(1==0)
+
+static struct {
+ kal_uint32 retrieved_events_L;
+ kal_uint32 events_l1FN_L;
+ kal_uint32 P2L_buf_L[CC_BUFFER_SIZE];
+ kal_uint32 L2P_buf_L[CC_BUFFER_SIZE];
+} l1audio_L;
+
+typedef struct {
+ void (*code_L)(kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32);
+ kal_uint32 data1_L;
+ kal_uint32 data2_L;
+ kal_uint32 data3_L;
+ kal_uint32 data4_L;
+ kal_uint32 data5_L;
+ kal_uint32 data6_L;
+ kal_uint32 data7_L;
+ kal_uint32 data8_L;
+ kal_uint32 data9_L;
+} AM_QFunction_L;
+
+typedef enum {
+ AM_STATE_IDLE_L,
+ AM_STATE_2G_L,
+ AM_STATE_3G_L,
+ AM_STATE_4G_L,
+ AM_STATE_C2K_L,
+ AM_STATE_STANDBY_L,
+}AM_STATE_L;
+
+static struct {
+ AM_STATE_L state_L;
+ RINGBUFFER_T(AM_QFunction_L,8) qfunc_L;
+ kal_bool tch_state_L; // true: TCH on; false: TCH off
+ kal_uint32 cntHandover_L;
+ kal_uint32 hasHandover_L;
+
+ uint16 ul_speech_mode_L; //behavior is the same as 3/4G
+ int8 ul_sub_channel_L; //behavior is the same as 3/4G
+ uint16 isVBISetFSM;
+}am_L;
+
+/*
+static struct {
+ unsigned short DSP_IO_L;
+}am_register_backup_L;
+*/
+static kal_uint32 u32L1Audio_DSP2MCU_Interrupt_L_counter;
+
+//Extern Funtions
+//2G
+extern unsigned short L1D_Audio_ChkDspInitDone();
+extern kal_uint32 L1I_GetTimeStamp( void );
+//extern unsigned short L1D_Audio_RestartDSP();
+extern void L1D_Audio_NoNeedDSP();
+extern void L1D_ENABLE_DTIRQ( void );
+
+void cc_irq_lisr_aud(kal_uint32 event_id, kal_uint32 param1, kal_uint32 param2);
+
+//Temp solution, and SS should support us with correct modifications!
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else //#if 0
+extern kalcc_rcuid aud_P2L_rcu;
+extern DEFINE_RCU_DC_ARRAY(kal_uint8, aud_P2L_rcu_mem, RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2)); // 1024 bytes * 1 blocks
+
+extern kalcc_rcuid aud_L2P_rcu;
+extern DEFINE_RCU_DC_ARRAY(kal_uint8, aud_L2P_rcu_mem, RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2)); // 1024 bytes * 1 blocks
+
+extern cc_eventgrpid AUD_P2L;
+extern cc_eventgrpid AUD_L2P;
+#endif //#if 0
+
+kal_uint32 convert_64us_diff_to_ms(kal_uint32 prev, kal_uint32 cur)
+{
+ kal_uint32 result;
+ result = (cur >= prev) ? (cur - prev) : (0xFFFFFFFF - prev + cur);
+ result = (result *64) / 1000;
+ return(result);
+}
+
+void AM_Init_L( void )
+{
+ RB_INIT( am_L.qfunc_L );
+ am_L.state_L = AM_STATE_IDLE_L;
+ am_L.tch_state_L = false;
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(0, am_L.cntHandover_L, am_L.hasHandover_L);
+ am_L.cntHandover_L = 0;
+ am_L.hasHandover_L = 0;
+ am_L.isVBISetFSM = 0;
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(1, am_L.cntHandover_L, am_L.hasHandover_L);
+ SAL_Dsp_Sph_Init();
+}
+
+static void AM_Enqueue_L( void (*code)(kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32, kal_uint32),
+ kal_uint32 data1, kal_uint32 data2,
+ kal_uint32 data3, kal_uint32 data4,
+ kal_uint32 data5, kal_uint32 data6,
+ kal_uint32 data7, kal_uint32 data8,
+ kal_uint32 data9, kal_bool isCritical )
+{
+ MD_TRC_L1Audio_Msg_PutQ_L(0);
+ if (isCritical) { // only 2g speech on will go to here
+ MD_TRC_L1Audio_Msg_PutQ_L(1);
+ AM_QFunction_L qf;
+
+
+ L1D_ENABLE_DTIRQ();
+
+ qf.code_L = code;
+ qf.data1_L = data1;
+ qf.data2_L = data2;
+ qf.data3_L = data3;
+ qf.data4_L = data4;
+ qf.data5_L = data5;
+ qf.data6_L = data6;
+ qf.data7_L = data7;
+ qf.data8_L = data8;
+ qf.data9_L = data9;
+ MD_TRC_L1Audio_Msg_PutQ_L(0);
+ RB_PUT( am_L.qfunc_L, qf );
+ MD_TRC_L1Audio_Msg_PutQ_L(1);
+
+ } else {// Direct execute in task
+ MD_TRC_L1Audio_Msg_PutQ_L(2);
+ code( data1 , data2, data3 , data4, data5, data6, data7, data8, data9 );
+ }
+ MD_TRC_L1Audio_Msg_PutQ_L(3);
+}
+
+kal_bool AM_IsSpeechOn_L( void ){
+ return AM_STATE_2G_L == am_L.state_L || AM_STATE_3G_L == am_L.state_L || AM_STATE_4G_L == am_L.state_L;
+}
+
+void AM_FlushQFunction_L( void )
+{
+#ifndef L1D_TEST
+ int i = 0;
+ while( !RB_EMPTY(am_L.qfunc_L) ){
+ kal_sleep_task( AUD_1TICK(1) );
+ i++;
+ ASSERT( i <= 5 ); // It is possible in the current design the CTIRQ disappears just after putting into the queue.
+ }
+#endif
+}
+
+void AM_Update_AudioManagerInfo(uint16 speech_mode, int8 sub_channel)
+{
+ MD_TRC_L1Audio_Msg_AM_AudioManagerInfo(speech_mode, sub_channel);
+ cc_irq_lisr_aud(IRQ_L2P_2G_AUDIOMANAGER_INFO, (kal_uint32)speech_mode, (kal_uint32)sub_channel);
+ am_L.ul_speech_mode_L = speech_mode;
+ am_L.ul_sub_channel_L = sub_channel;
+}
+
+kal_bool AM_AudioManager( kal_bool handover, kal_uint16 speech_mode, kal_int8 sub_channel )
+{
+ AM_QFunction_L func;
+
+ MD_TRC_L1Audio_Msg_AM_AudioManager_L( handover, speech_mode, sub_channel, L1Audio_Speech_State_L(am_L.state_L));
+ MD_TRC_L1Audio_Msg_AM_AudioManager2_L( am_L.ul_speech_mode_L, am_L.ul_sub_channel_L);
+ #if IS_SPEECH_RESYNC_SUPPORT
+ if(L1D_Get_Speech_Re_Sync_Flag())
+ L1Audio_Msg_AM_2G_Resync_L( am_L.speech_mode_L, speech_mode);
+ #endif
+ if( handover ){
+ AM_Update_AudioManagerInfo(speech_mode, sub_channel);
+ }
+
+ if( AM_STATE_2G_L == am_L.state_L && am_L.tch_state_L ){
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(2, am_L.cntHandover_L, am_L.hasHandover_L);
+ if( handover || 0 == am_L.hasHandover_L){
+ MD_TRC_L1Audio_Msg_AM_Handover_L(speech_mode, sub_channel);
+ cc_irq_lisr_aud(IRQ_L2P_2G_HANDOVER, (kal_uint32)speech_mode, (kal_uint32)sub_channel);
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(3, am_L.cntHandover_L, am_L.hasHandover_L);
+ am_L.cntHandover_L ++;
+ am_L.hasHandover_L = 1;
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(4, am_L.cntHandover_L, am_L.hasHandover_L);
+ AM_Update_AudioManagerInfo(speech_mode, sub_channel);
+ }else if(am_L.ul_speech_mode_L != speech_mode || am_L.ul_sub_channel_L != sub_channel){
+ AM_Update_AudioManagerInfo(speech_mode, sub_channel);
+ }
+ }
+
+#if defined(_MODEM_RESYNC_2G_)
+ if( AM_STATE_2G_L == am_L.state_L && am_L.tch_state_L ){
+ int16 time_drift = L1D_Get_Time_Drift(); //us
+ L1Audio_Msg_AM_Resync_L( 0, time_drift);
+ if(time_drift > 1000){
+ L1Audio_Msg_AM_Update_Time_Drift_L( 1 );//Q
+ L1D_Update_Time_Drift(true);
+ //notify DSP
+ SAL_8K_Resync(true, 8, true, 8);
+ }else if(time_drift < -1000){
+ L1Audio_Msg_AM_Update_Time_Drift_L( 0 );//Q
+ L1D_Update_Time_Drift(false);
+ //notify DSP
+ SAL_8K_Resync(true, -8, true, -8);
+ }
+ }
+#endif
+
+ if( !RB_EMPTY( am_L.qfunc_L ) ) {
+ RB_GET( am_L.qfunc_L, func );
+ uint32 func_code_L = (void*)func.code_L - (void*)0;
+ MD_TRC_L1Audio_Msg_GetQ_L( func_code_L, func.data1_L, func.data2_L, func.data3_L, func.data4_L, func.data5_L, func.data6_L, func.data7_L );
+ func.code_L( func.data1_L, func.data2_L, func.data3_L, func.data4_L, func.data5_L, func.data6_L, func.data7_L, func.data8_L, func.data9_L);
+ }
+
+ return false;
+}
+
+void cc_DSP_2G_Handover_L( kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel,
+ kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6 )
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 );
+
+#if defined(_MODEM_RESYNC_2G_)
+ L1Audio_Msg_AM_Reset_Time_Drift_L();//Q
+ L1D_Reset_Time_Drift();
+#endif
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(5, am_L.cntHandover_L, am_L.hasHandover_L);
+ ASSERT( am_L.cntHandover_L > 0);
+
+ am_L.cntHandover_L--;
+
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(6, am_L.cntHandover_L, am_L.hasHandover_L);
+ SAL_2G_Handover(enc_mod, dec_mod, sub_channel, am_L.tch_state_L, SAL_SRST_TYPE_HO);
+}
+
+
+void cc_2G_Handover_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel)
+{
+ //ASSERT( AM_STATE_2G == am.state );
+ if( AM_STATE_2G_L != am_L.state_L ){
+ MD_TRC_AM_L_CC_2G_HANDOVER_SKIP(am_L.tch_state_L, am_L.state_L);
+ return;
+ }
+ MD_TRC_AM_L_CC_2G_HANDOVER_ENTER(am_L.tch_state_L);
+ AM_Enqueue_L( cc_DSP_2G_Handover_L, enc_mod, dec_mod, sub_channel,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ am_L.tch_state_L );
+ AM_FlushQFunction_L();
+ MD_TRC_AM_L_CC_2G_HANDOVER_LEAVE();
+}
+
+void cc_DSP_2G_Call_Open_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel,
+ kal_uint32 resetType, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6 )
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 );
+
+#if defined(_MODEM_RESYNC_2G_)
+ L1Audio_Msg_AM_Reset_Time_Drift_L();
+ L1D_Reset_Time_Drift();
+#elif defined(_2G_DSP_SMR_SUPPORT_)
+ SAL_2G_SMR_Switch(true);
+#endif
+
+ SAL_2G_Call_Open(enc_mod, dec_mod, sub_channel, am_L.tch_state_L, resetType);
+}
+
+void cc_2G_Call_Open_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel, kal_uint32 resetType)
+{
+#if defined(_SWITCH_AFE_CLK_)
+ uint16 L1D_GetRF(uint16 mode);
+ uint16 RF_2G = L1D_GetRF(MML1_RF_2G);
+ MD_TRC_L1Audio_Msg_L1D_GetRF_L(RF_2G);
+#endif
+ MD_TRC_AM_L_CC_2G_CALLOPEN_ENTER(am_L.tch_state_L);
+#if defined(_SWITCH_AFE_CLK_)
+ if( 2 == RF_2G){ //return : 1 -> RF1, 2-> RF2
+ *MD2GSYS_AFE_CK_SEL = 0x0;
+ }
+#endif
+ //ASSERT( 0 == am.cntHandover || 2 == am.cntHandover);
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(7, am_L.cntHandover_L, am_L.hasHandover_L);
+ {
+ am_L.hasHandover_L = 0;
+ }
+ MD_TRC_L1Audio_Msg_AM_HandoverInfo_L(8, am_L.cntHandover_L, am_L.hasHandover_L);
+
+
+ AM_Enqueue_L( cc_DSP_2G_Call_Open_L, enc_mod, dec_mod, sub_channel, resetType,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ am_L.tch_state_L );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_2G_L;
+ MD_TRC_AM_L_CC_2G_CALLOPEN_LEAVE();
+}
+
+void cc_DSP_2G_Call_Close_L(kal_uint32 dsp_end,
+ kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8 )
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+
+#if defined(_2G_DSP_SMR_SUPPORT_)
+ SAL_2G_SMR_Switch(false);
+#endif
+ SAL_2G_Call_Close(dsp_end);
+}
+
+void cc_2G_Call_Close_L(kal_uint32 dsp_end)
+{
+#if defined(_SWITCH_AFE_CLK_)
+ uint16 L1D_GetRF(uint16 mode);
+ uint16 RF_2G = L1D_GetRF(MML1_RF_2G);
+ MD_TRC_L1Audio_Msg_L1D_GetRF_L(RF_2G);
+#endif
+ MD_TRC_AM_L_CC_2G_CALLCLOSE_ENTER(am_L.tch_state_L);
+#if defined(_SWITCH_AFE_CLK_)
+ if( 2 == RF_2G){ //return : 1 -> RF1, 2-> RF2
+ *MD2GSYS_AFE_CK_SEL = 0x1;
+ }
+#endif
+ AM_Enqueue_L( cc_DSP_2G_Call_Close_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ am_L.tch_state_L );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ MD_TRC_AM_L_CC_2G_CALLCLOSE_LEAVE();
+}
+
+void cc_DSP_3G_Call_Open_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM,
+ kal_uint32 resetType, kal_uint32 dummy1, kal_uint32 dummy2)
+{
+ uint16 LinkMode = SAL_3GLINK_MODE_NONE;
+
+#if defined( __UMTS_RAT__ )
+ switch(L1SP_GetSIMStatus()) {
+ case SP_3G_SIM_FDD_ACTIVE:
+ LinkMode = SAL_3GLINK_MODE_WCDMA;
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ LinkMode = SAL_3GLINK_MODE_TDSCDMA;
+ break;
+ default:
+ LinkMode = SAL_3GLINK_MODE_NONE;
+ }
+#endif
+
+ SAL_3G_Call_Open(enc_mod, dec_mod, dtx, delR, delW, delM, LinkMode, resetType);
+}
+
+void cc_3G_Call_Open_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us,
+ kal_uint32 resetType)
+{
+ kal_uint32 u32CurTime64usLocal, u32delay, u32delaySample;
+
+ MD_TRC_AM_L_CC_3G_CALLOPEN_ENTER(delR, delW);
+
+ u32CurTime64usLocal = fma_get_glb_ts();
+ u32delay = convert_64us_diff_to_ms(u32CurTime64us, u32CurTime64usLocal); //ms
+ u32delaySample = (u32delay % 20) * 8; //sample
+ if( (u32delaySample >= delR || u32delaySample >= delW) && (0 != u32delaySample) )
+ {
+ delR += 160;
+ delW += 160;
+ }
+ delR -= u32delaySample;
+ delW -= u32delaySample;
+
+ AM_Enqueue_L( cc_DSP_3G_Call_Open_L, enc_mod, dec_mod, dtx, delR, delW, delM, resetType,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_3G_L;
+ MD_TRC_AM_L_CC_3G_CALLOPEN_LEAVE(delR, delW, u32delay);
+}
+
+void cc_DSP_3G_Call_Close_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_3G_Call_Close(dsp_end);
+}
+
+void cc_3G_Call_Close_L(kal_uint32 dsp_end)
+{
+ MD_TRC_AM_L_CC_3G_CALLCLOSE_ENTER();
+ AM_Enqueue_L( cc_DSP_3G_Call_Close_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ MD_TRC_AM_L_CC_3G_CALLCLOSE_LEAVE();
+}
+
+void cc_DSP_4G_Call_Open_temp_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType, kal_uint32 dummy1, kal_uint32 dummy2)
+{
+ switch(resetType){
+ case PS_SRST_TYPE_HO_WITHOUT_VBIEND:
+ case PS_SRST_TYPE_UNSYNC:
+ SAL_4G_Call_Handover( enc_mod, dec_mod, dtx, delR, delW, delM, resetType);
+ break;
+ case PS_SRST_TYPE_CALLON:
+ case PS_SRST_TYPE_DEV:
+ case PS_SRST_TYPE_HO_WITH_VBIEND:
+ SAL_4G_Call_Open_temp( enc_mod, dec_mod, dtx, delR, delW, delM, resetType);
+ break;
+ }
+}
+
+void cc_4G_Call_Open_temp_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+ kal_uint32 u32CurTime64usLocal, u32delay, u32delaySample;
+
+
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER();
+
+ u32CurTime64usLocal = fma_get_glb_ts();
+ u32delay = convert_64us_diff_to_ms(u32CurTime64us, u32CurTime64usLocal); //ms
+ u32delaySample = (u32delay % 20) * 8; //sample
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER_DBG(1, delR, delW, u32CurTime64us, u32CurTime64usLocal, u32delay, u32delaySample);
+ if( (u32delaySample >= delR || u32delaySample >= delW) && (0 != u32delaySample) )
+ {
+ delR += 160;
+ delW += 160;
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER_DBG(2, delR, delW, u32CurTime64us, u32CurTime64usLocal, u32delay, u32delaySample);
+ }
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER_DBG(3, delR, delW, u32CurTime64us, u32CurTime64usLocal, u32delay, u32delaySample);
+ delR -= u32delaySample;
+ delW -= u32delaySample;
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER_DBG(4, delR, delW, u32CurTime64us, u32CurTime64usLocal, u32delay, u32delaySample);
+
+
+ AM_Enqueue_L( cc_DSP_4G_Call_Open_temp_L, enc_mod, dec_mod, dtx, delR, delW, delM, resetType, CC_DUMMY_PARAM, CC_DUMMY_PARAM, false );
+ AM_FlushQFunction_L();
+ MD_TRC_AM_L_CC_4G_CALLOPEN_ENTER_DBG(5, delR, delW, u32CurTime64us, u32CurTime64usLocal, u32delay, u32delaySample);
+ am_L.state_L = AM_STATE_4G_L;
+ MD_TRC_AM_L_CC_4G_CALLOPEN_LEAVE(delR, delW, u32delay, resetType);
+}
+
+void cc_DSP_4G_Call_Close_temp_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_4G_Call_Close_temp(dsp_end);
+}
+
+void cc_4G_Call_Close_temp_L(kal_uint32 dsp_end)
+{
+ MD_TRC_AM_L_CC_4G_CALLCLOSE_ENTER();
+ AM_Enqueue_L( cc_DSP_4G_Call_Close_temp_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ MD_TRC_AM_L_CC_4G_CALLCLOSE_LEAVE();
+}
+
+#if 1
+void cc_DSP_4G_G_Codec_Call_Open_temp_L(kal_uint32 band_mod, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_4G_ExtCod_Call_Open(band_mod, 0, delR, delW, delM, resetType);
+}
+
+void cc_4G_G_Codec_Call_Open_temp_L(kal_uint32 band_mod, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us,
+ kal_uint32 resetType)
+{
+ kal_uint32 u32CurTime64usLocal, u32delay, u32delaySample;
+
+
+ kal_prompt_trace(MOD_L1SPL1, "cc_4G_G_Codec_Call_Open_temp Enter");
+
+ u32CurTime64usLocal = fma_get_glb_ts();
+ u32delay = convert_64us_diff_to_ms(u32CurTime64us, u32CurTime64usLocal); //ms
+ u32delaySample = (u32delay % 20) * 8; //sample
+ if( (u32delaySample >= delR || u32delaySample >= delW) && (0 != u32delaySample) )
+ {
+ delR += 160;
+ delW += 160;
+ }
+ delR -= u32delaySample;
+ delW -= u32delaySample;
+
+ AM_Enqueue_L( cc_DSP_4G_G_Codec_Call_Open_temp_L, band_mod, delR, delW, delM, resetType, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_4G_L;
+ kal_prompt_trace(MOD_L1SP, "cc_4G_G_Codec_Call_Open_temp Leave delR=%d delW=%d P_to_L1_delay=%dms", delR, delW, u32delay);
+}
+
+void cc_DSP_4G_G_Codec_Call_Close_temp_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_4G_ExtCod_Call_Close(dsp_end);
+}
+
+void cc_4G_G_Codec_Call_Close_temp_L(kal_uint32 dsp_end)
+{
+ kal_prompt_trace(MOD_L1SPL1, "cc_4G_G_Codec_Call_Close_temp Enter");
+ AM_Enqueue_L( cc_DSP_4G_G_Codec_Call_Close_temp_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ kal_prompt_trace(MOD_L1SPL1, "cc_4G_G_Codec_Call_Close_temp Leave");
+}
+#endif
+
+void cc_DSP_4G_EVS_Codec_Call_Open_temp_L(kal_uint32 codec, kal_uint32 isDTX, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3)
+{
+ switch(resetType){
+ case PS_SRST_TYPE_HO_WITHOUT_VBIEND:
+ case PS_SRST_TYPE_UNSYNC:
+ SAL_4G_EVS_Call_Handover(codec, codec, isDTX, delR, delW, delM, resetType);
+ break;
+ case PS_SRST_TYPE_CALLON:
+ case PS_SRST_TYPE_DEV:
+ case PS_SRST_TYPE_HO_WITH_VBIEND:
+ SAL_4G_EVS_Call_Open(codec, codec, isDTX, delR, delW, delM, resetType);
+ break;
+ }
+}
+
+
+void cc_4G_EVS_Codec_Call_Open_temp_L(kal_uint32 codec, kal_uint32 isDTX, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+#if 1
+ kal_uint32 u32CurTime64usLocal, u32delay, u32delaySample;
+
+
+ //kal_prompt_trace(MOD_L1SPL1, "cc_4G_EVS_Codec_Call_Open_temp_L Enter");
+ MD_TRC_AM_L_CC_4G_EVSCALLOPEN_ENTER();
+
+ u32CurTime64usLocal = fma_get_glb_ts();
+ u32delay = convert_64us_diff_to_ms(u32CurTime64us, u32CurTime64usLocal); //ms
+ u32delaySample = (u32delay % 20) * 8; //sample
+ if( (u32delaySample >= delR || u32delaySample >= delW) && (0 != u32delaySample) )
+ {
+ delR += 160;
+ delW += 160;
+ }
+ delR -= u32delaySample;
+ delW -= u32delaySample;
+
+
+ AM_Enqueue_L( cc_DSP_4G_EVS_Codec_Call_Open_temp_L, codec, isDTX, delR, delW, delM, resetType,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_4G_L;
+ //kal_prompt_trace(MOD_L1SP, "cc_4G_EVS_Codec_Call_Open_temp_L Leave delR=%d delW=%d P_to_L1_delay=%dms", delR, delW, u32delay);
+ MD_TRC_AM_L_CC_4G_EVSCALLOPEN_LEAVE(delR, delW, u32delay, resetType);
+#endif
+}
+
+
+void cc_DSP_4G_EVS_Codec_Call_Close_temp_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6,kal_uint32 dummy7, kal_uint32 dummy8)
+{
+#if 1
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_4G_EVS_Call_Close(dsp_end);
+#endif
+}
+
+
+void cc_4G_EVS_Codec_Call_Close_temp_L(kal_uint32 dsp_end)
+{
+#if 1
+ //kal_prompt_trace(MOD_L1SPL1, "cc_4G_EVS_Codec_Call_Close_temp_L Enter");
+ MD_TRC_AM_L_CC_4G_EVSCALLCLOSE_ENTER();
+
+ AM_Enqueue_L( cc_DSP_4G_EVS_Codec_Call_Close_temp_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+
+ //kal_prompt_trace(MOD_L1SPL1, "cc_4G_EVS_Codec_Call_Close_temp_L Leave");
+ MD_TRC_AM_L_CC_4G_EVSCALLCLOSE_LEAVE();
+#endif
+}
+
+void cc_DSP_C2K_Call_Open_L(kal_uint32 so, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4)
+{
+ SAL_C2K_Call_Open(so, dtx, delR, delW, delM, resetType);
+}
+
+void cc_C2K_Call_Open_L(kal_uint32 so, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType)
+{
+ MD_TRC_AM_L_CC_C2K_CALLOPEN_ENTER(so, dtx, delR, delW, delM);
+
+ AM_Enqueue_L( cc_DSP_C2K_Call_Open_L, so, dtx, delR, delW, delM,
+ resetType, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_C2K_L;
+ MD_TRC_AM_L_CC_C2K_CALLOPEN_LEAVE(so, dtx, delR, delW, delM);
+}
+
+void cc_DSP_C2K_Call_Close_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_C2K_Call_Close(dsp_end);
+}
+
+void cc_C2K_Call_Close_L(kal_uint32 dsp_end)
+{
+ MD_TRC_AM_L_CC_C2K_CALLCLOSE_ENTER();
+ AM_Enqueue_L( cc_DSP_C2K_Call_Close_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ MD_TRC_AM_L_CC_C2K_CALLCLOSE_LEAVE();
+}
+
+
+void cc_DSP_Standby_Call_Open_L(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3)
+{
+ //SAL_Standby_Call_Open(uint32 enc_mod, uint32 dec_mod, uint32 dtx, uint32 delR, uint32 delW, uint32 delM)
+ SAL_Standby_Call_Open( enc_mod, enc_mod, 0, 31*8, 26*8, 0x20+(16<<10)+(2<<8), SAL_SRST_TYPE_CALLON );
+}
+
+void cc_set_VBI_for_FSM_L(kal_uint32 op)
+{
+ switch (op ){
+ case 1:
+ ASSERT(0==am_L.isVBISetFSM);
+ SAL_SetCallCloseWithFSM();
+ am_L.isVBISetFSM = 1;
+ break;
+ case 2:
+ ASSERT(1==am_L.isVBISetFSM);
+ {
+ int i = 0;
+ while( !SAL_IsCallCloseDone() ){
+ kal_sleep_task( AUD_1TICK(1) );
+ i++;
+ ASSERT( i <= 8 ); // It is possible in the current design the CTIRQ disappears just after putting into the queue.
+ }
+ }
+ am_L.isVBISetFSM = 0;
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+
+void cc_Standby_Call_Open_L(kal_uint32 enc_mod)
+{
+ MD_TRC_AM_L_CC_STANDBY_CALLOPEN_ENTER(enc_mod);
+
+ AM_Enqueue_L( cc_DSP_Standby_Call_Open_L, enc_mod, enc_mod, 0, 31*8, 26*8, 0x20+(16<<10)+(2<<8), CC_DUMMY_PARAM ,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, false);
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_STANDBY_L;
+ MD_TRC_AM_L_CC_STANDBY_CALLOPEN_LEAVE();
+}
+
+void cc_DSP_Standby_Call_Close_L(kal_uint32 dsp_end, kal_uint32 dummy1, kal_uint32 dummy2, kal_uint32 dummy3, kal_uint32 dummy4, kal_uint32 dummy5, kal_uint32 dummy6, kal_uint32 dummy7, kal_uint32 dummy8)
+{
+ //ASSERT( CC_DUMMY_PARAM == dummy1 && CC_DUMMY_PARAM == dummy2 && CC_DUMMY_PARAM == dummy3 && CC_DUMMY_PARAM == dummy4 && CC_DUMMY_PARAM == dummy5 && CC_DUMMY_PARAM == dummy6 );
+ SAL_Standby_Call_Close(dsp_end);
+}
+
+void cc_Standby_Call_Close_L(kal_uint32 dsp_end)
+{
+ MD_TRC_AM_L_CC_STANDBY_CALLCLOSE_ENTER();
+ AM_Enqueue_L( cc_DSP_Standby_Call_Close_L, dsp_end,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ CC_DUMMY_PARAM, CC_DUMMY_PARAM,
+ false );
+ AM_FlushQFunction_L();
+ am_L.state_L = AM_STATE_IDLE_L;
+ MD_TRC_AM_L_CC_STANDBY_CALLCLOSE_LEAVE();
+}
+
+
+void cc_L1D_Audio_ChkDspInitDone_L()
+{
+ while( 0 == L1D_Audio_ChkDspInitDone()){
+ kal_sleep_task(AUD_1TICK(1));
+ }
+}
+
+
+
+void L1Audio_Task_L(unsigned argc, void *argv)
+{
+ void L1Aud_Handler_L( kal_uint32 P2LBuf[CC_BUFFER_SIZE], kal_uint32 L2PBuf[CC_BUFFER_SIZE] );
+ kal_uint32 retrieved_events;
+ int i;
+ kal_uint32 P2LBuf[CC_BUFFER_SIZE];
+ kal_uint32 L2PBuf[CC_BUFFER_SIZE];
+ kal_uint32 *P2L_rcu_buf;
+ kal_uint32 *L2P_rcu_buf;
+
+ while( 1 ) {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2LBuf[i] = L2PBuf[i] = 0 ;
+ }
+ MD_TRC_AM_L_L1AUD_TASK_CLRBUF();
+ // P->L receives PCore's Messages
+ kalcc_retrieve_eg_events(SHARED_pVAR(AUD_P2L), 1 << AUD_P2L_MESSAGE_BIT, KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND);
+
+ l1audio_L.retrieved_events_L = retrieved_events;
+ l1audio_L.events_l1FN_L = L1I_GetTimeStamp();
+
+ MD_TRC_AM_L_L1AUD_TASK_P2L();
+
+ //Retrieve Params
+ P2L_rcu_buf = rcu_get_read_lock(SHARED_VAR(aud_P2L_rcu));
+ //dynamic_switch_cacheable_region(&P2L_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_CACHEABLE);
+
+ for(i=0; i<CC_BUFFER_SIZE; i++){
+ P2LBuf[i] = P2L_rcu_buf[i];
+ MD_TRC_AM_L_L1AUD_TASK_P2L_DATA(i, P2LBuf[i]);
+ }
+ //dynamic_switch_cacheable_region(&P2L_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_NO_CACHE);
+ ASSERT( KAL_SUCCESS == rcu_free_read_lock(P2L_rcu_buf));
+
+ ASSERT(P2LBuf[1] <= CC_MAX_DATA);
+
+ L1Aud_Handler_L( P2LBuf, L2PBuf );
+
+ ASSERT(L2PBuf[1] <= CC_MAX_DATA);
+
+ // L -> P sends returns
+ //Prepare Params
+ L2P_rcu_buf = rcu_get_free_buff(SHARED_VAR(aud_L2P_rcu));
+ //dynamic_switch_cacheable_region(&L2P_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_CACHEABLE);
+
+ for(i=0; i<CC_BUFFER_SIZE; i++){
+ MD_TRC_AM_L_L1AUD_TASK_L2P_DATA(i, L2PBuf[i]);
+ L2P_rcu_buf[i] = L2PBuf[i];
+ }
+ //dynamic_switch_cacheable_region(&L2P_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_NO_CACHE);
+ ASSERT(KAL_SUCCESS == rcu_commit_data(L2P_rcu_buf));
+
+ //Send A CrossCore Message
+ kalcc_set_eg_events(SHARED_pVAR(AUD_L2P), 0xFF, KAL_OR);
+ MD_TRC_AM_L_L1AUD_TASK_L2P();
+
+ ASSERT( ( P2LBuf[0] | 0x8000 ) == L2PBuf[0] );
+ }//end of while
+
+}
+
+
+void L1SP_TCH_Notify_L( kal_bool bOn )
+{
+ cc_irq_lisr_aud(IRQ_L2P_TCH_NOTIFY, (kal_uint32)bOn, 0);
+ am_L.tch_state_L = bOn;
+ MD_TRC_L1Audio_Msg_TCH_NOTIFY_L(L1AUDIO_Str_onoff(bOn), L1Audio_Speech_State_L(am_L.state_L));
+}
+
+
+
+//void SP4G_emac_timing_update(l1sp_emac_volte_timing_info_struct* p_timing_info){
+//
+//}
+
+
+void L1Aud_Handler_L( kal_uint32 P2LBuf[CC_BUFFER_SIZE], kal_uint32 L2PBuf[CC_BUFFER_SIZE] )
+{
+ switch(P2LBuf[0]){
+ case MSG_P2L_2G_CALL_ON:
+ ASSERT( 4 == P2LBuf[1]);
+ cc_2G_Call_Open_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5]);
+
+ L2PBuf[0] = MSG_L2P_2G_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_2G_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_2G_Call_Close_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_2G_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_2G_HANDOVER:
+ ASSERT( 3 == P2LBuf[1]);
+ cc_2G_Handover_L(P2LBuf[2], P2LBuf[3], P2LBuf[4]);
+
+ L2PBuf[0] = MSG_L2P_2G_HANDOVER_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_3G_CALL_ON:
+ ASSERT( 8 == P2LBuf[1]);
+ cc_3G_Call_Open_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5], P2LBuf[6], P2LBuf[7], P2LBuf[8], P2LBuf[9]);
+
+ L2PBuf[0] = MSG_L2P_3G_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_3G_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_3G_Call_Close_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_3G_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_CALL_ON:
+ ASSERT( 8 == P2LBuf[1]);
+ cc_4G_Call_Open_temp_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5], P2LBuf[6], P2LBuf[7], P2LBuf[8], P2LBuf[9]);
+
+ L2PBuf[0] = MSG_L2P_4G_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_4G_Call_Close_temp_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_4G_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_G_Codec_CALL_ON:
+ ASSERT( 6 == P2LBuf[1]);
+ cc_4G_G_Codec_Call_Open_temp_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5], P2LBuf[6], P2LBuf[7]);
+
+
+ L2PBuf[0] = MSG_L2P_4G_G_Codec_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_G_Codec_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_4G_G_Codec_Call_Close_temp_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_4G_G_Codec_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_EVS_Codec_CALL_ON:
+ ASSERT( 7 == P2LBuf[1]);
+ cc_4G_EVS_Codec_Call_Open_temp_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5], P2LBuf[6], P2LBuf[7], P2LBuf[8]);
+
+ L2PBuf[0] = MSG_L2P_4G_EVS_Codec_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_4G_EVS_Codec_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_4G_EVS_Codec_Call_Close_temp_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_4G_EVS_Codec_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_C2K_CALL_ON:
+ ASSERT( 6 == P2LBuf[1]);
+ cc_C2K_Call_Open_L(P2LBuf[2], P2LBuf[3], P2LBuf[4], P2LBuf[5], P2LBuf[6], P2LBuf[7]);
+
+ L2PBuf[0] = MSG_L2P_C2K_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_C2K_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_C2K_Call_Close_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_C2K_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_SET_VBI_FOR_FSM:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_set_VBI_for_FSM_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_SET_VBI_FOR_FSM_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_STANDBY_CALL_ON:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_Standby_Call_Open_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_STANDBY_CALL_ON_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_STANDBY_CALL_OFF:
+ ASSERT( 1 == P2LBuf[1]);
+ cc_Standby_Call_Close_L(P2LBuf[2]);
+
+ L2PBuf[0] = MSG_L2P_STANDBY_CALL_OFF_ACK;
+ L2PBuf[1] = 0;
+ break;
+ case MSG_P2L_AUD_RESTART_DSP:
+ {
+ //unsigned short DSP_status;
+ ASSERT( 0 == P2LBuf[1]);
+ kal_prompt_trace(MOD_L1SP, "[DBG]MSG_P2L_AUD_RESTART_DSP 1");
+ //DSP_status = L1D_Audio_RestartDSP();
+ kal_prompt_trace(MOD_L1SP, "[DBG]MSG_P2L_AUD_RESTART_DSP 2");
+ L2PBuf[0] = MSG_L2P_AUD_RESTART_DSP_ACK;
+ L2PBuf[1] = 1;
+ //L2PBuf[2] = DSP_status;
+ }
+ break;
+ case MSG_P2L_AUD_NONEEDDSP:
+ {
+ ASSERT( 0 == P2LBuf[1]);
+ kal_prompt_trace(MOD_L1SP, "[DBG]L1D_Audio_NoNeedDSP 1");
+ L1D_Audio_NoNeedDSP();
+ kal_prompt_trace(MOD_L1SP, "[DBG]L1D_Audio_NoNeedDSP 2");
+ L2PBuf[0] = MSG_L2P_AUD_NONEEDDSP_ACK;
+ L2PBuf[1] = 0;
+ }
+ break;
+ case MSG_P2L_L1D_AUD_CHKDSPINITDONE:
+ {
+ ASSERT( 0 == P2LBuf[1]);
+ cc_L1D_Audio_ChkDspInitDone_L();
+
+ L2PBuf[0] = MSG_L2P_L1D_AUD_CHKDSPINITDONE_ACK;
+ L2PBuf[1] = 0;
+ }
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+}
+
+
+//Fix build error with mcu\l1core\modem\tl1\tl1sim\tl1sim_dummy.c
+#if !((!defined(__MT6291PLUS_FIX__ERROR_)) && defined(__L1_STANDALONE__))
+void SP3G_UpdateL1AInFo( kal_uint8 bitmap, kal_uint8 value )
+{
+ ilm_struct current_ilm;
+ ilm_L2P_SP3G_UPDATE_L1_INFO *local_para;
+
+ MD_TRC_SP3G_L1A_UPDATE_INFO_L(bitmap, value);
+
+ current_ilm.src_mod_id = MOD_L1SPL1;
+ current_ilm.dest_mod_id = MOD_MED;
+ current_ilm.sap_id = AUDIO_SAP;
+ current_ilm.msg_id = MSG_ID_AUDIO_L2P_SP3G_UPDATE_L1_INFO;
+ current_ilm.peer_buff_ptr = NULL;
+ //current_ilm.local_para_ptr = construct_cc_non_cached_local_para(sizeof(ilm_L2P_SP3G_UPDATE_L1_INFO),TD_RESET);
+ current_ilm.local_para_ptr = construct_local_para(sizeof(ilm_L2P_SP3G_UPDATE_L1_INFO),TD_RESET);
+ local_para = (ilm_L2P_SP3G_UPDATE_L1_INFO *)current_ilm.local_para_ptr;
+ local_para->l1_info[0] = bitmap;
+ local_para->l1_info[1] = value;
+
+ msg_send_cc(¤t_ilm);
+ /*
+ ilm_L2P_SP3G_UPDATE_L1_INFO *local_para;
+ kal_prompt_trace(MOD_L1SP, "[SP3G_UpdateL1AInFo] Enter");
+ local_para = (ilm_L2P_SP3G_UPDATE_L1_INFO *) construct_local_para( sizeof(ilm_L2P_SP3G_UPDATE_L1_INFO), TD_CTRL );
+ local_para->l1_info[0] = bitmap;
+ local_para->l1_info[1] = value;
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_L2P_SP3G_UPDATE_L1_INFO, (local_para_struct *)local_para, NULL);
+ kal_prompt_trace(MOD_L1SP, "[SP3G_UpdateL1AInFo] Leave"); */
+}
+#endif //#if !((!defined(__MT6291PLUS_FIX__ERROR_)) && defined(__L1_STANDALONE__))
+
+
+static void l1audio_main_L(task_entry_struct * task_entry_ptr)
+{
+ kal_set_active_module_id(MOD_L1SPL1);
+
+ L1Audio_Task_L( 0, 0 );
+}
+
+static kal_bool l1audio_init_L(void)
+{
+ kal_status ret;
+
+ u32L1Audio_DSP2MCU_Interrupt_L_counter = 0;
+
+ ret = kalcc_create_event_group( SHARED_pVAR(AUD_P2L), "receive_AUD_P2L_eg" );
+ ASSERT(KAL_SUCCESS == ret);
+
+ SHARED_VAR(aud_L2P_rcu) = rcu_create((void *)SHARED_ARRAY(aud_L2P_rcu_mem),
+ RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2),
+ CC_BUFFER_SIZE * sizeof(kal_uint32), 0);
+ AM_Init_L();
+ return KAL_TRUE;
+}
+kal_bool l1spl1_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct l1spl1_handler_info =
+ {
+ l1audio_main_L, /* task entry function */
+ l1audio_init_L, /* task initialization function */
+ NULL, /* task configuration function */
+
+ };
+
+ *handle = (comptask_handler_struct *)&l1spl1_handler_info;
+
+ return KAL_TRUE;
+}
+
+void l1sp_register_backup()
+{
+ //L1Audio_Msg_AM_L1D_Backup_L(0, *SHARE2_D2MCON);
+ //am_register_backup_L.DSP_IO_L = *SHARE2_D2MCON;
+}
+
+void l1sp_register_backup_notify()
+{
+ //L1Audio_Msg_AM_L1D_Backup_L(0, *SHARE2_D2MCON);
+ //am_register_backup_L.DSP_IO_L = *SHARE2_D2MCON;
+}
+
+void l1sp_register_restore()
+{
+ //L1Audio_Msg_AM_L1D_Backup_L(1, am_register_backup_L.DSP_IO_L);
+
+ //*SHARE2_D2MCON = am_register_backup_L.DSP_IO_L;
+ //Data_Sync_Barrier();
+ //L1Audio_Msg_AM_L1D_Backup_L(2, *SHARE2_D2MCON);
+}
+
+void L1AL_Timer_L_HISR( void )
+{
+ MD_TRC_AM_L_SP3G_UPDATEL1DSYNC_TIMER(0);
+
+}
diff --git a/mcu/driver/audio/src/v1/L/dummy_audio_L.c b/mcu/driver/audio/src/v1/L/dummy_audio_L.c
new file mode 100644
index 0000000..4b6331c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/L/dummy_audio_L.c
@@ -0,0 +1,225 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * dummy_audio.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Provide APIs when speech functionality is disabled
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "syscomp_config.h"
+
+
+
+/************************************/
+/* Tasl Creation (temp solution) */
+/* Should modify task_config.h */
+/************************************/
+void L1AL_Timer_L_HISR( void )
+{
+}
+
+void L1AudioL1_HISR( void )
+{
+}
+
+kal_bool l1spl1_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct l1spl1_handler_info =
+ {
+ NULL, /* task entry function */
+ NULL, /* task initialization function */
+ NULL, /* task reset handler */
+ };
+
+ *handle = (comptask_handler_struct *)&l1spl1_handler_info;
+
+ return KAL_TRUE;
+}
+
+
+/************************************/
+/* Audio Manager */
+/************************************/
+
+void L1Audio_Dummy( void )
+{
+}
+
+/*void L1Audio_ResetDevice(void)
+{
+}*/
+
+//Fix build error with mcu\l1core\modem\tl1\tl1sim\tl1sim_dummy.c
+#if !((!defined(__MT6291PLUS_FIX__ERROR_)) && defined(__L1_STANDALONE__))
+void SP3G_UpdateL1AInFo( kal_uint8 bitmap, kal_uint8 value )
+{
+ (void) bitmap;
+ (void) value;
+}
+#endif //#if !((!defined(__MT6291PLUS_FIX__ERROR_)) && defined(__L1_STANDALONE__))
+
+/*void L1SP_Set_DAI_Mode( kal_uint8 mode )
+{
+ //this feature is phased out
+ (void) mode;
+}*/
+
+void L1SP_TCH_Notify_L( kal_bool bOn )
+{
+ (void) bOn;
+}
+
+kal_bool AM_IsSpeechOn_L( void )
+{
+ return KAL_FALSE;
+}
+
+kal_bool AM_AudioManager( kal_bool handover, kal_uint16 speech_mode, kal_int8 sub_channel )
+{
+ (void) handover;
+ (void) speech_mode;
+ (void) sub_channel;
+
+ return KAL_FALSE;
+}
+
+void l1sp_register_backup()
+{
+}
+
+void l1sp_register_backup_notify()
+{
+}
+
+void l1sp_register_restore()
+{
+}
+
+
diff --git a/mcu/driver/audio/src/v1/PcmMixer2.c b/mcu/driver/audio/src/v1/PcmMixer2.c
new file mode 100644
index 0000000..0b67ff5
--- /dev/null
+++ b/mcu/driver/audio/src/v1/PcmMixer2.c
@@ -0,0 +1,326 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * PcmMixer2.c
+ *
+ * Project:
+ * --------
+ *
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "sync_data.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "event_info_utility.h" // for MODEM_WARNING_MESSAGE
+
+
+#include "am.h"
+//#include "speech_def.h"
+#include "afe_def.h" // for output device setting
+#include "sp_drv.h"
+
+#include "pcmMixer.h"
+#include "sal_exp.h"
+
+/************************** Constants ***************************************/
+#define PCMMIXER_BUF_SIZE 960 // using in 16 bit, FB
+
+typedef enum {
+ PCMMIXER_STATE_IDLE = 0,
+ PCMMIXER_STATE_RUN,
+ PCMMIXER_STATE_CLOSING,
+}PCMMIXER_STATE_TYPE;
+
+/*********** Structure *******************************************************/
+
+typedef struct{
+
+ PCMMIXER_STATE_TYPE state;
+ kal_spinlockid lockId;
+
+ kal_bool ulmix;
+ kal_bool dlmix;
+
+ void (*hisrHandler)(void);
+
+ kal_uint16 aud_id;
+
+ kal_uint16 ULGain;
+ kal_uint16 DLGain;
+
+}PcmMixer_T;
+
+/*********** variable ********************************************************/
+
+static PcmMixer_T gPcmMixer;
+
+static kal_uint16 pcmMixerBuf[PCMMIXER_BUF_SIZE];
+
+/*********** internal fucntion **********************************************/
+
+
+
+void pcmMixerHisr( void *pram )
+{
+ volatile uint16* toBuf;
+ uint32 toBufLen;
+ uint16 i;
+
+ if (KAL_SPINLOCK_NOT_AVAILABLE == kal_take_spinlock(gPcmMixer.lockId, KAL_NO_WAIT)) {
+ MD_TRC_VM_HISR_LOCK_NOT_AVALIABLE(1);
+ goto leaveHisr;
+ }
+ // handle extra notify and closing state
+ if (PCMMIXER_STATE_RUN != gPcmMixer.state)
+ goto leaveProc;
+
+ if(!SAL_Mixer2_IsRunning())
+ goto leaveProc;;
+
+ // gain and setting update
+ SAL_Mixer2_Config(gPcmMixer.ULGain, gPcmMixer.DLGain, gPcmMixer.ulmix, gPcmMixer.dlmix);
+
+ // write data
+ toBuf = SAL_Mixer2_GetBuf_DL();
+ toBufLen = SAL_Mixer2_GetDataLen_DL();
+ for(i=0; i<toBufLen; i++) {
+ toBuf[i] = pcmMixerBuf[i];
+ }
+ Data_Sync_Barrier();
+
+
+leaveProc:
+ kal_give_spinlock(gPcmMixer.lockId);
+
+ if( gPcmMixer.hisrHandler != NULL) {
+ gPcmMixer.hisrHandler();
+ }
+
+leaveHisr:
+ return;
+}
+
+
+/*===========================================================================*/
+uint16 PcmMixer_QueryDlBufLen(void)
+{
+ return (uint16) (SAL_Mixer2_GetDataLen_DL());
+}
+
+/**
+ @srcBuf:
+ @len: length of sample
+*/
+void PcmMixer_writeDlBuf(uint16 *srcBuf, uint16 len)
+{
+ if(len <= PCMMIXER_BUF_SIZE) {
+ kal_take_spinlock(gPcmMixer.lockId, KAL_INFINITE_WAIT);
+ kal_mem_cpy(pcmMixerBuf, srcBuf, len*sizeof(int16));
+ kal_give_spinlock(gPcmMixer.lockId);
+ }
+}
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer_ConfigUl(kal_bool isMix, kal_int8 gain )
+{
+ MD_TRC_MIXER2_CONFIG_UL(isMix, gain);
+
+ if(gain<0) {
+ gain=0;
+ } else if (gain >7) {
+ gain=7;
+ }
+
+ if( gain == 0 )
+ gPcmMixer.ULGain = 0;
+ else {
+ gPcmMixer.ULGain = (kal_int16)(32767 >> (7 - gain));
+ }
+ gPcmMixer.ulmix= isMix;
+}
+
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer_ConfigDl(kal_bool isMix, kal_int8 gain )
+{
+ MD_TRC_MIXER2_CONFIG_DL(isMix, gain);
+
+ if(gain<0) {
+ gain=0;
+ } else if (gain >7) {
+ gain=7;
+ }
+
+ if( gain == 0 )
+ gPcmMixer.DLGain = 0;
+ else {
+ gPcmMixer.DLGain = (kal_int16)(32767 >> (7 - gain));
+ }
+ gPcmMixer.dlmix= isMix;
+}
+
+
+/**
+
+ The function starts the background sound playback of the media handle.
+
+ @bgSnd_hdlr: handler
+*/
+void PcmMixer_Start(void (*mixerHisrHandler)(void))
+{
+ if(PCMMIXER_STATE_RUN == gPcmMixer.state) {
+ return;
+ }
+
+ MD_TRC_MIXER2_START();
+
+ gPcmMixer.state = PCMMIXER_STATE_IDLE;
+ memset(pcmMixerBuf, 0, sizeof(kal_uint16)*PCMMIXER_BUF_SIZE);
+ gPcmMixer.hisrHandler = mixerHisrHandler;
+
+ L1Audio_SetFlag(gPcmMixer.aud_id);
+
+ // update config to dsp
+ SAL_Mixer2_Config(gPcmMixer.ULGain, gPcmMixer.DLGain, gPcmMixer.ulmix, gPcmMixer.dlmix);
+
+ // turn on.
+ // AM_SND_PlaybackOn(); TODO:
+ SAL_Mixer2_SetInit();
+ {
+ uint32 I;
+ for( I = 0; I < 20; I++ ) {
+ if(SAL_Mixer2_IsRunning()) {
+ gPcmMixer.state = PCMMIXER_STATE_RUN;
+ break;
+ }
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ MODEM_WARNING_MESSAGE(I < 20, "PcmMixer_Start: fail to wait DSP runing");
+ }
+
+
+}
+
+/*
+ * Description
+ * ---------
+ * The function stops the background sound playback of the media handle.
+ *
+ * Syntax
+ * ---------
+ * void PcmMixerStop();
+ *
+ * where
+ * hdl The media handle
+ *
+ * Return Value
+ * ---------
+ * None
+ */
+void PcmMixer_Stop(void)
+{
+ uint32 I;
+
+ if(PCMMIXER_STATE_RUN != gPcmMixer.state) {
+ L1Audio_ClearFlag(gPcmMixer.aud_id);
+ return;
+ }
+
+ // change the state before start closing
+ kal_take_spinlock(gPcmMixer.lockId, KAL_INFINITE_WAIT);
+ gPcmMixer.state= PCMMIXER_STATE_CLOSING;
+ kal_give_spinlock(gPcmMixer.lockId);
+
+ if(SAL_Mixer2_IsRunning())
+ SAL_Mixer2_SetFinal();
+ for ( I = 0; I < 20; I++ ) {
+ if ( SAL_Mixer2_IsIdle()) /* DSP returns to idle state */
+ break;
+
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ if(I>=20) {
+ DEBUG_ASSERT(0);
+ MODEM_WARNING_MESSAGE(0, "PcmMixer_Stop: fail to stop DSP mixer2 function");
+ }
+
+ // TODO:
+ // AM_SND_PlaybackOff( true );
+ gPcmMixer.state = PCMMIXER_STATE_IDLE;
+
+ L1Audio_ClearFlag(gPcmMixer.aud_id);
+}
+
+
+void PcmMixer_Init(void)
+{
+ gPcmMixer.lockId = kal_create_spinlock("pcmMixerLock");
+ gPcmMixer.aud_id = L1Audio_GetAudioID();
+ L1Audio_HookHisrHandler(DP_D2C_MIXER2_DL_ID, pcmMixerHisr, 0);
+}
+
+
diff --git a/mcu/driver/audio/src/v1/PcmMixer3.c b/mcu/driver/audio/src/v1/PcmMixer3.c
new file mode 100644
index 0000000..33abf5c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/PcmMixer3.c
@@ -0,0 +1,312 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * PcmMixer3.c
+ *
+ * Project:
+ * --------
+ *
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "sync_data.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "event_info_utility.h" // for MODEM_WARNING_MESSAGE
+
+
+#include "am.h"
+#include "afe_def.h" // for output device setting
+#include "sp_drv.h"
+
+#include "pcmMixer3.h"
+#include "sal_exp.h"
+
+/************************** Constants ***************************************/
+#define PCMMIXER3_BUF_SIZE 640 // using in 16 bit, SWB
+
+typedef enum {
+ PCMMIXER3_STATE_IDLE = 0,
+ PCMMIXER3_STATE_RUN,
+ PCMMIXER3_STATE_CLOSING,
+}PCMMIXER3_STATE_TYPE;
+
+/*********** Structure *******************************************************/
+
+typedef struct{
+
+ PCMMIXER3_STATE_TYPE state;
+ kal_spinlockid lockId;
+
+ kal_bool ulmix;
+ kal_bool dlmix;
+
+ void (*hisrHandler)(void);
+
+ kal_uint16 aud_id;
+
+ kal_uint16 ULGain;
+ //kal_uint16 DLGain;
+
+}PcmMixer3_T;
+
+/*********** variable ********************************************************/
+
+static PcmMixer3_T gPcmMixer3;
+
+static kal_uint16 pcmMixer3Buf[PCMMIXER3_BUF_SIZE];
+static kal_uint16 pcmMixer3Buf_len;
+/*********** internal fucntion **********************************************/
+
+void pcmMixer3Hisr( void *pram )
+{
+ volatile uint16* toBuf;
+ uint16 i;
+
+ if (KAL_SPINLOCK_NOT_AVAILABLE == kal_take_spinlock(gPcmMixer3.lockId, KAL_NO_WAIT)) {
+ MD_TRC_VM_HISR_LOCK_NOT_AVALIABLE(1);
+ goto leaveHisr;
+ }
+ // handle extra notify and closing state
+ if (PCMMIXER3_STATE_RUN != gPcmMixer3.state)
+ goto leaveProc;
+
+ if(!SAL_Mixer3_IsRunning())
+ goto leaveProc;;
+
+ // gain and setting update
+ SAL_Mixer3_Config(gPcmMixer3.ULGain, gPcmMixer3.ulmix);
+ MD_TRC_MIXER3_INFO(gPcmMixer3.ULGain, gPcmMixer3.ulmix);
+ // write data
+ toBuf = SAL_Mixer3_GetBuf();
+ SAL_Mixer3_SetDataLen(pcmMixer3Buf_len);
+
+
+ for(i=0; i<pcmMixer3Buf_len; i++) {
+ toBuf[i] = pcmMixer3Buf[i];
+ }
+ Data_Sync_Barrier();
+
+
+leaveProc:
+ kal_give_spinlock(gPcmMixer3.lockId);
+
+ if( gPcmMixer3.hisrHandler != NULL) {
+ gPcmMixer3.hisrHandler();
+ }
+
+leaveHisr:
+ return;
+}
+
+
+/*===========================================================================*/
+uint16 PcmMixer3_QueryUlBufLen(void)
+{
+ return (uint16) (PCMMIXER3_BUF_SIZE);
+}
+
+/**
+ @srcBuf:
+ @len: length of sample
+*/
+void PcmMixer3_writeUlBuf(uint16 *srcBuf, uint16 len)
+{
+ if(len <= PCMMIXER3_BUF_SIZE) {
+ kal_take_spinlock(gPcmMixer3.lockId, KAL_INFINITE_WAIT);
+ kal_mem_cpy(pcmMixer3Buf, srcBuf, len*sizeof(int16));
+ pcmMixer3Buf_len = len;
+ MD_TRC_MIXER3_DATA_LENGTH(len);
+ if(0 == pcmMixer3Buf_len) {
+ pcmMixer3Buf_len = PCMMIXER3_BUF_SIZE;
+ memset(pcmMixer3Buf, 0, sizeof(kal_uint16)*PCMMIXER3_BUF_SIZE);
+ }
+ kal_give_spinlock(gPcmMixer3.lockId);
+ }
+}
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer3_ConfigUl(kal_bool isMix, kal_int8 gain )
+{
+ MD_TRC_MIXER3_CONFIG_UL(isMix, gain);
+
+ if(gain<0) {
+ gain=0;
+ } else if (gain >7) {
+ gain=7;
+ }
+
+ if( gain == 0 )
+ gPcmMixer3.ULGain = 0;
+ else {
+ gPcmMixer3.ULGain = (kal_int16)(32767 >> (7 - gain));
+ }
+ gPcmMixer3.ulmix= isMix;
+}
+
+
+/**
+
+ The function starts the background sound playback of the media handle.
+
+ @bgSnd_hdlr: handler
+*/
+void PcmMixer3_Start(void (*mixerHisrHandler)(void))
+{
+ if(PCMMIXER3_STATE_RUN == gPcmMixer3.state) {
+ return;
+ }
+
+ MD_TRC_MIXER3_START();
+
+ gPcmMixer3.state = PCMMIXER3_STATE_IDLE;
+ memset(pcmMixer3Buf, 0, sizeof(kal_uint16)*PCMMIXER3_BUF_SIZE);
+ gPcmMixer3.hisrHandler = mixerHisrHandler;
+
+ L1Audio_SetFlag(gPcmMixer3.aud_id);
+
+ // update config to dsp
+ SAL_Mixer3_Config(gPcmMixer3.ULGain, gPcmMixer3.ulmix);
+
+ // turn on.
+ // AM_SND_PlaybackOn(); TODO:
+ SAL_Mixer3_SetInit();
+ {
+ uint32 I;
+ for( I = 0; I < 20; I++ ) {
+ if(SAL_Mixer3_IsRunning()) {
+ gPcmMixer3.state = PCMMIXER3_STATE_RUN;
+ break;
+ }
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ MODEM_WARNING_MESSAGE(I < 20, "PcmMixer3_Start: fail to wait DSP runing");
+ }
+
+
+}
+
+/*
+ * Description
+ * ---------
+ * The function stops the background sound playback of the media handle.
+ *
+ * Syntax
+ * ---------
+ * void PcmMixerStop();
+ *
+ * where
+ * hdl The media handle
+ *
+ * Return Value
+ * ---------
+ * None
+ */
+void PcmMixer3_Stop(void)
+{
+ uint32 I;
+
+ if(PCMMIXER3_STATE_RUN != gPcmMixer3.state) {
+ L1Audio_ClearFlag(gPcmMixer3.aud_id);
+ return;
+ }
+
+ // change the state before start closing
+ kal_take_spinlock(gPcmMixer3.lockId, KAL_INFINITE_WAIT);
+ gPcmMixer3.state= PCMMIXER3_STATE_CLOSING;
+ kal_give_spinlock(gPcmMixer3.lockId);
+
+ if(SAL_Mixer3_IsRunning())
+ SAL_Mixer3_SetFinal();
+ for ( I = 0; I < 20; I++ ) {
+ if ( SAL_Mixer3_IsIdle()) /* DSP returns to idle state */
+ break;
+
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ if(I>=20) {
+ DEBUG_ASSERT(0);
+ MODEM_WARNING_MESSAGE(0, "PcmMixer3_Stop: fail to stop DSP mixer2 function");
+ }
+
+ // TODO:
+ // AM_SND_PlaybackOff( true );
+ gPcmMixer3.state = PCMMIXER3_STATE_IDLE;
+
+ L1Audio_ClearFlag(gPcmMixer3.aud_id);
+}
+
+
+void PcmMixer3_Init(void)
+{
+ gPcmMixer3.lockId = kal_create_spinlock("pcmMixerLock");
+ gPcmMixer3.aud_id = L1Audio_GetAudioID();
+ L1Audio_HookHisrHandler(DP_D2C_MIXER3_UL_ID, pcmMixer3Hisr, 0);
+}
+
+
diff --git a/mcu/driver/audio/src/v1/VoLTETone.c b/mcu/driver/audio/src/v1/VoLTETone.c
new file mode 100644
index 0000000..3b97e99
--- /dev/null
+++ b/mcu/driver/audio/src/v1/VoLTETone.c
@@ -0,0 +1,309 @@
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+
+#include "l1audio.h"
+#include "drv_sap.h"
+#include "speech_def.h"
+#include "bgSnd.h"
+//#include "afe_def.h" // for output device setting
+//#include "sp_drv.h"
+
+
+
+#include "audio_msgid.h"
+#include "sp_drv.h"
+
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+typedef struct{
+ uint32 id;
+ bool is_used;
+}VOLTE_TONE_T;
+VOLTE_TONE_T volte_tone;
+
+extern kal_spinlockid MCUTONESpinLockID;
+
+extern void DTMF_MCU_DataRequestCallback();
+extern void DTMF_MCU_GetReadBuffer(kal_int16 **pBuf_16b, kal_uint32 *uDataWord);
+extern kal_bool DTMF_MCU_IsPlaying();
+extern void DTMF_MCU_ReadDataDone(kal_uint32 uDataWord);
+extern void EXT_BGSND_Hisr(BGSND_PROCESS_TYPE type);
+
+
+
+uint32 VolteToneGetID()
+{
+ return(volte_tone.id);
+}
+
+void VolteToneSetID(uint32 u32val)
+{
+ volte_tone.id = u32val;
+}
+
+bool VolteToneGetUsed()
+{
+ return(volte_tone.is_used);
+}
+
+void VolteToneSetUsed(bool bval)
+{
+ volte_tone.is_used = bval;
+}
+
+void SP4G_PSR_Tone_init()
+{
+
+}
+//tone
+void SP4G_PSR_DL_Tone_Play(const L1SP_Tones *pToneList)
+{
+ ilm_PSR_DL_TONE_t *local_para;
+
+ MD_TRC_SP4G_PSR_DL_TONE_PLAY_ENTER();
+
+ //TONE_Play(pToneList, DSP_TONE);
+ local_para = (ilm_PSR_DL_TONE_t *) construct_local_para( sizeof(ilm_PSR_DL_TONE_t), TD_CTRL/*TD_RESET*/ );
+ local_para->pToneList = (L1SP_Tones *)pToneList;
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_PLAY, (local_para_struct *)local_para, NULL);
+
+ MD_TRC_SP4G_PSR_DL_TONE_PLAY_LEAVE();
+}
+
+void SP4G_PSR_DL_Tone_Stop( void )
+{
+ MD_TRC_SP4G_PSR_DL_TONE_STOP_ENTER();
+ //TONE_Stop(DSP_TONE);
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_STOP, NULL, NULL);
+ MD_TRC_SP4G_PSR_DL_TONE_STOP_LEAVE();
+}
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+void volte_Tone_bgSnd_closeHandler(void);//BGSND HISR to MED ToDO
+void volte_BGSND_ULHdr(void);
+//TONE
+void SP4G_PSR_UL_Tone_Play(const L1SP_Tones *pToneList )
+{
+ ilm_PSR_DL_TONE_t *local_para;
+
+ MD_TRC_SP4G_PSR_UL_TONE_PLAY_ENTER();
+ /*if( !volte_tone.is_used ){
+ TONE_Play(pToneList, MCU_TONE);
+ volte_tone.id = EXT_BGSND_Start(volte_Tone_bgSnd_closeHandler, NULL, volte_BGSND_ULHdr, 7, 7);
+ volte_tone.is_used = true;
+ }else{
+ MD_TRC_SP4G_PSR_UL_TONE_PLAY_SKIP();
+ }*/
+ local_para = (ilm_PSR_DL_TONE_t *) construct_local_para( sizeof(ilm_PSR_DL_TONE_t), TD_CTRL/*TD_RESET*/ );
+ local_para->pToneList = (L1SP_Tones *)pToneList;
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_UL_TONE_PLAY, (local_para_struct *)local_para, NULL);
+
+ MD_TRC_SP4G_PSR_UL_TONE_PLAY_LEAVE();
+}
+
+void SP4G_PSR_UL_Tone_Stop( void )
+{
+ MD_TRC_SP4G_PSR_UL_TONE_STOP_ENTER();
+ /*if( volte_tone.is_used ){
+ EXT_BGSND_Flush(volte_tone.id);
+ TONE_Stop(MCU_TONE);
+ }else{
+ MD_TRC_SP4G_PSR_UL_TONE_STOP_SKIP();
+ }*/
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_UL_TONE_STOP, NULL, NULL);
+ MD_TRC_SP4G_PSR_UL_TONE_STOP_LEAVE();
+}
+
+void volte_Tone_bgSnd_closeHandler(void)//BGSND HISR to MED ToDO
+{
+ MD_TRC_VOLTE_BGSND_CLOSEHANDLER_ENTER();
+ ASSERT( volte_tone.is_used );
+ msg_send4(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_TONE_BGSND_CLOSE);
+ MD_TRC_VOLTE_BGSND_CLOSEHANDLER_LEAVE();
+}
+
+void volte_Tone_BgSndClose(void)//trigger by MED
+{
+ MD_TRC_VOLTE_BGSNDCLOSE_LEAVE();
+ ASSERT( volte_tone.is_used );
+ EXT_BGSND_Close(volte_tone.id);
+ volte_tone.is_used = false;
+ MD_TRC_VOLTE_BGSNDCLOSE_LEAVE();
+}
+
+//#############################################
+//KT
+void volte_KT_bgSnd_closeHandler(void);//BGSND HISR to MED ToDO
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/afe_common.c b/mcu/driver/audio/src/v1/afe_common.c
new file mode 100644
index 0000000..ba1b996
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afe_common.c
@@ -0,0 +1,242 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe2.c
+ *
+ * Project:
+ * --------
+ * Maui_sw
+ *
+ * Description:
+ * ------------
+ * Audio Front End
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: 1.20 $
+ * $Modtime: Aug 15 2005 14:00:06 $
+ * $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/l1audio/afe2.c-arc $
+ *
+ * 12 05 2019 sheila.chen
+ * [MOLY00462454] [Gen97][VMOLY]BusyLooping coding style improvement
+ * use yield instead of busy loop
+ *
+ * 05 14 2017 ys.hsieh
+ * [MOLY00249046] [MT6763]add speech hw dvt audio command patch
+ *
+ * Bianco DVT for audiocommand
+ *
+ * 03 01 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * clean marked code.
+ * refator the gain control (BT)
+ * fix bug: the debug info size should be 16.
+ * common parameter default value location change
+ *
+ * 02 24 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove backup and restore function in AFE.
+ *
+ * 02 24 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * rewrite digital gain control.
+ *
+ * 02 13 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove afe setrefresh and related code.
+ * remove mute speaker which is only using in audio path
+ *
+ * 02 13 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove unused toneLoopback
+ *
+ * 02 06 2017 thomas.chen
+ * [MOLY00227776] [Bianco Bring-up] 93 Bringup modification
+ * .
+ *
+ * 01 26 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * revise afe driver.
+ *
+ * 01 26 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * revise afe driver.
+ *
+ * 11 09 2016 thomas.chen
+ * [MOLY00212357] 93 SpeechDriver Checkin
+ * .
+ *
+ * 10 27 2016 fu-shing.ju
+ * [MOLY00206327] SWB Speech Dev
+ * SWB speech driver.
+ *
+ * 05 10 2012 jy.huang
+ * removed!
+ * .
+ *
+ * Rev 1.0 Dec 31 2004 11:29:16 BM
+ * Initial revision.
+ *
+ *******************************************************************************/
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| INCLUDE FILES
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+#include "afe.h"
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Global Variables
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+AFE_STRUCT_T afe;
+AFE_RG_STRUCT_T afeRG;
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Internal Utility Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/* ========================================================================= */
+/* AFE Event Handler */
+/* This function runs under the context of L1Audio Task */
+/* ========================================================================= */
+
+
+void AFE_Init_status(kal_bool flag)
+{
+ afe.afe_init = flag;
+}
+
+//=============================================================================================
+// AFE Init
+//=============================================================================================
+/*****************************************************************************
+* FUNCTION
+* AFE_Init
+* DESCRIPTION
+* This function is to initialize the AFE module.
+*
+* PARAMETERS
+* None
+* RETURNS
+* None
+* CALLER
+* L1Audio_Task, L1Audio_ResetDevice
+* GLOBALS AFFECTED
+* None
+*****************************************************************************/
+void AFE_Init( void )
+{
+ static kal_bool afe_initialized = KAL_FALSE;
+
+ afe.loopback = KAL_FALSE;
+
+ if (KAL_FALSE == afe_initialized) {
+ afe_initialized = KAL_TRUE;
+ }
+
+ afe.voice8kMode = 2; // 32k mode
+ AFE_Chip_Init();
+
+ afe.afe_init = true;
+
+}
+
+void AFE_DELAY(uint16 delay)
+{
+ ust_us_busyloop(delay);
+}
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Digital/Analog Gain Related
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+/*
+void AFE_DigitalOnly_GetOutputVolume(kal_uint8 aud_func, kal_uint8 *vol)
+{
+ *vol = 0x1000; // fix value for non speech path
+ // *vol = afe.aud[aud_func].digitOnly_digital_gain;
+}
+*/
+
+
+//=============================================================================================
+// Section: [AFE Feature] ABB Registers Backup/Store
+//=============================================================================================
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+void AFE_SetConn0(kal_uint32 val){
+ afeRG.afe_conn0 = val;
+ *AFE_CONN0 = afeRG.afe_conn0;
+ kal_prompt_trace(MOD_L1SP, "[AFE_SetConn0] afeRG.afe_conn0 = %d", afeRG.afe_conn0);
+}
+
diff --git a/mcu/driver/audio/src/v1/afes/afe_6295M.c b/mcu/driver/audio/src/v1/afes/afe_6295M.c
new file mode 100644
index 0000000..6045d3c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6295M.c
@@ -0,0 +1,372 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6295M) || defined(__MD95__)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && (defined(MT6295M) || defined(__MD95__))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && (defined(MT6295M) || defined(__MD95__))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif
diff --git a/mcu/driver/audio/src/v1/afes/afe_6297.c b/mcu/driver/audio/src/v1/afes/afe_6297.c
new file mode 100644
index 0000000..a23c424
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6297.c
@@ -0,0 +1,380 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__MD97__)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(MT6297)
+ *AFE_CONN0 = 0x54327610;
+#else //#if defined(MT6297)
+#if defined(__MODEM_ONLY__)
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+#endif //#if defined(MT6297)
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if ( defined( __CENTRALIZED_SLEEP_MANAGER__ )&& defined( MTK_SLEEP_ENABLE ))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if ( defined( __CENTRALIZED_SLEEP_MANAGER__ )&& defined( MTK_SLEEP_ENABLE ))
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif
diff --git a/mcu/driver/audio/src/v1/afes/afe_6298.c b/mcu/driver/audio/src/v1/afes/afe_6298.c
new file mode 100644
index 0000000..aef7505
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6298.c
@@ -0,0 +1,351 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MERCURY)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__)
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6885)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6739.c b/mcu/driver/audio/src/v1/afes/afe_6739.c
new file mode 100644
index 0000000..c76c429
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6739.c
@@ -0,0 +1,368 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6763) || defined(MT6739)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && ( defined(MT6763)|| defined(MT6739))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && ( defined(MT6763) || defined(MT6739))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6593)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6761.c b/mcu/driver/audio/src/v1/afes/afe_6761.c
new file mode 100644
index 0000000..a37d164
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6761.c
@@ -0,0 +1,368 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6761)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && (defined(MT6761))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && (define(MT6761))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6593)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6763.c b/mcu/driver/audio/src/v1/afes/afe_6763.c
new file mode 100644
index 0000000..c76c429
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6763.c
@@ -0,0 +1,368 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6763) || defined(MT6739)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && ( defined(MT6763)|| defined(MT6739))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && ( defined(MT6763) || defined(MT6739))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6593)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6765.c b/mcu/driver/audio/src/v1/afes/afe_6765.c
new file mode 100644
index 0000000..cb660e7
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6765.c
@@ -0,0 +1,368 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6765)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && ( defined(MT6763)|| defined(MT6739) || defined(MT6765))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && ( defined(MT6763) || defined(MT6739)|| defined(MT6765))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6765)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6771.c b/mcu/driver/audio/src/v1/afes/afe_6771.c
new file mode 100644
index 0000000..f3ae0f3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6771.c
@@ -0,0 +1,368 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6771)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__) && (defined(MT6771))
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && (define(MT6771))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6593)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6779.c b/mcu/driver/audio/src/v1/afes/afe_6779.c
new file mode 100644
index 0000000..bf323d5
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6779.c
@@ -0,0 +1,376 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(MT6779)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__)
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__) && ( defined(MT6763) || defined(MT6739) || defined(MT6779))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if defined(__MODEM_ONLY__) && defined(ELBRUS)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif //#if defined(MT6593)
diff --git a/mcu/driver/audio/src/v1/afes/afe_6885.c b/mcu/driver/audio/src/v1/afes/afe_6885.c
new file mode 100644
index 0000000..d644b73
--- /dev/null
+++ b/mcu/driver/audio/src/v1/afes/afe_6885.c
@@ -0,0 +1,369 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_6291.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * TK6291 chip dependent afe driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__MD97__)
+
+#include "afe.h"
+#include "sync_data.h"
+
+//=============================================================================================
+// AFE Loop back
+//=============================================================================================
+
+/// Caller: Task
+void AFE_TurnOnLoopback( void )
+{
+ *AFE_PCM_CON0 |= 0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_TRUE;
+ MD_TRC_AFE_SWITCH_LOOPBACK('+');
+}
+
+void AFE_TurnOffLoopback( void )
+{
+ *AFE_PCM_CON0 &= ~0x20000000;
+ Data_Sync_Barrier();
+ afe.loopback = KAL_FALSE;
+
+ MD_TRC_AFE_SWITCH_LOOPBACK('-');
+}
+
+//=============================================================================================
+// Audio/8K Clock Related
+//=============================================================================================
+
+void AFE_TurnOn8K( void )
+{
+#ifdef L1D_TEST
+ extern int PollLoopbackMode(void);
+ if( PollLoopbackMode() !=1 )
+#endif
+ {
+
+ // turn on clock gate
+ *USIP_CLK_ENABLE = 0x4;
+ Data_Sync_Barrier();
+
+ // 0. code in origianl init
+ // *AFE_VMCU_CON = 0;
+ // *AFE_VMCU_CON1 = 0;
+ *AFE_AMCU_CON0 = 0;
+ *AFE_AMCU_CON1 = 0;
+ // *AFE_MCU_CON0 = 0;
+ // *AFE_MCU_CON1 = 0x88; // default using 32k mode
+ // *AFE_IRQ_CON1 = 0x05; // default using DSP voice IRQ
+ // *AFE_PCM_CON0 = 0x8400800A; // default using 32k mode, 16 pin
+ // *AFE_CONN0 = 0x54321076;
+
+ // 1. config MDAFE_MCU_CON1, DSP DL/UL data rate
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_MCU_CON1 = 0x00;
+ else if ( afe.voice8kMode == 1 ) // wide bank, 8k mode, 16k sampling rate
+ *AFE_MCU_CON1 = 0x44;
+ else if ( afe.voice8kMode == 3 ) // full bank, 24k mode, 48k sampling rate
+ *AFE_MCU_CON1 = 0xAA;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_MCU_CON1 = 0x88;
+ Data_Sync_Barrier();
+
+ // 2. config MDAFE_VMCU_CON1
+ *AFE_VMCU_CON1 = 0; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 3. config MDAFE_PCM_CON0, not turn on pcm
+ if( afe.voice8kMode == 0 ) // narrow band, 4k mode, 8k sampling rate
+ *AFE_PCM_CON0 = 0x8400000A; // not turn on pcm
+ else if ( afe.voice8kMode == 1 )// wide bank, 8k mode, 16k sampling rate
+ *AFE_PCM_CON0 = 0x8400400A;
+ else if ( afe.voice8kMode == 3 )// full bank, 24k mode, 48k sampling rate
+ *AFE_PCM_CON0 = 0x8400A00A;
+ else //if ( afe.voice8kMode == 2 ) //default, super wide bank, 16k mode, 32k sampling rate
+ *AFE_PCM_CON0 = 0x8400800A;
+ Data_Sync_Barrier();
+
+ // 4. config MDAFE_IRQ_CON1 for irq setting
+ *AFE_IRQ_CON1 = 0x05; // Fix value, may set it on init
+ Data_Sync_Barrier();
+
+ // 5. config MDAFE_CONN0 for inteconnection
+#if defined(__MODEM_ONLY__)
+ // For ELBRUS, MD-AFE loopback
+ // MD: DL ( dsp_dl_data_ch0 / i06 ) --> UL( dsp_ul_data_ch0 / o02 )
+ // AP: UL ( pcmrx_d0 / i00 ) --> DL ( pcmrx_d0 / o00)
+ *AFE_CONN0 = 0x54327610;
+#else
+ *AFE_CONN0 = 0x54321076; // Fix value, may set it on init
+ *AFE_CONN0 = afeRG.afe_conn0;
+#endif
+
+ Data_Sync_Barrier();
+
+ // 6. config MDAFE_VMCU_CON0 = 0x00000001 to open Voice IRQ
+ *AFE_VMCU_CON = 0x1;
+ Data_Sync_Barrier();
+
+ // 7. config MDAFE_MCU_CON0 = 0x00000001 to open whole AFE
+ *AFE_MCU_CON0 = 0x1;
+ Data_Sync_Barrier();
+
+ // 8. config MDAFE_PCM_CON0 = MDAFE_PCM_CON0 | 0x00000001 open PCM interface
+ *AFE_PCM_CON0 |= 0x1;
+ Data_Sync_Barrier();
+
+ // AFE_SetRefVol(KAL_TRUE);
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(1), AFE_Switch_Name(0) );
+ }
+}
+
+
+void AFE_TurnOff8K( void )
+{
+
+ // i. close PCM interface
+ *AFE_PCM_CON0 &= ~0x1;
+ Data_Sync_Barrier();
+
+ AFE_DELAY(135);
+
+ // ii.close 8k IRQ
+ *AFE_VMCU_CON = 0x0;
+ Data_Sync_Barrier();
+
+ // iii. close whole AFE
+ *AFE_MCU_CON0 = 0;
+ Data_Sync_Barrier();
+
+ *USIP_CLK_DISABLE = 0x4;
+ Data_Sync_Barrier();
+
+ ////L1Audio_Msg_AFE_Switch( L1AUDIO_Str_onoff(0), AFE_Switch_Name(0) );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if __RELOAD_HW_COEFF__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Chip Specific AFE Init
+//=============================================================================================
+void AFE_Chip_Init( void )
+{
+ AFE_SetConn0(0x54321076);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined( MTK_SLEEP_ENABLE )
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| AFE Feature or Chip Sepcific Functions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+/**
+ @return: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+kal_uint8 AFE_GetVoice8KMode(void)
+{
+ return afe.voice8kMode;
+}
+
+
+/**
+ @mode: 0 == narrow band, 4k mode; 1 == wide band, 8k mode; 2 == extra wide band, 16k mode;
+*/
+void AFE_SetVoice8KMode(kal_uint8 mode)
+{
+ afe.voice8kMode = mode;
+}
+
+#endif
diff --git a/mcu/driver/audio/src/v1/am.c b/mcu/driver/audio/src/v1/am.c
new file mode 100644
index 0000000..54c096a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/am.c
@@ -0,0 +1,3826 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * am.c
+ *
+ * Project:
+ * --------
+ * Maui
+ *
+ * Description:
+ * ------------
+ * Audio Manager(AM) for Audio Mode Changes
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c#10
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c#11
+ * removed!
+ * removed!
+ * removed!
+ *
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c#9
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c#10
+<<<<
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/am.c
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+<<<<
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *******************************************************************************/
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "reg_base.h"
+#include "md2g_drv.h"
+#include "string.h"
+#include "sync_data.h"
+
+#include "media.h"
+#include "l1audio_trace_utmd.h"
+#include "audio_ringbuf.h" // "audio_def.h"
+#include "l1audio.h"
+#include "afe.h"
+#include "ddload.h"
+#include "am.h"
+#include "l1aud_common_def.h"
+#include "speech_def.h"
+#include "afe_def.h"
+
+#include "sp_daca.h"
+#include "pcm4way.h"
+#include "sp_enhance.h"
+
+#include "sal_def.h"
+#include "sal_exp.h"
+#include "sp_cc.h"
+#include "extcodec.h"
+
+#include "us_timer.h"
+#include "DVFS_drv_md_public.h"
+
+#include "sp_drv.h"
+#include "spc_drv.h"
+#include "sp_dsptone_drv.h"
+#include "sp_ps.h"
+
+//#define TK6291_FAKE_COMPILE
+
+
+#define AM_2G_RESYNC_THRESHOLD 1083
+/* ========================================================================= */
+
+/* ========================================================================= */
+#define AM_STATE_KEYTONE (1<<L1SP_KEYTONE )
+#define AM_STATE_TONE (1<<L1SP_TONE )
+#define AM_STATE_SPEECH (1<<L1SP_SPEECH )
+#define AM_STATE_VOIP (1<<(L1SP_MAX_AUDIO+0) )
+#define AM_STATE_VOICE (1<<L1SP_VOICE )
+// #define AM_STATE_DAI (1<<L1SP_DAI )
+// #define AM_STATE_AUDIO (1<<L1SP_AUDIO )
+#define AM_STATE_SND_EFFECT (1<<L1SP_SND_EFFECT)
+// #define AM_STATE_AvBT (1 << (L1SP_MAX_AUDIO + 1))
+// #define AM_STATE_AVSYNC (1 << (L1SP_MAX_AUDIO + 2))
+#define AM_STATE_DACA (1 << (L1SP_MAX_AUDIO + 3))
+
+#define AM_CONFLICT_STATE (AM_STATE_SPEECH + AM_STATE_VOIP + AM_STATE_VOICE ) // + AM_STATE_AUDIO) // no audio state exist
+
+/*======== Speech State : record features in dedicated-mode speech ========= */
+#define SP_STATE_VMR (1 << 0)
+#define SP_STATE_PCM8K_REC (1 << 1)
+#define SP_STATE_PCMNWAY (1 << 2)
+#define SP_STATE_DACA (1 << 3)
+#define SP_STATE_VMR_EPL (1 << 4) // VM record with EPL
+
+/*======== VoIP State ======================================= */
+#define VOIP_STATE_VMR (1 << 0)
+
+#define VOIP_STATE_REC_ONLY_CAL (1 << 1)
+#define VOIP_STATE_REC_PLAY_CAL (1 << 2)
+
+
+/*============= DSP&AFE IO types ============================ */
+#define NORMAL_MODE 0
+// #define DAI_MODE 1
+// #define BT_CORDLESS_MODE 2
+#define BT_EARPHONE_MODE 3
+// #define PCM_MODE 4
+
+/*============= low byte flags of *DP_AUDIO_PAR ============================ */
+// #define VOICE_INPUT_FILTER_FLAG 0x1
+// #define VOICE_OUTPUT_FILTER_FLAG 0x2
+// #define VOICE_WB_AMR_FLAG 0x8
+// #define VOICE_16K_SWITCH_FLAG 0x10
+// #define VOICE_MIC_MUTE_FLAG 0x20
+// #define VOICE_SIDETONE_FILTER_FLAG 0
+
+
+/* ========================================================================= */
+
+/* To work around the bug of DSP when handover in short time,
+ Do not set handover flag to DSP, but VBI_Reset and other setting remain */
+#define NOT_HANDOVER_IN_SHORT_TIME
+
+#define VBI_Reset() { ASSERT(0); }
+#define VBI_End() { ASSERT(0); }
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_DSP_TurnOffC2KSDSP(uint32 data , uint32 extraInfo);
+#endif
+/* =========== Block Filter Switch Between old/New Usage===================== */
+volatile kal_uint16 *g_Compen_Blk_Flt;
+extern ps_conf_test_mode_enum query_ps_conf_test_mode(void);
+typedef struct {
+ void (*code)(uint32, uint32);
+ uint32 data;
+ uint32 data2;
+} AM_QFunction;
+#define RAMP_QUEUE_SIZE 8
+typedef struct {
+ uint16 RampPoint;
+ bool MuteState;
+} RampStatus;
+
+static struct {
+#if defined( NOT_HANDOVER_IN_SHORT_TIME )
+ uint32 l1FN_HO;
+#endif
+ uint16 state;
+ uint16 pre_speech_mode;
+ uint8 is_reset_enh;
+ uint16 speech_mode;
+ uint16 ul_speech_mode; //behavior is the same as 3/4G
+ // int16 speech_off_delay;
+ int8 sub_channel;
+ int8 ul_sub_channel; //behavior is the same as 3/4G
+
+ // uint16 audioDigitalGain;
+ uint16 speechDigitalGain;
+ uint16 speechUplinkSwAgcGain;
+ uint16 speechDlEnhRefDigtalGain;
+
+ // uint16 bt_digital_gain; // temporary value for keeping origial dl volume in other mode
+ // uint16 bt_mic_gain; // temporary value for keeping origial up volume in other mode
+ // uint16 bt_dlEnhRef_digital_gain; // temporary value for keeping origial dl enhancement reference volum in the other mode
+
+
+ RINGBUFFER_T(AM_QFunction,8) qfunc;
+#if __SP3G_PLATFORM__
+ RINGBUFFER_T(AM_QFunction,8) qfunc2; // modem-unrelated
+#endif
+
+ uint8 speech_state;
+ // uint8 voip_state;
+ uint8 io_type;
+
+ // bool fLoopBack;
+ // kal_bool pre_isWBLink;
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ bool isFirCoeffSet;
+ bool isIirCoeffSet;
+ int16 in_coeff_tmp[90];
+ int16 out_coeff_tmp[90];
+ int16 IIR_in_coeff_tmp[42];
+ int16 IIR_out_coeff_tmp[42];
+ int16 MIC1_IIR_coeff_tmp[20];
+ int16 MIC2_IIR_coeff_tmp[20];
+ int16 wb_in_coeff_tmp[90];
+ int16 wb_out_coeff_tmp[90];
+ int16 wb_IIR_in_coeff_tmp[42];
+ int16 wb_IIR_out_coeff_tmp[42];
+ int16 wb_MIC1_IIR_coeff_tmp[20];
+ int16 wb_MIC2_IIR_coeff_tmp[20];
+ int16 swb_in_coeff_tmp[90];
+ int16 swb_out_coeff_tmp[90];
+ int16 swb_IIR_in_coeff_tmp[42];
+ int16 swb_IIR_out_coeff_tmp[42];
+ int16 swb_MIC1_IIR_coeff_tmp[20];
+ int16 swb_MIC2_IIR_coeff_tmp[20];
+#endif
+ // bool toneLoopbackRec;
+ bool sp3g_flag;
+
+
+ RINGBUFFER_T(RampStatus, RAMP_QUEUE_SIZE) ramp_point_queue;
+#if defined(__C2K_SPEECH_SUPPORT__)
+ bool spc2k_flag;
+ bool c2k_flag;
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ bool sp4g_flag;
+ int codec_4g;
+#endif
+
+ AM_RECORD_FORMAT record_format;
+ bool dsp_2g_reset;
+} am;
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+#if defined(__VOLTE_SUPPORT__)
+#define IsWBLink(speech_codec) ((SP4G_CODEC_G722 == speech_codec ) || ((speech_codec >= 0x20) && (speech_codec <= 0x28)) || (SPH_CODEC_C2K_SO73WB == speech_codec))
+#else
+#define IsWBLink(speech_codec) (((speech_codec) >= 0x20) || (SPH_CODEC_C2K_SO73WB == (speech_codec)))
+#endif
+#else
+#if defined(__VOLTE_SUPPORT__)
+#define IsWBLink(speech_codec) ((SP4G_CODEC_G722 == speech_codec ) || ((speech_codec >= 0x20) && (speech_codec <= 0x28)))
+#else
+#define IsWBLink(speech_codec) ((speech_codec) >= 0x20)
+#endif
+#endif
+
+
+
+
+/* --------------------------------------------------------------------------*/
+void SP4G_Call_Close(void);
+void SP4G_Call_Open(uint16 codec, PS_RESET_TYPE_t resetType);
+kal_uint32 SP4G_GetCodecMode(void);
+bool is_EVS_codec(uint8 codec);
+bool is_g_codec(uint8 codec);
+int get_sp4g_fake_EVS_IO(void);
+
+static void AM_ReloadDSPCoefficient( void );
+
+
+static void AM_Enqueue( void (*code)(uint32, uint32), uint32 data, uint32 data2, bool isCritical )
+{
+ /* For 65nm process, MCU has to reload DSP coefficient at each wake-up */
+ if (am.state == 0){
+ AM_ReloadDSPCoefficient();
+ }
+
+ code( data , data2 );
+}
+
+
+
+const signed short Sph_Mic1_IIR_In[20] =
+{
+-7815, 16002, 7900, -15800, 7900, -8033, 16219, 8192,-16384, 8192, /* UL SWB HP-IIR-137Hz (20ms task)*/
+ 0, 0, 8192, 0, 0, 0, 0, 8192, 0, 0 /* not used */
+};
+const signed short Sph_Mic2_IIR_In[20] =
+{
+-7972, 16162, 8000, -16000, 8000, -8095, 16285, 8192,-16384, 8192, /* UL SWB HP-IIR-75Hz (20ms task)*/
+ 0, 0, 8192, 0, 0, 0, 0, 8192, 0, 0 /*not used*/
+};
+const signed short Speech_All_Pass_IIR_Coeff[42] =
+{ /* All pass filter */
+ 0x14, 0x400, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0
+};
+const int16 Speech_All_Pass_FIR_Coeff[45] =
+ { /* All pass filter */
+ 32767, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0
+ };
+
+
+
+
+
+
+const uint16 DSP_PCM_IDLE_DELAY_M_VOLTE = (6*8)+(16<<10)+(2<<8);
+
+
+/* Note: The speech pattern length for amr-wb can be calculated from
+lenSpeechBitsAMR_WB in amr_table.h; therefore, remove them out.
+Those for amr might be removed if vm.c does not handle amr any more. */
+static const uint8 SpeechPatternLength[] = {
+ (uint8)((260 + 15) / 16), /* FR */
+ (uint8)((112 + 15) / 16), /* HR */
+ (uint8)((244 + 15) / 16), /* EFR */
+ (uint8)((244 + 15) / 16), /* AMR 12.2K */
+ (uint8)((204 + 15) / 16), /* AMR 10.2K */
+ (uint8)((159 + 15) / 16), /* AMR 7.95K */
+ (uint8)((148 + 15) / 16), /* AMR 7.4K */
+ (uint8)((134 + 15) / 16), /* AMR 6.7K */
+ (uint8)((118 + 15) / 16), /* AMR 5.9K */
+ (uint8)((103 + 15) / 16), /* AMR 5.15K */
+ (uint8)(( 95 + 15) / 16), /* AMR 4.75K */
+
+ (uint8)((132 + 15) / 16), /* AMR-WB 6.60 */
+ (uint8)((177 + 15) / 16), /* AMR-WB 8.85 */
+ (uint8)((253 + 15) / 16), /* AMR-WB 12.65 */
+ (uint8)((285 + 15) / 16), /* AMR-WB 14.25 */
+ (uint8)((317 + 15) / 16), /* AMR-WB 15.85 */
+ (uint8)((365 + 15) / 16), /* AMR-WB 18.25 */
+ (uint8)((397 + 15) / 16), /* AMR-WB 19.85 */
+ (uint8)((461 + 15) / 16), /* AMR-WB 23.05 */
+ (uint8)((477 + 15) / 16), /* AMR-WB 23.85 */
+
+ (uint8)(1), /* QCELP8K (Not supported)*/ //return 1 to prevent vm codec length check
+ (uint8)(17), /* QCELP13K */
+ (uint8)(11), /* EVRCA */
+ (uint8)(11), /* EVRCB */
+
+ (uint8)(9+2), /* EVS_AWB660 */
+ (uint8)(12+2), /* EVS_AWB885 */
+ (uint8)(16+2), /* EVS_AWB1265 */
+ (uint8)(18+2), /* EVS_AWB1425 */
+ (uint8)(20+2), /* EVS_AWB1585 */
+ (uint8)(23+2), /* EVS_AWB1825 */
+ (uint8)(25+2), /* EVS_AWB1985 */
+ (uint8)(29+2), /* EVS_AWB2305 */
+ (uint8)(30+2), /* EVS_AWB2385 */
+ (uint8)(10+2), /* EVS_PRI590 */
+ (uint8)(9+2), /* EVS_PRI720 */
+ (uint8)(10+2), /* EVS_PRI800 */
+ (uint8)(12+2), /* EVS_PRI960 */
+ (uint8)(17+2), /* EVS_PRI1320 */
+ (uint8)(21+2), /* EVS_PRI1640 */
+ (uint8)(31+2), /* EVS_PRI2440 */
+ (uint8)(40+2), /* EVS_PRI3200 */
+ (uint8)(60+2), /* EVS_PRI4800 */
+ (uint8)(80+2), /* EVS_PRI6400 */
+ (uint8)(120+2), /* EVS_PRI9600 */
+ (uint8)(160+2) /* EVS_PRI12800 */
+};
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+uint16 AM_GetSpeechPatternLength( uint8 speech_mode )
+{
+ if((speech_mode >= 11) && (speech_mode <= 31)) //EVS
+ {
+ speech_mode = speech_mode - 11 + 24;
+ }
+ else if( speech_mode >= 0x30) // c2k related
+ speech_mode = speech_mode - 0x30 + 0x14;
+ else if( speech_mode >= 0x20 )
+ speech_mode = speech_mode - 0x20 + 0x0B;
+ if( speech_mode<(sizeof(SpeechPatternLength)/sizeof(SpeechPatternLength[0])))
+ return (uint16)SpeechPatternLength[speech_mode];
+ else
+ return 1; //return 1 to prevent vm codec length check
+}
+//Need to add new pattern for MT6280
+
+static const uint16 SpeechSilencePattern[][31] = {
+ { 0x4820,0xD617,0x0284,0x2480,0x9249,0x8924,0x8002,0x4924, /* FR */
+ 0x2492,0x0289,0x2480,0x9249,0x8924,0x8002,0x4924,0x2492,
+ 0x0009 },
+ { 0x4E20,0x875E,0x5473,0x8482,0x00E9,0x0000,0x0000 }, /* HR */
+ { 0x7A10,0x092D,0xB55F,0x7C06,0x185C,0xDE06,0x4230,0x0103, /* EFR */
+ 0xA012,0x001A,0x0000,0x0000,0x0D6C,0x0000,0x0000,0x0000 },
+ { 0x00e2,0x5dfc,0xf095,0xcd4e,0x24da,0x0e04,0xf0fb,0x4f2e, /* AMR12.2 */
+ 0x4430,0x9fa8,0x0319,0x56c0,0xc144,0x0278,0x70ea,0x0004 },
+ { 0xe00a,0xf2e7,0x516b,0x19a1,0xc10d,0x145a,0x4c96,0x25e0, /* AMR10.2 */
+ 0x5ce6,0x17b9,0x0982,0x225d,0x00c4 },
+ { 0x033c,0xe5cd,0xd9fb,0x387f,0x420c,0x8c99,0x58d7,0x1156, /* AMR7.95 */
+ 0x397f,0x1074 },
+ { 0xe00a,0xf2e7,0x9ac5,0x4433,0x185b,0x3e05,0xdc64,0xc886, /* AMR7.4 */
+ 0xcd2e,0x0000 },
+ { 0xe00a,0xf2e7,0x7761,0x0486,0x0dd5,0xf47c,0x21b0,0xf547, /* AMR6.7 */
+ 0x0002 },
+ { 0xe00a,0xf2e7,0xb196,0xa8ae,0xbcb7,0x6fb9,0x0193,0x002e }, /* AMR5.9 */
+ { 0x3c0a,0x7e51,0x652c,0x5e91,0xd023,0xea5a,0x005b }, /* AMR5.15 */
+ { 0x3c0a,0x3e51,0x6529,0x3a49,0x977f,0x3565 }, /* AMR4.75 */
+ { 0x1480,0x02ee,0xd706,0x09f4,0x4e01,0x2ada,0x59ef,0x2a20,0x0001 }, /* AMR-WB 6.60 */
+ { 0x1290,0x0460,0x78f1,0xae42,0x2330,0x98c8,0x0120,0x57f8,0xa4b5,0xa681,0x25a0,0x0000 }, /* AMR-WB 8.85 */
+ { 0x1290,0x0460,0x78f1,0x4142,0xc702,0x3f49,0xd446,0x7295,0x55c0,0x1028,0x7159,0xe315,0x96cf,0x8328,0x06a7,0x1f2c }, /* AMR-WB 12.65 */
+ { 0x1290,0x0460,0x78f1,0x1542,0x8839,0x8c07,0x462d,0x59f4,0x3069,0x55c3,0x6028,0xa539,0x1724,0x2ebb,0xa182,0x92da,0xd156,0x1e06 }, /* AMR-WB 14.25 */
+ { 0x1290,0x0460,0x78f1,0x1542,0x00b8,0xc095,0x381e,0xf446,0x6959,0x6870,0x5f5c,0xe028,0xb886,0x2724,0xcbb3,0x820b,0xcaa0,0x5692,0x6053,0x1c05 }, /* AMR-WB 15.85 */
+ { 0x1290,0x0460,0x78f1,0xff42,0x0604,0xd0c8,0x8460,0x63e0,0x7b44,0xce75,0x3c14,0xea27,0x285d,0xf790,0x13eb,0xec97,0x5f93,0x28bb,0x2648,0x3b81,0x2de6,0x1529,0x1529 }, /* AMR-WB 18.25 */
+ { 0x1290,0x0460,0x78f1,0x3942,0xf104,0x2b51,0x40cb,0xd864,0xc463,0x75ce,0x5d7d,0x3c8f,0xfa23,0x285d,0xd690,0xfa27,0xc515,0x93ea,0xbb5f,0x1e28,0xc5ea,0xfa2f,0x2c8c,0x45d8,0x1529 }, /* AMR-WB 19.85 */
+ { 0x1290,0x0460,0x78f1,0x1742,0x2098,0xaa41,0x4330,0xb286,0xd023,0xc463,0x5ce6,0x6e55,0xe3d7,0x14ef,0xb10f,0x2017,0xf1e0,0xf68f,0x8735,0x1c66,0x5b22,0x3765,0xc86c,0xdb41,0x84d3,0x522a,0x8696,0xc4b6,0x1c2a }, /* AMR-WB 23.05 */
+ { 0x1290,0x0460,0x78f1,0x1742,0x2098,0xaa41,0x4330,0xb286,0xd023,0x4f63,0xce6c,0x0555,0x5926,0x4c7e,0x1af1,0xc5df,0xe01e,0x2daf,0xdc74,0x56be,0xe4c0,0xf38a,0xa07a,0x5585,0x41fb,0x784d,0x932d,0x4798,0x914b,0x0f52 } /* AMR-WB 27.85 */
+};
+
+void AM_Reset_Enh(uint32 codec)
+{
+ kal_bool preIsSWB;
+ kal_bool afterIsSWB;
+
+ //Set_Reset_Enh_Status(false);
+ if( (SP4G_CODEC_EVS_32K_005_9 <= codec) && (SP4G_CODEC_EVS_32K_128_0 >= codec) ){
+ afterIsSWB = true;
+ }else{
+ afterIsSWB = false;
+ }
+
+ if( (SP4G_CODEC_EVS_32K_005_9 <= am.pre_speech_mode) && (SP4G_CODEC_EVS_32K_128_0 >= am.pre_speech_mode) ){
+ preIsSWB = true;
+ }else{
+ preIsSWB = false;
+ }
+ kal_prompt_trace(MOD_L1SP, "AM_Reset_Enh,preIsSWB=%x,afterIsSWB=%x,codec=%x,am.pre_speech_mode=%x", preIsSWB,afterIsSWB,codec,am.pre_speech_mode);
+ if(preIsSWB != afterIsSWB ){
+ //SetSpeechEnhancement(false);
+ //SetSpeechEnhancement(true);
+ Set_Reset_Enh_Status(true);
+ }
+ am.pre_speech_mode = codec;
+}
+
+void Set_Reset_Enh_Status(uint8 status)
+{
+ am.is_reset_enh = status;
+}
+
+
+uint8 Get_Reset_Enh_Status(void)
+{
+ return am.is_reset_enh;
+}
+
+void AM_FillSilencePattern( volatile uint16 *addr, uint16 info, uint16 speech_mode )
+{
+#ifndef L1D_TEST
+ const uint16 *pat_info;
+ uint32 I, len;
+ if( speech_mode >= 0x20 )
+ speech_mode = speech_mode - 0x20 + 0x0B;
+
+ if( speech_mode >= (sizeof(SpeechPatternLength)/sizeof(SpeechPatternLength[0])) )
+ return;
+
+ pat_info = SpeechSilencePattern[speech_mode];
+ len = (uint16)SpeechPatternLength[speech_mode];
+
+ *addr++ = info;
+ for( I = 0; I < len; I++ )
+ *addr++ = *pat_info++;
+
+ Data_Sync_Barrier();
+#endif
+}
+
+void AM_FillSilencePatternInBuffer( uint16 *buffer, uint16 speech_mode )
+{
+#ifndef L1D_TEST
+ const uint16 *pat_info;
+ uint32 I, len;
+ if( speech_mode >= 0x20 )
+ speech_mode = speech_mode - 0x20 + 0x0B;
+
+ if( speech_mode >= (sizeof(SpeechPatternLength)/sizeof(SpeechPatternLength[0])) )
+ return;
+
+ pat_info = SpeechSilencePattern[speech_mode];
+ len = (uint16)SpeechPatternLength[speech_mode];
+
+ for( I = 0; I < len; I++ )
+ *buffer++ = *pat_info++;
+#endif
+}
+
+/* -------------------------------------------------------------------------- */
+extern uint32 L1I_GetTimeStamp( void );
+
+void AM_SetDSP2GReset(bool v)
+{
+ am.dsp_2g_reset = v;
+}
+
+void AM_Set2GCodecInfo(uint16 speech_mode, int8 sub_channel)//
+{
+ am.ul_speech_mode = speech_mode;
+ am.ul_sub_channel = sub_channel;
+}
+
+void AM_Get2GCodecInfo(uint16 *speech_mode, int8 *sub_channel)//
+{
+ *speech_mode = am.ul_speech_mode;
+ *sub_channel = am.ul_sub_channel;
+}
+
+void AM_FlushQFunction( void )
+{
+#ifndef L1D_TEST
+ while( !RB_EMPTY(am.qfunc) )
+ kal_sleep_task( AUD_1TICK(1) );
+#endif
+}
+
+/* ========================================================================= */
+/* Interface Functions */
+/* ========================================================================= */
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+static void AM_WriteSpeechCompensationFilter( const int16 in_coeff[90], const int16 out_coeff[90] )
+{
+ int i;
+ volatile uint16* dsp_ptr;
+
+ MD_TRC_SPE_DSP_CHECK_NB_FIR_PAR(in_coeff[0],in_coeff[1],out_coeff[0],out_coeff[1]);
+ /* Write audio FIR filter coeficients */
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_NB_UL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_NB; i++ )
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *in_coeff++;
+#else
+/* under construction !*/
+#endif
+
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_NB_DL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_NB; i++ )
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *out_coeff++;
+#else
+/* under construction !*/
+#endif
+
+
+ Data_Sync_Barrier();
+}
+static void AM_WriteSpeechIIRCompensationFilter( const int16 in_coeff[42], const int16 out_coeff[42],const int16 Mic1_coeff[20],const int16 Mic2_coeff[20] )
+{
+ int i;
+ volatile uint16* dsp_ptr;
+ /* Write audio IIR filter coeficients */
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_UL_NB);
+
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *in_coeff++;
+ }
+
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_DL_NB);
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *out_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC1_IIR_COEF_UL_NB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *Mic1_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC2_IIR_COEF_UL_NB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *Mic2_coeff++;
+ }
+ Data_Sync_Barrier();
+
+
+}
+void AM_WriteFirCoeffs( const int16 in_coeff[90], const int16 out_coeff[90] )
+{
+
+
+ memcpy(am.in_coeff_tmp, in_coeff, 90*sizeof(int16));
+ memcpy(am.out_coeff_tmp, out_coeff, 90*sizeof(int16));
+
+
+ am.isFirCoeffSet= true;
+
+ /* Write audio FIR filter coeficients */
+ AM_WriteSpeechCompensationFilter(in_coeff, out_coeff);
+
+
+
+}
+
+void AM_WriteIirCoeffs( const int16 in_coeff[42], const int16 out_coeff[42],const int16 Mic1_coeff[20],const int16 Mic2_coeff[20] )
+{
+ memcpy(am.IIR_in_coeff_tmp, in_coeff, 42*sizeof(int16));
+ memcpy(am.IIR_out_coeff_tmp, out_coeff, 42*sizeof(int16));
+ memcpy(am.MIC1_IIR_coeff_tmp, Mic1_coeff, 20*sizeof(int16));
+ memcpy(am.MIC2_IIR_coeff_tmp, Mic2_coeff, 20*sizeof(int16));
+ am.isIirCoeffSet= true;
+ /* Write audio IIR filter coeficients */
+ AM_WriteSpeechIIRCompensationFilter(in_coeff, out_coeff,Mic1_coeff,Mic2_coeff);
+
+
+
+}
+static void AM_WriteWbSpeechCompensationFilter( const int16 wb_in_coeff[90], const int16 wb_out_coeff[90] )
+{
+ int i;
+ volatile uint16* dsp_ptr;
+ MD_TRC_SPE_DSP_CHECK_WB_FIR_PAR(wb_in_coeff[0],wb_in_coeff[1],wb_out_coeff[0],wb_out_coeff[1]);
+ /* Write audio FIR filter coeficients */
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_WB_UL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_WB; i++ ){
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *wb_in_coeff++;
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ }
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_WB_DL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_WB; i++ ){
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *wb_out_coeff++;
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ }
+
+ Data_Sync_Barrier();
+}
+static void AM_WriteWbSpeechIIRCompensationFilter( const int16 wb_in_coeff[42], const int16 wb_out_coeff[42],const int16 wb_Mic1_coeff[20],const int16 wb_Mic2_coeff[20] )
+{
+ int i;
+ volatile uint16* dsp_ptr;
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_UL_WB);
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *wb_in_coeff++;
+ }
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_DL_WB);
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *wb_out_coeff++;
+ }
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC1_IIR_COEF_UL_WB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *wb_Mic1_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC2_IIR_COEF_UL_WB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *wb_Mic2_coeff++;
+ }
+ Data_Sync_Barrier();
+
+
+
+
+}
+static void AM_WriteSWbSpeechCompensationFilter( const int16 swb_in_coeff[90], const int16 swb_out_coeff[90] )
+{
+ int i;
+ volatile uint16* dsp_ptr;
+ MD_TRC_SPE_DSP_CHECK_SWB_FIR_PAR(swb_in_coeff[0],swb_in_coeff[1],swb_out_coeff[0],swb_out_coeff[1]);
+ /* Write audio FIR filter coeficients */
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_SWB_UL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_SWB; i++ ){
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *swb_in_coeff++;
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ }
+ dsp_ptr = SAL_BKF_GetFltCoefAddr_SWB_DL();
+
+ for( i=0; i<SAL_FLTCOEFLEN_BKF_SWB; i++ ){
+#if 1 // ndef __HQA_AUDIO__
+ *dsp_ptr ++ = *swb_out_coeff++;
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+ Data_Sync_Barrier();
+}
+static void AM_WriteSWbSpeechIIRCompensationFilter( const int16 swb_in_coeff[42], const int16 swb_out_coeff[42],const int16 swb_Mic1_coeff[20],const int16 swb_Mic2_coeff[20] )
+{
+ volatile uint16* dsp_ptr;
+ int i;
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_UL_SWB);
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *swb_in_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_ENH_IIR_COEF_DL_SWB);
+ for( i=0; i<SAL_FLTCOEFLEN_ENH_IIR; i++ )
+ {
+ *dsp_ptr ++ = *swb_out_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC1_IIR_COEF_UL_SWB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *swb_Mic1_coeff++;
+ }
+
+ dsp_ptr = SAL_IIR_Coef_GetBuf(SAL_MIC2_IIR_COEF_UL_SWB);
+ for( i=0; i<SAL_FLTCOEFLEN_MIC_IIR; i++ )
+ {
+ *dsp_ptr ++ = *swb_Mic2_coeff++;
+ }
+ MO_Sync();//Data_Sync_Barrier();
+
+}
+void AM_WriteWbFirCoeffs( const int16 wb_in_coeff[90], const int16 wb_out_coeff[90] )
+{
+
+
+ memcpy(am.wb_in_coeff_tmp, wb_in_coeff, 90*sizeof(int16));
+ memcpy(am.wb_out_coeff_tmp, wb_out_coeff, 90*sizeof(int16));
+
+
+ //write FIR coefiicient when some application is running.
+ // Otherwise, the coefficient will be reloaed under AM_Enqueue()
+ if(am.state !=0) {
+ AM_WriteWbSpeechCompensationFilter(am.wb_in_coeff_tmp, am.wb_out_coeff_tmp);
+ }
+}
+void AM_WriteWbIirCoeffs( const int16 wb_in_coeff[42], const int16 wb_out_coeff[42],const int16 wb_Mic1_coeff[20],const int16 wb_Mic2_coeff[20] )
+{
+// #if __RELOAD_DSP_COEFF__
+ memcpy(am.wb_IIR_in_coeff_tmp, wb_in_coeff, 42*sizeof(int16));
+ memcpy(am.wb_IIR_out_coeff_tmp, wb_out_coeff, 42*sizeof(int16));
+ memcpy(am.wb_MIC1_IIR_coeff_tmp, wb_Mic1_coeff, 20*sizeof(int16));
+ memcpy(am.wb_MIC2_IIR_coeff_tmp, wb_Mic2_coeff, 20*sizeof(int16));
+// #endif
+ if(am.state !=0) {
+ AM_WriteWbSpeechIIRCompensationFilter(am.wb_IIR_in_coeff_tmp, am.wb_IIR_out_coeff_tmp,am.wb_MIC1_IIR_coeff_tmp,am.wb_MIC2_IIR_coeff_tmp);
+ }
+}
+void AM_WriteSWbFirCoeffs( const int16 swb_in_coeff[90], const int16 swb_out_coeff[90] )
+{
+
+
+ memcpy(am.swb_in_coeff_tmp, swb_in_coeff, 90*sizeof(int16));
+ memcpy(am.swb_out_coeff_tmp, swb_out_coeff, 90*sizeof(int16));
+
+
+ //write FIR coefiicient when some application is running.
+ // Otherwise, the coefficient will be reloaed under AM_Enqueue()
+ if(am.state !=0) {
+ AM_WriteSWbSpeechCompensationFilter(am.swb_in_coeff_tmp, am.swb_out_coeff_tmp);
+ }
+}
+void AM_WriteSWbIirCoeffs( const int16 swb_in_coeff[42], const int16 swb_out_coeff[42],const int16 swb_Mic1_coeff[20],const int16 swb_Mic2_coeff[20] )
+{
+
+// #if __RELOAD_DSP_COEFF__
+ memcpy(am.swb_IIR_in_coeff_tmp, swb_in_coeff, 42*sizeof(int16));
+ memcpy(am.swb_IIR_out_coeff_tmp, swb_out_coeff, 42*sizeof(int16));
+ memcpy(am.swb_MIC1_IIR_coeff_tmp, swb_Mic1_coeff, 20*sizeof(int16));
+ memcpy(am.swb_MIC2_IIR_coeff_tmp, swb_Mic2_coeff, 20*sizeof(int16));
+// #endif
+
+ //writeIIR coefiicient when some application is running.
+ // Otherwise, the coefficient will be reloaed under AM_Enqueue()
+ if(am.state !=0) {
+ AM_WriteSWbSpeechIIRCompensationFilter(am.swb_IIR_in_coeff_tmp, am.swb_IIR_out_coeff_tmp,am.swb_MIC1_IIR_coeff_tmp,am.swb_MIC2_IIR_coeff_tmp);
+ }
+}
+#endif
+// SRC coefiicient using in DSP
+const signed short Audio_Flt_Coeff[82] =
+{
+ 0, 96, 162, -92, -488, -302, 408, 372, -660, -780,
+ 782, 1272, -958, -2094, 1088, 3458, -1200, -6426, 1266, 20318,
+ 30834, 20318, 1266, -6426, -1200, 3458, 1088, -2094, -958, 1272,
+ 782, -780, -660, 372, 408, -302, -488, -92, 162, 96,
+ 0, /* SRC Up-Sampling */
+ 0, 0, -36, -175, -262, -51, 277, 146, -376, -317,
+ 489, 595, -597, -1034, 689, 1777, -744, -3351, 727, 10500,
+ 15852, 10500, 727, -3351, -744, 1777, 689, -1034, -597, 595,
+ 489, -317, -376, 146, 277, -51, -262, -175, -36, 0,
+ 0 /* SRC Down-Sampling */
+};
+
+const signed short Sph_SRCPlus_Flt_Coeff[148] =
+{
+ 50, 163, 186, 27, -141, -49, 157, 87, -185, -143, 211,
+218, -233, -313, 243, 431, -239, -573, 214, 743, -160, -945,
+68, 1188, 76,-1486, -297, 1867, 639,-2392,-1199, 3213, 2245,
+-4839,-4904,10502,28344,28344,10502,-4904,-4839, 2245, 3213,-1199,
+-2392, 639, 1867, -297,-1486, 76, 1188, 68, -945, -160, 743,
+214, -573, -239, 431, 243, -313, -233, 218, 211, -143, -185,
+87, 157, -49, -141, 27, 186, 163, 50, /* SRC Up-Sampling */
+ 25, 82, 93, 14, -71, -25, 79, 44, -93, -72, 106,
+ 109, -117, -157, 122, 216, -120, -287, 107, 372, -80, -473,
+ 34, 594, 38, -743, -149, 934, 320, -1196, -600, 1607, 1123,
+ -2420, -2452, 5251, 14172, 14172, 5251, -2452, -2420, 1123, 1607, -600,
+ -1196, 320, 934, -149, -743, 38, 594, 34, -473, -80, 372,
+ 107, -287, -120, 216, 122, -157, -117, 109, 106, -72, -93,
+ 44, 79, -25, -71, 14, 93, 82, 25 /* SRC Down-Sampling */
+
+/* -12, 16, 48, -98, -312, -234, 100, 180, -130, -238, 136, 312, -134, -404, 122, 512, -94, -640,
+ 46, 792, 28, -970, -134, 1188, 286, -1458, -510, 1818, 852, -2336, -1464, 3052, 2446, -4652, -5070, 10232,
+28264, 28264, 10232, -5070, -4652, 2446, 3052, -1464, -2336, 852, 1818, -510, -1458, 286, 1188, -134, -970, 28,
+ 92, 46, -640, -94, 512, 122, -404, -134, 312, 136, -238, -130, 180, 100, -234, -312, -98, 48,
+ 16, -12, 0 // SRC Up-Sampling */
+};
+
+const signed short Sph_SRCPlus_Flt_SWB_Coeff[296] =
+{
+25, 82, 130, 185, 199, 166, 81, -27, -117, -146, -99, 7, 119, 177, 141, 20, -128, -222, -202, -64,
+128, 272, 279, 127, -117, -325, -372, -212, 89, 376, 482, 324, -38, -421, -607, -466, -42, 456, 748, 645,
+158, -475, -907, -867, -323, 471, 1086, 1147, 552, -435, -1291, -1506, -873, 351, 1535, 1986, 1339, -191, -1845, -2678,
+-2063, -106, 2295, 3811, 3351, 711, -3116, -6193, -6400, -2401, 5617, 15802, 25197, 30823, 30823, 25197, 15802, 5617, -2401, -6400,
+-6193, -3116, 711, 3351, 3811, 2295, -106, -2063, -2678, -1845, -191, 1339, 1986, 1535, 351, -873, -1506, -1291, -435, 552,
+1147, 1086, 471, -323, -867, -907, -475, 158, 645, 748, 456, -42, -466, -607, -421, -38, 324, 482, 376, 89,
+-212, -372, -325, -117, 127, 279, 272, 128, -64, -202, -222, -128, 20, 141, 177, 119, 7, -99, -146, -117,
+-27, 81, 166, 199, 185, 130, 82, 25, /* SRC Up-Sampling */
+6, 21, 33, 46, 50, 42, 20, -7, -29, -37, -25, 2, 30, 44, 35, 5, -32, -56, -51, -16,
+32, 68, 70, 32, -29, -81, -93, -53, 22, 94, 121, 81, -10, -105, -152, -117, -11, 114, 187, 161,
+40, -119, -227, -217, -81, 118, 272, 287, 138, -109, -323, -377, -218, 88, 384, 497, 335, -48, -461, -670,
+-516, -27, 574, 953, 838, 178, -779, -1548, -1600, -600, 1404, 3951, 6299, 7706, 7706, 6299, 3951, 1404, -600, -1600,
+-1548, -779, 178, 838, 953, 574, -27, -516, -670, -461, -48, 335, 497, 384, 88, -218, -377, -323, -109, 138,
+287, 272, 118, -81, -217, -227, -119, 40, 161, 187, 114, -11, -117, -152, -105, -10, 81, 121, 94, 22,
+-53, -93, -81, -29, 32, 70, 68, 32, -16, -51, -56, -32, 5, 35, 44, 30, 2, -25, -37, -29,
+-7, 20, 42, 50, 46, 33, 21, 6 /* SRC Down-Sampling */
+};
+
+const signed short Sph_SRC_IIR_Flt_Coeff[12] =
+{
+29909, 35641, 17819, 28766, 5421, 21716, 24199, 32394, 11027, 24904, 10224, 32768
+};
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+signed short Sph_Notch_Filter_Param[SAL_PARAMETERLEN_NOTCH] = {
+ -7708, 15853, 7980, -15929, 7980,
+ -7788, 15937, 8180, -16330, 8180,
+ -7948, 16103, 8190, -16346, 8190
+};
+
+void AM_SetNotchFilterParam(int16 *param)
+{
+ memcpy(Sph_Notch_Filter_Param, param, SAL_PARAMETERLEN_NOTCH*sizeof(int16));
+}
+
+/**
+ This function should used when DSP is turn on
+*/
+void AM_DSP_WriteNotchFilterParam( void )
+{
+ int I;
+ volatile uint16* toPtr = SAL_Notch_GetFltCoefAddr();
+ int16 *fromPtr = Sph_Notch_Filter_Param;
+
+ for( I = SAL_PARAMETERLEN_NOTCH; --I >= 0 ; )
+ *toPtr++ = *fromPtr++;
+
+ Data_Sync_Barrier();
+}
+
+
+
+/* For 65nm process, MCU has to reload DSP coefficient at each wake-up */
+static void AM_ReloadDSPCoefficient( void )
+{
+ // AM_WriteSidetoneFIR(); // 93 not dsp sidetone so remove it
+
+ // if(!am.toneLoopbackRec) lagency
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ AM_WriteSpeechCompensationFilter(am.in_coeff_tmp, am.out_coeff_tmp);
+ AM_WriteSpeechIIRCompensationFilter(am.IIR_in_coeff_tmp, am.IIR_out_coeff_tmp,am.MIC1_IIR_coeff_tmp,am.MIC2_IIR_coeff_tmp);
+ AM_WriteWbSpeechCompensationFilter(am.wb_in_coeff_tmp, am.wb_out_coeff_tmp);
+ AM_WriteWbSpeechIIRCompensationFilter(am.wb_IIR_in_coeff_tmp, am.wb_IIR_out_coeff_tmp,am.wb_MIC1_IIR_coeff_tmp,am.wb_MIC2_IIR_coeff_tmp);
+ AM_WriteSWbSpeechCompensationFilter(am.swb_in_coeff_tmp, am.swb_out_coeff_tmp);
+ AM_WriteWbSpeechIIRCompensationFilter(am.swb_IIR_in_coeff_tmp, am.swb_IIR_out_coeff_tmp,am.swb_MIC1_IIR_coeff_tmp,am.swb_MIC2_IIR_coeff_tmp);
+#endif
+ // AM_WriteAntiAliasFilter();
+ // L1SP_Reload_MagiClarity_Para();
+
+ if ( !(am.state & AM_STATE_SPEECH) )
+ L1SP_Reload_SPE_Para();
+}
+
+
+/* ========================================================================= */
+/* internal function Functions */
+/* ========================================================================= */
+
+/**
+ This function should call "after AFE_Turnoff8K" and "before AFE_TurnOn8K".
+ No user, so phase it out. The AFE_SetVoice8KMode is set directly by AP
+*/
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+// static void AM_DSP_VMRecordOff( uint32 data , uint32 extraInfo);
+
+extern kal_uint32 SP3G_GetCodecMode(void);
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_DSP_TurnOnC2KSDSP(int codec, uint32 extraInfo );
+void AM_TurnOffC2KSDSP(void);
+#endif
+static void AM_DSP_SpeechOn( uint32 rat_mode, uint32 extraInfo )
+{
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(5), L1AUDIO_Str_onoff(1) );
+
+ SAL_UltraSound_Removal_Switch(false);
+ SAL_Set_OpenDsp(L1SP_GetOpenDSPFlag());
+
+ if(rat_mode == RAT_2G_MODE)
+ {
+#if defined(__VOLTE_SUPPORT__)
+ am.sp4g_flag = false;
+#endif
+ am.sp3g_flag = false;
+ if(L1SP_TCH_State()){
+ AM_Get2GCodecInfo(&am.speech_mode, &am.sub_channel);
+ }else{
+ am.speech_mode = 0;
+ am.sub_channel = 0;
+ }
+
+#if defined(__SMART_PHONE_MODEM__)
+ if(spc_isAcLoopback()){
+ if(L1SP_TCH_State() == KAL_FALSE) {
+ cc_Standby_Call_Open(0x3);
+ }
+ else {
+ cc_2G_Call_Open(0, 0, am.sub_channel, ((extraInfo&1)? SAL_SRST_TYPE_DEV: SAL_SRST_TYPE_CALLON));
+ }
+ }
+ else
+#endif // __SMART_PHONE_MODEM__
+ {
+ if(L1SP_TCH_State() == KAL_FALSE) {
+ cc_Standby_Call_Open(0x3);
+ }
+ else {
+ cc_2G_Call_Open(am.speech_mode, am.speech_mode, am.sub_channel,
+ ((extraInfo&1)? SAL_SRST_TYPE_DEV: SAL_SRST_TYPE_CALLON));
+ }
+ }
+
+ }
+
+#if defined( __UMTS_RAT__ )
+ else if(rat_mode == RAT_3G_MODE
+#ifdef __VIDEO_CALL_SUPPORT__
+ || rat_mode == RAT_3G324M_MODE
+#endif
+ ){
+ kal_uint16 delayR, delayW, delayM;
+ kal_uint32 u32CurTime64us;
+
+ am.speech_mode = SP3G_GetCodecMode();
+ am.sp3g_flag = true;
+#if defined(__VOLTE_SUPPORT__)
+ am.sp4g_flag = false;
+#endif
+ // only use Bit[0] to inidicate the resync require
+
+
+ SP3G_GetSyncDelayRW( &delayR, &delayW, &delayM, &u32CurTime64us);
+
+ cc_3G_Call_Open(am.speech_mode, am.speech_mode, SP3G_IsDTXOn(), delayR, delayW, delayM, u32CurTime64us,
+ ((extraInfo&1)? SAL_SRST_TYPE_DEV: SAL_SRST_TYPE_CALLON));
+ }
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ else if(rat_mode == RAT_4G_MODE){
+ am.speech_mode = SP4G_GetCodecMode();
+ am.sp3g_flag = false;
+ am.sp4g_flag = true;
+ //get InitCodec
+ //SAL_4G_Call_Open(am.speech_mode);
+ SP4G_Call_Open(am.speech_mode, ((extraInfo&1)? PS_SRST_TYPE_DEV: PS_SRST_TYPE_CALLON));
+ }
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ else if(rat_mode == RAT_C2K_MODE){
+ am.sp3g_flag = false;
+#if defined(__VOLTE_SUPPORT__)
+ am.sp4g_flag = false;
+#endif
+ am.spc2k_flag = true;
+ AM_DSP_TurnOnC2KSDSP(L1SP_GetC2KSO_Codec(), (extraInfo&1)? SAL_SRST_TYPE_DEV: SAL_SRST_TYPE_CALLON);
+ }
+#endif
+ am.state |= AM_STATE_SPEECH;
+ am.pre_speech_mode = am.speech_mode;
+
+ l1sp_NetworkStatusNotification();
+ RB_INIT(am.ramp_point_queue);
+}
+
+uint32 AM_GetNetworkRate()
+{
+ switch(L1SP_GetState()){
+ case L1SP_STATE_2G_SPEECH_ON:
+ return RAT_2G_MODE;
+#if defined( __UMTS_RAT__ )
+ case L1SP_STATE_3G_SPEECH_ON:
+ case L1SP_STATE_3G_SPEECH_CLOSING:
+ return RAT_3G_MODE;
+#ifdef __VIDEO_CALL_SUPPORT__
+ case L1SP_STATE_3G324M_SPEECH_ON:
+ return RAT_3G324M_MODE;
+#endif
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ case L1SP_STATE_4G_SPEECH_ON:
+ case L1SP_STATE_4G_SPEECH_CLOSING:
+ return RAT_4G_MODE;
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ case L1SP_STATE_C2K_SPEECH_ON:
+ return RAT_C2K_MODE;
+#endif
+ default:
+ return RAT_NONE_MODE;
+ }
+}
+
+/**
+ @rat_mode: indicat the 2g/3g call status
+ @extraInfo: bit[0]: 1 for device change to resync
+*/
+void AM_SpeechOn(uint32 rat_mode, uint32 extraInfo)
+{
+ MD_TRC_L1Audio_Msg_AM_Speech(1);
+ AFE_TurnOn8K();//SAL user need to handle this for DSP Speech
+
+ AM_Enqueue( AM_DSP_SpeechOn, rat_mode, extraInfo, (rat_mode == RAT_2G_MODE) && L1SP_TCH_State() );
+
+ if(rat_mode == RAT_2G_MODE)
+ AM_FlushQFunction();
+}
+
+
+static void AM_DSP_SpeechOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(5), L1AUDIO_Str_onoff(0) );
+ // am.speech_off_delay = 10;
+ //fix BIANCO
+ //DP_KT_ATT = 0x0; // avoid SD buffer repeating if tone/keytone continues
+
+ Data_Sync_Barrier();
+// cc_set_VBI_for_FSM(1);
+ /*
+ if( am.speech_state & SP_STATE_VMR ) // call drop while conversation recording
+ AM_DSP_VMRecordOff( 0 , 0 );
+ */
+
+ am.state &= ~AM_STATE_SPEECH;
+
+#if defined(__VOLTE_SUPPORT__)
+ if(am.sp4g_flag){
+ SP4G_Call_Close();
+ am.sp4g_flag = false;
+ }else
+#endif
+#if defined( __UMTS_RAT__ )
+ if( am.sp3g_flag ){
+ cc_3G_Call_Close(true);
+
+ am.sp3g_flag = false;
+ }
+ else
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( am.spc2k_flag ){
+
+ AM_TurnOffC2KSDSP();
+
+ am.spc2k_flag = false;
+ } else
+#endif
+ cc_2G_Call_Close(true );
+ //am.speech_mode = SAL_C2K_COD_MODE_UNDEF;
+
+
+// cc_set_VBI_for_FSM(2);
+}
+
+
+/**
+ @info: bit[0]: need to force dsp8k off or not; 1 for force, 0 for not
+*/
+void AM_SpeechOff( uint32 info )
+{
+ SP_DSPTone_ForceEnd();
+
+ // if((info == 0)|| ((info&1)!=0))
+ cc_set_VBI_for_FSM(1);
+
+ MD_TRC_L1Audio_Msg_AM_Speech(0);
+ AM_Enqueue( AM_DSP_SpeechOff, info, 0, false );
+
+ AM_FlushQFunction();
+
+ // if((info == 0)|| ((info&1)!=0))
+ cc_set_VBI_for_FSM(2);
+
+ if( (am.state == 0) || ((info&1)!=0))
+ AFE_TurnOff8K();
+}
+
+bool AM_IsSpeechOn( void )
+{
+ return( (bool)((am.state & AM_STATE_SPEECH) != 0) );
+}
+
+bool AM_IsDataCardOn( void )
+{
+ return( (bool)((am.speech_state &= SP_STATE_DACA) != 0) );
+}
+
+bool AM_IsAmInSpeechState( void )
+{
+ if ((am.state & (AM_STATE_SPEECH | AM_STATE_VOICE | AM_STATE_VOIP )) != 0)
+ return true;
+ else
+ return false;
+}
+
+void AM_SetSpeechMode( uint16 speech_mode, int8 sub_channel )
+{
+ am.speech_mode = speech_mode;
+ am.sub_channel = sub_channel;
+}
+
+uint16 AM_GetSpeechMode(void)
+{
+ return am.speech_mode;
+}
+
+kal_bool AM_IsSpeechWB( void )
+{
+ return IsWBLink(am.speech_mode);
+}
+
+#if defined( __UMTS_RAT__ )
+/**
+ extraInfo: come from rate
+*/
+void AM_DSP_RAT_sub_2G( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ if(L1SP_TCH_State()){
+ AM_Get2GCodecInfo(&am.speech_mode, &am.sub_channel);
+ }else{
+ am.speech_mode = 0;
+ am.sub_channel = 0;
+ }
+ if( !(am.state & AM_STATE_SPEECH) )
+ return;
+ //VBI_End(); //When DSP in NB-AMR, driver set SC,SD mode as WB-AMR, and DSP will assert, and vice versa
+ if(extraInfo == SAL_APP_TYPE_2GCall){
+ cc_2G_Call_Close(true);
+ }
+ else if(extraInfo == SAL_APP_TYPE_3GCall){
+ cc_3G_Call_Close(true);
+ am.sp3g_flag = false;
+ }
+#if defined(__C2K_SPEECH_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_C2KCall){
+ AM_DSP_TurnOffC2KSDSP(0, 0);
+ }
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_4GCall){
+ SP4G_Call_Close();
+ am.sp4g_flag = false;
+ }
+#endif
+ cc_2G_Call_Open(am.speech_mode, am.speech_mode, am.sub_channel, SAL_SRST_TYPE_HO);
+ AM_Reset_Enh(am.speech_mode);
+ l1sp_NetworkStatusNotification();
+ // l1sp_CodecStatusNotification(am.speech_mode);
+}
+
+void AM_DSP_InterRAT_3G_to_2G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_2G(0, SAL_APP_TYPE_3GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_3G_TO_2G(am.speech_mode);
+}
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_DSP_InterRAT_C2K_to_2G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_2G(0, SAL_APP_TYPE_C2KCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_C2K_TO_2G(am.speech_mode);
+}
+#endif
+#if defined(__VOLTE_SUPPORT__)
+void AM_DSP_InterRAT_4G_to_2G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_2G(0, SAL_APP_TYPE_4GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_4G_TO_2G(am.speech_mode);
+}
+#endif
+void AM_DSP_InterRAT_Standby_to_2G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_2G(0, SAL_APP_TYPE_2GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_STANDBY_TO_2G(am.speech_mode);
+}
+
+void AM_InterRAT_3G_to_2G()
+{
+ AM_Enqueue( AM_DSP_InterRAT_3G_to_2G, 0, 0, false );
+ AM_FlushQFunction();
+}
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_InterRAT_C2K_to_2G()
+{
+ AM_Enqueue( AM_DSP_InterRAT_C2K_to_2G, 0, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+#if defined(__VOLTE_SUPPORT__)
+void AM_InterRAT_4G_to_2G()
+{
+ AM_Enqueue( AM_DSP_InterRAT_4G_to_2G, 0, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+void AM_InterRAT_Standby_to_2G()
+{
+ AM_Enqueue( AM_DSP_InterRAT_Standby_to_2G, 0, 0, false );
+ AM_FlushQFunction();
+}
+
+void AM_DSP_RAT_sub_3G(uint32 codec , uint32 extraInfo)
+{
+ kal_uint16 u16DelayR, u16DelayW, u16DelayM;
+ kal_uint32 u32CurTime64us;
+ am.speech_mode = codec;
+ if( !(am.state & AM_STATE_SPEECH) )
+ return;
+ if(extraInfo == SAL_APP_TYPE_2GCall){
+ cc_2G_Call_Close(true);
+ }else if(extraInfo == SAL_APP_TYPE_3GCall){
+ cc_3G_Call_Close(true);
+ }
+#if defined(__C2K_SPEECH_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_C2KCall){
+ AM_DSP_TurnOffC2KSDSP(0, 0);
+ }
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_4GCall){
+ SP4G_Call_Close();
+ am.sp4g_flag = false;
+ }
+#endif
+
+ SP3G_GetSyncDelayRW( &u16DelayR, &u16DelayW, &u16DelayM, &u32CurTime64us);
+ SAL_3G_Upd_Enc_Cod(codec);//for 3g codec internal, MT6280
+ SAL_3G_Upd_Dec_Cod(codec);//for 3g codec internal, MT6280
+#if defined(_MODEM_RESYNC_3G_)
+ MD_TRC_L1Audio_Msg_AM_3G_Reset_Time_Drift();
+#if defined( __UMTS_RAT__ )
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+ UL1D_Speech_Resync_Reset_Time_Offset();
+ break;
+#if defined(__UMTS_TDD128_MODE__)
+ case SP_3G_SIM_TDD_ACTIVE:
+ TL1C_Reset_Time_Drift();
+ break;
+#endif
+ default:
+ ASSERT(0);
+ }
+#endif
+#endif
+
+#if defined( __UMTS_RAT__ ) && !defined(__L1_STANDALONE__)
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+ if(query_ps_conf_test_mode()==PS_CONF_TEST_FTA)
+ SP3G_SetDTX(false);
+ else
+ SP3G_SetDTX(true);
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ break;
+ default:
+ ASSERT(0);
+ }
+#endif
+ cc_3G_Call_Open(codec, codec, SP3G_IsDTXOn(), u16DelayR, u16DelayW, u16DelayM, u32CurTime64us, SAL_SRST_TYPE_HO);
+ MD_TRC_L1Audio_Msg_SP3G_FORCE_RESYNC( codec, codec, u16DelayR, u16DelayW);
+ am.sp3g_flag = true;
+ AM_Reset_Enh(codec);
+ l1sp_NetworkStatusNotification();
+ // l1sp_CodecStatusNotification(am.speech_mode);
+}
+
+void AM_DSP_InterRAT_2G_to_3G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_3G(codec, SAL_APP_TYPE_2GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_2G_TO_3G(codec);
+}
+
+void AM_DSP_3G_INTRARAT (uint32 codec, uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_3G(codec, SAL_APP_TYPE_3GCall);
+ MD_TRC_L1Audio_Msg_3G_INTRARAT(codec);
+}
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_DSP_InterRAT_C2K_to_3G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_3G(codec, SAL_APP_TYPE_C2KCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_C2K_TO_3G(codec);
+}
+#endif
+
+#if defined(__VOLTE_SUPPORT__)
+void AM_DSP_InterRAT_4G_to_3G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_3G(codec, SAL_APP_TYPE_4GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_4G_TO_3G(codec);
+}
+#endif
+
+void AM_InterRAT_2G_to_3G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_2G_to_3G, codec, 0, false );
+ AM_FlushQFunction();
+}
+
+void AM_3G_INTRARAT(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_3G_INTRARAT, codec, 0, false );
+ AM_FlushQFunction();
+}
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_InterRAT_C2K_to_3G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_C2K_to_3G, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+
+#if defined(__VOLTE_SUPPORT__)
+void AM_InterRAT_4G_to_3G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_4G_to_3G, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+#endif
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+/*
+ extraInfo: 0:call on; 1: HO; 2: resync; 3: dev Change
+*/
+void AM_DSP_TurnOnC2KSDSP(int codec, uint32 extraInfo ){
+
+ uint16 DelR, DelW, DelM;
+
+ MD_TRC_C2K_AM_DSP_TurnOnC2KSDSP(am.speech_mode, codec);
+
+ SPC2K_GetSyncDelayRW( &DelR, &DelW, &DelM);
+ if((am.speech_mode != codec) && (!am.c2k_flag)) {
+ cc_C2K_Call_Open (codec, _C2K_DTX_SUPPORT_, DelR, DelW, DelM, extraInfo); //VBIRest();
+
+ am.speech_mode = codec;
+ am.c2k_flag = true; // ys
+ }else{
+ cc_C2K_Call_Open (codec, _C2K_DTX_SUPPORT_, DelR, DelW, DelM, extraInfo);//check by daniel//VBIRest();
+ }
+}
+void AM_DSP_TurnOffC2KSDSP(uint32 data , uint32 extraInfo)
+{
+ MD_TRC_C2K_AM_DSP_TurnOffC2KSDSP();
+
+ cc_C2K_Call_Close(true);
+
+ //am.speech_mode = SAL_C2K_COD_MODE_UNDEF;
+ am.c2k_flag = false;
+}
+
+void AM_TurnOffC2KSDSP(void)
+{
+ //TO , move c2kflag here for symmetry
+ AM_Enqueue( AM_DSP_TurnOffC2KSDSP, 0, 0, false );
+ AM_FlushQFunction();
+}
+
+void AM_DSP_RAT_sub_C2K(uint32 codec , uint32 extraInfo)
+{
+ if( !(am.state & AM_STATE_SPEECH) )
+ return;
+ if(extraInfo == SAL_APP_TYPE_2GCall){
+ cc_2G_Call_Close(true);
+ } else if(extraInfo == SAL_APP_TYPE_3GCall){
+ cc_3G_Call_Close(true);
+ am.sp3g_flag = false;
+ }
+#if defined(__VOLTE_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_4GCall){
+ SP4G_Call_Close();
+ am.sp4g_flag = false;
+ }
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_C2KCall){
+ AM_DSP_TurnOffC2KSDSP(0, 0);
+ }
+#endif
+ AM_DSP_TurnOnC2KSDSP(codec, 1);
+ am.spc2k_flag = true;
+ AM_Reset_Enh(codec);
+ l1sp_NetworkStatusNotification();
+}
+
+void AM_DSP_InterRAT_2G_to_C2K( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_C2K(codec, SAL_APP_TYPE_2GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_2G_TO_C2K(codec);
+}
+
+void AM_DSP_C2K_IntraRAT (uint32 codec, uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_C2K(codec, SAL_APP_TYPE_C2KCall);
+ MD_TRC_L1Audio_Msg_C2K_INTRARAT(codec);
+}
+
+#if defined( __UMTS_RAT__ )
+void AM_DSP_InterRAT_3G_to_C2K( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_C2K(codec, SAL_APP_TYPE_3GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_3G_TO_C2K(codec);
+}
+#endif
+#if defined(__VOLTE_SUPPORT__)
+void AM_DSP_InterRAT_4G_to_C2K( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_C2K(codec, SAL_APP_TYPE_4GCall);
+ MD_TRC_L1Audio_Msg_INTERRAT_4G_TO_C2K(codec);
+}
+#endif
+
+void AM_InterRAT_2G_to_C2K(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_2G_to_C2K, codec, 0, false );
+ AM_FlushQFunction();
+}
+
+void AM_C2K_IntraRAT(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_C2K_IntraRAT, codec, 0, false );
+ AM_FlushQFunction();
+}
+#if defined( __UMTS_RAT__ )
+void AM_InterRAT_3G_to_C2K(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_3G_to_C2K, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+#if defined(__VOLTE_SUPPORT__)
+void AM_InterRAT_4G_to_C2K(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_4G_to_C2K, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+#endif
+
+#if defined(__VOLTE_SUPPORT__)
+void AM_DSP_RAT_sub_4G(uint32 codec , uint32 extraInfo, uint32 resetType)
+{
+ //kal_uint16 u16DelayR, u16DelayW; //unused
+ am.speech_mode = codec;
+ if( !(am.state & AM_STATE_SPEECH) )
+ return;
+
+ if(PS_SRST_TYPE_HO_WITH_VBIEND == resetType)
+ {
+ if(extraInfo == SAL_APP_TYPE_2GCall){
+ cc_2G_Call_Close(true);
+ } else if(extraInfo == SAL_APP_TYPE_3GCall){
+ cc_3G_Call_Close(true);
+ am.sp3g_flag = false;
+ }
+#if defined(__C2K_SPEECH_SUPPORT__)
+ else if(extraInfo == SAL_APP_TYPE_C2KCall){
+ AM_DSP_TurnOffC2KSDSP(0, 0);
+ }
+#endif
+ else if(extraInfo == SAL_APP_TYPE_4GCall){
+ SP4G_Call_Close();
+ }
+ }
+
+ //SP3G_GetSyncDelayRW( &u16DelayR, &u16DelayW);//????
+ //SAL_4G_Upd_Enc_Cod(codec);//for 3g codec internal, MT6280
+ //SAL_4G_Upd_Dec_Cod(codec);//for 3g codec internal, MT6280
+ switch(SP4G_GetL2Mode()){
+#if defined(__LTE_RAT__)
+ case SP_PSCALL_EMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_LTE);
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case SP_PSCALL_NMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NR);
+ break;
+#endif
+ case SP_PSCALL_NONE:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NONE);
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ //SAL_4G_Call_Open(codec);
+ SP4G_Call_Open(codec, resetType);
+ AM_Reset_Enh(codec);
+ l1sp_NetworkStatusNotification();
+ // l1sp_CodecStatusNotification(am.speech_mode);
+ am.sp4g_flag = true;
+}
+
+void AM_DSP_InterRAT_2G_to_4G( uint32 codec , uint32 extraInfo)
+{
+ //ASSERT(codec < SP4G_CODEC_G711 || codec > SP4G_CODEC_G729);//context is under task level, so g-series cannot be used
+ AM_DSP_RAT_sub_4G(codec, SAL_APP_TYPE_2GCall, PS_SRST_TYPE_HO_WITH_VBIEND);
+ MD_TRC_L1Audio_Msg_INTERRAT_2G_TO_4G(codec, PS_SRST_TYPE_HO_WITH_VBIEND);
+}
+#if defined( __UMTS_RAT__ )
+void AM_DSP_InterRAT_3G_to_4G( uint32 codec , uint32 extraInfo)
+{
+ //ASSERT(codec < SP4G_CODEC_G711 || codec > SP4G_CODEC_G729);//context is under task level, so g-series cannot be used
+ AM_DSP_RAT_sub_4G(codec, SAL_APP_TYPE_3GCall, PS_SRST_TYPE_HO_WITH_VBIEND);
+ MD_TRC_L1Audio_Msg_INTERRAT_3G_TO_4G(codec, PS_SRST_TYPE_HO_WITH_VBIEND);
+}
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_DSP_InterRAT_C2K_to_4G( uint32 codec , uint32 extraInfo)
+{
+ AM_DSP_RAT_sub_4G(codec, SAL_APP_TYPE_C2KCall, PS_SRST_TYPE_HO_WITH_VBIEND);
+ MD_TRC_L1Audio_Msg_INTERRAT_C2K_TO_4G(codec, PS_SRST_TYPE_HO_WITH_VBIEND);
+}
+#endif
+
+void AM_DSP_4G_INTRARAT (uint32 codec, uint32 resetType)
+{
+ //ASSERT(codec < SP4G_CODEC_G711 || codec > SP4G_CODEC_G729); context is under task level, so g-series can be used
+ AM_DSP_RAT_sub_4G(codec, SAL_APP_TYPE_4GCall, resetType);
+ MD_TRC_L1Audio_Msg_4G_INTRARAT(codec, resetType);
+}
+
+void AM_InterRAT_2G_to_4G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_2G_to_4G, codec, 0, false );
+ AM_FlushQFunction();
+}
+#if defined( __UMTS_RAT__ )
+void AM_InterRAT_3G_to_4G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_3G_to_4G, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+void AM_InterRAT_C2K_to_4G(uint32 codec)
+{
+ AM_Enqueue( AM_DSP_InterRAT_C2K_to_4G, codec, 0, false );
+ AM_FlushQFunction();
+}
+#endif
+void AM_4G_INTRARAT(uint32 codec, uint32 resetType)
+{
+ AM_Enqueue( AM_DSP_4G_INTRARAT, codec, resetType, false );
+ AM_FlushQFunction();
+}
+
+void SAL_4G_AMRCall_Open(int codec, kal_bool isDTX, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void SAL_4G_AMRCall_Close();
+#if defined(__G_CODEC_SUPPORT__)
+void SAL_4G_GSeriesCall_Open(int codec, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void SAL_4G_GSeriesCall_Close(int codec);
+#endif
+#if defined(__EVS_CODEC_SUPPORT__)
+void SAL_4G_EVSCall_Open(int codec, kal_bool isDTX, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void SAL_4G_EVSCall_Close(void);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+void SP4G_Call_Open(uint16 codec, PS_RESET_TYPE_t resetType)
+{
+ kal_uint16 delayR, delayW, delayM;
+ kal_uint32 u32CurTime64us;
+
+ if(PS_SRST_TYPE_HO_WITH_VBIEND == resetType)
+ {
+ ASSERT(am.codec_4g == -1);
+ }
+ SAL_Set_AWBPlusFlag(0);
+ am.codec_4g = codec;
+ SP4G_GetSyncDelayRW( &delayR, &delayW, &delayM, &u32CurTime64us);
+#if defined(__G_CODEC_SUPPORT__)
+ if((codec >= SP4G_CODEC_G711) && (codec <= SP4G_CODEC_G729)){
+ SAL_4G_GSeriesCall_Open(codec, delayR, delayW, delayM, u32CurTime64us, resetType);
+ }else
+#endif
+ {
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(is_EVS_codec((uint8)codec)){
+ if( get_sp4g_fake_EVS_IO() )
+ {
+ SAL_Set_AWBPlusFlag(1);
+ }
+ SAL_4G_EVSCall_Open((kal_uint32)codec, (kal_uint32)SP4G_IsDTXOn(), (kal_uint32)delayR, (kal_uint32)delayW, (kal_uint32)delayM, (kal_uint32)u32CurTime64us, resetType);
+ }else
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ {
+ SAL_4G_AMRCall_Open(codec, SP4G_IsDTXOn(), delayR, delayW, delayM, u32CurTime64us, resetType);
+ }
+ }
+}
+
+void SP4G_Call_Close(void){
+ ASSERT(am.codec_4g != -1);
+ SAL_Set_AWBPlusFlag(0);
+#if defined(__G_CODEC_SUPPORT__)
+ if( is_g_codec(am.codec_4g) ){
+ SAL_4G_GSeriesCall_Close(SAL_PCM_NARROWBAND);
+ }else
+#endif
+ {
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(is_EVS_codec(am.codec_4g)){
+ SAL_4G_EVSCall_Close();
+ }else
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ {
+ SAL_4G_AMRCall_Close();
+ }
+ }
+ am.codec_4g = -1;
+}
+//extern void SAL_Set4G(bool b);
+void SAL_4G_AMRCall_Open(int codec, kal_bool isDTX, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+ //SP4G_GetSyncDelayRW( &u16DelayR, &u16DelayW);
+ SAL_3G_Upd_Enc_Cod(codec);
+ SAL_3G_Upd_Dec_Cod(codec);
+ //cc_3G_Call_Open(codec, codec, SP4G_IsDTXOn(), u16DelayR, u16DelayW, DSP_PCM_IDLE_DELAY_TABLE[6][2]);
+ //SAL_Set4G(true);
+ cc_4G_Call_Open_temp(codec, codec, isDTX, u16DelayR, u16DelayW, idle_delay, u32CurTime64us, resetType);
+ MD_TRC_L1Audio_Msg_SP4G_FORCE_RESYNC( codec, codec, u16DelayR, u16DelayW);
+};
+
+void SAL_4G_AMRCall_Close()
+{
+ cc_4G_Call_Close_temp(true);
+ //SAL_Set4G(false);
+}
+
+
+void SAL_4G_GSeriesCall_Open(int codec, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us,
+ kal_uint32 resetType){
+ int band_mod = SAL_NB;
+ if(SP4G_CODEC_G722 == codec )
+ band_mod = SAL_WB;
+
+ //SAL_Set4G(true);
+ //memset(&cfg, 0, sizeof(Sal_PCMEx_Config_t));
+ //cfg.idle = false;//true;
+ //cfg.swi = SAL_PCMEX_SWITCH_ON;
+ //cfg.type = SAL_PCMEX_TYPE_VOLTE;
+ //cfg.band = band;//SAL_PCM_NARROWBAND
+ //SAL_PcmEx_Config(&cfg);
+
+ /*if(band == SAL_PCM_WIDEBAND)
+ {
+ AMR_codec_temp = SP4G_CODEC_WBAMR_12_65;
+ }
+ else
+ {
+ AMR_codec_temp = SP4G_CODEC_AMR_12_2;
+ }
+ SAL_3G_Upd_Enc_Cod(AMR_codec_temp);
+ SAL_3G_Upd_Dec_Cod(AMR_codec_temp);*/
+ cc_4G_G_Codec_Call_Open(band_mod, u16DelayR, u16DelayW, idle_delay, u32CurTime64us, resetType);
+
+ {
+ void GSeries_Encode_Init(SP4G_Codec codec);
+ void GSeries_Decode_Init(SP4G_Codec codec);
+ GSeries_Encode_Init(codec);
+ GSeries_Decode_Init(codec);
+ //SP4G_SetCodec(codec);//fix
+ }
+ Extcodec_Call_Open();
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /*#if 0*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /*#if 0*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifndef L1D_TEST
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+ kal_prompt_trace(MOD_L1SP, "[SAL_4G_GSeriesCall_Open] SAL_PcmEx_CheckState OK");
+
+
+}
+
+
+void SAL_4G_GSeriesCall_Close(int codec){
+ Extcodec_Call_Close();
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ ////SAL_Set4G(false);
+ {
+ void GSeries_Encode_DeInit();
+ void GSeries_Decode_DeInit();
+ }
+
+ //fsju
+ cc_4G_G_Codec_Call_Close(true);
+}
+
+
+#if defined(__EVS_CODEC_SUPPORT__)
+void SP4G_EVS_CallOpenSetPar(void);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+void SAL_4G_EVSCall_Open(int codec, kal_bool isDTX, kal_uint16 u16DelayR, kal_uint16 u16DelayW, const uint16 idle_delay, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ SP4G_EVS_CallOpenSetPar();
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+ //cc_4G_EVS_Codec_Call_Open(codec, codec, 0/*isDTX*/, u16DelayR, u16DelayW, idle_delay, u32CurTime64us);
+ cc_4G_EVS_Codec_Call_Open((kal_uint32)codec, (kal_uint32)isDTX, (kal_uint32)u16DelayR, (kal_uint32)u16DelayW, (kal_uint32)idle_delay, (kal_uint32)u32CurTime64us, resetType);
+
+ //kal_prompt_trace(MOD_L1SP, "[SAL_4G_EVSCall_Open] SAL_PcmEx_CheckState OK");
+ MD_TRC_L1Audio_Msg_SP4G_EVSSeriesCall_Open_OK();
+}
+
+
+void SAL_4G_EVSCall_Close(void)
+{
+ cc_4G_EVS_Codec_Call_Close(1);
+}
+
+
+#endif
+
+kal_bool AM_Is_4G()
+{
+#if defined(__VOLTE_SUPPORT__)
+ return am.sp4g_flag;
+#else
+ return KAL_FALSE;
+#endif
+}
+
+
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+static void AM_DSP_VMRecordOn( uint32 speech_mode , uint32 extraInfo)
+{
+ Sal_VM_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_VM_Config_t));
+
+ cfg_t.swi = SAL_VM_SWITCH_ON;
+
+ if( am.state & (AM_STATE_SPEECH |AM_STATE_VOIP |AM_STATE_VOICE) ) { /* Conversation Recording */
+ ASSERT(!(am.speech_state & SP_STATE_VMR));
+ cfg_t.idle = false;
+ am.speech_state |= SP_STATE_VMR;
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(0) , L1AUDIO_Str_onoff(1) );
+ }
+ else { /* VM in idle mode */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(AMRWB_ENCODE) // not define in samrt phone
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif//#if defined(AMRWB_ENCODE)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ }
+
+ SAL_VM_Config(&cfg_t);
+
+}
+
+void AM_VMRecordOn( void )
+{
+ AM_Enqueue( AM_DSP_VMRecordOn, 0, 0, false );
+
+ AM_FlushQFunction();
+}
+
+
+static void AM_DSP_VMRecordOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ Sal_VM_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_VM_Config_t));
+
+ cfg_t.swi = SAL_VM_SWITCH_OFF;
+ cfg_t.idle = false;
+
+ if(am.speech_state & SP_STATE_VMR) /* Conversation Recording */
+ {
+ am.speech_state &= ~SP_STATE_VMR;
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(0) , L1AUDIO_Str_onoff(0) );
+ SAL_VM_Config(&cfg_t);
+ }
+ else /* VM in idle mode */
+ {
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ }
+}
+
+void AM_VMRecordOff( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ AM_Enqueue( AM_DSP_VMRecordOff, 0, 0, false );
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+static void AM_DSP_KeyToneOn( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ ASSERT(!(am.state & AM_STATE_KEYTONE));
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(0), L1AUDIO_Str_onoff(1) );
+
+ if ( am.state == 0 ) { // ( (am.state & ~AM_STATE_AVSYNC) == 0 ) {
+ AFE_TurnOn8K();
+ // AM_Write_Idle_Delay(4); // driver dost not support idle playback function, remove
+ VBI_Reset();
+ }
+ am.state |= AM_STATE_KEYTONE;
+}
+
+void AM_KeyToneOn( void )
+{
+ AM_Enqueue( AM_DSP_KeyToneOn, 0, 0, false );
+}
+
+static void AM_DSP_KeyToneOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(0), L1AUDIO_Str_onoff(0) );
+ am.state &= ~AM_STATE_KEYTONE;
+
+ if(am.state == 0)
+ VBI_End();
+
+ if( am.state == 0 ) // (am.state & ~AM_STATE_AUDIO) == 0 ) // no audio state exist
+ AFE_TurnOff8K();
+}
+
+void AM_KeyToneOff( void )
+{
+ AM_Enqueue( AM_DSP_KeyToneOff, 0, 0, false );
+}
+
+bool AM_IsKeyToneOn( void )
+{
+ if (am.state & AM_STATE_KEYTONE)
+ return true;
+ return false;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+static void AM_DSP_ToneOn( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ ASSERT(!(am.state & AM_STATE_TONE));
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(1), L1AUDIO_Str_onoff(1) );
+
+ if( am.state == 0 ) { // ( (am.state & ~AM_STATE_AVSYNC) == 0) {
+ AFE_TurnOn8K();
+ // AM_Write_Idle_Delay(4); // driver not support idle playback function, so remove
+ VBI_Reset();
+ }
+ am.state |= AM_STATE_TONE;
+}
+
+void AM_ToneOn( void )
+{
+ AM_Enqueue( AM_DSP_ToneOn, 0, 0, false );
+
+
+}
+
+static void AM_DSP_ToneOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(1), L1AUDIO_Str_onoff(0) );
+ am.state &= ~AM_STATE_TONE;
+
+ if( am.state == 0 )
+ VBI_End();
+
+ if( am.state == 0 ) // (am.state & ~AM_STATE_AUDIO) == 0 ) // no audio state exist
+ AFE_TurnOff8K();
+}
+
+void AM_ToneOff( void )
+{
+ AM_Enqueue( AM_DSP_ToneOff, 0, 0, false );
+}
+
+bool AM_IsToneOn( void )
+{
+ if (am.state & AM_STATE_TONE)
+ return true;
+ return false;
+}
+
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+static void AM_DSP_PCM8K_PlaybackOn( uint32 data , uint32 extraInfo)
+{
+ uint16 u16DelayR, u16DelayW, u16DelayM;
+
+ (void)data;
+
+ if( am.state == 0 ) {
+ AFE_TurnOn8K();
+ SAL_Get_Delay(SAL_DEALY_PCM8K_PB, SAL_DELAY_NA, SAL_DELAY_NA, &u16DelayR, &u16DelayW, &u16DelayM);
+ SAL_App_Open(u16DelayR, u16DelayW, u16DelayM);
+ }
+// #if defined(BGSND_ENABLE) || defined(__SMART_PHONE_MODEM__)
+ if ( data == 1 )
+ {
+ ASSERT(!(am.state & AM_STATE_SND_EFFECT));
+ am.state |= AM_STATE_SND_EFFECT;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(9), L1AUDIO_Str_onoff(1) );
+ }
+ else
+// #endif // #if defined(BGSND_ENABLE) || defined(__SMART_PHONE_MODEM__)
+ {
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ am.state |= AM_STATE_VOICE;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(2), L1AUDIO_Str_onoff(1) );
+ }
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+static void AM_DSP_PCM8K_PlaybackOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+
+// #if defined(BGSND_ENABLE) || defined(__SMART_PHONE_MODEM__)
+ if( data == 1 )
+ {
+ am.state &= ~AM_STATE_SND_EFFECT;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(9), L1AUDIO_Str_onoff(0) );
+ }
+ else
+// #endif // #if defined(BGSND_ENABLE) || defined(__SMART_PHONE_MODEM__)
+ {
+ am.state &= ~AM_STATE_VOICE;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(2), L1AUDIO_Str_onoff(0) );
+ }
+ SAL_App_Close(am.state == 0);
+
+ if( am.state == 0 ) // (am.state & ~AM_STATE_AUDIO) == 0 ) // no audio state exist
+ AFE_TurnOff8K();
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+uint32 AM_GetRecordFormat()
+{
+ return am.record_format;
+}
+
+/**
+ @data: bit[0:3] DL position
+*/
+static void AM_DSP_PCM16K_RecordOn( uint32 data , uint32 extraInfo)
+{
+ (void)extraInfo;
+ Sal_PCMEx_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_PCMEx_Config_t));
+
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ am.record_format = AM_RECORD_16K;
+
+
+ cfg_t.idle = true;
+ cfg_t.band = SAL_PCM_WIDEBAND;
+ cfg_t.type = SAL_PCMEX_TYPE_REC_NML;
+ cfg_t.swi = SAL_PCMEX_SWITCH_ON;
+ cfg_t.PCMRec_DL_Pos = (data&0xF);
+ SAL_Get_Delay(SAL_DEALY_PCM16K, SAL_DELAY_NA, SAL_DELAY_NA, &cfg_t.delR, &cfg_t.delW, &cfg_t.delM);
+
+ //config related digital device(nb/wb),
+ // am_SetDevice();
+
+ AFE_TurnOn8K();
+
+ SAL_PcmEx_Config(&cfg_t);
+
+ am.state |= AM_STATE_VOICE;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(10), L1AUDIO_Str_onoff(1) );
+}
+
+void AM_PCM16K_RecordOn( uint8 dlPos )
+{
+
+ if(!(am.state & AM_STATE_SPEECH))
+ {
+ AM_Enqueue( AM_DSP_PCM16K_RecordOn, dlPos, 0, false );
+ AM_FlushQFunction();
+
+ // enable enhancement
+ if(!AM_IsBTCordlessMode())
+ {
+ SetSpeechEnhancement(true);
+ }
+ } else {
+ DEBUG_ASSERT(0);
+ }
+
+}
+
+static void AM_DSP_PCM16K_RecordOff( uint32 data , uint32 extraInfo)
+{
+ (void)data;
+ (void)extraInfo;
+ Sal_PCMEx_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_PCMEx_Config_t));
+
+ cfg_t.swi = SAL_PCMEX_SWITCH_OFF;
+ am.state &= ~AM_STATE_VOICE;
+ am.record_format = AM_RECORD_NONE;
+ cfg_t.idle = false;
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(10), L1AUDIO_Str_onoff(0) );
+
+ if( am.state == 0 ) {
+ cfg_t.idle = true;
+ }
+ cfg_t.type = SAL_PCMEX_TYPE_REC_NML;
+
+ SAL_PcmEx_Config(&cfg_t);
+
+ if( am.state == 0 ) {
+ AFE_TurnOff8K();
+ }
+}
+
+void AM_PCM16K_RecordOff( bool wait )
+{
+ // turn off speech enhancment
+ if(!(am.state & AM_STATE_SPEECH))
+ {
+ if(!AM_IsBTCordlessMode())
+ {
+ SetSpeechEnhancement(false);
+ }
+
+ AM_Enqueue( AM_DSP_PCM16K_RecordOff, 0, 0, false );
+ if( wait )
+ AM_FlushQFunction();
+ } else {
+ DEBUG_ASSERT(0);
+ }
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+/**
+ @extraInfo: bit[0:3] DL position when appType is AM_PCM8KREC_APP_TYPE_PCMREC
+*/
+static void AM_DSP_PCM8K_RecordOn( uint32 appType , uint32 extraInfo)
+{
+ (void)extraInfo;
+
+ Sal_PCMEx_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_PCMEx_Config_t));
+
+ cfg_t.idle = false;
+ cfg_t.swi = SAL_PCMEX_SWITCH_ON;
+
+ am.record_format = AM_RECORD_8K;
+
+ if( am.state & (AM_STATE_SPEECH | AM_STATE_VOIP)) {
+ // REMIND: Call record and VM EPL can work in the same time,
+ // but they use same interrupt and setting.
+
+ if (AM_PCM8KREC_APP_TYPE_PCMREC == appType) { // Conversation Recording
+ if (!(am.speech_state & SP_STATE_PCM8K_REC)) {
+ cfg_t.type = SAL_PCMEX_TYPE_REC_NML;
+ cfg_t.PCMRec_DL_Pos = (extraInfo&0xF);
+ am.speech_state |= SP_STATE_PCM8K_REC;
+
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(1) , L1AUDIO_Str_onoff(1) );
+ } else {
+ return;
+ }
+ } else if(AM_PCM8KREC_APP_TYPE_VMEPL == appType) { // VM EPL
+ if (!(am.speech_state & SP_STATE_VMR_EPL)) {
+ cfg_t.type = SAL_PCMEX_TYPE_REC_EPL;
+ am.speech_state |= SP_STATE_VMR_EPL;
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(4) , L1AUDIO_Str_onoff(1) );
+ } else {
+ return;
+ }
+ } else {
+ DEBUG_ASSERT(0); // unknown application type
+ return;
+ }
+
+ }else{
+ if(AM_PCM8KREC_APP_TYPE_VMEPL == appType) { // idle epl
+ if((am.state & AM_STATE_VOICE)
+ && (!(am.speech_state & SP_STATE_VMR_EPL))) {
+
+ am.speech_state |= SP_STATE_VMR_EPL;
+ cfg_t.idle = false;
+ cfg_t.type = SAL_PCMEX_TYPE_REC_EPL;
+ } else {
+ return;
+ }
+ } else { // idle record
+ if( !(am.state & AM_CONFLICT_STATE) ){
+ am.state |= AM_STATE_VOICE;
+
+ cfg_t.idle = true;
+ cfg_t.type = SAL_PCMEX_TYPE_REC_NML;
+ cfg_t.band = SAL_PCM_NARROWBAND;
+ cfg_t.PCMRec_DL_Pos = (extraInfo&0xF);
+ SAL_Get_Delay(SAL_DEALY_NOTAMR, SAL_DELAY_NA, SAL_DELAY_NA, &cfg_t.delR, &cfg_t.delW, &cfg_t.delM);
+ } else {
+ return;
+ }
+ }
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(4), L1AUDIO_Str_onoff(1) );
+ }
+
+ if(cfg_t.idle)
+ AFE_TurnOn8K();
+
+ SAL_PcmEx_Config(&cfg_t);
+}
+
+void AM_PCM8K_RecordOn( AM_PCM8KREC_APP_TYPE appType, uint8 dlPos )
+{
+
+ AM_Enqueue( AM_DSP_PCM8K_RecordOn, (uint32)appType, dlPos, false );
+ AM_FlushQFunction();
+
+ if(!(am.state & (AM_STATE_SPEECH | AM_STATE_VOIP)))
+ {
+ if(!AM_IsBTCordlessMode())
+ {
+ SetSpeechEnhancement(true);
+ }
+ }
+}
+
+static void AM_DSP_PCM8K_RecordOff( uint32 appType , uint32 extraInfo)
+{
+ Sal_PCMEx_Config_t cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_PCMEx_Config_t));
+
+ am.record_format = AM_RECORD_NONE;
+ cfg_t.swi = SAL_PCMEX_SWITCH_OFF;
+ cfg_t.idle = false;
+
+ if(AM_PCM8KREC_APP_TYPE_PCMREC == appType)
+ cfg_t.type = SAL_PCMEX_TYPE_REC_NML;
+ if(AM_PCM8KREC_APP_TYPE_VMEPL == appType)
+ cfg_t.type = SAL_PCMEX_TYPE_REC_EPL;
+
+ if(am.speech_state & (SP_STATE_PCM8K_REC|SP_STATE_VMR_EPL) ) // under call
+ {
+ if(AM_PCM8KREC_APP_TYPE_PCMREC == appType) {
+ am.speech_state &= ~SP_STATE_PCM8K_REC;
+ } else if(AM_PCM8KREC_APP_TYPE_VMEPL == appType){
+ am.speech_state &= ~SP_STATE_VMR_EPL;
+ } else {
+ DEBUG_ASSERT(0); // unknow application type
+ return;
+ }
+
+ if(AM_PCM8KREC_APP_TYPE_PCMREC == appType) {
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(1) , L1AUDIO_Str_onoff(0) );
+ } else if(AM_PCM8KREC_APP_TYPE_VMEPL == appType){
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(4) , L1AUDIO_Str_onoff(0) );
+ }
+ }
+ else
+ {
+ if(AM_PCM8KREC_APP_TYPE_VMEPL == appType) { // idle VM epl
+ am.speech_state &= ~SP_STATE_VMR_EPL;
+ } else { // idle record
+ am.state &= ~AM_STATE_VOICE;
+ }
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(4), L1AUDIO_Str_onoff(0) );
+ }
+
+ if( am.state == 0 ) {
+ cfg_t.idle = true;
+ }
+
+ SAL_PcmEx_Config(&cfg_t);
+ if( am.state == 0 ) // (am.state & ~AM_STATE_AUDIO) == 0 ) // no audio state exist
+ AFE_TurnOff8K();
+}
+
+void AM_PCM8K_RecordOff( bool wait , AM_PCM8KREC_APP_TYPE appType)
+{
+ if(!(am.state & (AM_STATE_SPEECH | AM_STATE_VOIP)))
+ {
+ if(!AM_IsBTCordlessMode())
+
+ {
+ SetSpeechEnhancement(false);
+ }
+ }
+
+ AM_Enqueue( AM_DSP_PCM8K_RecordOff, (uint32)appType, 0, false );
+
+ if( wait )
+ AM_FlushQFunction();
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+int16 AM_IsAudioPlaybackOn( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ return -1;
+}
+
+int16 AM_IsIdleState( void )
+{
+ if( am.state == 0 )
+ return true;
+ return false;
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+bool AM_IsVoiceOn( void )
+{
+ if(am.state !=0 ) // ( am.state & ~AM_STATE_AUDIO) // no audio state exist
+ return true;
+ return false;
+}
+
+/* ==========================================================================*/
+static void RampPush( RampStatus status)
+{
+ if(RB_FULL(am.ramp_point_queue)) {
+ MD_TRC_L1SP_MUTE_DSP_RAMP_QUEUE_FULL();
+ } else {
+ RB_PUT(am.ramp_point_queue, status);
+ }
+}
+
+static void RampPop( void )
+{
+ if(RB_EMPTY(am.ramp_point_queue)) {
+ MD_TRC_L1SP_MUTE_DSP_RAMP_QUEUE_EMPTY();
+ ASSERT(0);
+ } else {
+ RB_CONSUME(am.ramp_point_queue);
+ }
+}
+
+void AM_RAMP_INIT(bool mute, uint16 ramp_point)
+{
+ Sal_Ramp_State_t preState = SAL_Ramp_GetState(ramp_point);
+ RampStatus rampStatus;
+ rampStatus.RampPoint = ramp_point;
+ rampStatus.MuteState = mute;
+ MD_TRC_L1SP_MUTE_DSP_RAMP_CONTROL(0, ramp_point, preState, mute, am.state);
+ if(AM_IsAmInSpeechState())
+ {
+ if(mute) {
+ if( SAL_RAMP_DOWN_DONE == preState) {
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(rampStatus.RampPoint);
+#endif
+ } else { // if state in RAMP_DOWN_INIT or RAMP_DOWN_RUN, it won't take effect
+ SAL_RampDown_SetInit(ramp_point);
+ RampPush(rampStatus);
+ }
+ } else { // unmute
+ if( SAL_RAMP_DOWN_DONE == preState) { // no sound, so ramp up
+ SAL_RampUp_SetInit(ramp_point);
+ RampPush(rampStatus);
+ } else { // if state in RAMP_UP_INIT or RAMP_UP_RUN, it won't take effect
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(rampStatus.RampPoint);
+#endif
+ }
+ }
+ } else {
+ if( mute) {
+ SAL_Ramp_SetMute(rampStatus.RampPoint);
+ } else {
+ SAL_Ramp_SetUnMute(rampStatus.RampPoint);
+ }
+ kal_prompt_trace(MOD_L1SP, "[AM_Ramp_Point] No in speech state!");
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(rampStatus.RampPoint);
+#endif
+ }
+ MD_TRC_L1SP_MUTE_DSP_RAMP_CONTROL(1, ramp_point, SAL_Ramp_GetState(ramp_point),mute,am.state);
+}
+void AM_RAMP_DONE(void)
+{
+ RampStatus rampStatus;
+ while (!RB_EMPTY(am.ramp_point_queue)) {
+ RB_PEEK(am.ramp_point_queue, rampStatus);
+ MD_TRC_L1SP_MUTE_DSP_RAMP_DONE_STATE(rampStatus.MuteState, rampStatus.RampPoint, am.state);
+ if(AM_IsAmInSpeechState()) {
+ if(rampStatus.MuteState) {
+ if(SAL_RampDown_IsDone(rampStatus.RampPoint)) {
+ kal_prompt_trace(MOD_L1SP, "[AM_Ramp_Point] ramp down pass!");
+ } else {
+ MD_TRC_L1SP_MUTE_DSP_RAMP_DELAY_MUTE();
+ break;
+ }
+ } else {
+ if(SAL_RampUp_IsDone(rampStatus.RampPoint)) {
+ kal_prompt_trace(MOD_L1SP, "[AM_Ramp_Point] ramp up pass!");
+ SAL_Ramp_SetFinal(rampStatus.RampPoint);
+ } else {
+ MD_TRC_L1SP_MUTE_DSP_RAMP_DELAY_UNMUTE();
+ break;
+ }
+ }
+ } else { // force mute/unmute when call end
+ if(rampStatus.MuteState) {
+ SAL_Ramp_SetFinal(rampStatus.RampPoint);
+ SAL_Ramp_SetMute(rampStatus.RampPoint);
+ MD_TRC_L1SP_MUTE_DSP_RAMP_FORCE_MUTE();
+ } else {
+ SAL_Ramp_SetFinal(rampStatus.RampPoint);
+ MD_TRC_L1SP_MUTE_DSP_RAMP_FORCE_UNMUTE();
+ }
+ }
+ RampPop();
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(rampStatus.RampPoint);
+#endif
+ }
+}
+void AM_Mute_UL_EnhResult_Speech(bool mute)
+{
+ MD_TRC_L1SP_MUTE_DSP_UL_ENH_RESULT_CONTROL(mute);
+ SAL_Mute_Ctrl(SAL_MUTE_UL_IN_EN, mute); // in the enhancement end point, which is set -60db to the result.
+}
+
+void AM_Mute_UL_Source_Speech(bool mute)
+{
+ AM_RAMP_INIT(mute, SAL_RAMP_UL_PRE_EN);
+}
+
+void AM_Mute_UL_Codec_Speech( bool mute )
+{
+ MD_TRC_L1SP_MUTE_DSP_UL_CODEC_CONTROL(mute);
+ SAL_Mute_Ctrl(SAL_MUTE_UL_PRE_EXTCOD, mute); // need to under this position, or background sound won't be mute.
+}
+
+void AM_Mute_UL_POS_EN_Speech( bool mute )
+{
+ AM_RAMP_INIT(mute, SAL_RAMP_UL_POS_EN);
+
+}
+
+void AM_Mute_DL_8K_Speech( bool mute )
+{
+ AM_RAMP_INIT(mute, SAL_RAMP_DL_PRE_DACA);
+}
+
+void AM_Mute_DL_Speech_Traffic( bool mute )
+{
+ MD_TRC_L1SP_MUTE_DSP_DL_TRAFFIC_CONTROL(mute);
+ SAL_Mute_Ctrl(SAL_MUTE_DL_POS_EXTCOD, mute); //considering the VT case using P2W, so mute data at this point , not at SAL_MUTE_DL_PRE_SD
+}
+
+void AM_Mute_DL_PRE_PcmMixer(bool mute)
+{
+ AM_RAMP_INIT(mute, SAL_RAMP_DL_PRE_MIXER2);
+}
+
+
+
+void AM_Init( void )
+{
+ am.dsp_2g_reset = false;
+
+ am.record_format = AM_RECORD_NONE;
+ RB_INIT( am.qfunc );
+ am.state = 0;
+ am.speech_mode = 0;
+ am.pre_speech_mode = 0;
+ am.sub_channel = 0;
+ am.is_reset_enh = 0;
+ // am.speech_off_delay = 0;
+ // am.pre_isWBLink = KAL_FALSE;
+#if defined(_SPE_ENH_MD_PARSE_)
+ am.isFirCoeffSet = false;
+#endif
+
+ SAL_Dsp_Sph_Init();
+
+ // AM_WriteSidetoneFIR(); // 93 not dsp sidetone, so remove
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+ if( am.isFirCoeffSet == KAL_FALSE ) {
+ AM_WriteWbFirCoeffs( WB_Speech_Input_FIR_Coeff[0], WB_Speech_Output_FIR_Coeff[0] );
+ AM_WriteFirCoeffs( WB_Speech_Input_FIR_Coeff[0], WB_Speech_Output_FIR_Coeff[0] );
+ }
+ #endif
+ // AM_WriteAntiAliasFilter();
+
+ am.io_type = NORMAL_MODE;
+ am.speech_state = 0;
+ // am.voip_state = 0;
+ // am.fLoopBack = false;
+ am.sp3g_flag = false;
+#if defined(__C2K_SPEECH_SUPPORT__)
+ am.spc2k_flag = false;
+ am.c2k_flag = false;
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ am.sp4g_flag = false;
+ am.codec_4g = -1;
+#endif
+
+ // AM_DSP_SetSpeechDigitalGain(DG_DL_Speech); // replace by spGain_Init()
+ // AM_DSP_SetSpeechEnhRefDigitalGain(DG_DL_Speech); //am.speechDlEnhRefDigtalGain init // replace by spGain_Init
+}
+
+/* ========================================================================= */
+/* Bluetooth control Functions */
+/* ========================================================================= */
+
+
+static void AM_DSP_BluetoothOn( uint32 data , uint32 extraInfo)
+{
+ Sal_BT_Config cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_BT_Config));
+ cfg_t.feed_cfg = true;
+
+
+ // leave the gain control to AP. do not do any backup now
+ // am.bt_digital_gain = AM_DSP_GetSpeechDigitalGain(); //*DP_VOL_OUT_PCM;
+ // am.bt_dlEnhRef_digital_gain = AM_GetSpeechEnhRefDigitalGain(); // use am.speechDlEnhRefDigtalGain
+
+ // Zero-pending
+ cfg_t.linear_ctrl = SAL_BT_LINEAR_GAIN_CONFIG_ZPAD;
+ cfg_t.mode = SAL_BT_MODE_LINEAR;
+ // MSB first
+ cfg_t.linear_reverse = false;
+
+ //set mode and uplink gain
+ cfg_t.linear_ul_gain = 1;
+
+ // leave the gain control to AP. do not do any backup now
+ // AM_DSP_SetSpeechDigitalGain(default_bt_pcm_out_vol); // *DP_VOL_OUT_PCM = 0x1000;
+ // AM_DSP_SetSpeechUplinkSwAgcGain(0); // AGC set to 0 db
+ // AM_DSP_SetSpeechEnhRefDigitalGain(default_bt_pcm_out_enh_ref_vol); // 0db
+
+
+ SAL_BT_Config(&cfg_t);
+
+ am.io_type = BT_EARPHONE_MODE;
+ MD_TRC_L1Audio_Msg_AM_IO_Switch( AM_IO_Name(am.io_type) );
+}
+
+static void AM_DSP_BluetoothOff( uint32 data , uint32 extraInfo)
+{
+ Sal_BT_Config cfg_t;
+ memset(&cfg_t, 0, sizeof(Sal_BT_Config));
+
+ cfg_t.feed_cfg = false;
+
+ // AFE_SetBtFlag(KAL_FALSE);
+
+ // leave the gain control to AP. do not do restore the value to default now
+ // AM_DSP_SetSpeechDigitalGain(am.bt_digital_gain);
+ // AM_DSP_SetSpeechUplinkSwAgcGain(am.speechUplinkSwAgcGain);
+ // AM_DSP_SetSpeechEnhRefDigitalGain(am.speechDlEnhRefDigtalGain);
+
+ SAL_BT_Config(&cfg_t);
+
+ am.io_type = NORMAL_MODE;
+ MD_TRC_L1Audio_Msg_AM_IO_Switch( AM_IO_Name(am.io_type) );
+}
+
+//*******************************************************************//
+//* bt_mode: 1 for cordless mode, 2 for earphone mode *//
+//* bt_sync_type: 0 for short sync, 1 for long sync *//
+//* bt_sync_length: range from 1 to 8 *//
+//*******************************************************************//
+#if 0 // [FIXME] useless??
+/* under construction !*/
+/* under construction !*/
+#endif
+
+void AM_BluetoothOn( uint8 bt_mode )
+{
+ ASSERT(bt_mode == 2); // expected earphone mode only
+
+ AM_Enqueue( AM_DSP_BluetoothOn, 0, 0, false );
+
+ AM_FlushQFunction();
+}
+
+void AM_BluetoothOff( void )
+{
+ SP_DSPTone_ForceEnd();
+
+ AM_Enqueue( AM_DSP_BluetoothOff, 0, 0, false );
+ AM_FlushQFunction();
+}
+
+bool AM_IsBluetoothOn( void )
+{
+ return SAL_BT_IsEnable();
+}
+
+bool AM_IsBTCordlessMode( void )
+{
+ return false;//( (*DP_AUDIO_PAR&0x1000)!=0 );
+}
+
+
+/* ========================================================================= */
+
+
+void AM_SND_PlaybackOn( void )
+{
+ AM_Enqueue( AM_DSP_PCM8K_PlaybackOn, 1, 0, false );
+
+ AM_FlushQFunction();
+}
+
+void AM_SND_PlaybackOff( bool wait )
+{
+
+ AM_Enqueue( AM_DSP_PCM8K_PlaybackOff, 1, 0, false );
+
+ if( wait )
+ AM_FlushQFunction();
+}
+// #endif // defined(BGSND_ENABLE) || defined(__SMART_PHONE_MODEM__)
+
+/* ========================================================================= */
+/* PCM_EX control Functions */
+/* ========================================================================= */
+
+void AM_DSP_PCM_EX_On(uint32 type, uint32 data)
+{
+ kal_bool flag;
+ // uint8 voip_state = 0;
+
+ Sal_PCMEx_Config_t cfg;
+ memset(&cfg, 0, sizeof(Sal_PCMEx_Config_t));
+
+
+ flag = true; //this flag is used to choose one among multiple options
+ switch(type)
+ {
+ case AM_PCMEX_TYPE_DACA_DEDICATION: // 100: //DACA ACTIVE
+ if(flag){
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(3) , L1AUDIO_Str_onoff(1) );
+ ASSERT(!(am.speech_state & SP_STATE_DACA));
+ am.speech_state |= SP_STATE_DACA;
+
+ cfg.idle = false;
+
+ flag=false;
+ }
+ case AM_PCMEX_TYPE_DACA_IDLE_WO_ENH: //101: //DACA IDLE
+ if(flag){
+ ASSERT_REBOOT( !(am.state & AM_STATE_DACA) );
+ ASSERT(am.state == 0);
+ am.state |= AM_STATE_DACA;
+
+ cfg.idle = true;
+
+ flag=false;
+ }
+ cfg.swi = SAL_PCMEX_SWITCH_ON;
+ cfg.type = SAL_PCMEX_TYPE_DACA;
+ {
+ _DACA_EX_T *dacaExData = (_DACA_EX_T *)data;
+ kal_uint32 app_type = dacaExData->app_type;
+ //cfg.band = (dacaExData->app_type & DACA_USE_NB) ? SAL_PCM_NARROWBAND : SAL_PCM_WIDEBAND;
+ if(app_type & DACA_USE_NB){
+ cfg.band = SAL_PCM_NARROWBAND;
+ }else if(app_type & DACA_USE_WB){
+ cfg.band = SAL_PCM_WIDEBAND;
+ }else if(app_type & DACA_USE_SWB){
+ cfg.band = SAL_PCM_SUPERWIDEBAND;
+ }else if(app_type & DACA_USE_FB){
+ cfg.band = SAL_PCM_FULLBAND;
+ }else{
+ ASSERT(0);
+ }
+ }
+
+ break;
+ // ======================================================================
+ case AM_PCMEX_TYPE_DEDICATION: // 0: //PCM4WAY CTM
+ if(flag){
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(2) , L1AUDIO_Str_onoff(1) );
+ ASSERT(!(am.speech_state & SP_STATE_PCMNWAY));
+
+ am.speech_state |= SP_STATE_PCMNWAY;
+
+ cfg.idle = false;
+
+ flag=false;
+ }
+ /*
+ case AM_PCMEX_TYPE_IDLE_WO_ENH: // 1: //PCM2WAY Voice
+ if(flag){
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ ASSERT(am.state == 0);
+ am.state |= AM_STATE_VOICE;
+
+ cfg.idle = true;
+
+ flag = false;
+ }
+ */
+ case AM_PCMEX_TYPE_IDLE: //2: PCM2WAY VoIP
+ if(flag){
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ ASSERT(am.state == 0);
+ am.state |= AM_STATE_VOIP;
+
+ cfg.idle = true;
+ flag = false;
+ }
+
+ cfg.swi = SAL_PCMEX_SWITCH_ON;
+ cfg.type = SAL_PCMEX_TYPE_PNW;
+
+ {
+
+ _PCMEX_T *pcmExData = (_PCMEX_T *)data;
+
+ cfg.D2M_ul1 = (0!=(pcmExData->cfgUL1 & USE_D2M_PATH));
+ cfg.M2D_ul1 = (0!=(pcmExData->cfgUL1 & USE_M2D_PATH));
+ cfg.afterEnh_ul1 = (0!=(pcmExData->cfgUL1 & DATA_SELECT_AFTER_ENH));
+
+ cfg.D2M_ul2 = (0!=(pcmExData->cfgUL2 & USE_D2M_PATH));
+ cfg.M2D_ul2 = (0!=(pcmExData->cfgUL2 & USE_M2D_PATH));
+ cfg.afterEnh_ul2 = (0!=(pcmExData->cfgUL2 & DATA_SELECT_AFTER_ENH));
+
+ cfg.D2M_ul3 = (0!=(pcmExData->cfgUL3 & USE_D2M_PATH));
+ cfg.M2D_ul3 = (0!=(pcmExData->cfgUL3 & USE_M2D_PATH));
+ cfg.afterEnh_ul3 = (0!=(pcmExData->cfgUL3 & DATA_SELECT_AFTER_ENH));
+
+ cfg.D2M_ul4 = (0!=(pcmExData->cfgUL4 & USE_D2M_PATH));
+ cfg.M2D_ul4 = (0!=(pcmExData->cfgUL4 & USE_M2D_PATH));
+ cfg.afterEnh_ul4 = (0!=(pcmExData->cfgUL4 & DATA_SELECT_AFTER_ENH));
+
+ cfg.D2M_dl = (0!=(pcmExData->cfgDL & USE_D2M_PATH));
+ cfg.M2D_dl = (0!=(pcmExData->cfgDL & USE_M2D_PATH));
+ cfg.afterEnh_dl = (0!=(pcmExData->cfgDL & DATA_SELECT_AFTER_ENH));
+
+
+ if(cfg.idle){
+ if(pcmExData->bandInfo == PCMEX_BAND_WB){
+ cfg.band = SAL_PCM_WIDEBAND;
+ }else if (pcmExData->bandInfo == PCMEX_BAND_NB){
+ cfg.band = SAL_PCM_NARROWBAND;
+ }else if (pcmExData->bandInfo == PCMEX_BAND_SWB){
+ cfg.band = SAL_PCM_SUPERWIDEBAND;
+ }else if (pcmExData->bandInfo == PCMEX_BAND_FB){
+ cfg.band = SAL_PCM_FULLBAND;
+ }else{ // should never been here
+ ASSERT(0);
+ }
+ } else {
+ cfg.band = SAL_PCM_DYNAMIC;
+ }
+
+ }
+
+ break;
+ default:
+ ASSERT(0); break;
+ }
+
+ if(cfg.idle == true){
+ SAL_Get_Delay(SAL_DEALY_PCM8K_PB_VOIP, SAL_DELAY_NA, SAL_DELAY_NA, &cfg.delR, &cfg.delW, &cfg.delM);
+ AFE_TurnOn8K();
+ }
+
+ SAL_PcmEx_Config(&cfg);
+}
+
+
+void AM_DSP_PCM_EX_Off(uint32 type, uint32 data)
+{
+ kal_bool flag;
+ // uint8 voip_state = 0;
+
+ Sal_PCMEx_Config_t cfg;
+ memset(&cfg, 0, sizeof(Sal_PCMEx_Config_t));
+
+ flag = true; //this flag is used to choose one among multiple options
+ switch(type)
+ {
+ case AM_PCMEX_TYPE_DACA_DEDICATION: //100: DACA ACTIVE
+ if(flag ){
+ am.speech_state &= ~SP_STATE_DACA;
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(3) , L1AUDIO_Str_onoff(0) );
+
+ cfg.idle = false;
+
+ flag = false;
+ }
+ case AM_PCMEX_TYPE_DACA_IDLE_WO_ENH: //101: DACA IDLE
+ if(flag ){
+ am.state &= ~AM_STATE_DACA;
+ ASSERT(am.state == 0);
+
+ cfg.idle = true;
+
+ flag =false;
+ }
+
+ cfg.swi = SAL_PCMEX_SWITCH_OFF;
+ cfg.type = SAL_PCMEX_TYPE_DACA;
+
+ break;
+ // ======================================================================
+ case AM_PCMEX_TYPE_DEDICATION: //PCM4WAY CTM
+ if(flag ){
+ am.speech_state &= ~SP_STATE_PCMNWAY;
+ MD_TRC_L1Audio_Msg_AM_SetSpeech( AM_Speech_Feature_Name(2) , L1AUDIO_Str_onoff(0) );
+
+ cfg.idle = false;
+
+ flag = false;
+ }
+ /*
+ case AM_PCMEX_TYPE_IDLE_WO_ENH: //PCM2WAY Voice
+ if(flag ){
+ am.state &= ~AM_STATE_VOICE;
+ ASSERT(am.state == 0);
+
+ cfg.idle = true;
+
+ flag = false;
+ }
+ */
+ case AM_PCMEX_TYPE_IDLE: //PCM2WAY VoIP
+ if(flag ){
+ am.state &= ~AM_STATE_VOIP;
+ ASSERT(am.state == 0);
+
+ cfg.idle = true;
+
+ flag = false;
+ }
+
+ cfg.swi = SAL_PCMEX_SWITCH_OFF;
+ cfg.type = SAL_PCMEX_TYPE_PNW;
+
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ if(cfg.idle == true){
+ cc_set_VBI_for_FSM(1);
+ SAL_PcmEx_Config(&cfg);
+ cc_set_VBI_for_FSM(2);
+ AFE_TurnOff8K();
+ } else {
+ SAL_PcmEx_Config(&cfg);
+ }
+}
+
+/**
+ @type: AM_PCMEX_TYPE, indicate the PCM EX type
+ @p2exData: Addess of "glable variable" like pcmEx, dacaEx
+*/
+void AM_PCM_EX_On( AM_PCMEX_TYPE type, uint32 p2exData)
+{
+ // kal_uint8 aud_func;
+ if(type == AM_PCMEX_TYPE_IDLE
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif
+ || type == AM_PCMEX_TYPE_DACA_IDLE )
+ {
+
+
+ // aud_func = L1SP_SPEECH;
+ }
+/*
+ else
+ {
+ // aud_func = L1SP_VOICE;
+ }
+*/
+
+
+ AM_Enqueue( AM_DSP_PCM_EX_On, type, p2exData, false );
+
+ AM_FlushQFunction();
+}
+
+
+void AM_PCM_EX_Off( AM_PCMEX_TYPE type, uint32 p2exData)
+{
+/*
+ // find out the aud_func
+ kal_uint8 aud_func = L1SP_MAX_AUDIO;
+
+ if( type == AM_PCMEX_TYPE_IDLE
+#if 0
+ || type == AM_PCMEX_TYPE_REC_ONLY_CAL
+ || type == AM_PCMEX_TYPE_REC_PLAY_CAL
+#endif
+ || type == AM_PCMEX_TYPE_DACA_IDLE ) {
+ aud_func = L1SP_SPEECH;
+ } else {
+ aud_func = L1SP_VOICE;
+ }
+*/
+
+ AM_Enqueue(AM_DSP_PCM_EX_Off, type, p2exData, false );
+ AM_FlushQFunction();
+}
+
+bool AM_IsVoIPOn( void )
+{
+ return( (bool)((am.state & AM_STATE_VOIP) != 0) );
+}
+
+/* ========================================================================= */
+
+uint16 AM_Status( void )
+{
+ return am.state;
+}
+
+/* phase out. lagency
+void AM_EnableToneLoopBackFlag( kal_bool param )
+{
+ if(param)
+ am.toneLoopbackRec = KAL_TRUE;
+ else
+ am.toneLoopbackRec = KAL_FALSE;
+}
+*/
+/* ========================================================================= */
+/* Functions for DSP PCM Router */
+/* ========================================================================= */
+#define PCM_ROUTER_DELAY_READ 0
+#define PCM_ROUTER_DELAY_WRITE 0xF0
+#define PCM_ROUTER_DELAY_DL 0x38
+#define PCM_ROUTER_DELAY_UL 0x118
+
+void AM_DSP_PcmRouter_On( uint32 voiceMode, uint32 extraInfo )
+{
+
+ Sal_PCM_Router_t pcmrt;
+
+ ASSERT_REBOOT( !(am.state & AM_CONFLICT_STATE) );
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(11), L1AUDIO_Str_onoff(1) );
+
+ // setting
+ memset(&pcmrt, 0 , sizeof(Sal_PCM_Router_t));
+
+ pcmrt.cod_band = 0; //voiceMode;
+ pcmrt.dev_band = voiceMode;
+ pcmrt.delR = PCM_ROUTER_DELAY_READ;
+ pcmrt.delW = PCM_ROUTER_DELAY_WRITE;
+ pcmrt.delM_DL = PCM_ROUTER_DELAY_DL;
+ pcmrt.delM_UL = PCM_ROUTER_DELAY_UL;
+
+ // turn on 8k
+ AFE_TurnOn8K();
+
+ SAL_PCM_Router_Open(&pcmrt, ((extraInfo&1)? SAL_SRST_TYPE_DEV: SAL_SRST_TYPE_CALLON));
+
+ am.state |= AM_STATE_VOIP;
+}
+
+
+/**
+ @extraInfo: bit[0]: 1 for device change to resync
+*/
+void AM_PcmRouter_On(uint32 extraInfo)
+{
+ kal_uint8 voiceMode;
+
+ // the following chips did not provide the function
+
+ voiceMode = AFE_GetVoice8KMode();
+
+ AM_Enqueue( AM_DSP_PcmRouter_On, voiceMode, extraInfo, false );
+
+ AM_FlushQFunction();
+
+}
+
+void AM_DSP_PcmRouter_Off( uint32 info, uint32 extraInfo )
+{
+ MD_TRC_L1Audio_Msg_AM_Switch( AM_Switch_Name(11), L1AUDIO_Str_onoff(0) );
+
+ SAL_PCM_Router_Close(true);
+
+ AFE_TurnOff8K();
+
+ am.state &= (~AM_STATE_VOIP);
+}
+
+
+void AM_PcmRouter_Off(void)
+{
+
+ AM_Enqueue( AM_DSP_PcmRouter_Off, 0, 0, false );
+
+ AM_FlushQFunction();
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+bool AM_IsConflictState( void )
+{
+ if( am.state & AM_CONFLICT_STATE )
+ return true;
+ else
+ return false;
+}
+
+
+kal_uint32 AM_Get2GResyncThreshold(void)
+{
+ return AM_2G_RESYNC_THRESHOLD;
+}
+
+//=============================================================================
+// sw digital gain related
+//=============================================================================
+
+void AM_DSP_SetSpeechDigitalGain(kal_uint16 digitalVol)
+{
+ am.speechDigitalGain = digitalVol;
+ SAL_DGain_Set_DL(digitalVol);
+
+ MD_TRC_L1Audio_Msg_AM_DSP_GAIN(AM_Gain_Name(1), digitalVol);
+}
+
+kal_uint16 AM_DSP_GetSpeechDigitalGain(void)
+{
+ return SAL_DGain_Get_DL();
+}
+
+
+void AM_DSP_SetSpeechUplinkSwAgcGain(kal_uint16 digitalVol)
+{
+ am.speechUplinkSwAgcGain = digitalVol;
+ SAL_AGC_SetGain(digitalVol);
+
+ MD_TRC_L1Audio_Msg_AM_DSP_GAIN(AM_Gain_Name(3), digitalVol);
+}
+
+kal_uint16 AM_GetSpeechEnhRefDigitalGain(void)
+{
+ return am.speechDlEnhRefDigtalGain;
+}
+
+void AM_DSP_SetSpeechEnhRefDigitalGain(kal_uint16 digitalVol)
+{
+ am.speechDlEnhRefDigtalGain = digitalVol;
+ SAL_ENH_Gain_Set_DL(digitalVol);
+
+ MD_TRC_L1Audio_Msg_AM_DSP_GAIN(AM_Gain_Name(4), digitalVol);
+}
+
diff --git a/mcu/driver/audio/src/v1/amr_table.c b/mcu/driver/audio/src/v1/amr_table.c
new file mode 100644
index 0000000..83bb894
--- /dev/null
+++ b/mcu/driver/audio/src/v1/amr_table.c
@@ -0,0 +1,570 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * amr_table.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Various tables for AMR and AMR-WB speech codec.
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_general_types.h"
+
+
+static const kal_uint8 AMR1220[244] = { /* 12.2 kbps */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 23, 15, 16, 17, 18,
+ 19, 20, 21, 22, 24, 25, 26, 27, 28, 38,
+ 141, 39, 142, 40, 143, 41, 144, 42, 145, 43,
+ 146, 44, 147, 45, 148, 46, 149, 47, 97, 150,
+ 200, 48, 98, 151, 201, 49, 99, 152, 202, 86,
+ 136, 189, 239, 87, 137, 190, 240, 88, 138, 191,
+ 241, 91, 194, 92, 195, 93, 196, 94, 197, 95,
+ 198, 29, 30, 31, 32, 33, 34, 35, 50, 100,
+ 153, 203, 89, 139, 192, 242, 51, 101, 154, 204,
+ 55, 105, 158, 208, 90, 140, 193, 243, 59, 109,
+ 162, 212, 63, 113, 166, 216, 67, 117, 170, 220,
+ 36, 37, 54, 53, 52, 58, 57, 56, 62, 61,
+ 60, 66, 65, 64, 70, 69, 68, 104, 103, 102,
+ 108, 107, 106, 112, 111, 110, 116, 115, 114, 120,
+ 119, 118, 157, 156, 155, 161, 160, 159, 165, 164,
+ 163, 169, 168, 167, 173, 172, 171, 207, 206, 205,
+ 211, 210, 209, 215, 214, 213, 219, 218, 217, 223,
+ 222, 221, 73, 72, 71, 76, 75, 74, 79, 78,
+ 77, 82, 81, 80, 85, 84, 83, 123, 122, 121,
+ 126, 125, 124, 129, 128, 127, 132, 131, 130, 135,
+ 134, 133, 176, 175, 174, 179, 178, 177, 182, 181,
+ 180, 185, 184, 183, 188, 187, 186, 226, 225, 224,
+ 229, 228, 227, 232, 231, 230, 235, 234, 233, 238,
+ 237, 236, 96, 199
+};
+
+static const kal_uint8 AMR1020[204] = { /* 10.2 kbps */
+ 7, 6, 5, 4, 3, 2, 1, 0, 16, 15,
+ 14, 13, 12, 11, 10, 9, 8, 26, 27, 28,
+ 29, 30, 31, 115, 116, 117, 118, 119, 120, 72,
+ 73, 161, 162, 65, 68, 69, 108, 111, 112, 154,
+ 157, 158, 197, 200, 201, 32, 33, 121, 122, 74,
+ 75, 163, 164, 66, 109, 155, 198, 19, 23, 21,
+ 22, 18, 17, 20, 24, 25, 37, 36, 35, 34,
+ 80, 79, 78, 77, 126, 125, 124, 123, 169, 168,
+ 167, 166, 70, 67, 71, 113, 110, 114, 159, 156,
+ 160, 202, 199, 203, 76, 165, 81, 82, 92, 91,
+ 93, 83, 95, 85, 84, 94, 101, 102, 96, 104,
+ 86, 103, 87, 97, 127, 128, 138, 137, 139, 129,
+ 141, 131, 130, 140, 147, 148, 142, 150, 132, 149,
+ 133, 143, 170, 171, 181, 180, 182, 172, 184, 174,
+ 173, 183, 190, 191, 185, 193, 175, 192, 176, 186,
+ 38, 39, 49, 48, 50, 40, 52, 42, 41, 51,
+ 58, 59, 53, 61, 43, 60, 44, 54, 194, 179,
+ 189, 196, 177, 195, 178, 187, 188, 151, 136, 146,
+ 153, 134, 152, 135, 144, 145, 105, 90, 100, 107,
+ 88, 106, 89, 98, 99, 62, 47, 57, 64, 45,
+ 63, 46, 55, 56
+};
+
+static const kal_uint8 AMR0795[159] = { /* 7.95 kbps */
+ 8, 7, 6, 5, 4, 3, 2, 14, 16, 9,
+ 10, 12, 13, 15, 11, 17, 20, 22, 24, 23,
+ 19, 18, 21, 56, 88, 122, 154, 57, 89, 123,
+ 155, 58, 90, 124, 156, 52, 84, 118, 150, 53,
+ 85, 119, 151, 27, 93, 28, 94, 29, 95, 30,
+ 96, 31, 97, 61, 127, 62, 128, 63, 129, 59,
+ 91, 125, 157, 32, 98, 64, 130, 1, 0, 25,
+ 26, 33, 99, 34, 100, 65, 131, 66, 132, 54,
+ 86, 120, 152, 60, 92, 126, 158, 55, 87, 121,
+ 153, 117, 116, 115, 46, 78, 112, 144, 43, 75,
+ 109, 141, 40, 72, 106, 138, 36, 68, 102, 134,
+ 114, 149, 148, 147, 146, 83, 82, 81, 80, 51,
+ 50, 49, 48, 47, 45, 44, 42, 39, 35, 79,
+ 77, 76, 74, 71, 67, 113, 111, 110, 108, 105,
+ 101, 145, 143, 142, 140, 137, 133, 41, 73, 107,
+ 139, 37, 69, 103, 135, 38, 70, 104, 136
+};
+
+static const kal_uint8 AMR0740[148] = { /* 7.4 kbps */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 26, 87, 27,
+ 88, 28, 89, 29, 90, 30, 91, 51, 80, 112,
+ 141, 52, 81, 113, 142, 54, 83, 115, 144, 55,
+ 84, 116, 145, 58, 119, 59, 120, 21, 22, 23,
+ 17, 18, 19, 31, 60, 92, 121, 56, 85, 117,
+ 146, 20, 24, 25, 50, 79, 111, 140, 57, 86,
+ 118, 147, 49, 78, 110, 139, 48, 77, 53, 82,
+ 114, 143, 109, 138, 47, 76, 108, 137, 32, 33,
+ 61, 62, 93, 94, 122, 123, 41, 42, 43, 44,
+ 45, 46, 70, 71, 72, 73, 74, 75, 102, 103,
+ 104, 105, 106, 107, 131, 132, 133, 134, 135, 136,
+ 34, 63, 95, 124, 35, 64, 96, 125, 36, 65,
+ 97, 126, 37, 66, 98, 127, 38, 67, 99, 128,
+ 39, 68, 100, 129, 40, 69, 101, 130
+};
+
+static const kal_uint8 AMR0670[134] = { /* 6.7 kbps */
+ 0, 1, 4, 3, 5, 6, 13, 7, 2, 8,
+ 9, 11, 15, 12, 14, 10, 28, 82, 29, 83,
+ 27, 81, 26, 80, 30, 84, 16, 55, 109, 56,
+ 110, 31, 85, 57, 111, 48, 73, 102, 127, 32,
+ 86, 51, 76, 105, 130, 52, 77, 106, 131, 58,
+ 112, 33, 87, 19, 23, 53, 78, 107, 132, 21,
+ 22, 18, 17, 20, 24, 25, 50, 75, 104, 129,
+ 47, 72, 101, 126, 54, 79, 108, 133, 46, 71,
+ 100, 125, 128, 103, 74, 49, 45, 70, 99, 124,
+ 42, 67, 96, 121, 39, 64, 93, 118, 38, 63,
+ 92, 117, 35, 60, 89, 114, 34, 59, 88, 113,
+ 44, 69, 98, 123, 43, 68, 97, 122, 41, 66,
+ 95, 120, 40, 65, 94, 119, 37, 62, 91, 116,
+ 36, 61, 90, 115
+};
+
+static const kal_uint8 AMR0590[118] = { /* 5.9 kbps */
+ 0, 1, 4, 5, 3, 6, 7, 2, 13, 15,
+ 8, 9, 11, 12, 14, 10, 16, 28, 74, 29,
+ 75, 27, 73, 26, 72, 30, 76, 51, 97, 50,
+ 71, 96, 117, 31, 77, 52, 98, 49, 70, 95,
+ 116, 53, 99, 32, 78, 33, 79, 48, 69, 94,
+ 115, 47, 68, 93, 114, 46, 67, 92, 113, 19,
+ 21, 23, 22, 18, 17, 20, 24, 111, 43, 89,
+ 110, 64, 65, 44, 90, 25, 45, 66, 91, 112,
+ 54, 100, 40, 61, 86, 107, 39, 60, 85, 106,
+ 36, 57, 82, 103, 35, 56, 81, 102, 34, 55,
+ 80, 101, 42, 63, 88, 109, 41, 62, 87, 108,
+ 38, 59, 84, 105, 37, 58, 83, 104
+};
+
+static const kal_uint8 AMR0515[103] = { /* 5.15 kbps */
+ 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
+ 13, 12, 11, 10, 9, 8, 23, 24, 25, 26,
+ 27, 46, 65, 84, 45, 44, 43, 64, 63, 62,
+ 83, 82, 81, 102, 101, 100, 42, 61, 80, 99,
+ 28, 47, 66, 85, 18, 41, 60, 79, 98, 29,
+ 48, 67, 17, 20, 22, 40, 59, 78, 97, 21,
+ 30, 49, 68, 86, 19, 16, 87, 39, 38, 58,
+ 57, 77, 35, 54, 73, 92, 76, 96, 95, 36,
+ 55, 74, 93, 32, 51, 33, 52, 70, 71, 89,
+ 90, 31, 50, 69, 88, 37, 56, 75, 94, 34,
+ 53, 72, 91
+};
+
+static const kal_uint8 AMR0475[95] = { /* 4.75 kbps */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 23, 24, 25, 26,
+ 27, 28, 48, 49, 61, 62, 82, 83, 47, 46,
+ 45, 44, 81, 80, 79, 78, 17, 18, 20, 22,
+ 77, 76, 75, 74, 29, 30, 43, 42, 41, 40,
+ 38, 39, 16, 19, 21, 50, 51, 59, 60, 63,
+ 64, 72, 73, 84, 85, 93, 94, 32, 33, 35,
+ 36, 53, 54, 56, 57, 66, 67, 69, 70, 87,
+ 88, 90, 91, 34, 55, 68, 89, 37, 58, 71,
+ 92, 31, 52, 65, 86
+};
+
+
+static const kal_uint16 AMRWB2385[477] = { /* 23.85 kbps */
+ 0, 4, 6, 145, 251, 360, 466, 7, 5, 3,
+ 47, 48, 49, 50, 51, 262, 263, 264, 265, 266,
+ 146, 252, 361, 467, 151, 257, 366, 472, 148, 254,
+ 363, 469, 149, 255, 364, 470, 156, 371, 150, 256,
+ 365, 471, 147, 253, 362, 468, 52, 2, 1, 157,
+ 372, 267, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 268, 31, 152, 153, 154, 155, 258, 259, 260, 261,
+ 367, 368, 369, 370, 473, 474, 475, 476, 158, 373,
+ 9, 33, 11, 159, 374, 54, 269, 28, 27, 160,
+ 375, 34, 35, 29, 46, 32, 30, 55, 270, 37,
+ 36, 39, 38, 40, 161, 376, 41, 42, 43, 44,
+ 45, 56, 162, 271, 377, 185, 196, 174, 79, 57,
+ 411, 90, 163, 305, 389, 378, 283, 68, 187, 400,
+ 294, 198, 307, 92, 70, 186, 413, 176, 59, 91,
+ 58, 412, 380, 165, 81, 164, 272, 175, 80, 401,
+ 402, 390, 391, 197, 306, 69, 274, 273, 379, 285,
+ 296, 284, 295, 188, 60, 199, 82, 93, 71, 381,
+ 414, 177, 166, 456, 308, 403, 98, 76, 286, 61,
+ 275, 386, 135, 423, 171, 102, 392, 204, 87, 182,
+ 65, 94, 208, 124, 72, 350, 193, 313, 393, 408,
+ 445, 309, 230, 419, 297, 241, 113, 219, 189, 128,
+ 317, 415, 116, 328, 200, 339, 382, 434, 178, 64,
+ 404, 83, 437, 223, 134, 192, 444, 112, 439, 139,
+ 287, 167, 448, 212, 459, 222, 240, 233, 97, 302,
+ 397, 234, 170, 276, 181, 455, 229, 438, 101, 280,
+ 138, 127, 298, 117, 355, 203, 426, 95, 140, 244,
+ 422, 407, 213, 129, 291, 354, 105, 245, 449, 86,
+ 316, 460, 207, 353, 190, 107, 224, 427, 342, 327,
+ 106, 321, 118, 123, 73, 211, 433, 218, 396, 385,
+ 450, 62, 383, 349, 75, 461, 172, 331, 168, 246,
+ 428, 332, 312, 201, 343, 416, 279, 63, 195, 333,
+ 96, 173, 235, 288, 320, 191, 418, 84, 205, 100,
+ 67, 394, 179, 344, 206, 338, 277, 405, 388, 395,
+ 301, 315, 421, 183, 293, 322, 310, 384, 410, 194,
+ 184, 89, 99, 103, 236, 78, 88, 77, 136, 399,
+ 169, 202, 406, 125, 180, 440, 74, 387, 242, 231,
+ 66, 281, 290, 141, 314, 424, 114, 85, 130, 356,
+ 119, 299, 304, 398, 237, 409, 311, 417, 292, 457,
+ 435, 225, 214, 209, 462, 108, 282, 446, 220, 351,
+ 345, 142, 247, 329, 420, 463, 318, 300, 120, 109,
+ 289, 451, 278, 441, 340, 303, 430, 215, 323, 226,
+ 334, 131, 442, 248, 335, 357, 429, 324, 143, 346,
+ 452, 238, 110, 216, 464, 249, 121, 431, 358, 227,
+ 132, 453, 336, 425, 325, 347, 126, 104, 137, 458,
+ 352, 243, 447, 115, 341, 210, 330, 221, 232, 436,
+ 465, 319, 359, 111, 454, 228, 217, 122, 443, 348,
+ 239, 250, 133, 144, 432, 337, 326
+};
+
+static const kal_uint16 AMRWB2305[461] = { /* 23.05 kbps */
+ 0, 4, 6, 145, 247, 352, 454, 7, 5, 3,
+ 47, 48, 49, 50, 51, 254, 255, 256, 257, 258,
+ 146, 248, 353, 455, 151, 253, 358, 460, 148, 250,
+ 355, 457, 149, 251, 356, 458, 152, 359, 150, 252,
+ 357, 459, 147, 249, 354, 456, 52, 2, 1, 153,
+ 360, 259, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 260, 31, 154, 361, 9, 33, 11, 155, 362, 54,
+ 261, 28, 27, 156, 363, 34, 35, 29, 46, 32,
+ 30, 55, 262, 37, 36, 39, 38, 40, 157, 364,
+ 41, 42, 43, 44, 45, 56, 158, 263, 365, 181,
+ 192, 170, 79, 57, 399, 90, 159, 297, 377, 366,
+ 275, 68, 183, 388, 286, 194, 299, 92, 70, 182,
+ 401, 172, 59, 91, 58, 400, 368, 161, 81, 160,
+ 264, 171, 80, 389, 390, 378, 379, 193, 298, 69,
+ 266, 265, 367, 277, 288, 276, 287, 184, 60, 195,
+ 82, 93, 71, 369, 402, 173, 162, 444, 300, 391,
+ 98, 76, 278, 61, 267, 374, 135, 411, 167, 102,
+ 380, 200, 87, 178, 65, 94, 204, 124, 72, 342,
+ 189, 305, 381, 396, 433, 301, 226, 407, 289, 237,
+ 113, 215, 185, 128, 309, 403, 116, 320, 196, 331,
+ 370, 422, 174, 64, 392, 83, 425, 219, 134, 188,
+ 432, 112, 427, 139, 279, 163, 436, 208, 447, 218,
+ 236, 229, 97, 294, 385, 230, 166, 268, 177, 443,
+ 225, 426, 101, 272, 138, 127, 290, 117, 347, 199,
+ 414, 95, 140, 240, 410, 395, 209, 129, 283, 346,
+ 105, 241, 437, 86, 308, 448, 203, 345, 186, 107,
+ 220, 415, 334, 319, 106, 313, 118, 123, 73, 207,
+ 421, 214, 384, 373, 438, 62, 371, 341, 75, 449,
+ 168, 323, 164, 242, 416, 324, 304, 197, 335, 404,
+ 271, 63, 191, 325, 96, 169, 231, 280, 312, 187,
+ 406, 84, 201, 100, 67, 382, 175, 336, 202, 330,
+ 269, 393, 376, 383, 293, 307, 409, 179, 285, 314,
+ 302, 372, 398, 190, 180, 89, 99, 103, 232, 78,
+ 88, 77, 136, 387, 165, 198, 394, 125, 176, 428,
+ 74, 375, 238, 227, 66, 273, 282, 141, 306, 412,
+ 114, 85, 130, 348, 119, 291, 296, 386, 233, 397,
+ 303, 405, 284, 445, 423, 221, 210, 205, 450, 108,
+ 274, 434, 216, 343, 337, 142, 243, 321, 408, 451,
+ 310, 292, 120, 109, 281, 439, 270, 429, 332, 295,
+ 418, 211, 315, 222, 326, 131, 430, 244, 327, 349,
+ 417, 316, 143, 338, 440, 234, 110, 212, 452, 245,
+ 121, 419, 350, 223, 132, 441, 328, 413, 317, 339,
+ 126, 104, 137, 446, 344, 239, 435, 115, 333, 206,
+ 322, 217, 228, 424, 453, 311, 351, 111, 442, 224,
+ 213, 122, 431, 340, 235, 246, 133, 144, 420, 329,
+ 318
+};
+
+static const kal_uint16 AMRWB1985[397] = { /* 19.85 kbps */
+ 0, 4, 6, 129, 215, 304, 390, 7, 5, 3,
+ 47, 48, 49, 50, 51, 222, 223, 224, 225, 226,
+ 130, 216, 305, 391, 135, 221, 310, 396, 132, 218,
+ 307, 393, 133, 219, 308, 394, 136, 311, 134, 220,
+ 309, 395, 131, 217, 306, 392, 52, 2, 1, 137,
+ 312, 227, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 228, 31, 138, 313, 9, 33, 11, 139, 314, 54,
+ 229, 28, 27, 140, 315, 34, 35, 29, 46, 32,
+ 30, 55, 230, 37, 36, 39, 38, 40, 141, 316,
+ 41, 42, 43, 44, 45, 56, 142, 231, 317, 63,
+ 73, 92, 340, 82, 324, 149, 353, 159, 334, 165,
+ 338, 178, 163, 254, 77, 168, 257, 153, 343, 57,
+ 248, 238, 79, 252, 166, 67, 80, 201, 101, 267,
+ 143, 164, 341, 255, 339, 187, 376, 318, 78, 328,
+ 362, 115, 232, 242, 253, 290, 276, 62, 58, 158,
+ 68, 93, 179, 319, 148, 169, 154, 72, 385, 329,
+ 333, 344, 102, 83, 144, 233, 323, 124, 243, 192,
+ 354, 237, 64, 247, 202, 209, 150, 116, 335, 268,
+ 239, 299, 188, 196, 298, 94, 195, 258, 123, 363,
+ 384, 109, 325, 371, 170, 370, 84, 110, 295, 180,
+ 74, 210, 191, 106, 291, 205, 367, 381, 377, 206,
+ 355, 122, 119, 120, 383, 160, 105, 108, 277, 380,
+ 294, 284, 285, 345, 208, 269, 249, 366, 386, 300,
+ 297, 259, 125, 369, 197, 97, 194, 286, 211, 281,
+ 280, 183, 372, 87, 155, 283, 59, 348, 327, 184,
+ 76, 111, 330, 203, 349, 69, 98, 152, 145, 189,
+ 66, 320, 337, 173, 358, 251, 198, 174, 263, 262,
+ 126, 241, 193, 88, 388, 117, 95, 387, 112, 359,
+ 287, 244, 103, 272, 301, 171, 162, 234, 273, 127,
+ 373, 181, 292, 85, 378, 302, 121, 107, 364, 346,
+ 356, 212, 278, 213, 65, 382, 288, 207, 113, 175,
+ 99, 296, 374, 368, 199, 260, 185, 336, 331, 161,
+ 270, 264, 250, 240, 75, 350, 151, 60, 89, 321,
+ 156, 274, 360, 326, 70, 282, 167, 146, 352, 81,
+ 91, 389, 266, 245, 177, 235, 190, 256, 204, 342,
+ 128, 118, 303, 104, 379, 182, 114, 375, 200, 96,
+ 293, 172, 214, 365, 279, 86, 289, 351, 347, 357,
+ 261, 186, 176, 271, 90, 100, 147, 322, 275, 361,
+ 71, 332, 61, 265, 157, 246, 236
+};
+
+static const kal_uint16 AMRWB1825[365] = { /* 18.25 kbps */
+ 0, 4, 6, 121, 199, 280, 358, 7, 5, 3,
+ 47, 48, 49, 50, 51, 206, 207, 208, 209, 210,
+ 122, 200, 281, 359, 127, 205, 286, 364, 124, 202,
+ 283, 361, 125, 203, 284, 362, 128, 287, 126, 204,
+ 285, 363, 123, 201, 282, 360, 52, 2, 1, 129,
+ 288, 211, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 212, 31, 130, 289, 9, 33, 11, 131, 290, 54,
+ 213, 28, 27, 132, 291, 34, 35, 29, 46, 32,
+ 30, 55, 214, 37, 36, 39, 38, 40, 133, 292,
+ 41, 42, 43, 44, 45, 56, 134, 215, 293, 198,
+ 299, 136, 120, 138, 60, 279, 58, 62, 357, 139,
+ 140, 295, 156, 57, 219, 297, 63, 217, 137, 170,
+ 300, 222, 64, 106, 61, 78, 294, 92, 142, 141,
+ 135, 221, 296, 301, 343, 59, 298, 184, 329, 315,
+ 220, 216, 265, 251, 218, 237, 352, 223, 157, 86,
+ 171, 87, 164, 351, 111, 302, 65, 178, 115, 323,
+ 72, 192, 101, 179, 93, 73, 193, 151, 337, 309,
+ 143, 274, 69, 324, 165, 150, 97, 338, 110, 310,
+ 330, 273, 68, 107, 175, 245, 114, 79, 113, 189,
+ 246, 259, 174, 71, 185, 96, 344, 100, 322, 83,
+ 334, 316, 333, 252, 161, 348, 147, 82, 269, 232,
+ 260, 308, 353, 347, 163, 231, 306, 320, 188, 270,
+ 146, 177, 266, 350, 256, 85, 149, 116, 191, 160,
+ 238, 258, 336, 305, 255, 88, 224, 99, 339, 230,
+ 228, 227, 272, 242, 241, 319, 233, 311, 102, 74,
+ 180, 275, 66, 194, 152, 325, 172, 247, 244, 261,
+ 117, 158, 166, 354, 75, 144, 108, 312, 94, 186,
+ 303, 80, 234, 89, 195, 112, 340, 181, 345, 317,
+ 326, 276, 239, 167, 118, 313, 70, 355, 327, 253,
+ 190, 176, 271, 104, 98, 153, 103, 90, 76, 267,
+ 277, 248, 225, 262, 182, 84, 154, 235, 335, 168,
+ 331, 196, 341, 249, 162, 307, 148, 349, 263, 321,
+ 257, 243, 229, 356, 159, 119, 67, 187, 173, 145,
+ 240, 77, 304, 332, 314, 342, 109, 254, 81, 278,
+ 105, 91, 346, 318, 183, 250, 197, 328, 95, 155,
+ 169, 268, 226, 236, 264
+};
+
+static const kal_uint16 AMRWB1585[317] = { /* 15.85 kbps */
+ 0, 4, 6, 109, 175, 244, 310, 7, 5, 3,
+ 47, 48, 49, 50, 51, 182, 183, 184, 185, 186,
+ 110, 176, 245, 311, 115, 181, 250, 316, 112, 178,
+ 247, 313, 113, 179, 248, 314, 116, 251, 114, 180,
+ 249, 315, 111, 177, 246, 312, 52, 2, 1, 117,
+ 252, 187, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 188, 31, 118, 253, 9, 33, 11, 119, 254, 54,
+ 189, 28, 27, 120, 255, 34, 35, 29, 46, 32,
+ 30, 55, 190, 37, 36, 39, 38, 40, 121, 256,
+ 41, 42, 43, 44, 45, 56, 122, 191, 257, 63,
+ 129, 198, 264, 76, 142, 211, 277, 89, 155, 224,
+ 290, 102, 168, 237, 303, 57, 123, 192, 258, 70,
+ 136, 205, 271, 83, 149, 218, 284, 96, 162, 231,
+ 297, 62, 128, 197, 263, 75, 141, 210, 276, 88,
+ 154, 223, 289, 101, 167, 236, 302, 58, 124, 193,
+ 259, 71, 137, 206, 272, 84, 150, 219, 285, 97,
+ 163, 232, 298, 59, 125, 194, 260, 64, 130, 199,
+ 265, 67, 133, 202, 268, 72, 138, 207, 273, 77,
+ 143, 212, 278, 80, 146, 215, 281, 85, 151, 220,
+ 286, 90, 156, 225, 291, 93, 159, 228, 294, 98,
+ 164, 233, 299, 103, 169, 238, 304, 106, 172, 241,
+ 307, 60, 126, 195, 261, 65, 131, 200, 266, 68,
+ 134, 203, 269, 73, 139, 208, 274, 78, 144, 213,
+ 279, 81, 147, 216, 282, 86, 152, 221, 287, 91,
+ 157, 226, 292, 94, 160, 229, 295, 99, 165, 234,
+ 300, 104, 170, 239, 305, 107, 173, 242, 308, 61,
+ 127, 196, 262, 66, 132, 201, 267, 69, 135, 204,
+ 270, 74, 140, 209, 275, 79, 145, 214, 280, 82,
+ 148, 217, 283, 87, 153, 222, 288, 92, 158, 227,
+ 293, 95, 161, 230, 296, 100, 166, 235, 301, 105,
+ 171, 240, 306, 108, 174, 243, 309
+};
+
+static const kal_uint16 AMRWB1425[285] = { /* 14.25 kbps */
+ 0, 4, 6, 101, 159, 220, 278, 7, 5, 3,
+ 47, 48, 49, 50, 51, 166, 167, 168, 169, 170,
+ 102, 160, 221, 279, 107, 165, 226, 284, 104, 162,
+ 223, 281, 105, 163, 224, 282, 108, 227, 106, 164,
+ 225, 283, 103, 161, 222, 280, 52, 2, 1, 109,
+ 228, 171, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 172, 31, 110, 229, 9, 33, 11, 111, 230, 54,
+ 173, 28, 27, 112, 231, 34, 35, 29, 46, 32,
+ 30, 55, 174, 37, 36, 39, 38, 40, 113, 232,
+ 41, 42, 43, 44, 45, 56, 114, 175, 233, 62,
+ 120, 181, 239, 75, 133, 194, 252, 57, 115, 176,
+ 234, 63, 121, 182, 240, 70, 128, 189, 247, 76,
+ 134, 195, 253, 83, 141, 202, 260, 92, 150, 211,
+ 269, 84, 142, 203, 261, 93, 151, 212, 270, 85,
+ 143, 204, 262, 94, 152, 213, 271, 86, 144, 205,
+ 263, 95, 153, 214, 272, 64, 122, 183, 241, 77,
+ 135, 196, 254, 65, 123, 184, 242, 78, 136, 197,
+ 255, 87, 145, 206, 264, 96, 154, 215, 273, 58,
+ 116, 177, 235, 66, 124, 185, 243, 71, 129, 190,
+ 248, 79, 137, 198, 256, 88, 146, 207, 265, 97,
+ 155, 216, 274, 59, 117, 178, 236, 67, 125, 186,
+ 244, 72, 130, 191, 249, 80, 138, 199, 257, 89,
+ 147, 208, 266, 98, 156, 217, 275, 60, 118, 179,
+ 237, 68, 126, 187, 245, 73, 131, 192, 250, 81,
+ 139, 200, 258, 90, 148, 209, 267, 99, 157, 218,
+ 276, 61, 119, 180, 238, 69, 127, 188, 246, 74,
+ 132, 193, 251, 82, 140, 201, 259, 91, 149, 210,
+ 268, 100, 158, 219, 277
+};
+
+
+static const kal_uint16 AMRWB1265[253] = { /* 12.65 kbps */
+ 0, 4, 6, 93, 143, 196, 246, 7, 5, 3,
+ 47, 48, 49, 50, 51, 150, 151, 152, 153, 154,
+ 94, 144, 197, 247, 99, 149, 202, 252, 96, 146,
+ 199, 249, 97, 147, 200, 250, 100, 203, 98, 148,
+ 201, 251, 95, 145, 198, 248, 52, 2, 1, 101,
+ 204, 155, 19, 21, 12, 17, 18, 20, 16, 25,
+ 13, 10, 14, 24, 23, 22, 26, 8, 15, 53,
+ 156, 31, 102, 205, 9, 33, 11, 103, 206, 54,
+ 157, 28, 27, 104, 207, 34, 35, 29, 46, 32,
+ 30, 55, 158, 37, 36, 39, 38, 40, 105, 208,
+ 41, 42, 43, 44, 45, 56, 106, 159, 209, 57,
+ 66, 75, 84, 107, 116, 125, 134, 160, 169, 178,
+ 187, 210, 219, 228, 237, 58, 108, 161, 211, 62,
+ 112, 165, 215, 67, 117, 170, 220, 71, 121, 174,
+ 224, 76, 126, 179, 229, 80, 130, 183, 233, 85,
+ 135, 188, 238, 89, 139, 192, 242, 59, 109, 162,
+ 212, 63, 113, 166, 216, 68, 118, 171, 221, 72,
+ 122, 175, 225, 77, 127, 180, 230, 81, 131, 184,
+ 234, 86, 136, 189, 239, 90, 140, 193, 243, 60,
+ 110, 163, 213, 64, 114, 167, 217, 69, 119, 172,
+ 222, 73, 123, 176, 226, 78, 128, 181, 231, 82,
+ 132, 185, 235, 87, 137, 190, 240, 91, 141, 194,
+ 244, 61, 111, 164, 214, 65, 115, 168, 218, 70,
+ 120, 173, 223, 74, 124, 177, 227, 79, 129, 182,
+ 232, 83, 133, 186, 236, 88, 138, 191, 241, 92,
+ 142, 195, 245
+};
+
+static const kal_uint16 AMRWB0885[177] = { /* 8.85 kbps */
+ 0, 4, 6, 7, 5, 3, 47, 48, 49, 112,
+ 113, 114, 75, 106, 140, 171, 80, 111, 145, 176,
+ 77, 108, 142, 173, 78, 109, 143, 174, 79, 110,
+ 144, 175, 76, 107, 141, 172, 50, 115, 51, 2,
+ 1, 81, 116, 146, 19, 21, 12, 17, 18, 20,
+ 16, 25, 13, 10, 14, 24, 23, 22, 26, 8,
+ 15, 52, 117, 31, 82, 147, 9, 33, 11, 83,
+ 148, 53, 118, 28, 27, 84, 149, 34, 35, 29,
+ 46, 32, 30, 54, 119, 37, 36, 39, 38, 40,
+ 85, 150, 41, 42, 43, 44, 45, 55, 60, 65,
+ 70, 86, 91, 96, 101, 120, 125, 130, 135, 151,
+ 156, 161, 166, 56, 87, 121, 152, 61, 92, 126,
+ 157, 66, 97, 131, 162, 71, 102, 136, 167, 57,
+ 88, 122, 153, 62, 93, 127, 158, 67, 98, 132,
+ 163, 72, 103, 137, 168, 58, 89, 123, 154, 63,
+ 94, 128, 159, 68, 99, 133, 164, 73, 104, 138,
+ 169, 59, 90, 124, 155, 64, 95, 129, 160, 69,
+ 100, 134, 165, 74, 105, 139, 170
+};
+
+static const kal_uint16 AMRWB0660[132] = { /* 6.60 kbps */
+ 0, 5, 6, 7, 61, 84, 107, 130, 62, 85,
+ 8, 4, 37, 38, 39, 40, 58, 81, 104, 127,
+ 60, 83, 106, 129, 108, 131, 128, 41, 42, 80,
+ 126, 1, 3, 57, 103, 82, 105, 59, 2, 63,
+ 109, 110, 86, 19, 22, 23, 64, 87, 18, 20,
+ 21, 17, 13, 88, 43, 89, 65, 111, 14, 24,
+ 25, 26, 27, 28, 15, 16, 44, 90, 66, 112,
+ 9, 11, 10, 12, 67, 113, 29, 30, 31, 32,
+ 34, 33, 35, 36, 45, 51, 68, 74, 91, 97,
+ 114, 120, 46, 69, 92, 115, 52, 75, 98, 121,
+ 47, 70, 93, 116, 53, 76, 99, 122, 48, 71,
+ 94, 117, 54, 77, 100, 123, 49, 72, 95, 118,
+ 55, 78, 101, 124, 50, 73, 96, 119, 56, 79,
+ 102, 125
+};
+
+const kal_uint8* tblAMROrder[8] = {
+ AMR0475, AMR0515, AMR0590, AMR0670,
+ AMR0740, AMR0795, AMR1020, AMR1220
+};
+
+
+const kal_uint16* tblAMR_WBOrder[9] = {
+ AMRWB0660, AMRWB0885, AMRWB1265, AMRWB1425,
+ AMRWB1585, AMRWB1825, AMRWB1985, AMRWB2305, AMRWB2385
+};
+
+
diff --git a/mcu/driver/audio/src/v1/apAudSysConfig.c b/mcu/driver/audio/src/v1/apAudSysConfig.c
new file mode 100644
index 0000000..4aad0eb
--- /dev/null
+++ b/mcu/driver/audio/src/v1/apAudSysConfig.c
@@ -0,0 +1,122 @@
+
+
+
+#if !defined(__SMART_PHONE_MODEM__)
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "reg_base.h"
+
+#include "dcl.h"
+
+#include "afe.h"
+
+#if defined(__ENABLE_SPEECH_DVT__)
+extern kal_bool Is_Sph_DVT_BT_Mode_NB(void);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+#define WriteREG(_addr, _value) (*(volatile kal_uint32 *)(_addr) = (_value))
+
+
+// ----------------------------------------------------------------------------
+// Register Definition
+// ----------------------------------------------------------------------------
+
+
+// #define AP_AUDSYS_BASE 0xA1220000
+
+#define AUDIO_TOP_CON0 (BASE_MADDR_AUDIO + 0x0000)
+#define AUDIO_TOP_CON1 (BASE_MADDR_AUDIO + 0x0004)
+//#define AUDIO_TOP_CON2 (BASE_MADDR_AUDIO + 0x0008)
+#define AUDIO_TOP_CON3 (BASE_MADDR_AUDIO + 0x000C)
+#define AFE_DAC_CON0 (BASE_MADDR_AUDIO + 0x0010)
+#define AFE_DAC_CON1 (BASE_MADDR_AUDIO + 0x0014)
+#define AFE_I2S_CON (BASE_MADDR_AUDIO + 0x0018)
+#define AFE_DAIBT_CON0 (BASE_MADDR_AUDIO + 0x001C)
+
+#define AP_AFE_CONN0 (BASE_MADDR_AUDIO + 0x0020)
+#define AP_AFE_CONN1 (BASE_MADDR_AUDIO + 0x0024)
+#define AP_AFE_CONN2 (BASE_MADDR_AUDIO + 0x0028)
+#define AP_AFE_CONN3 (BASE_MADDR_AUDIO + 0x002C)
+#define AP_AFE_CONN4 (BASE_MADDR_AUDIO + 0x0030)
+#define AP_AFE_CONN5 (BASE_MADDR_AUDIO + 0x005C)
+#define AP_AFE_CONN6 (BASE_MADDR_AUDIO + 0x00BC)
+#define AP_AFE_CONN9 (BASE_MADDR_AUDIO + 0x0468)
+#define AP_AFE_CONN10 (BASE_MADDR_AUDIO + 0x046C)
+
+#define AFE_I2S_CON1 (BASE_MADDR_AUDIO + 0x0034)
+#define AFE_I2S_CON2 (BASE_MADDR_AUDIO + 0x0038)
+#define AFE_MRGIF_CON (BASE_MADDR_AUDIO + 0x003C)
+#define AFE_I2S_CON3 (BASE_MADDR_AUDIO + 0x004C)
+
+#define AFE_ADDA_DL_SRC2_CON0 (BASE_MADDR_AUDIO + 0x0108)
+#define AFE_ADDA_DL_SRC2_CON1 (BASE_MADDR_AUDIO + 0x010C)
+#define AFE_ADDA_UL_SRC_CON0 (BASE_MADDR_AUDIO + 0x0114)
+#define AFE_ADDA_UL_SRC_CON1 (BASE_MADDR_AUDIO + 0x0118)
+
+#define AFE_ADDA_UL_DL_CON0 (BASE_MADDR_AUDIO + 0x0124)
+#define AFE_ADDA_NEWIF_CFG0 (BASE_MADDR_AUDIO + 0x0138)
+#define AFE_ADDA_NEWIF_CFG1 (BASE_MADDR_AUDIO + 0x013C)
+
+
+//#define AFE_SIDDETONE_MON (BASE_MADDR_AUDIO + 0x01D4)
+//#define AFE_SIDDETONE_CON0 (BASE_MADDR_AUDIO + 0x01E0)
+//#define AFE_SIDDETONE_COEFF (BASE_MADDR_AUDIO + 0x01E4)
+#define AFE_SIDDETONE_CON1 (BASE_MADDR_AUDIO + 0x01E8)
+//#define AFE_SIDDETONE_GAIN (BASE_MADDR_AUDIO + 0x01EC)
+
+#define AFE_SGEN_CON0 (BASE_MADDR_AUDIO + 0x01F0)
+#define AFE_TOP_CON0 (BASE_MADDR_AUDIO + 0x0200)
+#define AFE_GAIN1_CON0 (BASE_MADDR_AUDIO + 0x0410)
+
+#define AFE_GAIN1_CONN (BASE_MADDR_AUDIO + 0x0420)
+
+#define AFE_GAIN2_CON0 (BASE_MADDR_AUDIO + 0x0428)
+#define AFE_GAIN2_CONN (BASE_MADDR_AUDIO + 0x0438)
+#define AFE_GAIN2_CONN2 (BASE_MADDR_AUDIO + 0x0440)
+#define AFE_GAIN2_CONN3 (BASE_MADDR_AUDIO + 0x0444)
+
+#define PCM_INTF_CON1 (BASE_MADDR_AUDIO + 0x0530)
+#define PCM_INTF_CON2 (BASE_MADDR_AUDIO + 0x0538)
+#define PCM_INTF_CON (BASE_MADDR_AUDIO + 0x053C)
+//#define FOC_ROM_SIG (BASE_MADDR_AUDIO + 0x0630)
+
+
+
+// ----------------------------------------------------------------------------
+// Register Setting for different scenario
+// ----------------------------------------------------------------------------
+
+
+void PMIC_AudioConfig(void)
+{
+//For ELBRUS bring-up, loopback DL to UL by MD-AFE, and we can't control AP-AFE and PMIC.
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+}
+
+
+void ApAudSys_config(void)
+{
+//For ELBRUS bring-up, loopback DL to UL by MD-AFE, and we can't control AP-AFE and PMIC.
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+}
+
+
+#else // !defined(__SMART_PHONE_MODEM__)
+
+void ApAudSys_config(void)
+{
+ ;
+}
+
+#endif // !defined(__SMART_PHONE_MODEM__)
+
diff --git a/mcu/driver/audio/src/v1/audio_idma.c b/mcu/driver/audio/src/v1/audio_idma.c
new file mode 100644
index 0000000..c2b308c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/audio_idma.c
@@ -0,0 +1,207 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * L1audio_idma.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * transfer data by IDMA
+ * address-mode and short-mode could be predefined switched.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *===========================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *----------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *----------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *===========================================================
+*****************************************************************************/
+
+#include "reg_base.h"
+#include "sync_data.h"
+
+// #include "audio_def.h"
+#include "l1aud_common_def.h"
+
+/*void IDMA_WriteToDSP_Duplicate(volatile kal_uint16 *dst, kal_uint16 *src, kal_uint32 length)
+{
+ kal_int32 i;
+#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
+
+ for(i=length; i>0;i-=2)
+ {
+ *dst++ = *src;
+ *dst++ = *src++;
+ }
+#else
+
+ *dst = *src;
+ *IDMA_SHORT_ADDR = *src++;
+ for(i=length-2; i>0;i-=2)
+ {
+ *IDMA_SHORT_ADDR=*src;
+ *IDMA_SHORT_ADDR=*src++;
+ }
+#endif
+
+ Data_Sync_Barrier();
+}*/
+
+void EMI_WriteToDSP(kal_uint16 *dst, kal_uint16 *src, kal_uint32 length)
+{
+ //kal_int32 i;
+#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
+
+ //for(i=length; i>0;i--)
+ // *dst++ = *src++;
+ kal_mem_cpy(dst, (const void *)src, length<<1);
+#else
+
+ *dst = *src++;
+ for(i=length-1; i>0;i--)
+ *IDMA_SHORT_ADDR=*src++;
+
+#endif
+
+ Data_Sync_Barrier();
+}
+
+
+/*void IDMA_FillToDSP(volatile kal_uint16 *dst, kal_uint16 value, kal_uint32 length)
+{
+ kal_int32 i;
+#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
+
+ for(i=length; i>0;i--)
+ *dst++ = value;
+
+#else
+
+ *dst = value;
+ for(i=length-1; i>0;i--)
+ *IDMA_SHORT_ADDR=value;
+
+#endif
+
+ Data_Sync_Barrier();
+}*/
+
+void EMI_ReadFromDSP(kal_uint16 *dst, kal_uint16 *src, kal_uint32 length)
+{
+ //kal_int32 i;
+
+#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
+
+ //for( i = length; i > 0; i-- )
+ // *dst++ = *src++;
+ kal_mem_cpy(dst, (const void *)src, length<<1);
+#else
+
+ *dst = *src; // dummy read
+ for(i=length; i>0;i--)
+ *dst++ = *IDMA_SHORT_ADDR;
+
+#endif
+}
+/*
+void IDMA_ReadFromDSP_Skip_1(kal_uint16 *dst, volatile kal_uint16 *src, kal_uint32 length)
+{
+ kal_int32 i;
+
+#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
+
+ for( i = length; i > 0; i-- )
+ {
+ *dst++ = *src++;
+ dst++;
+ }
+
+#else
+
+ *dst = *src; // dummy read
+ for(i=length; i>0;i--)
+ {
+ *dst++ = *IDMA_SHORT_ADDR;
+ dst++;
+ }
+
+#endif
+}*/
+
diff --git a/mcu/driver/audio/src/v1/audio_service.c b/mcu/driver/audio/src/v1/audio_service.c
new file mode 100644
index 0000000..2774e5d
--- /dev/null
+++ b/mcu/driver/audio/src/v1/audio_service.c
@@ -0,0 +1,26704 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * l1audio_service.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * L1SP Task / L1Audio Service
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/audio_service.c#12
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/audio_service.c#13
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/audio_service.c
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+<<<<
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+#include "kal_hrt_api.h"
+#include "extcodec.h"
+#include "intrCtrl.h"
+#include "string.h"
+#include "hisr_config.h"
+#include "kal_public_defs.h"
+#include "sync_data.h"
+#include "reg_base.h"
+// #include "l1sm_public.h"
+#include "sp_cc.h"
+#include "sleepdrv_interface.h"
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "l1audio.h"
+// #include "audio_def.h"
+#include "media.h"
+#include "l1audio_trace_utmd.h"
+#include "ddload.h"
+#include "am.h"
+#include "afe.h"
+#include "l1aud_common_def.h"
+#include "cuif_l1core_public.h"
+//#include "speech_def.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+//for DSP_DynamicDownload(DDID_SPH_SCH);
+#include "ddload.h"
+#include "RM_public.h"
+#include "reg_base.h"
+//#include "drv_iomux.h"
+#if defined(__MD97__) || defined(__MD97P__)
+#include "dsp_module_based_api_public.h"
+#else //#if defined(__MD97__) || defined(__MD97P__)
+#include "usip_api_public.h"
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+
+#if defined(__SMART_PHONE_MODEM__)
+#include "bgSnd.h" // for BGSND_INIT()
+#endif // defined(__SMART_PHONE_MODEM__)
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+#include "bt_sco_drv.h"
+#endif
+
+#include "vm.h"
+#include "tone_drv.h"
+#include "pcm4way.h"
+#include "sp_daca.h"
+#include "rawpcmrec.h"
+#include "mml1_rf_global.h"
+#ifdef __FAKE_C2K_LOOPBACK__
+#include "lmd_audio.h"
+#endif
+#include "sp_dsptone_drv.h"
+#include "pcmMixer.h"
+#include "pcmMixer3.h"
+//#define TK6291_FAKE_COMPILE
+//#define TK6291_NO_SPEECH_HW
+
+#if defined( __UMTS_RAT__ ) || defined( __UMTS_TDD128_MODE__ )
+
+#if defined(__VOLTE_SUPPORT__)
+ #define MAX_HISR_HANDLER 25 // ramping, 3g(ul+dl), pnw(ul+dl), DACA for bt (ul+dl), vm, epl, bgsnd(ul+dl), record, 4G AMR (ul+dl), 4G G-codec (ul+dl), pcmmixer, voice quality
+#else //#if defined(__VOLTE_SUPPORT__)
+ #define MAX_HISR_HANDLER 21 // ramping, 3g, pnw, DACA for bt, vm, epl, bgsnd(ul+dl), record, cvsd, pcmmixer, voice quality
+#endif //#if defined(__VOLTE_SUPPORT__)
+#else // no 3g
+#define MAX_HISR_HANDLER 19 // ramping, pnw, DACA for bt, vm, epl, bgsnd(ul+dl), record, cvsd, pcmmixer, voice quality
+
+#endif
+
+void toneLoopbackRecInit( void );
+extern void DisableIRQ(void);
+
+
+#ifdef MTK_SLEEP_ENABLE
+ #include "sleepdrv_interface.h"
+ #define SLEEP_LOCK() { SleepDrv_LockSleep( SLEEP_CTL_SPEECH, SMP ); }
+ #define SLEEP_UNLOCK() { SleepDrv_UnlockSleep( SLEEP_CTL_SPEECH, SMP ); }
+#else
+ #define SLEEP_LOCK()
+ #define SLEEP_UNLOCK()
+#endif
+
+#ifndef TK6291_FAKE_COMPILE
+extern uint32 L1I_GetTimeStamp( void );
+#endif //#ifndef TK6291_FAKE_COMPILE
+
+#if defined(MTK_SLEEP_ENABLE)
+#if defined(__AUDIO_POWERON_RESET_DSP__)
+ #ifndef TK6291_FAKE_COMPILE
+ extern unsigned short cc_L1D_Audio_RestartDSP( void );
+ extern void cc_L1D_Audio_NoNeedDSP( void );
+ #endif //#ifndef TK6291_FAKE_COMPILE
+ // extern void AFE_Init_status(kal_bool flag);
+#else
+ #ifndef TK6291_FAKE_COMPILE
+ extern kal_uint8 L1SM_IntGetHandle( void );
+ extern void L1SM_Multi_SW_WakeUp(void);
+ extern void L1SM_IntSleepDisable( kal_uint8 handle );
+ extern void L1SM_IntSleepEnable( kal_uint8 handle );
+ extern kal_uint8 L1D_MD2G_PWD_GetHandle( void );
+ extern void L1D_MD2G_PWD_Disable( kal_uint8 handle );
+ extern void L1D_MD2G_PWD_Enable( kal_uint8 handle );
+ #endif //#ifndef TK6291_FAKE_COMPILE
+#endif // defined(__AUDIO_POWERON_RESET_DSP__)
+#endif //(defined( __CENTRALIZED_SLEEP_MANAGER__ ) && defined(MTK_SLEEP_ENABLE) )
+
+#if defined(__SMART_PHONE_MODEM__)
+extern void SpcIO_shmInit(void);
+#endif
+/* ------------------------------------------------------------------------------ */
+
+static struct {
+ uint32 sleppModeLocker;
+ uint32 dspUser;
+ kal_eventgrpid aud_events;
+ uint16 media_flag;
+ uint16 d2c_itype;
+ uint32 d2c_l1FN;
+ uint32 retrieved_events;
+ uint32 events_l1FN;
+
+ L1Audio_EventHandler evHandler[MAX_AUDIO_FUNCTIONS];
+ void *evData[MAX_AUDIO_FUNCTIONS];
+ uint32 id_flag;
+ uint32 event_flag;
+ L1Audio_EventHandler hisrHandler[MAX_HISR_HANDLER];
+ uint16 hisrMagicNo[MAX_HISR_HANDLER];
+ void *hisrUserData[MAX_HISR_HANDLER];
+ uint32 hisrMagicFlag;
+ uint8 sleep_handle;
+ int8 dsp_slow_idle_counter;
+#if defined(__MD97__) || defined(__MD97P__)
+ uint32 dsp_first_init_done;
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+
+ uint16 debug_info[NUM_DEBUG_INFO];
+
+ kal_uint8 md2g_pdn_handle;
+ kal_uint8 l1sm_handle;
+ kal_uint8 audio_dsp_count;
+ kal_semid sema;
+ bool is_Initialized;
+ bool isD2MIntAvalibaleUnderSleep; // does Dsp to MCU interrupt can trigger under MCU sleep
+ kal_spinlockid lisr_lockId;
+} l1audio;
+
+//#define L1_BASE_MADDR_SHARE_D1 REG_BASE(0xF77A0000)
+
+#define HW_WRITE(ptr,data) (*(ptr) = (data))
+#define HW_READ(ptr) (*(ptr))
+#define DSP_WRITE(addr, data) HW_WRITE(addr, (kal_uint16)(data) )
+#define DSP_READ(addr) HW_READ(addr)
+
+//#define DP_D2C_TASK4 ((APBADDR)(AFE_SHARED_REGISTER_BASE+0x0060)) /* 4th FW tsk interrupt */
+//#define DP_D2C_TASK5 ((APBADDR)(AFE_SHARED_REGISTER_BASE+0x0064)) /* 5th FW tsk interrupt */
+//#define DP_D2C_TASK6 ((APBADDR)(AFE_SHARED_REGISTER_BASE+0x0068)) /* 6th FW tsk interrupt */
+//#define DP_D2C_TASK7 ((APBADDR)(AFE_SHARED_REGISTER_BASE+0x006C)) /* 6th FW tsk interrupt */
+/* ------------------------------------------------------------------------------ */
+#ifndef TK6291_FAKE_COMPILE
+extern void L1D_DSP_EnableDspSlowIdle( void );
+#endif //#ifndef TK6291_FAKE_COMPILE
+int8 L1Audio_Disable_DSPSlowIdle(void)
+{
+ int8 dis_check_counter;
+
+
+ l1audio.dsp_slow_idle_counter++;
+ dis_check_counter = l1audio.dsp_slow_idle_counter;
+
+ //DP_SLOW_IDLE_CTRL = 0xFFFF;
+
+
+ return dis_check_counter;
+}
+
+int8 L1Audio_Enable_DSPSlowIdle(void)
+{
+ int8 en_check_counter;
+
+
+ l1audio.dsp_slow_idle_counter--;
+ en_check_counter = l1audio.dsp_slow_idle_counter;
+
+#ifndef TK6291_FAKE_COMPILE
+ if ( l1audio.dsp_slow_idle_counter == 0 )
+ ;//L1D_DSP_EnableDspSlowIdle();
+#endif //#ifndef TK6291_FAKE_COMPILE
+
+
+ ASSERT( en_check_counter >= 0 );
+
+ return en_check_counter;
+}
+
+kal_bool L1Audio_CheckAudioID( kal_uint16 audio_id )
+{
+ if( l1audio.id_flag & (1 << audio_id) )
+ return true;
+ return false;
+}
+
+uint16 L1Audio_GetAudioID( void )
+{
+ kal_take_sem(l1audio.sema, KAL_INFINITE_WAIT);
+ uint32 I;
+ for (I = 0; I < MAX_AUDIO_FUNCTIONS; I++)
+ {
+ if ((l1audio.id_flag & (1 << I)) == 0)
+ {
+ l1audio.id_flag |= (1 << I);
+ break;
+ }
+ }
+ kal_give_sem(l1audio.sema);
+
+ ASSERT((l1audio.sleppModeLocker & (1 << I)) == 0);
+ ASSERT_REBOOT(I < MAX_AUDIO_FUNCTIONS);
+ return (uint16) I;
+}
+
+void L1Audio_FreeAudioID( uint16 aud_id )
+{
+ uint32 retrieved_events;
+ kal_retrieve_eg_events(l1audio.aud_events, (1 << aud_id), KAL_OR_CONSUME, &retrieved_events, 0);
+ ASSERT((l1audio.sleppModeLocker & (1 << aud_id)) == 0);
+ ASSERT(l1audio.id_flag & (1 << aud_id));
+
+ kal_take_sem(l1audio.sema, KAL_INFINITE_WAIT);
+ l1audio.id_flag &= ~(1 << aud_id);
+ l1audio.retrieved_events &= ~(1 << aud_id);
+ kal_give_sem(l1audio.sema);
+}
+
+void L1Audio_SetEventHandler( uint16 audio_id, L1Audio_EventHandler handler )
+{
+ l1audio.evHandler[audio_id] = handler;
+}
+
+void L1Audio_SetEvent( uint16 audio_id, void *data )
+{
+ l1audio.evData[audio_id] = data;
+ /* Activate L1Audio Task */
+ kal_set_eg_events( l1audio.aud_events, 1 << audio_id, KAL_OR );
+}
+
+void L1Audio_LSetEvent( uint16 audio_id, void *data )
+{
+//When run in P-core/Core2, we do not run under CTIRQ.
+#if 1
+ L1Audio_SetEvent( audio_id, data );
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+
+void L1Audio_CCSetEvent( void )
+{
+ /* Activate L1Audio HISR */
+ kal_hrt_activate_hisr_index(L1AUDIO_HISR);
+}
+
+bool L1Audio_CheckFlag( uint16 audio_id )
+{
+ ASSERT( l1audio.id_flag & (1 << audio_id) );
+ if( l1audio.sleppModeLocker & (1 << audio_id) )
+ return true;
+ return false;
+}
+
+
+static void Audio_Wake_DSP(uint16 audio_id, kal_bool flag)
+{
+ if (!kal_if_hisr() && !kal_if_lisr())
+ MD_TRC_L1AUDIO_MD2G_PWR_CTRL(audio_id, flag);
+ else
+ MD_TRC_L1AUDIO_MD2G_PWR_CTRL(audio_id, flag);
+
+ if(flag)
+ {
+ //MODEM_TOPSM_MD2G_PowerControl(KAL_TRUE);
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+#if defined(MTK_SLEEP_ENABLE)
+ // AFE_RegisterStore();
+ {
+ //unsigned short DSP_status;
+ //DSP_status = cc_L1D_Audio_RestartDSP();
+ //ASSERT(!DSP_status);
+ }
+ {
+ uint32 I = 0 ;
+ kal_uint32 core_id;
+ kal_runtime_affinity_to_current_vpe();
+ core_id = kal_get_current_core_id();
+ SleepDrv_LockSleep( SLEEP_CTL_SPEECH, core_id );
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for active1 uSip",core_id);
+#if defined(__MD97__) || defined(__MD97P__)
+ //dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ if(0 == l1audio.dsp_first_init_done)
+ {
+ dsp_firstboot_activate_by_module(L1_MODULE_SPEECH);
+ l1audio.dsp_first_init_done = 1;
+ }
+ else
+ {
+ dsp_activate_by_module(L1_MODULE_SPEECH);
+ }
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for active2 uSip",core_id);
+ kal_runtime_affinity_resume();
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_ACTIVATE_DONE != dsp_activate_done_check_by_module(L1_MODULE_SPEECH) ){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 3 );
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for active2 uSip",core_id);
+ kal_runtime_affinity_resume();
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 3 );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+ SleepDrv_UnlockSleep( SLEEP_CTL_SPEECH, core_id );
+ }
+#endif
+ l1audio.audio_dsp_count++;
+ } else {
+#if defined(MTK_SLEEP_ENABLE)
+ uint32 I = 0;
+ kal_uint32 core_id;
+ kal_runtime_affinity_to_current_vpe();
+ core_id = kal_get_current_core_id();
+ SleepDrv_LockSleep( SLEEP_CTL_SPEECH, core_id );
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for deactive1 uSip",core_id);
+#if defined(__MD97__) || defined(__MD97P__)
+ //dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ dsp_deactivate_by_module(L1_MODULE_SPEECH);
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for deactive2 uSip",core_id);
+ kal_runtime_affinity_resume();
+ //while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_DEACTIVATE_DONE != dsp_deactivate_done_check_by_module(L1_MODULE_SPEECH) ){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 5 );
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ kal_prompt_trace(MOD_L1SP, "lock sleep mode core:%d for deactive2 uSip",core_id);
+ kal_runtime_affinity_resume();
+ while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 5 );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+ SleepDrv_UnlockSleep( SLEEP_CTL_SPEECH, core_id );
+ // AFE_RegisterBackup(); //Backup AFE register
+ //cc_L1D_Audio_NoNeedDSP();
+#endif
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+ //MODEM_TOPSM_MD2G_PowerControl(KAL_FALSE);
+ l1audio.audio_dsp_count--;
+ }
+ if (!kal_if_hisr() && !kal_if_lisr())
+ MD_TRC_L1AUDIO_MD2G_PWR_CTRL_DONE(audio_id, flag);
+ else
+ MD_TRC_L1AUDIO_MD2G_PWR_CTRL_DONE(audio_id, flag);
+}
+
+void L1Audio_SetFlag( uint16 audio_id )
+{
+ if (!kal_if_hisr() && !kal_if_lisr())
+ MD_TRC_L1AUDIO_SETFLAG_A(audio_id,l1audio.dspUser);
+ else
+ MD_TRC_L1AUDIO_SETFLAG_A(audio_id,l1audio.dspUser);
+
+ kal_take_sem( l1audio.sema, KAL_INFINITE_WAIT );
+ ASSERT( l1audio.id_flag & (1 << audio_id) );
+ ASSERT( (l1audio.sleppModeLocker & (1 << audio_id)) == 0 );
+ ASSERT( (l1audio.dspUser & (1 << audio_id)) == 0 );
+
+ if( l1audio.dspUser == 0 ) {
+#if defined( MTK_SLEEP_ENABLE )
+ Audio_Wake_DSP(audio_id, KAL_TRUE);
+#endif
+ }
+
+ if (false == l1audio.isD2MIntAvalibaleUnderSleep && l1audio.sleppModeLocker == 0) {
+ SLEEP_LOCK();
+ }
+
+
+ if (false == l1audio.isD2MIntAvalibaleUnderSleep) {
+ l1audio.sleppModeLocker |= (1 << audio_id);
+ }
+ l1audio.dspUser |= (1 << audio_id);
+
+ kal_give_sem( l1audio.sema );
+}
+
+void L1Audio_ClearFlag( uint16 audio_id )
+{
+ if (!kal_if_hisr() && !kal_if_lisr())
+ MD_TRC_L1AUDIO_CLEARFLAG_A(audio_id,l1audio.dspUser);
+ else
+ MD_TRC_L1AUDIO_CLEARFLAG_A(audio_id,l1audio.dspUser);
+
+ kal_take_sem( l1audio.sema, KAL_INFINITE_WAIT );
+ ASSERT( l1audio.id_flag & (1 << audio_id) );
+ ASSERT( l1audio.dspUser & (1 << audio_id) );
+ if (false == l1audio.isD2MIntAvalibaleUnderSleep) {
+ ASSERT( l1audio.sleppModeLocker & (1 << audio_id) );
+ }
+
+
+ if (false == l1audio.isD2MIntAvalibaleUnderSleep) {
+ l1audio.sleppModeLocker &= ~(1 << audio_id);
+ }
+ l1audio.dspUser &= ~(1 << audio_id);
+
+
+ if((false == l1audio.isD2MIntAvalibaleUnderSleep) && (l1audio.sleppModeLocker == 0) ) {
+ SLEEP_UNLOCK();
+ }
+
+ if( l1audio.dspUser == 0 ) {
+#if defined( MTK_SLEEP_ENABLE )
+ Audio_Wake_DSP(audio_id, KAL_FALSE);
+#endif
+ }
+ kal_give_sem( l1audio.sema );
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+
+/* ------------------------------------------------------------------------------ */
+/* L1Audio HISR */
+/* ------------------------------------------------------------------------------ */
+
+void L1Audio_HISR( void )
+{
+ int32 I;
+
+ //L1Audio_Disable_DSPSlowIdle();
+
+ if( l1audio.hisrMagicFlag ) {
+ for( I = 0; I < MAX_HISR_HANDLER; I++ ) {
+ if( l1audio.hisrMagicFlag & (1<<I) ) {
+ kal_take_spinlock(l1audio.lisr_lockId, KAL_INFINITE_WAIT);
+ l1audio.hisrMagicFlag &= ~(1<<I);
+ kal_give_spinlock(l1audio.lisr_lockId);
+ l1audio.hisrHandler[I]( l1audio.hisrUserData[I] );
+ }
+ }
+ }
+
+ if( l1audio.event_flag ) {
+ int16 I;
+ for( I = 0; I < MAX_AUDIO_FUNCTIONS; I++ ) {
+ if( l1audio.event_flag & (1<<I) ) {
+
+ l1audio.event_flag &= ~(1<<I);
+
+ L1Audio_SetEvent( I, l1audio.evData[I] );
+ }
+ }
+ }
+
+ SP_CC_Event_Handler();
+ // To restore slow idle ctrl for DSP
+ //L1Audio_Enable_DSPSlowIdle();
+}
+
+
+void L1Audio_TrigD2CHisr(uint16 magicNo)
+{
+ int32 I;
+ for( I = 0; I < MAX_HISR_HANDLER; I++ ) {
+ if( magicNo == l1audio.hisrMagicNo[I] ) {
+ kal_take_spinlock(l1audio.lisr_lockId, KAL_INFINITE_WAIT);
+ l1audio.hisrMagicFlag |= (1<<I);
+ kal_give_spinlock(l1audio.lisr_lockId);
+ kal_activate_hisr_index(L1AUDIO_HISR);
+ return;
+ }
+ }
+
+}
+
+void L1SP_D2C_LISR( uint16 itype )
+{
+ uint32 sph_int = 0;
+ bool dsp_ok = false;
+ bool from_sph;
+
+ l1audio.d2c_itype = itype;
+#ifndef TK6291_FAKE_COMPILE
+ l1audio.d2c_l1FN = 0;//L1I_GetTimeStamp();
+#else //#ifndef TK6291_FAKE_COMPILE
+ l1audio.d2c_l1FN = 0;
+#endif //#ifndef TK6291_FAKE_COMPILE
+ ////L1Audio_Msg_DSP_INT( itype );
+
+ if(itype == D2C_DSP_DEAD_INT_ID){
+ ASSERT(0);
+/*#ifndef L1D_TEST
+ ASSERT_DUMP_PARAM_T dump_param;
+ dump_param.addr[0] = (kal_uint32)(DPRAM_CPU_base +0x0A0*2);
+ dump_param.len[0] = 70*2;
+ dump_param.addr[1] = (kal_uint32)(DPRAM2_CPU_base+0x130*2);
+ dump_param.len[1] = 180*2;
+ dump_param.addr[2] = 0; //End of dump param
+ //EXT_ASSERT_DUMP(0, 0x20060622, 0, 0, &dump_param);
+ EXT_ASSERT_DUMP(0, &dump_param);
+#else
+ extern void L1DTest_AssertFail(void);
+ L1DTest_AssertFail();
+#endif*/
+ }
+
+ from_sph = SAL_DSPINT_Resolve(itype, &sph_int);//the itype should be the real one sent directly from DSP
+
+ MD_TRC_L1Audio_Msg_DSP_D2C_SPEECH_INT(L1AUDIO_Str_Bool(from_sph), (sph_int >> 16), sph_int);
+
+ if(from_sph) {
+
+ kal_int16 i;
+ for( i=1; i< SAL_DSPINT_PRIO_MAX; i++) {
+ if(sph_int & (1 << i)) {
+ L1Audio_TrigD2CHisr(DP_D2C_INT_MAPPING_BASIC+i); // please reference to
+ dsp_ok |= true;
+ }
+ }
+ /*
+ // original mapping
+ if(sph_int & SAL_DSPINT_ID_REC_VM){ // vm record
+ L1Audio_TrigD2CHisr(DP_D2C_VM_REC_INT);
+ dsp_ok |= true;
+ }
+
+ if(sph_int & SAL_DSPINT_ID_REC_PCM){ // pcm record
+ L1Audio_TrigD2CHisr(DP_D2C_PCM_REC_INT);
+ dsp_ok |= true;
+ }
+
+ if(sph_int & SAL_DSPINT_ID_PNW_DL){ // pnw
+ L1Audio_TrigD2CHisr(DP_D2C_PCM_EX_DL); // DP_D2C_PCM_EX_DL, pcmNway
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_DACA_DL){ // data card
+ L1Audio_TrigD2CHisr(DP_D2C_DACA_REQ_DL); // data card
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_3G_DL){ // 3g dl
+ //L1SP_D2C_LISR(DP_D2C_3G_DONE_DL);//Don't trigger LISR here. 3G driver will trigger HISR by it's timing
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_BGS){ // background sound
+ L1Audio_TrigD2CHisr(D2C_SOUND_EFFECT_INT_ID); // background sound, SND_EFFECT_MAGIC_NO
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_AVBT){ //AVBT
+ L1Audio_TrigD2CHisr(D2C_AUDIO_VIA_BT_ID);
+ dsp_ok |= true;
+ }
+
+ if(sph_int & SAL_DSPINT_ID_REC_EPL){
+ L1Audio_TrigD2CHisr(DP_D2C_VMEPL_REC_INT); // call record pcm, call record vm
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_PNW_UL){
+ L1Audio_TrigD2CHisr(DP_D2C_PCM_EX_UL); // pcmnway ul
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_DACA_UL){
+ L1Audio_TrigD2CHisr(DP_D2C_DACA_REQ_UL); // data card
+ dsp_ok |= true;
+ }
+ if(sph_int & SAL_DSPINT_ID_3G_UL){
+ L1Audio_TrigD2CHisr(DP_D2C_3G_DONE_UL); // 3g
+ dsp_ok |= true;
+ }
+ */
+
+ if(0 != sph_int){//After DSP send D2C and turn on bit in DP_D2C_SPEECH_UL_INT, but MCU doesnt receive D2C. Handover causes VBIReset which will clean DP_D2C_SPEECH_UL_INT
+ if (!dsp_ok) {
+ ASSERT(0);
+ }
+ }else{
+ ////L1Audio_Msg_DSP_D2C_SPEECH_INT_SKIP((sph_int >> 16), sph_int);
+ }
+
+ // if(from_sph)
+ return;
+ }
+
+ l1audio.media_flag = itype;
+ kal_activate_hisr_index(L1AUDIO_HISR);
+}
+
+#if 1
+void L1Audio_ActivateHisrHandler(kal_uint16 magic_no, void *userData)
+{
+ uint32 I;
+
+ for( I = 0; I < MAX_HISR_HANDLER; I++ ) {
+ if( magic_no == l1audio.hisrMagicNo[I] ) {
+ l1audio.hisrMagicFlag |= (1<<I);
+ l1audio.hisrUserData[I] = userData;
+ }
+ }
+
+ if(l1audio.hisrMagicFlag != 0)
+ kal_activate_hisr_index(L1AUDIO_HISR);
+}
+#endif //#if 0
+
+void L1Audio_HookHisrHandler( kal_uint16 magic_no, L1Audio_EventHandler handler, void *userData )
+{
+ int32 I;
+ for( I = 0; I < MAX_HISR_HANDLER; I++ ) {
+ if( l1audio.hisrMagicNo[I] == 0 ) {
+ l1audio.hisrMagicNo[I] = magic_no;
+ l1audio.hisrHandler[I] = handler;
+ l1audio.hisrUserData[I] = userData;
+ break;
+ }
+ }
+ ASSERT_REBOOT( I != MAX_HISR_HANDLER );
+}
+
+void L1Audio_UnhookHisrHandler( kal_uint16 magic_no )
+{
+ int32 I;
+ for( I = 0; I < MAX_HISR_HANDLER; I++ ) {
+ if( l1audio.hisrMagicNo[I] == magic_no ) {
+ l1audio.hisrMagicNo[I] = 0;
+ break;
+ }
+ }
+ ASSERT_REBOOT( I != MAX_HISR_HANDLER );
+}
+
+void L1Audio_SetDebugInfo( kal_uint16 debug_info[NUM_DEBUG_INFO])
+{
+ memcpy(l1audio.debug_info, debug_info, NUM_DEBUG_INFO*sizeof(uint16));
+ memcpy((void *)(SAL_EMP_DebugInfo_GetBuf()), debug_info, NUM_DEBUG_INFO*sizeof(uint16));
+}
+
+void L1Audio_SetDebugInfoN( kal_uint16 index, kal_uint16 debug_info )
+{
+ l1audio.debug_info[index] = debug_info;
+ *(SAL_EMP_DebugInfo_GetBuf() + index) = debug_info;
+}
+
+kal_uint16 L1Audio_GetDebugInfo( kal_uint8 index )
+{
+ ASSERT( index < NUM_DEBUG_INFO );
+ return l1audio.debug_info[index];
+}
+
+/* ------------------------------------------------------------------------------ */
+/* Debug functions used to verify the data written to DSP */
+/* ------------------------------------------------------------------------------ */
+#if VERIFY_DATA_TO_DSP
+#include "fat_fs.h"
+kal_uint8 bDSPBuffer[8192];
+kal_uint16 uDSPBufferRead;
+kal_uint16 uDSPBufferWrite;
+kal_uint32 uDSPBufferSize;
+kal_uint16 fname[12] = { 'E', ':', '\\', 'D', 'A', 'T', 'A', '.', 'D', 'A', 'T', 0x00 };
+FS_HANDLE fs_handle = 0;
+
+void VERIFY_DATA_TO_DSP_START( void )
+{
+ if( fs_handle )
+ FS_Close( fs_handle );
+ fs_handle = FS_Open( (const kal_wchar*)fname, FS_CREATE_ALWAYS );
+ ASSERT( fs_handle > 0 );
+ uDSPBufferSize = 8192;
+ uDSPBufferRead = 0;
+ uDSPBufferWrite = 0;
+}
+
+void VERIFY_DATA_TO_DSP_RESUME( void )
+{
+ kal_uint32 uFileSize;
+ kal_int32 ret;
+ fs_handle = FS_Open( (const kal_wchar*)fname, FS_READ_WRITE|FS_CREATE );
+ ASSERT( fs_handle > 0 );
+ if(FS_GetFileSize(fs_handle, &uFileSize) < 0)
+ ASSERT(0);
+ if(FS_Seek(fs_handle, uFileSize, FS_FILE_BEGIN) < 0)
+ ASSERT(0);
+ uDSPBufferSize = 8192;
+}
+
+void VERIFY_DATA_TO_DSP_STOP( void )
+{
+ if( fs_handle )
+ {
+ if (FS_Close( fs_handle ) != 0)
+ ASSERT(0);
+ fs_handle = 0;
+ }
+}
+
+void VERIFY_DATA_TO_DSP_WRITE_DATA( const kal_uint16 *buf, int32 len )
+{
+ kal_uint32 uDSPBufferFree;
+ if( uDSPBufferWrite < uDSPBufferRead )
+ { /// DDDDWxxxxxxxRDD
+ uDSPBufferFree = uDSPBufferRead - uDSPBufferWrite - 1;
+ ASSERT( len*2 <= uDSPBufferFree );
+ memcpy(bDSPBuffer+uDSPBufferWrite, buf, len*2);
+ uDSPBufferWrite += len*2;
+ }
+ else
+ { /// xxxRDDDDDDWxxxx
+ kal_uint32 free_1, free_2, write_count;
+ free_1 = uDSPBufferSize - uDSPBufferWrite;
+ free_2 = uDSPBufferRead - 1;
+ uDSPBufferFree = free_1 + free_2;
+ ASSERT( len*2 <= uDSPBufferFree );
+ write_count = ( len*2 > free_1 )? free_1 : len*2;
+ memcpy(bDSPBuffer+uDSPBufferWrite, buf, write_count);
+ uDSPBufferWrite += write_count;
+ if( uDSPBufferWrite==uDSPBufferSize )
+ uDSPBufferWrite = 0;
+ write_count = len*2 - write_count;
+ if( write_count )
+ memcpy(bDSPBuffer+uDSPBufferWrite, buf, write_count);
+ uDSPBufferWrite += write_count;
+ }
+}
+
+void VERIFY_DATA_TO_DSP_SAVE_DATA( void )
+{
+ if( fs_handle != 0 && uDSPBufferRead != uDSPBufferWrite )
+ {
+ kal_uint32 uDSPBufferUsed;
+ kal_uint32 uDataSaved;
+ if( uDSPBufferRead < uDSPBufferWrite )
+ { /// xxxRDDDDDDWxxxx
+ uDSPBufferUsed = uDSPBufferWrite - uDSPBufferRead;
+ FS_Write( fs_handle, bDSPBuffer+uDSPBufferRead, uDSPBufferUsed, &uDataSaved );
+ ASSERT( uDSPBufferUsed == uDataSaved );
+ uDSPBufferRead += uDataSaved;
+ }
+ else
+ { /// DDDDWxxxxxxxRDD
+ kal_uint32 used_1, used_2, write_count;
+ used_1 = uDSPBufferSize - uDSPBufferRead;
+ FS_Write( fs_handle, bDSPBuffer+uDSPBufferRead, used_1, &uDataSaved );
+ ASSERT( used_1 == uDataSaved );
+ used_2 = uDSPBufferWrite;
+ FS_Write( fs_handle, bDSPBuffer, used_2, &uDataSaved );
+ ASSERT( used_2 == uDataSaved );
+ uDSPBufferRead = uDataSaved;
+ }
+ }
+}
+#endif
+
+/* ------------------------------------------------------------------------------ */
+/* L1Audio Task */
+/* ------------------------------------------------------------------------------ */
+
+#ifndef TK6291_FAKE_COMPILE
+extern unsigned short L1D_Audio_ChkDspInitDone();
+#endif //#ifndef TK6291_FAKE_COMPILE
+
+#ifdef __DHL_MODULE__
+void tst_dummy_callback(const kal_uint8* pData, kal_uint32 nLen){
+}
+#endif
+
+kal_enhmutexid sp_handover_mutex; //just for 4G and 4G
+#if defined(__VOLTE_SUPPORT__)
+kal_enhmutexid sp4g_dl_mutex;
+kal_enhmutexid sp4g_ul_mutex;
+uint32 g_retrieved_events;
+#endif
+
+kal_enhmutexid sp_cc_mutex;
+
+#define DSP_DSP_EXCEPTION_ID 0x003E
+#define DSP_MPU_VIOLATION 0x003F
+
+void *CUIF_U2C_ULTail_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_UL_ID );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+void *CUIF_U2C_DLTail_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_DL_ID );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+void *CUIF_U2C_ULHead_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_UL_ID2 );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+void *CUIF_U2C_DLHead_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_DL_ID2 );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+void *CUIF_U2C_MMTail_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_MM_ID );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+void *CUIF_U2C_SPEECH_AUX_ISR(CUIF_Mask_t* mask)
+{
+ L1SP_D2C_LISR( DSP_IID_SPEECH_AUX_ID );
+ CUIF_SPEECH_WAKEUP_EOI();
+ return NULL;
+}
+
+bool L1Audio_IsInitialized(){
+ return l1audio.is_Initialized;
+}
+
+void L1Audio_LISR_Init()
+{
+ l1audio.lisr_lockId = kal_create_spinlock("LISR_LOCK");
+}
+void L1Audio_BootDSPSpeech()
+{
+ uint32 I = 0 ;
+ //bool is_default_user;
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+#if defined(__MD97__) || defined(__MD97P__)
+ //firstboot_activate(DSP_CONTROL_USIP1_SPEECH, DSP_CTRL_USIP_SPEECH);
+ if(0 == l1audio.dsp_first_init_done)
+ {
+ dsp_firstboot_activate_by_module(L1_MODULE_SPEECH);
+ l1audio.dsp_first_init_done = 1;
+ }
+ else
+ {
+ dsp_activate_by_module(L1_MODULE_SPEECH);
+ }
+
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_ACTIVATE_DONE != dsp_activate_done_check_by_module(L1_MODULE_SPEECH) ){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 3 );
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ firstboot_activate(DSP_CONTROL_USIP1_SPEECH, DSP_CTRL_USIP_SPEECH);
+
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 3 );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void L1Audio_UnBootDSPSpeech()
+{
+ uint32 I = 0 ;
+ //turn off power/clock API
+#if defined(__MD97__) || defined(__MD97P__)
+ //dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ dsp_deactivate_by_module(L1_MODULE_SPEECH);
+ //while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_DEACTIVATE_DONE != dsp_deactivate_done_check_by_module(L1_MODULE_SPEECH) ){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 5 );
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task(AUD_1TICK(1));
+ ASSERT( ++I < 5 );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+}
+
+void L1Audio_Task(unsigned argc, void *argv)
+{
+ uint32 retrieved_events;
+ uint32 I;
+ kal_uint16 initaud_id;
+
+#if defined(__SMART_PHONE_MODEM__)
+ SpcIO_shmInit();
+#endif
+
+
+ /*-----------------------------*/
+ /* enable FD216 DSP event (pcore) */
+ /*-----------------------------*/
+#ifdef __AUDIO_TASK_DISABLE__
+ return;
+#endif
+ L1Audio_BootDSPSpeech();
+ L1Audio_UnBootDSPSpeech();
+
+#ifdef __DHL_MODULE__
+ tst_vc_register_channel(TVCI_VM_LOGGING, tst_dummy_callback);
+#endif
+
+ sp_cc_mutex = kal_create_enh_mutex( "SP_CC_MUTEX" );
+ SP_CC_Init();
+
+ sp_handover_mutex = kal_create_enh_mutex( "SP_HANDOVER_ENH_MUTEX" );
+#if defined(__VOLTE_SUPPORT__)
+ sp4g_dl_mutex = kal_create_enh_mutex( "SP4G_DL_MUTEX" );
+ sp4g_ul_mutex = kal_create_enh_mutex( "SP4G_UL_MUTEX" );
+#endif
+ l1audio.aud_events = kal_create_event_group("L1Audio");
+
+
+#if defined(MTK_SLEEP_ENABLE) && !defined(__AUDIO_POWERON_RESET_DSP__)
+#ifndef TK6291_FAKE_COMPILE
+ l1audio.md2g_pdn_handle = L1D_MD2G_PWD_GetHandle();
+ l1audio.l1sm_handle = L1SM_IntGetHandle();
+#endif //#ifndef TK6291_FAKE_COMPILE
+#endif
+
+ l1audio.isD2MIntAvalibaleUnderSleep = KAL_TRUE;
+
+ l1audio.sleppModeLocker = 0;
+ l1audio.dspUser = 0;
+ l1audio.dsp_slow_idle_counter = 0;
+ l1audio.event_flag = 0;
+ l1audio.id_flag = 0;
+ l1audio.media_flag = 0;
+ l1audio.sema = kal_create_sem( "Aud_Sema", 1 );
+
+ l1audio.hisrMagicFlag = 0;
+ for( I = 0; I < MAX_HISR_HANDLER; I++ )
+ l1audio.hisrMagicNo[I] = 0;
+
+ cc_L1D_Audio_ChkDspInitDone();
+
+#if defined( MTK_SLEEP_ENABLE )
+ initaud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( initaud_id );
+#endif
+ DSP_DynamicDownload_Init();
+
+ AM_Init();
+ AFE_Init();
+ spGain_Init();
+#if defined(__AUDIO_POWERON_RESET_DSP__)
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifndef TK6291_NO_SPEECH_HW
+/* under construction !*/
+#endif //#ifndef TK6291_NO_SPEECH_HW
+/* under construction !*/
+/* under construction !*/
+#endif
+#endif
+ SP_Parse_EMI_Info();
+ L1SP_Init();
+
+
+#if defined(__SMART_PHONE_MODEM__)
+ EXT_BGSND_init();
+#endif
+
+#ifdef __CTM_SUPPORT__
+ l1ctm_init();
+#endif
+
+#if defined(__DATA_CARD_SPEECH__)
+ SP_Strm_Init();
+#endif
+ memset( &(l1audio.debug_info), 0, sizeof(l1audio.debug_info) );
+
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+ BT_SCO_Init();
+#endif
+
+ VM_Init();
+ DACA_Init();
+ pcmEx_Init();
+ RAWPcmRec_Init();
+ Extcodec_Init();
+ L1Audio_LISR_Init();
+ SP_DSPTone_Init();
+ PcmMixer_Init();
+ PcmMixer3_Init();
+
+#if defined(__ECALL_SUPPORT__)
+ eCall_Init();
+#endif
+
+#if defined( MTK_SLEEP_ENABLE )
+ L1Audio_ClearFlag( initaud_id );
+ L1Audio_FreeAudioID( initaud_id );
+#endif
+
+ l1audio.is_Initialized = true;
+ while( 1 ) {
+#if VERIFY_DATA_TO_DSP
+ VERIFY_DATA_TO_DSP_SAVE_DATA();
+#endif
+ kal_retrieve_eg_events(l1audio.aud_events,0xFFFF,KAL_OR_CONSUME,&retrieved_events,KAL_SUSPEND);
+ l1audio.retrieved_events = retrieved_events;
+#ifndef TK6291_FAKE_COMPILE
+ l1audio.events_l1FN = 0;//L1I_GetTimeStamp();
+#else //#ifndef TK6291_FAKE_COMPILE
+ l1audio.events_l1FN = 0;
+#endif //#ifndef TK6291_FAKE_COMPILE
+ kal_runtime_affinity_to_current_vpe();
+ for( I = 0; I < MAX_AUDIO_FUNCTIONS; I++ ) {
+ if ( l1audio.retrieved_events & (1<<I) ) {
+ l1audio.evHandler[I]( l1audio.evData[I] );
+ }
+ }
+ kal_runtime_affinity_resume();
+ // if( (l1audio.sleppModeLocker == 0))
+ // SLEEP_UNLOCK();
+ }
+}
+
+
+uint32 L1Audio_GetEventGroup( void )
+{
+ uint32 retrieved_events;
+ kal_retrieve_eg_events( l1audio.aud_events, 0xFFFF, KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND );
+ return retrieved_events;
+}
+
+void L1Audio_ExeEventHandler( uint32 event )
+{
+ ASSERT_REBOOT( event < MAX_AUDIO_FUNCTIONS );
+ l1audio.evHandler[event]( l1audio.evData[event] );
+}
+
+void L1Audio_ResetDevice(void)
+{
+ AFE_Init();
+}
+/* ------------------------------------------------------------------------------ */
+
+static char *_get_next_arg(char **ppstring)
+{
+ char *pstring = *ppstring, *pstring_t;
+ kal_uint8 ch;
+
+ if( *pstring=='\0' )
+ return NULL;
+
+ while(1)
+ { // find start
+ ch = *pstring;
+ if( ch!=' ' && ch!='\t' )
+ break;
+ pstring++;
+ }
+
+ pstring_t = pstring;
+
+ while(1)
+ {
+ ch = *pstring;
+ if( ch=='\0' )
+ break;
+ else if( ch==' ' || ch=='\t' )
+ {
+ *pstring = '\0';
+ pstring++;
+ break;
+ }
+ pstring++;
+ }
+
+ *ppstring = (char *)pstring;
+
+ return pstring_t;
+}
+
+static void dispatcher(char **ppstring, int (*entry_main)(int argc, char **argv))
+{
+ int argc = 0;
+ char *argv[16];
+
+ while(1)
+ {
+ char *args = _get_next_arg( ppstring );
+
+ if( args==NULL )
+ {
+ entry_main( argc, argv );
+ break;
+ }
+ else if( strcmp( args, "|" )==0 )
+ {
+ argv[argc] = NULL;
+ entry_main( argc, argv );
+ argc = 0;
+ }
+ else
+ argv[argc++] = args;
+ }
+}
+
+void l1audio_console(kal_uint8 index, kal_char *string)
+{
+ int (*entry_main)(int argc, char **argv);
+ char *pstring = (char *)string;
+
+ entry_main = NULL;
+ switch(index)
+ {
+ case 99: /* VoRTP unit test */
+ {
+ break;
+ }
+ default:
+ break;
+ }
+ if( entry_main!=NULL )
+ dispatcher(&pstring, entry_main);
+}
+
+static kal_uint32 is_fake_4g = 0;
+kal_uint32 get_is_fake_4g(void)
+{
+ return(is_fake_4g);
+}
+#ifdef __FAKE_3G_LOOPBACK__
+static kal_uint32 is_fake_3g = 0;
+kal_uint32 get_is_fake_3g(void)
+{
+ return(is_fake_3g);
+}
+#endif
+void l1audio_console_handler(kal_char *string)
+{
+ //(void)string; //just for integrating MCU TONE
+ //int ii=atoi(string);
+#if defined(__VOLTE_SUPPORT__)
+ static kal_uint32 temp_RAB_ID = 0;
+#endif //#if defined(__VOLTE_SUPPORT__)
+
+ if(strcmp(string, "0")==0) {
+ //void Spc_SpeechOn( kal_uint8 RAT_Mode );
+ //Spc_SpeechOn( 0 );
+ void L1SP_Speech_On( uint8 RAT_Mode );
+ L1SP_Speech_On(0);
+ }
+ else if(strcmp(string, "1")==0) {
+ //void Spc_SpeechOff( void );
+ //Spc_SpeechOff();
+ void L1SP_Speech_Off( void );
+ L1SP_Speech_Off();
+ }
+ else if(strcmp(string, "2")==0) {
+ void cc_2G_Call_Open(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel, kal_uint32 resetType);
+ cc_2G_Call_Open(2, 2, 1, SAL_SRST_TYPE_CALLON);
+ }
+ else if(strcmp(string, "3")==0) {
+
+ void cc_2G_Call_Close(kal_uint32 dsp_end);
+ cc_2G_Call_Close(KAL_TRUE);
+ }
+#if defined(__VOLTE_SUPPORT__)
+ else if(strcmp(string, "4")==0) {
+ kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec );
+ void SP4G_SetDTX(kal_bool on);
+
+ if(temp_RAB_ID == 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ is_fake_4g = 1;
+
+ temp_RAB_ID = SP4G_PSR_Link_Est( SP4G_CODEC_AMR_12_2 );
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G AMR");
+ }
+ }
+ else if(strcmp(string, "5")==0) {
+ kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec );
+ void SP4G_SetDTX(kal_bool on);
+
+ if(temp_RAB_ID == 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ is_fake_4g = 1;
+ temp_RAB_ID = SP4G_PSR_Link_Est( SP4G_CODEC_WBAMR_23_85 );
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G AMR-WB");
+ }
+ }
+#if defined(__EVS_CODEC_SUPPORT__)
+ else if(strcmp(string, "6")==0) {
+ void SP4G_SetDTX(kal_bool on);
+ kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec );
+ void sp4g_EVS_loopback_SetEVSEncCAPara(void);
+
+ if(temp_RAB_ID == 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ sp4g_EVS_loopback_SetEVSEncCAPara();
+ is_fake_4g = 1;
+ temp_RAB_ID = SP4G_PSR_Link_Est( SP4G_CODEC_EVS_32K_009_6 );
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G SP4G_CODEC_EVS_32K_009_6");
+ }
+ }
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ else if(strcmp(string, "7")==0) {
+ void SP4G_PSR_Link_Deest(kal_uint32 id);
+
+ if(temp_RAB_ID != 0)
+ {
+ SP4G_PSR_Link_Deest(temp_RAB_ID);
+ temp_RAB_ID = 0;
+ is_fake_4g = 0;
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G close");
+ }
+ }
+ else if(strcmp(string, "8")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_AMR_6_7);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_AMR_6_7");
+ }
+ }
+ else if(strcmp(string, "9")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_AMR_10_2);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_AMR_10_2");
+ }
+ }
+ else if(strcmp(string, "10")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_WBAMR_6_6);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_WBAMR_6_6");
+ }
+ }
+ else if(strcmp(string, "11")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_WBAMR_18_25);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_WBAMR_18_25");
+ }
+ }
+#if defined(__EVS_CODEC_SUPPORT__)
+ else if(strcmp(string, "12")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_EVS_32K_013_2);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_EVS_32K_013_2");
+ }
+ }
+ else if(strcmp(string, "13")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_EVS_16K_008_0);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_EVS_16K_008_0");
+ }
+ }
+ else if(strcmp(string, "14")==0) {
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+ //if(temp_RAB_ID != 0)
+ {
+ SP4G_SetDTX(KAL_TRUE);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_EVS_AWB_23_85);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_EVS_AWB_23_85");
+ }
+ }
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+#if defined(__G_CODEC_SUPPORT__)
+ else if(strcmp(string, "15")==0) {
+ void SP4G_Set_G711Parameters(kal_int32 law, kal_int32 dec_init_CNG_enable);
+ kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec );
+ void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec);
+ void SP4G_SetDTX(kal_bool on);
+
+ if(temp_RAB_ID == 0)
+ {
+ SP4G_SetDTX(KAL_FALSE);
+ SP4G_Set_G711Parameters(2, 0);
+ temp_RAB_ID = SP4G_PSR_Link_Est(SP4G_CODEC_G711);
+ is_fake_4g = 1;
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_G711");
+ }
+ else
+ {
+ SP4G_SetDTX(KAL_FALSE);
+ SP4G_Set_G711Parameters(2, 0);
+ SP4G_PSR_UL_SetFrameType(SP4G_CODEC_G711);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] Fake 4G set code to SP4G_CODEC_G711");
+ }
+ }
+#endif
+#endif //#if defined(__VOLTE_SUPPORT__)
+ else if(strcmp(string, "TestMode_Start")==0)
+ {
+ void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_1, L1SP_L4C_EVENT_CS);
+ void L1SP_Speech_On( uint8 RAT_Mode );
+ L1SP_Speech_On(0);
+ }
+ else if(strcmp(string, "TestMode_End")==0) {
+ void L1SP_Speech_Off( void );
+ void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_0, L1SP_L4C_EVENT_CS);
+ L1SP_Speech_Off();
+ }
+ else if(strcmp(string, "TestMode_EVS_Start")==0)
+ {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_4G_EVS);
+ void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_1, L1SP_L4C_EVENT_CS);
+ void L1SP_Speech_On( uint8 RAT_Mode );
+ L1SP_Speech_On(0);
+ }
+ else if(strcmp(string, "TestMode_AWB_Start")==0)
+ {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_3G_AWB);
+ void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_1, L1SP_L4C_EVENT_CS);
+ void L1SP_Speech_On( uint8 RAT_Mode );
+ L1SP_Speech_On(0);
+ }
+ else if(strcmp(string, "SPV_AWB_PATTERN")==0)
+ {
+ SAL_TestMode_Config(2, SAL_DSP_TESTMODE_3G_AWB);
+ }
+ else if(strcmp(string, "TestMode_2G_FR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_2G_FR);
+ }
+ else if(strcmp(string, "TestMode_2G_HR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_2G_HR);
+ }
+ else if(strcmp(string, "TestMode_2G_EFR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_2G_EFR);
+ }
+ else if(strcmp(string, "TestMode_2G_AMR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_2G_AMR);
+ }
+ else if(strcmp(string, "TestMode_2G_AWB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_2G_AWB);
+ }
+ else if(strcmp(string, "TestMode_3G_AMR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_3G_AMR);
+ }
+ else if(strcmp(string, "TestMode_3G_AWB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_3G_AWB);
+ }
+ else if(strcmp(string, "TestMode_4G_AMR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_4G_AMR);
+ }
+ else if(strcmp(string, "TestMode_4G_AWB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_4G_AWB);
+ }
+ else if(strcmp(string, "TestMode_4G_EVS")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_4G_EVS);
+ }
+ else if(strcmp(string, "TestMode_4G_EVSSWB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_4G_EVSSWB);
+ }
+ else if(strcmp(string, "TestMode_C2K_EVA")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_C2K_EVRCA);
+ }
+ else if(strcmp(string, "TestMode_C2K_EVB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_C2K_EVRCB);
+ }
+ else if(strcmp(string, "PROFILE_SSP_AMR")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_3G_AMR);
+ }
+ else if(strcmp(string, "PROFILE_SSP_AWB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_3G_AWB);
+ }
+ else if(strcmp(string, "PROFILE_SSP_EVB")==0) {
+ SAL_TestMode_Config(1, SAL_DSP_TESTMODE_C2K_EVRCB);
+ }
+ else if(strcmp(string, "DSP_DEBUG_MODE")==0) {
+ void SALI_DebugMode_Config(uint16 DebugMode);
+ SALI_DebugMode_Config(SAL_DSP_DBGMODE_SSP_PCM_U2D_AFE);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] On");
+ }
+ else if(strcmp(string, "U0D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ //SAL_TestMode_AFEDVT_Config(SAL_DSP_TESTMODE_AFEDVT_UL_CH0, SAL_DSP_TESTMODE_AFEDVT_DL_CH0);
+ SAL_TestMode_AFEDVT_Config(0, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 0, DL CH: 0");
+ }
+ else if(strcmp(string, "U1D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(1, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 1, DL CH: 0");
+ }
+ else if(strcmp(string, "U2D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(2, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 2, DL CH: 0");
+ }
+ else if(strcmp(string, "U3D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(3, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 3, DL CH: 0");
+ }
+ else if(strcmp(string, "U4D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(4, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 4, DL CH: 0");
+ }
+ else if(strcmp(string, "U5D0")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(5, 0);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 5, DL CH: 0");
+ }
+ else if(strcmp(string, "U0D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(0, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 0, DL CH: 1");
+ }
+ else if(strcmp(string, "U1D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(1, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 1, DL CH: 1");
+ }
+ else if(strcmp(string, "U2D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(2, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 2, DL CH: 1");
+ }
+ else if(strcmp(string, "U3D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(3, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 3, DL CH: 1");
+ }
+ else if(strcmp(string, "U4D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(4, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 4, DL CH: 1");
+ }
+ else if(strcmp(string, "U5D1")==0) { // UL: 0~5 (6CH), DL: 0~1 (2CH)
+ void SAL_TestMode_AFEDVT_Config(uint16 UL_Ch, uint16 DL_Ch);
+ SAL_TestMode_AFEDVT_Config(5, 1);
+ kal_prompt_trace(MOD_L1SP, "[AFE_DebugMode] UL CH: 5, DL CH: 1");
+ }
+#ifdef __FAKE_3G_LOOPBACK__
+ else if(strcmp(string, "31")==0) {
+ //void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ //SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_1, L1SP_L4C_EVENT_CS);
+ SP3G_Rab_Est(0, 0);
+ is_fake_3g = 1;
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] SP3G_Rab_Est");
+ }
+ else if(strcmp(string, "32")==0) {
+ SP3G_UL_SetFrameType(0);//0 --> 4.75
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] SP3G_UL_SetFrameType");
+ }
+ else if(strcmp(string, "33")==0) {
+ //void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode);
+ //SP_L4C_SetEvent_Execute(L1SP_L4C_ESPEECH_0, L1SP_L4C_EVENT_CS);
+ SP3G_Rab_Deest();
+ is_fake_3g = 0;
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] SP3G_Rab_Deest");
+ }
+ else if(strcmp(string, "41")==0) {
+ //void L1SP_C2K_Est(int codec);
+ //L1SP_C2K_Est(SAL_COD_EVRCA); //imply espeech_on in SO_Connect
+ void SPC2K_ConSSO_Req( uint16 u2SO, uint16 u2MaxEncRate);
+ SPC2K_ConSSO_Req( IPC_SPCH_SRVC_OPTION3, 0);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] L1SP_C2K_Est");
+ }
+ else if(strcmp(string, "42")==0) {
+ void L1SP_C2K_IntraRAT(int codec);
+ L1SP_C2K_IntraRAT(SAL_COD_EVRCA);
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] L1SP_C2K_IntraRAT");
+ }
+ else if(strcmp(string, "43")==0) {
+ void SPC2K_DisconSSO_Req( void );
+ SPC2K_DisconSSO_Req();
+ //void L1SP_C2K_DeEst( void );
+ //L1SP_C2K_DeEst();//imply espeech_off in SO_DisConnect
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] L1SP_C2K_DeEst");
+ }
+ else if(strcmp(string, "51")==0) {
+ void L1SP_TCH_Notify( bool bOn );
+ L1SP_TCH_Notify( true );
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] L1SP_TCH_Notify( true )");
+ }
+ else if(strcmp(string, "52")==0) {
+
+ }
+ else if(strcmp(string, "53")==0) {
+ void L1SP_TCH_Notify( bool bOn );
+ L1SP_TCH_Notify( false );
+ kal_prompt_trace(MOD_L1SP, "[l1audio_console_handler] L1SP_TCH_Notify( false )");
+ }
+
+#endif
+ else if(strcmp(string, "60")==0) {
+ void SP4G_PSR_DL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration);
+ SP4G_PSR_DL_KT_Play(300, 700, 0x7FFF);
+ }
+ else if(strcmp(string, "61")==0) {
+ void SP4G_PSR_DL_KT_Stop(void);
+ SP4G_PSR_DL_KT_Stop();
+ }
+ else if(strcmp(string, "62")==0) {
+ void SP4G_PSR_UL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration);
+ SP4G_PSR_UL_KT_Play(500, 900, 0x7FFF);
+ }
+ else if(strcmp(string, "63")==0) {
+ void SP4G_PSR_UL_KT_Stop(void);
+ SP4G_PSR_UL_KT_Stop();
+ }else if(strncmp(string, "debug", 5)==0) {
+ uint32 t1;
+ sscanf(string, "debug %d", &t1);
+ kal_prompt_trace(MOD_L1SP, "debug %d", t1);
+ SAL_DebugMode_Config(t1);
+ }
+#ifdef __AAM_AUTO_TEST_SUPPORT__
+ else if(strncmp(string, "Sync", 4)==0) {
+ void sp_ps_aam_fake_L2_Info(uint32 RX_period, uint32 TX_period, uint32 t2nextRX, uint32 t2nextTX);
+ uint32 t1, t2, t3, t4;
+ sscanf(string, "Sync %d %d %d %d", &t1, &t2, &t3, &t4);
+ kal_prompt_trace(MOD_L1SP, "sp_ps_aam_fake_L2_Info %d %d %d %d", t1, t2, t3, t4);
+ sp_ps_aam_fake_L2_Info(t1, t2, t3, t4);
+ }else if(strncmp(string, "AutoSyncTest", 12)==0) {
+ uint32 t1;
+ void aam_resync_test_start(uint32 start_idx);
+ sscanf(string, "AutoSyncTest %d", &t1);
+ kal_prompt_trace(MOD_L1SP, "aam_resync_test SyncTest %d", t1);
+ aam_resync_test_start(t1);
+ }
+#endif
+
+/*
+ (void)string;
+ if(strcmp(string, "speechOn")==0){
+ L1SP_Speech_On(0);
+ } else if(strcmp(string, "speechOff")==0) {
+ L1SP_Speech_Off();
+ } else if(strcmp(string, "get2gRF")==0) {
+ uint16 L1D_GetRF(uint16 mode);
+ uint16 RF_2G = L1D_GetRF(MML1_RF_2G);
+ ////L1Audio_Msg_L1D_GetRF(RF_2G);
+ }
+#if defined(__ENABLE_SPEECH_DVT__)
+ extern void Speech_DVT_Test_Main(kal_char *string);
+ Speech_DVT_Test_Main(string);
+#endif // defined(__ENABLE_SPEECH_DVT__)*/
+}
+
+/* ----------------------------------------------------------------------------- */
+/* Function ptr prototype [HAL rule] */
+/* ----------------------------------------------------------------------------- */
+//[MED]
+static fp_audio_alloc_aud_mem audio_alloc_aud_mem = NULL;
+static fp_audio_alloc_aud_mem audio_alloc_aud_mem_cacheable= NULL;
+static fp_audio_free_aud_mem audio_free_aud_mem = NULL;
+static fp_send_proc_call_req send_proc_call_req = NULL;
+static fp_send_proc_call_req send_proc_call_req2 = NULL;
+static fp_audio_set_path_volume audio_set_path_vol = NULL;
+static fp_audio_get_active_mode audio_get_active_mode = NULL;
+static fp_get_meta_data_file audio_get_meta_file = NULL;
+static fp_get_meta_data_array audio_get_meta_array = NULL;
+
+void Audio_MedFuncReg(Media_Func_Reg_Type *func){
+ audio_alloc_aud_mem = (fp_audio_alloc_aud_mem) func->alloc_mem;
+ audio_alloc_aud_mem_cacheable = (fp_audio_alloc_aud_mem) func->alloc_mem_cacheable;
+ audio_free_aud_mem = (fp_audio_free_aud_mem) func->free_mem;
+ audio_set_path_vol = (fp_audio_set_path_volume)func->set_path_volume;
+ audio_get_active_mode = (fp_audio_get_active_mode)func->get_active_mode;
+ send_proc_call_req = (fp_send_proc_call_req) func->send_proc_call;
+ send_proc_call_req2 = (fp_send_proc_call_req) func->send_proc_call2;
+ audio_get_meta_file = (fp_get_meta_data_file) func->get_meta_file;
+ audio_get_meta_array = (fp_get_meta_data_array) func->get_meta_array;
+}
+
+void *audio_alloc_ext_mem(kal_int32 size, char* file_p, long line_p){
+ void *ptr = NULL;
+ if (size == 0){
+ return NULL;
+ }
+ ptr = (void*) audio_alloc_aud_mem(size,file_p,line_p);
+ if(ptr){
+ memset(ptr, 0, size);
+ }
+ kal_wap_trace(MOD_L1SP, TRACE_INFO, "[AUD][MEM] get buffer from: %s, %d", file_p, line_p);
+ return ptr;
+}
+
+void *audio_alloc_ext_mem_cacheable(kal_int32 size, char* file_p, long line_p){
+ void *ptr = NULL;
+ if (size == 0){
+ return NULL;
+ }
+ ptr = (void*) audio_alloc_aud_mem_cacheable(size,file_p,line_p);
+ if(ptr){
+ memset(ptr, 0, size);
+ }
+ kal_wap_trace(MOD_L1SP, TRACE_INFO, "[AUD][MEM] get buffer from: %s, %d", file_p, line_p);
+ return ptr;
+}
+
+void audio_free_ext_mem(void **ptr, char* file_p, long line_p){
+ audio_free_aud_mem(ptr,file_p,line_p);
+ kal_wap_trace(MOD_L1SP, TRACE_INFO, "[AUD][MEM] free buffer from: %s, %d", file_p, line_p);
+}
+
+
+void L1Audio_InProcCall2(in_proc_call_type func, kal_uint32 func_arg1, void* func_arg2)
+{
+#ifndef MED_NOT_PRESENT
+ send_proc_call_req2(MOD_L1SP, func, func_arg1, func_arg2);
+#endif
+}
+
+void L1Audio_InProcCall(in_proc_call_type func, kal_uint32 func_arg1, void* func_arg2)
+{
+//#ifndef MED_NOT_PRESENT
+ send_proc_call_req(MOD_L1SP, func, func_arg1, func_arg2);
+//#endif
+}
+
+void aud_set_volume_internal(kal_uint8 audio_mode){
+ audio_set_path_vol(audio_mode);
+}
+
+kal_uint8 aud_get_mode_internal(void){
+ return audio_get_active_mode();
+}
+
+
+
+#if defined(__SMART_PHONE_MODEM__)
+#include "task_config.h"
+#include "ccci.h"
+
+extern void Spc_Init_B4_Scheduling(void);
+extern void Spc_Init(void);
+
+extern void SpcIO_Init_B4_Scheduling(void);
+
+extern void SpcIO_A2M_hisr(CCCI_BUFF_T *bufp);
+extern void SpcIO_M2A_hisr(CCCI_BUFF_T *bufp);
+extern void SpcIO_Init(void);
+
+#endif
+
+/***********************************************************/
+/* Export to MED/AUDL task */
+/***********************************************************/
+
+kal_bool SP_Drv_Init_Bootup(void)
+{
+#if defined (__SMART_PHONE_MODEM__)
+ kal_int32 ret;
+ ret = ccci_owner_init(CCCI_PCM_CHANNEL_ACK, kal_get_task_by_moduleID(MOD_MED), SpcIO_A2M_hisr);
+ if (ret != CCCI_SUCCESS) {
+ ASSERT(0);
+ }
+ ret = ccci_owner_init(CCCI_PCM_CHANNEL, kal_get_task_by_moduleID(MOD_MED), SpcIO_M2A_hisr);
+ if (ret != CCCI_SUCCESS) {
+ ASSERT(0);
+ }
+
+ Spc_Init_B4_Scheduling();
+ SpcIO_Init_B4_Scheduling();
+#endif
+
+ return KAL_TRUE;
+}
+
+kal_bool SP_Drv_Init_Task(void)
+{
+ while( !L1Audio_IsInitialized()){
+ kal_sleep_task(AUD_1TICK(1));
+ }
+
+#if defined (__SMART_PHONE_MODEM__)
+ Spc_Init();
+ SpcIO_Init();
+#endif
+
+ return KAL_TRUE;
+}
+
+#ifdef __AAM_AUTO_TEST_SUPPORT__
+
+int aam_resync_test_table[][4] ={
+{ 0 , 0 , 0 , 0 },
+{ 5 , 5 , 0 , 0 },
+{ 5 , 5 , 0 , 1 },
+{ 5 , 5 , 0 , 2 },
+{ 5 , 5 , 0 , 3 },
+{ 5 , 5 , 0 , 4 },
+{ 5 , 5 , 1 , 0 },
+{ 5 , 5 , 1 , 1 },
+{ 5 , 5 , 1 , 2 },
+{ 5 , 5 , 1 , 3 },
+{ 5 , 5 , 1 , 4 },
+{ 5 , 5 , 2 , 0 },
+{ 5 , 5 , 2 , 1 },
+{ 5 , 5 , 2 , 2 },
+{ 5 , 5 , 2 , 3 },
+{ 5 , 5 , 2 , 4 },
+{ 5 , 5 , 3 , 0 },
+{ 5 , 5 , 3 , 1 },
+{ 5 , 5 , 3 , 2 },
+{ 5 , 5 , 3 , 3 },
+{ 5 , 5 , 3 , 4 },
+{ 5 , 5 , 4 , 0 },
+{ 5 , 5 , 4 , 1 },
+{ 5 , 5 , 4 , 2 },
+{ 5 , 5 , 4 , 3 },
+{ 5 , 5 , 4 , 4 },
+{ 5 , 10 , 0 , 0 },
+{ 5 , 10 , 0 , 1 },
+{ 5 , 10 , 0 , 2 },
+{ 5 , 10 , 0 , 3 },
+{ 5 , 10 , 0 , 4 },
+{ 5 , 10 , 0 , 5 },
+{ 5 , 10 , 0 , 6 },
+{ 5 , 10 , 0 , 7 },
+{ 5 , 10 , 0 , 8 },
+{ 5 , 10 , 0 , 9 },
+{ 5 , 10 , 1 , 0 },
+{ 5 , 10 , 1 , 1 },
+{ 5 , 10 , 1 , 2 },
+{ 5 , 10 , 1 , 3 },
+{ 5 , 10 , 1 , 4 },
+{ 5 , 10 , 1 , 5 },
+{ 5 , 10 , 1 , 6 },
+{ 5 , 10 , 1 , 7 },
+{ 5 , 10 , 1 , 8 },
+{ 5 , 10 , 1 , 9 },
+{ 5 , 10 , 2 , 0 },
+{ 5 , 10 , 2 , 1 },
+{ 5 , 10 , 2 , 2 },
+{ 5 , 10 , 2 , 3 },
+{ 5 , 10 , 2 , 4 },
+{ 5 , 10 , 2 , 5 },
+{ 5 , 10 , 2 , 6 },
+{ 5 , 10 , 2 , 7 },
+{ 5 , 10 , 2 , 8 },
+{ 5 , 10 , 2 , 9 },
+{ 5 , 10 , 3 , 0 },
+{ 5 , 10 , 3 , 1 },
+{ 5 , 10 , 3 , 2 },
+{ 5 , 10 , 3 , 3 },
+{ 5 , 10 , 3 , 4 },
+{ 5 , 10 , 3 , 5 },
+{ 5 , 10 , 3 , 6 },
+{ 5 , 10 , 3 , 7 },
+{ 5 , 10 , 3 , 8 },
+{ 5 , 10 , 3 , 9 },
+{ 5 , 10 , 4 , 0 },
+{ 5 , 10 , 4 , 1 },
+{ 5 , 10 , 4 , 2 },
+{ 5 , 10 , 4 , 3 },
+{ 5 , 10 , 4 , 4 },
+{ 5 , 10 , 4 , 5 },
+{ 5 , 10 , 4 , 6 },
+{ 5 , 10 , 4 , 7 },
+{ 5 , 10 , 4 , 8 },
+{ 5 , 10 , 4 , 9 },
+{ 5 , 20 , 0 , 0 },
+{ 5 , 20 , 0 , 1 },
+{ 5 , 20 , 0 , 2 },
+{ 5 , 20 , 0 , 3 },
+{ 5 , 20 , 0 , 4 },
+{ 5 , 20 , 0 , 5 },
+{ 5 , 20 , 0 , 6 },
+{ 5 , 20 , 0 , 7 },
+{ 5 , 20 , 0 , 8 },
+{ 5 , 20 , 0 , 9 },
+{ 5 , 20 , 0 , 10 },
+{ 5 , 20 , 0 , 11 },
+{ 5 , 20 , 0 , 12 },
+{ 5 , 20 , 0 , 13 },
+{ 5 , 20 , 0 , 14 },
+{ 5 , 20 , 0 , 15 },
+{ 5 , 20 , 0 , 16 },
+{ 5 , 20 , 0 , 17 },
+{ 5 , 20 , 0 , 18 },
+{ 5 , 20 , 0 , 19 },
+{ 5 , 20 , 1 , 0 },
+{ 5 , 20 , 1 , 1 },
+{ 5 , 20 , 1 , 2 },
+{ 5 , 20 , 1 , 3 },
+{ 5 , 20 , 1 , 4 },
+{ 5 , 20 , 1 , 5 },
+{ 5 , 20 , 1 , 6 },
+{ 5 , 20 , 1 , 7 },
+{ 5 , 20 , 1 , 8 },
+{ 5 , 20 , 1 , 9 },
+{ 5 , 20 , 1 , 10 },
+{ 5 , 20 , 1 , 11 },
+{ 5 , 20 , 1 , 12 },
+{ 5 , 20 , 1 , 13 },
+{ 5 , 20 , 1 , 14 },
+{ 5 , 20 , 1 , 15 },
+{ 5 , 20 , 1 , 16 },
+{ 5 , 20 , 1 , 17 },
+{ 5 , 20 , 1 , 18 },
+{ 5 , 20 , 1 , 19 },
+{ 5 , 20 , 2 , 0 },
+{ 5 , 20 , 2 , 1 },
+{ 5 , 20 , 2 , 2 },
+{ 5 , 20 , 2 , 3 },
+{ 5 , 20 , 2 , 4 },
+{ 5 , 20 , 2 , 5 },
+{ 5 , 20 , 2 , 6 },
+{ 5 , 20 , 2 , 7 },
+{ 5 , 20 , 2 , 8 },
+{ 5 , 20 , 2 , 9 },
+{ 5 , 20 , 2 , 10 },
+{ 5 , 20 , 2 , 11 },
+{ 5 , 20 , 2 , 12 },
+{ 5 , 20 , 2 , 13 },
+{ 5 , 20 , 2 , 14 },
+{ 5 , 20 , 2 , 15 },
+{ 5 , 20 , 2 , 16 },
+{ 5 , 20 , 2 , 17 },
+{ 5 , 20 , 2 , 18 },
+{ 5 , 20 , 2 , 19 },
+{ 5 , 20 , 3 , 0 },
+{ 5 , 20 , 3 , 1 },
+{ 5 , 20 , 3 , 2 },
+{ 5 , 20 , 3 , 3 },
+{ 5 , 20 , 3 , 4 },
+{ 5 , 20 , 3 , 5 },
+{ 5 , 20 , 3 , 6 },
+{ 5 , 20 , 3 , 7 },
+{ 5 , 20 , 3 , 8 },
+{ 5 , 20 , 3 , 9 },
+{ 5 , 20 , 3 , 10 },
+{ 5 , 20 , 3 , 11 },
+{ 5 , 20 , 3 , 12 },
+{ 5 , 20 , 3 , 13 },
+{ 5 , 20 , 3 , 14 },
+{ 5 , 20 , 3 , 15 },
+{ 5 , 20 , 3 , 16 },
+{ 5 , 20 , 3 , 17 },
+{ 5 , 20 , 3 , 18 },
+{ 5 , 20 , 3 , 19 },
+{ 5 , 20 , 4 , 0 },
+{ 5 , 20 , 4 , 1 },
+{ 5 , 20 , 4 , 2 },
+{ 5 , 20 , 4 , 3 },
+{ 5 , 20 , 4 , 4 },
+{ 5 , 20 , 4 , 5 },
+{ 5 , 20 , 4 , 6 },
+{ 5 , 20 , 4 , 7 },
+{ 5 , 20 , 4 , 8 },
+{ 5 , 20 , 4 , 9 },
+{ 5 , 20 , 4 , 10 },
+{ 5 , 20 , 4 , 11 },
+{ 5 , 20 , 4 , 12 },
+{ 5 , 20 , 4 , 13 },
+{ 5 , 20 , 4 , 14 },
+{ 5 , 20 , 4 , 15 },
+{ 5 , 20 , 4 , 16 },
+{ 5 , 20 , 4 , 17 },
+{ 5 , 20 , 4 , 18 },
+{ 5 , 20 , 4 , 19 },
+{ 5 , 40 , 0 , 0 },
+{ 5 , 40 , 0 , 1 },
+{ 5 , 40 , 0 , 2 },
+{ 5 , 40 , 0 , 3 },
+{ 5 , 40 , 0 , 4 },
+{ 5 , 40 , 0 , 5 },
+{ 5 , 40 , 0 , 6 },
+{ 5 , 40 , 0 , 7 },
+{ 5 , 40 , 0 , 8 },
+{ 5 , 40 , 0 , 9 },
+{ 5 , 40 , 0 , 10 },
+{ 5 , 40 , 0 , 11 },
+{ 5 , 40 , 0 , 12 },
+{ 5 , 40 , 0 , 13 },
+{ 5 , 40 , 0 , 14 },
+{ 5 , 40 , 0 , 15 },
+{ 5 , 40 , 0 , 16 },
+{ 5 , 40 , 0 , 17 },
+{ 5 , 40 , 0 , 18 },
+{ 5 , 40 , 0 , 19 },
+{ 5 , 40 , 0 , 20 },
+{ 5 , 40 , 0 , 21 },
+{ 5 , 40 , 0 , 22 },
+{ 5 , 40 , 0 , 23 },
+{ 5 , 40 , 0 , 24 },
+{ 5 , 40 , 0 , 25 },
+{ 5 , 40 , 0 , 26 },
+{ 5 , 40 , 0 , 27 },
+{ 5 , 40 , 0 , 28 },
+{ 5 , 40 , 0 , 29 },
+{ 5 , 40 , 0 , 30 },
+{ 5 , 40 , 0 , 31 },
+{ 5 , 40 , 0 , 32 },
+{ 5 , 40 , 0 , 33 },
+{ 5 , 40 , 0 , 34 },
+{ 5 , 40 , 0 , 35 },
+{ 5 , 40 , 0 , 36 },
+{ 5 , 40 , 0 , 37 },
+{ 5 , 40 , 0 , 38 },
+{ 5 , 40 , 0 , 39 },
+{ 5 , 40 , 1 , 0 },
+{ 5 , 40 , 1 , 1 },
+{ 5 , 40 , 1 , 2 },
+{ 5 , 40 , 1 , 3 },
+{ 5 , 40 , 1 , 4 },
+{ 5 , 40 , 1 , 5 },
+{ 5 , 40 , 1 , 6 },
+{ 5 , 40 , 1 , 7 },
+{ 5 , 40 , 1 , 8 },
+{ 5 , 40 , 1 , 9 },
+{ 5 , 40 , 1 , 10 },
+{ 5 , 40 , 1 , 11 },
+{ 5 , 40 , 1 , 12 },
+{ 5 , 40 , 1 , 13 },
+{ 5 , 40 , 1 , 14 },
+{ 5 , 40 , 1 , 15 },
+{ 5 , 40 , 1 , 16 },
+{ 5 , 40 , 1 , 17 },
+{ 5 , 40 , 1 , 18 },
+{ 5 , 40 , 1 , 19 },
+{ 5 , 40 , 1 , 20 },
+{ 5 , 40 , 1 , 21 },
+{ 5 , 40 , 1 , 22 },
+{ 5 , 40 , 1 , 23 },
+{ 5 , 40 , 1 , 24 },
+{ 5 , 40 , 1 , 25 },
+{ 5 , 40 , 1 , 26 },
+{ 5 , 40 , 1 , 27 },
+{ 5 , 40 , 1 , 28 },
+{ 5 , 40 , 1 , 29 },
+{ 5 , 40 , 1 , 30 },
+{ 5 , 40 , 1 , 31 },
+{ 5 , 40 , 1 , 32 },
+{ 5 , 40 , 1 , 33 },
+{ 5 , 40 , 1 , 34 },
+{ 5 , 40 , 1 , 35 },
+{ 5 , 40 , 1 , 36 },
+{ 5 , 40 , 1 , 37 },
+{ 5 , 40 , 1 , 38 },
+{ 5 , 40 , 1 , 39 },
+{ 5 , 40 , 2 , 0 },
+{ 5 , 40 , 2 , 1 },
+{ 5 , 40 , 2 , 2 },
+{ 5 , 40 , 2 , 3 },
+{ 5 , 40 , 2 , 4 },
+{ 5 , 40 , 2 , 5 },
+{ 5 , 40 , 2 , 6 },
+{ 5 , 40 , 2 , 7 },
+{ 5 , 40 , 2 , 8 },
+{ 5 , 40 , 2 , 9 },
+{ 5 , 40 , 2 , 10 },
+{ 5 , 40 , 2 , 11 },
+{ 5 , 40 , 2 , 12 },
+{ 5 , 40 , 2 , 13 },
+{ 5 , 40 , 2 , 14 },
+{ 5 , 40 , 2 , 15 },
+{ 5 , 40 , 2 , 16 },
+{ 5 , 40 , 2 , 17 },
+{ 5 , 40 , 2 , 18 },
+{ 5 , 40 , 2 , 19 },
+{ 5 , 40 , 2 , 20 },
+{ 5 , 40 , 2 , 21 },
+{ 5 , 40 , 2 , 22 },
+{ 5 , 40 , 2 , 23 },
+{ 5 , 40 , 2 , 24 },
+{ 5 , 40 , 2 , 25 },
+{ 5 , 40 , 2 , 26 },
+{ 5 , 40 , 2 , 27 },
+{ 5 , 40 , 2 , 28 },
+{ 5 , 40 , 2 , 29 },
+{ 5 , 40 , 2 , 30 },
+{ 5 , 40 , 2 , 31 },
+{ 5 , 40 , 2 , 32 },
+{ 5 , 40 , 2 , 33 },
+{ 5 , 40 , 2 , 34 },
+{ 5 , 40 , 2 , 35 },
+{ 5 , 40 , 2 , 36 },
+{ 5 , 40 , 2 , 37 },
+{ 5 , 40 , 2 , 38 },
+{ 5 , 40 , 2 , 39 },
+{ 5 , 40 , 3 , 0 },
+{ 5 , 40 , 3 , 1 },
+{ 5 , 40 , 3 , 2 },
+{ 5 , 40 , 3 , 3 },
+{ 5 , 40 , 3 , 4 },
+{ 5 , 40 , 3 , 5 },
+{ 5 , 40 , 3 , 6 },
+{ 5 , 40 , 3 , 7 },
+{ 5 , 40 , 3 , 8 },
+{ 5 , 40 , 3 , 9 },
+{ 5 , 40 , 3 , 10 },
+{ 5 , 40 , 3 , 11 },
+{ 5 , 40 , 3 , 12 },
+{ 5 , 40 , 3 , 13 },
+{ 5 , 40 , 3 , 14 },
+{ 5 , 40 , 3 , 15 },
+{ 5 , 40 , 3 , 16 },
+{ 5 , 40 , 3 , 17 },
+{ 5 , 40 , 3 , 18 },
+{ 5 , 40 , 3 , 19 },
+{ 5 , 40 , 3 , 20 },
+{ 5 , 40 , 3 , 21 },
+{ 5 , 40 , 3 , 22 },
+{ 5 , 40 , 3 , 23 },
+{ 5 , 40 , 3 , 24 },
+{ 5 , 40 , 3 , 25 },
+{ 5 , 40 , 3 , 26 },
+{ 5 , 40 , 3 , 27 },
+{ 5 , 40 , 3 , 28 },
+{ 5 , 40 , 3 , 29 },
+{ 5 , 40 , 3 , 30 },
+{ 5 , 40 , 3 , 31 },
+{ 5 , 40 , 3 , 32 },
+{ 5 , 40 , 3 , 33 },
+{ 5 , 40 , 3 , 34 },
+{ 5 , 40 , 3 , 35 },
+{ 5 , 40 , 3 , 36 },
+{ 5 , 40 , 3 , 37 },
+{ 5 , 40 , 3 , 38 },
+{ 5 , 40 , 3 , 39 },
+{ 5 , 40 , 4 , 0 },
+{ 5 , 40 , 4 , 1 },
+{ 5 , 40 , 4 , 2 },
+{ 5 , 40 , 4 , 3 },
+{ 5 , 40 , 4 , 4 },
+{ 5 , 40 , 4 , 5 },
+{ 5 , 40 , 4 , 6 },
+{ 5 , 40 , 4 , 7 },
+{ 5 , 40 , 4 , 8 },
+{ 5 , 40 , 4 , 9 },
+{ 5 , 40 , 4 , 10 },
+{ 5 , 40 , 4 , 11 },
+{ 5 , 40 , 4 , 12 },
+{ 5 , 40 , 4 , 13 },
+{ 5 , 40 , 4 , 14 },
+{ 5 , 40 , 4 , 15 },
+{ 5 , 40 , 4 , 16 },
+{ 5 , 40 , 4 , 17 },
+{ 5 , 40 , 4 , 18 },
+{ 5 , 40 , 4 , 19 },
+{ 5 , 40 , 4 , 20 },
+{ 5 , 40 , 4 , 21 },
+{ 5 , 40 , 4 , 22 },
+{ 5 , 40 , 4 , 23 },
+{ 5 , 40 , 4 , 24 },
+{ 5 , 40 , 4 , 25 },
+{ 5 , 40 , 4 , 26 },
+{ 5 , 40 , 4 , 27 },
+{ 5 , 40 , 4 , 28 },
+{ 5 , 40 , 4 , 29 },
+{ 5 , 40 , 4 , 30 },
+{ 5 , 40 , 4 , 31 },
+{ 5 , 40 , 4 , 32 },
+{ 5 , 40 , 4 , 33 },
+{ 5 , 40 , 4 , 34 },
+{ 5 , 40 , 4 , 35 },
+{ 5 , 40 , 4 , 36 },
+{ 5 , 40 , 4 , 37 },
+{ 5 , 40 , 4 , 38 },
+{ 5 , 40 , 4 , 39 },
+{ 5 , 80 , 0 , 0 },
+{ 5 , 80 , 0 , 1 },
+{ 5 , 80 , 0 , 2 },
+{ 5 , 80 , 0 , 3 },
+{ 5 , 80 , 0 , 4 },
+{ 5 , 80 , 0 , 5 },
+{ 5 , 80 , 0 , 6 },
+{ 5 , 80 , 0 , 7 },
+{ 5 , 80 , 0 , 8 },
+{ 5 , 80 , 0 , 9 },
+{ 5 , 80 , 0 , 10 },
+{ 5 , 80 , 0 , 11 },
+{ 5 , 80 , 0 , 12 },
+{ 5 , 80 , 0 , 13 },
+{ 5 , 80 , 0 , 14 },
+{ 5 , 80 , 0 , 15 },
+{ 5 , 80 , 0 , 16 },
+{ 5 , 80 , 0 , 17 },
+{ 5 , 80 , 0 , 18 },
+{ 5 , 80 , 0 , 19 },
+{ 5 , 80 , 0 , 20 },
+{ 5 , 80 , 0 , 21 },
+{ 5 , 80 , 0 , 22 },
+{ 5 , 80 , 0 , 23 },
+{ 5 , 80 , 0 , 24 },
+{ 5 , 80 , 0 , 25 },
+{ 5 , 80 , 0 , 26 },
+{ 5 , 80 , 0 , 27 },
+{ 5 , 80 , 0 , 28 },
+{ 5 , 80 , 0 , 29 },
+{ 5 , 80 , 0 , 30 },
+{ 5 , 80 , 0 , 31 },
+{ 5 , 80 , 0 , 32 },
+{ 5 , 80 , 0 , 33 },
+{ 5 , 80 , 0 , 34 },
+{ 5 , 80 , 0 , 35 },
+{ 5 , 80 , 0 , 36 },
+{ 5 , 80 , 0 , 37 },
+{ 5 , 80 , 0 , 38 },
+{ 5 , 80 , 0 , 39 },
+{ 5 , 80 , 0 , 40 },
+{ 5 , 80 , 0 , 41 },
+{ 5 , 80 , 0 , 42 },
+{ 5 , 80 , 0 , 43 },
+{ 5 , 80 , 0 , 44 },
+{ 5 , 80 , 0 , 45 },
+{ 5 , 80 , 0 , 46 },
+{ 5 , 80 , 0 , 47 },
+{ 5 , 80 , 0 , 48 },
+{ 5 , 80 , 0 , 49 },
+{ 5 , 80 , 0 , 50 },
+{ 5 , 80 , 0 , 51 },
+{ 5 , 80 , 0 , 52 },
+{ 5 , 80 , 0 , 53 },
+{ 5 , 80 , 0 , 54 },
+{ 5 , 80 , 0 , 55 },
+{ 5 , 80 , 0 , 56 },
+{ 5 , 80 , 0 , 57 },
+{ 5 , 80 , 0 , 58 },
+{ 5 , 80 , 0 , 59 },
+{ 5 , 80 , 0 , 60 },
+{ 5 , 80 , 0 , 61 },
+{ 5 , 80 , 0 , 62 },
+{ 5 , 80 , 0 , 63 },
+{ 5 , 80 , 0 , 64 },
+{ 5 , 80 , 0 , 65 },
+{ 5 , 80 , 0 , 66 },
+{ 5 , 80 , 0 , 67 },
+{ 5 , 80 , 0 , 68 },
+{ 5 , 80 , 0 , 69 },
+{ 5 , 80 , 0 , 70 },
+{ 5 , 80 , 0 , 71 },
+{ 5 , 80 , 0 , 72 },
+{ 5 , 80 , 0 , 73 },
+{ 5 , 80 , 0 , 74 },
+{ 5 , 80 , 0 , 75 },
+{ 5 , 80 , 0 , 76 },
+{ 5 , 80 , 0 , 77 },
+{ 5 , 80 , 0 , 78 },
+{ 5 , 80 , 0 , 79 },
+{ 5 , 80 , 1 , 0 },
+{ 5 , 80 , 1 , 1 },
+{ 5 , 80 , 1 , 2 },
+{ 5 , 80 , 1 , 3 },
+{ 5 , 80 , 1 , 4 },
+{ 5 , 80 , 1 , 5 },
+{ 5 , 80 , 1 , 6 },
+{ 5 , 80 , 1 , 7 },
+{ 5 , 80 , 1 , 8 },
+{ 5 , 80 , 1 , 9 },
+{ 5 , 80 , 1 , 10 },
+{ 5 , 80 , 1 , 11 },
+{ 5 , 80 , 1 , 12 },
+{ 5 , 80 , 1 , 13 },
+{ 5 , 80 , 1 , 14 },
+{ 5 , 80 , 1 , 15 },
+{ 5 , 80 , 1 , 16 },
+{ 5 , 80 , 1 , 17 },
+{ 5 , 80 , 1 , 18 },
+{ 5 , 80 , 1 , 19 },
+{ 5 , 80 , 1 , 20 },
+{ 5 , 80 , 1 , 21 },
+{ 5 , 80 , 1 , 22 },
+{ 5 , 80 , 1 , 23 },
+{ 5 , 80 , 1 , 24 },
+{ 5 , 80 , 1 , 25 },
+{ 5 , 80 , 1 , 26 },
+{ 5 , 80 , 1 , 27 },
+{ 5 , 80 , 1 , 28 },
+{ 5 , 80 , 1 , 29 },
+{ 5 , 80 , 1 , 30 },
+{ 5 , 80 , 1 , 31 },
+{ 5 , 80 , 1 , 32 },
+{ 5 , 80 , 1 , 33 },
+{ 5 , 80 , 1 , 34 },
+{ 5 , 80 , 1 , 35 },
+{ 5 , 80 , 1 , 36 },
+{ 5 , 80 , 1 , 37 },
+{ 5 , 80 , 1 , 38 },
+{ 5 , 80 , 1 , 39 },
+{ 5 , 80 , 1 , 40 },
+{ 5 , 80 , 1 , 41 },
+{ 5 , 80 , 1 , 42 },
+{ 5 , 80 , 1 , 43 },
+{ 5 , 80 , 1 , 44 },
+{ 5 , 80 , 1 , 45 },
+{ 5 , 80 , 1 , 46 },
+{ 5 , 80 , 1 , 47 },
+{ 5 , 80 , 1 , 48 },
+{ 5 , 80 , 1 , 49 },
+{ 5 , 80 , 1 , 50 },
+{ 5 , 80 , 1 , 51 },
+{ 5 , 80 , 1 , 52 },
+{ 5 , 80 , 1 , 53 },
+{ 5 , 80 , 1 , 54 },
+{ 5 , 80 , 1 , 55 },
+{ 5 , 80 , 1 , 56 },
+{ 5 , 80 , 1 , 57 },
+{ 5 , 80 , 1 , 58 },
+{ 5 , 80 , 1 , 59 },
+{ 5 , 80 , 1 , 60 },
+{ 5 , 80 , 1 , 61 },
+{ 5 , 80 , 1 , 62 },
+{ 5 , 80 , 1 , 63 },
+{ 5 , 80 , 1 , 64 },
+{ 5 , 80 , 1 , 65 },
+{ 5 , 80 , 1 , 66 },
+{ 5 , 80 , 1 , 67 },
+{ 5 , 80 , 1 , 68 },
+{ 5 , 80 , 1 , 69 },
+{ 5 , 80 , 1 , 70 },
+{ 5 , 80 , 1 , 71 },
+{ 5 , 80 , 1 , 72 },
+{ 5 , 80 , 1 , 73 },
+{ 5 , 80 , 1 , 74 },
+{ 5 , 80 , 1 , 75 },
+{ 5 , 80 , 1 , 76 },
+{ 5 , 80 , 1 , 77 },
+{ 5 , 80 , 1 , 78 },
+{ 5 , 80 , 1 , 79 },
+{ 5 , 80 , 2 , 0 },
+{ 5 , 80 , 2 , 1 },
+{ 5 , 80 , 2 , 2 },
+{ 5 , 80 , 2 , 3 },
+{ 5 , 80 , 2 , 4 },
+{ 5 , 80 , 2 , 5 },
+{ 5 , 80 , 2 , 6 },
+{ 5 , 80 , 2 , 7 },
+{ 5 , 80 , 2 , 8 },
+{ 5 , 80 , 2 , 9 },
+{ 5 , 80 , 2 , 10 },
+{ 5 , 80 , 2 , 11 },
+{ 5 , 80 , 2 , 12 },
+{ 5 , 80 , 2 , 13 },
+{ 5 , 80 , 2 , 14 },
+{ 5 , 80 , 2 , 15 },
+{ 5 , 80 , 2 , 16 },
+{ 5 , 80 , 2 , 17 },
+{ 5 , 80 , 2 , 18 },
+{ 5 , 80 , 2 , 19 },
+{ 5 , 80 , 2 , 20 },
+{ 5 , 80 , 2 , 21 },
+{ 5 , 80 , 2 , 22 },
+{ 5 , 80 , 2 , 23 },
+{ 5 , 80 , 2 , 24 },
+{ 5 , 80 , 2 , 25 },
+{ 5 , 80 , 2 , 26 },
+{ 5 , 80 , 2 , 27 },
+{ 5 , 80 , 2 , 28 },
+{ 5 , 80 , 2 , 29 },
+{ 5 , 80 , 2 , 30 },
+{ 5 , 80 , 2 , 31 },
+{ 5 , 80 , 2 , 32 },
+{ 5 , 80 , 2 , 33 },
+{ 5 , 80 , 2 , 34 },
+{ 5 , 80 , 2 , 35 },
+{ 5 , 80 , 2 , 36 },
+{ 5 , 80 , 2 , 37 },
+{ 5 , 80 , 2 , 38 },
+{ 5 , 80 , 2 , 39 },
+{ 5 , 80 , 2 , 40 },
+{ 5 , 80 , 2 , 41 },
+{ 5 , 80 , 2 , 42 },
+{ 5 , 80 , 2 , 43 },
+{ 5 , 80 , 2 , 44 },
+{ 5 , 80 , 2 , 45 },
+{ 5 , 80 , 2 , 46 },
+{ 5 , 80 , 2 , 47 },
+{ 5 , 80 , 2 , 48 },
+{ 5 , 80 , 2 , 49 },
+{ 5 , 80 , 2 , 50 },
+{ 5 , 80 , 2 , 51 },
+{ 5 , 80 , 2 , 52 },
+{ 5 , 80 , 2 , 53 },
+{ 5 , 80 , 2 , 54 },
+{ 5 , 80 , 2 , 55 },
+{ 5 , 80 , 2 , 56 },
+{ 5 , 80 , 2 , 57 },
+{ 5 , 80 , 2 , 58 },
+{ 5 , 80 , 2 , 59 },
+{ 5 , 80 , 2 , 60 },
+{ 5 , 80 , 2 , 61 },
+{ 5 , 80 , 2 , 62 },
+{ 5 , 80 , 2 , 63 },
+{ 5 , 80 , 2 , 64 },
+{ 5 , 80 , 2 , 65 },
+{ 5 , 80 , 2 , 66 },
+{ 5 , 80 , 2 , 67 },
+{ 5 , 80 , 2 , 68 },
+{ 5 , 80 , 2 , 69 },
+{ 5 , 80 , 2 , 70 },
+{ 5 , 80 , 2 , 71 },
+{ 5 , 80 , 2 , 72 },
+{ 5 , 80 , 2 , 73 },
+{ 5 , 80 , 2 , 74 },
+{ 5 , 80 , 2 , 75 },
+{ 5 , 80 , 2 , 76 },
+{ 5 , 80 , 2 , 77 },
+{ 5 , 80 , 2 , 78 },
+{ 5 , 80 , 2 , 79 },
+{ 5 , 80 , 3 , 0 },
+{ 5 , 80 , 3 , 1 },
+{ 5 , 80 , 3 , 2 },
+{ 5 , 80 , 3 , 3 },
+{ 5 , 80 , 3 , 4 },
+{ 5 , 80 , 3 , 5 },
+{ 5 , 80 , 3 , 6 },
+{ 5 , 80 , 3 , 7 },
+{ 5 , 80 , 3 , 8 },
+{ 5 , 80 , 3 , 9 },
+{ 5 , 80 , 3 , 10 },
+{ 5 , 80 , 3 , 11 },
+{ 5 , 80 , 3 , 12 },
+{ 5 , 80 , 3 , 13 },
+{ 5 , 80 , 3 , 14 },
+{ 5 , 80 , 3 , 15 },
+{ 5 , 80 , 3 , 16 },
+{ 5 , 80 , 3 , 17 },
+{ 5 , 80 , 3 , 18 },
+{ 5 , 80 , 3 , 19 },
+{ 5 , 80 , 3 , 20 },
+{ 5 , 80 , 3 , 21 },
+{ 5 , 80 , 3 , 22 },
+{ 5 , 80 , 3 , 23 },
+{ 5 , 80 , 3 , 24 },
+{ 5 , 80 , 3 , 25 },
+{ 5 , 80 , 3 , 26 },
+{ 5 , 80 , 3 , 27 },
+{ 5 , 80 , 3 , 28 },
+{ 5 , 80 , 3 , 29 },
+{ 5 , 80 , 3 , 30 },
+{ 5 , 80 , 3 , 31 },
+{ 5 , 80 , 3 , 32 },
+{ 5 , 80 , 3 , 33 },
+{ 5 , 80 , 3 , 34 },
+{ 5 , 80 , 3 , 35 },
+{ 5 , 80 , 3 , 36 },
+{ 5 , 80 , 3 , 37 },
+{ 5 , 80 , 3 , 38 },
+{ 5 , 80 , 3 , 39 },
+{ 5 , 80 , 3 , 40 },
+{ 5 , 80 , 3 , 41 },
+{ 5 , 80 , 3 , 42 },
+{ 5 , 80 , 3 , 43 },
+{ 5 , 80 , 3 , 44 },
+{ 5 , 80 , 3 , 45 },
+{ 5 , 80 , 3 , 46 },
+{ 5 , 80 , 3 , 47 },
+{ 5 , 80 , 3 , 48 },
+{ 5 , 80 , 3 , 49 },
+{ 5 , 80 , 3 , 50 },
+{ 5 , 80 , 3 , 51 },
+{ 5 , 80 , 3 , 52 },
+{ 5 , 80 , 3 , 53 },
+{ 5 , 80 , 3 , 54 },
+{ 5 , 80 , 3 , 55 },
+{ 5 , 80 , 3 , 56 },
+{ 5 , 80 , 3 , 57 },
+{ 5 , 80 , 3 , 58 },
+{ 5 , 80 , 3 , 59 },
+{ 5 , 80 , 3 , 60 },
+{ 5 , 80 , 3 , 61 },
+{ 5 , 80 , 3 , 62 },
+{ 5 , 80 , 3 , 63 },
+{ 5 , 80 , 3 , 64 },
+{ 5 , 80 , 3 , 65 },
+{ 5 , 80 , 3 , 66 },
+{ 5 , 80 , 3 , 67 },
+{ 5 , 80 , 3 , 68 },
+{ 5 , 80 , 3 , 69 },
+{ 5 , 80 , 3 , 70 },
+{ 5 , 80 , 3 , 71 },
+{ 5 , 80 , 3 , 72 },
+{ 5 , 80 , 3 , 73 },
+{ 5 , 80 , 3 , 74 },
+{ 5 , 80 , 3 , 75 },
+{ 5 , 80 , 3 , 76 },
+{ 5 , 80 , 3 , 77 },
+{ 5 , 80 , 3 , 78 },
+{ 5 , 80 , 3 , 79 },
+{ 5 , 80 , 4 , 0 },
+{ 5 , 80 , 4 , 1 },
+{ 5 , 80 , 4 , 2 },
+{ 5 , 80 , 4 , 3 },
+{ 5 , 80 , 4 , 4 },
+{ 5 , 80 , 4 , 5 },
+{ 5 , 80 , 4 , 6 },
+{ 5 , 80 , 4 , 7 },
+{ 5 , 80 , 4 , 8 },
+{ 5 , 80 , 4 , 9 },
+{ 5 , 80 , 4 , 10 },
+{ 5 , 80 , 4 , 11 },
+{ 5 , 80 , 4 , 12 },
+{ 5 , 80 , 4 , 13 },
+{ 5 , 80 , 4 , 14 },
+{ 5 , 80 , 4 , 15 },
+{ 5 , 80 , 4 , 16 },
+{ 5 , 80 , 4 , 17 },
+{ 5 , 80 , 4 , 18 },
+{ 5 , 80 , 4 , 19 },
+{ 5 , 80 , 4 , 20 },
+{ 5 , 80 , 4 , 21 },
+{ 5 , 80 , 4 , 22 },
+{ 5 , 80 , 4 , 23 },
+{ 5 , 80 , 4 , 24 },
+{ 5 , 80 , 4 , 25 },
+{ 5 , 80 , 4 , 26 },
+{ 5 , 80 , 4 , 27 },
+{ 5 , 80 , 4 , 28 },
+{ 5 , 80 , 4 , 29 },
+{ 5 , 80 , 4 , 30 },
+{ 5 , 80 , 4 , 31 },
+{ 5 , 80 , 4 , 32 },
+{ 5 , 80 , 4 , 33 },
+{ 5 , 80 , 4 , 34 },
+{ 5 , 80 , 4 , 35 },
+{ 5 , 80 , 4 , 36 },
+{ 5 , 80 , 4 , 37 },
+{ 5 , 80 , 4 , 38 },
+{ 5 , 80 , 4 , 39 },
+{ 5 , 80 , 4 , 40 },
+{ 5 , 80 , 4 , 41 },
+{ 5 , 80 , 4 , 42 },
+{ 5 , 80 , 4 , 43 },
+{ 5 , 80 , 4 , 44 },
+{ 5 , 80 , 4 , 45 },
+{ 5 , 80 , 4 , 46 },
+{ 5 , 80 , 4 , 47 },
+{ 5 , 80 , 4 , 48 },
+{ 5 , 80 , 4 , 49 },
+{ 5 , 80 , 4 , 50 },
+{ 5 , 80 , 4 , 51 },
+{ 5 , 80 , 4 , 52 },
+{ 5 , 80 , 4 , 53 },
+{ 5 , 80 , 4 , 54 },
+{ 5 , 80 , 4 , 55 },
+{ 5 , 80 , 4 , 56 },
+{ 5 , 80 , 4 , 57 },
+{ 5 , 80 , 4 , 58 },
+{ 5 , 80 , 4 , 59 },
+{ 5 , 80 , 4 , 60 },
+{ 5 , 80 , 4 , 61 },
+{ 5 , 80 , 4 , 62 },
+{ 5 , 80 , 4 , 63 },
+{ 5 , 80 , 4 , 64 },
+{ 5 , 80 , 4 , 65 },
+{ 5 , 80 , 4 , 66 },
+{ 5 , 80 , 4 , 67 },
+{ 5 , 80 , 4 , 68 },
+{ 5 , 80 , 4 , 69 },
+{ 5 , 80 , 4 , 70 },
+{ 5 , 80 , 4 , 71 },
+{ 5 , 80 , 4 , 72 },
+{ 5 , 80 , 4 , 73 },
+{ 5 , 80 , 4 , 74 },
+{ 5 , 80 , 4 , 75 },
+{ 5 , 80 , 4 , 76 },
+{ 5 , 80 , 4 , 77 },
+{ 5 , 80 , 4 , 78 },
+{ 5 , 80 , 4 , 79 },
+{ 10 , 5 , 0 , 0 },
+{ 10 , 5 , 0 , 1 },
+{ 10 , 5 , 0 , 2 },
+{ 10 , 5 , 0 , 3 },
+{ 10 , 5 , 0 , 4 },
+{ 10 , 5 , 1 , 0 },
+{ 10 , 5 , 1 , 1 },
+{ 10 , 5 , 1 , 2 },
+{ 10 , 5 , 1 , 3 },
+{ 10 , 5 , 1 , 4 },
+{ 10 , 5 , 2 , 0 },
+{ 10 , 5 , 2 , 1 },
+{ 10 , 5 , 2 , 2 },
+{ 10 , 5 , 2 , 3 },
+{ 10 , 5 , 2 , 4 },
+{ 10 , 5 , 3 , 0 },
+{ 10 , 5 , 3 , 1 },
+{ 10 , 5 , 3 , 2 },
+{ 10 , 5 , 3 , 3 },
+{ 10 , 5 , 3 , 4 },
+{ 10 , 5 , 4 , 0 },
+{ 10 , 5 , 4 , 1 },
+{ 10 , 5 , 4 , 2 },
+{ 10 , 5 , 4 , 3 },
+{ 10 , 5 , 4 , 4 },
+{ 10 , 5 , 5 , 0 },
+{ 10 , 5 , 5 , 1 },
+{ 10 , 5 , 5 , 2 },
+{ 10 , 5 , 5 , 3 },
+{ 10 , 5 , 5 , 4 },
+{ 10 , 5 , 6 , 0 },
+{ 10 , 5 , 6 , 1 },
+{ 10 , 5 , 6 , 2 },
+{ 10 , 5 , 6 , 3 },
+{ 10 , 5 , 6 , 4 },
+{ 10 , 5 , 7 , 0 },
+{ 10 , 5 , 7 , 1 },
+{ 10 , 5 , 7 , 2 },
+{ 10 , 5 , 7 , 3 },
+{ 10 , 5 , 7 , 4 },
+{ 10 , 5 , 8 , 0 },
+{ 10 , 5 , 8 , 1 },
+{ 10 , 5 , 8 , 2 },
+{ 10 , 5 , 8 , 3 },
+{ 10 , 5 , 8 , 4 },
+{ 10 , 5 , 9 , 0 },
+{ 10 , 5 , 9 , 1 },
+{ 10 , 5 , 9 , 2 },
+{ 10 , 5 , 9 , 3 },
+{ 10 , 5 , 9 , 4 },
+{ 10 , 10 , 0 , 0 },
+{ 10 , 10 , 0 , 1 },
+{ 10 , 10 , 0 , 2 },
+{ 10 , 10 , 0 , 3 },
+{ 10 , 10 , 0 , 4 },
+{ 10 , 10 , 0 , 5 },
+{ 10 , 10 , 0 , 6 },
+{ 10 , 10 , 0 , 7 },
+{ 10 , 10 , 0 , 8 },
+{ 10 , 10 , 0 , 9 },
+{ 10 , 10 , 1 , 0 },
+{ 10 , 10 , 1 , 1 },
+{ 10 , 10 , 1 , 2 },
+{ 10 , 10 , 1 , 3 },
+{ 10 , 10 , 1 , 4 },
+{ 10 , 10 , 1 , 5 },
+{ 10 , 10 , 1 , 6 },
+{ 10 , 10 , 1 , 7 },
+{ 10 , 10 , 1 , 8 },
+{ 10 , 10 , 1 , 9 },
+{ 10 , 10 , 2 , 0 },
+{ 10 , 10 , 2 , 1 },
+{ 10 , 10 , 2 , 2 },
+{ 10 , 10 , 2 , 3 },
+{ 10 , 10 , 2 , 4 },
+{ 10 , 10 , 2 , 5 },
+{ 10 , 10 , 2 , 6 },
+{ 10 , 10 , 2 , 7 },
+{ 10 , 10 , 2 , 8 },
+{ 10 , 10 , 2 , 9 },
+{ 10 , 10 , 3 , 0 },
+{ 10 , 10 , 3 , 1 },
+{ 10 , 10 , 3 , 2 },
+{ 10 , 10 , 3 , 3 },
+{ 10 , 10 , 3 , 4 },
+{ 10 , 10 , 3 , 5 },
+{ 10 , 10 , 3 , 6 },
+{ 10 , 10 , 3 , 7 },
+{ 10 , 10 , 3 , 8 },
+{ 10 , 10 , 3 , 9 },
+{ 10 , 10 , 4 , 0 },
+{ 10 , 10 , 4 , 1 },
+{ 10 , 10 , 4 , 2 },
+{ 10 , 10 , 4 , 3 },
+{ 10 , 10 , 4 , 4 },
+{ 10 , 10 , 4 , 5 },
+{ 10 , 10 , 4 , 6 },
+{ 10 , 10 , 4 , 7 },
+{ 10 , 10 , 4 , 8 },
+{ 10 , 10 , 4 , 9 },
+{ 10 , 10 , 5 , 0 },
+{ 10 , 10 , 5 , 1 },
+{ 10 , 10 , 5 , 2 },
+{ 10 , 10 , 5 , 3 },
+{ 10 , 10 , 5 , 4 },
+{ 10 , 10 , 5 , 5 },
+{ 10 , 10 , 5 , 6 },
+{ 10 , 10 , 5 , 7 },
+{ 10 , 10 , 5 , 8 },
+{ 10 , 10 , 5 , 9 },
+{ 10 , 10 , 6 , 0 },
+{ 10 , 10 , 6 , 1 },
+{ 10 , 10 , 6 , 2 },
+{ 10 , 10 , 6 , 3 },
+{ 10 , 10 , 6 , 4 },
+{ 10 , 10 , 6 , 5 },
+{ 10 , 10 , 6 , 6 },
+{ 10 , 10 , 6 , 7 },
+{ 10 , 10 , 6 , 8 },
+{ 10 , 10 , 6 , 9 },
+{ 10 , 10 , 7 , 0 },
+{ 10 , 10 , 7 , 1 },
+{ 10 , 10 , 7 , 2 },
+{ 10 , 10 , 7 , 3 },
+{ 10 , 10 , 7 , 4 },
+{ 10 , 10 , 7 , 5 },
+{ 10 , 10 , 7 , 6 },
+{ 10 , 10 , 7 , 7 },
+{ 10 , 10 , 7 , 8 },
+{ 10 , 10 , 7 , 9 },
+{ 10 , 10 , 8 , 0 },
+{ 10 , 10 , 8 , 1 },
+{ 10 , 10 , 8 , 2 },
+{ 10 , 10 , 8 , 3 },
+{ 10 , 10 , 8 , 4 },
+{ 10 , 10 , 8 , 5 },
+{ 10 , 10 , 8 , 6 },
+{ 10 , 10 , 8 , 7 },
+{ 10 , 10 , 8 , 8 },
+{ 10 , 10 , 8 , 9 },
+{ 10 , 10 , 9 , 0 },
+{ 10 , 10 , 9 , 1 },
+{ 10 , 10 , 9 , 2 },
+{ 10 , 10 , 9 , 3 },
+{ 10 , 10 , 9 , 4 },
+{ 10 , 10 , 9 , 5 },
+{ 10 , 10 , 9 , 6 },
+{ 10 , 10 , 9 , 7 },
+{ 10 , 10 , 9 , 8 },
+{ 10 , 10 , 9 , 9 },
+{ 10 , 20 , 0 , 0 },
+{ 10 , 20 , 0 , 1 },
+{ 10 , 20 , 0 , 2 },
+{ 10 , 20 , 0 , 3 },
+{ 10 , 20 , 0 , 4 },
+{ 10 , 20 , 0 , 5 },
+{ 10 , 20 , 0 , 6 },
+{ 10 , 20 , 0 , 7 },
+{ 10 , 20 , 0 , 8 },
+{ 10 , 20 , 0 , 9 },
+{ 10 , 20 , 0 , 10 },
+{ 10 , 20 , 0 , 11 },
+{ 10 , 20 , 0 , 12 },
+{ 10 , 20 , 0 , 13 },
+{ 10 , 20 , 0 , 14 },
+{ 10 , 20 , 0 , 15 },
+{ 10 , 20 , 0 , 16 },
+{ 10 , 20 , 0 , 17 },
+{ 10 , 20 , 0 , 18 },
+{ 10 , 20 , 0 , 19 },
+{ 10 , 20 , 1 , 0 },
+{ 10 , 20 , 1 , 1 },
+{ 10 , 20 , 1 , 2 },
+{ 10 , 20 , 1 , 3 },
+{ 10 , 20 , 1 , 4 },
+{ 10 , 20 , 1 , 5 },
+{ 10 , 20 , 1 , 6 },
+{ 10 , 20 , 1 , 7 },
+{ 10 , 20 , 1 , 8 },
+{ 10 , 20 , 1 , 9 },
+{ 10 , 20 , 1 , 10 },
+{ 10 , 20 , 1 , 11 },
+{ 10 , 20 , 1 , 12 },
+{ 10 , 20 , 1 , 13 },
+{ 10 , 20 , 1 , 14 },
+{ 10 , 20 , 1 , 15 },
+{ 10 , 20 , 1 , 16 },
+{ 10 , 20 , 1 , 17 },
+{ 10 , 20 , 1 , 18 },
+{ 10 , 20 , 1 , 19 },
+{ 10 , 20 , 2 , 0 },
+{ 10 , 20 , 2 , 1 },
+{ 10 , 20 , 2 , 2 },
+{ 10 , 20 , 2 , 3 },
+{ 10 , 20 , 2 , 4 },
+{ 10 , 20 , 2 , 5 },
+{ 10 , 20 , 2 , 6 },
+{ 10 , 20 , 2 , 7 },
+{ 10 , 20 , 2 , 8 },
+{ 10 , 20 , 2 , 9 },
+{ 10 , 20 , 2 , 10 },
+{ 10 , 20 , 2 , 11 },
+{ 10 , 20 , 2 , 12 },
+{ 10 , 20 , 2 , 13 },
+{ 10 , 20 , 2 , 14 },
+{ 10 , 20 , 2 , 15 },
+{ 10 , 20 , 2 , 16 },
+{ 10 , 20 , 2 , 17 },
+{ 10 , 20 , 2 , 18 },
+{ 10 , 20 , 2 , 19 },
+{ 10 , 20 , 3 , 0 },
+{ 10 , 20 , 3 , 1 },
+{ 10 , 20 , 3 , 2 },
+{ 10 , 20 , 3 , 3 },
+{ 10 , 20 , 3 , 4 },
+{ 10 , 20 , 3 , 5 },
+{ 10 , 20 , 3 , 6 },
+{ 10 , 20 , 3 , 7 },
+{ 10 , 20 , 3 , 8 },
+{ 10 , 20 , 3 , 9 },
+{ 10 , 20 , 3 , 10 },
+{ 10 , 20 , 3 , 11 },
+{ 10 , 20 , 3 , 12 },
+{ 10 , 20 , 3 , 13 },
+{ 10 , 20 , 3 , 14 },
+{ 10 , 20 , 3 , 15 },
+{ 10 , 20 , 3 , 16 },
+{ 10 , 20 , 3 , 17 },
+{ 10 , 20 , 3 , 18 },
+{ 10 , 20 , 3 , 19 },
+{ 10 , 20 , 4 , 0 },
+{ 10 , 20 , 4 , 1 },
+{ 10 , 20 , 4 , 2 },
+{ 10 , 20 , 4 , 3 },
+{ 10 , 20 , 4 , 4 },
+{ 10 , 20 , 4 , 5 },
+{ 10 , 20 , 4 , 6 },
+{ 10 , 20 , 4 , 7 },
+{ 10 , 20 , 4 , 8 },
+{ 10 , 20 , 4 , 9 },
+{ 10 , 20 , 4 , 10 },
+{ 10 , 20 , 4 , 11 },
+{ 10 , 20 , 4 , 12 },
+{ 10 , 20 , 4 , 13 },
+{ 10 , 20 , 4 , 14 },
+{ 10 , 20 , 4 , 15 },
+{ 10 , 20 , 4 , 16 },
+{ 10 , 20 , 4 , 17 },
+{ 10 , 20 , 4 , 18 },
+{ 10 , 20 , 4 , 19 },
+{ 10 , 20 , 5 , 0 },
+{ 10 , 20 , 5 , 1 },
+{ 10 , 20 , 5 , 2 },
+{ 10 , 20 , 5 , 3 },
+{ 10 , 20 , 5 , 4 },
+{ 10 , 20 , 5 , 5 },
+{ 10 , 20 , 5 , 6 },
+{ 10 , 20 , 5 , 7 },
+{ 10 , 20 , 5 , 8 },
+{ 10 , 20 , 5 , 9 },
+{ 10 , 20 , 5 , 10 },
+{ 10 , 20 , 5 , 11 },
+{ 10 , 20 , 5 , 12 },
+{ 10 , 20 , 5 , 13 },
+{ 10 , 20 , 5 , 14 },
+{ 10 , 20 , 5 , 15 },
+{ 10 , 20 , 5 , 16 },
+{ 10 , 20 , 5 , 17 },
+{ 10 , 20 , 5 , 18 },
+{ 10 , 20 , 5 , 19 },
+{ 10 , 20 , 6 , 0 },
+{ 10 , 20 , 6 , 1 },
+{ 10 , 20 , 6 , 2 },
+{ 10 , 20 , 6 , 3 },
+{ 10 , 20 , 6 , 4 },
+{ 10 , 20 , 6 , 5 },
+{ 10 , 20 , 6 , 6 },
+{ 10 , 20 , 6 , 7 },
+{ 10 , 20 , 6 , 8 },
+{ 10 , 20 , 6 , 9 },
+{ 10 , 20 , 6 , 10 },
+{ 10 , 20 , 6 , 11 },
+{ 10 , 20 , 6 , 12 },
+{ 10 , 20 , 6 , 13 },
+{ 10 , 20 , 6 , 14 },
+{ 10 , 20 , 6 , 15 },
+{ 10 , 20 , 6 , 16 },
+{ 10 , 20 , 6 , 17 },
+{ 10 , 20 , 6 , 18 },
+{ 10 , 20 , 6 , 19 },
+{ 10 , 20 , 7 , 0 },
+{ 10 , 20 , 7 , 1 },
+{ 10 , 20 , 7 , 2 },
+{ 10 , 20 , 7 , 3 },
+{ 10 , 20 , 7 , 4 },
+{ 10 , 20 , 7 , 5 },
+{ 10 , 20 , 7 , 6 },
+{ 10 , 20 , 7 , 7 },
+{ 10 , 20 , 7 , 8 },
+{ 10 , 20 , 7 , 9 },
+{ 10 , 20 , 7 , 10 },
+{ 10 , 20 , 7 , 11 },
+{ 10 , 20 , 7 , 12 },
+{ 10 , 20 , 7 , 13 },
+{ 10 , 20 , 7 , 14 },
+{ 10 , 20 , 7 , 15 },
+{ 10 , 20 , 7 , 16 },
+{ 10 , 20 , 7 , 17 },
+{ 10 , 20 , 7 , 18 },
+{ 10 , 20 , 7 , 19 },
+{ 10 , 20 , 8 , 0 },
+{ 10 , 20 , 8 , 1 },
+{ 10 , 20 , 8 , 2 },
+{ 10 , 20 , 8 , 3 },
+{ 10 , 20 , 8 , 4 },
+{ 10 , 20 , 8 , 5 },
+{ 10 , 20 , 8 , 6 },
+{ 10 , 20 , 8 , 7 },
+{ 10 , 20 , 8 , 8 },
+{ 10 , 20 , 8 , 9 },
+{ 10 , 20 , 8 , 10 },
+{ 10 , 20 , 8 , 11 },
+{ 10 , 20 , 8 , 12 },
+{ 10 , 20 , 8 , 13 },
+{ 10 , 20 , 8 , 14 },
+{ 10 , 20 , 8 , 15 },
+{ 10 , 20 , 8 , 16 },
+{ 10 , 20 , 8 , 17 },
+{ 10 , 20 , 8 , 18 },
+{ 10 , 20 , 8 , 19 },
+{ 10 , 20 , 9 , 0 },
+{ 10 , 20 , 9 , 1 },
+{ 10 , 20 , 9 , 2 },
+{ 10 , 20 , 9 , 3 },
+{ 10 , 20 , 9 , 4 },
+{ 10 , 20 , 9 , 5 },
+{ 10 , 20 , 9 , 6 },
+{ 10 , 20 , 9 , 7 },
+{ 10 , 20 , 9 , 8 },
+{ 10 , 20 , 9 , 9 },
+{ 10 , 20 , 9 , 10 },
+{ 10 , 20 , 9 , 11 },
+{ 10 , 20 , 9 , 12 },
+{ 10 , 20 , 9 , 13 },
+{ 10 , 20 , 9 , 14 },
+{ 10 , 20 , 9 , 15 },
+{ 10 , 20 , 9 , 16 },
+{ 10 , 20 , 9 , 17 },
+{ 10 , 20 , 9 , 18 },
+{ 10 , 20 , 9 , 19 },
+{ 10 , 40 , 0 , 0 },
+{ 10 , 40 , 0 , 1 },
+{ 10 , 40 , 0 , 2 },
+{ 10 , 40 , 0 , 3 },
+{ 10 , 40 , 0 , 4 },
+{ 10 , 40 , 0 , 5 },
+{ 10 , 40 , 0 , 6 },
+{ 10 , 40 , 0 , 7 },
+{ 10 , 40 , 0 , 8 },
+{ 10 , 40 , 0 , 9 },
+{ 10 , 40 , 0 , 10 },
+{ 10 , 40 , 0 , 11 },
+{ 10 , 40 , 0 , 12 },
+{ 10 , 40 , 0 , 13 },
+{ 10 , 40 , 0 , 14 },
+{ 10 , 40 , 0 , 15 },
+{ 10 , 40 , 0 , 16 },
+{ 10 , 40 , 0 , 17 },
+{ 10 , 40 , 0 , 18 },
+{ 10 , 40 , 0 , 19 },
+{ 10 , 40 , 0 , 20 },
+{ 10 , 40 , 0 , 21 },
+{ 10 , 40 , 0 , 22 },
+{ 10 , 40 , 0 , 23 },
+{ 10 , 40 , 0 , 24 },
+{ 10 , 40 , 0 , 25 },
+{ 10 , 40 , 0 , 26 },
+{ 10 , 40 , 0 , 27 },
+{ 10 , 40 , 0 , 28 },
+{ 10 , 40 , 0 , 29 },
+{ 10 , 40 , 0 , 30 },
+{ 10 , 40 , 0 , 31 },
+{ 10 , 40 , 0 , 32 },
+{ 10 , 40 , 0 , 33 },
+{ 10 , 40 , 0 , 34 },
+{ 10 , 40 , 0 , 35 },
+{ 10 , 40 , 0 , 36 },
+{ 10 , 40 , 0 , 37 },
+{ 10 , 40 , 0 , 38 },
+{ 10 , 40 , 0 , 39 },
+{ 10 , 40 , 1 , 0 },
+{ 10 , 40 , 1 , 1 },
+{ 10 , 40 , 1 , 2 },
+{ 10 , 40 , 1 , 3 },
+{ 10 , 40 , 1 , 4 },
+{ 10 , 40 , 1 , 5 },
+{ 10 , 40 , 1 , 6 },
+{ 10 , 40 , 1 , 7 },
+{ 10 , 40 , 1 , 8 },
+{ 10 , 40 , 1 , 9 },
+{ 10 , 40 , 1 , 10 },
+{ 10 , 40 , 1 , 11 },
+{ 10 , 40 , 1 , 12 },
+{ 10 , 40 , 1 , 13 },
+{ 10 , 40 , 1 , 14 },
+{ 10 , 40 , 1 , 15 },
+{ 10 , 40 , 1 , 16 },
+{ 10 , 40 , 1 , 17 },
+{ 10 , 40 , 1 , 18 },
+{ 10 , 40 , 1 , 19 },
+{ 10 , 40 , 1 , 20 },
+{ 10 , 40 , 1 , 21 },
+{ 10 , 40 , 1 , 22 },
+{ 10 , 40 , 1 , 23 },
+{ 10 , 40 , 1 , 24 },
+{ 10 , 40 , 1 , 25 },
+{ 10 , 40 , 1 , 26 },
+{ 10 , 40 , 1 , 27 },
+{ 10 , 40 , 1 , 28 },
+{ 10 , 40 , 1 , 29 },
+{ 10 , 40 , 1 , 30 },
+{ 10 , 40 , 1 , 31 },
+{ 10 , 40 , 1 , 32 },
+{ 10 , 40 , 1 , 33 },
+{ 10 , 40 , 1 , 34 },
+{ 10 , 40 , 1 , 35 },
+{ 10 , 40 , 1 , 36 },
+{ 10 , 40 , 1 , 37 },
+{ 10 , 40 , 1 , 38 },
+{ 10 , 40 , 1 , 39 },
+{ 10 , 40 , 2 , 0 },
+{ 10 , 40 , 2 , 1 },
+{ 10 , 40 , 2 , 2 },
+{ 10 , 40 , 2 , 3 },
+{ 10 , 40 , 2 , 4 },
+{ 10 , 40 , 2 , 5 },
+{ 10 , 40 , 2 , 6 },
+{ 10 , 40 , 2 , 7 },
+{ 10 , 40 , 2 , 8 },
+{ 10 , 40 , 2 , 9 },
+{ 10 , 40 , 2 , 10 },
+{ 10 , 40 , 2 , 11 },
+{ 10 , 40 , 2 , 12 },
+{ 10 , 40 , 2 , 13 },
+{ 10 , 40 , 2 , 14 },
+{ 10 , 40 , 2 , 15 },
+{ 10 , 40 , 2 , 16 },
+{ 10 , 40 , 2 , 17 },
+{ 10 , 40 , 2 , 18 },
+{ 10 , 40 , 2 , 19 },
+{ 10 , 40 , 2 , 20 },
+{ 10 , 40 , 2 , 21 },
+{ 10 , 40 , 2 , 22 },
+{ 10 , 40 , 2 , 23 },
+{ 10 , 40 , 2 , 24 },
+{ 10 , 40 , 2 , 25 },
+{ 10 , 40 , 2 , 26 },
+{ 10 , 40 , 2 , 27 },
+{ 10 , 40 , 2 , 28 },
+{ 10 , 40 , 2 , 29 },
+{ 10 , 40 , 2 , 30 },
+{ 10 , 40 , 2 , 31 },
+{ 10 , 40 , 2 , 32 },
+{ 10 , 40 , 2 , 33 },
+{ 10 , 40 , 2 , 34 },
+{ 10 , 40 , 2 , 35 },
+{ 10 , 40 , 2 , 36 },
+{ 10 , 40 , 2 , 37 },
+{ 10 , 40 , 2 , 38 },
+{ 10 , 40 , 2 , 39 },
+{ 10 , 40 , 3 , 0 },
+{ 10 , 40 , 3 , 1 },
+{ 10 , 40 , 3 , 2 },
+{ 10 , 40 , 3 , 3 },
+{ 10 , 40 , 3 , 4 },
+{ 10 , 40 , 3 , 5 },
+{ 10 , 40 , 3 , 6 },
+{ 10 , 40 , 3 , 7 },
+{ 10 , 40 , 3 , 8 },
+{ 10 , 40 , 3 , 9 },
+{ 10 , 40 , 3 , 10 },
+{ 10 , 40 , 3 , 11 },
+{ 10 , 40 , 3 , 12 },
+{ 10 , 40 , 3 , 13 },
+{ 10 , 40 , 3 , 14 },
+{ 10 , 40 , 3 , 15 },
+{ 10 , 40 , 3 , 16 },
+{ 10 , 40 , 3 , 17 },
+{ 10 , 40 , 3 , 18 },
+{ 10 , 40 , 3 , 19 },
+{ 10 , 40 , 3 , 20 },
+{ 10 , 40 , 3 , 21 },
+{ 10 , 40 , 3 , 22 },
+{ 10 , 40 , 3 , 23 },
+{ 10 , 40 , 3 , 24 },
+{ 10 , 40 , 3 , 25 },
+{ 10 , 40 , 3 , 26 },
+{ 10 , 40 , 3 , 27 },
+{ 10 , 40 , 3 , 28 },
+{ 10 , 40 , 3 , 29 },
+{ 10 , 40 , 3 , 30 },
+{ 10 , 40 , 3 , 31 },
+{ 10 , 40 , 3 , 32 },
+{ 10 , 40 , 3 , 33 },
+{ 10 , 40 , 3 , 34 },
+{ 10 , 40 , 3 , 35 },
+{ 10 , 40 , 3 , 36 },
+{ 10 , 40 , 3 , 37 },
+{ 10 , 40 , 3 , 38 },
+{ 10 , 40 , 3 , 39 },
+{ 10 , 40 , 4 , 0 },
+{ 10 , 40 , 4 , 1 },
+{ 10 , 40 , 4 , 2 },
+{ 10 , 40 , 4 , 3 },
+{ 10 , 40 , 4 , 4 },
+{ 10 , 40 , 4 , 5 },
+{ 10 , 40 , 4 , 6 },
+{ 10 , 40 , 4 , 7 },
+{ 10 , 40 , 4 , 8 },
+{ 10 , 40 , 4 , 9 },
+{ 10 , 40 , 4 , 10 },
+{ 10 , 40 , 4 , 11 },
+{ 10 , 40 , 4 , 12 },
+{ 10 , 40 , 4 , 13 },
+{ 10 , 40 , 4 , 14 },
+{ 10 , 40 , 4 , 15 },
+{ 10 , 40 , 4 , 16 },
+{ 10 , 40 , 4 , 17 },
+{ 10 , 40 , 4 , 18 },
+{ 10 , 40 , 4 , 19 },
+{ 10 , 40 , 4 , 20 },
+{ 10 , 40 , 4 , 21 },
+{ 10 , 40 , 4 , 22 },
+{ 10 , 40 , 4 , 23 },
+{ 10 , 40 , 4 , 24 },
+{ 10 , 40 , 4 , 25 },
+{ 10 , 40 , 4 , 26 },
+{ 10 , 40 , 4 , 27 },
+{ 10 , 40 , 4 , 28 },
+{ 10 , 40 , 4 , 29 },
+{ 10 , 40 , 4 , 30 },
+{ 10 , 40 , 4 , 31 },
+{ 10 , 40 , 4 , 32 },
+{ 10 , 40 , 4 , 33 },
+{ 10 , 40 , 4 , 34 },
+{ 10 , 40 , 4 , 35 },
+{ 10 , 40 , 4 , 36 },
+{ 10 , 40 , 4 , 37 },
+{ 10 , 40 , 4 , 38 },
+{ 10 , 40 , 4 , 39 },
+{ 10 , 40 , 5 , 0 },
+{ 10 , 40 , 5 , 1 },
+{ 10 , 40 , 5 , 2 },
+{ 10 , 40 , 5 , 3 },
+{ 10 , 40 , 5 , 4 },
+{ 10 , 40 , 5 , 5 },
+{ 10 , 40 , 5 , 6 },
+{ 10 , 40 , 5 , 7 },
+{ 10 , 40 , 5 , 8 },
+{ 10 , 40 , 5 , 9 },
+{ 10 , 40 , 5 , 10 },
+{ 10 , 40 , 5 , 11 },
+{ 10 , 40 , 5 , 12 },
+{ 10 , 40 , 5 , 13 },
+{ 10 , 40 , 5 , 14 },
+{ 10 , 40 , 5 , 15 },
+{ 10 , 40 , 5 , 16 },
+{ 10 , 40 , 5 , 17 },
+{ 10 , 40 , 5 , 18 },
+{ 10 , 40 , 5 , 19 },
+{ 10 , 40 , 5 , 20 },
+{ 10 , 40 , 5 , 21 },
+{ 10 , 40 , 5 , 22 },
+{ 10 , 40 , 5 , 23 },
+{ 10 , 40 , 5 , 24 },
+{ 10 , 40 , 5 , 25 },
+{ 10 , 40 , 5 , 26 },
+{ 10 , 40 , 5 , 27 },
+{ 10 , 40 , 5 , 28 },
+{ 10 , 40 , 5 , 29 },
+{ 10 , 40 , 5 , 30 },
+{ 10 , 40 , 5 , 31 },
+{ 10 , 40 , 5 , 32 },
+{ 10 , 40 , 5 , 33 },
+{ 10 , 40 , 5 , 34 },
+{ 10 , 40 , 5 , 35 },
+{ 10 , 40 , 5 , 36 },
+{ 10 , 40 , 5 , 37 },
+{ 10 , 40 , 5 , 38 },
+{ 10 , 40 , 5 , 39 },
+{ 10 , 40 , 6 , 0 },
+{ 10 , 40 , 6 , 1 },
+{ 10 , 40 , 6 , 2 },
+{ 10 , 40 , 6 , 3 },
+{ 10 , 40 , 6 , 4 },
+{ 10 , 40 , 6 , 5 },
+{ 10 , 40 , 6 , 6 },
+{ 10 , 40 , 6 , 7 },
+{ 10 , 40 , 6 , 8 },
+{ 10 , 40 , 6 , 9 },
+{ 10 , 40 , 6 , 10 },
+{ 10 , 40 , 6 , 11 },
+{ 10 , 40 , 6 , 12 },
+{ 10 , 40 , 6 , 13 },
+{ 10 , 40 , 6 , 14 },
+{ 10 , 40 , 6 , 15 },
+{ 10 , 40 , 6 , 16 },
+{ 10 , 40 , 6 , 17 },
+{ 10 , 40 , 6 , 18 },
+{ 10 , 40 , 6 , 19 },
+{ 10 , 40 , 6 , 20 },
+{ 10 , 40 , 6 , 21 },
+{ 10 , 40 , 6 , 22 },
+{ 10 , 40 , 6 , 23 },
+{ 10 , 40 , 6 , 24 },
+{ 10 , 40 , 6 , 25 },
+{ 10 , 40 , 6 , 26 },
+{ 10 , 40 , 6 , 27 },
+{ 10 , 40 , 6 , 28 },
+{ 10 , 40 , 6 , 29 },
+{ 10 , 40 , 6 , 30 },
+{ 10 , 40 , 6 , 31 },
+{ 10 , 40 , 6 , 32 },
+{ 10 , 40 , 6 , 33 },
+{ 10 , 40 , 6 , 34 },
+{ 10 , 40 , 6 , 35 },
+{ 10 , 40 , 6 , 36 },
+{ 10 , 40 , 6 , 37 },
+{ 10 , 40 , 6 , 38 },
+{ 10 , 40 , 6 , 39 },
+{ 10 , 40 , 7 , 0 },
+{ 10 , 40 , 7 , 1 },
+{ 10 , 40 , 7 , 2 },
+{ 10 , 40 , 7 , 3 },
+{ 10 , 40 , 7 , 4 },
+{ 10 , 40 , 7 , 5 },
+{ 10 , 40 , 7 , 6 },
+{ 10 , 40 , 7 , 7 },
+{ 10 , 40 , 7 , 8 },
+{ 10 , 40 , 7 , 9 },
+{ 10 , 40 , 7 , 10 },
+{ 10 , 40 , 7 , 11 },
+{ 10 , 40 , 7 , 12 },
+{ 10 , 40 , 7 , 13 },
+{ 10 , 40 , 7 , 14 },
+{ 10 , 40 , 7 , 15 },
+{ 10 , 40 , 7 , 16 },
+{ 10 , 40 , 7 , 17 },
+{ 10 , 40 , 7 , 18 },
+{ 10 , 40 , 7 , 19 },
+{ 10 , 40 , 7 , 20 },
+{ 10 , 40 , 7 , 21 },
+{ 10 , 40 , 7 , 22 },
+{ 10 , 40 , 7 , 23 },
+{ 10 , 40 , 7 , 24 },
+{ 10 , 40 , 7 , 25 },
+{ 10 , 40 , 7 , 26 },
+{ 10 , 40 , 7 , 27 },
+{ 10 , 40 , 7 , 28 },
+{ 10 , 40 , 7 , 29 },
+{ 10 , 40 , 7 , 30 },
+{ 10 , 40 , 7 , 31 },
+{ 10 , 40 , 7 , 32 },
+{ 10 , 40 , 7 , 33 },
+{ 10 , 40 , 7 , 34 },
+{ 10 , 40 , 7 , 35 },
+{ 10 , 40 , 7 , 36 },
+{ 10 , 40 , 7 , 37 },
+{ 10 , 40 , 7 , 38 },
+{ 10 , 40 , 7 , 39 },
+{ 10 , 40 , 8 , 0 },
+{ 10 , 40 , 8 , 1 },
+{ 10 , 40 , 8 , 2 },
+{ 10 , 40 , 8 , 3 },
+{ 10 , 40 , 8 , 4 },
+{ 10 , 40 , 8 , 5 },
+{ 10 , 40 , 8 , 6 },
+{ 10 , 40 , 8 , 7 },
+{ 10 , 40 , 8 , 8 },
+{ 10 , 40 , 8 , 9 },
+{ 10 , 40 , 8 , 10 },
+{ 10 , 40 , 8 , 11 },
+{ 10 , 40 , 8 , 12 },
+{ 10 , 40 , 8 , 13 },
+{ 10 , 40 , 8 , 14 },
+{ 10 , 40 , 8 , 15 },
+{ 10 , 40 , 8 , 16 },
+{ 10 , 40 , 8 , 17 },
+{ 10 , 40 , 8 , 18 },
+{ 10 , 40 , 8 , 19 },
+{ 10 , 40 , 8 , 20 },
+{ 10 , 40 , 8 , 21 },
+{ 10 , 40 , 8 , 22 },
+{ 10 , 40 , 8 , 23 },
+{ 10 , 40 , 8 , 24 },
+{ 10 , 40 , 8 , 25 },
+{ 10 , 40 , 8 , 26 },
+{ 10 , 40 , 8 , 27 },
+{ 10 , 40 , 8 , 28 },
+{ 10 , 40 , 8 , 29 },
+{ 10 , 40 , 8 , 30 },
+{ 10 , 40 , 8 , 31 },
+{ 10 , 40 , 8 , 32 },
+{ 10 , 40 , 8 , 33 },
+{ 10 , 40 , 8 , 34 },
+{ 10 , 40 , 8 , 35 },
+{ 10 , 40 , 8 , 36 },
+{ 10 , 40 , 8 , 37 },
+{ 10 , 40 , 8 , 38 },
+{ 10 , 40 , 8 , 39 },
+{ 10 , 40 , 9 , 0 },
+{ 10 , 40 , 9 , 1 },
+{ 10 , 40 , 9 , 2 },
+{ 10 , 40 , 9 , 3 },
+{ 10 , 40 , 9 , 4 },
+{ 10 , 40 , 9 , 5 },
+{ 10 , 40 , 9 , 6 },
+{ 10 , 40 , 9 , 7 },
+{ 10 , 40 , 9 , 8 },
+{ 10 , 40 , 9 , 9 },
+{ 10 , 40 , 9 , 10 },
+{ 10 , 40 , 9 , 11 },
+{ 10 , 40 , 9 , 12 },
+{ 10 , 40 , 9 , 13 },
+{ 10 , 40 , 9 , 14 },
+{ 10 , 40 , 9 , 15 },
+{ 10 , 40 , 9 , 16 },
+{ 10 , 40 , 9 , 17 },
+{ 10 , 40 , 9 , 18 },
+{ 10 , 40 , 9 , 19 },
+{ 10 , 40 , 9 , 20 },
+{ 10 , 40 , 9 , 21 },
+{ 10 , 40 , 9 , 22 },
+{ 10 , 40 , 9 , 23 },
+{ 10 , 40 , 9 , 24 },
+{ 10 , 40 , 9 , 25 },
+{ 10 , 40 , 9 , 26 },
+{ 10 , 40 , 9 , 27 },
+{ 10 , 40 , 9 , 28 },
+{ 10 , 40 , 9 , 29 },
+{ 10 , 40 , 9 , 30 },
+{ 10 , 40 , 9 , 31 },
+{ 10 , 40 , 9 , 32 },
+{ 10 , 40 , 9 , 33 },
+{ 10 , 40 , 9 , 34 },
+{ 10 , 40 , 9 , 35 },
+{ 10 , 40 , 9 , 36 },
+{ 10 , 40 , 9 , 37 },
+{ 10 , 40 , 9 , 38 },
+{ 10 , 40 , 9 , 39 },
+{ 10 , 80 , 0 , 0 },
+{ 10 , 80 , 0 , 1 },
+{ 10 , 80 , 0 , 2 },
+{ 10 , 80 , 0 , 3 },
+{ 10 , 80 , 0 , 4 },
+{ 10 , 80 , 0 , 5 },
+{ 10 , 80 , 0 , 6 },
+{ 10 , 80 , 0 , 7 },
+{ 10 , 80 , 0 , 8 },
+{ 10 , 80 , 0 , 9 },
+{ 10 , 80 , 0 , 10 },
+{ 10 , 80 , 0 , 11 },
+{ 10 , 80 , 0 , 12 },
+{ 10 , 80 , 0 , 13 },
+{ 10 , 80 , 0 , 14 },
+{ 10 , 80 , 0 , 15 },
+{ 10 , 80 , 0 , 16 },
+{ 10 , 80 , 0 , 17 },
+{ 10 , 80 , 0 , 18 },
+{ 10 , 80 , 0 , 19 },
+{ 10 , 80 , 0 , 20 },
+{ 10 , 80 , 0 , 21 },
+{ 10 , 80 , 0 , 22 },
+{ 10 , 80 , 0 , 23 },
+{ 10 , 80 , 0 , 24 },
+{ 10 , 80 , 0 , 25 },
+{ 10 , 80 , 0 , 26 },
+{ 10 , 80 , 0 , 27 },
+{ 10 , 80 , 0 , 28 },
+{ 10 , 80 , 0 , 29 },
+{ 10 , 80 , 0 , 30 },
+{ 10 , 80 , 0 , 31 },
+{ 10 , 80 , 0 , 32 },
+{ 10 , 80 , 0 , 33 },
+{ 10 , 80 , 0 , 34 },
+{ 10 , 80 , 0 , 35 },
+{ 10 , 80 , 0 , 36 },
+{ 10 , 80 , 0 , 37 },
+{ 10 , 80 , 0 , 38 },
+{ 10 , 80 , 0 , 39 },
+{ 10 , 80 , 0 , 40 },
+{ 10 , 80 , 0 , 41 },
+{ 10 , 80 , 0 , 42 },
+{ 10 , 80 , 0 , 43 },
+{ 10 , 80 , 0 , 44 },
+{ 10 , 80 , 0 , 45 },
+{ 10 , 80 , 0 , 46 },
+{ 10 , 80 , 0 , 47 },
+{ 10 , 80 , 0 , 48 },
+{ 10 , 80 , 0 , 49 },
+{ 10 , 80 , 0 , 50 },
+{ 10 , 80 , 0 , 51 },
+{ 10 , 80 , 0 , 52 },
+{ 10 , 80 , 0 , 53 },
+{ 10 , 80 , 0 , 54 },
+{ 10 , 80 , 0 , 55 },
+{ 10 , 80 , 0 , 56 },
+{ 10 , 80 , 0 , 57 },
+{ 10 , 80 , 0 , 58 },
+{ 10 , 80 , 0 , 59 },
+{ 10 , 80 , 0 , 60 },
+{ 10 , 80 , 0 , 61 },
+{ 10 , 80 , 0 , 62 },
+{ 10 , 80 , 0 , 63 },
+{ 10 , 80 , 0 , 64 },
+{ 10 , 80 , 0 , 65 },
+{ 10 , 80 , 0 , 66 },
+{ 10 , 80 , 0 , 67 },
+{ 10 , 80 , 0 , 68 },
+{ 10 , 80 , 0 , 69 },
+{ 10 , 80 , 0 , 70 },
+{ 10 , 80 , 0 , 71 },
+{ 10 , 80 , 0 , 72 },
+{ 10 , 80 , 0 , 73 },
+{ 10 , 80 , 0 , 74 },
+{ 10 , 80 , 0 , 75 },
+{ 10 , 80 , 0 , 76 },
+{ 10 , 80 , 0 , 77 },
+{ 10 , 80 , 0 , 78 },
+{ 10 , 80 , 0 , 79 },
+{ 10 , 80 , 1 , 0 },
+{ 10 , 80 , 1 , 1 },
+{ 10 , 80 , 1 , 2 },
+{ 10 , 80 , 1 , 3 },
+{ 10 , 80 , 1 , 4 },
+{ 10 , 80 , 1 , 5 },
+{ 10 , 80 , 1 , 6 },
+{ 10 , 80 , 1 , 7 },
+{ 10 , 80 , 1 , 8 },
+{ 10 , 80 , 1 , 9 },
+{ 10 , 80 , 1 , 10 },
+{ 10 , 80 , 1 , 11 },
+{ 10 , 80 , 1 , 12 },
+{ 10 , 80 , 1 , 13 },
+{ 10 , 80 , 1 , 14 },
+{ 10 , 80 , 1 , 15 },
+{ 10 , 80 , 1 , 16 },
+{ 10 , 80 , 1 , 17 },
+{ 10 , 80 , 1 , 18 },
+{ 10 , 80 , 1 , 19 },
+{ 10 , 80 , 1 , 20 },
+{ 10 , 80 , 1 , 21 },
+{ 10 , 80 , 1 , 22 },
+{ 10 , 80 , 1 , 23 },
+{ 10 , 80 , 1 , 24 },
+{ 10 , 80 , 1 , 25 },
+{ 10 , 80 , 1 , 26 },
+{ 10 , 80 , 1 , 27 },
+{ 10 , 80 , 1 , 28 },
+{ 10 , 80 , 1 , 29 },
+{ 10 , 80 , 1 , 30 },
+{ 10 , 80 , 1 , 31 },
+{ 10 , 80 , 1 , 32 },
+{ 10 , 80 , 1 , 33 },
+{ 10 , 80 , 1 , 34 },
+{ 10 , 80 , 1 , 35 },
+{ 10 , 80 , 1 , 36 },
+{ 10 , 80 , 1 , 37 },
+{ 10 , 80 , 1 , 38 },
+{ 10 , 80 , 1 , 39 },
+{ 10 , 80 , 1 , 40 },
+{ 10 , 80 , 1 , 41 },
+{ 10 , 80 , 1 , 42 },
+{ 10 , 80 , 1 , 43 },
+{ 10 , 80 , 1 , 44 },
+{ 10 , 80 , 1 , 45 },
+{ 10 , 80 , 1 , 46 },
+{ 10 , 80 , 1 , 47 },
+{ 10 , 80 , 1 , 48 },
+{ 10 , 80 , 1 , 49 },
+{ 10 , 80 , 1 , 50 },
+{ 10 , 80 , 1 , 51 },
+{ 10 , 80 , 1 , 52 },
+{ 10 , 80 , 1 , 53 },
+{ 10 , 80 , 1 , 54 },
+{ 10 , 80 , 1 , 55 },
+{ 10 , 80 , 1 , 56 },
+{ 10 , 80 , 1 , 57 },
+{ 10 , 80 , 1 , 58 },
+{ 10 , 80 , 1 , 59 },
+{ 10 , 80 , 1 , 60 },
+{ 10 , 80 , 1 , 61 },
+{ 10 , 80 , 1 , 62 },
+{ 10 , 80 , 1 , 63 },
+{ 10 , 80 , 1 , 64 },
+{ 10 , 80 , 1 , 65 },
+{ 10 , 80 , 1 , 66 },
+{ 10 , 80 , 1 , 67 },
+{ 10 , 80 , 1 , 68 },
+{ 10 , 80 , 1 , 69 },
+{ 10 , 80 , 1 , 70 },
+{ 10 , 80 , 1 , 71 },
+{ 10 , 80 , 1 , 72 },
+{ 10 , 80 , 1 , 73 },
+{ 10 , 80 , 1 , 74 },
+{ 10 , 80 , 1 , 75 },
+{ 10 , 80 , 1 , 76 },
+{ 10 , 80 , 1 , 77 },
+{ 10 , 80 , 1 , 78 },
+{ 10 , 80 , 1 , 79 },
+{ 10 , 80 , 2 , 0 },
+{ 10 , 80 , 2 , 1 },
+{ 10 , 80 , 2 , 2 },
+{ 10 , 80 , 2 , 3 },
+{ 10 , 80 , 2 , 4 },
+{ 10 , 80 , 2 , 5 },
+{ 10 , 80 , 2 , 6 },
+{ 10 , 80 , 2 , 7 },
+{ 10 , 80 , 2 , 8 },
+{ 10 , 80 , 2 , 9 },
+{ 10 , 80 , 2 , 10 },
+{ 10 , 80 , 2 , 11 },
+{ 10 , 80 , 2 , 12 },
+{ 10 , 80 , 2 , 13 },
+{ 10 , 80 , 2 , 14 },
+{ 10 , 80 , 2 , 15 },
+{ 10 , 80 , 2 , 16 },
+{ 10 , 80 , 2 , 17 },
+{ 10 , 80 , 2 , 18 },
+{ 10 , 80 , 2 , 19 },
+{ 10 , 80 , 2 , 20 },
+{ 10 , 80 , 2 , 21 },
+{ 10 , 80 , 2 , 22 },
+{ 10 , 80 , 2 , 23 },
+{ 10 , 80 , 2 , 24 },
+{ 10 , 80 , 2 , 25 },
+{ 10 , 80 , 2 , 26 },
+{ 10 , 80 , 2 , 27 },
+{ 10 , 80 , 2 , 28 },
+{ 10 , 80 , 2 , 29 },
+{ 10 , 80 , 2 , 30 },
+{ 10 , 80 , 2 , 31 },
+{ 10 , 80 , 2 , 32 },
+{ 10 , 80 , 2 , 33 },
+{ 10 , 80 , 2 , 34 },
+{ 10 , 80 , 2 , 35 },
+{ 10 , 80 , 2 , 36 },
+{ 10 , 80 , 2 , 37 },
+{ 10 , 80 , 2 , 38 },
+{ 10 , 80 , 2 , 39 },
+{ 10 , 80 , 2 , 40 },
+{ 10 , 80 , 2 , 41 },
+{ 10 , 80 , 2 , 42 },
+{ 10 , 80 , 2 , 43 },
+{ 10 , 80 , 2 , 44 },
+{ 10 , 80 , 2 , 45 },
+{ 10 , 80 , 2 , 46 },
+{ 10 , 80 , 2 , 47 },
+{ 10 , 80 , 2 , 48 },
+{ 10 , 80 , 2 , 49 },
+{ 10 , 80 , 2 , 50 },
+{ 10 , 80 , 2 , 51 },
+{ 10 , 80 , 2 , 52 },
+{ 10 , 80 , 2 , 53 },
+{ 10 , 80 , 2 , 54 },
+{ 10 , 80 , 2 , 55 },
+{ 10 , 80 , 2 , 56 },
+{ 10 , 80 , 2 , 57 },
+{ 10 , 80 , 2 , 58 },
+{ 10 , 80 , 2 , 59 },
+{ 10 , 80 , 2 , 60 },
+{ 10 , 80 , 2 , 61 },
+{ 10 , 80 , 2 , 62 },
+{ 10 , 80 , 2 , 63 },
+{ 10 , 80 , 2 , 64 },
+{ 10 , 80 , 2 , 65 },
+{ 10 , 80 , 2 , 66 },
+{ 10 , 80 , 2 , 67 },
+{ 10 , 80 , 2 , 68 },
+{ 10 , 80 , 2 , 69 },
+{ 10 , 80 , 2 , 70 },
+{ 10 , 80 , 2 , 71 },
+{ 10 , 80 , 2 , 72 },
+{ 10 , 80 , 2 , 73 },
+{ 10 , 80 , 2 , 74 },
+{ 10 , 80 , 2 , 75 },
+{ 10 , 80 , 2 , 76 },
+{ 10 , 80 , 2 , 77 },
+{ 10 , 80 , 2 , 78 },
+{ 10 , 80 , 2 , 79 },
+{ 10 , 80 , 3 , 0 },
+{ 10 , 80 , 3 , 1 },
+{ 10 , 80 , 3 , 2 },
+{ 10 , 80 , 3 , 3 },
+{ 10 , 80 , 3 , 4 },
+{ 10 , 80 , 3 , 5 },
+{ 10 , 80 , 3 , 6 },
+{ 10 , 80 , 3 , 7 },
+{ 10 , 80 , 3 , 8 },
+{ 10 , 80 , 3 , 9 },
+{ 10 , 80 , 3 , 10 },
+{ 10 , 80 , 3 , 11 },
+{ 10 , 80 , 3 , 12 },
+{ 10 , 80 , 3 , 13 },
+{ 10 , 80 , 3 , 14 },
+{ 10 , 80 , 3 , 15 },
+{ 10 , 80 , 3 , 16 },
+{ 10 , 80 , 3 , 17 },
+{ 10 , 80 , 3 , 18 },
+{ 10 , 80 , 3 , 19 },
+{ 10 , 80 , 3 , 20 },
+{ 10 , 80 , 3 , 21 },
+{ 10 , 80 , 3 , 22 },
+{ 10 , 80 , 3 , 23 },
+{ 10 , 80 , 3 , 24 },
+{ 10 , 80 , 3 , 25 },
+{ 10 , 80 , 3 , 26 },
+{ 10 , 80 , 3 , 27 },
+{ 10 , 80 , 3 , 28 },
+{ 10 , 80 , 3 , 29 },
+{ 10 , 80 , 3 , 30 },
+{ 10 , 80 , 3 , 31 },
+{ 10 , 80 , 3 , 32 },
+{ 10 , 80 , 3 , 33 },
+{ 10 , 80 , 3 , 34 },
+{ 10 , 80 , 3 , 35 },
+{ 10 , 80 , 3 , 36 },
+{ 10 , 80 , 3 , 37 },
+{ 10 , 80 , 3 , 38 },
+{ 10 , 80 , 3 , 39 },
+{ 10 , 80 , 3 , 40 },
+{ 10 , 80 , 3 , 41 },
+{ 10 , 80 , 3 , 42 },
+{ 10 , 80 , 3 , 43 },
+{ 10 , 80 , 3 , 44 },
+{ 10 , 80 , 3 , 45 },
+{ 10 , 80 , 3 , 46 },
+{ 10 , 80 , 3 , 47 },
+{ 10 , 80 , 3 , 48 },
+{ 10 , 80 , 3 , 49 },
+{ 10 , 80 , 3 , 50 },
+{ 10 , 80 , 3 , 51 },
+{ 10 , 80 , 3 , 52 },
+{ 10 , 80 , 3 , 53 },
+{ 10 , 80 , 3 , 54 },
+{ 10 , 80 , 3 , 55 },
+{ 10 , 80 , 3 , 56 },
+{ 10 , 80 , 3 , 57 },
+{ 10 , 80 , 3 , 58 },
+{ 10 , 80 , 3 , 59 },
+{ 10 , 80 , 3 , 60 },
+{ 10 , 80 , 3 , 61 },
+{ 10 , 80 , 3 , 62 },
+{ 10 , 80 , 3 , 63 },
+{ 10 , 80 , 3 , 64 },
+{ 10 , 80 , 3 , 65 },
+{ 10 , 80 , 3 , 66 },
+{ 10 , 80 , 3 , 67 },
+{ 10 , 80 , 3 , 68 },
+{ 10 , 80 , 3 , 69 },
+{ 10 , 80 , 3 , 70 },
+{ 10 , 80 , 3 , 71 },
+{ 10 , 80 , 3 , 72 },
+{ 10 , 80 , 3 , 73 },
+{ 10 , 80 , 3 , 74 },
+{ 10 , 80 , 3 , 75 },
+{ 10 , 80 , 3 , 76 },
+{ 10 , 80 , 3 , 77 },
+{ 10 , 80 , 3 , 78 },
+{ 10 , 80 , 3 , 79 },
+{ 10 , 80 , 4 , 0 },
+{ 10 , 80 , 4 , 1 },
+{ 10 , 80 , 4 , 2 },
+{ 10 , 80 , 4 , 3 },
+{ 10 , 80 , 4 , 4 },
+{ 10 , 80 , 4 , 5 },
+{ 10 , 80 , 4 , 6 },
+{ 10 , 80 , 4 , 7 },
+{ 10 , 80 , 4 , 8 },
+{ 10 , 80 , 4 , 9 },
+{ 10 , 80 , 4 , 10 },
+{ 10 , 80 , 4 , 11 },
+{ 10 , 80 , 4 , 12 },
+{ 10 , 80 , 4 , 13 },
+{ 10 , 80 , 4 , 14 },
+{ 10 , 80 , 4 , 15 },
+{ 10 , 80 , 4 , 16 },
+{ 10 , 80 , 4 , 17 },
+{ 10 , 80 , 4 , 18 },
+{ 10 , 80 , 4 , 19 },
+{ 10 , 80 , 4 , 20 },
+{ 10 , 80 , 4 , 21 },
+{ 10 , 80 , 4 , 22 },
+{ 10 , 80 , 4 , 23 },
+{ 10 , 80 , 4 , 24 },
+{ 10 , 80 , 4 , 25 },
+{ 10 , 80 , 4 , 26 },
+{ 10 , 80 , 4 , 27 },
+{ 10 , 80 , 4 , 28 },
+{ 10 , 80 , 4 , 29 },
+{ 10 , 80 , 4 , 30 },
+{ 10 , 80 , 4 , 31 },
+{ 10 , 80 , 4 , 32 },
+{ 10 , 80 , 4 , 33 },
+{ 10 , 80 , 4 , 34 },
+{ 10 , 80 , 4 , 35 },
+{ 10 , 80 , 4 , 36 },
+{ 10 , 80 , 4 , 37 },
+{ 10 , 80 , 4 , 38 },
+{ 10 , 80 , 4 , 39 },
+{ 10 , 80 , 4 , 40 },
+{ 10 , 80 , 4 , 41 },
+{ 10 , 80 , 4 , 42 },
+{ 10 , 80 , 4 , 43 },
+{ 10 , 80 , 4 , 44 },
+{ 10 , 80 , 4 , 45 },
+{ 10 , 80 , 4 , 46 },
+{ 10 , 80 , 4 , 47 },
+{ 10 , 80 , 4 , 48 },
+{ 10 , 80 , 4 , 49 },
+{ 10 , 80 , 4 , 50 },
+{ 10 , 80 , 4 , 51 },
+{ 10 , 80 , 4 , 52 },
+{ 10 , 80 , 4 , 53 },
+{ 10 , 80 , 4 , 54 },
+{ 10 , 80 , 4 , 55 },
+{ 10 , 80 , 4 , 56 },
+{ 10 , 80 , 4 , 57 },
+{ 10 , 80 , 4 , 58 },
+{ 10 , 80 , 4 , 59 },
+{ 10 , 80 , 4 , 60 },
+{ 10 , 80 , 4 , 61 },
+{ 10 , 80 , 4 , 62 },
+{ 10 , 80 , 4 , 63 },
+{ 10 , 80 , 4 , 64 },
+{ 10 , 80 , 4 , 65 },
+{ 10 , 80 , 4 , 66 },
+{ 10 , 80 , 4 , 67 },
+{ 10 , 80 , 4 , 68 },
+{ 10 , 80 , 4 , 69 },
+{ 10 , 80 , 4 , 70 },
+{ 10 , 80 , 4 , 71 },
+{ 10 , 80 , 4 , 72 },
+{ 10 , 80 , 4 , 73 },
+{ 10 , 80 , 4 , 74 },
+{ 10 , 80 , 4 , 75 },
+{ 10 , 80 , 4 , 76 },
+{ 10 , 80 , 4 , 77 },
+{ 10 , 80 , 4 , 78 },
+{ 10 , 80 , 4 , 79 },
+{ 10 , 80 , 5 , 0 },
+{ 10 , 80 , 5 , 1 },
+{ 10 , 80 , 5 , 2 },
+{ 10 , 80 , 5 , 3 },
+{ 10 , 80 , 5 , 4 },
+{ 10 , 80 , 5 , 5 },
+{ 10 , 80 , 5 , 6 },
+{ 10 , 80 , 5 , 7 },
+{ 10 , 80 , 5 , 8 },
+{ 10 , 80 , 5 , 9 },
+{ 10 , 80 , 5 , 10 },
+{ 10 , 80 , 5 , 11 },
+{ 10 , 80 , 5 , 12 },
+{ 10 , 80 , 5 , 13 },
+{ 10 , 80 , 5 , 14 },
+{ 10 , 80 , 5 , 15 },
+{ 10 , 80 , 5 , 16 },
+{ 10 , 80 , 5 , 17 },
+{ 10 , 80 , 5 , 18 },
+{ 10 , 80 , 5 , 19 },
+{ 10 , 80 , 5 , 20 },
+{ 10 , 80 , 5 , 21 },
+{ 10 , 80 , 5 , 22 },
+{ 10 , 80 , 5 , 23 },
+{ 10 , 80 , 5 , 24 },
+{ 10 , 80 , 5 , 25 },
+{ 10 , 80 , 5 , 26 },
+{ 10 , 80 , 5 , 27 },
+{ 10 , 80 , 5 , 28 },
+{ 10 , 80 , 5 , 29 },
+{ 10 , 80 , 5 , 30 },
+{ 10 , 80 , 5 , 31 },
+{ 10 , 80 , 5 , 32 },
+{ 10 , 80 , 5 , 33 },
+{ 10 , 80 , 5 , 34 },
+{ 10 , 80 , 5 , 35 },
+{ 10 , 80 , 5 , 36 },
+{ 10 , 80 , 5 , 37 },
+{ 10 , 80 , 5 , 38 },
+{ 10 , 80 , 5 , 39 },
+{ 10 , 80 , 5 , 40 },
+{ 10 , 80 , 5 , 41 },
+{ 10 , 80 , 5 , 42 },
+{ 10 , 80 , 5 , 43 },
+{ 10 , 80 , 5 , 44 },
+{ 10 , 80 , 5 , 45 },
+{ 10 , 80 , 5 , 46 },
+{ 10 , 80 , 5 , 47 },
+{ 10 , 80 , 5 , 48 },
+{ 10 , 80 , 5 , 49 },
+{ 10 , 80 , 5 , 50 },
+{ 10 , 80 , 5 , 51 },
+{ 10 , 80 , 5 , 52 },
+{ 10 , 80 , 5 , 53 },
+{ 10 , 80 , 5 , 54 },
+{ 10 , 80 , 5 , 55 },
+{ 10 , 80 , 5 , 56 },
+{ 10 , 80 , 5 , 57 },
+{ 10 , 80 , 5 , 58 },
+{ 10 , 80 , 5 , 59 },
+{ 10 , 80 , 5 , 60 },
+{ 10 , 80 , 5 , 61 },
+{ 10 , 80 , 5 , 62 },
+{ 10 , 80 , 5 , 63 },
+{ 10 , 80 , 5 , 64 },
+{ 10 , 80 , 5 , 65 },
+{ 10 , 80 , 5 , 66 },
+{ 10 , 80 , 5 , 67 },
+{ 10 , 80 , 5 , 68 },
+{ 10 , 80 , 5 , 69 },
+{ 10 , 80 , 5 , 70 },
+{ 10 , 80 , 5 , 71 },
+{ 10 , 80 , 5 , 72 },
+{ 10 , 80 , 5 , 73 },
+{ 10 , 80 , 5 , 74 },
+{ 10 , 80 , 5 , 75 },
+{ 10 , 80 , 5 , 76 },
+{ 10 , 80 , 5 , 77 },
+{ 10 , 80 , 5 , 78 },
+{ 10 , 80 , 5 , 79 },
+{ 10 , 80 , 6 , 0 },
+{ 10 , 80 , 6 , 1 },
+{ 10 , 80 , 6 , 2 },
+{ 10 , 80 , 6 , 3 },
+{ 10 , 80 , 6 , 4 },
+{ 10 , 80 , 6 , 5 },
+{ 10 , 80 , 6 , 6 },
+{ 10 , 80 , 6 , 7 },
+{ 10 , 80 , 6 , 8 },
+{ 10 , 80 , 6 , 9 },
+{ 10 , 80 , 6 , 10 },
+{ 10 , 80 , 6 , 11 },
+{ 10 , 80 , 6 , 12 },
+{ 10 , 80 , 6 , 13 },
+{ 10 , 80 , 6 , 14 },
+{ 10 , 80 , 6 , 15 },
+{ 10 , 80 , 6 , 16 },
+{ 10 , 80 , 6 , 17 },
+{ 10 , 80 , 6 , 18 },
+{ 10 , 80 , 6 , 19 },
+{ 10 , 80 , 6 , 20 },
+{ 10 , 80 , 6 , 21 },
+{ 10 , 80 , 6 , 22 },
+{ 10 , 80 , 6 , 23 },
+{ 10 , 80 , 6 , 24 },
+{ 10 , 80 , 6 , 25 },
+{ 10 , 80 , 6 , 26 },
+{ 10 , 80 , 6 , 27 },
+{ 10 , 80 , 6 , 28 },
+{ 10 , 80 , 6 , 29 },
+{ 10 , 80 , 6 , 30 },
+{ 10 , 80 , 6 , 31 },
+{ 10 , 80 , 6 , 32 },
+{ 10 , 80 , 6 , 33 },
+{ 10 , 80 , 6 , 34 },
+{ 10 , 80 , 6 , 35 },
+{ 10 , 80 , 6 , 36 },
+{ 10 , 80 , 6 , 37 },
+{ 10 , 80 , 6 , 38 },
+{ 10 , 80 , 6 , 39 },
+{ 10 , 80 , 6 , 40 },
+{ 10 , 80 , 6 , 41 },
+{ 10 , 80 , 6 , 42 },
+{ 10 , 80 , 6 , 43 },
+{ 10 , 80 , 6 , 44 },
+{ 10 , 80 , 6 , 45 },
+{ 10 , 80 , 6 , 46 },
+{ 10 , 80 , 6 , 47 },
+{ 10 , 80 , 6 , 48 },
+{ 10 , 80 , 6 , 49 },
+{ 10 , 80 , 6 , 50 },
+{ 10 , 80 , 6 , 51 },
+{ 10 , 80 , 6 , 52 },
+{ 10 , 80 , 6 , 53 },
+{ 10 , 80 , 6 , 54 },
+{ 10 , 80 , 6 , 55 },
+{ 10 , 80 , 6 , 56 },
+{ 10 , 80 , 6 , 57 },
+{ 10 , 80 , 6 , 58 },
+{ 10 , 80 , 6 , 59 },
+{ 10 , 80 , 6 , 60 },
+{ 10 , 80 , 6 , 61 },
+{ 10 , 80 , 6 , 62 },
+{ 10 , 80 , 6 , 63 },
+{ 10 , 80 , 6 , 64 },
+{ 10 , 80 , 6 , 65 },
+{ 10 , 80 , 6 , 66 },
+{ 10 , 80 , 6 , 67 },
+{ 10 , 80 , 6 , 68 },
+{ 10 , 80 , 6 , 69 },
+{ 10 , 80 , 6 , 70 },
+{ 10 , 80 , 6 , 71 },
+{ 10 , 80 , 6 , 72 },
+{ 10 , 80 , 6 , 73 },
+{ 10 , 80 , 6 , 74 },
+{ 10 , 80 , 6 , 75 },
+{ 10 , 80 , 6 , 76 },
+{ 10 , 80 , 6 , 77 },
+{ 10 , 80 , 6 , 78 },
+{ 10 , 80 , 6 , 79 },
+{ 10 , 80 , 7 , 0 },
+{ 10 , 80 , 7 , 1 },
+{ 10 , 80 , 7 , 2 },
+{ 10 , 80 , 7 , 3 },
+{ 10 , 80 , 7 , 4 },
+{ 10 , 80 , 7 , 5 },
+{ 10 , 80 , 7 , 6 },
+{ 10 , 80 , 7 , 7 },
+{ 10 , 80 , 7 , 8 },
+{ 10 , 80 , 7 , 9 },
+{ 10 , 80 , 7 , 10 },
+{ 10 , 80 , 7 , 11 },
+{ 10 , 80 , 7 , 12 },
+{ 10 , 80 , 7 , 13 },
+{ 10 , 80 , 7 , 14 },
+{ 10 , 80 , 7 , 15 },
+{ 10 , 80 , 7 , 16 },
+{ 10 , 80 , 7 , 17 },
+{ 10 , 80 , 7 , 18 },
+{ 10 , 80 , 7 , 19 },
+{ 10 , 80 , 7 , 20 },
+{ 10 , 80 , 7 , 21 },
+{ 10 , 80 , 7 , 22 },
+{ 10 , 80 , 7 , 23 },
+{ 10 , 80 , 7 , 24 },
+{ 10 , 80 , 7 , 25 },
+{ 10 , 80 , 7 , 26 },
+{ 10 , 80 , 7 , 27 },
+{ 10 , 80 , 7 , 28 },
+{ 10 , 80 , 7 , 29 },
+{ 10 , 80 , 7 , 30 },
+{ 10 , 80 , 7 , 31 },
+{ 10 , 80 , 7 , 32 },
+{ 10 , 80 , 7 , 33 },
+{ 10 , 80 , 7 , 34 },
+{ 10 , 80 , 7 , 35 },
+{ 10 , 80 , 7 , 36 },
+{ 10 , 80 , 7 , 37 },
+{ 10 , 80 , 7 , 38 },
+{ 10 , 80 , 7 , 39 },
+{ 10 , 80 , 7 , 40 },
+{ 10 , 80 , 7 , 41 },
+{ 10 , 80 , 7 , 42 },
+{ 10 , 80 , 7 , 43 },
+{ 10 , 80 , 7 , 44 },
+{ 10 , 80 , 7 , 45 },
+{ 10 , 80 , 7 , 46 },
+{ 10 , 80 , 7 , 47 },
+{ 10 , 80 , 7 , 48 },
+{ 10 , 80 , 7 , 49 },
+{ 10 , 80 , 7 , 50 },
+{ 10 , 80 , 7 , 51 },
+{ 10 , 80 , 7 , 52 },
+{ 10 , 80 , 7 , 53 },
+{ 10 , 80 , 7 , 54 },
+{ 10 , 80 , 7 , 55 },
+{ 10 , 80 , 7 , 56 },
+{ 10 , 80 , 7 , 57 },
+{ 10 , 80 , 7 , 58 },
+{ 10 , 80 , 7 , 59 },
+{ 10 , 80 , 7 , 60 },
+{ 10 , 80 , 7 , 61 },
+{ 10 , 80 , 7 , 62 },
+{ 10 , 80 , 7 , 63 },
+{ 10 , 80 , 7 , 64 },
+{ 10 , 80 , 7 , 65 },
+{ 10 , 80 , 7 , 66 },
+{ 10 , 80 , 7 , 67 },
+{ 10 , 80 , 7 , 68 },
+{ 10 , 80 , 7 , 69 },
+{ 10 , 80 , 7 , 70 },
+{ 10 , 80 , 7 , 71 },
+{ 10 , 80 , 7 , 72 },
+{ 10 , 80 , 7 , 73 },
+{ 10 , 80 , 7 , 74 },
+{ 10 , 80 , 7 , 75 },
+{ 10 , 80 , 7 , 76 },
+{ 10 , 80 , 7 , 77 },
+{ 10 , 80 , 7 , 78 },
+{ 10 , 80 , 7 , 79 },
+{ 10 , 80 , 8 , 0 },
+{ 10 , 80 , 8 , 1 },
+{ 10 , 80 , 8 , 2 },
+{ 10 , 80 , 8 , 3 },
+{ 10 , 80 , 8 , 4 },
+{ 10 , 80 , 8 , 5 },
+{ 10 , 80 , 8 , 6 },
+{ 10 , 80 , 8 , 7 },
+{ 10 , 80 , 8 , 8 },
+{ 10 , 80 , 8 , 9 },
+{ 10 , 80 , 8 , 10 },
+{ 10 , 80 , 8 , 11 },
+{ 10 , 80 , 8 , 12 },
+{ 10 , 80 , 8 , 13 },
+{ 10 , 80 , 8 , 14 },
+{ 10 , 80 , 8 , 15 },
+{ 10 , 80 , 8 , 16 },
+{ 10 , 80 , 8 , 17 },
+{ 10 , 80 , 8 , 18 },
+{ 10 , 80 , 8 , 19 },
+{ 10 , 80 , 8 , 20 },
+{ 10 , 80 , 8 , 21 },
+{ 10 , 80 , 8 , 22 },
+{ 10 , 80 , 8 , 23 },
+{ 10 , 80 , 8 , 24 },
+{ 10 , 80 , 8 , 25 },
+{ 10 , 80 , 8 , 26 },
+{ 10 , 80 , 8 , 27 },
+{ 10 , 80 , 8 , 28 },
+{ 10 , 80 , 8 , 29 },
+{ 10 , 80 , 8 , 30 },
+{ 10 , 80 , 8 , 31 },
+{ 10 , 80 , 8 , 32 },
+{ 10 , 80 , 8 , 33 },
+{ 10 , 80 , 8 , 34 },
+{ 10 , 80 , 8 , 35 },
+{ 10 , 80 , 8 , 36 },
+{ 10 , 80 , 8 , 37 },
+{ 10 , 80 , 8 , 38 },
+{ 10 , 80 , 8 , 39 },
+{ 10 , 80 , 8 , 40 },
+{ 10 , 80 , 8 , 41 },
+{ 10 , 80 , 8 , 42 },
+{ 10 , 80 , 8 , 43 },
+{ 10 , 80 , 8 , 44 },
+{ 10 , 80 , 8 , 45 },
+{ 10 , 80 , 8 , 46 },
+{ 10 , 80 , 8 , 47 },
+{ 10 , 80 , 8 , 48 },
+{ 10 , 80 , 8 , 49 },
+{ 10 , 80 , 8 , 50 },
+{ 10 , 80 , 8 , 51 },
+{ 10 , 80 , 8 , 52 },
+{ 10 , 80 , 8 , 53 },
+{ 10 , 80 , 8 , 54 },
+{ 10 , 80 , 8 , 55 },
+{ 10 , 80 , 8 , 56 },
+{ 10 , 80 , 8 , 57 },
+{ 10 , 80 , 8 , 58 },
+{ 10 , 80 , 8 , 59 },
+{ 10 , 80 , 8 , 60 },
+{ 10 , 80 , 8 , 61 },
+{ 10 , 80 , 8 , 62 },
+{ 10 , 80 , 8 , 63 },
+{ 10 , 80 , 8 , 64 },
+{ 10 , 80 , 8 , 65 },
+{ 10 , 80 , 8 , 66 },
+{ 10 , 80 , 8 , 67 },
+{ 10 , 80 , 8 , 68 },
+{ 10 , 80 , 8 , 69 },
+{ 10 , 80 , 8 , 70 },
+{ 10 , 80 , 8 , 71 },
+{ 10 , 80 , 8 , 72 },
+{ 10 , 80 , 8 , 73 },
+{ 10 , 80 , 8 , 74 },
+{ 10 , 80 , 8 , 75 },
+{ 10 , 80 , 8 , 76 },
+{ 10 , 80 , 8 , 77 },
+{ 10 , 80 , 8 , 78 },
+{ 10 , 80 , 8 , 79 },
+{ 10 , 80 , 9 , 0 },
+{ 10 , 80 , 9 , 1 },
+{ 10 , 80 , 9 , 2 },
+{ 10 , 80 , 9 , 3 },
+{ 10 , 80 , 9 , 4 },
+{ 10 , 80 , 9 , 5 },
+{ 10 , 80 , 9 , 6 },
+{ 10 , 80 , 9 , 7 },
+{ 10 , 80 , 9 , 8 },
+{ 10 , 80 , 9 , 9 },
+{ 10 , 80 , 9 , 10 },
+{ 10 , 80 , 9 , 11 },
+{ 10 , 80 , 9 , 12 },
+{ 10 , 80 , 9 , 13 },
+{ 10 , 80 , 9 , 14 },
+{ 10 , 80 , 9 , 15 },
+{ 10 , 80 , 9 , 16 },
+{ 10 , 80 , 9 , 17 },
+{ 10 , 80 , 9 , 18 },
+{ 10 , 80 , 9 , 19 },
+{ 10 , 80 , 9 , 20 },
+{ 10 , 80 , 9 , 21 },
+{ 10 , 80 , 9 , 22 },
+{ 10 , 80 , 9 , 23 },
+{ 10 , 80 , 9 , 24 },
+{ 10 , 80 , 9 , 25 },
+{ 10 , 80 , 9 , 26 },
+{ 10 , 80 , 9 , 27 },
+{ 10 , 80 , 9 , 28 },
+{ 10 , 80 , 9 , 29 },
+{ 10 , 80 , 9 , 30 },
+{ 10 , 80 , 9 , 31 },
+{ 10 , 80 , 9 , 32 },
+{ 10 , 80 , 9 , 33 },
+{ 10 , 80 , 9 , 34 },
+{ 10 , 80 , 9 , 35 },
+{ 10 , 80 , 9 , 36 },
+{ 10 , 80 , 9 , 37 },
+{ 10 , 80 , 9 , 38 },
+{ 10 , 80 , 9 , 39 },
+{ 10 , 80 , 9 , 40 },
+{ 10 , 80 , 9 , 41 },
+{ 10 , 80 , 9 , 42 },
+{ 10 , 80 , 9 , 43 },
+{ 10 , 80 , 9 , 44 },
+{ 10 , 80 , 9 , 45 },
+{ 10 , 80 , 9 , 46 },
+{ 10 , 80 , 9 , 47 },
+{ 10 , 80 , 9 , 48 },
+{ 10 , 80 , 9 , 49 },
+{ 10 , 80 , 9 , 50 },
+{ 10 , 80 , 9 , 51 },
+{ 10 , 80 , 9 , 52 },
+{ 10 , 80 , 9 , 53 },
+{ 10 , 80 , 9 , 54 },
+{ 10 , 80 , 9 , 55 },
+{ 10 , 80 , 9 , 56 },
+{ 10 , 80 , 9 , 57 },
+{ 10 , 80 , 9 , 58 },
+{ 10 , 80 , 9 , 59 },
+{ 10 , 80 , 9 , 60 },
+{ 10 , 80 , 9 , 61 },
+{ 10 , 80 , 9 , 62 },
+{ 10 , 80 , 9 , 63 },
+{ 10 , 80 , 9 , 64 },
+{ 10 , 80 , 9 , 65 },
+{ 10 , 80 , 9 , 66 },
+{ 10 , 80 , 9 , 67 },
+{ 10 , 80 , 9 , 68 },
+{ 10 , 80 , 9 , 69 },
+{ 10 , 80 , 9 , 70 },
+{ 10 , 80 , 9 , 71 },
+{ 10 , 80 , 9 , 72 },
+{ 10 , 80 , 9 , 73 },
+{ 10 , 80 , 9 , 74 },
+{ 10 , 80 , 9 , 75 },
+{ 10 , 80 , 9 , 76 },
+{ 10 , 80 , 9 , 77 },
+{ 10 , 80 , 9 , 78 },
+{ 10 , 80 , 9 , 79 },
+{ 20 , 5 , 0 , 0 },
+{ 20 , 5 , 0 , 1 },
+{ 20 , 5 , 0 , 2 },
+{ 20 , 5 , 0 , 3 },
+{ 20 , 5 , 0 , 4 },
+{ 20 , 5 , 1 , 0 },
+{ 20 , 5 , 1 , 1 },
+{ 20 , 5 , 1 , 2 },
+{ 20 , 5 , 1 , 3 },
+{ 20 , 5 , 1 , 4 },
+{ 20 , 5 , 2 , 0 },
+{ 20 , 5 , 2 , 1 },
+{ 20 , 5 , 2 , 2 },
+{ 20 , 5 , 2 , 3 },
+{ 20 , 5 , 2 , 4 },
+{ 20 , 5 , 3 , 0 },
+{ 20 , 5 , 3 , 1 },
+{ 20 , 5 , 3 , 2 },
+{ 20 , 5 , 3 , 3 },
+{ 20 , 5 , 3 , 4 },
+{ 20 , 5 , 4 , 0 },
+{ 20 , 5 , 4 , 1 },
+{ 20 , 5 , 4 , 2 },
+{ 20 , 5 , 4 , 3 },
+{ 20 , 5 , 4 , 4 },
+{ 20 , 5 , 5 , 0 },
+{ 20 , 5 , 5 , 1 },
+{ 20 , 5 , 5 , 2 },
+{ 20 , 5 , 5 , 3 },
+{ 20 , 5 , 5 , 4 },
+{ 20 , 5 , 6 , 0 },
+{ 20 , 5 , 6 , 1 },
+{ 20 , 5 , 6 , 2 },
+{ 20 , 5 , 6 , 3 },
+{ 20 , 5 , 6 , 4 },
+{ 20 , 5 , 7 , 0 },
+{ 20 , 5 , 7 , 1 },
+{ 20 , 5 , 7 , 2 },
+{ 20 , 5 , 7 , 3 },
+{ 20 , 5 , 7 , 4 },
+{ 20 , 5 , 8 , 0 },
+{ 20 , 5 , 8 , 1 },
+{ 20 , 5 , 8 , 2 },
+{ 20 , 5 , 8 , 3 },
+{ 20 , 5 , 8 , 4 },
+{ 20 , 5 , 9 , 0 },
+{ 20 , 5 , 9 , 1 },
+{ 20 , 5 , 9 , 2 },
+{ 20 , 5 , 9 , 3 },
+{ 20 , 5 , 9 , 4 },
+{ 20 , 5 , 10 , 0 },
+{ 20 , 5 , 10 , 1 },
+{ 20 , 5 , 10 , 2 },
+{ 20 , 5 , 10 , 3 },
+{ 20 , 5 , 10 , 4 },
+{ 20 , 5 , 11 , 0 },
+{ 20 , 5 , 11 , 1 },
+{ 20 , 5 , 11 , 2 },
+{ 20 , 5 , 11 , 3 },
+{ 20 , 5 , 11 , 4 },
+{ 20 , 5 , 12 , 0 },
+{ 20 , 5 , 12 , 1 },
+{ 20 , 5 , 12 , 2 },
+{ 20 , 5 , 12 , 3 },
+{ 20 , 5 , 12 , 4 },
+{ 20 , 5 , 13 , 0 },
+{ 20 , 5 , 13 , 1 },
+{ 20 , 5 , 13 , 2 },
+{ 20 , 5 , 13 , 3 },
+{ 20 , 5 , 13 , 4 },
+{ 20 , 5 , 14 , 0 },
+{ 20 , 5 , 14 , 1 },
+{ 20 , 5 , 14 , 2 },
+{ 20 , 5 , 14 , 3 },
+{ 20 , 5 , 14 , 4 },
+{ 20 , 5 , 15 , 0 },
+{ 20 , 5 , 15 , 1 },
+{ 20 , 5 , 15 , 2 },
+{ 20 , 5 , 15 , 3 },
+{ 20 , 5 , 15 , 4 },
+{ 20 , 5 , 16 , 0 },
+{ 20 , 5 , 16 , 1 },
+{ 20 , 5 , 16 , 2 },
+{ 20 , 5 , 16 , 3 },
+{ 20 , 5 , 16 , 4 },
+{ 20 , 5 , 17 , 0 },
+{ 20 , 5 , 17 , 1 },
+{ 20 , 5 , 17 , 2 },
+{ 20 , 5 , 17 , 3 },
+{ 20 , 5 , 17 , 4 },
+{ 20 , 5 , 18 , 0 },
+{ 20 , 5 , 18 , 1 },
+{ 20 , 5 , 18 , 2 },
+{ 20 , 5 , 18 , 3 },
+{ 20 , 5 , 18 , 4 },
+{ 20 , 5 , 19 , 0 },
+{ 20 , 5 , 19 , 1 },
+{ 20 , 5 , 19 , 2 },
+{ 20 , 5 , 19 , 3 },
+{ 20 , 5 , 19 , 4 },
+{ 20 , 10 , 0 , 0 },
+{ 20 , 10 , 0 , 1 },
+{ 20 , 10 , 0 , 2 },
+{ 20 , 10 , 0 , 3 },
+{ 20 , 10 , 0 , 4 },
+{ 20 , 10 , 0 , 5 },
+{ 20 , 10 , 0 , 6 },
+{ 20 , 10 , 0 , 7 },
+{ 20 , 10 , 0 , 8 },
+{ 20 , 10 , 0 , 9 },
+{ 20 , 10 , 1 , 0 },
+{ 20 , 10 , 1 , 1 },
+{ 20 , 10 , 1 , 2 },
+{ 20 , 10 , 1 , 3 },
+{ 20 , 10 , 1 , 4 },
+{ 20 , 10 , 1 , 5 },
+{ 20 , 10 , 1 , 6 },
+{ 20 , 10 , 1 , 7 },
+{ 20 , 10 , 1 , 8 },
+{ 20 , 10 , 1 , 9 },
+{ 20 , 10 , 2 , 0 },
+{ 20 , 10 , 2 , 1 },
+{ 20 , 10 , 2 , 2 },
+{ 20 , 10 , 2 , 3 },
+{ 20 , 10 , 2 , 4 },
+{ 20 , 10 , 2 , 5 },
+{ 20 , 10 , 2 , 6 },
+{ 20 , 10 , 2 , 7 },
+{ 20 , 10 , 2 , 8 },
+{ 20 , 10 , 2 , 9 },
+{ 20 , 10 , 3 , 0 },
+{ 20 , 10 , 3 , 1 },
+{ 20 , 10 , 3 , 2 },
+{ 20 , 10 , 3 , 3 },
+{ 20 , 10 , 3 , 4 },
+{ 20 , 10 , 3 , 5 },
+{ 20 , 10 , 3 , 6 },
+{ 20 , 10 , 3 , 7 },
+{ 20 , 10 , 3 , 8 },
+{ 20 , 10 , 3 , 9 },
+{ 20 , 10 , 4 , 0 },
+{ 20 , 10 , 4 , 1 },
+{ 20 , 10 , 4 , 2 },
+{ 20 , 10 , 4 , 3 },
+{ 20 , 10 , 4 , 4 },
+{ 20 , 10 , 4 , 5 },
+{ 20 , 10 , 4 , 6 },
+{ 20 , 10 , 4 , 7 },
+{ 20 , 10 , 4 , 8 },
+{ 20 , 10 , 4 , 9 },
+{ 20 , 10 , 5 , 0 },
+{ 20 , 10 , 5 , 1 },
+{ 20 , 10 , 5 , 2 },
+{ 20 , 10 , 5 , 3 },
+{ 20 , 10 , 5 , 4 },
+{ 20 , 10 , 5 , 5 },
+{ 20 , 10 , 5 , 6 },
+{ 20 , 10 , 5 , 7 },
+{ 20 , 10 , 5 , 8 },
+{ 20 , 10 , 5 , 9 },
+{ 20 , 10 , 6 , 0 },
+{ 20 , 10 , 6 , 1 },
+{ 20 , 10 , 6 , 2 },
+{ 20 , 10 , 6 , 3 },
+{ 20 , 10 , 6 , 4 },
+{ 20 , 10 , 6 , 5 },
+{ 20 , 10 , 6 , 6 },
+{ 20 , 10 , 6 , 7 },
+{ 20 , 10 , 6 , 8 },
+{ 20 , 10 , 6 , 9 },
+{ 20 , 10 , 7 , 0 },
+{ 20 , 10 , 7 , 1 },
+{ 20 , 10 , 7 , 2 },
+{ 20 , 10 , 7 , 3 },
+{ 20 , 10 , 7 , 4 },
+{ 20 , 10 , 7 , 5 },
+{ 20 , 10 , 7 , 6 },
+{ 20 , 10 , 7 , 7 },
+{ 20 , 10 , 7 , 8 },
+{ 20 , 10 , 7 , 9 },
+{ 20 , 10 , 8 , 0 },
+{ 20 , 10 , 8 , 1 },
+{ 20 , 10 , 8 , 2 },
+{ 20 , 10 , 8 , 3 },
+{ 20 , 10 , 8 , 4 },
+{ 20 , 10 , 8 , 5 },
+{ 20 , 10 , 8 , 6 },
+{ 20 , 10 , 8 , 7 },
+{ 20 , 10 , 8 , 8 },
+{ 20 , 10 , 8 , 9 },
+{ 20 , 10 , 9 , 0 },
+{ 20 , 10 , 9 , 1 },
+{ 20 , 10 , 9 , 2 },
+{ 20 , 10 , 9 , 3 },
+{ 20 , 10 , 9 , 4 },
+{ 20 , 10 , 9 , 5 },
+{ 20 , 10 , 9 , 6 },
+{ 20 , 10 , 9 , 7 },
+{ 20 , 10 , 9 , 8 },
+{ 20 , 10 , 9 , 9 },
+{ 20 , 10 , 10 , 0 },
+{ 20 , 10 , 10 , 1 },
+{ 20 , 10 , 10 , 2 },
+{ 20 , 10 , 10 , 3 },
+{ 20 , 10 , 10 , 4 },
+{ 20 , 10 , 10 , 5 },
+{ 20 , 10 , 10 , 6 },
+{ 20 , 10 , 10 , 7 },
+{ 20 , 10 , 10 , 8 },
+{ 20 , 10 , 10 , 9 },
+{ 20 , 10 , 11 , 0 },
+{ 20 , 10 , 11 , 1 },
+{ 20 , 10 , 11 , 2 },
+{ 20 , 10 , 11 , 3 },
+{ 20 , 10 , 11 , 4 },
+{ 20 , 10 , 11 , 5 },
+{ 20 , 10 , 11 , 6 },
+{ 20 , 10 , 11 , 7 },
+{ 20 , 10 , 11 , 8 },
+{ 20 , 10 , 11 , 9 },
+{ 20 , 10 , 12 , 0 },
+{ 20 , 10 , 12 , 1 },
+{ 20 , 10 , 12 , 2 },
+{ 20 , 10 , 12 , 3 },
+{ 20 , 10 , 12 , 4 },
+{ 20 , 10 , 12 , 5 },
+{ 20 , 10 , 12 , 6 },
+{ 20 , 10 , 12 , 7 },
+{ 20 , 10 , 12 , 8 },
+{ 20 , 10 , 12 , 9 },
+{ 20 , 10 , 13 , 0 },
+{ 20 , 10 , 13 , 1 },
+{ 20 , 10 , 13 , 2 },
+{ 20 , 10 , 13 , 3 },
+{ 20 , 10 , 13 , 4 },
+{ 20 , 10 , 13 , 5 },
+{ 20 , 10 , 13 , 6 },
+{ 20 , 10 , 13 , 7 },
+{ 20 , 10 , 13 , 8 },
+{ 20 , 10 , 13 , 9 },
+{ 20 , 10 , 14 , 0 },
+{ 20 , 10 , 14 , 1 },
+{ 20 , 10 , 14 , 2 },
+{ 20 , 10 , 14 , 3 },
+{ 20 , 10 , 14 , 4 },
+{ 20 , 10 , 14 , 5 },
+{ 20 , 10 , 14 , 6 },
+{ 20 , 10 , 14 , 7 },
+{ 20 , 10 , 14 , 8 },
+{ 20 , 10 , 14 , 9 },
+{ 20 , 10 , 15 , 0 },
+{ 20 , 10 , 15 , 1 },
+{ 20 , 10 , 15 , 2 },
+{ 20 , 10 , 15 , 3 },
+{ 20 , 10 , 15 , 4 },
+{ 20 , 10 , 15 , 5 },
+{ 20 , 10 , 15 , 6 },
+{ 20 , 10 , 15 , 7 },
+{ 20 , 10 , 15 , 8 },
+{ 20 , 10 , 15 , 9 },
+{ 20 , 10 , 16 , 0 },
+{ 20 , 10 , 16 , 1 },
+{ 20 , 10 , 16 , 2 },
+{ 20 , 10 , 16 , 3 },
+{ 20 , 10 , 16 , 4 },
+{ 20 , 10 , 16 , 5 },
+{ 20 , 10 , 16 , 6 },
+{ 20 , 10 , 16 , 7 },
+{ 20 , 10 , 16 , 8 },
+{ 20 , 10 , 16 , 9 },
+{ 20 , 10 , 17 , 0 },
+{ 20 , 10 , 17 , 1 },
+{ 20 , 10 , 17 , 2 },
+{ 20 , 10 , 17 , 3 },
+{ 20 , 10 , 17 , 4 },
+{ 20 , 10 , 17 , 5 },
+{ 20 , 10 , 17 , 6 },
+{ 20 , 10 , 17 , 7 },
+{ 20 , 10 , 17 , 8 },
+{ 20 , 10 , 17 , 9 },
+{ 20 , 10 , 18 , 0 },
+{ 20 , 10 , 18 , 1 },
+{ 20 , 10 , 18 , 2 },
+{ 20 , 10 , 18 , 3 },
+{ 20 , 10 , 18 , 4 },
+{ 20 , 10 , 18 , 5 },
+{ 20 , 10 , 18 , 6 },
+{ 20 , 10 , 18 , 7 },
+{ 20 , 10 , 18 , 8 },
+{ 20 , 10 , 18 , 9 },
+{ 20 , 10 , 19 , 0 },
+{ 20 , 10 , 19 , 1 },
+{ 20 , 10 , 19 , 2 },
+{ 20 , 10 , 19 , 3 },
+{ 20 , 10 , 19 , 4 },
+{ 20 , 10 , 19 , 5 },
+{ 20 , 10 , 19 , 6 },
+{ 20 , 10 , 19 , 7 },
+{ 20 , 10 , 19 , 8 },
+{ 20 , 10 , 19 , 9 },
+{ 20 , 20 , 0 , 0 },
+{ 20 , 20 , 0 , 1 },
+{ 20 , 20 , 0 , 2 },
+{ 20 , 20 , 0 , 3 },
+{ 20 , 20 , 0 , 4 },
+{ 20 , 20 , 0 , 5 },
+{ 20 , 20 , 0 , 6 },
+{ 20 , 20 , 0 , 7 },
+{ 20 , 20 , 0 , 8 },
+{ 20 , 20 , 0 , 9 },
+{ 20 , 20 , 0 , 10 },
+{ 20 , 20 , 0 , 11 },
+{ 20 , 20 , 0 , 12 },
+{ 20 , 20 , 0 , 13 },
+{ 20 , 20 , 0 , 14 },
+{ 20 , 20 , 0 , 15 },
+{ 20 , 20 , 0 , 16 },
+{ 20 , 20 , 0 , 17 },
+{ 20 , 20 , 0 , 18 },
+{ 20 , 20 , 0 , 19 },
+{ 20 , 20 , 1 , 0 },
+{ 20 , 20 , 1 , 1 },
+{ 20 , 20 , 1 , 2 },
+{ 20 , 20 , 1 , 3 },
+{ 20 , 20 , 1 , 4 },
+{ 20 , 20 , 1 , 5 },
+{ 20 , 20 , 1 , 6 },
+{ 20 , 20 , 1 , 7 },
+{ 20 , 20 , 1 , 8 },
+{ 20 , 20 , 1 , 9 },
+{ 20 , 20 , 1 , 10 },
+{ 20 , 20 , 1 , 11 },
+{ 20 , 20 , 1 , 12 },
+{ 20 , 20 , 1 , 13 },
+{ 20 , 20 , 1 , 14 },
+{ 20 , 20 , 1 , 15 },
+{ 20 , 20 , 1 , 16 },
+{ 20 , 20 , 1 , 17 },
+{ 20 , 20 , 1 , 18 },
+{ 20 , 20 , 1 , 19 },
+{ 20 , 20 , 2 , 0 },
+{ 20 , 20 , 2 , 1 },
+{ 20 , 20 , 2 , 2 },
+{ 20 , 20 , 2 , 3 },
+{ 20 , 20 , 2 , 4 },
+{ 20 , 20 , 2 , 5 },
+{ 20 , 20 , 2 , 6 },
+{ 20 , 20 , 2 , 7 },
+{ 20 , 20 , 2 , 8 },
+{ 20 , 20 , 2 , 9 },
+{ 20 , 20 , 2 , 10 },
+{ 20 , 20 , 2 , 11 },
+{ 20 , 20 , 2 , 12 },
+{ 20 , 20 , 2 , 13 },
+{ 20 , 20 , 2 , 14 },
+{ 20 , 20 , 2 , 15 },
+{ 20 , 20 , 2 , 16 },
+{ 20 , 20 , 2 , 17 },
+{ 20 , 20 , 2 , 18 },
+{ 20 , 20 , 2 , 19 },
+{ 20 , 20 , 3 , 0 },
+{ 20 , 20 , 3 , 1 },
+{ 20 , 20 , 3 , 2 },
+{ 20 , 20 , 3 , 3 },
+{ 20 , 20 , 3 , 4 },
+{ 20 , 20 , 3 , 5 },
+{ 20 , 20 , 3 , 6 },
+{ 20 , 20 , 3 , 7 },
+{ 20 , 20 , 3 , 8 },
+{ 20 , 20 , 3 , 9 },
+{ 20 , 20 , 3 , 10 },
+{ 20 , 20 , 3 , 11 },
+{ 20 , 20 , 3 , 12 },
+{ 20 , 20 , 3 , 13 },
+{ 20 , 20 , 3 , 14 },
+{ 20 , 20 , 3 , 15 },
+{ 20 , 20 , 3 , 16 },
+{ 20 , 20 , 3 , 17 },
+{ 20 , 20 , 3 , 18 },
+{ 20 , 20 , 3 , 19 },
+{ 20 , 20 , 4 , 0 },
+{ 20 , 20 , 4 , 1 },
+{ 20 , 20 , 4 , 2 },
+{ 20 , 20 , 4 , 3 },
+{ 20 , 20 , 4 , 4 },
+{ 20 , 20 , 4 , 5 },
+{ 20 , 20 , 4 , 6 },
+{ 20 , 20 , 4 , 7 },
+{ 20 , 20 , 4 , 8 },
+{ 20 , 20 , 4 , 9 },
+{ 20 , 20 , 4 , 10 },
+{ 20 , 20 , 4 , 11 },
+{ 20 , 20 , 4 , 12 },
+{ 20 , 20 , 4 , 13 },
+{ 20 , 20 , 4 , 14 },
+{ 20 , 20 , 4 , 15 },
+{ 20 , 20 , 4 , 16 },
+{ 20 , 20 , 4 , 17 },
+{ 20 , 20 , 4 , 18 },
+{ 20 , 20 , 4 , 19 },
+{ 20 , 20 , 5 , 0 },
+{ 20 , 20 , 5 , 1 },
+{ 20 , 20 , 5 , 2 },
+{ 20 , 20 , 5 , 3 },
+{ 20 , 20 , 5 , 4 },
+{ 20 , 20 , 5 , 5 },
+{ 20 , 20 , 5 , 6 },
+{ 20 , 20 , 5 , 7 },
+{ 20 , 20 , 5 , 8 },
+{ 20 , 20 , 5 , 9 },
+{ 20 , 20 , 5 , 10 },
+{ 20 , 20 , 5 , 11 },
+{ 20 , 20 , 5 , 12 },
+{ 20 , 20 , 5 , 13 },
+{ 20 , 20 , 5 , 14 },
+{ 20 , 20 , 5 , 15 },
+{ 20 , 20 , 5 , 16 },
+{ 20 , 20 , 5 , 17 },
+{ 20 , 20 , 5 , 18 },
+{ 20 , 20 , 5 , 19 },
+{ 20 , 20 , 6 , 0 },
+{ 20 , 20 , 6 , 1 },
+{ 20 , 20 , 6 , 2 },
+{ 20 , 20 , 6 , 3 },
+{ 20 , 20 , 6 , 4 },
+{ 20 , 20 , 6 , 5 },
+{ 20 , 20 , 6 , 6 },
+{ 20 , 20 , 6 , 7 },
+{ 20 , 20 , 6 , 8 },
+{ 20 , 20 , 6 , 9 },
+{ 20 , 20 , 6 , 10 },
+{ 20 , 20 , 6 , 11 },
+{ 20 , 20 , 6 , 12 },
+{ 20 , 20 , 6 , 13 },
+{ 20 , 20 , 6 , 14 },
+{ 20 , 20 , 6 , 15 },
+{ 20 , 20 , 6 , 16 },
+{ 20 , 20 , 6 , 17 },
+{ 20 , 20 , 6 , 18 },
+{ 20 , 20 , 6 , 19 },
+{ 20 , 20 , 7 , 0 },
+{ 20 , 20 , 7 , 1 },
+{ 20 , 20 , 7 , 2 },
+{ 20 , 20 , 7 , 3 },
+{ 20 , 20 , 7 , 4 },
+{ 20 , 20 , 7 , 5 },
+{ 20 , 20 , 7 , 6 },
+{ 20 , 20 , 7 , 7 },
+{ 20 , 20 , 7 , 8 },
+{ 20 , 20 , 7 , 9 },
+{ 20 , 20 , 7 , 10 },
+{ 20 , 20 , 7 , 11 },
+{ 20 , 20 , 7 , 12 },
+{ 20 , 20 , 7 , 13 },
+{ 20 , 20 , 7 , 14 },
+{ 20 , 20 , 7 , 15 },
+{ 20 , 20 , 7 , 16 },
+{ 20 , 20 , 7 , 17 },
+{ 20 , 20 , 7 , 18 },
+{ 20 , 20 , 7 , 19 },
+{ 20 , 20 , 8 , 0 },
+{ 20 , 20 , 8 , 1 },
+{ 20 , 20 , 8 , 2 },
+{ 20 , 20 , 8 , 3 },
+{ 20 , 20 , 8 , 4 },
+{ 20 , 20 , 8 , 5 },
+{ 20 , 20 , 8 , 6 },
+{ 20 , 20 , 8 , 7 },
+{ 20 , 20 , 8 , 8 },
+{ 20 , 20 , 8 , 9 },
+{ 20 , 20 , 8 , 10 },
+{ 20 , 20 , 8 , 11 },
+{ 20 , 20 , 8 , 12 },
+{ 20 , 20 , 8 , 13 },
+{ 20 , 20 , 8 , 14 },
+{ 20 , 20 , 8 , 15 },
+{ 20 , 20 , 8 , 16 },
+{ 20 , 20 , 8 , 17 },
+{ 20 , 20 , 8 , 18 },
+{ 20 , 20 , 8 , 19 },
+{ 20 , 20 , 9 , 0 },
+{ 20 , 20 , 9 , 1 },
+{ 20 , 20 , 9 , 2 },
+{ 20 , 20 , 9 , 3 },
+{ 20 , 20 , 9 , 4 },
+{ 20 , 20 , 9 , 5 },
+{ 20 , 20 , 9 , 6 },
+{ 20 , 20 , 9 , 7 },
+{ 20 , 20 , 9 , 8 },
+{ 20 , 20 , 9 , 9 },
+{ 20 , 20 , 9 , 10 },
+{ 20 , 20 , 9 , 11 },
+{ 20 , 20 , 9 , 12 },
+{ 20 , 20 , 9 , 13 },
+{ 20 , 20 , 9 , 14 },
+{ 20 , 20 , 9 , 15 },
+{ 20 , 20 , 9 , 16 },
+{ 20 , 20 , 9 , 17 },
+{ 20 , 20 , 9 , 18 },
+{ 20 , 20 , 9 , 19 },
+{ 20 , 20 , 10 , 0 },
+{ 20 , 20 , 10 , 1 },
+{ 20 , 20 , 10 , 2 },
+{ 20 , 20 , 10 , 3 },
+{ 20 , 20 , 10 , 4 },
+{ 20 , 20 , 10 , 5 },
+{ 20 , 20 , 10 , 6 },
+{ 20 , 20 , 10 , 7 },
+{ 20 , 20 , 10 , 8 },
+{ 20 , 20 , 10 , 9 },
+{ 20 , 20 , 10 , 10 },
+{ 20 , 20 , 10 , 11 },
+{ 20 , 20 , 10 , 12 },
+{ 20 , 20 , 10 , 13 },
+{ 20 , 20 , 10 , 14 },
+{ 20 , 20 , 10 , 15 },
+{ 20 , 20 , 10 , 16 },
+{ 20 , 20 , 10 , 17 },
+{ 20 , 20 , 10 , 18 },
+{ 20 , 20 , 10 , 19 },
+{ 20 , 20 , 11 , 0 },
+{ 20 , 20 , 11 , 1 },
+{ 20 , 20 , 11 , 2 },
+{ 20 , 20 , 11 , 3 },
+{ 20 , 20 , 11 , 4 },
+{ 20 , 20 , 11 , 5 },
+{ 20 , 20 , 11 , 6 },
+{ 20 , 20 , 11 , 7 },
+{ 20 , 20 , 11 , 8 },
+{ 20 , 20 , 11 , 9 },
+{ 20 , 20 , 11 , 10 },
+{ 20 , 20 , 11 , 11 },
+{ 20 , 20 , 11 , 12 },
+{ 20 , 20 , 11 , 13 },
+{ 20 , 20 , 11 , 14 },
+{ 20 , 20 , 11 , 15 },
+{ 20 , 20 , 11 , 16 },
+{ 20 , 20 , 11 , 17 },
+{ 20 , 20 , 11 , 18 },
+{ 20 , 20 , 11 , 19 },
+{ 20 , 20 , 12 , 0 },
+{ 20 , 20 , 12 , 1 },
+{ 20 , 20 , 12 , 2 },
+{ 20 , 20 , 12 , 3 },
+{ 20 , 20 , 12 , 4 },
+{ 20 , 20 , 12 , 5 },
+{ 20 , 20 , 12 , 6 },
+{ 20 , 20 , 12 , 7 },
+{ 20 , 20 , 12 , 8 },
+{ 20 , 20 , 12 , 9 },
+{ 20 , 20 , 12 , 10 },
+{ 20 , 20 , 12 , 11 },
+{ 20 , 20 , 12 , 12 },
+{ 20 , 20 , 12 , 13 },
+{ 20 , 20 , 12 , 14 },
+{ 20 , 20 , 12 , 15 },
+{ 20 , 20 , 12 , 16 },
+{ 20 , 20 , 12 , 17 },
+{ 20 , 20 , 12 , 18 },
+{ 20 , 20 , 12 , 19 },
+{ 20 , 20 , 13 , 0 },
+{ 20 , 20 , 13 , 1 },
+{ 20 , 20 , 13 , 2 },
+{ 20 , 20 , 13 , 3 },
+{ 20 , 20 , 13 , 4 },
+{ 20 , 20 , 13 , 5 },
+{ 20 , 20 , 13 , 6 },
+{ 20 , 20 , 13 , 7 },
+{ 20 , 20 , 13 , 8 },
+{ 20 , 20 , 13 , 9 },
+{ 20 , 20 , 13 , 10 },
+{ 20 , 20 , 13 , 11 },
+{ 20 , 20 , 13 , 12 },
+{ 20 , 20 , 13 , 13 },
+{ 20 , 20 , 13 , 14 },
+{ 20 , 20 , 13 , 15 },
+{ 20 , 20 , 13 , 16 },
+{ 20 , 20 , 13 , 17 },
+{ 20 , 20 , 13 , 18 },
+{ 20 , 20 , 13 , 19 },
+{ 20 , 20 , 14 , 0 },
+{ 20 , 20 , 14 , 1 },
+{ 20 , 20 , 14 , 2 },
+{ 20 , 20 , 14 , 3 },
+{ 20 , 20 , 14 , 4 },
+{ 20 , 20 , 14 , 5 },
+{ 20 , 20 , 14 , 6 },
+{ 20 , 20 , 14 , 7 },
+{ 20 , 20 , 14 , 8 },
+{ 20 , 20 , 14 , 9 },
+{ 20 , 20 , 14 , 10 },
+{ 20 , 20 , 14 , 11 },
+{ 20 , 20 , 14 , 12 },
+{ 20 , 20 , 14 , 13 },
+{ 20 , 20 , 14 , 14 },
+{ 20 , 20 , 14 , 15 },
+{ 20 , 20 , 14 , 16 },
+{ 20 , 20 , 14 , 17 },
+{ 20 , 20 , 14 , 18 },
+{ 20 , 20 , 14 , 19 },
+{ 20 , 20 , 15 , 0 },
+{ 20 , 20 , 15 , 1 },
+{ 20 , 20 , 15 , 2 },
+{ 20 , 20 , 15 , 3 },
+{ 20 , 20 , 15 , 4 },
+{ 20 , 20 , 15 , 5 },
+{ 20 , 20 , 15 , 6 },
+{ 20 , 20 , 15 , 7 },
+{ 20 , 20 , 15 , 8 },
+{ 20 , 20 , 15 , 9 },
+{ 20 , 20 , 15 , 10 },
+{ 20 , 20 , 15 , 11 },
+{ 20 , 20 , 15 , 12 },
+{ 20 , 20 , 15 , 13 },
+{ 20 , 20 , 15 , 14 },
+{ 20 , 20 , 15 , 15 },
+{ 20 , 20 , 15 , 16 },
+{ 20 , 20 , 15 , 17 },
+{ 20 , 20 , 15 , 18 },
+{ 20 , 20 , 15 , 19 },
+{ 20 , 20 , 16 , 0 },
+{ 20 , 20 , 16 , 1 },
+{ 20 , 20 , 16 , 2 },
+{ 20 , 20 , 16 , 3 },
+{ 20 , 20 , 16 , 4 },
+{ 20 , 20 , 16 , 5 },
+{ 20 , 20 , 16 , 6 },
+{ 20 , 20 , 16 , 7 },
+{ 20 , 20 , 16 , 8 },
+{ 20 , 20 , 16 , 9 },
+{ 20 , 20 , 16 , 10 },
+{ 20 , 20 , 16 , 11 },
+{ 20 , 20 , 16 , 12 },
+{ 20 , 20 , 16 , 13 },
+{ 20 , 20 , 16 , 14 },
+{ 20 , 20 , 16 , 15 },
+{ 20 , 20 , 16 , 16 },
+{ 20 , 20 , 16 , 17 },
+{ 20 , 20 , 16 , 18 },
+{ 20 , 20 , 16 , 19 },
+{ 20 , 20 , 17 , 0 },
+{ 20 , 20 , 17 , 1 },
+{ 20 , 20 , 17 , 2 },
+{ 20 , 20 , 17 , 3 },
+{ 20 , 20 , 17 , 4 },
+{ 20 , 20 , 17 , 5 },
+{ 20 , 20 , 17 , 6 },
+{ 20 , 20 , 17 , 7 },
+{ 20 , 20 , 17 , 8 },
+{ 20 , 20 , 17 , 9 },
+{ 20 , 20 , 17 , 10 },
+{ 20 , 20 , 17 , 11 },
+{ 20 , 20 , 17 , 12 },
+{ 20 , 20 , 17 , 13 },
+{ 20 , 20 , 17 , 14 },
+{ 20 , 20 , 17 , 15 },
+{ 20 , 20 , 17 , 16 },
+{ 20 , 20 , 17 , 17 },
+{ 20 , 20 , 17 , 18 },
+{ 20 , 20 , 17 , 19 },
+{ 20 , 20 , 18 , 0 },
+{ 20 , 20 , 18 , 1 },
+{ 20 , 20 , 18 , 2 },
+{ 20 , 20 , 18 , 3 },
+{ 20 , 20 , 18 , 4 },
+{ 20 , 20 , 18 , 5 },
+{ 20 , 20 , 18 , 6 },
+{ 20 , 20 , 18 , 7 },
+{ 20 , 20 , 18 , 8 },
+{ 20 , 20 , 18 , 9 },
+{ 20 , 20 , 18 , 10 },
+{ 20 , 20 , 18 , 11 },
+{ 20 , 20 , 18 , 12 },
+{ 20 , 20 , 18 , 13 },
+{ 20 , 20 , 18 , 14 },
+{ 20 , 20 , 18 , 15 },
+{ 20 , 20 , 18 , 16 },
+{ 20 , 20 , 18 , 17 },
+{ 20 , 20 , 18 , 18 },
+{ 20 , 20 , 18 , 19 },
+{ 20 , 20 , 19 , 0 },
+{ 20 , 20 , 19 , 1 },
+{ 20 , 20 , 19 , 2 },
+{ 20 , 20 , 19 , 3 },
+{ 20 , 20 , 19 , 4 },
+{ 20 , 20 , 19 , 5 },
+{ 20 , 20 , 19 , 6 },
+{ 20 , 20 , 19 , 7 },
+{ 20 , 20 , 19 , 8 },
+{ 20 , 20 , 19 , 9 },
+{ 20 , 20 , 19 , 10 },
+{ 20 , 20 , 19 , 11 },
+{ 20 , 20 , 19 , 12 },
+{ 20 , 20 , 19 , 13 },
+{ 20 , 20 , 19 , 14 },
+{ 20 , 20 , 19 , 15 },
+{ 20 , 20 , 19 , 16 },
+{ 20 , 20 , 19 , 17 },
+{ 20 , 20 , 19 , 18 },
+{ 20 , 20 , 19 , 19 },
+{ 20 , 40 , 0 , 0 },
+{ 20 , 40 , 0 , 1 },
+{ 20 , 40 , 0 , 2 },
+{ 20 , 40 , 0 , 3 },
+{ 20 , 40 , 0 , 4 },
+{ 20 , 40 , 0 , 5 },
+{ 20 , 40 , 0 , 6 },
+{ 20 , 40 , 0 , 7 },
+{ 20 , 40 , 0 , 8 },
+{ 20 , 40 , 0 , 9 },
+{ 20 , 40 , 0 , 10 },
+{ 20 , 40 , 0 , 11 },
+{ 20 , 40 , 0 , 12 },
+{ 20 , 40 , 0 , 13 },
+{ 20 , 40 , 0 , 14 },
+{ 20 , 40 , 0 , 15 },
+{ 20 , 40 , 0 , 16 },
+{ 20 , 40 , 0 , 17 },
+{ 20 , 40 , 0 , 18 },
+{ 20 , 40 , 0 , 19 },
+{ 20 , 40 , 0 , 20 },
+{ 20 , 40 , 0 , 21 },
+{ 20 , 40 , 0 , 22 },
+{ 20 , 40 , 0 , 23 },
+{ 20 , 40 , 0 , 24 },
+{ 20 , 40 , 0 , 25 },
+{ 20 , 40 , 0 , 26 },
+{ 20 , 40 , 0 , 27 },
+{ 20 , 40 , 0 , 28 },
+{ 20 , 40 , 0 , 29 },
+{ 20 , 40 , 0 , 30 },
+{ 20 , 40 , 0 , 31 },
+{ 20 , 40 , 0 , 32 },
+{ 20 , 40 , 0 , 33 },
+{ 20 , 40 , 0 , 34 },
+{ 20 , 40 , 0 , 35 },
+{ 20 , 40 , 0 , 36 },
+{ 20 , 40 , 0 , 37 },
+{ 20 , 40 , 0 , 38 },
+{ 20 , 40 , 0 , 39 },
+{ 20 , 40 , 1 , 0 },
+{ 20 , 40 , 1 , 1 },
+{ 20 , 40 , 1 , 2 },
+{ 20 , 40 , 1 , 3 },
+{ 20 , 40 , 1 , 4 },
+{ 20 , 40 , 1 , 5 },
+{ 20 , 40 , 1 , 6 },
+{ 20 , 40 , 1 , 7 },
+{ 20 , 40 , 1 , 8 },
+{ 20 , 40 , 1 , 9 },
+{ 20 , 40 , 1 , 10 },
+{ 20 , 40 , 1 , 11 },
+{ 20 , 40 , 1 , 12 },
+{ 20 , 40 , 1 , 13 },
+{ 20 , 40 , 1 , 14 },
+{ 20 , 40 , 1 , 15 },
+{ 20 , 40 , 1 , 16 },
+{ 20 , 40 , 1 , 17 },
+{ 20 , 40 , 1 , 18 },
+{ 20 , 40 , 1 , 19 },
+{ 20 , 40 , 1 , 20 },
+{ 20 , 40 , 1 , 21 },
+{ 20 , 40 , 1 , 22 },
+{ 20 , 40 , 1 , 23 },
+{ 20 , 40 , 1 , 24 },
+{ 20 , 40 , 1 , 25 },
+{ 20 , 40 , 1 , 26 },
+{ 20 , 40 , 1 , 27 },
+{ 20 , 40 , 1 , 28 },
+{ 20 , 40 , 1 , 29 },
+{ 20 , 40 , 1 , 30 },
+{ 20 , 40 , 1 , 31 },
+{ 20 , 40 , 1 , 32 },
+{ 20 , 40 , 1 , 33 },
+{ 20 , 40 , 1 , 34 },
+{ 20 , 40 , 1 , 35 },
+{ 20 , 40 , 1 , 36 },
+{ 20 , 40 , 1 , 37 },
+{ 20 , 40 , 1 , 38 },
+{ 20 , 40 , 1 , 39 },
+{ 20 , 40 , 2 , 0 },
+{ 20 , 40 , 2 , 1 },
+{ 20 , 40 , 2 , 2 },
+{ 20 , 40 , 2 , 3 },
+{ 20 , 40 , 2 , 4 },
+{ 20 , 40 , 2 , 5 },
+{ 20 , 40 , 2 , 6 },
+{ 20 , 40 , 2 , 7 },
+{ 20 , 40 , 2 , 8 },
+{ 20 , 40 , 2 , 9 },
+{ 20 , 40 , 2 , 10 },
+{ 20 , 40 , 2 , 11 },
+{ 20 , 40 , 2 , 12 },
+{ 20 , 40 , 2 , 13 },
+{ 20 , 40 , 2 , 14 },
+{ 20 , 40 , 2 , 15 },
+{ 20 , 40 , 2 , 16 },
+{ 20 , 40 , 2 , 17 },
+{ 20 , 40 , 2 , 18 },
+{ 20 , 40 , 2 , 19 },
+{ 20 , 40 , 2 , 20 },
+{ 20 , 40 , 2 , 21 },
+{ 20 , 40 , 2 , 22 },
+{ 20 , 40 , 2 , 23 },
+{ 20 , 40 , 2 , 24 },
+{ 20 , 40 , 2 , 25 },
+{ 20 , 40 , 2 , 26 },
+{ 20 , 40 , 2 , 27 },
+{ 20 , 40 , 2 , 28 },
+{ 20 , 40 , 2 , 29 },
+{ 20 , 40 , 2 , 30 },
+{ 20 , 40 , 2 , 31 },
+{ 20 , 40 , 2 , 32 },
+{ 20 , 40 , 2 , 33 },
+{ 20 , 40 , 2 , 34 },
+{ 20 , 40 , 2 , 35 },
+{ 20 , 40 , 2 , 36 },
+{ 20 , 40 , 2 , 37 },
+{ 20 , 40 , 2 , 38 },
+{ 20 , 40 , 2 , 39 },
+{ 20 , 40 , 3 , 0 },
+{ 20 , 40 , 3 , 1 },
+{ 20 , 40 , 3 , 2 },
+{ 20 , 40 , 3 , 3 },
+{ 20 , 40 , 3 , 4 },
+{ 20 , 40 , 3 , 5 },
+{ 20 , 40 , 3 , 6 },
+{ 20 , 40 , 3 , 7 },
+{ 20 , 40 , 3 , 8 },
+{ 20 , 40 , 3 , 9 },
+{ 20 , 40 , 3 , 10 },
+{ 20 , 40 , 3 , 11 },
+{ 20 , 40 , 3 , 12 },
+{ 20 , 40 , 3 , 13 },
+{ 20 , 40 , 3 , 14 },
+{ 20 , 40 , 3 , 15 },
+{ 20 , 40 , 3 , 16 },
+{ 20 , 40 , 3 , 17 },
+{ 20 , 40 , 3 , 18 },
+{ 20 , 40 , 3 , 19 },
+{ 20 , 40 , 3 , 20 },
+{ 20 , 40 , 3 , 21 },
+{ 20 , 40 , 3 , 22 },
+{ 20 , 40 , 3 , 23 },
+{ 20 , 40 , 3 , 24 },
+{ 20 , 40 , 3 , 25 },
+{ 20 , 40 , 3 , 26 },
+{ 20 , 40 , 3 , 27 },
+{ 20 , 40 , 3 , 28 },
+{ 20 , 40 , 3 , 29 },
+{ 20 , 40 , 3 , 30 },
+{ 20 , 40 , 3 , 31 },
+{ 20 , 40 , 3 , 32 },
+{ 20 , 40 , 3 , 33 },
+{ 20 , 40 , 3 , 34 },
+{ 20 , 40 , 3 , 35 },
+{ 20 , 40 , 3 , 36 },
+{ 20 , 40 , 3 , 37 },
+{ 20 , 40 , 3 , 38 },
+{ 20 , 40 , 3 , 39 },
+{ 20 , 40 , 4 , 0 },
+{ 20 , 40 , 4 , 1 },
+{ 20 , 40 , 4 , 2 },
+{ 20 , 40 , 4 , 3 },
+{ 20 , 40 , 4 , 4 },
+{ 20 , 40 , 4 , 5 },
+{ 20 , 40 , 4 , 6 },
+{ 20 , 40 , 4 , 7 },
+{ 20 , 40 , 4 , 8 },
+{ 20 , 40 , 4 , 9 },
+{ 20 , 40 , 4 , 10 },
+{ 20 , 40 , 4 , 11 },
+{ 20 , 40 , 4 , 12 },
+{ 20 , 40 , 4 , 13 },
+{ 20 , 40 , 4 , 14 },
+{ 20 , 40 , 4 , 15 },
+{ 20 , 40 , 4 , 16 },
+{ 20 , 40 , 4 , 17 },
+{ 20 , 40 , 4 , 18 },
+{ 20 , 40 , 4 , 19 },
+{ 20 , 40 , 4 , 20 },
+{ 20 , 40 , 4 , 21 },
+{ 20 , 40 , 4 , 22 },
+{ 20 , 40 , 4 , 23 },
+{ 20 , 40 , 4 , 24 },
+{ 20 , 40 , 4 , 25 },
+{ 20 , 40 , 4 , 26 },
+{ 20 , 40 , 4 , 27 },
+{ 20 , 40 , 4 , 28 },
+{ 20 , 40 , 4 , 29 },
+{ 20 , 40 , 4 , 30 },
+{ 20 , 40 , 4 , 31 },
+{ 20 , 40 , 4 , 32 },
+{ 20 , 40 , 4 , 33 },
+{ 20 , 40 , 4 , 34 },
+{ 20 , 40 , 4 , 35 },
+{ 20 , 40 , 4 , 36 },
+{ 20 , 40 , 4 , 37 },
+{ 20 , 40 , 4 , 38 },
+{ 20 , 40 , 4 , 39 },
+{ 20 , 40 , 5 , 0 },
+{ 20 , 40 , 5 , 1 },
+{ 20 , 40 , 5 , 2 },
+{ 20 , 40 , 5 , 3 },
+{ 20 , 40 , 5 , 4 },
+{ 20 , 40 , 5 , 5 },
+{ 20 , 40 , 5 , 6 },
+{ 20 , 40 , 5 , 7 },
+{ 20 , 40 , 5 , 8 },
+{ 20 , 40 , 5 , 9 },
+{ 20 , 40 , 5 , 10 },
+{ 20 , 40 , 5 , 11 },
+{ 20 , 40 , 5 , 12 },
+{ 20 , 40 , 5 , 13 },
+{ 20 , 40 , 5 , 14 },
+{ 20 , 40 , 5 , 15 },
+{ 20 , 40 , 5 , 16 },
+{ 20 , 40 , 5 , 17 },
+{ 20 , 40 , 5 , 18 },
+{ 20 , 40 , 5 , 19 },
+{ 20 , 40 , 5 , 20 },
+{ 20 , 40 , 5 , 21 },
+{ 20 , 40 , 5 , 22 },
+{ 20 , 40 , 5 , 23 },
+{ 20 , 40 , 5 , 24 },
+{ 20 , 40 , 5 , 25 },
+{ 20 , 40 , 5 , 26 },
+{ 20 , 40 , 5 , 27 },
+{ 20 , 40 , 5 , 28 },
+{ 20 , 40 , 5 , 29 },
+{ 20 , 40 , 5 , 30 },
+{ 20 , 40 , 5 , 31 },
+{ 20 , 40 , 5 , 32 },
+{ 20 , 40 , 5 , 33 },
+{ 20 , 40 , 5 , 34 },
+{ 20 , 40 , 5 , 35 },
+{ 20 , 40 , 5 , 36 },
+{ 20 , 40 , 5 , 37 },
+{ 20 , 40 , 5 , 38 },
+{ 20 , 40 , 5 , 39 },
+{ 20 , 40 , 6 , 0 },
+{ 20 , 40 , 6 , 1 },
+{ 20 , 40 , 6 , 2 },
+{ 20 , 40 , 6 , 3 },
+{ 20 , 40 , 6 , 4 },
+{ 20 , 40 , 6 , 5 },
+{ 20 , 40 , 6 , 6 },
+{ 20 , 40 , 6 , 7 },
+{ 20 , 40 , 6 , 8 },
+{ 20 , 40 , 6 , 9 },
+{ 20 , 40 , 6 , 10 },
+{ 20 , 40 , 6 , 11 },
+{ 20 , 40 , 6 , 12 },
+{ 20 , 40 , 6 , 13 },
+{ 20 , 40 , 6 , 14 },
+{ 20 , 40 , 6 , 15 },
+{ 20 , 40 , 6 , 16 },
+{ 20 , 40 , 6 , 17 },
+{ 20 , 40 , 6 , 18 },
+{ 20 , 40 , 6 , 19 },
+{ 20 , 40 , 6 , 20 },
+{ 20 , 40 , 6 , 21 },
+{ 20 , 40 , 6 , 22 },
+{ 20 , 40 , 6 , 23 },
+{ 20 , 40 , 6 , 24 },
+{ 20 , 40 , 6 , 25 },
+{ 20 , 40 , 6 , 26 },
+{ 20 , 40 , 6 , 27 },
+{ 20 , 40 , 6 , 28 },
+{ 20 , 40 , 6 , 29 },
+{ 20 , 40 , 6 , 30 },
+{ 20 , 40 , 6 , 31 },
+{ 20 , 40 , 6 , 32 },
+{ 20 , 40 , 6 , 33 },
+{ 20 , 40 , 6 , 34 },
+{ 20 , 40 , 6 , 35 },
+{ 20 , 40 , 6 , 36 },
+{ 20 , 40 , 6 , 37 },
+{ 20 , 40 , 6 , 38 },
+{ 20 , 40 , 6 , 39 },
+{ 20 , 40 , 7 , 0 },
+{ 20 , 40 , 7 , 1 },
+{ 20 , 40 , 7 , 2 },
+{ 20 , 40 , 7 , 3 },
+{ 20 , 40 , 7 , 4 },
+{ 20 , 40 , 7 , 5 },
+{ 20 , 40 , 7 , 6 },
+{ 20 , 40 , 7 , 7 },
+{ 20 , 40 , 7 , 8 },
+{ 20 , 40 , 7 , 9 },
+{ 20 , 40 , 7 , 10 },
+{ 20 , 40 , 7 , 11 },
+{ 20 , 40 , 7 , 12 },
+{ 20 , 40 , 7 , 13 },
+{ 20 , 40 , 7 , 14 },
+{ 20 , 40 , 7 , 15 },
+{ 20 , 40 , 7 , 16 },
+{ 20 , 40 , 7 , 17 },
+{ 20 , 40 , 7 , 18 },
+{ 20 , 40 , 7 , 19 },
+{ 20 , 40 , 7 , 20 },
+{ 20 , 40 , 7 , 21 },
+{ 20 , 40 , 7 , 22 },
+{ 20 , 40 , 7 , 23 },
+{ 20 , 40 , 7 , 24 },
+{ 20 , 40 , 7 , 25 },
+{ 20 , 40 , 7 , 26 },
+{ 20 , 40 , 7 , 27 },
+{ 20 , 40 , 7 , 28 },
+{ 20 , 40 , 7 , 29 },
+{ 20 , 40 , 7 , 30 },
+{ 20 , 40 , 7 , 31 },
+{ 20 , 40 , 7 , 32 },
+{ 20 , 40 , 7 , 33 },
+{ 20 , 40 , 7 , 34 },
+{ 20 , 40 , 7 , 35 },
+{ 20 , 40 , 7 , 36 },
+{ 20 , 40 , 7 , 37 },
+{ 20 , 40 , 7 , 38 },
+{ 20 , 40 , 7 , 39 },
+{ 20 , 40 , 8 , 0 },
+{ 20 , 40 , 8 , 1 },
+{ 20 , 40 , 8 , 2 },
+{ 20 , 40 , 8 , 3 },
+{ 20 , 40 , 8 , 4 },
+{ 20 , 40 , 8 , 5 },
+{ 20 , 40 , 8 , 6 },
+{ 20 , 40 , 8 , 7 },
+{ 20 , 40 , 8 , 8 },
+{ 20 , 40 , 8 , 9 },
+{ 20 , 40 , 8 , 10 },
+{ 20 , 40 , 8 , 11 },
+{ 20 , 40 , 8 , 12 },
+{ 20 , 40 , 8 , 13 },
+{ 20 , 40 , 8 , 14 },
+{ 20 , 40 , 8 , 15 },
+{ 20 , 40 , 8 , 16 },
+{ 20 , 40 , 8 , 17 },
+{ 20 , 40 , 8 , 18 },
+{ 20 , 40 , 8 , 19 },
+{ 20 , 40 , 8 , 20 },
+{ 20 , 40 , 8 , 21 },
+{ 20 , 40 , 8 , 22 },
+{ 20 , 40 , 8 , 23 },
+{ 20 , 40 , 8 , 24 },
+{ 20 , 40 , 8 , 25 },
+{ 20 , 40 , 8 , 26 },
+{ 20 , 40 , 8 , 27 },
+{ 20 , 40 , 8 , 28 },
+{ 20 , 40 , 8 , 29 },
+{ 20 , 40 , 8 , 30 },
+{ 20 , 40 , 8 , 31 },
+{ 20 , 40 , 8 , 32 },
+{ 20 , 40 , 8 , 33 },
+{ 20 , 40 , 8 , 34 },
+{ 20 , 40 , 8 , 35 },
+{ 20 , 40 , 8 , 36 },
+{ 20 , 40 , 8 , 37 },
+{ 20 , 40 , 8 , 38 },
+{ 20 , 40 , 8 , 39 },
+{ 20 , 40 , 9 , 0 },
+{ 20 , 40 , 9 , 1 },
+{ 20 , 40 , 9 , 2 },
+{ 20 , 40 , 9 , 3 },
+{ 20 , 40 , 9 , 4 },
+{ 20 , 40 , 9 , 5 },
+{ 20 , 40 , 9 , 6 },
+{ 20 , 40 , 9 , 7 },
+{ 20 , 40 , 9 , 8 },
+{ 20 , 40 , 9 , 9 },
+{ 20 , 40 , 9 , 10 },
+{ 20 , 40 , 9 , 11 },
+{ 20 , 40 , 9 , 12 },
+{ 20 , 40 , 9 , 13 },
+{ 20 , 40 , 9 , 14 },
+{ 20 , 40 , 9 , 15 },
+{ 20 , 40 , 9 , 16 },
+{ 20 , 40 , 9 , 17 },
+{ 20 , 40 , 9 , 18 },
+{ 20 , 40 , 9 , 19 },
+{ 20 , 40 , 9 , 20 },
+{ 20 , 40 , 9 , 21 },
+{ 20 , 40 , 9 , 22 },
+{ 20 , 40 , 9 , 23 },
+{ 20 , 40 , 9 , 24 },
+{ 20 , 40 , 9 , 25 },
+{ 20 , 40 , 9 , 26 },
+{ 20 , 40 , 9 , 27 },
+{ 20 , 40 , 9 , 28 },
+{ 20 , 40 , 9 , 29 },
+{ 20 , 40 , 9 , 30 },
+{ 20 , 40 , 9 , 31 },
+{ 20 , 40 , 9 , 32 },
+{ 20 , 40 , 9 , 33 },
+{ 20 , 40 , 9 , 34 },
+{ 20 , 40 , 9 , 35 },
+{ 20 , 40 , 9 , 36 },
+{ 20 , 40 , 9 , 37 },
+{ 20 , 40 , 9 , 38 },
+{ 20 , 40 , 9 , 39 },
+{ 20 , 40 , 10 , 0 },
+{ 20 , 40 , 10 , 1 },
+{ 20 , 40 , 10 , 2 },
+{ 20 , 40 , 10 , 3 },
+{ 20 , 40 , 10 , 4 },
+{ 20 , 40 , 10 , 5 },
+{ 20 , 40 , 10 , 6 },
+{ 20 , 40 , 10 , 7 },
+{ 20 , 40 , 10 , 8 },
+{ 20 , 40 , 10 , 9 },
+{ 20 , 40 , 10 , 10 },
+{ 20 , 40 , 10 , 11 },
+{ 20 , 40 , 10 , 12 },
+{ 20 , 40 , 10 , 13 },
+{ 20 , 40 , 10 , 14 },
+{ 20 , 40 , 10 , 15 },
+{ 20 , 40 , 10 , 16 },
+{ 20 , 40 , 10 , 17 },
+{ 20 , 40 , 10 , 18 },
+{ 20 , 40 , 10 , 19 },
+{ 20 , 40 , 10 , 20 },
+{ 20 , 40 , 10 , 21 },
+{ 20 , 40 , 10 , 22 },
+{ 20 , 40 , 10 , 23 },
+{ 20 , 40 , 10 , 24 },
+{ 20 , 40 , 10 , 25 },
+{ 20 , 40 , 10 , 26 },
+{ 20 , 40 , 10 , 27 },
+{ 20 , 40 , 10 , 28 },
+{ 20 , 40 , 10 , 29 },
+{ 20 , 40 , 10 , 30 },
+{ 20 , 40 , 10 , 31 },
+{ 20 , 40 , 10 , 32 },
+{ 20 , 40 , 10 , 33 },
+{ 20 , 40 , 10 , 34 },
+{ 20 , 40 , 10 , 35 },
+{ 20 , 40 , 10 , 36 },
+{ 20 , 40 , 10 , 37 },
+{ 20 , 40 , 10 , 38 },
+{ 20 , 40 , 10 , 39 },
+{ 20 , 40 , 11 , 0 },
+{ 20 , 40 , 11 , 1 },
+{ 20 , 40 , 11 , 2 },
+{ 20 , 40 , 11 , 3 },
+{ 20 , 40 , 11 , 4 },
+{ 20 , 40 , 11 , 5 },
+{ 20 , 40 , 11 , 6 },
+{ 20 , 40 , 11 , 7 },
+{ 20 , 40 , 11 , 8 },
+{ 20 , 40 , 11 , 9 },
+{ 20 , 40 , 11 , 10 },
+{ 20 , 40 , 11 , 11 },
+{ 20 , 40 , 11 , 12 },
+{ 20 , 40 , 11 , 13 },
+{ 20 , 40 , 11 , 14 },
+{ 20 , 40 , 11 , 15 },
+{ 20 , 40 , 11 , 16 },
+{ 20 , 40 , 11 , 17 },
+{ 20 , 40 , 11 , 18 },
+{ 20 , 40 , 11 , 19 },
+{ 20 , 40 , 11 , 20 },
+{ 20 , 40 , 11 , 21 },
+{ 20 , 40 , 11 , 22 },
+{ 20 , 40 , 11 , 23 },
+{ 20 , 40 , 11 , 24 },
+{ 20 , 40 , 11 , 25 },
+{ 20 , 40 , 11 , 26 },
+{ 20 , 40 , 11 , 27 },
+{ 20 , 40 , 11 , 28 },
+{ 20 , 40 , 11 , 29 },
+{ 20 , 40 , 11 , 30 },
+{ 20 , 40 , 11 , 31 },
+{ 20 , 40 , 11 , 32 },
+{ 20 , 40 , 11 , 33 },
+{ 20 , 40 , 11 , 34 },
+{ 20 , 40 , 11 , 35 },
+{ 20 , 40 , 11 , 36 },
+{ 20 , 40 , 11 , 37 },
+{ 20 , 40 , 11 , 38 },
+{ 20 , 40 , 11 , 39 },
+{ 20 , 40 , 12 , 0 },
+{ 20 , 40 , 12 , 1 },
+{ 20 , 40 , 12 , 2 },
+{ 20 , 40 , 12 , 3 },
+{ 20 , 40 , 12 , 4 },
+{ 20 , 40 , 12 , 5 },
+{ 20 , 40 , 12 , 6 },
+{ 20 , 40 , 12 , 7 },
+{ 20 , 40 , 12 , 8 },
+{ 20 , 40 , 12 , 9 },
+{ 20 , 40 , 12 , 10 },
+{ 20 , 40 , 12 , 11 },
+{ 20 , 40 , 12 , 12 },
+{ 20 , 40 , 12 , 13 },
+{ 20 , 40 , 12 , 14 },
+{ 20 , 40 , 12 , 15 },
+{ 20 , 40 , 12 , 16 },
+{ 20 , 40 , 12 , 17 },
+{ 20 , 40 , 12 , 18 },
+{ 20 , 40 , 12 , 19 },
+{ 20 , 40 , 12 , 20 },
+{ 20 , 40 , 12 , 21 },
+{ 20 , 40 , 12 , 22 },
+{ 20 , 40 , 12 , 23 },
+{ 20 , 40 , 12 , 24 },
+{ 20 , 40 , 12 , 25 },
+{ 20 , 40 , 12 , 26 },
+{ 20 , 40 , 12 , 27 },
+{ 20 , 40 , 12 , 28 },
+{ 20 , 40 , 12 , 29 },
+{ 20 , 40 , 12 , 30 },
+{ 20 , 40 , 12 , 31 },
+{ 20 , 40 , 12 , 32 },
+{ 20 , 40 , 12 , 33 },
+{ 20 , 40 , 12 , 34 },
+{ 20 , 40 , 12 , 35 },
+{ 20 , 40 , 12 , 36 },
+{ 20 , 40 , 12 , 37 },
+{ 20 , 40 , 12 , 38 },
+{ 20 , 40 , 12 , 39 },
+{ 20 , 40 , 13 , 0 },
+{ 20 , 40 , 13 , 1 },
+{ 20 , 40 , 13 , 2 },
+{ 20 , 40 , 13 , 3 },
+{ 20 , 40 , 13 , 4 },
+{ 20 , 40 , 13 , 5 },
+{ 20 , 40 , 13 , 6 },
+{ 20 , 40 , 13 , 7 },
+{ 20 , 40 , 13 , 8 },
+{ 20 , 40 , 13 , 9 },
+{ 20 , 40 , 13 , 10 },
+{ 20 , 40 , 13 , 11 },
+{ 20 , 40 , 13 , 12 },
+{ 20 , 40 , 13 , 13 },
+{ 20 , 40 , 13 , 14 },
+{ 20 , 40 , 13 , 15 },
+{ 20 , 40 , 13 , 16 },
+{ 20 , 40 , 13 , 17 },
+{ 20 , 40 , 13 , 18 },
+{ 20 , 40 , 13 , 19 },
+{ 20 , 40 , 13 , 20 },
+{ 20 , 40 , 13 , 21 },
+{ 20 , 40 , 13 , 22 },
+{ 20 , 40 , 13 , 23 },
+{ 20 , 40 , 13 , 24 },
+{ 20 , 40 , 13 , 25 },
+{ 20 , 40 , 13 , 26 },
+{ 20 , 40 , 13 , 27 },
+{ 20 , 40 , 13 , 28 },
+{ 20 , 40 , 13 , 29 },
+{ 20 , 40 , 13 , 30 },
+{ 20 , 40 , 13 , 31 },
+{ 20 , 40 , 13 , 32 },
+{ 20 , 40 , 13 , 33 },
+{ 20 , 40 , 13 , 34 },
+{ 20 , 40 , 13 , 35 },
+{ 20 , 40 , 13 , 36 },
+{ 20 , 40 , 13 , 37 },
+{ 20 , 40 , 13 , 38 },
+{ 20 , 40 , 13 , 39 },
+{ 20 , 40 , 14 , 0 },
+{ 20 , 40 , 14 , 1 },
+{ 20 , 40 , 14 , 2 },
+{ 20 , 40 , 14 , 3 },
+{ 20 , 40 , 14 , 4 },
+{ 20 , 40 , 14 , 5 },
+{ 20 , 40 , 14 , 6 },
+{ 20 , 40 , 14 , 7 },
+{ 20 , 40 , 14 , 8 },
+{ 20 , 40 , 14 , 9 },
+{ 20 , 40 , 14 , 10 },
+{ 20 , 40 , 14 , 11 },
+{ 20 , 40 , 14 , 12 },
+{ 20 , 40 , 14 , 13 },
+{ 20 , 40 , 14 , 14 },
+{ 20 , 40 , 14 , 15 },
+{ 20 , 40 , 14 , 16 },
+{ 20 , 40 , 14 , 17 },
+{ 20 , 40 , 14 , 18 },
+{ 20 , 40 , 14 , 19 },
+{ 20 , 40 , 14 , 20 },
+{ 20 , 40 , 14 , 21 },
+{ 20 , 40 , 14 , 22 },
+{ 20 , 40 , 14 , 23 },
+{ 20 , 40 , 14 , 24 },
+{ 20 , 40 , 14 , 25 },
+{ 20 , 40 , 14 , 26 },
+{ 20 , 40 , 14 , 27 },
+{ 20 , 40 , 14 , 28 },
+{ 20 , 40 , 14 , 29 },
+{ 20 , 40 , 14 , 30 },
+{ 20 , 40 , 14 , 31 },
+{ 20 , 40 , 14 , 32 },
+{ 20 , 40 , 14 , 33 },
+{ 20 , 40 , 14 , 34 },
+{ 20 , 40 , 14 , 35 },
+{ 20 , 40 , 14 , 36 },
+{ 20 , 40 , 14 , 37 },
+{ 20 , 40 , 14 , 38 },
+{ 20 , 40 , 14 , 39 },
+{ 20 , 40 , 15 , 0 },
+{ 20 , 40 , 15 , 1 },
+{ 20 , 40 , 15 , 2 },
+{ 20 , 40 , 15 , 3 },
+{ 20 , 40 , 15 , 4 },
+{ 20 , 40 , 15 , 5 },
+{ 20 , 40 , 15 , 6 },
+{ 20 , 40 , 15 , 7 },
+{ 20 , 40 , 15 , 8 },
+{ 20 , 40 , 15 , 9 },
+{ 20 , 40 , 15 , 10 },
+{ 20 , 40 , 15 , 11 },
+{ 20 , 40 , 15 , 12 },
+{ 20 , 40 , 15 , 13 },
+{ 20 , 40 , 15 , 14 },
+{ 20 , 40 , 15 , 15 },
+{ 20 , 40 , 15 , 16 },
+{ 20 , 40 , 15 , 17 },
+{ 20 , 40 , 15 , 18 },
+{ 20 , 40 , 15 , 19 },
+{ 20 , 40 , 15 , 20 },
+{ 20 , 40 , 15 , 21 },
+{ 20 , 40 , 15 , 22 },
+{ 20 , 40 , 15 , 23 },
+{ 20 , 40 , 15 , 24 },
+{ 20 , 40 , 15 , 25 },
+{ 20 , 40 , 15 , 26 },
+{ 20 , 40 , 15 , 27 },
+{ 20 , 40 , 15 , 28 },
+{ 20 , 40 , 15 , 29 },
+{ 20 , 40 , 15 , 30 },
+{ 20 , 40 , 15 , 31 },
+{ 20 , 40 , 15 , 32 },
+{ 20 , 40 , 15 , 33 },
+{ 20 , 40 , 15 , 34 },
+{ 20 , 40 , 15 , 35 },
+{ 20 , 40 , 15 , 36 },
+{ 20 , 40 , 15 , 37 },
+{ 20 , 40 , 15 , 38 },
+{ 20 , 40 , 15 , 39 },
+{ 20 , 40 , 16 , 0 },
+{ 20 , 40 , 16 , 1 },
+{ 20 , 40 , 16 , 2 },
+{ 20 , 40 , 16 , 3 },
+{ 20 , 40 , 16 , 4 },
+{ 20 , 40 , 16 , 5 },
+{ 20 , 40 , 16 , 6 },
+{ 20 , 40 , 16 , 7 },
+{ 20 , 40 , 16 , 8 },
+{ 20 , 40 , 16 , 9 },
+{ 20 , 40 , 16 , 10 },
+{ 20 , 40 , 16 , 11 },
+{ 20 , 40 , 16 , 12 },
+{ 20 , 40 , 16 , 13 },
+{ 20 , 40 , 16 , 14 },
+{ 20 , 40 , 16 , 15 },
+{ 20 , 40 , 16 , 16 },
+{ 20 , 40 , 16 , 17 },
+{ 20 , 40 , 16 , 18 },
+{ 20 , 40 , 16 , 19 },
+{ 20 , 40 , 16 , 20 },
+{ 20 , 40 , 16 , 21 },
+{ 20 , 40 , 16 , 22 },
+{ 20 , 40 , 16 , 23 },
+{ 20 , 40 , 16 , 24 },
+{ 20 , 40 , 16 , 25 },
+{ 20 , 40 , 16 , 26 },
+{ 20 , 40 , 16 , 27 },
+{ 20 , 40 , 16 , 28 },
+{ 20 , 40 , 16 , 29 },
+{ 20 , 40 , 16 , 30 },
+{ 20 , 40 , 16 , 31 },
+{ 20 , 40 , 16 , 32 },
+{ 20 , 40 , 16 , 33 },
+{ 20 , 40 , 16 , 34 },
+{ 20 , 40 , 16 , 35 },
+{ 20 , 40 , 16 , 36 },
+{ 20 , 40 , 16 , 37 },
+{ 20 , 40 , 16 , 38 },
+{ 20 , 40 , 16 , 39 },
+{ 20 , 40 , 17 , 0 },
+{ 20 , 40 , 17 , 1 },
+{ 20 , 40 , 17 , 2 },
+{ 20 , 40 , 17 , 3 },
+{ 20 , 40 , 17 , 4 },
+{ 20 , 40 , 17 , 5 },
+{ 20 , 40 , 17 , 6 },
+{ 20 , 40 , 17 , 7 },
+{ 20 , 40 , 17 , 8 },
+{ 20 , 40 , 17 , 9 },
+{ 20 , 40 , 17 , 10 },
+{ 20 , 40 , 17 , 11 },
+{ 20 , 40 , 17 , 12 },
+{ 20 , 40 , 17 , 13 },
+{ 20 , 40 , 17 , 14 },
+{ 20 , 40 , 17 , 15 },
+{ 20 , 40 , 17 , 16 },
+{ 20 , 40 , 17 , 17 },
+{ 20 , 40 , 17 , 18 },
+{ 20 , 40 , 17 , 19 },
+{ 20 , 40 , 17 , 20 },
+{ 20 , 40 , 17 , 21 },
+{ 20 , 40 , 17 , 22 },
+{ 20 , 40 , 17 , 23 },
+{ 20 , 40 , 17 , 24 },
+{ 20 , 40 , 17 , 25 },
+{ 20 , 40 , 17 , 26 },
+{ 20 , 40 , 17 , 27 },
+{ 20 , 40 , 17 , 28 },
+{ 20 , 40 , 17 , 29 },
+{ 20 , 40 , 17 , 30 },
+{ 20 , 40 , 17 , 31 },
+{ 20 , 40 , 17 , 32 },
+{ 20 , 40 , 17 , 33 },
+{ 20 , 40 , 17 , 34 },
+{ 20 , 40 , 17 , 35 },
+{ 20 , 40 , 17 , 36 },
+{ 20 , 40 , 17 , 37 },
+{ 20 , 40 , 17 , 38 },
+{ 20 , 40 , 17 , 39 },
+{ 20 , 40 , 18 , 0 },
+{ 20 , 40 , 18 , 1 },
+{ 20 , 40 , 18 , 2 },
+{ 20 , 40 , 18 , 3 },
+{ 20 , 40 , 18 , 4 },
+{ 20 , 40 , 18 , 5 },
+{ 20 , 40 , 18 , 6 },
+{ 20 , 40 , 18 , 7 },
+{ 20 , 40 , 18 , 8 },
+{ 20 , 40 , 18 , 9 },
+{ 20 , 40 , 18 , 10 },
+{ 20 , 40 , 18 , 11 },
+{ 20 , 40 , 18 , 12 },
+{ 20 , 40 , 18 , 13 },
+{ 20 , 40 , 18 , 14 },
+{ 20 , 40 , 18 , 15 },
+{ 20 , 40 , 18 , 16 },
+{ 20 , 40 , 18 , 17 },
+{ 20 , 40 , 18 , 18 },
+{ 20 , 40 , 18 , 19 },
+{ 20 , 40 , 18 , 20 },
+{ 20 , 40 , 18 , 21 },
+{ 20 , 40 , 18 , 22 },
+{ 20 , 40 , 18 , 23 },
+{ 20 , 40 , 18 , 24 },
+{ 20 , 40 , 18 , 25 },
+{ 20 , 40 , 18 , 26 },
+{ 20 , 40 , 18 , 27 },
+{ 20 , 40 , 18 , 28 },
+{ 20 , 40 , 18 , 29 },
+{ 20 , 40 , 18 , 30 },
+{ 20 , 40 , 18 , 31 },
+{ 20 , 40 , 18 , 32 },
+{ 20 , 40 , 18 , 33 },
+{ 20 , 40 , 18 , 34 },
+{ 20 , 40 , 18 , 35 },
+{ 20 , 40 , 18 , 36 },
+{ 20 , 40 , 18 , 37 },
+{ 20 , 40 , 18 , 38 },
+{ 20 , 40 , 18 , 39 },
+{ 20 , 40 , 19 , 0 },
+{ 20 , 40 , 19 , 1 },
+{ 20 , 40 , 19 , 2 },
+{ 20 , 40 , 19 , 3 },
+{ 20 , 40 , 19 , 4 },
+{ 20 , 40 , 19 , 5 },
+{ 20 , 40 , 19 , 6 },
+{ 20 , 40 , 19 , 7 },
+{ 20 , 40 , 19 , 8 },
+{ 20 , 40 , 19 , 9 },
+{ 20 , 40 , 19 , 10 },
+{ 20 , 40 , 19 , 11 },
+{ 20 , 40 , 19 , 12 },
+{ 20 , 40 , 19 , 13 },
+{ 20 , 40 , 19 , 14 },
+{ 20 , 40 , 19 , 15 },
+{ 20 , 40 , 19 , 16 },
+{ 20 , 40 , 19 , 17 },
+{ 20 , 40 , 19 , 18 },
+{ 20 , 40 , 19 , 19 },
+{ 20 , 40 , 19 , 20 },
+{ 20 , 40 , 19 , 21 },
+{ 20 , 40 , 19 , 22 },
+{ 20 , 40 , 19 , 23 },
+{ 20 , 40 , 19 , 24 },
+{ 20 , 40 , 19 , 25 },
+{ 20 , 40 , 19 , 26 },
+{ 20 , 40 , 19 , 27 },
+{ 20 , 40 , 19 , 28 },
+{ 20 , 40 , 19 , 29 },
+{ 20 , 40 , 19 , 30 },
+{ 20 , 40 , 19 , 31 },
+{ 20 , 40 , 19 , 32 },
+{ 20 , 40 , 19 , 33 },
+{ 20 , 40 , 19 , 34 },
+{ 20 , 40 , 19 , 35 },
+{ 20 , 40 , 19 , 36 },
+{ 20 , 40 , 19 , 37 },
+{ 20 , 40 , 19 , 38 },
+{ 20 , 40 , 19 , 39 },
+{ 20 , 80 , 0 , 0 },
+{ 20 , 80 , 0 , 1 },
+{ 20 , 80 , 0 , 2 },
+{ 20 , 80 , 0 , 3 },
+{ 20 , 80 , 0 , 4 },
+{ 20 , 80 , 0 , 5 },
+{ 20 , 80 , 0 , 6 },
+{ 20 , 80 , 0 , 7 },
+{ 20 , 80 , 0 , 8 },
+{ 20 , 80 , 0 , 9 },
+{ 20 , 80 , 0 , 10 },
+{ 20 , 80 , 0 , 11 },
+{ 20 , 80 , 0 , 12 },
+{ 20 , 80 , 0 , 13 },
+{ 20 , 80 , 0 , 14 },
+{ 20 , 80 , 0 , 15 },
+{ 20 , 80 , 0 , 16 },
+{ 20 , 80 , 0 , 17 },
+{ 20 , 80 , 0 , 18 },
+{ 20 , 80 , 0 , 19 },
+{ 20 , 80 , 0 , 20 },
+{ 20 , 80 , 0 , 21 },
+{ 20 , 80 , 0 , 22 },
+{ 20 , 80 , 0 , 23 },
+{ 20 , 80 , 0 , 24 },
+{ 20 , 80 , 0 , 25 },
+{ 20 , 80 , 0 , 26 },
+{ 20 , 80 , 0 , 27 },
+{ 20 , 80 , 0 , 28 },
+{ 20 , 80 , 0 , 29 },
+{ 20 , 80 , 0 , 30 },
+{ 20 , 80 , 0 , 31 },
+{ 20 , 80 , 0 , 32 },
+{ 20 , 80 , 0 , 33 },
+{ 20 , 80 , 0 , 34 },
+{ 20 , 80 , 0 , 35 },
+{ 20 , 80 , 0 , 36 },
+{ 20 , 80 , 0 , 37 },
+{ 20 , 80 , 0 , 38 },
+{ 20 , 80 , 0 , 39 },
+{ 20 , 80 , 0 , 40 },
+{ 20 , 80 , 0 , 41 },
+{ 20 , 80 , 0 , 42 },
+{ 20 , 80 , 0 , 43 },
+{ 20 , 80 , 0 , 44 },
+{ 20 , 80 , 0 , 45 },
+{ 20 , 80 , 0 , 46 },
+{ 20 , 80 , 0 , 47 },
+{ 20 , 80 , 0 , 48 },
+{ 20 , 80 , 0 , 49 },
+{ 20 , 80 , 0 , 50 },
+{ 20 , 80 , 0 , 51 },
+{ 20 , 80 , 0 , 52 },
+{ 20 , 80 , 0 , 53 },
+{ 20 , 80 , 0 , 54 },
+{ 20 , 80 , 0 , 55 },
+{ 20 , 80 , 0 , 56 },
+{ 20 , 80 , 0 , 57 },
+{ 20 , 80 , 0 , 58 },
+{ 20 , 80 , 0 , 59 },
+{ 20 , 80 , 0 , 60 },
+{ 20 , 80 , 0 , 61 },
+{ 20 , 80 , 0 , 62 },
+{ 20 , 80 , 0 , 63 },
+{ 20 , 80 , 0 , 64 },
+{ 20 , 80 , 0 , 65 },
+{ 20 , 80 , 0 , 66 },
+{ 20 , 80 , 0 , 67 },
+{ 20 , 80 , 0 , 68 },
+{ 20 , 80 , 0 , 69 },
+{ 20 , 80 , 0 , 70 },
+{ 20 , 80 , 0 , 71 },
+{ 20 , 80 , 0 , 72 },
+{ 20 , 80 , 0 , 73 },
+{ 20 , 80 , 0 , 74 },
+{ 20 , 80 , 0 , 75 },
+{ 20 , 80 , 0 , 76 },
+{ 20 , 80 , 0 , 77 },
+{ 20 , 80 , 0 , 78 },
+{ 20 , 80 , 0 , 79 },
+{ 20 , 80 , 1 , 0 },
+{ 20 , 80 , 1 , 1 },
+{ 20 , 80 , 1 , 2 },
+{ 20 , 80 , 1 , 3 },
+{ 20 , 80 , 1 , 4 },
+{ 20 , 80 , 1 , 5 },
+{ 20 , 80 , 1 , 6 },
+{ 20 , 80 , 1 , 7 },
+{ 20 , 80 , 1 , 8 },
+{ 20 , 80 , 1 , 9 },
+{ 20 , 80 , 1 , 10 },
+{ 20 , 80 , 1 , 11 },
+{ 20 , 80 , 1 , 12 },
+{ 20 , 80 , 1 , 13 },
+{ 20 , 80 , 1 , 14 },
+{ 20 , 80 , 1 , 15 },
+{ 20 , 80 , 1 , 16 },
+{ 20 , 80 , 1 , 17 },
+{ 20 , 80 , 1 , 18 },
+{ 20 , 80 , 1 , 19 },
+{ 20 , 80 , 1 , 20 },
+{ 20 , 80 , 1 , 21 },
+{ 20 , 80 , 1 , 22 },
+{ 20 , 80 , 1 , 23 },
+{ 20 , 80 , 1 , 24 },
+{ 20 , 80 , 1 , 25 },
+{ 20 , 80 , 1 , 26 },
+{ 20 , 80 , 1 , 27 },
+{ 20 , 80 , 1 , 28 },
+{ 20 , 80 , 1 , 29 },
+{ 20 , 80 , 1 , 30 },
+{ 20 , 80 , 1 , 31 },
+{ 20 , 80 , 1 , 32 },
+{ 20 , 80 , 1 , 33 },
+{ 20 , 80 , 1 , 34 },
+{ 20 , 80 , 1 , 35 },
+{ 20 , 80 , 1 , 36 },
+{ 20 , 80 , 1 , 37 },
+{ 20 , 80 , 1 , 38 },
+{ 20 , 80 , 1 , 39 },
+{ 20 , 80 , 1 , 40 },
+{ 20 , 80 , 1 , 41 },
+{ 20 , 80 , 1 , 42 },
+{ 20 , 80 , 1 , 43 },
+{ 20 , 80 , 1 , 44 },
+{ 20 , 80 , 1 , 45 },
+{ 20 , 80 , 1 , 46 },
+{ 20 , 80 , 1 , 47 },
+{ 20 , 80 , 1 , 48 },
+{ 20 , 80 , 1 , 49 },
+{ 20 , 80 , 1 , 50 },
+{ 20 , 80 , 1 , 51 },
+{ 20 , 80 , 1 , 52 },
+{ 20 , 80 , 1 , 53 },
+{ 20 , 80 , 1 , 54 },
+{ 20 , 80 , 1 , 55 },
+{ 20 , 80 , 1 , 56 },
+{ 20 , 80 , 1 , 57 },
+{ 20 , 80 , 1 , 58 },
+{ 20 , 80 , 1 , 59 },
+{ 20 , 80 , 1 , 60 },
+{ 20 , 80 , 1 , 61 },
+{ 20 , 80 , 1 , 62 },
+{ 20 , 80 , 1 , 63 },
+{ 20 , 80 , 1 , 64 },
+{ 20 , 80 , 1 , 65 },
+{ 20 , 80 , 1 , 66 },
+{ 20 , 80 , 1 , 67 },
+{ 20 , 80 , 1 , 68 },
+{ 20 , 80 , 1 , 69 },
+{ 20 , 80 , 1 , 70 },
+{ 20 , 80 , 1 , 71 },
+{ 20 , 80 , 1 , 72 },
+{ 20 , 80 , 1 , 73 },
+{ 20 , 80 , 1 , 74 },
+{ 20 , 80 , 1 , 75 },
+{ 20 , 80 , 1 , 76 },
+{ 20 , 80 , 1 , 77 },
+{ 20 , 80 , 1 , 78 },
+{ 20 , 80 , 1 , 79 },
+{ 20 , 80 , 2 , 0 },
+{ 20 , 80 , 2 , 1 },
+{ 20 , 80 , 2 , 2 },
+{ 20 , 80 , 2 , 3 },
+{ 20 , 80 , 2 , 4 },
+{ 20 , 80 , 2 , 5 },
+{ 20 , 80 , 2 , 6 },
+{ 20 , 80 , 2 , 7 },
+{ 20 , 80 , 2 , 8 },
+{ 20 , 80 , 2 , 9 },
+{ 20 , 80 , 2 , 10 },
+{ 20 , 80 , 2 , 11 },
+{ 20 , 80 , 2 , 12 },
+{ 20 , 80 , 2 , 13 },
+{ 20 , 80 , 2 , 14 },
+{ 20 , 80 , 2 , 15 },
+{ 20 , 80 , 2 , 16 },
+{ 20 , 80 , 2 , 17 },
+{ 20 , 80 , 2 , 18 },
+{ 20 , 80 , 2 , 19 },
+{ 20 , 80 , 2 , 20 },
+{ 20 , 80 , 2 , 21 },
+{ 20 , 80 , 2 , 22 },
+{ 20 , 80 , 2 , 23 },
+{ 20 , 80 , 2 , 24 },
+{ 20 , 80 , 2 , 25 },
+{ 20 , 80 , 2 , 26 },
+{ 20 , 80 , 2 , 27 },
+{ 20 , 80 , 2 , 28 },
+{ 20 , 80 , 2 , 29 },
+{ 20 , 80 , 2 , 30 },
+{ 20 , 80 , 2 , 31 },
+{ 20 , 80 , 2 , 32 },
+{ 20 , 80 , 2 , 33 },
+{ 20 , 80 , 2 , 34 },
+{ 20 , 80 , 2 , 35 },
+{ 20 , 80 , 2 , 36 },
+{ 20 , 80 , 2 , 37 },
+{ 20 , 80 , 2 , 38 },
+{ 20 , 80 , 2 , 39 },
+{ 20 , 80 , 2 , 40 },
+{ 20 , 80 , 2 , 41 },
+{ 20 , 80 , 2 , 42 },
+{ 20 , 80 , 2 , 43 },
+{ 20 , 80 , 2 , 44 },
+{ 20 , 80 , 2 , 45 },
+{ 20 , 80 , 2 , 46 },
+{ 20 , 80 , 2 , 47 },
+{ 20 , 80 , 2 , 48 },
+{ 20 , 80 , 2 , 49 },
+{ 20 , 80 , 2 , 50 },
+{ 20 , 80 , 2 , 51 },
+{ 20 , 80 , 2 , 52 },
+{ 20 , 80 , 2 , 53 },
+{ 20 , 80 , 2 , 54 },
+{ 20 , 80 , 2 , 55 },
+{ 20 , 80 , 2 , 56 },
+{ 20 , 80 , 2 , 57 },
+{ 20 , 80 , 2 , 58 },
+{ 20 , 80 , 2 , 59 },
+{ 20 , 80 , 2 , 60 },
+{ 20 , 80 , 2 , 61 },
+{ 20 , 80 , 2 , 62 },
+{ 20 , 80 , 2 , 63 },
+{ 20 , 80 , 2 , 64 },
+{ 20 , 80 , 2 , 65 },
+{ 20 , 80 , 2 , 66 },
+{ 20 , 80 , 2 , 67 },
+{ 20 , 80 , 2 , 68 },
+{ 20 , 80 , 2 , 69 },
+{ 20 , 80 , 2 , 70 },
+{ 20 , 80 , 2 , 71 },
+{ 20 , 80 , 2 , 72 },
+{ 20 , 80 , 2 , 73 },
+{ 20 , 80 , 2 , 74 },
+{ 20 , 80 , 2 , 75 },
+{ 20 , 80 , 2 , 76 },
+{ 20 , 80 , 2 , 77 },
+{ 20 , 80 , 2 , 78 },
+{ 20 , 80 , 2 , 79 },
+{ 20 , 80 , 3 , 0 },
+{ 20 , 80 , 3 , 1 },
+{ 20 , 80 , 3 , 2 },
+{ 20 , 80 , 3 , 3 },
+{ 20 , 80 , 3 , 4 },
+{ 20 , 80 , 3 , 5 },
+{ 20 , 80 , 3 , 6 },
+{ 20 , 80 , 3 , 7 },
+{ 20 , 80 , 3 , 8 },
+{ 20 , 80 , 3 , 9 },
+{ 20 , 80 , 3 , 10 },
+{ 20 , 80 , 3 , 11 },
+{ 20 , 80 , 3 , 12 },
+{ 20 , 80 , 3 , 13 },
+{ 20 , 80 , 3 , 14 },
+{ 20 , 80 , 3 , 15 },
+{ 20 , 80 , 3 , 16 },
+{ 20 , 80 , 3 , 17 },
+{ 20 , 80 , 3 , 18 },
+{ 20 , 80 , 3 , 19 },
+{ 20 , 80 , 3 , 20 },
+{ 20 , 80 , 3 , 21 },
+{ 20 , 80 , 3 , 22 },
+{ 20 , 80 , 3 , 23 },
+{ 20 , 80 , 3 , 24 },
+{ 20 , 80 , 3 , 25 },
+{ 20 , 80 , 3 , 26 },
+{ 20 , 80 , 3 , 27 },
+{ 20 , 80 , 3 , 28 },
+{ 20 , 80 , 3 , 29 },
+{ 20 , 80 , 3 , 30 },
+{ 20 , 80 , 3 , 31 },
+{ 20 , 80 , 3 , 32 },
+{ 20 , 80 , 3 , 33 },
+{ 20 , 80 , 3 , 34 },
+{ 20 , 80 , 3 , 35 },
+{ 20 , 80 , 3 , 36 },
+{ 20 , 80 , 3 , 37 },
+{ 20 , 80 , 3 , 38 },
+{ 20 , 80 , 3 , 39 },
+{ 20 , 80 , 3 , 40 },
+{ 20 , 80 , 3 , 41 },
+{ 20 , 80 , 3 , 42 },
+{ 20 , 80 , 3 , 43 },
+{ 20 , 80 , 3 , 44 },
+{ 20 , 80 , 3 , 45 },
+{ 20 , 80 , 3 , 46 },
+{ 20 , 80 , 3 , 47 },
+{ 20 , 80 , 3 , 48 },
+{ 20 , 80 , 3 , 49 },
+{ 20 , 80 , 3 , 50 },
+{ 20 , 80 , 3 , 51 },
+{ 20 , 80 , 3 , 52 },
+{ 20 , 80 , 3 , 53 },
+{ 20 , 80 , 3 , 54 },
+{ 20 , 80 , 3 , 55 },
+{ 20 , 80 , 3 , 56 },
+{ 20 , 80 , 3 , 57 },
+{ 20 , 80 , 3 , 58 },
+{ 20 , 80 , 3 , 59 },
+{ 20 , 80 , 3 , 60 },
+{ 20 , 80 , 3 , 61 },
+{ 20 , 80 , 3 , 62 },
+{ 20 , 80 , 3 , 63 },
+{ 20 , 80 , 3 , 64 },
+{ 20 , 80 , 3 , 65 },
+{ 20 , 80 , 3 , 66 },
+{ 20 , 80 , 3 , 67 },
+{ 20 , 80 , 3 , 68 },
+{ 20 , 80 , 3 , 69 },
+{ 20 , 80 , 3 , 70 },
+{ 20 , 80 , 3 , 71 },
+{ 20 , 80 , 3 , 72 },
+{ 20 , 80 , 3 , 73 },
+{ 20 , 80 , 3 , 74 },
+{ 20 , 80 , 3 , 75 },
+{ 20 , 80 , 3 , 76 },
+{ 20 , 80 , 3 , 77 },
+{ 20 , 80 , 3 , 78 },
+{ 20 , 80 , 3 , 79 },
+{ 20 , 80 , 4 , 0 },
+{ 20 , 80 , 4 , 1 },
+{ 20 , 80 , 4 , 2 },
+{ 20 , 80 , 4 , 3 },
+{ 20 , 80 , 4 , 4 },
+{ 20 , 80 , 4 , 5 },
+{ 20 , 80 , 4 , 6 },
+{ 20 , 80 , 4 , 7 },
+{ 20 , 80 , 4 , 8 },
+{ 20 , 80 , 4 , 9 },
+{ 20 , 80 , 4 , 10 },
+{ 20 , 80 , 4 , 11 },
+{ 20 , 80 , 4 , 12 },
+{ 20 , 80 , 4 , 13 },
+{ 20 , 80 , 4 , 14 },
+{ 20 , 80 , 4 , 15 },
+{ 20 , 80 , 4 , 16 },
+{ 20 , 80 , 4 , 17 },
+{ 20 , 80 , 4 , 18 },
+{ 20 , 80 , 4 , 19 },
+{ 20 , 80 , 4 , 20 },
+{ 20 , 80 , 4 , 21 },
+{ 20 , 80 , 4 , 22 },
+{ 20 , 80 , 4 , 23 },
+{ 20 , 80 , 4 , 24 },
+{ 20 , 80 , 4 , 25 },
+{ 20 , 80 , 4 , 26 },
+{ 20 , 80 , 4 , 27 },
+{ 20 , 80 , 4 , 28 },
+{ 20 , 80 , 4 , 29 },
+{ 20 , 80 , 4 , 30 },
+{ 20 , 80 , 4 , 31 },
+{ 20 , 80 , 4 , 32 },
+{ 20 , 80 , 4 , 33 },
+{ 20 , 80 , 4 , 34 },
+{ 20 , 80 , 4 , 35 },
+{ 20 , 80 , 4 , 36 },
+{ 20 , 80 , 4 , 37 },
+{ 20 , 80 , 4 , 38 },
+{ 20 , 80 , 4 , 39 },
+{ 20 , 80 , 4 , 40 },
+{ 20 , 80 , 4 , 41 },
+{ 20 , 80 , 4 , 42 },
+{ 20 , 80 , 4 , 43 },
+{ 20 , 80 , 4 , 44 },
+{ 20 , 80 , 4 , 45 },
+{ 20 , 80 , 4 , 46 },
+{ 20 , 80 , 4 , 47 },
+{ 20 , 80 , 4 , 48 },
+{ 20 , 80 , 4 , 49 },
+{ 20 , 80 , 4 , 50 },
+{ 20 , 80 , 4 , 51 },
+{ 20 , 80 , 4 , 52 },
+{ 20 , 80 , 4 , 53 },
+{ 20 , 80 , 4 , 54 },
+{ 20 , 80 , 4 , 55 },
+{ 20 , 80 , 4 , 56 },
+{ 20 , 80 , 4 , 57 },
+{ 20 , 80 , 4 , 58 },
+{ 20 , 80 , 4 , 59 },
+{ 20 , 80 , 4 , 60 },
+{ 20 , 80 , 4 , 61 },
+{ 20 , 80 , 4 , 62 },
+{ 20 , 80 , 4 , 63 },
+{ 20 , 80 , 4 , 64 },
+{ 20 , 80 , 4 , 65 },
+{ 20 , 80 , 4 , 66 },
+{ 20 , 80 , 4 , 67 },
+{ 20 , 80 , 4 , 68 },
+{ 20 , 80 , 4 , 69 },
+{ 20 , 80 , 4 , 70 },
+{ 20 , 80 , 4 , 71 },
+{ 20 , 80 , 4 , 72 },
+{ 20 , 80 , 4 , 73 },
+{ 20 , 80 , 4 , 74 },
+{ 20 , 80 , 4 , 75 },
+{ 20 , 80 , 4 , 76 },
+{ 20 , 80 , 4 , 77 },
+{ 20 , 80 , 4 , 78 },
+{ 20 , 80 , 4 , 79 },
+{ 20 , 80 , 5 , 0 },
+{ 20 , 80 , 5 , 1 },
+{ 20 , 80 , 5 , 2 },
+{ 20 , 80 , 5 , 3 },
+{ 20 , 80 , 5 , 4 },
+{ 20 , 80 , 5 , 5 },
+{ 20 , 80 , 5 , 6 },
+{ 20 , 80 , 5 , 7 },
+{ 20 , 80 , 5 , 8 },
+{ 20 , 80 , 5 , 9 },
+{ 20 , 80 , 5 , 10 },
+{ 20 , 80 , 5 , 11 },
+{ 20 , 80 , 5 , 12 },
+{ 20 , 80 , 5 , 13 },
+{ 20 , 80 , 5 , 14 },
+{ 20 , 80 , 5 , 15 },
+{ 20 , 80 , 5 , 16 },
+{ 20 , 80 , 5 , 17 },
+{ 20 , 80 , 5 , 18 },
+{ 20 , 80 , 5 , 19 },
+{ 20 , 80 , 5 , 20 },
+{ 20 , 80 , 5 , 21 },
+{ 20 , 80 , 5 , 22 },
+{ 20 , 80 , 5 , 23 },
+{ 20 , 80 , 5 , 24 },
+{ 20 , 80 , 5 , 25 },
+{ 20 , 80 , 5 , 26 },
+{ 20 , 80 , 5 , 27 },
+{ 20 , 80 , 5 , 28 },
+{ 20 , 80 , 5 , 29 },
+{ 20 , 80 , 5 , 30 },
+{ 20 , 80 , 5 , 31 },
+{ 20 , 80 , 5 , 32 },
+{ 20 , 80 , 5 , 33 },
+{ 20 , 80 , 5 , 34 },
+{ 20 , 80 , 5 , 35 },
+{ 20 , 80 , 5 , 36 },
+{ 20 , 80 , 5 , 37 },
+{ 20 , 80 , 5 , 38 },
+{ 20 , 80 , 5 , 39 },
+{ 20 , 80 , 5 , 40 },
+{ 20 , 80 , 5 , 41 },
+{ 20 , 80 , 5 , 42 },
+{ 20 , 80 , 5 , 43 },
+{ 20 , 80 , 5 , 44 },
+{ 20 , 80 , 5 , 45 },
+{ 20 , 80 , 5 , 46 },
+{ 20 , 80 , 5 , 47 },
+{ 20 , 80 , 5 , 48 },
+{ 20 , 80 , 5 , 49 },
+{ 20 , 80 , 5 , 50 },
+{ 20 , 80 , 5 , 51 },
+{ 20 , 80 , 5 , 52 },
+{ 20 , 80 , 5 , 53 },
+{ 20 , 80 , 5 , 54 },
+{ 20 , 80 , 5 , 55 },
+{ 20 , 80 , 5 , 56 },
+{ 20 , 80 , 5 , 57 },
+{ 20 , 80 , 5 , 58 },
+{ 20 , 80 , 5 , 59 },
+{ 20 , 80 , 5 , 60 },
+{ 20 , 80 , 5 , 61 },
+{ 20 , 80 , 5 , 62 },
+{ 20 , 80 , 5 , 63 },
+{ 20 , 80 , 5 , 64 },
+{ 20 , 80 , 5 , 65 },
+{ 20 , 80 , 5 , 66 },
+{ 20 , 80 , 5 , 67 },
+{ 20 , 80 , 5 , 68 },
+{ 20 , 80 , 5 , 69 },
+{ 20 , 80 , 5 , 70 },
+{ 20 , 80 , 5 , 71 },
+{ 20 , 80 , 5 , 72 },
+{ 20 , 80 , 5 , 73 },
+{ 20 , 80 , 5 , 74 },
+{ 20 , 80 , 5 , 75 },
+{ 20 , 80 , 5 , 76 },
+{ 20 , 80 , 5 , 77 },
+{ 20 , 80 , 5 , 78 },
+{ 20 , 80 , 5 , 79 },
+{ 20 , 80 , 6 , 0 },
+{ 20 , 80 , 6 , 1 },
+{ 20 , 80 , 6 , 2 },
+{ 20 , 80 , 6 , 3 },
+{ 20 , 80 , 6 , 4 },
+{ 20 , 80 , 6 , 5 },
+{ 20 , 80 , 6 , 6 },
+{ 20 , 80 , 6 , 7 },
+{ 20 , 80 , 6 , 8 },
+{ 20 , 80 , 6 , 9 },
+{ 20 , 80 , 6 , 10 },
+{ 20 , 80 , 6 , 11 },
+{ 20 , 80 , 6 , 12 },
+{ 20 , 80 , 6 , 13 },
+{ 20 , 80 , 6 , 14 },
+{ 20 , 80 , 6 , 15 },
+{ 20 , 80 , 6 , 16 },
+{ 20 , 80 , 6 , 17 },
+{ 20 , 80 , 6 , 18 },
+{ 20 , 80 , 6 , 19 },
+{ 20 , 80 , 6 , 20 },
+{ 20 , 80 , 6 , 21 },
+{ 20 , 80 , 6 , 22 },
+{ 20 , 80 , 6 , 23 },
+{ 20 , 80 , 6 , 24 },
+{ 20 , 80 , 6 , 25 },
+{ 20 , 80 , 6 , 26 },
+{ 20 , 80 , 6 , 27 },
+{ 20 , 80 , 6 , 28 },
+{ 20 , 80 , 6 , 29 },
+{ 20 , 80 , 6 , 30 },
+{ 20 , 80 , 6 , 31 },
+{ 20 , 80 , 6 , 32 },
+{ 20 , 80 , 6 , 33 },
+{ 20 , 80 , 6 , 34 },
+{ 20 , 80 , 6 , 35 },
+{ 20 , 80 , 6 , 36 },
+{ 20 , 80 , 6 , 37 },
+{ 20 , 80 , 6 , 38 },
+{ 20 , 80 , 6 , 39 },
+{ 20 , 80 , 6 , 40 },
+{ 20 , 80 , 6 , 41 },
+{ 20 , 80 , 6 , 42 },
+{ 20 , 80 , 6 , 43 },
+{ 20 , 80 , 6 , 44 },
+{ 20 , 80 , 6 , 45 },
+{ 20 , 80 , 6 , 46 },
+{ 20 , 80 , 6 , 47 },
+{ 20 , 80 , 6 , 48 },
+{ 20 , 80 , 6 , 49 },
+{ 20 , 80 , 6 , 50 },
+{ 20 , 80 , 6 , 51 },
+{ 20 , 80 , 6 , 52 },
+{ 20 , 80 , 6 , 53 },
+{ 20 , 80 , 6 , 54 },
+{ 20 , 80 , 6 , 55 },
+{ 20 , 80 , 6 , 56 },
+{ 20 , 80 , 6 , 57 },
+{ 20 , 80 , 6 , 58 },
+{ 20 , 80 , 6 , 59 },
+{ 20 , 80 , 6 , 60 },
+{ 20 , 80 , 6 , 61 },
+{ 20 , 80 , 6 , 62 },
+{ 20 , 80 , 6 , 63 },
+{ 20 , 80 , 6 , 64 },
+{ 20 , 80 , 6 , 65 },
+{ 20 , 80 , 6 , 66 },
+{ 20 , 80 , 6 , 67 },
+{ 20 , 80 , 6 , 68 },
+{ 20 , 80 , 6 , 69 },
+{ 20 , 80 , 6 , 70 },
+{ 20 , 80 , 6 , 71 },
+{ 20 , 80 , 6 , 72 },
+{ 20 , 80 , 6 , 73 },
+{ 20 , 80 , 6 , 74 },
+{ 20 , 80 , 6 , 75 },
+{ 20 , 80 , 6 , 76 },
+{ 20 , 80 , 6 , 77 },
+{ 20 , 80 , 6 , 78 },
+{ 20 , 80 , 6 , 79 },
+{ 20 , 80 , 7 , 0 },
+{ 20 , 80 , 7 , 1 },
+{ 20 , 80 , 7 , 2 },
+{ 20 , 80 , 7 , 3 },
+{ 20 , 80 , 7 , 4 },
+{ 20 , 80 , 7 , 5 },
+{ 20 , 80 , 7 , 6 },
+{ 20 , 80 , 7 , 7 },
+{ 20 , 80 , 7 , 8 },
+{ 20 , 80 , 7 , 9 },
+{ 20 , 80 , 7 , 10 },
+{ 20 , 80 , 7 , 11 },
+{ 20 , 80 , 7 , 12 },
+{ 20 , 80 , 7 , 13 },
+{ 20 , 80 , 7 , 14 },
+{ 20 , 80 , 7 , 15 },
+{ 20 , 80 , 7 , 16 },
+{ 20 , 80 , 7 , 17 },
+{ 20 , 80 , 7 , 18 },
+{ 20 , 80 , 7 , 19 },
+{ 20 , 80 , 7 , 20 },
+{ 20 , 80 , 7 , 21 },
+{ 20 , 80 , 7 , 22 },
+{ 20 , 80 , 7 , 23 },
+{ 20 , 80 , 7 , 24 },
+{ 20 , 80 , 7 , 25 },
+{ 20 , 80 , 7 , 26 },
+{ 20 , 80 , 7 , 27 },
+{ 20 , 80 , 7 , 28 },
+{ 20 , 80 , 7 , 29 },
+{ 20 , 80 , 7 , 30 },
+{ 20 , 80 , 7 , 31 },
+{ 20 , 80 , 7 , 32 },
+{ 20 , 80 , 7 , 33 },
+{ 20 , 80 , 7 , 34 },
+{ 20 , 80 , 7 , 35 },
+{ 20 , 80 , 7 , 36 },
+{ 20 , 80 , 7 , 37 },
+{ 20 , 80 , 7 , 38 },
+{ 20 , 80 , 7 , 39 },
+{ 20 , 80 , 7 , 40 },
+{ 20 , 80 , 7 , 41 },
+{ 20 , 80 , 7 , 42 },
+{ 20 , 80 , 7 , 43 },
+{ 20 , 80 , 7 , 44 },
+{ 20 , 80 , 7 , 45 },
+{ 20 , 80 , 7 , 46 },
+{ 20 , 80 , 7 , 47 },
+{ 20 , 80 , 7 , 48 },
+{ 20 , 80 , 7 , 49 },
+{ 20 , 80 , 7 , 50 },
+{ 20 , 80 , 7 , 51 },
+{ 20 , 80 , 7 , 52 },
+{ 20 , 80 , 7 , 53 },
+{ 20 , 80 , 7 , 54 },
+{ 20 , 80 , 7 , 55 },
+{ 20 , 80 , 7 , 56 },
+{ 20 , 80 , 7 , 57 },
+{ 20 , 80 , 7 , 58 },
+{ 20 , 80 , 7 , 59 },
+{ 20 , 80 , 7 , 60 },
+{ 20 , 80 , 7 , 61 },
+{ 20 , 80 , 7 , 62 },
+{ 20 , 80 , 7 , 63 },
+{ 20 , 80 , 7 , 64 },
+{ 20 , 80 , 7 , 65 },
+{ 20 , 80 , 7 , 66 },
+{ 20 , 80 , 7 , 67 },
+{ 20 , 80 , 7 , 68 },
+{ 20 , 80 , 7 , 69 },
+{ 20 , 80 , 7 , 70 },
+{ 20 , 80 , 7 , 71 },
+{ 20 , 80 , 7 , 72 },
+{ 20 , 80 , 7 , 73 },
+{ 20 , 80 , 7 , 74 },
+{ 20 , 80 , 7 , 75 },
+{ 20 , 80 , 7 , 76 },
+{ 20 , 80 , 7 , 77 },
+{ 20 , 80 , 7 , 78 },
+{ 20 , 80 , 7 , 79 },
+{ 20 , 80 , 8 , 0 },
+{ 20 , 80 , 8 , 1 },
+{ 20 , 80 , 8 , 2 },
+{ 20 , 80 , 8 , 3 },
+{ 20 , 80 , 8 , 4 },
+{ 20 , 80 , 8 , 5 },
+{ 20 , 80 , 8 , 6 },
+{ 20 , 80 , 8 , 7 },
+{ 20 , 80 , 8 , 8 },
+{ 20 , 80 , 8 , 9 },
+{ 20 , 80 , 8 , 10 },
+{ 20 , 80 , 8 , 11 },
+{ 20 , 80 , 8 , 12 },
+{ 20 , 80 , 8 , 13 },
+{ 20 , 80 , 8 , 14 },
+{ 20 , 80 , 8 , 15 },
+{ 20 , 80 , 8 , 16 },
+{ 20 , 80 , 8 , 17 },
+{ 20 , 80 , 8 , 18 },
+{ 20 , 80 , 8 , 19 },
+{ 20 , 80 , 8 , 20 },
+{ 20 , 80 , 8 , 21 },
+{ 20 , 80 , 8 , 22 },
+{ 20 , 80 , 8 , 23 },
+{ 20 , 80 , 8 , 24 },
+{ 20 , 80 , 8 , 25 },
+{ 20 , 80 , 8 , 26 },
+{ 20 , 80 , 8 , 27 },
+{ 20 , 80 , 8 , 28 },
+{ 20 , 80 , 8 , 29 },
+{ 20 , 80 , 8 , 30 },
+{ 20 , 80 , 8 , 31 },
+{ 20 , 80 , 8 , 32 },
+{ 20 , 80 , 8 , 33 },
+{ 20 , 80 , 8 , 34 },
+{ 20 , 80 , 8 , 35 },
+{ 20 , 80 , 8 , 36 },
+{ 20 , 80 , 8 , 37 },
+{ 20 , 80 , 8 , 38 },
+{ 20 , 80 , 8 , 39 },
+{ 20 , 80 , 8 , 40 },
+{ 20 , 80 , 8 , 41 },
+{ 20 , 80 , 8 , 42 },
+{ 20 , 80 , 8 , 43 },
+{ 20 , 80 , 8 , 44 },
+{ 20 , 80 , 8 , 45 },
+{ 20 , 80 , 8 , 46 },
+{ 20 , 80 , 8 , 47 },
+{ 20 , 80 , 8 , 48 },
+{ 20 , 80 , 8 , 49 },
+{ 20 , 80 , 8 , 50 },
+{ 20 , 80 , 8 , 51 },
+{ 20 , 80 , 8 , 52 },
+{ 20 , 80 , 8 , 53 },
+{ 20 , 80 , 8 , 54 },
+{ 20 , 80 , 8 , 55 },
+{ 20 , 80 , 8 , 56 },
+{ 20 , 80 , 8 , 57 },
+{ 20 , 80 , 8 , 58 },
+{ 20 , 80 , 8 , 59 },
+{ 20 , 80 , 8 , 60 },
+{ 20 , 80 , 8 , 61 },
+{ 20 , 80 , 8 , 62 },
+{ 20 , 80 , 8 , 63 },
+{ 20 , 80 , 8 , 64 },
+{ 20 , 80 , 8 , 65 },
+{ 20 , 80 , 8 , 66 },
+{ 20 , 80 , 8 , 67 },
+{ 20 , 80 , 8 , 68 },
+{ 20 , 80 , 8 , 69 },
+{ 20 , 80 , 8 , 70 },
+{ 20 , 80 , 8 , 71 },
+{ 20 , 80 , 8 , 72 },
+{ 20 , 80 , 8 , 73 },
+{ 20 , 80 , 8 , 74 },
+{ 20 , 80 , 8 , 75 },
+{ 20 , 80 , 8 , 76 },
+{ 20 , 80 , 8 , 77 },
+{ 20 , 80 , 8 , 78 },
+{ 20 , 80 , 8 , 79 },
+{ 20 , 80 , 9 , 0 },
+{ 20 , 80 , 9 , 1 },
+{ 20 , 80 , 9 , 2 },
+{ 20 , 80 , 9 , 3 },
+{ 20 , 80 , 9 , 4 },
+{ 20 , 80 , 9 , 5 },
+{ 20 , 80 , 9 , 6 },
+{ 20 , 80 , 9 , 7 },
+{ 20 , 80 , 9 , 8 },
+{ 20 , 80 , 9 , 9 },
+{ 20 , 80 , 9 , 10 },
+{ 20 , 80 , 9 , 11 },
+{ 20 , 80 , 9 , 12 },
+{ 20 , 80 , 9 , 13 },
+{ 20 , 80 , 9 , 14 },
+{ 20 , 80 , 9 , 15 },
+{ 20 , 80 , 9 , 16 },
+{ 20 , 80 , 9 , 17 },
+{ 20 , 80 , 9 , 18 },
+{ 20 , 80 , 9 , 19 },
+{ 20 , 80 , 9 , 20 },
+{ 20 , 80 , 9 , 21 },
+{ 20 , 80 , 9 , 22 },
+{ 20 , 80 , 9 , 23 },
+{ 20 , 80 , 9 , 24 },
+{ 20 , 80 , 9 , 25 },
+{ 20 , 80 , 9 , 26 },
+{ 20 , 80 , 9 , 27 },
+{ 20 , 80 , 9 , 28 },
+{ 20 , 80 , 9 , 29 },
+{ 20 , 80 , 9 , 30 },
+{ 20 , 80 , 9 , 31 },
+{ 20 , 80 , 9 , 32 },
+{ 20 , 80 , 9 , 33 },
+{ 20 , 80 , 9 , 34 },
+{ 20 , 80 , 9 , 35 },
+{ 20 , 80 , 9 , 36 },
+{ 20 , 80 , 9 , 37 },
+{ 20 , 80 , 9 , 38 },
+{ 20 , 80 , 9 , 39 },
+{ 20 , 80 , 9 , 40 },
+{ 20 , 80 , 9 , 41 },
+{ 20 , 80 , 9 , 42 },
+{ 20 , 80 , 9 , 43 },
+{ 20 , 80 , 9 , 44 },
+{ 20 , 80 , 9 , 45 },
+{ 20 , 80 , 9 , 46 },
+{ 20 , 80 , 9 , 47 },
+{ 20 , 80 , 9 , 48 },
+{ 20 , 80 , 9 , 49 },
+{ 20 , 80 , 9 , 50 },
+{ 20 , 80 , 9 , 51 },
+{ 20 , 80 , 9 , 52 },
+{ 20 , 80 , 9 , 53 },
+{ 20 , 80 , 9 , 54 },
+{ 20 , 80 , 9 , 55 },
+{ 20 , 80 , 9 , 56 },
+{ 20 , 80 , 9 , 57 },
+{ 20 , 80 , 9 , 58 },
+{ 20 , 80 , 9 , 59 },
+{ 20 , 80 , 9 , 60 },
+{ 20 , 80 , 9 , 61 },
+{ 20 , 80 , 9 , 62 },
+{ 20 , 80 , 9 , 63 },
+{ 20 , 80 , 9 , 64 },
+{ 20 , 80 , 9 , 65 },
+{ 20 , 80 , 9 , 66 },
+{ 20 , 80 , 9 , 67 },
+{ 20 , 80 , 9 , 68 },
+{ 20 , 80 , 9 , 69 },
+{ 20 , 80 , 9 , 70 },
+{ 20 , 80 , 9 , 71 },
+{ 20 , 80 , 9 , 72 },
+{ 20 , 80 , 9 , 73 },
+{ 20 , 80 , 9 , 74 },
+{ 20 , 80 , 9 , 75 },
+{ 20 , 80 , 9 , 76 },
+{ 20 , 80 , 9 , 77 },
+{ 20 , 80 , 9 , 78 },
+{ 20 , 80 , 9 , 79 },
+{ 20 , 80 , 10 , 0 },
+{ 20 , 80 , 10 , 1 },
+{ 20 , 80 , 10 , 2 },
+{ 20 , 80 , 10 , 3 },
+{ 20 , 80 , 10 , 4 },
+{ 20 , 80 , 10 , 5 },
+{ 20 , 80 , 10 , 6 },
+{ 20 , 80 , 10 , 7 },
+{ 20 , 80 , 10 , 8 },
+{ 20 , 80 , 10 , 9 },
+{ 20 , 80 , 10 , 10 },
+{ 20 , 80 , 10 , 11 },
+{ 20 , 80 , 10 , 12 },
+{ 20 , 80 , 10 , 13 },
+{ 20 , 80 , 10 , 14 },
+{ 20 , 80 , 10 , 15 },
+{ 20 , 80 , 10 , 16 },
+{ 20 , 80 , 10 , 17 },
+{ 20 , 80 , 10 , 18 },
+{ 20 , 80 , 10 , 19 },
+{ 20 , 80 , 10 , 20 },
+{ 20 , 80 , 10 , 21 },
+{ 20 , 80 , 10 , 22 },
+{ 20 , 80 , 10 , 23 },
+{ 20 , 80 , 10 , 24 },
+{ 20 , 80 , 10 , 25 },
+{ 20 , 80 , 10 , 26 },
+{ 20 , 80 , 10 , 27 },
+{ 20 , 80 , 10 , 28 },
+{ 20 , 80 , 10 , 29 },
+{ 20 , 80 , 10 , 30 },
+{ 20 , 80 , 10 , 31 },
+{ 20 , 80 , 10 , 32 },
+{ 20 , 80 , 10 , 33 },
+{ 20 , 80 , 10 , 34 },
+{ 20 , 80 , 10 , 35 },
+{ 20 , 80 , 10 , 36 },
+{ 20 , 80 , 10 , 37 },
+{ 20 , 80 , 10 , 38 },
+{ 20 , 80 , 10 , 39 },
+{ 20 , 80 , 10 , 40 },
+{ 20 , 80 , 10 , 41 },
+{ 20 , 80 , 10 , 42 },
+{ 20 , 80 , 10 , 43 },
+{ 20 , 80 , 10 , 44 },
+{ 20 , 80 , 10 , 45 },
+{ 20 , 80 , 10 , 46 },
+{ 20 , 80 , 10 , 47 },
+{ 20 , 80 , 10 , 48 },
+{ 20 , 80 , 10 , 49 },
+{ 20 , 80 , 10 , 50 },
+{ 20 , 80 , 10 , 51 },
+{ 20 , 80 , 10 , 52 },
+{ 20 , 80 , 10 , 53 },
+{ 20 , 80 , 10 , 54 },
+{ 20 , 80 , 10 , 55 },
+{ 20 , 80 , 10 , 56 },
+{ 20 , 80 , 10 , 57 },
+{ 20 , 80 , 10 , 58 },
+{ 20 , 80 , 10 , 59 },
+{ 20 , 80 , 10 , 60 },
+{ 20 , 80 , 10 , 61 },
+{ 20 , 80 , 10 , 62 },
+{ 20 , 80 , 10 , 63 },
+{ 20 , 80 , 10 , 64 },
+{ 20 , 80 , 10 , 65 },
+{ 20 , 80 , 10 , 66 },
+{ 20 , 80 , 10 , 67 },
+{ 20 , 80 , 10 , 68 },
+{ 20 , 80 , 10 , 69 },
+{ 20 , 80 , 10 , 70 },
+{ 20 , 80 , 10 , 71 },
+{ 20 , 80 , 10 , 72 },
+{ 20 , 80 , 10 , 73 },
+{ 20 , 80 , 10 , 74 },
+{ 20 , 80 , 10 , 75 },
+{ 20 , 80 , 10 , 76 },
+{ 20 , 80 , 10 , 77 },
+{ 20 , 80 , 10 , 78 },
+{ 20 , 80 , 10 , 79 },
+{ 20 , 80 , 11 , 0 },
+{ 20 , 80 , 11 , 1 },
+{ 20 , 80 , 11 , 2 },
+{ 20 , 80 , 11 , 3 },
+{ 20 , 80 , 11 , 4 },
+{ 20 , 80 , 11 , 5 },
+{ 20 , 80 , 11 , 6 },
+{ 20 , 80 , 11 , 7 },
+{ 20 , 80 , 11 , 8 },
+{ 20 , 80 , 11 , 9 },
+{ 20 , 80 , 11 , 10 },
+{ 20 , 80 , 11 , 11 },
+{ 20 , 80 , 11 , 12 },
+{ 20 , 80 , 11 , 13 },
+{ 20 , 80 , 11 , 14 },
+{ 20 , 80 , 11 , 15 },
+{ 20 , 80 , 11 , 16 },
+{ 20 , 80 , 11 , 17 },
+{ 20 , 80 , 11 , 18 },
+{ 20 , 80 , 11 , 19 },
+{ 20 , 80 , 11 , 20 },
+{ 20 , 80 , 11 , 21 },
+{ 20 , 80 , 11 , 22 },
+{ 20 , 80 , 11 , 23 },
+{ 20 , 80 , 11 , 24 },
+{ 20 , 80 , 11 , 25 },
+{ 20 , 80 , 11 , 26 },
+{ 20 , 80 , 11 , 27 },
+{ 20 , 80 , 11 , 28 },
+{ 20 , 80 , 11 , 29 },
+{ 20 , 80 , 11 , 30 },
+{ 20 , 80 , 11 , 31 },
+{ 20 , 80 , 11 , 32 },
+{ 20 , 80 , 11 , 33 },
+{ 20 , 80 , 11 , 34 },
+{ 20 , 80 , 11 , 35 },
+{ 20 , 80 , 11 , 36 },
+{ 20 , 80 , 11 , 37 },
+{ 20 , 80 , 11 , 38 },
+{ 20 , 80 , 11 , 39 },
+{ 20 , 80 , 11 , 40 },
+{ 20 , 80 , 11 , 41 },
+{ 20 , 80 , 11 , 42 },
+{ 20 , 80 , 11 , 43 },
+{ 20 , 80 , 11 , 44 },
+{ 20 , 80 , 11 , 45 },
+{ 20 , 80 , 11 , 46 },
+{ 20 , 80 , 11 , 47 },
+{ 20 , 80 , 11 , 48 },
+{ 20 , 80 , 11 , 49 },
+{ 20 , 80 , 11 , 50 },
+{ 20 , 80 , 11 , 51 },
+{ 20 , 80 , 11 , 52 },
+{ 20 , 80 , 11 , 53 },
+{ 20 , 80 , 11 , 54 },
+{ 20 , 80 , 11 , 55 },
+{ 20 , 80 , 11 , 56 },
+{ 20 , 80 , 11 , 57 },
+{ 20 , 80 , 11 , 58 },
+{ 20 , 80 , 11 , 59 },
+{ 20 , 80 , 11 , 60 },
+{ 20 , 80 , 11 , 61 },
+{ 20 , 80 , 11 , 62 },
+{ 20 , 80 , 11 , 63 },
+{ 20 , 80 , 11 , 64 },
+{ 20 , 80 , 11 , 65 },
+{ 20 , 80 , 11 , 66 },
+{ 20 , 80 , 11 , 67 },
+{ 20 , 80 , 11 , 68 },
+{ 20 , 80 , 11 , 69 },
+{ 20 , 80 , 11 , 70 },
+{ 20 , 80 , 11 , 71 },
+{ 20 , 80 , 11 , 72 },
+{ 20 , 80 , 11 , 73 },
+{ 20 , 80 , 11 , 74 },
+{ 20 , 80 , 11 , 75 },
+{ 20 , 80 , 11 , 76 },
+{ 20 , 80 , 11 , 77 },
+{ 20 , 80 , 11 , 78 },
+{ 20 , 80 , 11 , 79 },
+{ 20 , 80 , 12 , 0 },
+{ 20 , 80 , 12 , 1 },
+{ 20 , 80 , 12 , 2 },
+{ 20 , 80 , 12 , 3 },
+{ 20 , 80 , 12 , 4 },
+{ 20 , 80 , 12 , 5 },
+{ 20 , 80 , 12 , 6 },
+{ 20 , 80 , 12 , 7 },
+{ 20 , 80 , 12 , 8 },
+{ 20 , 80 , 12 , 9 },
+{ 20 , 80 , 12 , 10 },
+{ 20 , 80 , 12 , 11 },
+{ 20 , 80 , 12 , 12 },
+{ 20 , 80 , 12 , 13 },
+{ 20 , 80 , 12 , 14 },
+{ 20 , 80 , 12 , 15 },
+{ 20 , 80 , 12 , 16 },
+{ 20 , 80 , 12 , 17 },
+{ 20 , 80 , 12 , 18 },
+{ 20 , 80 , 12 , 19 },
+{ 20 , 80 , 12 , 20 },
+{ 20 , 80 , 12 , 21 },
+{ 20 , 80 , 12 , 22 },
+{ 20 , 80 , 12 , 23 },
+{ 20 , 80 , 12 , 24 },
+{ 20 , 80 , 12 , 25 },
+{ 20 , 80 , 12 , 26 },
+{ 20 , 80 , 12 , 27 },
+{ 20 , 80 , 12 , 28 },
+{ 20 , 80 , 12 , 29 },
+{ 20 , 80 , 12 , 30 },
+{ 20 , 80 , 12 , 31 },
+{ 20 , 80 , 12 , 32 },
+{ 20 , 80 , 12 , 33 },
+{ 20 , 80 , 12 , 34 },
+{ 20 , 80 , 12 , 35 },
+{ 20 , 80 , 12 , 36 },
+{ 20 , 80 , 12 , 37 },
+{ 20 , 80 , 12 , 38 },
+{ 20 , 80 , 12 , 39 },
+{ 20 , 80 , 12 , 40 },
+{ 20 , 80 , 12 , 41 },
+{ 20 , 80 , 12 , 42 },
+{ 20 , 80 , 12 , 43 },
+{ 20 , 80 , 12 , 44 },
+{ 20 , 80 , 12 , 45 },
+{ 20 , 80 , 12 , 46 },
+{ 20 , 80 , 12 , 47 },
+{ 20 , 80 , 12 , 48 },
+{ 20 , 80 , 12 , 49 },
+{ 20 , 80 , 12 , 50 },
+{ 20 , 80 , 12 , 51 },
+{ 20 , 80 , 12 , 52 },
+{ 20 , 80 , 12 , 53 },
+{ 20 , 80 , 12 , 54 },
+{ 20 , 80 , 12 , 55 },
+{ 20 , 80 , 12 , 56 },
+{ 20 , 80 , 12 , 57 },
+{ 20 , 80 , 12 , 58 },
+{ 20 , 80 , 12 , 59 },
+{ 20 , 80 , 12 , 60 },
+{ 20 , 80 , 12 , 61 },
+{ 20 , 80 , 12 , 62 },
+{ 20 , 80 , 12 , 63 },
+{ 20 , 80 , 12 , 64 },
+{ 20 , 80 , 12 , 65 },
+{ 20 , 80 , 12 , 66 },
+{ 20 , 80 , 12 , 67 },
+{ 20 , 80 , 12 , 68 },
+{ 20 , 80 , 12 , 69 },
+{ 20 , 80 , 12 , 70 },
+{ 20 , 80 , 12 , 71 },
+{ 20 , 80 , 12 , 72 },
+{ 20 , 80 , 12 , 73 },
+{ 20 , 80 , 12 , 74 },
+{ 20 , 80 , 12 , 75 },
+{ 20 , 80 , 12 , 76 },
+{ 20 , 80 , 12 , 77 },
+{ 20 , 80 , 12 , 78 },
+{ 20 , 80 , 12 , 79 },
+{ 20 , 80 , 13 , 0 },
+{ 20 , 80 , 13 , 1 },
+{ 20 , 80 , 13 , 2 },
+{ 20 , 80 , 13 , 3 },
+{ 20 , 80 , 13 , 4 },
+{ 20 , 80 , 13 , 5 },
+{ 20 , 80 , 13 , 6 },
+{ 20 , 80 , 13 , 7 },
+{ 20 , 80 , 13 , 8 },
+{ 20 , 80 , 13 , 9 },
+{ 20 , 80 , 13 , 10 },
+{ 20 , 80 , 13 , 11 },
+{ 20 , 80 , 13 , 12 },
+{ 20 , 80 , 13 , 13 },
+{ 20 , 80 , 13 , 14 },
+{ 20 , 80 , 13 , 15 },
+{ 20 , 80 , 13 , 16 },
+{ 20 , 80 , 13 , 17 },
+{ 20 , 80 , 13 , 18 },
+{ 20 , 80 , 13 , 19 },
+{ 20 , 80 , 13 , 20 },
+{ 20 , 80 , 13 , 21 },
+{ 20 , 80 , 13 , 22 },
+{ 20 , 80 , 13 , 23 },
+{ 20 , 80 , 13 , 24 },
+{ 20 , 80 , 13 , 25 },
+{ 20 , 80 , 13 , 26 },
+{ 20 , 80 , 13 , 27 },
+{ 20 , 80 , 13 , 28 },
+{ 20 , 80 , 13 , 29 },
+{ 20 , 80 , 13 , 30 },
+{ 20 , 80 , 13 , 31 },
+{ 20 , 80 , 13 , 32 },
+{ 20 , 80 , 13 , 33 },
+{ 20 , 80 , 13 , 34 },
+{ 20 , 80 , 13 , 35 },
+{ 20 , 80 , 13 , 36 },
+{ 20 , 80 , 13 , 37 },
+{ 20 , 80 , 13 , 38 },
+{ 20 , 80 , 13 , 39 },
+{ 20 , 80 , 13 , 40 },
+{ 20 , 80 , 13 , 41 },
+{ 20 , 80 , 13 , 42 },
+{ 20 , 80 , 13 , 43 },
+{ 20 , 80 , 13 , 44 },
+{ 20 , 80 , 13 , 45 },
+{ 20 , 80 , 13 , 46 },
+{ 20 , 80 , 13 , 47 },
+{ 20 , 80 , 13 , 48 },
+{ 20 , 80 , 13 , 49 },
+{ 20 , 80 , 13 , 50 },
+{ 20 , 80 , 13 , 51 },
+{ 20 , 80 , 13 , 52 },
+{ 20 , 80 , 13 , 53 },
+{ 20 , 80 , 13 , 54 },
+{ 20 , 80 , 13 , 55 },
+{ 20 , 80 , 13 , 56 },
+{ 20 , 80 , 13 , 57 },
+{ 20 , 80 , 13 , 58 },
+{ 20 , 80 , 13 , 59 },
+{ 20 , 80 , 13 , 60 },
+{ 20 , 80 , 13 , 61 },
+{ 20 , 80 , 13 , 62 },
+{ 20 , 80 , 13 , 63 },
+{ 20 , 80 , 13 , 64 },
+{ 20 , 80 , 13 , 65 },
+{ 20 , 80 , 13 , 66 },
+{ 20 , 80 , 13 , 67 },
+{ 20 , 80 , 13 , 68 },
+{ 20 , 80 , 13 , 69 },
+{ 20 , 80 , 13 , 70 },
+{ 20 , 80 , 13 , 71 },
+{ 20 , 80 , 13 , 72 },
+{ 20 , 80 , 13 , 73 },
+{ 20 , 80 , 13 , 74 },
+{ 20 , 80 , 13 , 75 },
+{ 20 , 80 , 13 , 76 },
+{ 20 , 80 , 13 , 77 },
+{ 20 , 80 , 13 , 78 },
+{ 20 , 80 , 13 , 79 },
+{ 20 , 80 , 14 , 0 },
+{ 20 , 80 , 14 , 1 },
+{ 20 , 80 , 14 , 2 },
+{ 20 , 80 , 14 , 3 },
+{ 20 , 80 , 14 , 4 },
+{ 20 , 80 , 14 , 5 },
+{ 20 , 80 , 14 , 6 },
+{ 20 , 80 , 14 , 7 },
+{ 20 , 80 , 14 , 8 },
+{ 20 , 80 , 14 , 9 },
+{ 20 , 80 , 14 , 10 },
+{ 20 , 80 , 14 , 11 },
+{ 20 , 80 , 14 , 12 },
+{ 20 , 80 , 14 , 13 },
+{ 20 , 80 , 14 , 14 },
+{ 20 , 80 , 14 , 15 },
+{ 20 , 80 , 14 , 16 },
+{ 20 , 80 , 14 , 17 },
+{ 20 , 80 , 14 , 18 },
+{ 20 , 80 , 14 , 19 },
+{ 20 , 80 , 14 , 20 },
+{ 20 , 80 , 14 , 21 },
+{ 20 , 80 , 14 , 22 },
+{ 20 , 80 , 14 , 23 },
+{ 20 , 80 , 14 , 24 },
+{ 20 , 80 , 14 , 25 },
+{ 20 , 80 , 14 , 26 },
+{ 20 , 80 , 14 , 27 },
+{ 20 , 80 , 14 , 28 },
+{ 20 , 80 , 14 , 29 },
+{ 20 , 80 , 14 , 30 },
+{ 20 , 80 , 14 , 31 },
+{ 20 , 80 , 14 , 32 },
+{ 20 , 80 , 14 , 33 },
+{ 20 , 80 , 14 , 34 },
+{ 20 , 80 , 14 , 35 },
+{ 20 , 80 , 14 , 36 },
+{ 20 , 80 , 14 , 37 },
+{ 20 , 80 , 14 , 38 },
+{ 20 , 80 , 14 , 39 },
+{ 20 , 80 , 14 , 40 },
+{ 20 , 80 , 14 , 41 },
+{ 20 , 80 , 14 , 42 },
+{ 20 , 80 , 14 , 43 },
+{ 20 , 80 , 14 , 44 },
+{ 20 , 80 , 14 , 45 },
+{ 20 , 80 , 14 , 46 },
+{ 20 , 80 , 14 , 47 },
+{ 20 , 80 , 14 , 48 },
+{ 20 , 80 , 14 , 49 },
+{ 20 , 80 , 14 , 50 },
+{ 20 , 80 , 14 , 51 },
+{ 20 , 80 , 14 , 52 },
+{ 20 , 80 , 14 , 53 },
+{ 20 , 80 , 14 , 54 },
+{ 20 , 80 , 14 , 55 },
+{ 20 , 80 , 14 , 56 },
+{ 20 , 80 , 14 , 57 },
+{ 20 , 80 , 14 , 58 },
+{ 20 , 80 , 14 , 59 },
+{ 20 , 80 , 14 , 60 },
+{ 20 , 80 , 14 , 61 },
+{ 20 , 80 , 14 , 62 },
+{ 20 , 80 , 14 , 63 },
+{ 20 , 80 , 14 , 64 },
+{ 20 , 80 , 14 , 65 },
+{ 20 , 80 , 14 , 66 },
+{ 20 , 80 , 14 , 67 },
+{ 20 , 80 , 14 , 68 },
+{ 20 , 80 , 14 , 69 },
+{ 20 , 80 , 14 , 70 },
+{ 20 , 80 , 14 , 71 },
+{ 20 , 80 , 14 , 72 },
+{ 20 , 80 , 14 , 73 },
+{ 20 , 80 , 14 , 74 },
+{ 20 , 80 , 14 , 75 },
+{ 20 , 80 , 14 , 76 },
+{ 20 , 80 , 14 , 77 },
+{ 20 , 80 , 14 , 78 },
+{ 20 , 80 , 14 , 79 },
+{ 20 , 80 , 15 , 0 },
+{ 20 , 80 , 15 , 1 },
+{ 20 , 80 , 15 , 2 },
+{ 20 , 80 , 15 , 3 },
+{ 20 , 80 , 15 , 4 },
+{ 20 , 80 , 15 , 5 },
+{ 20 , 80 , 15 , 6 },
+{ 20 , 80 , 15 , 7 },
+{ 20 , 80 , 15 , 8 },
+{ 20 , 80 , 15 , 9 },
+{ 20 , 80 , 15 , 10 },
+{ 20 , 80 , 15 , 11 },
+{ 20 , 80 , 15 , 12 },
+{ 20 , 80 , 15 , 13 },
+{ 20 , 80 , 15 , 14 },
+{ 20 , 80 , 15 , 15 },
+{ 20 , 80 , 15 , 16 },
+{ 20 , 80 , 15 , 17 },
+{ 20 , 80 , 15 , 18 },
+{ 20 , 80 , 15 , 19 },
+{ 20 , 80 , 15 , 20 },
+{ 20 , 80 , 15 , 21 },
+{ 20 , 80 , 15 , 22 },
+{ 20 , 80 , 15 , 23 },
+{ 20 , 80 , 15 , 24 },
+{ 20 , 80 , 15 , 25 },
+{ 20 , 80 , 15 , 26 },
+{ 20 , 80 , 15 , 27 },
+{ 20 , 80 , 15 , 28 },
+{ 20 , 80 , 15 , 29 },
+{ 20 , 80 , 15 , 30 },
+{ 20 , 80 , 15 , 31 },
+{ 20 , 80 , 15 , 32 },
+{ 20 , 80 , 15 , 33 },
+{ 20 , 80 , 15 , 34 },
+{ 20 , 80 , 15 , 35 },
+{ 20 , 80 , 15 , 36 },
+{ 20 , 80 , 15 , 37 },
+{ 20 , 80 , 15 , 38 },
+{ 20 , 80 , 15 , 39 },
+{ 20 , 80 , 15 , 40 },
+{ 20 , 80 , 15 , 41 },
+{ 20 , 80 , 15 , 42 },
+{ 20 , 80 , 15 , 43 },
+{ 20 , 80 , 15 , 44 },
+{ 20 , 80 , 15 , 45 },
+{ 20 , 80 , 15 , 46 },
+{ 20 , 80 , 15 , 47 },
+{ 20 , 80 , 15 , 48 },
+{ 20 , 80 , 15 , 49 },
+{ 20 , 80 , 15 , 50 },
+{ 20 , 80 , 15 , 51 },
+{ 20 , 80 , 15 , 52 },
+{ 20 , 80 , 15 , 53 },
+{ 20 , 80 , 15 , 54 },
+{ 20 , 80 , 15 , 55 },
+{ 20 , 80 , 15 , 56 },
+{ 20 , 80 , 15 , 57 },
+{ 20 , 80 , 15 , 58 },
+{ 20 , 80 , 15 , 59 },
+{ 20 , 80 , 15 , 60 },
+{ 20 , 80 , 15 , 61 },
+{ 20 , 80 , 15 , 62 },
+{ 20 , 80 , 15 , 63 },
+{ 20 , 80 , 15 , 64 },
+{ 20 , 80 , 15 , 65 },
+{ 20 , 80 , 15 , 66 },
+{ 20 , 80 , 15 , 67 },
+{ 20 , 80 , 15 , 68 },
+{ 20 , 80 , 15 , 69 },
+{ 20 , 80 , 15 , 70 },
+{ 20 , 80 , 15 , 71 },
+{ 20 , 80 , 15 , 72 },
+{ 20 , 80 , 15 , 73 },
+{ 20 , 80 , 15 , 74 },
+{ 20 , 80 , 15 , 75 },
+{ 20 , 80 , 15 , 76 },
+{ 20 , 80 , 15 , 77 },
+{ 20 , 80 , 15 , 78 },
+{ 20 , 80 , 15 , 79 },
+{ 20 , 80 , 16 , 0 },
+{ 20 , 80 , 16 , 1 },
+{ 20 , 80 , 16 , 2 },
+{ 20 , 80 , 16 , 3 },
+{ 20 , 80 , 16 , 4 },
+{ 20 , 80 , 16 , 5 },
+{ 20 , 80 , 16 , 6 },
+{ 20 , 80 , 16 , 7 },
+{ 20 , 80 , 16 , 8 },
+{ 20 , 80 , 16 , 9 },
+{ 20 , 80 , 16 , 10 },
+{ 20 , 80 , 16 , 11 },
+{ 20 , 80 , 16 , 12 },
+{ 20 , 80 , 16 , 13 },
+{ 20 , 80 , 16 , 14 },
+{ 20 , 80 , 16 , 15 },
+{ 20 , 80 , 16 , 16 },
+{ 20 , 80 , 16 , 17 },
+{ 20 , 80 , 16 , 18 },
+{ 20 , 80 , 16 , 19 },
+{ 20 , 80 , 16 , 20 },
+{ 20 , 80 , 16 , 21 },
+{ 20 , 80 , 16 , 22 },
+{ 20 , 80 , 16 , 23 },
+{ 20 , 80 , 16 , 24 },
+{ 20 , 80 , 16 , 25 },
+{ 20 , 80 , 16 , 26 },
+{ 20 , 80 , 16 , 27 },
+{ 20 , 80 , 16 , 28 },
+{ 20 , 80 , 16 , 29 },
+{ 20 , 80 , 16 , 30 },
+{ 20 , 80 , 16 , 31 },
+{ 20 , 80 , 16 , 32 },
+{ 20 , 80 , 16 , 33 },
+{ 20 , 80 , 16 , 34 },
+{ 20 , 80 , 16 , 35 },
+{ 20 , 80 , 16 , 36 },
+{ 20 , 80 , 16 , 37 },
+{ 20 , 80 , 16 , 38 },
+{ 20 , 80 , 16 , 39 },
+{ 20 , 80 , 16 , 40 },
+{ 20 , 80 , 16 , 41 },
+{ 20 , 80 , 16 , 42 },
+{ 20 , 80 , 16 , 43 },
+{ 20 , 80 , 16 , 44 },
+{ 20 , 80 , 16 , 45 },
+{ 20 , 80 , 16 , 46 },
+{ 20 , 80 , 16 , 47 },
+{ 20 , 80 , 16 , 48 },
+{ 20 , 80 , 16 , 49 },
+{ 20 , 80 , 16 , 50 },
+{ 20 , 80 , 16 , 51 },
+{ 20 , 80 , 16 , 52 },
+{ 20 , 80 , 16 , 53 },
+{ 20 , 80 , 16 , 54 },
+{ 20 , 80 , 16 , 55 },
+{ 20 , 80 , 16 , 56 },
+{ 20 , 80 , 16 , 57 },
+{ 20 , 80 , 16 , 58 },
+{ 20 , 80 , 16 , 59 },
+{ 20 , 80 , 16 , 60 },
+{ 20 , 80 , 16 , 61 },
+{ 20 , 80 , 16 , 62 },
+{ 20 , 80 , 16 , 63 },
+{ 20 , 80 , 16 , 64 },
+{ 20 , 80 , 16 , 65 },
+{ 20 , 80 , 16 , 66 },
+{ 20 , 80 , 16 , 67 },
+{ 20 , 80 , 16 , 68 },
+{ 20 , 80 , 16 , 69 },
+{ 20 , 80 , 16 , 70 },
+{ 20 , 80 , 16 , 71 },
+{ 20 , 80 , 16 , 72 },
+{ 20 , 80 , 16 , 73 },
+{ 20 , 80 , 16 , 74 },
+{ 20 , 80 , 16 , 75 },
+{ 20 , 80 , 16 , 76 },
+{ 20 , 80 , 16 , 77 },
+{ 20 , 80 , 16 , 78 },
+{ 20 , 80 , 16 , 79 },
+{ 20 , 80 , 17 , 0 },
+{ 20 , 80 , 17 , 1 },
+{ 20 , 80 , 17 , 2 },
+{ 20 , 80 , 17 , 3 },
+{ 20 , 80 , 17 , 4 },
+{ 20 , 80 , 17 , 5 },
+{ 20 , 80 , 17 , 6 },
+{ 20 , 80 , 17 , 7 },
+{ 20 , 80 , 17 , 8 },
+{ 20 , 80 , 17 , 9 },
+{ 20 , 80 , 17 , 10 },
+{ 20 , 80 , 17 , 11 },
+{ 20 , 80 , 17 , 12 },
+{ 20 , 80 , 17 , 13 },
+{ 20 , 80 , 17 , 14 },
+{ 20 , 80 , 17 , 15 },
+{ 20 , 80 , 17 , 16 },
+{ 20 , 80 , 17 , 17 },
+{ 20 , 80 , 17 , 18 },
+{ 20 , 80 , 17 , 19 },
+{ 20 , 80 , 17 , 20 },
+{ 20 , 80 , 17 , 21 },
+{ 20 , 80 , 17 , 22 },
+{ 20 , 80 , 17 , 23 },
+{ 20 , 80 , 17 , 24 },
+{ 20 , 80 , 17 , 25 },
+{ 20 , 80 , 17 , 26 },
+{ 20 , 80 , 17 , 27 },
+{ 20 , 80 , 17 , 28 },
+{ 20 , 80 , 17 , 29 },
+{ 20 , 80 , 17 , 30 },
+{ 20 , 80 , 17 , 31 },
+{ 20 , 80 , 17 , 32 },
+{ 20 , 80 , 17 , 33 },
+{ 20 , 80 , 17 , 34 },
+{ 20 , 80 , 17 , 35 },
+{ 20 , 80 , 17 , 36 },
+{ 20 , 80 , 17 , 37 },
+{ 20 , 80 , 17 , 38 },
+{ 20 , 80 , 17 , 39 },
+{ 20 , 80 , 17 , 40 },
+{ 20 , 80 , 17 , 41 },
+{ 20 , 80 , 17 , 42 },
+{ 20 , 80 , 17 , 43 },
+{ 20 , 80 , 17 , 44 },
+{ 20 , 80 , 17 , 45 },
+{ 20 , 80 , 17 , 46 },
+{ 20 , 80 , 17 , 47 },
+{ 20 , 80 , 17 , 48 },
+{ 20 , 80 , 17 , 49 },
+{ 20 , 80 , 17 , 50 },
+{ 20 , 80 , 17 , 51 },
+{ 20 , 80 , 17 , 52 },
+{ 20 , 80 , 17 , 53 },
+{ 20 , 80 , 17 , 54 },
+{ 20 , 80 , 17 , 55 },
+{ 20 , 80 , 17 , 56 },
+{ 20 , 80 , 17 , 57 },
+{ 20 , 80 , 17 , 58 },
+{ 20 , 80 , 17 , 59 },
+{ 20 , 80 , 17 , 60 },
+{ 20 , 80 , 17 , 61 },
+{ 20 , 80 , 17 , 62 },
+{ 20 , 80 , 17 , 63 },
+{ 20 , 80 , 17 , 64 },
+{ 20 , 80 , 17 , 65 },
+{ 20 , 80 , 17 , 66 },
+{ 20 , 80 , 17 , 67 },
+{ 20 , 80 , 17 , 68 },
+{ 20 , 80 , 17 , 69 },
+{ 20 , 80 , 17 , 70 },
+{ 20 , 80 , 17 , 71 },
+{ 20 , 80 , 17 , 72 },
+{ 20 , 80 , 17 , 73 },
+{ 20 , 80 , 17 , 74 },
+{ 20 , 80 , 17 , 75 },
+{ 20 , 80 , 17 , 76 },
+{ 20 , 80 , 17 , 77 },
+{ 20 , 80 , 17 , 78 },
+{ 20 , 80 , 17 , 79 },
+{ 20 , 80 , 18 , 0 },
+{ 20 , 80 , 18 , 1 },
+{ 20 , 80 , 18 , 2 },
+{ 20 , 80 , 18 , 3 },
+{ 20 , 80 , 18 , 4 },
+{ 20 , 80 , 18 , 5 },
+{ 20 , 80 , 18 , 6 },
+{ 20 , 80 , 18 , 7 },
+{ 20 , 80 , 18 , 8 },
+{ 20 , 80 , 18 , 9 },
+{ 20 , 80 , 18 , 10 },
+{ 20 , 80 , 18 , 11 },
+{ 20 , 80 , 18 , 12 },
+{ 20 , 80 , 18 , 13 },
+{ 20 , 80 , 18 , 14 },
+{ 20 , 80 , 18 , 15 },
+{ 20 , 80 , 18 , 16 },
+{ 20 , 80 , 18 , 17 },
+{ 20 , 80 , 18 , 18 },
+{ 20 , 80 , 18 , 19 },
+{ 20 , 80 , 18 , 20 },
+{ 20 , 80 , 18 , 21 },
+{ 20 , 80 , 18 , 22 },
+{ 20 , 80 , 18 , 23 },
+{ 20 , 80 , 18 , 24 },
+{ 20 , 80 , 18 , 25 },
+{ 20 , 80 , 18 , 26 },
+{ 20 , 80 , 18 , 27 },
+{ 20 , 80 , 18 , 28 },
+{ 20 , 80 , 18 , 29 },
+{ 20 , 80 , 18 , 30 },
+{ 20 , 80 , 18 , 31 },
+{ 20 , 80 , 18 , 32 },
+{ 20 , 80 , 18 , 33 },
+{ 20 , 80 , 18 , 34 },
+{ 20 , 80 , 18 , 35 },
+{ 20 , 80 , 18 , 36 },
+{ 20 , 80 , 18 , 37 },
+{ 20 , 80 , 18 , 38 },
+{ 20 , 80 , 18 , 39 },
+{ 20 , 80 , 18 , 40 },
+{ 20 , 80 , 18 , 41 },
+{ 20 , 80 , 18 , 42 },
+{ 20 , 80 , 18 , 43 },
+{ 20 , 80 , 18 , 44 },
+{ 20 , 80 , 18 , 45 },
+{ 20 , 80 , 18 , 46 },
+{ 20 , 80 , 18 , 47 },
+{ 20 , 80 , 18 , 48 },
+{ 20 , 80 , 18 , 49 },
+{ 20 , 80 , 18 , 50 },
+{ 20 , 80 , 18 , 51 },
+{ 20 , 80 , 18 , 52 },
+{ 20 , 80 , 18 , 53 },
+{ 20 , 80 , 18 , 54 },
+{ 20 , 80 , 18 , 55 },
+{ 20 , 80 , 18 , 56 },
+{ 20 , 80 , 18 , 57 },
+{ 20 , 80 , 18 , 58 },
+{ 20 , 80 , 18 , 59 },
+{ 20 , 80 , 18 , 60 },
+{ 20 , 80 , 18 , 61 },
+{ 20 , 80 , 18 , 62 },
+{ 20 , 80 , 18 , 63 },
+{ 20 , 80 , 18 , 64 },
+{ 20 , 80 , 18 , 65 },
+{ 20 , 80 , 18 , 66 },
+{ 20 , 80 , 18 , 67 },
+{ 20 , 80 , 18 , 68 },
+{ 20 , 80 , 18 , 69 },
+{ 20 , 80 , 18 , 70 },
+{ 20 , 80 , 18 , 71 },
+{ 20 , 80 , 18 , 72 },
+{ 20 , 80 , 18 , 73 },
+{ 20 , 80 , 18 , 74 },
+{ 20 , 80 , 18 , 75 },
+{ 20 , 80 , 18 , 76 },
+{ 20 , 80 , 18 , 77 },
+{ 20 , 80 , 18 , 78 },
+{ 20 , 80 , 18 , 79 },
+{ 20 , 80 , 19 , 0 },
+{ 20 , 80 , 19 , 1 },
+{ 20 , 80 , 19 , 2 },
+{ 20 , 80 , 19 , 3 },
+{ 20 , 80 , 19 , 4 },
+{ 20 , 80 , 19 , 5 },
+{ 20 , 80 , 19 , 6 },
+{ 20 , 80 , 19 , 7 },
+{ 20 , 80 , 19 , 8 },
+{ 20 , 80 , 19 , 9 },
+{ 20 , 80 , 19 , 10 },
+{ 20 , 80 , 19 , 11 },
+{ 20 , 80 , 19 , 12 },
+{ 20 , 80 , 19 , 13 },
+{ 20 , 80 , 19 , 14 },
+{ 20 , 80 , 19 , 15 },
+{ 20 , 80 , 19 , 16 },
+{ 20 , 80 , 19 , 17 },
+{ 20 , 80 , 19 , 18 },
+{ 20 , 80 , 19 , 19 },
+{ 20 , 80 , 19 , 20 },
+{ 20 , 80 , 19 , 21 },
+{ 20 , 80 , 19 , 22 },
+{ 20 , 80 , 19 , 23 },
+{ 20 , 80 , 19 , 24 },
+{ 20 , 80 , 19 , 25 },
+{ 20 , 80 , 19 , 26 },
+{ 20 , 80 , 19 , 27 },
+{ 20 , 80 , 19 , 28 },
+{ 20 , 80 , 19 , 29 },
+{ 20 , 80 , 19 , 30 },
+{ 20 , 80 , 19 , 31 },
+{ 20 , 80 , 19 , 32 },
+{ 20 , 80 , 19 , 33 },
+{ 20 , 80 , 19 , 34 },
+{ 20 , 80 , 19 , 35 },
+{ 20 , 80 , 19 , 36 },
+{ 20 , 80 , 19 , 37 },
+{ 20 , 80 , 19 , 38 },
+{ 20 , 80 , 19 , 39 },
+{ 20 , 80 , 19 , 40 },
+{ 20 , 80 , 19 , 41 },
+{ 20 , 80 , 19 , 42 },
+{ 20 , 80 , 19 , 43 },
+{ 20 , 80 , 19 , 44 },
+{ 20 , 80 , 19 , 45 },
+{ 20 , 80 , 19 , 46 },
+{ 20 , 80 , 19 , 47 },
+{ 20 , 80 , 19 , 48 },
+{ 20 , 80 , 19 , 49 },
+{ 20 , 80 , 19 , 50 },
+{ 20 , 80 , 19 , 51 },
+{ 20 , 80 , 19 , 52 },
+{ 20 , 80 , 19 , 53 },
+{ 20 , 80 , 19 , 54 },
+{ 20 , 80 , 19 , 55 },
+{ 20 , 80 , 19 , 56 },
+{ 20 , 80 , 19 , 57 },
+{ 20 , 80 , 19 , 58 },
+{ 20 , 80 , 19 , 59 },
+{ 20 , 80 , 19 , 60 },
+{ 20 , 80 , 19 , 61 },
+{ 20 , 80 , 19 , 62 },
+{ 20 , 80 , 19 , 63 },
+{ 20 , 80 , 19 , 64 },
+{ 20 , 80 , 19 , 65 },
+{ 20 , 80 , 19 , 66 },
+{ 20 , 80 , 19 , 67 },
+{ 20 , 80 , 19 , 68 },
+{ 20 , 80 , 19 , 69 },
+{ 20 , 80 , 19 , 70 },
+{ 20 , 80 , 19 , 71 },
+{ 20 , 80 , 19 , 72 },
+{ 20 , 80 , 19 , 73 },
+{ 20 , 80 , 19 , 74 },
+{ 20 , 80 , 19 , 75 },
+{ 20 , 80 , 19 , 76 },
+{ 20 , 80 , 19 , 77 },
+{ 20 , 80 , 19 , 78 },
+{ 20 , 80 , 19 , 79 },
+{ 40 , 5 , 0 , 0 },
+{ 40 , 5 , 0 , 1 },
+{ 40 , 5 , 0 , 2 },
+{ 40 , 5 , 0 , 3 },
+{ 40 , 5 , 0 , 4 },
+{ 40 , 5 , 1 , 0 },
+{ 40 , 5 , 1 , 1 },
+{ 40 , 5 , 1 , 2 },
+{ 40 , 5 , 1 , 3 },
+{ 40 , 5 , 1 , 4 },
+{ 40 , 5 , 2 , 0 },
+{ 40 , 5 , 2 , 1 },
+{ 40 , 5 , 2 , 2 },
+{ 40 , 5 , 2 , 3 },
+{ 40 , 5 , 2 , 4 },
+{ 40 , 5 , 3 , 0 },
+{ 40 , 5 , 3 , 1 },
+{ 40 , 5 , 3 , 2 },
+{ 40 , 5 , 3 , 3 },
+{ 40 , 5 , 3 , 4 },
+{ 40 , 5 , 4 , 0 },
+{ 40 , 5 , 4 , 1 },
+{ 40 , 5 , 4 , 2 },
+{ 40 , 5 , 4 , 3 },
+{ 40 , 5 , 4 , 4 },
+{ 40 , 5 , 5 , 0 },
+{ 40 , 5 , 5 , 1 },
+{ 40 , 5 , 5 , 2 },
+{ 40 , 5 , 5 , 3 },
+{ 40 , 5 , 5 , 4 },
+{ 40 , 5 , 6 , 0 },
+{ 40 , 5 , 6 , 1 },
+{ 40 , 5 , 6 , 2 },
+{ 40 , 5 , 6 , 3 },
+{ 40 , 5 , 6 , 4 },
+{ 40 , 5 , 7 , 0 },
+{ 40 , 5 , 7 , 1 },
+{ 40 , 5 , 7 , 2 },
+{ 40 , 5 , 7 , 3 },
+{ 40 , 5 , 7 , 4 },
+{ 40 , 5 , 8 , 0 },
+{ 40 , 5 , 8 , 1 },
+{ 40 , 5 , 8 , 2 },
+{ 40 , 5 , 8 , 3 },
+{ 40 , 5 , 8 , 4 },
+{ 40 , 5 , 9 , 0 },
+{ 40 , 5 , 9 , 1 },
+{ 40 , 5 , 9 , 2 },
+{ 40 , 5 , 9 , 3 },
+{ 40 , 5 , 9 , 4 },
+{ 40 , 5 , 10 , 0 },
+{ 40 , 5 , 10 , 1 },
+{ 40 , 5 , 10 , 2 },
+{ 40 , 5 , 10 , 3 },
+{ 40 , 5 , 10 , 4 },
+{ 40 , 5 , 11 , 0 },
+{ 40 , 5 , 11 , 1 },
+{ 40 , 5 , 11 , 2 },
+{ 40 , 5 , 11 , 3 },
+{ 40 , 5 , 11 , 4 },
+{ 40 , 5 , 12 , 0 },
+{ 40 , 5 , 12 , 1 },
+{ 40 , 5 , 12 , 2 },
+{ 40 , 5 , 12 , 3 },
+{ 40 , 5 , 12 , 4 },
+{ 40 , 5 , 13 , 0 },
+{ 40 , 5 , 13 , 1 },
+{ 40 , 5 , 13 , 2 },
+{ 40 , 5 , 13 , 3 },
+{ 40 , 5 , 13 , 4 },
+{ 40 , 5 , 14 , 0 },
+{ 40 , 5 , 14 , 1 },
+{ 40 , 5 , 14 , 2 },
+{ 40 , 5 , 14 , 3 },
+{ 40 , 5 , 14 , 4 },
+{ 40 , 5 , 15 , 0 },
+{ 40 , 5 , 15 , 1 },
+{ 40 , 5 , 15 , 2 },
+{ 40 , 5 , 15 , 3 },
+{ 40 , 5 , 15 , 4 },
+{ 40 , 5 , 16 , 0 },
+{ 40 , 5 , 16 , 1 },
+{ 40 , 5 , 16 , 2 },
+{ 40 , 5 , 16 , 3 },
+{ 40 , 5 , 16 , 4 },
+{ 40 , 5 , 17 , 0 },
+{ 40 , 5 , 17 , 1 },
+{ 40 , 5 , 17 , 2 },
+{ 40 , 5 , 17 , 3 },
+{ 40 , 5 , 17 , 4 },
+{ 40 , 5 , 18 , 0 },
+{ 40 , 5 , 18 , 1 },
+{ 40 , 5 , 18 , 2 },
+{ 40 , 5 , 18 , 3 },
+{ 40 , 5 , 18 , 4 },
+{ 40 , 5 , 19 , 0 },
+{ 40 , 5 , 19 , 1 },
+{ 40 , 5 , 19 , 2 },
+{ 40 , 5 , 19 , 3 },
+{ 40 , 5 , 19 , 4 },
+{ 40 , 5 , 20 , 0 },
+{ 40 , 5 , 20 , 1 },
+{ 40 , 5 , 20 , 2 },
+{ 40 , 5 , 20 , 3 },
+{ 40 , 5 , 20 , 4 },
+{ 40 , 5 , 21 , 0 },
+{ 40 , 5 , 21 , 1 },
+{ 40 , 5 , 21 , 2 },
+{ 40 , 5 , 21 , 3 },
+{ 40 , 5 , 21 , 4 },
+{ 40 , 5 , 22 , 0 },
+{ 40 , 5 , 22 , 1 },
+{ 40 , 5 , 22 , 2 },
+{ 40 , 5 , 22 , 3 },
+{ 40 , 5 , 22 , 4 },
+{ 40 , 5 , 23 , 0 },
+{ 40 , 5 , 23 , 1 },
+{ 40 , 5 , 23 , 2 },
+{ 40 , 5 , 23 , 3 },
+{ 40 , 5 , 23 , 4 },
+{ 40 , 5 , 24 , 0 },
+{ 40 , 5 , 24 , 1 },
+{ 40 , 5 , 24 , 2 },
+{ 40 , 5 , 24 , 3 },
+{ 40 , 5 , 24 , 4 },
+{ 40 , 5 , 25 , 0 },
+{ 40 , 5 , 25 , 1 },
+{ 40 , 5 , 25 , 2 },
+{ 40 , 5 , 25 , 3 },
+{ 40 , 5 , 25 , 4 },
+{ 40 , 5 , 26 , 0 },
+{ 40 , 5 , 26 , 1 },
+{ 40 , 5 , 26 , 2 },
+{ 40 , 5 , 26 , 3 },
+{ 40 , 5 , 26 , 4 },
+{ 40 , 5 , 27 , 0 },
+{ 40 , 5 , 27 , 1 },
+{ 40 , 5 , 27 , 2 },
+{ 40 , 5 , 27 , 3 },
+{ 40 , 5 , 27 , 4 },
+{ 40 , 5 , 28 , 0 },
+{ 40 , 5 , 28 , 1 },
+{ 40 , 5 , 28 , 2 },
+{ 40 , 5 , 28 , 3 },
+{ 40 , 5 , 28 , 4 },
+{ 40 , 5 , 29 , 0 },
+{ 40 , 5 , 29 , 1 },
+{ 40 , 5 , 29 , 2 },
+{ 40 , 5 , 29 , 3 },
+{ 40 , 5 , 29 , 4 },
+{ 40 , 5 , 30 , 0 },
+{ 40 , 5 , 30 , 1 },
+{ 40 , 5 , 30 , 2 },
+{ 40 , 5 , 30 , 3 },
+{ 40 , 5 , 30 , 4 },
+{ 40 , 5 , 31 , 0 },
+{ 40 , 5 , 31 , 1 },
+{ 40 , 5 , 31 , 2 },
+{ 40 , 5 , 31 , 3 },
+{ 40 , 5 , 31 , 4 },
+{ 40 , 5 , 32 , 0 },
+{ 40 , 5 , 32 , 1 },
+{ 40 , 5 , 32 , 2 },
+{ 40 , 5 , 32 , 3 },
+{ 40 , 5 , 32 , 4 },
+{ 40 , 5 , 33 , 0 },
+{ 40 , 5 , 33 , 1 },
+{ 40 , 5 , 33 , 2 },
+{ 40 , 5 , 33 , 3 },
+{ 40 , 5 , 33 , 4 },
+{ 40 , 5 , 34 , 0 },
+{ 40 , 5 , 34 , 1 },
+{ 40 , 5 , 34 , 2 },
+{ 40 , 5 , 34 , 3 },
+{ 40 , 5 , 34 , 4 },
+{ 40 , 5 , 35 , 0 },
+{ 40 , 5 , 35 , 1 },
+{ 40 , 5 , 35 , 2 },
+{ 40 , 5 , 35 , 3 },
+{ 40 , 5 , 35 , 4 },
+{ 40 , 5 , 36 , 0 },
+{ 40 , 5 , 36 , 1 },
+{ 40 , 5 , 36 , 2 },
+{ 40 , 5 , 36 , 3 },
+{ 40 , 5 , 36 , 4 },
+{ 40 , 5 , 37 , 0 },
+{ 40 , 5 , 37 , 1 },
+{ 40 , 5 , 37 , 2 },
+{ 40 , 5 , 37 , 3 },
+{ 40 , 5 , 37 , 4 },
+{ 40 , 5 , 38 , 0 },
+{ 40 , 5 , 38 , 1 },
+{ 40 , 5 , 38 , 2 },
+{ 40 , 5 , 38 , 3 },
+{ 40 , 5 , 38 , 4 },
+{ 40 , 5 , 39 , 0 },
+{ 40 , 5 , 39 , 1 },
+{ 40 , 5 , 39 , 2 },
+{ 40 , 5 , 39 , 3 },
+{ 40 , 5 , 39 , 4 },
+{ 40 , 10 , 0 , 0 },
+{ 40 , 10 , 0 , 1 },
+{ 40 , 10 , 0 , 2 },
+{ 40 , 10 , 0 , 3 },
+{ 40 , 10 , 0 , 4 },
+{ 40 , 10 , 0 , 5 },
+{ 40 , 10 , 0 , 6 },
+{ 40 , 10 , 0 , 7 },
+{ 40 , 10 , 0 , 8 },
+{ 40 , 10 , 0 , 9 },
+{ 40 , 10 , 1 , 0 },
+{ 40 , 10 , 1 , 1 },
+{ 40 , 10 , 1 , 2 },
+{ 40 , 10 , 1 , 3 },
+{ 40 , 10 , 1 , 4 },
+{ 40 , 10 , 1 , 5 },
+{ 40 , 10 , 1 , 6 },
+{ 40 , 10 , 1 , 7 },
+{ 40 , 10 , 1 , 8 },
+{ 40 , 10 , 1 , 9 },
+{ 40 , 10 , 2 , 0 },
+{ 40 , 10 , 2 , 1 },
+{ 40 , 10 , 2 , 2 },
+{ 40 , 10 , 2 , 3 },
+{ 40 , 10 , 2 , 4 },
+{ 40 , 10 , 2 , 5 },
+{ 40 , 10 , 2 , 6 },
+{ 40 , 10 , 2 , 7 },
+{ 40 , 10 , 2 , 8 },
+{ 40 , 10 , 2 , 9 },
+{ 40 , 10 , 3 , 0 },
+{ 40 , 10 , 3 , 1 },
+{ 40 , 10 , 3 , 2 },
+{ 40 , 10 , 3 , 3 },
+{ 40 , 10 , 3 , 4 },
+{ 40 , 10 , 3 , 5 },
+{ 40 , 10 , 3 , 6 },
+{ 40 , 10 , 3 , 7 },
+{ 40 , 10 , 3 , 8 },
+{ 40 , 10 , 3 , 9 },
+{ 40 , 10 , 4 , 0 },
+{ 40 , 10 , 4 , 1 },
+{ 40 , 10 , 4 , 2 },
+{ 40 , 10 , 4 , 3 },
+{ 40 , 10 , 4 , 4 },
+{ 40 , 10 , 4 , 5 },
+{ 40 , 10 , 4 , 6 },
+{ 40 , 10 , 4 , 7 },
+{ 40 , 10 , 4 , 8 },
+{ 40 , 10 , 4 , 9 },
+{ 40 , 10 , 5 , 0 },
+{ 40 , 10 , 5 , 1 },
+{ 40 , 10 , 5 , 2 },
+{ 40 , 10 , 5 , 3 },
+{ 40 , 10 , 5 , 4 },
+{ 40 , 10 , 5 , 5 },
+{ 40 , 10 , 5 , 6 },
+{ 40 , 10 , 5 , 7 },
+{ 40 , 10 , 5 , 8 },
+{ 40 , 10 , 5 , 9 },
+{ 40 , 10 , 6 , 0 },
+{ 40 , 10 , 6 , 1 },
+{ 40 , 10 , 6 , 2 },
+{ 40 , 10 , 6 , 3 },
+{ 40 , 10 , 6 , 4 },
+{ 40 , 10 , 6 , 5 },
+{ 40 , 10 , 6 , 6 },
+{ 40 , 10 , 6 , 7 },
+{ 40 , 10 , 6 , 8 },
+{ 40 , 10 , 6 , 9 },
+{ 40 , 10 , 7 , 0 },
+{ 40 , 10 , 7 , 1 },
+{ 40 , 10 , 7 , 2 },
+{ 40 , 10 , 7 , 3 },
+{ 40 , 10 , 7 , 4 },
+{ 40 , 10 , 7 , 5 },
+{ 40 , 10 , 7 , 6 },
+{ 40 , 10 , 7 , 7 },
+{ 40 , 10 , 7 , 8 },
+{ 40 , 10 , 7 , 9 },
+{ 40 , 10 , 8 , 0 },
+{ 40 , 10 , 8 , 1 },
+{ 40 , 10 , 8 , 2 },
+{ 40 , 10 , 8 , 3 },
+{ 40 , 10 , 8 , 4 },
+{ 40 , 10 , 8 , 5 },
+{ 40 , 10 , 8 , 6 },
+{ 40 , 10 , 8 , 7 },
+{ 40 , 10 , 8 , 8 },
+{ 40 , 10 , 8 , 9 },
+{ 40 , 10 , 9 , 0 },
+{ 40 , 10 , 9 , 1 },
+{ 40 , 10 , 9 , 2 },
+{ 40 , 10 , 9 , 3 },
+{ 40 , 10 , 9 , 4 },
+{ 40 , 10 , 9 , 5 },
+{ 40 , 10 , 9 , 6 },
+{ 40 , 10 , 9 , 7 },
+{ 40 , 10 , 9 , 8 },
+{ 40 , 10 , 9 , 9 },
+{ 40 , 10 , 10 , 0 },
+{ 40 , 10 , 10 , 1 },
+{ 40 , 10 , 10 , 2 },
+{ 40 , 10 , 10 , 3 },
+{ 40 , 10 , 10 , 4 },
+{ 40 , 10 , 10 , 5 },
+{ 40 , 10 , 10 , 6 },
+{ 40 , 10 , 10 , 7 },
+{ 40 , 10 , 10 , 8 },
+{ 40 , 10 , 10 , 9 },
+{ 40 , 10 , 11 , 0 },
+{ 40 , 10 , 11 , 1 },
+{ 40 , 10 , 11 , 2 },
+{ 40 , 10 , 11 , 3 },
+{ 40 , 10 , 11 , 4 },
+{ 40 , 10 , 11 , 5 },
+{ 40 , 10 , 11 , 6 },
+{ 40 , 10 , 11 , 7 },
+{ 40 , 10 , 11 , 8 },
+{ 40 , 10 , 11 , 9 },
+{ 40 , 10 , 12 , 0 },
+{ 40 , 10 , 12 , 1 },
+{ 40 , 10 , 12 , 2 },
+{ 40 , 10 , 12 , 3 },
+{ 40 , 10 , 12 , 4 },
+{ 40 , 10 , 12 , 5 },
+{ 40 , 10 , 12 , 6 },
+{ 40 , 10 , 12 , 7 },
+{ 40 , 10 , 12 , 8 },
+{ 40 , 10 , 12 , 9 },
+{ 40 , 10 , 13 , 0 },
+{ 40 , 10 , 13 , 1 },
+{ 40 , 10 , 13 , 2 },
+{ 40 , 10 , 13 , 3 },
+{ 40 , 10 , 13 , 4 },
+{ 40 , 10 , 13 , 5 },
+{ 40 , 10 , 13 , 6 },
+{ 40 , 10 , 13 , 7 },
+{ 40 , 10 , 13 , 8 },
+{ 40 , 10 , 13 , 9 },
+{ 40 , 10 , 14 , 0 },
+{ 40 , 10 , 14 , 1 },
+{ 40 , 10 , 14 , 2 },
+{ 40 , 10 , 14 , 3 },
+{ 40 , 10 , 14 , 4 },
+{ 40 , 10 , 14 , 5 },
+{ 40 , 10 , 14 , 6 },
+{ 40 , 10 , 14 , 7 },
+{ 40 , 10 , 14 , 8 },
+{ 40 , 10 , 14 , 9 },
+{ 40 , 10 , 15 , 0 },
+{ 40 , 10 , 15 , 1 },
+{ 40 , 10 , 15 , 2 },
+{ 40 , 10 , 15 , 3 },
+{ 40 , 10 , 15 , 4 },
+{ 40 , 10 , 15 , 5 },
+{ 40 , 10 , 15 , 6 },
+{ 40 , 10 , 15 , 7 },
+{ 40 , 10 , 15 , 8 },
+{ 40 , 10 , 15 , 9 },
+{ 40 , 10 , 16 , 0 },
+{ 40 , 10 , 16 , 1 },
+{ 40 , 10 , 16 , 2 },
+{ 40 , 10 , 16 , 3 },
+{ 40 , 10 , 16 , 4 },
+{ 40 , 10 , 16 , 5 },
+{ 40 , 10 , 16 , 6 },
+{ 40 , 10 , 16 , 7 },
+{ 40 , 10 , 16 , 8 },
+{ 40 , 10 , 16 , 9 },
+{ 40 , 10 , 17 , 0 },
+{ 40 , 10 , 17 , 1 },
+{ 40 , 10 , 17 , 2 },
+{ 40 , 10 , 17 , 3 },
+{ 40 , 10 , 17 , 4 },
+{ 40 , 10 , 17 , 5 },
+{ 40 , 10 , 17 , 6 },
+{ 40 , 10 , 17 , 7 },
+{ 40 , 10 , 17 , 8 },
+{ 40 , 10 , 17 , 9 },
+{ 40 , 10 , 18 , 0 },
+{ 40 , 10 , 18 , 1 },
+{ 40 , 10 , 18 , 2 },
+{ 40 , 10 , 18 , 3 },
+{ 40 , 10 , 18 , 4 },
+{ 40 , 10 , 18 , 5 },
+{ 40 , 10 , 18 , 6 },
+{ 40 , 10 , 18 , 7 },
+{ 40 , 10 , 18 , 8 },
+{ 40 , 10 , 18 , 9 },
+{ 40 , 10 , 19 , 0 },
+{ 40 , 10 , 19 , 1 },
+{ 40 , 10 , 19 , 2 },
+{ 40 , 10 , 19 , 3 },
+{ 40 , 10 , 19 , 4 },
+{ 40 , 10 , 19 , 5 },
+{ 40 , 10 , 19 , 6 },
+{ 40 , 10 , 19 , 7 },
+{ 40 , 10 , 19 , 8 },
+{ 40 , 10 , 19 , 9 },
+{ 40 , 10 , 20 , 0 },
+{ 40 , 10 , 20 , 1 },
+{ 40 , 10 , 20 , 2 },
+{ 40 , 10 , 20 , 3 },
+{ 40 , 10 , 20 , 4 },
+{ 40 , 10 , 20 , 5 },
+{ 40 , 10 , 20 , 6 },
+{ 40 , 10 , 20 , 7 },
+{ 40 , 10 , 20 , 8 },
+{ 40 , 10 , 20 , 9 },
+{ 40 , 10 , 21 , 0 },
+{ 40 , 10 , 21 , 1 },
+{ 40 , 10 , 21 , 2 },
+{ 40 , 10 , 21 , 3 },
+{ 40 , 10 , 21 , 4 },
+{ 40 , 10 , 21 , 5 },
+{ 40 , 10 , 21 , 6 },
+{ 40 , 10 , 21 , 7 },
+{ 40 , 10 , 21 , 8 },
+{ 40 , 10 , 21 , 9 },
+{ 40 , 10 , 22 , 0 },
+{ 40 , 10 , 22 , 1 },
+{ 40 , 10 , 22 , 2 },
+{ 40 , 10 , 22 , 3 },
+{ 40 , 10 , 22 , 4 },
+{ 40 , 10 , 22 , 5 },
+{ 40 , 10 , 22 , 6 },
+{ 40 , 10 , 22 , 7 },
+{ 40 , 10 , 22 , 8 },
+{ 40 , 10 , 22 , 9 },
+{ 40 , 10 , 23 , 0 },
+{ 40 , 10 , 23 , 1 },
+{ 40 , 10 , 23 , 2 },
+{ 40 , 10 , 23 , 3 },
+{ 40 , 10 , 23 , 4 },
+{ 40 , 10 , 23 , 5 },
+{ 40 , 10 , 23 , 6 },
+{ 40 , 10 , 23 , 7 },
+{ 40 , 10 , 23 , 8 },
+{ 40 , 10 , 23 , 9 },
+{ 40 , 10 , 24 , 0 },
+{ 40 , 10 , 24 , 1 },
+{ 40 , 10 , 24 , 2 },
+{ 40 , 10 , 24 , 3 },
+{ 40 , 10 , 24 , 4 },
+{ 40 , 10 , 24 , 5 },
+{ 40 , 10 , 24 , 6 },
+{ 40 , 10 , 24 , 7 },
+{ 40 , 10 , 24 , 8 },
+{ 40 , 10 , 24 , 9 },
+{ 40 , 10 , 25 , 0 },
+{ 40 , 10 , 25 , 1 },
+{ 40 , 10 , 25 , 2 },
+{ 40 , 10 , 25 , 3 },
+{ 40 , 10 , 25 , 4 },
+{ 40 , 10 , 25 , 5 },
+{ 40 , 10 , 25 , 6 },
+{ 40 , 10 , 25 , 7 },
+{ 40 , 10 , 25 , 8 },
+{ 40 , 10 , 25 , 9 },
+{ 40 , 10 , 26 , 0 },
+{ 40 , 10 , 26 , 1 },
+{ 40 , 10 , 26 , 2 },
+{ 40 , 10 , 26 , 3 },
+{ 40 , 10 , 26 , 4 },
+{ 40 , 10 , 26 , 5 },
+{ 40 , 10 , 26 , 6 },
+{ 40 , 10 , 26 , 7 },
+{ 40 , 10 , 26 , 8 },
+{ 40 , 10 , 26 , 9 },
+{ 40 , 10 , 27 , 0 },
+{ 40 , 10 , 27 , 1 },
+{ 40 , 10 , 27 , 2 },
+{ 40 , 10 , 27 , 3 },
+{ 40 , 10 , 27 , 4 },
+{ 40 , 10 , 27 , 5 },
+{ 40 , 10 , 27 , 6 },
+{ 40 , 10 , 27 , 7 },
+{ 40 , 10 , 27 , 8 },
+{ 40 , 10 , 27 , 9 },
+{ 40 , 10 , 28 , 0 },
+{ 40 , 10 , 28 , 1 },
+{ 40 , 10 , 28 , 2 },
+{ 40 , 10 , 28 , 3 },
+{ 40 , 10 , 28 , 4 },
+{ 40 , 10 , 28 , 5 },
+{ 40 , 10 , 28 , 6 },
+{ 40 , 10 , 28 , 7 },
+{ 40 , 10 , 28 , 8 },
+{ 40 , 10 , 28 , 9 },
+{ 40 , 10 , 29 , 0 },
+{ 40 , 10 , 29 , 1 },
+{ 40 , 10 , 29 , 2 },
+{ 40 , 10 , 29 , 3 },
+{ 40 , 10 , 29 , 4 },
+{ 40 , 10 , 29 , 5 },
+{ 40 , 10 , 29 , 6 },
+{ 40 , 10 , 29 , 7 },
+{ 40 , 10 , 29 , 8 },
+{ 40 , 10 , 29 , 9 },
+{ 40 , 10 , 30 , 0 },
+{ 40 , 10 , 30 , 1 },
+{ 40 , 10 , 30 , 2 },
+{ 40 , 10 , 30 , 3 },
+{ 40 , 10 , 30 , 4 },
+{ 40 , 10 , 30 , 5 },
+{ 40 , 10 , 30 , 6 },
+{ 40 , 10 , 30 , 7 },
+{ 40 , 10 , 30 , 8 },
+{ 40 , 10 , 30 , 9 },
+{ 40 , 10 , 31 , 0 },
+{ 40 , 10 , 31 , 1 },
+{ 40 , 10 , 31 , 2 },
+{ 40 , 10 , 31 , 3 },
+{ 40 , 10 , 31 , 4 },
+{ 40 , 10 , 31 , 5 },
+{ 40 , 10 , 31 , 6 },
+{ 40 , 10 , 31 , 7 },
+{ 40 , 10 , 31 , 8 },
+{ 40 , 10 , 31 , 9 },
+{ 40 , 10 , 32 , 0 },
+{ 40 , 10 , 32 , 1 },
+{ 40 , 10 , 32 , 2 },
+{ 40 , 10 , 32 , 3 },
+{ 40 , 10 , 32 , 4 },
+{ 40 , 10 , 32 , 5 },
+{ 40 , 10 , 32 , 6 },
+{ 40 , 10 , 32 , 7 },
+{ 40 , 10 , 32 , 8 },
+{ 40 , 10 , 32 , 9 },
+{ 40 , 10 , 33 , 0 },
+{ 40 , 10 , 33 , 1 },
+{ 40 , 10 , 33 , 2 },
+{ 40 , 10 , 33 , 3 },
+{ 40 , 10 , 33 , 4 },
+{ 40 , 10 , 33 , 5 },
+{ 40 , 10 , 33 , 6 },
+{ 40 , 10 , 33 , 7 },
+{ 40 , 10 , 33 , 8 },
+{ 40 , 10 , 33 , 9 },
+{ 40 , 10 , 34 , 0 },
+{ 40 , 10 , 34 , 1 },
+{ 40 , 10 , 34 , 2 },
+{ 40 , 10 , 34 , 3 },
+{ 40 , 10 , 34 , 4 },
+{ 40 , 10 , 34 , 5 },
+{ 40 , 10 , 34 , 6 },
+{ 40 , 10 , 34 , 7 },
+{ 40 , 10 , 34 , 8 },
+{ 40 , 10 , 34 , 9 },
+{ 40 , 10 , 35 , 0 },
+{ 40 , 10 , 35 , 1 },
+{ 40 , 10 , 35 , 2 },
+{ 40 , 10 , 35 , 3 },
+{ 40 , 10 , 35 , 4 },
+{ 40 , 10 , 35 , 5 },
+{ 40 , 10 , 35 , 6 },
+{ 40 , 10 , 35 , 7 },
+{ 40 , 10 , 35 , 8 },
+{ 40 , 10 , 35 , 9 },
+{ 40 , 10 , 36 , 0 },
+{ 40 , 10 , 36 , 1 },
+{ 40 , 10 , 36 , 2 },
+{ 40 , 10 , 36 , 3 },
+{ 40 , 10 , 36 , 4 },
+{ 40 , 10 , 36 , 5 },
+{ 40 , 10 , 36 , 6 },
+{ 40 , 10 , 36 , 7 },
+{ 40 , 10 , 36 , 8 },
+{ 40 , 10 , 36 , 9 },
+{ 40 , 10 , 37 , 0 },
+{ 40 , 10 , 37 , 1 },
+{ 40 , 10 , 37 , 2 },
+{ 40 , 10 , 37 , 3 },
+{ 40 , 10 , 37 , 4 },
+{ 40 , 10 , 37 , 5 },
+{ 40 , 10 , 37 , 6 },
+{ 40 , 10 , 37 , 7 },
+{ 40 , 10 , 37 , 8 },
+{ 40 , 10 , 37 , 9 },
+{ 40 , 10 , 38 , 0 },
+{ 40 , 10 , 38 , 1 },
+{ 40 , 10 , 38 , 2 },
+{ 40 , 10 , 38 , 3 },
+{ 40 , 10 , 38 , 4 },
+{ 40 , 10 , 38 , 5 },
+{ 40 , 10 , 38 , 6 },
+{ 40 , 10 , 38 , 7 },
+{ 40 , 10 , 38 , 8 },
+{ 40 , 10 , 38 , 9 },
+{ 40 , 10 , 39 , 0 },
+{ 40 , 10 , 39 , 1 },
+{ 40 , 10 , 39 , 2 },
+{ 40 , 10 , 39 , 3 },
+{ 40 , 10 , 39 , 4 },
+{ 40 , 10 , 39 , 5 },
+{ 40 , 10 , 39 , 6 },
+{ 40 , 10 , 39 , 7 },
+{ 40 , 10 , 39 , 8 },
+{ 40 , 10 , 39 , 9 },
+{ 40 , 20 , 0 , 0 },
+{ 40 , 20 , 0 , 1 },
+{ 40 , 20 , 0 , 2 },
+{ 40 , 20 , 0 , 3 },
+{ 40 , 20 , 0 , 4 },
+{ 40 , 20 , 0 , 5 },
+{ 40 , 20 , 0 , 6 },
+{ 40 , 20 , 0 , 7 },
+{ 40 , 20 , 0 , 8 },
+{ 40 , 20 , 0 , 9 },
+{ 40 , 20 , 0 , 10 },
+{ 40 , 20 , 0 , 11 },
+{ 40 , 20 , 0 , 12 },
+{ 40 , 20 , 0 , 13 },
+{ 40 , 20 , 0 , 14 },
+{ 40 , 20 , 0 , 15 },
+{ 40 , 20 , 0 , 16 },
+{ 40 , 20 , 0 , 17 },
+{ 40 , 20 , 0 , 18 },
+{ 40 , 20 , 0 , 19 },
+{ 40 , 20 , 1 , 0 },
+{ 40 , 20 , 1 , 1 },
+{ 40 , 20 , 1 , 2 },
+{ 40 , 20 , 1 , 3 },
+{ 40 , 20 , 1 , 4 },
+{ 40 , 20 , 1 , 5 },
+{ 40 , 20 , 1 , 6 },
+{ 40 , 20 , 1 , 7 },
+{ 40 , 20 , 1 , 8 },
+{ 40 , 20 , 1 , 9 },
+{ 40 , 20 , 1 , 10 },
+{ 40 , 20 , 1 , 11 },
+{ 40 , 20 , 1 , 12 },
+{ 40 , 20 , 1 , 13 },
+{ 40 , 20 , 1 , 14 },
+{ 40 , 20 , 1 , 15 },
+{ 40 , 20 , 1 , 16 },
+{ 40 , 20 , 1 , 17 },
+{ 40 , 20 , 1 , 18 },
+{ 40 , 20 , 1 , 19 },
+{ 40 , 20 , 2 , 0 },
+{ 40 , 20 , 2 , 1 },
+{ 40 , 20 , 2 , 2 },
+{ 40 , 20 , 2 , 3 },
+{ 40 , 20 , 2 , 4 },
+{ 40 , 20 , 2 , 5 },
+{ 40 , 20 , 2 , 6 },
+{ 40 , 20 , 2 , 7 },
+{ 40 , 20 , 2 , 8 },
+{ 40 , 20 , 2 , 9 },
+{ 40 , 20 , 2 , 10 },
+{ 40 , 20 , 2 , 11 },
+{ 40 , 20 , 2 , 12 },
+{ 40 , 20 , 2 , 13 },
+{ 40 , 20 , 2 , 14 },
+{ 40 , 20 , 2 , 15 },
+{ 40 , 20 , 2 , 16 },
+{ 40 , 20 , 2 , 17 },
+{ 40 , 20 , 2 , 18 },
+{ 40 , 20 , 2 , 19 },
+{ 40 , 20 , 3 , 0 },
+{ 40 , 20 , 3 , 1 },
+{ 40 , 20 , 3 , 2 },
+{ 40 , 20 , 3 , 3 },
+{ 40 , 20 , 3 , 4 },
+{ 40 , 20 , 3 , 5 },
+{ 40 , 20 , 3 , 6 },
+{ 40 , 20 , 3 , 7 },
+{ 40 , 20 , 3 , 8 },
+{ 40 , 20 , 3 , 9 },
+{ 40 , 20 , 3 , 10 },
+{ 40 , 20 , 3 , 11 },
+{ 40 , 20 , 3 , 12 },
+{ 40 , 20 , 3 , 13 },
+{ 40 , 20 , 3 , 14 },
+{ 40 , 20 , 3 , 15 },
+{ 40 , 20 , 3 , 16 },
+{ 40 , 20 , 3 , 17 },
+{ 40 , 20 , 3 , 18 },
+{ 40 , 20 , 3 , 19 },
+{ 40 , 20 , 4 , 0 },
+{ 40 , 20 , 4 , 1 },
+{ 40 , 20 , 4 , 2 },
+{ 40 , 20 , 4 , 3 },
+{ 40 , 20 , 4 , 4 },
+{ 40 , 20 , 4 , 5 },
+{ 40 , 20 , 4 , 6 },
+{ 40 , 20 , 4 , 7 },
+{ 40 , 20 , 4 , 8 },
+{ 40 , 20 , 4 , 9 },
+{ 40 , 20 , 4 , 10 },
+{ 40 , 20 , 4 , 11 },
+{ 40 , 20 , 4 , 12 },
+{ 40 , 20 , 4 , 13 },
+{ 40 , 20 , 4 , 14 },
+{ 40 , 20 , 4 , 15 },
+{ 40 , 20 , 4 , 16 },
+{ 40 , 20 , 4 , 17 },
+{ 40 , 20 , 4 , 18 },
+{ 40 , 20 , 4 , 19 },
+{ 40 , 20 , 5 , 0 },
+{ 40 , 20 , 5 , 1 },
+{ 40 , 20 , 5 , 2 },
+{ 40 , 20 , 5 , 3 },
+{ 40 , 20 , 5 , 4 },
+{ 40 , 20 , 5 , 5 },
+{ 40 , 20 , 5 , 6 },
+{ 40 , 20 , 5 , 7 },
+{ 40 , 20 , 5 , 8 },
+{ 40 , 20 , 5 , 9 },
+{ 40 , 20 , 5 , 10 },
+{ 40 , 20 , 5 , 11 },
+{ 40 , 20 , 5 , 12 },
+{ 40 , 20 , 5 , 13 },
+{ 40 , 20 , 5 , 14 },
+{ 40 , 20 , 5 , 15 },
+{ 40 , 20 , 5 , 16 },
+{ 40 , 20 , 5 , 17 },
+{ 40 , 20 , 5 , 18 },
+{ 40 , 20 , 5 , 19 },
+{ 40 , 20 , 6 , 0 },
+{ 40 , 20 , 6 , 1 },
+{ 40 , 20 , 6 , 2 },
+{ 40 , 20 , 6 , 3 },
+{ 40 , 20 , 6 , 4 },
+{ 40 , 20 , 6 , 5 },
+{ 40 , 20 , 6 , 6 },
+{ 40 , 20 , 6 , 7 },
+{ 40 , 20 , 6 , 8 },
+{ 40 , 20 , 6 , 9 },
+{ 40 , 20 , 6 , 10 },
+{ 40 , 20 , 6 , 11 },
+{ 40 , 20 , 6 , 12 },
+{ 40 , 20 , 6 , 13 },
+{ 40 , 20 , 6 , 14 },
+{ 40 , 20 , 6 , 15 },
+{ 40 , 20 , 6 , 16 },
+{ 40 , 20 , 6 , 17 },
+{ 40 , 20 , 6 , 18 },
+{ 40 , 20 , 6 , 19 },
+{ 40 , 20 , 7 , 0 },
+{ 40 , 20 , 7 , 1 },
+{ 40 , 20 , 7 , 2 },
+{ 40 , 20 , 7 , 3 },
+{ 40 , 20 , 7 , 4 },
+{ 40 , 20 , 7 , 5 },
+{ 40 , 20 , 7 , 6 },
+{ 40 , 20 , 7 , 7 },
+{ 40 , 20 , 7 , 8 },
+{ 40 , 20 , 7 , 9 },
+{ 40 , 20 , 7 , 10 },
+{ 40 , 20 , 7 , 11 },
+{ 40 , 20 , 7 , 12 },
+{ 40 , 20 , 7 , 13 },
+{ 40 , 20 , 7 , 14 },
+{ 40 , 20 , 7 , 15 },
+{ 40 , 20 , 7 , 16 },
+{ 40 , 20 , 7 , 17 },
+{ 40 , 20 , 7 , 18 },
+{ 40 , 20 , 7 , 19 },
+{ 40 , 20 , 8 , 0 },
+{ 40 , 20 , 8 , 1 },
+{ 40 , 20 , 8 , 2 },
+{ 40 , 20 , 8 , 3 },
+{ 40 , 20 , 8 , 4 },
+{ 40 , 20 , 8 , 5 },
+{ 40 , 20 , 8 , 6 },
+{ 40 , 20 , 8 , 7 },
+{ 40 , 20 , 8 , 8 },
+{ 40 , 20 , 8 , 9 },
+{ 40 , 20 , 8 , 10 },
+{ 40 , 20 , 8 , 11 },
+{ 40 , 20 , 8 , 12 },
+{ 40 , 20 , 8 , 13 },
+{ 40 , 20 , 8 , 14 },
+{ 40 , 20 , 8 , 15 },
+{ 40 , 20 , 8 , 16 },
+{ 40 , 20 , 8 , 17 },
+{ 40 , 20 , 8 , 18 },
+{ 40 , 20 , 8 , 19 },
+{ 40 , 20 , 9 , 0 },
+{ 40 , 20 , 9 , 1 },
+{ 40 , 20 , 9 , 2 },
+{ 40 , 20 , 9 , 3 },
+{ 40 , 20 , 9 , 4 },
+{ 40 , 20 , 9 , 5 },
+{ 40 , 20 , 9 , 6 },
+{ 40 , 20 , 9 , 7 },
+{ 40 , 20 , 9 , 8 },
+{ 40 , 20 , 9 , 9 },
+{ 40 , 20 , 9 , 10 },
+{ 40 , 20 , 9 , 11 },
+{ 40 , 20 , 9 , 12 },
+{ 40 , 20 , 9 , 13 },
+{ 40 , 20 , 9 , 14 },
+{ 40 , 20 , 9 , 15 },
+{ 40 , 20 , 9 , 16 },
+{ 40 , 20 , 9 , 17 },
+{ 40 , 20 , 9 , 18 },
+{ 40 , 20 , 9 , 19 },
+{ 40 , 20 , 10 , 0 },
+{ 40 , 20 , 10 , 1 },
+{ 40 , 20 , 10 , 2 },
+{ 40 , 20 , 10 , 3 },
+{ 40 , 20 , 10 , 4 },
+{ 40 , 20 , 10 , 5 },
+{ 40 , 20 , 10 , 6 },
+{ 40 , 20 , 10 , 7 },
+{ 40 , 20 , 10 , 8 },
+{ 40 , 20 , 10 , 9 },
+{ 40 , 20 , 10 , 10 },
+{ 40 , 20 , 10 , 11 },
+{ 40 , 20 , 10 , 12 },
+{ 40 , 20 , 10 , 13 },
+{ 40 , 20 , 10 , 14 },
+{ 40 , 20 , 10 , 15 },
+{ 40 , 20 , 10 , 16 },
+{ 40 , 20 , 10 , 17 },
+{ 40 , 20 , 10 , 18 },
+{ 40 , 20 , 10 , 19 },
+{ 40 , 20 , 11 , 0 },
+{ 40 , 20 , 11 , 1 },
+{ 40 , 20 , 11 , 2 },
+{ 40 , 20 , 11 , 3 },
+{ 40 , 20 , 11 , 4 },
+{ 40 , 20 , 11 , 5 },
+{ 40 , 20 , 11 , 6 },
+{ 40 , 20 , 11 , 7 },
+{ 40 , 20 , 11 , 8 },
+{ 40 , 20 , 11 , 9 },
+{ 40 , 20 , 11 , 10 },
+{ 40 , 20 , 11 , 11 },
+{ 40 , 20 , 11 , 12 },
+{ 40 , 20 , 11 , 13 },
+{ 40 , 20 , 11 , 14 },
+{ 40 , 20 , 11 , 15 },
+{ 40 , 20 , 11 , 16 },
+{ 40 , 20 , 11 , 17 },
+{ 40 , 20 , 11 , 18 },
+{ 40 , 20 , 11 , 19 },
+{ 40 , 20 , 12 , 0 },
+{ 40 , 20 , 12 , 1 },
+{ 40 , 20 , 12 , 2 },
+{ 40 , 20 , 12 , 3 },
+{ 40 , 20 , 12 , 4 },
+{ 40 , 20 , 12 , 5 },
+{ 40 , 20 , 12 , 6 },
+{ 40 , 20 , 12 , 7 },
+{ 40 , 20 , 12 , 8 },
+{ 40 , 20 , 12 , 9 },
+{ 40 , 20 , 12 , 10 },
+{ 40 , 20 , 12 , 11 },
+{ 40 , 20 , 12 , 12 },
+{ 40 , 20 , 12 , 13 },
+{ 40 , 20 , 12 , 14 },
+{ 40 , 20 , 12 , 15 },
+{ 40 , 20 , 12 , 16 },
+{ 40 , 20 , 12 , 17 },
+{ 40 , 20 , 12 , 18 },
+{ 40 , 20 , 12 , 19 },
+{ 40 , 20 , 13 , 0 },
+{ 40 , 20 , 13 , 1 },
+{ 40 , 20 , 13 , 2 },
+{ 40 , 20 , 13 , 3 },
+{ 40 , 20 , 13 , 4 },
+{ 40 , 20 , 13 , 5 },
+{ 40 , 20 , 13 , 6 },
+{ 40 , 20 , 13 , 7 },
+{ 40 , 20 , 13 , 8 },
+{ 40 , 20 , 13 , 9 },
+{ 40 , 20 , 13 , 10 },
+{ 40 , 20 , 13 , 11 },
+{ 40 , 20 , 13 , 12 },
+{ 40 , 20 , 13 , 13 },
+{ 40 , 20 , 13 , 14 },
+{ 40 , 20 , 13 , 15 },
+{ 40 , 20 , 13 , 16 },
+{ 40 , 20 , 13 , 17 },
+{ 40 , 20 , 13 , 18 },
+{ 40 , 20 , 13 , 19 },
+{ 40 , 20 , 14 , 0 },
+{ 40 , 20 , 14 , 1 },
+{ 40 , 20 , 14 , 2 },
+{ 40 , 20 , 14 , 3 },
+{ 40 , 20 , 14 , 4 },
+{ 40 , 20 , 14 , 5 },
+{ 40 , 20 , 14 , 6 },
+{ 40 , 20 , 14 , 7 },
+{ 40 , 20 , 14 , 8 },
+{ 40 , 20 , 14 , 9 },
+{ 40 , 20 , 14 , 10 },
+{ 40 , 20 , 14 , 11 },
+{ 40 , 20 , 14 , 12 },
+{ 40 , 20 , 14 , 13 },
+{ 40 , 20 , 14 , 14 },
+{ 40 , 20 , 14 , 15 },
+{ 40 , 20 , 14 , 16 },
+{ 40 , 20 , 14 , 17 },
+{ 40 , 20 , 14 , 18 },
+{ 40 , 20 , 14 , 19 },
+{ 40 , 20 , 15 , 0 },
+{ 40 , 20 , 15 , 1 },
+{ 40 , 20 , 15 , 2 },
+{ 40 , 20 , 15 , 3 },
+{ 40 , 20 , 15 , 4 },
+{ 40 , 20 , 15 , 5 },
+{ 40 , 20 , 15 , 6 },
+{ 40 , 20 , 15 , 7 },
+{ 40 , 20 , 15 , 8 },
+{ 40 , 20 , 15 , 9 },
+{ 40 , 20 , 15 , 10 },
+{ 40 , 20 , 15 , 11 },
+{ 40 , 20 , 15 , 12 },
+{ 40 , 20 , 15 , 13 },
+{ 40 , 20 , 15 , 14 },
+{ 40 , 20 , 15 , 15 },
+{ 40 , 20 , 15 , 16 },
+{ 40 , 20 , 15 , 17 },
+{ 40 , 20 , 15 , 18 },
+{ 40 , 20 , 15 , 19 },
+{ 40 , 20 , 16 , 0 },
+{ 40 , 20 , 16 , 1 },
+{ 40 , 20 , 16 , 2 },
+{ 40 , 20 , 16 , 3 },
+{ 40 , 20 , 16 , 4 },
+{ 40 , 20 , 16 , 5 },
+{ 40 , 20 , 16 , 6 },
+{ 40 , 20 , 16 , 7 },
+{ 40 , 20 , 16 , 8 },
+{ 40 , 20 , 16 , 9 },
+{ 40 , 20 , 16 , 10 },
+{ 40 , 20 , 16 , 11 },
+{ 40 , 20 , 16 , 12 },
+{ 40 , 20 , 16 , 13 },
+{ 40 , 20 , 16 , 14 },
+{ 40 , 20 , 16 , 15 },
+{ 40 , 20 , 16 , 16 },
+{ 40 , 20 , 16 , 17 },
+{ 40 , 20 , 16 , 18 },
+{ 40 , 20 , 16 , 19 },
+{ 40 , 20 , 17 , 0 },
+{ 40 , 20 , 17 , 1 },
+{ 40 , 20 , 17 , 2 },
+{ 40 , 20 , 17 , 3 },
+{ 40 , 20 , 17 , 4 },
+{ 40 , 20 , 17 , 5 },
+{ 40 , 20 , 17 , 6 },
+{ 40 , 20 , 17 , 7 },
+{ 40 , 20 , 17 , 8 },
+{ 40 , 20 , 17 , 9 },
+{ 40 , 20 , 17 , 10 },
+{ 40 , 20 , 17 , 11 },
+{ 40 , 20 , 17 , 12 },
+{ 40 , 20 , 17 , 13 },
+{ 40 , 20 , 17 , 14 },
+{ 40 , 20 , 17 , 15 },
+{ 40 , 20 , 17 , 16 },
+{ 40 , 20 , 17 , 17 },
+{ 40 , 20 , 17 , 18 },
+{ 40 , 20 , 17 , 19 },
+{ 40 , 20 , 18 , 0 },
+{ 40 , 20 , 18 , 1 },
+{ 40 , 20 , 18 , 2 },
+{ 40 , 20 , 18 , 3 },
+{ 40 , 20 , 18 , 4 },
+{ 40 , 20 , 18 , 5 },
+{ 40 , 20 , 18 , 6 },
+{ 40 , 20 , 18 , 7 },
+{ 40 , 20 , 18 , 8 },
+{ 40 , 20 , 18 , 9 },
+{ 40 , 20 , 18 , 10 },
+{ 40 , 20 , 18 , 11 },
+{ 40 , 20 , 18 , 12 },
+{ 40 , 20 , 18 , 13 },
+{ 40 , 20 , 18 , 14 },
+{ 40 , 20 , 18 , 15 },
+{ 40 , 20 , 18 , 16 },
+{ 40 , 20 , 18 , 17 },
+{ 40 , 20 , 18 , 18 },
+{ 40 , 20 , 18 , 19 },
+{ 40 , 20 , 19 , 0 },
+{ 40 , 20 , 19 , 1 },
+{ 40 , 20 , 19 , 2 },
+{ 40 , 20 , 19 , 3 },
+{ 40 , 20 , 19 , 4 },
+{ 40 , 20 , 19 , 5 },
+{ 40 , 20 , 19 , 6 },
+{ 40 , 20 , 19 , 7 },
+{ 40 , 20 , 19 , 8 },
+{ 40 , 20 , 19 , 9 },
+{ 40 , 20 , 19 , 10 },
+{ 40 , 20 , 19 , 11 },
+{ 40 , 20 , 19 , 12 },
+{ 40 , 20 , 19 , 13 },
+{ 40 , 20 , 19 , 14 },
+{ 40 , 20 , 19 , 15 },
+{ 40 , 20 , 19 , 16 },
+{ 40 , 20 , 19 , 17 },
+{ 40 , 20 , 19 , 18 },
+{ 40 , 20 , 19 , 19 },
+{ 40 , 20 , 20 , 0 },
+{ 40 , 20 , 20 , 1 },
+{ 40 , 20 , 20 , 2 },
+{ 40 , 20 , 20 , 3 },
+{ 40 , 20 , 20 , 4 },
+{ 40 , 20 , 20 , 5 },
+{ 40 , 20 , 20 , 6 },
+{ 40 , 20 , 20 , 7 },
+{ 40 , 20 , 20 , 8 },
+{ 40 , 20 , 20 , 9 },
+{ 40 , 20 , 20 , 10 },
+{ 40 , 20 , 20 , 11 },
+{ 40 , 20 , 20 , 12 },
+{ 40 , 20 , 20 , 13 },
+{ 40 , 20 , 20 , 14 },
+{ 40 , 20 , 20 , 15 },
+{ 40 , 20 , 20 , 16 },
+{ 40 , 20 , 20 , 17 },
+{ 40 , 20 , 20 , 18 },
+{ 40 , 20 , 20 , 19 },
+{ 40 , 20 , 21 , 0 },
+{ 40 , 20 , 21 , 1 },
+{ 40 , 20 , 21 , 2 },
+{ 40 , 20 , 21 , 3 },
+{ 40 , 20 , 21 , 4 },
+{ 40 , 20 , 21 , 5 },
+{ 40 , 20 , 21 , 6 },
+{ 40 , 20 , 21 , 7 },
+{ 40 , 20 , 21 , 8 },
+{ 40 , 20 , 21 , 9 },
+{ 40 , 20 , 21 , 10 },
+{ 40 , 20 , 21 , 11 },
+{ 40 , 20 , 21 , 12 },
+{ 40 , 20 , 21 , 13 },
+{ 40 , 20 , 21 , 14 },
+{ 40 , 20 , 21 , 15 },
+{ 40 , 20 , 21 , 16 },
+{ 40 , 20 , 21 , 17 },
+{ 40 , 20 , 21 , 18 },
+{ 40 , 20 , 21 , 19 },
+{ 40 , 20 , 22 , 0 },
+{ 40 , 20 , 22 , 1 },
+{ 40 , 20 , 22 , 2 },
+{ 40 , 20 , 22 , 3 },
+{ 40 , 20 , 22 , 4 },
+{ 40 , 20 , 22 , 5 },
+{ 40 , 20 , 22 , 6 },
+{ 40 , 20 , 22 , 7 },
+{ 40 , 20 , 22 , 8 },
+{ 40 , 20 , 22 , 9 },
+{ 40 , 20 , 22 , 10 },
+{ 40 , 20 , 22 , 11 },
+{ 40 , 20 , 22 , 12 },
+{ 40 , 20 , 22 , 13 },
+{ 40 , 20 , 22 , 14 },
+{ 40 , 20 , 22 , 15 },
+{ 40 , 20 , 22 , 16 },
+{ 40 , 20 , 22 , 17 },
+{ 40 , 20 , 22 , 18 },
+{ 40 , 20 , 22 , 19 },
+{ 40 , 20 , 23 , 0 },
+{ 40 , 20 , 23 , 1 },
+{ 40 , 20 , 23 , 2 },
+{ 40 , 20 , 23 , 3 },
+{ 40 , 20 , 23 , 4 },
+{ 40 , 20 , 23 , 5 },
+{ 40 , 20 , 23 , 6 },
+{ 40 , 20 , 23 , 7 },
+{ 40 , 20 , 23 , 8 },
+{ 40 , 20 , 23 , 9 },
+{ 40 , 20 , 23 , 10 },
+{ 40 , 20 , 23 , 11 },
+{ 40 , 20 , 23 , 12 },
+{ 40 , 20 , 23 , 13 },
+{ 40 , 20 , 23 , 14 },
+{ 40 , 20 , 23 , 15 },
+{ 40 , 20 , 23 , 16 },
+{ 40 , 20 , 23 , 17 },
+{ 40 , 20 , 23 , 18 },
+{ 40 , 20 , 23 , 19 },
+{ 40 , 20 , 24 , 0 },
+{ 40 , 20 , 24 , 1 },
+{ 40 , 20 , 24 , 2 },
+{ 40 , 20 , 24 , 3 },
+{ 40 , 20 , 24 , 4 },
+{ 40 , 20 , 24 , 5 },
+{ 40 , 20 , 24 , 6 },
+{ 40 , 20 , 24 , 7 },
+{ 40 , 20 , 24 , 8 },
+{ 40 , 20 , 24 , 9 },
+{ 40 , 20 , 24 , 10 },
+{ 40 , 20 , 24 , 11 },
+{ 40 , 20 , 24 , 12 },
+{ 40 , 20 , 24 , 13 },
+{ 40 , 20 , 24 , 14 },
+{ 40 , 20 , 24 , 15 },
+{ 40 , 20 , 24 , 16 },
+{ 40 , 20 , 24 , 17 },
+{ 40 , 20 , 24 , 18 },
+{ 40 , 20 , 24 , 19 },
+{ 40 , 20 , 25 , 0 },
+{ 40 , 20 , 25 , 1 },
+{ 40 , 20 , 25 , 2 },
+{ 40 , 20 , 25 , 3 },
+{ 40 , 20 , 25 , 4 },
+{ 40 , 20 , 25 , 5 },
+{ 40 , 20 , 25 , 6 },
+{ 40 , 20 , 25 , 7 },
+{ 40 , 20 , 25 , 8 },
+{ 40 , 20 , 25 , 9 },
+{ 40 , 20 , 25 , 10 },
+{ 40 , 20 , 25 , 11 },
+{ 40 , 20 , 25 , 12 },
+{ 40 , 20 , 25 , 13 },
+{ 40 , 20 , 25 , 14 },
+{ 40 , 20 , 25 , 15 },
+{ 40 , 20 , 25 , 16 },
+{ 40 , 20 , 25 , 17 },
+{ 40 , 20 , 25 , 18 },
+{ 40 , 20 , 25 , 19 },
+{ 40 , 20 , 26 , 0 },
+{ 40 , 20 , 26 , 1 },
+{ 40 , 20 , 26 , 2 },
+{ 40 , 20 , 26 , 3 },
+{ 40 , 20 , 26 , 4 },
+{ 40 , 20 , 26 , 5 },
+{ 40 , 20 , 26 , 6 },
+{ 40 , 20 , 26 , 7 },
+{ 40 , 20 , 26 , 8 },
+{ 40 , 20 , 26 , 9 },
+{ 40 , 20 , 26 , 10 },
+{ 40 , 20 , 26 , 11 },
+{ 40 , 20 , 26 , 12 },
+{ 40 , 20 , 26 , 13 },
+{ 40 , 20 , 26 , 14 },
+{ 40 , 20 , 26 , 15 },
+{ 40 , 20 , 26 , 16 },
+{ 40 , 20 , 26 , 17 },
+{ 40 , 20 , 26 , 18 },
+{ 40 , 20 , 26 , 19 },
+{ 40 , 20 , 27 , 0 },
+{ 40 , 20 , 27 , 1 },
+{ 40 , 20 , 27 , 2 },
+{ 40 , 20 , 27 , 3 },
+{ 40 , 20 , 27 , 4 },
+{ 40 , 20 , 27 , 5 },
+{ 40 , 20 , 27 , 6 },
+{ 40 , 20 , 27 , 7 },
+{ 40 , 20 , 27 , 8 },
+{ 40 , 20 , 27 , 9 },
+{ 40 , 20 , 27 , 10 },
+{ 40 , 20 , 27 , 11 },
+{ 40 , 20 , 27 , 12 },
+{ 40 , 20 , 27 , 13 },
+{ 40 , 20 , 27 , 14 },
+{ 40 , 20 , 27 , 15 },
+{ 40 , 20 , 27 , 16 },
+{ 40 , 20 , 27 , 17 },
+{ 40 , 20 , 27 , 18 },
+{ 40 , 20 , 27 , 19 },
+{ 40 , 20 , 28 , 0 },
+{ 40 , 20 , 28 , 1 },
+{ 40 , 20 , 28 , 2 },
+{ 40 , 20 , 28 , 3 },
+{ 40 , 20 , 28 , 4 },
+{ 40 , 20 , 28 , 5 },
+{ 40 , 20 , 28 , 6 },
+{ 40 , 20 , 28 , 7 },
+{ 40 , 20 , 28 , 8 },
+{ 40 , 20 , 28 , 9 },
+{ 40 , 20 , 28 , 10 },
+{ 40 , 20 , 28 , 11 },
+{ 40 , 20 , 28 , 12 },
+{ 40 , 20 , 28 , 13 },
+{ 40 , 20 , 28 , 14 },
+{ 40 , 20 , 28 , 15 },
+{ 40 , 20 , 28 , 16 },
+{ 40 , 20 , 28 , 17 },
+{ 40 , 20 , 28 , 18 },
+{ 40 , 20 , 28 , 19 },
+{ 40 , 20 , 29 , 0 },
+{ 40 , 20 , 29 , 1 },
+{ 40 , 20 , 29 , 2 },
+{ 40 , 20 , 29 , 3 },
+{ 40 , 20 , 29 , 4 },
+{ 40 , 20 , 29 , 5 },
+{ 40 , 20 , 29 , 6 },
+{ 40 , 20 , 29 , 7 },
+{ 40 , 20 , 29 , 8 },
+{ 40 , 20 , 29 , 9 },
+{ 40 , 20 , 29 , 10 },
+{ 40 , 20 , 29 , 11 },
+{ 40 , 20 , 29 , 12 },
+{ 40 , 20 , 29 , 13 },
+{ 40 , 20 , 29 , 14 },
+{ 40 , 20 , 29 , 15 },
+{ 40 , 20 , 29 , 16 },
+{ 40 , 20 , 29 , 17 },
+{ 40 , 20 , 29 , 18 },
+{ 40 , 20 , 29 , 19 },
+{ 40 , 20 , 30 , 0 },
+{ 40 , 20 , 30 , 1 },
+{ 40 , 20 , 30 , 2 },
+{ 40 , 20 , 30 , 3 },
+{ 40 , 20 , 30 , 4 },
+{ 40 , 20 , 30 , 5 },
+{ 40 , 20 , 30 , 6 },
+{ 40 , 20 , 30 , 7 },
+{ 40 , 20 , 30 , 8 },
+{ 40 , 20 , 30 , 9 },
+{ 40 , 20 , 30 , 10 },
+{ 40 , 20 , 30 , 11 },
+{ 40 , 20 , 30 , 12 },
+{ 40 , 20 , 30 , 13 },
+{ 40 , 20 , 30 , 14 },
+{ 40 , 20 , 30 , 15 },
+{ 40 , 20 , 30 , 16 },
+{ 40 , 20 , 30 , 17 },
+{ 40 , 20 , 30 , 18 },
+{ 40 , 20 , 30 , 19 },
+{ 40 , 20 , 31 , 0 },
+{ 40 , 20 , 31 , 1 },
+{ 40 , 20 , 31 , 2 },
+{ 40 , 20 , 31 , 3 },
+{ 40 , 20 , 31 , 4 },
+{ 40 , 20 , 31 , 5 },
+{ 40 , 20 , 31 , 6 },
+{ 40 , 20 , 31 , 7 },
+{ 40 , 20 , 31 , 8 },
+{ 40 , 20 , 31 , 9 },
+{ 40 , 20 , 31 , 10 },
+{ 40 , 20 , 31 , 11 },
+{ 40 , 20 , 31 , 12 },
+{ 40 , 20 , 31 , 13 },
+{ 40 , 20 , 31 , 14 },
+{ 40 , 20 , 31 , 15 },
+{ 40 , 20 , 31 , 16 },
+{ 40 , 20 , 31 , 17 },
+{ 40 , 20 , 31 , 18 },
+{ 40 , 20 , 31 , 19 },
+{ 40 , 20 , 32 , 0 },
+{ 40 , 20 , 32 , 1 },
+{ 40 , 20 , 32 , 2 },
+{ 40 , 20 , 32 , 3 },
+{ 40 , 20 , 32 , 4 },
+{ 40 , 20 , 32 , 5 },
+{ 40 , 20 , 32 , 6 },
+{ 40 , 20 , 32 , 7 },
+{ 40 , 20 , 32 , 8 },
+{ 40 , 20 , 32 , 9 },
+{ 40 , 20 , 32 , 10 },
+{ 40 , 20 , 32 , 11 },
+{ 40 , 20 , 32 , 12 },
+{ 40 , 20 , 32 , 13 },
+{ 40 , 20 , 32 , 14 },
+{ 40 , 20 , 32 , 15 },
+{ 40 , 20 , 32 , 16 },
+{ 40 , 20 , 32 , 17 },
+{ 40 , 20 , 32 , 18 },
+{ 40 , 20 , 32 , 19 },
+{ 40 , 20 , 33 , 0 },
+{ 40 , 20 , 33 , 1 },
+{ 40 , 20 , 33 , 2 },
+{ 40 , 20 , 33 , 3 },
+{ 40 , 20 , 33 , 4 },
+{ 40 , 20 , 33 , 5 },
+{ 40 , 20 , 33 , 6 },
+{ 40 , 20 , 33 , 7 },
+{ 40 , 20 , 33 , 8 },
+{ 40 , 20 , 33 , 9 },
+{ 40 , 20 , 33 , 10 },
+{ 40 , 20 , 33 , 11 },
+{ 40 , 20 , 33 , 12 },
+{ 40 , 20 , 33 , 13 },
+{ 40 , 20 , 33 , 14 },
+{ 40 , 20 , 33 , 15 },
+{ 40 , 20 , 33 , 16 },
+{ 40 , 20 , 33 , 17 },
+{ 40 , 20 , 33 , 18 },
+{ 40 , 20 , 33 , 19 },
+{ 40 , 20 , 34 , 0 },
+{ 40 , 20 , 34 , 1 },
+{ 40 , 20 , 34 , 2 },
+{ 40 , 20 , 34 , 3 },
+{ 40 , 20 , 34 , 4 },
+{ 40 , 20 , 34 , 5 },
+{ 40 , 20 , 34 , 6 },
+{ 40 , 20 , 34 , 7 },
+{ 40 , 20 , 34 , 8 },
+{ 40 , 20 , 34 , 9 },
+{ 40 , 20 , 34 , 10 },
+{ 40 , 20 , 34 , 11 },
+{ 40 , 20 , 34 , 12 },
+{ 40 , 20 , 34 , 13 },
+{ 40 , 20 , 34 , 14 },
+{ 40 , 20 , 34 , 15 },
+{ 40 , 20 , 34 , 16 },
+{ 40 , 20 , 34 , 17 },
+{ 40 , 20 , 34 , 18 },
+{ 40 , 20 , 34 , 19 },
+{ 40 , 20 , 35 , 0 },
+{ 40 , 20 , 35 , 1 },
+{ 40 , 20 , 35 , 2 },
+{ 40 , 20 , 35 , 3 },
+{ 40 , 20 , 35 , 4 },
+{ 40 , 20 , 35 , 5 },
+{ 40 , 20 , 35 , 6 },
+{ 40 , 20 , 35 , 7 },
+{ 40 , 20 , 35 , 8 },
+{ 40 , 20 , 35 , 9 },
+{ 40 , 20 , 35 , 10 },
+{ 40 , 20 , 35 , 11 },
+{ 40 , 20 , 35 , 12 },
+{ 40 , 20 , 35 , 13 },
+{ 40 , 20 , 35 , 14 },
+{ 40 , 20 , 35 , 15 },
+{ 40 , 20 , 35 , 16 },
+{ 40 , 20 , 35 , 17 },
+{ 40 , 20 , 35 , 18 },
+{ 40 , 20 , 35 , 19 },
+{ 40 , 20 , 36 , 0 },
+{ 40 , 20 , 36 , 1 },
+{ 40 , 20 , 36 , 2 },
+{ 40 , 20 , 36 , 3 },
+{ 40 , 20 , 36 , 4 },
+{ 40 , 20 , 36 , 5 },
+{ 40 , 20 , 36 , 6 },
+{ 40 , 20 , 36 , 7 },
+{ 40 , 20 , 36 , 8 },
+{ 40 , 20 , 36 , 9 },
+{ 40 , 20 , 36 , 10 },
+{ 40 , 20 , 36 , 11 },
+{ 40 , 20 , 36 , 12 },
+{ 40 , 20 , 36 , 13 },
+{ 40 , 20 , 36 , 14 },
+{ 40 , 20 , 36 , 15 },
+{ 40 , 20 , 36 , 16 },
+{ 40 , 20 , 36 , 17 },
+{ 40 , 20 , 36 , 18 },
+{ 40 , 20 , 36 , 19 },
+{ 40 , 20 , 37 , 0 },
+{ 40 , 20 , 37 , 1 },
+{ 40 , 20 , 37 , 2 },
+{ 40 , 20 , 37 , 3 },
+{ 40 , 20 , 37 , 4 },
+{ 40 , 20 , 37 , 5 },
+{ 40 , 20 , 37 , 6 },
+{ 40 , 20 , 37 , 7 },
+{ 40 , 20 , 37 , 8 },
+{ 40 , 20 , 37 , 9 },
+{ 40 , 20 , 37 , 10 },
+{ 40 , 20 , 37 , 11 },
+{ 40 , 20 , 37 , 12 },
+{ 40 , 20 , 37 , 13 },
+{ 40 , 20 , 37 , 14 },
+{ 40 , 20 , 37 , 15 },
+{ 40 , 20 , 37 , 16 },
+{ 40 , 20 , 37 , 17 },
+{ 40 , 20 , 37 , 18 },
+{ 40 , 20 , 37 , 19 },
+{ 40 , 20 , 38 , 0 },
+{ 40 , 20 , 38 , 1 },
+{ 40 , 20 , 38 , 2 },
+{ 40 , 20 , 38 , 3 },
+{ 40 , 20 , 38 , 4 },
+{ 40 , 20 , 38 , 5 },
+{ 40 , 20 , 38 , 6 },
+{ 40 , 20 , 38 , 7 },
+{ 40 , 20 , 38 , 8 },
+{ 40 , 20 , 38 , 9 },
+{ 40 , 20 , 38 , 10 },
+{ 40 , 20 , 38 , 11 },
+{ 40 , 20 , 38 , 12 },
+{ 40 , 20 , 38 , 13 },
+{ 40 , 20 , 38 , 14 },
+{ 40 , 20 , 38 , 15 },
+{ 40 , 20 , 38 , 16 },
+{ 40 , 20 , 38 , 17 },
+{ 40 , 20 , 38 , 18 },
+{ 40 , 20 , 38 , 19 },
+{ 40 , 20 , 39 , 0 },
+{ 40 , 20 , 39 , 1 },
+{ 40 , 20 , 39 , 2 },
+{ 40 , 20 , 39 , 3 },
+{ 40 , 20 , 39 , 4 },
+{ 40 , 20 , 39 , 5 },
+{ 40 , 20 , 39 , 6 },
+{ 40 , 20 , 39 , 7 },
+{ 40 , 20 , 39 , 8 },
+{ 40 , 20 , 39 , 9 },
+{ 40 , 20 , 39 , 10 },
+{ 40 , 20 , 39 , 11 },
+{ 40 , 20 , 39 , 12 },
+{ 40 , 20 , 39 , 13 },
+{ 40 , 20 , 39 , 14 },
+{ 40 , 20 , 39 , 15 },
+{ 40 , 20 , 39 , 16 },
+{ 40 , 20 , 39 , 17 },
+{ 40 , 20 , 39 , 18 },
+{ 40 , 20 , 39 , 19 },
+{ 40 , 40 , 0 , 0 },
+{ 40 , 40 , 0 , 1 },
+{ 40 , 40 , 0 , 2 },
+{ 40 , 40 , 0 , 3 },
+{ 40 , 40 , 0 , 4 },
+{ 40 , 40 , 0 , 5 },
+{ 40 , 40 , 0 , 6 },
+{ 40 , 40 , 0 , 7 },
+{ 40 , 40 , 0 , 8 },
+{ 40 , 40 , 0 , 9 },
+{ 40 , 40 , 0 , 10 },
+{ 40 , 40 , 0 , 11 },
+{ 40 , 40 , 0 , 12 },
+{ 40 , 40 , 0 , 13 },
+{ 40 , 40 , 0 , 14 },
+{ 40 , 40 , 0 , 15 },
+{ 40 , 40 , 0 , 16 },
+{ 40 , 40 , 0 , 17 },
+{ 40 , 40 , 0 , 18 },
+{ 40 , 40 , 0 , 19 },
+{ 40 , 40 , 0 , 20 },
+{ 40 , 40 , 0 , 21 },
+{ 40 , 40 , 0 , 22 },
+{ 40 , 40 , 0 , 23 },
+{ 40 , 40 , 0 , 24 },
+{ 40 , 40 , 0 , 25 },
+{ 40 , 40 , 0 , 26 },
+{ 40 , 40 , 0 , 27 },
+{ 40 , 40 , 0 , 28 },
+{ 40 , 40 , 0 , 29 },
+{ 40 , 40 , 0 , 30 },
+{ 40 , 40 , 0 , 31 },
+{ 40 , 40 , 0 , 32 },
+{ 40 , 40 , 0 , 33 },
+{ 40 , 40 , 0 , 34 },
+{ 40 , 40 , 0 , 35 },
+{ 40 , 40 , 0 , 36 },
+{ 40 , 40 , 0 , 37 },
+{ 40 , 40 , 0 , 38 },
+{ 40 , 40 , 0 , 39 },
+{ 40 , 40 , 1 , 0 },
+{ 40 , 40 , 1 , 1 },
+{ 40 , 40 , 1 , 2 },
+{ 40 , 40 , 1 , 3 },
+{ 40 , 40 , 1 , 4 },
+{ 40 , 40 , 1 , 5 },
+{ 40 , 40 , 1 , 6 },
+{ 40 , 40 , 1 , 7 },
+{ 40 , 40 , 1 , 8 },
+{ 40 , 40 , 1 , 9 },
+{ 40 , 40 , 1 , 10 },
+{ 40 , 40 , 1 , 11 },
+{ 40 , 40 , 1 , 12 },
+{ 40 , 40 , 1 , 13 },
+{ 40 , 40 , 1 , 14 },
+{ 40 , 40 , 1 , 15 },
+{ 40 , 40 , 1 , 16 },
+{ 40 , 40 , 1 , 17 },
+{ 40 , 40 , 1 , 18 },
+{ 40 , 40 , 1 , 19 },
+{ 40 , 40 , 1 , 20 },
+{ 40 , 40 , 1 , 21 },
+{ 40 , 40 , 1 , 22 },
+{ 40 , 40 , 1 , 23 },
+{ 40 , 40 , 1 , 24 },
+{ 40 , 40 , 1 , 25 },
+{ 40 , 40 , 1 , 26 },
+{ 40 , 40 , 1 , 27 },
+{ 40 , 40 , 1 , 28 },
+{ 40 , 40 , 1 , 29 },
+{ 40 , 40 , 1 , 30 },
+{ 40 , 40 , 1 , 31 },
+{ 40 , 40 , 1 , 32 },
+{ 40 , 40 , 1 , 33 },
+{ 40 , 40 , 1 , 34 },
+{ 40 , 40 , 1 , 35 },
+{ 40 , 40 , 1 , 36 },
+{ 40 , 40 , 1 , 37 },
+{ 40 , 40 , 1 , 38 },
+{ 40 , 40 , 1 , 39 },
+{ 40 , 40 , 2 , 0 },
+{ 40 , 40 , 2 , 1 },
+{ 40 , 40 , 2 , 2 },
+{ 40 , 40 , 2 , 3 },
+{ 40 , 40 , 2 , 4 },
+{ 40 , 40 , 2 , 5 },
+{ 40 , 40 , 2 , 6 },
+{ 40 , 40 , 2 , 7 },
+{ 40 , 40 , 2 , 8 },
+{ 40 , 40 , 2 , 9 },
+{ 40 , 40 , 2 , 10 },
+{ 40 , 40 , 2 , 11 },
+{ 40 , 40 , 2 , 12 },
+{ 40 , 40 , 2 , 13 },
+{ 40 , 40 , 2 , 14 },
+{ 40 , 40 , 2 , 15 },
+{ 40 , 40 , 2 , 16 },
+{ 40 , 40 , 2 , 17 },
+{ 40 , 40 , 2 , 18 },
+{ 40 , 40 , 2 , 19 },
+{ 40 , 40 , 2 , 20 },
+{ 40 , 40 , 2 , 21 },
+{ 40 , 40 , 2 , 22 },
+{ 40 , 40 , 2 , 23 },
+{ 40 , 40 , 2 , 24 },
+{ 40 , 40 , 2 , 25 },
+{ 40 , 40 , 2 , 26 },
+{ 40 , 40 , 2 , 27 },
+{ 40 , 40 , 2 , 28 },
+{ 40 , 40 , 2 , 29 },
+{ 40 , 40 , 2 , 30 },
+{ 40 , 40 , 2 , 31 },
+{ 40 , 40 , 2 , 32 },
+{ 40 , 40 , 2 , 33 },
+{ 40 , 40 , 2 , 34 },
+{ 40 , 40 , 2 , 35 },
+{ 40 , 40 , 2 , 36 },
+{ 40 , 40 , 2 , 37 },
+{ 40 , 40 , 2 , 38 },
+{ 40 , 40 , 2 , 39 },
+{ 40 , 40 , 3 , 0 },
+{ 40 , 40 , 3 , 1 },
+{ 40 , 40 , 3 , 2 },
+{ 40 , 40 , 3 , 3 },
+{ 40 , 40 , 3 , 4 },
+{ 40 , 40 , 3 , 5 },
+{ 40 , 40 , 3 , 6 },
+{ 40 , 40 , 3 , 7 },
+{ 40 , 40 , 3 , 8 },
+{ 40 , 40 , 3 , 9 },
+{ 40 , 40 , 3 , 10 },
+{ 40 , 40 , 3 , 11 },
+{ 40 , 40 , 3 , 12 },
+{ 40 , 40 , 3 , 13 },
+{ 40 , 40 , 3 , 14 },
+{ 40 , 40 , 3 , 15 },
+{ 40 , 40 , 3 , 16 },
+{ 40 , 40 , 3 , 17 },
+{ 40 , 40 , 3 , 18 },
+{ 40 , 40 , 3 , 19 },
+{ 40 , 40 , 3 , 20 },
+{ 40 , 40 , 3 , 21 },
+{ 40 , 40 , 3 , 22 },
+{ 40 , 40 , 3 , 23 },
+{ 40 , 40 , 3 , 24 },
+{ 40 , 40 , 3 , 25 },
+{ 40 , 40 , 3 , 26 },
+{ 40 , 40 , 3 , 27 },
+{ 40 , 40 , 3 , 28 },
+{ 40 , 40 , 3 , 29 },
+{ 40 , 40 , 3 , 30 },
+{ 40 , 40 , 3 , 31 },
+{ 40 , 40 , 3 , 32 },
+{ 40 , 40 , 3 , 33 },
+{ 40 , 40 , 3 , 34 },
+{ 40 , 40 , 3 , 35 },
+{ 40 , 40 , 3 , 36 },
+{ 40 , 40 , 3 , 37 },
+{ 40 , 40 , 3 , 38 },
+{ 40 , 40 , 3 , 39 },
+{ 40 , 40 , 4 , 0 },
+{ 40 , 40 , 4 , 1 },
+{ 40 , 40 , 4 , 2 },
+{ 40 , 40 , 4 , 3 },
+{ 40 , 40 , 4 , 4 },
+{ 40 , 40 , 4 , 5 },
+{ 40 , 40 , 4 , 6 },
+{ 40 , 40 , 4 , 7 },
+{ 40 , 40 , 4 , 8 },
+{ 40 , 40 , 4 , 9 },
+{ 40 , 40 , 4 , 10 },
+{ 40 , 40 , 4 , 11 },
+{ 40 , 40 , 4 , 12 },
+{ 40 , 40 , 4 , 13 },
+{ 40 , 40 , 4 , 14 },
+{ 40 , 40 , 4 , 15 },
+{ 40 , 40 , 4 , 16 },
+{ 40 , 40 , 4 , 17 },
+{ 40 , 40 , 4 , 18 },
+{ 40 , 40 , 4 , 19 },
+{ 40 , 40 , 4 , 20 },
+{ 40 , 40 , 4 , 21 },
+{ 40 , 40 , 4 , 22 },
+{ 40 , 40 , 4 , 23 },
+{ 40 , 40 , 4 , 24 },
+{ 40 , 40 , 4 , 25 },
+{ 40 , 40 , 4 , 26 },
+{ 40 , 40 , 4 , 27 },
+{ 40 , 40 , 4 , 28 },
+{ 40 , 40 , 4 , 29 },
+{ 40 , 40 , 4 , 30 },
+{ 40 , 40 , 4 , 31 },
+{ 40 , 40 , 4 , 32 },
+{ 40 , 40 , 4 , 33 },
+{ 40 , 40 , 4 , 34 },
+{ 40 , 40 , 4 , 35 },
+{ 40 , 40 , 4 , 36 },
+{ 40 , 40 , 4 , 37 },
+{ 40 , 40 , 4 , 38 },
+{ 40 , 40 , 4 , 39 },
+{ 40 , 40 , 5 , 0 },
+{ 40 , 40 , 5 , 1 },
+{ 40 , 40 , 5 , 2 },
+{ 40 , 40 , 5 , 3 },
+{ 40 , 40 , 5 , 4 },
+{ 40 , 40 , 5 , 5 },
+{ 40 , 40 , 5 , 6 },
+{ 40 , 40 , 5 , 7 },
+{ 40 , 40 , 5 , 8 },
+{ 40 , 40 , 5 , 9 },
+{ 40 , 40 , 5 , 10 },
+{ 40 , 40 , 5 , 11 },
+{ 40 , 40 , 5 , 12 },
+{ 40 , 40 , 5 , 13 },
+{ 40 , 40 , 5 , 14 },
+{ 40 , 40 , 5 , 15 },
+{ 40 , 40 , 5 , 16 },
+{ 40 , 40 , 5 , 17 },
+{ 40 , 40 , 5 , 18 },
+{ 40 , 40 , 5 , 19 },
+{ 40 , 40 , 5 , 20 },
+{ 40 , 40 , 5 , 21 },
+{ 40 , 40 , 5 , 22 },
+{ 40 , 40 , 5 , 23 },
+{ 40 , 40 , 5 , 24 },
+{ 40 , 40 , 5 , 25 },
+{ 40 , 40 , 5 , 26 },
+{ 40 , 40 , 5 , 27 },
+{ 40 , 40 , 5 , 28 },
+{ 40 , 40 , 5 , 29 },
+{ 40 , 40 , 5 , 30 },
+{ 40 , 40 , 5 , 31 },
+{ 40 , 40 , 5 , 32 },
+{ 40 , 40 , 5 , 33 },
+{ 40 , 40 , 5 , 34 },
+{ 40 , 40 , 5 , 35 },
+{ 40 , 40 , 5 , 36 },
+{ 40 , 40 , 5 , 37 },
+{ 40 , 40 , 5 , 38 },
+{ 40 , 40 , 5 , 39 },
+{ 40 , 40 , 6 , 0 },
+{ 40 , 40 , 6 , 1 },
+{ 40 , 40 , 6 , 2 },
+{ 40 , 40 , 6 , 3 },
+{ 40 , 40 , 6 , 4 },
+{ 40 , 40 , 6 , 5 },
+{ 40 , 40 , 6 , 6 },
+{ 40 , 40 , 6 , 7 },
+{ 40 , 40 , 6 , 8 },
+{ 40 , 40 , 6 , 9 },
+{ 40 , 40 , 6 , 10 },
+{ 40 , 40 , 6 , 11 },
+{ 40 , 40 , 6 , 12 },
+{ 40 , 40 , 6 , 13 },
+{ 40 , 40 , 6 , 14 },
+{ 40 , 40 , 6 , 15 },
+{ 40 , 40 , 6 , 16 },
+{ 40 , 40 , 6 , 17 },
+{ 40 , 40 , 6 , 18 },
+{ 40 , 40 , 6 , 19 },
+{ 40 , 40 , 6 , 20 },
+{ 40 , 40 , 6 , 21 },
+{ 40 , 40 , 6 , 22 },
+{ 40 , 40 , 6 , 23 },
+{ 40 , 40 , 6 , 24 },
+{ 40 , 40 , 6 , 25 },
+{ 40 , 40 , 6 , 26 },
+{ 40 , 40 , 6 , 27 },
+{ 40 , 40 , 6 , 28 },
+{ 40 , 40 , 6 , 29 },
+{ 40 , 40 , 6 , 30 },
+{ 40 , 40 , 6 , 31 },
+{ 40 , 40 , 6 , 32 },
+{ 40 , 40 , 6 , 33 },
+{ 40 , 40 , 6 , 34 },
+{ 40 , 40 , 6 , 35 },
+{ 40 , 40 , 6 , 36 },
+{ 40 , 40 , 6 , 37 },
+{ 40 , 40 , 6 , 38 },
+{ 40 , 40 , 6 , 39 },
+{ 40 , 40 , 7 , 0 },
+{ 40 , 40 , 7 , 1 },
+{ 40 , 40 , 7 , 2 },
+{ 40 , 40 , 7 , 3 },
+{ 40 , 40 , 7 , 4 },
+{ 40 , 40 , 7 , 5 },
+{ 40 , 40 , 7 , 6 },
+{ 40 , 40 , 7 , 7 },
+{ 40 , 40 , 7 , 8 },
+{ 40 , 40 , 7 , 9 },
+{ 40 , 40 , 7 , 10 },
+{ 40 , 40 , 7 , 11 },
+{ 40 , 40 , 7 , 12 },
+{ 40 , 40 , 7 , 13 },
+{ 40 , 40 , 7 , 14 },
+{ 40 , 40 , 7 , 15 },
+{ 40 , 40 , 7 , 16 },
+{ 40 , 40 , 7 , 17 },
+{ 40 , 40 , 7 , 18 },
+{ 40 , 40 , 7 , 19 },
+{ 40 , 40 , 7 , 20 },
+{ 40 , 40 , 7 , 21 },
+{ 40 , 40 , 7 , 22 },
+{ 40 , 40 , 7 , 23 },
+{ 40 , 40 , 7 , 24 },
+{ 40 , 40 , 7 , 25 },
+{ 40 , 40 , 7 , 26 },
+{ 40 , 40 , 7 , 27 },
+{ 40 , 40 , 7 , 28 },
+{ 40 , 40 , 7 , 29 },
+{ 40 , 40 , 7 , 30 },
+{ 40 , 40 , 7 , 31 },
+{ 40 , 40 , 7 , 32 },
+{ 40 , 40 , 7 , 33 },
+{ 40 , 40 , 7 , 34 },
+{ 40 , 40 , 7 , 35 },
+{ 40 , 40 , 7 , 36 },
+{ 40 , 40 , 7 , 37 },
+{ 40 , 40 , 7 , 38 },
+{ 40 , 40 , 7 , 39 },
+{ 40 , 40 , 8 , 0 },
+{ 40 , 40 , 8 , 1 },
+{ 40 , 40 , 8 , 2 },
+{ 40 , 40 , 8 , 3 },
+{ 40 , 40 , 8 , 4 },
+{ 40 , 40 , 8 , 5 },
+{ 40 , 40 , 8 , 6 },
+{ 40 , 40 , 8 , 7 },
+{ 40 , 40 , 8 , 8 },
+{ 40 , 40 , 8 , 9 },
+{ 40 , 40 , 8 , 10 },
+{ 40 , 40 , 8 , 11 },
+{ 40 , 40 , 8 , 12 },
+{ 40 , 40 , 8 , 13 },
+{ 40 , 40 , 8 , 14 },
+{ 40 , 40 , 8 , 15 },
+{ 40 , 40 , 8 , 16 },
+{ 40 , 40 , 8 , 17 },
+{ 40 , 40 , 8 , 18 },
+{ 40 , 40 , 8 , 19 },
+{ 40 , 40 , 8 , 20 },
+{ 40 , 40 , 8 , 21 },
+{ 40 , 40 , 8 , 22 },
+{ 40 , 40 , 8 , 23 },
+{ 40 , 40 , 8 , 24 },
+{ 40 , 40 , 8 , 25 },
+{ 40 , 40 , 8 , 26 },
+{ 40 , 40 , 8 , 27 },
+{ 40 , 40 , 8 , 28 },
+{ 40 , 40 , 8 , 29 },
+{ 40 , 40 , 8 , 30 },
+{ 40 , 40 , 8 , 31 },
+{ 40 , 40 , 8 , 32 },
+{ 40 , 40 , 8 , 33 },
+{ 40 , 40 , 8 , 34 },
+{ 40 , 40 , 8 , 35 },
+{ 40 , 40 , 8 , 36 },
+{ 40 , 40 , 8 , 37 },
+{ 40 , 40 , 8 , 38 },
+{ 40 , 40 , 8 , 39 },
+{ 40 , 40 , 9 , 0 },
+{ 40 , 40 , 9 , 1 },
+{ 40 , 40 , 9 , 2 },
+{ 40 , 40 , 9 , 3 },
+{ 40 , 40 , 9 , 4 },
+{ 40 , 40 , 9 , 5 },
+{ 40 , 40 , 9 , 6 },
+{ 40 , 40 , 9 , 7 },
+{ 40 , 40 , 9 , 8 },
+{ 40 , 40 , 9 , 9 },
+{ 40 , 40 , 9 , 10 },
+{ 40 , 40 , 9 , 11 },
+{ 40 , 40 , 9 , 12 },
+{ 40 , 40 , 9 , 13 },
+{ 40 , 40 , 9 , 14 },
+{ 40 , 40 , 9 , 15 },
+{ 40 , 40 , 9 , 16 },
+{ 40 , 40 , 9 , 17 },
+{ 40 , 40 , 9 , 18 },
+{ 40 , 40 , 9 , 19 },
+{ 40 , 40 , 9 , 20 },
+{ 40 , 40 , 9 , 21 },
+{ 40 , 40 , 9 , 22 },
+{ 40 , 40 , 9 , 23 },
+{ 40 , 40 , 9 , 24 },
+{ 40 , 40 , 9 , 25 },
+{ 40 , 40 , 9 , 26 },
+{ 40 , 40 , 9 , 27 },
+{ 40 , 40 , 9 , 28 },
+{ 40 , 40 , 9 , 29 },
+{ 40 , 40 , 9 , 30 },
+{ 40 , 40 , 9 , 31 },
+{ 40 , 40 , 9 , 32 },
+{ 40 , 40 , 9 , 33 },
+{ 40 , 40 , 9 , 34 },
+{ 40 , 40 , 9 , 35 },
+{ 40 , 40 , 9 , 36 },
+{ 40 , 40 , 9 , 37 },
+{ 40 , 40 , 9 , 38 },
+{ 40 , 40 , 9 , 39 },
+{ 40 , 40 , 10 , 0 },
+{ 40 , 40 , 10 , 1 },
+{ 40 , 40 , 10 , 2 },
+{ 40 , 40 , 10 , 3 },
+{ 40 , 40 , 10 , 4 },
+{ 40 , 40 , 10 , 5 },
+{ 40 , 40 , 10 , 6 },
+{ 40 , 40 , 10 , 7 },
+{ 40 , 40 , 10 , 8 },
+{ 40 , 40 , 10 , 9 },
+{ 40 , 40 , 10 , 10 },
+{ 40 , 40 , 10 , 11 },
+{ 40 , 40 , 10 , 12 },
+{ 40 , 40 , 10 , 13 },
+{ 40 , 40 , 10 , 14 },
+{ 40 , 40 , 10 , 15 },
+{ 40 , 40 , 10 , 16 },
+{ 40 , 40 , 10 , 17 },
+{ 40 , 40 , 10 , 18 },
+{ 40 , 40 , 10 , 19 },
+{ 40 , 40 , 10 , 20 },
+{ 40 , 40 , 10 , 21 },
+{ 40 , 40 , 10 , 22 },
+{ 40 , 40 , 10 , 23 },
+{ 40 , 40 , 10 , 24 },
+{ 40 , 40 , 10 , 25 },
+{ 40 , 40 , 10 , 26 },
+{ 40 , 40 , 10 , 27 },
+{ 40 , 40 , 10 , 28 },
+{ 40 , 40 , 10 , 29 },
+{ 40 , 40 , 10 , 30 },
+{ 40 , 40 , 10 , 31 },
+{ 40 , 40 , 10 , 32 },
+{ 40 , 40 , 10 , 33 },
+{ 40 , 40 , 10 , 34 },
+{ 40 , 40 , 10 , 35 },
+{ 40 , 40 , 10 , 36 },
+{ 40 , 40 , 10 , 37 },
+{ 40 , 40 , 10 , 38 },
+{ 40 , 40 , 10 , 39 },
+{ 40 , 40 , 11 , 0 },
+{ 40 , 40 , 11 , 1 },
+{ 40 , 40 , 11 , 2 },
+{ 40 , 40 , 11 , 3 },
+{ 40 , 40 , 11 , 4 },
+{ 40 , 40 , 11 , 5 },
+{ 40 , 40 , 11 , 6 },
+{ 40 , 40 , 11 , 7 },
+{ 40 , 40 , 11 , 8 },
+{ 40 , 40 , 11 , 9 },
+{ 40 , 40 , 11 , 10 },
+{ 40 , 40 , 11 , 11 },
+{ 40 , 40 , 11 , 12 },
+{ 40 , 40 , 11 , 13 },
+{ 40 , 40 , 11 , 14 },
+{ 40 , 40 , 11 , 15 },
+{ 40 , 40 , 11 , 16 },
+{ 40 , 40 , 11 , 17 },
+{ 40 , 40 , 11 , 18 },
+{ 40 , 40 , 11 , 19 },
+{ 40 , 40 , 11 , 20 },
+{ 40 , 40 , 11 , 21 },
+{ 40 , 40 , 11 , 22 },
+{ 40 , 40 , 11 , 23 },
+{ 40 , 40 , 11 , 24 },
+{ 40 , 40 , 11 , 25 },
+{ 40 , 40 , 11 , 26 },
+{ 40 , 40 , 11 , 27 },
+{ 40 , 40 , 11 , 28 },
+{ 40 , 40 , 11 , 29 },
+{ 40 , 40 , 11 , 30 },
+{ 40 , 40 , 11 , 31 },
+{ 40 , 40 , 11 , 32 },
+{ 40 , 40 , 11 , 33 },
+{ 40 , 40 , 11 , 34 },
+{ 40 , 40 , 11 , 35 },
+{ 40 , 40 , 11 , 36 },
+{ 40 , 40 , 11 , 37 },
+{ 40 , 40 , 11 , 38 },
+{ 40 , 40 , 11 , 39 },
+{ 40 , 40 , 12 , 0 },
+{ 40 , 40 , 12 , 1 },
+{ 40 , 40 , 12 , 2 },
+{ 40 , 40 , 12 , 3 },
+{ 40 , 40 , 12 , 4 },
+{ 40 , 40 , 12 , 5 },
+{ 40 , 40 , 12 , 6 },
+{ 40 , 40 , 12 , 7 },
+{ 40 , 40 , 12 , 8 },
+{ 40 , 40 , 12 , 9 },
+{ 40 , 40 , 12 , 10 },
+{ 40 , 40 , 12 , 11 },
+{ 40 , 40 , 12 , 12 },
+{ 40 , 40 , 12 , 13 },
+{ 40 , 40 , 12 , 14 },
+{ 40 , 40 , 12 , 15 },
+{ 40 , 40 , 12 , 16 },
+{ 40 , 40 , 12 , 17 },
+{ 40 , 40 , 12 , 18 },
+{ 40 , 40 , 12 , 19 },
+{ 40 , 40 , 12 , 20 },
+{ 40 , 40 , 12 , 21 },
+{ 40 , 40 , 12 , 22 },
+{ 40 , 40 , 12 , 23 },
+{ 40 , 40 , 12 , 24 },
+{ 40 , 40 , 12 , 25 },
+{ 40 , 40 , 12 , 26 },
+{ 40 , 40 , 12 , 27 },
+{ 40 , 40 , 12 , 28 },
+{ 40 , 40 , 12 , 29 },
+{ 40 , 40 , 12 , 30 },
+{ 40 , 40 , 12 , 31 },
+{ 40 , 40 , 12 , 32 },
+{ 40 , 40 , 12 , 33 },
+{ 40 , 40 , 12 , 34 },
+{ 40 , 40 , 12 , 35 },
+{ 40 , 40 , 12 , 36 },
+{ 40 , 40 , 12 , 37 },
+{ 40 , 40 , 12 , 38 },
+{ 40 , 40 , 12 , 39 },
+{ 40 , 40 , 13 , 0 },
+{ 40 , 40 , 13 , 1 },
+{ 40 , 40 , 13 , 2 },
+{ 40 , 40 , 13 , 3 },
+{ 40 , 40 , 13 , 4 },
+{ 40 , 40 , 13 , 5 },
+{ 40 , 40 , 13 , 6 },
+{ 40 , 40 , 13 , 7 },
+{ 40 , 40 , 13 , 8 },
+{ 40 , 40 , 13 , 9 },
+{ 40 , 40 , 13 , 10 },
+{ 40 , 40 , 13 , 11 },
+{ 40 , 40 , 13 , 12 },
+{ 40 , 40 , 13 , 13 },
+{ 40 , 40 , 13 , 14 },
+{ 40 , 40 , 13 , 15 },
+{ 40 , 40 , 13 , 16 },
+{ 40 , 40 , 13 , 17 },
+{ 40 , 40 , 13 , 18 },
+{ 40 , 40 , 13 , 19 },
+{ 40 , 40 , 13 , 20 },
+{ 40 , 40 , 13 , 21 },
+{ 40 , 40 , 13 , 22 },
+{ 40 , 40 , 13 , 23 },
+{ 40 , 40 , 13 , 24 },
+{ 40 , 40 , 13 , 25 },
+{ 40 , 40 , 13 , 26 },
+{ 40 , 40 , 13 , 27 },
+{ 40 , 40 , 13 , 28 },
+{ 40 , 40 , 13 , 29 },
+{ 40 , 40 , 13 , 30 },
+{ 40 , 40 , 13 , 31 },
+{ 40 , 40 , 13 , 32 },
+{ 40 , 40 , 13 , 33 },
+{ 40 , 40 , 13 , 34 },
+{ 40 , 40 , 13 , 35 },
+{ 40 , 40 , 13 , 36 },
+{ 40 , 40 , 13 , 37 },
+{ 40 , 40 , 13 , 38 },
+{ 40 , 40 , 13 , 39 },
+{ 40 , 40 , 14 , 0 },
+{ 40 , 40 , 14 , 1 },
+{ 40 , 40 , 14 , 2 },
+{ 40 , 40 , 14 , 3 },
+{ 40 , 40 , 14 , 4 },
+{ 40 , 40 , 14 , 5 },
+{ 40 , 40 , 14 , 6 },
+{ 40 , 40 , 14 , 7 },
+{ 40 , 40 , 14 , 8 },
+{ 40 , 40 , 14 , 9 },
+{ 40 , 40 , 14 , 10 },
+{ 40 , 40 , 14 , 11 },
+{ 40 , 40 , 14 , 12 },
+{ 40 , 40 , 14 , 13 },
+{ 40 , 40 , 14 , 14 },
+{ 40 , 40 , 14 , 15 },
+{ 40 , 40 , 14 , 16 },
+{ 40 , 40 , 14 , 17 },
+{ 40 , 40 , 14 , 18 },
+{ 40 , 40 , 14 , 19 },
+{ 40 , 40 , 14 , 20 },
+{ 40 , 40 , 14 , 21 },
+{ 40 , 40 , 14 , 22 },
+{ 40 , 40 , 14 , 23 },
+{ 40 , 40 , 14 , 24 },
+{ 40 , 40 , 14 , 25 },
+{ 40 , 40 , 14 , 26 },
+{ 40 , 40 , 14 , 27 },
+{ 40 , 40 , 14 , 28 },
+{ 40 , 40 , 14 , 29 },
+{ 40 , 40 , 14 , 30 },
+{ 40 , 40 , 14 , 31 },
+{ 40 , 40 , 14 , 32 },
+{ 40 , 40 , 14 , 33 },
+{ 40 , 40 , 14 , 34 },
+{ 40 , 40 , 14 , 35 },
+{ 40 , 40 , 14 , 36 },
+{ 40 , 40 , 14 , 37 },
+{ 40 , 40 , 14 , 38 },
+{ 40 , 40 , 14 , 39 },
+{ 40 , 40 , 15 , 0 },
+{ 40 , 40 , 15 , 1 },
+{ 40 , 40 , 15 , 2 },
+{ 40 , 40 , 15 , 3 },
+{ 40 , 40 , 15 , 4 },
+{ 40 , 40 , 15 , 5 },
+{ 40 , 40 , 15 , 6 },
+{ 40 , 40 , 15 , 7 },
+{ 40 , 40 , 15 , 8 },
+{ 40 , 40 , 15 , 9 },
+{ 40 , 40 , 15 , 10 },
+{ 40 , 40 , 15 , 11 },
+{ 40 , 40 , 15 , 12 },
+{ 40 , 40 , 15 , 13 },
+{ 40 , 40 , 15 , 14 },
+{ 40 , 40 , 15 , 15 },
+{ 40 , 40 , 15 , 16 },
+{ 40 , 40 , 15 , 17 },
+{ 40 , 40 , 15 , 18 },
+{ 40 , 40 , 15 , 19 },
+{ 40 , 40 , 15 , 20 },
+{ 40 , 40 , 15 , 21 },
+{ 40 , 40 , 15 , 22 },
+{ 40 , 40 , 15 , 23 },
+{ 40 , 40 , 15 , 24 },
+{ 40 , 40 , 15 , 25 },
+{ 40 , 40 , 15 , 26 },
+{ 40 , 40 , 15 , 27 },
+{ 40 , 40 , 15 , 28 },
+{ 40 , 40 , 15 , 29 },
+{ 40 , 40 , 15 , 30 },
+{ 40 , 40 , 15 , 31 },
+{ 40 , 40 , 15 , 32 },
+{ 40 , 40 , 15 , 33 },
+{ 40 , 40 , 15 , 34 },
+{ 40 , 40 , 15 , 35 },
+{ 40 , 40 , 15 , 36 },
+{ 40 , 40 , 15 , 37 },
+{ 40 , 40 , 15 , 38 },
+{ 40 , 40 , 15 , 39 },
+{ 40 , 40 , 16 , 0 },
+{ 40 , 40 , 16 , 1 },
+{ 40 , 40 , 16 , 2 },
+{ 40 , 40 , 16 , 3 },
+{ 40 , 40 , 16 , 4 },
+{ 40 , 40 , 16 , 5 },
+{ 40 , 40 , 16 , 6 },
+{ 40 , 40 , 16 , 7 },
+{ 40 , 40 , 16 , 8 },
+{ 40 , 40 , 16 , 9 },
+{ 40 , 40 , 16 , 10 },
+{ 40 , 40 , 16 , 11 },
+{ 40 , 40 , 16 , 12 },
+{ 40 , 40 , 16 , 13 },
+{ 40 , 40 , 16 , 14 },
+{ 40 , 40 , 16 , 15 },
+{ 40 , 40 , 16 , 16 },
+{ 40 , 40 , 16 , 17 },
+{ 40 , 40 , 16 , 18 },
+{ 40 , 40 , 16 , 19 },
+{ 40 , 40 , 16 , 20 },
+{ 40 , 40 , 16 , 21 },
+{ 40 , 40 , 16 , 22 },
+{ 40 , 40 , 16 , 23 },
+{ 40 , 40 , 16 , 24 },
+{ 40 , 40 , 16 , 25 },
+{ 40 , 40 , 16 , 26 },
+{ 40 , 40 , 16 , 27 },
+{ 40 , 40 , 16 , 28 },
+{ 40 , 40 , 16 , 29 },
+{ 40 , 40 , 16 , 30 },
+{ 40 , 40 , 16 , 31 },
+{ 40 , 40 , 16 , 32 },
+{ 40 , 40 , 16 , 33 },
+{ 40 , 40 , 16 , 34 },
+{ 40 , 40 , 16 , 35 },
+{ 40 , 40 , 16 , 36 },
+{ 40 , 40 , 16 , 37 },
+{ 40 , 40 , 16 , 38 },
+{ 40 , 40 , 16 , 39 },
+{ 40 , 40 , 17 , 0 },
+{ 40 , 40 , 17 , 1 },
+{ 40 , 40 , 17 , 2 },
+{ 40 , 40 , 17 , 3 },
+{ 40 , 40 , 17 , 4 },
+{ 40 , 40 , 17 , 5 },
+{ 40 , 40 , 17 , 6 },
+{ 40 , 40 , 17 , 7 },
+{ 40 , 40 , 17 , 8 },
+{ 40 , 40 , 17 , 9 },
+{ 40 , 40 , 17 , 10 },
+{ 40 , 40 , 17 , 11 },
+{ 40 , 40 , 17 , 12 },
+{ 40 , 40 , 17 , 13 },
+{ 40 , 40 , 17 , 14 },
+{ 40 , 40 , 17 , 15 },
+{ 40 , 40 , 17 , 16 },
+{ 40 , 40 , 17 , 17 },
+{ 40 , 40 , 17 , 18 },
+{ 40 , 40 , 17 , 19 },
+{ 40 , 40 , 17 , 20 },
+{ 40 , 40 , 17 , 21 },
+{ 40 , 40 , 17 , 22 },
+{ 40 , 40 , 17 , 23 },
+{ 40 , 40 , 17 , 24 },
+{ 40 , 40 , 17 , 25 },
+{ 40 , 40 , 17 , 26 },
+{ 40 , 40 , 17 , 27 },
+{ 40 , 40 , 17 , 28 },
+{ 40 , 40 , 17 , 29 },
+{ 40 , 40 , 17 , 30 },
+{ 40 , 40 , 17 , 31 },
+{ 40 , 40 , 17 , 32 },
+{ 40 , 40 , 17 , 33 },
+{ 40 , 40 , 17 , 34 },
+{ 40 , 40 , 17 , 35 },
+{ 40 , 40 , 17 , 36 },
+{ 40 , 40 , 17 , 37 },
+{ 40 , 40 , 17 , 38 },
+{ 40 , 40 , 17 , 39 },
+{ 40 , 40 , 18 , 0 },
+{ 40 , 40 , 18 , 1 },
+{ 40 , 40 , 18 , 2 },
+{ 40 , 40 , 18 , 3 },
+{ 40 , 40 , 18 , 4 },
+{ 40 , 40 , 18 , 5 },
+{ 40 , 40 , 18 , 6 },
+{ 40 , 40 , 18 , 7 },
+{ 40 , 40 , 18 , 8 },
+{ 40 , 40 , 18 , 9 },
+{ 40 , 40 , 18 , 10 },
+{ 40 , 40 , 18 , 11 },
+{ 40 , 40 , 18 , 12 },
+{ 40 , 40 , 18 , 13 },
+{ 40 , 40 , 18 , 14 },
+{ 40 , 40 , 18 , 15 },
+{ 40 , 40 , 18 , 16 },
+{ 40 , 40 , 18 , 17 },
+{ 40 , 40 , 18 , 18 },
+{ 40 , 40 , 18 , 19 },
+{ 40 , 40 , 18 , 20 },
+{ 40 , 40 , 18 , 21 },
+{ 40 , 40 , 18 , 22 },
+{ 40 , 40 , 18 , 23 },
+{ 40 , 40 , 18 , 24 },
+{ 40 , 40 , 18 , 25 },
+{ 40 , 40 , 18 , 26 },
+{ 40 , 40 , 18 , 27 },
+{ 40 , 40 , 18 , 28 },
+{ 40 , 40 , 18 , 29 },
+{ 40 , 40 , 18 , 30 },
+{ 40 , 40 , 18 , 31 },
+{ 40 , 40 , 18 , 32 },
+{ 40 , 40 , 18 , 33 },
+{ 40 , 40 , 18 , 34 },
+{ 40 , 40 , 18 , 35 },
+{ 40 , 40 , 18 , 36 },
+{ 40 , 40 , 18 , 37 },
+{ 40 , 40 , 18 , 38 },
+{ 40 , 40 , 18 , 39 },
+{ 40 , 40 , 19 , 0 },
+{ 40 , 40 , 19 , 1 },
+{ 40 , 40 , 19 , 2 },
+{ 40 , 40 , 19 , 3 },
+{ 40 , 40 , 19 , 4 },
+{ 40 , 40 , 19 , 5 },
+{ 40 , 40 , 19 , 6 },
+{ 40 , 40 , 19 , 7 },
+{ 40 , 40 , 19 , 8 },
+{ 40 , 40 , 19 , 9 },
+{ 40 , 40 , 19 , 10 },
+{ 40 , 40 , 19 , 11 },
+{ 40 , 40 , 19 , 12 },
+{ 40 , 40 , 19 , 13 },
+{ 40 , 40 , 19 , 14 },
+{ 40 , 40 , 19 , 15 },
+{ 40 , 40 , 19 , 16 },
+{ 40 , 40 , 19 , 17 },
+{ 40 , 40 , 19 , 18 },
+{ 40 , 40 , 19 , 19 },
+{ 40 , 40 , 19 , 20 },
+{ 40 , 40 , 19 , 21 },
+{ 40 , 40 , 19 , 22 },
+{ 40 , 40 , 19 , 23 },
+{ 40 , 40 , 19 , 24 },
+{ 40 , 40 , 19 , 25 },
+{ 40 , 40 , 19 , 26 },
+{ 40 , 40 , 19 , 27 },
+{ 40 , 40 , 19 , 28 },
+{ 40 , 40 , 19 , 29 },
+{ 40 , 40 , 19 , 30 },
+{ 40 , 40 , 19 , 31 },
+{ 40 , 40 , 19 , 32 },
+{ 40 , 40 , 19 , 33 },
+{ 40 , 40 , 19 , 34 },
+{ 40 , 40 , 19 , 35 },
+{ 40 , 40 , 19 , 36 },
+{ 40 , 40 , 19 , 37 },
+{ 40 , 40 , 19 , 38 },
+{ 40 , 40 , 19 , 39 },
+{ 40 , 40 , 20 , 0 },
+{ 40 , 40 , 20 , 1 },
+{ 40 , 40 , 20 , 2 },
+{ 40 , 40 , 20 , 3 },
+{ 40 , 40 , 20 , 4 },
+{ 40 , 40 , 20 , 5 },
+{ 40 , 40 , 20 , 6 },
+{ 40 , 40 , 20 , 7 },
+{ 40 , 40 , 20 , 8 },
+{ 40 , 40 , 20 , 9 },
+{ 40 , 40 , 20 , 10 },
+{ 40 , 40 , 20 , 11 },
+{ 40 , 40 , 20 , 12 },
+{ 40 , 40 , 20 , 13 },
+{ 40 , 40 , 20 , 14 },
+{ 40 , 40 , 20 , 15 },
+{ 40 , 40 , 20 , 16 },
+{ 40 , 40 , 20 , 17 },
+{ 40 , 40 , 20 , 18 },
+{ 40 , 40 , 20 , 19 },
+{ 40 , 40 , 20 , 20 },
+{ 40 , 40 , 20 , 21 },
+{ 40 , 40 , 20 , 22 },
+{ 40 , 40 , 20 , 23 },
+{ 40 , 40 , 20 , 24 },
+{ 40 , 40 , 20 , 25 },
+{ 40 , 40 , 20 , 26 },
+{ 40 , 40 , 20 , 27 },
+{ 40 , 40 , 20 , 28 },
+{ 40 , 40 , 20 , 29 },
+{ 40 , 40 , 20 , 30 },
+{ 40 , 40 , 20 , 31 },
+{ 40 , 40 , 20 , 32 },
+{ 40 , 40 , 20 , 33 },
+{ 40 , 40 , 20 , 34 },
+{ 40 , 40 , 20 , 35 },
+{ 40 , 40 , 20 , 36 },
+{ 40 , 40 , 20 , 37 },
+{ 40 , 40 , 20 , 38 },
+{ 40 , 40 , 20 , 39 },
+{ 40 , 40 , 21 , 0 },
+{ 40 , 40 , 21 , 1 },
+{ 40 , 40 , 21 , 2 },
+{ 40 , 40 , 21 , 3 },
+{ 40 , 40 , 21 , 4 },
+{ 40 , 40 , 21 , 5 },
+{ 40 , 40 , 21 , 6 },
+{ 40 , 40 , 21 , 7 },
+{ 40 , 40 , 21 , 8 },
+{ 40 , 40 , 21 , 9 },
+{ 40 , 40 , 21 , 10 },
+{ 40 , 40 , 21 , 11 },
+{ 40 , 40 , 21 , 12 },
+{ 40 , 40 , 21 , 13 },
+{ 40 , 40 , 21 , 14 },
+{ 40 , 40 , 21 , 15 },
+{ 40 , 40 , 21 , 16 },
+{ 40 , 40 , 21 , 17 },
+{ 40 , 40 , 21 , 18 },
+{ 40 , 40 , 21 , 19 },
+{ 40 , 40 , 21 , 20 },
+{ 40 , 40 , 21 , 21 },
+{ 40 , 40 , 21 , 22 },
+{ 40 , 40 , 21 , 23 },
+{ 40 , 40 , 21 , 24 },
+{ 40 , 40 , 21 , 25 },
+{ 40 , 40 , 21 , 26 },
+{ 40 , 40 , 21 , 27 },
+{ 40 , 40 , 21 , 28 },
+{ 40 , 40 , 21 , 29 },
+{ 40 , 40 , 21 , 30 },
+{ 40 , 40 , 21 , 31 },
+{ 40 , 40 , 21 , 32 },
+{ 40 , 40 , 21 , 33 },
+{ 40 , 40 , 21 , 34 },
+{ 40 , 40 , 21 , 35 },
+{ 40 , 40 , 21 , 36 },
+{ 40 , 40 , 21 , 37 },
+{ 40 , 40 , 21 , 38 },
+{ 40 , 40 , 21 , 39 },
+{ 40 , 40 , 22 , 0 },
+{ 40 , 40 , 22 , 1 },
+{ 40 , 40 , 22 , 2 },
+{ 40 , 40 , 22 , 3 },
+{ 40 , 40 , 22 , 4 },
+{ 40 , 40 , 22 , 5 },
+{ 40 , 40 , 22 , 6 },
+{ 40 , 40 , 22 , 7 },
+{ 40 , 40 , 22 , 8 },
+{ 40 , 40 , 22 , 9 },
+{ 40 , 40 , 22 , 10 },
+{ 40 , 40 , 22 , 11 },
+{ 40 , 40 , 22 , 12 },
+{ 40 , 40 , 22 , 13 },
+{ 40 , 40 , 22 , 14 },
+{ 40 , 40 , 22 , 15 },
+{ 40 , 40 , 22 , 16 },
+{ 40 , 40 , 22 , 17 },
+{ 40 , 40 , 22 , 18 },
+{ 40 , 40 , 22 , 19 },
+{ 40 , 40 , 22 , 20 },
+{ 40 , 40 , 22 , 21 },
+{ 40 , 40 , 22 , 22 },
+{ 40 , 40 , 22 , 23 },
+{ 40 , 40 , 22 , 24 },
+{ 40 , 40 , 22 , 25 },
+{ 40 , 40 , 22 , 26 },
+{ 40 , 40 , 22 , 27 },
+{ 40 , 40 , 22 , 28 },
+{ 40 , 40 , 22 , 29 },
+{ 40 , 40 , 22 , 30 },
+{ 40 , 40 , 22 , 31 },
+{ 40 , 40 , 22 , 32 },
+{ 40 , 40 , 22 , 33 },
+{ 40 , 40 , 22 , 34 },
+{ 40 , 40 , 22 , 35 },
+{ 40 , 40 , 22 , 36 },
+{ 40 , 40 , 22 , 37 },
+{ 40 , 40 , 22 , 38 },
+{ 40 , 40 , 22 , 39 },
+{ 40 , 40 , 23 , 0 },
+{ 40 , 40 , 23 , 1 },
+{ 40 , 40 , 23 , 2 },
+{ 40 , 40 , 23 , 3 },
+{ 40 , 40 , 23 , 4 },
+{ 40 , 40 , 23 , 5 },
+{ 40 , 40 , 23 , 6 },
+{ 40 , 40 , 23 , 7 },
+{ 40 , 40 , 23 , 8 },
+{ 40 , 40 , 23 , 9 },
+{ 40 , 40 , 23 , 10 },
+{ 40 , 40 , 23 , 11 },
+{ 40 , 40 , 23 , 12 },
+{ 40 , 40 , 23 , 13 },
+{ 40 , 40 , 23 , 14 },
+{ 40 , 40 , 23 , 15 },
+{ 40 , 40 , 23 , 16 },
+{ 40 , 40 , 23 , 17 },
+{ 40 , 40 , 23 , 18 },
+{ 40 , 40 , 23 , 19 },
+{ 40 , 40 , 23 , 20 },
+{ 40 , 40 , 23 , 21 },
+{ 40 , 40 , 23 , 22 },
+{ 40 , 40 , 23 , 23 },
+{ 40 , 40 , 23 , 24 },
+{ 40 , 40 , 23 , 25 },
+{ 40 , 40 , 23 , 26 },
+{ 40 , 40 , 23 , 27 },
+{ 40 , 40 , 23 , 28 },
+{ 40 , 40 , 23 , 29 },
+{ 40 , 40 , 23 , 30 },
+{ 40 , 40 , 23 , 31 },
+{ 40 , 40 , 23 , 32 },
+{ 40 , 40 , 23 , 33 },
+{ 40 , 40 , 23 , 34 },
+{ 40 , 40 , 23 , 35 },
+{ 40 , 40 , 23 , 36 },
+{ 40 , 40 , 23 , 37 },
+{ 40 , 40 , 23 , 38 },
+{ 40 , 40 , 23 , 39 },
+{ 40 , 40 , 24 , 0 },
+{ 40 , 40 , 24 , 1 },
+{ 40 , 40 , 24 , 2 },
+{ 40 , 40 , 24 , 3 },
+{ 40 , 40 , 24 , 4 },
+{ 40 , 40 , 24 , 5 },
+{ 40 , 40 , 24 , 6 },
+{ 40 , 40 , 24 , 7 },
+{ 40 , 40 , 24 , 8 },
+{ 40 , 40 , 24 , 9 },
+{ 40 , 40 , 24 , 10 },
+{ 40 , 40 , 24 , 11 },
+{ 40 , 40 , 24 , 12 },
+{ 40 , 40 , 24 , 13 },
+{ 40 , 40 , 24 , 14 },
+{ 40 , 40 , 24 , 15 },
+{ 40 , 40 , 24 , 16 },
+{ 40 , 40 , 24 , 17 },
+{ 40 , 40 , 24 , 18 },
+{ 40 , 40 , 24 , 19 },
+{ 40 , 40 , 24 , 20 },
+{ 40 , 40 , 24 , 21 },
+{ 40 , 40 , 24 , 22 },
+{ 40 , 40 , 24 , 23 },
+{ 40 , 40 , 24 , 24 },
+{ 40 , 40 , 24 , 25 },
+{ 40 , 40 , 24 , 26 },
+{ 40 , 40 , 24 , 27 },
+{ 40 , 40 , 24 , 28 },
+{ 40 , 40 , 24 , 29 },
+{ 40 , 40 , 24 , 30 },
+{ 40 , 40 , 24 , 31 },
+{ 40 , 40 , 24 , 32 },
+{ 40 , 40 , 24 , 33 },
+{ 40 , 40 , 24 , 34 },
+{ 40 , 40 , 24 , 35 },
+{ 40 , 40 , 24 , 36 },
+{ 40 , 40 , 24 , 37 },
+{ 40 , 40 , 24 , 38 },
+{ 40 , 40 , 24 , 39 },
+{ 40 , 40 , 25 , 0 },
+{ 40 , 40 , 25 , 1 },
+{ 40 , 40 , 25 , 2 },
+{ 40 , 40 , 25 , 3 },
+{ 40 , 40 , 25 , 4 },
+{ 40 , 40 , 25 , 5 },
+{ 40 , 40 , 25 , 6 },
+{ 40 , 40 , 25 , 7 },
+{ 40 , 40 , 25 , 8 },
+{ 40 , 40 , 25 , 9 },
+{ 40 , 40 , 25 , 10 },
+{ 40 , 40 , 25 , 11 },
+{ 40 , 40 , 25 , 12 },
+{ 40 , 40 , 25 , 13 },
+{ 40 , 40 , 25 , 14 },
+{ 40 , 40 , 25 , 15 },
+{ 40 , 40 , 25 , 16 },
+{ 40 , 40 , 25 , 17 },
+{ 40 , 40 , 25 , 18 },
+{ 40 , 40 , 25 , 19 },
+{ 40 , 40 , 25 , 20 },
+{ 40 , 40 , 25 , 21 },
+{ 40 , 40 , 25 , 22 },
+{ 40 , 40 , 25 , 23 },
+{ 40 , 40 , 25 , 24 },
+{ 40 , 40 , 25 , 25 },
+{ 40 , 40 , 25 , 26 },
+{ 40 , 40 , 25 , 27 },
+{ 40 , 40 , 25 , 28 },
+{ 40 , 40 , 25 , 29 },
+{ 40 , 40 , 25 , 30 },
+{ 40 , 40 , 25 , 31 },
+{ 40 , 40 , 25 , 32 },
+{ 40 , 40 , 25 , 33 },
+{ 40 , 40 , 25 , 34 },
+{ 40 , 40 , 25 , 35 },
+{ 40 , 40 , 25 , 36 },
+{ 40 , 40 , 25 , 37 },
+{ 40 , 40 , 25 , 38 },
+{ 40 , 40 , 25 , 39 },
+{ 40 , 40 , 26 , 0 },
+{ 40 , 40 , 26 , 1 },
+{ 40 , 40 , 26 , 2 },
+{ 40 , 40 , 26 , 3 },
+{ 40 , 40 , 26 , 4 },
+{ 40 , 40 , 26 , 5 },
+{ 40 , 40 , 26 , 6 },
+{ 40 , 40 , 26 , 7 },
+{ 40 , 40 , 26 , 8 },
+{ 40 , 40 , 26 , 9 },
+{ 40 , 40 , 26 , 10 },
+{ 40 , 40 , 26 , 11 },
+{ 40 , 40 , 26 , 12 },
+{ 40 , 40 , 26 , 13 },
+{ 40 , 40 , 26 , 14 },
+{ 40 , 40 , 26 , 15 },
+{ 40 , 40 , 26 , 16 },
+{ 40 , 40 , 26 , 17 },
+{ 40 , 40 , 26 , 18 },
+{ 40 , 40 , 26 , 19 },
+{ 40 , 40 , 26 , 20 },
+{ 40 , 40 , 26 , 21 },
+{ 40 , 40 , 26 , 22 },
+{ 40 , 40 , 26 , 23 },
+{ 40 , 40 , 26 , 24 },
+{ 40 , 40 , 26 , 25 },
+{ 40 , 40 , 26 , 26 },
+{ 40 , 40 , 26 , 27 },
+{ 40 , 40 , 26 , 28 },
+{ 40 , 40 , 26 , 29 },
+{ 40 , 40 , 26 , 30 },
+{ 40 , 40 , 26 , 31 },
+{ 40 , 40 , 26 , 32 },
+{ 40 , 40 , 26 , 33 },
+{ 40 , 40 , 26 , 34 },
+{ 40 , 40 , 26 , 35 },
+{ 40 , 40 , 26 , 36 },
+{ 40 , 40 , 26 , 37 },
+{ 40 , 40 , 26 , 38 },
+{ 40 , 40 , 26 , 39 },
+{ 40 , 40 , 27 , 0 },
+{ 40 , 40 , 27 , 1 },
+{ 40 , 40 , 27 , 2 },
+{ 40 , 40 , 27 , 3 },
+{ 40 , 40 , 27 , 4 },
+{ 40 , 40 , 27 , 5 },
+{ 40 , 40 , 27 , 6 },
+{ 40 , 40 , 27 , 7 },
+{ 40 , 40 , 27 , 8 },
+{ 40 , 40 , 27 , 9 },
+{ 40 , 40 , 27 , 10 },
+{ 40 , 40 , 27 , 11 },
+{ 40 , 40 , 27 , 12 },
+{ 40 , 40 , 27 , 13 },
+{ 40 , 40 , 27 , 14 },
+{ 40 , 40 , 27 , 15 },
+{ 40 , 40 , 27 , 16 },
+{ 40 , 40 , 27 , 17 },
+{ 40 , 40 , 27 , 18 },
+{ 40 , 40 , 27 , 19 },
+{ 40 , 40 , 27 , 20 },
+{ 40 , 40 , 27 , 21 },
+{ 40 , 40 , 27 , 22 },
+{ 40 , 40 , 27 , 23 },
+{ 40 , 40 , 27 , 24 },
+{ 40 , 40 , 27 , 25 },
+{ 40 , 40 , 27 , 26 },
+{ 40 , 40 , 27 , 27 },
+{ 40 , 40 , 27 , 28 },
+{ 40 , 40 , 27 , 29 },
+{ 40 , 40 , 27 , 30 },
+{ 40 , 40 , 27 , 31 },
+{ 40 , 40 , 27 , 32 },
+{ 40 , 40 , 27 , 33 },
+{ 40 , 40 , 27 , 34 },
+{ 40 , 40 , 27 , 35 },
+{ 40 , 40 , 27 , 36 },
+{ 40 , 40 , 27 , 37 },
+{ 40 , 40 , 27 , 38 },
+{ 40 , 40 , 27 , 39 },
+{ 40 , 40 , 28 , 0 },
+{ 40 , 40 , 28 , 1 },
+{ 40 , 40 , 28 , 2 },
+{ 40 , 40 , 28 , 3 },
+{ 40 , 40 , 28 , 4 },
+{ 40 , 40 , 28 , 5 },
+{ 40 , 40 , 28 , 6 },
+{ 40 , 40 , 28 , 7 },
+{ 40 , 40 , 28 , 8 },
+{ 40 , 40 , 28 , 9 },
+{ 40 , 40 , 28 , 10 },
+{ 40 , 40 , 28 , 11 },
+{ 40 , 40 , 28 , 12 },
+{ 40 , 40 , 28 , 13 },
+{ 40 , 40 , 28 , 14 },
+{ 40 , 40 , 28 , 15 },
+{ 40 , 40 , 28 , 16 },
+{ 40 , 40 , 28 , 17 },
+{ 40 , 40 , 28 , 18 },
+{ 40 , 40 , 28 , 19 },
+{ 40 , 40 , 28 , 20 },
+{ 40 , 40 , 28 , 21 },
+{ 40 , 40 , 28 , 22 },
+{ 40 , 40 , 28 , 23 },
+{ 40 , 40 , 28 , 24 },
+{ 40 , 40 , 28 , 25 },
+{ 40 , 40 , 28 , 26 },
+{ 40 , 40 , 28 , 27 },
+{ 40 , 40 , 28 , 28 },
+{ 40 , 40 , 28 , 29 },
+{ 40 , 40 , 28 , 30 },
+{ 40 , 40 , 28 , 31 },
+{ 40 , 40 , 28 , 32 },
+{ 40 , 40 , 28 , 33 },
+{ 40 , 40 , 28 , 34 },
+{ 40 , 40 , 28 , 35 },
+{ 40 , 40 , 28 , 36 },
+{ 40 , 40 , 28 , 37 },
+{ 40 , 40 , 28 , 38 },
+{ 40 , 40 , 28 , 39 },
+{ 40 , 40 , 29 , 0 },
+{ 40 , 40 , 29 , 1 },
+{ 40 , 40 , 29 , 2 },
+{ 40 , 40 , 29 , 3 },
+{ 40 , 40 , 29 , 4 },
+{ 40 , 40 , 29 , 5 },
+{ 40 , 40 , 29 , 6 },
+{ 40 , 40 , 29 , 7 },
+{ 40 , 40 , 29 , 8 },
+{ 40 , 40 , 29 , 9 },
+{ 40 , 40 , 29 , 10 },
+{ 40 , 40 , 29 , 11 },
+{ 40 , 40 , 29 , 12 },
+{ 40 , 40 , 29 , 13 },
+{ 40 , 40 , 29 , 14 },
+{ 40 , 40 , 29 , 15 },
+{ 40 , 40 , 29 , 16 },
+{ 40 , 40 , 29 , 17 },
+{ 40 , 40 , 29 , 18 },
+{ 40 , 40 , 29 , 19 },
+{ 40 , 40 , 29 , 20 },
+{ 40 , 40 , 29 , 21 },
+{ 40 , 40 , 29 , 22 },
+{ 40 , 40 , 29 , 23 },
+{ 40 , 40 , 29 , 24 },
+{ 40 , 40 , 29 , 25 },
+{ 40 , 40 , 29 , 26 },
+{ 40 , 40 , 29 , 27 },
+{ 40 , 40 , 29 , 28 },
+{ 40 , 40 , 29 , 29 },
+{ 40 , 40 , 29 , 30 },
+{ 40 , 40 , 29 , 31 },
+{ 40 , 40 , 29 , 32 },
+{ 40 , 40 , 29 , 33 },
+{ 40 , 40 , 29 , 34 },
+{ 40 , 40 , 29 , 35 },
+{ 40 , 40 , 29 , 36 },
+{ 40 , 40 , 29 , 37 },
+{ 40 , 40 , 29 , 38 },
+{ 40 , 40 , 29 , 39 },
+{ 40 , 40 , 30 , 0 },
+{ 40 , 40 , 30 , 1 },
+{ 40 , 40 , 30 , 2 },
+{ 40 , 40 , 30 , 3 },
+{ 40 , 40 , 30 , 4 },
+{ 40 , 40 , 30 , 5 },
+{ 40 , 40 , 30 , 6 },
+{ 40 , 40 , 30 , 7 },
+{ 40 , 40 , 30 , 8 },
+{ 40 , 40 , 30 , 9 },
+{ 40 , 40 , 30 , 10 },
+{ 40 , 40 , 30 , 11 },
+{ 40 , 40 , 30 , 12 },
+{ 40 , 40 , 30 , 13 },
+{ 40 , 40 , 30 , 14 },
+{ 40 , 40 , 30 , 15 },
+{ 40 , 40 , 30 , 16 },
+{ 40 , 40 , 30 , 17 },
+{ 40 , 40 , 30 , 18 },
+{ 40 , 40 , 30 , 19 },
+{ 40 , 40 , 30 , 20 },
+{ 40 , 40 , 30 , 21 },
+{ 40 , 40 , 30 , 22 },
+{ 40 , 40 , 30 , 23 },
+{ 40 , 40 , 30 , 24 },
+{ 40 , 40 , 30 , 25 },
+{ 40 , 40 , 30 , 26 },
+{ 40 , 40 , 30 , 27 },
+{ 40 , 40 , 30 , 28 },
+{ 40 , 40 , 30 , 29 },
+{ 40 , 40 , 30 , 30 },
+{ 40 , 40 , 30 , 31 },
+{ 40 , 40 , 30 , 32 },
+{ 40 , 40 , 30 , 33 },
+{ 40 , 40 , 30 , 34 },
+{ 40 , 40 , 30 , 35 },
+{ 40 , 40 , 30 , 36 },
+{ 40 , 40 , 30 , 37 },
+{ 40 , 40 , 30 , 38 },
+{ 40 , 40 , 30 , 39 },
+{ 40 , 40 , 31 , 0 },
+{ 40 , 40 , 31 , 1 },
+{ 40 , 40 , 31 , 2 },
+{ 40 , 40 , 31 , 3 },
+{ 40 , 40 , 31 , 4 },
+{ 40 , 40 , 31 , 5 },
+{ 40 , 40 , 31 , 6 },
+{ 40 , 40 , 31 , 7 },
+{ 40 , 40 , 31 , 8 },
+{ 40 , 40 , 31 , 9 },
+{ 40 , 40 , 31 , 10 },
+{ 40 , 40 , 31 , 11 },
+{ 40 , 40 , 31 , 12 },
+{ 40 , 40 , 31 , 13 },
+{ 40 , 40 , 31 , 14 },
+{ 40 , 40 , 31 , 15 },
+{ 40 , 40 , 31 , 16 },
+{ 40 , 40 , 31 , 17 },
+{ 40 , 40 , 31 , 18 },
+{ 40 , 40 , 31 , 19 },
+{ 40 , 40 , 31 , 20 },
+{ 40 , 40 , 31 , 21 },
+{ 40 , 40 , 31 , 22 },
+{ 40 , 40 , 31 , 23 },
+{ 40 , 40 , 31 , 24 },
+{ 40 , 40 , 31 , 25 },
+{ 40 , 40 , 31 , 26 },
+{ 40 , 40 , 31 , 27 },
+{ 40 , 40 , 31 , 28 },
+{ 40 , 40 , 31 , 29 },
+{ 40 , 40 , 31 , 30 },
+{ 40 , 40 , 31 , 31 },
+{ 40 , 40 , 31 , 32 },
+{ 40 , 40 , 31 , 33 },
+{ 40 , 40 , 31 , 34 },
+{ 40 , 40 , 31 , 35 },
+{ 40 , 40 , 31 , 36 },
+{ 40 , 40 , 31 , 37 },
+{ 40 , 40 , 31 , 38 },
+{ 40 , 40 , 31 , 39 },
+{ 40 , 40 , 32 , 0 },
+{ 40 , 40 , 32 , 1 },
+{ 40 , 40 , 32 , 2 },
+{ 40 , 40 , 32 , 3 },
+{ 40 , 40 , 32 , 4 },
+{ 40 , 40 , 32 , 5 },
+{ 40 , 40 , 32 , 6 },
+{ 40 , 40 , 32 , 7 },
+{ 40 , 40 , 32 , 8 },
+{ 40 , 40 , 32 , 9 },
+{ 40 , 40 , 32 , 10 },
+{ 40 , 40 , 32 , 11 },
+{ 40 , 40 , 32 , 12 },
+{ 40 , 40 , 32 , 13 },
+{ 40 , 40 , 32 , 14 },
+{ 40 , 40 , 32 , 15 },
+{ 40 , 40 , 32 , 16 },
+{ 40 , 40 , 32 , 17 },
+{ 40 , 40 , 32 , 18 },
+{ 40 , 40 , 32 , 19 },
+{ 40 , 40 , 32 , 20 },
+{ 40 , 40 , 32 , 21 },
+{ 40 , 40 , 32 , 22 },
+{ 40 , 40 , 32 , 23 },
+{ 40 , 40 , 32 , 24 },
+{ 40 , 40 , 32 , 25 },
+{ 40 , 40 , 32 , 26 },
+{ 40 , 40 , 32 , 27 },
+{ 40 , 40 , 32 , 28 },
+{ 40 , 40 , 32 , 29 },
+{ 40 , 40 , 32 , 30 },
+{ 40 , 40 , 32 , 31 },
+{ 40 , 40 , 32 , 32 },
+{ 40 , 40 , 32 , 33 },
+{ 40 , 40 , 32 , 34 },
+{ 40 , 40 , 32 , 35 },
+{ 40 , 40 , 32 , 36 },
+{ 40 , 40 , 32 , 37 },
+{ 40 , 40 , 32 , 38 },
+{ 40 , 40 , 32 , 39 },
+{ 40 , 40 , 33 , 0 },
+{ 40 , 40 , 33 , 1 },
+{ 40 , 40 , 33 , 2 },
+{ 40 , 40 , 33 , 3 },
+{ 40 , 40 , 33 , 4 },
+{ 40 , 40 , 33 , 5 },
+{ 40 , 40 , 33 , 6 },
+{ 40 , 40 , 33 , 7 },
+{ 40 , 40 , 33 , 8 },
+{ 40 , 40 , 33 , 9 },
+{ 40 , 40 , 33 , 10 },
+{ 40 , 40 , 33 , 11 },
+{ 40 , 40 , 33 , 12 },
+{ 40 , 40 , 33 , 13 },
+{ 40 , 40 , 33 , 14 },
+{ 40 , 40 , 33 , 15 },
+{ 40 , 40 , 33 , 16 },
+{ 40 , 40 , 33 , 17 },
+{ 40 , 40 , 33 , 18 },
+{ 40 , 40 , 33 , 19 },
+{ 40 , 40 , 33 , 20 },
+{ 40 , 40 , 33 , 21 },
+{ 40 , 40 , 33 , 22 },
+{ 40 , 40 , 33 , 23 },
+{ 40 , 40 , 33 , 24 },
+{ 40 , 40 , 33 , 25 },
+{ 40 , 40 , 33 , 26 },
+{ 40 , 40 , 33 , 27 },
+{ 40 , 40 , 33 , 28 },
+{ 40 , 40 , 33 , 29 },
+{ 40 , 40 , 33 , 30 },
+{ 40 , 40 , 33 , 31 },
+{ 40 , 40 , 33 , 32 },
+{ 40 , 40 , 33 , 33 },
+{ 40 , 40 , 33 , 34 },
+{ 40 , 40 , 33 , 35 },
+{ 40 , 40 , 33 , 36 },
+{ 40 , 40 , 33 , 37 },
+{ 40 , 40 , 33 , 38 },
+{ 40 , 40 , 33 , 39 },
+{ 40 , 40 , 34 , 0 },
+{ 40 , 40 , 34 , 1 },
+{ 40 , 40 , 34 , 2 },
+{ 40 , 40 , 34 , 3 },
+{ 40 , 40 , 34 , 4 },
+{ 40 , 40 , 34 , 5 },
+{ 40 , 40 , 34 , 6 },
+{ 40 , 40 , 34 , 7 },
+{ 40 , 40 , 34 , 8 },
+{ 40 , 40 , 34 , 9 },
+{ 40 , 40 , 34 , 10 },
+{ 40 , 40 , 34 , 11 },
+{ 40 , 40 , 34 , 12 },
+{ 40 , 40 , 34 , 13 },
+{ 40 , 40 , 34 , 14 },
+{ 40 , 40 , 34 , 15 },
+{ 40 , 40 , 34 , 16 },
+{ 40 , 40 , 34 , 17 },
+{ 40 , 40 , 34 , 18 },
+{ 40 , 40 , 34 , 19 },
+{ 40 , 40 , 34 , 20 },
+{ 40 , 40 , 34 , 21 },
+{ 40 , 40 , 34 , 22 },
+{ 40 , 40 , 34 , 23 },
+{ 40 , 40 , 34 , 24 },
+{ 40 , 40 , 34 , 25 },
+{ 40 , 40 , 34 , 26 },
+{ 40 , 40 , 34 , 27 },
+{ 40 , 40 , 34 , 28 },
+{ 40 , 40 , 34 , 29 },
+{ 40 , 40 , 34 , 30 },
+{ 40 , 40 , 34 , 31 },
+{ 40 , 40 , 34 , 32 },
+{ 40 , 40 , 34 , 33 },
+{ 40 , 40 , 34 , 34 },
+{ 40 , 40 , 34 , 35 },
+{ 40 , 40 , 34 , 36 },
+{ 40 , 40 , 34 , 37 },
+{ 40 , 40 , 34 , 38 },
+{ 40 , 40 , 34 , 39 },
+{ 40 , 40 , 35 , 0 },
+{ 40 , 40 , 35 , 1 },
+{ 40 , 40 , 35 , 2 },
+{ 40 , 40 , 35 , 3 },
+{ 40 , 40 , 35 , 4 },
+{ 40 , 40 , 35 , 5 },
+{ 40 , 40 , 35 , 6 },
+{ 40 , 40 , 35 , 7 },
+{ 40 , 40 , 35 , 8 },
+{ 40 , 40 , 35 , 9 },
+{ 40 , 40 , 35 , 10 },
+{ 40 , 40 , 35 , 11 },
+{ 40 , 40 , 35 , 12 },
+{ 40 , 40 , 35 , 13 },
+{ 40 , 40 , 35 , 14 },
+{ 40 , 40 , 35 , 15 },
+{ 40 , 40 , 35 , 16 },
+{ 40 , 40 , 35 , 17 },
+{ 40 , 40 , 35 , 18 },
+{ 40 , 40 , 35 , 19 },
+{ 40 , 40 , 35 , 20 },
+{ 40 , 40 , 35 , 21 },
+{ 40 , 40 , 35 , 22 },
+{ 40 , 40 , 35 , 23 },
+{ 40 , 40 , 35 , 24 },
+{ 40 , 40 , 35 , 25 },
+{ 40 , 40 , 35 , 26 },
+{ 40 , 40 , 35 , 27 },
+{ 40 , 40 , 35 , 28 },
+{ 40 , 40 , 35 , 29 },
+{ 40 , 40 , 35 , 30 },
+{ 40 , 40 , 35 , 31 },
+{ 40 , 40 , 35 , 32 },
+{ 40 , 40 , 35 , 33 },
+{ 40 , 40 , 35 , 34 },
+{ 40 , 40 , 35 , 35 },
+{ 40 , 40 , 35 , 36 },
+{ 40 , 40 , 35 , 37 },
+{ 40 , 40 , 35 , 38 },
+{ 40 , 40 , 35 , 39 },
+{ 40 , 40 , 36 , 0 },
+{ 40 , 40 , 36 , 1 },
+{ 40 , 40 , 36 , 2 },
+{ 40 , 40 , 36 , 3 },
+{ 40 , 40 , 36 , 4 },
+{ 40 , 40 , 36 , 5 },
+{ 40 , 40 , 36 , 6 },
+{ 40 , 40 , 36 , 7 },
+{ 40 , 40 , 36 , 8 },
+{ 40 , 40 , 36 , 9 },
+{ 40 , 40 , 36 , 10 },
+{ 40 , 40 , 36 , 11 },
+{ 40 , 40 , 36 , 12 },
+{ 40 , 40 , 36 , 13 },
+{ 40 , 40 , 36 , 14 },
+{ 40 , 40 , 36 , 15 },
+{ 40 , 40 , 36 , 16 },
+{ 40 , 40 , 36 , 17 },
+{ 40 , 40 , 36 , 18 },
+{ 40 , 40 , 36 , 19 },
+{ 40 , 40 , 36 , 20 },
+{ 40 , 40 , 36 , 21 },
+{ 40 , 40 , 36 , 22 },
+{ 40 , 40 , 36 , 23 },
+{ 40 , 40 , 36 , 24 },
+{ 40 , 40 , 36 , 25 },
+{ 40 , 40 , 36 , 26 },
+{ 40 , 40 , 36 , 27 },
+{ 40 , 40 , 36 , 28 },
+{ 40 , 40 , 36 , 29 },
+{ 40 , 40 , 36 , 30 },
+{ 40 , 40 , 36 , 31 },
+{ 40 , 40 , 36 , 32 },
+{ 40 , 40 , 36 , 33 },
+{ 40 , 40 , 36 , 34 },
+{ 40 , 40 , 36 , 35 },
+{ 40 , 40 , 36 , 36 },
+{ 40 , 40 , 36 , 37 },
+{ 40 , 40 , 36 , 38 },
+{ 40 , 40 , 36 , 39 },
+{ 40 , 40 , 37 , 0 },
+{ 40 , 40 , 37 , 1 },
+{ 40 , 40 , 37 , 2 },
+{ 40 , 40 , 37 , 3 },
+{ 40 , 40 , 37 , 4 },
+{ 40 , 40 , 37 , 5 },
+{ 40 , 40 , 37 , 6 },
+{ 40 , 40 , 37 , 7 },
+{ 40 , 40 , 37 , 8 },
+{ 40 , 40 , 37 , 9 },
+{ 40 , 40 , 37 , 10 },
+{ 40 , 40 , 37 , 11 },
+{ 40 , 40 , 37 , 12 },
+{ 40 , 40 , 37 , 13 },
+{ 40 , 40 , 37 , 14 },
+{ 40 , 40 , 37 , 15 },
+{ 40 , 40 , 37 , 16 },
+{ 40 , 40 , 37 , 17 },
+{ 40 , 40 , 37 , 18 },
+{ 40 , 40 , 37 , 19 },
+{ 40 , 40 , 37 , 20 },
+{ 40 , 40 , 37 , 21 },
+{ 40 , 40 , 37 , 22 },
+{ 40 , 40 , 37 , 23 },
+{ 40 , 40 , 37 , 24 },
+{ 40 , 40 , 37 , 25 },
+{ 40 , 40 , 37 , 26 },
+{ 40 , 40 , 37 , 27 },
+{ 40 , 40 , 37 , 28 },
+{ 40 , 40 , 37 , 29 },
+{ 40 , 40 , 37 , 30 },
+{ 40 , 40 , 37 , 31 },
+{ 40 , 40 , 37 , 32 },
+{ 40 , 40 , 37 , 33 },
+{ 40 , 40 , 37 , 34 },
+{ 40 , 40 , 37 , 35 },
+{ 40 , 40 , 37 , 36 },
+{ 40 , 40 , 37 , 37 },
+{ 40 , 40 , 37 , 38 },
+{ 40 , 40 , 37 , 39 },
+{ 40 , 40 , 38 , 0 },
+{ 40 , 40 , 38 , 1 },
+{ 40 , 40 , 38 , 2 },
+{ 40 , 40 , 38 , 3 },
+{ 40 , 40 , 38 , 4 },
+{ 40 , 40 , 38 , 5 },
+{ 40 , 40 , 38 , 6 },
+{ 40 , 40 , 38 , 7 },
+{ 40 , 40 , 38 , 8 },
+{ 40 , 40 , 38 , 9 },
+{ 40 , 40 , 38 , 10 },
+{ 40 , 40 , 38 , 11 },
+{ 40 , 40 , 38 , 12 },
+{ 40 , 40 , 38 , 13 },
+{ 40 , 40 , 38 , 14 },
+{ 40 , 40 , 38 , 15 },
+{ 40 , 40 , 38 , 16 },
+{ 40 , 40 , 38 , 17 },
+{ 40 , 40 , 38 , 18 },
+{ 40 , 40 , 38 , 19 },
+{ 40 , 40 , 38 , 20 },
+{ 40 , 40 , 38 , 21 },
+{ 40 , 40 , 38 , 22 },
+{ 40 , 40 , 38 , 23 },
+{ 40 , 40 , 38 , 24 },
+{ 40 , 40 , 38 , 25 },
+{ 40 , 40 , 38 , 26 },
+{ 40 , 40 , 38 , 27 },
+{ 40 , 40 , 38 , 28 },
+{ 40 , 40 , 38 , 29 },
+{ 40 , 40 , 38 , 30 },
+{ 40 , 40 , 38 , 31 },
+{ 40 , 40 , 38 , 32 },
+{ 40 , 40 , 38 , 33 },
+{ 40 , 40 , 38 , 34 },
+{ 40 , 40 , 38 , 35 },
+{ 40 , 40 , 38 , 36 },
+{ 40 , 40 , 38 , 37 },
+{ 40 , 40 , 38 , 38 },
+{ 40 , 40 , 38 , 39 },
+{ 40 , 40 , 39 , 0 },
+{ 40 , 40 , 39 , 1 },
+{ 40 , 40 , 39 , 2 },
+{ 40 , 40 , 39 , 3 },
+{ 40 , 40 , 39 , 4 },
+{ 40 , 40 , 39 , 5 },
+{ 40 , 40 , 39 , 6 },
+{ 40 , 40 , 39 , 7 },
+{ 40 , 40 , 39 , 8 },
+{ 40 , 40 , 39 , 9 },
+{ 40 , 40 , 39 , 10 },
+{ 40 , 40 , 39 , 11 },
+{ 40 , 40 , 39 , 12 },
+{ 40 , 40 , 39 , 13 },
+{ 40 , 40 , 39 , 14 },
+{ 40 , 40 , 39 , 15 },
+{ 40 , 40 , 39 , 16 },
+{ 40 , 40 , 39 , 17 },
+{ 40 , 40 , 39 , 18 },
+{ 40 , 40 , 39 , 19 },
+{ 40 , 40 , 39 , 20 },
+{ 40 , 40 , 39 , 21 },
+{ 40 , 40 , 39 , 22 },
+{ 40 , 40 , 39 , 23 },
+{ 40 , 40 , 39 , 24 },
+{ 40 , 40 , 39 , 25 },
+{ 40 , 40 , 39 , 26 },
+{ 40 , 40 , 39 , 27 },
+{ 40 , 40 , 39 , 28 },
+{ 40 , 40 , 39 , 29 },
+{ 40 , 40 , 39 , 30 },
+{ 40 , 40 , 39 , 31 },
+{ 40 , 40 , 39 , 32 },
+{ 40 , 40 , 39 , 33 },
+{ 40 , 40 , 39 , 34 },
+{ 40 , 40 , 39 , 35 },
+{ 40 , 40 , 39 , 36 },
+{ 40 , 40 , 39 , 37 },
+{ 40 , 40 , 39 , 38 },
+{ 40 , 40 , 39 , 39 },
+{ 40 , 80 , 0 , 0 },
+{ 40 , 80 , 0 , 1 },
+{ 40 , 80 , 0 , 2 },
+{ 40 , 80 , 0 , 3 },
+{ 40 , 80 , 0 , 4 },
+{ 40 , 80 , 0 , 5 },
+{ 40 , 80 , 0 , 6 },
+{ 40 , 80 , 0 , 7 },
+{ 40 , 80 , 0 , 8 },
+{ 40 , 80 , 0 , 9 },
+{ 40 , 80 , 0 , 10 },
+{ 40 , 80 , 0 , 11 },
+{ 40 , 80 , 0 , 12 },
+{ 40 , 80 , 0 , 13 },
+{ 40 , 80 , 0 , 14 },
+{ 40 , 80 , 0 , 15 },
+{ 40 , 80 , 0 , 16 },
+{ 40 , 80 , 0 , 17 },
+{ 40 , 80 , 0 , 18 },
+{ 40 , 80 , 0 , 19 },
+{ 40 , 80 , 0 , 20 },
+{ 40 , 80 , 0 , 21 },
+{ 40 , 80 , 0 , 22 },
+{ 40 , 80 , 0 , 23 },
+{ 40 , 80 , 0 , 24 },
+{ 40 , 80 , 0 , 25 },
+{ 40 , 80 , 0 , 26 },
+{ 40 , 80 , 0 , 27 },
+{ 40 , 80 , 0 , 28 },
+{ 40 , 80 , 0 , 29 },
+{ 40 , 80 , 0 , 30 },
+{ 40 , 80 , 0 , 31 },
+{ 40 , 80 , 0 , 32 },
+{ 40 , 80 , 0 , 33 },
+{ 40 , 80 , 0 , 34 },
+{ 40 , 80 , 0 , 35 },
+{ 40 , 80 , 0 , 36 },
+{ 40 , 80 , 0 , 37 },
+{ 40 , 80 , 0 , 38 },
+{ 40 , 80 , 0 , 39 },
+{ 40 , 80 , 0 , 40 },
+{ 40 , 80 , 0 , 41 },
+{ 40 , 80 , 0 , 42 },
+{ 40 , 80 , 0 , 43 },
+{ 40 , 80 , 0 , 44 },
+{ 40 , 80 , 0 , 45 },
+{ 40 , 80 , 0 , 46 },
+{ 40 , 80 , 0 , 47 },
+{ 40 , 80 , 0 , 48 },
+{ 40 , 80 , 0 , 49 },
+{ 40 , 80 , 0 , 50 },
+{ 40 , 80 , 0 , 51 },
+{ 40 , 80 , 0 , 52 },
+{ 40 , 80 , 0 , 53 },
+{ 40 , 80 , 0 , 54 },
+{ 40 , 80 , 0 , 55 },
+{ 40 , 80 , 0 , 56 },
+{ 40 , 80 , 0 , 57 },
+{ 40 , 80 , 0 , 58 },
+{ 40 , 80 , 0 , 59 },
+{ 40 , 80 , 0 , 60 },
+{ 40 , 80 , 0 , 61 },
+{ 40 , 80 , 0 , 62 },
+{ 40 , 80 , 0 , 63 },
+{ 40 , 80 , 0 , 64 },
+{ 40 , 80 , 0 , 65 },
+{ 40 , 80 , 0 , 66 },
+{ 40 , 80 , 0 , 67 },
+{ 40 , 80 , 0 , 68 },
+{ 40 , 80 , 0 , 69 },
+{ 40 , 80 , 0 , 70 },
+{ 40 , 80 , 0 , 71 },
+{ 40 , 80 , 0 , 72 },
+{ 40 , 80 , 0 , 73 },
+{ 40 , 80 , 0 , 74 },
+{ 40 , 80 , 0 , 75 },
+{ 40 , 80 , 0 , 76 },
+{ 40 , 80 , 0 , 77 },
+{ 40 , 80 , 0 , 78 },
+{ 40 , 80 , 0 , 79 },
+{ 40 , 80 , 1 , 0 },
+{ 40 , 80 , 1 , 1 },
+{ 40 , 80 , 1 , 2 },
+{ 40 , 80 , 1 , 3 },
+{ 40 , 80 , 1 , 4 },
+{ 40 , 80 , 1 , 5 },
+{ 40 , 80 , 1 , 6 },
+{ 40 , 80 , 1 , 7 },
+{ 40 , 80 , 1 , 8 },
+{ 40 , 80 , 1 , 9 },
+{ 40 , 80 , 1 , 10 },
+{ 40 , 80 , 1 , 11 },
+{ 40 , 80 , 1 , 12 },
+{ 40 , 80 , 1 , 13 },
+{ 40 , 80 , 1 , 14 },
+{ 40 , 80 , 1 , 15 },
+{ 40 , 80 , 1 , 16 },
+{ 40 , 80 , 1 , 17 },
+{ 40 , 80 , 1 , 18 },
+{ 40 , 80 , 1 , 19 },
+{ 40 , 80 , 1 , 20 },
+{ 40 , 80 , 1 , 21 },
+{ 40 , 80 , 1 , 22 },
+{ 40 , 80 , 1 , 23 },
+{ 40 , 80 , 1 , 24 },
+{ 40 , 80 , 1 , 25 },
+{ 40 , 80 , 1 , 26 },
+{ 40 , 80 , 1 , 27 },
+{ 40 , 80 , 1 , 28 },
+{ 40 , 80 , 1 , 29 },
+{ 40 , 80 , 1 , 30 },
+{ 40 , 80 , 1 , 31 },
+{ 40 , 80 , 1 , 32 },
+{ 40 , 80 , 1 , 33 },
+{ 40 , 80 , 1 , 34 },
+{ 40 , 80 , 1 , 35 },
+{ 40 , 80 , 1 , 36 },
+{ 40 , 80 , 1 , 37 },
+{ 40 , 80 , 1 , 38 },
+{ 40 , 80 , 1 , 39 },
+{ 40 , 80 , 1 , 40 },
+{ 40 , 80 , 1 , 41 },
+{ 40 , 80 , 1 , 42 },
+{ 40 , 80 , 1 , 43 },
+{ 40 , 80 , 1 , 44 },
+{ 40 , 80 , 1 , 45 },
+{ 40 , 80 , 1 , 46 },
+{ 40 , 80 , 1 , 47 },
+{ 40 , 80 , 1 , 48 },
+{ 40 , 80 , 1 , 49 },
+{ 40 , 80 , 1 , 50 },
+{ 40 , 80 , 1 , 51 },
+{ 40 , 80 , 1 , 52 },
+{ 40 , 80 , 1 , 53 },
+{ 40 , 80 , 1 , 54 },
+{ 40 , 80 , 1 , 55 },
+{ 40 , 80 , 1 , 56 },
+{ 40 , 80 , 1 , 57 },
+{ 40 , 80 , 1 , 58 },
+{ 40 , 80 , 1 , 59 },
+{ 40 , 80 , 1 , 60 },
+{ 40 , 80 , 1 , 61 },
+{ 40 , 80 , 1 , 62 },
+{ 40 , 80 , 1 , 63 },
+{ 40 , 80 , 1 , 64 },
+{ 40 , 80 , 1 , 65 },
+{ 40 , 80 , 1 , 66 },
+{ 40 , 80 , 1 , 67 },
+{ 40 , 80 , 1 , 68 },
+{ 40 , 80 , 1 , 69 },
+{ 40 , 80 , 1 , 70 },
+{ 40 , 80 , 1 , 71 },
+{ 40 , 80 , 1 , 72 },
+{ 40 , 80 , 1 , 73 },
+{ 40 , 80 , 1 , 74 },
+{ 40 , 80 , 1 , 75 },
+{ 40 , 80 , 1 , 76 },
+{ 40 , 80 , 1 , 77 },
+{ 40 , 80 , 1 , 78 },
+{ 40 , 80 , 1 , 79 },
+{ 40 , 80 , 2 , 0 },
+{ 40 , 80 , 2 , 1 },
+{ 40 , 80 , 2 , 2 },
+{ 40 , 80 , 2 , 3 },
+{ 40 , 80 , 2 , 4 },
+{ 40 , 80 , 2 , 5 },
+{ 40 , 80 , 2 , 6 },
+{ 40 , 80 , 2 , 7 },
+{ 40 , 80 , 2 , 8 },
+{ 40 , 80 , 2 , 9 },
+{ 40 , 80 , 2 , 10 },
+{ 40 , 80 , 2 , 11 },
+{ 40 , 80 , 2 , 12 },
+{ 40 , 80 , 2 , 13 },
+{ 40 , 80 , 2 , 14 },
+{ 40 , 80 , 2 , 15 },
+{ 40 , 80 , 2 , 16 },
+{ 40 , 80 , 2 , 17 },
+{ 40 , 80 , 2 , 18 },
+{ 40 , 80 , 2 , 19 },
+{ 40 , 80 , 2 , 20 },
+{ 40 , 80 , 2 , 21 },
+{ 40 , 80 , 2 , 22 },
+{ 40 , 80 , 2 , 23 },
+{ 40 , 80 , 2 , 24 },
+{ 40 , 80 , 2 , 25 },
+{ 40 , 80 , 2 , 26 },
+{ 40 , 80 , 2 , 27 },
+{ 40 , 80 , 2 , 28 },
+{ 40 , 80 , 2 , 29 },
+{ 40 , 80 , 2 , 30 },
+{ 40 , 80 , 2 , 31 },
+{ 40 , 80 , 2 , 32 },
+{ 40 , 80 , 2 , 33 },
+{ 40 , 80 , 2 , 34 },
+{ 40 , 80 , 2 , 35 },
+{ 40 , 80 , 2 , 36 },
+{ 40 , 80 , 2 , 37 },
+{ 40 , 80 , 2 , 38 },
+{ 40 , 80 , 2 , 39 },
+{ 40 , 80 , 2 , 40 },
+{ 40 , 80 , 2 , 41 },
+{ 40 , 80 , 2 , 42 },
+{ 40 , 80 , 2 , 43 },
+{ 40 , 80 , 2 , 44 },
+{ 40 , 80 , 2 , 45 },
+{ 40 , 80 , 2 , 46 },
+{ 40 , 80 , 2 , 47 },
+{ 40 , 80 , 2 , 48 },
+{ 40 , 80 , 2 , 49 },
+{ 40 , 80 , 2 , 50 },
+{ 40 , 80 , 2 , 51 },
+{ 40 , 80 , 2 , 52 },
+{ 40 , 80 , 2 , 53 },
+{ 40 , 80 , 2 , 54 },
+{ 40 , 80 , 2 , 55 },
+{ 40 , 80 , 2 , 56 },
+{ 40 , 80 , 2 , 57 },
+{ 40 , 80 , 2 , 58 },
+{ 40 , 80 , 2 , 59 },
+{ 40 , 80 , 2 , 60 },
+{ 40 , 80 , 2 , 61 },
+{ 40 , 80 , 2 , 62 },
+{ 40 , 80 , 2 , 63 },
+{ 40 , 80 , 2 , 64 },
+{ 40 , 80 , 2 , 65 },
+{ 40 , 80 , 2 , 66 },
+{ 40 , 80 , 2 , 67 },
+{ 40 , 80 , 2 , 68 },
+{ 40 , 80 , 2 , 69 },
+{ 40 , 80 , 2 , 70 },
+{ 40 , 80 , 2 , 71 },
+{ 40 , 80 , 2 , 72 },
+{ 40 , 80 , 2 , 73 },
+{ 40 , 80 , 2 , 74 },
+{ 40 , 80 , 2 , 75 },
+{ 40 , 80 , 2 , 76 },
+{ 40 , 80 , 2 , 77 },
+{ 40 , 80 , 2 , 78 },
+{ 40 , 80 , 2 , 79 },
+{ 40 , 80 , 3 , 0 },
+{ 40 , 80 , 3 , 1 },
+{ 40 , 80 , 3 , 2 },
+{ 40 , 80 , 3 , 3 },
+{ 40 , 80 , 3 , 4 },
+{ 40 , 80 , 3 , 5 },
+{ 40 , 80 , 3 , 6 },
+{ 40 , 80 , 3 , 7 },
+{ 40 , 80 , 3 , 8 },
+{ 40 , 80 , 3 , 9 },
+{ 40 , 80 , 3 , 10 },
+{ 40 , 80 , 3 , 11 },
+{ 40 , 80 , 3 , 12 },
+{ 40 , 80 , 3 , 13 },
+{ 40 , 80 , 3 , 14 },
+{ 40 , 80 , 3 , 15 },
+{ 40 , 80 , 3 , 16 },
+{ 40 , 80 , 3 , 17 },
+{ 40 , 80 , 3 , 18 },
+{ 40 , 80 , 3 , 19 },
+{ 40 , 80 , 3 , 20 },
+{ 40 , 80 , 3 , 21 },
+{ 40 , 80 , 3 , 22 },
+{ 40 , 80 , 3 , 23 },
+{ 40 , 80 , 3 , 24 },
+{ 40 , 80 , 3 , 25 },
+{ 40 , 80 , 3 , 26 },
+{ 40 , 80 , 3 , 27 },
+{ 40 , 80 , 3 , 28 },
+{ 40 , 80 , 3 , 29 },
+{ 40 , 80 , 3 , 30 },
+{ 40 , 80 , 3 , 31 },
+{ 40 , 80 , 3 , 32 },
+{ 40 , 80 , 3 , 33 },
+{ 40 , 80 , 3 , 34 },
+{ 40 , 80 , 3 , 35 },
+{ 40 , 80 , 3 , 36 },
+{ 40 , 80 , 3 , 37 },
+{ 40 , 80 , 3 , 38 },
+{ 40 , 80 , 3 , 39 },
+{ 40 , 80 , 3 , 40 },
+{ 40 , 80 , 3 , 41 },
+{ 40 , 80 , 3 , 42 },
+{ 40 , 80 , 3 , 43 },
+{ 40 , 80 , 3 , 44 },
+{ 40 , 80 , 3 , 45 },
+{ 40 , 80 , 3 , 46 },
+{ 40 , 80 , 3 , 47 },
+{ 40 , 80 , 3 , 48 },
+{ 40 , 80 , 3 , 49 },
+{ 40 , 80 , 3 , 50 },
+{ 40 , 80 , 3 , 51 },
+{ 40 , 80 , 3 , 52 },
+{ 40 , 80 , 3 , 53 },
+{ 40 , 80 , 3 , 54 },
+{ 40 , 80 , 3 , 55 },
+{ 40 , 80 , 3 , 56 },
+{ 40 , 80 , 3 , 57 },
+{ 40 , 80 , 3 , 58 },
+{ 40 , 80 , 3 , 59 },
+{ 40 , 80 , 3 , 60 },
+{ 40 , 80 , 3 , 61 },
+{ 40 , 80 , 3 , 62 },
+{ 40 , 80 , 3 , 63 },
+{ 40 , 80 , 3 , 64 },
+{ 40 , 80 , 3 , 65 },
+{ 40 , 80 , 3 , 66 },
+{ 40 , 80 , 3 , 67 },
+{ 40 , 80 , 3 , 68 },
+{ 40 , 80 , 3 , 69 },
+{ 40 , 80 , 3 , 70 },
+{ 40 , 80 , 3 , 71 },
+{ 40 , 80 , 3 , 72 },
+{ 40 , 80 , 3 , 73 },
+{ 40 , 80 , 3 , 74 },
+{ 40 , 80 , 3 , 75 },
+{ 40 , 80 , 3 , 76 },
+{ 40 , 80 , 3 , 77 },
+{ 40 , 80 , 3 , 78 },
+{ 40 , 80 , 3 , 79 },
+{ 40 , 80 , 4 , 0 },
+{ 40 , 80 , 4 , 1 },
+{ 40 , 80 , 4 , 2 },
+{ 40 , 80 , 4 , 3 },
+{ 40 , 80 , 4 , 4 },
+{ 40 , 80 , 4 , 5 },
+{ 40 , 80 , 4 , 6 },
+{ 40 , 80 , 4 , 7 },
+{ 40 , 80 , 4 , 8 },
+{ 40 , 80 , 4 , 9 },
+{ 40 , 80 , 4 , 10 },
+{ 40 , 80 , 4 , 11 },
+{ 40 , 80 , 4 , 12 },
+{ 40 , 80 , 4 , 13 },
+{ 40 , 80 , 4 , 14 },
+{ 40 , 80 , 4 , 15 },
+{ 40 , 80 , 4 , 16 },
+{ 40 , 80 , 4 , 17 },
+{ 40 , 80 , 4 , 18 },
+{ 40 , 80 , 4 , 19 },
+{ 40 , 80 , 4 , 20 },
+{ 40 , 80 , 4 , 21 },
+{ 40 , 80 , 4 , 22 },
+{ 40 , 80 , 4 , 23 },
+{ 40 , 80 , 4 , 24 },
+{ 40 , 80 , 4 , 25 },
+{ 40 , 80 , 4 , 26 },
+{ 40 , 80 , 4 , 27 },
+{ 40 , 80 , 4 , 28 },
+{ 40 , 80 , 4 , 29 },
+{ 40 , 80 , 4 , 30 },
+{ 40 , 80 , 4 , 31 },
+{ 40 , 80 , 4 , 32 },
+{ 40 , 80 , 4 , 33 },
+{ 40 , 80 , 4 , 34 },
+{ 40 , 80 , 4 , 35 },
+{ 40 , 80 , 4 , 36 },
+{ 40 , 80 , 4 , 37 },
+{ 40 , 80 , 4 , 38 },
+{ 40 , 80 , 4 , 39 },
+{ 40 , 80 , 4 , 40 },
+{ 40 , 80 , 4 , 41 },
+{ 40 , 80 , 4 , 42 },
+{ 40 , 80 , 4 , 43 },
+{ 40 , 80 , 4 , 44 },
+{ 40 , 80 , 4 , 45 },
+{ 40 , 80 , 4 , 46 },
+{ 40 , 80 , 4 , 47 },
+{ 40 , 80 , 4 , 48 },
+{ 40 , 80 , 4 , 49 },
+{ 40 , 80 , 4 , 50 },
+{ 40 , 80 , 4 , 51 },
+{ 40 , 80 , 4 , 52 },
+{ 40 , 80 , 4 , 53 },
+{ 40 , 80 , 4 , 54 },
+{ 40 , 80 , 4 , 55 },
+{ 40 , 80 , 4 , 56 },
+{ 40 , 80 , 4 , 57 },
+{ 40 , 80 , 4 , 58 },
+{ 40 , 80 , 4 , 59 },
+{ 40 , 80 , 4 , 60 },
+{ 40 , 80 , 4 , 61 },
+{ 40 , 80 , 4 , 62 },
+{ 40 , 80 , 4 , 63 },
+{ 40 , 80 , 4 , 64 },
+{ 40 , 80 , 4 , 65 },
+{ 40 , 80 , 4 , 66 },
+{ 40 , 80 , 4 , 67 },
+{ 40 , 80 , 4 , 68 },
+{ 40 , 80 , 4 , 69 },
+{ 40 , 80 , 4 , 70 },
+{ 40 , 80 , 4 , 71 },
+{ 40 , 80 , 4 , 72 },
+{ 40 , 80 , 4 , 73 },
+{ 40 , 80 , 4 , 74 },
+{ 40 , 80 , 4 , 75 },
+{ 40 , 80 , 4 , 76 },
+{ 40 , 80 , 4 , 77 },
+{ 40 , 80 , 4 , 78 },
+{ 40 , 80 , 4 , 79 },
+{ 40 , 80 , 5 , 0 },
+{ 40 , 80 , 5 , 1 },
+{ 40 , 80 , 5 , 2 },
+{ 40 , 80 , 5 , 3 },
+{ 40 , 80 , 5 , 4 },
+{ 40 , 80 , 5 , 5 },
+{ 40 , 80 , 5 , 6 },
+{ 40 , 80 , 5 , 7 },
+{ 40 , 80 , 5 , 8 },
+{ 40 , 80 , 5 , 9 },
+{ 40 , 80 , 5 , 10 },
+{ 40 , 80 , 5 , 11 },
+{ 40 , 80 , 5 , 12 },
+{ 40 , 80 , 5 , 13 },
+{ 40 , 80 , 5 , 14 },
+{ 40 , 80 , 5 , 15 },
+{ 40 , 80 , 5 , 16 },
+{ 40 , 80 , 5 , 17 },
+{ 40 , 80 , 5 , 18 },
+{ 40 , 80 , 5 , 19 },
+{ 40 , 80 , 5 , 20 },
+{ 40 , 80 , 5 , 21 },
+{ 40 , 80 , 5 , 22 },
+{ 40 , 80 , 5 , 23 },
+{ 40 , 80 , 5 , 24 },
+{ 40 , 80 , 5 , 25 },
+{ 40 , 80 , 5 , 26 },
+{ 40 , 80 , 5 , 27 },
+{ 40 , 80 , 5 , 28 },
+{ 40 , 80 , 5 , 29 },
+{ 40 , 80 , 5 , 30 },
+{ 40 , 80 , 5 , 31 },
+{ 40 , 80 , 5 , 32 },
+{ 40 , 80 , 5 , 33 },
+{ 40 , 80 , 5 , 34 },
+{ 40 , 80 , 5 , 35 },
+{ 40 , 80 , 5 , 36 },
+{ 40 , 80 , 5 , 37 },
+{ 40 , 80 , 5 , 38 },
+{ 40 , 80 , 5 , 39 },
+{ 40 , 80 , 5 , 40 },
+{ 40 , 80 , 5 , 41 },
+{ 40 , 80 , 5 , 42 },
+{ 40 , 80 , 5 , 43 },
+{ 40 , 80 , 5 , 44 },
+{ 40 , 80 , 5 , 45 },
+{ 40 , 80 , 5 , 46 },
+{ 40 , 80 , 5 , 47 },
+{ 40 , 80 , 5 , 48 },
+{ 40 , 80 , 5 , 49 },
+{ 40 , 80 , 5 , 50 },
+{ 40 , 80 , 5 , 51 },
+{ 40 , 80 , 5 , 52 },
+{ 40 , 80 , 5 , 53 },
+{ 40 , 80 , 5 , 54 },
+{ 40 , 80 , 5 , 55 },
+{ 40 , 80 , 5 , 56 },
+{ 40 , 80 , 5 , 57 },
+{ 40 , 80 , 5 , 58 },
+{ 40 , 80 , 5 , 59 },
+{ 40 , 80 , 5 , 60 },
+{ 40 , 80 , 5 , 61 },
+{ 40 , 80 , 5 , 62 },
+{ 40 , 80 , 5 , 63 },
+{ 40 , 80 , 5 , 64 },
+{ 40 , 80 , 5 , 65 },
+{ 40 , 80 , 5 , 66 },
+{ 40 , 80 , 5 , 67 },
+{ 40 , 80 , 5 , 68 },
+{ 40 , 80 , 5 , 69 },
+{ 40 , 80 , 5 , 70 },
+{ 40 , 80 , 5 , 71 },
+{ 40 , 80 , 5 , 72 },
+{ 40 , 80 , 5 , 73 },
+{ 40 , 80 , 5 , 74 },
+{ 40 , 80 , 5 , 75 },
+{ 40 , 80 , 5 , 76 },
+{ 40 , 80 , 5 , 77 },
+{ 40 , 80 , 5 , 78 },
+{ 40 , 80 , 5 , 79 },
+{ 40 , 80 , 6 , 0 },
+{ 40 , 80 , 6 , 1 },
+{ 40 , 80 , 6 , 2 },
+{ 40 , 80 , 6 , 3 },
+{ 40 , 80 , 6 , 4 },
+{ 40 , 80 , 6 , 5 },
+{ 40 , 80 , 6 , 6 },
+{ 40 , 80 , 6 , 7 },
+{ 40 , 80 , 6 , 8 },
+{ 40 , 80 , 6 , 9 },
+{ 40 , 80 , 6 , 10 },
+{ 40 , 80 , 6 , 11 },
+{ 40 , 80 , 6 , 12 },
+{ 40 , 80 , 6 , 13 },
+{ 40 , 80 , 6 , 14 },
+{ 40 , 80 , 6 , 15 },
+{ 40 , 80 , 6 , 16 },
+{ 40 , 80 , 6 , 17 },
+{ 40 , 80 , 6 , 18 },
+{ 40 , 80 , 6 , 19 },
+{ 40 , 80 , 6 , 20 },
+{ 40 , 80 , 6 , 21 },
+{ 40 , 80 , 6 , 22 },
+{ 40 , 80 , 6 , 23 },
+{ 40 , 80 , 6 , 24 },
+{ 40 , 80 , 6 , 25 },
+{ 40 , 80 , 6 , 26 },
+{ 40 , 80 , 6 , 27 },
+{ 40 , 80 , 6 , 28 },
+{ 40 , 80 , 6 , 29 },
+{ 40 , 80 , 6 , 30 },
+{ 40 , 80 , 6 , 31 },
+{ 40 , 80 , 6 , 32 },
+{ 40 , 80 , 6 , 33 },
+{ 40 , 80 , 6 , 34 },
+{ 40 , 80 , 6 , 35 },
+{ 40 , 80 , 6 , 36 },
+{ 40 , 80 , 6 , 37 },
+{ 40 , 80 , 6 , 38 },
+{ 40 , 80 , 6 , 39 },
+{ 40 , 80 , 6 , 40 },
+{ 40 , 80 , 6 , 41 },
+{ 40 , 80 , 6 , 42 },
+{ 40 , 80 , 6 , 43 },
+{ 40 , 80 , 6 , 44 },
+{ 40 , 80 , 6 , 45 },
+{ 40 , 80 , 6 , 46 },
+{ 40 , 80 , 6 , 47 },
+{ 40 , 80 , 6 , 48 },
+{ 40 , 80 , 6 , 49 },
+{ 40 , 80 , 6 , 50 },
+{ 40 , 80 , 6 , 51 },
+{ 40 , 80 , 6 , 52 },
+{ 40 , 80 , 6 , 53 },
+{ 40 , 80 , 6 , 54 },
+{ 40 , 80 , 6 , 55 },
+{ 40 , 80 , 6 , 56 },
+{ 40 , 80 , 6 , 57 },
+{ 40 , 80 , 6 , 58 },
+{ 40 , 80 , 6 , 59 },
+{ 40 , 80 , 6 , 60 },
+{ 40 , 80 , 6 , 61 },
+{ 40 , 80 , 6 , 62 },
+{ 40 , 80 , 6 , 63 },
+{ 40 , 80 , 6 , 64 },
+{ 40 , 80 , 6 , 65 },
+{ 40 , 80 , 6 , 66 },
+{ 40 , 80 , 6 , 67 },
+{ 40 , 80 , 6 , 68 },
+{ 40 , 80 , 6 , 69 },
+{ 40 , 80 , 6 , 70 },
+{ 40 , 80 , 6 , 71 },
+{ 40 , 80 , 6 , 72 },
+{ 40 , 80 , 6 , 73 },
+{ 40 , 80 , 6 , 74 },
+{ 40 , 80 , 6 , 75 },
+{ 40 , 80 , 6 , 76 },
+{ 40 , 80 , 6 , 77 },
+{ 40 , 80 , 6 , 78 },
+{ 40 , 80 , 6 , 79 },
+{ 40 , 80 , 7 , 0 },
+{ 40 , 80 , 7 , 1 },
+{ 40 , 80 , 7 , 2 },
+{ 40 , 80 , 7 , 3 },
+{ 40 , 80 , 7 , 4 },
+{ 40 , 80 , 7 , 5 },
+{ 40 , 80 , 7 , 6 },
+{ 40 , 80 , 7 , 7 },
+{ 40 , 80 , 7 , 8 },
+{ 40 , 80 , 7 , 9 },
+{ 40 , 80 , 7 , 10 },
+{ 40 , 80 , 7 , 11 },
+{ 40 , 80 , 7 , 12 },
+{ 40 , 80 , 7 , 13 },
+{ 40 , 80 , 7 , 14 },
+{ 40 , 80 , 7 , 15 },
+{ 40 , 80 , 7 , 16 },
+{ 40 , 80 , 7 , 17 },
+{ 40 , 80 , 7 , 18 },
+{ 40 , 80 , 7 , 19 },
+{ 40 , 80 , 7 , 20 },
+{ 40 , 80 , 7 , 21 },
+{ 40 , 80 , 7 , 22 },
+{ 40 , 80 , 7 , 23 },
+{ 40 , 80 , 7 , 24 },
+{ 40 , 80 , 7 , 25 },
+{ 40 , 80 , 7 , 26 },
+{ 40 , 80 , 7 , 27 },
+{ 40 , 80 , 7 , 28 },
+{ 40 , 80 , 7 , 29 },
+{ 40 , 80 , 7 , 30 },
+{ 40 , 80 , 7 , 31 },
+{ 40 , 80 , 7 , 32 },
+{ 40 , 80 , 7 , 33 },
+{ 40 , 80 , 7 , 34 },
+{ 40 , 80 , 7 , 35 },
+{ 40 , 80 , 7 , 36 },
+{ 40 , 80 , 7 , 37 },
+{ 40 , 80 , 7 , 38 },
+{ 40 , 80 , 7 , 39 },
+{ 40 , 80 , 7 , 40 },
+{ 40 , 80 , 7 , 41 },
+{ 40 , 80 , 7 , 42 },
+{ 40 , 80 , 7 , 43 },
+{ 40 , 80 , 7 , 44 },
+{ 40 , 80 , 7 , 45 },
+{ 40 , 80 , 7 , 46 },
+{ 40 , 80 , 7 , 47 },
+{ 40 , 80 , 7 , 48 },
+{ 40 , 80 , 7 , 49 },
+{ 40 , 80 , 7 , 50 },
+{ 40 , 80 , 7 , 51 },
+{ 40 , 80 , 7 , 52 },
+{ 40 , 80 , 7 , 53 },
+{ 40 , 80 , 7 , 54 },
+{ 40 , 80 , 7 , 55 },
+{ 40 , 80 , 7 , 56 },
+{ 40 , 80 , 7 , 57 },
+{ 40 , 80 , 7 , 58 },
+{ 40 , 80 , 7 , 59 },
+{ 40 , 80 , 7 , 60 },
+{ 40 , 80 , 7 , 61 },
+{ 40 , 80 , 7 , 62 },
+{ 40 , 80 , 7 , 63 },
+{ 40 , 80 , 7 , 64 },
+{ 40 , 80 , 7 , 65 },
+{ 40 , 80 , 7 , 66 },
+{ 40 , 80 , 7 , 67 },
+{ 40 , 80 , 7 , 68 },
+{ 40 , 80 , 7 , 69 },
+{ 40 , 80 , 7 , 70 },
+{ 40 , 80 , 7 , 71 },
+{ 40 , 80 , 7 , 72 },
+{ 40 , 80 , 7 , 73 },
+{ 40 , 80 , 7 , 74 },
+{ 40 , 80 , 7 , 75 },
+{ 40 , 80 , 7 , 76 },
+{ 40 , 80 , 7 , 77 },
+{ 40 , 80 , 7 , 78 },
+{ 40 , 80 , 7 , 79 },
+{ 40 , 80 , 8 , 0 },
+{ 40 , 80 , 8 , 1 },
+{ 40 , 80 , 8 , 2 },
+{ 40 , 80 , 8 , 3 },
+{ 40 , 80 , 8 , 4 },
+{ 40 , 80 , 8 , 5 },
+{ 40 , 80 , 8 , 6 },
+{ 40 , 80 , 8 , 7 },
+{ 40 , 80 , 8 , 8 },
+{ 40 , 80 , 8 , 9 },
+{ 40 , 80 , 8 , 10 },
+{ 40 , 80 , 8 , 11 },
+{ 40 , 80 , 8 , 12 },
+{ 40 , 80 , 8 , 13 },
+{ 40 , 80 , 8 , 14 },
+{ 40 , 80 , 8 , 15 },
+{ 40 , 80 , 8 , 16 },
+{ 40 , 80 , 8 , 17 },
+{ 40 , 80 , 8 , 18 },
+{ 40 , 80 , 8 , 19 },
+{ 40 , 80 , 8 , 20 },
+{ 40 , 80 , 8 , 21 },
+{ 40 , 80 , 8 , 22 },
+{ 40 , 80 , 8 , 23 },
+{ 40 , 80 , 8 , 24 },
+{ 40 , 80 , 8 , 25 },
+{ 40 , 80 , 8 , 26 },
+{ 40 , 80 , 8 , 27 },
+{ 40 , 80 , 8 , 28 },
+{ 40 , 80 , 8 , 29 },
+{ 40 , 80 , 8 , 30 },
+{ 40 , 80 , 8 , 31 },
+{ 40 , 80 , 8 , 32 },
+{ 40 , 80 , 8 , 33 },
+{ 40 , 80 , 8 , 34 },
+{ 40 , 80 , 8 , 35 },
+{ 40 , 80 , 8 , 36 },
+{ 40 , 80 , 8 , 37 },
+{ 40 , 80 , 8 , 38 },
+{ 40 , 80 , 8 , 39 },
+{ 40 , 80 , 8 , 40 },
+{ 40 , 80 , 8 , 41 },
+{ 40 , 80 , 8 , 42 },
+{ 40 , 80 , 8 , 43 },
+{ 40 , 80 , 8 , 44 },
+{ 40 , 80 , 8 , 45 },
+{ 40 , 80 , 8 , 46 },
+{ 40 , 80 , 8 , 47 },
+{ 40 , 80 , 8 , 48 },
+{ 40 , 80 , 8 , 49 },
+{ 40 , 80 , 8 , 50 },
+{ 40 , 80 , 8 , 51 },
+{ 40 , 80 , 8 , 52 },
+{ 40 , 80 , 8 , 53 },
+{ 40 , 80 , 8 , 54 },
+{ 40 , 80 , 8 , 55 },
+{ 40 , 80 , 8 , 56 },
+{ 40 , 80 , 8 , 57 },
+{ 40 , 80 , 8 , 58 },
+{ 40 , 80 , 8 , 59 },
+{ 40 , 80 , 8 , 60 },
+{ 40 , 80 , 8 , 61 },
+{ 40 , 80 , 8 , 62 },
+{ 40 , 80 , 8 , 63 },
+{ 40 , 80 , 8 , 64 },
+{ 40 , 80 , 8 , 65 },
+{ 40 , 80 , 8 , 66 },
+{ 40 , 80 , 8 , 67 },
+{ 40 , 80 , 8 , 68 },
+{ 40 , 80 , 8 , 69 },
+{ 40 , 80 , 8 , 70 },
+{ 40 , 80 , 8 , 71 },
+{ 40 , 80 , 8 , 72 },
+{ 40 , 80 , 8 , 73 },
+{ 40 , 80 , 8 , 74 },
+{ 40 , 80 , 8 , 75 },
+{ 40 , 80 , 8 , 76 },
+{ 40 , 80 , 8 , 77 },
+{ 40 , 80 , 8 , 78 },
+{ 40 , 80 , 8 , 79 },
+{ 40 , 80 , 9 , 0 },
+{ 40 , 80 , 9 , 1 },
+{ 40 , 80 , 9 , 2 },
+{ 40 , 80 , 9 , 3 },
+{ 40 , 80 , 9 , 4 },
+{ 40 , 80 , 9 , 5 },
+{ 40 , 80 , 9 , 6 },
+{ 40 , 80 , 9 , 7 },
+{ 40 , 80 , 9 , 8 },
+{ 40 , 80 , 9 , 9 },
+{ 40 , 80 , 9 , 10 },
+{ 40 , 80 , 9 , 11 },
+{ 40 , 80 , 9 , 12 },
+{ 40 , 80 , 9 , 13 },
+{ 40 , 80 , 9 , 14 },
+{ 40 , 80 , 9 , 15 },
+{ 40 , 80 , 9 , 16 },
+{ 40 , 80 , 9 , 17 },
+{ 40 , 80 , 9 , 18 },
+{ 40 , 80 , 9 , 19 },
+{ 40 , 80 , 9 , 20 },
+{ 40 , 80 , 9 , 21 },
+{ 40 , 80 , 9 , 22 },
+{ 40 , 80 , 9 , 23 },
+{ 40 , 80 , 9 , 24 },
+{ 40 , 80 , 9 , 25 },
+{ 40 , 80 , 9 , 26 },
+{ 40 , 80 , 9 , 27 },
+{ 40 , 80 , 9 , 28 },
+{ 40 , 80 , 9 , 29 },
+{ 40 , 80 , 9 , 30 },
+{ 40 , 80 , 9 , 31 },
+{ 40 , 80 , 9 , 32 },
+{ 40 , 80 , 9 , 33 },
+{ 40 , 80 , 9 , 34 },
+{ 40 , 80 , 9 , 35 },
+{ 40 , 80 , 9 , 36 },
+{ 40 , 80 , 9 , 37 },
+{ 40 , 80 , 9 , 38 },
+{ 40 , 80 , 9 , 39 },
+{ 40 , 80 , 9 , 40 },
+{ 40 , 80 , 9 , 41 },
+{ 40 , 80 , 9 , 42 },
+{ 40 , 80 , 9 , 43 },
+{ 40 , 80 , 9 , 44 },
+{ 40 , 80 , 9 , 45 },
+{ 40 , 80 , 9 , 46 },
+{ 40 , 80 , 9 , 47 },
+{ 40 , 80 , 9 , 48 },
+{ 40 , 80 , 9 , 49 },
+{ 40 , 80 , 9 , 50 },
+{ 40 , 80 , 9 , 51 },
+{ 40 , 80 , 9 , 52 },
+{ 40 , 80 , 9 , 53 },
+{ 40 , 80 , 9 , 54 },
+{ 40 , 80 , 9 , 55 },
+{ 40 , 80 , 9 , 56 },
+{ 40 , 80 , 9 , 57 },
+{ 40 , 80 , 9 , 58 },
+{ 40 , 80 , 9 , 59 },
+{ 40 , 80 , 9 , 60 },
+{ 40 , 80 , 9 , 61 },
+{ 40 , 80 , 9 , 62 },
+{ 40 , 80 , 9 , 63 },
+{ 40 , 80 , 9 , 64 },
+{ 40 , 80 , 9 , 65 },
+{ 40 , 80 , 9 , 66 },
+{ 40 , 80 , 9 , 67 },
+{ 40 , 80 , 9 , 68 },
+{ 40 , 80 , 9 , 69 },
+{ 40 , 80 , 9 , 70 },
+{ 40 , 80 , 9 , 71 },
+{ 40 , 80 , 9 , 72 },
+{ 40 , 80 , 9 , 73 },
+{ 40 , 80 , 9 , 74 },
+{ 40 , 80 , 9 , 75 },
+{ 40 , 80 , 9 , 76 },
+{ 40 , 80 , 9 , 77 },
+{ 40 , 80 , 9 , 78 },
+{ 40 , 80 , 9 , 79 },
+{ 40 , 80 , 10 , 0 },
+{ 40 , 80 , 10 , 1 },
+{ 40 , 80 , 10 , 2 },
+{ 40 , 80 , 10 , 3 },
+{ 40 , 80 , 10 , 4 },
+{ 40 , 80 , 10 , 5 },
+{ 40 , 80 , 10 , 6 },
+{ 40 , 80 , 10 , 7 },
+{ 40 , 80 , 10 , 8 },
+{ 40 , 80 , 10 , 9 },
+{ 40 , 80 , 10 , 10 },
+{ 40 , 80 , 10 , 11 },
+{ 40 , 80 , 10 , 12 },
+{ 40 , 80 , 10 , 13 },
+{ 40 , 80 , 10 , 14 },
+{ 40 , 80 , 10 , 15 },
+{ 40 , 80 , 10 , 16 },
+{ 40 , 80 , 10 , 17 },
+{ 40 , 80 , 10 , 18 },
+{ 40 , 80 , 10 , 19 },
+{ 40 , 80 , 10 , 20 },
+{ 40 , 80 , 10 , 21 },
+{ 40 , 80 , 10 , 22 },
+{ 40 , 80 , 10 , 23 },
+{ 40 , 80 , 10 , 24 },
+{ 40 , 80 , 10 , 25 },
+{ 40 , 80 , 10 , 26 },
+{ 40 , 80 , 10 , 27 },
+{ 40 , 80 , 10 , 28 },
+{ 40 , 80 , 10 , 29 },
+{ 40 , 80 , 10 , 30 },
+{ 40 , 80 , 10 , 31 },
+{ 40 , 80 , 10 , 32 },
+{ 40 , 80 , 10 , 33 },
+{ 40 , 80 , 10 , 34 },
+{ 40 , 80 , 10 , 35 },
+{ 40 , 80 , 10 , 36 },
+{ 40 , 80 , 10 , 37 },
+{ 40 , 80 , 10 , 38 },
+{ 40 , 80 , 10 , 39 },
+{ 40 , 80 , 10 , 40 },
+{ 40 , 80 , 10 , 41 },
+{ 40 , 80 , 10 , 42 },
+{ 40 , 80 , 10 , 43 },
+{ 40 , 80 , 10 , 44 },
+{ 40 , 80 , 10 , 45 },
+{ 40 , 80 , 10 , 46 },
+{ 40 , 80 , 10 , 47 },
+{ 40 , 80 , 10 , 48 },
+{ 40 , 80 , 10 , 49 },
+{ 40 , 80 , 10 , 50 },
+{ 40 , 80 , 10 , 51 },
+{ 40 , 80 , 10 , 52 },
+{ 40 , 80 , 10 , 53 },
+{ 40 , 80 , 10 , 54 },
+{ 40 , 80 , 10 , 55 },
+{ 40 , 80 , 10 , 56 },
+{ 40 , 80 , 10 , 57 },
+{ 40 , 80 , 10 , 58 },
+{ 40 , 80 , 10 , 59 },
+{ 40 , 80 , 10 , 60 },
+{ 40 , 80 , 10 , 61 },
+{ 40 , 80 , 10 , 62 },
+{ 40 , 80 , 10 , 63 },
+{ 40 , 80 , 10 , 64 },
+{ 40 , 80 , 10 , 65 },
+{ 40 , 80 , 10 , 66 },
+{ 40 , 80 , 10 , 67 },
+{ 40 , 80 , 10 , 68 },
+{ 40 , 80 , 10 , 69 },
+{ 40 , 80 , 10 , 70 },
+{ 40 , 80 , 10 , 71 },
+{ 40 , 80 , 10 , 72 },
+{ 40 , 80 , 10 , 73 },
+{ 40 , 80 , 10 , 74 },
+{ 40 , 80 , 10 , 75 },
+{ 40 , 80 , 10 , 76 },
+{ 40 , 80 , 10 , 77 },
+{ 40 , 80 , 10 , 78 },
+{ 40 , 80 , 10 , 79 },
+{ 40 , 80 , 11 , 0 },
+{ 40 , 80 , 11 , 1 },
+{ 40 , 80 , 11 , 2 },
+{ 40 , 80 , 11 , 3 },
+{ 40 , 80 , 11 , 4 },
+{ 40 , 80 , 11 , 5 },
+{ 40 , 80 , 11 , 6 },
+{ 40 , 80 , 11 , 7 },
+{ 40 , 80 , 11 , 8 },
+{ 40 , 80 , 11 , 9 },
+{ 40 , 80 , 11 , 10 },
+{ 40 , 80 , 11 , 11 },
+{ 40 , 80 , 11 , 12 },
+{ 40 , 80 , 11 , 13 },
+{ 40 , 80 , 11 , 14 },
+{ 40 , 80 , 11 , 15 },
+{ 40 , 80 , 11 , 16 },
+{ 40 , 80 , 11 , 17 },
+{ 40 , 80 , 11 , 18 },
+{ 40 , 80 , 11 , 19 },
+{ 40 , 80 , 11 , 20 },
+{ 40 , 80 , 11 , 21 },
+{ 40 , 80 , 11 , 22 },
+{ 40 , 80 , 11 , 23 },
+{ 40 , 80 , 11 , 24 },
+{ 40 , 80 , 11 , 25 },
+{ 40 , 80 , 11 , 26 },
+{ 40 , 80 , 11 , 27 },
+{ 40 , 80 , 11 , 28 },
+{ 40 , 80 , 11 , 29 },
+{ 40 , 80 , 11 , 30 },
+{ 40 , 80 , 11 , 31 },
+{ 40 , 80 , 11 , 32 },
+{ 40 , 80 , 11 , 33 },
+{ 40 , 80 , 11 , 34 },
+{ 40 , 80 , 11 , 35 },
+{ 40 , 80 , 11 , 36 },
+{ 40 , 80 , 11 , 37 },
+{ 40 , 80 , 11 , 38 },
+{ 40 , 80 , 11 , 39 },
+{ 40 , 80 , 11 , 40 },
+{ 40 , 80 , 11 , 41 },
+{ 40 , 80 , 11 , 42 },
+{ 40 , 80 , 11 , 43 },
+{ 40 , 80 , 11 , 44 },
+{ 40 , 80 , 11 , 45 },
+{ 40 , 80 , 11 , 46 },
+{ 40 , 80 , 11 , 47 },
+{ 40 , 80 , 11 , 48 },
+{ 40 , 80 , 11 , 49 },
+{ 40 , 80 , 11 , 50 },
+{ 40 , 80 , 11 , 51 },
+{ 40 , 80 , 11 , 52 },
+{ 40 , 80 , 11 , 53 },
+{ 40 , 80 , 11 , 54 },
+{ 40 , 80 , 11 , 55 },
+{ 40 , 80 , 11 , 56 },
+{ 40 , 80 , 11 , 57 },
+{ 40 , 80 , 11 , 58 },
+{ 40 , 80 , 11 , 59 },
+{ 40 , 80 , 11 , 60 },
+{ 40 , 80 , 11 , 61 },
+{ 40 , 80 , 11 , 62 },
+{ 40 , 80 , 11 , 63 },
+{ 40 , 80 , 11 , 64 },
+{ 40 , 80 , 11 , 65 },
+{ 40 , 80 , 11 , 66 },
+{ 40 , 80 , 11 , 67 },
+{ 40 , 80 , 11 , 68 },
+{ 40 , 80 , 11 , 69 },
+{ 40 , 80 , 11 , 70 },
+{ 40 , 80 , 11 , 71 },
+{ 40 , 80 , 11 , 72 },
+{ 40 , 80 , 11 , 73 },
+{ 40 , 80 , 11 , 74 },
+{ 40 , 80 , 11 , 75 },
+{ 40 , 80 , 11 , 76 },
+{ 40 , 80 , 11 , 77 },
+{ 40 , 80 , 11 , 78 },
+{ 40 , 80 , 11 , 79 },
+{ 40 , 80 , 12 , 0 },
+{ 40 , 80 , 12 , 1 },
+{ 40 , 80 , 12 , 2 },
+{ 40 , 80 , 12 , 3 },
+{ 40 , 80 , 12 , 4 },
+{ 40 , 80 , 12 , 5 },
+{ 40 , 80 , 12 , 6 },
+{ 40 , 80 , 12 , 7 },
+{ 40 , 80 , 12 , 8 },
+{ 40 , 80 , 12 , 9 },
+{ 40 , 80 , 12 , 10 },
+{ 40 , 80 , 12 , 11 },
+{ 40 , 80 , 12 , 12 },
+{ 40 , 80 , 12 , 13 },
+{ 40 , 80 , 12 , 14 },
+{ 40 , 80 , 12 , 15 },
+{ 40 , 80 , 12 , 16 },
+{ 40 , 80 , 12 , 17 },
+{ 40 , 80 , 12 , 18 },
+{ 40 , 80 , 12 , 19 },
+{ 40 , 80 , 12 , 20 },
+{ 40 , 80 , 12 , 21 },
+{ 40 , 80 , 12 , 22 },
+{ 40 , 80 , 12 , 23 },
+{ 40 , 80 , 12 , 24 },
+{ 40 , 80 , 12 , 25 },
+{ 40 , 80 , 12 , 26 },
+{ 40 , 80 , 12 , 27 },
+{ 40 , 80 , 12 , 28 },
+{ 40 , 80 , 12 , 29 },
+{ 40 , 80 , 12 , 30 },
+{ 40 , 80 , 12 , 31 },
+{ 40 , 80 , 12 , 32 },
+{ 40 , 80 , 12 , 33 },
+{ 40 , 80 , 12 , 34 },
+{ 40 , 80 , 12 , 35 },
+{ 40 , 80 , 12 , 36 },
+{ 40 , 80 , 12 , 37 },
+{ 40 , 80 , 12 , 38 },
+{ 40 , 80 , 12 , 39 },
+{ 40 , 80 , 12 , 40 },
+{ 40 , 80 , 12 , 41 },
+{ 40 , 80 , 12 , 42 },
+{ 40 , 80 , 12 , 43 },
+{ 40 , 80 , 12 , 44 },
+{ 40 , 80 , 12 , 45 },
+{ 40 , 80 , 12 , 46 },
+{ 40 , 80 , 12 , 47 },
+{ 40 , 80 , 12 , 48 },
+{ 40 , 80 , 12 , 49 },
+{ 40 , 80 , 12 , 50 },
+{ 40 , 80 , 12 , 51 },
+{ 40 , 80 , 12 , 52 },
+{ 40 , 80 , 12 , 53 },
+{ 40 , 80 , 12 , 54 },
+{ 40 , 80 , 12 , 55 },
+{ 40 , 80 , 12 , 56 },
+{ 40 , 80 , 12 , 57 },
+{ 40 , 80 , 12 , 58 },
+{ 40 , 80 , 12 , 59 },
+{ 40 , 80 , 12 , 60 },
+{ 40 , 80 , 12 , 61 },
+{ 40 , 80 , 12 , 62 },
+{ 40 , 80 , 12 , 63 },
+{ 40 , 80 , 12 , 64 },
+{ 40 , 80 , 12 , 65 },
+{ 40 , 80 , 12 , 66 },
+{ 40 , 80 , 12 , 67 },
+{ 40 , 80 , 12 , 68 },
+{ 40 , 80 , 12 , 69 },
+{ 40 , 80 , 12 , 70 },
+{ 40 , 80 , 12 , 71 },
+{ 40 , 80 , 12 , 72 },
+{ 40 , 80 , 12 , 73 },
+{ 40 , 80 , 12 , 74 },
+{ 40 , 80 , 12 , 75 },
+{ 40 , 80 , 12 , 76 },
+{ 40 , 80 , 12 , 77 },
+{ 40 , 80 , 12 , 78 },
+{ 40 , 80 , 12 , 79 },
+{ 40 , 80 , 13 , 0 },
+{ 40 , 80 , 13 , 1 },
+{ 40 , 80 , 13 , 2 },
+{ 40 , 80 , 13 , 3 },
+{ 40 , 80 , 13 , 4 },
+{ 40 , 80 , 13 , 5 },
+{ 40 , 80 , 13 , 6 },
+{ 40 , 80 , 13 , 7 },
+{ 40 , 80 , 13 , 8 },
+{ 40 , 80 , 13 , 9 },
+{ 40 , 80 , 13 , 10 },
+{ 40 , 80 , 13 , 11 },
+{ 40 , 80 , 13 , 12 },
+{ 40 , 80 , 13 , 13 },
+{ 40 , 80 , 13 , 14 },
+{ 40 , 80 , 13 , 15 },
+{ 40 , 80 , 13 , 16 },
+{ 40 , 80 , 13 , 17 },
+{ 40 , 80 , 13 , 18 },
+{ 40 , 80 , 13 , 19 },
+{ 40 , 80 , 13 , 20 },
+{ 40 , 80 , 13 , 21 },
+{ 40 , 80 , 13 , 22 },
+{ 40 , 80 , 13 , 23 },
+{ 40 , 80 , 13 , 24 },
+{ 40 , 80 , 13 , 25 },
+{ 40 , 80 , 13 , 26 },
+{ 40 , 80 , 13 , 27 },
+{ 40 , 80 , 13 , 28 },
+{ 40 , 80 , 13 , 29 },
+{ 40 , 80 , 13 , 30 },
+{ 40 , 80 , 13 , 31 },
+{ 40 , 80 , 13 , 32 },
+{ 40 , 80 , 13 , 33 },
+{ 40 , 80 , 13 , 34 },
+{ 40 , 80 , 13 , 35 },
+{ 40 , 80 , 13 , 36 },
+{ 40 , 80 , 13 , 37 },
+{ 40 , 80 , 13 , 38 },
+{ 40 , 80 , 13 , 39 },
+{ 40 , 80 , 13 , 40 },
+{ 40 , 80 , 13 , 41 },
+{ 40 , 80 , 13 , 42 },
+{ 40 , 80 , 13 , 43 },
+{ 40 , 80 , 13 , 44 },
+{ 40 , 80 , 13 , 45 },
+{ 40 , 80 , 13 , 46 },
+{ 40 , 80 , 13 , 47 },
+{ 40 , 80 , 13 , 48 },
+{ 40 , 80 , 13 , 49 },
+{ 40 , 80 , 13 , 50 },
+{ 40 , 80 , 13 , 51 },
+{ 40 , 80 , 13 , 52 },
+{ 40 , 80 , 13 , 53 },
+{ 40 , 80 , 13 , 54 },
+{ 40 , 80 , 13 , 55 },
+{ 40 , 80 , 13 , 56 },
+{ 40 , 80 , 13 , 57 },
+{ 40 , 80 , 13 , 58 },
+{ 40 , 80 , 13 , 59 },
+{ 40 , 80 , 13 , 60 },
+{ 40 , 80 , 13 , 61 },
+{ 40 , 80 , 13 , 62 },
+{ 40 , 80 , 13 , 63 },
+{ 40 , 80 , 13 , 64 },
+{ 40 , 80 , 13 , 65 },
+{ 40 , 80 , 13 , 66 },
+{ 40 , 80 , 13 , 67 },
+{ 40 , 80 , 13 , 68 },
+{ 40 , 80 , 13 , 69 },
+{ 40 , 80 , 13 , 70 },
+{ 40 , 80 , 13 , 71 },
+{ 40 , 80 , 13 , 72 },
+{ 40 , 80 , 13 , 73 },
+{ 40 , 80 , 13 , 74 },
+{ 40 , 80 , 13 , 75 },
+{ 40 , 80 , 13 , 76 },
+{ 40 , 80 , 13 , 77 },
+{ 40 , 80 , 13 , 78 },
+{ 40 , 80 , 13 , 79 },
+{ 40 , 80 , 14 , 0 },
+{ 40 , 80 , 14 , 1 },
+{ 40 , 80 , 14 , 2 },
+{ 40 , 80 , 14 , 3 },
+{ 40 , 80 , 14 , 4 },
+{ 40 , 80 , 14 , 5 },
+{ 40 , 80 , 14 , 6 },
+{ 40 , 80 , 14 , 7 },
+{ 40 , 80 , 14 , 8 },
+{ 40 , 80 , 14 , 9 },
+{ 40 , 80 , 14 , 10 },
+{ 40 , 80 , 14 , 11 },
+{ 40 , 80 , 14 , 12 },
+{ 40 , 80 , 14 , 13 },
+{ 40 , 80 , 14 , 14 },
+{ 40 , 80 , 14 , 15 },
+{ 40 , 80 , 14 , 16 },
+{ 40 , 80 , 14 , 17 },
+{ 40 , 80 , 14 , 18 },
+{ 40 , 80 , 14 , 19 },
+{ 40 , 80 , 14 , 20 },
+{ 40 , 80 , 14 , 21 },
+{ 40 , 80 , 14 , 22 },
+{ 40 , 80 , 14 , 23 },
+{ 40 , 80 , 14 , 24 },
+{ 40 , 80 , 14 , 25 },
+{ 40 , 80 , 14 , 26 },
+{ 40 , 80 , 14 , 27 },
+{ 40 , 80 , 14 , 28 },
+{ 40 , 80 , 14 , 29 },
+{ 40 , 80 , 14 , 30 },
+{ 40 , 80 , 14 , 31 },
+{ 40 , 80 , 14 , 32 },
+{ 40 , 80 , 14 , 33 },
+{ 40 , 80 , 14 , 34 },
+{ 40 , 80 , 14 , 35 },
+{ 40 , 80 , 14 , 36 },
+{ 40 , 80 , 14 , 37 },
+{ 40 , 80 , 14 , 38 },
+{ 40 , 80 , 14 , 39 },
+{ 40 , 80 , 14 , 40 },
+{ 40 , 80 , 14 , 41 },
+{ 40 , 80 , 14 , 42 },
+{ 40 , 80 , 14 , 43 },
+{ 40 , 80 , 14 , 44 },
+{ 40 , 80 , 14 , 45 },
+{ 40 , 80 , 14 , 46 },
+{ 40 , 80 , 14 , 47 },
+{ 40 , 80 , 14 , 48 },
+{ 40 , 80 , 14 , 49 },
+{ 40 , 80 , 14 , 50 },
+{ 40 , 80 , 14 , 51 },
+{ 40 , 80 , 14 , 52 },
+{ 40 , 80 , 14 , 53 },
+{ 40 , 80 , 14 , 54 },
+{ 40 , 80 , 14 , 55 },
+{ 40 , 80 , 14 , 56 },
+{ 40 , 80 , 14 , 57 },
+{ 40 , 80 , 14 , 58 },
+{ 40 , 80 , 14 , 59 },
+{ 40 , 80 , 14 , 60 },
+{ 40 , 80 , 14 , 61 },
+{ 40 , 80 , 14 , 62 },
+{ 40 , 80 , 14 , 63 },
+{ 40 , 80 , 14 , 64 },
+{ 40 , 80 , 14 , 65 },
+{ 40 , 80 , 14 , 66 },
+{ 40 , 80 , 14 , 67 },
+{ 40 , 80 , 14 , 68 },
+{ 40 , 80 , 14 , 69 },
+{ 40 , 80 , 14 , 70 },
+{ 40 , 80 , 14 , 71 },
+{ 40 , 80 , 14 , 72 },
+{ 40 , 80 , 14 , 73 },
+{ 40 , 80 , 14 , 74 },
+{ 40 , 80 , 14 , 75 },
+{ 40 , 80 , 14 , 76 },
+{ 40 , 80 , 14 , 77 },
+{ 40 , 80 , 14 , 78 },
+{ 40 , 80 , 14 , 79 },
+{ 40 , 80 , 15 , 0 },
+{ 40 , 80 , 15 , 1 },
+{ 40 , 80 , 15 , 2 },
+{ 40 , 80 , 15 , 3 },
+{ 40 , 80 , 15 , 4 },
+{ 40 , 80 , 15 , 5 },
+{ 40 , 80 , 15 , 6 },
+{ 40 , 80 , 15 , 7 },
+{ 40 , 80 , 15 , 8 },
+{ 40 , 80 , 15 , 9 },
+{ 40 , 80 , 15 , 10 },
+{ 40 , 80 , 15 , 11 },
+{ 40 , 80 , 15 , 12 },
+{ 40 , 80 , 15 , 13 },
+{ 40 , 80 , 15 , 14 },
+{ 40 , 80 , 15 , 15 },
+{ 40 , 80 , 15 , 16 },
+{ 40 , 80 , 15 , 17 },
+{ 40 , 80 , 15 , 18 },
+{ 40 , 80 , 15 , 19 },
+{ 40 , 80 , 15 , 20 },
+{ 40 , 80 , 15 , 21 },
+{ 40 , 80 , 15 , 22 },
+{ 40 , 80 , 15 , 23 },
+{ 40 , 80 , 15 , 24 },
+{ 40 , 80 , 15 , 25 },
+{ 40 , 80 , 15 , 26 },
+{ 40 , 80 , 15 , 27 },
+{ 40 , 80 , 15 , 28 },
+{ 40 , 80 , 15 , 29 },
+{ 40 , 80 , 15 , 30 },
+{ 40 , 80 , 15 , 31 },
+{ 40 , 80 , 15 , 32 },
+{ 40 , 80 , 15 , 33 },
+{ 40 , 80 , 15 , 34 },
+{ 40 , 80 , 15 , 35 },
+{ 40 , 80 , 15 , 36 },
+{ 40 , 80 , 15 , 37 },
+{ 40 , 80 , 15 , 38 },
+{ 40 , 80 , 15 , 39 },
+{ 40 , 80 , 15 , 40 },
+{ 40 , 80 , 15 , 41 },
+{ 40 , 80 , 15 , 42 },
+{ 40 , 80 , 15 , 43 },
+{ 40 , 80 , 15 , 44 },
+{ 40 , 80 , 15 , 45 },
+{ 40 , 80 , 15 , 46 },
+{ 40 , 80 , 15 , 47 },
+{ 40 , 80 , 15 , 48 },
+{ 40 , 80 , 15 , 49 },
+{ 40 , 80 , 15 , 50 },
+{ 40 , 80 , 15 , 51 },
+{ 40 , 80 , 15 , 52 },
+{ 40 , 80 , 15 , 53 },
+{ 40 , 80 , 15 , 54 },
+{ 40 , 80 , 15 , 55 },
+{ 40 , 80 , 15 , 56 },
+{ 40 , 80 , 15 , 57 },
+{ 40 , 80 , 15 , 58 },
+{ 40 , 80 , 15 , 59 },
+{ 40 , 80 , 15 , 60 },
+{ 40 , 80 , 15 , 61 },
+{ 40 , 80 , 15 , 62 },
+{ 40 , 80 , 15 , 63 },
+{ 40 , 80 , 15 , 64 },
+{ 40 , 80 , 15 , 65 },
+{ 40 , 80 , 15 , 66 },
+{ 40 , 80 , 15 , 67 },
+{ 40 , 80 , 15 , 68 },
+{ 40 , 80 , 15 , 69 },
+{ 40 , 80 , 15 , 70 },
+{ 40 , 80 , 15 , 71 },
+{ 40 , 80 , 15 , 72 },
+{ 40 , 80 , 15 , 73 },
+{ 40 , 80 , 15 , 74 },
+{ 40 , 80 , 15 , 75 },
+{ 40 , 80 , 15 , 76 },
+{ 40 , 80 , 15 , 77 },
+{ 40 , 80 , 15 , 78 },
+{ 40 , 80 , 15 , 79 },
+{ 40 , 80 , 16 , 0 },
+{ 40 , 80 , 16 , 1 },
+{ 40 , 80 , 16 , 2 },
+{ 40 , 80 , 16 , 3 },
+{ 40 , 80 , 16 , 4 },
+{ 40 , 80 , 16 , 5 },
+{ 40 , 80 , 16 , 6 },
+{ 40 , 80 , 16 , 7 },
+{ 40 , 80 , 16 , 8 },
+{ 40 , 80 , 16 , 9 },
+{ 40 , 80 , 16 , 10 },
+{ 40 , 80 , 16 , 11 },
+{ 40 , 80 , 16 , 12 },
+{ 40 , 80 , 16 , 13 },
+{ 40 , 80 , 16 , 14 },
+{ 40 , 80 , 16 , 15 },
+{ 40 , 80 , 16 , 16 },
+{ 40 , 80 , 16 , 17 },
+{ 40 , 80 , 16 , 18 },
+{ 40 , 80 , 16 , 19 },
+{ 40 , 80 , 16 , 20 },
+{ 40 , 80 , 16 , 21 },
+{ 40 , 80 , 16 , 22 },
+{ 40 , 80 , 16 , 23 },
+{ 40 , 80 , 16 , 24 },
+{ 40 , 80 , 16 , 25 },
+{ 40 , 80 , 16 , 26 },
+{ 40 , 80 , 16 , 27 },
+{ 40 , 80 , 16 , 28 },
+{ 40 , 80 , 16 , 29 },
+{ 40 , 80 , 16 , 30 },
+{ 40 , 80 , 16 , 31 },
+{ 40 , 80 , 16 , 32 },
+{ 40 , 80 , 16 , 33 },
+{ 40 , 80 , 16 , 34 },
+{ 40 , 80 , 16 , 35 },
+{ 40 , 80 , 16 , 36 },
+{ 40 , 80 , 16 , 37 },
+{ 40 , 80 , 16 , 38 },
+{ 40 , 80 , 16 , 39 },
+{ 40 , 80 , 16 , 40 },
+{ 40 , 80 , 16 , 41 },
+{ 40 , 80 , 16 , 42 },
+{ 40 , 80 , 16 , 43 },
+{ 40 , 80 , 16 , 44 },
+{ 40 , 80 , 16 , 45 },
+{ 40 , 80 , 16 , 46 },
+{ 40 , 80 , 16 , 47 },
+{ 40 , 80 , 16 , 48 },
+{ 40 , 80 , 16 , 49 },
+{ 40 , 80 , 16 , 50 },
+{ 40 , 80 , 16 , 51 },
+{ 40 , 80 , 16 , 52 },
+{ 40 , 80 , 16 , 53 },
+{ 40 , 80 , 16 , 54 },
+{ 40 , 80 , 16 , 55 },
+{ 40 , 80 , 16 , 56 },
+{ 40 , 80 , 16 , 57 },
+{ 40 , 80 , 16 , 58 },
+{ 40 , 80 , 16 , 59 },
+{ 40 , 80 , 16 , 60 },
+{ 40 , 80 , 16 , 61 },
+{ 40 , 80 , 16 , 62 },
+{ 40 , 80 , 16 , 63 },
+{ 40 , 80 , 16 , 64 },
+{ 40 , 80 , 16 , 65 },
+{ 40 , 80 , 16 , 66 },
+{ 40 , 80 , 16 , 67 },
+{ 40 , 80 , 16 , 68 },
+{ 40 , 80 , 16 , 69 },
+{ 40 , 80 , 16 , 70 },
+{ 40 , 80 , 16 , 71 },
+{ 40 , 80 , 16 , 72 },
+{ 40 , 80 , 16 , 73 },
+{ 40 , 80 , 16 , 74 },
+{ 40 , 80 , 16 , 75 },
+{ 40 , 80 , 16 , 76 },
+{ 40 , 80 , 16 , 77 },
+{ 40 , 80 , 16 , 78 },
+{ 40 , 80 , 16 , 79 },
+{ 40 , 80 , 17 , 0 },
+{ 40 , 80 , 17 , 1 },
+{ 40 , 80 , 17 , 2 },
+{ 40 , 80 , 17 , 3 },
+{ 40 , 80 , 17 , 4 },
+{ 40 , 80 , 17 , 5 },
+{ 40 , 80 , 17 , 6 },
+{ 40 , 80 , 17 , 7 },
+{ 40 , 80 , 17 , 8 },
+{ 40 , 80 , 17 , 9 },
+{ 40 , 80 , 17 , 10 },
+{ 40 , 80 , 17 , 11 },
+{ 40 , 80 , 17 , 12 },
+{ 40 , 80 , 17 , 13 },
+{ 40 , 80 , 17 , 14 },
+{ 40 , 80 , 17 , 15 },
+{ 40 , 80 , 17 , 16 },
+{ 40 , 80 , 17 , 17 },
+{ 40 , 80 , 17 , 18 },
+{ 40 , 80 , 17 , 19 },
+{ 40 , 80 , 17 , 20 },
+{ 40 , 80 , 17 , 21 },
+{ 40 , 80 , 17 , 22 },
+{ 40 , 80 , 17 , 23 },
+{ 40 , 80 , 17 , 24 },
+{ 40 , 80 , 17 , 25 },
+{ 40 , 80 , 17 , 26 },
+{ 40 , 80 , 17 , 27 },
+{ 40 , 80 , 17 , 28 },
+{ 40 , 80 , 17 , 29 },
+{ 40 , 80 , 17 , 30 },
+{ 40 , 80 , 17 , 31 },
+{ 40 , 80 , 17 , 32 },
+{ 40 , 80 , 17 , 33 },
+{ 40 , 80 , 17 , 34 },
+{ 40 , 80 , 17 , 35 },
+{ 40 , 80 , 17 , 36 },
+{ 40 , 80 , 17 , 37 },
+{ 40 , 80 , 17 , 38 },
+{ 40 , 80 , 17 , 39 },
+{ 40 , 80 , 17 , 40 },
+{ 40 , 80 , 17 , 41 },
+{ 40 , 80 , 17 , 42 },
+{ 40 , 80 , 17 , 43 },
+{ 40 , 80 , 17 , 44 },
+{ 40 , 80 , 17 , 45 },
+{ 40 , 80 , 17 , 46 },
+{ 40 , 80 , 17 , 47 },
+{ 40 , 80 , 17 , 48 },
+{ 40 , 80 , 17 , 49 },
+{ 40 , 80 , 17 , 50 },
+{ 40 , 80 , 17 , 51 },
+{ 40 , 80 , 17 , 52 },
+{ 40 , 80 , 17 , 53 },
+{ 40 , 80 , 17 , 54 },
+{ 40 , 80 , 17 , 55 },
+{ 40 , 80 , 17 , 56 },
+{ 40 , 80 , 17 , 57 },
+{ 40 , 80 , 17 , 58 },
+{ 40 , 80 , 17 , 59 },
+{ 40 , 80 , 17 , 60 },
+{ 40 , 80 , 17 , 61 },
+{ 40 , 80 , 17 , 62 },
+{ 40 , 80 , 17 , 63 },
+{ 40 , 80 , 17 , 64 },
+{ 40 , 80 , 17 , 65 },
+{ 40 , 80 , 17 , 66 },
+{ 40 , 80 , 17 , 67 },
+{ 40 , 80 , 17 , 68 },
+{ 40 , 80 , 17 , 69 },
+{ 40 , 80 , 17 , 70 },
+{ 40 , 80 , 17 , 71 },
+{ 40 , 80 , 17 , 72 },
+{ 40 , 80 , 17 , 73 },
+{ 40 , 80 , 17 , 74 },
+{ 40 , 80 , 17 , 75 },
+{ 40 , 80 , 17 , 76 },
+{ 40 , 80 , 17 , 77 },
+{ 40 , 80 , 17 , 78 },
+{ 40 , 80 , 17 , 79 },
+{ 40 , 80 , 18 , 0 },
+{ 40 , 80 , 18 , 1 },
+{ 40 , 80 , 18 , 2 },
+{ 40 , 80 , 18 , 3 },
+{ 40 , 80 , 18 , 4 },
+{ 40 , 80 , 18 , 5 },
+{ 40 , 80 , 18 , 6 },
+{ 40 , 80 , 18 , 7 },
+{ 40 , 80 , 18 , 8 },
+{ 40 , 80 , 18 , 9 },
+{ 40 , 80 , 18 , 10 },
+{ 40 , 80 , 18 , 11 },
+{ 40 , 80 , 18 , 12 },
+{ 40 , 80 , 18 , 13 },
+{ 40 , 80 , 18 , 14 },
+{ 40 , 80 , 18 , 15 },
+{ 40 , 80 , 18 , 16 },
+{ 40 , 80 , 18 , 17 },
+{ 40 , 80 , 18 , 18 },
+{ 40 , 80 , 18 , 19 },
+{ 40 , 80 , 18 , 20 },
+{ 40 , 80 , 18 , 21 },
+{ 40 , 80 , 18 , 22 },
+{ 40 , 80 , 18 , 23 },
+{ 40 , 80 , 18 , 24 },
+{ 40 , 80 , 18 , 25 },
+{ 40 , 80 , 18 , 26 },
+{ 40 , 80 , 18 , 27 },
+{ 40 , 80 , 18 , 28 },
+{ 40 , 80 , 18 , 29 },
+{ 40 , 80 , 18 , 30 },
+{ 40 , 80 , 18 , 31 },
+{ 40 , 80 , 18 , 32 },
+{ 40 , 80 , 18 , 33 },
+{ 40 , 80 , 18 , 34 },
+{ 40 , 80 , 18 , 35 },
+{ 40 , 80 , 18 , 36 },
+{ 40 , 80 , 18 , 37 },
+{ 40 , 80 , 18 , 38 },
+{ 40 , 80 , 18 , 39 },
+{ 40 , 80 , 18 , 40 },
+{ 40 , 80 , 18 , 41 },
+{ 40 , 80 , 18 , 42 },
+{ 40 , 80 , 18 , 43 },
+{ 40 , 80 , 18 , 44 },
+{ 40 , 80 , 18 , 45 },
+{ 40 , 80 , 18 , 46 },
+{ 40 , 80 , 18 , 47 },
+{ 40 , 80 , 18 , 48 },
+{ 40 , 80 , 18 , 49 },
+{ 40 , 80 , 18 , 50 },
+{ 40 , 80 , 18 , 51 },
+{ 40 , 80 , 18 , 52 },
+{ 40 , 80 , 18 , 53 },
+{ 40 , 80 , 18 , 54 },
+{ 40 , 80 , 18 , 55 },
+{ 40 , 80 , 18 , 56 },
+{ 40 , 80 , 18 , 57 },
+{ 40 , 80 , 18 , 58 },
+{ 40 , 80 , 18 , 59 },
+{ 40 , 80 , 18 , 60 },
+{ 40 , 80 , 18 , 61 },
+{ 40 , 80 , 18 , 62 },
+{ 40 , 80 , 18 , 63 },
+{ 40 , 80 , 18 , 64 },
+{ 40 , 80 , 18 , 65 },
+{ 40 , 80 , 18 , 66 },
+{ 40 , 80 , 18 , 67 },
+{ 40 , 80 , 18 , 68 },
+{ 40 , 80 , 18 , 69 },
+{ 40 , 80 , 18 , 70 },
+{ 40 , 80 , 18 , 71 },
+{ 40 , 80 , 18 , 72 },
+{ 40 , 80 , 18 , 73 },
+{ 40 , 80 , 18 , 74 },
+{ 40 , 80 , 18 , 75 },
+{ 40 , 80 , 18 , 76 },
+{ 40 , 80 , 18 , 77 },
+{ 40 , 80 , 18 , 78 },
+{ 40 , 80 , 18 , 79 },
+{ 40 , 80 , 19 , 0 },
+{ 40 , 80 , 19 , 1 },
+{ 40 , 80 , 19 , 2 },
+{ 40 , 80 , 19 , 3 },
+{ 40 , 80 , 19 , 4 },
+{ 40 , 80 , 19 , 5 },
+{ 40 , 80 , 19 , 6 },
+{ 40 , 80 , 19 , 7 },
+{ 40 , 80 , 19 , 8 },
+{ 40 , 80 , 19 , 9 },
+{ 40 , 80 , 19 , 10 },
+{ 40 , 80 , 19 , 11 },
+{ 40 , 80 , 19 , 12 },
+{ 40 , 80 , 19 , 13 },
+{ 40 , 80 , 19 , 14 },
+{ 40 , 80 , 19 , 15 },
+{ 40 , 80 , 19 , 16 },
+{ 40 , 80 , 19 , 17 },
+{ 40 , 80 , 19 , 18 },
+{ 40 , 80 , 19 , 19 },
+{ 40 , 80 , 19 , 20 },
+{ 40 , 80 , 19 , 21 },
+{ 40 , 80 , 19 , 22 },
+{ 40 , 80 , 19 , 23 },
+{ 40 , 80 , 19 , 24 },
+{ 40 , 80 , 19 , 25 },
+{ 40 , 80 , 19 , 26 },
+{ 40 , 80 , 19 , 27 },
+{ 40 , 80 , 19 , 28 },
+{ 40 , 80 , 19 , 29 },
+{ 40 , 80 , 19 , 30 },
+{ 40 , 80 , 19 , 31 },
+{ 40 , 80 , 19 , 32 },
+{ 40 , 80 , 19 , 33 },
+{ 40 , 80 , 19 , 34 },
+{ 40 , 80 , 19 , 35 },
+{ 40 , 80 , 19 , 36 },
+{ 40 , 80 , 19 , 37 },
+{ 40 , 80 , 19 , 38 },
+{ 40 , 80 , 19 , 39 },
+{ 40 , 80 , 19 , 40 },
+{ 40 , 80 , 19 , 41 },
+{ 40 , 80 , 19 , 42 },
+{ 40 , 80 , 19 , 43 },
+{ 40 , 80 , 19 , 44 },
+{ 40 , 80 , 19 , 45 },
+{ 40 , 80 , 19 , 46 },
+{ 40 , 80 , 19 , 47 },
+{ 40 , 80 , 19 , 48 },
+{ 40 , 80 , 19 , 49 },
+{ 40 , 80 , 19 , 50 },
+{ 40 , 80 , 19 , 51 },
+{ 40 , 80 , 19 , 52 },
+{ 40 , 80 , 19 , 53 },
+{ 40 , 80 , 19 , 54 },
+{ 40 , 80 , 19 , 55 },
+{ 40 , 80 , 19 , 56 },
+{ 40 , 80 , 19 , 57 },
+{ 40 , 80 , 19 , 58 },
+{ 40 , 80 , 19 , 59 },
+{ 40 , 80 , 19 , 60 },
+{ 40 , 80 , 19 , 61 },
+{ 40 , 80 , 19 , 62 },
+{ 40 , 80 , 19 , 63 },
+{ 40 , 80 , 19 , 64 },
+{ 40 , 80 , 19 , 65 },
+{ 40 , 80 , 19 , 66 },
+{ 40 , 80 , 19 , 67 },
+{ 40 , 80 , 19 , 68 },
+{ 40 , 80 , 19 , 69 },
+{ 40 , 80 , 19 , 70 },
+{ 40 , 80 , 19 , 71 },
+{ 40 , 80 , 19 , 72 },
+{ 40 , 80 , 19 , 73 },
+{ 40 , 80 , 19 , 74 },
+{ 40 , 80 , 19 , 75 },
+{ 40 , 80 , 19 , 76 },
+{ 40 , 80 , 19 , 77 },
+{ 40 , 80 , 19 , 78 },
+{ 40 , 80 , 19 , 79 },
+{ 40 , 80 , 20 , 0 },
+{ 40 , 80 , 20 , 1 },
+{ 40 , 80 , 20 , 2 },
+{ 40 , 80 , 20 , 3 },
+{ 40 , 80 , 20 , 4 },
+{ 40 , 80 , 20 , 5 },
+{ 40 , 80 , 20 , 6 },
+{ 40 , 80 , 20 , 7 },
+{ 40 , 80 , 20 , 8 },
+{ 40 , 80 , 20 , 9 },
+{ 40 , 80 , 20 , 10 },
+{ 40 , 80 , 20 , 11 },
+{ 40 , 80 , 20 , 12 },
+{ 40 , 80 , 20 , 13 },
+{ 40 , 80 , 20 , 14 },
+{ 40 , 80 , 20 , 15 },
+{ 40 , 80 , 20 , 16 },
+{ 40 , 80 , 20 , 17 },
+{ 40 , 80 , 20 , 18 },
+{ 40 , 80 , 20 , 19 },
+{ 40 , 80 , 20 , 20 },
+{ 40 , 80 , 20 , 21 },
+{ 40 , 80 , 20 , 22 },
+{ 40 , 80 , 20 , 23 },
+{ 40 , 80 , 20 , 24 },
+{ 40 , 80 , 20 , 25 },
+{ 40 , 80 , 20 , 26 },
+{ 40 , 80 , 20 , 27 },
+{ 40 , 80 , 20 , 28 },
+{ 40 , 80 , 20 , 29 },
+{ 40 , 80 , 20 , 30 },
+{ 40 , 80 , 20 , 31 },
+{ 40 , 80 , 20 , 32 },
+{ 40 , 80 , 20 , 33 },
+{ 40 , 80 , 20 , 34 },
+{ 40 , 80 , 20 , 35 },
+{ 40 , 80 , 20 , 36 },
+{ 40 , 80 , 20 , 37 },
+{ 40 , 80 , 20 , 38 },
+{ 40 , 80 , 20 , 39 },
+{ 40 , 80 , 20 , 40 },
+{ 40 , 80 , 20 , 41 },
+{ 40 , 80 , 20 , 42 },
+{ 40 , 80 , 20 , 43 },
+{ 40 , 80 , 20 , 44 },
+{ 40 , 80 , 20 , 45 },
+{ 40 , 80 , 20 , 46 },
+{ 40 , 80 , 20 , 47 },
+{ 40 , 80 , 20 , 48 },
+{ 40 , 80 , 20 , 49 },
+{ 40 , 80 , 20 , 50 },
+{ 40 , 80 , 20 , 51 },
+{ 40 , 80 , 20 , 52 },
+{ 40 , 80 , 20 , 53 },
+{ 40 , 80 , 20 , 54 },
+{ 40 , 80 , 20 , 55 },
+{ 40 , 80 , 20 , 56 },
+{ 40 , 80 , 20 , 57 },
+{ 40 , 80 , 20 , 58 },
+{ 40 , 80 , 20 , 59 },
+{ 40 , 80 , 20 , 60 },
+{ 40 , 80 , 20 , 61 },
+{ 40 , 80 , 20 , 62 },
+{ 40 , 80 , 20 , 63 },
+{ 40 , 80 , 20 , 64 },
+{ 40 , 80 , 20 , 65 },
+{ 40 , 80 , 20 , 66 },
+{ 40 , 80 , 20 , 67 },
+{ 40 , 80 , 20 , 68 },
+{ 40 , 80 , 20 , 69 },
+{ 40 , 80 , 20 , 70 },
+{ 40 , 80 , 20 , 71 },
+{ 40 , 80 , 20 , 72 },
+{ 40 , 80 , 20 , 73 },
+{ 40 , 80 , 20 , 74 },
+{ 40 , 80 , 20 , 75 },
+{ 40 , 80 , 20 , 76 },
+{ 40 , 80 , 20 , 77 },
+{ 40 , 80 , 20 , 78 },
+{ 40 , 80 , 20 , 79 },
+{ 40 , 80 , 21 , 0 },
+{ 40 , 80 , 21 , 1 },
+{ 40 , 80 , 21 , 2 },
+{ 40 , 80 , 21 , 3 },
+{ 40 , 80 , 21 , 4 },
+{ 40 , 80 , 21 , 5 },
+{ 40 , 80 , 21 , 6 },
+{ 40 , 80 , 21 , 7 },
+{ 40 , 80 , 21 , 8 },
+{ 40 , 80 , 21 , 9 },
+{ 40 , 80 , 21 , 10 },
+{ 40 , 80 , 21 , 11 },
+{ 40 , 80 , 21 , 12 },
+{ 40 , 80 , 21 , 13 },
+{ 40 , 80 , 21 , 14 },
+{ 40 , 80 , 21 , 15 },
+{ 40 , 80 , 21 , 16 },
+{ 40 , 80 , 21 , 17 },
+{ 40 , 80 , 21 , 18 },
+{ 40 , 80 , 21 , 19 },
+{ 40 , 80 , 21 , 20 },
+{ 40 , 80 , 21 , 21 },
+{ 40 , 80 , 21 , 22 },
+{ 40 , 80 , 21 , 23 },
+{ 40 , 80 , 21 , 24 },
+{ 40 , 80 , 21 , 25 },
+{ 40 , 80 , 21 , 26 },
+{ 40 , 80 , 21 , 27 },
+{ 40 , 80 , 21 , 28 },
+{ 40 , 80 , 21 , 29 },
+{ 40 , 80 , 21 , 30 },
+{ 40 , 80 , 21 , 31 },
+{ 40 , 80 , 21 , 32 },
+{ 40 , 80 , 21 , 33 },
+{ 40 , 80 , 21 , 34 },
+{ 40 , 80 , 21 , 35 },
+{ 40 , 80 , 21 , 36 },
+{ 40 , 80 , 21 , 37 },
+{ 40 , 80 , 21 , 38 },
+{ 40 , 80 , 21 , 39 },
+{ 40 , 80 , 21 , 40 },
+{ 40 , 80 , 21 , 41 },
+{ 40 , 80 , 21 , 42 },
+{ 40 , 80 , 21 , 43 },
+{ 40 , 80 , 21 , 44 },
+{ 40 , 80 , 21 , 45 },
+{ 40 , 80 , 21 , 46 },
+{ 40 , 80 , 21 , 47 },
+{ 40 , 80 , 21 , 48 },
+{ 40 , 80 , 21 , 49 },
+{ 40 , 80 , 21 , 50 },
+{ 40 , 80 , 21 , 51 },
+{ 40 , 80 , 21 , 52 },
+{ 40 , 80 , 21 , 53 },
+{ 40 , 80 , 21 , 54 },
+{ 40 , 80 , 21 , 55 },
+{ 40 , 80 , 21 , 56 },
+{ 40 , 80 , 21 , 57 },
+{ 40 , 80 , 21 , 58 },
+{ 40 , 80 , 21 , 59 },
+{ 40 , 80 , 21 , 60 },
+{ 40 , 80 , 21 , 61 },
+{ 40 , 80 , 21 , 62 },
+{ 40 , 80 , 21 , 63 },
+{ 40 , 80 , 21 , 64 },
+{ 40 , 80 , 21 , 65 },
+{ 40 , 80 , 21 , 66 },
+{ 40 , 80 , 21 , 67 },
+{ 40 , 80 , 21 , 68 },
+{ 40 , 80 , 21 , 69 },
+{ 40 , 80 , 21 , 70 },
+{ 40 , 80 , 21 , 71 },
+{ 40 , 80 , 21 , 72 },
+{ 40 , 80 , 21 , 73 },
+{ 40 , 80 , 21 , 74 },
+{ 40 , 80 , 21 , 75 },
+{ 40 , 80 , 21 , 76 },
+{ 40 , 80 , 21 , 77 },
+{ 40 , 80 , 21 , 78 },
+{ 40 , 80 , 21 , 79 },
+{ 40 , 80 , 22 , 0 },
+{ 40 , 80 , 22 , 1 },
+{ 40 , 80 , 22 , 2 },
+{ 40 , 80 , 22 , 3 },
+{ 40 , 80 , 22 , 4 },
+{ 40 , 80 , 22 , 5 },
+{ 40 , 80 , 22 , 6 },
+{ 40 , 80 , 22 , 7 },
+{ 40 , 80 , 22 , 8 },
+{ 40 , 80 , 22 , 9 },
+{ 40 , 80 , 22 , 10 },
+{ 40 , 80 , 22 , 11 },
+{ 40 , 80 , 22 , 12 },
+{ 40 , 80 , 22 , 13 },
+{ 40 , 80 , 22 , 14 },
+{ 40 , 80 , 22 , 15 },
+{ 40 , 80 , 22 , 16 },
+{ 40 , 80 , 22 , 17 },
+{ 40 , 80 , 22 , 18 },
+{ 40 , 80 , 22 , 19 },
+{ 40 , 80 , 22 , 20 },
+{ 40 , 80 , 22 , 21 },
+{ 40 , 80 , 22 , 22 },
+{ 40 , 80 , 22 , 23 },
+{ 40 , 80 , 22 , 24 },
+{ 40 , 80 , 22 , 25 },
+{ 40 , 80 , 22 , 26 },
+{ 40 , 80 , 22 , 27 },
+{ 40 , 80 , 22 , 28 },
+{ 40 , 80 , 22 , 29 },
+{ 40 , 80 , 22 , 30 },
+{ 40 , 80 , 22 , 31 },
+{ 40 , 80 , 22 , 32 },
+{ 40 , 80 , 22 , 33 },
+{ 40 , 80 , 22 , 34 },
+{ 40 , 80 , 22 , 35 },
+{ 40 , 80 , 22 , 36 },
+{ 40 , 80 , 22 , 37 },
+{ 40 , 80 , 22 , 38 },
+{ 40 , 80 , 22 , 39 },
+{ 40 , 80 , 22 , 40 },
+{ 40 , 80 , 22 , 41 },
+{ 40 , 80 , 22 , 42 },
+{ 40 , 80 , 22 , 43 },
+{ 40 , 80 , 22 , 44 },
+{ 40 , 80 , 22 , 45 },
+{ 40 , 80 , 22 , 46 },
+{ 40 , 80 , 22 , 47 },
+{ 40 , 80 , 22 , 48 },
+{ 40 , 80 , 22 , 49 },
+{ 40 , 80 , 22 , 50 },
+{ 40 , 80 , 22 , 51 },
+{ 40 , 80 , 22 , 52 },
+{ 40 , 80 , 22 , 53 },
+{ 40 , 80 , 22 , 54 },
+{ 40 , 80 , 22 , 55 },
+{ 40 , 80 , 22 , 56 },
+{ 40 , 80 , 22 , 57 },
+{ 40 , 80 , 22 , 58 },
+{ 40 , 80 , 22 , 59 },
+{ 40 , 80 , 22 , 60 },
+{ 40 , 80 , 22 , 61 },
+{ 40 , 80 , 22 , 62 },
+{ 40 , 80 , 22 , 63 },
+{ 40 , 80 , 22 , 64 },
+{ 40 , 80 , 22 , 65 },
+{ 40 , 80 , 22 , 66 },
+{ 40 , 80 , 22 , 67 },
+{ 40 , 80 , 22 , 68 },
+{ 40 , 80 , 22 , 69 },
+{ 40 , 80 , 22 , 70 },
+{ 40 , 80 , 22 , 71 },
+{ 40 , 80 , 22 , 72 },
+{ 40 , 80 , 22 , 73 },
+{ 40 , 80 , 22 , 74 },
+{ 40 , 80 , 22 , 75 },
+{ 40 , 80 , 22 , 76 },
+{ 40 , 80 , 22 , 77 },
+{ 40 , 80 , 22 , 78 },
+{ 40 , 80 , 22 , 79 },
+{ 40 , 80 , 23 , 0 },
+{ 40 , 80 , 23 , 1 },
+{ 40 , 80 , 23 , 2 },
+{ 40 , 80 , 23 , 3 },
+{ 40 , 80 , 23 , 4 },
+{ 40 , 80 , 23 , 5 },
+{ 40 , 80 , 23 , 6 },
+{ 40 , 80 , 23 , 7 },
+{ 40 , 80 , 23 , 8 },
+{ 40 , 80 , 23 , 9 },
+{ 40 , 80 , 23 , 10 },
+{ 40 , 80 , 23 , 11 },
+{ 40 , 80 , 23 , 12 },
+{ 40 , 80 , 23 , 13 },
+{ 40 , 80 , 23 , 14 },
+{ 40 , 80 , 23 , 15 },
+{ 40 , 80 , 23 , 16 },
+{ 40 , 80 , 23 , 17 },
+{ 40 , 80 , 23 , 18 },
+{ 40 , 80 , 23 , 19 },
+{ 40 , 80 , 23 , 20 },
+{ 40 , 80 , 23 , 21 },
+{ 40 , 80 , 23 , 22 },
+{ 40 , 80 , 23 , 23 },
+{ 40 , 80 , 23 , 24 },
+{ 40 , 80 , 23 , 25 },
+{ 40 , 80 , 23 , 26 },
+{ 40 , 80 , 23 , 27 },
+{ 40 , 80 , 23 , 28 },
+{ 40 , 80 , 23 , 29 },
+{ 40 , 80 , 23 , 30 },
+{ 40 , 80 , 23 , 31 },
+{ 40 , 80 , 23 , 32 },
+{ 40 , 80 , 23 , 33 },
+{ 40 , 80 , 23 , 34 },
+{ 40 , 80 , 23 , 35 },
+{ 40 , 80 , 23 , 36 },
+{ 40 , 80 , 23 , 37 },
+{ 40 , 80 , 23 , 38 },
+{ 40 , 80 , 23 , 39 },
+{ 40 , 80 , 23 , 40 },
+{ 40 , 80 , 23 , 41 },
+{ 40 , 80 , 23 , 42 },
+{ 40 , 80 , 23 , 43 },
+{ 40 , 80 , 23 , 44 },
+{ 40 , 80 , 23 , 45 },
+{ 40 , 80 , 23 , 46 },
+{ 40 , 80 , 23 , 47 },
+{ 40 , 80 , 23 , 48 },
+{ 40 , 80 , 23 , 49 },
+{ 40 , 80 , 23 , 50 },
+{ 40 , 80 , 23 , 51 },
+{ 40 , 80 , 23 , 52 },
+{ 40 , 80 , 23 , 53 },
+{ 40 , 80 , 23 , 54 },
+{ 40 , 80 , 23 , 55 },
+{ 40 , 80 , 23 , 56 },
+{ 40 , 80 , 23 , 57 },
+{ 40 , 80 , 23 , 58 },
+{ 40 , 80 , 23 , 59 },
+{ 40 , 80 , 23 , 60 },
+{ 40 , 80 , 23 , 61 },
+{ 40 , 80 , 23 , 62 },
+{ 40 , 80 , 23 , 63 },
+{ 40 , 80 , 23 , 64 },
+{ 40 , 80 , 23 , 65 },
+{ 40 , 80 , 23 , 66 },
+{ 40 , 80 , 23 , 67 },
+{ 40 , 80 , 23 , 68 },
+{ 40 , 80 , 23 , 69 },
+{ 40 , 80 , 23 , 70 },
+{ 40 , 80 , 23 , 71 },
+{ 40 , 80 , 23 , 72 },
+{ 40 , 80 , 23 , 73 },
+{ 40 , 80 , 23 , 74 },
+{ 40 , 80 , 23 , 75 },
+{ 40 , 80 , 23 , 76 },
+{ 40 , 80 , 23 , 77 },
+{ 40 , 80 , 23 , 78 },
+{ 40 , 80 , 23 , 79 },
+{ 40 , 80 , 24 , 0 },
+{ 40 , 80 , 24 , 1 },
+{ 40 , 80 , 24 , 2 },
+{ 40 , 80 , 24 , 3 },
+{ 40 , 80 , 24 , 4 },
+{ 40 , 80 , 24 , 5 },
+{ 40 , 80 , 24 , 6 },
+{ 40 , 80 , 24 , 7 },
+{ 40 , 80 , 24 , 8 },
+{ 40 , 80 , 24 , 9 },
+{ 40 , 80 , 24 , 10 },
+{ 40 , 80 , 24 , 11 },
+{ 40 , 80 , 24 , 12 },
+{ 40 , 80 , 24 , 13 },
+{ 40 , 80 , 24 , 14 },
+{ 40 , 80 , 24 , 15 },
+{ 40 , 80 , 24 , 16 },
+{ 40 , 80 , 24 , 17 },
+{ 40 , 80 , 24 , 18 },
+{ 40 , 80 , 24 , 19 },
+{ 40 , 80 , 24 , 20 },
+{ 40 , 80 , 24 , 21 },
+{ 40 , 80 , 24 , 22 },
+{ 40 , 80 , 24 , 23 },
+{ 40 , 80 , 24 , 24 },
+{ 40 , 80 , 24 , 25 },
+{ 40 , 80 , 24 , 26 },
+{ 40 , 80 , 24 , 27 },
+{ 40 , 80 , 24 , 28 },
+{ 40 , 80 , 24 , 29 },
+{ 40 , 80 , 24 , 30 },
+{ 40 , 80 , 24 , 31 },
+{ 40 , 80 , 24 , 32 },
+{ 40 , 80 , 24 , 33 },
+{ 40 , 80 , 24 , 34 },
+{ 40 , 80 , 24 , 35 },
+{ 40 , 80 , 24 , 36 },
+{ 40 , 80 , 24 , 37 },
+{ 40 , 80 , 24 , 38 },
+{ 40 , 80 , 24 , 39 },
+{ 40 , 80 , 24 , 40 },
+{ 40 , 80 , 24 , 41 },
+{ 40 , 80 , 24 , 42 },
+{ 40 , 80 , 24 , 43 },
+{ 40 , 80 , 24 , 44 },
+{ 40 , 80 , 24 , 45 },
+{ 40 , 80 , 24 , 46 },
+{ 40 , 80 , 24 , 47 },
+{ 40 , 80 , 24 , 48 },
+{ 40 , 80 , 24 , 49 },
+{ 40 , 80 , 24 , 50 },
+{ 40 , 80 , 24 , 51 },
+{ 40 , 80 , 24 , 52 },
+{ 40 , 80 , 24 , 53 },
+{ 40 , 80 , 24 , 54 },
+{ 40 , 80 , 24 , 55 },
+{ 40 , 80 , 24 , 56 },
+{ 40 , 80 , 24 , 57 },
+{ 40 , 80 , 24 , 58 },
+{ 40 , 80 , 24 , 59 },
+{ 40 , 80 , 24 , 60 },
+{ 40 , 80 , 24 , 61 },
+{ 40 , 80 , 24 , 62 },
+{ 40 , 80 , 24 , 63 },
+{ 40 , 80 , 24 , 64 },
+{ 40 , 80 , 24 , 65 },
+{ 40 , 80 , 24 , 66 },
+{ 40 , 80 , 24 , 67 },
+{ 40 , 80 , 24 , 68 },
+{ 40 , 80 , 24 , 69 },
+{ 40 , 80 , 24 , 70 },
+{ 40 , 80 , 24 , 71 },
+{ 40 , 80 , 24 , 72 },
+{ 40 , 80 , 24 , 73 },
+{ 40 , 80 , 24 , 74 },
+{ 40 , 80 , 24 , 75 },
+{ 40 , 80 , 24 , 76 },
+{ 40 , 80 , 24 , 77 },
+{ 40 , 80 , 24 , 78 },
+{ 40 , 80 , 24 , 79 },
+{ 40 , 80 , 25 , 0 },
+{ 40 , 80 , 25 , 1 },
+{ 40 , 80 , 25 , 2 },
+{ 40 , 80 , 25 , 3 },
+{ 40 , 80 , 25 , 4 },
+{ 40 , 80 , 25 , 5 },
+{ 40 , 80 , 25 , 6 },
+{ 40 , 80 , 25 , 7 },
+{ 40 , 80 , 25 , 8 },
+{ 40 , 80 , 25 , 9 },
+{ 40 , 80 , 25 , 10 },
+{ 40 , 80 , 25 , 11 },
+{ 40 , 80 , 25 , 12 },
+{ 40 , 80 , 25 , 13 },
+{ 40 , 80 , 25 , 14 },
+{ 40 , 80 , 25 , 15 },
+{ 40 , 80 , 25 , 16 },
+{ 40 , 80 , 25 , 17 },
+{ 40 , 80 , 25 , 18 },
+{ 40 , 80 , 25 , 19 },
+{ 40 , 80 , 25 , 20 },
+{ 40 , 80 , 25 , 21 },
+{ 40 , 80 , 25 , 22 },
+{ 40 , 80 , 25 , 23 },
+{ 40 , 80 , 25 , 24 },
+{ 40 , 80 , 25 , 25 },
+{ 40 , 80 , 25 , 26 },
+{ 40 , 80 , 25 , 27 },
+{ 40 , 80 , 25 , 28 },
+{ 40 , 80 , 25 , 29 },
+{ 40 , 80 , 25 , 30 },
+{ 40 , 80 , 25 , 31 },
+{ 40 , 80 , 25 , 32 },
+{ 40 , 80 , 25 , 33 },
+{ 40 , 80 , 25 , 34 },
+{ 40 , 80 , 25 , 35 },
+{ 40 , 80 , 25 , 36 },
+{ 40 , 80 , 25 , 37 },
+{ 40 , 80 , 25 , 38 },
+{ 40 , 80 , 25 , 39 },
+{ 40 , 80 , 25 , 40 },
+{ 40 , 80 , 25 , 41 },
+{ 40 , 80 , 25 , 42 },
+{ 40 , 80 , 25 , 43 },
+{ 40 , 80 , 25 , 44 },
+{ 40 , 80 , 25 , 45 },
+{ 40 , 80 , 25 , 46 },
+{ 40 , 80 , 25 , 47 },
+{ 40 , 80 , 25 , 48 },
+{ 40 , 80 , 25 , 49 },
+{ 40 , 80 , 25 , 50 },
+{ 40 , 80 , 25 , 51 },
+{ 40 , 80 , 25 , 52 },
+{ 40 , 80 , 25 , 53 },
+{ 40 , 80 , 25 , 54 },
+{ 40 , 80 , 25 , 55 },
+{ 40 , 80 , 25 , 56 },
+{ 40 , 80 , 25 , 57 },
+{ 40 , 80 , 25 , 58 },
+{ 40 , 80 , 25 , 59 },
+{ 40 , 80 , 25 , 60 },
+{ 40 , 80 , 25 , 61 },
+{ 40 , 80 , 25 , 62 },
+{ 40 , 80 , 25 , 63 },
+{ 40 , 80 , 25 , 64 },
+{ 40 , 80 , 25 , 65 },
+{ 40 , 80 , 25 , 66 },
+{ 40 , 80 , 25 , 67 },
+{ 40 , 80 , 25 , 68 },
+{ 40 , 80 , 25 , 69 },
+{ 40 , 80 , 25 , 70 },
+{ 40 , 80 , 25 , 71 },
+{ 40 , 80 , 25 , 72 },
+{ 40 , 80 , 25 , 73 },
+{ 40 , 80 , 25 , 74 },
+{ 40 , 80 , 25 , 75 },
+{ 40 , 80 , 25 , 76 },
+{ 40 , 80 , 25 , 77 },
+{ 40 , 80 , 25 , 78 },
+{ 40 , 80 , 25 , 79 },
+{ 40 , 80 , 26 , 0 },
+{ 40 , 80 , 26 , 1 },
+{ 40 , 80 , 26 , 2 },
+{ 40 , 80 , 26 , 3 },
+{ 40 , 80 , 26 , 4 },
+{ 40 , 80 , 26 , 5 },
+{ 40 , 80 , 26 , 6 },
+{ 40 , 80 , 26 , 7 },
+{ 40 , 80 , 26 , 8 },
+{ 40 , 80 , 26 , 9 },
+{ 40 , 80 , 26 , 10 },
+{ 40 , 80 , 26 , 11 },
+{ 40 , 80 , 26 , 12 },
+{ 40 , 80 , 26 , 13 },
+{ 40 , 80 , 26 , 14 },
+{ 40 , 80 , 26 , 15 },
+{ 40 , 80 , 26 , 16 },
+{ 40 , 80 , 26 , 17 },
+{ 40 , 80 , 26 , 18 },
+{ 40 , 80 , 26 , 19 },
+{ 40 , 80 , 26 , 20 },
+{ 40 , 80 , 26 , 21 },
+{ 40 , 80 , 26 , 22 },
+{ 40 , 80 , 26 , 23 },
+{ 40 , 80 , 26 , 24 },
+{ 40 , 80 , 26 , 25 },
+{ 40 , 80 , 26 , 26 },
+{ 40 , 80 , 26 , 27 },
+{ 40 , 80 , 26 , 28 },
+{ 40 , 80 , 26 , 29 },
+{ 40 , 80 , 26 , 30 },
+{ 40 , 80 , 26 , 31 },
+{ 40 , 80 , 26 , 32 },
+{ 40 , 80 , 26 , 33 },
+{ 40 , 80 , 26 , 34 },
+{ 40 , 80 , 26 , 35 },
+{ 40 , 80 , 26 , 36 },
+{ 40 , 80 , 26 , 37 },
+{ 40 , 80 , 26 , 38 },
+{ 40 , 80 , 26 , 39 },
+{ 40 , 80 , 26 , 40 },
+{ 40 , 80 , 26 , 41 },
+{ 40 , 80 , 26 , 42 },
+{ 40 , 80 , 26 , 43 },
+{ 40 , 80 , 26 , 44 },
+{ 40 , 80 , 26 , 45 },
+{ 40 , 80 , 26 , 46 },
+{ 40 , 80 , 26 , 47 },
+{ 40 , 80 , 26 , 48 },
+{ 40 , 80 , 26 , 49 },
+{ 40 , 80 , 26 , 50 },
+{ 40 , 80 , 26 , 51 },
+{ 40 , 80 , 26 , 52 },
+{ 40 , 80 , 26 , 53 },
+{ 40 , 80 , 26 , 54 },
+{ 40 , 80 , 26 , 55 },
+{ 40 , 80 , 26 , 56 },
+{ 40 , 80 , 26 , 57 },
+{ 40 , 80 , 26 , 58 },
+{ 40 , 80 , 26 , 59 },
+{ 40 , 80 , 26 , 60 },
+{ 40 , 80 , 26 , 61 },
+{ 40 , 80 , 26 , 62 },
+{ 40 , 80 , 26 , 63 },
+{ 40 , 80 , 26 , 64 },
+{ 40 , 80 , 26 , 65 },
+{ 40 , 80 , 26 , 66 },
+{ 40 , 80 , 26 , 67 },
+{ 40 , 80 , 26 , 68 },
+{ 40 , 80 , 26 , 69 },
+{ 40 , 80 , 26 , 70 },
+{ 40 , 80 , 26 , 71 },
+{ 40 , 80 , 26 , 72 },
+{ 40 , 80 , 26 , 73 },
+{ 40 , 80 , 26 , 74 },
+{ 40 , 80 , 26 , 75 },
+{ 40 , 80 , 26 , 76 },
+{ 40 , 80 , 26 , 77 },
+{ 40 , 80 , 26 , 78 },
+{ 40 , 80 , 26 , 79 },
+{ 40 , 80 , 27 , 0 },
+{ 40 , 80 , 27 , 1 },
+{ 40 , 80 , 27 , 2 },
+{ 40 , 80 , 27 , 3 },
+{ 40 , 80 , 27 , 4 },
+{ 40 , 80 , 27 , 5 },
+{ 40 , 80 , 27 , 6 },
+{ 40 , 80 , 27 , 7 },
+{ 40 , 80 , 27 , 8 },
+{ 40 , 80 , 27 , 9 },
+{ 40 , 80 , 27 , 10 },
+{ 40 , 80 , 27 , 11 },
+{ 40 , 80 , 27 , 12 },
+{ 40 , 80 , 27 , 13 },
+{ 40 , 80 , 27 , 14 },
+{ 40 , 80 , 27 , 15 },
+{ 40 , 80 , 27 , 16 },
+{ 40 , 80 , 27 , 17 },
+{ 40 , 80 , 27 , 18 },
+{ 40 , 80 , 27 , 19 },
+{ 40 , 80 , 27 , 20 },
+{ 40 , 80 , 27 , 21 },
+{ 40 , 80 , 27 , 22 },
+{ 40 , 80 , 27 , 23 },
+{ 40 , 80 , 27 , 24 },
+{ 40 , 80 , 27 , 25 },
+{ 40 , 80 , 27 , 26 },
+{ 40 , 80 , 27 , 27 },
+{ 40 , 80 , 27 , 28 },
+{ 40 , 80 , 27 , 29 },
+{ 40 , 80 , 27 , 30 },
+{ 40 , 80 , 27 , 31 },
+{ 40 , 80 , 27 , 32 },
+{ 40 , 80 , 27 , 33 },
+{ 40 , 80 , 27 , 34 },
+{ 40 , 80 , 27 , 35 },
+{ 40 , 80 , 27 , 36 },
+{ 40 , 80 , 27 , 37 },
+{ 40 , 80 , 27 , 38 },
+{ 40 , 80 , 27 , 39 },
+{ 40 , 80 , 27 , 40 },
+{ 40 , 80 , 27 , 41 },
+{ 40 , 80 , 27 , 42 },
+{ 40 , 80 , 27 , 43 },
+{ 40 , 80 , 27 , 44 },
+{ 40 , 80 , 27 , 45 },
+{ 40 , 80 , 27 , 46 },
+{ 40 , 80 , 27 , 47 },
+{ 40 , 80 , 27 , 48 },
+{ 40 , 80 , 27 , 49 },
+{ 40 , 80 , 27 , 50 },
+{ 40 , 80 , 27 , 51 },
+{ 40 , 80 , 27 , 52 },
+{ 40 , 80 , 27 , 53 },
+{ 40 , 80 , 27 , 54 },
+{ 40 , 80 , 27 , 55 },
+{ 40 , 80 , 27 , 56 },
+{ 40 , 80 , 27 , 57 },
+{ 40 , 80 , 27 , 58 },
+{ 40 , 80 , 27 , 59 },
+{ 40 , 80 , 27 , 60 },
+{ 40 , 80 , 27 , 61 },
+{ 40 , 80 , 27 , 62 },
+{ 40 , 80 , 27 , 63 },
+{ 40 , 80 , 27 , 64 },
+{ 40 , 80 , 27 , 65 },
+{ 40 , 80 , 27 , 66 },
+{ 40 , 80 , 27 , 67 },
+{ 40 , 80 , 27 , 68 },
+{ 40 , 80 , 27 , 69 },
+{ 40 , 80 , 27 , 70 },
+{ 40 , 80 , 27 , 71 },
+{ 40 , 80 , 27 , 72 },
+{ 40 , 80 , 27 , 73 },
+{ 40 , 80 , 27 , 74 },
+{ 40 , 80 , 27 , 75 },
+{ 40 , 80 , 27 , 76 },
+{ 40 , 80 , 27 , 77 },
+{ 40 , 80 , 27 , 78 },
+{ 40 , 80 , 27 , 79 },
+{ 40 , 80 , 28 , 0 },
+{ 40 , 80 , 28 , 1 },
+{ 40 , 80 , 28 , 2 },
+{ 40 , 80 , 28 , 3 },
+{ 40 , 80 , 28 , 4 },
+{ 40 , 80 , 28 , 5 },
+{ 40 , 80 , 28 , 6 },
+{ 40 , 80 , 28 , 7 },
+{ 40 , 80 , 28 , 8 },
+{ 40 , 80 , 28 , 9 },
+{ 40 , 80 , 28 , 10 },
+{ 40 , 80 , 28 , 11 },
+{ 40 , 80 , 28 , 12 },
+{ 40 , 80 , 28 , 13 },
+{ 40 , 80 , 28 , 14 },
+{ 40 , 80 , 28 , 15 },
+{ 40 , 80 , 28 , 16 },
+{ 40 , 80 , 28 , 17 },
+{ 40 , 80 , 28 , 18 },
+{ 40 , 80 , 28 , 19 },
+{ 40 , 80 , 28 , 20 },
+{ 40 , 80 , 28 , 21 },
+{ 40 , 80 , 28 , 22 },
+{ 40 , 80 , 28 , 23 },
+{ 40 , 80 , 28 , 24 },
+{ 40 , 80 , 28 , 25 },
+{ 40 , 80 , 28 , 26 },
+{ 40 , 80 , 28 , 27 },
+{ 40 , 80 , 28 , 28 },
+{ 40 , 80 , 28 , 29 },
+{ 40 , 80 , 28 , 30 },
+{ 40 , 80 , 28 , 31 },
+{ 40 , 80 , 28 , 32 },
+{ 40 , 80 , 28 , 33 },
+{ 40 , 80 , 28 , 34 },
+{ 40 , 80 , 28 , 35 },
+{ 40 , 80 , 28 , 36 },
+{ 40 , 80 , 28 , 37 },
+{ 40 , 80 , 28 , 38 },
+{ 40 , 80 , 28 , 39 },
+{ 40 , 80 , 28 , 40 },
+{ 40 , 80 , 28 , 41 },
+{ 40 , 80 , 28 , 42 },
+{ 40 , 80 , 28 , 43 },
+{ 40 , 80 , 28 , 44 },
+{ 40 , 80 , 28 , 45 },
+{ 40 , 80 , 28 , 46 },
+{ 40 , 80 , 28 , 47 },
+{ 40 , 80 , 28 , 48 },
+{ 40 , 80 , 28 , 49 },
+{ 40 , 80 , 28 , 50 },
+{ 40 , 80 , 28 , 51 },
+{ 40 , 80 , 28 , 52 },
+{ 40 , 80 , 28 , 53 },
+{ 40 , 80 , 28 , 54 },
+{ 40 , 80 , 28 , 55 },
+{ 40 , 80 , 28 , 56 },
+{ 40 , 80 , 28 , 57 },
+{ 40 , 80 , 28 , 58 },
+{ 40 , 80 , 28 , 59 },
+{ 40 , 80 , 28 , 60 },
+{ 40 , 80 , 28 , 61 },
+{ 40 , 80 , 28 , 62 },
+{ 40 , 80 , 28 , 63 },
+{ 40 , 80 , 28 , 64 },
+{ 40 , 80 , 28 , 65 },
+{ 40 , 80 , 28 , 66 },
+{ 40 , 80 , 28 , 67 },
+{ 40 , 80 , 28 , 68 },
+{ 40 , 80 , 28 , 69 },
+{ 40 , 80 , 28 , 70 },
+{ 40 , 80 , 28 , 71 },
+{ 40 , 80 , 28 , 72 },
+{ 40 , 80 , 28 , 73 },
+{ 40 , 80 , 28 , 74 },
+{ 40 , 80 , 28 , 75 },
+{ 40 , 80 , 28 , 76 },
+{ 40 , 80 , 28 , 77 },
+{ 40 , 80 , 28 , 78 },
+{ 40 , 80 , 28 , 79 },
+{ 40 , 80 , 29 , 0 },
+{ 40 , 80 , 29 , 1 },
+{ 40 , 80 , 29 , 2 },
+{ 40 , 80 , 29 , 3 },
+{ 40 , 80 , 29 , 4 },
+{ 40 , 80 , 29 , 5 },
+{ 40 , 80 , 29 , 6 },
+{ 40 , 80 , 29 , 7 },
+{ 40 , 80 , 29 , 8 },
+{ 40 , 80 , 29 , 9 },
+{ 40 , 80 , 29 , 10 },
+{ 40 , 80 , 29 , 11 },
+{ 40 , 80 , 29 , 12 },
+{ 40 , 80 , 29 , 13 },
+{ 40 , 80 , 29 , 14 },
+{ 40 , 80 , 29 , 15 },
+{ 40 , 80 , 29 , 16 },
+{ 40 , 80 , 29 , 17 },
+{ 40 , 80 , 29 , 18 },
+{ 40 , 80 , 29 , 19 },
+{ 40 , 80 , 29 , 20 },
+{ 40 , 80 , 29 , 21 },
+{ 40 , 80 , 29 , 22 },
+{ 40 , 80 , 29 , 23 },
+{ 40 , 80 , 29 , 24 },
+{ 40 , 80 , 29 , 25 },
+{ 40 , 80 , 29 , 26 },
+{ 40 , 80 , 29 , 27 },
+{ 40 , 80 , 29 , 28 },
+{ 40 , 80 , 29 , 29 },
+{ 40 , 80 , 29 , 30 },
+{ 40 , 80 , 29 , 31 },
+{ 40 , 80 , 29 , 32 },
+{ 40 , 80 , 29 , 33 },
+{ 40 , 80 , 29 , 34 },
+{ 40 , 80 , 29 , 35 },
+{ 40 , 80 , 29 , 36 },
+{ 40 , 80 , 29 , 37 },
+{ 40 , 80 , 29 , 38 },
+{ 40 , 80 , 29 , 39 },
+{ 40 , 80 , 29 , 40 },
+{ 40 , 80 , 29 , 41 },
+{ 40 , 80 , 29 , 42 },
+{ 40 , 80 , 29 , 43 },
+{ 40 , 80 , 29 , 44 },
+{ 40 , 80 , 29 , 45 },
+{ 40 , 80 , 29 , 46 },
+{ 40 , 80 , 29 , 47 },
+{ 40 , 80 , 29 , 48 },
+{ 40 , 80 , 29 , 49 },
+{ 40 , 80 , 29 , 50 },
+{ 40 , 80 , 29 , 51 },
+{ 40 , 80 , 29 , 52 },
+{ 40 , 80 , 29 , 53 },
+{ 40 , 80 , 29 , 54 },
+{ 40 , 80 , 29 , 55 },
+{ 40 , 80 , 29 , 56 },
+{ 40 , 80 , 29 , 57 },
+{ 40 , 80 , 29 , 58 },
+{ 40 , 80 , 29 , 59 },
+{ 40 , 80 , 29 , 60 },
+{ 40 , 80 , 29 , 61 },
+{ 40 , 80 , 29 , 62 },
+{ 40 , 80 , 29 , 63 },
+{ 40 , 80 , 29 , 64 },
+{ 40 , 80 , 29 , 65 },
+{ 40 , 80 , 29 , 66 },
+{ 40 , 80 , 29 , 67 },
+{ 40 , 80 , 29 , 68 },
+{ 40 , 80 , 29 , 69 },
+{ 40 , 80 , 29 , 70 },
+{ 40 , 80 , 29 , 71 },
+{ 40 , 80 , 29 , 72 },
+{ 40 , 80 , 29 , 73 },
+{ 40 , 80 , 29 , 74 },
+{ 40 , 80 , 29 , 75 },
+{ 40 , 80 , 29 , 76 },
+{ 40 , 80 , 29 , 77 },
+{ 40 , 80 , 29 , 78 },
+{ 40 , 80 , 29 , 79 },
+{ 40 , 80 , 30 , 0 },
+{ 40 , 80 , 30 , 1 },
+{ 40 , 80 , 30 , 2 },
+{ 40 , 80 , 30 , 3 },
+{ 40 , 80 , 30 , 4 },
+{ 40 , 80 , 30 , 5 },
+{ 40 , 80 , 30 , 6 },
+{ 40 , 80 , 30 , 7 },
+{ 40 , 80 , 30 , 8 },
+{ 40 , 80 , 30 , 9 },
+{ 40 , 80 , 30 , 10 },
+{ 40 , 80 , 30 , 11 },
+{ 40 , 80 , 30 , 12 },
+{ 40 , 80 , 30 , 13 },
+{ 40 , 80 , 30 , 14 },
+{ 40 , 80 , 30 , 15 },
+{ 40 , 80 , 30 , 16 },
+{ 40 , 80 , 30 , 17 },
+{ 40 , 80 , 30 , 18 },
+{ 40 , 80 , 30 , 19 },
+{ 40 , 80 , 30 , 20 },
+{ 40 , 80 , 30 , 21 },
+{ 40 , 80 , 30 , 22 },
+{ 40 , 80 , 30 , 23 },
+{ 40 , 80 , 30 , 24 },
+{ 40 , 80 , 30 , 25 },
+{ 40 , 80 , 30 , 26 },
+{ 40 , 80 , 30 , 27 },
+{ 40 , 80 , 30 , 28 },
+{ 40 , 80 , 30 , 29 },
+{ 40 , 80 , 30 , 30 },
+{ 40 , 80 , 30 , 31 },
+{ 40 , 80 , 30 , 32 },
+{ 40 , 80 , 30 , 33 },
+{ 40 , 80 , 30 , 34 },
+{ 40 , 80 , 30 , 35 },
+{ 40 , 80 , 30 , 36 },
+{ 40 , 80 , 30 , 37 },
+{ 40 , 80 , 30 , 38 },
+{ 40 , 80 , 30 , 39 },
+{ 40 , 80 , 30 , 40 },
+{ 40 , 80 , 30 , 41 },
+{ 40 , 80 , 30 , 42 },
+{ 40 , 80 , 30 , 43 },
+{ 40 , 80 , 30 , 44 },
+{ 40 , 80 , 30 , 45 },
+{ 40 , 80 , 30 , 46 },
+{ 40 , 80 , 30 , 47 },
+{ 40 , 80 , 30 , 48 },
+{ 40 , 80 , 30 , 49 },
+{ 40 , 80 , 30 , 50 },
+{ 40 , 80 , 30 , 51 },
+{ 40 , 80 , 30 , 52 },
+{ 40 , 80 , 30 , 53 },
+{ 40 , 80 , 30 , 54 },
+{ 40 , 80 , 30 , 55 },
+{ 40 , 80 , 30 , 56 },
+{ 40 , 80 , 30 , 57 },
+{ 40 , 80 , 30 , 58 },
+{ 40 , 80 , 30 , 59 },
+{ 40 , 80 , 30 , 60 },
+{ 40 , 80 , 30 , 61 },
+{ 40 , 80 , 30 , 62 },
+{ 40 , 80 , 30 , 63 },
+{ 40 , 80 , 30 , 64 },
+{ 40 , 80 , 30 , 65 },
+{ 40 , 80 , 30 , 66 },
+{ 40 , 80 , 30 , 67 },
+{ 40 , 80 , 30 , 68 },
+{ 40 , 80 , 30 , 69 },
+{ 40 , 80 , 30 , 70 },
+{ 40 , 80 , 30 , 71 },
+{ 40 , 80 , 30 , 72 },
+{ 40 , 80 , 30 , 73 },
+{ 40 , 80 , 30 , 74 },
+{ 40 , 80 , 30 , 75 },
+{ 40 , 80 , 30 , 76 },
+{ 40 , 80 , 30 , 77 },
+{ 40 , 80 , 30 , 78 },
+{ 40 , 80 , 30 , 79 },
+{ 40 , 80 , 31 , 0 },
+{ 40 , 80 , 31 , 1 },
+{ 40 , 80 , 31 , 2 },
+{ 40 , 80 , 31 , 3 },
+{ 40 , 80 , 31 , 4 },
+{ 40 , 80 , 31 , 5 },
+{ 40 , 80 , 31 , 6 },
+{ 40 , 80 , 31 , 7 },
+{ 40 , 80 , 31 , 8 },
+{ 40 , 80 , 31 , 9 },
+{ 40 , 80 , 31 , 10 },
+{ 40 , 80 , 31 , 11 },
+{ 40 , 80 , 31 , 12 },
+{ 40 , 80 , 31 , 13 },
+{ 40 , 80 , 31 , 14 },
+{ 40 , 80 , 31 , 15 },
+{ 40 , 80 , 31 , 16 },
+{ 40 , 80 , 31 , 17 },
+{ 40 , 80 , 31 , 18 },
+{ 40 , 80 , 31 , 19 },
+{ 40 , 80 , 31 , 20 },
+{ 40 , 80 , 31 , 21 },
+{ 40 , 80 , 31 , 22 },
+{ 40 , 80 , 31 , 23 },
+{ 40 , 80 , 31 , 24 },
+{ 40 , 80 , 31 , 25 },
+{ 40 , 80 , 31 , 26 },
+{ 40 , 80 , 31 , 27 },
+{ 40 , 80 , 31 , 28 },
+{ 40 , 80 , 31 , 29 },
+{ 40 , 80 , 31 , 30 },
+{ 40 , 80 , 31 , 31 },
+{ 40 , 80 , 31 , 32 },
+{ 40 , 80 , 31 , 33 },
+{ 40 , 80 , 31 , 34 },
+{ 40 , 80 , 31 , 35 },
+{ 40 , 80 , 31 , 36 },
+{ 40 , 80 , 31 , 37 },
+{ 40 , 80 , 31 , 38 },
+{ 40 , 80 , 31 , 39 },
+{ 40 , 80 , 31 , 40 },
+{ 40 , 80 , 31 , 41 },
+{ 40 , 80 , 31 , 42 },
+{ 40 , 80 , 31 , 43 },
+{ 40 , 80 , 31 , 44 },
+{ 40 , 80 , 31 , 45 },
+{ 40 , 80 , 31 , 46 },
+{ 40 , 80 , 31 , 47 },
+{ 40 , 80 , 31 , 48 },
+{ 40 , 80 , 31 , 49 },
+{ 40 , 80 , 31 , 50 },
+{ 40 , 80 , 31 , 51 },
+{ 40 , 80 , 31 , 52 },
+{ 40 , 80 , 31 , 53 },
+{ 40 , 80 , 31 , 54 },
+{ 40 , 80 , 31 , 55 },
+{ 40 , 80 , 31 , 56 },
+{ 40 , 80 , 31 , 57 },
+{ 40 , 80 , 31 , 58 },
+{ 40 , 80 , 31 , 59 },
+{ 40 , 80 , 31 , 60 },
+{ 40 , 80 , 31 , 61 },
+{ 40 , 80 , 31 , 62 },
+{ 40 , 80 , 31 , 63 },
+{ 40 , 80 , 31 , 64 },
+{ 40 , 80 , 31 , 65 },
+{ 40 , 80 , 31 , 66 },
+{ 40 , 80 , 31 , 67 },
+{ 40 , 80 , 31 , 68 },
+{ 40 , 80 , 31 , 69 },
+{ 40 , 80 , 31 , 70 },
+{ 40 , 80 , 31 , 71 },
+{ 40 , 80 , 31 , 72 },
+{ 40 , 80 , 31 , 73 },
+{ 40 , 80 , 31 , 74 },
+{ 40 , 80 , 31 , 75 },
+{ 40 , 80 , 31 , 76 },
+{ 40 , 80 , 31 , 77 },
+{ 40 , 80 , 31 , 78 },
+{ 40 , 80 , 31 , 79 },
+{ 40 , 80 , 32 , 0 },
+{ 40 , 80 , 32 , 1 },
+{ 40 , 80 , 32 , 2 },
+{ 40 , 80 , 32 , 3 },
+{ 40 , 80 , 32 , 4 },
+{ 40 , 80 , 32 , 5 },
+{ 40 , 80 , 32 , 6 },
+{ 40 , 80 , 32 , 7 },
+{ 40 , 80 , 32 , 8 },
+{ 40 , 80 , 32 , 9 },
+{ 40 , 80 , 32 , 10 },
+{ 40 , 80 , 32 , 11 },
+{ 40 , 80 , 32 , 12 },
+{ 40 , 80 , 32 , 13 },
+{ 40 , 80 , 32 , 14 },
+{ 40 , 80 , 32 , 15 },
+{ 40 , 80 , 32 , 16 },
+{ 40 , 80 , 32 , 17 },
+{ 40 , 80 , 32 , 18 },
+{ 40 , 80 , 32 , 19 },
+{ 40 , 80 , 32 , 20 },
+{ 40 , 80 , 32 , 21 },
+{ 40 , 80 , 32 , 22 },
+{ 40 , 80 , 32 , 23 },
+{ 40 , 80 , 32 , 24 },
+{ 40 , 80 , 32 , 25 },
+{ 40 , 80 , 32 , 26 },
+{ 40 , 80 , 32 , 27 },
+{ 40 , 80 , 32 , 28 },
+{ 40 , 80 , 32 , 29 },
+{ 40 , 80 , 32 , 30 },
+{ 40 , 80 , 32 , 31 },
+{ 40 , 80 , 32 , 32 },
+{ 40 , 80 , 32 , 33 },
+{ 40 , 80 , 32 , 34 },
+{ 40 , 80 , 32 , 35 },
+{ 40 , 80 , 32 , 36 },
+{ 40 , 80 , 32 , 37 },
+{ 40 , 80 , 32 , 38 },
+{ 40 , 80 , 32 , 39 },
+{ 40 , 80 , 32 , 40 },
+{ 40 , 80 , 32 , 41 },
+{ 40 , 80 , 32 , 42 },
+{ 40 , 80 , 32 , 43 },
+{ 40 , 80 , 32 , 44 },
+{ 40 , 80 , 32 , 45 },
+{ 40 , 80 , 32 , 46 },
+{ 40 , 80 , 32 , 47 },
+{ 40 , 80 , 32 , 48 },
+{ 40 , 80 , 32 , 49 },
+{ 40 , 80 , 32 , 50 },
+{ 40 , 80 , 32 , 51 },
+{ 40 , 80 , 32 , 52 },
+{ 40 , 80 , 32 , 53 },
+{ 40 , 80 , 32 , 54 },
+{ 40 , 80 , 32 , 55 },
+{ 40 , 80 , 32 , 56 },
+{ 40 , 80 , 32 , 57 },
+{ 40 , 80 , 32 , 58 },
+{ 40 , 80 , 32 , 59 },
+{ 40 , 80 , 32 , 60 },
+{ 40 , 80 , 32 , 61 },
+{ 40 , 80 , 32 , 62 },
+{ 40 , 80 , 32 , 63 },
+{ 40 , 80 , 32 , 64 },
+{ 40 , 80 , 32 , 65 },
+{ 40 , 80 , 32 , 66 },
+{ 40 , 80 , 32 , 67 },
+{ 40 , 80 , 32 , 68 },
+{ 40 , 80 , 32 , 69 },
+{ 40 , 80 , 32 , 70 },
+{ 40 , 80 , 32 , 71 },
+{ 40 , 80 , 32 , 72 },
+{ 40 , 80 , 32 , 73 },
+{ 40 , 80 , 32 , 74 },
+{ 40 , 80 , 32 , 75 },
+{ 40 , 80 , 32 , 76 },
+{ 40 , 80 , 32 , 77 },
+{ 40 , 80 , 32 , 78 },
+{ 40 , 80 , 32 , 79 },
+{ 40 , 80 , 33 , 0 },
+{ 40 , 80 , 33 , 1 },
+{ 40 , 80 , 33 , 2 },
+{ 40 , 80 , 33 , 3 },
+{ 40 , 80 , 33 , 4 },
+{ 40 , 80 , 33 , 5 },
+{ 40 , 80 , 33 , 6 },
+{ 40 , 80 , 33 , 7 },
+{ 40 , 80 , 33 , 8 },
+{ 40 , 80 , 33 , 9 },
+{ 40 , 80 , 33 , 10 },
+{ 40 , 80 , 33 , 11 },
+{ 40 , 80 , 33 , 12 },
+{ 40 , 80 , 33 , 13 },
+{ 40 , 80 , 33 , 14 },
+{ 40 , 80 , 33 , 15 },
+{ 40 , 80 , 33 , 16 },
+{ 40 , 80 , 33 , 17 },
+{ 40 , 80 , 33 , 18 },
+{ 40 , 80 , 33 , 19 },
+{ 40 , 80 , 33 , 20 },
+{ 40 , 80 , 33 , 21 },
+{ 40 , 80 , 33 , 22 },
+{ 40 , 80 , 33 , 23 },
+{ 40 , 80 , 33 , 24 },
+{ 40 , 80 , 33 , 25 },
+{ 40 , 80 , 33 , 26 },
+{ 40 , 80 , 33 , 27 },
+{ 40 , 80 , 33 , 28 },
+{ 40 , 80 , 33 , 29 },
+{ 40 , 80 , 33 , 30 },
+{ 40 , 80 , 33 , 31 },
+{ 40 , 80 , 33 , 32 },
+{ 40 , 80 , 33 , 33 },
+{ 40 , 80 , 33 , 34 },
+{ 40 , 80 , 33 , 35 },
+{ 40 , 80 , 33 , 36 },
+{ 40 , 80 , 33 , 37 },
+{ 40 , 80 , 33 , 38 },
+{ 40 , 80 , 33 , 39 },
+{ 40 , 80 , 33 , 40 },
+{ 40 , 80 , 33 , 41 },
+{ 40 , 80 , 33 , 42 },
+{ 40 , 80 , 33 , 43 },
+{ 40 , 80 , 33 , 44 },
+{ 40 , 80 , 33 , 45 },
+{ 40 , 80 , 33 , 46 },
+{ 40 , 80 , 33 , 47 },
+{ 40 , 80 , 33 , 48 },
+{ 40 , 80 , 33 , 49 },
+{ 40 , 80 , 33 , 50 },
+{ 40 , 80 , 33 , 51 },
+{ 40 , 80 , 33 , 52 },
+{ 40 , 80 , 33 , 53 },
+{ 40 , 80 , 33 , 54 },
+{ 40 , 80 , 33 , 55 },
+{ 40 , 80 , 33 , 56 },
+{ 40 , 80 , 33 , 57 },
+{ 40 , 80 , 33 , 58 },
+{ 40 , 80 , 33 , 59 },
+{ 40 , 80 , 33 , 60 },
+{ 40 , 80 , 33 , 61 },
+{ 40 , 80 , 33 , 62 },
+{ 40 , 80 , 33 , 63 },
+{ 40 , 80 , 33 , 64 },
+{ 40 , 80 , 33 , 65 },
+{ 40 , 80 , 33 , 66 },
+{ 40 , 80 , 33 , 67 },
+{ 40 , 80 , 33 , 68 },
+{ 40 , 80 , 33 , 69 },
+{ 40 , 80 , 33 , 70 },
+{ 40 , 80 , 33 , 71 },
+{ 40 , 80 , 33 , 72 },
+{ 40 , 80 , 33 , 73 },
+{ 40 , 80 , 33 , 74 },
+{ 40 , 80 , 33 , 75 },
+{ 40 , 80 , 33 , 76 },
+{ 40 , 80 , 33 , 77 },
+{ 40 , 80 , 33 , 78 },
+{ 40 , 80 , 33 , 79 },
+{ 40 , 80 , 34 , 0 },
+{ 40 , 80 , 34 , 1 },
+{ 40 , 80 , 34 , 2 },
+{ 40 , 80 , 34 , 3 },
+{ 40 , 80 , 34 , 4 },
+{ 40 , 80 , 34 , 5 },
+{ 40 , 80 , 34 , 6 },
+{ 40 , 80 , 34 , 7 },
+{ 40 , 80 , 34 , 8 },
+{ 40 , 80 , 34 , 9 },
+{ 40 , 80 , 34 , 10 },
+{ 40 , 80 , 34 , 11 },
+{ 40 , 80 , 34 , 12 },
+{ 40 , 80 , 34 , 13 },
+{ 40 , 80 , 34 , 14 },
+{ 40 , 80 , 34 , 15 },
+{ 40 , 80 , 34 , 16 },
+{ 40 , 80 , 34 , 17 },
+{ 40 , 80 , 34 , 18 },
+{ 40 , 80 , 34 , 19 },
+{ 40 , 80 , 34 , 20 },
+{ 40 , 80 , 34 , 21 },
+{ 40 , 80 , 34 , 22 },
+{ 40 , 80 , 34 , 23 },
+{ 40 , 80 , 34 , 24 },
+{ 40 , 80 , 34 , 25 },
+{ 40 , 80 , 34 , 26 },
+{ 40 , 80 , 34 , 27 },
+{ 40 , 80 , 34 , 28 },
+{ 40 , 80 , 34 , 29 },
+{ 40 , 80 , 34 , 30 },
+{ 40 , 80 , 34 , 31 },
+{ 40 , 80 , 34 , 32 },
+{ 40 , 80 , 34 , 33 },
+{ 40 , 80 , 34 , 34 },
+{ 40 , 80 , 34 , 35 },
+{ 40 , 80 , 34 , 36 },
+{ 40 , 80 , 34 , 37 },
+{ 40 , 80 , 34 , 38 },
+{ 40 , 80 , 34 , 39 },
+{ 40 , 80 , 34 , 40 },
+{ 40 , 80 , 34 , 41 },
+{ 40 , 80 , 34 , 42 },
+{ 40 , 80 , 34 , 43 },
+{ 40 , 80 , 34 , 44 },
+{ 40 , 80 , 34 , 45 },
+{ 40 , 80 , 34 , 46 },
+{ 40 , 80 , 34 , 47 },
+{ 40 , 80 , 34 , 48 },
+{ 40 , 80 , 34 , 49 },
+{ 40 , 80 , 34 , 50 },
+{ 40 , 80 , 34 , 51 },
+{ 40 , 80 , 34 , 52 },
+{ 40 , 80 , 34 , 53 },
+{ 40 , 80 , 34 , 54 },
+{ 40 , 80 , 34 , 55 },
+{ 40 , 80 , 34 , 56 },
+{ 40 , 80 , 34 , 57 },
+{ 40 , 80 , 34 , 58 },
+{ 40 , 80 , 34 , 59 },
+{ 40 , 80 , 34 , 60 },
+{ 40 , 80 , 34 , 61 },
+{ 40 , 80 , 34 , 62 },
+{ 40 , 80 , 34 , 63 },
+{ 40 , 80 , 34 , 64 },
+{ 40 , 80 , 34 , 65 },
+{ 40 , 80 , 34 , 66 },
+{ 40 , 80 , 34 , 67 },
+{ 40 , 80 , 34 , 68 },
+{ 40 , 80 , 34 , 69 },
+{ 40 , 80 , 34 , 70 },
+{ 40 , 80 , 34 , 71 },
+{ 40 , 80 , 34 , 72 },
+{ 40 , 80 , 34 , 73 },
+{ 40 , 80 , 34 , 74 },
+{ 40 , 80 , 34 , 75 },
+{ 40 , 80 , 34 , 76 },
+{ 40 , 80 , 34 , 77 },
+{ 40 , 80 , 34 , 78 },
+{ 40 , 80 , 34 , 79 },
+{ 40 , 80 , 35 , 0 },
+{ 40 , 80 , 35 , 1 },
+{ 40 , 80 , 35 , 2 },
+{ 40 , 80 , 35 , 3 },
+{ 40 , 80 , 35 , 4 },
+{ 40 , 80 , 35 , 5 },
+{ 40 , 80 , 35 , 6 },
+{ 40 , 80 , 35 , 7 },
+{ 40 , 80 , 35 , 8 },
+{ 40 , 80 , 35 , 9 },
+{ 40 , 80 , 35 , 10 },
+{ 40 , 80 , 35 , 11 },
+{ 40 , 80 , 35 , 12 },
+{ 40 , 80 , 35 , 13 },
+{ 40 , 80 , 35 , 14 },
+{ 40 , 80 , 35 , 15 },
+{ 40 , 80 , 35 , 16 },
+{ 40 , 80 , 35 , 17 },
+{ 40 , 80 , 35 , 18 },
+{ 40 , 80 , 35 , 19 },
+{ 40 , 80 , 35 , 20 },
+{ 40 , 80 , 35 , 21 },
+{ 40 , 80 , 35 , 22 },
+{ 40 , 80 , 35 , 23 },
+{ 40 , 80 , 35 , 24 },
+{ 40 , 80 , 35 , 25 },
+{ 40 , 80 , 35 , 26 },
+{ 40 , 80 , 35 , 27 },
+{ 40 , 80 , 35 , 28 },
+{ 40 , 80 , 35 , 29 },
+{ 40 , 80 , 35 , 30 },
+{ 40 , 80 , 35 , 31 },
+{ 40 , 80 , 35 , 32 },
+{ 40 , 80 , 35 , 33 },
+{ 40 , 80 , 35 , 34 },
+{ 40 , 80 , 35 , 35 },
+{ 40 , 80 , 35 , 36 },
+{ 40 , 80 , 35 , 37 },
+{ 40 , 80 , 35 , 38 },
+{ 40 , 80 , 35 , 39 },
+{ 40 , 80 , 35 , 40 },
+{ 40 , 80 , 35 , 41 },
+{ 40 , 80 , 35 , 42 },
+{ 40 , 80 , 35 , 43 },
+{ 40 , 80 , 35 , 44 },
+{ 40 , 80 , 35 , 45 },
+{ 40 , 80 , 35 , 46 },
+{ 40 , 80 , 35 , 47 },
+{ 40 , 80 , 35 , 48 },
+{ 40 , 80 , 35 , 49 },
+{ 40 , 80 , 35 , 50 },
+{ 40 , 80 , 35 , 51 },
+{ 40 , 80 , 35 , 52 },
+{ 40 , 80 , 35 , 53 },
+{ 40 , 80 , 35 , 54 },
+{ 40 , 80 , 35 , 55 },
+{ 40 , 80 , 35 , 56 },
+{ 40 , 80 , 35 , 57 },
+{ 40 , 80 , 35 , 58 },
+{ 40 , 80 , 35 , 59 },
+{ 40 , 80 , 35 , 60 },
+{ 40 , 80 , 35 , 61 },
+{ 40 , 80 , 35 , 62 },
+{ 40 , 80 , 35 , 63 },
+{ 40 , 80 , 35 , 64 },
+{ 40 , 80 , 35 , 65 },
+{ 40 , 80 , 35 , 66 },
+{ 40 , 80 , 35 , 67 },
+{ 40 , 80 , 35 , 68 },
+{ 40 , 80 , 35 , 69 },
+{ 40 , 80 , 35 , 70 },
+{ 40 , 80 , 35 , 71 },
+{ 40 , 80 , 35 , 72 },
+{ 40 , 80 , 35 , 73 },
+{ 40 , 80 , 35 , 74 },
+{ 40 , 80 , 35 , 75 },
+{ 40 , 80 , 35 , 76 },
+{ 40 , 80 , 35 , 77 },
+{ 40 , 80 , 35 , 78 },
+{ 40 , 80 , 35 , 79 },
+{ 40 , 80 , 36 , 0 },
+{ 40 , 80 , 36 , 1 },
+{ 40 , 80 , 36 , 2 },
+{ 40 , 80 , 36 , 3 },
+{ 40 , 80 , 36 , 4 },
+{ 40 , 80 , 36 , 5 },
+{ 40 , 80 , 36 , 6 },
+{ 40 , 80 , 36 , 7 },
+{ 40 , 80 , 36 , 8 },
+{ 40 , 80 , 36 , 9 },
+{ 40 , 80 , 36 , 10 },
+{ 40 , 80 , 36 , 11 },
+{ 40 , 80 , 36 , 12 },
+{ 40 , 80 , 36 , 13 },
+{ 40 , 80 , 36 , 14 },
+{ 40 , 80 , 36 , 15 },
+{ 40 , 80 , 36 , 16 },
+{ 40 , 80 , 36 , 17 },
+{ 40 , 80 , 36 , 18 },
+{ 40 , 80 , 36 , 19 },
+{ 40 , 80 , 36 , 20 },
+{ 40 , 80 , 36 , 21 },
+{ 40 , 80 , 36 , 22 },
+{ 40 , 80 , 36 , 23 },
+{ 40 , 80 , 36 , 24 },
+{ 40 , 80 , 36 , 25 },
+{ 40 , 80 , 36 , 26 },
+{ 40 , 80 , 36 , 27 },
+{ 40 , 80 , 36 , 28 },
+{ 40 , 80 , 36 , 29 },
+{ 40 , 80 , 36 , 30 },
+{ 40 , 80 , 36 , 31 },
+{ 40 , 80 , 36 , 32 },
+{ 40 , 80 , 36 , 33 },
+{ 40 , 80 , 36 , 34 },
+{ 40 , 80 , 36 , 35 },
+{ 40 , 80 , 36 , 36 },
+{ 40 , 80 , 36 , 37 },
+{ 40 , 80 , 36 , 38 },
+{ 40 , 80 , 36 , 39 },
+{ 40 , 80 , 36 , 40 },
+{ 40 , 80 , 36 , 41 },
+{ 40 , 80 , 36 , 42 },
+{ 40 , 80 , 36 , 43 },
+{ 40 , 80 , 36 , 44 },
+{ 40 , 80 , 36 , 45 },
+{ 40 , 80 , 36 , 46 },
+{ 40 , 80 , 36 , 47 },
+{ 40 , 80 , 36 , 48 },
+{ 40 , 80 , 36 , 49 },
+{ 40 , 80 , 36 , 50 },
+{ 40 , 80 , 36 , 51 },
+{ 40 , 80 , 36 , 52 },
+{ 40 , 80 , 36 , 53 },
+{ 40 , 80 , 36 , 54 },
+{ 40 , 80 , 36 , 55 },
+{ 40 , 80 , 36 , 56 },
+{ 40 , 80 , 36 , 57 },
+{ 40 , 80 , 36 , 58 },
+{ 40 , 80 , 36 , 59 },
+{ 40 , 80 , 36 , 60 },
+{ 40 , 80 , 36 , 61 },
+{ 40 , 80 , 36 , 62 },
+{ 40 , 80 , 36 , 63 },
+{ 40 , 80 , 36 , 64 },
+{ 40 , 80 , 36 , 65 },
+{ 40 , 80 , 36 , 66 },
+{ 40 , 80 , 36 , 67 },
+{ 40 , 80 , 36 , 68 },
+{ 40 , 80 , 36 , 69 },
+{ 40 , 80 , 36 , 70 },
+{ 40 , 80 , 36 , 71 },
+{ 40 , 80 , 36 , 72 },
+{ 40 , 80 , 36 , 73 },
+{ 40 , 80 , 36 , 74 },
+{ 40 , 80 , 36 , 75 },
+{ 40 , 80 , 36 , 76 },
+{ 40 , 80 , 36 , 77 },
+{ 40 , 80 , 36 , 78 },
+{ 40 , 80 , 36 , 79 },
+{ 40 , 80 , 37 , 0 },
+{ 40 , 80 , 37 , 1 },
+{ 40 , 80 , 37 , 2 },
+{ 40 , 80 , 37 , 3 },
+{ 40 , 80 , 37 , 4 },
+{ 40 , 80 , 37 , 5 },
+{ 40 , 80 , 37 , 6 },
+{ 40 , 80 , 37 , 7 },
+{ 40 , 80 , 37 , 8 },
+{ 40 , 80 , 37 , 9 },
+{ 40 , 80 , 37 , 10 },
+{ 40 , 80 , 37 , 11 },
+{ 40 , 80 , 37 , 12 },
+{ 40 , 80 , 37 , 13 },
+{ 40 , 80 , 37 , 14 },
+{ 40 , 80 , 37 , 15 },
+{ 40 , 80 , 37 , 16 },
+{ 40 , 80 , 37 , 17 },
+{ 40 , 80 , 37 , 18 },
+{ 40 , 80 , 37 , 19 },
+{ 40 , 80 , 37 , 20 },
+{ 40 , 80 , 37 , 21 },
+{ 40 , 80 , 37 , 22 },
+{ 40 , 80 , 37 , 23 },
+{ 40 , 80 , 37 , 24 },
+{ 40 , 80 , 37 , 25 },
+{ 40 , 80 , 37 , 26 },
+{ 40 , 80 , 37 , 27 },
+{ 40 , 80 , 37 , 28 },
+{ 40 , 80 , 37 , 29 },
+{ 40 , 80 , 37 , 30 },
+{ 40 , 80 , 37 , 31 },
+{ 40 , 80 , 37 , 32 },
+{ 40 , 80 , 37 , 33 },
+{ 40 , 80 , 37 , 34 },
+{ 40 , 80 , 37 , 35 },
+{ 40 , 80 , 37 , 36 },
+{ 40 , 80 , 37 , 37 },
+{ 40 , 80 , 37 , 38 },
+{ 40 , 80 , 37 , 39 },
+{ 40 , 80 , 37 , 40 },
+{ 40 , 80 , 37 , 41 },
+{ 40 , 80 , 37 , 42 },
+{ 40 , 80 , 37 , 43 },
+{ 40 , 80 , 37 , 44 },
+{ 40 , 80 , 37 , 45 },
+{ 40 , 80 , 37 , 46 },
+{ 40 , 80 , 37 , 47 },
+{ 40 , 80 , 37 , 48 },
+{ 40 , 80 , 37 , 49 },
+{ 40 , 80 , 37 , 50 },
+{ 40 , 80 , 37 , 51 },
+{ 40 , 80 , 37 , 52 },
+{ 40 , 80 , 37 , 53 },
+{ 40 , 80 , 37 , 54 },
+{ 40 , 80 , 37 , 55 },
+{ 40 , 80 , 37 , 56 },
+{ 40 , 80 , 37 , 57 },
+{ 40 , 80 , 37 , 58 },
+{ 40 , 80 , 37 , 59 },
+{ 40 , 80 , 37 , 60 },
+{ 40 , 80 , 37 , 61 },
+{ 40 , 80 , 37 , 62 },
+{ 40 , 80 , 37 , 63 },
+{ 40 , 80 , 37 , 64 },
+{ 40 , 80 , 37 , 65 },
+{ 40 , 80 , 37 , 66 },
+{ 40 , 80 , 37 , 67 },
+{ 40 , 80 , 37 , 68 },
+{ 40 , 80 , 37 , 69 },
+{ 40 , 80 , 37 , 70 },
+{ 40 , 80 , 37 , 71 },
+{ 40 , 80 , 37 , 72 },
+{ 40 , 80 , 37 , 73 },
+{ 40 , 80 , 37 , 74 },
+{ 40 , 80 , 37 , 75 },
+{ 40 , 80 , 37 , 76 },
+{ 40 , 80 , 37 , 77 },
+{ 40 , 80 , 37 , 78 },
+{ 40 , 80 , 37 , 79 },
+{ 40 , 80 , 38 , 0 },
+{ 40 , 80 , 38 , 1 },
+{ 40 , 80 , 38 , 2 },
+{ 40 , 80 , 38 , 3 },
+{ 40 , 80 , 38 , 4 },
+{ 40 , 80 , 38 , 5 },
+{ 40 , 80 , 38 , 6 },
+{ 40 , 80 , 38 , 7 },
+{ 40 , 80 , 38 , 8 },
+{ 40 , 80 , 38 , 9 },
+{ 40 , 80 , 38 , 10 },
+{ 40 , 80 , 38 , 11 },
+{ 40 , 80 , 38 , 12 },
+{ 40 , 80 , 38 , 13 },
+{ 40 , 80 , 38 , 14 },
+{ 40 , 80 , 38 , 15 },
+{ 40 , 80 , 38 , 16 },
+{ 40 , 80 , 38 , 17 },
+{ 40 , 80 , 38 , 18 },
+{ 40 , 80 , 38 , 19 },
+{ 40 , 80 , 38 , 20 },
+{ 40 , 80 , 38 , 21 },
+{ 40 , 80 , 38 , 22 },
+{ 40 , 80 , 38 , 23 },
+{ 40 , 80 , 38 , 24 },
+{ 40 , 80 , 38 , 25 },
+{ 40 , 80 , 38 , 26 },
+{ 40 , 80 , 38 , 27 },
+{ 40 , 80 , 38 , 28 },
+{ 40 , 80 , 38 , 29 },
+{ 40 , 80 , 38 , 30 },
+{ 40 , 80 , 38 , 31 },
+{ 40 , 80 , 38 , 32 },
+{ 40 , 80 , 38 , 33 },
+{ 40 , 80 , 38 , 34 },
+{ 40 , 80 , 38 , 35 },
+{ 40 , 80 , 38 , 36 },
+{ 40 , 80 , 38 , 37 },
+{ 40 , 80 , 38 , 38 },
+{ 40 , 80 , 38 , 39 },
+{ 40 , 80 , 38 , 40 },
+{ 40 , 80 , 38 , 41 },
+{ 40 , 80 , 38 , 42 },
+{ 40 , 80 , 38 , 43 },
+{ 40 , 80 , 38 , 44 },
+{ 40 , 80 , 38 , 45 },
+{ 40 , 80 , 38 , 46 },
+{ 40 , 80 , 38 , 47 },
+{ 40 , 80 , 38 , 48 },
+{ 40 , 80 , 38 , 49 },
+{ 40 , 80 , 38 , 50 },
+{ 40 , 80 , 38 , 51 },
+{ 40 , 80 , 38 , 52 },
+{ 40 , 80 , 38 , 53 },
+{ 40 , 80 , 38 , 54 },
+{ 40 , 80 , 38 , 55 },
+{ 40 , 80 , 38 , 56 },
+{ 40 , 80 , 38 , 57 },
+{ 40 , 80 , 38 , 58 },
+{ 40 , 80 , 38 , 59 },
+{ 40 , 80 , 38 , 60 },
+{ 40 , 80 , 38 , 61 },
+{ 40 , 80 , 38 , 62 },
+{ 40 , 80 , 38 , 63 },
+{ 40 , 80 , 38 , 64 },
+{ 40 , 80 , 38 , 65 },
+{ 40 , 80 , 38 , 66 },
+{ 40 , 80 , 38 , 67 },
+{ 40 , 80 , 38 , 68 },
+{ 40 , 80 , 38 , 69 },
+{ 40 , 80 , 38 , 70 },
+{ 40 , 80 , 38 , 71 },
+{ 40 , 80 , 38 , 72 },
+{ 40 , 80 , 38 , 73 },
+{ 40 , 80 , 38 , 74 },
+{ 40 , 80 , 38 , 75 },
+{ 40 , 80 , 38 , 76 },
+{ 40 , 80 , 38 , 77 },
+{ 40 , 80 , 38 , 78 },
+{ 40 , 80 , 38 , 79 },
+{ 40 , 80 , 39 , 0 },
+{ 40 , 80 , 39 , 1 },
+{ 40 , 80 , 39 , 2 },
+{ 40 , 80 , 39 , 3 },
+{ 40 , 80 , 39 , 4 },
+{ 40 , 80 , 39 , 5 },
+{ 40 , 80 , 39 , 6 },
+{ 40 , 80 , 39 , 7 },
+{ 40 , 80 , 39 , 8 },
+{ 40 , 80 , 39 , 9 },
+{ 40 , 80 , 39 , 10 },
+{ 40 , 80 , 39 , 11 },
+{ 40 , 80 , 39 , 12 },
+{ 40 , 80 , 39 , 13 },
+{ 40 , 80 , 39 , 14 },
+{ 40 , 80 , 39 , 15 },
+{ 40 , 80 , 39 , 16 },
+{ 40 , 80 , 39 , 17 },
+{ 40 , 80 , 39 , 18 },
+{ 40 , 80 , 39 , 19 },
+{ 40 , 80 , 39 , 20 },
+{ 40 , 80 , 39 , 21 },
+{ 40 , 80 , 39 , 22 },
+{ 40 , 80 , 39 , 23 },
+{ 40 , 80 , 39 , 24 },
+{ 40 , 80 , 39 , 25 },
+{ 40 , 80 , 39 , 26 },
+{ 40 , 80 , 39 , 27 },
+{ 40 , 80 , 39 , 28 },
+{ 40 , 80 , 39 , 29 },
+{ 40 , 80 , 39 , 30 },
+{ 40 , 80 , 39 , 31 },
+{ 40 , 80 , 39 , 32 },
+{ 40 , 80 , 39 , 33 },
+{ 40 , 80 , 39 , 34 },
+{ 40 , 80 , 39 , 35 },
+{ 40 , 80 , 39 , 36 },
+{ 40 , 80 , 39 , 37 },
+{ 40 , 80 , 39 , 38 },
+{ 40 , 80 , 39 , 39 },
+{ 40 , 80 , 39 , 40 },
+{ 40 , 80 , 39 , 41 },
+{ 40 , 80 , 39 , 42 },
+{ 40 , 80 , 39 , 43 },
+{ 40 , 80 , 39 , 44 },
+{ 40 , 80 , 39 , 45 },
+{ 40 , 80 , 39 , 46 },
+{ 40 , 80 , 39 , 47 },
+{ 40 , 80 , 39 , 48 },
+{ 40 , 80 , 39 , 49 },
+{ 40 , 80 , 39 , 50 },
+{ 40 , 80 , 39 , 51 },
+{ 40 , 80 , 39 , 52 },
+{ 40 , 80 , 39 , 53 },
+{ 40 , 80 , 39 , 54 },
+{ 40 , 80 , 39 , 55 },
+{ 40 , 80 , 39 , 56 },
+{ 40 , 80 , 39 , 57 },
+{ 40 , 80 , 39 , 58 },
+{ 40 , 80 , 39 , 59 },
+{ 40 , 80 , 39 , 60 },
+{ 40 , 80 , 39 , 61 },
+{ 40 , 80 , 39 , 62 },
+{ 40 , 80 , 39 , 63 },
+{ 40 , 80 , 39 , 64 },
+{ 40 , 80 , 39 , 65 },
+{ 40 , 80 , 39 , 66 },
+{ 40 , 80 , 39 , 67 },
+{ 40 , 80 , 39 , 68 },
+{ 40 , 80 , 39 , 69 },
+{ 40 , 80 , 39 , 70 },
+{ 40 , 80 , 39 , 71 },
+{ 40 , 80 , 39 , 72 },
+{ 40 , 80 , 39 , 73 },
+{ 40 , 80 , 39 , 74 },
+{ 40 , 80 , 39 , 75 },
+{ 40 , 80 , 39 , 76 },
+{ 40 , 80 , 39 , 77 },
+{ 40 , 80 , 39 , 78 },
+{ 40 , 80 , 39 , 79 },
+{ 80 , 5 , 0 , 0 },
+{ 80 , 5 , 0 , 1 },
+{ 80 , 5 , 0 , 2 },
+{ 80 , 5 , 0 , 3 },
+{ 80 , 5 , 0 , 4 },
+{ 80 , 5 , 1 , 0 },
+{ 80 , 5 , 1 , 1 },
+{ 80 , 5 , 1 , 2 },
+{ 80 , 5 , 1 , 3 },
+{ 80 , 5 , 1 , 4 },
+{ 80 , 5 , 2 , 0 },
+{ 80 , 5 , 2 , 1 },
+{ 80 , 5 , 2 , 2 },
+{ 80 , 5 , 2 , 3 },
+{ 80 , 5 , 2 , 4 },
+{ 80 , 5 , 3 , 0 },
+{ 80 , 5 , 3 , 1 },
+{ 80 , 5 , 3 , 2 },
+{ 80 , 5 , 3 , 3 },
+{ 80 , 5 , 3 , 4 },
+{ 80 , 5 , 4 , 0 },
+{ 80 , 5 , 4 , 1 },
+{ 80 , 5 , 4 , 2 },
+{ 80 , 5 , 4 , 3 },
+{ 80 , 5 , 4 , 4 },
+{ 80 , 5 , 5 , 0 },
+{ 80 , 5 , 5 , 1 },
+{ 80 , 5 , 5 , 2 },
+{ 80 , 5 , 5 , 3 },
+{ 80 , 5 , 5 , 4 },
+{ 80 , 5 , 6 , 0 },
+{ 80 , 5 , 6 , 1 },
+{ 80 , 5 , 6 , 2 },
+{ 80 , 5 , 6 , 3 },
+{ 80 , 5 , 6 , 4 },
+{ 80 , 5 , 7 , 0 },
+{ 80 , 5 , 7 , 1 },
+{ 80 , 5 , 7 , 2 },
+{ 80 , 5 , 7 , 3 },
+{ 80 , 5 , 7 , 4 },
+{ 80 , 5 , 8 , 0 },
+{ 80 , 5 , 8 , 1 },
+{ 80 , 5 , 8 , 2 },
+{ 80 , 5 , 8 , 3 },
+{ 80 , 5 , 8 , 4 },
+{ 80 , 5 , 9 , 0 },
+{ 80 , 5 , 9 , 1 },
+{ 80 , 5 , 9 , 2 },
+{ 80 , 5 , 9 , 3 },
+{ 80 , 5 , 9 , 4 },
+{ 80 , 5 , 10 , 0 },
+{ 80 , 5 , 10 , 1 },
+{ 80 , 5 , 10 , 2 },
+{ 80 , 5 , 10 , 3 },
+{ 80 , 5 , 10 , 4 },
+{ 80 , 5 , 11 , 0 },
+{ 80 , 5 , 11 , 1 },
+{ 80 , 5 , 11 , 2 },
+{ 80 , 5 , 11 , 3 },
+{ 80 , 5 , 11 , 4 },
+{ 80 , 5 , 12 , 0 },
+{ 80 , 5 , 12 , 1 },
+{ 80 , 5 , 12 , 2 },
+{ 80 , 5 , 12 , 3 },
+{ 80 , 5 , 12 , 4 },
+{ 80 , 5 , 13 , 0 },
+{ 80 , 5 , 13 , 1 },
+{ 80 , 5 , 13 , 2 },
+{ 80 , 5 , 13 , 3 },
+{ 80 , 5 , 13 , 4 },
+{ 80 , 5 , 14 , 0 },
+{ 80 , 5 , 14 , 1 },
+{ 80 , 5 , 14 , 2 },
+{ 80 , 5 , 14 , 3 },
+{ 80 , 5 , 14 , 4 },
+{ 80 , 5 , 15 , 0 },
+{ 80 , 5 , 15 , 1 },
+{ 80 , 5 , 15 , 2 },
+{ 80 , 5 , 15 , 3 },
+{ 80 , 5 , 15 , 4 },
+{ 80 , 5 , 16 , 0 },
+{ 80 , 5 , 16 , 1 },
+{ 80 , 5 , 16 , 2 },
+{ 80 , 5 , 16 , 3 },
+{ 80 , 5 , 16 , 4 },
+{ 80 , 5 , 17 , 0 },
+{ 80 , 5 , 17 , 1 },
+{ 80 , 5 , 17 , 2 },
+{ 80 , 5 , 17 , 3 },
+{ 80 , 5 , 17 , 4 },
+{ 80 , 5 , 18 , 0 },
+{ 80 , 5 , 18 , 1 },
+{ 80 , 5 , 18 , 2 },
+{ 80 , 5 , 18 , 3 },
+{ 80 , 5 , 18 , 4 },
+{ 80 , 5 , 19 , 0 },
+{ 80 , 5 , 19 , 1 },
+{ 80 , 5 , 19 , 2 },
+{ 80 , 5 , 19 , 3 },
+{ 80 , 5 , 19 , 4 },
+{ 80 , 5 , 20 , 0 },
+{ 80 , 5 , 20 , 1 },
+{ 80 , 5 , 20 , 2 },
+{ 80 , 5 , 20 , 3 },
+{ 80 , 5 , 20 , 4 },
+{ 80 , 5 , 21 , 0 },
+{ 80 , 5 , 21 , 1 },
+{ 80 , 5 , 21 , 2 },
+{ 80 , 5 , 21 , 3 },
+{ 80 , 5 , 21 , 4 },
+{ 80 , 5 , 22 , 0 },
+{ 80 , 5 , 22 , 1 },
+{ 80 , 5 , 22 , 2 },
+{ 80 , 5 , 22 , 3 },
+{ 80 , 5 , 22 , 4 },
+{ 80 , 5 , 23 , 0 },
+{ 80 , 5 , 23 , 1 },
+{ 80 , 5 , 23 , 2 },
+{ 80 , 5 , 23 , 3 },
+{ 80 , 5 , 23 , 4 },
+{ 80 , 5 , 24 , 0 },
+{ 80 , 5 , 24 , 1 },
+{ 80 , 5 , 24 , 2 },
+{ 80 , 5 , 24 , 3 },
+{ 80 , 5 , 24 , 4 },
+{ 80 , 5 , 25 , 0 },
+{ 80 , 5 , 25 , 1 },
+{ 80 , 5 , 25 , 2 },
+{ 80 , 5 , 25 , 3 },
+{ 80 , 5 , 25 , 4 },
+{ 80 , 5 , 26 , 0 },
+{ 80 , 5 , 26 , 1 },
+{ 80 , 5 , 26 , 2 },
+{ 80 , 5 , 26 , 3 },
+{ 80 , 5 , 26 , 4 },
+{ 80 , 5 , 27 , 0 },
+{ 80 , 5 , 27 , 1 },
+{ 80 , 5 , 27 , 2 },
+{ 80 , 5 , 27 , 3 },
+{ 80 , 5 , 27 , 4 },
+{ 80 , 5 , 28 , 0 },
+{ 80 , 5 , 28 , 1 },
+{ 80 , 5 , 28 , 2 },
+{ 80 , 5 , 28 , 3 },
+{ 80 , 5 , 28 , 4 },
+{ 80 , 5 , 29 , 0 },
+{ 80 , 5 , 29 , 1 },
+{ 80 , 5 , 29 , 2 },
+{ 80 , 5 , 29 , 3 },
+{ 80 , 5 , 29 , 4 },
+{ 80 , 5 , 30 , 0 },
+{ 80 , 5 , 30 , 1 },
+{ 80 , 5 , 30 , 2 },
+{ 80 , 5 , 30 , 3 },
+{ 80 , 5 , 30 , 4 },
+{ 80 , 5 , 31 , 0 },
+{ 80 , 5 , 31 , 1 },
+{ 80 , 5 , 31 , 2 },
+{ 80 , 5 , 31 , 3 },
+{ 80 , 5 , 31 , 4 },
+{ 80 , 5 , 32 , 0 },
+{ 80 , 5 , 32 , 1 },
+{ 80 , 5 , 32 , 2 },
+{ 80 , 5 , 32 , 3 },
+{ 80 , 5 , 32 , 4 },
+{ 80 , 5 , 33 , 0 },
+{ 80 , 5 , 33 , 1 },
+{ 80 , 5 , 33 , 2 },
+{ 80 , 5 , 33 , 3 },
+{ 80 , 5 , 33 , 4 },
+{ 80 , 5 , 34 , 0 },
+{ 80 , 5 , 34 , 1 },
+{ 80 , 5 , 34 , 2 },
+{ 80 , 5 , 34 , 3 },
+{ 80 , 5 , 34 , 4 },
+{ 80 , 5 , 35 , 0 },
+{ 80 , 5 , 35 , 1 },
+{ 80 , 5 , 35 , 2 },
+{ 80 , 5 , 35 , 3 },
+{ 80 , 5 , 35 , 4 },
+{ 80 , 5 , 36 , 0 },
+{ 80 , 5 , 36 , 1 },
+{ 80 , 5 , 36 , 2 },
+{ 80 , 5 , 36 , 3 },
+{ 80 , 5 , 36 , 4 },
+{ 80 , 5 , 37 , 0 },
+{ 80 , 5 , 37 , 1 },
+{ 80 , 5 , 37 , 2 },
+{ 80 , 5 , 37 , 3 },
+{ 80 , 5 , 37 , 4 },
+{ 80 , 5 , 38 , 0 },
+{ 80 , 5 , 38 , 1 },
+{ 80 , 5 , 38 , 2 },
+{ 80 , 5 , 38 , 3 },
+{ 80 , 5 , 38 , 4 },
+{ 80 , 5 , 39 , 0 },
+{ 80 , 5 , 39 , 1 },
+{ 80 , 5 , 39 , 2 },
+{ 80 , 5 , 39 , 3 },
+{ 80 , 5 , 39 , 4 },
+{ 80 , 5 , 40 , 0 },
+{ 80 , 5 , 40 , 1 },
+{ 80 , 5 , 40 , 2 },
+{ 80 , 5 , 40 , 3 },
+{ 80 , 5 , 40 , 4 },
+{ 80 , 5 , 41 , 0 },
+{ 80 , 5 , 41 , 1 },
+{ 80 , 5 , 41 , 2 },
+{ 80 , 5 , 41 , 3 },
+{ 80 , 5 , 41 , 4 },
+{ 80 , 5 , 42 , 0 },
+{ 80 , 5 , 42 , 1 },
+{ 80 , 5 , 42 , 2 },
+{ 80 , 5 , 42 , 3 },
+{ 80 , 5 , 42 , 4 },
+{ 80 , 5 , 43 , 0 },
+{ 80 , 5 , 43 , 1 },
+{ 80 , 5 , 43 , 2 },
+{ 80 , 5 , 43 , 3 },
+{ 80 , 5 , 43 , 4 },
+{ 80 , 5 , 44 , 0 },
+{ 80 , 5 , 44 , 1 },
+{ 80 , 5 , 44 , 2 },
+{ 80 , 5 , 44 , 3 },
+{ 80 , 5 , 44 , 4 },
+{ 80 , 5 , 45 , 0 },
+{ 80 , 5 , 45 , 1 },
+{ 80 , 5 , 45 , 2 },
+{ 80 , 5 , 45 , 3 },
+{ 80 , 5 , 45 , 4 },
+{ 80 , 5 , 46 , 0 },
+{ 80 , 5 , 46 , 1 },
+{ 80 , 5 , 46 , 2 },
+{ 80 , 5 , 46 , 3 },
+{ 80 , 5 , 46 , 4 },
+{ 80 , 5 , 47 , 0 },
+{ 80 , 5 , 47 , 1 },
+{ 80 , 5 , 47 , 2 },
+{ 80 , 5 , 47 , 3 },
+{ 80 , 5 , 47 , 4 },
+{ 80 , 5 , 48 , 0 },
+{ 80 , 5 , 48 , 1 },
+{ 80 , 5 , 48 , 2 },
+{ 80 , 5 , 48 , 3 },
+{ 80 , 5 , 48 , 4 },
+{ 80 , 5 , 49 , 0 },
+{ 80 , 5 , 49 , 1 },
+{ 80 , 5 , 49 , 2 },
+{ 80 , 5 , 49 , 3 },
+{ 80 , 5 , 49 , 4 },
+{ 80 , 5 , 50 , 0 },
+{ 80 , 5 , 50 , 1 },
+{ 80 , 5 , 50 , 2 },
+{ 80 , 5 , 50 , 3 },
+{ 80 , 5 , 50 , 4 },
+{ 80 , 5 , 51 , 0 },
+{ 80 , 5 , 51 , 1 },
+{ 80 , 5 , 51 , 2 },
+{ 80 , 5 , 51 , 3 },
+{ 80 , 5 , 51 , 4 },
+{ 80 , 5 , 52 , 0 },
+{ 80 , 5 , 52 , 1 },
+{ 80 , 5 , 52 , 2 },
+{ 80 , 5 , 52 , 3 },
+{ 80 , 5 , 52 , 4 },
+{ 80 , 5 , 53 , 0 },
+{ 80 , 5 , 53 , 1 },
+{ 80 , 5 , 53 , 2 },
+{ 80 , 5 , 53 , 3 },
+{ 80 , 5 , 53 , 4 },
+{ 80 , 5 , 54 , 0 },
+{ 80 , 5 , 54 , 1 },
+{ 80 , 5 , 54 , 2 },
+{ 80 , 5 , 54 , 3 },
+{ 80 , 5 , 54 , 4 },
+{ 80 , 5 , 55 , 0 },
+{ 80 , 5 , 55 , 1 },
+{ 80 , 5 , 55 , 2 },
+{ 80 , 5 , 55 , 3 },
+{ 80 , 5 , 55 , 4 },
+{ 80 , 5 , 56 , 0 },
+{ 80 , 5 , 56 , 1 },
+{ 80 , 5 , 56 , 2 },
+{ 80 , 5 , 56 , 3 },
+{ 80 , 5 , 56 , 4 },
+{ 80 , 5 , 57 , 0 },
+{ 80 , 5 , 57 , 1 },
+{ 80 , 5 , 57 , 2 },
+{ 80 , 5 , 57 , 3 },
+{ 80 , 5 , 57 , 4 },
+{ 80 , 5 , 58 , 0 },
+{ 80 , 5 , 58 , 1 },
+{ 80 , 5 , 58 , 2 },
+{ 80 , 5 , 58 , 3 },
+{ 80 , 5 , 58 , 4 },
+{ 80 , 5 , 59 , 0 },
+{ 80 , 5 , 59 , 1 },
+{ 80 , 5 , 59 , 2 },
+{ 80 , 5 , 59 , 3 },
+{ 80 , 5 , 59 , 4 },
+{ 80 , 5 , 60 , 0 },
+{ 80 , 5 , 60 , 1 },
+{ 80 , 5 , 60 , 2 },
+{ 80 , 5 , 60 , 3 },
+{ 80 , 5 , 60 , 4 },
+{ 80 , 5 , 61 , 0 },
+{ 80 , 5 , 61 , 1 },
+{ 80 , 5 , 61 , 2 },
+{ 80 , 5 , 61 , 3 },
+{ 80 , 5 , 61 , 4 },
+{ 80 , 5 , 62 , 0 },
+{ 80 , 5 , 62 , 1 },
+{ 80 , 5 , 62 , 2 },
+{ 80 , 5 , 62 , 3 },
+{ 80 , 5 , 62 , 4 },
+{ 80 , 5 , 63 , 0 },
+{ 80 , 5 , 63 , 1 },
+{ 80 , 5 , 63 , 2 },
+{ 80 , 5 , 63 , 3 },
+{ 80 , 5 , 63 , 4 },
+{ 80 , 5 , 64 , 0 },
+{ 80 , 5 , 64 , 1 },
+{ 80 , 5 , 64 , 2 },
+{ 80 , 5 , 64 , 3 },
+{ 80 , 5 , 64 , 4 },
+{ 80 , 5 , 65 , 0 },
+{ 80 , 5 , 65 , 1 },
+{ 80 , 5 , 65 , 2 },
+{ 80 , 5 , 65 , 3 },
+{ 80 , 5 , 65 , 4 },
+{ 80 , 5 , 66 , 0 },
+{ 80 , 5 , 66 , 1 },
+{ 80 , 5 , 66 , 2 },
+{ 80 , 5 , 66 , 3 },
+{ 80 , 5 , 66 , 4 },
+{ 80 , 5 , 67 , 0 },
+{ 80 , 5 , 67 , 1 },
+{ 80 , 5 , 67 , 2 },
+{ 80 , 5 , 67 , 3 },
+{ 80 , 5 , 67 , 4 },
+{ 80 , 5 , 68 , 0 },
+{ 80 , 5 , 68 , 1 },
+{ 80 , 5 , 68 , 2 },
+{ 80 , 5 , 68 , 3 },
+{ 80 , 5 , 68 , 4 },
+{ 80 , 5 , 69 , 0 },
+{ 80 , 5 , 69 , 1 },
+{ 80 , 5 , 69 , 2 },
+{ 80 , 5 , 69 , 3 },
+{ 80 , 5 , 69 , 4 },
+{ 80 , 5 , 70 , 0 },
+{ 80 , 5 , 70 , 1 },
+{ 80 , 5 , 70 , 2 },
+{ 80 , 5 , 70 , 3 },
+{ 80 , 5 , 70 , 4 },
+{ 80 , 5 , 71 , 0 },
+{ 80 , 5 , 71 , 1 },
+{ 80 , 5 , 71 , 2 },
+{ 80 , 5 , 71 , 3 },
+{ 80 , 5 , 71 , 4 },
+{ 80 , 5 , 72 , 0 },
+{ 80 , 5 , 72 , 1 },
+{ 80 , 5 , 72 , 2 },
+{ 80 , 5 , 72 , 3 },
+{ 80 , 5 , 72 , 4 },
+{ 80 , 5 , 73 , 0 },
+{ 80 , 5 , 73 , 1 },
+{ 80 , 5 , 73 , 2 },
+{ 80 , 5 , 73 , 3 },
+{ 80 , 5 , 73 , 4 },
+{ 80 , 5 , 74 , 0 },
+{ 80 , 5 , 74 , 1 },
+{ 80 , 5 , 74 , 2 },
+{ 80 , 5 , 74 , 3 },
+{ 80 , 5 , 74 , 4 },
+{ 80 , 5 , 75 , 0 },
+{ 80 , 5 , 75 , 1 },
+{ 80 , 5 , 75 , 2 },
+{ 80 , 5 , 75 , 3 },
+{ 80 , 5 , 75 , 4 },
+{ 80 , 5 , 76 , 0 },
+{ 80 , 5 , 76 , 1 },
+{ 80 , 5 , 76 , 2 },
+{ 80 , 5 , 76 , 3 },
+{ 80 , 5 , 76 , 4 },
+{ 80 , 5 , 77 , 0 },
+{ 80 , 5 , 77 , 1 },
+{ 80 , 5 , 77 , 2 },
+{ 80 , 5 , 77 , 3 },
+{ 80 , 5 , 77 , 4 },
+{ 80 , 5 , 78 , 0 },
+{ 80 , 5 , 78 , 1 },
+{ 80 , 5 , 78 , 2 },
+{ 80 , 5 , 78 , 3 },
+{ 80 , 5 , 78 , 4 },
+{ 80 , 5 , 79 , 0 },
+{ 80 , 5 , 79 , 1 },
+{ 80 , 5 , 79 , 2 },
+{ 80 , 5 , 79 , 3 },
+{ 80 , 5 , 79 , 4 },
+{ 80 , 10 , 0 , 0 },
+{ 80 , 10 , 0 , 1 },
+{ 80 , 10 , 0 , 2 },
+{ 80 , 10 , 0 , 3 },
+{ 80 , 10 , 0 , 4 },
+{ 80 , 10 , 0 , 5 },
+{ 80 , 10 , 0 , 6 },
+{ 80 , 10 , 0 , 7 },
+{ 80 , 10 , 0 , 8 },
+{ 80 , 10 , 0 , 9 },
+{ 80 , 10 , 1 , 0 },
+{ 80 , 10 , 1 , 1 },
+{ 80 , 10 , 1 , 2 },
+{ 80 , 10 , 1 , 3 },
+{ 80 , 10 , 1 , 4 },
+{ 80 , 10 , 1 , 5 },
+{ 80 , 10 , 1 , 6 },
+{ 80 , 10 , 1 , 7 },
+{ 80 , 10 , 1 , 8 },
+{ 80 , 10 , 1 , 9 },
+{ 80 , 10 , 2 , 0 },
+{ 80 , 10 , 2 , 1 },
+{ 80 , 10 , 2 , 2 },
+{ 80 , 10 , 2 , 3 },
+{ 80 , 10 , 2 , 4 },
+{ 80 , 10 , 2 , 5 },
+{ 80 , 10 , 2 , 6 },
+{ 80 , 10 , 2 , 7 },
+{ 80 , 10 , 2 , 8 },
+{ 80 , 10 , 2 , 9 },
+{ 80 , 10 , 3 , 0 },
+{ 80 , 10 , 3 , 1 },
+{ 80 , 10 , 3 , 2 },
+{ 80 , 10 , 3 , 3 },
+{ 80 , 10 , 3 , 4 },
+{ 80 , 10 , 3 , 5 },
+{ 80 , 10 , 3 , 6 },
+{ 80 , 10 , 3 , 7 },
+{ 80 , 10 , 3 , 8 },
+{ 80 , 10 , 3 , 9 },
+{ 80 , 10 , 4 , 0 },
+{ 80 , 10 , 4 , 1 },
+{ 80 , 10 , 4 , 2 },
+{ 80 , 10 , 4 , 3 },
+{ 80 , 10 , 4 , 4 },
+{ 80 , 10 , 4 , 5 },
+{ 80 , 10 , 4 , 6 },
+{ 80 , 10 , 4 , 7 },
+{ 80 , 10 , 4 , 8 },
+{ 80 , 10 , 4 , 9 },
+{ 80 , 10 , 5 , 0 },
+{ 80 , 10 , 5 , 1 },
+{ 80 , 10 , 5 , 2 },
+{ 80 , 10 , 5 , 3 },
+{ 80 , 10 , 5 , 4 },
+{ 80 , 10 , 5 , 5 },
+{ 80 , 10 , 5 , 6 },
+{ 80 , 10 , 5 , 7 },
+{ 80 , 10 , 5 , 8 },
+{ 80 , 10 , 5 , 9 },
+{ 80 , 10 , 6 , 0 },
+{ 80 , 10 , 6 , 1 },
+{ 80 , 10 , 6 , 2 },
+{ 80 , 10 , 6 , 3 },
+{ 80 , 10 , 6 , 4 },
+{ 80 , 10 , 6 , 5 },
+{ 80 , 10 , 6 , 6 },
+{ 80 , 10 , 6 , 7 },
+{ 80 , 10 , 6 , 8 },
+{ 80 , 10 , 6 , 9 },
+{ 80 , 10 , 7 , 0 },
+{ 80 , 10 , 7 , 1 },
+{ 80 , 10 , 7 , 2 },
+{ 80 , 10 , 7 , 3 },
+{ 80 , 10 , 7 , 4 },
+{ 80 , 10 , 7 , 5 },
+{ 80 , 10 , 7 , 6 },
+{ 80 , 10 , 7 , 7 },
+{ 80 , 10 , 7 , 8 },
+{ 80 , 10 , 7 , 9 },
+{ 80 , 10 , 8 , 0 },
+{ 80 , 10 , 8 , 1 },
+{ 80 , 10 , 8 , 2 },
+{ 80 , 10 , 8 , 3 },
+{ 80 , 10 , 8 , 4 },
+{ 80 , 10 , 8 , 5 },
+{ 80 , 10 , 8 , 6 },
+{ 80 , 10 , 8 , 7 },
+{ 80 , 10 , 8 , 8 },
+{ 80 , 10 , 8 , 9 },
+{ 80 , 10 , 9 , 0 },
+{ 80 , 10 , 9 , 1 },
+{ 80 , 10 , 9 , 2 },
+{ 80 , 10 , 9 , 3 },
+{ 80 , 10 , 9 , 4 },
+{ 80 , 10 , 9 , 5 },
+{ 80 , 10 , 9 , 6 },
+{ 80 , 10 , 9 , 7 },
+{ 80 , 10 , 9 , 8 },
+{ 80 , 10 , 9 , 9 },
+{ 80 , 10 , 10 , 0 },
+{ 80 , 10 , 10 , 1 },
+{ 80 , 10 , 10 , 2 },
+{ 80 , 10 , 10 , 3 },
+{ 80 , 10 , 10 , 4 },
+{ 80 , 10 , 10 , 5 },
+{ 80 , 10 , 10 , 6 },
+{ 80 , 10 , 10 , 7 },
+{ 80 , 10 , 10 , 8 },
+{ 80 , 10 , 10 , 9 },
+{ 80 , 10 , 11 , 0 },
+{ 80 , 10 , 11 , 1 },
+{ 80 , 10 , 11 , 2 },
+{ 80 , 10 , 11 , 3 },
+{ 80 , 10 , 11 , 4 },
+{ 80 , 10 , 11 , 5 },
+{ 80 , 10 , 11 , 6 },
+{ 80 , 10 , 11 , 7 },
+{ 80 , 10 , 11 , 8 },
+{ 80 , 10 , 11 , 9 },
+{ 80 , 10 , 12 , 0 },
+{ 80 , 10 , 12 , 1 },
+{ 80 , 10 , 12 , 2 },
+{ 80 , 10 , 12 , 3 },
+{ 80 , 10 , 12 , 4 },
+{ 80 , 10 , 12 , 5 },
+{ 80 , 10 , 12 , 6 },
+{ 80 , 10 , 12 , 7 },
+{ 80 , 10 , 12 , 8 },
+{ 80 , 10 , 12 , 9 },
+{ 80 , 10 , 13 , 0 },
+{ 80 , 10 , 13 , 1 },
+{ 80 , 10 , 13 , 2 },
+{ 80 , 10 , 13 , 3 },
+{ 80 , 10 , 13 , 4 },
+{ 80 , 10 , 13 , 5 },
+{ 80 , 10 , 13 , 6 },
+{ 80 , 10 , 13 , 7 },
+{ 80 , 10 , 13 , 8 },
+{ 80 , 10 , 13 , 9 },
+{ 80 , 10 , 14 , 0 },
+{ 80 , 10 , 14 , 1 },
+{ 80 , 10 , 14 , 2 },
+{ 80 , 10 , 14 , 3 },
+{ 80 , 10 , 14 , 4 },
+{ 80 , 10 , 14 , 5 },
+{ 80 , 10 , 14 , 6 },
+{ 80 , 10 , 14 , 7 },
+{ 80 , 10 , 14 , 8 },
+{ 80 , 10 , 14 , 9 },
+{ 80 , 10 , 15 , 0 },
+{ 80 , 10 , 15 , 1 },
+{ 80 , 10 , 15 , 2 },
+{ 80 , 10 , 15 , 3 },
+{ 80 , 10 , 15 , 4 },
+{ 80 , 10 , 15 , 5 },
+{ 80 , 10 , 15 , 6 },
+{ 80 , 10 , 15 , 7 },
+{ 80 , 10 , 15 , 8 },
+{ 80 , 10 , 15 , 9 },
+{ 80 , 10 , 16 , 0 },
+{ 80 , 10 , 16 , 1 },
+{ 80 , 10 , 16 , 2 },
+{ 80 , 10 , 16 , 3 },
+{ 80 , 10 , 16 , 4 },
+{ 80 , 10 , 16 , 5 },
+{ 80 , 10 , 16 , 6 },
+{ 80 , 10 , 16 , 7 },
+{ 80 , 10 , 16 , 8 },
+{ 80 , 10 , 16 , 9 },
+{ 80 , 10 , 17 , 0 },
+{ 80 , 10 , 17 , 1 },
+{ 80 , 10 , 17 , 2 },
+{ 80 , 10 , 17 , 3 },
+{ 80 , 10 , 17 , 4 },
+{ 80 , 10 , 17 , 5 },
+{ 80 , 10 , 17 , 6 },
+{ 80 , 10 , 17 , 7 },
+{ 80 , 10 , 17 , 8 },
+{ 80 , 10 , 17 , 9 },
+{ 80 , 10 , 18 , 0 },
+{ 80 , 10 , 18 , 1 },
+{ 80 , 10 , 18 , 2 },
+{ 80 , 10 , 18 , 3 },
+{ 80 , 10 , 18 , 4 },
+{ 80 , 10 , 18 , 5 },
+{ 80 , 10 , 18 , 6 },
+{ 80 , 10 , 18 , 7 },
+{ 80 , 10 , 18 , 8 },
+{ 80 , 10 , 18 , 9 },
+{ 80 , 10 , 19 , 0 },
+{ 80 , 10 , 19 , 1 },
+{ 80 , 10 , 19 , 2 },
+{ 80 , 10 , 19 , 3 },
+{ 80 , 10 , 19 , 4 },
+{ 80 , 10 , 19 , 5 },
+{ 80 , 10 , 19 , 6 },
+{ 80 , 10 , 19 , 7 },
+{ 80 , 10 , 19 , 8 },
+{ 80 , 10 , 19 , 9 },
+{ 80 , 10 , 20 , 0 },
+{ 80 , 10 , 20 , 1 },
+{ 80 , 10 , 20 , 2 },
+{ 80 , 10 , 20 , 3 },
+{ 80 , 10 , 20 , 4 },
+{ 80 , 10 , 20 , 5 },
+{ 80 , 10 , 20 , 6 },
+{ 80 , 10 , 20 , 7 },
+{ 80 , 10 , 20 , 8 },
+{ 80 , 10 , 20 , 9 },
+{ 80 , 10 , 21 , 0 },
+{ 80 , 10 , 21 , 1 },
+{ 80 , 10 , 21 , 2 },
+{ 80 , 10 , 21 , 3 },
+{ 80 , 10 , 21 , 4 },
+{ 80 , 10 , 21 , 5 },
+{ 80 , 10 , 21 , 6 },
+{ 80 , 10 , 21 , 7 },
+{ 80 , 10 , 21 , 8 },
+{ 80 , 10 , 21 , 9 },
+{ 80 , 10 , 22 , 0 },
+{ 80 , 10 , 22 , 1 },
+{ 80 , 10 , 22 , 2 },
+{ 80 , 10 , 22 , 3 },
+{ 80 , 10 , 22 , 4 },
+{ 80 , 10 , 22 , 5 },
+{ 80 , 10 , 22 , 6 },
+{ 80 , 10 , 22 , 7 },
+{ 80 , 10 , 22 , 8 },
+{ 80 , 10 , 22 , 9 },
+{ 80 , 10 , 23 , 0 },
+{ 80 , 10 , 23 , 1 },
+{ 80 , 10 , 23 , 2 },
+{ 80 , 10 , 23 , 3 },
+{ 80 , 10 , 23 , 4 },
+{ 80 , 10 , 23 , 5 },
+{ 80 , 10 , 23 , 6 },
+{ 80 , 10 , 23 , 7 },
+{ 80 , 10 , 23 , 8 },
+{ 80 , 10 , 23 , 9 },
+{ 80 , 10 , 24 , 0 },
+{ 80 , 10 , 24 , 1 },
+{ 80 , 10 , 24 , 2 },
+{ 80 , 10 , 24 , 3 },
+{ 80 , 10 , 24 , 4 },
+{ 80 , 10 , 24 , 5 },
+{ 80 , 10 , 24 , 6 },
+{ 80 , 10 , 24 , 7 },
+{ 80 , 10 , 24 , 8 },
+{ 80 , 10 , 24 , 9 },
+{ 80 , 10 , 25 , 0 },
+{ 80 , 10 , 25 , 1 },
+{ 80 , 10 , 25 , 2 },
+{ 80 , 10 , 25 , 3 },
+{ 80 , 10 , 25 , 4 },
+{ 80 , 10 , 25 , 5 },
+{ 80 , 10 , 25 , 6 },
+{ 80 , 10 , 25 , 7 },
+{ 80 , 10 , 25 , 8 },
+{ 80 , 10 , 25 , 9 },
+{ 80 , 10 , 26 , 0 },
+{ 80 , 10 , 26 , 1 },
+{ 80 , 10 , 26 , 2 },
+{ 80 , 10 , 26 , 3 },
+{ 80 , 10 , 26 , 4 },
+{ 80 , 10 , 26 , 5 },
+{ 80 , 10 , 26 , 6 },
+{ 80 , 10 , 26 , 7 },
+{ 80 , 10 , 26 , 8 },
+{ 80 , 10 , 26 , 9 },
+{ 80 , 10 , 27 , 0 },
+{ 80 , 10 , 27 , 1 },
+{ 80 , 10 , 27 , 2 },
+{ 80 , 10 , 27 , 3 },
+{ 80 , 10 , 27 , 4 },
+{ 80 , 10 , 27 , 5 },
+{ 80 , 10 , 27 , 6 },
+{ 80 , 10 , 27 , 7 },
+{ 80 , 10 , 27 , 8 },
+{ 80 , 10 , 27 , 9 },
+{ 80 , 10 , 28 , 0 },
+{ 80 , 10 , 28 , 1 },
+{ 80 , 10 , 28 , 2 },
+{ 80 , 10 , 28 , 3 },
+{ 80 , 10 , 28 , 4 },
+{ 80 , 10 , 28 , 5 },
+{ 80 , 10 , 28 , 6 },
+{ 80 , 10 , 28 , 7 },
+{ 80 , 10 , 28 , 8 },
+{ 80 , 10 , 28 , 9 },
+{ 80 , 10 , 29 , 0 },
+{ 80 , 10 , 29 , 1 },
+{ 80 , 10 , 29 , 2 },
+{ 80 , 10 , 29 , 3 },
+{ 80 , 10 , 29 , 4 },
+{ 80 , 10 , 29 , 5 },
+{ 80 , 10 , 29 , 6 },
+{ 80 , 10 , 29 , 7 },
+{ 80 , 10 , 29 , 8 },
+{ 80 , 10 , 29 , 9 },
+{ 80 , 10 , 30 , 0 },
+{ 80 , 10 , 30 , 1 },
+{ 80 , 10 , 30 , 2 },
+{ 80 , 10 , 30 , 3 },
+{ 80 , 10 , 30 , 4 },
+{ 80 , 10 , 30 , 5 },
+{ 80 , 10 , 30 , 6 },
+{ 80 , 10 , 30 , 7 },
+{ 80 , 10 , 30 , 8 },
+{ 80 , 10 , 30 , 9 },
+{ 80 , 10 , 31 , 0 },
+{ 80 , 10 , 31 , 1 },
+{ 80 , 10 , 31 , 2 },
+{ 80 , 10 , 31 , 3 },
+{ 80 , 10 , 31 , 4 },
+{ 80 , 10 , 31 , 5 },
+{ 80 , 10 , 31 , 6 },
+{ 80 , 10 , 31 , 7 },
+{ 80 , 10 , 31 , 8 },
+{ 80 , 10 , 31 , 9 },
+{ 80 , 10 , 32 , 0 },
+{ 80 , 10 , 32 , 1 },
+{ 80 , 10 , 32 , 2 },
+{ 80 , 10 , 32 , 3 },
+{ 80 , 10 , 32 , 4 },
+{ 80 , 10 , 32 , 5 },
+{ 80 , 10 , 32 , 6 },
+{ 80 , 10 , 32 , 7 },
+{ 80 , 10 , 32 , 8 },
+{ 80 , 10 , 32 , 9 },
+{ 80 , 10 , 33 , 0 },
+{ 80 , 10 , 33 , 1 },
+{ 80 , 10 , 33 , 2 },
+{ 80 , 10 , 33 , 3 },
+{ 80 , 10 , 33 , 4 },
+{ 80 , 10 , 33 , 5 },
+{ 80 , 10 , 33 , 6 },
+{ 80 , 10 , 33 , 7 },
+{ 80 , 10 , 33 , 8 },
+{ 80 , 10 , 33 , 9 },
+{ 80 , 10 , 34 , 0 },
+{ 80 , 10 , 34 , 1 },
+{ 80 , 10 , 34 , 2 },
+{ 80 , 10 , 34 , 3 },
+{ 80 , 10 , 34 , 4 },
+{ 80 , 10 , 34 , 5 },
+{ 80 , 10 , 34 , 6 },
+{ 80 , 10 , 34 , 7 },
+{ 80 , 10 , 34 , 8 },
+{ 80 , 10 , 34 , 9 },
+{ 80 , 10 , 35 , 0 },
+{ 80 , 10 , 35 , 1 },
+{ 80 , 10 , 35 , 2 },
+{ 80 , 10 , 35 , 3 },
+{ 80 , 10 , 35 , 4 },
+{ 80 , 10 , 35 , 5 },
+{ 80 , 10 , 35 , 6 },
+{ 80 , 10 , 35 , 7 },
+{ 80 , 10 , 35 , 8 },
+{ 80 , 10 , 35 , 9 },
+{ 80 , 10 , 36 , 0 },
+{ 80 , 10 , 36 , 1 },
+{ 80 , 10 , 36 , 2 },
+{ 80 , 10 , 36 , 3 },
+{ 80 , 10 , 36 , 4 },
+{ 80 , 10 , 36 , 5 },
+{ 80 , 10 , 36 , 6 },
+{ 80 , 10 , 36 , 7 },
+{ 80 , 10 , 36 , 8 },
+{ 80 , 10 , 36 , 9 },
+{ 80 , 10 , 37 , 0 },
+{ 80 , 10 , 37 , 1 },
+{ 80 , 10 , 37 , 2 },
+{ 80 , 10 , 37 , 3 },
+{ 80 , 10 , 37 , 4 },
+{ 80 , 10 , 37 , 5 },
+{ 80 , 10 , 37 , 6 },
+{ 80 , 10 , 37 , 7 },
+{ 80 , 10 , 37 , 8 },
+{ 80 , 10 , 37 , 9 },
+{ 80 , 10 , 38 , 0 },
+{ 80 , 10 , 38 , 1 },
+{ 80 , 10 , 38 , 2 },
+{ 80 , 10 , 38 , 3 },
+{ 80 , 10 , 38 , 4 },
+{ 80 , 10 , 38 , 5 },
+{ 80 , 10 , 38 , 6 },
+{ 80 , 10 , 38 , 7 },
+{ 80 , 10 , 38 , 8 },
+{ 80 , 10 , 38 , 9 },
+{ 80 , 10 , 39 , 0 },
+{ 80 , 10 , 39 , 1 },
+{ 80 , 10 , 39 , 2 },
+{ 80 , 10 , 39 , 3 },
+{ 80 , 10 , 39 , 4 },
+{ 80 , 10 , 39 , 5 },
+{ 80 , 10 , 39 , 6 },
+{ 80 , 10 , 39 , 7 },
+{ 80 , 10 , 39 , 8 },
+{ 80 , 10 , 39 , 9 },
+{ 80 , 10 , 40 , 0 },
+{ 80 , 10 , 40 , 1 },
+{ 80 , 10 , 40 , 2 },
+{ 80 , 10 , 40 , 3 },
+{ 80 , 10 , 40 , 4 },
+{ 80 , 10 , 40 , 5 },
+{ 80 , 10 , 40 , 6 },
+{ 80 , 10 , 40 , 7 },
+{ 80 , 10 , 40 , 8 },
+{ 80 , 10 , 40 , 9 },
+{ 80 , 10 , 41 , 0 },
+{ 80 , 10 , 41 , 1 },
+{ 80 , 10 , 41 , 2 },
+{ 80 , 10 , 41 , 3 },
+{ 80 , 10 , 41 , 4 },
+{ 80 , 10 , 41 , 5 },
+{ 80 , 10 , 41 , 6 },
+{ 80 , 10 , 41 , 7 },
+{ 80 , 10 , 41 , 8 },
+{ 80 , 10 , 41 , 9 },
+{ 80 , 10 , 42 , 0 },
+{ 80 , 10 , 42 , 1 },
+{ 80 , 10 , 42 , 2 },
+{ 80 , 10 , 42 , 3 },
+{ 80 , 10 , 42 , 4 },
+{ 80 , 10 , 42 , 5 },
+{ 80 , 10 , 42 , 6 },
+{ 80 , 10 , 42 , 7 },
+{ 80 , 10 , 42 , 8 },
+{ 80 , 10 , 42 , 9 },
+{ 80 , 10 , 43 , 0 },
+{ 80 , 10 , 43 , 1 },
+{ 80 , 10 , 43 , 2 },
+{ 80 , 10 , 43 , 3 },
+{ 80 , 10 , 43 , 4 },
+{ 80 , 10 , 43 , 5 },
+{ 80 , 10 , 43 , 6 },
+{ 80 , 10 , 43 , 7 },
+{ 80 , 10 , 43 , 8 },
+{ 80 , 10 , 43 , 9 },
+{ 80 , 10 , 44 , 0 },
+{ 80 , 10 , 44 , 1 },
+{ 80 , 10 , 44 , 2 },
+{ 80 , 10 , 44 , 3 },
+{ 80 , 10 , 44 , 4 },
+{ 80 , 10 , 44 , 5 },
+{ 80 , 10 , 44 , 6 },
+{ 80 , 10 , 44 , 7 },
+{ 80 , 10 , 44 , 8 },
+{ 80 , 10 , 44 , 9 },
+{ 80 , 10 , 45 , 0 },
+{ 80 , 10 , 45 , 1 },
+{ 80 , 10 , 45 , 2 },
+{ 80 , 10 , 45 , 3 },
+{ 80 , 10 , 45 , 4 },
+{ 80 , 10 , 45 , 5 },
+{ 80 , 10 , 45 , 6 },
+{ 80 , 10 , 45 , 7 },
+{ 80 , 10 , 45 , 8 },
+{ 80 , 10 , 45 , 9 },
+{ 80 , 10 , 46 , 0 },
+{ 80 , 10 , 46 , 1 },
+{ 80 , 10 , 46 , 2 },
+{ 80 , 10 , 46 , 3 },
+{ 80 , 10 , 46 , 4 },
+{ 80 , 10 , 46 , 5 },
+{ 80 , 10 , 46 , 6 },
+{ 80 , 10 , 46 , 7 },
+{ 80 , 10 , 46 , 8 },
+{ 80 , 10 , 46 , 9 },
+{ 80 , 10 , 47 , 0 },
+{ 80 , 10 , 47 , 1 },
+{ 80 , 10 , 47 , 2 },
+{ 80 , 10 , 47 , 3 },
+{ 80 , 10 , 47 , 4 },
+{ 80 , 10 , 47 , 5 },
+{ 80 , 10 , 47 , 6 },
+{ 80 , 10 , 47 , 7 },
+{ 80 , 10 , 47 , 8 },
+{ 80 , 10 , 47 , 9 },
+{ 80 , 10 , 48 , 0 },
+{ 80 , 10 , 48 , 1 },
+{ 80 , 10 , 48 , 2 },
+{ 80 , 10 , 48 , 3 },
+{ 80 , 10 , 48 , 4 },
+{ 80 , 10 , 48 , 5 },
+{ 80 , 10 , 48 , 6 },
+{ 80 , 10 , 48 , 7 },
+{ 80 , 10 , 48 , 8 },
+{ 80 , 10 , 48 , 9 },
+{ 80 , 10 , 49 , 0 },
+{ 80 , 10 , 49 , 1 },
+{ 80 , 10 , 49 , 2 },
+{ 80 , 10 , 49 , 3 },
+{ 80 , 10 , 49 , 4 },
+{ 80 , 10 , 49 , 5 },
+{ 80 , 10 , 49 , 6 },
+{ 80 , 10 , 49 , 7 },
+{ 80 , 10 , 49 , 8 },
+{ 80 , 10 , 49 , 9 },
+{ 80 , 10 , 50 , 0 },
+{ 80 , 10 , 50 , 1 },
+{ 80 , 10 , 50 , 2 },
+{ 80 , 10 , 50 , 3 },
+{ 80 , 10 , 50 , 4 },
+{ 80 , 10 , 50 , 5 },
+{ 80 , 10 , 50 , 6 },
+{ 80 , 10 , 50 , 7 },
+{ 80 , 10 , 50 , 8 },
+{ 80 , 10 , 50 , 9 },
+{ 80 , 10 , 51 , 0 },
+{ 80 , 10 , 51 , 1 },
+{ 80 , 10 , 51 , 2 },
+{ 80 , 10 , 51 , 3 },
+{ 80 , 10 , 51 , 4 },
+{ 80 , 10 , 51 , 5 },
+{ 80 , 10 , 51 , 6 },
+{ 80 , 10 , 51 , 7 },
+{ 80 , 10 , 51 , 8 },
+{ 80 , 10 , 51 , 9 },
+{ 80 , 10 , 52 , 0 },
+{ 80 , 10 , 52 , 1 },
+{ 80 , 10 , 52 , 2 },
+{ 80 , 10 , 52 , 3 },
+{ 80 , 10 , 52 , 4 },
+{ 80 , 10 , 52 , 5 },
+{ 80 , 10 , 52 , 6 },
+{ 80 , 10 , 52 , 7 },
+{ 80 , 10 , 52 , 8 },
+{ 80 , 10 , 52 , 9 },
+{ 80 , 10 , 53 , 0 },
+{ 80 , 10 , 53 , 1 },
+{ 80 , 10 , 53 , 2 },
+{ 80 , 10 , 53 , 3 },
+{ 80 , 10 , 53 , 4 },
+{ 80 , 10 , 53 , 5 },
+{ 80 , 10 , 53 , 6 },
+{ 80 , 10 , 53 , 7 },
+{ 80 , 10 , 53 , 8 },
+{ 80 , 10 , 53 , 9 },
+{ 80 , 10 , 54 , 0 },
+{ 80 , 10 , 54 , 1 },
+{ 80 , 10 , 54 , 2 },
+{ 80 , 10 , 54 , 3 },
+{ 80 , 10 , 54 , 4 },
+{ 80 , 10 , 54 , 5 },
+{ 80 , 10 , 54 , 6 },
+{ 80 , 10 , 54 , 7 },
+{ 80 , 10 , 54 , 8 },
+{ 80 , 10 , 54 , 9 },
+{ 80 , 10 , 55 , 0 },
+{ 80 , 10 , 55 , 1 },
+{ 80 , 10 , 55 , 2 },
+{ 80 , 10 , 55 , 3 },
+{ 80 , 10 , 55 , 4 },
+{ 80 , 10 , 55 , 5 },
+{ 80 , 10 , 55 , 6 },
+{ 80 , 10 , 55 , 7 },
+{ 80 , 10 , 55 , 8 },
+{ 80 , 10 , 55 , 9 },
+{ 80 , 10 , 56 , 0 },
+{ 80 , 10 , 56 , 1 },
+{ 80 , 10 , 56 , 2 },
+{ 80 , 10 , 56 , 3 },
+{ 80 , 10 , 56 , 4 },
+{ 80 , 10 , 56 , 5 },
+{ 80 , 10 , 56 , 6 },
+{ 80 , 10 , 56 , 7 },
+{ 80 , 10 , 56 , 8 },
+{ 80 , 10 , 56 , 9 },
+{ 80 , 10 , 57 , 0 },
+{ 80 , 10 , 57 , 1 },
+{ 80 , 10 , 57 , 2 },
+{ 80 , 10 , 57 , 3 },
+{ 80 , 10 , 57 , 4 },
+{ 80 , 10 , 57 , 5 },
+{ 80 , 10 , 57 , 6 },
+{ 80 , 10 , 57 , 7 },
+{ 80 , 10 , 57 , 8 },
+{ 80 , 10 , 57 , 9 },
+{ 80 , 10 , 58 , 0 },
+{ 80 , 10 , 58 , 1 },
+{ 80 , 10 , 58 , 2 },
+{ 80 , 10 , 58 , 3 },
+{ 80 , 10 , 58 , 4 },
+{ 80 , 10 , 58 , 5 },
+{ 80 , 10 , 58 , 6 },
+{ 80 , 10 , 58 , 7 },
+{ 80 , 10 , 58 , 8 },
+{ 80 , 10 , 58 , 9 },
+{ 80 , 10 , 59 , 0 },
+{ 80 , 10 , 59 , 1 },
+{ 80 , 10 , 59 , 2 },
+{ 80 , 10 , 59 , 3 },
+{ 80 , 10 , 59 , 4 },
+{ 80 , 10 , 59 , 5 },
+{ 80 , 10 , 59 , 6 },
+{ 80 , 10 , 59 , 7 },
+{ 80 , 10 , 59 , 8 },
+{ 80 , 10 , 59 , 9 },
+{ 80 , 10 , 60 , 0 },
+{ 80 , 10 , 60 , 1 },
+{ 80 , 10 , 60 , 2 },
+{ 80 , 10 , 60 , 3 },
+{ 80 , 10 , 60 , 4 },
+{ 80 , 10 , 60 , 5 },
+{ 80 , 10 , 60 , 6 },
+{ 80 , 10 , 60 , 7 },
+{ 80 , 10 , 60 , 8 },
+{ 80 , 10 , 60 , 9 },
+{ 80 , 10 , 61 , 0 },
+{ 80 , 10 , 61 , 1 },
+{ 80 , 10 , 61 , 2 },
+{ 80 , 10 , 61 , 3 },
+{ 80 , 10 , 61 , 4 },
+{ 80 , 10 , 61 , 5 },
+{ 80 , 10 , 61 , 6 },
+{ 80 , 10 , 61 , 7 },
+{ 80 , 10 , 61 , 8 },
+{ 80 , 10 , 61 , 9 },
+{ 80 , 10 , 62 , 0 },
+{ 80 , 10 , 62 , 1 },
+{ 80 , 10 , 62 , 2 },
+{ 80 , 10 , 62 , 3 },
+{ 80 , 10 , 62 , 4 },
+{ 80 , 10 , 62 , 5 },
+{ 80 , 10 , 62 , 6 },
+{ 80 , 10 , 62 , 7 },
+{ 80 , 10 , 62 , 8 },
+{ 80 , 10 , 62 , 9 },
+{ 80 , 10 , 63 , 0 },
+{ 80 , 10 , 63 , 1 },
+{ 80 , 10 , 63 , 2 },
+{ 80 , 10 , 63 , 3 },
+{ 80 , 10 , 63 , 4 },
+{ 80 , 10 , 63 , 5 },
+{ 80 , 10 , 63 , 6 },
+{ 80 , 10 , 63 , 7 },
+{ 80 , 10 , 63 , 8 },
+{ 80 , 10 , 63 , 9 },
+{ 80 , 10 , 64 , 0 },
+{ 80 , 10 , 64 , 1 },
+{ 80 , 10 , 64 , 2 },
+{ 80 , 10 , 64 , 3 },
+{ 80 , 10 , 64 , 4 },
+{ 80 , 10 , 64 , 5 },
+{ 80 , 10 , 64 , 6 },
+{ 80 , 10 , 64 , 7 },
+{ 80 , 10 , 64 , 8 },
+{ 80 , 10 , 64 , 9 },
+{ 80 , 10 , 65 , 0 },
+{ 80 , 10 , 65 , 1 },
+{ 80 , 10 , 65 , 2 },
+{ 80 , 10 , 65 , 3 },
+{ 80 , 10 , 65 , 4 },
+{ 80 , 10 , 65 , 5 },
+{ 80 , 10 , 65 , 6 },
+{ 80 , 10 , 65 , 7 },
+{ 80 , 10 , 65 , 8 },
+{ 80 , 10 , 65 , 9 },
+{ 80 , 10 , 66 , 0 },
+{ 80 , 10 , 66 , 1 },
+{ 80 , 10 , 66 , 2 },
+{ 80 , 10 , 66 , 3 },
+{ 80 , 10 , 66 , 4 },
+{ 80 , 10 , 66 , 5 },
+{ 80 , 10 , 66 , 6 },
+{ 80 , 10 , 66 , 7 },
+{ 80 , 10 , 66 , 8 },
+{ 80 , 10 , 66 , 9 },
+{ 80 , 10 , 67 , 0 },
+{ 80 , 10 , 67 , 1 },
+{ 80 , 10 , 67 , 2 },
+{ 80 , 10 , 67 , 3 },
+{ 80 , 10 , 67 , 4 },
+{ 80 , 10 , 67 , 5 },
+{ 80 , 10 , 67 , 6 },
+{ 80 , 10 , 67 , 7 },
+{ 80 , 10 , 67 , 8 },
+{ 80 , 10 , 67 , 9 },
+{ 80 , 10 , 68 , 0 },
+{ 80 , 10 , 68 , 1 },
+{ 80 , 10 , 68 , 2 },
+{ 80 , 10 , 68 , 3 },
+{ 80 , 10 , 68 , 4 },
+{ 80 , 10 , 68 , 5 },
+{ 80 , 10 , 68 , 6 },
+{ 80 , 10 , 68 , 7 },
+{ 80 , 10 , 68 , 8 },
+{ 80 , 10 , 68 , 9 },
+{ 80 , 10 , 69 , 0 },
+{ 80 , 10 , 69 , 1 },
+{ 80 , 10 , 69 , 2 },
+{ 80 , 10 , 69 , 3 },
+{ 80 , 10 , 69 , 4 },
+{ 80 , 10 , 69 , 5 },
+{ 80 , 10 , 69 , 6 },
+{ 80 , 10 , 69 , 7 },
+{ 80 , 10 , 69 , 8 },
+{ 80 , 10 , 69 , 9 },
+{ 80 , 10 , 70 , 0 },
+{ 80 , 10 , 70 , 1 },
+{ 80 , 10 , 70 , 2 },
+{ 80 , 10 , 70 , 3 },
+{ 80 , 10 , 70 , 4 },
+{ 80 , 10 , 70 , 5 },
+{ 80 , 10 , 70 , 6 },
+{ 80 , 10 , 70 , 7 },
+{ 80 , 10 , 70 , 8 },
+{ 80 , 10 , 70 , 9 },
+{ 80 , 10 , 71 , 0 },
+{ 80 , 10 , 71 , 1 },
+{ 80 , 10 , 71 , 2 },
+{ 80 , 10 , 71 , 3 },
+{ 80 , 10 , 71 , 4 },
+{ 80 , 10 , 71 , 5 },
+{ 80 , 10 , 71 , 6 },
+{ 80 , 10 , 71 , 7 },
+{ 80 , 10 , 71 , 8 },
+{ 80 , 10 , 71 , 9 },
+{ 80 , 10 , 72 , 0 },
+{ 80 , 10 , 72 , 1 },
+{ 80 , 10 , 72 , 2 },
+{ 80 , 10 , 72 , 3 },
+{ 80 , 10 , 72 , 4 },
+{ 80 , 10 , 72 , 5 },
+{ 80 , 10 , 72 , 6 },
+{ 80 , 10 , 72 , 7 },
+{ 80 , 10 , 72 , 8 },
+{ 80 , 10 , 72 , 9 },
+{ 80 , 10 , 73 , 0 },
+{ 80 , 10 , 73 , 1 },
+{ 80 , 10 , 73 , 2 },
+{ 80 , 10 , 73 , 3 },
+{ 80 , 10 , 73 , 4 },
+{ 80 , 10 , 73 , 5 },
+{ 80 , 10 , 73 , 6 },
+{ 80 , 10 , 73 , 7 },
+{ 80 , 10 , 73 , 8 },
+{ 80 , 10 , 73 , 9 },
+{ 80 , 10 , 74 , 0 },
+{ 80 , 10 , 74 , 1 },
+{ 80 , 10 , 74 , 2 },
+{ 80 , 10 , 74 , 3 },
+{ 80 , 10 , 74 , 4 },
+{ 80 , 10 , 74 , 5 },
+{ 80 , 10 , 74 , 6 },
+{ 80 , 10 , 74 , 7 },
+{ 80 , 10 , 74 , 8 },
+{ 80 , 10 , 74 , 9 },
+{ 80 , 10 , 75 , 0 },
+{ 80 , 10 , 75 , 1 },
+{ 80 , 10 , 75 , 2 },
+{ 80 , 10 , 75 , 3 },
+{ 80 , 10 , 75 , 4 },
+{ 80 , 10 , 75 , 5 },
+{ 80 , 10 , 75 , 6 },
+{ 80 , 10 , 75 , 7 },
+{ 80 , 10 , 75 , 8 },
+{ 80 , 10 , 75 , 9 },
+{ 80 , 10 , 76 , 0 },
+{ 80 , 10 , 76 , 1 },
+{ 80 , 10 , 76 , 2 },
+{ 80 , 10 , 76 , 3 },
+{ 80 , 10 , 76 , 4 },
+{ 80 , 10 , 76 , 5 },
+{ 80 , 10 , 76 , 6 },
+{ 80 , 10 , 76 , 7 },
+{ 80 , 10 , 76 , 8 },
+{ 80 , 10 , 76 , 9 },
+{ 80 , 10 , 77 , 0 },
+{ 80 , 10 , 77 , 1 },
+{ 80 , 10 , 77 , 2 },
+{ 80 , 10 , 77 , 3 },
+{ 80 , 10 , 77 , 4 },
+{ 80 , 10 , 77 , 5 },
+{ 80 , 10 , 77 , 6 },
+{ 80 , 10 , 77 , 7 },
+{ 80 , 10 , 77 , 8 },
+{ 80 , 10 , 77 , 9 },
+{ 80 , 10 , 78 , 0 },
+{ 80 , 10 , 78 , 1 },
+{ 80 , 10 , 78 , 2 },
+{ 80 , 10 , 78 , 3 },
+{ 80 , 10 , 78 , 4 },
+{ 80 , 10 , 78 , 5 },
+{ 80 , 10 , 78 , 6 },
+{ 80 , 10 , 78 , 7 },
+{ 80 , 10 , 78 , 8 },
+{ 80 , 10 , 78 , 9 },
+{ 80 , 10 , 79 , 0 },
+{ 80 , 10 , 79 , 1 },
+{ 80 , 10 , 79 , 2 },
+{ 80 , 10 , 79 , 3 },
+{ 80 , 10 , 79 , 4 },
+{ 80 , 10 , 79 , 5 },
+{ 80 , 10 , 79 , 6 },
+{ 80 , 10 , 79 , 7 },
+{ 80 , 10 , 79 , 8 },
+{ 80 , 10 , 79 , 9 },
+{ 80 , 20 , 0 , 0 },
+{ 80 , 20 , 0 , 1 },
+{ 80 , 20 , 0 , 2 },
+{ 80 , 20 , 0 , 3 },
+{ 80 , 20 , 0 , 4 },
+{ 80 , 20 , 0 , 5 },
+{ 80 , 20 , 0 , 6 },
+{ 80 , 20 , 0 , 7 },
+{ 80 , 20 , 0 , 8 },
+{ 80 , 20 , 0 , 9 },
+{ 80 , 20 , 0 , 10 },
+{ 80 , 20 , 0 , 11 },
+{ 80 , 20 , 0 , 12 },
+{ 80 , 20 , 0 , 13 },
+{ 80 , 20 , 0 , 14 },
+{ 80 , 20 , 0 , 15 },
+{ 80 , 20 , 0 , 16 },
+{ 80 , 20 , 0 , 17 },
+{ 80 , 20 , 0 , 18 },
+{ 80 , 20 , 0 , 19 },
+{ 80 , 20 , 1 , 0 },
+{ 80 , 20 , 1 , 1 },
+{ 80 , 20 , 1 , 2 },
+{ 80 , 20 , 1 , 3 },
+{ 80 , 20 , 1 , 4 },
+{ 80 , 20 , 1 , 5 },
+{ 80 , 20 , 1 , 6 },
+{ 80 , 20 , 1 , 7 },
+{ 80 , 20 , 1 , 8 },
+{ 80 , 20 , 1 , 9 },
+{ 80 , 20 , 1 , 10 },
+{ 80 , 20 , 1 , 11 },
+{ 80 , 20 , 1 , 12 },
+{ 80 , 20 , 1 , 13 },
+{ 80 , 20 , 1 , 14 },
+{ 80 , 20 , 1 , 15 },
+{ 80 , 20 , 1 , 16 },
+{ 80 , 20 , 1 , 17 },
+{ 80 , 20 , 1 , 18 },
+{ 80 , 20 , 1 , 19 },
+{ 80 , 20 , 2 , 0 },
+{ 80 , 20 , 2 , 1 },
+{ 80 , 20 , 2 , 2 },
+{ 80 , 20 , 2 , 3 },
+{ 80 , 20 , 2 , 4 },
+{ 80 , 20 , 2 , 5 },
+{ 80 , 20 , 2 , 6 },
+{ 80 , 20 , 2 , 7 },
+{ 80 , 20 , 2 , 8 },
+{ 80 , 20 , 2 , 9 },
+{ 80 , 20 , 2 , 10 },
+{ 80 , 20 , 2 , 11 },
+{ 80 , 20 , 2 , 12 },
+{ 80 , 20 , 2 , 13 },
+{ 80 , 20 , 2 , 14 },
+{ 80 , 20 , 2 , 15 },
+{ 80 , 20 , 2 , 16 },
+{ 80 , 20 , 2 , 17 },
+{ 80 , 20 , 2 , 18 },
+{ 80 , 20 , 2 , 19 },
+{ 80 , 20 , 3 , 0 },
+{ 80 , 20 , 3 , 1 },
+{ 80 , 20 , 3 , 2 },
+{ 80 , 20 , 3 , 3 },
+{ 80 , 20 , 3 , 4 },
+{ 80 , 20 , 3 , 5 },
+{ 80 , 20 , 3 , 6 },
+{ 80 , 20 , 3 , 7 },
+{ 80 , 20 , 3 , 8 },
+{ 80 , 20 , 3 , 9 },
+{ 80 , 20 , 3 , 10 },
+{ 80 , 20 , 3 , 11 },
+{ 80 , 20 , 3 , 12 },
+{ 80 , 20 , 3 , 13 },
+{ 80 , 20 , 3 , 14 },
+{ 80 , 20 , 3 , 15 },
+{ 80 , 20 , 3 , 16 },
+{ 80 , 20 , 3 , 17 },
+{ 80 , 20 , 3 , 18 },
+{ 80 , 20 , 3 , 19 },
+{ 80 , 20 , 4 , 0 },
+{ 80 , 20 , 4 , 1 },
+{ 80 , 20 , 4 , 2 },
+{ 80 , 20 , 4 , 3 },
+{ 80 , 20 , 4 , 4 },
+{ 80 , 20 , 4 , 5 },
+{ 80 , 20 , 4 , 6 },
+{ 80 , 20 , 4 , 7 },
+{ 80 , 20 , 4 , 8 },
+{ 80 , 20 , 4 , 9 },
+{ 80 , 20 , 4 , 10 },
+{ 80 , 20 , 4 , 11 },
+{ 80 , 20 , 4 , 12 },
+{ 80 , 20 , 4 , 13 },
+{ 80 , 20 , 4 , 14 },
+{ 80 , 20 , 4 , 15 },
+{ 80 , 20 , 4 , 16 },
+{ 80 , 20 , 4 , 17 },
+{ 80 , 20 , 4 , 18 },
+{ 80 , 20 , 4 , 19 },
+{ 80 , 20 , 5 , 0 },
+{ 80 , 20 , 5 , 1 },
+{ 80 , 20 , 5 , 2 },
+{ 80 , 20 , 5 , 3 },
+{ 80 , 20 , 5 , 4 },
+{ 80 , 20 , 5 , 5 },
+{ 80 , 20 , 5 , 6 },
+{ 80 , 20 , 5 , 7 },
+{ 80 , 20 , 5 , 8 },
+{ 80 , 20 , 5 , 9 },
+{ 80 , 20 , 5 , 10 },
+{ 80 , 20 , 5 , 11 },
+{ 80 , 20 , 5 , 12 },
+{ 80 , 20 , 5 , 13 },
+{ 80 , 20 , 5 , 14 },
+{ 80 , 20 , 5 , 15 },
+{ 80 , 20 , 5 , 16 },
+{ 80 , 20 , 5 , 17 },
+{ 80 , 20 , 5 , 18 },
+{ 80 , 20 , 5 , 19 },
+{ 80 , 20 , 6 , 0 },
+{ 80 , 20 , 6 , 1 },
+{ 80 , 20 , 6 , 2 },
+{ 80 , 20 , 6 , 3 },
+{ 80 , 20 , 6 , 4 },
+{ 80 , 20 , 6 , 5 },
+{ 80 , 20 , 6 , 6 },
+{ 80 , 20 , 6 , 7 },
+{ 80 , 20 , 6 , 8 },
+{ 80 , 20 , 6 , 9 },
+{ 80 , 20 , 6 , 10 },
+{ 80 , 20 , 6 , 11 },
+{ 80 , 20 , 6 , 12 },
+{ 80 , 20 , 6 , 13 },
+{ 80 , 20 , 6 , 14 },
+{ 80 , 20 , 6 , 15 },
+{ 80 , 20 , 6 , 16 },
+{ 80 , 20 , 6 , 17 },
+{ 80 , 20 , 6 , 18 },
+{ 80 , 20 , 6 , 19 },
+{ 80 , 20 , 7 , 0 },
+{ 80 , 20 , 7 , 1 },
+{ 80 , 20 , 7 , 2 },
+{ 80 , 20 , 7 , 3 },
+{ 80 , 20 , 7 , 4 },
+{ 80 , 20 , 7 , 5 },
+{ 80 , 20 , 7 , 6 },
+{ 80 , 20 , 7 , 7 },
+{ 80 , 20 , 7 , 8 },
+{ 80 , 20 , 7 , 9 },
+{ 80 , 20 , 7 , 10 },
+{ 80 , 20 , 7 , 11 },
+{ 80 , 20 , 7 , 12 },
+{ 80 , 20 , 7 , 13 },
+{ 80 , 20 , 7 , 14 },
+{ 80 , 20 , 7 , 15 },
+{ 80 , 20 , 7 , 16 },
+{ 80 , 20 , 7 , 17 },
+{ 80 , 20 , 7 , 18 },
+{ 80 , 20 , 7 , 19 },
+{ 80 , 20 , 8 , 0 },
+{ 80 , 20 , 8 , 1 },
+{ 80 , 20 , 8 , 2 },
+{ 80 , 20 , 8 , 3 },
+{ 80 , 20 , 8 , 4 },
+{ 80 , 20 , 8 , 5 },
+{ 80 , 20 , 8 , 6 },
+{ 80 , 20 , 8 , 7 },
+{ 80 , 20 , 8 , 8 },
+{ 80 , 20 , 8 , 9 },
+{ 80 , 20 , 8 , 10 },
+{ 80 , 20 , 8 , 11 },
+{ 80 , 20 , 8 , 12 },
+{ 80 , 20 , 8 , 13 },
+{ 80 , 20 , 8 , 14 },
+{ 80 , 20 , 8 , 15 },
+{ 80 , 20 , 8 , 16 },
+{ 80 , 20 , 8 , 17 },
+{ 80 , 20 , 8 , 18 },
+{ 80 , 20 , 8 , 19 },
+{ 80 , 20 , 9 , 0 },
+{ 80 , 20 , 9 , 1 },
+{ 80 , 20 , 9 , 2 },
+{ 80 , 20 , 9 , 3 },
+{ 80 , 20 , 9 , 4 },
+{ 80 , 20 , 9 , 5 },
+{ 80 , 20 , 9 , 6 },
+{ 80 , 20 , 9 , 7 },
+{ 80 , 20 , 9 , 8 },
+{ 80 , 20 , 9 , 9 },
+{ 80 , 20 , 9 , 10 },
+{ 80 , 20 , 9 , 11 },
+{ 80 , 20 , 9 , 12 },
+{ 80 , 20 , 9 , 13 },
+{ 80 , 20 , 9 , 14 },
+{ 80 , 20 , 9 , 15 },
+{ 80 , 20 , 9 , 16 },
+{ 80 , 20 , 9 , 17 },
+{ 80 , 20 , 9 , 18 },
+{ 80 , 20 , 9 , 19 },
+{ 80 , 20 , 10 , 0 },
+{ 80 , 20 , 10 , 1 },
+{ 80 , 20 , 10 , 2 },
+{ 80 , 20 , 10 , 3 },
+{ 80 , 20 , 10 , 4 },
+{ 80 , 20 , 10 , 5 },
+{ 80 , 20 , 10 , 6 },
+{ 80 , 20 , 10 , 7 },
+{ 80 , 20 , 10 , 8 },
+{ 80 , 20 , 10 , 9 },
+{ 80 , 20 , 10 , 10 },
+{ 80 , 20 , 10 , 11 },
+{ 80 , 20 , 10 , 12 },
+{ 80 , 20 , 10 , 13 },
+{ 80 , 20 , 10 , 14 },
+{ 80 , 20 , 10 , 15 },
+{ 80 , 20 , 10 , 16 },
+{ 80 , 20 , 10 , 17 },
+{ 80 , 20 , 10 , 18 },
+{ 80 , 20 , 10 , 19 },
+{ 80 , 20 , 11 , 0 },
+{ 80 , 20 , 11 , 1 },
+{ 80 , 20 , 11 , 2 },
+{ 80 , 20 , 11 , 3 },
+{ 80 , 20 , 11 , 4 },
+{ 80 , 20 , 11 , 5 },
+{ 80 , 20 , 11 , 6 },
+{ 80 , 20 , 11 , 7 },
+{ 80 , 20 , 11 , 8 },
+{ 80 , 20 , 11 , 9 },
+{ 80 , 20 , 11 , 10 },
+{ 80 , 20 , 11 , 11 },
+{ 80 , 20 , 11 , 12 },
+{ 80 , 20 , 11 , 13 },
+{ 80 , 20 , 11 , 14 },
+{ 80 , 20 , 11 , 15 },
+{ 80 , 20 , 11 , 16 },
+{ 80 , 20 , 11 , 17 },
+{ 80 , 20 , 11 , 18 },
+{ 80 , 20 , 11 , 19 },
+{ 80 , 20 , 12 , 0 },
+{ 80 , 20 , 12 , 1 },
+{ 80 , 20 , 12 , 2 },
+{ 80 , 20 , 12 , 3 },
+{ 80 , 20 , 12 , 4 },
+{ 80 , 20 , 12 , 5 },
+{ 80 , 20 , 12 , 6 },
+{ 80 , 20 , 12 , 7 },
+{ 80 , 20 , 12 , 8 },
+{ 80 , 20 , 12 , 9 },
+{ 80 , 20 , 12 , 10 },
+{ 80 , 20 , 12 , 11 },
+{ 80 , 20 , 12 , 12 },
+{ 80 , 20 , 12 , 13 },
+{ 80 , 20 , 12 , 14 },
+{ 80 , 20 , 12 , 15 },
+{ 80 , 20 , 12 , 16 },
+{ 80 , 20 , 12 , 17 },
+{ 80 , 20 , 12 , 18 },
+{ 80 , 20 , 12 , 19 },
+{ 80 , 20 , 13 , 0 },
+{ 80 , 20 , 13 , 1 },
+{ 80 , 20 , 13 , 2 },
+{ 80 , 20 , 13 , 3 },
+{ 80 , 20 , 13 , 4 },
+{ 80 , 20 , 13 , 5 },
+{ 80 , 20 , 13 , 6 },
+{ 80 , 20 , 13 , 7 },
+{ 80 , 20 , 13 , 8 },
+{ 80 , 20 , 13 , 9 },
+{ 80 , 20 , 13 , 10 },
+{ 80 , 20 , 13 , 11 },
+{ 80 , 20 , 13 , 12 },
+{ 80 , 20 , 13 , 13 },
+{ 80 , 20 , 13 , 14 },
+{ 80 , 20 , 13 , 15 },
+{ 80 , 20 , 13 , 16 },
+{ 80 , 20 , 13 , 17 },
+{ 80 , 20 , 13 , 18 },
+{ 80 , 20 , 13 , 19 },
+{ 80 , 20 , 14 , 0 },
+{ 80 , 20 , 14 , 1 },
+{ 80 , 20 , 14 , 2 },
+{ 80 , 20 , 14 , 3 },
+{ 80 , 20 , 14 , 4 },
+{ 80 , 20 , 14 , 5 },
+{ 80 , 20 , 14 , 6 },
+{ 80 , 20 , 14 , 7 },
+{ 80 , 20 , 14 , 8 },
+{ 80 , 20 , 14 , 9 },
+{ 80 , 20 , 14 , 10 },
+{ 80 , 20 , 14 , 11 },
+{ 80 , 20 , 14 , 12 },
+{ 80 , 20 , 14 , 13 },
+{ 80 , 20 , 14 , 14 },
+{ 80 , 20 , 14 , 15 },
+{ 80 , 20 , 14 , 16 },
+{ 80 , 20 , 14 , 17 },
+{ 80 , 20 , 14 , 18 },
+{ 80 , 20 , 14 , 19 },
+{ 80 , 20 , 15 , 0 },
+{ 80 , 20 , 15 , 1 },
+{ 80 , 20 , 15 , 2 },
+{ 80 , 20 , 15 , 3 },
+{ 80 , 20 , 15 , 4 },
+{ 80 , 20 , 15 , 5 },
+{ 80 , 20 , 15 , 6 },
+{ 80 , 20 , 15 , 7 },
+{ 80 , 20 , 15 , 8 },
+{ 80 , 20 , 15 , 9 },
+{ 80 , 20 , 15 , 10 },
+{ 80 , 20 , 15 , 11 },
+{ 80 , 20 , 15 , 12 },
+{ 80 , 20 , 15 , 13 },
+{ 80 , 20 , 15 , 14 },
+{ 80 , 20 , 15 , 15 },
+{ 80 , 20 , 15 , 16 },
+{ 80 , 20 , 15 , 17 },
+{ 80 , 20 , 15 , 18 },
+{ 80 , 20 , 15 , 19 },
+{ 80 , 20 , 16 , 0 },
+{ 80 , 20 , 16 , 1 },
+{ 80 , 20 , 16 , 2 },
+{ 80 , 20 , 16 , 3 },
+{ 80 , 20 , 16 , 4 },
+{ 80 , 20 , 16 , 5 },
+{ 80 , 20 , 16 , 6 },
+{ 80 , 20 , 16 , 7 },
+{ 80 , 20 , 16 , 8 },
+{ 80 , 20 , 16 , 9 },
+{ 80 , 20 , 16 , 10 },
+{ 80 , 20 , 16 , 11 },
+{ 80 , 20 , 16 , 12 },
+{ 80 , 20 , 16 , 13 },
+{ 80 , 20 , 16 , 14 },
+{ 80 , 20 , 16 , 15 },
+{ 80 , 20 , 16 , 16 },
+{ 80 , 20 , 16 , 17 },
+{ 80 , 20 , 16 , 18 },
+{ 80 , 20 , 16 , 19 },
+{ 80 , 20 , 17 , 0 },
+{ 80 , 20 , 17 , 1 },
+{ 80 , 20 , 17 , 2 },
+{ 80 , 20 , 17 , 3 },
+{ 80 , 20 , 17 , 4 },
+{ 80 , 20 , 17 , 5 },
+{ 80 , 20 , 17 , 6 },
+{ 80 , 20 , 17 , 7 },
+{ 80 , 20 , 17 , 8 },
+{ 80 , 20 , 17 , 9 },
+{ 80 , 20 , 17 , 10 },
+{ 80 , 20 , 17 , 11 },
+{ 80 , 20 , 17 , 12 },
+{ 80 , 20 , 17 , 13 },
+{ 80 , 20 , 17 , 14 },
+{ 80 , 20 , 17 , 15 },
+{ 80 , 20 , 17 , 16 },
+{ 80 , 20 , 17 , 17 },
+{ 80 , 20 , 17 , 18 },
+{ 80 , 20 , 17 , 19 },
+{ 80 , 20 , 18 , 0 },
+{ 80 , 20 , 18 , 1 },
+{ 80 , 20 , 18 , 2 },
+{ 80 , 20 , 18 , 3 },
+{ 80 , 20 , 18 , 4 },
+{ 80 , 20 , 18 , 5 },
+{ 80 , 20 , 18 , 6 },
+{ 80 , 20 , 18 , 7 },
+{ 80 , 20 , 18 , 8 },
+{ 80 , 20 , 18 , 9 },
+{ 80 , 20 , 18 , 10 },
+{ 80 , 20 , 18 , 11 },
+{ 80 , 20 , 18 , 12 },
+{ 80 , 20 , 18 , 13 },
+{ 80 , 20 , 18 , 14 },
+{ 80 , 20 , 18 , 15 },
+{ 80 , 20 , 18 , 16 },
+{ 80 , 20 , 18 , 17 },
+{ 80 , 20 , 18 , 18 },
+{ 80 , 20 , 18 , 19 },
+{ 80 , 20 , 19 , 0 },
+{ 80 , 20 , 19 , 1 },
+{ 80 , 20 , 19 , 2 },
+{ 80 , 20 , 19 , 3 },
+{ 80 , 20 , 19 , 4 },
+{ 80 , 20 , 19 , 5 },
+{ 80 , 20 , 19 , 6 },
+{ 80 , 20 , 19 , 7 },
+{ 80 , 20 , 19 , 8 },
+{ 80 , 20 , 19 , 9 },
+{ 80 , 20 , 19 , 10 },
+{ 80 , 20 , 19 , 11 },
+{ 80 , 20 , 19 , 12 },
+{ 80 , 20 , 19 , 13 },
+{ 80 , 20 , 19 , 14 },
+{ 80 , 20 , 19 , 15 },
+{ 80 , 20 , 19 , 16 },
+{ 80 , 20 , 19 , 17 },
+{ 80 , 20 , 19 , 18 },
+{ 80 , 20 , 19 , 19 },
+{ 80 , 20 , 20 , 0 },
+{ 80 , 20 , 20 , 1 },
+{ 80 , 20 , 20 , 2 },
+{ 80 , 20 , 20 , 3 },
+{ 80 , 20 , 20 , 4 },
+{ 80 , 20 , 20 , 5 },
+{ 80 , 20 , 20 , 6 },
+{ 80 , 20 , 20 , 7 },
+{ 80 , 20 , 20 , 8 },
+{ 80 , 20 , 20 , 9 },
+{ 80 , 20 , 20 , 10 },
+{ 80 , 20 , 20 , 11 },
+{ 80 , 20 , 20 , 12 },
+{ 80 , 20 , 20 , 13 },
+{ 80 , 20 , 20 , 14 },
+{ 80 , 20 , 20 , 15 },
+{ 80 , 20 , 20 , 16 },
+{ 80 , 20 , 20 , 17 },
+{ 80 , 20 , 20 , 18 },
+{ 80 , 20 , 20 , 19 },
+{ 80 , 20 , 21 , 0 },
+{ 80 , 20 , 21 , 1 },
+{ 80 , 20 , 21 , 2 },
+{ 80 , 20 , 21 , 3 },
+{ 80 , 20 , 21 , 4 },
+{ 80 , 20 , 21 , 5 },
+{ 80 , 20 , 21 , 6 },
+{ 80 , 20 , 21 , 7 },
+{ 80 , 20 , 21 , 8 },
+{ 80 , 20 , 21 , 9 },
+{ 80 , 20 , 21 , 10 },
+{ 80 , 20 , 21 , 11 },
+{ 80 , 20 , 21 , 12 },
+{ 80 , 20 , 21 , 13 },
+{ 80 , 20 , 21 , 14 },
+{ 80 , 20 , 21 , 15 },
+{ 80 , 20 , 21 , 16 },
+{ 80 , 20 , 21 , 17 },
+{ 80 , 20 , 21 , 18 },
+{ 80 , 20 , 21 , 19 },
+{ 80 , 20 , 22 , 0 },
+{ 80 , 20 , 22 , 1 },
+{ 80 , 20 , 22 , 2 },
+{ 80 , 20 , 22 , 3 },
+{ 80 , 20 , 22 , 4 },
+{ 80 , 20 , 22 , 5 },
+{ 80 , 20 , 22 , 6 },
+{ 80 , 20 , 22 , 7 },
+{ 80 , 20 , 22 , 8 },
+{ 80 , 20 , 22 , 9 },
+{ 80 , 20 , 22 , 10 },
+{ 80 , 20 , 22 , 11 },
+{ 80 , 20 , 22 , 12 },
+{ 80 , 20 , 22 , 13 },
+{ 80 , 20 , 22 , 14 },
+{ 80 , 20 , 22 , 15 },
+{ 80 , 20 , 22 , 16 },
+{ 80 , 20 , 22 , 17 },
+{ 80 , 20 , 22 , 18 },
+{ 80 , 20 , 22 , 19 },
+{ 80 , 20 , 23 , 0 },
+{ 80 , 20 , 23 , 1 },
+{ 80 , 20 , 23 , 2 },
+{ 80 , 20 , 23 , 3 },
+{ 80 , 20 , 23 , 4 },
+{ 80 , 20 , 23 , 5 },
+{ 80 , 20 , 23 , 6 },
+{ 80 , 20 , 23 , 7 },
+{ 80 , 20 , 23 , 8 },
+{ 80 , 20 , 23 , 9 },
+{ 80 , 20 , 23 , 10 },
+{ 80 , 20 , 23 , 11 },
+{ 80 , 20 , 23 , 12 },
+{ 80 , 20 , 23 , 13 },
+{ 80 , 20 , 23 , 14 },
+{ 80 , 20 , 23 , 15 },
+{ 80 , 20 , 23 , 16 },
+{ 80 , 20 , 23 , 17 },
+{ 80 , 20 , 23 , 18 },
+{ 80 , 20 , 23 , 19 },
+{ 80 , 20 , 24 , 0 },
+{ 80 , 20 , 24 , 1 },
+{ 80 , 20 , 24 , 2 },
+{ 80 , 20 , 24 , 3 },
+{ 80 , 20 , 24 , 4 },
+{ 80 , 20 , 24 , 5 },
+{ 80 , 20 , 24 , 6 },
+{ 80 , 20 , 24 , 7 },
+{ 80 , 20 , 24 , 8 },
+{ 80 , 20 , 24 , 9 },
+{ 80 , 20 , 24 , 10 },
+{ 80 , 20 , 24 , 11 },
+{ 80 , 20 , 24 , 12 },
+{ 80 , 20 , 24 , 13 },
+{ 80 , 20 , 24 , 14 },
+{ 80 , 20 , 24 , 15 },
+{ 80 , 20 , 24 , 16 },
+{ 80 , 20 , 24 , 17 },
+{ 80 , 20 , 24 , 18 },
+{ 80 , 20 , 24 , 19 },
+{ 80 , 20 , 25 , 0 },
+{ 80 , 20 , 25 , 1 },
+{ 80 , 20 , 25 , 2 },
+{ 80 , 20 , 25 , 3 },
+{ 80 , 20 , 25 , 4 },
+{ 80 , 20 , 25 , 5 },
+{ 80 , 20 , 25 , 6 },
+{ 80 , 20 , 25 , 7 },
+{ 80 , 20 , 25 , 8 },
+{ 80 , 20 , 25 , 9 },
+{ 80 , 20 , 25 , 10 },
+{ 80 , 20 , 25 , 11 },
+{ 80 , 20 , 25 , 12 },
+{ 80 , 20 , 25 , 13 },
+{ 80 , 20 , 25 , 14 },
+{ 80 , 20 , 25 , 15 },
+{ 80 , 20 , 25 , 16 },
+{ 80 , 20 , 25 , 17 },
+{ 80 , 20 , 25 , 18 },
+{ 80 , 20 , 25 , 19 },
+{ 80 , 20 , 26 , 0 },
+{ 80 , 20 , 26 , 1 },
+{ 80 , 20 , 26 , 2 },
+{ 80 , 20 , 26 , 3 },
+{ 80 , 20 , 26 , 4 },
+{ 80 , 20 , 26 , 5 },
+{ 80 , 20 , 26 , 6 },
+{ 80 , 20 , 26 , 7 },
+{ 80 , 20 , 26 , 8 },
+{ 80 , 20 , 26 , 9 },
+{ 80 , 20 , 26 , 10 },
+{ 80 , 20 , 26 , 11 },
+{ 80 , 20 , 26 , 12 },
+{ 80 , 20 , 26 , 13 },
+{ 80 , 20 , 26 , 14 },
+{ 80 , 20 , 26 , 15 },
+{ 80 , 20 , 26 , 16 },
+{ 80 , 20 , 26 , 17 },
+{ 80 , 20 , 26 , 18 },
+{ 80 , 20 , 26 , 19 },
+{ 80 , 20 , 27 , 0 },
+{ 80 , 20 , 27 , 1 },
+{ 80 , 20 , 27 , 2 },
+{ 80 , 20 , 27 , 3 },
+{ 80 , 20 , 27 , 4 },
+{ 80 , 20 , 27 , 5 },
+{ 80 , 20 , 27 , 6 },
+{ 80 , 20 , 27 , 7 },
+{ 80 , 20 , 27 , 8 },
+{ 80 , 20 , 27 , 9 },
+{ 80 , 20 , 27 , 10 },
+{ 80 , 20 , 27 , 11 },
+{ 80 , 20 , 27 , 12 },
+{ 80 , 20 , 27 , 13 },
+{ 80 , 20 , 27 , 14 },
+{ 80 , 20 , 27 , 15 },
+{ 80 , 20 , 27 , 16 },
+{ 80 , 20 , 27 , 17 },
+{ 80 , 20 , 27 , 18 },
+{ 80 , 20 , 27 , 19 },
+{ 80 , 20 , 28 , 0 },
+{ 80 , 20 , 28 , 1 },
+{ 80 , 20 , 28 , 2 },
+{ 80 , 20 , 28 , 3 },
+{ 80 , 20 , 28 , 4 },
+{ 80 , 20 , 28 , 5 },
+{ 80 , 20 , 28 , 6 },
+{ 80 , 20 , 28 , 7 },
+{ 80 , 20 , 28 , 8 },
+{ 80 , 20 , 28 , 9 },
+{ 80 , 20 , 28 , 10 },
+{ 80 , 20 , 28 , 11 },
+{ 80 , 20 , 28 , 12 },
+{ 80 , 20 , 28 , 13 },
+{ 80 , 20 , 28 , 14 },
+{ 80 , 20 , 28 , 15 },
+{ 80 , 20 , 28 , 16 },
+{ 80 , 20 , 28 , 17 },
+{ 80 , 20 , 28 , 18 },
+{ 80 , 20 , 28 , 19 },
+{ 80 , 20 , 29 , 0 },
+{ 80 , 20 , 29 , 1 },
+{ 80 , 20 , 29 , 2 },
+{ 80 , 20 , 29 , 3 },
+{ 80 , 20 , 29 , 4 },
+{ 80 , 20 , 29 , 5 },
+{ 80 , 20 , 29 , 6 },
+{ 80 , 20 , 29 , 7 },
+{ 80 , 20 , 29 , 8 },
+{ 80 , 20 , 29 , 9 },
+{ 80 , 20 , 29 , 10 },
+{ 80 , 20 , 29 , 11 },
+{ 80 , 20 , 29 , 12 },
+{ 80 , 20 , 29 , 13 },
+{ 80 , 20 , 29 , 14 },
+{ 80 , 20 , 29 , 15 },
+{ 80 , 20 , 29 , 16 },
+{ 80 , 20 , 29 , 17 },
+{ 80 , 20 , 29 , 18 },
+{ 80 , 20 , 29 , 19 },
+{ 80 , 20 , 30 , 0 },
+{ 80 , 20 , 30 , 1 },
+{ 80 , 20 , 30 , 2 },
+{ 80 , 20 , 30 , 3 },
+{ 80 , 20 , 30 , 4 },
+{ 80 , 20 , 30 , 5 },
+{ 80 , 20 , 30 , 6 },
+{ 80 , 20 , 30 , 7 },
+{ 80 , 20 , 30 , 8 },
+{ 80 , 20 , 30 , 9 },
+{ 80 , 20 , 30 , 10 },
+{ 80 , 20 , 30 , 11 },
+{ 80 , 20 , 30 , 12 },
+{ 80 , 20 , 30 , 13 },
+{ 80 , 20 , 30 , 14 },
+{ 80 , 20 , 30 , 15 },
+{ 80 , 20 , 30 , 16 },
+{ 80 , 20 , 30 , 17 },
+{ 80 , 20 , 30 , 18 },
+{ 80 , 20 , 30 , 19 },
+{ 80 , 20 , 31 , 0 },
+{ 80 , 20 , 31 , 1 },
+{ 80 , 20 , 31 , 2 },
+{ 80 , 20 , 31 , 3 },
+{ 80 , 20 , 31 , 4 },
+{ 80 , 20 , 31 , 5 },
+{ 80 , 20 , 31 , 6 },
+{ 80 , 20 , 31 , 7 },
+{ 80 , 20 , 31 , 8 },
+{ 80 , 20 , 31 , 9 },
+{ 80 , 20 , 31 , 10 },
+{ 80 , 20 , 31 , 11 },
+{ 80 , 20 , 31 , 12 },
+{ 80 , 20 , 31 , 13 },
+{ 80 , 20 , 31 , 14 },
+{ 80 , 20 , 31 , 15 },
+{ 80 , 20 , 31 , 16 },
+{ 80 , 20 , 31 , 17 },
+{ 80 , 20 , 31 , 18 },
+{ 80 , 20 , 31 , 19 },
+{ 80 , 20 , 32 , 0 },
+{ 80 , 20 , 32 , 1 },
+{ 80 , 20 , 32 , 2 },
+{ 80 , 20 , 32 , 3 },
+{ 80 , 20 , 32 , 4 },
+{ 80 , 20 , 32 , 5 },
+{ 80 , 20 , 32 , 6 },
+{ 80 , 20 , 32 , 7 },
+{ 80 , 20 , 32 , 8 },
+{ 80 , 20 , 32 , 9 },
+{ 80 , 20 , 32 , 10 },
+{ 80 , 20 , 32 , 11 },
+{ 80 , 20 , 32 , 12 },
+{ 80 , 20 , 32 , 13 },
+{ 80 , 20 , 32 , 14 },
+{ 80 , 20 , 32 , 15 },
+{ 80 , 20 , 32 , 16 },
+{ 80 , 20 , 32 , 17 },
+{ 80 , 20 , 32 , 18 },
+{ 80 , 20 , 32 , 19 },
+{ 80 , 20 , 33 , 0 },
+{ 80 , 20 , 33 , 1 },
+{ 80 , 20 , 33 , 2 },
+{ 80 , 20 , 33 , 3 },
+{ 80 , 20 , 33 , 4 },
+{ 80 , 20 , 33 , 5 },
+{ 80 , 20 , 33 , 6 },
+{ 80 , 20 , 33 , 7 },
+{ 80 , 20 , 33 , 8 },
+{ 80 , 20 , 33 , 9 },
+{ 80 , 20 , 33 , 10 },
+{ 80 , 20 , 33 , 11 },
+{ 80 , 20 , 33 , 12 },
+{ 80 , 20 , 33 , 13 },
+{ 80 , 20 , 33 , 14 },
+{ 80 , 20 , 33 , 15 },
+{ 80 , 20 , 33 , 16 },
+{ 80 , 20 , 33 , 17 },
+{ 80 , 20 , 33 , 18 },
+{ 80 , 20 , 33 , 19 },
+{ 80 , 20 , 34 , 0 },
+{ 80 , 20 , 34 , 1 },
+{ 80 , 20 , 34 , 2 },
+{ 80 , 20 , 34 , 3 },
+{ 80 , 20 , 34 , 4 },
+{ 80 , 20 , 34 , 5 },
+{ 80 , 20 , 34 , 6 },
+{ 80 , 20 , 34 , 7 },
+{ 80 , 20 , 34 , 8 },
+{ 80 , 20 , 34 , 9 },
+{ 80 , 20 , 34 , 10 },
+{ 80 , 20 , 34 , 11 },
+{ 80 , 20 , 34 , 12 },
+{ 80 , 20 , 34 , 13 },
+{ 80 , 20 , 34 , 14 },
+{ 80 , 20 , 34 , 15 },
+{ 80 , 20 , 34 , 16 },
+{ 80 , 20 , 34 , 17 },
+{ 80 , 20 , 34 , 18 },
+{ 80 , 20 , 34 , 19 },
+{ 80 , 20 , 35 , 0 },
+{ 80 , 20 , 35 , 1 },
+{ 80 , 20 , 35 , 2 },
+{ 80 , 20 , 35 , 3 },
+{ 80 , 20 , 35 , 4 },
+{ 80 , 20 , 35 , 5 },
+{ 80 , 20 , 35 , 6 },
+{ 80 , 20 , 35 , 7 },
+{ 80 , 20 , 35 , 8 },
+{ 80 , 20 , 35 , 9 },
+{ 80 , 20 , 35 , 10 },
+{ 80 , 20 , 35 , 11 },
+{ 80 , 20 , 35 , 12 },
+{ 80 , 20 , 35 , 13 },
+{ 80 , 20 , 35 , 14 },
+{ 80 , 20 , 35 , 15 },
+{ 80 , 20 , 35 , 16 },
+{ 80 , 20 , 35 , 17 },
+{ 80 , 20 , 35 , 18 },
+{ 80 , 20 , 35 , 19 },
+{ 80 , 20 , 36 , 0 },
+{ 80 , 20 , 36 , 1 },
+{ 80 , 20 , 36 , 2 },
+{ 80 , 20 , 36 , 3 },
+{ 80 , 20 , 36 , 4 },
+{ 80 , 20 , 36 , 5 },
+{ 80 , 20 , 36 , 6 },
+{ 80 , 20 , 36 , 7 },
+{ 80 , 20 , 36 , 8 },
+{ 80 , 20 , 36 , 9 },
+{ 80 , 20 , 36 , 10 },
+{ 80 , 20 , 36 , 11 },
+{ 80 , 20 , 36 , 12 },
+{ 80 , 20 , 36 , 13 },
+{ 80 , 20 , 36 , 14 },
+{ 80 , 20 , 36 , 15 },
+{ 80 , 20 , 36 , 16 },
+{ 80 , 20 , 36 , 17 },
+{ 80 , 20 , 36 , 18 },
+{ 80 , 20 , 36 , 19 },
+{ 80 , 20 , 37 , 0 },
+{ 80 , 20 , 37 , 1 },
+{ 80 , 20 , 37 , 2 },
+{ 80 , 20 , 37 , 3 },
+{ 80 , 20 , 37 , 4 },
+{ 80 , 20 , 37 , 5 },
+{ 80 , 20 , 37 , 6 },
+{ 80 , 20 , 37 , 7 },
+{ 80 , 20 , 37 , 8 },
+{ 80 , 20 , 37 , 9 },
+{ 80 , 20 , 37 , 10 },
+{ 80 , 20 , 37 , 11 },
+{ 80 , 20 , 37 , 12 },
+{ 80 , 20 , 37 , 13 },
+{ 80 , 20 , 37 , 14 },
+{ 80 , 20 , 37 , 15 },
+{ 80 , 20 , 37 , 16 },
+{ 80 , 20 , 37 , 17 },
+{ 80 , 20 , 37 , 18 },
+{ 80 , 20 , 37 , 19 },
+{ 80 , 20 , 38 , 0 },
+{ 80 , 20 , 38 , 1 },
+{ 80 , 20 , 38 , 2 },
+{ 80 , 20 , 38 , 3 },
+{ 80 , 20 , 38 , 4 },
+{ 80 , 20 , 38 , 5 },
+{ 80 , 20 , 38 , 6 },
+{ 80 , 20 , 38 , 7 },
+{ 80 , 20 , 38 , 8 },
+{ 80 , 20 , 38 , 9 },
+{ 80 , 20 , 38 , 10 },
+{ 80 , 20 , 38 , 11 },
+{ 80 , 20 , 38 , 12 },
+{ 80 , 20 , 38 , 13 },
+{ 80 , 20 , 38 , 14 },
+{ 80 , 20 , 38 , 15 },
+{ 80 , 20 , 38 , 16 },
+{ 80 , 20 , 38 , 17 },
+{ 80 , 20 , 38 , 18 },
+{ 80 , 20 , 38 , 19 },
+{ 80 , 20 , 39 , 0 },
+{ 80 , 20 , 39 , 1 },
+{ 80 , 20 , 39 , 2 },
+{ 80 , 20 , 39 , 3 },
+{ 80 , 20 , 39 , 4 },
+{ 80 , 20 , 39 , 5 },
+{ 80 , 20 , 39 , 6 },
+{ 80 , 20 , 39 , 7 },
+{ 80 , 20 , 39 , 8 },
+{ 80 , 20 , 39 , 9 },
+{ 80 , 20 , 39 , 10 },
+{ 80 , 20 , 39 , 11 },
+{ 80 , 20 , 39 , 12 },
+{ 80 , 20 , 39 , 13 },
+{ 80 , 20 , 39 , 14 },
+{ 80 , 20 , 39 , 15 },
+{ 80 , 20 , 39 , 16 },
+{ 80 , 20 , 39 , 17 },
+{ 80 , 20 , 39 , 18 },
+{ 80 , 20 , 39 , 19 },
+{ 80 , 20 , 40 , 0 },
+{ 80 , 20 , 40 , 1 },
+{ 80 , 20 , 40 , 2 },
+{ 80 , 20 , 40 , 3 },
+{ 80 , 20 , 40 , 4 },
+{ 80 , 20 , 40 , 5 },
+{ 80 , 20 , 40 , 6 },
+{ 80 , 20 , 40 , 7 },
+{ 80 , 20 , 40 , 8 },
+{ 80 , 20 , 40 , 9 },
+{ 80 , 20 , 40 , 10 },
+{ 80 , 20 , 40 , 11 },
+{ 80 , 20 , 40 , 12 },
+{ 80 , 20 , 40 , 13 },
+{ 80 , 20 , 40 , 14 },
+{ 80 , 20 , 40 , 15 },
+{ 80 , 20 , 40 , 16 },
+{ 80 , 20 , 40 , 17 },
+{ 80 , 20 , 40 , 18 },
+{ 80 , 20 , 40 , 19 },
+{ 80 , 20 , 41 , 0 },
+{ 80 , 20 , 41 , 1 },
+{ 80 , 20 , 41 , 2 },
+{ 80 , 20 , 41 , 3 },
+{ 80 , 20 , 41 , 4 },
+{ 80 , 20 , 41 , 5 },
+{ 80 , 20 , 41 , 6 },
+{ 80 , 20 , 41 , 7 },
+{ 80 , 20 , 41 , 8 },
+{ 80 , 20 , 41 , 9 },
+{ 80 , 20 , 41 , 10 },
+{ 80 , 20 , 41 , 11 },
+{ 80 , 20 , 41 , 12 },
+{ 80 , 20 , 41 , 13 },
+{ 80 , 20 , 41 , 14 },
+{ 80 , 20 , 41 , 15 },
+{ 80 , 20 , 41 , 16 },
+{ 80 , 20 , 41 , 17 },
+{ 80 , 20 , 41 , 18 },
+{ 80 , 20 , 41 , 19 },
+{ 80 , 20 , 42 , 0 },
+{ 80 , 20 , 42 , 1 },
+{ 80 , 20 , 42 , 2 },
+{ 80 , 20 , 42 , 3 },
+{ 80 , 20 , 42 , 4 },
+{ 80 , 20 , 42 , 5 },
+{ 80 , 20 , 42 , 6 },
+{ 80 , 20 , 42 , 7 },
+{ 80 , 20 , 42 , 8 },
+{ 80 , 20 , 42 , 9 },
+{ 80 , 20 , 42 , 10 },
+{ 80 , 20 , 42 , 11 },
+{ 80 , 20 , 42 , 12 },
+{ 80 , 20 , 42 , 13 },
+{ 80 , 20 , 42 , 14 },
+{ 80 , 20 , 42 , 15 },
+{ 80 , 20 , 42 , 16 },
+{ 80 , 20 , 42 , 17 },
+{ 80 , 20 , 42 , 18 },
+{ 80 , 20 , 42 , 19 },
+{ 80 , 20 , 43 , 0 },
+{ 80 , 20 , 43 , 1 },
+{ 80 , 20 , 43 , 2 },
+{ 80 , 20 , 43 , 3 },
+{ 80 , 20 , 43 , 4 },
+{ 80 , 20 , 43 , 5 },
+{ 80 , 20 , 43 , 6 },
+{ 80 , 20 , 43 , 7 },
+{ 80 , 20 , 43 , 8 },
+{ 80 , 20 , 43 , 9 },
+{ 80 , 20 , 43 , 10 },
+{ 80 , 20 , 43 , 11 },
+{ 80 , 20 , 43 , 12 },
+{ 80 , 20 , 43 , 13 },
+{ 80 , 20 , 43 , 14 },
+{ 80 , 20 , 43 , 15 },
+{ 80 , 20 , 43 , 16 },
+{ 80 , 20 , 43 , 17 },
+{ 80 , 20 , 43 , 18 },
+{ 80 , 20 , 43 , 19 },
+{ 80 , 20 , 44 , 0 },
+{ 80 , 20 , 44 , 1 },
+{ 80 , 20 , 44 , 2 },
+{ 80 , 20 , 44 , 3 },
+{ 80 , 20 , 44 , 4 },
+{ 80 , 20 , 44 , 5 },
+{ 80 , 20 , 44 , 6 },
+{ 80 , 20 , 44 , 7 },
+{ 80 , 20 , 44 , 8 },
+{ 80 , 20 , 44 , 9 },
+{ 80 , 20 , 44 , 10 },
+{ 80 , 20 , 44 , 11 },
+{ 80 , 20 , 44 , 12 },
+{ 80 , 20 , 44 , 13 },
+{ 80 , 20 , 44 , 14 },
+{ 80 , 20 , 44 , 15 },
+{ 80 , 20 , 44 , 16 },
+{ 80 , 20 , 44 , 17 },
+{ 80 , 20 , 44 , 18 },
+{ 80 , 20 , 44 , 19 },
+{ 80 , 20 , 45 , 0 },
+{ 80 , 20 , 45 , 1 },
+{ 80 , 20 , 45 , 2 },
+{ 80 , 20 , 45 , 3 },
+{ 80 , 20 , 45 , 4 },
+{ 80 , 20 , 45 , 5 },
+{ 80 , 20 , 45 , 6 },
+{ 80 , 20 , 45 , 7 },
+{ 80 , 20 , 45 , 8 },
+{ 80 , 20 , 45 , 9 },
+{ 80 , 20 , 45 , 10 },
+{ 80 , 20 , 45 , 11 },
+{ 80 , 20 , 45 , 12 },
+{ 80 , 20 , 45 , 13 },
+{ 80 , 20 , 45 , 14 },
+{ 80 , 20 , 45 , 15 },
+{ 80 , 20 , 45 , 16 },
+{ 80 , 20 , 45 , 17 },
+{ 80 , 20 , 45 , 18 },
+{ 80 , 20 , 45 , 19 },
+{ 80 , 20 , 46 , 0 },
+{ 80 , 20 , 46 , 1 },
+{ 80 , 20 , 46 , 2 },
+{ 80 , 20 , 46 , 3 },
+{ 80 , 20 , 46 , 4 },
+{ 80 , 20 , 46 , 5 },
+{ 80 , 20 , 46 , 6 },
+{ 80 , 20 , 46 , 7 },
+{ 80 , 20 , 46 , 8 },
+{ 80 , 20 , 46 , 9 },
+{ 80 , 20 , 46 , 10 },
+{ 80 , 20 , 46 , 11 },
+{ 80 , 20 , 46 , 12 },
+{ 80 , 20 , 46 , 13 },
+{ 80 , 20 , 46 , 14 },
+{ 80 , 20 , 46 , 15 },
+{ 80 , 20 , 46 , 16 },
+{ 80 , 20 , 46 , 17 },
+{ 80 , 20 , 46 , 18 },
+{ 80 , 20 , 46 , 19 },
+{ 80 , 20 , 47 , 0 },
+{ 80 , 20 , 47 , 1 },
+{ 80 , 20 , 47 , 2 },
+{ 80 , 20 , 47 , 3 },
+{ 80 , 20 , 47 , 4 },
+{ 80 , 20 , 47 , 5 },
+{ 80 , 20 , 47 , 6 },
+{ 80 , 20 , 47 , 7 },
+{ 80 , 20 , 47 , 8 },
+{ 80 , 20 , 47 , 9 },
+{ 80 , 20 , 47 , 10 },
+{ 80 , 20 , 47 , 11 },
+{ 80 , 20 , 47 , 12 },
+{ 80 , 20 , 47 , 13 },
+{ 80 , 20 , 47 , 14 },
+{ 80 , 20 , 47 , 15 },
+{ 80 , 20 , 47 , 16 },
+{ 80 , 20 , 47 , 17 },
+{ 80 , 20 , 47 , 18 },
+{ 80 , 20 , 47 , 19 },
+{ 80 , 20 , 48 , 0 },
+{ 80 , 20 , 48 , 1 },
+{ 80 , 20 , 48 , 2 },
+{ 80 , 20 , 48 , 3 },
+{ 80 , 20 , 48 , 4 },
+{ 80 , 20 , 48 , 5 },
+{ 80 , 20 , 48 , 6 },
+{ 80 , 20 , 48 , 7 },
+{ 80 , 20 , 48 , 8 },
+{ 80 , 20 , 48 , 9 },
+{ 80 , 20 , 48 , 10 },
+{ 80 , 20 , 48 , 11 },
+{ 80 , 20 , 48 , 12 },
+{ 80 , 20 , 48 , 13 },
+{ 80 , 20 , 48 , 14 },
+{ 80 , 20 , 48 , 15 },
+{ 80 , 20 , 48 , 16 },
+{ 80 , 20 , 48 , 17 },
+{ 80 , 20 , 48 , 18 },
+{ 80 , 20 , 48 , 19 },
+{ 80 , 20 , 49 , 0 },
+{ 80 , 20 , 49 , 1 },
+{ 80 , 20 , 49 , 2 },
+{ 80 , 20 , 49 , 3 },
+{ 80 , 20 , 49 , 4 },
+{ 80 , 20 , 49 , 5 },
+{ 80 , 20 , 49 , 6 },
+{ 80 , 20 , 49 , 7 },
+{ 80 , 20 , 49 , 8 },
+{ 80 , 20 , 49 , 9 },
+{ 80 , 20 , 49 , 10 },
+{ 80 , 20 , 49 , 11 },
+{ 80 , 20 , 49 , 12 },
+{ 80 , 20 , 49 , 13 },
+{ 80 , 20 , 49 , 14 },
+{ 80 , 20 , 49 , 15 },
+{ 80 , 20 , 49 , 16 },
+{ 80 , 20 , 49 , 17 },
+{ 80 , 20 , 49 , 18 },
+{ 80 , 20 , 49 , 19 },
+{ 80 , 20 , 50 , 0 },
+{ 80 , 20 , 50 , 1 },
+{ 80 , 20 , 50 , 2 },
+{ 80 , 20 , 50 , 3 },
+{ 80 , 20 , 50 , 4 },
+{ 80 , 20 , 50 , 5 },
+{ 80 , 20 , 50 , 6 },
+{ 80 , 20 , 50 , 7 },
+{ 80 , 20 , 50 , 8 },
+{ 80 , 20 , 50 , 9 },
+{ 80 , 20 , 50 , 10 },
+{ 80 , 20 , 50 , 11 },
+{ 80 , 20 , 50 , 12 },
+{ 80 , 20 , 50 , 13 },
+{ 80 , 20 , 50 , 14 },
+{ 80 , 20 , 50 , 15 },
+{ 80 , 20 , 50 , 16 },
+{ 80 , 20 , 50 , 17 },
+{ 80 , 20 , 50 , 18 },
+{ 80 , 20 , 50 , 19 },
+{ 80 , 20 , 51 , 0 },
+{ 80 , 20 , 51 , 1 },
+{ 80 , 20 , 51 , 2 },
+{ 80 , 20 , 51 , 3 },
+{ 80 , 20 , 51 , 4 },
+{ 80 , 20 , 51 , 5 },
+{ 80 , 20 , 51 , 6 },
+{ 80 , 20 , 51 , 7 },
+{ 80 , 20 , 51 , 8 },
+{ 80 , 20 , 51 , 9 },
+{ 80 , 20 , 51 , 10 },
+{ 80 , 20 , 51 , 11 },
+{ 80 , 20 , 51 , 12 },
+{ 80 , 20 , 51 , 13 },
+{ 80 , 20 , 51 , 14 },
+{ 80 , 20 , 51 , 15 },
+{ 80 , 20 , 51 , 16 },
+{ 80 , 20 , 51 , 17 },
+{ 80 , 20 , 51 , 18 },
+{ 80 , 20 , 51 , 19 },
+{ 80 , 20 , 52 , 0 },
+{ 80 , 20 , 52 , 1 },
+{ 80 , 20 , 52 , 2 },
+{ 80 , 20 , 52 , 3 },
+{ 80 , 20 , 52 , 4 },
+{ 80 , 20 , 52 , 5 },
+{ 80 , 20 , 52 , 6 },
+{ 80 , 20 , 52 , 7 },
+{ 80 , 20 , 52 , 8 },
+{ 80 , 20 , 52 , 9 },
+{ 80 , 20 , 52 , 10 },
+{ 80 , 20 , 52 , 11 },
+{ 80 , 20 , 52 , 12 },
+{ 80 , 20 , 52 , 13 },
+{ 80 , 20 , 52 , 14 },
+{ 80 , 20 , 52 , 15 },
+{ 80 , 20 , 52 , 16 },
+{ 80 , 20 , 52 , 17 },
+{ 80 , 20 , 52 , 18 },
+{ 80 , 20 , 52 , 19 },
+{ 80 , 20 , 53 , 0 },
+{ 80 , 20 , 53 , 1 },
+{ 80 , 20 , 53 , 2 },
+{ 80 , 20 , 53 , 3 },
+{ 80 , 20 , 53 , 4 },
+{ 80 , 20 , 53 , 5 },
+{ 80 , 20 , 53 , 6 },
+{ 80 , 20 , 53 , 7 },
+{ 80 , 20 , 53 , 8 },
+{ 80 , 20 , 53 , 9 },
+{ 80 , 20 , 53 , 10 },
+{ 80 , 20 , 53 , 11 },
+{ 80 , 20 , 53 , 12 },
+{ 80 , 20 , 53 , 13 },
+{ 80 , 20 , 53 , 14 },
+{ 80 , 20 , 53 , 15 },
+{ 80 , 20 , 53 , 16 },
+{ 80 , 20 , 53 , 17 },
+{ 80 , 20 , 53 , 18 },
+{ 80 , 20 , 53 , 19 },
+{ 80 , 20 , 54 , 0 },
+{ 80 , 20 , 54 , 1 },
+{ 80 , 20 , 54 , 2 },
+{ 80 , 20 , 54 , 3 },
+{ 80 , 20 , 54 , 4 },
+{ 80 , 20 , 54 , 5 },
+{ 80 , 20 , 54 , 6 },
+{ 80 , 20 , 54 , 7 },
+{ 80 , 20 , 54 , 8 },
+{ 80 , 20 , 54 , 9 },
+{ 80 , 20 , 54 , 10 },
+{ 80 , 20 , 54 , 11 },
+{ 80 , 20 , 54 , 12 },
+{ 80 , 20 , 54 , 13 },
+{ 80 , 20 , 54 , 14 },
+{ 80 , 20 , 54 , 15 },
+{ 80 , 20 , 54 , 16 },
+{ 80 , 20 , 54 , 17 },
+{ 80 , 20 , 54 , 18 },
+{ 80 , 20 , 54 , 19 },
+{ 80 , 20 , 55 , 0 },
+{ 80 , 20 , 55 , 1 },
+{ 80 , 20 , 55 , 2 },
+{ 80 , 20 , 55 , 3 },
+{ 80 , 20 , 55 , 4 },
+{ 80 , 20 , 55 , 5 },
+{ 80 , 20 , 55 , 6 },
+{ 80 , 20 , 55 , 7 },
+{ 80 , 20 , 55 , 8 },
+{ 80 , 20 , 55 , 9 },
+{ 80 , 20 , 55 , 10 },
+{ 80 , 20 , 55 , 11 },
+{ 80 , 20 , 55 , 12 },
+{ 80 , 20 , 55 , 13 },
+{ 80 , 20 , 55 , 14 },
+{ 80 , 20 , 55 , 15 },
+{ 80 , 20 , 55 , 16 },
+{ 80 , 20 , 55 , 17 },
+{ 80 , 20 , 55 , 18 },
+{ 80 , 20 , 55 , 19 },
+{ 80 , 20 , 56 , 0 },
+{ 80 , 20 , 56 , 1 },
+{ 80 , 20 , 56 , 2 },
+{ 80 , 20 , 56 , 3 },
+{ 80 , 20 , 56 , 4 },
+{ 80 , 20 , 56 , 5 },
+{ 80 , 20 , 56 , 6 },
+{ 80 , 20 , 56 , 7 },
+{ 80 , 20 , 56 , 8 },
+{ 80 , 20 , 56 , 9 },
+{ 80 , 20 , 56 , 10 },
+{ 80 , 20 , 56 , 11 },
+{ 80 , 20 , 56 , 12 },
+{ 80 , 20 , 56 , 13 },
+{ 80 , 20 , 56 , 14 },
+{ 80 , 20 , 56 , 15 },
+{ 80 , 20 , 56 , 16 },
+{ 80 , 20 , 56 , 17 },
+{ 80 , 20 , 56 , 18 },
+{ 80 , 20 , 56 , 19 },
+{ 80 , 20 , 57 , 0 },
+{ 80 , 20 , 57 , 1 },
+{ 80 , 20 , 57 , 2 },
+{ 80 , 20 , 57 , 3 },
+{ 80 , 20 , 57 , 4 },
+{ 80 , 20 , 57 , 5 },
+{ 80 , 20 , 57 , 6 },
+{ 80 , 20 , 57 , 7 },
+{ 80 , 20 , 57 , 8 },
+{ 80 , 20 , 57 , 9 },
+{ 80 , 20 , 57 , 10 },
+{ 80 , 20 , 57 , 11 },
+{ 80 , 20 , 57 , 12 },
+{ 80 , 20 , 57 , 13 },
+{ 80 , 20 , 57 , 14 },
+{ 80 , 20 , 57 , 15 },
+{ 80 , 20 , 57 , 16 },
+{ 80 , 20 , 57 , 17 },
+{ 80 , 20 , 57 , 18 },
+{ 80 , 20 , 57 , 19 },
+{ 80 , 20 , 58 , 0 },
+{ 80 , 20 , 58 , 1 },
+{ 80 , 20 , 58 , 2 },
+{ 80 , 20 , 58 , 3 },
+{ 80 , 20 , 58 , 4 },
+{ 80 , 20 , 58 , 5 },
+{ 80 , 20 , 58 , 6 },
+{ 80 , 20 , 58 , 7 },
+{ 80 , 20 , 58 , 8 },
+{ 80 , 20 , 58 , 9 },
+{ 80 , 20 , 58 , 10 },
+{ 80 , 20 , 58 , 11 },
+{ 80 , 20 , 58 , 12 },
+{ 80 , 20 , 58 , 13 },
+{ 80 , 20 , 58 , 14 },
+{ 80 , 20 , 58 , 15 },
+{ 80 , 20 , 58 , 16 },
+{ 80 , 20 , 58 , 17 },
+{ 80 , 20 , 58 , 18 },
+{ 80 , 20 , 58 , 19 },
+{ 80 , 20 , 59 , 0 },
+{ 80 , 20 , 59 , 1 },
+{ 80 , 20 , 59 , 2 },
+{ 80 , 20 , 59 , 3 },
+{ 80 , 20 , 59 , 4 },
+{ 80 , 20 , 59 , 5 },
+{ 80 , 20 , 59 , 6 },
+{ 80 , 20 , 59 , 7 },
+{ 80 , 20 , 59 , 8 },
+{ 80 , 20 , 59 , 9 },
+{ 80 , 20 , 59 , 10 },
+{ 80 , 20 , 59 , 11 },
+{ 80 , 20 , 59 , 12 },
+{ 80 , 20 , 59 , 13 },
+{ 80 , 20 , 59 , 14 },
+{ 80 , 20 , 59 , 15 },
+{ 80 , 20 , 59 , 16 },
+{ 80 , 20 , 59 , 17 },
+{ 80 , 20 , 59 , 18 },
+{ 80 , 20 , 59 , 19 },
+{ 80 , 20 , 60 , 0 },
+{ 80 , 20 , 60 , 1 },
+{ 80 , 20 , 60 , 2 },
+{ 80 , 20 , 60 , 3 },
+{ 80 , 20 , 60 , 4 },
+{ 80 , 20 , 60 , 5 },
+{ 80 , 20 , 60 , 6 },
+{ 80 , 20 , 60 , 7 },
+{ 80 , 20 , 60 , 8 },
+{ 80 , 20 , 60 , 9 },
+{ 80 , 20 , 60 , 10 },
+{ 80 , 20 , 60 , 11 },
+{ 80 , 20 , 60 , 12 },
+{ 80 , 20 , 60 , 13 },
+{ 80 , 20 , 60 , 14 },
+{ 80 , 20 , 60 , 15 },
+{ 80 , 20 , 60 , 16 },
+{ 80 , 20 , 60 , 17 },
+{ 80 , 20 , 60 , 18 },
+{ 80 , 20 , 60 , 19 },
+{ 80 , 20 , 61 , 0 },
+{ 80 , 20 , 61 , 1 },
+{ 80 , 20 , 61 , 2 },
+{ 80 , 20 , 61 , 3 },
+{ 80 , 20 , 61 , 4 },
+{ 80 , 20 , 61 , 5 },
+{ 80 , 20 , 61 , 6 },
+{ 80 , 20 , 61 , 7 },
+{ 80 , 20 , 61 , 8 },
+{ 80 , 20 , 61 , 9 },
+{ 80 , 20 , 61 , 10 },
+{ 80 , 20 , 61 , 11 },
+{ 80 , 20 , 61 , 12 },
+{ 80 , 20 , 61 , 13 },
+{ 80 , 20 , 61 , 14 },
+{ 80 , 20 , 61 , 15 },
+{ 80 , 20 , 61 , 16 },
+{ 80 , 20 , 61 , 17 },
+{ 80 , 20 , 61 , 18 },
+{ 80 , 20 , 61 , 19 },
+{ 80 , 20 , 62 , 0 },
+{ 80 , 20 , 62 , 1 },
+{ 80 , 20 , 62 , 2 },
+{ 80 , 20 , 62 , 3 },
+{ 80 , 20 , 62 , 4 },
+{ 80 , 20 , 62 , 5 },
+{ 80 , 20 , 62 , 6 },
+{ 80 , 20 , 62 , 7 },
+{ 80 , 20 , 62 , 8 },
+{ 80 , 20 , 62 , 9 },
+{ 80 , 20 , 62 , 10 },
+{ 80 , 20 , 62 , 11 },
+{ 80 , 20 , 62 , 12 },
+{ 80 , 20 , 62 , 13 },
+{ 80 , 20 , 62 , 14 },
+{ 80 , 20 , 62 , 15 },
+{ 80 , 20 , 62 , 16 },
+{ 80 , 20 , 62 , 17 },
+{ 80 , 20 , 62 , 18 },
+{ 80 , 20 , 62 , 19 },
+{ 80 , 20 , 63 , 0 },
+{ 80 , 20 , 63 , 1 },
+{ 80 , 20 , 63 , 2 },
+{ 80 , 20 , 63 , 3 },
+{ 80 , 20 , 63 , 4 },
+{ 80 , 20 , 63 , 5 },
+{ 80 , 20 , 63 , 6 },
+{ 80 , 20 , 63 , 7 },
+{ 80 , 20 , 63 , 8 },
+{ 80 , 20 , 63 , 9 },
+{ 80 , 20 , 63 , 10 },
+{ 80 , 20 , 63 , 11 },
+{ 80 , 20 , 63 , 12 },
+{ 80 , 20 , 63 , 13 },
+{ 80 , 20 , 63 , 14 },
+{ 80 , 20 , 63 , 15 },
+{ 80 , 20 , 63 , 16 },
+{ 80 , 20 , 63 , 17 },
+{ 80 , 20 , 63 , 18 },
+{ 80 , 20 , 63 , 19 },
+{ 80 , 20 , 64 , 0 },
+{ 80 , 20 , 64 , 1 },
+{ 80 , 20 , 64 , 2 },
+{ 80 , 20 , 64 , 3 },
+{ 80 , 20 , 64 , 4 },
+{ 80 , 20 , 64 , 5 },
+{ 80 , 20 , 64 , 6 },
+{ 80 , 20 , 64 , 7 },
+{ 80 , 20 , 64 , 8 },
+{ 80 , 20 , 64 , 9 },
+{ 80 , 20 , 64 , 10 },
+{ 80 , 20 , 64 , 11 },
+{ 80 , 20 , 64 , 12 },
+{ 80 , 20 , 64 , 13 },
+{ 80 , 20 , 64 , 14 },
+{ 80 , 20 , 64 , 15 },
+{ 80 , 20 , 64 , 16 },
+{ 80 , 20 , 64 , 17 },
+{ 80 , 20 , 64 , 18 },
+{ 80 , 20 , 64 , 19 },
+{ 80 , 20 , 65 , 0 },
+{ 80 , 20 , 65 , 1 },
+{ 80 , 20 , 65 , 2 },
+{ 80 , 20 , 65 , 3 },
+{ 80 , 20 , 65 , 4 },
+{ 80 , 20 , 65 , 5 },
+{ 80 , 20 , 65 , 6 },
+{ 80 , 20 , 65 , 7 },
+{ 80 , 20 , 65 , 8 },
+{ 80 , 20 , 65 , 9 },
+{ 80 , 20 , 65 , 10 },
+{ 80 , 20 , 65 , 11 },
+{ 80 , 20 , 65 , 12 },
+{ 80 , 20 , 65 , 13 },
+{ 80 , 20 , 65 , 14 },
+{ 80 , 20 , 65 , 15 },
+{ 80 , 20 , 65 , 16 },
+{ 80 , 20 , 65 , 17 },
+{ 80 , 20 , 65 , 18 },
+{ 80 , 20 , 65 , 19 },
+{ 80 , 20 , 66 , 0 },
+{ 80 , 20 , 66 , 1 },
+{ 80 , 20 , 66 , 2 },
+{ 80 , 20 , 66 , 3 },
+{ 80 , 20 , 66 , 4 },
+{ 80 , 20 , 66 , 5 },
+{ 80 , 20 , 66 , 6 },
+{ 80 , 20 , 66 , 7 },
+{ 80 , 20 , 66 , 8 },
+{ 80 , 20 , 66 , 9 },
+{ 80 , 20 , 66 , 10 },
+{ 80 , 20 , 66 , 11 },
+{ 80 , 20 , 66 , 12 },
+{ 80 , 20 , 66 , 13 },
+{ 80 , 20 , 66 , 14 },
+{ 80 , 20 , 66 , 15 },
+{ 80 , 20 , 66 , 16 },
+{ 80 , 20 , 66 , 17 },
+{ 80 , 20 , 66 , 18 },
+{ 80 , 20 , 66 , 19 },
+{ 80 , 20 , 67 , 0 },
+{ 80 , 20 , 67 , 1 },
+{ 80 , 20 , 67 , 2 },
+{ 80 , 20 , 67 , 3 },
+{ 80 , 20 , 67 , 4 },
+{ 80 , 20 , 67 , 5 },
+{ 80 , 20 , 67 , 6 },
+{ 80 , 20 , 67 , 7 },
+{ 80 , 20 , 67 , 8 },
+{ 80 , 20 , 67 , 9 },
+{ 80 , 20 , 67 , 10 },
+{ 80 , 20 , 67 , 11 },
+{ 80 , 20 , 67 , 12 },
+{ 80 , 20 , 67 , 13 },
+{ 80 , 20 , 67 , 14 },
+{ 80 , 20 , 67 , 15 },
+{ 80 , 20 , 67 , 16 },
+{ 80 , 20 , 67 , 17 },
+{ 80 , 20 , 67 , 18 },
+{ 80 , 20 , 67 , 19 },
+{ 80 , 20 , 68 , 0 },
+{ 80 , 20 , 68 , 1 },
+{ 80 , 20 , 68 , 2 },
+{ 80 , 20 , 68 , 3 },
+{ 80 , 20 , 68 , 4 },
+{ 80 , 20 , 68 , 5 },
+{ 80 , 20 , 68 , 6 },
+{ 80 , 20 , 68 , 7 },
+{ 80 , 20 , 68 , 8 },
+{ 80 , 20 , 68 , 9 },
+{ 80 , 20 , 68 , 10 },
+{ 80 , 20 , 68 , 11 },
+{ 80 , 20 , 68 , 12 },
+{ 80 , 20 , 68 , 13 },
+{ 80 , 20 , 68 , 14 },
+{ 80 , 20 , 68 , 15 },
+{ 80 , 20 , 68 , 16 },
+{ 80 , 20 , 68 , 17 },
+{ 80 , 20 , 68 , 18 },
+{ 80 , 20 , 68 , 19 },
+{ 80 , 20 , 69 , 0 },
+{ 80 , 20 , 69 , 1 },
+{ 80 , 20 , 69 , 2 },
+{ 80 , 20 , 69 , 3 },
+{ 80 , 20 , 69 , 4 },
+{ 80 , 20 , 69 , 5 },
+{ 80 , 20 , 69 , 6 },
+{ 80 , 20 , 69 , 7 },
+{ 80 , 20 , 69 , 8 },
+{ 80 , 20 , 69 , 9 },
+{ 80 , 20 , 69 , 10 },
+{ 80 , 20 , 69 , 11 },
+{ 80 , 20 , 69 , 12 },
+{ 80 , 20 , 69 , 13 },
+{ 80 , 20 , 69 , 14 },
+{ 80 , 20 , 69 , 15 },
+{ 80 , 20 , 69 , 16 },
+{ 80 , 20 , 69 , 17 },
+{ 80 , 20 , 69 , 18 },
+{ 80 , 20 , 69 , 19 },
+{ 80 , 20 , 70 , 0 },
+{ 80 , 20 , 70 , 1 },
+{ 80 , 20 , 70 , 2 },
+{ 80 , 20 , 70 , 3 },
+{ 80 , 20 , 70 , 4 },
+{ 80 , 20 , 70 , 5 },
+{ 80 , 20 , 70 , 6 },
+{ 80 , 20 , 70 , 7 },
+{ 80 , 20 , 70 , 8 },
+{ 80 , 20 , 70 , 9 },
+{ 80 , 20 , 70 , 10 },
+{ 80 , 20 , 70 , 11 },
+{ 80 , 20 , 70 , 12 },
+{ 80 , 20 , 70 , 13 },
+{ 80 , 20 , 70 , 14 },
+{ 80 , 20 , 70 , 15 },
+{ 80 , 20 , 70 , 16 },
+{ 80 , 20 , 70 , 17 },
+{ 80 , 20 , 70 , 18 },
+{ 80 , 20 , 70 , 19 },
+{ 80 , 20 , 71 , 0 },
+{ 80 , 20 , 71 , 1 },
+{ 80 , 20 , 71 , 2 },
+{ 80 , 20 , 71 , 3 },
+{ 80 , 20 , 71 , 4 },
+{ 80 , 20 , 71 , 5 },
+{ 80 , 20 , 71 , 6 },
+{ 80 , 20 , 71 , 7 },
+{ 80 , 20 , 71 , 8 },
+{ 80 , 20 , 71 , 9 },
+{ 80 , 20 , 71 , 10 },
+{ 80 , 20 , 71 , 11 },
+{ 80 , 20 , 71 , 12 },
+{ 80 , 20 , 71 , 13 },
+{ 80 , 20 , 71 , 14 },
+{ 80 , 20 , 71 , 15 },
+{ 80 , 20 , 71 , 16 },
+{ 80 , 20 , 71 , 17 },
+{ 80 , 20 , 71 , 18 },
+{ 80 , 20 , 71 , 19 },
+{ 80 , 20 , 72 , 0 },
+{ 80 , 20 , 72 , 1 },
+{ 80 , 20 , 72 , 2 },
+{ 80 , 20 , 72 , 3 },
+{ 80 , 20 , 72 , 4 },
+{ 80 , 20 , 72 , 5 },
+{ 80 , 20 , 72 , 6 },
+{ 80 , 20 , 72 , 7 },
+{ 80 , 20 , 72 , 8 },
+{ 80 , 20 , 72 , 9 },
+{ 80 , 20 , 72 , 10 },
+{ 80 , 20 , 72 , 11 },
+{ 80 , 20 , 72 , 12 },
+{ 80 , 20 , 72 , 13 },
+{ 80 , 20 , 72 , 14 },
+{ 80 , 20 , 72 , 15 },
+{ 80 , 20 , 72 , 16 },
+{ 80 , 20 , 72 , 17 },
+{ 80 , 20 , 72 , 18 },
+{ 80 , 20 , 72 , 19 },
+{ 80 , 20 , 73 , 0 },
+{ 80 , 20 , 73 , 1 },
+{ 80 , 20 , 73 , 2 },
+{ 80 , 20 , 73 , 3 },
+{ 80 , 20 , 73 , 4 },
+{ 80 , 20 , 73 , 5 },
+{ 80 , 20 , 73 , 6 },
+{ 80 , 20 , 73 , 7 },
+{ 80 , 20 , 73 , 8 },
+{ 80 , 20 , 73 , 9 },
+{ 80 , 20 , 73 , 10 },
+{ 80 , 20 , 73 , 11 },
+{ 80 , 20 , 73 , 12 },
+{ 80 , 20 , 73 , 13 },
+{ 80 , 20 , 73 , 14 },
+{ 80 , 20 , 73 , 15 },
+{ 80 , 20 , 73 , 16 },
+{ 80 , 20 , 73 , 17 },
+{ 80 , 20 , 73 , 18 },
+{ 80 , 20 , 73 , 19 },
+{ 80 , 20 , 74 , 0 },
+{ 80 , 20 , 74 , 1 },
+{ 80 , 20 , 74 , 2 },
+{ 80 , 20 , 74 , 3 },
+{ 80 , 20 , 74 , 4 },
+{ 80 , 20 , 74 , 5 },
+{ 80 , 20 , 74 , 6 },
+{ 80 , 20 , 74 , 7 },
+{ 80 , 20 , 74 , 8 },
+{ 80 , 20 , 74 , 9 },
+{ 80 , 20 , 74 , 10 },
+{ 80 , 20 , 74 , 11 },
+{ 80 , 20 , 74 , 12 },
+{ 80 , 20 , 74 , 13 },
+{ 80 , 20 , 74 , 14 },
+{ 80 , 20 , 74 , 15 },
+{ 80 , 20 , 74 , 16 },
+{ 80 , 20 , 74 , 17 },
+{ 80 , 20 , 74 , 18 },
+{ 80 , 20 , 74 , 19 },
+{ 80 , 20 , 75 , 0 },
+{ 80 , 20 , 75 , 1 },
+{ 80 , 20 , 75 , 2 },
+{ 80 , 20 , 75 , 3 },
+{ 80 , 20 , 75 , 4 },
+{ 80 , 20 , 75 , 5 },
+{ 80 , 20 , 75 , 6 },
+{ 80 , 20 , 75 , 7 },
+{ 80 , 20 , 75 , 8 },
+{ 80 , 20 , 75 , 9 },
+{ 80 , 20 , 75 , 10 },
+{ 80 , 20 , 75 , 11 },
+{ 80 , 20 , 75 , 12 },
+{ 80 , 20 , 75 , 13 },
+{ 80 , 20 , 75 , 14 },
+{ 80 , 20 , 75 , 15 },
+{ 80 , 20 , 75 , 16 },
+{ 80 , 20 , 75 , 17 },
+{ 80 , 20 , 75 , 18 },
+{ 80 , 20 , 75 , 19 },
+{ 80 , 20 , 76 , 0 },
+{ 80 , 20 , 76 , 1 },
+{ 80 , 20 , 76 , 2 },
+{ 80 , 20 , 76 , 3 },
+{ 80 , 20 , 76 , 4 },
+{ 80 , 20 , 76 , 5 },
+{ 80 , 20 , 76 , 6 },
+{ 80 , 20 , 76 , 7 },
+{ 80 , 20 , 76 , 8 },
+{ 80 , 20 , 76 , 9 },
+{ 80 , 20 , 76 , 10 },
+{ 80 , 20 , 76 , 11 },
+{ 80 , 20 , 76 , 12 },
+{ 80 , 20 , 76 , 13 },
+{ 80 , 20 , 76 , 14 },
+{ 80 , 20 , 76 , 15 },
+{ 80 , 20 , 76 , 16 },
+{ 80 , 20 , 76 , 17 },
+{ 80 , 20 , 76 , 18 },
+{ 80 , 20 , 76 , 19 },
+{ 80 , 20 , 77 , 0 },
+{ 80 , 20 , 77 , 1 },
+{ 80 , 20 , 77 , 2 },
+{ 80 , 20 , 77 , 3 },
+{ 80 , 20 , 77 , 4 },
+{ 80 , 20 , 77 , 5 },
+{ 80 , 20 , 77 , 6 },
+{ 80 , 20 , 77 , 7 },
+{ 80 , 20 , 77 , 8 },
+{ 80 , 20 , 77 , 9 },
+{ 80 , 20 , 77 , 10 },
+{ 80 , 20 , 77 , 11 },
+{ 80 , 20 , 77 , 12 },
+{ 80 , 20 , 77 , 13 },
+{ 80 , 20 , 77 , 14 },
+{ 80 , 20 , 77 , 15 },
+{ 80 , 20 , 77 , 16 },
+{ 80 , 20 , 77 , 17 },
+{ 80 , 20 , 77 , 18 },
+{ 80 , 20 , 77 , 19 },
+{ 80 , 20 , 78 , 0 },
+{ 80 , 20 , 78 , 1 },
+{ 80 , 20 , 78 , 2 },
+{ 80 , 20 , 78 , 3 },
+{ 80 , 20 , 78 , 4 },
+{ 80 , 20 , 78 , 5 },
+{ 80 , 20 , 78 , 6 },
+{ 80 , 20 , 78 , 7 },
+{ 80 , 20 , 78 , 8 },
+{ 80 , 20 , 78 , 9 },
+{ 80 , 20 , 78 , 10 },
+{ 80 , 20 , 78 , 11 },
+{ 80 , 20 , 78 , 12 },
+{ 80 , 20 , 78 , 13 },
+{ 80 , 20 , 78 , 14 },
+{ 80 , 20 , 78 , 15 },
+{ 80 , 20 , 78 , 16 },
+{ 80 , 20 , 78 , 17 },
+{ 80 , 20 , 78 , 18 },
+{ 80 , 20 , 78 , 19 },
+{ 80 , 20 , 79 , 0 },
+{ 80 , 20 , 79 , 1 },
+{ 80 , 20 , 79 , 2 },
+{ 80 , 20 , 79 , 3 },
+{ 80 , 20 , 79 , 4 },
+{ 80 , 20 , 79 , 5 },
+{ 80 , 20 , 79 , 6 },
+{ 80 , 20 , 79 , 7 },
+{ 80 , 20 , 79 , 8 },
+{ 80 , 20 , 79 , 9 },
+{ 80 , 20 , 79 , 10 },
+{ 80 , 20 , 79 , 11 },
+{ 80 , 20 , 79 , 12 },
+{ 80 , 20 , 79 , 13 },
+{ 80 , 20 , 79 , 14 },
+{ 80 , 20 , 79 , 15 },
+{ 80 , 20 , 79 , 16 },
+{ 80 , 20 , 79 , 17 },
+{ 80 , 20 , 79 , 18 },
+{ 80 , 20 , 79 , 19 },
+{ 80 , 40 , 0 , 0 },
+{ 80 , 40 , 0 , 1 },
+{ 80 , 40 , 0 , 2 },
+{ 80 , 40 , 0 , 3 },
+{ 80 , 40 , 0 , 4 },
+{ 80 , 40 , 0 , 5 },
+{ 80 , 40 , 0 , 6 },
+{ 80 , 40 , 0 , 7 },
+{ 80 , 40 , 0 , 8 },
+{ 80 , 40 , 0 , 9 },
+{ 80 , 40 , 0 , 10 },
+{ 80 , 40 , 0 , 11 },
+{ 80 , 40 , 0 , 12 },
+{ 80 , 40 , 0 , 13 },
+{ 80 , 40 , 0 , 14 },
+{ 80 , 40 , 0 , 15 },
+{ 80 , 40 , 0 , 16 },
+{ 80 , 40 , 0 , 17 },
+{ 80 , 40 , 0 , 18 },
+{ 80 , 40 , 0 , 19 },
+{ 80 , 40 , 0 , 20 },
+{ 80 , 40 , 0 , 21 },
+{ 80 , 40 , 0 , 22 },
+{ 80 , 40 , 0 , 23 },
+{ 80 , 40 , 0 , 24 },
+{ 80 , 40 , 0 , 25 },
+{ 80 , 40 , 0 , 26 },
+{ 80 , 40 , 0 , 27 },
+{ 80 , 40 , 0 , 28 },
+{ 80 , 40 , 0 , 29 },
+{ 80 , 40 , 0 , 30 },
+{ 80 , 40 , 0 , 31 },
+{ 80 , 40 , 0 , 32 },
+{ 80 , 40 , 0 , 33 },
+{ 80 , 40 , 0 , 34 },
+{ 80 , 40 , 0 , 35 },
+{ 80 , 40 , 0 , 36 },
+{ 80 , 40 , 0 , 37 },
+{ 80 , 40 , 0 , 38 },
+{ 80 , 40 , 0 , 39 },
+{ 80 , 40 , 1 , 0 },
+{ 80 , 40 , 1 , 1 },
+{ 80 , 40 , 1 , 2 },
+{ 80 , 40 , 1 , 3 },
+{ 80 , 40 , 1 , 4 },
+{ 80 , 40 , 1 , 5 },
+{ 80 , 40 , 1 , 6 },
+{ 80 , 40 , 1 , 7 },
+{ 80 , 40 , 1 , 8 },
+{ 80 , 40 , 1 , 9 },
+{ 80 , 40 , 1 , 10 },
+{ 80 , 40 , 1 , 11 },
+{ 80 , 40 , 1 , 12 },
+{ 80 , 40 , 1 , 13 },
+{ 80 , 40 , 1 , 14 },
+{ 80 , 40 , 1 , 15 },
+{ 80 , 40 , 1 , 16 },
+{ 80 , 40 , 1 , 17 },
+{ 80 , 40 , 1 , 18 },
+{ 80 , 40 , 1 , 19 },
+{ 80 , 40 , 1 , 20 },
+{ 80 , 40 , 1 , 21 },
+{ 80 , 40 , 1 , 22 },
+{ 80 , 40 , 1 , 23 },
+{ 80 , 40 , 1 , 24 },
+{ 80 , 40 , 1 , 25 },
+{ 80 , 40 , 1 , 26 },
+{ 80 , 40 , 1 , 27 },
+{ 80 , 40 , 1 , 28 },
+{ 80 , 40 , 1 , 29 },
+{ 80 , 40 , 1 , 30 },
+{ 80 , 40 , 1 , 31 },
+{ 80 , 40 , 1 , 32 },
+{ 80 , 40 , 1 , 33 },
+{ 80 , 40 , 1 , 34 },
+{ 80 , 40 , 1 , 35 },
+{ 80 , 40 , 1 , 36 },
+{ 80 , 40 , 1 , 37 },
+{ 80 , 40 , 1 , 38 },
+{ 80 , 40 , 1 , 39 },
+{ 80 , 40 , 2 , 0 },
+{ 80 , 40 , 2 , 1 },
+{ 80 , 40 , 2 , 2 },
+{ 80 , 40 , 2 , 3 },
+{ 80 , 40 , 2 , 4 },
+{ 80 , 40 , 2 , 5 },
+{ 80 , 40 , 2 , 6 },
+{ 80 , 40 , 2 , 7 },
+{ 80 , 40 , 2 , 8 },
+{ 80 , 40 , 2 , 9 },
+{ 80 , 40 , 2 , 10 },
+{ 80 , 40 , 2 , 11 },
+{ 80 , 40 , 2 , 12 },
+{ 80 , 40 , 2 , 13 },
+{ 80 , 40 , 2 , 14 },
+{ 80 , 40 , 2 , 15 },
+{ 80 , 40 , 2 , 16 },
+{ 80 , 40 , 2 , 17 },
+{ 80 , 40 , 2 , 18 },
+{ 80 , 40 , 2 , 19 },
+{ 80 , 40 , 2 , 20 },
+{ 80 , 40 , 2 , 21 },
+{ 80 , 40 , 2 , 22 },
+{ 80 , 40 , 2 , 23 },
+{ 80 , 40 , 2 , 24 },
+{ 80 , 40 , 2 , 25 },
+{ 80 , 40 , 2 , 26 },
+{ 80 , 40 , 2 , 27 },
+{ 80 , 40 , 2 , 28 },
+{ 80 , 40 , 2 , 29 },
+{ 80 , 40 , 2 , 30 },
+{ 80 , 40 , 2 , 31 },
+{ 80 , 40 , 2 , 32 },
+{ 80 , 40 , 2 , 33 },
+{ 80 , 40 , 2 , 34 },
+{ 80 , 40 , 2 , 35 },
+{ 80 , 40 , 2 , 36 },
+{ 80 , 40 , 2 , 37 },
+{ 80 , 40 , 2 , 38 },
+{ 80 , 40 , 2 , 39 },
+{ 80 , 40 , 3 , 0 },
+{ 80 , 40 , 3 , 1 },
+{ 80 , 40 , 3 , 2 },
+{ 80 , 40 , 3 , 3 },
+{ 80 , 40 , 3 , 4 },
+{ 80 , 40 , 3 , 5 },
+{ 80 , 40 , 3 , 6 },
+{ 80 , 40 , 3 , 7 },
+{ 80 , 40 , 3 , 8 },
+{ 80 , 40 , 3 , 9 },
+{ 80 , 40 , 3 , 10 },
+{ 80 , 40 , 3 , 11 },
+{ 80 , 40 , 3 , 12 },
+{ 80 , 40 , 3 , 13 },
+{ 80 , 40 , 3 , 14 },
+{ 80 , 40 , 3 , 15 },
+{ 80 , 40 , 3 , 16 },
+{ 80 , 40 , 3 , 17 },
+{ 80 , 40 , 3 , 18 },
+{ 80 , 40 , 3 , 19 },
+{ 80 , 40 , 3 , 20 },
+{ 80 , 40 , 3 , 21 },
+{ 80 , 40 , 3 , 22 },
+{ 80 , 40 , 3 , 23 },
+{ 80 , 40 , 3 , 24 },
+{ 80 , 40 , 3 , 25 },
+{ 80 , 40 , 3 , 26 },
+{ 80 , 40 , 3 , 27 },
+{ 80 , 40 , 3 , 28 },
+{ 80 , 40 , 3 , 29 },
+{ 80 , 40 , 3 , 30 },
+{ 80 , 40 , 3 , 31 },
+{ 80 , 40 , 3 , 32 },
+{ 80 , 40 , 3 , 33 },
+{ 80 , 40 , 3 , 34 },
+{ 80 , 40 , 3 , 35 },
+{ 80 , 40 , 3 , 36 },
+{ 80 , 40 , 3 , 37 },
+{ 80 , 40 , 3 , 38 },
+{ 80 , 40 , 3 , 39 },
+{ 80 , 40 , 4 , 0 },
+{ 80 , 40 , 4 , 1 },
+{ 80 , 40 , 4 , 2 },
+{ 80 , 40 , 4 , 3 },
+{ 80 , 40 , 4 , 4 },
+{ 80 , 40 , 4 , 5 },
+{ 80 , 40 , 4 , 6 },
+{ 80 , 40 , 4 , 7 },
+{ 80 , 40 , 4 , 8 },
+{ 80 , 40 , 4 , 9 },
+{ 80 , 40 , 4 , 10 },
+{ 80 , 40 , 4 , 11 },
+{ 80 , 40 , 4 , 12 },
+{ 80 , 40 , 4 , 13 },
+{ 80 , 40 , 4 , 14 },
+{ 80 , 40 , 4 , 15 },
+{ 80 , 40 , 4 , 16 },
+{ 80 , 40 , 4 , 17 },
+{ 80 , 40 , 4 , 18 },
+{ 80 , 40 , 4 , 19 },
+{ 80 , 40 , 4 , 20 },
+{ 80 , 40 , 4 , 21 },
+{ 80 , 40 , 4 , 22 },
+{ 80 , 40 , 4 , 23 },
+{ 80 , 40 , 4 , 24 },
+{ 80 , 40 , 4 , 25 },
+{ 80 , 40 , 4 , 26 },
+{ 80 , 40 , 4 , 27 },
+{ 80 , 40 , 4 , 28 },
+{ 80 , 40 , 4 , 29 },
+{ 80 , 40 , 4 , 30 },
+{ 80 , 40 , 4 , 31 },
+{ 80 , 40 , 4 , 32 },
+{ 80 , 40 , 4 , 33 },
+{ 80 , 40 , 4 , 34 },
+{ 80 , 40 , 4 , 35 },
+{ 80 , 40 , 4 , 36 },
+{ 80 , 40 , 4 , 37 },
+{ 80 , 40 , 4 , 38 },
+{ 80 , 40 , 4 , 39 },
+{ 80 , 40 , 5 , 0 },
+{ 80 , 40 , 5 , 1 },
+{ 80 , 40 , 5 , 2 },
+{ 80 , 40 , 5 , 3 },
+{ 80 , 40 , 5 , 4 },
+{ 80 , 40 , 5 , 5 },
+{ 80 , 40 , 5 , 6 },
+{ 80 , 40 , 5 , 7 },
+{ 80 , 40 , 5 , 8 },
+{ 80 , 40 , 5 , 9 },
+{ 80 , 40 , 5 , 10 },
+{ 80 , 40 , 5 , 11 },
+{ 80 , 40 , 5 , 12 },
+{ 80 , 40 , 5 , 13 },
+{ 80 , 40 , 5 , 14 },
+{ 80 , 40 , 5 , 15 },
+{ 80 , 40 , 5 , 16 },
+{ 80 , 40 , 5 , 17 },
+{ 80 , 40 , 5 , 18 },
+{ 80 , 40 , 5 , 19 },
+{ 80 , 40 , 5 , 20 },
+{ 80 , 40 , 5 , 21 },
+{ 80 , 40 , 5 , 22 },
+{ 80 , 40 , 5 , 23 },
+{ 80 , 40 , 5 , 24 },
+{ 80 , 40 , 5 , 25 },
+{ 80 , 40 , 5 , 26 },
+{ 80 , 40 , 5 , 27 },
+{ 80 , 40 , 5 , 28 },
+{ 80 , 40 , 5 , 29 },
+{ 80 , 40 , 5 , 30 },
+{ 80 , 40 , 5 , 31 },
+{ 80 , 40 , 5 , 32 },
+{ 80 , 40 , 5 , 33 },
+{ 80 , 40 , 5 , 34 },
+{ 80 , 40 , 5 , 35 },
+{ 80 , 40 , 5 , 36 },
+{ 80 , 40 , 5 , 37 },
+{ 80 , 40 , 5 , 38 },
+{ 80 , 40 , 5 , 39 },
+{ 80 , 40 , 6 , 0 },
+{ 80 , 40 , 6 , 1 },
+{ 80 , 40 , 6 , 2 },
+{ 80 , 40 , 6 , 3 },
+{ 80 , 40 , 6 , 4 },
+{ 80 , 40 , 6 , 5 },
+{ 80 , 40 , 6 , 6 },
+{ 80 , 40 , 6 , 7 },
+{ 80 , 40 , 6 , 8 },
+{ 80 , 40 , 6 , 9 },
+{ 80 , 40 , 6 , 10 },
+{ 80 , 40 , 6 , 11 },
+{ 80 , 40 , 6 , 12 },
+{ 80 , 40 , 6 , 13 },
+{ 80 , 40 , 6 , 14 },
+{ 80 , 40 , 6 , 15 },
+{ 80 , 40 , 6 , 16 },
+{ 80 , 40 , 6 , 17 },
+{ 80 , 40 , 6 , 18 },
+{ 80 , 40 , 6 , 19 },
+{ 80 , 40 , 6 , 20 },
+{ 80 , 40 , 6 , 21 },
+{ 80 , 40 , 6 , 22 },
+{ 80 , 40 , 6 , 23 },
+{ 80 , 40 , 6 , 24 },
+{ 80 , 40 , 6 , 25 },
+{ 80 , 40 , 6 , 26 },
+{ 80 , 40 , 6 , 27 },
+{ 80 , 40 , 6 , 28 },
+{ 80 , 40 , 6 , 29 },
+{ 80 , 40 , 6 , 30 },
+{ 80 , 40 , 6 , 31 },
+{ 80 , 40 , 6 , 32 },
+{ 80 , 40 , 6 , 33 },
+{ 80 , 40 , 6 , 34 },
+{ 80 , 40 , 6 , 35 },
+{ 80 , 40 , 6 , 36 },
+{ 80 , 40 , 6 , 37 },
+{ 80 , 40 , 6 , 38 },
+{ 80 , 40 , 6 , 39 },
+{ 80 , 40 , 7 , 0 },
+{ 80 , 40 , 7 , 1 },
+{ 80 , 40 , 7 , 2 },
+{ 80 , 40 , 7 , 3 },
+{ 80 , 40 , 7 , 4 },
+{ 80 , 40 , 7 , 5 },
+{ 80 , 40 , 7 , 6 },
+{ 80 , 40 , 7 , 7 },
+{ 80 , 40 , 7 , 8 },
+{ 80 , 40 , 7 , 9 },
+{ 80 , 40 , 7 , 10 },
+{ 80 , 40 , 7 , 11 },
+{ 80 , 40 , 7 , 12 },
+{ 80 , 40 , 7 , 13 },
+{ 80 , 40 , 7 , 14 },
+{ 80 , 40 , 7 , 15 },
+{ 80 , 40 , 7 , 16 },
+{ 80 , 40 , 7 , 17 },
+{ 80 , 40 , 7 , 18 },
+{ 80 , 40 , 7 , 19 },
+{ 80 , 40 , 7 , 20 },
+{ 80 , 40 , 7 , 21 },
+{ 80 , 40 , 7 , 22 },
+{ 80 , 40 , 7 , 23 },
+{ 80 , 40 , 7 , 24 },
+{ 80 , 40 , 7 , 25 },
+{ 80 , 40 , 7 , 26 },
+{ 80 , 40 , 7 , 27 },
+{ 80 , 40 , 7 , 28 },
+{ 80 , 40 , 7 , 29 },
+{ 80 , 40 , 7 , 30 },
+{ 80 , 40 , 7 , 31 },
+{ 80 , 40 , 7 , 32 },
+{ 80 , 40 , 7 , 33 },
+{ 80 , 40 , 7 , 34 },
+{ 80 , 40 , 7 , 35 },
+{ 80 , 40 , 7 , 36 },
+{ 80 , 40 , 7 , 37 },
+{ 80 , 40 , 7 , 38 },
+{ 80 , 40 , 7 , 39 },
+{ 80 , 40 , 8 , 0 },
+{ 80 , 40 , 8 , 1 },
+{ 80 , 40 , 8 , 2 },
+{ 80 , 40 , 8 , 3 },
+{ 80 , 40 , 8 , 4 },
+{ 80 , 40 , 8 , 5 },
+{ 80 , 40 , 8 , 6 },
+{ 80 , 40 , 8 , 7 },
+{ 80 , 40 , 8 , 8 },
+{ 80 , 40 , 8 , 9 },
+{ 80 , 40 , 8 , 10 },
+{ 80 , 40 , 8 , 11 },
+{ 80 , 40 , 8 , 12 },
+{ 80 , 40 , 8 , 13 },
+{ 80 , 40 , 8 , 14 },
+{ 80 , 40 , 8 , 15 },
+{ 80 , 40 , 8 , 16 },
+{ 80 , 40 , 8 , 17 },
+{ 80 , 40 , 8 , 18 },
+{ 80 , 40 , 8 , 19 },
+{ 80 , 40 , 8 , 20 },
+{ 80 , 40 , 8 , 21 },
+{ 80 , 40 , 8 , 22 },
+{ 80 , 40 , 8 , 23 },
+{ 80 , 40 , 8 , 24 },
+{ 80 , 40 , 8 , 25 },
+{ 80 , 40 , 8 , 26 },
+{ 80 , 40 , 8 , 27 },
+{ 80 , 40 , 8 , 28 },
+{ 80 , 40 , 8 , 29 },
+{ 80 , 40 , 8 , 30 },
+{ 80 , 40 , 8 , 31 },
+{ 80 , 40 , 8 , 32 },
+{ 80 , 40 , 8 , 33 },
+{ 80 , 40 , 8 , 34 },
+{ 80 , 40 , 8 , 35 },
+{ 80 , 40 , 8 , 36 },
+{ 80 , 40 , 8 , 37 },
+{ 80 , 40 , 8 , 38 },
+{ 80 , 40 , 8 , 39 },
+{ 80 , 40 , 9 , 0 },
+{ 80 , 40 , 9 , 1 },
+{ 80 , 40 , 9 , 2 },
+{ 80 , 40 , 9 , 3 },
+{ 80 , 40 , 9 , 4 },
+{ 80 , 40 , 9 , 5 },
+{ 80 , 40 , 9 , 6 },
+{ 80 , 40 , 9 , 7 },
+{ 80 , 40 , 9 , 8 },
+{ 80 , 40 , 9 , 9 },
+{ 80 , 40 , 9 , 10 },
+{ 80 , 40 , 9 , 11 },
+{ 80 , 40 , 9 , 12 },
+{ 80 , 40 , 9 , 13 },
+{ 80 , 40 , 9 , 14 },
+{ 80 , 40 , 9 , 15 },
+{ 80 , 40 , 9 , 16 },
+{ 80 , 40 , 9 , 17 },
+{ 80 , 40 , 9 , 18 },
+{ 80 , 40 , 9 , 19 },
+{ 80 , 40 , 9 , 20 },
+{ 80 , 40 , 9 , 21 },
+{ 80 , 40 , 9 , 22 },
+{ 80 , 40 , 9 , 23 },
+{ 80 , 40 , 9 , 24 },
+{ 80 , 40 , 9 , 25 },
+{ 80 , 40 , 9 , 26 },
+{ 80 , 40 , 9 , 27 },
+{ 80 , 40 , 9 , 28 },
+{ 80 , 40 , 9 , 29 },
+{ 80 , 40 , 9 , 30 },
+{ 80 , 40 , 9 , 31 },
+{ 80 , 40 , 9 , 32 },
+{ 80 , 40 , 9 , 33 },
+{ 80 , 40 , 9 , 34 },
+{ 80 , 40 , 9 , 35 },
+{ 80 , 40 , 9 , 36 },
+{ 80 , 40 , 9 , 37 },
+{ 80 , 40 , 9 , 38 },
+{ 80 , 40 , 9 , 39 },
+{ 80 , 40 , 10 , 0 },
+{ 80 , 40 , 10 , 1 },
+{ 80 , 40 , 10 , 2 },
+{ 80 , 40 , 10 , 3 },
+{ 80 , 40 , 10 , 4 },
+{ 80 , 40 , 10 , 5 },
+{ 80 , 40 , 10 , 6 },
+{ 80 , 40 , 10 , 7 },
+{ 80 , 40 , 10 , 8 },
+{ 80 , 40 , 10 , 9 },
+{ 80 , 40 , 10 , 10 },
+{ 80 , 40 , 10 , 11 },
+{ 80 , 40 , 10 , 12 },
+{ 80 , 40 , 10 , 13 },
+{ 80 , 40 , 10 , 14 },
+{ 80 , 40 , 10 , 15 },
+{ 80 , 40 , 10 , 16 },
+{ 80 , 40 , 10 , 17 },
+{ 80 , 40 , 10 , 18 },
+{ 80 , 40 , 10 , 19 },
+{ 80 , 40 , 10 , 20 },
+{ 80 , 40 , 10 , 21 },
+{ 80 , 40 , 10 , 22 },
+{ 80 , 40 , 10 , 23 },
+{ 80 , 40 , 10 , 24 },
+{ 80 , 40 , 10 , 25 },
+{ 80 , 40 , 10 , 26 },
+{ 80 , 40 , 10 , 27 },
+{ 80 , 40 , 10 , 28 },
+{ 80 , 40 , 10 , 29 },
+{ 80 , 40 , 10 , 30 },
+{ 80 , 40 , 10 , 31 },
+{ 80 , 40 , 10 , 32 },
+{ 80 , 40 , 10 , 33 },
+{ 80 , 40 , 10 , 34 },
+{ 80 , 40 , 10 , 35 },
+{ 80 , 40 , 10 , 36 },
+{ 80 , 40 , 10 , 37 },
+{ 80 , 40 , 10 , 38 },
+{ 80 , 40 , 10 , 39 },
+{ 80 , 40 , 11 , 0 },
+{ 80 , 40 , 11 , 1 },
+{ 80 , 40 , 11 , 2 },
+{ 80 , 40 , 11 , 3 },
+{ 80 , 40 , 11 , 4 },
+{ 80 , 40 , 11 , 5 },
+{ 80 , 40 , 11 , 6 },
+{ 80 , 40 , 11 , 7 },
+{ 80 , 40 , 11 , 8 },
+{ 80 , 40 , 11 , 9 },
+{ 80 , 40 , 11 , 10 },
+{ 80 , 40 , 11 , 11 },
+{ 80 , 40 , 11 , 12 },
+{ 80 , 40 , 11 , 13 },
+{ 80 , 40 , 11 , 14 },
+{ 80 , 40 , 11 , 15 },
+{ 80 , 40 , 11 , 16 },
+{ 80 , 40 , 11 , 17 },
+{ 80 , 40 , 11 , 18 },
+{ 80 , 40 , 11 , 19 },
+{ 80 , 40 , 11 , 20 },
+{ 80 , 40 , 11 , 21 },
+{ 80 , 40 , 11 , 22 },
+{ 80 , 40 , 11 , 23 },
+{ 80 , 40 , 11 , 24 },
+{ 80 , 40 , 11 , 25 },
+{ 80 , 40 , 11 , 26 },
+{ 80 , 40 , 11 , 27 },
+{ 80 , 40 , 11 , 28 },
+{ 80 , 40 , 11 , 29 },
+{ 80 , 40 , 11 , 30 },
+{ 80 , 40 , 11 , 31 },
+{ 80 , 40 , 11 , 32 },
+{ 80 , 40 , 11 , 33 },
+{ 80 , 40 , 11 , 34 },
+{ 80 , 40 , 11 , 35 },
+{ 80 , 40 , 11 , 36 },
+{ 80 , 40 , 11 , 37 },
+{ 80 , 40 , 11 , 38 },
+{ 80 , 40 , 11 , 39 },
+{ 80 , 40 , 12 , 0 },
+{ 80 , 40 , 12 , 1 },
+{ 80 , 40 , 12 , 2 },
+{ 80 , 40 , 12 , 3 },
+{ 80 , 40 , 12 , 4 },
+{ 80 , 40 , 12 , 5 },
+{ 80 , 40 , 12 , 6 },
+{ 80 , 40 , 12 , 7 },
+{ 80 , 40 , 12 , 8 },
+{ 80 , 40 , 12 , 9 },
+{ 80 , 40 , 12 , 10 },
+{ 80 , 40 , 12 , 11 },
+{ 80 , 40 , 12 , 12 },
+{ 80 , 40 , 12 , 13 },
+{ 80 , 40 , 12 , 14 },
+{ 80 , 40 , 12 , 15 },
+{ 80 , 40 , 12 , 16 },
+{ 80 , 40 , 12 , 17 },
+{ 80 , 40 , 12 , 18 },
+{ 80 , 40 , 12 , 19 },
+{ 80 , 40 , 12 , 20 },
+{ 80 , 40 , 12 , 21 },
+{ 80 , 40 , 12 , 22 },
+{ 80 , 40 , 12 , 23 },
+{ 80 , 40 , 12 , 24 },
+{ 80 , 40 , 12 , 25 },
+{ 80 , 40 , 12 , 26 },
+{ 80 , 40 , 12 , 27 },
+{ 80 , 40 , 12 , 28 },
+{ 80 , 40 , 12 , 29 },
+{ 80 , 40 , 12 , 30 },
+{ 80 , 40 , 12 , 31 },
+{ 80 , 40 , 12 , 32 },
+{ 80 , 40 , 12 , 33 },
+{ 80 , 40 , 12 , 34 },
+{ 80 , 40 , 12 , 35 },
+{ 80 , 40 , 12 , 36 },
+{ 80 , 40 , 12 , 37 },
+{ 80 , 40 , 12 , 38 },
+{ 80 , 40 , 12 , 39 },
+{ 80 , 40 , 13 , 0 },
+{ 80 , 40 , 13 , 1 },
+{ 80 , 40 , 13 , 2 },
+{ 80 , 40 , 13 , 3 },
+{ 80 , 40 , 13 , 4 },
+{ 80 , 40 , 13 , 5 },
+{ 80 , 40 , 13 , 6 },
+{ 80 , 40 , 13 , 7 },
+{ 80 , 40 , 13 , 8 },
+{ 80 , 40 , 13 , 9 },
+{ 80 , 40 , 13 , 10 },
+{ 80 , 40 , 13 , 11 },
+{ 80 , 40 , 13 , 12 },
+{ 80 , 40 , 13 , 13 },
+{ 80 , 40 , 13 , 14 },
+{ 80 , 40 , 13 , 15 },
+{ 80 , 40 , 13 , 16 },
+{ 80 , 40 , 13 , 17 },
+{ 80 , 40 , 13 , 18 },
+{ 80 , 40 , 13 , 19 },
+{ 80 , 40 , 13 , 20 },
+{ 80 , 40 , 13 , 21 },
+{ 80 , 40 , 13 , 22 },
+{ 80 , 40 , 13 , 23 },
+{ 80 , 40 , 13 , 24 },
+{ 80 , 40 , 13 , 25 },
+{ 80 , 40 , 13 , 26 },
+{ 80 , 40 , 13 , 27 },
+{ 80 , 40 , 13 , 28 },
+{ 80 , 40 , 13 , 29 },
+{ 80 , 40 , 13 , 30 },
+{ 80 , 40 , 13 , 31 },
+{ 80 , 40 , 13 , 32 },
+{ 80 , 40 , 13 , 33 },
+{ 80 , 40 , 13 , 34 },
+{ 80 , 40 , 13 , 35 },
+{ 80 , 40 , 13 , 36 },
+{ 80 , 40 , 13 , 37 },
+{ 80 , 40 , 13 , 38 },
+{ 80 , 40 , 13 , 39 },
+{ 80 , 40 , 14 , 0 },
+{ 80 , 40 , 14 , 1 },
+{ 80 , 40 , 14 , 2 },
+{ 80 , 40 , 14 , 3 },
+{ 80 , 40 , 14 , 4 },
+{ 80 , 40 , 14 , 5 },
+{ 80 , 40 , 14 , 6 },
+{ 80 , 40 , 14 , 7 },
+{ 80 , 40 , 14 , 8 },
+{ 80 , 40 , 14 , 9 },
+{ 80 , 40 , 14 , 10 },
+{ 80 , 40 , 14 , 11 },
+{ 80 , 40 , 14 , 12 },
+{ 80 , 40 , 14 , 13 },
+{ 80 , 40 , 14 , 14 },
+{ 80 , 40 , 14 , 15 },
+{ 80 , 40 , 14 , 16 },
+{ 80 , 40 , 14 , 17 },
+{ 80 , 40 , 14 , 18 },
+{ 80 , 40 , 14 , 19 },
+{ 80 , 40 , 14 , 20 },
+{ 80 , 40 , 14 , 21 },
+{ 80 , 40 , 14 , 22 },
+{ 80 , 40 , 14 , 23 },
+{ 80 , 40 , 14 , 24 },
+{ 80 , 40 , 14 , 25 },
+{ 80 , 40 , 14 , 26 },
+{ 80 , 40 , 14 , 27 },
+{ 80 , 40 , 14 , 28 },
+{ 80 , 40 , 14 , 29 },
+{ 80 , 40 , 14 , 30 },
+{ 80 , 40 , 14 , 31 },
+{ 80 , 40 , 14 , 32 },
+{ 80 , 40 , 14 , 33 },
+{ 80 , 40 , 14 , 34 },
+{ 80 , 40 , 14 , 35 },
+{ 80 , 40 , 14 , 36 },
+{ 80 , 40 , 14 , 37 },
+{ 80 , 40 , 14 , 38 },
+{ 80 , 40 , 14 , 39 },
+{ 80 , 40 , 15 , 0 },
+{ 80 , 40 , 15 , 1 },
+{ 80 , 40 , 15 , 2 },
+{ 80 , 40 , 15 , 3 },
+{ 80 , 40 , 15 , 4 },
+{ 80 , 40 , 15 , 5 },
+{ 80 , 40 , 15 , 6 },
+{ 80 , 40 , 15 , 7 },
+{ 80 , 40 , 15 , 8 },
+{ 80 , 40 , 15 , 9 },
+{ 80 , 40 , 15 , 10 },
+{ 80 , 40 , 15 , 11 },
+{ 80 , 40 , 15 , 12 },
+{ 80 , 40 , 15 , 13 },
+{ 80 , 40 , 15 , 14 },
+{ 80 , 40 , 15 , 15 },
+{ 80 , 40 , 15 , 16 },
+{ 80 , 40 , 15 , 17 },
+{ 80 , 40 , 15 , 18 },
+{ 80 , 40 , 15 , 19 },
+{ 80 , 40 , 15 , 20 },
+{ 80 , 40 , 15 , 21 },
+{ 80 , 40 , 15 , 22 },
+{ 80 , 40 , 15 , 23 },
+{ 80 , 40 , 15 , 24 },
+{ 80 , 40 , 15 , 25 },
+{ 80 , 40 , 15 , 26 },
+{ 80 , 40 , 15 , 27 },
+{ 80 , 40 , 15 , 28 },
+{ 80 , 40 , 15 , 29 },
+{ 80 , 40 , 15 , 30 },
+{ 80 , 40 , 15 , 31 },
+{ 80 , 40 , 15 , 32 },
+{ 80 , 40 , 15 , 33 },
+{ 80 , 40 , 15 , 34 },
+{ 80 , 40 , 15 , 35 },
+{ 80 , 40 , 15 , 36 },
+{ 80 , 40 , 15 , 37 },
+{ 80 , 40 , 15 , 38 },
+{ 80 , 40 , 15 , 39 },
+{ 80 , 40 , 16 , 0 },
+{ 80 , 40 , 16 , 1 },
+{ 80 , 40 , 16 , 2 },
+{ 80 , 40 , 16 , 3 },
+{ 80 , 40 , 16 , 4 },
+{ 80 , 40 , 16 , 5 },
+{ 80 , 40 , 16 , 6 },
+{ 80 , 40 , 16 , 7 },
+{ 80 , 40 , 16 , 8 },
+{ 80 , 40 , 16 , 9 },
+{ 80 , 40 , 16 , 10 },
+{ 80 , 40 , 16 , 11 },
+{ 80 , 40 , 16 , 12 },
+{ 80 , 40 , 16 , 13 },
+{ 80 , 40 , 16 , 14 },
+{ 80 , 40 , 16 , 15 },
+{ 80 , 40 , 16 , 16 },
+{ 80 , 40 , 16 , 17 },
+{ 80 , 40 , 16 , 18 },
+{ 80 , 40 , 16 , 19 },
+{ 80 , 40 , 16 , 20 },
+{ 80 , 40 , 16 , 21 },
+{ 80 , 40 , 16 , 22 },
+{ 80 , 40 , 16 , 23 },
+{ 80 , 40 , 16 , 24 },
+{ 80 , 40 , 16 , 25 },
+{ 80 , 40 , 16 , 26 },
+{ 80 , 40 , 16 , 27 },
+{ 80 , 40 , 16 , 28 },
+{ 80 , 40 , 16 , 29 },
+{ 80 , 40 , 16 , 30 },
+{ 80 , 40 , 16 , 31 },
+{ 80 , 40 , 16 , 32 },
+{ 80 , 40 , 16 , 33 },
+{ 80 , 40 , 16 , 34 },
+{ 80 , 40 , 16 , 35 },
+{ 80 , 40 , 16 , 36 },
+{ 80 , 40 , 16 , 37 },
+{ 80 , 40 , 16 , 38 },
+{ 80 , 40 , 16 , 39 },
+{ 80 , 40 , 17 , 0 },
+{ 80 , 40 , 17 , 1 },
+{ 80 , 40 , 17 , 2 },
+{ 80 , 40 , 17 , 3 },
+{ 80 , 40 , 17 , 4 },
+{ 80 , 40 , 17 , 5 },
+{ 80 , 40 , 17 , 6 },
+{ 80 , 40 , 17 , 7 },
+{ 80 , 40 , 17 , 8 },
+{ 80 , 40 , 17 , 9 },
+{ 80 , 40 , 17 , 10 },
+{ 80 , 40 , 17 , 11 },
+{ 80 , 40 , 17 , 12 },
+{ 80 , 40 , 17 , 13 },
+{ 80 , 40 , 17 , 14 },
+{ 80 , 40 , 17 , 15 },
+{ 80 , 40 , 17 , 16 },
+{ 80 , 40 , 17 , 17 },
+{ 80 , 40 , 17 , 18 },
+{ 80 , 40 , 17 , 19 },
+{ 80 , 40 , 17 , 20 },
+{ 80 , 40 , 17 , 21 },
+{ 80 , 40 , 17 , 22 },
+{ 80 , 40 , 17 , 23 },
+{ 80 , 40 , 17 , 24 },
+{ 80 , 40 , 17 , 25 },
+{ 80 , 40 , 17 , 26 },
+{ 80 , 40 , 17 , 27 },
+{ 80 , 40 , 17 , 28 },
+{ 80 , 40 , 17 , 29 },
+{ 80 , 40 , 17 , 30 },
+{ 80 , 40 , 17 , 31 },
+{ 80 , 40 , 17 , 32 },
+{ 80 , 40 , 17 , 33 },
+{ 80 , 40 , 17 , 34 },
+{ 80 , 40 , 17 , 35 },
+{ 80 , 40 , 17 , 36 },
+{ 80 , 40 , 17 , 37 },
+{ 80 , 40 , 17 , 38 },
+{ 80 , 40 , 17 , 39 },
+{ 80 , 40 , 18 , 0 },
+{ 80 , 40 , 18 , 1 },
+{ 80 , 40 , 18 , 2 },
+{ 80 , 40 , 18 , 3 },
+{ 80 , 40 , 18 , 4 },
+{ 80 , 40 , 18 , 5 },
+{ 80 , 40 , 18 , 6 },
+{ 80 , 40 , 18 , 7 },
+{ 80 , 40 , 18 , 8 },
+{ 80 , 40 , 18 , 9 },
+{ 80 , 40 , 18 , 10 },
+{ 80 , 40 , 18 , 11 },
+{ 80 , 40 , 18 , 12 },
+{ 80 , 40 , 18 , 13 },
+{ 80 , 40 , 18 , 14 },
+{ 80 , 40 , 18 , 15 },
+{ 80 , 40 , 18 , 16 },
+{ 80 , 40 , 18 , 17 },
+{ 80 , 40 , 18 , 18 },
+{ 80 , 40 , 18 , 19 },
+{ 80 , 40 , 18 , 20 },
+{ 80 , 40 , 18 , 21 },
+{ 80 , 40 , 18 , 22 },
+{ 80 , 40 , 18 , 23 },
+{ 80 , 40 , 18 , 24 },
+{ 80 , 40 , 18 , 25 },
+{ 80 , 40 , 18 , 26 },
+{ 80 , 40 , 18 , 27 },
+{ 80 , 40 , 18 , 28 },
+{ 80 , 40 , 18 , 29 },
+{ 80 , 40 , 18 , 30 },
+{ 80 , 40 , 18 , 31 },
+{ 80 , 40 , 18 , 32 },
+{ 80 , 40 , 18 , 33 },
+{ 80 , 40 , 18 , 34 },
+{ 80 , 40 , 18 , 35 },
+{ 80 , 40 , 18 , 36 },
+{ 80 , 40 , 18 , 37 },
+{ 80 , 40 , 18 , 38 },
+{ 80 , 40 , 18 , 39 },
+{ 80 , 40 , 19 , 0 },
+{ 80 , 40 , 19 , 1 },
+{ 80 , 40 , 19 , 2 },
+{ 80 , 40 , 19 , 3 },
+{ 80 , 40 , 19 , 4 },
+{ 80 , 40 , 19 , 5 },
+{ 80 , 40 , 19 , 6 },
+{ 80 , 40 , 19 , 7 },
+{ 80 , 40 , 19 , 8 },
+{ 80 , 40 , 19 , 9 },
+{ 80 , 40 , 19 , 10 },
+{ 80 , 40 , 19 , 11 },
+{ 80 , 40 , 19 , 12 },
+{ 80 , 40 , 19 , 13 },
+{ 80 , 40 , 19 , 14 },
+{ 80 , 40 , 19 , 15 },
+{ 80 , 40 , 19 , 16 },
+{ 80 , 40 , 19 , 17 },
+{ 80 , 40 , 19 , 18 },
+{ 80 , 40 , 19 , 19 },
+{ 80 , 40 , 19 , 20 },
+{ 80 , 40 , 19 , 21 },
+{ 80 , 40 , 19 , 22 },
+{ 80 , 40 , 19 , 23 },
+{ 80 , 40 , 19 , 24 },
+{ 80 , 40 , 19 , 25 },
+{ 80 , 40 , 19 , 26 },
+{ 80 , 40 , 19 , 27 },
+{ 80 , 40 , 19 , 28 },
+{ 80 , 40 , 19 , 29 },
+{ 80 , 40 , 19 , 30 },
+{ 80 , 40 , 19 , 31 },
+{ 80 , 40 , 19 , 32 },
+{ 80 , 40 , 19 , 33 },
+{ 80 , 40 , 19 , 34 },
+{ 80 , 40 , 19 , 35 },
+{ 80 , 40 , 19 , 36 },
+{ 80 , 40 , 19 , 37 },
+{ 80 , 40 , 19 , 38 },
+{ 80 , 40 , 19 , 39 },
+{ 80 , 40 , 20 , 0 },
+{ 80 , 40 , 20 , 1 },
+{ 80 , 40 , 20 , 2 },
+{ 80 , 40 , 20 , 3 },
+{ 80 , 40 , 20 , 4 },
+{ 80 , 40 , 20 , 5 },
+{ 80 , 40 , 20 , 6 },
+{ 80 , 40 , 20 , 7 },
+{ 80 , 40 , 20 , 8 },
+{ 80 , 40 , 20 , 9 },
+{ 80 , 40 , 20 , 10 },
+{ 80 , 40 , 20 , 11 },
+{ 80 , 40 , 20 , 12 },
+{ 80 , 40 , 20 , 13 },
+{ 80 , 40 , 20 , 14 },
+{ 80 , 40 , 20 , 15 },
+{ 80 , 40 , 20 , 16 },
+{ 80 , 40 , 20 , 17 },
+{ 80 , 40 , 20 , 18 },
+{ 80 , 40 , 20 , 19 },
+{ 80 , 40 , 20 , 20 },
+{ 80 , 40 , 20 , 21 },
+{ 80 , 40 , 20 , 22 },
+{ 80 , 40 , 20 , 23 },
+{ 80 , 40 , 20 , 24 },
+{ 80 , 40 , 20 , 25 },
+{ 80 , 40 , 20 , 26 },
+{ 80 , 40 , 20 , 27 },
+{ 80 , 40 , 20 , 28 },
+{ 80 , 40 , 20 , 29 },
+{ 80 , 40 , 20 , 30 },
+{ 80 , 40 , 20 , 31 },
+{ 80 , 40 , 20 , 32 },
+{ 80 , 40 , 20 , 33 },
+{ 80 , 40 , 20 , 34 },
+{ 80 , 40 , 20 , 35 },
+{ 80 , 40 , 20 , 36 },
+{ 80 , 40 , 20 , 37 },
+{ 80 , 40 , 20 , 38 },
+{ 80 , 40 , 20 , 39 },
+{ 80 , 40 , 21 , 0 },
+{ 80 , 40 , 21 , 1 },
+{ 80 , 40 , 21 , 2 },
+{ 80 , 40 , 21 , 3 },
+{ 80 , 40 , 21 , 4 },
+{ 80 , 40 , 21 , 5 },
+{ 80 , 40 , 21 , 6 },
+{ 80 , 40 , 21 , 7 },
+{ 80 , 40 , 21 , 8 },
+{ 80 , 40 , 21 , 9 },
+{ 80 , 40 , 21 , 10 },
+{ 80 , 40 , 21 , 11 },
+{ 80 , 40 , 21 , 12 },
+{ 80 , 40 , 21 , 13 },
+{ 80 , 40 , 21 , 14 },
+{ 80 , 40 , 21 , 15 },
+{ 80 , 40 , 21 , 16 },
+{ 80 , 40 , 21 , 17 },
+{ 80 , 40 , 21 , 18 },
+{ 80 , 40 , 21 , 19 },
+{ 80 , 40 , 21 , 20 },
+{ 80 , 40 , 21 , 21 },
+{ 80 , 40 , 21 , 22 },
+{ 80 , 40 , 21 , 23 },
+{ 80 , 40 , 21 , 24 },
+{ 80 , 40 , 21 , 25 },
+{ 80 , 40 , 21 , 26 },
+{ 80 , 40 , 21 , 27 },
+{ 80 , 40 , 21 , 28 },
+{ 80 , 40 , 21 , 29 },
+{ 80 , 40 , 21 , 30 },
+{ 80 , 40 , 21 , 31 },
+{ 80 , 40 , 21 , 32 },
+{ 80 , 40 , 21 , 33 },
+{ 80 , 40 , 21 , 34 },
+{ 80 , 40 , 21 , 35 },
+{ 80 , 40 , 21 , 36 },
+{ 80 , 40 , 21 , 37 },
+{ 80 , 40 , 21 , 38 },
+{ 80 , 40 , 21 , 39 },
+{ 80 , 40 , 22 , 0 },
+{ 80 , 40 , 22 , 1 },
+{ 80 , 40 , 22 , 2 },
+{ 80 , 40 , 22 , 3 },
+{ 80 , 40 , 22 , 4 },
+{ 80 , 40 , 22 , 5 },
+{ 80 , 40 , 22 , 6 },
+{ 80 , 40 , 22 , 7 },
+{ 80 , 40 , 22 , 8 },
+{ 80 , 40 , 22 , 9 },
+{ 80 , 40 , 22 , 10 },
+{ 80 , 40 , 22 , 11 },
+{ 80 , 40 , 22 , 12 },
+{ 80 , 40 , 22 , 13 },
+{ 80 , 40 , 22 , 14 },
+{ 80 , 40 , 22 , 15 },
+{ 80 , 40 , 22 , 16 },
+{ 80 , 40 , 22 , 17 },
+{ 80 , 40 , 22 , 18 },
+{ 80 , 40 , 22 , 19 },
+{ 80 , 40 , 22 , 20 },
+{ 80 , 40 , 22 , 21 },
+{ 80 , 40 , 22 , 22 },
+{ 80 , 40 , 22 , 23 },
+{ 80 , 40 , 22 , 24 },
+{ 80 , 40 , 22 , 25 },
+{ 80 , 40 , 22 , 26 },
+{ 80 , 40 , 22 , 27 },
+{ 80 , 40 , 22 , 28 },
+{ 80 , 40 , 22 , 29 },
+{ 80 , 40 , 22 , 30 },
+{ 80 , 40 , 22 , 31 },
+{ 80 , 40 , 22 , 32 },
+{ 80 , 40 , 22 , 33 },
+{ 80 , 40 , 22 , 34 },
+{ 80 , 40 , 22 , 35 },
+{ 80 , 40 , 22 , 36 },
+{ 80 , 40 , 22 , 37 },
+{ 80 , 40 , 22 , 38 },
+{ 80 , 40 , 22 , 39 },
+{ 80 , 40 , 23 , 0 },
+{ 80 , 40 , 23 , 1 },
+{ 80 , 40 , 23 , 2 },
+{ 80 , 40 , 23 , 3 },
+{ 80 , 40 , 23 , 4 },
+{ 80 , 40 , 23 , 5 },
+{ 80 , 40 , 23 , 6 },
+{ 80 , 40 , 23 , 7 },
+{ 80 , 40 , 23 , 8 },
+{ 80 , 40 , 23 , 9 },
+{ 80 , 40 , 23 , 10 },
+{ 80 , 40 , 23 , 11 },
+{ 80 , 40 , 23 , 12 },
+{ 80 , 40 , 23 , 13 },
+{ 80 , 40 , 23 , 14 },
+{ 80 , 40 , 23 , 15 },
+{ 80 , 40 , 23 , 16 },
+{ 80 , 40 , 23 , 17 },
+{ 80 , 40 , 23 , 18 },
+{ 80 , 40 , 23 , 19 },
+{ 80 , 40 , 23 , 20 },
+{ 80 , 40 , 23 , 21 },
+{ 80 , 40 , 23 , 22 },
+{ 80 , 40 , 23 , 23 },
+{ 80 , 40 , 23 , 24 },
+{ 80 , 40 , 23 , 25 },
+{ 80 , 40 , 23 , 26 },
+{ 80 , 40 , 23 , 27 },
+{ 80 , 40 , 23 , 28 },
+{ 80 , 40 , 23 , 29 },
+{ 80 , 40 , 23 , 30 },
+{ 80 , 40 , 23 , 31 },
+{ 80 , 40 , 23 , 32 },
+{ 80 , 40 , 23 , 33 },
+{ 80 , 40 , 23 , 34 },
+{ 80 , 40 , 23 , 35 },
+{ 80 , 40 , 23 , 36 },
+{ 80 , 40 , 23 , 37 },
+{ 80 , 40 , 23 , 38 },
+{ 80 , 40 , 23 , 39 },
+{ 80 , 40 , 24 , 0 },
+{ 80 , 40 , 24 , 1 },
+{ 80 , 40 , 24 , 2 },
+{ 80 , 40 , 24 , 3 },
+{ 80 , 40 , 24 , 4 },
+{ 80 , 40 , 24 , 5 },
+{ 80 , 40 , 24 , 6 },
+{ 80 , 40 , 24 , 7 },
+{ 80 , 40 , 24 , 8 },
+{ 80 , 40 , 24 , 9 },
+{ 80 , 40 , 24 , 10 },
+{ 80 , 40 , 24 , 11 },
+{ 80 , 40 , 24 , 12 },
+{ 80 , 40 , 24 , 13 },
+{ 80 , 40 , 24 , 14 },
+{ 80 , 40 , 24 , 15 },
+{ 80 , 40 , 24 , 16 },
+{ 80 , 40 , 24 , 17 },
+{ 80 , 40 , 24 , 18 },
+{ 80 , 40 , 24 , 19 },
+{ 80 , 40 , 24 , 20 },
+{ 80 , 40 , 24 , 21 },
+{ 80 , 40 , 24 , 22 },
+{ 80 , 40 , 24 , 23 },
+{ 80 , 40 , 24 , 24 },
+{ 80 , 40 , 24 , 25 },
+{ 80 , 40 , 24 , 26 },
+{ 80 , 40 , 24 , 27 },
+{ 80 , 40 , 24 , 28 },
+{ 80 , 40 , 24 , 29 },
+{ 80 , 40 , 24 , 30 },
+{ 80 , 40 , 24 , 31 },
+{ 80 , 40 , 24 , 32 },
+{ 80 , 40 , 24 , 33 },
+{ 80 , 40 , 24 , 34 },
+{ 80 , 40 , 24 , 35 },
+{ 80 , 40 , 24 , 36 },
+{ 80 , 40 , 24 , 37 },
+{ 80 , 40 , 24 , 38 },
+{ 80 , 40 , 24 , 39 },
+{ 80 , 40 , 25 , 0 },
+{ 80 , 40 , 25 , 1 },
+{ 80 , 40 , 25 , 2 },
+{ 80 , 40 , 25 , 3 },
+{ 80 , 40 , 25 , 4 },
+{ 80 , 40 , 25 , 5 },
+{ 80 , 40 , 25 , 6 },
+{ 80 , 40 , 25 , 7 },
+{ 80 , 40 , 25 , 8 },
+{ 80 , 40 , 25 , 9 },
+{ 80 , 40 , 25 , 10 },
+{ 80 , 40 , 25 , 11 },
+{ 80 , 40 , 25 , 12 },
+{ 80 , 40 , 25 , 13 },
+{ 80 , 40 , 25 , 14 },
+{ 80 , 40 , 25 , 15 },
+{ 80 , 40 , 25 , 16 },
+{ 80 , 40 , 25 , 17 },
+{ 80 , 40 , 25 , 18 },
+{ 80 , 40 , 25 , 19 },
+{ 80 , 40 , 25 , 20 },
+{ 80 , 40 , 25 , 21 },
+{ 80 , 40 , 25 , 22 },
+{ 80 , 40 , 25 , 23 },
+{ 80 , 40 , 25 , 24 },
+{ 80 , 40 , 25 , 25 },
+{ 80 , 40 , 25 , 26 },
+{ 80 , 40 , 25 , 27 },
+{ 80 , 40 , 25 , 28 },
+{ 80 , 40 , 25 , 29 },
+{ 80 , 40 , 25 , 30 },
+{ 80 , 40 , 25 , 31 },
+{ 80 , 40 , 25 , 32 },
+{ 80 , 40 , 25 , 33 },
+{ 80 , 40 , 25 , 34 },
+{ 80 , 40 , 25 , 35 },
+{ 80 , 40 , 25 , 36 },
+{ 80 , 40 , 25 , 37 },
+{ 80 , 40 , 25 , 38 },
+{ 80 , 40 , 25 , 39 },
+{ 80 , 40 , 26 , 0 },
+{ 80 , 40 , 26 , 1 },
+{ 80 , 40 , 26 , 2 },
+{ 80 , 40 , 26 , 3 },
+{ 80 , 40 , 26 , 4 },
+{ 80 , 40 , 26 , 5 },
+{ 80 , 40 , 26 , 6 },
+{ 80 , 40 , 26 , 7 },
+{ 80 , 40 , 26 , 8 },
+{ 80 , 40 , 26 , 9 },
+{ 80 , 40 , 26 , 10 },
+{ 80 , 40 , 26 , 11 },
+{ 80 , 40 , 26 , 12 },
+{ 80 , 40 , 26 , 13 },
+{ 80 , 40 , 26 , 14 },
+{ 80 , 40 , 26 , 15 },
+{ 80 , 40 , 26 , 16 },
+{ 80 , 40 , 26 , 17 },
+{ 80 , 40 , 26 , 18 },
+{ 80 , 40 , 26 , 19 },
+{ 80 , 40 , 26 , 20 },
+{ 80 , 40 , 26 , 21 },
+{ 80 , 40 , 26 , 22 },
+{ 80 , 40 , 26 , 23 },
+{ 80 , 40 , 26 , 24 },
+{ 80 , 40 , 26 , 25 },
+{ 80 , 40 , 26 , 26 },
+{ 80 , 40 , 26 , 27 },
+{ 80 , 40 , 26 , 28 },
+{ 80 , 40 , 26 , 29 },
+{ 80 , 40 , 26 , 30 },
+{ 80 , 40 , 26 , 31 },
+{ 80 , 40 , 26 , 32 },
+{ 80 , 40 , 26 , 33 },
+{ 80 , 40 , 26 , 34 },
+{ 80 , 40 , 26 , 35 },
+{ 80 , 40 , 26 , 36 },
+{ 80 , 40 , 26 , 37 },
+{ 80 , 40 , 26 , 38 },
+{ 80 , 40 , 26 , 39 },
+{ 80 , 40 , 27 , 0 },
+{ 80 , 40 , 27 , 1 },
+{ 80 , 40 , 27 , 2 },
+{ 80 , 40 , 27 , 3 },
+{ 80 , 40 , 27 , 4 },
+{ 80 , 40 , 27 , 5 },
+{ 80 , 40 , 27 , 6 },
+{ 80 , 40 , 27 , 7 },
+{ 80 , 40 , 27 , 8 },
+{ 80 , 40 , 27 , 9 },
+{ 80 , 40 , 27 , 10 },
+{ 80 , 40 , 27 , 11 },
+{ 80 , 40 , 27 , 12 },
+{ 80 , 40 , 27 , 13 },
+{ 80 , 40 , 27 , 14 },
+{ 80 , 40 , 27 , 15 },
+{ 80 , 40 , 27 , 16 },
+{ 80 , 40 , 27 , 17 },
+{ 80 , 40 , 27 , 18 },
+{ 80 , 40 , 27 , 19 },
+{ 80 , 40 , 27 , 20 },
+{ 80 , 40 , 27 , 21 },
+{ 80 , 40 , 27 , 22 },
+{ 80 , 40 , 27 , 23 },
+{ 80 , 40 , 27 , 24 },
+{ 80 , 40 , 27 , 25 },
+{ 80 , 40 , 27 , 26 },
+{ 80 , 40 , 27 , 27 },
+{ 80 , 40 , 27 , 28 },
+{ 80 , 40 , 27 , 29 },
+{ 80 , 40 , 27 , 30 },
+{ 80 , 40 , 27 , 31 },
+{ 80 , 40 , 27 , 32 },
+{ 80 , 40 , 27 , 33 },
+{ 80 , 40 , 27 , 34 },
+{ 80 , 40 , 27 , 35 },
+{ 80 , 40 , 27 , 36 },
+{ 80 , 40 , 27 , 37 },
+{ 80 , 40 , 27 , 38 },
+{ 80 , 40 , 27 , 39 },
+{ 80 , 40 , 28 , 0 },
+{ 80 , 40 , 28 , 1 },
+{ 80 , 40 , 28 , 2 },
+{ 80 , 40 , 28 , 3 },
+{ 80 , 40 , 28 , 4 },
+{ 80 , 40 , 28 , 5 },
+{ 80 , 40 , 28 , 6 },
+{ 80 , 40 , 28 , 7 },
+{ 80 , 40 , 28 , 8 },
+{ 80 , 40 , 28 , 9 },
+{ 80 , 40 , 28 , 10 },
+{ 80 , 40 , 28 , 11 },
+{ 80 , 40 , 28 , 12 },
+{ 80 , 40 , 28 , 13 },
+{ 80 , 40 , 28 , 14 },
+{ 80 , 40 , 28 , 15 },
+{ 80 , 40 , 28 , 16 },
+{ 80 , 40 , 28 , 17 },
+{ 80 , 40 , 28 , 18 },
+{ 80 , 40 , 28 , 19 },
+{ 80 , 40 , 28 , 20 },
+{ 80 , 40 , 28 , 21 },
+{ 80 , 40 , 28 , 22 },
+{ 80 , 40 , 28 , 23 },
+{ 80 , 40 , 28 , 24 },
+{ 80 , 40 , 28 , 25 },
+{ 80 , 40 , 28 , 26 },
+{ 80 , 40 , 28 , 27 },
+{ 80 , 40 , 28 , 28 },
+{ 80 , 40 , 28 , 29 },
+{ 80 , 40 , 28 , 30 },
+{ 80 , 40 , 28 , 31 },
+{ 80 , 40 , 28 , 32 },
+{ 80 , 40 , 28 , 33 },
+{ 80 , 40 , 28 , 34 },
+{ 80 , 40 , 28 , 35 },
+{ 80 , 40 , 28 , 36 },
+{ 80 , 40 , 28 , 37 },
+{ 80 , 40 , 28 , 38 },
+{ 80 , 40 , 28 , 39 },
+{ 80 , 40 , 29 , 0 },
+{ 80 , 40 , 29 , 1 },
+{ 80 , 40 , 29 , 2 },
+{ 80 , 40 , 29 , 3 },
+{ 80 , 40 , 29 , 4 },
+{ 80 , 40 , 29 , 5 },
+{ 80 , 40 , 29 , 6 },
+{ 80 , 40 , 29 , 7 },
+{ 80 , 40 , 29 , 8 },
+{ 80 , 40 , 29 , 9 },
+{ 80 , 40 , 29 , 10 },
+{ 80 , 40 , 29 , 11 },
+{ 80 , 40 , 29 , 12 },
+{ 80 , 40 , 29 , 13 },
+{ 80 , 40 , 29 , 14 },
+{ 80 , 40 , 29 , 15 },
+{ 80 , 40 , 29 , 16 },
+{ 80 , 40 , 29 , 17 },
+{ 80 , 40 , 29 , 18 },
+{ 80 , 40 , 29 , 19 },
+{ 80 , 40 , 29 , 20 },
+{ 80 , 40 , 29 , 21 },
+{ 80 , 40 , 29 , 22 },
+{ 80 , 40 , 29 , 23 },
+{ 80 , 40 , 29 , 24 },
+{ 80 , 40 , 29 , 25 },
+{ 80 , 40 , 29 , 26 },
+{ 80 , 40 , 29 , 27 },
+{ 80 , 40 , 29 , 28 },
+{ 80 , 40 , 29 , 29 },
+{ 80 , 40 , 29 , 30 },
+{ 80 , 40 , 29 , 31 },
+{ 80 , 40 , 29 , 32 },
+{ 80 , 40 , 29 , 33 },
+{ 80 , 40 , 29 , 34 },
+{ 80 , 40 , 29 , 35 },
+{ 80 , 40 , 29 , 36 },
+{ 80 , 40 , 29 , 37 },
+{ 80 , 40 , 29 , 38 },
+{ 80 , 40 , 29 , 39 },
+{ 80 , 40 , 30 , 0 },
+{ 80 , 40 , 30 , 1 },
+{ 80 , 40 , 30 , 2 },
+{ 80 , 40 , 30 , 3 },
+{ 80 , 40 , 30 , 4 },
+{ 80 , 40 , 30 , 5 },
+{ 80 , 40 , 30 , 6 },
+{ 80 , 40 , 30 , 7 },
+{ 80 , 40 , 30 , 8 },
+{ 80 , 40 , 30 , 9 },
+{ 80 , 40 , 30 , 10 },
+{ 80 , 40 , 30 , 11 },
+{ 80 , 40 , 30 , 12 },
+{ 80 , 40 , 30 , 13 },
+{ 80 , 40 , 30 , 14 },
+{ 80 , 40 , 30 , 15 },
+{ 80 , 40 , 30 , 16 },
+{ 80 , 40 , 30 , 17 },
+{ 80 , 40 , 30 , 18 },
+{ 80 , 40 , 30 , 19 },
+{ 80 , 40 , 30 , 20 },
+{ 80 , 40 , 30 , 21 },
+{ 80 , 40 , 30 , 22 },
+{ 80 , 40 , 30 , 23 },
+{ 80 , 40 , 30 , 24 },
+{ 80 , 40 , 30 , 25 },
+{ 80 , 40 , 30 , 26 },
+{ 80 , 40 , 30 , 27 },
+{ 80 , 40 , 30 , 28 },
+{ 80 , 40 , 30 , 29 },
+{ 80 , 40 , 30 , 30 },
+{ 80 , 40 , 30 , 31 },
+{ 80 , 40 , 30 , 32 },
+{ 80 , 40 , 30 , 33 },
+{ 80 , 40 , 30 , 34 },
+{ 80 , 40 , 30 , 35 },
+{ 80 , 40 , 30 , 36 },
+{ 80 , 40 , 30 , 37 },
+{ 80 , 40 , 30 , 38 },
+{ 80 , 40 , 30 , 39 },
+{ 80 , 40 , 31 , 0 },
+{ 80 , 40 , 31 , 1 },
+{ 80 , 40 , 31 , 2 },
+{ 80 , 40 , 31 , 3 },
+{ 80 , 40 , 31 , 4 },
+{ 80 , 40 , 31 , 5 },
+{ 80 , 40 , 31 , 6 },
+{ 80 , 40 , 31 , 7 },
+{ 80 , 40 , 31 , 8 },
+{ 80 , 40 , 31 , 9 },
+{ 80 , 40 , 31 , 10 },
+{ 80 , 40 , 31 , 11 },
+{ 80 , 40 , 31 , 12 },
+{ 80 , 40 , 31 , 13 },
+{ 80 , 40 , 31 , 14 },
+{ 80 , 40 , 31 , 15 },
+{ 80 , 40 , 31 , 16 },
+{ 80 , 40 , 31 , 17 },
+{ 80 , 40 , 31 , 18 },
+{ 80 , 40 , 31 , 19 },
+{ 80 , 40 , 31 , 20 },
+{ 80 , 40 , 31 , 21 },
+{ 80 , 40 , 31 , 22 },
+{ 80 , 40 , 31 , 23 },
+{ 80 , 40 , 31 , 24 },
+{ 80 , 40 , 31 , 25 },
+{ 80 , 40 , 31 , 26 },
+{ 80 , 40 , 31 , 27 },
+{ 80 , 40 , 31 , 28 },
+{ 80 , 40 , 31 , 29 },
+{ 80 , 40 , 31 , 30 },
+{ 80 , 40 , 31 , 31 },
+{ 80 , 40 , 31 , 32 },
+{ 80 , 40 , 31 , 33 },
+{ 80 , 40 , 31 , 34 },
+{ 80 , 40 , 31 , 35 },
+{ 80 , 40 , 31 , 36 },
+{ 80 , 40 , 31 , 37 },
+{ 80 , 40 , 31 , 38 },
+{ 80 , 40 , 31 , 39 },
+{ 80 , 40 , 32 , 0 },
+{ 80 , 40 , 32 , 1 },
+{ 80 , 40 , 32 , 2 },
+{ 80 , 40 , 32 , 3 },
+{ 80 , 40 , 32 , 4 },
+{ 80 , 40 , 32 , 5 },
+{ 80 , 40 , 32 , 6 },
+{ 80 , 40 , 32 , 7 },
+{ 80 , 40 , 32 , 8 },
+{ 80 , 40 , 32 , 9 },
+{ 80 , 40 , 32 , 10 },
+{ 80 , 40 , 32 , 11 },
+{ 80 , 40 , 32 , 12 },
+{ 80 , 40 , 32 , 13 },
+{ 80 , 40 , 32 , 14 },
+{ 80 , 40 , 32 , 15 },
+{ 80 , 40 , 32 , 16 },
+{ 80 , 40 , 32 , 17 },
+{ 80 , 40 , 32 , 18 },
+{ 80 , 40 , 32 , 19 },
+{ 80 , 40 , 32 , 20 },
+{ 80 , 40 , 32 , 21 },
+{ 80 , 40 , 32 , 22 },
+{ 80 , 40 , 32 , 23 },
+{ 80 , 40 , 32 , 24 },
+{ 80 , 40 , 32 , 25 },
+{ 80 , 40 , 32 , 26 },
+{ 80 , 40 , 32 , 27 },
+{ 80 , 40 , 32 , 28 },
+{ 80 , 40 , 32 , 29 },
+{ 80 , 40 , 32 , 30 },
+{ 80 , 40 , 32 , 31 },
+{ 80 , 40 , 32 , 32 },
+{ 80 , 40 , 32 , 33 },
+{ 80 , 40 , 32 , 34 },
+{ 80 , 40 , 32 , 35 },
+{ 80 , 40 , 32 , 36 },
+{ 80 , 40 , 32 , 37 },
+{ 80 , 40 , 32 , 38 },
+{ 80 , 40 , 32 , 39 },
+{ 80 , 40 , 33 , 0 },
+{ 80 , 40 , 33 , 1 },
+{ 80 , 40 , 33 , 2 },
+{ 80 , 40 , 33 , 3 },
+{ 80 , 40 , 33 , 4 },
+{ 80 , 40 , 33 , 5 },
+{ 80 , 40 , 33 , 6 },
+{ 80 , 40 , 33 , 7 },
+{ 80 , 40 , 33 , 8 },
+{ 80 , 40 , 33 , 9 },
+{ 80 , 40 , 33 , 10 },
+{ 80 , 40 , 33 , 11 },
+{ 80 , 40 , 33 , 12 },
+{ 80 , 40 , 33 , 13 },
+{ 80 , 40 , 33 , 14 },
+{ 80 , 40 , 33 , 15 },
+{ 80 , 40 , 33 , 16 },
+{ 80 , 40 , 33 , 17 },
+{ 80 , 40 , 33 , 18 },
+{ 80 , 40 , 33 , 19 },
+{ 80 , 40 , 33 , 20 },
+{ 80 , 40 , 33 , 21 },
+{ 80 , 40 , 33 , 22 },
+{ 80 , 40 , 33 , 23 },
+{ 80 , 40 , 33 , 24 },
+{ 80 , 40 , 33 , 25 },
+{ 80 , 40 , 33 , 26 },
+{ 80 , 40 , 33 , 27 },
+{ 80 , 40 , 33 , 28 },
+{ 80 , 40 , 33 , 29 },
+{ 80 , 40 , 33 , 30 },
+{ 80 , 40 , 33 , 31 },
+{ 80 , 40 , 33 , 32 },
+{ 80 , 40 , 33 , 33 },
+{ 80 , 40 , 33 , 34 },
+{ 80 , 40 , 33 , 35 },
+{ 80 , 40 , 33 , 36 },
+{ 80 , 40 , 33 , 37 },
+{ 80 , 40 , 33 , 38 },
+{ 80 , 40 , 33 , 39 },
+{ 80 , 40 , 34 , 0 },
+{ 80 , 40 , 34 , 1 },
+{ 80 , 40 , 34 , 2 },
+{ 80 , 40 , 34 , 3 },
+{ 80 , 40 , 34 , 4 },
+{ 80 , 40 , 34 , 5 },
+{ 80 , 40 , 34 , 6 },
+{ 80 , 40 , 34 , 7 },
+{ 80 , 40 , 34 , 8 },
+{ 80 , 40 , 34 , 9 },
+{ 80 , 40 , 34 , 10 },
+{ 80 , 40 , 34 , 11 },
+{ 80 , 40 , 34 , 12 },
+{ 80 , 40 , 34 , 13 },
+{ 80 , 40 , 34 , 14 },
+{ 80 , 40 , 34 , 15 },
+{ 80 , 40 , 34 , 16 },
+{ 80 , 40 , 34 , 17 },
+{ 80 , 40 , 34 , 18 },
+{ 80 , 40 , 34 , 19 },
+{ 80 , 40 , 34 , 20 },
+{ 80 , 40 , 34 , 21 },
+{ 80 , 40 , 34 , 22 },
+{ 80 , 40 , 34 , 23 },
+{ 80 , 40 , 34 , 24 },
+{ 80 , 40 , 34 , 25 },
+{ 80 , 40 , 34 , 26 },
+{ 80 , 40 , 34 , 27 },
+{ 80 , 40 , 34 , 28 },
+{ 80 , 40 , 34 , 29 },
+{ 80 , 40 , 34 , 30 },
+{ 80 , 40 , 34 , 31 },
+{ 80 , 40 , 34 , 32 },
+{ 80 , 40 , 34 , 33 },
+{ 80 , 40 , 34 , 34 },
+{ 80 , 40 , 34 , 35 },
+{ 80 , 40 , 34 , 36 },
+{ 80 , 40 , 34 , 37 },
+{ 80 , 40 , 34 , 38 },
+{ 80 , 40 , 34 , 39 },
+{ 80 , 40 , 35 , 0 },
+{ 80 , 40 , 35 , 1 },
+{ 80 , 40 , 35 , 2 },
+{ 80 , 40 , 35 , 3 },
+{ 80 , 40 , 35 , 4 },
+{ 80 , 40 , 35 , 5 },
+{ 80 , 40 , 35 , 6 },
+{ 80 , 40 , 35 , 7 },
+{ 80 , 40 , 35 , 8 },
+{ 80 , 40 , 35 , 9 },
+{ 80 , 40 , 35 , 10 },
+{ 80 , 40 , 35 , 11 },
+{ 80 , 40 , 35 , 12 },
+{ 80 , 40 , 35 , 13 },
+{ 80 , 40 , 35 , 14 },
+{ 80 , 40 , 35 , 15 },
+{ 80 , 40 , 35 , 16 },
+{ 80 , 40 , 35 , 17 },
+{ 80 , 40 , 35 , 18 },
+{ 80 , 40 , 35 , 19 },
+{ 80 , 40 , 35 , 20 },
+{ 80 , 40 , 35 , 21 },
+{ 80 , 40 , 35 , 22 },
+{ 80 , 40 , 35 , 23 },
+{ 80 , 40 , 35 , 24 },
+{ 80 , 40 , 35 , 25 },
+{ 80 , 40 , 35 , 26 },
+{ 80 , 40 , 35 , 27 },
+{ 80 , 40 , 35 , 28 },
+{ 80 , 40 , 35 , 29 },
+{ 80 , 40 , 35 , 30 },
+{ 80 , 40 , 35 , 31 },
+{ 80 , 40 , 35 , 32 },
+{ 80 , 40 , 35 , 33 },
+{ 80 , 40 , 35 , 34 },
+{ 80 , 40 , 35 , 35 },
+{ 80 , 40 , 35 , 36 },
+{ 80 , 40 , 35 , 37 },
+{ 80 , 40 , 35 , 38 },
+{ 80 , 40 , 35 , 39 },
+{ 80 , 40 , 36 , 0 },
+{ 80 , 40 , 36 , 1 },
+{ 80 , 40 , 36 , 2 },
+{ 80 , 40 , 36 , 3 },
+{ 80 , 40 , 36 , 4 },
+{ 80 , 40 , 36 , 5 },
+{ 80 , 40 , 36 , 6 },
+{ 80 , 40 , 36 , 7 },
+{ 80 , 40 , 36 , 8 },
+{ 80 , 40 , 36 , 9 },
+{ 80 , 40 , 36 , 10 },
+{ 80 , 40 , 36 , 11 },
+{ 80 , 40 , 36 , 12 },
+{ 80 , 40 , 36 , 13 },
+{ 80 , 40 , 36 , 14 },
+{ 80 , 40 , 36 , 15 },
+{ 80 , 40 , 36 , 16 },
+{ 80 , 40 , 36 , 17 },
+{ 80 , 40 , 36 , 18 },
+{ 80 , 40 , 36 , 19 },
+{ 80 , 40 , 36 , 20 },
+{ 80 , 40 , 36 , 21 },
+{ 80 , 40 , 36 , 22 },
+{ 80 , 40 , 36 , 23 },
+{ 80 , 40 , 36 , 24 },
+{ 80 , 40 , 36 , 25 },
+{ 80 , 40 , 36 , 26 },
+{ 80 , 40 , 36 , 27 },
+{ 80 , 40 , 36 , 28 },
+{ 80 , 40 , 36 , 29 },
+{ 80 , 40 , 36 , 30 },
+{ 80 , 40 , 36 , 31 },
+{ 80 , 40 , 36 , 32 },
+{ 80 , 40 , 36 , 33 },
+{ 80 , 40 , 36 , 34 },
+{ 80 , 40 , 36 , 35 },
+{ 80 , 40 , 36 , 36 },
+{ 80 , 40 , 36 , 37 },
+{ 80 , 40 , 36 , 38 },
+{ 80 , 40 , 36 , 39 },
+{ 80 , 40 , 37 , 0 },
+{ 80 , 40 , 37 , 1 },
+{ 80 , 40 , 37 , 2 },
+{ 80 , 40 , 37 , 3 },
+{ 80 , 40 , 37 , 4 },
+{ 80 , 40 , 37 , 5 },
+{ 80 , 40 , 37 , 6 },
+{ 80 , 40 , 37 , 7 },
+{ 80 , 40 , 37 , 8 },
+{ 80 , 40 , 37 , 9 },
+{ 80 , 40 , 37 , 10 },
+{ 80 , 40 , 37 , 11 },
+{ 80 , 40 , 37 , 12 },
+{ 80 , 40 , 37 , 13 },
+{ 80 , 40 , 37 , 14 },
+{ 80 , 40 , 37 , 15 },
+{ 80 , 40 , 37 , 16 },
+{ 80 , 40 , 37 , 17 },
+{ 80 , 40 , 37 , 18 },
+{ 80 , 40 , 37 , 19 },
+{ 80 , 40 , 37 , 20 },
+{ 80 , 40 , 37 , 21 },
+{ 80 , 40 , 37 , 22 },
+{ 80 , 40 , 37 , 23 },
+{ 80 , 40 , 37 , 24 },
+{ 80 , 40 , 37 , 25 },
+{ 80 , 40 , 37 , 26 },
+{ 80 , 40 , 37 , 27 },
+{ 80 , 40 , 37 , 28 },
+{ 80 , 40 , 37 , 29 },
+{ 80 , 40 , 37 , 30 },
+{ 80 , 40 , 37 , 31 },
+{ 80 , 40 , 37 , 32 },
+{ 80 , 40 , 37 , 33 },
+{ 80 , 40 , 37 , 34 },
+{ 80 , 40 , 37 , 35 },
+{ 80 , 40 , 37 , 36 },
+{ 80 , 40 , 37 , 37 },
+{ 80 , 40 , 37 , 38 },
+{ 80 , 40 , 37 , 39 },
+{ 80 , 40 , 38 , 0 },
+{ 80 , 40 , 38 , 1 },
+{ 80 , 40 , 38 , 2 },
+{ 80 , 40 , 38 , 3 },
+{ 80 , 40 , 38 , 4 },
+{ 80 , 40 , 38 , 5 },
+{ 80 , 40 , 38 , 6 },
+{ 80 , 40 , 38 , 7 },
+{ 80 , 40 , 38 , 8 },
+{ 80 , 40 , 38 , 9 },
+{ 80 , 40 , 38 , 10 },
+{ 80 , 40 , 38 , 11 },
+{ 80 , 40 , 38 , 12 },
+{ 80 , 40 , 38 , 13 },
+{ 80 , 40 , 38 , 14 },
+{ 80 , 40 , 38 , 15 },
+{ 80 , 40 , 38 , 16 },
+{ 80 , 40 , 38 , 17 },
+{ 80 , 40 , 38 , 18 },
+{ 80 , 40 , 38 , 19 },
+{ 80 , 40 , 38 , 20 },
+{ 80 , 40 , 38 , 21 },
+{ 80 , 40 , 38 , 22 },
+{ 80 , 40 , 38 , 23 },
+{ 80 , 40 , 38 , 24 },
+{ 80 , 40 , 38 , 25 },
+{ 80 , 40 , 38 , 26 },
+{ 80 , 40 , 38 , 27 },
+{ 80 , 40 , 38 , 28 },
+{ 80 , 40 , 38 , 29 },
+{ 80 , 40 , 38 , 30 },
+{ 80 , 40 , 38 , 31 },
+{ 80 , 40 , 38 , 32 },
+{ 80 , 40 , 38 , 33 },
+{ 80 , 40 , 38 , 34 },
+{ 80 , 40 , 38 , 35 },
+{ 80 , 40 , 38 , 36 },
+{ 80 , 40 , 38 , 37 },
+{ 80 , 40 , 38 , 38 },
+{ 80 , 40 , 38 , 39 },
+{ 80 , 40 , 39 , 0 },
+{ 80 , 40 , 39 , 1 },
+{ 80 , 40 , 39 , 2 },
+{ 80 , 40 , 39 , 3 },
+{ 80 , 40 , 39 , 4 },
+{ 80 , 40 , 39 , 5 },
+{ 80 , 40 , 39 , 6 },
+{ 80 , 40 , 39 , 7 },
+{ 80 , 40 , 39 , 8 },
+{ 80 , 40 , 39 , 9 },
+{ 80 , 40 , 39 , 10 },
+{ 80 , 40 , 39 , 11 },
+{ 80 , 40 , 39 , 12 },
+{ 80 , 40 , 39 , 13 },
+{ 80 , 40 , 39 , 14 },
+{ 80 , 40 , 39 , 15 },
+{ 80 , 40 , 39 , 16 },
+{ 80 , 40 , 39 , 17 },
+{ 80 , 40 , 39 , 18 },
+{ 80 , 40 , 39 , 19 },
+{ 80 , 40 , 39 , 20 },
+{ 80 , 40 , 39 , 21 },
+{ 80 , 40 , 39 , 22 },
+{ 80 , 40 , 39 , 23 },
+{ 80 , 40 , 39 , 24 },
+{ 80 , 40 , 39 , 25 },
+{ 80 , 40 , 39 , 26 },
+{ 80 , 40 , 39 , 27 },
+{ 80 , 40 , 39 , 28 },
+{ 80 , 40 , 39 , 29 },
+{ 80 , 40 , 39 , 30 },
+{ 80 , 40 , 39 , 31 },
+{ 80 , 40 , 39 , 32 },
+{ 80 , 40 , 39 , 33 },
+{ 80 , 40 , 39 , 34 },
+{ 80 , 40 , 39 , 35 },
+{ 80 , 40 , 39 , 36 },
+{ 80 , 40 , 39 , 37 },
+{ 80 , 40 , 39 , 38 },
+{ 80 , 40 , 39 , 39 },
+{ 80 , 40 , 40 , 0 },
+{ 80 , 40 , 40 , 1 },
+{ 80 , 40 , 40 , 2 },
+{ 80 , 40 , 40 , 3 },
+{ 80 , 40 , 40 , 4 },
+{ 80 , 40 , 40 , 5 },
+{ 80 , 40 , 40 , 6 },
+{ 80 , 40 , 40 , 7 },
+{ 80 , 40 , 40 , 8 },
+{ 80 , 40 , 40 , 9 },
+{ 80 , 40 , 40 , 10 },
+{ 80 , 40 , 40 , 11 },
+{ 80 , 40 , 40 , 12 },
+{ 80 , 40 , 40 , 13 },
+{ 80 , 40 , 40 , 14 },
+{ 80 , 40 , 40 , 15 },
+{ 80 , 40 , 40 , 16 },
+{ 80 , 40 , 40 , 17 },
+{ 80 , 40 , 40 , 18 },
+{ 80 , 40 , 40 , 19 },
+{ 80 , 40 , 40 , 20 },
+{ 80 , 40 , 40 , 21 },
+{ 80 , 40 , 40 , 22 },
+{ 80 , 40 , 40 , 23 },
+{ 80 , 40 , 40 , 24 },
+{ 80 , 40 , 40 , 25 },
+{ 80 , 40 , 40 , 26 },
+{ 80 , 40 , 40 , 27 },
+{ 80 , 40 , 40 , 28 },
+{ 80 , 40 , 40 , 29 },
+{ 80 , 40 , 40 , 30 },
+{ 80 , 40 , 40 , 31 },
+{ 80 , 40 , 40 , 32 },
+{ 80 , 40 , 40 , 33 },
+{ 80 , 40 , 40 , 34 },
+{ 80 , 40 , 40 , 35 },
+{ 80 , 40 , 40 , 36 },
+{ 80 , 40 , 40 , 37 },
+{ 80 , 40 , 40 , 38 },
+{ 80 , 40 , 40 , 39 },
+{ 80 , 40 , 41 , 0 },
+{ 80 , 40 , 41 , 1 },
+{ 80 , 40 , 41 , 2 },
+{ 80 , 40 , 41 , 3 },
+{ 80 , 40 , 41 , 4 },
+{ 80 , 40 , 41 , 5 },
+{ 80 , 40 , 41 , 6 },
+{ 80 , 40 , 41 , 7 },
+{ 80 , 40 , 41 , 8 },
+{ 80 , 40 , 41 , 9 },
+{ 80 , 40 , 41 , 10 },
+{ 80 , 40 , 41 , 11 },
+{ 80 , 40 , 41 , 12 },
+{ 80 , 40 , 41 , 13 },
+{ 80 , 40 , 41 , 14 },
+{ 80 , 40 , 41 , 15 },
+{ 80 , 40 , 41 , 16 },
+{ 80 , 40 , 41 , 17 },
+{ 80 , 40 , 41 , 18 },
+{ 80 , 40 , 41 , 19 },
+{ 80 , 40 , 41 , 20 },
+{ 80 , 40 , 41 , 21 },
+{ 80 , 40 , 41 , 22 },
+{ 80 , 40 , 41 , 23 },
+{ 80 , 40 , 41 , 24 },
+{ 80 , 40 , 41 , 25 },
+{ 80 , 40 , 41 , 26 },
+{ 80 , 40 , 41 , 27 },
+{ 80 , 40 , 41 , 28 },
+{ 80 , 40 , 41 , 29 },
+{ 80 , 40 , 41 , 30 },
+{ 80 , 40 , 41 , 31 },
+{ 80 , 40 , 41 , 32 },
+{ 80 , 40 , 41 , 33 },
+{ 80 , 40 , 41 , 34 },
+{ 80 , 40 , 41 , 35 },
+{ 80 , 40 , 41 , 36 },
+{ 80 , 40 , 41 , 37 },
+{ 80 , 40 , 41 , 38 },
+{ 80 , 40 , 41 , 39 },
+{ 80 , 40 , 42 , 0 },
+{ 80 , 40 , 42 , 1 },
+{ 80 , 40 , 42 , 2 },
+{ 80 , 40 , 42 , 3 },
+{ 80 , 40 , 42 , 4 },
+{ 80 , 40 , 42 , 5 },
+{ 80 , 40 , 42 , 6 },
+{ 80 , 40 , 42 , 7 },
+{ 80 , 40 , 42 , 8 },
+{ 80 , 40 , 42 , 9 },
+{ 80 , 40 , 42 , 10 },
+{ 80 , 40 , 42 , 11 },
+{ 80 , 40 , 42 , 12 },
+{ 80 , 40 , 42 , 13 },
+{ 80 , 40 , 42 , 14 },
+{ 80 , 40 , 42 , 15 },
+{ 80 , 40 , 42 , 16 },
+{ 80 , 40 , 42 , 17 },
+{ 80 , 40 , 42 , 18 },
+{ 80 , 40 , 42 , 19 },
+{ 80 , 40 , 42 , 20 },
+{ 80 , 40 , 42 , 21 },
+{ 80 , 40 , 42 , 22 },
+{ 80 , 40 , 42 , 23 },
+{ 80 , 40 , 42 , 24 },
+{ 80 , 40 , 42 , 25 },
+{ 80 , 40 , 42 , 26 },
+{ 80 , 40 , 42 , 27 },
+{ 80 , 40 , 42 , 28 },
+{ 80 , 40 , 42 , 29 },
+{ 80 , 40 , 42 , 30 },
+{ 80 , 40 , 42 , 31 },
+{ 80 , 40 , 42 , 32 },
+{ 80 , 40 , 42 , 33 },
+{ 80 , 40 , 42 , 34 },
+{ 80 , 40 , 42 , 35 },
+{ 80 , 40 , 42 , 36 },
+{ 80 , 40 , 42 , 37 },
+{ 80 , 40 , 42 , 38 },
+{ 80 , 40 , 42 , 39 },
+{ 80 , 40 , 43 , 0 },
+{ 80 , 40 , 43 , 1 },
+{ 80 , 40 , 43 , 2 },
+{ 80 , 40 , 43 , 3 },
+{ 80 , 40 , 43 , 4 },
+{ 80 , 40 , 43 , 5 },
+{ 80 , 40 , 43 , 6 },
+{ 80 , 40 , 43 , 7 },
+{ 80 , 40 , 43 , 8 },
+{ 80 , 40 , 43 , 9 },
+{ 80 , 40 , 43 , 10 },
+{ 80 , 40 , 43 , 11 },
+{ 80 , 40 , 43 , 12 },
+{ 80 , 40 , 43 , 13 },
+{ 80 , 40 , 43 , 14 },
+{ 80 , 40 , 43 , 15 },
+{ 80 , 40 , 43 , 16 },
+{ 80 , 40 , 43 , 17 },
+{ 80 , 40 , 43 , 18 },
+{ 80 , 40 , 43 , 19 },
+{ 80 , 40 , 43 , 20 },
+{ 80 , 40 , 43 , 21 },
+{ 80 , 40 , 43 , 22 },
+{ 80 , 40 , 43 , 23 },
+{ 80 , 40 , 43 , 24 },
+{ 80 , 40 , 43 , 25 },
+{ 80 , 40 , 43 , 26 },
+{ 80 , 40 , 43 , 27 },
+{ 80 , 40 , 43 , 28 },
+{ 80 , 40 , 43 , 29 },
+{ 80 , 40 , 43 , 30 },
+{ 80 , 40 , 43 , 31 },
+{ 80 , 40 , 43 , 32 },
+{ 80 , 40 , 43 , 33 },
+{ 80 , 40 , 43 , 34 },
+{ 80 , 40 , 43 , 35 },
+{ 80 , 40 , 43 , 36 },
+{ 80 , 40 , 43 , 37 },
+{ 80 , 40 , 43 , 38 },
+{ 80 , 40 , 43 , 39 },
+{ 80 , 40 , 44 , 0 },
+{ 80 , 40 , 44 , 1 },
+{ 80 , 40 , 44 , 2 },
+{ 80 , 40 , 44 , 3 },
+{ 80 , 40 , 44 , 4 },
+{ 80 , 40 , 44 , 5 },
+{ 80 , 40 , 44 , 6 },
+{ 80 , 40 , 44 , 7 },
+{ 80 , 40 , 44 , 8 },
+{ 80 , 40 , 44 , 9 },
+{ 80 , 40 , 44 , 10 },
+{ 80 , 40 , 44 , 11 },
+{ 80 , 40 , 44 , 12 },
+{ 80 , 40 , 44 , 13 },
+{ 80 , 40 , 44 , 14 },
+{ 80 , 40 , 44 , 15 },
+{ 80 , 40 , 44 , 16 },
+{ 80 , 40 , 44 , 17 },
+{ 80 , 40 , 44 , 18 },
+{ 80 , 40 , 44 , 19 },
+{ 80 , 40 , 44 , 20 },
+{ 80 , 40 , 44 , 21 },
+{ 80 , 40 , 44 , 22 },
+{ 80 , 40 , 44 , 23 },
+{ 80 , 40 , 44 , 24 },
+{ 80 , 40 , 44 , 25 },
+{ 80 , 40 , 44 , 26 },
+{ 80 , 40 , 44 , 27 },
+{ 80 , 40 , 44 , 28 },
+{ 80 , 40 , 44 , 29 },
+{ 80 , 40 , 44 , 30 },
+{ 80 , 40 , 44 , 31 },
+{ 80 , 40 , 44 , 32 },
+{ 80 , 40 , 44 , 33 },
+{ 80 , 40 , 44 , 34 },
+{ 80 , 40 , 44 , 35 },
+{ 80 , 40 , 44 , 36 },
+{ 80 , 40 , 44 , 37 },
+{ 80 , 40 , 44 , 38 },
+{ 80 , 40 , 44 , 39 },
+{ 80 , 40 , 45 , 0 },
+{ 80 , 40 , 45 , 1 },
+{ 80 , 40 , 45 , 2 },
+{ 80 , 40 , 45 , 3 },
+{ 80 , 40 , 45 , 4 },
+{ 80 , 40 , 45 , 5 },
+{ 80 , 40 , 45 , 6 },
+{ 80 , 40 , 45 , 7 },
+{ 80 , 40 , 45 , 8 },
+{ 80 , 40 , 45 , 9 },
+{ 80 , 40 , 45 , 10 },
+{ 80 , 40 , 45 , 11 },
+{ 80 , 40 , 45 , 12 },
+{ 80 , 40 , 45 , 13 },
+{ 80 , 40 , 45 , 14 },
+{ 80 , 40 , 45 , 15 },
+{ 80 , 40 , 45 , 16 },
+{ 80 , 40 , 45 , 17 },
+{ 80 , 40 , 45 , 18 },
+{ 80 , 40 , 45 , 19 },
+{ 80 , 40 , 45 , 20 },
+{ 80 , 40 , 45 , 21 },
+{ 80 , 40 , 45 , 22 },
+{ 80 , 40 , 45 , 23 },
+{ 80 , 40 , 45 , 24 },
+{ 80 , 40 , 45 , 25 },
+{ 80 , 40 , 45 , 26 },
+{ 80 , 40 , 45 , 27 },
+{ 80 , 40 , 45 , 28 },
+{ 80 , 40 , 45 , 29 },
+{ 80 , 40 , 45 , 30 },
+{ 80 , 40 , 45 , 31 },
+{ 80 , 40 , 45 , 32 },
+{ 80 , 40 , 45 , 33 },
+{ 80 , 40 , 45 , 34 },
+{ 80 , 40 , 45 , 35 },
+{ 80 , 40 , 45 , 36 },
+{ 80 , 40 , 45 , 37 },
+{ 80 , 40 , 45 , 38 },
+{ 80 , 40 , 45 , 39 },
+{ 80 , 40 , 46 , 0 },
+{ 80 , 40 , 46 , 1 },
+{ 80 , 40 , 46 , 2 },
+{ 80 , 40 , 46 , 3 },
+{ 80 , 40 , 46 , 4 },
+{ 80 , 40 , 46 , 5 },
+{ 80 , 40 , 46 , 6 },
+{ 80 , 40 , 46 , 7 },
+{ 80 , 40 , 46 , 8 },
+{ 80 , 40 , 46 , 9 },
+{ 80 , 40 , 46 , 10 },
+{ 80 , 40 , 46 , 11 },
+{ 80 , 40 , 46 , 12 },
+{ 80 , 40 , 46 , 13 },
+{ 80 , 40 , 46 , 14 },
+{ 80 , 40 , 46 , 15 },
+{ 80 , 40 , 46 , 16 },
+{ 80 , 40 , 46 , 17 },
+{ 80 , 40 , 46 , 18 },
+{ 80 , 40 , 46 , 19 },
+{ 80 , 40 , 46 , 20 },
+{ 80 , 40 , 46 , 21 },
+{ 80 , 40 , 46 , 22 },
+{ 80 , 40 , 46 , 23 },
+{ 80 , 40 , 46 , 24 },
+{ 80 , 40 , 46 , 25 },
+{ 80 , 40 , 46 , 26 },
+{ 80 , 40 , 46 , 27 },
+{ 80 , 40 , 46 , 28 },
+{ 80 , 40 , 46 , 29 },
+{ 80 , 40 , 46 , 30 },
+{ 80 , 40 , 46 , 31 },
+{ 80 , 40 , 46 , 32 },
+{ 80 , 40 , 46 , 33 },
+{ 80 , 40 , 46 , 34 },
+{ 80 , 40 , 46 , 35 },
+{ 80 , 40 , 46 , 36 },
+{ 80 , 40 , 46 , 37 },
+{ 80 , 40 , 46 , 38 },
+{ 80 , 40 , 46 , 39 },
+{ 80 , 40 , 47 , 0 },
+{ 80 , 40 , 47 , 1 },
+{ 80 , 40 , 47 , 2 },
+{ 80 , 40 , 47 , 3 },
+{ 80 , 40 , 47 , 4 },
+{ 80 , 40 , 47 , 5 },
+{ 80 , 40 , 47 , 6 },
+{ 80 , 40 , 47 , 7 },
+{ 80 , 40 , 47 , 8 },
+{ 80 , 40 , 47 , 9 },
+{ 80 , 40 , 47 , 10 },
+{ 80 , 40 , 47 , 11 },
+{ 80 , 40 , 47 , 12 },
+{ 80 , 40 , 47 , 13 },
+{ 80 , 40 , 47 , 14 },
+{ 80 , 40 , 47 , 15 },
+{ 80 , 40 , 47 , 16 },
+{ 80 , 40 , 47 , 17 },
+{ 80 , 40 , 47 , 18 },
+{ 80 , 40 , 47 , 19 },
+{ 80 , 40 , 47 , 20 },
+{ 80 , 40 , 47 , 21 },
+{ 80 , 40 , 47 , 22 },
+{ 80 , 40 , 47 , 23 },
+{ 80 , 40 , 47 , 24 },
+{ 80 , 40 , 47 , 25 },
+{ 80 , 40 , 47 , 26 },
+{ 80 , 40 , 47 , 27 },
+{ 80 , 40 , 47 , 28 },
+{ 80 , 40 , 47 , 29 },
+{ 80 , 40 , 47 , 30 },
+{ 80 , 40 , 47 , 31 },
+{ 80 , 40 , 47 , 32 },
+{ 80 , 40 , 47 , 33 },
+{ 80 , 40 , 47 , 34 },
+{ 80 , 40 , 47 , 35 },
+{ 80 , 40 , 47 , 36 },
+{ 80 , 40 , 47 , 37 },
+{ 80 , 40 , 47 , 38 },
+{ 80 , 40 , 47 , 39 },
+{ 80 , 40 , 48 , 0 },
+{ 80 , 40 , 48 , 1 },
+{ 80 , 40 , 48 , 2 },
+{ 80 , 40 , 48 , 3 },
+{ 80 , 40 , 48 , 4 },
+{ 80 , 40 , 48 , 5 },
+{ 80 , 40 , 48 , 6 },
+{ 80 , 40 , 48 , 7 },
+{ 80 , 40 , 48 , 8 },
+{ 80 , 40 , 48 , 9 },
+{ 80 , 40 , 48 , 10 },
+{ 80 , 40 , 48 , 11 },
+{ 80 , 40 , 48 , 12 },
+{ 80 , 40 , 48 , 13 },
+{ 80 , 40 , 48 , 14 },
+{ 80 , 40 , 48 , 15 },
+{ 80 , 40 , 48 , 16 },
+{ 80 , 40 , 48 , 17 },
+{ 80 , 40 , 48 , 18 },
+{ 80 , 40 , 48 , 19 },
+{ 80 , 40 , 48 , 20 },
+{ 80 , 40 , 48 , 21 },
+{ 80 , 40 , 48 , 22 },
+{ 80 , 40 , 48 , 23 },
+{ 80 , 40 , 48 , 24 },
+{ 80 , 40 , 48 , 25 },
+{ 80 , 40 , 48 , 26 },
+{ 80 , 40 , 48 , 27 },
+{ 80 , 40 , 48 , 28 },
+{ 80 , 40 , 48 , 29 },
+{ 80 , 40 , 48 , 30 },
+{ 80 , 40 , 48 , 31 },
+{ 80 , 40 , 48 , 32 },
+{ 80 , 40 , 48 , 33 },
+{ 80 , 40 , 48 , 34 },
+{ 80 , 40 , 48 , 35 },
+{ 80 , 40 , 48 , 36 },
+{ 80 , 40 , 48 , 37 },
+{ 80 , 40 , 48 , 38 },
+{ 80 , 40 , 48 , 39 },
+{ 80 , 40 , 49 , 0 },
+{ 80 , 40 , 49 , 1 },
+{ 80 , 40 , 49 , 2 },
+{ 80 , 40 , 49 , 3 },
+{ 80 , 40 , 49 , 4 },
+{ 80 , 40 , 49 , 5 },
+{ 80 , 40 , 49 , 6 },
+{ 80 , 40 , 49 , 7 },
+{ 80 , 40 , 49 , 8 },
+{ 80 , 40 , 49 , 9 },
+{ 80 , 40 , 49 , 10 },
+{ 80 , 40 , 49 , 11 },
+{ 80 , 40 , 49 , 12 },
+{ 80 , 40 , 49 , 13 },
+{ 80 , 40 , 49 , 14 },
+{ 80 , 40 , 49 , 15 },
+{ 80 , 40 , 49 , 16 },
+{ 80 , 40 , 49 , 17 },
+{ 80 , 40 , 49 , 18 },
+{ 80 , 40 , 49 , 19 },
+{ 80 , 40 , 49 , 20 },
+{ 80 , 40 , 49 , 21 },
+{ 80 , 40 , 49 , 22 },
+{ 80 , 40 , 49 , 23 },
+{ 80 , 40 , 49 , 24 },
+{ 80 , 40 , 49 , 25 },
+{ 80 , 40 , 49 , 26 },
+{ 80 , 40 , 49 , 27 },
+{ 80 , 40 , 49 , 28 },
+{ 80 , 40 , 49 , 29 },
+{ 80 , 40 , 49 , 30 },
+{ 80 , 40 , 49 , 31 },
+{ 80 , 40 , 49 , 32 },
+{ 80 , 40 , 49 , 33 },
+{ 80 , 40 , 49 , 34 },
+{ 80 , 40 , 49 , 35 },
+{ 80 , 40 , 49 , 36 },
+{ 80 , 40 , 49 , 37 },
+{ 80 , 40 , 49 , 38 },
+{ 80 , 40 , 49 , 39 },
+{ 80 , 40 , 50 , 0 },
+{ 80 , 40 , 50 , 1 },
+{ 80 , 40 , 50 , 2 },
+{ 80 , 40 , 50 , 3 },
+{ 80 , 40 , 50 , 4 },
+{ 80 , 40 , 50 , 5 },
+{ 80 , 40 , 50 , 6 },
+{ 80 , 40 , 50 , 7 },
+{ 80 , 40 , 50 , 8 },
+{ 80 , 40 , 50 , 9 },
+{ 80 , 40 , 50 , 10 },
+{ 80 , 40 , 50 , 11 },
+{ 80 , 40 , 50 , 12 },
+{ 80 , 40 , 50 , 13 },
+{ 80 , 40 , 50 , 14 },
+{ 80 , 40 , 50 , 15 },
+{ 80 , 40 , 50 , 16 },
+{ 80 , 40 , 50 , 17 },
+{ 80 , 40 , 50 , 18 },
+{ 80 , 40 , 50 , 19 },
+{ 80 , 40 , 50 , 20 },
+{ 80 , 40 , 50 , 21 },
+{ 80 , 40 , 50 , 22 },
+{ 80 , 40 , 50 , 23 },
+{ 80 , 40 , 50 , 24 },
+{ 80 , 40 , 50 , 25 },
+{ 80 , 40 , 50 , 26 },
+{ 80 , 40 , 50 , 27 },
+{ 80 , 40 , 50 , 28 },
+{ 80 , 40 , 50 , 29 },
+{ 80 , 40 , 50 , 30 },
+{ 80 , 40 , 50 , 31 },
+{ 80 , 40 , 50 , 32 },
+{ 80 , 40 , 50 , 33 },
+{ 80 , 40 , 50 , 34 },
+{ 80 , 40 , 50 , 35 },
+{ 80 , 40 , 50 , 36 },
+{ 80 , 40 , 50 , 37 },
+{ 80 , 40 , 50 , 38 },
+{ 80 , 40 , 50 , 39 },
+{ 80 , 40 , 51 , 0 },
+{ 80 , 40 , 51 , 1 },
+{ 80 , 40 , 51 , 2 },
+{ 80 , 40 , 51 , 3 },
+{ 80 , 40 , 51 , 4 },
+{ 80 , 40 , 51 , 5 },
+{ 80 , 40 , 51 , 6 },
+{ 80 , 40 , 51 , 7 },
+{ 80 , 40 , 51 , 8 },
+{ 80 , 40 , 51 , 9 },
+{ 80 , 40 , 51 , 10 },
+{ 80 , 40 , 51 , 11 },
+{ 80 , 40 , 51 , 12 },
+{ 80 , 40 , 51 , 13 },
+{ 80 , 40 , 51 , 14 },
+{ 80 , 40 , 51 , 15 },
+{ 80 , 40 , 51 , 16 },
+{ 80 , 40 , 51 , 17 },
+{ 80 , 40 , 51 , 18 },
+{ 80 , 40 , 51 , 19 },
+{ 80 , 40 , 51 , 20 },
+{ 80 , 40 , 51 , 21 },
+{ 80 , 40 , 51 , 22 },
+{ 80 , 40 , 51 , 23 },
+{ 80 , 40 , 51 , 24 },
+{ 80 , 40 , 51 , 25 },
+{ 80 , 40 , 51 , 26 },
+{ 80 , 40 , 51 , 27 },
+{ 80 , 40 , 51 , 28 },
+{ 80 , 40 , 51 , 29 },
+{ 80 , 40 , 51 , 30 },
+{ 80 , 40 , 51 , 31 },
+{ 80 , 40 , 51 , 32 },
+{ 80 , 40 , 51 , 33 },
+{ 80 , 40 , 51 , 34 },
+{ 80 , 40 , 51 , 35 },
+{ 80 , 40 , 51 , 36 },
+{ 80 , 40 , 51 , 37 },
+{ 80 , 40 , 51 , 38 },
+{ 80 , 40 , 51 , 39 },
+{ 80 , 40 , 52 , 0 },
+{ 80 , 40 , 52 , 1 },
+{ 80 , 40 , 52 , 2 },
+{ 80 , 40 , 52 , 3 },
+{ 80 , 40 , 52 , 4 },
+{ 80 , 40 , 52 , 5 },
+{ 80 , 40 , 52 , 6 },
+{ 80 , 40 , 52 , 7 },
+{ 80 , 40 , 52 , 8 },
+{ 80 , 40 , 52 , 9 },
+{ 80 , 40 , 52 , 10 },
+{ 80 , 40 , 52 , 11 },
+{ 80 , 40 , 52 , 12 },
+{ 80 , 40 , 52 , 13 },
+{ 80 , 40 , 52 , 14 },
+{ 80 , 40 , 52 , 15 },
+{ 80 , 40 , 52 , 16 },
+{ 80 , 40 , 52 , 17 },
+{ 80 , 40 , 52 , 18 },
+{ 80 , 40 , 52 , 19 },
+{ 80 , 40 , 52 , 20 },
+{ 80 , 40 , 52 , 21 },
+{ 80 , 40 , 52 , 22 },
+{ 80 , 40 , 52 , 23 },
+{ 80 , 40 , 52 , 24 },
+{ 80 , 40 , 52 , 25 },
+{ 80 , 40 , 52 , 26 },
+{ 80 , 40 , 52 , 27 },
+{ 80 , 40 , 52 , 28 },
+{ 80 , 40 , 52 , 29 },
+{ 80 , 40 , 52 , 30 },
+{ 80 , 40 , 52 , 31 },
+{ 80 , 40 , 52 , 32 },
+{ 80 , 40 , 52 , 33 },
+{ 80 , 40 , 52 , 34 },
+{ 80 , 40 , 52 , 35 },
+{ 80 , 40 , 52 , 36 },
+{ 80 , 40 , 52 , 37 },
+{ 80 , 40 , 52 , 38 },
+{ 80 , 40 , 52 , 39 },
+{ 80 , 40 , 53 , 0 },
+{ 80 , 40 , 53 , 1 },
+{ 80 , 40 , 53 , 2 },
+{ 80 , 40 , 53 , 3 },
+{ 80 , 40 , 53 , 4 },
+{ 80 , 40 , 53 , 5 },
+{ 80 , 40 , 53 , 6 },
+{ 80 , 40 , 53 , 7 },
+{ 80 , 40 , 53 , 8 },
+{ 80 , 40 , 53 , 9 },
+{ 80 , 40 , 53 , 10 },
+{ 80 , 40 , 53 , 11 },
+{ 80 , 40 , 53 , 12 },
+{ 80 , 40 , 53 , 13 },
+{ 80 , 40 , 53 , 14 },
+{ 80 , 40 , 53 , 15 },
+{ 80 , 40 , 53 , 16 },
+{ 80 , 40 , 53 , 17 },
+{ 80 , 40 , 53 , 18 },
+{ 80 , 40 , 53 , 19 },
+{ 80 , 40 , 53 , 20 },
+{ 80 , 40 , 53 , 21 },
+{ 80 , 40 , 53 , 22 },
+{ 80 , 40 , 53 , 23 },
+{ 80 , 40 , 53 , 24 },
+{ 80 , 40 , 53 , 25 },
+{ 80 , 40 , 53 , 26 },
+{ 80 , 40 , 53 , 27 },
+{ 80 , 40 , 53 , 28 },
+{ 80 , 40 , 53 , 29 },
+{ 80 , 40 , 53 , 30 },
+{ 80 , 40 , 53 , 31 },
+{ 80 , 40 , 53 , 32 },
+{ 80 , 40 , 53 , 33 },
+{ 80 , 40 , 53 , 34 },
+{ 80 , 40 , 53 , 35 },
+{ 80 , 40 , 53 , 36 },
+{ 80 , 40 , 53 , 37 },
+{ 80 , 40 , 53 , 38 },
+{ 80 , 40 , 53 , 39 },
+{ 80 , 40 , 54 , 0 },
+{ 80 , 40 , 54 , 1 },
+{ 80 , 40 , 54 , 2 },
+{ 80 , 40 , 54 , 3 },
+{ 80 , 40 , 54 , 4 },
+{ 80 , 40 , 54 , 5 },
+{ 80 , 40 , 54 , 6 },
+{ 80 , 40 , 54 , 7 },
+{ 80 , 40 , 54 , 8 },
+{ 80 , 40 , 54 , 9 },
+{ 80 , 40 , 54 , 10 },
+{ 80 , 40 , 54 , 11 },
+{ 80 , 40 , 54 , 12 },
+{ 80 , 40 , 54 , 13 },
+{ 80 , 40 , 54 , 14 },
+{ 80 , 40 , 54 , 15 },
+{ 80 , 40 , 54 , 16 },
+{ 80 , 40 , 54 , 17 },
+{ 80 , 40 , 54 , 18 },
+{ 80 , 40 , 54 , 19 },
+{ 80 , 40 , 54 , 20 },
+{ 80 , 40 , 54 , 21 },
+{ 80 , 40 , 54 , 22 },
+{ 80 , 40 , 54 , 23 },
+{ 80 , 40 , 54 , 24 },
+{ 80 , 40 , 54 , 25 },
+{ 80 , 40 , 54 , 26 },
+{ 80 , 40 , 54 , 27 },
+{ 80 , 40 , 54 , 28 },
+{ 80 , 40 , 54 , 29 },
+{ 80 , 40 , 54 , 30 },
+{ 80 , 40 , 54 , 31 },
+{ 80 , 40 , 54 , 32 },
+{ 80 , 40 , 54 , 33 },
+{ 80 , 40 , 54 , 34 },
+{ 80 , 40 , 54 , 35 },
+{ 80 , 40 , 54 , 36 },
+{ 80 , 40 , 54 , 37 },
+{ 80 , 40 , 54 , 38 },
+{ 80 , 40 , 54 , 39 },
+{ 80 , 40 , 55 , 0 },
+{ 80 , 40 , 55 , 1 },
+{ 80 , 40 , 55 , 2 },
+{ 80 , 40 , 55 , 3 },
+{ 80 , 40 , 55 , 4 },
+{ 80 , 40 , 55 , 5 },
+{ 80 , 40 , 55 , 6 },
+{ 80 , 40 , 55 , 7 },
+{ 80 , 40 , 55 , 8 },
+{ 80 , 40 , 55 , 9 },
+{ 80 , 40 , 55 , 10 },
+{ 80 , 40 , 55 , 11 },
+{ 80 , 40 , 55 , 12 },
+{ 80 , 40 , 55 , 13 },
+{ 80 , 40 , 55 , 14 },
+{ 80 , 40 , 55 , 15 },
+{ 80 , 40 , 55 , 16 },
+{ 80 , 40 , 55 , 17 },
+{ 80 , 40 , 55 , 18 },
+{ 80 , 40 , 55 , 19 },
+{ 80 , 40 , 55 , 20 },
+{ 80 , 40 , 55 , 21 },
+{ 80 , 40 , 55 , 22 },
+{ 80 , 40 , 55 , 23 },
+{ 80 , 40 , 55 , 24 },
+{ 80 , 40 , 55 , 25 },
+{ 80 , 40 , 55 , 26 },
+{ 80 , 40 , 55 , 27 },
+{ 80 , 40 , 55 , 28 },
+{ 80 , 40 , 55 , 29 },
+{ 80 , 40 , 55 , 30 },
+{ 80 , 40 , 55 , 31 },
+{ 80 , 40 , 55 , 32 },
+{ 80 , 40 , 55 , 33 },
+{ 80 , 40 , 55 , 34 },
+{ 80 , 40 , 55 , 35 },
+{ 80 , 40 , 55 , 36 },
+{ 80 , 40 , 55 , 37 },
+{ 80 , 40 , 55 , 38 },
+{ 80 , 40 , 55 , 39 },
+{ 80 , 40 , 56 , 0 },
+{ 80 , 40 , 56 , 1 },
+{ 80 , 40 , 56 , 2 },
+{ 80 , 40 , 56 , 3 },
+{ 80 , 40 , 56 , 4 },
+{ 80 , 40 , 56 , 5 },
+{ 80 , 40 , 56 , 6 },
+{ 80 , 40 , 56 , 7 },
+{ 80 , 40 , 56 , 8 },
+{ 80 , 40 , 56 , 9 },
+{ 80 , 40 , 56 , 10 },
+{ 80 , 40 , 56 , 11 },
+{ 80 , 40 , 56 , 12 },
+{ 80 , 40 , 56 , 13 },
+{ 80 , 40 , 56 , 14 },
+{ 80 , 40 , 56 , 15 },
+{ 80 , 40 , 56 , 16 },
+{ 80 , 40 , 56 , 17 },
+{ 80 , 40 , 56 , 18 },
+{ 80 , 40 , 56 , 19 },
+{ 80 , 40 , 56 , 20 },
+{ 80 , 40 , 56 , 21 },
+{ 80 , 40 , 56 , 22 },
+{ 80 , 40 , 56 , 23 },
+{ 80 , 40 , 56 , 24 },
+{ 80 , 40 , 56 , 25 },
+{ 80 , 40 , 56 , 26 },
+{ 80 , 40 , 56 , 27 },
+{ 80 , 40 , 56 , 28 },
+{ 80 , 40 , 56 , 29 },
+{ 80 , 40 , 56 , 30 },
+{ 80 , 40 , 56 , 31 },
+{ 80 , 40 , 56 , 32 },
+{ 80 , 40 , 56 , 33 },
+{ 80 , 40 , 56 , 34 },
+{ 80 , 40 , 56 , 35 },
+{ 80 , 40 , 56 , 36 },
+{ 80 , 40 , 56 , 37 },
+{ 80 , 40 , 56 , 38 },
+{ 80 , 40 , 56 , 39 },
+{ 80 , 40 , 57 , 0 },
+{ 80 , 40 , 57 , 1 },
+{ 80 , 40 , 57 , 2 },
+{ 80 , 40 , 57 , 3 },
+{ 80 , 40 , 57 , 4 },
+{ 80 , 40 , 57 , 5 },
+{ 80 , 40 , 57 , 6 },
+{ 80 , 40 , 57 , 7 },
+{ 80 , 40 , 57 , 8 },
+{ 80 , 40 , 57 , 9 },
+{ 80 , 40 , 57 , 10 },
+{ 80 , 40 , 57 , 11 },
+{ 80 , 40 , 57 , 12 },
+{ 80 , 40 , 57 , 13 },
+{ 80 , 40 , 57 , 14 },
+{ 80 , 40 , 57 , 15 },
+{ 80 , 40 , 57 , 16 },
+{ 80 , 40 , 57 , 17 },
+{ 80 , 40 , 57 , 18 },
+{ 80 , 40 , 57 , 19 },
+{ 80 , 40 , 57 , 20 },
+{ 80 , 40 , 57 , 21 },
+{ 80 , 40 , 57 , 22 },
+{ 80 , 40 , 57 , 23 },
+{ 80 , 40 , 57 , 24 },
+{ 80 , 40 , 57 , 25 },
+{ 80 , 40 , 57 , 26 },
+{ 80 , 40 , 57 , 27 },
+{ 80 , 40 , 57 , 28 },
+{ 80 , 40 , 57 , 29 },
+{ 80 , 40 , 57 , 30 },
+{ 80 , 40 , 57 , 31 },
+{ 80 , 40 , 57 , 32 },
+{ 80 , 40 , 57 , 33 },
+{ 80 , 40 , 57 , 34 },
+{ 80 , 40 , 57 , 35 },
+{ 80 , 40 , 57 , 36 },
+{ 80 , 40 , 57 , 37 },
+{ 80 , 40 , 57 , 38 },
+{ 80 , 40 , 57 , 39 },
+{ 80 , 40 , 58 , 0 },
+{ 80 , 40 , 58 , 1 },
+{ 80 , 40 , 58 , 2 },
+{ 80 , 40 , 58 , 3 },
+{ 80 , 40 , 58 , 4 },
+{ 80 , 40 , 58 , 5 },
+{ 80 , 40 , 58 , 6 },
+{ 80 , 40 , 58 , 7 },
+{ 80 , 40 , 58 , 8 },
+{ 80 , 40 , 58 , 9 },
+{ 80 , 40 , 58 , 10 },
+{ 80 , 40 , 58 , 11 },
+{ 80 , 40 , 58 , 12 },
+{ 80 , 40 , 58 , 13 },
+{ 80 , 40 , 58 , 14 },
+{ 80 , 40 , 58 , 15 },
+{ 80 , 40 , 58 , 16 },
+{ 80 , 40 , 58 , 17 },
+{ 80 , 40 , 58 , 18 },
+{ 80 , 40 , 58 , 19 },
+{ 80 , 40 , 58 , 20 },
+{ 80 , 40 , 58 , 21 },
+{ 80 , 40 , 58 , 22 },
+{ 80 , 40 , 58 , 23 },
+{ 80 , 40 , 58 , 24 },
+{ 80 , 40 , 58 , 25 },
+{ 80 , 40 , 58 , 26 },
+{ 80 , 40 , 58 , 27 },
+{ 80 , 40 , 58 , 28 },
+{ 80 , 40 , 58 , 29 },
+{ 80 , 40 , 58 , 30 },
+{ 80 , 40 , 58 , 31 },
+{ 80 , 40 , 58 , 32 },
+{ 80 , 40 , 58 , 33 },
+{ 80 , 40 , 58 , 34 },
+{ 80 , 40 , 58 , 35 },
+{ 80 , 40 , 58 , 36 },
+{ 80 , 40 , 58 , 37 },
+{ 80 , 40 , 58 , 38 },
+{ 80 , 40 , 58 , 39 },
+{ 80 , 40 , 59 , 0 },
+{ 80 , 40 , 59 , 1 },
+{ 80 , 40 , 59 , 2 },
+{ 80 , 40 , 59 , 3 },
+{ 80 , 40 , 59 , 4 },
+{ 80 , 40 , 59 , 5 },
+{ 80 , 40 , 59 , 6 },
+{ 80 , 40 , 59 , 7 },
+{ 80 , 40 , 59 , 8 },
+{ 80 , 40 , 59 , 9 },
+{ 80 , 40 , 59 , 10 },
+{ 80 , 40 , 59 , 11 },
+{ 80 , 40 , 59 , 12 },
+{ 80 , 40 , 59 , 13 },
+{ 80 , 40 , 59 , 14 },
+{ 80 , 40 , 59 , 15 },
+{ 80 , 40 , 59 , 16 },
+{ 80 , 40 , 59 , 17 },
+{ 80 , 40 , 59 , 18 },
+{ 80 , 40 , 59 , 19 },
+{ 80 , 40 , 59 , 20 },
+{ 80 , 40 , 59 , 21 },
+{ 80 , 40 , 59 , 22 },
+{ 80 , 40 , 59 , 23 },
+{ 80 , 40 , 59 , 24 },
+{ 80 , 40 , 59 , 25 },
+{ 80 , 40 , 59 , 26 },
+{ 80 , 40 , 59 , 27 },
+{ 80 , 40 , 59 , 28 },
+{ 80 , 40 , 59 , 29 },
+{ 80 , 40 , 59 , 30 },
+{ 80 , 40 , 59 , 31 },
+{ 80 , 40 , 59 , 32 },
+{ 80 , 40 , 59 , 33 },
+{ 80 , 40 , 59 , 34 },
+{ 80 , 40 , 59 , 35 },
+{ 80 , 40 , 59 , 36 },
+{ 80 , 40 , 59 , 37 },
+{ 80 , 40 , 59 , 38 },
+{ 80 , 40 , 59 , 39 },
+{ 80 , 40 , 60 , 0 },
+{ 80 , 40 , 60 , 1 },
+{ 80 , 40 , 60 , 2 },
+{ 80 , 40 , 60 , 3 },
+{ 80 , 40 , 60 , 4 },
+{ 80 , 40 , 60 , 5 },
+{ 80 , 40 , 60 , 6 },
+{ 80 , 40 , 60 , 7 },
+{ 80 , 40 , 60 , 8 },
+{ 80 , 40 , 60 , 9 },
+{ 80 , 40 , 60 , 10 },
+{ 80 , 40 , 60 , 11 },
+{ 80 , 40 , 60 , 12 },
+{ 80 , 40 , 60 , 13 },
+{ 80 , 40 , 60 , 14 },
+{ 80 , 40 , 60 , 15 },
+{ 80 , 40 , 60 , 16 },
+{ 80 , 40 , 60 , 17 },
+{ 80 , 40 , 60 , 18 },
+{ 80 , 40 , 60 , 19 },
+{ 80 , 40 , 60 , 20 },
+{ 80 , 40 , 60 , 21 },
+{ 80 , 40 , 60 , 22 },
+{ 80 , 40 , 60 , 23 },
+{ 80 , 40 , 60 , 24 },
+{ 80 , 40 , 60 , 25 },
+{ 80 , 40 , 60 , 26 },
+{ 80 , 40 , 60 , 27 },
+{ 80 , 40 , 60 , 28 },
+{ 80 , 40 , 60 , 29 },
+{ 80 , 40 , 60 , 30 },
+{ 80 , 40 , 60 , 31 },
+{ 80 , 40 , 60 , 32 },
+{ 80 , 40 , 60 , 33 },
+{ 80 , 40 , 60 , 34 },
+{ 80 , 40 , 60 , 35 },
+{ 80 , 40 , 60 , 36 },
+{ 80 , 40 , 60 , 37 },
+{ 80 , 40 , 60 , 38 },
+{ 80 , 40 , 60 , 39 },
+{ 80 , 40 , 61 , 0 },
+{ 80 , 40 , 61 , 1 },
+{ 80 , 40 , 61 , 2 },
+{ 80 , 40 , 61 , 3 },
+{ 80 , 40 , 61 , 4 },
+{ 80 , 40 , 61 , 5 },
+{ 80 , 40 , 61 , 6 },
+{ 80 , 40 , 61 , 7 },
+{ 80 , 40 , 61 , 8 },
+{ 80 , 40 , 61 , 9 },
+{ 80 , 40 , 61 , 10 },
+{ 80 , 40 , 61 , 11 },
+{ 80 , 40 , 61 , 12 },
+{ 80 , 40 , 61 , 13 },
+{ 80 , 40 , 61 , 14 },
+{ 80 , 40 , 61 , 15 },
+{ 80 , 40 , 61 , 16 },
+{ 80 , 40 , 61 , 17 },
+{ 80 , 40 , 61 , 18 },
+{ 80 , 40 , 61 , 19 },
+{ 80 , 40 , 61 , 20 },
+{ 80 , 40 , 61 , 21 },
+{ 80 , 40 , 61 , 22 },
+{ 80 , 40 , 61 , 23 },
+{ 80 , 40 , 61 , 24 },
+{ 80 , 40 , 61 , 25 },
+{ 80 , 40 , 61 , 26 },
+{ 80 , 40 , 61 , 27 },
+{ 80 , 40 , 61 , 28 },
+{ 80 , 40 , 61 , 29 },
+{ 80 , 40 , 61 , 30 },
+{ 80 , 40 , 61 , 31 },
+{ 80 , 40 , 61 , 32 },
+{ 80 , 40 , 61 , 33 },
+{ 80 , 40 , 61 , 34 },
+{ 80 , 40 , 61 , 35 },
+{ 80 , 40 , 61 , 36 },
+{ 80 , 40 , 61 , 37 },
+{ 80 , 40 , 61 , 38 },
+{ 80 , 40 , 61 , 39 },
+{ 80 , 40 , 62 , 0 },
+{ 80 , 40 , 62 , 1 },
+{ 80 , 40 , 62 , 2 },
+{ 80 , 40 , 62 , 3 },
+{ 80 , 40 , 62 , 4 },
+{ 80 , 40 , 62 , 5 },
+{ 80 , 40 , 62 , 6 },
+{ 80 , 40 , 62 , 7 },
+{ 80 , 40 , 62 , 8 },
+{ 80 , 40 , 62 , 9 },
+{ 80 , 40 , 62 , 10 },
+{ 80 , 40 , 62 , 11 },
+{ 80 , 40 , 62 , 12 },
+{ 80 , 40 , 62 , 13 },
+{ 80 , 40 , 62 , 14 },
+{ 80 , 40 , 62 , 15 },
+{ 80 , 40 , 62 , 16 },
+{ 80 , 40 , 62 , 17 },
+{ 80 , 40 , 62 , 18 },
+{ 80 , 40 , 62 , 19 },
+{ 80 , 40 , 62 , 20 },
+{ 80 , 40 , 62 , 21 },
+{ 80 , 40 , 62 , 22 },
+{ 80 , 40 , 62 , 23 },
+{ 80 , 40 , 62 , 24 },
+{ 80 , 40 , 62 , 25 },
+{ 80 , 40 , 62 , 26 },
+{ 80 , 40 , 62 , 27 },
+{ 80 , 40 , 62 , 28 },
+{ 80 , 40 , 62 , 29 },
+{ 80 , 40 , 62 , 30 },
+{ 80 , 40 , 62 , 31 },
+{ 80 , 40 , 62 , 32 },
+{ 80 , 40 , 62 , 33 },
+{ 80 , 40 , 62 , 34 },
+{ 80 , 40 , 62 , 35 },
+{ 80 , 40 , 62 , 36 },
+{ 80 , 40 , 62 , 37 },
+{ 80 , 40 , 62 , 38 },
+{ 80 , 40 , 62 , 39 },
+{ 80 , 40 , 63 , 0 },
+{ 80 , 40 , 63 , 1 },
+{ 80 , 40 , 63 , 2 },
+{ 80 , 40 , 63 , 3 },
+{ 80 , 40 , 63 , 4 },
+{ 80 , 40 , 63 , 5 },
+{ 80 , 40 , 63 , 6 },
+{ 80 , 40 , 63 , 7 },
+{ 80 , 40 , 63 , 8 },
+{ 80 , 40 , 63 , 9 },
+{ 80 , 40 , 63 , 10 },
+{ 80 , 40 , 63 , 11 },
+{ 80 , 40 , 63 , 12 },
+{ 80 , 40 , 63 , 13 },
+{ 80 , 40 , 63 , 14 },
+{ 80 , 40 , 63 , 15 },
+{ 80 , 40 , 63 , 16 },
+{ 80 , 40 , 63 , 17 },
+{ 80 , 40 , 63 , 18 },
+{ 80 , 40 , 63 , 19 },
+{ 80 , 40 , 63 , 20 },
+{ 80 , 40 , 63 , 21 },
+{ 80 , 40 , 63 , 22 },
+{ 80 , 40 , 63 , 23 },
+{ 80 , 40 , 63 , 24 },
+{ 80 , 40 , 63 , 25 },
+{ 80 , 40 , 63 , 26 },
+{ 80 , 40 , 63 , 27 },
+{ 80 , 40 , 63 , 28 },
+{ 80 , 40 , 63 , 29 },
+{ 80 , 40 , 63 , 30 },
+{ 80 , 40 , 63 , 31 },
+{ 80 , 40 , 63 , 32 },
+{ 80 , 40 , 63 , 33 },
+{ 80 , 40 , 63 , 34 },
+{ 80 , 40 , 63 , 35 },
+{ 80 , 40 , 63 , 36 },
+{ 80 , 40 , 63 , 37 },
+{ 80 , 40 , 63 , 38 },
+{ 80 , 40 , 63 , 39 },
+{ 80 , 40 , 64 , 0 },
+{ 80 , 40 , 64 , 1 },
+{ 80 , 40 , 64 , 2 },
+{ 80 , 40 , 64 , 3 },
+{ 80 , 40 , 64 , 4 },
+{ 80 , 40 , 64 , 5 },
+{ 80 , 40 , 64 , 6 },
+{ 80 , 40 , 64 , 7 },
+{ 80 , 40 , 64 , 8 },
+{ 80 , 40 , 64 , 9 },
+{ 80 , 40 , 64 , 10 },
+{ 80 , 40 , 64 , 11 },
+{ 80 , 40 , 64 , 12 },
+{ 80 , 40 , 64 , 13 },
+{ 80 , 40 , 64 , 14 },
+{ 80 , 40 , 64 , 15 },
+{ 80 , 40 , 64 , 16 },
+{ 80 , 40 , 64 , 17 },
+{ 80 , 40 , 64 , 18 },
+{ 80 , 40 , 64 , 19 },
+{ 80 , 40 , 64 , 20 },
+{ 80 , 40 , 64 , 21 },
+{ 80 , 40 , 64 , 22 },
+{ 80 , 40 , 64 , 23 },
+{ 80 , 40 , 64 , 24 },
+{ 80 , 40 , 64 , 25 },
+{ 80 , 40 , 64 , 26 },
+{ 80 , 40 , 64 , 27 },
+{ 80 , 40 , 64 , 28 },
+{ 80 , 40 , 64 , 29 },
+{ 80 , 40 , 64 , 30 },
+{ 80 , 40 , 64 , 31 },
+{ 80 , 40 , 64 , 32 },
+{ 80 , 40 , 64 , 33 },
+{ 80 , 40 , 64 , 34 },
+{ 80 , 40 , 64 , 35 },
+{ 80 , 40 , 64 , 36 },
+{ 80 , 40 , 64 , 37 },
+{ 80 , 40 , 64 , 38 },
+{ 80 , 40 , 64 , 39 },
+{ 80 , 40 , 65 , 0 },
+{ 80 , 40 , 65 , 1 },
+{ 80 , 40 , 65 , 2 },
+{ 80 , 40 , 65 , 3 },
+{ 80 , 40 , 65 , 4 },
+{ 80 , 40 , 65 , 5 },
+{ 80 , 40 , 65 , 6 },
+{ 80 , 40 , 65 , 7 },
+{ 80 , 40 , 65 , 8 },
+{ 80 , 40 , 65 , 9 },
+{ 80 , 40 , 65 , 10 },
+{ 80 , 40 , 65 , 11 },
+{ 80 , 40 , 65 , 12 },
+{ 80 , 40 , 65 , 13 },
+{ 80 , 40 , 65 , 14 },
+{ 80 , 40 , 65 , 15 },
+{ 80 , 40 , 65 , 16 },
+{ 80 , 40 , 65 , 17 },
+{ 80 , 40 , 65 , 18 },
+{ 80 , 40 , 65 , 19 },
+{ 80 , 40 , 65 , 20 },
+{ 80 , 40 , 65 , 21 },
+{ 80 , 40 , 65 , 22 },
+{ 80 , 40 , 65 , 23 },
+{ 80 , 40 , 65 , 24 },
+{ 80 , 40 , 65 , 25 },
+{ 80 , 40 , 65 , 26 },
+{ 80 , 40 , 65 , 27 },
+{ 80 , 40 , 65 , 28 },
+{ 80 , 40 , 65 , 29 },
+{ 80 , 40 , 65 , 30 },
+{ 80 , 40 , 65 , 31 },
+{ 80 , 40 , 65 , 32 },
+{ 80 , 40 , 65 , 33 },
+{ 80 , 40 , 65 , 34 },
+{ 80 , 40 , 65 , 35 },
+{ 80 , 40 , 65 , 36 },
+{ 80 , 40 , 65 , 37 },
+{ 80 , 40 , 65 , 38 },
+{ 80 , 40 , 65 , 39 },
+{ 80 , 40 , 66 , 0 },
+{ 80 , 40 , 66 , 1 },
+{ 80 , 40 , 66 , 2 },
+{ 80 , 40 , 66 , 3 },
+{ 80 , 40 , 66 , 4 },
+{ 80 , 40 , 66 , 5 },
+{ 80 , 40 , 66 , 6 },
+{ 80 , 40 , 66 , 7 },
+{ 80 , 40 , 66 , 8 },
+{ 80 , 40 , 66 , 9 },
+{ 80 , 40 , 66 , 10 },
+{ 80 , 40 , 66 , 11 },
+{ 80 , 40 , 66 , 12 },
+{ 80 , 40 , 66 , 13 },
+{ 80 , 40 , 66 , 14 },
+{ 80 , 40 , 66 , 15 },
+{ 80 , 40 , 66 , 16 },
+{ 80 , 40 , 66 , 17 },
+{ 80 , 40 , 66 , 18 },
+{ 80 , 40 , 66 , 19 },
+{ 80 , 40 , 66 , 20 },
+{ 80 , 40 , 66 , 21 },
+{ 80 , 40 , 66 , 22 },
+{ 80 , 40 , 66 , 23 },
+{ 80 , 40 , 66 , 24 },
+{ 80 , 40 , 66 , 25 },
+{ 80 , 40 , 66 , 26 },
+{ 80 , 40 , 66 , 27 },
+{ 80 , 40 , 66 , 28 },
+{ 80 , 40 , 66 , 29 },
+{ 80 , 40 , 66 , 30 },
+{ 80 , 40 , 66 , 31 },
+{ 80 , 40 , 66 , 32 },
+{ 80 , 40 , 66 , 33 },
+{ 80 , 40 , 66 , 34 },
+{ 80 , 40 , 66 , 35 },
+{ 80 , 40 , 66 , 36 },
+{ 80 , 40 , 66 , 37 },
+{ 80 , 40 , 66 , 38 },
+{ 80 , 40 , 66 , 39 },
+{ 80 , 40 , 67 , 0 },
+{ 80 , 40 , 67 , 1 },
+{ 80 , 40 , 67 , 2 },
+{ 80 , 40 , 67 , 3 },
+{ 80 , 40 , 67 , 4 },
+{ 80 , 40 , 67 , 5 },
+{ 80 , 40 , 67 , 6 },
+{ 80 , 40 , 67 , 7 },
+{ 80 , 40 , 67 , 8 },
+{ 80 , 40 , 67 , 9 },
+{ 80 , 40 , 67 , 10 },
+{ 80 , 40 , 67 , 11 },
+{ 80 , 40 , 67 , 12 },
+{ 80 , 40 , 67 , 13 },
+{ 80 , 40 , 67 , 14 },
+{ 80 , 40 , 67 , 15 },
+{ 80 , 40 , 67 , 16 },
+{ 80 , 40 , 67 , 17 },
+{ 80 , 40 , 67 , 18 },
+{ 80 , 40 , 67 , 19 },
+{ 80 , 40 , 67 , 20 },
+{ 80 , 40 , 67 , 21 },
+{ 80 , 40 , 67 , 22 },
+{ 80 , 40 , 67 , 23 },
+{ 80 , 40 , 67 , 24 },
+{ 80 , 40 , 67 , 25 },
+{ 80 , 40 , 67 , 26 },
+{ 80 , 40 , 67 , 27 },
+{ 80 , 40 , 67 , 28 },
+{ 80 , 40 , 67 , 29 },
+{ 80 , 40 , 67 , 30 },
+{ 80 , 40 , 67 , 31 },
+{ 80 , 40 , 67 , 32 },
+{ 80 , 40 , 67 , 33 },
+{ 80 , 40 , 67 , 34 },
+{ 80 , 40 , 67 , 35 },
+{ 80 , 40 , 67 , 36 },
+{ 80 , 40 , 67 , 37 },
+{ 80 , 40 , 67 , 38 },
+{ 80 , 40 , 67 , 39 },
+{ 80 , 40 , 68 , 0 },
+{ 80 , 40 , 68 , 1 },
+{ 80 , 40 , 68 , 2 },
+{ 80 , 40 , 68 , 3 },
+{ 80 , 40 , 68 , 4 },
+{ 80 , 40 , 68 , 5 },
+{ 80 , 40 , 68 , 6 },
+{ 80 , 40 , 68 , 7 },
+{ 80 , 40 , 68 , 8 },
+{ 80 , 40 , 68 , 9 },
+{ 80 , 40 , 68 , 10 },
+{ 80 , 40 , 68 , 11 },
+{ 80 , 40 , 68 , 12 },
+{ 80 , 40 , 68 , 13 },
+{ 80 , 40 , 68 , 14 },
+{ 80 , 40 , 68 , 15 },
+{ 80 , 40 , 68 , 16 },
+{ 80 , 40 , 68 , 17 },
+{ 80 , 40 , 68 , 18 },
+{ 80 , 40 , 68 , 19 },
+{ 80 , 40 , 68 , 20 },
+{ 80 , 40 , 68 , 21 },
+{ 80 , 40 , 68 , 22 },
+{ 80 , 40 , 68 , 23 },
+{ 80 , 40 , 68 , 24 },
+{ 80 , 40 , 68 , 25 },
+{ 80 , 40 , 68 , 26 },
+{ 80 , 40 , 68 , 27 },
+{ 80 , 40 , 68 , 28 },
+{ 80 , 40 , 68 , 29 },
+{ 80 , 40 , 68 , 30 },
+{ 80 , 40 , 68 , 31 },
+{ 80 , 40 , 68 , 32 },
+{ 80 , 40 , 68 , 33 },
+{ 80 , 40 , 68 , 34 },
+{ 80 , 40 , 68 , 35 },
+{ 80 , 40 , 68 , 36 },
+{ 80 , 40 , 68 , 37 },
+{ 80 , 40 , 68 , 38 },
+{ 80 , 40 , 68 , 39 },
+{ 80 , 40 , 69 , 0 },
+{ 80 , 40 , 69 , 1 },
+{ 80 , 40 , 69 , 2 },
+{ 80 , 40 , 69 , 3 },
+{ 80 , 40 , 69 , 4 },
+{ 80 , 40 , 69 , 5 },
+{ 80 , 40 , 69 , 6 },
+{ 80 , 40 , 69 , 7 },
+{ 80 , 40 , 69 , 8 },
+{ 80 , 40 , 69 , 9 },
+{ 80 , 40 , 69 , 10 },
+{ 80 , 40 , 69 , 11 },
+{ 80 , 40 , 69 , 12 },
+{ 80 , 40 , 69 , 13 },
+{ 80 , 40 , 69 , 14 },
+{ 80 , 40 , 69 , 15 },
+{ 80 , 40 , 69 , 16 },
+{ 80 , 40 , 69 , 17 },
+{ 80 , 40 , 69 , 18 },
+{ 80 , 40 , 69 , 19 },
+{ 80 , 40 , 69 , 20 },
+{ 80 , 40 , 69 , 21 },
+{ 80 , 40 , 69 , 22 },
+{ 80 , 40 , 69 , 23 },
+{ 80 , 40 , 69 , 24 },
+{ 80 , 40 , 69 , 25 },
+{ 80 , 40 , 69 , 26 },
+{ 80 , 40 , 69 , 27 },
+{ 80 , 40 , 69 , 28 },
+{ 80 , 40 , 69 , 29 },
+{ 80 , 40 , 69 , 30 },
+{ 80 , 40 , 69 , 31 },
+{ 80 , 40 , 69 , 32 },
+{ 80 , 40 , 69 , 33 },
+{ 80 , 40 , 69 , 34 },
+{ 80 , 40 , 69 , 35 },
+{ 80 , 40 , 69 , 36 },
+{ 80 , 40 , 69 , 37 },
+{ 80 , 40 , 69 , 38 },
+{ 80 , 40 , 69 , 39 },
+{ 80 , 40 , 70 , 0 },
+{ 80 , 40 , 70 , 1 },
+{ 80 , 40 , 70 , 2 },
+{ 80 , 40 , 70 , 3 },
+{ 80 , 40 , 70 , 4 },
+{ 80 , 40 , 70 , 5 },
+{ 80 , 40 , 70 , 6 },
+{ 80 , 40 , 70 , 7 },
+{ 80 , 40 , 70 , 8 },
+{ 80 , 40 , 70 , 9 },
+{ 80 , 40 , 70 , 10 },
+{ 80 , 40 , 70 , 11 },
+{ 80 , 40 , 70 , 12 },
+{ 80 , 40 , 70 , 13 },
+{ 80 , 40 , 70 , 14 },
+{ 80 , 40 , 70 , 15 },
+{ 80 , 40 , 70 , 16 },
+{ 80 , 40 , 70 , 17 },
+{ 80 , 40 , 70 , 18 },
+{ 80 , 40 , 70 , 19 },
+{ 80 , 40 , 70 , 20 },
+{ 80 , 40 , 70 , 21 },
+{ 80 , 40 , 70 , 22 },
+{ 80 , 40 , 70 , 23 },
+{ 80 , 40 , 70 , 24 },
+{ 80 , 40 , 70 , 25 },
+{ 80 , 40 , 70 , 26 },
+{ 80 , 40 , 70 , 27 },
+{ 80 , 40 , 70 , 28 },
+{ 80 , 40 , 70 , 29 },
+{ 80 , 40 , 70 , 30 },
+{ 80 , 40 , 70 , 31 },
+{ 80 , 40 , 70 , 32 },
+{ 80 , 40 , 70 , 33 },
+{ 80 , 40 , 70 , 34 },
+{ 80 , 40 , 70 , 35 },
+{ 80 , 40 , 70 , 36 },
+{ 80 , 40 , 70 , 37 },
+{ 80 , 40 , 70 , 38 },
+{ 80 , 40 , 70 , 39 },
+{ 80 , 40 , 71 , 0 },
+{ 80 , 40 , 71 , 1 },
+{ 80 , 40 , 71 , 2 },
+{ 80 , 40 , 71 , 3 },
+{ 80 , 40 , 71 , 4 },
+{ 80 , 40 , 71 , 5 },
+{ 80 , 40 , 71 , 6 },
+{ 80 , 40 , 71 , 7 },
+{ 80 , 40 , 71 , 8 },
+{ 80 , 40 , 71 , 9 },
+{ 80 , 40 , 71 , 10 },
+{ 80 , 40 , 71 , 11 },
+{ 80 , 40 , 71 , 12 },
+{ 80 , 40 , 71 , 13 },
+{ 80 , 40 , 71 , 14 },
+{ 80 , 40 , 71 , 15 },
+{ 80 , 40 , 71 , 16 },
+{ 80 , 40 , 71 , 17 },
+{ 80 , 40 , 71 , 18 },
+{ 80 , 40 , 71 , 19 },
+{ 80 , 40 , 71 , 20 },
+{ 80 , 40 , 71 , 21 },
+{ 80 , 40 , 71 , 22 },
+{ 80 , 40 , 71 , 23 },
+{ 80 , 40 , 71 , 24 },
+{ 80 , 40 , 71 , 25 },
+{ 80 , 40 , 71 , 26 },
+{ 80 , 40 , 71 , 27 },
+{ 80 , 40 , 71 , 28 },
+{ 80 , 40 , 71 , 29 },
+{ 80 , 40 , 71 , 30 },
+{ 80 , 40 , 71 , 31 },
+{ 80 , 40 , 71 , 32 },
+{ 80 , 40 , 71 , 33 },
+{ 80 , 40 , 71 , 34 },
+{ 80 , 40 , 71 , 35 },
+{ 80 , 40 , 71 , 36 },
+{ 80 , 40 , 71 , 37 },
+{ 80 , 40 , 71 , 38 },
+{ 80 , 40 , 71 , 39 },
+{ 80 , 40 , 72 , 0 },
+{ 80 , 40 , 72 , 1 },
+{ 80 , 40 , 72 , 2 },
+{ 80 , 40 , 72 , 3 },
+{ 80 , 40 , 72 , 4 },
+{ 80 , 40 , 72 , 5 },
+{ 80 , 40 , 72 , 6 },
+{ 80 , 40 , 72 , 7 },
+{ 80 , 40 , 72 , 8 },
+{ 80 , 40 , 72 , 9 },
+{ 80 , 40 , 72 , 10 },
+{ 80 , 40 , 72 , 11 },
+{ 80 , 40 , 72 , 12 },
+{ 80 , 40 , 72 , 13 },
+{ 80 , 40 , 72 , 14 },
+{ 80 , 40 , 72 , 15 },
+{ 80 , 40 , 72 , 16 },
+{ 80 , 40 , 72 , 17 },
+{ 80 , 40 , 72 , 18 },
+{ 80 , 40 , 72 , 19 },
+{ 80 , 40 , 72 , 20 },
+{ 80 , 40 , 72 , 21 },
+{ 80 , 40 , 72 , 22 },
+{ 80 , 40 , 72 , 23 },
+{ 80 , 40 , 72 , 24 },
+{ 80 , 40 , 72 , 25 },
+{ 80 , 40 , 72 , 26 },
+{ 80 , 40 , 72 , 27 },
+{ 80 , 40 , 72 , 28 },
+{ 80 , 40 , 72 , 29 },
+{ 80 , 40 , 72 , 30 },
+{ 80 , 40 , 72 , 31 },
+{ 80 , 40 , 72 , 32 },
+{ 80 , 40 , 72 , 33 },
+{ 80 , 40 , 72 , 34 },
+{ 80 , 40 , 72 , 35 },
+{ 80 , 40 , 72 , 36 },
+{ 80 , 40 , 72 , 37 },
+{ 80 , 40 , 72 , 38 },
+{ 80 , 40 , 72 , 39 },
+{ 80 , 40 , 73 , 0 },
+{ 80 , 40 , 73 , 1 },
+{ 80 , 40 , 73 , 2 },
+{ 80 , 40 , 73 , 3 },
+{ 80 , 40 , 73 , 4 },
+{ 80 , 40 , 73 , 5 },
+{ 80 , 40 , 73 , 6 },
+{ 80 , 40 , 73 , 7 },
+{ 80 , 40 , 73 , 8 },
+{ 80 , 40 , 73 , 9 },
+{ 80 , 40 , 73 , 10 },
+{ 80 , 40 , 73 , 11 },
+{ 80 , 40 , 73 , 12 },
+{ 80 , 40 , 73 , 13 },
+{ 80 , 40 , 73 , 14 },
+{ 80 , 40 , 73 , 15 },
+{ 80 , 40 , 73 , 16 },
+{ 80 , 40 , 73 , 17 },
+{ 80 , 40 , 73 , 18 },
+{ 80 , 40 , 73 , 19 },
+{ 80 , 40 , 73 , 20 },
+{ 80 , 40 , 73 , 21 },
+{ 80 , 40 , 73 , 22 },
+{ 80 , 40 , 73 , 23 },
+{ 80 , 40 , 73 , 24 },
+{ 80 , 40 , 73 , 25 },
+{ 80 , 40 , 73 , 26 },
+{ 80 , 40 , 73 , 27 },
+{ 80 , 40 , 73 , 28 },
+{ 80 , 40 , 73 , 29 },
+{ 80 , 40 , 73 , 30 },
+{ 80 , 40 , 73 , 31 },
+{ 80 , 40 , 73 , 32 },
+{ 80 , 40 , 73 , 33 },
+{ 80 , 40 , 73 , 34 },
+{ 80 , 40 , 73 , 35 },
+{ 80 , 40 , 73 , 36 },
+{ 80 , 40 , 73 , 37 },
+{ 80 , 40 , 73 , 38 },
+{ 80 , 40 , 73 , 39 },
+{ 80 , 40 , 74 , 0 },
+{ 80 , 40 , 74 , 1 },
+{ 80 , 40 , 74 , 2 },
+{ 80 , 40 , 74 , 3 },
+{ 80 , 40 , 74 , 4 },
+{ 80 , 40 , 74 , 5 },
+{ 80 , 40 , 74 , 6 },
+{ 80 , 40 , 74 , 7 },
+{ 80 , 40 , 74 , 8 },
+{ 80 , 40 , 74 , 9 },
+{ 80 , 40 , 74 , 10 },
+{ 80 , 40 , 74 , 11 },
+{ 80 , 40 , 74 , 12 },
+{ 80 , 40 , 74 , 13 },
+{ 80 , 40 , 74 , 14 },
+{ 80 , 40 , 74 , 15 },
+{ 80 , 40 , 74 , 16 },
+{ 80 , 40 , 74 , 17 },
+{ 80 , 40 , 74 , 18 },
+{ 80 , 40 , 74 , 19 },
+{ 80 , 40 , 74 , 20 },
+{ 80 , 40 , 74 , 21 },
+{ 80 , 40 , 74 , 22 },
+{ 80 , 40 , 74 , 23 },
+{ 80 , 40 , 74 , 24 },
+{ 80 , 40 , 74 , 25 },
+{ 80 , 40 , 74 , 26 },
+{ 80 , 40 , 74 , 27 },
+{ 80 , 40 , 74 , 28 },
+{ 80 , 40 , 74 , 29 },
+{ 80 , 40 , 74 , 30 },
+{ 80 , 40 , 74 , 31 },
+{ 80 , 40 , 74 , 32 },
+{ 80 , 40 , 74 , 33 },
+{ 80 , 40 , 74 , 34 },
+{ 80 , 40 , 74 , 35 },
+{ 80 , 40 , 74 , 36 },
+{ 80 , 40 , 74 , 37 },
+{ 80 , 40 , 74 , 38 },
+{ 80 , 40 , 74 , 39 },
+{ 80 , 40 , 75 , 0 },
+{ 80 , 40 , 75 , 1 },
+{ 80 , 40 , 75 , 2 },
+{ 80 , 40 , 75 , 3 },
+{ 80 , 40 , 75 , 4 },
+{ 80 , 40 , 75 , 5 },
+{ 80 , 40 , 75 , 6 },
+{ 80 , 40 , 75 , 7 },
+{ 80 , 40 , 75 , 8 },
+{ 80 , 40 , 75 , 9 },
+{ 80 , 40 , 75 , 10 },
+{ 80 , 40 , 75 , 11 },
+{ 80 , 40 , 75 , 12 },
+{ 80 , 40 , 75 , 13 },
+{ 80 , 40 , 75 , 14 },
+{ 80 , 40 , 75 , 15 },
+{ 80 , 40 , 75 , 16 },
+{ 80 , 40 , 75 , 17 },
+{ 80 , 40 , 75 , 18 },
+{ 80 , 40 , 75 , 19 },
+{ 80 , 40 , 75 , 20 },
+{ 80 , 40 , 75 , 21 },
+{ 80 , 40 , 75 , 22 },
+{ 80 , 40 , 75 , 23 },
+{ 80 , 40 , 75 , 24 },
+{ 80 , 40 , 75 , 25 },
+{ 80 , 40 , 75 , 26 },
+{ 80 , 40 , 75 , 27 },
+{ 80 , 40 , 75 , 28 },
+{ 80 , 40 , 75 , 29 },
+{ 80 , 40 , 75 , 30 },
+{ 80 , 40 , 75 , 31 },
+{ 80 , 40 , 75 , 32 },
+{ 80 , 40 , 75 , 33 },
+{ 80 , 40 , 75 , 34 },
+{ 80 , 40 , 75 , 35 },
+{ 80 , 40 , 75 , 36 },
+{ 80 , 40 , 75 , 37 },
+{ 80 , 40 , 75 , 38 },
+{ 80 , 40 , 75 , 39 },
+{ 80 , 40 , 76 , 0 },
+{ 80 , 40 , 76 , 1 },
+{ 80 , 40 , 76 , 2 },
+{ 80 , 40 , 76 , 3 },
+{ 80 , 40 , 76 , 4 },
+{ 80 , 40 , 76 , 5 },
+{ 80 , 40 , 76 , 6 },
+{ 80 , 40 , 76 , 7 },
+{ 80 , 40 , 76 , 8 },
+{ 80 , 40 , 76 , 9 },
+{ 80 , 40 , 76 , 10 },
+{ 80 , 40 , 76 , 11 },
+{ 80 , 40 , 76 , 12 },
+{ 80 , 40 , 76 , 13 },
+{ 80 , 40 , 76 , 14 },
+{ 80 , 40 , 76 , 15 },
+{ 80 , 40 , 76 , 16 },
+{ 80 , 40 , 76 , 17 },
+{ 80 , 40 , 76 , 18 },
+{ 80 , 40 , 76 , 19 },
+{ 80 , 40 , 76 , 20 },
+{ 80 , 40 , 76 , 21 },
+{ 80 , 40 , 76 , 22 },
+{ 80 , 40 , 76 , 23 },
+{ 80 , 40 , 76 , 24 },
+{ 80 , 40 , 76 , 25 },
+{ 80 , 40 , 76 , 26 },
+{ 80 , 40 , 76 , 27 },
+{ 80 , 40 , 76 , 28 },
+{ 80 , 40 , 76 , 29 },
+{ 80 , 40 , 76 , 30 },
+{ 80 , 40 , 76 , 31 },
+{ 80 , 40 , 76 , 32 },
+{ 80 , 40 , 76 , 33 },
+{ 80 , 40 , 76 , 34 },
+{ 80 , 40 , 76 , 35 },
+{ 80 , 40 , 76 , 36 },
+{ 80 , 40 , 76 , 37 },
+{ 80 , 40 , 76 , 38 },
+{ 80 , 40 , 76 , 39 },
+{ 80 , 40 , 77 , 0 },
+{ 80 , 40 , 77 , 1 },
+{ 80 , 40 , 77 , 2 },
+{ 80 , 40 , 77 , 3 },
+{ 80 , 40 , 77 , 4 },
+{ 80 , 40 , 77 , 5 },
+{ 80 , 40 , 77 , 6 },
+{ 80 , 40 , 77 , 7 },
+{ 80 , 40 , 77 , 8 },
+{ 80 , 40 , 77 , 9 },
+{ 80 , 40 , 77 , 10 },
+{ 80 , 40 , 77 , 11 },
+{ 80 , 40 , 77 , 12 },
+{ 80 , 40 , 77 , 13 },
+{ 80 , 40 , 77 , 14 },
+{ 80 , 40 , 77 , 15 },
+{ 80 , 40 , 77 , 16 },
+{ 80 , 40 , 77 , 17 },
+{ 80 , 40 , 77 , 18 },
+{ 80 , 40 , 77 , 19 },
+{ 80 , 40 , 77 , 20 },
+{ 80 , 40 , 77 , 21 },
+{ 80 , 40 , 77 , 22 },
+{ 80 , 40 , 77 , 23 },
+{ 80 , 40 , 77 , 24 },
+{ 80 , 40 , 77 , 25 },
+{ 80 , 40 , 77 , 26 },
+{ 80 , 40 , 77 , 27 },
+{ 80 , 40 , 77 , 28 },
+{ 80 , 40 , 77 , 29 },
+{ 80 , 40 , 77 , 30 },
+{ 80 , 40 , 77 , 31 },
+{ 80 , 40 , 77 , 32 },
+{ 80 , 40 , 77 , 33 },
+{ 80 , 40 , 77 , 34 },
+{ 80 , 40 , 77 , 35 },
+{ 80 , 40 , 77 , 36 },
+{ 80 , 40 , 77 , 37 },
+{ 80 , 40 , 77 , 38 },
+{ 80 , 40 , 77 , 39 },
+{ 80 , 40 , 78 , 0 },
+{ 80 , 40 , 78 , 1 },
+{ 80 , 40 , 78 , 2 },
+{ 80 , 40 , 78 , 3 },
+{ 80 , 40 , 78 , 4 },
+{ 80 , 40 , 78 , 5 },
+{ 80 , 40 , 78 , 6 },
+{ 80 , 40 , 78 , 7 },
+{ 80 , 40 , 78 , 8 },
+{ 80 , 40 , 78 , 9 },
+{ 80 , 40 , 78 , 10 },
+{ 80 , 40 , 78 , 11 },
+{ 80 , 40 , 78 , 12 },
+{ 80 , 40 , 78 , 13 },
+{ 80 , 40 , 78 , 14 },
+{ 80 , 40 , 78 , 15 },
+{ 80 , 40 , 78 , 16 },
+{ 80 , 40 , 78 , 17 },
+{ 80 , 40 , 78 , 18 },
+{ 80 , 40 , 78 , 19 },
+{ 80 , 40 , 78 , 20 },
+{ 80 , 40 , 78 , 21 },
+{ 80 , 40 , 78 , 22 },
+{ 80 , 40 , 78 , 23 },
+{ 80 , 40 , 78 , 24 },
+{ 80 , 40 , 78 , 25 },
+{ 80 , 40 , 78 , 26 },
+{ 80 , 40 , 78 , 27 },
+{ 80 , 40 , 78 , 28 },
+{ 80 , 40 , 78 , 29 },
+{ 80 , 40 , 78 , 30 },
+{ 80 , 40 , 78 , 31 },
+{ 80 , 40 , 78 , 32 },
+{ 80 , 40 , 78 , 33 },
+{ 80 , 40 , 78 , 34 },
+{ 80 , 40 , 78 , 35 },
+{ 80 , 40 , 78 , 36 },
+{ 80 , 40 , 78 , 37 },
+{ 80 , 40 , 78 , 38 },
+{ 80 , 40 , 78 , 39 },
+{ 80 , 40 , 79 , 0 },
+{ 80 , 40 , 79 , 1 },
+{ 80 , 40 , 79 , 2 },
+{ 80 , 40 , 79 , 3 },
+{ 80 , 40 , 79 , 4 },
+{ 80 , 40 , 79 , 5 },
+{ 80 , 40 , 79 , 6 },
+{ 80 , 40 , 79 , 7 },
+{ 80 , 40 , 79 , 8 },
+{ 80 , 40 , 79 , 9 },
+{ 80 , 40 , 79 , 10 },
+{ 80 , 40 , 79 , 11 },
+{ 80 , 40 , 79 , 12 },
+{ 80 , 40 , 79 , 13 },
+{ 80 , 40 , 79 , 14 },
+{ 80 , 40 , 79 , 15 },
+{ 80 , 40 , 79 , 16 },
+{ 80 , 40 , 79 , 17 },
+{ 80 , 40 , 79 , 18 },
+{ 80 , 40 , 79 , 19 },
+{ 80 , 40 , 79 , 20 },
+{ 80 , 40 , 79 , 21 },
+{ 80 , 40 , 79 , 22 },
+{ 80 , 40 , 79 , 23 },
+{ 80 , 40 , 79 , 24 },
+{ 80 , 40 , 79 , 25 },
+{ 80 , 40 , 79 , 26 },
+{ 80 , 40 , 79 , 27 },
+{ 80 , 40 , 79 , 28 },
+{ 80 , 40 , 79 , 29 },
+{ 80 , 40 , 79 , 30 },
+{ 80 , 40 , 79 , 31 },
+{ 80 , 40 , 79 , 32 },
+{ 80 , 40 , 79 , 33 },
+{ 80 , 40 , 79 , 34 },
+{ 80 , 40 , 79 , 35 },
+{ 80 , 40 , 79 , 36 },
+{ 80 , 40 , 79 , 37 },
+{ 80 , 40 , 79 , 38 },
+{ 80 , 40 , 79 , 39 },
+{ 80 , 80 , 0 , 0 },
+{ 80 , 80 , 0 , 1 },
+{ 80 , 80 , 0 , 2 },
+{ 80 , 80 , 0 , 3 },
+{ 80 , 80 , 0 , 4 },
+{ 80 , 80 , 0 , 5 },
+{ 80 , 80 , 0 , 6 },
+{ 80 , 80 , 0 , 7 },
+{ 80 , 80 , 0 , 8 },
+{ 80 , 80 , 0 , 9 },
+{ 80 , 80 , 0 , 10 },
+{ 80 , 80 , 0 , 11 },
+{ 80 , 80 , 0 , 12 },
+{ 80 , 80 , 0 , 13 },
+{ 80 , 80 , 0 , 14 },
+{ 80 , 80 , 0 , 15 },
+{ 80 , 80 , 0 , 16 },
+{ 80 , 80 , 0 , 17 },
+{ 80 , 80 , 0 , 18 },
+{ 80 , 80 , 0 , 19 },
+{ 80 , 80 , 0 , 20 },
+{ 80 , 80 , 0 , 21 },
+{ 80 , 80 , 0 , 22 },
+{ 80 , 80 , 0 , 23 },
+{ 80 , 80 , 0 , 24 },
+{ 80 , 80 , 0 , 25 },
+{ 80 , 80 , 0 , 26 },
+{ 80 , 80 , 0 , 27 },
+{ 80 , 80 , 0 , 28 },
+{ 80 , 80 , 0 , 29 },
+{ 80 , 80 , 0 , 30 },
+{ 80 , 80 , 0 , 31 },
+{ 80 , 80 , 0 , 32 },
+{ 80 , 80 , 0 , 33 },
+{ 80 , 80 , 0 , 34 },
+{ 80 , 80 , 0 , 35 },
+{ 80 , 80 , 0 , 36 },
+{ 80 , 80 , 0 , 37 },
+{ 80 , 80 , 0 , 38 },
+{ 80 , 80 , 0 , 39 },
+{ 80 , 80 , 0 , 40 },
+{ 80 , 80 , 0 , 41 },
+{ 80 , 80 , 0 , 42 },
+{ 80 , 80 , 0 , 43 },
+{ 80 , 80 , 0 , 44 },
+{ 80 , 80 , 0 , 45 },
+{ 80 , 80 , 0 , 46 },
+{ 80 , 80 , 0 , 47 },
+{ 80 , 80 , 0 , 48 },
+{ 80 , 80 , 0 , 49 },
+{ 80 , 80 , 0 , 50 },
+{ 80 , 80 , 0 , 51 },
+{ 80 , 80 , 0 , 52 },
+{ 80 , 80 , 0 , 53 },
+{ 80 , 80 , 0 , 54 },
+{ 80 , 80 , 0 , 55 },
+{ 80 , 80 , 0 , 56 },
+{ 80 , 80 , 0 , 57 },
+{ 80 , 80 , 0 , 58 },
+{ 80 , 80 , 0 , 59 },
+{ 80 , 80 , 0 , 60 },
+{ 80 , 80 , 0 , 61 },
+{ 80 , 80 , 0 , 62 },
+{ 80 , 80 , 0 , 63 },
+{ 80 , 80 , 0 , 64 },
+{ 80 , 80 , 0 , 65 },
+{ 80 , 80 , 0 , 66 },
+{ 80 , 80 , 0 , 67 },
+{ 80 , 80 , 0 , 68 },
+{ 80 , 80 , 0 , 69 },
+{ 80 , 80 , 0 , 70 },
+{ 80 , 80 , 0 , 71 },
+{ 80 , 80 , 0 , 72 },
+{ 80 , 80 , 0 , 73 },
+{ 80 , 80 , 0 , 74 },
+{ 80 , 80 , 0 , 75 },
+{ 80 , 80 , 0 , 76 },
+{ 80 , 80 , 0 , 77 },
+{ 80 , 80 , 0 , 78 },
+{ 80 , 80 , 0 , 79 },
+{ 80 , 80 , 1 , 0 },
+{ 80 , 80 , 1 , 1 },
+{ 80 , 80 , 1 , 2 },
+{ 80 , 80 , 1 , 3 },
+{ 80 , 80 , 1 , 4 },
+{ 80 , 80 , 1 , 5 },
+{ 80 , 80 , 1 , 6 },
+{ 80 , 80 , 1 , 7 },
+{ 80 , 80 , 1 , 8 },
+{ 80 , 80 , 1 , 9 },
+{ 80 , 80 , 1 , 10 },
+{ 80 , 80 , 1 , 11 },
+{ 80 , 80 , 1 , 12 },
+{ 80 , 80 , 1 , 13 },
+{ 80 , 80 , 1 , 14 },
+{ 80 , 80 , 1 , 15 },
+{ 80 , 80 , 1 , 16 },
+{ 80 , 80 , 1 , 17 },
+{ 80 , 80 , 1 , 18 },
+{ 80 , 80 , 1 , 19 },
+{ 80 , 80 , 1 , 20 },
+{ 80 , 80 , 1 , 21 },
+{ 80 , 80 , 1 , 22 },
+{ 80 , 80 , 1 , 23 },
+{ 80 , 80 , 1 , 24 },
+{ 80 , 80 , 1 , 25 },
+{ 80 , 80 , 1 , 26 },
+{ 80 , 80 , 1 , 27 },
+{ 80 , 80 , 1 , 28 },
+{ 80 , 80 , 1 , 29 },
+{ 80 , 80 , 1 , 30 },
+{ 80 , 80 , 1 , 31 },
+{ 80 , 80 , 1 , 32 },
+{ 80 , 80 , 1 , 33 },
+{ 80 , 80 , 1 , 34 },
+{ 80 , 80 , 1 , 35 },
+{ 80 , 80 , 1 , 36 },
+{ 80 , 80 , 1 , 37 },
+{ 80 , 80 , 1 , 38 },
+{ 80 , 80 , 1 , 39 },
+{ 80 , 80 , 1 , 40 },
+{ 80 , 80 , 1 , 41 },
+{ 80 , 80 , 1 , 42 },
+{ 80 , 80 , 1 , 43 },
+{ 80 , 80 , 1 , 44 },
+{ 80 , 80 , 1 , 45 },
+{ 80 , 80 , 1 , 46 },
+{ 80 , 80 , 1 , 47 },
+{ 80 , 80 , 1 , 48 },
+{ 80 , 80 , 1 , 49 },
+{ 80 , 80 , 1 , 50 },
+{ 80 , 80 , 1 , 51 },
+{ 80 , 80 , 1 , 52 },
+{ 80 , 80 , 1 , 53 },
+{ 80 , 80 , 1 , 54 },
+{ 80 , 80 , 1 , 55 },
+{ 80 , 80 , 1 , 56 },
+{ 80 , 80 , 1 , 57 },
+{ 80 , 80 , 1 , 58 },
+{ 80 , 80 , 1 , 59 },
+{ 80 , 80 , 1 , 60 },
+{ 80 , 80 , 1 , 61 },
+{ 80 , 80 , 1 , 62 },
+{ 80 , 80 , 1 , 63 },
+{ 80 , 80 , 1 , 64 },
+{ 80 , 80 , 1 , 65 },
+{ 80 , 80 , 1 , 66 },
+{ 80 , 80 , 1 , 67 },
+{ 80 , 80 , 1 , 68 },
+{ 80 , 80 , 1 , 69 },
+{ 80 , 80 , 1 , 70 },
+{ 80 , 80 , 1 , 71 },
+{ 80 , 80 , 1 , 72 },
+{ 80 , 80 , 1 , 73 },
+{ 80 , 80 , 1 , 74 },
+{ 80 , 80 , 1 , 75 },
+{ 80 , 80 , 1 , 76 },
+{ 80 , 80 , 1 , 77 },
+{ 80 , 80 , 1 , 78 },
+{ 80 , 80 , 1 , 79 },
+{ 80 , 80 , 2 , 0 },
+{ 80 , 80 , 2 , 1 },
+{ 80 , 80 , 2 , 2 },
+{ 80 , 80 , 2 , 3 },
+{ 80 , 80 , 2 , 4 },
+{ 80 , 80 , 2 , 5 },
+{ 80 , 80 , 2 , 6 },
+{ 80 , 80 , 2 , 7 },
+{ 80 , 80 , 2 , 8 },
+{ 80 , 80 , 2 , 9 },
+{ 80 , 80 , 2 , 10 },
+{ 80 , 80 , 2 , 11 },
+{ 80 , 80 , 2 , 12 },
+{ 80 , 80 , 2 , 13 },
+{ 80 , 80 , 2 , 14 },
+{ 80 , 80 , 2 , 15 },
+{ 80 , 80 , 2 , 16 },
+{ 80 , 80 , 2 , 17 },
+{ 80 , 80 , 2 , 18 },
+{ 80 , 80 , 2 , 19 },
+{ 80 , 80 , 2 , 20 },
+{ 80 , 80 , 2 , 21 },
+{ 80 , 80 , 2 , 22 },
+{ 80 , 80 , 2 , 23 },
+{ 80 , 80 , 2 , 24 },
+{ 80 , 80 , 2 , 25 },
+{ 80 , 80 , 2 , 26 },
+{ 80 , 80 , 2 , 27 },
+{ 80 , 80 , 2 , 28 },
+{ 80 , 80 , 2 , 29 },
+{ 80 , 80 , 2 , 30 },
+{ 80 , 80 , 2 , 31 },
+{ 80 , 80 , 2 , 32 },
+{ 80 , 80 , 2 , 33 },
+{ 80 , 80 , 2 , 34 },
+{ 80 , 80 , 2 , 35 },
+{ 80 , 80 , 2 , 36 },
+{ 80 , 80 , 2 , 37 },
+{ 80 , 80 , 2 , 38 },
+{ 80 , 80 , 2 , 39 },
+{ 80 , 80 , 2 , 40 },
+{ 80 , 80 , 2 , 41 },
+{ 80 , 80 , 2 , 42 },
+{ 80 , 80 , 2 , 43 },
+{ 80 , 80 , 2 , 44 },
+{ 80 , 80 , 2 , 45 },
+{ 80 , 80 , 2 , 46 },
+{ 80 , 80 , 2 , 47 },
+{ 80 , 80 , 2 , 48 },
+{ 80 , 80 , 2 , 49 },
+{ 80 , 80 , 2 , 50 },
+{ 80 , 80 , 2 , 51 },
+{ 80 , 80 , 2 , 52 },
+{ 80 , 80 , 2 , 53 },
+{ 80 , 80 , 2 , 54 },
+{ 80 , 80 , 2 , 55 },
+{ 80 , 80 , 2 , 56 },
+{ 80 , 80 , 2 , 57 },
+{ 80 , 80 , 2 , 58 },
+{ 80 , 80 , 2 , 59 },
+{ 80 , 80 , 2 , 60 },
+{ 80 , 80 , 2 , 61 },
+{ 80 , 80 , 2 , 62 },
+{ 80 , 80 , 2 , 63 },
+{ 80 , 80 , 2 , 64 },
+{ 80 , 80 , 2 , 65 },
+{ 80 , 80 , 2 , 66 },
+{ 80 , 80 , 2 , 67 },
+{ 80 , 80 , 2 , 68 },
+{ 80 , 80 , 2 , 69 },
+{ 80 , 80 , 2 , 70 },
+{ 80 , 80 , 2 , 71 },
+{ 80 , 80 , 2 , 72 },
+{ 80 , 80 , 2 , 73 },
+{ 80 , 80 , 2 , 74 },
+{ 80 , 80 , 2 , 75 },
+{ 80 , 80 , 2 , 76 },
+{ 80 , 80 , 2 , 77 },
+{ 80 , 80 , 2 , 78 },
+{ 80 , 80 , 2 , 79 },
+{ 80 , 80 , 3 , 0 },
+{ 80 , 80 , 3 , 1 },
+{ 80 , 80 , 3 , 2 },
+{ 80 , 80 , 3 , 3 },
+{ 80 , 80 , 3 , 4 },
+{ 80 , 80 , 3 , 5 },
+{ 80 , 80 , 3 , 6 },
+{ 80 , 80 , 3 , 7 },
+{ 80 , 80 , 3 , 8 },
+{ 80 , 80 , 3 , 9 },
+{ 80 , 80 , 3 , 10 },
+{ 80 , 80 , 3 , 11 },
+{ 80 , 80 , 3 , 12 },
+{ 80 , 80 , 3 , 13 },
+{ 80 , 80 , 3 , 14 },
+{ 80 , 80 , 3 , 15 },
+{ 80 , 80 , 3 , 16 },
+{ 80 , 80 , 3 , 17 },
+{ 80 , 80 , 3 , 18 },
+{ 80 , 80 , 3 , 19 },
+{ 80 , 80 , 3 , 20 },
+{ 80 , 80 , 3 , 21 },
+{ 80 , 80 , 3 , 22 },
+{ 80 , 80 , 3 , 23 },
+{ 80 , 80 , 3 , 24 },
+{ 80 , 80 , 3 , 25 },
+{ 80 , 80 , 3 , 26 },
+{ 80 , 80 , 3 , 27 },
+{ 80 , 80 , 3 , 28 },
+{ 80 , 80 , 3 , 29 },
+{ 80 , 80 , 3 , 30 },
+{ 80 , 80 , 3 , 31 },
+{ 80 , 80 , 3 , 32 },
+{ 80 , 80 , 3 , 33 },
+{ 80 , 80 , 3 , 34 },
+{ 80 , 80 , 3 , 35 },
+{ 80 , 80 , 3 , 36 },
+{ 80 , 80 , 3 , 37 },
+{ 80 , 80 , 3 , 38 },
+{ 80 , 80 , 3 , 39 },
+{ 80 , 80 , 3 , 40 },
+{ 80 , 80 , 3 , 41 },
+{ 80 , 80 , 3 , 42 },
+{ 80 , 80 , 3 , 43 },
+{ 80 , 80 , 3 , 44 },
+{ 80 , 80 , 3 , 45 },
+{ 80 , 80 , 3 , 46 },
+{ 80 , 80 , 3 , 47 },
+{ 80 , 80 , 3 , 48 },
+{ 80 , 80 , 3 , 49 },
+{ 80 , 80 , 3 , 50 },
+{ 80 , 80 , 3 , 51 },
+{ 80 , 80 , 3 , 52 },
+{ 80 , 80 , 3 , 53 },
+{ 80 , 80 , 3 , 54 },
+{ 80 , 80 , 3 , 55 },
+{ 80 , 80 , 3 , 56 },
+{ 80 , 80 , 3 , 57 },
+{ 80 , 80 , 3 , 58 },
+{ 80 , 80 , 3 , 59 },
+{ 80 , 80 , 3 , 60 },
+{ 80 , 80 , 3 , 61 },
+{ 80 , 80 , 3 , 62 },
+{ 80 , 80 , 3 , 63 },
+{ 80 , 80 , 3 , 64 },
+{ 80 , 80 , 3 , 65 },
+{ 80 , 80 , 3 , 66 },
+{ 80 , 80 , 3 , 67 },
+{ 80 , 80 , 3 , 68 },
+{ 80 , 80 , 3 , 69 },
+{ 80 , 80 , 3 , 70 },
+{ 80 , 80 , 3 , 71 },
+{ 80 , 80 , 3 , 72 },
+{ 80 , 80 , 3 , 73 },
+{ 80 , 80 , 3 , 74 },
+{ 80 , 80 , 3 , 75 },
+{ 80 , 80 , 3 , 76 },
+{ 80 , 80 , 3 , 77 },
+{ 80 , 80 , 3 , 78 },
+{ 80 , 80 , 3 , 79 },
+{ 80 , 80 , 4 , 0 },
+{ 80 , 80 , 4 , 1 },
+{ 80 , 80 , 4 , 2 },
+{ 80 , 80 , 4 , 3 },
+{ 80 , 80 , 4 , 4 },
+{ 80 , 80 , 4 , 5 },
+{ 80 , 80 , 4 , 6 },
+{ 80 , 80 , 4 , 7 },
+{ 80 , 80 , 4 , 8 },
+{ 80 , 80 , 4 , 9 },
+{ 80 , 80 , 4 , 10 },
+{ 80 , 80 , 4 , 11 },
+{ 80 , 80 , 4 , 12 },
+{ 80 , 80 , 4 , 13 },
+{ 80 , 80 , 4 , 14 },
+{ 80 , 80 , 4 , 15 },
+{ 80 , 80 , 4 , 16 },
+{ 80 , 80 , 4 , 17 },
+{ 80 , 80 , 4 , 18 },
+{ 80 , 80 , 4 , 19 },
+{ 80 , 80 , 4 , 20 },
+{ 80 , 80 , 4 , 21 },
+{ 80 , 80 , 4 , 22 },
+{ 80 , 80 , 4 , 23 },
+{ 80 , 80 , 4 , 24 },
+{ 80 , 80 , 4 , 25 },
+{ 80 , 80 , 4 , 26 },
+{ 80 , 80 , 4 , 27 },
+{ 80 , 80 , 4 , 28 },
+{ 80 , 80 , 4 , 29 },
+{ 80 , 80 , 4 , 30 },
+{ 80 , 80 , 4 , 31 },
+{ 80 , 80 , 4 , 32 },
+{ 80 , 80 , 4 , 33 },
+{ 80 , 80 , 4 , 34 },
+{ 80 , 80 , 4 , 35 },
+{ 80 , 80 , 4 , 36 },
+{ 80 , 80 , 4 , 37 },
+{ 80 , 80 , 4 , 38 },
+{ 80 , 80 , 4 , 39 },
+{ 80 , 80 , 4 , 40 },
+{ 80 , 80 , 4 , 41 },
+{ 80 , 80 , 4 , 42 },
+{ 80 , 80 , 4 , 43 },
+{ 80 , 80 , 4 , 44 },
+{ 80 , 80 , 4 , 45 },
+{ 80 , 80 , 4 , 46 },
+{ 80 , 80 , 4 , 47 },
+{ 80 , 80 , 4 , 48 },
+{ 80 , 80 , 4 , 49 },
+{ 80 , 80 , 4 , 50 },
+{ 80 , 80 , 4 , 51 },
+{ 80 , 80 , 4 , 52 },
+{ 80 , 80 , 4 , 53 },
+{ 80 , 80 , 4 , 54 },
+{ 80 , 80 , 4 , 55 },
+{ 80 , 80 , 4 , 56 },
+{ 80 , 80 , 4 , 57 },
+{ 80 , 80 , 4 , 58 },
+{ 80 , 80 , 4 , 59 },
+{ 80 , 80 , 4 , 60 },
+{ 80 , 80 , 4 , 61 },
+{ 80 , 80 , 4 , 62 },
+{ 80 , 80 , 4 , 63 },
+{ 80 , 80 , 4 , 64 },
+{ 80 , 80 , 4 , 65 },
+{ 80 , 80 , 4 , 66 },
+{ 80 , 80 , 4 , 67 },
+{ 80 , 80 , 4 , 68 },
+{ 80 , 80 , 4 , 69 },
+{ 80 , 80 , 4 , 70 },
+{ 80 , 80 , 4 , 71 },
+{ 80 , 80 , 4 , 72 },
+{ 80 , 80 , 4 , 73 },
+{ 80 , 80 , 4 , 74 },
+{ 80 , 80 , 4 , 75 },
+{ 80 , 80 , 4 , 76 },
+{ 80 , 80 , 4 , 77 },
+{ 80 , 80 , 4 , 78 },
+{ 80 , 80 , 4 , 79 },
+{ 80 , 80 , 5 , 0 },
+{ 80 , 80 , 5 , 1 },
+{ 80 , 80 , 5 , 2 },
+{ 80 , 80 , 5 , 3 },
+{ 80 , 80 , 5 , 4 },
+{ 80 , 80 , 5 , 5 },
+{ 80 , 80 , 5 , 6 },
+{ 80 , 80 , 5 , 7 },
+{ 80 , 80 , 5 , 8 },
+{ 80 , 80 , 5 , 9 },
+{ 80 , 80 , 5 , 10 },
+{ 80 , 80 , 5 , 11 },
+{ 80 , 80 , 5 , 12 },
+{ 80 , 80 , 5 , 13 },
+{ 80 , 80 , 5 , 14 },
+{ 80 , 80 , 5 , 15 },
+{ 80 , 80 , 5 , 16 },
+{ 80 , 80 , 5 , 17 },
+{ 80 , 80 , 5 , 18 },
+{ 80 , 80 , 5 , 19 },
+{ 80 , 80 , 5 , 20 },
+{ 80 , 80 , 5 , 21 },
+{ 80 , 80 , 5 , 22 },
+{ 80 , 80 , 5 , 23 },
+{ 80 , 80 , 5 , 24 },
+{ 80 , 80 , 5 , 25 },
+{ 80 , 80 , 5 , 26 },
+{ 80 , 80 , 5 , 27 },
+{ 80 , 80 , 5 , 28 },
+{ 80 , 80 , 5 , 29 },
+{ 80 , 80 , 5 , 30 },
+{ 80 , 80 , 5 , 31 },
+{ 80 , 80 , 5 , 32 },
+{ 80 , 80 , 5 , 33 },
+{ 80 , 80 , 5 , 34 },
+{ 80 , 80 , 5 , 35 },
+{ 80 , 80 , 5 , 36 },
+{ 80 , 80 , 5 , 37 },
+{ 80 , 80 , 5 , 38 },
+{ 80 , 80 , 5 , 39 },
+{ 80 , 80 , 5 , 40 },
+{ 80 , 80 , 5 , 41 },
+{ 80 , 80 , 5 , 42 },
+{ 80 , 80 , 5 , 43 },
+{ 80 , 80 , 5 , 44 },
+{ 80 , 80 , 5 , 45 },
+{ 80 , 80 , 5 , 46 },
+{ 80 , 80 , 5 , 47 },
+{ 80 , 80 , 5 , 48 },
+{ 80 , 80 , 5 , 49 },
+{ 80 , 80 , 5 , 50 },
+{ 80 , 80 , 5 , 51 },
+{ 80 , 80 , 5 , 52 },
+{ 80 , 80 , 5 , 53 },
+{ 80 , 80 , 5 , 54 },
+{ 80 , 80 , 5 , 55 },
+{ 80 , 80 , 5 , 56 },
+{ 80 , 80 , 5 , 57 },
+{ 80 , 80 , 5 , 58 },
+{ 80 , 80 , 5 , 59 },
+{ 80 , 80 , 5 , 60 },
+{ 80 , 80 , 5 , 61 },
+{ 80 , 80 , 5 , 62 },
+{ 80 , 80 , 5 , 63 },
+{ 80 , 80 , 5 , 64 },
+{ 80 , 80 , 5 , 65 },
+{ 80 , 80 , 5 , 66 },
+{ 80 , 80 , 5 , 67 },
+{ 80 , 80 , 5 , 68 },
+{ 80 , 80 , 5 , 69 },
+{ 80 , 80 , 5 , 70 },
+{ 80 , 80 , 5 , 71 },
+{ 80 , 80 , 5 , 72 },
+{ 80 , 80 , 5 , 73 },
+{ 80 , 80 , 5 , 74 },
+{ 80 , 80 , 5 , 75 },
+{ 80 , 80 , 5 , 76 },
+{ 80 , 80 , 5 , 77 },
+{ 80 , 80 , 5 , 78 },
+{ 80 , 80 , 5 , 79 },
+{ 80 , 80 , 6 , 0 },
+{ 80 , 80 , 6 , 1 },
+{ 80 , 80 , 6 , 2 },
+{ 80 , 80 , 6 , 3 },
+{ 80 , 80 , 6 , 4 },
+{ 80 , 80 , 6 , 5 },
+{ 80 , 80 , 6 , 6 },
+{ 80 , 80 , 6 , 7 },
+{ 80 , 80 , 6 , 8 },
+{ 80 , 80 , 6 , 9 },
+{ 80 , 80 , 6 , 10 },
+{ 80 , 80 , 6 , 11 },
+{ 80 , 80 , 6 , 12 },
+{ 80 , 80 , 6 , 13 },
+{ 80 , 80 , 6 , 14 },
+{ 80 , 80 , 6 , 15 },
+{ 80 , 80 , 6 , 16 },
+{ 80 , 80 , 6 , 17 },
+{ 80 , 80 , 6 , 18 },
+{ 80 , 80 , 6 , 19 },
+{ 80 , 80 , 6 , 20 },
+{ 80 , 80 , 6 , 21 },
+{ 80 , 80 , 6 , 22 },
+{ 80 , 80 , 6 , 23 },
+{ 80 , 80 , 6 , 24 },
+{ 80 , 80 , 6 , 25 },
+{ 80 , 80 , 6 , 26 },
+{ 80 , 80 , 6 , 27 },
+{ 80 , 80 , 6 , 28 },
+{ 80 , 80 , 6 , 29 },
+{ 80 , 80 , 6 , 30 },
+{ 80 , 80 , 6 , 31 },
+{ 80 , 80 , 6 , 32 },
+{ 80 , 80 , 6 , 33 },
+{ 80 , 80 , 6 , 34 },
+{ 80 , 80 , 6 , 35 },
+{ 80 , 80 , 6 , 36 },
+{ 80 , 80 , 6 , 37 },
+{ 80 , 80 , 6 , 38 },
+{ 80 , 80 , 6 , 39 },
+{ 80 , 80 , 6 , 40 },
+{ 80 , 80 , 6 , 41 },
+{ 80 , 80 , 6 , 42 },
+{ 80 , 80 , 6 , 43 },
+{ 80 , 80 , 6 , 44 },
+{ 80 , 80 , 6 , 45 },
+{ 80 , 80 , 6 , 46 },
+{ 80 , 80 , 6 , 47 },
+{ 80 , 80 , 6 , 48 },
+{ 80 , 80 , 6 , 49 },
+{ 80 , 80 , 6 , 50 },
+{ 80 , 80 , 6 , 51 },
+{ 80 , 80 , 6 , 52 },
+{ 80 , 80 , 6 , 53 },
+{ 80 , 80 , 6 , 54 },
+{ 80 , 80 , 6 , 55 },
+{ 80 , 80 , 6 , 56 },
+{ 80 , 80 , 6 , 57 },
+{ 80 , 80 , 6 , 58 },
+{ 80 , 80 , 6 , 59 },
+{ 80 , 80 , 6 , 60 },
+{ 80 , 80 , 6 , 61 },
+{ 80 , 80 , 6 , 62 },
+{ 80 , 80 , 6 , 63 },
+{ 80 , 80 , 6 , 64 },
+{ 80 , 80 , 6 , 65 },
+{ 80 , 80 , 6 , 66 },
+{ 80 , 80 , 6 , 67 },
+{ 80 , 80 , 6 , 68 },
+{ 80 , 80 , 6 , 69 },
+{ 80 , 80 , 6 , 70 },
+{ 80 , 80 , 6 , 71 },
+{ 80 , 80 , 6 , 72 },
+{ 80 , 80 , 6 , 73 },
+{ 80 , 80 , 6 , 74 },
+{ 80 , 80 , 6 , 75 },
+{ 80 , 80 , 6 , 76 },
+{ 80 , 80 , 6 , 77 },
+{ 80 , 80 , 6 , 78 },
+{ 80 , 80 , 6 , 79 },
+{ 80 , 80 , 7 , 0 },
+{ 80 , 80 , 7 , 1 },
+{ 80 , 80 , 7 , 2 },
+{ 80 , 80 , 7 , 3 },
+{ 80 , 80 , 7 , 4 },
+{ 80 , 80 , 7 , 5 },
+{ 80 , 80 , 7 , 6 },
+{ 80 , 80 , 7 , 7 },
+{ 80 , 80 , 7 , 8 },
+{ 80 , 80 , 7 , 9 },
+{ 80 , 80 , 7 , 10 },
+{ 80 , 80 , 7 , 11 },
+{ 80 , 80 , 7 , 12 },
+{ 80 , 80 , 7 , 13 },
+{ 80 , 80 , 7 , 14 },
+{ 80 , 80 , 7 , 15 },
+{ 80 , 80 , 7 , 16 },
+{ 80 , 80 , 7 , 17 },
+{ 80 , 80 , 7 , 18 },
+{ 80 , 80 , 7 , 19 },
+{ 80 , 80 , 7 , 20 },
+{ 80 , 80 , 7 , 21 },
+{ 80 , 80 , 7 , 22 },
+{ 80 , 80 , 7 , 23 },
+{ 80 , 80 , 7 , 24 },
+{ 80 , 80 , 7 , 25 },
+{ 80 , 80 , 7 , 26 },
+{ 80 , 80 , 7 , 27 },
+{ 80 , 80 , 7 , 28 },
+{ 80 , 80 , 7 , 29 },
+{ 80 , 80 , 7 , 30 },
+{ 80 , 80 , 7 , 31 },
+{ 80 , 80 , 7 , 32 },
+{ 80 , 80 , 7 , 33 },
+{ 80 , 80 , 7 , 34 },
+{ 80 , 80 , 7 , 35 },
+{ 80 , 80 , 7 , 36 },
+{ 80 , 80 , 7 , 37 },
+{ 80 , 80 , 7 , 38 },
+{ 80 , 80 , 7 , 39 },
+{ 80 , 80 , 7 , 40 },
+{ 80 , 80 , 7 , 41 },
+{ 80 , 80 , 7 , 42 },
+{ 80 , 80 , 7 , 43 },
+{ 80 , 80 , 7 , 44 },
+{ 80 , 80 , 7 , 45 },
+{ 80 , 80 , 7 , 46 },
+{ 80 , 80 , 7 , 47 },
+{ 80 , 80 , 7 , 48 },
+{ 80 , 80 , 7 , 49 },
+{ 80 , 80 , 7 , 50 },
+{ 80 , 80 , 7 , 51 },
+{ 80 , 80 , 7 , 52 },
+{ 80 , 80 , 7 , 53 },
+{ 80 , 80 , 7 , 54 },
+{ 80 , 80 , 7 , 55 },
+{ 80 , 80 , 7 , 56 },
+{ 80 , 80 , 7 , 57 },
+{ 80 , 80 , 7 , 58 },
+{ 80 , 80 , 7 , 59 },
+{ 80 , 80 , 7 , 60 },
+{ 80 , 80 , 7 , 61 },
+{ 80 , 80 , 7 , 62 },
+{ 80 , 80 , 7 , 63 },
+{ 80 , 80 , 7 , 64 },
+{ 80 , 80 , 7 , 65 },
+{ 80 , 80 , 7 , 66 },
+{ 80 , 80 , 7 , 67 },
+{ 80 , 80 , 7 , 68 },
+{ 80 , 80 , 7 , 69 },
+{ 80 , 80 , 7 , 70 },
+{ 80 , 80 , 7 , 71 },
+{ 80 , 80 , 7 , 72 },
+{ 80 , 80 , 7 , 73 },
+{ 80 , 80 , 7 , 74 },
+{ 80 , 80 , 7 , 75 },
+{ 80 , 80 , 7 , 76 },
+{ 80 , 80 , 7 , 77 },
+{ 80 , 80 , 7 , 78 },
+{ 80 , 80 , 7 , 79 },
+{ 80 , 80 , 8 , 0 },
+{ 80 , 80 , 8 , 1 },
+{ 80 , 80 , 8 , 2 },
+{ 80 , 80 , 8 , 3 },
+{ 80 , 80 , 8 , 4 },
+{ 80 , 80 , 8 , 5 },
+{ 80 , 80 , 8 , 6 },
+{ 80 , 80 , 8 , 7 },
+{ 80 , 80 , 8 , 8 },
+{ 80 , 80 , 8 , 9 },
+{ 80 , 80 , 8 , 10 },
+{ 80 , 80 , 8 , 11 },
+{ 80 , 80 , 8 , 12 },
+{ 80 , 80 , 8 , 13 },
+{ 80 , 80 , 8 , 14 },
+{ 80 , 80 , 8 , 15 },
+{ 80 , 80 , 8 , 16 },
+{ 80 , 80 , 8 , 17 },
+{ 80 , 80 , 8 , 18 },
+{ 80 , 80 , 8 , 19 },
+{ 80 , 80 , 8 , 20 },
+{ 80 , 80 , 8 , 21 },
+{ 80 , 80 , 8 , 22 },
+{ 80 , 80 , 8 , 23 },
+{ 80 , 80 , 8 , 24 },
+{ 80 , 80 , 8 , 25 },
+{ 80 , 80 , 8 , 26 },
+{ 80 , 80 , 8 , 27 },
+{ 80 , 80 , 8 , 28 },
+{ 80 , 80 , 8 , 29 },
+{ 80 , 80 , 8 , 30 },
+{ 80 , 80 , 8 , 31 },
+{ 80 , 80 , 8 , 32 },
+{ 80 , 80 , 8 , 33 },
+{ 80 , 80 , 8 , 34 },
+{ 80 , 80 , 8 , 35 },
+{ 80 , 80 , 8 , 36 },
+{ 80 , 80 , 8 , 37 },
+{ 80 , 80 , 8 , 38 },
+{ 80 , 80 , 8 , 39 },
+{ 80 , 80 , 8 , 40 },
+{ 80 , 80 , 8 , 41 },
+{ 80 , 80 , 8 , 42 },
+{ 80 , 80 , 8 , 43 },
+{ 80 , 80 , 8 , 44 },
+{ 80 , 80 , 8 , 45 },
+{ 80 , 80 , 8 , 46 },
+{ 80 , 80 , 8 , 47 },
+{ 80 , 80 , 8 , 48 },
+{ 80 , 80 , 8 , 49 },
+{ 80 , 80 , 8 , 50 },
+{ 80 , 80 , 8 , 51 },
+{ 80 , 80 , 8 , 52 },
+{ 80 , 80 , 8 , 53 },
+{ 80 , 80 , 8 , 54 },
+{ 80 , 80 , 8 , 55 },
+{ 80 , 80 , 8 , 56 },
+{ 80 , 80 , 8 , 57 },
+{ 80 , 80 , 8 , 58 },
+{ 80 , 80 , 8 , 59 },
+{ 80 , 80 , 8 , 60 },
+{ 80 , 80 , 8 , 61 },
+{ 80 , 80 , 8 , 62 },
+{ 80 , 80 , 8 , 63 },
+{ 80 , 80 , 8 , 64 },
+{ 80 , 80 , 8 , 65 },
+{ 80 , 80 , 8 , 66 },
+{ 80 , 80 , 8 , 67 },
+{ 80 , 80 , 8 , 68 },
+{ 80 , 80 , 8 , 69 },
+{ 80 , 80 , 8 , 70 },
+{ 80 , 80 , 8 , 71 },
+{ 80 , 80 , 8 , 72 },
+{ 80 , 80 , 8 , 73 },
+{ 80 , 80 , 8 , 74 },
+{ 80 , 80 , 8 , 75 },
+{ 80 , 80 , 8 , 76 },
+{ 80 , 80 , 8 , 77 },
+{ 80 , 80 , 8 , 78 },
+{ 80 , 80 , 8 , 79 },
+{ 80 , 80 , 9 , 0 },
+{ 80 , 80 , 9 , 1 },
+{ 80 , 80 , 9 , 2 },
+{ 80 , 80 , 9 , 3 },
+{ 80 , 80 , 9 , 4 },
+{ 80 , 80 , 9 , 5 },
+{ 80 , 80 , 9 , 6 },
+{ 80 , 80 , 9 , 7 },
+{ 80 , 80 , 9 , 8 },
+{ 80 , 80 , 9 , 9 },
+{ 80 , 80 , 9 , 10 },
+{ 80 , 80 , 9 , 11 },
+{ 80 , 80 , 9 , 12 },
+{ 80 , 80 , 9 , 13 },
+{ 80 , 80 , 9 , 14 },
+{ 80 , 80 , 9 , 15 },
+{ 80 , 80 , 9 , 16 },
+{ 80 , 80 , 9 , 17 },
+{ 80 , 80 , 9 , 18 },
+{ 80 , 80 , 9 , 19 },
+{ 80 , 80 , 9 , 20 },
+{ 80 , 80 , 9 , 21 },
+{ 80 , 80 , 9 , 22 },
+{ 80 , 80 , 9 , 23 },
+{ 80 , 80 , 9 , 24 },
+{ 80 , 80 , 9 , 25 },
+{ 80 , 80 , 9 , 26 },
+{ 80 , 80 , 9 , 27 },
+{ 80 , 80 , 9 , 28 },
+{ 80 , 80 , 9 , 29 },
+{ 80 , 80 , 9 , 30 },
+{ 80 , 80 , 9 , 31 },
+{ 80 , 80 , 9 , 32 },
+{ 80 , 80 , 9 , 33 },
+{ 80 , 80 , 9 , 34 },
+{ 80 , 80 , 9 , 35 },
+{ 80 , 80 , 9 , 36 },
+{ 80 , 80 , 9 , 37 },
+{ 80 , 80 , 9 , 38 },
+{ 80 , 80 , 9 , 39 },
+{ 80 , 80 , 9 , 40 },
+{ 80 , 80 , 9 , 41 },
+{ 80 , 80 , 9 , 42 },
+{ 80 , 80 , 9 , 43 },
+{ 80 , 80 , 9 , 44 },
+{ 80 , 80 , 9 , 45 },
+{ 80 , 80 , 9 , 46 },
+{ 80 , 80 , 9 , 47 },
+{ 80 , 80 , 9 , 48 },
+{ 80 , 80 , 9 , 49 },
+{ 80 , 80 , 9 , 50 },
+{ 80 , 80 , 9 , 51 },
+{ 80 , 80 , 9 , 52 },
+{ 80 , 80 , 9 , 53 },
+{ 80 , 80 , 9 , 54 },
+{ 80 , 80 , 9 , 55 },
+{ 80 , 80 , 9 , 56 },
+{ 80 , 80 , 9 , 57 },
+{ 80 , 80 , 9 , 58 },
+{ 80 , 80 , 9 , 59 },
+{ 80 , 80 , 9 , 60 },
+{ 80 , 80 , 9 , 61 },
+{ 80 , 80 , 9 , 62 },
+{ 80 , 80 , 9 , 63 },
+{ 80 , 80 , 9 , 64 },
+{ 80 , 80 , 9 , 65 },
+{ 80 , 80 , 9 , 66 },
+{ 80 , 80 , 9 , 67 },
+{ 80 , 80 , 9 , 68 },
+{ 80 , 80 , 9 , 69 },
+{ 80 , 80 , 9 , 70 },
+{ 80 , 80 , 9 , 71 },
+{ 80 , 80 , 9 , 72 },
+{ 80 , 80 , 9 , 73 },
+{ 80 , 80 , 9 , 74 },
+{ 80 , 80 , 9 , 75 },
+{ 80 , 80 , 9 , 76 },
+{ 80 , 80 , 9 , 77 },
+{ 80 , 80 , 9 , 78 },
+{ 80 , 80 , 9 , 79 },
+{ 80 , 80 , 10 , 0 },
+{ 80 , 80 , 10 , 1 },
+{ 80 , 80 , 10 , 2 },
+{ 80 , 80 , 10 , 3 },
+{ 80 , 80 , 10 , 4 },
+{ 80 , 80 , 10 , 5 },
+{ 80 , 80 , 10 , 6 },
+{ 80 , 80 , 10 , 7 },
+{ 80 , 80 , 10 , 8 },
+{ 80 , 80 , 10 , 9 },
+{ 80 , 80 , 10 , 10 },
+{ 80 , 80 , 10 , 11 },
+{ 80 , 80 , 10 , 12 },
+{ 80 , 80 , 10 , 13 },
+{ 80 , 80 , 10 , 14 },
+{ 80 , 80 , 10 , 15 },
+{ 80 , 80 , 10 , 16 },
+{ 80 , 80 , 10 , 17 },
+{ 80 , 80 , 10 , 18 },
+{ 80 , 80 , 10 , 19 },
+{ 80 , 80 , 10 , 20 },
+{ 80 , 80 , 10 , 21 },
+{ 80 , 80 , 10 , 22 },
+{ 80 , 80 , 10 , 23 },
+{ 80 , 80 , 10 , 24 },
+{ 80 , 80 , 10 , 25 },
+{ 80 , 80 , 10 , 26 },
+{ 80 , 80 , 10 , 27 },
+{ 80 , 80 , 10 , 28 },
+{ 80 , 80 , 10 , 29 },
+{ 80 , 80 , 10 , 30 },
+{ 80 , 80 , 10 , 31 },
+{ 80 , 80 , 10 , 32 },
+{ 80 , 80 , 10 , 33 },
+{ 80 , 80 , 10 , 34 },
+{ 80 , 80 , 10 , 35 },
+{ 80 , 80 , 10 , 36 },
+{ 80 , 80 , 10 , 37 },
+{ 80 , 80 , 10 , 38 },
+{ 80 , 80 , 10 , 39 },
+{ 80 , 80 , 10 , 40 },
+{ 80 , 80 , 10 , 41 },
+{ 80 , 80 , 10 , 42 },
+{ 80 , 80 , 10 , 43 },
+{ 80 , 80 , 10 , 44 },
+{ 80 , 80 , 10 , 45 },
+{ 80 , 80 , 10 , 46 },
+{ 80 , 80 , 10 , 47 },
+{ 80 , 80 , 10 , 48 },
+{ 80 , 80 , 10 , 49 },
+{ 80 , 80 , 10 , 50 },
+{ 80 , 80 , 10 , 51 },
+{ 80 , 80 , 10 , 52 },
+{ 80 , 80 , 10 , 53 },
+{ 80 , 80 , 10 , 54 },
+{ 80 , 80 , 10 , 55 },
+{ 80 , 80 , 10 , 56 },
+{ 80 , 80 , 10 , 57 },
+{ 80 , 80 , 10 , 58 },
+{ 80 , 80 , 10 , 59 },
+{ 80 , 80 , 10 , 60 },
+{ 80 , 80 , 10 , 61 },
+{ 80 , 80 , 10 , 62 },
+{ 80 , 80 , 10 , 63 },
+{ 80 , 80 , 10 , 64 },
+{ 80 , 80 , 10 , 65 },
+{ 80 , 80 , 10 , 66 },
+{ 80 , 80 , 10 , 67 },
+{ 80 , 80 , 10 , 68 },
+{ 80 , 80 , 10 , 69 },
+{ 80 , 80 , 10 , 70 },
+{ 80 , 80 , 10 , 71 },
+{ 80 , 80 , 10 , 72 },
+{ 80 , 80 , 10 , 73 },
+{ 80 , 80 , 10 , 74 },
+{ 80 , 80 , 10 , 75 },
+{ 80 , 80 , 10 , 76 },
+{ 80 , 80 , 10 , 77 },
+{ 80 , 80 , 10 , 78 },
+{ 80 , 80 , 10 , 79 },
+{ 80 , 80 , 11 , 0 },
+{ 80 , 80 , 11 , 1 },
+{ 80 , 80 , 11 , 2 },
+{ 80 , 80 , 11 , 3 },
+{ 80 , 80 , 11 , 4 },
+{ 80 , 80 , 11 , 5 },
+{ 80 , 80 , 11 , 6 },
+{ 80 , 80 , 11 , 7 },
+{ 80 , 80 , 11 , 8 },
+{ 80 , 80 , 11 , 9 },
+{ 80 , 80 , 11 , 10 },
+{ 80 , 80 , 11 , 11 },
+{ 80 , 80 , 11 , 12 },
+{ 80 , 80 , 11 , 13 },
+{ 80 , 80 , 11 , 14 },
+{ 80 , 80 , 11 , 15 },
+{ 80 , 80 , 11 , 16 },
+{ 80 , 80 , 11 , 17 },
+{ 80 , 80 , 11 , 18 },
+{ 80 , 80 , 11 , 19 },
+{ 80 , 80 , 11 , 20 },
+{ 80 , 80 , 11 , 21 },
+{ 80 , 80 , 11 , 22 },
+{ 80 , 80 , 11 , 23 },
+{ 80 , 80 , 11 , 24 },
+{ 80 , 80 , 11 , 25 },
+{ 80 , 80 , 11 , 26 },
+{ 80 , 80 , 11 , 27 },
+{ 80 , 80 , 11 , 28 },
+{ 80 , 80 , 11 , 29 },
+{ 80 , 80 , 11 , 30 },
+{ 80 , 80 , 11 , 31 },
+{ 80 , 80 , 11 , 32 },
+{ 80 , 80 , 11 , 33 },
+{ 80 , 80 , 11 , 34 },
+{ 80 , 80 , 11 , 35 },
+{ 80 , 80 , 11 , 36 },
+{ 80 , 80 , 11 , 37 },
+{ 80 , 80 , 11 , 38 },
+{ 80 , 80 , 11 , 39 },
+{ 80 , 80 , 11 , 40 },
+{ 80 , 80 , 11 , 41 },
+{ 80 , 80 , 11 , 42 },
+{ 80 , 80 , 11 , 43 },
+{ 80 , 80 , 11 , 44 },
+{ 80 , 80 , 11 , 45 },
+{ 80 , 80 , 11 , 46 },
+{ 80 , 80 , 11 , 47 },
+{ 80 , 80 , 11 , 48 },
+{ 80 , 80 , 11 , 49 },
+{ 80 , 80 , 11 , 50 },
+{ 80 , 80 , 11 , 51 },
+{ 80 , 80 , 11 , 52 },
+{ 80 , 80 , 11 , 53 },
+{ 80 , 80 , 11 , 54 },
+{ 80 , 80 , 11 , 55 },
+{ 80 , 80 , 11 , 56 },
+{ 80 , 80 , 11 , 57 },
+{ 80 , 80 , 11 , 58 },
+{ 80 , 80 , 11 , 59 },
+{ 80 , 80 , 11 , 60 },
+{ 80 , 80 , 11 , 61 },
+{ 80 , 80 , 11 , 62 },
+{ 80 , 80 , 11 , 63 },
+{ 80 , 80 , 11 , 64 },
+{ 80 , 80 , 11 , 65 },
+{ 80 , 80 , 11 , 66 },
+{ 80 , 80 , 11 , 67 },
+{ 80 , 80 , 11 , 68 },
+{ 80 , 80 , 11 , 69 },
+{ 80 , 80 , 11 , 70 },
+{ 80 , 80 , 11 , 71 },
+{ 80 , 80 , 11 , 72 },
+{ 80 , 80 , 11 , 73 },
+{ 80 , 80 , 11 , 74 },
+{ 80 , 80 , 11 , 75 },
+{ 80 , 80 , 11 , 76 },
+{ 80 , 80 , 11 , 77 },
+{ 80 , 80 , 11 , 78 },
+{ 80 , 80 , 11 , 79 },
+{ 80 , 80 , 12 , 0 },
+{ 80 , 80 , 12 , 1 },
+{ 80 , 80 , 12 , 2 },
+{ 80 , 80 , 12 , 3 },
+{ 80 , 80 , 12 , 4 },
+{ 80 , 80 , 12 , 5 },
+{ 80 , 80 , 12 , 6 },
+{ 80 , 80 , 12 , 7 },
+{ 80 , 80 , 12 , 8 },
+{ 80 , 80 , 12 , 9 },
+{ 80 , 80 , 12 , 10 },
+{ 80 , 80 , 12 , 11 },
+{ 80 , 80 , 12 , 12 },
+{ 80 , 80 , 12 , 13 },
+{ 80 , 80 , 12 , 14 },
+{ 80 , 80 , 12 , 15 },
+{ 80 , 80 , 12 , 16 },
+{ 80 , 80 , 12 , 17 },
+{ 80 , 80 , 12 , 18 },
+{ 80 , 80 , 12 , 19 },
+{ 80 , 80 , 12 , 20 },
+{ 80 , 80 , 12 , 21 },
+{ 80 , 80 , 12 , 22 },
+{ 80 , 80 , 12 , 23 },
+{ 80 , 80 , 12 , 24 },
+{ 80 , 80 , 12 , 25 },
+{ 80 , 80 , 12 , 26 },
+{ 80 , 80 , 12 , 27 },
+{ 80 , 80 , 12 , 28 },
+{ 80 , 80 , 12 , 29 },
+{ 80 , 80 , 12 , 30 },
+{ 80 , 80 , 12 , 31 },
+{ 80 , 80 , 12 , 32 },
+{ 80 , 80 , 12 , 33 },
+{ 80 , 80 , 12 , 34 },
+{ 80 , 80 , 12 , 35 },
+{ 80 , 80 , 12 , 36 },
+{ 80 , 80 , 12 , 37 },
+{ 80 , 80 , 12 , 38 },
+{ 80 , 80 , 12 , 39 },
+{ 80 , 80 , 12 , 40 },
+{ 80 , 80 , 12 , 41 },
+{ 80 , 80 , 12 , 42 },
+{ 80 , 80 , 12 , 43 },
+{ 80 , 80 , 12 , 44 },
+{ 80 , 80 , 12 , 45 },
+{ 80 , 80 , 12 , 46 },
+{ 80 , 80 , 12 , 47 },
+{ 80 , 80 , 12 , 48 },
+{ 80 , 80 , 12 , 49 },
+{ 80 , 80 , 12 , 50 },
+{ 80 , 80 , 12 , 51 },
+{ 80 , 80 , 12 , 52 },
+{ 80 , 80 , 12 , 53 },
+{ 80 , 80 , 12 , 54 },
+{ 80 , 80 , 12 , 55 },
+{ 80 , 80 , 12 , 56 },
+{ 80 , 80 , 12 , 57 },
+{ 80 , 80 , 12 , 58 },
+{ 80 , 80 , 12 , 59 },
+{ 80 , 80 , 12 , 60 },
+{ 80 , 80 , 12 , 61 },
+{ 80 , 80 , 12 , 62 },
+{ 80 , 80 , 12 , 63 },
+{ 80 , 80 , 12 , 64 },
+{ 80 , 80 , 12 , 65 },
+{ 80 , 80 , 12 , 66 },
+{ 80 , 80 , 12 , 67 },
+{ 80 , 80 , 12 , 68 },
+{ 80 , 80 , 12 , 69 },
+{ 80 , 80 , 12 , 70 },
+{ 80 , 80 , 12 , 71 },
+{ 80 , 80 , 12 , 72 },
+{ 80 , 80 , 12 , 73 },
+{ 80 , 80 , 12 , 74 },
+{ 80 , 80 , 12 , 75 },
+{ 80 , 80 , 12 , 76 },
+{ 80 , 80 , 12 , 77 },
+{ 80 , 80 , 12 , 78 },
+{ 80 , 80 , 12 , 79 },
+{ 80 , 80 , 13 , 0 },
+{ 80 , 80 , 13 , 1 },
+{ 80 , 80 , 13 , 2 },
+{ 80 , 80 , 13 , 3 },
+{ 80 , 80 , 13 , 4 },
+{ 80 , 80 , 13 , 5 },
+{ 80 , 80 , 13 , 6 },
+{ 80 , 80 , 13 , 7 },
+{ 80 , 80 , 13 , 8 },
+{ 80 , 80 , 13 , 9 },
+{ 80 , 80 , 13 , 10 },
+{ 80 , 80 , 13 , 11 },
+{ 80 , 80 , 13 , 12 },
+{ 80 , 80 , 13 , 13 },
+{ 80 , 80 , 13 , 14 },
+{ 80 , 80 , 13 , 15 },
+{ 80 , 80 , 13 , 16 },
+{ 80 , 80 , 13 , 17 },
+{ 80 , 80 , 13 , 18 },
+{ 80 , 80 , 13 , 19 },
+{ 80 , 80 , 13 , 20 },
+{ 80 , 80 , 13 , 21 },
+{ 80 , 80 , 13 , 22 },
+{ 80 , 80 , 13 , 23 },
+{ 80 , 80 , 13 , 24 },
+{ 80 , 80 , 13 , 25 },
+{ 80 , 80 , 13 , 26 },
+{ 80 , 80 , 13 , 27 },
+{ 80 , 80 , 13 , 28 },
+{ 80 , 80 , 13 , 29 },
+{ 80 , 80 , 13 , 30 },
+{ 80 , 80 , 13 , 31 },
+{ 80 , 80 , 13 , 32 },
+{ 80 , 80 , 13 , 33 },
+{ 80 , 80 , 13 , 34 },
+{ 80 , 80 , 13 , 35 },
+{ 80 , 80 , 13 , 36 },
+{ 80 , 80 , 13 , 37 },
+{ 80 , 80 , 13 , 38 },
+{ 80 , 80 , 13 , 39 },
+{ 80 , 80 , 13 , 40 },
+{ 80 , 80 , 13 , 41 },
+{ 80 , 80 , 13 , 42 },
+{ 80 , 80 , 13 , 43 },
+{ 80 , 80 , 13 , 44 },
+{ 80 , 80 , 13 , 45 },
+{ 80 , 80 , 13 , 46 },
+{ 80 , 80 , 13 , 47 },
+{ 80 , 80 , 13 , 48 },
+{ 80 , 80 , 13 , 49 },
+{ 80 , 80 , 13 , 50 },
+{ 80 , 80 , 13 , 51 },
+{ 80 , 80 , 13 , 52 },
+{ 80 , 80 , 13 , 53 },
+{ 80 , 80 , 13 , 54 },
+{ 80 , 80 , 13 , 55 },
+{ 80 , 80 , 13 , 56 },
+{ 80 , 80 , 13 , 57 },
+{ 80 , 80 , 13 , 58 },
+{ 80 , 80 , 13 , 59 },
+{ 80 , 80 , 13 , 60 },
+{ 80 , 80 , 13 , 61 },
+{ 80 , 80 , 13 , 62 },
+{ 80 , 80 , 13 , 63 },
+{ 80 , 80 , 13 , 64 },
+{ 80 , 80 , 13 , 65 },
+{ 80 , 80 , 13 , 66 },
+{ 80 , 80 , 13 , 67 },
+{ 80 , 80 , 13 , 68 },
+{ 80 , 80 , 13 , 69 },
+{ 80 , 80 , 13 , 70 },
+{ 80 , 80 , 13 , 71 },
+{ 80 , 80 , 13 , 72 },
+{ 80 , 80 , 13 , 73 },
+{ 80 , 80 , 13 , 74 },
+{ 80 , 80 , 13 , 75 },
+{ 80 , 80 , 13 , 76 },
+{ 80 , 80 , 13 , 77 },
+{ 80 , 80 , 13 , 78 },
+{ 80 , 80 , 13 , 79 },
+{ 80 , 80 , 14 , 0 },
+{ 80 , 80 , 14 , 1 },
+{ 80 , 80 , 14 , 2 },
+{ 80 , 80 , 14 , 3 },
+{ 80 , 80 , 14 , 4 },
+{ 80 , 80 , 14 , 5 },
+{ 80 , 80 , 14 , 6 },
+{ 80 , 80 , 14 , 7 },
+{ 80 , 80 , 14 , 8 },
+{ 80 , 80 , 14 , 9 },
+{ 80 , 80 , 14 , 10 },
+{ 80 , 80 , 14 , 11 },
+{ 80 , 80 , 14 , 12 },
+{ 80 , 80 , 14 , 13 },
+{ 80 , 80 , 14 , 14 },
+{ 80 , 80 , 14 , 15 },
+{ 80 , 80 , 14 , 16 },
+{ 80 , 80 , 14 , 17 },
+{ 80 , 80 , 14 , 18 },
+{ 80 , 80 , 14 , 19 },
+{ 80 , 80 , 14 , 20 },
+{ 80 , 80 , 14 , 21 },
+{ 80 , 80 , 14 , 22 },
+{ 80 , 80 , 14 , 23 },
+{ 80 , 80 , 14 , 24 },
+{ 80 , 80 , 14 , 25 },
+{ 80 , 80 , 14 , 26 },
+{ 80 , 80 , 14 , 27 },
+{ 80 , 80 , 14 , 28 },
+{ 80 , 80 , 14 , 29 },
+{ 80 , 80 , 14 , 30 },
+{ 80 , 80 , 14 , 31 },
+{ 80 , 80 , 14 , 32 },
+{ 80 , 80 , 14 , 33 },
+{ 80 , 80 , 14 , 34 },
+{ 80 , 80 , 14 , 35 },
+{ 80 , 80 , 14 , 36 },
+{ 80 , 80 , 14 , 37 },
+{ 80 , 80 , 14 , 38 },
+{ 80 , 80 , 14 , 39 },
+{ 80 , 80 , 14 , 40 },
+{ 80 , 80 , 14 , 41 },
+{ 80 , 80 , 14 , 42 },
+{ 80 , 80 , 14 , 43 },
+{ 80 , 80 , 14 , 44 },
+{ 80 , 80 , 14 , 45 },
+{ 80 , 80 , 14 , 46 },
+{ 80 , 80 , 14 , 47 },
+{ 80 , 80 , 14 , 48 },
+{ 80 , 80 , 14 , 49 },
+{ 80 , 80 , 14 , 50 },
+{ 80 , 80 , 14 , 51 },
+{ 80 , 80 , 14 , 52 },
+{ 80 , 80 , 14 , 53 },
+{ 80 , 80 , 14 , 54 },
+{ 80 , 80 , 14 , 55 },
+{ 80 , 80 , 14 , 56 },
+{ 80 , 80 , 14 , 57 },
+{ 80 , 80 , 14 , 58 },
+{ 80 , 80 , 14 , 59 },
+{ 80 , 80 , 14 , 60 },
+{ 80 , 80 , 14 , 61 },
+{ 80 , 80 , 14 , 62 },
+{ 80 , 80 , 14 , 63 },
+{ 80 , 80 , 14 , 64 },
+{ 80 , 80 , 14 , 65 },
+{ 80 , 80 , 14 , 66 },
+{ 80 , 80 , 14 , 67 },
+{ 80 , 80 , 14 , 68 },
+{ 80 , 80 , 14 , 69 },
+{ 80 , 80 , 14 , 70 },
+{ 80 , 80 , 14 , 71 },
+{ 80 , 80 , 14 , 72 },
+{ 80 , 80 , 14 , 73 },
+{ 80 , 80 , 14 , 74 },
+{ 80 , 80 , 14 , 75 },
+{ 80 , 80 , 14 , 76 },
+{ 80 , 80 , 14 , 77 },
+{ 80 , 80 , 14 , 78 },
+{ 80 , 80 , 14 , 79 },
+{ 80 , 80 , 15 , 0 },
+{ 80 , 80 , 15 , 1 },
+{ 80 , 80 , 15 , 2 },
+{ 80 , 80 , 15 , 3 },
+{ 80 , 80 , 15 , 4 },
+{ 80 , 80 , 15 , 5 },
+{ 80 , 80 , 15 , 6 },
+{ 80 , 80 , 15 , 7 },
+{ 80 , 80 , 15 , 8 },
+{ 80 , 80 , 15 , 9 },
+{ 80 , 80 , 15 , 10 },
+{ 80 , 80 , 15 , 11 },
+{ 80 , 80 , 15 , 12 },
+{ 80 , 80 , 15 , 13 },
+{ 80 , 80 , 15 , 14 },
+{ 80 , 80 , 15 , 15 },
+{ 80 , 80 , 15 , 16 },
+{ 80 , 80 , 15 , 17 },
+{ 80 , 80 , 15 , 18 },
+{ 80 , 80 , 15 , 19 },
+{ 80 , 80 , 15 , 20 },
+{ 80 , 80 , 15 , 21 },
+{ 80 , 80 , 15 , 22 },
+{ 80 , 80 , 15 , 23 },
+{ 80 , 80 , 15 , 24 },
+{ 80 , 80 , 15 , 25 },
+{ 80 , 80 , 15 , 26 },
+{ 80 , 80 , 15 , 27 },
+{ 80 , 80 , 15 , 28 },
+{ 80 , 80 , 15 , 29 },
+{ 80 , 80 , 15 , 30 },
+{ 80 , 80 , 15 , 31 },
+{ 80 , 80 , 15 , 32 },
+{ 80 , 80 , 15 , 33 },
+{ 80 , 80 , 15 , 34 },
+{ 80 , 80 , 15 , 35 },
+{ 80 , 80 , 15 , 36 },
+{ 80 , 80 , 15 , 37 },
+{ 80 , 80 , 15 , 38 },
+{ 80 , 80 , 15 , 39 },
+{ 80 , 80 , 15 , 40 },
+{ 80 , 80 , 15 , 41 },
+{ 80 , 80 , 15 , 42 },
+{ 80 , 80 , 15 , 43 },
+{ 80 , 80 , 15 , 44 },
+{ 80 , 80 , 15 , 45 },
+{ 80 , 80 , 15 , 46 },
+{ 80 , 80 , 15 , 47 },
+{ 80 , 80 , 15 , 48 },
+{ 80 , 80 , 15 , 49 },
+{ 80 , 80 , 15 , 50 },
+{ 80 , 80 , 15 , 51 },
+{ 80 , 80 , 15 , 52 },
+{ 80 , 80 , 15 , 53 },
+{ 80 , 80 , 15 , 54 },
+{ 80 , 80 , 15 , 55 },
+{ 80 , 80 , 15 , 56 },
+{ 80 , 80 , 15 , 57 },
+{ 80 , 80 , 15 , 58 },
+{ 80 , 80 , 15 , 59 },
+{ 80 , 80 , 15 , 60 },
+{ 80 , 80 , 15 , 61 },
+{ 80 , 80 , 15 , 62 },
+{ 80 , 80 , 15 , 63 },
+{ 80 , 80 , 15 , 64 },
+{ 80 , 80 , 15 , 65 },
+{ 80 , 80 , 15 , 66 },
+{ 80 , 80 , 15 , 67 },
+{ 80 , 80 , 15 , 68 },
+{ 80 , 80 , 15 , 69 },
+{ 80 , 80 , 15 , 70 },
+{ 80 , 80 , 15 , 71 },
+{ 80 , 80 , 15 , 72 },
+{ 80 , 80 , 15 , 73 },
+{ 80 , 80 , 15 , 74 },
+{ 80 , 80 , 15 , 75 },
+{ 80 , 80 , 15 , 76 },
+{ 80 , 80 , 15 , 77 },
+{ 80 , 80 , 15 , 78 },
+{ 80 , 80 , 15 , 79 },
+{ 80 , 80 , 16 , 0 },
+{ 80 , 80 , 16 , 1 },
+{ 80 , 80 , 16 , 2 },
+{ 80 , 80 , 16 , 3 },
+{ 80 , 80 , 16 , 4 },
+{ 80 , 80 , 16 , 5 },
+{ 80 , 80 , 16 , 6 },
+{ 80 , 80 , 16 , 7 },
+{ 80 , 80 , 16 , 8 },
+{ 80 , 80 , 16 , 9 },
+{ 80 , 80 , 16 , 10 },
+{ 80 , 80 , 16 , 11 },
+{ 80 , 80 , 16 , 12 },
+{ 80 , 80 , 16 , 13 },
+{ 80 , 80 , 16 , 14 },
+{ 80 , 80 , 16 , 15 },
+{ 80 , 80 , 16 , 16 },
+{ 80 , 80 , 16 , 17 },
+{ 80 , 80 , 16 , 18 },
+{ 80 , 80 , 16 , 19 },
+{ 80 , 80 , 16 , 20 },
+{ 80 , 80 , 16 , 21 },
+{ 80 , 80 , 16 , 22 },
+{ 80 , 80 , 16 , 23 },
+{ 80 , 80 , 16 , 24 },
+{ 80 , 80 , 16 , 25 },
+{ 80 , 80 , 16 , 26 },
+{ 80 , 80 , 16 , 27 },
+{ 80 , 80 , 16 , 28 },
+{ 80 , 80 , 16 , 29 },
+{ 80 , 80 , 16 , 30 },
+{ 80 , 80 , 16 , 31 },
+{ 80 , 80 , 16 , 32 },
+{ 80 , 80 , 16 , 33 },
+{ 80 , 80 , 16 , 34 },
+{ 80 , 80 , 16 , 35 },
+{ 80 , 80 , 16 , 36 },
+{ 80 , 80 , 16 , 37 },
+{ 80 , 80 , 16 , 38 },
+{ 80 , 80 , 16 , 39 },
+{ 80 , 80 , 16 , 40 },
+{ 80 , 80 , 16 , 41 },
+{ 80 , 80 , 16 , 42 },
+{ 80 , 80 , 16 , 43 },
+{ 80 , 80 , 16 , 44 },
+{ 80 , 80 , 16 , 45 },
+{ 80 , 80 , 16 , 46 },
+{ 80 , 80 , 16 , 47 },
+{ 80 , 80 , 16 , 48 },
+{ 80 , 80 , 16 , 49 },
+{ 80 , 80 , 16 , 50 },
+{ 80 , 80 , 16 , 51 },
+{ 80 , 80 , 16 , 52 },
+{ 80 , 80 , 16 , 53 },
+{ 80 , 80 , 16 , 54 },
+{ 80 , 80 , 16 , 55 },
+{ 80 , 80 , 16 , 56 },
+{ 80 , 80 , 16 , 57 },
+{ 80 , 80 , 16 , 58 },
+{ 80 , 80 , 16 , 59 },
+{ 80 , 80 , 16 , 60 },
+{ 80 , 80 , 16 , 61 },
+{ 80 , 80 , 16 , 62 },
+{ 80 , 80 , 16 , 63 },
+{ 80 , 80 , 16 , 64 },
+{ 80 , 80 , 16 , 65 },
+{ 80 , 80 , 16 , 66 },
+{ 80 , 80 , 16 , 67 },
+{ 80 , 80 , 16 , 68 },
+{ 80 , 80 , 16 , 69 },
+{ 80 , 80 , 16 , 70 },
+{ 80 , 80 , 16 , 71 },
+{ 80 , 80 , 16 , 72 },
+{ 80 , 80 , 16 , 73 },
+{ 80 , 80 , 16 , 74 },
+{ 80 , 80 , 16 , 75 },
+{ 80 , 80 , 16 , 76 },
+{ 80 , 80 , 16 , 77 },
+{ 80 , 80 , 16 , 78 },
+{ 80 , 80 , 16 , 79 },
+{ 80 , 80 , 17 , 0 },
+{ 80 , 80 , 17 , 1 },
+{ 80 , 80 , 17 , 2 },
+{ 80 , 80 , 17 , 3 },
+{ 80 , 80 , 17 , 4 },
+{ 80 , 80 , 17 , 5 },
+{ 80 , 80 , 17 , 6 },
+{ 80 , 80 , 17 , 7 },
+{ 80 , 80 , 17 , 8 },
+{ 80 , 80 , 17 , 9 },
+{ 80 , 80 , 17 , 10 },
+{ 80 , 80 , 17 , 11 },
+{ 80 , 80 , 17 , 12 },
+{ 80 , 80 , 17 , 13 },
+{ 80 , 80 , 17 , 14 },
+{ 80 , 80 , 17 , 15 },
+{ 80 , 80 , 17 , 16 },
+{ 80 , 80 , 17 , 17 },
+{ 80 , 80 , 17 , 18 },
+{ 80 , 80 , 17 , 19 },
+{ 80 , 80 , 17 , 20 },
+{ 80 , 80 , 17 , 21 },
+{ 80 , 80 , 17 , 22 },
+{ 80 , 80 , 17 , 23 },
+{ 80 , 80 , 17 , 24 },
+{ 80 , 80 , 17 , 25 },
+{ 80 , 80 , 17 , 26 },
+{ 80 , 80 , 17 , 27 },
+{ 80 , 80 , 17 , 28 },
+{ 80 , 80 , 17 , 29 },
+{ 80 , 80 , 17 , 30 },
+{ 80 , 80 , 17 , 31 },
+{ 80 , 80 , 17 , 32 },
+{ 80 , 80 , 17 , 33 },
+{ 80 , 80 , 17 , 34 },
+{ 80 , 80 , 17 , 35 },
+{ 80 , 80 , 17 , 36 },
+{ 80 , 80 , 17 , 37 },
+{ 80 , 80 , 17 , 38 },
+{ 80 , 80 , 17 , 39 },
+{ 80 , 80 , 17 , 40 },
+{ 80 , 80 , 17 , 41 },
+{ 80 , 80 , 17 , 42 },
+{ 80 , 80 , 17 , 43 },
+{ 80 , 80 , 17 , 44 },
+{ 80 , 80 , 17 , 45 },
+{ 80 , 80 , 17 , 46 },
+{ 80 , 80 , 17 , 47 },
+{ 80 , 80 , 17 , 48 },
+{ 80 , 80 , 17 , 49 },
+{ 80 , 80 , 17 , 50 },
+{ 80 , 80 , 17 , 51 },
+{ 80 , 80 , 17 , 52 },
+{ 80 , 80 , 17 , 53 },
+{ 80 , 80 , 17 , 54 },
+{ 80 , 80 , 17 , 55 },
+{ 80 , 80 , 17 , 56 },
+{ 80 , 80 , 17 , 57 },
+{ 80 , 80 , 17 , 58 },
+{ 80 , 80 , 17 , 59 },
+{ 80 , 80 , 17 , 60 },
+{ 80 , 80 , 17 , 61 },
+{ 80 , 80 , 17 , 62 },
+{ 80 , 80 , 17 , 63 },
+{ 80 , 80 , 17 , 64 },
+{ 80 , 80 , 17 , 65 },
+{ 80 , 80 , 17 , 66 },
+{ 80 , 80 , 17 , 67 },
+{ 80 , 80 , 17 , 68 },
+{ 80 , 80 , 17 , 69 },
+{ 80 , 80 , 17 , 70 },
+{ 80 , 80 , 17 , 71 },
+{ 80 , 80 , 17 , 72 },
+{ 80 , 80 , 17 , 73 },
+{ 80 , 80 , 17 , 74 },
+{ 80 , 80 , 17 , 75 },
+{ 80 , 80 , 17 , 76 },
+{ 80 , 80 , 17 , 77 },
+{ 80 , 80 , 17 , 78 },
+{ 80 , 80 , 17 , 79 },
+{ 80 , 80 , 18 , 0 },
+{ 80 , 80 , 18 , 1 },
+{ 80 , 80 , 18 , 2 },
+{ 80 , 80 , 18 , 3 },
+{ 80 , 80 , 18 , 4 },
+{ 80 , 80 , 18 , 5 },
+{ 80 , 80 , 18 , 6 },
+{ 80 , 80 , 18 , 7 },
+{ 80 , 80 , 18 , 8 },
+{ 80 , 80 , 18 , 9 },
+{ 80 , 80 , 18 , 10 },
+{ 80 , 80 , 18 , 11 },
+{ 80 , 80 , 18 , 12 },
+{ 80 , 80 , 18 , 13 },
+{ 80 , 80 , 18 , 14 },
+{ 80 , 80 , 18 , 15 },
+{ 80 , 80 , 18 , 16 },
+{ 80 , 80 , 18 , 17 },
+{ 80 , 80 , 18 , 18 },
+{ 80 , 80 , 18 , 19 },
+{ 80 , 80 , 18 , 20 },
+{ 80 , 80 , 18 , 21 },
+{ 80 , 80 , 18 , 22 },
+{ 80 , 80 , 18 , 23 },
+{ 80 , 80 , 18 , 24 },
+{ 80 , 80 , 18 , 25 },
+{ 80 , 80 , 18 , 26 },
+{ 80 , 80 , 18 , 27 },
+{ 80 , 80 , 18 , 28 },
+{ 80 , 80 , 18 , 29 },
+{ 80 , 80 , 18 , 30 },
+{ 80 , 80 , 18 , 31 },
+{ 80 , 80 , 18 , 32 },
+{ 80 , 80 , 18 , 33 },
+{ 80 , 80 , 18 , 34 },
+{ 80 , 80 , 18 , 35 },
+{ 80 , 80 , 18 , 36 },
+{ 80 , 80 , 18 , 37 },
+{ 80 , 80 , 18 , 38 },
+{ 80 , 80 , 18 , 39 },
+{ 80 , 80 , 18 , 40 },
+{ 80 , 80 , 18 , 41 },
+{ 80 , 80 , 18 , 42 },
+{ 80 , 80 , 18 , 43 },
+{ 80 , 80 , 18 , 44 },
+{ 80 , 80 , 18 , 45 },
+{ 80 , 80 , 18 , 46 },
+{ 80 , 80 , 18 , 47 },
+{ 80 , 80 , 18 , 48 },
+{ 80 , 80 , 18 , 49 },
+{ 80 , 80 , 18 , 50 },
+{ 80 , 80 , 18 , 51 },
+{ 80 , 80 , 18 , 52 },
+{ 80 , 80 , 18 , 53 },
+{ 80 , 80 , 18 , 54 },
+{ 80 , 80 , 18 , 55 },
+{ 80 , 80 , 18 , 56 },
+{ 80 , 80 , 18 , 57 },
+{ 80 , 80 , 18 , 58 },
+{ 80 , 80 , 18 , 59 },
+{ 80 , 80 , 18 , 60 },
+{ 80 , 80 , 18 , 61 },
+{ 80 , 80 , 18 , 62 },
+{ 80 , 80 , 18 , 63 },
+{ 80 , 80 , 18 , 64 },
+{ 80 , 80 , 18 , 65 },
+{ 80 , 80 , 18 , 66 },
+{ 80 , 80 , 18 , 67 },
+{ 80 , 80 , 18 , 68 },
+{ 80 , 80 , 18 , 69 },
+{ 80 , 80 , 18 , 70 },
+{ 80 , 80 , 18 , 71 },
+{ 80 , 80 , 18 , 72 },
+{ 80 , 80 , 18 , 73 },
+{ 80 , 80 , 18 , 74 },
+{ 80 , 80 , 18 , 75 },
+{ 80 , 80 , 18 , 76 },
+{ 80 , 80 , 18 , 77 },
+{ 80 , 80 , 18 , 78 },
+{ 80 , 80 , 18 , 79 },
+{ 80 , 80 , 19 , 0 },
+{ 80 , 80 , 19 , 1 },
+{ 80 , 80 , 19 , 2 },
+{ 80 , 80 , 19 , 3 },
+{ 80 , 80 , 19 , 4 },
+{ 80 , 80 , 19 , 5 },
+{ 80 , 80 , 19 , 6 },
+{ 80 , 80 , 19 , 7 },
+{ 80 , 80 , 19 , 8 },
+{ 80 , 80 , 19 , 9 },
+{ 80 , 80 , 19 , 10 },
+{ 80 , 80 , 19 , 11 },
+{ 80 , 80 , 19 , 12 },
+{ 80 , 80 , 19 , 13 },
+{ 80 , 80 , 19 , 14 },
+{ 80 , 80 , 19 , 15 },
+{ 80 , 80 , 19 , 16 },
+{ 80 , 80 , 19 , 17 },
+{ 80 , 80 , 19 , 18 },
+{ 80 , 80 , 19 , 19 },
+{ 80 , 80 , 19 , 20 },
+{ 80 , 80 , 19 , 21 },
+{ 80 , 80 , 19 , 22 },
+{ 80 , 80 , 19 , 23 },
+{ 80 , 80 , 19 , 24 },
+{ 80 , 80 , 19 , 25 },
+{ 80 , 80 , 19 , 26 },
+{ 80 , 80 , 19 , 27 },
+{ 80 , 80 , 19 , 28 },
+{ 80 , 80 , 19 , 29 },
+{ 80 , 80 , 19 , 30 },
+{ 80 , 80 , 19 , 31 },
+{ 80 , 80 , 19 , 32 },
+{ 80 , 80 , 19 , 33 },
+{ 80 , 80 , 19 , 34 },
+{ 80 , 80 , 19 , 35 },
+{ 80 , 80 , 19 , 36 },
+{ 80 , 80 , 19 , 37 },
+{ 80 , 80 , 19 , 38 },
+{ 80 , 80 , 19 , 39 },
+{ 80 , 80 , 19 , 40 },
+{ 80 , 80 , 19 , 41 },
+{ 80 , 80 , 19 , 42 },
+{ 80 , 80 , 19 , 43 },
+{ 80 , 80 , 19 , 44 },
+{ 80 , 80 , 19 , 45 },
+{ 80 , 80 , 19 , 46 },
+{ 80 , 80 , 19 , 47 },
+{ 80 , 80 , 19 , 48 },
+{ 80 , 80 , 19 , 49 },
+{ 80 , 80 , 19 , 50 },
+{ 80 , 80 , 19 , 51 },
+{ 80 , 80 , 19 , 52 },
+{ 80 , 80 , 19 , 53 },
+{ 80 , 80 , 19 , 54 },
+{ 80 , 80 , 19 , 55 },
+{ 80 , 80 , 19 , 56 },
+{ 80 , 80 , 19 , 57 },
+{ 80 , 80 , 19 , 58 },
+{ 80 , 80 , 19 , 59 },
+{ 80 , 80 , 19 , 60 },
+{ 80 , 80 , 19 , 61 },
+{ 80 , 80 , 19 , 62 },
+{ 80 , 80 , 19 , 63 },
+{ 80 , 80 , 19 , 64 },
+{ 80 , 80 , 19 , 65 },
+{ 80 , 80 , 19 , 66 },
+{ 80 , 80 , 19 , 67 },
+{ 80 , 80 , 19 , 68 },
+{ 80 , 80 , 19 , 69 },
+{ 80 , 80 , 19 , 70 },
+{ 80 , 80 , 19 , 71 },
+{ 80 , 80 , 19 , 72 },
+{ 80 , 80 , 19 , 73 },
+{ 80 , 80 , 19 , 74 },
+{ 80 , 80 , 19 , 75 },
+{ 80 , 80 , 19 , 76 },
+{ 80 , 80 , 19 , 77 },
+{ 80 , 80 , 19 , 78 },
+{ 80 , 80 , 19 , 79 },
+{ 80 , 80 , 20 , 0 },
+{ 80 , 80 , 20 , 1 },
+{ 80 , 80 , 20 , 2 },
+{ 80 , 80 , 20 , 3 },
+{ 80 , 80 , 20 , 4 },
+{ 80 , 80 , 20 , 5 },
+{ 80 , 80 , 20 , 6 },
+{ 80 , 80 , 20 , 7 },
+{ 80 , 80 , 20 , 8 },
+{ 80 , 80 , 20 , 9 },
+{ 80 , 80 , 20 , 10 },
+{ 80 , 80 , 20 , 11 },
+{ 80 , 80 , 20 , 12 },
+{ 80 , 80 , 20 , 13 },
+{ 80 , 80 , 20 , 14 },
+{ 80 , 80 , 20 , 15 },
+{ 80 , 80 , 20 , 16 },
+{ 80 , 80 , 20 , 17 },
+{ 80 , 80 , 20 , 18 },
+{ 80 , 80 , 20 , 19 },
+{ 80 , 80 , 20 , 20 },
+{ 80 , 80 , 20 , 21 },
+{ 80 , 80 , 20 , 22 },
+{ 80 , 80 , 20 , 23 },
+{ 80 , 80 , 20 , 24 },
+{ 80 , 80 , 20 , 25 },
+{ 80 , 80 , 20 , 26 },
+{ 80 , 80 , 20 , 27 },
+{ 80 , 80 , 20 , 28 },
+{ 80 , 80 , 20 , 29 },
+{ 80 , 80 , 20 , 30 },
+{ 80 , 80 , 20 , 31 },
+{ 80 , 80 , 20 , 32 },
+{ 80 , 80 , 20 , 33 },
+{ 80 , 80 , 20 , 34 },
+{ 80 , 80 , 20 , 35 },
+{ 80 , 80 , 20 , 36 },
+{ 80 , 80 , 20 , 37 },
+{ 80 , 80 , 20 , 38 },
+{ 80 , 80 , 20 , 39 },
+{ 80 , 80 , 20 , 40 },
+{ 80 , 80 , 20 , 41 },
+{ 80 , 80 , 20 , 42 },
+{ 80 , 80 , 20 , 43 },
+{ 80 , 80 , 20 , 44 },
+{ 80 , 80 , 20 , 45 },
+{ 80 , 80 , 20 , 46 },
+{ 80 , 80 , 20 , 47 },
+{ 80 , 80 , 20 , 48 },
+{ 80 , 80 , 20 , 49 },
+{ 80 , 80 , 20 , 50 },
+{ 80 , 80 , 20 , 51 },
+{ 80 , 80 , 20 , 52 },
+{ 80 , 80 , 20 , 53 },
+{ 80 , 80 , 20 , 54 },
+{ 80 , 80 , 20 , 55 },
+{ 80 , 80 , 20 , 56 },
+{ 80 , 80 , 20 , 57 },
+{ 80 , 80 , 20 , 58 },
+{ 80 , 80 , 20 , 59 },
+{ 80 , 80 , 20 , 60 },
+{ 80 , 80 , 20 , 61 },
+{ 80 , 80 , 20 , 62 },
+{ 80 , 80 , 20 , 63 },
+{ 80 , 80 , 20 , 64 },
+{ 80 , 80 , 20 , 65 },
+{ 80 , 80 , 20 , 66 },
+{ 80 , 80 , 20 , 67 },
+{ 80 , 80 , 20 , 68 },
+{ 80 , 80 , 20 , 69 },
+{ 80 , 80 , 20 , 70 },
+{ 80 , 80 , 20 , 71 },
+{ 80 , 80 , 20 , 72 },
+{ 80 , 80 , 20 , 73 },
+{ 80 , 80 , 20 , 74 },
+{ 80 , 80 , 20 , 75 },
+{ 80 , 80 , 20 , 76 },
+{ 80 , 80 , 20 , 77 },
+{ 80 , 80 , 20 , 78 },
+{ 80 , 80 , 20 , 79 },
+{ 80 , 80 , 21 , 0 },
+{ 80 , 80 , 21 , 1 },
+{ 80 , 80 , 21 , 2 },
+{ 80 , 80 , 21 , 3 },
+{ 80 , 80 , 21 , 4 },
+{ 80 , 80 , 21 , 5 },
+{ 80 , 80 , 21 , 6 },
+{ 80 , 80 , 21 , 7 },
+{ 80 , 80 , 21 , 8 },
+{ 80 , 80 , 21 , 9 },
+{ 80 , 80 , 21 , 10 },
+{ 80 , 80 , 21 , 11 },
+{ 80 , 80 , 21 , 12 },
+{ 80 , 80 , 21 , 13 },
+{ 80 , 80 , 21 , 14 },
+{ 80 , 80 , 21 , 15 },
+{ 80 , 80 , 21 , 16 },
+{ 80 , 80 , 21 , 17 },
+{ 80 , 80 , 21 , 18 },
+{ 80 , 80 , 21 , 19 },
+{ 80 , 80 , 21 , 20 },
+{ 80 , 80 , 21 , 21 },
+{ 80 , 80 , 21 , 22 },
+{ 80 , 80 , 21 , 23 },
+{ 80 , 80 , 21 , 24 },
+{ 80 , 80 , 21 , 25 },
+{ 80 , 80 , 21 , 26 },
+{ 80 , 80 , 21 , 27 },
+{ 80 , 80 , 21 , 28 },
+{ 80 , 80 , 21 , 29 },
+{ 80 , 80 , 21 , 30 },
+{ 80 , 80 , 21 , 31 },
+{ 80 , 80 , 21 , 32 },
+{ 80 , 80 , 21 , 33 },
+{ 80 , 80 , 21 , 34 },
+{ 80 , 80 , 21 , 35 },
+{ 80 , 80 , 21 , 36 },
+{ 80 , 80 , 21 , 37 },
+{ 80 , 80 , 21 , 38 },
+{ 80 , 80 , 21 , 39 },
+{ 80 , 80 , 21 , 40 },
+{ 80 , 80 , 21 , 41 },
+{ 80 , 80 , 21 , 42 },
+{ 80 , 80 , 21 , 43 },
+{ 80 , 80 , 21 , 44 },
+{ 80 , 80 , 21 , 45 },
+{ 80 , 80 , 21 , 46 },
+{ 80 , 80 , 21 , 47 },
+{ 80 , 80 , 21 , 48 },
+{ 80 , 80 , 21 , 49 },
+{ 80 , 80 , 21 , 50 },
+{ 80 , 80 , 21 , 51 },
+{ 80 , 80 , 21 , 52 },
+{ 80 , 80 , 21 , 53 },
+{ 80 , 80 , 21 , 54 },
+{ 80 , 80 , 21 , 55 },
+{ 80 , 80 , 21 , 56 },
+{ 80 , 80 , 21 , 57 },
+{ 80 , 80 , 21 , 58 },
+{ 80 , 80 , 21 , 59 },
+{ 80 , 80 , 21 , 60 },
+{ 80 , 80 , 21 , 61 },
+{ 80 , 80 , 21 , 62 },
+{ 80 , 80 , 21 , 63 },
+{ 80 , 80 , 21 , 64 },
+{ 80 , 80 , 21 , 65 },
+{ 80 , 80 , 21 , 66 },
+{ 80 , 80 , 21 , 67 },
+{ 80 , 80 , 21 , 68 },
+{ 80 , 80 , 21 , 69 },
+{ 80 , 80 , 21 , 70 },
+{ 80 , 80 , 21 , 71 },
+{ 80 , 80 , 21 , 72 },
+{ 80 , 80 , 21 , 73 },
+{ 80 , 80 , 21 , 74 },
+{ 80 , 80 , 21 , 75 },
+{ 80 , 80 , 21 , 76 },
+{ 80 , 80 , 21 , 77 },
+{ 80 , 80 , 21 , 78 },
+{ 80 , 80 , 21 , 79 },
+{ 80 , 80 , 22 , 0 },
+{ 80 , 80 , 22 , 1 },
+{ 80 , 80 , 22 , 2 },
+{ 80 , 80 , 22 , 3 },
+{ 80 , 80 , 22 , 4 },
+{ 80 , 80 , 22 , 5 },
+{ 80 , 80 , 22 , 6 },
+{ 80 , 80 , 22 , 7 },
+{ 80 , 80 , 22 , 8 },
+{ 80 , 80 , 22 , 9 },
+{ 80 , 80 , 22 , 10 },
+{ 80 , 80 , 22 , 11 },
+{ 80 , 80 , 22 , 12 },
+{ 80 , 80 , 22 , 13 },
+{ 80 , 80 , 22 , 14 },
+{ 80 , 80 , 22 , 15 },
+{ 80 , 80 , 22 , 16 },
+{ 80 , 80 , 22 , 17 },
+{ 80 , 80 , 22 , 18 },
+{ 80 , 80 , 22 , 19 },
+{ 80 , 80 , 22 , 20 },
+{ 80 , 80 , 22 , 21 },
+{ 80 , 80 , 22 , 22 },
+{ 80 , 80 , 22 , 23 },
+{ 80 , 80 , 22 , 24 },
+{ 80 , 80 , 22 , 25 },
+{ 80 , 80 , 22 , 26 },
+{ 80 , 80 , 22 , 27 },
+{ 80 , 80 , 22 , 28 },
+{ 80 , 80 , 22 , 29 },
+{ 80 , 80 , 22 , 30 },
+{ 80 , 80 , 22 , 31 },
+{ 80 , 80 , 22 , 32 },
+{ 80 , 80 , 22 , 33 },
+{ 80 , 80 , 22 , 34 },
+{ 80 , 80 , 22 , 35 },
+{ 80 , 80 , 22 , 36 },
+{ 80 , 80 , 22 , 37 },
+{ 80 , 80 , 22 , 38 },
+{ 80 , 80 , 22 , 39 },
+{ 80 , 80 , 22 , 40 },
+{ 80 , 80 , 22 , 41 },
+{ 80 , 80 , 22 , 42 },
+{ 80 , 80 , 22 , 43 },
+{ 80 , 80 , 22 , 44 },
+{ 80 , 80 , 22 , 45 },
+{ 80 , 80 , 22 , 46 },
+{ 80 , 80 , 22 , 47 },
+{ 80 , 80 , 22 , 48 },
+{ 80 , 80 , 22 , 49 },
+{ 80 , 80 , 22 , 50 },
+{ 80 , 80 , 22 , 51 },
+{ 80 , 80 , 22 , 52 },
+{ 80 , 80 , 22 , 53 },
+{ 80 , 80 , 22 , 54 },
+{ 80 , 80 , 22 , 55 },
+{ 80 , 80 , 22 , 56 },
+{ 80 , 80 , 22 , 57 },
+{ 80 , 80 , 22 , 58 },
+{ 80 , 80 , 22 , 59 },
+{ 80 , 80 , 22 , 60 },
+{ 80 , 80 , 22 , 61 },
+{ 80 , 80 , 22 , 62 },
+{ 80 , 80 , 22 , 63 },
+{ 80 , 80 , 22 , 64 },
+{ 80 , 80 , 22 , 65 },
+{ 80 , 80 , 22 , 66 },
+{ 80 , 80 , 22 , 67 },
+{ 80 , 80 , 22 , 68 },
+{ 80 , 80 , 22 , 69 },
+{ 80 , 80 , 22 , 70 },
+{ 80 , 80 , 22 , 71 },
+{ 80 , 80 , 22 , 72 },
+{ 80 , 80 , 22 , 73 },
+{ 80 , 80 , 22 , 74 },
+{ 80 , 80 , 22 , 75 },
+{ 80 , 80 , 22 , 76 },
+{ 80 , 80 , 22 , 77 },
+{ 80 , 80 , 22 , 78 },
+{ 80 , 80 , 22 , 79 },
+{ 80 , 80 , 23 , 0 },
+{ 80 , 80 , 23 , 1 },
+{ 80 , 80 , 23 , 2 },
+{ 80 , 80 , 23 , 3 },
+{ 80 , 80 , 23 , 4 },
+{ 80 , 80 , 23 , 5 },
+{ 80 , 80 , 23 , 6 },
+{ 80 , 80 , 23 , 7 },
+{ 80 , 80 , 23 , 8 },
+{ 80 , 80 , 23 , 9 },
+{ 80 , 80 , 23 , 10 },
+{ 80 , 80 , 23 , 11 },
+{ 80 , 80 , 23 , 12 },
+{ 80 , 80 , 23 , 13 },
+{ 80 , 80 , 23 , 14 },
+{ 80 , 80 , 23 , 15 },
+{ 80 , 80 , 23 , 16 },
+{ 80 , 80 , 23 , 17 },
+{ 80 , 80 , 23 , 18 },
+{ 80 , 80 , 23 , 19 },
+{ 80 , 80 , 23 , 20 },
+{ 80 , 80 , 23 , 21 },
+{ 80 , 80 , 23 , 22 },
+{ 80 , 80 , 23 , 23 },
+{ 80 , 80 , 23 , 24 },
+{ 80 , 80 , 23 , 25 },
+{ 80 , 80 , 23 , 26 },
+{ 80 , 80 , 23 , 27 },
+{ 80 , 80 , 23 , 28 },
+{ 80 , 80 , 23 , 29 },
+{ 80 , 80 , 23 , 30 },
+{ 80 , 80 , 23 , 31 },
+{ 80 , 80 , 23 , 32 },
+{ 80 , 80 , 23 , 33 },
+{ 80 , 80 , 23 , 34 },
+{ 80 , 80 , 23 , 35 },
+{ 80 , 80 , 23 , 36 },
+{ 80 , 80 , 23 , 37 },
+{ 80 , 80 , 23 , 38 },
+{ 80 , 80 , 23 , 39 },
+{ 80 , 80 , 23 , 40 },
+{ 80 , 80 , 23 , 41 },
+{ 80 , 80 , 23 , 42 },
+{ 80 , 80 , 23 , 43 },
+{ 80 , 80 , 23 , 44 },
+{ 80 , 80 , 23 , 45 },
+{ 80 , 80 , 23 , 46 },
+{ 80 , 80 , 23 , 47 },
+{ 80 , 80 , 23 , 48 },
+{ 80 , 80 , 23 , 49 },
+{ 80 , 80 , 23 , 50 },
+{ 80 , 80 , 23 , 51 },
+{ 80 , 80 , 23 , 52 },
+{ 80 , 80 , 23 , 53 },
+{ 80 , 80 , 23 , 54 },
+{ 80 , 80 , 23 , 55 },
+{ 80 , 80 , 23 , 56 },
+{ 80 , 80 , 23 , 57 },
+{ 80 , 80 , 23 , 58 },
+{ 80 , 80 , 23 , 59 },
+{ 80 , 80 , 23 , 60 },
+{ 80 , 80 , 23 , 61 },
+{ 80 , 80 , 23 , 62 },
+{ 80 , 80 , 23 , 63 },
+{ 80 , 80 , 23 , 64 },
+{ 80 , 80 , 23 , 65 },
+{ 80 , 80 , 23 , 66 },
+{ 80 , 80 , 23 , 67 },
+{ 80 , 80 , 23 , 68 },
+{ 80 , 80 , 23 , 69 },
+{ 80 , 80 , 23 , 70 },
+{ 80 , 80 , 23 , 71 },
+{ 80 , 80 , 23 , 72 },
+{ 80 , 80 , 23 , 73 },
+{ 80 , 80 , 23 , 74 },
+{ 80 , 80 , 23 , 75 },
+{ 80 , 80 , 23 , 76 },
+{ 80 , 80 , 23 , 77 },
+{ 80 , 80 , 23 , 78 },
+{ 80 , 80 , 23 , 79 },
+{ 80 , 80 , 24 , 0 },
+{ 80 , 80 , 24 , 1 },
+{ 80 , 80 , 24 , 2 },
+{ 80 , 80 , 24 , 3 },
+{ 80 , 80 , 24 , 4 },
+{ 80 , 80 , 24 , 5 },
+{ 80 , 80 , 24 , 6 },
+{ 80 , 80 , 24 , 7 },
+{ 80 , 80 , 24 , 8 },
+{ 80 , 80 , 24 , 9 },
+{ 80 , 80 , 24 , 10 },
+{ 80 , 80 , 24 , 11 },
+{ 80 , 80 , 24 , 12 },
+{ 80 , 80 , 24 , 13 },
+{ 80 , 80 , 24 , 14 },
+{ 80 , 80 , 24 , 15 },
+{ 80 , 80 , 24 , 16 },
+{ 80 , 80 , 24 , 17 },
+{ 80 , 80 , 24 , 18 },
+{ 80 , 80 , 24 , 19 },
+{ 80 , 80 , 24 , 20 },
+{ 80 , 80 , 24 , 21 },
+{ 80 , 80 , 24 , 22 },
+{ 80 , 80 , 24 , 23 },
+{ 80 , 80 , 24 , 24 },
+{ 80 , 80 , 24 , 25 },
+{ 80 , 80 , 24 , 26 },
+{ 80 , 80 , 24 , 27 },
+{ 80 , 80 , 24 , 28 },
+{ 80 , 80 , 24 , 29 },
+{ 80 , 80 , 24 , 30 },
+{ 80 , 80 , 24 , 31 },
+{ 80 , 80 , 24 , 32 },
+{ 80 , 80 , 24 , 33 },
+{ 80 , 80 , 24 , 34 },
+{ 80 , 80 , 24 , 35 },
+{ 80 , 80 , 24 , 36 },
+{ 80 , 80 , 24 , 37 },
+{ 80 , 80 , 24 , 38 },
+{ 80 , 80 , 24 , 39 },
+{ 80 , 80 , 24 , 40 },
+{ 80 , 80 , 24 , 41 },
+{ 80 , 80 , 24 , 42 },
+{ 80 , 80 , 24 , 43 },
+{ 80 , 80 , 24 , 44 },
+{ 80 , 80 , 24 , 45 },
+{ 80 , 80 , 24 , 46 },
+{ 80 , 80 , 24 , 47 },
+{ 80 , 80 , 24 , 48 },
+{ 80 , 80 , 24 , 49 },
+{ 80 , 80 , 24 , 50 },
+{ 80 , 80 , 24 , 51 },
+{ 80 , 80 , 24 , 52 },
+{ 80 , 80 , 24 , 53 },
+{ 80 , 80 , 24 , 54 },
+{ 80 , 80 , 24 , 55 },
+{ 80 , 80 , 24 , 56 },
+{ 80 , 80 , 24 , 57 },
+{ 80 , 80 , 24 , 58 },
+{ 80 , 80 , 24 , 59 },
+{ 80 , 80 , 24 , 60 },
+{ 80 , 80 , 24 , 61 },
+{ 80 , 80 , 24 , 62 },
+{ 80 , 80 , 24 , 63 },
+{ 80 , 80 , 24 , 64 },
+{ 80 , 80 , 24 , 65 },
+{ 80 , 80 , 24 , 66 },
+{ 80 , 80 , 24 , 67 },
+{ 80 , 80 , 24 , 68 },
+{ 80 , 80 , 24 , 69 },
+{ 80 , 80 , 24 , 70 },
+{ 80 , 80 , 24 , 71 },
+{ 80 , 80 , 24 , 72 },
+{ 80 , 80 , 24 , 73 },
+{ 80 , 80 , 24 , 74 },
+{ 80 , 80 , 24 , 75 },
+{ 80 , 80 , 24 , 76 },
+{ 80 , 80 , 24 , 77 },
+{ 80 , 80 , 24 , 78 },
+{ 80 , 80 , 24 , 79 },
+{ 80 , 80 , 25 , 0 },
+{ 80 , 80 , 25 , 1 },
+{ 80 , 80 , 25 , 2 },
+{ 80 , 80 , 25 , 3 },
+{ 80 , 80 , 25 , 4 },
+{ 80 , 80 , 25 , 5 },
+{ 80 , 80 , 25 , 6 },
+{ 80 , 80 , 25 , 7 },
+{ 80 , 80 , 25 , 8 },
+{ 80 , 80 , 25 , 9 },
+{ 80 , 80 , 25 , 10 },
+{ 80 , 80 , 25 , 11 },
+{ 80 , 80 , 25 , 12 },
+{ 80 , 80 , 25 , 13 },
+{ 80 , 80 , 25 , 14 },
+{ 80 , 80 , 25 , 15 },
+{ 80 , 80 , 25 , 16 },
+{ 80 , 80 , 25 , 17 },
+{ 80 , 80 , 25 , 18 },
+{ 80 , 80 , 25 , 19 },
+{ 80 , 80 , 25 , 20 },
+{ 80 , 80 , 25 , 21 },
+{ 80 , 80 , 25 , 22 },
+{ 80 , 80 , 25 , 23 },
+{ 80 , 80 , 25 , 24 },
+{ 80 , 80 , 25 , 25 },
+{ 80 , 80 , 25 , 26 },
+{ 80 , 80 , 25 , 27 },
+{ 80 , 80 , 25 , 28 },
+{ 80 , 80 , 25 , 29 },
+{ 80 , 80 , 25 , 30 },
+{ 80 , 80 , 25 , 31 },
+{ 80 , 80 , 25 , 32 },
+{ 80 , 80 , 25 , 33 },
+{ 80 , 80 , 25 , 34 },
+{ 80 , 80 , 25 , 35 },
+{ 80 , 80 , 25 , 36 },
+{ 80 , 80 , 25 , 37 },
+{ 80 , 80 , 25 , 38 },
+{ 80 , 80 , 25 , 39 },
+{ 80 , 80 , 25 , 40 },
+{ 80 , 80 , 25 , 41 },
+{ 80 , 80 , 25 , 42 },
+{ 80 , 80 , 25 , 43 },
+{ 80 , 80 , 25 , 44 },
+{ 80 , 80 , 25 , 45 },
+{ 80 , 80 , 25 , 46 },
+{ 80 , 80 , 25 , 47 },
+{ 80 , 80 , 25 , 48 },
+{ 80 , 80 , 25 , 49 },
+{ 80 , 80 , 25 , 50 },
+{ 80 , 80 , 25 , 51 },
+{ 80 , 80 , 25 , 52 },
+{ 80 , 80 , 25 , 53 },
+{ 80 , 80 , 25 , 54 },
+{ 80 , 80 , 25 , 55 },
+{ 80 , 80 , 25 , 56 },
+{ 80 , 80 , 25 , 57 },
+{ 80 , 80 , 25 , 58 },
+{ 80 , 80 , 25 , 59 },
+{ 80 , 80 , 25 , 60 },
+{ 80 , 80 , 25 , 61 },
+{ 80 , 80 , 25 , 62 },
+{ 80 , 80 , 25 , 63 },
+{ 80 , 80 , 25 , 64 },
+{ 80 , 80 , 25 , 65 },
+{ 80 , 80 , 25 , 66 },
+{ 80 , 80 , 25 , 67 },
+{ 80 , 80 , 25 , 68 },
+{ 80 , 80 , 25 , 69 },
+{ 80 , 80 , 25 , 70 },
+{ 80 , 80 , 25 , 71 },
+{ 80 , 80 , 25 , 72 },
+{ 80 , 80 , 25 , 73 },
+{ 80 , 80 , 25 , 74 },
+{ 80 , 80 , 25 , 75 },
+{ 80 , 80 , 25 , 76 },
+{ 80 , 80 , 25 , 77 },
+{ 80 , 80 , 25 , 78 },
+{ 80 , 80 , 25 , 79 },
+{ 80 , 80 , 26 , 0 },
+{ 80 , 80 , 26 , 1 },
+{ 80 , 80 , 26 , 2 },
+{ 80 , 80 , 26 , 3 },
+{ 80 , 80 , 26 , 4 },
+{ 80 , 80 , 26 , 5 },
+{ 80 , 80 , 26 , 6 },
+{ 80 , 80 , 26 , 7 },
+{ 80 , 80 , 26 , 8 },
+{ 80 , 80 , 26 , 9 },
+{ 80 , 80 , 26 , 10 },
+{ 80 , 80 , 26 , 11 },
+{ 80 , 80 , 26 , 12 },
+{ 80 , 80 , 26 , 13 },
+{ 80 , 80 , 26 , 14 },
+{ 80 , 80 , 26 , 15 },
+{ 80 , 80 , 26 , 16 },
+{ 80 , 80 , 26 , 17 },
+{ 80 , 80 , 26 , 18 },
+{ 80 , 80 , 26 , 19 },
+{ 80 , 80 , 26 , 20 },
+{ 80 , 80 , 26 , 21 },
+{ 80 , 80 , 26 , 22 },
+{ 80 , 80 , 26 , 23 },
+{ 80 , 80 , 26 , 24 },
+{ 80 , 80 , 26 , 25 },
+{ 80 , 80 , 26 , 26 },
+{ 80 , 80 , 26 , 27 },
+{ 80 , 80 , 26 , 28 },
+{ 80 , 80 , 26 , 29 },
+{ 80 , 80 , 26 , 30 },
+{ 80 , 80 , 26 , 31 },
+{ 80 , 80 , 26 , 32 },
+{ 80 , 80 , 26 , 33 },
+{ 80 , 80 , 26 , 34 },
+{ 80 , 80 , 26 , 35 },
+{ 80 , 80 , 26 , 36 },
+{ 80 , 80 , 26 , 37 },
+{ 80 , 80 , 26 , 38 },
+{ 80 , 80 , 26 , 39 },
+{ 80 , 80 , 26 , 40 },
+{ 80 , 80 , 26 , 41 },
+{ 80 , 80 , 26 , 42 },
+{ 80 , 80 , 26 , 43 },
+{ 80 , 80 , 26 , 44 },
+{ 80 , 80 , 26 , 45 },
+{ 80 , 80 , 26 , 46 },
+{ 80 , 80 , 26 , 47 },
+{ 80 , 80 , 26 , 48 },
+{ 80 , 80 , 26 , 49 },
+{ 80 , 80 , 26 , 50 },
+{ 80 , 80 , 26 , 51 },
+{ 80 , 80 , 26 , 52 },
+{ 80 , 80 , 26 , 53 },
+{ 80 , 80 , 26 , 54 },
+{ 80 , 80 , 26 , 55 },
+{ 80 , 80 , 26 , 56 },
+{ 80 , 80 , 26 , 57 },
+{ 80 , 80 , 26 , 58 },
+{ 80 , 80 , 26 , 59 },
+{ 80 , 80 , 26 , 60 },
+{ 80 , 80 , 26 , 61 },
+{ 80 , 80 , 26 , 62 },
+{ 80 , 80 , 26 , 63 },
+{ 80 , 80 , 26 , 64 },
+{ 80 , 80 , 26 , 65 },
+{ 80 , 80 , 26 , 66 },
+{ 80 , 80 , 26 , 67 },
+{ 80 , 80 , 26 , 68 },
+{ 80 , 80 , 26 , 69 },
+{ 80 , 80 , 26 , 70 },
+{ 80 , 80 , 26 , 71 },
+{ 80 , 80 , 26 , 72 },
+{ 80 , 80 , 26 , 73 },
+{ 80 , 80 , 26 , 74 },
+{ 80 , 80 , 26 , 75 },
+{ 80 , 80 , 26 , 76 },
+{ 80 , 80 , 26 , 77 },
+{ 80 , 80 , 26 , 78 },
+{ 80 , 80 , 26 , 79 },
+{ 80 , 80 , 27 , 0 },
+{ 80 , 80 , 27 , 1 },
+{ 80 , 80 , 27 , 2 },
+{ 80 , 80 , 27 , 3 },
+{ 80 , 80 , 27 , 4 },
+{ 80 , 80 , 27 , 5 },
+{ 80 , 80 , 27 , 6 },
+{ 80 , 80 , 27 , 7 },
+{ 80 , 80 , 27 , 8 },
+{ 80 , 80 , 27 , 9 },
+{ 80 , 80 , 27 , 10 },
+{ 80 , 80 , 27 , 11 },
+{ 80 , 80 , 27 , 12 },
+{ 80 , 80 , 27 , 13 },
+{ 80 , 80 , 27 , 14 },
+{ 80 , 80 , 27 , 15 },
+{ 80 , 80 , 27 , 16 },
+{ 80 , 80 , 27 , 17 },
+{ 80 , 80 , 27 , 18 },
+{ 80 , 80 , 27 , 19 },
+{ 80 , 80 , 27 , 20 },
+{ 80 , 80 , 27 , 21 },
+{ 80 , 80 , 27 , 22 },
+{ 80 , 80 , 27 , 23 },
+{ 80 , 80 , 27 , 24 },
+{ 80 , 80 , 27 , 25 },
+{ 80 , 80 , 27 , 26 },
+{ 80 , 80 , 27 , 27 },
+{ 80 , 80 , 27 , 28 },
+{ 80 , 80 , 27 , 29 },
+{ 80 , 80 , 27 , 30 },
+{ 80 , 80 , 27 , 31 },
+{ 80 , 80 , 27 , 32 },
+{ 80 , 80 , 27 , 33 },
+{ 80 , 80 , 27 , 34 },
+{ 80 , 80 , 27 , 35 },
+{ 80 , 80 , 27 , 36 },
+{ 80 , 80 , 27 , 37 },
+{ 80 , 80 , 27 , 38 },
+{ 80 , 80 , 27 , 39 },
+{ 80 , 80 , 27 , 40 },
+{ 80 , 80 , 27 , 41 },
+{ 80 , 80 , 27 , 42 },
+{ 80 , 80 , 27 , 43 },
+{ 80 , 80 , 27 , 44 },
+{ 80 , 80 , 27 , 45 },
+{ 80 , 80 , 27 , 46 },
+{ 80 , 80 , 27 , 47 },
+{ 80 , 80 , 27 , 48 },
+{ 80 , 80 , 27 , 49 },
+{ 80 , 80 , 27 , 50 },
+{ 80 , 80 , 27 , 51 },
+{ 80 , 80 , 27 , 52 },
+{ 80 , 80 , 27 , 53 },
+{ 80 , 80 , 27 , 54 },
+{ 80 , 80 , 27 , 55 },
+{ 80 , 80 , 27 , 56 },
+{ 80 , 80 , 27 , 57 },
+{ 80 , 80 , 27 , 58 },
+{ 80 , 80 , 27 , 59 },
+{ 80 , 80 , 27 , 60 },
+{ 80 , 80 , 27 , 61 },
+{ 80 , 80 , 27 , 62 },
+{ 80 , 80 , 27 , 63 },
+{ 80 , 80 , 27 , 64 },
+{ 80 , 80 , 27 , 65 },
+{ 80 , 80 , 27 , 66 },
+{ 80 , 80 , 27 , 67 },
+{ 80 , 80 , 27 , 68 },
+{ 80 , 80 , 27 , 69 },
+{ 80 , 80 , 27 , 70 },
+{ 80 , 80 , 27 , 71 },
+{ 80 , 80 , 27 , 72 },
+{ 80 , 80 , 27 , 73 },
+{ 80 , 80 , 27 , 74 },
+{ 80 , 80 , 27 , 75 },
+{ 80 , 80 , 27 , 76 },
+{ 80 , 80 , 27 , 77 },
+{ 80 , 80 , 27 , 78 },
+{ 80 , 80 , 27 , 79 },
+{ 80 , 80 , 28 , 0 },
+{ 80 , 80 , 28 , 1 },
+{ 80 , 80 , 28 , 2 },
+{ 80 , 80 , 28 , 3 },
+{ 80 , 80 , 28 , 4 },
+{ 80 , 80 , 28 , 5 },
+{ 80 , 80 , 28 , 6 },
+{ 80 , 80 , 28 , 7 },
+{ 80 , 80 , 28 , 8 },
+{ 80 , 80 , 28 , 9 },
+{ 80 , 80 , 28 , 10 },
+{ 80 , 80 , 28 , 11 },
+{ 80 , 80 , 28 , 12 },
+{ 80 , 80 , 28 , 13 },
+{ 80 , 80 , 28 , 14 },
+{ 80 , 80 , 28 , 15 },
+{ 80 , 80 , 28 , 16 },
+{ 80 , 80 , 28 , 17 },
+{ 80 , 80 , 28 , 18 },
+{ 80 , 80 , 28 , 19 },
+{ 80 , 80 , 28 , 20 },
+{ 80 , 80 , 28 , 21 },
+{ 80 , 80 , 28 , 22 },
+{ 80 , 80 , 28 , 23 },
+{ 80 , 80 , 28 , 24 },
+{ 80 , 80 , 28 , 25 },
+{ 80 , 80 , 28 , 26 },
+{ 80 , 80 , 28 , 27 },
+{ 80 , 80 , 28 , 28 },
+{ 80 , 80 , 28 , 29 },
+{ 80 , 80 , 28 , 30 },
+{ 80 , 80 , 28 , 31 },
+{ 80 , 80 , 28 , 32 },
+{ 80 , 80 , 28 , 33 },
+{ 80 , 80 , 28 , 34 },
+{ 80 , 80 , 28 , 35 },
+{ 80 , 80 , 28 , 36 },
+{ 80 , 80 , 28 , 37 },
+{ 80 , 80 , 28 , 38 },
+{ 80 , 80 , 28 , 39 },
+{ 80 , 80 , 28 , 40 },
+{ 80 , 80 , 28 , 41 },
+{ 80 , 80 , 28 , 42 },
+{ 80 , 80 , 28 , 43 },
+{ 80 , 80 , 28 , 44 },
+{ 80 , 80 , 28 , 45 },
+{ 80 , 80 , 28 , 46 },
+{ 80 , 80 , 28 , 47 },
+{ 80 , 80 , 28 , 48 },
+{ 80 , 80 , 28 , 49 },
+{ 80 , 80 , 28 , 50 },
+{ 80 , 80 , 28 , 51 },
+{ 80 , 80 , 28 , 52 },
+{ 80 , 80 , 28 , 53 },
+{ 80 , 80 , 28 , 54 },
+{ 80 , 80 , 28 , 55 },
+{ 80 , 80 , 28 , 56 },
+{ 80 , 80 , 28 , 57 },
+{ 80 , 80 , 28 , 58 },
+{ 80 , 80 , 28 , 59 },
+{ 80 , 80 , 28 , 60 },
+{ 80 , 80 , 28 , 61 },
+{ 80 , 80 , 28 , 62 },
+{ 80 , 80 , 28 , 63 },
+{ 80 , 80 , 28 , 64 },
+{ 80 , 80 , 28 , 65 },
+{ 80 , 80 , 28 , 66 },
+{ 80 , 80 , 28 , 67 },
+{ 80 , 80 , 28 , 68 },
+{ 80 , 80 , 28 , 69 },
+{ 80 , 80 , 28 , 70 },
+{ 80 , 80 , 28 , 71 },
+{ 80 , 80 , 28 , 72 },
+{ 80 , 80 , 28 , 73 },
+{ 80 , 80 , 28 , 74 },
+{ 80 , 80 , 28 , 75 },
+{ 80 , 80 , 28 , 76 },
+{ 80 , 80 , 28 , 77 },
+{ 80 , 80 , 28 , 78 },
+{ 80 , 80 , 28 , 79 },
+{ 80 , 80 , 29 , 0 },
+{ 80 , 80 , 29 , 1 },
+{ 80 , 80 , 29 , 2 },
+{ 80 , 80 , 29 , 3 },
+{ 80 , 80 , 29 , 4 },
+{ 80 , 80 , 29 , 5 },
+{ 80 , 80 , 29 , 6 },
+{ 80 , 80 , 29 , 7 },
+{ 80 , 80 , 29 , 8 },
+{ 80 , 80 , 29 , 9 },
+{ 80 , 80 , 29 , 10 },
+{ 80 , 80 , 29 , 11 },
+{ 80 , 80 , 29 , 12 },
+{ 80 , 80 , 29 , 13 },
+{ 80 , 80 , 29 , 14 },
+{ 80 , 80 , 29 , 15 },
+{ 80 , 80 , 29 , 16 },
+{ 80 , 80 , 29 , 17 },
+{ 80 , 80 , 29 , 18 },
+{ 80 , 80 , 29 , 19 },
+{ 80 , 80 , 29 , 20 },
+{ 80 , 80 , 29 , 21 },
+{ 80 , 80 , 29 , 22 },
+{ 80 , 80 , 29 , 23 },
+{ 80 , 80 , 29 , 24 },
+{ 80 , 80 , 29 , 25 },
+{ 80 , 80 , 29 , 26 },
+{ 80 , 80 , 29 , 27 },
+{ 80 , 80 , 29 , 28 },
+{ 80 , 80 , 29 , 29 },
+{ 80 , 80 , 29 , 30 },
+{ 80 , 80 , 29 , 31 },
+{ 80 , 80 , 29 , 32 },
+{ 80 , 80 , 29 , 33 },
+{ 80 , 80 , 29 , 34 },
+{ 80 , 80 , 29 , 35 },
+{ 80 , 80 , 29 , 36 },
+{ 80 , 80 , 29 , 37 },
+{ 80 , 80 , 29 , 38 },
+{ 80 , 80 , 29 , 39 },
+{ 80 , 80 , 29 , 40 },
+{ 80 , 80 , 29 , 41 },
+{ 80 , 80 , 29 , 42 },
+{ 80 , 80 , 29 , 43 },
+{ 80 , 80 , 29 , 44 },
+{ 80 , 80 , 29 , 45 },
+{ 80 , 80 , 29 , 46 },
+{ 80 , 80 , 29 , 47 },
+{ 80 , 80 , 29 , 48 },
+{ 80 , 80 , 29 , 49 },
+{ 80 , 80 , 29 , 50 },
+{ 80 , 80 , 29 , 51 },
+{ 80 , 80 , 29 , 52 },
+{ 80 , 80 , 29 , 53 },
+{ 80 , 80 , 29 , 54 },
+{ 80 , 80 , 29 , 55 },
+{ 80 , 80 , 29 , 56 },
+{ 80 , 80 , 29 , 57 },
+{ 80 , 80 , 29 , 58 },
+{ 80 , 80 , 29 , 59 },
+{ 80 , 80 , 29 , 60 },
+{ 80 , 80 , 29 , 61 },
+{ 80 , 80 , 29 , 62 },
+{ 80 , 80 , 29 , 63 },
+{ 80 , 80 , 29 , 64 },
+{ 80 , 80 , 29 , 65 },
+{ 80 , 80 , 29 , 66 },
+{ 80 , 80 , 29 , 67 },
+{ 80 , 80 , 29 , 68 },
+{ 80 , 80 , 29 , 69 },
+{ 80 , 80 , 29 , 70 },
+{ 80 , 80 , 29 , 71 },
+{ 80 , 80 , 29 , 72 },
+{ 80 , 80 , 29 , 73 },
+{ 80 , 80 , 29 , 74 },
+{ 80 , 80 , 29 , 75 },
+{ 80 , 80 , 29 , 76 },
+{ 80 , 80 , 29 , 77 },
+{ 80 , 80 , 29 , 78 },
+{ 80 , 80 , 29 , 79 },
+{ 80 , 80 , 30 , 0 },
+{ 80 , 80 , 30 , 1 },
+{ 80 , 80 , 30 , 2 },
+{ 80 , 80 , 30 , 3 },
+{ 80 , 80 , 30 , 4 },
+{ 80 , 80 , 30 , 5 },
+{ 80 , 80 , 30 , 6 },
+{ 80 , 80 , 30 , 7 },
+{ 80 , 80 , 30 , 8 },
+{ 80 , 80 , 30 , 9 },
+{ 80 , 80 , 30 , 10 },
+{ 80 , 80 , 30 , 11 },
+{ 80 , 80 , 30 , 12 },
+{ 80 , 80 , 30 , 13 },
+{ 80 , 80 , 30 , 14 },
+{ 80 , 80 , 30 , 15 },
+{ 80 , 80 , 30 , 16 },
+{ 80 , 80 , 30 , 17 },
+{ 80 , 80 , 30 , 18 },
+{ 80 , 80 , 30 , 19 },
+{ 80 , 80 , 30 , 20 },
+{ 80 , 80 , 30 , 21 },
+{ 80 , 80 , 30 , 22 },
+{ 80 , 80 , 30 , 23 },
+{ 80 , 80 , 30 , 24 },
+{ 80 , 80 , 30 , 25 },
+{ 80 , 80 , 30 , 26 },
+{ 80 , 80 , 30 , 27 },
+{ 80 , 80 , 30 , 28 },
+{ 80 , 80 , 30 , 29 },
+{ 80 , 80 , 30 , 30 },
+{ 80 , 80 , 30 , 31 },
+{ 80 , 80 , 30 , 32 },
+{ 80 , 80 , 30 , 33 },
+{ 80 , 80 , 30 , 34 },
+{ 80 , 80 , 30 , 35 },
+{ 80 , 80 , 30 , 36 },
+{ 80 , 80 , 30 , 37 },
+{ 80 , 80 , 30 , 38 },
+{ 80 , 80 , 30 , 39 },
+{ 80 , 80 , 30 , 40 },
+{ 80 , 80 , 30 , 41 },
+{ 80 , 80 , 30 , 42 },
+{ 80 , 80 , 30 , 43 },
+{ 80 , 80 , 30 , 44 },
+{ 80 , 80 , 30 , 45 },
+{ 80 , 80 , 30 , 46 },
+{ 80 , 80 , 30 , 47 },
+{ 80 , 80 , 30 , 48 },
+{ 80 , 80 , 30 , 49 },
+{ 80 , 80 , 30 , 50 },
+{ 80 , 80 , 30 , 51 },
+{ 80 , 80 , 30 , 52 },
+{ 80 , 80 , 30 , 53 },
+{ 80 , 80 , 30 , 54 },
+{ 80 , 80 , 30 , 55 },
+{ 80 , 80 , 30 , 56 },
+{ 80 , 80 , 30 , 57 },
+{ 80 , 80 , 30 , 58 },
+{ 80 , 80 , 30 , 59 },
+{ 80 , 80 , 30 , 60 },
+{ 80 , 80 , 30 , 61 },
+{ 80 , 80 , 30 , 62 },
+{ 80 , 80 , 30 , 63 },
+{ 80 , 80 , 30 , 64 },
+{ 80 , 80 , 30 , 65 },
+{ 80 , 80 , 30 , 66 },
+{ 80 , 80 , 30 , 67 },
+{ 80 , 80 , 30 , 68 },
+{ 80 , 80 , 30 , 69 },
+{ 80 , 80 , 30 , 70 },
+{ 80 , 80 , 30 , 71 },
+{ 80 , 80 , 30 , 72 },
+{ 80 , 80 , 30 , 73 },
+{ 80 , 80 , 30 , 74 },
+{ 80 , 80 , 30 , 75 },
+{ 80 , 80 , 30 , 76 },
+{ 80 , 80 , 30 , 77 },
+{ 80 , 80 , 30 , 78 },
+{ 80 , 80 , 30 , 79 },
+{ 80 , 80 , 31 , 0 },
+{ 80 , 80 , 31 , 1 },
+{ 80 , 80 , 31 , 2 },
+{ 80 , 80 , 31 , 3 },
+{ 80 , 80 , 31 , 4 },
+{ 80 , 80 , 31 , 5 },
+{ 80 , 80 , 31 , 6 },
+{ 80 , 80 , 31 , 7 },
+{ 80 , 80 , 31 , 8 },
+{ 80 , 80 , 31 , 9 },
+{ 80 , 80 , 31 , 10 },
+{ 80 , 80 , 31 , 11 },
+{ 80 , 80 , 31 , 12 },
+{ 80 , 80 , 31 , 13 },
+{ 80 , 80 , 31 , 14 },
+{ 80 , 80 , 31 , 15 },
+{ 80 , 80 , 31 , 16 },
+{ 80 , 80 , 31 , 17 },
+{ 80 , 80 , 31 , 18 },
+{ 80 , 80 , 31 , 19 },
+{ 80 , 80 , 31 , 20 },
+{ 80 , 80 , 31 , 21 },
+{ 80 , 80 , 31 , 22 },
+{ 80 , 80 , 31 , 23 },
+{ 80 , 80 , 31 , 24 },
+{ 80 , 80 , 31 , 25 },
+{ 80 , 80 , 31 , 26 },
+{ 80 , 80 , 31 , 27 },
+{ 80 , 80 , 31 , 28 },
+{ 80 , 80 , 31 , 29 },
+{ 80 , 80 , 31 , 30 },
+{ 80 , 80 , 31 , 31 },
+{ 80 , 80 , 31 , 32 },
+{ 80 , 80 , 31 , 33 },
+{ 80 , 80 , 31 , 34 },
+{ 80 , 80 , 31 , 35 },
+{ 80 , 80 , 31 , 36 },
+{ 80 , 80 , 31 , 37 },
+{ 80 , 80 , 31 , 38 },
+{ 80 , 80 , 31 , 39 },
+{ 80 , 80 , 31 , 40 },
+{ 80 , 80 , 31 , 41 },
+{ 80 , 80 , 31 , 42 },
+{ 80 , 80 , 31 , 43 },
+{ 80 , 80 , 31 , 44 },
+{ 80 , 80 , 31 , 45 },
+{ 80 , 80 , 31 , 46 },
+{ 80 , 80 , 31 , 47 },
+{ 80 , 80 , 31 , 48 },
+{ 80 , 80 , 31 , 49 },
+{ 80 , 80 , 31 , 50 },
+{ 80 , 80 , 31 , 51 },
+{ 80 , 80 , 31 , 52 },
+{ 80 , 80 , 31 , 53 },
+{ 80 , 80 , 31 , 54 },
+{ 80 , 80 , 31 , 55 },
+{ 80 , 80 , 31 , 56 },
+{ 80 , 80 , 31 , 57 },
+{ 80 , 80 , 31 , 58 },
+{ 80 , 80 , 31 , 59 },
+{ 80 , 80 , 31 , 60 },
+{ 80 , 80 , 31 , 61 },
+{ 80 , 80 , 31 , 62 },
+{ 80 , 80 , 31 , 63 },
+{ 80 , 80 , 31 , 64 },
+{ 80 , 80 , 31 , 65 },
+{ 80 , 80 , 31 , 66 },
+{ 80 , 80 , 31 , 67 },
+{ 80 , 80 , 31 , 68 },
+{ 80 , 80 , 31 , 69 },
+{ 80 , 80 , 31 , 70 },
+{ 80 , 80 , 31 , 71 },
+{ 80 , 80 , 31 , 72 },
+{ 80 , 80 , 31 , 73 },
+{ 80 , 80 , 31 , 74 },
+{ 80 , 80 , 31 , 75 },
+{ 80 , 80 , 31 , 76 },
+{ 80 , 80 , 31 , 77 },
+{ 80 , 80 , 31 , 78 },
+{ 80 , 80 , 31 , 79 },
+{ 80 , 80 , 32 , 0 },
+{ 80 , 80 , 32 , 1 },
+{ 80 , 80 , 32 , 2 },
+{ 80 , 80 , 32 , 3 },
+{ 80 , 80 , 32 , 4 },
+{ 80 , 80 , 32 , 5 },
+{ 80 , 80 , 32 , 6 },
+{ 80 , 80 , 32 , 7 },
+{ 80 , 80 , 32 , 8 },
+{ 80 , 80 , 32 , 9 },
+{ 80 , 80 , 32 , 10 },
+{ 80 , 80 , 32 , 11 },
+{ 80 , 80 , 32 , 12 },
+{ 80 , 80 , 32 , 13 },
+{ 80 , 80 , 32 , 14 },
+{ 80 , 80 , 32 , 15 },
+{ 80 , 80 , 32 , 16 },
+{ 80 , 80 , 32 , 17 },
+{ 80 , 80 , 32 , 18 },
+{ 80 , 80 , 32 , 19 },
+{ 80 , 80 , 32 , 20 },
+{ 80 , 80 , 32 , 21 },
+{ 80 , 80 , 32 , 22 },
+{ 80 , 80 , 32 , 23 },
+{ 80 , 80 , 32 , 24 },
+{ 80 , 80 , 32 , 25 },
+{ 80 , 80 , 32 , 26 },
+{ 80 , 80 , 32 , 27 },
+{ 80 , 80 , 32 , 28 },
+{ 80 , 80 , 32 , 29 },
+{ 80 , 80 , 32 , 30 },
+{ 80 , 80 , 32 , 31 },
+{ 80 , 80 , 32 , 32 },
+{ 80 , 80 , 32 , 33 },
+{ 80 , 80 , 32 , 34 },
+{ 80 , 80 , 32 , 35 },
+{ 80 , 80 , 32 , 36 },
+{ 80 , 80 , 32 , 37 },
+{ 80 , 80 , 32 , 38 },
+{ 80 , 80 , 32 , 39 },
+{ 80 , 80 , 32 , 40 },
+{ 80 , 80 , 32 , 41 },
+{ 80 , 80 , 32 , 42 },
+{ 80 , 80 , 32 , 43 },
+{ 80 , 80 , 32 , 44 },
+{ 80 , 80 , 32 , 45 },
+{ 80 , 80 , 32 , 46 },
+{ 80 , 80 , 32 , 47 },
+{ 80 , 80 , 32 , 48 },
+{ 80 , 80 , 32 , 49 },
+{ 80 , 80 , 32 , 50 },
+{ 80 , 80 , 32 , 51 },
+{ 80 , 80 , 32 , 52 },
+{ 80 , 80 , 32 , 53 },
+{ 80 , 80 , 32 , 54 },
+{ 80 , 80 , 32 , 55 },
+{ 80 , 80 , 32 , 56 },
+{ 80 , 80 , 32 , 57 },
+{ 80 , 80 , 32 , 58 },
+{ 80 , 80 , 32 , 59 },
+{ 80 , 80 , 32 , 60 },
+{ 80 , 80 , 32 , 61 },
+{ 80 , 80 , 32 , 62 },
+{ 80 , 80 , 32 , 63 },
+{ 80 , 80 , 32 , 64 },
+{ 80 , 80 , 32 , 65 },
+{ 80 , 80 , 32 , 66 },
+{ 80 , 80 , 32 , 67 },
+{ 80 , 80 , 32 , 68 },
+{ 80 , 80 , 32 , 69 },
+{ 80 , 80 , 32 , 70 },
+{ 80 , 80 , 32 , 71 },
+{ 80 , 80 , 32 , 72 },
+{ 80 , 80 , 32 , 73 },
+{ 80 , 80 , 32 , 74 },
+{ 80 , 80 , 32 , 75 },
+{ 80 , 80 , 32 , 76 },
+{ 80 , 80 , 32 , 77 },
+{ 80 , 80 , 32 , 78 },
+{ 80 , 80 , 32 , 79 },
+{ 80 , 80 , 33 , 0 },
+{ 80 , 80 , 33 , 1 },
+{ 80 , 80 , 33 , 2 },
+{ 80 , 80 , 33 , 3 },
+{ 80 , 80 , 33 , 4 },
+{ 80 , 80 , 33 , 5 },
+{ 80 , 80 , 33 , 6 },
+{ 80 , 80 , 33 , 7 },
+{ 80 , 80 , 33 , 8 },
+{ 80 , 80 , 33 , 9 },
+{ 80 , 80 , 33 , 10 },
+{ 80 , 80 , 33 , 11 },
+{ 80 , 80 , 33 , 12 },
+{ 80 , 80 , 33 , 13 },
+{ 80 , 80 , 33 , 14 },
+{ 80 , 80 , 33 , 15 },
+{ 80 , 80 , 33 , 16 },
+{ 80 , 80 , 33 , 17 },
+{ 80 , 80 , 33 , 18 },
+{ 80 , 80 , 33 , 19 },
+{ 80 , 80 , 33 , 20 },
+{ 80 , 80 , 33 , 21 },
+{ 80 , 80 , 33 , 22 },
+{ 80 , 80 , 33 , 23 },
+{ 80 , 80 , 33 , 24 },
+{ 80 , 80 , 33 , 25 },
+{ 80 , 80 , 33 , 26 },
+{ 80 , 80 , 33 , 27 },
+{ 80 , 80 , 33 , 28 },
+{ 80 , 80 , 33 , 29 },
+{ 80 , 80 , 33 , 30 },
+{ 80 , 80 , 33 , 31 },
+{ 80 , 80 , 33 , 32 },
+{ 80 , 80 , 33 , 33 },
+{ 80 , 80 , 33 , 34 },
+{ 80 , 80 , 33 , 35 },
+{ 80 , 80 , 33 , 36 },
+{ 80 , 80 , 33 , 37 },
+{ 80 , 80 , 33 , 38 },
+{ 80 , 80 , 33 , 39 },
+{ 80 , 80 , 33 , 40 },
+{ 80 , 80 , 33 , 41 },
+{ 80 , 80 , 33 , 42 },
+{ 80 , 80 , 33 , 43 },
+{ 80 , 80 , 33 , 44 },
+{ 80 , 80 , 33 , 45 },
+{ 80 , 80 , 33 , 46 },
+{ 80 , 80 , 33 , 47 },
+{ 80 , 80 , 33 , 48 },
+{ 80 , 80 , 33 , 49 },
+{ 80 , 80 , 33 , 50 },
+{ 80 , 80 , 33 , 51 },
+{ 80 , 80 , 33 , 52 },
+{ 80 , 80 , 33 , 53 },
+{ 80 , 80 , 33 , 54 },
+{ 80 , 80 , 33 , 55 },
+{ 80 , 80 , 33 , 56 },
+{ 80 , 80 , 33 , 57 },
+{ 80 , 80 , 33 , 58 },
+{ 80 , 80 , 33 , 59 },
+{ 80 , 80 , 33 , 60 },
+{ 80 , 80 , 33 , 61 },
+{ 80 , 80 , 33 , 62 },
+{ 80 , 80 , 33 , 63 },
+{ 80 , 80 , 33 , 64 },
+{ 80 , 80 , 33 , 65 },
+{ 80 , 80 , 33 , 66 },
+{ 80 , 80 , 33 , 67 },
+{ 80 , 80 , 33 , 68 },
+{ 80 , 80 , 33 , 69 },
+{ 80 , 80 , 33 , 70 },
+{ 80 , 80 , 33 , 71 },
+{ 80 , 80 , 33 , 72 },
+{ 80 , 80 , 33 , 73 },
+{ 80 , 80 , 33 , 74 },
+{ 80 , 80 , 33 , 75 },
+{ 80 , 80 , 33 , 76 },
+{ 80 , 80 , 33 , 77 },
+{ 80 , 80 , 33 , 78 },
+{ 80 , 80 , 33 , 79 },
+{ 80 , 80 , 34 , 0 },
+{ 80 , 80 , 34 , 1 },
+{ 80 , 80 , 34 , 2 },
+{ 80 , 80 , 34 , 3 },
+{ 80 , 80 , 34 , 4 },
+{ 80 , 80 , 34 , 5 },
+{ 80 , 80 , 34 , 6 },
+{ 80 , 80 , 34 , 7 },
+{ 80 , 80 , 34 , 8 },
+{ 80 , 80 , 34 , 9 },
+{ 80 , 80 , 34 , 10 },
+{ 80 , 80 , 34 , 11 },
+{ 80 , 80 , 34 , 12 },
+{ 80 , 80 , 34 , 13 },
+{ 80 , 80 , 34 , 14 },
+{ 80 , 80 , 34 , 15 },
+{ 80 , 80 , 34 , 16 },
+{ 80 , 80 , 34 , 17 },
+{ 80 , 80 , 34 , 18 },
+{ 80 , 80 , 34 , 19 },
+{ 80 , 80 , 34 , 20 },
+{ 80 , 80 , 34 , 21 },
+{ 80 , 80 , 34 , 22 },
+{ 80 , 80 , 34 , 23 },
+{ 80 , 80 , 34 , 24 },
+{ 80 , 80 , 34 , 25 },
+{ 80 , 80 , 34 , 26 },
+{ 80 , 80 , 34 , 27 },
+{ 80 , 80 , 34 , 28 },
+{ 80 , 80 , 34 , 29 },
+{ 80 , 80 , 34 , 30 },
+{ 80 , 80 , 34 , 31 },
+{ 80 , 80 , 34 , 32 },
+{ 80 , 80 , 34 , 33 },
+{ 80 , 80 , 34 , 34 },
+{ 80 , 80 , 34 , 35 },
+{ 80 , 80 , 34 , 36 },
+{ 80 , 80 , 34 , 37 },
+{ 80 , 80 , 34 , 38 },
+{ 80 , 80 , 34 , 39 },
+{ 80 , 80 , 34 , 40 },
+{ 80 , 80 , 34 , 41 },
+{ 80 , 80 , 34 , 42 },
+{ 80 , 80 , 34 , 43 },
+{ 80 , 80 , 34 , 44 },
+{ 80 , 80 , 34 , 45 },
+{ 80 , 80 , 34 , 46 },
+{ 80 , 80 , 34 , 47 },
+{ 80 , 80 , 34 , 48 },
+{ 80 , 80 , 34 , 49 },
+{ 80 , 80 , 34 , 50 },
+{ 80 , 80 , 34 , 51 },
+{ 80 , 80 , 34 , 52 },
+{ 80 , 80 , 34 , 53 },
+{ 80 , 80 , 34 , 54 },
+{ 80 , 80 , 34 , 55 },
+{ 80 , 80 , 34 , 56 },
+{ 80 , 80 , 34 , 57 },
+{ 80 , 80 , 34 , 58 },
+{ 80 , 80 , 34 , 59 },
+{ 80 , 80 , 34 , 60 },
+{ 80 , 80 , 34 , 61 },
+{ 80 , 80 , 34 , 62 },
+{ 80 , 80 , 34 , 63 },
+{ 80 , 80 , 34 , 64 },
+{ 80 , 80 , 34 , 65 },
+{ 80 , 80 , 34 , 66 },
+{ 80 , 80 , 34 , 67 },
+{ 80 , 80 , 34 , 68 },
+{ 80 , 80 , 34 , 69 },
+{ 80 , 80 , 34 , 70 },
+{ 80 , 80 , 34 , 71 },
+{ 80 , 80 , 34 , 72 },
+{ 80 , 80 , 34 , 73 },
+{ 80 , 80 , 34 , 74 },
+{ 80 , 80 , 34 , 75 },
+{ 80 , 80 , 34 , 76 },
+{ 80 , 80 , 34 , 77 },
+{ 80 , 80 , 34 , 78 },
+{ 80 , 80 , 34 , 79 },
+{ 80 , 80 , 35 , 0 },
+{ 80 , 80 , 35 , 1 },
+{ 80 , 80 , 35 , 2 },
+{ 80 , 80 , 35 , 3 },
+{ 80 , 80 , 35 , 4 },
+{ 80 , 80 , 35 , 5 },
+{ 80 , 80 , 35 , 6 },
+{ 80 , 80 , 35 , 7 },
+{ 80 , 80 , 35 , 8 },
+{ 80 , 80 , 35 , 9 },
+{ 80 , 80 , 35 , 10 },
+{ 80 , 80 , 35 , 11 },
+{ 80 , 80 , 35 , 12 },
+{ 80 , 80 , 35 , 13 },
+{ 80 , 80 , 35 , 14 },
+{ 80 , 80 , 35 , 15 },
+{ 80 , 80 , 35 , 16 },
+{ 80 , 80 , 35 , 17 },
+{ 80 , 80 , 35 , 18 },
+{ 80 , 80 , 35 , 19 },
+{ 80 , 80 , 35 , 20 },
+{ 80 , 80 , 35 , 21 },
+{ 80 , 80 , 35 , 22 },
+{ 80 , 80 , 35 , 23 },
+{ 80 , 80 , 35 , 24 },
+{ 80 , 80 , 35 , 25 },
+{ 80 , 80 , 35 , 26 },
+{ 80 , 80 , 35 , 27 },
+{ 80 , 80 , 35 , 28 },
+{ 80 , 80 , 35 , 29 },
+{ 80 , 80 , 35 , 30 },
+{ 80 , 80 , 35 , 31 },
+{ 80 , 80 , 35 , 32 },
+{ 80 , 80 , 35 , 33 },
+{ 80 , 80 , 35 , 34 },
+{ 80 , 80 , 35 , 35 },
+{ 80 , 80 , 35 , 36 },
+{ 80 , 80 , 35 , 37 },
+{ 80 , 80 , 35 , 38 },
+{ 80 , 80 , 35 , 39 },
+{ 80 , 80 , 35 , 40 },
+{ 80 , 80 , 35 , 41 },
+{ 80 , 80 , 35 , 42 },
+{ 80 , 80 , 35 , 43 },
+{ 80 , 80 , 35 , 44 },
+{ 80 , 80 , 35 , 45 },
+{ 80 , 80 , 35 , 46 },
+{ 80 , 80 , 35 , 47 },
+{ 80 , 80 , 35 , 48 },
+{ 80 , 80 , 35 , 49 },
+{ 80 , 80 , 35 , 50 },
+{ 80 , 80 , 35 , 51 },
+{ 80 , 80 , 35 , 52 },
+{ 80 , 80 , 35 , 53 },
+{ 80 , 80 , 35 , 54 },
+{ 80 , 80 , 35 , 55 },
+{ 80 , 80 , 35 , 56 },
+{ 80 , 80 , 35 , 57 },
+{ 80 , 80 , 35 , 58 },
+{ 80 , 80 , 35 , 59 },
+{ 80 , 80 , 35 , 60 },
+{ 80 , 80 , 35 , 61 },
+{ 80 , 80 , 35 , 62 },
+{ 80 , 80 , 35 , 63 },
+{ 80 , 80 , 35 , 64 },
+{ 80 , 80 , 35 , 65 },
+{ 80 , 80 , 35 , 66 },
+{ 80 , 80 , 35 , 67 },
+{ 80 , 80 , 35 , 68 },
+{ 80 , 80 , 35 , 69 },
+{ 80 , 80 , 35 , 70 },
+{ 80 , 80 , 35 , 71 },
+{ 80 , 80 , 35 , 72 },
+{ 80 , 80 , 35 , 73 },
+{ 80 , 80 , 35 , 74 },
+{ 80 , 80 , 35 , 75 },
+{ 80 , 80 , 35 , 76 },
+{ 80 , 80 , 35 , 77 },
+{ 80 , 80 , 35 , 78 },
+{ 80 , 80 , 35 , 79 },
+{ 80 , 80 , 36 , 0 },
+{ 80 , 80 , 36 , 1 },
+{ 80 , 80 , 36 , 2 },
+{ 80 , 80 , 36 , 3 },
+{ 80 , 80 , 36 , 4 },
+{ 80 , 80 , 36 , 5 },
+{ 80 , 80 , 36 , 6 },
+{ 80 , 80 , 36 , 7 },
+{ 80 , 80 , 36 , 8 },
+{ 80 , 80 , 36 , 9 },
+{ 80 , 80 , 36 , 10 },
+{ 80 , 80 , 36 , 11 },
+{ 80 , 80 , 36 , 12 },
+{ 80 , 80 , 36 , 13 },
+{ 80 , 80 , 36 , 14 },
+{ 80 , 80 , 36 , 15 },
+{ 80 , 80 , 36 , 16 },
+{ 80 , 80 , 36 , 17 },
+{ 80 , 80 , 36 , 18 },
+{ 80 , 80 , 36 , 19 },
+{ 80 , 80 , 36 , 20 },
+{ 80 , 80 , 36 , 21 },
+{ 80 , 80 , 36 , 22 },
+{ 80 , 80 , 36 , 23 },
+{ 80 , 80 , 36 , 24 },
+{ 80 , 80 , 36 , 25 },
+{ 80 , 80 , 36 , 26 },
+{ 80 , 80 , 36 , 27 },
+{ 80 , 80 , 36 , 28 },
+{ 80 , 80 , 36 , 29 },
+{ 80 , 80 , 36 , 30 },
+{ 80 , 80 , 36 , 31 },
+{ 80 , 80 , 36 , 32 },
+{ 80 , 80 , 36 , 33 },
+{ 80 , 80 , 36 , 34 },
+{ 80 , 80 , 36 , 35 },
+{ 80 , 80 , 36 , 36 },
+{ 80 , 80 , 36 , 37 },
+{ 80 , 80 , 36 , 38 },
+{ 80 , 80 , 36 , 39 },
+{ 80 , 80 , 36 , 40 },
+{ 80 , 80 , 36 , 41 },
+{ 80 , 80 , 36 , 42 },
+{ 80 , 80 , 36 , 43 },
+{ 80 , 80 , 36 , 44 },
+{ 80 , 80 , 36 , 45 },
+{ 80 , 80 , 36 , 46 },
+{ 80 , 80 , 36 , 47 },
+{ 80 , 80 , 36 , 48 },
+{ 80 , 80 , 36 , 49 },
+{ 80 , 80 , 36 , 50 },
+{ 80 , 80 , 36 , 51 },
+{ 80 , 80 , 36 , 52 },
+{ 80 , 80 , 36 , 53 },
+{ 80 , 80 , 36 , 54 },
+{ 80 , 80 , 36 , 55 },
+{ 80 , 80 , 36 , 56 },
+{ 80 , 80 , 36 , 57 },
+{ 80 , 80 , 36 , 58 },
+{ 80 , 80 , 36 , 59 },
+{ 80 , 80 , 36 , 60 },
+{ 80 , 80 , 36 , 61 },
+{ 80 , 80 , 36 , 62 },
+{ 80 , 80 , 36 , 63 },
+{ 80 , 80 , 36 , 64 },
+{ 80 , 80 , 36 , 65 },
+{ 80 , 80 , 36 , 66 },
+{ 80 , 80 , 36 , 67 },
+{ 80 , 80 , 36 , 68 },
+{ 80 , 80 , 36 , 69 },
+{ 80 , 80 , 36 , 70 },
+{ 80 , 80 , 36 , 71 },
+{ 80 , 80 , 36 , 72 },
+{ 80 , 80 , 36 , 73 },
+{ 80 , 80 , 36 , 74 },
+{ 80 , 80 , 36 , 75 },
+{ 80 , 80 , 36 , 76 },
+{ 80 , 80 , 36 , 77 },
+{ 80 , 80 , 36 , 78 },
+{ 80 , 80 , 36 , 79 },
+{ 80 , 80 , 37 , 0 },
+{ 80 , 80 , 37 , 1 },
+{ 80 , 80 , 37 , 2 },
+{ 80 , 80 , 37 , 3 },
+{ 80 , 80 , 37 , 4 },
+{ 80 , 80 , 37 , 5 },
+{ 80 , 80 , 37 , 6 },
+{ 80 , 80 , 37 , 7 },
+{ 80 , 80 , 37 , 8 },
+{ 80 , 80 , 37 , 9 },
+{ 80 , 80 , 37 , 10 },
+{ 80 , 80 , 37 , 11 },
+{ 80 , 80 , 37 , 12 },
+{ 80 , 80 , 37 , 13 },
+{ 80 , 80 , 37 , 14 },
+{ 80 , 80 , 37 , 15 },
+{ 80 , 80 , 37 , 16 },
+{ 80 , 80 , 37 , 17 },
+{ 80 , 80 , 37 , 18 },
+{ 80 , 80 , 37 , 19 },
+{ 80 , 80 , 37 , 20 },
+{ 80 , 80 , 37 , 21 },
+{ 80 , 80 , 37 , 22 },
+{ 80 , 80 , 37 , 23 },
+{ 80 , 80 , 37 , 24 },
+{ 80 , 80 , 37 , 25 },
+{ 80 , 80 , 37 , 26 },
+{ 80 , 80 , 37 , 27 },
+{ 80 , 80 , 37 , 28 },
+{ 80 , 80 , 37 , 29 },
+{ 80 , 80 , 37 , 30 },
+{ 80 , 80 , 37 , 31 },
+{ 80 , 80 , 37 , 32 },
+{ 80 , 80 , 37 , 33 },
+{ 80 , 80 , 37 , 34 },
+{ 80 , 80 , 37 , 35 },
+{ 80 , 80 , 37 , 36 },
+{ 80 , 80 , 37 , 37 },
+{ 80 , 80 , 37 , 38 },
+{ 80 , 80 , 37 , 39 },
+{ 80 , 80 , 37 , 40 },
+{ 80 , 80 , 37 , 41 },
+{ 80 , 80 , 37 , 42 },
+{ 80 , 80 , 37 , 43 },
+{ 80 , 80 , 37 , 44 },
+{ 80 , 80 , 37 , 45 },
+{ 80 , 80 , 37 , 46 },
+{ 80 , 80 , 37 , 47 },
+{ 80 , 80 , 37 , 48 },
+{ 80 , 80 , 37 , 49 },
+{ 80 , 80 , 37 , 50 },
+{ 80 , 80 , 37 , 51 },
+{ 80 , 80 , 37 , 52 },
+{ 80 , 80 , 37 , 53 },
+{ 80 , 80 , 37 , 54 },
+{ 80 , 80 , 37 , 55 },
+{ 80 , 80 , 37 , 56 },
+{ 80 , 80 , 37 , 57 },
+{ 80 , 80 , 37 , 58 },
+{ 80 , 80 , 37 , 59 },
+{ 80 , 80 , 37 , 60 },
+{ 80 , 80 , 37 , 61 },
+{ 80 , 80 , 37 , 62 },
+{ 80 , 80 , 37 , 63 },
+{ 80 , 80 , 37 , 64 },
+{ 80 , 80 , 37 , 65 },
+{ 80 , 80 , 37 , 66 },
+{ 80 , 80 , 37 , 67 },
+{ 80 , 80 , 37 , 68 },
+{ 80 , 80 , 37 , 69 },
+{ 80 , 80 , 37 , 70 },
+{ 80 , 80 , 37 , 71 },
+{ 80 , 80 , 37 , 72 },
+{ 80 , 80 , 37 , 73 },
+{ 80 , 80 , 37 , 74 },
+{ 80 , 80 , 37 , 75 },
+{ 80 , 80 , 37 , 76 },
+{ 80 , 80 , 37 , 77 },
+{ 80 , 80 , 37 , 78 },
+{ 80 , 80 , 37 , 79 },
+{ 80 , 80 , 38 , 0 },
+{ 80 , 80 , 38 , 1 },
+{ 80 , 80 , 38 , 2 },
+{ 80 , 80 , 38 , 3 },
+{ 80 , 80 , 38 , 4 },
+{ 80 , 80 , 38 , 5 },
+{ 80 , 80 , 38 , 6 },
+{ 80 , 80 , 38 , 7 },
+{ 80 , 80 , 38 , 8 },
+{ 80 , 80 , 38 , 9 },
+{ 80 , 80 , 38 , 10 },
+{ 80 , 80 , 38 , 11 },
+{ 80 , 80 , 38 , 12 },
+{ 80 , 80 , 38 , 13 },
+{ 80 , 80 , 38 , 14 },
+{ 80 , 80 , 38 , 15 },
+{ 80 , 80 , 38 , 16 },
+{ 80 , 80 , 38 , 17 },
+{ 80 , 80 , 38 , 18 },
+{ 80 , 80 , 38 , 19 },
+{ 80 , 80 , 38 , 20 },
+{ 80 , 80 , 38 , 21 },
+{ 80 , 80 , 38 , 22 },
+{ 80 , 80 , 38 , 23 },
+{ 80 , 80 , 38 , 24 },
+{ 80 , 80 , 38 , 25 },
+{ 80 , 80 , 38 , 26 },
+{ 80 , 80 , 38 , 27 },
+{ 80 , 80 , 38 , 28 },
+{ 80 , 80 , 38 , 29 },
+{ 80 , 80 , 38 , 30 },
+{ 80 , 80 , 38 , 31 },
+{ 80 , 80 , 38 , 32 },
+{ 80 , 80 , 38 , 33 },
+{ 80 , 80 , 38 , 34 },
+{ 80 , 80 , 38 , 35 },
+{ 80 , 80 , 38 , 36 },
+{ 80 , 80 , 38 , 37 },
+{ 80 , 80 , 38 , 38 },
+{ 80 , 80 , 38 , 39 },
+{ 80 , 80 , 38 , 40 },
+{ 80 , 80 , 38 , 41 },
+{ 80 , 80 , 38 , 42 },
+{ 80 , 80 , 38 , 43 },
+{ 80 , 80 , 38 , 44 },
+{ 80 , 80 , 38 , 45 },
+{ 80 , 80 , 38 , 46 },
+{ 80 , 80 , 38 , 47 },
+{ 80 , 80 , 38 , 48 },
+{ 80 , 80 , 38 , 49 },
+{ 80 , 80 , 38 , 50 },
+{ 80 , 80 , 38 , 51 },
+{ 80 , 80 , 38 , 52 },
+{ 80 , 80 , 38 , 53 },
+{ 80 , 80 , 38 , 54 },
+{ 80 , 80 , 38 , 55 },
+{ 80 , 80 , 38 , 56 },
+{ 80 , 80 , 38 , 57 },
+{ 80 , 80 , 38 , 58 },
+{ 80 , 80 , 38 , 59 },
+{ 80 , 80 , 38 , 60 },
+{ 80 , 80 , 38 , 61 },
+{ 80 , 80 , 38 , 62 },
+{ 80 , 80 , 38 , 63 },
+{ 80 , 80 , 38 , 64 },
+{ 80 , 80 , 38 , 65 },
+{ 80 , 80 , 38 , 66 },
+{ 80 , 80 , 38 , 67 },
+{ 80 , 80 , 38 , 68 },
+{ 80 , 80 , 38 , 69 },
+{ 80 , 80 , 38 , 70 },
+{ 80 , 80 , 38 , 71 },
+{ 80 , 80 , 38 , 72 },
+{ 80 , 80 , 38 , 73 },
+{ 80 , 80 , 38 , 74 },
+{ 80 , 80 , 38 , 75 },
+{ 80 , 80 , 38 , 76 },
+{ 80 , 80 , 38 , 77 },
+{ 80 , 80 , 38 , 78 },
+{ 80 , 80 , 38 , 79 },
+{ 80 , 80 , 39 , 0 },
+{ 80 , 80 , 39 , 1 },
+{ 80 , 80 , 39 , 2 },
+{ 80 , 80 , 39 , 3 },
+{ 80 , 80 , 39 , 4 },
+{ 80 , 80 , 39 , 5 },
+{ 80 , 80 , 39 , 6 },
+{ 80 , 80 , 39 , 7 },
+{ 80 , 80 , 39 , 8 },
+{ 80 , 80 , 39 , 9 },
+{ 80 , 80 , 39 , 10 },
+{ 80 , 80 , 39 , 11 },
+{ 80 , 80 , 39 , 12 },
+{ 80 , 80 , 39 , 13 },
+{ 80 , 80 , 39 , 14 },
+{ 80 , 80 , 39 , 15 },
+{ 80 , 80 , 39 , 16 },
+{ 80 , 80 , 39 , 17 },
+{ 80 , 80 , 39 , 18 },
+{ 80 , 80 , 39 , 19 },
+{ 80 , 80 , 39 , 20 },
+{ 80 , 80 , 39 , 21 },
+{ 80 , 80 , 39 , 22 },
+{ 80 , 80 , 39 , 23 },
+{ 80 , 80 , 39 , 24 },
+{ 80 , 80 , 39 , 25 },
+{ 80 , 80 , 39 , 26 },
+{ 80 , 80 , 39 , 27 },
+{ 80 , 80 , 39 , 28 },
+{ 80 , 80 , 39 , 29 },
+{ 80 , 80 , 39 , 30 },
+{ 80 , 80 , 39 , 31 },
+{ 80 , 80 , 39 , 32 },
+{ 80 , 80 , 39 , 33 },
+{ 80 , 80 , 39 , 34 },
+{ 80 , 80 , 39 , 35 },
+{ 80 , 80 , 39 , 36 },
+{ 80 , 80 , 39 , 37 },
+{ 80 , 80 , 39 , 38 },
+{ 80 , 80 , 39 , 39 },
+{ 80 , 80 , 39 , 40 },
+{ 80 , 80 , 39 , 41 },
+{ 80 , 80 , 39 , 42 },
+{ 80 , 80 , 39 , 43 },
+{ 80 , 80 , 39 , 44 },
+{ 80 , 80 , 39 , 45 },
+{ 80 , 80 , 39 , 46 },
+{ 80 , 80 , 39 , 47 },
+{ 80 , 80 , 39 , 48 },
+{ 80 , 80 , 39 , 49 },
+{ 80 , 80 , 39 , 50 },
+{ 80 , 80 , 39 , 51 },
+{ 80 , 80 , 39 , 52 },
+{ 80 , 80 , 39 , 53 },
+{ 80 , 80 , 39 , 54 },
+{ 80 , 80 , 39 , 55 },
+{ 80 , 80 , 39 , 56 },
+{ 80 , 80 , 39 , 57 },
+{ 80 , 80 , 39 , 58 },
+{ 80 , 80 , 39 , 59 },
+{ 80 , 80 , 39 , 60 },
+{ 80 , 80 , 39 , 61 },
+{ 80 , 80 , 39 , 62 },
+{ 80 , 80 , 39 , 63 },
+{ 80 , 80 , 39 , 64 },
+{ 80 , 80 , 39 , 65 },
+{ 80 , 80 , 39 , 66 },
+{ 80 , 80 , 39 , 67 },
+{ 80 , 80 , 39 , 68 },
+{ 80 , 80 , 39 , 69 },
+{ 80 , 80 , 39 , 70 },
+{ 80 , 80 , 39 , 71 },
+{ 80 , 80 , 39 , 72 },
+{ 80 , 80 , 39 , 73 },
+{ 80 , 80 , 39 , 74 },
+{ 80 , 80 , 39 , 75 },
+{ 80 , 80 , 39 , 76 },
+{ 80 , 80 , 39 , 77 },
+{ 80 , 80 , 39 , 78 },
+{ 80 , 80 , 39 , 79 },
+{ 80 , 80 , 40 , 0 },
+{ 80 , 80 , 40 , 1 },
+{ 80 , 80 , 40 , 2 },
+{ 80 , 80 , 40 , 3 },
+{ 80 , 80 , 40 , 4 },
+{ 80 , 80 , 40 , 5 },
+{ 80 , 80 , 40 , 6 },
+{ 80 , 80 , 40 , 7 },
+{ 80 , 80 , 40 , 8 },
+{ 80 , 80 , 40 , 9 },
+{ 80 , 80 , 40 , 10 },
+{ 80 , 80 , 40 , 11 },
+{ 80 , 80 , 40 , 12 },
+{ 80 , 80 , 40 , 13 },
+{ 80 , 80 , 40 , 14 },
+{ 80 , 80 , 40 , 15 },
+{ 80 , 80 , 40 , 16 },
+{ 80 , 80 , 40 , 17 },
+{ 80 , 80 , 40 , 18 },
+{ 80 , 80 , 40 , 19 },
+{ 80 , 80 , 40 , 20 },
+{ 80 , 80 , 40 , 21 },
+{ 80 , 80 , 40 , 22 },
+{ 80 , 80 , 40 , 23 },
+{ 80 , 80 , 40 , 24 },
+{ 80 , 80 , 40 , 25 },
+{ 80 , 80 , 40 , 26 },
+{ 80 , 80 , 40 , 27 },
+{ 80 , 80 , 40 , 28 },
+{ 80 , 80 , 40 , 29 },
+{ 80 , 80 , 40 , 30 },
+{ 80 , 80 , 40 , 31 },
+{ 80 , 80 , 40 , 32 },
+{ 80 , 80 , 40 , 33 },
+{ 80 , 80 , 40 , 34 },
+{ 80 , 80 , 40 , 35 },
+{ 80 , 80 , 40 , 36 },
+{ 80 , 80 , 40 , 37 },
+{ 80 , 80 , 40 , 38 },
+{ 80 , 80 , 40 , 39 },
+{ 80 , 80 , 40 , 40 },
+{ 80 , 80 , 40 , 41 },
+{ 80 , 80 , 40 , 42 },
+{ 80 , 80 , 40 , 43 },
+{ 80 , 80 , 40 , 44 },
+{ 80 , 80 , 40 , 45 },
+{ 80 , 80 , 40 , 46 },
+{ 80 , 80 , 40 , 47 },
+{ 80 , 80 , 40 , 48 },
+{ 80 , 80 , 40 , 49 },
+{ 80 , 80 , 40 , 50 },
+{ 80 , 80 , 40 , 51 },
+{ 80 , 80 , 40 , 52 },
+{ 80 , 80 , 40 , 53 },
+{ 80 , 80 , 40 , 54 },
+{ 80 , 80 , 40 , 55 },
+{ 80 , 80 , 40 , 56 },
+{ 80 , 80 , 40 , 57 },
+{ 80 , 80 , 40 , 58 },
+{ 80 , 80 , 40 , 59 },
+{ 80 , 80 , 40 , 60 },
+{ 80 , 80 , 40 , 61 },
+{ 80 , 80 , 40 , 62 },
+{ 80 , 80 , 40 , 63 },
+{ 80 , 80 , 40 , 64 },
+{ 80 , 80 , 40 , 65 },
+{ 80 , 80 , 40 , 66 },
+{ 80 , 80 , 40 , 67 },
+{ 80 , 80 , 40 , 68 },
+{ 80 , 80 , 40 , 69 },
+{ 80 , 80 , 40 , 70 },
+{ 80 , 80 , 40 , 71 },
+{ 80 , 80 , 40 , 72 },
+{ 80 , 80 , 40 , 73 },
+{ 80 , 80 , 40 , 74 },
+{ 80 , 80 , 40 , 75 },
+{ 80 , 80 , 40 , 76 },
+{ 80 , 80 , 40 , 77 },
+{ 80 , 80 , 40 , 78 },
+{ 80 , 80 , 40 , 79 },
+{ 80 , 80 , 41 , 0 },
+{ 80 , 80 , 41 , 1 },
+{ 80 , 80 , 41 , 2 },
+{ 80 , 80 , 41 , 3 },
+{ 80 , 80 , 41 , 4 },
+{ 80 , 80 , 41 , 5 },
+{ 80 , 80 , 41 , 6 },
+{ 80 , 80 , 41 , 7 },
+{ 80 , 80 , 41 , 8 },
+{ 80 , 80 , 41 , 9 },
+{ 80 , 80 , 41 , 10 },
+{ 80 , 80 , 41 , 11 },
+{ 80 , 80 , 41 , 12 },
+{ 80 , 80 , 41 , 13 },
+{ 80 , 80 , 41 , 14 },
+{ 80 , 80 , 41 , 15 },
+{ 80 , 80 , 41 , 16 },
+{ 80 , 80 , 41 , 17 },
+{ 80 , 80 , 41 , 18 },
+{ 80 , 80 , 41 , 19 },
+{ 80 , 80 , 41 , 20 },
+{ 80 , 80 , 41 , 21 },
+{ 80 , 80 , 41 , 22 },
+{ 80 , 80 , 41 , 23 },
+{ 80 , 80 , 41 , 24 },
+{ 80 , 80 , 41 , 25 },
+{ 80 , 80 , 41 , 26 },
+{ 80 , 80 , 41 , 27 },
+{ 80 , 80 , 41 , 28 },
+{ 80 , 80 , 41 , 29 },
+{ 80 , 80 , 41 , 30 },
+{ 80 , 80 , 41 , 31 },
+{ 80 , 80 , 41 , 32 },
+{ 80 , 80 , 41 , 33 },
+{ 80 , 80 , 41 , 34 },
+{ 80 , 80 , 41 , 35 },
+{ 80 , 80 , 41 , 36 },
+{ 80 , 80 , 41 , 37 },
+{ 80 , 80 , 41 , 38 },
+{ 80 , 80 , 41 , 39 },
+{ 80 , 80 , 41 , 40 },
+{ 80 , 80 , 41 , 41 },
+{ 80 , 80 , 41 , 42 },
+{ 80 , 80 , 41 , 43 },
+{ 80 , 80 , 41 , 44 },
+{ 80 , 80 , 41 , 45 },
+{ 80 , 80 , 41 , 46 },
+{ 80 , 80 , 41 , 47 },
+{ 80 , 80 , 41 , 48 },
+{ 80 , 80 , 41 , 49 },
+{ 80 , 80 , 41 , 50 },
+{ 80 , 80 , 41 , 51 },
+{ 80 , 80 , 41 , 52 },
+{ 80 , 80 , 41 , 53 },
+{ 80 , 80 , 41 , 54 },
+{ 80 , 80 , 41 , 55 },
+{ 80 , 80 , 41 , 56 },
+{ 80 , 80 , 41 , 57 },
+{ 80 , 80 , 41 , 58 },
+{ 80 , 80 , 41 , 59 },
+{ 80 , 80 , 41 , 60 },
+{ 80 , 80 , 41 , 61 },
+{ 80 , 80 , 41 , 62 },
+{ 80 , 80 , 41 , 63 },
+{ 80 , 80 , 41 , 64 },
+{ 80 , 80 , 41 , 65 },
+{ 80 , 80 , 41 , 66 },
+{ 80 , 80 , 41 , 67 },
+{ 80 , 80 , 41 , 68 },
+{ 80 , 80 , 41 , 69 },
+{ 80 , 80 , 41 , 70 },
+{ 80 , 80 , 41 , 71 },
+{ 80 , 80 , 41 , 72 },
+{ 80 , 80 , 41 , 73 },
+{ 80 , 80 , 41 , 74 },
+{ 80 , 80 , 41 , 75 },
+{ 80 , 80 , 41 , 76 },
+{ 80 , 80 , 41 , 77 },
+{ 80 , 80 , 41 , 78 },
+{ 80 , 80 , 41 , 79 },
+{ 80 , 80 , 42 , 0 },
+{ 80 , 80 , 42 , 1 },
+{ 80 , 80 , 42 , 2 },
+{ 80 , 80 , 42 , 3 },
+{ 80 , 80 , 42 , 4 },
+{ 80 , 80 , 42 , 5 },
+{ 80 , 80 , 42 , 6 },
+{ 80 , 80 , 42 , 7 },
+{ 80 , 80 , 42 , 8 },
+{ 80 , 80 , 42 , 9 },
+{ 80 , 80 , 42 , 10 },
+{ 80 , 80 , 42 , 11 },
+{ 80 , 80 , 42 , 12 },
+{ 80 , 80 , 42 , 13 },
+{ 80 , 80 , 42 , 14 },
+{ 80 , 80 , 42 , 15 },
+{ 80 , 80 , 42 , 16 },
+{ 80 , 80 , 42 , 17 },
+{ 80 , 80 , 42 , 18 },
+{ 80 , 80 , 42 , 19 },
+{ 80 , 80 , 42 , 20 },
+{ 80 , 80 , 42 , 21 },
+{ 80 , 80 , 42 , 22 },
+{ 80 , 80 , 42 , 23 },
+{ 80 , 80 , 42 , 24 },
+{ 80 , 80 , 42 , 25 },
+{ 80 , 80 , 42 , 26 },
+{ 80 , 80 , 42 , 27 },
+{ 80 , 80 , 42 , 28 },
+{ 80 , 80 , 42 , 29 },
+{ 80 , 80 , 42 , 30 },
+{ 80 , 80 , 42 , 31 },
+{ 80 , 80 , 42 , 32 },
+{ 80 , 80 , 42 , 33 },
+{ 80 , 80 , 42 , 34 },
+{ 80 , 80 , 42 , 35 },
+{ 80 , 80 , 42 , 36 },
+{ 80 , 80 , 42 , 37 },
+{ 80 , 80 , 42 , 38 },
+{ 80 , 80 , 42 , 39 },
+{ 80 , 80 , 42 , 40 },
+{ 80 , 80 , 42 , 41 },
+{ 80 , 80 , 42 , 42 },
+{ 80 , 80 , 42 , 43 },
+{ 80 , 80 , 42 , 44 },
+{ 80 , 80 , 42 , 45 },
+{ 80 , 80 , 42 , 46 },
+{ 80 , 80 , 42 , 47 },
+{ 80 , 80 , 42 , 48 },
+{ 80 , 80 , 42 , 49 },
+{ 80 , 80 , 42 , 50 },
+{ 80 , 80 , 42 , 51 },
+{ 80 , 80 , 42 , 52 },
+{ 80 , 80 , 42 , 53 },
+{ 80 , 80 , 42 , 54 },
+{ 80 , 80 , 42 , 55 },
+{ 80 , 80 , 42 , 56 },
+{ 80 , 80 , 42 , 57 },
+{ 80 , 80 , 42 , 58 },
+{ 80 , 80 , 42 , 59 },
+{ 80 , 80 , 42 , 60 },
+{ 80 , 80 , 42 , 61 },
+{ 80 , 80 , 42 , 62 },
+{ 80 , 80 , 42 , 63 },
+{ 80 , 80 , 42 , 64 },
+{ 80 , 80 , 42 , 65 },
+{ 80 , 80 , 42 , 66 },
+{ 80 , 80 , 42 , 67 },
+{ 80 , 80 , 42 , 68 },
+{ 80 , 80 , 42 , 69 },
+{ 80 , 80 , 42 , 70 },
+{ 80 , 80 , 42 , 71 },
+{ 80 , 80 , 42 , 72 },
+{ 80 , 80 , 42 , 73 },
+{ 80 , 80 , 42 , 74 },
+{ 80 , 80 , 42 , 75 },
+{ 80 , 80 , 42 , 76 },
+{ 80 , 80 , 42 , 77 },
+{ 80 , 80 , 42 , 78 },
+{ 80 , 80 , 42 , 79 },
+{ 80 , 80 , 43 , 0 },
+{ 80 , 80 , 43 , 1 },
+{ 80 , 80 , 43 , 2 },
+{ 80 , 80 , 43 , 3 },
+{ 80 , 80 , 43 , 4 },
+{ 80 , 80 , 43 , 5 },
+{ 80 , 80 , 43 , 6 },
+{ 80 , 80 , 43 , 7 },
+{ 80 , 80 , 43 , 8 },
+{ 80 , 80 , 43 , 9 },
+{ 80 , 80 , 43 , 10 },
+{ 80 , 80 , 43 , 11 },
+{ 80 , 80 , 43 , 12 },
+{ 80 , 80 , 43 , 13 },
+{ 80 , 80 , 43 , 14 },
+{ 80 , 80 , 43 , 15 },
+{ 80 , 80 , 43 , 16 },
+{ 80 , 80 , 43 , 17 },
+{ 80 , 80 , 43 , 18 },
+{ 80 , 80 , 43 , 19 },
+{ 80 , 80 , 43 , 20 },
+{ 80 , 80 , 43 , 21 },
+{ 80 , 80 , 43 , 22 },
+{ 80 , 80 , 43 , 23 },
+{ 80 , 80 , 43 , 24 },
+{ 80 , 80 , 43 , 25 },
+{ 80 , 80 , 43 , 26 },
+{ 80 , 80 , 43 , 27 },
+{ 80 , 80 , 43 , 28 },
+{ 80 , 80 , 43 , 29 },
+{ 80 , 80 , 43 , 30 },
+{ 80 , 80 , 43 , 31 },
+{ 80 , 80 , 43 , 32 },
+{ 80 , 80 , 43 , 33 },
+{ 80 , 80 , 43 , 34 },
+{ 80 , 80 , 43 , 35 },
+{ 80 , 80 , 43 , 36 },
+{ 80 , 80 , 43 , 37 },
+{ 80 , 80 , 43 , 38 },
+{ 80 , 80 , 43 , 39 },
+{ 80 , 80 , 43 , 40 },
+{ 80 , 80 , 43 , 41 },
+{ 80 , 80 , 43 , 42 },
+{ 80 , 80 , 43 , 43 },
+{ 80 , 80 , 43 , 44 },
+{ 80 , 80 , 43 , 45 },
+{ 80 , 80 , 43 , 46 },
+{ 80 , 80 , 43 , 47 },
+{ 80 , 80 , 43 , 48 },
+{ 80 , 80 , 43 , 49 },
+{ 80 , 80 , 43 , 50 },
+{ 80 , 80 , 43 , 51 },
+{ 80 , 80 , 43 , 52 },
+{ 80 , 80 , 43 , 53 },
+{ 80 , 80 , 43 , 54 },
+{ 80 , 80 , 43 , 55 },
+{ 80 , 80 , 43 , 56 },
+{ 80 , 80 , 43 , 57 },
+{ 80 , 80 , 43 , 58 },
+{ 80 , 80 , 43 , 59 },
+{ 80 , 80 , 43 , 60 },
+{ 80 , 80 , 43 , 61 },
+{ 80 , 80 , 43 , 62 },
+{ 80 , 80 , 43 , 63 },
+{ 80 , 80 , 43 , 64 },
+{ 80 , 80 , 43 , 65 },
+{ 80 , 80 , 43 , 66 },
+{ 80 , 80 , 43 , 67 },
+{ 80 , 80 , 43 , 68 },
+{ 80 , 80 , 43 , 69 },
+{ 80 , 80 , 43 , 70 },
+{ 80 , 80 , 43 , 71 },
+{ 80 , 80 , 43 , 72 },
+{ 80 , 80 , 43 , 73 },
+{ 80 , 80 , 43 , 74 },
+{ 80 , 80 , 43 , 75 },
+{ 80 , 80 , 43 , 76 },
+{ 80 , 80 , 43 , 77 },
+{ 80 , 80 , 43 , 78 },
+{ 80 , 80 , 43 , 79 },
+{ 80 , 80 , 44 , 0 },
+{ 80 , 80 , 44 , 1 },
+{ 80 , 80 , 44 , 2 },
+{ 80 , 80 , 44 , 3 },
+{ 80 , 80 , 44 , 4 },
+{ 80 , 80 , 44 , 5 },
+{ 80 , 80 , 44 , 6 },
+{ 80 , 80 , 44 , 7 },
+{ 80 , 80 , 44 , 8 },
+{ 80 , 80 , 44 , 9 },
+{ 80 , 80 , 44 , 10 },
+{ 80 , 80 , 44 , 11 },
+{ 80 , 80 , 44 , 12 },
+{ 80 , 80 , 44 , 13 },
+{ 80 , 80 , 44 , 14 },
+{ 80 , 80 , 44 , 15 },
+{ 80 , 80 , 44 , 16 },
+{ 80 , 80 , 44 , 17 },
+{ 80 , 80 , 44 , 18 },
+{ 80 , 80 , 44 , 19 },
+{ 80 , 80 , 44 , 20 },
+{ 80 , 80 , 44 , 21 },
+{ 80 , 80 , 44 , 22 },
+{ 80 , 80 , 44 , 23 },
+{ 80 , 80 , 44 , 24 },
+{ 80 , 80 , 44 , 25 },
+{ 80 , 80 , 44 , 26 },
+{ 80 , 80 , 44 , 27 },
+{ 80 , 80 , 44 , 28 },
+{ 80 , 80 , 44 , 29 },
+{ 80 , 80 , 44 , 30 },
+{ 80 , 80 , 44 , 31 },
+{ 80 , 80 , 44 , 32 },
+{ 80 , 80 , 44 , 33 },
+{ 80 , 80 , 44 , 34 },
+{ 80 , 80 , 44 , 35 },
+{ 80 , 80 , 44 , 36 },
+{ 80 , 80 , 44 , 37 },
+{ 80 , 80 , 44 , 38 },
+{ 80 , 80 , 44 , 39 },
+{ 80 , 80 , 44 , 40 },
+{ 80 , 80 , 44 , 41 },
+{ 80 , 80 , 44 , 42 },
+{ 80 , 80 , 44 , 43 },
+{ 80 , 80 , 44 , 44 },
+{ 80 , 80 , 44 , 45 },
+{ 80 , 80 , 44 , 46 },
+{ 80 , 80 , 44 , 47 },
+{ 80 , 80 , 44 , 48 },
+{ 80 , 80 , 44 , 49 },
+{ 80 , 80 , 44 , 50 },
+{ 80 , 80 , 44 , 51 },
+{ 80 , 80 , 44 , 52 },
+{ 80 , 80 , 44 , 53 },
+{ 80 , 80 , 44 , 54 },
+{ 80 , 80 , 44 , 55 },
+{ 80 , 80 , 44 , 56 },
+{ 80 , 80 , 44 , 57 },
+{ 80 , 80 , 44 , 58 },
+{ 80 , 80 , 44 , 59 },
+{ 80 , 80 , 44 , 60 },
+{ 80 , 80 , 44 , 61 },
+{ 80 , 80 , 44 , 62 },
+{ 80 , 80 , 44 , 63 },
+{ 80 , 80 , 44 , 64 },
+{ 80 , 80 , 44 , 65 },
+{ 80 , 80 , 44 , 66 },
+{ 80 , 80 , 44 , 67 },
+{ 80 , 80 , 44 , 68 },
+{ 80 , 80 , 44 , 69 },
+{ 80 , 80 , 44 , 70 },
+{ 80 , 80 , 44 , 71 },
+{ 80 , 80 , 44 , 72 },
+{ 80 , 80 , 44 , 73 },
+{ 80 , 80 , 44 , 74 },
+{ 80 , 80 , 44 , 75 },
+{ 80 , 80 , 44 , 76 },
+{ 80 , 80 , 44 , 77 },
+{ 80 , 80 , 44 , 78 },
+{ 80 , 80 , 44 , 79 },
+{ 80 , 80 , 45 , 0 },
+{ 80 , 80 , 45 , 1 },
+{ 80 , 80 , 45 , 2 },
+{ 80 , 80 , 45 , 3 },
+{ 80 , 80 , 45 , 4 },
+{ 80 , 80 , 45 , 5 },
+{ 80 , 80 , 45 , 6 },
+{ 80 , 80 , 45 , 7 },
+{ 80 , 80 , 45 , 8 },
+{ 80 , 80 , 45 , 9 },
+{ 80 , 80 , 45 , 10 },
+{ 80 , 80 , 45 , 11 },
+{ 80 , 80 , 45 , 12 },
+{ 80 , 80 , 45 , 13 },
+{ 80 , 80 , 45 , 14 },
+{ 80 , 80 , 45 , 15 },
+{ 80 , 80 , 45 , 16 },
+{ 80 , 80 , 45 , 17 },
+{ 80 , 80 , 45 , 18 },
+{ 80 , 80 , 45 , 19 },
+{ 80 , 80 , 45 , 20 },
+{ 80 , 80 , 45 , 21 },
+{ 80 , 80 , 45 , 22 },
+{ 80 , 80 , 45 , 23 },
+{ 80 , 80 , 45 , 24 },
+{ 80 , 80 , 45 , 25 },
+{ 80 , 80 , 45 , 26 },
+{ 80 , 80 , 45 , 27 },
+{ 80 , 80 , 45 , 28 },
+{ 80 , 80 , 45 , 29 },
+{ 80 , 80 , 45 , 30 },
+{ 80 , 80 , 45 , 31 },
+{ 80 , 80 , 45 , 32 },
+{ 80 , 80 , 45 , 33 },
+{ 80 , 80 , 45 , 34 },
+{ 80 , 80 , 45 , 35 },
+{ 80 , 80 , 45 , 36 },
+{ 80 , 80 , 45 , 37 },
+{ 80 , 80 , 45 , 38 },
+{ 80 , 80 , 45 , 39 },
+{ 80 , 80 , 45 , 40 },
+{ 80 , 80 , 45 , 41 },
+{ 80 , 80 , 45 , 42 },
+{ 80 , 80 , 45 , 43 },
+{ 80 , 80 , 45 , 44 },
+{ 80 , 80 , 45 , 45 },
+{ 80 , 80 , 45 , 46 },
+{ 80 , 80 , 45 , 47 },
+{ 80 , 80 , 45 , 48 },
+{ 80 , 80 , 45 , 49 },
+{ 80 , 80 , 45 , 50 },
+{ 80 , 80 , 45 , 51 },
+{ 80 , 80 , 45 , 52 },
+{ 80 , 80 , 45 , 53 },
+{ 80 , 80 , 45 , 54 },
+{ 80 , 80 , 45 , 55 },
+{ 80 , 80 , 45 , 56 },
+{ 80 , 80 , 45 , 57 },
+{ 80 , 80 , 45 , 58 },
+{ 80 , 80 , 45 , 59 },
+{ 80 , 80 , 45 , 60 },
+{ 80 , 80 , 45 , 61 },
+{ 80 , 80 , 45 , 62 },
+{ 80 , 80 , 45 , 63 },
+{ 80 , 80 , 45 , 64 },
+{ 80 , 80 , 45 , 65 },
+{ 80 , 80 , 45 , 66 },
+{ 80 , 80 , 45 , 67 },
+{ 80 , 80 , 45 , 68 },
+{ 80 , 80 , 45 , 69 },
+{ 80 , 80 , 45 , 70 },
+{ 80 , 80 , 45 , 71 },
+{ 80 , 80 , 45 , 72 },
+{ 80 , 80 , 45 , 73 },
+{ 80 , 80 , 45 , 74 },
+{ 80 , 80 , 45 , 75 },
+{ 80 , 80 , 45 , 76 },
+{ 80 , 80 , 45 , 77 },
+{ 80 , 80 , 45 , 78 },
+{ 80 , 80 , 45 , 79 },
+{ 80 , 80 , 46 , 0 },
+{ 80 , 80 , 46 , 1 },
+{ 80 , 80 , 46 , 2 },
+{ 80 , 80 , 46 , 3 },
+{ 80 , 80 , 46 , 4 },
+{ 80 , 80 , 46 , 5 },
+{ 80 , 80 , 46 , 6 },
+{ 80 , 80 , 46 , 7 },
+{ 80 , 80 , 46 , 8 },
+{ 80 , 80 , 46 , 9 },
+{ 80 , 80 , 46 , 10 },
+{ 80 , 80 , 46 , 11 },
+{ 80 , 80 , 46 , 12 },
+{ 80 , 80 , 46 , 13 },
+{ 80 , 80 , 46 , 14 },
+{ 80 , 80 , 46 , 15 },
+{ 80 , 80 , 46 , 16 },
+{ 80 , 80 , 46 , 17 },
+{ 80 , 80 , 46 , 18 },
+{ 80 , 80 , 46 , 19 },
+{ 80 , 80 , 46 , 20 },
+{ 80 , 80 , 46 , 21 },
+{ 80 , 80 , 46 , 22 },
+{ 80 , 80 , 46 , 23 },
+{ 80 , 80 , 46 , 24 },
+{ 80 , 80 , 46 , 25 },
+{ 80 , 80 , 46 , 26 },
+{ 80 , 80 , 46 , 27 },
+{ 80 , 80 , 46 , 28 },
+{ 80 , 80 , 46 , 29 },
+{ 80 , 80 , 46 , 30 },
+{ 80 , 80 , 46 , 31 },
+{ 80 , 80 , 46 , 32 },
+{ 80 , 80 , 46 , 33 },
+{ 80 , 80 , 46 , 34 },
+{ 80 , 80 , 46 , 35 },
+{ 80 , 80 , 46 , 36 },
+{ 80 , 80 , 46 , 37 },
+{ 80 , 80 , 46 , 38 },
+{ 80 , 80 , 46 , 39 },
+{ 80 , 80 , 46 , 40 },
+{ 80 , 80 , 46 , 41 },
+{ 80 , 80 , 46 , 42 },
+{ 80 , 80 , 46 , 43 },
+{ 80 , 80 , 46 , 44 },
+{ 80 , 80 , 46 , 45 },
+{ 80 , 80 , 46 , 46 },
+{ 80 , 80 , 46 , 47 },
+{ 80 , 80 , 46 , 48 },
+{ 80 , 80 , 46 , 49 },
+{ 80 , 80 , 46 , 50 },
+{ 80 , 80 , 46 , 51 },
+{ 80 , 80 , 46 , 52 },
+{ 80 , 80 , 46 , 53 },
+{ 80 , 80 , 46 , 54 },
+{ 80 , 80 , 46 , 55 },
+{ 80 , 80 , 46 , 56 },
+{ 80 , 80 , 46 , 57 },
+{ 80 , 80 , 46 , 58 },
+{ 80 , 80 , 46 , 59 },
+{ 80 , 80 , 46 , 60 },
+{ 80 , 80 , 46 , 61 },
+{ 80 , 80 , 46 , 62 },
+{ 80 , 80 , 46 , 63 },
+{ 80 , 80 , 46 , 64 },
+{ 80 , 80 , 46 , 65 },
+{ 80 , 80 , 46 , 66 },
+{ 80 , 80 , 46 , 67 },
+{ 80 , 80 , 46 , 68 },
+{ 80 , 80 , 46 , 69 },
+{ 80 , 80 , 46 , 70 },
+{ 80 , 80 , 46 , 71 },
+{ 80 , 80 , 46 , 72 },
+{ 80 , 80 , 46 , 73 },
+{ 80 , 80 , 46 , 74 },
+{ 80 , 80 , 46 , 75 },
+{ 80 , 80 , 46 , 76 },
+{ 80 , 80 , 46 , 77 },
+{ 80 , 80 , 46 , 78 },
+{ 80 , 80 , 46 , 79 },
+{ 80 , 80 , 47 , 0 },
+{ 80 , 80 , 47 , 1 },
+{ 80 , 80 , 47 , 2 },
+{ 80 , 80 , 47 , 3 },
+{ 80 , 80 , 47 , 4 },
+{ 80 , 80 , 47 , 5 },
+{ 80 , 80 , 47 , 6 },
+{ 80 , 80 , 47 , 7 },
+{ 80 , 80 , 47 , 8 },
+{ 80 , 80 , 47 , 9 },
+{ 80 , 80 , 47 , 10 },
+{ 80 , 80 , 47 , 11 },
+{ 80 , 80 , 47 , 12 },
+{ 80 , 80 , 47 , 13 },
+{ 80 , 80 , 47 , 14 },
+{ 80 , 80 , 47 , 15 },
+{ 80 , 80 , 47 , 16 },
+{ 80 , 80 , 47 , 17 },
+{ 80 , 80 , 47 , 18 },
+{ 80 , 80 , 47 , 19 },
+{ 80 , 80 , 47 , 20 },
+{ 80 , 80 , 47 , 21 },
+{ 80 , 80 , 47 , 22 },
+{ 80 , 80 , 47 , 23 },
+{ 80 , 80 , 47 , 24 },
+{ 80 , 80 , 47 , 25 },
+{ 80 , 80 , 47 , 26 },
+{ 80 , 80 , 47 , 27 },
+{ 80 , 80 , 47 , 28 },
+{ 80 , 80 , 47 , 29 },
+{ 80 , 80 , 47 , 30 },
+{ 80 , 80 , 47 , 31 },
+{ 80 , 80 , 47 , 32 },
+{ 80 , 80 , 47 , 33 },
+{ 80 , 80 , 47 , 34 },
+{ 80 , 80 , 47 , 35 },
+{ 80 , 80 , 47 , 36 },
+{ 80 , 80 , 47 , 37 },
+{ 80 , 80 , 47 , 38 },
+{ 80 , 80 , 47 , 39 },
+{ 80 , 80 , 47 , 40 },
+{ 80 , 80 , 47 , 41 },
+{ 80 , 80 , 47 , 42 },
+{ 80 , 80 , 47 , 43 },
+{ 80 , 80 , 47 , 44 },
+{ 80 , 80 , 47 , 45 },
+{ 80 , 80 , 47 , 46 },
+{ 80 , 80 , 47 , 47 },
+{ 80 , 80 , 47 , 48 },
+{ 80 , 80 , 47 , 49 },
+{ 80 , 80 , 47 , 50 },
+{ 80 , 80 , 47 , 51 },
+{ 80 , 80 , 47 , 52 },
+{ 80 , 80 , 47 , 53 },
+{ 80 , 80 , 47 , 54 },
+{ 80 , 80 , 47 , 55 },
+{ 80 , 80 , 47 , 56 },
+{ 80 , 80 , 47 , 57 },
+{ 80 , 80 , 47 , 58 },
+{ 80 , 80 , 47 , 59 },
+{ 80 , 80 , 47 , 60 },
+{ 80 , 80 , 47 , 61 },
+{ 80 , 80 , 47 , 62 },
+{ 80 , 80 , 47 , 63 },
+{ 80 , 80 , 47 , 64 },
+{ 80 , 80 , 47 , 65 },
+{ 80 , 80 , 47 , 66 },
+{ 80 , 80 , 47 , 67 },
+{ 80 , 80 , 47 , 68 },
+{ 80 , 80 , 47 , 69 },
+{ 80 , 80 , 47 , 70 },
+{ 80 , 80 , 47 , 71 },
+{ 80 , 80 , 47 , 72 },
+{ 80 , 80 , 47 , 73 },
+{ 80 , 80 , 47 , 74 },
+{ 80 , 80 , 47 , 75 },
+{ 80 , 80 , 47 , 76 },
+{ 80 , 80 , 47 , 77 },
+{ 80 , 80 , 47 , 78 },
+{ 80 , 80 , 47 , 79 },
+{ 80 , 80 , 48 , 0 },
+{ 80 , 80 , 48 , 1 },
+{ 80 , 80 , 48 , 2 },
+{ 80 , 80 , 48 , 3 },
+{ 80 , 80 , 48 , 4 },
+{ 80 , 80 , 48 , 5 },
+{ 80 , 80 , 48 , 6 },
+{ 80 , 80 , 48 , 7 },
+{ 80 , 80 , 48 , 8 },
+{ 80 , 80 , 48 , 9 },
+{ 80 , 80 , 48 , 10 },
+{ 80 , 80 , 48 , 11 },
+{ 80 , 80 , 48 , 12 },
+{ 80 , 80 , 48 , 13 },
+{ 80 , 80 , 48 , 14 },
+{ 80 , 80 , 48 , 15 },
+{ 80 , 80 , 48 , 16 },
+{ 80 , 80 , 48 , 17 },
+{ 80 , 80 , 48 , 18 },
+{ 80 , 80 , 48 , 19 },
+{ 80 , 80 , 48 , 20 },
+{ 80 , 80 , 48 , 21 },
+{ 80 , 80 , 48 , 22 },
+{ 80 , 80 , 48 , 23 },
+{ 80 , 80 , 48 , 24 },
+{ 80 , 80 , 48 , 25 },
+{ 80 , 80 , 48 , 26 },
+{ 80 , 80 , 48 , 27 },
+{ 80 , 80 , 48 , 28 },
+{ 80 , 80 , 48 , 29 },
+{ 80 , 80 , 48 , 30 },
+{ 80 , 80 , 48 , 31 },
+{ 80 , 80 , 48 , 32 },
+{ 80 , 80 , 48 , 33 },
+{ 80 , 80 , 48 , 34 },
+{ 80 , 80 , 48 , 35 },
+{ 80 , 80 , 48 , 36 },
+{ 80 , 80 , 48 , 37 },
+{ 80 , 80 , 48 , 38 },
+{ 80 , 80 , 48 , 39 },
+{ 80 , 80 , 48 , 40 },
+{ 80 , 80 , 48 , 41 },
+{ 80 , 80 , 48 , 42 },
+{ 80 , 80 , 48 , 43 },
+{ 80 , 80 , 48 , 44 },
+{ 80 , 80 , 48 , 45 },
+{ 80 , 80 , 48 , 46 },
+{ 80 , 80 , 48 , 47 },
+{ 80 , 80 , 48 , 48 },
+{ 80 , 80 , 48 , 49 },
+{ 80 , 80 , 48 , 50 },
+{ 80 , 80 , 48 , 51 },
+{ 80 , 80 , 48 , 52 },
+{ 80 , 80 , 48 , 53 },
+{ 80 , 80 , 48 , 54 },
+{ 80 , 80 , 48 , 55 },
+{ 80 , 80 , 48 , 56 },
+{ 80 , 80 , 48 , 57 },
+{ 80 , 80 , 48 , 58 },
+{ 80 , 80 , 48 , 59 },
+{ 80 , 80 , 48 , 60 },
+{ 80 , 80 , 48 , 61 },
+{ 80 , 80 , 48 , 62 },
+{ 80 , 80 , 48 , 63 },
+{ 80 , 80 , 48 , 64 },
+{ 80 , 80 , 48 , 65 },
+{ 80 , 80 , 48 , 66 },
+{ 80 , 80 , 48 , 67 },
+{ 80 , 80 , 48 , 68 },
+{ 80 , 80 , 48 , 69 },
+{ 80 , 80 , 48 , 70 },
+{ 80 , 80 , 48 , 71 },
+{ 80 , 80 , 48 , 72 },
+{ 80 , 80 , 48 , 73 },
+{ 80 , 80 , 48 , 74 },
+{ 80 , 80 , 48 , 75 },
+{ 80 , 80 , 48 , 76 },
+{ 80 , 80 , 48 , 77 },
+{ 80 , 80 , 48 , 78 },
+{ 80 , 80 , 48 , 79 },
+{ 80 , 80 , 49 , 0 },
+{ 80 , 80 , 49 , 1 },
+{ 80 , 80 , 49 , 2 },
+{ 80 , 80 , 49 , 3 },
+{ 80 , 80 , 49 , 4 },
+{ 80 , 80 , 49 , 5 },
+{ 80 , 80 , 49 , 6 },
+{ 80 , 80 , 49 , 7 },
+{ 80 , 80 , 49 , 8 },
+{ 80 , 80 , 49 , 9 },
+{ 80 , 80 , 49 , 10 },
+{ 80 , 80 , 49 , 11 },
+{ 80 , 80 , 49 , 12 },
+{ 80 , 80 , 49 , 13 },
+{ 80 , 80 , 49 , 14 },
+{ 80 , 80 , 49 , 15 },
+{ 80 , 80 , 49 , 16 },
+{ 80 , 80 , 49 , 17 },
+{ 80 , 80 , 49 , 18 },
+{ 80 , 80 , 49 , 19 },
+{ 80 , 80 , 49 , 20 },
+{ 80 , 80 , 49 , 21 },
+{ 80 , 80 , 49 , 22 },
+{ 80 , 80 , 49 , 23 },
+{ 80 , 80 , 49 , 24 },
+{ 80 , 80 , 49 , 25 },
+{ 80 , 80 , 49 , 26 },
+{ 80 , 80 , 49 , 27 },
+{ 80 , 80 , 49 , 28 },
+{ 80 , 80 , 49 , 29 },
+{ 80 , 80 , 49 , 30 },
+{ 80 , 80 , 49 , 31 },
+{ 80 , 80 , 49 , 32 },
+{ 80 , 80 , 49 , 33 },
+{ 80 , 80 , 49 , 34 },
+{ 80 , 80 , 49 , 35 },
+{ 80 , 80 , 49 , 36 },
+{ 80 , 80 , 49 , 37 },
+{ 80 , 80 , 49 , 38 },
+{ 80 , 80 , 49 , 39 },
+{ 80 , 80 , 49 , 40 },
+{ 80 , 80 , 49 , 41 },
+{ 80 , 80 , 49 , 42 },
+{ 80 , 80 , 49 , 43 },
+{ 80 , 80 , 49 , 44 },
+{ 80 , 80 , 49 , 45 },
+{ 80 , 80 , 49 , 46 },
+{ 80 , 80 , 49 , 47 },
+{ 80 , 80 , 49 , 48 },
+{ 80 , 80 , 49 , 49 },
+{ 80 , 80 , 49 , 50 },
+{ 80 , 80 , 49 , 51 },
+{ 80 , 80 , 49 , 52 },
+{ 80 , 80 , 49 , 53 },
+{ 80 , 80 , 49 , 54 },
+{ 80 , 80 , 49 , 55 },
+{ 80 , 80 , 49 , 56 },
+{ 80 , 80 , 49 , 57 },
+{ 80 , 80 , 49 , 58 },
+{ 80 , 80 , 49 , 59 },
+{ 80 , 80 , 49 , 60 },
+{ 80 , 80 , 49 , 61 },
+{ 80 , 80 , 49 , 62 },
+{ 80 , 80 , 49 , 63 },
+{ 80 , 80 , 49 , 64 },
+{ 80 , 80 , 49 , 65 },
+{ 80 , 80 , 49 , 66 },
+{ 80 , 80 , 49 , 67 },
+{ 80 , 80 , 49 , 68 },
+{ 80 , 80 , 49 , 69 },
+{ 80 , 80 , 49 , 70 },
+{ 80 , 80 , 49 , 71 },
+{ 80 , 80 , 49 , 72 },
+{ 80 , 80 , 49 , 73 },
+{ 80 , 80 , 49 , 74 },
+{ 80 , 80 , 49 , 75 },
+{ 80 , 80 , 49 , 76 },
+{ 80 , 80 , 49 , 77 },
+{ 80 , 80 , 49 , 78 },
+{ 80 , 80 , 49 , 79 },
+{ 80 , 80 , 50 , 0 },
+{ 80 , 80 , 50 , 1 },
+{ 80 , 80 , 50 , 2 },
+{ 80 , 80 , 50 , 3 },
+{ 80 , 80 , 50 , 4 },
+{ 80 , 80 , 50 , 5 },
+{ 80 , 80 , 50 , 6 },
+{ 80 , 80 , 50 , 7 },
+{ 80 , 80 , 50 , 8 },
+{ 80 , 80 , 50 , 9 },
+{ 80 , 80 , 50 , 10 },
+{ 80 , 80 , 50 , 11 },
+{ 80 , 80 , 50 , 12 },
+{ 80 , 80 , 50 , 13 },
+{ 80 , 80 , 50 , 14 },
+{ 80 , 80 , 50 , 15 },
+{ 80 , 80 , 50 , 16 },
+{ 80 , 80 , 50 , 17 },
+{ 80 , 80 , 50 , 18 },
+{ 80 , 80 , 50 , 19 },
+{ 80 , 80 , 50 , 20 },
+{ 80 , 80 , 50 , 21 },
+{ 80 , 80 , 50 , 22 },
+{ 80 , 80 , 50 , 23 },
+{ 80 , 80 , 50 , 24 },
+{ 80 , 80 , 50 , 25 },
+{ 80 , 80 , 50 , 26 },
+{ 80 , 80 , 50 , 27 },
+{ 80 , 80 , 50 , 28 },
+{ 80 , 80 , 50 , 29 },
+{ 80 , 80 , 50 , 30 },
+{ 80 , 80 , 50 , 31 },
+{ 80 , 80 , 50 , 32 },
+{ 80 , 80 , 50 , 33 },
+{ 80 , 80 , 50 , 34 },
+{ 80 , 80 , 50 , 35 },
+{ 80 , 80 , 50 , 36 },
+{ 80 , 80 , 50 , 37 },
+{ 80 , 80 , 50 , 38 },
+{ 80 , 80 , 50 , 39 },
+{ 80 , 80 , 50 , 40 },
+{ 80 , 80 , 50 , 41 },
+{ 80 , 80 , 50 , 42 },
+{ 80 , 80 , 50 , 43 },
+{ 80 , 80 , 50 , 44 },
+{ 80 , 80 , 50 , 45 },
+{ 80 , 80 , 50 , 46 },
+{ 80 , 80 , 50 , 47 },
+{ 80 , 80 , 50 , 48 },
+{ 80 , 80 , 50 , 49 },
+{ 80 , 80 , 50 , 50 },
+{ 80 , 80 , 50 , 51 },
+{ 80 , 80 , 50 , 52 },
+{ 80 , 80 , 50 , 53 },
+{ 80 , 80 , 50 , 54 },
+{ 80 , 80 , 50 , 55 },
+{ 80 , 80 , 50 , 56 },
+{ 80 , 80 , 50 , 57 },
+{ 80 , 80 , 50 , 58 },
+{ 80 , 80 , 50 , 59 },
+{ 80 , 80 , 50 , 60 },
+{ 80 , 80 , 50 , 61 },
+{ 80 , 80 , 50 , 62 },
+{ 80 , 80 , 50 , 63 },
+{ 80 , 80 , 50 , 64 },
+{ 80 , 80 , 50 , 65 },
+{ 80 , 80 , 50 , 66 },
+{ 80 , 80 , 50 , 67 },
+{ 80 , 80 , 50 , 68 },
+{ 80 , 80 , 50 , 69 },
+{ 80 , 80 , 50 , 70 },
+{ 80 , 80 , 50 , 71 },
+{ 80 , 80 , 50 , 72 },
+{ 80 , 80 , 50 , 73 },
+{ 80 , 80 , 50 , 74 },
+{ 80 , 80 , 50 , 75 },
+{ 80 , 80 , 50 , 76 },
+{ 80 , 80 , 50 , 77 },
+{ 80 , 80 , 50 , 78 },
+{ 80 , 80 , 50 , 79 },
+{ 80 , 80 , 51 , 0 },
+{ 80 , 80 , 51 , 1 },
+{ 80 , 80 , 51 , 2 },
+{ 80 , 80 , 51 , 3 },
+{ 80 , 80 , 51 , 4 },
+{ 80 , 80 , 51 , 5 },
+{ 80 , 80 , 51 , 6 },
+{ 80 , 80 , 51 , 7 },
+{ 80 , 80 , 51 , 8 },
+{ 80 , 80 , 51 , 9 },
+{ 80 , 80 , 51 , 10 },
+{ 80 , 80 , 51 , 11 },
+{ 80 , 80 , 51 , 12 },
+{ 80 , 80 , 51 , 13 },
+{ 80 , 80 , 51 , 14 },
+{ 80 , 80 , 51 , 15 },
+{ 80 , 80 , 51 , 16 },
+{ 80 , 80 , 51 , 17 },
+{ 80 , 80 , 51 , 18 },
+{ 80 , 80 , 51 , 19 },
+{ 80 , 80 , 51 , 20 },
+{ 80 , 80 , 51 , 21 },
+{ 80 , 80 , 51 , 22 },
+{ 80 , 80 , 51 , 23 },
+{ 80 , 80 , 51 , 24 },
+{ 80 , 80 , 51 , 25 },
+{ 80 , 80 , 51 , 26 },
+{ 80 , 80 , 51 , 27 },
+{ 80 , 80 , 51 , 28 },
+{ 80 , 80 , 51 , 29 },
+{ 80 , 80 , 51 , 30 },
+{ 80 , 80 , 51 , 31 },
+{ 80 , 80 , 51 , 32 },
+{ 80 , 80 , 51 , 33 },
+{ 80 , 80 , 51 , 34 },
+{ 80 , 80 , 51 , 35 },
+{ 80 , 80 , 51 , 36 },
+{ 80 , 80 , 51 , 37 },
+{ 80 , 80 , 51 , 38 },
+{ 80 , 80 , 51 , 39 },
+{ 80 , 80 , 51 , 40 },
+{ 80 , 80 , 51 , 41 },
+{ 80 , 80 , 51 , 42 },
+{ 80 , 80 , 51 , 43 },
+{ 80 , 80 , 51 , 44 },
+{ 80 , 80 , 51 , 45 },
+{ 80 , 80 , 51 , 46 },
+{ 80 , 80 , 51 , 47 },
+{ 80 , 80 , 51 , 48 },
+{ 80 , 80 , 51 , 49 },
+{ 80 , 80 , 51 , 50 },
+{ 80 , 80 , 51 , 51 },
+{ 80 , 80 , 51 , 52 },
+{ 80 , 80 , 51 , 53 },
+{ 80 , 80 , 51 , 54 },
+{ 80 , 80 , 51 , 55 },
+{ 80 , 80 , 51 , 56 },
+{ 80 , 80 , 51 , 57 },
+{ 80 , 80 , 51 , 58 },
+{ 80 , 80 , 51 , 59 },
+{ 80 , 80 , 51 , 60 },
+{ 80 , 80 , 51 , 61 },
+{ 80 , 80 , 51 , 62 },
+{ 80 , 80 , 51 , 63 },
+{ 80 , 80 , 51 , 64 },
+{ 80 , 80 , 51 , 65 },
+{ 80 , 80 , 51 , 66 },
+{ 80 , 80 , 51 , 67 },
+{ 80 , 80 , 51 , 68 },
+{ 80 , 80 , 51 , 69 },
+{ 80 , 80 , 51 , 70 },
+{ 80 , 80 , 51 , 71 },
+{ 80 , 80 , 51 , 72 },
+{ 80 , 80 , 51 , 73 },
+{ 80 , 80 , 51 , 74 },
+{ 80 , 80 , 51 , 75 },
+{ 80 , 80 , 51 , 76 },
+{ 80 , 80 , 51 , 77 },
+{ 80 , 80 , 51 , 78 },
+{ 80 , 80 , 51 , 79 },
+{ 80 , 80 , 52 , 0 },
+{ 80 , 80 , 52 , 1 },
+{ 80 , 80 , 52 , 2 },
+{ 80 , 80 , 52 , 3 },
+{ 80 , 80 , 52 , 4 },
+{ 80 , 80 , 52 , 5 },
+{ 80 , 80 , 52 , 6 },
+{ 80 , 80 , 52 , 7 },
+{ 80 , 80 , 52 , 8 },
+{ 80 , 80 , 52 , 9 },
+{ 80 , 80 , 52 , 10 },
+{ 80 , 80 , 52 , 11 },
+{ 80 , 80 , 52 , 12 },
+{ 80 , 80 , 52 , 13 },
+{ 80 , 80 , 52 , 14 },
+{ 80 , 80 , 52 , 15 },
+{ 80 , 80 , 52 , 16 },
+{ 80 , 80 , 52 , 17 },
+{ 80 , 80 , 52 , 18 },
+{ 80 , 80 , 52 , 19 },
+{ 80 , 80 , 52 , 20 },
+{ 80 , 80 , 52 , 21 },
+{ 80 , 80 , 52 , 22 },
+{ 80 , 80 , 52 , 23 },
+{ 80 , 80 , 52 , 24 },
+{ 80 , 80 , 52 , 25 },
+{ 80 , 80 , 52 , 26 },
+{ 80 , 80 , 52 , 27 },
+{ 80 , 80 , 52 , 28 },
+{ 80 , 80 , 52 , 29 },
+{ 80 , 80 , 52 , 30 },
+{ 80 , 80 , 52 , 31 },
+{ 80 , 80 , 52 , 32 },
+{ 80 , 80 , 52 , 33 },
+{ 80 , 80 , 52 , 34 },
+{ 80 , 80 , 52 , 35 },
+{ 80 , 80 , 52 , 36 },
+{ 80 , 80 , 52 , 37 },
+{ 80 , 80 , 52 , 38 },
+{ 80 , 80 , 52 , 39 },
+{ 80 , 80 , 52 , 40 },
+{ 80 , 80 , 52 , 41 },
+{ 80 , 80 , 52 , 42 },
+{ 80 , 80 , 52 , 43 },
+{ 80 , 80 , 52 , 44 },
+{ 80 , 80 , 52 , 45 },
+{ 80 , 80 , 52 , 46 },
+{ 80 , 80 , 52 , 47 },
+{ 80 , 80 , 52 , 48 },
+{ 80 , 80 , 52 , 49 },
+{ 80 , 80 , 52 , 50 },
+{ 80 , 80 , 52 , 51 },
+{ 80 , 80 , 52 , 52 },
+{ 80 , 80 , 52 , 53 },
+{ 80 , 80 , 52 , 54 },
+{ 80 , 80 , 52 , 55 },
+{ 80 , 80 , 52 , 56 },
+{ 80 , 80 , 52 , 57 },
+{ 80 , 80 , 52 , 58 },
+{ 80 , 80 , 52 , 59 },
+{ 80 , 80 , 52 , 60 },
+{ 80 , 80 , 52 , 61 },
+{ 80 , 80 , 52 , 62 },
+{ 80 , 80 , 52 , 63 },
+{ 80 , 80 , 52 , 64 },
+{ 80 , 80 , 52 , 65 },
+{ 80 , 80 , 52 , 66 },
+{ 80 , 80 , 52 , 67 },
+{ 80 , 80 , 52 , 68 },
+{ 80 , 80 , 52 , 69 },
+{ 80 , 80 , 52 , 70 },
+{ 80 , 80 , 52 , 71 },
+{ 80 , 80 , 52 , 72 },
+{ 80 , 80 , 52 , 73 },
+{ 80 , 80 , 52 , 74 },
+{ 80 , 80 , 52 , 75 },
+{ 80 , 80 , 52 , 76 },
+{ 80 , 80 , 52 , 77 },
+{ 80 , 80 , 52 , 78 },
+{ 80 , 80 , 52 , 79 },
+{ 80 , 80 , 53 , 0 },
+{ 80 , 80 , 53 , 1 },
+{ 80 , 80 , 53 , 2 },
+{ 80 , 80 , 53 , 3 },
+{ 80 , 80 , 53 , 4 },
+{ 80 , 80 , 53 , 5 },
+{ 80 , 80 , 53 , 6 },
+{ 80 , 80 , 53 , 7 },
+{ 80 , 80 , 53 , 8 },
+{ 80 , 80 , 53 , 9 },
+{ 80 , 80 , 53 , 10 },
+{ 80 , 80 , 53 , 11 },
+{ 80 , 80 , 53 , 12 },
+{ 80 , 80 , 53 , 13 },
+{ 80 , 80 , 53 , 14 },
+{ 80 , 80 , 53 , 15 },
+{ 80 , 80 , 53 , 16 },
+{ 80 , 80 , 53 , 17 },
+{ 80 , 80 , 53 , 18 },
+{ 80 , 80 , 53 , 19 },
+{ 80 , 80 , 53 , 20 },
+{ 80 , 80 , 53 , 21 },
+{ 80 , 80 , 53 , 22 },
+{ 80 , 80 , 53 , 23 },
+{ 80 , 80 , 53 , 24 },
+{ 80 , 80 , 53 , 25 },
+{ 80 , 80 , 53 , 26 },
+{ 80 , 80 , 53 , 27 },
+{ 80 , 80 , 53 , 28 },
+{ 80 , 80 , 53 , 29 },
+{ 80 , 80 , 53 , 30 },
+{ 80 , 80 , 53 , 31 },
+{ 80 , 80 , 53 , 32 },
+{ 80 , 80 , 53 , 33 },
+{ 80 , 80 , 53 , 34 },
+{ 80 , 80 , 53 , 35 },
+{ 80 , 80 , 53 , 36 },
+{ 80 , 80 , 53 , 37 },
+{ 80 , 80 , 53 , 38 },
+{ 80 , 80 , 53 , 39 },
+{ 80 , 80 , 53 , 40 },
+{ 80 , 80 , 53 , 41 },
+{ 80 , 80 , 53 , 42 },
+{ 80 , 80 , 53 , 43 },
+{ 80 , 80 , 53 , 44 },
+{ 80 , 80 , 53 , 45 },
+{ 80 , 80 , 53 , 46 },
+{ 80 , 80 , 53 , 47 },
+{ 80 , 80 , 53 , 48 },
+{ 80 , 80 , 53 , 49 },
+{ 80 , 80 , 53 , 50 },
+{ 80 , 80 , 53 , 51 },
+{ 80 , 80 , 53 , 52 },
+{ 80 , 80 , 53 , 53 },
+{ 80 , 80 , 53 , 54 },
+{ 80 , 80 , 53 , 55 },
+{ 80 , 80 , 53 , 56 },
+{ 80 , 80 , 53 , 57 },
+{ 80 , 80 , 53 , 58 },
+{ 80 , 80 , 53 , 59 },
+{ 80 , 80 , 53 , 60 },
+{ 80 , 80 , 53 , 61 },
+{ 80 , 80 , 53 , 62 },
+{ 80 , 80 , 53 , 63 },
+{ 80 , 80 , 53 , 64 },
+{ 80 , 80 , 53 , 65 },
+{ 80 , 80 , 53 , 66 },
+{ 80 , 80 , 53 , 67 },
+{ 80 , 80 , 53 , 68 },
+{ 80 , 80 , 53 , 69 },
+{ 80 , 80 , 53 , 70 },
+{ 80 , 80 , 53 , 71 },
+{ 80 , 80 , 53 , 72 },
+{ 80 , 80 , 53 , 73 },
+{ 80 , 80 , 53 , 74 },
+{ 80 , 80 , 53 , 75 },
+{ 80 , 80 , 53 , 76 },
+{ 80 , 80 , 53 , 77 },
+{ 80 , 80 , 53 , 78 },
+{ 80 , 80 , 53 , 79 },
+{ 80 , 80 , 54 , 0 },
+{ 80 , 80 , 54 , 1 },
+{ 80 , 80 , 54 , 2 },
+{ 80 , 80 , 54 , 3 },
+{ 80 , 80 , 54 , 4 },
+{ 80 , 80 , 54 , 5 },
+{ 80 , 80 , 54 , 6 },
+{ 80 , 80 , 54 , 7 },
+{ 80 , 80 , 54 , 8 },
+{ 80 , 80 , 54 , 9 },
+{ 80 , 80 , 54 , 10 },
+{ 80 , 80 , 54 , 11 },
+{ 80 , 80 , 54 , 12 },
+{ 80 , 80 , 54 , 13 },
+{ 80 , 80 , 54 , 14 },
+{ 80 , 80 , 54 , 15 },
+{ 80 , 80 , 54 , 16 },
+{ 80 , 80 , 54 , 17 },
+{ 80 , 80 , 54 , 18 },
+{ 80 , 80 , 54 , 19 },
+{ 80 , 80 , 54 , 20 },
+{ 80 , 80 , 54 , 21 },
+{ 80 , 80 , 54 , 22 },
+{ 80 , 80 , 54 , 23 },
+{ 80 , 80 , 54 , 24 },
+{ 80 , 80 , 54 , 25 },
+{ 80 , 80 , 54 , 26 },
+{ 80 , 80 , 54 , 27 },
+{ 80 , 80 , 54 , 28 },
+{ 80 , 80 , 54 , 29 },
+{ 80 , 80 , 54 , 30 },
+{ 80 , 80 , 54 , 31 },
+{ 80 , 80 , 54 , 32 },
+{ 80 , 80 , 54 , 33 },
+{ 80 , 80 , 54 , 34 },
+{ 80 , 80 , 54 , 35 },
+{ 80 , 80 , 54 , 36 },
+{ 80 , 80 , 54 , 37 },
+{ 80 , 80 , 54 , 38 },
+{ 80 , 80 , 54 , 39 },
+{ 80 , 80 , 54 , 40 },
+{ 80 , 80 , 54 , 41 },
+{ 80 , 80 , 54 , 42 },
+{ 80 , 80 , 54 , 43 },
+{ 80 , 80 , 54 , 44 },
+{ 80 , 80 , 54 , 45 },
+{ 80 , 80 , 54 , 46 },
+{ 80 , 80 , 54 , 47 },
+{ 80 , 80 , 54 , 48 },
+{ 80 , 80 , 54 , 49 },
+{ 80 , 80 , 54 , 50 },
+{ 80 , 80 , 54 , 51 },
+{ 80 , 80 , 54 , 52 },
+{ 80 , 80 , 54 , 53 },
+{ 80 , 80 , 54 , 54 },
+{ 80 , 80 , 54 , 55 },
+{ 80 , 80 , 54 , 56 },
+{ 80 , 80 , 54 , 57 },
+{ 80 , 80 , 54 , 58 },
+{ 80 , 80 , 54 , 59 },
+{ 80 , 80 , 54 , 60 },
+{ 80 , 80 , 54 , 61 },
+{ 80 , 80 , 54 , 62 },
+{ 80 , 80 , 54 , 63 },
+{ 80 , 80 , 54 , 64 },
+{ 80 , 80 , 54 , 65 },
+{ 80 , 80 , 54 , 66 },
+{ 80 , 80 , 54 , 67 },
+{ 80 , 80 , 54 , 68 },
+{ 80 , 80 , 54 , 69 },
+{ 80 , 80 , 54 , 70 },
+{ 80 , 80 , 54 , 71 },
+{ 80 , 80 , 54 , 72 },
+{ 80 , 80 , 54 , 73 },
+{ 80 , 80 , 54 , 74 },
+{ 80 , 80 , 54 , 75 },
+{ 80 , 80 , 54 , 76 },
+{ 80 , 80 , 54 , 77 },
+{ 80 , 80 , 54 , 78 },
+{ 80 , 80 , 54 , 79 },
+{ 80 , 80 , 55 , 0 },
+{ 80 , 80 , 55 , 1 },
+{ 80 , 80 , 55 , 2 },
+{ 80 , 80 , 55 , 3 },
+{ 80 , 80 , 55 , 4 },
+{ 80 , 80 , 55 , 5 },
+{ 80 , 80 , 55 , 6 },
+{ 80 , 80 , 55 , 7 },
+{ 80 , 80 , 55 , 8 },
+{ 80 , 80 , 55 , 9 },
+{ 80 , 80 , 55 , 10 },
+{ 80 , 80 , 55 , 11 },
+{ 80 , 80 , 55 , 12 },
+{ 80 , 80 , 55 , 13 },
+{ 80 , 80 , 55 , 14 },
+{ 80 , 80 , 55 , 15 },
+{ 80 , 80 , 55 , 16 },
+{ 80 , 80 , 55 , 17 },
+{ 80 , 80 , 55 , 18 },
+{ 80 , 80 , 55 , 19 },
+{ 80 , 80 , 55 , 20 },
+{ 80 , 80 , 55 , 21 },
+{ 80 , 80 , 55 , 22 },
+{ 80 , 80 , 55 , 23 },
+{ 80 , 80 , 55 , 24 },
+{ 80 , 80 , 55 , 25 },
+{ 80 , 80 , 55 , 26 },
+{ 80 , 80 , 55 , 27 },
+{ 80 , 80 , 55 , 28 },
+{ 80 , 80 , 55 , 29 },
+{ 80 , 80 , 55 , 30 },
+{ 80 , 80 , 55 , 31 },
+{ 80 , 80 , 55 , 32 },
+{ 80 , 80 , 55 , 33 },
+{ 80 , 80 , 55 , 34 },
+{ 80 , 80 , 55 , 35 },
+{ 80 , 80 , 55 , 36 },
+{ 80 , 80 , 55 , 37 },
+{ 80 , 80 , 55 , 38 },
+{ 80 , 80 , 55 , 39 },
+{ 80 , 80 , 55 , 40 },
+{ 80 , 80 , 55 , 41 },
+{ 80 , 80 , 55 , 42 },
+{ 80 , 80 , 55 , 43 },
+{ 80 , 80 , 55 , 44 },
+{ 80 , 80 , 55 , 45 },
+{ 80 , 80 , 55 , 46 },
+{ 80 , 80 , 55 , 47 },
+{ 80 , 80 , 55 , 48 },
+{ 80 , 80 , 55 , 49 },
+{ 80 , 80 , 55 , 50 },
+{ 80 , 80 , 55 , 51 },
+{ 80 , 80 , 55 , 52 },
+{ 80 , 80 , 55 , 53 },
+{ 80 , 80 , 55 , 54 },
+{ 80 , 80 , 55 , 55 },
+{ 80 , 80 , 55 , 56 },
+{ 80 , 80 , 55 , 57 },
+{ 80 , 80 , 55 , 58 },
+{ 80 , 80 , 55 , 59 },
+{ 80 , 80 , 55 , 60 },
+{ 80 , 80 , 55 , 61 },
+{ 80 , 80 , 55 , 62 },
+{ 80 , 80 , 55 , 63 },
+{ 80 , 80 , 55 , 64 },
+{ 80 , 80 , 55 , 65 },
+{ 80 , 80 , 55 , 66 },
+{ 80 , 80 , 55 , 67 },
+{ 80 , 80 , 55 , 68 },
+{ 80 , 80 , 55 , 69 },
+{ 80 , 80 , 55 , 70 },
+{ 80 , 80 , 55 , 71 },
+{ 80 , 80 , 55 , 72 },
+{ 80 , 80 , 55 , 73 },
+{ 80 , 80 , 55 , 74 },
+{ 80 , 80 , 55 , 75 },
+{ 80 , 80 , 55 , 76 },
+{ 80 , 80 , 55 , 77 },
+{ 80 , 80 , 55 , 78 },
+{ 80 , 80 , 55 , 79 },
+{ 80 , 80 , 56 , 0 },
+{ 80 , 80 , 56 , 1 },
+{ 80 , 80 , 56 , 2 },
+{ 80 , 80 , 56 , 3 },
+{ 80 , 80 , 56 , 4 },
+{ 80 , 80 , 56 , 5 },
+{ 80 , 80 , 56 , 6 },
+{ 80 , 80 , 56 , 7 },
+{ 80 , 80 , 56 , 8 },
+{ 80 , 80 , 56 , 9 },
+{ 80 , 80 , 56 , 10 },
+{ 80 , 80 , 56 , 11 },
+{ 80 , 80 , 56 , 12 },
+{ 80 , 80 , 56 , 13 },
+{ 80 , 80 , 56 , 14 },
+{ 80 , 80 , 56 , 15 },
+{ 80 , 80 , 56 , 16 },
+{ 80 , 80 , 56 , 17 },
+{ 80 , 80 , 56 , 18 },
+{ 80 , 80 , 56 , 19 },
+{ 80 , 80 , 56 , 20 },
+{ 80 , 80 , 56 , 21 },
+{ 80 , 80 , 56 , 22 },
+{ 80 , 80 , 56 , 23 },
+{ 80 , 80 , 56 , 24 },
+{ 80 , 80 , 56 , 25 },
+{ 80 , 80 , 56 , 26 },
+{ 80 , 80 , 56 , 27 },
+{ 80 , 80 , 56 , 28 },
+{ 80 , 80 , 56 , 29 },
+{ 80 , 80 , 56 , 30 },
+{ 80 , 80 , 56 , 31 },
+{ 80 , 80 , 56 , 32 },
+{ 80 , 80 , 56 , 33 },
+{ 80 , 80 , 56 , 34 },
+{ 80 , 80 , 56 , 35 },
+{ 80 , 80 , 56 , 36 },
+{ 80 , 80 , 56 , 37 },
+{ 80 , 80 , 56 , 38 },
+{ 80 , 80 , 56 , 39 },
+{ 80 , 80 , 56 , 40 },
+{ 80 , 80 , 56 , 41 },
+{ 80 , 80 , 56 , 42 },
+{ 80 , 80 , 56 , 43 },
+{ 80 , 80 , 56 , 44 },
+{ 80 , 80 , 56 , 45 },
+{ 80 , 80 , 56 , 46 },
+{ 80 , 80 , 56 , 47 },
+{ 80 , 80 , 56 , 48 },
+{ 80 , 80 , 56 , 49 },
+{ 80 , 80 , 56 , 50 },
+{ 80 , 80 , 56 , 51 },
+{ 80 , 80 , 56 , 52 },
+{ 80 , 80 , 56 , 53 },
+{ 80 , 80 , 56 , 54 },
+{ 80 , 80 , 56 , 55 },
+{ 80 , 80 , 56 , 56 },
+{ 80 , 80 , 56 , 57 },
+{ 80 , 80 , 56 , 58 },
+{ 80 , 80 , 56 , 59 },
+{ 80 , 80 , 56 , 60 },
+{ 80 , 80 , 56 , 61 },
+{ 80 , 80 , 56 , 62 },
+{ 80 , 80 , 56 , 63 },
+{ 80 , 80 , 56 , 64 },
+{ 80 , 80 , 56 , 65 },
+{ 80 , 80 , 56 , 66 },
+{ 80 , 80 , 56 , 67 },
+{ 80 , 80 , 56 , 68 },
+{ 80 , 80 , 56 , 69 },
+{ 80 , 80 , 56 , 70 },
+{ 80 , 80 , 56 , 71 },
+{ 80 , 80 , 56 , 72 },
+{ 80 , 80 , 56 , 73 },
+{ 80 , 80 , 56 , 74 },
+{ 80 , 80 , 56 , 75 },
+{ 80 , 80 , 56 , 76 },
+{ 80 , 80 , 56 , 77 },
+{ 80 , 80 , 56 , 78 },
+{ 80 , 80 , 56 , 79 },
+{ 80 , 80 , 57 , 0 },
+{ 80 , 80 , 57 , 1 },
+{ 80 , 80 , 57 , 2 },
+{ 80 , 80 , 57 , 3 },
+{ 80 , 80 , 57 , 4 },
+{ 80 , 80 , 57 , 5 },
+{ 80 , 80 , 57 , 6 },
+{ 80 , 80 , 57 , 7 },
+{ 80 , 80 , 57 , 8 },
+{ 80 , 80 , 57 , 9 },
+{ 80 , 80 , 57 , 10 },
+{ 80 , 80 , 57 , 11 },
+{ 80 , 80 , 57 , 12 },
+{ 80 , 80 , 57 , 13 },
+{ 80 , 80 , 57 , 14 },
+{ 80 , 80 , 57 , 15 },
+{ 80 , 80 , 57 , 16 },
+{ 80 , 80 , 57 , 17 },
+{ 80 , 80 , 57 , 18 },
+{ 80 , 80 , 57 , 19 },
+{ 80 , 80 , 57 , 20 },
+{ 80 , 80 , 57 , 21 },
+{ 80 , 80 , 57 , 22 },
+{ 80 , 80 , 57 , 23 },
+{ 80 , 80 , 57 , 24 },
+{ 80 , 80 , 57 , 25 },
+{ 80 , 80 , 57 , 26 },
+{ 80 , 80 , 57 , 27 },
+{ 80 , 80 , 57 , 28 },
+{ 80 , 80 , 57 , 29 },
+{ 80 , 80 , 57 , 30 },
+{ 80 , 80 , 57 , 31 },
+{ 80 , 80 , 57 , 32 },
+{ 80 , 80 , 57 , 33 },
+{ 80 , 80 , 57 , 34 },
+{ 80 , 80 , 57 , 35 },
+{ 80 , 80 , 57 , 36 },
+{ 80 , 80 , 57 , 37 },
+{ 80 , 80 , 57 , 38 },
+{ 80 , 80 , 57 , 39 },
+{ 80 , 80 , 57 , 40 },
+{ 80 , 80 , 57 , 41 },
+{ 80 , 80 , 57 , 42 },
+{ 80 , 80 , 57 , 43 },
+{ 80 , 80 , 57 , 44 },
+{ 80 , 80 , 57 , 45 },
+{ 80 , 80 , 57 , 46 },
+{ 80 , 80 , 57 , 47 },
+{ 80 , 80 , 57 , 48 },
+{ 80 , 80 , 57 , 49 },
+{ 80 , 80 , 57 , 50 },
+{ 80 , 80 , 57 , 51 },
+{ 80 , 80 , 57 , 52 },
+{ 80 , 80 , 57 , 53 },
+{ 80 , 80 , 57 , 54 },
+{ 80 , 80 , 57 , 55 },
+{ 80 , 80 , 57 , 56 },
+{ 80 , 80 , 57 , 57 },
+{ 80 , 80 , 57 , 58 },
+{ 80 , 80 , 57 , 59 },
+{ 80 , 80 , 57 , 60 },
+{ 80 , 80 , 57 , 61 },
+{ 80 , 80 , 57 , 62 },
+{ 80 , 80 , 57 , 63 },
+{ 80 , 80 , 57 , 64 },
+{ 80 , 80 , 57 , 65 },
+{ 80 , 80 , 57 , 66 },
+{ 80 , 80 , 57 , 67 },
+{ 80 , 80 , 57 , 68 },
+{ 80 , 80 , 57 , 69 },
+{ 80 , 80 , 57 , 70 },
+{ 80 , 80 , 57 , 71 },
+{ 80 , 80 , 57 , 72 },
+{ 80 , 80 , 57 , 73 },
+{ 80 , 80 , 57 , 74 },
+{ 80 , 80 , 57 , 75 },
+{ 80 , 80 , 57 , 76 },
+{ 80 , 80 , 57 , 77 },
+{ 80 , 80 , 57 , 78 },
+{ 80 , 80 , 57 , 79 },
+{ 80 , 80 , 58 , 0 },
+{ 80 , 80 , 58 , 1 },
+{ 80 , 80 , 58 , 2 },
+{ 80 , 80 , 58 , 3 },
+{ 80 , 80 , 58 , 4 },
+{ 80 , 80 , 58 , 5 },
+{ 80 , 80 , 58 , 6 },
+{ 80 , 80 , 58 , 7 },
+{ 80 , 80 , 58 , 8 },
+{ 80 , 80 , 58 , 9 },
+{ 80 , 80 , 58 , 10 },
+{ 80 , 80 , 58 , 11 },
+{ 80 , 80 , 58 , 12 },
+{ 80 , 80 , 58 , 13 },
+{ 80 , 80 , 58 , 14 },
+{ 80 , 80 , 58 , 15 },
+{ 80 , 80 , 58 , 16 },
+{ 80 , 80 , 58 , 17 },
+{ 80 , 80 , 58 , 18 },
+{ 80 , 80 , 58 , 19 },
+{ 80 , 80 , 58 , 20 },
+{ 80 , 80 , 58 , 21 },
+{ 80 , 80 , 58 , 22 },
+{ 80 , 80 , 58 , 23 },
+{ 80 , 80 , 58 , 24 },
+{ 80 , 80 , 58 , 25 },
+{ 80 , 80 , 58 , 26 },
+{ 80 , 80 , 58 , 27 },
+{ 80 , 80 , 58 , 28 },
+{ 80 , 80 , 58 , 29 },
+{ 80 , 80 , 58 , 30 },
+{ 80 , 80 , 58 , 31 },
+{ 80 , 80 , 58 , 32 },
+{ 80 , 80 , 58 , 33 },
+{ 80 , 80 , 58 , 34 },
+{ 80 , 80 , 58 , 35 },
+{ 80 , 80 , 58 , 36 },
+{ 80 , 80 , 58 , 37 },
+{ 80 , 80 , 58 , 38 },
+{ 80 , 80 , 58 , 39 },
+{ 80 , 80 , 58 , 40 },
+{ 80 , 80 , 58 , 41 },
+{ 80 , 80 , 58 , 42 },
+{ 80 , 80 , 58 , 43 },
+{ 80 , 80 , 58 , 44 },
+{ 80 , 80 , 58 , 45 },
+{ 80 , 80 , 58 , 46 },
+{ 80 , 80 , 58 , 47 },
+{ 80 , 80 , 58 , 48 },
+{ 80 , 80 , 58 , 49 },
+{ 80 , 80 , 58 , 50 },
+{ 80 , 80 , 58 , 51 },
+{ 80 , 80 , 58 , 52 },
+{ 80 , 80 , 58 , 53 },
+{ 80 , 80 , 58 , 54 },
+{ 80 , 80 , 58 , 55 },
+{ 80 , 80 , 58 , 56 },
+{ 80 , 80 , 58 , 57 },
+{ 80 , 80 , 58 , 58 },
+{ 80 , 80 , 58 , 59 },
+{ 80 , 80 , 58 , 60 },
+{ 80 , 80 , 58 , 61 },
+{ 80 , 80 , 58 , 62 },
+{ 80 , 80 , 58 , 63 },
+{ 80 , 80 , 58 , 64 },
+{ 80 , 80 , 58 , 65 },
+{ 80 , 80 , 58 , 66 },
+{ 80 , 80 , 58 , 67 },
+{ 80 , 80 , 58 , 68 },
+{ 80 , 80 , 58 , 69 },
+{ 80 , 80 , 58 , 70 },
+{ 80 , 80 , 58 , 71 },
+{ 80 , 80 , 58 , 72 },
+{ 80 , 80 , 58 , 73 },
+{ 80 , 80 , 58 , 74 },
+{ 80 , 80 , 58 , 75 },
+{ 80 , 80 , 58 , 76 },
+{ 80 , 80 , 58 , 77 },
+{ 80 , 80 , 58 , 78 },
+{ 80 , 80 , 58 , 79 },
+{ 80 , 80 , 59 , 0 },
+{ 80 , 80 , 59 , 1 },
+{ 80 , 80 , 59 , 2 },
+{ 80 , 80 , 59 , 3 },
+{ 80 , 80 , 59 , 4 },
+{ 80 , 80 , 59 , 5 },
+{ 80 , 80 , 59 , 6 },
+{ 80 , 80 , 59 , 7 },
+{ 80 , 80 , 59 , 8 },
+{ 80 , 80 , 59 , 9 },
+{ 80 , 80 , 59 , 10 },
+{ 80 , 80 , 59 , 11 },
+{ 80 , 80 , 59 , 12 },
+{ 80 , 80 , 59 , 13 },
+{ 80 , 80 , 59 , 14 },
+{ 80 , 80 , 59 , 15 },
+{ 80 , 80 , 59 , 16 },
+{ 80 , 80 , 59 , 17 },
+{ 80 , 80 , 59 , 18 },
+{ 80 , 80 , 59 , 19 },
+{ 80 , 80 , 59 , 20 },
+{ 80 , 80 , 59 , 21 },
+{ 80 , 80 , 59 , 22 },
+{ 80 , 80 , 59 , 23 },
+{ 80 , 80 , 59 , 24 },
+{ 80 , 80 , 59 , 25 },
+{ 80 , 80 , 59 , 26 },
+{ 80 , 80 , 59 , 27 },
+{ 80 , 80 , 59 , 28 },
+{ 80 , 80 , 59 , 29 },
+{ 80 , 80 , 59 , 30 },
+{ 80 , 80 , 59 , 31 },
+{ 80 , 80 , 59 , 32 },
+{ 80 , 80 , 59 , 33 },
+{ 80 , 80 , 59 , 34 },
+{ 80 , 80 , 59 , 35 },
+{ 80 , 80 , 59 , 36 },
+{ 80 , 80 , 59 , 37 },
+{ 80 , 80 , 59 , 38 },
+{ 80 , 80 , 59 , 39 },
+{ 80 , 80 , 59 , 40 },
+{ 80 , 80 , 59 , 41 },
+{ 80 , 80 , 59 , 42 },
+{ 80 , 80 , 59 , 43 },
+{ 80 , 80 , 59 , 44 },
+{ 80 , 80 , 59 , 45 },
+{ 80 , 80 , 59 , 46 },
+{ 80 , 80 , 59 , 47 },
+{ 80 , 80 , 59 , 48 },
+{ 80 , 80 , 59 , 49 },
+{ 80 , 80 , 59 , 50 },
+{ 80 , 80 , 59 , 51 },
+{ 80 , 80 , 59 , 52 },
+{ 80 , 80 , 59 , 53 },
+{ 80 , 80 , 59 , 54 },
+{ 80 , 80 , 59 , 55 },
+{ 80 , 80 , 59 , 56 },
+{ 80 , 80 , 59 , 57 },
+{ 80 , 80 , 59 , 58 },
+{ 80 , 80 , 59 , 59 },
+{ 80 , 80 , 59 , 60 },
+{ 80 , 80 , 59 , 61 },
+{ 80 , 80 , 59 , 62 },
+{ 80 , 80 , 59 , 63 },
+{ 80 , 80 , 59 , 64 },
+{ 80 , 80 , 59 , 65 },
+{ 80 , 80 , 59 , 66 },
+{ 80 , 80 , 59 , 67 },
+{ 80 , 80 , 59 , 68 },
+{ 80 , 80 , 59 , 69 },
+{ 80 , 80 , 59 , 70 },
+{ 80 , 80 , 59 , 71 },
+{ 80 , 80 , 59 , 72 },
+{ 80 , 80 , 59 , 73 },
+{ 80 , 80 , 59 , 74 },
+{ 80 , 80 , 59 , 75 },
+{ 80 , 80 , 59 , 76 },
+{ 80 , 80 , 59 , 77 },
+{ 80 , 80 , 59 , 78 },
+{ 80 , 80 , 59 , 79 },
+{ 80 , 80 , 60 , 0 },
+{ 80 , 80 , 60 , 1 },
+{ 80 , 80 , 60 , 2 },
+{ 80 , 80 , 60 , 3 },
+{ 80 , 80 , 60 , 4 },
+{ 80 , 80 , 60 , 5 },
+{ 80 , 80 , 60 , 6 },
+{ 80 , 80 , 60 , 7 },
+{ 80 , 80 , 60 , 8 },
+{ 80 , 80 , 60 , 9 },
+{ 80 , 80 , 60 , 10 },
+{ 80 , 80 , 60 , 11 },
+{ 80 , 80 , 60 , 12 },
+{ 80 , 80 , 60 , 13 },
+{ 80 , 80 , 60 , 14 },
+{ 80 , 80 , 60 , 15 },
+{ 80 , 80 , 60 , 16 },
+{ 80 , 80 , 60 , 17 },
+{ 80 , 80 , 60 , 18 },
+{ 80 , 80 , 60 , 19 },
+{ 80 , 80 , 60 , 20 },
+{ 80 , 80 , 60 , 21 },
+{ 80 , 80 , 60 , 22 },
+{ 80 , 80 , 60 , 23 },
+{ 80 , 80 , 60 , 24 },
+{ 80 , 80 , 60 , 25 },
+{ 80 , 80 , 60 , 26 },
+{ 80 , 80 , 60 , 27 },
+{ 80 , 80 , 60 , 28 },
+{ 80 , 80 , 60 , 29 },
+{ 80 , 80 , 60 , 30 },
+{ 80 , 80 , 60 , 31 },
+{ 80 , 80 , 60 , 32 },
+{ 80 , 80 , 60 , 33 },
+{ 80 , 80 , 60 , 34 },
+{ 80 , 80 , 60 , 35 },
+{ 80 , 80 , 60 , 36 },
+{ 80 , 80 , 60 , 37 },
+{ 80 , 80 , 60 , 38 },
+{ 80 , 80 , 60 , 39 },
+{ 80 , 80 , 60 , 40 },
+{ 80 , 80 , 60 , 41 },
+{ 80 , 80 , 60 , 42 },
+{ 80 , 80 , 60 , 43 },
+{ 80 , 80 , 60 , 44 },
+{ 80 , 80 , 60 , 45 },
+{ 80 , 80 , 60 , 46 },
+{ 80 , 80 , 60 , 47 },
+{ 80 , 80 , 60 , 48 },
+{ 80 , 80 , 60 , 49 },
+{ 80 , 80 , 60 , 50 },
+{ 80 , 80 , 60 , 51 },
+{ 80 , 80 , 60 , 52 },
+{ 80 , 80 , 60 , 53 },
+{ 80 , 80 , 60 , 54 },
+{ 80 , 80 , 60 , 55 },
+{ 80 , 80 , 60 , 56 },
+{ 80 , 80 , 60 , 57 },
+{ 80 , 80 , 60 , 58 },
+{ 80 , 80 , 60 , 59 },
+{ 80 , 80 , 60 , 60 },
+{ 80 , 80 , 60 , 61 },
+{ 80 , 80 , 60 , 62 },
+{ 80 , 80 , 60 , 63 },
+{ 80 , 80 , 60 , 64 },
+{ 80 , 80 , 60 , 65 },
+{ 80 , 80 , 60 , 66 },
+{ 80 , 80 , 60 , 67 },
+{ 80 , 80 , 60 , 68 },
+{ 80 , 80 , 60 , 69 },
+{ 80 , 80 , 60 , 70 },
+{ 80 , 80 , 60 , 71 },
+{ 80 , 80 , 60 , 72 },
+{ 80 , 80 , 60 , 73 },
+{ 80 , 80 , 60 , 74 },
+{ 80 , 80 , 60 , 75 },
+{ 80 , 80 , 60 , 76 },
+{ 80 , 80 , 60 , 77 },
+{ 80 , 80 , 60 , 78 },
+{ 80 , 80 , 60 , 79 },
+{ 80 , 80 , 61 , 0 },
+{ 80 , 80 , 61 , 1 },
+{ 80 , 80 , 61 , 2 },
+{ 80 , 80 , 61 , 3 },
+{ 80 , 80 , 61 , 4 },
+{ 80 , 80 , 61 , 5 },
+{ 80 , 80 , 61 , 6 },
+{ 80 , 80 , 61 , 7 },
+{ 80 , 80 , 61 , 8 },
+{ 80 , 80 , 61 , 9 },
+{ 80 , 80 , 61 , 10 },
+{ 80 , 80 , 61 , 11 },
+{ 80 , 80 , 61 , 12 },
+{ 80 , 80 , 61 , 13 },
+{ 80 , 80 , 61 , 14 },
+{ 80 , 80 , 61 , 15 },
+{ 80 , 80 , 61 , 16 },
+{ 80 , 80 , 61 , 17 },
+{ 80 , 80 , 61 , 18 },
+{ 80 , 80 , 61 , 19 },
+{ 80 , 80 , 61 , 20 },
+{ 80 , 80 , 61 , 21 },
+{ 80 , 80 , 61 , 22 },
+{ 80 , 80 , 61 , 23 },
+{ 80 , 80 , 61 , 24 },
+{ 80 , 80 , 61 , 25 },
+{ 80 , 80 , 61 , 26 },
+{ 80 , 80 , 61 , 27 },
+{ 80 , 80 , 61 , 28 },
+{ 80 , 80 , 61 , 29 },
+{ 80 , 80 , 61 , 30 },
+{ 80 , 80 , 61 , 31 },
+{ 80 , 80 , 61 , 32 },
+{ 80 , 80 , 61 , 33 },
+{ 80 , 80 , 61 , 34 },
+{ 80 , 80 , 61 , 35 },
+{ 80 , 80 , 61 , 36 },
+{ 80 , 80 , 61 , 37 },
+{ 80 , 80 , 61 , 38 },
+{ 80 , 80 , 61 , 39 },
+{ 80 , 80 , 61 , 40 },
+{ 80 , 80 , 61 , 41 },
+{ 80 , 80 , 61 , 42 },
+{ 80 , 80 , 61 , 43 },
+{ 80 , 80 , 61 , 44 },
+{ 80 , 80 , 61 , 45 },
+{ 80 , 80 , 61 , 46 },
+{ 80 , 80 , 61 , 47 },
+{ 80 , 80 , 61 , 48 },
+{ 80 , 80 , 61 , 49 },
+{ 80 , 80 , 61 , 50 },
+{ 80 , 80 , 61 , 51 },
+{ 80 , 80 , 61 , 52 },
+{ 80 , 80 , 61 , 53 },
+{ 80 , 80 , 61 , 54 },
+{ 80 , 80 , 61 , 55 },
+{ 80 , 80 , 61 , 56 },
+{ 80 , 80 , 61 , 57 },
+{ 80 , 80 , 61 , 58 },
+{ 80 , 80 , 61 , 59 },
+{ 80 , 80 , 61 , 60 },
+{ 80 , 80 , 61 , 61 },
+{ 80 , 80 , 61 , 62 },
+{ 80 , 80 , 61 , 63 },
+{ 80 , 80 , 61 , 64 },
+{ 80 , 80 , 61 , 65 },
+{ 80 , 80 , 61 , 66 },
+{ 80 , 80 , 61 , 67 },
+{ 80 , 80 , 61 , 68 },
+{ 80 , 80 , 61 , 69 },
+{ 80 , 80 , 61 , 70 },
+{ 80 , 80 , 61 , 71 },
+{ 80 , 80 , 61 , 72 },
+{ 80 , 80 , 61 , 73 },
+{ 80 , 80 , 61 , 74 },
+{ 80 , 80 , 61 , 75 },
+{ 80 , 80 , 61 , 76 },
+{ 80 , 80 , 61 , 77 },
+{ 80 , 80 , 61 , 78 },
+{ 80 , 80 , 61 , 79 },
+{ 80 , 80 , 62 , 0 },
+{ 80 , 80 , 62 , 1 },
+{ 80 , 80 , 62 , 2 },
+{ 80 , 80 , 62 , 3 },
+{ 80 , 80 , 62 , 4 },
+{ 80 , 80 , 62 , 5 },
+{ 80 , 80 , 62 , 6 },
+{ 80 , 80 , 62 , 7 },
+{ 80 , 80 , 62 , 8 },
+{ 80 , 80 , 62 , 9 },
+{ 80 , 80 , 62 , 10 },
+{ 80 , 80 , 62 , 11 },
+{ 80 , 80 , 62 , 12 },
+{ 80 , 80 , 62 , 13 },
+{ 80 , 80 , 62 , 14 },
+{ 80 , 80 , 62 , 15 },
+{ 80 , 80 , 62 , 16 },
+{ 80 , 80 , 62 , 17 },
+{ 80 , 80 , 62 , 18 },
+{ 80 , 80 , 62 , 19 },
+{ 80 , 80 , 62 , 20 },
+{ 80 , 80 , 62 , 21 },
+{ 80 , 80 , 62 , 22 },
+{ 80 , 80 , 62 , 23 },
+{ 80 , 80 , 62 , 24 },
+{ 80 , 80 , 62 , 25 },
+{ 80 , 80 , 62 , 26 },
+{ 80 , 80 , 62 , 27 },
+{ 80 , 80 , 62 , 28 },
+{ 80 , 80 , 62 , 29 },
+{ 80 , 80 , 62 , 30 },
+{ 80 , 80 , 62 , 31 },
+{ 80 , 80 , 62 , 32 },
+{ 80 , 80 , 62 , 33 },
+{ 80 , 80 , 62 , 34 },
+{ 80 , 80 , 62 , 35 },
+{ 80 , 80 , 62 , 36 },
+{ 80 , 80 , 62 , 37 },
+{ 80 , 80 , 62 , 38 },
+{ 80 , 80 , 62 , 39 },
+{ 80 , 80 , 62 , 40 },
+{ 80 , 80 , 62 , 41 },
+{ 80 , 80 , 62 , 42 },
+{ 80 , 80 , 62 , 43 },
+{ 80 , 80 , 62 , 44 },
+{ 80 , 80 , 62 , 45 },
+{ 80 , 80 , 62 , 46 },
+{ 80 , 80 , 62 , 47 },
+{ 80 , 80 , 62 , 48 },
+{ 80 , 80 , 62 , 49 },
+{ 80 , 80 , 62 , 50 },
+{ 80 , 80 , 62 , 51 },
+{ 80 , 80 , 62 , 52 },
+{ 80 , 80 , 62 , 53 },
+{ 80 , 80 , 62 , 54 },
+{ 80 , 80 , 62 , 55 },
+{ 80 , 80 , 62 , 56 },
+{ 80 , 80 , 62 , 57 },
+{ 80 , 80 , 62 , 58 },
+{ 80 , 80 , 62 , 59 },
+{ 80 , 80 , 62 , 60 },
+{ 80 , 80 , 62 , 61 },
+{ 80 , 80 , 62 , 62 },
+{ 80 , 80 , 62 , 63 },
+{ 80 , 80 , 62 , 64 },
+{ 80 , 80 , 62 , 65 },
+{ 80 , 80 , 62 , 66 },
+{ 80 , 80 , 62 , 67 },
+{ 80 , 80 , 62 , 68 },
+{ 80 , 80 , 62 , 69 },
+{ 80 , 80 , 62 , 70 },
+{ 80 , 80 , 62 , 71 },
+{ 80 , 80 , 62 , 72 },
+{ 80 , 80 , 62 , 73 },
+{ 80 , 80 , 62 , 74 },
+{ 80 , 80 , 62 , 75 },
+{ 80 , 80 , 62 , 76 },
+{ 80 , 80 , 62 , 77 },
+{ 80 , 80 , 62 , 78 },
+{ 80 , 80 , 62 , 79 },
+{ 80 , 80 , 63 , 0 },
+{ 80 , 80 , 63 , 1 },
+{ 80 , 80 , 63 , 2 },
+{ 80 , 80 , 63 , 3 },
+{ 80 , 80 , 63 , 4 },
+{ 80 , 80 , 63 , 5 },
+{ 80 , 80 , 63 , 6 },
+{ 80 , 80 , 63 , 7 },
+{ 80 , 80 , 63 , 8 },
+{ 80 , 80 , 63 , 9 },
+{ 80 , 80 , 63 , 10 },
+{ 80 , 80 , 63 , 11 },
+{ 80 , 80 , 63 , 12 },
+{ 80 , 80 , 63 , 13 },
+{ 80 , 80 , 63 , 14 },
+{ 80 , 80 , 63 , 15 },
+{ 80 , 80 , 63 , 16 },
+{ 80 , 80 , 63 , 17 },
+{ 80 , 80 , 63 , 18 },
+{ 80 , 80 , 63 , 19 },
+{ 80 , 80 , 63 , 20 },
+{ 80 , 80 , 63 , 21 },
+{ 80 , 80 , 63 , 22 },
+{ 80 , 80 , 63 , 23 },
+{ 80 , 80 , 63 , 24 },
+{ 80 , 80 , 63 , 25 },
+{ 80 , 80 , 63 , 26 },
+{ 80 , 80 , 63 , 27 },
+{ 80 , 80 , 63 , 28 },
+{ 80 , 80 , 63 , 29 },
+{ 80 , 80 , 63 , 30 },
+{ 80 , 80 , 63 , 31 },
+{ 80 , 80 , 63 , 32 },
+{ 80 , 80 , 63 , 33 },
+{ 80 , 80 , 63 , 34 },
+{ 80 , 80 , 63 , 35 },
+{ 80 , 80 , 63 , 36 },
+{ 80 , 80 , 63 , 37 },
+{ 80 , 80 , 63 , 38 },
+{ 80 , 80 , 63 , 39 },
+{ 80 , 80 , 63 , 40 },
+{ 80 , 80 , 63 , 41 },
+{ 80 , 80 , 63 , 42 },
+{ 80 , 80 , 63 , 43 },
+{ 80 , 80 , 63 , 44 },
+{ 80 , 80 , 63 , 45 },
+{ 80 , 80 , 63 , 46 },
+{ 80 , 80 , 63 , 47 },
+{ 80 , 80 , 63 , 48 },
+{ 80 , 80 , 63 , 49 },
+{ 80 , 80 , 63 , 50 },
+{ 80 , 80 , 63 , 51 },
+{ 80 , 80 , 63 , 52 },
+{ 80 , 80 , 63 , 53 },
+{ 80 , 80 , 63 , 54 },
+{ 80 , 80 , 63 , 55 },
+{ 80 , 80 , 63 , 56 },
+{ 80 , 80 , 63 , 57 },
+{ 80 , 80 , 63 , 58 },
+{ 80 , 80 , 63 , 59 },
+{ 80 , 80 , 63 , 60 },
+{ 80 , 80 , 63 , 61 },
+{ 80 , 80 , 63 , 62 },
+{ 80 , 80 , 63 , 63 },
+{ 80 , 80 , 63 , 64 },
+{ 80 , 80 , 63 , 65 },
+{ 80 , 80 , 63 , 66 },
+{ 80 , 80 , 63 , 67 },
+{ 80 , 80 , 63 , 68 },
+{ 80 , 80 , 63 , 69 },
+{ 80 , 80 , 63 , 70 },
+{ 80 , 80 , 63 , 71 },
+{ 80 , 80 , 63 , 72 },
+{ 80 , 80 , 63 , 73 },
+{ 80 , 80 , 63 , 74 },
+{ 80 , 80 , 63 , 75 },
+{ 80 , 80 , 63 , 76 },
+{ 80 , 80 , 63 , 77 },
+{ 80 , 80 , 63 , 78 },
+{ 80 , 80 , 63 , 79 },
+{ 80 , 80 , 64 , 0 },
+{ 80 , 80 , 64 , 1 },
+{ 80 , 80 , 64 , 2 },
+{ 80 , 80 , 64 , 3 },
+{ 80 , 80 , 64 , 4 },
+{ 80 , 80 , 64 , 5 },
+{ 80 , 80 , 64 , 6 },
+{ 80 , 80 , 64 , 7 },
+{ 80 , 80 , 64 , 8 },
+{ 80 , 80 , 64 , 9 },
+{ 80 , 80 , 64 , 10 },
+{ 80 , 80 , 64 , 11 },
+{ 80 , 80 , 64 , 12 },
+{ 80 , 80 , 64 , 13 },
+{ 80 , 80 , 64 , 14 },
+{ 80 , 80 , 64 , 15 },
+{ 80 , 80 , 64 , 16 },
+{ 80 , 80 , 64 , 17 },
+{ 80 , 80 , 64 , 18 },
+{ 80 , 80 , 64 , 19 },
+{ 80 , 80 , 64 , 20 },
+{ 80 , 80 , 64 , 21 },
+{ 80 , 80 , 64 , 22 },
+{ 80 , 80 , 64 , 23 },
+{ 80 , 80 , 64 , 24 },
+{ 80 , 80 , 64 , 25 },
+{ 80 , 80 , 64 , 26 },
+{ 80 , 80 , 64 , 27 },
+{ 80 , 80 , 64 , 28 },
+{ 80 , 80 , 64 , 29 },
+{ 80 , 80 , 64 , 30 },
+{ 80 , 80 , 64 , 31 },
+{ 80 , 80 , 64 , 32 },
+{ 80 , 80 , 64 , 33 },
+{ 80 , 80 , 64 , 34 },
+{ 80 , 80 , 64 , 35 },
+{ 80 , 80 , 64 , 36 },
+{ 80 , 80 , 64 , 37 },
+{ 80 , 80 , 64 , 38 },
+{ 80 , 80 , 64 , 39 },
+{ 80 , 80 , 64 , 40 },
+{ 80 , 80 , 64 , 41 },
+{ 80 , 80 , 64 , 42 },
+{ 80 , 80 , 64 , 43 },
+{ 80 , 80 , 64 , 44 },
+{ 80 , 80 , 64 , 45 },
+{ 80 , 80 , 64 , 46 },
+{ 80 , 80 , 64 , 47 },
+{ 80 , 80 , 64 , 48 },
+{ 80 , 80 , 64 , 49 },
+{ 80 , 80 , 64 , 50 },
+{ 80 , 80 , 64 , 51 },
+{ 80 , 80 , 64 , 52 },
+{ 80 , 80 , 64 , 53 },
+{ 80 , 80 , 64 , 54 },
+{ 80 , 80 , 64 , 55 },
+{ 80 , 80 , 64 , 56 },
+{ 80 , 80 , 64 , 57 },
+{ 80 , 80 , 64 , 58 },
+{ 80 , 80 , 64 , 59 },
+{ 80 , 80 , 64 , 60 },
+{ 80 , 80 , 64 , 61 },
+{ 80 , 80 , 64 , 62 },
+{ 80 , 80 , 64 , 63 },
+{ 80 , 80 , 64 , 64 },
+{ 80 , 80 , 64 , 65 },
+{ 80 , 80 , 64 , 66 },
+{ 80 , 80 , 64 , 67 },
+{ 80 , 80 , 64 , 68 },
+{ 80 , 80 , 64 , 69 },
+{ 80 , 80 , 64 , 70 },
+{ 80 , 80 , 64 , 71 },
+{ 80 , 80 , 64 , 72 },
+{ 80 , 80 , 64 , 73 },
+{ 80 , 80 , 64 , 74 },
+{ 80 , 80 , 64 , 75 },
+{ 80 , 80 , 64 , 76 },
+{ 80 , 80 , 64 , 77 },
+{ 80 , 80 , 64 , 78 },
+{ 80 , 80 , 64 , 79 },
+{ 80 , 80 , 65 , 0 },
+{ 80 , 80 , 65 , 1 },
+{ 80 , 80 , 65 , 2 },
+{ 80 , 80 , 65 , 3 },
+{ 80 , 80 , 65 , 4 },
+{ 80 , 80 , 65 , 5 },
+{ 80 , 80 , 65 , 6 },
+{ 80 , 80 , 65 , 7 },
+{ 80 , 80 , 65 , 8 },
+{ 80 , 80 , 65 , 9 },
+{ 80 , 80 , 65 , 10 },
+{ 80 , 80 , 65 , 11 },
+{ 80 , 80 , 65 , 12 },
+{ 80 , 80 , 65 , 13 },
+{ 80 , 80 , 65 , 14 },
+{ 80 , 80 , 65 , 15 },
+{ 80 , 80 , 65 , 16 },
+{ 80 , 80 , 65 , 17 },
+{ 80 , 80 , 65 , 18 },
+{ 80 , 80 , 65 , 19 },
+{ 80 , 80 , 65 , 20 },
+{ 80 , 80 , 65 , 21 },
+{ 80 , 80 , 65 , 22 },
+{ 80 , 80 , 65 , 23 },
+{ 80 , 80 , 65 , 24 },
+{ 80 , 80 , 65 , 25 },
+{ 80 , 80 , 65 , 26 },
+{ 80 , 80 , 65 , 27 },
+{ 80 , 80 , 65 , 28 },
+{ 80 , 80 , 65 , 29 },
+{ 80 , 80 , 65 , 30 },
+{ 80 , 80 , 65 , 31 },
+{ 80 , 80 , 65 , 32 },
+{ 80 , 80 , 65 , 33 },
+{ 80 , 80 , 65 , 34 },
+{ 80 , 80 , 65 , 35 },
+{ 80 , 80 , 65 , 36 },
+{ 80 , 80 , 65 , 37 },
+{ 80 , 80 , 65 , 38 },
+{ 80 , 80 , 65 , 39 },
+{ 80 , 80 , 65 , 40 },
+{ 80 , 80 , 65 , 41 },
+{ 80 , 80 , 65 , 42 },
+{ 80 , 80 , 65 , 43 },
+{ 80 , 80 , 65 , 44 },
+{ 80 , 80 , 65 , 45 },
+{ 80 , 80 , 65 , 46 },
+{ 80 , 80 , 65 , 47 },
+{ 80 , 80 , 65 , 48 },
+{ 80 , 80 , 65 , 49 },
+{ 80 , 80 , 65 , 50 },
+{ 80 , 80 , 65 , 51 },
+{ 80 , 80 , 65 , 52 },
+{ 80 , 80 , 65 , 53 },
+{ 80 , 80 , 65 , 54 },
+{ 80 , 80 , 65 , 55 },
+{ 80 , 80 , 65 , 56 },
+{ 80 , 80 , 65 , 57 },
+{ 80 , 80 , 65 , 58 },
+{ 80 , 80 , 65 , 59 },
+{ 80 , 80 , 65 , 60 },
+{ 80 , 80 , 65 , 61 },
+{ 80 , 80 , 65 , 62 },
+{ 80 , 80 , 65 , 63 },
+{ 80 , 80 , 65 , 64 },
+{ 80 , 80 , 65 , 65 },
+{ 80 , 80 , 65 , 66 },
+{ 80 , 80 , 65 , 67 },
+{ 80 , 80 , 65 , 68 },
+{ 80 , 80 , 65 , 69 },
+{ 80 , 80 , 65 , 70 },
+{ 80 , 80 , 65 , 71 },
+{ 80 , 80 , 65 , 72 },
+{ 80 , 80 , 65 , 73 },
+{ 80 , 80 , 65 , 74 },
+{ 80 , 80 , 65 , 75 },
+{ 80 , 80 , 65 , 76 },
+{ 80 , 80 , 65 , 77 },
+{ 80 , 80 , 65 , 78 },
+{ 80 , 80 , 65 , 79 },
+{ 80 , 80 , 66 , 0 },
+{ 80 , 80 , 66 , 1 },
+{ 80 , 80 , 66 , 2 },
+{ 80 , 80 , 66 , 3 },
+{ 80 , 80 , 66 , 4 },
+{ 80 , 80 , 66 , 5 },
+{ 80 , 80 , 66 , 6 },
+{ 80 , 80 , 66 , 7 },
+{ 80 , 80 , 66 , 8 },
+{ 80 , 80 , 66 , 9 },
+{ 80 , 80 , 66 , 10 },
+{ 80 , 80 , 66 , 11 },
+{ 80 , 80 , 66 , 12 },
+{ 80 , 80 , 66 , 13 },
+{ 80 , 80 , 66 , 14 },
+{ 80 , 80 , 66 , 15 },
+{ 80 , 80 , 66 , 16 },
+{ 80 , 80 , 66 , 17 },
+{ 80 , 80 , 66 , 18 },
+{ 80 , 80 , 66 , 19 },
+{ 80 , 80 , 66 , 20 },
+{ 80 , 80 , 66 , 21 },
+{ 80 , 80 , 66 , 22 },
+{ 80 , 80 , 66 , 23 },
+{ 80 , 80 , 66 , 24 },
+{ 80 , 80 , 66 , 25 },
+{ 80 , 80 , 66 , 26 },
+{ 80 , 80 , 66 , 27 },
+{ 80 , 80 , 66 , 28 },
+{ 80 , 80 , 66 , 29 },
+{ 80 , 80 , 66 , 30 },
+{ 80 , 80 , 66 , 31 },
+{ 80 , 80 , 66 , 32 },
+{ 80 , 80 , 66 , 33 },
+{ 80 , 80 , 66 , 34 },
+{ 80 , 80 , 66 , 35 },
+{ 80 , 80 , 66 , 36 },
+{ 80 , 80 , 66 , 37 },
+{ 80 , 80 , 66 , 38 },
+{ 80 , 80 , 66 , 39 },
+{ 80 , 80 , 66 , 40 },
+{ 80 , 80 , 66 , 41 },
+{ 80 , 80 , 66 , 42 },
+{ 80 , 80 , 66 , 43 },
+{ 80 , 80 , 66 , 44 },
+{ 80 , 80 , 66 , 45 },
+{ 80 , 80 , 66 , 46 },
+{ 80 , 80 , 66 , 47 },
+{ 80 , 80 , 66 , 48 },
+{ 80 , 80 , 66 , 49 },
+{ 80 , 80 , 66 , 50 },
+{ 80 , 80 , 66 , 51 },
+{ 80 , 80 , 66 , 52 },
+{ 80 , 80 , 66 , 53 },
+{ 80 , 80 , 66 , 54 },
+{ 80 , 80 , 66 , 55 },
+{ 80 , 80 , 66 , 56 },
+{ 80 , 80 , 66 , 57 },
+{ 80 , 80 , 66 , 58 },
+{ 80 , 80 , 66 , 59 },
+{ 80 , 80 , 66 , 60 },
+{ 80 , 80 , 66 , 61 },
+{ 80 , 80 , 66 , 62 },
+{ 80 , 80 , 66 , 63 },
+{ 80 , 80 , 66 , 64 },
+{ 80 , 80 , 66 , 65 },
+{ 80 , 80 , 66 , 66 },
+{ 80 , 80 , 66 , 67 },
+{ 80 , 80 , 66 , 68 },
+{ 80 , 80 , 66 , 69 },
+{ 80 , 80 , 66 , 70 },
+{ 80 , 80 , 66 , 71 },
+{ 80 , 80 , 66 , 72 },
+{ 80 , 80 , 66 , 73 },
+{ 80 , 80 , 66 , 74 },
+{ 80 , 80 , 66 , 75 },
+{ 80 , 80 , 66 , 76 },
+{ 80 , 80 , 66 , 77 },
+{ 80 , 80 , 66 , 78 },
+{ 80 , 80 , 66 , 79 },
+{ 80 , 80 , 67 , 0 },
+{ 80 , 80 , 67 , 1 },
+{ 80 , 80 , 67 , 2 },
+{ 80 , 80 , 67 , 3 },
+{ 80 , 80 , 67 , 4 },
+{ 80 , 80 , 67 , 5 },
+{ 80 , 80 , 67 , 6 },
+{ 80 , 80 , 67 , 7 },
+{ 80 , 80 , 67 , 8 },
+{ 80 , 80 , 67 , 9 },
+{ 80 , 80 , 67 , 10 },
+{ 80 , 80 , 67 , 11 },
+{ 80 , 80 , 67 , 12 },
+{ 80 , 80 , 67 , 13 },
+{ 80 , 80 , 67 , 14 },
+{ 80 , 80 , 67 , 15 },
+{ 80 , 80 , 67 , 16 },
+{ 80 , 80 , 67 , 17 },
+{ 80 , 80 , 67 , 18 },
+{ 80 , 80 , 67 , 19 },
+{ 80 , 80 , 67 , 20 },
+{ 80 , 80 , 67 , 21 },
+{ 80 , 80 , 67 , 22 },
+{ 80 , 80 , 67 , 23 },
+{ 80 , 80 , 67 , 24 },
+{ 80 , 80 , 67 , 25 },
+{ 80 , 80 , 67 , 26 },
+{ 80 , 80 , 67 , 27 },
+{ 80 , 80 , 67 , 28 },
+{ 80 , 80 , 67 , 29 },
+{ 80 , 80 , 67 , 30 },
+{ 80 , 80 , 67 , 31 },
+{ 80 , 80 , 67 , 32 },
+{ 80 , 80 , 67 , 33 },
+{ 80 , 80 , 67 , 34 },
+{ 80 , 80 , 67 , 35 },
+{ 80 , 80 , 67 , 36 },
+{ 80 , 80 , 67 , 37 },
+{ 80 , 80 , 67 , 38 },
+{ 80 , 80 , 67 , 39 },
+{ 80 , 80 , 67 , 40 },
+{ 80 , 80 , 67 , 41 },
+{ 80 , 80 , 67 , 42 },
+{ 80 , 80 , 67 , 43 },
+{ 80 , 80 , 67 , 44 },
+{ 80 , 80 , 67 , 45 },
+{ 80 , 80 , 67 , 46 },
+{ 80 , 80 , 67 , 47 },
+{ 80 , 80 , 67 , 48 },
+{ 80 , 80 , 67 , 49 },
+{ 80 , 80 , 67 , 50 },
+{ 80 , 80 , 67 , 51 },
+{ 80 , 80 , 67 , 52 },
+{ 80 , 80 , 67 , 53 },
+{ 80 , 80 , 67 , 54 },
+{ 80 , 80 , 67 , 55 },
+{ 80 , 80 , 67 , 56 },
+{ 80 , 80 , 67 , 57 },
+{ 80 , 80 , 67 , 58 },
+{ 80 , 80 , 67 , 59 },
+{ 80 , 80 , 67 , 60 },
+{ 80 , 80 , 67 , 61 },
+{ 80 , 80 , 67 , 62 },
+{ 80 , 80 , 67 , 63 },
+{ 80 , 80 , 67 , 64 },
+{ 80 , 80 , 67 , 65 },
+{ 80 , 80 , 67 , 66 },
+{ 80 , 80 , 67 , 67 },
+{ 80 , 80 , 67 , 68 },
+{ 80 , 80 , 67 , 69 },
+{ 80 , 80 , 67 , 70 },
+{ 80 , 80 , 67 , 71 },
+{ 80 , 80 , 67 , 72 },
+{ 80 , 80 , 67 , 73 },
+{ 80 , 80 , 67 , 74 },
+{ 80 , 80 , 67 , 75 },
+{ 80 , 80 , 67 , 76 },
+{ 80 , 80 , 67 , 77 },
+{ 80 , 80 , 67 , 78 },
+{ 80 , 80 , 67 , 79 },
+{ 80 , 80 , 68 , 0 },
+{ 80 , 80 , 68 , 1 },
+{ 80 , 80 , 68 , 2 },
+{ 80 , 80 , 68 , 3 },
+{ 80 , 80 , 68 , 4 },
+{ 80 , 80 , 68 , 5 },
+{ 80 , 80 , 68 , 6 },
+{ 80 , 80 , 68 , 7 },
+{ 80 , 80 , 68 , 8 },
+{ 80 , 80 , 68 , 9 },
+{ 80 , 80 , 68 , 10 },
+{ 80 , 80 , 68 , 11 },
+{ 80 , 80 , 68 , 12 },
+{ 80 , 80 , 68 , 13 },
+{ 80 , 80 , 68 , 14 },
+{ 80 , 80 , 68 , 15 },
+{ 80 , 80 , 68 , 16 },
+{ 80 , 80 , 68 , 17 },
+{ 80 , 80 , 68 , 18 },
+{ 80 , 80 , 68 , 19 },
+{ 80 , 80 , 68 , 20 },
+{ 80 , 80 , 68 , 21 },
+{ 80 , 80 , 68 , 22 },
+{ 80 , 80 , 68 , 23 },
+{ 80 , 80 , 68 , 24 },
+{ 80 , 80 , 68 , 25 },
+{ 80 , 80 , 68 , 26 },
+{ 80 , 80 , 68 , 27 },
+{ 80 , 80 , 68 , 28 },
+{ 80 , 80 , 68 , 29 },
+{ 80 , 80 , 68 , 30 },
+{ 80 , 80 , 68 , 31 },
+{ 80 , 80 , 68 , 32 },
+{ 80 , 80 , 68 , 33 },
+{ 80 , 80 , 68 , 34 },
+{ 80 , 80 , 68 , 35 },
+{ 80 , 80 , 68 , 36 },
+{ 80 , 80 , 68 , 37 },
+{ 80 , 80 , 68 , 38 },
+{ 80 , 80 , 68 , 39 },
+{ 80 , 80 , 68 , 40 },
+{ 80 , 80 , 68 , 41 },
+{ 80 , 80 , 68 , 42 },
+{ 80 , 80 , 68 , 43 },
+{ 80 , 80 , 68 , 44 },
+{ 80 , 80 , 68 , 45 },
+{ 80 , 80 , 68 , 46 },
+{ 80 , 80 , 68 , 47 },
+{ 80 , 80 , 68 , 48 },
+{ 80 , 80 , 68 , 49 },
+{ 80 , 80 , 68 , 50 },
+{ 80 , 80 , 68 , 51 },
+{ 80 , 80 , 68 , 52 },
+{ 80 , 80 , 68 , 53 },
+{ 80 , 80 , 68 , 54 },
+{ 80 , 80 , 68 , 55 },
+{ 80 , 80 , 68 , 56 },
+{ 80 , 80 , 68 , 57 },
+{ 80 , 80 , 68 , 58 },
+{ 80 , 80 , 68 , 59 },
+{ 80 , 80 , 68 , 60 },
+{ 80 , 80 , 68 , 61 },
+{ 80 , 80 , 68 , 62 },
+{ 80 , 80 , 68 , 63 },
+{ 80 , 80 , 68 , 64 },
+{ 80 , 80 , 68 , 65 },
+{ 80 , 80 , 68 , 66 },
+{ 80 , 80 , 68 , 67 },
+{ 80 , 80 , 68 , 68 },
+{ 80 , 80 , 68 , 69 },
+{ 80 , 80 , 68 , 70 },
+{ 80 , 80 , 68 , 71 },
+{ 80 , 80 , 68 , 72 },
+{ 80 , 80 , 68 , 73 },
+{ 80 , 80 , 68 , 74 },
+{ 80 , 80 , 68 , 75 },
+{ 80 , 80 , 68 , 76 },
+{ 80 , 80 , 68 , 77 },
+{ 80 , 80 , 68 , 78 },
+{ 80 , 80 , 68 , 79 },
+{ 80 , 80 , 69 , 0 },
+{ 80 , 80 , 69 , 1 },
+{ 80 , 80 , 69 , 2 },
+{ 80 , 80 , 69 , 3 },
+{ 80 , 80 , 69 , 4 },
+{ 80 , 80 , 69 , 5 },
+{ 80 , 80 , 69 , 6 },
+{ 80 , 80 , 69 , 7 },
+{ 80 , 80 , 69 , 8 },
+{ 80 , 80 , 69 , 9 },
+{ 80 , 80 , 69 , 10 },
+{ 80 , 80 , 69 , 11 },
+{ 80 , 80 , 69 , 12 },
+{ 80 , 80 , 69 , 13 },
+{ 80 , 80 , 69 , 14 },
+{ 80 , 80 , 69 , 15 },
+{ 80 , 80 , 69 , 16 },
+{ 80 , 80 , 69 , 17 },
+{ 80 , 80 , 69 , 18 },
+{ 80 , 80 , 69 , 19 },
+{ 80 , 80 , 69 , 20 },
+{ 80 , 80 , 69 , 21 },
+{ 80 , 80 , 69 , 22 },
+{ 80 , 80 , 69 , 23 },
+{ 80 , 80 , 69 , 24 },
+{ 80 , 80 , 69 , 25 },
+{ 80 , 80 , 69 , 26 },
+{ 80 , 80 , 69 , 27 },
+{ 80 , 80 , 69 , 28 },
+{ 80 , 80 , 69 , 29 },
+{ 80 , 80 , 69 , 30 },
+{ 80 , 80 , 69 , 31 },
+{ 80 , 80 , 69 , 32 },
+{ 80 , 80 , 69 , 33 },
+{ 80 , 80 , 69 , 34 },
+{ 80 , 80 , 69 , 35 },
+{ 80 , 80 , 69 , 36 },
+{ 80 , 80 , 69 , 37 },
+{ 80 , 80 , 69 , 38 },
+{ 80 , 80 , 69 , 39 },
+{ 80 , 80 , 69 , 40 },
+{ 80 , 80 , 69 , 41 },
+{ 80 , 80 , 69 , 42 },
+{ 80 , 80 , 69 , 43 },
+{ 80 , 80 , 69 , 44 },
+{ 80 , 80 , 69 , 45 },
+{ 80 , 80 , 69 , 46 },
+{ 80 , 80 , 69 , 47 },
+{ 80 , 80 , 69 , 48 },
+{ 80 , 80 , 69 , 49 },
+{ 80 , 80 , 69 , 50 },
+{ 80 , 80 , 69 , 51 },
+{ 80 , 80 , 69 , 52 },
+{ 80 , 80 , 69 , 53 },
+{ 80 , 80 , 69 , 54 },
+{ 80 , 80 , 69 , 55 },
+{ 80 , 80 , 69 , 56 },
+{ 80 , 80 , 69 , 57 },
+{ 80 , 80 , 69 , 58 },
+{ 80 , 80 , 69 , 59 },
+{ 80 , 80 , 69 , 60 },
+{ 80 , 80 , 69 , 61 },
+{ 80 , 80 , 69 , 62 },
+{ 80 , 80 , 69 , 63 },
+{ 80 , 80 , 69 , 64 },
+{ 80 , 80 , 69 , 65 },
+{ 80 , 80 , 69 , 66 },
+{ 80 , 80 , 69 , 67 },
+{ 80 , 80 , 69 , 68 },
+{ 80 , 80 , 69 , 69 },
+{ 80 , 80 , 69 , 70 },
+{ 80 , 80 , 69 , 71 },
+{ 80 , 80 , 69 , 72 },
+{ 80 , 80 , 69 , 73 },
+{ 80 , 80 , 69 , 74 },
+{ 80 , 80 , 69 , 75 },
+{ 80 , 80 , 69 , 76 },
+{ 80 , 80 , 69 , 77 },
+{ 80 , 80 , 69 , 78 },
+{ 80 , 80 , 69 , 79 },
+{ 80 , 80 , 70 , 0 },
+{ 80 , 80 , 70 , 1 },
+{ 80 , 80 , 70 , 2 },
+{ 80 , 80 , 70 , 3 },
+{ 80 , 80 , 70 , 4 },
+{ 80 , 80 , 70 , 5 },
+{ 80 , 80 , 70 , 6 },
+{ 80 , 80 , 70 , 7 },
+{ 80 , 80 , 70 , 8 },
+{ 80 , 80 , 70 , 9 },
+{ 80 , 80 , 70 , 10 },
+{ 80 , 80 , 70 , 11 },
+{ 80 , 80 , 70 , 12 },
+{ 80 , 80 , 70 , 13 },
+{ 80 , 80 , 70 , 14 },
+{ 80 , 80 , 70 , 15 },
+{ 80 , 80 , 70 , 16 },
+{ 80 , 80 , 70 , 17 },
+{ 80 , 80 , 70 , 18 },
+{ 80 , 80 , 70 , 19 },
+{ 80 , 80 , 70 , 20 },
+{ 80 , 80 , 70 , 21 },
+{ 80 , 80 , 70 , 22 },
+{ 80 , 80 , 70 , 23 },
+{ 80 , 80 , 70 , 24 },
+{ 80 , 80 , 70 , 25 },
+{ 80 , 80 , 70 , 26 },
+{ 80 , 80 , 70 , 27 },
+{ 80 , 80 , 70 , 28 },
+{ 80 , 80 , 70 , 29 },
+{ 80 , 80 , 70 , 30 },
+{ 80 , 80 , 70 , 31 },
+{ 80 , 80 , 70 , 32 },
+{ 80 , 80 , 70 , 33 },
+{ 80 , 80 , 70 , 34 },
+{ 80 , 80 , 70 , 35 },
+{ 80 , 80 , 70 , 36 },
+{ 80 , 80 , 70 , 37 },
+{ 80 , 80 , 70 , 38 },
+{ 80 , 80 , 70 , 39 },
+{ 80 , 80 , 70 , 40 },
+{ 80 , 80 , 70 , 41 },
+{ 80 , 80 , 70 , 42 },
+{ 80 , 80 , 70 , 43 },
+{ 80 , 80 , 70 , 44 },
+{ 80 , 80 , 70 , 45 },
+{ 80 , 80 , 70 , 46 },
+{ 80 , 80 , 70 , 47 },
+{ 80 , 80 , 70 , 48 },
+{ 80 , 80 , 70 , 49 },
+{ 80 , 80 , 70 , 50 },
+{ 80 , 80 , 70 , 51 },
+{ 80 , 80 , 70 , 52 },
+{ 80 , 80 , 70 , 53 },
+{ 80 , 80 , 70 , 54 },
+{ 80 , 80 , 70 , 55 },
+{ 80 , 80 , 70 , 56 },
+{ 80 , 80 , 70 , 57 },
+{ 80 , 80 , 70 , 58 },
+{ 80 , 80 , 70 , 59 },
+{ 80 , 80 , 70 , 60 },
+{ 80 , 80 , 70 , 61 },
+{ 80 , 80 , 70 , 62 },
+{ 80 , 80 , 70 , 63 },
+{ 80 , 80 , 70 , 64 },
+{ 80 , 80 , 70 , 65 },
+{ 80 , 80 , 70 , 66 },
+{ 80 , 80 , 70 , 67 },
+{ 80 , 80 , 70 , 68 },
+{ 80 , 80 , 70 , 69 },
+{ 80 , 80 , 70 , 70 },
+{ 80 , 80 , 70 , 71 },
+{ 80 , 80 , 70 , 72 },
+{ 80 , 80 , 70 , 73 },
+{ 80 , 80 , 70 , 74 },
+{ 80 , 80 , 70 , 75 },
+{ 80 , 80 , 70 , 76 },
+{ 80 , 80 , 70 , 77 },
+{ 80 , 80 , 70 , 78 },
+{ 80 , 80 , 70 , 79 },
+{ 80 , 80 , 71 , 0 },
+{ 80 , 80 , 71 , 1 },
+{ 80 , 80 , 71 , 2 },
+{ 80 , 80 , 71 , 3 },
+{ 80 , 80 , 71 , 4 },
+{ 80 , 80 , 71 , 5 },
+{ 80 , 80 , 71 , 6 },
+{ 80 , 80 , 71 , 7 },
+{ 80 , 80 , 71 , 8 },
+{ 80 , 80 , 71 , 9 },
+{ 80 , 80 , 71 , 10 },
+{ 80 , 80 , 71 , 11 },
+{ 80 , 80 , 71 , 12 },
+{ 80 , 80 , 71 , 13 },
+{ 80 , 80 , 71 , 14 },
+{ 80 , 80 , 71 , 15 },
+{ 80 , 80 , 71 , 16 },
+{ 80 , 80 , 71 , 17 },
+{ 80 , 80 , 71 , 18 },
+{ 80 , 80 , 71 , 19 },
+{ 80 , 80 , 71 , 20 },
+{ 80 , 80 , 71 , 21 },
+{ 80 , 80 , 71 , 22 },
+{ 80 , 80 , 71 , 23 },
+{ 80 , 80 , 71 , 24 },
+{ 80 , 80 , 71 , 25 },
+{ 80 , 80 , 71 , 26 },
+{ 80 , 80 , 71 , 27 },
+{ 80 , 80 , 71 , 28 },
+{ 80 , 80 , 71 , 29 },
+{ 80 , 80 , 71 , 30 },
+{ 80 , 80 , 71 , 31 },
+{ 80 , 80 , 71 , 32 },
+{ 80 , 80 , 71 , 33 },
+{ 80 , 80 , 71 , 34 },
+{ 80 , 80 , 71 , 35 },
+{ 80 , 80 , 71 , 36 },
+{ 80 , 80 , 71 , 37 },
+{ 80 , 80 , 71 , 38 },
+{ 80 , 80 , 71 , 39 },
+{ 80 , 80 , 71 , 40 },
+{ 80 , 80 , 71 , 41 },
+{ 80 , 80 , 71 , 42 },
+{ 80 , 80 , 71 , 43 },
+{ 80 , 80 , 71 , 44 },
+{ 80 , 80 , 71 , 45 },
+{ 80 , 80 , 71 , 46 },
+{ 80 , 80 , 71 , 47 },
+{ 80 , 80 , 71 , 48 },
+{ 80 , 80 , 71 , 49 },
+{ 80 , 80 , 71 , 50 },
+{ 80 , 80 , 71 , 51 },
+{ 80 , 80 , 71 , 52 },
+{ 80 , 80 , 71 , 53 },
+{ 80 , 80 , 71 , 54 },
+{ 80 , 80 , 71 , 55 },
+{ 80 , 80 , 71 , 56 },
+{ 80 , 80 , 71 , 57 },
+{ 80 , 80 , 71 , 58 },
+{ 80 , 80 , 71 , 59 },
+{ 80 , 80 , 71 , 60 },
+{ 80 , 80 , 71 , 61 },
+{ 80 , 80 , 71 , 62 },
+{ 80 , 80 , 71 , 63 },
+{ 80 , 80 , 71 , 64 },
+{ 80 , 80 , 71 , 65 },
+{ 80 , 80 , 71 , 66 },
+{ 80 , 80 , 71 , 67 },
+{ 80 , 80 , 71 , 68 },
+{ 80 , 80 , 71 , 69 },
+{ 80 , 80 , 71 , 70 },
+{ 80 , 80 , 71 , 71 },
+{ 80 , 80 , 71 , 72 },
+{ 80 , 80 , 71 , 73 },
+{ 80 , 80 , 71 , 74 },
+{ 80 , 80 , 71 , 75 },
+{ 80 , 80 , 71 , 76 },
+{ 80 , 80 , 71 , 77 },
+{ 80 , 80 , 71 , 78 },
+{ 80 , 80 , 71 , 79 },
+{ 80 , 80 , 72 , 0 },
+{ 80 , 80 , 72 , 1 },
+{ 80 , 80 , 72 , 2 },
+{ 80 , 80 , 72 , 3 },
+{ 80 , 80 , 72 , 4 },
+{ 80 , 80 , 72 , 5 },
+{ 80 , 80 , 72 , 6 },
+{ 80 , 80 , 72 , 7 },
+{ 80 , 80 , 72 , 8 },
+{ 80 , 80 , 72 , 9 },
+{ 80 , 80 , 72 , 10 },
+{ 80 , 80 , 72 , 11 },
+{ 80 , 80 , 72 , 12 },
+{ 80 , 80 , 72 , 13 },
+{ 80 , 80 , 72 , 14 },
+{ 80 , 80 , 72 , 15 },
+{ 80 , 80 , 72 , 16 },
+{ 80 , 80 , 72 , 17 },
+{ 80 , 80 , 72 , 18 },
+{ 80 , 80 , 72 , 19 },
+{ 80 , 80 , 72 , 20 },
+{ 80 , 80 , 72 , 21 },
+{ 80 , 80 , 72 , 22 },
+{ 80 , 80 , 72 , 23 },
+{ 80 , 80 , 72 , 24 },
+{ 80 , 80 , 72 , 25 },
+{ 80 , 80 , 72 , 26 },
+{ 80 , 80 , 72 , 27 },
+{ 80 , 80 , 72 , 28 },
+{ 80 , 80 , 72 , 29 },
+{ 80 , 80 , 72 , 30 },
+{ 80 , 80 , 72 , 31 },
+{ 80 , 80 , 72 , 32 },
+{ 80 , 80 , 72 , 33 },
+{ 80 , 80 , 72 , 34 },
+{ 80 , 80 , 72 , 35 },
+{ 80 , 80 , 72 , 36 },
+{ 80 , 80 , 72 , 37 },
+{ 80 , 80 , 72 , 38 },
+{ 80 , 80 , 72 , 39 },
+{ 80 , 80 , 72 , 40 },
+{ 80 , 80 , 72 , 41 },
+{ 80 , 80 , 72 , 42 },
+{ 80 , 80 , 72 , 43 },
+{ 80 , 80 , 72 , 44 },
+{ 80 , 80 , 72 , 45 },
+{ 80 , 80 , 72 , 46 },
+{ 80 , 80 , 72 , 47 },
+{ 80 , 80 , 72 , 48 },
+{ 80 , 80 , 72 , 49 },
+{ 80 , 80 , 72 , 50 },
+{ 80 , 80 , 72 , 51 },
+{ 80 , 80 , 72 , 52 },
+{ 80 , 80 , 72 , 53 },
+{ 80 , 80 , 72 , 54 },
+{ 80 , 80 , 72 , 55 },
+{ 80 , 80 , 72 , 56 },
+{ 80 , 80 , 72 , 57 },
+{ 80 , 80 , 72 , 58 },
+{ 80 , 80 , 72 , 59 },
+{ 80 , 80 , 72 , 60 },
+{ 80 , 80 , 72 , 61 },
+{ 80 , 80 , 72 , 62 },
+{ 80 , 80 , 72 , 63 },
+{ 80 , 80 , 72 , 64 },
+{ 80 , 80 , 72 , 65 },
+{ 80 , 80 , 72 , 66 },
+{ 80 , 80 , 72 , 67 },
+{ 80 , 80 , 72 , 68 },
+{ 80 , 80 , 72 , 69 },
+{ 80 , 80 , 72 , 70 },
+{ 80 , 80 , 72 , 71 },
+{ 80 , 80 , 72 , 72 },
+{ 80 , 80 , 72 , 73 },
+{ 80 , 80 , 72 , 74 },
+{ 80 , 80 , 72 , 75 },
+{ 80 , 80 , 72 , 76 },
+{ 80 , 80 , 72 , 77 },
+{ 80 , 80 , 72 , 78 },
+{ 80 , 80 , 72 , 79 },
+{ 80 , 80 , 73 , 0 },
+{ 80 , 80 , 73 , 1 },
+{ 80 , 80 , 73 , 2 },
+{ 80 , 80 , 73 , 3 },
+{ 80 , 80 , 73 , 4 },
+{ 80 , 80 , 73 , 5 },
+{ 80 , 80 , 73 , 6 },
+{ 80 , 80 , 73 , 7 },
+{ 80 , 80 , 73 , 8 },
+{ 80 , 80 , 73 , 9 },
+{ 80 , 80 , 73 , 10 },
+{ 80 , 80 , 73 , 11 },
+{ 80 , 80 , 73 , 12 },
+{ 80 , 80 , 73 , 13 },
+{ 80 , 80 , 73 , 14 },
+{ 80 , 80 , 73 , 15 },
+{ 80 , 80 , 73 , 16 },
+{ 80 , 80 , 73 , 17 },
+{ 80 , 80 , 73 , 18 },
+{ 80 , 80 , 73 , 19 },
+{ 80 , 80 , 73 , 20 },
+{ 80 , 80 , 73 , 21 },
+{ 80 , 80 , 73 , 22 },
+{ 80 , 80 , 73 , 23 },
+{ 80 , 80 , 73 , 24 },
+{ 80 , 80 , 73 , 25 },
+{ 80 , 80 , 73 , 26 },
+{ 80 , 80 , 73 , 27 },
+{ 80 , 80 , 73 , 28 },
+{ 80 , 80 , 73 , 29 },
+{ 80 , 80 , 73 , 30 },
+{ 80 , 80 , 73 , 31 },
+{ 80 , 80 , 73 , 32 },
+{ 80 , 80 , 73 , 33 },
+{ 80 , 80 , 73 , 34 },
+{ 80 , 80 , 73 , 35 },
+{ 80 , 80 , 73 , 36 },
+{ 80 , 80 , 73 , 37 },
+{ 80 , 80 , 73 , 38 },
+{ 80 , 80 , 73 , 39 },
+{ 80 , 80 , 73 , 40 },
+{ 80 , 80 , 73 , 41 },
+{ 80 , 80 , 73 , 42 },
+{ 80 , 80 , 73 , 43 },
+{ 80 , 80 , 73 , 44 },
+{ 80 , 80 , 73 , 45 },
+{ 80 , 80 , 73 , 46 },
+{ 80 , 80 , 73 , 47 },
+{ 80 , 80 , 73 , 48 },
+{ 80 , 80 , 73 , 49 },
+{ 80 , 80 , 73 , 50 },
+{ 80 , 80 , 73 , 51 },
+{ 80 , 80 , 73 , 52 },
+{ 80 , 80 , 73 , 53 },
+{ 80 , 80 , 73 , 54 },
+{ 80 , 80 , 73 , 55 },
+{ 80 , 80 , 73 , 56 },
+{ 80 , 80 , 73 , 57 },
+{ 80 , 80 , 73 , 58 },
+{ 80 , 80 , 73 , 59 },
+{ 80 , 80 , 73 , 60 },
+{ 80 , 80 , 73 , 61 },
+{ 80 , 80 , 73 , 62 },
+{ 80 , 80 , 73 , 63 },
+{ 80 , 80 , 73 , 64 },
+{ 80 , 80 , 73 , 65 },
+{ 80 , 80 , 73 , 66 },
+{ 80 , 80 , 73 , 67 },
+{ 80 , 80 , 73 , 68 },
+{ 80 , 80 , 73 , 69 },
+{ 80 , 80 , 73 , 70 },
+{ 80 , 80 , 73 , 71 },
+{ 80 , 80 , 73 , 72 },
+{ 80 , 80 , 73 , 73 },
+{ 80 , 80 , 73 , 74 },
+{ 80 , 80 , 73 , 75 },
+{ 80 , 80 , 73 , 76 },
+{ 80 , 80 , 73 , 77 },
+{ 80 , 80 , 73 , 78 },
+{ 80 , 80 , 73 , 79 },
+{ 80 , 80 , 74 , 0 },
+{ 80 , 80 , 74 , 1 },
+{ 80 , 80 , 74 , 2 },
+{ 80 , 80 , 74 , 3 },
+{ 80 , 80 , 74 , 4 },
+{ 80 , 80 , 74 , 5 },
+{ 80 , 80 , 74 , 6 },
+{ 80 , 80 , 74 , 7 },
+{ 80 , 80 , 74 , 8 },
+{ 80 , 80 , 74 , 9 },
+{ 80 , 80 , 74 , 10 },
+{ 80 , 80 , 74 , 11 },
+{ 80 , 80 , 74 , 12 },
+{ 80 , 80 , 74 , 13 },
+{ 80 , 80 , 74 , 14 },
+{ 80 , 80 , 74 , 15 },
+{ 80 , 80 , 74 , 16 },
+{ 80 , 80 , 74 , 17 },
+{ 80 , 80 , 74 , 18 },
+{ 80 , 80 , 74 , 19 },
+{ 80 , 80 , 74 , 20 },
+{ 80 , 80 , 74 , 21 },
+{ 80 , 80 , 74 , 22 },
+{ 80 , 80 , 74 , 23 },
+{ 80 , 80 , 74 , 24 },
+{ 80 , 80 , 74 , 25 },
+{ 80 , 80 , 74 , 26 },
+{ 80 , 80 , 74 , 27 },
+{ 80 , 80 , 74 , 28 },
+{ 80 , 80 , 74 , 29 },
+{ 80 , 80 , 74 , 30 },
+{ 80 , 80 , 74 , 31 },
+{ 80 , 80 , 74 , 32 },
+{ 80 , 80 , 74 , 33 },
+{ 80 , 80 , 74 , 34 },
+{ 80 , 80 , 74 , 35 },
+{ 80 , 80 , 74 , 36 },
+{ 80 , 80 , 74 , 37 },
+{ 80 , 80 , 74 , 38 },
+{ 80 , 80 , 74 , 39 },
+{ 80 , 80 , 74 , 40 },
+{ 80 , 80 , 74 , 41 },
+{ 80 , 80 , 74 , 42 },
+{ 80 , 80 , 74 , 43 },
+{ 80 , 80 , 74 , 44 },
+{ 80 , 80 , 74 , 45 },
+{ 80 , 80 , 74 , 46 },
+{ 80 , 80 , 74 , 47 },
+{ 80 , 80 , 74 , 48 },
+{ 80 , 80 , 74 , 49 },
+{ 80 , 80 , 74 , 50 },
+{ 80 , 80 , 74 , 51 },
+{ 80 , 80 , 74 , 52 },
+{ 80 , 80 , 74 , 53 },
+{ 80 , 80 , 74 , 54 },
+{ 80 , 80 , 74 , 55 },
+{ 80 , 80 , 74 , 56 },
+{ 80 , 80 , 74 , 57 },
+{ 80 , 80 , 74 , 58 },
+{ 80 , 80 , 74 , 59 },
+{ 80 , 80 , 74 , 60 },
+{ 80 , 80 , 74 , 61 },
+{ 80 , 80 , 74 , 62 },
+{ 80 , 80 , 74 , 63 },
+{ 80 , 80 , 74 , 64 },
+{ 80 , 80 , 74 , 65 },
+{ 80 , 80 , 74 , 66 },
+{ 80 , 80 , 74 , 67 },
+{ 80 , 80 , 74 , 68 },
+{ 80 , 80 , 74 , 69 },
+{ 80 , 80 , 74 , 70 },
+{ 80 , 80 , 74 , 71 },
+{ 80 , 80 , 74 , 72 },
+{ 80 , 80 , 74 , 73 },
+{ 80 , 80 , 74 , 74 },
+{ 80 , 80 , 74 , 75 },
+{ 80 , 80 , 74 , 76 },
+{ 80 , 80 , 74 , 77 },
+{ 80 , 80 , 74 , 78 },
+{ 80 , 80 , 74 , 79 },
+{ 80 , 80 , 75 , 0 },
+{ 80 , 80 , 75 , 1 },
+{ 80 , 80 , 75 , 2 },
+{ 80 , 80 , 75 , 3 },
+{ 80 , 80 , 75 , 4 },
+{ 80 , 80 , 75 , 5 },
+{ 80 , 80 , 75 , 6 },
+{ 80 , 80 , 75 , 7 },
+{ 80 , 80 , 75 , 8 },
+{ 80 , 80 , 75 , 9 },
+{ 80 , 80 , 75 , 10 },
+{ 80 , 80 , 75 , 11 },
+{ 80 , 80 , 75 , 12 },
+{ 80 , 80 , 75 , 13 },
+{ 80 , 80 , 75 , 14 },
+{ 80 , 80 , 75 , 15 },
+{ 80 , 80 , 75 , 16 },
+{ 80 , 80 , 75 , 17 },
+{ 80 , 80 , 75 , 18 },
+{ 80 , 80 , 75 , 19 },
+{ 80 , 80 , 75 , 20 },
+{ 80 , 80 , 75 , 21 },
+{ 80 , 80 , 75 , 22 },
+{ 80 , 80 , 75 , 23 },
+{ 80 , 80 , 75 , 24 },
+{ 80 , 80 , 75 , 25 },
+{ 80 , 80 , 75 , 26 },
+{ 80 , 80 , 75 , 27 },
+{ 80 , 80 , 75 , 28 },
+{ 80 , 80 , 75 , 29 },
+{ 80 , 80 , 75 , 30 },
+{ 80 , 80 , 75 , 31 },
+{ 80 , 80 , 75 , 32 },
+{ 80 , 80 , 75 , 33 },
+{ 80 , 80 , 75 , 34 },
+{ 80 , 80 , 75 , 35 },
+{ 80 , 80 , 75 , 36 },
+{ 80 , 80 , 75 , 37 },
+{ 80 , 80 , 75 , 38 },
+{ 80 , 80 , 75 , 39 },
+{ 80 , 80 , 75 , 40 },
+{ 80 , 80 , 75 , 41 },
+{ 80 , 80 , 75 , 42 },
+{ 80 , 80 , 75 , 43 },
+{ 80 , 80 , 75 , 44 },
+{ 80 , 80 , 75 , 45 },
+{ 80 , 80 , 75 , 46 },
+{ 80 , 80 , 75 , 47 },
+{ 80 , 80 , 75 , 48 },
+{ 80 , 80 , 75 , 49 },
+{ 80 , 80 , 75 , 50 },
+{ 80 , 80 , 75 , 51 },
+{ 80 , 80 , 75 , 52 },
+{ 80 , 80 , 75 , 53 },
+{ 80 , 80 , 75 , 54 },
+{ 80 , 80 , 75 , 55 },
+{ 80 , 80 , 75 , 56 },
+{ 80 , 80 , 75 , 57 },
+{ 80 , 80 , 75 , 58 },
+{ 80 , 80 , 75 , 59 },
+{ 80 , 80 , 75 , 60 },
+{ 80 , 80 , 75 , 61 },
+{ 80 , 80 , 75 , 62 },
+{ 80 , 80 , 75 , 63 },
+{ 80 , 80 , 75 , 64 },
+{ 80 , 80 , 75 , 65 },
+{ 80 , 80 , 75 , 66 },
+{ 80 , 80 , 75 , 67 },
+{ 80 , 80 , 75 , 68 },
+{ 80 , 80 , 75 , 69 },
+{ 80 , 80 , 75 , 70 },
+{ 80 , 80 , 75 , 71 },
+{ 80 , 80 , 75 , 72 },
+{ 80 , 80 , 75 , 73 },
+{ 80 , 80 , 75 , 74 },
+{ 80 , 80 , 75 , 75 },
+{ 80 , 80 , 75 , 76 },
+{ 80 , 80 , 75 , 77 },
+{ 80 , 80 , 75 , 78 },
+{ 80 , 80 , 75 , 79 },
+{ 80 , 80 , 76 , 0 },
+{ 80 , 80 , 76 , 1 },
+{ 80 , 80 , 76 , 2 },
+{ 80 , 80 , 76 , 3 },
+{ 80 , 80 , 76 , 4 },
+{ 80 , 80 , 76 , 5 },
+{ 80 , 80 , 76 , 6 },
+{ 80 , 80 , 76 , 7 },
+{ 80 , 80 , 76 , 8 },
+{ 80 , 80 , 76 , 9 },
+{ 80 , 80 , 76 , 10 },
+{ 80 , 80 , 76 , 11 },
+{ 80 , 80 , 76 , 12 },
+{ 80 , 80 , 76 , 13 },
+{ 80 , 80 , 76 , 14 },
+{ 80 , 80 , 76 , 15 },
+{ 80 , 80 , 76 , 16 },
+{ 80 , 80 , 76 , 17 },
+{ 80 , 80 , 76 , 18 },
+{ 80 , 80 , 76 , 19 },
+{ 80 , 80 , 76 , 20 },
+{ 80 , 80 , 76 , 21 },
+{ 80 , 80 , 76 , 22 },
+{ 80 , 80 , 76 , 23 },
+{ 80 , 80 , 76 , 24 },
+{ 80 , 80 , 76 , 25 },
+{ 80 , 80 , 76 , 26 },
+{ 80 , 80 , 76 , 27 },
+{ 80 , 80 , 76 , 28 },
+{ 80 , 80 , 76 , 29 },
+{ 80 , 80 , 76 , 30 },
+{ 80 , 80 , 76 , 31 },
+{ 80 , 80 , 76 , 32 },
+{ 80 , 80 , 76 , 33 },
+{ 80 , 80 , 76 , 34 },
+{ 80 , 80 , 76 , 35 },
+{ 80 , 80 , 76 , 36 },
+{ 80 , 80 , 76 , 37 },
+{ 80 , 80 , 76 , 38 },
+{ 80 , 80 , 76 , 39 },
+{ 80 , 80 , 76 , 40 },
+{ 80 , 80 , 76 , 41 },
+{ 80 , 80 , 76 , 42 },
+{ 80 , 80 , 76 , 43 },
+{ 80 , 80 , 76 , 44 },
+{ 80 , 80 , 76 , 45 },
+{ 80 , 80 , 76 , 46 },
+{ 80 , 80 , 76 , 47 },
+{ 80 , 80 , 76 , 48 },
+{ 80 , 80 , 76 , 49 },
+{ 80 , 80 , 76 , 50 },
+{ 80 , 80 , 76 , 51 },
+{ 80 , 80 , 76 , 52 },
+{ 80 , 80 , 76 , 53 },
+{ 80 , 80 , 76 , 54 },
+{ 80 , 80 , 76 , 55 },
+{ 80 , 80 , 76 , 56 },
+{ 80 , 80 , 76 , 57 },
+{ 80 , 80 , 76 , 58 },
+{ 80 , 80 , 76 , 59 },
+{ 80 , 80 , 76 , 60 },
+{ 80 , 80 , 76 , 61 },
+{ 80 , 80 , 76 , 62 },
+{ 80 , 80 , 76 , 63 },
+{ 80 , 80 , 76 , 64 },
+{ 80 , 80 , 76 , 65 },
+{ 80 , 80 , 76 , 66 },
+{ 80 , 80 , 76 , 67 },
+{ 80 , 80 , 76 , 68 },
+{ 80 , 80 , 76 , 69 },
+{ 80 , 80 , 76 , 70 },
+{ 80 , 80 , 76 , 71 },
+{ 80 , 80 , 76 , 72 },
+{ 80 , 80 , 76 , 73 },
+{ 80 , 80 , 76 , 74 },
+{ 80 , 80 , 76 , 75 },
+{ 80 , 80 , 76 , 76 },
+{ 80 , 80 , 76 , 77 },
+{ 80 , 80 , 76 , 78 },
+{ 80 , 80 , 76 , 79 },
+{ 80 , 80 , 77 , 0 },
+{ 80 , 80 , 77 , 1 },
+{ 80 , 80 , 77 , 2 },
+{ 80 , 80 , 77 , 3 },
+{ 80 , 80 , 77 , 4 },
+{ 80 , 80 , 77 , 5 },
+{ 80 , 80 , 77 , 6 },
+{ 80 , 80 , 77 , 7 },
+{ 80 , 80 , 77 , 8 },
+{ 80 , 80 , 77 , 9 },
+{ 80 , 80 , 77 , 10 },
+{ 80 , 80 , 77 , 11 },
+{ 80 , 80 , 77 , 12 },
+{ 80 , 80 , 77 , 13 },
+{ 80 , 80 , 77 , 14 },
+{ 80 , 80 , 77 , 15 },
+{ 80 , 80 , 77 , 16 },
+{ 80 , 80 , 77 , 17 },
+{ 80 , 80 , 77 , 18 },
+{ 80 , 80 , 77 , 19 },
+{ 80 , 80 , 77 , 20 },
+{ 80 , 80 , 77 , 21 },
+{ 80 , 80 , 77 , 22 },
+{ 80 , 80 , 77 , 23 },
+{ 80 , 80 , 77 , 24 },
+{ 80 , 80 , 77 , 25 },
+{ 80 , 80 , 77 , 26 },
+{ 80 , 80 , 77 , 27 },
+{ 80 , 80 , 77 , 28 },
+{ 80 , 80 , 77 , 29 },
+{ 80 , 80 , 77 , 30 },
+{ 80 , 80 , 77 , 31 },
+{ 80 , 80 , 77 , 32 },
+{ 80 , 80 , 77 , 33 },
+{ 80 , 80 , 77 , 34 },
+{ 80 , 80 , 77 , 35 },
+{ 80 , 80 , 77 , 36 },
+{ 80 , 80 , 77 , 37 },
+{ 80 , 80 , 77 , 38 },
+{ 80 , 80 , 77 , 39 },
+{ 80 , 80 , 77 , 40 },
+{ 80 , 80 , 77 , 41 },
+{ 80 , 80 , 77 , 42 },
+{ 80 , 80 , 77 , 43 },
+{ 80 , 80 , 77 , 44 },
+{ 80 , 80 , 77 , 45 },
+{ 80 , 80 , 77 , 46 },
+{ 80 , 80 , 77 , 47 },
+{ 80 , 80 , 77 , 48 },
+{ 80 , 80 , 77 , 49 },
+{ 80 , 80 , 77 , 50 },
+{ 80 , 80 , 77 , 51 },
+{ 80 , 80 , 77 , 52 },
+{ 80 , 80 , 77 , 53 },
+{ 80 , 80 , 77 , 54 },
+{ 80 , 80 , 77 , 55 },
+{ 80 , 80 , 77 , 56 },
+{ 80 , 80 , 77 , 57 },
+{ 80 , 80 , 77 , 58 },
+{ 80 , 80 , 77 , 59 },
+{ 80 , 80 , 77 , 60 },
+{ 80 , 80 , 77 , 61 },
+{ 80 , 80 , 77 , 62 },
+{ 80 , 80 , 77 , 63 },
+{ 80 , 80 , 77 , 64 },
+{ 80 , 80 , 77 , 65 },
+{ 80 , 80 , 77 , 66 },
+{ 80 , 80 , 77 , 67 },
+{ 80 , 80 , 77 , 68 },
+{ 80 , 80 , 77 , 69 },
+{ 80 , 80 , 77 , 70 },
+{ 80 , 80 , 77 , 71 },
+{ 80 , 80 , 77 , 72 },
+{ 80 , 80 , 77 , 73 },
+{ 80 , 80 , 77 , 74 },
+{ 80 , 80 , 77 , 75 },
+{ 80 , 80 , 77 , 76 },
+{ 80 , 80 , 77 , 77 },
+{ 80 , 80 , 77 , 78 },
+{ 80 , 80 , 77 , 79 },
+{ 80 , 80 , 78 , 0 },
+{ 80 , 80 , 78 , 1 },
+{ 80 , 80 , 78 , 2 },
+{ 80 , 80 , 78 , 3 },
+{ 80 , 80 , 78 , 4 },
+{ 80 , 80 , 78 , 5 },
+{ 80 , 80 , 78 , 6 },
+{ 80 , 80 , 78 , 7 },
+{ 80 , 80 , 78 , 8 },
+{ 80 , 80 , 78 , 9 },
+{ 80 , 80 , 78 , 10 },
+{ 80 , 80 , 78 , 11 },
+{ 80 , 80 , 78 , 12 },
+{ 80 , 80 , 78 , 13 },
+{ 80 , 80 , 78 , 14 },
+{ 80 , 80 , 78 , 15 },
+{ 80 , 80 , 78 , 16 },
+{ 80 , 80 , 78 , 17 },
+{ 80 , 80 , 78 , 18 },
+{ 80 , 80 , 78 , 19 },
+{ 80 , 80 , 78 , 20 },
+{ 80 , 80 , 78 , 21 },
+{ 80 , 80 , 78 , 22 },
+{ 80 , 80 , 78 , 23 },
+{ 80 , 80 , 78 , 24 },
+{ 80 , 80 , 78 , 25 },
+{ 80 , 80 , 78 , 26 },
+{ 80 , 80 , 78 , 27 },
+{ 80 , 80 , 78 , 28 },
+{ 80 , 80 , 78 , 29 },
+{ 80 , 80 , 78 , 30 },
+{ 80 , 80 , 78 , 31 },
+{ 80 , 80 , 78 , 32 },
+{ 80 , 80 , 78 , 33 },
+{ 80 , 80 , 78 , 34 },
+{ 80 , 80 , 78 , 35 },
+{ 80 , 80 , 78 , 36 },
+{ 80 , 80 , 78 , 37 },
+{ 80 , 80 , 78 , 38 },
+{ 80 , 80 , 78 , 39 },
+{ 80 , 80 , 78 , 40 },
+{ 80 , 80 , 78 , 41 },
+{ 80 , 80 , 78 , 42 },
+{ 80 , 80 , 78 , 43 },
+{ 80 , 80 , 78 , 44 },
+{ 80 , 80 , 78 , 45 },
+{ 80 , 80 , 78 , 46 },
+{ 80 , 80 , 78 , 47 },
+{ 80 , 80 , 78 , 48 },
+{ 80 , 80 , 78 , 49 },
+{ 80 , 80 , 78 , 50 },
+{ 80 , 80 , 78 , 51 },
+{ 80 , 80 , 78 , 52 },
+{ 80 , 80 , 78 , 53 },
+{ 80 , 80 , 78 , 54 },
+{ 80 , 80 , 78 , 55 },
+{ 80 , 80 , 78 , 56 },
+{ 80 , 80 , 78 , 57 },
+{ 80 , 80 , 78 , 58 },
+{ 80 , 80 , 78 , 59 },
+{ 80 , 80 , 78 , 60 },
+{ 80 , 80 , 78 , 61 },
+{ 80 , 80 , 78 , 62 },
+{ 80 , 80 , 78 , 63 },
+{ 80 , 80 , 78 , 64 },
+{ 80 , 80 , 78 , 65 },
+{ 80 , 80 , 78 , 66 },
+{ 80 , 80 , 78 , 67 },
+{ 80 , 80 , 78 , 68 },
+{ 80 , 80 , 78 , 69 },
+{ 80 , 80 , 78 , 70 },
+{ 80 , 80 , 78 , 71 },
+{ 80 , 80 , 78 , 72 },
+{ 80 , 80 , 78 , 73 },
+{ 80 , 80 , 78 , 74 },
+{ 80 , 80 , 78 , 75 },
+{ 80 , 80 , 78 , 76 },
+{ 80 , 80 , 78 , 77 },
+{ 80 , 80 , 78 , 78 },
+{ 80 , 80 , 78 , 79 },
+{ 80 , 80 , 79 , 0 },
+{ 80 , 80 , 79 , 1 },
+{ 80 , 80 , 79 , 2 },
+{ 80 , 80 , 79 , 3 },
+{ 80 , 80 , 79 , 4 },
+{ 80 , 80 , 79 , 5 },
+{ 80 , 80 , 79 , 6 },
+{ 80 , 80 , 79 , 7 },
+{ 80 , 80 , 79 , 8 },
+{ 80 , 80 , 79 , 9 },
+{ 80 , 80 , 79 , 10 },
+{ 80 , 80 , 79 , 11 },
+{ 80 , 80 , 79 , 12 },
+{ 80 , 80 , 79 , 13 },
+{ 80 , 80 , 79 , 14 },
+{ 80 , 80 , 79 , 15 },
+{ 80 , 80 , 79 , 16 },
+{ 80 , 80 , 79 , 17 },
+{ 80 , 80 , 79 , 18 },
+{ 80 , 80 , 79 , 19 },
+{ 80 , 80 , 79 , 20 },
+{ 80 , 80 , 79 , 21 },
+{ 80 , 80 , 79 , 22 },
+{ 80 , 80 , 79 , 23 },
+{ 80 , 80 , 79 , 24 },
+{ 80 , 80 , 79 , 25 },
+{ 80 , 80 , 79 , 26 },
+{ 80 , 80 , 79 , 27 },
+{ 80 , 80 , 79 , 28 },
+{ 80 , 80 , 79 , 29 },
+{ 80 , 80 , 79 , 30 },
+{ 80 , 80 , 79 , 31 },
+{ 80 , 80 , 79 , 32 },
+{ 80 , 80 , 79 , 33 },
+{ 80 , 80 , 79 , 34 },
+{ 80 , 80 , 79 , 35 },
+{ 80 , 80 , 79 , 36 },
+{ 80 , 80 , 79 , 37 },
+{ 80 , 80 , 79 , 38 },
+{ 80 , 80 , 79 , 39 },
+{ 80 , 80 , 79 , 40 },
+{ 80 , 80 , 79 , 41 },
+{ 80 , 80 , 79 , 42 },
+{ 80 , 80 , 79 , 43 },
+{ 80 , 80 , 79 , 44 },
+{ 80 , 80 , 79 , 45 },
+{ 80 , 80 , 79 , 46 },
+{ 80 , 80 , 79 , 47 },
+{ 80 , 80 , 79 , 48 },
+{ 80 , 80 , 79 , 49 },
+{ 80 , 80 , 79 , 50 },
+{ 80 , 80 , 79 , 51 },
+{ 80 , 80 , 79 , 52 },
+{ 80 , 80 , 79 , 53 },
+{ 80 , 80 , 79 , 54 },
+{ 80 , 80 , 79 , 55 },
+{ 80 , 80 , 79 , 56 },
+{ 80 , 80 , 79 , 57 },
+{ 80 , 80 , 79 , 58 },
+{ 80 , 80 , 79 , 59 },
+{ 80 , 80 , 79 , 60 },
+{ 80 , 80 , 79 , 61 },
+{ 80 , 80 , 79 , 62 },
+{ 80 , 80 , 79 , 63 },
+{ 80 , 80 , 79 , 64 },
+{ 80 , 80 , 79 , 65 },
+{ 80 , 80 , 79 , 66 },
+{ 80 , 80 , 79 , 67 },
+{ 80 , 80 , 79 , 68 },
+{ 80 , 80 , 79 , 69 },
+{ 80 , 80 , 79 , 70 },
+{ 80 , 80 , 79 , 71 },
+{ 80 , 80 , 79 , 72 },
+{ 80 , 80 , 79 , 73 },
+{ 80 , 80 , 79 , 74 },
+{ 80 , 80 , 79 , 75 },
+{ 80 , 80 , 79 , 76 },
+{ 80 , 80 , 79 , 77 },
+{ 80 , 80 , 79 , 78 },
+{ 80 , 80 , 79 , 79 },
+};
+
+//uint32 aam_gpt;
+int aam_resync_test_idx;
+int aam_resync_is_start = 0;
+uint32 aam_flag;
+
+kal_timerid aam_timer;
+
+void clear_aam_resync_test_flag(){
+ if(0 == aam_flag){
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_1();
+ }
+ aam_flag = 0;
+}
+
+void sub_aam_resync_test(){
+ void sp_ps_aam_fake_L2_Info(uint32 RX_period, uint32 TX_period, uint32 t2nextRX, uint32 t2nextTX);
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_2(aam_resync_test_idx, sizeof(aam_resync_test_table)/sizeof(aam_resync_test_table[0]));
+ if(0 == aam_flag){
+ aam_resync_test_idx++;
+ }else if(aam_flag < 20){
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_3(aam_flag);
+ }else{
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_4(aam_resync_test_idx);
+ aam_resync_test_idx++;
+ aam_flag = 0;
+ }
+ if(aam_resync_test_idx == sizeof(aam_resync_test_table)/sizeof(aam_resync_test_table[0])){
+ //DclSGPT_Control(aam_gpt ,SGPT_CMD_STOP, 0);
+ kal_cancel_timer(aam_timer);
+ aam_resync_is_start = 0;
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_5();
+ }else{
+ void sp_ps_aam_fake_L2_Info(uint32 RX_period, uint32 TX_period, uint32 t2nextRX, uint32 t2nextTX);
+ int t1 = aam_resync_test_table[aam_resync_test_idx][0];
+ int t2 = aam_resync_test_table[aam_resync_test_idx][1];
+ int t3 = aam_resync_test_table[aam_resync_test_idx][2];
+ int t4 = aam_resync_test_table[aam_resync_test_idx][3];
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_6(t1, t2, t3, t4, aam_resync_test_idx);
+ //SGPT_CTRL_START_T start;
+ //start.u2Tick = 100; // 1second
+ //start.pfCallback = sub_aam_resync_test;
+ aam_flag ++;
+ sp_ps_aam_fake_L2_Info(t1, t2, t3, t4);
+ kal_set_timer (aam_timer, sub_aam_resync_test, NULL, KAL_TICKS_2_SEC+aam_flag, 0);
+ }
+}
+
+void aam_resync_test_start(uint32 start_idx){
+ if(0 == aam_resync_is_start){
+ //SGPT_CTRL_START_T start;
+ //start.u2Tick = 100;
+ //start.pfCallback = sub_aam_resync_test;
+ //aam_gpt = DclSGPT_Open( DCL_GPT_CB ,0 );
+ aam_resync_test_idx = start_idx-1;
+ aam_resync_is_start = 1;
+ aam_flag = 0;
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_7(aam_resync_test_idx);
+ aam_timer = kal_create_timer("aam_timer");
+ kal_set_timer (aam_timer, sub_aam_resync_test, NULL, KAL_TICKS_2_SEC, 0);
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_8();
+ }else{
+ MD_TRC_SP_PS_AAM_RESYNC_TEST_9();
+ }
+}
+#endif
diff --git a/mcu/driver/audio/src/v1/bgSnd.c b/mcu/driver/audio/src/v1/bgSnd.c
new file mode 100644
index 0000000..85ac76e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/bgSnd.c
@@ -0,0 +1,1033 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * snd_effect.c
+ *
+ * Project:
+ * --------
+ * Maui_sw
+ *
+ * Description:
+ * ------------
+ * Streaming Background Sound Playback.
+ * Play 8kHz mono linear PCM in TCH or idle mode.
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "sync_data.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+
+
+#include "am.h"
+//#include "speech_def.h"
+#include "afe_def.h" // for output device setting
+#include "sp_drv.h"
+
+#include "sal_exp.h"
+
+#define DSP_BGS_UP_DOWN_INT_SEPERATE
+
+/************************** Constants ***************************************/
+// #define DP_BUFFER_DEFAULT_LEN 4096 /* The frame size of DSP. */
+#define DSP_BUFFER_LEN_NB 160 //unit is sample (16bit)
+#define DSP_BUFFER_LEN_WB 320 //unit is sample (16bit)
+#define DSP_BUFFER_LEN_MAX 320 //unit is sample (16bit)
+
+/* DSP Sound Effect State */
+#define DP_BGSND_STATE_IDLE 0 /* MCU: 0 -> 1 */
+#define DP_BGSND_STATE_READY 1 /* DSP: 1 -> 2 */
+#define DP_BGSND_STATE_PLAYING 2 /* MCU: 2 -> 3 */
+#define DP_BGSND_STATE_STOP 3 /* DSP: 3 -> 0 */
+
+//#define SND_CHECK_DATA
+
+#define SND_GAIN_CONFIG 1 /* 0: right shamt, 1: multiplier */
+
+#define BGSND_BUF_SIZE 2560 // using in 16 bit
+#define BGSND_BUF_PTR_DIFF 2
+
+typedef enum {
+ BGSND_STATE_IDLE = 0,
+ BGSND_STATE_RUN,
+ BGSND_STATE_STOP,
+ BGSND_STATE_CLOSE,
+}BGSND_STATE_TYPE;
+
+/*********** Structure *******************************************************/
+
+typedef struct{
+
+ BGSND_STATE_TYPE state;
+
+ kal_bool fULSPH;
+ kal_bool fDLSPH;
+
+ kal_bool isDlHisrCome;
+ kal_bool isUlHisrCome;
+
+ void (*bgSnd_hisrHandler)(void);
+ void (*bgSnd_offHandler)(void);
+
+ kal_uint16 aud_id;
+ kal_timerid timer;
+ kal_uint16 endCount;
+
+ kal_uint16 ULGain;
+ kal_uint16 DLGain;
+ kal_uint16 dspLastSample;
+
+ kal_uint16 *pBuf;
+
+
+ kal_int32 bufSize; // unit is 16 bit (sample)
+ kal_int32 bufWrite; // unit is 16 bit
+ kal_int32 bufRead; // unit is 16 bit
+}BGSND_T;
+
+/*********** variable ********************************************************/
+
+static BGSND_T bgSnd;
+
+static kal_uint16 bgSndBuf[BGSND_BUF_SIZE];
+
+/*********** internal fucntion **********************************************/
+
+static void bgsndUpdateMixer()
+{
+ if ( AM_IsSpeechOn() ) {
+ SAL_Bgsnd_Config(bgSnd.ULGain, bgSnd.DLGain, bgSnd.fULSPH, bgSnd.fDLSPH);
+ } else {
+ SAL_Bgsnd_Config(bgSnd.ULGain, bgSnd.DLGain, 0, 0);
+ }
+
+}
+
+/**
+ @return: size is 16-bit, available PCM size
+*/
+static int32 bgsndGetDataCount(void)
+{
+ int32 count;
+ // int32 count = (int32)ihdl->mh.rbInfo.write - (int32)ihdl->mh.rbInfo.read;
+ if(bgSnd.bufWrite<bgSnd.bufRead){
+ count = (bgSnd.bufSize - BGSND_BUF_PTR_DIFF)+bgSnd.bufWrite - bgSnd.bufRead;
+ } else {
+ count = bgSnd.bufWrite - bgSnd.bufRead;
+ }
+
+ if( count > BGSND_BUF_PTR_DIFF) {
+ count -= BGSND_BUF_PTR_DIFF;
+ } else {
+ count = 0;
+ }
+
+ if(count&1){
+ count = count -1;
+ }
+ return count;
+ /*
+ int32 count = bgSnd.bufWrite - bgSnd.bufRead;
+ if( count < 0 )
+ count += (bgSnd.bufSize - BGSND_BUF_PTR_DIFF );
+ else if( count > 2)
+ count -= BGSND_BUF_PTR_DIFF;
+ else
+ count = 0;
+ return count;
+ */
+}
+/*
+static kal_int16 tone1k_16kSR[320] = {
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05,
+0x0000, 0x30FC, 0x5A82, 0x7641, 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+0x0001, 0xCF05, 0xA57E, 0x89C0, 0x8001, 0x89BF, 0xA57E, 0xCF05
+};
+
+*/
+static void bgsnd_WriteToDSP(void)
+{
+ uint16 dsp_buf_len, dsp_buf_len_Ul;
+ uint16 *dataPtr;
+ volatile uint16 *toPtr;
+ volatile uint16 *toPtr_Ul;
+ int32 count, segment, i;
+ bool isWb, isWb_Ul;
+
+/*
+ ¡VSph_Band_Flag
+ ¡EBit 0: Sch band (0/1 : Nb/Wb)
+ ¡EBit 1: Cod band (0/1 : Nb/Wb)
+ ¡EBit 2: VBI band (0/1 : Nb/Wb)
+ ¡EBit 3: BT band (0/1 : Nb/Wb)
+ MT6280 0x2FBF
+ MT6589 0x32F1
+ dm5
+*/
+
+ // get current buffer data length in two sample alight. (16k sampling rate)
+ count = bgsndGetDataCount();
+
+ //set up the DSP address and pointers
+ dsp_buf_len = SAL_Bgsnd_GetDataLen_DL();
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ dsp_buf_len_Ul = SAL_Bgsnd_GetDataLen_UL();
+#else
+ dsp_buf_len_Ul = dsp_buf_len;
+#endif
+
+ if(dsp_buf_len == DSP_BUFFER_LEN_WB)
+ isWb = true;
+ else if(dsp_buf_len == DSP_BUFFER_LEN_NB){
+ isWb = false;
+// count >>= 1;
+ }
+ else {
+ ASSERT_REBOOT(0);
+ isWb = false;
+ }
+
+ if(dsp_buf_len_Ul == DSP_BUFFER_LEN_WB)
+ isWb_Ul= true;
+ else if(dsp_buf_len_Ul == DSP_BUFFER_LEN_NB){
+ isWb_Ul= false;
+ }
+ else {
+ ASSERT_REBOOT(0);
+ isWb_Ul = false;
+ }
+
+ toPtr = SAL_Bgsnd_GetBuf_DL();
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ toPtr_Ul = SAL_Bgsnd_GetBuf_UL();
+#else
+ toPtr_Ul = toPtr;
+#endif
+
+ MD_TRC_L1SND_DSP_BUFFER_INFO(count, toPtr, dsp_buf_len);
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ MD_TRC_L1SND_DSP_BUFFER_INFO(-1, toPtr_Ul, dsp_buf_len_Ul);
+#else
+ MD_TRC_L1SND_DSP_BUFFER_INFO(count, toPtr_Ul, dsp_buf_len_Ul);
+#endif
+
+
+ if (count > DSP_BUFFER_LEN_MAX)
+ count = DSP_BUFFER_LEN_MAX;
+
+ if(count > 0) {
+
+ /* First Segemnt */
+ if(bgSnd.bufWrite < bgSnd.bufRead) {
+ segment = (bgSnd.bufSize - bgSnd.bufRead);
+ } else {
+ segment = (bgSnd.bufWrite - bgSnd.bufRead);
+ }
+
+ if(segment&1){ // keep two sample alight
+ segment =segment - 1;
+ }
+
+ /*
+ if(isNb){ // 8k
+ if (segment > (count<<1))
+ segment = (count<<1);
+
+ }else { // 16 k
+ if (segment > count)
+ segment = count;
+ }
+ */
+ if (segment > count)
+ segment = count;
+
+ if (segment > 0) {
+
+ // kal_dev_trace(TRACE_STATE, L1SND_FILLBUFFER, segment);
+ dataPtr = &(bgSnd.pBuf[bgSnd.bufRead]);
+
+ for (i=segment; i>0; (i-=2)) {
+ // first sample
+ *toPtr++ = *dataPtr;
+ *toPtr_Ul++ = *dataPtr++;
+
+ // second sample
+ if(isWb) {
+ *toPtr++ = *dataPtr;
+ }
+ if(isWb_Ul) {
+ *toPtr_Ul++ = *dataPtr;
+ }
+ dataPtr++;
+ }
+ Data_Sync_Barrier();
+
+ bgSnd.dspLastSample = *(toPtr-1);
+
+ bgSnd.bufRead += segment;
+ if (bgSnd.bufRead >= bgSnd.bufSize)
+ bgSnd.bufRead = (bgSnd.bufRead-bgSnd.bufSize);
+
+ MD_TRC_L1SND_FILLBUFFER(1, segment, bgSnd.bufRead, bgSnd.bufWrite);
+ }
+
+ /* Second Segment */
+ /*
+ if(isNb){ // 8k
+ segment = (count<<1) - segment;
+ } else {
+ segment = count - segment;
+ }
+ */
+ segment = count - segment;
+
+ if (segment > 0) {
+ // kal_dev_trace(TRACE_STATE, L1SND_FILLBUFFER, segment);
+ // dataPtr = bgSnd.pBuf;
+ dataPtr = &(bgSnd.pBuf[bgSnd.bufRead]);
+ for (i=segment; i>0; (i-=2)) {
+ // first sample
+ *toPtr++ = *dataPtr;
+ *toPtr_Ul++ = *dataPtr++;
+
+ // second sample
+ if(isWb) {
+ *toPtr++ = *dataPtr;
+ }
+ if(isWb_Ul) {
+ *toPtr_Ul++ = *dataPtr;
+ }
+ dataPtr++;
+ }
+ Data_Sync_Barrier();
+
+ bgSnd.dspLastSample = *(toPtr-1);
+ bgSnd.bufRead += segment;
+ if (bgSnd.bufRead >= bgSnd.bufSize)
+ bgSnd.bufRead = (bgSnd.bufRead-bgSnd.bufSize);
+
+ MD_TRC_L1SND_FILLBUFFER(2, segment, bgSnd.bufRead, bgSnd.bufWrite);
+ }
+
+ }
+
+
+ /* Put silence (last sample) if MCU buffer is empty */
+ if (count < DSP_BUFFER_LEN_MAX) {
+
+ kal_uint16 last_sample;
+
+ last_sample = bgSnd.dspLastSample;
+ // segment = dsp_buf_len - count;
+ segment = DSP_BUFFER_LEN_MAX - count;
+ MD_TRC_L1SND_PUT_SILENCE(segment, last_sample);
+
+ /*
+ for (i=segment; i>0; i--) {
+ *toPtr++ = last_sample;
+ }
+ */
+ for (i=segment; i>0; (i-=2)) {
+ // first sample
+ *toPtr++ = last_sample;
+ *toPtr_Ul++ = last_sample;
+
+ // second sample
+ if(isWb) {
+ *toPtr++ = last_sample;
+ }
+ if(isWb_Ul) {
+ *toPtr_Ul++ = last_sample;
+ }
+
+ }
+ Data_Sync_Barrier();
+ }
+}
+
+
+void bgsndHisr( void *pram )
+{
+
+ // gain and setting update
+ bgsndUpdateMixer();
+
+ // handle extra notify and closing state
+ if ((BGSND_STATE_RUN != bgSnd.state) && (BGSND_STATE_STOP !=bgSnd.state))
+ return;
+ // if ( ihdl->end_status != MEDIA_NONE )
+ // return;
+
+ if(!SAL_Bgsnd_IsRunning())
+ return;
+
+ bgsnd_WriteToDSP();
+
+ if( bgSnd.bgSnd_hisrHandler != NULL) {
+ bgSnd.bgSnd_hisrHandler();
+ }
+}
+
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+void bgsndDlHisr( void * param)
+{
+ if(true == bgSnd.isDlHisrCome) {
+ MD_TRC_L1SND_REENTER_HISR(bgSnd.isDlHisrCome, bgSnd.isUlHisrCome);
+ } else {
+ bgSnd.isDlHisrCome = true;
+
+ if(bgSnd.isUlHisrCome == bgSnd.isDlHisrCome) {
+ bgsndHisr(param);
+ bgSnd.isUlHisrCome = false;
+ bgSnd.isDlHisrCome = false;
+ }
+ }
+}
+
+void bgsndUlHisr( void * param)
+{
+ if(true == bgSnd.isUlHisrCome) {
+ MD_TRC_L1SND_REENTER_HISR(bgSnd.isDlHisrCome, bgSnd.isUlHisrCome);
+ } else {
+ bgSnd.isUlHisrCome = true;
+
+ if(bgSnd.isUlHisrCome == bgSnd.isDlHisrCome) {
+ bgsndHisr(param);
+ bgSnd.isUlHisrCome = false;
+ bgSnd.isDlHisrCome = false;
+ }
+ }
+
+}
+
+#endif // DSP_BGS_UP_DOWN_INT_SEPERATE
+
+void bgsndOnHandler(void)
+{
+
+ AM_SND_PlaybackOn();
+ SAL_Bgsnd_SetInit();
+ //*DSP_SOUND_EFFECT_CTRL = DP_BGSND_STATE_READY;
+ {
+ uint32 I;
+ for( I = 0; ; I++ ) {
+ //if( *DSP_SOUND_EFFECT_CTRL == DP_BGSND_STATE_PLAYING)
+ if(SAL_Bgsnd_IsRunning())
+ break;
+ ASSERT_REBOOT( I < 20 );
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ }
+}
+
+void bgsndOffHandler(void)
+{
+
+ if(BGSND_STATE_STOP != bgSnd.state) {
+ return;
+ }
+
+ uint32 I;
+ if(SAL_Bgsnd_IsRunning())
+ SAL_Bgsnd_SetFinal();
+ for ( I = 0; ; I++ ) {
+ if ( SAL_Bgsnd_IsIdle()) /* DSP returns to idle state */
+ break;
+ ASSERT_REBOOT( I < 20 );
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+
+
+ AM_SND_PlaybackOff( true );
+}
+
+void bgsndTimerCallback(void)
+{
+ L1Audio_SetEvent(bgSnd.aud_id, NULL);
+}
+
+/**
+ Run on AUDIO task
+*/
+void bgsndEventHandler(void)
+{
+ MD_TRC_L1SND_ENTER_EVENT_HANDLER(bgSnd.state);
+
+ switch (bgSnd.state)
+ {
+ case BGSND_STATE_STOP:
+ {
+ // int32 I = 0;
+ // Flush and Disable DSP.
+ //while( I++ >= 0 ){
+ while(bgSnd.endCount++ >=0){
+ int32 count = bgsndGetDataCount();
+
+ // if( I >=40 ){
+ if(bgSnd.endCount >=20) {
+ MD_TRC_L1SND_STOP_FLUSH_LEAVE(count);
+ break;
+ }
+
+ if( count > BGSND_BUF_PTR_DIFF ){
+ MD_TRC_L1SND_STOP_FLUSH_COUNT(count);
+ // kal_sleep_task( AUD_1TICK(1) );
+ kal_set_timer(bgSnd.timer, (kal_timer_func_ptr)(bgsndTimerCallback), NULL, AUD_1TICK(2), AUD_1TICK(0));
+ return;
+ }
+
+ }
+ //if ( *DSP_SOUND_EFFECT_CTRL == DP_BGSND_STATE_PLAYING ) {
+ // *DSP_SOUND_EFFECT_CTRL = DP_BGSND_STATE_STOP; /* give ABORT command to the DSP */
+ //}
+ kal_cancel_timer(bgSnd.timer);
+ bgsndOffHandler();
+
+ if(NULL != bgSnd.bgSnd_offHandler){
+ bgSnd.bgSnd_offHandler();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+
+}
+/*===========================================================================*/
+
+
+/**
+ @srcBuf:
+ @bufLen: unit is byte
+*/
+void BGSND_WriteData(kal_uint8 *srcBuf, kal_int32 bufLen)
+{
+ int32 freeLen;
+ int32 srcBufLen = bufLen >> 1; // unit i s word
+ int32 currentRead = bgSnd.bufRead;
+
+ if(currentRead > bgSnd.bufWrite || currentRead < BGSND_BUF_PTR_DIFF) { // one segment
+ if(currentRead > bgSnd.bufWrite){
+ freeLen=currentRead - bgSnd.bufWrite-BGSND_BUF_PTR_DIFF;
+ }else {
+ freeLen=bgSnd.bufSize - bgSnd.bufWrite-BGSND_BUF_PTR_DIFF;
+ }
+
+ MD_TRC_L1SND_WRITE_DATA(1, srcBufLen, freeLen, bgSnd.bufRead, bgSnd.bufWrite+srcBufLen); /* using write information which is after memory copy*/
+
+ ASSERT(srcBufLen <= freeLen); // unit is 2 byte
+ memcpy(bgSnd.pBuf+bgSnd.bufWrite, srcBuf, srcBufLen*sizeof(uint16));
+
+ bgSnd.bufWrite += srcBufLen;
+
+ //kal_prompt_trace(MOD_L1SP, "[pDebug]BGSND_WriteData1, bgSnd.bufRead=%d, bgSnd.bufWrite=%d", bgSnd.bufRead, bgSnd.bufWrite);
+
+
+ } else { // two segment
+
+ int32 segment;
+ kal_uint8 *p2SrcBuf;
+
+ freeLen= currentRead + bgSnd.bufSize - bgSnd.bufWrite-BGSND_BUF_PTR_DIFF;
+
+ MD_TRC_L1SND_WRITE_DATA(2, srcBufLen, freeLen, 0, 0);
+ ASSERT(srcBufLen <= freeLen);
+
+ p2SrcBuf = srcBuf;
+ segment = bgSnd.bufSize - bgSnd.bufWrite; // bug
+ if(segment > srcBufLen){
+ segment = srcBufLen;
+ }
+
+ if(segment>0) { //first segment
+
+ // kal_prompt_trace(MOD_L1SP, "xbgs temp3: bgSnd.pBuf+bgSnd.bufWrite=%x, p2SrcBuf=%x, segment*sizeof(kal_uint16)=%x",
+ // bgSnd.pBuf+bgSnd.bufWrite, p2SrcBuf, segment*sizeof(kal_uint16));
+
+ memcpy(bgSnd.pBuf+bgSnd.bufWrite, p2SrcBuf, segment*sizeof(kal_uint16));
+
+ //update pointer
+ p2SrcBuf = srcBuf + segment*sizeof(kal_uint16);
+ bgSnd.bufWrite += segment;
+ if(bgSnd.bufWrite>=bgSnd.bufSize){
+ bgSnd.bufWrite = 0;
+ }
+
+ // kal_prompt_trace(MOD_L1SP, "[pDebug]BGSND_WriteData2-1, bgSnd.bufRead=%d, bgSnd.bufWrite=%d", bgSnd.bufRead, bgSnd.bufWrite);
+ MD_TRC_L1SND_WRITE_DATA(3, 0, 0, bgSnd.bufRead, bgSnd.bufWrite);
+
+ segment = srcBufLen - segment;
+ }
+
+ if(segment>0) { //second segement
+ // kal_prompt_trace(MOD_L1SP, "xbgs temp5: bgSnd.pBuf=%x, p2SrcBuf=%x, segment*sizeof(kal_uint16=%x)",
+ // bgSnd.pBuf, p2SrcBuf, segment*sizeof(kal_uint16));
+
+ memcpy(bgSnd.pBuf, p2SrcBuf, segment*sizeof(kal_uint16));
+ bgSnd.bufWrite = segment;
+
+ // kal_prompt_trace(MOD_L1SP, "[pDebug]BGSND_WriteData2-2, bgSnd.bufRead=%d, bgSnd.bufWrite=%d", bgSnd.bufRead, bgSnd.bufWrite);
+ MD_TRC_L1SND_WRITE_DATA(4, 0, 0, bgSnd.bufRead, bgSnd.bufWrite);
+
+ }
+ }
+
+ /*
+ freeLen=bgSnd.bufRead - bgSnd.bufWrite-1;
+ if(freeLen<0){ // two segment
+ int32 segment;
+ kal_uint8 *p2SrcBuf;
+
+ freeLen += bgSnd.bufSize;
+
+
+ p2SrcBuf = srcBuf;
+ segment = bgSnd.bufSize - bgSnd.bufWrite;
+ memcpy(bgSnd.pBuf+bgSnd.bufWrite, p2SrcBuf, segment*sizeof(kal_uint16));
+ //update pointer
+ p2SrcBuf = srcBuf + (segment<<1);
+ bgSnd.bufWrite = 0;
+
+
+ segment = srcBufLen - segment;
+ memcpy(bgSnd.pBuf+bgSnd.bufWrite, p2SrcBuf, segment*sizeof(kal_uint16));
+ bgSnd.bufWrite = segment;
+
+ } else { // one segment
+ ASSERT(bufLen <= freeLen);
+ memcpy(bgSnd.pBuf+bgSnd.bufWrite, srcBuf, bufLen);
+
+ // for debug
+ kal_prompt_trace(MOD_L1SP, "bgs temp: bgSnd.pBuf=%x, bgSnd.bufWrite=%x, bgSnd.pBuf+bgSnd.bufWrite = %x",
+ bgSnd.pBuf, bgSnd.bufWrite, bgSnd.pBuf+bgSnd.bufWrite);
+
+ bgSnd.bufWrite += (bufLen>>1);
+
+ // for debg
+ kal_prompt_trace(MOD_L1SP, "bgs temp2: new bgSnd.bufWrite = %x", bgSnd.bufWrite);
+
+ }
+ */
+
+}
+
+/**
+ @return: size is 16-bit (2byte)
+*/
+int32 BGSND_GetFreeSpace(void)
+{
+ int32 count;
+
+ count = bgSnd.bufSize + bgSnd.bufRead - bgSnd.bufWrite-BGSND_BUF_PTR_DIFF; // (int32)ihdl->mh.rbInfo.read - (int32)ihdl->mh.rbInfo.write - 1;
+ if( count > bgSnd.bufSize )
+ count = count - bgSnd.bufSize;
+ return count;
+}
+
+/**
+ The function sets the playback mode.
+
+ @bULSPHFlag: Mixer switch for uplink speech, 1 for SPH+background Sound, 0 for background sound only
+ @ULSNDGain: Sound effect gain for uplink mixer
+*/
+void BGSND_ConfigULMixer(kal_bool bULSPHFlag, kal_int8 ULSNDGain )
+{
+#if defined(__ENABLE_SPEECH_DVT__)
+ ULSNDGain = 7;
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ MD_TRC_L1SND_CONFIG_ULMIXER(bULSPHFlag, ULSNDGain);
+
+ ASSERT(ULSNDGain>=0 && ULSNDGain<=7);
+ if( ULSNDGain == 0 )
+ bgSnd.ULGain = 0;
+ else {
+ bgSnd.ULGain = (kal_int16)(32767 >> (7 - ULSNDGain));
+ }
+ bgSnd.fULSPH = bULSPHFlag;
+}
+
+
+/**
+ The function sets the playback mode.
+
+ @bDLSPHFlag: Mixer switch for downlink speech, 1 for SPH+background Sound, 0 for background sound only
+ @DLSNDGain: Sound effect gain for downlink mixer
+*/
+void BGSND_ConfigDLMixer(kal_bool bDLSPHFlag, kal_int8 DLSNDGain )
+{
+#if defined(__ENABLE_SPEECH_DVT__)
+ DLSNDGain = 7;
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ MD_TRC_L1SND_CONFIG_DLMIXER(bDLSPHFlag, DLSNDGain);
+
+ ASSERT(DLSNDGain>=0 && DLSNDGain<=7);
+ if( DLSNDGain == 0)
+ bgSnd.DLGain = 0;
+ else {
+ bgSnd.DLGain = (kal_int16)(32767 >> (7 - DLSNDGain));
+ }
+ bgSnd.fDLSPH = bDLSPHFlag;
+}
+
+/**
+
+ The function starts the background sound playback of the media handle.
+
+ @bgSnd_hdlr: handler
+ @ULGainLevel: uplink gain level, from 0~7
+ @DLGainLevel: downlink gain level, from 0~7
+
+*/
+void BGSND_Start(void (*bgSnd_hisrHandler)(void), void (*bgSnd_offHandler)(void),
+ kal_uint8 ULGainLevel , kal_uint8 DLGainLevel)
+{
+ MD_TRC_L1SND_ENTER_BGSND_START();
+
+ // clean up
+ bgSnd.dspLastSample = 0;
+ bgSnd.endCount = 0;
+
+ // buffer reset
+ memset(bgSndBuf, 0, sizeof(kal_uint16)*BGSND_BUF_SIZE);
+ bgSnd.pBuf = bgSndBuf;
+ bgSnd.bufSize = BGSND_BUF_SIZE;
+ bgSnd.bufRead = 0;
+ bgSnd.bufWrite = BGSND_BUF_PTR_DIFF;
+
+ // clear hisr flag
+ bgSnd.isDlHisrCome = false;
+ bgSnd.isUlHisrCome = false;
+
+ // lock DSP for sherif writing.
+ L1Audio_SetFlag( bgSnd.aud_id ); // REIMIND: Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag1
+
+ // L1Audio_SetEventHandler(bgSnd.aud_id, BGSND_eventHandler );
+ bgSnd.bgSnd_hisrHandler = bgSnd_hisrHandler;
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL, bgsndDlHisr, 0);
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_UL, bgsndUlHisr, 0);
+#else
+ L1Audio_HookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL, bgsndHisr, 0);
+#endif
+
+ bgSnd.bgSnd_offHandler = bgSnd_offHandler;
+
+ // gain setting and update
+ if(AM_IsSpeechOn()){
+ BGSND_ConfigULMixer(KAL_TRUE, ULGainLevel);
+ BGSND_ConfigDLMixer(KAL_TRUE, DLGainLevel);
+ } else {
+ BGSND_ConfigULMixer(KAL_FALSE, ULGainLevel);
+ BGSND_ConfigDLMixer(KAL_FALSE, DLGainLevel);
+ }
+ bgsndUpdateMixer();
+
+
+ // Before dynamic download, all application should be off.
+ // But background sound do not need to dynamic download, so the following is unnecessary.
+ // KT_StopAndWait();
+
+ // turn on.
+ bgsndOnHandler();
+
+ // L1SP_Register_BgsService(bgsndOnHandler, bgsndOffHandler);
+ bgSnd.state = BGSND_STATE_RUN;
+}
+
+/*
+ * Description
+ * ---------
+ * The function stops the background sound playback of the media handle.
+ *
+ * Syntax
+ * ---------
+ * void BGSND_Stop();
+ *
+ * where
+ * hdl The media handle
+ *
+ * Return Value
+ * ---------
+ * None
+ */
+void BGSND_Stop(void)
+{
+
+
+
+ MD_TRC_L1SND_ENTER_BGSND_STOP();
+
+ /*
+ if ( !L1Audio_CheckFlag( bgSnd.aud_id ) )
+ return;
+ */
+
+ // unregister service
+ // L1SP_UnRegister_BgsService();
+
+ bgSnd.state = BGSND_STATE_STOP;
+
+ // set event to trigger close process
+ L1Audio_SetEvent(bgSnd.aud_id, NULL);
+}
+
+void BGSND_Close(void)
+{
+
+ L1Audio_ClearFlag( bgSnd.aud_id );
+
+#ifdef DSP_BGS_UP_DOWN_INT_SEPERATE
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL);
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_UL);
+#else
+ L1Audio_UnhookHisrHandler(D2C_SOUND_EFFECT_INT_ID_DL);
+#endif
+
+ // reset the pointer
+ bgSnd.pBuf = NULL;
+ bgSnd.bufSize = 0;
+ bgSnd.bgSnd_hisrHandler = NULL;
+
+
+ bgSnd.state = BGSND_STATE_IDLE;
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function sets the output device.
+ *
+ * Syntax
+ * ---------
+ * void BGSND_SetOutputDevice( kal_uint8 device );
+ *
+ * where
+ * device The output device (L1SP_SPEAKER1, L1SP_SPEAKER2, L1SP_LOUD_SPEAKER)
+ *
+ * Return Value
+ * ---------
+ * None
+
+void BGSND_SetOutputDevice( kal_uint8 device )
+{
+ //if( !AM_IsSpeechOn() )
+#ifdef ANALOG_AFE_PATH_EXIST
+ AFE_SetOutputDevice( L1SP_SND_EFFECT, device );
+#endif
+}
+*/
+
+
+void BGSND_INIT()
+{
+ memset(&bgSnd, 0, sizeof(BGSND_T));
+
+ // get audio ID
+ bgSnd.aud_id = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler( bgSnd.aud_id, (L1Audio_EventHandler)bgsndEventHandler );
+ bgSnd.timer = kal_create_timer("bgSnd");
+}
+
diff --git a/mcu/driver/audio/src/v1/bt_sco_drv.c b/mcu/driver/audio/src/v1/bt_sco_drv.c
new file mode 100644
index 0000000..b7df75e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/bt_sco_drv.c
@@ -0,0 +1,1588 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * BT_SCO_drv.c
+ *
+ * Project:
+ * --------
+ * Maui_sw
+ *
+ * Description:
+ * ------------
+ * BT SCO driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+
+#include "kal_public_defs.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "l1audio.h"
+#include "speech_def.h"
+#include "media.h"
+#include "audio_enum.h"
+#include "l1sp_trc.h"
+#include "bt_sco_drv.h"
+#include "cvsd_codec_exp.h"
+#include "sp_daca.h"
+#include "intrCtrl.h"
+#include "audio_dsp_d2c_def.h"
+#include "dcl.h"
+#include "msbc_codec_exp.h"
+#include "afe.h"
+#include "us_timer.h"
+
+/* for SP_LOG */
+#include "audio_msgid.h"
+#include "speech_service.h"
+//#define DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP 1
+//#define DELAY_UNMASK_INTERRUPT 1
+
+extern void L1Audio_TrigD2CHisr(uint16 magicNo);
+
+#define SCO_CVSD_BUFFER_SIZE 30000//24004//(13296)
+static kal_uint8 SCO_CVSD_BUFFER[SCO_CVSD_BUFFER_SIZE];
+
+#if defined(DELAY_UNMASK_INTERRUPT)
+static kal_uint32 uCVSDGPT;
+#endif
+
+static const kal_uint32 btsco_PacketValidMask[6][6] = {{0x1 , 0x1<<1, 0x1<<2, 0x1<<3, 0x1<<4 , 0x1<<5 }, //30
+ {0x1 , 0x1 , 0x2 , 0x2 , 0x4 , 0x4 }, //60
+ {0x1 , 0x1 , 0x1 , 0x2 , 0x2 , 0x2 }, //90
+ {0x1 , 0x1 , 0x1 , 0x1 , 0 , 0 }, //120
+ {0x7 , 0x7<<3, 0x7<<6, 0x7<<9, 0x7<<12, 0x7<<15}, //10
+ {0x3 , 0x3<<1, 0x3<<3, 0x3<<4, 0x3<<6 , 0x3<<7 }}; //20
+
+static const kal_uint8 btsco_PacketInfo[6][6] = {{ 30, 6, BT_SCO_PACKET_180/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_180/SCO_RX_PLC_SIZE}, // 30, 6, 3, 6
+ { 60, 3, BT_SCO_PACKET_180/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_180/SCO_RX_PLC_SIZE}, // 60, 3, 3, 6
+ { 90, 2, BT_SCO_PACKET_180/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_180/SCO_RX_PLC_SIZE}, // 90, 2, 3, 6
+ {120, 1, BT_SCO_PACKET_120/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_120/SCO_RX_PLC_SIZE}, //120, 1, 2, 4
+ { 10,18, BT_SCO_PACKET_180/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_180/SCO_RX_PLC_SIZE}, // 10,18, 3, 6
+ { 20, 9, BT_SCO_PACKET_180/SCO_TX_ENCODE_SIZE, BT_SCO_PACKET_180/SCO_RX_PLC_SIZE}}; // 20, 9, 3, 6
+
+static const kal_uint8 btsco_MsbcHeader[4] = {0x08, 0x38, 0xc8, 0xf8};
+
+kal_uint8 table_msbc_silence[180] = {
+ 0x01, 0x38, 0xad, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0x00,
+ 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d,
+ 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7,
+ 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd,
+ 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77,
+ 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6c, 0x00,
+ 0x01, 0xc8, 0xad, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0x00,
+ 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d,
+ 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7,
+ 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd,
+ 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77,
+ 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6c, 0x00,
+ 0x01, 0xf8, 0xad, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0x00,
+ 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d,
+ 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7,
+ 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, 0xdd,
+ 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77,
+ 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6c, 0x00
+};
+
+kal_spinlockid bt_lockId;
+kal_enhmutexid bt_mutex;
+
+static struct{
+ BT_SCO_TX *pTX;
+ BT_SCO_RX *pRX;
+ kal_uint8 *pTempPacketBuf;
+ kal_uint8 *pSpeechData;
+ kal_uint16 uAudId;
+ BT_SCO_STATE uState;
+ BT_SCO_MODE uMode;
+ bool fBtError;
+ bool fWideBand;
+ bool isCodecAlign;
+ kal_uint8 uMsbcHeaderIndex;
+}btsco;
+
+void BT_SCO_LISR(void);
+
+//=============================================================================================
+// BT SCO Buffer control interface
+//=============================================================================================
+
+static void BT_SCO_GetReadBuffer_RX(kal_uint8 **pBuf, kal_uint32 *pLen)
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ rbGetReadBuffer(&btsco.pRX->RingBuffer, pBuf, pLen);
+}
+
+static void BT_SCO_ReadDataDone_RX(kal_uint32 uLen)
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ rbReadDataDone(&btsco.pRX->RingBuffer, uLen);
+}
+
+static kal_int32 BT_SCO_GetDataCount_RX()
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ return rbGetDataCount(&btsco.pRX->RingBuffer);
+}
+
+static void BT_SCO_GetWriteBuffer_TX(kal_uint8 **pBuf, kal_uint32 *pLen)
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ rbGetWriteBuffer(&btsco.pTX->RingBuffer, pBuf, pLen);
+}
+
+static void BT_SCO_WriteDataDone_TX(kal_uint32 uLen)
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ rbWriteDataDone(&btsco.pTX->RingBuffer, uLen);
+}
+
+static kal_int32 BT_SCO_GetFreeSpace_TX()
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ return rbGetFreeSpace(&btsco.pTX->RingBuffer);
+}
+
+static void btsco_GetReadBuffer_TX(kal_uint8 **pBuf, kal_uint32 *pLen)
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ rbGetReadBuffer(&btsco.pTX->RingBuffer, pBuf, pLen);
+}
+
+static void btsco_ReadDataDone_TX(kal_uint32 uLen)
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ rbReadDataDone(&btsco.pTX->RingBuffer, uLen);
+}
+
+static kal_uint32 btsco_GetDataCount_TX()
+{
+ ASSERT(btsco.pTX->RingBuffer.rb_base);
+ return rbGetDataCount(&btsco.pTX->RingBuffer);
+}
+
+static kal_int32 btsco_GetFreeSpace_RX()
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ return rbGetFreeSpace(&btsco.pRX->RingBuffer);
+}
+
+static void btsco_GetWriteBuffer_RX(kal_uint8 **pBuf, kal_uint32 *pLen)
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ rbGetWriteBuffer(&btsco.pRX->RingBuffer, pBuf, pLen);
+}
+
+static void btsco_WriteDataDone_RX(kal_uint32 uLen)
+{
+ ASSERT(btsco.pRX->RingBuffer.rb_base);
+ rbWriteDataDone(&btsco.pRX->RingBuffer, uLen);
+}
+
+//=============================================================================================
+// BT SCO Internal Function
+//=============================================================================================
+
+static void btsco_DataTransfer(BT_SCO_DIRECT uDir, kal_uint8 *pSrc, kal_uint8 *pDst, kal_uint32 uBlockSize, kal_uint32 uBlockNum )
+{
+ kal_int32 i, j;
+ if(uBlockSize == 60 || uBlockSize == 120 || uBlockSize == 20)
+ {
+ kal_uint32 *pSrc32 = (kal_uint32*)pSrc;
+ kal_uint32 *pDst32 = (kal_uint32*)pDst;
+ for(i=0 ; i<(uBlockSize*uBlockNum/4) ; i++)
+ {
+ *pDst32++ = *pSrc32++;
+ if(uDir == BT_SCO_DIRECT_ARM2BT && i%3==0)
+ {
+ AFE_DELAY(15);
+ }
+ }
+ }
+ else
+ {
+ kal_uint16 *pSrc16 = (kal_uint16*)pSrc;
+ kal_uint16 *pDst16 = (kal_uint16*)pDst;
+ for(j=0 ; j< uBlockNum ; j++)
+ {
+ for(i=0 ; i<(uBlockSize/2) ; i++)
+ {
+ *pDst16++ = *pSrc16++;
+ if(uDir == BT_SCO_DIRECT_ARM2BT && i%3==0)
+ {
+ AFE_DELAY(15);
+ }
+ }
+ if(uDir == BT_SCO_DIRECT_BT2ARM)
+ {
+ pSrc16++;
+ }
+ else
+ {
+ pDst16++;
+ }
+ }
+ }
+}
+
+
+static void btsco_ReadFromBT(BT_SCO_PACKET_LEN uLen, kal_uint32 uPacketLength, kal_uint32 uPacketNumber, kal_uint32 uBlockSize, kal_uint32 uControl)
+{
+ kal_int32 i;
+ #if (defined(MT6765) || defined(MT3967) || defined(MT6779) || defined(MT6785) || defined(MT6885) || defined(MERCURY) || defined(MT6873) || defined(MT6853) || defined(MT6833) || defined(MT6877))
+ kal_uint8 *pSrc = (kal_uint8 *)(BTSRAM_base + ((*BT_SCO_HW_REG_PACKET_R & 0xFFFF)));
+ #else
+ kal_uint8 *pSrc = (kal_uint8 *)(BTSRAM_base + ((((*BT_SCO_HW_REG_PACKET_R & 0x00F00000)>>4)-0x00010000) | (*BT_SCO_HW_REG_PACKET_R & 0xFFFF)));
+ #endif
+ if(*BT_SCO_HW_REG_PACKET_W == 0 || *BT_SCO_HW_REG_PACKET_R == 0 ||*BT_SCO_HW_REG_PACKET_W == 0xDEADFEED ||*BT_SCO_HW_REG_PACKET_R == 0xDEADFEED
+ ||(*BT_SCO_HW_REG_PACKET_R & 0xFFFF)==0xFEED)
+ {
+ MD_TRC_L1AUDIO_BTSCO_CONTROL(0x0, 0x0, *BT_SCO_HW_REG_PACKET_W, *BT_SCO_HW_REG_PACKET_R);
+ btsco.fBtError = KAL_TRUE;
+ return;
+ }
+
+
+ if(btsco.isCodecAlign==true){
+ btsco_DataTransfer(BT_SCO_DIRECT_BT2ARM, pSrc, btsco.pTempPacketBuf, uPacketLength, uPacketNumber );
+ }
+
+ SPLog_LogData(MSG_ID_AUDIO_LOGGING_BT_RX, (kal_uint32)(uPacketLength*uPacketNumber), btsco.pTempPacketBuf);
+ if(btsco.uState == BT_SCO_STATE_ENDING)
+ {
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ memset(btsco.pTempPacketBuf, 0, uPacketLength*uPacketNumber*sizeof(kal_uint8));
+ }
+ else
+#endif
+ {
+ memset(btsco.pTempPacketBuf, 0x55, uPacketLength*uPacketNumber*sizeof(kal_uint8));
+ }
+ }
+ for(i=0;i<uBlockSize;i++)
+ {
+ memcpy(btsco.pRX->PacketBuf[btsco.pRX->iPacket_w & SCO_RX_PACKET_MASK], btsco.pTempPacketBuf+(SCO_RX_PLC_SIZE*i), SCO_RX_PLC_SIZE);
+ if( (uControl & btsco_PacketValidMask[uLen][i]) == btsco_PacketValidMask[uLen][i])
+ {
+ btsco.pRX->PacketValid[btsco.pRX->iPacket_w & SCO_RX_PACKET_MASK] = 1 ; //packet valid
+ }
+ else
+ {
+ btsco.pRX->PacketValid[btsco.pRX->iPacket_w & SCO_RX_PACKET_MASK] = 0 ; //packet invalid
+ }
+ btsco.pRX->iPacket_w++;
+ }
+}
+
+static void btsco_WriteToBT(BT_SCO_PACKET_LEN uLen, kal_uint32 uPacketLength, kal_uint32 uPacketNumber, kal_uint32 uBlockSize, kal_bool fFillSilence)
+{
+ kal_int32 i;
+ #if (defined(MT6765) || defined(MT3967) || defined(MT6779) || defined(MT6785) || defined(MT6885) || defined(MERCURY) || defined(MT6873) || defined(MT6853) || defined(MT6833) || defined(MT6877))
+ kal_uint8 *pDst = (kal_uint8 *)(BTSRAM_base + ((*BT_SCO_HW_REG_PACKET_W & 0xFFFF)));
+ #else
+ kal_uint8 *pDst = (kal_uint8 *)(BTSRAM_base + ((((*BT_SCO_HW_REG_PACKET_W & 0x00F00000)>>4)-0x00010000) | (*BT_SCO_HW_REG_PACKET_W & 0xFFFF)));
+ #endif
+ if(*BT_SCO_HW_REG_PACKET_W == 0 || *BT_SCO_HW_REG_PACKET_R == 0 ||*BT_SCO_HW_REG_PACKET_W == 0xDEADFEED ||*BT_SCO_HW_REG_PACKET_R == 0xDEADFEED
+ ||(*BT_SCO_HW_REG_PACKET_W & 0xFFFF) ==0xFEED)
+ {
+ MD_TRC_L1AUDIO_BTSCO_CONTROL(0x02, 0x02, *BT_SCO_HW_REG_PACKET_W, *BT_SCO_HW_REG_PACKET_R);
+ btsco.fBtError = KAL_TRUE;
+ return;
+ }
+ if(fFillSilence == KAL_TRUE)
+ {
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ //memset(btsco.pTempPacketBuf, 0, uPacketLength*uPacketNumber*sizeof(kal_uint8));
+ ASSERT( 180 == (uPacketLength*uPacketNumber));
+ for(i=0;i<3;i++)
+ {
+ table_msbc_silence[(60*i)+1]= btsco_MsbcHeader[btsco.uMsbcHeaderIndex&0x3]; //header
+ btsco.uMsbcHeaderIndex++;
+ if(btsco.uMsbcHeaderIndex>=4)
+ {
+ btsco.uMsbcHeaderIndex = 0;
+ }
+ }
+
+ memcpy(btsco.pTempPacketBuf, table_msbc_silence, uPacketLength*uPacketNumber*sizeof(kal_uint8));
+ }
+ else
+#endif
+ {
+ memset(btsco.pTempPacketBuf, 0x55, uPacketLength*uPacketNumber*sizeof(kal_uint8));
+ }
+ }
+ else
+ {
+ for(i=0;i<uBlockSize;i++)
+ {
+ #if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ btsco.pTX->PacketBuf[btsco.pTX->iPacket_r & SCO_TX_PACKET_MASK][1]=btsco_MsbcHeader[btsco.uMsbcHeaderIndex&0x3];
+ btsco.uMsbcHeaderIndex++;
+ if(btsco.uMsbcHeaderIndex>=4)
+ {
+ btsco.uMsbcHeaderIndex = 0;
+ }
+ }
+ #endif
+ memcpy(btsco.pTempPacketBuf+(SCO_TX_ENCODE_SIZE*i), btsco.pTX->PacketBuf[btsco.pTX->iPacket_r & SCO_TX_PACKET_MASK], SCO_TX_ENCODE_SIZE);
+
+ btsco.pTX->iPacket_r++;
+ }
+ }
+ if(btsco.isCodecAlign==true){
+ btsco_DataTransfer(BT_SCO_DIRECT_ARM2BT, btsco.pTempPacketBuf, pDst, uPacketLength, uPacketNumber );
+ }
+
+ SPLog_LogData(MSG_ID_AUDIO_LOGGING_BT_TX, (kal_uint32)(uPacketLength*uPacketNumber), btsco.pTempPacketBuf);
+}
+
+static void btsco_hisr_internal()
+{
+ kal_uint32 curr_frc, latest_us;
+ kal_uint32 uPacketType, uPacketNumber, uPacketLength, uBufferCount_TX, uBufferCount_RX, uControl;
+
+ if((btsco.uState != BT_SCO_STATE_RUNNING) && (btsco.uState != BT_SCO_STATE_ENDING))
+ {
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ uControl = *BT_SCO_HW_REG_CONTROL;
+ uPacketType = (uControl >> 18) & 0x7;
+
+ MD_TRC_L1AUDIO_BTSCO_CONTROL(uControl, uPacketType, *BT_SCO_HW_REG_PACKET_W, *BT_SCO_HW_REG_PACKET_R);
+
+ btsco.fBtError = KAL_FALSE;
+ if(*BT_SCO_HW_REG_PACKET_W == 0 || *BT_SCO_HW_REG_PACKET_R == 0 || uControl == 0)
+ {
+ MD_TRC_CVSD_BTSCO_HISR_ADDRESS(BT_SCO_HW_REG_PACKET_W, BT_SCO_HW_REG_PACKET_R, BT_SCO_HW_REG_CONTROL);
+ btsco.fBtError = KAL_TRUE;
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ // consys in sleep will return 0xDEADFEED (DE(Congliang Liao))
+ //1. connsys in sleep
+ //2. connsys mcu enter FW exception
+ if(*BT_SCO_HW_REG_PACKET_W == 0xDEADFEED || *BT_SCO_HW_REG_PACKET_R == 0xDEADFEED || uControl == 0xDEADFEED)
+ {
+ MD_TRC_CVSD_BTSCO_HISR_ADDRESS(BT_SCO_HW_REG_PACKET_W, BT_SCO_HW_REG_PACKET_R, BT_SCO_HW_REG_CONTROL);
+ btsco.fBtError = KAL_TRUE;
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+
+ if( ((uControl>>31) & 1) == 0)
+ {
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ ASSERT(uPacketType < BT_SCO_CVSD_MAX);
+ uPacketLength = (kal_uint32)btsco_PacketInfo[uPacketType][0];
+ uPacketNumber = (kal_uint32)btsco_PacketInfo[uPacketType][1];
+ uBufferCount_TX = (kal_uint32)btsco_PacketInfo[uPacketType][2];
+ uBufferCount_RX = (kal_uint32)btsco_PacketInfo[uPacketType][3];
+
+ if(btsco.uMode == BT_SCO_MODE_LOOPBACK_WITHOUT_CODEC) // read data from BT and write back directly
+ {
+ kal_uint8 *pDst, *pSrc;
+ pDst = (kal_uint8 *)(BTSRAM_base + ((((*BT_SCO_HW_REG_PACKET_W & 0x00F00000)>>4)-0x00010000) | (*BT_SCO_HW_REG_PACKET_W & 0xFFFF)));
+ pSrc = (kal_uint8 *)(BTSRAM_base + ((((*BT_SCO_HW_REG_PACKET_R & 0x00F00000)>>4)-0x00010000) | (*BT_SCO_HW_REG_PACKET_R & 0xFFFF)));
+ if(*BT_SCO_HW_REG_PACKET_W == 0 || *BT_SCO_HW_REG_PACKET_R == 0 || uControl == 0)
+ {
+ MD_TRC_CVSD_BTSCO_HISR_ADDRESS(BT_SCO_HW_REG_PACKET_W, BT_SCO_HW_REG_PACKET_R, BT_SCO_HW_REG_CONTROL);
+ btsco.fBtError = KAL_TRUE;
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+
+ if(*BT_SCO_HW_REG_PACKET_W == 0xDEADFEED || *BT_SCO_HW_REG_PACKET_R == 0xDEADFEED || uControl == 0xDEADFEED)
+ {
+ MD_TRC_CVSD_BTSCO_HISR_ADDRESS(BT_SCO_HW_REG_PACKET_W, BT_SCO_HW_REG_PACKET_R, BT_SCO_HW_REG_CONTROL);
+ btsco.fBtError = KAL_TRUE;
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ btsco_DataTransfer(BT_SCO_DIRECT_BT2ARM, pSrc, btsco.pTempPacketBuf, uPacketLength, uPacketNumber );
+ btsco_DataTransfer(BT_SCO_DIRECT_ARM2BT, btsco.pTempPacketBuf, pDst, uPacketLength, uPacketNumber );
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ curr_frc = ust_get_current_time();
+ if(btsco.pRX)
+ {
+ MD_TRC_L1AUDIO_BTSCO_COPY_RX(btsco.pRX->fOverflow, btsco.pRX->iPacket_w, btsco.pRX->iPacket_r, uBufferCount_RX);
+ if(btsco.pRX->fOverflow)
+ {
+ if(btsco.pRX->iPacket_w - btsco.pRX->iPacket_r <= SCO_RX_PACKER_BUF_NUM - 2*uBufferCount_RX)
+ {
+ //free space is larger then twice interrupt rx data size
+ btsco.pRX->fOverflow = KAL_FALSE;
+ }
+ }
+ if(!btsco.pRX->fOverflow && (btsco.pRX->iPacket_w - btsco.pRX->iPacket_r <= SCO_RX_PACKER_BUF_NUM - uBufferCount_RX))
+ {
+ btsco_ReadFromBT(uPacketType, uPacketLength, uPacketNumber, uBufferCount_RX, uControl);
+ }
+ else
+ {
+ btsco.pRX->fOverflow = KAL_TRUE;
+ }
+ }
+ latest_us = ust_get_current_time();
+ MD_TRC_L1AUDIO_BTSCO_HISR_TX_PERIOD(ust_us_duration(curr_frc, latest_us));
+ curr_frc = ust_get_current_time();
+ if(btsco.pTX)
+ {
+ MD_TRC_L1AUDIO_BTSCO_COPY_TX(btsco.pTX->fUnderflow, btsco.pTX->iPacket_w, btsco.pTX->iPacket_r, uBufferCount_TX);
+ if(btsco.pTX->fUnderflow)
+ {
+ //prepared data is larger then twice interrupt tx data size
+ if(btsco.pTX->iPacket_w - btsco.pTX->iPacket_r >= 2*uBufferCount_TX)
+ {
+ btsco.pTX->fUnderflow = KAL_FALSE;
+ }
+ }
+
+ if(btsco.pTX->iPacket_w - btsco.pTX->iPacket_r < uBufferCount_TX)
+ {
+ btsco.pTX->fUnderflow = KAL_TRUE;
+ }
+ kal_give_spinlock(bt_lockId);
+ if(btsco.pTX->fUnderflow || btsco.uState == BT_SCO_STATE_ENDING)
+ { //silence
+ btsco_WriteToBT(uPacketType, uPacketLength, uPacketNumber, uBufferCount_TX, KAL_TRUE);
+ }
+ else
+ { //cvsd packet
+ btsco_WriteToBT(uPacketType, uPacketLength, uPacketNumber, uBufferCount_TX, KAL_FALSE);
+ }
+ }
+ else{
+ kal_give_spinlock(bt_lockId);
+ }
+ latest_us = ust_get_current_time();
+ MD_TRC_L1AUDIO_BTSCO_HISR_RX_PERIOD(ust_us_duration(curr_frc, latest_us));
+}
+
+#if defined(DELAY_UNMASK_INTERRUPT)
+static void btsco_DelayInterruptUnMask( void *data )
+{
+ if( btsco.uState != BT_SCO_STATE_IDLE )
+ {
+ IRQUnmask(IRQ_BT_CVSD_CODE);
+ }
+}
+#endif
+
+static void btsco_hisr(void *pData)
+{
+ kal_uint32 curr_frc, latest_us, uCodec_id;
+ uCodec_id = (*BT_SCO_HW_REG_CONTROL & BT_CVSD_Codec_id)>>25; // 00:init 01:cvsd 02:msbc
+
+ if((btsco.fWideBand==true && uCodec_id==0x01)||(btsco.fWideBand==false && uCodec_id==0x02))
+ {
+ MD_TRC_CVSD_BTSCO_CODEC_ID(btsco.fWideBand, uCodec_id, BT_SCO_HW_REG_CONTROL);
+ btsco.isCodecAlign=false;
+ }else{
+ btsco.isCodecAlign=true;
+ }
+
+
+ MD_TRC_L1AUDIO_BTSCO_HISR(btsco.uState);
+ curr_frc = ust_get_current_time();//unit: micro second (us)
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ if( btsco.uState == BT_SCO_STATE_IDLE )
+ {
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ btsco_hisr_internal();
+ *BT_SCO_HW_REG_CONTROL &= ~BT_CVSD_CLEAR;
+ Data_Sync_Barrier();
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+ if( btsco.uState != BT_SCO_STATE_IDLE )
+ {
+#if defined(DELAY_UNMASK_INTERRUPT)
+ kal_trace( TRACE_GROUP_SCO,L1AUDIO_BTSCO_HISR_GPT, btsco.fBtError, uCVSDGPT);
+ if(btsco.fBtError == KAL_TRUE && uCVSDGPT)
+ {
+ #define CVSD_DELAY_INTERRUPT 1000 //msec
+ SGPT_CTRL_START_T start;
+ start.u2Tick = (CVSD_DELAY_INTERRUPT / 10);
+ start.pfCallback = btsco_DelayInterruptUnMask;
+ start.vPara = NULL;
+ DclSGPT_Control( uCVSDGPT, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ }
+ else
+#endif
+ {
+ IRQUnmask(IRQ_BT_CVSD_CODE);
+ }
+ }
+#endif
+ //kal_give_spinlock(bt_lockId);
+ latest_us = ust_get_current_time();
+ MD_TRC_L1AUDIO_BTSCO_HISR_PERIOD(ust_us_duration(curr_frc, latest_us));
+
+ if(btsco.isCodecAlign==true){
+ L1Audio_SetEvent( btsco.uAudId, NULL );
+ }
+}
+
+static kal_uint32 btsco_GetMemorySize_4ByteAlign(BT_SCO_MODULE uModule)
+{
+ kal_uint32 uSize=0;
+ switch(uModule)
+ {
+ case BT_SCO_MOD_CVSD_ENCODE:
+ uSize = (kal_uint32)CVSD_ENC_GetBufferSize();
+ break;
+ case BT_SCO_MOD_CVSD_DECODE:
+ uSize = (kal_uint32)CVSD_DEC_GetBufferSize();
+ break;
+ case BT_SCO_MOD_PLC_NB:
+ case BT_SCO_MOD_PLC_WB:
+ uSize = (kal_uint32)g711plc_GetMemorySize_v2();
+ break;
+ case BT_SCO_MOD_CVSD_TX_SRC:
+ uSize = CVSD_UpSample_GetMemory();
+ break;
+ case BT_SCO_MOD_CVSD_RX_SRC:
+ uSize = CVSD_DownSample_GetMemory();
+ break;
+ case BT_SCO_MOD_PCM_RINGBUF_TX:
+ uSize = SCO_TX_RINGBUFFER_SIZE;
+ break;
+ case BT_SCO_MOD_PCM_RINGBUF_RX:
+ uSize = SCO_RX_RINGBUFFER_SIZE;
+ break;
+#if defined(__CVSD_CODEC_SUPPORT__)
+ case BT_SCO_MOD_MSBC_ENCODE:
+ uSize = (kal_uint32)MSBC_ENC_GetBufferSize();
+ break;
+ case BT_SCO_MOD_MSBC_DECODE:
+ uSize = (kal_uint32)MSBC_DEC_GetBufferSize();
+ break;
+#endif
+ default:
+ ASSERT(0);
+ }
+ uSize = (uSize+3) & ~3 ;
+ MD_TRC_L1AUDIO_BTSCO_GET_MEM(uModule, uSize);
+ return uSize;
+}
+
+static void btsco_InitialModule(BT_SCO_MODULE uModule, kal_uint8 *pBuf)
+{
+ ASSERT(pBuf);
+ switch(uModule)
+ {
+ case BT_SCO_MOD_CVSD_ENCODE:
+ btsco.pTX->pEncHandle = CVSD_ENC_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_CVSD_DECODE:
+ btsco.pRX->pDecHandle = CVSD_DEC_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_PLC_NB:
+ g711plc_construct_v2((void *)pBuf, 8000);
+ btsco.pRX->pPLCHandle = (void*)pBuf;
+ break;
+ case BT_SCO_MOD_CVSD_TX_SRC:
+ btsco.pTX->pSRCHandle = CVSD_UpSample_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_CVSD_RX_SRC:
+ btsco.pRX->pSRCHandle = CVSD_DownSample_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_PCM_RINGBUF_TX:
+ btsco.pTX->RingBuffer.rb_base = pBuf;
+ btsco.pTX->RingBuffer.rb_size = SCO_TX_RINGBUFFER_SIZE;
+ break;
+ case BT_SCO_MOD_PCM_RINGBUF_RX:
+ btsco.pRX->RingBuffer.rb_base = pBuf;
+ btsco.pRX->RingBuffer.rb_size = SCO_RX_RINGBUFFER_SIZE;
+ break;
+#if defined(__MSBC_CODEC_SUPPORT__)
+ case BT_SCO_MOD_MSBC_ENCODE:
+ btsco.pTX->pEncHandle = MSBC_ENC_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_MSBC_DECODE:
+ btsco.pRX->pDecHandle = MSBC_DEC_Init((char*)pBuf);
+ break;
+ case BT_SCO_MOD_PLC_WB:
+ g711plc_construct_v2((void *)pBuf, 16000);
+ btsco.pRX->pPLCHandle = (void*)pBuf;
+ break;
+#endif
+ default:
+ ASSERT(0);
+ }
+}
+
+static void btsco_AllocMemory_CVSD()
+{
+ kal_uint32 uTotalMemory = 0, uTxMemSize = 0, uRxMemSize = 0, uSpeechBufferSize=0;
+ kal_uint8 *pBuf = SCO_CVSD_BUFFER;
+ uTxMemSize = (sizeof(BT_SCO_TX)+3)& ~0x3;
+ uRxMemSize = (sizeof(BT_SCO_RX)+3)& ~0x3;
+ uSpeechBufferSize = (NB_SPEECH_FRAME_SIZE+3)& ~0x3;
+ uTotalMemory = uTxMemSize+uRxMemSize+uSpeechBufferSize+BT_SCO_PACKET_180;
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_TX);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_ENCODE);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_TX_SRC);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_RX);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_DECODE);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_RX_SRC);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PLC_NB);
+
+ MD_TRC_L1AUDIO_BTSCO_ALLOC_MEM(uTotalMemory, pBuf);
+ ASSERT(SCO_CVSD_BUFFER_SIZE >= uTotalMemory); //double check
+ memset(SCO_CVSD_BUFFER, 0, SCO_CVSD_BUFFER_SIZE);
+
+ btsco.pTX = (BT_SCO_TX*)pBuf;
+ pBuf += uTxMemSize;
+ btsco.pRX = (BT_SCO_RX*)pBuf;
+ pBuf += uRxMemSize;
+ btsco.pSpeechData = (kal_uint8 *)pBuf;
+ pBuf += uSpeechBufferSize;
+ btsco.pTempPacketBuf = (kal_uint8 *)pBuf;
+ pBuf += BT_SCO_PACKET_180;
+ btsco_InitialModule(BT_SCO_MOD_CVSD_ENCODE, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_ENCODE);
+ btsco_InitialModule(BT_SCO_MOD_CVSD_TX_SRC, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_TX_SRC);
+ btsco_InitialModule(BT_SCO_MOD_PCM_RINGBUF_TX, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_TX);
+ btsco_InitialModule(BT_SCO_MOD_CVSD_DECODE, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_DECODE);
+ btsco_InitialModule(BT_SCO_MOD_CVSD_RX_SRC, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_CVSD_RX_SRC);
+ btsco_InitialModule(BT_SCO_MOD_PCM_RINGBUF_RX, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_RX);
+ btsco_InitialModule(BT_SCO_MOD_PLC_NB, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PLC_NB);
+
+ MD_TRC_CVSD_BT_SCO_ALLOC_CVSD_MEMORY(uTotalMemory);
+}
+
+static void btsco_process_TX_CVSD()
+{
+ kal_int32 iCount=0;
+ while(1)
+ {
+ for(iCount = 0 ; iCount < 2 ; iCount++)
+ { //downsample
+ kal_uint8 *pInBuf;
+ kal_uint32 uInByte=0, uOutByte=0, uConsumeByte=0;
+ if(SCO_TX_PCM64K_BUF_SIZE != btsco.pTX->uPcmBuf_w)
+ {
+ btsco_GetReadBuffer_TX(&pInBuf, &uInByte);
+ MD_TRC_L1AUDIO_BTSCO_PROC_TX_RAW(uInByte, btsco.pTX->uPcmBuf_w);
+ uInByte = uInByte & 0xFFFFFFFE;
+ if(uInByte<2)
+ {
+ return;
+ }
+ uOutByte = SCO_TX_PCM64K_BUF_SIZE - btsco.pTX->uPcmBuf_w;
+ {
+ kal_uint32 uSrcInSample, uSrcOutSample;
+ uSrcInSample = uInByte >> 1;
+ uSrcOutSample = uOutByte >> 1;
+ if((uSrcInSample) > (uSrcOutSample>>3))
+ {
+ uSrcInSample = uSrcOutSample>>3;
+ }
+ CVSD_UpSample_Process(btsco.pTX->pSRCHandle, (kal_int16 *)pInBuf, (kal_int16 *)(&btsco.pTX->PcmBuf_64k[btsco.pTX->uPcmBuf_w]), (kal_int16 *)btsco.pTX->PcmBuf_Temp, uSrcInSample);
+ uConsumeByte = uSrcInSample<<1;
+ uOutByte = uSrcInSample<<4;
+ }
+ MD_TRC_L1AUDIO_BTSCO_PROC_TX_SRC(uConsumeByte, uOutByte);
+ btsco.pTX->uPcmBuf_w += uOutByte;
+ btsco_ReadDataDone_TX(uConsumeByte);
+ }
+ }
+ if(SCO_TX_PCM64K_BUF_SIZE == btsco.pTX->uPcmBuf_w)
+ {
+ if(btsco.pTX->iPacket_w - btsco.pTX->iPacket_r < SCO_TX_PACKER_BUF_NUM)
+ {
+ MD_TRC_L1AUDIO_BTSCO_PROC_TX_CVSD(btsco.pTX->iPacket_w, btsco.pTX->iPacket_r, 0);
+ { //encode
+ kal_int32 iInSample = SCO_TX_PCM64K_BUF_SIZE>>1;
+ kal_int32 iOutByte = SCO_TX_ENCODE_SIZE;
+ CVSD_ENC_Process(btsco.pTX->pEncHandle, (kal_int16*)btsco.pTX->PcmBuf_64k, &iInSample, (char*)&btsco.pTX->PacketBuf[btsco.pTX->iPacket_w & SCO_TX_PACKET_MASK][0], &iOutByte);
+ btsco.pTX->uPcmBuf_w = 0;
+ btsco.pTX->iPacket_w++;
+ }
+ }
+ else
+ {
+ return;
+ }
+ }
+ }
+}
+
+static void btsco_process_RX_CVSD()
+{
+ kal_int32 iCount=0;
+ while(1)
+ {
+ if(SCO_RX_PCM8K_BUF_SIZE == btsco.pRX->uPcmBuf_r)
+ {
+ //decode 30 byte cvsd
+ if(btsco.pRX->iPacket_w != btsco.pRX->iPacket_r)
+ {
+ kal_int32 iOutSample=0, iInByte=0;
+ iInByte=SCO_RX_PLC_SIZE;
+ iOutSample=SCO_RX_PCM64K_BUF_SIZE>>1;
+ MD_TRC_L1AUDIO_BTSCO_PROC_RX_CVSD(btsco.pRX->iPacket_w, btsco.pRX->iPacket_r, 0, 1);
+ CVSD_DEC_Process(btsco.pRX->pDecHandle, (char*)&btsco.pRX->PacketBuf[btsco.pRX->iPacket_r & SCO_RX_PACKET_MASK][0], &iInByte, (kal_int16*)btsco.pRX->PcmBuf_64k, &iOutSample);
+ {
+ kal_uint32 uConsumeByte=0;
+ CVSD_DownSample_Process(btsco.pRX->pSRCHandle, (kal_int16 *)btsco.pRX->PcmBuf_64k, (kal_int16 *)btsco.pRX->PcmBuf_8k, (kal_int16 *)btsco.pRX->PcmBuf_Temp, SCO_RX_PCM64K_BUF_SIZE>>1);
+ uConsumeByte = SCO_RX_PCM64K_BUF_SIZE;
+ ASSERT(uConsumeByte == SCO_RX_PCM64K_BUF_SIZE);
+ }
+ if(btsco.uMode == BT_SCO_MODE_SPEECH)//do PLC
+ {
+ MD_TRC_L1AUDIO_BTSCO_PROC_RX_PLC();
+ if(btsco.pRX->PacketValid[btsco.pRX->iPacket_r & SCO_RX_PACKET_MASK])
+ { //packet not lost
+ g711plc_addtohistory_v2(btsco.pRX->pPLCHandle, (short *)btsco.pRX->PcmBuf_8k, 0);
+ MD_TRC_CVSD_G711PLC_ADDTOHISTORY_COPY(btsco.pRX->iPacket_r);
+ }
+ else
+ { //packet lost
+ g711plc_dofe_v2(btsco.pRX->pPLCHandle, (short *)btsco.pRX->PcmBuf_8k, 0);
+ MD_TRC_CVSD_G711PLC_DOFE_COPY(btsco.pRX->iPacket_r);
+ }
+ }
+ btsco.pRX->iPacket_r++;
+ btsco.pRX->uPcmBuf_r=0;
+ }
+ else
+ { //cvsd buffer empty
+ return;
+ }
+
+ }
+ for(iCount = 0 ; iCount < 2 ; iCount++)
+ {
+ kal_uint32 uOutByte=0, uConsumeByte=0, uTotalSpace=0;
+ kal_uint8 *pOutBuf;
+ btsco_GetWriteBuffer_RX(&pOutBuf, &uOutByte);
+ uTotalSpace = btsco_GetFreeSpace_RX();
+ MD_TRC_L1AUDIO_BTSCO_PROC_RX_RAW(uOutByte, uTotalSpace, btsco.pRX->uPcmBuf_r);
+ uOutByte = uOutByte & 0xFFFFFFFE;;
+ if(uOutByte<2)
+ { //output buffer is empty
+ return;
+ }
+ { //output is 8k mono
+ uConsumeByte = SCO_RX_PCM8K_BUF_SIZE - btsco.pRX->uPcmBuf_r;
+ if(uConsumeByte>uOutByte)
+ {
+ uConsumeByte = uOutByte;
+ }
+ memcpy(pOutBuf, (btsco.pRX->PcmBuf_8k + btsco.pRX->uPcmBuf_r), uConsumeByte);
+ uOutByte = uConsumeByte;
+ }
+ btsco.pRX->uPcmBuf_r += uConsumeByte;
+ btsco_WriteDataDone_RX(uOutByte);
+ if(SCO_RX_PCM8K_BUF_SIZE == btsco.pRX->uPcmBuf_r)
+ {
+ break;
+ }
+ }
+ }
+}
+
+#if defined(__MSBC_CODEC_SUPPORT__)
+
+static void btsco_AllocMemory_MSBC()
+{
+ kal_uint32 uTotalMemory = 0, uTxMemSize = 0, uRxMemSize = 0, uSpeechBufferSize=0;
+ kal_uint8 *pBuf = SCO_CVSD_BUFFER;
+ uTxMemSize = (sizeof(BT_SCO_TX)+3)& ~0x3;
+ uRxMemSize = (sizeof(BT_SCO_RX)+3)& ~0x3;
+ uSpeechBufferSize = (WB_SPEECH_FRAME_SIZE+3)& ~0x3;
+ uTotalMemory = uTxMemSize+uRxMemSize+uSpeechBufferSize+BT_SCO_PACKET_180;
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_TX);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_MSBC_ENCODE);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_RX);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_MSBC_DECODE);
+ uTotalMemory += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PLC_WB);
+
+ MD_TRC_L1AUDIO_BTSCO_ALLOC_MEM(uTotalMemory, pBuf);
+ ASSERT(SCO_CVSD_BUFFER_SIZE >= uTotalMemory); //double check
+ memset(SCO_CVSD_BUFFER, 0, SCO_CVSD_BUFFER_SIZE);
+
+ btsco.pTX = (BT_SCO_TX*)pBuf;
+ pBuf += uTxMemSize;
+ btsco.pRX = (BT_SCO_RX*)pBuf;
+ pBuf += uRxMemSize;
+ btsco.pSpeechData = (kal_uint8 *)pBuf;
+ pBuf += uSpeechBufferSize;
+ btsco.pTempPacketBuf = (kal_uint8 *)pBuf;
+ pBuf += BT_SCO_PACKET_180;
+ btsco_InitialModule(BT_SCO_MOD_PCM_RINGBUF_TX, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_TX);
+ btsco_InitialModule(BT_SCO_MOD_MSBC_ENCODE, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_MSBC_ENCODE);
+ btsco_InitialModule(BT_SCO_MOD_PCM_RINGBUF_RX, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PCM_RINGBUF_RX);
+ btsco_InitialModule(BT_SCO_MOD_MSBC_DECODE, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_MSBC_DECODE);
+ btsco_InitialModule(BT_SCO_MOD_PLC_WB, pBuf);
+ pBuf += btsco_GetMemorySize_4ByteAlign(BT_SCO_MOD_PLC_WB);
+
+ MD_TRC_CVSD_BT_SCO_ALLOC_MSBC_MEMORY(uTotalMemory);
+}
+
+static void btsco_process_TX_MSBC()
+{
+ kal_uint32 iInByte1=0, iInByte2;
+ kal_int32 iOutByte=0, iInSample=0, index=0;
+ kal_uint8 *pSrcBuf;
+ while(1)
+ {
+ if(btsco_GetDataCount_TX() < MSBC_PCM_FRAME_BYTE)
+ {
+ break; // source pcm not enough one frame
+ }
+ if(btsco.pTX->iPacket_w - btsco.pTX->iPacket_r >= SCO_TX_PACKER_BUF_NUM)
+ {
+ break; // bitstream buffer full
+ }
+ btsco_GetReadBuffer_TX(&pSrcBuf, &iInByte1);
+ if(iInByte1 > MSBC_PCM_FRAME_BYTE)
+ {
+ memcpy(btsco.pTX->PcmBuf_64k, pSrcBuf, MSBC_PCM_FRAME_BYTE);
+ btsco_ReadDataDone_TX(MSBC_PCM_FRAME_BYTE);
+ }
+ else
+ {
+ memcpy(btsco.pTX->PcmBuf_64k, pSrcBuf, iInByte1);
+ btsco_ReadDataDone_TX(iInByte1);
+ btsco_GetReadBuffer_TX(&pSrcBuf, &iInByte2);
+ memcpy(btsco.pTX->PcmBuf_64k + iInByte1, pSrcBuf, MSBC_PCM_FRAME_BYTE-iInByte1);
+ btsco_ReadDataDone_TX(MSBC_PCM_FRAME_BYTE-iInByte1);
+ }
+ iInSample = MSBC_PCM_FRAME_BYTE >> 1;
+ iOutByte = MSBC_BTSTREAM_FRAME_BYTE;
+ index = btsco.pTX->iPacket_w & SCO_TX_PACKET_MASK;
+ MSBC_ENC_Process(btsco.pTX->pEncHandle, (short *)btsco.pTX->PcmBuf_64k, &iInSample, (char *)&btsco.pTX->PacketBuf[index][2], &iOutByte); //out 57 bytes
+ btsco.pTX->PacketBuf[index][0 ] = 0x01; //header
+ // btsco.pTX->PacketBuf[index][1 ] = btsco_MsbcHeader[index&0x3]; //header
+ btsco.pTX->PacketBuf[index][1 ] = 0xFF; //header
+ btsco.pTX->PacketBuf[index][59] = 0; //header
+ btsco.pTX->iPacket_w++;
+ }
+}
+
+static void btsco_process_RX_MSBC()
+{
+ kal_int32 index1=0, index2=0, index3=0, iInByte=0, iOutSample=0, status=-1, dwBtEv3HalfBad=0;
+ kal_uint32 iOutByte1=0, iOutByte2=0, i=0;
+ kal_uint8 *pDstBuf;
+ while(1)
+ {
+ if(btsco_GetFreeSpace_RX() < MSBC_PCM_FRAME_BYTE)
+ {
+ break; // pcm buffer full
+ }
+ if(btsco.pRX->iPacket_w - btsco.pRX->iPacket_r < 2 ) //use two block (2*30) each time
+ {
+ break; // bitstream not enough
+ }
+ index1 = btsco.pRX->iPacket_r & SCO_RX_PACKET_MASK;
+ index2 = (btsco.pRX->iPacket_r+1) & SCO_RX_PACKET_MASK;
+ index3 = (btsco.pRX->iPacket_r+2) & SCO_RX_PACKET_MASK;
+ btsco.pRX->iPacket_r++;
+ MD_TRC_MSBC_INFO(btsco.pRX->PacketBuf[index1][0],btsco.pRX->PacketBuf[index1][1], index1, btsco.pRX->PacketValid[index1]);
+ if( (btsco.pRX->PacketBuf[index1][0] == 0x01) && ((btsco.pRX->PacketBuf[index1][1]&0x0F) == 0x08) )//correct header
+ {
+ MD_TRC_L1AUDIO_BTSCO_MSBC_CORRECT_HEADER();
+ memcpy(btsco.pRX->PcmBuf_8k , &btsco.pRX->PacketBuf[index1][2], 28);
+ memcpy(btsco.pRX->PcmBuf_8k+28, &btsco.pRX->PacketBuf[index2][0], 29); // total 57
+ iInByte = MSBC_BTSTREAM_FRAME_BYTE;
+ iOutSample = MSBC_PCM_FRAME_BYTE >> 1;
+ status = MSBC_DEC_Process(btsco.pRX->pDecHandle, (char *)&btsco.pRX->PcmBuf_8k, &iInByte, (kal_int16*)btsco.pRX->PcmBuf_64k, &iOutSample);
+ MD_TRC_MSBC_STATUS(status);
+ btsco.pRX->iPacket_r++;
+ }
+ else if(btsco.pRX->PacketValid[index1]==1)
+ {//wrong header, but packet not lost, sync to next 30 byte block (should only happenes on packetsize 30)
+ MD_TRC_L1AUDIO_BTSCO_MSBC_WRONG_HEADER();
+ status = -1;
+ for(i = 0; i < 29; i++)
+ {
+ if((btsco.pRX->PacketBuf[index1][i] == 0x01) && ((btsco.pRX->PacketBuf[index1][i+1]&0x0F) == 0x08))//search the first packet (30 byte)
+ {
+ memcpy(btsco.pRX->PcmBuf_8k , &btsco.pRX->PacketBuf[index1][i+2], 28-i);
+ memcpy(btsco.pRX->PcmBuf_8k+28-i , &btsco.pRX->PacketBuf[index2][0], 30);
+ memcpy(btsco.pRX->PcmBuf_8k+58-i , &btsco.pRX->PacketBuf[index3][0], i-1);
+ iInByte = MSBC_BTSTREAM_FRAME_BYTE;
+ iOutSample = MSBC_PCM_FRAME_BYTE >> 1;
+ status = MSBC_DEC_Process(btsco.pRX->pDecHandle, (char *)&btsco.pRX->PcmBuf_8k, &iInByte, (kal_int16*)btsco.pRX->PcmBuf_64k, &iOutSample);
+ MD_TRC_MSBC_STATUS(status);
+ btsco.pRX->iPacket_r++;
+ break;
+ }
+ }
+ if(status == -1)
+ {
+ MD_TRC_L1AUDIO_BTSCO_MSBC_PACKET_NOT_FOUND();
+ }
+ }
+ else
+ {//packet lost at first frame, fail to decode
+ MD_TRC_L1AUDIO_BTSCO_MSBC_DATA_PACKET_NOT_FOUND();
+ status = -1;
+ btsco.pRX->iPacket_r++;
+ }
+ if(status==MSBC_BTSTREAM_FRAME_BYTE)
+ {
+ if(btsco.pRX->PacketValid[index1]==1 && btsco.pRX->PacketValid[index2]==0)
+ {
+ dwBtEv3HalfBad = 1;
+ }
+ else
+ {
+ dwBtEv3HalfBad = 0;
+ }
+ }
+ if(status==MSBC_BTSTREAM_FRAME_BYTE && btsco.pRX->PacketValid[index1]==1 && btsco.pRX->PacketValid[index2]==1)
+ {
+ g711plc_addtohistory_v2(btsco.pRX->pPLCHandle, (short *)btsco.pRX->PcmBuf_64k, 0);
+ }
+ else
+ {
+ g711plc_dofe_v2(btsco.pRX->pPLCHandle, (short *)btsco.pRX->PcmBuf_64k, dwBtEv3HalfBad);
+ }
+ btsco_GetWriteBuffer_RX(&pDstBuf, &iOutByte1);
+ if(iOutByte1 > MSBC_PCM_FRAME_BYTE)
+ {
+ memcpy(pDstBuf, btsco.pRX->PcmBuf_64k, MSBC_PCM_FRAME_BYTE);
+ btsco_WriteDataDone_RX(MSBC_PCM_FRAME_BYTE);
+ }
+ else
+ {
+ memcpy(pDstBuf, btsco.pRX->PcmBuf_64k, iOutByte1);
+ btsco_WriteDataDone_RX(iOutByte1);
+ btsco_GetWriteBuffer_RX(&pDstBuf, &iOutByte2);
+ memcpy(pDstBuf, btsco.pRX->PcmBuf_64k + iOutByte1, MSBC_PCM_FRAME_BYTE-iOutByte1);
+ btsco_WriteDataDone_RX(MSBC_PCM_FRAME_BYTE-iOutByte1);
+ }
+ }
+}
+
+#endif
+
+static void btsco_process_loopback()
+{
+ kal_uint8 *pInBuf, *pOutBuf;
+ kal_uint32 uInLen, uOutLen, i;
+ for(i=0;i<4;i++)
+ {
+ BT_SCO_GetReadBuffer_RX(&pInBuf, &uInLen);
+ BT_SCO_GetWriteBuffer_TX(&pOutBuf, &uOutLen);
+ MD_TRC_CVSD_BTSCO_PROCESS_LOOPBACK(uInLen, uOutLen);
+ uInLen &= 0xFFFFFFFE;
+ uOutLen &= 0xFFFFFFFE;
+ if(uInLen < uOutLen)
+ {
+ uOutLen = uInLen;
+ }
+ memcpy( pOutBuf, pInBuf, uOutLen );
+ BT_SCO_WriteDataDone_TX(uOutLen);
+ BT_SCO_ReadDataDone_RX(uOutLen);
+ }
+}
+
+static void btsco_process(void *pData)
+{
+ kal_take_enh_mutex( bt_mutex);
+ MD_TRC_L1AUDIO_BTSCO_PROCESS(btsco.uState, btsco.pRX, btsco.pTX);
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ if(btsco.uState != BT_SCO_STATE_RUNNING)
+ {
+ kal_give_spinlock(bt_lockId);
+ kal_give_enh_mutex( bt_mutex);
+ return;
+ }
+ kal_give_spinlock(bt_lockId);
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ btsco_process_RX_MSBC();
+ }
+ else
+#endif
+ {
+ btsco_process_RX_CVSD();
+ }
+ if(btsco.uMode == BT_SCO_MODE_LOOPBACK_WITH_CODEC)
+ {
+ btsco_process_loopback();
+ }
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ btsco_process_TX_MSBC();
+ }
+ else
+#endif
+ {
+ btsco_process_TX_CVSD();
+ }
+ kal_give_enh_mutex( bt_mutex);
+
+}
+
+static void BT_SCO_Start(BT_SCO_MODE uMode, kal_bool fIsWideBand)
+{
+ MD_TRC_BTSCO_CVSD_MSBC_SWITCH();
+ MD_TRC_L1AUDIO_BTSCO_START(btsco.uState, fIsWideBand);
+ kal_take_enh_mutex( bt_mutex);
+ if(fIsWideBand)
+ {
+#if defined(__MSBC_CODEC_SUPPORT__)
+ btsco_AllocMemory_MSBC();
+#else
+ ASSERT(0);
+#endif
+ }
+ else
+ {
+ btsco_AllocMemory_CVSD();
+ }
+ btsco.uMode = uMode;
+ btsco.fWideBand = fIsWideBand;
+ btsco.uMsbcHeaderIndex = 0;
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ btsco.uState = BT_SCO_STATE_RUNNING;
+ kal_give_spinlock(bt_lockId);
+#if defined(DELAY_UNMASK_INTERRUPT)
+ if(uCVSDGPT == 0)
+ {
+ uCVSDGPT = DclSGPT_Open( DCL_GPT_CB ,0 );
+ }
+#endif
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+ IRQUnmask(IRQ_BT_CVSD_CODE);
+#endif
+
+ kal_give_enh_mutex( bt_mutex );
+
+}
+
+static void BT_SCO_Stop()
+{
+ kal_take_enh_mutex( bt_mutex);
+ MD_TRC_L1AUDIO_BTSCO_STOP(btsco.uState);
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ ASSERT(btsco.uState != BT_SCO_STATE_IDLE);
+ btsco.uState = BT_SCO_STATE_ENDING;
+ kal_give_spinlock(bt_lockId);
+ kal_sleep_task( AUD_1TICK(10) ); //flush zero (22.5*2 msec)
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ btsco.uState = BT_SCO_STATE_IDLE;
+ // memset(&btsco, 0, sizeof(btsco));
+ kal_give_spinlock(bt_lockId);
+
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+ IRQMask(IRQ_BT_CVSD_CODE);
+#endif
+ kal_give_enh_mutex( bt_mutex );
+}
+
+void BT_SCO_LISR(void)
+{
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+
+ IRQMask(IRQ_BT_CVSD_CODE);
+ L1Audio_TrigD2CHisr(BT_CVSD_HISR_MAGIC_NO);
+
+#endif
+}
+
+void BT_SCO_Init()
+{
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+ IRQMask(IRQ_BT_CVSD_CODE);
+ // [Jade] different from k2 || Denali
+ L1Audio_HookHisrHandler( BT_CVSD_HISR_MAGIC_NO, btsco_hisr, NULL );
+ IRQMask(IRQ_BT_CVSD_CODE);
+ bt_lockId = kal_create_spinlock("BT_LOCK");
+ bt_mutex= kal_create_enh_mutex( "BT_MUTEX" );
+
+ btsco.uAudId = L1Audio_GetAudioID();
+ btsco.isCodecAlign=true;
+ L1Audio_SetEventHandler( btsco.uAudId, btsco_process );
+#endif
+}
+
+static void BT_SCO_Speech_TX_HISR()
+{
+
+ kal_uint8 *pDst, *pSrc;
+ kal_uint32 uOutByte, uFreeSpace, uRemainByte, uSpeechFrameSize;
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+
+ if(btsco.uState != BT_SCO_STATE_RUNNING)
+ {
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ uSpeechFrameSize = WB_SPEECH_FRAME_SIZE;
+ }
+ else
+#endif
+ {
+ uSpeechFrameSize = NB_SPEECH_FRAME_SIZE;
+ }
+ BT_SCO_GetWriteBuffer_TX(&pDst, &uOutByte);
+ uFreeSpace = BT_SCO_GetFreeSpace_TX();
+ MD_TRC_L1AUDIO_BTSCO_AP_SPEECH_TX_DATA(uOutByte, uFreeSpace);
+ uOutByte = uOutByte & 0xFFFFFFFE;
+ uFreeSpace = uFreeSpace & 0xFFFFFFFE;
+ if(uOutByte >= uSpeechFrameSize)
+ {
+ pSrc = pDst;
+ }
+ else if(uFreeSpace >= uSpeechFrameSize)
+ {
+ pSrc = btsco.pSpeechData;
+ }
+ else
+ {
+ MD_TRC_L1AUDIO_BTSCO_AP_SPEECH_TX_OF(uFreeSpace);
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ DACA_GetFromSD((kal_uint16*)pSrc);
+ if(uOutByte >= uSpeechFrameSize)
+ {
+ BT_SCO_WriteDataDone_TX(uSpeechFrameSize);
+ }
+ else
+ {//put to temp buffer first
+ memcpy(pDst, pSrc, uOutByte);
+ BT_SCO_WriteDataDone_TX(uOutByte);
+ pSrc += uOutByte;
+ uRemainByte = uSpeechFrameSize - uOutByte;
+ BT_SCO_GetWriteBuffer_TX(&pDst, &uOutByte);
+ uOutByte = uOutByte & 0xFFFFFFFE;
+ ASSERT(uOutByte>=uRemainByte);
+ memcpy(pDst, pSrc, uRemainByte);
+ BT_SCO_WriteDataDone_TX(uRemainByte);
+ }
+ kal_give_spinlock(bt_lockId);
+
+}
+
+static void BT_SCO_Speech_RX_HISR()
+{
+ kal_uint8 *pSrc, *pDst;
+ kal_uint32 uInByte, uDataCount, uRemainByte, uDirectCopy=0, uSpeechFrameSize=0;
+ kal_take_spinlock(bt_lockId, KAL_INFINITE_WAIT);
+ if(btsco.uState != BT_SCO_STATE_RUNNING)
+ {
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ uSpeechFrameSize = WB_SPEECH_FRAME_SIZE;
+ }
+ else
+#endif
+ {
+ uSpeechFrameSize = NB_SPEECH_FRAME_SIZE;
+ }
+ BT_SCO_GetReadBuffer_RX(&pSrc, &uInByte);
+ uDataCount = BT_SCO_GetDataCount_RX();
+ MD_TRC_L1AUDIO_BTSCO_AP_SPEECH_RX_DATA(uInByte, uDataCount);
+ uInByte = uInByte & 0xFFFFFFFE;
+ uDataCount = uDataCount & 0xFFFFFFFE;
+ if(uInByte >= uSpeechFrameSize)
+ {
+ uDirectCopy = 1;
+ }
+ else if(uDataCount >= uSpeechFrameSize)
+ {
+ pDst = btsco.pSpeechData;
+ memcpy(pDst, pSrc, uInByte);
+ pDst += uInByte;
+ uRemainByte = uSpeechFrameSize - uInByte;
+ BT_SCO_ReadDataDone_RX(uInByte);
+ BT_SCO_GetReadBuffer_RX(&pSrc, &uInByte);
+ ASSERT(uInByte>=uRemainByte);
+ memcpy(pDst, pSrc, uRemainByte);
+ BT_SCO_ReadDataDone_RX(uRemainByte);
+ pSrc = btsco.pSpeechData;
+ }
+ else
+ {
+ MD_TRC_L1AUDIO_BTSCO_AP_SPEECH_RX_UF(uDataCount);
+ DACA_FillSE(0);
+ kal_give_spinlock(bt_lockId);
+ return;
+ }
+ DACA_PutToSE((const kal_uint16*)pSrc);
+ if(uDirectCopy)
+ {
+ BT_SCO_ReadDataDone_RX(uSpeechFrameSize);
+ }
+ kal_give_spinlock(bt_lockId);
+}
+
+void BT_SCO_SPEECH_ON(kal_bool fWideBand)
+{
+ DACA_APP_TYPE uType = DACA_APP_TYPE_ACTIVE_UL_DL_NB;
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+ MD_TRC_CVSD_BT_SCO_SPEECH_ON(btsco.uState, fWideBand);
+ //kal_trace( TRACE_GROUP_SCO, L1AUDIO_BTSCO_SP_ON, btsco.uState);
+ ASSERT(btsco.uState == BT_SCO_STATE_IDLE);
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(fWideBand)
+ {
+ uType = DACA_APP_TYPE_ACTIVE_UL_DL_WB;
+ }
+#endif
+ SPLog_LogDbgInfo(MSG_ID_AUDIO_LOGGING_BT_TX, 0, (void *)fWideBand);
+ SPLog_LogDbgInfo(MSG_ID_AUDIO_LOGGING_BT_RX, 0, (void *)fWideBand);
+ DACA_Start(BT_SCO_Speech_TX_HISR, BT_SCO_Speech_RX_HISR, uType);
+ BT_SCO_Start( BT_SCO_MODE_SPEECH, fWideBand);
+#endif
+}
+
+void BT_SCO_SPEECH_OFF()
+{
+ DACA_APP_TYPE uType = DACA_APP_TYPE_ACTIVE_UL_DL_NB;
+#if !defined(DISABLE_BTCVSD_FOR_CHIPBACK_BOOTUP)
+#if defined(__MSBC_CODEC_SUPPORT__)
+ if(btsco.fWideBand)
+ {
+ uType = DACA_APP_TYPE_ACTIVE_UL_DL_WB;
+ }
+#endif
+ MD_TRC_CVSD_BT_SCO_SPEECH_OFF(btsco.uState);
+ SPLog_LogDbgInfo(MSG_ID_AUDIO_LOGGING_BT_TX, 2, (void *)btsco.fWideBand);
+ SPLog_LogDbgInfo(MSG_ID_AUDIO_LOGGING_BT_RX, 2, (void *)btsco.fWideBand);
+ //kal_trace( TRACE_GROUP_SCO, L1AUDIO_BTSCO_SP_OFF, btsco.uState);
+ ASSERT(btsco.uState != BT_SCO_STATE_IDLE);
+ BT_SCO_Stop();
+ DACA_Stop(uType);
+#endif
+}
+
+kal_bool BT_SCO_IS_SPEECH_ON()
+{
+ if(btsco.uState == BT_SCO_STATE_IDLE)
+ {
+ return KAL_FALSE;
+ }
+ return KAL_TRUE;
+}
+
+void BT_SCO_Loopback_ON(kal_bool fDisableCodec, kal_bool fWideBand)
+{
+ MD_TRC_CVSD_BT_SCO_LOOPBACK_ON(fDisableCodec, btsco.uState);
+ ASSERT(btsco.uState == BT_SCO_STATE_IDLE);
+ if(fDisableCodec)
+ {
+ BT_SCO_Start( BT_SCO_MODE_LOOPBACK_WITHOUT_CODEC, fWideBand );
+ }
+ else
+ {
+ BT_SCO_Start( BT_SCO_MODE_LOOPBACK_WITH_CODEC, fWideBand );
+ }
+}
+
+void BT_SCO_Loopback_OFF()
+{
+ MD_TRC_CVSD_BT_SCO_LOOPBACK_OFF(btsco.uState);
+ ASSERT(btsco.uState != BT_SCO_STATE_IDLE);
+ BT_SCO_Stop();
+}
+
+#endif //__CVSD_CODEC_SUPPORT__
+
diff --git a/mcu/driver/audio/src/v1/ctm_drv.c b/mcu/driver/audio/src/v1/ctm_drv.c
new file mode 100644
index 0000000..bc2ba7a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/ctm_drv.c
@@ -0,0 +1,1914 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * l1ctm.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * L1Ctm interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifdef __CTM_SUPPORT__
+
+int dsp_tch_bfi; // temp solution
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "l1audio.h"
+#include "speech_def.h"
+#include "pcm4way.h"
+#include "l1sp_trc.h"
+#include "am.h"
+#include "ctm_drv.h"
+#include "ctm_params.h"
+#include "ctm_modem.h"
+#include "afe_def.h"
+
+#include "sal_def.h"
+#include "sal_exp.h"
+
+#include "bli_exp.h"
+#include "sp_enhance.h"
+
+#include "sp_drv.h"
+#include "audio_msgid.h"
+#include "drv_sap.h"
+#include "audio_ringbuf.h" // "audio_def.h" // for ring buffer
+#include "media.h"
+#include "spc_io.h"
+
+// Catcher trace
+/*#define L1CTM_TRACE_FUNC(X) kal_trace(TRACE_FUNC, X)
+*/
+/*#define L1CTM_TRACE_STATE(X) kal_trace(TRACE_STATE, X)
+*/
+/*#define L1CTM_TRACE_INFO(X,Y) kal_trace(TRACE_INFO, X, Y)
+*/
+
+//4g TTY
+#define TTY_QUEUE_SIZE 512
+#define NUM_DELAY_FRAME 10
+#define NUM_UL_SEND_FRAME 10
+
+int ctm_hco_vco_state = 0; // 0 - disable; 1 - HCO enable; 2 - VCO enable;
+
+__attribute__((aligned(4)))
+static uint16 zero_dl_pcm[160] =
+{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+
+
+#define MORE_ENQUIRY 8
+static uint32 more_enquiry_times;
+static int16 cprm_debug_flag = 0;
+
+#ifdef __SMART_PHONE_MODEM__
+
+#define UL_IN_PCM_RECORD_MD
+#define UL_OUT_PCM_RECORD_MD
+#define DL_IN_PCM_RECORD_MD
+#define DL_OUT_PCM_RECORD_MD
+
+#endif // __SMART_PHONE_MODEM__
+
+
+#define UL_TTY_BUF_LEN 64
+#define UL_CTM_BUF_LEN 256
+#define DL_TTY_BUF_LEN 1024
+#define DL_CTM_BUF_LEN 256
+
+#define PCM_FIFO_LEN 2 // could be 1 ~ N
+#define CTM_SWB_BUF_LEN 640 // 32k*20ms = 640
+#define CTM_WB_BUF_LEN 320 // 16k*20ms = 320
+#define CTM_NB_BUF_LEN 160 // 8k*20ms = 160
+
+#define BLI_SRC_BUFFER_SIZE 2184 // fixed value
+typedef struct{
+ void (*callback_handler)(L1Ctm_Event event, void *data);
+#if defined(__SMART_PHONE_MODEM__)
+ void (*debugCallback)(uint16 pos, uint16 *buffer, uint16 len, bool isDone);
+#endif
+ // speech-channel PCM buffer
+ uint16 ul_pcm_fifo[PCM_FIFO_LEN][CTM_NB_BUF_LEN]; // input buffer size = 160
+ uint16 dl_pcm_fifo[PCM_FIFO_LEN][CTM_NB_BUF_LEN];
+ uint16 ul_pcm_input[PCM_FIFO_LEN][CTM_SWB_BUF_LEN]; // input buffer size = 640
+ uint16 dl_pcm_input[PCM_FIFO_LEN][CTM_SWB_BUF_LEN];
+
+ uint16 ul_pcm_input2[PCM_FIFO_LEN][CTM_SWB_BUF_LEN]; // input buffer size = 640
+ uint16 ul_pcm_output2[PCM_FIFO_LEN][CTM_SWB_BUF_LEN]; // output buffer size = 640
+
+ uint16 ul_pcm_output[PCM_FIFO_LEN][CTM_NB_BUF_LEN]; //160
+ uint16 ul_pcm_output_wb[PCM_FIFO_LEN][CTM_WB_BUF_LEN]; //320
+ uint16 ul_pcm_output_swb[PCM_FIFO_LEN][CTM_SWB_BUF_LEN]; //640
+
+ uint16 dl_pcm_output[PCM_FIFO_LEN][CTM_NB_BUF_LEN]; //160
+ uint16 dl_pcm_output_wb[PCM_FIFO_LEN][CTM_WB_BUF_LEN]; //320
+ uint16 dl_pcm_output_swb[PCM_FIFO_LEN][CTM_SWB_BUF_LEN]; //640
+
+ uint16 ul_pcm_input_len[PCM_FIFO_LEN];
+ uint16 dl_pcm_input_len[PCM_FIFO_LEN];
+
+ uint8 internal_buf_ul_in[2184]; // internal buffer for src
+ uint8 internal_buf_ul_out[2184]; // internal buffer for src
+ uint8 internal_buf_dl_in[2184]; // internal buffer for src
+ uint8 internal_buf_dl_out[2184]; // internal buffer for src
+
+ uint8 internal_buf_ul_in2[2184]; // internal buffer for src
+ uint8 internal_buf_ul_out2[2184]; // internal buffer for src
+ uint8 internal_buf_dl_in2[2184]; // internal buffer for src
+ uint8 internal_buf_dl_out2[2184]; // internal buffer for src
+
+ BLI_HANDLE * ul_downsample_16_8;
+ BLI_HANDLE * dl_downsample_16_8;
+ BLI_HANDLE * ul_downsample_32_8;
+ BLI_HANDLE * dl_downsample_32_8;
+ BLI_HANDLE * ul_upsample_8_16;
+ BLI_HANDLE * dl_upsample_8_16;
+ BLI_HANDLE * ul_upsample_8_32;
+ BLI_HANDLE * dl_upsample_8_32;
+
+
+ // text buffer
+ uint8 ul_tty_buf[UL_TTY_BUF_LEN];
+ uint8 ul_ctm_buf[UL_CTM_BUF_LEN];
+ uint8 dl_tty_buf[DL_TTY_BUF_LEN];
+ uint8 dl_ctm_buf[DL_CTM_BUF_LEN];
+ // buffer read write pointer
+ uint16 ul_tty_buf_read; // buf_read == buf_write , means buffer empty
+ uint16 ul_tty_buf_write; // buffer could be filled at most (BUF_LEN - 1) data
+ uint16 ul_ctm_buf_read;
+ uint16 ul_ctm_buf_write;
+ uint16 dl_tty_buf_read;
+ uint16 dl_tty_buf_write;
+ uint16 dl_ctm_buf_read;
+ uint16 dl_ctm_buf_write;
+ // control relative
+ uint16 next_to_process;
+ uint16 pcm_fifo_write;
+ uint16 pcm_fifo_read;
+ uint16 aud_id;
+ uint16 FLAGS;
+ uint16 ul_mute_flags;
+ uint16 dl_mute_flags;
+ uint8 bfi_info[PCM_FIFO_LEN];
+ uint8 l1d_bfi_info[PCM_FIFO_LEN];
+ uint8 interface;
+ uint8 state;
+ uint8 next_ack_timeout;
+ int8 enquiry_count;
+ uint8 enquiry_timeout1;
+ uint8 enquiry_timeout2;
+ uint8 transition_mute;
+ uint8 debug_function;
+
+ // 2g/3g TTY variables
+ bool dl_isTTY;
+ bool ul_isTTY;
+ bool ul_isSending;
+ uint16 ul_send_count;
+
+ // 4g TTY variables
+ uint16 dl_put_count;
+
+ kal_spinlockid lockId;
+ bool skip_hisr;
+ bool stop;
+
+}L1Ctm_Module;
+
+static L1Ctm_Module *l1ctm;
+static RTT_Module rtt;
+
+//extern UNSIGNED TMD_System_Clock;
+
+
+//***** UTF8 special character
+#define ENQUIRY_CHAR 0x5
+#define IDLE_CHAR 0x16
+#define NON_UTF8_CHAR 0xFF
+#define NO_CHAR 0xFF
+
+//***** LCF : L1CTM Control Flag
+// CTM Negotiation relative
+#define LCF_NEGOTIATION_REQ 0x1
+#define LCF_NEGOTIATION 0x2
+#define LCF_SEND_ENQUIRY 0x4
+#define LCF_SEND_ACK 0x8
+#define LCF_FAR_END_DETECTED 0x10
+// speech-channel output relative
+#define LCF_UL_CTM_TRANSMITTING 0x20
+#define LCF_UL_MUTE 0x40
+#define LCF_DL_CTM_RECEIVING 0x80
+#define LCF_DL_BAUDOT_TRANSMITTING 0x100
+#define LCF_DL_MUTE 0x200
+#define LCF_ACKING 0x400
+#define LCF_DL_ACKING 0x800
+
+//***** time-out setting
+#define ENQUIRY_TIMEOUT1 21 // 20 (400 ms) + 1
+#define ENQUIRY_TIMEOUT2 67 // 66 (1320 ms) + 1
+#define NEXT_ACK_TIMEOUT 26 // 25 (500 ms) + 1
+#define DL_TRANSITION_MUTE_TIMEOUT 2 // 40 ms
+
+//***** L1CTM state
+#define L1CTM_READY_STATE 0xAB
+#define L1CTM_CONNECTED_STATE 0xCD
+
+//***** text buffer operation used in l1ctm_in_task
+
+#define UL_TTY_BUF_CHAR_READY() (l1ctm->ul_tty_buf_read != l1ctm->ul_tty_buf_write)
+
+#define UL_TTY_BUF_GET_CHAR(tty_code) { \
+ tty_code = l1ctm->ul_tty_buf[l1ctm->ul_tty_buf_read ++]; \
+ l1ctm->ul_tty_buf_read &= (UL_TTY_BUF_LEN-1); \
+ }
+
+#define UL_TTY_BUF_PUT_CHAR(tty_code) \
+ { \
+ l1ctm->ul_tty_buf[l1ctm->ul_tty_buf_write ++] = tty_code; \
+ l1ctm->ul_tty_buf_write &= (UL_TTY_BUF_LEN-1); \
+ if(l1ctm->ul_tty_buf_write == l1ctm->ul_tty_buf_read) \
+ { \
+ l1ctm->ul_tty_buf_read ++; \
+ l1ctm->ul_tty_buf_read &= (UL_TTY_BUF_LEN-1); \
+ } \
+ }
+
+
+#define DL_TTY_BUF_CHAR_READY() (l1ctm->dl_tty_buf_read != l1ctm->dl_tty_buf_write)
+
+#define DL_TTY_BUF_GET_CHAR(tty_code) { \
+ tty_code = l1ctm->dl_tty_buf[l1ctm->dl_tty_buf_read++]; \
+ l1ctm->dl_tty_buf_read &= (DL_TTY_BUF_LEN-1); \
+ }
+
+#define DL_TTY_BUF_PUT_CHAR(tty_code) \
+ { \
+ l1ctm->dl_tty_buf[l1ctm->dl_tty_buf_write ++] = tty_code; \
+ l1ctm->dl_tty_buf_write &= (DL_TTY_BUF_LEN-1); \
+ if(l1ctm->dl_tty_buf_write == l1ctm->dl_tty_buf_read) \
+ { \
+ l1ctm->dl_tty_buf_read ++; \
+ l1ctm->dl_tty_buf_read &= (DL_TTY_BUF_LEN-1); \
+ } \
+ }
+
+
+#define UL_CTM_BUF_CHAR_READY() (l1ctm->ul_ctm_buf_read != l1ctm->ul_ctm_buf_write)
+
+#define UL_CTM_BUF_GET_CHAR(ctm_code) { \
+ ctm_code = l1ctm->ul_ctm_buf[l1ctm->ul_ctm_buf_read++]; \
+ l1ctm->ul_ctm_buf_read &= (UL_CTM_BUF_LEN - 1); \
+ }
+
+
+#define DL_CTM_BUF_PUT_CHAR(ctm_code) { \
+ l1ctm->dl_ctm_buf[l1ctm->dl_ctm_buf_write++] = ctm_code; \
+ l1ctm->dl_ctm_buf_write &= (DL_CTM_BUF_LEN - 1); \
+ ASSERT(l1ctm->dl_ctm_buf_write != l1ctm->dl_ctm_buf_read);\
+ }
+
+/*==============================================================================*/
+
+/*==== begin of 4G TTY Queue====*/
+
+RINGBUFFER_T(kal_uint8, TTY_QUEUE_SIZE) ul_tty_queue;
+RINGBUFFER_T(kal_uint8, TTY_QUEUE_SIZE) dl_tty_queue;
+
+RINGBUFFER_T(kal_uint8, TTY_QUEUE_SIZE) ul_rtt_queue[8]; // cid: 0~7
+RINGBUFFER_T(kal_uint8, TTY_QUEUE_SIZE) dl_rtt_queue[8]; // cid: 0~7
+
+void ctm_init(void)
+{
+ int i;
+
+ for(i = 0; i < 8; i++){
+ RB_INIT(ul_rtt_queue[i]);
+ RB_INIT(dl_rtt_queue[i]);
+ }
+
+ rtt.isRttOn = false;
+}
+
+
+/* TTY Queue*/
+
+void TTY_LTE_PSR_UL_Queue_Init(void)
+{
+ RB_INIT(ul_tty_queue);
+}
+
+kal_uint8 TTY_LTE_PSR_UL_Get(void)
+{
+ kal_uint8 tty_char;
+ RB_GET(ul_tty_queue, tty_char);
+
+ MD_TRC_L1CTM_TTY_LTE_UL_GET(tty_char);
+
+ return tty_char;
+}
+
+kal_uint16 TTY_LTE_PSR_UL_GetChar(kal_uint8 call_id, kal_uint8 *buf){
+ uint8 ch;
+ kal_prompt_trace(MOD_L1SP, "[TTY_LTE_PSR_UL_GetChar] Enter");
+ if(getRttStatus()==true){
+ if(!RB_EMPTY(ul_rtt_queue[call_id])){
+ RB_GET(ul_rtt_queue[call_id], ch);
+ *buf = ch;
+ kal_prompt_trace(MOD_L1SP, "[TTY_LTE_PSR_UL_GetChar] ch = %x", ch);
+ return 1;
+ }
+ }
+ else{
+ if(!TTY_LTE_PSR_UL_isEmpty()){
+ *buf = TTY_LTE_PSR_UL_Get();
+ kal_prompt_trace(MOD_L1SP, "[TTY_LTE_PSR_UL_GetChar] ch = %x", *buf);
+ return 1;
+ }
+ }
+ return 0;
+
+}
+
+
+kal_uint16 TTY_LTE_PSR_UL_GetString(kal_uint8 call_id, kal_uint8 *buf, kal_uint16 *length)
+{
+ return 0;
+}
+
+
+void TTY_LTE_PSR_UL_Put(kal_uint8 tty_char)
+{
+ RB_PUT(ul_tty_queue, tty_char);
+ MD_TRC_L1CTM_TTY_LTE_UL_PUT(tty_char);
+}
+
+kal_bool TTY_LTE_PSR_UL_isEmpty(void)
+{
+ return RB_EMPTY(ul_tty_queue);
+}
+
+kal_bool TTY_LTE_PSR_UL_isFull(void)
+{
+ return RB_FULL(ul_tty_queue);
+}
+
+kal_uint16 TTY_LTE_PSR_UL_Queue_Size(void)
+{
+ kal_uint16 size = RB_COUNT(ul_tty_queue);
+ MD_TRC_L1CTM_TTY_LTE_UL_QUEUE_SIZE(size);
+ return size;
+}
+
+
+void TTY_LTE_PSR_DL_Queue_Init(void)
+{
+ RB_INIT(dl_tty_queue);
+}
+
+void TTY_LTE_PSR_DL_Put(kal_uint8 tty_char)
+{
+ RB_PUT(dl_tty_queue, tty_char);
+ MD_TRC_L1CTM_TTY_LTE_DL_PUT(tty_char);
+
+}
+
+void TTY_LTE_PSR_DL_PutString(kal_uint8 call_id, kal_uint8 string[256], kal_uint16 length)
+{
+ int i;
+
+ if(getRttStatus()==true){
+ for(i = 0; i < length; i++){
+ if(!RB_FULL(dl_rtt_queue[call_id])){
+ RB_PUT(dl_rtt_queue[call_id], string[i]);
+
+ kal_prompt_trace(MOD_L1SP, "[TTY_LTE_PSR_DL_PutString] cid = %d, ch = %x", call_id, string[i]);
+ }
+ else{
+ break;
+ }
+ }
+
+ SP_L4C_SendERTTSTR(call_id);
+ }
+ else{
+ for(i = 0; i < length; i++){
+ if(!TTY_LTE_PSR_DL_isFull()){
+ TTY_LTE_PSR_DL_Put(string[i]);
+ }
+ else{
+ break;
+ }
+ }
+ }
+ kal_prompt_trace(MOD_L1SP, "[TTY_LTE_PSR_DL_PutString] call_id= %d, length = %d", call_id, length);
+}
+
+
+kal_uint8 TTY_LTE_PSR_DL_Get()
+{
+ kal_uint8 tty_char;
+ RB_GET(dl_tty_queue, tty_char);
+
+ MD_TRC_L1CTM_TTY_LTE_DL_GET(tty_char);
+
+ return tty_char;
+}
+
+kal_uint16 TTY_LTE_PSR_DL_Queue_Size(void)
+{
+ kal_uint16 size = RB_COUNT(dl_tty_queue);
+ MD_TRC_L1CTM_TTY_LTE_DL_QUEUE_SIZE(size);
+ return size;
+
+}
+
+kal_bool TTY_LTE_PSR_DL_isEmpty(void)
+{
+ return RB_EMPTY(dl_tty_queue);
+}
+
+kal_bool TTY_LTE_PSR_DL_isFull(void)
+{
+ return RB_FULL(dl_tty_queue);
+}
+
+/*=====end of 4G TTY queue=====*/
+
+
+void SP_L4C_SetERTTSTR(kal_uint8 call_id, kal_uint8 string[256], kal_uint16 length){
+ int i;
+ for(i = 0; i < length; i++){
+ if(!RB_FULL(ul_rtt_queue[call_id])){
+ RB_PUT(ul_rtt_queue[call_id], string[i]);
+ kal_prompt_trace(MOD_L1SP, "[SP_L4C_SetERTTSTR] call_id = %d, char = %x ", call_id, string[i]);
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "[SP_L4C_SetERTTSTR] call_id = %d, length = %d ", call_id, length);
+
+}
+
+void SP_L4C_SendERTTSTR(uint8 call_id){
+
+ ilm_L4C_ERTT_STRING_t *local_para;
+
+ int i;
+ uint8 ch;
+ uint16 len = RB_COUNT(dl_rtt_queue[call_id]);
+
+ local_para = (ilm_L4C_ERTT_STRING_t *) construct_local_para( sizeof(ilm_L4C_ERTT_STRING_t), TD_CTRL);
+ local_para -> call_id = call_id;
+ local_para -> length = len;
+
+ for(i = 0; i < len; i++){
+ if(!RB_EMPTY(dl_rtt_queue[call_id])){
+ RB_GET(dl_rtt_queue[call_id], ch);
+ local_para -> string[i] = ch;
+
+ kal_prompt_trace(MOD_L1SP, "[SP_L4C_SendERTTSTR] cid = %d, ch = %x", call_id, ch);
+ }
+
+ }
+
+ msg_send6(MOD_MED, MOD_L4C, AUDIO_SAP, MSG_ID_AUDIO_L4C_ERTTSTR, (local_para_struct *)local_para, NULL);
+
+ kal_prompt_trace(MOD_L1SP, "[SP_L4C_SendERTTSTR] cid = %d, length = %d", call_id, local_para -> length);
+
+}
+
+
+void l1ctm_init(void)
+{
+ l1ctm = (L1Ctm_Module*) 0;
+}
+
+
+#define PCM_BFI_SHIFT 1
+void l1ctm_in_hisr()
+{
+ MD_TRC_L1CTM_IN_HISR_ENTER();
+
+ if(l1ctm->skip_hisr)
+ return;
+ uint16 buf_idx, bfi_data, bfi_rec, bfi_store_idx;
+
+ buf_idx = l1ctm->pcm_fifo_read;
+ if(buf_idx >= PCM_FIFO_LEN)
+ buf_idx -= PCM_FIFO_LEN;
+
+ bfi_store_idx = buf_idx + PCM_BFI_SHIFT;
+ if(bfi_store_idx >= PCM_FIFO_LEN)
+ bfi_store_idx -= PCM_FIFO_LEN;
+
+
+ if(l1ctm->pcm_fifo_read == l1ctm->next_to_process){
+ MD_TRC_L1CTM_BUF_OVFLOW();
+ if(l1ctm->stop){
+ l1ctm->skip_hisr = true;
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_CONTROL_CTM_CLOSE, 0, 0, SPC_MSG_FROM_AUDHISR);
+ }
+ return;
+ }
+
+ // uplink-path
+ if(l1ctm->ul_mute_flags & (1 << l1ctm->pcm_fifo_read))
+ PCM4WAY_FillSE(0);
+ else
+ {
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_PNW_BUF_M2D_UL1);
+ PCM4WAY_PutToSE2((const uint16*)(l1ctm->ul_pcm_output2[buf_idx]));
+
+ if(CTM_NB_BUF_LEN == bufLen){
+ PCM4WAY_PutToSE((const uint16*)(l1ctm->ul_pcm_output[buf_idx]));
+ }
+ else if(CTM_WB_BUF_LEN == bufLen){
+ PCM4WAY_PutToSE((const uint16*)(l1ctm->ul_pcm_output_wb[buf_idx]));
+ }
+ else{
+ PCM4WAY_PutToSE((const uint16*)(l1ctm->ul_pcm_output_swb[buf_idx]));
+ }
+ }
+
+ l1ctm->ul_pcm_input_len[buf_idx] = PCM4WAY_GetFromMic((uint16*)(l1ctm->ul_pcm_input[buf_idx]));
+ PCM4WAY_GetFromMic2((uint16*)(l1ctm->ul_pcm_input2[buf_idx]));
+ kal_prompt_trace(MOD_L1SP, "l1ctm->ul_pcm_input_len[buf_idx] = %d", l1ctm->ul_pcm_input_len[buf_idx]);
+
+ // downlink-path
+ if(l1ctm->dl_mute_flags & (1 << l1ctm->pcm_fifo_read))
+ PCM4WAY_FillSpk(0);
+ else{
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_PNW_BUF_M2D_DL1);
+ if(CTM_NB_BUF_LEN == bufLen){
+ PCM4WAY_PutToSpk((const uint16*)(l1ctm->dl_pcm_output[buf_idx]));
+ }
+ else if(CTM_WB_BUF_LEN == bufLen){
+ PCM4WAY_PutToSpk((const uint16*)(l1ctm->dl_pcm_output_wb[buf_idx]));
+ }
+ else{
+ PCM4WAY_PutToSpk((const uint16*)(l1ctm->dl_pcm_output_swb[buf_idx]));
+ }
+
+ }
+
+ l1ctm->dl_pcm_input_len[buf_idx] = PCM4WAY_GetFromSD((uint16*)(l1ctm->dl_pcm_input[buf_idx]));
+
+
+ bfi_data = SAL_CTM_GetValue(SAL_CTM_VALUE_TYPE_FACCH_REPORT);
+
+ bfi_rec = (bfi_data&0x1)|(((bfi_data&0x10)>>4)<<1)|(((bfi_data&0x100)>>8)<<2)|(((bfi_data&0x1000)>>12)<<3)|(((bfi_data&0x4000)>>14)<<4);
+
+
+ l1ctm->bfi_info[buf_idx] = bfi_rec;
+
+ if(dsp_tch_bfi > 0)
+ l1ctm->l1d_bfi_info[bfi_store_idx] = 1;
+ else
+ l1ctm->l1d_bfi_info[bfi_store_idx] = 0;
+
+ l1ctm->pcm_fifo_write++;
+ if(l1ctm->pcm_fifo_write == 2 * PCM_FIFO_LEN)
+ l1ctm->pcm_fifo_write = 0;
+ l1ctm->pcm_fifo_read++;
+ if(l1ctm->pcm_fifo_read == 2 * PCM_FIFO_LEN)
+ l1ctm->pcm_fifo_read = 0;
+
+ if(l1ctm->stop){
+ l1ctm->skip_hisr = true;
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_CONTROL_CTM_CLOSE, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+ }
+ else{
+ L1Audio_SetEvent(l1ctm->aud_id, (void*)0); // involve L1Audio task to run CTM modem
+ }
+ MD_TRC_L1CTM_IN_HISR_LEAVE();
+}
+
+//uint8 A[20]={'A','B', 'C','D','E','F','G','H','I','J','1','2','3','4','5','6','7','8','9','0'};
+//uint8 B[20]={'1','2', '3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0'};
+int ind = 0;
+int indA = 0;
+int indB = 0;
+int wc = 0;
+int sz = 0;
+
+void l1ctm_in_task_2g_3g()
+{
+ uint16 l1ctmFlags, ctmFlags, interface, buf_idx;
+
+
+ uint32 ul_ds_inLen, ul_ds_outLen, dl_ds_inLen, dl_ds_outLen;
+ uint32 ul_us_inLen, ul_us_outLen, dl_us_inLen, dl_us_outLen;
+
+ uint16 *p_ul_ds_inBuf, *p_ul_ds_outBuf;
+ uint16 *p_dl_ds_inBuf, *p_dl_ds_outBuf;
+
+ uint16 *p_ul_us_inBuf, *p_ul_us_outBuf;
+ uint16 *p_dl_us_inBuf, *p_dl_us_outBuf;
+ uint8 utf8_code;
+ kal_bool bfi_flag;
+
+
+ if(l1ctm == (L1Ctm_Module*) 0)
+ return;
+
+ while(l1ctm->next_to_process != l1ctm->pcm_fifo_write)
+ {
+ buf_idx = l1ctm->next_to_process;
+ if(buf_idx >= PCM_FIFO_LEN)
+ buf_idx -= PCM_FIFO_LEN;
+
+ /******************************************************
+ * ul_pcm_input -> ul_pcm_fifo -> ul_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [CTM] *
+ ******************************************************/
+
+
+ /*[CTM blisrc] UL downsample start*/
+
+
+
+ p_ul_ds_inBuf = l1ctm->ul_pcm_input[buf_idx];
+ p_ul_ds_outBuf = l1ctm->ul_pcm_fifo[buf_idx];
+
+ if(CTM_WB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ul_ds_inLen = CTM_WB_BUF_LEN << 1;
+ ul_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->ul_downsample_16_8, (short *)p_ul_ds_inBuf, &ul_ds_inLen, (short *)p_ul_ds_outBuf, &ul_ds_outLen);
+ }
+ else if(CTM_SWB_BUF_LEN ==l1ctm->ul_pcm_input_len[buf_idx]){
+ ul_ds_inLen = CTM_SWB_BUF_LEN << 1;
+ ul_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->ul_downsample_32_8, (short *)p_ul_ds_inBuf, &ul_ds_inLen, (short *)p_ul_ds_outBuf, &ul_ds_outLen);
+ }
+ else{
+ memcpy(p_ul_ds_outBuf, p_ul_ds_inBuf, CTM_NB_BUF_LEN << 1);
+ }
+
+ /*[CTM blisrc] UL downsample end*/
+
+
+ /*[CTM blisrc] DL downsample start*/
+
+
+ p_dl_ds_inBuf = l1ctm->dl_pcm_input[buf_idx];
+ p_dl_ds_outBuf = l1ctm->dl_pcm_fifo[buf_idx];
+
+ if(CTM_WB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ dl_ds_inLen = CTM_WB_BUF_LEN << 1;
+ dl_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+ }
+ else if(CTM_SWB_BUF_LEN ==l1ctm->dl_pcm_input_len[buf_idx]){
+ dl_ds_inLen = CTM_SWB_BUF_LEN << 1;
+ dl_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+ }
+ else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, CTM_NB_BUF_LEN << 1);
+ }
+
+
+ /*[CTM blisrc] DL downsample end*/
+
+
+ bfi_flag = (kal_bool)(l1ctm->l1d_bfi_info[buf_idx]);
+
+
+ #ifdef UL_IN_PCM_RECORD_MD
+ if( l1ctm->debugCallback != NULL ){
+ l1ctm->debugCallback(UL_IN_WRITE_FILE_REQUEST, l1ctm->ul_pcm_fifo[buf_idx], CTM_NB_BUF_LEN, false);
+
+ }
+ #endif
+
+ #ifdef DL_IN_PCM_RECORD_MD
+ if( l1ctm->debugCallback != NULL ){
+ l1ctm->debugCallback(DL_IN_WRITE_FILE_REQUEST, l1ctm->dl_pcm_fifo[buf_idx], CTM_NB_BUF_LEN, false);
+ }
+ #endif
+
+
+ l1ctmFlags = l1ctm->FLAGS;
+ interface = l1ctm->interface;
+
+ ctmFlags = ctm_modem_get_flags();
+
+
+ // up-link path input : Baudot Demodulator
+ if(interface != DIRECT_MODE)
+ {
+ #if !defined(DUPLEX_BAUDOT)
+ if(ctmFlags & CMF_BAUDOT_OUT_BITS_READY && l1ctm->enquiry_count != -2)
+ l1ctmFlags |= LCF_UL_MUTE;
+ else
+ #endif
+ {
+ baudot_demod((const uint16*)l1ctm->ul_pcm_fifo[buf_idx],&ctmFlags, &utf8_code);
+
+ if(ctmFlags & CMF_BAUDOT_IN_DETECTED && l1ctm->enquiry_count != -2)
+ l1ctmFlags |= LCF_UL_MUTE;
+ else if(ctmFlags & CMF_BAUDOT_IN_CHAR)
+ {
+ UL_TTY_BUF_PUT_CHAR(utf8_code);
+ MD_TRC_L1CTM_UL_GET_DECODED_TTY_CHAR(utf8_code);
+ }
+ }
+ }
+
+ // down-link path input : CTM receiver
+ if( l1ctm->interface != DIRECT_MODE ) // Half-duplex CTM for BAUDOT_MODE //mtk01407, 2006-05-22
+ {
+ if( (!(ctmFlags & CMF_CTM_TX_BITS_READY)) || (l1ctmFlags & (LCF_NEGOTIATION | LCF_ACKING)) )
+ { ctm_receiver((const uint16*)l1ctm->dl_pcm_fifo[buf_idx], bfi_flag, &ctmFlags, &utf8_code); }
+ else
+ { // If CTM is transmitting, dump zero patter to CTM receiver that means disable receiving function of CTM
+ // Set bfi = 0 to avoid const zero_dl_pcm[] being modified //mtk01407, 2006-05-17
+ ctm_receiver((const uint16*)zero_dl_pcm, 0, &ctmFlags, &utf8_code);
+ }
+
+ }else // Full-duplex CTM for DIRECT_MODE
+ {
+ ctm_receiver((const uint16*)l1ctm->dl_pcm_fifo[buf_idx], bfi_flag, &ctmFlags, &utf8_code);
+ }
+
+ if(ctmFlags & CMF_CTM_RX_DETECTED)
+ {
+ if(!(l1ctmFlags & LCF_DL_CTM_RECEIVING))
+ {
+ l1ctmFlags |= LCF_DL_CTM_RECEIVING;
+
+ MD_TRC_L1CTM_DL_DETECT_CTM_SYNC();
+
+ SAL_CTM_Switch(true);
+ l1ctm->dl_isTTY = 1;
+
+ if(!(l1ctmFlags & LCF_FAR_END_DETECTED))
+ {
+ l1ctmFlags |= LCF_FAR_END_DETECTED;
+ MD_TRC_L1CTM_FAR_END_CTM_DETECTED();
+ l1ctm->state = L1CTM_CONNECTED_STATE;
+ // first detect far-end CTM
+ if(l1ctmFlags & LCF_NEGOTIATION)
+ {
+ MD_TRC_L1CTM_NEGOTIATION_SUCCESS();
+ l1ctmFlags &= ~LCF_NEGOTIATION;
+ l1ctmFlags |= LCF_DL_ACKING;
+ l1ctm->enquiry_timeout1 = 0;
+ l1ctm->enquiry_timeout2 = 0;
+ if(interface != DIRECT_MODE)
+ l1ctm->enquiry_count = -1; //0;
+ else if(interface == DIRECT_MODE)
+ {
+ l1ctm->callback_handler(CTM_MO_SUCCESS, (void*) 0);
+ l1ctm->enquiry_count = 3;
+ }
+ }
+ else
+ {
+ MD_TRC_L1CTM_DEMAND_CTM_ACK();
+ l1ctmFlags |= LCF_SEND_ACK;
+ l1ctm->next_ack_timeout = NEXT_ACK_TIMEOUT;
+ if(interface == DIRECT_MODE)
+ l1ctm->callback_handler(CTM_MT_DETECTED, (void*) 0);
+ }
+ }
+ } // end of if(!(l1ctmFlags & LCF_DL_CTM_RECEIVING))
+
+ if(ctmFlags & CMF_CTM_RX_CHAR)
+ {
+ MD_TRC_L1CTM_DL_GET_RECEIVED_CTM_CHAR(utf8_code);
+ if(l1ctmFlags & LCF_DL_ACKING)
+ {
+ }
+ else if(utf8_code == ENQUIRY_CHAR)
+ {
+ if(l1ctm->next_ack_timeout == 0)
+ {
+ l1ctmFlags |= LCF_SEND_ACK;
+ l1ctm->next_ack_timeout = NEXT_ACK_TIMEOUT;
+ }
+ }
+ else // receive a normal character
+ {
+
+ if(interface !=DIRECT_MODE)
+ {
+ DL_TTY_BUF_PUT_CHAR(utf8_code);
+ }
+ else if(interface == DIRECT_MODE)
+ {
+ DL_CTM_BUF_PUT_CHAR(utf8_code);
+ l1ctm->callback_handler(CTM_CHAR_RECEIVED, (void *)(uint32)utf8_code);
+ }
+ }
+ } // end of if(ctmFlags & CMF_CTM_RX_CHAR)
+ }
+ else
+ {
+ if(l1ctmFlags & LCF_DL_CTM_RECEIVING)
+ {
+ MD_TRC_L1CTM_DL_CTM_BURST_END();
+
+ l1ctmFlags &= ~LCF_DL_CTM_RECEIVING;
+ l1ctmFlags &= ~LCF_DL_ACKING;
+
+
+ // command DSP to change to normal speech codec
+ SAL_CTM_Switch(false);
+ l1ctm->dl_isTTY = 0;
+
+ l1ctm->transition_mute = DL_TRANSITION_MUTE_TIMEOUT;
+ }
+ }
+
+
+ // judge RX mute case
+ if(ctmFlags & CMF_CTM_RX_EARLY_MUTE || l1ctmFlags & LCF_DL_CTM_RECEIVING)
+ l1ctmFlags |= LCF_DL_MUTE;
+
+ if(SAL_CTM_IsOff())
+ l1ctmFlags |= LCF_DL_MUTE;
+
+ if(SAL_CTM_IsIdle() && l1ctm->transition_mute > 0)
+ {
+ l1ctm->transition_mute --;
+ l1ctmFlags |= LCF_DL_MUTE;
+ }
+
+
+ // down-link path output
+ if(interface !=DIRECT_MODE)
+ {
+ if(ctmFlags & CMF_BAUDOT_OUT_BITS_READY)
+ {
+ utf8_code = NON_UTF8_CHAR;
+
+ if(ctmFlags & CMF_BAUDOT_OUT_NEAR_EMPTY)
+ if(DL_TTY_BUF_CHAR_READY())
+ {
+ DL_TTY_BUF_GET_CHAR(utf8_code);
+ MD_TRC_L1CTM_DL_SEND_TTY_CHAR(utf8_code);
+ }
+
+ baudot_mod(utf8_code, l1ctm->dl_pcm_fifo[buf_idx], &ctmFlags);
+ }
+ else
+ {
+ if(l1ctmFlags & LCF_DL_BAUDOT_TRANSMITTING)
+ l1ctmFlags &= ~LCF_DL_BAUDOT_TRANSMITTING;
+
+ if(DL_TTY_BUF_CHAR_READY())
+ {
+ DL_TTY_BUF_GET_CHAR(utf8_code);
+ MD_TRC_L1CTM_DL_SEND_TTY_CHAR(utf8_code);
+ baudot_mod(utf8_code, l1ctm->dl_pcm_fifo[buf_idx], &ctmFlags);
+ #if !defined(DUPLEX_BAUDOT)
+ baudot_demod_reset();
+ l1ctmFlags |= LCF_UL_MUTE; // mute for baudot_out is modulating
+ #endif
+ l1ctmFlags |= LCF_DL_BAUDOT_TRANSMITTING;
+ }
+ }
+ }
+
+ // up-link path output
+ if(ctmFlags & CMF_CTM_TX_BITS_READY)
+ {
+ utf8_code = NON_UTF8_CHAR;
+
+ l1ctmFlags &= ~LCF_SEND_ACK;
+
+ if(ctmFlags & CMF_CTM_TX_NEAR_EMPTY)
+ {
+ utf8_code = IDLE_CHAR;
+
+ if(l1ctmFlags & LCF_NEGOTIATION)
+ {
+ // Yuan comment out to test the ul nego fail problem in LA.
+ //if(interface !=DIRECT_MODE && l1ctm->enquiry_timeout1 > 0)
+ // if(UL_TTY_BUF_CHAR_READY())
+ // UL_TTY_BUF_GET_CHAR(utf8_code);
+ //if(interface !=DIRECT_MODE && l1ctm->enquiry_timeout1 > 0)
+ //utf8_code = ENQUIRY_CHAR;
+ }
+ else
+ {
+ if(interface !=DIRECT_MODE && UL_TTY_BUF_CHAR_READY())
+ {
+ UL_TTY_BUF_GET_CHAR(utf8_code);
+ }
+ else if(interface == DIRECT_MODE && UL_CTM_BUF_CHAR_READY())
+ {
+ UL_CTM_BUF_GET_CHAR(utf8_code);
+ l1ctm->callback_handler(CTM_CHAR_SENT, (void *)(uint32)utf8_code);
+ }
+ }
+ MD_TRC_L1CTM_UL_SEND_CTM_CHAR(utf8_code);
+ l1ctm->ul_send_count = NUM_UL_SEND_FRAME;
+ l1ctm->ul_isSending = 1;
+ }
+ ctm_transmitter(utf8_code, l1ctm->ul_pcm_fifo[buf_idx], &ctmFlags);
+ }
+ else
+ {
+ if(l1ctmFlags & LCF_UL_CTM_TRANSMITTING)
+ {
+ l1ctmFlags &= ~LCF_UL_CTM_TRANSMITTING;
+ if(l1ctmFlags & LCF_ACKING){
+ l1ctmFlags &= ~LCF_ACKING;
+ l1ctm->ul_isTTY = 0;
+ }
+
+ if(interface == DIRECT_MODE)
+ l1ctm->callback_handler(CTM_TX_BURST_END, (void*) 0);
+ }
+
+ if(l1ctm->enquiry_timeout2 == 0 && l1ctm->enquiry_count == 0)
+ {
+ l1ctmFlags &= ~LCF_NEGOTIATION;
+
+ MD_TRC_L1CTM_NEGOTIATION_FAIL();
+ if(interface == DIRECT_MODE)
+ {
+ l1ctm->callback_handler(CTM_MO_FAIL, (void*)0);
+ l1ctm->enquiry_count = 3; // reset enquiry_count to allow next negotiation
+ }
+ else // BAUDOT_MODE
+ l1ctm->enquiry_count = -2;
+
+ }
+
+ // judge if has character to send
+ if(l1ctmFlags & LCF_FAR_END_DETECTED)
+ {
+ utf8_code = NO_CHAR;
+
+ if(interface !=DIRECT_MODE && UL_TTY_BUF_CHAR_READY())
+ {
+ UL_TTY_BUF_GET_CHAR(utf8_code);
+ }
+ else if(interface == DIRECT_MODE && UL_CTM_BUF_CHAR_READY())
+ {
+ UL_CTM_BUF_GET_CHAR(utf8_code);
+ l1ctm->callback_handler(CTM_CHAR_SENT, (void *)(uint32)utf8_code);
+ }
+ else if(l1ctmFlags & LCF_SEND_ACK)
+ {
+ MD_TRC_L1CTM_UL_SEND_IDLE_AS_ACK();
+ utf8_code = IDLE_CHAR;
+ }
+
+ if(utf8_code != NO_CHAR)
+ {
+ if(l1ctmFlags & LCF_SEND_ACK)
+ {
+ l1ctmFlags &= ~LCF_SEND_ACK;
+ l1ctmFlags |= LCF_ACKING;
+ }
+ MD_TRC_L1CTM_UL_SEND_CTM_CHAR(utf8_code);
+ ctm_transmitter(utf8_code, l1ctm->ul_pcm_fifo[buf_idx], &ctmFlags);
+ l1ctmFlags |= LCF_UL_CTM_TRANSMITTING;
+ l1ctm->ul_send_count = NUM_UL_SEND_FRAME;
+ l1ctm->ul_isSending = 1;
+ }
+ }
+ else
+ {
+ if(l1ctm->enquiry_count > 0)
+ {
+ //if(l1ctm->enquiry_count == 3) // Adam : mark for more enquiry
+ if(l1ctm->enquiry_count == more_enquiry_times)
+ {
+ if((interface !=DIRECT_MODE && UL_TTY_BUF_CHAR_READY()) ||
+ (interface == DIRECT_MODE && (l1ctmFlags & LCF_NEGOTIATION_REQ)))
+ l1ctmFlags |= (LCF_SEND_ENQUIRY + LCF_NEGOTIATION);
+ }
+ else
+ {
+ if(l1ctm->enquiry_timeout2 == 0)
+ l1ctmFlags |= LCF_SEND_ENQUIRY;
+ }
+
+ if(l1ctmFlags & LCF_SEND_ENQUIRY)
+ {
+ l1ctm->enquiry_count --;
+ l1ctm->enquiry_timeout1 = ENQUIRY_TIMEOUT1;
+ l1ctm->enquiry_timeout2 = ENQUIRY_TIMEOUT2;
+ MD_TRC_L1CTM_UL_SEND_ENQUIRY_CHAR(3 - l1ctm->enquiry_count);
+ ctm_transmitter(ENQUIRY_CHAR, l1ctm->ul_pcm_fifo[buf_idx], &ctmFlags);
+ l1ctmFlags |= LCF_UL_CTM_TRANSMITTING;
+ l1ctmFlags &= ~(LCF_SEND_ENQUIRY + LCF_NEGOTIATION_REQ);
+ }
+ }
+ }
+ }
+
+ // calculate time out
+ if(l1ctm->next_ack_timeout > 0)
+ l1ctm->next_ack_timeout --;
+ if(l1ctm->enquiry_timeout1 > 0)
+ l1ctm->enquiry_timeout1 --;
+ if(l1ctm->enquiry_timeout2 > 0)
+ l1ctm->enquiry_timeout2 --;
+
+
+ // process output for MUTE case
+ if(!(l1ctmFlags & LCF_UL_CTM_TRANSMITTING) && (l1ctmFlags & LCF_UL_MUTE))
+ l1ctm->ul_mute_flags |= 1 << l1ctm->next_to_process;
+ else
+ l1ctm->ul_mute_flags &= ~(1 << l1ctm->next_to_process);
+
+
+ if(!(l1ctmFlags & LCF_DL_BAUDOT_TRANSMITTING) && (l1ctmFlags & LCF_DL_MUTE))
+ l1ctm->dl_mute_flags |= 1 << l1ctm->next_to_process;
+ else
+ l1ctm->dl_mute_flags &= ~(1 << l1ctm->next_to_process);
+
+ l1ctmFlags &= ~(LCF_UL_MUTE + LCF_DL_MUTE);
+ l1ctm->FLAGS = l1ctmFlags;
+
+
+
+ #ifdef UL_OUT_PCM_RECORD_MD
+ if( l1ctm->debugCallback != NULL ){
+ if(l1ctm->ul_mute_flags & (1 << l1ctm->next_to_process)) {
+ l1ctm->debugCallback(UL_OUT_WRITE_FILE_REQUEST, zero_dl_pcm, CTM_NB_BUF_LEN, false);
+ } else {
+ l1ctm->debugCallback(UL_OUT_WRITE_FILE_REQUEST, l1ctm->ul_pcm_fifo[buf_idx], CTM_NB_BUF_LEN, false);
+ }
+ }
+ #endif
+
+ #ifdef DL_OUT_PCM_RECORD_MD
+ if( l1ctm->debugCallback != NULL ){
+ if(l1ctm->dl_mute_flags & (1 << l1ctm->next_to_process)) {
+ l1ctm->debugCallback(DL_OUT_WRITE_FILE_REQUEST, zero_dl_pcm, CTM_NB_BUF_LEN, false);
+ } else {
+ l1ctm->debugCallback(DL_OUT_WRITE_FILE_REQUEST, l1ctm->dl_pcm_fifo[buf_idx], CTM_NB_BUF_LEN, false);
+ }
+ }
+ #endif
+
+
+#if defined(UL_IN_PCM_RECORD_MD) || defined(DL_IN_PCM_RECORD_MD) || defined(UL_OUT_PCM_RECORD_MD) || defined(DL_OUT_PCM_RECORD_MD)
+ {
+ if( l1ctm->debugCallback != NULL ){
+ l1ctm->debugCallback(0, NULL, 0, true);
+ }
+ }
+#endif
+
+ l1ctm->next_to_process ++;
+ if(l1ctm->next_to_process == 2 * PCM_FIFO_LEN)
+ l1ctm->next_to_process = 0;
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [CTM] <- [BAUDOT] *
+ *****************************************************/
+
+
+ /*[CTM blisrc] UL up sampling start*/
+
+ p_ul_us_inBuf = l1ctm->ul_pcm_fifo[buf_idx];
+ p_ul_us_outBuf = l1ctm->ul_pcm_output[buf_idx];
+
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, CTM_NB_BUF_LEN << 1);
+
+ ul_us_inLen = CTM_NB_BUF_LEN << 1;
+ ul_us_outLen = CTM_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = l1ctm->ul_pcm_output_wb[buf_idx];
+ BLI_Convert(l1ctm -> ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ ul_us_inLen = CTM_NB_BUF_LEN << 1;
+ ul_us_outLen = CTM_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = l1ctm->ul_pcm_output_swb[buf_idx];
+ BLI_Convert(l1ctm -> ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+
+ /*[CTM blisrc] UL up sampling end*/
+
+
+
+ /*[CTM blisrc] DL up sampling start*/
+
+
+ p_dl_us_inBuf = l1ctm->dl_pcm_fifo[buf_idx];
+ p_dl_us_outBuf = l1ctm->dl_pcm_output[buf_idx];
+
+
+ memcpy(p_dl_us_outBuf, p_dl_us_inBuf, CTM_NB_BUF_LEN << 1);
+
+ dl_us_inLen = CTM_NB_BUF_LEN << 1;
+ dl_us_outLen = CTM_WB_BUF_LEN << 1;
+ p_dl_us_outBuf = l1ctm->dl_pcm_output_wb[buf_idx];
+ BLI_Convert(l1ctm -> dl_upsample_8_16, (short *)p_dl_us_inBuf, &dl_us_inLen, (short *)p_dl_us_outBuf, &dl_us_outLen);
+
+ dl_us_inLen = CTM_NB_BUF_LEN << 1;
+ dl_us_outLen = CTM_SWB_BUF_LEN << 1;
+ p_dl_us_outBuf = l1ctm->dl_pcm_output_swb[buf_idx];
+ BLI_Convert(l1ctm -> dl_upsample_8_32, (short *)p_dl_us_inBuf, &dl_us_inLen, (short *)p_dl_us_outBuf, &dl_us_outLen);
+
+ /*[CTM blisrc] DL up sampling end*/
+
+ if(l1ctm->ul_isSending){
+ l1ctm->ul_isTTY = 1;
+ l1ctm->ul_send_count --;
+ }
+
+ if(l1ctm->ul_send_count == 0){
+ l1ctm->ul_isTTY = 0;
+ l1ctm->ul_isSending = 0;
+ }
+ uint16 *ptrSrc;
+ uint16 *ptrDest;
+ if(VCO_MODE == l1ctm->interface && (!l1ctm->ul_isTTY)){
+ ptrSrc = l1ctm->ul_pcm_input[buf_idx];
+ if(CTM_SWB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->ul_pcm_output_swb[buf_idx];
+ }
+ else if(CTM_WB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->ul_pcm_output_wb[buf_idx];
+ }
+ else{
+ ptrDest = l1ctm->ul_pcm_output[buf_idx];
+ }
+
+ memcpy(ptrDest, ptrSrc, l1ctm->ul_pcm_input_len[buf_idx] * sizeof(uint16));
+ }
+ if(HCO_MODE == l1ctm->interface && (!l1ctm->dl_isTTY)){
+ ptrSrc = l1ctm->dl_pcm_input[buf_idx];
+ if(CTM_SWB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->dl_pcm_output_swb[buf_idx];
+ }
+ else if(CTM_WB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->dl_pcm_output_wb[buf_idx];
+ }
+ else{
+ ptrDest = l1ctm->dl_pcm_output[buf_idx];
+ }
+
+ memcpy(ptrDest, ptrSrc, l1ctm->dl_pcm_input_len[buf_idx] * sizeof(uint16));
+ }
+
+ //copy 2nd mic data directly
+ ptrSrc = l1ctm->ul_pcm_input2[buf_idx];
+ ptrDest = l1ctm->ul_pcm_output2[buf_idx];
+ memcpy(ptrDest, ptrSrc, l1ctm->ul_pcm_input_len[buf_idx] * sizeof(uint16));
+
+ }
+
+}
+
+void l1ctm_in_task_4g()
+{
+ uint16 l1ctmFlags, ctmFlags, interface, buf_idx;
+
+
+ uint32 ul_ds_inLen, ul_ds_outLen, dl_ds_inLen, dl_ds_outLen;
+ uint32 ul_us_inLen, ul_us_outLen, dl_us_inLen, dl_us_outLen;
+
+ uint16 *p_ul_ds_inBuf, *p_ul_ds_outBuf;
+ uint16 *p_dl_ds_inBuf, *p_dl_ds_outBuf;
+
+ uint16 *p_ul_us_inBuf, *p_ul_us_outBuf;
+ uint16 *p_dl_us_inBuf, *p_dl_us_outBuf;
+
+ uint8 utf8_code;
+
+
+ if(l1ctm == (L1Ctm_Module*) 0)
+ return;
+
+ while(l1ctm->next_to_process != l1ctm->pcm_fifo_write)
+ {
+ buf_idx = l1ctm->next_to_process;
+ if(buf_idx >= PCM_FIFO_LEN)
+ buf_idx -= PCM_FIFO_LEN;
+
+
+ /******************************************************
+ * ul_pcm_input -> ul_pcm_fifo -> ul_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [CTM] *
+ ******************************************************/
+
+
+
+ /*[CTM blisrc] UL downsample start*/
+
+ p_ul_ds_inBuf = l1ctm->ul_pcm_input[buf_idx];
+ p_ul_ds_outBuf = l1ctm->ul_pcm_fifo[buf_idx];
+
+ if(CTM_WB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ul_ds_inLen = CTM_WB_BUF_LEN << 1;
+ ul_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->ul_downsample_16_8, (short *)p_ul_ds_inBuf, &ul_ds_inLen, (short *)p_ul_ds_outBuf, &ul_ds_outLen);
+ }
+ else if(CTM_SWB_BUF_LEN ==l1ctm->ul_pcm_input_len[buf_idx]){
+ ul_ds_inLen = CTM_SWB_BUF_LEN << 1;
+ ul_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->ul_downsample_32_8, (short *)p_ul_ds_inBuf, &ul_ds_inLen, (short *)p_ul_ds_outBuf, &ul_ds_outLen);
+ }
+ else{
+ memcpy(p_ul_ds_outBuf, p_ul_ds_inBuf, CTM_NB_BUF_LEN << 1);
+ }
+
+ /*[CTM blisrc] UL downsample end*/
+
+
+ /*[CTM blisrc] DL downsample start*/
+
+ p_dl_ds_inBuf = l1ctm->dl_pcm_input[buf_idx];
+ p_dl_ds_outBuf = l1ctm->dl_pcm_fifo[buf_idx];
+
+
+ if(CTM_WB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ dl_ds_inLen = CTM_WB_BUF_LEN << 1;
+ dl_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+ }
+ else if(CTM_SWB_BUF_LEN ==l1ctm->dl_pcm_input_len[buf_idx]){
+ dl_ds_inLen = CTM_SWB_BUF_LEN << 1;
+ dl_ds_outLen = CTM_NB_BUF_LEN << 1;
+ BLI_Convert(l1ctm->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+ }
+ else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, CTM_NB_BUF_LEN << 1);
+ }
+ /*[CTM blisrc] DL downsample end*/
+
+
+ l1ctmFlags = l1ctm->FLAGS;
+ interface = l1ctm->interface;
+
+ ctmFlags = ctm_modem_get_flags();
+
+
+ // up-link path input : Baudot Demodulator
+ if(interface != DIRECT_MODE)
+ {
+ #if !defined(DUPLEX_BAUDOT)
+ if(ctmFlags & CMF_BAUDOT_OUT_BITS_READY && l1ctm->enquiry_count != -2){
+ l1ctmFlags |= LCF_UL_MUTE;
+
+ }
+ else
+ #endif
+ {
+ baudot_demod((const uint16*)l1ctm->ul_pcm_fifo[buf_idx],&ctmFlags, &utf8_code);
+
+ if(ctmFlags & CMF_BAUDOT_IN_DETECTED && l1ctm->enquiry_count != -2)
+ l1ctmFlags |= LCF_UL_MUTE;
+ else if(ctmFlags & CMF_BAUDOT_IN_CHAR)
+ {
+ //UL_TTY_BUF_PUT_CHAR(utf8_code);
+
+ if(!TTY_LTE_PSR_UL_isFull())
+ TTY_LTE_PSR_UL_Put(utf8_code);
+
+ MD_TRC_L1CTM_4G_PUT_UL(utf8_code);
+ MD_TRC_L1CTM_UL_GET_DECODED_TTY_CHAR(utf8_code);
+
+
+ }
+ }
+ }
+
+ if(l1ctm->dl_put_count == 0){
+ if(!TTY_LTE_PSR_DL_isEmpty()){
+ uint8 ch = TTY_LTE_PSR_DL_Get();
+ DL_TTY_BUF_PUT_CHAR(ch);
+
+ MD_TRC_L1CTM_4G_GET_DL(ch);
+
+ }
+ l1ctm->dl_put_count = NUM_DELAY_FRAME;
+ }
+ l1ctm->dl_put_count--;
+
+
+ // down-link path output
+ if(interface !=DIRECT_MODE)
+ {
+ if(ctmFlags & CMF_BAUDOT_OUT_BITS_READY)
+ {
+ utf8_code = NON_UTF8_CHAR;
+
+ if(ctmFlags & CMF_BAUDOT_OUT_NEAR_EMPTY)
+ if(DL_TTY_BUF_CHAR_READY())
+ {
+ DL_TTY_BUF_GET_CHAR(utf8_code);
+ MD_TRC_L1CTM_DL_SEND_TTY_CHAR(utf8_code);
+ }
+
+ baudot_mod(utf8_code, l1ctm->dl_pcm_fifo[buf_idx], &ctmFlags);
+ }
+ else
+ {
+ if(l1ctmFlags & LCF_DL_BAUDOT_TRANSMITTING)
+ l1ctmFlags &= ~LCF_DL_BAUDOT_TRANSMITTING;
+
+ if(DL_TTY_BUF_CHAR_READY())
+ {
+ DL_TTY_BUF_GET_CHAR(utf8_code);
+ MD_TRC_L1CTM_DL_SEND_TTY_CHAR(utf8_code);
+ baudot_mod(utf8_code, l1ctm->dl_pcm_fifo[buf_idx], &ctmFlags);
+ #if !defined(DUPLEX_BAUDOT)
+ baudot_demod_reset();
+ l1ctmFlags |= LCF_UL_MUTE; // mute for baudot_out is modulating
+ #endif
+ l1ctmFlags |= LCF_DL_BAUDOT_TRANSMITTING;
+ }
+ }
+ }
+
+
+ // calculate time out
+ if(l1ctm->next_ack_timeout > 0)
+ l1ctm->next_ack_timeout --;
+ if(l1ctm->enquiry_timeout1 > 0)
+ l1ctm->enquiry_timeout1 --;
+ if(l1ctm->enquiry_timeout2 > 0)
+ l1ctm->enquiry_timeout2 --;
+
+ // process output for MUTE case
+ if(!(l1ctmFlags & LCF_UL_CTM_TRANSMITTING) && (l1ctmFlags & LCF_UL_MUTE))
+ l1ctm->ul_mute_flags |= 1 << l1ctm->next_to_process;
+ else
+ l1ctm->ul_mute_flags &= ~(1 << l1ctm->next_to_process);
+
+
+ if(!(l1ctmFlags & LCF_DL_BAUDOT_TRANSMITTING) && (l1ctmFlags & LCF_DL_MUTE))
+ l1ctm->dl_mute_flags |= 1 << l1ctm->next_to_process;
+ else
+ l1ctm->dl_mute_flags &= ~(1 << l1ctm->next_to_process);
+
+ l1ctmFlags &= ~(LCF_UL_MUTE + LCF_DL_MUTE);
+ l1ctm->FLAGS = l1ctmFlags;
+
+
+ l1ctm->next_to_process ++;
+ if(l1ctm->next_to_process == 2 * PCM_FIFO_LEN)
+ l1ctm->next_to_process = 0;
+
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [CTM] <- [BAUDOT] *
+ *****************************************************/
+
+
+ /*[CTM blisrc] UL up sampling start*/
+
+ p_ul_us_inBuf = l1ctm->ul_pcm_fifo[buf_idx];
+ p_ul_us_outBuf = l1ctm->ul_pcm_output[buf_idx];
+
+
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, 160 << 1);
+
+ ul_us_inLen = CTM_NB_BUF_LEN << 1;
+ ul_us_outLen = CTM_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = l1ctm->ul_pcm_output_wb[buf_idx];
+ BLI_Convert(l1ctm -> ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ ul_us_inLen = CTM_NB_BUF_LEN << 1;
+ ul_us_outLen = CTM_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = l1ctm->ul_pcm_output_swb[buf_idx];
+ BLI_Convert(l1ctm -> ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ /*[CTM blisrc] UL up sampling end*/
+
+
+
+ /*[CTM blisrc] DL up sampling start*/
+
+ p_dl_us_inBuf = l1ctm->dl_pcm_fifo[buf_idx];
+ p_dl_us_outBuf = l1ctm->dl_pcm_output[buf_idx];
+
+
+ memcpy(p_dl_us_outBuf, p_dl_us_inBuf, 160 << 1);
+
+ dl_us_inLen = CTM_NB_BUF_LEN << 1;
+ dl_us_outLen = CTM_WB_BUF_LEN << 1;
+ p_dl_us_outBuf = l1ctm->dl_pcm_output_wb[buf_idx];
+ BLI_Convert(l1ctm -> dl_upsample_8_16, (short *)p_dl_us_inBuf, &dl_us_inLen, (short *)p_dl_us_outBuf, &dl_us_outLen);
+
+ dl_us_inLen = CTM_NB_BUF_LEN << 1;
+ dl_us_outLen = CTM_SWB_BUF_LEN << 1;
+ p_dl_us_outBuf = l1ctm->dl_pcm_output_swb[buf_idx];
+ BLI_Convert(l1ctm -> dl_upsample_8_32, (short *)p_dl_us_inBuf, &dl_us_inLen, (short *)p_dl_us_outBuf, &dl_us_outLen);
+
+
+ /*[CTM blisrc] DL up sampling end*/
+
+ uint16 *ptrSrc;
+ uint16 *ptrDest;
+ if(VCO_MODE == l1ctm->interface){
+ ptrSrc = l1ctm->ul_pcm_input[buf_idx];
+
+ if(CTM_SWB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->ul_pcm_output_swb[buf_idx];
+ }
+ else if(CTM_WB_BUF_LEN == l1ctm->ul_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->ul_pcm_output_wb[buf_idx];
+ }
+ else{
+ ptrDest = l1ctm->ul_pcm_output[buf_idx];
+ }
+ memcpy(ptrDest, ptrSrc, l1ctm->ul_pcm_input_len[buf_idx] * sizeof(uint16));
+
+ }
+ else if(HCO_MODE == l1ctm->interface){
+ ptrSrc = l1ctm->dl_pcm_input[buf_idx];
+
+ if(CTM_SWB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->dl_pcm_output_swb[buf_idx];
+ }
+ else if(CTM_WB_BUF_LEN == l1ctm->dl_pcm_input_len[buf_idx]){
+ ptrDest = l1ctm->dl_pcm_output_wb[buf_idx];
+ }
+ else{
+ ptrDest = l1ctm->dl_pcm_output[buf_idx];
+ }
+
+ memcpy(ptrDest, ptrSrc, l1ctm->dl_pcm_input_len[buf_idx] * sizeof(uint16));
+ }
+ else{
+ memset(l1ctm->ul_pcm_output[buf_idx], 0, CTM_NB_BUF_LEN << 1);
+ memset(l1ctm->ul_pcm_output_wb[buf_idx], 0, CTM_WB_BUF_LEN << 1);
+ memset(l1ctm->ul_pcm_output_swb[buf_idx], 0, CTM_SWB_BUF_LEN << 1);
+ }
+ }
+}
+
+void l1ctm_in_task(void *data){
+ if(L1SP_STATE_4G_SPEECH_ON == L1SP_GetState()){
+ l1ctm_in_task_4g();
+ }
+ else{
+ l1ctm_in_task_2g_3g();
+ }
+}
+
+/*============================== L1Ctm APIs ====================================*/
+
+uint32 L1Ctm_GetMemReq(void)
+{
+ uint32 mem_size = 0;
+
+ mem_size = sizeof(L1Ctm_Module) + ctm_modem_mem_req();
+
+ return mem_size;
+}
+
+
+void L1Ctm_Open(L1Ctm_Interface a, L1Ctm_Callback handler, uint8 *buf, uint32 buf_len, L1Ctm_DebugCallback debugCallback)
+{
+ uint8 *buf_ptr;
+
+ CTM_Param *ctm_param, CTM_param;
+ #if defined(__DSP_FCORE4__)
+ CTM_param.cprm_tone_demod_down_samp = 0x7D;
+ #else
+ CTM_param.cprm_tone_demod_down_samp = 0x05;
+ #endif
+ ctm_param = &CTM_param;
+
+ MD_TRC_L1CTM_OPEN();
+
+ ASSERT(buf_len >= L1Ctm_GetMemReq());
+
+
+ // allocate memory to L1CTM and CTM modem , and init CTM modem
+ l1ctm = (L1Ctm_Module*) buf;
+ buf_ptr = buf + sizeof(L1Ctm_Module);
+ buf_len -= sizeof(L1Ctm_Module);
+
+ ctm_modem_init(buf_ptr, buf_len, ctm_param);
+
+ if(ctm_param != NULL)
+ {
+ cprm_debug_flag = ctm_param->cprm_tone_demod_down_samp;
+ MD_TRC_L1CTM_OPEN_PARAM(cprm_debug_flag);
+ }
+ else
+ {
+ cprm_debug_flag = CPRM_MASK_DOWN_SAMP | CPRM_MASK_REC_DL_PCM_IN | CPRM_MASK_REC_DL_PCM_OUT | CPRM_MASK_REC_UL_PCM_IN | CPRM_MASK_REC_UL_PCM_OUT;
+ }
+
+
+ l1ctm->interface = a;
+
+
+ {
+ uint16 bit;
+ for(bit=0; bit<PCM_FIFO_LEN; bit++) {
+ l1ctm->ul_mute_flags |= (1<<bit);
+ l1ctm->dl_mute_flags |= (1<<bit);
+ }
+ }
+
+ // open BLI Src for ctm
+ l1ctm -> ul_downsample_32_8 = BLI_Open( 32000, 1, 8000, 1, (signed char*)l1ctm -> internal_buf_ul_in, 0); // open UL down sampling src
+ l1ctm -> dl_downsample_32_8 = BLI_Open( 32000, 1, 8000, 1, (signed char*)l1ctm -> internal_buf_dl_in, 0); // open DL down sampling src
+ l1ctm -> ul_upsample_8_32 = BLI_Open( 8000, 1, 32000, 1, (signed char*)l1ctm -> internal_buf_ul_out, 0); // open UL up sampling src
+ l1ctm -> dl_upsample_8_32 = BLI_Open( 8000, 1, 32000, 1, (signed char*)l1ctm -> internal_buf_dl_out, 0); // open DL up sampling src
+
+
+ l1ctm -> ul_downsample_16_8 = BLI_Open( 16000, 1, 8000, 1, (signed char*)l1ctm -> internal_buf_ul_in2, 0); // open UL down sampling src
+ l1ctm -> dl_downsample_16_8 = BLI_Open( 16000, 1, 8000, 1, (signed char*)l1ctm -> internal_buf_dl_in2, 0); // open DL down sampling src
+ l1ctm -> ul_upsample_8_16 = BLI_Open( 8000, 1, 16000, 1, (signed char*)l1ctm -> internal_buf_ul_out2, 0); // open UL up sampling src
+ l1ctm -> dl_upsample_8_16 = BLI_Open( 8000, 1, 16000, 1, (signed char*)l1ctm -> internal_buf_dl_out2, 0); // open DL up sampling src
+ // init l1ctm variables
+
+ l1ctm -> aud_id = L1Audio_GetAudioID();
+
+ // init 2g_3g tty variables
+ l1ctm->ul_isTTY = 0;
+ l1ctm->dl_isTTY = 0;
+ l1ctm->ul_isSending = 0;
+ l1ctm->ul_send_count = NUM_UL_SEND_FRAME;
+
+ // init 4g tty variables
+ TTY_LTE_PSR_UL_Queue_Init();
+ TTY_LTE_PSR_DL_Queue_Init();
+
+
+ l1ctm->dl_put_count = NUM_DELAY_FRAME;
+
+ L1Audio_SetEventHandler(l1ctm->aud_id , l1ctm_in_task);
+ L1Audio_SetFlag(l1ctm->aud_id);
+
+ l1ctm->callback_handler = handler;
+#if defined(__SMART_PHONE_MODEM__)
+ l1ctm->debugCallback = debugCallback;
+#endif
+ l1ctm->next_to_process = PCM_FIFO_LEN;
+ l1ctm->pcm_fifo_write = PCM_FIFO_LEN;
+ l1ctm->pcm_fifo_read = 0;
+ l1ctm->ul_tty_buf_read = 0;
+ l1ctm->ul_tty_buf_write = 0;
+ l1ctm->ul_ctm_buf_read = 0;
+ l1ctm->ul_ctm_buf_write = 0;
+ l1ctm->dl_tty_buf_read = 0;
+ l1ctm->dl_tty_buf_write = 0;
+ l1ctm->dl_ctm_buf_read = 0;
+ l1ctm->dl_ctm_buf_write = 0;
+ l1ctm->FLAGS = 0;
+ l1ctm->state = L1CTM_READY_STATE;
+ l1ctm->next_ack_timeout = 0;
+ l1ctm->enquiry_count = 3;
+ l1ctm->debug_function = 0;
+
+
+ if(cprm_debug_flag & CPRM_MASK_MORE_ENQUIRY) // Adam : for more enquiry
+ {
+ l1ctm->enquiry_count = MORE_ENQUIRY;
+ more_enquiry_times = MORE_ENQUIRY;
+ }
+ else
+ more_enquiry_times = 3; // the same setting as Spec
+
+ if(cprm_debug_flag & CPRM_MASK_ALWAYS_NEGO_SUC) // Adam : for non-Negotiation test
+ {
+ l1ctm->FLAGS = LCF_FAR_END_DETECTED;
+ if(l1ctm->interface !=DIRECT_MODE)
+ l1ctm->enquiry_count = -1;
+ }
+
+ l1ctm->enquiry_timeout1 = 0;
+ l1ctm->enquiry_timeout2 = 0;
+ l1ctm->transition_mute = 0;
+
+ l1ctm->l1d_bfi_info[0] = 0;
+
+
+ SAL_CTM_Switch(false);
+ l1ctm->dl_isTTY = 0;
+ SAL_CTM_SetGain(CPRM_CODEBOOK_GAIN_THRESHOLD, CPRM_CODEBOOK_GAIN_VALUE);
+
+
+ l1ctm->interface = a;
+
+ if(VCO_MODE == l1ctm->interface){
+ l1sp_setCtmSpeStatus(1);
+ SetSPEnhancePath(SpeechEnh_UL);
+ }
+ else if(HCO_MODE == l1ctm->interface){
+ l1sp_setCtmSpeStatus(1);
+ SetSPEnhancePath(SpeechEnh_DL);
+ }
+ else{
+ l1sp_setCtmSpeStatus(1);
+ SetSpeechEnhancement(false);
+ l1sp_setCtmSpeStatus(0);
+ }
+ MD_TRC_L1CTM_TTY_MODE((int)l1ctm->interface);
+
+
+ if(DIRECT_MODE != l1ctm->interface)
+ PCM4WAY_Start(l1ctm_in_hisr, P4W_APP_CTM);
+
+ l1ctm->skip_hisr = false;
+ l1ctm->stop = false;
+} // End of L1Ctm_open(~)
+
+void L1Ctm_Stop(void){
+ MD_TRC_L1CTM_STOP_ENTER();
+ l1ctm-> stop = true;
+ MD_TRC_L1CTM_STOP_LEAVE();
+}
+
+void L1Ctm_Close(void)
+{
+ MD_TRC_L1CTM_CLOSE();
+
+ ASSERT(l1ctm != (L1Ctm_Module*) 0);
+ PCM4WAY_Stop(0);
+
+
+ L1Audio_ClearFlag(l1ctm->aud_id);
+ L1Audio_FreeAudioID(l1ctm->aud_id);
+
+ l1sp_setCtmSpeStatus(1);
+ SetSPEnhancePath(SpeechEnh_All); // remember to turn on SPE while TTY off
+
+ BLI_Close( l1ctm->ul_downsample_16_8, 0); // Close UL down sampling src
+ BLI_Close( l1ctm->dl_downsample_16_8, 0); // Close DL down sampling src
+ BLI_Close( l1ctm->ul_downsample_32_8, 0); // Close UL down sampling src
+ BLI_Close( l1ctm->dl_downsample_32_8, 0); // Close DL down sampling src
+ BLI_Close( l1ctm->ul_upsample_8_16, 0); // Close UL up sampling src
+ BLI_Close( l1ctm->dl_upsample_8_16, 0); // Close DL up sampling src
+ BLI_Close( l1ctm->ul_upsample_8_32, 0); // Close UL up sampling src
+ BLI_Close( l1ctm->dl_upsample_8_32, 0); // Close DL up sampling src
+ // l1ctm = (L1Ctm_Module*) 0;
+
+} // end of L1Ctm_Close(~)
+
+void L1Ctm_RTTOpen(){
+ kal_prompt_trace(MOD_L1SP, "[L1Ctm_RTTOpen] Enter");
+
+ TTY_LTE_PSR_UL_Queue_Init();
+ TTY_LTE_PSR_DL_Queue_Init();
+
+ rtt.isRttOn = true;
+
+ kal_prompt_trace(MOD_L1SP, "[L1Ctm_RTTOpen] Leave");
+}
+
+void L1Ctm_RTTClose(){
+
+ if(rtt.isRttOn) {
+ ctm_init();
+ }
+}
+
+bool getRttStatus(){
+ return rtt.isRttOn;
+}
+
+
+/*===========================MED_L1Audio_Integrate_Handler===========================================*/
+
+
+#else
+char dummy_l1ctm_c; /* define a dummy variable to avoid warning message */
+#endif // __CTM_SUPPORT__
diff --git a/mcu/driver/audio/src/v1/dummy_audio.c b/mcu/driver/audio/src/v1/dummy_audio.c
new file mode 100644
index 0000000..275127e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/dummy_audio.c
@@ -0,0 +1,1029 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * dummy_audio.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Provide APIs when speech functionality is disabled
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "syscomp_config.h"
+#include "l1audio.h"
+#include "l1sp_el2_struct.h"
+#include "dcl.h"
+//#include "uas_export_api.h"
+#include "csr_export_api.h"
+#include "cuif_l1core_public.h"
+#if defined(__MD97__) || defined(__MD97P__)
+#include "dsp_module_based_api_public.h"
+#else //#if defined(__MD97__) || defined(__MD97P__)
+#include "usip_api_public.h"
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+#include "l1aud_common_def.h"
+#include "RM_public.h"
+#include "lmd_audio.h"
+#include "lmd_msgid.h"
+//for MED
+//#include "med_struct.h"
+
+/************************************/
+/* Tasl Creation (temp solution) */
+/* Should modify task_config.h */
+/************************************/
+
+void L1Audio_HISR( void )
+{
+}
+
+static void l1audio_main(task_entry_struct * task_entry_ptr);
+
+kal_bool l1sp_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct l1sp_handler_info =
+ {
+ l1audio_main, /* task entry function */
+ NULL, /* task initialization function */
+ NULL, /* task reset handler */
+ };
+
+ *handle = (comptask_handler_struct *)&l1sp_handler_info;
+
+ return KAL_TRUE;
+}
+
+kal_bool l1audio_sph_srv_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct l1audio_sph_srv_handler_info =
+ {
+ NULL,
+ NULL,
+ NULL,
+ };
+ *handle = (comptask_handler_struct *)&l1audio_sph_srv_handler_info;
+
+ return KAL_TRUE;
+}
+
+kal_bool audl_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct audl_handler_info =
+ {
+ NULL, /* task entry function */
+ NULL, /* task initialization function */
+ NULL, /* task reset handler */
+ };
+
+ *handle = (comptask_handler_struct *)&audl_handler_info;
+ return KAL_TRUE;
+}
+
+/************************************/
+/* Audio Manager */
+/************************************/
+
+#ifndef uint16
+typedef kal_uint16 uint16;
+typedef kal_int16 int16;
+typedef kal_uint32 uint32;
+typedef kal_int32 int32;
+typedef kal_uint8 uint8;
+typedef kal_int8 int8;
+typedef kal_bool bool;
+#define true (kal_bool)(1==1)
+#define false (kal_bool)(1==0)
+#endif
+
+bool AM_IsSpeechOn( void )
+{
+ return false;
+}
+
+kal_uint32 AM_Get2GResyncThreshold( void )
+{
+ return 1083;
+}
+
+void AM_SetLoopBackTest(bool enable)
+{
+ (void) enable;
+}
+
+/*bool AM_AudioManager( bool handover, uint16 speech_mode, int8 sub_channel )
+{
+ (void) handover;
+ (void) speech_mode;
+ (void) sub_channel;
+
+ return false;
+}*/
+
+/************************************/
+/* Speech */
+/************************************/
+
+void L1SP_Set_DAI_Mode( uint8 mode )
+{
+ (void) mode;
+}
+
+void L1SP_SetAfeLoopback( bool enable )
+{
+ (void) enable;
+}
+
+void L1Audio_EnterDedicatedMode( void )
+{
+}
+
+void L1Audio_LeaveDedicatedMode( void )
+{
+}
+
+void L1SP_D2C_LISR( uint16 itype )
+{
+ (void) itype;
+}
+
+/*void L1SP_TCH_Notify( bool bOn )
+{
+ (void) bOn;
+}
+*/
+
+void L1SP_SetOutputVolume( kal_uint8 volume1, kal_int8 digital_gain_index )
+{
+ (void) volume1;
+ (void) digital_gain_index;
+}
+
+void L1SP_SetMicrophoneVolume( kal_uint8 mic_volume )
+{
+ (void) mic_volume;
+}
+
+void L1SP_Speech_On( uint8 RAT_Mode )
+{
+ (void) RAT_Mode;
+}
+
+void L1SP_Speech_Off( void )
+{
+}
+
+void L1SP_SetSidetoneVolume( uint8 sidetone )
+{
+ (void) sidetone;
+}
+
+/************************************/
+/* Speech 3G */
+/************************************/
+
+typedef struct
+{
+ kal_uint8 RSSI;
+ kal_uint8 RSCP;
+ kal_uint8 ECIO;
+ kal_uint8 HHO_SHO;
+
+ /* Used by UMAC */
+ /* Modified CRC = CRC |(S value decision)
+ S value decision=1 => S value < S Threshold. this frame is not reliable
+ S value decision =0 => S value > S Threshold. This frame is reliable
+
+ Modified CRC =0, speech good, CRC=0, S value decision =0
+ Modified CRC=1, CRC =1 or S value decision=1
+
+ crc_result value meaning :
+ 0 : Modified CRC = 0
+ 1 : Modified CRC = 1, CRC = 0
+ 2 : Modified CRC = 1, CRC = 1
+ */
+ kal_uint8 crc_result[3]; /* For Class A/B/C */
+ kal_uint32 s_value[3]; /* For Class A/B/C */
+
+ kal_int16 tpc_SIR_lta; // For recording into speech VM
+ kal_int16 dpdch_SIR_lta; // For recording into speech VM
+ kal_int16 TFCI_max_corr; // For recording into speech VM
+}L1_info_struct;
+
+kal_bool CS_NeedSpeechExtraLog( void )
+{
+ return KAL_FALSE;
+}
+
+/*void SP3G_UpdateL1AInFo( kal_uint8 bitmap, kal_uint8 value )
+{
+ (void) bitmap;
+ (void) value;
+}
+*/
+
+void SP3G_Log_L1_Info(uint32 CFN, L1_info_struct *p_L1_Info)
+{
+ (void) CFN;
+ (void) p_L1_Info;
+}
+
+void SP3G_Closed_Confirm( void )
+{
+}
+
+uint32 l1sp_rab_id;
+fp_CSR_SP3G_Callback CSR_SP3G_Callback;
+void SP3G_Rab_Est( uint32 rab_id, kal_uint8 default_speech_codec )
+{
+
+ (void) default_speech_codec;
+ CSR_SP3G_Callback = csr_get_fp_CSR_SP3G_Callback();
+ l1sp_rab_id = rab_id;
+ CSR_SP3G_Callback(SP3G_CODEC_READY, (void*)l1sp_rab_id );
+}
+
+void SP3G_Rab_Deest( void )
+{
+ CSR_SP3G_Callback = csr_get_fp_CSR_SP3G_Callback();
+ CSR_SP3G_Callback(SP3G_CODEC_CLOSED, (void*)l1sp_rab_id );
+}
+
+void SP3GHSPA_DL_SetMaxCsDelay(kal_uint8 max_cs_delay)
+{
+ (void) max_cs_delay;
+}
+
+void SP3GHSPA_DL_PutSpeechFrame(kal_uint32 CFN, kal_uint8 frame_type, kal_bool crc_status, kal_uint8 *subflow)
+{
+ (void) CFN;
+ (void) frame_type;
+ (void) crc_status;
+ (void) subflow;
+}
+
+void SP3GHSPA_UL_GetSpeechFrame(kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ (void) frame_type;
+ (void) rab_byte_array;
+ (void) len;
+}
+
+void SP3G_DL_PutSpeechFrame(uint32 CFN, uint8 sub_flow_id, uint8 frame_type, bool crc_status, uint8 *subflow)
+{
+ (void) CFN;
+ (void) sub_flow_id;
+ (void) frame_type;
+ (void) crc_status;
+ (void) subflow;
+}
+
+void SP3G_UL_SetFrameType(uint8 amr_frame_type)
+{
+ (void) amr_frame_type;
+}
+
+void SP3G_UL_GetSpeechFrame(kal_uint16*frame_index, kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ (void) frame_index;
+ (void) frame_type;
+ (void) rab_byte_array;
+ (void) len;
+}
+
+/************************************/
+/* Misc. */
+/************************************/
+
+void TONE_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+ (void) volume1;
+ (void) digital_gain_index;
+}
+
+void KT_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+ (void) volume1;
+ (void) digital_gain_index;
+}
+
+void Media_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+ (void) volume1;
+ (void) digital_gain_index;
+}
+
+void L1Audio_ResetDevice(void)
+{
+}
+
+// Temp solution here.
+// Formal solution: modify TrcMod.c
+unsigned char L1Audio_Trace_Filter[5] = { 0x1, 0x3, 0x0, 0x0, 0x0 };
+
+void Set_L1Audio_Filter(unsigned char *setting)
+{
+ int i;
+
+ for(i=0; i<5; i++)
+ L1Audio_Trace_Filter[i] = setting[i];
+}
+
+
+void SP_L4C_SetEvent(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode)
+{
+}
+
+
+#ifdef __SPEECH_OVER_USB__
+UART_PORT SPEECH_PORT = (UART_PORT)(0);//uart_port_null;
+#endif
+
+kal_bool SP_Drv_Init_Bootup(void)
+{
+ return( KAL_TRUE );
+}
+
+void l1audio_console_handler(kal_char *string)
+{
+}
+
+void SP_Strm_Audl_Handler( ilm_struct *ilm_ptr )
+{
+}
+
+kal_bool SP_Drv_Init_Task(void)
+{
+ return KAL_TRUE;
+}
+
+void Audio_MedFuncReg(Media_Func_Reg_Type *func){
+ /*audio_alloc_aud_mem = (fp_audio_alloc_aud_mem) func->alloc_mem;
+ audio_alloc_aud_mem_cacheable = (fp_audio_alloc_aud_mem) func->alloc_mem_cacheable;
+ audio_free_aud_mem = (fp_audio_free_aud_mem) func->free_mem;
+ audio_set_path_vol = (fp_audio_set_path_volume)func->set_path_volume;
+ audio_get_active_mode = (fp_audio_get_active_mode)func->get_active_mode;
+ send_proc_call_req = (fp_send_proc_call_req) func->send_proc_call;
+ send_proc_call_req2 = (fp_send_proc_call_req) func->send_proc_call2;
+ audio_get_meta_file = (fp_get_meta_data_file) func->get_meta_file;
+ audio_get_meta_array = (fp_get_meta_data_array) func->get_meta_array;*/
+}
+
+void SpcIO_Msg_Handler_inAudL(ilm_struct *ilm_ptr){
+}
+
+void L1SP_SetNvramInfoByIndex(L1SP_NVRAM_INFO_INDEX index, uint8* buffer, uint16 len){}
+void L1SP_GetNvramInfoByIndex(L1SP_NVRAM_INFO_INDEX index, void *buffer, uint16 len){}
+void L1SP_LoadCommonSpeechPara( uint16 c_para[NUM_COMMON_PARAS] ){}
+void L1SP_SetOutputDevice( uint8 device ){}
+void L1SP_SetSpeechVolumeLevelByIndex(kal_uint8 level, kal_uint8 v_paraIndex){}
+void L1SP_SetInputSource( uint8 src ){}
+void L1SP_SetSpeechEnhanceAndFir(uint32 scene, uint32 updatedCoeff){}
+bool L1SP_IsMicrophoneMuted( void ){ return( false ); }
+void L1SP_MuteMicrophone( bool mute ){}
+void Media_SetMelodyFilter( uint16 len, const int16 *filter ){}
+// void Media_MuteSpeaker( bool mute ){}
+void KT_SetOutputDevice( uint8 device ){}
+void KT_SetFIR( bool enable ){}
+void KT_Play( uint16 freq1, uint16 freq2, uint16 duration, TONE_TYPE type ){}
+void KT_Stop( TONE_TYPE type ){}
+void TONE_SetOutputDevice( uint8 device ){}
+void TONE_SetFIR( bool enable ){}
+void TONE_Play( const L1SP_Tones *tonelist, TONE_TYPE type ){}
+void TONE_Stop( TONE_TYPE type ){}
+
+void SP4G_emac_timing_update(l1sp_emac_volte_timing_info_struct* p_timing_info){
+}
+void SP3G_SetDTX(kal_bool on){}
+void SP_M2M_Handler(ilm_struct *ilm_ptr){}
+void Spc_ForceEndAllApp(void){}
+
+
+//for VoLTE Tone and KeyTone
+void SP4G_PSR_DL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration){}
+void SP4G_PSR_DL_KT_Stop( void ){}
+void SP4G_PSR_UL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration){}
+void SP4G_PSR_UL_KT_Stop( void ){}
+void SP4G_PSR_UL_Tone_Play(const L1SP_Tones *pToneList ){}
+void SP4G_PSR_UL_Tone_Stop( void ){}
+void SP4G_PSR_DL_Tone_Play(const L1SP_Tones *pToneList ){}
+void SP4G_PSR_DL_Tone_Stop( void ){}
+//for VoLTE Link
+void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec){}
+kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec ){ return( 0 ); }
+void SP4G_PSR_Link_Deest(kal_uint32 id){}
+void SP4G_UL_SetFrameType(uint8 amr_frame_type){ (void) amr_frame_type; }
+kal_uint32 SP4G_JBM_GetDLVADFlag(){ return( 0 ); }
+//for VoLTE AMR codec
+void SP4G_PSR_UL_AMR_GetSpeechFrame(SP4G_Codec *frame_type, kal_uint8 *encodebits, kal_uint8 *bitlen, VoLTE_JBM_TS_Info_t *JBM_info){}
+void SP4G_PSR_DL_AMR_PutSpeechFrame(kal_uint32 CFN, SP4G_PSR_Codec codec, SP4G_Codec frame_type, kal_bool crc_status, kal_uint8 *encodebits, VoLTE_JBM_TS_Info_t *JBM_info){}
+void SP4G_PSR_SetDTX(kal_bool on){}
+void SP4G_SetDTX(kal_bool on){}
+kal_uint16 SP4G_PSR_GetCodecBitLength(SP4G_Codec codec){ return( 0 ); }
+//for VoLTE G serial codec
+void SP4G_PSR_UL_GSeries_GetSpeechFrame(SP4G_Codec *codec, kal_uint8 *encodebits, kal_uint8 *bitlen){}
+void SP4G_PSR_DL_GSeries_PutSpeechFrame(SP4G_Codec codec, kal_uint8 *encodebits, kal_uint8 *bitlen){}
+int SP4G_PSR_UL_GSeries_IsMoreData(void){ return( 0 ); }
+void SP4G_Set_G711Parameters(kal_int32 law, kal_int32 dec_init_CNG_enable){}
+//for VoLTE EVS codec
+//#if defined(__EVS_SUPPORT__)
+void SP4G_PSR_SetEVSEncCAPara(EVS_ENC_CA_PARAMETER *pEVS_CA_Par){}
+void SP4G_PSR_UL_EVS_GetSpeechFrame(SP4G_Codec *frame_type, kal_uint8 *encodebits, kal_uint32 *bitlen, VoLTE_JBM_TS_Info_t *JBM_info){}
+void SP4G_PSR_DL_EVS_PutSpeechFrame(kal_uint32 CFN, SP4G_Codec frame_type, kal_uint8 *encodebits, EVS_DEC_CA_PARAMETER *pEVS_Dec_CA_Par, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info){}
+kal_bool convert_EVSHeaderFullCMR_to_SP4GCodecEnum(kal_uint8 CMR_value, SP4G_Codec *pSP4G_Codec, EVS_ENC_CA_PARAMETER *pEVS_ENC_CA_PARAMETER){return KAL_TRUE;}
+kal_bool convert_EVSHeaderFullTOC_to_SP4GCodecEnum(kal_uint8 TOC_value, kal_uint8 EVS_band, SP4G_Codec *pSP4G_Codec){return KAL_TRUE;}
+kal_bool convert_EVSCompactFormatCMR_to_SP4GCodecEnum(kal_uint8 CMR_value, SP4G_Codec *pSP4G_Codec){return KAL_TRUE;}
+//#endif //#if defined(__EVS_SUPPORT__)
+//for sp_4g_opt
+kal_int32 SP4G_PSR_getToneDeteResult(void) { return( 0 ); }
+kal_int32 SP4G_PSR_getEarPhone(void) { return( 0 ); }
+//for fake VoLTE loopback
+void sp4g_fake_loopback(void){}
+
+
+//for MED
+//void aud_util_in_proc_call_req_hdlr(ilm_struct *ilm_ptr){}
+//typedef void (*media_in_proc_call_type) (kal_uint32 arg1, void *arg2);
+//void aud_send_in_proc_call_req( module_type src_mod_id, media_in_proc_call_type func, kal_uint32 func_arg1, void *func_arg2){}
+kal_uint16 get_spcGetEpofTimes(enum_EPOF_event EPOF_event){ return( 0 ); }
+void set_spcGetEpofTimes(enum_EPOF_event EPOF_event, int on){}
+void spc_sendCustomDump(void *ilm){}
+
+void SP_setEmCodecNotifyOff(bool isOff){}
+void SP_setEmVoiceQualityEvent(kal_bool isOn){}
+
+void SP_L2P_Handler(ilm_struct *ilm_ptr){}
+//for 4G TTY
+kal_bool TTY_LTE_PSR_UL_isEmpty(void){return KAL_TRUE;}
+kal_uint8 TTY_LTE_PSR_UL_Get(void){return 0;}
+kal_uint16 TTY_LTE_PSR_UL_Queue_Size(void){return 0;}
+
+kal_bool TTY_LTE_PSR_DL_isFull(void){return KAL_TRUE;}
+void TTY_LTE_PSR_DL_Put(kal_uint8 tty_char){}
+kal_uint16 TTY_LTE_PSR_DL_Queue_Size(void){return 0;}
+void TTY_LTE_PSR_UL_Queue_Init(){};
+void TTY_LTE_PSR_DL_Queue_Init(){};
+
+
+
+void *CUIF_U2C_ULTail_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+void *CUIF_U2C_DLTail_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+void *CUIF_U2C_ULHead_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+void *CUIF_U2C_DLHead_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+void *CUIF_U2C_SPEECH_AUX_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+void *CUIF_U2C_MMTail_ISR(CUIF_Mask_t* mask){ return NULL; }
+
+#if defined(__MD97__) || defined(__MD97P__)
+static struct {
+ uint32 dsp_first_init_done;
+} l1audio;
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+
+void SetFlag()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ //dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ if(0 == l1audio.dsp_first_init_done)
+ {
+ dsp_firstboot_activate_by_module(L1_MODULE_SPEECH);
+ l1audio.dsp_first_init_done = 1;
+ }
+ else
+ {
+ dsp_activate_by_module(L1_MODULE_SPEECH);
+ }
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_ACTIVATE_DONE != dsp_activate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;//kal_sleep_task( AUD_1TICK(1) );
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task( AUD_1TICK(1) );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void ClearFlag()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+
+ //dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ dsp_deactivate_by_module(L1_MODULE_SPEECH);
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_DEACTIVATE_DONE != dsp_deactivate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;//kal_sleep_task( AUD_1TICK(1) );
+ }
+
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+
+ dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ kal_sleep_task( AUD_1TICK(1) );
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void L1Audio_BootDSPSpeech()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //bool is_default_user;
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ //firstboot_activate(DSP_CONTROL_USIP1_SPEECH, DSP_CTRL_USIP_SPEECH);
+ if(0 == l1audio.dsp_first_init_done)
+ {
+ dsp_firstboot_activate_by_module(L1_MODULE_SPEECH);
+ l1audio.dsp_first_init_done = 1;
+ }
+ else
+ {
+ dsp_activate_by_module(L1_MODULE_SPEECH);
+ }
+
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_ACTIVATE_DONE != dsp_activate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //bool is_default_user;
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ firstboot_activate(DSP_CONTROL_USIP1_SPEECH, DSP_CTRL_USIP_SPEECH);
+
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ ;
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void L1Audio_UnBootDSPSpeech()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+ //dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ dsp_deactivate_by_module(L1_MODULE_SPEECH);
+ //while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_DEACTIVATE_DONE != dsp_deactivate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;
+ }
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+ dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ ;
+ }
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void L1Audio_UseDSPSpeech()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //bool is_default_user;
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ //dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ if(0 == l1audio.dsp_first_init_done)
+ {
+ dsp_firstboot_activate_by_module(L1_MODULE_SPEECH);
+ l1audio.dsp_first_init_done = 1;
+ }
+ else
+ {
+ dsp_activate_by_module(L1_MODULE_SPEECH);
+ }
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ //while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_ACTIVATE_DONE != dsp_activate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;
+ }
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //bool is_default_user;
+ //turn on power/clock API
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_TRUE);
+
+ dsp_uSIP_speech_activate(DSP_CTRL_USIP_SPEECH);
+ //is_default_user = is_myself_duty_rat(DSP_CTRL_USIP_SPEECH_SS1_INIT, DSP_CTRL_USIP_SPEECH);
+
+ while( uSIP_ACTIVEDONE != dsp_uSIP_speech_active_done_check(DSP_CTRL_USIP_SPEECH)){
+ ;
+ }
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void L1Audio_NotUseDSPSpeech()
+{
+#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+ //dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ dsp_deactivate_by_module(L1_MODULE_SPEECH);
+ //while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ while( DSP_CTRL_DEACTIVATE_DONE != dsp_deactivate_done_check_by_module(L1_MODULE_SPEECH) ){
+ ;
+ }
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+#else //#if defined(__MD97__) || defined(__MD97P__)
+ //turn off power/clock API
+ dsp_uSIP_speech_deactivate(DSP_CTRL_USIP_SPEECH);
+ while( uSIP_DEACTIVEDONE != dsp_uSIP_speech_deactive_done_check(DSP_CTRL_USIP_SPEECH)){
+ ;
+ }
+ MD_TOPSM_PWR_SW_Control(USIP0_PWR, KAL_FALSE);
+#endif //#if defined(__MD97__) || defined(__MD97P__)
+}
+
+void SP_SetUSIP_MPU_Info(void)
+{
+}
+
+void L1Audio_Task(unsigned argc, void *argv)
+{
+#ifdef __AUDIO_TASK_DISABLE__
+ return;
+#endif
+ L1Audio_BootDSPSpeech();
+ L1Audio_UnBootDSPSpeech();
+
+ //while(uSIP_BOOTDONE != uSIP_SPEECH_BootDoneCheck(uSIP_SPEECH_API_USE_NUM)){
+ // kal_sleep_task(AUD_1TICK(1));
+ //}
+
+ L1Audio_UseDSPSpeech();
+ //read/write DSP
+ L1Audio_NotUseDSPSpeech();
+}
+
+static void l1audio_main(task_entry_struct * task_entry_ptr)
+{
+ kal_set_active_module_id(MOD_L1SP);
+ L1Audio_Task( 0, 0 );
+}
+
+void SP_L4C_SetERTTSTR(uint8 call_id, uint8 string[256], uint16 length){};
+void SP_L4C_SendERTTSTR(){};
+void SPC2K_ConSSO_Req( uint16 u2SO, uint16 u2MaxEncRate){};
+void SPC2K_DisconSSO_Req( void ){};
+void SPC2K_DL_PutSpeechFrame_Do(IpcDsvSendSpkrVoiceFwdChPcktDataMsgT *MsgFLDataP){};
+
+
+void SPC2K_EncMaxRate_Set(IpcDsvSetMicVoiceEncMaxRateMsgT *pMsg){};
+void SPC2K_Debug_Info(IpcDsvSendAudioChanQltyMsgT * pMsg){};
+void SPC2K_SOCM_Set(IpcDsvSendSsoCtrlParamsMsgT *pMsg){};
+void SPC2K_ConSSO_Done_Rsp( void ){
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SSO_CONN_RSP_MSG, NULL);
+}
+void SPC2K_DisconSSO_Done_Rsp( void ){
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SSO_DISCONN_RSP_MSG, NULL);
+}
+
+void TTY_LTE_PSR_DL_PutString(kal_uint8 call_id, kal_uint8 string[256], kal_uint16 length)
+{
+}
+
+kal_uint16 TTY_LTE_PSR_UL_GetChar(kal_uint8 call_id, kal_uint8 *buf){
+ return 0;
+}
+
diff --git a/mcu/driver/audio/src/v1/dummy_lib.c b/mcu/driver/audio/src/v1/dummy_lib.c
new file mode 100644
index 0000000..42ff355
--- /dev/null
+++ b/mcu/driver/audio/src/v1/dummy_lib.c
@@ -0,0 +1,266 @@
+#include "audip_exp.h"
+#include "awb_exp.h"
+#include "bli_exp.h"
+#include "cvsd_codec_exp.h"
+#include "dtmf_exp.h"
+#include "g_series_exp.h"
+#include "g_series_union.h"
+#include "g711_exp.h"
+#include "g711plc_exp.h"
+#include "g722_exp.h"
+#include "g726_exp.h"
+#include "g729_exp.h"
+#include "g7231_exp.h"
+#include "msbc_codec_exp.h"
+int AWB_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int AWB_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+
+void BLI_GetMemSize(unsigned int inSR, /* Input, input sampling rate of the conversion */
+ unsigned int inChannel, /* Input, input channel number of the conversion */
+ unsigned int outSR, /* Input, output sampling rate of the conversion */
+ unsigned int outChannel, /* Input, output channel number of the conversion */
+ unsigned int *workBufSize){return ;} /* Output, the required working buffer size in byte */
+
+/*----------------------------------------------------------------------*/
+/* Get the BLI Software SRC handler. */
+/* Return: the handle of current BLI Software SRC */
+/*----------------------------------------------------------------------*/
+BLI_HANDLE *BLI_Open(unsigned int inSR, /* Input, input sampling rate of the conversion */
+ unsigned int inChannel, /* Input, input channel number of the conversion */
+ unsigned int outSR, /* Input, output sampling rate of the conversion */
+ unsigned int outChannel, /* Input, output channel number of the conversion */
+ signed char* buffer, /* Input, pointer to the working buffer */
+ void *(*custom_alloc)(unsigned int)){return 0;}
+unsigned int BLI_Convert(void *hdl, /* Input, handle of this conversion */
+ short *inBuf, /* Input, pointer to input buffer */
+ unsigned int *inLength, /* Input, length(byte) of input buffer */
+ /* Output, length(byte) left in the input buffer after conversion */
+ short *outBuf, /* Input, pointer to output buffer */
+ unsigned int *outLength){return 0;}
+
+/*----------------------------------------------------------------------*/
+/* Close the process */
+/*----------------------------------------------------------------------*/
+void BLI_Close( void *hdl,
+ void (*custom_free) (void *)){return ;}
+
+
+/*----------------------------------------------------------------------*/
+/* Change the input sampling rate during the process */
+/* Return: error code, 0 represents "everything is OK" */
+/*----------------------------------------------------------------------*/
+int BLI_SetSamplingRate(void *hdl,
+ unsigned int inSR){return 0;} /* Input, input sampling rate of the conversion */
+
+/*----------------------------------------------------------------------*/
+/* Clear the internal status for the discontinuous input buffer */
+/*----------------------------------------------------------------------*/
+int BLI_Reset(void *hdl){return 0;}
+void CVSD_DEC_Process(
+ void *pHandle, //handle
+ char *pInBuf, //input CVSD packet
+ int *pInLen, //input length (Byte)
+ short *pOutBuf, //output Sample
+ int *pOutLen //output length (Word)
+){return;}
+
+void CVSD_ENC_Process(
+ void *pHandle, //handle
+ short *pInBuf, //input Samples
+ int *pInLen, //input length (word)
+ char *pOutBuf, //CVSD packet
+ int *pOutLen //output Length (byte)
+){return;}
+int CVSD_DEC_GetBufferSize( void ){return 0;}
+int CVSD_ENC_GetBufferSize( void ){return 0;}
+void *CVSD_DEC_Init(char *pBuffer ){return 0;}
+void *CVSD_ENC_Init(char *pBuffer ){return 0;}
+DTMF_STATUS DTMF_GetBufferSize( unsigned int *InterBufSize,
+ unsigned int *PcmBufSize,
+ DTMF_SR samplerate,
+ DTMF_CHANNEL channel
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_Init
+ *
+ * DESCRIPTION
+ * This function initializes DTMF Generator.
+ *
+ * PARAMETERS
+ * InterBuf Internal buffer
+ * channel Output channels, DTMF_MONO --> mono, DTMF_STEREO --> stereo
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+void* DTMF_Init( void *InterBuf,
+ DTMF_MODE mode,
+ DTMF_SR samplerate,
+ DTMF_CHANNEL channel
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_Gen
+ *
+ * DESCRIPTION
+ * This function generates PCM data of DTMF tones.
+ *
+ * PARAMETERS
+ * PcmBuf Output PCM buffer
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_Gen( void *hdl,
+ void *PcmBuf
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_Tone
+ *
+ * DESCRIPTION
+ * This function is used to turn on/off DTMF tones
+ *
+ * PARAMETERS
+ * key Specify a key
+ * dtmfswitch 1 --> press the key, 0 --> release the key
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_Tone( void *hdl,
+ DTMF_KEY key,
+ int dtmfswitch
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_SetDuration
+ *
+ * DESCRIPTION
+ * This function specifies the DTMF duration of each tone on FIXDURATION mode.
+ *
+ * PARAMETERS
+ * duration To specify the frame counts
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_SetDuration( void *hdl,
+ unsigned int duration
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_GetKey
+ *
+ * DESCRIPTION
+ * This function is used to get the frequency of specified key.
+ *
+ * PARAMETERS
+ * key Specify a key
+ * freq1 Frequency of the first tone
+ * freq2 Frequency of the second tone
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_GetKey( void *hdl,
+ DTMF_KEY key,
+ int *freq1,
+ int *freq2
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_SetKey
+ *
+ * DESCRIPTION
+ * This function is used to define the frequency of DTMF tone.
+ *
+ * PARAMETERS
+ * key Specify a key
+ * freq1 Frequency of the first tone
+ * freq2 Frequency of the second tone
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_SetKey( void *hdl,
+ DTMF_KEY key,
+ int freq1,
+ int freq2
+ ){return 0;}
+
+/*****************************************************************************
+ * FUNCTION
+ * DTMF_SetGain
+ *
+ * DESCRIPTION
+ * This function is used to set the digital gain of each DTMF tone.
+ *
+ * PARAMETERS
+ * gain Digital gain, ranges from 0~0x3FFF
+ *
+ * RETURNS
+ * DTMF_Status
+ *****************************************************************************
+ */
+DTMF_STATUS DTMF_SetGain( void *hdl,
+ int gain
+ ){return 0;}
+int G711PLC_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G711_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G711_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+void G711PLC_AddToHistory(G_Series_Handle *p_handle, short *pcm_buffer){return ;}
+void G711PLC_DoPLC(G_Series_Handle *p_handle, short *pcm_buffer){return ;}
+int G722_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G722_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G7231_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G7231_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G726_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G726_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G729_Enc_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G729_Dec_Set_Handle(G_Series_Handle *p_handle){return 0;}
+int G729B_Get_VAD(G_Series_Handle *p_handle, void *p_temp_buffer, short *speech_in){return 0;}
+int MSBC_DEC_Process(
+ void *pHandle, //handle
+ char *pInBuf, //input MSBC packet
+ int *pInLen, //input length (Byte)
+ short *pOutBuf, //output Sample
+ int *pOutLen //output length (Word)
+){return 0;}
+
+int MSBC_ENC_Process(
+ void *pHandle, //handle
+ short *pInBuf, //input Samples
+ int *pInLen, //input length (word)
+ char *pOutBuf, //MSBC packet
+ int *pOutLen //output Length (byte)
+){return 0;}
+int MSBC_DEC_GetBufferSize( void ){return 0;}
+int MSBC_ENC_GetBufferSize( void ){return 0;}
+void *MSBC_DEC_Init(char *pBuffer ){return 0;}
+void *MSBC_ENC_Init(char *pBuffer ){return 0;}
+
+void g711plc_addtohistory_v2(void *lc, short *s, unsigned int dwBtEv3HalfBad){return ;}
+void g711plc_dofe_v2(void *lc, short *s, unsigned int dwBtEv3HalfBad){return ;}
+int g711plc_GetMemorySize_v2(){return 0;}
+int g711plc_construct_v2(void *lc, unsigned int dwFs){return 0;}
+
+void CVSD_DownSample_Process(void *pHandle, short *pInSample, short *pOutSample, short *pTempBuffer, int iSourceSamples){return ;}
+int CVSD_DownSample_GetMemory(void){return 0;}
+void *CVSD_DownSample_Init(char *pBuffer){return 0;}
+void CVSD_UpSample_Process(void *pHandle, short *pInSample, short *pOutSample, short *pTempBuffer, int iSourceSamples){return ;}
+int CVSD_UpSample_GetMemory(void){return 0;}
+void *CVSD_UpSample_Init(char *pBuffer){return 0;}
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/eCall_drv.c b/mcu/driver/audio/src/v1/eCall_drv.c
new file mode 100644
index 0000000..787dfda
--- /dev/null
+++ b/mcu/driver/audio/src/v1/eCall_drv.c
@@ -0,0 +1,1312 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * eCall_drv.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * eCall Modem Driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include <stdio.h>
+#include "ecall_defines.h"
+#include "ecall_control.h"
+#include "modemx.h"
+
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "l1audio.h"
+#include "pcm4way.h"
+#include "am.h"
+#include "media.h"
+#include "sp_enhance.h"
+#include "bli_exp.h"
+#include "spc_drv.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+
+
+Int16 eCall_TX_CTRL_SEQ_State[800];
+Int16 eCall_TX_CTRL_SEQ_dlData[800];
+Int16 eCall_TX_CTRL_SEQ_dlMetric[800];
+Int16 eCall_RX_CTRL_SEQ_State[800];
+Int16 eCall_RX_CTRL_SEQ_dlData[800];
+Int16 eCall_RX_CTRL_SEQ_dlMetric[800];
+Int16 eCall_RX_Ctrl_Index;
+
+#define PCM_FIFO_LEN 2 // could be 1 ~ N
+#define ECALL_SWB_BUF_LEN 640 // 32k*20ms = 640
+#define ECALL_WB_BUF_LEN 320 // 16k*20ms = 320
+#define ECALL_NB_BUF_LEN 160 // 8k*20ms = 160
+
+typedef enum {
+ Udef = -1, Ivs, IvsRx, IvsTx, Psap, PsapRx, PsapTx
+} RunMode;
+
+typedef struct {
+ RunMode mode;
+
+ kal_bool ivsPush;
+ kal_bool msdReceived;
+ kal_bool msdSet;
+ kal_uint8 aud_id;
+ kal_uint8 Ctrl_Par_Switch;
+ kal_bool TxRx;
+
+ int frameStartHlack;
+ int frameStartHlackCur;
+
+ Ord8 NewMsd[ECALL_MSD_MAX_LENGTH];
+ Ord8 CurMsd[ECALL_MSD_MAX_LENGTH];
+
+ // For PCM4Way
+ kal_uint16 pcm_fifo_read;
+ kal_uint16 pcm_fifo_write;
+ kal_uint16 next_to_process;
+ kal_uint16 reserve_2byte;
+
+ // speech-channel PCM buffer
+ // Input from PCM4WAY
+ kal_uint16 ul_pcm_input[2*PCM_FIFO_LEN][ECALL_SWB_BUF_LEN]; // input buffer size = 640
+ kal_uint16 dl_pcm_input[2*PCM_FIFO_LEN][ECALL_SWB_BUF_LEN];
+
+ kal_uint16 ul_pcm_input_len[2*PCM_FIFO_LEN];
+ kal_uint16 dl_pcm_input_len[2*PCM_FIFO_LEN];
+
+ // SRC temp buffer (NB 8k only)
+ kal_uint16 ul_pcm_fifo[2*PCM_FIFO_LEN][ECALL_NB_BUF_LEN]; // input buffer size = 160
+ kal_uint16 dl_pcm_fifo[2*PCM_FIFO_LEN][ECALL_NB_BUF_LEN];
+
+ // Output to PCM4WAY
+ kal_uint16 ul_pcm_output_nb[2*PCM_FIFO_LEN][ECALL_NB_BUF_LEN]; //160
+ kal_uint16 ul_pcm_output_wb[2*PCM_FIFO_LEN][ECALL_WB_BUF_LEN]; //320
+ kal_uint16 ul_pcm_output_swb[2*PCM_FIFO_LEN][ECALL_SWB_BUF_LEN]; //640
+
+ kal_bool isUpdateUL[2*PCM_FIFO_LEN];
+
+ // SRC handler internal buffer
+ // 32k <-> 8k
+ kal_uint8 internal_buf_ul_out[2184]; // internal buffer for src
+ kal_uint8 internal_buf_dl_in[2184]; // internal buffer for src
+ // 16k <-> 8k
+ kal_uint8 internal_buf_ul_out2[2184]; // internal buffer for src
+ kal_uint8 internal_buf_dl_in2[2184]; // internal buffer for src
+
+
+ BLI_HANDLE * dl_downsample_16_8;
+ BLI_HANDLE * dl_downsample_32_8;
+ BLI_HANDLE * ul_upsample_8_16;
+ BLI_HANDLE * ul_upsample_8_32;
+
+ // For HRT
+ kal_uint16 HRT_status;
+ kal_uint16 HRT_status_backup;
+
+ eCall_Callback handler;
+
+ void *allocMem;
+} EcallShell;
+
+static EcallShell *eCallModemIVS;
+static EcallShell *eCallModemPSAP;
+
+kal_enhmutexid eCall_mutex;
+
+/*------------------------------------------------*/
+/* The private functions of eCall modem driver. */
+/*------------------------------------------------*/
+//#pragma arm section code="SECONDARY_ROCODE"
+void eCall_Init(void)
+{
+ eCall_mutex= kal_create_enh_mutex( "ECALL_MUTEX" );
+}
+
+static void eCall_HRT_Set(void)
+{
+ eCallModemIVS->HRT_status = 1;
+}
+
+static void eCall_HRT_Clean(void)
+{
+ eCallModemIVS->HRT_status = 0;
+}
+
+static void eCall_IVS_hisr(void)
+{
+ kal_uint16 read_idx, write_idx;
+
+ if (eCallModemIVS == NULL)
+ return;
+
+ read_idx = eCallModemIVS->pcm_fifo_read;
+ write_idx = eCallModemIVS->pcm_fifo_write;
+
+ if (eCallModemIVS->pcm_fifo_read == eCallModemIVS->next_to_process) {
+ // Processed data isn't enough
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_ENABLE ){
+ PCM4WAY_FillSE(0);
+ PCM4WAY_FillSpk(0);
+ }
+
+ } else {
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_ENABLE ) {
+ // uplink-path
+ if (eCallModemIVS->isUpdateUL[read_idx] == KAL_FALSE) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemIVS->ul_pcm_input[read_idx]));
+
+ } else {
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_PNW_BUF_M2D_UL1);
+ if(ECALL_NB_BUF_LEN == bufLen) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemIVS->ul_pcm_output_nb[read_idx]));
+
+ } else if(ECALL_WB_BUF_LEN == bufLen) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemIVS->ul_pcm_output_wb[read_idx]));
+
+ } else {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemIVS->ul_pcm_output_swb[read_idx]));
+ }
+
+ eCallModemIVS->isUpdateUL[read_idx] = KAL_FALSE;
+ MD_TRC_ECALL_IVS_PCM_UPDATE_PUTTOSE(read_idx, bufLen);
+ }
+
+ // downlink-path no change
+ PCM4WAY_PutToSpk((const uint16*)(eCallModemIVS->dl_pcm_input[read_idx]));
+ }
+
+ // Update index
+ eCallModemIVS->pcm_fifo_write++;
+ if (eCallModemIVS->pcm_fifo_write == 2*PCM_FIFO_LEN) {
+ eCallModemIVS->pcm_fifo_write = 0;
+ }
+ }
+ if (read_idx != write_idx) {
+ // There is enough space to write data from microphone
+ eCallModemIVS->ul_pcm_input_len[write_idx] = PCM4WAY_GetFromMic((uint16*)(eCallModemIVS->ul_pcm_input[write_idx]));
+ eCallModemIVS->dl_pcm_input_len[write_idx] = PCM4WAY_GetFromSD((uint16*)(eCallModemIVS->dl_pcm_input[write_idx]));
+ MD_TRC_ECALL_IVS_PCM_INPUT_LEN(write_idx, eCallModemIVS->ul_pcm_input_len[write_idx], write_idx, eCallModemIVS->dl_pcm_input_len);
+
+ // Update index
+ eCallModemIVS->pcm_fifo_read++;
+ if (eCallModemIVS->pcm_fifo_read == 2*PCM_FIFO_LEN) {
+ eCallModemIVS->pcm_fifo_read = 0;
+ }
+ }
+
+ eCallModemIVS->HRT_status_backup = eCallModemIVS->HRT_status;
+ eCall_HRT_Set();
+
+ L1Audio_SetEvent(eCallModemIVS->aud_id, (void*)0);
+}
+//#pragma arm section
+
+static void eCall_IVS_ProcessFrame(void)
+{
+ kal_uint32 proc_idx;
+
+ // Here we only do DL downsample, UL upsample
+ kal_uint32 dl_ds_inLen, dl_ds_outLen;
+ kal_uint32 ul_us_inLen, ul_us_outLen;
+
+ kal_uint16 *p_dl_ds_inBuf, *p_dl_ds_outBuf;
+ kal_uint16 *p_ul_us_inBuf, *p_ul_us_outBuf;
+
+ if (eCallModemIVS == NULL)
+ return;
+
+ proc_idx = eCallModemIVS->next_to_process;
+
+ switch (eCallModemIVS->mode) {
+ case Ivs:
+ if (eCallModemIVS->ivsPush == KAL_TRUE) {
+ IvsSendStart();
+ eCallModemIVS->ivsPush = KAL_FALSE;
+ }
+
+ /******************************************************
+ * dl_pcm_input -> dl_pcm_fifo -> dl_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [ECALLLIB] *
+ ******************************************************/
+
+ /* [ECALL blisrc] DL downsample start */
+ p_dl_ds_inBuf = eCallModemIVS->dl_pcm_input[proc_idx];
+ p_dl_ds_outBuf = eCallModemIVS->dl_pcm_fifo[proc_idx];
+
+ if(ECALL_WB_BUF_LEN == eCallModemIVS->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_WB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemIVS->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else if(ECALL_SWB_BUF_LEN ==eCallModemIVS->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_SWB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemIVS->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, ECALL_NB_BUF_LEN << 1);
+ }
+ /* [ECALL blisrc] DL downsample end */
+
+#if 1
+ {
+ IvsState preRxState = IvsRxGetState();
+ IvsState curState;
+
+ IvsProcess((Int16 *)eCallModemIVS->dl_pcm_fifo[proc_idx]);
+
+ curState = IvsTxGetState();
+ if ((curState == IvsTrigger) || (curState == IvsStart) || (curState == IvsSendMsd) || (preRxState != IvsIdle) || (IvsRxGetState() != IvsIdle)) {
+ memcpy(eCallModemIVS->ul_pcm_fifo[proc_idx], eCallModemIVS->dl_pcm_fifo[proc_idx], ECALL_NB_BUF_LEN*sizeof(kal_uint16));
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [ECALLLIB] <- [BAUDOT] *
+ *****************************************************/
+
+ /* [ECALL blisrc] UL up sampling start */
+ //NB output
+ p_ul_us_inBuf = eCallModemIVS->ul_pcm_fifo[proc_idx];
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_nb[proc_idx];
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, ECALL_NB_BUF_LEN << 1);
+
+ //WB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_wb[proc_idx];
+ BLI_Convert(eCallModemIVS->ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ //SWB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_swb[proc_idx];
+ BLI_Convert(eCallModemIVS->ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+ /* [ECALL blisrc] UL up sampling end */
+
+ eCallModemIVS->isUpdateUL[proc_idx] = KAL_TRUE;
+ MD_TRC_ECALL_IVS_PCM_UPDATE_UL(proc_idx, curState, proc_idx, eCallModemIVS->isUpdateUL[proc_idx]);
+ }
+ }
+
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ break;
+ case IvsRx:
+ if (eCallModemIVS->ivsPush == KAL_TRUE) {
+ IvsSendStart();
+ eCallModemIVS->ivsPush = KAL_FALSE;
+ }
+
+ /******************************************************
+ * dl_pcm_input -> dl_pcm_fifo -> dl_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [ECALLLIB] *
+ ******************************************************/
+
+ /* [ECALL blisrc] DL downsample start */
+ p_dl_ds_inBuf = eCallModemIVS->dl_pcm_input[proc_idx];
+ p_dl_ds_outBuf = eCallModemIVS->dl_pcm_fifo[proc_idx];
+
+ if(ECALL_WB_BUF_LEN == eCallModemIVS->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_WB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemIVS->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else if(ECALL_SWB_BUF_LEN ==eCallModemIVS->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_SWB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemIVS->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, ECALL_NB_BUF_LEN << 1);
+ }
+ /* [ECALL blisrc] DL downsample end */
+
+#if 1
+ {
+ IvsState preRxState = IvsRxGetState();
+ IvsState curState;
+
+ IvsProcess((Int16 *)eCallModemIVS->dl_pcm_fifo[proc_idx]);
+
+ curState = IvsTxGetState();
+ if ((curState == IvsTrigger) || (curState == IvsStart) || (curState == IvsSendMsd) || (preRxState != IvsIdle) || (IvsRxGetState() != IvsIdle)) {
+ memcpy(eCallModemIVS->ul_pcm_fifo[proc_idx], eCallModemIVS->dl_pcm_fifo[proc_idx], ECALL_NB_BUF_LEN*sizeof(kal_uint16));
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [ECALLLIB] <- [BAUDOT] *
+ *****************************************************/
+
+ /* [ECALL blisrc] UL up sampling start */
+ //NB output
+ p_ul_us_inBuf = eCallModemIVS->ul_pcm_fifo[proc_idx];
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_nb[proc_idx];
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, ECALL_NB_BUF_LEN << 1);
+
+ //WB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_wb[proc_idx];
+ BLI_Convert(eCallModemIVS->ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ //SWB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemIVS->ul_pcm_output_swb[proc_idx];
+ BLI_Convert(eCallModemIVS->ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+ /* [ECALL blisrc] UL up sampling end */
+
+ eCallModemIVS->isUpdateUL[proc_idx] = KAL_TRUE;
+ MD_TRC_ECALL_IVS_PCM_UPDATE_UL(proc_idx, curState, proc_idx, eCallModemIVS->isUpdateUL[proc_idx]);
+ }
+ }
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+}
+
+static void eCall_IVS_ProcessTask(void *data)
+{
+ kal_take_enh_mutex( eCall_mutex);
+ if (eCallModemIVS == NULL) {
+ kal_give_enh_mutex( eCall_mutex);
+ return;
+ }
+
+ if (eCallModemIVS->HRT_status_backup != 0)
+ {
+ MD_TRC_ECALL_IVS_HRT_STATUS(eCallModemIVS->HRT_status_backup);
+ }
+
+ while (eCallModemIVS->next_to_process != eCallModemIVS->pcm_fifo_write) {
+ // Process each frame
+ eCall_IVS_ProcessFrame();
+
+ // Update index
+ eCallModemIVS->next_to_process++;
+ if (eCallModemIVS->next_to_process == 2 * PCM_FIFO_LEN) {
+ eCallModemIVS->next_to_process = 0;
+ }
+
+ eCall_HRT_Clean();
+ }
+ kal_give_enh_mutex( eCall_mutex);
+}
+
+static void eCall_IVS_OnHandler( void *data )
+{
+ (void)data;
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_ENABLE )
+ {
+
+ PCM4WAY_Start(eCall_IVS_hisr, 0);
+ }
+ else
+ {
+ PCM4WAY_Start(eCall_IVS_hisr, 4);
+ }
+}
+
+static void eCall_IVS_OffHandler( void *data )
+{
+ (void)data;
+
+ PCM4WAY_Stop(0);
+}
+
+/*------------------------------------------------*/
+/* The public functions of eCall modem driver. */
+/*------------------------------------------------*/
+eCall_Modem_Status eCall_IVS_Open(eCall_Callback handler)
+{
+ ASSERT( handler != NULL );
+
+ MD_TRC_ECALL_IVS_DRV_OPEN(spc_Get_Ecall_Lib_Status());
+
+ if (eCallModemPSAP != NULL) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( eCallModemIVS != NULL ) {
+ return eCALL_OPERATION_ALREADY_OPEN;
+ }
+
+ //L1SP_EnableSpeechEnhancement(KAL_FALSE);
+
+ //eCallModemIVS = (EcallShell *)audio_alloc_mem_cacheable( sizeof(EcallShell) );
+ eCallModemIVS = (EcallShell *)get_ctrl_buffer( sizeof(EcallShell) );
+ ASSERT( eCallModemIVS != NULL );
+ memset(eCallModemIVS, 0, sizeof(EcallShell));
+
+ // Allocate for IVS internal structure
+ {
+ kal_uint32 reqSize;
+
+ reqSize = (kal_uint32) IvsGetMemSize();
+ // eCallModemIVS->allocMem = (void *)audio_alloc_mem_cacheable( reqSize );
+ eCallModemIVS->allocMem = (void *)get_ctrl_buffer( reqSize );
+ memset(eCallModemIVS->allocMem, 0, sizeof(reqSize));
+ IvsInit( eCallModemIVS->allocMem );
+
+ if (eCallModemIVS->allocMem == NULL) {
+ MD_TRC_ECALL_IVS_DRV_ALLOCMEM_NULL();
+ }
+ }
+
+ // open BLI Src for ecall
+ // 32k <-> 8k
+ eCallModemIVS->dl_downsample_32_8 = BLI_Open(32000, 1, 8000, 1, (signed char*)eCallModemIVS->internal_buf_dl_in, 0); // open DL down sampling src
+ eCallModemIVS->ul_upsample_8_32 = BLI_Open(8000, 1, 32000, 1, (signed char*)eCallModemIVS->internal_buf_ul_out, 0); // open UL up sampling src
+ // 16k <-> 8k
+ eCallModemIVS->dl_downsample_16_8 = BLI_Open(16000, 1, 8000, 1, (signed char*)eCallModemIVS->internal_buf_dl_in2, 0); // open DL down sampling src
+ eCallModemIVS->ul_upsample_8_16 = BLI_Open(8000, 1, 16000, 1, (signed char*)eCallModemIVS->internal_buf_ul_out2, 0); // open UL up sampling src
+
+ eCallModemIVS->aud_id = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler(eCallModemIVS->aud_id , eCall_IVS_ProcessTask);
+ L1Audio_SetFlag(eCallModemIVS->aud_id);
+
+ IvsRxReset();
+
+ eCallModemIVS->mode = IvsRx;
+ eCallModemIVS->pcm_fifo_read = 0;
+ eCallModemIVS->pcm_fifo_write = PCM_FIFO_LEN;
+ eCallModemIVS->next_to_process = PCM_FIFO_LEN;
+ eCallModemIVS->handler = handler;
+
+ for (int i=0; i<2*PCM_FIFO_LEN; i++) {
+ eCallModemIVS->isUpdateUL[i] = KAL_FALSE;
+ }
+
+ //Init eCall RX ctrl seq
+ memset(eCall_RX_CTRL_SEQ_State, 0, 800*sizeof(Int16));
+ memset(eCall_RX_CTRL_SEQ_dlData, 0, 800*sizeof(Int16));
+ memset(eCall_RX_CTRL_SEQ_dlMetric, 0, 800*sizeof(Int16));
+ eCall_RX_Ctrl_Index = 1;
+ eCall_RX_CTRL_SEQ_dlMetric[0] = 0xFF;
+ eCall_RX_CTRL_SEQ_State[0] = 0xDD;
+ eCall_RX_CTRL_SEQ_dlData[0] = 0xEE;
+
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_SDT_ONLY ){
+ Ivs_Set_Ecall_Lib_Status(Ivs_ECALL_SDT_ONLY);
+ }else if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_ENABLE){
+ Ivs_Set_Ecall_Lib_Status(Ivs_ECALL_ENABLE);
+ }else {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( AM_IsSpeechOn() ) {
+ eCall_IVS_OnHandler( (void *)0 );
+ }
+
+ // Hook service to L1SP
+ L1SP_Register_Pcm4WayService( eCall_IVS_OnHandler, eCall_IVS_OffHandler );
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+eCall_Modem_Status eCall_IVS_Close(void)
+{
+ MD_TRC_ECALL_IVS_DRV_CLOSE();
+ kal_take_enh_mutex( eCall_mutex);
+ if ( eCallModemIVS == NULL ) {
+ kal_give_enh_mutex( eCall_mutex);
+ return eCALL_OPERATION_ALREADY_CLOSE;
+ }
+
+ if (eCallModemPSAP != NULL) {
+ kal_give_enh_mutex( eCall_mutex);
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_DISABLE){
+ kal_give_enh_mutex( eCall_mutex);
+ return eCALL_OPERATION_FAIL;
+ }
+ // Unhook service to L1SP
+ L1SP_UnRegister_Pcm4Way_Service();
+
+ if ( AM_IsSpeechOn() ) {
+ eCall_IVS_OffHandler( (void *)0 );
+ }
+
+ L1Audio_ClearFlag(eCallModemIVS->aud_id);
+ L1Audio_FreeAudioID(eCallModemIVS->aud_id);
+
+ BLI_Close(eCallModemIVS->dl_downsample_16_8, 0); // Close DL down sampling src
+ BLI_Close(eCallModemIVS->dl_downsample_32_8, 0); // Close DL down sampling src
+ BLI_Close(eCallModemIVS->ul_upsample_8_16, 0); // Close UL up sampling src
+ BLI_Close(eCallModemIVS->ul_upsample_8_32, 0); // Close UL up sampling src
+
+ // Deallocate for IVS internal structure
+ {
+ IvsDeinit();
+ if (eCallModemIVS->allocMem == NULL) {
+ MD_TRC_ECALL_IVS_DRV_ALLOCMEM_NULL();
+
+ } else {
+ free_ctrl_buffer( (void *) eCallModemIVS->allocMem );
+ }
+ }
+
+ free_ctrl_buffer( (void *) eCallModemIVS );
+ //L1SP_EnableSpeechEnhancement(KAL_TRUE);
+ eCallModemIVS = NULL;
+
+ //transfer ctrl data to AP
+ spc_eCall_RX_CTRL_Data(0xDD);
+ spc_eCall_RX_CTRL_Data(0xEE);
+ spc_eCall_RX_CTRL_Data(0xFF);
+
+ kal_give_enh_mutex( eCall_mutex);
+ return eCALL_OPERATION_SUCCESS;
+}
+
+eCall_Modem_Status eCall_IVS_PutMSD(const kal_uint8 *pMSD, const kal_uint32 uLen, kal_uint8 from)
+{
+ kal_uint8 i=0;
+ if (eCallModemPSAP != NULL) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( eCallModemIVS == NULL ) {
+ return eCALL_OPERATION_FAIL;
+ }
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_SDT_ONLY)
+ {
+ return eCALL_OPERATION_STOP;
+ }
+ ASSERT( pMSD != NULL );
+ ASSERT( uLen <= ECALL_MSD_MAX_LENGTH);
+
+ memset(eCallModemIVS->NewMsd, 0, ECALL_MSD_MAX_LENGTH*sizeof(Ord8));
+ memcpy(eCallModemIVS->NewMsd, pMSD, uLen*sizeof(Ord8));
+// for(i=0;i<140;i=i+7)
+// {
+// MD_TRC_ECALL_IVS_DRV_PUT_MSD(pMSD[i],pMSD[i+1],pMSD[i+2],pMSD[i+3],pMSD[i+4],pMSD[i+5],pMSD[i+6]);
+// }
+ // Check status and copy to current MSD
+ //if ( IvsTxGetState() == IvsIdle ) {
+ memcpy(eCallModemIVS->CurMsd, eCallModemIVS->NewMsd, ECALL_MSD_MAX_LENGTH*sizeof(Ord8));
+ //}
+ for(i=0;i<140;i=i+7)
+ {
+ MD_TRC_ECALL_IVS_DRV_PUT_MSD(eCallModemIVS->CurMsd[i],eCallModemIVS->CurMsd[i+1],eCallModemIVS->CurMsd[i+2],eCallModemIVS->CurMsd[i+3],eCallModemIVS->CurMsd[i+4],eCallModemIVS->CurMsd[i+5],eCallModemIVS->CurMsd[i+6]);
+ }
+
+ // 0: Internal, 1:L5
+ if (from == 1) {
+ eCallModemIVS->msdSet = KAL_TRUE;
+ }
+ MD_TRC_ECALL_IVS_DRV_MSD_SET(from, eCallModemIVS->msdSet);
+
+ IvsTxReset(eCallModemIVS->CurMsd, ECALL_MSD_MAX_LENGTH);
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+eCall_Modem_Status eCall_IVS_SendStart(void)
+{
+ MD_TRC_ECALL_IVS_DRV_SEND_START();
+ if (eCallModemPSAP != NULL) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( eCallModemIVS == NULL ) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ // Check state
+ if ( IvsTxGetState() != IvsIdle ) {
+ return eCALL_OPERATION_DURING_TRANSMISSION;
+ }
+ if(spc_Get_Ecall_Lib_Status()==SPC_ECALL_DISABLE){
+ return eCALL_OPERATION_FAIL;
+ }
+ eCallModemIVS->TxRx = KAL_TRUE;
+ IvsRxReset();
+
+ if (eCallModemIVS->msdSet) {
+ eCallModemIVS->mode = Ivs;
+ }
+
+ eCallModemIVS->ivsPush = KAL_TRUE;
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+
+#if 1
+/*------------------------------------------------*/
+/* The unit test code for callback. */
+/*------------------------------------------------*/
+
+void IvsCatchEvent(IvsEvent ie)
+{
+ ASSERT(eCallModemIVS);
+
+ MD_TRC_ECALL_IVS_DRV_CATCH_EVENT(ie);
+
+ /* custom event handlers to be implemented here... */
+ /* see modemx.h for a list of possible events (enum IvsEvent) */
+ switch (ie) {
+ case IVSEVENT_SENDINGMSD:
+ #if defined(__L5_SUPPORT__)
+ if (eCallModemIVS->msdSet) {
+ spc_L5ECALL_Status_Info_Callback(0xE1,0);
+ } else {
+ MD_TRC_ECALL_IVS_DRV_MSD_NOT_SET();
+ }
+ #else
+ spc_eCall_Handshake_Info_Notify(0xE1,0);
+ #endif
+ break;
+ case IVSEVENT_CONTROLLOCK:
+ eCallModemIVS->mode = Ivs;
+ eCallModemIVS->TxRx = KAL_TRUE;
+ eCallModemIVS->handler( eCALL_EVENT_RECV_START, NULL);
+ break;
+ case IVSEVENT_NACKRECEIVED:
+ eCallModemIVS->handler( eCALL_EVENT_RECV_NACK, NULL);
+ break;
+ case IVSEVENT_LLACKRECEIVED:
+ #if defined(__L5_SUPPORT__)
+ spc_L5ECALL_Status_Info_Callback(0xE2,0);
+ #else
+ spc_eCall_Handshake_Info_Notify(0xE2,0);
+ #endif
+ eCallModemIVS->handler( eCALL_EVENT_RECV_LL_ACK, NULL);
+ break;
+ case IVSEVENT_HLACKRECEIVED:
+ eCallModemIVS->mode = IvsRx;
+ break;
+ case IVSEVENT_RECEIVESTART:
+ #if defined(__L5_SUPPORT__)
+ spc_L5ECALL_Status_Info_Callback(0xE4,0);
+ #else
+ spc_eCall_Handshake_Info_Notify(0xE4,0);
+ #endif
+ break;
+ default:
+ break;
+ }
+}
+
+void IvsReceiveHlack(const Ord8 data)
+{
+ MD_TRC_ECALL_IVS_DRV_HLACK((eCallModemIVS->CurMsd[0] & 0x0F), (data & 0x0F));
+ #if defined(__L5_SUPPORT__)
+ spc_L5ECALL_Status_Info_Callback(0xE3,data);
+ #else
+ spc_eCall_Handshake_Info_Notify(0xE3,data);
+ #endif
+
+ if ((eCallModemIVS->CurMsd[0] & 0x0F) == (data & 0x0F)) {
+ //eCallModemIVS->handler( eCALL_EVENT_RECV_HL_ACK_CORRECT, (void *)data); //NEED TO CHECK
+ } else {
+ //eCallModemIVS->handler( eCALL_EVENT_RECV_HL_ACK_MISMATCH, (void *)data);
+ }
+ IvsRxReset();
+ IvsTxReset(eCallModemIVS->CurMsd, ECALL_MSD_MAX_LENGTH);
+ eCallModemIVS->TxRx = KAL_FALSE;
+}
+
+void PsapCatchEvent(PsapEvent pe)
+{
+ MD_TRC_ECALL_PSAP_DRV_CATCH_EVENT(pe);
+
+ switch (pe) {
+ /* custom event handlers to be implemented here... */
+ /* see modemx.h for a list of possible events (enum PsapEvent) */
+ case PSAPEVENT_CONTROLLOCK:
+ eCallModemPSAP->TxRx = KAL_TRUE;
+ break;
+ case PSAPEVENT_IDLEPOSTHLACK:
+ PsapReset();
+ eCallModemPSAP->frameStartHlackCur = 0;
+ eCallModemPSAP->msdReceived = KAL_FALSE;
+ eCallModemPSAP->ivsPush = KAL_TRUE;
+ eCallModemPSAP->TxRx = KAL_FALSE;
+ break;
+ default:
+ break;
+ }
+}
+
+#endif
+
+#if defined(__ECALL_PSAP_SUPPORT__)
+
+/*------------------------------------------------*/
+/* The unit test code for PSAP. */
+/*------------------------------------------------*/
+
+void PsapReceiveMsd(const Ord8 *msd, int length) {
+ int n;
+
+ MD_TRC_ECALL_PSAP_DRV_RECEIVE_MSD();
+
+ for (n = 0; n < ECALL_MSD_MAX_LENGTH; n++) {
+ eCallModemPSAP->CurMsd[n] = msd[n];
+ }
+ eCallModemPSAP->msdReceived = KAL_TRUE;
+
+ for (n=0; n<20; n++) {
+ kal_uint32 base = 7*n;
+
+ MD_TRC_ECALL_PSAP_DRV_MSD_DATA(
+ msd[base], msd[base+1], msd[base+2], msd[base+3], msd[base+4], msd[base+5], msd[base+6]);
+ }
+
+ eCallModemPSAP->handler( eCALL_EVENT_PSAP_RECV_MSD, eCallModemPSAP->CurMsd);
+}
+
+//#pragma arm section code="SECONDARY_ROCODE"
+static void eCall_PSAP_hisr(void)
+{
+ kal_uint16 read_idx, write_idx;
+
+ read_idx = eCallModemPSAP->pcm_fifo_read;
+ write_idx = eCallModemPSAP->pcm_fifo_write;
+
+ if (eCallModemPSAP->pcm_fifo_read == eCallModemPSAP->next_to_process) {
+ // Processed data isn't enough
+ PCM4WAY_FillSE(0);
+ PCM4WAY_FillSpk(0);
+ } else {
+ // uplink-path
+ if (eCallModemPSAP->isUpdateUL[read_idx] == KAL_FALSE) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemPSAP->ul_pcm_input[read_idx]));
+
+ } else {
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_PNW_BUF_M2D_UL1);
+ if(ECALL_NB_BUF_LEN == bufLen) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemPSAP->ul_pcm_output_nb[read_idx]));
+
+ } else if(ECALL_WB_BUF_LEN == bufLen) {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemPSAP->ul_pcm_output_wb[read_idx]));
+
+ } else {
+ PCM4WAY_PutToSE((const uint16*)(eCallModemPSAP->ul_pcm_output_swb[read_idx]));
+ }
+
+ eCallModemPSAP->isUpdateUL[read_idx] = KAL_FALSE;
+ MD_TRC_ECALL_PSAP_PCM_UPDATE_PUTTOSE(read_idx, bufLen);
+ }
+
+ // downlink-path no change
+ PCM4WAY_PutToSpk((const uint16*)(eCallModemPSAP->dl_pcm_input[read_idx]));
+
+ // Update index
+ eCallModemPSAP->pcm_fifo_write++;
+ if (eCallModemPSAP->pcm_fifo_write == 2*PCM_FIFO_LEN) {
+ eCallModemPSAP->pcm_fifo_write = 0;
+ }
+ }
+ if (read_idx != write_idx) {
+ // There is enough space to write data from microphone
+ eCallModemPSAP->ul_pcm_input_len[write_idx] = PCM4WAY_GetFromMic((uint16*)(eCallModemPSAP->ul_pcm_input[write_idx]));
+ eCallModemPSAP->dl_pcm_input_len[write_idx] = PCM4WAY_GetFromSD((uint16*)(eCallModemPSAP->dl_pcm_input[write_idx]));
+ MD_TRC_ECALL_PSAP_PCM_INPUT_LEN(write_idx, eCallModemPSAP->ul_pcm_input_len[write_idx], write_idx, eCallModemPSAP->dl_pcm_input_len);
+
+ // Update index
+ eCallModemPSAP->pcm_fifo_read++;
+ if (eCallModemPSAP->pcm_fifo_read == 2*PCM_FIFO_LEN) {
+ eCallModemPSAP->pcm_fifo_read = 0;
+ }
+ }
+
+ L1Audio_SetEvent(eCallModemPSAP->aud_id, (void*)0);
+}
+//#pragma arm section
+
+static void eCall_PSAP_ProcessFrame(void)
+{
+ kal_uint32 proc_idx = eCallModemPSAP->next_to_process;
+
+ // Here we only do DL downsample, UL upsample
+ kal_uint32 dl_ds_inLen, dl_ds_outLen;
+ kal_uint32 ul_us_inLen, ul_us_outLen;
+
+ kal_uint16 *p_dl_ds_inBuf, *p_dl_ds_outBuf;
+ kal_uint16 *p_ul_us_inBuf, *p_ul_us_outBuf;
+
+ switch (eCallModemPSAP->mode) {
+ case Psap:
+ if (eCallModemPSAP->ivsPush == KAL_FALSE) {
+ PsapSendStart();
+ eCallModemPSAP->ivsPush = KAL_TRUE;
+ }
+ if (eCallModemPSAP->msdReceived == KAL_TRUE) {
+ if ( ++eCallModemPSAP->frameStartHlackCur == eCallModemPSAP->frameStartHlack)
+ PsapSendHlack(eCallModemPSAP->CurMsd[0] & 0x0F);
+ }
+
+ /******************************************************
+ * dl_pcm_input -> dl_pcm_fifo -> dl_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [ECALLLIB] *
+ ******************************************************/
+
+ /* [ECALL blisrc] DL downsample start */
+ p_dl_ds_inBuf = eCallModemPSAP->dl_pcm_input[proc_idx];
+ p_dl_ds_outBuf = eCallModemPSAP->dl_pcm_fifo[proc_idx];
+
+ if(ECALL_WB_BUF_LEN == eCallModemPSAP->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_WB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemPSAP->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else if(ECALL_SWB_BUF_LEN ==eCallModemPSAP->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_SWB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemPSAP->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, ECALL_NB_BUF_LEN << 1);
+ }
+ /* [ECALL blisrc] DL downsample end */
+
+ PsapProcess( (Int16 *)eCallModemPSAP->dl_pcm_fifo[proc_idx]);
+
+ if (eCallModemPSAP->TxRx) {
+ memcpy(eCallModemPSAP->ul_pcm_fifo[proc_idx], eCallModemPSAP->dl_pcm_fifo[proc_idx], ECALL_NB_BUF_LEN*sizeof(kal_uint16));
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [ECALLLIB] <- [BAUDOT] *
+ *****************************************************/
+
+ /* [ECALL blisrc] UL up sampling start */
+ //NB output
+ p_ul_us_inBuf = eCallModemPSAP->ul_pcm_fifo[proc_idx];
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_nb[proc_idx];
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, ECALL_NB_BUF_LEN << 1);
+
+ //WB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_wb[proc_idx];
+ BLI_Convert(eCallModemPSAP->ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ //SWB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_swb[proc_idx];
+ BLI_Convert(eCallModemPSAP->ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+ /* [ECALL blisrc] UL up sampling end */
+
+ eCallModemPSAP->isUpdateUL[proc_idx] = KAL_TRUE;
+ MD_TRC_ECALL_PSAP_PCM_UPDATE_UL(proc_idx, eCallModemPSAP->TxRx, proc_idx, eCallModemPSAP->isUpdateUL[proc_idx]);
+ }
+
+ break;
+ case PsapRx:
+ if (eCallModemPSAP->ivsPush == KAL_FALSE) {
+ PsapSendStart();
+ eCallModemPSAP->ivsPush = KAL_TRUE;
+ }
+ if (eCallModemPSAP->msdReceived == KAL_TRUE) {
+ if ( ++eCallModemPSAP->frameStartHlackCur == eCallModemPSAP->frameStartHlack)
+ PsapSendHlack(eCallModemPSAP->CurMsd[0] & 0x0F);
+ }
+
+ /******************************************************
+ * dl_pcm_input -> dl_pcm_fifo -> dl_pcm_output *
+ * 32k 8k 32k *
+ * [BAUDOT] -> [ECALLLIB] *
+ ******************************************************/
+
+ /* [ECALL blisrc] DL downsample start */
+ p_dl_ds_inBuf = eCallModemPSAP->dl_pcm_input[proc_idx];
+ p_dl_ds_outBuf = eCallModemPSAP->dl_pcm_fifo[proc_idx];
+
+ if(ECALL_WB_BUF_LEN == eCallModemPSAP->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_WB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemPSAP->dl_downsample_16_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else if(ECALL_SWB_BUF_LEN ==eCallModemPSAP->dl_pcm_input_len[proc_idx]) {
+ dl_ds_inLen = ECALL_SWB_BUF_LEN << 1;
+ dl_ds_outLen = ECALL_NB_BUF_LEN << 1;
+ BLI_Convert(eCallModemPSAP->dl_downsample_32_8, (short *)p_dl_ds_inBuf, &dl_ds_inLen, (short *)p_dl_ds_outBuf, &dl_ds_outLen);
+
+ } else{
+ memcpy(p_dl_ds_outBuf, p_dl_ds_inBuf, ECALL_NB_BUF_LEN << 1);
+ }
+ /* [ECALL blisrc] DL downsample end */
+
+ PsapRxProcess( (Int16 *)eCallModemPSAP->dl_pcm_fifo[proc_idx] );
+
+ if (eCallModemPSAP->TxRx) {
+ memcpy(eCallModemPSAP->ul_pcm_fifo[proc_idx], eCallModemPSAP->dl_pcm_fifo[proc_idx], ECALL_NB_BUF_LEN*sizeof(kal_uint16));
+
+ /*****************************************************
+ * dl_pcm_output <- dl_pcm_fifo <- dl_pcm_input *
+ * 32k 8k 32k *
+ * [ECALLLIB] <- [BAUDOT] *
+ *****************************************************/
+
+ /* [ECALL blisrc] UL up sampling start */
+ //NB output
+ p_ul_us_inBuf = eCallModemPSAP->ul_pcm_fifo[proc_idx];
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_nb[proc_idx];
+ memcpy(p_ul_us_outBuf, p_ul_us_inBuf, ECALL_NB_BUF_LEN << 1);
+
+ //WB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_WB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_wb[proc_idx];
+ BLI_Convert(eCallModemPSAP->ul_upsample_8_16, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+
+ //SWB output
+ ul_us_inLen = ECALL_NB_BUF_LEN << 1;
+ ul_us_outLen = ECALL_SWB_BUF_LEN << 1;
+ p_ul_us_outBuf = eCallModemPSAP->ul_pcm_output_swb[proc_idx];
+ BLI_Convert(eCallModemPSAP->ul_upsample_8_32, (short *)p_ul_us_inBuf, &ul_us_inLen, (short *)p_ul_us_outBuf, &ul_us_outLen);
+ /* [ECALL blisrc] UL up sampling end */
+
+ eCallModemPSAP->isUpdateUL[proc_idx] = KAL_TRUE;
+ MD_TRC_ECALL_PSAP_PCM_UPDATE_UL(proc_idx, eCallModemPSAP->TxRx, proc_idx, eCallModemPSAP->isUpdateUL[proc_idx]);
+ }
+
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+}
+
+static void eCall_PSAP_ProcessTask(void *data)
+{
+ if (eCallModemPSAP == NULL) {
+ return;
+ }
+
+ while (eCallModemPSAP->next_to_process != eCallModemPSAP->pcm_fifo_write) {
+ // Process each frame
+ eCall_PSAP_ProcessFrame();
+
+ // Update index
+ eCallModemPSAP->next_to_process++;
+ if (eCallModemPSAP->next_to_process == 2 * PCM_FIFO_LEN) {
+ eCallModemPSAP->next_to_process = 0;
+ }
+ }
+}
+
+static void eCall_PSAP_OnHandler( void *data )
+{
+ (void)data;
+
+ PCM4WAY_Start(eCall_PSAP_hisr, 0);
+}
+
+static void eCall_PSAP_OffHandler( void *data )
+{
+ (void)data;
+
+ PCM4WAY_Stop(0);
+}
+
+eCall_Modem_Status eCall_PSAP_Open(eCall_Callback handler)
+{
+ ASSERT( handler != NULL );
+
+ if ( eCallModemIVS != NULL ) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( eCallModemPSAP != NULL ) {
+ return eCALL_OPERATION_ALREADY_OPEN;
+ }
+
+ //L1SP_EnableSpeechEnhancement(KAL_FALSE);
+
+ //eCallModemPSAP = (EcallShell *)audio_alloc_mem_cacheable( sizeof(EcallShell) );
+ eCallModemPSAP = (EcallShell *)get_ctrl_buffer( sizeof(EcallShell) );
+ ASSERT( eCallModemPSAP != NULL );
+ memset(eCallModemPSAP, 0, sizeof(EcallShell));
+
+ // Allocate for PSAP internal structure
+ {
+ kal_uint32 reqSize;
+
+ reqSize = (kal_uint32) PsapGetMemSize();
+ //eCallModemPSAP->allocMem = (void *)audio_alloc_mem_cacheable( reqSize );
+ eCallModemPSAP->allocMem = (void *)get_ctrl_buffer( reqSize );
+ memset(eCallModemPSAP->allocMem, 0, sizeof(reqSize));
+ PsapInit( eCallModemPSAP->allocMem );
+ }
+
+ // open BLI Src for ecall
+ // 32k <-> 8k
+ eCallModemPSAP->dl_downsample_32_8 = BLI_Open(32000, 1, 8000, 1, (signed char*)eCallModemPSAP->internal_buf_dl_in, 0); // open DL down sampling src
+ eCallModemPSAP->ul_upsample_8_32 = BLI_Open(8000, 1, 32000, 1, (signed char*)eCallModemPSAP->internal_buf_ul_out, 0); // open UL up sampling src
+ // 16k <-> 8k
+ eCallModemPSAP->dl_downsample_16_8 = BLI_Open(16000, 1, 8000, 1, (signed char*)eCallModemPSAP->internal_buf_dl_in2, 0); // open DL down sampling src
+ eCallModemPSAP->ul_upsample_8_16 = BLI_Open(8000, 1, 16000, 1, (signed char*)eCallModemPSAP->internal_buf_ul_out2, 0); // open UL up sampling src
+
+ eCallModemPSAP->aud_id = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler(eCallModemPSAP->aud_id , eCall_PSAP_ProcessTask);
+ L1Audio_SetFlag(eCallModemPSAP->aud_id);
+
+ PsapReset();
+
+ eCallModemPSAP->mode = Psap; //PsapRx;
+ eCallModemPSAP->ivsPush = KAL_TRUE; //KAL_FALSE;
+ eCallModemPSAP->msdReceived = KAL_FALSE;
+ eCallModemPSAP->frameStartHlack = 10;
+ eCallModemPSAP->pcm_fifo_read = 0;
+ eCallModemPSAP->pcm_fifo_write = PCM_FIFO_LEN;
+ eCallModemPSAP->next_to_process = PCM_FIFO_LEN;
+ eCallModemPSAP->frameStartHlackCur = 0;
+ eCallModemPSAP->handler = handler;
+
+ for (int i=0; i<2*PCM_FIFO_LEN; i++) {
+ eCallModemPSAP->isUpdateUL[i] = KAL_FALSE;
+ }
+
+ if ( AM_IsSpeechOn() ) {
+ eCall_PSAP_OnHandler( (void *)0 );
+ }
+
+ // Hook service to L1SP
+ L1SP_Register_Pcm4WayService( eCall_PSAP_OnHandler, eCall_PSAP_OffHandler );
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+eCall_Modem_Status eCall_PSAP_Close(void)
+{
+ if( eCallModemPSAP == NULL ) {
+ return eCALL_OPERATION_ALREADY_CLOSE;
+ }
+
+ if ( eCallModemIVS != NULL ) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ // Unhook service to L1SP
+ L1SP_UnRegister_Pcm4Way_Service();
+
+ if ( AM_IsSpeechOn() ) {
+ eCall_PSAP_OffHandler( (void *)0 );
+ }
+
+ L1Audio_ClearFlag(eCallModemPSAP->aud_id);
+ L1Audio_FreeAudioID(eCallModemPSAP->aud_id);
+
+ BLI_Close(eCallModemPSAP->dl_downsample_16_8, 0); // Close DL down sampling src
+ BLI_Close(eCallModemPSAP->dl_downsample_32_8, 0); // Close DL down sampling src
+ BLI_Close(eCallModemPSAP->ul_upsample_8_16, 0); // Close UL up sampling src
+ BLI_Close(eCallModemPSAP->ul_upsample_8_32, 0); // Close UL up sampling src
+
+ // Deallocate for PSAP internal structure
+ {
+ PsapDeinit();
+ free_ctrl_buffer( (void *) eCallModemPSAP->allocMem );
+ }
+
+ free_ctrl_buffer( (void *) eCallModemPSAP );
+ //L1SP_EnableSpeechEnhancement(KAL_TRUE);
+ eCallModemPSAP = NULL;
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+eCall_Modem_Status eCall_PSAP_SendStart(void)
+{
+ if (eCallModemPSAP == NULL) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ if ( eCallModemIVS != NULL ) {
+ return eCALL_OPERATION_FAIL;
+ }
+
+ eCallModemPSAP->TxRx = KAL_TRUE;
+ eCallModemPSAP->mode = Psap;
+ eCallModemPSAP->ivsPush = KAL_FALSE;
+
+ return eCALL_OPERATION_SUCCESS;
+}
+
+#else
+
+// Provide dummy function to support feature switchable
+void PsapReceiveMsd(const Ord8 *msd, int length) { }
+eCall_Modem_Status eCall_PSAP_Open(eCall_Callback handler) {return eCALL_OPERATION_FAIL;}
+eCall_Modem_Status eCall_PSAP_Close(void) {return eCALL_OPERATION_FAIL;}
+eCall_Modem_Status eCall_PSAP_SendStart(void) {return eCALL_OPERATION_FAIL;}
+
+#endif
diff --git a/mcu/driver/audio/src/v1/extcodec.c b/mcu/driver/audio/src/v1/extcodec.c
new file mode 100644
index 0000000..5e7659f
--- /dev/null
+++ b/mcu/driver/audio/src/v1/extcodec.c
@@ -0,0 +1,325 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * pcm4way.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * EXTCODEC interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "sync_data.h"
+#include "l1sp_trc.h"
+// #include "reg_base.h"
+#include "l1audio.h"
+#include "am.h"
+
+#include "media.h"
+#include "extcodec.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+
+#include "sp_drv.h"
+#include "sp_enhance.h"
+
+
+#define ACLOOPBACK_FRAME_BUF_NO (64) // REMIND: should be pow of 2
+#define ACLOOPBACK_NB_FRAME_SIZE (160)
+//static uint16 gSpc_acLoopback_PCM_UL_BUF[ACLOOPBACK_NB_FRAME_SIZE];
+#if defined (__SMART_PHONE_MODEM__)
+static uint16 gSpc_acLoopback_PCM_DL_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE];
+#endif // defined (__SMART_PHONE_MODEM__)
+
+typedef struct _EXTCODEC_T_
+{
+ kal_uint8 pnwBufInfo; //ref to SPC_PNW_MSG_BUFFER_x
+ kal_uint8 pnwBand; //0: for narrow band, 1: for wide band
+ kal_uint32 micBufSize; // unit is byte (8bit)
+ kal_uint32 spkBufSize; // unit is byte (8bit)
+ kal_uint32 DL_tmp_w;
+ kal_uint32 DL_tmp_r;
+ kal_uint32 delay;
+ kal_uint32 running;
+ kal_spinlockid extcodecspinLockID;
+}_EXTCODEC_T_;
+
+_EXTCODEC_T_ extcodec;
+
+
+uint16 Extcodec_writePatternToSpk(uint16 pattern)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_EXTCOD_BUF_DL);
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_EXTCOD_BUF_DL);
+ for( I = bufLen; I > 0; I-- ){
+ *ptr++ = pattern;
+ }
+ return bufLen;
+}
+
+void Extcodec_Set_Delay(kal_uint32 delay)
+{
+ extcodec.delay = delay;
+}
+
+void Extcodec_Call_Open()
+{
+#if defined (__SMART_PHONE_MODEM__)
+ int I;
+ kal_take_spinlock(extcodec.extcodecspinLockID, KAL_INFINITE_WAIT);
+ extcodec.running = 1;
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+ extcodec.DL_tmp_w = 0;
+ extcodec.DL_tmp_r = 0;
+ //extcodec.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)
+ //ASSERT(extcodec.pnwBufInfo != 0);
+
+ extcodec.micBufSize = 0;
+ extcodec.spkBufSize = 0;
+ memset(gSpc_acLoopback_PCM_DL_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE);
+
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF) && SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF));
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_ON);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_ON);
+ for(I = 0; ;I ++){
+ kal_bool is_ready = true;
+ int test_return_DL, test_return_UL;
+ test_return_DL = SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_RDY);
+ test_return_UL = SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_RDY);
+ kal_prompt_trace(MOD_L1SP,"extcodec check status");
+ if( !test_return_DL){
+ is_ready &= false;
+ }
+
+ if( !test_return_UL){
+ is_ready &= false;
+ }
+
+ if(is_ready){
+ break;
+ }
+ ASSERT(I < 40); // wait 400ms
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+#endif // defined (__SMART_PHONE_MODEM__)
+}
+
+void Extcodec_Call_Close()
+{
+#if defined (__SMART_PHONE_MODEM__)
+ Sal_PCMEx_Config_t cfg;
+ kal_take_spinlock(extcodec.extcodecspinLockID, KAL_INFINITE_WAIT);
+ extcodec.running = 0;
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+ memset(&cfg, 0, sizeof(Sal_PCMEx_Config_t));
+ /* the begining of configure the SAL */
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_RDY));
+ ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_RDY));
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_EXT_COD, SAL_PCMEX_OFF);
+ cfg.swi = SAL_PCMEX_SWITCH_OFF;
+ cfg.type = SAL_PCMEX_TYPE_EXT_COD;
+ cfg.band = SAL_PCM_NARROWBAND;
+ SAL_PcmEx_Config(&cfg);
+ Extcodec_writePatternToSpk(0);
+
+ // clear buffer
+ extcodec.pnwBufInfo = 0;
+ extcodec.micBufSize = 0;
+ extcodec.spkBufSize = 0;
+#endif // defined (__SMART_PHONE_MODEM__)
+}
+
+void Extcodec_Init()
+{
+ extcodec.extcodecspinLockID = kal_create_spinlock("EXTCODEC_LOCK");
+}
+uint16 Extcodec_GetFromMic(uint16 *toBuf)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_EXTCOD_BUF_UL);
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_EXTCOD_BUF_UL);
+ if( SP_IsMicMute() ){
+ for( I = bufLen; I > 0; I-- ){
+ *toBuf++ = 0;
+ }
+ } else {
+ for( I = bufLen; I > 0; I-- ){
+ *toBuf++ = *ptr++;
+ }
+ }
+ return bufLen;
+}
+
+uint16 Extcodec_PutToSpk(const uint16 *fromBuf)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(SAL_PCMEX_EXTCOD_BUF_DL);
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_EXTCOD_BUF_DL);
+ for( I = bufLen; I > 0; I-- ){
+ *ptr++ = *fromBuf++;
+ }
+ return bufLen;
+}
+
+void Extcodec_hisr_dl_loopback(void *data)
+{
+#if defined (__SMART_PHONE_MODEM__)
+ MD_TRC_SPC_AC_LOOPBACK_HISR_DL();
+ kal_take_spinlock(extcodec.extcodecspinLockID, KAL_INFINITE_WAIT);
+ if(extcodec.running == 0)
+ {
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+ MD_TRC_SPC_AC_LOOPBACK_HISR_SKIP();
+ return;
+ }
+
+ if(extcodec.DL_tmp_w > extcodec.DL_tmp_r &&(extcodec.DL_tmp_w - extcodec.DL_tmp_r) >= extcodec.delay)
+ {
+ extcodec.spkBufSize = Extcodec_PutToSpk(gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ (extcodec.DL_tmp_r)++;
+ MD_TRC_SPC_AC_LOOPBACK_TO_SPK(
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ } else {
+ Extcodec_writePatternToSpk(0);
+ }
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+#endif // defined (__SMART_PHONE_MODEM__)
+}
+
+void Extcodec_hisr_ul_loopback(void *data)
+{
+#if defined (__SMART_PHONE_MODEM__)
+ MD_TRC_SPC_AC_LOOPBACK_HISR_UL();
+ kal_take_spinlock(extcodec.extcodecspinLockID, KAL_INFINITE_WAIT);
+ if(extcodec.running == 0)
+ {
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+ MD_TRC_SPC_AC_LOOPBACK_HISR_SKIP();
+ return;
+ }
+
+ if((extcodec.DL_tmp_w - extcodec.DL_tmp_r) <= extcodec.delay)
+ {
+ extcodec.micBufSize = Extcodec_GetFromMic((uint16*)gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ (extcodec.DL_tmp_w)++;
+ MD_TRC_SPC_AC_LOOPBACK_FROM_SD(
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_DL_BUF[extcodec.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ }
+ kal_give_spinlock(extcodec.extcodecspinLockID);
+#endif // defined (__SMART_PHONE_MODEM__)
+}
+
+
diff --git a/mcu/driver/audio/src/v1/inc/afe.h b/mcu/driver/audio/src/v1/inc/afe.h
new file mode 100644
index 0000000..4d5ecaf
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/afe.h
@@ -0,0 +1,426 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Audio Front End
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: 1.21 $
+ * $Modtime: Jul 08 2005 16:31:52 $
+ * $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/l1audio/afe.h-arc $
+ *
+ * 12 19 2017 thomas.chen
+ * [MOLY00296986] [Build warning removal]fix warning
+ * .
+ *
+ * 11 09 2017 thomas.chen
+ * [MOLY00288616] Remove DisableInterrupt API
+ * .
+ *
+ * 09 27 2017 thomas.chen
+ * [MOLY00279366] Fix 9295M build error
+ * .
+ *
+ * 08 25 2017 ting-ni.chen
+ * [MOLY00273782] [Sylvia] [MT6771] bringup chip define
+ * [Sylvia][MT6771] bringup chip define
+ *
+ * 06 09 2017 sungshen.wu
+ * [MOLY00245550] [Zion] Bringup Check in
+ * .Zion check in
+ *
+ * 05 14 2017 ys.hsieh
+ * [MOLY00249046] [MT6763]add speech hw dvt audio command patch
+ *
+ * Bianco DVT for audiocommand
+ *
+ * 03 01 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * clean marked code.
+ * refator the gain control (BT)
+ * fix bug: the debug info size should be 16.
+ * common parameter default value location change
+ *
+ * 02 24 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove backup and restore function in AFE.
+ *
+ * 02 24 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * rewrite digital gain control.
+ *
+ * 02 13 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove afe setrefresh and related code.
+ * remove mute speaker which is only using in audio path
+ *
+ * 02 13 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove unused toneLoopback
+ *
+ * 02 08 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * remove unused media functions.
+ *
+ * 01 26 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * revise afe driver.
+ *
+ * 01 26 2017 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * revise afe driver.
+ *
+ * 11 09 2016 thomas.chen
+ * [MOLY00212357] 93 SpeechDriver Checkin
+ * .
+ *
+ * 03 30 2016 thomas.chen
+ * [MOLY00171812] fix UMOLYA BuildError
+ * .
+ *
+ * 02 04 2016 fu-shing.ju
+ * [MOLY00120200] 6291Plus development
+ * Fix MSBB issue.
+ *
+ * 10 07 2015 fu-shing.ju
+ * [MOLY00120200] 6291Plus development
+ * Add Data_Sync_Barrier() for 6292.
+ *
+ * 08 17 2015 fu-shing.ju
+ * [MOLY00120200] 6291Plus development
+ * Add ELBRUS chip option.
+ *
+ * 06 11 2015 thomas.chen
+ * [MOLY00120543] Jade PreBuild
+ * .
+ *
+ * 02 03 2015 fu-shing.ju
+ * [MOLY00091627] TK6291 development
+ * Sync Audio driver with MOLY TRUNK W15.05.P1.
+ *
+ * 04 07 2014 sheila.chen
+ * [MOLY00061869] [UMoly] check-in
+ * add TK6291 chip
+ *
+ * 01 28 2014 sheila.chen
+ * [MOLY00050441] [MT6595 Bring-Up] speech related code
+ * DVT test cases check in
+ *
+ * 01 15 2014 sheila.chen
+ * [MOLY00050441] [MT6595 Bring-Up] speech related code
+ * [ROME] add DVT setting
+ *
+ * 01 07 2014 sheila.chen
+ * [MOLY00050441] [MT6595 Bring-Up] speech related code
+ * Merging //MOLY/Development_BRANCHES/MT6595E1_BRING_UP_DEV/mcu/driver/audio/...
+ * to //MOLY/TRUNK/MOLY/mcu/driver/audio/...
+ *
+ * 12 26 2013 sheila.chen
+ * [MOLY00050441] [MT6595 Bring-Up] speech related code
+ * Fix bug, MDAFE hw register is 32 bit instead of 16 bit
+ *
+ * 12 10 2013 lanus.chao
+ * [MOLY00046252] Add MT6595 chip option
+ * .
+ *
+ * 12 09 2013 lanus.chao
+ * [MOLY00046252] Add MT6595 chip option
+ * .
+ *
+ * 08 21 2013 sheila.chen
+ * [MOLY00031287] [MT6592][MT6571] Chip back prepare
+ * add MT6592/MT6571 chip options
+ *
+ * 08 16 2013 sheila.chen
+ * [MOLY00011218] [MT6290] Code modification
+ * remove unused code
+ *
+ * 08 13 2013 sheila.chen
+ * [MOLY00011218] [MT6290] Code modification
+ * move register backup by chip
+ *
+ * 08 05 2013 sheila.chen
+ * [MOLY00011218] [MT6290] Code modification
+ * remove unused afe code
+ *
+ * 05 14 2013 sheila.chen
+ * [MOLY00022118] [Volunteer Patch] DRC2.0 (MagiLoudness) Integration
+ * DRC 2.0 modification
+ *
+ * 03 01 2013 sheila.chen
+ * [MOLY00011218] [MT6290] Code modification
+ * Fix Build error for MT6290
+ *
+ * 01 16 2013 sheila.chen
+ * [MOLY00008869] [Need Patch][Build Error] WR8 build error for MT6582_L1S(DEFAULT)
+ * Fix Build Error
+ *
+ * 01 07 2013 sheila.chen
+ * [MOLY00008234] [MT6572] Integration
+ * MT6572 bring up
+ *
+ * 12 25 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * wbBT
+ *
+ * 12 18 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Set Mode Modification
+ *
+ * 11 01 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * 1. Sidetone update
+ *
+ * 2. digital gain setting (AGC, DL volume)
+ *
+ * 3. FIX AFE setting to privent too many noise
+ *
+ * 4. Fix PCM MSB, LSB mapping mismatch
+ * 5. Turn on enhancement
+ * 6. Add Acroustic loopback code
+ *
+ * 09 26 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Chip Rename to MT6589
+ * Remove unused AFE functions
+ * Phase in phone call usage
+ *
+ * 09 20 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * add compile option for analog AFE
+ *
+ * 09 17 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * 83 phone call prepare, warning removal
+ *
+ * 08 21 2012 dior.lin
+ * [MOLY00002430] Modify for MD2G wakeup by Audio
+ * Modify for MD2G wakeup by Audio.
+ *
+ * 08 17 2012 kh.hung
+ * [MOLY00002243] Fix cross category header inclusion
+ * Remove l1d_reg.h.
+ *
+ * 07 27 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Fix build warning.
+ *
+ * 07 25 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Phase in PCMNWAY, param AM manager with 2 parameter, and recording.
+ *
+ * 06 08 2012 kh.hung
+ * removed!
+ * .
+ *
+ * 05 16 2012 jy.huang
+ * removed!
+ * .
+ *
+ * 05 16 2012 jy.huang
+ * removed!
+ * .
+ *
+ * 05 14 2012 jy.huang
+ * removed!
+ * .
+ *
+ * 11 29 2011 lanus.chao
+ * removed!
+ * .
+ *
+ *
+ *******************************************************************************/
+#ifndef AFE_H
+#define AFE_H
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: INCLUDE FILES
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "reg_base.h"
+#include "kal_trace.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "audcoeff_default.h"
+#include "afe_def.h"
+#include "dcl.h"
+#include "us_timer.h"
+#include "speech_def.h"
+
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Data Types and Structures
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if (defined(MT6295M) || defined(__MD95__))
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Section: Structure AFE_STRUCT_T (afe main structure)
+//=============================================================================================
+typedef struct {
+
+ // kal_uint16 aud_id;
+
+ kal_bool loopback;
+ kal_bool afe_init;
+ kal_uint8 voice8kMode;
+
+
+ //for 65nm clock gating, digital AFE register backup
+ // RegBackup regbak;
+
+
+} AFE_STRUCT_T;
+
+typedef struct {
+
+ kal_uint32 afe_conn0;
+
+} AFE_RG_STRUCT_T;
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Special Configurations for Specific Usage
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+//=============================================================================================
+// Section: Debug and Unit Test Configuration
+//=============================================================================================
+//#define __AFE_DEBUG__
+#ifdef __AFE_DEBUG__
+ #define afe_prompt_trace kal_prompt_trace
+
+static kal_char * _aszAfeState[] =
+{
+ "AFE_STATE_OFF",
+ "AFE_STATE_ON",
+ "AFE_STATE_IDLE_OFF",
+ "AFE_STATE_CLASS_D_OFF"
+};
+
+#else
+ #define afe_prompt_trace(...)
+#endif
+
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: DEFINITION OF DATA TYPES
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+
+//=============================================================================================
+// Section: External Variables and Functions
+//=============================================================================================
+extern AFE_STRUCT_T afe;
+extern AFE_RG_STRUCT_T afeRG;
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Function Prototypes
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+void AFE_Init( void );
+
+
+void AFE_DELAY(uint16 delay);
+
+
+void AFE_Chip_Init( void );
+
+
+void AFE_TurnOnLoopback( void );
+void AFE_TurnOffLoopback( void );
+
+kal_uint8 AFE_GetVoice8KMode(void);
+void AFE_SetVoice8KMode(kal_uint8 mode);
+void AFE_SetConn0(kal_uint32 val);
+#endif //AFE_H
diff --git a/mcu/driver/audio/src/v1/inc/afe_def.h b/mcu/driver/audio/src/v1/inc/afe_def.h
new file mode 100644
index 0000000..5d9b333
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/afe_def.h
@@ -0,0 +1,262 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file defines all the AFE registers used in audio module.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef __AFE_DEF_H
+#define __AFE_DEF_H
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: INCLUDE FILES
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+#include "kal_public_api.h"
+#include "reg_base.h"
+#include "l1audio.h"
+
+#include "am.h"
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Register Definitions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+#define AFE_base (AFE_BASE)
+
+//=============================================================================================
+// Sections: Register Audio Front End Hardware Control Register
+//=============================================================================================
+#define AFE_VMCU_CON ((APBADDR)(AFE_base+0x0000)) /* AFE Voice MCU Control Register */
+#define AFE_VMCU_CON1 ((APBADDR)(AFE_base+0x000C)) /* AFE Voice Analog Circuit Control Register 1 */
+
+#define AFE_PCM_CON0 ((APBADDR32)(AFE_base+0x0014)) /* AFE PCM Interface Control Register 0 */
+
+#define AFE_AMCU_CON0 ((APBADDR)(AFE_base+0x0020)) /* AFE Audio MCU Control Register 0 */
+#define AFE_AMCU_CON1 ((APBADDR)(AFE_base+0x0024)) /* AFE Audio Control Register 1 */
+
+#define AFE_IRQ_CON1 ((APBADDR32)(AFE_base+0x0034)) /* IRQ mode setting */
+
+#define AFE_MCU_CON0 ((APBADDR32)(AFE_base+0x0080)) /* MD AFE control Register 0 */
+#define AFE_MCU_CON1 ((APBADDR32)(AFE_base+0x0084)) /* MD AFE control Register 1 */
+#define AFE_CONN0 ((APBADDR32)(AFE_base+0x00A0)) /* MD AFE connection control Register 1 */
+
+
+#define USIP_CLK_ENABLE ((APBADDR)(SPEECHDSP_CONFIG_BASE+0x0000)) /* Power Down Disable 2 Register */
+#define USIP_CLK_DISABLE ((APBADDR)(SPEECHDSP_CONFIG_BASE+0x0004)) /* Power Down Enable 2 Register */
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Chapter: Function Prototypes
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+void AFE_TurnOn8K(void);
+void AFE_TurnOff8K(void);
+
+// void AFE_RegisterBackup(void);
+#endif //__AFE_DEF_H
+
diff --git a/mcu/driver/audio/src/v1/inc/am.h b/mcu/driver/audio/src/v1/inc/am.h
new file mode 100644
index 0000000..44f9a50
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/am.h
@@ -0,0 +1,341 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * afe.c
+ *
+ * Project:
+ * --------
+ * MT6208
+ *
+ * Description:
+ * ------------
+ * Audio Manager
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *******************************************************************************/
+#ifndef AM_H
+#define AM_H
+
+#include "l1aud_common_def.h"
+#include "sal_def.h"
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+typedef enum{
+ AM_RECORD_NONE = 0,
+ AM_RECORD_8K,
+ AM_RECORD_16K
+}AM_RECORD_FORMAT;
+
+void AM_Init( void );
+void AM_SetDSP2GReset(bool v);
+//bool AM_AudioManager( bool handover,uint16 speech_mode, int8 sub_channel );
+//void AM_AudioManager_OS_Tick( void );
+void AM_FlushQFunction( void );
+void AM_FillSilencePattern( volatile uint16 *addr, uint16 info, uint16 speech_mode );
+void AM_FillSilencePatternInBuffer( uint16 *buffer, uint16 speech_mode );
+uint16 AM_GetSpeechPatternLength( uint8 speech_mode );
+bool AM_CodecMode_IsLegal(uint8 codec_mode);
+void AM_SpeechOn(uint32 rat_mode, uint32 extraInfo);
+void AM_SpeechOff( uint32 info );
+bool AM_IsSpeechOn( void );
+void AM_SetDAIMode ( uint8 mode );
+bool AM_IsDAIMode( void );
+#if defined(_SPE_ENH_MD_PARSE_)
+void AM_WriteFirCoeffs( const int16 *in_coeff, const int16 *out_coeff );
+void AM_WriteWbFirCoeffs( const int16 wb_in_coeff[90], const int16 wb_out_coeff[90] );
+void AM_WriteSWbFirCoeffs( const int16 swb_in_coeff[90], const int16 swb_out_coeff[90] );
+void AM_WriteWbIirCoeffs( const int16 wb_in_coeff[42], const int16 wb_out_coeff[42],const int16 wb_Mic1_coeff[20],const int16 wb_Mic2_coeff[20] );
+void AM_WriteIirCoeffs( const int16 in_coeff[42], const int16 out_coeff[42],const int16 Mic1_coeff[20],const int16 Mic2_coeff[20] );
+void AM_WriteSWbIirCoeffs( const int16 swb_in_coeff[42], const int16 swb_out_coeff[42],const int16 swb_Mic1_coeff[20],const int16 swb_Mic2_coeff[20] );
+#endif
+void AM_VMRecordOn( void );
+void AM_VMRecordOff( void );
+
+void AM_KeyToneOn( void );
+void AM_KeyToneOff( void );
+void AM_ToneOn( void );
+void AM_ToneOff( void );
+void Set_Reset_Enh_Status(uint8 status);
+uint8 Get_Reset_Enh_Status(void);
+
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+uint32 AM_GetRecordFormat(void);
+typedef enum{
+ AM_PCM8KREC_APP_TYPE_PCMREC = 0,
+ AM_PCM8KREC_APP_TYPE_VMEPL,
+}AM_PCM8KREC_APP_TYPE;
+
+void AM_PCM8K_RecordOn( AM_PCM8KREC_APP_TYPE appType, uint8 dlPos );
+void AM_PCM8K_RecordOff( bool wait, AM_PCM8KREC_APP_TYPE appType );
+void AM_PCM16K_RecordOn( uint8 dlPos ); /*PCM16K recording support 6219 and latter version*/
+void AM_PCM16K_RecordOff( bool wait );
+void AM_RAMP_DONE(void);
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif
+// bool AM_IsULSpeechMuted( void );
+void AM_Mute_UL_EnhResult_Speech(bool mute);
+void AM_Mute_UL_Source_Speech(bool mute);
+void AM_Mute_UL_Codec_Speech( bool mute );
+void AM_Mute_UL_POS_EN_Speech( bool mute );
+void AM_Mute_DL_8K_Speech( bool mute );
+void AM_Mute_DL_Speech_Traffic( bool mute );
+void AM_Mute_DL_PRE_PcmMixer( bool mute );
+
+// PCMNWAY function inside AM
+typedef enum {
+ AM_PCMEX_TYPE_DEDICATION = 0, // under call
+// AM_PCMEX_TYPE_IDLE_WO_ENH, // without call, voice path, no enhancement
+ AM_PCMEX_TYPE_IDLE, // without call, speech quality like, with enhancement
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif
+ AM_PCMEX_TYPE_DACA_DEDICATION, // data card under call (speech on)
+ AM_PCMEX_TYPE_DACA_IDLE_WO_ENH, // data card without call, voice path, no enhancement
+ AM_PCMEX_TYPE_DACA_IDLE, // data card without call, speech quality like, with enhancement
+
+ AM_PCMEX_TYPE_UNDEF = 0xffff,
+} AM_PCMEX_TYPE;
+
+void AM_PCM_EX_On( AM_PCMEX_TYPE type, uint32 cfg_ptr);
+void AM_PCM_EX_Off( AM_PCMEX_TYPE type, uint32 cfg_ptr);
+bool AM_IsVoIPOn( void );
+bool AM_IsConflictState( void );
+bool AM_IsKeyToneOn( void );
+bool AM_IsToneOn( void );
+bool AM_IsVoiceOn( void );
+
+// PCM router control function
+void AM_PcmRouter_On(uint32 extraInfo);
+void AM_PcmRouter_Off(void);
+
+// [Phase out] PCM path control functions, defualt is 16k PCM, so we don't need to open it.
+// void AM_PCM_Mode_Off(void);
+// void AM_PCM_Mode_On(kal_uint16 data);
+// kal_bool AM_IsPcmModeOn( void );
+
+// Bluetooth earphone control functions
+void AM_BluetoothOn( uint8 bt_mode);
+void AM_BluetoothOff( void );
+bool AM_IsBluetoothOn( void );
+bool AM_IsBTCordlessMode( void );
+
+// Sound effect control functions
+void AM_SND_PlaybackOn( void );
+void AM_SND_PlaybackOff( bool wait );
+
+// Functions for modem loopback test
+void AM_SetLoopBackTest( bool enable );
+bool AM_IsLoopBackTest( void );
+
+// void AM_EnableToneLoopBackFlag( kal_bool param );
+
+// network information
+void AM_SetSpeechMode( uint16 speech_mode, int8 sub_channel );
+uint16 AM_GetSpeechMode(void);
+bool AM_IsSpeechWB( void );
+uint32 AM_GetNetworkRate( void );
+
+// InterRAT
+void AM_InterRAT_3G_to_2G( void );
+void AM_InterRAT_4G_to_2G();
+void AM_InterRAT_C2K_to_2G();
+void AM_InterRAT_Standby_to_2G();
+
+void AM_InterRAT_2G_to_3G( kal_uint32 codec );
+void AM_InterRAT_4G_to_3G(uint32 codec);
+void AM_InterRAT_C2K_to_3G(uint32 codec);
+void AM_3G_INTRARAT(kal_uint32 codec);
+
+void AM_InterRAT_2G_to_4G(uint32 codec);
+void AM_InterRAT_3G_to_4G(uint32 codec);
+void AM_InterRAT_C2K_to_4G(uint32 codec);
+void AM_4G_INTRARAT(kal_uint32 codec, uint32 is_4G_handover);
+kal_bool AM_Is_4G();
+
+
+void AM_InterRAT_2G_to_C2K(uint32 codec);
+void AM_InterRAT_3G_to_C2K(uint32 codec);
+void AM_InterRAT_4G_to_C2K(uint32 codec);
+void AM_C2K_IntraRAT(uint32 codec);
+//block filter run time switch function, used in sp_enhance.c
+// void AM_SwitchCompFilter( kal_uint16 par );
+//block filter turn on/off
+// void AM_TurnOnBlockFilter( void );
+// void AM_TurnOffBlockFilter( void );
+
+bool AM_IsAmInSpeechState( void );
+
+
+bool AM_IsDataCardOn( void );
+
+// sw digital gain related
+// void AM_DSP_SetAudioDigitalGain(kal_uint16 digitalVol);
+// kal_uint16 AM_DSP_GetAudioDigitalGain(void);
+void AM_DSP_SetSpeechDigitalGain(kal_uint16 digitalVol);
+kal_uint16 AM_DSP_GetSpeechDigitalGain(void);
+void AM_DSP_SetSpeechUplinkSwAgcGain(kal_uint16 digitalVol);
+kal_uint16 AM_GetSpeechEnhRefDigitalGain(void);
+void AM_DSP_SetSpeechEnhRefDigitalGain(kal_uint16 digitalVol);
+
+// dsp filter/enhancement parameter/coefficient related
+void AM_SetNotchFilterParam(int16 *param);
+void AM_DSP_WriteNotchFilterParam(void);
+
+int16 AM_IsAudioPlaybackOn( void );
+void AM_SetBlockMED( uint32 RAT, bool b, uint32 pos );
+void AM_Set2GCodecInfo(uint16 speech_mode, int8 sub_channel);
+#endif
+
+
diff --git a/mcu/driver/audio/src/v1/inc/amr_table.h b/mcu/driver/audio/src/v1/inc/amr_table.h
new file mode 100644
index 0000000..4469b50
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/amr_table.h
@@ -0,0 +1,102 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * amr_table.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Various tables for AMR and AMR-WB speech codec.
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef __AMR_TABLE_H
+#define __AMR_TABLE_H
+
+extern const kal_uint8* tblAMROrder[8];
+
+/* These tables will be reference by MPEG4 module */
+extern const kal_uint16 lenSpeechBitsAMR[9];
+extern const kal_uint16 lenSpeechBitsAMR_WB[10];
+
+/* input: Frame Type defined in AMR frame structure */
+/* output: Speech Codec Mode defined in SHERIF */
+extern const kal_uint8 FTtoSCM_AMR[8];
+extern const kal_uint16 AMR_get_tab[16]; /* bits order of SHERIF */
+extern const kal_uint16 AMR_ord_tab[16]; /* bits order of AMR file */
+extern const kal_uint8 AMR_frame_length[9];
+
+extern const kal_uint16* tblAMR_WBOrder[9];
+extern const kal_uint8 FTtoSCM_AMR_WB[9];
+extern const kal_uint8 AWB_frame_length[10];
+
+#endif
+
+
diff --git a/mcu/driver/audio/src/v1/inc/apAudSysConfig.h b/mcu/driver/audio/src/v1/inc/apAudSysConfig.h
new file mode 100644
index 0000000..a001961
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/apAudSysConfig.h
@@ -0,0 +1,9 @@
+
+#ifndef _AP_AUD_SYS_CONFIG_H
+#define _AP_AUD_SYS_CONFIG_H
+
+
+void ApAudSys_config(void);
+
+#endif //_AP_AUD_SYS_CONFIG_H
+
diff --git a/mcu/driver/audio/src/v1/inc/audio_def.h b/mcu/driver/audio/src/v1/inc/audio_def.h
new file mode 100644
index 0000000..0da17a3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/audio_def.h
@@ -0,0 +1,284 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * audio_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file defines all the audio registers used in audio module.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __AUDIO_DEF_H
+#define __AUDIO_DEF_H
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifndef RINGBUFFER_T
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /* RINGBUFFER_T */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#endif //__AUDIO_DEF_H
+
diff --git a/mcu/driver/audio/src/v1/inc/audio_dsp_d2c_def.h b/mcu/driver/audio/src/v1/inc/audio_dsp_d2c_def.h
new file mode 100644
index 0000000..5dd3acc
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/audio_dsp_d2c_def.h
@@ -0,0 +1,310 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * audio_dsp_d2c_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file defines all the D2M used in audio module.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef __AUD_DSP_D2C_DEF__
+#define __AUD_DSP_D2C_DEF__
+
+#include "sal_def.h"
+
+
+
+
+ #define IO4567_D2C_ID_SPEECH_BASE 1 //1~30
+ #define IO4567_D2C_ID_AUDIO_BASE 31 //31~60
+ #define IO4567_D2C_ID_OTHER_BASE 61 //61~63
+
+ //Speech
+ #define DP_D2C_SPEECH_UL_ID (IO4567_D2C_ID_SPEECH_BASE+0 ) // mapping to SpeechDSP DP_D2C_SPEECH_UL_ID interrupt which must be consistent with SpeechDSP's setting(D2C_Status_80.h)
+ #define DP_D2C_SPEECH_DL_ID (IO4567_D2C_ID_SPEECH_BASE+1 ) // mapping to SpeechDSP DP_D2C_SPEECH_DL_ID interrupt which must be consistent with SpeechDSP's setting(D2C_Status_80.h)
+
+ /* Speech Driver Mapping which can be changed. It is independent of SpeechDSP's setting(D2C_Status_80.h) */
+ #define DP_D2C_INT_MAPPING_BASIC (IO4567_D2C_ID_SPEECH_BASE+5 )
+
+ #define DP_D2C_PCM_REC_INT (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_REC_PCM ) // idle or TCH pcm record
+ #define DP_D2C_VM_REC_INT (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_REC_VM ) // idle or TCH vm record
+ #define DP_D2C_VMEPL_REC_INT (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_REC_EPL ) // idle or TCH VM EPL record
+
+ #define DP_D2C_3G_DONE_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_3G_UL ) // 3G Call UL
+ #define DP_D2C_3G_DONE_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_3G_DL ) // 3G Call DL
+
+ #define DP_D2C_4G_AMR_DONE_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_4G_UL ) // 4G Call UL AMR
+ #define DP_D2C_4G_AMR_DONE_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_4G_DL ) // 4G Call DL AMR
+
+ #define DP_D2C_4G_PCM_DONE_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_EXTCOD_UL ) // 4G Call UL PCM
+ #define DP_D2C_4G_PCM_DONE_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_EXTCOD_DL ) // 4G Call DL PCM
+
+ #define DP_D2C_4G_AAMPLUS (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_4G_AAMPLUS ) // 4G AAM Plus
+
+ #define D2C_SOUND_EFFECT_INT_ID_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_BGS_DL) // Background Sound, org DL+UL(MT6589, MT6280), new UL (MT6572, MT6582)
+ #define D2C_SOUND_EFFECT_INT_ID_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_BGS_UL) // Background Sound, new UL (MT6572, MT6582)
+ #define D2C_AUDIO_VIA_BT_ID (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_AVBT ) // Audio via BT
+ #define DP_D2C_PCM_EX_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_PNW_DL ) // PCMNWAY for DL
+ #define DP_D2C_PCM_EX_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_PNW_UL ) // PCMNWAY for UL
+ #define DP_D2C_DACA_REQ_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_DACA_DL ) // DATACARD for DL
+ #define DP_D2C_DACA_REQ_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_DACA_UL ) // DATACARD for UL
+ #define DP_D2C_RAMP_DONE_INT_ID (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_RAMP_DONE ) // RAMP DONE
+ #define DP_D2C_MIXER2_DL_ID (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_MIXER2_DL ) // MIXER2 DL
+ #define DP_D2C_VOICE_QUALITY_ID (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_DMF ) // noice quality notify
+ #define DP_D2C_MIXER3_UL_ID (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_MIXER3 ) // MIXER3 for telephonyTX
+
+ #define DP_D2C_4G_AAM (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_4G_AAM ) // 4G Call UL AMR
+ //C2K
+ #define DP_D2C_C2K_DONE_UL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_C2K_UL )
+ #define DP_D2C_C2K_DONE_DL (DP_D2C_INT_MAPPING_BASIC+SAL_DSPINT_PRIO_C2K_DL )
+
+
+ //Audio
+ #define DP_D2C_WT_INT (IO4567_D2C_ID_AUDIO_BASE+0) //0x0013 // WT to MCU interrupt
+ #define DP_D2C_PCMROUNT_INT (IO4567_D2C_ID_AUDIO_BASE+1) //0xABCD // PCMRount to MCU interrupt
+ #define DP_D2C_MP3_INT (IO4567_D2C_ID_AUDIO_BASE+2) //0x1111 // MP3 to MCU interrupt
+ #define DP_D2C_AAC_CT_INT (IO4567_D2C_ID_AUDIO_BASE+3) //0x2222 // AAC, AACPLUS, AACPS, BSAC to MCU interrupt
+ #define DP_D2C_WMA_INT (IO4567_D2C_ID_AUDIO_BASE+4) //0x3333 // WMA to MCU interrupt
+ #define DP_D2C_AWB_PLUS_INT (IO4567_D2C_ID_AUDIO_BASE+5) //0xBBBB // AWB PLUS to MCU interrupt
+ #define DP_D2C_AUDLP_ERR_INT (IO4567_D2C_ID_AUDIO_BASE+6) //0xEECC
+ #define DP_D2C_AVSYNC_A2V_INT (IO4567_D2C_ID_AUDIO_BASE+7) //0x1234 // AVSync to MCU interrupt
+ #define DP_D2C_SBC_INT (IO4567_D2C_ID_AUDIO_BASE+8) //0xA4BC
+ #define DP_D2C_I2S_REC_INT (IO4567_D2C_ID_AUDIO_BASE+9) //0x1414
+ #define DP_D2C_COOK_INT (IO4567_D2C_ID_AUDIO_BASE+10) //0x1313 // COOK, D2C interrupt
+ //Other
+ #define D2C_INT6_MAGIC (IO4567_D2C_ID_OTHER_BASE+0) //0xDD66
+ #define D2C_DSP_DEAD_INT_ID (IO4567_D2C_ID_OTHER_BASE+1) //0xDD44
+ #define D2C_MPU_ERROR (IO4567_D2C_ID_OTHER_BASE+2) //0x002A
+ #define BT_CVSD_HISR_MAGIC_NO (0x2537) //For BT CVSD, used in cvsd driver
+
+
+/* -------------------------------------------------------------------------- */
+/* Old DSP to MCU interrupt magic number definition rename */
+/* -------------------------------------------------------------------------- */
+ #define DP_D2C_3G DP_D2C_3G_DONE
+ #define DP_D2C_PCM_P DP_D2C_WAV_REQ
+ // #define DP_D2C_PCM_R DP_D2C_WAV_REC_REQ // unused
+
+ /* refactoring
+#if defined(MT6280)
+ #define DP_D2C_PCM_EX_UL DP_D2C_CTM_VOIP_REQ_UL
+ #define DP_D2C_PCM_EX_DL DP_D2C_CTM_VOIP_REQ_DL
+#else
+ #define DP_D2C_PCM_EX DP_D2C_CTM_VOIP_REQ
+#endif
+ */
+
+ // #define DP_D2C_PCM_TCH_R D2C_UL_DL_PCM_REC_INT_ID // unused
+ #define DP_D2C_WAV_REC D2C_WAV_REC_REQ_ID
+ #define DP_D2C_ADAPT_VOL D2C_RINI_ID
+
+ #define DP_D2C_WT DP_D2C_WT_INT
+ #define DP_D2C_PCM_RUT DP_D2C_PCMROUNT_INT
+ #define DP_D2C_DAF DP_D2C_MP3_INT
+ #define DP_D2C_AAC DP_D2C_AAC_CT_INT
+ #define DP_D2C_WMA DP_D2C_WMA_INT
+ #define DP_D2C_AWBPLUS DP_D2C_AWB_PLUS_INT
+ #define DP_D2C_AVSYNC DP_D2C_AVSYNC_A2V_INT
+ #define DP_D2C_I2S_REC DP_D2C_I2S_REC_INT
+ #define DP_D2C_COOK DP_D2C_COOK_INT
+ #define D2C_MAGIC_NO_SBC DP_D2C_SBC_INT
+ #define D2C_AUDIO_VIA_8KBT_ID D2C_AUDIO_VIA_BT_ID
+ #define SND_EFFECT_MAGIC_NO D2C_SOUND_EFFECT_INT_ID
+
+#endif //__AUD_DSP_D2C_DEF__
+
+
diff --git a/mcu/driver/audio/src/v1/inc/audio_em_struct.h b/mcu/driver/audio/src/v1/inc/audio_em_struct.h
new file mode 100644
index 0000000..927b07a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/audio_em_struct.h
@@ -0,0 +1,231 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2008
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * aud_custom_exp.h
+ *
+ * Project:
+ * --------
+ * DUMA
+ *
+ * Description:
+ * ------------
+ * This file is the header of audio customization related function or definition.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * $Revision:$
+ * $Modtime:$
+ * $Log:$
+ *
+ * 10 24 2016 sheila.chen
+ * [MOLY00209193] [93MD] speech driver
+ * Remove old historys.
+ *
+ * 02 03 2015 fu-shing.ju
+ * [MOLY00091627] TK6291 development
+ * Sync Audio driver with MOLY TRUNK W15.05.P1.
+ *
+ * 02 12 2014 sheila.chen
+ * [MOLY00050441] [MT6595 Bring-Up] speech related code
+ * 95 ENH Basic
+ *
+ * Merging
+ *
+ * //MOLY_CBr/sheila.chen/MOLY_95It/mcu/driver/audio/src/...
+ *
+ * to //MOLY/TRUNK/MOLY/mcu/driver/audio/src/...
+ *
+ * 05 22 2013 sheila.chen
+ * [MOLY00023100] [Volunteer Patch][[MP Feature Patch Back] [Vibration Speaker] Speech HAL part (make 2-in1, 3-in-1 difference)
+ * 3-in-1 speaker modification. (to indicate 2-in-1 or 3-in-1)
+ *
+ * 05 03 2013 sheila.chen
+ * [MOLY00008234] [MT6572/MT6582] Integration
+ * 3-in-1 speaker interface
+ *
+ * 03 08 2013 sheila.chen
+ * [MOLY00008234] [MT6572/MT6582] Integration
+ * Lenovo's new feature for MT6582 & MT657
+ *
+ * 11 21 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Warming removal 3
+ *
+ * Fix CTM potential bug
+ *
+ * 10 15 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * 1. enable background sound
+ *
+ * 2. change WB em data structure
+ *
+ * 09 11 2012 sheila.chen
+ * [MOLY00000112] [MT6583] Pre-integration
+ * Sync Mode number
+ *
+ * 07 16 2012 sheila.chen
+ * NULL
+ * phase in 75+80.
+ *
+ * 06 27 2012 sheila.chen
+ * removed!
+ * Phase-in pcm2way
+ *
+ * 06 04 2012 sheila.chen
+ * removed!
+ * .
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef AUDIO_CUSTOM_EXP_H
+#define AUDIO_CUSTOM_EXP_H
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+typedef struct _AUDIO_VIBSPK_PARAMETER_STRUCT_
+{
+ short notch_filter_para[15];
+ bool is2In1Spk; // true for 2-in-1 speaker, false for 3-in-1 speaker.
+
+} AUDIO_VIBSPK_PARAMETER_STRUCT;
+
+typedef struct _AUDIO_NXP_SMARTPA_PARAMETER_STRUCT_
+{
+ bool isNxpFeatureOptOn;
+ short chip_delay_with_switch;
+ 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,
+
+} AUDIO_NXP_SMARTPA_PARAMETER_STRUCT;
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/bgSnd.h b/mcu/driver/audio/src/v1/inc/bgSnd.h
new file mode 100644
index 0000000..44ef7e3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/bgSnd.h
@@ -0,0 +1,54 @@
+
+#ifndef __BGSNG_H__
+#define __BGSNG_H__
+
+#define BGSND_RB_DEFAULT_THRESHOLD 640
+
+/*
+int32 BGSND_GetFreeSpace(void);
+void BGSND_WriteData(kal_uint8 *srcBuf, kal_int32 bufLen);
+
+void BGSND_ConfigULMixer(kal_bool bULSPHFlag, kal_int8 ULSNDGain );
+void BGSND_ConfigDLMixer(kal_bool bDLSPHFlag, kal_int8 DLSNDGain );
+void BGSND_Start(void (*bgSnd_hisrHandler)(void), void (*bgSnd_offHandler)(void), kal_uint8 ULGainLevel , kal_uint8 DLGainLevel);
+void BGSND_Stop(void);
+void BGSND_Close(void);
+void BGSND_INIT(void);
+*/
+
+typedef enum {
+ BGSND_DL_PROCESS = 0, //you cannot change the value since I use "1-type" to switch either.
+ BGSND_UL_PROCESS = 1,
+}BGSND_PROCESS_TYPE;
+
+
+typedef enum {
+ EXT_SRC_STATE_IDLE = 0,
+ EXT_SRC_STATE_RUN,
+ EXT_SRC_STATE_FLUSHING,
+ EXT_SRC_STATE_FLUSHING_OVER,
+ EXT_SRC_STATE_STOPPING,
+}EXT_SRC_STATE_TYPE;
+
+
+int32 EXT_BGSND_GetFreeSpace(uint32 id, BGSND_PROCESS_TYPE type);
+int32 EXT_BGSND_GetDataCount(uint32 id, BGSND_PROCESS_TYPE type);
+void EXT_BGSND_WriteSrcBuffer(uint32 id, kal_uint8 *srcBuf, kal_int32 bufLen, BGSND_PROCESS_TYPE type);
+void EXT_BGSND_WriteExtBuffer(uint32 id, int gain, BGSND_PROCESS_TYPE type);
+
+void EXT_BGSND_ConfigMixer(int id, kal_bool bSPHFlag, kal_int8 SNDGain, BGSND_PROCESS_TYPE type);
+uint32 EXT_BGSND_Start(void (*offHdr)(void),
+ void (*DLHisr)(void), //move data from src -> ext
+ void (*ULHisr)(void), //move data from src -> ext
+ kal_int8 DLSNDGain,
+ kal_int8 ULSNDGain
+ /*,
+ void (*EventHandler)(void)*/);
+void EXT_BGSND_Flush(uint32 id);
+void EXT_BGSND_Close(uint32 id);
+
+uint32 EXT_BGSND_init();
+
+EXT_SRC_STATE_TYPE EXT_BGSND_GetStatus(int id, BGSND_PROCESS_TYPE enULDL);
+
+#endif //__BGSNG_H__
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/inc/bt_sco_drv.h b/mcu/driver/audio/src/v1/inc/bt_sco_drv.h
new file mode 100644
index 0000000..a62039f
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/bt_sco_drv.h
@@ -0,0 +1,374 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * BT_SCO_drv.h
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * BT SCO driver header file
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __BT_SCO_DRV_H
+#define __BT_SCO_DRV_H
+
+#include "l1aud_common_def.h"
+#include "reg_base.h"
+
+// PLC Interface
+/*
+extern kal_int32 g711plc_GetMemorySize(void);
+extern void g711plc_construct(void *lc);
+extern void g711plc_addtohistory(void *lc, kal_int16 *s);
+extern void g711plc_dofe(void *lc,kal_int16 *out);
+*/
+
+extern void g711plc_addtohistory_v2(void *lc, short *s, unsigned int dwBtEv3HalfBad);
+extern void g711plc_dofe_v2(void *lc, short *s, unsigned int dwBtEv3HalfBad);
+extern int g711plc_GetMemorySize_v2();
+extern int g711plc_construct_v2(void *lc, unsigned int dwFs);
+
+extern void CVSD_DownSample_Process(void *pHandle, short *pInSample, short *pOutSample, short *pTempBuffer, int iSourceSamples);
+extern int CVSD_DownSample_GetMemory(void);
+extern void *CVSD_DownSample_Init(char *pBuffer);
+extern void CVSD_UpSample_Process(void *pHandle, short *pInSample, short *pOutSample, short *pTempBuffer, int iSourceSamples);
+extern int CVSD_UpSample_GetMemory(void);
+extern void *CVSD_UpSample_Init(char *pBuffer);
+
+void BT_SCO_Loopback_OFF(void);
+void BT_SCO_Loopback_ON(kal_bool fDisableCodec, kal_bool fWideBand);
+kal_bool BT_SCO_IS_SPEECH_ON(void);
+void BT_SCO_SPEECH_OFF(void);
+void BT_SCO_SPEECH_ON(kal_bool fWideBand);
+void BT_SCO_Init(void);
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+#define __MSBC_CODEC_SUPPORT__ 1
+
+// BT HW Register address
+//#define BTSRAM_base (0xA8080000) //defined in mcu/driver/sys_drv/regbase/inc/reg_base_mtxxxx.h
+//#define BTPKT_base (0xA8000000) //defined in mcu/driver/sys_drv/regbase/inc/reg_base_mtxxxx.h
+#if defined(MT6885)
+#define BTSRAM_base (BASE_MADDR_WCN_AHB_SLAVE + 0x00840000)
+#elif defined(MT6779)
+#define BTSRAM_base (BASE_MADDR_WCN_AHB_SLAVE + 0x00090000) //defined in mcu/driver/sys_drv/regbase/inc/reg_base_mtxxxx.h
+#else
+#define BTSRAM_base (BASE_MADDR_WCN_AHB_SLAVE + 0x00080000) //defined in mcu/driver/sys_drv/regbase/inc/reg_base_mtxxxx.h
+#endif
+
+#define BTPKT_base (BASE_MADDR_WCN_AHB_SLAVE) //defined in mcu/driver/sys_drv/regbase/inc/reg_base_mtxxxx.h
+
+#if defined(MT6885)
+#define BT_SCO_HW_REG_PACKET_R ((volatile kal_uint32*)(BTPKT_base+0x830140))
+#define BT_SCO_HW_REG_PACKET_W ((volatile kal_uint32*)(BTPKT_base+0x830144))
+#define BT_SCO_HW_REG_CONTROL ((volatile kal_uint32*)(BTPKT_base+0x830148))
+#elif (defined(MT6765) || defined(MT3967) || defined(MT6779) || defined(MT6785) || defined(MERCURY) || defined(MT6873) || defined(MT6853) || defined(MT6833) || defined(MT6877))
+#define BT_SCO_HW_REG_PACKET_R ((volatile kal_uint32*)(BTPKT_base+0x50140))
+#define BT_SCO_HW_REG_PACKET_W ((volatile kal_uint32*)(BTPKT_base+0x50144))
+#define BT_SCO_HW_REG_CONTROL ((volatile kal_uint32*)(BTPKT_base+0x50148))
+#else
+#define BT_SCO_HW_REG_PACKET_R ((volatile kal_uint32*)(BTPKT_base+0x0FD0))
+#define BT_SCO_HW_REG_PACKET_W ((volatile kal_uint32*)(BTPKT_base+0x0FD4))
+#define BT_SCO_HW_REG_CONTROL ((volatile kal_uint32*)(BTPKT_base+0x0FD8))
+#endif
+
+#endif
+#if defined(MT6752) // temp irq id,for MT6752 MD2
+ #if !defined (__MD1__)
+ #define IRQ_BT_CVSD_CODE 0
+ #endif
+#endif
+
+#define MSBC_BTSTREAM_FRAME_BYTE 57
+#define MSBC_PCM_FRAME_BYTE 240 //120 sample
+
+#define BT_SCO_PACKET_120 120
+#define BT_SCO_PACKET_180 180
+
+#define BT_CVSD_TX_NREADY (1<<21)
+#define BT_CVSD_RX_READY (1<<22)
+#define BT_CVSD_TX_UNDERFLOW (1<<23)
+#define BT_CVSD_RX_OVERFLOW (1<<24)
+#define BT_CVSD_Codec_id_1 (1<<25)
+#define BT_CVSD_Codec_id_2 (1<<26)
+#define BT_CVSD_INTERRUPT (1<<31)
+
+#define BT_CVSD_CLEAR (BT_CVSD_TX_NREADY | BT_CVSD_RX_READY | BT_CVSD_TX_UNDERFLOW | BT_CVSD_RX_OVERFLOW | BT_CVSD_INTERRUPT)
+#define BT_CVSD_Codec_id (BT_CVSD_Codec_id_1 | BT_CVSD_Codec_id_2) //00:init 01:cvsd 02:msbc
+
+
+//TX
+#define SCO_TX_ENCODE_SIZE (60 ) // 60 byte (60*8 samples)
+#define SCO_TX_PACKER_BUF_NUM (8 )
+#define SCO_TX_PACKET_MASK (0x7 )
+#define SCO_TX_PCM64K_BUF_SIZE (SCO_TX_ENCODE_SIZE*2*8 ) // 60 * 2 * 8 byte
+#define SCO_TX_RINGBUFFER_SIZE (320*9 ) // = 2880, should by multple of 320 and 360 and 240
+
+//RX
+#define SCO_RX_PLC_SIZE (30 )
+#define SCO_RX_PACKER_BUF_NUM (16 )
+#define SCO_RX_PACKET_MASK (0xF )
+#define SCO_RX_PCM64K_BUF_SIZE (SCO_RX_PLC_SIZE*2*8 )
+#define SCO_RX_PCM8K_BUF_SIZE (SCO_RX_PLC_SIZE*2 )
+#define SCO_RX_RINGBUFFER_SIZE (320*9 ) // = 2880, should by multple of 320 and 360 and 240
+
+#define SCORX_BT_CVSD_RX_PACKET_BUFFER_LEN (BT_CVSD_BLOCKSIZE * 6) // 360 byte
+
+#define NB_SPEECH_FRAME_SIZE 320 //BYTE
+#define WB_SPEECH_FRAME_SIZE 640 //BYTE
+
+typedef enum {
+ BT_SCO_STATE_IDLE=0,
+ BT_SCO_STATE_RUNNING,
+ BT_SCO_STATE_ENDING
+} BT_SCO_STATE;
+
+typedef enum {
+ BT_SCO_MODE_SPEECH,
+ BT_SCO_MODE_LOOPBACK_WITH_CODEC,
+ BT_SCO_MODE_LOOPBACK_WITHOUT_CODEC
+} BT_SCO_MODE;
+
+typedef enum {
+ BT_SCO_MOD_CVSD_ENCODE,
+ BT_SCO_MOD_CVSD_DECODE,
+ BT_SCO_MOD_PLC_NB,
+ BT_SCO_MOD_CVSD_TX_SRC,
+ BT_SCO_MOD_CVSD_RX_SRC,
+ BT_SCO_MOD_PCM_RINGBUF_TX,
+ BT_SCO_MOD_PCM_RINGBUF_RX,
+ BT_SCO_MOD_MSBC_DECODE,
+ BT_SCO_MOD_MSBC_ENCODE,
+ BT_SCO_MOD_PLC_WB
+} BT_SCO_MODULE;
+
+typedef enum {
+ BT_SCO_DIRECT_BT2ARM,
+ BT_SCO_DIRECT_ARM2BT
+} BT_SCO_DIRECT;
+
+typedef enum {
+ BT_SCO_CVSD_30 =0,
+ BT_SCO_CVSD_60 =1,
+ BT_SCO_CVSD_90 =2,
+ BT_SCO_CVSD_120=3,
+ BT_SCO_CVSD_10 =4,
+ BT_SCO_CVSD_20 =5,
+ BT_SCO_CVSD_MAX=6
+} BT_SCO_PACKET_LEN;
+
+typedef struct {
+ //handle
+ void *pSRCHandle;
+ void *pEncHandle;
+ AUD_RB_INFO RingBuffer;
+
+ //bitstream buffer
+ kal_uint8 PacketBuf[SCO_TX_PACKER_BUF_NUM][SCO_TX_ENCODE_SIZE];
+ kal_uint32 iPacket_w;
+ kal_uint32 iPacket_r;
+ kal_uint8 PcmBuf_64k[SCO_TX_PCM64K_BUF_SIZE];
+ kal_uint8 PcmBuf_Temp[SCO_TX_PCM64K_BUF_SIZE];
+ kal_uint32 uPcmBuf_w;
+ kal_bool fUnderflow;
+} BT_SCO_TX;
+
+typedef struct {
+ //handle
+ void *pDecHandle;
+ void *pPLCHandle;
+ void *pSRCHandle;
+
+ //bitstream buffer
+ kal_uint8 PacketBuf[SCO_RX_PACKER_BUF_NUM][SCO_RX_PLC_SIZE];
+ kal_bool PacketValid[SCO_RX_PACKER_BUF_NUM];
+ kal_uint32 iPacket_w;
+ kal_uint32 iPacket_r;
+
+ //temp buffer
+ kal_uint8 PcmBuf_64k[SCO_RX_PCM64K_BUF_SIZE];
+ kal_uint8 PcmBuf_Temp[SCO_RX_PCM64K_BUF_SIZE];
+ kal_uint8 PcmBuf_8k[SCO_RX_PCM8K_BUF_SIZE];
+ kal_uint32 uPcmBuf_r; //for PcmBuf_8k
+ AUD_RB_INFO RingBuffer;
+ kal_bool fOverflow;
+
+} BT_SCO_RX;
+
+#endif //__BT_SCO_DRV_H
+
diff --git a/mcu/driver/audio/src/v1/inc/ctm_drv.h b/mcu/driver/audio/src/v1/inc/ctm_drv.h
new file mode 100644
index 0000000..ac3ba42
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/ctm_drv.h
@@ -0,0 +1,203 @@
+/*******************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * l1ctm.h
+ *
+ * Project:
+ * --------
+ *
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+// l1ctm.h
+#ifndef __L1CTM_H
+#define __L1CTM_H
+#include "l1aud_common_def.h"
+
+typedef enum{
+ DIRECT_MODE,
+ FULL_MODE = 1,
+ VCO_MODE = 2,
+ HCO_MODE = 4
+} L1Ctm_Interface;
+
+typedef enum{
+ CTM_MO_SUCCESS,
+ CTM_MO_FAIL,
+ CTM_MT_DETECTED,
+ CTM_CHAR_SENT,
+ CTM_CHAR_RECEIVED,
+ CTM_TX_BURST_START,
+ CTM_TX_BURST_END
+} L1Ctm_Event;
+
+// Msg_Info Debug Message
+#define OPEN_CTM_REQUEST 1
+#define CLOSE_CTM_REQUEST 2
+#define UL_READ_PCM_FILE_REQUEST 3
+#define DL_READ_PCM_FILE_REQUEST 4
+#define DL_READ_BFI_FILE_REQUEST 5
+#define UL_IN_WRITE_FILE_REQUEST 6
+#define DL_IN_WRITE_FILE_REQUEST 7
+#define UL_OUT_WRITE_FILE_REQUEST 8
+#define DL_OUT_WRITE_FILE_REQUEST 9
+#define GENERAL_WRITE_FILE_REQUEST 10
+#define PUT_TEXT_TO_UL_CTM_BUF_REQUEST 11
+#define UL_CTM_BUF_DUMMY_READ_REQUEST 12
+
+#define DSP_REC_RX_BUF0_REQUEST 13
+#define DSP_REC_NB_RESULT0_REQUEST 14
+#define DSP_REC_FN_REQUEST 15
+#define DSP_REC_EQ_SO0_REQUEST 16
+
+#define START_NEGOTIATION_REQUEST 17
+
+#define DONE_WRITE_FILE_REQUEST 18
+
+
+// need to define CTM_Param
+typedef struct
+{
+ kal_int16 cprm_tone_demod_down_samp; // 1 (0, 1)
+} CTM_Param;
+
+typedef struct{
+ bool isRttOn;
+}RTT_Module;
+
+typedef void (*L1Ctm_Callback)(L1Ctm_Event , void*);
+typedef void (*L1Ctm_DebugCallback)(uint16 pos, uint16 *buffer, uint16 len, bool isDone);
+
+uint32 L1Ctm_GetMemReq(void);
+void L1Ctm_Open(L1Ctm_Interface a, L1Ctm_Callback handler, uint8 *buf, uint32 buf_len, L1Ctm_DebugCallback debugCallback);
+void L1Ctm_Close(void);
+void L1Ctm_Stop(void);
+uint32 L1Ctm_TxPutText(const uint8 *text, uint32 len, uint32 *left_space);
+uint32 L1Ctm_RxGetText(uint8 *text, uint32 len, uint32 *left_count);
+
+void RTT_UL_LEN_Queue_Init(void);
+void RTT_UL_LEN_Queue_Put(kal_uint16 len);
+kal_uint16 RTT_UL_LEN_Queue_Get(void);
+kal_bool RTT_UL_LEN_Queue_isEmpty(void);
+kal_bool RTT_UL_LEN_Queue_isFull(void);
+kal_uint16 RTT_UL_LEN_Queue_Size(void);
+void RTT_DL_LEN_Queue_Init(void);
+void RTT_DL_LEN_Queue_Put(kal_uint16 len);
+kal_uint16 RTT_DL_LEN_Queue_Get(void);
+kal_bool RTT_DL_LEN_Queue_isEmpty(void);
+kal_bool RTT_DL_LEN_Queue_isFull(void);
+kal_uint16 RTT_DL_LEN_Queue_Size(void);
+
+
+void RTT_UL_ID_Queue_Init(void);
+void RTT_UL_ID_Queue_Put(kal_uint8 id);
+kal_uint8 RTT_UL_ID_Queue_Get(void);
+kal_bool RTT_UL_ID_Queue_isEmpty(void);
+kal_bool RTT_UL_ID_Queue_isFull(void);
+kal_uint16 RTT_UL_ID_Queue_Size(void);
+void RTT_DL_ID_Queue_Init(void);
+void RTT_DL_ID_Queue_Put(kal_uint8 id);
+kal_uint8 RTT_DL_ID_Queue_Get(void);
+kal_bool RTT_DL_ID_Queue_isEmpty(void);
+kal_bool RTT_DL_ID_Queue_isFull(void);
+kal_uint16 RTT_DL_ID_Queue_Size(void);
+
+
+void TTY_LTE_PSR_UL_Queue_Init(void);
+kal_uint8 TTY_LTE_PSR_UL_Get(void);
+void TTY_LTE_PSR_UL_Put(kal_uint8 tty_char);
+kal_bool TTY_LTE_PSR_UL_isEmpty(void);
+kal_bool TTY_LTE_PSR_UL_isFull(void);
+kal_uint16 TTY_LTE_PSR_UL_Queue_Size(void);
+void TTY_LTE_PSR_DL_Queue_Init(void);
+void TTY_LTE_PSR_DL_Put(kal_uint8 tty_char);
+kal_uint8 TTY_LTE_PSR_DL_Get();
+kal_uint16 TTY_LTE_PSR_DL_Queue_Size(void);
+kal_bool TTY_LTE_PSR_DL_isEmpty(void);
+kal_bool TTY_LTE_PSR_DL_isFull(void);
+void TTY_LTE_PSR_DL_PutString(kal_uint8 call_id, kal_uint8 string[256], kal_uint16 length);
+kal_uint16 TTY_LTE_PSR_UL_GetString(kal_uint8 call_id, kal_uint8 *buf, kal_uint16 *length);
+kal_uint16 TTY_LTE_PSR_UL_GetChar(kal_uint8 call_id, kal_uint8 *buf);
+void SP_L4C_SetERTTSTR(kal_uint8 call_id, kal_uint8 string[256], kal_uint16 length);
+void SP_L4C_SendERTTSTR(kal_uint8 call_id);
+
+
+void L1Ctm_RTTOpen();
+void L1Ctm_RTTClose();
+bool getRttStatus();
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/extcodec.h b/mcu/driver/audio/src/v1/inc/extcodec.h
new file mode 100644
index 0000000..e04eedb
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/extcodec.h
@@ -0,0 +1,141 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * extcodec.h
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * EXTCODEC interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __EXTCODEC_H
+#define __EXTCODEC_H
+
+void Extcodec_Set_Delay(kal_uint32 delay);
+void Extcodec_Call_Open();
+void Extcodec_Call_Close();
+void Extcodec_Init();
+void Extcodec_hisr_ul_loopback(void *data);
+void Extcodec_hisr_dl_loopback(void *data);
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/l1aud_common_def.h b/mcu/driver/audio/src/v1/inc/l1aud_common_def.h
new file mode 100644
index 0000000..6a3dab9
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1aud_common_def.h
@@ -0,0 +1,513 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2011
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * audio_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * The common definition used in audio module.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef __L1AUD_COMMON_DEF_H
+#define __L1AUD_COMMON_DEF_H
+
+#include "kal_public_api.h"
+#include "reg_base.h"
+//#define SHAREG2_base (0xA77A0000)//(L1_BASE_MADDR_SHARE_D1) //the same as L1_BASE_MADDR_SHARE_D1
+//#define DPRAM_CPU_base (0xA7400000)//(L1_BASE_MADDR_DM_IDMA) //FIXIT: the same as L1_BASE_MADDR_DM_IDMA
+//#define IDMA_base (0xA7200000)//(L1_BASE_MADDR_CM_IDMA) //FIXIT: the same as L1_BASE_MADDR_CM_IDMA
+
+//#if defined(__CDMA2000_RAT__)
+#define __C2K_SPEECH_SUPPORT__
+#define _C2K_DTX_SUPPORT_ (0)
+//#else
+//#define C2K_SDRV_DISABLE
+//#endif
+
+//#define __FAKE_C2K_LOOPBACK__
+//#define __FAKE_3G_LOOPBACK__
+
+#ifdef __FAKE_3G_LOOPBACK__
+#ifndef __CSHSPA_SUPPORT__
+#define __CSHSPA_SUPPORT__
+#endif
+#endif
+
+//#define SHARE_base (AFE_SHARED_REGISTER_BASE)
+
+typedef volatile unsigned short* DPRAMADDR;
+typedef volatile unsigned long* APBADDR32; /* APB addr is 32 bits */
+typedef volatile unsigned short* APBADDR; /* APB addr is 32 bits */
+
+//#define __VOLTE_SUPPORT__
+#define _SMR_SUPPORT_
+//#define __AAM_AUTO_TEST_SUPPORT__
+/*
+#define IDMA_LONG_ADDR ((APBADDR32)IDMA_LONG)
+#define IDMA_SHORT_ADDR ((DPRAMADDR)IDMA_SHORT)
+#define DSP_CM_ADDR(page,addr) ((APBADDR32)(IDMA_CM0+((page)<<16)+((addr)<<2)))
+#define DSP_PM_ADDR(page,addr) ((DPRAMADDR)(IDMA_PM0+((page)<<16)+((addr)<<1)))
+#define DSP_DM_ADDR(page,addr) ((DPRAMADDR)(IDMA_DM0+((page)<<16)+((addr)<<1)))*/
+
+#define AUD_1TICK(tick) (tick * ((KAL_TICKS_10_MSEC) >> 1)) /* New Tick Transfer 1tick */
+#define AUD_10TICK(tick) (tick * (KAL_TICKS_50_MSEC)) /* New Tick Transfer 10tick */
+
+
+/* -------------------------------------------------------------------------- */
+/* Data Type Definition */
+/* -------------------------------------------------------------------------- */
+#ifndef uint16
+typedef kal_uint16 uint16;
+typedef kal_int16 int16;
+typedef kal_uint32 uint32;
+typedef kal_int32 int32;
+typedef kal_uint8 uint8;
+typedef kal_int8 int8;
+typedef kal_bool bool;
+#define true (kal_bool)(1==1)
+#define false (kal_bool)(1==0)
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* DSP Share Registers */
+/* -------------------------------------------------------------------------- */
+// #if defined(MT6280) || defined(MT6589)
+
+/* -------------------------------------------------------------------------- */
+/* Internal definition of audio module */
+/* -------------------------------------------------------------------------- */
+
+// no audio close delay, phase it out
+// #define AUDIO_CLOSE_DELAY 500 //500 ms, unit is 10ms
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+//change mcu and dsp share memory to internal memory, always define after MT6256
+// #if defined(MT6280) || defined(MT6589) || defined(MT6572)
+// #define _DSP_INTERSHAREMEM_EN_ // only using in audio, so phase it out
+#define L1AUDIO_IDMA_ALL_ADDRESS_MODE
+// #endif
+
+
+// For <65nm, dsp coefficients need to reload after sleep. This are always happen after 80, so remove the redundant
+#define __RELOAD_HW_COEFF__ (1)
+
+
+#define _MODEM_RESYNC_2G_
+
+
+#define _2G_DSP_SMR_SUPPORT_
+
+#if defined(__MD93__)
+#define _SPE_ENH_MD_PARSE_
+#else
+#define _SPE_ENH_DSP_PARSE_
+#endif
+
+
+
+#if defined(_2G_DSP_SMR_SUPPORT_)// Notice these , _MODEM_RESYNC_2G_ and _2G_DSP_SMR_SUPPORT_, are exclusive.
+#undef _MODEM_RESYNC_2G_
+#endif
+
+
+#define _MODEM_RESYNC_3G_
+#if defined(_MODEM_RESYNC_3G_)
+//3G FDD Modem Resync
+extern void UL1D_Speech_Resync_Reset_Time_Offset();
+extern kal_int16 UL1D_Speech_Resync_Get_Time_Offset();
+extern void UL1D_Speech_Resync_Update_Time_Offset(kal_bool direction);
+//3G TDD Modem Resync
+extern void TL1C_Reset_Time_Drift();
+extern kal_int16 TL1C_Get_Time_Drift();
+extern void TL1C_Update_Time_Drift(kal_bool direction);
+#endif
+/* -------------------------------------------------------------------------- */
+/* Assertion check */
+/* -------------------------------------------------------------------------- */
+#define ASSERT_REBOOT(st) EXT_ASSERT(st,0,0,0)
+#define DSP_DATA_CARD_INTERFACE_SUPPORT (defined(MT6280))
+
+
+/* -------------------------------------------------------------------------- */
+/* Internal Audio Definition */
+/* -------------------------------------------------------------------------- */
+#define __AUDIO_POWERON_RESET_DSP__
+
+
+#if defined(__HIF_CCCI_SUPPORT__)
+#define __CCCI_OVER_SDIO_SUPPORT__ //currently only MT6290
+#endif
+
+
+
+
+//Reduce VoLTE DL delay. Remove DL HISR.
+#define __REDUCE_VOLTE_DL_DELAY__
+//Modem Logging Feature Option
+#define __MODEM_LOGGING_SUPPORT__
+
+#if defined(__EVS_SUPPORT__)
+#define __EVS_CODEC_SUPPORT__
+#endif //#if defined(__EVS_SUPPORT__)
+
+#define SPH_DEBUGINFO (12)
+typedef enum {
+ SPH_DEBUGINFO12_BIT0 = 1<<0, //AWB+Switch
+ SPH_DEBUGINFO12_BIT1 = 1<<1, //g_bNeedExtraLog
+ SPH_DEBUGINFO12_BIT2 = 1<<2,
+ SPH_DEBUGINFO12_BIT3 = 1<<3,
+ SPH_DEBUGINFO12_BIT4 = 1<<4,
+ SPH_DEBUGINFO12_BIT5 = 1<<5,
+ SPH_DEBUGINFO12_BIT6 = 1<<6,
+ SPH_DEBUGINFO12_BIT7 = 1<<7,
+ SPH_DEBUGINFO12_BIT8 = 1<<8,
+ SPH_DEBUGINFO12_BIT9 = 1<<9,
+ SPH_DEBUGINFO12_BIT10 = 1<<10,
+ SPH_DEBUGINFO12_BIT11 = 1<<11,
+ SPH_DEBUGINFO12_BIT12 = 1<<12,
+ SPH_DEBUGINFO12_BIT13 = 1<<13,
+ SPH_DEBUGINFO12_BIT14 = 1<<14,
+ SPH_DEBUGINFO12_BIT15 = 1<<15,
+}SPH_DEBUGINFO12;
+
+#endif //__COMMON_DEF_H
diff --git a/mcu/driver/audio/src/v1/inc/l1audio_sph_trc.h b/mcu/driver/audio/src/v1/inc/l1audio_sph_trc.h
new file mode 100644
index 0000000..9e804dd
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1audio_sph_trc.h
@@ -0,0 +1,19 @@
+#ifndef _L1AUDIO_SPH_TRC_H
+#define _L1AUDIO_SPH_TRC_H
+
+#if !defined(GEN_FOR_PC)
+#if defined(__TST_MODULE__) || defined(__CUSTOM_RELEASE__)
+#endif /* TST Trace Defintion */
+#endif
+
+#define TRACE_GROUP_VM TRACE_GROUP_1
+#define TRACE_GROUP_EPL TRACE_GROUP_2
+#define TRACE_GROUP_REFMIC TRACE_GROUP_3
+#define TRACE_GROUP_ECHOREF TRACE_GROUP_4
+#define TRACE_GROUP_THIRDMIC TRACE_GROUP_5
+#define TRACE_GROUP_2NDECHOREF TRACE_GROUP_6
+
+#if !defined(GEN_FOR_PC)
+#include"l1audio_sph_trc_mod_l1audio_sph_srv_utmd.h"
+#endif
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/l1audio_sph_trc_mod_l1audio_sph_srv_utmd.json b/mcu/driver/audio/src/v1/inc/l1audio_sph_trc_mod_l1audio_sph_srv_utmd.json
new file mode 100644
index 0000000..c65895e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1audio_sph_trc_mod_l1audio_sph_srv_utmd.json
@@ -0,0 +1,96 @@
+{
+ "endGen": "-",
+ "legacyParameters": {},
+ "module": "MOD_L1AUDIO_SPH_SRV",
+ "startGen": "Legacy",
+ "traceClassDefs": [
+ {
+ "TRACE_INFO": {
+ "debugLevel": "Ultra-High",
+ "tag": [
+ "L1AUDIO_SPH_SRV",
+ "TRACE_INFO"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_WARNING": {
+ "debugLevel": "Low",
+ "tag": [
+ "L1AUDIO_SPH_SRV",
+ "TRACE_WARNING"
+ ],
+ "traceType": "DesignInfo"
+ }
+ },
+ {
+ "TRACE_ERROR": {
+ "debugLevel": "Ultra-High",
+ "tag": [
+ "L1AUDIO_SPH_SRV",
+ "TRACE_ERROR"
+ ],
+ "traceType": "DesignInfo"
+ }
+ },
+ {
+ "TRACE_FUNC": {
+ "debugLevel": "Medium",
+ "tag": [
+ "L1AUDIO_SPH_SRV",
+ "TRACE_FUNC"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_VM": {
+ "debugLevel": "High",
+ "tag": [
+ "L1AUDIO_SPH_SRV",
+ "L1AUDIO_SPH_SRV_VM",
+ "Sensitive"
+ ],
+ "traceType": "Public"
+ }
+ }
+ ],
+ "traceDefs": [
+ {
+ "VM_DATA": {
+ "format": "VM data",
+ "traceClass": "TRACE_VM"
+ }
+ },
+ {
+ "RECORD_LENGTH": {
+ "apiType": "index",
+ "format": "Recording VM length = %u bytes",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SET_EPL_PARA": {
+ "apiType": "index",
+ "format": "EPL common parameter0 is set to %d",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "EPL_PARA_ERROR": {
+ "apiType": "index",
+ "format": "Invalid EPL common parameter0",
+ "traceClass": "TRACE_ERROR"
+ }
+ },
+ {
+ "DEBUG_NUMBER": {
+ "format": "Debug number = %d",
+ "traceClass": "TRACE_WARNING"
+ }
+ }
+ ],
+ "traceFamily": "PS",
+ "userModule": ""
+}
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/inc/l1audio_voc_utmd.json b/mcu/driver/audio/src/v1/inc/l1audio_voc_utmd.json
new file mode 100644
index 0000000..88e4137
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1audio_voc_utmd.json
@@ -0,0 +1,39 @@
+{
+ "traceFamily": "L1",
+ "startGen": "97",
+ "endGen": "-",
+ "legacyParameters": {},
+ "module": "L1Audio_VoC",
+
+ "traceClassDefs": [
+ {
+ "TRACE_VM": {
+ "debugLevel": "Ultra-High",
+ "tag": [
+ "VM",
+ "ONLY"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_EPL": {
+ "debugLevel": "Low",
+ "tag": [
+ "VM",
+ "EPL"
+ ],
+ "traceType": "Public"
+ }
+ }
+ ],
+ "traceDefs": [
+ {
+ "VM_DEBUG_INFO": {
+ "format": "VM debug info[0] = %d",
+ "traceClass": "TRACE_VM"
+ }
+ }
+ ],
+ "userModule": ""
+}
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/inc/l1sp_trc.h b/mcu/driver/audio/src/v1/inc/l1sp_trc.h
new file mode 100644
index 0000000..71d66fc
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1sp_trc.h
@@ -0,0 +1,30 @@
+#ifndef _L1SP_TRC_H
+#define _L1SP_TRC_H
+#ifndef GEN_FOR_PC
+ #ifndef _STACK_CONFIG_H
+ #error "stack_config.h should be included before l1sp_trc.h"
+ #endif
+#endif /* GEN_FOR_PC */
+#include "kal_trace.h"
+#ifndef _KAL_TRACE_H
+ #error "kal_trace.h should be included before nvram_trc.h"
+#endif
+#define TRACE_GROUP_DDLOAD TRACE_GROUP_1
+#define TRACE_GROUP_SND TRACE_GROUP_2
+#define TRACE_GROUP_AUD_PROCESS TRACE_GROUP_3
+#define TRACE_GROUP_SP_DEBUG TRACE_GROUP_5
+#define TRACE_GROUP_SP4G TRACE_GROUP_6
+#define TRACE_GROUP_SP3G TRACE_GROUP_8
+#define TRACE_GROUP_AUD_PLAYBACK TRACE_GROUP_9
+#define TRACE_GROUP_ECALL TRACE_GROUP_1
+#define TRACE_GROUP_AUD_MD2GCTRL TRACE_GROUP_1
+#define TRACE_GROUP_SCO TRACE_INFO
+#define TRACE_GROUP_SPLOG TRACE_INFO
+#if !defined(GEN_FOR_PC)
+#if defined(__TST_MODULE__) || defined(__CUSTOM_RELEASE__)
+#endif /* TST Trace Defintion */
+#endif
+#if !defined(GEN_FOR_PC)
+#include"l1sp_trc_mod_l1sp_utmd.h"
+#endif
+#endif // _L1SP_TRC_H
diff --git a/mcu/driver/audio/src/v1/inc/l1sp_trc_mod_l1sp_utmd.json b/mcu/driver/audio/src/v1/inc/l1sp_trc_mod_l1sp_utmd.json
new file mode 100644
index 0000000..60c2701
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/l1sp_trc_mod_l1sp_utmd.json
@@ -0,0 +1,6464 @@
+{
+ "endGen": "-",
+ "legacyParameters": {},
+ "module": "MOD_L1SP",
+ "startGen": "Legacy",
+ "traceClassDefs": [
+ {
+ "TRACE_INFO": {
+ "debugLevel": "Ultra-High",
+ "tag": [
+ "L1SP",
+ "TRACE_INFO"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_WARNING": {
+ "debugLevel": "Low",
+ "tag": [
+ "L1SP",
+ "TRACE_WARNING"
+ ],
+ "traceType": "DesignInfo"
+ }
+ },
+ {
+ "TRACE_FUNC": {
+ "debugLevel": "Medium",
+ "tag": [
+ "L1SP",
+ "TRACE_FUNC"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_STATE": {
+ "debugLevel": "Ultra-High",
+ "tag": [
+ "L1SP",
+ "TRACE_STATE"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_SP_PS": {
+ "debugLevel": "High",
+ "tag": [
+ "L1SP",
+ "L1SP_SP_PS"
+ ],
+ "traceType": "Public"
+ }
+ }
+ ],
+ "traceDefs": [
+ {
+ "AM_L_SP3G_UPDATEL1DSYNC": {
+ "format": "[SPH_L]sp3g_updateL1DSync_dummy timer_hisr_state_L=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_SP3G_UPDATEL1DSYNC_TIMER": {
+ "format": "[SPH_L]L1AL_Timer_L_HISR timer_hisr_state_L=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_HANDOVER_SKIP": {
+ "format": "[SPH_L]cc_2G_Handover Skip %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_HANDOVER_ENTER": {
+ "format": "[SPH_L]cc_2G_Handover Enter %d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_HANDOVER_LEAVE": {
+ "format": "[SPH_L]cc_2G_Handover Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_CALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_2G_Call_Open Enter %d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_CALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_2G_Call_Open Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_CALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_2G_Call_Close Enter %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_2G_CALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_2G_Call_Close Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_3G_CALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_3G_Call_Open Enter delR=%d delW=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_3G_CALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_3G_Call_Open Leave delR=%d delW=%d P_to_L1_delay=%dms",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_3G_CALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_3G_Call_Close Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_3G_CALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_3G_Call_Close Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_CALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_4G_Call_Open_temp Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_CALLOPEN_ENTER_DBG": {
+ "format": "[DBG]cc_4G_Call_Open_temp Enter %d, delR=%d, delW=%d, u32CurTime64us=%d, u32CurTime64usLocal=%d, u32delay=%d, u32delaySample=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_DBG": {
+ "format": "[DBG]DACA_DBG %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_CALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_4G_Call_Open_temp Leave delR=%d delW=%d P_to_L1_delay=%dms reset_type=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_CALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_4G_Call_Close_temp Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_CALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_4G_Call_Close_temp Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_GCALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_4G_G_Codec_Call_Open_temp Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_GCALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_4G_G_Codec_Call_Open_temp Leave delR=%d delW=%d P_to_L1_delay=%dms",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_GCALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_4G_G_Codec_Call_Close_temp Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_GCALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_4G_G_Codec_Call_Close_temp Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_C2K_CALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_C2K_Call_Open Enter so=%d dtx=%d delR=%d delW=%d delM=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_C2K_CALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_C2K_Call_Open Leave so=%d dtx=%d delR=%d delW=%d delM=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_C2K_CALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_C2K_Call_Close Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_C2K_CALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_C2K_Call_Close Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_STANDBY_CALLOPEN_ENTER": {
+ "format": "[SPH_L]cc_STANDBY_Call_Open Enter codec=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_STANDBY_CALLOPEN_LEAVE": {
+ "format": "[SPH_L]cc_STANDBY_Call_Open Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_STANDBY_CALLCLOSE_ENTER": {
+ "format": "[SPH_L]cc_STANDBY_Call_Close Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_STANDBY_CALLCLOSE_LEAVE": {
+ "format": "[SPH_L]cc_STANDBY_Call_Close Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_SET_VBI_FOR_FSM_ENTER": {
+ "format": "[SPH_L]cc_Set VBI For FSM Enter: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_SET_VBI_FOR_FSM_LEAVE": {
+ "format": "[SPH_L]cc_Set VBI For FSM Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_L1AUD_TASK_CLRBUF": {
+ "format": "[SPH_L]L1AUD_TASK_L clear internal buffer",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_L1AUD_TASK_P2L": {
+ "format": "[SPH_L]L1AUD_TASK_L receive a P2L event",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_L1AUD_TASK_P2L_DATA": {
+ "format": "[SPH_L]L1AUD_TASK_L receive a P2L data[%d] = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_L1AUD_TASK_L2P_DATA": {
+ "format": "[SPH_L]L1AUD_TASK_L receive a L2P data[%d] = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_L1AUD_TASK_L2P": {
+ "format": "[SPH_L]L1AUD_TASK_L set a L2P event",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_L1A_UPDATE_INFO_L": {
+ "apiType": "index",
+ "format": "[SPH_L] SP3G Update Info bitmap %d, val %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_EVSCALLOPEN_ENTER": {
+ "format": "cc_4G_EVS_Codec_Call_Open_temp_L Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_EVSCALLOPEN_LEAVE": {
+ "format": "cc_4G_EVS_Codec_Call_Open_temp_L Leave delR=%d delW=%d P_to_L1_delay=%dms resettype=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_EVSCALLCLOSE_ENTER": {
+ "format": "cc_4G_EVS_Codec_Call_Close_temp_L Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AM_L_CC_4G_EVSCALLCLOSE_LEAVE": {
+ "format": "cc_4G_EVS_Codec_Call_Close_temp_L Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_PLAY": {
+ "format": "[DTMF]DTMF_MCU_Play, DTMF_SW.pHandle: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_STOP": {
+ "format": "[DTMF]DTMF_MCU_Stop, DTMF_SW.pHandle: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_STOP_AND_WAIT": {
+ "format": "[DTMF]DTMF_MCU_StopAndWait, DTMF_SW.pHandle: 0x%X, I: %d, IsAudioPlaying: %d, SoundRuning: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_DATA_REQUEST": {
+ "format": "[DTMF]DTMF_MCU_DataRequestCallback, DTMF_SW.pHandle: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_GET_DATA_COUNT": {
+ "format": "[DTMF]DTMF_MCU_GetDataCount, uDataWord: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_READ_DATA_DONE": {
+ "format": "[DTMF]DTMF_MCU_ReadDataDone, uDataWord: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_GET_REAR_BUFFER": {
+ "format": "[DTMF]DTMF_MCU_GetReadBuffer, uDataWord: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_DESTROY": {
+ "format": "[DTMF]dtmf_mcu_Destroy, DTMF_SW.pHandle: 0x%X, fNewDTMF: %d, fEnding: %d, fForceStop: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_INIT": {
+ "format": "[DTMF]dtmf_mcu_Init, uSampleRate: %d, uPcmBufSize(byte): %d, uTotalBufferSize(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_PROCESS_ENTRY": {
+ "format": "[DTMF]dtmf_mcu_Process.entry, fNewDTMF: %d, fClearDTMF: %d, fEnding: %d, uBufLen(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_PROCESS_STATUS": {
+ "format": "[DTMF]dtmf_mcu_Process.status, fIsPlaying: %d, uCurrentData: %d, uFlushSilenceCount: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_NEWKEY": {
+ "format": "[DTMF]dtmf_mcu_ActivatNewKey, uCurIdx: %d, uCurrentDur: %d IsQTMF: %d, Freq: [%d] [%d] [%d] [%d]",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_NEWKEY_FORCE_END_2": {
+ "format": "[DTMF]dtmf_mcu_ActivatNewKey, Force stop: uPreIndex2: %d, uRemainDuration: %d, uTotalDuration:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_NEWKEY_FORCE_END_1": {
+ "format": "[DTMF]dtmf_mcu_ActivatNewKey, Reduce Dur: uPreIndex1: %d, uRemainDuration: %d, uTotalDuration:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_UPDATE_TONE_PREV_END": {
+ "format": "[DTMF]dtmf_mcu_UpdateTone, prev_end: uIndex: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_UPDATE_TONE_CURR_END": {
+ "format": "[DTMF]dtmf_mcu_UpdateTone, curr_end: uIndex: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_UPDATE_TONE_CURR_OFF": {
+ "format": "[DTMF]dtmf_mcu_UpdateTone, curr_off: uIndex: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_UPDATE_TONE_CURR_ON": {
+ "format": "[DTMF]dtmf_mcu_UpdateTone, curr_on : uIndex: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_UPDATE_TONE_RAMPDOWN": {
+ "format": "[DTMF]dtmf_mcu_UpdateTone, RAMPDOWN: uIndex: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_MCU_PROCESS_INTERNAL_ENTER": {
+ "format": "[dtmf_mcu_Process_Internal] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MCU_DTMF_MCU_PROCESS_INTERNAL_LEAVE": {
+ "format": "[dtmf_mcu_Process_Internal] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_AM_DSP_TurnOnC2KSDSP": {
+ "format": "[C2K][AM] C2K_AM_DSP_TurnOnC2KSDSP speech_modec=%X codec=%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_AM_DSP_TurnOffC2KSDSP": {
+ "format": "[C2K][AM] C2K_AM_DSP_TurnOffC2KSDSP",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_SO_CONNECT": {
+ "format": "[C2K][SPH] SO_Connect codec=%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_SO_CONNECT2": {
+ "format": "[C2K][SPH] SO_Connect(%d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_SO_DISCON": {
+ "format": "[C2K][SPH] SO_Disconnect(%d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_SO_DISCON_DONE": {
+ "format": "[C2K][SPH] SO_Disconnect_Done(%d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_INTRARAT": {
+ "format": "[C2K][SPH] SO_INTRARAT(%d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_SKIP_SO_CON_DONE": {
+ "format": "[C2K][SPH] Skip SO_Connect_Done(%d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_RS_COD_PARSE": {
+ "format": "[C2K][SPH] RS=%d, Cod=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_CON_SSO_REQ": {
+ "format": "[C2K][SPH] Link connect SSO req, SO=%d, MaxRate=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_CON_SSO_REQ_REPEAT": {
+ "format": "[C2K][SPH] Link SSO req repeat",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_CON_SSO_DONE": {
+ "format": "[C2K][SPH] Link connect SSO done",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_DISCON_SSO_REQ": {
+ "format": "[C2K][SPH] Link disconnect SSO req",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_DISCON_SSO_REQ_REPEAT": {
+ "format": "[C2K][SPH] Link disconnect SSO req repeat",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_DISCON_SSO_DONE": {
+ "format": "[C2K][SPH] Link disconnect SSO done",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_RDY": {
+ "format": "[C2K][SPH] Link cod ready, CodRdy=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_CLOSE": {
+ "format": "[C2K][SPH] Link cod close, CodRdy=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_DL_UNRDY": {
+ "format": "[C2K][SPH] Link cod DL unready",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_UL_UNRDY": {
+ "format": "[C2K][SPH] Link cod UL unready",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_UL_UNSYNC": {
+ "format": "[C2K][SPH] Link UL unsync",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_LBK_DL": {
+ "format": "[C2K][SPH] Link lbk DL, Rate=%d, len=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_LBK_UL": {
+ "format": "[C2K][SPH] Link lbk UL, Rate=%d, len=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_DL": {
+ "format": "[C2K][SPH] Cod_DL %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_COD_UL": {
+ "format": "[C2K][SPH] Cod_UL %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_RATE_DL": {
+ "format": "[C2K][SPH] rate_DL %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_RATE_UL": {
+ "format": "[C2K][SPH] rate_UL %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_HB_DL": {
+ "format": "[C2K][SPH] HB_DL %x %x %x %x %x %x %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "C2K_SPH_LINK_HB_UL": {
+ "format": "[C2K][SPH] HB_UL %x %x %x %x %x %x %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AFE_SWITCH_LOOPBACK": {
+ "apiType": "index",
+ "format": "AFE Switch Loopback %c",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "AFE_DIGI_GAIN": {
+ "format": "DP_VOL_OUT_PCM:%X, DP_EnhRefDigiGain_Setting:%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AFE_SET_MIC_VOLUME": {
+ "apiType": "index",
+ "format": "AFE SetMicrophoneVolume: %d",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "AFE_SET_OUTPUT_VOLUME": {
+ "format": "AFE Set aud_func %X OutputVolume %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AFE_SET_LEVEL_VOLUME": {
+ "format": "AFE Set aud_func %X MaxAnalogGain %d , step %d, level %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AFE_SET_GIDI_GAIN": {
+ "apiType": "index",
+ "format": "AFE Set digital gain level %d, isForce=%d",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "AFE_SET_SPH_REF_GIDI_GAIN": {
+ "apiType": "index",
+ "format": "AFE Set speech enhancement reference digital gain %d",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1CTM_OPEN": {
+ "format": "Call L1Ctm_Open",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_CLOSE": {
+ "format": "Call L1Ctm_Close",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_SET_INTERFACE": {
+ "format": "Call L1Ctm_SetInterface",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_START_NEGOTIATION": {
+ "format": "Call L1Ctm_StartNegotiation",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_4G_PUT_UL": {
+ "format": "[4G TTY] put to UL Buffer %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_4G_GET_DL": {
+ "format": "[4G TTY] get from DL Buffer %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_UL_GET": {
+ "format": "[TTY_LTE_PSR_UL_Get] ch = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_DL_GET": {
+ "format": "[TTY_LTE_PSR_DL_Get] ch = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_UL_PUT": {
+ "format": "[TTY_LTE_PSR_UL_Put] ch = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_DL_PUT": {
+ "format": "[TTY_LTE_PSR_DL_Put] ch = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_UL_QUEUE_SIZE": {
+ "format": "[TTY_LTE_PSR_UL_Queue_Size] size = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_LTE_DL_QUEUE_SIZE": {
+ "format": "[TTY_LTE_PSR_DL_Queue_Size] size = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TTY_MODE": {
+ "format": "[CTM] TTY mode = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_TX_PUT_TEXT": {
+ "format": "Call L1Ctm_TxPutText",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_RX_GET_TEXT": {
+ "format": "Call L1Ctm_RxGetText",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_IN_HISR_ENTER": {
+ "apiType": "index",
+ "format": "[l1ctm_in_hisr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_IN_HISR_LEAVE": {
+ "apiType": "index",
+ "format": "[l1ctm_in_hisr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_STOP_ENTER": {
+ "apiType": "index",
+ "format": "[L1Ctm_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_STOP_LEAVE": {
+ "apiType": "index",
+ "format": "[L1Ctm_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_FAR_END_CTM_DETECTED": {
+ "format": "L1Ctm far-end CTM detected",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_NEGOTIATION_SUCCESS": {
+ "format": "L1Ctm negotiation success",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_NEGOTIATION_FAIL": {
+ "format": "L1Ctm negotiation fail",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEMAND_CTM_ACK": {
+ "format": "L1Ctm is demanded to send CTM ACK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_UL_SEND_IDLE_AS_ACK": {
+ "format": "L1CtmTx ul-path send IDLE as ACK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DL_DETECT_CTM_SYNC": {
+ "format": "L1Ctm dl-path detect CTM Sync",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DL_CTM_BURST_END": {
+ "format": "L1Ctm dl-path detect CTM burst-end",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_UL_SEND_ENQUIRY_CHAR": {
+ "format": "L1Ctm ul-path send %d-time ENQUIRY char",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_UL_GET_DECODED_TTY_CHAR": {
+ "format": "L1Ctm ul-path get decoded TTY-char 0x%02X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_UL_SEND_CTM_CHAR": {
+ "format": "L1Ctm ul-path send CTM-char 0x%02X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DL_GET_RECEIVED_CTM_CHAR": {
+ "format": "L1Ctm dl-path get received CTM-char 0x%02X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DL_SEND_TTY_CHAR": {
+ "format": "L1Ctm dl-path send TTY-char 0x%02X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_REC_DIR_NO": {
+ "format": "L1Ctm record to dir REC_%02u",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_SAVE_DECODED_CHAR": {
+ "format": "L1Ctm dl-path save decoded char 0x%02X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING1": {
+ "format": "[CTM Setting 6229] AEC, EES, ES (Address 0x1A0~0x1A2): %d,%d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING2": {
+ "format": "[CTM Setting 6229] AMR codebook threshold=%d, gain=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING3": {
+ "format": "[CTM Setting 6229] DSP_AFS/AHS_SP_BFI_THRESHOLD 0: %d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING4": {
+ "format": "[CTM Setting 6229] DSP_AFS/AHS_SP_BFI_THRESHOLD 1: %d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING5": {
+ "format": "[CTM Setting 6229] DSP_AFS/AHS_SP_BFI_THRESHOLD 2: %d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING6": {
+ "format": "[CTM Setting 6229] DSP_AFS/AHS_SP_BFI_THRESHOLD 3: %d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING7": {
+ "format": "[CTM Setting]: Audio Coefficient for input : %d, %d, %d, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_DEBUG_SHOW_SETTING8": {
+ "format": "[CTM Setting]: Audio Coefficient for output: %d, %d, %d, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_FAKE_COSIM": {
+ "format": "Turning on COSIM bit in DP_CTM_COSIM_CTRL",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_BUF_OVFLOW": {
+ "apiType": "index",
+ "format": "l1ctm buffer overflow",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1CTM_COSIM": {
+ "format": "Turning on COSIM bit in DP_CTM_COSIM_CTRL",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_BFI_INFO": {
+ "format": "l1ctm_in_hisr in cosim mode(buf_idx=%x, bfi_store_idx=%x, dsp_tch_bfi=%x, bfi flag=%x)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_HCO_MODE": {
+ "format": "Opening ctm in HCO mode.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_VCO_MODE": {
+ "format": "Opening ctm in VCO mode.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_COSIM_MODE": {
+ "format": "Opening CTM in cosim mode",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_NORMAL_MODE": {
+ "format": "Opening ctm in normal mode (no HCO/VCO).",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1CTM_OPEN_PARAM": {
+ "apiType": "index",
+ "format": "ctm param is not null, cprm_debug_flag=%x",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_BGSND_WRITEDATADONE_ENTER": {
+ "apiType": "index",
+ "format": "[spc_bgSnd_writeDataDone] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_WRITEDATADONE_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_bgSnd_writeDataDone] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_REQUESTDATA_ENTER": {
+ "apiType": "index",
+ "format": "[spc_bgSnd_requestData] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_REQUESTDATA_INFO": {
+ "apiType": "index",
+ "format": "[spc_bgSnd_requestData] bLen=%d BGSND_RB_DEFAULT_THRESHOLD=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_REQUESTDATA_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_bgSnd_requestData] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_DLHDR_ENTER": {
+ "apiType": "index",
+ "format": "[spc_BGSND_DLHdr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSND_DLHDR_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_BGSND_DLHdr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDSTART_ENTER": {
+ "apiType": "index",
+ "format": "[spc_BgSndStart] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDSTART_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_BgSndStart] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDSTOP_ENTER": {
+ "apiType": "index",
+ "format": "[spc_BgSndStop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDSTOP_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_BgSndStop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDCONFIG_ENTER": {
+ "apiType": "index",
+ "format": "[spc_BgSndConfig] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_BGSNDCONFIG_LEAVE": {
+ "apiType": "index",
+ "format": "[spc_BgSndConfig] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_INIT_ENTER": {
+ "format": "[DSP_BGSND_INIT] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_INIT_LEAVE": {
+ "format": "[DSP_BGSND_INIT] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_CONFIGMIXER_ENTER": {
+ "format": "[DSP_BGSND_ConfigMixer] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_CONFIGMIXER_BGSND_PROCESS_TYPE": {
+ "format": "[DSP_BGSND_ConfigMixer] BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d flag:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_CONFIGMIXER_LEAVE": {
+ "format": "[DSP_BGSND_ConfigMixer] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_UPDATEMIXER_ENTER": {
+ "format": "[DSP_BGSND_UpdateMixer] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_UPDATEMIXER_LEAVE": {
+ "format": "[DSP_BGSND_UpdateMixer] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_STOP_ENTER": {
+ "apiType": "index",
+ "format": "[DSP_BGSND_Stop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_STOP_LEAVE": {
+ "apiType": "index",
+ "format": "[DSP_BGSND_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_SHARED_HISR_DL_UL_ENTER": {
+ "format": "[DSP_BGSND_Shared_Hisr_DL_UL] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_SHARED_HISR_DL_UL_LEAVE": {
+ "format": "[DSP_BGSND_Shared_Hisr_DL_UL] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_HISR_ENTER": {
+ "format": "[DSP_BGSND_Hisr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_HISR_BGSND_PROCESS_TYPE": {
+ "format": "[DSP_BGSND_Hisr] BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_HISR": {
+ "format": "[DSP_BGSND_Hisr] %x %x %x %x %x %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_HISR_LEAVE": {
+ "format": "[DSP_BGSND_Hisr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_START_ENTER": {
+ "apiType": "index",
+ "format": "[DSP_BGSND_Start] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSP_BGSND_START_LEAVE": {
+ "apiType": "index",
+ "format": "[DSP_BGSND_Start] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_INIT_ENTER": {
+ "format": "[EXT_BGSND_init] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_INIT_LEAVE": {
+ "format": "[EXT_BGSND_init] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_ENTER": {
+ "format": "[EXT_BGSND_Start] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_DEBUG1": {
+ "format": "[EXT_BGSND_Start] debug1 i=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_DEBUG2": {
+ "format": "[EXT_BGSND_Start] debug2 i=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_SELECTED_SRC": {
+ "format": "[EXT_BGSND_Start] selected_src_id=%d num_src_used=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_DEBUG3": {
+ "format": "[EXT_BGSND_Start] debug3 i=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_DEBUG4": {
+ "format": "[EXT_BGSND_Start] debug4 i=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_DEBUG5": {
+ "format": "[EXT_BGSND_Start] debug5 i=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_START_LEAVE": {
+ "apiType": "index",
+ "format": "[EXT_BGSND_Start] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_FLUSH_ENTER": {
+ "format": "[EXT_BGSND_Flush] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_FLUSH_ID": {
+ "format": "[EXT_BGSND_Flush] id=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_FLUSH_STATE": {
+ "format": "[EXT_BGSND_Flush] state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_FLUSH_LEAVE": {
+ "format": "[EXT_BGSND_Flush] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CLOSE_ENTER": {
+ "format": "[EXT_BGSND_Close] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CLOSE_SELECTED_SRC": {
+ "format": "[EXT_BGSND_Close] selected_src_id=%d num_src_used=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CLOSE_LEAVE": {
+ "format": "[EXT_BGSND_Close] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_DLHISR_ENTER": {
+ "format": "[EXT_BGSND_DLHisr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_DLHISR_LEAVE": {
+ "format": "[EXT_BGSND_DLHisr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_ULHISR_ENTER": {
+ "format": "[EXT_BGSND_ULHisr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_ULHISR_LEAVE": {
+ "format": "[EXT_BGSND_ULHisr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETDATACOUNT_ENTER": {
+ "format": "[EXT_BGSND_GetDataCount] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETDATACOUNT_COUNT": {
+ "format": "[EXT_BGSND_GetDataCount] count=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETDATACOUNT_LEAVE": {
+ "format": "[EXT_BGSND_GetDataCount] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_ENTER": {
+ "format": "[EXT_BGSND_Hisr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_BGSND_PROCESS_TYPE": {
+ "format": "[EXT_BGSND_Hisr] BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_SELECTED_SRC": {
+ "format": "[EXT_BGSND_Hisr] selected_src_id=%d src_state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_EXT_SRC_STATE_FLUSHING_OVER": {
+ "format": " [EXT_BGSND_Hisr] %d-th Src's BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d EXT_SRC_STATE_FLUSHING_OVER",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_ENTER_SRC_OFFHDR": {
+ "format": " [EXT_BGSND_Hisr] Enter %d-th Src's OffHdr",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_LEAVE_SRC_OFFHDR": {
+ "format": " [EXT_BGSND_Hisr] Leave %d-th Src's OffHdr",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_FLUSH_SRC_OFFHDR_COMPLETELY": {
+ "format": " [EXT_BGSND_Hisr] Flush %d-th Src's OffHdr completely",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_WAIT_SRC_HDR_TO_FLUSH_COMPLETELY": {
+ "format": " [EXT_BGSND_Hisr] Wait %d-th Src's Hdr to flush completely",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_FLUSHING": {
+ "format": " [EXT_BGSND_Hisr] %d-th Src's BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d is flushing with len=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_NOT_FLUSHING": {
+ "format": " [EXT_BGSND_Hisr] %d-th Src's BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d is not flushing with state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_HDR_IS_NOT_USED": {
+ "format": "[EXT_BGSND_Hisr] %d-th Src's Hdr is not used",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_HISR_LEAVE": {
+ "format": "[EXT_BGSND_Hisr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "BGSND_DSP_BGSND_BUF_ADD": {
+ "format": "[BGSND] DSP_BGSND_Buf_Add id=%d src_len=%d type=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "BKGSND_DSP_BUF_ADD_BUF": {
+ "format": "[BKGSND]DSP_buf_add buf[%d]=%x DSP_DLBuffer[%d]=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITESRCBUFFER_ENTER": {
+ "format": "[EXT_BGSND_WriteSrcBuffer] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITESRCBUFFER_LEAVE": {
+ "format": "[EXT_BGSND_WriteSrcBuffer] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_ENTER": {
+ "format": "[EXT_BGSND_WriteExtBuffer] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_SELECTED_SRC": {
+ "format": "[EXT_BGSND_WriteExtBuffer] selected_src_id = %d BGSND_PROCESS_TYPE(0->DL, 1->UL)=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_FSPH": {
+ "format": "[EXT_BGSND_WriteExtBuffer] fSph=%d gain=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_COUNT": {
+ "format": "[EXT_BGSND_WriteExtBuffer] count=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_OVERFLOWS1": {
+ "format": "[EXT_BGSND_WriteExtBuffer] overflows1",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_FILLED_TO_DSP": {
+ "format": "[EXT_BGSND_WriteExtBuffer_%d] Filled %d word to DSP, bgSnd.bufRead=%d, bgSnd.bufWrite=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_OVERFLOWS2": {
+ "format": "[EXT_BGSND_WriteExtBuffer] overflows2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_FILLED_TO_DSP_WITH_LAST_SAMPLE": {
+ "format": "[EXT_BGSND_WriteExtBuffer] Filled %d word to DSP with last sample %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_OVERFLOWS3": {
+ "format": "[EXT_BGSND_WriteExtBuffer] overflows3",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_SKIP_TO_DSP": {
+ "format": "[EXT_BGSND_WriteExtBuffer] skip fill %d word to DSP with silence pattern, state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER": {
+ "format": "[EXT_BGSND_WriteExtBuffer] %x %x %x %x %x %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_WRITEEXTBUFFER_LEAVE": {
+ "format": "[EXT_BGSND_WriteExtBuffer] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETFREESPACE_ENTER": {
+ "format": "[EXT_BGSND_GetFreeSpace] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETFREESPACE_INFO": {
+ "format": "[EXT_BGSND_GetFreeSpace] ## r = %d w = %d size = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_GETFREESPACE_LEAVE": {
+ "format": "[EXT_BGSND_GetFreeSpace] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CONFIGMIXER_ENTER": {
+ "format": "[EXT_BGSND_ConfigMixer] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CONFIGMIXER_BSPHFLAG": {
+ "format": "[EXT_BGSND_ConfigMixer] bSPHFlag=%d SNDGain=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "EXT_BGSND_CONFIGMIXER_LEAVE": {
+ "format": "[EXT_BGSND_ConfigMixer] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_KT_PLAY_ENTER": {
+ "format": "[SP4G_PSR_DL_KT_Play] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_KT_PLAY_LEAVE": {
+ "format": "[SP4G_PSR_DL_KT_Play] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_KT_STOP_ENTER": {
+ "format": "[SP4G_PSR_DL_KT_Stop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_KT_STOP_LEAVE": {
+ "format": "[SP4G_PSR_DL_KT_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_TONE_PLAY_ENTER": {
+ "format": "[SP4G_PSR_DL_Tone_Play] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_TONE_PLAY_LEAVE": {
+ "format": "[SP4G_PSR_DL_Tone_Play] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_TONE_STOP_ENTER": {
+ "format": "[SP4G_PSR_DL_Tone_Stop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_DL_TONE_STOP_LEAVE": {
+ "format": "[SP4G_PSR_DL_Tone_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_PLAY_ENTER": {
+ "format": "[SP4G_PSR_UL_KT_Play] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_PLAY_LEAVE": {
+ "format": "[SP4G_PSR_UL_KT_Play] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_PLAY_SKIP": {
+ "format": "[SP4G_PSR_UL_KT_Play] Skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_STOP_ENTER": {
+ "format": "[SP4G_PSR_UL_KT_Stop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_STOP_LEAVE": {
+ "format": "[SP4G_PSR_UL_KT_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_KT_STOP_SKIP": {
+ "format": "[SP4G_PSR_UL_KT_Stop] Skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_PLAY_ENTER": {
+ "format": "[SP4G_PSR_UL_Tone_Play] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_PLAY_LEAVE": {
+ "format": "[SP4G_PSR_UL_Tone_Play] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_PLAY_SKIP": {
+ "format": "[SP4G_PSR_UL_Tone_Play] Skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_STOP_ENTER": {
+ "format": "[SP4G_PSR_UL_Tone_Stop] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_STOP_LEAVE": {
+ "format": "[SP4G_PSR_UL_Tone_Stop] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP4G_PSR_UL_TONE_STOP_SKIP": {
+ "format": "[SP4G_PSR_UL_Tone_Stop] Skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSNDCLOSE_ENTER": {
+ "format": "[volte_BgSndClose] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSNDCLOSE_LEAVE": {
+ "format": "[volte_BgSndClose] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_CLOSEHANDLER_ENTER": {
+ "format": "[volte_bgSnd_closeHandler] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_CLOSEHANDLER_LEAVE": {
+ "format": "[volte_bgSnd_closeHandler] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_ENTER": {
+ "format": "[volte_BGSND_ULHdr] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_EXT_BGSND_WRITEEXTBUFFER": {
+ "format": "[volte_BGSND_ULHdr] EXT_BGSND_WriteExtBuffer",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_EXT_BGSND_WRITEEXTBUFFER_LAST_DATA": {
+ "format": "[volte_BGSND_ULHdr] EXT_BGSND_WriteExtBuffer last data",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_LEAVE": {
+ "format": "[volte_BGSND_ULHdr] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_NEED_SAMPLES": {
+ "format": "[volte_BGSND_ULHdr] we still need %d samples",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_NO_EXT_BGSND_WRITEEXTBUFFER": {
+ "format": "[volte_BGSND_ULHdr] No EXT_BGSND_WriteExtBuffer",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VOLTE_BGSND_ULHDR_TONECNT_REMAINS": {
+ "format": "[volte_BGSND_ULHdr] ToneCnt %d Remains %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_PLAY_SKIP": {
+ "format": "[SP_DSPTone] SP_DSPTone_UL_KT_Play skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_PLAY_START": {
+ "format": "[SP_DSPTone] SP_DSPTone_UL_KT_Play start freq1=%d freq2=%d duration=%d ulgain=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_PLAY_LEAVE": {
+ "format": "[SP_DSPTone] SP_DSPTONE_UL_KT_Play leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_STOP_SKIP": {
+ "format": "[SP_DSPTone] SP_DSPTone_UL_KT_Stop skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_STOP_START": {
+ "format": "[SP_DSPTone] SP_DSPTone_UL_KT_Stop start",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_UL_KT_STOP_LEAVE": {
+ "format": "[SP_DSPTone] SP_DSPTone_UL_KT_Stop leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_PLAY_SKIP": {
+ "format": "[SP_DSPTone] SP_DSPTone_DL_KT_Play skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_PLAY_START": {
+ "format": "[SP_DSPTone] SP_DSPTone_DL_KT_Play start freq1=%d freq2=%d duration=%d dlgain=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_PLAY_LEAVE": {
+ "format": "[SP_DSPTone] SP_DSPTONE_DL_KT_Play leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_STOP_SKIP": {
+ "format": "[SP_DSPTone] SP_DSPTone_DL_KT_Stop skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_STOP_START": {
+ "format": "[SP_DSPTone] SP_DSPTone_DL_KT_Stop start",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DSPTONE_DL_KT_STOP_LEAVE": {
+ "format": "[SP_DSPTone] SP_DSPTone_DL_KT_Stop leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SAL_4G_GSeriesCall_Open_CheckState_UL_DL": {
+ "format": "[SAL_4G_GSeriesCall_Open] I=%d SAL_PcmEx_CheckStateDL=%d SAL_PcmEx_CheckStateUL=%d is_ready=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SAL_4G_GSeriesCall_Open_CheckState": {
+ "format": "[SAL_4G_GSeriesCall_Open] SAL_PcmEx_CheckState OK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_DSP2MCU": {
+ "format": "DSP2MCU",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_DSP2MCU_TASK4": {
+ "format": "DSP2MCU Task4",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_DSP2MCU_TASK5": {
+ "format": "DSP2MCU Task5",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_DSP2MCU_TASK6": {
+ "format": "DSP2MCU Task6",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_DSP2MCU_TASK7_DSP_DIE": {
+ "format": "DSP2MCU Task7 DSP Die ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_L1AUDIO_CONSOLE_HANDLER_VIO18_ON": {
+ "format": "l1audio_console_handler VIO18 ON",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "AUDIO_SERVICE_L1AUDIO_CONSOLE_HANDLER_VIO18_OFF": {
+ "format": "l1audio_console_handler VIO18 OFF",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BTSCO_HISR_ADDRESS": {
+ "format": "[CVSD]btsco_hisr address: W:%x, R:%x, status:%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BTSCO_CODEC_ID": {
+ "format": "[CVSD]fWideBand: %x, uCodec_id:%x, BT_SCO_HW_REG_CONTROL:%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "BTSCO_CVSD_MSBC_SWITCH": {
+ "format": "[SCO]msbc cvsd switch",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_ALLOC_CVSD_MEMORY": {
+ "format": "[CVSD]BT_SCO_Alloc_CVSD_Memory: uTotalMemory %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_G711PLC_ADDTOHISTORY_COPY": {
+ "format": "[CVSD]\u0014g711plc_addtohistory copy: btsco.pRX->iPacket_r %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_G711PLC_DOFE_COPY": {
+ "format": "[CVSD]\u0014g711plc_dofe copy: btsco.pRX->iPacket_r %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_ALLOC_MSBC_MEMORY": {
+ "format": "[CVSD]BT_SCO_Alloc_MSBC_Memory: uTotalMemory %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MSBC_INFO": {
+ "format": "[MSBC][%d][%d], index1: %d, valid: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MSBC_STATUS": {
+ "format": "[MSBC]status: %d,",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BTSCO_PROCESS_LOOPBACK": {
+ "format": "[CVSD]btsco_process_loopback, uInLen: %d, uOutLen: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_SPEECH_ON": {
+ "format": "[CVSD]BT_SCO_SPEECH_ON, uState: %d, fWideBand = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_SPEECH_OFF": {
+ "format": "[CVSD]BT_SCO_SPEECH_OFF, uState: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_LOOPBACK_ON": {
+ "format": "[CVSD]BT_SCO_Loopback_ON, fDisableCodec: %d, uState: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "CVSD_BT_SCO_LOOPBACK_OFF": {
+ "format": "[CVSD]BT_SCO_Loopback_OFF, uState: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "P4W_GETDATAFROMDSP": {
+ "format": "pcmEx_getDataFromDsp bufName=%d, addr=%x, length=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "P4W_WRITEDATATODSP": {
+ "format": "pcmEx_writeDataToDsp bufName=%d, addr=%x, length=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_DSP_BUFFER_INFO": {
+ "apiType": "index",
+ "format": "BGSND buf count:%d; dsp_buf_addr(toPtr): %x, dsp_buf_len: %d word",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_FILLBUFFER": {
+ "apiType": "index",
+ "format": "BGSND[%d] Filled %d word to DSP, bgSnd.bufRead=%d, bgSnd.bufWrite=%d",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1SND_PUT_SILENCE": {
+ "apiType": "index",
+ "format": "BGSND Filled %d word to DSP with silence pattern %x",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1SND_WRITE_DATA": {
+ "format": "[EXT_BGSND_WriteSrcBuffer_%d] selected_src_id=%d type=%d Write data %d word to buffer %d, bgSnd.bufRead=%d, bgSnd.bufWrite=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_STOP_FLUSH_COUNT": {
+ "apiType": "index",
+ "format": "BGSND Flush count: %d word",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1SND_STOP_FLUSH_LEAVE": {
+ "apiType": "index",
+ "format": "BGSND Flush Still Leave: %d word",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1SND_ENTER_BGSND_START": {
+ "format": "Enter BGSND_Start",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_ENTER_BGSND_STOP": {
+ "format": "Enter BGSND_Stop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_ENTER_EVENT_HANDLER": {
+ "apiType": "index",
+ "format": "Enter bgsndEventHandler with state=%d",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "L1SND_CONFIG_ULMIXER": {
+ "format": "BGSND ConfigULMixer, flag:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_CONFIG_DLMIXER": {
+ "format": "BGSND ConfigDLMixer, flag:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SND_REENTER_HISR": {
+ "format": "SND re-enter HISR with isDlHisrCome=%d, isUlHisrCome=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPPS_PSR_EVS_LOOPBACK_UL_1": {
+ "apiType": "index",
+ "format": "PS EVS_loopback_ul",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_EVS_LOOPBACK_UL_2": {
+ "apiType": "index",
+ "format": "PS EVS_loopback_ul %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_EVS_LOOPBACK_DL_1": {
+ "apiType": "index",
+ "format": "PS EVS_loopback_dl",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_EVS_LOOPBACK_DL_2": {
+ "apiType": "index",
+ "format": "PS EVS_loopback_dl %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_G711_LOOPBACK": {
+ "apiType": "index",
+ "format": "SP4G_PSR_loopback_G711 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_DL_GSERIES_PUTSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PS PSR_DL_GSeries_Put",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_DL_GSERIES_PUTSPEECHFRAME_INFO": {
+ "apiType": "index",
+ "format": "PS PSR_DL_GSeries_Put: codec=%MSP4G_Codec(0x%x), encodebits=%02x%02x%02x%02x, bitlen=%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_DL_HISR_SKIP": {
+ "apiType": "index",
+ "format": "PS DL_HISR SKIP %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_UL_HISR_SKIP": {
+ "apiType": "index",
+ "format": "PS UL_HISR SKIP %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_IS_EQUAL": {
+ "apiType": "index",
+ "format": "PS SetCodec is equal %MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PP5_1": {
+ "apiType": "index",
+ "format": "PS PP5.1 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PP5_SP4G_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PS PP5 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PP6_SP4G_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PS PP6 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_UL_EVS_GETSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PS EVS PSR_UL_Get",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_UL_SETFRAMETYPE1": {
+ "apiType": "index",
+ "format": "PS PSR_UL_SetFrameType with codec=%x, L1SP_GetState()=%d, is_g_codec=%x, is_EVS=%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC": {
+ "apiType": "index",
+ "format": "PS SetCodec: in_codec_mode=%MSP4G_Codec(0x%x), real_codec_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC0": {
+ "apiType": "index",
+ "format": "PS SetCodec: in_codec_mode=%MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_USE_EVS_IO_REPLACE_AWB_IN": {
+ "apiType": "index",
+ "format": "PS SetCodec: USE_EVS_IO_REPLACE_AWB in_codec_mode=0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_USE_EVS_IO_REPLACE_AWB_OUT": {
+ "apiType": "index",
+ "format": "PS SetCodec: USE_EVS_IO_REPLACE_AWB out_codec_mode=0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_SETFRAMETYPE1": {
+ "apiType": "index",
+ "format": "PS SetCodec1: %MSP4G_Codec(0x%x) 0x%x ftype=%MSP4G_Codec(0x%x), ul_intrarat=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_SETFRAMETYPE2": {
+ "apiType": "index",
+ "format": "PS SetCodec2: %d %d ftype=%MSP4G_Codec(0x%x), ul_intrarat=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SETCODEC_SETFRAMETYPE3": {
+ "apiType": "index",
+ "format": "PS SetCodec2: %d %d ftype=%MSP4G_Codec(0x%x), ul_intrarat=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_DEBUG_SPPS_SPEECH_INIT": {
+ "apiType": "index",
+ "format": "PS speech_init_codec = 0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_UL_GETSPEECHFRAME_USE_EVS_IO_REPLACE_AWB": {
+ "apiType": "index",
+ "format": "PS UL_Get USE_EVS_IO_REPLACE_AWB",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_UL_GETSPEECHFRAME_USE_EVS_IO_REPLACE_AWB_LEN": {
+ "apiType": "index",
+ "format": "PS UL_Get USE_EVS_IO_REPLACE_AWB bit_len=%d, byte_len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_DL_PUTSPEECHFRAME_USE_EVS_IO_REPLACE_AWB": {
+ "apiType": "index",
+ "format": "PS DL_Put USE_EVS_IO_REPLACE_AWB",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_UL_GSERIES_GETSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PS PSR_UL_GSeries_Get",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_UL_GSERIES_GETSPEECHFRAME_INFO": {
+ "apiType": "index",
+ "format": "PS PSR_UL_GSeries_Get: codec=%MSP4G_Codec(0x%x), encodebits=%02x%02x%02x%02x, bitlen=%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_LINK_DEEST": {
+ "apiType": "index",
+ "format": "PS PSR_Link_Deest: spPS_rab_id=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_PSR_LINK_EST": {
+ "apiType": "index",
+ "format": "PS PSR_Link_Est: spPS_rab_id=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_RAB_DEEST": {
+ "apiType": "index",
+ "format": "PS notify RAB De-establish id=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_RAB_EST1": {
+ "apiType": "index",
+ "format": "PS Rab_Est: in_codec_mode=%MSP4G_Codec(0x%x), real_codec_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_RAB_EST2": {
+ "apiType": "index",
+ "format": "PP Rab_Est: CSR notify RAB establish id=%x codec=%MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_RAB_EST_USE_EVS_IO_REPLACE_AWB_IN": {
+ "apiType": "index",
+ "format": "PS Rab_Est: USE_EVS_IO_REPLACE_AWB in_codec_mode=%MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_RAB_EST_USE_EVS_IO_REPLACE_AWB_OUT": {
+ "apiType": "index",
+ "format": "PS Rab_Est: USE_EVS_IO_REPLACE_AWB out_codec_mode=%MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_REQUEST_UL_FRAME_TYPE": {
+ "apiType": "index",
+ "format": "PS set UL frame type %MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SPPS_SET_DTX": {
+ "apiType": "index",
+ "format": "PS Set DTX %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_TX_SPEECH_GOOD": {
+ "apiType": "index",
+ "format": "PSCod hisr_ul SPEECH_GOOD",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_TX_SID_FIRST": {
+ "apiType": "index",
+ "format": "PSCod hisr_ul SID_FISRT",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_TX_SID_UPDATE": {
+ "apiType": "index",
+ "format": "PSCod hisr_ul SID_UPDATE",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_TX_NO_DATA": {
+ "apiType": "index",
+ "format": "PSCod hisr_ul NO_DATA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_UL_SKIP_NOTIFY": {
+ "apiType": "index",
+ "format": "PSCod UL_SKIP_NOTIFY_PSR",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_UL_DELAY": {
+ "apiType": "index",
+ "format": "PSCod UL delay %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_DL_SKIP_NOTIFY": {
+ "apiType": "index",
+ "format": "PSCod DL_SKIP_NOTIFY_PSR",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_DL_DELAY": {
+ "apiType": "index",
+ "format": "PSCod DL delay %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_UL_SYNC_AM_4G_INTRARAT": {
+ "apiType": "index",
+ "format": "PSCod UL_Sync AM_INTRARAT",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_DL_FRM": {
+ "apiType": "index",
+ "format": "PSCod DL Frm NA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_DL_PUT_SPEECH_FRAME_EVS": {
+ "apiType": "index",
+ "format": "PSCod DL sub_flow %d, frame_type %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_DL_PUT_SPEECH_FRAME_AMR": {
+ "apiType": "index",
+ "format": "PSCod DL sub_flow %d, frame_type %x, crc_status %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_RX_SID_FIRST": {
+ "apiType": "index",
+ "format": "PSCod RX SID FISRT",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_RX_SID_UPDATE": {
+ "apiType": "index",
+ "format": "PSCod RX SID UPDATE",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_RX_NO_DATA": {
+ "apiType": "index",
+ "format": "PSCod RX GET NO DATA FRAME",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_RX_LOST_DATA": {
+ "apiType": "index",
+ "format": "PSCod RX GET LOST DATA FRAME",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_UL_GET_SPEECH_FRAME": {
+ "apiType": "index",
+ "format": "PSCod UL GetSpFrame type %x, len %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_BUFFER": {
+ "apiType": "index",
+ "format": "PSCodAMR UL cnt=%d,r=%d,w=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_CONVERT_SP4G_CODEC_AMR_AMRWB_TO_SPH_CODEC": {
+ "apiType": "index",
+ "format": "PSCodAMR convert_AMR_AMRWB_to_SPH_CODEC frame_type=%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_GETSPEECHFRAMESUB_1": {
+ "apiType": "index",
+ "format": "PSCodAMR UL_Get1 reset_flag=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_GETSPEECHFRAMESUB_2": {
+ "apiType": "index",
+ "format": "PSCodAMR UL_Get2 reset_flag=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_HISR_SKIP_AMR": {
+ "apiType": "index",
+ "format": "PSCodAMR UL_HISR SKIP AMR %d %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DL_HISR_SKIP_AMR": {
+ "apiType": "index",
+ "format": "PSCodAMR DL_HISR SKIP AMR %d %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HISR_UL_INVALID_CODEC_MODE": {
+ "apiType": "index",
+ "format": "PSCodAMR hisr_ul invalid UL codec mode %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HISR_UL_AMR_NO_UPDATE_UL_BUFFER_1": {
+ "apiType": "index",
+ "format": "PSCodAMR hisr_ul no update UL buffer 1",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HISR_UL_AMR_NO_UPDATE_UL_BUFFER_2": {
+ "apiType": "index",
+ "format": "PSCodAMR hisr_ul no update UL buffer 2",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HISR_UL_DSP_NOT_READY": {
+ "apiType": "index",
+ "format": "PSCodAMR hisr_ul no ready, force using silence pattern DSP_Len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DEBUG_UL_BUFF": {
+ "apiType": "index",
+ "format": "PSCodAMR hisr_ul_buff %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_SYNC_SP4G_HISR_DL_AMR_1_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR [UL_Sync]hisr_dl.1 ul_request_resync = %d reset_flag=%d ctime = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_UL_SYNC_SP4G_HISR_DL_AMR_FORCED_NO_DATA": {
+ "apiType": "index",
+ "format": "PSCodAMR [UL_Sync]hisr_dl.2 forced no_data",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_RETURN": {
+ "apiType": "index",
+ "format": "PSCodAMR PSR_DL_Put: now is EVS codec, skip this data flow.",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DL_BIT_TRUE": {
+ "apiType": "index",
+ "format": "PSCodAMR DL Type 0x%x, Frm %x %x %x %x %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HIST_4G_SYNC": {
+ "apiType": "index",
+ "format": "PSCodAMR sync=%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PSCodAMR PSR_DL_Put codec=%MSP4G_PSR_Codec(0x%x) frame_type=%MSP4G_Codec(0x%x) ul_codec_mode=0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_G_SKIP": {
+ "apiType": "index",
+ "format": "PSCodAMR PSR_DL_Put: now is G codec, skip this data flow.",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_LOST_FRAME": {
+ "apiType": "index",
+ "format": "PSCodAMR PSR_DL_Put LOST_FRAME",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_HSPA_DL_PUT_SPEECH_FRAME": {
+ "apiType": "index",
+ "format": "PSCodAMR DL Put type %MSP4G_Codec(0x%x), CFN %d, crc %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_P0_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR P0 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_P1_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR P1 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_P2_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR P2 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_P3_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR P3 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_P4_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodAMR P4 reset_flag=%d dl_count=%d %d %d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DL_DROP_FRAME": {
+ "apiType": "index",
+ "format": "PSCodAMR DL drop frame",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DTX_NO_DATA": {
+ "format": "PSCodAMR DL_HISR INSERT NO DATA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DL_HISR_STATUS": {
+ "format": "PSCodAMR DL_HISR AMR = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_BUFFER_STATUS": {
+ "format": "PSCodAMR DL_HISR r = %d, w = %d, num = %d, 1st byte = %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_RX_FORCE_NO_DATA_WHEN_CHANGE_BAND": {
+ "apiType": "index",
+ "format": "PSCodAMR DL_HISR Band Change, force NO_DATA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_AMR_DEBUG_UL_GETSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PSCodAMR UL_Get r_idx %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_RESET_FLAG_INFO": {
+ "apiType": "index",
+ "format": "PSCodEVS %d reset_flag=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_DECODER_PREPARE_PARAMETER": {
+ "apiType": "index",
+ "format": "PSCodEVS dec_prepare_parameter: EVS_network_request_bw=%d, EVS_capability_bw=%d, EVS_PCM_bw=%d EVS_HBLen=%d, EVS_BFI=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_ENCODER_PREPARE_PARAMETER1": {
+ "apiType": "index",
+ "format": "PSCodEVS enc_prepare_parameter1: EVS_network_request_bw=%d, EVS_capability_bw=%d, EVS_PCM_bw=%d codec=%MSP4G_Codec(0x%x), DTX=%d, EVS_CA_Par.enable=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Event duration EVS_HISR_start",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_PCM_SIZE": {
+ "format": "PSCodEVS hisr_ul FD216 UL PCM size=%d, EVS_pcm_ul_rb_buf size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_DROP_PCM": {
+ "format": "PSCodEVS hisr_ul drop EVS_pcm_ul_rb_buf PCM data",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_ENC_DONE": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul encoder done",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_ASSERT_ID": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul encoder EVS codec ID is wrong: 0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_PROCESS_EVS_HB": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul process EVS HB",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_BIT_LEN": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul EVS HB bit_len: %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_PROCESS_AWB_HB": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul process AWB HB",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_PROCESS_AWB_HB_LEN": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul AWB HB byte len: %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_AWB_INVALID_CODEC_RATE": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul AWB invalid codec rate: 0x%x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_ENC_NOT_FINISH": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul encoder do not finish, dsp_len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_ERROR": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul ERROR",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_DATA": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul DATA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_MUTE": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul MUTE",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_UL_NON": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_ul NON",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_DL_ERROR": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_dl ERROR",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_DL_DATA": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_dl DATA",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_DL_MUTE": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_dl MUTE",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HISR_DL_NON": {
+ "apiType": "index",
+ "format": "PSCodEVS hisr_dl NON",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get Return",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_EVS_HB_UL_RB_BUF_FREE_SPACE": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get EVS_HB_ul_rb_buf free space=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_HEADER_INFO": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get header ID=%x codec=%MSP4G_Codec(0x%x) byte_len=%d bit_len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_EVS_HB_UL_RB_BUF_EMPTY": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get EVS_HB_ul_rb_buf is empty",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_INFO": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get codec=%MSP4G_Codec(0x%x) bit_len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_MISMATCH_CODEC": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get Mismatch codec %x %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_INVALID_CODEC": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get invalid ul_codec_mode: %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_MERGE_3RAB_TO_IF1": {
+ "apiType": "index",
+ "format": "PSCodEVS UL_Get merge 3 R.A.B. to IF1",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_DL_PUTSPEECHFRAME_REORDERAWB_ENTER": {
+ "apiType": "index",
+ "format": "PSCodEVS DL_Put_ReorderAWB enter",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_1": {
+ "apiType": "index",
+ "format": "PSCodEVS DL_Put.1 ul_request_resync = %d reset_flag=%d ctime = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_2_1": {
+ "apiType": "index",
+ "format": "PSCodEVS DL_Put.2-1 forced no_data",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_2_2": {
+ "apiType": "index",
+ "format": "PSCodEVS DL_Put.2-2 forced no_data",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME": {
+ "apiType": "index",
+ "format": "PSCodEVS PSR_DL_Put",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME_RETURN": {
+ "apiType": "index",
+ "format": "PSCodEVS PSR_DL_Put: now is not EVS codec, skip this data flow.",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME_DATA": {
+ "apiType": "index",
+ "format": "PSCodEVS PSR_DL_Put: CFN=%x codec=%x to %x, encodebits=%02x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_SET_G711PARAMETERS": {
+ "apiType": "index",
+ "format": "PSCodG Set_G711Parameters input dec_init_CNG_enable is out of range(0~1): %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_SET_G711PARAMETERS_OUT_OF_RANGE": {
+ "apiType": "index",
+ "format": "PSCodG Set_G711Parameters input law is out of range(1~2): %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_ENCODE_GETBUFFERSIZE": {
+ "apiType": "index",
+ "format": "PSCodG Enc GetBufferSize %d %d %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_GETBUFFERSIZE": {
+ "apiType": "index",
+ "format": "PSCodG Dec GetBufferSize %d %d %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_DL_EVENT": {
+ "apiType": "index",
+ "format": "PSCodG DL_Event %d-th ",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_DL_EVENT_CODEC": {
+ "apiType": "index",
+ "format": "PSCodG DL_Event codec=%MSP4G_Codec(0x%x) len=%d hdr.len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_DL_EVENT_DECODED_GSERIES_DECODE_PROCESS": {
+ "apiType": "index",
+ "format": "PSCodG DL_Event Dec GSeries_Decode_Process result=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_DL_EVENT_DROP_PCM": {
+ "apiType": "index",
+ "format": "PSCodG DL_Event drop PCM",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_DL_EVENT_READHARDBIT_NO_SIZE": {
+ "apiType": "index",
+ "format": "PSCodG DL_Event ReadHardbit no size",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_INFO": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event %d-th codec=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_READPCM_NO_SIZE": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event ReadPCM no size",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_READPCM_SIZE": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event ReadPCM size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_WRITE1": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Write1 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_WRITE2": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Write2 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_WRITE3": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Write3 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_CODEC_MISMATCH": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event codec %d %d mismatch",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_DROP1": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event drop1 %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_DROP2": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event drop2 %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_DROP2_SIZE_INFO": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event drop2 stream size is larger than %dbyte",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_DROP3": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event drop3 %d ",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_DROP_CODEC_MUTE_INFO": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event drop data, SP_is_codec_mute()=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_ENCODED_FREE_SIZE": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Enc free_size=%d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_ENCODED_GSERIES_ENCODE_PROCESS": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Enc GSeries_Encode_Process return=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_UL_EVENT_ENCODED_INFO": {
+ "apiType": "index",
+ "format": "PSCodG UL_Event Enc codec=%d size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME2": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get: %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME_INFO": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get codec=%d len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME_MISMATCH": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get Mismatch codec %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME_NODATA": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get NoData",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_GETFRAME_OK": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Get Ok",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_PUTFRAME3": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Put aud_dl_id %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_PUTFRAME4": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Put codec=%d len=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_PUTFRAME_DROP": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Put drop",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_PUTFRAME_DROP_SIZE_INFO": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Put drop stream size is larger than %dbyte",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_PSR_PUTFRAME_MISMATCH": {
+ "apiType": "index",
+ "format": "PSCodG PSR_Put mismatch codec=%MSP4G_Codec(0x%x) %MSP4G_Codec(0x%x)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_DL_INFO1": {
+ "apiType": "index",
+ "format": "PSCodG hisr_dl_g %x fsize=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_DL_INFO2": {
+ "apiType": "index",
+ "format": "PSCodG hisr_dl_g reset_flag=%d rab_state=%d codec_mute=%d sp4g_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_DL_STATUS": {
+ "apiType": "index",
+ "format": "PSCodG hisr_dl_g %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_DL_NO_DATA": {
+ "apiType": "index",
+ "format": "PSCodG hisr_dl_g no data",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_UL": {
+ "apiType": "index",
+ "format": "PSCodG hisr_ul_g %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_UL_AUD_UL_ID": {
+ "apiType": "index",
+ "format": "PSCodG hisr_ul_g aud_ul_id %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_UL_DROP": {
+ "apiType": "index",
+ "format": "PSCodG hisr_ul_g drop",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_CODEC_G_HISR_UL_SIZE": {
+ "apiType": "index",
+ "format": "PSCodG hisr_ul_g size=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_1": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test[Check] unexpected resync",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_2": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test enter %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_3": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test retry (%d)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_4": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test abandon %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_5": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test stop",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_6": {
+ "apiType": "index",
+ "format": "sub_aam_resync_test testing %d %d %d %d idx %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_7": {
+ "apiType": "index",
+ "format": "aam_resync_test_start start1 aam_resync_test_idx=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_8": {
+ "apiType": "index",
+ "format": "aam_resync_test_start start2",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_RESYNC_TEST_9": {
+ "apiType": "index",
+ "format": "aam_resync_test_start start (skip)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_FAKE_L2_INFO": {
+ "apiType": "index",
+ "format": "PSAAM FAKE L2 Info rx_p=%d tx_p=%d t2tx=%d t2rx=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TRUE": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC True(%d) Start module=%d sph_l2_mode=%d l2_mode=%d sal_mode=%d %x %x %x %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_0": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC Fake %x %x %x %x %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake_offset %x %x %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake tx_fake_offset %x fake_offset %x fake_t2nextTX %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_3": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake time2nextTX %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_4": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake time2nextTX_skip %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_5": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake rx_fake_offset %x fake_offset %x fake_t2nextRX %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_6": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake time2nextRX %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_FAKE_7": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC fake time2nextRX_skip %x",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_INIT_INFO1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC setting: UL_HISR2SR=%dms reset_drift=%dms",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: emac tx=%d rx=%d t2tx=%d t2rx=%d issue_time=%d nmac tx=%d rx=%d t2tx=%d t2rx=%d issue_time=%d sal_mode=%d ul_margin=%d dl_margin=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO3": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: t2nextSR=%d t2nextDRX=%d t2nextULHISR=%d t2nextDLHISR=%d sph_l2_mode=%d is_4g_lch_on=%d is_5g_lch_on=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO4_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: selected_sph_l2_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO5": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: return with SPPS_is_trigger_mac_notify=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO6": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: return with useless info(%d) TX_period=%d, time2nextTX=%d RX_period=%d, time2nextRX=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_VOLTE_CALLOFF": {
+ "apiType": "index",
+ "format": "PSAAM LTE_emac_volte_calloff at sub_SP4G_emac_timing_update",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC1",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1_INFO": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC1: drx_period=%d sr_period=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1_INFO2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC1: time_to_next_on=%x time_to_trig_sr=%x ctime=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1_OK": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC1: OK",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1_SKIP": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC1: skip",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_RETURN": {
+ "apiType": "index",
+ "format": "PSAAM LTE_EMAC: return l2_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_GETSYNCDELAYRW_0": {
+ "apiType": "index",
+ "format": "PSAAM LTE_GetDelRW.0 %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_GETSYNCDELAYRW_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_GetDelRW.1 l2_mode= %d ctime = %d t2nextSR = %d t2nextDRX = %d t2nextULHISR = %d t2nextDLHISR = %d txperiod=%d rxperiod=%d time_emac_to_here= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_GETSYNCDELAYRW_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_GetDelRW.2 sal_mode=%d time2nextSR = %d TX_period= %d time2nextDRX = %d RX_period= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_GETSYNCDELAYRW_2_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_GetDelRW.2_1 offset_AAM = %d u16DelayR= %d u16DelayW = %d u16DelayM= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_LTE_GETSYNCDELAYRW_2_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_GetDelRW.2_2 offset_AAM invalid",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_EXECUTE_LTE_ON": {
+ "apiType": "index",
+ "format": "PSAAM Execute_LTE_On",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_EXECUTE_LTE_OFF": {
+ "apiType": "index",
+ "format": "PSAAM Execute_LTE_Off",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_EXECUTE_LTE_RESYNC": {
+ "apiType": "index",
+ "format": "PSAAM Execute_LTE_Resync",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_0_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.0 mac_notify %d codec_mute=%d SP4G_ul_resync_info_available=%d %d l2_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_0_1_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.0 %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_1_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.1 t2nextSR=%d t2nextDRX = %d t2nextULHISR=%d t2nextDLHISR = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_1_1_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.1-1 Skip Resync",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_2_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.2 time_emac_2_aamhisr = %d time_2_nextHISR = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_2_1_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.2-1 diff = %d diff_mod=%d diff_mod_2=%d tx_period_min = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_2_2_INFO": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.2-2 adjust diff_mod = %d with DRIFT_DSP2MCU_RESET = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_3": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.3 t_req_resync = %d ctime = %d tdiff_req_resync = %d, ul_req_resync = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_4": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.4 %d %d %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_5_1": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.5-2 UL sync start(%d)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_5_2": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.5-3 UL sync skip(%d)",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_CHECK_STATUS_LTE_5_3": {
+ "apiType": "index",
+ "format": "PSAAM CHK_STATUS_LTE.5-3 UL sync SPPS_is_aligned",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_HISR_1": {
+ "apiType": "index",
+ "format": "PSAAM AAM_HISR is_ever_aligned = %d aam_result = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_SMR_STATUS.1 mac_notify %d codec_mute=%d SP4G_ul_resync_info_available=%d %d l2_mode=%d time[l2_mode][0]=%d ctime = %d t2nextSR = %d t2nextDRX = %d t2nextULHISR = %d t2nextDLHISR = %d txperiod=%d rxperiod=%d time_emac_to_here= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_SMR_STATUS.2 sal_mode=%d time2nextSR = %d TX_period= %d time2nextDRX = %d RX_period= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_2_1": {
+ "apiType": "index",
+ "format": "PSAAM LTE_SMR_STATUS.2_1 offset_AAM = %d u16DelayR= %d u16DelayW = %d u16DelayM= %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_2_2": {
+ "apiType": "index",
+ "format": "PSAAM LTE_SMR_STATUS.2_2 offset_AAM invalid mac_notify %d codec_mute=%d SP4G_ul_resync_info_available=%d %d l2_mode=%d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_3": {
+ "apiType": "index",
+ "format": "PSAAM LTE_SMR_STATUS.3 ul_req_resync = %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAM_SMR_STATUS_3_1": {
+ "apiType": "index",
+ "format": "PSAAM SMR sync start",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_SET_ULFRAMETYPE": {
+ "apiType": "index",
+ "format": "Silence_Detec_set_ULType %d, %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_SET_DLFRAMETYPE": {
+ "apiType": "index",
+ "format": "Silence_Detec_set_DLType %d, %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS0": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status 0",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS1": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status 1",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS2": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status 2",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS3": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status 3",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS4": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status 4",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SILENCE_DETECTION_GET_STATUS_INFO": {
+ "apiType": "index",
+ "format": "Silence_Detec_get_status %d, %d, %d, %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAMPLUS_ENABLE": {
+ "apiType": "index",
+ "format": "PSAAMPlus Enable",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAMPLUS_DISABLE": {
+ "apiType": "index",
+ "format": "PSAAMPlus Disable",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAMPLUS_TALK": {
+ "apiType": "index",
+ "format": "PSAAMPlus TALK",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAMPLUS_SILENCE_SID_FIRST": {
+ "apiType": "index",
+ "format": "PSAAMPlus SILENCE SID first",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_AAMPLUS_SILENCE_SID_UPDATE": {
+ "apiType": "index",
+ "format": "PSAAMPlus SILENCE SID update",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_DSP_OPT_TONEDETETASKINIT": {
+ "apiType": "index",
+ "format": "PSDspOpt_ToneDeteTaskInit",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_DSP_OPT_TONEDETEEXEC": {
+ "apiType": "index",
+ "format": "PSDspOpt_ToneDeteExec frame %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_PS_DSP_OPT_PATTERNDETECION": {
+ "apiType": "index",
+ "format": "PSDspOpt_PatternDetecion frame: %d",
+ "traceClass": "TRACE_SP_PS"
+ }
+ },
+ {
+ "SP_CC_L2P_Hdler": {
+ "format": "[SP_CC]SP_L2P_Hdlr %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_L2P_Hdler_Err": {
+ "format": "[SP_CC]SP_L2P_Hdlr skip command: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_EVENT_HANDLER_ENTER": {
+ "format": "[SP_CC][event_handler] Enter event_id=%d param1=%d param2=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_EVENT_HANDLER_LEAVE": {
+ "format": "[SP_CC][event_handler] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_INVOKELCORE": {
+ "format": "[SP_CC]InvokeLCoreFunction %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_INVOKELCORE_INFO": {
+ "format": "[SP_CC]InvokeLCoreFunction %d %d %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_MSG_ID_AUDIO_L2P_SP3G_LOG_L1_INFO": {
+ "format": "[SP_CC]MSG_ID_AUDIO_L2P_SP3G_LOG_L1_INFO %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CC_SP_L2P_HANDLER_SKIP_COMMAND": {
+ "format": "[SP_CC]SP_L2P_Handler skip command: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_CHANGERAT_MODE": {
+ "format": "ChangeRAT_Mode %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_L4C_SETEVENT_ENTER": {
+ "format": "[SP_L4C_SetEvent] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_L4C_SETEVENT_LEAVE": {
+ "format": "[SP_L4C_SetEvent] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_M2M_HANDLER_SKIP_COMMAND": {
+ "format": "SP_M2M_Handler skip command: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SET_ISSTANDBYMODE": {
+ "apiType": "index",
+ "format": "L1SP_Set_isStandByMode: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_L4C_SKIP_NETWORKNOTIFICATION": {
+ "apiType": "index",
+ "format": "[SP_L4C_SetEvent] SKIP networknotification",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_EM_UPDATE_CODEC": {
+ "apiType": "index",
+ "format": "[SP_updateEmCodec] isEmCodecNotifyOff=%d, updateUL(%d)/updateDL(%d), voc=%d, l1sp.state=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT_C_PARAM": {
+ "format": "[SPE]SetSpeechEnhancement,c_param 0~47",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT_M_PARAM": {
+ "format": "[SPE]SetSpeechEnhancement,m_param 0~47",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT_M_PARAM_WB": {
+ "format": "[SPE]SetSpeechEnhancement,m_param_wb 0~47",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT1": {
+ "format": "[SPE]SetSpeechEnhancement, SAL_ENH_Dynamic_State_Set(SAL_ENH_DYN_DDL_SET) \u0014done ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT2": {
+ "format": "[SPE]SetSpeechEnhancement, SPE_WaitSPEDynready(SAL_ENH_DYN_DDL_SET) \u0014done ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT3": {
+ "format": "[SPE]SetSpeechEnhancement, SAL_ENH_Dynamic_State_Set ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT4": {
+ "format": "[SPE]SetSpeechEnhancement, SAL_ENH_Dynamic_State_Set done ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETSPEECHENHANCEMENT_SPE_WAITSPEDYNREADY_DONE": {
+ "format": "[SPE]SetSpeechEnhancement, SPE_WaitSPEDynready done ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETDYNAMICPARTOMD_NOT_FIND": {
+ "format": "[SPE]SetDynamicPartoMD can't find the ID number: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_SETDYNAMIC_SM": {
+ "format": "[SPE]SPE_SetDynamicStatemachine pos=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SPE_SET_EMI_INFO": {
+ "format": "[SPC][SPE] Set EMI INFO , Status: %d, offset : 0x%x, Len : 0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_NOTIFY_NETWORK_STATUS": {
+ "apiType": "index",
+ "format": "[SPC]spc_notify_network_status %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_NOTIFY_NETWORK_STATUS_SKIP": {
+ "format": "[SPC]spc_notify_network_status skip %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_PRINTS": {
+ "format": "[SPC]prints: %x, %d, %x, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AUDIOTASK_WAIT_EL1_RF_INIT": {
+ "format": "[SPC]AudioTask Wait EL1 RF Init for %d tick(s). ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_EPOF_SPC_FORCEENDALLAPP_NOTIFY_AP": {
+ "format": "[SPC] [EPOF]Spc_ForceEndAllApp notify AP",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_RECEIVEDYNAMICPARAMETER": {
+ "format": " %MAUD_SPC_DYNAMIC_PARAM_MAGICNUM_T(size=%d), comeFrom:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_DMNR_HEADER": {
+ "format": " [SPC][SPE]DMNR Header Check : %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_RECEIVEDYNAMICPARAMETER2": {
+ "format": "[SPC][SPE]spc_ReceiveDynamicParameter,Mode=%x,SpeechIndex=%x,Version=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_EMI_SPEECH_INFO": {
+ "format": "[SPC][SPE] Cehck EMI Speech Info Structure, State=%x,param_usip_index = %x, param_usip_len = %x, param_shm_valid=%x,param_path=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT": {
+ "apiType": "index",
+ "format": "[SPC][SPE]Ceheck speech psr. header format,Data_Header=%x\u0014,Network=%x",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_EMI_COMMON_PAR": {
+ "format": "[SPC][SPE]Check EMI Par. Common par : 0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_EMI_DBG_PAR": {
+ "format": "[SPC][SPE]Check EMI Par. DBG par : 0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_MODE_PAR": {
+ "format": "[SPC][SPE]Check NB mode par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_FIR_IN_PAR": {
+ "format": "[SPC][SPE]Check NB FIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_FIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check NB FIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_IIR_IN_PAR": {
+ "format": "[SPC][SPE]Check NB IIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_IIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check NB IIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_MIC1_IIR_PAR": {
+ "format": "[SPC][SPE]Check NB MIC1 IIR par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_NB_MIC2_IIR_PAR": {
+ "format": "[SPC][SPE]Check NB MIC2 IIRpar [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_MODE_PAR": {
+ "format": "[SPC][SPE]Check WB mode par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_FIR_IN_PAR": {
+ "format": "[SPC][SPE]Check WB FIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_FIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check WB FIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_IIR_IN_PAR": {
+ "format": "[SPC][SPE]Check WB IIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_IIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check WB IIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_MIC1_IIR_PAR": {
+ "format": "[SPC][SPE]Check WB MIC1 IIR par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_WB_MIC2_IIR_PAR": {
+ "format": "[SPC][SPE]Check WB MIC2 IIRpar [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_MODE_PAR": {
+ "format": "[SPC][SPE]Check SWB mode par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_FIR_IN_PAR": {
+ "format": "[SPC][SPE]Check SWB FIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_FIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check SWB FIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_IIR_IN_PAR": {
+ "format": "[SPC][SPE]Check SWB IIR in par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_IIR_OUT_PAR": {
+ "format": "[SPC][SPE]Check SWB IIR out par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_MIC1_IIR_PAR": {
+ "format": "[SPC][SPE]Check SWB MIC1 IIR par [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_CHECK_SWB_MIC2_IIR_PAR": {
+ "format": "[SPC][SPE]Check SWB MIC2 IIRpar [%x]: 0x%x,0x%x,0x%x,0x%x,0x%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPE_ASSERT_CHECK": {
+ "format": "[SPC][SPE]ASSERT!!, Par0:0x%x,Par1:0x%x,Par3:0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_CUST_DUMP_DROP": {
+ "apiType": "index",
+ "format": "[SPC][cust dump]drop a frame of dump",
+ "traceClass": "TRACE_WARNING"
+ }
+ },
+ {
+ "SPE_DSP_CHECK_NB_FIR_PAR": {
+ "format": "[SPE]Check FIR NB IN/OUT par, FIR NB IN[0]= 0x%x,[1]= 0x%x, FIR OUT PAR[0]=0x%x,[1]= 0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_DSP_CHECK_WB_FIR_PAR": {
+ "format": "[SPE]Check FIR WB IN/OUT par, FIR WB IN[0]= 0x%x,[1]= 0x%x, FIR OUT PAR[0]=0x%x,[1]= 0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_DSP_CHECK_SWB_FIR_PAR": {
+ "format": "[SPE]Check FIR SWB IN/OUT par, FIR SWB IN[0]= 0x%x,[1]= 0x%x, FIR OUT PAR[0]=0x%x,[1]= 0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYOFF_1": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOff] 1",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYOFF_2": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOff] 2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYOFF_ENTER": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOff] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYOFF_LEAVE": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOff] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYON_1": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOn] 1",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYON_2": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOn] 2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYON_ENTER": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOn] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAYON_LEAVE": {
+ "format": "[TONEDRV][dtmf_dsp_PlayOn] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAY_ENTER": {
+ "format": "[TONEDRV][DTMF_DSP_Play] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_PLAY_LEAVE": {
+ "format": "[TONEDRV][DTMF_DSP_Play] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_START_ENTER": {
+ "format": "[TONEDRV][dtmf_dsp_Start] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DTMF_DSP_START_LEAVE": {
+ "format": "[TONEDRV][dtmf_dsp_Start] Leave",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOP_FLUSHQUEUE1": {
+ "format": "[TONE]toneStop_FlushQueue_1 %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOP_FLUSHQUEUE2": {
+ "format": "[TONE]toneStop_FlushQueue_2 %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOP1": {
+ "format": "[TONE]toneStop1 return",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOP2": {
+ "format": "[TONE]toneStop2 %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONEMUTE": {
+ "format": "[TONE]toneMute %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONEPLAY": {
+ "format": "[TONE]TONE_Play[%d]",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOP": {
+ "format": "[TONE]TONE_Stop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOPANDWAIT1": {
+ "format": "[TONE]TONE_StopAndWait_1",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "TONESTOPANDWAIT2": {
+ "format": "[TONE]TONE_StopAndWait_2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOPFLUSHQUEUE1": {
+ "format": "[KT]ktStop_FlushQueue_1 %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOPFLUSHQUEUE2": {
+ "format": "[KT]ktStop_FlushQueue_2 %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOP1": {
+ "format": "[KT]ktStop_1 return",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOP2": {
+ "format": "[KT]ktStop_2 %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTPLAY": {
+ "format": "[KT]KT_Play[%d]",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOP": {
+ "format": "[KT]KT_Stop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOPANDWAIT1": {
+ "format": "[KT]KT_StopAndWait_1",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "KTSTOPANDWAIT2": {
+ "format": "[KT]KT_StopAndWait_2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_READ_BYTE": {
+ "format": "Read %d bytes from media buffer",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_MD2G_PWR_CTRL": {
+ "format": "MD2G PWR CTRL, audioid= %d, flag = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_MD2G_PWR_CTRL_DONE": {
+ "format": "MD2G PWR CTRL DONE, audioid= %d, flag = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_SETFLAG_A": {
+ "format": "[AUDMD2G] L1Audio_SetFlag , audioid= %d, dspUser = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_CLEARFLAG_A": {
+ "format": "[AUDMD2G] L1Audio_ClearFlag, audioid= %d, dspUser = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_SETFLAG_MD2G_A": {
+ "format": "[AUDMD2G] L1Audio_SetFlag_MD2G , audioid= %d, dspUser = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_CLEARFLAG_MD2G_A": {
+ "format": "[AUDMD2G] L1Audio_ClearFlag_MD2G, audioid= %d, dspUser = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SETOPENDSP_FLAG": {
+ "apiType": "index",
+ "format": "[SETOPENDSP]flag=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_PHONE_CALL": {
+ "apiType": "index",
+ "format": "[PHONECALL]pos=%d, %d, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MODE_VALUE": {
+ "apiType": "index",
+ "format": "[PHONECALL]param value: m0=%d, m1=%d, m2=%d, m3=%d, m4=%d, m5=%d, m6=%d, m7=%d, m8=%d, m9=%d, m10=%d, m11=%d, m12=%d, m13=%d, m14=%d, m15=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_COMMON_PARAM_VALUE": {
+ "apiType": "index",
+ "format": "[PHONECALL]Common Param value: c0=%d, c1=%d, c2=%d, c3=%d, c4=%d, c5=%d, c6=%d, c7=%d, c8=%d, c9=%d, c10=%d, c11=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_DEV_MODE_SETTING": {
+ "apiType": "index",
+ "format": "[SP_devInfo] before=%d, after=%d, beforeSr=%d, aferSr=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_EXT_DEV_SETTING": {
+ "apiType": "index",
+ "format": "[SP_extDevInfo] dev=%d, extDev=%d, echoRefDelay=%d, micDelay=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SPEECH_ENHANCEMENT": {
+ "format": "L1SP turn on speech enhancement flag=0x%x, m0=%d, m1=%d, c0=%d, c1=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SET_MIC_VOL": {
+ "format": "L1SP Set Mic Vol %d, sph_par %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_ADAPT_MIC_VOL": {
+ "format": "L1SP Adapt Mic Vol %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_INC_SPK_VOL": {
+ "format": "L1SP DSP Inc Spk Vol to %d, report %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_L4C_SEND_CODEC": {
+ "apiType": "index",
+ "format": "L1SP L4C Send Codec codec=%x l4c_codec=%x pre_l4c_codec=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_L4C_SEND_CODEC_SKIP": {
+ "apiType": "index",
+ "format": "L1SP L4C Send Codec_Skip codec=%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_L4C_SEND_CODEC_SKIP2": {
+ "apiType": "index",
+ "format": "L1SP L4C Send Codec_Skip without SpeechOn ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_L4C_SEND_CODEC_SKIP3": {
+ "apiType": "index",
+ "format": "L1SP L4C Send Codec_Skip pre_l4c_codec=%x ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_L4C_EVENT": {
+ "apiType": "index",
+ "format": "L1SP L4C Event %d mode=%d pre_mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_CONTROL_STATUS": {
+ "apiType": "index",
+ "format": "L1SP MuteControl(%x) apULmute=%x apDLmute=%x codec_mute=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_NOTIFY_NETWORK_STATUS": {
+ "apiType": "index",
+ "format": "[L1SP]l1sp_notify_network_status %d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP_M2M_HANDLER": {
+ "apiType": "index",
+ "format": "[L1SP]SP_M2M_HANDLER %d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_EXCEPTION": {
+ "format": "[DATACARD]Expection %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_OPEN_PORT": {
+ "format": "[DATACARD]mode=%d port %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_GET_DATA": {
+ "format": "[DATACARD]Audl Get %d Bytes from mode=%d, ori req %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_PUT_DATA": {
+ "format": "[DATACARD]Audl Put %d Bytes to mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_BUFFER_IDX": {
+ "format": "[DATACARD]ss_buf_idx %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_PLUGIN": {
+ "format": "[DATACARD]PlugIn mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_STRM_ENABLE": {
+ "format": "[DATACARD]Enable mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_STRM_DISABLE": {
+ "format": "[DATACARD]Disable mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_REQUEST_EXCHANGE_DL_DATA": {
+ "format": "[DataCard]##l1audio Enter MSG_SAC2L1AUDIO_SPEECH_DATACARD_REQUEST_EXCHANGE_DL_DATA is_strmOn=%d dl_ready=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_REQUEST_EXCHANGE_UL_DATA": {
+ "format": "[DataCard]##l1audio Enter MSG_SAC2L1AUDIO_SPEECH_DATACARD_REQUEST_EXCHANGE_UL_DATA is_strmOn=%d ul_ready=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_UL_HAS_NO_DATA": {
+ "format": "[DataCard]##l1audio UL has no data",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_UL_HAS_DATA": {
+ "format": "[DataCard]##l1audio UL has data",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_LEAVE_REQUEST_EXCHANGE_UL_DATA": {
+ "format": "[DataCard]##l1audio Leave MSG_SAC2L1AUDIO_SPEECH_DATACARD_REQUEST_EXCHANGE_UL_DATA",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_STRMONHANDLER": {
+ "format": "[DataCard]##spStrmOnHandler",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_STRMOFFHANDLER": {
+ "format": "[DataCard]##spStrmOffHandler",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_GETDATA1": {
+ "format": "[DataCard]##Enter GetData1 is_strmOn=%d ul_ready=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_GETDATA2": {
+ "format": "[DataCard]##Enter GetData2",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_ENTER_PUTDATA1": {
+ "format": "[DataCard]##Enter PutData1 is_strmOn=%d dl_ready=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_GET_SUFFICIENT_DATA": {
+ "format": "[DataCard]##GetData Data sufficient",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_GET_INSUFFICIENT_DATA": {
+ "format": "[DataCard]##GetData Data Insufficient",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DACA_LEAVE_GETDATA": {
+ "format": "[DataCard]##Leave GetData",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_USELESS_SET": {
+ "format": "SPH[ENH] %d, %d, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK": {
+ "format": "[SPC] Illegle app control to turn on %MMSG_SPC_APP_T when (%d)%MMSG_SPC_APP_T, gSpc.spcAppUsage=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_ILLEGAL_SPC_APP_BEHAVIOR": {
+ "format": "[SPC] Illegle app control with (%d)%MMSG_SPC_APP_T, to On/Off=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_APP_DATA_SEND_FAIL": {
+ "format": "[SPC] (%d)%MMSG_SPC_APP_T app send data fail at pos %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_M2A_DROP": {
+ "format": "[SPC] Drop app (%d)%MMSG_SPC_APP_T data send, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_INVALID_MSG": {
+ "apiType": "index",
+ "format": "[SPC]INVALID CCCI A2M MSG (%08X)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_M2A_DONE": {
+ "format": "[SPC] CCCI A2M %x done",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPEECH_ON": {
+ "format": "Spc_Speech_On %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE": {
+ "format": "Spc_Speech_On, ap&md payload size mismatch: apLen=%d, mdHeaderLen=%d, mdStructLen=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPEECH_ON_PAYLOAD": {
+ "apiType": "index",
+ "format": "Spc_Speech_On, app:%d, bt:%d, sr:%d, openDsp:%d, paramPath:%d, shmValid:%d, paramSize:%d, idx:%d, extDevInfo:%d, muteMask=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPEECH_OFF": {
+ "format": "Spc_Speech_Off",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SPEECH_ON_DTMF_SUPPORT": {
+ "format": "Spc_Speech_On, dtmf support:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SET_DROP_UL_MUTE": {
+ "apiType": "index",
+ "format": "spc_gain_UlMuteSet mute is not apply",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_SET_DROP_DL_MUTE": {
+ "apiType": "index",
+ "format": "spc_gain_DlMuteSet mute is not apply",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_SET_DROP_UL_SOURCE_MUTE": {
+ "apiType": "index",
+ "format": "spc_gain_UlSourceMuteSet mute is not apply",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_SET_DROP_DL_CODEC_MUTE": {
+ "apiType": "index",
+ "format": "spc_gain_DlMuteCodecSet mute is not apply",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_SET_DROP_DL_MUTE_WITH_POS": {
+ "apiType": "index",
+ "format": "spc_gain_DlMuteSet_withPos mute is not apply",
+ "traceClass": "TRACE_STATE"
+ }
+ },
+ {
+ "SPC_EM_DEFAULT_INIT": {
+ "apiType": "index",
+ "format": "spc_EmInit, default used common=%d, wb=%d, dmnr=%d, lspkDmnr=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_DROP_SET": {
+ "apiType": "index",
+ "format": "[SPC] drop seting 0x%08X [(0x%04X)%MAUD_CCCI_MSG_T], data16 = 0x%04X, data32 = 0x%08X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_EPOF_NOTIFY": {
+ "apiType": "index",
+ "format": "[SPC] Receive EPOF from L4C, application usage = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_CODEC_NOTIFY_IN": {
+ "apiType": "index",
+ "format": "[SPC][Codec] enter spc_codecInfoNotify. orgCodec=%x, newCodec=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_CODEC_NOTIFY_TO_AP": {
+ "apiType": "index",
+ "format": "[SPC][Codec] send AP Info codecInfo=\\\"%s\\\", codecOp=\\\"%s\\\"",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_CODEC_NOTIFY_UNKNOW": {
+ "apiType": "index",
+ "format": "[SPC][Codec] Unknow codec = %x, rr =%x, pos=%d",
+ "traceClass": "TRACE_WARNING"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_INFO": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]info enable=%d, flag=0x%x, delay=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_FROM_MIC": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]FromMic %d %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_SKIP_MIC": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Skip FromMic",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_TO_SE": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]ToSE %d %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_FILL_SE": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]FillSE",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_FROM_SD": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]FromSD %d %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_SKIP_SD": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Skip FromSD",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_TO_SPK": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]ToSPK %d %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_HISR_UL": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Extcodec_hisr_dl",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_HISR_DL": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Extcodec_hisr_ul",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_HISR_SKIP": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Extcodec stop hisr skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_FILL_SPK": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]FillSpk",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_AC_LOOPBACK_UL_DL_INDEX": {
+ "apiType": "index",
+ "format": "[SPC AC Loopback]Dw, Dr, Uw, Ur %d %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_NOTIFY_NETWORK_STATUS_INFO": {
+ "apiType": "index",
+ "format": "[SPC_NOTIFY_NETWORK_STATUS]tmp:%x isWB:%x RAT:%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SPE_CTRL_UPDATE": {
+ "format": "L1SP Set Enhancement ctrol update,ENH ctrl=0x%x, enhPath=0x%x, Network info=0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SET_ENHANCEMENT_SUB_MASK": {
+ "format": "L1SP Set Enhancement submask[%d]=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_ENHANCE_ON_OFF": {
+ "format": "[SPE]L1SP turn enhance =%d, with state=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPE_AGC_CONFIG_INFO": {
+ "format": "[SPE]AGC turnOff/On/Other=%d, gain=0x%x, isEchoRefOn=%d, micInfo=0x%x, dspParam=0x%x, enhMasEchoRef=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SET_ENH_FIR": {
+ "format": "SPH[ENH] enhancement mode %d, enhance Index %d, inFIR Index %d, outFIR Index %d, updateMask %d to value %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_CHANGE_ENH_MODE": {
+ "format": "SPH[ENH] ChangeSpeechMode premode=%d, aftermode=%d, currentMode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_WRITE_FIR": {
+ "format": "SPH[ENH] Write FIR isWB=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_SET_MIC_GAIN_CONTROL": {
+ "format": "[MIC GAIN CONTROL]L1SP set mic gain control %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_ADAPT_MIC_GAIN_CONTROL": {
+ "format": "[MIC GAIN CONTROL]L1SP adapt mic gain control %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_UL_CODEC_CONTROL": {
+ "apiType": "index",
+ "format": "[MUTE] AM_Mute_UL_Codec_Speech: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_UL_POS_EN_CONTROL": {
+ "format": "[MUTE] AM_Mute_UL_POS_EN_Speech: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_DL_TRAFFIC_CONTROL": {
+ "apiType": "index",
+ "format": "[MUTE] AM_Mute_DL_Speech_Traffic: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_DL_8K_CONTROL": {
+ "format": "[MUTE] AM_Mute_DL_8k_Speech: %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_UL_ENH_RESULT_CONTROL": {
+ "apiType": "index",
+ "format": "[MUTE] mute dsp uplink enhancement result(inAM): %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_UL_SOURCE_CONTROL": {
+ "apiType": "index",
+ "format": "[MUTE] mute dsp uplink source(inAM): %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_CONTROL": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] pos=%d, mute Point: %d, State: %d, Mute: %d, am state: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_QUEUE_FULL": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] RAMP queue is full",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_QUEUE_EMPTY": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] RAMP queue is empty",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_DONE_STATE": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] mute_state %d, rampPoint %d am.state %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_DELAY_MUTE": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] delay mute, may pop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_DELAY_UNMUTE": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] delay mute, may pop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_FORCE_MUTE": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] force mute, may pop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1SP_MUTE_DSP_RAMP_FORCE_UNMUTE": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] force unmute, may pop",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_MUTE_DSP_RAMP_ACK_POINT": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] spc RampWaitAck points %x, ramp point %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_MUTE_DSP_RAMP_NO_ACK": {
+ "apiType": "index",
+ "format": "[MUTE RAMP] No need to send ack",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_HISR_SKIP": {
+ "apiType": "index",
+ "format": "SP3G UL_HISR SKIP %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_CODEC_READY_SKIP": {
+ "format": "SP3G Skip Callback of Codec_Ready %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_CODEC_CLOSE_SKIP": {
+ "format": "SP3G Skip Callback of Codec_Close %d %d %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_CODEC_READY_OK": {
+ "format": "SP3G OK Callback of Codec_Ready %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_CODEC_CLOSE_OK": {
+ "format": "SP3G OK Callback of Codec_Close %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_PUT_SPEECH_FRAME_DEBUG": {
+ "format": "SP3G DL return %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_PUT_SPEECH_FRAME_DEBUG": {
+ "format": "SP3G UL return %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1D_RESYNC_UPDATE": {
+ "apiType": "index",
+ "format": "[SP3G L1D Resync]Update %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1D_RESYNC_RESET": {
+ "format": "[SP3G L1D Resync]Reset",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_L1D_Resync_Skip": {
+ "apiType": "index",
+ "format": "[SP3G L1D Resync] skip",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_L1D_Resync": {
+ "apiType": "index",
+ "format": "[SP3G L1D Resync] %d offeset=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DEBUG_UL_SETFRAMETYPE": {
+ "format": "[DEBUG]SP3G_UL_SetFrameType%d %d %d ftype=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DEBUG_UL_GETSPEECHFRAME": {
+ "apiType": "index",
+ "format": "Debug_UL_GetSpeechFrame %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_SYNC": {
+ "format": "SP3G_HISR 3g_sync=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DEBUG_UL_BUFF": {
+ "apiType": "index",
+ "format": "#debug_ul_buff(6) %d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RAB_EST_0": {
+ "format": "[PhoneCall3G] SP3G_Rab_Est state=%d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RAB_DEEST_0": {
+ "format": "[PhoneCall3G] SP3G_Rab_Deest state=%d ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RAB_EST": {
+ "format": "SP3G CSR notify RAB establish",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RAB_DEEST": {
+ "format": "SP3G CSR notify RAB De-establish",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_TX_SID_FIRST": {
+ "format": "SP3G_HISR TX SID FISRT",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RX_FORCE_NO_DATA_WHEN_CHANGE_BAND": {
+ "format": "SP3G_HISR RX Band Change,force speech frame to NO_DATA",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_TX_SID_UPDATE": {
+ "format": "SP3G_HISR TX SID UPDATE",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RX_SID_FIRST": {
+ "format": "SP3G_HISR RX SID FISRT",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RX_SID_UPDATE": {
+ "format": "SP3G_HISR RX SID UPDATE",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_RX_NO_DATA": {
+ "format": "SP3G_HISR RX GET NO DATA FRAME",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DTX_NO_DATA": {
+ "format": "SP3G_HISR INSERT NO DATA",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_BUFFER_STATUS": {
+ "format": "SP3G_HISR DL r = %d, w = %d, num = %d, 1st byte = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_DELAY": {
+ "format": "SP3G UL delay %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_REQUEST": {
+ "format": "SP3G Request",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_REQUEST_UL_FRAME_TYPE": {
+ "apiType": "index",
+ "format": "SP3G set UL frame type %Mem_csr_SpeechCodecType",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_GET_SPEECH_FRAME": {
+ "apiType": "index",
+ "format": "SP3G UL GetSpFrame",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_GET_SPEECH_FRAME_SKIP": {
+ "apiType": "index",
+ "format": "SP3G UL GetSpFrame %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_BUFFER_FINISH": {
+ "format": "SP3G DL Buffering finished",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_PUT_SPEECH_FRAME": {
+ "format": "SP3G DL sub_flow %d, frame_type %Mem_csr_SpeechCodecType, crc_status %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_LOG_L1_INFO": {
+ "format": "SP3G CFN=%x, l1info=%x, crc = %x, s_val =%x, %x, %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_L1A_UPDATE_INFO": {
+ "apiType": "index",
+ "format": "SP3G Update Info bitmap %d, val %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_INVALID_UL_CODEC_MODE": {
+ "apiType": "index",
+ "format": "SP3G invalid UL codec mode %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_SET_DTX": {
+ "format": "SP3G Set DTX %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_BIT_TRUE_DSP_F8": {
+ "apiType": "index",
+ "format": "SP3GHISR UL DSP len %d, %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_BIT_TRUE_DSP_N8": {
+ "apiType": "index",
+ "format": "SP3GHISR UL DSP %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_TX_SPEECH_GOOD": {
+ "apiType": "index",
+ "format": "SP3G_HISR UL is TX_SPEECH_GOOD",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_NO_DATA": {
+ "apiType": "index",
+ "format": "SP3G_HISR UL is NO DATA",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_BIT_TRUE_F8": {
+ "apiType": "index",
+ "format": "SP3G_HISR=%d UL Type %Mem_csr_SpeechCodecType, Frm %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_BIT_TRUE_N13": {
+ "apiType": "index",
+ "format": "SP3G UL %hx %hx %hx %hx %hx %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_BUFFER": {
+ "apiType": "index",
+ "format": "SP3GVT UL cnt=%d,r=%d,w=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_BIT_TRUE": {
+ "apiType": "index",
+ "format": "SP3G_HISR DL Type %d, Frm %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_BIT_TRUE_TASK": {
+ "apiType": "index",
+ "format": "SP3G DL Frm %x %x %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_BIT_TRUE_DSP_F8": {
+ "apiType": "index",
+ "format": "SP3GHISR DL DSP len %d, %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_BIT_TRUE_DSP_N8": {
+ "apiType": "index",
+ "format": "SP3GHISR DL DSP %hx %hx %hx %hx %hx %hx %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_FAKE_NODATA": {
+ "format": "SP3GVT Fake NoData",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_DL_TIMING": {
+ "apiType": "index",
+ "format": "SP3G DL Timing %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_TIMING": {
+ "apiType": "index",
+ "format": "SP3G UL Timing %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_D2M_UL_TIMING_MODIFY": {
+ "format": "SP3G D2M UL Timing MODIFY: LISR_64us=%x, HISR_64us=%x, diff_us=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_D2M_UL_TIMING": {
+ "apiType": "index",
+ "format": "SP3G D2M UL Timing %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_D2M_DL_TIMING": {
+ "apiType": "index",
+ "format": "SP3G D2M DL Timing %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_FORCE_NODATA_WHEN_RESYNC": {
+ "apiType": "index",
+ "format": "SP3G force one AMR_NO_DATA frame before resync",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_UL_DSP_NOT_READY_WARNING_AND_FILL_SILENCE": {
+ "apiType": "index",
+ "format": "SP3G_HISR UL NOT READY, Force Using Silence Pattern",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_FOUND_UL_SYNC_TIMING_ERROR": {
+ "apiType": "index",
+ "format": "SP3G found UL resync timing error",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_FOUND_DL_SYNC_TIMING_ERROR": {
+ "apiType": "index",
+ "format": "SP3G found DL resync timing error",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_SKIP_UL_REFRESH": {
+ "apiType": "index",
+ "format": "SP3G SKIP UL REFRESH ul_report=%d ul_codec_mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_HSPA_UL_GET_SPEECH_FRAME": {
+ "apiType": "index",
+ "format": "SP3GHSPA UL GetSpFrame type %Mem_csr_SpeechCodecType, len %d, %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_HSPA_DL_PUT_SPEECH_FRAME": {
+ "format": "SP3GHSPA DL PutSpFrame type %Mem_csr_SpeechCodecType, CFN %d, crc %d, %hx %hx",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3G_HSPA_DL_MAX_CS_DELAY": {
+ "format": "SP3GHSPA set Max CS delay %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_UL_GET_SPEECH_FRAME": {
+ "format": "SP3GVT UL GetSpFrm, CurFrmCount %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_UL_FRAME_INFO": {
+ "format": "SP3GVT UL Frm len %d, first 3 byte %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_DL_FRAME_INFO": {
+ "format": "SP3GVT DL Frm len %d, first 3 byte %x %x %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_DL_FRAME_ERROR": {
+ "format": "SP3GVT DL FrmType Err Warning %d !!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SP3GVT_SET_DELAY": {
+ "format": "SP3GVT SetDelay %d ms, about %d frame",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_SENDVMDATA_INFO": {
+ "apiType": "index",
+ "format": "vm prints: %x, %d, %x, %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_SP3G_VM_L1T": {
+ "format": "[VMREC] SP3G VM L1T %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_REC_DEBUG_INFO": {
+ "apiType": "index",
+ "format": "[VMREC] VM_DEBUG_INFO = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_REC_HISR_VM_DATA_LOST": {
+ "apiType": "index",
+ "format": "[VMREC] hisr data lost with count=%d, pos = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_REC_HISR_PCM_DATA_LOST": {
+ "apiType": "index",
+ "format": "[VMREC] some vm's pcm data is missing, pos = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_HISR_LOCK_NOT_AVALIABLE": {
+ "apiType": "index",
+ "format": "[VMREC] vm lcok is not avaiable in pos = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_INFO1": {
+ "format": "[vmFormatter_gseries] vm.control_1=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_INFO2": {
+ "format": "[vmFormatter_gseries] vm.control_2=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_ULSTREAM_ENTER": {
+ "format": "[vmStoreGCodecULStream] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_ULSTREAM_INFO1": {
+ "format": "[vmStoreGCodecULStream] u32TotalBufferSize=%d, vmGCodecULBufWritePos=%d, u16Stream2byteSize=%d, u16StreamSize=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_ULSTREAM_INFO2": {
+ "format": "[vmStoreGCodecULStream] data 2byte size is large than available buffer 2byte size, data 2byte size=%d, available buffer 2byte size=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_ULSTREAM_INFO3": {
+ "format": "[vmStoreGCodecULStream] data 2byte size is large than total buffer 2byte size, data 2byte size=%d, total buffer 2byte size=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_ULSTREAM_EXIT": {
+ "format": "[vmStoreGCodecULStream] Exit",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_DLSTREAM_ENTER": {
+ "format": "[vmStoreGCodecDLStream] Enter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_DLSTREAM_INFO1": {
+ "format": "[vmStoreGCodecDLStream] u32TotalBufferSize=%d, vmGCodecDLBufWritePos=%d, u16Stream2byteSize=%d, u16StreamSize=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_DLSTREAM_INFO2": {
+ "format": "[vmStoreGCodecDLStream] data 2byte size is large than available buffer 2byte size, data 2byte size=%d, available buffer 2byte size=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_DLSTREAM_INFO3": {
+ "format": "[vmStoreGCodecDLStream] data 2byte size is large than total buffer 2byte size, data 2byte size=%d, total buffer 2byte size=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_GFORM_DLSTREAM_EXIT": {
+ "format": "[vmStoreGCodecDLStream] Exit",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_VMRECORDHISR_G_CODEC": {
+ "format": "[vmrec]vmRecordHisr record 4G G-serial codec",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_TCHPCMHISR_G_CODEC": {
+ "format": "[vmrec]vmTchPcmRecordHisr record 4G G-serial codec",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "VM_TCHRECORDHISR_G_CODEC": {
+ "format": "[vmrec]vmTchRecordHisr record 4G G-serial codec",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_TONE_LOOPBACK_REC_CALLBACK_MODE": {
+ "format": "TONE_LOOPBACK_REC: callback Mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_TONE_LOOPBACK_REC_MODE": {
+ "format": "TONE_LOOPBACK_REC: Mode=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPCIO_INVALID_MSG": {
+ "apiType": "index",
+ "format": "INVALID SPCIO MSG ID(%08X), data (%08X) with reserved (%08X)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPCIO_INVALID_MSG_BEFORE_QUEUE_READY": {
+ "apiType": "index",
+ "format": "Before queue ready, INVALID SPCIO MSG ID(%08X), data (%08X) with reserved (%08X)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_ECALL_CHECK_TX_CTRL_HEADER": {
+ "apiType": "index",
+ "format": "[eCall]Check eCall TX Ctrl Header : %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_TX_CTRL_STATE": {
+ "apiType": "index",
+ "format": "[eCall] eCall_TX_CTRL_State, Header = 0xAA, [%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_TX_CTRL_DATA": {
+ "apiType": "index",
+ "format": "[eCall] eCall_TX_CTRL_dlDate, Header =0xBB,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_TX_CTRL_METRIC": {
+ "apiType": "index",
+ "format": "[eCall] eCall_TX_CTRL_dlMetric, Header =0xCC,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_RX_CTRL_STATE": {
+ "apiType": "index",
+ "format": "[eCall] eCall_RX_CTRL_State, Header = 0xDD, [%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_RX_CTRL_DATA": {
+ "apiType": "index",
+ "format": "[eCall] eCall_RX_CTRL_dlData, Header =0xEE,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_RX_CTRL_METRIC": {
+ "apiType": "index",
+ "format": "[eCall] eCall_RX_CTRL_dlMetric, Header =0xFF,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d,[%x]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_SEND_PAR_CTRL_SWITCH": {
+ "apiType": "index",
+ "format": "[eCall]Set_eCall_Par_Crtl_Switch=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPC_SEND_DATA_TO_AP_FAIL": {
+ "apiType": "index",
+ "format": "[eCall] Send Enc Data to AP Fail!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_MSD_RV_SENT": {
+ "apiType": "index",
+ "format": "[eCall] MSD RV%hd has been sent",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_RX_RECV_LL_DATA": {
+ "apiType": "index",
+ "format": "[eCall] received LL DL-Data",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_RX_RECV_HL_DATA": {
+ "apiType": "index",
+ "format": "[eCall] received HL DL-Data",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_DEMOD_INFO": {
+ "apiType": "index",
+ "format": "[eCall] msg = %s, metric = %d, maxCorr = %d, runnerup = %d, IVS_THRESHOLD = %u",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_DEMOD_UNRELIALBE1": {
+ "apiType": "index",
+ "format": "[eCall] msg is unreliable: maxCorr < IVS_THRESHOLD",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_DEMOD_UNRELIALBE2": {
+ "apiType": "index",
+ "format": "[eCall] msg is unreliable: (maxCorr-runnerup)/(maxCorr/100) <= 33",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_ECALL_HANDSHAKE_INFO_NOTIFY": {
+ "apiType": "index",
+ "format": "[eCall][IVS] eCall Handshake info notify,Header =%x,Data=%x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_DDLOAD_STATUS_FAIL": {
+ "apiType": "index",
+ "format": "[DDLoad]DSP Status Not Clear",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_DDLOAD_STATUS_SUCCESS": {
+ "apiType": "index",
+ "format": "[DDLoad]DDLoad success",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_DDLOAD_ID": {
+ "apiType": "index",
+ "format": "[DDLoad]DDLoad ID = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_OPEN": {
+ "format": "[eCall]IVS Driver Open %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_CLOSE": {
+ "format": "[eCall]IVS Driver Close",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_PUT_MSD": {
+ "format": "[eCall]IVS Driver PutMSD %d,%d,%d,%d,%d,%d,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_MSD_SET": {
+ "format": "[eCall]IVS Driver MSD from %d, msdSet %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_SEND_START": {
+ "format": "[eCall]IVS Driver SendStart",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_CATCH_EVENT": {
+ "format": "[eCall]IVS Driver Catch Event %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_MSD_NOT_SET": {
+ "format": "[eCall]IVS Driver MSD not set, ignore notify",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_HLACK": {
+ "format": "[eCall]IVS Driver HLACK. Expect %d, Received %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_DRV_ALLOCMEM_NULL": {
+ "format": "[eCall]IVS Driver CallModemIVS->allocMem is NULL",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_DRV_CATCH_EVENT": {
+ "format": "[eCall]PSAP Driver Catch Event %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_DRV_RECEIVE_MSD": {
+ "format": "[eCall]PSAP Driver Received MSD",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_DRV_MSD_DATA": {
+ "format": "[eCall]PSAP MSD %3d %3d %3d %3d %3d %3d %3d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_SENDSTART": {
+ "format": "[eCall]IVS SendStart received from control",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_SENDSTART_IGNORE": {
+ "format": "[eCall]IVS SendStart received from control, ignored",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RX_RESET": {
+ "format": "[eCall]IVS reset receiver",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_TX_RESET": {
+ "apiType": "index",
+ "format": "[eCall]IVS reset transmitter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_TX_RESET_MSD_PROVIDED": {
+ "format": "[eCall]IVS reset transmitter (MSD provided)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_SENDSTART_DUR_MSD_IGNORE": {
+ "format": "[eCall]IVS SendStart during MSD transmission, ignored.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_SENDING_SEND": {
+ "format": "[eCall]IVS sending SEND",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_FULL_RESET": {
+ "format": "[eCall]IVS full reset (no sync detected)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_IGNORING_HLACK": {
+ "format": "[eCall]IVS ignoring additional HLACK (data: 0x0%X, metric: %3d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_HLACK_FINISHED": {
+ "format": "[eCall]IVS received HLACK (data: 0x0%X, metric: %3d), finished.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_HLACK_WAITING": {
+ "format": "[eCall]IVS received HLACK (data: 0x0%X, metric: %3d), waiting...",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_START_LOW_RELIABILITY": {
+ "format": "[eCall]IVS received START !> ignoring message (reliability too low)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_START_TOO_OFTEN": {
+ "format": "[eCall]IVS received START (metric: %3d) too often starting over...",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_START_STARTING": {
+ "format": "[eCall]IVS received START (metric: %3d), starting...",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_FAST_MODULATOR": {
+ "format": "[eCall]IVS fast modulator chosen (NACK count: %d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_ROBUST_MODULATOR": {
+ "format": "[eCall]IVS robust modulator chosen (NACK count: %d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_START": {
+ "format": "[eCall]IVS received START (metric: %3d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_START_AFTER_ACK": {
+ "format": "[eCall]IVS START ... !> assuming previous ACK was wrong",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_START_AFTER_HLACK": {
+ "format": "[eCall]IVS START ... !> assuming previous HLACK was wrong",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_NACK_EXCEPTING_START": {
+ "format": "[eCall]IVS received NACK !> ignoring message (expecting START)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_NACK_LOW_RELIABILITY": {
+ "format": "[eCall]IVS received NACK !> ignoring message (reliability too low)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_NACK_ASSUME_IDLE": {
+ "format": "[eCall]IVS received NACK !> ignoring message (assume IDLE)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_NACK_FIRST_TIME": {
+ "format": "[eCall]IVS received NACK (metric: %3d), first time",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_NACK": {
+ "format": "[eCall]IVS received NACK (metric: %3d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_NACK_AFTER_ACK": {
+ "format": "[eCall]IVS NACK ... !> assuming previous ACK was wrong",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_NACK_AFTER_HLACK": {
+ "format": "[eCall]IVS NACK ... !> assuming previous HLACK was wrong",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK_EXPECTING_START": {
+ "format": "[eCall]IVS received ACK !> ignoring message (expecting START)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK_RECORDED": {
+ "format": "[eCall]IVS received ACK !> ignoring message (already recorded)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK_LOW_RELIABILITY": {
+ "format": "[eCall]IVS received ACK !> ignoring message (reliability too low)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK_ASSUME_IDLE": {
+ "format": "[eCall]IVS received ACK !> ignoring message (assume IDLE)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK": {
+ "format": "[eCall]IVS received ACK (metric: %3d), ACK recorded, wait for HLACK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_ACK_WAITING": {
+ "format": "[eCall]IVS received ACK (metric: %3d), waiting...",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_ACK_AFTER_HLACK": {
+ "format": "[eCall]IVS ACK ... !> assuming previous HLACK was wrong",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_IDLE_EXPECTING_START": {
+ "format": "[eCall]IVS received IDLE !> ignoring message (expecting START)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_IDLE_IGNORE": {
+ "format": "[eCall]IVS received IDLE !> ignoring message",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_MODEM_RECEIVED_IDLE_REMAINING": {
+ "format": "[eCall]IVS remaining in IDLE mode",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_DETECTED": {
+ "format": "[eCall]sync detected; delay: %+4d; npeaks: %+4d (inverted sync)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_DETECTED_REGULAR": {
+ "format": "[eCall]sync detected; delay: %+4d; npeaks: %+4d (regular sync)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_MAX_RANGE": {
+ "format": "[eCall]maximum sync checking range is [-480...480] samples",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_DETECTE_SLIP": {
+ "format": "[eCall]sync check detects sample slip! [%+1d sample(s)]",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_PSAP_MAX_RANGE": {
+ "format": "[eCall][PSAP] maximum sync tracking range is [-240...240] samples",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_SYNC_PSAP_SLIP": {
+ "format": "[eCall][PSAP] sync tracking detects sample slip! [%+1d sample(s)]",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_CONTROL_PORT_UNDEFINE": {
+ "format": "[eCall]control callback: port owner undefined.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_CONTROL_SYNC_LOCKED": {
+ "format": "[eCall]sync locked, starting control message detection",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_CONTROL_CODEC_INVERSION": {
+ "format": "[eCall]codec inversion detected!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_CONTROL_MESSAGE_IGNORE": {
+ "format": "[eCall]message ignored (bad sync check)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_SEND_CONTROL": {
+ "format": "[eCall][PSAP] SendStart received from control",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_SEND_OVER": {
+ "format": "[eCall][PSAP] SendStart received, starting over...",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_SEND_IGNORE": {
+ "format": "[eCall][PSAP] SendStart received from control, ignored.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_HLACK": {
+ "format": "[eCall][PSAP] HLACK data received from control",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_HLACK_IGNORE": {
+ "format": "[eCall][PSAP] HLACK data received from control, ignored.",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RESET_RECEIVER": {
+ "format": "[eCall][PSAP] reset receiver",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RESET_TRANSMITTER": {
+ "format": "[eCall][PSAP] reset transmitter",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_SEND": {
+ "format": "[eCall][PSAP] received SEND (metric: %3d), initiating START trigger",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_INVERSION_DETECT": {
+ "format": "[eCall][PSAP] codec inversion detected!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_INVERSION_SYNC": {
+ "format": "[eCall][PSAP] codec inversion detected (sync observer)!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RESTART": {
+ "format": "[eCall][PSAP] restart due to tracking failures!",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_CRC_FAIL": {
+ "format": "[eCall][PSAP] CRC failed; rv = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_RECEIVED_MSD": {
+ "format": "[eCall][PSAP] MSD successfully received; redundancy versions: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_SENDING_HLACK": {
+ "format": "[eCall][PSAP] sending HLACK; data: 0x0%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_SENDING_START": {
+ "format": "[eCall][PSAP] sending START",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_SENDING_NACK": {
+ "format": "[eCall][PSAP] sending NACK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_SENDING_ACK": {
+ "format": "[eCall][PSAP] sending ACK",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_SENDING_ACK_PEND": {
+ "format": "[eCall][PSAP] sending ACK (HLACK pending)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_FAST_REMAIN_IDLE": {
+ "format": "[eCall][PSAP] remaining in IDLE mode",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_FAST_MODULATION": {
+ "format": "[eCall][PSAP] fast modulator chosen (metric: %d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_MODEM_ROBUST_MODULATION": {
+ "format": "[eCall][PSAP] robust modulator chosen (metric: %d)",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_PCM_UPDATE_PUTTOSE": {
+ "format": "[eCall][PSAP] PCM4WAY_PutToSE (UpdatedUL) read_idx=%d, bufLen=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_PCM_INPUT_LEN": {
+ "format": "[eCall][PSAP] ul_pcm_input_len[%d]=%d, dl_pcm_input_len[%d]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_PSAP_PCM_UPDATE_UL": {
+ "format": "[eCall][PSAP] eCall_PSAP_ProcessFrame proc_idx=%d, IvsTxState=%d, eCallModemIVS->isUpdateUL[%d]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_HRT_STATUS": {
+ "format": "[eCall][IVS] HRT status,%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_PCM_UPDATE_PUTTOSE": {
+ "format": "[eCall][IVS] PCM4WAY_PutToSE (UpdatedUL) read_idx=%d, bufLen=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_PCM_INPUT_LEN": {
+ "format": "[eCall][IVS] ul_pcm_input_len[%d]=%d, dl_pcm_input_len[%d]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "ECALL_IVS_PCM_UPDATE_UL": {
+ "format": "[eCall][IVS] eCall_IVS_ProcessFrame proc_idx=%d, IvsTxState=%d, eCallModemIVS->isUpdateUL[%d]=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_HISR_DATA_DROP_DSP": {
+ "apiType": "index",
+ "format": "[rawPcmRec] Drop dsp data due to buffer is in using",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_HISR_DATA_FROM_DSP": {
+ "apiType": "index",
+ "format": "[rawPcmRec] SE buffer = %x, len = %x",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_GET_MIC_DATA_BUFS": {
+ "apiType": "index",
+ "format": "[rawPcmRec] RawPcmRec_GetMicDataBufs: add=%x, header len=%d, UL data len=%d, DL data len=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_GET_DATA_BUFS": {
+ "apiType": "index",
+ "format": "[rawPcmRec] Get data buffers add1 = %x, len1 = %d, add2 = %x, len2 = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_GET_DATA_INFO": {
+ "apiType": "index",
+ "format": "[rawPcmRec] Get data info %d: UL_fs=%d, UL_byte_len=%d, DL_fs=%d, DL_byte_len=%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_GET_EMPTY_DATA": {
+ "apiType": "index",
+ "format": "[rawPcmRec] Get data empty buffer",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "RAWPCMREC_HISR_LOCK_NOT_AVALIABLE": {
+ "apiType": "index",
+ "format": "[rawPcmRec] rawPcmRec lcok is not avaiable in hisr",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_HISR_TX_PERIOD": {
+ "format": "[SCO] btsco_hisr TX disable isr period %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_HISR_RX_PERIOD": {
+ "format": "[SCO] btsco_hisr RX disable isr period %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_HISR_PERIOD": {
+ "format": "[SCO] btsco_hisr disable isr period %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_MSBC_CORRECT_HEADER": {
+ "apiType": "index",
+ "format": "[SCO][DRV] MSBC DATA : correct header",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_MSBC_WRONG_HEADER": {
+ "apiType": "index",
+ "format": "[SCO][DRV] MSBC DATA : wrong header",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_MSBC_PACKET_NOT_FOUND": {
+ "apiType": "index",
+ "format": "[SCO][DRV] MSBC DATA : packets can not be found",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_MSBC_DATA_PACKET_NOT_FOUND": {
+ "apiType": "index",
+ "format": "[SCO][DRV] MSBC DATA : wrong header and failed packets",
+ "traceClass": "TRACE_FUNC"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_SP_ON": {
+ "format": "[SCO][DRV]Speech On, state: %d, fWideBand = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_SP_OFF": {
+ "format": "[SCO][DRV]Speech Off, state: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_START": {
+ "format": "[SCO][DRV]Start, state: %d, fWideBand = %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_STOP": {
+ "format": "[SCO][DRV]Stop, state: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROCESS": {
+ "format": "[SCO][DRV]Process, state: %d, pRX: 0x%X, pTX: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_HISR": {
+ "format": "[SCO][DRV]HISR, state: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_CONTROL": {
+ "format": "[SCO][DRV]Control: 0x%X, PacketType: %d, W_Address: 0x%X, R_Address: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_COPY_RX": {
+ "format": "[SCO][DRV]Copy_RX, overflow : %d, iPacket_w: %d, iPacket_r: %d, uBufferCount: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_COPY_TX": {
+ "format": "[SCO][DRV]Copy_TX, underflow: %d, iPacket_w: %d, iPacket_r: %d, uBufferCount: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_GET_MEM": {
+ "format": "[SCO][DRV]GetMemory, uModule: %d, uSize(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_TX_RAW": {
+ "format": "[SCO][DRV]PROC_TX_RAW, RawDataLen(byte): %d,uPcmBuf_w(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_TX_SRC": {
+ "format": "[SCO][DRV]PROC_TX_SRC, uConsumeByte: %d, uOutByte: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_TX_CVSD": {
+ "format": "[SCO][DRV]CVSD_TX_CVSD, iPacket_w: %d, iPacket_r: %d, fEnableFilter: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_RX_RAW": {
+ "format": "[SCO][DRV]PROC_RX_RAW, CurrentFreeSpace(byte): %d, TotalFreeSpace(byte): %d, uPcmBuf_r(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_RX_PLC": {
+ "format": "[SCO][DRV]PROC_RX_PLC",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_PROC_RX_CVSD": {
+ "format": "[SCO][DRV]CVSD_RX_CVSD, iPacket_w: %d, iPacket_r: %d, fEnableFilter: %d, fEnablePLC: %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_ALLOC_MEM": {
+ "format": "[SCO][DRV]Alloc Memory, Size: %d, ptr: 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_AP_SPEECH_TX_DATA": {
+ "format": "[SCO][APP]Speech TX data, uCurrentSpace(Byte): %d, uTotalSpace(Byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_AP_SPEECH_TX_OF": {
+ "format": "[SCO][APP]Speech TX Overflow, freespace(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_AP_SPEECH_RX_DATA": {
+ "format": "[SCO][APP]Speech RX data, uCurrentData(Byte): %d, uTotalData(Byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "L1AUDIO_BTSCO_AP_SPEECH_RX_UF": {
+ "format": "[SCO][APP]Speech RX Underflow, datacount(byte): %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "SPLOG_GET_DBG_FLAG": {
+ "apiType": "index",
+ "format": "[SPLOG]GET_DBG_FLAG, 0x%X",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER2_START": {
+ "format": "Enter PcmMixer_Start",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER2_CONFIG_DL": {
+ "format": "pcmMixer DL Config, isMix:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER2_CONFIG_UL": {
+ "format": "pcmMixer UL Config, isMix:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER3_START": {
+ "format": "Enter PcmMixer3_Start",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER3_CONFIG_UL": {
+ "format": "pcmMixer3 UL Config, isMix:%d, gain:%d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER3_INFO": {
+ "format": "PcmMixer3 Gain %x Mix %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "MIXER3_DATA_LENGTH": {
+ "format": "PcmMixer3_writeUlBuf %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DROP_SPEECH_QUALITY_EM": {
+ "format": "[DMF]drop speech quality hisr, pos:%d, rat=%d, source=0x%x",
+ "traceClass": "TRACE_INFO"
+ }
+ }
+ ],
+ "traceFamily": "PS",
+ "userModule": ""
+}
diff --git a/mcu/driver/audio/src/v1/inc/media.h b/mcu/driver/audio/src/v1/inc/media.h
new file mode 100644
index 0000000..beac009
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/media.h
@@ -0,0 +1,342 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * media.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Media file recording/playback
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef __MEDIA_H
+#define __MEDIA_H
+
+#include "fs_type.h"
+#include "fsal.h"
+
+#include "l1audio.h"
+#include "l1aud_common_def.h"
+
+
+/*****************************************************************************
+* Function Declaration
+*****************************************************************************/
+// void mediaHisr( uint16 flag );
+
+
+/* L1Audio_IDMA*/
+//void IDMA_WriteToDSP(volatile kal_uint16 *dst, kal_uint16 *src, kal_uint32 length);
+//void IDMA_FillToDSP(volatile kal_uint16 *dst, kal_uint16 value, kal_uint32 length);
+//void IDMA_ReadFromDSP(kal_uint16 *dst, volatile kal_uint16 *src, kal_uint32 length);
+//void IDMA_ReadFromDSP_Skip_1(kal_uint16 *dst, volatile kal_uint16 *src, kal_uint32 length);
+//void IDMA_WriteToDSP_Duplicate(volatile kal_uint16 *dst, kal_uint16 *src, kal_uint32 length);
+void EMI_ReadFromDSP(kal_uint16 *dst, volatile kal_uint16 *src, kal_uint32 length);
+void EMI_WriteToDSP(volatile kal_uint16 *dst, kal_uint16 *src, kal_uint32 length);
+
+/* For Ring Buffer Access */
+// void rb_ClearRB( void );
+// int32 rb_GetByteCount( void );
+// int32 rb_GetFreeSpace( void );
+// bool rb_GetByte( uint8* data_8 );
+// bool rb_GetWord( uint16* data_16 );
+// bool rb_GetDWord( uint32* data_32 );
+// bool rb_PeekByte( uint8* data_8 );
+// bool rb_PeekWord( uint16* data_16 );
+// bool rb_PeekDWord( uint32* data_32 );
+// bool rb_PutByte( uint8 data_8 );
+// bool rb_PutWord( uint16 data_16 );
+// bool rb_PutDWord( uint32 data_32 );
+// uint32 rb_SkipNByte( uint32 skip_count );
+// uint32 rb_SkipNWord( uint32 skip_count );
+// uint32 rb_GetWriteIndex( void );
+// uint32 rb_GetReadIndex( void );
+// uint32 rb_GetSize( void );
+// uint16 rb_GetOBFlag( void );
+// uint16 rb_GetOddByte( void );
+//int rb_PutNByte( const uint8 *buffer, int len );
+// nint rb_GetNByte( uint8 *buffer, int len );
+/* For Ring Buffer Access */
+
+
+void ktInit( uint16 aud_id, uint16 id_num );
+void ktLock( void );
+void ktUnlock( void );
+void toneInit( uint16 aud_id, uint16 id_num );
+
+#define VERIFY_DATA_TO_DSP 0
+
+/* L1CTM interface */
+void l1ctm_init( void );
+
+int32 rbGetDataCount( AUD_RB_INFO *rb );
+//kal_uint8 rbGetByte(AUD_RB_INFO *srcRB);
+void rbGetWriteBuffer( AUD_RB_INFO *rb, kal_uint8 **buffer, kal_uint32 *buf_len );// in bytes
+void rbGetReadBuffer( AUD_RB_INFO *rb, kal_uint8 **buffer, kal_uint32 *buf_len );// in bytes
+void rbWriteDataDone( AUD_RB_INFO *rb, kal_uint32 len ); // in bytes
+void rbReadDataDone( AUD_RB_INFO *rb, kal_uint32 len ); // in bytes
+int32 rbGetFreeSpace( AUD_RB_INFO *rb );
+
+
+// speech enhancement control functions
+// #define SPE_ES_FLAG (1 << 0)
+//#define SPE_AEC_FLAG (1 << 1)
+// #define SPE_EES_FLAG (1 << 2)
+//#define SPE_UL_NR_FLAG (1 << 3)
+//#define SPE_DL_NR_FLAG (1 << 4)
+//#define SPE_TDDNC_FLAG (1 << 5)
+//#define SPE_DMNR_FLAG (1 << 6)
+//#define SPE_AGC_FLAG (1 << 7)
+#define NUM_OF_SPH_FLAG 8 // if you add new SPE, please remind to revind the table define from uint8 to uint 16
+
+//speech enhancement mask for l1sp.spe_mask usage
+// #define SPH_ENH_MASK_ES SPE_ES_FLAG
+//#define SPH_ENH_MASK_AEC SPE_AEC_FLAG
+// #define SPH_ENH_MASK_EES SPE_EES_FLAG
+//#define SPH_ENH_MASK_ULNR SPE_UL_NR_FLAG
+//#define SPH_ENH_MASK_DLNR SPE_DL_NR_FLAG
+//#define SPH_ENH_MASK_TDDNC SPE_TDDNC_FLAG
+//#define SPH_ENH_MASK_DMNR SPE_DMNR_FLAG
+//#define SPH_ENH_MASK_AGC SPE_AGC_FLAG
+// #define SPH_ENH_MASK_SIDETONE (1 << NUM_OF_SPH_FLAG) removed
+//#define SPH_ENH_MASK_NOTCH_FILTER (1 << (NUM_OF_SPH_FLAG+1))
+//#define SPH_ENH_MASK_ECHO_REF (1 << (NUM_OF_SPH_FLAG+2))
+
+#define SPE_DMNR_SUPPORT (1 << 0)
+#define SPE_TDNC_SUPPORT (1 << 1)
+#define SPE_MAGI_CON_SUPPORT (2 << 1)
+
+
+
+void SPE_Init( void );
+void SPE_ENHCtrlSwitch(uint16 state);
+
+
+void SPE_Clear_DLL_Entry();
+//void SPE_SetULNR( bool ec );
+void SPE_LoadLimiterPara(uint16 para);
+#if defined(_SPE_ENH_MD_PARSE_)
+void SPE_LoadDmnrCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM]);
+void SPE_LoadWbDmnrCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM]);
+void SPE_LoadDmnrLspCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM]);
+void SPE_LoadWbDmnrLspCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM]);
+void SPE_LoadSWbLspDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM]);
+void SPE_LoadSWbDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM]);
+#endif
+
+
+
+/* L1SP interface */
+void L1SP_Init( void );
+void SPE_Enable_DLL_Entry(void);
+bool isSPEEnable(void);
+
+#if defined(_SPE_ENH_MD_PARSE_)
+void SetDynamicParToDSP(uint32 IDnumber);
+void L1SP_LoadSpeechPara( void );
+void Set2GDynPar(void);
+void Set3GDynPar(void);
+void Set4GDynPar(void);
+void SetC2KDynPar(void) ;
+void SPE_SetDynamicStatemachine(void);
+#else // for 95,97
+void SPE_SetDynamicStatemachine(kal_uint32 Offset, kal_uint32 Len);
+#endif
+
+
+
+
+void L1SP_SetState(kal_uint8 state);
+kal_uint8 L1SP_GetState( void );
+void L1SP_Set_isStandByMode(bool RAB_status);
+bool L1SP_Get_isStandByMode( void );
+void L1SP_Reload_SPE_Para( void );
+void L1SP_Register_Pcm4WayService(void (*onHandler)(void *), void (*offHandler)(void *));
+void L1SP_UnRegister_Pcm4Way_Service( void );
+bool L1SP_isC2KSO_Connected();
+
+kal_bool L1SP_TCH_State( void );
+
+enum{ // RIMIND: please keep following same as em_speech_info_SpeechNetworkType in audio_enum.h
+ L1SP_STATE_IDLE = 0,
+ L1SP_STATE_2G_SPEECH_ON,
+ L1SP_STATE_3G_SPEECH_ON,
+ L1SP_STATE_3G324M_SPEECH_ON,
+ L1SP_STATE_3G_SPEECH_CLOSING,
+ L1SP_STATE_4G_SPEECH_ON,
+ L1SP_STATE_4G_SPEECH_CLOSING,
+ L1SP_STATE_C2K_SPEECH_ON,
+ L1SP_STATE_C2K_SPEECH_CLOSING,
+ //L1SP_STATE_3G_SPEECH_CLOSED
+};
+
+void sp3g_speech_init( uint8 RAT_Mode );
+void sp3g_speech_close( bool IsInterRAT );
+void sp3g_init( void );//boot up init
+kal_bool SP3G_Rab_State( void );
+kal_uint32 SP3G_Rab_Id( void );
+void SP3G_Reset( void );
+void SP3G_SetRxTypeToNoData( void );
+kal_bool SP3G_IsDTXOn( void );
+void SP3G_GetSyncDelayRW( kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us);
+void SP3G_UpdateL1AInFo_P( kal_uint8 bitmap, kal_uint8 value );
+kal_uint32 SP3G_GetCodecMode(void);
+
+void sp4g_speech_init( uint8 RAT_Mode );
+void sp4g_speech_close( void );
+void sp4g_init( void );//boot up init
+kal_bool SP4G_Rab_State( void );
+kal_uint32 SP4G_Rab_Id( void );
+void SP4G_Reset( void );
+void SP4G_SetRxTypeToNoData( void );
+kal_bool SP4G_IsDTXOn( void );
+void SP4G_GetSyncDelayRW( kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us);
+
+void SPC2K_GetSyncDelayRW( uint16 *u2DelR, uint16 *u2DelW, uint16 *u2DelM);
+void SPC2K_ConSSO_Done( void );
+void SPC2K_DisconSSO_Done( void );
+
+void L1SP_C2K_Est(int codec);
+void L1SP_C2K_DeEst( void );
+void L1SP_C2K_IntraRAT(int codec);
+
+void L1SP_SetOpenDSPFlag(kal_uint8 flag);
+kal_uint8 L1SP_GetOpenDSPFlag(void);
+
+kal_uint32 L1Audio_GetEventGroup( void );
+void L1Audio_ExeEventHandler( kal_uint32 event );
+void L1Audio_ActivateHisrHandler(kal_uint16 magic_no, void *userData);
+
+
+// For In Process Call
+void L1Audio_InProcCall(in_proc_call_type func, kal_uint32 func_arg1, void* func_arg2);
+void L1Audio_InProcCall2(in_proc_call_type func, kal_uint32 func_arg1, void* func_arg2);
+
+
+
+// uint32 PCM2Way_GetBandInfo(void);
+
+// Speech related
+void SP_Strm_Init(void);
+
+#endif /* __MEDIA_H */
+
+
diff --git a/mcu/driver/audio/src/v1/inc/pcm4way.h b/mcu/driver/audio/src/v1/inc/pcm4way.h
new file mode 100644
index 0000000..ef8094c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcm4way.h
@@ -0,0 +1,281 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * pcm4way.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * PCM4WAY/PCM2WAY interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __PCM4WAY_H
+#define __PCM4WAY_H
+#include "l1aud_common_def.h"
+
+
+// #define PNW_ENBLE (1<<8)
+#define DATA_SELECT_AFTER_ENH (1<<9)
+#define USE_D2M_PATH (1<<10)
+#define USE_M2D_PATH (1<<11)
+
+// #define PNW_DSP_IDLE (0)
+// #define PNW_DSP_ON (1)
+// #define PNW_DSP_READY (2)
+
+// #define PCM4WAY_STATE 0x1
+// #define PCM2WAY_STATE 0x2
+
+typedef enum{
+ PNW_STATE_IDLE = 0,
+ PNW_STATE_RUN,
+
+}PCMEX_STATE;
+
+typedef enum {
+ PCMEX_BAND_UNSET = 0,
+ PCMEX_BAND_NB,
+ PCMEX_BAND_WB,
+ PCMEX_BAND_SWB,
+ PCMEX_BAND_FB,
+ PCMEX_BAND_DYNAMIC, // follow codec, only for delication mode
+}PCMEX_BAND;
+
+typedef enum {
+ PCMEX_IDLE_ENH_SETTING_NONE = 0,
+ PCMEX_IDLE_ENH_SETTING_WITH,
+ PCMEX_IDLE_ENH_SETTING_WITHOUT,
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif
+}PCMEX_IDLE_ENH_SETTING;
+
+
+typedef struct{
+ uint16 aud_id; // to lock sleep mode
+ bool isEnhOn;
+ kal_uint32 running;
+ kal_spinlockid PCMEXspinLockID;
+
+ PCMEX_STATE state; // on/off
+ kal_uint32 am_type;
+ // kal_uint32 app_type;
+
+ PCMEX_BAND bandInfo; //to record the band information,
+
+ kal_uint32 cfgUL1;
+ kal_uint32 cfgUL2;
+ kal_uint32 cfgUL3;
+ kal_uint32 cfgUL4;
+ kal_uint32 cfgDL;
+
+ // kal_int16 dspPcmExMicLen; // unit is 16-bit (sampel), -1 means useless
+ // kal_int16 dspPcmExSpkLen; // unit is 16-bit (sampel), 0xFFFFFFFF means useless
+
+ void (*pnw_dl_hdlr)(void);
+ void (*pnw_ul_hdlr)(void);
+}_PCMEX_T;
+
+
+typedef enum{
+ PNW_APP_TYPE_IDLE = 0,
+ PNW_APP_TYPE_UNDER_CALL,
+}PCMEX_APP_TYPE;
+
+
+typedef enum{
+ MCU_SET_P4W_OFF = 0,
+ MCU_SET_P4W_ON = 1,
+ DSP_SET_P4W_READY = 2
+}P4W_CTRL_STATUS;
+
+typedef enum{
+ MCU_SET_P2W_OFF = 0<<4,
+ MCU_SET_P2W_ON = 1<<4,
+ DSP_SET_P2W_READY = 2<<4
+}P2W_CTRL_STATUS;
+
+
+typedef enum {
+ P4W_APP_CTM = 0,
+ P4W_APP_TYPE_UNDER_CALL, //p2w acts as I/O to get/put pcm data under idle
+ P4W_APP_TYPE_WITHOUT_CALL,
+ P4W_APP_TYPE_WITHOUT_CALL_WB,
+ P4W_APP_ECALL_DETECT,
+
+ P4W_APP_TYPE_UNDEFINE = 0xFFFF
+}P4W_APP_TYPE;
+
+typedef enum {
+ P2W_APP_TYPE_UNDER_CALL = 0, //p2w acts as I/O to get/put pcm data under phone call
+ P2W_APP_TYPE_WITHOUT_CALL, //p2w acts as I/O to get/put pcm data when idle
+ P2W_APP_TYPE_VOIP, //VOIP, speech quality like phone call but not under calling
+ // P2W_APP_TYPE_REC_ONLY_CAL, //dmnr calibration, record only
+ // P2W_APP_TYPE_REC_PLAY_CAL //dmnr calibration, record and playback at the same time
+ P2W_APP_TYPE_UNDEFINE = 0xFFFF
+}P2W_App_Type;
+
+
+void PCM4WAY_Start(void (*pcm4way_hdlr)(void), uint32 type);
+void PCM4WAY_Stop(uint32 type);
+// void Extended_PCM4WAY_Start(void (*pcm4way_dl_hdlr)(void), void (*pcm4way_ul_hdlr)(void), uint32 type, uint32 cfgUL, uint32 cfgDL);
+// void Extended_PCM4WAY_Stop(uint32 type);
+
+uint16 PCM4WAY_GetFromMic(uint16 *ul_buf);
+uint16 PCM4WAY_GetFromMic2(uint16 *ul_buf);
+uint16 PCM4WAY_PutToSE(const uint16 *ul_data);
+uint16 PCM4WAY_PutToSE2(const uint16 *ul_data);
+uint16 PCM4WAY_FillSE(uint16 value);
+uint16 PCM4WAY_FillSE2(uint16 value);
+
+uint16 PCM4WAY_GetFromSD(uint16 *dl_buf);
+uint16 PCM4WAY_PutToSpk(const uint16 *dl_data);
+uint16 PCM4WAY_FillSpk(uint16 value);
+
+void PCM2WAY_Start(void (*pcm2way_hdlr)(void), uint32 type);
+void PCM2WAY_Stop(uint32 type);
+// void Extended_PCM2WAY_Start(void (*pcm2way_dl_hdlr)(void), void (*pcm2way_ul_hdlr)(void), uint32 type, uint32 cfgUL, uint32 cfgDL);
+// void Extended_PCM2WAY_Stop(uint32 type);
+
+uint16 PCM2WAY_GetFromMic(uint16 *ul_buf);
+uint16 PCM2WAY_PutToSpk(const uint16 *dl_data);
+uint16 PCM2WAY_FillSpk(uint16 value);
+
+void Idle_PcmEx_Start(void (*pcmNway_dl_hdlr)(void), void (*pcmNway_ul_hdlr)(void), uint32 cfgUL1, uint32 cfgUL2, uint32 cfgUL3, uint32 cfgUL4, uint32 cfgDL, PCMEX_BAND band, PCMEX_IDLE_ENH_SETTING enhSetting);
+void Del_PcmEx_Start(void (*pcmNway_dl_hdlr)(void), void (*pcmNway_ul_hdlr)(void), uint32 cfgUL1, uint32 cfgUL2, uint32 cfgUL3, uint32 cfgUL4, uint32 cfgDL);
+void PcmEx_Stop(void);
+void pcmEx_Init();
+bool pcmEx_isRunInIdleMode(void);
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/pcmMixer.h b/mcu/driver/audio/src/v1/inc/pcmMixer.h
new file mode 100644
index 0000000..d71f4e3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcmMixer.h
@@ -0,0 +1,29 @@
+
+#ifndef __PCMMIXER_H__
+#define __PCMMIXER_H__
+
+
+uint16 PcmMixer_QueryDlBufLen(void);
+void PcmMixer_writeDlBuf(uint16 *srcBuf, uint16 len);
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer_ConfigUl(kal_bool isMix, kal_int8 gain );
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer_ConfigDl(kal_bool isMix, kal_int8 gain );
+
+/**
+ @mixerHisrHandler: handler
+*/
+void PcmMixer_Start(void (*mixerHisrHandler)(void));
+void PcmMixer_Stop(void);
+
+void PcmMixer_Init(void);
+
+#endif //__PCMMIXER_H__
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/inc/pcmMixer3.h b/mcu/driver/audio/src/v1/inc/pcmMixer3.h
new file mode 100644
index 0000000..1a22c2d
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcmMixer3.h
@@ -0,0 +1,29 @@
+
+#ifndef __PCMMIXER3_H__
+#define __PCMMIXER3_H__
+
+
+uint16 PcmMixer3_QueryUlBufLen(void);
+void PcmMixer3_writeUlBuf(uint16 *srcBuf, uint16 len);
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+void PcmMixer3_ConfigUl(kal_bool isMix, kal_int8 gain );
+
+/**
+ @isMix: Mixer switch for uplink speech, 1 for SPH+Sound, 0 for sound only
+ @gain: Sound effect gain for uplink mixer, for 0 to 7
+*/
+//void PcmMixer3_ConfigDl(kal_bool isMix, kal_int8 gain );
+
+/**
+ @mixerHisrHandler: handler
+*/
+void PcmMixer3_Start(void (*mixerHisrHandler)(void));
+void PcmMixer3_Stop(void);
+
+void PcmMixer3_Init(void);
+
+#endif //__PCMMIXER3_H__
\ No newline at end of file
diff --git a/mcu/driver/audio/src/v1/inc/pcmRouter.h b/mcu/driver/audio/src/v1/inc/pcmRouter.h
new file mode 100644
index 0000000..9205d08
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcmRouter.h
@@ -0,0 +1,13 @@
+#ifndef _PCM_ROUTER_H
+#define _PCM_ROUTER_H
+
+
+// ----------------------------------------------------------------------------
+//=========================== call from spc_drv.c ============================
+void PcmRouterStart(void);
+void PcmRouterStop(void);
+
+//=============================================================================
+
+#endif //_PCM_ROUTER_H
+
diff --git a/mcu/driver/audio/src/v1/inc/pcmrb.h b/mcu/driver/audio/src/v1/inc/pcmrb.h
new file mode 100644
index 0000000..e4c94d1
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcmrb.h
@@ -0,0 +1,168 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * PCMRB.h
+ *
+ * Project:
+ * --------
+ * Maui_sw
+ *
+ * Description:
+ * ------------
+ * PCMRB utility
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef _PCMRB_DOT_H_
+#define _PCMRB_DOT_H_
+
+/*****************************************************************************
+* C O M P I L E R F L A G S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* E X T E R N A L R E F E R E N C E S
+******************************************************************************
+*/
+#include "l1aud_common_def.h"
+/*****************************************************************************
+* C O N S T A N T S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A T Y P E S
+******************************************************************************
+*/
+typedef struct PcmRingBufferStruct PCMRB;
+struct PcmRingBufferStruct {
+ int16 *buffer;
+ int32 read;
+ int32 write;
+ int32 size;
+};
+
+/*****************************************************************************
+* P U B L I C D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* M A C R O S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A D E C L A R A T I O N S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+bool PCMRB_Init( PCMRB *rb, int16 *buffer, int32 buffer_size );
+int32 PCMRB_GetFreeSpace( PCMRB *rb );
+int32 PCMRB_GetDataCount( PCMRB *rb );
+void PCMRB_Write( PCMRB *dest_rb, int16 *src_buffer, int32 size );
+void PCMRB_Write_from_DSP( PCMRB *dest_rb, volatile uint16 *src_buffer, int32 size );
+void PCMRB_Write2( PCMRB *dest_rb, int16 *src_buffer, int32 size );
+void PCMRB_Read( PCMRB *src_rb, int16 *dest_buffer, int32 size );
+void PCMRB_Read_to_DSP( PCMRB *src_rb, volatile uint16 *dest_buffer, int32 size );
+void PCMRB_Read_to_DSP_Padding( PCMRB *src_rb, volatile uint16 *dest_buffer, int32 size );
+void PCMRB_GetWriteBlock( PCMRB *dest_rb, int16 **write_ptr, int32 *write_cnt );
+void PCMRB_GetReadBlock( PCMRB *src_rb, int16 **read_ptr, int32 *read_cnt );
+void PCMRB_ShiftWritePointer( PCMRB *rb, int32 shamt );
+void PCMRB_ShiftReadPointer( PCMRB *rb, int32 shamt );
+void PCMRB_ShiftReadPointer2( PCMRB *rb, int32 shamt );
+void PCMRB_Mix( PCMRB *dest_rb, PCMRB *src_rb, int32 size );
+
+void pcm_mix_n( int16 *dest, int16 *src, int32 n );
+
+/*****************************************************************************
+* I N L I N E F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+
+#endif // ..._PCMRB_DOT_H_
+
diff --git a/mcu/driver/audio/src/v1/inc/pcmrec.h b/mcu/driver/audio/src/v1/inc/pcmrec.h
new file mode 100644
index 0000000..dca60ab
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/pcmrec.h
@@ -0,0 +1,18 @@
+#ifndef _PCMREC_H_
+#define _PCMREC_H_
+
+typedef enum {
+ PCM_REC_SAMPLE_RATE_IDX_8K = 0,
+ PCM_REC_SAMPLE_RATE_IDX_16K,
+ PCM_REC_SAMPLE_RATE_IDX_32K,
+ PCM_REC_SAMPLE_RATE_IDX_48K,
+
+ PCM_REC_SAMPLE_RATE_IDX_UNDEF = 0xf
+}PCM_REC_SAMPLE_RATE_IDX;
+
+void PCMREC_Start(void (*pcmRec_hdlr)(void), uint8 channelNum, PCM_REC_SAMPLE_RATE_IDX samplingRateIdx);
+void PCMREC_Stop();
+
+void PcmRec_GetMicDataBufs(kal_uint32 *add1, kal_uint16 *len1, kal_uint32 *add2, kal_uint16 *len2);
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/rawpcmrec.h b/mcu/driver/audio/src/v1/inc/rawpcmrec.h
new file mode 100644
index 0000000..cf1c29a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/rawpcmrec.h
@@ -0,0 +1,32 @@
+#ifndef _RAWPCMREC_H_
+#define _RAWPCMREC_H_
+
+#include "pcmrec.h"
+/*typedef enum {
+ PCM_REC_SAMPLE_RATE_IDX_8K = 0,
+ PCM_REC_SAMPLE_RATE_IDX_16K,
+ PCM_REC_SAMPLE_RATE_IDX_32K,
+ PCM_REC_SAMPLE_RATE_IDX_48K,
+
+ PCM_REC_SAMPLE_RATE_IDX_UNDEF = 0xf
+}PCM_REC_SAMPLE_RATE_IDX;*/
+
+typedef struct spcRAWPCMBufInfoStruct{
+ //UL sample rate, please refer PCM_REC_SAMPLE_RATE_IDX
+ uint16 u16ULFreq;
+ //UL length in byte
+ uint16 u16ULLength;
+ //DL sample rate, please refer PCM_REC_SAMPLE_RATE_IDX
+ uint16 u16DLFreq;
+ //DL length in byte
+ uint16 u16DLLength;
+}spcRAWPCMBufInfo, *pspcRAWPCMBufInfo;
+
+void RAWPcmRec_Init();
+void RAWPCMREC_Start(void (*pcmRec_hdlr)(void), kal_uint8 ULChannelNumIdx);
+void RAWPCMREC_Stop();
+
+void RawPcmRec_GetMicDataBufs(kal_uint32 *add1, kal_uint16 *len1, kal_uint32 *add2, kal_uint16 *len2);
+
+#endif //#ifndef _RAWPCMREC_H_
+
diff --git a/mcu/driver/audio/src/v1/inc/sp_c2k.h b/mcu/driver/audio/src/v1/inc/sp_c2k.h
new file mode 100644
index 0000000..772e8a5
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_c2k.h
@@ -0,0 +1,84 @@
+#ifndef __SP_C2K__
+#define __SP_C2K__
+
+// For bringup not use DTS
+//#ifdef MTK_AUDIO_BRINGUP
+ #define C2K_DTS_DISABLE
+//#endif
+
+// For no SAL on integrate stage
+//#define C2K_SAL_DISABLE
+
+// For no Sph Drv on integrate stage
+//#define C2K_SDRV_DISABLE
+
+// For bring up
+//#define C2K_BRING_UP
+
+// For LBK regular timer
+//#define C2K_LBK_TIMER_ENABLE
+
+//#define SALI_DISABLE
+
+//#define C2K_MODEM_DISABLE
+//#define C2K_LBK_U2D
+//#define C2K_LBK_D2U
+
+//#define C2K_SPH_EVRCNW_SUPPORT
+
+#define C2K_COD_RS_1 1
+#define C2K_COD_RS_2 2
+#define C2K_COD_RS_UNDEF 0x29
+
+#define C2K_COD_RS_1_BLANK_LEN_WORD16 0
+#define C2K_COD_RS_1_EIGHTH_LEN_WORD16 1
+#define C2K_COD_RS_1_QUARTER_LEN_WORD16 3
+#define C2K_COD_RS_1_HALF_LEN_WORD16 5
+#define C2K_COD_RS_1_FULL_LEN_WORD16 11
+#define C2K_COD_RS_1_ERASURE_LEN_WORD16 0
+#define C2K_COD_RS_1_FULL_LIKELY_LEN_WORD16 11
+
+#define C2K_COD_RS_2_BLANK_LEN_WORD16 0
+#define C2K_COD_RS_2_EIGHTH_LEN_WORD16 2
+#define C2K_COD_RS_2_QUARTER_LEN_WORD16 4
+#define C2K_COD_RS_2_HALF_LEN_WORD16 8
+#define C2K_COD_RS_2_FULL_LEN_WORD16 17
+#define C2K_COD_RS_2_ERASURE_LEN_WORD16 0
+
+#define C2K_COD_RATE_MAX_LEN_WORD16 17
+
+#define C2K_COD_QCELP8K 0x30
+#define C2K_COD_QCELP13K 0x31
+#define C2K_COD_EVRCA 0x32
+#define C2K_COD_EVRCB 0x33
+#define C2K_COD_EVRCNW_NB 0x34
+#define C2K_COD_EVRCNW_WB 0x35
+#define C2K_COD_UNDEF 0x39
+
+#define C2K_LMD_LBK 1
+#define C2K_CAAL_LBK 2
+
+// SOCM
+#define C2K_SOCM_EVRCA_RATE_REDUC_MIN 0
+#define C2K_SOCM_EVRCA_RATE_REDUC_MAX 4
+#define C2K_SOCM_QCELP13K_RATE_REDUC_MIN 0
+#define C2K_SOCM_QCELP13K_RATE_REDUC_MAX 4
+#define C2K_SOCM_EVRCB_RATE_REDUC_MIN 0
+#define C2K_SOCM_EVRCB_RATE_REDUC_MAX 7
+#define C2K_SOCM_EVRCNW_RATE_REDUC_MIN 0
+#define C2K_SOCM_EVRCNW_RATE_REDUC_MAX 7
+
+#define C2K_SOCM_RATE_REDUC_SHIFT 5
+#define C2K_SOCM_MOBILE_TO_MOBILE_SHIFT 1
+
+// DelR/W/M (ms)
+#define C2K_DELR 8.25
+#define C2K_DELW 3
+#define C2K_DELM 4
+
+#define C2K_DBG_BIT_INIT 0x0
+#define C2K_DBG_BIT_U2D_LOOPBACK 0x1
+#define C2K_DBG_BIT_NO_MODEM 0x2
+
+
+#endif //__SP_C2K__
diff --git a/mcu/driver/audio/src/v1/inc/sp_cc.h b/mcu/driver/audio/src/v1/inc/sp_cc.h
new file mode 100644
index 0000000..01a8e57
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_cc.h
@@ -0,0 +1,39 @@
+#ifndef SP_CC
+#define SP_CC
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "cache_sw.h" //? ask SS, it ought not be exposed from RCU_MEMORY_SIZE
+#include "mmu.h"
+#include "audio_cc.h"
+#include "audio_ringbuf.h"
+#include "cc_irq_public.h"
+#include "sp_drv.h"
+#include "audio_msgid.h"
+#include "drv_sap.h"
+void SP_CC_Init();
+void SP_CC_Event_Handler();
+
+void cc_set_VBI_for_FSM(kal_uint32 state);
+void cc_Standby_Call_Open(kal_uint32 enc_mod);
+void cc_Standby_Call_Close(kal_uint32 dsp_end);
+void cc_2G_Call_Open(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel, kal_uint32 resetType);
+void cc_2G_Call_Close(kal_uint32 dsp_end);
+void cc_3G_Call_Open(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void cc_3G_Call_Close(kal_uint32 dsp_end);
+void cc_4G_Call_Open_temp(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void cc_4G_Call_Close_temp(kal_uint32 dsp_end);
+void cc_4G_G_Codec_Call_Open(kal_uint32 band_mod, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void cc_4G_G_Codec_Call_Close(kal_uint32 dsp_end);
+void cc_4G_EVS_Codec_Call_Open(kal_uint32 codec, uint32 isDTX, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType);
+void cc_4G_EVS_Codec_Call_Close(kal_uint32 dsp_end);
+void cc_C2K_Call_Open(kal_uint32 so, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 resetType);
+void cc_C2K_Call_Close(kal_uint32 dsp_end);
+void cc_L1D_Audio_ChkDspInitDone();
+kal_uint16 cc_L1D_Audio_RestartDSP();
+void cc_L1D_Audio_NoNeedDSP();
+
+
+
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/sp_daca.h b/mcu/driver/audio/src/v1/inc/sp_daca.h
new file mode 100644
index 0000000..f44a523
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_daca.h
@@ -0,0 +1,166 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * pcm4way.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * PCM4WAY/PCM2WAY interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __DACA_H__
+#define __DACA_H__
+#include "l1aud_common_def.h"
+
+
+typedef struct{
+ kal_uint16 aud_daca_id;
+ kal_uint32 state; //identify pcm2way or pcm4way
+ kal_uint32 running;
+ kal_uint32 am_type;
+ kal_uint32 app_type;
+ kal_uint32 frame_size; //to record the band information, please refer to PCMNWAY_BAND_INFO
+
+ kal_uint32 u4DspPcmExMicLen;
+ kal_uint32 u4DspPcmExSpkLen;
+ kal_spinlockid DACASpinLockID;
+ void (*daca_dl_hdlr)(void);
+ void (*daca_ul_hdlr)(void);
+}_DACA_EX_T;
+
+
+//the following macro is bit-wise
+#define DACA_IN_PHONE_CALL 0x0001
+#define DACA_USE_NB 0x0002
+#define DACA_USE_UL 0x0004
+#define DACA_USE_DL 0x0008
+#define DACA_USE_WB 0x0010
+#define DACA_USE_SWB 0x0020
+#define DACA_USE_FB 0x0040
+#define DACA_UNDEFINED 0x8000
+
+typedef enum {
+ DACA_APP_TYPE_IDLE_UL_DL_NB = DACA_USE_NB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_IDLE_UL_NB = DACA_USE_NB + DACA_USE_UL,
+ DACA_APP_TYPE_IDLE_DL_NB = DACA_USE_NB + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_DL_NB = DACA_IN_PHONE_CALL + DACA_USE_NB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_NB = DACA_IN_PHONE_CALL + DACA_USE_NB + DACA_USE_UL,
+ DACA_APP_TYPE_ACTIVE_DL_NB = DACA_IN_PHONE_CALL + DACA_USE_NB + DACA_USE_DL,
+
+ DACA_APP_TYPE_IDLE_UL_DL_WB = DACA_USE_WB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_IDLE_UL_WB = DACA_USE_WB + DACA_USE_UL,
+ DACA_APP_TYPE_IDLE_DL_WB = DACA_USE_WB + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_DL_WB = DACA_IN_PHONE_CALL + DACA_USE_WB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_WB = DACA_IN_PHONE_CALL + DACA_USE_WB + DACA_USE_UL ,
+ DACA_APP_TYPE_ACTIVE_DL_WB = DACA_IN_PHONE_CALL + DACA_USE_WB + DACA_USE_DL,
+
+ DACA_APP_TYPE_IDLE_UL_DL_SWB = DACA_USE_SWB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_IDLE_UL_SWB = DACA_USE_SWB + DACA_USE_UL,
+ DACA_APP_TYPE_IDLE_DL_SWB = DACA_USE_SWB + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_DL_SWB = DACA_IN_PHONE_CALL + DACA_USE_SWB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_SWB = DACA_IN_PHONE_CALL + DACA_USE_SWB + DACA_USE_UL ,
+ DACA_APP_TYPE_ACTIVE_DL_SWB = DACA_IN_PHONE_CALL + DACA_USE_SWB + DACA_USE_DL,
+
+ DACA_APP_TYPE_IDLE_UL_DL_FB = DACA_USE_FB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_IDLE_UL_FB = DACA_USE_FB + DACA_USE_UL,
+ DACA_APP_TYPE_IDLE_DL_FB = DACA_USE_FB + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_DL_FB = DACA_IN_PHONE_CALL + DACA_USE_FB + DACA_USE_UL + DACA_USE_DL,
+ DACA_APP_TYPE_ACTIVE_UL_FB = DACA_IN_PHONE_CALL + DACA_USE_FB + DACA_USE_UL ,
+ DACA_APP_TYPE_ACTIVE_DL_FB = DACA_IN_PHONE_CALL + DACA_USE_FB + DACA_USE_DL,
+
+ DACA_APP_TYPE_UNDEFINE = DACA_UNDEFINED
+}DACA_APP_TYPE;
+
+void DACA_Start(void (*daca_dl_hdlr)(void), void (*daca_ul_hdlr)(void), DACA_APP_TYPE app_type);
+void DACA_Stop(DACA_APP_TYPE app_type);
+uint32 DACA_GetFromSD(uint16 *dl_buf);
+void DACA_PutToSE(const uint16 *ul_data);
+void DACA_FillSE(uint16 value);
+void DACA_Init();
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/sp_drv.h b/mcu/driver/audio/src/v1/inc/sp_drv.h
new file mode 100644
index 0000000..b4487b1
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_drv.h
@@ -0,0 +1,798 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_drv.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * MD speech control interfaces
+ *
+ * Author:
+ * -------
+ *
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef _SP_DRV_H
+#define _SP_DRV_H
+
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "l1sp_el2_struct.h"
+
+// ----------------------------------------------------------------------------
+// defines
+// ----------------------------------------------------------------------------
+
+#define DEFAULT_SPEECH_COMMON_PARA \
+{ \
+ 0, 55997, 31000, 10752, 32769, 0, 0, 0, 0, 0, \
+ 0, 0 \
+}
+
+// ----------------------------------------------------------------------------
+// mute related
+// ----------------------------------------------------------------------------
+
+kal_bool SP_IsSpeakerMute(void);
+
+void SP_MuteUlSource(kal_bool mute);
+void SP_MuteDl_beforePcmMixer(bool mute);
+
+typedef enum { // saving inside l1sp.isUlMute, bit wise record
+ SP_MIC_MUTE_POS_FROM_SPC = 0x1,
+ SP_MIC_MUTE_POS_FROM_MED = 0x2,
+
+ SP_MIC_MUTE_POS_FROM_ALL = 0xFFFF,
+
+}SP_MIC_MUTE_POS;
+void SP_MuteUlFromDiffPos(bool mute, SP_MIC_MUTE_POS pos);
+bool SP_IsMicMute(void);
+void L1SP_SetCodecMuteByAp( bool mute );
+
+// ----------------------------------------------------------------------------
+// codec/network information related
+// ----------------------------------------------------------------------------
+#include "em_audio_public_struct.h"
+void SP_updateEmCodecEvent(void);
+void emCodecTimerOn(void);
+void emCodecTimerOff(void);
+
+
+void l1sp_NetworkStatusNotification(void);
+void l1sp_send_codec_status_notify(uint32 codec); //to L4C
+// ----------------------------------------------------------------------------
+
+void L1SP_SpeechLoopBackEnable(kal_bool fgEnable);
+
+typedef enum {
+ SPH_DEVINFO_NORMAL,
+ SPH_DEVINFO_BT_PCM, /* via Modem PCM hardware */
+ SPH_DEVINFO_BT_CVSD_MSBC, /* via software BT codec */
+ SPH_DEVINFO_BT_CVSD,
+ SPH_DEVINFO_BT_MSBC
+}sp_device_info_t; // same as spc_sph_on_bt_info_t
+
+uint8 SP_GetDevSamplingRate(void);
+sp_device_info_t SP_GetDevInfo(void);
+void SP_SetDevicePath(sp_device_info_t newDev, kal_uint8 voice8kMode);
+
+typedef enum {
+ SPH_EXTDEVINFO_DEFULAT = 0,
+ SPH_EXTDEVINFO_VIBRATION_RECEIVER, // vibration receiver (3-in-1)
+ SPH_EXTDEVINFO_VIBRATION_SPEAKER, // speaker (2-in-1 or 3-in-1)
+ SPH_EXTDEVINFO_SMARTPA_SPEAKER, // speaker with smart-PA which need echo reference path
+ SPH_EXTDEVINFO_SMARTPA_VIBRATION_SPEAKER, // vibration speaker with smart-PA which need echo reference path
+ SPH_EXTDEVINFO_USB_AUDIO, // usb audio device, which needs echo reference path
+ SPH_EXTDEVINFO_EARPHONE, // earphone audio device
+ SPH_EXTDEVINFO_DUALSMARTPA_SPEAKER, // speaker with smart-PA which need echo reference path
+ SPH_EXTDEVINFO_DUALSMARTPA_VIBRATION_SPEAKER, // vibration speaker with smart-PA which need echo reference path
+}sp_ext_dev_info_t;
+
+void SP_SetExtraDevInfo(sp_device_info_t dev, sp_ext_dev_info_t extDevInfo, uint8 smartPA_config, uint16 echoRefDelay, uint8 micDelay);
+sp_ext_dev_info_t SP_GetExtDevInfo(void);
+
+// ----------------------------------------------------------------------------
+// ENHANCEMENT MODE PARAMETERS
+// ----------------------------------------------------------------------------
+#if defined(_SPE_ENH_MD_PARSE_)
+void l1sp_SetWbSpeechPara( kal_uint16 m_para[NUM_MODE_PARAS] );
+// void l1sp_SetSpeechMode( uint8 devMode, uint8 mode, uint16 m_para[NUM_MODE_PARAS] );
+// void l1sp_SetSpeechMode( uint8 devMode, uint8 mode);
+
+
+void l1sp_setAllSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length);
+void l1sp_setAllSpeechFirCoeff_InputOnly(kal_int16 *speech_input_FIR_coeffs, kal_int16 length);
+void l1sp_setAllSpeechFirCoeff_OutputOnly(kal_int16 *speech_output_FIR_coeffs, kal_int16 length);
+void l1sp_setAllSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length);
+void l1sp_setAllWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length);
+void l1sp_setAllWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length);
+void l1sp_setAllWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length);
+void l1sp_setAllWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length);
+void l1sp_setAllSWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length);
+
+void l1sp_setAllWbSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length);
+void l1sp_setAllWbSpeechFirCoeff_InputOnly(kal_int16 *speech_input_FIR_coeffs, kal_int16 length);
+void l1sp_setAllSWbSpeechFirCoeff_InputOnly(kal_int16 *speech_input_FIR_coeffs, kal_int16 length);
+void l1sp_setAllWbSpeechFirCoeff_OutputOnly(kal_int16 *speech_output_FIR_coeffs, kal_int16 length);
+void l1sp_setAllSWbSpeechFirCoeff_OutputOnly(kal_int16 *speech_output_FIR_coeffs, kal_int16 length);
+
+void l1sp_setAllSWbSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length);
+void SP_SetSpeechPara( uint16 sph_m_para[NUM_MODE_PARAS] );
+void SP_SetWbSpeechPara( kal_uint16 m_para[NUM_MODE_PARAS] );
+void SP_SetSWbSpeechPara( kal_uint16 m_para[NUM_MODE_PARAS] );
+
+
+kal_uint16 *Sp_GetSpeechPara(void);
+kal_uint16 *Sp_GetWbSpeechPara(void);
+#endif
+kal_uint16 *Sp_GetCommonSpeechPara(void);
+
+
+
+// ----------------------------------------------------------------------------
+// DSP volume related
+// ----------------------------------------------------------------------------
+void spGain_SetDigitalGain(kal_int16 digitalGainQdB, kal_bool isForceSet);
+void spGain_SetEnhRefDigitalGain(kal_int16 refDigitalGainQdB, kal_bool isForceSet);
+void spGain_SetMicrophoneVolume( kal_int16 mic_volume, kal_bool isForceSet );
+void spGain_Refresh2DSP(void);
+void spGain_Init(void);
+
+
+// ----------------------------------------------------------------------------
+kal_uint16 L1SP_GetAudID(void);
+void L1SP_FreeAudID(kal_uint16 aud_id);
+// ----------------------------------------------------------------------------
+
+int L1SP_GetC2KSO_Codec( void );
+// ----------------------------------------------------------------------------
+// Mute Control
+// ----------------------------------------------------------------------------
+typedef enum{ //bit mask
+ L1SP_FORCEDUNMUTE_ALL = 0xFFFF,
+ L1SP_FORCEDUNMUTE_PCMROUTER = 0x01,
+ L1SP_FORCEDUNMUTE_PCMRECORD = 0x02,
+ L1SP_FORCEDUNMUTE_ACOUSTICLOOPBACK = 0x04,
+ L1SP_FORCEDUNMUTE_RAWPCMRECORD = 0x08,
+}L1SP_FORCEDUNMUTE_BITMASK;
+
+kal_bool SP_is_codec_mute(void);
+void SP_SetForcedUnMuteController(L1SP_FORCEDUNMUTE_BITMASK mask, bool b);
+void sp4g_hisr_ul_g(void *data);
+void sp4g_hisr_dl_g(void *data);
+void L1SP_RampDone(void);
+
+// ----------------------------------------------------------------------------
+// em for voice qualtiy
+// ----------------------------------------------------------------------------
+#include "sal_def.h"
+
+typedef struct{
+ kal_bool isNotify;
+ kal_bool isOn;
+ kal_bool is4gWifi;
+ Sal_DMF_SPH_DL_Info_t dlInfo;
+ Sal_DMF_SPH_UL_Info_t ulInfo;
+ Sal_DMF_ENH_UL_Info_t enhUl;
+} SP_EM_VOICE_QUALITY_INFO;
+
+
+void sp_voiceQualityHisrHdl(void);
+void sp_voiceQualityEventHdl(SP_EM_VOICE_QUALITY_INFO *pEmVQ);
+
+// ----------------------------------------------------------------------------
+// Else
+// ----------------------------------------------------------------------------
+
+#if defined(MT6295M) || defined(__MODEM_ONLY__)
+#define SPH_CHIP_BACK_PHONECALL_USE
+#endif
+
+#if defined(MT6295M) || defined(__MODEM_ONLY__)
+#define SPH_CHIP_BACK_MODE_FIX_TO_NORMAL
+#endif
+
+#if defined(__VOLTE_SUPPORT__)
+typedef struct{
+ //raw information from eMAC
+ uint32 RX_period; //ms
+ uint32 TX_period; //ms
+ uint32 time2nextRX; //ms
+ uint32 time2nextTX; //ms
+ uint32 issueTime; //ms
+ kal_bool is_lch_on;
+}resync_info_t;
+
+typedef struct{
+ LOCAL_PARA_HDR
+ //raw information from eMAC
+ uint32 RX_period; //ms
+ uint32 TX_period; //ms
+ uint32 time2nextRX; //ms
+ uint32 time2nextTX; //ms
+ uint32 issueTime; //ms
+}ilm_resync_info_t;
+
+void sub_SP4G_emac_timing_update(l1sp_emac_resync_info_struct* p_timing_info, module_type module);
+kal_bool SP4G_IsGCodecMode(void);
+
+#endif //#if defined(__VOLTE_SUPPORT__)
+
+typedef struct{
+ LOCAL_PARA_HDR
+ kal_int16 freq1;
+ kal_int16 freq2;
+ kal_int16 duration;
+}ilm_PSR_DL_KT_t;
+
+typedef struct {
+ LOCAL_PARA_HDR
+ L1SP_Tones *pToneList;
+}ilm_PSR_DL_TONE_t;
+
+#if defined(__EVS_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+kal_bool SP4G_IsEVSCodecMode();
+#endif //#if defined(__EVS_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+
+typedef struct {
+ LOCAL_PARA_HDR
+ uint16 rate;
+}ilm_SP_C2K_RATE_NOTI_t;
+
+typedef struct {
+ LOCAL_PARA_HDR
+ uint16 pu2RateReduc_EM;
+}ilm_SP_C2K_RATE_REDUC_NOTI_t;
+
+typedef struct {
+ LOCAL_PARA_HDR
+ L1SP_C2K_Event event;
+ int param;
+}ilm_SP_C2K_EVENT_t;
+
+typedef struct {
+ LOCAL_PARA_HDR
+ L1SP_L4C_Event event;
+ L1SP_L4C_Event_Mode mode;
+}ilm_SP_L4C_SET_EVENT_t;
+
+typedef enum {
+ SP_2G_HANDOVER,
+ SP_2G_TCH,
+ SP_3G_RAB,
+ SP_4G_RAB,
+ SP_2G_AUDIOMANAGER_INFO
+}SP_CHANGERAT_EVENT;
+
+typedef struct {
+ LOCAL_PARA_HDR
+ SP_CHANGERAT_EVENT event; // information from L1Core : mapping AUD_CC_IRQ_T to SP_CHANGERAT_EVENT; information from PCORE : use straightly
+ kal_uint32 param[2];
+}ilm_SP_CHANGERATE_EVENT_t;
+
+typedef enum {
+ SP_3G_SIM_FDD_ACTIVE,
+ SP_3G_SIM_TDD_ACTIVE,
+ SP_3G_SIM_IDLE,
+}SP_3G_SIM;
+
+SP_3G_SIM L1SP_GetSIMStatus();
+
+typedef struct {
+ LOCAL_PARA_HDR
+ uint8 text;
+}ilm_SP_L4C_SET_EGTT_t;
+void SP_Parse_EMI_Info(void);
+kal_uint32* SP_GetSphParamBufAddr();
+kal_uint32 SP_GetSphParamBufSize();
+
+typedef struct {
+ LOCAL_PARA_HDR
+ bool enable;
+}ilm_SPC_SETLOOPBACK_DL_UL_t;
+
+#if defined(__ECALL_SUPPORT__)
+#if defined(__L5_SUPPORT__)
+typedef struct {
+ LOCAL_PARA_HDR
+ L1SP_L5ECALL_Event event;
+ kal_uint8 *data;
+}ilm_SP_L5ECALL_SET_EVENT_t;
+#endif
+#endif
+
+#endif //_SP_DRV_H
diff --git a/mcu/driver/audio/src/v1/inc/sp_dsptone_drv.h b/mcu/driver/audio/src/v1/inc/sp_dsptone_drv.h
new file mode 100644
index 0000000..53164ab
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_dsptone_drv.h
@@ -0,0 +1,8 @@
+void SP_DSPTone_Init(void);
+void SP_DSPTone_ForceEnd(void);
+void SP_DSPTone_DL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration);
+void SP_DSPTone_DL_KT_Stop(void);
+void SP_DSPTone_UL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration);
+void SP_DSPTone_UL_KT_Stop(void);
+
+
diff --git a/mcu/driver/audio/src/v1/inc/sp_enhance.h b/mcu/driver/audio/src/v1/inc/sp_enhance.h
new file mode 100644
index 0000000..d88f151
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_enhance.h
@@ -0,0 +1,65 @@
+
+#ifndef _SP_ENHANCE_H
+#define _SP_ENHANCE_H
+
+#include "l1aud_common_def.h"
+#include "sal_def.h"
+
+
+//EMI Header Layout (uint:word)
+#define EMI_NEED_3K_0 1536 // EMI need 3k=0,13K=data
+#define EMI_GUARD_PATTERN 16
+#define MD_PRIVATE 4
+
+
+//EMI MD default par
+#define EMI_MD_DEFAULT_LEN 16384 //16K
+#define EMI_MD_DEFAULT_OFFSET 0
+#define EMI_SPE_PAR_OFFSET 16384
+#define EMI_MD_COMMON_PAR_OFFSET 9
+#define EMI_MD_DBG_PAR_OFFSET 22
+
+
+
+
+
+void L1SP_EnableSpeechEnhancement( bool enable );
+void l1sp_SetParEMIInfo(uint32 offset,uint32 len);
+void SPE_LoadCommonPara( uint16 c_para[NUM_COMMON_PARAS]);
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+bool spe_isSpeFweOn(void);
+void SPE_LoadSpeechPara( uint16 c_para[NUM_COMMON_PARAS], uint16 m_para[NUM_MODE_PARAS],
+ uint16 m_paraWb[NUM_MODE_PARAS],uint16 m_paraSWb[NUM_MODE_PARAS]);
+void spe_setHacModeNeeded(bool isNeed);
+//void SPE_MagiClarityData(short MagiClarityData[32]);
+#endif
+
+// ----------------------------------------------------------------------------
+// DSP filter/function related parameter/coefficient setting
+// ----------------------------------------------------------------------------
+#if defined(_SPE_ENH_MD_PARSE_)
+void spe_setMagiCon(void);
+void spe_DisableMagiCon(void);
+//void SPE_SetActiveEchoRefInfo(uint16 sphMode);
+//void SPE_SetEchoRefInfo(bool isEchoRefOn, uint16 echoRefMicIndex, uint16 delayAndSwitch4Dsp, uint16 sphMode);
+#endif
+
+
+void spe_setNotchFilterParam(int16 *param, bool is2In1Spk);
+void L1SP_EnhancementCtrlSupport( uint16 value );
+void SetSpeechEnhancement(bool ec);
+void SPE_WaitSPEDynReady(void) ;
+void l1sp_setCtmSpeStatus(bool s);
+bool l1sp_getCtmSpeStatus();
+
+typedef enum{
+ SpeechEnh_All = 0, //default path : UL+DL
+ SpeechEnh_UL,
+ SpeechEnh_DL,
+}SpeechEnh_path;
+void SetSPEnhancePath(uint8 path);
+
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps.h b/mcu/driver/audio/src/v1/inc/sp_ps.h
new file mode 100644
index 0000000..c218c25
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps.h
@@ -0,0 +1,247 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching speech interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 08 24 2020 thomas.chen
+ * [MOLY00561737] ³q??µ??¤ÀªR
+ *
+ * .
+ *
+ * 05 26 2020 yf.wang
+ * [MOLY00527586] [MP3 Excluded][MT6885][Petrus][TMO-US][MP3][WWFT][Seattle][5G4G][NSN][MDST][SWIFT][Assert] file:mcu/driver/audio/src/v1/sp_ps_codec_evs.c line:752 p1:0x00000000 p2:0x00000000 p3:0x00000000
+ * Add UL delay threshold for LTECSR.
+ *
+ * 12 04 2019 thomas.chen
+ * [MOLY00457654] AAM for 4/5G L2 Switching
+ *
+ * .
+ *
+ * 09 25 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ * .
+ *
+ * 07 02 2019 sheila.chen
+ * [MOLY00418158] �iP90�j DMF ?��?�q�I?�ݨD
+ * DMF: event for speech discontinued modification
+ *
+ * 06 26 2019 sheila.chen
+ * [MOLY00408630] �iP90�j DMF ?��?�q�I?�ݨD
+ *
+ * [MOLY00413193] �iP90�j DMF ?��?�q�I?�ݨD
+ *
+ * DMF ?��?�q�I?�ݨD patch back
+ *
+ * 05 22 2019 sheila.chen
+ * [MOLY00407961] �iP90�j DMF ?��?�q�I?�ݨD
+ * speech quality event notify.
+ *
+ * 06 12 2018 fu-shing.ju
+ * [MOLY00328903] [EIGER] Refactor PS Call code for LTE and NR.
+ *
+ * Fix build warring.
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef SP_PS_CALL_H
+#define SP_PS_CALL_H
+
+//Code Option
+//#define TK6291_FAKE_COMPILE
+//#define __USE_EVS_IO_REPLACE_AWB__
+#define __SP4G_UL_RESYNC__
+#define UL_HARD_REAL_TIME_DEMAND
+#define __OP_IS_AT_AND_T__
+
+#ifdef __PRODUCTION_RELEASE__
+ #define SP_PS_CALL_DBG_ASSERT(exp)
+#else
+/* under construction !*/
+#endif
+
+
+//Declare constant
+#define INIT_CODEC (0x3)
+
+#define SPPS_RAB_ID_MAX (6)
+
+#define AMR_SID_FRAME 8
+#define AMR_NO_DATA 15
+
+#define AWB_SID_FRAME 9
+#define WB_AMR_SID_FRAME 25
+
+#define UL_MAX_DATA_SIZE 62 // frame_type, UL : len / DL : FQI_flag , DATA(23.85=>60)
+#define DL_MAX_DATA_SIZE 66 // frame_type, UL : len / DL : FQI_flag , CFN(4 bytes), DATA(23.85=>60)
+#define MAX_DSP_FRAME_LEN 30
+
+#define MAXIMUM_UL_DELAY 15 // CSR define for debug
+#define START_SHRINK_UL_DELAY 10 // L1Audio shrink UL delay from 40ms to 20ms
+#define UL_DELAY_THRESHOLD 3 // CSR define for UL delay threshold
+
+#define MAX_4G_DL_BUFF_SIZE (2)
+#define MAX_4G_UL_BUFF_SIZE (2)
+
+#define DL_4G_THRESHOLD (1)
+#define UL_4G_THRESHOLD (2)
+
+#define HARD_REAL_TIME_UL_BUFFER_NUM 1 // could not revise
+#define RAT_4G_UL_BUFFER_NUM MAX_4G_UL_BUFF_SIZE // could not revise
+
+#define RAT_4G_DL_BUFFER_NUM MAX_4G_DL_BUFF_SIZE // do not suggest to revise
+#define RAT_4G_DL_BUFFER_NUM_BEFORE_RESYNC MAX_4G_DL_BUFF_SIZE // do not suggest to revise
+
+#define MAX_UL_BUFFER_NUM RAT_4G_UL_BUFFER_NUM
+#define MAX_DL_BUFFER_NUM RAT_4G_DL_BUFFER_NUM_BEFORE_RESYNC
+
+#define __SP4G_DL_BUFFER_BEFORE_PLAY__
+/* Enable more buffering before put frame to DSP to keep start of speech smooth.
+ If not defined this compile option, it can reduce delay but maybe can't cover the initial discontinous.
+*/
+
+// here should be careful for this will limit MAX_DL_BUFFER_NUM to 1 << DL_BUF_INDEX_BIT_NUM
+// and MAX_UL_BUFFER_NUM to 1 << UL_BUF_INDEX_BIT_NUM
+#define DL_BUF_INDEX_BIT_NUM 5
+#define UL_BUF_INDEX_BIT_NUM (8 - DL_BUF_INDEX_BIT_NUM)
+
+#define SP4G324M_DL_EXTRA_LEN 5//frameType(1), len(1), l1_frame : recieve(3)
+#define SP4G_DL_EXTRA_LEN 6//frameType(1), FQI_flag(1), CFN(4)(unit:byte)
+
+//AMRWB 23.85 classB 405 bits=>51 bytes
+#define MAX_BYTES_IN_SINGLE_SUBFLOW ((405 + 7)>>3)
+#define _IGNORE_TYPE_ERROR_ // for 4G324M since the CRC is weaker, it's possible wrong pattern.
+ // so ignore it instead of assert.
+
+#ifdef __OP_IS_AT_AND_T__
+#define SILENCE_DETECTION_COUNT_NUMBER (25)
+#define SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER (SILENCE_DETECTION_COUNT_NUMBER+1)
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+#if defined(__SP4G_UL_RESYNC__)
+typedef enum {
+ SP_PSCALL_EMAC=0,
+ SP_PSCALL_NMAC,
+ SP_PSCALL_NONE=0xFF,
+}SP_PSCALL_L2_MODE;
+#endif
+
+typedef struct
+{
+ uint16 ul_dsp_buffer[MAX_DSP_FRAME_LEN];
+ uint16 dl_dsp_buffer[MAX_DSP_FRAME_LEN];
+ uint8 dl_buffer[MAX_DL_BUFFER_NUM][DL_MAX_DATA_SIZE];
+ /*0: CFN, 1:RSSI|RSCP|ECIO|HHO_SHO ,2:crc_result ,3:s_value[0], 4:tpc_SIR_lta, 5:dpdch_SIR_lta, 6:TFCI_max_corr */
+ uint32 L1_Info[4][7];
+
+#if defined(__SP4G_UL_RESYNC__)
+ uint32 time[2][3]; //EMAC -- >unit:ms 0: MAC , 1: under dl_hisr, ready for VBIReset, 2: ul_hisr timing
+ //NMAC -- >unit:ms 0: MAC , 1: under dl_hisr, ready for VBIReset, 2: ul_hisr timing
+ bool request_resync;
+ int32 time2nextSR[2]; //unit: ms
+ int32 time2nextDRX[2]; //unit: ms
+ int32 time2nextULHISR[2]; //unit: ms
+ int32 time2nextDLHISR[2]; //unit: ms
+ SP_PSCALL_L2_MODE sph_l2_mode;
+#endif
+
+ kal_uint16 margin_AAM_ul, margin_AAM_dl;
+
+ uint8 ul_buffer[MAX_UL_BUFFER_NUM][UL_MAX_DATA_SIZE];// prevent sp4g_hisr , CSR race condition
+ uint8 ul_write_idx;
+ uint8 ul_read_idx;
+ uint8 ul_count;
+ bool is_getting_ul_data;
+ uint8 ul_delay;
+ uint8 dl_delay;
+ uint8 dl_count;
+ uint8 dl_write_idx;
+ uint8 dl_read_idx;
+ uint8 ul_codec_mode;
+ uint8 ul_report;
+ uint8 dl_report;
+ uint8 pre_ul_report;
+ uint8 pre_dl_report;
+ bool ul_waiting; // 1-message-1-get policy
+ bool dl_waiting; // 1-message-1-get policy
+ bool ul_refresh; // detect change codec_mode
+ bool ul_intrarat; //if DSP SE interrupt raise at next beginning of next SE, ignore first SE.
+ uint8 l1_info_idx;
+
+ uint8 sp4g_mode;
+ uint8 ul_buffer_size;
+ uint8 dl_buffer_size;
+ uint8 dtx_state; //enter dtx mode
+ uint8 dtx_force; //occured that force AMR frame
+ uint8 dl_subflow[MAX_BYTES_IN_SINGLE_SUBFLOW];
+}SPPS_Struct_t;
+
+typedef enum{
+ PS_SRST_TYPE_CALLON = 0,
+ PS_SRST_TYPE_HO_WITHOUT_VBIEND,
+ PS_SRST_TYPE_UNSYNC,
+ PS_SRST_TYPE_DEV,
+ PS_SRST_TYPE_HO_WITH_VBIEND,
+}PS_RESET_TYPE_t;
+
+void PSR_SP4G_Callback( SP4G_Event event, void *data);
+SP_PSCALL_L2_MODE SP4G_GetL2Mode();
+#endif //#ifndef SP_PS_CALL_H
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_aam.h b/mcu/driver/audio/src/v1/inc/sp_ps_aam.h
new file mode 100644
index 0000000..82eec1f
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_aam.h
@@ -0,0 +1,142 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_aam.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AAM
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 09 25 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ *
+ * .
+ *
+ * 09 24 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ * .
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef SP_PS_AAM_H
+#define SP_PS_AAM_H
+
+#include "sp_ps.h"
+#include "us_timer.h"
+
+//#if defined(__SP4G_UL_RESYNC__)
+#define ust_get_duration_true(prev, cur) (((cur) >= (prev))? (((cur) - (prev))): ((USCNT_WRAP - (prev) + (cur))))
+#undef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+#define DSP_SD_MIPS (5) //ms
+//#define DSP_SE_MIPS (14-9) //ms
+#define DSP_SE_MIPS (20) //ms
+#define DSP_PERIOD (20) //ms
+
+#define DRIFT_DSP2MCU_RESET (2) //unit ms :allow the timing of DSP interrupt deviated from time2nextULHISR is with DRIFT_DSP2MCU_US ms.
+#define DRIFT_DSP2MCU_DSP_FINE_TUNE (1) //unit ms :allow the timing of DSP interrupt deviated from time2nextULHISR is with DRIFT_DSP2MCU_US ms.
+#define DIFF_TX_RX_ALIGN (2)
+
+#define MARGIN_CORESONIC_INIT_TIME (3) //unit ms :The length of time of transferring data from PSR to EMAC ,TO-DO, by reception of EMAC, we can adapt this value instead of a fixed value
+#define MARGIN_PSR2MAC (2) //unit ms :The length of time of transferring data from PSR to EMAC ,TO-DO, by reception of EMAC, we can adapt this value instead of a fixed value
+//#endif //#if defined(__SP4G_UL_RESYNC__)
+
+
+//#ifdef __OP_IS_AT_AND_T__
+typedef struct {
+ int UL_count;
+ int DL_count;
+ int UL_write;
+ int DL_write;
+ int UL_frame_type[SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER];
+ int DL_frame_type[SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER];
+ int first_EMAC_info;
+}Silence_Detection_t;
+//#endif //#ifdef __OP_IS_AT_AND_T__
+
+
+typedef enum{
+ SP_PS_AAM_STATE_NONE,
+ SP_PS_AAM_STATE_LTE_EMAC_ON,
+ SP_PS_AAM_STATE_LTE_EMAC_OFF,
+ SP_PS_AAM_STATE_LTE_RESYNC,
+ SP_PS_AAM_STATE_NR_EMAC_ON,
+ SP_PS_AAM_STATE_NR_EMAC_OFF,
+ SP_PS_AAM_STATE_NR_RESYNC,
+} SP_PS_AAM_STATE;
+
+
+void sp_ps_aam_init(void);
+void sp_ps_aam_speech_init(void);
+void sp_ps_aam_speech_init_SilenceDetection(void);
+void sp_ps_aam_GetSyncDelayRW(kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us);
+void sp_ps_aam_execute(SP_PS_AAM_STATE aam_state);
+SP_PS_AAM_STATE sp_ps_aam_check_status(void);
+
+void Silence_Detection_reset_count(void);
+void Silence_Detection_set_ULFrameType(int val);
+void Silence_Detection_set_DLFrameType(int val);
+
+void sp_ps_AAM_hisr(void *data);
+
+void sp_ps_smr_resync_procedure_done(void);
+#endif //#ifndef SP_PS_AAM_H
+
+
+
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_aamp.h b/mcu/driver/audio/src/v1/inc/sp_ps_aamp.h
new file mode 100644
index 0000000..d00df31
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_aamp.h
@@ -0,0 +1,77 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_aamp.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AAM Plus
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef __SP_PS_AAMP_H__
+#define __SP_PS_AAMP_H__
+
+#define __SP_PS_AAM_PLUS__
+
+void sp_ps_AAMPlus_enable(void);
+void sp_ps_AAMPlus_disable(void);
+void sp_ps_AAMPlus_notify_EMAC(void *data);
+
+#endif //__SP_PS_AAMP_H__
+
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_codec_amr.h b/mcu/driver/audio/src/v1/inc/sp_ps_codec_amr.h
new file mode 100644
index 0000000..a153d99
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_codec_amr.h
@@ -0,0 +1,105 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_amr.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AMR speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 07 30 2018 fu-shing.ju
+ * [MOLY00342603] JBM2.0 Timesacling phase - LR13.R0.MP
+ * JBM 2.0 - Speech Driver.
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef SP_PS_CALL_CODEC_AMR_H
+#define SP_PS_CALL_CODEC_AMR_H
+
+#include "sp_ps.h"
+#include "amr_table.h"
+
+
+//#define GetFrameType2DspMode(ftype) (AmrFrameType2DspMode_spps[(ftype)])
+#define GetDspMode2FrameType(mode) (((0x20 <= (mode)) && ((mode) <= 0x28)) ? (WB_DspMode2AmrFrameType_spps[(mode)-0x20]) : \
+ (((0x03 <= (mode)) && ((mode) <= 0x0A)) ? (NB_DspMode2AmrFrameType_spps[(mode)-0x03]) : (-1)))
+
+#define GetDspModeLen(mode) (((0x20 <= (mode)) && ((mode) <= 0x28)) ? (WB_DspModeLen_spps[(mode)-0x20]) : \
+ (((0x03 <= (mode)) && ((mode) <= 0x0A)) ? (NB_DspModeLen_spps[(mode)-0x03]) : (0x00)))
+
+#define GetRab2DspMapping(ftype) (((0x10 <= (ftype)) && ((ftype) <= 0x18)) ? (tblAMR_WBOrder[(ftype) - 0x10]) : \
+ (((0x00 <= (ftype)) && ((ftype) <= 0x07)) ? (tblAMROrder[(ftype)-0x00]) : (0)))
+
+
+
+em_speech_info_SpeechCodecType convert_SP4G_CODEC_AMR_AMRWB_to_SPH_CODEC(SP4G_Codec frame_type);
+uint16 sp_ps_codec_amr_Get_RAB_subflow_spps(int index1, int index2);
+kal_uint16 sp_ps_codec_amr_GetCodecBitLength(SP4G_Codec codec);
+uint8 sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(int index);
+void sp_ps_codec_amr_reset_internal(void);
+void sp_ps_codec_amr_hisr_ul_amr(void *data);
+void sp_ps_codec_amr_hisr_dl_amr(void *data);
+void sp_ps_codec_amr_UL_GetSpeechFrame(kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len);
+void sp_ps_codec_amr_DL_PutSpeechFrame(kal_uint32 CFN, SP4G_PSR_Codec codec, SP4G_Codec frame_type, kal_uint8 *encodebits, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info);
+
+
+
+
+
+#endif //#ifndef SP_PS_CALL_CODEC_AMR_H
+
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_codec_evs.h b/mcu/driver/audio/src/v1/inc/sp_ps_codec_evs.h
new file mode 100644
index 0000000..5082f3d
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_codec_evs.h
@@ -0,0 +1,153 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_evs.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching EVS speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 09 25 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ *
+ * .
+ *
+ * 09 24 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ * .
+ *
+ * 07 30 2018 fu-shing.ju
+ * [MOLY00342603] JBM2.0 Timesacling phase - LR13.R0.MP
+ * JBM 2.0 - Speech Driver.
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef SP_PS_CALL_CODEC_EVS_H
+#define SP_PS_CALL_CODEC_EVS_H
+
+#include "sp_ps.h"
+
+
+//#if defined(__EVS_CODEC_SUPPORT__)
+#include "vm.h"
+#include "pcmrb.h"
+#include "streamrb.h"
+//#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+
+#define DSP_EVS_SD_MIPS (5)
+#define DSP_EVS_SE_MIPS (20)
+
+
+//fsju, should remove
+#define EVS_CAPABILITY_BW (SP4G_CODEC_EVS_32K)
+#define EVS_PCM_BW (SP4G_CODEC_EVS_32K)
+
+typedef struct {
+ int magicid;
+ int codec;
+ int byte_len;
+ int bit_len;
+}EVS_frame_header_t;
+
+
+//sample_number(20ms at 48k) * 2byte_per_sample
+#define EVS_CODEC_PCM_BYTE_SIZE (960*2)
+//EVS Primary mode 128k: 320byte
+#define EVS_CODEC_FRAME_BYTE_SIZE (2560>>3)
+#define EVS_CODEC_PCM_BUFFER_NUM (8)
+#define EVS_CODEC_FRAME_BUFFER_NUM (8)
+//ring buffer will waste 1 element, so add dummy 2 byte(1 pcm element is 2 byte)
+#define EVS_CODEC_PCM_RB_BYTE_SIZE (EVS_CODEC_PCM_BYTE_SIZE*EVS_CODEC_PCM_BUFFER_NUM+2)
+//ring buffer will waste 1 element, so add dummy 1 byte(1 HB element is 1 byte)
+#define EVS_CODEC_FRAME_RB_BYTE_SIZE ((EVS_CODEC_FRAME_BYTE_SIZE+sizeof(EVS_frame_header_t))*EVS_CODEC_FRAME_BUFFER_NUM+1)
+
+typedef enum{
+ ENUM_EVS_NOTIFY_LTECSR_MSG_ERROR,
+ ENUM_EVS_NOTIFY_LTECSR_MSG_DATA,
+ ENUM_EVS_NOTIFY_LTECSR_MSG_MUTE,
+ ENUM_EVS_NOTIFY_LTECSR_MSG_NON,
+}enum_EVS_NOTIFY_LTECSR_MSG;
+
+
+
+
+bool sp_ps_codec_evs_is_EVS_codec(uint8 codec);
+kal_bool convert_AWB_to_EVSIOEnum(SP4G_Codec input_speech_codec, SP4G_Codec *poutput_SP4G_Codec);
+kal_bool convert_EVSIO_to_AWBEnum(SP4G_Codec input_speech_codec, SP4G_Codec *poutput_SP4G_Codec);
+void sp_ps_codec_evs_SetEVSEncCAPara(EVS_ENC_CA_PARAMETER *pEVS_CA_Par);
+void sp_ps_codec_evs_SetEVSDecCAPara(EVS_DEC_CA_PARAMETER *pEVS_CA_Par);
+SP4G_CODEC_EVS_AWB_SID_TYPE EVS_decoder_get_SID_type(void);
+void sp_ps_codec_evs_hisr_ul_EVS(void *data);
+void sp_ps_codec_evs_hisr_dl_EVS(void *data);
+int sp_ps_codec_evs_UL_GetSpeechFrame(SP4G_Codec *frame_type, uint8 *encodebits, kal_int32 *bitlen);
+void sp_ps_codec_evs_DL_PutSpeechFrame(kal_uint32 CFN, SP4G_Codec frame_type, kal_uint8 *encodebits, EVS_DEC_CA_PARAMETER *pEVS_Dec_CA_Par, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info);
+void sp_ps_codec_evs_speech_init(void);
+void sp_ps_codec_evs_init(void);
+kal_uint16 sp_ps_codec_evs_GetCodecBitLength(SP4G_Codec codec);
+uint16 sp_ps_codec_evs_Get_EVS_AWB_RAB_subflow(int index1, int index2);
+void sp_ps_codec_evs_reset_internal(void);
+void sp_ps_codec_evs_set_network_bw(SP4G_Codec codec);
+void sp_ps_codec_evs_CallOpenSetPar(void);
+
+
+//void EVS_encoder_prepare_parameter(EVS_ENCODER_PARAMETER *pEVS_Enc_Par);
+//void EVS_decoder_prepare_parameter(EVS_DECODER_PARAMETER *pEVS_Decoder_Par, kal_int32 bitlen, kal_int32 BFI);
+
+
+#endif //#ifndef SP_PS_CALL_CODEC_EVS_H
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_codec_g.h b/mcu/driver/audio/src/v1/inc/sp_ps_codec_g.h
new file mode 100644
index 0000000..bb15370
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_codec_g.h
@@ -0,0 +1,150 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_g.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching G speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 05 14 2020 yf.wang
+ * [MOLY00523036] [MT6873][Margaux][Q0][R3][MP5][SQC][Elisa][WW FT][Finland][NSA][IMS][TCID: V-CC-065] Sometimes audios missing when calling to Customer Service
+ *
+ * G-Series Codec add DL hisr handle to notify data for LTECSR
+ *
+ * 05 13 2020 yf.wang
+ * [MOLY00523036] [MT6873][Margaux][Q0][R3][MP5][SQC][Elisa][WW FT][Finland][NSA][IMS][TCID: V-CC-065] Sometimes audios missing when calling to Customer Service
+ * G-Series Codec add DL hisr handle to notify data for LTECSR
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef SP_PS_CALL_CODEC_G_H
+#define SP_PS_CALL_CODEC_G_H
+
+#include "sp_ps.h"
+
+//#if defined(__VOLTE_SUPPORT__)
+#include "vm.h"
+//#endif //#if defined(__VOLTE_SUPPORT__)
+
+//#if defined(__G_CODEC_SUPPORT__)
+#include "pcmrb.h"
+#include "streamrb.h"
+#include "g_series_union.h"
+
+//10frame * sample_number(20ms at 8k) * 2byte_per_sample
+#define G_SERIAL_CODEC_PCM_RB_BYTE_SIZE (10*160*2)
+//2048byte
+#define G_SERIAL_CODEC_STREAM_RB_BYTE_SIZE (2048)
+
+
+typedef struct GSERIES_MANAGER{
+ SP4G_Codec enc_codec;
+ //encode
+ void *enc_hdl;
+ void *enc_tmp_buf;
+ void *enc_init_buf;
+
+ int enc_pcm_size;
+ int enc_bs_size;
+
+ void *enc_init_param;
+ void *enc_rtime_param;
+
+ SP4G_Codec dec_codec;
+ //decode
+ void *dec_hdl;
+ void *dec_tmp_buf;
+ void *dec_init_buf;
+
+ int dec_pcm_size;
+ int dec_bs_size;
+
+ void *dec_init_param;
+ void *dec_rtime_param;
+}g_series_mgr_t;
+
+typedef struct {
+ int magicid;
+ int codec;
+ int len;
+}frame_header_t;
+
+
+
+
+bool sp_ps_codec_g_is_g_codec(uint8 codec);
+uint16 sp_ps_codec_g_get_g_dl_id(void);
+uint16 sp_ps_codec_g_get_g_ul_id(void);
+void sp_ps_codec_g_Encode_Init(SP4G_Codec codec_);
+void sp_ps_codec_g_Decode_Init(SP4G_Codec codec_);
+void sp_ps_codec_g_speech_init(void);
+void sp_ps_codec_g_close(void);
+void sp_ps_codec_g_reset_internal(void);
+void sp_ps_codec_g_Set_G711Parameters(kal_int32 law, kal_int32 dec_init_CNG_enable);
+int sp_ps_codec_g_GetFrame(int8* c, int8* len, uint8* tmp_buf);
+void sp_ps_codec_g_PutFrame(int c, int encoded_len, uint8* encoded_bits);
+void sp_ps_codec_g_hisr_ul_g(void *data);
+void sp_ps_codec_g_hisr_dl_g(void *data);
+int sp_ps_codec_g_UL_GSeries_IsMoreData(void);
+
+
+
+
+
+#endif //#ifndef SP_PS_CALL_CODEC_G_H
diff --git a/mcu/driver/audio/src/v1/inc/sp_ps_dsp_opt.h b/mcu/driver/audio/src/v1/inc/sp_ps_dsp_opt.h
new file mode 100644
index 0000000..e690481
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/sp_ps_dsp_opt.h
@@ -0,0 +1,88 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_dsp_opt.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching speech DSP related features
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 07 02 2018 fu-shing.ju
+ * [MOLY00336128] Gen95 dudu detection
+ *
+ * Gen95 dudu detection
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#ifndef __SP_PS_DSP_OPT__
+#define __SP_PS_DSP_OPT__
+
+
+//#define __SP_4G_OPT_TONE_DETECTION__
+#define __SP_4G_OPT_TONE_DETECTION_EXECUTED_IN_DSP__
+
+
+uint16 sp_ps_dsp_opt_ToneDeteGetAudID(void);
+void sp_ps_dsp_opt_ToneDeteInit(void);
+void sp_ps_dsp_opt_ToneDeteClose(void);
+void sp_ps_dsp_opt_ToneDeteTaskInit(void);
+void sp_ps_dsp_opt_ToneDeteExec();
+int32 sp_ps_dsp_opt_ToneDeteGetResult(void);
+
+
+#endif //__SP_PS_DSP_OPT__
diff --git a/mcu/driver/audio/src/v1/inc/spc_drv.h b/mcu/driver/audio/src/v1/inc/spc_drv.h
new file mode 100644
index 0000000..d69663f
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/spc_drv.h
@@ -0,0 +1,379 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * spc_drv.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * MD speech control interfaces
+ *
+ * Author:
+ * -------
+ *
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef _SPC_DRV_H
+#define _SPC_DRV_H
+
+#include "sp_drv.h"
+#include "audio_enum.h"
+
+
+typedef struct spcBufInfoStruct
+{
+ uint16 syncWord;
+ uint16 type;
+ uint16 length;
+} spcBufInfo;
+
+typedef struct spcExtendedBufInfoStruct
+{
+ uint16 syncWord;
+ uint16 type;
+ uint16 length;
+ uint16 curIdx;
+ uint16 totalIdx;
+} spcExtendedBufInfo;
+
+// ----------------------------------------------------------------------------
+// Datacard
+// ----------------------------------------------------------------------------
+void spc_daca_sendDlData(void);
+void spc_daca_requestUlData(void);
+
+// ----------------------------------------------------------------------------
+// PCMNWAY
+// ----------------------------------------------------------------------------
+#if defined(__ENABLE_SPEECH_DVT__)
+void spc_pcmNWay_sendUlData(uint16 bufLen);
+void spc_pcmNWay_requestDlData(uint16 bufLen);
+#else // defined(__ENABLE_SPEECH_DVT__)
+void spc_pcmNWay_sendUlData(void);
+void spc_pcmNWay_requestDlData(void);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+// ----------------------------------------------------------------------------
+// Background Sound
+// ----------------------------------------------------------------------------
+void spc_bgSnd_requestData(void);
+void spc_BgSndClose(void);
+
+// ----------------------------------------------------------------------------
+// Recording
+// ----------------------------------------------------------------------------
+// void spc_record_sendPcmData(void); // removed after 93md
+void spc_record_sendVmData(void);
+void spc_record_sendRAWPcmData(void);
+
+// ----------------------------------------------------------------------------
+// Ramp
+// ----------------------------------------------------------------------------
+//
+void spc_gain_sendRampDone(void);
+
+// ----------------------------------------------------------------------------
+// CTM
+// ----------------------------------------------------------------------------
+void spc_ctm_sendDumpDebugData(void);
+
+// ----------------------------------------------------------------------------
+// ECALL
+// ----------------------------------------------------------------------------
+#if defined(__ECALL_SUPPORT__)
+
+typedef enum{
+ SPC_ECALL_DISABLE = 0,
+ SPC_ECALL_SDT_ONLY,
+ SPC_ECALL_ENABLE,
+ SPC_ECALL_MAX = 3 // due to spcEmInit is unit16, so only 16 em data message can existing.
+} SPC_ECALL_STATUS;
+void spc_eCall_IVS_Open(void);
+void spc_eCall_IVS_Close(void);
+void spc_eCall_PSAP_Open(void);
+void spc_eCall_PSAP_Close(void);
+void spc_eCall_SDT_Open(void);
+void spc_eCall_SDT_Close(void);
+void spc_eCall_Msd_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom);
+void spc_eCall_TX_CTRL_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom);
+void spc_eCall_RX_CTRL_Data(uint16 header);
+void spc_eCall_Handshake_Info_Notify (uint16 header,uint32 data);
+void spc_Set_Ecall_Lib_Status(uint8 status);
+uint8 spc_Get_Ecall_Lib_Status(void);
+#if defined(__L5_SUPPORT__)
+ void spc_L5ECALL_Status_Info_Callback(kal_uint16 status, kal_uint32 data);
+#endif
+
+#endif
+
+void spc_gain_DlMuteSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_UlMuteSet(kal_bool on, kal_bool byPassCheck);
+
+// ----------------------------------------------------------------------------
+// MIXER
+// ----------------------------------------------------------------------------
+void spc_pcmMixer3_requestUlData(void);
+// ----------------------------------------------------------------------------
+// MIXER
+// ----------------------------------------------------------------------------
+void spc_pcmMixer_requestDlData(void);
+
+
+// ----------------------------------------------------------------------------
+// AUDL running functions Related
+// ----------------------------------------------------------------------------
+void Spc_Init(void);
+void spc_A2M_MsgHandler(kal_uint32 ccciMsg, kal_uint32 ccciResv, SPC_MSG_FROM_T comeFrom);
+#if defined(_SPE_ENH_MD_PARSE_)
+uint16 spc_ReceiveDynamicParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom);
+#else
+void spc_ReceiveEMIParInfo(const kal_uint32 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom);
+#endif
+void spc_notify_network_status(uint32 codec);
+void spc_record_sendRawPcmData(void);
+void spc_setAcLoopbackState(bool b);
+bool spc_isAcLoopback();
+// void Spc_SetSpeechEnhMode_Adaptation( uint8 mode );
+void spc_dev_LoopbackPoint_DVT(kal_uint16 point);
+void spc_CtmClose(void);
+void spc_RttConfig(uint16 type);
+void spc_sendRampDoneAck(uint16 ramp_point);
+kal_uint16 spc_getCtmMode();
+void spc_C2KCtmStart(kal_uint16 mode);
+kal_bool spc_isPCM();
+#endif // _SPC_DRV_H
diff --git a/mcu/driver/audio/src/v1/inc/spc_io.h b/mcu/driver/audio/src/v1/inc/spc_io.h
new file mode 100644
index 0000000..d291eb3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/spc_io.h
@@ -0,0 +1,432 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * spc_io.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * IO interface between AP and MD speech driver, and AUDL basic function structure
+ *
+ * Author:
+ * -------
+ *
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef _SPC_IO_H_
+#define _SPC_IO_H_
+
+#include "audio_enum.h"
+
+
+typedef enum {
+
+ SPCIO_MSG_FROM_SPC_SPH_DL_DIGIT_VOLUME_ACK = 0x00,
+ SPCIO_MSG_FROM_SPC_SPH_UL_DIGIT_VOLUME_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_ACK,
+ SPCIO_MSG_FROM_SPC_SIDETONE_VOLUME_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_DL_ENH_REF_DIGIT_VOLUME_ACK,
+ SPCIO_MSG_FROM_SPC_SIDETONE_CONFIG_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ENH_RESULT_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_SOURCE_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_CODEC_ACK,
+ SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_DYNAMIC_ACK,
+
+ SPCIO_MSG_FROM_SPC_SPH_ON_ACK = 0x20,
+ SPCIO_MSG_FROM_SPC_SPH_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_SET_SPH_MODE_ACK,
+ SPCIO_MSG_FROM_SPC_CTRL_SPH_ENH_ACK,
+ SPCIO_MSG_FROM_SPC_CONFIG_SPH_ENH_ACK,
+ SPCIO_MSG_FROM_SPC_SET_ACOUSTIC_LOOPBACK_ACK,
+ SPCIO_MSG_FROM_SPC_QUERY_MD_CAPABILITY_ACK,
+ SPCIO_MSG_FROM_SPC_SET_MD_CAPABILITY_ACK,
+ SPCIO_MSG_FROM_SPC_PRINT_SPH_COEFF_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_ON_FOR_HOLD_CALL_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_ON_FOR_DACA_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_ROUTER_ON_ACK,
+ SPCIO_MSG_FROM_SPC_SET_VOICE_ENCRYPTION_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_DEV_CHANGE_ACK,
+ SPCIO_MSG_FROM_SPC_ENH_CTRL_SUPPORT_ACK,
+
+ SPCIO_MSG_FROM_SPC_PNW_ON_ACK = 0x30,
+ SPCIO_MSG_FROM_SPC_PNW_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_RECORD_ON_ACK,
+ SPCIO_MSG_FROM_SPC_RECORD_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_DMNR_RECPLAY_ON_ACK,
+ SPCIO_MSG_FROM_SPC_DMNR_RECPLAY_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_DMNR_REC_ONLY_ON_ACK,
+ SPCIO_MSG_FROM_SPC_DMNR_REC_ONLY_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_PCM_REC_ON_ACK,
+ SPCIO_MSG_FROM_SPC_PCM_REC_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_VM_REC_ON_ACK,
+ SPCIO_MSG_FROM_SPC_VM_REC_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_ON_ACK,
+ SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_PCMMIXER_ON_ACK,
+ SPCIO_MSG_FROM_SPC_PCMMIXER_OFF_ACK,
+
+ SPCIO_MSG_FROM_SPC_CTM_ON_ACK = 0x40,
+ SPCIO_MSG_FROM_SPC_CTM_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_CTM_DUMP_DEBUG_FILE_ACK,
+ SPCIO_MSG_FROM_SPC_BGSND_ON_ACK,
+ SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK,
+ SPCIO_MSG_FROM_SPC_BGSND_CONFIG_ACK,
+
+ SPCIO_MSG_FROM_SPC_PNW_DLDATA_REQUEST = 0x50,
+ SPCIO_MSG_FROM_SPC_BGS_DATA_REQUEST,
+ SPCIO_MSG_FROM_SPC_CTM_DATA_REQUEST,
+ SPCIO_MSG_FROM_SPC_DACA_ULDATA_REQUEST,
+ SPCIO_MSG_FROM_SPC_ECALL_MSD_NOTIFY,
+ SPCIO_MSG_FROM_SPC_SPC_UL_ENC_NOTIFY,
+ SPCIO_MSG_FROM_SPC_SPC_DL_DEC_REQUEST,
+ SPCIO_MSG_FROM_SPC_PCMMIXER_DL_DATA_REQUEST,
+ SPCIO_MSG_FROM_SPC_PCMMIXER_UL_DATA_REQUEST,
+
+ SPCIO_MSG_FROM_SPC_PNW_ULDATA_NOTIFY = 0x60,
+ SPCIO_MSG_FROM_SPC_REC_DATA_NOTIFY,
+ SPCIO_MSG_FROM_SPC_CTM_DEBUG_DATA_NOTIFY,
+ SPCIO_MSG_FROM_SPC_PCM_REC_DATA_NOTIFY,
+ SPCIO_MSG_FROM_SPC_VM_REC_DATA_NOTIFY,
+ SPCIO_MSG_FROM_SPC_DACA_DLDATA_NOTIFY,
+ SPCIO_MSG_FROM_SPC_RAW_PCM_REC_DATA_NOTIFY, //0x60 + 0x6
+ SPCIO_MSG_FROM_SPC_CUST_DUMP_NOTIFY,
+
+ SPCIO_MSG_FROM_SPC_EM_DATA_REQUEST = 0x70,
+ SPCIO_MSG_FROM_SPC_EM_INCALL_ACK,
+ SPCIO_MSG_FROM_SPC_EM_DMNR_ACK,
+ SPCIO_MSG_FROM_SPC_EM_WB_ACK,
+ SPCIO_MSG_FROM_SPC_EM_MAGICON_ACK,
+ SPCIO_MSG_FROM_SPC_NETWORK_STATUS_NOTIFY,
+ SPCIO_MSG_FROM_SPC_RF_INFO_NOTIFY,
+ SPCIO_MSG_FROM_SPC_EM_HAC_ACK,
+ SPCIO_MSG_FROM_SPC_EPOF_NOTIFY,
+ SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_ACK,
+ SPCIO_MSG_FROM_SPC_SPH_ENH_CORE_ACK,
+ SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_IN_STRUCT_SHM_ACK,
+ SPCIO_MSG_FROM_SPC_EMI_SPEECH_PAR_INFO_ACK,
+
+ SPCIO_MSG_FROM_SPC_VIBSPK_PARAMETER_ACK = 0x80,
+ SPCIO_MSG_FROM_SPC_NXP_SMARTPA_PARAMETER_ACK,
+
+ SPCIO_MSG_FROM_SPC_NW_CODEC_INFO_NOTIFY = 0x90,
+
+ SPCIO_MSG_FROM_AUD_ALIVE_NOTIFY = 0xA0,
+
+}SPCIO_MSG_FROM_SPC;
+
+#define SPEECH_SHM_GUARD_REGION_SIZE (32)
+
+typedef enum {
+
+ SPH_SHM_AP_FLAG_READY = (1 << 0), /* AP init SHM ready or nor */
+ SPH_SHM_AP_FLAG_SPH_PARAM_WRITE = (1 << 1), /* AP is writing SHM speech param */
+
+ SPH_SHM_AP_FLAG_MAX = (1 << 31) /* max 32 bit !! */
+}sph_shm_ap_flag_t;
+
+typedef enum {
+
+ SPH_SHM_MD_FLAG_ALIVE = (1 << 0), /* modem is alive or not */
+ SPH_SHM_MD_FLAG_SPH_PARAM_READ = (1 << 1), /* MD is reading SHM speech param */
+
+ SPH_SHM_MD_FLAG_MAX = (1 << 31) /* max 32 bit !! */
+}sph_shm_md_flag_t;
+
+
+typedef struct region_info_t {
+ kal_uint32 offset; /* ex: 0x1000 */
+ kal_uint32 size; /* ex: 0x100 */
+ kal_uint32 read_idx; /* ex: 0x0 ~ 0xFF */
+ kal_uint32 write_idx; /* ex: 0x0 ~ 0xFF */
+} region_info_t;
+
+
+typedef struct sph_shm_region_t {
+ region_info_t sph_param_region;
+ region_info_t ap_data_region;
+ region_info_t md_data_region;
+ region_info_t reserve_1;
+ region_info_t reserve_2;
+} sph_shm_region_t;
+
+
+typedef struct sph_shm_t {
+ /* 32 bytes gurard region */
+ kal_uint8 guard_region_pre[SPEECH_SHM_GUARD_REGION_SIZE];
+
+ /* 8 bytes init flag */
+ kal_uint32 ap_flag; /* sph_shm_ap_flag_t: ap can r/w, md read only */
+ kal_uint32 md_flag; /* sph_shm_md_flag_t: md can r/w, ap read only */
+
+ /* 80 bytes SHM region base */
+ sph_shm_region_t region;
+
+ /* 2 bytes alive message info */
+ kal_uint16 enhMDVersion; /* enhancement using version in alive message*/
+
+ kal_uint16 reserve; /* alive message version*/
+
+ /* 4 bytes strcut size check sum */
+ kal_uint32 struct_checksum; /* assert(shm->struct_checksum == (&shm->struct_checksum - shm)); */
+
+ /* 12K bytes speech param */
+ // kal_uint8 sph_param[SPEECH_SHM_SPEECH_PARAM_SIZE];
+
+ /* 8K bytes AP data */
+ // kal_uint8 ap_data[SPEECH_SHM_AP_DATA_SIZE];
+
+ /* 32K bytes MD data */
+ // kal_uint8 md_data[SPEECH_SHM_MD_DATA_SIZE];
+
+ /* 32 bytes gurard region */
+ // kal_uint8 guard_region_post[SPEECH_SHM_GUARD_REGION_SIZE];
+} sph_shm_t;
+
+
+
+// ----------------------------------------------------------------------------
+// Macro function
+// ----------------------------------------------------------------------------
+
+// extend version
+#define SPCIO_CCCI_MSG_CMD(msg) ((msg) >> 16)
+#define SPCIO_CCCI_MSG_DATA16(msg) ((msg) & 0xffffU)
+#define SPCIO_CCCI_MSG_CONSTRCUT_CMD(msg, data16) ( ((msg)<<16) | (0xffffU&(data16)) )
+#define SPCIO_CCCI_MSG_CONSTRCUT_DATA_CMD(msg, leng) SPCIO_CCCI_MSG_CONSTRCUT_CMD(msg, leng)
+#define SPCIO_CCCI_MSG_CONSTRUCT_DATA_CMD_WO_SHIFT(typefuncData, length) ( ( (typefuncData)&0xFFFF0000U) | ((length)&0xffffU) )
+
+
+// ----------------------------------------------------------------------------
+// function for AUDL thread putting
+// ----------------------------------------------------------------------------
+/**
+ @prSmpMsg:
+ @comeFrom: 0 for trigger from CCCI_HISR, 1 for trigger from AUDL. (you can add more in the future
+*/
+void SpcIO_MsgQueuePut(SPC_MSG_ID_T msgId, uint32 msgData, uint32 msgDataRev, SPC_MSG_FROM_T callerFrom);
+// ----------------------------------------------------------------------------
+// function for msg send/receive
+// ----------------------------------------------------------------------------
+kal_uint16 spcIo_GetDataFromAp_viaIntBuf(const kal_uint16 offset, const kal_uint16 length, void *buf);
+void SpcIO_GetDataFromAp_inOneTime(kal_uint16 offset, kal_uint16 length, kal_int16 headerLen,
+ void *header, void *buf, SPC_MSG_FROM_T comeFrom);
+bool SpcIO_WriteDataToAp(void *headerBuf, kal_int16 headerLen,
+ void *srcBuf1, kal_int16 srcLen1, void *srcBuf2, kal_int16 srcLen2, SPCIO_MSG_FROM_SPC spcIoMsg);
+kal_bool SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC spcIoMsg, uint32 data1, uint32 reserve);
+kal_uint16 SpcIo_GetDataFromAp(const kal_uint16 offset, const kal_uint16 length, void *buf, SPC_MSG_FROM_T comeFrom);
+
+kal_bool SpcIO_isFactoryBoot(void);
+
+#endif // _SPC_IO_H_
+
diff --git a/mcu/driver/audio/src/v1/inc/speech_def.h b/mcu/driver/audio/src/v1/inc/speech_def.h
new file mode 100644
index 0000000..987203e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/speech_def.h
@@ -0,0 +1,315 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * speech_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file defines all the speech registers used in audio module.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __SPEECH_DEF_H
+#define __SPEECH_DEF_H
+
+#include "kal_public_api.h"
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| Feature Definitions
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+
+#if defined(__DUAL_TALK_MODEM_SUPPORT__)
+ //In 6252 W+C project, L1Audio is the only module to use BT. In this project, no BT task won't be invoked, so we add by myself to use the setMode(BT_Earphone)
+ #define __BT_SUPPORT__
+#endif
+
+//=============================================================================================
+// HQA relative setting
+//=============================================================================================
+#if 0 // defined(__HQA_AUDIO__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+//=============================================================================================
+// Others
+//=============================================================================================
+// #define NEW_BLOCK_FILTER_SUPPORT
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| SPEECH SHERIF BASE ADDRESS
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| SPEECH DSP Control
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+//=============================================================================================
+// SPEECH Control Filed
+//=============================================================================================
+
+
+//=============================================================================================
+// Audio control field (Use Speech base)
+//=============================================================================================
+
+
+
+//=============================================================================================
+// Keytone & Tone
+
+
+//=============================================================================================
+// Voice Memo
+//=============================================================================================
+
+
+
+//=============================================================================================
+// PCM (Use Speech base)
+//=============================================================================================
+
+
+//=============================================================================================
+// AMR-WB playback control (Use Speech base)
+//=============================================================================================
+
+
+
+//=============================================================================================
+// Audio control field (Use Speech base)
+//=============================================================================================
+
+//=============================================================================================
+// EC / AEC / EES / DMNR Control Registers
+//=============================================================================================
+
+//=============================================================================================
+// Gain/Coeff/Compensation
+//=============================================================================================
+
+
+//=============================================================================================
+// Uplink Comfort noise
+//=============================================================================================
+
+//=============================================================================================
+// NR Control
+//=============================================================================================
+
+//=============================================================================================
+// TDNC Control
+//=============================================================================================
+
+//=============================================================================================
+// Enhanced Audio Control Field
+//=============================================================================================
+
+//=============================================================================================
+// Uplink WB AMR in TCH buffer
+//=============================================================================================
+
+
+//=============================================================================================
+// Sound Effect (Use Speech base)
+//=============================================================================================
+
+//=============================================================================================
+// CTM
+//=============================================================================================
+
+//=============================================================================================
+// 8K limiter control
+//=============================================================================================
+
+//=============================================================================================
+// SBC Support Definition
+//=============================================================================================
+
+//=============================================================================================
+// 3G Speech Sherif Address
+//=============================================================================================
+
+//=============================================================================================
+// DSP Speech Control
+//=============================================================================================
+
+
+
+//=============================================================================================
+// BlueTooth Mode Control Field (Sign-extension / linear / gain mode)
+//=============================================================================================
+
+//=============================================================================================
+// To indicate CSD channel types
+//=============================================================================================
+// #define DSP_TCH_S0_FLAGS DPRAM2_base(DP_TCH_S0_FLAGS)
+
+//=============================================================================================
+// DataCard Interface
+//=============================================================================================
+
+//=============================================================================================
+// Others
+//=============================================================================================
+
+/*
+============================================================================================================
+------------------------------------------------------------------------------------------------------------
+|| SPEECH DSP Control Including DM/PM Addr Define
+------------------------------------------------------------------------------------------------------------
+============================================================================================================
+*/
+
+//=============================================================================================
+// DUAL MIC Control
+//=============================================================================================
+
+
+//=============================================================================================
+// Speech Engineer Parameter
+//=============================================================================================
+
+//=============================================================================================
+// DSP Internal memory access
+//=============================================================================================
+
+//=============================================================================================
+//#define DP_AUDIO_VIA_8KBT_CTRL DPRAM2_base(DP2_AUDIO_VIA_BT_CTRL)
+//#define DP_VSBT_CTRL DPRAM2_base(DP_VBI_SYNC_BT_Earphone_CTRL)
+// #define BT_AUDIO_PLAYBACK_SD_PAGE_NUM 5
+// DSP AGC control
+//=============================================================================================
+
+
+//=============================================================================================
+// DSP Interrupt
+//=============================================================================================
+
+//=============================================================================================
+// Others
+//=============================================================================================
+
+
+#endif //__SPEECH_DEF_H
+
diff --git a/mcu/driver/audio/src/v1/inc/speech_service.h b/mcu/driver/audio/src/v1/inc/speech_service.h
new file mode 100644
index 0000000..9c916d2
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/speech_service.h
@@ -0,0 +1,50 @@
+#ifndef __SPEECH_SERVICE_H__
+#define __SPEECH_SERVICE_H__
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+
+/* for MACE */
+//#include "audio_struct.h"
+#include "audio_msgid.h"
+#include "dhl_trace.h"
+
+typedef struct {
+ kal_uint16 flag;
+}SPLog_t;
+
+
+typedef struct{
+ LOCAL_PARA_HDR /* size is 4 bytes now */
+ kal_uint8 local_hdr_len;
+ kal_uint8 reserved[3];
+ kal_uint32 data_len;
+ kal_uint8 data[256];
+}singleData_struct;
+
+typedef struct{
+ LOCAL_PARA_HDR /* size is 4 bytes now */
+ kal_uint8 local_hdr_len;
+ kal_uint8 opcode;
+ kal_uint8 reserved[2];
+}dbgInfo_struct;
+
+typedef struct{
+ LOCAL_PARA_HDR /* size is 4 bytes now */
+ kal_uint8 local_hdr_len;
+ kal_uint8 opcode;
+ kal_uint8 reserved[2];
+ kal_uint32 log_seq;
+ kal_uint32 data_len;
+ kal_uint8 data[256];
+}data_struct;
+
+
+void SPLog_GetFlagSetting(void);
+void SPLog_LogFlagSetting(void);
+void SPLog_LogSingleData(kal_uint32 msg_id, kal_uint32 data_length, void *data);
+void SPLog_LogData(kal_uint32 msg_id, kal_uint32 data_length, void *data);
+void SPLog_LogDbgInfo(kal_uint32 msg_id, kal_uint8 opcode, void *data);
+
+#endif /* __SPEECH_SERVICE_H__ */
diff --git a/mcu/driver/audio/src/v1/inc/streamrb.h b/mcu/driver/audio/src/v1/inc/streamrb.h
new file mode 100644
index 0000000..ac3d8b6
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/streamrb.h
@@ -0,0 +1,139 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * StreamRB.h
+ *
+ * Project:
+ * --------
+ * MOLY_sw
+ *
+ * Description:
+ * ------------
+ * StreamRB utility
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef _StreamRB_DOT_H_
+#define _StreamRB_DOT_H_
+
+/*****************************************************************************
+* C O M P I L E R F L A G S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* E X T E R N A L R E F E R E N C E S
+******************************************************************************
+*/
+#include "l1aud_common_def.h"
+/*****************************************************************************
+* C O N S T A N T S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A T Y P E S
+******************************************************************************
+*/
+typedef struct StreamRingBufferStruct StreamRB;
+struct StreamRingBufferStruct {
+ uint8 *buffer;
+ int32 read;
+ int32 write;
+ int32 size;
+};
+
+/*****************************************************************************
+* P U B L I C D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* M A C R O S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A D E C L A R A T I O N S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+bool StreamRB_Init( StreamRB *rb, uint8 *buffer, int32 buffer_size );
+int32 StreamRB_GetFreeSpace( StreamRB *rb );
+int32 StreamRB_GetDataCount( StreamRB *rb );
+void StreamRB_Write( StreamRB *dest_rb, uint8 *src_buffer, int32 size );
+void StreamRB_Read( StreamRB *src_rb, uint8 *dest_buffer, int32 size );
+void StreamRB_GetWriteBlock( StreamRB *dest_rb, uint8 **write_ptr, int32 *write_cnt );
+void StreamRB_GetReadBlock( StreamRB *src_rb, uint8 **read_ptr, int32 *read_cnt );
+void StreamRB_ShiftWritePointer( StreamRB *rb, int32 shamt );
+void StreamRB_ShiftReadPointer( StreamRB *rb, int32 shamt );
+//void StreamRB_ShiftReadPointer2( StreamRB *rb, int32 shamt );
+
+
+/*****************************************************************************
+* I N L I N E F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+
+#endif // ..._StreamRB_DOT_H_
+
diff --git a/mcu/driver/audio/src/v1/inc/tone_drv.h b/mcu/driver/audio/src/v1/inc/tone_drv.h
new file mode 100644
index 0000000..6d452e3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/tone_drv.h
@@ -0,0 +1,122 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * Tone_Drv.h
+ *
+ * Project:
+ * --------
+ * MTK Feature Phone
+ *
+ * Description:
+ * ------------
+ * DTMF tone driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#ifndef __TONE_DRV__H
+#define __TONE_DRV__H
+
+#define DTMF_KEYTONE_LOCK_MAX_COUNT 8
+
+void DTMF_MCU_StopAndWait();
+void DTMF_MCU_Play( const L1SP_Tones *pToneList, kal_bool fIsQTMF, kal_bool fIsKeytone);
+void DTMF_MCU_Stop(kal_bool fIsKeytone);
+kal_bool DTMF_MCU_IsTonePlaying();
+kal_bool DTMF_MCU_IsKeytonePlaying();
+
+
+typedef enum {
+ DTMF_DSP_STATE_IDLE = 0,
+ DTMF_DSP_STATE_INIT,
+ DTMF_DSP_STATE_PLAYING,
+ DTMF_DSP_STATE_ENDING,
+} DTMF_DSP_STATE;
+
+typedef struct {
+ kal_uint16 uFreq1;
+ kal_uint16 uFreq2;
+ kal_uint16 uFreq3;
+ kal_uint16 uFreq4;
+ kal_uint16 uDuration; //msec
+} DTMF_STRUCT;
+
+#if IS_EV_BOARD
+#define KT_INIT_AMP 0x1000
+#else
+#define KT_INIT_AMP 0x3FFF
+#endif
+
+#if IS_EV_BOARD
+#define TONE_INIT_AMP 0x1000
+#else
+#define TONE_INIT_AMP 0x1FFF
+#endif
+
+void DTMF_MCU_lockInit();
+
+#endif
diff --git a/mcu/driver/audio/src/v1/inc/vm.h b/mcu/driver/audio/src/v1/inc/vm.h
new file mode 100644
index 0000000..1197138
--- /dev/null
+++ b/mcu/driver/audio/src/v1/inc/vm.h
@@ -0,0 +1,210 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * vm.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * VM record related interface using internal
+ *
+ * Author:
+ * -------
+ *
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef _VM_H
+#define _VM_H
+
+#if defined(__MD93__) || defined(__MD95__) || defined(__MD97__) || defined(__MD97P__)
+#define VM_CHIP_ID 0x6293
+#else
+#define VM_CHIP_ID 0xFFFF
+#endif
+
+typedef enum {
+ EVS_AWB660 = 11,
+ EVS_AWB885,
+ EVS_AWB1265,
+ EVS_AWB1425,
+ EVS_AWB1585,
+ EVS_AWB1825,
+ EVS_AWB1985,
+ EVS_AWB2305,
+ EVS_AWB2385,
+ EVS_PRI590,
+ EVS_PRI720,
+ EVS_PRI800,
+ EVS_PRI960,
+ EVS_PRI1320,
+ EVS_PRI1640,
+ EVS_PRI2440,
+ EVS_PRI3200,
+ EVS_PRI4800,
+ EVS_PRI6400,
+ EVS_PRI9600,
+ EVS_PRI12800,
+ EVS_SID_LOST_NODATA = 98,
+ EVS_UNDEF = 99
+}EVS_VM_ID;
+
+//#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+typedef struct _vmGCodecULInfo
+{
+ uint16 drop_info;
+ //uint16 system_time;
+ uint16 codec;
+ uint16 codec_parameters;
+}vmGCodecULInfo, *pvmGCodecULInfo;
+
+typedef struct _vmGCodecDLInfo
+{
+ uint16 drop_info;
+ //uint16 system_time;
+ uint16 codec;
+ uint16 codec_parameters;
+ uint16 DL_PCM_size;
+}vmGCodecDLInfo, *pvmGCodecDLInfo;
+
+void vmStoreGCodecULStream(vmGCodecULInfo *pstvmGCodecULInfo, kal_uint16 u16StreamSize, kal_uint8 *pu8StreamData);
+void vmStoreGCodecDLStream(vmGCodecDLInfo *pstvmGCodecDLInfo, kal_uint16 u16StreamSize, kal_uint8 *pu8StreamData);
+//#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+
+void vmSet3GNetworkInfo(uint32 *l1_info, uint16 crc_result, uint16 buf_status, uint8 dl_count);
+
+void VM_Init(void);
+void VMREC_ConfigEpl(void);
+void VMREC_Start(void (*vm_hdlr)(void), bool isVoc);
+void VMREC_Stop( bool isVoc);
+
+/**
+ @buf1: [Output]pointer to pcm buf1,
+ @len1: [Output]length of buf1, unit is word(2byte)
+ @buf2: [Output]pointer to pcm buf2
+ @len2: [Output]length of buf2. unit is word(2byte)
+*/
+void VmRec_GetReadBufs(kal_uint32 *add1, kal_uint16 *len1, kal_uint32 *add2, kal_uint16 *len2);
+void VmRec_ReadDataDone(uint16 len);
+
+#endif //_VM_H
+
diff --git a/mcu/driver/audio/src/v1/l1audio_sph_srv.c b/mcu/driver/audio/src/v1/l1audio_sph_srv.c
new file mode 100644
index 0000000..0551672
--- /dev/null
+++ b/mcu/driver/audio/src/v1/l1audio_sph_srv.c
@@ -0,0 +1,156 @@
+#include "task_config.h"
+#include "syscomp_config.h"
+#include "kal_public_api.h"
+#include "tst_sap.h"
+#include "tst_msgid.h"
+
+#include "kal_trace.h"
+#include "l1audio_sph_trc.h"
+
+// #include "l1audio_def.h"
+#include "stdlib.h"
+
+// #include "sal_exp.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+
+#ifdef __SMMT_SUPPORT__
+#include "pcm4way.h"
+kal_bool bSMMT_ON = KAL_FALSE;
+uint16 *SphPat_Ptr;
+unsigned int SphPat_Index;
+extern const unsigned char CMCC_SWB_pcm[];
+extern unsigned int CMCC_SWB_pcm_len;
+#endif
+
+kal_bool setCommonPara = KAL_FALSE;
+uint16 commonPara_0 = 0;
+
+void voc_tst_handler(kal_char *string)
+{
+ commonPara_0 = atoi(string);
+
+ if ((commonPara_0 < 0) || (commonPara_0 > 16))
+ {
+ setCommonPara = KAL_FALSE;
+ commonPara_0 = 0;
+ MD_TRC_EPL_PARA_ERROR();
+ }
+ else
+ {
+ setCommonPara = KAL_TRUE;
+ MD_TRC_SET_EPL_PARA(commonPara_0);
+ }
+}
+
+void l1audio_sph_srv_tst_handler(ilm_struct *ilm_ptr)
+{
+ tst_module_string_inject_struct *tst_inject = (tst_module_string_inject_struct*) ilm_ptr->local_para_ptr;
+
+ if ( NULL == tst_inject)
+ return;
+
+ switch (tst_inject->index)
+ {
+ case 1:
+ {
+ voc_tst_handler( (kal_char *)tst_inject->string );
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void l1audio_sph_srv_main(ilm_struct *ilm_ptr)
+{
+ if(ilm_ptr->msg_id == MSG_ID_TST_INJECT_STRING)
+ l1audio_sph_srv_tst_handler(ilm_ptr);
+}
+
+void l1audio_sph_srv_task_main(task_entry_struct *task_entry_ptr)
+{
+ ilm_struct current_ilm;
+
+ while(1)
+ {
+ msg_receive_extq(¤t_ilm);
+ kal_set_active_module_id(current_ilm.dest_mod_id);
+
+ l1audio_sph_srv_main((void *)¤t_ilm);
+
+ destroy_ilm(¤t_ilm);
+ }
+}
+
+kal_bool l1audio_sph_srv_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct l1audio_sph_srv_handler_info =
+ {
+ l1audio_sph_srv_task_main,
+ NULL,
+ NULL
+ };
+ *handle = (comptask_handler_struct *)&l1audio_sph_srv_handler_info;
+ return KAL_TRUE;
+}
+
+#ifdef __SMMT_SUPPORT__
+void SMMT_UL_Hdl(void)
+{
+ PCM4WAY_PutToSE(&SphPat_Ptr[SphPat_Index]);
+
+ SphPat_Index += 640; // SCH band = SWB (frame length)
+ if(SphPat_Index >= (CMCC_SWB_pcm_len>>1))
+ {
+ SphPat_Index = 0;
+ }
+}
+#endif
+
+void l1audio_sph_srv_SMMT_Start(void)
+{
+#ifdef __SMMT_SUPPORT__
+ if (bSMMT_ON == KAL_TRUE)
+ {
+ return;
+ }
+
+ if (L1Audio_GetDebugInfo(14) & 4)
+ {
+ bSMMT_ON = KAL_TRUE;
+ SphPat_Ptr = (uint16*) CMCC_SWB_pcm;
+ SphPat_Index = 0;
+ Del_PcmEx_Start(NULL, SMMT_UL_Hdl,
+ USE_M2D_PATH,
+ 0,
+ 0,
+ 0,
+ 0);
+ }
+#endif
+}
+
+void l1audio_sph_srv_SMMT_End(void)
+{
+#ifdef __SMMT_SUPPORT__
+ if (bSMMT_ON == KAL_TRUE)
+ {
+ PCM4WAY_Stop(0);
+ bSMMT_ON = KAL_FALSE;
+ }
+#endif
+}
+#ifdef __SMMT_SUPPORT__
+__attribute__((aligned (4))) const unsigned char CMCC_SWB_pcm[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+unsigned int CMCC_SWB_pcm_len = 96;
+#endif
diff --git a/mcu/driver/audio/src/v1/l1audio_trace.c b/mcu/driver/audio/src/v1/l1audio_trace.c
new file mode 100644
index 0000000..13ccefc
--- /dev/null
+++ b/mcu/driver/audio/src/v1/l1audio_trace.c
@@ -0,0 +1,340 @@
+#ifdef L1_CATCHER
+
+//#include "TrcMod.h"
+#include "L1Trc.h"
+#include "kal_general_types.h"
+
+/****************/
+/* Filter array */
+/****************/
+unsigned char L1Audio_Trace_Filter[5] =
+ { 0x1, 0x3, 0x0, 0x0, 0x0 };
+/***********************/
+/* Set filter function */
+/***********************/
+void Set_L1Audio_Filter(unsigned char *setting)
+{
+ int i;
+
+ for(i=0; i<5; i++)
+ L1Audio_Trace_Filter[i] = setting[i];
+}
+
+/****************************************/
+/* Function definition for each Message */
+/****************************************/
+/* L1Audio_Msg_AFE_Switch */
+void L1TRC_Send_L1Audio_Msg_AFE_Switch(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x40);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_TurnSpk */
+void L1TRC_Send_L1Audio_Msg_AFE_TurnSpk(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x41);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_TurnMIC */
+void L1TRC_Send_L1Audio_Msg_AFE_TurnMIC(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x42);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_TurnFIR */
+void L1TRC_Send_L1Audio_Msg_AFE_TurnFIR(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x43);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_SetInput */
+void L1TRC_Send_L1Audio_Msg_AFE_SetInput(char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x44);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_MicVolume */
+void L1TRC_Send_L1Audio_Msg_AFE_MicVolume(unsigned char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x45);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_StVolume */
+void L1TRC_Send_L1Audio_Msg_AFE_StVolume(unsigned char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x46);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_EcParam */
+void L1TRC_Send_L1Audio_Msg_AFE_EcParam(short v1, short v2)
+{
+ TRC_START_FILL_TASK(6);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x47);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_PAD_SHORT(0xFAFA);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_AFE_SetDevice */
+void L1TRC_Send_L1Audio_Msg_AFE_SetDevice(unsigned char v1, char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x48);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AFE_SetVolume */
+void L1TRC_Send_L1Audio_Msg_AFE_SetVolume(unsigned char v1, unsigned char v2, unsigned char v3)
+{
+ TRC_START_FILL_TASK(5);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x49);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, v3);
+ TRC_PAD_FN(0xFAFAFA);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_AFE_SpkSelect */
+void L1TRC_Send_L1Audio_Msg_AFE_SpkSelect(short v1, short v2, short v3, short v4, short v5)
+{
+ TRC_START_FILL_TASK(12);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4A);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v3);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v4);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v5);
+ TRC_END_FILL_TASK_4w;
+}
+
+/* L1Audio_Msg_AFE_Gain */
+void L1TRC_Send_L1Audio_Msg_AFE_Gain(unsigned short v1, unsigned short v2, short v3)
+{
+ TRC_START_FILL_TASK(8);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4B);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v3);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_AM_Switch */
+void L1TRC_Send_L1Audio_Msg_AM_Switch(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4C);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AM_Handover */
+void L1TRC_Send_L1Audio_Msg_AM_Handover(char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4D);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AM_IO_Switch */
+void L1TRC_Send_L1Audio_Msg_AM_IO_Switch(unsigned char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4E);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AM_SetSpeech */
+void L1TRC_Send_L1Audio_Msg_AM_SetSpeech(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x4F);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_Speech_State */
+void L1TRC_Send_L1Audio_Msg_Speech_State(unsigned char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x50);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_DSP_INT */
+void L1TRC_Send_L1Audio_Msg_DSP_INT(unsigned short v1)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x51);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_AM_DELAY_TABLE */
+void L1TRC_Send_L1Audio_Msg_AM_DELAY_TABLE(short v1)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x52);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_SPEECH_FRAME */
+void L1TRC_Send_L1Audio_Msg_SPEECH_FRAME(unsigned char v1, unsigned char v2, unsigned char v3)
+{
+ TRC_START_FILL_TASK(5);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x53);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, v3);
+ TRC_PAD_FN(0xFAFAFA);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_SPEECH_CODEC */
+void L1TRC_Send_L1Audio_Msg_SPEECH_CODEC(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x54);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_VM_DEBUG */
+void L1TRC_Send_L1Audio_Msg_VM_DEBUG(unsigned short v1, unsigned short v2, unsigned short v3)
+{
+ TRC_START_FILL_TASK(8);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x55);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v3);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_VBI_RESET */
+void L1TRC_Send_L1Audio_Msg_VBI_RESET(void)
+{
+ TRC_START_FILL_TASK(2);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x56);
+ TRC_PAD_SHORT(0xFAFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_TCH_NOTIFY */
+void L1TRC_Send_L1Audio_Msg_TCH_NOTIFY(unsigned char v1, unsigned char v2)
+{
+ TRC_START_FILL_TASK(4);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x57);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_CHAR_3c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_INTERRAT_W2G */
+void L1TRC_Send_L1Audio_Msg_INTERRAT_W2G(void)
+{
+ TRC_START_FILL_TASK(2);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x58);
+ TRC_PAD_SHORT(0xFAFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_INTERRAT_G2W */
+void L1TRC_Send_L1Audio_Msg_INTERRAT_G2W(void)
+{
+ TRC_START_FILL_TASK(2);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x59);
+ TRC_PAD_SHORT(0xFAFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+/* L1Audio_Msg_SWITCH_FILT */
+void L1TRC_Send_L1Audio_Msg_SWITCH_FILT(short v1, unsigned short v2)
+{
+ TRC_START_FILL_TASK(6);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x5A);
+ TRC_MAKE_SHORT_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_MAKE_SHORT_0c(TRC_TASK_BUFFER, TRC_LOCAL, v2);
+ TRC_PAD_SHORT(0xFAFA);
+ TRC_END_FILL_TASK_3w;
+}
+
+/* L1Audio_Msg_AFE_RegBackup */
+void L1TRC_Send_L1Audio_Msg_AFE_RegBackup(unsigned char v1)
+{
+ TRC_START_FILL_TASK(3);
+ TRC_MAKE_CHAR_0c(TRC_TASK_BUFFER, TRC_LOCAL, 0xF0);
+ TRC_MAKE_CHAR_1c(TRC_TASK_BUFFER, TRC_LOCAL, 0x5B);
+ TRC_MAKE_CHAR_2c(TRC_TASK_BUFFER, TRC_LOCAL, v1);
+ TRC_PAD_CHAR(0xFA);
+ TRC_END_FILL_TASK_2w;
+}
+
+#endif
diff --git a/mcu/driver/audio/src/v1/l1audio_trace_utmd.json b/mcu/driver/audio/src/v1/l1audio_trace_utmd.json
new file mode 100644
index 0000000..24a6e60
--- /dev/null
+++ b/mcu/driver/audio/src/v1/l1audio_trace_utmd.json
@@ -0,0 +1,921 @@
+{
+ "endGen": "-",
+ "legacyParameters": {
+ "modemType": "L1_AUDIO"
+ },
+ "module": "L1Audio",
+ "startGen": "Legacy",
+ "stringTranslationDefs": [
+ {
+ "L1AUDIO_Str_Bool": [
+ "false",
+ "true"
+ ]
+ },
+ {
+ "L1AUDIO_Str_onoff": [
+ "off",
+ "on"
+ ]
+ },
+ {
+ "L1AUDIO_Func_Name": [
+ "Keytone",
+ "Tone",
+ "Speech",
+ "SND Effect",
+ "Audio",
+ "Voice",
+ "DAI",
+ "FM Radio"
+ ]
+ },
+ {
+ "AFE_Switch_Name": [
+ "8K interrupt",
+ "DAI",
+ "audio curcuit loopback",
+ "echo suppressor",
+ "AFE bias"
+ ]
+ },
+ {
+ "AM_Switch_Name": [
+ "Keytone",
+ "Tone",
+ "PCM8K Playback",
+ "PCM16K Playback",
+ "PCM8K Record",
+ "Speech",
+ "VM Record",
+ "VM Playback",
+ "PCM_HI Playback",
+ "SND Effect",
+ "PCM16K Record",
+ "PcmRouter"
+ ]
+ },
+ {
+ "AM_IO_Name": [
+ "NORMALE_MODE",
+ "DAI_MODE",
+ "BT_CORDLESS_MODE",
+ "BT_EARPHONE_MODE",
+ "PCM_MODE"
+ ]
+ },
+ {
+ "AM_Speech_Feature_Name": [
+ "VM Record",
+ "PCM8K Record",
+ "PCMNWAY",
+ "Data Card",
+ "VM Record EPL"
+ ]
+ },
+ {
+ "AM_Gain_Name": [
+ "Audio Dig Gain",
+ "Speech Dig Gain",
+ "Speech UL Dig Gain",
+ "Speech SW AGC Gain",
+ "Speech DL Enh Reference Dig Gain"
+ ]
+ },
+ {
+ "L1Audio_Speech_State": [
+ "Idle",
+ "2G speech on",
+ "3G speech on",
+ "3G324M speech on",
+ "3G speech closing",
+ "4G speech on",
+ "4G speech closed",
+ "C2K speech on",
+ "C2K speech closed"
+ ]
+ },
+ {
+ "L1Audio_Speech_State_L": [
+ "Idle",
+ "2G speech on",
+ "3G speech on",
+ "4G speech on",
+ "C2K speech on",
+ "Standby speech on"
+ ]
+ },
+ {
+ "L1SP_Speech_Codec_Mode": [
+ "FR",
+ "HR",
+ "EFR",
+ "AMR12.2",
+ "AMR10.2",
+ "AMR7.95",
+ "AMR7.4",
+ "AMR6.7",
+ "AMR5.9",
+ "AMR5.15",
+ "AMR4.75"
+ ]
+ },
+ {
+ "L1SP_Speech_TX_Type": [
+ "NO DATA",
+ "SID FIRST",
+ "SPEECH",
+ "SID UPDATE"
+ ]
+ },
+ {
+ "L1SP_Speech_RX_Type": [
+ "SPEECH_GOOD",
+ "SPEECH_DEGRADED",
+ "SPEECH_BAD",
+ "SID_FIRST",
+ "SID_UPDATE",
+ "SID_BAD",
+ "ONSET",
+ "NO_DATA",
+ "Non-AMR SPEECH_GOOD",
+ "Non-AMR SPEECH_GOOD, BFI",
+ "Non-AMR SID_probability",
+ "Non-AMR SID_probability, BFI",
+ "Non-AMR SID",
+ "Non-AMR SID, BFI"
+ ]
+ },
+ {
+ "SAL_DSP_VALUE_NAME": [
+ "UPDATE_3G_ENC_RATE",
+ "UPDATE_3G_DEC_RATE",
+ "UPDATE_MUTE_CTRL",
+ "UPDATE_SCH_DELAY",
+ "UPDATE_8K_CTRL",
+ "UPDATE_ENH_DYNAMIC_CTRL",
+ "HANDOVER_STATUS",
+ "UPDATE_AGC1_CTRL",
+ "UPDATE_SIDETONE_GAIN",
+ "UPDATE_SIDETONE_CTRL",
+ "UPDATE_AGC2_CTRL",
+ "UPDATE_AGC3_CTRL",
+ "UPDATE_AGC4_CTRL",
+ "UPDATE_ENH_DYNAMIC_STATE_SET",
+ "UPDATE_ENH_DYNAMIC_STATE_CHECK",
+ "UPDATE_ENH_FLAG_PAR",
+ "UPDATE_OPEN_DSP_HANDSHAKE_MD",
+ "UPDATE_OPEN_DSP_TIMEOUT_THRESHOLD",
+ "UPDATE_OPEN_DSP_CTRL",
+ "FAKE_SCH_DELAY",
+ "UPDATE_ECHO_REF_SOURCE",
+ "Get_PCM_EX_BUF_ADDR",
+ "GET_IIR_COEF_BUF_ADDR",
+ "UPDATE_RAMP_CTRL",
+ "UPDATE_PSRAN_TYPE",
+ "UPDATE_DTMF_REMOVAL_CTRL",
+ "UPDATE_UltraSound_REMOVAL_Switch"
+ ]
+ },
+ {
+ "SAL_PROC_NAME": [
+ "2G_CALL_OPEN",
+ "2G_CALL_CLOSE",
+ "2G_CALL_HANDOVER",
+ "3G_CALL_OPEN",
+ "3G_CALL_CLOSE",
+ "BGSND_SWITCH",
+ "BGSND_CONFIG",
+ "BKF_SWITCH",
+ "ENH_CONTROL_ENABLE",
+ "ENH_SWITCH",
+ "SPH_PAR_BKF_ADDR",
+ "SPH_PAR_MODE_ADDR",
+ "SPH_PAR_COMMON_ADDR",
+ "SPH_PAR_DMNR_ADDR",
+ "PCM_EX_CONFIG",
+ "PCM_EX_SET_STATE",
+ "LOOKBACK_ENABLE",
+ "BT_CONFIG",
+ "CTM_SWITCH",
+ "SAL_INIT",
+ "VM_CONFIG",
+ "SAL_SET_DEVICE",
+ "SAL_NOTCHFILTER_ENABLE",
+ "SAL_8K_RESYNC",
+ "SAL_VOLTE_SETINFO",
+ "SAL_2G_SMR_SWITCH",
+ "SAL_PAR_INTERNAL_ADDR",
+ "SAL_PCM_ROUTER_OPEN",
+ "SAL_PCM_ROUTER_CLOSE",
+ "4G_G_CODEC_CALL_OPEN",
+ "4G_G_CODEC_CALL_CLOSE",
+ "ENH_DYNAMIC_STATE_PARAMETER_INIT",
+ "SPH_PAR_MODE2_NB_ADDR",
+ "SPH_PAR_MODE3_NB_ADDR",
+ "SPH_PAR_MODE2_WB_ADDR",
+ "SPH_PAR_MODE3_WB_ADDR",
+ "SPH_PAR_FS_ADDR",
+ "SPH_OPEN_DSP_CTRL",
+ "4G_EXCOD_CALL_OPEN",
+ "4G_EXCOD_CALL_CLOSE",
+ "SPH_PAR_MODE_SWB_ADDR",
+ "SPH_PAR_BKF_SWB_ADDR",
+ "4G_CALL_OPEN",
+ "4G_CALL_CLOSE",
+ "4G_EVS_CALL_OPEN",
+ "4G_EVS_CALL_CLOSE",
+ "C2K_CALL_OPEN",
+ "C2K_CALL_CLOSE",
+ "C2K_COD_FEA_SWITCH",
+ "C2K_SET_VALUE",
+ "C2K_SET_TTY_SWITCH",
+ "C2K_SET_TTY_STATUS",
+ "ENH_PAR_UPDATE",
+ "EVS_SET_ENC_PAR",
+ "EVS_SET_DEC_PAR",
+ "SPH_DSP_KEYTONE",
+ "STANDBY_CALL_OPEN",
+ "STANDBY_CALL_CLOSE",
+ "4G_CALL_HANDOVER",
+ "4G_EVS_CALL_HANDOVER",
+ "MIXER2_SWITCH",
+ "MIXER2_CONFIG",
+ "MIXER3_SWITCH",
+ "MIXER3_CONFIG",
+ "GET_AAM_TIMEINFO",
+ "LBK_D2U_LBK"
+ ]
+ }
+ ],
+ "traceClassDefs": [
+ {
+ "AFE_Inf_H": {
+ "_comment": "filterDefaulValue is used in xl1sim, will be phased out later",
+ "debugLevel": "High",
+ "filterDefaultValue": "ON",
+ "tag": [
+ "L1Audio",
+ "L1Audio_AFE_INFO"
+ ],
+ "traceType": "CoreDesign"
+ }
+ },
+ {
+ "AM_Inf_H": {
+ "_comment": "filterDefaulValue is used in xl1sim, will be phased out later",
+ "debugLevel": "Ultra-High",
+ "filterDefaultValue": "ON",
+ "tag": [
+ "L1Audio",
+ "L1Audio_AM_INFO"
+ ],
+ "traceType": "CoreDesign"
+ }
+ },
+ {
+ "AM2_Inf_H": {
+ "_comment": "filterDefaulValue is used in xl1sim, will be phased out later",
+ "debugLevel": "Low",
+ "filterDefaultValue": "ON",
+ "tag": [
+ "L1Audio",
+ "L1Audio_AM2_INFO"
+ ],
+ "traceType": "CoreDesign"
+ }
+ },
+ {
+ "AUDIO_Inf_H": {
+ "_comment": "filterDefaulValue is used in xl1sim, will be phased out later",
+ "debugLevel": "Medium",
+ "filterDefaultValue": "ON",
+ "tag": [
+ "L1Audio",
+ "L1Audio_AUDIO_INFO"
+ ],
+ "traceType": "Public"
+ }
+ }
+ ],
+ "traceDefs": [
+ {
+ "L1Audio_Msg_AFE_Switch": {
+ "format": "AFE Turn %s %s",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AFE_TurnSpk": {
+ "format": "AFE Turn %s %s speaker",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AFE_TurnMIC": {
+ "format": "AFE Turn %s %s microphone",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AFE_TurnPath": {
+ "format": "AFE Turn %s %s wrok path",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AFE_SpkSelect": {
+ "format": "AFE SpkSelect v_lowest:%d, a_lowest:%d, fir:%d, mic:%d, mic_vol:%d",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Switch": {
+ "format": "AM %s %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Handover": {
+ "format": "AM handover occurs, speech mode=%b",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_AudioManagerInfo": {
+ "format": "AM Update AudioMgr Info, speech mode=%b sub_channel=%b",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_2G_Resync": {
+ "format": "2G Re-sync occurs, previous speech mode = %b, current speech mode = %b",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_IO_Switch": {
+ "format": "AM IO Switch to %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_SetSpeech": {
+ "format": "AM Speech-Feature %s %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_Speech_State": {
+ "format": "AM Speech State Change : %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_DSP_INT": {
+ "format": "DSP INT %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_DELAY_TABLE": {
+ "format": "AM Speech PCM Delay Table ID %d",
+ "traceClass": "AM2_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SPEECH_FRAME": {
+ "format": "Speech Frame Tx %s, Rx %s, BER = %ub",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SPEECH_CODEC": {
+ "format": "Speech Codec Mode Tx %s, Rx %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_VM_DEBUG": {
+ "format": "VM debug info %xd, %xd, %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_VBI_RESET": {
+ "format": "VBI Reset",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_VBI_END": {
+ "format": "VBI End",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_TCH_NOTIFY": {
+ "format": "AM TCH %s notify L1Audio, Speech State : %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SWITCH_FILT": {
+ "format": "AM switch to previous block filter %d %xd",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AFE_RegBackup": {
+ "format": "AFE Registers Bakcup %s",
+ "traceClass": "AFE_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_SRC1": {
+ "format": "AM SRCCtrl_1=%xd codec=%xd speech_mode=%xd",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_SRC2": {
+ "format": "AM SRCCtrl_2=%xd codec=%xd speech_mode=%xd",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_DSP_D2C_SPEECH_INT": {
+ "format": "DSP INT from SPH %s MSB = [%xd] LSB = [%xd]",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_DSP_D2C_SPEECH_INT_SKIP": {
+ "format": "DSP INT from SPH MSB = [%xd] LSB = [%xd] Skip",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP3G_FORCE_RESYNC": {
+ "format": "SP3G force resync message,U %xd, D %xd, R %xd, W %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP3G_SEND_RESYNC_INFO": {
+ "format": "SP3G resync idx %d, val %d, timing UL %xd DL %xd Cur %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP3G_REYSNC_DELAY_OVERFLOW": {
+ "format": "SP3G resync delay overflow, use default r=%d, w=%d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_DEBUG": {
+ "format": "2G AM Manager, previous speech mode = %b, current speech mode = %b handover=%d sub_ch=%d dsp_2g_reset=%d",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_DSP_GAIN": {
+ "format": "AM Set %s = %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SAL_SET_VALUE": {
+ "format": "SphAL update : %s = %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SAL_SET_VALUE_MULTI": {
+ "format": "SphAL update : %s = [%xd] [%xd] [%xd] [%xd] [%xd]",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SAL_PROC": {
+ "format": "SphAL proc : %s : [%xd] [%xd] [%xd] [%xd]",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP": {
+ "format": "PhoneCall SpeechOn %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_AudioManager": {
+ "format": "PhoneCall AM_AudioManager %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Resync": {
+ "format": "AM 2G L1D Resync %d offeset=%d",
+ "traceClass": "AM2_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Reset_Time_Drift": {
+ "format": "AM 2G L1D Resync Reset",
+ "traceClass": "AM2_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Update_Time_Drift": {
+ "format": "AM 2G L1D Resync Update %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_3G_Reset_Time_Drift": {
+ "format": "AM 3G L1D Resync Reset",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_3G_Reset_Debug": {
+ "format": "AM 3G L1D Resync Debug %d drift=%d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP3G_GetSyncDelayRW": {
+ "format": "SP3G_GetSyncDelayRW ul_codec_mode = %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Speech": {
+ "format": "AM_Speech %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_PutQ": {
+ "format": "AM_PutQ %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_L1D_GetRF": {
+ "format": "TCH_Notify L1D_GetRF %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_FORCE_RESYNC": {
+ "format": "SP4G force resync message,U %xd, D %xd, R %xd, W %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_SEND_RESYNC_INFO": {
+ "format": "SP4G resync idx %d, val %d, timing UL %xd DL %xd Cur %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_REYSNC_DELAY_OVERFLOW": {
+ "format": "SP4G resync delay overflow, use default r=%d, w=%d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_W2G": {
+ "format": "AM InterRAT 3G_to_2G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_G2W": {
+ "format": "AM InterRAT 2G_to_3G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Handover_L": {
+ "format": "AM handover occurs, speech mode=%b sub_channel=%b",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_AudioManager_L": {
+ "format": "2G AM Manager, handover=%d speech mode = %b sub_ch=%d am_state=%s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_AudioManager2_L": {
+ "format": "2G AM Manager, ul_speech_mode_L=%b ul_sub_channel_L = %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_TCH_NOTIFY_L": {
+ "format": "AM TCH %s notify L1Audio, am_state : %s",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_Speech_L": {
+ "format": "AM_Speech %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_PutQ_L": {
+ "format": "AM_PutQ %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_GetQ_L": {
+ "format": "AM_GetQ code_address=%xd param=%d %d %d %d %d %d %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_L1D_GetRF_L": {
+ "format": "L1D_GetRF %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_L1D_Backup_L": {
+ "format": "AM L1D backup %d %xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_HandoverInfo_L": {
+ "format": "AM %d cntHandover_L %d hasHandover_L %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_D2M_NOTIFY_L": {
+ "format": "AM D2M notify L1Audio in Core0 VPE0 counter: %d, %8xl",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_BT_SCO_NOTIFY_L": {
+ "format": "[SCO][DRV]BT SCO notify L1Audio in Core0 VPE0 counter: %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_D2M_NOTIFY_L2P": {
+ "format": "AM D2M notify L1Audio L2P counter: %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_BT_SCO_L2P": {
+ "format": "[SCO][DRV]BT SCO notify L1Audio L2P counter: %d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_BlockMED": {
+ "format": "AM BLOCK MED is_4G=%xd value=%xd pos=%xd",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_BlockMED_Status": {
+ "format": "AM BLOCK MED Status 3G=%xd 4G=%xd",
+ "traceClass": "AUDIO_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_GSeriesCall_Open": {
+ "format": "[SAL_4G_GSeriesCall_Open] I=%d SAL_PcmEx_CheckStateDL=%d SAL_PcmEx_CheckStateUL=%d is_ready=%d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_GSeriesCall_Open_OK": {
+ "format": "[SAL_4G_GSeriesCall_Open] SAL_PcmEx_CheckState OK",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_EVSSeriesCall_Open": {
+ "format": "[SAL_4G_EVSCall_Open] I=%d SAL_PcmEx_CheckStateDL=%d SAL_PcmEx_CheckStateUL=%d is_ready=%d",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_SP4G_EVSSeriesCall_Open_OK": {
+ "format": "[SAL_4G_EVSCall_Open] SAL_PcmEx_CheckState OK",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_AM_DVFS_Setting": {
+ "format": "AM DVFS codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_3G_TO_2G": {
+ "format": "AM InterRAT 3G_to_2G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_4G_TO_2G": {
+ "format": "AM InterRAT 4G_to_2G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_C2K_TO_2G": {
+ "format": "AM InterRAT C2K_to_2G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_STANDBY_TO_2G": {
+ "format": "AM InterRAT Standby_to_2G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_2G_TO_STANDBY": {
+ "format": "AM InterRAT 2G_to_STANDBY codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_2G_TO_3G": {
+ "format": "AM InterRAT 2G_to_3G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_3G_INTRARAT": {
+ "format": "AM InterRAT 3G to_3G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_4G_TO_3G": {
+ "format": "AM InterRAT 4G_to_3G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_C2K_TO_3G": {
+ "format": "AM InterRAT C2K_to_3G codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_2G_TO_4G": {
+ "format": "AM InterRAT 2G_to_4G codec=%xd reset_type=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_3G_TO_4G": {
+ "format": "AM InterRAT 3G_to_4G codec=%xd reset_type=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_4G_INTRARAT": {
+ "format": "AM InterRAT 4G_to_4G codec=%xd reset_type=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_C2K_TO_4G": {
+ "format": "AM InterRAT C2K_to_4G codec=%xd reset_type=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_2G_TO_C2K": {
+ "format": "AM InterRAT 2G_to_C2K codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_3G_TO_C2K": {
+ "format": "AM InterRAT 3G_to_C2K codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_INTERRAT_4G_TO_C2K": {
+ "format": "AM InterRAT 4G_to_C2K codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ },
+ {
+ "L1Audio_Msg_C2K_INTRARAT": {
+ "format": "AM InterRAT C2K_2_C2K codec codec=%xd",
+ "traceClass": "AM_Inf_H",
+ "traceHighlightOption": "info"
+ }
+ }
+ ],
+ "traceFamily": "L1",
+ "userModule": ""
+}
diff --git a/mcu/driver/audio/src/v1/media.c b/mcu/driver/audio/src/v1/media.c
new file mode 100644
index 0000000..8d3b798
--- /dev/null
+++ b/mcu/driver/audio/src/v1/media.c
@@ -0,0 +1,814 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * media.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Audio Playback/Record general interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_public_defs.h"
+#include "reg_base.h"
+#include "fs_type.h"
+#include "kal_trace.h"
+#include "string.h"
+#include "fsal.h"
+#include "audcoeff_default.h"
+
+#include "ddload.h"
+#include "l1audio.h"
+// #include "audio_def.h"
+#include "speech_def.h"
+#include "am.h"
+#include "media.h"
+#include "afe.h"
+#include "audio_enum.h"
+#include "l1sp_trc.h"
+#include "fs_errcode.h"
+
+#if defined(__AUDIO_COMPONENT_SUPPORT__)
+#include "AudComUtil.h"
+#endif
+
+#if VERIFY_DATA_TO_DSP
+extern void VERIFY_DATA_TO_DSP_START( void );
+extern void VERIFY_DATA_TO_DSP_RESUME( void );
+extern void VERIFY_DATA_TO_DSP_STOP( void );
+#endif
+
+
+
+
+/* Functions for Ring Buffer Access */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+/* ------------------------------------------------------------------------------ */
+/* Media File Playback/Recording Interface */
+/* ------------------------------------------------------------------------------ */
+// extern void AudioPP_Loudness_Registry( void );
+
+
+/* ------------------------------------------------------------------------------ */
+
+#ifdef PCM_EX_UNIT_TEST
+#include "pcm4way.h"
+static uint32 pcm_ex_test_on = 0;
+static uint16 PCM_BUF[160];
+static uint16 PCM_UL_BUF[8][160];
+static uint16 PCM_DL_BUF[8][160];
+static uint32 pcm_buf_rw;
+
+void pcm4way_hisrHdl()
+{
+ uint32 I;
+ int16 *buf1, *buf2;
+
+ buf1 = (int16*)PCM_UL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ *buf2++ = (*buf1++) >> 2;
+ PCM4WAY_GetFromMic((uint16*)PCM_UL_BUF[pcm_buf_rw]);
+ buf1 = (int16*)PCM_UL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ (*buf2++) += (*buf1++) >> 2 * 3;
+ PCM4WAY_PutToSE((const uint16*)PCM_BUF);
+
+ buf1 = (int16*)PCM_DL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ *buf2++ = (*buf1++) >> 2;
+ PCM4WAY_GetFromSD((uint16*)PCM_DL_BUF[pcm_buf_rw]);
+ buf1 = (int16*)PCM_DL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ (*buf2++) += (*buf1++) >> 2 * 3;
+ PCM4WAY_PutToSpk((const uint16*)PCM_BUF);
+
+ pcm_buf_rw ++;
+ pcm_buf_rw &= 0x7;
+}
+
+void pcm2way_hisrHdl()
+{
+ uint32 I;
+ int16 *buf1, *buf2;
+
+ buf1 = (int16*)PCM_UL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ *buf2++ = (*buf1++) >> 2;
+ PCM2WAY_GetFromMic((uint16*)PCM_UL_BUF[pcm_buf_rw]);
+ buf1 = (int16*)PCM_UL_BUF[pcm_buf_rw];
+ buf2 = (int16*)PCM_BUF;
+ for(I = 160; I > 0 ; I--)
+ (*buf2++) += (*buf1++) >> 2 * 3;
+ PCM2WAY_PutToSpk((const uint16*)PCM_BUF);
+
+ pcm_buf_rw ++;
+ pcm_buf_rw &= 0x7;
+}
+
+#endif
+
+/*
+void Media_MuteSpeaker( bool mute )
+{
+// AFE_MuteSpeaker( L1SP_AUDIO, mute );
+// AFE_MuteSpeaker( L1SP_VOICE, mute );
+}
+*/
+
+/* ------------------------------------------------------------------------------ */
+
+#ifndef __L1_STANDALONE__ // avoid link error
+
+//interface for audiohdl
+void rbGetWriteBuffer( AUD_RB_INFO *rb, kal_uint8 **buffer, kal_uint32 *buf_len )// in bytes
+{
+ int32 count;
+ int32 temp_read = rb->read;
+ int32 temp_write = rb->write;
+ if( temp_read > temp_write )
+ count = temp_read - temp_write - 1;
+ else if( temp_read == 0 )
+ count = rb->rb_size - temp_write - 1;
+ else
+ count = rb->rb_size - temp_write;
+
+ ASSERT( count>=0 );
+ *buffer = (uint8 *)&rb->rb_base[temp_write];
+ *buf_len = count;
+}
+
+void rbGetReadBuffer( AUD_RB_INFO *rb, kal_uint8 **buffer, kal_uint32 *buf_len )// in bytes
+{
+ int32 count;
+ int32 temp_write = rb->write;
+ int32 temp_read = rb->read;
+ if( temp_write >= temp_read )
+ count = temp_write - temp_read;
+ else
+ count = rb->rb_size - temp_read;
+
+ ASSERT( count>=0 );
+ *buffer = (uint8 *)&rb->rb_base[temp_read];
+ *buf_len = count;
+}
+
+void rbReadDataDone( AUD_RB_INFO *rb, kal_uint32 len ) // in bytes
+{
+ int32 temp_read = rb->read;
+ temp_read+= len;
+
+ ASSERT(temp_read <= rb->rb_size);
+ if( temp_read == rb->rb_size )
+ {
+ temp_read = 0;
+ }
+ rb->read = temp_read;
+
+ MD_TRC_L1AUDIO_READ_BYTE(len);
+}
+
+
+void rbWriteDataDone( AUD_RB_INFO *rb, kal_uint32 len ) // in bytes
+{
+ int32 temp_write = rb->write;
+ temp_write += len;
+
+ ASSERT(temp_write <= rb->rb_size);
+ if( temp_write == rb->rb_size )
+ {
+ temp_write = 0;
+ }
+ rb->write = temp_write;
+}
+
+int32 rbGetFreeSpace( AUD_RB_INFO *rb )
+{
+ int32 count;
+
+ count = rb->read - rb->write - 1;
+ if( count < 0 )
+ count += rb->rb_size;
+ return count; // free size in byte
+}
+
+int32 rbGetDataCount( AUD_RB_INFO *rb )
+{
+ return rb->rb_size - rbGetFreeSpace(rb) - 1;
+}
+//interface for audiohdl end
+
+
+#endif // #ifndef __L1_STANDALONE__
+
diff --git a/mcu/driver/audio/src/v1/pcm4way.c b/mcu/driver/audio/src/v1/pcm4way.c
new file mode 100644
index 0000000..fcd3e97
--- /dev/null
+++ b/mcu/driver/audio/src/v1/pcm4way.c
@@ -0,0 +1,868 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * pcm4way.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * PCM4WAY/PCM2WAY interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "sync_data.h"
+#include "l1sp_trc.h"
+#include "l1audio_voc_utmd.h"
+#include "l1audio.h"
+#include "am.h"
+
+// #include "afe_def.h"
+#include "media.h"
+#include "pcm4way.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+
+#include "sp_drv.h"
+#include "sp_enhance.h"
+
+#include "vm.h"
+
+#define PCMEX_INTERNAL_BUF_MAX_SIZE 960 // 48 * 20 samples
+
+#define PCMEX_CO_BUFFER_WHEN_RW 1
+
+_PCMEX_T pcmEx;
+
+#if PCMEX_CO_BUFFER_WHEN_RW
+static uint16 pcmEx_ul1_tempBufDataSize;
+static uint16 pcmEx_ul2_tempBufDataSize;
+static uint16 pcmEx_ul3_tempBufDataSize;
+static uint16 pcmEx_ul4_tempBufDataSize;
+
+static uint16 pcmEx_dl_tempBufDataSize;
+
+static uint16 pcmEx_ul1_tempBuf[PCMEX_INTERNAL_BUF_MAX_SIZE];
+static uint16 pcmEx_ul2_tempBuf[PCMEX_INTERNAL_BUF_MAX_SIZE];
+static uint16 pcmEx_ul3_tempBuf[PCMEX_INTERNAL_BUF_MAX_SIZE];
+static uint16 pcmEx_ul4_tempBuf[PCMEX_INTERNAL_BUF_MAX_SIZE];
+
+static uint16 pcmEx_dl_tempBuf[PCMEX_INTERNAL_BUF_MAX_SIZE];
+#endif
+
+static bool idlePnwVm;
+
+bool pcmEx_isRunInIdleMode(void)
+{
+ return (pcmEx.am_type==AM_PCMEX_TYPE_IDLE);
+}
+
+void pcmEx_Init()
+{
+ pcmEx.PCMEXspinLockID = kal_create_spinlock("PCMEX_LOCK");
+
+}
+
+uint16 pcmEx_getDataFromDsp(uint16 *toBuf, Sal_PcmEx_BufId_t bufName, kal_bool isUl)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(bufName);
+
+ // Use address mode to prevent idma being interrupted by other ISR, ie. L1D.
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(bufName);
+ MD_TRC_P4W_GETDATAFROMDSP(bufName, ptr, bufLen);
+ if( SP_IsMicMute() && (KAL_TRUE == isUl) ){
+ for( I = bufLen; I > 0; I-- )
+ *toBuf++ = 0;
+ } else {
+ for( I = bufLen; I > 0; I-- )
+ *toBuf++ = *ptr++;
+ }
+
+ return bufLen;
+}
+
+uint16 pcmEx_writeDataToDsp(const uint16 *fromBuf, Sal_PcmEx_BufId_t bufName)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(bufName);
+
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(bufName);
+ MD_TRC_P4W_WRITEDATATODSP(bufName, ptr, bufLen);
+ for( I = bufLen; I > 0; I-- )
+ *ptr++ = *fromBuf++;
+ Data_Sync_Barrier();
+
+ return bufLen;
+}
+
+uint16 pcmEx_writePatternToDsp(uint16 pattern, Sal_PcmEx_BufId_t bufName)
+{
+ uint32 I;
+ uint16 bufLen = SAL_PcmEx_GetBufLen(bufName);
+
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(bufName);
+ for( I = bufLen; I > 0; I-- )
+ *ptr++ = pattern;
+ Data_Sync_Barrier();
+
+ return bufLen;
+}
+
+
+void pcmEx_hisrDlHdlr(void *param)
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ // get SD buf data to temp buffer
+ pcmEx_dl_tempBufDataSize = pcmEx_getDataFromDsp(pcmEx_dl_tempBuf, SAL_PCMEX_PNW_BUF_D2M_DL1, KAL_FALSE);
+
+#endif
+
+ // handler callback
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ if(pcmEx.pnw_dl_hdlr)
+ {
+ pcmEx.pnw_dl_hdlr();
+ }
+
+}
+
+void pcmEx_hisrUlHdlr(void *param)
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ // mics' data to temp buffer
+ if(pcmEx.cfgUL1) {
+ pcmEx_ul1_tempBufDataSize = pcmEx_getDataFromDsp(pcmEx_ul1_tempBuf, SAL_PCMEX_PNW_BUF_D2M_UL1, KAL_TRUE);
+ }
+
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ if(pcmEx.cfgUL2) {
+ pcmEx_ul2_tempBufDataSize = pcmEx_getDataFromDsp(pcmEx_ul2_tempBuf, SAL_PCMEX_PNW_BUF_D2M_UL2, KAL_TRUE);
+ }
+
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ if(pcmEx.cfgUL3) {
+ pcmEx_ul3_tempBufDataSize = pcmEx_getDataFromDsp(pcmEx_ul3_tempBuf, SAL_PCMEX_PNW_BUF_D2M_UL3, KAL_TRUE);
+ }
+
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ if(pcmEx.cfgUL4) {
+ pcmEx_ul4_tempBufDataSize = pcmEx_getDataFromDsp(pcmEx_ul4_tempBuf, SAL_PCMEX_PNW_BUF_D2M_UL4, KAL_TRUE);
+ }
+
+#endif
+
+ // handler callback
+ if(pcmEx.pnw_ul_hdlr)
+ {
+ pcmEx.pnw_ul_hdlr();
+ }
+}
+
+
+/**
+
+@pcmNway_dl_hdlr
+@pcmNway_ul_hdlr:
+*/
+void Idle_PcmEx_Start(void (*pcmNway_dl_hdlr)(void), void (*pcmNway_ul_hdlr)(void),
+ uint32 cfgUL1, uint32 cfgUL2, uint32 cfgUL3, uint32 cfgUL4, uint32 cfgDL,
+ PCMEX_BAND band, PCMEX_IDLE_ENH_SETTING enhSetting)
+{
+ uint32 I;
+ kal_uint32 voc_ptn = TVCI_CLOSE_FILE;
+ kal_uint32 *voc_ptn_ptr = &voc_ptn;
+
+
+ // prevent re-entry!!
+ ASSERT(PNW_STATE_IDLE == pcmEx.state);
+
+ pcmEx.aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( pcmEx.aud_id ); /*Be careful.Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag*/
+
+ // band and am type setting
+ pcmEx.bandInfo = band;
+ switch(band){
+ case PCMEX_BAND_NB:
+ {
+ ASSERT(enhSetting != PCMEX_IDLE_ENH_SETTING_NONE);
+ pcmEx.am_type = AM_PCMEX_TYPE_IDLE;
+ }
+ break;
+ case PCMEX_BAND_WB:
+ {
+ ASSERT(enhSetting != PCMEX_IDLE_ENH_SETTING_NONE);
+ pcmEx.am_type = AM_PCMEX_TYPE_IDLE;
+ }
+ break;
+ default: // include PCMEX_BAND_DYNAMIC and PCMEX_BAND_UNSET cases
+ ASSERT(0);
+ }
+ pcmEx.cfgUL1 = cfgUL1;
+ pcmEx.cfgUL2 = cfgUL2;
+ pcmEx.cfgUL3 = cfgUL3;
+ pcmEx.cfgUL4 = cfgUL4;
+ pcmEx.cfgDL = cfgDL;
+
+ pcmEx.pnw_dl_hdlr = pcmNway_dl_hdlr;
+ pcmEx.pnw_ul_hdlr = pcmNway_ul_hdlr;
+
+ L1Audio_HookHisrHandler(DP_D2C_PCM_EX_DL,(L1Audio_EventHandler)pcmEx_hisrDlHdlr, 0);
+ L1Audio_HookHisrHandler(DP_D2C_PCM_EX_UL,(L1Audio_EventHandler)pcmEx_hisrUlHdlr, 0);
+
+ // check DSP state and turn on
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) && SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF));
+ AM_PCM_EX_On(pcmEx.am_type, (uint32)(&pcmEx));//to config pnw
+
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_ON);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_ON);
+
+ // wait for ready
+ for(I = 0; ;I ++){
+ kal_bool is_ready = true;
+
+ if( (pcmEx.cfgDL & (USE_D2M_PATH+USE_M2D_PATH)) && (!SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY)))
+ is_ready &= false;
+ if( (pcmEx.cfgUL1 & (USE_D2M_PATH+USE_M2D_PATH)) && (!SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY)))
+ is_ready &= false;
+
+ if(is_ready)
+ break;
+#ifndef L1D_TEST
+ ASSERT(I < 22); // wait 200ms
+ kal_sleep_task( AUD_1TICK(2) );
+#endif
+ }
+
+ pcmEx.state = PNW_STATE_RUN;
+#ifndef __L1_STANDALONE__ // avoid link error
+ if(ChkL1ClsFltr_L1Audio_VoC_TRACE_VM())
+ {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 1);
+ if(ChkL1ClsFltr_L1Audio_VoC_TRACE_EPL()) {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 2);
+ }
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)voc_ptn_ptr, 4);
+ VMREC_Start(NULL, true);
+ idlePnwVm = true;
+ }
+ else {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 0);
+ }
+#endif
+
+ if(PCMEX_IDLE_ENH_SETTING_WITH == enhSetting) {
+ pcmEx.isEnhOn = true;
+ SetSpeechEnhancement(true);
+ }
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ pcmEx.running = 1;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+
+ /* the end of configure the SAL */
+}
+
+
+
+void Del_PcmEx_Start(void (*pcmNway_dl_hdlr)(void), void (*pcmNway_ul_hdlr)(void),
+ uint32 cfgUL1, uint32 cfgUL2, uint32 cfgUL3, uint32 cfgUL4, uint32 cfgDL)
+{
+ uint32 I;
+ //kal_bool flag;
+
+ // prevent re-entry!!
+ ASSERT(PNW_STATE_IDLE == pcmEx.state);
+
+ pcmEx.aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( pcmEx.aud_id ); /*Be careful.Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag*/
+
+ // band and am type setting
+ pcmEx.bandInfo = PCMEX_BAND_DYNAMIC;
+ pcmEx.am_type = AM_PCMEX_TYPE_DEDICATION;
+
+ // pcmEx.dspPcmExMicLen = 0;
+ // pcmEx.dspPcmExSpkLen = 0;
+
+ pcmEx.cfgUL1 = cfgUL1;
+ pcmEx.cfgUL2 = cfgUL2;
+ pcmEx.cfgUL3 = cfgUL3;
+ pcmEx.cfgUL4 = cfgUL4;
+
+ pcmEx.cfgDL = cfgDL;
+
+ pcmEx.pnw_dl_hdlr = pcmNway_dl_hdlr;
+ pcmEx.pnw_ul_hdlr = pcmNway_ul_hdlr;
+
+ L1Audio_HookHisrHandler(DP_D2C_PCM_EX_DL,(L1Audio_EventHandler)pcmEx_hisrDlHdlr, 0);
+ L1Audio_HookHisrHandler(DP_D2C_PCM_EX_UL,(L1Audio_EventHandler)pcmEx_hisrUlHdlr, 0);
+
+ // check DSP state and turn on
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) && SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF));
+ AM_PCM_EX_On(pcmEx.am_type, (uint32)(&pcmEx));//to config pnw
+
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_ON);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_ON);
+
+ // wait for ready
+ for(I = 0; ;I ++){
+ kal_bool is_ready = true;
+
+ if( (pcmEx.cfgDL & (USE_D2M_PATH+USE_M2D_PATH)) && (!SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY)))
+ is_ready &= false;
+ if( (pcmEx.cfgUL1 & (USE_D2M_PATH+USE_M2D_PATH)) && (!SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY)))
+ is_ready &= false;
+
+ if(is_ready)
+ break;
+#ifndef L1D_TEST
+ ASSERT(I < 22); // wait 200ms
+ kal_sleep_task( AUD_1TICK(2) );
+#endif
+ }
+
+ pcmEx.state = PNW_STATE_RUN;
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ pcmEx.running = 1;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ /* the end of configure the SAL */
+}
+
+void PcmEx_Stop(void)
+{
+ kal_uint32 voc_ptn = TVCI_CLOSE_FILE;
+ kal_uint32 *voc_ptn_ptr = &voc_ptn;
+
+ ASSERT( PNW_STATE_RUN == pcmEx.state);
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ pcmEx.running = 0;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ if(true == pcmEx.isEnhOn) {
+ SetSpeechEnhancement(false);
+ }
+
+
+ if(idlePnwVm)
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)voc_ptn_ptr, 4);
+ VMREC_Stop(true);
+ idlePnwVm = false;
+ }
+ /* the begining of configure the SAL */
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
+ ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
+
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);
+
+ AM_PCM_EX_Off(pcmEx.am_type, (uint32)(&pcmEx));
+
+ L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_DL);
+ L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_UL);
+
+ L1Audio_ClearFlag( pcmEx.aud_id );
+ L1Audio_FreeAudioID( pcmEx.aud_id );
+
+ // set to default.
+ pcmEx.pnw_dl_hdlr = pcmEx.pnw_ul_hdlr = NULL;
+ pcmEx.cfgUL1 = 0;
+ pcmEx.cfgUL2 = 0;
+ pcmEx.cfgUL3 = 0;
+ pcmEx.cfgUL4 = 0;
+ pcmEx.cfgDL = 0;
+
+ // pcmEx.dspPcmExMicLen = 0;
+ // pcmEx.dspPcmExSpkLen = 0;
+
+ pcmEx.bandInfo = PCMEX_BAND_UNSET;
+ pcmEx.am_type = AM_PCMEX_TYPE_UNDEF;
+
+ pcmEx.state = PNW_STATE_IDLE;
+
+
+}
+
+
+uint16 PcmEx_GetFromMic1(uint16 *ul_buf)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ memcpy(ul_buf, pcmEx_ul1_tempBuf, pcmEx_ul1_tempBufDataSize*sizeof(uint16));
+ return pcmEx_ul1_tempBufDataSize;
+
+#else
+
+ return pcmEx_getDataFromDsp(ul_buf, SAL_PCMEX_PNW_BUF_D2M_UL1, KAL_TRUE);
+
+#endif
+}
+
+uint16 PcmEx_GetFromMic2(uint16 *ul_buf)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ memcpy(ul_buf, pcmEx_ul2_tempBuf, pcmEx_ul2_tempBufDataSize*sizeof(uint16));
+ return pcmEx_ul2_tempBufDataSize;
+
+#else
+
+ return pcmEx_getDataFromDsp(ul_buf, SAL_PCMEX_PNW_BUF_D2M_UL2, KAL_TRUE);
+
+#endif
+}
+
+uint16 PcmEx_GetFromMic3(uint16 *ul_buf)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ memcpy(ul_buf, pcmEx_ul3_tempBuf, pcmEx_ul3_tempBufDataSize*sizeof(uint16));
+ return pcmEx_ul3_tempBufDataSize;
+
+#else
+
+ return 0;
+
+#endif
+}
+
+uint16 PcmEx_GetFromMic4(uint16 *ul_buf)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ memcpy(ul_buf, pcmEx_ul4_tempBuf, pcmEx_ul4_tempBufDataSize*sizeof(uint16));
+ return pcmEx_ul4_tempBufDataSize;
+
+#else
+
+ return 0 ;
+
+#endif
+}
+
+uint16 PcmEx_PutToSE1(const uint16 *ul_data)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writeDataToDsp(ul_data, SAL_PCMEX_PNW_BUF_M2D_UL1);
+#else
+ return pcmEx_writeDataToDsp(ul_data, SAL_PCMEX_PNW_BUF_M2D_UL2);
+#endif
+}
+
+uint16 PcmEx_FillSE1(uint16 value)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_UL1);
+#else
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_UL2);
+#endif
+}
+
+uint16 PcmEx_PutToSE2(const uint16 *ul_data)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writeDataToDsp(ul_data, SAL_PCMEX_PNW_BUF_M2D_UL2);
+#else
+ return 0;
+#endif
+}
+
+uint16 PcmEx_FillSE2(uint16 value)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_UL2);
+#else
+ return 0;
+#endif
+}
+
+uint16 PcmEx_PutToSE3(const uint16 *ul_data)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writeDataToDsp(ul_data, SAL_PCMEX_PNW_BUF_M2D_UL3);
+#else
+ return 0;
+#endif
+}
+
+uint16 PcmEx_FillSE3(uint16 value)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_UL3);
+#else
+ return 0;
+#endif
+}
+
+uint16 PcmEx_PutToSE4(const uint16 *ul_data)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writeDataToDsp(ul_data, SAL_PCMEX_PNW_BUF_M2D_UL4);
+#else
+ return 0;
+#endif
+}
+
+uint16 PcmEx_FillSE4(uint16 value)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_UL4);
+#else
+ return 0;
+#endif
+}
+
+// --------------------------
+
+uint16 PcmEx_GetFromSD(uint16 *dl_buf)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+
+ memcpy(dl_buf, pcmEx_dl_tempBuf, pcmEx_dl_tempBufDataSize*sizeof(uint16));
+ return pcmEx_dl_tempBufDataSize;
+
+#else
+ return pcmEx_getDataFromDsp(dl_buf,SAL_PCMEX_PNW_BUF_D2M_DL1 , KAL_FALSE);
+#endif
+}
+
+uint16 PcmEx_PutToSpk(const uint16 *dl_data)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writeDataToDsp(dl_data, SAL_PCMEX_PNW_BUF_M2D_DL1);
+#else
+ return pcmEx_writeDataToDsp(dl_data, SAL_PCMEX_PNW_BUF_M2D_DL1);
+#endif
+
+}
+
+uint16 PcmEx_FillSpk(uint16 value)
+{
+#if PCMEX_CO_BUFFER_WHEN_RW
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_DL1);
+#else
+ return pcmEx_writePatternToDsp(value, SAL_PCMEX_PNW_BUF_M2D_DL1);
+#endif
+
+}
+
+
+//************** PCM 4-WAY ****************************************************
+
+void PCM4WAY_Start(void (*pcm4way_hdlr)(void), uint32 type)
+{
+ kal_prompt_trace(MOD_L1SP, "[Test] PCM4WAY_Start config type:%x", type);
+ switch(type) {
+ case P4W_APP_CTM:
+ Del_PcmEx_Start(pcm4way_hdlr, NULL,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_D2M_PATH + USE_M2D_PATH );
+ break;
+ case P4W_APP_TYPE_UNDER_CALL:
+ Del_PcmEx_Start(pcm4way_hdlr, NULL,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_D2M_PATH + USE_M2D_PATH);
+ break;
+ case P4W_APP_TYPE_WITHOUT_CALL:
+ Idle_PcmEx_Start(pcm4way_hdlr, NULL,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_D2M_PATH + USE_M2D_PATH,
+ PCMEX_BAND_NB, PCMEX_IDLE_ENH_SETTING_WITH); // nb
+ break;
+ case P4W_APP_TYPE_WITHOUT_CALL_WB:
+ Idle_PcmEx_Start(pcm4way_hdlr, NULL,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_D2M_PATH + USE_M2D_PATH,
+ PCMEX_BAND_WB, PCMEX_IDLE_ENH_SETTING_WITH);
+ break;
+ case P4W_APP_ECALL_DETECT:
+ Del_PcmEx_Start(pcm4way_hdlr, NULL,
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_D2M_PATH );
+ break;
+ default:
+ ASSERT(0);
+ }
+
+
+}
+
+void PCM4WAY_Stop(uint32 type)
+{
+ PcmEx_Stop();
+}
+
+uint16 PCM4WAY_GetFromMic(uint16 *ul_buf)
+{
+ return PcmEx_GetFromMic1(ul_buf);
+}
+uint16 PCM4WAY_GetFromMic2(uint16 *ul_buf)
+{
+ return PcmEx_GetFromMic2(ul_buf);
+}
+
+uint16 PCM4WAY_PutToSE(const uint16 *ul_data)
+{
+ return PcmEx_PutToSE1(ul_data);
+}
+
+uint16 PCM4WAY_PutToSE2(const uint16 *ul_data)
+{
+ return PcmEx_PutToSE2(ul_data);
+}
+
+uint16 PCM4WAY_FillSE(uint16 value)
+{
+ return PcmEx_FillSE1(value);
+}
+
+uint16 PCM4WAY_FillSE2(uint16 value)
+{
+ return PcmEx_FillSE2(value);
+}
+
+uint16 PCM4WAY_GetFromSD(uint16 *dl_buf)
+{
+ return PcmEx_GetFromSD(dl_buf);
+
+}
+
+uint16 PCM4WAY_PutToSpk(const uint16 *dl_data)
+{
+ return PcmEx_PutToSpk(dl_data);
+}
+
+uint16 PCM4WAY_FillSpk(uint16 value)
+{
+ return PcmEx_FillSpk(value);
+
+}
+
+//************** PCM 2-WAY ****************************************************
+
+void PCM2WAY_Start(void (*pcm2way_hdlr)(void), uint32 type)
+{
+ switch(type) {
+ case P2W_APP_TYPE_UNDER_CALL:
+ Del_PcmEx_Start(pcm2way_hdlr, NULL,
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_M2D_PATH);
+ break;
+ case P2W_APP_TYPE_VOIP:
+ case P2W_APP_TYPE_WITHOUT_CALL:
+ Idle_PcmEx_Start(pcm2way_hdlr, NULL,
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_M2D_PATH,
+ PCMEX_BAND_NB, PCMEX_IDLE_ENH_SETTING_WITH); // nb
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+
+void PCM2WAY_Stop(uint32 type)
+{
+ PcmEx_Stop();
+}
+
+
+
+uint16 PCM2WAY_GetFromMic(uint16 *ul_buf)
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ return PcmEx_GetFromMic1(ul_buf);
+// }
+}
+
+uint16 PCM2WAY_PutToSpk(const uint16 *dl_data)
+{
+ return PcmEx_PutToSpk(dl_data);
+}
+
+
+uint16 PCM2WAY_FillSpk(uint16 value)
+{
+ return PcmEx_FillSpk(value);
+}
+
diff --git a/mcu/driver/audio/src/v1/pcmRouter.c b/mcu/driver/audio/src/v1/pcmRouter.c
new file mode 100644
index 0000000..7404895
--- /dev/null
+++ b/mcu/driver/audio/src/v1/pcmRouter.c
@@ -0,0 +1,141 @@
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "l1audio_trace_utmd.h"
+#include "l1audio_sph_trc.h"
+#include "event_info_utility.h" // for MODEM_WARNING_MESSAGE
+
+#include "l1audio.h"
+#include "l1aud_common_def.h"
+#include "am.h"
+#include "sp_drv.h"
+#include "vm.h"
+#include "sp_enhance.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+
+#include "afe.h"
+#if defined(__CVSD_CODEC_SUPPORT__)
+#include "bt_sco_drv.h"
+#endif
+
+typedef struct {
+ bool isEnable;
+ bool isVocOn;
+
+ uint16 aud_id;
+
+
+} PCM_ROUTER_T;
+
+
+static PCM_ROUTER_T g_PcmRouter;
+
+// ============================================================================
+
+void PcmRouterStart(void)
+{
+
+ kal_uint32 module_id = MOD_L1AUDIO_SPH_SRV;
+ kal_uint32 voc_ptn = TVCI_CREATE_FILE;
+
+ //call cpd and lock sleep mode
+ g_PcmRouter.aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( g_PcmRouter.aud_id );
+
+ // force unmute to decople PS module
+ // turn on
+ AM_PcmRouter_On(0);
+
+ // voc
+ if(!tst_trace_check_ps_filter_off(TRACE_GROUP_VM, &module_id, 0x2))
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)&voc_ptn, 4);
+ VMREC_Start(NULL, true);
+ g_PcmRouter.isVocOn = true;
+ }
+
+ // turn on speech enhancement
+ SetSpeechEnhancement( true );
+
+ //always unmute DSP uplink when speech on (This is to keep the mute definition)
+ // SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_ALL);
+ // L1SP_MuteSpeaker(false);
+
+#if 0 // defined(__ECALL_SUPPORT__)
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+ if(SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD_MSBC
+ || SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD
+ || SP_GetDevInfo() == SPH_DEVINFO_BT_MSBC)
+ {
+ kal_uint8 voice8kMode = SP_GetDevSamplingRate();
+
+ if( (voice8kMode==0) || (voice8kMode==1) ) {
+ BT_SCO_SPEECH_ON(voice8kMode==1);
+ } else {
+ MODEM_WARNING_MESSAGE((voice8kMode==0), "PcmRouterStart(bt): incorrect Voice8kMode, %d", voice8kMode);
+ MODEM_WARNING_MESSAGE((voice8kMode==1), "PcmRouterStart(bt): incorrect Voice8kMode, %d", voice8kMode);
+ }
+
+ }
+#endif
+
+ g_PcmRouter.isEnable = true;
+}
+
+void PcmRouterStop(void)
+{
+ kal_uint32 voc_ptn = TVCI_CLOSE_FILE;
+
+ // due to AP will close DL directly before speech off, so md can mute dl directly without ramping
+ // This will prevent sound pushes to hardware buffer then cause noise
+ SAL_Mute_Ctrl(SAL_MUTE_DL_8K, KAL_TRUE); // to replace L1SP_MuteSpeaker(true);
+
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+ if(BT_SCO_IS_SPEECH_ON())
+ {
+ BT_SCO_SPEECH_OFF();
+ }
+#endif
+
+#if 0 // defined(__ECALL_SUPPORT__)
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+ SetSpeechEnhancement( false );
+
+ // voc
+ if(g_PcmRouter.isVocOn)
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)(&voc_ptn), 4);
+ VMREC_Stop(true);
+ g_PcmRouter.isVocOn = false;
+ }
+
+ // turn off
+ AM_PcmRouter_Off();
+
+ SAL_Mute_Ctrl(SAL_MUTE_DL_8K, KAL_FALSE);
+ //always unmute DSP uplink after speech off to keep the mute definition
+ SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_ALL);
+ L1SP_MuteSpeaker(false);
+
+ // leave the mute control to PS module
+
+ //unlock sleep mode and release CPD
+ L1Audio_ClearFlag( g_PcmRouter.aud_id );
+ L1Audio_FreeAudioID( g_PcmRouter.aud_id );
+ g_PcmRouter.aud_id = 0xffff;
+
+ g_PcmRouter.isEnable = false;
+}
diff --git a/mcu/driver/audio/src/v1/pcmrb.c b/mcu/driver/audio/src/v1/pcmrb.c
new file mode 100644
index 0000000..02e6d92
--- /dev/null
+++ b/mcu/driver/audio/src/v1/pcmrb.c
@@ -0,0 +1,836 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * PCMRB.c
+ *
+ * Project:
+ * --------
+ * Maui_sw
+ *
+ * Description:
+ * ------------
+ * PCMRB interface and driver, providing pcm ring buffer utility
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*****************************************************************************
+* C O M P I L E R F L A G S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* E X T E R N A L R E F E R E N C E S
+******************************************************************************
+*/
+#include "kal_public_api.h"
+#include "sync_data.h"
+//#include "kal_non_specific_general_types.h"
+//#include "kal_release.h"
+#include "string.h"
+
+#include "l1aud_common_def.h"
+#include "pcmrb.h"
+/*****************************************************************************
+* C O N S T A N T S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A T Y P E S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* P U B L I C D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* P R I V A T E D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* M A C R O S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N S
+******************************************************************************
+*/
+
+__inline int16 pcm_add( int32 x, int32 y )
+{
+#if defined(__TARGET_FEATURE_DSPMUL)
+ int32 xs, ys, rs;
+ __asm {
+ mov xs, x, lsl #16;
+ mov ys, y, lsl #16;
+ qadd rs, xs, ys;
+ }
+ return (int16)(rs >> 16);
+#else
+ x = x + y;
+ if( x>32767 )
+ x = 32767;
+ else if( x< -32768 )
+ x = -32768;
+
+ return (int16)x;
+#endif
+}
+
+void pcm_mix_n( int16 *dest, int16 *src, int32 n )
+{
+ do {
+ int32 x = *dest;
+ int32 y = *src++;
+ *dest++ = pcm_add( x, y );
+ } while( --n>0 );
+}
+
+/*
+ * Description
+ * ---------
+ * The function initializes the ring buffer instance.
+ *
+ * Syntax
+ * ---------
+ * bool PCMRB_Init( PCMRB *rb, int16 *buffer, int32 buffer_size )
+ *
+ * where
+ * rb The ring buffer instance
+ * buffer Address of the memory allocated for the ring buffer
+ * buffer_size Size of the memory allocated for the ring buffer
+ *
+ * Return Value
+ * ---------
+ * true
+ * false
+ */
+bool PCMRB_Init( PCMRB *rb, int16 *buffer, int32 buffer_size )
+{
+ ASSERT( rb!=NULL );
+
+ memset( buffer, 0, buffer_size*sizeof(int16) );
+ rb->buffer = buffer;
+ rb->size = buffer_size;
+ rb->read = 0;
+ rb->write = 0;
+
+ return true;
+}
+
+/*
+ * Description
+ * ---------
+ * The function returns the available free space of the ring buffer instance.
+ *
+ * Syntax
+ * ---------
+ * int32 PCMRB_GetFreeSpace( PCMRB *rb )
+ *
+ * where
+ * rb The ring buffer instance
+ *
+ * Return Value
+ * ---------
+ * the free space in words
+ */
+int32 PCMRB_GetFreeSpace( PCMRB *rb )
+{
+ int32 count;
+
+ ASSERT( rb!=NULL );
+
+ count = rb->read - rb->write - 1;
+ if( 0>count )
+ count += rb->size;
+ return count;
+}
+
+/*
+ * Description
+ * ---------
+ * The function returns available data count of the ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * int32 PCMRB_GetDataCount( PCMRB *rb )
+ *
+ * where
+ * rb The ring buffer instance
+ *
+ * Return Value
+ * ---------
+ * the data count in words
+ */
+int32 PCMRB_GetDataCount( PCMRB *rb )
+{
+ int32 count;
+
+ ASSERT( rb!=NULL );
+
+ count = rb->write - rb->read;
+ if( 0>count )
+ count += rb->size;
+ return count;
+}
+
+/*
+ * Description
+ * ---------
+ * The function copies data from a linear array to a ring buffer instance.
+ * The free space of the ring buffer instance shall be enough, or assertion will happen
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_Write( PCMRB *dest_rb, int16 *src_buffer, int32 size )
+ *
+ * where
+ * dest_rb The ring buffer instance
+ * src_buffer Address of the linear array
+ * size Size of copy
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_Write( PCMRB *dest_rb, int16 *src_buffer, int32 size )
+{
+ int16 *write_ptr;
+ int32 write_cnt;
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write size=%d",size);
+ ASSERT( dest_rb!=NULL );
+ ASSERT( PCMRB_GetFreeSpace( dest_rb )>=size );
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (int16 *)NULL ){
+ memset( write_ptr, 0, write_cnt*sizeof(int16) );
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write Null");
+ }else{
+ memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write %x %x %x %x", write_ptr, *(src_buffer+0),*(src_buffer+1),*(src_buffer+2));
+ }
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ size -= write_cnt;
+
+ if( size>0 )
+ {
+ if( src_buffer != (int16 *)NULL ) src_buffer += write_cnt;
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (int16 *)NULL ) memset( write_ptr, 0, write_cnt*sizeof(int16) );
+ else memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ }
+}
+
+//fsju
+void PCMRB_Write_from_DSP( PCMRB *dest_rb, volatile uint16 *src_buffer, int32 size )
+{
+ int16 *write_ptr;
+ int32 write_cnt;
+ int32 i;
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write size=%d",size);
+ ASSERT( dest_rb!=NULL );
+ ASSERT( PCMRB_GetFreeSpace( dest_rb )>=size );
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (volatile uint16 *)NULL ){
+ memset( write_ptr, 0, write_cnt*sizeof(int16) );
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write Null");
+ }else{
+ //memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+ for(i=0; i<write_cnt; i++)
+ {
+ write_ptr[i] = src_buffer[i];
+ }
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write %x %x %x %x", write_ptr, *(src_buffer+0),*(src_buffer+1),*(src_buffer+2));
+ }
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ size -= write_cnt;
+
+ if( size>0 )
+ {
+ if( src_buffer != (volatile uint16 *)NULL ) src_buffer += write_cnt;
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (volatile uint16 *)NULL )
+ {
+ memset( write_ptr, 0, write_cnt*sizeof(int16) );
+ }
+ else
+ {
+ //memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+ for(i=0; i<write_cnt; i++)
+ {
+ write_ptr[i] = src_buffer[i];
+ }
+ }
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ }
+}
+
+//fsju, for test, should remove
+void PCMRB_Write2( PCMRB *dest_rb, int16 *src_buffer, int32 size )
+{
+ int16 *write_ptr;
+ int32 write_cnt;
+ int32 i;
+ static short test_val = 0;
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write size=%d",size);
+ ASSERT( dest_rb!=NULL );
+ ASSERT( PCMRB_GetFreeSpace( dest_rb )>=size );
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (int16 *)NULL ){
+ memset( write_ptr, 0, write_cnt*sizeof(int16) );
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write Null");
+ }else{
+ //memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+ for(i=0; i<write_cnt; i++)
+ {
+ write_ptr[i] = test_val;
+ test_val++;
+ }
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Write %x %x %x %x", write_ptr, *(src_buffer+0),*(src_buffer+1),*(src_buffer+2));
+ }
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ size -= write_cnt;
+
+ if( size>0 )
+ {
+ if( src_buffer != (int16 *)NULL ) src_buffer += write_cnt;
+
+ PCMRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (int16 *)NULL )
+ {
+ memset( write_ptr, 0, write_cnt*sizeof(int16) );
+ }
+ else
+ {
+ //memcpy( write_ptr, src_buffer, write_cnt*sizeof(int16) );
+ for(i=0; i<write_cnt; i++)
+ {
+ write_ptr[i] = test_val;
+ test_val++;
+ }
+ }
+
+ PCMRB_ShiftWritePointer( dest_rb, write_cnt );
+ }
+}
+//fsju add end
+
+/*
+ * Description
+ * ---------
+ * The function copies data from a ring buffer instance to a linear array
+ * The data count of the ring buffer instance shall be enough, or assertion will happen
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_Read( PCMRB *src_rb, int16 *dest_buffer, int32 size )
+ *
+ * where
+ * src_rb The ring buffer instance
+ * dest_buffer Address of the linear array
+ * size Size of copy
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_Read( PCMRB *src_rb, int16 *dest_buffer, int32 size )
+{
+ int16 *read_ptr;
+ int32 read_cnt;
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Read size=%d",size);
+ ASSERT( src_rb!=NULL );
+ ASSERT( PCMRB_GetDataCount( src_rb )>=size );
+
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ size -= read_cnt;
+
+ if( size>0 )
+ {
+ dest_buffer += read_cnt;
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ }
+}
+
+//fsju
+void PCMRB_Read_to_DSP( PCMRB *src_rb, volatile uint16 *dest_buffer, int32 size )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else //#if 0
+ int16 *read_ptr;
+ int32 read_cnt;
+ int32 i;
+ //volatile uint16* ptr_dest_buffer = dest_buffer;
+/// kal_prompt_trace(MOD_L1SP, "PCMRB_Read size=%d",size);
+ ASSERT( src_rb!=NULL );
+ ASSERT( PCMRB_GetDataCount( src_rb )>=size );
+
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ //memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ for(i=0; i<read_cnt; i++)
+ {
+ dest_buffer[i] = read_ptr[i];
+ }
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ size -= read_cnt;
+
+ if( size>0 )
+ {
+ dest_buffer += read_cnt;
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ //memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ for(i=0; i<read_cnt; i++)
+ {
+ dest_buffer[i] = read_ptr[i];
+ }
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ }
+
+ Data_Sync_Barrier();
+#endif //#if 0
+}
+
+
+void PCMRB_Read_to_DSP_Padding( PCMRB *src_rb, volatile uint16 *dest_buffer, int32 size )
+{
+ int16 *read_ptr;
+ int32 read_cnt;
+ int32 i;
+ //32k 20ms
+ uint32 buffered_data[640/sizeof(uint32)];
+ int32 read_cnt_total;
+
+ ASSERT( src_rb!=NULL );
+ //ASSERT( PCMRB_GetDataCount( src_rb )>=size );
+
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding1: read_cnt=%d, size=%d", read_cnt, size);
+ if( read_cnt>size ) read_cnt = size;
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding1: read_cnt=%d, size=%d", read_cnt, size);
+ for(i=0; i<read_cnt; i++)
+ {
+ dest_buffer[i] = read_ptr[i];
+ buffered_data[i] = read_ptr[i];
+ }
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding1: src_rb->read=%d, src_rb->write=%d", src_rb->read, src_rb->write);
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding1: src_rb->read=%d, src_rb->write=%d", src_rb->read, src_rb->write);
+ size -= read_cnt;
+ dest_buffer += read_cnt;
+ read_cnt_total = read_cnt;
+
+ if( size>0 )
+ {
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding2: read_cnt=%d, size=%d", read_cnt, size);
+ if( read_cnt>size ) read_cnt = size;
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding2: read_cnt=%d, size=%d", read_cnt, size);
+ for(i=0; i<read_cnt; i++)
+ {
+ dest_buffer[i] = read_ptr[i];
+ buffered_data[i+read_cnt_total] = read_ptr[i];
+ }
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding2: src_rb->read=%d, src_rb->write=%d", src_rb->read, src_rb->write);
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding2: src_rb->read=%d, src_rb->write=%d", src_rb->read, src_rb->write);
+ size -= read_cnt;
+ dest_buffer += read_cnt;
+ read_cnt_total += read_cnt;
+ }
+
+ //padding
+ while(size > 0)
+ {
+ read_cnt = read_cnt_total;
+ //kal_prompt_trace(MOD_L1SP, "PCMRB_Read_to_DSP_Padding3: read_cnt=%d, size=%d", read_cnt, size);
+ if(read_cnt > size)
+ {
+ read_cnt = size;
+ }
+ for(i=0; i<read_cnt; i++)
+ {
+ dest_buffer[i] = buffered_data[i];
+ }
+ size -= read_cnt;
+ dest_buffer += read_cnt;
+ }
+
+ Data_Sync_Barrier();
+}
+
+
+void PCMRB_ShiftReadPointer2( PCMRB *src_rb, int32 size )
+{
+ int16 *read_ptr;
+ int32 read_cnt;
+
+ ASSERT( src_rb!=NULL );
+ ASSERT( PCMRB_GetDataCount( src_rb )>=size );
+
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ //memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ size -= read_cnt;
+
+ if( size>0 )
+ {
+ //dest_buffer += read_cnt;
+ PCMRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size ) read_cnt = size;
+ // memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ PCMRB_ShiftReadPointer( src_rb, read_cnt );
+ }
+}
+/*
+ * Description
+ * ---------
+ * The function returns the linear write block and its size of a ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_GetWriteBlock( PCMRB *dest_rb, int16 **write_ptr, int32 *write_cnt )
+ *
+ * where
+ * dest_rb The ring buffer instance
+ * write_ptr Address of the memory to put the address of the linear write block
+ * write_cnt Address of the memory to put the size of the linear write block
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_GetWriteBlock( PCMRB *dest_rb, int16 **write_ptr, int32 *write_cnt )
+{
+ int32 cnt;
+
+ ASSERT( (dest_rb!=NULL) && (write_ptr!=NULL) && (write_cnt!=NULL) );
+
+ if( dest_rb->read>dest_rb->write )
+ cnt = dest_rb->read - dest_rb->write - 1;
+ else if( dest_rb->read==0 )
+ cnt = dest_rb->size - dest_rb->write - 1;
+ else
+ cnt = dest_rb->size - dest_rb->write;
+
+ *write_cnt = cnt;
+ *write_ptr = &dest_rb->buffer[dest_rb->write];
+}
+
+/*
+ * Description
+ * ---------
+ * The function returns the linear read block and its size of a ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_GetReadBlock( PCMRB *src_rb, int16 **read_ptr, int32 *read_cnt )
+ *
+ * where
+ * src_rb The ring buffer instance
+ * read_ptr Address of the memory to put the address of the linear read block
+ * read_cnt Address of the memory to put the size of the linear read block
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_GetReadBlock( PCMRB *src_rb, int16 **read_ptr, int32 *read_cnt )
+{
+ int32 cnt;
+
+ ASSERT( (src_rb!=NULL) && (read_ptr!=NULL) && (read_cnt!=NULL) );
+
+ if( src_rb->write == src_rb->read )
+ cnt = 0;
+ else if( src_rb->write>src_rb->read )
+ cnt = src_rb->write - src_rb->read;
+ else
+ cnt = src_rb->size - src_rb->read;
+
+ *read_cnt = cnt;
+ *read_ptr = &src_rb->buffer[src_rb->read];
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function shifts the write pointer of a ring buffer instance in circular way
+ * Use this with PCMRB_GetWriteBlock
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_ShiftWritePointer( PCMRB *rb, int32 shamt )
+ *
+ * where
+ * rb The ring buffer instance
+ * shamt shift amount
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_ShiftWritePointer( PCMRB *rb, int32 shamt )
+{
+ ASSERT( rb!=NULL );
+
+ rb->write += shamt;
+ if( rb->write>=rb->size )
+ rb->write -= rb->size;
+}
+
+/*
+ * Description
+ * ---------
+ * The function shifts the read pointer of a ring buffer instance in circular way
+ * Use this with PCMRB_GetReadBlock
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_ShiftReadPointer( PCMRB *rb, int32 shamt )
+ *
+ * where
+ * rb The ring buffer instance
+ * shamt shift amount
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void PCMRB_ShiftReadPointer( PCMRB *rb, int32 shamt )
+{
+ ASSERT( rb!=NULL );
+
+ rb->read += shamt;
+ if( rb->read>=rb->size )
+ rb->read -= rb->size;
+}
+
+/*
+ * Description
+ * ---------
+ * The function mixes two ring buffer instance without shift their pointers
+ *
+ * Syntax
+ * ---------
+ * void PCMRB_Mix( PCMRB *dest_rb, PCMRB *src_rb )
+ *
+ * where
+ * dest_rb One of the input ring buffer, also the output ring buffer
+ * src_rb One of the input ring buffer
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+ void PCMRB_Mix( PCMRB *dest_rb, PCMRB *src_rb, int32 size )
+{
+ int32 dest_rb_write, src_rb_read;
+
+ ASSERT( dest_rb!=NULL );
+ ASSERT( src_rb!=NULL );
+ ASSERT( PCMRB_GetFreeSpace( dest_rb )>=size );
+ ASSERT( PCMRB_GetDataCount( src_rb )>=size );
+
+ dest_rb_write = dest_rb->write;
+ src_rb_read = src_rb->read;
+ while( 1 )
+ {
+ int32 cnt_write, cnt_read;
+ int16 *dest_rb_buf, *src_rb_buf;
+ int32 cnt;
+ if( src_rb->write>src_rb_read )
+ cnt_read = src_rb->write - src_rb_read;
+ else
+ cnt_read = src_rb->size - src_rb_read;
+ if( dest_rb->read>dest_rb_write )
+ cnt_write = dest_rb->read - dest_rb_write;
+ else
+ cnt_write = dest_rb->size - dest_rb_write;
+ cnt = (cnt_read<cnt_write)? cnt_read: cnt_write;
+ if( cnt>size ) cnt = size;
+
+ dest_rb_buf = dest_rb->buffer + dest_rb_write;
+ src_rb_buf = src_rb->buffer + src_rb_read;
+
+ pcm_mix_n( dest_rb_buf, src_rb_buf, cnt );
+
+ size -= cnt;
+ if( size==0 )
+ break;
+
+ dest_rb_write += cnt;
+ if( dest_rb_write==dest_rb->size )
+ dest_rb_write = 0;
+ src_rb_read += cnt;
+ if( src_rb_read==src_rb->size )
+ src_rb_read = 0;
+ }
+
+}
+
+
diff --git a/mcu/driver/audio/src/v1/rawpcmrec_drv.c b/mcu/driver/audio/src/v1/rawpcmrec_drv.c
new file mode 100644
index 0000000..60ec64f
--- /dev/null
+++ b/mcu/driver/audio/src/v1/rawpcmrec_drv.c
@@ -0,0 +1,300 @@
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "l1audio_trace_utmd.h"
+
+
+#include "am.h"
+#include "media.h" // for EMI_ReadFromDSP
+#include "rawpcmrec.h"
+#include "audio_dsp_d2c_def.h"
+#include "sal_exp.h"
+#include "sal_def.h"
+
+
+// ----------------------------------------------------------------------------
+// Structure
+// ----------------------------------------------------------------------------
+
+static struct{
+ kal_spinlockid lockId;
+ kal_uint16 audId;
+
+ kal_bool isRecording; //state information.
+
+ void (*RawPcmRec_hdlr)(void);
+
+ PCM_REC_SAMPLE_RATE_IDX inSampleRateIdx; // DSP to MCU sampling rate.
+ kal_bool isDedicatedMode; //recording under speech is on, DSP to MCU sampling rate is sync with codec
+ kal_bool skip_hisr;
+}RawPcmRec;
+
+
+// ----------------------------------------------------------------------------
+// Define
+// ----------------------------------------------------------------------------
+
+#define RAW_PCM_REC_FRAME_BUF_SIZE_8K (160)
+#define RAW_PCM_REC_FRAME_BUF_SIZE_16K (320)
+#define RAW_PCM_REC_FRAME_BUF_SIZE_32K (640)
+#define RAW_PCM_REC_FRAME_BUF_SIZE_48K (960)
+
+//header + sample*2ch(UL+DL)*2byte
+#define RAW_PCM_TOTAL_BUFFER_BYTE_SIZE (sizeof(spcRAWPCMBufInfo) + RAW_PCM_REC_FRAME_BUF_SIZE_48K*2*2)
+
+// ----------------------------------------------------------------------------
+// buffers and varables
+// ----------------------------------------------------------------------------
+
+// static kal_uint16 dualMicOrDlTempBuf[RAW_PCM_REC_FRAME_BUF_SIZE_48K];
+static kal_uint32 RawPcmRecBuf[(RAW_PCM_TOTAL_BUFFER_BYTE_SIZE+3)>>2];
+static spcRAWPCMBufInfo *pstspcRAWPCMBufInfo;
+static kal_uint16 *pRawPcmRecBufData;
+
+
+extern bool spc_RawPcmRec_getDataWaiting(void);
+
+
+/**
+ @buf1: pointer to pcm buf1,
+ @len1:length of buf1, unit is word(2byte)
+ @buf2:pointer to pcm buf2
+ @len2: length of buf2. unit is word(2byte)
+*/
+void RawPcmRec_GetMicDataBufs(kal_uint32 *add1, kal_uint16 *len1, kal_uint32 *add2, kal_uint16 *len2)
+{
+ *add1 = (kal_uint32)(RawPcmRecBuf);
+ *len1 = (sizeof(spcRAWPCMBufInfo) + pstspcRAWPCMBufInfo->u16ULLength + pstspcRAWPCMBufInfo->u16DLLength) >> 1;
+ *add2 = 0;
+ *len2 = 0;
+
+ MD_TRC_RAWPCMREC_GET_MIC_DATA_BUFS(RawPcmRecBuf, sizeof(spcRAWPCMBufInfo), pstspcRAWPCMBufInfo->u16ULLength, pstspcRAWPCMBufInfo->u16DLLength);
+}
+
+
+void RawPcmRec_GetMicDataFromDSP(kal_uint16 * buf)
+{
+ volatile uint16* dspAddr;
+ uint32 framesize = 0; //uplink
+ uint16 dlFrameSize = 0;
+
+ {
+ if(RawPcmRec.isDedicatedMode) { // under call
+
+ framesize = SAL_PcmEx_GetBufLen(SAL_PCMEX_BUF_SE);
+ ASSERT(framesize <= RAW_PCM_REC_FRAME_BUF_SIZE_48K);
+ dspAddr = SAL_PcmEx_GetBuf(SAL_PCMEX_BUF_SE);
+ MD_TRC_RAWPCMREC_HISR_DATA_FROM_DSP(dspAddr, framesize);
+ EMI_ReadFromDSP(buf, dspAddr, (uint32)framesize);
+
+ switch(framesize)
+ {
+ case RAW_PCM_REC_FRAME_BUF_SIZE_8K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_8K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_8K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_16K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_16K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_16K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_32K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_32K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_32K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_48K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_48K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_48K<<1; //unit is byte
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_UNDEF;
+ pstspcRAWPCMBufInfo->u16DLLength = 0;
+
+ // get downlink data
+ dlFrameSize = SAL_PcmEx_GetBufLen(SAL_PCMEX_BUF_SD);
+ ASSERT(dlFrameSize <= RAW_PCM_REC_FRAME_BUF_SIZE_48K);
+ dspAddr = SAL_PcmEx_GetBuf(SAL_PCMEX_BUF_SD);
+ MD_TRC_RAWPCMREC_HISR_DATA_FROM_DSP(dspAddr, dlFrameSize);
+ EMI_ReadFromDSP(/*dualMicOrDlTempBuf*/buf+framesize, dspAddr, (uint32)dlFrameSize);
+
+ switch(dlFrameSize)
+ {
+ case RAW_PCM_REC_FRAME_BUF_SIZE_8K:
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_8K;
+ pstspcRAWPCMBufInfo->u16DLLength = RAW_PCM_REC_FRAME_BUF_SIZE_8K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_16K:
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_16K;
+ pstspcRAWPCMBufInfo->u16DLLength = RAW_PCM_REC_FRAME_BUF_SIZE_16K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_32K:
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_32K;
+ pstspcRAWPCMBufInfo->u16DLLength = RAW_PCM_REC_FRAME_BUF_SIZE_32K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_48K:
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_48K;
+ pstspcRAWPCMBufInfo->u16DLLength = RAW_PCM_REC_FRAME_BUF_SIZE_48K<<1; //unit is byte
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ MD_TRC_RAWPCMREC_GET_DATA_INFO(1, pstspcRAWPCMBufInfo->u16ULFreq, pstspcRAWPCMBufInfo->u16ULLength, pstspcRAWPCMBufInfo->u16DLFreq, pstspcRAWPCMBufInfo->u16DLLength);
+
+ } else { // idle
+ //framesize = RawPcmRec.outputFrameSize;
+
+ framesize = SAL_PcmEx_GetBufLen(SAL_PCMEX_BUF_SE);
+ ASSERT(framesize <= RAW_PCM_REC_FRAME_BUF_SIZE_48K);
+
+ /* handle uplink data */
+ dspAddr = SAL_PcmEx_GetBuf(SAL_PCMEX_BUF_SE);
+ //kal_prompt_trace(MOD_L1SP, "*DPRAM2_base(SPH_DM_ADDR_SE_PTR) = %x", dspAddr);
+ //dspAddr = *DSP_DM_ADDR(PCM_REC_PAGE_NUM, dspAddr);
+ MD_TRC_RAWPCMREC_HISR_DATA_FROM_DSP(dspAddr, framesize);
+
+ EMI_ReadFromDSP(buf, dspAddr, (uint32)framesize);
+
+ switch(framesize)
+ {
+ case RAW_PCM_REC_FRAME_BUF_SIZE_8K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_8K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_8K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_16K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_16K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_16K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_32K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_32K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_32K<<1; //unit is byte
+ break;
+ case RAW_PCM_REC_FRAME_BUF_SIZE_48K:
+ pstspcRAWPCMBufInfo->u16ULFreq = PCM_REC_SAMPLE_RATE_IDX_48K;
+ pstspcRAWPCMBufInfo->u16ULLength = RAW_PCM_REC_FRAME_BUF_SIZE_48K<<1; //unit is byte
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ pstspcRAWPCMBufInfo->u16DLFreq = PCM_REC_SAMPLE_RATE_IDX_UNDEF;
+ pstspcRAWPCMBufInfo->u16DLLength = 0;
+
+ MD_TRC_RAWPCMREC_GET_DATA_INFO(2, pstspcRAWPCMBufInfo->u16ULFreq, pstspcRAWPCMBufInfo->u16ULLength, pstspcRAWPCMBufInfo->u16DLFreq, pstspcRAWPCMBufInfo->u16DLLength);
+ }
+
+ }
+
+}
+
+
+void RawPcmRecHisr(void *param)
+{
+ if (KAL_SPINLOCK_NOT_AVAILABLE == kal_take_spinlock(RawPcmRec.lockId, KAL_NO_WAIT)) {
+ MD_TRC_RAWPCMREC_HISR_LOCK_NOT_AVALIABLE();
+ return;
+ }
+ if(KAL_TRUE == RawPcmRec.skip_hisr) {
+ kal_give_spinlock(RawPcmRec.lockId);
+ return;
+ }
+ // check the buffer
+ if(true == spc_RawPcmRec_getDataWaiting()) {
+ //leave the log when buffer is full
+ MD_TRC_RAWPCMREC_HISR_DATA_DROP_DSP();
+ } else { // There has some empty buffer
+ //get from dsp
+ RawPcmRec_GetMicDataFromDSP(pRawPcmRecBufData);
+ }
+ kal_give_spinlock(RawPcmRec.lockId);
+ //excute callback function
+ RawPcmRec.RawPcmRec_hdlr();
+}
+
+
+/**
+ @dlPos: definition same as SAL_PCMREC_DL_POS_xx in sal_def.h
+ 0: DL end
+ 1: POS ENH
+ 2: Pre Mixer2
+*/
+void RAWPCMREC_Start(void (*RawPcmRec_hdlr)(void), kal_uint8 dlPos)
+{
+
+ // lock sleep mode
+ RawPcmRec.audId = L1Audio_GetAudioID();
+ L1Audio_SetFlag( RawPcmRec.audId );
+
+ RawPcmRec.isDedicatedMode = AM_IsAmInSpeechState();
+ RawPcmRec.RawPcmRec_hdlr = RawPcmRec_hdlr;
+
+ memset(RawPcmRecBuf, 0, sizeof(RawPcmRecBuf));
+ pstspcRAWPCMBufInfo = (pspcRAWPCMBufInfo)(RawPcmRecBuf);
+ pRawPcmRecBufData = (kal_uint16 *)(RawPcmRecBuf);
+ pRawPcmRecBufData = pRawPcmRecBufData + ( sizeof(spcRAWPCMBufInfo) / sizeof(kal_uint16) );
+
+ L1Audio_HookHisrHandler( DP_D2C_PCM_REC_INT, RawPcmRecHisr, 0);
+
+ // invoke am to start record
+ if(RawPcmRec.isDedicatedMode) {
+ RawPcmRec.inSampleRateIdx = PCM_REC_SAMPLE_RATE_IDX_UNDEF; // dynamic
+ AM_PCM8K_RecordOn(AM_PCM8KREC_APP_TYPE_PCMREC, dlPos);
+ }else {
+ RawPcmRec.inSampleRateIdx = PCM_REC_SAMPLE_RATE_IDX_16K;
+ AM_PCM16K_RecordOn(dlPos);
+ }
+
+ RawPcmRec.isRecording = KAL_TRUE;
+ RawPcmRec.skip_hisr = KAL_FALSE;
+}
+
+
+
+void RAWPCMREC_Stop()
+{
+ kal_take_spinlock(RawPcmRec.lockId, KAL_INFINITE_WAIT);
+ RawPcmRec.skip_hisr = KAL_TRUE;
+ kal_give_spinlock(RawPcmRec.lockId);
+ if (RawPcmRec.isDedicatedMode) {
+
+ AM_PCM8K_RecordOff(false, AM_PCM8KREC_APP_TYPE_PCMREC); // do not need toe wait
+ // L1Audio_UnhookHisrHandler(D2C_UL_DL_PCM_REC_INT_ID); //vocTchPcmRecordHisr
+
+ } else {
+
+ if(PCM_REC_SAMPLE_RATE_IDX_8K == RawPcmRec.inSampleRateIdx) {
+
+ AM_PCM8K_RecordOff(true, AM_PCM8KREC_APP_TYPE_PCMREC);
+
+ } else if(PCM_REC_SAMPLE_RATE_IDX_16K == RawPcmRec.inSampleRateIdx) {
+
+ AM_PCM16K_RecordOff(true);
+
+ } else {
+ ASSERT(0); // invalid input sampling rate.
+ }
+ // L1Audio_UnhookHisrHandler(DP_D2C_PCM_REC_INT);
+ }
+ L1Audio_UnhookHisrHandler(DP_D2C_PCM_REC_INT);
+ RawPcmRec.isRecording = KAL_FALSE;
+
+ kal_take_spinlock(RawPcmRec.lockId, KAL_INFINITE_WAIT);
+ RawPcmRec.isDedicatedMode = KAL_FALSE;
+ kal_give_spinlock(RawPcmRec.lockId);
+ RawPcmRec.inSampleRateIdx = PCM_REC_SAMPLE_RATE_IDX_UNDEF;
+
+ // unlock sleep
+ L1Audio_ClearFlag( RawPcmRec.audId );
+ L1Audio_FreeAudioID( RawPcmRec.audId );
+
+}
+
+void RAWPcmRec_Init()
+{
+ RawPcmRec.lockId = kal_create_spinlock("rawpcmrec_spinlock");
+}
diff --git a/mcu/driver/audio/src/v1/sp_3g.c b/mcu/driver/audio/src/v1/sp_3g.c
new file mode 100644
index 0000000..44196c3
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_3g.c
@@ -0,0 +1,2601 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_3g.c
+ *
+ * Project:
+ * --------
+ * Maui
+ *
+ * Description:
+ * ------------
+ * 3G speech interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *******************************************************************************/
+
+//#define TK6291_FAKE_COMPILE
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "sync_data.h"
+//#include "string.h"
+#include "kal_trace.h"
+#include "reg_base.h"
+//MPD
+//#include "l4_ps_api.h"
+#include "ps_em_exported_enum.h"
+//#include "l4_ps_api_public.h"
+extern ps_conf_test_mode_enum query_ps_conf_test_mode(void);
+
+//#include "speech_def.h"
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+//#ifndef TK6291_FAKE_COMPILE
+//#include "uas_export_api.h"
+#include "csr_export_api.h"
+//#endif //#ifndef TK6291_FAKE_COMPILE
+#include "am.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "l1sp_trc.h"
+#include "amr_table.h"
+
+#include "sal_exp.h"
+#include "sal_def.h"
+
+#include "sp_enhance.h"
+#include "sp_cc.h"
+
+#if defined(__VOLTE_SUPPORT__)
+#include "sp_ps.h"
+#endif
+#ifdef __VIDEO_CALL_SUPPORT__
+extern void vt_SP3G_Callback( kal_uint8 event, void *data );
+#endif
+
+extern const kal_uint16* tblAMR_WBOrder[9];
+
+#define __DLDCH_DELAY_IMPROVE__
+#if defined(__DLDCH_DELAY_IMPROVE__)
+#define __SP3G_UL_DSP_RESYNC_CSR__
+#define __SP3G_DIRECT_TO_DSP__
+#define ust_get_duration_true(prev, cur) (((cur) >= (prev))? (((cur) - (prev))): ((USCNT_WRAP - (prev) + (cur))))
+#endif
+
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+#include "us_timer.h"
+
+
+
+#define MINIMUM_DELAY_READ_THRESHOLD 14
+#endif
+
+extern kal_enhmutexid sp_handover_mutex;//sp_4g.c
+
+
+#if defined( __UMTS_RAT__ )
+
+#define _EXTRA_LOG_FOR_BIT_TRUE_
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+kal_bool CS_NeedSpeechExtraLog( void );
+kal_bool g_bNeedExtraLog;
+#endif
+
+extern void L1SP_3G_Request(void);
+kal_uint32 SP4G_GetCodecMode(void);
+
+
+
+#define AMR_SID_FRAME 8
+#define AMR_NO_DATA 15
+
+#define AWB_SID_FRAME 9
+#define WB_AMR_SID_FRAME 25
+#define UL_HARD_REAL_TIME_DEMAND
+
+#define UL_MAX_DATA_SIZE 62 // frame_type, UL : len / DL : FQI_flag , DATA(23.85=>60)
+#define DL_MAX_DATA_SIZE 66 // frame_type, UL : len / DL : FQI_flag , CFN(4 bytes), DATA(23.85=>60)
+#define MAX_DSP_FRAME_LEN 30
+
+
+#define MAXIMUM_UL_DELAY 15 // CSR define for debug
+#define START_SHRINK_UL_DELAY 10 // L1Audio shrink UL delay from 40ms to 20ms
+
+
+#define HARD_REAL_TIME_UL_BUFFER_NUM 1 // could not revise
+#define RAT_3G_UL_BUFFER_NUM 2 // could not revise
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ #define RAT_3G_DL_BUFFER_NUM 1 // do not suggest to revise
+ #define RAT_3G_DL_BUFFER_NUM_BEFORE_RESYNC 2 // do not suggest to revise
+#else
+ #define RAT_3G_DL_BUFFER_NUM 2 // do not suggest to revise
+ #define RAT_3G_DL_BUFFER_NUM_BEFORE_RESYNC 2 // do not suggest to revise
+#endif
+
+#ifdef __VIDEO_CALL_SUPPORT__
+ #define MAX_3G_UL_BUFFER_NUM 5
+ #define MAX_3G_DL_BUFFER_NUM 20
+#elif defined(__CSHSPA_SUPPORT__)
+ #define MAX_3G_UL_BUFFER_NUM 2
+ //In theory, Max CS delay is 200ms at most, which is 10 frames
+ #define MAX_3G_DL_BUFFER_NUM 10
+#else
+ #define MAX_3G_UL_BUFFER_NUM RAT_3G_UL_BUFFER_NUM
+ #define MAX_3G_DL_BUFFER_NUM RAT_3G_DL_BUFFER_NUM_BEFORE_RESYNC
+#endif
+
+#define __SP3G_DL_BUFFER_BEFORE_PLAY__
+/* Enable more buffering before put frame to DSP to keep start of speech smooth.
+ If not defined this compile option, it can reduce delay but maybe can't cover the initial discontinous.
+*/
+
+// here should be careful for this will limit MAX_DL_BUFFER_NUM to 1 << DL_BUF_INDEX_BIT_NUM
+// and MAX_UL_BUFFER_NUM to 1 << UL_BUF_INDEX_BIT_NUM
+#define DL_BUF_INDEX_BIT_NUM 5
+#define UL_BUF_INDEX_BIT_NUM (8 - DL_BUF_INDEX_BIT_NUM)
+
+#define SP3G324M_DL_EXTRA_LEN 5//frameType(1), len(1), l1_frame : recieve(3)
+#define SP3G_DL_EXTRA_LEN 6//frameType(1), FQI_flag(1), CFN(4)(unit:byte)
+
+//AMRWB 23.85 classB 405 bits=>51 bytes
+#define MAX_BYTES_IN_SINGLE_SUBFLOW ((405 + 7)>>3)
+#define _IGNORE_TYPE_ERROR_ // for 3G324M since the CRC is weaker, it's possible wrong pattern.
+ // so ignore it instead of assert.
+
+typedef struct
+{
+ uint16 dsp_buffer[MAX_DSP_FRAME_LEN];
+ uint16 dsp_buffer_dl[MAX_DSP_FRAME_LEN];
+ uint8 dl_buffer[MAX_3G_DL_BUFFER_NUM][DL_MAX_DATA_SIZE];
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ uint8 dl_buffer2[MAX_3G_DL_BUFFER_NUM][DL_MAX_DATA_SIZE];
+#endif
+ /*0: CFN, 1:RSSI|RSCP|ECIO|HHO_SHO ,2:crc_result ,3:s_value[0], 4:tpc_SIR_lta, 5:dpdch_SIR_lta, 6:TFCI_max_corr */
+ uint32 L1_Info[4][7];
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ uint32 int_time[5];//0: UL, 1: DL, 2: temp UL, 3: DSP UL time, 4: send DSP resync time
+ bool ul_request_resync;
+ uint8 uDelW;
+#endif
+ uint8 ul_buffer[MAX_3G_UL_BUFFER_NUM][UL_MAX_DATA_SIZE]; // prevent sp3g_hisr , CSR race condition
+ uint8 ul_write_idx;
+ uint8 ul_read_idx;
+ uint8 ul_count;
+ bool is_getting_ul_data;
+ uint8 ul_delay;
+ uint8 dl_count;
+ uint8 dl_write_idx;
+ uint8 dl_read_idx;
+ bool under_interact;
+ uint8 ul_codec_mode;
+ uint8 ul_report;
+ uint8 dl_report;
+ uint8 pre_ul_report;
+ uint8 pre_dl_report;
+ bool waiting; // 1-message-1-get policy
+ bool ul_refresh; // detect change codec_mode
+ uint8 l1_info_idx;
+ uint8 sp3g_mode;
+ uint8 ul_buffer_size;
+ uint8 dl_buffer_size;
+ uint8 dtx_state; //enter dtx mode
+ uint8 dtx_force; //occured that force AMR frame
+#if defined(__CSHSPA_SUPPORT__)
+ uint8 dl_subflow[MAX_BYTES_IN_SINGLE_SUBFLOW];
+#endif
+}SP3G_Struct;
+
+static SP3G_Struct sp3gInfo;
+SP3G_Struct *sp3g;
+kal_spinlockid sp3g_spinlockID;
+static kal_uint32 sp3g_rab_id;
+static kal_bool sp3g_rab_state;
+static kal_bool sp3g_is_csr_ready;
+static kal_uint32 l1AInfo;
+
+static kal_uint8 sp3g_reset_flag; // speech on and InterRAT : set TRUE
+static kal_bool sp3g_dtx_mode;
+#if defined(__CSHSPA_SUPPORT__)
+static kal_uint8 sp3g_max_cs_delay;
+#endif
+
+
+#define INIT_3G_CODEC (0xA) //// 4.75 NB AMR
+
+const uint16 RAB_subflow[][4] = {
+ {42, 53, 0, 13}, // 4.75
+ {49, 54, 0, 14}, // 5.15
+ {55, 63, 0, 15}, // 5.9
+ {58, 76, 0, 18}, // 6.7
+ {61, 87, 0, 19}, // 7.4
+ {75, 84, 0, 21}, // 7.95
+ {65, 99, 40, 27}, // 10.2
+ {81, 103,60, 32}, // 12.2
+ {39, 0, 0, 5}, // SID
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // For Future use
+ {8, 0, 0, 0}, // AMR NoData
+
+/* TS26.201, Table 7 */
+ {54, 78, 0, 17},/* WB type 0, AMR-WB 6.60 */
+ {64, 113, 0, 23},/* WB type 1, AMR-WB 8.85 */
+ {72, 181, 0, 32},/* WB type 2, AMR-WB 12.65 */
+ {72, 213, 0, 36},/* WB type 3, AMR-WB 14.25 */
+ {72, 245, 0, 40},/* WB type 4, AMR-WB 15.85 */
+ {72, 293, 0, 46},/* WB type 5, AMR-WB 18.25 */
+ {72, 325, 0, 50},/* WB type 6, AMR-WB 19.85 */
+ {72, 389, 0, 58},/* WB type 7, AMR-WB 23.05 */
+ {72, 405, 0, 60},/* WB type 8, AMR-WB 23.85 */
+ {40, 0, 0, 5}/* WB type 9, AMR-WB SID */
+/* WB type 10-13, Not Used */
+
+};
+
+const uint8 RAB_Order[8] = {
+ 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 /* bits order of AMR frame */
+};
+
+const uint16 DSP_Order[16] = {
+ 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, /* bits order of SHERIF */
+ 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
+};
+#ifdef __VIDEO_CALL_SUPPORT__
+const uint8 AMR_IF2_Order[8] = {
+ 0x10,0x20,0x40,0x80,0x01,0x02,0x04,0x08 /* bits order of AMR IF2 frame */
+};
+
+const uint8 AMR_IF2_FRAME_LENGTH[16] = {/* byte length of AMR IF2 frame */
+ 13, 14, 16, 18, 19, 21, 26, 31, 6,
+ 0 , 0, 0, 0, 0, 0, 1
+};
+#endif
+
+const uint8 AmrFrameType2DspMode[25] = {0x0A, 0x09, 0x08, 0x07, 0x06,
+ 0x05, 0x04, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x21, 0x22, 0x23,
+ 0x24, 0x25, 0x26, 0x27, 0x28};
+
+ //** From {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00};
+ //** mapping to
+const uint8 NB_DspMode2AmrFrameType[17] = {0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+
+ //** From {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28};
+ //** mapping to
+const uint8 WB_DspMode2AmrFrameType[17] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+
+ //** From {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00};
+ //** mapping to
+const uint8 NB_DspModeLen[17] = {0x10, 0x0D, 0x0A, 0x0A, 0x09, 0x08, 0x07, 0x06};
+
+ //** From {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28};
+ //** mapping to
+const uint8 WB_DspModeLen[17] = {0x09, 0x0C, 0x10, 0x12, 0x14, 0x17, 0x19, 0x1D, 0x1E};
+
+
+#define GetFrameType2DspMode(ftype) (AmrFrameType2DspMode[(ftype)])
+#define GetDspMode2FrameType(mode) (((0x20 <= (mode)) && ((mode) <= 0x28)) ? (WB_DspMode2AmrFrameType[(mode)-0x20]) : \
+ (((0x03 <= (mode)) && ((mode) <= 0x0A)) ? (NB_DspMode2AmrFrameType[(mode)-0x03]) : (-1)))
+
+#define GetDspModeLen(mode) (((0x20 <= (mode)) && ((mode) <= 0x28)) ? (WB_DspModeLen[(mode)-0x20]) : \
+ (((0x03 <= (mode)) && ((mode) <= 0x0A)) ? (NB_DspModeLen[(mode)-0x03]) : (0x00)))
+
+#define GetRab2DspMapping(ftype) (((0x10 <= (ftype)) && ((ftype) <= 0x18)) ? (tblAMR_WBOrder[(ftype) - 0x10]) : \
+ (((0x00 <= (ftype)) && ((ftype) <= 0x07)) ? (tblAMROrder[(ftype)-0x00]) : (0)))
+
+
+
+extern const uint8* tblAMROrder[8];
+
+#define AMR_DATA_LOG
+#ifdef __FAKE_3G_LOOPBACK__
+void fake_CSR_Speech_Callback(SP3G_Event event, void *data){}
+#endif
+
+#if defined(__L1_STANDALONE__)
+void CSR_SP3G_Callback( SP3G_Event event, void *data){}
+void CSR_SP4G_Callback( SP4G_Event event, void *data ){}
+#else
+fp_CSR_SP3G_Callback CSR_SP3G_Callback;
+extern void CSR_SP4G_Callback( SP4G_Event event, void *data );
+#endif
+
+extern uint32 L1I_GetTimeStamp( void );
+
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+kal_bool CS_NeedSpeechExtraLog( void )
+{
+ return g_bNeedExtraLog;
+}
+#endif
+
+extern void sp3g_vmRecordService( uint32 *l1_info, uint16 crc_result, uint16 buf_status, uint16 *ul_frame_data, uint16* dl_frame_data, kal_bool bBufferOK);
+
+/* SP3G_UpdateL1InFo */
+/* called by L1A to update DCH on/off and TX in/off(DCH UL on/off) */
+/* bit 0: DCH on/off (1: on, 0: off) */
+/* bit 1: DCH UL on/off (1: on, 0: off) */
+/* bit 2: indicate RLF status (1: indicate RLF, 0: reset RLF) */
+/* bit 3: 3 bits to indicate DCH setup type */
+
+void SP3G_UpdateL1AInFo_P( kal_uint8 bitmap, kal_uint8 value )
+{
+ ASSERT( bitmap <= 3 );
+ MD_TRC_SP3G_L1A_UPDATE_INFO(bitmap, value);
+
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ if( bitmap == 3 ){
+ l1AInfo |= (value << 3);
+ } else {
+ if( value > 0 )
+ l1AInfo |= (1 << bitmap);
+ else
+ l1AInfo &= ~(1 << bitmap);
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+extern kal_enhmutexid sp_mutex;
+//CSR inform RAB is established, the rab_id should be set as parameter when callback to CSR
+
+void CSR_Codec_Ready(int rab_id)
+{
+ if(!sp3g_is_csr_ready && NULL != CSR_SP3G_Callback){
+ MD_TRC_SP3G_CODEC_READY_OK(rab_id);
+ CSR_SP3G_Callback(SP3G_CODEC_READY, (void*)rab_id ); // It means that l1sp_speechon is not invoked and callback will be replied until l1sp_speechon is triggered.
+ sp3g_is_csr_ready = true;
+ }else{
+ MD_TRC_SP3G_CODEC_READY_SKIP(rab_id, sp3g_is_csr_ready, (NULL==CSR_SP3G_Callback));
+ }
+}
+
+void CSR_Codec_Close(int rab_id)
+{
+ if(sp3g_is_csr_ready && NULL != CSR_SP3G_Callback){
+ MD_TRC_SP3G_CODEC_CLOSE_OK(rab_id);
+ CSR_SP3G_Callback(SP3G_CODEC_CLOSED, (void*)rab_id );
+ sp3g_is_csr_ready = false;
+ }else{
+ MD_TRC_SP3G_CODEC_CLOSE_SKIP(rab_id, sp3g_is_csr_ready, (NULL==CSR_SP3G_Callback));
+ }
+}
+
+void SP3G_Rab_Est_sub()
+{
+ CSR_Codec_Ready(sp3g_rab_id);
+ SP3G_Reset();
+ AM_InterRAT_2G_to_3G(sp3g->ul_codec_mode);
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+}
+#ifdef __FAKE_3G_LOOPBACK__
+extern kal_uint32 get_is_fake_3g(void);
+#endif
+void SP3G_Rab_Est( uint32 rab_id, kal_uint8 default_speech_codec )
+{
+#ifdef __FAKE_3G_LOOPBACK__
+ if(get_is_fake_3g()){
+ uint32 codec;
+ kal_prompt_trace(MOD_L1SP, "[SP3G]SP3G_Rab_Est %d %d", rab_id, default_speech_codec);
+ codec = AmrFrameType2DspMode[default_speech_codec];
+ sp3g->ul_codec_mode = codec;
+ }
+#endif
+ sp3g_rab_id = rab_id;
+ sp3g_rab_state = KAL_TRUE;
+
+ //sp3g_codec_mode = default_speech_codec;
+ MD_TRC_SP3G_RAB_EST_0(L1SP_GetState());
+
+#if defined(_MODEM_RESYNC_3G_)
+ MD_TRC_L1Audio_Msg_AM_3G_Reset_Time_Drift();
+#if defined( __UMTS_RAT__ )
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+#if defined(__UMTS_FDD_MODE__)
+ UL1D_Speech_Resync_Reset_Time_Offset();
+#endif
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+#if defined( __UMTS_TDD128_MODE__ )
+ TL1C_Reset_Time_Drift();
+#endif
+ break;
+ default:
+ ASSERT(0);
+ }
+#endif
+#endif
+
+#if defined( __UMTS_RAT__ ) && !defined(__L1_STANDALONE__)
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+ if(query_ps_conf_test_mode()==PS_CONF_TEST_FTA)
+ SP3G_SetDTX(false);
+ else
+ SP3G_SetDTX(true);
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ break;
+ default:
+ ASSERT(0);
+ }
+#endif
+
+ kal_take_enh_mutex( sp_handover_mutex );
+ MD_TRC_SP3G_RAB_EST();
+
+ //CSR_SP3G_Callback(SP3G_CODEC_READY, (void*)sp3g_rab_id );
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_3G , true);
+ CSR_Codec_Ready(sp3g_rab_id);
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( L1SP_GetState() == L1SP_STATE_C2K_SPEECH_ON ){//
+ //PSR_C2K_Callback(C2K_CODEC_READY, (void*)0 );
+ //C2k_Reset();
+ AM_InterRAT_C2K_to_3G(sp3g->ul_codec_mode);
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }else
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ if( L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON ){//
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)0 );
+ SP3G_Reset();
+ AM_InterRAT_4G_to_3G(sp3g->ul_codec_mode);
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }else
+#endif
+ if( L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON ){//prepare InterRAT HO
+ SP3G_Reset();
+ AM_InterRAT_2G_to_3G(sp3g->ul_codec_mode);
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }
+
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+void SP3G_Rab_Deest( void )
+{
+ sp3g_rab_state = KAL_FALSE;
+ MD_TRC_SP3G_RAB_DEEST_0(L1SP_GetState());
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ MD_TRC_SP3G_RAB_DEEST();
+
+ //CSR_SP3G_Callback(SP3G_CODEC_CLOSED, (void*)sp3g_rab_id );
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_3G , false);
+ CSR_Codec_Close(sp3g_rab_id);
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( L1SP_isC2KSO_Connected() && L1SP_GetState() != L1SP_STATE_C2K_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//3G->4G
+ //PSR_C2K_Callback(C2K_CODEC_READY, (void*)0 );
+ //C2k_Reset();
+ AM_InterRAT_3G_to_C2K(L1SP_GetC2KSO_Codec());
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }else
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ if( SP4G_Rab_State() && L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//3G->4G
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+ AM_InterRAT_3G_to_4G(SP4G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+#endif
+ if( L1SP_TCH_State() && L1SP_GetState() != L1SP_STATE_2G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//2G->3G fail case
+ AM_InterRAT_3G_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+kal_bool SP3G_Rab_State( void )
+{
+ return sp3g_rab_state;
+}
+
+kal_uint32 SP3G_Rab_Id( void )
+{
+ return sp3g_rab_id;
+}
+
+
+
+void SP3G_GetSyncDelayRW( kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us)
+{
+ kal_uint16 msDelayR, msDelayW;
+ kal_uint32 cur_time, delay, idx;
+ kal_uint32 MODE_3G;
+
+#if defined( __UMTS_RAT__ )
+ if(!SP3G_Rab_State()){
+ MODE_3G = SAL_DEALY_3G_FDD;
+ } else {
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+#if defined(__UMTS_FDD_MODE__)
+ MODE_3G = SAL_DEALY_3G_FDD;
+#endif
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+#if defined( __UMTS_TDD128_MODE__ )
+ MODE_3G = SAL_DEALY_3G_TDD;
+#endif
+ break;
+ default:
+ ASSERT(0);
+ }
+ }
+#endif
+
+ *u32CurTime64us = fma_get_glb_ts();
+ cur_time = ust_get_current_time();
+ sp3g->int_time[4] = cur_time;
+
+ MD_TRC_L1Audio_Msg_SP3G_GetSyncDelayRW( sp3g->ul_codec_mode );
+
+ if( sp3g_reset_flag == 2 ){
+ idx = ( ( ust_us_duration( sp3g->int_time[0], sp3g->int_time[1] ) ) / 1000 ) % 20;
+ SAL_Get_Delay(MODE_3G, 0, idx, u16DelayR, u16DelayW, u16DelayM);
+ // ASSERT( 0==((*u16DelayR)&0x7) );
+ // ASSERT( 0==((*u16DelayW)&0x7) );
+ // ASSERT( 0==((*u16DelayM)&0x7) );
+ msDelayR = (*u16DelayR)>>3;
+ msDelayW = (*u16DelayW)>>3;
+ MD_TRC_L1Audio_Msg_SP3G_SEND_RESYNC_INFO( idx, msDelayR, sp3g->int_time[0]/1000, sp3g->int_time[1]/1000, cur_time/1000);
+ delay = ( ust_us_duration( sp3g->int_time[1], cur_time ) ) / 1000 ;
+ if(delay >= msDelayR || delay >= msDelayW){ //error handling
+ SAL_Get_Delay(MODE_3G, SAL_DELAY_NA, SAL_DELAY_NA, u16DelayR, u16DelayW, u16DelayM);
+ // ASSERT( 0==((*u16DelayR)&0x7) );
+ // ASSERT( 0==((*u16DelayW)&0x7) );
+ // ASSERT( 0==((*u16DelayM)&0x7) );
+ msDelayR = (*u16DelayR)>>3;
+ msDelayW = (*u16DelayW)>>3;
+ MD_TRC_L1Audio_Msg_SP3G_REYSNC_DELAY_OVERFLOW(msDelayR, msDelayW);
+ sp3g->uDelW = msDelayW;
+ } else {
+ *u16DelayR = (msDelayR - delay) * 8;//samples
+ sp3g->uDelW = (msDelayW - delay);
+ *u16DelayW = sp3g->uDelW * 8;
+ }
+ } else {
+ SAL_Get_Delay(MODE_3G, SAL_DELAY_NA, SAL_DELAY_NA, u16DelayR, u16DelayW, u16DelayM);
+ // ASSERT( 0==((*u16DelayR)&0x7) );
+ // ASSERT( 0==((*u16DelayW)&0x7) );
+ // ASSERT( 0==((*u16DelayM)&0x7) );
+ //msDelayR = (*u16DelayR)>>3;
+ msDelayW = (*u16DelayW)>>3;
+ sp3g->uDelW = msDelayW;
+ }
+}
+void sp3g_hisr_ul(void *data)
+{
+ int32 I, J = 0, K;
+ uint16 *ptr16;
+ uint16 tx_type, sc_mode;
+ uint8 *ptr8;
+ uint8 len;
+ const uint8* RAB_To_DSP_Mapping;
+ uint16 total_bits, idx, rabBitsCount;
+ uint8 frame_type = 0,bit8Data;
+ bool bWrite;
+
+ kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ if(L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON){
+ MD_TRC_SP3G_UL_HISR_SKIP(L1SP_GetState());
+ kal_give_spinlock(sp3g_spinlockID);
+ return;
+ }
+
+ ASSERT(sp3g != (SP3G_Struct*) 0);
+
+ sp3g->ul_report = SAL_3G_GetValue(SAL_3G_VALUE_TX_CODEC_MODE);
+
+ /*for catcher log codec information*/
+ if( sp3g->ul_report != sp3g->pre_ul_report ){
+ MD_TRC_L1Audio_Msg_SPEECH_CODEC( L1SP_Speech_Codec_Mode(sp3g->ul_report), L1SP_Speech_Codec_Mode(sp3g->dl_report) );
+ sp3g->pre_ul_report = sp3g->ul_report;
+ }
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ sp3g->int_time[3] = ust_get_current_time();
+ MD_TRC_SP3G_D2M_UL_TIMING((sp3g->int_time[3])/1000);
+#endif
+
+ // UL side
+ ptr16 = (uint16*)sp3g->dsp_buffer;
+ {
+ // get data from DSP UL buffer
+ volatile uint16 *addr;
+ tx_type = SAL_3G_GetValue(SAL_3G_VALUE_TX_TYPE);
+ sc_mode = sp3g->ul_report;
+ if( sc_mode < 0x03 || sc_mode > 0x28 )
+ {
+ MD_TRC_SP3G_INVALID_UL_CODEC_MODE(sc_mode);
+ tx_type = SAL_3G_TX_NO_DATA;
+ sc_mode = 3;
+ }
+ addr = SAL_3G_GetAddr(SAL_3G_ADDR_TXHB);
+ for(I = GetDspModeLen(sc_mode); --I >= 0 ; )
+ *ptr16++ = *addr++;
+ }
+
+ // do bit re-ordering
+ ptr16 = (uint16*)sp3g->dsp_buffer;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true){
+ ptr16 = (uint16*)sp3g->dsp_buffer;
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3GHISR UL DSP len %d, %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
+ // DspModeLen[sc_mode - 3], ptr16[0], ptr16[1], ptr16[2], ptr16[3], ptr16[4], ptr16[5], ptr16[6], ptr16[7],
+ // ptr16[8], ptr16[9], ptr16[10], ptr16[11], ptr16[12], ptr16[13], ptr16[14], ptr16[15]);
+ MD_TRC_SP3G_UL_BIT_TRUE_DSP_F8(
+ GetDspModeLen(sc_mode), ptr16[0], ptr16[1], ptr16[2], ptr16[3], ptr16[4], ptr16[5], ptr16[6], ptr16[7]);
+ MD_TRC_SP3G_UL_BIT_TRUE_DSP_N8(
+ ptr16[8], ptr16[9], ptr16[10], ptr16[11], ptr16[12], ptr16[13], ptr16[14], ptr16[15]);
+
+ }
+#endif
+ ptr8 = (uint8*)sp3g->ul_buffer[sp3g->ul_write_idx];
+
+ bWrite = KAL_FALSE;
+
+ if(SAL_3G_IsULReady()){//DSP tell MCU the data of DSP is ready
+ if( sp3g->ul_count < sp3g->ul_buffer_size ){
+ bWrite = KAL_TRUE;
+ }
+ if( sp3g->ul_count == sp3g->ul_buffer_size ){
+ if( sp3g->is_getting_ul_data ){
+ bWrite = KAL_FALSE;
+ }else{
+ sp3g->ul_read_idx++; //drop oldest frame
+ sp3g->ul_count--;
+ bWrite = KAL_TRUE;
+ if( sp3g->ul_read_idx == sp3g->ul_buffer_size )
+ sp3g->ul_read_idx = 0;
+ }
+ }
+ SAL_3G_SetULEmpty();
+ }else{//DSP tell MCU the data of DSP is not ready
+ sp3g->ul_report = sp3g->ul_codec_mode;
+ sc_mode = sp3g->ul_report;
+ AM_FillSilencePatternInBuffer( ptr16, sp3g->ul_report );
+ tx_type = SAL_3G_TX_SPEECH_GOOD;
+ bWrite = KAL_TRUE;
+ MD_TRC_SP3G_UL_DSP_NOT_READY_WARNING_AND_FILL_SILENCE();
+ }
+
+ if(sp3g->under_interact){
+ MD_TRC_SP3G_SKIP_UL_REFRESH(sp3g->ul_report, sp3g->ul_codec_mode);
+ kal_give_spinlock(sp3g_spinlockID);
+ return;
+ }
+ if( bWrite ){
+ frame_type = GetDspMode2FrameType(sc_mode);
+ switch(tx_type)
+ {
+ case SAL_3G_TX_SPEECH_GOOD:
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ *ptr8++ = frame_type;
+ len = RAB_subflow[frame_type][3];
+ *ptr8++ = len;
+
+ if(frame_type >= 0x10) //AMR-WB
+ RAB_To_DSP_Mapping = (const uint8 *)tblAMR_WBOrder[frame_type-0x10];
+ else
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+
+ // do bit reorder , move speech information bits to rab_byte_array
+ total_bits = RAB_subflow[frame_type][0] + RAB_subflow[frame_type][1] + RAB_subflow[frame_type][2];
+
+ for(I = len; --I >= 0; *ptr8++ = 0);
+
+ for(idx = 0, ptr8 -= len, I = 0; I < 3; I ++){
+ rabBitsCount = RAB_subflow[frame_type][I];
+
+ if( frame_type >= 16 ){
+ const uint16* WB_RAB_To_DSP_Mapping;
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order[K & 15])? RAB_Order[J & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ } else {
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order[K & 15])? RAB_Order[J & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+
+ ASSERT(idx == total_bits);
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{
+ len = AMR_IF2_FRAME_LENGTH[frame_type]; //frame length
+ *ptr8++ = len;
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+ total_bits = RAB_subflow[frame_type][0] + RAB_subflow[frame_type][1] + RAB_subflow[frame_type][2];
+
+ for(I = len; --I >= 0 ; )
+ *ptr8++ = 0;
+ idx = 0;
+ ptr8 -= len;
+ // do bit reorder , first byte contains frame_type
+ *ptr8 = frame_type;
+ I = 4;
+ for(J = 0; J < total_bits; J++,I++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order[K & 15])? AMR_IF2_Order[J & 0x7] : 0;
+ ptr8[I >> 3] |= bit8Data;
+ }
+ }
+#endif
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3G_HISR UL is TX_SPEECH_GOOD");
+ MD_TRC_SP3G_TX_SPEECH_GOOD();
+#endif
+ break;
+ case SAL_3G_TX_SID_FIRST:
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ if( sp3g->ul_report >= 0x20 )
+ *ptr8++ = WB_AMR_SID_FRAME;//WB SID
+ else
+ *ptr8++ = AMR_SID_FRAME;
+ *ptr8++ = 5;
+ for(I = 4; --I >= 0; )
+ *ptr8++ = 0;
+
+ if( sp3g->ul_report >= 0x20 )
+ *ptr8 = (uint8)(sp3g->ul_report - 0x20);
+ else
+ *ptr8 = (uint8)(frame_type << 1);
+ #ifdef AMR_DATA_LOG
+ ptr8 -= 6;
+ MD_TRC_SP3G_TX_SID_FIRST();
+ #endif
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G 324M
+ *ptr8++ = 6;//frame length
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+ *ptr8 = (uint8)(frame_type);
+ ptr8 -= 5;
+ *ptr8 |= AMR_SID_FRAME;
+ }
+#endif
+ break;
+ case SAL_3G_TX_SID_UPDATE:
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ if( sp3g->ul_report >= 0x20 )
+ *ptr8++ = WB_AMR_SID_FRAME;//WB SID
+ else
+ *ptr8++ = AMR_SID_FRAME;
+ *ptr8++ = 5;
+ // do bit reorder , move sid information bits to rab_byte_array
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+
+ ptr8 -= 5;
+ for(I = 0; I < 35; I ++)
+ {
+ bit8Data = (ptr16[I >> 4] & DSP_Order[I & 15])? RAB_Order[I & 0x7] : 0;
+ ptr8[I >> 3] |= bit8Data;
+ }
+ frame_type = (frame_type >> 2) | ((frame_type & 0x1) << 2) | (frame_type & 0x2);
+
+ if( sp3g->ul_report >= 0x20 )
+ ptr8[4] |= (uint8)(sp3g->ul_report - 0x20)|0x10;
+ else
+ ptr8[4] |= (uint8)(frame_type << 1)|0x10;
+
+ #ifdef AMR_DATA_LOG
+ ptr8 -= 2;
+ MD_TRC_SP3G_TX_SID_UPDATE();
+ #endif
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G 324M
+ *ptr8++ = 6;//frame length
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+ *ptr8 = (uint8)(frame_type);
+ ptr8 -= 5;
+ *ptr8 |= AMR_SID_FRAME;
+ J = 4;
+ for(I = 0; I < 35; J++, I++)
+ {
+ bit8Data = (ptr16[I >> 4] & DSP_Order[I & 15])? AMR_IF2_Order[I & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ ptr8[4] |= 0x80;
+ }
+#endif
+ break;
+ case SAL_3G_TX_NO_DATA:
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ *ptr8++ = AMR_NO_DATA;
+ *ptr8++ = 0;
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G324M
+ *ptr8++ = 1;
+ *ptr8++ = AMR_NO_DATA;
+ }
+#endif
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3G_HISR UL is NO DATA");
+ MD_TRC_SP3G_UL_NO_DATA();
+#endif
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true){
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3G_HISR UL Type %d, Frm %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
+ // tx_type, ptr8[0], ptr8[1],ptr8[2],ptr8[3],ptr8[4],
+ // ptr8[5],ptr8[6],ptr8[7],ptr8[8],ptr8[9],ptr8[10],ptr8[11],ptr8[12],ptr8[13],ptr8[14],ptr8[15], ptr8[16],ptr8[17],ptr8[18],ptr8[19],ptr8[20]);
+ uint8 *tmp_ = (uint8*)sp3g->ul_buffer[sp3g->ul_write_idx];
+ MD_TRC_SP3G_DEBUG_UL_BUFF(sp3g->ul_write_idx);
+ MD_TRC_SP3G_UL_BIT_TRUE_F8(
+ 1, tx_type, tmp_[0], tmp_[1],tmp_[2],tmp_[3],tmp_[4],tmp_[5],tmp_[6],tmp_[7]);
+ MD_TRC_SP3G_UL_BIT_TRUE_N13(
+ tmp_[8],tmp_[9],tmp_[10],tmp_[11],tmp_[12],tmp_[13],tmp_[14],tmp_[15],
+ tmp_[16],tmp_[17],tmp_[18],tmp_[19],tmp_[20]);
+ }
+#endif
+ }
+
+ if( sp3g->ul_refresh )
+ {
+ if((sp3g->ul_report <= 0x0A && sp3g->ul_codec_mode >= 0x20) || //WB, NB handover
+ (sp3g->ul_report >= 0x20 && sp3g->ul_codec_mode <= 0xA)){
+ ASSERT(0);
+ }else if(sp3g->ul_report != sp3g->ul_codec_mode ){
+ SAL_3G_Upd_Enc_Cod(sp3g->ul_codec_mode);
+ }
+ sp3g->ul_refresh = KAL_FALSE;
+ }
+
+ if( bWrite ){
+ sp3g->ul_write_idx++;
+ if( sp3g->ul_write_idx == sp3g->ul_buffer_size )
+ sp3g->ul_write_idx = 0;
+ sp3g->ul_count++;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true) {
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3GVT UL cnt=%d,r=%d,w=%d",sp3g->ul_count,sp3g->ul_read_idx,sp3g->ul_write_idx);
+ MD_TRC_SP3G_UL_BUFFER(sp3g->ul_count,sp3g->ul_read_idx,sp3g->ul_write_idx);
+ }
+#endif
+ if( sp3g->sp3g_mode == RAT_3G_MODE && sp3g->ul_delay > START_SHRINK_UL_DELAY && !sp3g->is_getting_ul_data){
+ sp3g->ul_read_idx++;
+ if( sp3g->ul_read_idx == sp3g->ul_buffer_size )
+ sp3g->ul_read_idx = 0;
+ if(sp3g->ul_count > 1)
+ sp3g->ul_count--;
+ }//when ul write updated, check ul_delay. keep newest one
+ }
+
+ if( sp3g->waiting == KAL_FALSE )
+ {
+ sp3g->waiting = KAL_TRUE;
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ ASSERT( NULL != CSR_SP3G_Callback );
+ CSR_SP3G_Callback( SP3G_UL_DATA_NOTIFY, (void*)0 );
+ }
+ }
+ else
+ {
+ sp3g->ul_delay ++;
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ ASSERT( NULL != CSR_SP3G_Callback );
+ CSR_SP3G_Callback(SP3G_UL_DATA_DEALY_TICK, (void *)(kal_uint32)sp3g->ul_delay);
+ }
+ MD_TRC_SP3G_UL_DELAY(sp3g->ul_delay);
+#if 0
+/* under construction !*/
+#endif
+ }
+ kal_give_spinlock(sp3g_spinlockID);
+#ifdef __FAKE_3G_LOOPBACK__
+ if(get_is_fake_3g()){
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SP3G_UL_EVENT, NULL, NULL);
+ }
+#endif
+}
+
+void sp3g_updateL1DSync(void)
+{
+#if defined(_MODEM_RESYNC_3G_)
+ int16 time_drift;
+#if defined( __UMTS_RAT__ )
+ if(!SP3G_Rab_State()){
+ MD_TRC_SP3G_L1D_Resync_Skip();
+ return;
+ }
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+#if defined(__UMTS_FDD_MODE__)
+ time_drift = UL1D_Speech_Resync_Get_Time_Offset(); //us
+ MD_TRC_SP3G_L1D_Resync(1, time_drift);
+ if(time_drift > 1000){
+ MD_TRC_L1D_RESYNC_UPDATE(1);
+ UL1D_Speech_Resync_Update_Time_Offset(true);
+ SAL_8K_Resync(true, 8, true, 8);
+ }else if(time_drift < -1000){
+ MD_TRC_L1D_RESYNC_UPDATE(0);
+ UL1D_Speech_Resync_Update_Time_Offset(false);
+ SAL_8K_Resync(true, -8, true, -8);
+ }
+#endif
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+#if defined( __UMTS_TDD128_MODE__ )
+ time_drift = TL1C_Get_Time_Drift(); //us
+ MD_TRC_SP3G_L1D_Resync(2, time_drift);
+ if(time_drift > 1000){
+ MD_TRC_L1D_RESYNC_UPDATE(1);
+ TL1C_Update_Time_Drift(true);
+ SAL_8K_Resync(true, 8, true, 8);
+ }else if(time_drift < -1000){
+ MD_TRC_L1D_RESYNC_UPDATE(0);
+ TL1C_Update_Time_Drift(false);
+ SAL_8K_Resync(true, -8, true, -8);
+ }
+#endif
+ break;
+ default:
+ ASSERT(0);
+ }
+#endif
+#endif
+}
+
+extern void vmSet3GNetworkInfo( uint32 *l1_info, uint16 crc_result, uint16 buf_status, uint8 dl_count );
+void sp3g_hisr_dl(void *data)
+{
+ int32 I, J = 0, K;
+ uint16 *ptr16;
+ uint16 rx_type = 0, sd_mode = 0, rx_len = 0;
+ uint8 *ptr8;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ uint8 *ptr8_bak;
+#endif
+ const uint8* RAB_To_DSP_Mapping, *Order = NULL;
+ uint16 total_bits, idx, rabBitsCount;
+ uint8 frame_type = 0;
+ uint16 bit16Data;
+ uint8 sidData;
+ bool FQI_flag = false;
+
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ MD_TRC_SP3G_D2M_DL_TIMING((ust_get_current_time())/1000);
+#endif
+ if(L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON)
+ return;
+ ASSERT(sp3g != (SP3G_Struct*) 0);
+
+ sp3g->dl_report = SAL_3G_GetValue(SAL_3G_VALUE_RX_CODEC_MODE);
+
+
+ /*for catcher log codec information*/
+ if( sp3g->dl_report != sp3g->pre_dl_report ){
+ MD_TRC_L1Audio_Msg_SPEECH_CODEC( L1SP_Speech_Codec_Mode(sp3g->ul_report), L1SP_Speech_Codec_Mode(sp3g->dl_report) );
+ sp3g->pre_dl_report = sp3g->dl_report;
+ }
+
+
+ {
+ uint32 *l1_info = NULL;
+ //uint16 crc_result = 0;
+ uint16 buf_status, crc_result = 0;
+
+ if( sp3g->dl_count == 0 ){
+ crc_result = (l1AInfo << 8);
+ }
+ else
+ {
+ uint32 CFN = 0;
+ if( sp3g->sp3g_mode == RAT_3G324M_MODE ){
+ l1_info = NULL;
+ }
+ else{
+ ptr8 = (uint8*) sp3g->dl_buffer[sp3g->dl_read_idx];
+ ptr8 += 2;
+ CFN = ptr8[0] + (ptr8[1] << 8) + (ptr8[2] << 16) + (ptr8[3] << 24);
+
+ for(I = 0 ; I < 4 ; I ++)
+ if( CFN == sp3g->L1_Info[I][0] )
+ break;
+ if( I == 4 ){
+ crc_result = (l1AInfo << 8);
+ l1_info = NULL;
+ }else{
+ l1_info = sp3g->L1_Info[I];
+ crc_result = (uint16)(l1AInfo << 8) | (uint16)(sp3g->L1_Info[I][2] & 0xF); //[0:7]:CRC, [8:15]:l1AInfo
+ }
+ /*SID BAD False alarm work around, log in VM first*/
+ {
+ uint8 * ptrDL;
+ ptrDL = (uint8*) sp3g->dl_buffer[sp3g->dl_read_idx];
+ if( sp3g->dtx_state == 0 && ptrDL[0] == 8 /*AMR_SID*/ && ptrDL[1] == KAL_FALSE/*CRC fail*/)
+ crc_result |= 0x8000;// The flag indicate working around
+ if( ptrDL[0] == AMR_NO_DATA && sp3g->dtx_force == KAL_TRUE )
+ //crc_result |= 0x4000;
+ crc_result |= 0x0080;//move from bit14 to bit7. 20100821
+ }
+ }
+ }
+ buf_status = ( ( (sp3g->ul_read_idx << DL_BUF_INDEX_BIT_NUM) + sp3g->dl_read_idx ) << 8 ) +
+ (sp3g->ul_write_idx << DL_BUF_INDEX_BIT_NUM) + sp3g->dl_write_idx;
+ vmSet3GNetworkInfo(l1_info, crc_result, buf_status, sp3g->dl_count);
+
+ }
+
+ l1AInfo &= ~0xFFFC;
+ // DL side
+ if( sp3g->dl_count == 0 || sp3g_reset_flag != 2 ){ // buffer under flow
+ SAL_3G_Set_RxType(SAL_3G_RX_NO_DATA);
+ rx_type = SAL_3G_RX_NO_DATA;
+ sp3g->dtx_state = 1;
+ MD_TRC_SP3G_DTX_NO_DATA();
+ }
+ else
+ {
+ MD_TRC_SP3G_BUFFER_STATUS(sp3g->dl_read_idx, sp3g->dl_write_idx,sp3g->dl_count, sp3g->dl_buffer[sp3g->dl_read_idx][0]);
+
+ ptr8 = (uint8*) sp3g->dl_buffer[sp3g->dl_read_idx];
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak = (uint8*) sp3g->dl_buffer2[sp3g->dl_read_idx];
+#endif
+ ptr16 = (uint16*) sp3g->dsp_buffer_dl;
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ frame_type = *ptr8++; // here 0 ~ 7 and includes SID and NO_DATA
+ FQI_flag = (bool)*ptr8++;
+ ptr8 += 4; // skip CFN
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak += 6;
+#endif
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G 324M
+ FQI_flag = KAL_TRUE;
+ frame_type = *ptr8++; // here 0 ~ 7 and includes SID and NO_DATA
+ ptr8++; // skip frame length
+ }
+#endif
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true){
+ //kal_prompt_trace(MOD_L1SPHISR,"SP3G_HISR DL Type %d, Frm %x %x %x %x %x", frame_type, ptr8[0], ptr8[1],ptr8[2],ptr8[3],ptr8[4]);
+ MD_TRC_SP3G_DL_BIT_TRUE(frame_type, ptr8[0], ptr8[1],ptr8[2],ptr8[3],ptr8[4]);
+ }
+#endif
+ if( frame_type == AMR_NO_DATA && sp3g->dtx_force == KAL_TRUE ){
+ frame_type = AMR_SID_FRAME;
+ FQI_flag = KAL_FALSE; // force enter SID_BAD;
+ sp3g->dtx_state = 1;
+ }
+ sp3g->dtx_force = KAL_FALSE;
+ if( sp3g->dtx_state == 0 && frame_type == AMR_SID_FRAME && FQI_flag == KAL_FALSE ){//previous dtx_state is false, but suddenly SID_BAD, regard it as false alarm.
+ frame_type = AMR_NO_DATA;
+ sp3g->dtx_force = KAL_TRUE;
+ }
+ if( data == (void *)2 )
+ {
+#if defined(__SP3G_DL_BUFFER_BEFORE_PLAY__)
+ MD_TRC_SP3G_FORCE_NODATA_WHEN_RESYNC();
+ frame_type = AMR_NO_DATA;
+#endif
+ }
+ switch(frame_type)
+ {
+ case 0: // 4.75 kbps
+ case 1: // 5.15 kbps
+ case 2: // 5.9 kbps
+ case 3: // 6.7 kbps
+ case 4: // 7.4 kbps
+ case 5: // 7.95 kbps
+ case 6: // 10.2 kbps
+ case 7: // 12.2 kbps
+ case 16:/* WB type 0, AMR-WB 6.60 */
+ case 17:/* WB type 1, AMR-WB 8.85 */
+ case 18:/* WB type 2, AMR-WB 12.65 */
+ case 19:/* WB type 3, AMR-WB 14.25 */
+ case 20:/* WB type 4, AMR-WB 15.85 */
+ case 21:/* WB type 5, AMR-WB 18.25 */
+ case 22:/* WB type 6, AMR-WB 19.85 */
+ case 23:/* WB type 7, AMR-WB 23.05 */
+ case 24:/* WB type 8, AMR-WB 23.85 */
+ if( frame_type >= 16 )
+ RAB_To_DSP_Mapping = (const uint8 *) tblAMR_WBOrder[frame_type-16];
+ else
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+ if( FQI_flag == KAL_TRUE )
+ rx_type = SAL_3G_RX_SPEECH_GOOD;
+ else
+ rx_type = SAL_3G_RX_SPEECH_BAD;
+
+ sd_mode = GetFrameType2DspMode(frame_type);
+ rx_len = GetDspModeLen(sd_mode);
+ // move amr data to dl_buffer
+
+ total_bits = RAB_subflow[frame_type][0] + RAB_subflow[frame_type][1] + RAB_subflow[frame_type][2];
+
+ for(I = rx_len; --I >= 0; )
+ *ptr16++ = 0;
+
+ ptr16 -= rx_len;
+ idx = 0;
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ for(I = 0; I < 3; I ++)
+ {
+ if(RAB_subflow[frame_type][I] == 0)
+ break;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true){
+ ASSERT( *ptr8 == *ptr8_bak );
+ }
+#endif
+ rabBitsCount = RAB_subflow[frame_type][I];
+ if(frame_type >= 16){
+ const uint16* WB_RAB_To_DSP_Mapping;
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[J >> 3] & RAB_Order[J & 7])? DSP_Order[K & 15] : 0;
+ ptr16[K >> 4] |= bit16Data;
+ }
+ } else {
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ uint32 t1;
+ uint16 *t2;
+ K = RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[J >> 3] & RAB_Order[J & 7])? DSP_Order[K & 15] : 0;
+ t1 = K >> 4;
+ t2 = ptr16 + t1;
+
+ //ptr16[K >> 4] |= bit16Data;
+ *t2 |= bit16Data;
+ }
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak += (rabBitsCount + 7) >> 3;
+#endif
+ }
+ ASSERT(idx == total_bits);
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G 324M
+ I = 4;
+ for(J = 0; J < total_bits; J++, I++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[I >> 3] & AMR_IF2_Order[J & 7])? DSP_Order[K & 15] : 0;
+ ptr16[K >> 4] |= bit16Data;
+ }
+ }
+#endif
+ sp3g->dtx_state = 0;
+ break;
+
+ case 8: // AMR SID
+ case 25:
+ sidData = ptr8[4];
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ if( FQI_flag == KAL_TRUE )
+ {
+ if( sidData & 0x10 )
+ rx_type = SAL_3G_RX_SID_UPDATE;
+ else
+ rx_type = SAL_3G_RX_SID_FIRST;
+ sp3g->dtx_state = 1;
+ }
+ else
+ rx_type = SAL_3G_RX_SID_BAD;
+
+ if( frame_type == 25 ){
+ sd_mode = (sidData & 0xF);
+
+ if(sd_mode >= 10)
+ {
+ rx_type = SAL_3G_RX_SID_BAD;
+ sd_mode = sp3g->pre_dl_report;
+ } else if(9 == sd_mode){
+ sd_mode = sp3g->pre_dl_report;
+ } else {
+ sd_mode = GetFrameType2DspMode(sd_mode+16);
+ }
+ } else
+ {
+ sd_mode = (sidData & 0xE) >> 1;// should reverse
+ sd_mode = (sd_mode >> 2) | ((sd_mode & 0x1) << 2) | (sd_mode & 0x2);
+ sd_mode = GetFrameType2DspMode(sd_mode);
+ //sd_mode = AmrFrameType2DspMode[sd_mode]; // RX SD Mode
+ }
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G 324M
+ if( sidData & 0x80 )
+ rx_type = SAL_3G_RX_SID_UPDATE;
+ else
+ rx_type = SAL_3G_RX_SID_FIRST;
+ sd_mode = GetFrameType2DspMode((ptr8[5] & 0x7));
+ }
+#endif
+
+ rx_len = 3; // 35 information bits
+ // move sid data to dl_buffer
+ for(I = 3; --I >= 0; )
+ *ptr16++ = 0;
+ ptr16 -= 3;
+ Order = RAB_Order;
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+ J = 0;
+ Order = RAB_Order;
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//3G324M
+ J = 4;
+ Order = AMR_IF2_Order;
+ }
+#endif
+
+ for(I = 0; I < 35; I++,J++)
+ {
+ bit16Data = (ptr8[J >> 3] & Order[I & 7])? DSP_Order[I & 15] : 0;
+ ptr16[I >> 4] |= bit16Data;
+ }
+ #ifdef AMR_DATA_LOG
+ if( rx_type == SAL_3G_RX_SID_FIRST )
+ MD_TRC_SP3G_RX_SID_FIRST();
+ else if( rx_type == SAL_3G_RX_SID_UPDATE )
+ MD_TRC_SP3G_RX_SID_UPDATE();
+ #endif
+ break;
+
+ case 15: // NO DATA
+ MD_TRC_SP3G_RX_NO_DATA();
+ rx_type = SAL_3G_RX_NO_DATA;
+ rx_len = 0;
+ // no need to record codec mode , inherit from previous
+ break;
+
+ default:
+ ASSERT(false);
+ break;
+ }
+ // get codec_mode , set RX codec_mode
+ // get data from dl_read
+ ptr16 = (uint16*) sp3g->dsp_buffer_dl;
+
+ SAL_3G_Set_RxType(rx_type);
+
+ //For NB/WB handover, it's decided by network set UL codec.
+ // If downlink happens, set it as NO data.
+ if( rx_type != SAL_3G_RX_NO_DATA )
+ {
+ if( (sd_mode <= 0x0A && sp3g->dl_report >= 0x20) ||
+ (sd_mode >= 0x20 && sp3g->dl_report <= 0x0A) )
+ {
+ SAL_3G_Set_RxType(SAL_3G_RX_NO_DATA);
+ SAL_3G_Upd_Dec_Cod(sp3g->dl_report);
+ rx_type = SAL_3G_RX_NO_DATA;
+ MD_TRC_SP3G_RX_FORCE_NO_DATA_WHEN_CHANGE_BAND();
+ }
+ }
+ else if (data == (void *)2) {
+#if defined(__SP3G_DL_BUFFER_BEFORE_PLAY__)
+ AM_3G_INTRARAT(sp3g->ul_codec_mode);
+ sp3g->ul_request_resync = KAL_FALSE;
+#endif
+ }
+ if( rx_type != SAL_3G_RX_NO_DATA && rx_type != SAL_3G_RX_SID_BAD ) //if RX_NO_DATA or RX_SID_BAD, codec mode will use the previous one
+ {
+ volatile uint16 *addr;
+ SAL_3G_Upd_Dec_Cod(sd_mode);
+ addr = SAL_3G_GetAddr(SAL_3G_ADDR_RXHB);
+ for(I = rx_len ; --I >= 0; )
+ *addr++ = *ptr16++;
+ Data_Sync_Barrier();
+ }
+
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ if( data == (void *)2 ){
+ sp3g->dl_count --;
+ sp3g->dl_read_idx++;
+ sp3g->dl_buffer_size = RAT_3G_DL_BUFFER_NUM; // 1 or 2
+ } else
+#endif
+ {
+ // update 3G dl_count
+ sp3g->dl_count --;
+ sp3g->dl_read_idx++;
+ }
+ if( sp3g->dl_read_idx >= sp3g->dl_buffer_size ){//near end of buffer
+ sp3g->dl_read_idx = 0;
+ }
+ }
+ MD_TRC_SP3G_SYNC(((uint8)SAL_3G_IsDLEmpty()<<1) + (uint8)SAL_3G_IsULReady());
+ SAL_3G_SetDLReady(); // MCU tell DSP the data is ready
+
+ { /*for catcher log codec information*/
+ uint8 txType, rxType, ber;
+ txType = SAL_3G_GetValue(SAL_3G_VALUE_TX_TYPE);
+ rxType = rx_type >> 1;
+ ber = 255;//useless both for dsp and driver;
+ //ber = (*DP_3G_DL_RX_TYPE & 0xFF00);
+ MD_TRC_L1Audio_Msg_SPEECH_FRAME( L1SP_Speech_TX_Type(txType), L1SP_Speech_RX_Type(rxType), ber );
+ //L1Audio_Msg_VM_DEBUG( DP2_3G_debug_info0, DP2_3G_debug_info1, DP2_3G_debug_info7 );
+ }
+}
+
+
+void SP3G_Reset( void )
+{
+ sp3g_reset_flag = 1;
+}
+
+kal_bool SP3G_IsDTXOn()
+{
+ return sp3g_dtx_mode;
+}
+
+void SP3G_SetDTX(kal_bool on)
+{
+ sp3g_dtx_mode = on;
+ MD_TRC_SP3G_SET_DTX(on);
+ if( L1SP_GetState() == L1SP_STATE_3G_SPEECH_ON )
+ {
+ kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ SAL_3G_SetDtx(on);
+ kal_give_spinlock(sp3g_spinlockID);
+ }
+}
+
+// Force Rx Type to No data frame, used in speech off
+void SP3G_SetRxTypeToNoData( void )
+{
+ SAL_3G_Set_RxType(SAL_3G_RX_NO_DATA);
+}
+
+void sp3g_reset_internal( void )
+{
+ // DL side
+ sp3g->dl_count = 0;
+ sp3g->dl_write_idx = 0;
+ sp3g->dl_read_idx = 0;
+#if defined(__CSHSPA_SUPPORT__)
+ sp3g->dl_buffer_size = sp3g_max_cs_delay;
+#else
+ sp3g->dl_buffer_size = RAT_3G_DL_BUFFER_NUM_BEFORE_RESYNC;
+#endif
+ sp3g_reset_flag = 0; // clear reset flag, wait it to be 2
+}
+
+void sp3g_init( void )
+{
+ sp3g_is_csr_ready = false;
+ sp3g_rab_id = 0;
+ sp3g_rab_state = KAL_FALSE;
+ l1AInfo = 0;
+
+#if !defined(__L1_STANDALONE__)
+ CSR_SP3G_Callback = NULL;
+#endif
+#if defined(__CSHSPA_SUPPORT__)
+ sp3g_max_cs_delay = 2;
+#endif
+
+ sp3g_dtx_mode = 0;
+
+
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ g_bNeedExtraLog = KAL_FALSE;
+#endif
+ sp3g_spinlockID = kal_create_spinlock("sp3g_spinlock");
+ sp3g = &sp3gInfo;
+}
+
+void sp3g_speech_init(uint8 RAT_Mode)
+{
+ ASSERT( (RAT_Mode == RAT_3G_MODE) || (RAT_Mode == RAT_3G324M_MODE) );
+ ASSERT( L1SP_GetState() == L1SP_STATE_IDLE );
+
+#if !defined(__L1_STANDALONE__)
+#ifdef __FAKE_3G_LOOPBACK__
+ CSR_SP3G_Callback = fake_CSR_Speech_Callback;
+ g_bNeedExtraLog = KAL_TRUE;
+#else
+ CSR_SP3G_Callback = csr_get_fp_CSR_SP3G_Callback();
+#endif
+#endif
+ memset(sp3g, 0, sizeof(SP3G_Struct));
+ sp3g->sp3g_mode = RAT_Mode;
+ // UL side
+ sp3g->waiting = KAL_FALSE;
+
+ sp3g->ul_write_idx = 0;
+ sp3g->ul_read_idx = 0;
+ sp3g->ul_count = 0;
+ sp3g->is_getting_ul_data = KAL_FALSE;
+ sp3g->under_interact = KAL_FALSE;
+ sp3g->ul_delay = 0;
+ sp3g->pre_ul_report = sp3g->pre_dl_report = sp3g->ul_report = sp3g->dl_report = INIT_3G_CODEC;
+
+ if( sp3g->sp3g_mode == RAT_3G_MODE )
+ sp3g->ul_buffer_size = RAT_3G_UL_BUFFER_NUM;
+#ifdef __VIDEO_CALL_SUPPORT__
+ else //3G324M
+ sp3g->ul_buffer_size = MAX_3G_UL_BUFFER_NUM;
+#endif
+#if defined(UL_HARD_REAL_TIME_DEMAND)
+ sp3g->ul_buffer_size = HARD_REAL_TIME_UL_BUFFER_NUM;
+#endif
+
+#ifdef __FAKE_3G_LOOPBACK__
+ if(get_is_fake_3g()){
+ ;//sp3g->ul_codec_mode = INIT_3G_CODEC; applya the previous codec
+ }else{
+ sp3g->ul_codec_mode = INIT_3G_CODEC;
+ }
+#else
+ sp3g->ul_codec_mode = INIT_3G_CODEC;
+#endif
+
+ sp3g->ul_refresh = KAL_FALSE; // detect change codec_mode
+
+ // DL side
+ sp3g->dl_count = 0;
+ sp3g->dl_write_idx = 0;
+ sp3g->dl_read_idx = 0;
+
+ if( sp3g->sp3g_mode == RAT_3G_MODE ){
+#if defined(__CSHSPA_SUPPORT__)
+ sp3g->dl_buffer_size = sp3g_max_cs_delay;
+#else
+ sp3g->dl_buffer_size = RAT_3G_DL_BUFFER_NUM_BEFORE_RESYNC;
+#endif
+ sp3g_reset_flag = 1;
+ }
+ else{ // 3G324M
+ sp3g->dl_buffer_size = MAX_3G_DL_BUFFER_NUM;
+ sp3g_reset_flag = 2;
+ }
+
+#if defined(SP3G_UNIT_TEST)
+ L1Audio_HookHisrHandler(DP_D2C_3G,(L1Audio_EventHandler)sp3g_hisr_2, 0);
+#else
+#if 0//!defined(__UNIFIED_ISR_LEVEL__)
+/* under construction !*/
+#endif
+ L1Audio_HookHisrHandler(DP_D2C_3G_DONE_UL,(L1Audio_EventHandler)sp3g_hisr_ul, 0);
+#endif
+ SAL_3G_Upd_Enc_Cod(sp3g->ul_codec_mode);
+ SAL_3G_Upd_Dec_Cod(sp3g->ul_codec_mode);
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ sp3g->int_time[0] = 0;
+ sp3g->int_time[1] = 0;
+ sp3g->int_time[2] = 0;
+ sp3g->int_time[3] = 0;
+ sp3g->int_time[4] = 0;
+ sp3g->ul_request_resync = KAL_FALSE;
+#endif
+ sp3g->l1_info_idx = 0;
+ sp3g->dtx_state = 0;
+}
+
+void sp3g_speech_close( bool IsInterRAT )
+{
+#if 0//!defined(__UNIFIED_ISR_LEVEL__)
+/* under construction !*/
+#endif
+ L1Audio_UnhookHisrHandler(DP_D2C_3G_DONE_UL);
+ //kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ //free_ctrl_buffer(sp3g);
+ //sp3g = (SP3G_Struct*) 0;
+ //kal_give_spinlock(sp3g_spinlockID);
+#if defined(__CSHSPA_SUPPORT__)
+ sp3g_max_cs_delay = 2;
+ //reset to 2 frame
+#if defined(CSHSPA_UNIT_TEST)
+ L1Audio_FreeAudioID(sp3g_hspa_aud_id);
+#endif
+#endif
+
+ /* only these cases should wait state, if only 2G happen, then return to idle */
+ if( L1SP_GetState() == L1SP_STATE_3G_SPEECH_ON || L1SP_GetState() == L1SP_STATE_3G_SPEECH_CLOSING || IsInterRAT
+#ifdef __VIDEO_CALL_SUPPORT__
+ || L1SP_GetState() == L1SP_STATE_3G324M_SPEECH_ON
+#endif
+ ){
+ //uint32 waitTime;
+#ifdef __VIDEO_CALL_SUPPORT__
+ if( L1SP_GetState() == L1SP_STATE_3G324M_SPEECH_ON )
+ vt_SP3G_Callback( (kal_uint8)SP3G_CODEC_CLOSED, (void*)0);
+ else
+#endif
+ CSR_Codec_Close(SP3G_Rab_Id());
+ }
+#if !defined(__L1_STANDALONE__)
+ kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ CSR_SP3G_Callback = NULL;
+ kal_give_spinlock(sp3g_spinlockID);
+#endif
+}
+
+void SP3G_Request(void)
+{
+ MD_TRC_SP3G_REQUEST();
+ L1SP_3G_Request();
+}
+
+kal_uint32 SP3G_GetCodecMode(void)
+{
+ if(sp3g != NULL)
+ return sp3g->ul_codec_mode;
+ else
+ return INIT_3G_CODEC;
+}
+
+void SP3G_UL_SetFrameType(uint8 amr_frame_type) // function call
+{
+ uint8 state;
+ uint32 codec;
+ if( (state = L1SP_GetState()) != L1SP_STATE_3G_SPEECH_ON)
+ {
+ //if(state == L1SP_STATE_3G_SPEECH_CLOSING)
+ return;
+ //else
+ //ASSERT(false);
+ }
+
+ ASSERT(sp3g != (SP3G_Struct*) 0);
+
+ codec = AmrFrameType2DspMode[amr_frame_type];
+ if((sp3g->ul_codec_mode >= 0x20 && codec <= 0x0A) ||
+ (sp3g->ul_codec_mode <= 0x0A && codec >= 0x20)){//Intrarat
+ sp3g->under_interact = KAL_TRUE;
+ sp3g->ul_codec_mode = codec;
+ AM_3G_INTRARAT(codec);
+ sp3g->under_interact = KAL_FALSE;
+ SP3G_Reset();
+ MD_TRC_SP3G_DEBUG_UL_SETFRAMETYPE(1, sp3g->ul_codec_mode, codec, amr_frame_type);
+ //L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }else{
+ MD_TRC_SP3G_DEBUG_UL_SETFRAMETYPE(2, sp3g->ul_codec_mode, codec,amr_frame_type);
+ sp3g->ul_codec_mode = codec;
+ sp3g->ul_refresh = KAL_TRUE;
+ }
+}
+
+// do bit reorder here
+
+void sub_SP3G_UL_GetSpeechFrame(kal_uint16*frame_index, kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ uint8 *ptr8;
+ int32 I;
+ uint16 sc_mode=0;
+ uint8 state;
+
+ if( (state = L1SP_GetState()) != L1SP_STATE_3G_SPEECH_ON){
+ *frame_index = 0xABCD;
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ MD_TRC_SP3G_UL_PUT_SPEECH_FRAME_DEBUG(0);
+ return;
+ }
+
+ ASSERT(sp3g != (SP3G_Struct*) 0);
+ MD_TRC_SP3G_UL_GET_SPEECH_FRAME();
+
+ //ASSERT(sp3g->waiting == KAL_TRUE); // 1 message 1 get ,
+ // should take care if CSR doesn't get by DATA_NOTIFY message
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ sp3g->int_time[2] = ust_get_current_time(); // log temp UL time
+ MD_TRC_SP3G_UL_TIMING(sp3g->int_time[2]/1000);
+#endif
+
+ *frame_index = 0xABCD; // tmp setting , should be apply true value in near future , Adam
+ kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ sp3g->is_getting_ul_data = KAL_TRUE;
+ kal_give_spinlock(sp3g_spinlockID);
+
+ if(sp3g->ul_count == 0)// or should repeat last frame
+ {
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ sp3g->is_getting_ul_data = KAL_FALSE;
+ SAL_3G_SetULUnsync();
+ MD_TRC_SP3G_UL_PUT_SPEECH_FRAME_DEBUG(1);
+ return;
+ }
+
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ {
+ kal_uint32 time_diff, time_diff_request_resync;
+ static kal_uint32 time_request_resync = 0;
+ time_diff = ust_us_duration( sp3g->int_time[3], sp3g->int_time[2] ) / 1000;
+ time_diff_request_resync = ust_us_duration( time_request_resync, sp3g->int_time[2] ) / 1000;
+ if( (time_diff == 0 || time_diff >= 20 ) && sp3g->ul_request_resync == KAL_FALSE && time_diff_request_resync > 200 /*larger than a certain time to wait resync done*/) {
+ sp3g_reset_flag = 1;
+ //Do not repeat set sp3g_reset_flag = 1
+ sp3g->ul_request_resync = KAL_TRUE;
+ time_request_resync = sp3g->int_time[2];
+ MD_TRC_SP3G_FOUND_UL_SYNC_TIMING_ERROR();
+ }
+ }
+#endif
+ //frame_index = 0xABCD; // tmp setting , should be apply true value in near future , Adam
+ //sp3g->is_getting_ul_data = KAL_TRUE;
+
+ ptr8 = (uint8*)sp3g->ul_buffer[sp3g->ul_read_idx];
+
+ *frame_type = *ptr8;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if (g_bNeedExtraLog == true){
+ uint8 *tmp_ = (uint8*)sp3g->ul_buffer[sp3g->ul_read_idx];
+ //kal_prompt_trace(MOD_L1SP,"SP3G UL Type %d, Frm %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
+ // *frame_type, ptr8[0], ptr8[1],ptr8[2],ptr8[3],ptr8[4],
+ // ptr8[5],ptr8[6],ptr8[7],ptr8[8],ptr8[9],ptr8[10],ptr8[11],ptr8[12],ptr8[13],ptr8[14],ptr8[15], ptr8[16],ptr8[17],ptr8[18],ptr8[19],ptr8[20]);
+ MD_TRC_SP3G_DEBUG_UL_GETSPEECHFRAME(sp3g->ul_read_idx);
+ MD_TRC_SP3G_UL_BIT_TRUE_F8(
+ 0, *frame_type, tmp_[0], tmp_[1],tmp_[2],tmp_[3],tmp_[4],tmp_[5],tmp_[6],tmp_[7]);
+ MD_TRC_SP3G_UL_BIT_TRUE_N13(
+ tmp_[8],tmp_[9],tmp_[10],tmp_[11],tmp_[12],tmp_[13],tmp_[14],tmp_[15],
+ tmp_[16],tmp_[17],tmp_[18],tmp_[19],tmp_[20]);
+ }
+#endif
+ if(*frame_type < AMR_SID_FRAME)
+ sc_mode = AmrFrameType2DspMode[*frame_type];
+ else if(*frame_type >= 16 && *frame_type <= 24){
+ sc_mode = AmrFrameType2DspMode[*frame_type];
+ *ptr8 -= 16;//in subflow data, remap to 0~8?????
+ }else if( *frame_type == 25 ){ //WB AMR SID
+ *ptr8 = AWB_SID_FRAME; //in subflow data, remap to 9
+ }
+ ptr8++;
+
+#if defined( __UMTS_RAT__ )
+ if(!SP3G_Rab_State()){
+ MD_TRC_SP3G_UL_GET_SPEECH_FRAME_SKIP(0);
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ return;
+ }else{
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+ if((*frame_type < 8) && sc_mode < sp3g->ul_codec_mode) // maximum bit_rate limitation
+ {
+ MD_TRC_SP3G_UL_GET_SPEECH_FRAME_SKIP(1);
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ }
+ else
+ {
+ *len = *ptr8++;
+ ASSERT( *len <= 60 );
+
+ for( I = *len; --I >= 0 ; )
+ *rab_byte_array++ = *ptr8++;
+ }
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ if( sc_mode != sp3g->ul_codec_mode) // maximum bit_rate limitation
+ {
+ MD_TRC_SP3G_UL_GET_SPEECH_FRAME_SKIP(2);
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ }
+ else
+ {
+ *len = *ptr8++;
+ ASSERT( *len <= 60 );
+
+ for( I = *len; --I >= 0 ; )
+ *rab_byte_array++ = *ptr8++;
+ }
+ break;
+ default:
+ ASSERT(0);
+ }
+ }
+#endif
+
+
+// kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+ sp3g->waiting = KAL_FALSE;
+ sp3g->ul_delay = 0;
+ sp3g->ul_count--;
+// kal_give_spinlock(sp3g_spinlockID);
+ sp3g->ul_read_idx++;
+ if( sp3g->ul_read_idx == sp3g->ul_buffer_size )
+ sp3g->ul_read_idx = 0;
+ sp3g->is_getting_ul_data = KAL_FALSE;
+}
+
+void SP3G_UL_GetSpeechFrame(kal_uint16*frame_index, kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+ sub_SP3G_UL_GetSpeechFrame(frame_index, frame_type, rab_byte_array, len);
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+const uint8 last_sub_flow_id[26] = { 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
+
+// do bit reorder here
+void sub_SP3G_DL_PutSpeechFrame(uint32 CFN, uint8 sub_flow_id, uint8 frame_type, bool crc_status, uint8 *subflow)
+{
+ int32 I;
+ uint8 *ptr8;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ uint8 *ptr8_bak;
+#endif
+ uint16 rabBitsCount, state;
+
+
+ if( (state = L1SP_GetState()) != L1SP_STATE_3G_SPEECH_ON)
+ {
+ if(state == L1SP_STATE_3G_SPEECH_CLOSING){
+ MD_TRC_SP3G_DL_PUT_SPEECH_FRAME_DEBUG(0);
+ }else {
+ MD_TRC_SP3G_DL_PUT_SPEECH_FRAME_DEBUG(1);
+ }
+ return;
+ }
+
+ ASSERT(sp3g != (SP3G_Struct*) 0);
+
+ MD_TRC_SP3G_DL_PUT_SPEECH_FRAME(sub_flow_id, frame_type, crc_status);
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if( sub_flow_id == 0 && (frame_type == 8 || frame_type == 25) ) {
+ //kal_prompt_trace(MOD_L1SP,"SP3G DL Frm %x %x %x %x %x", subflow[0], subflow[1],subflow[2],subflow[3],subflow[4]);
+ MD_TRC_SP3G_DL_BIT_TRUE_TASK(subflow[0], subflow[1],subflow[2],subflow[3],subflow[4]);
+ }
+#endif
+ //if( frame_type == AMR_NO_DATA )
+ // return;
+
+ ASSERT( frame_type <= 25 );
+
+
+
+ if( sp3g_reset_flag == 1 ){
+ sp3g_reset_internal();
+ }
+
+
+ if( sub_flow_id > last_sub_flow_id[frame_type] ){
+ return;
+ }
+
+ if( sp3g->dl_count >= sp3g->dl_buffer_size )
+ {
+ sp3g->dl_read_idx++;
+ if( sp3g->dl_read_idx >= sp3g->dl_buffer_size )
+ sp3g->dl_read_idx = 0;
+ sp3g->dl_count --;
+ }//keep only 2 frame
+
+
+ ptr8 = sp3g->dl_buffer[sp3g->dl_write_idx];
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak = sp3g->dl_buffer2[sp3g->dl_write_idx];
+#endif
+ if( sub_flow_id == 0 )
+ {
+ //frame_len = RAB_subflow[frame_type][3];
+
+ // before first RB-subflow write
+ *ptr8++ = frame_type;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = frame_type;
+#endif
+ *ptr8++ = (uint8)crc_status;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = (uint8)crc_status;
+#endif
+ *ptr8++ = CFN & 0xFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = CFN & 0xFF;
+#endif
+ *ptr8++ = (CFN >> 8) & 0xFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = (CFN >> 8) & 0xFF;
+#endif
+ *ptr8++ = (CFN >> 16) & 0xFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = (CFN >> 16) & 0xFF;
+#endif
+ *ptr8++ = (CFN >> 24) & 0xFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8_bak++ = (CFN >> 24) & 0xFF;
+#endif
+ }
+ else
+ {
+ if( frame_type > AMR_NO_DATA && sub_flow_id == 1 ){
+ //For WB-AMR, the frame type can not be differed in subflow 0,
+ // so that update it at subflow 1
+ *ptr8 = frame_type;//Range 16~25
+ }
+
+ //kal_prompt_trace(MOD_L1SP,"SP3G DL r=%d,w=%d,n=%d",sp3g->dl_read,sp3g->dl_write,sp3g->dl_count);
+ ptr8 += 6;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak += 6;
+#endif
+ for(I = 0 ; I < sub_flow_id ; I ++)
+ {
+ rabBitsCount = RAB_subflow[frame_type][I];
+ ptr8 += (rabBitsCount + 7) >> 3;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ ptr8_bak += (rabBitsCount + 7) >> 3;
+#endif
+ }
+ }
+
+ rabBitsCount = RAB_subflow[frame_type][sub_flow_id];
+
+ for( I = 0; I < (rabBitsCount + 7) >> 3; I++ ){
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ *ptr8++ = *subflow;
+ *ptr8_bak++ = *subflow++;
+#else
+ *ptr8++ = *subflow++;
+#endif
+ }
+
+ // after last RB-subflow write
+ if( sub_flow_id == last_sub_flow_id[frame_type] )
+ {
+ kal_uint8 u8CheckBufFinish = 0;
+ sp3g->dl_write_idx++;
+ if( sp3g->dl_write_idx >= sp3g->dl_buffer_size )
+ sp3g->dl_write_idx = 0;
+#if defined(__SP3G_UL_DSP_RESYNC_CSR__)
+ sp3g->int_time[1] = ust_get_current_time();
+ if(sp3g->int_time[1] > sp3g->int_time[2]){
+ sp3g->int_time[0] = sp3g->int_time[2];
+ }
+
+ MD_TRC_SP3G_DL_TIMING(sp3g->int_time[1]/1000);
+#endif
+#if defined(__SP3G_DIRECT_TO_DSP__)
+ if(sp3g_reset_flag == 2 ){// reset done
+ uint32 time_diff;
+ time_diff = ust_get_duration_true( sp3g->int_time[4], sp3g->int_time[1] );
+ time_diff = ( ( time_diff / 1000 ) - sp3g->uDelW ) % 20; //Time difference between sending-resync and SP3G_DL_PUT_SPEECH_FRAME
+ if(time_diff == 0){ //It's too close, trigger reset
+ MD_TRC_SP3G_FOUND_DL_SYNC_TIMING_ERROR();
+ sp3g_reset_flag = 1;
+ }
+ }
+ if(sp3g_reset_flag == 2 ){// reset done
+ u8CheckBufFinish = 1;
+ }
+#endif
+
+
+ sp3g->dl_count ++;
+ if( sp3g->dl_count == sp3g->dl_buffer_size && sp3g_reset_flag == 0 ){
+ sp3g_reset_flag = 2;// reset done
+ u8CheckBufFinish = 2;
+ }
+
+
+#ifdef __FAKE_3G_LOOPBACK__
+ if(get_is_fake_3g()){
+ sp3g_reset_flag = 2;// reset done
+ u8CheckBufFinish = 1;
+ }
+#endif
+
+ if( u8CheckBufFinish == 1 ){
+#if 1//defined(__UNIFIED_ISR_LEVEL__) //Since MT6290, LISR has been depricated, and only HISR and Task are left. Therefore, to avoid affecting the OS scheduling, System Service prohibits any attempt to invoke HISR from a task level
+ sp3g_hisr_dl((void *)0);
+#else
+/* under construction !*/
+#endif
+ } else if ( u8CheckBufFinish == 2 ){
+#if 1//defined(__UNIFIED_ISR_LEVEL__)
+ sp3g_hisr_dl((void *)2);
+#else
+/* under construction !*/
+#endif
+ MD_TRC_SP3G_DL_BUFFER_FINISH();
+ }
+ }
+}
+
+void SP3G_DL_PutSpeechFrame(uint32 CFN, uint8 sub_flow_id, uint8 frame_type, bool crc_status, uint8 *subflow)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+ sub_SP3G_DL_PutSpeechFrame(CFN, sub_flow_id, frame_type, crc_status, subflow);
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+typedef struct
+{
+ kal_uint8 RSSI;
+ kal_uint8 RSCP;
+ kal_uint8 ECIO;
+ kal_uint8 HHO_SHO;
+/* Used by UMAC */
+ /* Modified CRC = CRC |(S value decision)
+ S value decision=1 => S value < S Threshold. this frame is not reliable
+ S value decision =0 => S value > S Threshold. This frame is reliable
+
+ Modified CRC =0, speech good, CRC=0, S value decision =0
+ Modified CRC=1, CRC =1 or S value decision=1
+
+ crc_result value meaning :
+ 0 : Modified CRC = 0
+ 1 : Modified CRC = 1, CRC = 0
+ 2 : Modified CRC = 1, CRC = 1
+ */
+ kal_uint8 crc_result[3]; /* For Class A/B/C */
+ kal_uint32 s_value[3]; /* For Class A/B/C */
+
+ kal_int16 tpc_SIR_lta; // For recording into speech VM
+ kal_int16 dpdch_SIR_lta; // For recording into speech VM
+ kal_int16 TFCI_max_corr; // For recording into speech VM
+}L1_info_struct;
+
+void SP3G_Log_L1_Info(uint32 CFN, L1_info_struct *p_L1_Info)
+{
+ uint32 *l1_info;
+ uint32 l1_data, crc_result;
+
+ kal_take_enh_mutex( sp_handover_mutex );
+ if(L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON){
+ kal_give_enh_mutex( sp_handover_mutex );
+ return;
+ }
+ l1_info = sp3g->L1_Info[sp3g->l1_info_idx++];
+ sp3g->l1_info_idx &= 0x3;
+
+ l1_info[0] = CFN;
+ l1_data = (uint32)(p_L1_Info->RSSI) + ((uint32)(p_L1_Info->RSCP) << 8) +
+ ((uint32)(p_L1_Info->ECIO) << 16) + ((uint32)(p_L1_Info->HHO_SHO) << 24);
+ crc_result = (uint32)(p_L1_Info->crc_result[0]) + ((uint32)(p_L1_Info->crc_result[1]) << 8) +
+ ((uint32)(p_L1_Info->crc_result[2]) << 16);
+ l1_info[1] = l1_data;
+ l1_info[2] = crc_result;
+ l1_info[3] = p_L1_Info->s_value[0];
+ l1_info[4] = (uint32)p_L1_Info->tpc_SIR_lta;
+ l1_info[5] = (uint32)p_L1_Info->dpdch_SIR_lta;
+ l1_info[6] = (uint32)p_L1_Info->TFCI_max_corr;
+ MD_TRC_SP3G_LOG_L1_INFO(
+ l1_info[0], l1_info[1], crc_result, p_L1_Info->s_value[0], p_L1_Info->s_value[1],p_L1_Info->s_value[2]);
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+void SP3G_Closed_Confirm( void )
+{
+ //ASSERT( L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON );
+ //L1SP_SetState(L1SP_STATE_3G_SPEECH_CLOSED);
+}
+/*====================== CS over HSPA interface ============================*/
+#if defined(__CSHSPA_SUPPORT__)
+void SP3GHSPA_UL_GetSpeechFrame(kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ kal_uint16 frame_index, I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+ kal_take_enh_mutex( sp_handover_mutex );
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else
+//#if 1
+ sub_SP3G_UL_GetSpeechFrame(&frame_index, frame_type, rab_byte_array, len);
+ //reorder to AMR IF1
+ if( *frame_type != AMR_NO_DATA && *frame_type != 25 && *frame_type != AMR_SID_FRAME )
+ {
+ ptr8 = rab_byte_array;
+ ptr8_swap = rab_byte_array;
+ byte_swap = *ptr8_swap;
+ *ptr8 = 0;
+ K = 0;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = RAB_subflow[*frame_type][I];
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order[J & 7])? RAB_Order[K & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ if( (K&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ }
+ if( (J&7) != 0 ){ // avoid false advance a byte
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ //recalculate rab length
+ rabBitsCount = 0;
+ for( I = 0 ; I < 3 ; I++ )
+ rabBitsCount += RAB_subflow[*frame_type][I];
+ *len = ((rabBitsCount+7)>>3);
+ }
+#endif
+ MD_TRC_SP3G_HSPA_UL_GET_SPEECH_FRAME(*frame_type, *len, rab_byte_array[0], rab_byte_array[1]);
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+kal_uint8 subflow_null[32];
+void SP3GHSPA_DL_PutSpeechFrame(kal_uint32 CFN, kal_uint8 frame_type, kal_bool crc_status, kal_uint8 *subflow)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ if(NULL != subflow) {
+ MD_TRC_SP3G_HSPA_DL_PUT_SPEECH_FRAME(frame_type, CFN, crc_status, subflow[0], subflow[1]);
+ }
+ else {
+ MD_TRC_SP3G_HSPA_DL_PUT_SPEECH_FRAME(frame_type, CFN, crc_status, 0, 0);
+ }
+ if( frame_type != AMR_NO_DATA && frame_type != 25 && frame_type != AMR_SID_FRAME ){
+ kal_uint16 I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+
+ K = 0;
+ ptr8_swap = subflow;
+ byte_swap = *ptr8_swap;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = RAB_subflow[frame_type][I];
+ if( rabBitsCount == 0 )
+ break;
+ ptr8 = &sp3g->dl_subflow[0];
+ *ptr8 = 0;//reset
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order[K & 7])? RAB_Order[J & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ if( (K&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ sub_SP3G_DL_PutSpeechFrame(CFN, I, frame_type, crc_status, sp3g->dl_subflow);
+ }
+ } else {
+ if(NULL != subflow) {
+ sub_SP3G_DL_PutSpeechFrame(CFN, 0, frame_type, crc_status, subflow);
+ }
+ else {
+ sub_SP3G_DL_PutSpeechFrame(CFN, 0, frame_type, crc_status, subflow_null);
+ }
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+void SP3GHSPA_DL_SetMaxCsDelay(kal_uint8 max_cs_delay)
+{
+ MD_TRC_SP3G_HSPA_DL_MAX_CS_DELAY(max_cs_delay);
+
+ sp3g_max_cs_delay = (max_cs_delay + 19) / 20;
+ ASSERT(sp3g_max_cs_delay <= 10);
+ if( sp3g_max_cs_delay < 2 )
+ sp3g_max_cs_delay = 2;
+#if 1
+ if(L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON || sp3g == NULL )
+ return;
+
+
+ kal_take_spinlock(sp3g_spinlockID, KAL_INFINITE_WAIT);
+
+ //Already in speech, allow extend buffer size
+ if(sp3g->dl_buffer_size < sp3g_max_cs_delay){
+ sp3g->dl_buffer_size = sp3g_max_cs_delay;
+ }
+
+ kal_give_spinlock(sp3g_spinlockID);
+
+
+#endif
+}
+
+#endif // if defined(__CSHSPA_SUPPORT__)
+
+#endif // __UMTS_RAT__
diff --git a/mcu/driver/audio/src/v1/sp_c2k.c b/mcu/driver/audio/src/v1/sp_c2k.c
new file mode 100644
index 0000000..291fb9a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_c2k.c
@@ -0,0 +1,671 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2015
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+#include "l1aud_common_def.h"
+#include "lmd_audio.h"
+#include "sp_c2k.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+#include "am.h"
+#include "audio_dsp_d2c_def.h"
+#include "l1sp_trc.h"
+#include "media.h"
+#include "lmd_msgid.h"
+#include "sp_drv.h"
+#include "val_msgid.h"
+
+
+static void CodReady( void );
+static void CodClose( void );
+static void CodHBLenGet( uint16 u2RS, IpcSpchSrvcOptRateT u2Rate, uint16 *p2HBLen );
+static void CodParse( IpcSpchSrvcOptT SO );
+static void DLFrameProc(IpcDsvSendSpkrVoiceFwdChPcktDataMsgT *MsgFLDataP);
+SPC2K_Struct spc2k;
+
+ IpcCpSpchDataRevChPacketMsgT MsgLbkUL;
+ IpcDsvSendSpkrVoiceFwdChPcktDataMsgT MsgLbkDL;
+
+uint16 au2ToneTab1K[C2K_COD_RS_1_FULL_LEN_WORD16] = {0x6eac, 0xe370, 0x4862, 0xf8f0, 0x0444, 0x7c16, 0x5e3a, 0x688f, 0x8ca0, 0xc171, 0x4a00};
+uint16 RateReduc_last = 0;
+
+static void CodParse( IpcSpchSrvcOptT SO)
+{
+ switch (SO)
+ {
+ case IPC_SPCH_SRVC_OPTION3:
+ spc2k.u2RS = C2K_COD_RS_1;
+ spc2k.u2Cod = C2K_COD_EVRCA;
+ break;
+
+ case IPC_SPCH_SRVC_OPTION68:
+ spc2k.u2RS = C2K_COD_RS_1;
+ spc2k.u2Cod = C2K_COD_EVRCB;
+ break;
+
+ case IPC_SPCH_SRVC_OPTION73:
+ spc2k.u2RS = C2K_COD_RS_1;
+ spc2k.u2Cod = C2K_COD_EVRCNW_NB;
+ break;
+
+ case IPC_SPCH_SRVC_OPTION73WB:
+ spc2k.u2RS = C2K_COD_RS_1;
+ spc2k.u2Cod = C2K_COD_EVRCNW_WB;
+ break;
+
+ case IPC_SPCH_SRVC_OPTION17:
+ spc2k.u2RS = C2K_COD_RS_2;
+ spc2k.u2Cod = C2K_COD_QCELP13K;
+ break;
+
+ default:
+ break;
+ }
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] RS=%d, Cod=%d", spc2k.u2RS, spc2k.u2Cod);
+ MD_TRC_C2K_SPH_RS_COD_PARSE(spc2k.u2RS, spc2k.u2Cod);
+ //MonTrace (MON_CP_SPH_LINK_PARSE, 2, spc2k.u2RS, spc2k.u2Cod);
+}
+
+static void CodHBLenGet( uint16 u2RS, IpcSpchSrvcOptRateT u2Rate, uint16 *p2HBLen )
+{
+ if (C2K_COD_RS_1 == u2RS)
+ {
+ switch (u2Rate)
+ {
+ case IPC_SPCH_BLANK:
+ *p2HBLen = C2K_COD_RS_1_BLANK_LEN_WORD16;
+ break;
+ case IPC_SPCH_EIGHTH:
+ *p2HBLen = C2K_COD_RS_1_EIGHTH_LEN_WORD16;
+ break;
+ case IPC_SPCH_QUARTER:
+ *p2HBLen = C2K_COD_RS_1_QUARTER_LEN_WORD16;
+ break;
+ case IPC_SPCH_HALF:
+ *p2HBLen = C2K_COD_RS_1_HALF_LEN_WORD16;
+ break;
+ case IPC_SPCH_FULL:
+ *p2HBLen = C2K_COD_RS_1_FULL_LEN_WORD16;
+ break;
+ case IPC_SPCH_ERASURE:
+ *p2HBLen = C2K_COD_RS_1_ERASURE_LEN_WORD16;
+ break;
+ case IPC_SPCH_FULL_LIKELY:
+ *p2HBLen = C2K_COD_RS_1_FULL_LIKELY_LEN_WORD16;
+ break;
+ default:
+ break;
+ }
+ }
+ else if(C2K_COD_RS_2 == u2RS)
+ {
+ switch (u2Rate)
+ {
+ case IPC_SPCH_BLANK:
+ *p2HBLen = C2K_COD_RS_2_BLANK_LEN_WORD16;
+ break;
+ case IPC_SPCH_EIGHTH:
+ *p2HBLen = C2K_COD_RS_2_EIGHTH_LEN_WORD16;
+ break;
+ case IPC_SPCH_QUARTER:
+ *p2HBLen = C2K_COD_RS_2_QUARTER_LEN_WORD16;
+ break;
+ case IPC_SPCH_HALF:
+ *p2HBLen = C2K_COD_RS_2_HALF_LEN_WORD16;
+ break;
+ case IPC_SPCH_FULL:
+ *p2HBLen = C2K_COD_RS_2_FULL_LEN_WORD16;
+ break;
+ case IPC_SPCH_ERASURE:
+ *p2HBLen = C2K_COD_RS_2_ERASURE_LEN_WORD16;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void SPC2K_init( void )
+{
+ spc2k.u4HBFrmCountUL1 = 0;
+ spc2k.u4HBFrmCountUL2 = 0;
+ spc2k.u4HBFrmCountDL1 = 0;
+ spc2k.u4HBFrmCountDL2 = 0;
+ spc2k.bCodRdy = false;
+ spc2k.bSta = false;
+ spc2k.bFstDLFrm = false;
+ spc2k.bAppSta = false;
+ spc2k.bLMDLbk = false;
+ spc2k.bCAALLbk = false;
+ spc2k.u2Cod = C2K_COD_UNDEF;
+ spc2k.u2RS = C2K_COD_RS_UNDEF;
+#ifdef __FAKE_C2K_LOOPBACK__
+ spc2k.u2Dbg = C2K_DBG_BIT_U2D_LOOPBACK | C2K_DBG_BIT_NO_MODEM;
+#else
+ spc2k.u2Dbg = C2K_DBG_BIT_INIT;
+#endif
+#ifndef C2K_SDRV_DISABLE
+ L1Audio_HookHisrHandler(DP_D2C_C2K_DONE_UL,(L1Audio_EventHandler)SPC2K_UL_GetSpeechFrame, 0);
+ L1Audio_HookHisrHandler(DP_D2C_C2K_DONE_DL,(L1Audio_EventHandler)SPC2K_DL_PutSpeechFrame, 0);
+#endif
+}
+
+void SPC2K_ConSSO_Req( uint16 u2SO, uint16 u2MaxEncRate)
+{
+ //MonTrace (MON_CP_SPH_LINK_CON_SSO_REQ, 2, u2SO, u2MaxEncRate);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link connect SSO req, SO=%d, MaxRate=%d", u2SO, u2MaxEncRate);
+ MD_TRC_C2K_SPH_LINK_CON_SSO_REQ(u2SO, u2MaxEncRate);
+ if(true == spc2k.bSta)
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_SSO_REQ_REPEAT, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link SSO req repeat");
+ MD_TRC_C2K_SPH_LINK_CON_SSO_REQ_REPEAT();
+ return;
+ }
+ spc2k.bSta = true;
+ CodParse( u2SO );
+
+#ifndef C2K_SDRV_DISABLE
+ L1SP_C2K_Est(spc2k.u2Cod);
+#else
+ SPC2K_ConSSO_Done();
+#endif
+}
+
+void SPC2K_ConSSO_Done( void )
+{
+ //MonTrace (MON_CP_SPH_LINK_CON_SSO_DONE, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link connect SSO done");
+ MD_TRC_C2K_SPH_LINK_CON_SSO_DONE();
+ if(!(spc2k.u2Dbg & C2K_DBG_BIT_NO_MODEM))
+ {
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_SDRV_SSO_CONN_DONE_MSG, NULL);
+ //ExeMsgSend (EXE_IPC_ID, IPC_MAILBOX_DSPV_ASYN, SDRV_SSO_CONN_DONE, NULL, 0);
+ }
+ else
+ {
+ SPC2K_ConSSO_Done_Rsp();
+ }
+}
+
+void SPC2K_ConSSO_Done_Rsp( void )
+{
+ #ifndef CAAL_DISABLE
+ //enum CAALMsgId MsgId;
+ #endif
+
+ CodReady();
+ spc2k.bFstDLFrm = true;
+ spc2k.u4HBFrmCountUL1 = 0;
+ spc2k.u4HBFrmCountUL2 = 0;
+ spc2k.u4HBFrmCountDL1 = 0;
+ spc2k.u4HBFrmCountDL2 = 0;
+ #ifndef CAAL_DISABLE
+ if(false == spc2k.bCAALLbk)
+ {
+ //MsgId = MSG_ID_CAAL_SSO_CONN_RSP_MSG;
+ if(!(spc2k.u2Dbg & C2K_DBG_BIT_NO_MODEM))
+ {
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SSO_CONN_RSP_MSG, NULL);
+ //CAAL_ReadMsgsFromDsp(MsgId, NULL);
+ }
+ }
+ #endif
+}
+
+void SPC2K_DisconSSO_Req( void )
+{
+ //MonTrace (MON_CP_SPH_LINK_DISCON_SSO_REQ, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link disconnect SSO req");
+ MD_TRC_C2K_SPH_LINK_DISCON_SSO_REQ();
+ if(false == spc2k.bSta)
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_DISCON_SSO_REQ_REPEAT, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link disconnect SSO req repeat");
+ MD_TRC_C2K_SPH_LINK_DISCON_SSO_REQ_REPEAT();
+ return;
+ }
+#ifndef C2K_SDRV_DISABLE
+ L1SP_C2K_DeEst();
+#else
+ SPC2K_DisconSSO_Done();
+#endif
+}
+
+void SPC2K_DisconSSO_Done( void )
+{
+ //MonTrace (MON_CP_SPH_LINK_DISCON_SSO_DONE, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link disconnect SSO done");
+ MD_TRC_C2K_SPH_LINK_DISCON_SSO_DONE();
+ if(!(spc2k.u2Dbg & C2K_DBG_BIT_NO_MODEM))
+ {
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_SDRV_SSO_DISCONN_DONE_MSG, NULL);
+ //ExeMsgSend (EXE_IPC_ID, IPC_MAILBOX_DSPV_ASYN, SDRV_SSO_DISCONN_DONE, NULL, 0);
+ }
+ else
+ {
+ SPC2K_DisconSSO_Done_Rsp();
+ }
+}
+
+void SPC2K_DisconSSO_Done_Rsp( void )
+{
+ #ifndef CAAL_DISABLE
+ //enum CAALMsgId MsgId;
+ #endif
+
+ spc2k.bSta = false;
+ CodClose();
+ #ifndef CAAL_DISABLE
+ if(false == spc2k.bCAALLbk)
+ {
+ if(!(spc2k.u2Dbg & C2K_DBG_BIT_NO_MODEM))
+ {
+ //MsgId = MSG_ID_CAAL_SSO_DISCONN_RSP_MSG;
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SSO_DISCONN_RSP_MSG, NULL);
+ //CAAL_ReadMsgsFromDsp(MsgId, NULL);
+ }
+ }
+ #endif
+}
+
+
+bool SPC2K_State( void )
+{
+ return spc2k.bSta;
+}
+
+static void CodReady( void )
+{
+ //MonTrace (MON_CP_SPH_LINK_COD_RDY, 1, spc2k.bCodRdy);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link cod ready, CodRdy=%d", spc2k.bCodRdy);
+ MD_TRC_C2K_SPH_LINK_COD_RDY(spc2k.bCodRdy);
+ if(!spc2k.bCodRdy)
+ {
+ spc2k.bCodRdy = true;
+ }
+}
+
+static void CodClose( void )
+{
+ //MonTrace (MON_CP_SPH_LINK_COD_CLOSE, 1, spc2k.bCodRdy);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link cod close, CodRdy=%d", spc2k.bCodRdy);
+ MD_TRC_C2K_SPH_LINK_COD_CLOSE(spc2k.bCodRdy);
+ if(spc2k.bCodRdy)
+ {
+ spc2k.bCodRdy = false;
+ }
+}
+
+static void DLFrameProc(IpcDsvSendSpkrVoiceFwdChPcktDataMsgT *MsgFLDataP)
+{
+#ifndef C2K_SAL_DISABLE
+ volatile uint16 *pu2Addr;
+#endif
+ uint16 u2HBLen;
+ uint16 i;
+
+ //check rate
+ if((MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_BLANK) && (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_EIGHTH) &&
+ (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_QUARTER) && (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_HALF) &&
+ (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_FULL) && (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_ERASURE) &&
+ (MsgFLDataP->SpkrVoiceFwdChPcktRate != IPC_SPCH_FULL_LIKELY))
+ {
+ // MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_DL_RATE_ERR, MsgFLDataP->SpkrVoiceFwdChPcktRate, MON_HALT);
+ }
+ CodHBLenGet(spc2k.u2RS, MsgFLDataP->SpkrVoiceFwdChPcktRate, &u2HBLen);
+ //check size
+ if(MsgFLDataP->SpkrVoiceFwdChPcktSize != u2HBLen)
+ {
+ //MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_DL_HB_SIZE_ERR, MsgFLDataP->SpkrVoiceFwdChPcktSize, MON_HALT);
+ }
+ //LBK
+ //MsgLbk.MppSpchRate = MsgFLDataP->SpkrVoiceFwdChPcktRate;
+ //MsgLbk.NumMppSpchData = u2HBLen;
+ //for(i = 0; i < u2HBLen; i++)
+ //{
+ // MsgLbk.MppSpchData[i] = MsgFLDataP->SpkrVoiceFwdChPcktData[i];
+ //}
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link lbk DL, Rate=%d, len=%d", MsgLbk.MppSpchRate, MsgLbk.NumMppSpchData);
+ //kal_trace( TRACE_FUNC, C2K_SPH_LINK_LBK_DL, MsgLbk.MppSpchRate, MsgLbk.NumMppSpchData);
+ //
+ //SPC2K_UL_GetSpeechFrame();
+
+#ifndef C2K_SAL_DISABLE
+ SAL_C2K_SetValue(SAL_C2K_DL_RATE, MsgFLDataP->SpkrVoiceFwdChPcktRate);
+ pu2Addr = SAL_C2K_GetAddr(SAL_C2K_ADDR_RXHB);
+ for(i = 0; i < u2HBLen; i++)
+ {
+ *pu2Addr = MsgFLDataP->SpkrVoiceFwdChPcktData[i];
+ pu2Addr++;
+ }
+ SAL_C2K_SetDLReady();
+#endif
+}
+
+
+void SPC2K_DL_PutSpeechFrame_Do(IpcDsvSendSpkrVoiceFwdChPcktDataMsgT *MsgFLDataP)
+{
+ spc2k.u4HBFrmCountDL1++;
+ spc2k.u4HBFrmCountDL2++;
+ if(!spc2k.bCodRdy)
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_COD_DL_UNRDY, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link cod DL unready");
+ MD_TRC_C2K_SPH_LINK_COD_DL_UNRDY();
+
+ return;
+ }
+
+#ifdef C2K_DTS_DISABLE
+ if(!(spc2k.u2Dbg & C2K_DBG_BIT_U2D_LOOPBACK))
+ {
+ if(spc2k.bFstDLFrm)
+ {
+ //MonTrace (MON_CP_SPH_LINK_COD_1ST_FRAME, 0);
+ spc2k.bFstDLFrm = false;
+ #ifndef C2K_SDRV_DISABLE
+ L1SP_C2K_IntraRAT(spc2k.u2Cod);
+ #endif
+ }
+ else
+ {
+ DLFrameProc(MsgFLDataP);
+ }
+ }
+ else
+ {
+ DLFrameProc(MsgFLDataP);
+ }
+#else
+ DLFrameProc(MsgFLDataP);
+#endif //C2K_DTS_DISABLE
+
+ MD_TRC_C2K_SPH_LINK_RATE_DL(MsgFLDataP->SpkrVoiceFwdChPcktRate);
+ MD_TRC_C2K_SPH_LINK_COD_DL(spc2k.u2Cod);
+ MD_TRC_C2K_SPH_LINK_HB_DL(MsgFLDataP->SpkrVoiceFwdChPcktData[0], MsgFLDataP->SpkrVoiceFwdChPcktData[1], MsgFLDataP->SpkrVoiceFwdChPcktData[2], MsgFLDataP->SpkrVoiceFwdChPcktData[3],
+ MsgFLDataP->SpkrVoiceFwdChPcktData[4], MsgFLDataP->SpkrVoiceFwdChPcktData[5], MsgFLDataP->SpkrVoiceFwdChPcktData[6], MsgFLDataP->SpkrVoiceFwdChPcktData[7], MsgFLDataP->SpkrVoiceFwdChPcktData[8],
+ MsgFLDataP->SpkrVoiceFwdChPcktData[9], MsgFLDataP->SpkrVoiceFwdChPcktData[10]);
+
+ //MonTrace (MON_CP_SPH_LINK_HB_DL1, 10, MsgFLDataP->SpkrVoiceFwdChPcktRate, spc2k.u2RS, spc2k.u4HBFrmCountDL1, MsgFLDataP->SpkrVoiceFwdChPcktData[0], MsgFLDataP->SpkrVoiceFwdChPcktData[1],
+ // MsgFLDataP->SpkrVoiceFwdChPcktData[2], MsgFLDataP->SpkrVoiceFwdChPcktData[3], MsgFLDataP->SpkrVoiceFwdChPcktData[4], MsgFLDataP->SpkrVoiceFwdChPcktData[5],
+ // MsgFLDataP->SpkrVoiceFwdChPcktData[6]);
+ //MonTrace (MON_CP_SPH_LINK_HB_DL2, 5, spc2k.u4HBFrmCountDL2, MsgFLDataP->SpkrVoiceFwdChPcktData[7], MsgFLDataP->SpkrVoiceFwdChPcktData[8], MsgFLDataP->SpkrVoiceFwdChPcktData[9], MsgFLDataP->SpkrVoiceFwdChPcktData[10]);
+}
+
+void SPC2K_SOCM_Set(IpcDsvSendSsoCtrlParamsMsgT *pMsg)
+{
+#ifndef C2K_SAL_DISABLE
+ uint16 u2SOCM;
+ uint16 u2ValId;
+
+ ilm_SP_C2K_RATE_REDUC_NOTI_t *local_para;
+
+ u2SOCM = (pMsg->AudioSsoCtrlRrmLevel << C2K_SOCM_RATE_REDUC_SHIFT) || (pMsg->AudioSsoCtrlM2mMode << C2K_SOCM_MOBILE_TO_MOBILE_SHIFT) || pMsg->AudioSsoCtrlInitCodecMode;
+
+ switch(spc2k.u2Cod)
+ {
+ case SAL_C2K_COD_QCELP13K:
+ u2ValId = SAL_C2K_SOCM_QCELP13K;
+ SAL_C2K_SetValue(u2ValId, u2SOCM);
+ break;
+
+ case SAL_C2K_COD_EVRCA:
+ u2ValId = SAL_C2K_SOCM_EVRCA;
+ SAL_C2K_SetValue(u2ValId, u2SOCM);
+ break;
+
+ case SAL_C2K_COD_EVRCB:
+ u2ValId = SAL_C2K_SOCM_EVRCB;
+ SAL_C2K_SetValue(u2ValId, u2SOCM);
+ break;
+
+ case SAL_C2K_COD_EVRCNW_NB:
+ u2ValId = SAL_C2K_SOCM_EVRCNW_NB;
+ SAL_C2K_SetValue(u2ValId, u2SOCM);
+ break;
+
+ case SAL_C2K_COD_EVRCNW_WB:
+ u2ValId = SAL_C2K_SOCM_EVRCNW_WB;
+ SAL_C2K_SetValue(u2ValId, u2SOCM);
+ break;
+
+ default:
+
+ break;
+ }
+
+ //Ask Sheila to check
+ //pu2RateReduc = (uint16 *)ExeMsgBufferGet(sizeof(uint16));
+ //*pu2RateReduc = pMsg->AudioSsoCtrlRrmLevel;
+
+ //ExeMsgSend (EXE_VAL_ID, VAL_MAILBOX , VAL_SPH_RATE_REDUCE_NOTIFY_MSG, (void *)pu2RateReduc, sizeof(uint16));
+
+ if (RateReduc_last - pMsg->AudioSsoCtrlRrmLevel != 0)
+ {
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] RateReduc_last=%d", RateReduc_last);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] AudioSsoCtrlRrmLevel=%d", pMsg->AudioSsoCtrlRrmLevel);
+ RateReduc_last = pMsg->AudioSsoCtrlRrmLevel;
+ local_para = (ilm_SP_C2K_RATE_REDUC_NOTI_t *) construct_local_para( sizeof(ilm_SP_C2K_RATE_REDUC_NOTI_t), TD_CTRL/*TD_RESET*/ );
+ local_para->pu2RateReduc_EM = pMsg->AudioSsoCtrlRrmLevel;
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] pu2RateReduc_EM=%d", local_para->pu2RateReduc_EM);
+ msg_send6(MOD_L1SP, MOD_CVAL, 0 ,MSG_ID_VAL_IPC_RATE_REDUCTION_MSG, (local_para_struct *)local_para, NULL);
+ }
+
+#endif
+}
+
+void SPC2K_EncMaxRate_Set(IpcDsvSetMicVoiceEncMaxRateMsgT *pMsg)
+{
+ //MonTrace (MON_CP_SPH_LINK_ENC_MAX_RATE, 1, pMsg->MicVoiceEncMaxRate);
+ //Check ENC_MAX_RATE val
+ if((pMsg->MicVoiceEncMaxRate != IPC_SPCH_BLANK) && (pMsg->MicVoiceEncMaxRate != IPC_SPCH_EIGHTH) && (pMsg->MicVoiceEncMaxRate != IPC_SPCH_QUARTER) && (pMsg->MicVoiceEncMaxRate != IPC_SPCH_HALF) && (pMsg->MicVoiceEncMaxRate != IPC_SPCH_FULL))
+ {
+ //MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_ENC_MAX_RATE_VAL_ERR, pMsg->MicVoiceEncMaxRate, MON_HALT);
+ }
+#ifndef C2K_SAL_DISABLE
+ SAL_C2K_SetValue(SAL_C2K_ENC_MAX_RATE, pMsg->MicVoiceEncMaxRate);
+#endif
+}
+
+void SPC2K_UL_GetSpeechFrame( void )
+{
+ uint16 u2SO;
+ uint16 u2HBLen;
+ uint16 i;
+#ifndef C2K_SAL_DISABLE
+ volatile uint16 *pu2Addr;
+ //volatile uint16 *pu2LbkDLAddr;
+#endif
+
+ lmd_tx_spch_msg_struct* MsgRevPktP;
+ //IpcCpSpchDataRevChPacketMsgT MsgRevPkt;
+ spc2k.u4HBFrmCountUL1++;
+ spc2k.u4HBFrmCountUL2++;
+ if(!spc2k.bCodRdy)
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_COD_UL_UNRDY, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link cod UL unready");
+ MD_TRC_C2K_SPH_LINK_COD_UL_UNRDY();
+ return;
+ }
+
+#ifndef C2K_SAL_DISABLE
+ if (false == SAL_C2K_IsULReady())
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_UL_UNSYNC, 0);
+ //kal_prompt_trace(MOD_L1SP, "[C2K][SPH] Link UL unsync");
+ MD_TRC_C2K_SPH_LINK_UL_UNSYNC();
+ SAL_C2K_SetULUnsync();
+ return;
+ }
+#endif
+
+#ifndef C2K_SAL_DISABLE
+ u2SO = SAL_C2K_GetValue(SAL_C2K_VALUE_SO);
+ //check SO
+ if((u2SO != SAL_C2K_COD_QCELP8K) && (u2SO != SAL_C2K_COD_QCELP13K) && (u2SO != SAL_C2K_COD_EVRCA) && (u2SO != SAL_C2K_COD_EVRCB) && (u2SO != SAL_C2K_COD_EVRCNW_NB) && (u2SO != SAL_C2K_COD_EVRCNW_WB))
+ {
+ //MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_SO_ERR, u2SO, MON_HALT);
+ }
+ //check DSP & CAAL SO conflict
+ if(u2SO != spc2k.u2Cod)
+ {
+ //MonTrace (MON_CP_SPH_LINK_WARN_SO_CONFLICT, 0);
+ return;
+ }
+#endif
+
+if(!(spc2k.u2Dbg & C2K_DBG_BIT_NO_MODEM))
+{
+ MsgRevPktP = (lmd_tx_spch_msg_struct *)construct_local_para(sizeof(lmd_tx_spch_msg_struct),TD_RESET);
+ #ifndef C2K_SAL_DISABLE
+ MsgRevPktP->msg.MppSpchRate = SAL_C2K_GetValue(SAL_C2K_VALUE_UL_RATE);
+ #endif
+
+ //check rate
+ if((MsgRevPktP->msg.MppSpchRate != IPC_SPCH_BLANK) && (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_EIGHTH) &&
+ (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_QUARTER) && (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_HALF) &&
+ (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_FULL) && (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_ERASURE) &&
+ (MsgRevPktP->msg.MppSpchRate != IPC_SPCH_FULL_LIKELY))
+ {
+ //MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_UL_RATE_ERR, MsgRevPktP->MppSpchRate, MON_HALT);
+ }
+ CodHBLenGet(spc2k.u2RS, MsgRevPktP->msg.MppSpchRate, &u2HBLen);
+ MsgRevPktP->msg.NumMppSpchData = u2HBLen;
+ #ifndef C2K_SAL_DISABLE
+ pu2Addr = SAL_C2K_GetAddr(SAL_C2K_ADDR_TXHB);
+ for(i = 0; i < u2HBLen; i++)
+ {
+ MsgRevPktP->msg.MppSpchData[i] = *pu2Addr;
+ pu2Addr++;
+ }
+ #endif
+ msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SPH_DATA_UL_MSG, (local_para_struct *) MsgRevPktP);
+ MD_TRC_C2K_SPH_LINK_HB_UL(MsgRevPktP->msg.MppSpchData[0], MsgRevPktP->msg.MppSpchData[1], MsgRevPktP->msg.MppSpchData[2], MsgRevPktP->msg.MppSpchData[3],
+ MsgRevPktP->msg.MppSpchData[4], MsgRevPktP->msg.MppSpchData[5], MsgRevPktP->msg.MppSpchData[6], MsgRevPktP->msg.MppSpchData[7], MsgRevPktP->msg.MppSpchData[8],
+ MsgRevPktP->msg.MppSpchData[9], MsgRevPktP->msg.MppSpchData[10]);
+ MD_TRC_C2K_SPH_LINK_RATE_UL(MsgRevPktP->msg.MppSpchRate);
+}
+
+if(spc2k.u2Dbg & C2K_DBG_BIT_U2D_LOOPBACK)
+{
+ MsgLbkDL.SpkrVoiceFwdChPcktRate = SAL_C2K_GetValue(SAL_C2K_VALUE_UL_RATE);
+ //check rate
+ if((MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_BLANK) && (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_EIGHTH) &&
+ (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_QUARTER) && (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_HALF) &&
+ (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_FULL) && (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_ERASURE) &&
+ (MsgLbkDL.SpkrVoiceFwdChPcktRate != IPC_SPCH_FULL_LIKELY))
+ {
+ //MonFault (MON_IPC_FAULT_UNIT, C2K_LINK_UL_RATE_ERR, MsgRevPktP->MppSpchRate, MON_HALT);
+ }
+ CodHBLenGet(spc2k.u2RS, MsgLbkDL.SpkrVoiceFwdChPcktRate, &u2HBLen);
+ MsgLbkDL.SpkrVoiceFwdChPcktSize = u2HBLen;
+ #ifndef C2K_SAL_DISABLE
+ pu2Addr = SAL_C2K_GetAddr(SAL_C2K_ADDR_TXHB);
+ for(i = 0; i < u2HBLen; i++)
+ {
+ MsgLbkDL.SpkrVoiceFwdChPcktData[i] = *pu2Addr;
+ pu2Addr++;
+ }
+ #endif
+ MD_TRC_C2K_SPH_LINK_LBK_UL(MsgLbkDL.SpkrVoiceFwdChPcktRate, MsgLbkDL.SpkrVoiceFwdChPcktSize);
+ SPC2K_DL_PutSpeechFrame_Do(&MsgLbkDL);
+}
+ SAL_C2K_SetULEmpty();
+
+ MD_TRC_C2K_SPH_LINK_COD_UL(spc2k.u2Cod);
+
+// MonTrace (MON_CP_SPH_LINK_HB_UL1, 10, MsgRevPktP->MppSpchRate, spc2k.u2RS, spc2k.u4HBFrmCountUL1, MsgRevPktP->MppSpchData[0], MsgRevPktP->MppSpchData[1],
+// MsgRevPktP->MppSpchData[2], MsgRevPktP->MppSpchData[3], MsgRevPktP->MppSpchData[4], MsgRevPktP->MppSpchData[5],
+// MsgRevPktP->MppSpchData[6]);
+// MonTrace (MON_CP_SPH_LINK_HB_UL2, 5, spc2k.u4HBFrmCountUL2, MsgRevPktP->MppSpchData[7], MsgRevPktP->MppSpchData[8], MsgRevPktP->MppSpchData[9], MsgRevPktP->MppSpchData[10]);
+
+#ifndef CAAL_DISABLE
+ //if(true == spc2k.bCAALLbk)
+ //{
+ // SAL_C2K_SetValue(SAL_C2K_DL_RATE, MsgRevPktP->msg.MppSpchRate);
+ // pu2LbkDLAddr = SAL_C2K_GetAddr(SAL_C2K_ADDR_RXHB);
+ // for(i = 0; i < u2HBLen; i++)
+ // {
+ // *pu2LbkDLAddr = MsgRevPktP->msg.MppSpchData[i];
+ // pu2LbkDLAddr++;
+ // }
+ // //ExeMsgBufferFree(MsgRevPktP);
+ // //MsgRevPktP = NULL;
+ //}
+ //else
+ //{
+ // MsgId = MSG_ID_CAAL_SPH_DATA_UL_MSG;
+ // msg_send5(MOD_L1SP ,MOD_SPCH ,0x0 ,MSG_ID_CAAL_SPH_DATA_UL_MSG, (local_para_struct *) MsgRevPktP);
+ // //CAAL_ReadMsgsFromDsp(MsgId, (void *)MsgRevPktP);
+ //}
+#endif
+}
+
+void SPC2K_DL_PutSpeechFrame(IpcDsvSendSpkrVoiceFwdChPcktDataMsgT *MsgFLDataP)
+{
+ if(true == spc2k.bCAALLbk)
+ {
+ SPC2K_DL_PutSpeechFrame_Do(MsgFLDataP);
+ }
+}
+
+void SPC2K_GetSyncDelayRW( uint16 *u2DelR, uint16 *u2DelW, uint16 *u2DelM)
+{
+ SAL_Get_Delay(SAL_DEALY_C2K, SAL_DELAY_NA, SAL_DELAY_NA, u2DelR, u2DelW, u2DelM);
+ //MonTrace (MON_CP_SPH_LINK_DELRWM, 3, *u2DelR, *u2DelW, *u2DelM);
+}
+
+void SPC2K_Link_Lbk(HwdSphLbkMsgT *pMsg)
+{
+ //MonTrace (MON_CP_SPH_LINK_LBK, 3, pMsg->u2Mode, pMsg->u2SO, pMsg->bStart);
+ //#ifndef CAAL_DISABLE
+ //if(C2K_LMD_LBK == pMsg->u2Mode)
+ //{
+ // CAAL_Loopback_LMD(pMsg->u2SO, pMsg->bStart);
+ //}
+ //else if(C2K_CAAL_LBK == pMsg->u2Mode)
+ //{
+ // CAAL_Loopback_CAAL(pMsg->u2SO, pMsg->bStart);
+ //}
+ //#endif
+}
+
+void SPC2K_Debug_Info(IpcDsvSendAudioChanQltyMsgT * pMsg)
+{
+#ifndef C2K_SAL_DISABLE
+ SAL_C2K_SetValue(SAL_C2K_EBNT, pMsg->EbNt);
+#endif
+}
diff --git a/mcu/driver/audio/src/v1/sp_cc.c b/mcu/driver/audio/src/v1/sp_cc.c
new file mode 100644
index 0000000..63938e0
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_cc.c
@@ -0,0 +1,564 @@
+#include "kal_public_defs.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "sp_cc.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "media.h"
+
+
+//DEFINE_C_SHARED_VAR(kalcc_rcuid, aud_P2L_rcu);
+kalcc_rcuid aud_P2L_rcu;
+DEFINE_RCU_DC_ARRAY(kal_uint8, aud_P2L_rcu_mem, RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2)); // 1024 bytes * 1 blocks
+
+//DEFINE_C_SHARED_VAR(kalcc_rcuid, aud_L2P_rcu);
+kalcc_rcuid aud_L2P_rcu;
+DEFINE_RCU_DC_ARRAY(kal_uint8, aud_L2P_rcu_mem, RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2)); // 1024 bytes * 1 blocks
+
+//DECLARE_SHARED_VAR(cc_eventgrpid, AUD_P2L);
+//DEFINE_C_SHARED_VAR(cc_eventgrpid, AUD_P2L);
+cc_eventgrpid AUD_P2L;
+
+//DECLARE_SHARED_VAR(cc_eventgrpid, AUD_L2P);
+//DEFINE_C_SHARED_VAR(cc_eventgrpid, AUD_L2P);
+cc_eventgrpid AUD_L2P;
+
+typedef struct {
+ kal_uint32 event_id;
+ kal_uint32 event_param1;
+ kal_uint32 event_param2;
+} SP_CC_EVENT_PARAM;
+
+RINGBUFFER_T(SP_CC_EVENT_PARAM,32) qsp_cc_event_param;
+extern kal_enhmutexid sp_handover_mutex;
+
+
+static kal_uint32 u32BT_SCO_LISR_L2P_counter;
+
+extern void L1Audio_DSP2MCU_Interrupt();
+#if defined(__CVSD_CODEC_SUPPORT__)
+extern void BT_SCO_LISR(void);
+#endif //#if defined(__CVSD_CODEC_SUPPORT__)
+
+
+extern kal_enhmutexid sp_cc_mutex;
+
+void SP_CC_Event_Handler()
+{
+ //send a message to MED
+ SP_CC_EVENT_PARAM sp_cc_event_param_local;
+
+ while( !RB_EMPTY(qsp_cc_event_param) ){
+ ilm_SP_CHANGERATE_EVENT_t *local_para;
+ RB_GET( qsp_cc_event_param, sp_cc_event_param_local );
+ MD_TRC_SP_CC_EVENT_HANDLER_ENTER(sp_cc_event_param_local.event_id, sp_cc_event_param_local.event_param1, sp_cc_event_param_local.event_param2);
+ local_para = (ilm_SP_CHANGERATE_EVENT_t *) construct_local_para( sizeof(ilm_SP_CHANGERATE_EVENT_t), TD_CTRL );
+
+ switch(sp_cc_event_param_local.event_id){
+ case IRQ_L2P_TCH_NOTIFY:
+ local_para->event = SP_2G_TCH;
+ break;
+ case IRQ_L2P_2G_HANDOVER:
+ local_para->event = SP_2G_HANDOVER;
+ break;
+ case IRQ_L2P_2G_AUDIOMANAGER_INFO:
+ local_para->event = SP_2G_AUDIOMANAGER_INFO;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ local_para->param[0] = sp_cc_event_param_local.event_param1;
+ local_para->param[1] = sp_cc_event_param_local.event_param2;
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_CHANGERATE_EVENT, (local_para_struct *)local_para, NULL);
+ MD_TRC_SP_CC_EVENT_HANDLER_LEAVE();
+ }
+}
+
+void cc_irq_lisr_aud(kal_uint32 event_id, kal_uint32 param1, kal_uint32 param2)
+{
+ SP_CC_EVENT_PARAM sp_cc_event_param_local;
+ void L1Audio_CCSetEvent( void );
+
+ sp_cc_event_param_local.event_id = event_id;
+ sp_cc_event_param_local.event_param1 = param1;
+ sp_cc_event_param_local.event_param2 = param2;
+ RB_PUT( qsp_cc_event_param, sp_cc_event_param_local );
+ L1Audio_CCSetEvent();
+}
+
+//ToDO move Task Init
+void SP_CC_Init()
+{
+ RB_INIT( qsp_cc_event_param );
+
+ u32BT_SCO_LISR_L2P_counter = 0;
+
+ ASSERT( KAL_SUCCESS == kalcc_create_event_group( SHARED_pVAR(AUD_L2P), "receive_AUD_L2P_eg" ) );
+
+ SHARED_VAR(aud_P2L_rcu) = rcu_create((void *)SHARED_ARRAY(aud_P2L_rcu_mem), RCU_MEMORY_SIZE(CC_BUFFER_SIZE * sizeof(kal_uint32), 2), CC_BUFFER_SIZE * sizeof(kal_uint32), 0);
+
+}
+
+//audio_service.c
+void cc_InvokeLCoreFunction(kal_uint32 P2L_Buf[CC_BUFFER_SIZE], kal_uint32 L2P_Buf[CC_BUFFER_SIZE])
+{
+ int i;
+ kal_uint32 *P2L_rcu_buf;
+ kal_uint32 *L2P_rcu_buf;
+ kal_uint32 retrieved_events;
+
+ kal_take_enh_mutex( sp_cc_mutex );
+
+ ASSERT(P2L_Buf[1] <= CC_MAX_DATA);
+
+ // P -> L invoke a LCore side's function
+ //Prepare Params
+ MD_TRC_SP_CC_INVOKELCORE(1);
+ P2L_rcu_buf = rcu_get_free_buff(SHARED_VAR(aud_P2L_rcu));
+ //dynamic_switch_cacheable_region(&P2L_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_CACHEABLE);
+
+ MD_TRC_SP_CC_INVOKELCORE(2);
+ for(i=0; i<CC_BUFFER_SIZE; i++){
+ P2L_rcu_buf[i] = P2L_Buf[i];
+ MD_TRC_SP_CC_INVOKELCORE_INFO(3, i, P2L_Buf[i]);
+ }
+ //dynamic_switch_cacheable_region(&P2L_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_NO_CACHE);
+ ASSERT(KAL_SUCCESS == rcu_commit_data(P2L_rcu_buf));
+
+ MD_TRC_SP_CC_INVOKELCORE(4);
+ //Send A CrossCore Message
+ kalcc_set_eg_events(SHARED_pVAR(AUD_P2L), 0xFF, KAL_OR);
+
+ // L -> P Get return values
+ //Wait for the response
+ MD_TRC_SP_CC_INVOKELCORE(5);
+ kalcc_retrieve_eg_events(SHARED_pVAR(AUD_L2P), 0xFF, KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND);
+
+ //Retrieve returns
+ MD_TRC_SP_CC_INVOKELCORE(6);
+ L2P_rcu_buf = rcu_get_read_lock(SHARED_VAR(aud_L2P_rcu));
+ //dynamic_switch_cacheable_region(&L2P_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_CACHEABLE);
+
+ for(i=0; i<CC_BUFFER_SIZE; i++){
+ L2P_Buf[i] = L2P_rcu_buf[i];
+ MD_TRC_SP_CC_INVOKELCORE_INFO(7, i, L2P_Buf[i]);
+ }
+ //dynamic_switch_cacheable_region(&L2P_rcu_buf, ALIGNTOCACHELINE(CC_BUFFER_SIZE * sizeof(kal_uint32)), PAGE_NO_CACHE);
+ ASSERT( KAL_SUCCESS == rcu_free_read_lock(L2P_rcu_buf));
+
+ ASSERT( ( P2L_Buf[0] | 0x8000 ) == L2P_Buf[0] );
+
+ kal_give_enh_mutex( sp_cc_mutex );
+}
+
+
+void cc_L1D_Audio_ChkDspInitDone()
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_L1D_AUD_CHKDSPINITDONE;
+ P2L_Buf[1] = 0;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+kal_uint16 cc_L1D_Audio_RestartDSP()
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_AUD_RESTART_DSP;
+ P2L_Buf[1] = 0;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 1 == L2P_Buf[1]);
+ return L2P_Buf[2];
+}
+
+void cc_L1D_Audio_NoNeedDSP()
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_AUD_NONEEDDSP;
+ P2L_Buf[1] = 0;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_set_VBI_for_FSM(kal_uint32 state)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_SET_VBI_FOR_FSM;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = state;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_Standby_Call_Open(kal_uint32 enc_mod)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_STANDBY_CALL_ON;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = enc_mod;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ L1SP_Set_isStandByMode(true);
+}
+
+
+void cc_Standby_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_STANDBY_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ L1SP_Set_isStandByMode(false);
+}
+
+
+//am.c
+void cc_2G_Call_Open(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 sub_channel, kal_uint32 resetType)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_2G_CALL_ON;
+ P2L_Buf[1] = 4;
+ P2L_Buf[2] = enc_mod; P2L_Buf[3] = dec_mod; P2L_Buf[4] = sub_channel; P2L_Buf[5] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_2G_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_2G_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+}
+
+void cc_2G_Call_Handover(kal_uint32 speech_mode, kal_uint32 sub_channel)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_2G_HANDOVER;
+ P2L_Buf[1] = 3;
+ P2L_Buf[2] = speech_mode;
+ P2L_Buf[3] = speech_mode;
+ P2L_Buf[4] = sub_channel;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_3G_Call_Open(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us,
+ kal_uint32 resetType)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_3G_CALL_ON;
+ P2L_Buf[1] = 8;
+ P2L_Buf[2] = enc_mod; P2L_Buf[3] = dec_mod; P2L_Buf[4] = dtx;
+ P2L_Buf[5] = delR; P2L_Buf[6] = delW; P2L_Buf[7] = delM;
+ P2L_Buf[8] = u32CurTime64us; P2L_Buf[9] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_3G_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_3G_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+}
+
+void cc_4G_Call_Open_temp(kal_uint32 enc_mod, kal_uint32 dec_mod, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_CALL_ON;
+ P2L_Buf[1] = 8;
+ P2L_Buf[2] = enc_mod; P2L_Buf[3] = dec_mod; P2L_Buf[4] = dtx;
+ P2L_Buf[5] = delR; P2L_Buf[6] = delW; P2L_Buf[7] = delM;
+ P2L_Buf[8] = u32CurTime64us;
+ P2L_Buf[9] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_4G_Call_Close_temp(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+}
+
+void cc_4G_G_Codec_Call_Open(kal_uint32 band_mod, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us,
+ kal_uint32 resetType)
+{
+ int i;
+// ASSERT(false);
+ #if 1
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_G_Codec_CALL_ON;
+ P2L_Buf[1] = 6;
+ P2L_Buf[2] = band_mod; P2L_Buf[3] = delR; P2L_Buf[4] = delW;
+ P2L_Buf[5] = delM; P2L_Buf[6] = u32CurTime64us;
+ P2L_Buf[7] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ #endif
+}
+
+void cc_4G_G_Codec_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+// ASSERT(false);
+ #if 1
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_G_Codec_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+ #endif
+}
+
+
+void cc_4G_EVS_Codec_Call_Open(kal_uint32 codec, uint32 isDTX, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM, kal_uint32 u32CurTime64us, kal_uint32 resetType)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_EVS_Codec_CALL_ON;
+ P2L_Buf[1] = 7;
+ P2L_Buf[2] = codec; P2L_Buf[3] = isDTX; P2L_Buf[4] = delR;
+ P2L_Buf[5] = delW; P2L_Buf[6] = delM; P2L_Buf[7] = u32CurTime64us;
+ P2L_Buf[8] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+
+void cc_4G_EVS_Codec_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_4G_EVS_Codec_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+}
+
+
+void cc_C2K_Call_Open(kal_uint32 so, kal_uint32 dtx, kal_uint32 delR, kal_uint32 delW, kal_uint32 delM,
+ kal_uint32 resetType)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_C2K_CALL_ON;
+ P2L_Buf[1] = 6;
+ P2L_Buf[2] = so;
+ P2L_Buf[3] = dtx;
+ P2L_Buf[4] = delR;
+ P2L_Buf[5] = delW;
+ P2L_Buf[6] = delM;
+ P2L_Buf[7] = resetType;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+}
+
+void cc_C2K_Call_Close(kal_uint32 dsp_end)
+{
+ int i;
+ kal_uint32 P2L_Buf[CC_BUFFER_SIZE];
+ kal_uint32 L2P_Buf[CC_BUFFER_SIZE];
+
+ if( L1SP_Get_isStandByMode() ) {
+ cc_Standby_Call_Close(true);
+ }
+ else {
+ // clear internal buffer
+ for( i = 0; i < CC_BUFFER_SIZE ; i++){
+ P2L_Buf[i] = L2P_Buf[i] = 0 ;
+ }
+
+ P2L_Buf[0] = MSG_P2L_C2K_CALL_OFF;
+ P2L_Buf[1] = 1;
+ P2L_Buf[2] = dsp_end;
+ cc_InvokeLCoreFunction(P2L_Buf, L2P_Buf);
+ ASSERT( 0 == L2P_Buf[1]);
+ }
+}
+
+void SP_L2P_Handler(ilm_struct *ilm_ptr)
+{
+ switch (ilm_ptr->msg_id) {
+ case MSG_ID_AUDIO_L2P_SP3G_UPDATE_L1_INFO:
+ {
+ ilm_L2P_SP3G_UPDATE_L1_INFO *local_para = (ilm_L2P_SP3G_UPDATE_L1_INFO *)(ilm_ptr->local_para_ptr);
+ MD_TRC_SP_CC_L2P_Hdler(0, local_para->l1_info[0], local_para->l1_info[1]);
+ SP3G_UpdateL1AInFo_P(local_para->l1_info[0], local_para->l1_info[1]);
+ }
+ break;
+ default:
+ {
+ MD_TRC_SP_CC_L2P_Hdler_Err(ilm_ptr->msg_id);
+ break;
+ }
+ }
+}
diff --git a/mcu/driver/audio/src/v1/sp_daca.c b/mcu/driver/audio/src/v1/sp_daca.c
new file mode 100644
index 0000000..3a3a068
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_daca.c
@@ -0,0 +1,199 @@
+#include "kal_public_api.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "l1audio.h"
+#include "am.h"
+// #include "audio_def.h"
+#include "afe_def.h"
+#include "media.h"
+#include "sp_daca.h"
+#include "sp_drv.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+#include "l1sp_trc.h"
+#define DACA_STATE 0x4
+
+
+static _DACA_EX_T dacaEx;
+
+void Daca_hisrDlHdlr(void *param)
+{
+ kal_take_spinlock(dacaEx.DACASpinLockID, KAL_INFINITE_WAIT);
+ if(dacaEx.running == 0){
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+ return;
+ }
+ dacaEx.daca_dl_hdlr();
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+}
+
+void Daca_hisrUlHdlr(void *param)
+{
+ kal_take_spinlock(dacaEx.DACASpinLockID, KAL_INFINITE_WAIT);
+ if(dacaEx.running == 0){
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+ return;
+ }
+ dacaEx.daca_ul_hdlr();
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+}
+
+void DACA_Init()
+{
+ dacaEx.DACASpinLockID = kal_create_spinlock("DACA_LOCK");
+
+}
+
+void DACA_Start(void (*daca_dl_hdlr)(void), void (*daca_ul_hdlr)(void), DACA_APP_TYPE app_type)
+{
+ uint32 I;
+ //Sal_PCMEx_Config_t cfg_t;
+
+ //cfg_t.idle = false;//initialized;
+ dacaEx.aud_daca_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( dacaEx.aud_daca_id );
+
+ L1Audio_HookHisrHandler(DP_D2C_DACA_REQ_DL,(L1Audio_EventHandler)Daca_hisrDlHdlr, 0);
+ L1Audio_HookHisrHandler(DP_D2C_DACA_REQ_UL,(L1Audio_EventHandler)Daca_hisrUlHdlr, 0);
+ dacaEx.daca_dl_hdlr = daca_dl_hdlr;
+ dacaEx.daca_ul_hdlr = daca_ul_hdlr;
+
+ dacaEx.app_type = app_type;
+
+ if(app_type & DACA_IN_PHONE_CALL){
+ dacaEx.am_type = AM_PCMEX_TYPE_DACA_DEDICATION;
+ }else{
+ dacaEx.am_type = AM_PCMEX_TYPE_DACA_IDLE_WO_ENH;
+ }
+
+ if(app_type & DACA_USE_NB){
+ dacaEx.frame_size = 160;//PCMNWAY_BAND_INFO_NB;
+ // cfg_t.band = SAL_PCM_NARROWBAND;
+ }else if(app_type & DACA_USE_WB){
+ dacaEx.frame_size = 320;//PCMNWAY_BAND_INFO_WB;
+ // cfg_t.band = SAL_PCM_WIDEBAND;
+ }else if(app_type & DACA_USE_SWB){
+ dacaEx.frame_size = 640;//PCMNWAY_BAND_INFO_WB;
+ // cfg_t.band = SAL_PCM_WIDEBAND;
+ }else if(app_type & DACA_USE_FB){
+ dacaEx.frame_size = 960;//PCMNWAY_BAND_INFO_WB;
+ // cfg_t.band = SAL_PCM_WIDEBAND;
+ }else{
+ ASSERT(0);
+ }
+
+ /* the begining of configure the SAL */
+ if(app_type & DACA_USE_UL){
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_ON);
+ }
+
+ if(app_type & DACA_USE_DL){
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_ON);
+ }
+ //cfg_t.swi = SAL_PCMEX_SWITCH_ON;
+ //cfg_t.type = SAL_PCMEX_TYPE_DACA;
+ //cfg_t.band = (app_type & DACA_USE_NB) ? SAL_PCM_NARROWBAND : SAL_PCM_WIDEBAND;
+
+ AM_PCM_EX_On(dacaEx.am_type, (uint32)&dacaEx);
+ for(dacaEx.state = DACA_STATE, I = 0; ;I ++){
+ kal_bool is_ready = true;
+ if((dacaEx.app_type & DACA_USE_UL) && (!SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY)))
+ is_ready = false;
+ if((dacaEx.app_type & DACA_USE_DL) && (!SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY)))
+ is_ready = false;
+
+ if(is_ready)
+ break;
+ MD_TRC_DACA_DBG(I);
+ ASSERT(I < 25); // wait 250ms
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ kal_take_spinlock(dacaEx.DACASpinLockID, KAL_INFINITE_WAIT);
+ dacaEx.running = 1;
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+ /* the end of configure the SAL */
+}
+
+void DACA_Stop(DACA_APP_TYPE app_type)
+{
+ // Sal_PCMEx_Config_t cfg_t;
+
+ // cfg_t.idle = false;//initialized
+ kal_take_spinlock(dacaEx.DACASpinLockID, KAL_INFINITE_WAIT);
+ dacaEx.running = 0;
+ kal_give_spinlock(dacaEx.DACASpinLockID);
+ ASSERT((dacaEx.app_type == app_type) && (dacaEx.state == DACA_STATE));
+
+ /* the begining of configure the SAL */
+ if(dacaEx.app_type & DACA_USE_UL){//either ready or off
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY));
+ }else{
+ ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF));
+ }
+
+ if(dacaEx.app_type & DACA_USE_DL){//either ready or off
+ ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY));
+ }else{
+ ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF));
+ }
+
+ SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF);
+ SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF);
+
+ // cfg_t.swi = SAL_PCMEX_SWITCH_OFF;
+ // cfg_t.type = SAL_PCMEX_TYPE_DACA;
+ AM_PCM_EX_Off(dacaEx.am_type, (uint32)&dacaEx);
+ /* the end of configure the SAL */
+
+ L1Audio_UnhookHisrHandler(DP_D2C_DACA_REQ_DL);
+ L1Audio_UnhookHisrHandler(DP_D2C_DACA_REQ_UL);
+
+ L1Audio_ClearFlag( dacaEx.aud_daca_id );
+ L1Audio_FreeAudioID( dacaEx.aud_daca_id );
+
+ dacaEx.daca_dl_hdlr = dacaEx.daca_ul_hdlr = NULL;
+ dacaEx.state = 0;
+ dacaEx.app_type = DACA_APP_TYPE_UNDEFINE;
+ dacaEx.am_type = 0xFFFF;
+}
+
+
+uint32 DACA_GetFromSD(uint16 *dl_buf)
+{
+ uint32 I;
+ uint32 fsize = dacaEx.frame_size;
+
+ volatile int16* ptr = (int16 *)SAL_PcmEx_GetBuf(SAL_PCMEX_DACA_BUF_DL);
+ int16 *out_buf = (int16 *)dl_buf;
+
+ int32 gain = AM_DSP_GetSpeechDigitalGain();
+ ASSERT(gain > 0 && gain <= 4096);
+
+ for( I = 0 ; I < fsize; I++ ){
+ //*out_buf++ = (*ptr++ * gain) >> 12;
+ *out_buf++ = *ptr++;
+ }
+ return fsize;
+}
+
+void DACA_PutToSE(const uint16 *ul_data)
+{
+ uint32 I;
+ uint32 fsize = dacaEx.frame_size;
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_DACA_BUF_UL);
+ for( I = fsize; I > 0; I-- )
+ *ptr++ = *ul_data++;
+ Data_Sync_Barrier();
+}
+
+void DACA_FillSE(uint16 value)
+{
+ uint32 I;
+ uint32 fsize = dacaEx.frame_size;
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_DACA_BUF_UL);
+ for( I = fsize; I > 0; I-- )
+ *ptr++ = value;
+ Data_Sync_Barrier();
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_drv.c b/mcu/driver/audio/src/v1/sp_drv.c
new file mode 100644
index 0000000..abf3a36
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_drv.c
@@ -0,0 +1,3502 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * l1sp.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * L1SP Interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c#15
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c#16
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c#14
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c#15
+<<<<
+ * removed!
+ * removed!
+ * removed!
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/sp_drv.c
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+<<<<
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "string.h"
+#include "reg_base.h"
+// #include "custom_equipment.h" /* custom_cfg_audio_ec_range() */
+#include "device.h" /* MAX_VOL_LEVEL, in ps\l4\include */
+#include "audcoeff_default.h"
+#include "gmss_public.h"
+//#include "l4_ps_api.h" //for query_ps_conf_test_mode()
+
+// #include "audio_def.h"
+#include "l1audio.h"
+#include "l1audio_trace_utmd.h"
+#include "l1audio_voc_utmd.h"
+#include "l1sp_trc.h"
+#include "l1audio_sph_trc.h"
+
+#include "media.h"
+#include "sp_enhance.h"
+#include "afe.h"
+#include "am.h"
+#include "vm.h"
+#include "sal_def.h"
+#include "sal_exp.h"
+#include "bgSnd.h"
+#include "spc_drv.h"
+#include "extcodec.h"
+
+#include "mml1_rf_global.h"
+#include "sp_drv.h"
+
+#include "ps_em_exported_enum.h"
+#include "ps_public_utility.h"
+
+#if defined(__DATA_CARD_SPEECH__) || defined(__BT_SCO_CODEC_SUPPORT__)
+#include "sp_daca.h"
+#endif
+
+#ifdef __TWOMICNR_SUPPORT__
+#include "two_mic_NR_custom_if.h"
+#endif
+
+#if !defined(__SMART_PHONE_MODEM__)
+#include "apAudSysConfig.h"
+#else
+
+#endif
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+#include "bt_sco_drv.h"
+#endif
+
+#if defined(__VOLTE_SUPPORT__)
+#include "l1audio.h"
+#include "sp_ps.h"
+#endif
+
+#include "speech_service.h"
+#include "sp_cc.h"
+
+// for modem project, DONGLE product use
+
+#include "audio_msgid.h"
+#include "drv_sap.h"
+// #include "aud_common_config.h" // for DEFAULT_SPEECH_COMMON_PARA. in customer folder
+#if defined(__C2K_SPEECH_SUPPORT__)
+#include "lmd_audio.h"
+#endif
+
+#if defined( __UMTS_RAT__ )
+//#include "uas_export_api.h"
+#include "csr_export_api.h"
+#endif
+#include "sp_dsptone_drv.h"
+#include "ctm_drv.h"
+
+#if defined(__HIF_CCCI_SUPPORT__)
+#include "ccci_if.h"
+#endif
+
+#include "cache_sw.h"
+/* ------------------------------------------------------------------------------ */
+/* Speech Interface */
+/* ------------------------------------------------------------------------------ */
+
+static struct {
+ uint8 devSr;
+ sp_device_info_t devInfo;
+ sp_ext_dev_info_t extDevInfo;
+
+ uint16 aud_id;
+ uint16 aud_id_network_status;
+ uint16 aud_id_em_codec_update;
+ uint16 aud_id_voice_quality_event;
+
+ uint16 sph_c_para[NUM_COMMON_PARAS];
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ uint16 sph_m_para[NUM_MODE_PARAS];
+ // uint16 sph_v_para[NUM_VOL_PARAS]; // useless, should fine time to remove it
+ uint16 sph_m_paraWb[NUM_MODE_PARAS];
+ uint16 sph_m_paraSWb[NUM_MODE_PARAS];
+#endif
+ uint8 mic_volume; // [analog+digital gain]value corrently set to DSP&HW; when ANALOG_AFE_PATH_EXIST is NOT defined, this is 0
+
+ uint16 isULMute; // flag to keep the DSP UL MUTE states
+ bool isDLMute; // flag to keep the DSP DL MUTE states
+
+ bool isUlSourceMute;
+ bool codec_mute;
+ bool dl_codec_mute_by_ap;
+ bool dl_pre_PcmMixer_mute;
+ L1SP_L4C_Event_Mode codec_mute_mode;
+ bool tch_state; // true: TCH on; false: TCH off
+ uint8 state; // recording the network is 2G or 3G
+ bool isStandByMode; // recording any RAB exist
+
+ L1SP_L4C_Codec pre_l4c_codec; // remind to clean the codec in MED task
+#if defined( __UMTS_RAT__ )
+ bool interRAT;
+#endif
+
+#if defined(__DATA_CARD_SPEECH__)
+ void (*strmOnHandler)(void *);
+ void (*strmOffHandler)(void *);
+ void (*strmHdl)(kal_uint32 event, void *param);
+#endif
+
+
+#if defined(__ECALL_SUPPORT__)
+ void (*pcm4wayOnHandler)(void *);
+ void (*pcm4wayOffHandler)(void *);
+#endif
+
+ bool isEmCodecNotifyOff;
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+ int c2k_so_codec;
+ bool isSO_Connected;
+ bool isConSSO_Done;
+#endif
+ void (*rampDoneHandler)(void *);
+ kal_uint32 AUIF_EMI_addr;
+ kal_uint32 AUIF_EMI_size;
+
+ kal_uint32 *SphParamBuffer;
+ kal_uint32 SphParamBufferSize;
+
+ kal_uint32 *SphOpenDSPBuffer;
+ kal_uint32 SphOpenDSPBufferSize;
+
+ kal_uint8 opendsp_flag;/* 0: internal SPE, 1: OpenDSP */
+} l1sp = {0};
+extern kal_enhmutexid sp_handover_mutex;
+
+static kal_timerid sp_vmFilterChk_timer;
+static kal_timerid sp_emCodec_timer;
+static SP_EM_VOICE_QUALITY_INFO sp_emVoiceQuality;
+extern void vt_SP3G_Callback( kal_uint8 event, void *data );
+extern void CSR_Codec_Ready(int rab_id);
+extern void CSR_Codec_Close(int rab_id);
+extern kal_uint32 SP3G_GetCodecMode(void);
+extern kal_uint32 SP4G_GetCodecMode(void);
+
+extern void l1audio_sph_srv_SMMT_Start(void);
+extern void l1audio_sph_srv_SMMT_End(void);
+
+
+#if defined( __UMTS_RAT__ )
+SP_3G_SIM L1SP_GetSIMStatus()
+{
+#ifdef __FAKE_3G_LOOPBACK__
+ return SP_3G_SIM_FDD_ACTIVE;
+#else
+ if( gmss_is_wcdma_mode_activated( FDD_CSR_ACTIVE_SIM()) ) {
+ return SP_3G_SIM_FDD_ACTIVE;
+ }else if( gmss_is_tdscdma_mode_activated( TDD_CSR_ACTIVE_SIM())){
+ return SP_3G_SIM_TDD_ACTIVE;
+ }else{
+ return SP_3G_SIM_IDLE;
+ }
+#endif
+}
+#endif
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+
+
+void L1SP_C2K_IntraRAT( int codec )
+{
+ int16 aud_id;
+ ASSERT(l1sp.isSO_Connected);
+ MD_TRC_C2K_SPH_INTRARAT(0);
+ kal_take_enh_mutex( sp_handover_mutex );
+ aud_id = L1SP_GetAudID();
+ AM_C2K_IntraRAT(codec);
+ L1SP_FreeAudID(aud_id);
+ kal_give_enh_mutex( sp_handover_mutex );
+ MD_TRC_C2K_SPH_INTRARAT(1);
+}
+
+
+
+
+void sub_SPC2K_DisconSSO_Done(void)
+{
+ uint16 aud_id;
+ MD_TRC_C2K_SPH_SO_DISCON_DONE(0);
+ aud_id = L1SP_GetAudID();
+ l1sp.isConSSO_Done = false;//clear
+ SPC2K_DisconSSO_Done();
+ L1SP_FreeAudID(aud_id);
+ MD_TRC_C2K_SPH_SO_DISCON_DONE(1);
+}
+
+void L1SP_C2K_DeEst( void )
+{
+ uint16 aud_id;
+ MD_TRC_C2K_SPH_SO_DISCON(0);
+ kal_take_enh_mutex( sp_handover_mutex );
+ aud_id = L1SP_GetAudID();
+ ASSERT(l1sp.isSO_Connected);
+#ifndef __FAKE_C2K_LOOPBACK__
+ SP_L4C_SetEvent(L1SP_L4C_ESPEECH_0, L1SP_L4C_EVENT_CS);
+#endif
+ //SAL_C2K_SetValue(SAL_C2K_DL_RATE, IPC_SPCH_ERASURE);
+ //l1sp.c2k_so_codec = SAL_C2K_COD_MODE_UNDEF;
+ l1sp.isSO_Connected = false;
+//#if !defined(__WAIT_SP1__)
+ sub_SPC2K_DisconSSO_Done();
+//#endif
+
+#if defined(__VOLTE_SUPPORT__)
+ if( SP4G_Rab_State() && L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//3G->4G
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+ AM_InterRAT_C2K_to_4G(SP4G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+#endif
+ if( SP3G_Rab_State() && L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//4G->3G
+ CSR_Codec_Ready(SP3G_Rab_Id());
+ AM_InterRAT_C2K_to_3G(SP3G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }else
+ if( L1SP_TCH_State() && L1SP_GetState() != L1SP_STATE_2G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//2G->3G fail case
+ AM_InterRAT_C2K_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+ L1SP_FreeAudID(aud_id);
+ kal_give_enh_mutex( sp_handover_mutex );
+ MD_TRC_C2K_SPH_SO_DISCON(1);
+}
+
+int L1SP_GetC2KSO_Codec( void )
+{
+ return l1sp.c2k_so_codec;
+}
+
+void sub_SPC2K_ConSSO_Done(void)
+{
+ if(!l1sp.isConSSO_Done){
+ MD_TRC_C2K_SPH_SKIP_SO_CON_DONE(0);
+ l1sp.isConSSO_Done = true;
+ SPC2K_ConSSO_Done();
+ }else{//skip
+ MD_TRC_C2K_SPH_SKIP_SO_CON_DONE(1);
+ //log
+ }
+}
+
+void L1SP_C2K_Est(int codec)//ESpeech:1 is presumed before this is invoked.
+{
+ MD_TRC_C2K_SPH_SO_CONNECT(codec);
+
+ ASSERT(!l1sp.isSO_Connected);
+ kal_take_enh_mutex( sp_handover_mutex );
+ l1sp.c2k_so_codec = codec;
+
+ if(AM_IsSpeechOn()){ //speech On(2G) -> SO connect or during a call, SO change
+ MD_TRC_C2K_SPH_SO_CONNECT2(1);
+ if( L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON ){
+ MD_TRC_C2K_SPH_SO_CONNECT2(2);
+ AM_InterRAT_2G_to_C2K(codec);
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }else if( L1SP_GetState() == L1SP_STATE_3G_SPEECH_ON ){
+ MD_TRC_C2K_SPH_SO_CONNECT2(3);
+ CSR_Codec_Close(SP3G_Rab_Id());
+ AM_InterRAT_3G_to_C2K(codec);
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }
+#if defined(__VOLTE_SUPPORT__)
+ else if( L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON ){
+ MD_TRC_C2K_SPH_SO_CONNECT2(4);
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)0 );
+ AM_InterRAT_4G_to_C2K(codec);
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }
+#endif
+ else if( L1SP_GetState() == L1SP_STATE_C2K_SPEECH_ON ){
+ MD_TRC_C2K_SPH_SO_CONNECT2(5);
+ AM_C2K_IntraRAT(codec);
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }else{//others
+ MD_TRC_C2K_SPH_SO_CONNECT2(6);
+ ASSERT(0);
+ }
+
+ sub_SPC2K_ConSSO_Done();
+
+ MD_TRC_C2K_SPH_SO_CONNECT2(7);
+
+ }else{
+ MD_TRC_C2K_SPH_SO_CONNECT2(8);
+ //don't send ack until SpeechOn
+ }
+ l1sp.isSO_Connected = true;
+#ifndef __FAKE_C2K_LOOPBACK__
+ SP_L4C_SetEvent(L1SP_L4C_ESPEECH_1, L1SP_L4C_EVENT_CS);
+#endif
+ kal_give_enh_mutex( sp_handover_mutex );
+
+ MD_TRC_C2K_SPH_SO_CONNECT2(9);
+}
+
+bool L1SP_isC2KSO_Connected()
+{
+ return l1sp.isSO_Connected;
+}
+
+#endif
+
+
+bool L1SP_IsBluetoothOn( void )
+{
+ return ((l1sp.devInfo == SPH_DEVINFO_BT_CVSD_MSBC)
+ || (l1sp.devInfo == SPH_DEVINFO_BT_CVSD)
+ || (l1sp.devInfo == SPH_DEVINFO_BT_MSBC)
+ || (l1sp.devInfo == SPH_DEVINFO_BT_PCM));
+}
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+void SP_SetSpeechPara( uint16 sph_m_para[NUM_MODE_PARAS] )
+{
+ memcpy(l1sp.sph_m_para, sph_m_para, NUM_MODE_PARAS*sizeof(uint16));
+}
+#endif
+
+
+kal_uint16 L1SP_GetAudID(void)/*Be careful.Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag*/
+{
+ kal_uint16 aud_id;
+ aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aud_id );
+ return aud_id;
+}
+void L1SP_FreeAudID(kal_uint16 aud_id)
+{
+ L1Audio_ClearFlag( aud_id );
+ L1Audio_FreeAudioID( aud_id );
+}
+
+
+/*******************************************************************/
+/* The new interface for DSP speech enhancement function / Bluetooth */
+/*******************************************************************/
+/*
+void sp_setBtOn(bool on)
+{
+ l1sp.bt_on = on;
+}
+
+bool sp_getIsBtOn(void)
+{
+ return l1sp.bt_on;
+}
+*/
+
+
+
+void L1SP_Reload_SPE_Para( void )
+{
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ SPE_LoadSpeechPara(l1sp.sph_c_para, l1sp.sph_m_para, l1sp.sph_m_paraWb,l1sp.sph_m_paraSWb);
+ #else // for 95,97
+ SPE_LoadCommonPara(l1sp.sph_c_para);
+#endif
+}
+
+
+
+
+
+void L1SP_LoadCommonSpeechPara( uint16 c_para[NUM_COMMON_PARAS] )
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+
+ memcpy(l1sp.sph_c_para, c_para, NUM_COMMON_PARAS*sizeof(uint16));
+
+ // Some common parameters are used in non-speech function
+ // Force to load common parameter
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ SPE_LoadSpeechPara(l1sp.sph_c_para, NULL, NULL, NULL);
+ #else // for 97,95
+ SPE_LoadCommonPara(l1sp.sph_c_para);
+#endif
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+}
+
+uint16 *Sp_GetCommonSpeechPara(void)
+{
+ return l1sp.sph_c_para;
+}
+
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+uint16 *Sp_GetSpeechPara(void)
+{
+ return l1sp.sph_m_para;
+}
+
+
+void SP_SetWbSpeechPara( kal_uint16 m_para[NUM_MODE_PARAS] )
+{
+ memcpy( l1sp.sph_m_paraWb, m_para, NUM_MODE_PARAS*sizeof(uint16));
+}
+void SP_SetSWbSpeechPara( kal_uint16 m_para[NUM_MODE_PARAS] )
+{
+ memcpy( l1sp.sph_m_paraSWb, m_para, NUM_MODE_PARAS*sizeof(uint16));
+}
+
+uint16 *Sp_GetWbSpeechPara(void)
+{
+ return l1sp.sph_m_paraWb;
+}
+
+#endif
+void SP_SetUSIP_MPU_Info()
+{
+ l1sp.AUIF_EMI_addr = 0;
+ l1sp.AUIF_EMI_size = 0;
+ l1sp.SphParamBuffer = NULL;
+ l1sp.SphParamBufferSize = 0;
+ l1sp.SphOpenDSPBuffer = NULL;
+ l1sp.SphOpenDSPBufferSize = 0;
+
+#if defined(__HIF_CCCI_SUPPORT__)
+
+ CCCI_RUNTIME_FEATURE_SUPPORT_T feature_support;
+ CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T shm;
+
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_MD_USIP_SHARE_MEMORY, &shm, sizeof(CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T ));
+
+ if (feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if(0 == shm.size){
+ ASSERT(0);
+ }
+ l1sp.AUIF_EMI_addr = shm.addr;
+ l1sp.AUIF_EMI_size = shm.size;
+ }
+#endif
+ SAL_ExtAUIF_SetMemAddr(SAL_EXTAUIF_MEM_TYPE_SPHALL, l1sp.AUIF_EMI_addr, l1sp.AUIF_EMI_size);
+ //invalidate_dcache(l1sp.AUIF_EMI_addr, l1sp.AUIF_EMI_size);
+}
+
+#define NUM_MPU_REGION 3
+typedef unsigned int SP_EMI_LAYOUT_VERSION;
+
+typedef enum {
+ SP_EMI_AP_USIP_PARAMETER,
+ SP_EMI_ADSP_USIP_PHONECALL,
+ SP_EMI_ADSP_USIP_SMARTPA
+}SP_EMI_TYPE;
+
+typedef enum {
+ SP_MPU_READ_BIT = 0,
+ SP_MPU_WRITE_BIT = 1,
+ SP_MPU_CACHEABLE_BIT = 2,
+}SP_MPU_BIT;
+
+typedef unsigned short SP_MPU_ATTRIBUTE;
+
+typedef struct SP_EMI_Entry{
+ SP_EMI_TYPE TYPE;
+ int OFFSET;
+ int SIZE;
+
+ SP_MPU_ATTRIBUTE AP_MPU;
+ SP_MPU_ATTRIBUTE ADSP_MPU; //HIFI3
+}SP_EMI_Entry_t;
+
+typedef struct SP_EMI_Info{
+ SP_EMI_LAYOUT_VERSION version;
+ SP_EMI_Entry_t EMI_Entry[NUM_MPU_REGION];
+ int EMI_Entry_Num;
+}SP_EMI_Info_t;
+
+SP_EMI_Info_t sp_emi_info;
+SP_EMI_Entry_t sp_emi_entry;
+
+
+int EMI_TABLE[3][3]={{0, 0, 0x30000},{1, 0x30000, 0x8000},{2, 0x38000, 0x28000}};
+void SP_Parse_EMI_Info()
+{
+#if defined(__HIF_CCCI_SUPPORT__)
+ if(0 != l1sp.AUIF_EMI_size){
+ int i = 0;
+ //volatile kal_uint32* p = (volatile kal_uint32* )l1sp.AUIF_EMI_addr;
+ int number = 3;
+ //int start_id = 4;
+ for(i = 0; i < number; i++){
+ sp_emi_info.EMI_Entry[i].TYPE = EMI_TABLE[i][0];
+ sp_emi_info.EMI_Entry[i].OFFSET = EMI_TABLE[i][1];
+ sp_emi_info.EMI_Entry[i].SIZE = EMI_TABLE[i][2];
+ }
+ for(i = 0; i < number; i++)
+ kal_prompt_trace(MOD_L1SP, "SP_Parse_EMI_Info %d %d %d %d", i, sp_emi_info.EMI_Entry[i].TYPE, sp_emi_info.EMI_Entry[i].OFFSET, sp_emi_info.EMI_Entry[i].SIZE);
+
+
+ //temp solution. allocate the whole memory to enh
+ l1sp.SphParamBuffer = (kal_uint32 *)(l1sp.AUIF_EMI_addr + sp_emi_info.EMI_Entry[(int)SP_EMI_AP_USIP_PARAMETER].OFFSET); //send address to DSP, not offset
+ l1sp.SphParamBufferSize = sp_emi_info.EMI_Entry[(int)SP_EMI_AP_USIP_PARAMETER].SIZE;
+ l1sp.SphOpenDSPBuffer = (kal_uint32 *)(l1sp.AUIF_EMI_addr + sp_emi_info.EMI_Entry[(int)SP_EMI_ADSP_USIP_PHONECALL].OFFSET); //send address to DSP, not offset
+ l1sp.SphOpenDSPBufferSize = sp_emi_info.EMI_Entry[(int)SP_EMI_ADSP_USIP_PHONECALL].SIZE;
+
+ kal_prompt_trace(MOD_L1SP, "SP_Parse_EMI_Info_2 %d %d %d %d", l1sp.SphParamBuffer, l1sp.SphParamBufferSize, l1sp.SphOpenDSPBuffer, l1sp.SphOpenDSPBufferSize);
+ kal_prompt_trace(MOD_L1SP, "SP_Parse_EMI_Info_3 %d %d", l1sp.AUIF_EMI_addr, l1sp.AUIF_EMI_size);
+
+
+ }/*else{
+ ASSERT(0);
+ }*/
+#endif
+
+ SAL_ExtAUIF_SetMemAddr(SAL_EXTAUIF_MEM_TYPE_OD, (kal_uint32)l1sp.SphOpenDSPBuffer, l1sp.SphOpenDSPBufferSize);
+ SAL_ExtAUIF_SetMemAddr(SAL_EXTAUIF_MEM_TYPE_ENH, (kal_uint32)l1sp.SphParamBuffer, l1sp.SphParamBufferSize);
+
+
+}
+
+kal_uint32* SP_GetSphParamBufAddr()
+{//possible , NULL
+ kal_prompt_trace(MOD_L1SP, "[DBG] %d", (kal_uint32)l1sp.SphParamBuffer);
+ return l1sp.SphParamBuffer;
+}
+
+kal_uint32 SP_GetSphParamBufSize()
+{ //possible , 0
+ return l1sp.SphParamBufferSize;
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+// TODO: this function should phase out
+
+/**
+ @index: [Input] Identify which LID is going to provide
+ @buffer: [Output] Buffer with the contain the result
+ @len: [Input] Length of the output buffer
+*/
+void L1SP_GetNvramInfoByIndex(L1SP_NVRAM_INFO_INDEX index, void *buffer, uint16 len)
+{
+ switch(index)
+ {
+
+ case L1SP_NVRAM_INFO_INDEX_WB_SPEECH_INPUT_FIR:
+ {
+ ASSERT(len == (NUM_SPH_INPUT_FIR * NUM_WB_FIR_COEFFS));
+ }
+ break;
+ case L1SP_NVRAM_INFO_INDEX_WB_SPEECH_OUTPUT_FIR:
+ {
+ ASSERT(len == (NUM_SPH_OUTPUT_FIR * NUM_WB_FIR_COEFFS));
+ }
+ break;
+ case L1SP_NVRAM_INFO_INDEX_WB_SPEECH_MODE_PARAM:
+ {
+ ASSERT(len == (NUM_SPH_MODE * NUM_MODE_PARAS));
+ }
+ break;
+
+ default:
+ ASSERT(0);
+ }
+}
+/**
+ MED can put all nvram structure to AUD via this function. Audio/Speech driver will parsing the LID by itself.
+
+ @index: [Input] Identify which LID is used to parsing the buffer
+ @buffer: [Input] Buffer with the contain from nvram
+ @len: [Input] Length of the input buffer
+*/
+void L1SP_SetNvramInfoByIndex(L1SP_NVRAM_INFO_INDEX index, uint8* buffer, uint16 len)
+{
+ {
+ bool L1Audio_IsInitialized();
+ while( !L1Audio_IsInitialized()){
+ kal_sleep_task(AUD_1TICK(1));
+ }
+ }
+ return;
+
+}
+
+
+
+/**
+ @device: device using in speech. pleae refer to
+ #define L1SP_BUFFER_0 0x01 // NOTE: Don't use buffer definition directly
+ #define L1SP_BUFFER_1 0x02 // Use speaker definition below
+ #define L1SP_BUFFER_ST 0x04
+ #define L1SP_BUFFER_EXT 0x08
+ #define L1SP_BUFFER_EXT_G 0x10
+ #define L1SP_STEREO2MONO 0x20 // Do not use this term for speaker definition
+ #define L1SP_BUFFER_ST_M (L1SP_BUFFER_ST|L1SP_STEREO2MONO)
+ #define L1SP_EXT_DAC_BUF0 0x40
+ #define L1SP_EXT_DAC_BUF1 0x80
+ Phase-out function without using
+*/
+void L1SP_SetOutputDevice( uint8 device )
+{
+}
+
+
+/**
+ Function is used when MODEM side has PGA gain & DSP digital gain control
+ i.e. ANALOG_AFE_PATH_EXIST is defined
+
+ @volume1: MMI(EM) value from 0 to 256
+ @digital_gain_index:unit is 0.5 db. Value from 0 to -64db (seems option)
+*/
+void L1SP_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+}
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/**
+ this function is to replace L1SP_SetSpeechVolumeLevel()
+
+ @level: [input] speech volume level for speech
+ @v_paraIndex: [input] volume paramter (saving in nvram) index
+*/
+void L1SP_SetSpeechVolumeLevelByIndex(kal_uint8 level, kal_uint8 v_paraIndex)
+{
+// phase out.
+// L1SP_SetSpeechVolumeLevel(level, l1sp.sph_allVolumePara[v_paraIndex][level]);
+}
+
+/**
+ Phase out function without using
+ @src: microhpone source for speech, plese refer to
+ #define L1SP_LNA_0 0
+ #define L1SP_LNA_1 1
+ #define L1SP_LNA_DIGITAL 2
+ #define L1SP_LNA_FMRR 3
+
+*/
+void L1SP_SetInputSource( uint8 src )
+{
+
+}
+
+/**
+ Phase out function without using
+ @return: microphone source for speech
+*/
+uint8 L1SP_GetInputSource( void )
+{
+ return 0; // AFE_GetInputSource();
+}
+
+
+
+/**
+ @mic_volume: MMI(EM) value. Including Analog & digital gain
+*/
+void L1SP_SetMicrophoneVolume( uint8 mic_volume )
+{
+
+
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+uint8 L1SP_GetMicrophoneVolume( void )
+{
+ return 0;
+}
+void L1SP_SetOpenDSPFlag(kal_uint8 flag)
+{/* 0: internal SPE, 1: OpenDSP */
+ l1sp.opendsp_flag = flag;
+ MD_TRC_L1SP_SETOPENDSP_FLAG(flag);
+}
+kal_uint8 L1SP_GetOpenDSPFlag(void)
+{/* 0: internal SPE, 1: OpenDSP */
+ return l1sp.opendsp_flag;
+}
+/**
+ Phase out function without using
+ @sidetone: value from EM, which is 0~255.
+*/
+void L1SP_SetSidetoneVolume( uint8 sidetone )
+{
+ // keep API header to avoid link error
+}
+
+
+/**
+ Phase out function without using
+ @return: value from EM, which is 0~255.
+*/
+uint8 L1SP_GetSidetoneVolume( void )
+{
+ // keep API header to avoid link error,
+ return 0;
+}
+
+
+void SP_MuteUlSource(bool mute)
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+ l1sp.isUlSourceMute = mute;
+ AM_Mute_UL_Source_Speech(mute);
+
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+
+}
+
+/**
+ running inside speech is active
+ @mute: true for mute, false for unmute
+*/
+void SP_MuteDl_beforePcmMixer(bool mute)
+{
+ l1sp.dl_pre_PcmMixer_mute = mute;
+ AM_Mute_DL_PRE_PcmMixer(mute);
+}
+
+
+void L1SP_SetCodecMuteByAp( bool mute )
+{
+ l1sp.dl_codec_mute_by_ap = mute;
+
+ AM_Mute_DL_Speech_Traffic(l1sp.codec_mute || l1sp.dl_codec_mute_by_ap);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+void SP_MuteUlFromDiffPos(bool mute, SP_MIC_MUTE_POS pos)
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+
+ if(mute)
+ l1sp.isULMute |= pos;
+ else
+ l1sp.isULMute &= (~pos);
+
+ AM_Mute_UL_POS_EN_Speech(0 != l1sp.isULMute); // use raming if possible
+
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+}
+
+/**
+ For MED use ONLY!!!
+ other function please use void SP_MuteUlFromDiffPos(bool mute, SP_MIC_MUTE_POS pos)
+*/
+void L1SP_MuteMicrophone( bool mute )
+{
+
+ //AFE_MuteMicrophone( mute ); // do not use AFE_MuteMicrophone for speech enhancement
+ // AM_MuteULSpeech( mute );
+ // l1sp.isULMute = mute;
+ SP_MuteUlFromDiffPos(mute, SP_MIC_MUTE_POS_FROM_MED);
+}
+
+void L1SP_MuteSpeaker( bool mute )
+{
+#if 0 //def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#else
+
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+ l1sp.isDLMute = mute;
+ AM_Mute_DL_8K_Speech(l1sp.isDLMute);
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+
+#endif
+}
+
+bool SP_IsSpeakerMute(void)
+{
+ return (l1sp.isDLMute!=0);
+}
+
+bool SP_IsMicMute(void)
+{
+ return (l1sp.isULMute!=0);
+}
+
+/**
+ For MED use ONLY!!!
+ other function please use SP_IsMicMute() instead
+*/
+bool L1SP_IsMicrophoneMuted( void )
+{
+ return (l1sp.isULMute&SP_MIC_MUTE_POS_FROM_MED)!=0;
+ // return AM_IsULSpeechMuted();
+}
+
+
+#if defined( __UMTS_RAT__ )
+
+void L1SP_3G_Request(void)
+{
+ if(l1sp.state == L1SP_STATE_3G_SPEECH_ON)
+ {
+ CSR_Codec_Ready(SP3G_Rab_Id());
+ return;
+ }
+}
+#endif
+
+void L1SP_SetState(uint8 state)
+{
+#if defined( __UMTS_RAT__ )
+ if(( l1sp.state == L1SP_STATE_2G_SPEECH_ON && state == L1SP_STATE_3G_SPEECH_ON ) ||
+ ( l1sp.state == L1SP_STATE_2G_SPEECH_ON && state == L1SP_STATE_4G_SPEECH_ON ) ||
+ ( l1sp.state == L1SP_STATE_3G_SPEECH_ON && state == L1SP_STATE_2G_SPEECH_ON ) ||
+ ( l1sp.state == L1SP_STATE_3G_SPEECH_ON && state == L1SP_STATE_4G_SPEECH_ON ) ||
+ ( l1sp.state == L1SP_STATE_4G_SPEECH_ON && state == L1SP_STATE_2G_SPEECH_ON ) ||
+ ( l1sp.state == L1SP_STATE_4G_SPEECH_ON && state == L1SP_STATE_3G_SPEECH_ON ) )
+ l1sp.interRAT = true;
+#endif
+ l1sp.state = state;
+ MD_TRC_L1Audio_Msg_Speech_State(L1Audio_Speech_State(state));
+}
+
+uint8 L1SP_GetState( void )
+{
+ return l1sp.state;
+}
+
+
+void L1SP_Set_isStandByMode(bool RAB_status)
+{
+ l1sp.isStandByMode = RAB_status;
+ //TRC_MSG(L1SP_SET_ISSTANDBYMODE ,"L1SP_Set_isStandByMode: %d")
+ MD_TRC_L1SP_SET_ISSTANDBYMODE((int)RAB_status);
+}
+
+
+bool L1SP_Get_isStandByMode( void )
+{
+ return l1sp.isStandByMode;
+}
+
+
+kal_bool L1SP_IsSpeechOn( void )
+{
+ return (AM_IsSpeechOn());
+}
+
+bool voc_flag = false;
+
+void vmFilteChkTimerCallback(void)
+{
+ kal_prompt_trace(MOD_L1SP, "enter call back,%d, %d", voc_flag, ChkL1ClsFltr_L1Audio_VoC_TRACE_VM());
+#ifdef __SENSITIVE_DATA_MOSAIC__
+ if (dhl_mask_sensitive_trace_on())
+ {
+ kal_set_timer(sp_vmFilterChk_timer, (kal_timer_func_ptr)(vmFilteChkTimerCallback), NULL, KAL_TICKS_50_MSEC*20, AUD_1TICK(0));
+ } else
+#endif
+ {
+ if (false == voc_flag && ChkL1ClsFltr_L1Audio_VoC_TRACE_VM()) {
+ // trigger VM start
+ msg_send4(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VM_START);
+ } else if(true == voc_flag && !ChkL1ClsFltr_L1Audio_VoC_TRACE_VM()) {
+ msg_send4(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VM_STOP);
+ } else {
+ kal_set_timer(sp_vmFilterChk_timer, (kal_timer_func_ptr)(vmFilteChkTimerCallback), NULL, KAL_TICKS_50_MSEC*20, AUD_1TICK(0));
+ }
+ }
+}
+
+void vocEnable(void)
+{
+ kal_uint32 voc_ptn = TVCI_CREATE_FILE;
+ kal_uint32 *voc_ptn_ptr = &voc_ptn;
+
+ if(ChkL1ClsFltr_L1Audio_VoC_TRACE_VM())
+ {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 1);
+ if(ChkL1ClsFltr_L1Audio_VoC_TRACE_EPL()) {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 2);
+ }
+
+#ifdef __SENSITIVE_DATA_MOSAIC__
+ if (dhl_mask_sensitive_trace_on())
+ {
+ voc_flag = false;
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 4);
+ } else
+#endif
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)voc_ptn_ptr, 4);
+ VMREC_Start(NULL, true);
+ voc_flag = true;
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 3);
+ }
+ }
+ else {
+ MD_TRC_L1SP_PHONE_CALL(5, 1, 0);
+ }
+}
+
+void vocDisable(void)
+{
+
+ kal_uint32 voc_ptn = TVCI_CLOSE_FILE;
+ kal_uint32 *voc_ptn_ptr = &voc_ptn;
+
+ if(voc_flag)
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)voc_ptn_ptr, 4);
+ VMREC_Stop(true);
+ voc_flag = false;
+ }
+}
+
+
+void L1SP_extcodec_hisr_ul(void *data)
+{
+#if defined(__SMART_PHONE_MODEM__)
+ if(spc_isAcLoopback()) {
+ Extcodec_hisr_ul_loopback(0);
+ }
+#endif
+#if defined(__G_CODEC_SUPPORT__)
+ else if( SP4G_Rab_State()){
+ sp4g_hisr_ul_g(0);
+ }
+#endif
+}
+
+void L1SP_extcodec_hisr_dl(void *data)
+{
+#if defined(__SMART_PHONE_MODEM__)
+ if(spc_isAcLoopback()) {
+ Extcodec_hisr_dl_loopback(0);
+ }
+#endif
+#if defined(__G_CODEC_SUPPORT__)
+ else if( SP4G_Rab_State()) {
+ sp4g_hisr_dl_g(0);
+ }
+#endif
+}
+
+/**
+ MED task
+*/
+#include "med_spcio.h"
+void L1SP_RampDone(void)
+{
+ AM_RAMP_DONE();
+}
+
+void RAMP_DONE_Hisr(void * param)
+{
+ // Send notification to MED to begin data transfer
+ msg_send4(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_RAMP_DONE);
+}
+
+void sp_enableBT_SCO(sp_device_info_t newDev, kal_uint8 voice8kMode)
+{
+#if defined(__CVSD_CODEC_SUPPORT__)
+ if(!BT_SCO_IS_SPEECH_ON())
+ {
+ if (SPH_DEVINFO_BT_CVSD_MSBC == newDev) {
+ ASSERT( (voice8kMode==0) || (voice8kMode==1) );
+ BT_SCO_SPEECH_ON((voice8kMode == 1));
+ } else if (SPH_DEVINFO_BT_CVSD == newDev) {
+ BT_SCO_SPEECH_ON(false);
+ } else if (SPH_DEVINFO_BT_MSBC == newDev){
+ BT_SCO_SPEECH_ON(true);
+ }
+ }
+#endif
+
+}
+
+void L1SP_Speech_On( uint8 RAT_Mode )
+{
+ MD_TRC_L1SP_PHONE_CALL(0, RAT_Mode, -1);
+
+ SPLog_GetFlagSetting(); //get logging flag setting from engineer mode
+ if( AM_IsSpeechOn() )
+ {
+ sp_enableBT_SCO(l1sp.devInfo, l1sp.devSr);
+ return;
+ }
+
+#if defined(__G_CODEC_SUPPORT__)
+ L1Audio_HookHisrHandler(DP_D2C_4G_PCM_DONE_UL,(L1Audio_EventHandler)L1SP_extcodec_hisr_ul, 0);
+ L1Audio_HookHisrHandler(DP_D2C_4G_PCM_DONE_DL,(L1Audio_EventHandler)L1SP_extcodec_hisr_dl, 0);
+#endif //#if defined(__G_CODEC_SUPPORT__)
+
+ l1sp.pre_l4c_codec = L1SP_L4C_NONE;
+ // for phone call used.
+ l1sp.aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( l1sp.aud_id ); /* To lock sleep mode */
+
+ sp_emVoiceQuality.isNotify = KAL_FALSE;
+ L1Audio_HookHisrHandler(DP_D2C_VOICE_QUALITY_ID,(L1Audio_EventHandler)sp_voiceQualityHisrHdl, 0);
+
+ //Check the mute status, this should always unmute.
+ ASSERT(SAL_Mute_Check(SAL_MUTE_DL_8K)==0);
+
+ SP_DSPTone_ForceEnd();
+
+ spGain_Refresh2DSP();
+
+
+#if defined(__VOLTE_SUPPORT__)
+ sp4g_speech_init( RAT_4G_MODE );
+#endif
+
+#if defined( __UMTS_RAT__ )
+#ifdef __VIDEO_CALL_SUPPORT__
+ if( RAT_Mode == RAT_3G324M_MODE )
+ sp3g_speech_init( RAT_3G324M_MODE );
+ else
+#endif
+ //In Dual mode, allow 2G/3G capability at initialization stage for InterRAT HO
+ //if 3G324M, there is no InterRAT
+ sp3g_speech_init( RAT_3G_MODE );
+#endif
+ MD_TRC_L1Audio_Msg_SP(0);
+ kal_take_enh_mutex( sp_handover_mutex );
+ // choose the mode is 2g /3g
+#if defined(__VOLTE_SUPPORT__)
+ if( SP4G_Rab_State()){
+ RAT_Mode = RAT_4G_MODE;
+ }else
+#endif
+#if defined( __UMTS_RAT__ )
+ if( SP3G_Rab_State() && RAT_Mode != RAT_3G324M_MODE ){
+ RAT_Mode = RAT_3G_MODE;
+ }else
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if (l1sp.isSO_Connected){
+ RAT_Mode = RAT_C2K_MODE;
+ }else
+#endif
+ if ( l1sp.tch_state ){
+ RAT_Mode = RAT_2G_MODE;
+ }
+#if defined( __UMTS_RAT__ )
+ else if(RAT_Mode != RAT_3G324M_MODE ){
+ RAT_Mode = RAT_2G_MODE;
+ }
+ l1sp.interRAT = false;
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ MD_TRC_L1SP_PHONE_CALL(1, SP4G_Rab_State(), SP3G_Rab_State());
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ MD_TRC_L1SP_PHONE_CALL(2, l1sp.isSO_Connected, l1sp.tch_state);
+#else
+ MD_TRC_L1SP_PHONE_CALL(2, -1, l1sp.tch_state);
+#endif
+ MD_TRC_L1SP_PHONE_CALL(3, RAT_Mode, -1);
+ MD_TRC_L1SP_PHONE_CALL(3, -1, -1);
+
+ MD_TRC_L1Audio_Msg_SP(1);
+ AM_SpeechOn(RAT_Mode, 0);
+ MD_TRC_L1Audio_Msg_SP(2);
+
+ switch(RAT_Mode)
+ {
+ case RAT_2G_MODE:
+ L1SP_SetState(L1SP_STATE_2G_SPEECH_ON);
+ break;
+#if defined( __UMTS_RAT__ )
+ case RAT_3G_MODE:
+ L1SP_SetState(L1SP_STATE_3G_SPEECH_ON);
+ CSR_Codec_Ready(SP3G_Rab_Id());
+ break;
+#ifdef __VIDEO_CALL_SUPPORT__
+ case RAT_3G324M_MODE:
+ L1SP_SetState(L1SP_STATE_3G324M_SPEECH_ON);
+ vt_SP3G_Callback( (kal_uint8)SP3G_CODEC_READY, (void*)0 );
+ break;
+#endif
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ case RAT_4G_MODE:
+ L1SP_SetState(L1SP_STATE_4G_SPEECH_ON);
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)SP4G_Rab_Id());
+ break;
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ case RAT_C2K_MODE:
+ L1SP_SetState(L1SP_STATE_C2K_SPEECH_ON);
+ sub_SPC2K_ConSSO_Done();
+ break;
+#endif
+ default:
+ ASSERT(false);
+ }
+ MD_TRC_L1SP_PHONE_CALL(4, -1, -1);
+ kal_give_enh_mutex( sp_handover_mutex );
+ MD_TRC_L1SP_PHONE_CALL(5, -1, -1);
+
+#ifndef __L1_STANDALONE__ // avoid link error
+ vocEnable();
+ kal_set_timer(sp_vmFilterChk_timer, (kal_timer_func_ptr)(vmFilteChkTimerCallback), NULL, KAL_TICKS_50_MSEC*20, AUD_1TICK(0));
+#endif
+ emCodecTimerOn();
+
+ //always unmute DSP uplink when speech on (This is to keep the mute definition)
+
+ SetSpeechEnhancement( true );
+
+// for phone call usage
+#if !DATA_CARD_DISABLE_INTERNAL
+#if defined(__DATA_CARD_SPEECH__)
+ if (l1sp.strmOnHandler != NULL)
+ l1sp.strmOnHandler( NULL );
+#endif
+#endif
+
+#if defined(__ECALL_SUPPORT__)
+ if (l1sp.pcm4wayOnHandler != NULL)
+ l1sp.pcm4wayOnHandler( (void *)0);
+#endif
+
+ sp_enableBT_SCO(l1sp.devInfo, l1sp.devSr);
+
+ MD_TRC_L1Audio_Msg_SP(4);
+
+ if(L1SP_L4C_EVENT_NONE != l1sp.codec_mute_mode) {
+ l1audio_sph_srv_SMMT_Start();
+ }
+
+}
+
+
+#if defined(__DATA_CARD_SPEECH__)
+void L1SP_Register_Strm_Handler(
+ void (*onHandler)(void *hdl),
+ void (*offHandler)(void *hdl),
+ void (*hdl)(kal_uint32 event, void *param))
+{
+ l1sp.strmOnHandler = onHandler;
+ l1sp.strmOffHandler = offHandler;
+ l1sp.strmHdl = hdl;
+ //For MOLY00004781, sometimes auto script hit that register handler later than speech on. In this case, we let daca run.
+ if( AM_IsSpeechOn() ){
+ l1sp.strmOnHandler(NULL);
+ }
+}
+
+void L1SP_UnRegister_Strm_Handler( void )
+{
+ if(AM_IsDataCardOn() && (l1sp.strmOffHandler != NULL)){
+ /* Normal Case: PLUGIN(RegisterHandler)-->SpeechOn(OnHandler)-->SpeechOff(OffHandler) -->PLUGOUT(UnRegisterHandler)
+ Unexpected Case: PLUGIN(RegisterHandler)-->SpeechOn(OnHandler)-->PLUGOUT(UnRegisterHandler), registerHandler again -->SpeechOff(OffHandler) */
+ DACA_Stop(DACA_APP_TYPE_ACTIVE_UL_DL_WB);
+ }
+ l1sp.strmOnHandler = NULL;
+ l1sp.strmOffHandler = NULL;
+}
+#endif
+
+#if defined(__ECALL_SUPPORT__)
+void L1SP_Register_Pcm4WayService(void (*onHandler)(void *), void (*offHandler)(void *))
+{
+ l1sp.pcm4wayOnHandler = onHandler;
+ l1sp.pcm4wayOffHandler = offHandler;
+}
+
+void L1SP_UnRegister_Pcm4Way_Service( void )
+{
+ l1sp.pcm4wayOnHandler = NULL;
+ l1sp.pcm4wayOffHandler = NULL;
+}
+#endif
+
+void L1SP_Speech_Off( void )
+{
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+ if(BT_SCO_IS_SPEECH_ON())
+ {
+ BT_SCO_SPEECH_OFF();
+ }
+#endif
+
+ if( !AM_IsSpeechOn() )
+ return;
+
+ // due to AP will close DL directly before speech off, so md can mute dl directly without ramping
+ // This will prevent sound pushes to hardware buffer then cause noise
+ SAL_Mute_Ctrl(SAL_MUTE_DL_8K, KAL_TRUE);
+
+ l1audio_sph_srv_SMMT_End();
+
+#if !DATA_CARD_DISABLE_INTERNAL
+//FIXME: for phone call usage
+#if defined(__DATA_CARD_SPEECH__)
+ if (l1sp.strmOffHandler != NULL)
+ l1sp.strmOffHandler( NULL );
+#endif
+#endif
+
+#if defined(__ECALL_SUPPORT__)
+ if (l1sp.pcm4wayOffHandler != NULL)
+ l1sp.pcm4wayOffHandler( (void *)0 );
+#endif
+
+ SetSpeechEnhancement( false );
+
+ emCodecTimerOff();
+ kal_cancel_timer(sp_vmFilterChk_timer);
+#ifndef __L1_STANDALONE__ // avoid link error
+ vocDisable();
+#endif
+ MD_TRC_L1SP_PHONE_CALL(20, -1, -1);
+ kal_take_enh_mutex( sp_handover_mutex );
+ MD_TRC_L1SP_PHONE_CALL(21, -1, -1);
+
+ AM_SpeechOff(0);
+
+#if defined(__VOLTE_SUPPORT__)
+ {
+ uint8 state;
+ state = l1sp.state;
+
+ if(l1sp.state == L1SP_STATE_4G_SPEECH_ON || l1sp.interRAT ){
+ L1SP_SetState(L1SP_STATE_4G_SPEECH_CLOSING);
+ }
+ sp4g_speech_close();
+
+ /* only these cases should wait state, if only 2G happen, then return to idle */
+ if( state == L1SP_STATE_4G_SPEECH_ON || l1sp.interRAT
+ ){
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)SP4G_Rab_Id());
+ }
+ }
+#endif
+
+#if defined( __UMTS_RAT__ )
+ {
+ if(l1sp.state == L1SP_STATE_3G_SPEECH_ON || l1sp.interRAT
+#ifdef __VIDEO_CALL_SUPPORT__
+ || l1sp.state == L1SP_STATE_3G324M_SPEECH_ON
+#endif
+ ){
+ L1SP_SetState(L1SP_STATE_3G_SPEECH_CLOSING);
+ }
+ sp3g_speech_close(l1sp.interRAT);
+ }
+#endif
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+ {
+ uint8 state;
+ state = l1sp.state;
+
+ if(l1sp.state == L1SP_STATE_C2K_SPEECH_ON || l1sp.isSO_Connected){
+ L1SP_SetState(L1SP_STATE_C2K_SPEECH_CLOSING);
+ }
+
+ if( state == L1SP_STATE_C2K_SPEECH_ON || l1sp.isSO_Connected){
+ //uint32 waitTime;
+ ;//TODO : Daniel : CSR_Codec_Close(SP3G_Rab_Id());
+ }
+ }
+#endif
+
+ L1SP_SetState( L1SP_STATE_IDLE );
+ L1SP_Set_isStandByMode( false );
+ MD_TRC_L1SP_PHONE_CALL(22, -1, -1);
+ kal_give_enh_mutex( sp_handover_mutex );
+ MD_TRC_L1SP_PHONE_CALL(23, -1, -1);
+
+#if defined(__VIBRATION_SPEAKER_SUPPORT__)
+ VIBR_Vibration_Activate();
+#endif
+
+ SAL_Mute_Ctrl(SAL_MUTE_DL_8K, KAL_FALSE);
+ //always unmute DSP uplink after speech off to keep the mute definition
+ SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_ALL);
+ L1SP_MuteSpeaker(false);
+ L1SP_SetCodecMuteByAp(false);
+ SP_MuteUlSource(false);
+ SP_MuteDl_beforePcmMixer(false);
+ L1SP_RampDone();
+
+#if defined(__G_CODEC_SUPPORT__)
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_PCM_DONE_UL);
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_PCM_DONE_DL);
+#endif //#if defined(__G_CODEC_SUPPORT__)
+
+ L1Audio_UnhookHisrHandler(DP_D2C_VOICE_QUALITY_ID);
+
+ L1Audio_ClearFlag( l1sp.aud_id );
+ L1Audio_FreeAudioID( l1sp.aud_id );
+
+ // clean emCodec
+ SP_updateEmCodecEvent();
+ MD_TRC_L1SP_PHONE_CALL(24, -1, -1);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+void L1SP_SetAfeLoopback( bool enable )
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+ if( enable )
+ AFE_TurnOnLoopback();
+ else
+ AFE_TurnOffLoopback();
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+void L1SP_LoadSpeechPara( void )
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+ SPE_LoadSpeechPara(l1sp.sph_c_para, l1sp.sph_m_para, l1sp.sph_m_paraWb,l1sp.sph_m_paraSWb);
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+}
+#endif
+
+// ----------------------------------------------------------------------------
+// codec information update
+// ----------------------------------------------------------------------------
+
+#include "em_audio_public_struct.h"
+#include "em_msgid.h"
+#include "md_sap.h"
+
+void emCodecTimerCallback(void)
+{
+ SP_updateEmCodecEvent();
+ if (false == voc_flag && (true == AM_IsSpeechOn()) && (false==l1sp.isEmCodecNotifyOff)) {
+ kal_set_timer(sp_emCodec_timer, (kal_timer_func_ptr)(emCodecTimerCallback), NULL, AUD_1TICK(4), AUD_1TICK(0));
+ }
+}
+
+void emCodecTimerOn(void)
+{
+ if (false == voc_flag && (true == AM_IsSpeechOn()) && (false==l1sp.isEmCodecNotifyOff)) {
+ kal_set_timer(sp_emCodec_timer, (kal_timer_func_ptr)(emCodecTimerCallback), NULL, AUD_1TICK(4), AUD_1TICK(0));
+ }
+}
+
+void emCodecTimerOff(void)
+{
+ kal_cancel_timer(sp_emCodec_timer);
+}
+
+/**
+ call from MED, to turn/off EM codec filter
+ @isOff:
+*/
+void SP_setEmCodecNotifyOff(bool isOff){
+
+ bool orgValue = l1sp.isEmCodecNotifyOff;
+ l1sp.isEmCodecNotifyOff = isOff;
+
+ if(true==isOff && false==orgValue){ // turn off
+ emCodecTimerOff();
+ } else if(false==isOff && true==orgValue){ // turn on
+ emCodecTimerOn();
+ }
+
+
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+void SP_updateEmCodecEvent(void)
+{
+ if(true == l1sp.isEmCodecNotifyOff) {
+ MD_TRC_SP_EM_UPDATE_CODEC(l1sp.isEmCodecNotifyOff,
+ SAL_Get_Codec_Mode(0), SAL_Get_Codec_Mode(1),
+ voc_flag, L1SP_GetState());
+ return;
+ } else { // set event
+ if(kal_if_lisr())
+ L1Audio_LSetEvent(l1sp.aud_id_em_codec_update, NULL);
+ else
+ L1Audio_SetEvent(l1sp.aud_id_em_codec_update, NULL);
+ }
+}
+
+void sp_updateEmCodecEventHandler(void)
+{
+ ilm_struct ilm;
+ em_speech_info_sph_codec_ind_struct *em_para_ptr;
+
+ if((true == AM_IsSpeechOn()) && (true==l1sp.codec_mute)){ //During ESPEECH OFF, skip
+ return;
+ }
+
+ ilm.src_mod_id = MOD_L1SP;
+ ilm.dest_mod_id = MOD_DHL;
+ ilm.sap_id = EM_PS_SAP;
+ ilm.msg_id = MSG_ID_EM_SPEECH_INFO_SPH_CODEC_IND;
+ em_para_ptr = (em_speech_info_sph_codec_ind_struct *)(construct_local_para(sizeof(em_speech_info_sph_codec_ind_struct ), TD_RESET));
+
+ em_para_ptr->em_info = EM_SPEECH_INFO_SPH_CODEC;
+
+ if(true == AM_IsSpeechOn()) {
+ em_para_ptr->ulSphCodec = SAL_Get_Codec_Mode(0);
+ em_para_ptr->dlSphCodec = SAL_Get_Codec_Mode(1);
+ } else {
+ em_para_ptr->ulSphCodec = SPH_CODEC_CODEC_NONE;
+ em_para_ptr->dlSphCodec = SPH_CODEC_CODEC_NONE;
+ }
+ em_para_ptr->sphNetwork = L1SP_GetState();
+
+ ilm.local_para_ptr = (local_para_struct*)em_para_ptr;
+ ilm.peer_buff_ptr = NULL;
+ dhl_EM_logger(&ilm);
+
+ destroy_ilm(&ilm); //or free_local_para((local_para_struct*)em_para_ptr );
+}
+
+
+void l1sp_NetworkStatusNotification(void)
+{
+ if(kal_if_lisr())
+ L1Audio_LSetEvent(l1sp.aud_id_network_status, NULL );
+ else
+ L1Audio_SetEvent(l1sp.aud_id_network_status, NULL);
+}
+
+//AUDIO task
+void l1sp_send_codec_status_notify(uint32 codec)//to L4C
+{
+#if !defined(__L1_STANDALONE__)
+ // uint32 codec = (uint32) data;
+ L1SP_L4C_Codec l4c_codec = L1SP_L4C_NONE;
+
+ switch(codec){
+ case 0:
+ l4c_codec = L1SP_L4C_GSM_FR;
+ break;
+ case 1:
+ l4c_codec = L1SP_L4C_GSM_HR;
+ break;
+ case 2:
+ l4c_codec = L1SP_L4C_GSM_EFR;
+ break;
+
+ // c2k
+ case SPH_CODEC_C2K_SO3:
+ l4c_codec = L1SP_L4C_EVRC;
+ break;
+ case SPH_CODEC_C2K_SO17:
+ l4c_codec = L1SP_L4C_QCELP13K;
+ break;
+ case SPH_CODEC_C2K_SO68:
+ l4c_codec = L1SP_L4C_EVRC_B;
+ break;
+ case SPH_CODEC_C2K_SO73:
+ l4c_codec = L1SP_L4C_EVRC_NW;
+ break;
+ case SPH_CODEC_C2K_SO73WB:
+ l4c_codec = L1SP_L4C_EVRC_WB;
+ break;
+
+ default:
+
+ if(codec >= 0x3 && codec <= 0xA ){
+ l4c_codec = L1SP_L4C_AMR_NB;
+ }else if(codec >= 0x20 && codec <= 0x28 ){
+ l4c_codec = L1SP_L4C_AMR_WB;
+ }else if(codec >= SPH_CODEC_EVS_08K_005_9 && codec <= SPH_CODEC_EVS_08K_000_0_NODATA ){
+
+ l4c_codec = L1SP_L4C_EVS_NB;
+ }else if(codec >= SPH_CODEC_EVS_16K_005_9 && codec <= SPH_CODEC_EVS_16K_000_0_NODATA ){
+
+ l4c_codec = L1SP_L4C_EVS_WB;
+ }else if(codec >= SPH_CODEC_EVS_32K_005_9 && codec <= SPH_CODEC_EVS_32K_000_0_NODATA ){
+
+ l4c_codec = L1SP_L4C_EVS_SW;
+ }else if(codec >= SPH_CODEC_EVS_48K_005_9 && codec <= SPH_CODEC_EVS_48K_000_0_NODATA ){
+
+ l4c_codec = L1SP_L4C_EVS_FB;
+ }else if(codec >= SPH_CODEC_EVS_AWB_06_60 && codec <= SPH_CODEC_EVS_AWB_00_00_NODATA ){
+
+ l4c_codec = L1SP_L4C_EVS_AWB;
+ }
+ break;
+ }
+
+ if(l1sp.pre_l4c_codec != l4c_codec){
+ MD_TRC_L1SP_L4C_SEND_CODEC(codec, l4c_codec, l1sp.pre_l4c_codec);
+ l4c_report_voice_codec(l4c_codec);
+ l1sp.pre_l4c_codec = l4c_codec;
+ }else{
+ MD_TRC_L1SP_L4C_SEND_CODEC_SKIP3(l4c_codec);
+ }
+#endif
+}
+
+void l1sp_notify_network_status( void )
+{
+
+ uint32 amCodec = AM_GetSpeechMode();
+
+ MD_TRC_L1SP_NOTIFY_NETWORK_STATUS(amCodec);
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SP_UPDATE_SPEECH_ENHANCEMENT_PARAMETER, NULL, NULL);
+ if(l1sp.codec_mute){//During ESPEECH OFF, skip all codec notification
+ MD_TRC_L1SP_L4C_SEND_CODEC_SKIP(amCodec);
+ return;
+ }
+
+ if(!L1SP_IsSpeechOn()){//During ESPEECH OFF, skip all codec notification
+ MD_TRC_L1SP_L4C_SEND_CODEC_SKIP2();
+ return;
+ }
+ // send via L4C. too keep original process
+ l1sp_send_codec_status_notify(amCodec);
+
+#if defined(__SMART_PHONE_MODEM__)
+ extern void spc_send_network_status_notify(em_speech_info_SpeechCodecType codec);
+ spc_send_network_status_notify((em_speech_info_SpeechCodecType)amCodec);
+#endif
+
+ //msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SP_UPDATE_SPEECH_ENHANCEMENT_PARAMETER, NULL, NULL);
+ MD_TRC_L1SP_NOTIFY_NETWORK_STATUS(-1);
+}
+
+#if defined(_SPE_ENH_MD_PARSE_)
+extern const unsigned short Speech_Normal_Mode_Para[16];
+extern const unsigned short WB_Speech_Normal_Mode_Para[16];
+#endif
+void L1SP_Init( void )
+{
+ l1sp.tch_state = KAL_FALSE;
+ uint16 commonP[] = DEFAULT_SPEECH_COMMON_PARA;
+
+ memset(&l1sp.sph_c_para, 0, NUM_COMMON_PARAS*sizeof(uint16));
+#if defined(_SPE_ENH_MD_PARSE_)
+ memset(&l1sp.sph_m_para, 0, NUM_MODE_PARAS*sizeof(uint16));
+ // memset(&l1sp.sph_v_para, 0, NUM_VOL_PARAS*sizeof(uint16));
+ memset(&l1sp.sph_m_paraWb, 0, NUM_MODE_PARAS*sizeof(uint16));
+ memset(&l1sp.sph_m_paraSWb, 0, NUM_MODE_PARAS*sizeof(uint16));
+ memcpy(l1sp.sph_m_para, Speech_Normal_Mode_Para, 16*sizeof(uint16));
+ memcpy( l1sp.sph_m_paraWb, WB_Speech_Normal_Mode_Para, 16*sizeof(uint16));
+ memcpy( l1sp.sph_m_paraSWb, WB_Speech_Normal_Mode_Para, 16*sizeof(uint16));
+ L1SP_LoadCommonSpeechPara(commonP);
+#endif
+ memcpy(l1sp.sph_c_para, commonP, NUM_COMMON_PARAS*sizeof(uint16));
+
+
+ l1sp.devInfo = 0;
+ l1sp.devSr = 2; // similar to afe.voice8kMode = 2 but keeping in driver. for
+ SP_SetDevicePath(l1sp.devInfo, l1sp.devSr);
+
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#else
+ l1sp.mic_volume = 0;
+#endif
+
+
+#if defined( __UMTS_RAT__ )
+ sp3g_init();
+ l1sp.interRAT = false;
+#endif
+#if defined(__VOLTE_SUPPORT__)
+ sp4g_init();
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ SPC2K_init();
+#endif
+ SPE_Init();
+ // l1sp.spe_flag = true;
+ l1sp.isDLMute = l1sp.isULMute = false;
+ l1sp.codec_mute = true;
+ l1sp.codec_mute_mode = L1SP_L4C_EVENT_NONE;
+ l1sp.dl_codec_mute_by_ap = false;
+
+
+#if defined(__DATA_CARD_SPEECH__)
+ l1sp.strmOnHandler = NULL;
+ l1sp.strmOffHandler = NULL;
+ l1sp.strmHdl = NULL;
+#endif
+#if defined(__ECALL_SUPPORT__)
+ l1sp.pcm4wayOnHandler = NULL;
+ l1sp.pcm4wayOffHandler = NULL;
+#endif
+ L1SP_Set_isStandByMode( false );
+ l1sp.pre_l4c_codec = L1SP_L4C_NONE;
+ L1SP_SetState(L1SP_STATE_IDLE);
+ l1sp.aud_id_network_status = L1Audio_GetAudioID();
+ sp_vmFilterChk_timer = kal_create_timer("vmFltChk");
+
+ L1Audio_SetEventHandler(l1sp.aud_id_network_status, (L1Audio_EventHandler)l1sp_notify_network_status);
+
+ l1sp.aud_id_em_codec_update = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler(l1sp.aud_id_em_codec_update, (L1Audio_EventHandler)sp_updateEmCodecEventHandler);
+ sp_emCodec_timer = kal_create_timer("emCodec");
+
+ l1sp.aud_id_voice_quality_event = L1Audio_GetAudioID();
+ l1sp.isEmCodecNotifyOff = true;
+ L1Audio_SetEventHandler(l1sp.aud_id_voice_quality_event, (L1Audio_EventHandler)sp_voiceQualityEventHdl);
+
+#if defined(__C2K_SPEECH_SUPPORT__)
+ l1sp.c2k_so_codec = SAL_C2K_COD_MODE_UNDEF;
+ l1sp.isConSSO_Done = l1sp.isSO_Connected = false;
+#endif
+ l1sp.opendsp_flag = 0;
+ l1sp.rampDoneHandler = RAMP_DONE_Hisr;
+ L1Audio_HookHisrHandler(DP_D2C_RAMP_DONE_INT_ID, (L1Audio_EventHandler)l1sp.rampDoneHandler , 0);
+}
+kal_bool L1SP_TCH_State( void )
+{
+ return l1sp.tch_state;
+}
+
+void ChangeRAT_Mode(SP_CHANGERAT_EVENT event, kal_uint32 param1, kal_uint32 param2)
+{
+ MD_TRC_SP_CHANGERAT_MODE(event, param1, param2);
+ switch(event){
+ case SP_2G_HANDOVER:
+ //param1 : codec
+ //param2 : sub_channel
+ {
+ void cc_2G_Call_Handover(kal_uint32 speech_mode, kal_uint32 sub_channel);
+ cc_2G_Call_Handover(param1, param2);
+ AM_SetSpeechMode(param1, param2);
+ }
+ l1sp_NetworkStatusNotification();
+ // l1sp_CodecStatusNotification((uint16)param1);
+ break;
+ case SP_2G_AUDIOMANAGER_INFO:
+ AM_Set2GCodecInfo((uint16)param1, (int8)param2);
+ break;
+ case SP_2G_TCH:
+ //param1 : on / off
+ {
+ void L1SP_TCH_Notify( bool bOn );
+ L1SP_TCH_Notify( param1);
+ }
+ break;
+ case SP_3G_RAB:
+ //param1 : on / off
+ //param2 : codec
+ break;
+ case SP_4G_RAB:
+ //param1 : on / off
+ //param2 : codec
+ break;
+ }
+
+
+ if( AM_IsSpeechOn() ){
+ //original
+ //switch( L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON )
+ //new
+ }else{
+
+ }
+}
+
+// This is invoked by 2G L1D(LISR)
+void L1SP_TCH_Notify( bool bOn )
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+ if( !bOn ){ // for 2G->3G handover, mute speech in case Speech_Off command too late to avoid noise
+ MD_TRC_L1Audio_Msg_TCH_NOTIFY(L1AUDIO_Str_onoff(0), L1Audio_Speech_State(l1sp.state));
+ l1sp.tch_state = KAL_FALSE;
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_2G , false);
+ //mute speech
+#if defined(__VOLTE_SUPPORT__)
+ if( SP4G_Rab_State() && l1sp.state != L1SP_STATE_4G_SPEECH_ON && l1sp.state != L1SP_STATE_IDLE){//2G->4G fail case, TCH will be off
+ SP4G_Reset();
+ AM_InterRAT_2G_to_4G(SP4G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+#endif
+#if defined( __UMTS_RAT__ )
+ if( SP3G_Rab_State() && l1sp.state != L1SP_STATE_3G_SPEECH_ON && l1sp.state != L1SP_STATE_IDLE){//3G->2G fail case, TCH will be off
+ SP3G_Reset();
+ AM_InterRAT_2G_to_3G(SP3G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( L1SP_isC2KSO_Connected() && (l1sp.state != L1SP_STATE_C2K_SPEECH_ON) && (l1sp.state != L1SP_STATE_IDLE) ){
+ //reset
+ AM_InterRAT_2G_to_C2K(L1SP_GetC2KSO_Codec());
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }
+#endif
+ }
+ else{
+ MD_TRC_L1Audio_Msg_TCH_NOTIFY(L1AUDIO_Str_onoff(1), L1Audio_Speech_State(l1sp.state));
+ l1sp.tch_state = KAL_TRUE;
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_2G , true);
+ //*DP_SC_MUTE &= ~0x0002;
+#if defined(__VOLTE_SUPPORT__)
+ if( l1sp.state == L1SP_STATE_4G_SPEECH_ON ){//4G->2G HO
+ AM_InterRAT_4G_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }else
+#endif
+#if defined( __UMTS_RAT__ )
+ if( l1sp.state == L1SP_STATE_3G_SPEECH_ON ){//3G->2G HO
+ AM_InterRAT_3G_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+#endif
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( l1sp.state == L1SP_STATE_C2K_SPEECH_ON ){//3G->2G HO
+ AM_InterRAT_C2K_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+#endif
+ if( L1SP_Get_isStandByMode() ){//Standby->2G HO
+ AM_InterRAT_Standby_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+em_speech_info_SpeechCodecType L1SP_QuerySpeechDlCodec(void)
+{
+ em_speech_info_SpeechCodecType dlCodec = SPH_CODEC_CODEC_NONE;
+
+
+ if(L1SP_STATE_IDLE != L1SP_GetState()) {
+ // need to ensure the DSP is alive to query the value
+ dlCodec = SAL_3G_GetValue(SAL_3G_VALUE_RX_CODEC_MODE);
+
+ } else {
+
+ }
+
+ return dlCodec;
+
+}
+
+void L1SP_SpeechLoopBackEnable(kal_bool fgEnable)
+{
+ SAL_LBK_Codec(fgEnable);
+}
+
+//-----------------------------------------------------------------------------
+// Line in related. Phase out
+/*
+
+void LINEIN_SetOutputDevice( uint8 device )
+{
+ AFE_SetOutputDevice( L1SP_LINEIN, device );
+}
+
+void LINEIN_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+ AFE_SetOutputVolume( L1SP_LINEIN, volume1, digital_gain_index );
+}
+
+void LINEIN_Open()
+{
+
+ if (!lineon_flag){
+ ktLock();
+#if 0 // def ANALOG_AFE_PATH_EXIST
+ AFE_TurnOnSpeaker(L1SP_LINEIN);
+#endif
+ lineon_flag = KAL_TRUE;
+ }
+}
+
+void LINEIN_Close()
+{
+ if(lineon_flag){
+#if defined(MT6252H) || defined(MT6252)
+ AFE_SetGainFastRamp(KAL_TRUE);
+#endif
+
+#if 0 // def ANALOG_AFE_PATH_EXIST
+ AFE_TurnOffSpeaker(L1SP_LINEIN);
+#endif
+
+#if defined(MT6252H) || defined(MT6252)
+ kal_sleep_task( AUD_1TICK(3) );
+ AFE_SetGainFastRamp(KAL_FALSE);
+#endif
+
+ ktUnlock();
+ lineon_flag = KAL_FALSE;
+ }
+#if defined(__VIBRATION_SPEAKER_SUPPORT__)
+ VIBR_Vibration_Activate();
+#endif
+}
+
+void LINEIN_MuteSpeaker( bool mute )
+{
+ AFE_MuteSpeaker( L1SP_LINEIN, mute );
+}
+
+#if 0 // defined(__GAIN_TABLE_SUPPORT__)
+void LINEIN_SetOutputGainControl( kal_uint32 gain ){
+}
+
+void LINEIN_SetOutputGainControlDualPath( kal_uint32 ext_amp_gain ){
+}
+#endif
+*/
+//-----------------------------------------------------------------------------
+void L1SP_MutePCMOuputPort ( kal_bool fMute )
+{
+
+}
+
+//-----------------------------------------------------------------------------
+
+
+bool SP_is_codec_mute()
+{
+ return l1sp.codec_mute;
+}
+
+#if defined(__ECALL_SUPPORT__)
+#if defined(__L5_SUPPORT__)
+void SP_L5ECALL_SetEvent(L1SP_L5ECALL_Event event, kal_uint8 *data)
+{
+ ilm_SP_L5ECALL_SET_EVENT_t *local_para;
+
+ local_para = (ilm_SP_L5ECALL_SET_EVENT_t *) construct_local_para( sizeof(ilm_SP_L5ECALL_SET_EVENT_t), TD_CTRL );
+ local_para->event = event;
+ local_para->data = data;
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SP_L5ECALL_SET_EVENT, (local_para_struct *)local_para, NULL);
+}
+
+void SP_L5ECALL_SetEvent_Execute(L1SP_L5ECALL_Event event, kal_uint8 *data)
+{
+ switch(event){
+ case L1SP_L5ECALL_INITIAL:
+ Set_eCall_Par_Crtl_Switch(0);
+ spc_gain_DlMuteSet(KAL_TRUE, KAL_FALSE);
+ spc_gain_UlMuteSet(KAL_TRUE, KAL_FALSE);
+ spc_eCall_IVS_Open();
+ eCall_IVS_PutMSD(data,140,1);
+ eCall_IVS_SendStart();
+ break;
+ case L1SP_L5ECALL_UPDATE_MSD:
+ eCall_IVS_PutMSD(data,140,1);
+ spc_gain_DlMuteSet(KAL_TRUE, KAL_FALSE);
+ spc_gain_UlMuteSet(KAL_TRUE, KAL_FALSE);
+ spc_eCall_IVS_Open();
+ eCall_IVS_PutMSD(data,140,1);
+ break;
+ case L1SP_L5ECALL_RESET:
+ spc_eCall_IVS_Close();
+ spc_gain_DlMuteSet(KAL_FALSE, KAL_FALSE);
+ spc_gain_UlMuteSet(KAL_FALSE, KAL_FALSE);
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+#endif
+#endif
+
+void SP_L4C_SetEvent(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode)
+{
+ #if defined(__SMART_PHONE_MODEM__)
+ kal_prompt_trace(MOD_L1SP, "SP_L4C_SetEvent = %d %d %d", event, L1SP_GetState(), spc_isPCM());
+ if(L1SP_STATE_C2K_SPEECH_ON == L1SP_GetState() && event){
+ if(spc_isPCM()){
+ L1Ctm_Close();
+ }
+ spc_C2KCtmStart(spc_getCtmMode());
+ }
+ #endif
+ ilm_SP_L4C_SET_EVENT_t *local_para;
+ MD_TRC_SP_L4C_SETEVENT_ENTER();
+ local_para = (ilm_SP_L4C_SET_EVENT_t *) construct_local_para( sizeof(ilm_SP_L4C_SET_EVENT_t), TD_CTRL );
+ local_para->event = event;
+ local_para->mode = mode;
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SP_L4C_SET_EVENT, (local_para_struct *)local_para, NULL);
+ MD_TRC_SP_L4C_SETEVENT_LEAVE();
+}
+
+
+void SP_L4C_SetEvent_Execute(L1SP_L4C_Event event, L1SP_L4C_Event_Mode mode)
+{
+ MD_TRC_L1SP_L4C_EVENT(event, mode, l1sp.codec_mute_mode);
+ MD_TRC_L1SP_MUTE_CONTROL_STATUS(0, l1sp.isULMute, l1sp.isDLMute, l1sp.codec_mute);
+
+ ASSERT( L1SP_L4C_EVENT_NONE == l1sp.codec_mute_mode || mode == l1sp.codec_mute_mode );
+
+ switch(event){
+ case L1SP_L4C_ESPEECH_0:
+ ASSERT(!l1sp.codec_mute);
+ l1sp.codec_mute = true;
+ l1sp.codec_mute_mode = L1SP_L4C_EVENT_NONE;
+
+ l1sp.pre_l4c_codec = L1SP_L4C_NONE; // reset codec when speech on / espeech off. (MED task)
+ break;
+ case L1SP_L4C_ESPEECH_1:
+ ASSERT(l1sp.codec_mute);
+ l1sp.codec_mute = false;
+ l1sp.codec_mute_mode = mode;
+ if(AM_IsSpeechOn()){
+ l1audio_sph_srv_SMMT_Start();
+ }
+ break;
+ default:
+ ASSERT(0);
+ }
+ if(AM_IsSpeechOn()){
+ l1sp_NetworkStatusNotification();
+ }else{
+ MD_TRC_SP_L4C_SKIP_NETWORKNOTIFICATION();
+ }
+ {
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+ AM_Mute_DL_Speech_Traffic(l1sp.codec_mute || l1sp.dl_codec_mute_by_ap);
+ AM_Mute_UL_Codec_Speech(l1sp.codec_mute);
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+ MD_TRC_L1SP_MUTE_CONTROL_STATUS(1, l1sp.isULMute, l1sp.isDLMute, l1sp.codec_mute);
+ }
+}
+
+#if defined(__VOLTE_SUPPORT__)
+static const L1SP_Tones tone_call_waiting[] = { { 440, 0, 200, 100, 1 },
+ { 440, 0, 200,3500, 0 } };
+
+extern void spc_BgSndConfig(kal_uint8 ulGainLevel, kal_uint8 dlGainLevel);
+int spc_ul_gain = 7;
+int spc_dl_gain = 7;
+#endif
+void SpeechDVT(int item){
+#if defined(__VOLTE_SUPPORT__)
+ switch(item){
+ case 0:
+ spc_ul_gain --;
+ if(spc_ul_gain<0)spc_ul_gain = 0;
+ spc_BgSndConfig(spc_ul_gain, spc_dl_gain);
+ break;
+ case 1:
+ spc_ul_gain ++;
+ if(spc_ul_gain>7)spc_ul_gain = 7;
+ spc_BgSndConfig(spc_ul_gain, spc_dl_gain);
+ break;
+ case 2:
+ spc_dl_gain --;
+ if(spc_dl_gain<0)spc_dl_gain = 0;
+ spc_BgSndConfig(spc_ul_gain, spc_dl_gain);
+ break;
+ case 3:
+ spc_dl_gain ++;
+ if(spc_dl_gain>7)spc_dl_gain = 7;
+ spc_BgSndConfig(spc_ul_gain, spc_dl_gain);
+ break;
+
+ case 6:
+ L1SP_Speech_On(RAT_2G_MODE);
+ break;
+ case 7:
+ L1SP_Speech_Off();
+ break;
+
+ case 57:
+ SP4G_PSR_DL_KT_Play(300, 1300, 20000);
+ break;
+ case 58:
+ SP4G_PSR_DL_KT_Stop();
+ break;
+ case 67:
+ SP4G_PSR_UL_KT_Play(1000, 0, 20000);
+ break;
+ case 68:
+ SP4G_PSR_UL_KT_Stop();
+ break;
+ case 69:
+ //KT_SetOutputVolume(100,4096*2); //avoid build warning
+ break;
+ case 71:
+ {
+ SP4G_PSR_UL_Tone_Play( tone_call_waiting );
+ }
+ break;
+ case 72:
+ {
+ SP4G_PSR_UL_Tone_Stop( );
+ }
+ break;
+ case 73:
+ {
+ SP4G_PSR_DL_Tone_Play( tone_call_waiting );
+ }
+ break;
+ case 74:
+ {
+ SP4G_PSR_DL_Tone_Stop( );
+ }
+ break;
+ }
+#endif
+}
+
+#if defined(__VOLTE_SUPPORT__)
+#include "l1sp_el2_struct.h"
+#if defined(__MCU_DTMF_SUPPORT__)
+uint32 VolteToneGetID();
+void VolteToneSetID(uint32 u32val);
+bool VolteToneGetUsed();
+void VolteToneSetUsed(bool bval);
+#endif //#if defined(__MCU_DTMF_SUPPORT__)
+#endif //#if defined(__VOLTE_SUPPORT__)
+#ifdef __FAKE_3G_LOOPBACK__
+kal_uint8 tmp_buf[1000];
+void SP3GHSPA_UL_GetSpeechFrame(kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len);
+void SP3GHSPA_DL_PutSpeechFrame(kal_uint32 CFN, kal_uint8 frame_type, kal_bool crc_status, kal_uint8 *subflow);
+#endif
+void SP_M2M_Handler(ilm_struct *ilm_ptr)
+{
+ switch (ilm_ptr->msg_id) {
+#if defined(__C2K_SPEECH_SUPPORT__)
+ case MSG_ID_AUDIO_M2M_SP_C2K_EVENT:
+ {
+ ASSERT(0);
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_SP_C2K_RATE_REDUCTION:
+ {
+#if defined(__SMART_PHONE_MODEM__)
+ extern void spc_codecInfoNotify_soRateUpdate(uint16 newRate);
+ ilm_SP_C2K_RATE_NOTI_t *local_para;
+ local_para = (ilm_SP_C2K_RATE_NOTI_t *)(ilm_ptr->local_para_ptr);
+ spc_codecInfoNotify_soRateUpdate(local_para->rate);
+#endif
+ }
+ break;
+#endif
+ case MSG_ID_AUDIO_M2M_CHANGERATE_EVENT:
+ {
+ ilm_SP_CHANGERATE_EVENT_t *local_para;
+ local_para = (ilm_SP_CHANGERATE_EVENT_t *)(ilm_ptr->local_para_ptr);
+
+ ChangeRAT_Mode(local_para->event, local_para->param[0], local_para->param[1]);
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_SP_L4C_SET_EVENT:
+ {
+ ilm_SP_L4C_SET_EVENT_t *local_para;
+ MD_TRC_SP_M2M_HANDLER(1);
+ local_para = (ilm_SP_L4C_SET_EVENT_t *)(ilm_ptr->local_para_ptr);
+ SP_L4C_SetEvent_Execute(local_para->event, local_para->mode);
+ }
+ break;
+#if defined(__ECALL_SUPPORT__)
+#if defined(__L5_SUPPORT__)
+ case MSG_ID_AUDIO_M2M_SP_L5ECALL_SET_EVENT:
+ {
+ ilm_SP_L5ECALL_SET_EVENT_t *local_para;
+ local_para = (ilm_SP_L5ECALL_SET_EVENT_t *)(ilm_ptr->local_para_ptr);
+ SP_L5ECALL_SetEvent_Execute(local_para->event, local_para->data);
+ }
+ break;
+#endif
+#endif
+ case MSG_ID_AUDIO_M2M_SP_UPDATE_SPEECH_ENHANCEMENT_PARAMETER:
+ {
+ MD_TRC_SP_M2M_HANDLER(2);
+ kal_prompt_trace(MOD_L1SP, "Get_Reset_Enh_Status()=%x",Get_Reset_Enh_Status() );
+ if(Get_Reset_Enh_Status()==true)
+ {
+ SetSpeechEnhancement( false );
+ SetSpeechEnhancement( true );
+ Set_Reset_Enh_Status(false);
+ }
+ else
+ {
+ SetSpeechEnhancement( true );
+ }
+
+ }
+ break;
+#if defined(__VOLTE_SUPPORT__)
+ case MSG_ID_AUDIO_M2M_VOLTE_MAC_TIMING_INFO:
+ case MSG_ID_AUDIO_M2M_VONR_MAC_TIMING_INFO:
+ {
+ sub_SP4G_emac_timing_update((l1sp_emac_resync_info_struct*)ilm_ptr->local_para_ptr, ilm_ptr->src_mod_id);
+ }
+ break;
+#if defined(__MCU_DTMF_SUPPORT__)
+ case MSG_ID_AUDIO_M2M_VOLTE_TONE_BGSND_CLOSE:
+ {
+ void volte_Tone_BgSndClose(void);
+ volte_Tone_BgSndClose();
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_DL_KT_PLAY:
+ {
+ //SP4G_PSR_DL_KT_Play(5000, 8000, 100000);
+ ilm_PSR_DL_KT_t *local_para;
+ local_para = (ilm_PSR_DL_KT_t *)(ilm_ptr->local_para_ptr);
+ //KT_Play(local_para->freq1, local_para->freq2, local_para->duration, DSP_TONE);
+ SP_DSPTone_DL_KT_Play(local_para->freq1, local_para->freq2, local_para->duration);
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_DL_KT_STOP:
+ {
+ //SP4G_PSR_DL_KT_Stop();
+ //KT_Stop(DSP_TONE);
+ SP_DSPTone_DL_KT_Stop();
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_UL_KT_PLAY:
+ {
+ //SP4G_PSR_UL_KT_Play(5000, 8000, 100000);
+ ilm_PSR_DL_KT_t *local_para;
+ local_para = (ilm_PSR_DL_KT_t *)(ilm_ptr->local_para_ptr);
+ /*if( KAL_FALSE == VolteToneGetUsed() ){
+ KT_Play(local_para->freq1, local_para->freq2, local_para->duration, MCU_TONE);
+ VolteToneSetID( EXT_BGSND_Start(volte_KT_bgSnd_closeHandler, NULL, volte_BGSND_ULHdr, 7, 7) );
+ VolteToneSetUsed(KAL_TRUE);
+ }else{
+ MD_TRC_SP4G_PSR_UL_KT_PLAY_SKIP();
+ }*/
+ SP_DSPTone_UL_KT_Play(local_para->freq1, local_para->freq2, local_para->duration);
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_UL_KT_STOP:
+ {
+ //SP4G_PSR_UL_KT_Stop();
+ /*if( KAL_TRUE == VolteToneGetUsed() ){
+ EXT_BGSND_Flush( VolteToneGetID() );
+ KT_Stop(MCU_TONE);
+ }else{
+ MD_TRC_SP4G_PSR_UL_KT_STOP_SKIP();
+ }*/
+ SP_DSPTone_UL_KT_Stop();
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_PLAY:
+ {
+ //SP4G_PSR_DL_Tone_Play( tone_call_waiting );
+ //ilm_PSR_DL_TONE_t *local_para;
+ //local_para = (ilm_PSR_DL_TONE_t *)(ilm_ptr->local_para_ptr);
+ //TONE_Play(local_para->pToneList, DSP_TONE);
+ kal_prompt_trace(MOD_L1SP, "DSP tone not ready skip MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_PLAY");
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_STOP:
+ {
+ //SP4G_PSR_DL_Tone_Stop();
+ //TONE_Stop(DSP_TONE);
+ kal_prompt_trace(MOD_L1SP, "DSP tone not ready skip MSG_ID_AUDIO_M2M_VOLTE_DL_TONE_STOP");
+ }
+ break;
+#endif //#if defined(__MCU_DTMF_SUPPORT__)
+#endif //#if defined(__VOLTE_SUPPORT__)
+#ifdef __FAKE_3G_LOOPBACK__
+ case MSG_ID_AUDIO_M2M_SP3G_UL_EVENT:
+ {
+ kal_uint8 frame_type, len;
+ kal_prompt_trace(MOD_L1SP, "MSG_ID_AUDIO_M2M_SP3G_UL_EVENT 1");
+ //if(use_sleep == 1){
+ // kal_sleep_task( AUD_1TICK(1) );
+ //}
+ kal_prompt_trace(MOD_L1SP, "MSG_ID_AUDIO_M2M_SP3G_UL_EVENT 2");
+ SP3GHSPA_UL_GetSpeechFrame(&frame_type, tmp_buf, &len);
+ SP3GHSPA_DL_PutSpeechFrame(1, frame_type, 1, tmp_buf);
+ break;
+ }
+#endif
+ case MSG_ID_AUDIO_M2M_RAMP_DONE:
+ {
+ L1SP_RampDone();
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_SPC_SETLOOPBACK_DL_UL:
+ {
+ ilm_SPC_SETLOOPBACK_DL_UL_t *local_para;
+ local_para = (ilm_SPC_SETLOOPBACK_DL_UL_t *)(ilm_ptr->local_para_ptr);
+
+ SAL_LBK_PCM_D2U(local_para->enable);
+ }
+ break;
+ case MSG_ID_AUDIO_M2M_VM_START:
+ vocEnable();
+ break;
+ case MSG_ID_AUDIO_M2M_VM_STOP:
+ vocDisable();
+ break;
+
+ default:
+ {
+ MD_TRC_SP_M2M_HANDLER_SKIP_COMMAND(ilm_ptr->msg_id);
+ break;
+ }
+ }
+}
+
+void SP_SetDevSamplingRate(kal_uint8 voice8kMode)
+{
+ l1sp.devSr = voice8kMode;
+}
+
+uint8 SP_GetDevSamplingRate(void)
+{
+ return l1sp.devSr;
+}
+
+
+sp_device_info_t SP_GetDevInfo(void)
+{
+ return l1sp.devInfo;
+}
+
+void sp_turnOffPath(kal_bool isSpeechOn, kal_bool isPcmRoutOn)
+{
+ if(true == isSpeechOn) {
+ AM_SpeechOff(1); // turn off 8k and speech off
+ } else if (true == isPcmRoutOn){
+ AM_PcmRouter_Off();
+ } else { // cordless mode AM_BTCordlessOff ()/ speech
+ }
+}
+
+void sp_turnOnPath(kal_bool isSpeechOn, kal_bool isPcmRoutOn)
+{
+ if(true == isSpeechOn) {
+ uint32 rat = AM_GetNetworkRate();
+ // [REMIND]L1SP_STATE_xx can mapping to RAT_2G_MODE using "index -1"
+ ASSERT(L1SP_STATE_IDLE != L1SP_GetState());
+ ASSERT(RAT_NONE_MODE != rat );
+ AM_SpeechOn(rat, 1);
+
+ } else if (true == isPcmRoutOn){
+ AM_PcmRouter_On(1);
+ } else { // cordless mode / speech
+ }
+}
+
+void SP_SetDevicePath(sp_device_info_t newDev, kal_uint8 voice8kMode)
+{
+ kal_bool isSpeechOn;
+ kal_bool isPcmRoutOn;
+ kal_bool isAmInSpeechState;
+ kal_bool needOffOn;
+ kal_uint16 audId;
+
+ audId = L1SP_GetAudID();
+
+ sp_device_info_t beforeDev = l1sp.devInfo;
+
+ isSpeechOn = AM_IsSpeechOn();
+ isPcmRoutOn = AM_IsVoIPOn();
+ isAmInSpeechState = AM_IsAmInSpeechState();
+
+ MD_TRC_SP_DEV_MODE_SETTING(beforeDev, newDev, SP_GetDevSamplingRate(), voice8kMode);
+ if((SPH_DEVINFO_NORMAL == beforeDev && SPH_DEVINFO_NORMAL== newDev)
+ || (SPH_DEVINFO_NORMAL == beforeDev && SPH_DEVINFO_BT_PCM== newDev)
+ || (SPH_DEVINFO_BT_PCM == beforeDev && SPH_DEVINFO_NORMAL == newDev)
+ || (SPH_DEVINFO_BT_PCM == beforeDev && SPH_DEVINFO_BT_PCM == newDev) ){
+ needOffOn = ((true == isAmInSpeechState) && (SP_GetDevSamplingRate()!=voice8kMode));
+
+ // off
+ if(true == needOffOn) {
+ sp_turnOffPath(isSpeechOn, isPcmRoutOn);
+ }
+ if(SPH_DEVINFO_BT_PCM == beforeDev) {
+ AM_BluetoothOff();
+ }
+
+ // change setting
+ if(SPH_DEVINFO_BT_PCM== newDev) {
+ ASSERT( (voice8kMode==0) || (voice8kMode==1) );
+ if(0== voice8kMode) { // NB
+ SAL_Set_Device(SAL_DEV_BT_EARPHONE_NB, SAL_NB);
+ } else { //WB
+ SAL_Set_Device(SAL_DEV_BT_EARPHONE_WB, SAL_WB);
+ }
+ } else {
+ SAL_Set_Device(SAL_DEV_NORMAL, voice8kMode);
+ }
+ SP_SetDevSamplingRate(voice8kMode);
+ AFE_SetVoice8KMode(voice8kMode);
+
+ // on
+ if(SPH_DEVINFO_BT_PCM == newDev) {
+ AM_BluetoothOn(2);
+ }
+ if(true == needOffOn){
+ sp_turnOnPath(isSpeechOn, isPcmRoutOn);
+ }
+ }
+#if defined(__CVSD_CODEC_SUPPORT__)
+ else if((SPH_DEVINFO_NORMAL == beforeDev
+ || SPH_DEVINFO_BT_CVSD_MSBC == beforeDev
+ || SPH_DEVINFO_BT_CVSD == beforeDev
+ || SPH_DEVINFO_BT_MSBC == beforeDev)
+ && (SPH_DEVINFO_BT_CVSD_MSBC == newDev
+ || SPH_DEVINFO_BT_CVSD == newDev
+ || SPH_DEVINFO_BT_MSBC == newDev)) {
+ // no off
+ if (isSpeechOn && BT_SCO_IS_SPEECH_ON())
+ {
+ BT_SCO_SPEECH_OFF();
+ }
+
+ // change
+ if (SPH_DEVINFO_BT_CVSD_MSBC == newDev) {
+ SP_SetDevSamplingRate(voice8kMode);
+ } else if (SPH_DEVINFO_BT_CVSD == newDev) {
+ SP_SetDevSamplingRate(0);
+ } else { // MSBC
+ SP_SetDevSamplingRate(1);
+ }
+
+ // on
+ if(isSpeechOn)
+ {
+ sp_enableBT_SCO(newDev, voice8kMode);
+ }
+ }
+ else if((SPH_DEVINFO_BT_CVSD_MSBC == beforeDev && SPH_DEVINFO_NORMAL == newDev)
+ || (SPH_DEVINFO_BT_CVSD == beforeDev && SPH_DEVINFO_NORMAL == newDev)
+ || (SPH_DEVINFO_BT_MSBC == beforeDev && SPH_DEVINFO_NORMAL == newDev)) {
+ needOffOn = ((true == isAmInSpeechState) && (AFE_GetVoice8KMode() != voice8kMode));
+
+ // off
+ if (isSpeechOn && BT_SCO_IS_SPEECH_ON())
+ {
+ BT_SCO_SPEECH_OFF();
+ }
+ if (needOffOn) {
+ sp_turnOffPath(isSpeechOn, isPcmRoutOn);
+ }
+
+ // change
+ SAL_Set_Device(SAL_DEV_NORMAL, voice8kMode);
+ SP_SetDevSamplingRate(voice8kMode);
+ AFE_SetVoice8KMode(voice8kMode);
+
+ // on
+ if(needOffOn){
+ sp_turnOnPath(isSpeechOn, isPcmRoutOn);
+ }
+ }
+#endif
+
+ l1sp.devInfo = newDev;
+ if(l1sp.devInfo== SPH_DEVINFO_NORMAL || l1sp.devInfo == SPH_DEVINFO_BT_PCM) {
+ SAL_Set_DevInfo((Sal_DevInfo_Int_t)(l1sp.devInfo + 1 ), (Sal_DevInfo_Ext_t)(l1sp.extDevInfo));
+ } else {
+ SAL_Set_DevInfo(SAL_DEVINFO_INT_CVSD_MSBC, (Sal_DevInfo_Ext_t)(l1sp.extDevInfo));
+ }
+ L1SP_FreeAudID(audId);
+
+}
+
+void SP_SetExtraDevInfo(sp_device_info_t dev, sp_ext_dev_info_t extDevInfo, uint8 smartpa_config, uint16 echoRefDelay, uint8 micDelay)
+{
+
+ kal_uint16 audId;
+
+ MD_TRC_SP_EXT_DEV_SETTING(dev, extDevInfo, echoRefDelay, micDelay);
+
+ audId = L1SP_GetAudID();
+ if( 0 == smartpa_config || 1 == smartpa_config){
+ SAL_Set_SmartPA_Config(SAL_SMARTPA_SINGLE);
+ }else if( 2 == smartpa_config ){
+ SAL_Set_SmartPA_Config(SAL_SMARTPA_DUAL);
+ }
+
+ // notch filter setting
+ switch(extDevInfo) {
+ case SPH_EXTDEVINFO_VIBRATION_RECEIVER:
+ case SPH_EXTDEVINFO_VIBRATION_SPEAKER:
+ case SPH_EXTDEVINFO_SMARTPA_VIBRATION_SPEAKER:
+ AM_DSP_WriteNotchFilterParam();
+ SAL_NotchFilter_Enable(true , false);
+ break;
+ default:
+ SAL_NotchFilter_Enable(false , false);
+ break;
+ }
+
+
+ // echo ref setting
+ switch(extDevInfo) {
+ case SPH_EXTDEVINFO_DUALSMARTPA_SPEAKER:
+ case SPH_EXTDEVINFO_DUALSMARTPA_VIBRATION_SPEAKER:
+ SAL_ENH_ExtEchoRef_Switch(true);
+
+ SAL_ENH_ExtEchoRef_DelayConfig(0, echoRefDelay, micDelay);
+ SAL_ENH_ExtEchoRef_DelayConfig(1, echoRefDelay, micDelay);
+ break;
+ case SPH_EXTDEVINFO_SMARTPA_SPEAKER:
+ case SPH_EXTDEVINFO_SMARTPA_VIBRATION_SPEAKER:
+ case SPH_EXTDEVINFO_USB_AUDIO:
+ SAL_ENH_ExtEchoRef_Switch(true);
+
+ SAL_ENH_ExtEchoRef_DelayConfig(0, echoRefDelay, micDelay);
+ break;
+ default:
+ {
+ SAL_ENH_ExtEchoRef_Switch(false);
+ if(SPH_DEVINFO_BT_CVSD_MSBC == dev ) {
+ SAL_ENH_ExtEchoRef_DelayConfig(0, echoRefDelay, micDelay);
+ } else { // not delay setting
+ SAL_ENH_ExtEchoRef_DelayConfig(0, 0, 0);
+ }
+ }
+ break;
+ }
+
+ l1sp.extDevInfo = extDevInfo;
+ if(l1sp.devInfo== SPH_DEVINFO_NORMAL || l1sp.devInfo == SPH_DEVINFO_BT_PCM) {
+ SAL_Set_DevInfo((Sal_DevInfo_Int_t)(l1sp.devInfo + 1 ), (Sal_DevInfo_Ext_t)(l1sp.extDevInfo));
+ } else {
+ SAL_Set_DevInfo(SAL_DEVINFO_INT_CVSD_MSBC, (Sal_DevInfo_Ext_t)(l1sp.extDevInfo));
+ }
+ L1SP_FreeAudID(audId);
+
+}
+
+sp_ext_dev_info_t SP_GetExtDevInfo (void)
+{
+ return l1sp.extDevInfo;
+
+}
+
+// ============================================================================
+void SP_setEmVoiceQualityEvent(kal_bool isOn)
+{
+ sp_emVoiceQuality.isOn = isOn;
+}
+
+
+void sp_voiceQualityHisrHdl(void)
+{
+ kal_uint16 rate = SAL_Get_DMFRate();
+ kal_uint16 source = SAL_Get_DMFSource();
+
+ if(sp_emVoiceQuality.isNotify) {
+ // leave log
+ MD_TRC_DROP_SPEECH_QUALITY_EM(1, rate, source);
+ return;
+ }
+
+ memset(&(sp_emVoiceQuality.ulInfo), 0, sizeof(Sal_DMF_SPH_UL_Info_t));
+ if(0!=(source&SAL_DMF_SOURCE_SPH_UL)) {
+ SAL_Get_DMF_SPH_UL_Info(&(sp_emVoiceQuality.ulInfo));
+
+ sp_emVoiceQuality.isNotify = KAL_TRUE;
+ }
+
+ sp_emVoiceQuality.is4gWifi = KAL_FALSE;
+ memset(&(sp_emVoiceQuality.dlInfo), 0, sizeof(Sal_DMF_SPH_DL_Info_t));
+ if(0!=(source&SAL_DMF_SOURCE_SPH_DL)) {
+
+ SAL_Get_DMF_SPH_DL_Info(&(sp_emVoiceQuality.dlInfo));
+
+ sp_emVoiceQuality.isNotify = KAL_TRUE;
+ sp_emVoiceQuality.is4gWifi = KAL_FALSE;
+#if defined(__VOLTE_SUPPORT__)
+ if(SAL_DMF_RATE_4G == sp_emVoiceQuality.dlInfo.DMFRate) {
+ if(SP4G_PSR_CallType_VoWiFi == SP4G_PSR_GetCallType()
+ || SP4G_PSR_CallType_ViWiFi == SP4G_PSR_GetCallType()) {
+ sp_emVoiceQuality.is4gWifi = KAL_TRUE;
+ }
+ }
+#endif
+ }
+
+ memset(&(sp_emVoiceQuality.enhUl), 0, sizeof(Sal_DMF_ENH_UL_Info_t));
+ if(0!=(source&SAL_DMF_SOURCE_ENH_UL)) {
+ SAL_Get_DMF_ENH_UL_Info(&(sp_emVoiceQuality.enhUl));
+
+ sp_emVoiceQuality.isNotify = KAL_TRUE;
+ }
+
+ if(sp_emVoiceQuality.isOn && sp_emVoiceQuality.isNotify ) {
+ if(kal_if_lisr())
+ L1Audio_LSetEvent(l1sp.aud_id_voice_quality_event, &sp_emVoiceQuality);
+ else
+ L1Audio_SetEvent(l1sp.aud_id_voice_quality_event, &sp_emVoiceQuality);
+ } else {
+ MD_TRC_DROP_SPEECH_QUALITY_EM(2, rate, source);
+ sp_emVoiceQuality.isNotify = KAL_FALSE;
+ }
+}
+
+void sp_voiceQualityEventHdl(SP_EM_VOICE_QUALITY_INFO *pEmVQ)
+{
+
+ if(pEmVQ->isNotify) {
+ ilm_struct ilm;
+ em_speech_info_voice_quality_event_ind_struct *em_para_ptr;
+
+ ilm.src_mod_id = MOD_L1SP;
+ ilm.dest_mod_id = MOD_DHL;
+ ilm.sap_id = EM_PS_SAP;
+ ilm.msg_id = MSG_ID_EM_SPEECH_INFO_VOICE_QUALITY_EVENT_IND;
+ em_para_ptr = (em_speech_info_voice_quality_event_ind_struct *)(construct_local_para(sizeof(em_speech_info_voice_quality_event_ind_struct ), TD_RESET));
+
+ em_para_ptr->em_info = EM_SPEECH_INFO_VOICE_QUALITY_EVENT;
+ em_para_ptr->event = pEmVQ->dlInfo.DMFDLStatus;
+ em_para_ptr->dspRate= pEmVQ->dlInfo.DMFRate;
+ em_para_ptr->is4GWifi = pEmVQ->is4gWifi;
+ em_para_ptr->isDlHaveSound = pEmVQ->dlInfo.DMFDLVoice;
+
+
+ em_para_ptr->dlCRCFailCnt = pEmVQ->dlInfo.DMFCRCFailCnt;
+ em_para_ptr->dlSphRstCnt = pEmVQ->dlInfo.DMFSphRstCnt;
+ em_para_ptr->dlPktLossCnt = pEmVQ->dlInfo.DMFPktLossCnt;
+ em_para_ptr->dlJitterLossCnt = pEmVQ->dlInfo.DMFJitterLossCnt;
+ memcpy(em_para_ptr->dlBadFrmCnt, pEmVQ->dlInfo.DMFBadFrmCnt, SAL_DMF_BADFRM_ID_NUM*sizeof(uint16));
+ memcpy(em_para_ptr->dlHomFrmCnt, pEmVQ->dlInfo.DMFHomFrmCnt, SAL_DMF_HOMFRM_ID_NUM*sizeof(uint16));
+ memcpy(em_para_ptr->dlNoDataCnt, pEmVQ->dlInfo.DMFNoDataCnt, SAL_DMF_NODATA_ID_NUM*sizeof(uint16));
+
+ em_para_ptr->uLMutePosENHCnt = pEmVQ->ulInfo.DMFULMutePosENHCnt;
+
+ em_para_ptr->enhUlRobustStatusPre = pEmVQ->enhUl.DMFENHRobustStatusPre;
+ em_para_ptr->enhUlRobustStatusPos = pEmVQ->enhUl.DMFENHRobustStatusPos;
+
+ ilm.local_para_ptr = (local_para_struct*)em_para_ptr;
+ ilm.peer_buff_ptr = NULL;
+ dhl_EM_logger(&ilm);
+
+ destroy_ilm(&ilm); //or free_local_para((local_para_struct*)em_para_ptr );
+
+ pEmVQ->isNotify = KAL_FALSE;
+ }
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_dsptone_drv.c b/mcu/driver/audio/src/v1/sp_dsptone_drv.c
new file mode 100644
index 0000000..f24afb6
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_dsptone_drv.c
@@ -0,0 +1,170 @@
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+#include "l1audio.h"
+#include "drv_sap.h"
+#include "speech_def.h"
+#include "bgSnd.h"
+#include "audio_msgid.h"
+#include "sp_drv.h"
+#include "am.h"
+#include "sal_exp.h"
+
+
+typedef struct
+{
+ kal_uint16 uAudId;
+ kal_bool IsUsed;
+} st_DSPTone;
+
+
+st_DSPTone stDSPToneUL;
+st_DSPTone stDSPToneDL;
+
+
+void SP_DSPTone_DL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration)
+{
+ kal_int16 dlgain = 4096; //digitOnly_quater_dB_tableForSpeech in sp_gain.c
+
+ if( (stDSPToneDL.IsUsed==KAL_TRUE) || (AM_IsAmInSpeechState()==false) )
+ {
+ MD_TRC_SP_DSPTONE_DL_KT_PLAY_SKIP();
+ return;
+ }
+ stDSPToneDL.IsUsed = KAL_TRUE;
+
+ MD_TRC_SP_DSPTONE_DL_KT_PLAY_START(freq1, freq2, duration, dlgain);
+
+ stDSPToneDL.uAudId = L1Audio_GetAudioID();
+ L1Audio_SetFlag( stDSPToneDL.uAudId );
+
+ SAL_Sph_KeyTone_DL_On(freq1, freq2, dlgain);
+
+ MD_TRC_SP_DSPTONE_DL_KT_PLAY_LEAVE();
+}
+
+
+void SP_DSPTone_DL_KT_Stop(void)
+{
+ if(stDSPToneDL.IsUsed == KAL_FALSE)
+ {
+ MD_TRC_SP_DSPTONE_DL_KT_STOP_SKIP();
+ return;
+ }
+
+ MD_TRC_SP_DSPTONE_DL_KT_STOP_START();
+
+ SAL_Sph_KeyTone_DL_Off();
+
+ L1Audio_ClearFlag( stDSPToneDL.uAudId );
+ L1Audio_FreeAudioID( stDSPToneDL.uAudId );
+
+ stDSPToneDL.IsUsed = KAL_FALSE;
+
+ MD_TRC_SP_DSPTONE_DL_KT_STOP_LEAVE();
+}
+
+
+void SP_DSPTone_UL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration)
+{
+ kal_int16 ulgain = 4096; //digitOnly_quater_dB_tableForSpeech in sp_gain.c
+
+ if( (stDSPToneUL.IsUsed==KAL_TRUE) || (AM_IsAmInSpeechState()==false) )
+ {
+ MD_TRC_SP_DSPTONE_UL_KT_PLAY_SKIP();
+ return;
+ }
+ stDSPToneUL.IsUsed = KAL_TRUE;
+
+ MD_TRC_SP_DSPTONE_UL_KT_PLAY_START(freq1, freq2, duration, ulgain);
+
+ stDSPToneUL.uAudId = L1Audio_GetAudioID();
+ L1Audio_SetFlag( stDSPToneUL.uAudId );
+
+ SAL_Sph_KeyTone_UL_On(freq1, freq2, ulgain);
+
+ MD_TRC_SP_DSPTONE_UL_KT_PLAY_LEAVE();
+}
+
+
+void SP_DSPTone_UL_KT_Stop(void)
+{
+ if(stDSPToneUL.IsUsed == KAL_FALSE)
+ {
+ MD_TRC_SP_DSPTONE_UL_KT_STOP_SKIP();
+ return;
+ }
+
+ MD_TRC_SP_DSPTONE_UL_KT_STOP_START();
+
+ SAL_Sph_KeyTone_UL_Off();
+
+ L1Audio_ClearFlag( stDSPToneUL.uAudId );
+ L1Audio_FreeAudioID( stDSPToneUL.uAudId );
+
+ stDSPToneUL.IsUsed = KAL_FALSE;
+
+ MD_TRC_SP_DSPTONE_UL_KT_STOP_LEAVE();
+}
+
+
+void SP_DSPTone_Init(void)
+{
+ stDSPToneUL.uAudId = 0;
+ stDSPToneUL.IsUsed = KAL_FALSE;
+ stDSPToneDL.uAudId = 0;
+ stDSPToneDL.IsUsed = KAL_FALSE;
+}
+
+
+void SP_DSPTone_ForceEnd(void)
+{
+ SP_DSPTone_UL_KT_Stop();
+ SP_DSPTone_DL_KT_Stop();
+}
+
+
+void SP4G_PSR_DL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration)
+{
+ ilm_PSR_DL_KT_t *local_para;
+
+ MD_TRC_SP4G_PSR_DL_KT_PLAY_ENTER();
+ local_para = (ilm_PSR_DL_KT_t *) construct_local_para( sizeof(ilm_PSR_DL_KT_t), TD_CTRL/*TD_RESET*/ );
+ local_para->freq1 = freq1;
+ local_para->freq2 = freq2;
+ local_para->duration = duration;
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_DL_KT_PLAY, (local_para_struct *)local_para, NULL);
+ MD_TRC_SP4G_PSR_DL_KT_PLAY_LEAVE();
+}
+
+
+void SP4G_PSR_DL_KT_Stop(void)
+{
+ MD_TRC_SP4G_PSR_DL_KT_STOP_ENTER();
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_DL_KT_STOP, NULL, NULL);
+ MD_TRC_SP4G_PSR_DL_KT_STOP_LEAVE();
+}
+
+
+void SP4G_PSR_UL_KT_Play(kal_int16 freq1, kal_int16 freq2, kal_int16 duration)
+{
+ ilm_PSR_DL_KT_t *local_para;
+
+ MD_TRC_SP4G_PSR_UL_KT_PLAY_ENTER();
+ local_para = (ilm_PSR_DL_KT_t *) construct_local_para( sizeof(ilm_PSR_DL_KT_t), TD_CTRL/*TD_RESET*/ );
+ local_para->freq1 = freq1;
+ local_para->freq2 = freq2;
+ local_para->duration = duration;
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_UL_KT_PLAY, (local_para_struct *)local_para, NULL);
+ MD_TRC_SP4G_PSR_UL_KT_PLAY_LEAVE();
+}
+
+
+void SP4G_PSR_UL_KT_Stop(void)
+{
+ MD_TRC_SP4G_PSR_UL_KT_STOP_ENTER();
+ msg_send6(MOD_LTECSR, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_UL_KT_STOP, NULL, NULL);
+ MD_TRC_SP4G_PSR_UL_KT_STOP_LEAVE();
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_enhance.c b/mcu/driver/audio/src/v1/sp_enhance.c
new file mode 100644
index 0000000..a75203c
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_enhance.c
@@ -0,0 +1,1640 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_enhance.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * speech enhancement functions (moved from am.c)
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+
+
+
+#include "kal_general_types.h"
+#include "sync_data.h"
+
+// #include "reg_base.h"
+
+#include "l1audio.h"
+
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+
+#include "sp_enhance.h"
+#include "sp_drv.h"
+#include "am.h"
+#include "media.h"
+#include "afe.h"
+
+
+#include "ddload.h"
+
+
+#include "sal_def.h"
+#include "sal_exp.h"
+
+
+
+
+
+
+
+
+const unsigned short Common_Param_Default[72] = { 0, 0xB , 0x1010 ,0 ,0 ,0,0,0 ,
+ 0xC , 0x64,0xDABD,0x7918,0x2A00,0x8001,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,
+ 0x10 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0xB0B, 0 ,0, 0
+ };
+
+
+
+
+
+const unsigned short DMNR_Param_Default[1468] = { 0 , 0xC , 0x1010,0,0, 0,0,0 ,
+ 0x1001, 44 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0 ,
+ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,
+ 0x1002, 44 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0 ,
+ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,
+ 0x2001, 76 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0,
+ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ 0x2002, 76 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x44,0x0,0x0,0x0,
+ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ 0x4001, 120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x44, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x4002, 120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x44, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x8001, 120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x44, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x8002, 120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x44, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ };
+
+const unsigned short MagiClarity_Param_Default[75] = { 0, 0xD, 0x1010,0,0, 0,0,0,
+ 32, 0xFF73,0x01C3,0x01DC,0x0240,0x026E,0x022B,0x0156,0xFFE5,0xFDEB,0xFB89,0xF8E6,0xF60E,0xF2C3,0xEDFB,0xE38B,0xAE09,0x51F7,0x1C75,0x1205,0x0D3D,0x09F2,0x071A,0x0477,0x0215,0x001B,0xFEAA,0xFDD5,0xFD92,0xFDC0,0xFE24,0xFE3D,0x008D , 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0xD0D, 0 ,0, 0
+};
+
+
+
+
+const unsigned short Speech_Param_Default[418 + 134] =
+{ 0, 0xA, 0x1010,0,0, 0,0,0, 0x1001,
+ 64, 0x60,0xFD,0x4004,0x1F,0xE107,0x231F,0x195,0x40,0x110,0xC5,0x262,0x0,0x4008,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 90, 0x7FFF,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ 90, 0x7FFF,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ 20, 0xE342, 0x3CA1, 0x1DDC, 0xC448, 0x1DDC, 0xE0E8, 0x3F04, 0x2000, 0xC001, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x2000,
+ 20, 0xE0B7, 0x3F42, 0x1ECC, 0xC268, 0x1ECC, 0xE1B2, 0x3E47, 0x2000, 0xC000, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x2000,
+ 42, 0x7A90,0xC524,0x8001,0x4000,0x7F54,0xC090,0x800A,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3BB,0x2,
+ 42, 0x7A90,0xC524,0x8001,0x4000,0x7F54,0xC090,0x800A,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3BB,0x2,
+ 90, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 42, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0xA0A, 0,0,0
+};
+
+const unsigned short Param_Default[2167] = { 0 };
+
+
+short Speech_All_Pass_MAG_CLARITY[32] =
+ { /* All pass filter */
+ 32767, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0
+ };
+
+const unsigned short Speech_Common_Para[12] =
+{
+ 0, 55997, 31000, 10752, 32769, 0, 0, 0, 0, 0,
+ 0, 0
+};
+const unsigned short Debug_Info_Para[16] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0
+};
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+#define Par_Speech_Common 0 //Volume Dependent ,speech unit : ModePar,FIR in,Fir out
+#define Par_GSM_NB_SpeechUnit 1
+#define Par_GSM_WB_SpeechUnit 2
+#define Par_WCDMA_NB_SpeechUnit 3
+#define Par_WCDMA_WB_SpeechUnit 4
+#define Par_CDMA_NB_SpeechUnit 5
+#define Par_CDMA_WB_SpeechUnit 6
+#define Par_VOLTE_NB_SpeechUnit 7
+#define Par_VOLTE_WB_SpeechUnit 8
+#define Par_C2K_NB_SpeechUnit 9
+#define Par_C2K_WB_SpeechUnit 10
+#define Par_VOLTE_SWB_SpeechUnit 11
+#endif
+kal_enhmutexid spe_enh_mutex;
+
+// #define TOTAL_NUM_SPH_MODE (NUM_SPH_MODE+2) // new 1 for HAC, 1 for USB
+// #define TOTAL_NUM_SPH_INPUT_FIR (NUM_SPH_INPUT_FIR+2) // new 1 for HAC, 1 for USB
+// #define TOTAL_NUM_SPH_OUTPUT_FIR (NUM_SPH_OUTPUT_FIR+2) // new 1 for HAC, 1 for USB
+typedef struct
+{
+ // uint8 sph_mode;
+ bool spe_flag;
+ bool EMI_isExist;
+ bool spe_isFweOn;
+
+ uint8 sph_SPE_path; // ul_only=0,dl_only=1,ul+dl=2
+ // uint16 spe_state; // record which enhancement is open
+
+ // uint16 spe_usr_sub_mask; // record the usage of enhancement sub feature. Sync with Sal_Enh_Dynamic_t definition. Ex. phonecall should be turned on DMNR, but users can decide whether turn on or not.please do not update the mask directly, please use function l1sp_updateUsrSubMask() to update
+ uint16 spe_usr_enh_ctrl; // bit0=DMNR,bit1=TDDNC,bit2=magi con
+ bool spe_is_update_enh_ctrl;
+#if defined(_SPE_ENH_MD_PARSE_)
+ int16 sph_dmnr_para[NUM_DMNR_PARAM];
+ int16 sph_wb_dmnr_para[NUM_WB_DMNR_PARAM];
+ int16 sph_swb_dmnr_para[NUM_SWB_DMNR_PARAM];
+ int16 sph_lspk_dmnr_para[NUM_DMNR_PARAM];
+ int16 sph_lspk_wb_dmnr_para[NUM_WB_DMNR_PARAM];
+ int16 sph_lspk_swb_dmnr_para[NUM_SWB_DMNR_PARAM];
+
+ // short sph_magi_clarity_para[NUM_MAGI_CLARITY_PARAM];
+ uint16 sph_magicConParam[NUM_MODE_PARAS];
+ uint16 sph_magicConWbParam[NUM_MODE_PARAS];
+#endif
+ uint32 sph_EMI_Info_offset;
+ uint32 sph_EMI_Info_len;
+ bool isMagiConOn;
+
+ bool isHacModeNeeded; // if AP send Hac paramters and FIRs to MD, the flag will be set.
+ bool isSPE_Enable; // check SPE already enable or not
+ // uint8 spe_Path;
+ // bool isReDDL;
+#if defined(_SPE_ENH_MD_PARSE_)
+ // --NB--
+ uint16 sph_ModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+ int16 sph_InFirCoeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+ int16 sph_OutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+ int16 sph_InIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_OutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_Mic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+ int16 sph_Mic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+ // --WB--
+ uint16 sph_WbModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+ int16 sph_WbInFirCoeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+ int16 sph_WbOutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+ int16 sph_WbInIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_WbOutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_WbMic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+ int16 sph_WbMic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+ // --SWB--
+ uint16 sph_SWbModePara[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+ int16 sph_SWbInFirCoeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+ int16 sph_SWbOutFirCoeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+ int16 sph_SWbInIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_SWbOutIirCoeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+ int16 sph_SWbMic1IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+ int16 sph_SWbMic2IirCoeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+#endif
+ bool ctm_spe_status;
+
+} _SPE_T;
+
+static _SPE_T gSpe;
+
+void l1sp_SetParEMIInfo(uint32 offset,uint32 len)
+{
+ gSpe.sph_EMI_Info_offset = offset ;
+ gSpe.sph_EMI_Info_len = len ;
+
+ MD_TRC_L1SP_SPE_SET_EMI_INFO(0,gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len);
+}
+void l1sp_setCtmSpeStatus(bool s){
+ gSpe.ctm_spe_status = s;
+}
+
+bool l1sp_getCtmSpeStatus(){
+ return (gSpe.ctm_spe_status);
+}
+
+
+/* ========================================================================= */
+#if defined(_SPE_ENH_MD_PARSE_)
+void l1sp_setAllSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length);
+ memcpy(gSpe.sph_ModePara, speech_mode_para,
+ TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+}
+
+
+
+
+
+void l1sp_setAllSpeechFirCoeff_InputOnly(kal_int16 *speech_input_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_InFirCoeff, speech_input_FIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16));
+
+}
+
+
+
+
+void l1sp_setAllSpeechFirCoeff_OutputOnly(kal_int16 *speech_output_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_OutFirCoeff, speech_output_FIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16));
+}
+//IIR
+void l1sp_setAllSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_InIirCoeff, speech_input_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+
+}
+
+
+void l1sp_setAllSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_OutIirCoeff, speech_output_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+}
+
+void l1sp_setAllSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_Mic1IirCoeff, speech_output_Mic1_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+}
+void l1sp_setAllSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_Mic2IirCoeff, speech_output_Mic2_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+}
+//--------------- WB ----------------
+void l1sp_setAllWbSpeechModePara(kal_uint16 * speech_mode_para, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length);
+
+ memcpy(gSpe.sph_WbModePara, speech_mode_para,
+ TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+}
+void l1sp_setAllSWbSpeechModePara(kal_uint16 * speech_mode_para,kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS) == length);
+
+ memcpy(gSpe.sph_SWbModePara, speech_mode_para,
+ TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+
+}
+void spe_setMagiCon(void)
+{
+
+ gSpe.isMagiConOn = true;
+ gSpe.spe_isFweOn = true;
+}
+
+void spe_DisableMagiCon(void)
+{
+ gSpe.isMagiConOn = false;
+ gSpe.spe_isFweOn = false;
+}
+
+
+void l1sp_setAllWbSpeechFirCoeff_InputOnly(
+ kal_int16 *speech_input_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbInFirCoeff, speech_input_FIR_coeffs,
+ length*sizeof(int16));
+}
+
+void l1sp_setAllSWbSpeechFirCoeff_InputOnly(
+ kal_int16 *speech_input_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbInFirCoeff, speech_input_FIR_coeffs,
+ length*sizeof(int16));
+
+}
+
+
+void l1sp_setAllWbSpeechFirCoeff_OutputOnly(
+ kal_int16 *speech_output_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbOutFirCoeff, speech_output_FIR_coeffs,
+ length*sizeof(int16));
+}
+
+void l1sp_setAllSWbSpeechFirCoeff_OutputOnly(
+ kal_int16 *speech_output_FIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbOutFirCoeff, speech_output_FIR_coeffs,
+ length*sizeof(int16));
+}
+
+//IIR
+void l1sp_setAllWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbInIirCoeff, speech_input_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+
+}
+void l1sp_setAllWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbOutIirCoeff, speech_output_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+}
+void l1sp_setAllWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length)
+{
+
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbMic1IirCoeff, speech_output_Mic1_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+
+}
+void l1sp_setAllWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_WbMic2IirCoeff, speech_output_Mic2_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+
+}
+void l1sp_setAllSWBSpeechIirCoeff_InputOnly(kal_int16 *speech_input_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbInIirCoeff, speech_input_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+
+}
+void l1sp_setAllSWBSpeechIirCoeff_OutputOnly(kal_int16 *speech_output_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbOutIirCoeff, speech_output_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+}
+void l1sp_setAllSWBSpeechMic1IirCoeff(kal_int16 *speech_output_Mic1_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbMic1IirCoeff, speech_output_Mic1_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+}
+void l1sp_setAllSWBSpeechMic2IirCoeff(kal_int16 *speech_output_Mic2_IIR_coeffs, kal_int16 length)
+{
+ ASSERT((TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS) == length);
+ memcpy(gSpe.sph_SWbMic2IirCoeff, speech_output_Mic2_IIR_coeffs,
+ TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+}
+//--------------- DMNR ----------------
+
+
+/**
+ Not support parameter rewirte under application begin runnning
+*/
+void L1SP_SetDMNRPara( const kal_int16 DMNR_para[NUM_DMNR_PARAM] )
+{
+
+ memcpy(&gSpe.sph_dmnr_para, DMNR_para, NUM_DMNR_PARAM*sizeof(uint16));
+}
+
+/**
+ Not support parameter rewirte under application begin runnning
+*/
+void L1SP_SetWbDMNRPara( const kal_int16 WB_DMNR_para[NUM_WB_DMNR_PARAM] )
+{
+ memcpy(&gSpe.sph_wb_dmnr_para, WB_DMNR_para, NUM_WB_DMNR_PARAM*sizeof(uint16));
+}
+void L1SP_SetSWbDMNRPara( const kal_int16 SWB_DMNR_para[NUM_SWB_DMNR_PARAM] )
+{
+ memcpy(&gSpe.sph_swb_dmnr_para, SWB_DMNR_para, NUM_SWB_DMNR_PARAM*sizeof(uint16));
+}
+
+/**
+ Not support parameter rewirte under application begin runnning
+*/
+void L1SP_SetLSpkDMNRPara( const kal_int16 LSpk_DMNR_para[NUM_DMNR_PARAM] )
+{
+ memcpy(&gSpe.sph_lspk_dmnr_para, LSpk_DMNR_para, NUM_DMNR_PARAM*sizeof(uint16));
+}
+
+
+/**
+ Not support parameter rewirte under application begin runnning
+*/
+void L1SP_SetLSpkWbDMNRPara( const kal_int16 LSpk_Wb_DMNR_para[NUM_WB_DMNR_PARAM] )
+{
+ memcpy(&gSpe.sph_lspk_wb_dmnr_para, LSpk_Wb_DMNR_para, NUM_WB_DMNR_PARAM*sizeof(uint16));
+}
+void L1SP_SetLSpkSWbDMNRPara( const kal_int16 LSpk_SWb_DMNR_para[NUM_SWB_DMNR_PARAM] )
+{
+ memcpy(&gSpe.sph_lspk_swb_dmnr_para, LSpk_SWb_DMNR_para, NUM_SWB_DMNR_PARAM*sizeof(uint16));
+}
+
+
+//--------------- MagiCon (Loudspeaker mode) ---------------------
+
+bool spe_isSpeFweOn(void)
+{
+ return gSpe.spe_isFweOn;
+}
+
+
+//--------------- New Modes ---------------------
+
+void spe_setHacModeNeeded(bool isNeed)
+{
+ gSpe.isHacModeNeeded = isNeed;
+}
+#endif
+//--------------- viberation speaker ----------------
+
+void spe_setNotchFilterParam(int16 *param, bool is2In1Spk)
+{
+ AM_SetNotchFilterParam(param);
+}
+
+
+/* ========================================================================= */
+/*
+void L1SP_MagiClarityData(const short MAGI_CLARITY_PAR[NUM_MAGI_CLARITY_PARAM])
+{
+ memcpy(&gSpe.sph_magi_clarity_para, MAGI_CLARITY_PAR, NUM_MAGI_CLARITY_PARAM*sizeof(short));
+}
+*/
+/*
+void L1SP_Reload_MagiClarity_Para( void )
+{
+ SPE_MagiClarityData(gSpe.sph_magi_clarity_para);
+}
+*/
+/**
+ Use currect information inside gSpe to decide the mode paramters.
+ @m_para: nb para result
+ @m_para_wb: wb para result
+*/
+
+
+
+void spe_setSpeechMode( uint8 afterSalDevMode, uint8 after_sph_mode)
+{
+ // kal_bool preIsLSP;
+ // kal_bool afterIsLsp;
+
+ // uint8 prev_sph_mode = gSpe.sph_mode;
+
+#if defined( MTK_SLEEP_ENABLE )
+ // kal_uint16 aud_id = L1SP_GetAudID();
+ kal_uint16 aud_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aud_id );
+#endif
+
+
+ //------------------------------------------------------
+ // Changing
+ //------------------------------------------------------
+ // gSpe.sph_mode = after_sph_mode;
+
+ //------------------------------------------------------
+ // Turn on
+ //------------------------------------------------------
+
+
+ SetSpeechEnhancement( true );
+
+ //------------------------------------------------------
+#if defined( MTK_SLEEP_ENABLE )
+ L1Audio_ClearFlag( aud_id );
+ L1Audio_FreeAudioID( aud_id );
+#endif
+
+}
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+void SetSpeechEnhancement( bool ec )
+{
+
+ // For hosted dongle, speech enhancment is not existing by default.
+ // For RNDIS, speech is useless, so don't care.
+ // For super dongle, speech is useful.
+ // As the result, condition is: (chip list) && (data card case without spe enable)
+
+#if defined(SPH_CHIP_BACK_PHONECALL_USE)
+ return;
+#endif // SPH_CHIP_BACK_PHONECALL_USE
+
+ kal_prompt_trace(MOD_L1SP, "[CTM][SPE] l1sp_getCtmSpeStatus() = %d",l1sp_getCtmSpeStatus());
+ // speech is not working.
+ if ((!AM_IsAmInSpeechState()) || (!gSpe.spe_flag) || (!l1sp_getCtmSpeStatus()))
+ return;
+
+ // kal_trace( TRACE_INFO, L1SP_APPLY_MODE, (ec)?1:0, gSpe.sph_mode, -1, 0 );
+ if( ec ) {
+
+ //====================================
+
+ MD_TRC_SPE_SETDYNAMIC_SM(0);
+ MD_TRC_L1SP_SPE_CTRL_UPDATE(gSpe.spe_usr_enh_ctrl, gSpe.sph_SPE_path, AM_GetNetworkRate());
+ SAL_ENH_SetULPath(gSpe.sph_SPE_path!=SpeechEnh_DL);
+ SAL_ENH_SetDLPath(gSpe.sph_SPE_path!=SpeechEnh_UL);
+
+ kal_take_enh_mutex (spe_enh_mutex);
+
+ while(1){
+ MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ if(SAL_ENH_IsParMemAvailable()){
+ SAL_ENH_OccupyParMem();
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ break;
+ }
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ }
+ kal_give_enh_mutex (spe_enh_mutex);
+ MD_TRC_SPE_SETDYNAMIC_SM(1);
+ if(gSpe.spe_is_update_enh_ctrl)
+ {
+ SPE_ENHCtrlSwitch(gSpe.spe_usr_enh_ctrl);
+ }
+
+ //==========write the parameters to DSP==========================
+
+
+ uint16 *c_param ;
+ uint16 *m_param ;
+ uint16 *m_param_wb ;
+ c_param = Sp_GetCommonSpeechPara();
+ m_param = Sp_GetSpeechPara();
+ m_param_wb = Sp_GetWbSpeechPara();
+
+ //1. set Common par.
+ if(gSpe.isSPE_Enable == false)
+ {
+ SPE_LoadSpeechPara(c_param, NULL, NULL, NULL);
+ }
+ //MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ //2. Set Mode par.FIR par.IIR par.
+ if(AM_GetNetworkRate() == RAT_2G_MODE)
+ {
+ Set2GDynPar();
+ }
+ else if(AM_GetNetworkRate()== RAT_3G_MODE || AM_GetNetworkRate()==RAT_3G324M_MODE )
+ {
+ Set3GDynPar();
+ }
+ else if(AM_GetNetworkRate()== RAT_4G_MODE )
+ {
+ Set4GDynPar();
+ }
+ else if(AM_GetNetworkRate()== RAT_C2K_MODE)
+ {
+ SetC2KDynPar();
+ }
+ else
+ {
+ Set2GDynPar();
+ }
+
+
+ //MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ //3. set echo ref info ==> move to scheduler
+ // SPE_SetActiveEchoRefInfo(gSpe.sph_mode);
+ //4. set magiclarity par. (Remove)
+ // SPE_MagiClarityData(gSpe.sph_magi_clarity_para);
+ //5. set DMNR par .
+
+ if(((gSpe.spe_usr_enh_ctrl & SPE_DMNR_SUPPORT)!=0))
+ {
+ SPE_LoadDmnrLspCoeffs(gSpe.sph_lspk_dmnr_para);
+ SPE_LoadWbDmnrLspCoeffs(gSpe.sph_lspk_wb_dmnr_para);
+ SPE_LoadSWbLspDmnrCoeffs(gSpe.sph_lspk_swb_dmnr_para);
+ SPE_LoadDmnrCoeffs(gSpe.sph_dmnr_para);
+ SPE_LoadWbDmnrCoeffs(gSpe.sph_wb_dmnr_para);
+ SPE_LoadSWbDmnrCoeffs(gSpe.sph_swb_dmnr_para);
+ }
+
+ MD_TRC_SPE_SETDYNAMIC_SM(3);
+ SPE_SetDynamicStatemachine();
+ if(gSpe.isSPE_Enable == false)
+ {
+ SPE_Enable_DLL_Entry();
+ }
+ //SPE_WaitSPEDynReady();
+ //MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ SAL_ENH_ReleaseParMem();
+ MD_TRC_SPE_SETDYNAMIC_SM(4);
+ MD_TRC_L1SP_SPEECH_ENHANCEMENT(*m_param, *(m_param+1), *c_param, *(c_param+11));
+ MD_TRC_SPE_SETSPEECHENHANCEMENT_C_PARAM();
+ MD_TRC_L1SP_MODE_VALUE(c_param[0], c_param[1], c_param[2], c_param[3], c_param[4], c_param[5], c_param[6], c_param[7], c_param[8], c_param[9], c_param[10], c_param[11], c_param[12], c_param[13], c_param[14], c_param[15]);
+ MD_TRC_SPE_SETSPEECHENHANCEMENT_M_PARAM();
+ MD_TRC_L1SP_MODE_VALUE(m_param[0], m_param[1], m_param[2], m_param[3], m_param[4], m_param[5], m_param[6], m_param[7], m_param[8], m_param[9], m_param[10], m_param[11], m_param[12], m_param[13], m_param[14], m_param[15]);
+ MD_TRC_L1SP_MODE_VALUE(m_param[16], m_param[17], m_param[18], m_param[19], m_param[20], m_param[21], m_param[22], m_param[23], m_param[24], m_param[25], m_param[26], m_param[27], m_param[28], m_param[29], m_param[30], m_param[31]);
+ MD_TRC_L1SP_MODE_VALUE(m_param[32], m_param[33], m_param[34], m_param[35], m_param[36], m_param[37], m_param[38], m_param[39], m_param[40], m_param[41], m_param[42], m_param[43], m_param[44], m_param[45], m_param[46], m_param[47]);
+ MD_TRC_SPE_SETSPEECHENHANCEMENT_M_PARAM_WB();
+ MD_TRC_L1SP_MODE_VALUE(m_param_wb[0], m_param_wb[1], m_param_wb[2], m_param_wb[3], m_param_wb[4], m_param_wb[5], m_param_wb[6], m_param_wb[7], m_param_wb[8], m_param_wb[9], m_param_wb[10], m_param_wb[11], m_param_wb[12], m_param_wb[13], m_param_wb[14], m_param_wb[15]);
+ MD_TRC_L1SP_MODE_VALUE(m_param_wb[16], m_param_wb[17], m_param_wb[18], m_param_wb[19], m_param_wb[20], m_param_wb[21], m_param_wb[22], m_param_wb[23], m_param_wb[24], m_param_wb[25], m_param_wb[26], m_param_wb[27], m_param_wb[28], m_param_wb[29], m_param_wb[30], m_param_wb[31]);
+ MD_TRC_L1SP_MODE_VALUE(m_param_wb[32], m_param_wb[33], m_param_wb[34], m_param_wb[35], m_param_wb[36], m_param_wb[37], m_param_wb[38], m_param_wb[39], m_param_wb[40], m_param_wb[41], m_param_wb[42], m_param_wb[43], m_param_wb[44], m_param_wb[45], m_param_wb[46], m_param_wb[47]);
+ gSpe.isSPE_Enable = true;
+ gSpe.spe_is_update_enh_ctrl = false;
+ }
+ else {
+
+
+ kal_take_enh_mutex (spe_enh_mutex);
+ MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ SPE_ENHCtrlSwitch(0);
+ SPE_Clear_DLL_Entry();
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ kal_give_enh_mutex (spe_enh_mutex);
+ gSpe.isSPE_Enable = false;
+ // gSpe.spe_state = 0;
+ gSpe.spe_is_update_enh_ctrl = true;
+
+
+#if defined(__TC01_VOICE_ENGINE__)
+ VC_Stop();
+ VS_Stop();
+#endif
+ }
+
+}
+
+
+#else // for 95,97
+
+
+void SetSpeechEnhancement( bool ec )
+{
+ // For hosted dongle, speech enhancment is not existing by default.
+ // For RNDIS, speech is useless, so don't care.
+ // For super dongle, speech is useful.
+ // As the result, condition is: (chip list) && (data card case without spe enable)
+
+#if defined(SPH_CHIP_BACK_PHONECALL_USE)
+ return;
+#endif // SPH_CHIP_BACK_PHONECALL_USE
+
+ kal_prompt_trace(MOD_L1SP, "[SPE] l1sp_getCtmSpeStatus() = %d, gSpe.EMI_isExist__0--0 =%d",l1sp_getCtmSpeStatus(),gSpe.EMI_isExist);
+ // speech is not working.
+ if ((!AM_IsAmInSpeechState()) || (!gSpe.spe_flag) || (!l1sp_getCtmSpeStatus()) || (!gSpe.EMI_isExist))
+ return;
+
+ // kal_trace( TRACE_INFO, L1SP_APPLY_MODE, (ec)?1:0, gSpe.sph_mode, -1, 0 );
+ if( ec ) {
+
+ //====================================
+
+ // notify FDD/TDD info to uSip
+ kal_prompt_trace(MOD_L1SP, "[SPE]SP3G_Rab_State() = %x,L1SP_GetSIMStatus()=%x",SP3G_Rab_State(),L1SP_GetSIMStatus());
+ if( SP3G_Rab_State() )
+ {
+ switch(L1SP_GetSIMStatus()) {
+ case SP_3G_SIM_FDD_ACTIVE:
+ SAL_ENH_Set3GNetworkType(0);
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ SAL_ENH_Set3GNetworkType(1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ MD_TRC_SPE_SETDYNAMIC_SM(0);
+ MD_TRC_L1SP_SPE_CTRL_UPDATE(gSpe.spe_usr_enh_ctrl, gSpe.sph_SPE_path, AM_GetNetworkRate());
+ SAL_ENH_SetULPath(gSpe.sph_SPE_path!=SpeechEnh_DL);
+ SAL_ENH_SetDLPath(gSpe.sph_SPE_path!=SpeechEnh_UL);
+
+ kal_take_enh_mutex (spe_enh_mutex);
+
+ while(1){
+ MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ if(SAL_ENH_IsParMemAvailable()){
+ SAL_ENH_OccupyParMem();
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ break;
+ }
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ }
+ kal_give_enh_mutex (spe_enh_mutex);
+
+ MD_TRC_SPE_SETDYNAMIC_SM(1);
+ if(gSpe.spe_is_update_enh_ctrl)
+ {
+ SPE_ENHCtrlSwitch(gSpe.spe_usr_enh_ctrl);
+ }
+
+ //==========write the parameters to DSP==========================
+
+
+ uint16 *c_param ;
+ c_param = Sp_GetCommonSpeechPara();
+
+ MD_TRC_SPE_SETDYNAMIC_SM(3);
+ MD_TRC_L1SP_SPE_SET_EMI_INFO(1,gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len);
+ SPE_SetDynamicStatemachine(gSpe.sph_EMI_Info_offset,gSpe.sph_EMI_Info_len);
+ if(gSpe.isSPE_Enable == false)
+ {
+ SPE_Enable_DLL_Entry();
+ }
+ SAL_ENH_ReleaseParMem();
+ MD_TRC_SPE_SETDYNAMIC_SM(4);
+ MD_TRC_SPE_SETSPEECHENHANCEMENT_C_PARAM();
+ MD_TRC_L1SP_MODE_VALUE(c_param[0], c_param[1], c_param[2], c_param[3], c_param[4], c_param[5], c_param[6], c_param[7], c_param[8], c_param[9], c_param[10], c_param[11], c_param[12], c_param[13], c_param[14], c_param[15]);
+ gSpe.isSPE_Enable = true;
+ gSpe.spe_is_update_enh_ctrl = false;
+ }
+ else {
+ kal_take_enh_mutex (spe_enh_mutex);
+ MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ SPE_ENHCtrlSwitch(0);
+ SPE_Clear_DLL_Entry();
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ kal_give_enh_mutex (spe_enh_mutex);
+ gSpe.isSPE_Enable = false;
+ // gSpe.spe_state = 0;
+ gSpe.spe_is_update_enh_ctrl = true;
+
+
+#if defined(__TC01_VOICE_ENGINE__)
+ VC_Stop();
+ VS_Stop();
+#endif
+ }
+
+}
+
+
+#endif
+
+static void spe_getFirMappingByScene(const uint32 scene,
+ uint8 *devMode, uint8 *enhMode,
+ uint8 *inFir, uint8 *outFir)
+{
+ uint8 tempDevMode = 0xff;
+ uint8 tempEnhMode = 0xff;
+ uint8 tempInFir = 0xff;
+ uint8 tempOutFir = 0xff;
+
+ switch(scene) {
+ case SPH_ENH_AND_FIR_SCENE_NORMAL:
+ tempDevMode = SAL_DEV_NORMAL; // SPH_MODE_NORMAL;
+ tempEnhMode = SPH_MODE_NORMAL;
+ tempInFir = SPH_FIR_COEFF_NORMAL;
+ tempOutFir = SPH_FIR_COEFF_NORMAL;
+
+ break;
+ case SPH_ENH_AND_FIR_SCENE_EARPHONE:
+ case SPH_ENH_AND_FIR_SCENE_LOUDSPK:
+ tempDevMode = scene; // SAL_DEV_EARPHONE or SAL_DEV_LOUDSPK
+ tempEnhMode = scene;
+ tempInFir = scene;
+ tempOutFir = scene;
+ break;
+// #if defined(__BT_SUPPORT__)
+ case SPH_ENH_AND_FIR_SCENE_BT_EARPHONE:
+ case SPH_ENH_AND_FIR_SCENE_BT_CARKIT:
+ tempDevMode = SAL_DEV_BT_EARPHONE_NB; //scene;
+ tempEnhMode = scene;
+ tempInFir = SPH_FIR_COEFF_BT;
+ tempOutFir = SPH_FIR_COEFF_BT;
+ break;
+
+ case SPH_ENH_AND_FIR_SCENE_BT_CORDLESS:
+ tempDevMode = SAL_DEV_BT_CORDLESS; //scene;
+ tempEnhMode = scene;
+ tempInFir = SPH_FIR_COEFF_BT;
+ tempOutFir = SPH_FIR_COEFF_BT;
+ break;
+//#endif
+ case SPH_ENH_AND_FIR_SCENE_AUX1: // AUX is use to loud speaker mode
+ tempDevMode = SAL_DEV_LOUDSPK; //scene
+ tempEnhMode = SPH_MODE_AUX1; //scene
+ tempInFir = SPH_FIR_COEFF_HANDFREE;
+ tempOutFir = SPH_FIR_COEFF_HANDFREE;
+ break;
+ case SPH_ENH_AND_FIR_SCENE_AUX2:
+ tempDevMode = SPH_MODE_NORMAL;
+ tempEnhMode = SPH_MODE_AUX2;
+ tempInFir = SPH_FIR_COEFF_NORMAL;
+ tempOutFir = SPH_FIR_COEFF_NORMAL;
+ break;
+
+ case SPH_ENH_AND_FIR_SCENE_HAC:
+ ASSERT(true == gSpe.isHacModeNeeded); // is AP did not set the mode parameter. assert it directly!
+
+ tempDevMode = SPH_MODE_NORMAL;
+ tempEnhMode = SPH_MODE_HAC;
+ tempInFir = SPH_FIR_COEFF_HAC;
+ tempOutFir = SPH_FIR_COEFF_HAC;
+ break;
+ case SPH_ENH_AND_FIR_SCENE_USB: // similar to earphone
+ tempDevMode = SPH_MODE_EARPHONE;
+ tempEnhMode = SPH_MODE_USB;
+ tempInFir = SPH_FIR_COEFF_USB;
+ tempOutFir = SPH_FIR_COEFF_USB;
+ break;
+ default:
+ {
+ ASSERT(0);
+ }
+
+ }
+
+ *devMode = tempDevMode;
+ *enhMode = tempEnhMode;
+ *inFir = tempInFir;
+ *outFir = tempOutFir;
+
+}
+
+/**
+ new interface to replace L1SP_SetSpeechMode(), L1SP_Write_Audio_Coefficients(),
+ L1SP_Write_WB_Audio_Coefficients() in the same time.
+
+ if you want to use personal configuration, you can use original interfaces.
+
+ @scene: [Input] scenario for different enhancement and fir combination.
+*/
+void L1SP_SetSpeechEnhanceAndFir(uint32 scene, uint32 updatedCoeff)
+
+{
+ uint8 modeIndex = 0;
+ uint8 inFirIndex = 0;
+ uint8 outFirIndex = 0;
+ uint8 devModeIndex = 0;
+
+
+ //speech mode
+//----------------- original scenario ---------------
+ if(scene <SPH_MODE_UNDEFINED)
+ { //keeping the original scenario
+
+ spe_getFirMappingByScene(scene, &devModeIndex, &modeIndex,
+ &inFirIndex, &outFirIndex);
+
+ if((updatedCoeff == 0)
+ || (updatedCoeff&SPH_ENH_AND_FIR_UPDATE_TYPE_NB_ENH_MODE)!=0
+ || (updatedCoeff&SPH_ENH_AND_FIR_UPDATE_TYPE_WB_ENH_MODE)!=0)
+ spe_setSpeechMode(devModeIndex, modeIndex);
+
+
+ }
+//---------------------- undefined cases --------------------
+ else { // undefined cases.
+ MD_TRC_L1SP_USELESS_SET(scene, 0, 0);
+ }
+
+ //kal_trace( TRACE_INFO, L1SP_SET_ENH_FIR, scene, modeIndex, inFirIndex, outFirIndex, l1sp.spe_usr_mask, l1sp.spe_app_mask);
+ MD_TRC_L1SP_SET_ENH_FIR(scene, modeIndex, inFirIndex, outFirIndex, 0,0);
+
+}
+
+// ----------------------------------------------------------------------------
+// speech parameter loading
+// ----------------------------------------------------------------------------
+extern kal_bool setCommonPara;
+extern uint16 commonPara_0;
+
+void SPE_LoadCommonPara( uint16 c_para[NUM_COMMON_PARAS])
+{
+ uint16 *para;
+ volatile uint16* dsp_ptr;
+ int I;
+ if(c_para)
+ {
+ para = c_para;
+ dsp_ptr = SAL_CommonPar_GetBuf();
+ for(I = SAL_PARAMETERLEN_COMMON; --I >= 0 ; )
+ *dsp_ptr++ = *para++;
+ }
+
+ if(setCommonPara)
+ {
+ dsp_ptr = SAL_CommonPar_GetBuf();
+ *dsp_ptr = commonPara_0;
+ }
+
+}
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+void SPE_LoadSpeechPara( uint16 c_para[NUM_COMMON_PARAS], uint16 m_para[NUM_MODE_PARAS],
+ uint16 m_paraWb[NUM_MODE_PARAS],uint16 m_paraSWb[NUM_MODE_PARAS])
+{
+ uint16 *para;
+ volatile uint16* dsp_ptr;
+ int I;
+
+ if(c_para)
+ {
+ para = c_para;
+ dsp_ptr = SAL_CommonPar_GetBuf();
+ for(I = SAL_PARAMETERLEN_COMMON; --I >= 0 ; )
+ *dsp_ptr++ = *para++;
+ }
+
+ if(setCommonPara)
+ {
+ dsp_ptr = SAL_CommonPar_GetBuf();
+ *dsp_ptr = commonPara_0;
+ }
+
+ if(m_para)
+ {
+ para = m_para;
+ dsp_ptr = SAL_ModePar_GetBuf_NB();
+ for(I = NUM_MODE_PARAS; --I >= 0 ; ) // remind to change SAL_PARAMETERLEN_MODE_NB
+ {
+ *dsp_ptr++ = *para++;
+ }
+ }
+
+ if(m_paraWb)
+ {
+ para = m_paraWb;
+ dsp_ptr = SAL_ModePar_GetBuf_WB();
+ for(I = NUM_MODE_PARAS; --I >= 0 ; )
+ *dsp_ptr++ = *para++;
+ }
+
+ if(m_paraSWb)
+ {
+ para = m_paraSWb;
+ dsp_ptr = SAL_ModePar_GetBuf_SWB();
+ for(I = NUM_MODE_PARAS; --I >= 0 ; )
+ {
+ *dsp_ptr++ = *para++;
+ }
+ }
+
+ Data_Sync_Barrier();
+}
+#endif
+/*
+void SPE_MagiClarityData(short MagiClarityData[32])
+{
+
+ int i;
+ volatile uint16* dsp_ptr;
+ dsp_ptr = SAL_FS_GetFltCoefAddr();
+ for( i = 0; i<32; i++) {
+ *dsp_ptr++ = MagiClarityData[i];
+ }
+
+
+}
+*/
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+void SPE_LoadDmnrCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM])
+{
+
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_NB();
+
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_NB; i++) {
+ *dsp_ptr++ = dmnr_para[i];
+ }
+
+ Data_Sync_Barrier();
+}
+void SPE_LoadDmnrLspCoeffs(kal_int16 dmnr_para[NUM_DMNR_PARAM])
+{
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_NB();
+
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_NB; i++) {
+ *dsp_ptr++ = dmnr_para[i];
+ }
+
+ Data_Sync_Barrier();
+}
+void SPE_LoadWbDmnrCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM])
+{
+
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_WB();
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_WB; i++) {
+ *dsp_ptr++ = wb_dmnr_para[i];
+ }
+
+ Data_Sync_Barrier();
+}
+void SPE_LoadWbDmnrLspCoeffs(kal_int16 wb_dmnr_para[NUM_WB_DMNR_PARAM])
+{
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_WB();
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_WB; i++) {
+ *dsp_ptr++ = wb_dmnr_para[i];
+ }
+
+ Data_Sync_Barrier();
+}
+void SPE_LoadSWbDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM])
+{
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_SWB();
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_SWB; i++) {
+ *dsp_ptr++ = swb_dmnr_para[i];
+ }
+ Data_Sync_Barrier();
+}
+void SPE_LoadSWbLspDmnrCoeffs(kal_int16 swb_dmnr_para[NUM_SWB_DMNR_PARAM])
+{
+
+ int i;
+ volatile uint16* dsp_ptr;
+
+ dsp_ptr = SAL_DMNR_GetFltCoefAddr_LSPK_SWB();
+
+ for( i = 0; i<SAL_FLTCOEFLEN_DMNR_SWB; i++) {
+ *dsp_ptr++ = swb_dmnr_para[i];
+ }
+ Data_Sync_Barrier();
+}
+#endif
+
+void L1SP_EnableSpeechEnhancement( bool enable )
+{
+ if(enable)
+ {
+ gSpe.spe_flag = true;
+ SetSpeechEnhancement(true);
+ }
+ else
+ {
+ SetSpeechEnhancement(false);
+ gSpe.spe_flag = false;
+ }
+}
+
+void L1SP_EnhancementCtrlSupport( uint16 value )
+{
+
+ gSpe.spe_usr_enh_ctrl = value;
+ SetSpeechEnhancement(true);
+}
+
+/* ========================================================================= */
+
+#if defined(_SPE_ENH_MD_PARSE_)
+extern const unsigned short Speech_Normal_Mode_Para[16];
+extern const unsigned short WB_Speech_Normal_Mode_Para[16];
+#endif
+// extern const unsigned short Speech_Vol_Para[4];
+
+void SPE_Init( void )
+{
+
+
+#if !defined(_SPE_ENH_MD_PARSE_) // for 95,97
+ uint32 spe_emi_default_par_offset;
+ gSpe.sph_EMI_Info_offset = 0;
+ gSpe.sph_EMI_Info_len = EMI_MD_DEFAULT_LEN; //set EMI default len
+
+#endif
+ gSpe.spe_flag = true;
+ gSpe.isSPE_Enable = false;
+ // gSpe.isReDDL = false;
+ gSpe.sph_SPE_path=SpeechEnh_All;
+
+ gSpe.spe_isFweOn = false;
+
+
+ //default set the DMNR on
+ // gSpe.spe_usr_sub_mask = 0x023E; // default value to turn on , [bit6]HF DMNR is default off. [bit7] DRC2.0 is default off. sync with Sal_Enh_Dynamic_t bit wise definition
+ gSpe.spe_usr_enh_ctrl = 0x0003; // bit0=DMNR,bit1=TDDNC,bit2=magi con
+ gSpe.spe_is_update_enh_ctrl = true;
+ // gSpe.isNotchFitOn = false;
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ memset(gSpe.sph_ModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+ memset(gSpe.sph_InFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_OutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_InIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_OutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_Mic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_Mic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+
+ memset(gSpe.sph_WbModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+ memset(gSpe.sph_WbInFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_WbOutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_WbInIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_WbOutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_WbMic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_WbMic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbModePara, 0, TOTAL_NETWORK_NUMBER*NUM_MODE_PARAS*sizeof(uint16));
+ memset(gSpe.sph_SWbInFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbOutFirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbInIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbOutIirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbMic1IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS*sizeof(int16));
+ memset(gSpe.sph_SWbMic2IirCoeff, 0, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS*sizeof(int16));
+ // SPE_MagiClarityData(Speech_All_Pass_MAG_CLARITY);
+
+ memset(&gSpe.sph_dmnr_para, 0, NUM_DMNR_PARAM*sizeof(uint16));
+ memset(&gSpe.sph_lspk_dmnr_para, 0, NUM_DMNR_PARAM*sizeof(uint16));
+ memset(&gSpe.sph_wb_dmnr_para, 0, NUM_WB_DMNR_PARAM*sizeof(uint16));
+ memset(&gSpe.sph_lspk_wb_dmnr_para, 0, NUM_WB_DMNR_PARAM*sizeof(uint16));
+
+
+ gSpe.isMagiConOn = false;
+ memset(gSpe.sph_magicConParam, 0, NUM_MODE_PARAS*sizeof(uint16));
+ memset(gSpe.sph_magicConWbParam, 0, NUM_MODE_PARAS*sizeof(uint16));
+
+
+ // init the AGC as off in every channal
+ // _write_enh_internalPar_(SPE_INTERNALPAR_INDEX_AGC, 0)
+
+ SPE_LoadSpeechPara((uint16 *)Speech_Common_Para, (uint16 *)Speech_Normal_Mode_Para, (uint16 *)WB_Speech_Normal_Mode_Para,(uint16 *)WB_Speech_Normal_Mode_Para );
+
+ #else //for 95,97
+ L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para);
+ L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para);
+ SAL_ENH_Set3GNetworkType(0);
+ // EMI layout
+ // EMI layout
+ spe_emi_default_par_offset = EMI_NEED_3K_0 + EMI_GUARD_PATTERN + MD_PRIVATE;
+ if(SP_GetSphParamBufAddr() == NULL)
+ {
+ gSpe.EMI_isExist = false;
+ }
+ else
+ {
+ gSpe.EMI_isExist = true;
+ memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset, &(Common_Param_Default), sizeof(unsigned short) * 72);
+ memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+72, &(DMNR_Param_Default), sizeof(unsigned short) * 1468);
+ memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+1540, &(MagiClarity_Param_Default), sizeof(unsigned short) * 75);
+ memcpy(((unsigned short *)(SP_GetSphParamBufAddr()))+ spe_emi_default_par_offset+1615, &(Speech_Param_Default), sizeof(unsigned short) * (418+134));
+ memset(((unsigned short *)(SP_GetSphParamBufAddr())), 0, EMI_NEED_3K_0*sizeof(unsigned short)); //3K
+ }
+ #endif
+ if (! spe_enh_mutex)
+ {
+ spe_enh_mutex = kal_create_enh_mutex("spe_enh_mutex");
+ }
+ gSpe.ctm_spe_status = true;
+}
+
+
+/* ========================================================================= */
+/* ========================================================================= */
+/* EC/AEC/EES control Functions */
+/* ========================================================================= */
+#define FLAG_EC_SUPP 1
+#define FLAG_DDL_UL_ENTRY 2
+#define FLAG_DDL_DL_ENTRY 4
+
+#define SPE_IDLE_STATE 0 /* MCU: 0 -> 1 */
+#define SPE_READY_STATE 1 /* DSP: 1 -> 2 */
+#define SPE_WORKING_STATE 2 /* MCU: 2 -> 3 */
+#define SPE_STOP_STATE 3 /* DSP: 3 -> 0 */
+
+
+#define _wait_for_ready_( enh_mod ) \
+{ \
+ uint32 I; \
+ for( I = 0; ; I++ ) { \
+ if( SAL_ENH_IsReady(enh_mod)) \
+ break; \
+ ASSERT_REBOOT( I < 20 ); \
+ kal_sleep_task( AUD_1TICK(2) ); \
+ } \
+}
+
+#define _wait_for_idle_( enh_mod ) \
+{ \
+ uint32 I; \
+ for( I = 0; ; I++ ) { \
+ if( SAL_ENH_IsIdle(enh_mod)) \
+ break; \
+ ASSERT_REBOOT( I < 20 ); \
+ kal_sleep_task( AUD_1TICK(2) ); \
+ } \
+}
+
+
+void SPE_ENHCtrlSwitch(uint16 state)
+{
+
+ SAL_ENH_SetDMNR(((state & SPE_DMNR_SUPPORT)!=0));
+ SAL_ENH_SetTDNC(((state & SPE_TDNC_SUPPORT)!=0));
+ SAL_ENH_SetMagicConference(((state & SPE_MAGI_CON_SUPPORT)!=0));
+}
+
+
+
+void SPE_Clear_DLL_Entry()
+{
+ SAL_ENH_SetMainSwitch(false);
+}
+
+
+void SPE_Enable_DLL_Entry(void)
+{
+ SAL_ENH_SetMainSwitch(true);
+}
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+void SPE_SetDynamicStatemachine(void)
+{
+
+ SAL_ENH_ParUpdState_SetUpd();
+ MD_TRC_SPE_SETDYNAMIC_SM(0);
+
+
+}
+
+#else //for 95,97
+void SPE_SetDynamicStatemachine(kal_uint32 Offset, kal_uint32 Len)
+{
+
+ SAL_ENH_ParUpdState_SetUpd_Offset(Offset,Len);
+ MD_TRC_SPE_SETDYNAMIC_SM(0);
+}
+#endif
+
+void SPE_WaitSPEDynReady(void)
+{
+
+ uint32 I;
+ for( I = 0; ; I++ ) {
+ if( SAL_ENH_ParUpdPState_IsIdle())
+ break;
+ //ASSERT_REBOOT( I < 20 );
+ if(I>20)
+ {
+ ASSERT(0);
+ }
+ kal_sleep_task(AUD_1TICK(2)); //kal_sleep_task( 2 );
+
+ }
+ MD_TRC_SPE_SETDYNAMIC_SM(1);
+}
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+void SetDynamicParToDSP(uint32 IDnumber)
+{
+#if defined( MTK_SLEEP_ENABLE )
+ kal_uint16 aud_id = L1SP_GetAudID();
+#endif
+
+ kal_take_enh_mutex (spe_enh_mutex);
+ MD1_DSP_kal_cc_take_spinlock(kal_cc_md1_dsp_spinlock, KAL_INFINITE_WAIT);
+ switch (IDnumber) {
+
+ case Par_GSM_NB_SpeechUnit:
+ {
+ SP_SetSpeechPara(gSpe.sph_ModePara[0]);
+ SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[0], NULL, NULL);
+ AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[0], gSpe.sph_OutFirCoeff[0] );
+ AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[0], gSpe.sph_OutIirCoeff[0],gSpe.sph_Mic1IirCoeff[0],gSpe.sph_Mic2IirCoeff[0]);
+
+ }
+ break;
+ case Par_GSM_WB_SpeechUnit:
+ {
+ SP_SetWbSpeechPara(gSpe.sph_WbModePara[0]);
+ SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[0], NULL );
+ AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]);
+ AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[0],gSpe.sph_WbOutIirCoeff[0],gSpe.sph_WbMic1IirCoeff[0],gSpe.sph_WbMic2IirCoeff[0]);
+
+ }
+ break;
+
+#if !defined( __UMTS_TDD128_MODE__ )
+ case Par_WCDMA_NB_SpeechUnit:
+ {
+ SP_SetSpeechPara(gSpe.sph_ModePara[1]);
+ SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[1], NULL, NULL);
+ AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[1], gSpe.sph_OutFirCoeff[1] );
+ AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[1], gSpe.sph_OutIirCoeff[1],gSpe.sph_Mic1IirCoeff[1],gSpe.sph_Mic2IirCoeff[1]);
+
+ //set speech nb mode flag, fir nb in flag,fir out nb flag
+ }
+ break;
+ case Par_WCDMA_WB_SpeechUnit:
+ {
+ SP_SetWbSpeechPara(gSpe.sph_WbModePara[1]);
+ SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[1], NULL );
+ AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[1],gSpe.sph_WbOutFirCoeff[1]);
+ AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[1],gSpe.sph_WbOutIirCoeff[1],gSpe.sph_WbMic1IirCoeff[1],gSpe.sph_WbMic2IirCoeff[1]);
+
+ }
+ break;
+#else //CDMA
+ case Par_CDMA_NB_SpeechUnit:
+ {
+ SP_SetSpeechPara(gSpe.sph_ModePara[2]);
+ SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[2], NULL, NULL);
+ AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[2], gSpe.sph_OutFirCoeff[2] );
+ AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[2], gSpe.sph_OutIirCoeff[2],gSpe.sph_Mic1IirCoeff[2],gSpe.sph_Mic2IirCoeff[2]);
+ }
+ break;
+ case Par_CDMA_WB_SpeechUnit:
+ {
+ SP_SetWbSpeechPara((kal_uint16*)gSpe.sph_WbModePara[2]);
+ SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[2], NULL );
+ AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[2],gSpe.sph_WbOutFirCoeff[2]);
+ AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[2],gSpe.sph_WbOutIirCoeff[2],gSpe.sph_WbMic1IirCoeff[2],gSpe.sph_WbMic2IirCoeff[2]);
+
+ }
+ break;
+
+#endif
+ case Par_VOLTE_NB_SpeechUnit:
+ {
+
+ SP_SetSpeechPara(gSpe.sph_ModePara[3]);
+ SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[3], NULL, NULL);
+ AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[3], gSpe.sph_OutFirCoeff[3] );
+ AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[3], gSpe.sph_OutIirCoeff[3],gSpe.sph_Mic1IirCoeff[3],gSpe.sph_Mic2IirCoeff[3]);
+
+ }
+ break;
+ case Par_VOLTE_WB_SpeechUnit:
+ {
+
+ SP_SetWbSpeechPara(gSpe.sph_WbModePara[3]);
+ SPE_LoadSpeechPara(NULL, NULL, gSpe.sph_WbModePara[3], NULL);
+ AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[3],gSpe.sph_WbOutFirCoeff[3]);
+ AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[3],gSpe.sph_WbOutIirCoeff[3],gSpe.sph_WbMic1IirCoeff[3],gSpe.sph_WbMic2IirCoeff[3]);
+ }
+ break;
+ case Par_VOLTE_SWB_SpeechUnit:
+ {
+ SP_SetSWbSpeechPara(gSpe.sph_SWbModePara[3]);
+ SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_SWbModePara[3] );
+ AM_WriteSWbFirCoeffs(gSpe.sph_SWbInFirCoeff[3],gSpe.sph_SWbOutFirCoeff[3]);
+ AM_WriteSWbIirCoeffs(gSpe.sph_SWbInIirCoeff[3],gSpe.sph_SWbOutIirCoeff[3],gSpe.sph_SWbMic1IirCoeff[3],gSpe.sph_SWbMic2IirCoeff[3]);
+
+ }
+ break;
+ case Par_C2K_NB_SpeechUnit:
+ {
+
+ SP_SetSpeechPara(gSpe.sph_ModePara[4]);
+ SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[4], NULL, NULL); // l1sp.sph_v_para no one use it.
+ AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[4], gSpe.sph_OutFirCoeff[4] );
+ AM_WriteIirCoeffs( gSpe.sph_InIirCoeff[4], gSpe.sph_OutIirCoeff[4],gSpe.sph_Mic1IirCoeff[4],gSpe.sph_Mic2IirCoeff[4]);
+
+
+ }
+ break;
+ case Par_C2K_WB_SpeechUnit:
+ {
+
+ SP_SetWbSpeechPara(gSpe.sph_WbModePara[4]);
+ SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[4] ); // l1sp.sph_v_para no one use it.
+ AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[4],gSpe.sph_WbOutFirCoeff[4]);
+ AM_WriteWbIirCoeffs(gSpe.sph_WbInIirCoeff[4],gSpe.sph_WbOutIirCoeff[4],gSpe.sph_WbMic1IirCoeff[4],gSpe.sph_WbMic2IirCoeff[4]);
+
+ }
+ break;
+
+
+
+ default:
+ {
+ MD_TRC_SPE_SETDYNAMICPARTOMD_NOT_FIND(IDnumber);
+ break;
+ }
+ }
+ MD1_DSP_kal_cc_give_spinlock(kal_cc_md1_dsp_spinlock);
+ kal_give_enh_mutex (spe_enh_mutex);
+#if defined( MTK_SLEEP_ENABLE )
+ L1SP_FreeAudID(aud_id);
+#endif
+
+}
+void Set2GDynPar(void)
+{
+ SetDynamicParToDSP(Par_GSM_NB_SpeechUnit);
+ SetDynamicParToDSP(Par_GSM_WB_SpeechUnit);
+
+}
+
+void Set3GDynPar(void)
+{
+#if !defined( __UMTS_TDD128_MODE__ )
+
+ SetDynamicParToDSP(Par_WCDMA_NB_SpeechUnit);
+ SetDynamicParToDSP(Par_WCDMA_WB_SpeechUnit);
+#else
+ SetDynamicParToDSP(Par_CDMA_NB_SpeechUnit);
+ SetDynamicParToDSP(Par_CDMA_WB_SpeechUnit);
+
+#endif
+
+}
+
+void Set4GDynPar(void)
+{
+ SetDynamicParToDSP(Par_VOLTE_NB_SpeechUnit);
+ SetDynamicParToDSP(Par_VOLTE_WB_SpeechUnit);
+ SetDynamicParToDSP(Par_VOLTE_SWB_SpeechUnit);
+
+}
+
+void SetC2KDynPar(void)
+{
+ SetDynamicParToDSP(Par_C2K_NB_SpeechUnit);
+ SetDynamicParToDSP(Par_C2K_WB_SpeechUnit);
+
+}
+#endif
+
+
+
+
+void SetSPEnhancePath(uint8 path)
+{
+ if(path == SpeechEnh_All)
+ {
+ gSpe.sph_SPE_path=SpeechEnh_All;
+ }
+ else if(path == SpeechEnh_UL)
+ {
+ gSpe.sph_SPE_path=SpeechEnh_UL;
+ }
+ else if(path == SpeechEnh_DL)
+ {
+ gSpe.sph_SPE_path=SpeechEnh_DL;
+ }
+ else
+ {
+ ASSERT(0);
+ }
+
+ SetSpeechEnhancement(true);
+
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_gain.c b/mcu/driver/audio/src/v1/sp_gain.c
new file mode 100644
index 0000000..d00bab7
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_gain.c
@@ -0,0 +1,285 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2017
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_gain.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+
+#include "l1sp_trc.h"
+
+#include "l1audio.h"
+#include "am.h"
+
+static struct {
+
+ kal_int16 digitOnly_digital_gain;
+ kal_int16 digitOnly_sphEnhRef_digital_gain;
+ kal_int16 digitOnly_mic_volume;
+
+}spGain;
+
+
+const kal_uint16 digitOnly_quater_dB_tableForSpeech[296] =
+{
+ 10289, 9997, 9713, 9438, /* 8 ~ 7.25 dB*/
+ 9170, 8910, 8657, 8411, /* 7 ~ 6.25 dB*/
+ 8173, 7941, 7715, 7497, /* 6 ~ 5.25 dB*/
+ 7284, 7077, 6876, 6681, /* 5 ~ 4.25 dB*/
+ 6492, 6308, 6129, 5955, /* 4 ~ 3.25 dB*/
+ 5786, 5622, 5462, 5307, /* 3 ~ 2.25 dB*/
+ 5120, 5010, 4868, 4730, /* 2 ~ 1.25 dB*/ // uplink begin (2 db == 5120 == 0x1400)
+ 4596, 4465, 4339, 4216, /* 1 ~ 0.25 dB*/
+ 4096, 3980, 3867, 3757, /* 0 ~ -0.75 dB*/ // downlink begin (0 db == 4096 == 0x1000) ==> chip newer then MT6572
+ 3645, 3547, 3446, 3349, /* -1 ~ -1.75 dB*/ // downlink begin (-1db == 3645 == 0xE3D) ==> Old chip MT6280 & MT6589
+ 3254, 3161, 3072, 2984, /* -2 ~ -2.75 dB*/
+ 2900, 2817, 2738, 2660, /* -3 ~ -3.75 dB*/
+ 2584, 2511, 2440, 2371, /* -4 ~ -4.75 dB*/
+ 2303, 2238, 2175, 2113, /* -5 ~ -5.75 dB*/
+ 2053, 1995, 1938, 1883, /* -6 ~ -6.75 dB*/
+ 1830, 1778, 1727, 1678, /* -7 ~ -7.75 dB*/
+ 1631, 1584, 1539, 1496, /* -8 ~ -8.75 dB*/
+ 1453, 1412, 1372, 1333, /* -9 ~ -9.75 dB*/
+ 1295, 1259, 1223, 1188, /* -10 ~ -10.75 dB*/
+ 1154, 1122, 1090, 1059, /* -11 ~ -11.75 dB*/
+ 1029, 1000, 971 , 944 , /* -12 ~ -12.75 dB*/
+ 917 , 891 , 866 , 841 , /* -13 ~ -13.75 dB*/
+ 817 , 794 , 772 , 750 , /* -14 ~ -14.75 dB*/
+ 728 , 708 , 688 , 668 , /* -15 ~ -15.75 dB*/
+ 649 , 631 , 613 , 595 , /* -16 ~ -16.75 dB*/
+ 579 , 562 , 546 , 531 , /* -17 ~ -17.75 dB*/
+ 516 , 501 , 487 , 473 , /* -18 ~ -18.75 dB*/
+ 460 , 447 , 434 , 422 , /* -19 ~ -19.75 dB*/
+ 410 , 398 , 387 , 376 , /* -20 ~ -20.75 dB*/
+ 365 , 355 , 345 , 335 , /* -21 ~ -21.75 dB*/
+ 325 , 316 , 307 , 298 , /* -22 ~ -22.75 dB*/
+ 290 , 282 , 274 , 266 , /* -23 ~ -23.75 dB*/
+ 258 , 251 , 244 , 237 , /* -24 ~ -24.75 dB*/
+ 230 , 224 , 217 , 211 , /* -25 ~ -25.75 dB*/
+ 205 , 199 , 194 , 188 , /* -26 ~ -26.75 dB*/
+ 183 , 178 , 173 , 168 , /* -27 ~ -27.75 dB*/
+ 163 , 158 , 154 , 150 , /* -28 ~ -28.75 dB*/
+ 145 , 141 , 137 , 133 , /* -29 ~ -29.75 dB*/
+ 130 , 126 , 122 , 119 , /* -30 ~ -30.75 dB*/
+ 115 , 112 , 109 , 106 , /* -31 ~ -31.75 dB*/
+ 103 , 100 , 97 , 94 , /* -32 ~ -32.75 dB*/
+ 92 , 89 , 87 , 84 , /* -33 ~ -33.75 dB*/
+ 82 , 79 , 77 , 75 , /* -34 ~ -34.75 dB*/
+ 73 , 71 , 69 , 67 , /* -35 ~ -35.75 dB*/
+ 65 , 63 , 61 , 60 , /* -36 ~ -36.75 dB*/
+ 58 , 56 , 55 , 53 , /* -37 ~ -37.75 dB*/
+ 52 , 50 , 49 , 47 , /* -38 ~ -38.75 dB*/
+ 46 , 45 , 43 , 42 , /* -39 ~ -39.75 dB*/
+ 41 , 40 , 39 , 38 , /* -40 ~ -40.75 dB*/
+ 37 , 35 , 34 , 33 , /* -41 ~ -41.75 dB*/
+ 33 , 32 , 31 , 30 , /* -42 ~ -42.75 dB*/
+ 29 , 28 , 27 , 27 , /* -43 ~ -43.75 dB*/
+ 26 , 25 , 24 , 24 , /* -44 ~ -44.75 dB*/
+ 23 , 22 , 22 , 21 , /* -45 ~ -45.75 dB*/
+ 21 , 20 , 19 , 19 , /* -46 ~ -46.75 dB*/
+ 18 , 18 , 17 , 17 , /* -47 ~ -47.75 dB*/
+ 16 , 16 , 15 , 15 , /* -48 ~ -48.75 dB*/
+ 15 , 14 , 14 , 13 , /* -49 ~ -49.75 dB*/
+ 13 , 13 , 12 , 12 , /* -50 ~ -50.75 dB*/
+ 12 , 11 , 11 , 11 , /* -51 ~ -51.75 dB*/
+ 10 , 10 , 10 , 9 , /* -52 ~ -52.75 dB*/
+ 9 , 9 , 9 , 8 , /* -53 ~ -53.75 dB*/
+ 8 , 8 , 8 , 7 , /* -54 ~ -54.75 dB*/
+ 7 , 7 , 7 , 7 , /* -55 ~ -55.75 dB*/
+ 6 , 6 , 6 , 6 , /* -56 ~ -56.75 dB*/
+ 6 , 6 , 5 , 5 , /* -57 ~ -57.75 dB*/
+ 5 , 5 , 5 , 5 , /* -58 ~ -58.75 dB*/
+ 5 , 4 , 4 , 4 , /* -59 ~ -59.75 dB*/
+ 4 , 4 , 4 , 4 , /* -60 ~ -60.75 dB*/
+ 4 , 4 , 3 , 3 , /* -61 ~ -61.75 dB*/
+ 3 , 3 , 3 , 3 , /* -62 ~ -62.75 dB*/
+ 3 , 3 , 3 , 3 , /* -63 ~ -63.75 dB*/
+ 3 , 3 , 2 , 2 , /* -64 ~ -64.75 dB*/
+ 2 , 2 , 2 , 2 , /* -65 ~ -65.75 dB*/
+};
+
+/**
+ Only use when MODEM do not have analog device, ie. ANALOG_AFE_PATH_EXIST is NOT defined
+
+ @digitalGainQDb: input digital gain value in dB. 4 step/1db.
+ for example: digitalGainDb=1 --> 0.25 dB; digitalGainDb=FFF4(-12) --> -3dB
+ @isDL: true for downlink, false for uplink
+ @return: value set to dsp
+
+*/
+kal_uint16 _digitOnly_convert_digital_gain_forSpeech(kal_int16 digitalGainQDb, kal_bool isDl)
+{
+ kal_int16 idx = (-digitalGainQDb);
+
+ if(isDl){
+#if 0
+/* under construction !*/
+/* under construction !*/
+#else // data card chip should begin from 0
+ idx += 32; // begin from 0 db
+#endif
+ } else {
+ // for UL. useless now
+ }
+
+ return digitOnly_quater_dB_tableForSpeech[idx];
+
+}
+
+//=============================================================================
+/**
+ @digitalGainQdB: input digital gain value in quarter dB, i.e. 4 step/1db.
+ for example: digitalGainDb=1 --> 0.25 dB; digitalGainDb=FFF4(-12) --> -3dB
+*/
+// void AFE_DigitalOnly_SetDigitalGain(kal_uint8 aud_func, kal_int16 digitalGainQdB, kal_bool isForceSet)
+void spGain_SetDigitalGain(kal_int16 digitalGainQdB, kal_bool isForceSet)
+{
+ MD_TRC_AFE_SET_GIDI_GAIN(digitalGainQdB, isForceSet);
+ ASSERT((digitalGainQdB)<=0 && (digitalGainQdB>=-256)); // value frome -64 db to 0 db
+
+ spGain.digitOnly_digital_gain = _digitOnly_convert_digital_gain_forSpeech(digitalGainQdB, true);
+
+ if(AM_IsAmInSpeechState()) {
+ AM_DSP_SetSpeechDigitalGain(spGain.digitOnly_digital_gain );
+ } else if (isForceSet) {
+ uint16 aid = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aid );
+
+ AM_DSP_SetSpeechDigitalGain(spGain.digitOnly_digital_gain );
+
+ L1Audio_ClearFlag( aid );
+ L1Audio_FreeAudioID( aid );
+ }
+}
+
+
+
+/**
+
+ @digitalGainQdB: input digital gain value in quarter dB, i.e. 4 step/1db.
+ for example: digitalGainDb=1 --> 0.25 dB; digitalGainDb=FFF4(-12) --> -3dB
+*/
+void spGain_SetEnhRefDigitalGain(kal_int16 refDigitalGainQdB, kal_bool isForceSet)
+{
+ MD_TRC_AFE_SET_SPH_REF_GIDI_GAIN(refDigitalGainQdB);
+ ASSERT((refDigitalGainQdB)<=0 && (refDigitalGainQdB>=-28)); // value from -7 db to 0 db
+
+ spGain.digitOnly_sphEnhRef_digital_gain = _digitOnly_convert_digital_gain_forSpeech(refDigitalGainQdB, true);
+
+ if(AM_IsAmInSpeechState()) {
+ AM_DSP_SetSpeechEnhRefDigitalGain(spGain.digitOnly_sphEnhRef_digital_gain);
+ } else if (isForceSet) {
+ uint16 aid = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aid );
+
+ AM_DSP_SetSpeechEnhRefDigitalGain(spGain.digitOnly_sphEnhRef_digital_gain );
+
+ L1Audio_ClearFlag( aid );
+ L1Audio_FreeAudioID( aid );
+ }
+}
+
+void spGain_SetMicrophoneVolume( kal_int16 mic_volume, kal_bool isForceSet )
+{
+ MD_TRC_AFE_SET_MIC_VOLUME(mic_volume);
+ ASSERT((mic_volume)>=0 && (mic_volume<=120)); // range is 0~ 30 dB
+
+ spGain.digitOnly_mic_volume = (mic_volume>>2); // 4 is 1 db
+ if(AM_IsAmInSpeechState()) {
+ AM_DSP_SetSpeechUplinkSwAgcGain(spGain.digitOnly_mic_volume);
+ } else if (isForceSet) {
+ uint16 aid = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aid );
+
+ AM_DSP_SetSpeechUplinkSwAgcGain(spGain.digitOnly_mic_volume);
+
+ L1Audio_ClearFlag( aid );
+ L1Audio_FreeAudioID( aid );
+ }
+}
+
+
+// ============================================================================
+void spGain_Refresh2DSP(void)
+{
+ uint16 aid = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aid );
+
+ AM_DSP_SetSpeechDigitalGain(spGain.digitOnly_digital_gain );
+ AM_DSP_SetSpeechEnhRefDigitalGain(spGain.digitOnly_sphEnhRef_digital_gain );
+ AM_DSP_SetSpeechUplinkSwAgcGain(spGain.digitOnly_mic_volume);
+
+ L1Audio_ClearFlag( aid );
+ L1Audio_FreeAudioID( aid );
+}
+
+void spGain_Init(void)
+{
+ spGain.digitOnly_digital_gain = 0x1000; // 0 dB in DSP
+ spGain.digitOnly_sphEnhRef_digital_gain = 0x1000; // 0 dB in DSP
+ spGain.digitOnly_mic_volume = 0;
+
+ spGain_Refresh2DSP();
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_ps.c b/mcu/driver/audio/src/v1/sp_ps.c
new file mode 100644
index 0000000..1227614
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps.c
@@ -0,0 +1,1641 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching speech interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "l1sp_trc.h"
+#include "amr_table.h"
+#include "sal_exp.h"
+#include "sal_def.h"
+#include "dcl.h"
+#include "drv_sap.h"
+#include "ltecsr_msgid.h"
+#include "audio_msgid.h"
+#include "sp_drv.h"
+
+#include "sp_ps.h"
+#include "sp_ps_aam.h"
+
+#include "sp_ps_codec_amr.h"
+#if defined(__EVS_CODEC_SUPPORT__)
+#include "sp_ps_codec_evs.h"
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+//#if defined(__G_CODEC_SUPPORT__)
+#include "sp_ps_codec_g.h"
+//#endif //#if defined(__G_CODEC_SUPPORT__)
+
+#include "sp_ps_dsp_opt.h"
+#include "sp_ps_aamp.h"
+
+//for query OP
+#include "ps_public_utility.h"
+
+//AAM related
+#include "l1sp_el2_struct.h"
+#include "el2_msgid.h"
+//#ifndef TK6291_FAKE_COMPILE
+//#include "uas_export_api.h"
+//#include "csr_export_api.h"
+//#endif //#ifndef TK6291_FAKE_COMPILE
+
+
+/*****************************
+Definitions
+*****************************/
+
+
+/*****************************
+External variables
+*****************************/
+extern kal_enhmutexid sp_handover_mutex;//sp_4g.c
+
+
+/*****************************
+External functions
+*****************************/
+extern void CSR_Codec_Close(int rab_id);
+extern void CSR_Codec_Ready(int rab_id);
+extern kal_uint32 SP3G_Rab_Id( void );
+extern uint32 L1I_GetTimeStamp( void );
+extern void sp4g_vmRecordService( uint32 *l1_info, uint16 crc_result, uint16 buf_status, uint16 *ul_frame_data, uint16* dl_frame_data, kal_bool bBufferOK);
+volatile uint16* SAL_PcmEx_Get4GULBuf(int *len);
+extern kal_uint32 get_is_fake_4g(void);
+
+
+/*****************************
+Local variables
+*****************************/
+static kal_uint8 spPS_reset_flag; // speech on and InterRAT : set TRUE
+static kal_bool spPS_dtx_mode;
+static int spPS_fake_EVS_IO;
+static uint8 spPS_est_codec_mode;
+static kal_uint32 spPS_rab_id;
+static kal_uint32 spPS_rab_id_record[SPPS_RAB_ID_MAX]; //valid element: 1~(SPPS_RAB_ID_MAX-1)
+static kal_bool spPS_rab_state;
+static SP_PS_RADIO_TYPE spPS_RadioType;
+
+static kal_uint8 encodebits_null[32];
+static kal_uint8 bitlen_null;
+
+VoLTE_JBM_TS_Info_t JBM_info_local;
+
+SPPS_Struct_t *spPS;
+SPPS_Struct_t stSPPS;
+kal_spinlockid spinlock_sp4g;
+
+SP4G_PSR_CallType sp4g_PSR_CallType = SP4G_PSR_CallType_None;
+
+/*****************************
+Local functions
+*****************************/
+
+void SP4G_PSR_SetCallType(SP4G_PSR_CallType type){
+ sp4g_PSR_CallType = type;
+}
+SP4G_PSR_CallType SP4G_PSR_GetCallType(void){
+ return(sp4g_PSR_CallType);
+}
+
+void spPS_RadioType_set(SP_PS_RADIO_TYPE radio_type)
+{
+ spPS_RadioType = radio_type;
+}
+
+
+SP_PS_RADIO_TYPE spPS_RadioType_get(void)
+{
+ return(spPS_RadioType);
+}
+
+
+void spPS_reset_flag_set(kal_uint8 val)
+{
+ spPS_reset_flag = val;
+}
+
+
+kal_uint8 spPS_reset_flag_get(void)
+{
+ return(spPS_reset_flag);
+}
+
+
+bool is_g_codec(uint8 codec)
+{
+ return( sp_ps_codec_g_is_g_codec(codec) );
+}
+
+
+bool is_EVS_codec(uint8 codec)
+{
+ return( sp_ps_codec_evs_is_EVS_codec(codec) );
+}
+
+
+int UseEVSIO2ReplaceAWB(void)
+{
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ int ret = (int)L1Audio_GetDebugInfo(SPH_DEBUGINFO);
+
+ ret = ret & SPH_DEBUGINFO12_BIT0;
+ if(ret == 0x00)
+ return(1);
+ else
+ return(0);
+#else //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ return(0);
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+}
+
+
+void PSR_SP4G_Callback( SP4G_Event event, void *data ){
+ if(get_is_fake_4g() == 0)
+ {
+ if(SP4G_UL_DATA_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_LTECSR, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_UL_DATA_NOTIFY /* message id */
+ );
+ }else if(SP4G_UL_MUTE_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_LTECSR, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_UL_MUTE_NOTIFY /* message id */
+ );
+ }else if(SP4G_DL_DATA_NOTIFY == event){
+#if 1
+ ilm_SP4G_PSR_DL_INFO_t *local_para;
+ local_para = (ilm_SP4G_PSR_DL_INFO_t *) construct_local_para( sizeof(ilm_SP4G_PSR_DL_INFO_t), TD_CTRL );
+ local_para->JBM_info.TS_Switch = (kal_uint8)SAL_4G_GetTSSwitch();
+ local_para->JBM_info.TS_Remain_Length_ms = (kal_int16)SAL_Get_RingBuf_RemainLen();
+ local_para->JBM_info.TS_Total_Length_ms = (kal_int16)SAL_Get_RingBuf_TotalLen();
+ msg_send6(MOD_L1SP, MOD_LTECSR, L1SP_LTECSR_SAP, MSG_ID_LTECSR_VOICE_DL_DATA_NOTIFY, (local_para_struct *)local_para, NULL);
+
+#endif
+ }
+ else if(SP4G_DL_MUTE_NOTIFY == event){
+#if 1
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_LTECSR, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_DL_MUTE_NOTIFY /* message id */
+ );
+#endif
+ }
+ }
+ else
+ {
+ if(SP4G_UL_DATA_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_MED, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_UL_DATA_NOTIFY /* message id */
+ );
+ }else if(SP4G_UL_MUTE_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_MED, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_UL_MUTE_NOTIFY /* message id */
+ );
+ }else if(SP4G_DL_DATA_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_MED, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_DL_DATA_NOTIFY /* message id */
+ );
+ }
+ else if(SP4G_DL_MUTE_NOTIFY == event){
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_MED, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_VOICE_DL_MUTE_NOTIFY /* message id */
+ );
+ }
+ }
+}
+
+
+int get_spps_fake_EVS_IO(void)
+{
+ return spPS_fake_EVS_IO;
+}
+
+
+int get_sp4g_fake_EVS_IO(void)
+{
+ return( get_spps_fake_EVS_IO() );
+}
+
+
+kal_int32 SP4G_PSR_getToneDeteResult(void)
+{
+#ifdef __SP_4G_OPT_TONE_DETECTION_EXECUTED_IN_DSP__
+ return( (kal_int32)SAL_Get_DuDuPtnFlag() );
+#else // __SP_4G_OPT_TONE_DETECTION_EXECUTED_IN_DSP__
+#if defined(__SP_4G_OPT_TONE_DETECTION__)
+ return( sp_ps_dsp_opt_ToneDeteGetResult() );
+#else //#if defined(__SP_4G_OPT_TONE_DETECTION__)
+ return( 0 );
+#endif //#if defined(__SP_4G_OPT_TONE_DETECTION__)
+#endif // __SP_4G_OPT_TONE_DETECTION_EXECUTED_IN_DSP__
+}
+
+
+kal_int32 SP4G_PSR_getEarPhone(void)
+{
+ if( SPH_EXTDEVINFO_EARPHONE == SP_GetExtDevInfo() ) {
+ return( 1 );
+ }
+ else {
+ return( 0 );
+ }
+}
+
+
+kal_uint32 SP4G_GetGCodecMode(void)
+{
+ return spPS->ul_codec_mode;
+
+}
+
+
+kal_bool SP4G_IsGCodecMode()
+{
+ return sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode);
+}
+
+
+kal_bool SP4G_IsEVSCodecMode()
+{
+ return sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode);
+}
+
+
+kal_uint32 SP4G_GetCodecMode(void)
+{
+ if(spPS != NULL)
+ return spPS->ul_codec_mode;
+ else
+ return INIT_CODEC;
+}
+
+
+void sp_ps_link_est( uint32 rab_id, kal_uint8 default_speech_codec )
+{
+ kal_uint8 old_ul_codec_mode = spPS->ul_codec_mode;
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ kal_bool retval;
+ kal_uint8 new_SP4G_Codec;
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ spPS_rab_id = rab_id;
+ spPS_rab_state = KAL_TRUE;
+
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ if( UseEVSIO2ReplaceAWB() )
+ {
+ MD_TRC_SPPS_RAB_EST_USE_EVS_IO_REPLACE_AWB_IN(default_speech_codec, default_speech_codec);
+ retval = convert_AWB_to_EVSIOEnum( (SP4G_Codec)default_speech_codec, (SP4G_Codec*)&new_SP4G_Codec );
+ if(retval == KAL_TRUE) {
+ spPS_fake_EVS_IO = 1;
+ }
+ else {
+ spPS_fake_EVS_IO = 0;
+ }
+ default_speech_codec = new_SP4G_Codec;
+ MD_TRC_SPPS_RAB_EST_USE_EVS_IO_REPLACE_AWB_OUT(default_speech_codec, default_speech_codec);
+ }
+ else
+ {
+ spPS_fake_EVS_IO = 0;
+ }
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ spPS_est_codec_mode = default_speech_codec;
+ if( (sp_ps_codec_g_is_g_codec(spPS_est_codec_mode) == false) && (sp_ps_codec_evs_is_EVS_codec(spPS_est_codec_mode) == false) )
+ {
+ spPS_est_codec_mode = sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(spPS_est_codec_mode);//GetFrameType2DspMode(spPS_est_codec_mode);
+ }
+ if(spPS != (SPPS_Struct_t *)NULL)
+ {
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = spPS_est_codec_mode;//default_speech_codec;
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ MD_TRC_SPPS_RAB_EST1(default_speech_codec, default_speech_codec, spPS_est_codec_mode);
+ MD_TRC_SPPS_RAB_EST2(rab_id, default_speech_codec, default_speech_codec/*spPS_est_codec_mode*/); /* Notice!! Due to the procedure of PSR, SP4G_Rab_Est must follow SetULFrameType so that spPS_est_codec_mode has been set properly*/
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( L1SP_GetState() == L1SP_STATE_C2K_SPEECH_ON ){//
+ //C2K_Codec_Close(SP3G_Rab_Id());
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+ AM_InterRAT_C2K_to_4G(SP4G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+#endif
+ if( L1SP_GetState() == L1SP_STATE_3G_SPEECH_ON ){//
+ CSR_Codec_Close(SP3G_Rab_Id());
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+
+ AM_InterRAT_3G_to_4G(SP4G_GetCodecMode());
+
+ //fix me , depend on codec
+
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+ if( L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON ){//prepare InterRAT HO
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+ AM_InterRAT_2G_to_4G(SP4G_GetCodecMode());
+
+ //fix me , depend on codec
+
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else
+ if( L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON ){//prepare InterRAT HO
+ uint32 resetType = PS_SRST_TYPE_HO_WITHOUT_VBIEND;
+ PSR_SP4G_Callback(SP4G_CODEC_READY, (void*)0 );
+ SP4G_Reset();
+ if( (sp_ps_codec_g_is_g_codec(old_ul_codec_mode) == true) || (sp_ps_codec_g_is_g_codec(default_speech_codec) == true) )
+ {
+ resetType = PS_SRST_TYPE_HO_WITH_VBIEND;
+ }
+ AM_4G_INTRARAT(SP4G_GetCodecMode(), resetType);
+
+ //fix me , depend on codec
+
+ L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }
+}
+
+
+//CSR inform RAB is established, the rab_id should be set as parameter when callback to CSR
+kal_uint32 SPPS_PSR_Link_Est(SP4G_Codec default_speech_codec, SP_PS_RADIO_TYPE radio_type) // function call
+{
+ kal_int32 i;
+ kal_uint8 speech_codec_local = (kal_uint8)default_speech_codec;
+ //spPS_rab_id++;
+ //if(spPS_rab_id > 5)//just want to get unique id without any extra purpose
+ // spPS_rab_id = 0;
+
+ spPS_rab_id = 0;
+ for(i=1; i<SPPS_RAB_ID_MAX; i++)
+ {
+ if(spPS_rab_id_record[i] == 0)
+ {
+ spPS_rab_id = i;
+ spPS_rab_id_record[i] = 1;
+ break;
+ }
+ }
+ ASSERT(spPS_rab_id > 0);
+
+ kal_take_enh_mutex( sp_handover_mutex );
+ //AM_SetBlockMED( SAL_APP_TYPE_4GCall, true, 4);
+
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_4G , true);
+ spPS_RadioType = radio_type;
+ sp_ps_link_est( spPS_rab_id, speech_codec_local );
+
+ //AM_SetBlockMED( SAL_APP_TYPE_4GCall, false, 4);
+ kal_give_enh_mutex( sp_handover_mutex );
+
+ MD_TRC_SPPS_PSR_LINK_EST(spPS_rab_id);
+ return spPS_rab_id;
+}
+
+
+//CSR inform RAB is established, the rab_id should be set as parameter when callback to CSR
+kal_uint32 SP4G_PSR_Link_Est( SP4G_Codec default_speech_codec ) // function call
+{
+ return( SPPS_PSR_Link_Est(default_speech_codec, SP_PS_RADIO_TYPE_LTE) );
+}
+
+
+void SP4G_PSR_Link_Deest(kal_uint32 id) // function call
+{
+ kal_int32 i;
+ kal_uint32 spPS_rab_id_total;
+ MD_TRC_SPPS_RAB_DEEST(id);
+ //ASSERT(id == spPS_rab_id);
+ ASSERT(spPS_rab_id_record[id] == 1);
+
+ spPS_rab_id_record[id] = 0;
+ spPS_rab_id_total = 0;
+ for(i=1; i<SPPS_RAB_ID_MAX; i++)
+ {
+ spPS_rab_id_total |= spPS_rab_id_record[i];
+ }
+ if(spPS_rab_id_total == 0)
+ {
+ spPS_rab_state = KAL_FALSE;
+ spPS_est_codec_mode = INIT_CODEC;
+ spPS_RadioType = SP_PS_RADIO_TYPE_UNKNOWN;
+ }
+
+ MD_TRC_SPPS_PSR_LINK_DEEST(spPS_rab_state);
+
+ SAL_Set_LinkStatus(SAL_LINKSTATUS_4G , false);
+ kal_take_enh_mutex( sp_handover_mutex );
+#if defined(__C2K_SPEECH_SUPPORT__)
+ if( L1SP_isC2KSO_Connected() && L1SP_GetState() != L1SP_STATE_C2K_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//4G->C2K
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)0 );
+ AM_InterRAT_4G_to_C2K(L1SP_GetC2KSO_Codec());
+ L1SP_SetState( L1SP_STATE_C2K_SPEECH_ON );
+ }else
+#endif
+ if( SP3G_Rab_State() && L1SP_GetState() != L1SP_STATE_3G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//4G->3G
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)0 );
+ CSR_Codec_Ready(SP3G_Rab_Id());
+ AM_InterRAT_4G_to_3G(SP3G_GetCodecMode());
+ L1SP_SetState( L1SP_STATE_3G_SPEECH_ON );
+ }else
+ if( L1SP_TCH_State() && L1SP_GetState() != L1SP_STATE_2G_SPEECH_ON && L1SP_GetState() != L1SP_STATE_IDLE ){//4G->2G
+ PSR_SP4G_Callback(SP4G_CODEC_CLOSED, (void*)0 );
+ AM_InterRAT_4G_to_2G();
+ L1SP_SetState( L1SP_STATE_2G_SPEECH_ON );
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+kal_bool spPS_Rab_State_get( void )
+{
+ return spPS_rab_state;
+}
+
+
+kal_bool SP4G_Rab_State( void )
+{
+ return( spPS_Rab_State_get() );
+}
+
+
+kal_uint32 SP4G_Rab_Id( void )
+{
+ return spPS_rab_id;
+}
+
+
+void SP4G_GetSyncDelayRW( kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us)
+{
+ sp_ps_aam_GetSyncDelayRW(u16DelayR, u16DelayW, u16DelayM, u32CurTime64us);
+}
+
+
+void SP4G_Set_G711Parameters(kal_int32 law, kal_int32 dec_init_CNG_enable)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ sp_ps_codec_g_Set_G711Parameters(law, dec_init_CNG_enable);
+//#endif //#if defined(__G_CODEC_SUPPORT__)
+}
+
+
+void SP4G_PSR_UL_GSeries_GetSpeechFrame(SP4G_Codec *codec, kal_uint8 *encodebits, kal_uint8 *bitlen)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ MD_TRC_SPPS_PSR_UL_GSERIES_GETSPEECHFRAME();
+ sp_ps_codec_g_GetFrame((int8 *)codec, (int8 *)bitlen, (uint8 *)encodebits);
+ MD_TRC_SPPS_PSR_UL_GSERIES_GETSPEECHFRAME_INFO(*codec, *codec, encodebits[0], encodebits[1], encodebits[2], encodebits[3], *bitlen);
+ // SP_updateEmCodec(true, *codec, false, 0);
+//#endif
+}
+
+
+void SP4G_PSR_DL_GSeries_PutSpeechFrame(SP4G_Codec codec, kal_uint8 *encodebits, kal_uint8 *bitlen)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ if(encodebits == NULL)
+ {
+ encodebits = encodebits_null;
+ bitlen = &bitlen_null;
+ *bitlen = 0;
+ }
+ MD_TRC_SPPS_PSR_DL_GSERIES_PUTSPEECHFRAME();
+ sp_ps_codec_g_PutFrame((int)codec, (int)(*bitlen), (uint8 *)encodebits);
+ MD_TRC_SPPS_PSR_DL_GSERIES_PUTSPEECHFRAME_INFO(codec, codec, encodebits[0], encodebits[1], encodebits[2], encodebits[3], *bitlen);
+ // SP_updateEmCodec(false, 0, true, codec);
+//#endif
+}
+
+
+/*
+return value:
+0: No more data in ul_buf.
+1: Have more data in ul_buf
+*/
+int SP4G_PSR_UL_GSeries_IsMoreData(void)
+{
+ return( sp_ps_codec_g_UL_GSeries_IsMoreData() );
+}
+
+
+void sp4g_hisr_ul_g(void *data)
+{
+ sp_ps_codec_g_hisr_ul_g((void *)0);
+}
+
+void sp4g_hisr_dl_g(void *data)
+{
+ sp_ps_codec_g_hisr_dl_g((void *)0);
+}
+
+void SP4G_EVS_CallOpenSetPar(void)
+{
+ sp_ps_codec_evs_CallOpenSetPar();
+}
+
+
+void SP4G_PSR_SetEVSEncCAPara(EVS_ENC_CA_PARAMETER *pEVS_CA_Par)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ sp_ps_codec_evs_SetEVSEncCAPara(pEVS_CA_Par);
+ kal_give_spinlock(spinlock_sp4g);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void SP4G_PSR_SetEVSDecCAPara(EVS_DEC_CA_PARAMETER *pEVS_CA_Par)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ sp_ps_codec_evs_SetEVSDecCAPara(pEVS_CA_Par);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+kal_bool SP4G_PSR_GetEVSDecCAPara(kal_uint8* CA_RF_Flag, kal_uint8* CA_RF_Offset, SP4G_Codec codec, kal_uint8* frame_pt, kal_uint8 offset)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ kal_uint32 rf_flag, rf_offset, rf_type;
+ *CA_RF_Flag = 0;
+ *CA_RF_Offset = 0;
+
+ if (codec==SP4G_CODEC_EVS_16K_013_2 || codec==SP4G_CODEC_EVS_32K_013_2) // EVS 13.2
+ {
+ rf_flag = SP4G_Get_Bit_Value(frame_pt, offset, 5);
+ rf_offset = SP4G_Get_Bit_Value(frame_pt, offset + 259, 2);
+ rf_type = SP4G_Get_Bit_Value(frame_pt, offset + 261, 3);
+ //FPRINT_04("VoLTE JBM Get_Payload_Info: rf_flag: %d, rf_offset: %d, rf_type: %d\n", rf_flag, rf_offset, rf_type);
+ if (rf_flag >=21 && rf_flag <=28 && rf_type != 0)
+ {
+ *CA_RF_Flag = 1;
+ if (rf_offset == 0)
+ *CA_RF_Offset = 2;
+ else if (rf_offset == 1)
+ *CA_RF_Offset = 3;
+ else if (rf_offset == 2)
+ *CA_RF_Offset = 5;
+ else if (rf_offset == 3)
+ *CA_RF_Offset = 7;
+ else
+ *CA_RF_Offset = 0;
+ }
+ return KAL_TRUE;
+ }
+
+ return KAL_FALSE;
+#else //#if defined(__EVS_CODEC_SUPPORT__)
+ return KAL_FALSE;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+kal_uint32 SP4G_Get_Bit_Value(kal_uint8* frame_pt, kal_uint32 offset, kal_uint8 size)
+{
+ kal_uint8 index, bit_offset, data;
+ kal_uint32 ret = 0;
+ kal_uint8 bits;
+
+ if (size >32)
+ {
+ return 0;
+ }
+ bits = sizeof(kal_uint8)*8;
+ index = offset/bits;
+ bit_offset = bits - 1 - offset%bits;
+ for (; size>0; size--)
+ {
+ ret = ret << 1;
+ data = frame_pt[index];
+ if (((data >> bit_offset) & 0x1) == 1)
+ {
+ ret++;
+ }
+ if (bit_offset == 0)
+ {
+ bit_offset = bits - 1;
+ index++;
+ }
+ else
+ {
+ bit_offset--;
+ }
+ }
+ return ret;
+}
+
+void SP4G_PSR_UL_EVS_GetSpeechFrame(SP4G_Codec *frame_type, kal_uint8 *encodebits, kal_uint32 *bitlen, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ //kal_prompt_trace(MOD_L1SP, "SP4G_PSR_UL_EVS_GetSpeechFrame");
+ MD_TRC_SPPS_PSR_UL_EVS_GETSPEECHFRAME();
+
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ sp_ps_codec_evs_UL_GetSpeechFrame(frame_type, encodebits, (kal_int32 *) bitlen);
+
+ kal_give_enh_mutex( sp_handover_mutex );
+
+ // SP_updateEmCodec(true, *frame_type, false, 0);
+#else //#if defined(__EVS_CODEC_SUPPORT__)
+ *frame_type = SP4G_CODEC_EVS_32K_000_0_NODATA;
+ *bitlen = 0;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void SP4G_PSR_DL_EVS_PutSpeechFrame(kal_uint32 CFN, SP4G_Codec frame_type, kal_uint8 *encodebits, EVS_DEC_CA_PARAMETER *pEVS_Dec_CA_Par, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+ if( (VoLTE_JBM_TS_Info_t *)NULL == JBM_info )
+ {
+ JBM_info = &JBM_info_local;
+ }
+ sp_ps_codec_evs_DL_PutSpeechFrame(CFN, frame_type, encodebits, pEVS_Dec_CA_Par, crc_status, JBM_info);
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+void sp4g_hisr_dl(void *data)
+{
+ uint8 ul_codec_mode_local;
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ ul_codec_mode_local = spPS->ul_codec_mode;
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (sp_ps_codec_g_is_g_codec(ul_codec_mode_local)) )
+ {
+ MD_TRC_SPPS_DL_HISR_SKIP(L1SP_GetState(), sp_ps_codec_g_is_g_codec(ul_codec_mode_local));
+ kal_give_spinlock(spinlock_sp4g);
+ return;
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(sp_ps_codec_evs_is_EVS_codec(ul_codec_mode_local))
+ {
+ sp_ps_codec_evs_hisr_dl_EVS(data);
+ }
+ else
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ {
+ sp_ps_codec_amr_hisr_dl_amr(data);
+ }
+}
+
+void SP4G_Reset( void )
+{
+ spPS_reset_flag = 1;
+}
+
+
+kal_bool spPS_IsDTXOn(void)
+{
+ return spPS_dtx_mode;
+}
+
+
+kal_bool SP4G_IsDTXOn(void)
+{
+ return( spPS_IsDTXOn() );
+}
+
+
+void SP4G_SetDTX(kal_bool on)
+{
+ spPS_dtx_mode = on;
+ MD_TRC_SPPS_SET_DTX(on);
+ if( L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON )
+ {
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ SAL_3G_SetDtx(on);
+
+ kal_give_spinlock(spinlock_sp4g);
+ }
+}
+
+
+void SP4G_PSR_SetDTX(kal_bool on)
+{
+ SP4G_SetDTX(on);
+}
+
+
+void SP4G_SetRxTypeToNoData( void )
+{
+ //SAL_3G_Set_RxType(SAL_3G_RX_NO_DATA);
+ SAL_4G_Set_RxType(SAL_3G_RX_NO_DATA, SAL_3G_RX_NO_DATA);
+}
+
+
+kal_uint32 SP4G_JBM_GetDLVADFlag()
+{
+ return SAL_GetDLVADFlag();
+}
+
+
+void sp4g_hisr_ul(void *data)
+{
+ uint8 ul_codec_mode_local;
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ ul_codec_mode_local = spPS->ul_codec_mode;
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (sp_ps_codec_g_is_g_codec(ul_codec_mode_local)) )
+ {
+ MD_TRC_SPPS_UL_HISR_SKIP(L1SP_GetState(), sp_ps_codec_g_is_g_codec(ul_codec_mode_local));
+ kal_give_spinlock(spinlock_sp4g);
+ return;
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(sp_ps_codec_evs_is_EVS_codec(ul_codec_mode_local))
+ {
+ sp_ps_codec_evs_hisr_ul_EVS(data);
+ }
+ else
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ {
+ sp_ps_codec_amr_hisr_ul_amr(data);
+ }
+
+#if defined(__SP_4G_OPT_TONE_DETECTION__)
+ /**************************/
+ // Execute Tone Detection
+ /**************************/
+ L1Audio_SetEvent( sp_ps_dsp_opt_ToneDeteGetAudID(), (void *)0 );
+#endif //#if defined(__SP_4G_OPT_TONE_DETECTION__)
+}
+
+
+void sp_ps_reset_internal( void )
+{
+ // DL side(G-series)
+//#if defined(__G_CODEC_SUPPORT__)
+ if(sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)){
+ sp_ps_codec_g_reset_internal();
+ spPS_reset_flag = 2;
+ }else
+//#endif //#if defined(__G_CODEC_SUPPORT__)
+ {
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)) {
+ sp_ps_codec_evs_reset_internal();
+ spPS_reset_flag = 0;
+ }else
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ {
+ sp_ps_codec_amr_reset_internal();
+ spPS_reset_flag = 0; // clear reset flag, wait it to be 2
+ }
+ spPS->ul_waiting = KAL_FALSE;
+ spPS->dl_waiting = KAL_FALSE;
+ }
+}
+
+
+void sp4g_init( void )
+{
+ int i;
+
+ spPS_rab_id = 0;
+ for(i=0; i<SPPS_RAB_ID_MAX; i++)
+ {
+ spPS_rab_id_record[i] = 0;
+ }
+ spPS_rab_state = KAL_FALSE;
+ spPS_fake_EVS_IO = 0;
+ spPS_dtx_mode = 1;
+
+ spPS_RadioType = SP_PS_RADIO_TYPE_UNKNOWN;
+
+ JBM_info_local.TS_Switch = 0;
+ JBM_info_local.TS_HB_Frm_Num = 1;
+ JBM_info_local.TS_Frm_ID = 1;
+ JBM_info_local.TS_isRemainFrame = 0;
+ JBM_info_local.TS_Scale = 100;
+ JBM_info_local.TS_Max_Scale = 0;
+ JBM_info_local.TS_JBM_Reset_Flag = 0;
+ JBM_info_local.TS_DSP_Reset_Flag = 0;
+ JBM_info_local.TS_Remain_Length_ms = 0;
+ JBM_info_local.TS_Total_Length_ms = 0;
+ //JBM_info_local.TS_Reserve[JBM_TS_RESERVE];
+ JBM_info_local.Nodata_Type = JBM_NODATA_NORMAL;
+
+#if defined(__EVS_CODEC_SUPPORT__)
+ sp_ps_codec_evs_init();
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+#if defined(__SP4G_UL_RESYNC__)
+ sp_ps_aam_init();
+#endif
+
+ spPS = &stSPPS;
+ spinlock_sp4g = kal_create_spinlock("SP4GSL");
+}
+
+
+void sp4g_speech_init(uint8 RAT_Mode)
+{
+ ASSERT( RAT_Mode == RAT_4G_MODE );
+ ASSERT( L1SP_GetState() == L1SP_STATE_IDLE );
+
+ memset(spPS, 0, sizeof(SPPS_Struct_t));
+ spPS->sp4g_mode = RAT_Mode;
+ // UL side
+ spPS->ul_waiting = KAL_FALSE;
+ spPS->dl_waiting = KAL_FALSE;
+ spPS->ul_write_idx = 0;
+ spPS->ul_read_idx = 0;
+ spPS->ul_count = 0;
+ spPS->is_getting_ul_data = KAL_FALSE;
+ spPS->ul_delay = 0;
+ spPS->dl_delay = 0;
+ spPS->pre_ul_report = spPS->pre_dl_report = spPS->ul_report = spPS->dl_report = spPS_est_codec_mode;//INIT_CODEC;
+ MD_TRC_SPPS_DEBUG_SPPS_SPEECH_INIT(spPS_est_codec_mode);
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ spPS->ul_buffer_size = RAT_4G_UL_BUFFER_NUM;
+ }
+
+#if defined(UL_HARD_REAL_TIME_DEMAND)
+ spPS->ul_buffer_size = HARD_REAL_TIME_UL_BUFFER_NUM;
+#endif
+
+ spPS->ul_codec_mode = spPS_est_codec_mode;//INIT_CODEC;// use 12.20kbps rate initially
+
+ spPS->ul_refresh = KAL_FALSE; // detect change codec_mode
+ spPS->ul_intrarat = KAL_FALSE;
+
+ // DL side
+ spPS->dl_count = 0;
+ spPS->dl_write_idx = 0;
+ spPS->dl_read_idx = 0;
+
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ MD_TRC_SPPS_PP5_SP4G_RESET_FLAG_INFO(spPS_reset_flag, spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+ MD_TRC_SPPS_PP5_1(RAT_4G_DL_BUFFER_NUM_BEFORE_RESYNC);
+ spPS->dl_buffer_size = RAT_4G_DL_BUFFER_NUM_BEFORE_RESYNC;
+ spPS->dl_buffer_size = 2;
+ MD_TRC_SPPS_PP6_SP4G_RESET_FLAG_INFO(spPS_reset_flag, spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+ spPS_reset_flag = 1;
+ }
+ else{ // 4G324M
+ spPS->dl_buffer_size = MAX_DL_BUFFER_NUM;
+ spPS_reset_flag = 2;
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ spPS->time[SP_PSCALL_EMAC][0] = spPS->time[SP_PSCALL_EMAC][1] = spPS->time[SP_PSCALL_EMAC][2] = 0;
+ spPS->time[SP_PSCALL_NMAC][0] = spPS->time[SP_PSCALL_NMAC][1] = spPS->time[SP_PSCALL_NMAC][2] = 0;
+ spPS->request_resync = KAL_FALSE;
+ spPS->time2nextULHISR[SP_PSCALL_EMAC] = spPS->time2nextULHISR[SP_PSCALL_NMAC] = 0; //unit: ms
+#endif
+
+#if defined(__SP4G_UL_RESYNC__)
+ sp_ps_aam_speech_init();
+#endif
+
+ sp_ps_aam_speech_init_SilenceDetection();
+
+#if defined(SP4G_UNIT_TEST)
+ L1Audio_HookHisrHandler(DP_D2C_4G,(L1Audio_EventHandler)sp4g_hisr_2, 0);
+#else
+ L1Audio_HookHisrHandler(DP_D2C_4G_AMR_DONE_UL,(L1Audio_EventHandler)sp4g_hisr_ul, 0);
+ L1Audio_HookHisrHandler(DP_D2C_4G_AMR_DONE_DL,(L1Audio_EventHandler)sp4g_hisr_dl, 0);
+#endif
+
+#if defined(__SP4G_UL_RESYNC__)
+ L1Audio_HookHisrHandler(DP_D2C_4G_AAM,(L1Audio_EventHandler)sp_ps_AAM_hisr, 0);
+#endif
+
+#ifdef __SP_PS_AAM_PLUS__
+ L1Audio_HookHisrHandler(DP_D2C_4G_AAMPLUS,(L1Audio_EventHandler)sp_ps_AAMPlus_notify_EMAC, 0);//fix
+#endif //#ifdef __SP_PS_AAM_PLUS__
+
+
+//#if defined(__G_CODEC_SUPPORT__)
+ sp_ps_codec_g_speech_init();
+//#endif//#if defined(__G_CODEC_SUPPORT__)
+
+#if defined(__EVS_CODEC_SUPPORT__)
+ sp_ps_codec_evs_speech_init();
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+#if defined(__SP_4G_OPT_TONE_DETECTION__)
+ sp_ps_dsp_opt_ToneDeteInit();
+ sp_ps_dsp_opt_ToneDeteTaskInit();
+#endif //#if defined(__SP_4G_OPT_TONE_DETECTION__)
+
+ spPS->l1_info_idx = 0;
+ spPS->dtx_state = 0;
+
+#ifdef __SP_PS_AAM_PLUS__
+ sp_ps_AAMPlus_enable();
+#endif //#ifdef __SP_PS_AAM_PLUS__
+
+}
+
+SP_PSCALL_L2_MODE SP4G_GetL2Mode()
+{
+ return spPS->sph_l2_mode;
+}
+//#if defined(__G_CODEC_SUPPORT__)
+void GSeries_Encode_Init(SP4G_Codec codec_)
+{
+ sp_ps_codec_g_Encode_Init(codec_);
+}
+
+
+void GSeries_Encode_DeInit()
+{
+
+}
+
+
+void GSeries_Decode_Init(SP4G_Codec codec_)
+{
+ sp_ps_codec_g_Decode_Init(codec_);
+}
+
+
+void GSeries_Decode_DeInit()
+{
+
+}
+
+
+void sp4g_speech_close( void )
+{
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_AMR_DONE_DL);
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_AMR_DONE_UL);
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_AAM);
+#ifdef __SP_PS_AAM_PLUS__
+ L1Audio_UnhookHisrHandler(DP_D2C_4G_AAMPLUS);
+#endif //#ifdef __SP_PS_AAM_PLUS__
+
+ sp_ps_codec_g_close();
+
+#if defined(__SP_4G_OPT_TONE_DETECTION__)
+ sp_ps_dsp_opt_ToneDeteClose();
+#endif //#if defined(__SP_4G_OPT_TONE_DETECTION__)
+
+#ifdef __SP_PS_AAM_PLUS__
+ sp_ps_AAMPlus_disable();
+#endif //#ifdef __SP_PS_AAM_PLUS__
+}
+
+
+kal_uint16 SP4G_PSR_GetCodecBitLength(SP4G_Codec codec) // function call
+{
+ int len = 0/*, I*/;
+
+ if(sp_ps_codec_g_is_g_codec(codec)){
+ if(codec == SP4G_CODEC_G711)
+ {
+ kal_uint16 G711_codec_bitlength = 80*8;
+ return G711_codec_bitlength;
+ }
+ ASSERT(false);//FIX ME
+ }else if(GET_IS_SP4G_CODEC_ENUM_EVS_ID(codec)){
+ #if defined(__EVS_CODEC_SUPPORT__)
+ return( sp_ps_codec_evs_GetCodecBitLength(codec) );
+ #else //#if defined(__EVS_CODEC_SUPPORT__)
+ ASSERT(false);//FIX ME
+ #endif //#if defined(__EVS_CODEC_SUPPORT__)
+ }else{//AMR, WB-AMR
+ return( sp_ps_codec_amr_GetCodecBitLength(codec) );
+ }
+ return len;
+}
+
+
+void SP4G_UL_SetFrameType(uint8 amr_frame_type) // function call
+{
+ uint8 state;
+ uint32 codec;
+ spPS_est_codec_mode = sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(amr_frame_type);//AmrFrameType2DspMode_spps[amr_frame_type];
+
+ if( (state = L1SP_GetState()) != L1SP_STATE_4G_SPEECH_ON){
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ MD_TRC_SPPS_REQUEST_UL_FRAME_TYPE(amr_frame_type, amr_frame_type);
+ codec = sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(amr_frame_type);//AmrFrameType2DspMode_spps[amr_frame_type];
+ if( (sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)==true) || (sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)==true) )
+ {
+ uint32 resetType = PS_SRST_TYPE_HO_WITHOUT_VBIEND;
+ if( sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode) == true )
+ {
+ resetType = PS_SRST_TYPE_HO_WITH_VBIEND;
+ }
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ AM_4G_INTRARAT(codec, resetType);
+ //may add at 3G
+ //spPS->ul_intrarat = KAL_TRUE;
+ SP4G_Reset();
+ MD_TRC_SPPS_SETCODEC_SETFRAMETYPE1(spPS->ul_codec_mode, spPS->ul_codec_mode, codec, amr_frame_type, amr_frame_type, spPS->ul_intrarat);
+ //L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else if( (spPS->ul_codec_mode >= 0x20 && codec <= 0x0A) || (spPS->ul_codec_mode <= 0x0A && codec >= 0x20) ){//Intrarat
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ AM_4G_INTRARAT(codec, PS_SRST_TYPE_HO_WITHOUT_VBIEND);
+ //may add at 3G
+ spPS->ul_intrarat = KAL_TRUE;
+ SP4G_Reset();
+ MD_TRC_SPPS_SETCODEC_SETFRAMETYPE2(spPS->ul_codec_mode, codec, amr_frame_type, amr_frame_type, spPS->ul_intrarat);
+ //L1SP_SetState( L1SP_STATE_4G_SPEECH_ON );
+ }else{
+ if(spPS->ul_codec_mode != codec){
+ MD_TRC_SPPS_SETCODEC_SETFRAMETYPE3(spPS->ul_codec_mode, codec,amr_frame_type, amr_frame_type, spPS->ul_intrarat);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ spPS->ul_refresh = KAL_TRUE;
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ }
+}
+
+
+void SP4G_PSR_UL_SetFrameType(SP4G_Codec codec)
+{
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ kal_bool retval;
+ kal_uint8 new_SP4G_Codec;
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ MD_TRC_SPPS_SETCODEC0(codec, codec);
+
+ MD_TRC_SPPS_PSR_UL_SETFRAMETYPE1(codec, L1SP_GetState(), sp_ps_codec_g_is_g_codec(codec), sp_ps_codec_evs_is_EVS_codec(codec));
+
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ if( UseEVSIO2ReplaceAWB() )
+ {
+ MD_TRC_SPPS_SETCODEC_USE_EVS_IO_REPLACE_AWB_IN(codec);
+ retval = convert_AWB_to_EVSIOEnum( codec, (SP4G_Codec*)&new_SP4G_Codec );
+ if(retval == KAL_TRUE) {
+ spPS_fake_EVS_IO = 1;
+ }
+ else {
+ spPS_fake_EVS_IO = 0;
+ }
+ codec = new_SP4G_Codec;
+ MD_TRC_SPPS_SETCODEC_USE_EVS_IO_REPLACE_AWB_OUT(codec);
+ }
+ else
+ {
+ spPS_fake_EVS_IO = 0;
+ }
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ spPS_est_codec_mode = codec;
+ if( (sp_ps_codec_g_is_g_codec(spPS_est_codec_mode)==false) && (sp_ps_codec_evs_is_EVS_codec(spPS_est_codec_mode)==false) ){
+ spPS_est_codec_mode = sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(spPS_est_codec_mode);//GetFrameType2DspMode(spPS_est_codec_mode);
+ }
+
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ if( 1/*L1SP_STATE_IDLE == L1SP_GetState()*/ ){
+ if( spPS != (SPPS_Struct_t *)NULL ){
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = spPS_est_codec_mode;//default_speech_codec;
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ MD_TRC_SPPS_SETCODEC(codec, codec, spPS_est_codec_mode);
+ }
+ kal_give_enh_mutex( sp_handover_mutex );
+ return;
+ }
+
+ if(sp_ps_codec_g_is_g_codec(codec)){
+ if(codec == spPS->ul_codec_mode){
+ MD_TRC_SPPS_SETCODEC_IS_EQUAL(codec, codec);
+ //return;
+ }
+ else{
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ AM_4G_INTRARAT(codec, PS_SRST_TYPE_HO_WITH_VBIEND);
+ SP4G_Reset();
+ }
+ }else if(sp_ps_codec_evs_is_EVS_codec(codec)){
+ if( /*sp_ps_codec_evs_is_EVS_codec(codec) ==*/ sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode) ){
+ if( GET_SP4G_CODEC_ENUM_NON_EVS_ID(codec) != GET_SP4G_CODEC_ENUM_NON_EVS_ID(spPS->ul_codec_mode) )
+ {
+ sp_ps_codec_evs_set_network_bw(codec);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ AM_4G_INTRARAT(codec, PS_SRST_TYPE_HO_WITHOUT_VBIEND);
+ SP4G_Reset();
+ }
+ else if( codec != (spPS->ul_codec_mode) )
+ {
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ }
+ else
+ {
+ uint32 reset_type = PS_SRST_TYPE_HO_WITHOUT_VBIEND;
+ if( sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode) == true )
+ {
+ reset_type = PS_SRST_TYPE_HO_WITH_VBIEND;
+ }
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_codec_mode = codec;
+ kal_give_spinlock(spinlock_sp4g);
+ AM_4G_INTRARAT(codec, reset_type);
+ SP4G_Reset();
+ }
+ }else{
+ SP4G_UL_SetFrameType(codec);
+ }
+
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+void SP4G_PSR_UL_AMR_GetSpeechFrame(SP4G_Codec *frame_type, kal_uint8 *encodebits, kal_uint8 *bitlen, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ if(spPS_fake_EVS_IO == 0) {
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ sp_ps_codec_amr_UL_GetSpeechFrame(frame_type, encodebits, bitlen);
+ // SP_updateEmCodec(true, convert_SP4G_CODEC_AMR_AMRWB_to_SPH_CODEC((*frame_type)), false, 0);
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ } else {
+ kal_bool retval;
+ SP4G_Codec EVSIO_frame_type;
+ kal_uint32 u32bitlen;
+ uint8 EVS_codec_rate = 0;
+
+ //MD_TRC_SPPS_UL_GETSPEECHFRAME_USE_EVS_IO_REPLACE_AWB();
+
+ {
+#if defined(__EVS_CODEC_SUPPORT__)
+ sp_ps_codec_evs_UL_GetSpeechFrame(&EVSIO_frame_type, encodebits, (kal_int32 *)&u32bitlen);
+#else //#if defined(__EVS_CODEC_SUPPORT__)
+ *frame_type = SP4G_CODEC_EVS_32K_000_0_NODATA;
+ *bitlen = 0;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+ }
+
+ EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(EVSIO_frame_type);
+ *bitlen = (kal_uint8)sp_ps_codec_evs_Get_EVS_AWB_RAB_subflow(EVS_codec_rate, 3);//EVS_AWB_RAB_subflow[EVS_codec_rate][3];
+ MD_TRC_SPPS_UL_GETSPEECHFRAME_USE_EVS_IO_REPLACE_AWB_LEN(u32bitlen, *bitlen);
+
+ retval = convert_EVSIO_to_AWBEnum(EVSIO_frame_type, frame_type);
+ if(retval == KAL_FALSE) {
+ *frame_type = AMR_NO_DATA;
+ *bitlen = 0;
+ }
+ }
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+void SP4G_PSR_DL_AMR_PutSpeechFrame(kal_uint32 CFN, SP4G_PSR_Codec codec, SP4G_Codec frame_type, kal_bool crc_status, kal_uint8 *encodebits, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ kal_take_enh_mutex( sp_handover_mutex );
+
+ if( (VoLTE_JBM_TS_Info_t *)NULL == JBM_info )
+ {
+ JBM_info = &JBM_info_local;
+ }
+
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ if(spPS_fake_EVS_IO == 0) {
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ sp_ps_codec_amr_DL_PutSpeechFrame(CFN, codec, frame_type, encodebits, crc_status, JBM_info);
+#if defined(__USE_EVS_IO_REPLACE_AWB__)
+ } else {
+ kal_bool retval;
+ SP4G_Codec EVSIO_frame_type;
+
+ //MD_TRC_SPPS_DL_PUTSPEECHFRAME_USE_EVS_IO_REPLACE_AWB();
+
+ retval = convert_AWB_to_EVSIOEnum(frame_type, &EVSIO_frame_type);
+ if(retval == KAL_FALSE) {
+ EVSIO_frame_type = SP4G_CODEC_EVS_AWB_00_00_NODATA;
+ }
+
+ sp_ps_codec_evs_DL_PutSpeechFrame(CFN, EVSIO_frame_type, encodebits, (EVS_DEC_CA_PARAMETER*)NULL, crc_status, JBM_info);
+ }
+#endif //#if defined(__USE_EVS_IO_REPLACE_AWB__)
+
+ kal_give_enh_mutex( sp_handover_mutex );
+}
+
+
+//=====================================
+// Fake 4G llopbck
+//=====================================
+kal_uint32 get_is_fake_4g(void);
+kal_uint32 encodebits_buf[1000];
+kal_uint8 encodebits[128];
+
+SP4G_Codec pscall_loopback_frame_type;
+kal_uint32 pscall_loopback_bitlen;
+kal_uint8 pscall_loopback_uint8_bitlen;
+
+void sp4g_EVS_loopback_ul(void)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ kal_uint8 *encodebits = (kal_uint8 *)encodebits_buf;
+ MD_TRC_SPPS_PSR_EVS_LOOPBACK_UL_1();
+ if( sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode) )
+ {
+ SP4G_PSR_UL_EVS_GetSpeechFrame(&pscall_loopback_frame_type, encodebits, &pscall_loopback_bitlen, (VoLTE_JBM_TS_Info_t *)NULL);
+ {
+ l1sp_emac_resync_info_struct *local_para;
+ local_para = (l1sp_emac_resync_info_struct *) construct_local_para( sizeof(l1sp_emac_resync_info_struct), TD_CTRL );
+ local_para->RX_period = 0;
+ local_para->TX_period = 20;
+ local_para->time2nextRX = 0;
+ local_para->time2nextTX = 7;
+ local_para->issueTime = ust_get_current_time();
+
+ msg_send6(MOD_EMAC, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_VOLTE_MAC_TIMING_INFO, (local_para_struct *)local_para, NULL);
+ }
+ MD_TRC_SPPS_PSR_EVS_LOOPBACK_UL_2(pscall_loopback_frame_type, pscall_loopback_bitlen);
+ }
+#endif //#if 0
+}
+
+void sp4g_EVS_loopback_dl(void)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ kal_uint8 *encodebits = (kal_uint8 *)encodebits_buf;
+ EVS_DEC_CA_PARAMETER EVS_Dec_CA_Par;
+ EVS_DEC_CA_PARAMETER *pEVS_Dec_CA_Par = &EVS_Dec_CA_Par;
+
+ EVS_Dec_CA_Par.FrameMode = FRAMEMODE_NORMAL;
+ MD_TRC_SPPS_PSR_EVS_LOOPBACK_DL_1();
+ if( sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode) )
+ {
+ MD_TRC_SPPS_PSR_EVS_LOOPBACK_DL_2(pscall_loopback_frame_type, pscall_loopback_bitlen);
+ //SP4G_PSR_UL_EVS_GetSpeechFrame(&frame_type, encodebits, &bitlen, (VoLTE_JBM_TS_Info_t *)NULL);
+ if(pscall_loopback_bitlen == 0)
+ {
+ SP4G_PSR_DL_EVS_PutSpeechFrame(0, pscall_loopback_frame_type, NULL, pEVS_Dec_CA_Par, KAL_TRUE, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+ else
+ {
+ SP4G_PSR_DL_EVS_PutSpeechFrame(0, pscall_loopback_frame_type, encodebits, pEVS_Dec_CA_Par, KAL_TRUE, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+ }
+#endif //#if 0
+}
+
+
+void sp4g_EVS_loopback_SetEVSEncCAPara(void)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ EVS_ENC_CA_PARAMETER EVS_CA_Par;
+
+ EVS_CA_Par.enable = 0;
+ EVS_CA_Par.rf_fec_indicator = 0;
+ EVS_CA_Par.rf_fec_offset = 0;
+ EVS_CA_Par.rev3 = 0;
+ EVS_CA_Par.rev4 = 0;
+ EVS_CA_Par.rev5 = 0;
+
+ SP4G_PSR_SetEVSEncCAPara(&EVS_CA_Par);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void sp4g_AMR_NB_loopback_ul(void)
+{
+ SP4G_PSR_UL_AMR_GetSpeechFrame(&pscall_loopback_frame_type, encodebits, &pscall_loopback_uint8_bitlen, (VoLTE_JBM_TS_Info_t *)NULL);
+}
+
+void sp4g_AMR_NB_loopback_dl(void)
+{
+ if( (pscall_loopback_frame_type >= SP4G_CODEC_WBAMR_6_6) && (pscall_loopback_frame_type <= SP4G_CODEC_WBAMR_SID) )
+ {
+ return;
+ }
+
+ if( (pscall_loopback_frame_type==SP4G_CODEC_AMR_NO_DATA) || (pscall_loopback_frame_type==SP4G_CODEC_LOST_FRAME) )
+ {
+ SP4G_PSR_DL_AMR_PutSpeechFrame(0, SP4G_PSR_AMR, pscall_loopback_frame_type, KAL_TRUE, NULL, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+ else
+ {
+ SP4G_PSR_DL_AMR_PutSpeechFrame(0, SP4G_PSR_AMR, pscall_loopback_frame_type, KAL_TRUE, encodebits, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+}
+
+void sp4g_AMR_WB_loopback_ul(void)
+{
+ SP4G_PSR_UL_AMR_GetSpeechFrame(&pscall_loopback_frame_type, encodebits, &pscall_loopback_uint8_bitlen, (VoLTE_JBM_TS_Info_t *)NULL);
+}
+
+void sp4g_AMR_WB_loopback_dl(void)
+{
+ if( pscall_loopback_frame_type <= SP4G_CODEC_AMR_SID )
+ {
+ return;
+ }
+
+ if( (pscall_loopback_frame_type==SP4G_CODEC_AMR_NO_DATA) || (pscall_loopback_frame_type==SP4G_CODEC_LOST_FRAME) )
+ {
+ SP4G_PSR_DL_AMR_PutSpeechFrame(0, SP4G_PSR_WBAMR, pscall_loopback_frame_type, KAL_TRUE, NULL, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+ else
+ {
+ SP4G_PSR_DL_AMR_PutSpeechFrame(0, SP4G_PSR_WBAMR, pscall_loopback_frame_type, KAL_TRUE, encodebits, (VoLTE_JBM_TS_Info_t *)NULL);
+ }
+}
+
+
+void sp4g_G711_loopback(void)
+{
+ SP4G_Codec frame_type;
+ kal_uint8 bitlen;
+
+ while(SP4G_PSR_UL_GSeries_IsMoreData())
+ {
+ MD_TRC_SPPS_PSR_G711_LOOPBACK(0);
+ SP4G_PSR_UL_GSeries_GetSpeechFrame(&frame_type, encodebits, &bitlen);
+ MD_TRC_SPPS_PSR_G711_LOOPBACK(1);
+ SP4G_PSR_DL_GSeries_PutSpeechFrame(frame_type, encodebits, &bitlen);
+ MD_TRC_SPPS_PSR_G711_LOOPBACK(2);
+ }
+}
+
+
+void sp4g_fake_loopback_ul(void)
+{
+ uint8 local_ul_codec_mode = spPS->ul_codec_mode;
+
+ if( get_is_fake_4g() == 0 )
+ {
+ return;
+ }
+
+#ifdef TEST_AAM
+ if(KAL_TRUE == SPPS_is_trigger_mac_notify)
+ {
+ if(0 == test_aam_resync)
+ {
+ SP4G_Set_AAM_Info(40, 20, 30, 5);
+ }
+ else
+ {
+ SP4G_Set_AAM_Info(40, 20, 30, 15);
+ test_aam_resync = 0;
+ }
+ }
+#endif //#ifdef TEST_AAM
+
+ //EVS
+ if( sp_ps_codec_evs_is_EVS_codec(local_ul_codec_mode) )
+ {
+ sp4g_EVS_loopback_ul();
+ }
+ //G series
+ else if( sp_ps_codec_g_is_g_codec(local_ul_codec_mode) )
+ {
+ sp4g_G711_loopback();
+ }
+ //AMR-NB
+ else if( local_ul_codec_mode <= 0xA )
+ {
+ sp4g_AMR_NB_loopback_ul();
+ }
+ //AMR-WB
+ else if( local_ul_codec_mode >= 0x20 )
+ {
+ sp4g_AMR_WB_loopback_dl();
+ }
+}
+
+void sp4g_fake_loopback_dl(void)
+{
+ uint8 local_ul_codec_mode = spPS->ul_codec_mode;
+
+ if( get_is_fake_4g() == 0 )
+ {
+ return;
+ }
+
+#ifdef TEST_AAM
+ if(KAL_TRUE == SPPS_is_trigger_mac_notify)
+ {
+ if(0 == test_aam_resync)
+ {
+ SP4G_Set_AAM_Info(40, 20, 30, 5);
+ }
+ else
+ {
+ SP4G_Set_AAM_Info(40, 20, 30, 15);
+ test_aam_resync = 0;
+ }
+ }
+#endif //#ifdef TEST_AAM
+
+ //EVS
+ if( sp_ps_codec_evs_is_EVS_codec(local_ul_codec_mode) )
+ {
+ sp4g_EVS_loopback_dl();
+ }
+ //G series
+ //else if( sp_ps_codec_g_is_g_codec(local_ul_codec_mode) )
+ //{
+ // sp4g_G711_loopback();
+ //}
+ //AMR-NB
+ else if( local_ul_codec_mode <= 0xA )
+ {
+ sp4g_AMR_NB_loopback_dl();
+ }
+ //AMR-WB
+ else if( local_ul_codec_mode >= 0x20 )
+ {
+ sp4g_AMR_WB_loopback_dl();
+ }
+}
+
+
+
+//#endif // __UMTS_RAT__
+
+
+
+
diff --git a/mcu/driver/audio/src/v1/sp_ps_aam.c b/mcu/driver/audio/src/v1/sp_ps_aam.c
new file mode 100644
index 0000000..0c83ede
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_aam.c
@@ -0,0 +1,1090 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_aam.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AAM
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 07 02 2020 thomas.chen
+ * [MOLY00541641] Fix VoNR AAM bug
+ *
+ * .
+ *
+ * 03 24 2020 thomas.chen
+ * [MOLY00506990] [MT6873][Margaux][Q0][MP2][SQC][Log profiling][MP2 Excluded]LTE Volte Slim filter W02 PS target fail, MOD_L1SP
+ *
+ * .
+ *
+ * 02 26 2020 thomas.chen
+ * [MOLY00501517] [MT6873][Margaux][Q0][MP2][SQC][Log profiling]LTE VoLTE PS Standard filter - W06 target fail - MOD_L1SP
+ *
+ * 02 12 2020 thomas.chen
+ * [MOLY00498636] [MT6873][Margaux][Q0][MP2][SQC][India][Delhi][5GMM][FDD][AIRTEL][RJIO][Auto][Android Linux Script][SST][STATIC][Error Times:1][Fatal error(task)] err_code1:0x00000B31 err_code2:0x900C7442 err_code3:0xCCCCCCCC CaDeFa
+ *
+ * AAM_HISR.
+ *
+ * 01 08 2020 thomas.chen
+ * [MOLY00470340] [MT6873][Margaux][Q0][MP2][SQC][India][Delhi][5GMM][Free Test][MDST][Auto][CAT][Idea][Vodafone][ASSERT] file:mcu/driver/audio/src/v1/sp_ps_aam.c line:293
+ *
+ * .
+ *
+ * 12 04 2019 thomas.chen
+ * [MOLY00457654] AAM for 4/5G L2 Switching
+ *
+ * .
+ *
+ * 09 26 2019 thomas.chen
+ * [MOLY00444115] [Top Issue][Blocking][MT6885][Petrus][SF][EVB][MP1][Sanity][NSA]Assert fail sp_ps_aam.c 381 - MED
+ *
+ * .
+ *
+ * 09 25 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ *
+ * .
+ *
+ * 09 24 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ * .
+ *
+ * 09 28 2018 fu-shing.ju
+ * [MOLY00353395] [MT6297] Modify code for MPD.
+ * VMOLY speech driver
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "sync_data.h"
+
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "media.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "dcl.h"
+#include "drv_sap.h"
+#include "ltecsr_msgid.h"
+#include "audio_msgid.h"
+//for SP_is_codec_mute()
+#include "sp_drv.h"
+
+#include "sal_exp.h"
+
+#include "sp_ps.h"
+#include "sp_ps_aam.h"
+#include "sp_ps_codec_g.h"
+
+
+//for query OP
+#include "ps_public_utility.h"
+
+//AAM related
+#include "l1sp_el2_struct.h"
+#include "el2_msgid.h"
+#include "nl2_msgid.h"
+//#ifndef TK6291_FAKE_COMPILE
+//#include "uas_export_api.h"
+//#include "csr_export_api.h"
+//#endif //#ifndef TK6291_FAKE_COMPILE
+
+
+/*****************************
+Definitions
+*****************************/
+
+
+/*****************************
+Local variables
+*****************************/
+resync_info_t resync_info[2];
+bool SPPS_is_trigger_mac_notify;
+bool SPPS_resync_info_available[2];
+uint32 SPPS_EMACSyncInfoInUse[2];
+bool SPPS_is_ever_aligned;
+uint32 fake_start, fake_RX_period, fake_TX_period, fake_t2nextRX, fake_t2nextTX;
+static kal_uint32 LTE_time_request_resync = 0;
+#ifdef __OP_IS_AT_AND_T__
+Silence_Detection_t stSilenceDetection;
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+
+/*****************************
+External variables
+*****************************/
+extern SPPS_Struct_t *spPS;
+extern kal_spinlockid spinlock_sp4g;
+
+
+/*****************************
+External functions
+*****************************/
+void spPS_reset_flag_set(kal_uint8 val);
+kal_uint8 spPS_reset_flag_get(void);
+SP_PS_RADIO_TYPE spPS_RadioType_get(void);
+
+
+/*****************************
+Local functions
+*****************************/
+
+
+void sp_ps_aam_init(void)
+{
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ SPPS_is_trigger_mac_notify = KAL_FALSE;
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = KAL_FALSE;
+}
+
+
+void sp_ps_aam_speech_init(void)
+{
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_INIT_INFO1(MARGIN_CORESONIC_INIT_TIME+MARGIN_PSR2MAC, DRIFT_DSP2MCU_RESET);
+ SPPS_is_ever_aligned = KAL_FALSE;
+ fake_start = fake_RX_period = fake_TX_period = fake_t2nextRX = fake_t2nextTX = 0xFF;
+ spPS->sph_l2_mode = SP_PSCALL_EMAC;//for loopback mode
+#if defined _SMR_SUPPORT_
+ SAL_AAM_SetPar(SAL_DEALY_2G, SAL_DELAY_NA, SAL_DELAY_NA, SAL_DELAY_NA, SAL_DELAY_NA);
+#endif
+}
+
+void sp_ps_aam_fake_L2_Info(uint32 RX_period, uint32 TX_period, uint32 t2nextRX, uint32 t2nextTX){
+ fake_start = ust_get_current_time();
+ fake_RX_period = RX_period;
+ fake_TX_period = TX_period;
+ fake_t2nextRX = t2nextRX;
+ fake_t2nextTX = t2nextTX;
+ MD_TRC_SP_PS_AAM_FAKE_L2_INFO(fake_RX_period, fake_TX_period, fake_t2nextRX, fake_t2nextTX);
+}
+
+void sp_ps_aam_speech_init_SilenceDetection(void)
+{
+#ifdef __OP_IS_AT_AND_T__
+ stSilenceDetection.UL_count = 0;
+ stSilenceDetection.DL_count = 0;
+ stSilenceDetection.UL_write = 0;
+ stSilenceDetection.DL_write = 0;
+ stSilenceDetection.first_EMAC_info = 1;
+#endif //#ifdef __OP_IS_AT_AND_T__
+}
+
+
+#ifdef __OP_IS_AT_AND_T__
+void Silence_Detection_reset_count(void)
+{
+ stSilenceDetection.UL_count = 0;
+ stSilenceDetection.DL_count = 0;
+}
+
+
+void Silence_Detection_set_ULFrameType(int val)
+{
+ stSilenceDetection.UL_frame_type[stSilenceDetection.UL_write] = val;
+ stSilenceDetection.UL_write++;
+ if( stSilenceDetection.UL_write >= SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER ) {
+ stSilenceDetection.UL_write = 0;
+ }
+ if( stSilenceDetection.UL_count < SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER ) {
+ stSilenceDetection.UL_count++;
+ }
+ //MD_TRC_SILENCE_DETECTION_SET_ULFRAMETYPE(stSilenceDetection.UL_write, stSilenceDetection.UL_count);
+}
+
+
+void Silence_Detection_set_DLFrameType(int val)
+{
+ stSilenceDetection.DL_frame_type[stSilenceDetection.DL_write] = val;
+ stSilenceDetection.DL_write++;
+ if( stSilenceDetection.DL_write >= SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER ) {
+ stSilenceDetection.DL_write = 0;
+ }
+ if( stSilenceDetection.DL_count < SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER ) {
+ stSilenceDetection.DL_count++;
+ }
+ //MD_TRC_SILENCE_DETECTION_SET_DLFRAMETYPE(stSilenceDetection.DL_write, stSilenceDetection.DL_count);
+}
+
+
+int Silence_Detection_get_status(void)
+{
+ int UL_TotalFrameType, UL_OldestFrameType;
+ int DL_TotalFrameType, DL_OldestFrameType;
+ int i;
+
+ if( stSilenceDetection.UL_count < SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER) {
+ MD_TRC_SILENCE_DETECTION_GET_STATUS0();
+ return(0);
+ }
+ if( stSilenceDetection.DL_count < SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER) {
+ MD_TRC_SILENCE_DETECTION_GET_STATUS1();
+ return(0);
+ }
+
+ UL_OldestFrameType = stSilenceDetection.UL_frame_type[stSilenceDetection.UL_write];
+ DL_OldestFrameType = stSilenceDetection.DL_frame_type[stSilenceDetection.DL_write];
+
+ UL_TotalFrameType = 0;
+ DL_TotalFrameType = 0;
+ for(i=0; i<SILENCE_DETECTION_FRAME_TYPE_RECORD_NUMBER; i++) {
+ UL_TotalFrameType += stSilenceDetection.UL_frame_type[i];
+ DL_TotalFrameType += stSilenceDetection.DL_frame_type[i];
+ }
+ MD_TRC_SILENCE_DETECTION_GET_STATUS_INFO(UL_TotalFrameType, DL_TotalFrameType, UL_TotalFrameType, DL_TotalFrameType);
+
+ if( (UL_OldestFrameType == 1) && (UL_TotalFrameType == 1) && (DL_TotalFrameType == 0) ) {
+ MD_TRC_SILENCE_DETECTION_GET_STATUS2();
+ return(1);
+ }
+
+ if( (DL_OldestFrameType == 1) && (DL_TotalFrameType == 1) && (UL_TotalFrameType == 0) ) {
+ MD_TRC_SILENCE_DETECTION_GET_STATUS3();
+ return(1);
+ }
+
+ MD_TRC_SILENCE_DETECTION_GET_STATUS4();
+ return(0);
+}
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+
+void sp_ps_aam_GetSyncDelayRW( kal_uint16 *u16DelayR, kal_uint16 *u16DelayW, kal_uint16 *u16DelayM, kal_uint32 *u32CurTime64us)
+{
+ kal_uint16 offset_AAM;
+ Sal_Delay_Type_t sal_mode = SAL_DEALY_NONE;
+ SP_PSCALL_L2_MODE l2_mode = ((spPS == NULL)? SP_PSCALL_NONE : spPS->sph_l2_mode);
+ *u32CurTime64us = fma_get_glb_ts();
+ ASSERT((SP_PSCALL_EMAC==l2_mode) || (SP_PSCALL_NMAC==l2_mode) || (SP_PSCALL_NONE==l2_mode));
+ switch(l2_mode){
+#if defined(__LTE_RAT__)
+ case SP_PSCALL_EMAC:
+ sal_mode = SAL_DEALY_4G;
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case SP_PSCALL_NMAC:
+ sal_mode = SAL_DEALY_5G;
+ break;
+#endif
+ default:
+ sal_mode = SAL_DEALY_NONE;
+ break;
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ if( (SP_PSCALL_NONE!=l2_mode) && (spPS_reset_flag_get() != 1) && (SPPS_resync_info_available[l2_mode])){
+ uint32 ctime = spPS->time[l2_mode][1] = ust_get_current_time();
+ int32 sal_time2nextSR, sal_time2nextDRX;
+ int32 sal_TXPeriod, sal_RXPeriod;
+ int32 time_emac_to_here ;
+ int32 reserved_offset = 2 ;
+
+ //uint32 align_period_min;
+ MD_TRC_SP_PS_AAM_LTE_GETSYNCDELAYRW_0(spPS->time[l2_mode][0], ctime);
+ if(ctime > spPS->time[l2_mode][0]){
+ time_emac_to_here = (ctime - spPS->time[l2_mode][0])/1000;
+ }else{
+ time_emac_to_here = (USCNT_WRAP - spPS->time[l2_mode][0] + ctime)/1000;
+ }
+
+ MD_TRC_SP_PS_AAM_LTE_GETSYNCDELAYRW_1(l2_mode, ctime, spPS->time2nextSR[l2_mode], spPS->time2nextDRX[l2_mode], spPS->time2nextULHISR[l2_mode], spPS->time2nextDLHISR[l2_mode], resync_info[l2_mode].TX_period, resync_info[l2_mode].RX_period, time_emac_to_here);
+
+ sal_time2nextSR = sal_time2nextDRX = SAL_DELAY_NA;
+ sal_TXPeriod = sal_RXPeriod = 0;
+ if(resync_info[l2_mode].TX_period > 0){
+ //align_period_min = MIN(resync_info[l2_mode].TX_period, 20);
+ sal_time2nextSR = spPS->time2nextSR[l2_mode];
+ //while(time_emac_to_here + reserved_offset > sal_time2nextSR){
+ // sal_time2nextSR += resync_info[l2_mode].TX_period;
+ //}
+ if(time_emac_to_here + reserved_offset > sal_time2nextSR){
+ sal_time2nextSR = time_emac_to_here + reserved_offset + resync_info[l2_mode].TX_period - ((time_emac_to_here + reserved_offset - sal_time2nextSR) % resync_info[l2_mode].TX_period);
+ }
+ sal_time2nextSR -= time_emac_to_here;
+ sal_TXPeriod = resync_info[l2_mode].TX_period;
+ }
+
+ if(resync_info[l2_mode].RX_period > 0){
+ //align_period_min = MIN(resync_info[l2_mode].RX_period, 20);
+ sal_time2nextDRX = spPS->time2nextDRX[l2_mode];
+ //while(time_emac_to_here + reserved_offset > sal_time2nextDRX ){
+ // sal_time2nextDRX += resync_info[l2_mode].RX_period;
+ //}
+ if(time_emac_to_here + reserved_offset > sal_time2nextDRX){
+ sal_time2nextDRX = time_emac_to_here + reserved_offset + resync_info[l2_mode].RX_period - ((time_emac_to_here + reserved_offset - sal_time2nextDRX) % resync_info[l2_mode].RX_period);
+ }
+ sal_time2nextDRX -= time_emac_to_here;
+ sal_RXPeriod = resync_info[l2_mode].RX_period;
+ }
+
+ MD_TRC_SP_PS_AAM_LTE_GETSYNCDELAYRW_2(sal_mode,
+ sal_time2nextSR, sal_TXPeriod,
+ sal_time2nextDRX, sal_RXPeriod);
+
+ SAL_Get_AAM_Offset(sal_mode, sal_time2nextSR, sal_TXPeriod,
+ sal_time2nextDRX, sal_RXPeriod,
+ &offset_AAM);
+
+ SAL_Get_Delay(sal_mode, offset_AAM, SAL_DELAY_NA, u16DelayR, u16DelayW, u16DelayM);
+ MD_TRC_SP_PS_AAM_LTE_GETSYNCDELAYRW_2_1(offset_AAM, *u16DelayR, *u16DelayW,*u16DelayM);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ kal_give_spinlock(spinlock_sp4g);
+ }else
+#endif
+ {
+ MD_TRC_SP_PS_AAM_LTE_GETSYNCDELAYRW_2_2();
+ SAL_Get_Delay(sal_mode, SAL_DELAY_NA, SAL_DELAY_NA, u16DelayR, u16DelayW, u16DelayM);
+ }
+
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_reset_count();
+#endif //#ifdef __OP_IS_AT_AND_T__
+}
+
+
+void SP4G_emac_timing_update(l1sp_emac_volte_timing_info_struct* p_timing_info){
+#if defined(__SP4G_UL_RESYNC__)
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_1_SKIP();
+#endif
+}
+
+
+void sub_SP4G_emac_timing_update(l1sp_emac_resync_info_struct* p_timing_info, module_type module){
+#if defined(__SP4G_UL_RESYNC__)
+ uint32 u32SoftwareCodecDelay = 0;
+ SP_PSCALL_L2_MODE l2_mode;
+ Sal_Delay_Type_t sal_mode;
+ switch(module){
+#if defined(__LTE_RAT__)
+ case MOD_EMAC:
+#ifdef __GEMINI_LTE__
+ case MOD_EMAC_2:
+#if (GEMINI_PLUS_LTE >=3)
+ case MOD_EMAC_3:
+#if (GEMINI_PLUS_LTE >=4)
+ case MOD_EMAC_4:
+#endif /*GEMINI_PLUS_LTE >= 4*/
+#endif /*GEMINI_PLUS_LTE >= 3*/
+#endif /*__GEMINI_LTE__*/
+ l2_mode = SP_PSCALL_EMAC;
+ sal_mode = SAL_DEALY_4G;
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case MOD_NMAC:
+#if MAX_NR_NUM >= 2
+ case MOD_NMAC_2:
+#endif
+#if MAX_NR_NUM >= 3
+ case MOD_NMAC_3:
+#endif
+#if MAX_NR_NUM >= 4
+ case MOD_NMAC_4:
+#endif
+ l2_mode = SP_PSCALL_NMAC;
+ sal_mode = SAL_DEALY_5G;
+ break;
+#endif
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TRUE(0, module, spPS->sph_l2_mode, l2_mode, sal_mode, p_timing_info->RX_period, p_timing_info->TX_period, p_timing_info->time2nextRX, p_timing_info->time2nextTX);
+#ifdef __AAM_AUTO_TEST_SUPPORT__
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_0(fake_start, fake_RX_period, fake_TX_period, fake_t2nextRX, fake_t2nextTX);
+ if(fake_start != 0xFF){
+ uint32 fake_offset = 0;
+ if(p_timing_info->issueTime > fake_start){
+ fake_offset = (p_timing_info->issueTime - fake_start)/1000;
+ }else{
+ fake_offset = ((USCNT_WRAP - (fake_start) - (p_timing_info->issueTime)))/1000;
+ }
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_1(fake_offset, p_timing_info->issueTime, fake_start);
+ p_timing_info->TX_period = fake_TX_period;
+ if(fake_TX_period != 0){
+ uint32 tx_fake_offset = fake_offset % fake_TX_period;
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_2(tx_fake_offset, fake_offset, fake_t2nextTX);
+ if(fake_t2nextTX > tx_fake_offset){
+ p_timing_info->time2nextTX = fake_t2nextTX - tx_fake_offset;
+ }else{
+ p_timing_info->time2nextTX = fake_t2nextTX - tx_fake_offset + fake_TX_period;
+ }
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_3(p_timing_info->time2nextTX);
+ }else{
+ p_timing_info->time2nextTX = 0;
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_4(p_timing_info->time2nextTX);
+ }
+
+ p_timing_info->RX_period = fake_RX_period;
+ if(fake_RX_period != 0){
+ uint32 rx_fake_offset = fake_offset % fake_RX_period;
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_5(rx_fake_offset, fake_offset, fake_t2nextRX);
+ if(fake_t2nextRX > rx_fake_offset){
+ p_timing_info->time2nextRX = fake_t2nextRX - rx_fake_offset;
+ }else{
+ p_timing_info->time2nextRX = fake_t2nextRX - rx_fake_offset + fake_RX_period;
+ }
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_6(p_timing_info->time2nextRX);
+ }else{
+ p_timing_info->time2nextRX = 0;
+ MD_TRC_SP_PS_AAM_LTE_EMAC_FAKE_7(p_timing_info->time2nextRX);
+ }
+ }
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TRUE(1, p_timing_info->RX_period, p_timing_info->TX_period, p_timing_info->time2nextRX, p_timing_info->time2nextTX);
+#endif
+
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON)
+ {
+
+ if( KAL_TRUE == SPPS_is_trigger_mac_notify )
+ {
+ SPPS_is_trigger_mac_notify = KAL_FALSE;
+ //SPPS_is_ever_aligned = KAL_FALSE;
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = KAL_FALSE;
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ kal_give_spinlock(spinlock_sp4g);
+#ifndef TK6291_FAKE_COMPILE
+#if defined(__LTE_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_EMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_EMAC_VOLTE_TIMING_INFO_REQ,
+ 0,
+ 0);
+#endif
+#if defined(__NR_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_NMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_NMAC_VONR_TIMING_INFO_REQ,
+ 0,
+ 0);
+#endif
+#endif //#ifndef TK6291_FAKE_COMPILE
+ MD_TRC_SP_PS_AAM_LTE_EMAC_VOLTE_CALLOFF();
+ }
+ else
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ }
+
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*)0);
+ ASSERT((SP_PSCALL_EMAC == l2_mode) || (SP_PSCALL_NMAC == l2_mode));
+ if(SPPS_is_trigger_mac_notify == false)
+ {
+
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = false;
+
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO5(SPPS_is_trigger_mac_notify);
+ return;
+ }
+
+ if(SPPS_EMACSyncInfoInUse[l2_mode] == 1)
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_RETURN(l2_mode);
+ return;
+ }
+ else
+ {
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = false;
+ if( !(((p_timing_info->TX_period == 0) || (p_timing_info->TX_period == 5) || (p_timing_info->TX_period == 10) || (p_timing_info->TX_period == 20) || (p_timing_info->TX_period == 40) || (p_timing_info->TX_period == 80))) ||
+ !(((p_timing_info->RX_period == 0) || (p_timing_info->RX_period == 5) || (p_timing_info->RX_period == 10) || (p_timing_info->RX_period == 20) || (p_timing_info->RX_period == 40) || (p_timing_info->RX_period == 80))) )
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO6(0, p_timing_info->TX_period, p_timing_info->time2nextTX, p_timing_info->RX_period, p_timing_info->time2nextRX);
+ return;
+ }
+
+ if( ((p_timing_info->TX_period == 0)&&(p_timing_info->RX_period == 0)) ||
+ (p_timing_info->time2nextTX > p_timing_info->TX_period) ||
+ (p_timing_info->time2nextRX > p_timing_info->RX_period))
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO6(2, p_timing_info->TX_period, p_timing_info->time2nextTX, p_timing_info->RX_period, p_timing_info->time2nextRX);
+ return;
+ }
+
+ SPPS_EMACSyncInfoInUse[l2_mode] = 1;
+ spPS->time[l2_mode][0] = p_timing_info->issueTime;
+ }
+ //MD_TRC_SP_PS_AAM_LTE_EMAC_TRUE(2, p_timing_info->RX_period, p_timing_info->TX_period, p_timing_info->time2nextRX, p_timing_info->time2nextTX);
+
+ resync_info[l2_mode].RX_period = p_timing_info->RX_period;
+ resync_info[l2_mode].TX_period = p_timing_info->TX_period;
+ resync_info[l2_mode].time2nextRX = p_timing_info->time2nextRX;
+ resync_info[l2_mode].time2nextTX = p_timing_info->time2nextTX;
+
+ resync_info[l2_mode].issueTime = p_timing_info->issueTime;
+ resync_info[l2_mode].is_lch_on = p_timing_info->is_lch_on_for_voice;
+
+ SAL_Get_AAM_Margin(sal_mode, resync_info[l2_mode].time2nextTX, resync_info[l2_mode].TX_period,
+ resync_info[l2_mode].time2nextRX, resync_info[l2_mode].RX_period,
+ &spPS->margin_AAM_ul, &spPS->margin_AAM_dl);
+
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO1(
+ resync_info[0].TX_period, resync_info[0].RX_period,
+ resync_info[0].time2nextTX, resync_info[0].time2nextRX, resync_info[0].issueTime,
+ resync_info[1].TX_period, resync_info[1].RX_period,
+ resync_info[1].time2nextTX, resync_info[1].time2nextRX, resync_info[1].issueTime,
+ sal_mode, spPS->margin_AAM_ul, spPS->margin_AAM_dl);
+ if((spPS->margin_AAM_ul > 0)&&(spPS->margin_AAM_ul < SAL_DELAY_NA)){
+ spPS->margin_AAM_dl = SAL_DELAY_NA;
+ }
+
+ ASSERT(!((spPS->margin_AAM_ul!=SAL_DELAY_NA) && (spPS->margin_AAM_dl!=SAL_DELAY_NA)));
+ if(sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ {
+ switch(spPS->ul_codec_mode)
+ {
+ case SP4G_CODEC_G711:
+ case SP4G_CODEC_G722:
+ case SP4G_CODEC_G723_1:
+ case SP4G_CODEC_G726:
+ case SP4G_CODEC_G729:
+ u32SoftwareCodecDelay = 0;
+ break;
+ default:
+ u32SoftwareCodecDelay = 0;
+ break;
+ }
+ }
+ else
+ {
+ u32SoftwareCodecDelay = 0;
+ }
+
+ {
+ uint32 period;
+ period = resync_info[l2_mode].TX_period;
+ if(0 == period || SAL_DELAY_NA == spPS->margin_AAM_ul){
+ spPS->time2nextSR[l2_mode] = 0;
+ spPS->time2nextULHISR[l2_mode] = 0;
+ }else{
+ spPS->time2nextSR[l2_mode] = resync_info[l2_mode].time2nextTX;
+ spPS->time2nextULHISR[l2_mode] = resync_info[l2_mode].time2nextTX - spPS->margin_AAM_ul - u32SoftwareCodecDelay;
+ while(spPS->time2nextULHISR[l2_mode] < 0){
+ spPS->time2nextULHISR[l2_mode] += period;
+ }
+ }
+ period = resync_info[l2_mode].RX_period;
+ if(0 == period || SAL_DELAY_NA == spPS->margin_AAM_dl){
+ spPS->time2nextDRX[l2_mode] = 0;
+ spPS->time2nextDLHISR[l2_mode] = 0;
+ }else{
+ spPS->time2nextDRX[l2_mode] = resync_info[l2_mode].time2nextRX;
+ spPS->time2nextDLHISR[l2_mode] = resync_info[l2_mode].time2nextRX - spPS->margin_AAM_dl - u32SoftwareCodecDelay;
+ while(spPS->time2nextDLHISR[l2_mode] < 0){
+ spPS->time2nextDLHISR[l2_mode] += period;
+ }
+ }
+ }
+ ASSERT(!(spPS->time2nextULHISR[l2_mode]>0 && spPS->time2nextDLHISR[l2_mode]>0));
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO3(spPS->time2nextSR[l2_mode], spPS->time2nextDRX[l2_mode], spPS->time2nextULHISR[l2_mode], spPS->time2nextDLHISR[l2_mode],
+ spPS->sph_l2_mode, resync_info[SP_PSCALL_EMAC].is_lch_on, resync_info[SP_PSCALL_NMAC].is_lch_on);
+
+ if(resync_info[SP_PSCALL_EMAC].is_lch_on && resync_info[SP_PSCALL_NMAC].is_lch_on){//Don't change
+ spPS->sph_l2_mode = SP_PSCALL_NONE;;
+ }else{
+ if(resync_info[SP_PSCALL_EMAC].is_lch_on){
+ spPS->sph_l2_mode = SP_PSCALL_EMAC;
+ } else if(resync_info[SP_PSCALL_NMAC].is_lch_on){
+ spPS->sph_l2_mode = SP_PSCALL_NMAC;
+ } else {
+ spPS->sph_l2_mode = SP_PSCALL_NONE;
+ }
+ }
+ MD_TRC_SP_PS_AAM_LTE_EMAC_TIMING_UPDATE_INFO4_2(spPS->sph_l2_mode);
+ //TODO, when SR period is not 1 2 5 10 20 40 80=>we can not do sync!!!
+ if(SP_PSCALL_NONE != spPS->sph_l2_mode){
+ SPPS_resync_info_available[spPS->sph_l2_mode] = true;
+ }else{
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = KAL_FALSE;
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ }
+
+ kal_give_spinlock(spinlock_sp4g);
+ // reading this only in ul_hisr is safety for race condition
+#endif
+}
+
+
+
+SP_PS_AAM_STATE sp_ps_aam_check_status_NR(void)
+{
+ return(SP_PS_AAM_STATE_NONE);
+}
+
+
+void sp_ps_aam_execute_LTE_On(void)
+{
+ MD_TRC_SP_PS_AAM_EXECUTE_LTE_ON();
+#ifndef TK6291_FAKE_COMPILE
+#ifdef __OP_IS_AT_AND_T__
+ stSilenceDetection.first_EMAC_info = 1;
+#endif //#ifdef __OP_IS_AT_AND_T__
+#if defined(__LTE_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_EMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_EMAC_VOLTE_TIMING_INFO_REQ,
+ 20/*report_period*/,
+ 0);
+#endif
+#if defined(__NR_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_NMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_NMAC_VONR_TIMING_INFO_REQ,
+ 20/*report_period*/,
+ 0);
+#endif
+#endif //#ifndef TK6291_FAKE_COMPILE
+ SPPS_is_trigger_mac_notify = KAL_TRUE;
+ //SPPS_is_ever_aligned = KAL_FALSE;
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = KAL_FALSE;
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+}
+
+
+void sp_ps_aam_execute_LTE_Off(void)
+{
+ MD_TRC_SP_PS_AAM_EXECUTE_LTE_OFF();
+#ifndef TK6291_FAKE_COMPILE
+#if defined(__LTE_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_EMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_EMAC_VOLTE_TIMING_INFO_REQ,
+ 0,
+ 0);
+#endif
+#if defined(__NR_RAT__)
+ msg_send_8bytes_inline6(MOD_MED,
+ MOD_NMAC,
+ AUDIO_SAP,
+ MSG_ID_MED_NMAC_VONR_TIMING_INFO_REQ,
+ 0,
+ 0);
+#endif
+#endif //#ifndef TK6291_FAKE_COMPILE
+ SPPS_is_trigger_mac_notify = KAL_FALSE;
+ //SPPS_is_ever_aligned = KAL_FALSE;
+ SPPS_resync_info_available[0] = SPPS_resync_info_available[1] = KAL_FALSE;
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+}
+
+
+void sp_ps_aam_execute_LTE_Resync(void)
+{
+ spPS_reset_flag_set(1);
+ LTE_time_request_resync = ust_get_current_time();//ctime;
+ spPS->request_resync = KAL_TRUE;
+ MD_TRC_SP_PS_AAM_EXECUTE_LTE_RESYNC();
+ //SPPS_is_ever_aligned = KAL_FALSE;
+}
+
+
+
+SP_PS_AAM_STATE sp_ps_aam_check_status_LTE(void)
+{
+#if defined(__SP4G_UL_RESYNC__)
+ SP_PSCALL_L2_MODE l2_mode = ((spPS == NULL)? SP_PSCALL_NONE : spPS->sph_l2_mode);
+ SP_PS_AAM_STATE ret = SP_PS_AAM_STATE_NONE;
+ ASSERT(!SAL_AAM_CheckReset());
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_0_INFO(
+ SPPS_is_trigger_mac_notify,
+ SP_is_codec_mute(), SPPS_resync_info_available[0], SPPS_resync_info_available[1], l2_mode
+ );
+ switch(l2_mode){
+#if defined(__LTE_RAT__)
+ case SP_PSCALL_EMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_LTE);
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case SP_PSCALL_NMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NR);
+ break;
+#endif
+ case SP_PSCALL_NONE:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NONE);
+ break;
+// default:
+// ASSERT(0);
+// break;
+ }
+ if(!SPPS_is_trigger_mac_notify && !SP_is_codec_mute()){
+ return SP_PS_AAM_STATE_LTE_EMAC_ON;
+ }else if(SPPS_is_trigger_mac_notify && SP_is_codec_mute()){
+ return SP_PS_AAM_STATE_LTE_EMAC_OFF;
+ }
+
+ if( (SP_PSCALL_NONE != l2_mode) && (SPPS_resync_info_available[l2_mode]) && (SPPS_is_trigger_mac_notify) ){
+ //static kal_uint32 LTE_time_request_resync = 0;
+ uint32 ctime = spPS->time[l2_mode][2] = ust_get_current_time();
+ uint32 time_emac_2_aamhisr;// = ust_get_duration_true( ctime, spPS->time[0] ) / 1000;
+ uint32 time_2_nextHISR;// = ust_get_duration_true( ctime, spPS->time[0] ) / 1000;
+ uint32 time_diff_request_resync = 0;
+ uint32 diff, diff_mod, diff_mod_2;
+ uint32 align_period_min;//MIN(resync_info.TX_period, 20);
+
+ //ASSERT(0 != resync_info[l2_mode].time2nextTX && 0 != resync_info[l2_mode].time2nextRX);
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_0_1_INFO(spPS->time[l2_mode][0], ctime);
+ if(ctime > spPS->time[l2_mode][0]){
+ time_emac_2_aamhisr = (ctime - spPS->time[l2_mode][0])/1000;
+ }else{
+ time_emac_2_aamhisr = ((USCNT_WRAP - (spPS->time[l2_mode][0]) - (ctime)))/1000;
+ }
+
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_1_INFO(spPS->time2nextSR[l2_mode], spPS->time2nextDRX[l2_mode], spPS->time2nextULHISR[l2_mode], spPS->time2nextDLHISR[l2_mode]);
+
+ ASSERT(!(spPS->time2nextULHISR[l2_mode]>0 && spPS->time2nextDLHISR[l2_mode]>0));
+ if(spPS->time2nextULHISR[l2_mode] > 0){
+ time_2_nextHISR = spPS->time2nextULHISR[l2_mode];
+ align_period_min = MIN(resync_info[l2_mode].TX_period, 20);
+ }else if(spPS->time2nextDLHISR[l2_mode] > 0){
+ time_2_nextHISR = spPS->time2nextDLHISR[l2_mode];
+ align_period_min = MIN(resync_info[l2_mode].RX_period, 20);
+ }else {
+ time_2_nextHISR = 0;
+ align_period_min = 0;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_1_1_INFO();
+ }
+
+ if(align_period_min > 0){
+ diff = (time_emac_2_aamhisr > time_2_nextHISR ) ? (time_emac_2_aamhisr - time_2_nextHISR) : (time_2_nextHISR - time_emac_2_aamhisr);
+ diff_mod = diff % align_period_min;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_2_INFO(
+ time_emac_2_aamhisr, time_2_nextHISR);
+ diff_mod_2 = (align_period_min - diff_mod) % align_period_min;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_2_1_INFO(
+ diff, diff_mod, diff_mod_2, align_period_min);
+
+ diff_mod = diff_mod < diff_mod_2 ? diff_mod : diff_mod_2;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_2_2_INFO(
+ diff_mod, DRIFT_DSP2MCU_RESET);
+
+ if(ctime > LTE_time_request_resync){
+ time_diff_request_resync = ( ctime - LTE_time_request_resync ) / 1000;
+ } else {
+ time_diff_request_resync = ( USCNT_WRAP - ctime + LTE_time_request_resync) / 1000;
+ }
+
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_3(
+ LTE_time_request_resync, ctime, time_diff_request_resync, spPS->request_resync);
+ }else{
+ diff_mod = 0;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_5_2(0);
+ }
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_4(
+ diff_mod > DRIFT_DSP2MCU_RESET,(spPS->request_resync == KAL_FALSE),
+ (time_diff_request_resync > 200));
+ if((diff_mod > DRIFT_DSP2MCU_RESET) &&
+ (spPS->request_resync == KAL_FALSE) &&
+ (time_diff_request_resync > 200)){
+#ifdef __AAM_AUTO_TEST_SUPPORT__
+ void clear_aam_resync_test_flag();
+#endif
+ ret = SP_PS_AAM_STATE_LTE_RESYNC;
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_5_1(0);
+#ifdef __AAM_AUTO_TEST_SUPPORT__
+ clear_aam_resync_test_flag();
+#endif
+ } else {
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ if((align_period_min > 0) && (diff_mod <= DRIFT_DSP2MCU_RESET)){
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_5_3();
+ SPPS_is_ever_aligned = KAL_TRUE;
+ }
+ MD_TRC_SP_PS_AAM_CHECK_STATUS_LTE_5_2(1);
+ //log
+ }
+#ifdef __OP_IS_AT_AND_T__
+ stSilenceDetection.first_EMAC_info = 0;
+#endif //#ifdef __OP_IS_AT_AND_T__
+ }
+#endif
+
+/*************
+ Should modify!!!!!!!!!!!!!!!!!!!!!!!!!
+**************/
+ return(ret);
+}
+
+
+void sp_ps_aam_execute(SP_PS_AAM_STATE aam_state)
+{
+ switch(aam_state)
+ {
+ case SP_PS_AAM_STATE_NONE:
+ break;
+ case SP_PS_AAM_STATE_LTE_EMAC_ON:
+ sp_ps_aam_execute_LTE_On();
+ break;
+ case SP_PS_AAM_STATE_LTE_EMAC_OFF:
+ sp_ps_aam_execute_LTE_Off();
+ break;
+ case SP_PS_AAM_STATE_LTE_RESYNC:
+ sp_ps_aam_execute_LTE_Resync();
+ break;
+ case SP_PS_AAM_STATE_NR_EMAC_ON:
+ case SP_PS_AAM_STATE_NR_EMAC_OFF:
+ case SP_PS_AAM_STATE_NR_RESYNC:
+ default :
+ ASSERT(0);
+ break;
+ }
+}
+
+SP_PS_AAM_STATE sp_ps_smr_check_status(void)
+{
+ SP_PSCALL_L2_MODE l2_mode = ((spPS == NULL)? SP_PSCALL_NONE : spPS->sph_l2_mode);
+ Sal_Delay_Type_t sal_mode;
+ SP_PS_AAM_STATE ret = SP_PS_AAM_STATE_NONE;
+ switch(l2_mode){
+#if defined(__LTE_RAT__)
+ case SP_PSCALL_EMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_LTE);
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case SP_PSCALL_NMAC:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NR);
+ break;
+#endif
+ case SP_PSCALL_NONE:
+ SAL_Set_PSRANType(SAL_PSRAN_TYPE_NONE);
+ break;
+ }
+ if(!SPPS_is_trigger_mac_notify && !SP_is_codec_mute()){
+ ret = SP_PS_AAM_STATE_LTE_EMAC_ON;
+ }else if(SPPS_is_trigger_mac_notify && SP_is_codec_mute()){
+ ret = SP_PS_AAM_STATE_LTE_EMAC_OFF;
+ }
+ switch(l2_mode){
+#if defined(__LTE_RAT__)
+ case SP_PSCALL_EMAC:
+ sal_mode = SAL_DEALY_4G;
+ break;
+#endif
+#if defined(__NR_RAT__)
+ case SP_PSCALL_NMAC:
+ sal_mode = SAL_DEALY_5G;
+ break;
+#endif
+ default:
+ sal_mode = SAL_DEALY_NONE;
+ break;
+ }
+ if( (SP_PSCALL_NONE != l2_mode) && (SPPS_resync_info_available[l2_mode]) && (SPPS_is_trigger_mac_notify) ){
+//#if defined(__SMR_SUPPORT__)
+ if(SAL_AAM_CheckReset()){
+ //reset DSP
+ /*uint32 ctime = ust_get_current_time();
+ uint32 time_diff_request_resync = 0;
+ if(ctime > LTE_time_request_resync){
+ time_diff_request_resync = ( ctime - LTE_time_request_resync ) / 1000;
+ } else {
+ time_diff_request_resync = ( USCNT_WRAP - ctime + LTE_time_request_resync) / 1000;
+ }*/
+
+ MD_TRC_SP_PS_AAM_SMR_STATUS_3(spPS->request_resync);
+ if((spPS->request_resync == KAL_FALSE)){
+ ret = SP_PS_AAM_STATE_LTE_RESYNC;
+ MD_TRC_SP_PS_AAM_SMR_STATUS_3_1();
+ }
+ }else{
+ uint32 ctime = spPS->time[l2_mode][1] = ust_get_current_time();
+ int32 sal_time2nextSR, sal_time2nextDRX;
+ int32 sal_TXPeriod, sal_RXPeriod;
+ int32 time_emac_to_here ;
+ int32 reserved_offset = 2 ;
+
+ //uint32 align_period_min;
+ if(ctime > spPS->time[l2_mode][0]){
+ time_emac_to_here = (ctime - spPS->time[l2_mode][0])/1000;
+ }else{
+ time_emac_to_here = (USCNT_WRAP - spPS->time[l2_mode][0] + ctime)/1000;
+ }
+
+ MD_TRC_SP_PS_AAM_SMR_STATUS_1( SPPS_is_trigger_mac_notify,
+ SP_is_codec_mute(), SPPS_resync_info_available[0], SPPS_resync_info_available[1],
+ l2_mode, spPS->time[l2_mode][0],
+ ctime, spPS->time2nextSR[l2_mode], spPS->time2nextDRX[l2_mode],
+ spPS->time2nextULHISR[l2_mode], spPS->time2nextDLHISR[l2_mode],
+ resync_info[l2_mode].TX_period, resync_info[l2_mode].RX_period, time_emac_to_here);
+
+ sal_time2nextSR = sal_time2nextDRX = SAL_DELAY_NA;
+ sal_TXPeriod = sal_RXPeriod = 0;
+ if(resync_info[l2_mode].TX_period > 0){
+ //align_period_min = MIN(resync_info[l2_mode].TX_period, 20);
+ sal_time2nextSR = spPS->time2nextSR[l2_mode];
+ if(time_emac_to_here + reserved_offset > sal_time2nextSR){
+ sal_time2nextSR = time_emac_to_here + reserved_offset + resync_info[l2_mode].TX_period - ((time_emac_to_here + reserved_offset - sal_time2nextSR) % resync_info[l2_mode].TX_period);
+ }
+ //while(time_emac_to_here + reserved_offset > sal_time2nextSR){
+ // sal_time2nextSR += resync_info[l2_mode].TX_period;
+ //}
+ sal_time2nextSR -= time_emac_to_here;
+ sal_TXPeriod = resync_info[l2_mode].TX_period;
+ }
+
+ if(resync_info[l2_mode].RX_period > 0){
+ //align_period_min = MIN(resync_info[l2_mode].RX_period, 20);
+ sal_time2nextDRX = spPS->time2nextDRX[l2_mode];
+ if(time_emac_to_here + reserved_offset > sal_time2nextDRX){
+ sal_time2nextDRX = time_emac_to_here + reserved_offset + resync_info[l2_mode].RX_period - ((time_emac_to_here + reserved_offset - sal_time2nextDRX) % resync_info[l2_mode].RX_period);
+ }
+ //while(time_emac_to_here + reserved_offset > sal_time2nextDRX ){
+ // sal_time2nextDRX += resync_info[l2_mode].RX_period;
+ //}
+ sal_time2nextDRX -= time_emac_to_here;
+ sal_RXPeriod = resync_info[l2_mode].RX_period;
+ }
+
+ //MD_TRC_SP_PS_AAM_SMR_STATUS_2(sal_mode,
+ // sal_time2nextSR, sal_TXPeriod,
+ // sal_time2nextDRX, sal_RXPeriod);
+
+ SAL_AAM_SetPar(sal_mode, sal_time2nextSR, sal_TXPeriod, sal_time2nextDRX, sal_RXPeriod);
+
+ SPPS_EMACSyncInfoInUse[0] = SPPS_EMACSyncInfoInUse[1] = 0;
+ }
+//#endif
+ } else {
+ MD_TRC_SP_PS_AAM_SMR_STATUS_2_2(SPPS_is_trigger_mac_notify,
+ SP_is_codec_mute(), SPPS_resync_info_available[0], SPPS_resync_info_available[1], l2_mode);
+ SAL_AAM_SetPar(sal_mode, SAL_DELAY_NA, SAL_DELAY_NA, SAL_DELAY_NA, SAL_DELAY_NA);
+ }
+ return(ret);
+}
+
+
+SP_PS_AAM_STATE sp_ps_aam_check_status(void)
+{
+ SP_PS_AAM_STATE ret_val = SP_PS_AAM_STATE_NONE;
+
+#if defined(__SP4G_UL_RESYNC__)
+ switch( spPS_RadioType_get() )
+ {
+ case SP_PS_RADIO_TYPE_LTE:
+ case SP_PS_RADIO_TYPE_NR:
+ ret_val = sp_ps_aam_check_status_LTE();
+ break;
+ case SP_PS_RADIO_TYPE_WIFI:
+ case SP_PS_RADIO_TYPE_UNKNOWN:
+ default :
+ ret_val = SP_PS_AAM_STATE_NONE;
+ break;
+ }
+#endif //#if defined(__SP4G_UL_RESYNC__)
+
+ return(ret_val);
+}
+
+void sp_ps_AAM_hisr(void *data)
+{
+#if defined(__SP4G_UL_RESYNC__)
+ SP_PS_AAM_STATE aam_result;
+#endif
+
+ msg_send4( MOD_L1SP, /* source module id */
+ MOD_LTECSR, /* destination module id */
+ L1SP_LTECSR_SAP, /* sap id */
+ MSG_ID_LTECSR_AV_SYNC_NOTIFY /* message id */
+ );
+
+#if defined(__SP4G_UL_RESYNC__)
+ MD_TRC_SP_PS_AAM_HISR_1(SPPS_is_ever_aligned);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+#if defined _SMR_SUPPORT_
+ if(!SPPS_is_ever_aligned){
+#else
+ if(1){
+#endif
+ aam_result = sp_ps_aam_check_status();
+ } else {
+ aam_result = sp_ps_smr_check_status();
+ }
+ MD_TRC_SP_PS_AAM_HISR_1(SPPS_is_ever_aligned, aam_result);
+ if( (SP_PS_AAM_STATE_LTE_EMAC_ON == aam_result) || ((SP_PS_AAM_STATE_LTE_EMAC_OFF == aam_result)) )
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ sp_ps_aam_execute(aam_result);
+ }
+ else
+ {
+ sp_ps_aam_execute(aam_result);
+ kal_give_spinlock(spinlock_sp4g);
+ }
+#endif //#if defined(__SP4G_UL_RESYNC__)
+}
diff --git a/mcu/driver/audio/src/v1/sp_ps_aamp.c b/mcu/driver/audio/src/v1/sp_ps_aamp.c
new file mode 100644
index 0000000..f1a54f6
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_aamp.c
@@ -0,0 +1,152 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_aamp.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AAM Plus
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_public_defs.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "l1sp_trc.h"
+
+#include "sal_exp.h"
+#include "sal_def.h"
+
+#include "sp_ps_aamp.h"
+#include "l1sp_el2_struct.h"
+#include "audio_msgid.h"
+#include "drv_sap.h"
+#include "us_timer.h"
+#include "dcl.h"
+
+
+void sp_ps_AAMPlus_enable(void)
+{
+#ifdef __SP_PS_AAM_PLUS__
+ MD_TRC_SP_PS_AAMPLUS_ENABLE();
+ SAL_AAMPlus_Switch(KAL_TRUE);
+#endif //#ifdef __SP_PS_AAM_PLUS__
+}
+
+
+void sp_ps_AAMPlus_disable(void)
+{
+#ifdef __SP_PS_AAM_PLUS__
+ MD_TRC_SP_PS_AAMPLUS_DISABLE();
+ SAL_AAMPlus_Switch(KAL_FALSE);
+#endif //#ifdef __SP_PS_AAM_PLUS__
+}
+
+
+void sp_ps_AAMPlus_notify_EMAC(void *data)
+{
+#ifdef __SP_PS_AAM_PLUS__
+ l1sp_emac_volte_notify_mode_change_struct *local_para;
+
+ local_para = (l1sp_emac_volte_notify_mode_change_struct *) construct_local_para( sizeof(l1sp_emac_volte_notify_mode_change_struct), TD_CTRL/*TD_RESET*/ );
+ local_para->issue_time = ust_get_current_time();
+
+ //Should modify for different Chip and Codec!!!
+ local_para->notify_to_data_ms = SAL_AAMPlus_Get_Period();
+
+ Sal_AAMPlus_State_t AAMPlus_status = SAL_AAMPlus_Get_Enc_State();
+ switch(AAMPlus_status)
+ {
+ case SAL_AAMPLUS_STA_SILENCE_SID_FIRST:
+ local_para->silence_talk = SP4G_AAMPLUS_STA_SID_FIRST;
+ MD_TRC_SP_PS_AAMPLUS_SILENCE_SID_FIRST();
+ break;
+ case SAL_AAMPLUS_STA_SILENCE_SID_UPDATE:
+ local_para->silence_talk = SP4G_AAMPLUS_STA_SILENCE;
+ MD_TRC_SP_PS_AAMPLUS_SILENCE_SID_UPDATE();
+ break;
+ case SAL_AAMPLUS_STA_TALK:
+ default:
+ local_para->silence_talk = SP4G_AAMPLUS_STA_TALK;
+ MD_TRC_SP_PS_AAMPLUS_TALK();
+ break;
+ }
+
+ //send ILM to EMAC
+ msg_send6(MOD_MED, MOD_EMAC, AUDIO_SAP, MSG_ID_L1SP_EMAC_VOLTE_NOTIFY_MODE_CHANGE, (local_para_struct *)local_para, NULL);
+#endif //#ifdef __SP_PS_AAM_PLUS__
+}
+
diff --git a/mcu/driver/audio/src/v1/sp_ps_codec_amr.c b/mcu/driver/audio/src/v1/sp_ps_codec_amr.c
new file mode 100644
index 0000000..b2f1d1a
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_codec_amr.c
@@ -0,0 +1,1524 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_amr.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching AMR speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "sync_data.h"
+
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "media.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "dcl.h"
+#include "drv_sap.h"
+#include "ltecsr_msgid.h"
+#include "audio_msgid.h"
+//for SP_is_codec_mute()
+#include "sp_drv.h"
+
+#include "sal_exp.h"
+
+#include "sp_ps.h"
+#include "sp_ps_aam.h"
+#include "sp_ps_codec_amr.h"
+#include "sp_ps_codec_evs.h"
+#include "sp_ps_codec_g.h"
+
+
+/*****************************
+Definitions
+*****************************/
+
+
+/*****************************
+External variables
+*****************************/
+extern SPPS_Struct_t *spPS;
+extern kal_spinlockid spinlock_sp4g;
+
+
+/*****************************
+External functions
+*****************************/
+void spPS_reset_flag_set(kal_uint8 val);
+kal_uint8 spPS_reset_flag_get(void);
+kal_bool spPS_Rab_State_get(void);
+kal_uint32 get_is_fake_4g(void);
+void sp_ps_reset_internal(void);
+
+
+
+/*****************************
+Local variables
+*****************************/
+static const uint8 last_sub_flow_id[26] = { 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1};
+
+const uint16 RAB_subflow_spps[][4] = {
+ {42, 53, 0, 13}, // 4.75
+ {49, 54, 0, 14}, // 5.15
+ {55, 63, 0, 15}, // 5.9
+ {58, 76, 0, 18}, // 6.7
+ {61, 87, 0, 19}, // 7.4
+ {75, 84, 0, 21}, // 7.95
+ {65, 99, 40, 27}, // 10.2
+ {81, 103,60, 32}, // 12.2
+ {39, 0, 0, 5}, // SID
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // dummy
+ {39, 0, 0, 5}, // For Future use
+ {8, 0, 0, 0}, // AMR NoData
+/* TS26.201, Table 7 */
+ {54, 78, 0, 17},/* WB type 0, AMR-WB 6.60 */
+ {64, 113, 0, 23},/* WB type 1, AMR-WB 8.85 */
+ {72, 181, 0, 32},/* WB type 2, AMR-WB 12.65 */
+ {72, 213, 0, 36},/* WB type 3, AMR-WB 14.25 */
+ {72, 245, 0, 40},/* WB type 4, AMR-WB 15.85 */
+ {72, 293, 0, 46},/* WB type 5, AMR-WB 18.25 */
+ {72, 325, 0, 50},/* WB type 6, AMR-WB 19.85 */
+ {72, 389, 0, 58},/* WB type 7, AMR-WB 23.05 */
+ {72, 405, 0, 60},/* WB type 8, AMR-WB 23.85 */
+ {40, 0, 0, 5}/* WB type 9, AMR-WB SID */
+/* WB type 10-13, Not Used */
+};
+
+const uint8 RAB_Order_spps[8] = {
+ 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 /* bits order of AMR frame */
+};
+
+const uint16 DSP_Order_spps[16] = {
+ 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, /* bits order of SHERIF */
+ 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
+};
+
+const uint8 AmrFrameType2DspMode_spps[25] = {0x0A, 0x09, 0x08, 0x07, 0x06,
+ 0x05, 0x04, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x21, 0x22, 0x23,
+ 0x24, 0x25, 0x26, 0x27, 0x28};
+
+ //** From {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00};
+ //** mapping to
+const uint8 NB_DspMode2AmrFrameType_spps[17] = {0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+
+ //** From {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28};
+ //** mapping to
+const uint8 WB_DspMode2AmrFrameType_spps[17] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+
+ //** From {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00};
+ //** mapping to
+const uint8 NB_DspModeLen_spps[17] = {0x10, 0x0D, 0x0A, 0x0A, 0x09, 0x08, 0x07, 0x06};
+
+ //** From {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28};
+ //** mapping to
+const uint8 WB_DspModeLen_spps[17] = {0x09, 0x0C, 0x10, 0x12, 0x14, 0x17, 0x19, 0x1D, 0x1E};
+
+#ifdef __VIDEO_CALL_SUPPORT__
+static const uint8 AMR_IF2_Order[8] = {
+ 0x10,0x20,0x40,0x80,0x01,0x02,0x04,0x08 /* bits order of AMR IF2 frame */
+};
+
+static const uint8 AMR_IF2_FRAME_LENGTH[16] = {/* byte length of AMR IF2 frame */
+ 13, 14, 16, 18, 19, 21, 26, 31, 6,
+ 0 , 0, 0, 0, 0, 0, 1
+};
+#endif
+
+static kal_uint8 encodebits_null[32];
+static kal_uint32 l1AInfo_spps = 0;
+
+
+/*****************************
+Local functions
+*****************************/
+
+
+em_speech_info_SpeechCodecType convert_SP4G_CODEC_AMR_AMRWB_to_SPH_CODEC(SP4G_Codec frame_type)
+{
+ unsigned char ret_type = SPH_CODEC_LOST_FRAME;
+ if( (SP4G_CODEC_AMR_4_75<=frame_type) && (SP4G_CODEC_AMR_12_2>=frame_type) )
+ {
+ ret_type = AmrFrameType2DspMode_spps[frame_type];
+ }
+ else if( SP4G_CODEC_AMR_SID == frame_type )
+ {
+ ret_type = SPH_CODEC_AMR_SID;
+ }
+ else if( SP4G_CODEC_WBAMR_SID == frame_type )
+ {
+ ret_type = SPH_CODEC_AMRWB_SID;
+ }
+ else if( SP4G_CODEC_AMR_NO_DATA == frame_type )
+ {
+ ret_type = SPH_CODEC_AMR_NODATA;
+ }
+ else if( (SP4G_CODEC_WBAMR_6_6<=frame_type) && (SP4G_CODEC_LOST_FRAME>=frame_type) )
+ {
+ ret_type = frame_type + 0x10;
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_AMR_CONVERT_SP4G_CODEC_AMR_AMRWB_TO_SPH_CODEC(frame_type);
+ ASSERT(0);
+ }
+ return( (em_speech_info_SpeechCodecType)ret_type );
+}
+
+
+void sp_ps_codec_amr_reset_internal(void)
+{
+ spPS->ul_count = 0;
+ spPS->ul_write_idx = 0;
+ spPS->ul_read_idx = 0;
+ // DL side
+ spPS->dl_count = 0;
+ spPS->dl_write_idx = 0;
+ spPS->dl_read_idx = 0;
+ spPS->dl_buffer_size = RAT_4G_DL_BUFFER_NUM_BEFORE_RESYNC;
+ spPS->dl_buffer_size = 2;
+}
+
+
+uint16 sp_ps_codec_amr_Get_RAB_subflow_spps(int index1, int index2)
+{
+ ASSERT( (index1<26) && (index1>=0) );
+ ASSERT( (index2< 4) && (index2>=0) );
+ return( RAB_subflow_spps[index1][index2] );
+}
+
+
+uint8 sp_ps_codec_amr_Get_AmrFrameType2DspMode_spps(int index)
+{
+ ASSERT( (index<25) && (index>=0) );
+ return( AmrFrameType2DspMode_spps[index] );
+}
+
+
+kal_uint16 sp_ps_codec_amr_GetCodecBitLength(SP4G_Codec codec)
+{
+ int len = 0, I;
+
+ if(codec == 25 || codec == AMR_SID_FRAME){
+ len= sp_ps_codec_amr_Get_RAB_subflow_spps(codec, 0);
+ }else if(codec == AMR_NO_DATA){
+ len = 0;
+ }else{
+ for( len = 0, I = 0 ; I < 3 ; I++ ) {
+ len += sp_ps_codec_amr_Get_RAB_subflow_spps(codec, I);
+ }
+ }
+ return(len);
+}
+
+
+void sp_ps_codec_amr_hisr_ul_amr(void *data)
+{
+ int32 I, J = 0, K;
+ uint16 *ptr16;
+ uint16 tx_type, sc_mode;
+ uint8 *ptr8;
+ uint8 len;
+ const uint8* RAB_To_DSP_Mapping;
+ uint16 total_bits, idx, rabBitsCount;
+ uint8 frame_type = 0,bit8Data;
+ bool bWrite;
+ int32 isGiveSpinlock = 0;
+
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)) || (sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)) )
+ {
+ MD_TRC_SP_PS_CODEC_AMR_UL_HISR_SKIP_AMR(L1SP_GetState(), sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode), sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode));
+ kal_give_spinlock(spinlock_sp4g);
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+
+ spPS->ul_report = SAL_3G_GetValue(SAL_3G_VALUE_TX_CODEC_MODE);
+
+ /*for catcher log codec information*/
+ if( spPS->ul_report != spPS->pre_ul_report ){
+ MD_TRC_L1Audio_Msg_SPEECH_CODEC( L1SP_Speech_Codec_Mode(spPS->ul_report), L1SP_Speech_Codec_Mode(spPS->dl_report) );
+ spPS->pre_ul_report = spPS->ul_report;
+ }
+
+
+ // UL side
+ ptr16 = (uint16*)spPS->ul_dsp_buffer;
+ {
+ // get data from DSP UL buffer
+ volatile uint16 *addr;
+ tx_type = SAL_3G_GetValue(SAL_3G_VALUE_TX_TYPE);
+ sc_mode = spPS->ul_report;
+ if( sc_mode < 0x03 || sc_mode > 0x28 )
+ {
+ MD_TRC_SP_PS_CODEC_AMR_HISR_UL_INVALID_CODEC_MODE(sc_mode);
+ tx_type = SAL_3G_TX_NO_DATA;
+ sc_mode = 3;
+ }
+ addr = SAL_3G_GetAddr(SAL_3G_ADDR_TXHB);
+ for(I = GetDspModeLen(sc_mode); --I >= 0 ; )
+ *ptr16++ = *addr++;
+ }
+
+ // do bit re-ordering
+ ptr16 = (uint16*)spPS->ul_dsp_buffer;
+
+ ptr8 = (uint8*)spPS->ul_buffer[spPS->ul_write_idx];
+
+ bWrite = KAL_FALSE;
+
+ if(SAL_3G_IsULReady()){//DSP tell MCU the data of DSP is ready
+ if( spPS->ul_count < spPS->ul_buffer_size ){
+ bWrite = KAL_TRUE;
+ }
+ if( spPS->ul_count == spPS->ul_buffer_size ){
+ if( spPS->is_getting_ul_data ){
+ bWrite = KAL_FALSE;
+ MD_TRC_SP_PS_CODEC_AMR_HISR_UL_AMR_NO_UPDATE_UL_BUFFER_1();
+ }else{
+ spPS->ul_read_idx++; //drop oldest frame
+ spPS->ul_count--;
+ bWrite = KAL_TRUE;
+ if( spPS->ul_read_idx == spPS->ul_buffer_size )
+ spPS->ul_read_idx = 0;
+ }
+ }
+ SAL_3G_SetULEmpty();
+ }else{//DSP tell MCU the data of DSP is not ready
+ //We should not modify spPS->ul_report, but this case is error handling.
+ spPS->ul_report = spPS->ul_codec_mode;
+ sc_mode = spPS->ul_report;
+ if (sc_mode < 0x03 || sc_mode > 0x28)
+ {
+ // error handling
+ MD_TRC_SP_PS_CODEC_AMR_HISR_UL_INVALID_CODEC_MODE(sc_mode);
+ sc_mode = 3;
+ }
+ AM_FillSilencePatternInBuffer( ptr16, spPS->ul_report );
+ tx_type = SAL_3G_TX_SPEECH_GOOD;
+ SAL_3G_SetULUnsync();
+
+ if( spPS->ul_count < spPS->ul_buffer_size ){
+ bWrite = KAL_TRUE;
+ }
+ if( spPS->ul_count == spPS->ul_buffer_size ){
+ if( spPS->is_getting_ul_data ){
+ bWrite = KAL_FALSE;
+ MD_TRC_SP_PS_CODEC_AMR_HISR_UL_AMR_NO_UPDATE_UL_BUFFER_2();
+ }else{
+ spPS->ul_read_idx++; //drop oldest frame
+ spPS->ul_count--;
+ bWrite = KAL_TRUE;
+ if( spPS->ul_read_idx == spPS->ul_buffer_size )
+ spPS->ul_read_idx = 0;
+ }
+ }
+
+ MD_TRC_SP_PS_CODEC_AMR_HISR_UL_DSP_NOT_READY(GetDspModeLen(sc_mode));
+ }
+
+ if( bWrite ){
+ frame_type = GetDspMode2FrameType(sc_mode);
+ switch(tx_type)
+ {
+ case SAL_3G_TX_SPEECH_GOOD:
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(1);
+#endif //#ifdef __OP_IS_AT_AND_T__
+ *ptr8++ = frame_type;
+ if(frame_type >= 26)
+ ASSERT(0);
+ else
+ len = RAB_subflow_spps[frame_type][3];
+ *ptr8++ = len;
+
+ if(frame_type >= 0x10) //AMR-WB
+ {
+ if((frame_type-0x10) >= 9)
+ ASSERT(0);
+ else
+ RAB_To_DSP_Mapping = (const uint8 *)tblAMR_WBOrder[frame_type-0x10];
+ }
+ else
+ {
+ if(frame_type >= 8)
+ ASSERT(0);
+ else
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+ }
+
+ // do bit reorder , move speech information bits to rab_byte_array
+ total_bits = RAB_subflow_spps[frame_type][0] + RAB_subflow_spps[frame_type][1] + RAB_subflow_spps[frame_type][2];
+
+ for(I = len; --I >= 0; *ptr8++ = 0);
+
+ for(idx = 0, ptr8 -= len, I = 0; I < 3; I ++){
+ rabBitsCount = RAB_subflow_spps[frame_type][I];
+
+ if( frame_type >= 16 ){
+ const uint16* WB_RAB_To_DSP_Mapping;
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order_spps[K & 15])? RAB_Order_spps[J & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ } else {
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order_spps[K & 15])? RAB_Order_spps[J & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+
+ ASSERT(idx == total_bits);
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{
+ len = AMR_IF2_FRAME_LENGTH[frame_type]; //frame length
+ *ptr8++ = len;
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+ total_bits = RAB_subflow_spps[frame_type][0] + RAB_subflow_spps[frame_type][1] + RAB_subflow_spps[frame_type][2];
+
+ for(I = len; --I >= 0 ; )
+ *ptr8++ = 0;
+ idx = 0;
+ ptr8 -= len;
+ // do bit reorder , first byte contains frame_type
+ *ptr8 = frame_type;
+ I = 4;
+ for(J = 0; J < total_bits; J++,I++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order_spps[K & 15])? AMR_IF2_Order[J & 0x7] : 0;
+ ptr8[I >> 3] |= bit8Data;
+ }
+ }
+#endif
+ MD_TRC_SP_PS_CODEC_TX_SPEECH_GOOD();
+ break;
+ case SAL_3G_TX_SID_FIRST:
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(0);
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+ if( spPS->ul_report >= 0x20 )
+ *ptr8++ = WB_AMR_SID_FRAME;//WB SID
+ else
+ *ptr8++ = AMR_SID_FRAME;
+ *ptr8++ = 5;
+ for(I = 4; --I >= 0; )
+ *ptr8++ = 0;
+
+ if( spPS->ul_report >= 0x20 )
+ *ptr8 = (uint8)(spPS->ul_report - 0x20);
+ else
+ *ptr8 = (uint8)(frame_type << 1);
+ //#ifdef AMR_DATA_LOG
+ ptr8 -= 6;
+ MD_TRC_SP_PS_CODEC_TX_SID_FIRST();
+ //#endif
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G 324M
+ *ptr8++ = 6;//frame length
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+ *ptr8 = (uint8)(frame_type);
+ ptr8 -= 5;
+ *ptr8 |= AMR_SID_FRAME;
+ }
+#endif
+ break;
+ case SAL_3G_TX_SID_UPDATE:
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(0);
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+ if( spPS->ul_report >= 0x20 )
+ *ptr8++ = WB_AMR_SID_FRAME;//WB SID
+ else
+ *ptr8++ = AMR_SID_FRAME;
+ *ptr8++ = 5;
+ // do bit reorder , move sid information bits to rab_byte_array
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+
+ ptr8 -= 5;
+ for(I = 0; I < 35; I ++)
+ {
+ bit8Data = (ptr16[I >> 4] & DSP_Order_spps[I & 15])? RAB_Order_spps[I & 0x7] : 0;
+ ptr8[I >> 3] |= bit8Data;
+ }
+ frame_type = (frame_type >> 2) | ((frame_type & 0x1) << 2) | (frame_type & 0x2);
+ if( spPS->ul_report >= 0x20 )
+ ptr8[4] |= (uint8)(spPS->ul_report - 0x20)|0x10;
+ else
+ ptr8[4] |= (uint8)(frame_type << 1)|0x10;
+
+
+ //#ifdef AMR_DATA_LOG
+ ptr8 -= 2;
+ MD_TRC_SP_PS_CODEC_TX_SID_UPDATE();
+ //#endif
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G 324M
+ *ptr8++ = 6;//frame length
+ for(I = 5; --I >= 0; )
+ *ptr8++ = 0;
+ *ptr8 = (uint8)(frame_type);
+ ptr8 -= 5;
+ *ptr8 |= AMR_SID_FRAME;
+ J = 4;
+ for(I = 0; I < 35; J++, I++)
+ {
+ bit8Data = (ptr16[I >> 4] & DSP_Order_spps[I & 15])? AMR_IF2_Order[I & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ ptr8[4] |= 0x80;
+ }
+#endif
+ break;
+ case SAL_3G_TX_NO_DATA:
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(0);
+#endif //#ifdef __OP_IS_AT_AND_T__
+ *ptr8++ = AMR_NO_DATA;
+ *ptr8++ = 0;
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G324M
+ *ptr8++ = 1;
+ *ptr8++ = AMR_NO_DATA;
+ }
+#endif
+ MD_TRC_SP_PS_CODEC_TX_NO_DATA();
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
+ }
+
+ if( spPS->ul_refresh && (spPS->ul_intrarat == KAL_FALSE) )
+ {
+ uint8 ul_report = SAL_3G_GetValue(SAL_3G_VALUE_TX_CODEC_MODE);
+ if((spPS->ul_report <= 0x0A && spPS->ul_codec_mode >= 0x20) || //WB, NB handover
+ (spPS->ul_report >= 0x20 && spPS->ul_codec_mode <= 0xA)){
+ ASSERT(0);
+ }else if(ul_report != spPS->ul_codec_mode ){
+ SAL_3G_Upd_Enc_Cod(spPS->ul_codec_mode);
+ }
+ spPS->ul_refresh = KAL_FALSE;
+ }
+ spPS->ul_intrarat = KAL_FALSE;
+
+ if( bWrite ){
+ spPS->ul_write_idx++;
+ if( spPS->ul_write_idx == spPS->ul_buffer_size )
+ spPS->ul_write_idx = 0;
+ spPS->ul_count++;
+ MD_TRC_SP_PS_CODEC_AMR_UL_BUFFER(spPS->ul_count,spPS->ul_read_idx,spPS->ul_write_idx);
+ if( spPS->sp4g_mode == RAT_4G_MODE && spPS->ul_delay > START_SHRINK_UL_DELAY && !spPS->is_getting_ul_data){
+ spPS->ul_read_idx++;
+ if( spPS->ul_read_idx == spPS->ul_buffer_size )
+ spPS->ul_read_idx = 0;
+ if(spPS->ul_count > 1)
+ spPS->ul_count--;
+ }//when ul write updated, check ul_delay. keep newest one
+ }
+
+ if(SP_is_codec_mute())
+ {
+ if(KAL_TRUE == spPS_Rab_State_get())
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback( SP4G_UL_MUTE_NOTIFY, (void*)0 );
+ MD_TRC_SP_PS_CODEC_UL_SKIP_NOTIFY();
+ }
+ }
+ else
+ {
+ if( spPS->ul_waiting == KAL_FALSE ){
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ spPS->ul_waiting = KAL_TRUE;
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback( SP4G_UL_DATA_NOTIFY, (void*)0 );
+ }
+ }else{
+ spPS->ul_delay ++;
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback(SP4G_UL_DATA_DEALY_TICK, (void *)(kal_uint32)spPS->ul_delay);
+ MD_TRC_SP_PS_CODEC_UL_DELAY(spPS->ul_delay);
+ if (spPS->ul_delay >= UL_DELAY_THRESHOLD)
+ {
+ SP_PS_CALL_DBG_ASSERT(0);
+ }
+ #if 0
+/* under construction !*/
+ #endif
+ }
+ }
+ }
+
+ if(0 == isGiveSpinlock)
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ }
+
+}
+
+
+
+void sp_ps_codec_amr_hisr_dl_amr(void *data)
+{
+ int32 isGiveSpinlock = 0;
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(0);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)) || (sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)) )
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_SKIP_AMR( L1SP_GetState(), sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode), sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode));
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(1);
+ return;
+ }
+
+ if(SP_is_codec_mute())
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(2);
+ if(KAL_TRUE == spPS_Rab_State_get())
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(3);
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback( SP4G_DL_MUTE_NOTIFY, (void*)0 );
+ MD_TRC_SP_PS_CODEC_DL_SKIP_NOTIFY();
+ }
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(4);
+// if( spPS->dl_waiting == KAL_FALSE ){
+// MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(5);
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(6);
+ spPS->dl_waiting = KAL_TRUE;
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback( SP4G_DL_DATA_NOTIFY, (void*)0 );
+ }
+/*
+ }else{
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(7);
+ spPS->dl_delay ++;
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(8);
+ kal_give_spinlock(spinlock_sp4g);
+ isGiveSpinlock = 1;
+ PSR_SP4G_Callback(SP4G_DL_DATA_DEALY_TICK, (void *)(kal_uint32)spPS->dl_delay);
+ MD_TRC_SP_PS_CODEC_DL_DELAY( spPS->dl_delay );
+ SP_PS_CALL_DBG_ASSERT(0);
+ }
+ }
+*/
+ }
+ if(0 == isGiveSpinlock)
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ MD_TRC_SP_PS_CODEC_AMR_DL_HISR_STATUS(9);
+}
+
+void sp_ps_codec_amr_dl_reorder2dspformat(void *data)
+{
+ int32 I, J = 0, K;
+ uint16 *ptr16;
+ uint16 rx_type = 0, sd_mode = 0, rx_len = 0;
+ uint8 *ptr8;
+ const uint8* RAB_To_DSP_Mapping, *Order = NULL;
+ uint16 total_bits, idx, rabBitsCount;
+ uint8 frame_type = 0;
+ uint16 bit16Data;
+ uint8 sidData;
+ bool FQI_flag = false;
+ VoLTE_JBM_TS_Info_t *JBM_info = (VoLTE_JBM_TS_Info_t *)data;
+ uint32 JBM_Nth_Frm = SAL_4G_RX_FIRST_FRM;
+#if defined(__SP4G_UL_RESYNC__)
+ bool ul_request_resync;
+ uint32 ctime;
+#endif
+
+ if( (JBM_info->TS_HB_Frm_Num==2) && (JBM_info->TS_isRemainFrame==0) )
+ {
+ JBM_Nth_Frm = SAL_4G_RX_SECOND_FRM;
+ }
+ //SAL_4G_SetTSSwitch(JBM_info->TS_Switch);
+ SAL_4G_SetTSScale(JBM_info->TS_Scale, JBM_info->TS_Max_Scale, JBM_Nth_Frm);
+ SAL_VOLTE_SetInfo(SAL_VOLTE_INFO_JBM_NODATA_TYPE, JBM_info->Nodata_Type);
+
+#if defined(__SP4G_UL_RESYNC__)
+ ctime = ust_get_current_time();
+#endif
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON)
+ {
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ if(sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ {
+ return;
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ ul_request_resync = spPS->request_resync ;
+ MD_TRC_SP_PS_CODEC_AMR_UL_SYNC_SP4G_HISR_DL_AMR_1_INFO(ul_request_resync, spPS_reset_flag_get(), ctime);
+#endif
+
+ spPS->dl_report = SAL_4G_GetRXValue(SAL_4G_VALUE_RX_CODEC_MODE, JBM_Nth_Frm);//SAL_3G_GetValue(SAL_3G_VALUE_RX_CODEC_MODE);
+
+
+ /*for catcher log codec information*/
+ if( spPS->dl_report != spPS->pre_dl_report ){
+ MD_TRC_L1Audio_Msg_SPEECH_CODEC( L1SP_Speech_Codec_Mode(spPS->ul_report), L1SP_Speech_Codec_Mode(spPS->dl_report) );
+ spPS->pre_dl_report = spPS->dl_report;
+ }
+
+ {
+ uint16 crc_result = 0;
+ uint32 CFN;
+
+ if( spPS->dl_count == 0 ){
+ crc_result = (l1AInfo_spps << 8);
+ CFN = 0xFFFFFFFF;
+ }
+ else
+ {
+ CFN = 0;
+ ptr8 = (uint8*) spPS->dl_buffer[spPS->dl_read_idx];
+ ptr8 += 2;
+ CFN = ptr8[0] + (ptr8[1] << 8) + (ptr8[2] << 16) + (ptr8[3] << 24);
+
+ for(I = 0 ; I < 4 ; I ++)
+ if( CFN == spPS->L1_Info[I][0] )
+ break;
+ if( I == 4 ){
+ crc_result = (l1AInfo_spps << 8);
+ //l1_info = NULL;
+ }else{
+ //l1_info = spPS->L1_Info[I];
+ crc_result = (uint16)(l1AInfo_spps << 8) | (uint16)(spPS->L1_Info[I][2] & 0xF); //[0:7]:CRC, [8:15]:l1AInfo
+ }
+ /*SID BAD False alarm work around, log in VM first*/
+ {
+ uint8 * ptrDL;
+ ptrDL = (uint8*) spPS->dl_buffer[spPS->dl_read_idx];
+ if( spPS->dtx_state == 0 && ptrDL[0] == 8 /*AMR_SID*/ && ptrDL[1] == KAL_FALSE/*CRC fail*/)
+ crc_result |= 0x8000;// The flag indicate working around
+ if( ptrDL[0] == AMR_NO_DATA && spPS->dtx_force == KAL_TRUE )
+ //crc_result |= 0x4000;
+ crc_result |= 0x0080;//move from bit14 to bit7. 20100821
+ }
+ }
+ SAL_VOLTE_SetInfo(SAL_VOLTE_INFO_JBM_OUT_SN, CFN);
+ }
+
+ l1AInfo_spps &= ~0xFFFC;
+ //MD_TRC_SP_PS_CODEC_AMR_P0_RESET_FLAG_INFO(spPS_reset_flag_get(), spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+ // DL side
+ if( spPS->dl_count == 0 || spPS_reset_flag_get() != 2 ){ // buffer under flow
+ SAL_4G_Set_RxType(SAL_3G_RX_NO_DATA, JBM_Nth_Frm);
+ rx_type = SAL_3G_RX_NO_DATA;
+ spPS->dtx_state = 1;
+ MD_TRC_SP_PS_CODEC_AMR_DTX_NO_DATA();
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_AMR_BUFFER_STATUS(spPS->dl_read_idx, spPS->dl_write_idx,spPS->dl_count, spPS->dl_buffer[spPS->dl_read_idx][0]);
+
+ ptr8 = (uint8*) spPS->dl_buffer[spPS->dl_read_idx];
+ ptr16 = (uint16*) spPS->dl_dsp_buffer;
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ frame_type = *ptr8++; // here 0 ~ 7 and includes SID and NO_DATA
+ FQI_flag = (bool)*ptr8++;
+ ptr8 += 4; // skip CFN
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G 324M
+ FQI_flag = KAL_TRUE;
+ frame_type = *ptr8++; // here 0 ~ 7 and includes SID and NO_DATA
+ ptr8++; // skip frame length
+ }
+#endif
+ MD_TRC_SP_PS_CODEC_AMR_DL_BIT_TRUE(frame_type, ptr8[0], ptr8[1],ptr8[2],ptr8[3],ptr8[4]);
+
+ if( frame_type == AMR_NO_DATA && spPS->dtx_force == KAL_TRUE ){
+ frame_type = AMR_SID_FRAME;
+ FQI_flag = KAL_FALSE; // force enter SID_BAD;
+ spPS->dtx_state = 1;
+ }
+ spPS->dtx_force = KAL_FALSE;
+ if( spPS->dtx_state == 0 && frame_type == AMR_SID_FRAME && FQI_flag == KAL_FALSE ){//previous dtx_state is false, but suddenly SID_BAD, regard it as false alarm.
+ frame_type = AMR_NO_DATA;
+ spPS->dtx_force = KAL_TRUE;
+ }
+#if defined(__SP4G_UL_RESYNC__)
+ if( ul_request_resync ){
+ MD_TRC_SP_PS_CODEC_AMR_UL_SYNC_SP4G_HISR_DL_AMR_FORCED_NO_DATA();
+
+ frame_type = AMR_NO_DATA;
+ }
+#endif
+ switch(frame_type)
+ {
+ case 0: // 4.75 kbps
+ case 1: // 5.15 kbps
+ case 2: // 5.9 kbps
+ case 3: // 6.7 kbps
+ case 4: // 7.4 kbps
+ case 5: // 7.95 kbps
+ case 6: // 10.2 kbps
+ case 7: // 12.2 kbps
+ case 16:/* WB type 0, AMR-WB 6.60 */
+ case 17:/* WB type 1, AMR-WB 8.85 */
+ case 18:/* WB type 2, AMR-WB 12.65 */
+ case 19:/* WB type 3, AMR-WB 14.25 */
+ case 20:/* WB type 4, AMR-WB 15.85 */
+ case 21:/* WB type 5, AMR-WB 18.25 */
+ case 22:/* WB type 6, AMR-WB 19.85 */
+ case 23:/* WB type 7, AMR-WB 23.05 */
+ case 24:/* WB type 8, AMR-WB 23.85 */
+ if( frame_type >= 16 )
+ RAB_To_DSP_Mapping = (const uint8 *) tblAMR_WBOrder[frame_type-16];
+ else
+ RAB_To_DSP_Mapping = tblAMROrder[frame_type];
+ if( FQI_flag == KAL_TRUE )
+ rx_type = SAL_3G_RX_SPEECH_GOOD;
+ else
+ rx_type = SAL_3G_RX_SPEECH_BAD;
+
+ sd_mode = AmrFrameType2DspMode_spps[frame_type];//GetFrameType2DspMode(frame_type);
+ rx_len = GetDspModeLen(sd_mode);
+ // move amr data to dl_buffer
+
+ total_bits = RAB_subflow_spps[frame_type][0] + RAB_subflow_spps[frame_type][1] + RAB_subflow_spps[frame_type][2];
+
+ for(I = rx_len; --I >= 0; )
+ *ptr16++ = 0;
+
+ ptr16 -= rx_len;
+ idx = 0;
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ for(I = 0; I < 3; I ++)
+ {
+ if(RAB_subflow_spps[frame_type][I] == 0)
+ break;
+ rabBitsCount = RAB_subflow_spps[frame_type][I];
+ if(frame_type >= 16){
+ const uint16* WB_RAB_To_DSP_Mapping;
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[J >> 3] & RAB_Order_spps[J & 7])? DSP_Order_spps[K & 15] : 0;
+ ptr16[K >> 4] |= bit16Data;
+ }
+ } else {
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ uint32 t1;
+ uint16 *t2;
+ K = RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[J >> 3] & RAB_Order_spps[J & 7])? DSP_Order_spps[K & 15] : 0;
+ t1 = K >> 4;
+ t2 = ptr16 + t1;
+
+ //ptr16[K >> 4] |= bit16Data;
+ *t2 |= bit16Data;
+ }
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+ ASSERT(idx == total_bits);
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G 324M
+ I = 4;
+ for(J = 0; J < total_bits; J++, I++)
+ {
+ K = RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[I >> 3] & AMR_IF2_Order[J & 7])? DSP_Order_spps[K & 15] : 0;
+ ptr16[K >> 4] |= bit16Data;
+ }
+ }
+#endif
+ spPS->dtx_state = 0;
+ break;
+
+ case 8: // AMR SID
+ case 25:
+ sidData = ptr8[4];
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ if( FQI_flag == KAL_TRUE )
+ {
+ if( sidData & 0x10 )
+ rx_type = SAL_3G_RX_SID_UPDATE;
+ else
+ rx_type = SAL_3G_RX_SID_FIRST;
+ spPS->dtx_state = 1;
+ }
+ else
+ rx_type = SAL_3G_RX_SID_BAD;
+
+ if( frame_type == 25 ){
+ sd_mode = (sidData & 0xF);
+
+ if(sd_mode >= 10)
+ {
+ rx_type = SAL_3G_RX_SID_BAD;
+ sd_mode = spPS->pre_dl_report;
+ } else if(9 == sd_mode){
+ sd_mode = spPS->pre_dl_report;
+ } else {
+ sd_mode = AmrFrameType2DspMode_spps[sd_mode+16];//GetFrameType2DspMode(sd_mode+16);
+ }
+ } else
+ {
+ sd_mode = (sidData & 0xE) >> 1;// should reverse
+ sd_mode = (sd_mode >> 2) | ((sd_mode & 0x1) << 2) | (sd_mode & 0x2);
+ sd_mode = AmrFrameType2DspMode_spps[sd_mode];//GetFrameType2DspMode(sd_mode);
+ //sd_mode = AmrFrameType2DspMode_spps[sd_mode]; // RX SD Mode
+ }
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G 324M
+ if( sidData & 0x80 )
+ rx_type = SAL_3G_RX_SID_UPDATE;
+ else
+ rx_type = SAL_3G_RX_SID_FIRST;
+ sd_mode = AmrFrameType2DspMode_spps[(ptr8[5] & 0x7)]; //GetFrameType2DspMode((ptr8[5] & 0x7));
+ }
+#endif
+
+ rx_len = 3; // 35 information bits
+ // move sid data to dl_buffer
+ for(I = 3; --I >= 0; )
+ *ptr16++ = 0;
+ ptr16 -= 3;
+ Order = RAB_Order_spps;
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ J = 0;
+ Order = RAB_Order_spps;
+ }
+#ifdef __VIDEO_CALL_SUPPORT__
+ else{//4G324M
+ J = 4;
+ Order = AMR_IF2_Order;
+ }
+#endif
+
+ for(I = 0; I < 35; I++,J++)
+ {
+ bit16Data = (ptr8[J >> 3] & Order[I & 7])? DSP_Order_spps[I & 15] : 0;
+ ptr16[I >> 4] |= bit16Data;
+ }
+ //#ifdef AMR_DATA_LOG
+ if( rx_type == SAL_3G_RX_SID_FIRST )
+ MD_TRC_SP_PS_CODEC_RX_SID_FIRST();
+ else if( rx_type == SAL_3G_RX_SID_UPDATE )
+ MD_TRC_SP_PS_CODEC_RX_SID_UPDATE();
+ //#endif
+ break;
+
+ case 15: // NO DATA
+ MD_TRC_SP_PS_CODEC_RX_NO_DATA();
+ rx_type = SAL_3G_RX_NO_DATA;
+ rx_len = 0;
+ // no need to record codec mode , inherit from previous
+ break;
+ case SP4G_CODEC_LOST_FRAME:
+ MD_TRC_SP_PS_CODEC_RX_LOST_DATA();
+ rx_type = SAL_3G_RX_NO_DATA;
+ rx_len = 0;
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
+ // get codec_mode , set RX codec_mode
+ // get data from dl_read
+ ptr16 = (uint16*) spPS->dl_dsp_buffer;
+
+ SAL_4G_Set_RxType(rx_type, JBM_Nth_Frm);
+
+ //For NB/WB handover, it's decided by network set UL codec.
+ // If downlink happens, set it as NO data.
+ if( rx_type != SAL_3G_RX_NO_DATA )
+ {
+ if( (sd_mode <= 0x0A && spPS->dl_report >= 0x20) ||
+ (sd_mode >= 0x20 && spPS->dl_report <= 0x0A) )
+ {
+ SAL_4G_Set_RxType(SAL_3G_RX_NO_DATA, JBM_Nth_Frm);
+ SAL_3G_Upd_Dec_Cod(spPS->dl_report);
+ rx_type = SAL_3G_RX_NO_DATA;
+ MD_TRC_SP_PS_CODEC_AMR_RX_FORCE_NO_DATA_WHEN_CHANGE_BAND();
+ }
+ }
+#if defined(__SP4G_UL_RESYNC__)
+ else if (ul_request_resync) {
+ MD_TRC_SP_PS_CODEC_UL_SYNC_AM_4G_INTRARAT();
+ AM_4G_INTRARAT(spPS->ul_codec_mode, PS_SRST_TYPE_UNSYNC);
+ spPS->request_resync = KAL_FALSE;
+ }
+#endif
+ if( rx_type != SAL_3G_RX_NO_DATA && rx_type != SAL_3G_RX_SID_BAD ) //if RX_NO_DATA or RX_SID_BAD, codec mode will use the previous one
+ {
+ volatile uint16 *addr;
+ SAL_3G_Upd_Dec_Cod(sd_mode);
+ addr = SAL_4G_GetRXAddr(SAL_4G_ADDR_RXHB, JBM_Nth_Frm);//SAL_3G_GetAddr(SAL_3G_ADDR_RXHB);
+ for(I = rx_len ; --I >= 0; )
+ *addr++ = *ptr16++;
+ Data_Sync_Barrier();
+ }
+ {
+ // update 4G dl_count
+ spPS->dl_count --;
+ spPS->dl_read_idx++;
+ }
+ if( spPS->dl_read_idx >= spPS->dl_buffer_size ){//near end of buffer
+ spPS->dl_read_idx = 0;
+ }
+ }
+ MD_TRC_SP_PS_CODEC_AMR_HIST_4G_SYNC(((uint8)SAL_3G_IsDLEmpty()<<1) + (uint8)SAL_3G_IsULReady());
+ if(JBM_info->TS_HB_Frm_Num != 0)
+ {
+ SAL_4G_SetDLHBValid(true, JBM_Nth_Frm);
+ }
+ SAL_3G_SetDLReady(); // MCU tell DSP the data is ready
+
+ { /*for catcher log codec information*/
+ uint8 txType, rxType, ber;
+ txType = SAL_3G_GetValue(SAL_3G_VALUE_TX_TYPE);
+ rxType = rx_type >> 1;
+ ber = 255;//useless both for dsp and driver;
+ //ber = (*DP_4G_DL_RX_TYPE & 0xFF00);
+ MD_TRC_L1Audio_Msg_SPEECH_FRAME( L1SP_Speech_TX_Type(txType), L1SP_Speech_RX_Type(rxType), ber );
+ //L1Audio_Msg_VM_DEBUG( DP2_3G_debug_info0, DP2_3G_debug_info1, DP2_3G_debug_info7 );
+ }
+}
+
+
+void sp_ps_codec_amr_UL_GetSpeechFrameSub(kal_uint16*frame_index, kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ uint8 *ptr8;
+ int32 I;
+ uint16 sc_mode=0;
+ uint8 state;
+
+
+ //kal_give_spinlock(spinlock_sp4g);
+
+ if( (state = L1SP_GetState()) != L1SP_STATE_4G_SPEECH_ON)
+ {
+ *frame_index = 0xABCD;
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ //MD_TRC_SP_PS_CODEC_AMR_UL_GETSPEECHFRAMESUB_1(spPS_reset_flag_get());
+
+ if( spPS_reset_flag_get() == 1 ){
+ sp_ps_reset_internal();
+ }
+
+
+ //MD_TRC_SP_PS_CODEC_AMR_UL_GETSPEECHFRAMESUB_2(spPS_reset_flag_get());
+
+ *frame_index = 0xABCD; // tmp setting , should be apply true value in near future , Adam
+
+ if( spPS->ul_count == 0)// or should repeat last frame
+ {
+ *frame_type = AMR_NO_DATA;
+ *len = 0;
+ return;
+ }
+
+ //*frame_index = 0xABCD; // tmp setting , should be apply true value in near future , Adam
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->is_getting_ul_data = KAL_TRUE;
+ kal_give_spinlock(spinlock_sp4g);
+
+ ptr8 = (uint8*)spPS->ul_buffer[spPS->ul_read_idx];
+
+ *frame_type = *ptr8;
+
+ if(*frame_type < AMR_SID_FRAME)
+ sc_mode = AmrFrameType2DspMode_spps[*frame_type];
+ else if(*frame_type >= 16 && *frame_type <= 24){
+ sc_mode = AmrFrameType2DspMode_spps[*frame_type];
+ *ptr8 -= 16;//in subflow data, remap to 0~8?????
+ }else if( *frame_type == 25 ){ //WB AMR SID
+ *ptr8 = AWB_SID_FRAME; //in subflow data, remap to 9
+ }
+
+ ptr8++;
+ {
+ *len = *ptr8++;
+ ASSERT( *len <= 60 );
+
+ for( I = *len; --I >= 0 ; )
+ *rab_byte_array++ = *ptr8++;
+ }
+
+ spPS->ul_count--;
+
+ spPS->ul_read_idx++;
+ if( spPS->ul_read_idx == spPS->ul_buffer_size )
+ spPS->ul_read_idx = 0;
+ spPS->is_getting_ul_data = KAL_FALSE;
+ if(sc_mode){
+ // do something // avoid build warning
+ }
+}
+
+
+void sp_ps_codec_amr_UL_GetSpeechFrame(kal_uint8 *frame_type, kal_uint8 *rab_byte_array, kal_uint8 *len)
+{
+ kal_uint16 frame_index, I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+ ASSERT(spPS->ul_waiting == KAL_TRUE); // 1 message 1 get, should take care if CSR doesn't get by DATA_NOTIFY message
+ sp_ps_codec_amr_UL_GetSpeechFrameSub(&frame_index, frame_type, rab_byte_array, len);
+ //reorder to AMR IF1
+ if( *frame_type != AMR_NO_DATA && *frame_type != 25 && *frame_type != AMR_SID_FRAME )
+ {
+ ptr8 = rab_byte_array;
+ ptr8_swap = rab_byte_array;
+ byte_swap = *ptr8_swap;
+ *ptr8 = 0;
+ K = 0;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = RAB_subflow_spps[*frame_type][I];
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order_spps[J & 7])? RAB_Order_spps[K & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ if( (K&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ }
+ if( (J&7) != 0 ){ // avoid false advance a byte
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ //recalculate rab length
+ rabBitsCount = 0;
+ for( I = 0 ; I < 3 ; I++ )
+ rabBitsCount += RAB_subflow_spps[*frame_type][I];
+ *len = ((rabBitsCount+7)>>3);
+ }
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_waiting = KAL_FALSE;
+ spPS->ul_delay = 0;
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_CODEC_UL_GET_SPEECH_FRAME(*frame_type, *len);
+}
+
+
+void sp_ps_codec_amr_DL_PutSpeechFrame3Rab(uint32 CFN, uint8 sub_flow_id, uint8 frame_type, bool crc_status, uint8 *subflow, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ int32 I;
+ uint8 *ptr8;
+ uint16 rabBitsCount, state;
+ uint8 last_id;
+ if( (state = L1SP_GetState()) != L1SP_STATE_4G_SPEECH_ON)
+ {
+ if(state == L1SP_STATE_4G_SPEECH_CLOSING)
+ return;
+ else
+ //ASSERT(false);
+ return;
+ }
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ MD_TRC_SP_PS_CODEC_DL_PUT_SPEECH_FRAME_AMR(sub_flow_id, frame_type, crc_status);
+
+ if(frame_type == SP4G_CODEC_LOST_FRAME){
+ MD_TRC_SP_PS_CODEC_DL_FRM();
+ }else{
+ //if( sub_flow_id == 0 ) {
+ //MD_TRC_SP_PS_CODEC_DL_BIT_TRUE_TASK(subflow[0], subflow[1],subflow[2],subflow[3],subflow[4]);
+ //}
+ }
+
+ ASSERT( frame_type <= 25 || frame_type == SP4G_CODEC_LOST_FRAME);
+
+ //MD_TRC_SP_PS_CODEC_AMR_P1_RESET_FLAG_INFO(spPS_reset_flag_get(), spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+
+ if(frame_type == SP4G_CODEC_LOST_FRAME)
+ last_id = 0;
+ else
+ last_id = last_sub_flow_id[frame_type];
+
+ if( sub_flow_id > last_id )
+ return;
+
+ if( spPS->dl_count >= spPS->dl_buffer_size )
+ {
+ spPS->dl_read_idx++;
+ if( spPS->dl_read_idx >= spPS->dl_buffer_size )
+ spPS->dl_read_idx = 0;
+ spPS->dl_count --;
+ }//keep only 2 frame
+
+ //MD_TRC_SP_PS_CODEC_AMR_P2_RESET_FLAG_INFO(spPS_reset_flag_get(), spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+ ptr8 = spPS->dl_buffer[spPS->dl_write_idx];
+ if( sub_flow_id == 0 )
+ {
+ //frame_len = RAB_subflow_spps[frame_type][3];
+
+ // before first RB-subflow write
+ *ptr8++ = frame_type;
+ *ptr8++ = (uint8)crc_status;
+ *ptr8++ = CFN & 0xFF;
+ *ptr8++ = (CFN >> 8) & 0xFF;
+ *ptr8++ = (CFN >> 16) & 0xFF;
+ *ptr8++ = (CFN >> 24) & 0xFF;
+ }
+ else
+ {
+ if( frame_type > AMR_NO_DATA && sub_flow_id == 1 ){
+ //For WB-AMR, the frame type can not be differed in subflow 0,
+ // so that update it at subflow 1
+ *ptr8 = frame_type;//Range 16~25
+ }
+
+ ptr8 += 6;
+ for(I = 0 ; I < sub_flow_id ; I ++)
+ {
+ rabBitsCount = RAB_subflow_spps[frame_type][I];
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+ }
+
+ if(frame_type == SP4G_CODEC_LOST_FRAME)
+ rabBitsCount = 0;
+ else
+ rabBitsCount = sp_ps_codec_amr_Get_RAB_subflow_spps(frame_type, sub_flow_id);
+
+ for( I = 0; I < (rabBitsCount + 7) >> 3; I++ ){
+ *ptr8++ = *subflow++;
+ }
+
+ // after last RB-subflow write
+ if( sub_flow_id == last_id )
+ {
+ //kal_uint8 u8CheckBufFinish = 0;
+
+ spPS->dl_write_idx++;
+ if( spPS->dl_write_idx >= spPS->dl_buffer_size ){
+ //MD_TRC_SP_PS_CODEC_AMR_P3_RESET_FLAG_INFO(spPS_reset_flag_get(), spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+ spPS->dl_write_idx = 0;
+ }
+ //MD_TRC_SP_PS_CODEC_AMR_P4_RESET_FLAG_INFO(spPS_reset_flag_get(), spPS->dl_count, spPS->dl_read_idx, spPS->dl_write_idx, spPS->dl_buffer_size);
+
+
+ spPS->dl_count++;
+
+ if( spPS->dl_count >= DL_4G_THRESHOLD && spPS_reset_flag_get() == 0 ){
+ spPS_reset_flag_set(2);// reset done
+ }
+
+
+
+#ifdef __REDUCE_VOLTE_DL_DELAY__
+ if(2 == spPS_reset_flag_get()){
+ sp_ps_codec_amr_dl_reorder2dspformat((void *)JBM_info/*0*/);
+ }
+ else {
+ MD_TRC_SP_PS_CODEC_AMR_DL_DROP_FRAME();
+ }
+#endif //#ifdef __REDUCE_VOLTE_DL_DELAY__
+ }
+}
+
+
+void sp_ps_codec_amr_DL_PutSpeechFrameReOrder(kal_uint32 CFN, kal_uint8 frame_type, kal_bool crc_status, kal_uint8 *subflow, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ uint32 JBM_Nth_Frm = SAL_4G_RX_FIRST_FRM;
+
+ MD_TRC_SP_PS_CODEC_AMR_HSPA_DL_PUT_SPEECH_FRAME(frame_type, frame_type, CFN, crc_status);
+
+#ifdef __OP_IS_AT_AND_T__
+ if( (frame_type == SP4G_CODEC_AMR_NO_DATA) || (frame_type == SP4G_CODEC_LOST_FRAME) || (frame_type == SP4G_CODEC_AMR_SID) || (frame_type == SP4G_CODEC_WBAMR_SID) ){
+ Silence_Detection_set_DLFrameType(0);
+ }
+ else {
+ Silence_Detection_set_DLFrameType(1);
+ }
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+ if( (JBM_info->TS_HB_Frm_Num==2) && (JBM_info->TS_isRemainFrame==0) )
+ {
+ JBM_Nth_Frm = SAL_4G_RX_SECOND_FRM;
+ }
+ //SAL_4G_SetTSSwitch(JBM_info->TS_Switch);
+ SAL_4G_SetTSScale(JBM_info->TS_Scale, JBM_info->TS_Max_Scale, JBM_Nth_Frm);
+ SAL_VOLTE_SetInfo(SAL_VOLTE_INFO_JBM_NODATA_TYPE, JBM_info->Nodata_Type);
+
+ if(SAL_Get_Repeat_Flag())
+ {
+ if(JBM_info->TS_HB_Frm_Num != 0)
+ {
+ SAL_4G_SetDLHBValid(true, JBM_Nth_Frm);
+ }
+ SAL_3G_SetDLReady(); // MCU tell DSP the data is ready
+ return;
+ }
+
+ if( frame_type != AMR_NO_DATA && frame_type != 25 && frame_type != AMR_SID_FRAME && frame_type != SP4G_CODEC_LOST_FRAME ){
+ kal_uint16 I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+
+ K = 0;
+ ptr8_swap = subflow;
+ byte_swap = *ptr8_swap;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = sp_ps_codec_amr_Get_RAB_subflow_spps(frame_type, I);
+ if( rabBitsCount == 0 )
+ break;
+ ptr8 = &spPS->dl_subflow[0];
+ *ptr8 = 0;//reset
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order_spps[K & 7])? RAB_Order_spps[J & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ if( (K&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ sp_ps_codec_amr_DL_PutSpeechFrame3Rab(CFN, I, frame_type, crc_status, spPS->dl_subflow, JBM_info);
+ }
+ } else {
+ sp_ps_codec_amr_DL_PutSpeechFrame3Rab(CFN, 0, frame_type, crc_status, subflow, JBM_info);
+ }
+}
+
+
+void sp_ps_codec_amr_DL_PutSpeechFrame(kal_uint32 CFN, SP4G_PSR_Codec codec, SP4G_Codec frame_type, kal_uint8 *encodebits, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ return;
+ }
+ if(spPS == (SPPS_Struct_t*) 0){
+ return;
+ }
+ //band mismatch . assert
+//#if defined(__G_CODEC_SUPPORT__)
+ if(sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)){
+ MD_TRC_SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_G_SKIP();
+ return;
+ }
+//#endif /*#if defined(__G_CODEC_SUPPORT__)*/
+
+
+#if defined(__EVS_CODEC_SUPPORT__)
+ if(sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)){
+ MD_TRC_SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_RETURN();
+ return;
+ }
+#endif /*#if defined(__EVS_CODEC_SUPPORT__)*/
+
+ if(NULL != encodebits){
+ MD_TRC_SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME(codec, codec, frame_type, frame_type, spPS->ul_codec_mode);
+ ASSERT( (codec ==SP4G_PSR_AMR && spPS->ul_codec_mode >= 0x03 && spPS->ul_codec_mode <= 0x0A) ||
+ (codec ==SP4G_PSR_WBAMR && spPS->ul_codec_mode >= 0x20 && spPS->ul_codec_mode <= 0x28)
+ );
+
+ ASSERT( (frame_type >= SP4G_CODEC_AMR_4_75 && frame_type <= SP4G_CODEC_AMR_SID && spPS->ul_codec_mode >= 0x03 && spPS->ul_codec_mode <= 0x0A) ||
+ (frame_type >= SP4G_CODEC_WBAMR_6_6 && frame_type <= SP4G_CODEC_WBAMR_SID && spPS->ul_codec_mode >= 0x20 && spPS->ul_codec_mode <= 0x28)
+ );
+
+ sp_ps_codec_amr_DL_PutSpeechFrameReOrder(CFN, frame_type, crc_status, encodebits, JBM_info);
+
+ // SP_updateEmCodec(false, 0, true, convert_SP4G_CODEC_AMR_AMRWB_to_SPH_CODEC(frame_type));
+ }else{
+ MD_TRC_SP_PS_CODEC_AMR_PSR_DL_AMR_PUTSPEECHFRAME_LOST_FRAME();
+
+ sp_ps_codec_amr_DL_PutSpeechFrameReOrder(CFN, SP4G_CODEC_LOST_FRAME, crc_status, encodebits_null, JBM_info);
+
+ // SP_updateEmCodec(false, 0, true, SPH_CODEC_LOST_FRAME);
+ }
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->dl_delay = 0;
+ spPS->dl_waiting = KAL_FALSE;
+ kal_give_spinlock(spinlock_sp4g);
+}
+
+
diff --git a/mcu/driver/audio/src/v1/sp_ps_codec_evs.c b/mcu/driver/audio/src/v1/sp_ps_codec_evs.c
new file mode 100644
index 0000000..5332046
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_codec_evs.c
@@ -0,0 +1,1528 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_evs.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching EVS speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "sync_data.h"
+
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "media.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "dcl.h"
+#include "drv_sap.h"
+#include "ltecsr_msgid.h"
+#include "audio_msgid.h"
+//for SP_is_codec_mute()
+#include "sp_drv.h"
+
+#include "sal_exp.h"
+
+#include "sp_ps.h"
+#include "sp_ps_aam.h"
+#include "sp_ps_codec_evs.h"
+#include "sp_ps_codec_g.h"
+
+/*****************************
+Definitions
+*****************************/
+
+
+/*****************************
+External variables
+*****************************/
+extern SPPS_Struct_t *spPS;
+extern kal_spinlockid spinlock_sp4g;
+extern const uint8 RAB_Order_spps[8];
+extern const uint16 DSP_Order_spps[16];
+extern const kal_uint16* tblAMR_WBOrder[9];
+
+
+/*****************************
+External functions
+*****************************/
+void spPS_reset_flag_set(kal_uint8 val);
+kal_uint8 spPS_reset_flag_get(void);
+kal_bool spPS_IsDTXOn(void);
+kal_bool spPS_Rab_State_get(void);
+kal_uint32 get_is_fake_4g(void);
+void sp_ps_reset_internal(void);
+
+
+/*****************************
+Local variables
+*****************************/
+#if 1
+#if defined(__EVS_CODEC_SUPPORT__)
+const uint16 EVS_Primary_FrameBitLength[16] =
+{
+ ( 56), // 2.8k
+ ( 144), // 7.2k
+ ( 160), // 8.0k
+ ( 192), // 9.6k
+ ( 264), // 13.2k
+ ( 328), // 16.4k
+ ( 488), // 24.4k
+ ( 640), // 32.0k
+ ( 960), // 48.0k
+ (1280), // 64.0k
+ (1920), // 96.0k
+ (2560), //128.0k
+ ( 48), // 2.4k SID
+ ( 0), //NON
+ ( 0), //Lost
+ ( 0) //No data
+};
+
+const uint16 EVS_AWB_RAB_subflow[16][5] = {
+/* TS26.201, Table 7 */
+ {54, 78, 0, 17, 132},/* WB type 0, AMR-WB 6.60 */
+ {64, 113, 0, 23, 177},/* WB type 1, AMR-WB 8.85 */
+ {72, 181, 0, 32, 253},/* WB type 2, AMR-WB 12.65 */
+ {72, 213, 0, 36, 285},/* WB type 3, AMR-WB 14.25 */
+ {72, 245, 0, 40, 317},/* WB type 4, AMR-WB 15.85 */
+ {72, 293, 0, 46, 365},/* WB type 5, AMR-WB 18.25 */
+ {72, 325, 0, 50, 397},/* WB type 6, AMR-WB 19.85 */
+ {72, 389, 0, 58, 461},/* WB type 7, AMR-WB 23.05 */
+ {72, 405, 0, 60, 477},/* WB type 8, AMR-WB 23.85 */
+ {40, 0, 0, 5, 40},/* WB type 9, AMR-WB SID */
+ { 0, 0, 0, 0, 0},/* WB type 10, AMR-WB REV0 */
+ { 0, 0, 0, 0, 0},/* WB type 11, AMR-WB REV1 */
+ { 0, 0, 0, 0, 0},/* WB type 12, AMR-WB REV2 */
+ { 0, 0, 0, 0, 0},/* WB type 13, AMR-WB REV3 */
+ { 0, 0, 0, 0, 0},/* WB type 14, AMR-WB LOST */
+ { 0, 0, 0, 0, 0} /* WB type 15, AMR-WB NODATA */
+};
+static const uint8 EVS_AWB_last_sub_flow_id[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0};
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+
+#endif //#if 0
+
+__attribute__((aligned (4))) unsigned char EVS_enc_HB_rb_array[EVS_CODEC_FRAME_RB_BYTE_SIZE];
+__attribute__((aligned (4))) unsigned char EVS_one_UL_HB_buffer[(EVS_CODEC_FRAME_BYTE_SIZE+sizeof(EVS_frame_header_t))];
+__attribute__((aligned (4))) unsigned char EVS_one_UL_HB_buffer_temp[(EVS_CODEC_FRAME_BYTE_SIZE+sizeof(EVS_frame_header_t))];
+__attribute__((aligned (4))) unsigned char EVS_one_DL_HB_buffer[(EVS_CODEC_FRAME_BYTE_SIZE+sizeof(EVS_frame_header_t))];
+StreamRB EVS_HB_ul_rb_buf;
+EVS_ENCODER_PARAMETER EVS_EncPar;
+EVS_DECODER_PARAMETER EVS_DecPar;
+SP4G_CODEC_EVS_AWB_SID_TYPE SP4G_EVS_AWB_DL_SID_Type;
+static kal_uint8 encodebits_null[32];
+
+
+/*****************************
+Local functions
+*****************************/
+bool sp_ps_codec_evs_is_EVS_codec(uint8 codec)
+{
+ if( (SP4G_CODEC_EVS_08K_005_9 <= codec) && (SP4G_CODEC_EVS_08K_128_0 >= codec) )
+ return true;
+ if( (SP4G_CODEC_EVS_16K_005_9 <= codec) && (SP4G_CODEC_EVS_16K_128_0 >= codec) )
+ return true;
+ if( (SP4G_CODEC_EVS_32K_005_9 <= codec) && (SP4G_CODEC_EVS_32K_128_0 >= codec) )
+ return true;
+ if( (SP4G_CODEC_EVS_48K_005_9 <= codec) && (SP4G_CODEC_EVS_48K_128_0 >= codec) )
+ return true;
+ if( (SP4G_CODEC_EVS_AWB_06_60 <= codec) && (SP4G_CODEC_EVS_AWB_23_85 >= codec) )
+ return true;
+ return false;
+}
+
+
+kal_bool convert_AWB_to_EVSIOEnum(SP4G_Codec input_speech_codec, SP4G_Codec *poutput_SP4G_Codec)
+{
+ kal_bool retval;
+ unsigned char u8codec = (unsigned char)input_speech_codec;
+
+ if( (input_speech_codec >= SP4G_CODEC_WBAMR_6_6) && (input_speech_codec <= SP4G_CODEC_WBAMR_23_85) )
+ {
+ u8codec = u8codec - ((unsigned char)SP4G_CODEC_WBAMR_6_6) + ((unsigned char)SP4G_CODEC_EVS_AWB_06_60);
+ *poutput_SP4G_Codec = (SP4G_Codec)u8codec;
+ retval = KAL_TRUE;
+ }
+ else if( input_speech_codec == SP4G_CODEC_WBAMR_SID )
+ {
+ *poutput_SP4G_Codec = SP4G_CODEC_EVS_AWB_02_00_SID;
+ retval = KAL_TRUE;
+ }
+ else if( input_speech_codec == AMR_NO_DATA )
+ {
+ *poutput_SP4G_Codec = SP4G_CODEC_EVS_AWB_00_00_NODATA;
+ retval = KAL_TRUE;
+ }
+ else
+ {
+ *poutput_SP4G_Codec = input_speech_codec;
+ retval = KAL_FALSE;
+ }
+
+ return(retval);
+}
+
+
+kal_bool convert_EVSIO_to_AWBEnum(SP4G_Codec input_speech_codec, SP4G_Codec *poutput_SP4G_Codec)
+{
+ kal_bool retval;
+ unsigned char u8codec = (unsigned char)input_speech_codec;
+
+ if( (input_speech_codec >= SP4G_CODEC_EVS_AWB_06_60) && (input_speech_codec <= SP4G_CODEC_EVS_AWB_23_85) )
+ {
+ u8codec = u8codec - ((unsigned char)SP4G_CODEC_EVS_AWB_06_60) + ((unsigned char)SP4G_CODEC_WBAMR_6_6);
+ *poutput_SP4G_Codec = (SP4G_Codec)u8codec;
+ retval = KAL_TRUE;
+ }
+ else if( input_speech_codec == SP4G_CODEC_EVS_AWB_02_00_SID )
+ {
+ *poutput_SP4G_Codec = SP4G_CODEC_WBAMR_SID;
+ retval = KAL_TRUE;
+ }
+ else if( input_speech_codec == SP4G_CODEC_EVS_AWB_00_00_NODATA )
+ {
+ *poutput_SP4G_Codec = AMR_NO_DATA;
+ retval = KAL_TRUE;
+ }
+ else
+ {
+ *poutput_SP4G_Codec = input_speech_codec;
+ retval = KAL_FALSE;
+ }
+
+ return(retval);
+}
+
+
+void sp_ps_codec_evs_SetEVSEncCAPara(EVS_ENC_CA_PARAMETER *pEVS_CA_Par)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ EVS_EncPar.EVS_CA_Par.enable = pEVS_CA_Par->enable;
+ EVS_EncPar.EVS_CA_Par.rf_fec_indicator = pEVS_CA_Par->rf_fec_indicator;
+ EVS_EncPar.EVS_CA_Par.rf_fec_offset = pEVS_CA_Par->rf_fec_offset;
+ EVS_EncPar.EVS_CA_Par.rev3 = pEVS_CA_Par->rev3;
+ EVS_EncPar.EVS_CA_Par.rev4 = pEVS_CA_Par->rev4;
+ EVS_EncPar.EVS_CA_Par.rev5 = pEVS_CA_Par->rev5;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+
+void sp_ps_codec_evs_SetEVSDecCAPara(EVS_DEC_CA_PARAMETER *pEVS_CA_Par)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ EVS_DecPar.EVS_CA_Par.FrameMode = pEVS_CA_Par->FrameMode;
+ EVS_DecPar.EVS_CA_Par.rev1 = pEVS_CA_Par->rev1;
+ EVS_DecPar.EVS_CA_Par.rev2 = pEVS_CA_Par->rev2;
+ EVS_DecPar.EVS_CA_Par.rev3 = pEVS_CA_Par->rev3;
+ EVS_DecPar.EVS_CA_Par.rev4 = pEVS_CA_Par->rev4;
+ EVS_DecPar.EVS_CA_Par.rev5 = pEVS_CA_Par->rev5;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void EVS_encoder_prepare_parameter(EVS_ENCODER_PARAMETER *pEVS_Enc_Par)
+{
+ pEVS_Enc_Par->codec = spPS->ul_codec_mode;
+ pEVS_Enc_Par->DTX = spPS_IsDTXOn();//spPS_dtx_mode;
+ pEVS_Enc_Par->EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(pEVS_Enc_Par->codec/*EVS_EncPar.codec*/);
+ pEVS_Enc_Par->EVS_capability_bw = EVS_CAPABILITY_BW;
+ pEVS_Enc_Par->EVS_PCM_bw = EVS_PCM_BW;
+ //MD_TRC_SP_PS_CODEC_EVS_ENCODER_PREPARE_PARAMETER1(pEVS_Enc_Par->EVS_network_request_bw, pEVS_Enc_Par->EVS_capability_bw, pEVS_Enc_Par->EVS_PCM_bw, pEVS_Enc_Par->codec, pEVS_Enc_Par->codec, pEVS_Enc_Par->DTX, EVS_EncPar.EVS_CA_Par.enable);
+}
+
+
+void EVS_decoder_prepare_parameter(EVS_DECODER_PARAMETER *pEVS_Decoder_Par, kal_int32 bitlen, kal_int32 BFI, SP4G_Codec codec_local)
+{
+ pEVS_Decoder_Par->codec = codec_local;
+ pEVS_Decoder_Par->EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(spPS->ul_codec_mode);
+ pEVS_Decoder_Par->EVS_capability_bw = EVS_CAPABILITY_BW;
+ pEVS_Decoder_Par->EVS_PCM_bw = EVS_PCM_BW;
+ pEVS_Decoder_Par->EVS_HBLen = bitlen;
+ pEVS_Decoder_Par->EVS_BFI = BFI;
+ //MD_TRC_SP_PS_CODEC_EVS_DECODER_PREPARE_PARAMETER(pEVS_Decoder_Par->EVS_network_request_bw, pEVS_Decoder_Par->EVS_capability_bw, pEVS_Decoder_Par->EVS_PCM_bw, pEVS_Decoder_Par->EVS_HBLen, pEVS_Decoder_Par->EVS_BFI);
+}
+
+
+void sp_ps_codec_evs_CallOpenSetPar(void)
+{
+ EVS_encoder_prepare_parameter(&EVS_EncPar);
+ SAL_EVS_Set_Enc_Par(&EVS_EncPar);
+ EVS_decoder_prepare_parameter(&EVS_DecPar, 0, 0, spPS->ul_codec_mode);
+ SAL_EVS_Set_Dec_Par(&EVS_DecPar, SAL_4G_RX_FIRST_FRM);
+}
+
+
+SP4G_CODEC_EVS_AWB_SID_TYPE EVS_decoder_get_SID_type(void)
+{
+ return(SP4G_EVS_AWB_DL_SID_Type);
+}
+
+
+void EVS_decoder_execute(SP4G_Codec frame_type, EVS_DECODER_PARAMETER *pEVS_Decoder_Par, kal_uint8 *encodebits, kal_int32 bitlen, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ uint16 JBM_Nth_Frm = SAL_4G_RX_FIRST_FRM;
+
+ if( (JBM_info->TS_HB_Frm_Num==2) && (JBM_info->TS_isRemainFrame==0) )
+ {
+ JBM_Nth_Frm = SAL_4G_RX_SECOND_FRM;
+ }
+
+ //SAL_4G_SetTSSwitch(JBM_info->TS_Switch);
+ SAL_4G_SetTSScale(JBM_info->TS_Scale, JBM_info->TS_Max_Scale, JBM_Nth_Frm);
+ SAL_VOLTE_SetInfo(SAL_VOLTE_INFO_JBM_NODATA_TYPE, JBM_info->Nodata_Type);
+
+ if(SAL_Get_Repeat_Flag())
+ {
+ if(JBM_info->TS_HB_Frm_Num != 0)
+ {
+ SAL_4G_SetDLHBValid(true, JBM_Nth_Frm);
+ }
+ SAL_3G_SetDLReady(); // MCU tell DSP the data is ready
+ return;
+ }
+
+ SAL_EVS_Set_Dec_Par(pEVS_Decoder_Par, JBM_Nth_Frm);
+
+ if(SP4G_EVS_AWB_DL_SID_Type == SP4G_CODEC_EVS_AWB_SID_TYPE_FIRST)
+ {
+ SAL_EVS_Set_Dec_SIDFirst_Status(KAL_TRUE, JBM_Nth_Frm);
+ }
+ else
+ {
+ SAL_EVS_Set_Dec_SIDFirst_Status(KAL_FALSE, JBM_Nth_Frm);
+ }
+
+ if( bitlen != 0 )
+ {
+ kal_int32 I;
+ volatile uint8 *addr;
+ kal_int32 rx_len;
+
+ addr = (volatile uint8*)SAL_4G_GetRXAddr(SAL_4G_ADDR_RXHB, JBM_Nth_Frm); //SAL_3G_GetAddr(SAL_3G_ADDR_RXHB);
+ rx_len = (bitlen+7) >> 3;
+ if( GET_IS_SP4G_CODEC_ENUM_EVS_AMRIO_ID(frame_type) )
+ {
+ rx_len = ((rx_len+1)>>1)<<1;
+ }
+ for(I=0; I<rx_len; I++)
+ addr[I] = encodebits[I];
+ Data_Sync_Barrier();
+ }
+
+ if(JBM_info->TS_HB_Frm_Num != 0)
+ {
+ SAL_4G_SetDLHBValid(true, JBM_Nth_Frm);
+ }
+ SAL_3G_SetDLReady(); // MCU tell DSP the data is ready
+}
+
+void sp_ps_codec_evs_hisr_dl_EVS(void *data)
+{
+ enum_EVS_NOTIFY_LTECSR_MSG notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_ERROR;
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ ASSERT(spPS != (SPPS_Struct_t*) 0);
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)) )
+ {
+ MD_TRC_SPPS_DL_HISR_SKIP(L1SP_GetState(), sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode));
+ kal_give_spinlock(spinlock_sp4g);
+ return;
+ }
+
+ if(SP_is_codec_mute())
+ {
+ if(KAL_TRUE == spPS_Rab_State_get())
+ {
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_MUTE;
+ MD_TRC_SP_PS_CODEC_UL_SKIP_NOTIFY();
+ }
+ }
+ else
+ {
+/*
+ if( spPS->dl_waiting == KAL_FALSE ){
+*/
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_DATA;
+ spPS->dl_waiting = KAL_TRUE;
+ }
+/*
+ }
+ else{
+ spPS->dl_delay ++;
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_NON;
+ MD_TRC_SP_PS_CODEC_DL_DELAY( spPS->dl_delay );
+ SP_PS_CALL_DBG_ASSERT(0);
+ }
+ }
+*/
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+ switch(notify_MSG_type)
+ {
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_ERROR:
+ MD_TRC_SP_PS_CODEC_EVS_HISR_DL_ERROR();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_DATA:
+ PSR_SP4G_Callback( SP4G_DL_DATA_NOTIFY, (void*)0 );
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_DL_DATA();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_MUTE:
+ PSR_SP4G_Callback( SP4G_DL_MUTE_NOTIFY, (void*)0 );
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_DL_MUTE();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_NON:
+ default:
+ MD_TRC_SP_PS_CODEC_EVS_HISR_DL_NON();
+ break;
+ }
+}
+
+void sp_ps_codec_evs_hisr_ul_EVS(void *data)
+{
+ int I;
+ int J = 0;
+ int K;
+ int len;
+ uint8 *ptr8;
+ volatile uint8 *EVS_HB_addr;
+ EVS_frame_header_t ul_header;
+ enum_EVS_NOTIFY_LTECSR_MSG notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_ERROR;
+ int valid_data = 0;
+
+ uint16 *ptr16;
+ const uint8* RAB_To_DSP_Mapping;
+ uint16 total_bits, idx, rabBitsCount;
+ uint8 EVS_codec_rate = 0;
+ uint8 bit8Data;
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+
+ /**************************/
+ // Get UL HB
+ /**************************/
+ if( SAL_3G_IsULReady() )
+ {
+ spPS->ul_report = SAL_3G_GetValue(SAL_3G_VALUE_TX_CODEC_MODE);
+ if( spPS->ul_report != spPS->pre_ul_report )
+ {
+ MD_TRC_L1Audio_Msg_SPEECH_CODEC( L1SP_Speech_Codec_Mode(spPS->ul_report), L1SP_Speech_Codec_Mode(spPS->dl_report) );
+ spPS->pre_ul_report = spPS->ul_report;
+ }
+
+ //check encoder output codec type
+ if( !GET_IS_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_report) )
+ {
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_ASSERT_ID(spPS->ul_report);
+ spPS->ul_report = SET_SP4G_CODEC_ENUM_EVS_RATE( (spPS->ul_codec_mode), SP4G_CODEC_EVS_000_0_NODATA);
+ }
+
+ ul_header.magicid = 0xFFAA;
+ ul_header.codec = spPS->ul_report;
+ EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(ul_header.codec);
+ if(SP4G_CODEC_EVS_ID == GET_SP4G_CODEC_ENUM_EVS_ID(ul_header.codec))
+ {
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_PROCESS_EVS_HB();
+
+ ASSERT( (SP4G_CODEC_EVS_000_0_REV!=EVS_codec_rate) && (SP4G_CODEC_EVS_000_0_LOST!=EVS_codec_rate) );
+
+#ifdef __OP_IS_AT_AND_T__
+ if( (EVS_codec_rate == SP4G_CODEC_EVS_002_4_SID) || (EVS_codec_rate == SP4G_CODEC_EVS_000_0_NODATA) ){
+ Silence_Detection_set_ULFrameType(0);
+ }
+ else {
+ Silence_Detection_set_ULFrameType(1);
+ }
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+ len = EVS_Primary_FrameBitLength[EVS_codec_rate];
+ ul_header.bit_len = len;
+ len = (len + 7) >> 3;
+ ul_header.byte_len = len;
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_UL_BIT_LEN(ul_header.bit_len);
+
+ if(len)
+ {
+ ptr8 = EVS_one_UL_HB_buffer_temp;
+ EVS_HB_addr = (volatile uint8 *)SAL_3G_GetAddr(SAL_3G_ADDR_TXHB);//EVS_encoder_get_HBAddr();
+ for(I = len; --I >= 0 ; )
+ {
+ *ptr8++ = *EVS_HB_addr++;
+ }
+ }
+ valid_data = 1;
+ //fsju, move the the end of UL HISR? SP4G_PSR_UL_EVS_GetSpeechFrame()?
+ EVS_encoder_prepare_parameter(&EVS_EncPar);
+ SAL_EVS_Set_Enc_Par(&EVS_EncPar);
+ //Ckear SAL_3G_IsULReady()
+ SAL_3G_SetULEmpty();
+ }
+ else
+ {
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_UL_PROCESS_AWB_HB();
+ ul_header.byte_len = EVS_AWB_RAB_subflow[EVS_codec_rate][3];
+ ul_header.bit_len = EVS_AWB_RAB_subflow[EVS_codec_rate][4];
+ len = ul_header.byte_len;
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_UL_PROCESS_AWB_HB_LEN(len);
+
+ if(len)
+ {
+ ptr8 = (uint8 *)EVS_one_UL_HB_buffer_temp;
+ EVS_HB_addr = (volatile uint8 *)SAL_3G_GetAddr(SAL_3G_ADDR_TXHB);//EVS_encoder_get_HBAddr();
+ for(I = (((len+1)>>1)<<1); --I >= 0 ; )
+ {
+ *ptr8++ = *EVS_HB_addr++;
+ }
+ }
+
+ //fsju, move the the end of UL HISR? SP4G_PSR_UL_EVS_GetSpeechFrame()?
+ EVS_encoder_prepare_parameter(&EVS_EncPar);
+ SAL_EVS_Set_Enc_Par(&EVS_EncPar);
+ //Ckear SAL_3G_IsULReady()
+ SAL_3G_SetULEmpty();
+
+ // do bit re-ordering
+ ptr16 = (uint16*)EVS_one_UL_HB_buffer_temp;
+
+ ptr8 = (uint8*)spPS->ul_buffer[0];
+ switch( EVS_codec_rate )
+ {
+ case SP4G_CODEC_EVS_AWB_RATE_06_60:
+ case SP4G_CODEC_EVS_AWB_RATE_08_85:
+ case SP4G_CODEC_EVS_AWB_RATE_12_65:
+ case SP4G_CODEC_EVS_AWB_RATE_14_25:
+ case SP4G_CODEC_EVS_AWB_RATE_15_85:
+ case SP4G_CODEC_EVS_AWB_RATE_18_25:
+ case SP4G_CODEC_EVS_AWB_RATE_19_85:
+ case SP4G_CODEC_EVS_AWB_RATE_23_05:
+ case SP4G_CODEC_EVS_AWB_RATE_23_85:
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(1);
+#endif //#ifdef __OP_IS_AT_AND_T__
+ len = ul_header.byte_len;
+ RAB_To_DSP_Mapping = (const uint8 *)tblAMR_WBOrder[EVS_codec_rate];
+ total_bits = EVS_AWB_RAB_subflow[EVS_codec_rate][4];
+
+ for(I = len; --I >= 0; *ptr8++ = 0);
+
+ //should check DSP order is the same as EVS order?????
+ for(idx = 0, ptr8 -= len, I = 0; I < 3; I ++)
+ {
+ const uint16* WB_RAB_To_DSP_Mapping;
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][I];
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit8Data = (ptr16[K >> 4] & DSP_Order_spps[K & 15])? RAB_Order_spps[J & 0x7] : 0;
+ ptr8[J >> 3] |= bit8Data;
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+ ASSERT(idx == total_bits);
+
+ ptr8 = (uint8*)spPS->ul_buffer[0];
+ for(I=0; I<ul_header.byte_len; I++)
+ {
+ EVS_one_UL_HB_buffer_temp[I] = ptr8[I];
+ }
+ valid_data = 1;
+ MD_TRC_SP_PS_CODEC_TX_SPEECH_GOOD();
+ break;
+
+ case SP4G_CODEC_EVS_AWB_RATE_02_00_SID:
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(0);
+#endif //#ifdef __OP_IS_AT_AND_T__
+ if( SAL_EVS_Get_Enc_SIDFirst_Status() )
+ {
+ //SID first
+ for(I=0; I<5; I++)
+ {
+ EVS_one_UL_HB_buffer_temp[I] = 0;
+ }
+ EVS_one_UL_HB_buffer_temp[4] = (uint8)((spPS->ul_codec_mode)&0x0F);
+ valid_data = 1;
+ MD_TRC_SP_PS_CODEC_TX_SID_FIRST();
+ }
+ else
+ {
+ //SID update
+ for(I=0; I<5; I++)
+ {
+ ptr8[I] = 0;
+ }
+ for(I = 0; I < 35; I ++)
+ {
+ bit8Data = (ptr16[I >> 4] & DSP_Order_spps[I & 15])? RAB_Order_spps[I & 0x7] : 0;
+ ptr8[I >> 3] |= bit8Data;
+ }
+ ptr8[4] |= ((uint8)((spPS->ul_codec_mode)&0x0F)) | 0x10;
+
+ for(I=0; I<5; I++)
+ {
+ EVS_one_UL_HB_buffer_temp[I] = ptr8[I];
+ }
+ valid_data = 1;
+ MD_TRC_SP_PS_CODEC_TX_SID_UPDATE();
+ }
+ break;
+
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_NODATA:
+#ifdef __OP_IS_AT_AND_T__
+ Silence_Detection_set_ULFrameType(0);
+#endif //#ifdef __OP_IS_AT_AND_T__
+ valid_data = 1;
+ MD_TRC_SP_PS_CODEC_TX_NO_DATA();
+ break;
+
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_REV0:
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_REV1:
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_REV2:
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_REV3:
+ case SP4G_CODEC_EVS_AWB_RATE_00_00_LOST:
+ default :
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_AWB_INVALID_CODEC_RATE(ul_header.codec);
+ ASSERT(0);
+ break;
+ }
+ }
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_ENC_NOT_FINISH(EVS_AWB_RAB_subflow[EVS_codec_rate][3]);
+ SAL_3G_SetULUnsync();
+ valid_data = 0;
+ }
+
+ if(SP_is_codec_mute())
+ {
+ if(KAL_TRUE == spPS_Rab_State_get())
+ {
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_MUTE;
+ MD_TRC_SP_PS_CODEC_UL_SKIP_NOTIFY();
+ }
+ }
+ else
+ {
+ if( spPS->ul_waiting == KAL_FALSE ){
+ if( spPS->sp4g_mode == RAT_4G_MODE ){
+ if(valid_data)
+ {
+ ASSERT( (sizeof(ul_header)+ul_header.byte_len) <= StreamRB_GetFreeSpace(&EVS_HB_ul_rb_buf) );
+ StreamRB_Write(&EVS_HB_ul_rb_buf, (uint8*)&ul_header, sizeof(ul_header)/sizeof(uint8));
+ if(ul_header.byte_len)
+ {
+ StreamRB_Write(&EVS_HB_ul_rb_buf, EVS_one_UL_HB_buffer_temp, ul_header.byte_len);
+ }
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_DATA;
+ spPS->ul_waiting = KAL_TRUE;
+ }
+ else
+ {
+ //process as other type?
+ ;
+ }
+ }
+ }
+ else{
+ spPS->ul_delay ++;
+ if( spPS->sp4g_mode == RAT_4G_MODE )
+ {
+ notify_MSG_type = ENUM_EVS_NOTIFY_LTECSR_MSG_NON;
+ MD_TRC_SP_PS_CODEC_UL_DELAY(spPS->ul_delay);
+ if (spPS->ul_delay >= UL_DELAY_THRESHOLD)
+ {
+ SP_PS_CALL_DBG_ASSERT(0);
+ }
+ }
+ }
+ }
+
+ kal_give_spinlock(spinlock_sp4g);
+
+ switch(notify_MSG_type)
+ {
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_ERROR:
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_ERROR();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_DATA:
+ PSR_SP4G_Callback( SP4G_UL_DATA_NOTIFY, (void*)0 );
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_UL_DATA();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_MUTE:
+ PSR_SP4G_Callback( SP4G_UL_MUTE_NOTIFY, (void*)0 );
+ //MD_TRC_SP_PS_CODEC_EVS_HISR_UL_MUTE();
+ break;
+ case ENUM_EVS_NOTIFY_LTECSR_MSG_NON:
+ default:
+ MD_TRC_SP_PS_CODEC_EVS_HISR_UL_NON();
+ break;
+ }
+
+}
+
+
+void SP_PS_codec_EVS_UL_EVS_GetSpeechFrame(SP4G_Codec *frame_type, kal_uint8 *rab_byte_array, kal_int32 *bitlen)
+{
+ EVS_frame_header_t tmp_hdr;
+
+ if( (L1SP_STATE_4G_SPEECH_ON != L1SP_GetState()) || (!sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode)) || (spPS == (SPPS_Struct_t*) 0) )
+ {
+ *frame_type = SP4G_CODEC_EVS_16K_000_0_NODATA;
+ *bitlen = 0;
+ return;
+ }
+
+
+ if(1 == spPS_reset_flag_get())
+ {
+ //This will set spPS_reset_flag=0, and clear EVS_HB_ul_rb_buf
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ sp_ps_reset_internal();
+ kal_give_spinlock(spinlock_sp4g);
+
+ if( SP4G_CODEC_EVS_ID == GET_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) )
+ {
+ *frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(spPS->ul_codec_mode, SP4G_CODEC_EVS_000_0_NODATA);
+ }
+ else
+ {
+ *frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(spPS->ul_codec_mode, SP4G_CODEC_EVS_AWB_RATE_00_00_NODATA);
+ }
+ *bitlen = 0;
+ MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME();
+ return;
+ }
+
+ //MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_EVS_HB_UL_RB_BUF_FREE_SPACE(StreamRB_GetFreeSpace(&EVS_HB_ul_rb_buf));
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ if(0 < StreamRB_GetDataCount(&EVS_HB_ul_rb_buf))
+ {
+ StreamRB_Read(&EVS_HB_ul_rb_buf, (uint8 *)&tmp_hdr, sizeof(tmp_hdr)/sizeof(uint8));
+ ASSERT(tmp_hdr.magicid == 0xFFAA);
+ }
+ else
+ {
+ kal_give_spinlock(spinlock_sp4g);
+ MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_EVS_HB_UL_RB_BUF_EMPTY();
+ ASSERT(0);
+ }
+ if( GET_IS_SP4G_CODEC_ENUM_EVS_ID(tmp_hdr.codec) && GET_IS_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) )
+ {
+ if(tmp_hdr.byte_len)
+ {
+ StreamRB_Read(&EVS_HB_ul_rb_buf, rab_byte_array, tmp_hdr.byte_len);
+ }
+ }
+ else
+ {
+ if(tmp_hdr.byte_len)
+ {
+ StreamRB_ShiftReadPointer(&EVS_HB_ul_rb_buf, tmp_hdr.byte_len);
+ }
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+ //MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_HEADER_INFO(tmp_hdr.magicid, tmp_hdr.codec, tmp_hdr.codec, tmp_hdr.byte_len, tmp_hdr.bit_len);
+
+ if( GET_IS_SP4G_CODEC_ENUM_EVS_ID(tmp_hdr.codec) && GET_IS_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) )
+ {
+ *frame_type = tmp_hdr.codec;
+ *bitlen = tmp_hdr.bit_len;
+
+ //MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_INFO(*frame_type, *frame_type, *bitlen);
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_MISMATCH_CODEC(tmp_hdr.codec, spPS->ul_codec_mode);
+
+ if( SP4G_CODEC_EVS_ID == GET_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) )
+ {
+ *frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(spPS->ul_codec_mode, SP4G_CODEC_EVS_000_0_NODATA);
+ *bitlen = 0;
+ }
+ else if( SP4G_CODEC_EVS_AWB_ID == GET_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) )
+ {
+ *frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(spPS->ul_codec_mode, SP4G_CODEC_EVS_AWB_RATE_00_00_NODATA);
+ *bitlen = 0;
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_INVALID_CODEC(spPS->ul_codec_mode);
+ ASSERT(0);
+ }
+ }
+
+}
+
+
+int sp_ps_codec_evs_UL_GetSpeechFrame(SP4G_Codec *frame_type, uint8 *encodebits, kal_int32 *bitlen)
+{
+ kal_uint16 I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+ uint8 EVS_codec_rate = 0;
+
+ ASSERT(spPS->ul_waiting == KAL_TRUE); // 1 message 1 get ,
+
+ SP_PS_codec_EVS_UL_EVS_GetSpeechFrame(frame_type, encodebits, bitlen);
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->ul_delay = 0;
+ spPS->ul_waiting = KAL_FALSE;
+ kal_give_spinlock(spinlock_sp4g);
+
+
+ //MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_BYTE_ALIGN_3RAB();
+
+ //AWB, merge 3 RAB to IF1
+ if( ((*frame_type)>=SP4G_CODEC_EVS_AWB_06_60) && ((*frame_type)<=SP4G_CODEC_EVS_AWB_23_85) )
+ {
+ MD_TRC_SP_PS_CODEC_EVS_UL_GETSPEECHFRAME_MERGE_3RAB_TO_IF1();
+ EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE((*frame_type));
+ ptr8 = encodebits;
+ ptr8_swap = encodebits;
+ byte_swap = *ptr8_swap;
+ *ptr8 = 0;
+ K = 0;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][I];
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order_spps[J & 7])? RAB_Order_spps[K & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ if( (K&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ }
+ if( (J&7) != 0 ){ // avoid false advance a byte
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ }
+
+ MD_TRC_SP_PS_CODEC_UL_GET_SPEECH_FRAME(*frame_type, *bitlen);
+
+ return 0;
+}
+
+
+// do bit reorder here
+void sp_ps_codec_evs_DL_EVS_PutSpeechFrame_ReorderAWB(uint32 CFN, SP4G_Codec frame_type)
+{
+ int32 I, J = 0, K;
+ uint16 *ptr16;
+ uint16 rx_len = 0;
+ uint8 *ptr8;
+ const uint16* RAB_To_DSP_Mapping;
+ const uint8* Order = NULL;
+ uint16 total_bits, idx, rabBitsCount;
+ uint16 bit16Data;
+ uint8 sidData;
+ //bool FQI_flag = false;
+ uint8 EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(frame_type);
+
+ //MD_TRC_SP_PS_CODEC_EVS_DL_PUTSPEECHFRAME_REORDERAWB_ENTER();
+
+ ptr8 = (uint8*) spPS->dl_buffer[0];
+ ptr16 = (uint16*) EVS_one_DL_HB_buffer;
+
+ switch(frame_type)
+ {
+ case SP4G_CODEC_EVS_AWB_06_60:
+ case SP4G_CODEC_EVS_AWB_08_85:
+ case SP4G_CODEC_EVS_AWB_12_65:
+ case SP4G_CODEC_EVS_AWB_14_25:
+ case SP4G_CODEC_EVS_AWB_15_85:
+ case SP4G_CODEC_EVS_AWB_18_25:
+ case SP4G_CODEC_EVS_AWB_19_85:
+ case SP4G_CODEC_EVS_AWB_23_05:
+ case SP4G_CODEC_EVS_AWB_23_85:
+ RAB_To_DSP_Mapping = (const uint16 *) tblAMR_WBOrder[EVS_codec_rate];
+ rx_len = EVS_AWB_RAB_subflow[EVS_codec_rate][3];
+ rx_len = ((rx_len+1)>>1);
+ total_bits = EVS_AWB_RAB_subflow[EVS_codec_rate][4];
+
+ for(I=0; I<rx_len; I++)
+ ptr16[I] = 0;
+
+ idx = 0;
+ for(I = 0; I < 3; I ++)
+ {
+ const uint16* WB_RAB_To_DSP_Mapping;
+ if(EVS_AWB_RAB_subflow[EVS_codec_rate][I] == 0)
+ {
+ break;
+ }
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][I];
+ WB_RAB_To_DSP_Mapping = (const uint16*)RAB_To_DSP_Mapping;
+ for(J = 0; J < rabBitsCount; J++)
+ {
+ K = WB_RAB_To_DSP_Mapping[idx++];
+ bit16Data = (ptr8[J >> 3] & RAB_Order_spps[J & 7]) ? DSP_Order_spps[K & 15] : 0;
+ ptr16[K >> 4] |= bit16Data;
+ }
+ ptr8 += (rabBitsCount + 7) >> 3;
+ }
+ ASSERT(idx == total_bits);
+ break;
+
+ case SP4G_CODEC_EVS_AWB_02_00_SID:
+ sidData = ptr8[4];
+ if( sidData & 0x10 )
+ {
+ //SID_UPDATE
+ SP4G_EVS_AWB_DL_SID_Type = SP4G_CODEC_EVS_AWB_SID_TYPE_UPDATE;
+ MD_TRC_SP_PS_CODEC_RX_SID_UPDATE();
+ }
+ else
+ {
+ //SID_FIRST
+ SP4G_EVS_AWB_DL_SID_Type = SP4G_CODEC_EVS_AWB_SID_TYPE_FIRST;
+ MD_TRC_SP_PS_CODEC_RX_SID_FIRST();
+ }
+
+ rx_len = 3;
+ for(I = 3; --I >= 0; )
+ *ptr16++ = 0;
+ ptr16 -= 3;
+
+ J = 0;
+ Order = RAB_Order_spps;
+ for(I = 0; I < 35; I++,J++)
+ {
+ bit16Data = (ptr8[J >> 3] & Order[I & 7])? DSP_Order_spps[I & 15] : 0;
+ ptr16[I >> 4] |= bit16Data;
+ }
+ ;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_00_00_REV0:
+ case SP4G_CODEC_EVS_AWB_00_00_REV1:
+ case SP4G_CODEC_EVS_AWB_00_00_REV2:
+ case SP4G_CODEC_EVS_AWB_00_00_REV3:
+ case SP4G_CODEC_EVS_AWB_00_00_LOST:
+ case SP4G_CODEC_EVS_AWB_00_00_NODATA:
+ default :
+ ASSERT(0);
+ break;
+ }
+
+}
+
+
+void sp_ps_codec_evs_DL_EVS_PutSpeechFrame_SplitAWBtoRAB(uint32 CFN, uint8 sub_flow_id, SP4G_Codec frame_type, uint8 *subflow)
+{
+ int32 I;
+ uint8 *ptr8;
+ uint16 rabBitsCount;
+ uint8 last_id;
+ uint8 EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(frame_type);
+
+ //MD_TRC_SP_PS_CODEC_DL_PUT_SPEECH_FRAME_EVS(sub_flow_id, frame_type);
+
+ if( (frame_type >= SP4G_CODEC_EVS_AWB_06_60) && (frame_type <= SP4G_CODEC_EVS_AWB_02_00_SID) ){
+ //if( sub_flow_id == 0 ) {
+ // MD_TRC_SP_PS_CODEC_DL_BIT_TRUE_TASK(subflow[0], subflow[1],subflow[2],subflow[3],subflow[4]);
+ //}
+ }else{
+ MD_TRC_SP_PS_CODEC_DL_FRM();
+ }
+
+ //MD_TRC_SP_PS_CODEC_EVS_RESET_FLAG_INFO(1, spPS_reset_flag_get());
+
+ last_id = EVS_AWB_last_sub_flow_id[EVS_codec_rate];
+ if( sub_flow_id > last_id )
+ return;
+
+ //MD_TRC_SP_PS_CODEC_EVS_RESET_FLAG_INFO(2, spPS_reset_flag_get());
+
+ ptr8 = spPS->dl_buffer[0];
+ if( sub_flow_id != 0 )
+ {
+ for(I = 0 ; I < sub_flow_id ; I ++)
+ {
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][I];
+ ptr8 += ((rabBitsCount + 7) >> 3);
+ }
+ }
+
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][sub_flow_id];
+
+ for( I = 0; I < ((rabBitsCount + 7) >> 3); I++ ){
+ *ptr8++ = *subflow++;
+ }
+
+ if( sub_flow_id == last_id )
+ {
+ //MD_TRC_SP_PS_CODEC_EVS_RESET_FLAG_INFO(3, spPS_reset_flag_get());
+ sp_ps_codec_evs_DL_EVS_PutSpeechFrame_ReorderAWB(CFN, frame_type);
+ }
+}
+
+
+void sp_ps_codec_evs_DL_EVS_PutSpeechFrame(kal_uint32 CFN, SP4G_Codec frame_type, kal_uint8 *encodebits, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+ int i;
+ kal_int32 bitlen;
+ uint8 EVS_codec_rate = 0;
+#if defined(__SP4G_UL_RESYNC__)
+ bool ul_request_resync;
+ uint32 ctime = ust_get_current_time();
+#endif
+
+ //MD_TRC_SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_PUTEVSFRAME_INFO(CFN, frame_type);
+
+ if( L1SP_STATE_4G_SPEECH_ON != L1SP_GetState() )
+ {
+ return;
+ }
+ if(!sp_ps_codec_evs_is_EVS_codec(spPS->ul_codec_mode))
+ {
+ return;
+ }
+
+ if(0 == spPS_reset_flag_get())
+ {
+ spPS_reset_flag_set(2);
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ ul_request_resync = spPS->request_resync ;
+ if( (ul_request_resync) && (spPS_reset_flag_get() == 2) ) {
+ MD_TRC_SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_1(ul_request_resync, spPS_reset_flag_get(), ctime);
+ MD_TRC_SP_PS_CODEC_UL_SYNC_AM_4G_INTRARAT();
+ AM_4G_INTRARAT(spPS->ul_codec_mode, PS_SRST_TYPE_UNSYNC);
+ //sp_ps_smr_resync_procedure_done();
+ spPS->request_resync = KAL_FALSE;
+ }
+#endif
+
+ EVS_codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(frame_type);
+ if( SP4G_CODEC_EVS_AWB_ID == GET_SP4G_CODEC_ENUM_EVS_ID(frame_type) )
+ {
+#ifdef __OP_IS_AT_AND_T__
+ if( (frame_type == SP4G_CODEC_EVS_AWB_02_00_SID) || (frame_type == SP4G_CODEC_EVS_AWB_00_00_LOST) || (frame_type == SP4G_CODEC_EVS_AWB_00_00_NODATA) ){
+ Silence_Detection_set_DLFrameType(0);
+ }
+ else {
+ Silence_Detection_set_DLFrameType(1);
+ }
+#endif //#ifdef __OP_IS_AT_AND_T__
+
+ SP4G_EVS_AWB_DL_SID_Type = SP4G_CODEC_EVS_AWB_SID_TYPE_NONSID;
+ bitlen = EVS_AWB_RAB_subflow[EVS_codec_rate][4];
+ //By RFC3267, AWB use the IF1 format, refer SP4GHSPA_DL_PutSpeechFrame()
+ if( (frame_type>=SP4G_CODEC_EVS_AWB_06_60) && (frame_type<=SP4G_CODEC_EVS_AWB_02_00_SID) )
+ {
+ kal_uint16 I, J, K, rabBitsCount;
+ kal_uint8 *ptr8, *ptr8_swap, byte_swap, bit8Data;
+
+ K = 0;
+ ptr8_swap = encodebits;
+ byte_swap = *ptr8_swap;
+ for( I = 0 ; I < 3 ; I++ ){
+ rabBitsCount = EVS_AWB_RAB_subflow[EVS_codec_rate][I];
+ if( rabBitsCount == 0 )
+ break;
+ ptr8 = &spPS->dl_subflow[0];
+ *ptr8 = 0;//reset
+ for( J = 0; J < rabBitsCount ; J++, K++ ){
+ bit8Data = (byte_swap & RAB_Order_spps[K & 7])? RAB_Order_spps[J & 7] : 0;
+ *ptr8 |= bit8Data;
+ if( (J&7) == 7 ){
+ ptr8++;
+ *ptr8 = 0;
+ }
+ if( (K&7) == 7 ){
+ ptr8_swap++;
+ byte_swap = *ptr8_swap;
+ }
+ }
+ sp_ps_codec_evs_DL_EVS_PutSpeechFrame_SplitAWBtoRAB(CFN, I, frame_type, spPS->dl_subflow);
+ }
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ if( ul_request_resync ){
+ MD_TRC_SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_2_1();
+ frame_type = SP4G_CODEC_EVS_AWB_00_00_NODATA;
+ bitlen = 0;
+ }
+#endif
+
+ EVS_decoder_prepare_parameter(&EVS_DecPar, bitlen, 0, frame_type);
+ EVS_decoder_execute(frame_type, &EVS_DecPar, EVS_one_DL_HB_buffer, bitlen, JBM_info);
+
+ }
+ else
+ {
+#ifdef __OP_IS_AT_AND_T__
+ if( (EVS_codec_rate == SP4G_CODEC_EVS_002_4_SID) || (EVS_codec_rate == SP4G_CODEC_EVS_000_0_LOST) || (EVS_codec_rate == SP4G_CODEC_EVS_000_0_NODATA) ){
+ Silence_Detection_set_DLFrameType(0);
+ }
+ else {
+ Silence_Detection_set_DLFrameType(1);
+ }
+#endif //#ifdef __OP_IS_AT_AND_T__
+ bitlen = EVS_Primary_FrameBitLength[EVS_codec_rate];
+ for(i=0; i<((bitlen+7)>>3); i++)
+ {
+ EVS_one_DL_HB_buffer[i] = encodebits[i];
+ }
+
+#if defined(__SP4G_UL_RESYNC__)
+ if( ul_request_resync ){
+ MD_TRC_SP_PS_CODEC_EVS_HSPA_DL_EVS_PUTSPEECHFRAME_UL_SYNC_2_2();
+ frame_type = SET_SP4G_CODEC_ENUM_EVS_ID(frame_type, SP4G_CODEC_EVS_000_0_NODATA);
+ bitlen = 0;
+ }
+#endif
+
+ EVS_decoder_prepare_parameter(&EVS_DecPar, bitlen, 0, frame_type);
+ EVS_decoder_execute(frame_type, &EVS_DecPar, EVS_one_DL_HB_buffer, bitlen, JBM_info);
+ }
+}
+
+
+void sp_ps_codec_evs_DL_PutSpeechFrame(kal_uint32 CFN, SP4G_Codec frame_type, kal_uint8 *encodebits, EVS_DEC_CA_PARAMETER *pEVS_Dec_CA_Par, kal_bool crc_status, VoLTE_JBM_TS_Info_t *JBM_info)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+
+ if( (L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON) || (spPS == (SPPS_Struct_t*) 0) ){
+ return;
+ }
+
+ if( !GET_IS_SP4G_CODEC_ENUM_EVS_ID(spPS->ul_codec_mode) ){
+ MD_TRC_SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME_RETURN();
+ return;
+ }
+
+ //MD_TRC_SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME();
+
+ //Use NULL pointer for No Data???
+ if(KAL_FALSE == crc_status || encodebits == NULL)
+ {
+ frame_type = spPS->ul_codec_mode;
+ if( SP4G_CODEC_EVS_AWB_ID == GET_SP4G_CODEC_ENUM_EVS_ID(frame_type) )
+ {
+ frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(frame_type, SP4G_CODEC_EVS_AWB_RATE_00_00_NODATA);
+ }
+ else
+ {
+ frame_type = SET_SP4G_CODEC_ENUM_EVS_RATE(frame_type, SP4G_CODEC_EVS_000_0_NODATA);
+ }
+ //kal_prompt_trace(MOD_L1SP, "SP4G_PSR_DL_EVS_PutSpeechFrame receive NULL data pointer, modify frame_type %x to %x", spPS->ul_codec_mode, frame_type);
+ //MD_TRC_SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME_RETURN2(spPS->ul_codec_mode, frame_type);
+ encodebits = encodebits_null;
+ }
+
+ // SP_updateEmCodec(false, 0, true, frame_type);
+
+ if(NULL == pEVS_Dec_CA_Par)
+ {
+ EVS_DecPar.EVS_CA_Par.FrameMode = FRAMEMODE_MISSING;
+ EVS_DecPar.EVS_CA_Par.rev1 = 0;
+ EVS_DecPar.EVS_CA_Par.rev2 = 0;
+ EVS_DecPar.EVS_CA_Par.rev3 = 0;
+ EVS_DecPar.EVS_CA_Par.rev4 = 0;
+ EVS_DecPar.EVS_CA_Par.rev5 = 0;
+ }
+ else
+ {
+ sp_ps_codec_evs_SetEVSDecCAPara(pEVS_Dec_CA_Par);
+ }
+
+ sp_ps_codec_evs_DL_EVS_PutSpeechFrame(CFN, frame_type, encodebits, JBM_info);
+ MD_TRC_SP_PS_CODEC_EVS_PSR_DL_EVS_PUTSPEECHFRAME_DATA(CFN, spPS->ul_codec_mode, frame_type, encodebits[0]);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ spPS->dl_delay = 0;
+ spPS->dl_waiting = KAL_FALSE;
+ kal_give_spinlock(spinlock_sp4g);
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void sp_ps_codec_evs_reset_internal(void)
+{
+ if((StreamRB *)NULL != &EVS_HB_ul_rb_buf)
+ {
+ EVS_HB_ul_rb_buf.read = EVS_HB_ul_rb_buf.write;
+ }
+}
+
+
+void sp_ps_codec_evs_set_network_bw(SP4G_Codec codec)
+{
+ EVS_EncPar.EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(codec);
+ EVS_DecPar.EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(codec);
+}
+
+
+void sp_ps_codec_evs_speech_init(void)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ ASSERT(StreamRB_Init( &EVS_HB_ul_rb_buf, (uint8 *)EVS_enc_HB_rb_array, EVS_CODEC_FRAME_RB_BYTE_SIZE ) );
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void sp_ps_codec_evs_init(void)
+{
+#if defined(__EVS_CODEC_SUPPORT__)
+ //encoder
+ EVS_EncPar.codec = SP4G_CODEC_EVS_16K_008_0;
+ EVS_EncPar.DTX = spPS_IsDTXOn();//spPS_dtx_mode;
+ EVS_EncPar.EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(SP4G_CODEC_EVS_16K_008_0);
+ EVS_EncPar.EVS_capability_bw = EVS_CAPABILITY_BW;
+ EVS_EncPar.EVS_PCM_bw = EVS_PCM_BW;
+ EVS_EncPar.EVS_CA_Par.enable = 0;
+ EVS_EncPar.EVS_CA_Par.rf_fec_indicator = 0;
+ EVS_EncPar.EVS_CA_Par.rf_fec_offset = 0;
+ EVS_EncPar.EVS_CA_Par.rev3 = 0;
+ EVS_EncPar.EVS_CA_Par.rev4 = 0;
+ EVS_EncPar.EVS_CA_Par.rev5 = 0;
+ //decoder
+ EVS_DecPar.codec = SP4G_CODEC_EVS_16K_008_0;
+ EVS_DecPar.EVS_network_request_bw = GET_SP4G_CODEC_ENUM_EVS_BW(SP4G_CODEC_EVS_16K_008_0);
+ EVS_DecPar.EVS_capability_bw = EVS_CAPABILITY_BW;
+ EVS_DecPar.EVS_PCM_bw = EVS_PCM_BW;
+ EVS_DecPar.EVS_HBLen = 0;
+ EVS_DecPar.EVS_BFI = 0;
+ EVS_DecPar.EVS_CA_Par.FrameMode = 0;
+ EVS_DecPar.EVS_CA_Par.rev1 = 0;
+ EVS_DecPar.EVS_CA_Par.rev2 = 0;
+ EVS_DecPar.EVS_CA_Par.rev3 = 0;
+ EVS_DecPar.EVS_CA_Par.rev4 = 0;
+ EVS_DecPar.EVS_CA_Par.rev5 = 0;
+ SP4G_EVS_AWB_DL_SID_Type = SP4G_CODEC_EVS_AWB_SID_TYPE_NONSID;
+#endif //#if defined(__EVS_CODEC_SUPPORT__)
+}
+
+
+void convert_EVSHeaderFullCMRCA_to_EncCAPara(uint8 CMR_Rate, EVS_ENC_CA_PARAMETER *pEVS_ENC_CA_PARAMETER)
+{
+ pEVS_ENC_CA_PARAMETER->enable = 1;
+
+ if(CMR_Rate > 0x3)
+ pEVS_ENC_CA_PARAMETER->rf_fec_indicator = 1;
+ else
+ pEVS_ENC_CA_PARAMETER->rf_fec_indicator = 0;
+
+ switch(CMR_Rate & 0x3)
+ {
+ case 0x0:
+ pEVS_ENC_CA_PARAMETER->rf_fec_offset = 2;
+ break;
+ case 0x1:
+ pEVS_ENC_CA_PARAMETER->rf_fec_offset = 3;
+ break;
+ case 0x2:
+ pEVS_ENC_CA_PARAMETER->rf_fec_offset = 5;
+ break;
+ case 0x3:
+ pEVS_ENC_CA_PARAMETER->rf_fec_offset = 7;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+}
+
+
+kal_bool convert_EVSHeaderFullCMR_to_SP4GCodecEnum(kal_uint8 CMR_value, SP4G_Codec *pSP4G_Codec, EVS_ENC_CA_PARAMETER *pEVS_ENC_CA_PARAMETER)
+{
+ SP4G_Codec SP4G_Codec_Val = 0;
+ uint8 CMR_Type = (CMR_value >> 4) & 0x07;
+ uint8 CMR_Rate = CMR_value & 0x0F;
+
+ //init all parameters
+ *pSP4G_Codec = SP4G_CODEC_NONE;
+ pEVS_ENC_CA_PARAMETER->enable = 0;
+ pEVS_ENC_CA_PARAMETER->rf_fec_indicator = 0;
+ pEVS_ENC_CA_PARAMETER->rf_fec_offset = 0;
+
+ switch(CMR_Type)
+ {
+ case 0x0:
+ if(CMR_Rate > SP4G_CODEC_EVS_024_4)
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_08K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, CMR_Rate);
+ break;
+ case 0x1:
+ if(CMR_Rate > SP4G_CODEC_EVS_AWB_RATE_23_85)
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_16K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, CMR_Rate);
+ break;
+ case 0x2:
+ if(CMR_Rate > SP4G_CODEC_EVS_128_0)
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_16K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, CMR_Rate);
+ break;
+ case 0x3:
+ if( (CMR_Rate > SP4G_CODEC_EVS_128_0) || (CMR_Rate < SP4G_CODEC_EVS_009_6) )
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_32K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, CMR_Rate);
+ break;
+ case 0x4:
+ if( (CMR_Rate > SP4G_CODEC_EVS_128_0) || (CMR_Rate < SP4G_CODEC_EVS_016_4) )
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_48K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, CMR_Rate);
+ break;
+ case 0x5:
+ if( CMR_Rate > 0x7 )
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_16K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_013_2);
+ convert_EVSHeaderFullCMRCA_to_EncCAPara(CMR_Rate, pEVS_ENC_CA_PARAMETER);
+ break;
+ case 0x6:
+ if( CMR_Rate > 0x7 )
+ return KAL_FALSE;
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_32K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_013_2);
+ convert_EVSHeaderFullCMRCA_to_EncCAPara(CMR_Rate, pEVS_ENC_CA_PARAMETER);
+ break;
+ case 0x7:
+ default :
+ return KAL_FALSE;
+ break;
+ }
+
+ *pSP4G_Codec = SP4G_Codec_Val;
+ return KAL_TRUE;
+}
+
+
+kal_bool convert_EVSHeaderFullTOC_to_SP4GCodecEnum(kal_uint8 TOC_value, kal_uint8 EVS_band, SP4G_Codec *pSP4G_Codec)
+{
+ SP4G_Codec SP4G_Codec_Val = 0;
+ uint8 TOC_value_EVSmode = (TOC_value >> 5) & 0x1;
+ uint8 TOC_value_Q = (TOC_value >> 4) & 0x1;
+ uint8 TOC_value_BitRate = TOC_value & 0x0F;
+
+ if(TOC_value_EVSmode)
+ {
+ //EVS AMR-WB
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, SP4G_CODEC_EVS_16K);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, TOC_value_BitRate);
+ *pSP4G_Codec = SP4G_Codec_Val;
+ if( (TOC_value_BitRate >= 0xA) && (TOC_value_BitRate <= 0xD) )
+ return KAL_FALSE;
+ }
+ else
+ {
+ //EVS
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_ID(SP4G_Codec_Val, SP4G_CODEC_EVS_ID);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_BW(SP4G_Codec_Val, EVS_band);
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, TOC_value_BitRate);
+ *pSP4G_Codec = SP4G_Codec_Val;
+ if( (TOC_value_BitRate == 0xD) || (TOC_value_Q) )
+ return KAL_FALSE;
+ }
+ return KAL_TRUE;
+}
+
+
+kal_bool convert_EVSCompactFormatCMR_to_SP4GCodecEnum(kal_uint8 CMR_value, SP4G_Codec *pSP4G_Codec)
+{
+ SP4G_Codec SP4G_Codec_Val = SP4G_CODEC_EVS_AWB_ID | SP4G_CODEC_EVS_16K;
+ switch(CMR_value)
+ {
+ case 0:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_06_60);
+ break;
+ case 1:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_08_85);
+ break;
+ case 2:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_12_65);
+ break;
+ case 3:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_15_85);
+ break;
+ case 4:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_18_25);
+ break;
+ case 5:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_23_05);
+ break;
+ case 6:
+ SP4G_Codec_Val = SET_SP4G_CODEC_ENUM_EVS_RATE(SP4G_Codec_Val, SP4G_CODEC_EVS_AWB_RATE_23_85);
+ break;
+ case 7:
+ default:
+ *pSP4G_Codec = SP4G_CODEC_NONE;
+ return(KAL_FALSE);
+ break;
+ }
+ *pSP4G_Codec = SP4G_Codec_Val;
+ return(KAL_TRUE);
+}
+
+kal_uint16 sp_ps_codec_evs_GetCodecBitLength(SP4G_Codec codec)
+{
+ kal_uint8 codec_rate = GET_SP4G_CODEC_ENUM_EVS_RATE(codec);
+ if(SP4G_CODEC_EVS_ID == GET_SP4G_CODEC_ENUM_EVS_ID(codec))
+ {
+ return( EVS_Primary_FrameBitLength[codec_rate] );
+ }
+ else
+ {
+ return( EVS_AWB_RAB_subflow[codec_rate][4] );
+ }
+}
+
+
+uint16 sp_ps_codec_evs_Get_EVS_AWB_RAB_subflow(int index1, int index2)
+{
+ ASSERT( (index1<16) && (index1>=0) );
+ ASSERT( (index2< 5) && (index2>=0) );
+ return( EVS_AWB_RAB_subflow[index1][index2] );
+}
+
+
diff --git a/mcu/driver/audio/src/v1/sp_ps_codec_g.c b/mcu/driver/audio/src/v1/sp_ps_codec_g.c
new file mode 100644
index 0000000..556b90d
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_codec_g.c
@@ -0,0 +1,966 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_codec_g.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching G speech codec driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 05 14 2020 yf.wang
+ * [MOLY00523036] [MT6873][Margaux][Q0][R3][MP5][SQC][Elisa][WW FT][Finland][NSA][IMS][TCID: V-CC-065] Sometimes audios missing when calling to Customer Service
+ *
+ * G-Series Codec add DL hisr handle to notify data for LTECSR
+ *
+ * 05 13 2020 yf.wang
+ * [MOLY00523036] [MT6873][Margaux][Q0][R3][MP5][SQC][Elisa][WW FT][Finland][NSA][IMS][TCID: V-CC-065] Sometimes audios missing when calling to Customer Service
+ * G-Series Codec add DL hisr handle to notify data for LTECSR
+ *
+ * 09 25 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ *
+ * .
+ *
+ * 09 24 2019 thomas.chen
+ * [MOLY00443295] Gen97 Multi IRQ for reducing VoLTE delay
+ * .
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+
+#include "audio_dsp_d2c_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "l1sp_trc.h"
+#include "dcl.h"
+#include "drv_sap.h"
+#include "ltecsr_msgid.h"
+#include "audio_msgid.h"
+//for SP_is_codec_mute()
+#include "sp_drv.h"
+#include "sal_exp.h"
+
+#include "sp_ps.h"
+#include "sp_ps_codec_g.h"
+#include "g_series_union.h"
+#include "us_timer.h"
+
+
+/*****************************
+Definitions
+*****************************/
+
+
+/*****************************
+External variables
+*****************************/
+extern SPPS_Struct_t *spPS;
+extern kal_spinlockid spinlock_sp4g;
+extern kal_enhmutexid sp4g_dl_mutex;
+extern kal_enhmutexid sp4g_ul_mutex;
+
+
+/*****************************
+External functions
+*****************************/
+kal_uint8 spPS_reset_flag_get(void);
+kal_bool spPS_Rab_State_get(void);
+void sp_ps_reset_internal(void);
+
+
+
+/*****************************
+Local variables
+*****************************/
+uint16 aud_g_dl_id;
+uint16 aud_g_ul_id;
+
+__attribute__((aligned (4))) G_Series_Handle enc_handle;
+__attribute__((aligned (4))) unsigned char enc_tmp_buf[4000+100];
+__attribute__((aligned (4))) unsigned char enc_init_buf[4000+100];
+
+__attribute__((aligned (4))) G_Series_Handle dec_handle;
+__attribute__((aligned (4))) unsigned char dec_tmp_buf[4000+100];
+__attribute__((aligned (4))) unsigned char dec_init_buf[4000+100];
+
+__attribute__((aligned (4))) G726_Enc_Init_Param enc_init_param_g726;
+__attribute__((aligned (4))) G726_Enc_Runtime_Param enc_rtime_param_g726;
+__attribute__((aligned (4))) G726_Dec_Init_Param dec_init_param_g726;
+
+__attribute__((aligned (4))) G722_Dec_Runtime_Param dec_rtime_param_g722;
+__attribute__((aligned (4))) G722_Dec_Init_Param dec_init_param_g722;
+
+__attribute__((aligned (4))) G729_Enc_Init_Param enc_init_param_g729;
+
+__attribute__((aligned (4))) G7231_Enc_Init_Param enc_init_param_g723_1;
+__attribute__((aligned (4))) G7231_Enc_Runtime_Param enc_rtime_param_g723_1;
+
+__attribute__((aligned (4))) G711_Enc_Init_Param enc_init_param_g711;
+__attribute__((aligned (4))) G711_Dec_Init_Param dec_init_param_g711;
+__attribute__((aligned (4))) G711_Dec_Runtime_Param dec_rtime_param_g711;
+
+uint16 dl_pcm_tmp[400];
+uint16 ul_pcm_tmp[400];
+uint32 dl_encoded_tmp[600/sizeof(uint32)];
+uint32 ul_encoded_tmp[600/sizeof(uint32)];
+
+kal_uint16 pcm_ul_buf_ptr[G_SERIAL_CODEC_PCM_RB_BYTE_SIZE>>1];
+kal_uint16 pcm_dl_buf_ptr[G_SERIAL_CODEC_PCM_RB_BYTE_SIZE>>1];
+kal_uint8 ul_buf_ptr[G_SERIAL_CODEC_STREAM_RB_BYTE_SIZE];
+kal_uint8 dl_buf_ptr[G_SERIAL_CODEC_STREAM_RB_BYTE_SIZE];
+
+PCMRB pcm_ul_buf, pcm_dl_buf;
+StreamRB ul_buf, dl_buf;
+
+g_series_mgr_t g_series_mgr;
+
+
+/*****************************
+Local functions
+*****************************/
+
+bool sp_ps_codec_g_is_g_codec(uint8 codec)
+{
+ if(codec == SP4G_CODEC_G711)
+ return true;
+ if(codec == SP4G_CODEC_G722)
+ return true;
+ if(codec == SP4G_CODEC_G723_1)
+ return true;
+ if(codec == SP4G_CODEC_G726)
+ return true;
+ if(codec == SP4G_CODEC_G729)
+ return true;
+ return false;
+}
+
+
+uint16 ps_codec_g_get_g_ul_id(void)
+{
+ return(aud_g_ul_id);
+}
+
+
+
+void sp_ps_codec_g_Encode_Init(SP4G_Codec codec_)
+{
+ g_series_mgr.enc_codec = codec_;
+ //Encode
+ g_series_mgr.enc_hdl = (G_Series_Handle *)&enc_handle; //FIX ME 4-byte alignment
+
+ switch(g_series_mgr.enc_codec){
+ case SP4G_CODEC_G726:
+ g_series_mgr.enc_init_param = (void *)&enc_init_param_g726;
+ g_series_mgr.enc_rtime_param = (void *)&enc_rtime_param_g726;
+ break;
+ case SP4G_CODEC_G722:
+ g_series_mgr.enc_init_param = NULL;
+ g_series_mgr.enc_rtime_param = NULL;
+ break;
+ case SP4G_CODEC_G729:
+ g_series_mgr.enc_init_param = (void *)&enc_init_param_g729;
+ g_series_mgr.enc_rtime_param = NULL;
+ break;
+ case SP4G_CODEC_G723_1:
+ g_series_mgr.enc_init_param = (void *)&enc_init_param_g723_1;
+ g_series_mgr.enc_rtime_param = (void *)&enc_rtime_param_g723_1;
+ break;
+ case SP4G_CODEC_G711:
+ g_series_mgr.enc_init_param = (void *)&enc_init_param_g711;
+ g_series_mgr.enc_rtime_param = NULL;
+ break;
+ default :
+ break;
+ }
+ {//Encode
+ G_Series_Handle *p_handle = g_series_mgr.enc_hdl;
+
+ // Step 0 : Set handle
+ switch(g_series_mgr.enc_codec){
+ case SP4G_CODEC_G726:
+ G726_Enc_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G722:
+ G722_Enc_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G729:
+ G729_Enc_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G723_1:
+ G7231_Enc_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G711:
+ G711_Enc_Set_Handle(p_handle);
+ break;
+ default :
+ break;
+ }
+
+ {// Step 1 : Get buffer size
+ int int_buf_size, tmp_buf_size, pcm_buf_size, bs_buf_size;
+ p_handle->GetBufferSize( (unsigned int *)(&int_buf_size), (unsigned int *)(&tmp_buf_size), (unsigned int *)(&pcm_buf_size), (unsigned int *)(&bs_buf_size) );
+ MD_TRC_SP_PS_CODEC_G_ENCODE_GETBUFFERSIZE(int_buf_size, tmp_buf_size, pcm_buf_size, bs_buf_size);
+
+ g_series_mgr.enc_tmp_buf = (void *)enc_tmp_buf; //FIX ME 4-byte alignment
+ g_series_mgr.enc_init_buf = (void *)enc_init_buf; //FIX ME 4-byte alignment
+ g_series_mgr.enc_pcm_size = pcm_buf_size;
+ g_series_mgr.enc_bs_size = bs_buf_size;
+ }
+
+ {// Step 2 : Initialize
+ switch(g_series_mgr.enc_codec){
+ case SP4G_CODEC_G726:
+ ((G726_Enc_Init_Param *)g_series_mgr.enc_init_param)->BitRate = G726_BITRATE_40;
+ break;
+ case SP4G_CODEC_G729:
+ ((G729_Enc_Init_Param *)g_series_mgr.enc_init_param)->VAD_enable = 1;
+ ((G729_Enc_Init_Param *)g_series_mgr.enc_init_param)->CNG_enable = 1;
+ break;
+ case SP4G_CODEC_G723_1:
+ ((G7231_Enc_Init_Param *)g_series_mgr.enc_init_param)->VAD_enable = 1;
+ ((G7231_Enc_Init_Param *)g_series_mgr.enc_init_param)->CNG_enable = 1;
+ ((G7231_Enc_Init_Param *)g_series_mgr.enc_init_param)->BitRate = G7231_BITRATE_63;
+ break;
+ case SP4G_CODEC_G711:
+ //((G711_Enc_Init_Param *)g_series_mgr.enc_init_param)->law = G711_ALAW;
+ ((G711_Enc_Init_Param *)g_series_mgr.enc_init_param)->VAD_enable = 0;//(int)SP4G_IsDTXOn();//0;//1;
+ break;
+ default :
+ break;
+ }
+ p_handle->Init(p_handle,
+ g_series_mgr.enc_init_buf,
+ g_series_mgr.enc_tmp_buf,
+ g_series_mgr.enc_init_param);
+ }
+ }
+}
+
+
+int sp_ps_codec_g_Encode_Process(uint16 *pcm_tmp, int *pcm_size, uint8 *encoded_tmp, int *bs_size)
+{
+ int result;
+ G_Series_Handle *p_handle = g_series_mgr.enc_hdl;
+
+ ASSERT( *pcm_size == g_series_mgr.enc_pcm_size);
+ *bs_size = g_series_mgr.enc_bs_size;
+
+ switch(g_series_mgr.enc_codec){
+ case SP4G_CODEC_G726:
+ ((G726_Enc_Runtime_Param *)g_series_mgr.enc_rtime_param)->BitRate = G726_BITRATE_40;
+ break;
+ case SP4G_CODEC_G723_1:
+ ((G7231_Enc_Runtime_Param *)g_series_mgr.enc_rtime_param)->BitRate = G7231_BITRATE_63;
+ break;
+ default :
+ break;
+ }
+
+ result = p_handle->Process(p_handle, g_series_mgr.enc_tmp_buf, (short int *)pcm_tmp, pcm_size, encoded_tmp, bs_size, g_series_mgr.enc_rtime_param);
+ return result;
+}
+
+
+void sp_ps_codec_g_Decode_Init(SP4G_Codec codec_)
+{
+ g_series_mgr.dec_codec = codec_;
+ //Decode
+ g_series_mgr.dec_hdl = (G_Series_Handle *)&dec_handle; //FIX ME 4-byte alignment
+ switch(g_series_mgr.dec_codec){
+ case SP4G_CODEC_G726:
+ g_series_mgr.dec_init_param = (void *)&dec_init_param_g726;
+ g_series_mgr.dec_rtime_param = NULL;
+ break;
+ case SP4G_CODEC_G722:
+ g_series_mgr.dec_init_param = (void *)&dec_init_param_g722;
+ g_series_mgr.dec_rtime_param = (G722_Dec_Runtime_Param*)&dec_rtime_param_g722;
+ break;
+ case SP4G_CODEC_G729:
+ g_series_mgr.dec_init_param = NULL;
+ g_series_mgr.dec_rtime_param = NULL;
+ break;
+ case SP4G_CODEC_G723_1:
+ g_series_mgr.dec_init_param = NULL;
+ g_series_mgr.dec_rtime_param = NULL;
+ break;
+ case SP4G_CODEC_G711:
+ g_series_mgr.dec_init_param = (void *)&dec_init_param_g711;
+ g_series_mgr.dec_rtime_param = (G711_Dec_Runtime_Param*)&dec_rtime_param_g711;
+ break;
+ default :
+ break;
+ }
+
+ {//Decode
+ G_Series_Handle *p_handle = g_series_mgr.dec_hdl;
+ // Step 0 : Set handle
+ switch(g_series_mgr.dec_codec){
+ case SP4G_CODEC_G726:
+ G726_Dec_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G722:
+ G722_Dec_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G729:
+ G729_Dec_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G723_1:
+ G7231_Dec_Set_Handle(p_handle);
+ break;
+ case SP4G_CODEC_G711:
+ G711_Dec_Set_Handle(p_handle);
+ break;
+ default :
+ break;
+ }
+
+ {// Step 1 : Get buffer size
+ int int_buf_size, tmp_buf_size, pcm_buf_size, bs_buf_size;
+ p_handle->GetBufferSize( (unsigned int *)(&int_buf_size), (unsigned int *)(&tmp_buf_size), (unsigned int *)(&pcm_buf_size), (unsigned int *)(&bs_buf_size) );
+ MD_TRC_SP_PS_CODEC_G_GETBUFFERSIZE(int_buf_size, tmp_buf_size, pcm_buf_size, bs_buf_size);
+
+ g_series_mgr.dec_tmp_buf = (void *)dec_tmp_buf; //FIX ME 4-byte alignment
+ g_series_mgr.dec_init_buf = (void *)dec_init_buf; //FIX ME 4-byte alignment
+ g_series_mgr.dec_pcm_size = pcm_buf_size;
+ g_series_mgr.dec_bs_size = bs_buf_size;
+ }
+
+ {// Step 2 : Initialize
+ switch(g_series_mgr.dec_codec){
+ case SP4G_CODEC_G726:
+ ((G726_Dec_Init_Param *)g_series_mgr.dec_init_param)->BitRate = G726_BITRATE_40;
+ break;
+ case SP4G_CODEC_G722:
+ ((G722_Dec_Init_Param *)g_series_mgr.dec_init_param)->frame_size_in_samples = G722_20MS_PCM_FRAME_SIZE_IN_BYTES/2;
+ break;
+ case SP4G_CODEC_G711:
+ //((G711_Dec_Init_Param *)g_series_mgr.dec_init_param)->law = G711_ALAW;
+ //((G711_Dec_Init_Param *)g_series_mgr.dec_init_param)->CNG_enable = 0;//1;
+ break;
+ default :
+ break;
+ }
+ p_handle->Init(p_handle,
+ g_series_mgr.dec_init_buf,
+ g_series_mgr.dec_tmp_buf,
+ g_series_mgr.dec_init_param);
+ }
+ }
+}
+
+
+int sp_ps_codec_g_Decode_Process(uint16 *pcm_tmp, int *pcm_size, uint8 *encoded_tmp, int *bs_size)
+{
+ int result;
+ G_Series_Handle *p_handle = g_series_mgr.dec_hdl;
+ //int bs_size = hdr.len*2;//g_series_mgr.dec_bs_size;
+
+ ASSERT( *pcm_size == g_series_mgr.dec_pcm_size);
+
+ switch(g_series_mgr.dec_codec){
+ case SP4G_CODEC_G722:
+ ((G722_Dec_Runtime_Param *)g_series_mgr.dec_rtime_param)->bad_frame_indicator = G722PLC_GOOD_FRAME;//G722PLC_BAD_FRAME;
+ ((G722_Dec_Runtime_Param *)g_series_mgr.dec_rtime_param)->mode = 1;
+ break;
+ case SP4G_CODEC_G711:
+ ((G711_Dec_Runtime_Param *)g_series_mgr.dec_rtime_param)->BFI = 0;
+ ((G711_Dec_Runtime_Param *)g_series_mgr.dec_rtime_param)->ENH_enable = 0;//1;
+ break;
+ default :
+ break;
+ }
+
+ result = p_handle->Process(p_handle, g_series_mgr.dec_tmp_buf, (short int *)pcm_tmp, pcm_size, encoded_tmp, bs_size, g_series_mgr.dec_rtime_param);
+ return result;
+}
+
+
+void sp_ps_codec_g_DL_Event(void *nouse)
+{
+ frame_header_t hdr;
+ uint8 *pu8_dl_encoded_tmp = (uint8 *)dl_encoded_tmp;
+ //vmGCodecDLInfo stvmGCodecDLInfo;
+
+ int i;
+ int max_iteration = 5;
+ int f;
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ return;
+ }
+
+ if(!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ return;
+
+ for(i=0; i<max_iteration; i++){
+ MD_TRC_SP_PS_CODEC_G_DL_EVENT(i);
+
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ if( spPS_reset_flag_get() == 1 ){
+ sp_ps_reset_internal();
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+ f = 0;
+ kal_take_enh_mutex( sp4g_dl_mutex );
+ if(StreamRB_GetDataCount(&dl_buf) >0) {
+ StreamRB_Read(&dl_buf, (uint8 *)&hdr, sizeof(hdr)/sizeof(uint8));
+ ASSERT(hdr.magicid == 0xFFAA);
+ StreamRB_Read(&dl_buf, pu8_dl_encoded_tmp, hdr.len);
+ f = 1;
+ }
+ kal_give_enh_mutex( sp4g_dl_mutex );
+
+ if(f==1){
+ int pcm_len = 0;
+ switch(hdr.codec){
+ case SP4G_CODEC_G711:
+ case SP4G_CODEC_G722:
+ case SP4G_CODEC_G723_1:
+ case SP4G_CODEC_G726:
+ case SP4G_CODEC_G729:
+ {
+ int result;
+ int pcm_size = g_series_mgr.dec_pcm_size;
+ int bs_size = hdr.len;//hdr.len*2;
+ result = sp_ps_codec_g_Decode_Process(dl_pcm_tmp, &pcm_size, pu8_dl_encoded_tmp, &bs_size);
+ MD_TRC_SP_PS_CODEC_G_DL_EVENT_DECODED_GSERIES_DECODE_PROCESS(result);
+
+ pcm_len = pcm_size/2;
+ }
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ ASSERT(pcm_len != 0);
+ MD_TRC_SP_PS_CODEC_G_DL_EVENT_CODEC(hdr.codec, hdr.codec, pcm_len, hdr.len);
+
+ //setVmGCodecDLInfo(&hdr, &stvmGCodecDLInfo);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ {
+ if(PCMRB_GetFreeSpace(&pcm_dl_buf)<pcm_len ){
+ MD_TRC_SP_PS_CODEC_G_DL_EVENT_DROP_PCM();
+ PCMRB_ShiftReadPointer(&pcm_dl_buf, pcm_len);
+ //stvmGCodecDLInfo.drop_info = 0x0002;
+ }
+ }
+ PCMRB_Write(&pcm_dl_buf, (int16 *)dl_pcm_tmp, pcm_len);
+ kal_give_spinlock(spinlock_sp4g);
+
+ //vmStoreGCodecDLStream(&stvmGCodecDLInfo, (kal_uint16)(hdr.len), pu8_dl_encoded_tmp);
+ }else{
+ MD_TRC_SP_PS_CODEC_G_DL_EVENT_READHARDBIT_NO_SIZE();
+ }
+ }
+
+}
+
+
+uint32 streamDataBuffer_UL_Event[640/sizeof(uint32)];
+void sp_ps_codec_g_UL_Event(void *nouse)
+{
+ int frame_size = 0;
+ int max_iteration = 5;
+ int c_codec;
+ frame_header_t ul_header;
+ uint8 *pu8_ul_encoded_tmp = (uint8 *)ul_encoded_tmp;
+ int i;
+ int f;
+ int valid_stream_data;
+
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ return;
+ }
+
+
+ if(!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ return;
+
+ valid_stream_data = 0;
+ if(SP_is_codec_mute() == false)
+ {
+ for(i=0; i<max_iteration; i++){
+ c_codec = g_series_mgr.enc_codec;
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_INFO(i, c_codec);
+ switch(c_codec){ //unit is word
+ case SP4G_CODEC_G711:
+ case SP4G_CODEC_G722:
+ case SP4G_CODEC_G723_1:
+ case SP4G_CODEC_G726:
+ case SP4G_CODEC_G729:
+ frame_size = g_series_mgr.enc_pcm_size/2;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ f = 0;
+ {
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ if(PCMRB_GetDataCount(&pcm_ul_buf) >= frame_size) {
+ PCMRB_Read(&pcm_ul_buf, (int16 *)ul_pcm_tmp, frame_size);
+ f = 1;
+ }
+ kal_give_spinlock(spinlock_sp4g);
+ }
+
+ if(f == 1){
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_READPCM_SIZE(frame_size);
+
+ ul_header.magicid = 0xFFAA;
+ switch(c_codec){
+ case SP4G_CODEC_G711:
+ case SP4G_CODEC_G722:
+ case SP4G_CODEC_G723_1:
+ case SP4G_CODEC_G726:
+ case SP4G_CODEC_G729:
+ {
+ int result;
+ int pcm_size = g_series_mgr.enc_pcm_size;
+ int bs_size = g_series_mgr.enc_bs_size;
+
+ result = sp_ps_codec_g_Encode_Process(ul_pcm_tmp, &pcm_size, pu8_ul_encoded_tmp, &bs_size);
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_ENCODED_GSERIES_ENCODE_PROCESS(result);
+ ul_header.codec = c_codec;
+ ul_header.len = bs_size;//bs_size/2;
+ }
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_ENCODED_INFO(c_codec, ul_header.len);
+ if(ul_header.codec==spPS->ul_codec_mode)
+ {
+ valid_stream_data = 1;
+ kal_take_enh_mutex( sp4g_ul_mutex );
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_ENCODED_FREE_SIZE(StreamRB_GetFreeSpace(&ul_buf), ul_header.len);
+ while(StreamRB_GetFreeSpace(&ul_buf)< ul_header.len + (sizeof(frame_header_t)/sizeof(uint8))){
+ frame_header_t hdr;
+ //for VM
+ //uint32 streamDataBuffer[640/sizeof(uint32)];
+ uint32 *streamDataBuffer = streamDataBuffer_UL_Event;
+ //vmGCodecULInfo stvmGCodecULInfo;
+
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP1(StreamRB_GetFreeSpace(&ul_buf));
+ //drop a frame
+ StreamRB_Read(&ul_buf, (uint8*)&hdr, sizeof(hdr)/sizeof(uint8));
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP2(StreamRB_GetFreeSpace(&ul_buf), hdr.len);
+ ASSERT(hdr.magicid == 0xFFAA);
+
+ //setVmGCodecULInfo(&hdr, &stvmGCodecULInfo);
+ //stvmGCodecULInfo.drop_info = 0x0001;
+ //StreamRB_ShiftReadPointer(&ul_buf, hdr.len);
+ if(hdr.len <= sizeof(streamDataBuffer))
+ {
+ StreamRB_Read(&ul_buf, (uint8*)streamDataBuffer, hdr.len);
+ //vmStoreGCodecULStream(&stvmGCodecULInfo, (kal_uint16)hdr.len, (kal_uint8 *)streamDataBuffer);
+ }
+ else
+ {
+ StreamRB_Read(&ul_buf, (uint8*)streamDataBuffer, sizeof(streamDataBuffer));
+ StreamRB_ShiftReadPointer(&ul_buf, hdr.len-sizeof(streamDataBuffer));
+ //vmStoreGCodecULStream(&stvmGCodecULInfo, (kal_uint16)(sizeof(streamDataBuffer)), (kal_uint8 *)streamDataBuffer);
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP2_SIZE_INFO(sizeof(streamDataBuffer));
+ }
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP3(StreamRB_GetFreeSpace(&ul_buf));
+ }
+
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_WRITE1(StreamRB_GetFreeSpace(&ul_buf));
+ StreamRB_Write(&ul_buf, (uint8*)&ul_header, sizeof(ul_header)/sizeof(uint8));
+
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_WRITE2(StreamRB_GetFreeSpace(&ul_buf));
+ StreamRB_Write(&ul_buf, pu8_ul_encoded_tmp, ul_header.len);
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_WRITE3(StreamRB_GetFreeSpace(&ul_buf));
+ kal_give_enh_mutex( sp4g_ul_mutex );
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_CODEC_MISMATCH(ul_header.codec, spPS->ul_codec_mode);
+ }
+ }
+ else
+ {
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_READPCM_NO_SIZE();
+ break;
+ }
+ }
+ }
+ else
+ {
+ // clear RB
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ ASSERT(PCMRB_Init( &pcm_ul_buf, (int16 *)pcm_ul_buf_ptr, (G_SERIAL_CODEC_PCM_RB_BYTE_SIZE>>1)/*1600*/) );
+ kal_give_spinlock(spinlock_sp4g);
+ }
+ if(valid_stream_data != 0)
+ {
+ PSR_SP4G_Callback(SP4G_UL_DATA_NOTIFY, 0);
+ }
+ else
+ {
+ if(KAL_TRUE == spPS_Rab_State_get())
+ {
+ PSR_SP4G_Callback( SP4G_UL_MUTE_NOTIFY, (void*)0 );
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP_CODEC_MUTE_INFO(SP_is_codec_mute());
+ }
+ }
+
+}
+
+
+void sp_ps_codec_g_speech_init(void)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ ASSERT(PCMRB_Init( &pcm_ul_buf, (int16 *)pcm_ul_buf_ptr, (G_SERIAL_CODEC_PCM_RB_BYTE_SIZE>>1)/*1600*/ ) );
+ ASSERT(PCMRB_Init( &pcm_dl_buf, (int16 *)pcm_dl_buf_ptr, (G_SERIAL_CODEC_PCM_RB_BYTE_SIZE>>1)/*1600*/ ) );
+ ASSERT(StreamRB_Init( &ul_buf, (uint8 *)ul_buf_ptr, G_SERIAL_CODEC_STREAM_RB_BYTE_SIZE/*2048*/ ) );
+ ASSERT(StreamRB_Init( &dl_buf, (uint8 *)dl_buf_ptr, G_SERIAL_CODEC_STREAM_RB_BYTE_SIZE/*2048*/ ) );
+
+ aud_g_dl_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aud_g_dl_id ); /* To lock sleep mode */
+ aud_g_ul_id = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aud_g_ul_id ); /* To lock sleep mode */
+
+ L1Audio_SetEventHandler( aud_g_dl_id, sp_ps_codec_g_DL_Event );
+ L1Audio_SetEventHandler( aud_g_ul_id, sp_ps_codec_g_UL_Event );
+//#endif//#if defined(__G_CODEC_SUPPORT__)
+}
+
+
+void sp_ps_codec_g_close( void )
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ L1Audio_ClearFlag( aud_g_ul_id);
+ L1Audio_FreeAudioID( aud_g_ul_id);
+ L1Audio_ClearFlag( aud_g_dl_id);
+ L1Audio_FreeAudioID( aud_g_dl_id);
+//#endif//#if defined(__G_CODEC_SUPPORT__)
+}
+
+
+void sp_ps_codec_g_reset_internal(void)
+{
+ pcm_dl_buf.read = pcm_dl_buf.write;
+}
+
+
+void sp_ps_codec_g_Set_G711Parameters(kal_int32 law, kal_int32 dec_init_CNG_enable)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ if( (law != G711_ALAW) && (law != G711_ULAW) )
+ {
+ MD_TRC_SP_PS_CODEC_G_SET_G711PARAMETERS_OUT_OF_RANGE(law);
+ ASSERT(0);
+ }
+ enc_init_param_g711.law = law;
+ dec_init_param_g711.law = law;
+
+ if( (dec_init_CNG_enable != 0) && (dec_init_CNG_enable != 1) )
+ {
+ MD_TRC_SP_PS_CODEC_G_SET_G711PARAMETERS(dec_init_CNG_enable);
+ ASSERT(0);
+ }
+ dec_init_param_g711.CNG_enable = dec_init_CNG_enable;
+//#endif //#if defined(__G_CODEC_SUPPORT__)
+}
+
+
+uint32 streamDataBuffer_PSR_GetFrame[640/sizeof(uint32)];
+int sp_ps_codec_g_GetFrame(int8* c, int8* len, uint8* tmp_buf)
+{
+ int i= 0;
+ int left = 0;
+ frame_header_t tmp_hdr;
+
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ return 0;
+ }
+ if(!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ return 0;
+
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME();
+ kal_take_enh_mutex( sp4g_ul_mutex );
+ while(StreamRB_GetDataCount(&ul_buf)>0){
+ //for VM
+ //uint32 streamDataBuffer[640/sizeof(uint32)];
+ uint32 *streamDataBuffer = streamDataBuffer_PSR_GetFrame;
+ //vmGCodecULInfo stvmGCodecULInfo;
+
+ StreamRB_Read(&ul_buf, (uint8 *)&tmp_hdr, sizeof(tmp_hdr)/sizeof(uint8));
+ ASSERT(tmp_hdr.magicid == 0xFFAA);
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME2(i++);
+
+ //setVmGCodecULInfo(&tmp_hdr, &stvmGCodecULInfo);
+
+ if(tmp_hdr.codec == spPS->ul_codec_mode){
+ *c = spPS->ul_codec_mode;
+ *len = tmp_hdr.len;
+
+ StreamRB_Read(&ul_buf, tmp_buf, tmp_hdr.len);
+ //vmStoreGCodecULStream(&stvmGCodecULInfo, (kal_uint16)tmp_hdr.len, tmp_buf);
+
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME_INFO(*c, *len);
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME_OK();
+
+ break;//return;
+ }else{
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME_MISMATCH(tmp_hdr.codec, spPS->ul_codec_mode);
+
+ //stvmGCodecULInfo.drop_info = 0x0001;
+ //StreamRB_ShiftReadPointer(&ul_buf, tmp_hdr.len);
+ if(tmp_hdr.len <= sizeof(streamDataBuffer))
+ {
+ StreamRB_Read(&ul_buf, (uint8*)streamDataBuffer, tmp_hdr.len);
+ //vmStoreGCodecULStream(&stvmGCodecULInfo, (kal_uint16)tmp_hdr.len, (kal_uint8 *)streamDataBuffer);
+ }
+ else
+ {
+ StreamRB_Read(&ul_buf, (uint8*)streamDataBuffer, sizeof(streamDataBuffer));
+ StreamRB_ShiftReadPointer(&ul_buf, tmp_hdr.len-sizeof(streamDataBuffer));
+ //vmStoreGCodecULStream(&stvmGCodecULInfo, (kal_uint16)(sizeof(streamDataBuffer)), (kal_uint8 *)streamDataBuffer);
+ MD_TRC_SP_PS_CODEC_G_UL_EVENT_DROP2_SIZE_INFO(sizeof(streamDataBuffer));
+ }
+ }
+ }
+ left = StreamRB_GetDataCount(&ul_buf)>0;
+ kal_give_enh_mutex( sp4g_ul_mutex );
+ //give a NODATA frame
+ MD_TRC_SP_PS_CODEC_G_PSR_GETFRAME_NODATA();
+ return left;
+}
+
+uint32 streamDataBuffer_PSR_PutFrame[640/sizeof(uint32)];
+void sp_ps_codec_g_PutFrame(int c, int encoded_len, uint8* encoded_bits)
+{
+ frame_header_t hdr;
+ if( L1SP_GetState() != L1SP_STATE_4G_SPEECH_ON){
+ return;
+ }
+
+ if(!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ return;
+
+ if(c==spPS->ul_codec_mode){
+ kal_take_enh_mutex( sp4g_dl_mutex );
+ while(StreamRB_GetFreeSpace(&dl_buf)< encoded_len + (sizeof(frame_header_t)/sizeof(uint8))){
+ //uint16 tmp_buf[2048];
+ //uint32 streamDataBuffer[640/sizeof(uint32)];
+ uint32 *streamDataBuffer = streamDataBuffer_PSR_PutFrame;
+ //vmGCodecDLInfo stvmGCodecDLInfo;
+
+ MD_TRC_SP_PS_CODEC_G_PSR_PUTFRAME_DROP();
+ //drop a frame
+ StreamRB_Read(&dl_buf, (uint8 *)&hdr, sizeof(hdr)/sizeof(uint8));
+ ASSERT(hdr.magicid == 0xFFAA);
+
+ //setVmGCodecDLInfo(&hdr, &stvmGCodecDLInfo);
+ //stvmGCodecDLInfo.drop_info = 0x0001;
+ //StreamRB_ShiftReadPointer(&dl_buf, hdr.len);
+ if(hdr.len <= sizeof(streamDataBuffer))
+ {
+ StreamRB_Read(&dl_buf, (uint8*)streamDataBuffer, hdr.len);
+ //vmStoreGCodecDLStream(&stvmGCodecDLInfo, (kal_uint16)hdr.len, (kal_uint8 *)streamDataBuffer);
+ }
+ else
+ {
+ StreamRB_Read(&dl_buf, (uint8*)streamDataBuffer, sizeof(streamDataBuffer));
+ StreamRB_ShiftReadPointer(&dl_buf, hdr.len-sizeof(streamDataBuffer));
+ //vmStoreGCodecDLStream(&stvmGCodecDLInfo, (kal_uint16)(sizeof(streamDataBuffer)), (kal_uint8 *)streamDataBuffer);
+ MD_TRC_SP_PS_CODEC_G_PSR_PUTFRAME_DROP_SIZE_INFO(sizeof(streamDataBuffer));
+ }
+ }
+
+ hdr.magicid = 0xFFAA;
+ hdr.codec = c;
+ hdr.len = encoded_len;
+ MD_TRC_SP_PS_CODEC_G_PSR_PUTFRAME4(c, encoded_len);
+ StreamRB_Write(&dl_buf, (uint8 *)&hdr, sizeof(hdr)/sizeof(uint8));
+ StreamRB_Write(&dl_buf, encoded_bits, encoded_len);
+
+ kal_give_enh_mutex( sp4g_dl_mutex );
+ }
+ else
+ {
+ //vmGCodecDLInfo stvmGCodecDLInfo;
+
+ MD_TRC_SP_PS_CODEC_G_PSR_PUTFRAME_MISMATCH(c, c, spPS->ul_codec_mode, spPS->ul_codec_mode);
+
+ //hdr.magicid = 0xFFAA;
+ //hdr.codec = c;
+ //hdr.len = encoded_len;
+
+ //setVmGCodecDLInfo(&hdr, &stvmGCodecDLInfo);
+ //stvmGCodecDLInfo.drop_info = 0x0001;
+ //vmStoreGCodecDLStream(&stvmGCodecDLInfo, (kal_uint16)(encoded_len), (kal_uint8 *)encoded_bits);
+ }
+ L1Audio_SetEvent( aud_g_dl_id, (void *)0 );
+ MD_TRC_SP_PS_CODEC_G_PSR_PUTFRAME3(aud_g_dl_id);
+}
+
+
+void sp_ps_codec_g_hisr_dl_g(void *data)
+{
+ int fsize;
+ volatile uint16* ptr;
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_STATUS(0);
+
+ if ((L1SP_GetState() == L1SP_STATE_4G_SPEECH_CLOSING)
+ || (!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode)))
+ {
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_STATUS(1);
+ return;
+ }
+
+ // Read DL_DATA from pcm_dl_buf and write to DSP Buffer
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ fsize = SAL_PcmEx_GetBufLen(SAL_PCMEX_EXTCOD_BUF_DL);
+ ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_EXTCOD_BUF_DL);
+
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_INFO1(ptr, fsize);
+
+ if ((spPS_reset_flag_get() == 2)
+ && (PCMRB_GetDataCount(&pcm_dl_buf) >= fsize))
+ {
+ PCMRB_Read_to_DSP(&pcm_dl_buf, ptr, fsize);
+ }
+ else
+ {
+ int i;
+ for (i = 0; i < fsize; i++)
+ {
+ *ptr++ = 0;
+ }
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_NO_DATA();
+ Data_Sync_Barrier();
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+ // DL_DATA_NOTIFY to LTECSR
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_INFO2(spPS_reset_flag_get(),
+ spPS_Rab_State_get(), SP_is_codec_mute(), spPS->sp4g_mode);
+ if (SP_is_codec_mute())
+ {
+ if (KAL_TRUE == spPS_Rab_State_get())
+ {
+ PSR_SP4G_Callback(SP4G_DL_MUTE_NOTIFY, (void*) 0);
+ }
+ }
+ else
+ {
+ if (spPS->sp4g_mode == RAT_4G_MODE)
+ {
+ PSR_SP4G_Callback(SP4G_DL_DATA_NOTIFY, (void*) 0);
+ }
+ }
+ MD_TRC_SP_PS_CODEC_G_HISR_DL_STATUS(2);
+}
+
+
+void sp_ps_codec_g_hisr_ul_g(void *data)
+{
+ int fsize;
+ if(L1SP_GetState() == L1SP_STATE_4G_SPEECH_CLOSING)
+ return;
+
+ if(!sp_ps_codec_g_is_g_codec(spPS->ul_codec_mode))
+ return;
+ fsize = SAL_PcmEx_GetBufLen(SAL_PCMEX_EXTCOD_BUF_UL);
+
+ MD_TRC_SP_PS_CODEC_G_HISR_UL_SIZE(fsize);
+ kal_take_spinlock(spinlock_sp4g, KAL_INFINITE_WAIT);
+ if(PCMRB_GetFreeSpace(&pcm_ul_buf) < fsize){
+ PCMRB_ShiftReadPointer(&pcm_ul_buf, fsize);
+ MD_TRC_SP_PS_CODEC_G_HISR_UL_DROP();
+ }
+
+ {
+ volatile uint16* ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_EXTCOD_BUF_UL);
+ MD_TRC_SP_PS_CODEC_G_HISR_UL(ptr);
+ PCMRB_Write_from_DSP(&pcm_ul_buf, ptr, fsize);
+ }
+ kal_give_spinlock(spinlock_sp4g);
+
+ L1Audio_SetEvent(aud_g_ul_id, (void *)0);
+ MD_TRC_SP_PS_CODEC_G_HISR_UL_AUD_UL_ID(aud_g_ul_id);
+}
+
+
+int sp_ps_codec_g_UL_GSeries_IsMoreData(void)
+{
+//#if defined(__G_CODEC_SUPPORT__)
+ kal_take_enh_mutex( sp4g_ul_mutex );
+ if(StreamRB_GetDataCount(&ul_buf) > 0)
+ {
+ kal_give_enh_mutex( sp4g_ul_mutex );
+ return(1);
+ }
+ kal_give_enh_mutex( sp4g_ul_mutex );
+//#endif
+ return(0);
+}
+
+
diff --git a/mcu/driver/audio/src/v1/sp_ps_dsp_opt.c b/mcu/driver/audio/src/v1/sp_ps_dsp_opt.c
new file mode 100644
index 0000000..b0b4ac9
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_ps_dsp_opt.c
@@ -0,0 +1,560 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_ps_dsp_opt.c
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Packet-switching speech DSP related features
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *------------------------------------------------------------------------------
+ * $Revision: $
+ * $Modtime: $
+ * $Log: $
+ *
+ * 04 10 2018 fu-shing.ju
+ * [MOLY00305348] Use debug_info[12] bit0 to enable/disable USE_EVSIO_TO_REPLCAE_AWB.
+ * .
+ *
+
+ *******************************************************************************/
+
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "kal_trace.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "am.h"
+#include "l1audio_trace_utmd.h"
+#include "media.h"
+#include "l1sp_trc.h"
+
+#include "sal_exp.h"
+#include "sal_def.h"
+
+#include "sp_ps_dsp_opt.h"
+//#include "pcmrb.h"
+
+uint16 aud_id_sppsToneDete;
+
+#define FRAME_SIZE (640)
+#define PATTERN_SIZE (FRAME_SIZE*3)
+#define BUFFER_SIZE (FRAME_SIZE*4)
+#define PATTERN_COR_THRD (309532521273 * 0.75)
+#define PATTERN_SEARCH_STEP (20)
+#define PATTERN_SEARCH_COUNT (32)
+#define PATTERN_ENG_THRD (100000000)
+#define FRAME_COUNT_MAX (50*60*60*10)
+
+int16 sp4g_frame_count;
+int16 sp4g_last_tone_frame;
+int16 sp4g_tone_frame_dur[2];
+int16 sp4g_tone_frame_dur_index;
+int16 sp4g_tone_frame_count;
+int16 sp4g_tone_frame_dur_hit_count;
+uint16 sp4g_pattern_flag;
+int16 sp4g_detect_buffer[BUFFER_SIZE];
+int16 sp4g_detect_buffer_index;
+extern int16 sp4g_tone_pattern[PATTERN_SIZE];
+
+uint16 sp_ps_dsp_opt_PatternDetecion(int16* input, int16 input_index, int16 input_size, int16 frame);
+uint16 sp_ps_dsp_opt_ToneSearch(int16 *input, int16 input_index, uint16 input_size, int16 *pattern, uint16 length, uint16 correlation_count, uint16 step);
+uint16 sp_ps_dsp_opt_ToneDetection(int16 *x, int16 index_x, uint16 size_x, int16 *pattern, uint16 length);
+
+
+uint16 sp_ps_dsp_opt_ToneDeteGetAudID(void)
+{
+ return( aud_id_sppsToneDete );
+}
+
+
+void sp_ps_dsp_opt_ToneDeteInit(void)
+{
+ aud_id_sppsToneDete = L1Audio_GetAudioID();
+ L1Audio_SetFlag( aud_id_sppsToneDete );
+ L1Audio_SetEventHandler( aud_id_sppsToneDete, sp_ps_dsp_opt_ToneDeteExec );
+}
+
+
+void sp_ps_dsp_opt_ToneDeteClose(void)
+{
+ L1Audio_ClearFlag( aud_id_sppsToneDete );
+ L1Audio_FreeAudioID( aud_id_sppsToneDete );
+}
+
+
+void sp_ps_dsp_opt_ToneDeteTaskInit(void)
+{
+ MD_TRC_SP_PS_DSP_OPT_TONEDETETASKINIT();
+
+ uint16 i =0;
+ sp4g_frame_count = 0;
+ sp4g_last_tone_frame = -1;
+ sp4g_tone_frame_dur[0] = 0;
+ sp4g_tone_frame_dur[1] = 0;
+ sp4g_tone_frame_dur_index = 0;
+ sp4g_tone_frame_count = 0;
+ sp4g_pattern_flag = 0;
+ sp4g_tone_frame_dur_hit_count = 0;
+ sp4g_detect_buffer_index = 0;
+
+ for (i=0; i<BUFFER_SIZE; i++)
+ {
+ sp4g_detect_buffer[i] = 0;
+ }
+
+}
+
+
+void sp_ps_dsp_opt_ToneDeteExec()
+{
+ int16 fsize, i;
+ volatile uint16* ptr;
+
+ MD_TRC_SP_PS_DSP_OPT_TONEDETEEXEC(sp4g_frame_count);
+
+ fsize = SAL_PcmEx_GetBufLen(SAL_PCMEX_BUF_SD);
+ ptr = SAL_PcmEx_GetBuf(SAL_PCMEX_BUF_SD);
+
+ if(fsize != 640)
+ {
+ sp4g_pattern_flag = 0;
+ return;
+ }
+
+ for(i=0;i<fsize;i++)
+ {
+ sp4g_detect_buffer[sp4g_detect_buffer_index + i] = ptr[i];
+ }
+
+ sp4g_detect_buffer_index += FRAME_SIZE;
+ sp4g_detect_buffer_index %= BUFFER_SIZE;
+
+ sp_ps_dsp_opt_PatternDetecion(sp4g_detect_buffer, sp4g_detect_buffer_index, BUFFER_SIZE, sp4g_frame_count);
+ sp4g_frame_count ++;
+ if (sp4g_frame_count > FRAME_COUNT_MAX)
+ sp4g_frame_count = 0;
+}
+
+
+int32 sp_ps_dsp_opt_ToneDeteGetResult(void)
+{
+ return(sp4g_pattern_flag);
+}
+
+
+uint16 sp_ps_dsp_opt_PatternDetecion(int16* input, int16 input_index, int16 input_size, int16 frame)
+{
+ int dur;
+ if (sp4g_last_tone_frame > 0)
+ {
+ if (frame - sp4g_last_tone_frame < 15)
+ {
+ return sp4g_pattern_flag;
+ }
+ }
+
+ if (sp_ps_dsp_opt_ToneSearch(input, input_index, input_size, sp4g_tone_pattern, PATTERN_SIZE, PATTERN_SEARCH_COUNT, PATTERN_SEARCH_STEP) == 1)
+ {
+ MD_TRC_SP_PS_DSP_OPT_PATTERNDETECION(frame);
+ sp4g_tone_frame_count ++;
+ if(sp4g_tone_frame_count == 1 || (frame < sp4g_last_tone_frame))
+ {
+ sp4g_last_tone_frame = frame;
+ return sp4g_pattern_flag;
+ }
+
+ dur = frame - sp4g_last_tone_frame;
+ sp4g_last_tone_frame = frame;
+ if ((dur > sp4g_tone_frame_dur[0] - 10) && (dur < sp4g_tone_frame_dur[0] + 10))
+ {
+ sp4g_tone_frame_dur[0] = dur;
+ sp4g_tone_frame_dur_index = 1;
+ sp4g_tone_frame_dur_hit_count ++;
+ }
+ else if ((dur > sp4g_tone_frame_dur[1] - 10) && (dur < sp4g_tone_frame_dur[1] + 10))
+ {
+ sp4g_tone_frame_dur[1] = dur;
+ sp4g_tone_frame_dur_index = 0;
+ sp4g_tone_frame_dur_hit_count ++;
+ }
+ else
+ {
+ sp4g_tone_frame_dur[sp4g_tone_frame_dur_index++] = dur;
+ sp4g_tone_frame_dur_hit_count --;
+ sp4g_tone_frame_dur_index %= 2;
+ }
+ if(sp4g_tone_frame_dur_hit_count > 8)
+ {
+ sp4g_tone_frame_dur_hit_count = 8;
+ }
+ else if(sp4g_tone_frame_dur_hit_count < 0)
+ {
+ sp4g_tone_frame_dur_hit_count = 0;
+ }
+
+ if(sp4g_tone_frame_dur_hit_count >= 4)
+ {
+ sp4g_pattern_flag = 1;
+ }
+ else
+ {
+ sp4g_pattern_flag = 0;
+ }
+ }
+ else if (sp4g_pattern_flag == 1)
+ {
+ if (frame < sp4g_last_tone_frame && frame > 3000)
+ {
+ sp4g_pattern_flag = 0;
+ }
+ else if (frame - sp4g_last_tone_frame > 3000)
+ {
+ sp4g_pattern_flag = 0;
+ }
+ }
+
+ return sp4g_pattern_flag;
+}
+
+uint16 sp_ps_dsp_opt_ToneSearch(int16 *input, int16 input_index, uint16 input_size, int16 *pattern, uint16 length, uint16 correlation_count, uint16 step)
+{
+ int i=0;
+ uint16 r;
+
+ for (i=0; i < correlation_count; i ++)
+ {
+ r = sp_ps_dsp_opt_ToneDetection( input, input_index, input_size, pattern, length);
+ if(r == 1)
+ {
+ return 1;
+ }
+ input_index += step;
+ input_index %= input_size;
+ }
+ return 0;
+}
+
+uint16 sp_ps_dsp_opt_ToneDetection(int16 *x, int16 index_x, uint16 size_x, int16 *pattern, uint16 length)
+{
+ int i,n = length;
+ long long sum_xy=0, sum_x2=0, cor;
+ int16* y = pattern;
+
+ index_x %= size_x;
+ for (i=0; i<n; i++)
+ {
+ sum_x2 += x[index_x] * x[index_x];
+ sum_xy += x[index_x] * y[i];
+ index_x ++;
+ index_x %= size_x;
+ }
+
+ if (sum_x2==0)
+ {
+ cor = 0;
+ }
+ else
+ {
+ cor = (sum_xy<<10) / sum_x2 * (sum_xy>>10) ;
+ }
+ if (cor >= PATTERN_COR_THRD && sum_x2 > PATTERN_ENG_THRD)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+int16 sp4g_tone_pattern[] = {
+0x0002, 0x0002, 0x0001, 0xfffb, 0xfff3, 0xfff2, 0xfff5, 0xfff6,
+0xfff1, 0xffec, 0xffeb, 0xffed, 0xffef, 0xfff3, 0xfffc, 0x0005,
+0x0009, 0x000a, 0x000e, 0x0018, 0x0020, 0x0021, 0x001a, 0x0010,
+0x0008, 0x0003, 0xfffe, 0xfff6, 0xffec, 0xffe2, 0xffd9, 0xffcf,
+0xffc1, 0xffb6, 0xffb1, 0xffb0, 0xffaf, 0xffb0, 0xffb6, 0xffc4,
+0xffd6, 0xffe5, 0xfff0, 0xfffc, 0x000a, 0x0019, 0x0025, 0x002f,
+0x0038, 0x0040, 0x0043, 0x0041, 0x0039, 0x0030, 0x0028, 0x0021,
+0x0017, 0x0009, 0xfffa, 0xfff2, 0xffef, 0xffef, 0xfff0, 0xfff6,
+0xffff, 0x0007, 0x000d, 0x0013, 0x001d, 0x0025, 0x0026, 0x0023,
+0x0022, 0x0020, 0x0017, 0x0008, 0xfffb, 0xfff2, 0xffe5, 0xffd1,
+0xffbf, 0xffb5, 0xffad, 0xffa1, 0xff98, 0xff9f, 0xffb5, 0xffd1,
+0xfff0, 0x0016, 0x0041, 0x0069, 0x008c, 0x00af, 0x00d5, 0x00f3,
+0x0103, 0x0108, 0x0107, 0x00ff, 0x00eb, 0x00d0, 0x00b1, 0x008e,
+0x0063, 0x0032, 0x0002, 0xffd6, 0xffab, 0xff84, 0xff64, 0xff4b,
+0xff36, 0xff27, 0xff22, 0xff26, 0xff28, 0xff27, 0xff29, 0xff33,
+0xff3d, 0xff41, 0xff41, 0xff45, 0xff4b, 0xff4a, 0xff43, 0xff41,
+0xff46, 0xff4d, 0xff53, 0xff5e, 0xff71, 0xff8a, 0xffa5, 0xffc7,
+0xfff7, 0x002f, 0x0065, 0x0094, 0x00be, 0x00e9, 0x0117, 0x0144,
+0x016a, 0x0183, 0x0189, 0x0181, 0x0176, 0x0167, 0x014b, 0x0113,
+0x00c3, 0x0069, 0x0013, 0xffc4, 0xff78, 0xff32, 0xfef7, 0xfec5,
+0xfe99, 0xfe77, 0xfe69, 0xfe73, 0xfe8a, 0xfea3, 0xfebc, 0xfedc,
+0xff04, 0xff33, 0xff67, 0xff9e, 0xffd0, 0xfff4, 0x000b, 0x0024,
+0x0049, 0x0072, 0x0090, 0x00a2, 0x00b5, 0x00d3, 0x00f5, 0x0112,
+0x0127, 0x0141, 0x0167, 0x018e, 0x01a8, 0x01b3, 0x01bd, 0x01cf,
+0x01e0, 0x01db, 0x01c2, 0x01a7, 0x0194, 0x0179, 0x0145, 0x00fd,
+0x00b6, 0x0074, 0x002c, 0xffd7, 0xff81, 0xff33, 0xfee8, 0xfe9e,
+0xfe5d, 0xfe30, 0xfe11, 0xfdf7, 0xfde7, 0xfdee, 0xfe0a, 0xfe2f,
+0xfe63, 0xfeb6, 0xff1d, 0xff76, 0xffae, 0xffd4, 0x0001, 0x0031,
+0x0050, 0x005e, 0x0067, 0x006f, 0x0071, 0x0072, 0x0078, 0x007a,
+0x006b, 0x0057, 0x0058, 0x006b, 0x006c, 0x004b, 0x0027, 0x0023,
+0x0033, 0x0033, 0x001c, 0x0004, 0xfff5, 0xffe3, 0xffca, 0xffb6,
+0xffa6, 0xff83, 0xff44, 0xff02, 0xfed9, 0xfec4, 0xfeac, 0xfe89,
+0xfe63, 0xfe44, 0xfe28, 0xfe10, 0xfe02, 0xfe04, 0xfe16, 0xfe3c,
+0xfe79, 0xfec7, 0xff17, 0xff5f, 0xff99, 0xffc7, 0xfff2, 0x0020,
+0x0053, 0x0083, 0x00a5, 0x00b7, 0x00c2, 0x00cc, 0x00cb, 0x00aa,
+0x005c, 0xffea, 0xff76, 0xff23, 0xff01, 0xff03, 0xff04, 0xfee9,
+0xfebe, 0xfeab, 0xfec8, 0xfefe, 0xff2a, 0xff4b, 0xff7f, 0xffcc,
+0x0012, 0x0039, 0x005c, 0x00a7, 0x010d, 0x0159, 0x0174, 0x0184,
+0x01b2, 0x01f3, 0x0220, 0x022e, 0x022f, 0x0237, 0x0249, 0x0266,
+0x0292, 0x02bc, 0x02ce, 0x02c4, 0x02b6, 0x02b8, 0x02bb, 0x02a7,
+0x0270, 0x0222, 0x01cf, 0x0183, 0x0135, 0x00d9, 0x006c, 0xfffd,
+0xff91, 0xff15, 0xfe7b, 0xfdde, 0xfd65, 0xfd12, 0xfcc3, 0xfc75,
+0xfc4c, 0xfc51, 0xfc4f, 0xfc23, 0xfbcb, 0xfb0b, 0xf8e9, 0xf3f3,
+0xeb39, 0xdf7c, 0xd331, 0xc960, 0xc392, 0xc0d2, 0xbecd, 0xbc82,
+0xbb51, 0xbd1a, 0xc1ad, 0xc722, 0xcc8d, 0xd30b, 0xdbd9, 0xe639,
+0xf0af, 0xfb03, 0x0645, 0x127d, 0x1e8e, 0x29c8, 0x34f5, 0x4088,
+0x4ba9, 0x5540, 0x5d9f, 0x658b, 0x6cc0, 0x722c, 0x759d, 0x77a3,
+0x7845, 0x76e9, 0x73c1, 0x6fee, 0x6bbe, 0x6617, 0x5e12, 0x547c,
+0x4a84, 0x4028, 0x3483, 0x27af, 0x1a90, 0x0d9d, 0x0052, 0xf2aa,
+0xe55e, 0xd90d, 0xcd4e, 0xc1c4, 0xb6c2, 0xacfe, 0xa483, 0x9d1d,
+0x96ea, 0x9250, 0x8f41, 0x8d72, 0x8ced, 0x8e14, 0x910a, 0x95a5,
+0x9be4, 0xa3c2, 0xacc1, 0xb60d, 0xbf99, 0xca0d, 0xd5d8, 0xe243,
+0xee8a, 0xfaa5, 0x0712, 0x138c, 0x1f62, 0x2a3e, 0x347c, 0x3e06,
+0x4641, 0x4ccb, 0x5233, 0x5707, 0x5afe, 0x5d4a, 0x5db6, 0x5cbb,
+0x5ab2, 0x576d, 0x529e, 0x4c62, 0x4501, 0x3cb1, 0x3375, 0x295e,
+0x1e79, 0x1309, 0x075e, 0xfbd9, 0xf06f, 0xe4fb, 0xd981, 0xce83,
+0xc460, 0xbb21, 0xb28c, 0xaac6, 0xa41f, 0x9ece, 0x9ac8, 0x982e,
+0x9745, 0x980f, 0x9a0c, 0x9cbc, 0xa04c, 0xa553, 0xac0e, 0xb3f9,
+0xbc99, 0xc5ed, 0xd04a, 0xdb78, 0xe6f6, 0xf273, 0xfe25, 0x0a03,
+0x15b4, 0x20c9, 0x2b59, 0x3570, 0x3edb, 0x473d, 0x4e9f, 0x5510,
+0x5a5d, 0x5e2c, 0x608e, 0x61c8, 0x61d4, 0x6064, 0x5d69, 0x5932,
+0x53ed, 0x4d89, 0x45ee, 0x3d5d, 0x340a, 0x2a13, 0x1f78, 0x1473,
+0x092a, 0xfdca, 0xf268, 0xe73f, 0xdc69, 0xd216, 0xc86b, 0xbfa1,
+0xb7b1, 0xb0a4, 0xaaa7, 0xa60a, 0xa2d4, 0xa0d9, 0xa017, 0xa0c6,
+0xa2ff, 0xa68b, 0xab3d, 0xb117, 0xb82c, 0xc051, 0xc961, 0xd339,
+0xddca, 0xe8d1, 0xf423, 0xff9d, 0x0b3c, 0x16c2, 0x21ff, 0x2cbc,
+0x36ea, 0x405f, 0x48ff, 0x509d, 0x5723, 0x5c74, 0x6093, 0x6374,
+0x6501, 0x6520, 0x63db, 0x6150, 0x5d81, 0x5867, 0x520e, 0x4aa8,
+0x4255, 0x3932, 0x2f4d, 0x24d6, 0x19db, 0x0e87, 0x02fb, 0xf77a,
+0xec12, 0xe0ea, 0xd632, 0xcc38, 0xc304, 0xba96, 0xb304, 0xaca6,
+0xa7a3, 0xa3ef, 0xa171, 0xa046, 0xa088, 0xa230, 0xa529, 0xa973,
+0xaf13, 0xb5dd, 0xbda3, 0xc63f, 0xcfb0, 0xd9d7, 0xe496, 0xefb1,
+0xfb0c, 0x0671, 0x11cc, 0x1cea, 0x27af, 0x31df, 0x3b64, 0x441a,
+0x4bef, 0x52b8, 0x585c, 0x5cc4, 0x5fed, 0x61ce, 0x6265, 0x61a8,
+0x5f8d, 0x5c17, 0x575e, 0x5186, 0x4a94, 0x429a, 0x39a9, 0x2ff4,
+0x2591, 0x1ab2, 0x0f76, 0x0411, 0xf885, 0xecf6, 0xe193, 0xd6b5,
+0xcc7e, 0xc308, 0xba5a, 0xb2a0, 0xabeb, 0xa65b, 0xa212, 0x9f39,
+0x9dd2, 0x9dc2, 0x9ef9, 0xa17b, 0xa54f, 0xaa5d, 0xb09c, 0xb7f0,
+0xc044, 0xc966, 0xd348, 0xddc8, 0xe8c2, 0xf3ec, 0xff34, 0x0a87,
+0x15d4, 0x20c7, 0x2b2a, 0x34d5, 0x3dcd, 0x45f4, 0x4d37, 0x536c,
+0x5872, 0x5c23, 0x5e85, 0x5fac, 0x5f96, 0x5e23, 0x5b48, 0x5724,
+0x51d4, 0x4b63, 0x43d3, 0x3b52, 0x31fd, 0x27e8, 0x1d17, 0x11d0,
+0x064e, 0xfac4, 0xef30, 0xe3c7, 0xd8c0, 0xce55, 0xc48a, 0xbb85,
+0xb375, 0xac94, 0xa6e7, 0xa275, 0x9f4d, 0x9d82, 0x9d07, 0x9dca,
+0x9fda, 0xa34b, 0xa811, 0xadf5, 0xb4da, 0xbcb5, 0xc58c, 0xcf32,
+0xd988, 0xe457, 0xef80, 0xfac9, 0x061e, 0x1161, 0x1c81, 0x2733,
+0x314a, 0x3a9e, 0x4334, 0x4aec, 0x51a0, 0x571d, 0x5b5c, 0x5e5a,
+0x6019, 0x608a, 0x5fa0, 0x5d5b, 0x59c3, 0x54e4, 0x4ebb, 0x4760,
+0x3ef4, 0x35b2, 0x2bb3, 0x2117, 0x15f0, 0x0a79, 0xfed4, 0xf333,
+0xe7b6, 0xdca7, 0xd232, 0xc881, 0xbf8c, 0xb766, 0xb026, 0xaa08,
+0xa52b, 0xa19b, 0x9f50, 0x9e53, 0x9eab, 0xa050, 0xa336, 0xa759,
+0xacc4, 0xb360, 0xbb01, 0xc376, 0xccbd, 0xd6c6, 0xe173, 0xec78,
+0xf7b7, 0x0314, 0x0e81, 0x19ba, 0x249b, 0x2ef7, 0x38c1, 0x41c9,
+0x49f1, 0x5112, 0x571e, 0x5bed, 0x5f6b, 0x6189, 0x624c, 0x61b8,
+0x5fc5, 0x5c69, 0x57a8, 0x51ac, 0x4aa0, 0x42a7, 0x39af, 0x2fc1,
+0x250c, 0x19fc, 0x0ec8, 0x0387, 0xf826, 0xecd0, 0xe1b6, 0xd718,
+0xcd0f, 0xc3c9, 0xbb5a, 0xb3df, 0xad62, 0xa808, 0xa3ed, 0xa11f,
+0x9f95, 0x9f4c, 0xa054, 0xa2b8, 0xa674, 0xab70, 0xb196, 0xb8c3,
+0xc0e8, 0xc9ec, 0xd3c6, 0xde44, 0xe937, 0xf469, 0xffd7, 0x0b60,
+0x16df, 0x2203, 0x2ca3, 0x369b, 0x3fe9, 0x4869, 0x4ff7, 0x5655,
+0x5b66, 0x5f21, 0x619a, 0x62c7, 0x628d, 0x60da, 0x5dbd, 0x5956,
+0x53b2, 0x4ce9, 0x4518, 0x3c6c, 0x32ee, 0x28be, 0x1dfa, 0x12df,
+0x0782, 0xfc0e, 0xf0a9, 0xe597, 0xdae9, 0xd0bb, 0xc71f, 0xbe53,
+0xb671, 0xaf95, 0xa9d1, 0xa545, 0xa1f5, 0x9fe2, 0x9f17, 0x9fb1,
+0xa1b1, 0xa4fd, 0xa97d, 0xaf29, 0xb5fc, 0xbdd8, 0xc6a8, 0xd04b,
+0xdaa4, 0xe571, 0xf096, 0xfbf5, 0x0785, 0x130a, 0x1e53, 0x2925,
+0x336b, 0x3cf9, 0x45b0, 0x4d5d, 0x53eb, 0x5948, 0x5d7a, 0x6068,
+0x61ef, 0x61f1, 0x6080, 0x5dc3, 0x59d2, 0x54b9, 0x4e7b, 0x472d,
+0x3ed6, 0x359b, 0x2ba0, 0x2127, 0x163d, 0x0b02, 0xff93, 0xf43a,
+0xe914, 0xde46, 0xd3dd, 0xca0b, 0xc0e9, 0xb8a0, 0xb150, 0xab27,
+0xa629, 0xa25c, 0x9fce, 0x9e9c, 0x9ec9, 0xa043, 0xa30a, 0xa720,
+0xac7a, 0xb2ec, 0xba63, 0xc2d3, 0xcc36, 0xd65c, 0xe12b, 0xec72,
+0xf807, 0x039c, 0x0f1c, 0x1a69, 0x256f, 0x2fe4, 0x39a6, 0x4298,
+0x4aa4, 0x5185, 0x571a, 0x5b67, 0x5e8c, 0x607a, 0x6114, 0x6052,
+0x5e44, 0x5aee, 0x5647, 0x5066, 0x496d, 0x4183, 0x38b1, 0x2f1a,
+0x24e0, 0x1a36, 0x0f25, 0x03d3, 0xf861, 0xed15, 0xe208, 0xd765,
+0xcd42, 0xc3d7, 0xbb3e, 0xb39c, 0xad02, 0xa792, 0xa358, 0xa05d,
+0x9e9c, 0x9e23, 0x9f06, 0xa153, 0xa508, 0xaa0c, 0xb04d, 0xb7aa,
+0xc010, 0xc952, 0xd35b, 0xde03, 0xe92e, 0xf4a1, 0x003f, 0x0bdc,
+0x1761, 0x227e, 0x2cf7, 0x369f, 0x3f8e, 0x47bb, 0x4eff, 0x5514,
+0x59e9, 0x5d89, 0x5ff8, 0x6112, 0x60bf, 0x5f13, 0x5c2e, 0x5817,
+0x52be, 0x4c36, 0x44a1, 0x3c2b, 0x32e0, 0x28e3, 0x1e50, 0x1358,
+0x080b, 0xfc98, 0xf12a, 0xe606, 0xdb3f, 0xd0f3, 0xc732, 0xbe30,
+0xb60c, 0xaee9, 0xa8dd, 0xa40e, 0xa090, 0x9e72, 0x9db4, 0x9e59,
+0xa065, 0xa3ce, 0xa885, 0xae6d, 0xb57a, 0xbd92, 0xc6a9, 0xd090,
+0xdb24, 0xe62c, 0xf184, 0xfceb, 0x0848, 0x137d, 0x1e8a, 0x2938,
+0x3353, 0x3ca0, 0x4519, 0x4c9e, 0x5311, 0x5851, 0x5c66, 0x5f4c,
+0x60e9, 0x611f, 0x5ffc, 0x5d9d, 0x59fb, 0x5509, 0x4ed5, 0x4798,
+0x3f6d, 0x3665, 0x2c8a, 0x2218, 0x172b, 0x0bec, 0x0072, 0xf502,
+0xe9b3, 0xde9c, 0xd3d7, 0xc9bd, 0xc080, 0xb834, 0xb0cd, 0xaa7c,
+0xa570, 0xa1bd, 0x9f4c, 0x9e25, 0x9e63, 0xa00c, 0xa30d, 0xa75a,
+0xacf8, 0xb3c2, 0xbb7b, 0xc3ef, 0xcd35, 0xd745, 0xe1f5, 0xecf4,
+0xf831, 0x0396, 0x0f05, 0x1a2b, 0x24eb, 0x2f2a, 0x38d9, 0x41b4,
+0x49a3, 0x5099, 0x5691, 0x5b51, 0x5eb9, 0x60ca, 0x619d, 0x6128,
+0x5f4d, 0x5c0e, 0x578b, 0x51e6, 0x4b1f, 0x4344, 0x3a6a, 0x30ca,
+0x2682, 0x1bb8, 0x1078, 0x04f2, 0xf949, 0xedc2, 0xe27a, 0xd7a3,
+0xcd57, 0xc3d1, 0xbb27, 0xb36d, 0xacad, 0xa719, 0xa2d8, 0x9ffb,
+0x9e6f, 0x9e36, 0x9f65, 0xa1f7, 0xa5ca, 0xaaba, 0xb0d1, 0xb80a,
+0xc04d, 0xc95d, 0xd32e, 0xddab, 0xe8be, 0xf414, 0xff84, 0x0af2,
+0x165e, 0x218c, 0x2c43, 0x3649, 0x3f93, 0x4805, 0x4f86, 0x55e7,
+0x5b11, 0x5ef0, 0x6181, 0x62bc, 0x6298, 0x6110, 0x5e29, 0x59f3,
+0x5479, 0x4dd1, 0x4608, 0x3d4c, 0x33b5, 0x2964, 0x1e63, 0x12e5,
+0x0716, 0xfb3f, 0xef7b, 0xe3f4, 0xd8c2, 0xce20, 0xc42b, 0xbb08,
+0xb2ca, 0xaba6, 0xa5bd, 0xa12a, 0x9ddf, 0x9be1, 0x9b3a, 0x9bf3,
+0x9e05, 0xa167, 0xa627, 0xac39, 0xb379, 0xbbab, 0xc4c1, 0xcead,
+0xd95f, 0xe496, 0xf02b, 0xfbf4, 0x07de, 0x13ac, 0x1f37, 0x2a47,
+0x34c9, 0x3e93, 0x478b, 0x4f80, 0x5658, 0x5bf3, 0x604e, 0x6357,
+0x64fa, 0x6526, 0x63e0, 0x613e, 0x5d4c, 0x5815, 0x519e, 0x4a09,
+0x4166, 0x37de, 0x2d8b, 0x22a4, 0x1738, 0x0b72, 0xff73, 0xf388,
+0xe7d4, 0xdc8a, 0xd1cd, 0xc7d6, 0xbeae, 0xb65d, 0xaeeb, 0xa89b,
+0xa396, 0x9fe6, 0x9d76, 0x9c57, 0x9ca4, 0x9e65, 0xa17d, 0xa5cf,
+0xab5e, 0xb226, 0xba16, 0xc2f7, 0xcca7, 0xd701, 0xe1f4, 0xed51,
+0xf8f9, 0x04b5, 0x106d, 0x1be9, 0x270d, 0x31a5, 0x3b98, 0x44b2,
+0x4cd8, 0x53e8, 0x59df, 0x5e9f, 0x6208, 0x63f9, 0x647b, 0x63a8,
+0x618c, 0x5e1c, 0x5948, 0x5327, 0x4bd5, 0x4380, 0x3a3d, 0x3038,
+0x258a, 0x1a72, 0x0f1d, 0x03c6, 0xf864, 0xecf6, 0xe18f, 0xd697,
+0xcc53, 0xc2de, 0xba1b, 0xb233, 0xab68, 0xa5ea, 0xa19c, 0x9e74,
+0x9c93, 0x9c26, 0x9d24, 0x9f66, 0xa2ef, 0xa7cc, 0xadf2, 0xb525,
+0xbd57, 0xc67f, 0xd08e, 0xdb31, 0xe640, 0xf1a8, 0xfd69, 0x0933,
+0x14cb, 0x2005, 0x2ae7, 0x3532, 0x3eb3, 0x4741, 0x4eeb, 0x558a,
+0x5ae9, 0x5ee7, 0x61a3, 0x6325, 0x6344, 0x61d9, 0x5ef4, 0x5ac6,
+0x5564, 0x4ee0, 0x475a, 0x3f07, 0x35e2, 0x2be5, 0x211c, 0x15dc,
+0x0a64, 0xfee6, 0xf366, 0xe80c, 0xdd1b, 0xd332, 0xcb44, 0xc69b,
+0xc628, 0xc9a5, 0xcf00, 0xd34b, 0xd4eb, 0xd4f4, 0xd5e0, 0xd8ac,
+0xdbd8, 0xdd89, 0xde09, 0xdf20, 0xe171, 0xe3b8, 0xe4e4, 0xe5a4,
+0xe72b, 0xe933, 0xea8e, 0xeb10, 0xebca, 0xed44, 0xeec5, 0xef99,
+0xf02d, 0xf12a, 0xf255, 0xf30d, 0xf36e, 0xf418, 0xf51a, 0xf5de,
+0xf62f, 0xf688, 0xf73b, 0xf7f9, 0xf878, 0xf8f0, 0xf9a9, 0xfa77,
+0xfb13, 0xfb96, 0xfc4c, 0xfd2a, 0xfdf4, 0xfeac, 0xff80, 0x0066,
+0x012c, 0x01de, 0x02bc, 0x03bf, 0x0494, 0x051b, 0x059a, 0x064a,
+0x070b, 0x079e, 0x080f, 0x088a, 0x090d, 0x0973, 0x09b4, 0x09e3,
+0x09f8, 0x09d9, 0x0990, 0x0952, 0x0935, 0x091f, 0x08fc, 0x08e0,
+0x08e1, 0x08f1, 0x08f0, 0x08d6, 0x08b9, 0x08ac, 0x08b0, 0x08b4,
+0x08a7, 0x0886, 0x0852, 0x0813, 0x07d5, 0x07ad, 0x07a5, 0x07a7,
+0x078f, 0x0763, 0x0750, 0x076b, 0x078d, 0x0791, 0x078b, 0x07aa,
+0x07e1, 0x07fb, 0x07ec, 0x07e3, 0x07f9, 0x0812, 0x0811, 0x0805,
+0x0802, 0x07f8, 0x07d4, 0x07a4, 0x077d, 0x0753, 0x070e, 0x06bc,
+0x067c, 0x0645, 0x05eb, 0x055d, 0x04c5, 0x0457, 0x041d, 0x03f7,
+0x03c0, 0x0371, 0x0319, 0x02d1, 0x029b, 0x0268, 0x0236, 0x0216,
+0x0215, 0x020e, 0x01cd, 0x0150, 0x00d2, 0x0086, 0x005f, 0x0031,
+0xfff3, 0xffbc, 0xff96, 0xff6f, 0xff3f, 0xff18, 0xff0a, 0xff04,
+0xfef6, 0xfee4, 0xfee0, 0xfee7, 0xfeeb, 0xfee7, 0xfee4, 0xfee1,
+0xfed7, 0xfecc, 0xfeca, 0xfed1, 0xfeca, 0xfeaf, 0xfe8c, 0xfe72,
+0xfe61, 0xfe51, 0xfe34, 0xfdfc, 0xfdae, 0xfd6f, 0xfd61, 0xfd70,
+0xfd6c, 0xfd47, 0xfd25, 0xfd21, 0xfd25, 0xfd1b, 0xfd18, 0xfd31,
+0xfd54, 0xfd60, 0xfd54, 0xfd3c, 0xfd10, 0xfcd0, 0xfc98, 0xfc7e,
+0xfc67, 0xfc36, 0xfc04, 0xfbf9, 0xfc03, 0xfbf0, 0xfbc6, 0xfbc0,
+0xfbef, 0xfc1f, 0xfc2c, 0xfc34, 0xfc58, 0xfc8c, 0xfcb7, 0xfcdd,
+0xfd09, 0xfd2c, 0xfd38, 0xfd3e, 0xfd51, 0xfd65, 0xfd6a, 0xfd67,
+0xfd6d, 0xfd75, 0xfd6d, 0xfd58, 0xfd4c, 0xfd51, 0xfd5c, 0xfd60,
+0xfd5a, 0xfd4f, 0xfd49, 0xfd4d, 0xfd54, 0xfd55, 0xfd56, 0xfd6c,
+0xfd98, 0xfdc2, 0xfdd0, 0xfdcb, 0xfdc5, 0xfdca, 0xfdd0, 0xfdd3,
+0xfdd3, 0xfdd2, 0xfdd2, 0xfdd5, 0xfdda, 0xfddf, 0xfde4, 0xfdef,
+0xfe01, 0xfe18, 0xfe35, 0xfe57, 0xfe7e, 0xfea7, 0xfed3, 0xff01,
+0xff2b, 0xff4d, 0xff6f, 0xff9a, 0xffc7, 0xffe7, 0xfff8, 0x0003,
+0x0010, 0x0017, 0x0015, 0x0011, 0x000f, 0x000e, 0x000e, 0x0011,
+0x0018, 0x001f, 0x0026, 0x0034, 0x0047, 0x0056, 0x0060, 0x006e,
+0x0083, 0x0097, 0x00a4, 0x00af, 0x00be, 0x00d0, 0x00dc, 0x00e2,
+0x00e8, 0x00f2, 0x00fe, 0x010a, 0x0112, 0x0115, 0x0117, 0x011c,
+0x0125, 0x012d, 0x0134, 0x0138, 0x013e, 0x0146, 0x014f, 0x015a,
+0x0165, 0x016d, 0x0176, 0x017f, 0x0187, 0x018c, 0x0192, 0x019a,
+0x019e, 0x019c, 0x0195, 0x0190, 0x018d, 0x018a, 0x0186, 0x0184,
+0x0181, 0x017b, 0x0176, 0x0179, 0x017f, 0x0181, 0x017f, 0x0180,
+0x0187, 0x018b, 0x018c, 0x018d, 0x018d, 0x0187, 0x017c, 0x0175,
+0x0178, 0x0179, 0x0174, 0x016d, 0x016c, 0x016c, 0x0169, 0x0164,
+0x015f, 0x015b, 0x0156, 0x0151, 0x014e, 0x014b, 0x0147, 0x0144,
+0x0143, 0x013e, 0x0134, 0x012a, 0x0126, 0x0127, 0x0125, 0x011e,
+0x0118, 0x0113, 0x0110, 0x010c, 0x0106, 0x0100, 0x00f8, 0x00f0,
+0x00e9, 0x00e3, 0x00dd, 0x00d5, 0x00d0, 0x00cc, 0x00c8, 0x00c4,
+0x00c1, 0x00be, 0x00b9, 0x00af, 0x00a2, 0x0097, 0x0090, 0x008c,
+0x0086, 0x007e, 0x0075, 0x006d, 0x0064, 0x005b, 0x0054, 0x004e,
+0x0048, 0x0041, 0x003d, 0x003c, 0x003e, 0x003d, 0x0037, 0x002f,
+0x0026, 0x001d, 0x0015, 0x000f, 0x000a, 0x0005, 0x0001, 0x0001,
+0x0004, 0x0004, 0xffff, 0xfff6, 0xffee, 0xffe7, 0xffdd, 0xffd3,
+0xffca, 0xffc5, 0xffc3, 0xffc0, 0xffbc, 0xffba, 0xffba, 0xffba,
+0xffb5, 0xffad, 0xffa6, 0xff9f, 0xff99, 0xff91, 0xff8d, 0xff8d,
+0xff90, 0xff91, 0xff91, 0xff94, 0xff96, 0xff95, 0xff91, 0xff8f,
+0xff90, 0xff8f, 0xff8b, 0xff88, 0xff89, 0xff8b, 0xff8a, 0xff86,
+0xff86, 0xff89, 0xff89, 0xff87, 0xff85, 0xff85, 0xff85, 0xff85,
+0xff85, 0xff87, 0xff88, 0xff87, 0xff86, 0xff86, 0xff85, 0xff83,
+0xff80, 0xff7f, 0xff81, 0xff84, 0xff86, 0xff89, 0xff8c, 0xff8e,
+0xff8f, 0xff91, 0xff95, 0xff9a, 0xff9e, 0xff9f, 0xff9d, 0xff99,
+0xff96, 0xff97, 0xff9a, 0xff9e, 0xffa2, 0xffa5, 0xffa7, 0xffa6,
+0xffa3, 0xffa3, 0xffa7, 0xffaa, 0xffaa, 0xffa8, 0xffa8, 0xffa9,
+0xffaa, 0xffaa, 0xffae, 0xffb5, 0xffb8, 0xffb6, 0xffb6, 0xffbb,
+0xffc4, 0xffcb, 0xffcd, 0xffcf, 0xffd2, 0xffd1, 0xffcf, 0xffcf,
+0xffd0, 0xffd1, 0xffcf, 0xffcd, 0xffcf, 0xffd3, 0xffd8, 0xffde,
+0xffe3, 0xffe8, 0xffed, 0xfff0, 0xfff2, 0xfff2, 0xfff2, 0xfff3,
+0xfff6, 0xfff7, 0xfff7, 0xfff9, 0xfffe, 0x0004, 0x0007, 0x0008,
+0x0008, 0x0009, 0x0007, 0x0005, 0x0006, 0x000a, 0x000d, 0x000e,
+0x000f, 0x0011, 0x0013, 0x0013, 0x0015, 0x001b, 0x0020, 0x0020,
+0x001c, 0x0017, 0x0018, 0x001c, 0x0021, 0x0025, 0x0029, 0x002e,
+0x0033, 0x0035, 0x0032, 0x002f, 0x002f, 0x0032, 0x0035, 0x0038,
+0x003b, 0x0040, 0x0043, 0x0042, 0x003f, 0x003e, 0x003e, 0x003c,
+0x003b, 0x003d, 0x003f, 0x0040, 0x0040, 0x0041, 0x0041, 0x003f,
+0x003c, 0x003c, 0x003b, 0x003a, 0x003a, 0x003a, 0x0039, 0x0035,
+0x0031, 0x0031, 0x0034, 0x0033, 0x0030, 0x0030, 0x0033, 0x0036,
+0x0033, 0x0030, 0x0030, 0x0032, 0x0034, 0x0036, 0x0036, 0x0034,
+0x002e, 0x0029, 0x0029, 0x002a, 0x002a, 0x002a, 0x002a, 0x0029,
+0x0024, 0x0021, 0x0025, 0x002c, 0x002c, 0x0025, 0x001e, 0x001d
+};
+
+
diff --git a/mcu/driver/audio/src/v1/sp_strm_drv.c b/mcu/driver/audio/src/v1/sp_strm_drv.c
new file mode 100644
index 0000000..e518e86
--- /dev/null
+++ b/mcu/driver/audio/src/v1/sp_strm_drv.c
@@ -0,0 +1,645 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * sp_strm_drv.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Data card speech streaming driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__DATA_CARD_SPEECH__)
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "l1audio_trace_utmd.h"
+#include "l1audio.h"
+#include "drv_sap.h"
+#include "audio_msgid.h"
+#include "cmux_msgid.h"
+#include "drv_msgid.h"
+
+#include "dcl.h"
+#include "audio_enum.h"
+#include "cmux_struct.h" // For cmux_dlc_connect_ind_struct;
+#include "l1sp_trc.h"
+#include "sp_daca.h"
+
+typedef struct spstrmcontrol SpStrmControl;
+#define CMUX_SPEECH_CHANNEL 10
+#define WB_FRAME_SIZE 320
+
+typedef enum{
+ VIA_CMUX_MODE,
+ VIA_USB_MODE
+}DATA_CARD_MODE;
+
+struct spstrmcontrol{
+ kal_int16 ul_pcm[WB_FRAME_SIZE]; // fixed WB
+ kal_int16 dl_pcm[WB_FRAME_SIZE]; // fixed WB
+ kal_uint16 fc_aud_id;
+ kal_bool is_strmOn;
+ kal_uint16 ul_sample_count;
+ kal_bool ul_ready;
+ kal_bool dl_ready;
+ UART_PORT port;
+ DATA_CARD_MODE mode;
+ DCL_HANDLE cmux_handle;
+ DCL_HANDLE usb_handle;
+};
+
+typedef struct {
+ kal_uint8 ref_count;
+ kal_uint16 msg_len;
+ void *para;
+} sstrm_para_struct;
+
+DCL_HANDLE gUSB_HANDLE;
+SpStrmControl *intSStrmControl = NULL;
+kal_enhmutexid ss_enh_mutex = NULL;
+
+extern void L1SP_UnRegister_Strm_Handler( void );
+extern void L1SP_Register_Strm_Handler( void (*onHandler)(void *hdl), void (*offHandler)(void *hdl), void (*hdl)(kal_uint32 event, void *param));
+
+//#define SS_UNIT_TEST
+#if defined(SS_UNIT_TEST)
+#define SS_BUF_MASK 7
+kal_uint16 ss_buf_idx = 0;
+kal_uint16 SS_BUFF[8][WB_FRAME_SIZE];
+#endif
+
+/* send message to AUDL task*/
+void spStrmCallback(kal_uint32 event, void *param)
+{
+ msg_send4(MOD_L1SP, MOD_MED, AUDIO_SAP, event);
+
+}
+
+
+
+/*in audio task*/
+void daca_dl_hdlr(void){
+ if(NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(7);
+ return;
+ }
+
+ MD_TRC_DACA_ENTER_REQUEST_EXCHANGE_DL_DATA(intSStrmControl->is_strmOn, intSStrmControl->dl_ready);
+
+ if( intSStrmControl->dl_ready == KAL_TRUE )
+ return;
+#if 1
+ ASSERT(DACA_GetFromSD( (uint16 *)intSStrmControl->dl_pcm ) == WB_FRAME_SIZE);
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ spStrmCallback( MSG_ID_STRM_SPEECH_DL_DATA_NOTIFY, NULL );
+ intSStrmControl->dl_ready = true;
+}
+
+void daca_ul_hdlr(void){
+ if(NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(8);
+ return;
+ }
+
+ MD_TRC_DACA_ENTER_REQUEST_EXCHANGE_UL_DATA(intSStrmControl->is_strmOn, intSStrmControl->ul_ready);
+
+ if( !intSStrmControl->ul_ready ){
+ MD_TRC_DACA_UL_HAS_NO_DATA();
+
+ DACA_FillSE(0);
+ }else{
+ MD_TRC_DACA_UL_HAS_DATA();
+
+#if 1
+ DACA_PutToSE( (uint16 *)intSStrmControl->ul_pcm );
+#else
+/* under construction !*/
+/* under construction !*/
+#endif
+ intSStrmControl->ul_ready = KAL_FALSE;
+ }
+ spStrmCallback( MSG_ID_STRM_SPEECH_UL_DATA_REQUEST, NULL );
+ MD_TRC_DACA_LEAVE_REQUEST_EXCHANGE_UL_DATA();
+}
+
+/*Run in L1SP_Speech_On, usually in MED_TASK*/
+void spStrmOnHandler( void *data )
+{
+ if(NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(9);
+ return;
+ }
+
+ memset(intSStrmControl->dl_pcm, 0, sizeof(kal_int16) * WB_FRAME_SIZE);
+ memset(intSStrmControl->ul_pcm, 0, sizeof(kal_int16) * WB_FRAME_SIZE);
+
+ spStrmCallback( MSG_ID_SPEECH_ON_ACK, NULL );
+ DACA_Start(daca_dl_hdlr, daca_ul_hdlr, DACA_APP_TYPE_ACTIVE_UL_DL_WB);
+ intSStrmControl->is_strmOn = KAL_TRUE;
+ MD_TRC_DACA_ENTER_STRMONHANDLER();
+}
+/*Run in L1SP_Speech_Off, usually in MED_TASK*/
+void spStrmOffHandler( void *data)
+{
+ if(NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(10);
+ return;
+ }
+
+ DACA_Stop(DACA_APP_TYPE_ACTIVE_UL_DL_WB);
+ spStrmCallback( MSG_ID_SPEECH_OFF_ACK, NULL );
+ intSStrmControl->is_strmOn = KAL_FALSE;
+ MD_TRC_DACA_ENTER_STRMOFFHANDLER();
+}
+
+#ifdef __SPEECH_OVER_USB__
+UART_PORT SPEECH_PORT = uart_port1;
+#endif
+
+void SP_Strm_Init()
+{
+#if DATA_CARD_DISABLE_INTERNAL
+ return;
+#endif
+#ifdef __SPEECH_OVER_USB__
+ UART_CTRL_OPEN_T data;
+ DCL_STATUS status;
+ ASSERT(SPEECH_PORT != uart_port_null);
+ gUSB_HANDLE = DclSerialPort_Open(SPEECH_PORT, 0);
+
+ MD_TRC_DACA_OPEN_PORT(VIA_USB_MODE, SPEECH_PORT);
+ data.u4OwenrId = MOD_MED;
+ status = DclSerialPort_Control(gUSB_HANDLE, SIO_CMD_OPEN, (DCL_CTRL_DATA_T*)&data); // Notice!! Only when SIO_CMD_OPEN, USB task will send MSG_ID_UART_PLUGIN_IND to AUDL
+ ASSERT(STATUS_OK == status);
+#endif
+
+}
+
+void SP_Strm_Enable( )
+{
+ UART_CTRL_OPEN_T data;
+ DCL_STATUS status;
+
+ ASSERT (intSStrmControl != NULL );
+
+ intSStrmControl->ul_ready = intSStrmControl->dl_ready = KAL_FALSE;
+ intSStrmControl->ul_sample_count = 0;
+ intSStrmControl->is_strmOn = KAL_FALSE;
+#if !defined(SS_UNIT_TEST)
+ data.u4OwenrId = MOD_MED;
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ status = DclSerialPort_Control(intSStrmControl->cmux_handle, SIO_CMD_OPEN, (DCL_CTRL_DATA_T*)&data);
+ ASSERT(STATUS_OK == status);
+ break;
+ case VIA_USB_MODE:
+ //OpenPort in SP_Strm_Init which is invoked in reboot
+ break;
+ }
+ MD_TRC_DACA_STRM_ENABLE(intSStrmControl->mode);
+#endif
+ L1SP_Register_Strm_Handler( spStrmOnHandler, spStrmOffHandler, spStrmCallback );
+}
+
+void SP_Strm_Disable( void )
+{
+ //FIXME: for phone call usage
+
+#if !defined(SS_UNIT_TEST)
+ UART_CTRL_CLOSE_T data;
+ ASSERT (intSStrmControl != NULL );
+ data.u4OwenrId = MOD_MED;
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ DclSerialPort_Control( intSStrmControl->cmux_handle, SIO_CMD_CLOSE, (DCL_CTRL_DATA_T*)&data);
+ break;
+ case VIA_USB_MODE:
+ //DclSerialPort_Control( intSStrmControl->usb_handle, SIO_CMD_CLOSE, (DCL_CTRL_DATA_T*)&data); //After PC hibernates, USB will send the driver "plugout". If The driver closes connection with USB port, it causes the USB can't send "plugin" to the driver even if PC wakes up!! In this case, the driver stays without datacard mode. Any voice can be delivered to PC
+ break;
+ }
+ MD_TRC_DACA_STRM_DISABLE(intSStrmControl->mode);
+#endif
+
+ free_ctrl_buffer(intSStrmControl);
+ intSStrmControl = NULL;
+
+ L1SP_UnRegister_Strm_Handler();
+}
+
+
+
+void SP_Strm_Audl_Handler( ilm_struct *ilm_ptr )
+{
+ #if DATA_CARD_DISABLE_INTERNAL
+ return;
+ #endif
+ switch (ilm_ptr->msg_id) {
+ case MSG_ID_CMUX_DLC_CONNECT_IND:
+ {
+ cmux_dlc_connect_ind_struct *local_para;
+ MD_TRC_DACA_PLUGIN(VIA_CMUX_MODE);
+ //ASSERT (NULL == intSStrmControl);
+ if (NULL != intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(1);
+ return;
+ }
+
+ intSStrmControl = (SpStrmControl *)get_ctrl_buffer(sizeof(SpStrmControl));
+ local_para = (cmux_dlc_connect_ind_struct *)ilm_ptr->local_para_ptr;
+ MD_TRC_DACA_OPEN_PORT(VIA_CMUX_MODE, local_para->port);
+
+ intSStrmControl->cmux_handle = DclSerialPort_Open(local_para->port, 0);
+ intSStrmControl->mode = VIA_CMUX_MODE;
+ SP_Strm_Enable();
+ }
+ break;
+#ifdef __SPEECH_OVER_USB__
+ case MSG_ID_UART_PLUGIN_IND:
+ MD_TRC_DACA_PLUGIN(VIA_USB_MODE);
+ //ASSERT (NULL == intSStrmControl);
+ if (NULL != intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(2);
+ return;
+ }
+ intSStrmControl = (SpStrmControl *)get_ctrl_buffer(sizeof(SpStrmControl));
+
+ intSStrmControl->usb_handle = gUSB_HANDLE;
+ intSStrmControl->mode = VIA_USB_MODE;
+ SP_Strm_Enable();
+ break;
+#endif
+ case MSG_ID_UART_PLUGOUT_IND:
+ //ASSERT (intSStrmControl != NULL );
+ if( NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(3);
+ return;
+ }
+ SP_Strm_Disable();
+
+ break;
+ case MSG_ID_SPEECH_ON_ACK:
+ case MSG_ID_SPEECH_OFF_ACK:
+ {
+ UART_CTRL_CLR_BUFFER_T data;
+ data.u4OwenrId = MOD_MED;
+
+ //ASSERT (NULL == intSStrmControl);
+ if (NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(4);
+ return;
+ }
+
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ DclSerialPort_Control( intSStrmControl->cmux_handle,SIO_CMD_CLR_RX_BUF, (DCL_CTRL_DATA_T*)&data);
+ DclSerialPort_Control( intSStrmControl->cmux_handle,SIO_CMD_CLR_TX_BUF, (DCL_CTRL_DATA_T*)&data);
+ break;
+ case VIA_USB_MODE:
+ DclSerialPort_Control( intSStrmControl->usb_handle,SIO_CMD_CLR_RX_BUF, (DCL_CTRL_DATA_T*)&data);
+ DclSerialPort_Control( intSStrmControl->usb_handle,SIO_CMD_CLR_TX_BUF, (DCL_CTRL_DATA_T*)&data);
+ break;
+ }
+ break;
+ }
+#if !defined(SS_UNIT_TEST)
+ case MSG_ID_UART_READY_TO_READ_IND:
+ case MSG_ID_STRM_SPEECH_UL_DATA_REQUEST:
+ {
+ UART_CTRL_GET_BYTES_T data;
+ kal_uint8 status;
+
+ // ASSERT (NULL == intSStrmControl);
+ if (NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(5);
+ return;
+ }
+ MD_TRC_DACA_ENTER_GETDATA1(intSStrmControl->is_strmOn, intSStrmControl->ul_ready);
+
+ if(!intSStrmControl->is_strmOn){
+ UART_CTRL_CLR_BUFFER_T data;
+ data.u4OwenrId = MOD_MED;
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ DclSerialPort_Control( intSStrmControl->cmux_handle,SIO_CMD_CLR_RX_BUF, (DCL_CTRL_DATA_T*)&data);
+ DclSerialPort_Control( intSStrmControl->cmux_handle,SIO_CMD_CLR_TX_BUF, (DCL_CTRL_DATA_T*)&data);
+ break;
+ case VIA_USB_MODE:
+ DclSerialPort_Control( intSStrmControl->usb_handle,SIO_CMD_CLR_RX_BUF, (DCL_CTRL_DATA_T*)&data);
+ DclSerialPort_Control( intSStrmControl->usb_handle,SIO_CMD_CLR_TX_BUF, (DCL_CTRL_DATA_T*)&data);
+ break;
+ }
+ }else{
+ if( intSStrmControl->ul_ready == KAL_TRUE )
+ return;
+ MD_TRC_DACA_ENTER_GETDATA2();
+ data.u4OwenrId = MOD_MED;
+ data.u2Length = WB_FRAME_SIZE * sizeof(kal_int16) - intSStrmControl->ul_sample_count;
+ data.puBuffaddr = (DCL_UINT8 *)intSStrmControl->ul_pcm + intSStrmControl->ul_sample_count;
+ data.pustatus = &status;
+
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ DclSerialPort_Control( intSStrmControl->cmux_handle,SIO_CMD_GET_BYTES, (DCL_CTRL_DATA_T*)&data);
+ MD_TRC_DACA_GET_DATA(data.u2RetSize, VIA_CMUX_MODE, data.u2Length);
+ break;
+ case VIA_USB_MODE:
+ DclSerialPort_Control( intSStrmControl->usb_handle,SIO_CMD_GET_BYTES, (DCL_CTRL_DATA_T*)&data);
+ MD_TRC_DACA_GET_DATA(data.u2RetSize, VIA_USB_MODE, data.u2Length);
+ break;
+ }
+
+ intSStrmControl->ul_sample_count += data.u2RetSize;
+ if( intSStrmControl->ul_sample_count >= WB_FRAME_SIZE * sizeof(kal_int16) ){
+ intSStrmControl->ul_sample_count = 0;
+ intSStrmControl->ul_ready = KAL_TRUE;
+
+ MD_TRC_DACA_GET_SUFFICIENT_DATA();
+ }else{
+ MD_TRC_DACA_GET_INSUFFICIENT_DATA();
+ }
+ MD_TRC_DACA_LEAVE_GETDATA();
+ }
+ break;
+ }
+ case MSG_ID_UART_READY_TO_WRITE_IND:
+ case MSG_ID_STRM_SPEECH_DL_DATA_NOTIFY:
+ {
+ UART_CTRL_PUT_BYTES_T data;
+
+ //ASSERT (NULL == intSStrmControl);
+ if (NULL == intSStrmControl){
+ MD_TRC_DACA_EXCEPTION(6);
+ return;
+ }
+ MD_TRC_DACA_ENTER_PUTDATA1(intSStrmControl->is_strmOn, intSStrmControl->dl_ready);
+ if( !intSStrmControl->dl_ready )
+ return;
+ data.u4OwenrId = MOD_MED;
+ data.u2Length = WB_FRAME_SIZE * sizeof(kal_int16);
+ data.puBuffaddr = (DCL_UINT8 *)intSStrmControl->dl_pcm;
+
+ switch(intSStrmControl->mode){
+ case VIA_CMUX_MODE:
+ DclSerialPort_Control( intSStrmControl->cmux_handle, SIO_CMD_PUT_BYTES, (DCL_CTRL_DATA_T*)&data );
+ MD_TRC_DACA_PUT_DATA(data.u2RetSize, VIA_CMUX_MODE);
+ break;
+ case VIA_USB_MODE:
+ DclSerialPort_Control( intSStrmControl->usb_handle, SIO_CMD_PUT_BYTES, (DCL_CTRL_DATA_T*)&data );
+ MD_TRC_DACA_PUT_DATA(data.u2RetSize, VIA_USB_MODE);
+ break;
+ }
+ intSStrmControl->dl_ready = false;
+ break;
+ }
+#else
+ case MSG_ID_STRM_SPEECH_UL_DATA_REQUEST:
+ {
+ break;
+ }
+
+ case MSG_ID_STRM_SPEECH_DL_DATA_NOTIFY:
+ {
+ //loopback from DL to UL directly.
+ memcpy(SS_BUFF[ss_buf_idx & SS_BUF_MASK], intSStrmControl->dl_pcm, WB_FRAME_SIZE * sizeof(kal_int16));
+ memcpy(intSStrmControl->ul_pcm, SS_BUFF[(ss_buf_idx-7) & SS_BUF_MASK] , WB_FRAME_SIZE * sizeof(kal_int16));
+ ss_buf_idx++;
+ MD_TRC_DACA_BUFFER_IDX(ss_buf_idx);
+ break;
+ }
+#endif
+ default:
+ ASSERT(0);
+ }
+}
+
+#endif //#if defined(__DATA_CARD_SPEECH__)
+
diff --git a/mcu/driver/audio/src/v1/spc_drv.c b/mcu/driver/audio/src/v1/spc_drv.c
new file mode 100644
index 0000000..0097994
--- /dev/null
+++ b/mcu/driver/audio/src/v1/spc_drv.c
@@ -0,0 +1,6600 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * spc_drv.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * MD speech control
+ *
+ * Author:
+ * -------
+ *
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+>>>> ORIGINAL //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c#11
+==== THEIRS //VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c#12
+ * removed!
+ * removed!
+ * removed!
+==== YOURS //ws_thomas.chen_work1/VMOLY/TRUNK/VMOLY/mcu/driver/audio/src/v1/spc_drv.c
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+<<<<
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "stack_config.h"
+#include "reg_base.h"
+#include "kal_trace.h"
+#include "string.h"
+#include "fsal.h"
+#include "sp_cc.h"
+#include "event_info_utility.h" // for MODEM_WARNING_MESSAGE
+
+#include "audio_enum.h"
+#include "am.h"
+#include "afe.h"
+#include "media.h"
+#include "l1sp_trc.h"
+#include "audcoeff_default.h"
+#include "dcl.h"
+#include "extcodec.h"
+
+#if defined(__L5_SUPPORT__)
+
+#include "l1audio.h"
+
+#include "drv_sap.h"
+#include "l5_msgid.h"
+#endif
+
+
+#include "med_spcio.h"
+#include "audio_em_struct.h"
+// #include "aud_common_config.h" // for DEFAULT_SPEECH_COMMON_PARA. in customer folder
+
+
+#include "spc_drv.h" // including "sp_drv.h"
+#include "sp_enhance.h"
+#include "sp_daca.h"
+#include "pcm4way.h"
+// #include "pcmrec.h"
+#include "rawpcmrec.h"
+#include "bgSnd.h"
+#include "pcmRouter.h"
+#include "ctm_drv.h"
+#include "vm.h"
+#include "pcmMixer.h"
+#include "pcmMixer3.h"
+// #include "mml1_rf_global.h"
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+#include "bt_sco_drv.h"
+#endif
+
+#include "sp_dsptone_drv.h"
+#include "sal_exp.h"
+
+// ----------------------------------------------------------------------------
+void Spc_AcousticLoopback(bool enable, kal_uint8 uParam, kal_uint8 extraParam);
+#if defined(_SPE_ENH_MD_PARSE_)
+uint16 spc_dynamicParameterParser_dispatcher(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen, kal_uint16 *newOffset);
+#endif
+void Spc_SpeechRouterOn(kal_bool enable);
+void Spc_SpeechOnForDaca( kal_uint8 RAT_Mode, kal_bool enable);
+void spc_SpeechOnForCallHold(kal_bool isGen);
+kal_bool spc_endApp(void);
+
+void spc_gain_UlMuteSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_DlMuteSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_UlEnhResultMuteSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_UlSourceMuteSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_DlMuteCodecSet(kal_bool on, kal_bool byPassCheck);
+void spc_gain_DlMuteSet_PrePcmMixer(kal_bool on, kal_bool byPassCheck);
+
+// ----------------------------------------------------------------------------
+
+#if defined(__ECALL_SUPPORT__)
+void aud_ecall_event_callback(eCall_Modem_Event event, void *param);
+#endif
+
+extern _PCMEX_T pcmEx;
+typedef enum {
+ SPC_APP_SPEECH_USAGE = 0,
+ SPC_APP_PCMNWAY_USAGE,
+ 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
+ SPC_APP_BGSND_USAGE,
+
+ SPC_APP_CTM_USAGE,
+ SPC_APP_ACLOOPBACK_USAGE,
+
+ SPC_APP_OLD_PCM_REC_USAGE, // 6, add from MT6582 chip, remove from 93md
+ SPC_APP_VM_REC_USAGE,
+
+ SPC_APP_HOLD_USAGE, // cannot mix with other speech application
+ SPC_APP_HOSTED_USAGE,
+ SPC_APP_PCMROUTER_USAGE,
+
+ //We can't enable all record function, only following selections are acceptable:
+ //1. SPC_APP_OLD_RECORD_USAGE
+ //2. SPC_APP_OLD_PCM_REC_USAGE
+ //3. SPC_APP_OLD_PCM_REC_USAGE + SPC_APP_VM_REC_USAGE
+ //4. SPC_APP_RAW_PCM_REC_USAGE
+ //5. SPC_APP_RAW_PCM_REC_USAGE + SPC_APP_VM_REC_USAGE
+ SPC_APP_RAW_PCM_REC_USAGE, //11, add from MT6752 chip
+
+ SPC_APP_MERGE_SPH_USAGE, // 12
+ SPC_APP_MIXER_USAGE, // 13
+ SPC_APP_MIXER3_USAGE, // 14
+ SPC_APP_MAX = 16 // due to spcAppUsage is uint16. so only 16 application can existing.
+} MSG_SPC_APP_T;
+
+typedef enum{
+ SPC_EM_INIT_COMMON = 0,
+ SPC_EM_INIT_NB,
+ SPC_EM_INIT_WB,
+ SPC_EM_INIT_SWB,
+ SPC_EM_INIT_DMNR,
+ SPC_EM_INIT_LSPK_DMNR,
+ SPC_EM_INIT_IIR,
+
+ SPC_EM_INIT_MAX = 16 // due to spcEmInit is unit16, so only 16 em data message can existing.
+} SPC_EM_INIT_T;
+
+typedef struct _SPC_T_
+{
+ kal_uint16 spcGetEpofTimes;
+ kal_uint16 spcAppUsage; //Please reference MSG_SPC_APP_T for bit definition
+
+ kal_uint16 spcEmInit;
+
+ // DSP mute
+ kal_bool spcMuteUl;
+ kal_bool spcMuteDl;
+
+ kal_bool spcMuteUlEnhResult;
+ kal_bool spcMuteUlSource;
+
+ kal_uint16 spcRampAck;
+#if defined(__ECALL_SUPPORT__)
+ kal_uint8 eCall_LIB_Status; //0:disable ecall,1:only enable SDT,2:enable ecall
+ kal_uint8 eCall_Ctrl_Seq_Switch;
+#endif
+} _SPC_T;
+
+#if defined(__ECALL_SUPPORT__)
+typedef signed short int Int16; /* 16 bit signed variable */
+
+extern Int16 eCall_TX_CTRL_SEQ_State[800];
+extern Int16 eCall_TX_CTRL_SEQ_dlData[800];
+extern Int16 eCall_TX_CTRL_SEQ_dlMetric[800];
+extern Int16 eCall_RX_CTRL_SEQ_State[800];
+extern Int16 eCall_RX_CTRL_SEQ_dlData[800];
+extern Int16 eCall_RX_CTRL_SEQ_dlMetric[800];
+kal_uint8 eCall_Msd[140];
+// Speech Recognition Feature for Eu spec
+#endif
+
+typedef struct spcEMIParInfoStruct
+{
+ uint32 EMI_Offset;
+ uint32 EMI_Len;
+ uint32 Common_Offset;
+ uint32 Dbg_Info_Offset;
+
+} spcEMIParInfo;
+
+
+
+
+
+
+
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+typedef struct spcDynParHeaderStruct
+{
+ uint16 SphParserVer;
+ uint16 NumLayer;
+ uint16 NumEachLayer;
+ uint16 Param_Header_Layer1;
+ uint16 Param_Header_Layer2;
+ uint16 Param_Header_Layer3;
+ uint16 Param_Header_Layer4;
+ uint16 SphUnitMagiNum;
+} spcDynParHeader;
+
+
+typedef struct spcDynParNBDataStruct
+{
+ unsigned short speech_Mode_para[NUM_MODE_PARAS];
+ short speech_NB_FIR_IN_para[NUM_FIR_COEFFS];
+ short speech_NB_FIR_OUT_para[NUM_FIR_COEFFS];
+} spcDynParNBData;
+
+
+typedef struct spcDynParNBDataStruct_V10 // need remover later
+{
+ unsigned short speech_Mode_para[NUM_MODE_PARAS];
+ short speech_NB_FIR_IN_para[45];
+ short speech_NB_FIR_OUT_para[45];
+} spcDynParNBData_V10;
+
+
+
+typedef struct spcDynParNBIIRDataStruct
+{
+ short speech_NB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS];
+ short speech_NB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS];
+ short speech_NB_IIR_IN_para[NUM_IIR_COEFFS];
+ short speech_NB_IIR_OUT_para[NUM_IIR_COEFFS];
+} spcDynParNBIIRData;
+typedef struct spcDynParWBDataStruct
+{
+
+ unsigned short speech_Mode_para[NUM_MODE_PARAS];
+ short speech_WB_FIR_IN_para[NUM_WB_FIR_COEFFS];
+ short speech_WB_FIR_OUT_para[NUM_WB_FIR_COEFFS];
+} spcDynParWBData;
+typedef struct spcDynParWBIIRDataStruct
+{
+ short speech_WB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS];
+ short speech_WB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS];
+ short speech_WB_IIR_IN_para[NUM_IIR_COEFFS];
+ short speech_WB_IIR_OUT_para[NUM_IIR_COEFFS];
+
+} spcDynParWBIIRData;
+typedef struct spcDynParSWBDataStruct
+{
+
+ unsigned short speech_Mode_para[NUM_MODE_PARAS];
+ short speech_SWB_FIR_IN_para[NUM_SWB_FIR_COEFFS];
+ short speech_SWB_FIR_OUT_para[NUM_SWB_FIR_COEFFS];
+} spcDynParSWBData;
+typedef struct spcDynParSWBIIRDataStruct
+{
+ short speech_SWB_MIC1_IIR_para[NUM_MIC1_IIR_COEFFS];
+ short speech_SWB_MIC2_IIR_para[NUM_MIC2_IIR_COEFFS];
+ short speech_SWB_IIR_IN_para[NUM_IIR_COEFFS];
+ short speech_SWB_IIR_OUT_para[NUM_IIR_COEFFS];
+} spcDynParSWBIIRData;
+typedef struct spcMagiClarityDataStruct
+{
+ short MagiClarity_Para[32];
+} spcMagiClarityData;
+
+typedef struct spcCommonDataStruct
+{
+
+ unsigned short Common_Para[NUM_COMMON_PARAS];
+ unsigned short Debug_info_para[NUM_DEBUG_INFO];
+
+} spcCommonData;
+#endif
+
+typedef struct spcDynParEchoRefForUsbAudioStruct
+{
+
+ bool isEchoRefForUsbAudioOn;
+ short chip_delay_with_switch;
+ 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,
+
+} spcDynParEchoRefForUsbAudio_T;
+
+#if defined(_SPE_ENH_MD_PARSE_)
+short DMNR_NB_REC[NUM_DMNR_PARAM];
+short DMNR_NB_LoudSpk[NUM_DMNR_PARAM];
+short DMNR_WB_REC[NUM_WB_DMNR_PARAM];
+short DMNR_WB_LoudSpk[NUM_WB_DMNR_PARAM];
+short DMNR_SWB_REC[NUM_SWB_DMNR_PARAM];
+short DMNR_SWB_LoudSpk[NUM_SWB_DMNR_PARAM];
+//DMNR header
+#define Header_DMNR_NB_REC 0x0011
+#define Header_DMNR_NB_LSP 0x0012
+#define Header_DMNR_WB_REC 0x0021
+#define Header_DMNR_WB_LSP 0x0022
+#define Header_DMNR_SWB_REC 0x0031
+#define Header_DMNR_SWB_LSP 0x0032
+
+
+//define data header - voice band
+#define NB_Par 0x10
+#define WB_Par 0x20
+#define SWB_Par 0x30
+//define param header- voice band
+#define VoiceBand_NB (1 << 1)
+#define VoiceBand_WB (1 << 2)
+#define VoiceBand_SWB 0x04
+#define VoiceBand_FB 0x08
+
+
+
+//define data header -network
+
+#define GSM_NETWORK 0x01
+#define WCDMA_NETWORK 0x02
+#define CDMA_NETWORK 0x03
+#define VOLTE_NETWORK 0x04
+#define C2K_NETWORK 0x05
+#define DONT_CARE_NETWORK 0x0F
+
+
+unsigned short Temp_speech_NB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+short Temp_speech_NB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+short Temp_speech_NB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+short Temp_speech_NB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_NB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_NB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+short Temp_speech_NB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+
+unsigned short Temp_speech_WB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+short Temp_speech_WB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+short Temp_speech_WB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+short Temp_speech_WB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_WB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_WB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+short Temp_speech_WB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+
+unsigned short Temp_speech_SWB_Mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+short Temp_speech_SWB_FIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+short Temp_speech_SWB_FIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+short Temp_speech_SWB_IIR_IN_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_SWB_IIR_OUT_para[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+short Temp_speech_SWB_MIC1_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+short Temp_speech_SWB_MIC2_IIR_para[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+#endif
+extern const unsigned short Speech_Common_Para[12] ;
+extern const unsigned short Debug_Info_Para[16] ;
+
+
+
+
+
+
+// ----------------------------------------------------------------------------
+// Global Variable
+// ----------------------------------------------------------------------------
+
+static _SPC_T gSpc;
+
+__attribute__((aligned (4)))static kal_uint8 emDataBuf[4096];
+
+
+static uint16 gSpc_networkStatus = 0xFF;
+
+// ----------------------------------------------------------------------------
+// Macro function
+// ----------------------------------------------------------------------------
+
+#define IS_SPC_APP_USED(app) ((gSpc.spcAppUsage & (1 << (app))) != 0)
+#define SET_SPC_APP_USAGE(app) (gSpc.spcAppUsage |= (1 << (app)))
+#define CLR_SPC_APP_USAGE(app) (gSpc.spcAppUsage &= (~(1 << (app))))
+
+
+#define IS_SPC_EM_INIT(emPara) ((gSpc.spcEmInit& (1 << (emPara))) != 0)
+#define SET_SPC_EM_INIT(emPara) (gSpc.spcEmInit |= (1 << (emPara)))
+
+#define IS_SPC_RAMP_WAIT_ACK(point) ((gSpc.spcRampAck & (1 << (point))) != 0)
+#define SET_SPC_RAMP_WAIT_ACK(point) (gSpc.spcRampAck |= (1 << (point)))
+#define CLR_SPC_RAMP_WAIT_ACK(point) (gSpc.spcRampAck &= (~(1 << (point))))
+
+#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)))
+
+/*
+#if ((defined(MT6280) || defined(MT6290)) && (defined(__SMART_PHONE_MODEM__))) || defined(SPH_CHIP_BACK_PHONECALL_USE)
+// for super dongle project on data card chip, MD reset scenario is useless
+// So the protection is unnecessary and un-sync with AP side, so the request is always done
+#define IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE (true)
+#else
+#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
+#endif
+*/
+
+// ----------------------------------------------------------------------------
+// Internal Init Related
+// ----------------------------------------------------------------------------
+#if defined(_SPE_ENH_MD_PARSE_)
+// following constant inside ./custom/driver/common/aud_common.c
+extern const unsigned short Speech_Normal_Mode_Para[16];
+extern const unsigned short Speech_Earphone_Mode_Para[16];
+extern const unsigned short Speech_LoudSpk_Mode_Para[16];
+extern const unsigned short Speech_BT_Earphone_Mode_Para[16];
+extern const unsigned short Speech_BT_Cordless_Mode_Para[16];
+extern const unsigned short Speech_CARKIT_Mode_Para[16];
+extern const unsigned short Speech_AUX1_Mode_Para[16];
+extern const unsigned short Speech_AUX2_Mode_Para[16];
+extern const unsigned short WB_Speech_Normal_Mode_Para[16];
+extern const unsigned short WB_Speech_Earphone_Mode_Para[16];
+extern const unsigned short WB_Speech_LoudSpk_Mode_Para[16];
+extern const unsigned short WB_Speech_BT_Earphone_Mode_Para[16];
+extern const unsigned short WB_Speech_BT_Cordless_Mode_Para[16];
+extern const unsigned short WB_Speech_CARKIT_Mode_Para[16];
+extern const unsigned short WB_Speech_AUX1_Mode_Para[16];
+extern const unsigned short WB_Speech_AUX2_Mode_Para[16];
+
+
+extern const signed short WB_DMNR_Para[76];
+extern const signed short LSpk_WB_DMNR_Para[76];
+extern const signed short DMNR_Para[44];
+extern const signed short LSpk_DMNR_Para[44];
+
+
+
+/**
+
+*/
+extern const signed short Speech_All_Pass_IIR_Coeff[42] ;
+extern const signed short Sph_Mic1_IIR_In[20] ;
+extern const signed short Sph_Mic2_IIR_In[20] ;
+unsigned short default_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+signed short default_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+signed short default_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_FIR_COEFFS];
+signed short default_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+signed short default_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+unsigned short default_WB_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+signed short default_WB_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+signed short default_WB_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_WB_FIR_COEFFS];
+signed short default_WB_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_WB_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_WB_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+signed short default_WB_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+unsigned short default_SWB_speech_mode_para[TOTAL_NETWORK_NUMBER][NUM_MODE_PARAS];
+signed short default_SWB_Speech_Input_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+signed short default_SWB_Speech_Output_FIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_SWB_FIR_COEFFS];
+signed short default_SWB_Speech_Input_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_SWB_Speech_Output_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_IIR_COEFFS];
+signed short default_SWB_Speech_MIC1_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC1_IIR_COEFFS];
+signed short default_SWB_Speech_MIC2_IIR_Coeff[TOTAL_NETWORK_NUMBER][NUM_MIC2_IIR_COEFFS];
+#endif
+
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+void spc_EmInit(kal_bool isNeedBasic, kal_bool isNeedNb,kal_bool isNeedWb,kal_bool isNeedSWb, kal_bool isNeedDmnr, kal_bool isNeedLspkDmnr,kal_bool isNeedIIR)
+{
+ MD_TRC_SPC_EM_DEFAULT_INIT(isNeedBasic, isNeedNb,isNeedWb, isNeedSWb,isNeedDmnr, isNeedLspkDmnr,isNeedIIR);
+
+ // ====== parameters from EM =======
+ if(isNeedBasic){
+ // common parameter
+ uint16 commonP[] = DEFAULT_SPEECH_COMMON_PARA;
+ L1SP_LoadCommonSpeechPara(commonP);
+
+ }
+ if(isNeedNb){
+
+ // mode parameter , default use normal mode,GSM,NB
+ uint8 count;
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_speech_mode_para[count], Speech_Normal_Mode_Para, 16*sizeof(uint16)) ;
+ }
+ l1sp_setAllSpeechModePara((kal_uint16 *)default_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ // SPE_LoadSpeechPara(NULL, gSpe.sph_ModePara[0], NULL, NULL); // l1sp.sph_v_para no one use it.
+
+
+ // FIR , default use normal mode,GSM,NB
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_FIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechFirCoeff_InputOnly((int16 *)default_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_FIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechFirCoeff_OutputOnly((int16 *)default_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_FIR_COEFFS);
+ //AM_WriteFirCoeffs( gSpe.sph_InFirCoeff[0], gSpe.sph_OutFirCoeff[0] );
+
+ }
+ if(isNeedWb){
+ // WB FIR
+
+ // in customer folder's Audcoeff.c
+ uint8 count;
+
+
+ // WB mode parameter , default use normal mode,GSM,NB
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_speech_mode_para[count], WB_Speech_Normal_Mode_Para, 16*sizeof(uint16)) ;
+ }
+ l1sp_setAllWbSpeechModePara((kal_uint16* )default_WB_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ //SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[0] );
+
+
+ extern const signed short WB_Speech_Input_FIR_Coeff[6][90];
+ extern const signed short WB_Speech_Output_FIR_Coeff[6][90];
+
+
+
+ // WB FIR , default use normal mode,GSM,NB
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_WB_FIR_COEFFS*sizeof(int16)) ;
+ }
+
+ l1sp_setAllWbSpeechFirCoeff_InputOnly((kal_int16 *)default_WB_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_WB_FIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllWbSpeechFirCoeff_OutputOnly((int16 *)default_WB_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_WB_FIR_COEFFS);
+ //AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]);
+ }
+ if(isNeedSWb){
+ // SWB FIR
+ // SWB mode parameter , default use normal mode,GSM,NB
+ uint8 count;
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_speech_mode_para[count], WB_Speech_Normal_Mode_Para, 16*sizeof(uint16)) ;
+ }
+ l1sp_setAllSWbSpeechModePara((kal_uint16* )default_SWB_speech_mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ //SPE_LoadSpeechPara(NULL, NULL, NULL,gSpe.sph_WbModePara[0] );
+
+
+ extern const signed short WB_Speech_Input_FIR_Coeff[6][90];
+ extern const signed short WB_Speech_Output_FIR_Coeff[6][90];
+
+
+
+ // WB FIR , default use normal mode,GSM,NB
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_Input_FIR_Coeff[count], WB_Speech_Input_FIR_Coeff[0], NUM_SWB_FIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWbSpeechFirCoeff_InputOnly((kal_int16 *)default_SWB_Speech_Input_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_Output_FIR_Coeff[count], WB_Speech_Output_FIR_Coeff[0], NUM_SWB_FIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWbSpeechFirCoeff_OutputOnly((int16 *)default_SWB_Speech_Output_FIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_SWB_FIR_COEFFS);
+ //AM_WriteWbFirCoeffs(gSpe.sph_WbInFirCoeff[0],gSpe.sph_WbOutFirCoeff[0]);
+
+
+ }
+ if(isNeedIIR){
+ //IIR
+ uint8 count;
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechIirCoeff_InputOnly((int16 *)default_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechIirCoeff_OutputOnly((int16 *)default_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechMic1IirCoeff((int16 *)default_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSpeechMic2IirCoeff((int16 *)default_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS);
+
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllWBSpeechIirCoeff_InputOnly((int16 *)default_WB_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllWBSpeechIirCoeff_OutputOnly((int16 *)default_WB_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllWBSpeechMic1IirCoeff((int16 *)default_WB_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_WB_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllWBSpeechMic2IirCoeff((int16 *)default_WB_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS);
+
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_Input_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWBSpeechIirCoeff_InputOnly((int16 *)default_SWB_Speech_Input_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_Output_IIR_Coeff[count], Speech_All_Pass_IIR_Coeff, NUM_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWBSpeechIirCoeff_OutputOnly((int16 *)default_SWB_Speech_Output_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_MIC1_IIR_Coeff[count], Sph_Mic1_IIR_In, NUM_MIC1_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWBSpeechMic1IirCoeff((int16 *)default_SWB_Speech_MIC1_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC1_IIR_COEFFS);
+ for(count=0; count<TOTAL_NETWORK_NUMBER; count++)
+ {
+ memcpy(default_SWB_Speech_MIC2_IIR_Coeff[count], Sph_Mic2_IIR_In, NUM_MIC2_IIR_COEFFS*sizeof(int16)) ;
+ }
+ l1sp_setAllSWBSpeechMic2IirCoeff((int16 *)default_SWB_Speech_MIC2_IIR_Coeff, TOTAL_NETWORK_NUMBER*NUM_MIC2_IIR_COEFFS);
+
+ }
+
+ if(isNeedDmnr){
+ L1SP_SetWbDMNRPara(WB_DMNR_Para);
+ L1SP_SetDMNRPara(DMNR_Para);
+ }
+
+ if(isNeedLspkDmnr){ // load param when begin run
+ L1SP_SetLSpkWbDMNRPara(LSpk_WB_DMNR_Para);
+ L1SP_SetLSpkDMNRPara(LSpk_DMNR_Para);
+ }
+
+ // loading!!
+ // if(isNeedBasic || isNeedWb) {
+ // L1SP_LoadSpeechPara();
+ // }
+}
+
+#endif
+/**
+ @app: app to be enable
+ @return: check result, true for pass, false for fail
+*/
+bool spc_mainAppOnCheck(MSG_SPC_APP_T app)
+{
+ // other related check
+ if(SPC_APP_SPEECH_USAGE != app && SPC_APP_MERGE_SPH_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+ if(SPC_APP_ACLOOPBACK_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_ACLOOPBACK_USAGE, SPC_APP_ACLOOPBACK_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+
+
+ if(SPC_APP_HOLD_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+ if(SPC_APP_HOSTED_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+ if(SPC_APP_PCMROUTER_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_PCMROUTER_USAGE, SPC_APP_PCMROUTER_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+ if(SPC_APP_MERGE_SPH_USAGE != app && SPC_APP_SPEECH_USAGE != app) {
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+// ----------------------------------------------------------------------------
+// Codec Related
+// ----------------------------------------------------------------------------
+/*
+#define CODEC_INFO_PROP_CODEC "codec="
+#define CODEC_INFO_PROP_ISHDV "isHdV="
+#define CODEC_INFO_PROP_HDVOP "HDVOp="
+#define CODEC_INFO_PROP_SR "sr="
+#define CODEC_INFO_PROP_BR "br="
+#define CODEC_INFO_PROP_FS "fs="
+#define CODEC_INFO_PROP_RR "rr="
+#define CODEC_INFO_PROP_SEPERATER ";"
+
+
+#define CODEC_INFO_PROP_CODEC_VALUE_FR "FR"
+#define CODEC_INFO_PROP_CODEC_VALUE_HR "HR"
+#define CODEC_INFO_PROP_CODEC_VALUE_EFR "EFR"
+#define CODEC_INFO_PROP_CODEC_VALUE_AMR "AMR"
+#define CODEC_INFO_PROP_CODEC_VALUE_AWB "AWB"
+
+#define CODEC_INFO_PROP_ISHDV_VALUE_Y "Y"
+#define CODEC_INFO_PROP_ISHDV_VALUE_N "N"
+*/
+
+#define SPC_PROP_CODEC_LEN 92
+
+typedef struct {
+ char codecInfo[SPC_PROP_CODEC_LEN];
+ char codecOp[SPC_PROP_CODEC_LEN];
+} SPC_CODEC_INFO_STRUCT;
+
+static struct {
+ uint32 curSpeechMode;
+ uint16 curRateInSoCodec;
+ SPC_CODEC_INFO_STRUCT info;
+} gSpc_codec_info;
+
+void spc_codecInfoInit(void)
+{
+ gSpc_codec_info.curSpeechMode = 0xffffffff;
+ gSpc_codec_info.curRateInSoCodec = 0xffff;
+ memset(&(gSpc_codec_info.info), '\0', sizeof(SPC_CODEC_INFO_STRUCT));
+}
+
+void spc_sendCodecInfoNotify(void)
+{
+ spcBufInfo info;
+
+ info.syncWord = 0x1234;
+ info.type = AUD_CCCI_STRMBUF_TYPE_NW_CODEC_INFO;
+ info.length = sizeof(SPC_CODEC_INFO_STRUCT); // currently, fix the buffer size in WB
+
+ SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ &(gSpc_codec_info.info), sizeof(SPC_CODEC_INFO_STRUCT), NULL, 0,
+ SPCIO_MSG_FROM_SPC_NW_CODEC_INFO_NOTIFY);
+ MD_TRC_SPC_CODEC_NOTIFY_TO_AP(gSpc_codec_info.info.codecInfo, gSpc_codec_info.info.codecOp);
+}
+
+void spc_codecInfoNotify(uint32 codec)
+{
+
+ MD_TRC_SPC_CODEC_NOTIFY_IN(gSpc_codec_info.curSpeechMode, codec);
+
+ if(false == IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, 1);
+ return;
+ }
+
+ // if codec&rate did not change, just return
+ if(codec== gSpc_codec_info.curSpeechMode) {
+ return;
+ }
+
+ // prepare codec sending
+ memset(&(gSpc_codec_info.info), 0, sizeof(SPC_CODEC_INFO_STRUCT));
+
+ if(0 == codec) { // FR,
+
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=FR;sr=8k;");
+
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if (1 == codec) {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=HR;sr=8k;");
+
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if (2 == codec) {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EFR;sr=8k;");
+
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ((codec >= 0x20 && codec<=0x28) ||(codec >= 0xD0 && codec <= 0xDF)) { // AWB, EVS-AWB
+ uint8 bitRate = (codec&0xF);
+ if(codec >= 0x20 && codec<=0x28) { // AWB
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=AWB;sr=16k;");
+ } else { //EVS-AWB
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVSAWB;sr=16k;");
+ }
+
+ // bit rate
+ if ( 0x0 == bitRate) { // 6.60
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=6.60;");
+ } else if ( 0x1 == bitRate) { // 8.85
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=8.85;");
+ } else if ( 0x2 == bitRate) { // 12.65
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=12.65;");
+ } else if ( 0x3 == bitRate) { // 14.25
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=14.25;");
+ } else if ( 0x4 == bitRate) { // 15.85
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=15.85;");
+ } else if ( 0x5 == bitRate) { // 18.25
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=18.25;");
+ } else if ( 0x6 == bitRate) { // 19.85
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=19.85;");
+ } else if ( 0x7 == bitRate) { // 23.05
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=23.05;");
+ } else if ( 0x8 == bitRate) { // 23.85
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=23.85;");
+ } else { // unkonw codec
+ MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 1);
+ }
+
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ } else if(codec >=3 && codec <= 0xA) { // from 3~0x1f, AMR
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=AMR;sr=8k;");
+
+ // bit rate
+ if (3 == codec) { // 12.2k
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=12.20;");
+ } else if (4 == codec) { // 10.2K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=10.20;");
+ } else if (5 == codec) { // 7.95K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.95;");
+ } else if (6 == codec) { // 7.4K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.40;");
+ } else if (7 == codec) { // 6.7K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=6.70;");
+ } else if (8 == codec) { // 5.9K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=5.90;");
+ } else if (9 == codec) { // 5.15K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=5.15;");
+ } else if (0xA == codec) { // 4.75K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=4.75;");
+ } else { // unkonw codec
+ MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 2);
+ }
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ }else if(codec >= 0x80 && codec <= 0xBF) { // EVS
+ uint8 bitRate = (codec&0xF);
+
+ if ( codec < 0x90 ) {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=8k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( codec < 0xA0 ) {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=16k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ } else if ( codec < 0xB0 ) {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=32k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ } else {
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=EVS;sr=48k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ }
+
+ // bit rate
+ if ( 0x0 == bitRate) { // 2.80
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=2.80;");
+ } else if ( 0x1 == bitRate) { // 7.20
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=7.20;");
+ } else if ( 0x2 == bitRate) { // 8.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=8.00;");
+ } else if ( 0x3 == bitRate) { // 9.60
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=9.60");
+ } else if ( 0x4 == bitRate) { // 13.20
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=13.20;");
+ } else if ( 0x5 == bitRate) { // 16.40
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=16.40;");
+ } else if ( 0x6 == bitRate) { // 24.40
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=24.40;");
+ } else if ( 0x7 == bitRate) { // 32.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=32.00;");
+ } else if ( 0x8 == bitRate) { // 48.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=48.00;");
+ } else if ( 0x9 == bitRate) { // 64.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=64.00;");
+ } else if ( 0xA == bitRate) { // 96.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=96.00;");
+ } else if ( 0xB == bitRate) { // 128.00
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "br=128.00;");
+ } else { // unkonw codec
+ MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 3);
+ }
+
+ } else if ( 0x60 == codec ) { // g711
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G711;sr=8k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x61 == codec ) { // 722
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G722;sr=16k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ } else if ( 0x62 == codec ) { // g732.1
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G723_1;sr=8k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x63 == codec ) { // g726
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G726;sr=8k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x64 == codec ) { // g729,
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=G729;sr=8k;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if (codec >= 0x30 && codec <= 0x35) {
+
+ if( 0x30 == codec ) { // SAL_C2K_COD_QCELP8K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S01;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x31 == codec ) { // SAL_C2K_COD_QCELP13K
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S017;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x32 == codec ) { // SAL_C2K_COD_EVRCA
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S03;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x33 == codec ) { // SAL_C2K_COD_EVRCB
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S068;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x34 == codec ) { // SAL_C2K_COD_EVRCNW_NB
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S073;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=N;");
+ } else if ( 0x35 == codec ) { // SAL_C2K_COD_EVRCNW_WB
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "codec=S073;");
+ SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecOp, "OM=Y;");
+ }
+
+ gSpc_codec_info.curRateInSoCodec = 0xffff; // reset only when SO codec change.
+
+ }
+ else {
+ MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(codec, 0xffff, 4);
+ }
+
+ // send to AP
+ spc_sendCodecInfoNotify();
+
+ // update codec
+ gSpc_codec_info.curSpeechMode = codec;
+
+}
+
+void spc_codecInfoNotify_soRateUpdate(uint16 newRate)
+{
+ if (gSpc_codec_info.curSpeechMode >= 0x30 && gSpc_codec_info.curSpeechMode <= 0x35) {
+
+ // if codec&rate did not change, just return
+ if(newRate == gSpc_codec_info.curRateInSoCodec) {
+ return;
+ }
+
+ switch(newRate){
+ case 0: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=0;"); break;
+ case 1: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=1;"); break;
+ case 2: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=2;"); break;
+ case 3: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=3;"); break;
+ case 4: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=4;"); break;
+ case 5: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=5;"); break;
+ case 6: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=6;"); break;
+ case 7: SPC_CODEC_INFO_STRCAT(gSpc_codec_info.info.codecInfo, "rr=7;"); break;
+ default: break;
+ }
+
+ gSpc_codec_info.curRateInSoCodec = newRate;
+
+ // send to AP
+ spc_sendCodecInfoNotify();
+ } else {
+ MD_TRC_SPC_CODEC_NOTIFY_UNKNOW(gSpc_codec_info.curSpeechMode, newRate, 5);
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// Phone Call Related
+// ----------------------------------------------------------------------------
+typedef enum {
+ SPH_ON_APPLICATION_NORMAL = 0,
+ SPH_ON_APPLICATION_VT_CALL,
+ SPH_ON_APPLICATION_LOOPBACK,
+ SPH_ON_APPLICATION_ROUTER,
+ SPH_ON_APPLICATION_DACA,
+ SPH_ON_APPLICATION_HOLD_CALL,
+ SPH_ON_APPLICATION_ENCRYPTION,
+}spc_sph_on_application_t;
+
+typedef enum {
+ SPH_ON_BTINFO_BT_OFF,
+ SPH_ON_BTINFO_BT_PCM, /* via Modem PCM hardware */
+ SPH_ON_BTINFO_BT_CVSD_MSBC, /* via software BT codec */
+ SPH_ON_BTINFO_BT_CVSD,
+ SPH_ON_BTINFO_BT_MSBC
+}spc_sph_on_bt_info_t;
+
+typedef enum {
+ SPH_ON_SAMPLE_RATE_08K = 0,
+ SPH_ON_SAMPLE_RATE_16K,
+ SPH_ON_SAMPLE_RATE_32K,
+ SPH_ON_SAMPLE_RATE_48K,
+ SPH_ON_SAMPLE_RATE_MAX
+}spc_sph_on_sample_rate_t;
+
+typedef enum {
+ SPH_ON_PARAM_VIA_PAYLOAD = 0, /* speech param is written in payload */
+ SPH_ON_PARAM_VIA_SHM /* speech param is written in share memory */
+}spc_sph_on_param_path_t;
+
+typedef enum {
+ SPH_ON_EXT_DEV_INFO_DEFULAT = 0,
+ SPH_ON_EXT_DEV_INFO_VIBRATION_RECEIVER, // vibration receiver (3-in-1)
+ SPH_ON_EXT_DEV_INFO_VIBRATION_SPEAKER, // speaker (2-in-1 or 3-in-1)
+ SPH_ON_EXT_DEV_INFO_SMARTPA_SPEAKER, // speaker with smart-PA which need echo reference path
+ SPH_ON_EXT_DEV_INFO_SMARTPA_VIBRATION_SPEAKER, // vibration speaker with smart-PA which need echo reference path
+ SPH_ON_EXT_DEV_INFO_USB_AUDIO, // usb audio device, which needs echo reference path
+ SPH_ON_EXT_DEV_INFO_EARPHONE, // earphone audio device
+}spc_sph_on_ext_dev_info_t;
+
+typedef enum {
+ 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
+ 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
+}spc_sph_on_loopback_info_flag;
+
+typedef struct {
+ kal_uint8 loopback_flag;
+ kal_uint8 loopback_delay; /* spc_sph_on_loopback_info_flag */
+}spc_sph_on_loopback_info_t;
+
+typedef enum {
+ SPH_ON_MUTE_BIT_UL = (1<<0),
+ SPH_ON_MUTE_BIT_DL = (1<<1),
+ SPH_ON_MUTE_BIT_UL_ENH_RESULT = (1<<2),
+ SPH_ON_MUTE_BIT_UL_SOURCE = (1<<3),
+ SPH_ON_MUTE_BIT_DL_CODEC = (1<<4),
+ SPH_ON_MUTE_BIT_DL_PRE_PCM_MIXER = (1<<5),
+}spc_sph_on_mute_bit;
+
+typedef struct {
+ kal_uint8 application; /* spc_sph_on_application_t */
+ kal_uint8 bt_info; /* spc_sph_on_bt_info_t */
+ kal_uint8 sample_rate_enum; /* spc_sph_on_sample_rate_t */
+ kal_uint8 opendsp_flag; /* 0: internal SPE, 1: OpenDSP */
+
+ kal_uint8 param_path; /* spc_sph_on_param_path_t */
+ kal_uint8 param_shm_valid; /* SPH_ON_PARAM_VIA_SHM only. 0: invalid, 1: valid */
+ kal_uint16 param_size; /* Max 65535 bytes */
+
+ kal_uint16 param_idx;
+ kal_uint16 ext_dev_info; /* spc_sph_on_ext_dev_info_t */
+
+ kal_uint8 loopback_flag;
+ kal_uint8 loopback_delay; /* spc_sph_on_loopback_info_flag */
+ kal_uint16 echo_ref_delay_ms; /* echo reference data delay, unit is ms */
+
+ kal_uint8 mic_delay_ms; /* UL0 data delay, unit is ms */
+ kal_uint8 mute_mask; /* bit-wise define in spc_sph_on_mute_bit. 0: unmute, 1: mute */
+ kal_uint16 enh_crtl_support;
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ kal_uint8 reserve_at_32byte[12];
+ kal_uint8 reserve_at_48byte[16];
+ kal_uint8 reserve_at_64byte[16];
+#else
+
+ kal_uint32 param_usip_len; // 95MD support EMI par.
+
+ kal_uint32 param_usip_index; // 95MD support EMI par.
+ kal_uint16 common_param[12]; /* param for driver/scheduler */
+ kal_uint16 debug_info[16]; /* param for driver/scheduler */
+
+ kal_uint8 smartPA_config;
+
+#if defined(MT6890)
+ kal_uint8 dtmf_rm_support; /* 0: Disable DTMF removal, 1: Enable DTMF removal */
+ kal_uint8 reserve_at_128byte[42];
+#else
+ kal_uint8 reserve_at_128byte[43];
+#endif
+
+
+#endif
+
+
+
+} spc_sph_on_info_t; /* 64 bytes */
+
+static spc_sph_on_info_t gSpc_sphOnInfo;
+
+#define SPC_CUST_ENH 0
+#if SPC_CUST_ENH
+#define PROCESS_BLK_SIZE 320
+static uint16 gSpc_DV_PCM_UL1_BUF[PROCESS_BLK_SIZE];
+static uint16 gSpc_DV_PCM_UL2_BUF[PROCESS_BLK_SIZE];
+static uint16 gSpc_DV_PCM_IN_BUF[PROCESS_BLK_SIZE];
+static uint16 gSpc_DV_PCM_DL_BUF[PROCESS_BLK_SIZE];
+static uint16 gSpc_DV_PCM_OUT_BUF[PROCESS_BLK_SIZE];
+static uint16 DV_dl_audioid;
+static uint16 DV_ul_audioid;
+
+void DV_init(void)
+{
+ // Do DV initialize
+ return;
+}
+
+void DV_Release(void)
+{
+ // Do DV destroy
+}
+
+void DV_UL_process()
+{
+ // do speech enahncment for uplink
+ // gSpc_DV_PCM_IN_BUF = ulProcess(gSpc_DV_PCM_UL1_BUF, gSpc_DV_PCM_UL2_BUF);
+}
+
+void DV_DL_process()
+{
+ // do speech enahncment for downlink
+ // gSpc_DV_PCM_OUT_BUF = dlProcess(gSpc_DV_PCM_DL_BUF);
+ memcpy(gSpc_DV_PCM_OUT_BUF, gSpc_DV_PCM_DL_BUF, 640);
+
+ spc_customDump(320, gSpc_DV_PCM_OUT_BUF);
+}
+
+void DV_PCM4WAY_DL_HisrHdl()
+{
+
+ PCM4WAY_GetFromSD(gSpc_DV_PCM_DL_BUF);
+
+ PCM4WAY_PutToSpk(gSpc_DV_PCM_OUT_BUF);
+
+ L1Audio_SetEvent(DV_dl_audioid, NULL);
+
+}
+
+void DV_PCM4WAY_UL_HisrHdl()
+{
+
+
+ PcmEx_GetFromMic1(gSpc_DV_PCM_UL1_BUF);
+ PcmEx_GetFromMic2(gSpc_DV_PCM_UL2_BUF);
+
+
+
+ PCM4WAY_PutToSE(gSpc_DV_PCM_IN_BUF);
+
+ L1Audio_SetEvent(DV_ul_audioid, NULL);
+}
+#endif // SPC_CUST_ENH
+
+void Spc_SpeechOn( kal_uint8 RAT_Mode )
+{
+
+ if(false == spc_mainAppOnCheck(SPC_APP_SPEECH_USAGE))
+ return;
+
+ ASSERT(RAT_Mode <= RAT_3G324M_MODE);
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ // checking speech useage parameter. if Not, use the default value.
+ spc_EmInit(!IS_SPC_EM_INIT(SPC_EM_INIT_COMMON),!IS_SPC_EM_INIT(SPC_EM_INIT_NB),
+ !IS_SPC_EM_INIT(SPC_EM_INIT_WB),!IS_SPC_EM_INIT(SPC_EM_INIT_SWB),
+ !IS_SPC_EM_INIT(SPC_EM_INIT_DMNR),
+ !IS_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR),
+ !IS_SPC_EM_INIT(SPC_EM_INIT_IIR));
+#endif
+
+ // rate setting
+#if defined(__UMTS_RAT__)
+ if( RAT_Mode != RAT_3G324M_MODE )
+ RAT_Mode = RAT_3G_MODE; // Force initial 3G
+#else
+ RAT_Mode = RAT_2G_MODE;
+#endif
+
+ MD_TRC_SPC_SPEECH_ON(RAT_Mode);
+
+
+ // reset codec before speechOn.
+ spc_codecInfoInit();
+ gSpc_networkStatus = 0xFF;
+
+ L1SP_Speech_On( RAT_Mode );
+
+ SET_SPC_APP_USAGE(SPC_APP_SPEECH_USAGE);
+
+
+#if SPC_CUST_ENH
+ DV_init();
+ Del_PcmEx_Start(DV_PCM4WAY_DL_HisrHdl, NULL, //DV_PCM4WAY_UL_HisrHdl,
+ NULL, //USE_D2M_PATH + USE_M2D_PATH,
+ NULL, //USE_D2M_PATH + USE_M2D_PATH,
+ NULL, //USE_D2M_PATH + USE_M2D_PATH,
+ NULL, //USE_D2M_PATH + USE_M2D_PATH,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH);
+#endif
+}
+
+kal_uint16 Spc_SpeechOn_withData(kal_uint16 offset, kal_uint16 length, const SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo header;
+ spc_sph_on_info_t info;
+ kal_uint16 totalProcLen = 0;
+ kal_bool check;
+
+#if defined(_SPE_ENH_DSP_PARSE_)
+ kal_uint32 EMI_Offset;
+ //unsigned short Common_Para[NUM_COMMON_PARAS];
+ //unsigned short Dbg_Para[16];
+#endif
+
+ memset(&info, 0, sizeof(spc_sph_on_info_t));
+ if(length == (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom);
+ } else if ((length < (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) && (length > sizeof(spcBufInfo))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom);
+ MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t));
+ } else if (length > (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t)), sizeof(spcBufInfo), &header, &info, comeFrom);
+ MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t));
+ }else {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 2);
+ return totalProcLen;
+ }
+
+ check = (header.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow syncWord");
+ if(!check)
+ goto leaveSphOn;
+ check = (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO);
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow type");
+ if(!check)
+ goto leaveSphOn;
+ check = (header.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechOn_withData: unknow length");
+ if(!check)
+ goto leaveSphOn;
+
+ MD_TRC_SPC_SPEECH_ON_PAYLOAD(
+ info.application, info.bt_info, info.sample_rate_enum, info.opendsp_flag,
+ info.param_path, info.param_shm_valid, info.param_size, info.param_idx, info.ext_dev_info,
+ info.mute_mask);
+
+ if(false == spc_mainAppOnCheck(SPC_APP_MERGE_SPH_USAGE)) {
+ return info.param_size;
+ }
+
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 1);
+ return info.param_size;
+ }
+
+ memcpy(&gSpc_sphOnInfo, &info, sizeof(spc_sph_on_info_t));
+
+ // set device
+ SP_SetDevicePath(info.bt_info, info.sample_rate_enum);
+ SP_SetExtraDevInfo(info.bt_info, info.ext_dev_info, info.smartPA_config, info.echo_ref_delay_ms, info.mic_delay_ms);
+ // Set Enh
+ L1SP_EnhancementCtrlSupport(info.enh_crtl_support);
+
+#if defined(MT6890)
+ MD_TRC_SPC_SPEECH_ON_DTMF_SUPPORT(info.dtmf_rm_support);
+ if (info.dtmf_rm_support == 0) {
+ SAL_DTMF_Removal_Ctrl(SAL_DTMF_REMOVAL_UL_PRE_EN, false);
+ } else {
+ SAL_DTMF_Removal_Ctrl(SAL_DTMF_REMOVAL_UL_PRE_EN, true);
+ }
+#endif
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ if(SPH_ON_PARAM_VIA_SHM == info.param_path) {
+ if(1 == info.param_shm_valid) {
+ kal_uint16 procLen = 0;
+ kal_uint16 curOffset = info.param_idx;
+
+ while (totalProcLen < info.param_size ) {
+ kal_uint16 newOffset;
+ spc_dynamicParameterParser_dispatcher(curOffset, info.param_size-totalProcLen,
+ SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset);
+
+ totalProcLen += procLen;
+ curOffset = newOffset;
+ }
+ }
+ } else {
+ // Via stream. Not implement yet
+ kal_prompt_trace(MOD_L1SP, "SphO. param data from payload!!");
+ }
+
+#else // for _SPE_ENH_DSP_PARSE_
+
+ // mute position apply
+ spc_gain_UlMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL)!=0, KAL_TRUE);
+ spc_gain_DlMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_DL)!=0, KAL_TRUE);
+ // spc_gain_UlEnhResultMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL_ENH_RESULT)!=0, KAL_TRUE);
+ spc_gain_UlSourceMuteSet((info.mute_mask&SPH_ON_MUTE_BIT_UL_SOURCE)!=0, KAL_TRUE);
+ spc_gain_DlMuteCodecSet((info.mute_mask&SPH_ON_MUTE_BIT_DL_CODEC)!=0, KAL_TRUE);
+ spc_gain_DlMuteSet_PrePcmMixer((info.mute_mask&SPH_ON_MUTE_BIT_DL_PRE_PCM_MIXER)!=0,KAL_TRUE);
+
+ 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]);
+ 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]);
+ L1SP_LoadCommonSpeechPara((uint16 *) info.common_param);
+ L1Audio_SetDebugInfo((uint16 *) info.debug_info);
+ VMREC_ConfigEpl();
+ spc_dev_LoopbackPoint_DVT(info.debug_info[15]);
+
+
+ MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(0,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path);
+ EMI_Offset=0;
+ if(info.param_path == 2 && info.param_shm_valid ==1 )
+ {
+ EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ;
+ //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS);
+ //memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16);
+ //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]);
+ //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]);
+ //L1SP_LoadCommonSpeechPara(Common_Para);
+ //L1Audio_SetDebugInfo((uint16 *)Dbg_Para);
+ l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len);
+ SetSpeechEnhancement(true);
+
+ }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par.
+ {
+ SetSpeechEnhancement(true);
+ }
+ else
+ {
+ // need use MD default par
+ l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN);
+ // L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para);
+ // L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para);
+ SetSpeechEnhancement(true);
+ }
+#endif
+
+ L1SP_SetOpenDSPFlag(info.opendsp_flag);
+ if(SPH_ON_APPLICATION_NORMAL == info.application) {
+ Spc_SpeechOn(RAT_3G_MODE);
+ } else if (SPH_ON_APPLICATION_VT_CALL == info.application) {
+ // phase out from ap side
+ Spc_SpeechOn(RAT_3G324M_MODE);
+ } else if (SPH_ON_APPLICATION_LOOPBACK == info.application) {
+ Spc_AcousticLoopback(true, info.loopback_flag, info.loopback_delay);
+ } else if (SPH_ON_APPLICATION_ROUTER == info.application) {
+ Spc_SpeechRouterOn(true);
+ } else if (SPH_ON_APPLICATION_DACA == info.application) {
+ Spc_SpeechOnForDaca(0, true);
+ } else if (SPH_ON_APPLICATION_HOLD_CALL == info.application) {
+ spc_SpeechOnForCallHold(true);
+ }
+
+ SET_SPC_APP_USAGE(SPC_APP_MERGE_SPH_USAGE);
+
+leaveSphOn:
+ return totalProcLen;
+}
+
+
+void Spc_SpeechOff( void )
+{
+ kal_bool isAppOn=false;
+
+ MD_TRC_SPC_SPEECH_OFF();
+
+ // check app status
+ isAppOn = spc_endApp();
+ MODEM_WARNING_MESSAGE((false==isAppOn), "Spc_SpeechOff: with app=%x", gSpc.spcAppUsage);
+ // ASSERT(0==IS_SPC_APP_USED(SPC_APP_RECORD_USAGE)); removed from 93md
+ // ASSERT(0==IS_SPC_APP_USED(SPC_APP_PCM_REC_USAGE)); removed from 93md
+
+ if(!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_SPEECH_USAGE, SPC_APP_SPEECH_USAGE, 0);
+ return;
+ }
+
+#if SPC_CUST_ENH
+ PcmEx_Stop();
+ DV_Release();
+#endif
+
+
+ // close speech
+ L1SP_Speech_Off();
+ CLR_SPC_APP_USAGE(SPC_APP_SPEECH_USAGE);
+
+}
+
+void Spc_SpeechOff_Merge( void)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)) {
+ if(SPH_ON_APPLICATION_NORMAL == gSpc_sphOnInfo.application) {
+ Spc_SpeechOff();
+ } else if (SPH_ON_APPLICATION_VT_CALL == gSpc_sphOnInfo.application) {
+ Spc_SpeechOff();
+ } else if (SPH_ON_APPLICATION_LOOPBACK == gSpc_sphOnInfo.application) {
+ Spc_AcousticLoopback(false,0,0);
+ } else if (SPH_ON_APPLICATION_ROUTER == gSpc_sphOnInfo.application) {
+ Spc_SpeechRouterOn(false);
+ } else if (SPH_ON_APPLICATION_DACA == gSpc_sphOnInfo.application) {
+ Spc_SpeechOnForDaca(0, false);
+ } else if (SPH_ON_APPLICATION_HOLD_CALL == gSpc_sphOnInfo.application) {
+ spc_SpeechOnForCallHold(false);
+ }
+
+ CLR_SPC_APP_USAGE(SPC_APP_MERGE_SPH_USAGE);
+ } else {
+ Spc_SpeechOff();
+ }
+
+}
+
+// MSG_A2M_SPH_DEV_CHANGE
+kal_uint16 Spc_SpeechDeviceChange(kal_uint16 offset, kal_uint16 length, const SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo header;
+ spc_sph_on_info_t info;
+ kal_uint16 totalProcLen = 0;
+ kal_bool check;
+
+#if defined(_SPE_ENH_DSP_PARSE_)//for 95,97
+ kal_uint32 EMI_Offset;
+ //unsigned short Common_Para[NUM_COMMON_PARAS];
+ //unsigned short Dbg_Para[16];
+#endif
+ memset(&info, 0, sizeof(spc_sph_on_info_t));
+ if(length == (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom);
+ } else if ((length < (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) && (length > sizeof(spcBufInfo))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &header, &info, comeFrom);
+ MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t));
+ } else if (length > (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t))) {
+ SpcIO_GetDataFromAp_inOneTime(offset, (sizeof(spcBufInfo) + sizeof(spc_sph_on_info_t)), sizeof(spcBufInfo), &header, &info, comeFrom);
+ MD_TRC_SPC_SPH_ON_MISMATCH_PAYLOAD_SIZE(length, sizeof(spcBufInfo), sizeof(spc_sph_on_info_t));
+ }else {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MERGE_SPH_USAGE, SPC_APP_MERGE_SPH_USAGE, 3);
+ goto leaveDevChange;
+ }
+
+ check = (header.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow syncWord");
+ if(!check)
+ goto leaveDevChange;
+ check = (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO);
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow type");
+ if(!check)
+ goto leaveDevChange;
+ check = (header.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "Spc_SpeechDeviceChange: unknow length");
+ if(!check)
+ goto leaveDevChange;
+
+ MD_TRC_SPC_SPEECH_ON_PAYLOAD(
+ info.application, info.bt_info, info.sample_rate_enum, info.opendsp_flag,
+ info.param_path, info.param_shm_valid, info.param_size, info.param_idx, info.ext_dev_info,
+ info.mute_mask);
+
+ // set device
+ SP_SetDevicePath(info.bt_info, info.sample_rate_enum);
+ SP_SetExtraDevInfo(info.bt_info, info.ext_dev_info, info.smartPA_config, info.echo_ref_delay_ms, info.mic_delay_ms);
+ gSpc_sphOnInfo.sample_rate_enum = info.sample_rate_enum;
+ gSpc_sphOnInfo.bt_info = info.bt_info;
+ gSpc_sphOnInfo.ext_dev_info = info.ext_dev_info;
+ gSpc_sphOnInfo.echo_ref_delay_ms = info.echo_ref_delay_ms;
+ gSpc_sphOnInfo.mic_delay_ms = info.mic_delay_ms;
+
+
+
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ // apply the parameter
+ if(SPH_ON_PARAM_VIA_SHM == info.param_path) {
+ if(1 == info.param_shm_valid) {
+ kal_uint16 procLen = 0;
+ kal_uint16 curOffset = info.param_idx;
+
+ while (totalProcLen < info.param_size ) {
+ kal_uint16 newOffset;
+ spc_dynamicParameterParser_dispatcher(curOffset, info.param_size-totalProcLen,
+ SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset);
+
+ totalProcLen += procLen;
+ curOffset = newOffset;
+ }
+ }
+ } else {
+ // Via stream. Not implement yet
+ kal_prompt_trace(MOD_L1SP, "DEV change. param data from payload!!");
+ }
+
+#else
+ 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]);
+ 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]);
+ L1SP_LoadCommonSpeechPara((uint16 *) info.common_param);
+ L1Audio_SetDebugInfo((uint16 *) info.debug_info);
+ VMREC_ConfigEpl();
+ spc_dev_LoopbackPoint_DVT(info.debug_info[15]);
+
+ MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(1,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path);
+ EMI_Offset=0;
+ if(info.param_path == 2 && info.param_shm_valid ==1 )
+ {
+ EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ;
+ //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS);
+ //memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16);
+ //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]);
+ //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]);
+ //L1SP_LoadCommonSpeechPara((uint16 *)Common_Para);
+ //L1Audio_SetDebugInfo((uint16 *)Dbg_Para);
+ l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len);
+ SetSpeechEnhancement(true);
+
+ }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par.
+ {
+
+ SetSpeechEnhancement(true);
+ }
+ else
+ {
+ // need use MD default par
+ l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN);
+ // L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para);
+ //L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para);
+ SetSpeechEnhancement(true);
+ }
+
+#endif
+
+leaveDevChange:
+ return totalProcLen;
+}
+
+
+void spc_DebugPrint(void)
+{
+ uint16 *m_para;
+
+ m_para = Sp_GetCommonSpeechPara(); // size NUM_COMMON_PARAS
+ 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]);
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ m_para = Sp_GetSpeechPara(); // size NUM_MODE_PARAS
+ 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]);
+
+ m_para = Sp_GetWbSpeechPara(); // size NUM_MODE_PARAS
+ 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]);
+#endif
+}
+
+
+/**
+ MED(AUDL) task
+ codec: em_speech_info_SpeechCodecType. in "em_public_struct.h"
+*/
+void spc_notify_network_status(uint32 codec)
+{
+ uint16 tmp;
+ uint8 band = 0; // default 8k
+ uint32 RAT = AM_GetNetworkRate();
+ uint8 Network = 0xF;
+
+ if( (0x61 == codec ) || ((codec >= 0x20) && (codec <= 0x28))
+ || ((codec >= 0x90) && (codec <= 0x9F))
+ || ((codec >= 0xD0) && (codec <= 0xDF)) ){ // 16k
+ band = 1;
+
+ } else if((codec >= 0xA0) && (codec <= 0xAF)) { // 32k
+ band = 2;
+ } else if((codec >= 0xB0) && (codec <= 0xBF)) { // 48k
+ band = 3;
+ }
+
+ if(RAT == RAT_4G_MODE)
+ {
+ Network = NETWORK_VOLTE;
+ }
+ else if(RAT == RAT_3G_MODE)
+ {
+ Network = NETWORK_WCDMA_FDD;
+#if defined( __UMTS_RAT__ )
+ switch(L1SP_GetSIMStatus()){
+ case SP_3G_SIM_FDD_ACTIVE:
+ Network = NETWORK_WCDMA_FDD;
+ break;
+ case SP_3G_SIM_TDD_ACTIVE:
+ Network = NETWORK_WCDMA_TDD;
+ break;
+ default:
+ Network = NETWORK_WCDMA_FDD;
+ break;
+ }
+#endif
+ }
+ else if(RAT == RAT_2G_MODE)
+ {
+ Network = NETWORK_GSM;
+ }
+ else if(RAT == RAT_C2K_MODE)
+ {
+ Network = NETWORK_C2K;
+ }
+
+ tmp = (kal_uint16)((band) << 4 | (Network & 0xF) | ( 0x1 << 15 ));
+ // tmp = (kal_uint16)( (band << 3) | (RAT & 0x7));
+
+ if(gSpc_networkStatus != tmp){
+ MD_TRC_SPC_NOTIFY_NETWORK_STATUS_INFO(tmp, band, RAT);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_NETWORK_STATUS_NOTIFY, (kal_uint16)tmp, 0);
+ MD_TRC_SPC_NOTIFY_NETWORK_STATUS(gSpc_networkStatus, tmp);
+ gSpc_networkStatus = tmp;
+ }else{
+ MD_TRC_SPC_NOTIFY_NETWORK_STATUS_SKIP(tmp);
+ }
+
+ spc_codecInfoNotify(codec);
+}
+
+//AUDIO task
+#include "em_audio_public_struct.h"
+void spc_send_network_status_notify(em_speech_info_SpeechCodecType codec)
+{
+ SpcIO_MsgQueuePut(SPC_ID_NETWORK_STATUS_NOTIFY, codec, 0, SPC_MSG_FROM_AUDHISR);
+}
+
+void spc_ReceiveNwCodecInfoReadDone(void)
+{
+ l1sp_send_codec_status_notify(AM_GetSpeechMode());
+}
+/**
+ @isGen: true for trun on, false for turn off
+*/
+void spc_SpeechOnForCallHold(kal_bool isGen)
+{
+
+
+ if(isGen){ // turn on
+
+ if(false == spc_mainAppOnCheck(SPC_APP_HOLD_USAGE))
+ return;
+
+ // turn on speech and mute
+
+ L1SP_Speech_On(RAT_3G_MODE);
+ SP_MuteUlFromDiffPos(true, SP_MIC_MUTE_POS_FROM_SPC);
+
+ SET_SPC_APP_USAGE(SPC_APP_HOLD_USAGE);
+ } else { // turn off
+
+ if(!IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)) { // sid generation not in use
+ // just leave the log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, 0);
+ return;
+ }
+
+ // turn off
+ SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_SPC);
+ L1SP_Speech_Off();
+ CLR_SPC_APP_USAGE(SPC_APP_HOLD_USAGE);
+ }
+
+}
+
+// ----------------------------------------------------------------------------
+// Loopback
+// ----------------------------------------------------------------------------
+#define ACLOOPBACK_USING_P2W 1
+
+#define ACLOOPBACK_FRAME_BUF_NO (64) // REMIND: should be pow of 2
+#define ACLOOPBACK_NB_FRAME_SIZE (160)
+#define ACLOOPBACK_DELAY 12 // unit is 20ms
+
+#if ACLOOPBACK_USING_P2W
+static uint16 gSpc_acLoopback_PCM_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE];
+#else
+// static uint16 gSpc_acLoopback_PCM_UL_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE];
+static uint16 gSpc_acLoopback_PCM_UL_BUF[ACLOOPBACK_NB_FRAME_SIZE];
+static uint16 gSpc_acLoopback_PCM_DL_BUF[ACLOOPBACK_FRAME_BUF_NO][ACLOOPBACK_NB_FRAME_SIZE];
+#endif
+
+typedef struct
+{
+ uint32 delay;
+ uint8 isLoopback;
+
+#if ACLOOPBACK_USING_P2W
+ uint32 tmp_w;
+ uint32 tmp_r;
+#else
+ // uint32 UL_tmp_w;
+ // uint32 UL_tmp_r;
+ uint32 DL_tmp_w;
+ uint32 DL_tmp_r;
+#endif
+
+} _SPC_ACOUSTIC_LOOPBACK_T;
+
+static _SPC_ACOUSTIC_LOOPBACK_T gSpc_acLoopback;
+void spc_setAcLoopbackState(bool b)
+{
+ gSpc_acLoopback.isLoopback = b;
+}
+
+bool spc_isAcLoopback()
+{
+ return gSpc_acLoopback.isLoopback;
+}
+
+
+#if ACLOOPBACK_USING_P2W
+void AcousticLoopback_PCM2WAY_UL_HisrHdl()
+#else
+void AcousticLoopback_PCM4WAY_UL_HisrHdl()
+#endif
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+#if ACLOOPBACK_USING_P2W
+
+ /* P2W */
+ if( (gSpc_acLoopback.tmp_w - gSpc_acLoopback.tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){
+ PCM2WAY_GetFromMic((uint16*)gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ MD_TRC_SPC_AC_LOOPBACK_FROM_MIC(
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.tmp_w)++;
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_SKIP_MIC();
+ }
+
+#else
+ /* P4W UL with delay
+ if( (gSpc_acLoopback.UL_tmp_w - gSpc_acLoopback.UL_tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){
+ PCM4WAY_GetFromMic((uint16*)gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ MD_TRC_SPC_AC_LOOPBACK_FROM_MIC(
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.UL_tmp_w)++;
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_SKIP_MIC();
+ }
+
+ if( (gSpc_acLoopback.UL_tmp_w - gSpc_acLoopback.UL_tmp_r) >= gSpc_acLoopback.delay ){
+ PCM4WAY_PutToSE(gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ MD_TRC_SPC_AC_LOOPBACK_TO_SE(
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_UL_BUF[gSpc_acLoopback.UL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.UL_tmp_r)++;
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_FILL_SE();
+ PCM4WAY_FillSE(0);
+ }
+ */
+
+ // P4W UL without delay
+ PCM4WAY_GetFromMic(gSpc_acLoopback_PCM_UL_BUF);
+ MD_TRC_SPC_AC_LOOPBACK_FROM_MIC(
+ gSpc_acLoopback_PCM_UL_BUF[0],
+ gSpc_acLoopback_PCM_UL_BUF[1],
+ gSpc_acLoopback_PCM_UL_BUF[2],
+ gSpc_acLoopback_PCM_UL_BUF[3]);
+
+ PCM4WAY_PutToSE(gSpc_acLoopback_PCM_UL_BUF);
+ MD_TRC_SPC_AC_LOOPBACK_TO_SE(
+ gSpc_acLoopback_PCM_UL_BUF[0],
+ gSpc_acLoopback_PCM_UL_BUF[1],
+ gSpc_acLoopback_PCM_UL_BUF[2],
+ gSpc_acLoopback_PCM_UL_BUF[3]);
+
+#endif
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+}
+
+#if ACLOOPBACK_USING_P2W
+void AcousticLoopback_PCM2WAY_DL_HisrHdl()
+#else
+void AcousticLoopback_PCM4WAY_DL_HisrHdl()
+#endif
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+#if ACLOOPBACK_USING_P2W
+ /* P2W */
+ if( (gSpc_acLoopback.tmp_w - gSpc_acLoopback.tmp_r) >= gSpc_acLoopback.delay){
+ PCM2WAY_PutToSpk(gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ MD_TRC_SPC_AC_LOOPBACK_TO_SPK(
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_BUF[gSpc_acLoopback.tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.tmp_r)++;
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_FILL_SPK();
+ PCM2WAY_FillSpk(0);
+ }
+
+ MD_TRC_SPC_AC_LOOPBACK_UL_DL_INDEX(
+ gSpc_acLoopback.tmp_w, gSpc_acLoopback.tmp_r, 0, 0);
+#else
+
+
+ if( (gSpc_acLoopback.DL_tmp_w - gSpc_acLoopback.DL_tmp_r) < ACLOOPBACK_FRAME_BUF_NO ){
+ PCM4WAY_GetFromSD((uint16*)gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+ MD_TRC_SPC_AC_LOOPBACK_FROM_SD(
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_w & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.DL_tmp_w)++;
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_SKIP_SD();
+ }
+
+
+
+ if( (gSpc_acLoopback.DL_tmp_w - gSpc_acLoopback.DL_tmp_r) >= gSpc_acLoopback.delay){
+ PCM4WAY_PutToSpk(gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)]);
+
+ MD_TRC_SPC_AC_LOOPBACK_TO_SPK(
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][0],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][1],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][2],
+ gSpc_acLoopback_PCM_DL_BUF[gSpc_acLoopback.DL_tmp_r & (ACLOOPBACK_FRAME_BUF_NO - 1)][3]);
+ (gSpc_acLoopback.DL_tmp_r)++;
+
+ }else{
+ MD_TRC_SPC_AC_LOOPBACK_FILL_SPK();
+
+ PCM4WAY_FillSpk(0);
+ }
+
+
+ MD_TRC_SPC_AC_LOOPBACK_UL_DL_INDEX(
+ /* gSpc_acLoopback.DL_tmp_w, gSpc_acLoopback.DL_tmp_r, gSpc_acLoopback.UL_tmp_w, gSpc_acLoopback.UL_tmp_r);*/
+ gSpc_acLoopback.DL_tmp_w, gSpc_acLoopback.DL_tmp_r, 0, 0);
+
+#endif
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+
+}
+
+/**
+ @uParam: reference spc_sph_on_loopback_info_flag
+ 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
+ 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]
+ @extraParam:
+ 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.
+*/
+void Spc_AcousticLoopback(bool enable, kal_uint8 uParam, kal_uint8 extraParam)
+{
+ // kal_bool enable = uParam & 0x1; // bit(0): on/off bit(1): disable/enable BT SW codec
+
+ MD_TRC_SPC_AC_LOOPBACK_INFO(enable, uParam, extraParam);
+
+ if(enable){
+
+ if(false == spc_mainAppOnCheck(SPC_APP_ACLOOPBACK_USAGE)) // remind to skip EM check if necessary
+ return;
+
+ if(IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(SPC_APP_ACLOOPBACK_USAGE, SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, gSpc.spcAppUsage);
+ return;
+ }
+
+ // special case for BT loopback
+#if defined(__CVSD_CODEC_SUPPORT__)
+
+ if( SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD_MSBC
+ || SP_GetDevInfo() == SPH_DEVINFO_BT_CVSD
+ || SP_GetDevInfo() == SPH_DEVINFO_BT_MSBC)
+ { // for SW BT platform, BT loopback does not related to speech and DSP.
+
+ kal_uint8 voice8kMode = SP_GetDevSamplingRate();
+ if( (voice8kMode==0) || (voice8kMode==1) ) {
+
+ SET_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE);
+ BT_SCO_Loopback_ON( (uParam&SPH_ON_LOOPBACK_INFO_FLAG_DISABLE_BT_CODEC) ,(voice8kMode == 1));
+ return; // REMIND!!!
+
+ } else {
+ MODEM_WARNING_MESSAGE((voice8kMode==0), "Spc_AcousticLoopback(bt): incorrect Voice8kMode, %d", voice8kMode);
+ MODEM_WARNING_MESSAGE((voice8kMode==1), "Spc_AcousticLoopback(bt): incorrect Voice8kMode, %d", voice8kMode);
+ return;
+ }
+ }
+#endif
+
+ // setup
+ gSpc_acLoopback.delay = ACLOOPBACK_DELAY;
+ if((uParam & SPH_ON_LOOPBACK_INFO_FLAG_DELAY_SETTING) !=0) { // using bit[1] for check delay
+ kal_uint8 givenDelay = (extraParam & 0xFF); //use msg32 bit [7:0] for delay setting
+ ASSERT(givenDelay<= ACLOOPBACK_FRAME_BUF_NO);
+ gSpc_acLoopback.delay = givenDelay;
+ }
+#if ACLOOPBACK_USING_P2W
+ gSpc_acLoopback.tmp_w = 0;
+ gSpc_acLoopback.tmp_r = 0;
+#else
+ // gSpc_acLoopback.UL_tmp_w = 0;
+ // gSpc_acLoopback.UL_tmp_r = 0;
+ gSpc_acLoopback.DL_tmp_w = 0;
+ gSpc_acLoopback.DL_tmp_r = 0;
+#endif
+
+ //clean memory
+#if ACLOOPBACK_USING_P2W
+ memset(gSpc_acLoopback_PCM_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE);
+#else
+ // memset(gSpc_acLoopback_PCM_UL_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE);
+ memset(gSpc_acLoopback_PCM_UL_BUF, 0, sizeof(uint16)*ACLOOPBACK_NB_FRAME_SIZE);
+ memset(gSpc_acLoopback_PCM_DL_BUF, 0, sizeof(uint16)*ACLOOPBACK_FRAME_BUF_NO*ACLOOPBACK_NB_FRAME_SIZE);
+#endif
+ spc_setAcLoopbackState(1);
+#if ACLOOPBACK_USING_P2W
+ /* P2W */
+ Idle_PcmEx_Start(AcousticLoopback_PCM2WAY_DL_HisrHdl, AcousticLoopback_PCM2WAY_UL_HisrHdl,
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul1
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul2
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul3
+ USE_D2M_PATH + DATA_SELECT_AFTER_ENH, // ul4
+ USE_M2D_PATH,
+ PCMEX_BAND_NB, PCMEX_IDLE_ENH_SETTING_WITH);
+#else
+ // enable
+ L1SP_Speech_On(RAT_2G_MODE);
+
+#if ACLOOPBACK_USING_ExtCodec
+ Extcodec_Set_Delay(gSpc_acLoopback.delay);
+ Extcodec_Call_Open();
+
+#else
+ L1SP_SpeechLoopBackEnable(KAL_TRUE); //dsp codec loopback
+
+ Del_PcmEx_Start(AcousticLoopback_PCM4WAY_DL_HisrHdl, AcousticLoopback_PCM4WAY_UL_HisrHdl,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH,
+ USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH,
+ USE_D2M_PATH + USE_M2D_PATH);
+#endif//ACLOOPBACK_USING_ExtCodec
+#endif//ACLOOPBACK_USING_P2W
+
+
+ SET_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE);
+
+ } else {
+
+ if(!IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_ACLOOPBACK_USAGE, SPC_APP_ACLOOPBACK_USAGE, 0);
+ return;
+ }
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+ if( BT_SCO_IS_SPEECH_ON() )
+ { // for SW BT platform, BT loopback does not related to speech and DSP.
+ BT_SCO_Loopback_OFF();
+ CLR_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE);
+ return;
+ }
+#endif
+
+
+#if ACLOOPBACK_USING_P2W
+ /* P2W */
+ // SetSpeechEnhancement(false);
+ PcmEx_Stop();
+ /*mute after loopback*/
+
+ SP_MuteUlFromDiffPos(false, SP_MIC_MUTE_POS_FROM_ALL);
+ L1SP_MuteSpeaker(false);
+#else
+
+ // Extended_PCM4WAY_Stop(P4W_APP_TYPE_UNDER_CALL);
+#if ACLOOPBACK_USING_ExtCodec
+ Extcodec_Call_Close();
+#else
+ PcmEx_Stop();
+#endif//ACLOOPBACK_USING_ExtCodec
+
+
+ L1SP_SpeechLoopBackEnable(KAL_FALSE);
+ L1SP_Speech_Off();
+ spc_setAcLoopbackState(0);
+
+
+#endif//ACLOOPBACK_USING_P2W
+
+ CLR_SPC_APP_USAGE(SPC_APP_ACLOOPBACK_USAGE);
+
+ }
+
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// Speech on for Hosted Dongle
+// ----------------------------------------------------------------------------
+#define SPC_DACA_SIZE 320 // 16*20 words, currently fix 16k
+#define SPC_DACA_SIZE_IN_BYTE 640
+
+typedef struct _SPC_DACA_T_{
+
+ kal_bool dacaIsMicBufWaiting;
+ kal_bool dacaIsSpkBufWaiting;
+
+}_SPC_DACA_T;
+
+static _SPC_DACA_T gSpc_Daca;
+static kal_uint16 gSpc_Daca_spkBuf[SPC_DACA_SIZE];
+static kal_uint16 gSpc_Daca_micBuf[SPC_DACA_SIZE];
+
+/**
+ MD -> AP, Run under AUDL/MED
+*/
+void spc_daca_sendDlData(void)
+{
+ kal_bool sendResult = KAL_TRUE;
+ spcBufInfo info;
+
+ if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ // prevent data sending after DACA is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 3);
+ return;
+ }
+
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_DACA_GetSpk;
+ info.length = SPC_DACA_SIZE_IN_BYTE; // currently, fix the buffer size in WB
+
+ sendResult = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ gSpc_Daca_spkBuf, SPC_DACA_SIZE_IN_BYTE, NULL, 0,
+ SPCIO_MSG_FROM_SPC_DACA_DLDATA_NOTIFY));
+
+ if(KAL_TRUE != sendResult) {
+ //clean up the read waiting flag when send fail to prevent blocking.
+ gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 0);
+ }
+}
+
+void spc_daca_sendDlDataDone(void)
+{
+
+ if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 4);
+ return;
+ }
+ gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE;
+}
+
+
+/**
+ MD -> AP, Run under AUDL/MED
+*/
+void spc_daca_requestUlData(void)
+{
+ kal_int32 sendResult;
+
+ if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){ // prevent data sending after DACA is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 5);
+ return;
+ }
+
+ sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DACA_ULDATA_REQUEST, SPC_DACA_SIZE, 0);
+
+ if(sendResult<0){ //clean waiting flag of speaker to prevent message blocking
+ gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1);
+ }
+}
+
+void spc_daca_writeUlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom)
+{
+
+ spcBufInfo info;
+ kal_uint16 curOffSet;
+ kal_bool check;
+
+ if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 6);
+ return;
+ }
+
+ check = (length>=sizeof(spcBufInfo));
+ MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: length=%d small then sizeof(spcBufInfo)", length);
+ if(!check)
+ goto leaveDacaUlDone;
+ curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom);
+
+
+ //header checking
+ check = (info.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow syncWord");
+ if(!check)
+ goto leaveDacaUlDone;
+ check = (info.type == AUD_CCCI_STRMBUF_TYPE_DACA_FillMic);
+ MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow type");
+ if(!check)
+ goto leaveDacaUlDone;
+ check = (info.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: unknow length");
+ if(!check)
+ goto leaveDacaUlDone;
+
+ if(info.length >0){
+ check = (info.length == SPC_DACA_SIZE_IN_BYTE);
+ MODEM_WARNING_MESSAGE(check, "spc_daca_writeUlDataDone: info.length=%d", info.length);
+ if(!check)
+ goto leaveDacaUlDone;
+ SpcIo_GetDataFromAp(curOffSet, SPC_DACA_SIZE_IN_BYTE, gSpc_Daca_micBuf, comeFrom);
+ }
+
+leaveDacaUlDone:
+ gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE;
+}
+
+void spc_dacaDl_handler(void)
+{
+ if( gSpc_Daca.dacaIsSpkBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 0);
+ return;
+ }
+
+ // speaker buffer comes from SD
+ DACA_GetFromSD((uint16 *)gSpc_Daca_spkBuf);
+
+ // Transfer to AUDL
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_DACA_DL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+ gSpc_Daca.dacaIsSpkBufWaiting = KAL_TRUE;
+
+}
+
+void spc_dacaUl_handler(void)
+{
+ if( gSpc_Daca.dacaIsMicBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1);
+ return;
+ }
+
+ // mic buffer put to SE.
+ DACA_PutToSE((const uint16 *)gSpc_Daca_micBuf);
+
+
+ // Transfer to AUDL
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_DACA_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+ gSpc_Daca.dacaIsMicBufWaiting = KAL_TRUE;
+}
+
+/**
+ @RAT_Mode: 0 for 2G, 1 for 3G, 2 for 3G324
+ @enable: true for daca speech on, false for daca speech off
+*/
+void Spc_SpeechOnForDaca( kal_uint8 RAT_Mode, kal_bool enable)
+{
+ if(true == enable){ // speech on with DACA
+
+ if(false == spc_mainAppOnCheck(SPC_APP_HOSTED_USAGE)) {
+ return;
+ }
+
+
+ // disable speech enhancment, due to path is too long, enhancment is meaningless
+ L1SP_EnableSpeechEnhancement(false);
+
+ // clean up setting
+ gSpc_Daca.dacaIsSpkBufWaiting = KAL_FALSE;
+ gSpc_Daca.dacaIsMicBufWaiting = KAL_FALSE;
+
+ // turn on
+#if defined(__UMTS_RAT__) // rate setting
+ if( RAT_Mode != RAT_3G324M_MODE )
+ RAT_Mode = RAT_3G_MODE; // Force initial 3G
+#else
+ RAT_Mode = RAT_2G_MODE;
+#endif
+ MD_TRC_SPC_SPEECH_ON(RAT_Mode);
+ L1SP_Speech_On(RAT_Mode);
+ DACA_Start(spc_dacaDl_handler, spc_dacaUl_handler, DACA_APP_TYPE_ACTIVE_UL_DL_WB); // fix wb due to USB protocal
+
+ SET_SPC_APP_USAGE(SPC_APP_HOSTED_USAGE);
+
+ } else { // speech off with DACA
+
+ // status checking
+ if(!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_HOSTED_USAGE, SPC_APP_HOSTED_USAGE, 1);
+ return;
+ }
+
+ // turn off
+ DACA_Stop(DACA_APP_TYPE_ACTIVE_UL_DL_WB);
+ L1SP_Speech_Off();
+
+ // speech enhancment back to normal
+ L1SP_EnableSpeechEnhancement(false);
+
+ CLR_SPC_APP_USAGE(SPC_APP_HOSTED_USAGE);
+ }
+}
+// ----------------------------------------------------------------------------
+// DSP PCM ROUTER
+// ----------------------------------------------------------------------------
+void Spc_SpeechRouterOn(kal_bool enable)
+{
+ if(enable) {
+
+ // status check
+ if(false == spc_mainAppOnCheck(SPC_APP_PCMROUTER_USAGE)){
+ return;
+ }
+
+ //set solution ver before application start.
+
+ // application enable
+ PcmRouterStart();
+ SET_SPC_APP_USAGE(SPC_APP_PCMROUTER_USAGE);
+
+ } else {
+
+ // status checking
+ if(!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMROUTER_USAGE, SPC_APP_PCMROUTER_USAGE, 1);
+
+ return;
+ }
+
+
+ // application disable
+ PcmRouterStop();
+ CLR_SPC_APP_USAGE(SPC_APP_PCMROUTER_USAGE);
+
+ }
+}
+
+// ----------------------------------------------------------------------------
+// RECORD
+// ----------------------------------------------------------------------------
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+typedef struct
+{
+ bool isRecordDataWaiting;
+
+} _SPC_VM_RECORD_T;
+
+typedef struct
+{
+ bool isRecordDataWaiting;
+} _SPC_RAW_PCM_RECORD_T;
+
+// static _SPC_PCM_RECORD_T gSpc_PcmRecord;
+static _SPC_VM_RECORD_T gSpc_VmRecord;
+static _SPC_RAW_PCM_RECORD_T gSpc_RawPcmRecord;
+// static SPC_REC_FORMAT gSpc_Record_format; // only use under record command containing vm/pcm
+/*
+static kal_uint8 tempMicDataCnt = 0;
+static kal_uint16 tempMicData[320]
+ // = { 0x4808,0x85, 0x156,0, 0x4,0, 0x146,0x9000,
+ = {
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575
+
+};
+*/
+
+void spc_RawPcmRec_sendDataDone(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 1);
+ return;
+ }
+
+ gSpc_RawPcmRecord.isRecordDataWaiting = false;
+}
+
+
+/**
+ run under AUDL/MED, when process message "SPC_ID_AUDIO_STRM_RAWPCMREC_DATA_NOTIFY"
+*/
+void spc_record_sendRawPcmData(void)
+{
+ kal_uint32 add1, add2;
+ kal_uint16 len1, len2;
+ spcBufInfo info;
+ bool sendResult = true;
+
+ if( (!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)) ){ // prevent pcm data sending to AP after record off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 4);
+ return;
+ }
+
+ RawPcmRec_GetMicDataBufs(&add1, &len1, &add2, &len2);
+
+ MD_TRC_RAWPCMREC_GET_DATA_BUFS(add1, len1, add2, len2);
+
+ // change the len to unit of byte
+ len1 <<=1;
+ len2 <<=1;
+
+ if(len1 == 0){
+ gSpc_RawPcmRecord.isRecordDataWaiting = false;
+ MD_TRC_RAWPCMREC_GET_EMPTY_DATA();
+ } else {
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_RAW_PCM_TYPE;
+ info.length = len1 + len2;
+
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ (void *)add1, len1, (void *)add2, len2,
+ SPCIO_MSG_FROM_SPC_RAW_PCM_REC_DATA_NOTIFY);
+
+ if(sendResult == false) {
+ gSpc_RawPcmRecord.isRecordDataWaiting = false;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0);
+ }
+ }
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+/**
+ Send notification to AUDL/MED, prepare to get the recording data
+*/
+void spc_RawPcmRec_handler(void)
+{
+ if( gSpc_RawPcmRecord.isRecordDataWaiting == true){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0);
+ return;
+ }
+
+ gSpc_RawPcmRecord.isRecordDataWaiting = true;
+ // Send notification to AUDL to begin data transfer
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_RAWPCMREC_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+
+ return;
+}
+
+void spc_RawPcmRec_On(kal_uint8 dlPosition)
+{
+ // RAW PCM Record
+ gSpc_RawPcmRecord.isRecordDataWaiting = false;
+
+ RAWPCMREC_Start(spc_RawPcmRec_handler, dlPosition);
+}
+
+void spc_RawPcmRec_Off(void)
+{
+ RAWPCMREC_Stop();
+}
+
+bool spc_RawPcmRec_getDataWaiting(void)
+{
+ return(gSpc_RawPcmRecord.isRecordDataWaiting);
+}
+
+
+void spc_vmRec_sendMicDataDone(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1);
+ return;
+ }
+
+ gSpc_VmRecord.isRecordDataWaiting = false;
+}
+
+
+/**
+ run under AUDL/MED, when process message "SPC_ID_AUDIO_STRM_VMREC_DATA_NOTIFY"
+*/
+void spc_record_sendVmData(void)
+{
+
+ kal_uint32 add1, add2;
+ kal_uint16 len1, len2;
+ kal_uint16 totalLenInWord;
+ spcBufInfo info;
+ bool sendResult = true;
+
+ if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){ // prevent sening vm data to AP after record off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 5);
+ return;
+ }
+
+ // get data, length is word!!
+ VmRec_GetReadBufs(&add1, &len1, &add2, &len2);
+ totalLenInWord = len1+len2;
+
+ MD_TRC_VM_SENDVMDATA_INFO(add1, len1, add2, len2);
+
+ // change the len to unit of byte
+ len1 <<= 1;
+ len2 <<= 1;
+
+ if(len1 == 0){
+ gSpc_VmRecord.isRecordDataWaiting = false;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1);
+
+ } else {
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_VM_TYPE;
+ info.length = len1 + len2;
+
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ (void *)add1, len1, (void *)add2, len2,
+ SPCIO_MSG_FROM_SPC_VM_REC_DATA_NOTIFY);
+
+ VmRec_ReadDataDone(totalLenInWord);
+
+ if(sendResult == false) {
+ gSpc_VmRecord.isRecordDataWaiting = false;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 2);;
+ }
+ }
+}
+
+void spc_vmRec_handler(void)
+{
+ if( gSpc_VmRecord.isRecordDataWaiting == true){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1);
+ return;
+ }
+
+ gSpc_VmRecord.isRecordDataWaiting = true;
+
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_VMREC_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+ return;
+}
+
+void spc_vmRec_On(void)
+{
+ VMREC_Start(spc_vmRec_handler, false);
+
+ gSpc_VmRecord.isRecordDataWaiting = false;
+}
+
+void spc_vmRec_Off(void)
+{
+ gSpc_VmRecord.isRecordDataWaiting = true;
+
+ VMREC_Stop(false);
+}
+
+// ---- Entry Points and Checking -----
+
+/**
+ @return: true for pass checking, flase for fail checking
+*/
+bool spc_recordStartCheck(MSG_SPC_APP_T app)
+{
+/*
+ if(!IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE){ // prevent record on before EM data sending
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(app, app, 0);
+ return false;
+ }
+*/
+ if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)){ // under SID generation state, record function is not provided
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR_CHECK(app, SPC_APP_HOLD_USAGE, SPC_APP_HOLD_USAGE, gSpc.spcAppUsage);
+
+ ASSERT(0);
+
+ return false;
+ }
+
+ // system is under idle state, we do not provide record function.
+ if((!IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE))
+ && (!IS_SPC_APP_USED(SPC_APP_ACLOOPBACK_USAGE))
+ && (!IS_SPC_APP_USED(SPC_APP_CTM_USAGE))
+ && (!IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE))
+ && (!IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE))
+ ){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(app, app, 3);
+
+ // REMOVE
+ // ASSERT(0);
+
+ return false;
+ }
+
+ // defualt
+ return true;
+}
+
+
+/**
+ Open vm logging to AP side. This can concurrency with PCM record (spc_PcmRecordStart)
+*/
+void spc_VmRecordStart(void)
+{
+ if(true!= spc_recordStartCheck(SPC_APP_VM_REC_USAGE)){
+ return;
+ }
+
+ // prevent re-entry
+ if(IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 2);
+ return;
+ }
+
+ spc_vmRec_On();
+
+ SET_SPC_APP_USAGE(SPC_APP_VM_REC_USAGE);
+}
+
+/**
+ Pair with spc_VmRecordStart(), to close vm logging.
+*/
+void spc_VmRecordStop(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_VM_REC_USAGE, SPC_APP_VM_REC_USAGE, 1);
+ return;
+ }
+
+ spc_vmRec_Off();
+ CLR_SPC_APP_USAGE(SPC_APP_VM_REC_USAGE);
+}
+
+
+/**
+ Open RAW PCM record. This can concurrency with VM record (spc_VmRecordStart)
+ Only support speech on record!! (Speech on for daca is NOT support)
+*/
+void spc_RawPcmRecordStart(kal_uint8 dlPosition)
+{
+ if(true != spc_recordStartCheck(SPC_APP_RAW_PCM_REC_USAGE)){
+ return;
+ }
+
+ if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) // PCM record is not allow on DACA
+ {
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 4);
+ ASSERT(0);
+ return;
+ }
+
+ // prevent re-entry
+ if(IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 2);
+ return;
+ }
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ spc_RawPcmRec_On(dlPosition);
+ SET_SPC_APP_USAGE(SPC_APP_RAW_PCM_REC_USAGE);
+}
+
+
+void spc_RawPcmRecordStop(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_RAW_PCM_REC_USAGE, SPC_APP_RAW_PCM_REC_USAGE, 0);
+ return;
+ }
+
+ spc_RawPcmRec_Off();
+ CLR_SPC_APP_USAGE(SPC_APP_RAW_PCM_REC_USAGE);
+}
+
+
+// ----------------------------------------------------------------------------
+// PCMNWAY
+// ----------------------------------------------------------------------------
+#define SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF 960 // unit is 16bit(word)
+#define SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF 960 // unit is 16bit(word), max = 48*20 = 960
+#define SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF 1922 // unit is 16bit(word), max = 960*2 +2(agc use)
+#define SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF 960 // unit is 16bit(word)
+
+
+#define SPC_PNW_MSG_BUFFER_SE 1 // Bit 0
+#define SPC_PNW_MSG_BUFFER_SPK 2 // Bit 1
+#define SPC_PNW_MSG_BUFFER_MIC 4 // Bit 2
+#define SPC_PNW_MSG_BUFFER_SD 8 // Bit 3
+
+#define SPC_PNW_MSG_BIT_BAND 4
+
+typedef enum
+{
+
+ SPC_PCMNWAY_APP_TYPE_NONE = 0,
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ SPC_PCMNWAY_APP_TYPE_UNSET = 0xffff,
+} SPC_PCMNWAY_APP_TYPE_T;
+
+typedef enum {
+ SPC_PCMNWAY_FORMAT_P2W_NORMAL = 0,
+ SPC_PCMNWAY_FORMAT_P2W_VOIP,
+ SPC_PCMNWAY_FORMAT_P2W_CAL, //calibration
+ SPC_PCMNWAY_FORMAT_P2W_WB_CAL, //wb calibration
+ SPC_PCMNWAY_FORMAT_P2W_WB_NORMAL, //normal usage for WB p2w
+
+ SPC_PCMNWAY_FORMAT_UNSET = 0xffff,
+}SPC_PCMNWAY_Format;
+
+
+typedef struct _SPC_PCMNWAY_T_
+{
+ kal_uint8 pnwBufInfo; //ref to SPC_PNW_MSG_BUFFER_x
+ kal_uint8 pnwBand; //0: for narrow band, 1: for wide band
+ // kal_uint16 pnwAppType;
+
+ kal_bool pnwIsMicBufWaiting;
+ kal_bool pnwIsSpkBufWaiting;
+
+ kal_uint32 micBufSize; // unit is byte (8bit)
+ kal_uint32 spkBufSize; // unit is byte (8bit)
+ kal_uint32 seBufSize;
+ kal_uint32 sdBufSize;
+
+
+}_SPC_PCMNWAY_T;
+
+static _SPC_PCMNWAY_T gSpc_Pcmnway;
+static kal_uint16 gSpc_Pcmnway_seBuf[SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF];
+static kal_uint16 gSpc_Pcmnway_spkBuf[SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF];
+static kal_uint16 gSpc_Pcmnway_micBuf[SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF];
+static kal_uint16 gSpc_Pcmnway_sdBuf[SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF];
+
+/*
+__attribute__ ((section ("NONCACHEDZI"))) static kal_uint16 tempUlData[179]
+ // = { 0x4808,0x85, 0x156,0, 0x4,0, 0x146,0x9000,
+ = { 0,0, 0,0, 0,0, 0,0,
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 0x2A2A, 0x2, 0x140,
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575,
+
+ 0xfff4,0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587,
+ 0x8001, 0xa575, 0xfff4, 0x5a7a, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575,
+ 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a78,
+ 0x7fff, 0x5a8a, 0x000d, 0xa587, 0x8001, 0xa576, 0xfff3, 0x5a79, 0x7fff, 0x5a8b,
+ 0x000d, 0xa587, 0x8001, 0xa575, 0xfff4, 0x5a79, 0x7fff, 0x5a8a, 0x000c, 0xa588,
+ 0x8001, 0xa576, 0xfff4, 0x5a79, 0x7fff, 0x5a8b, 0x000d, 0xa587, 0x8001, 0xa575
+};
+*/
+
+/**
+ MD -> AP, Run under AUDL/MED
+*/
+void spc_pcmNWay_sendUlData(void)
+{
+ kal_bool sendResultMic = KAL_TRUE;
+ kal_bool sendResultSd = KAL_TRUE;
+ spcBufInfo info;
+
+ if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ // prevent data sending after PCMNWAY is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 4);
+ return;
+ }
+
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) {
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_PCM_GetFromMic;
+#if 0 //defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#else // defined(__ENABLE_SPEECH_DVT__)
+ info.length = gSpc_Pcmnway.micBufSize;
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+ // for debug
+ /*
+ sendResultMic = spcIO_sendDataViaCCCI(
+ SPCIO_CCCI_MSG_CONSTRCUT_DATA_CMD(MSG_M2A_DATA_NOTIFY_PNW_ULREAD, 326),
+ &(tempUlData[8]), 342);
+ */
+
+#if 0 //defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ {
+ sendResultMic = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ gSpc_Pcmnway_micBuf, gSpc_Pcmnway.micBufSize, NULL, 0,
+ SPCIO_MSG_FROM_SPC_PNW_ULDATA_NOTIFY));
+ }
+
+ }
+
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SD) {
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_PCM_GetfromSD;
+ info.length = gSpc_Pcmnway.sdBufSize;
+
+ sendResultSd = (SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ gSpc_Pcmnway_sdBuf, gSpc_Pcmnway.sdBufSize, NULL, 0,
+ SPCIO_MSG_FROM_SPC_PNW_ULDATA_NOTIFY));
+ }
+
+ if((KAL_TRUE != sendResultMic) || (KAL_TRUE != sendResultSd)) {
+ //clean up the read waiting flag when send fail to prevent blocking.
+ gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 0);
+ }
+}
+
+void spc_pcmNWay_sendUlDataDone(void)
+{
+
+ if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1);
+ return;
+ }
+ gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE;
+
+}
+
+/**
+ MD -> AP
+*/
+// void spc_pcmNWay_requestDlData(uint16 bufLength)
+void spc_pcmNWay_requestDlData(void)
+{
+ kal_int32 sendResult;
+
+ if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){ // prevent data sending after PCMNWAY is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 5);
+ return;
+ }
+
+#if 0 // defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ {
+ sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_DLDATA_REQUEST, gSpc_Pcmnway.spkBufSize, 0);
+ }
+ // SPCIO_CCCI_MSG_ORG_CONSTRCUT_CMD(MSG_M2A_DATA_REQUEST_PNW_DLDATA, gSpc_Pcmnway.spkBufSize));
+
+ if(sendResult<0){ //clean waiting flag of speaker to prevent message blocking
+ gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1);
+ }
+}
+
+void spc_pcmNWay_writeDlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom)
+{
+
+ spcBufInfo info;
+ kal_uint16 curOffSet;
+ kal_bool check;
+
+ if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 5);
+ return;
+ }
+
+ check = (length>=sizeof(spcBufInfo));
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: length=%d small then sizeof(spcBufInfo)", length);
+ if(!check)
+ goto leavePnwDlDone;
+ curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom);
+
+
+ //header checking
+ check = (info.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord");
+ if(!check)
+ goto leavePnwDlDone;
+ check = ( (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSE) || (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSpk) );
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord");
+ if(!check)
+ goto leavePnwDlDone;
+ check = (info.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: unknow syncWord");
+ if(!check)
+ goto leavePnwDlDone;
+
+ if(info.length >0){
+ if (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_FillSE) { //SE
+ check = (info.length == gSpc_Pcmnway.seBufSize);
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: (se)info.length=%d", info.length);
+ if(!check)
+ goto leavePnwDlDone;
+ SpcIo_GetDataFromAp(curOffSet, gSpc_Pcmnway.seBufSize, gSpc_Pcmnway_seBuf, comeFrom);
+ } else { //SPK
+ check = (info.length == gSpc_Pcmnway.spkBufSize);
+ MODEM_WARNING_MESSAGE(check, "spc_pcmNWay_writeDlDataDone: (spk)info.length=%d", info.length);
+ if(!check)
+ goto leavePnwDlDone;
+ SpcIo_GetDataFromAp(curOffSet, gSpc_Pcmnway.spkBufSize, gSpc_Pcmnway_spkBuf, comeFrom);
+
+ }
+ }
+
+leavePnwDlDone:
+ gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE;
+}
+
+
+void spc_pcm4way_handler( void )
+{
+ // spc_pcm4wayDl_handler();
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+ if( gSpc_Pcmnway.pnwIsSpkBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 4);
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+ // SE buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SE) {
+ gSpc_Pcmnway.seBufSize = ((PCM4WAY_PutToSE((const uint16*)gSpc_Pcmnway_seBuf)) << 1);
+ }
+
+ // Speaker buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SPK) {
+ gSpc_Pcmnway.spkBufSize = ((PCM4WAY_PutToSpk((const uint16*)gSpc_Pcmnway_spkBuf)) << 1);
+ }
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ // Transfer to AUDL
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+ gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_TRUE;
+
+ // --------------------------------------------------------------
+ // spc_pcm4wayUl_handler();
+ if( gSpc_Pcmnway.pnwIsMicBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 3);
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+
+ // Microphone buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) {
+ gSpc_Pcmnway.micBufSize = ((PCM4WAY_GetFromMic((uint16*)gSpc_Pcmnway_micBuf))<<1);
+ }
+
+ // SD buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SD) {
+ gSpc_Pcmnway.sdBufSize = ((PCM4WAY_GetFromSD((uint16*)gSpc_Pcmnway_sdBuf))<<1);
+ }
+
+ // Transfer to AUDL
+ // Send notification
+ gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_TRUE;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_UL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+
+
+}
+
+void spc_pcm2wayUl_handler( void )
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+#if defined(__ENABLE_SPEECH_DVT__)
+ kal_uint16 bufLen;
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+ if( gSpc_Pcmnway.pnwIsMicBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 1);
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+ // Microphone buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_MIC) {
+#if 0 //defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#else // defined(__ENABLE_SPEECH_DVT__)
+ gSpc_Pcmnway.micBufSize = ((PCM2WAY_GetFromMic((uint16*)gSpc_Pcmnway_micBuf))<<1);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ }
+ gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_TRUE;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ // Transfer to AUDL
+ // Send notification
+#if 0 // defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#else // defined(__ENABLE_SPEECH_DVT__)
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_UL_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+
+}
+
+void spc_pcm2wayDl_handler( void )
+{
+ kal_take_spinlock(pcmEx.PCMEXspinLockID, KAL_INFINITE_WAIT);
+ if(pcmEx.running == 0){
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+#if 0 //defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+ if( gSpc_Pcmnway.pnwIsSpkBufWaiting == KAL_TRUE){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 2);
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ return;
+ }
+
+ // Speaker buffer
+ if (gSpc_Pcmnway.pnwBufInfo & SPC_PNW_MSG_BUFFER_SPK) {
+#if 0 //defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#else // defined(__ENABLE_SPEECH_DVT__)
+ gSpc_Pcmnway.spkBufSize = ((PCM2WAY_PutToSpk((const uint16*)gSpc_Pcmnway_spkBuf))<<1);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ }
+ gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_TRUE;
+ kal_give_spinlock(pcmEx.PCMEXspinLockID);
+ // Transfer to AUDL
+ // Send notification
+#if 0 // defined(__ENABLE_SPEECH_DVT__)
+/* under construction !*/
+#else // defined(__ENABLE_SPEECH_DVT__)
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_PNW_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
+
+}
+
+
+void spc_pcm2way_handler( void )
+{
+ spc_pcm2wayDl_handler();
+ spc_pcm2wayUl_handler();
+}
+
+
+/**
+ @param:
+ [0:3] pcmnway buffer infor, please ref SPC_PNW_MSG_BUFFER_x
+ [4]: band information: 0 narrow band, 1 wide band,
+ @format: please reference SPC_PCMNWAY_Format. If its value is 0xFFFF(undefine), we decide it by band information.
+ @appType: application type using in PCMNWAY. If its value is 0xFFFF(undefine), we will choose by ourself
+*/
+void spc_PcmNWayStart(kal_uint32 param, SPC_PCMNWAY_Format format) // , SPC_PCMNWAY_APP_TYPE_T appType)
+{
+ uint32 cfgUL1 , cfgUL2, cfgUL3, cfgUL4, cfgDL;
+
+ if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE) || IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 3);
+
+ ASSERT(0);
+
+ return;
+ }
+
+
+ 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)
+ gSpc_Pcmnway.pnwBand = ((param >> SPC_PNW_MSG_BIT_BAND) & 0x1);
+
+ ASSERT(gSpc_Pcmnway.pnwBufInfo != 0);
+
+
+ // buffer rest
+ memset( (kal_uint8 *)gSpc_Pcmnway_seBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SE_BUF*sizeof(uint16) );
+ memset( (kal_uint8 *)gSpc_Pcmnway_spkBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SPK_BUF*sizeof(uint16) );
+ memset( (kal_uint8 *)gSpc_Pcmnway_micBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_MIC_BUF*sizeof(uint16) );
+ memset( (kal_uint8 *)gSpc_Pcmnway_sdBuf, 0, SPC_PCMNWAY_MAX_SIZE_OF_SD_BUF*sizeof(uint16) );
+ gSpc_Pcmnway.micBufSize = 0;
+ gSpc_Pcmnway.spkBufSize = 0;
+ gSpc_Pcmnway.seBufSize = 0;
+ gSpc_Pcmnway.sdBufSize = 0;
+
+ // reset wating
+ gSpc_Pcmnway.pnwIsMicBufWaiting = KAL_FALSE;
+ gSpc_Pcmnway.pnwIsSpkBufWaiting = KAL_FALSE;
+
+
+ // UL1 path
+ cfgUL1 =DATA_SELECT_AFTER_ENH;
+ if(SPC_PNW_MSG_BUFFER_MIC & gSpc_Pcmnway.pnwBufInfo ) {
+ cfgUL1 |= USE_D2M_PATH;
+ }
+ if(SPC_PNW_MSG_BUFFER_SE & gSpc_Pcmnway.pnwBufInfo ) {
+ cfgUL1 |= USE_M2D_PATH;
+ }
+
+ //UL2 path
+ cfgUL2=DATA_SELECT_AFTER_ENH;
+ //UL3 path
+ cfgUL3=DATA_SELECT_AFTER_ENH;
+ //UL4 path
+ cfgUL4=DATA_SELECT_AFTER_ENH;
+
+ // DL path
+ cfgDL = 0;
+ if(SPC_PNW_MSG_BUFFER_SD & gSpc_Pcmnway.pnwBufInfo ) {
+ cfgDL |= USE_D2M_PATH;
+ }
+ if(SPC_PNW_MSG_BUFFER_SPK & gSpc_Pcmnway.pnwBufInfo ) {
+ cfgDL |= USE_M2D_PATH;
+ }
+
+ if (IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) { // in call
+ if( (SPC_PNW_MSG_BUFFER_SPK|SPC_PNW_MSG_BUFFER_MIC) == gSpc_Pcmnway.pnwBufInfo) { // 2way
+ Del_PcmEx_Start(spc_pcm2wayDl_handler, spc_pcm2wayUl_handler,
+ cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL);
+ } else {
+ Del_PcmEx_Start(spc_pcm4way_handler, NULL,
+ cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL);
+ }
+
+
+ } else { // idle
+
+ PCMEX_BAND band = PCMEX_BAND_UNSET;
+ PCMEX_IDLE_ENH_SETTING enhSetting = PCMEX_IDLE_ENH_SETTING_WITH; // default with
+
+ band = ((gSpc_Pcmnway.pnwBufInfo == 0)? PCMEX_BAND_NB : PCMEX_BAND_WB);
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ if( (SPC_PNW_MSG_BUFFER_SPK|SPC_PNW_MSG_BUFFER_MIC) == gSpc_Pcmnway.pnwBufInfo) { // 2way
+ Idle_PcmEx_Start(spc_pcm2wayDl_handler, spc_pcm2wayUl_handler,
+ cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL,
+ band, enhSetting);
+ } else {
+ Idle_PcmEx_Start(spc_pcm4way_handler, NULL,
+ cfgUL1, cfgUL2, cfgUL3, cfgUL4, cfgDL,
+ band, enhSetting);
+ }
+
+ }
+
+
+ // record the spc application usage status
+ SET_SPC_APP_USAGE(SPC_APP_PCMNWAY_USAGE);
+
+}
+
+void spc_PcmNWayStop()
+{
+
+ if(!IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_PCMNWAY_USAGE, SPC_APP_PCMNWAY_USAGE, 0);
+ return;
+ }
+
+ PcmEx_Stop();
+
+ // clear buffer
+ gSpc_Pcmnway.pnwBufInfo = 0;
+ gSpc_Pcmnway.pnwBand = 0;
+ gSpc_Pcmnway.micBufSize = 0;
+ gSpc_Pcmnway.spkBufSize = 0;
+ gSpc_Pcmnway.seBufSize = 0;
+ gSpc_Pcmnway.sdBufSize = 0;
+
+ CLR_SPC_APP_USAGE(SPC_APP_PCMNWAY_USAGE);
+
+}
+
+// ----------------------------------------------------------------------------
+// PCMMIXER
+// ----------------------------------------------------------------------------
+typedef struct _SPC_PCMMIXER_T_
+{
+ kal_bool isUlBufWaiting;
+ kal_bool isDlBufWaiting;
+}_SPC_PCMMIXER_T;
+
+static _SPC_PCMMIXER_T gSpc_PCMMixer;
+
+void spc_PCMMixer_UL_handler( void )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+}
+
+void spc_PCMMixer_DL_handler( void )
+{
+ if(gSpc_PCMMixer.isDlBufWaiting){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 0);
+ return;
+ }
+ gSpc_PCMMixer.isDlBufWaiting = KAL_TRUE;
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER_DL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+}
+
+
+void spc_PCMMixerConfig(kal_bool isUlMix, kal_bool isDlMix, uint8 ulGainLevel, uint8 dlGainLevel)
+{
+ PcmMixer_ConfigUl(isUlMix, ulGainLevel);
+ PcmMixer_ConfigDl(isDlMix, dlGainLevel);
+}
+
+void spc_PCMMixerStart(kal_bool isUlMix, kal_bool isDlMix, uint8 ulGainLevel, uint8 dlGainLevel)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // application re-entry
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 5);
+ return;
+ }
+
+ 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
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 3);
+ return;
+ }
+
+ gSpc_PCMMixer.isDlBufWaiting = KAL_FALSE;
+ PcmMixer_ConfigUl(isUlMix, ulGainLevel);
+ PcmMixer_ConfigDl(isDlMix, dlGainLevel);
+
+ PcmMixer_Start(spc_PCMMixer_DL_handler);
+ SET_SPC_APP_USAGE(SPC_APP_MIXER_USAGE);
+}
+
+void spc_PCMMixerStop()
+{
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // application re-entry
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_PCMNWAY_USAGE, 0);
+ return;
+ }
+
+ gSpc_PCMMixer.isDlBufWaiting = KAL_TRUE;
+ PcmMixer_Stop();
+
+ CLR_SPC_APP_USAGE(SPC_APP_MIXER_USAGE);
+}
+
+void spc_pcmMixer_requestDlData(void)
+{
+ kal_bool sendResult;
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){ // prevent data sending after mixer is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 1);
+ return;
+ }
+
+ sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_DL_DATA_REQUEST, ((PcmMixer_QueryDlBufLen())<<1) , 0);
+ if(KAL_FALSE == sendResult){ //clean waiting flag of speaker to prevent message blocking
+ gSpc_PCMMixer.isDlBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 1);
+ }
+
+}
+
+
+void spc_PCMMixer_writeDlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ kal_bool check;
+
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER_USAGE)){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 5);
+ return;
+ }
+
+ ASSERT(length>=sizeof(spcBufInfo));
+
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom);
+
+
+ //header checking
+ check = (info.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow syncWord");
+ if(!check)
+ goto leave;
+ check = (info.type == AUD_CCCI_STRMBUF_TYPE_PCM_MIXER_DL);
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow type");
+ if(!check)
+ goto leave;
+ check = (info.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: incorrect length");
+ if(!check)
+ goto leave;
+
+ PcmMixer_writeDlBuf((uint16 *)emDataBuf, info.length>>1);
+
+leave:
+ gSpc_PCMMixer.isDlBufWaiting = false;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// PCMMIXER3
+// ----------------------------------------------------------------------------
+typedef struct _SPC_PCMMIXER3_T_
+{
+ kal_bool isUlBufWaiting;
+}_SPC_PCMMIXER3_T;
+
+static _SPC_PCMMIXER3_T gSpc_PCMMixer3;
+
+void spc_PCMMixer3_UL_handler( void )
+{
+ if(gSpc_PCMMixer3.isUlBufWaiting){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 0);
+ return;
+ }
+ gSpc_PCMMixer3.isUlBufWaiting = KAL_TRUE;
+ // Send notification
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_PCMMIXER3_UL_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+}
+
+
+void spc_PCMMixer3Config(kal_bool isUlMix, uint8 ulGainLevel)
+{
+ PcmMixer3_ConfigUl(isUlMix, ulGainLevel);
+}
+
+void spc_PCMMixer3Start(kal_bool isUlMix, uint8 ulGainLevel)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // application re-entry
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 5);
+ return;
+ }
+
+ 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
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER_USAGE, SPC_APP_MIXER_USAGE, 3);
+ return;
+ }
+
+ gSpc_PCMMixer3.isUlBufWaiting = KAL_FALSE;
+ PcmMixer3_ConfigUl(isUlMix, ulGainLevel);
+ //PcmMixer3_ConfigDl(isDlMix, dlGainLevel);
+
+ PcmMixer3_Start(spc_PCMMixer3_UL_handler);
+ SET_SPC_APP_USAGE(SPC_APP_MIXER3_USAGE);
+}
+
+void spc_PCMMixer3Stop()
+{
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // application re-entry
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_PCMNWAY_USAGE, 0);
+ return;
+ }
+
+ gSpc_PCMMixer3.isUlBufWaiting = KAL_TRUE;
+ PcmMixer3_Stop();
+
+ CLR_SPC_APP_USAGE(SPC_APP_MIXER3_USAGE);
+}
+
+void spc_pcmMixer3_requestUlData(void)
+{
+ kal_bool sendResult;
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){ // prevent data sending after mixer is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 1);
+ return;
+ }
+
+ sendResult = SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_UL_DATA_REQUEST, ((PcmMixer3_QueryUlBufLen())<<1) , 0);
+ if(KAL_FALSE == sendResult){ //clean waiting flag of speaker to prevent message blocking
+ gSpc_PCMMixer3.isUlBufWaiting = KAL_FALSE;
+ MD_TRC_SPC_APP_DATA_SEND_FAIL(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 1);
+ }
+
+}
+
+void spc_PCMMixer3_writeUlDataDone(kal_uint16 offset, kal_int16 length, SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ kal_bool check;
+
+ if(!IS_SPC_APP_USED(SPC_APP_MIXER3_USAGE)){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_MIXER3_USAGE, SPC_APP_MIXER3_USAGE, 5);
+ return;
+ }
+
+ ASSERT(length>=sizeof(spcBufInfo));
+
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom);
+
+
+ //header checking
+ check = (info.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow syncWord");
+ if(!check)
+ goto leave;
+ check = (info.type == AUD_CCCI_STRMBUF_TYPE_TELEPHONYTX_UL);
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: unknow type");
+ if(!check)
+ goto leave;
+ check = (info.length == (length - sizeof(spcBufInfo)));
+ MODEM_WARNING_MESSAGE(check, "PcmMixer: incorrect length");
+ if(!check)
+ goto leave;
+
+ PcmMixer3_writeUlBuf((uint16 *)emDataBuf, info.length>>1);
+
+leave:
+ gSpc_PCMMixer3.isUlBufWaiting = false;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// Background Sound
+// ----------------------------------------------------------------------------
+typedef struct _SPC_BGSND_T_
+{
+ kal_uint8 ulGainLevel;
+ kal_uint8 dlGainLevel;
+
+ kal_bool isDataWaiting;
+ kal_uint32 id;
+}_SPC_BGSND_T;
+
+static _SPC_BGSND_T gSpc_bgSnd;
+
+/**
+ Run under MED/AUDL Thread
+*/
+void spc_bgSnd_writeDataDone(kal_uint16 offset, kal_uint16 length, SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ kal_bool check;
+
+ if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // prevent data sending after background sound is off
+ MD_TRC_SPC_M2A_DROP(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 1);
+ return;
+ }
+
+ MD_TRC_SPC_BGSND_WRITEDATADONE_ENTER();
+
+ check = (length >= sizeof(spcBufInfo));
+ MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: small data size");
+ if(!check)
+ goto bgsLeave;
+
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, emDataBuf, comeFrom);
+
+ //header check
+ check = (info.syncWord == 0xA2A2);
+ MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow syncWord");
+ if(!check)
+ goto bgsLeave;
+ check = (info.type == AUD_CCCI_STRMBUF_TYPE_BGS_TYPE);
+ MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow type");
+ if(!check)
+ goto bgsLeave;
+ check = (info.length == (length-6));
+ MODEM_WARNING_MESSAGE(check, "spc_bgSnd_writeDataDone: unknow length");
+ if(!check)
+ goto bgsLeave;
+
+ if(info.length>0){
+ EXT_BGSND_WriteSrcBuffer(gSpc_bgSnd.id, emDataBuf, (kal_int32) info.length, BGSND_DL_PROCESS);
+ EXT_BGSND_WriteSrcBuffer(gSpc_bgSnd.id, emDataBuf, (kal_int32) info.length, BGSND_UL_PROCESS);
+ }
+
+bgsLeave:
+ gSpc_bgSnd.isDataWaiting = KAL_FALSE;
+
+ MD_TRC_SPC_BGSND_WRITEDATADONE_LEAVE();
+}
+
+/**
+ Run under MED/AUDL Thread
+*/
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+void spc_bgSnd_requestData(void)
+{
+ int32 bLen;
+ MD_TRC_SPC_BGSND_REQUESTDATA_ENTER();
+ if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // prevent data sending after background sound is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 1);
+ return;
+ }
+
+ if(gSpc_bgSnd.isDataWaiting){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 0);
+ return;
+ }
+ bLen = MIN( EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_UL_PROCESS), EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS));
+ //bLen = BGSND_GetFreeSpace(); //unit is 16bit in BGSND_GetFreeSpace() return
+ // bLen &= ~0x1;
+ MD_TRC_SPC_BGSND_REQUESTDATA_INFO(bLen, BGSND_RB_DEFAULT_THRESHOLD);
+
+ if( bLen >= BGSND_RB_DEFAULT_THRESHOLD ) {
+
+ // send data request to AP
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_BGS_DATA_REQUEST, (bLen<<1) , 0);
+ gSpc_bgSnd.isDataWaiting = KAL_TRUE;
+
+ }
+ MD_TRC_SPC_BGSND_REQUESTDATA_LEAVE();
+
+}
+
+/**
+ Call back handler from HISR
+*/
+void spc_BGSND_DLHdr(void)
+{
+ MD_TRC_SPC_BGSND_DLHDR_ENTER();
+ EXT_BGSND_WriteExtBuffer(gSpc_bgSnd.id, 1, BGSND_DL_PROCESS);
+ EXT_BGSND_WriteExtBuffer(gSpc_bgSnd.id, 1, BGSND_UL_PROCESS);
+
+ if(KAL_FALSE == gSpc_bgSnd.isDataWaiting) {
+ int bLen = MIN( EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS), EXT_BGSND_GetFreeSpace(gSpc_bgSnd.id, BGSND_DL_PROCESS));
+ if( (bLen >= BGSND_RB_DEFAULT_THRESHOLD) && (EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS) == EXT_SRC_STATE_RUN) ) {
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_BGSND_DATA_REQUEST, 0, 0, SPC_MSG_FROM_AUDHISR);
+ }
+ }
+ MD_TRC_SPC_BGSND_DLHDR_LEAVE();
+}
+
+/**
+ Call back handler from AUDIO task when bgSnd is off
+*/
+void spc_bgSnd_closeHandler(void)
+{
+
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_CONTROL_BGSND_CLOSE, 0, 0, SPC_MSG_FROM_AUDHISR);
+}
+
+void spc_BgSndStart(void)
+{
+#ifdef SPH_CHIP_BACK_PHONECALL_USE
+ return;
+#endif
+
+
+ if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // application re-entry
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 5);
+ return;
+ }
+
+/*
+ if(!IS_SPC_ID_SPEECH_CUSTOM_DATA_REQUEST_DONE){ // prevent background sound on before EM data sending
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 4);
+ return;
+ }
+*/
+ 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
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 3);
+ return;
+ }
+
+ if(IS_SPC_APP_USED(SPC_APP_HOLD_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 2);
+
+ ASSERT(0);
+
+ return;
+ }
+ MD_TRC_SPC_BGSNDSTART_ENTER();
+ gSpc_bgSnd.isDataWaiting = KAL_FALSE;
+ gSpc_bgSnd.id = EXT_BGSND_Start(spc_bgSnd_closeHandler, spc_BGSND_DLHdr, NULL, gSpc_bgSnd.dlGainLevel, gSpc_bgSnd.ulGainLevel);
+ SET_SPC_APP_USAGE(SPC_APP_BGSND_USAGE);
+ MD_TRC_SPC_BGSNDSTART_LEAVE();
+}
+
+void spc_BgSndStop(void)
+{
+
+ if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){
+ // just leave log and return,
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 0);
+
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0);
+ return;
+ }
+
+ // to avoid to many data request
+ gSpc_bgSnd.isDataWaiting = KAL_TRUE;
+ MD_TRC_SPC_BGSNDSTOP_ENTER();
+ EXT_BGSND_Flush(gSpc_bgSnd.id);
+ MD_TRC_SPC_BGSNDSTOP_LEAVE();
+}
+
+void spc_BgSndForceClose(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){ // due to AP close process may interrupt by EPOF command, so the checked is need
+ // just leave log and return,
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_BGSND_USAGE, SPC_APP_BGSND_USAGE, 6);
+
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0);
+ return;
+ }
+
+ EXT_BGSND_Close(gSpc_bgSnd.id);
+ CLR_SPC_APP_USAGE(SPC_APP_BGSND_USAGE);
+}
+
+void spc_BgSndClose(void)
+{
+ spc_BgSndForceClose();
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, 0, 0);
+}
+
+
+/**
+ @ulGainLevel: 0~7 levels, mapping to 0~32767
+ @dlGainLevel: 0~7 levels, mapping to 0~32767
+*/
+void spc_BgSndConfig(kal_uint8 ulGainLevel, kal_uint8 dlGainLevel)
+{
+ MD_TRC_SPC_BGSNDCONFIG_ENTER();
+ gSpc_bgSnd.ulGainLevel = ulGainLevel;
+ gSpc_bgSnd.dlGainLevel = dlGainLevel;
+
+ // when application is running, update hte gain directly
+ if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)){
+ EXT_BGSND_ConfigMixer(gSpc_bgSnd.id, KAL_TRUE, gSpc_bgSnd.dlGainLevel, BGSND_DL_PROCESS);
+ EXT_BGSND_ConfigMixer(gSpc_bgSnd.id, KAL_TRUE, gSpc_bgSnd.ulGainLevel, BGSND_UL_PROCESS);
+ }
+ MD_TRC_SPC_BGSNDCONFIG_LEAVE();
+}
+// ----------------------------------------------------------------------------
+// CTM
+// ----------------------------------------------------------------------------
+
+#ifdef __CTM_SUPPORT__
+
+#if defined(__CCCI_OVER_SDIO_SUPPORT__)
+#define SPC_CTM_DUMP_DEBUG_BUF_SIZE (165 *4 )
+#else
+#define SPC_CTM_DUMP_DEBUG_BUF_SIZE (163 *4 )
+#endif
+
+typedef struct _SPC_CTM_T_
+{
+ kal_bool isDumpDebugFile;
+ kal_bool isDumpDataWaiting;
+ kal_uint16 dumpDebugBuf[SPC_CTM_DUMP_DEBUG_BUF_SIZE];
+ kal_uint16 dumpDebugBufPtr;
+ kal_uint16 mode;
+ kal_bool isPCM;
+}_SPC_CTM_T;
+
+
+#define SPC_CTM_BUFFER_SIZE 44600 // 44596
+__attribute__((aligned (4)))static kal_uint8 gSpc_Ctm_buf[SPC_CTM_BUFFER_SIZE];
+
+static _SPC_CTM_T gSpc_ctm;
+
+
+void spc_ctm_sendDumpDebugData(void)
+{
+ kal_bool sendResult;
+
+ if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){ // prevent data sending after CTM is off
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 1);
+ return;
+ }
+
+
+#if defined(__CCCI_OVER_SDIO_SUPPORT__)
+ {
+ uint8 *ptr = (uint8 *)gSpc_ctm.dumpDebugBuf;
+ spcExtendedBufInfo *pinfo;
+ int i, len;
+
+ sendResult=true;
+ for(i=1; i<=4; i++){
+ pinfo = (spcExtendedBufInfo *)ptr;
+ ASSERT(pinfo->syncWord == 0x1234);
+ // ASSERT(pinfo->curIdx == i);
+ // ASSERT(pinfo->totalIdx == 4);
+
+ len = sizeof(spcExtendedBufInfo)+ pinfo->length;
+ sendResult &= SpcIO_WriteDataToAp(NULL, 0, ptr, (len), NULL, 0, SPCIO_MSG_FROM_SPC_CTM_DEBUG_DATA_NOTIFY);
+
+ ptr += len;
+ }
+
+ if(KAL_TRUE != sendResult) {
+ gSpc_ctm.dumpDebugBufPtr = 0;
+ gSpc_ctm.isDumpDataWaiting = KAL_FALSE;
+
+ }
+ }
+#else
+ sendResult = (SpcIO_WriteDataToAp(NULL, 0,
+ gSpc_ctm.dumpDebugBuf, ((gSpc_ctm.dumpDebugBufPtr)<<1), NULL, 0,
+ SPCIO_MSG_FROM_SPC_CTM_DEBUG_DATA_NOTIFY));
+
+ if(KAL_TRUE != sendResult) {
+ //clean up the read waiting flag when send fail to prevent blocking.
+ gSpc_ctm.dumpDebugBufPtr = 0;
+ gSpc_ctm.isDumpDataWaiting = KAL_FALSE;
+
+ }
+#endif
+}
+
+void spc_ctm_sendDumpDebugDataDone(void)
+{
+ if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 2);
+ return;
+ }
+ gSpc_ctm.dumpDebugBufPtr = 0;
+ gSpc_ctm.isDumpDataWaiting = false;
+}
+
+static void spc_ctm_handler(L1Ctm_Event event, void *param)
+{
+
+}
+
+/**
+ This function is running under L1audioTask, as a callback function
+ @length: length of buffer unit in 16bit.
+*/
+void spc_Ctm_DebugCallback(uint16 pos, uint16 *buffer, uint16 length, bool isDone)
+{
+
+ if(gSpc_ctm.isDumpDebugFile == false)
+ {
+ return;
+ }
+
+
+ if(true == isDone ){
+
+ if( KAL_TRUE == gSpc_ctm.isDumpDataWaiting){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 1);
+ return;
+ }
+
+ // send request to MED
+ SpcIO_MsgQueuePut(SPC_ID_AUDIO_STRM_CTM_DUMP_DATA_NOTIFY, 0, 0, SPC_MSG_FROM_AUDHISR);
+ gSpc_ctm.isDumpDataWaiting = KAL_TRUE;
+
+ } else {
+#if defined(__CCCI_OVER_SDIO_SUPPORT__)
+ spcExtendedBufInfo info;
+#else
+ spcBufInfo info;
+#endif
+ if( KAL_TRUE == gSpc_ctm.isDumpDataWaiting){
+ MD_TRC_SPC_M2A_DROP(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 0);
+ return;
+ }
+#if defined(__CCCI_OVER_SDIO_SUPPORT__)
+ info.syncWord = 0x1234;
+#else
+ info.syncWord = 0x2A2A;
+#endif
+ info.length = length*sizeof(uint16);
+
+ switch(pos){
+ case UL_IN_WRITE_FILE_REQUEST: // 1
+ info.type = AUD_CCCI_STRMBUF_TYPE_CTM_UL_IN;
+ break;
+ case DL_IN_WRITE_FILE_REQUEST: // 2
+ info.type = AUD_CCCI_STRMBUF_TYPE_CTM_DL_IN;
+ break;
+ case UL_OUT_WRITE_FILE_REQUEST: // 3
+ info.type = AUD_CCCI_STRMBUF_TYPE_CTM_UL_OUT;
+ break;
+ case DL_OUT_WRITE_FILE_REQUEST: // 4
+ info.type = AUD_CCCI_STRMBUF_TYPE_CTM_DL_OUT;
+ break;
+ default:
+ ASSERT(0);
+ }
+
+#if defined(__CCCI_OVER_SDIO_SUPPORT__)
+ info.curIdx = 1;
+ info.totalIdx = 1;
+ memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), &info, sizeof(spcExtendedBufInfo));
+
+ gSpc_ctm.dumpDebugBufPtr += 5; // header= sizeof(spcBufInfo)
+#else
+ memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), &info, sizeof(spcBufInfo));
+ gSpc_ctm.dumpDebugBufPtr += 3; // header= sizeof(spcBufInfo)
+#endif
+
+ memcpy((uint8 *)(&(gSpc_ctm.dumpDebugBuf[gSpc_ctm.dumpDebugBufPtr])), buffer, length*sizeof(uint16));
+ gSpc_ctm.dumpDebugBufPtr +=length;
+
+ ASSERT(gSpc_ctm.dumpDebugBufPtr <= SPC_CTM_DUMP_DEBUG_BUF_SIZE); // overflow protection
+ }
+}
+
+/**
+ @mode: 0: DIRECT_MODE, 1: BAUDOT_MODE
+*/
+void spc_NormalCtmStart(kal_uint16 mode){
+ if (L1Ctm_GetMemReq() > SPC_CTM_BUFFER_SIZE)
+ ASSERT(0);
+
+ gSpc_ctm.isDumpDataWaiting = false;
+ memset(gSpc_ctm.dumpDebugBuf, 0, sizeof(uint16)*SPC_CTM_DUMP_DEBUG_BUF_SIZE);
+ gSpc_ctm.dumpDebugBufPtr=0;
+
+ L1Ctm_Open( mode, spc_ctm_handler, gSpc_Ctm_buf, SPC_CTM_BUFFER_SIZE, spc_Ctm_DebugCallback);
+ SET_SPC_APP_USAGE(SPC_APP_CTM_USAGE);
+}
+void spc_C2KCtmStart(kal_uint16 mode){
+ if(FULL_MODE == mode){
+ SAL_C2K_SetTTYStatus(true, true);
+ l1sp_setCtmSpeStatus(1);
+ kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__);
+ SetSpeechEnhancement(false);
+ l1sp_setCtmSpeStatus(0);
+ }
+ else if(VCO_MODE == mode){
+ SAL_C2K_SetTTYStatus(false, true);
+ l1sp_setCtmSpeStatus(1);
+ kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__);
+ SetSPEnhancePath(SpeechEnh_UL);
+ }
+ else if(HCO_MODE == mode){
+ SAL_C2K_SetTTYStatus(true, false);
+ l1sp_setCtmSpeStatus(1);
+ kal_prompt_trace(MOD_L1SP, "%s() SetSpeechEnhancement = false", __FUNCTION__);
+ SetSPEnhancePath(SpeechEnh_DL);
+ }
+ gSpc_ctm.isPCM = false;
+}
+kal_uint16 spc_getCtmMode(){
+ return gSpc_ctm.mode;
+}
+
+kal_bool spc_isPCM(){
+ kal_prompt_trace(MOD_L1SP, "spc_isPCM = %d",gSpc_ctm.isPCM);
+ return gSpc_ctm.isPCM;
+}
+
+void spc_CtmStart(kal_uint16 mode)
+{
+ gSpc_ctm.mode = mode;
+ if(L1SP_STATE_C2K_SPEECH_ON == L1SP_GetState()){
+ spc_C2KCtmStart(mode);
+ }
+ else{
+ spc_NormalCtmStart(mode);
+ gSpc_ctm.isPCM = true;
+ }
+}
+
+void spc_NormalCtmStop(void){
+
+ if(!IS_SPC_APP_USED(SPC_APP_CTM_USAGE)){
+ // just leave log and return
+ MD_TRC_SPC_ILLEGAL_SPC_APP_BEHAVIOR(SPC_APP_CTM_USAGE, SPC_APP_CTM_USAGE, 0);
+ return;
+ }
+
+ L1Ctm_Stop();
+
+ CLR_SPC_APP_USAGE(SPC_APP_CTM_USAGE);
+}
+void spc_CtmStop(void)
+{
+ l1sp_setCtmSpeStatus(1);
+ SetSpeechEnhancement(true);
+ SAL_C2K_SetTTYStatus(false, false);
+
+ if(!gSpc_ctm.isPCM){
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, 0, 0);
+ }
+ else{
+ spc_NormalCtmStop();
+ }
+
+ gSpc_ctm.isPCM = false;
+ gSpc_ctm.mode = 0;
+}
+
+void spc_CtmClose(void)
+{
+ kal_prompt_trace(MOD_L1SP, "[spc_CtmClose] Enter");
+ L1Ctm_Close();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, 0, 0);
+ kal_prompt_trace(MOD_L1SP, "[spc_CtmClose] Leave");
+}
+
+void spc_RttConfig(uint16 type){
+
+ kal_prompt_trace(MOD_L1SP, "[spc_RttConfig] %d", type);
+ if(type==1)
+ L1Ctm_RTTOpen();
+ else
+ L1Ctm_RTTClose();
+}
+
+
+/*
+[REMIND] This function "L1Ctm_StartNegotiation" is not called from AP side.
+The actual user is L1D in modem. So phase it out.
+
+void spc_CtmNegotiation(void)
+{
+ L1Ctm_StartNegotiation();
+}
+*/
+
+void spc_CtmDebugConfig(kal_bool turnOn)
+{
+ gSpc_ctm.isDumpDebugFile = turnOn;
+}
+
+#endif // __CTM_SUPPORT__
+
+// ----------------------------------------------------------------------------
+// Parameter Setting like EM
+// ----------------------------------------------------------------------------
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+void spc_ReceiveViberationSpkParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ AUDIO_VIBSPK_PARAMETER_STRUCT *vibSpkParam; //buffer reuse
+
+ vibSpkParam = (AUDIO_VIBSPK_PARAMETER_STRUCT *)(&emDataBuf); //buffer reuse
+
+ //get data
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, vibSpkParam, comeFrom);
+
+ //header checking
+ ASSERT(info.syncWord == 0xA2A2);
+ ASSERT(info.type== AUD_CCCI_STRMBUF_TYPE_VIBSPK_PARAM); //just use the bit[0:3] to inidicate the type.
+ ASSERT(info.length == (length-6));
+
+
+ // copy coefficient
+ spe_setNotchFilterParam(vibSpkParam->notch_filter_para, vibSpkParam->is2In1Spk);
+
+
+}
+
+void spc_ReceiveNxpSmartPaParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ AUDIO_NXP_SMARTPA_PARAMETER_STRUCT *nxpPaParam; //buffer reuse
+
+ nxpPaParam = (AUDIO_NXP_SMARTPA_PARAMETER_STRUCT *)(&emDataBuf); //buffer reuse
+
+ //get data
+ SpcIO_GetDataFromAp_inOneTime(offset, length, sizeof(spcBufInfo), &info, nxpPaParam, comeFrom);
+
+ //[REMOVE] header checking
+ // ASSERT(info.syncWord == 0xA2A2);
+ // ASSERT(info.type== AUD_CCCI_STRMBUF_TYPE_NXP_SMARTPA_PARAM); //just use the bit[0:3] to inidicate the type.
+ // ASSERT(info.length == (length-6));
+
+ // SPE_SetEchoRefInfo(nxpPaParam->isNxpFeatureOptOn, nxpPaParam->mic_index, nxpPaParam->chip_delay_with_switch, SPH_MODE_LOUDSPK);
+
+}
+#if defined(_SPE_ENH_MD_PARSE_)
+
+kal_uint16 spc_ReceiveDynamicParameter_viaStructShm(const kal_uint16 offset,const kal_uint16 length,SPC_MSG_FROM_T comeFrom)
+{
+ // spcBufInfo header;
+ // spc_sph_on_info_t info;
+ kal_uint16 totalProcLen = 0;
+ kal_uint16 curOffset = offset;
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ while(totalProcLen < length) {
+ kal_uint16 procLen = 0;
+ kal_uint16 newOffset;
+ spc_dynamicParameterParser_dispatcher(curOffset, length, SPC_MSG_FROM_CCCI_STREAM_AND_SHM, &procLen, &newOffset);
+ totalProcLen += procLen;
+ curOffset = newOffset;
+ }
+ return totalProcLen;
+
+}
+#endif
+
+
+
+// ----------------------------------------------------------------------------
+// Volume Setting
+// ----------------------------------------------------------------------------
+/**
+ @digiGain: unit is 0.25 dB
+*/
+void spc_gain_DlDigiGainSet(kal_uint16 digiGain)
+{
+ spGain_SetDigitalGain( (kal_int16)digiGain, false );
+ // l1sp_digiOnly_SetOutputVolume((kal_int16)digiGain);
+}
+
+/**
+ @refDigiGain: unit is 0.25 dB
+*/
+void spc_gain_DlEnhRefDigiGainSet(kal_uint16 refDigiGain)
+{
+ spGain_SetEnhRefDigitalGain((kal_int16)refDigiGain, false);
+ //l1sp_digiOnly_SetEnhRefOutputVolume((kal_int16)refDigiGain);
+}
+
+/**
+ @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
+*/
+void spc_gain_UlDigiGainSet(kal_uint16 digiGain)
+{
+ spGain_SetMicrophoneVolume((kal_int16)digiGain, false);
+ // l1sp_digiOnly_SetMicrophoneVolume((kal_int16)digiGain);
+}
+
+/**
+ @on: 1 for turn on mute, 0 for turn off mute
+ @byPassCheck: 1 for by pass check, 0 for normal check
+*/
+void spc_gain_UlMuteSet(kal_bool on, kal_bool byPassCheck)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)
+ || KAL_TRUE == byPassCheck) {
+ gSpc.spcMuteUl = on;
+ SP_MuteUlFromDiffPos(on, SP_MIC_MUTE_POS_FROM_SPC); // L1SP_MuteMicrophone(on);
+ } else {
+ MD_TRC_SPC_SET_DROP_UL_MUTE();
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(SAL_RAMP_UL_POS_EN);
+#endif
+ }
+}
+
+void spc_gain_DlMuteSet(kal_bool on, kal_bool byPassCheck)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)
+ || KAL_TRUE == byPassCheck){
+ gSpc.spcMuteDl = on;
+ L1SP_MuteSpeaker(on);
+ } else {
+ MD_TRC_SPC_SET_DROP_DL_MUTE();
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(SAL_RAMP_DL_PRE_DACA);
+#endif
+ }
+}
+
+void spc_gain_UlSourceMuteSet(kal_bool on, kal_bool byPassCheck)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)
+ ||IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)
+ || KAL_TRUE == byPassCheck) {
+ gSpc.spcMuteUlSource = on;
+ SP_MuteUlSource(on);
+ } else {
+ MD_TRC_SPC_SET_DROP_UL_SOURCE_MUTE();
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(SAL_RAMP_UL_PRE_EN);
+#endif
+ }
+}
+
+/**
+ run under AUDL/MED, when process message "MSG_ID_AUDIO_M2M_RAMP_DONE"
+*/
+
+void spc_sendRampDoneAck(uint16 ramp_point)
+{
+ MD_TRC_SPC_MUTE_DSP_RAMP_ACK_POINT(gSpc.spcRampAck, ramp_point);
+ if(!IS_SPC_RAMP_WAIT_ACK(ramp_point)) {
+ MD_TRC_SPC_MUTE_DSP_RAMP_NO_ACK();
+ return;
+ }
+ CLR_SPC_RAMP_WAIT_ACK(ramp_point);
+ switch(ramp_point){
+ case SAL_RAMP_UL_POS_EN:
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ACK, 0, 0);
+ break;
+ case SAL_RAMP_UL_PRE_EN:
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_SOURCE_ACK, 0, 0);
+ break;
+ case SAL_RAMP_DL_PRE_DACA:
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_ACK, 0, 0);
+ break;
+ case SAL_RAMP_DL_PRE_MIXER2:
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_DL_DYNAMIC_ACK, 0, 0);
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+void spc_gain_DlMuteCodecSet(kal_bool on, kal_bool byPassCheck)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)
+ ||IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)
+ || KAL_TRUE == byPassCheck) {
+ L1SP_SetCodecMuteByAp(on);
+ } else {
+ MD_TRC_SPC_SET_DROP_DL_CODEC_MUTE();
+ }
+}
+
+void spc_gain_DlMuteSet_PrePcmMixer(kal_bool on, kal_bool byPassCheck)
+{
+ if(IS_SPC_APP_USED(SPC_APP_MERGE_SPH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)
+ || IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)
+ || KAL_TRUE == byPassCheck) {
+ SP_MuteDl_beforePcmMixer(on);
+ } else {
+ MD_TRC_SPC_SET_DROP_DL_MUTE_WITH_POS();
+#if defined(__SMART_PHONE_MODEM__)
+ spc_sendRampDoneAck(SAL_RAMP_DL_PRE_MIXER2);
+#endif
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// Device Related Setting
+// ----------------------------------------------------------------------------
+
+void spc_dev_SamplingRateSet(kal_uint16 sampleRate)
+{
+ switch(sampleRate){
+ case 0:
+ AFE_SetVoice8KMode(2); //default 32000, case 0: reset
+ break;
+ case 8000:
+ AFE_SetVoice8KMode(0);
+ break;
+ case 16000:
+ AFE_SetVoice8KMode(1);
+ break;
+ case 32000:
+ AFE_SetVoice8KMode(2);
+ break;
+ case 48000:
+ AFE_SetVoice8KMode(3);
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// AUDL running functions Related
+// ----------------------------------------------------------------------------
+
+void spc_A2M_MsgHandler(kal_uint32 ccciMsg, kal_uint32 ccciResv, SPC_MSG_FROM_T comeFrom)
+{
+ kal_uint16 cmd, msgData16;
+ kal_uint16 msgData32;
+ uint16 type16 = 0;
+
+ cmd = SPCIO_CCCI_MSG_CMD(ccciMsg);
+ msgData16 = SPCIO_CCCI_MSG_DATA16(ccciMsg);
+ msgData32 = ccciResv;
+
+ switch(cmd){
+ case MSG_A2M_SPH_DL_DIGIT_VOLUME:
+ spc_gain_DlDigiGainSet(msgData16);
+ break;
+ case MSG_A2M_SPH_UL_DIGIT_VOLUME:
+ spc_gain_UlDigiGainSet(msgData16);
+ break;
+ case MSG_A2M_MUTE_SPH_UL:
+ SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_UL_POS_EN);
+ spc_gain_UlMuteSet( (kal_bool)(msgData16&1), KAL_FALSE);
+ break;
+ case MSG_A2M_MUTE_SPH_DL:
+ SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_DL_PRE_DACA);
+ spc_gain_DlMuteSet( (kal_bool)(msgData16&1), KAL_FALSE);
+ break;
+ // case MSG_A2M_SIDETONE_VOLUME: break;
+ case MSG_A2M_SPH_DL_ENH_REF_DIGIT_VOLUME:
+ spc_gain_DlEnhRefDigiGainSet(msgData16);
+ break;
+ // case MSG_A2M_SIDETONE_CONFIG: break;
+ case MSG_A2M_MUTE_SPH_UL_ENH_RESULT:
+ // spc_gain_UlEnhResultMuteSet((kal_bool)(msgData16&1), KAL_FALSE);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_MUTE_SPH_UL_ENH_RESULT_ACK, 0, 0);
+ break;
+ case MSG_A2M_MUTE_SPH_UL_SOURCE:
+ SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_UL_PRE_EN);
+ spc_gain_UlSourceMuteSet((kal_bool)(msgData16&1), KAL_FALSE);
+ break;
+ case MSG_A2M_MUTE_SPH_DL_CODEC:
+ spc_gain_DlMuteCodecSet((kal_bool)(msgData16&1), KAL_FALSE);
+ break;
+ case MSG_A2M_MUTE_SPH_DL_DYNAMIC:
+ SET_SPC_RAMP_WAIT_ACK(SAL_RAMP_DL_PRE_MIXER2);
+ spc_gain_DlMuteSet_PrePcmMixer((kal_bool)(msgData16&1), KAL_FALSE);
+ break;
+
+ // --------- [0x10] device related -----------
+ case MSG_A2M_SET_SAMPLE_RATE:
+ spc_dev_SamplingRateSet(msgData16);
+ break;
+ // case MSG_A2M_SET_DUAL_MIC: break;
+ case MSG_A2M_SET_LPBK_POINT_DVT:
+ spc_dev_LoopbackPoint_DVT(msgData16);
+ break;
+
+ // --------- [0x20] speech control -----------
+ case MSG_A2M_SPH_ON:
+ {
+ if(SPC_MSG_FROM_CCCI_STREAM == comeFrom) {
+ type16 = Spc_SpeechOn_withData((kal_uint16)msgData32, msgData16, comeFrom);
+ } else {
+ Spc_SpeechOn((kal_uint8) msgData16);
+ }
+
+#if defined(__ECALL_SUPPORT__)
+ spc_eCall_SDT_Open();
+#endif
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_ACK, type16, 0);
+ }
+ break;
+ case MSG_A2M_SPH_OFF:
+ {
+#if defined(__ECALL_SUPPORT__)
+ spc_eCall_SDT_Close();
+#endif
+ // Spc_SpeechOff();
+ Spc_SpeechOff_Merge();
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_OFF_ACK, 0, 0);
+ }
+ break;
+ case MSG_A2M_SET_SPH_MODE:
+ {
+ // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) msgData16 );
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_SPH_MODE_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_CTRL_SPH_ENH:
+ {
+ // add condition checking when turn speech enhancment on/off
+ if(IS_SPC_APP_USED(SPC_APP_HOSTED_USAGE)) {
+ MD_TRC_SPC_DROP_SET(ccciMsg, cmd, cmd, msgData16, msgData32);
+ } else {
+ L1SP_EnableSpeechEnhancement((msgData16!=0));
+ }
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTRL_SPH_ENH_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_CONFIG_SPH_ENH:
+ {
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CONFIG_SPH_ENH_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_SET_ACOUSTIC_LOOPBACK:
+ {
+#if defined(__ENABLE_SPEECH_DVT__)
+ Spc_PCMNWay_DVT_Test((kal_uint8) msgData16 );
+#else // defined(__ENABLE_SPEECH_DVT__)
+ Spc_AcousticLoopback((msgData16&1), (kal_uint8)(msgData16>>1), (kal_uint8)(msgData32&0xff));
+#endif // defined(__ENABLE_SPEECH_DVT__)
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_ACOUSTIC_LOOPBACK_ACK, msgData16, msgData32);
+ }
+ break;
+ case MSG_A2M_PRINT_SPH_COEFF:
+ {
+ spc_DebugPrint();
+ // ack is: SPCIO_MSG_FROM_SPC_PRINT_SPH_COEFF_ACK --> MSG_M2A_PRINT_SPH_COEFF_ACK
+ }
+ break;
+ case MSG_A2M_SPH_ON_FOR_HOLD_CALL:
+ {
+ // [REMIND] No application can be on under this application
+ spc_SpeechOnForCallHold((msgData16 == 1)); // bit 0, 0 for off, 1 for on
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_FOR_HOLD_CALL_ACK, 0, 0);
+ }
+ break;
+ case MSG_A2M_SPH_ON_FOR_DACA:
+ {
+ Spc_SpeechOnForDaca((kal_uint8) msgData16, (kal_bool)(msgData16 >> 8));
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ON_FOR_DACA_ACK, msgData16, 0);
+ }
+ break;
+
+ case MSG_A2M_SPH_ROUTER_ON:
+ {
+ Spc_SpeechRouterOn((msgData16&1)==1);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_ROUTER_ON_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_SET_VOICE_ENCRYPTION:
+ {
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SET_VOICE_ENCRYPTION_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_SPH_DEV_CHANGE:
+ {
+ type16 = Spc_SpeechDeviceChange((kal_uint16)msgData32, msgData16, comeFrom);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_SPH_DEV_CHANGE_ACK, type16, 0);
+ }
+ break;
+ case MSG_A2M_ENH_CTRL_SUPPORT:
+ {
+ L1SP_EnhancementCtrlSupport(msgData16);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_ENH_CTRL_SUPPORT_ACK, type16, 0);
+ }
+ break;
+ // --------- [0x30] speech control -----------
+ case MSG_A2M_PNW_ON: // normal use always narrow band/decided by network
+ {
+ spc_PcmNWayStart(msgData16, SPC_PCMNWAY_FORMAT_UNSET) ; // , SPC_PCMNWAY_APP_TYPE_UNSET);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_ON_ACK, msgData16, 0);
+ // SPCIO_CCCI_MSG_CONSTRCUT_CMD(MSG_M2A_PNW_ON_ACK, msgData16));
+ }
+ break;
+ case MSG_A2M_PNW_OFF:
+ {
+ spc_PcmNWayStop();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PNW_OFF_ACK, msgData16, 0);
+ // SPCIO_CCCI_MSG_CONSTRCUT_CMD(MSG_M2A_PNW_OFF_ACK, msgData16));
+ }
+ break;
+/*
+ case MSG_A2M_RECORD_ON: // spc_RecordStart
+ break;
+ case MSG_A2M_RECORD_OFF: // spc_RecordStop
+ break;
+ case MSG_A2M_DMNR_RECPLAY_ON:
+ break;
+ case MSG_A2M_DMNR_RECPLAY_OFF:
+ break;
+ case MSG_A2M_DMNR_REC_ONLY_ON:
+ break;
+ case MSG_A2M_DMNR_REC_ONLY_OFF:
+ break;
+ case MSG_A2M_PCM_REC_ON: // spc_PcmRecordStart
+ break;
+ case MSG_A2M_PCM_REC_OFF: // spc_PcmRecordStop
+ break;
+*/
+ case MSG_A2M_VM_REC_ON:
+ {
+ spc_VmRecordStart();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VM_REC_ON_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_VM_REC_OFF:
+ {
+ spc_VmRecordStop();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VM_REC_OFF_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_RECORD_RAW_PCM_ON:
+ {
+ // data16 bit[0:3] is position info
+ spc_RawPcmRecordStart((kal_uint8)(msgData16&0xF));
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_ON_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_RECORD_RAW_PCM_OFF:
+ {
+ spc_RawPcmRecordStop();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_RECORD_RAW_PCM_OFF_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_PCMMIXER_ON:
+ {
+ //bit 0: isDlMix: 0 is replace, 1 is mix
+ //bit 2: isUlMix: 0 is replace, 1 is mix
+ spc_PCMMixerStart((msgData16&4)==4, (msgData16&1)==1, 0, 7);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_ON_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_PCMMIXER_OFF:
+ {
+ spc_PCMMixerStop();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER_OFF_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_TELEPHONY_TX_ON:
+ {
+ //bit 0: isUlMix: 0 is replace, 1 is mix
+ spc_PCMMixer3Start(msgData16&1, 7);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_ON_ACK, msgData16, 0);
+ }
+ break;
+ case MSG_A2M_TELEPHONY_TX_OFF:
+ {
+ spc_PCMMixer3Stop();
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_PCMMIXER3_OFF_ACK, msgData16, 0);
+ }
+ break;
+ // --------- [0x40] other control function -----------
+#ifdef __CTM_SUPPORT__
+ case MSG_A2M_CTM_ON:
+ spc_CtmStart(msgData16);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_ON_ACK, msgData16, 0);
+ break;
+ case MSG_A2M_CTM_OFF:
+ spc_CtmStop();
+ //SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_OFF_ACK, msgData16, 0);
+ break;
+ case MSG_A2M_CTM_DUMP_DEBUG_FILE:
+ spc_CtmDebugConfig(msgData16!=0);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_CTM_DUMP_DEBUG_FILE_ACK, msgData16, 0);
+ break;
+#endif // __CTM_SUPPORT__
+
+ case MSG_A2M_BGSND_ON:
+ spc_BgSndStart();
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_ON_ACK, msgData16, 0);
+ break;
+ case MSG_A2M_BGSND_OFF:
+ spc_BgSndStop();
+ // SpcIO_SendMsgToAp( SPCIO_MSG_FROM_SPC_BGSND_OFF_ACK, msgData16, 0);
+ break;
+ case MSG_A2M_BGSND_CONFIG:
+ // msgData16, [15:8] ulGainLevel from 0 ~ 255, [7:0] dlGainLevel from 0 ~ 255
+ // we mapping the value into 0~7 levels. so right shift 5
+ // spc_BgSndConfig((msgData16>>8)>>5, (msgData16&0xff)>>5);
+ spc_BgSndConfig((msgData16>>13), ((msgData16&0xff)>>5));
+ break; // SPCIO_MSG_FROM_SPC_BGSND_CONFIG_ACK-- > MSG_M2A_BGSND_CONFIG_ACK
+ case MSG_A2M_RTT_CONFIG:
+ spc_RttConfig(msgData16);
+ break;
+ case MSG_A2M_PCMMIXER_CONFIG:
+ //bit 0: isDlMix: 0 is replace, 1 is mix
+ //bit 2: isUlMix: 0 is replace, 1 is mix
+ spc_PCMMixerConfig((msgData16&4)==4,(msgData16&1)==1,0,7);
+ break;
+ case MSG_A2M_TELEPHONY_TX_CONFIG:
+ //bit 0: isDlMix: 0 is replace, 1 is mix
+ spc_PCMMixer3Config((msgData16&1)==1,7);
+ break;
+ // --------- [0x50] Recevie DATA notify -----------
+ case MSG_A2M_PNW_DLDATA_NOTIFY:
+ spc_pcmNWay_writeDlDataDone((kal_uint16)msgData32, msgData16, comeFrom);
+ break;
+ case MSG_A2M_BGSND_DATA_NOTIFY:
+ spc_bgSnd_writeDataDone( (kal_uint16)msgData32, msgData16, comeFrom);
+ break;
+ case MSG_A2M_CTM_DATA_NOTIFY: break;
+ case MSG_A2M_DACA_UL_DATA_NOTIFY:
+ spc_daca_writeUlDataDone((kal_uint16)msgData32, msgData16, comeFrom);
+ break;
+ // MSG_A2M_ECALL_MSD,
+ // MSG_A2M_SPC_UL_ENC,
+ // MSG_A2M_SPC_DL_DEC,
+ case MSG_A2M_PCMMIXER_DLDATA_NOTIFY:
+ spc_PCMMixer_writeDlDataDone((kal_uint16)msgData32, msgData16, comeFrom);
+ break;
+ case MSG_A2M_PCMMIXER_ULDATA_NOTIFY:
+ break;
+ case MSG_A2M_TELEPHONY_TX_ULDATA_NOTIFY:
+ spc_PCMMixer3_writeUlDataDone((kal_uint16)msgData32, msgData16, comeFrom);
+ break;
+ // --------- [0x60] Send DATA Ack ---------------
+ case MSG_A2M_PNW_ULDATA_READ_ACK:
+ spc_pcmNWay_sendUlDataDone();
+ break;
+ case MSG_A2M_REC_DATA_READ_ACK: // removed from 93md
+ // spc_record_sendMicDataDone();
+ break;
+#ifdef __CTM_SUPPORT__
+ case MSG_A2M_CTM_DEBUG_DATA_READ_ACK:
+ spc_ctm_sendDumpDebugDataDone();
+ break;
+#endif
+ case MSG_A2M_PCM_REC_DATA_READ_ACK: // removed from 93md
+ // spc_pcmRec_sendMicDataDone();
+ break;
+ case MSG_A2M_VM_REC_DATA_READ_ACK:
+ spc_vmRec_sendMicDataDone();
+ break;
+ case MSG_A2M_DACA_DL_DATA_READ_ACK:
+ spc_daca_sendDlDataDone();
+ break;
+ case MSG_A2M_RAW_PCM_REC_DATA_READ_ACK:
+ spc_RawPcmRec_sendDataDone();
+ break;
+
+ // --------- [0x70] EM related --------------------
+ // case MSG_A2M_EM_INCALL: break;
+ // case MSG_A2M_EM_DMNR: break;
+ // case MSG_A2M_EM_WB: break;
+ // case MSG_A2M_EM_MAGICON: break;
+ case MSG_A2M_NETWORK_STATUS_ACK:
+ break;
+/*
+ case MSG_A2M_QUERY_RF_INFO:
+ // spc_notify_rf_info();
+ break;
+ case MSG_A2M_EM_HAC:
+ break;
+*/
+ case MSG_A2M_DYNAMIC_PAR:
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ type16 = spc_ReceiveDynamicParameter((kal_uint16)msgData32, msgData16, comeFrom);
+#endif
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_ACK, type16, 0 );
+ break;
+ case MSG_A2M_SPH_ENH_CORE:
+ // use for OPEN DSP??
+ break;
+ case MSG_A2M_DYNAMIC_PAR_IN_STRUCT_SHM:
+
+#if defined(_SPE_ENH_MD_PARSE_)
+ type16 = spc_ReceiveDynamicParameter_viaStructShm((kal_uint16)msgData32, msgData16, comeFrom);
+#else // for 95,97
+ spc_ReceiveEMIParInfo(msgData32, msgData16, comeFrom);
+#endif
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_DYNAMIC_PAR_IN_STRUCT_SHM_ACK, type16, 0 );
+ break;
+
+
+ // --------- [0x80] New feature data related --------------------
+ case MSG_A2M_VIBSPK_PARAMETER:
+ spc_ReceiveViberationSpkParameter((kal_uint16)msgData32, msgData16, comeFrom);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_VIBSPK_PARAMETER_ACK, 0, 0 );
+ break;
+
+ case MSG_A2M_NXP_SMARTPA_PARAMETER:
+ spc_ReceiveNxpSmartPaParameter((kal_uint16)msgData32, msgData16, comeFrom);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_NXP_SMARTPA_PARAMETER_ACK, 0, 0 );
+ break;
+
+ // --------- [0x90] New feature data related --------------------
+ case MSG_A2M_NW_CODEC_INFO_READ_ACK:
+ spc_ReceiveNwCodecInfoReadDone();
+ break;
+
+ // --------- [0xA0] Alive related --------------------
+ case MSG_A2M_AUD_ALIVE_READ_ACK:
+ break;
+
+
+ // --------- [0xB0] Telematics feature --------------------
+ case MSG_A2M_IVS_SWITCH:
+#if defined(__ECALL_SUPPORT__)
+ if(msgData16 == 1)
+ {
+ spc_eCall_IVS_Open();
+ }
+ else if(msgData16 == 0)
+ {
+ spc_eCall_IVS_Close();
+ }
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_IVS_SWITCH_ACK, 0, 0);
+#endif
+ break;
+ case MSG_A2M_PSAP_SWITCH:
+#if defined(__ECALL_SUPPORT__)
+ if(msgData16 == 1)
+ {
+ spc_eCall_PSAP_Open();
+ }
+ else if(msgData16 == 0)
+ {
+ spc_eCall_PSAP_Close();
+ }
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_PSAP_SWITCH_ACK, 0, 0);
+#endif
+ break;
+ case MSG_A2M_IVS_SEND:
+#if defined(__ECALL_SUPPORT__)
+ eCall_IVS_SendStart();
+#endif
+ break;
+ case MSG_A2M_PSAP_SEND:
+#if defined(__ECALL_SUPPORT__)
+ eCall_PSAP_SendStart();
+#endif
+ break;
+ case MSG_A2M_ECALL_CTL_SEQ_SWITCH:
+#if defined(__ECALL_SUPPORT__)
+ Set_eCall_Par_Crtl_Switch((kal_uint8)msgData16);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_ECALL_CTL_SEQ_SWITCH_ACK, 0, 0);
+#endif
+ break;
+
+#if defined(__ECALL_SUPPORT__)
+ case MSG_A2M_ECALL_MSD:
+ spc_eCall_Msd_Data((kal_uint16)msgData32, msgData16,comeFrom);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_MSD_DATA_ACK, 0, 0);
+ break;
+#endif
+ case MSG_A2M_ECALL_TX_CTRL_PAR:
+#if defined(__ECALL_SUPPORT__)
+ spc_eCall_TX_CTRL_Data((kal_uint16)msgData32, msgData16,comeFrom);
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_ECALL_TX_CTRL_PAR_ACK, 0, 0);
+#endif
+ break;
+ case MSG_A2M_ECALL_RX_CTRL_PAR:
+#if defined(__ECALL_SUPPORT__)
+#endif
+ break;
+
+ default:
+ if(SPC_MSG_FROM_CCCI == comeFrom)
+ SpcIO_unknownMsgAckToAp(cmd, 0, 0);
+ MD_TRC_SPCIO_INVALID_MSG(SPC_ID_AUDIO_A2M_CCCI, ccciMsg, ccciResv);
+
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// Init Related
+// ----------------------------------------------------------------------------
+
+#ifndef TK6291_FAKE_COMPILE
+extern unsigned short L1D_Audio_ChkDspInitDone();
+#endif //#ifndef TK6291_FAKE_COMPILE
+/**
+ Function owner is EL1.
+ @return: true all rat init done, else is false
+*/
+/*
+#ifndef TK6291_FAKE_COMPILE
+extern kal_bool MML1_RF_CHECK_RF_INIT_STATUS(void);
+#endif //#ifndef TK6291_FAKE_COMPILE
+*/
+
+void Spc_Init_B4_Scheduling(void)
+{
+ // all data inside gSpc are 0 when boot up
+ gSpc.spcGetEpofTimes = 0;
+
+ // ====== Initial needed by other application =======
+ //background sound
+ gSpc_bgSnd.ulGainLevel = 5;
+ gSpc_bgSnd.dlGainLevel = 5;
+}
+
+void Spc_Init(void) {
+
+ /*
+ // for MT6752 MD1, due to RF K needs 1.5 second, please wait for it.
+#if (defined(MT6752) && defined (__MD1__)) || defined(MT6595) || defined(MT6735)
+ #ifndef TK6291_FAKE_COMPILE
+ while( false == MML1_RF_CHECK_RF_INIT_STATUS()) {
+ MD_TRC_SPC_AUDIOTASK_WAIT_EL1_RF_INIT(tick);
+ kal_sleep_task( AUD_1TICK(1) );
+ tick++;
+ }
+ #endif //#ifndef TK6291_FAKE_COMPILE
+#endif
+ */
+ gSpc_acLoopback.isLoopback = 0; // set loopback state = 0
+ // ----------------------
+#if SPC_CUST_ENH
+ // add IDs for DV process
+ DV_dl_audioid = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler(DV_dl_audioid, (L1Audio_EventHandler)DV_DL_process);
+ DV_ul_audioid = L1Audio_GetAudioID();
+ L1Audio_SetEventHandler(DV_ul_audioid, (L1Audio_EventHandler)DV_UL_process);
+#endif
+ #if defined(__ECALL_SUPPORT__)
+ gSpc.eCall_Ctrl_Seq_Switch = 0;
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE);
+ memset(eCall_Msd, 0, 140*sizeof(kal_uint8));
+ #endif
+}
+
+
+kal_bool spc_endApp(void)
+{
+ kal_bool isAppOn=false;
+
+ if(IS_SPC_APP_USED(SPC_APP_PCMNWAY_USAGE)) {
+ spc_PcmNWayStop();
+ isAppOn=true;
+ }
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ if(IS_SPC_APP_USED(SPC_APP_BGSND_USAGE)) {
+ if(EXT_SRC_STATE_RUN == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS) ){
+ // force close without ack
+ spc_BgSndForceClose();
+
+ } else if (EXT_SRC_STATE_FLUSHING == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS)
+ || EXT_SRC_STATE_FLUSHING_OVER == EXT_BGSND_GetStatus(gSpc_bgSnd.id, BGSND_DL_PROCESS)) {
+ // AP has send close request, as the result we need to send ack to AP
+ spc_BgSndClose();
+ } // else is idle
+ isAppOn=true;
+ }
+
+
+ if(IS_SPC_APP_USED(SPC_APP_CTM_USAGE)) {
+#ifdef __CTM_SUPPORT__
+ spc_CtmStop();
+#endif
+ isAppOn=true;
+ }
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ if(IS_SPC_APP_USED(SPC_APP_VM_REC_USAGE)) {
+ spc_VmRecordStop();
+ isAppOn=true;
+ }
+
+ if(IS_SPC_APP_USED(SPC_APP_RAW_PCM_REC_USAGE)) {
+ spc_RawPcmRecordStop();
+ isAppOn=true;
+ }
+
+ return isAppOn;
+}
+void Spc_ForceEndAllApp(void) // AP send ETOF to MD L4C. L4C will send ILM to MED and invoke this function
+{
+ kal_bool is_factory_mode = SpcIO_isFactoryBoot();
+ gSpc.spcGetEpofTimes |= ENUM_EPOF_DO_FORCEENDALLAPP;
+
+ MD_TRC_SPC_EPOF_NOTIFY(gSpc.spcAppUsage);
+
+ SP_DSPTone_ForceEnd();
+
+ spc_endApp();
+
+ // main app
+ if(IS_SPC_APP_USED(SPC_APP_SPEECH_USAGE)) {
+ // Spc_SpeechOff();
+ Spc_SpeechOff_Merge();
+ }
+
+ if(IS_SPC_APP_USED(SPC_APP_PCMROUTER_USAGE)) {
+ Spc_SpeechRouterOn(false);
+ }
+#if defined( __SMART_PHONE_MODEM__ )
+ if(is_factory_mode != true)
+ {
+ SpcIO_SendMsgToAp(SPCIO_MSG_FROM_SPC_EPOF_NOTIFY, (kal_uint16)0, 0);
+ MD_TRC_SPC_EPOF_SPC_FORCEENDALLAPP_NOTIFY_AP();
+ }
+#endif //#if defined( __SMART_PHONE_MODEM__ )
+ if(is_factory_mode == true)
+ {
+ //Notify L4C: speech driver enter EPOF done
+ msg_send6(MOD_MED, MOD_L4C, AUDIO_SAP, MSG_ID_AUDIO_L4C_EPOF_ACK, (local_para_struct *)NULL, NULL);
+ kal_prompt_trace(MOD_L1SP, "[EPOF]Spc_ForceEndAllApp notify L4C done at factory mode");
+ }
+
+}
+
+#if defined(_SPE_ENH_MD_PARSE_)
+
+spcDynParNBData NBParData;
+spcDynParNBData_V10 NBParData_v10; //need remove later
+spcDynParWBData WBParData;
+spcDynParSWBData SWBParData;
+spcDynParNBIIRData NBIIRParData;
+spcDynParWBIIRData WBIIRParData;
+spcDynParSWBIIRData SWBIIRParData;
+
+kal_uint16 spc_dynamicParameterParser_volInUnit(AUD_SPC_DYNAMIC_PARAM_MAGICNUM_T unit,
+ const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen)
+{
+ kal_uint16 curOffset;
+ kal_uint16 Data_Header;
+
+ kal_uint16 tempProclen = 0;
+
+ MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(unit, length, comeFrom);
+
+ kal_prompt_trace(MOD_L1SP, "where am I? %x", offset);
+ curOffset = SpcIo_GetDataFromAp(offset, sizeof(Data_Header), &Data_Header, comeFrom);
+ tempProclen += sizeof(Data_Header);
+
+ kal_prompt_trace(MOD_L1SP, "where am I?? %x", curOffset);
+
+ if((Data_Header&0x0F) == 0xF)
+ {
+ switch(unit) {
+ case Vol_in_general_unit:
+ {
+ spcCommonData *CommonParData;
+ uint16 *m_para; // debug print
+
+ CommonParData = (spcCommonData *)emDataBuf;
+ // reuse the emDataBuf to get data
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcCommonData), CommonParData, comeFrom);
+ tempProclen += sizeof(spcCommonData);
+
+ L1SP_LoadCommonSpeechPara(CommonParData->Common_Para);
+
+ // debug Print
+ m_para = CommonParData->Common_Para; // size NUM_COMMON_PARAS
+ 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]);
+
+ L1Audio_SetDebugInfo(CommonParData->Debug_info_para);
+ VMREC_ConfigEpl();
+ spc_dev_LoopbackPoint_DVT(CommonParData->Debug_info_para[15]);
+
+ // debug Print
+ m_para = CommonParData->Debug_info_para;
+ 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]);
+
+ SET_SPC_EM_INIT(SPC_EM_INIT_COMMON);
+ }
+ break;
+ case Vol_in_MagiClarity:
+ {
+ spcMagiClarityData *MagiClarityData;
+ MagiClarityData = (spcMagiClarityData *)emDataBuf;
+
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcMagiClarityData), MagiClarityData, comeFrom);
+ tempProclen += sizeof(spcMagiClarityData);
+
+ // L1SP_MagiClarityData(MagiClarityData->MagiClarity_Para);
+
+ }
+ break;
+ case Vol_in_echoRefforUsbAudio:
+ {
+ spcDynParEchoRefForUsbAudio_T *usbAudioParam;
+ usbAudioParam = (spcDynParEchoRefForUsbAudio_T *)(&emDataBuf); //buffer reuse
+
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParEchoRefForUsbAudio_T), usbAudioParam, comeFrom);
+ tempProclen += sizeof(spcDynParEchoRefForUsbAudio_T);
+
+ // [remove]
+ // SPE_SetEchoRefInfo(usbAudioParam->isEchoRefForUsbAudioOn, usbAudioParam->mic_index, usbAudioParam->chip_delay_with_switch, SPH_MODE_USB);
+ }
+ break;
+ default:
+ break;
+ }
+
+
+ }
+ else
+ {
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,unit,0);
+ ASSERT(0); // Not support the Header
+ }
+
+ *procLen = tempProclen;
+ return curOffset;
+
+}
+
+kal_uint16 spc_dynamicParameterParser_dmnrUnit(spcDynParHeader *Header,
+ const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen)
+{
+ kal_uint16 DynamicParCount;
+ kal_uint16 i;
+ kal_uint16 Data_Header;
+ kal_uint16 curOffset = offset;
+ kal_uint16 tempProclen = 0;
+
+ int16 *m_para; // debug print
+
+ // kal_trace( TRACE_FUNC,SPC_SPE_RECEIVEDYNAMICPARAMETER4);
+ MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(Vol_in_DMNR, length, comeFrom);
+ DynamicParCount = (((Header->NumEachLayer)&0xF0)>>4) * ((Header->NumEachLayer)&0x0F);
+
+
+ for(i=0;i<DynamicParCount;i++)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom);
+ tempProclen += sizeof(Data_Header);
+ MD_TRC_SPC_SPE_DMNR_HEADER(Data_Header);
+ if(Data_Header==Header_DMNR_NB_REC)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_NB_REC), &DMNR_NB_REC, comeFrom);
+ tempProclen += sizeof(DMNR_NB_REC);
+ L1SP_SetDMNRPara(DMNR_NB_REC);
+ SET_SPC_EM_INIT(SPC_EM_INIT_DMNR);
+
+ m_para = DMNR_NB_REC;
+ 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]);
+ m_para = &(DMNR_NB_REC[16]);
+ 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]);
+ m_para = &(DMNR_NB_REC[32]);
+ 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);
+
+ }
+ else if(Data_Header == Header_DMNR_WB_REC)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_WB_REC), &DMNR_WB_REC, comeFrom);
+ tempProclen += sizeof(DMNR_WB_REC);
+ L1SP_SetWbDMNRPara(DMNR_WB_REC);
+ SET_SPC_EM_INIT(SPC_EM_INIT_DMNR);
+
+ m_para = DMNR_WB_REC;
+ 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]);
+ m_para = &(DMNR_WB_REC[16]);
+ 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]);
+ m_para = &(DMNR_WB_REC[32]);
+ 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]);
+ m_para = &(DMNR_WB_REC[48]);
+ 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]);
+ m_para = &(DMNR_WB_REC[64]);
+ 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);
+ }
+ else if(Data_Header == Header_DMNR_NB_LSP)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_NB_LoudSpk), &DMNR_NB_LoudSpk, comeFrom);
+ tempProclen += sizeof(DMNR_NB_LoudSpk);
+ L1SP_SetLSpkDMNRPara(DMNR_NB_LoudSpk);
+ SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR);
+
+ m_para = DMNR_NB_LoudSpk;
+ 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]);
+ m_para = &(DMNR_NB_LoudSpk[16]);
+ 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]);
+ m_para = &(DMNR_NB_LoudSpk[32]);
+ 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);
+
+ }
+
+ else if(Data_Header == Header_DMNR_WB_LSP)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_WB_LoudSpk), &DMNR_WB_LoudSpk, comeFrom);
+ tempProclen += sizeof(DMNR_WB_LoudSpk);
+ L1SP_SetLSpkWbDMNRPara(DMNR_WB_LoudSpk);
+ SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR);
+
+ m_para = DMNR_WB_LoudSpk;
+ 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]);
+ m_para = &(DMNR_WB_LoudSpk[16]);
+ 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]);
+ m_para = &(DMNR_WB_LoudSpk[32]);
+ 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]);
+ m_para = &(DMNR_WB_LoudSpk[48]);
+ 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]);
+ m_para = &(DMNR_WB_LoudSpk[64]);
+ 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);
+ }
+ else if((Data_Header == Header_DMNR_SWB_REC) )
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_SWB_REC), &DMNR_SWB_REC, comeFrom);
+ tempProclen += sizeof(DMNR_SWB_REC);
+ L1SP_SetSWbDMNRPara(DMNR_SWB_REC);
+ SET_SPC_EM_INIT(SPC_EM_INIT_DMNR);
+ m_para = DMNR_SWB_REC;
+ 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]);
+ m_para = &(DMNR_SWB_REC[16]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[32]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[48]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[64]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[80]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[96]);
+ 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]);
+ m_para = &(DMNR_SWB_REC[112]);
+ 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);
+ }
+ else if((Data_Header == Header_DMNR_SWB_LSP) )
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(DMNR_SWB_LoudSpk), &DMNR_SWB_LoudSpk, comeFrom);
+ tempProclen += sizeof(DMNR_SWB_LoudSpk);
+ L1SP_SetLSpkSWbDMNRPara(DMNR_SWB_LoudSpk);
+ SET_SPC_EM_INIT(SPC_EM_INIT_LSPK_DMNR);
+ m_para = DMNR_SWB_LoudSpk;
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[16]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[32]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[48]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[64]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[80]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[96]);
+ 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]);
+ m_para = &(DMNR_SWB_LoudSpk[112]);
+ 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);
+ }
+ else
+ {
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,Vol_in_DMNR,0);
+ ASSERT(0);//not support the dataheader
+ }
+ // SetSpeechEnhancement(false);
+ // SetSpeechEnhancement(true);
+ }
+
+
+ *procLen = tempProclen;
+ return curOffset;
+}
+
+
+kal_uint16 spc_dynamicParameterParser_volDeUnit_ver10(kal_uint16 DynamicParCount,
+ const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen)
+{
+ kal_uint16 Data_Header;
+ kal_uint16 tempProclen = 0;
+ kal_uint16 curOffset = offset;
+
+ kal_uint16 i,Network,k;
+
+ for(i = 0 ; i < DynamicParCount ; i ++)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom);
+ tempProclen += sizeof(Data_Header);
+
+ if(((Data_Header&0xF000)>>8)==NB_Par)
+ {
+
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData_V10), &NBParData_v10, comeFrom);
+ tempProclen += sizeof(spcDynParNBData_V10);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if((Network>>12)==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_NB_Mode_para[k], NBParData_v10.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData_v10.speech_NB_FIR_IN_para, 45*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData_v10.speech_NB_FIR_OUT_para, 45*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_NB_Mode_para[k], NBParData_v10.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData_v10.speech_NB_FIR_IN_para, 45*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData_v10.speech_NB_FIR_OUT_para, 45*sizeof(uint16)) ;
+ }
+ }
+ }
+
+ SET_SPC_EM_INIT(SPC_EM_INIT_NB);
+ }
+ else if((((Data_Header&0xF000)>>8)==WB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom);
+ tempProclen += sizeof(spcDynParWBData);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if((Network>>12)==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_WB);
+ }
+ else if((((Data_Header&0xF000)>>8)==SWB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom);
+ tempProclen += sizeof(spcDynParSWBData);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if((Network>>12)==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_SWB);
+ }
+ else
+ {
+ //Not suppot bandover
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0);
+ ASSERT(0);
+ }
+ }
+
+ *procLen = tempProclen;
+ return curOffset;
+}
+
+kal_uint16 spc_dynamicParameterParser_volDeUnit_ver20(kal_uint16 DynamicParCount,
+ const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen)
+{
+ kal_uint16 Data_Header;
+ kal_uint16 tempProclen = 0;
+ kal_uint16 curOffset = offset;
+
+ kal_uint16 i,Network,k;
+
+ for(i = 0 ; i < DynamicParCount ; i ++)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom);
+ tempProclen += sizeof(Data_Header);
+
+ if(((Data_Header&0xF000)>>8)==NB_Par)
+ {
+
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData), &NBParData, comeFrom);
+ tempProclen += sizeof(spcDynParNBData);
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBIIRData), &NBIIRParData, comeFrom);
+ tempProclen += sizeof(spcDynParNBIIRData);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if(Network==0x0FFF) // all network use same par.
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_IIR_IN_para[k], NBIIRParData.speech_NB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_IIR_OUT_para[k], NBIIRParData.speech_NB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_MIC1_IIR_para[k], NBIIRParData.speech_NB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_MIC2_IIR_para[k], NBIIRParData.speech_NB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_IIR_IN_para[k], NBIIRParData.speech_NB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_IIR_OUT_para[k], NBIIRParData.speech_NB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_MIC1_IIR_para[k], NBIIRParData.speech_NB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_NB_MIC2_IIR_para[k], NBIIRParData.speech_NB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ }
+
+ SET_SPC_EM_INIT(SPC_EM_INIT_NB);
+ }
+ else if((((Data_Header&0xF000)>>8)==WB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom);
+ tempProclen += sizeof(spcDynParWBData);
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBIIRData), &WBIIRParData, comeFrom);
+ tempProclen += sizeof(spcDynParWBIIRData);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if(Network==0x0FFF) // all network use same par.
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_IIR_IN_para[k], WBIIRParData.speech_WB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_IIR_OUT_para[k], WBIIRParData.speech_WB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_MIC1_IIR_para[k], WBIIRParData.speech_WB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_MIC2_IIR_para[k], WBIIRParData.speech_WB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_IIR_IN_para[k], WBIIRParData.speech_WB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_IIR_OUT_para[k], WBIIRParData.speech_WB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_MIC1_IIR_para[k], WBIIRParData.speech_WB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_WB_MIC2_IIR_para[k], WBIIRParData.speech_WB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_WB);
+ }
+ else if((((Data_Header&0xF000)>>8)==SWB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom);
+ tempProclen += sizeof(spcDynParSWBData);
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBIIRData), &SWBIIRParData, comeFrom);
+ tempProclen += sizeof(spcDynParSWBIIRData);
+
+ Network = (Data_Header&0x0FFF); // [bit0~bit11] bit0:GSM bit1:WCDMA bit2:CDMA bit3:VOLTE bit4:C2K
+ MD_TRC_SPC_SPE_CHECK_SPEECH_PAR_HEADER_FORMAT(Data_Header,Network);
+ if(Network==0x0FFF) // all network use same par.
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_IIR_IN_para[k], SWBIIRParData.speech_SWB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_IIR_OUT_para[k], SWBIIRParData.speech_SWB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_MIC1_IIR_para[k], SWBIIRParData.speech_SWB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_MIC2_IIR_para[k], SWBIIRParData.speech_SWB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ else
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ if(((Network>>k)&0x1))
+ {
+ memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_IIR_IN_para[k], SWBIIRParData.speech_SWB_IIR_IN_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_IIR_OUT_para[k], SWBIIRParData.speech_SWB_IIR_OUT_para, NUM_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_MIC1_IIR_para[k], SWBIIRParData.speech_SWB_MIC1_IIR_para, NUM_MIC1_IIR_COEFFS*sizeof(uint16));
+ memcpy(Temp_speech_SWB_MIC2_IIR_para[k], SWBIIRParData.speech_SWB_MIC2_IIR_para, NUM_MIC2_IIR_COEFFS*sizeof(uint16));
+ }
+ }
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_SWB);
+ }
+ else
+ {
+ //Not suppot bandover
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0);
+ ASSERT(0);
+ }
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_IIR);
+ *procLen = tempProclen;
+ return curOffset;
+}
+
+kal_uint16 spc_dynamicParameterParser_volDeUnit_ver00(kal_uint16 DynamicParCount,
+ const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen)
+{
+ kal_uint16 Data_Header;
+ kal_uint16 tempProclen = 0;
+ kal_uint16 curOffset = offset;
+
+ kal_uint16 i,Network,k;
+
+ for(i = 0 ; i < DynamicParCount ; i ++)
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(Data_Header), &Data_Header, comeFrom);
+ tempProclen = tempProclen + sizeof(Data_Header);
+
+ if(((Data_Header&0xF0)==NB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParNBData), &NBParData, comeFrom);
+ tempProclen = tempProclen + sizeof(spcDynParNBData);
+
+ Network = (Data_Header&0x0F);
+ if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK)
+ {
+ memcpy(Temp_speech_NB_Mode_para[Network-1], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[Network-1], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[Network-1], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ else if(Network==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_NB_Mode_para[k], NBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_IN_para[k], NBParData.speech_NB_FIR_IN_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_NB_FIR_OUT_para[k], NBParData.speech_NB_FIR_OUT_para, NUM_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ // not support the network info
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0);
+ ASSERT(0);
+
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_NB);
+ }
+ else if(((Data_Header&0xF0)==WB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParWBData), &WBParData, comeFrom);
+ tempProclen = tempProclen + sizeof(spcDynParWBData);
+
+ Network = (Data_Header&0x0F);
+ if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK)
+ {
+ memcpy(Temp_speech_WB_Mode_para[Network-1], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[Network-1], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[Network-1], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ else if(Network==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_WB_Mode_para[k], WBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_IN_para[k], WBParData.speech_WB_FIR_IN_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_WB_FIR_OUT_para[k], WBParData.speech_WB_FIR_OUT_para, NUM_WB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ // not support the network info
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0);
+ ASSERT(0);
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_WB);
+ }
+ else if(((Data_Header&0xF0)==SWB_Par))
+ {
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spcDynParSWBData), &SWBParData, comeFrom);
+ tempProclen = tempProclen + sizeof(spcDynParSWBData);
+
+ Network = (Data_Header&0x0F);
+ if(Network == GSM_NETWORK||Network == WCDMA_NETWORK||Network == CDMA_NETWORK||Network == VOLTE_NETWORK||Network == C2K_NETWORK)
+ {
+ memcpy(Temp_speech_SWB_Mode_para[Network-1], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[Network-1], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[Network-1], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ else if(Network==DONT_CARE_NETWORK)
+ {
+ for(k = 0; k < TOTAL_NETWORK_NUMBER; k++)
+ {
+ memcpy(Temp_speech_SWB_Mode_para[k], SWBParData.speech_Mode_para, NUM_MODE_PARAS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_IN_para[k], SWBParData.speech_SWB_FIR_IN_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ memcpy(Temp_speech_SWB_FIR_OUT_para[k], SWBParData.speech_SWB_FIR_OUT_para, NUM_SWB_FIR_COEFFS*sizeof(uint16)) ;
+ }
+ }
+ else
+ {
+ // not support the network info
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Network,0,0);
+ ASSERT(0);
+ }
+ SET_SPC_EM_INIT(SPC_EM_INIT_SWB);
+ }
+ else
+ {
+ //Not suppot bandover
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Data_Header,0,0);
+ ASSERT(0);
+ }
+ }
+
+ *procLen = tempProclen;
+ return curOffset;
+}
+
+
+
+/**
+ @return: magic
+ @procLen: [OUTPUT] process length
+*/
+
+uint16 spc_dynamicParameterParser_dispatcher(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom,
+ kal_uint16 *procLen, kal_uint16 *newOffset)
+{
+ spcDynParHeader Header;
+ kal_uint16 curOffset;
+ uint16 unProcLen = length;
+
+ memset(&Header, 0, sizeof(spcDynParHeader));
+ curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcDynParHeader), &Header, comeFrom);
+ unProcLen = unProcLen - sizeof(spcDynParHeader);
+
+ kal_prompt_trace(MOD_L1SP, "where am I dispatcher: %x, %x, %x, %d", offset, curOffset, length, comeFrom);
+
+
+ switch(Header.SphUnitMagiNum){
+ case 0:
+ {
+ // when curOffset == offset, it also means cannot get data from AP param_shm
+ // cannot get data from AP
+ unProcLen = 0;
+
+ }
+ break;
+ case Vol_de_speech_unit:
+ {
+ kal_uint16 DynamicParCount = 0; //initialize
+ kal_uint16 SpeechIndex; // bit1: Volume index, bit0: Mode
+ // kal_uint16 Data_Header;
+ kal_uint16 Mode;
+ kal_uint16 count;
+
+ //Param_Header_Layer1; Network
+ //Param_Header_Layer2; VoiceBand
+ // kal_trace( TRACE_FUNC,SPC_SPE_RECEIVEDYNAMICPARAMETER1);
+ MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER(Vol_de_speech_unit, length, comeFrom);
+ if(Header.NumLayer == 0x2)
+ {
+ DynamicParCount = (((Header.NumEachLayer)&0x00F0)>>4) * ((Header.NumEachLayer)&0x000F);
+ }
+ else if(Header.NumLayer == 0x1)
+ {
+ DynamicParCount = ((Header.NumEachLayer)&0x000F);
+ }
+ else
+ {
+ //Not suppot over 2 Layer
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Header.NumLayer,0,0);
+ ASSERT(0);
+ }
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(SpeechIndex), &SpeechIndex, comeFrom);
+ unProcLen = unProcLen - sizeof(SpeechIndex);
+
+ Mode = (SpeechIndex&0x0F);
+ SpeechIndex = (((SpeechIndex)&0xF0)>>4);
+ MD_TRC_SPC_SPE_RECEIVEDYNAMICPARAMETER2(Mode,SpeechIndex,Header.Param_Header_Layer3);
+
+ if(Header.Param_Header_Layer3== 0x10) // Version 1.0.
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volDeUnit_ver10(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+ }
+ else if(Header.Param_Header_Layer3== 0x20) // Version 2.0.
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volDeUnit_ver20(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+
+ }
+ else //Version 0.0
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volDeUnit_ver00(DynamicParCount, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+ }
+ l1sp_setAllSpeechModePara((kal_uint16 *) Temp_speech_NB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ l1sp_setAllSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_NB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_FIR_COEFFS);
+ l1sp_setAllSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_NB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_FIR_COEFFS);
+ l1sp_setAllWbSpeechModePara((kal_uint16 *)Temp_speech_WB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ l1sp_setAllWbSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_WB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_WB_FIR_COEFFS);
+ l1sp_setAllWbSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_WB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_WB_FIR_COEFFS);
+ l1sp_setAllSWbSpeechModePara((kal_uint16 *)Temp_speech_SWB_Mode_para, TOTAL_NETWORK_NUMBER * NUM_MODE_PARAS);
+ l1sp_setAllSWbSpeechFirCoeff_InputOnly((kal_int16 *)Temp_speech_SWB_FIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_SWB_FIR_COEFFS);
+ l1sp_setAllSWbSpeechFirCoeff_OutputOnly((kal_int16 *)Temp_speech_SWB_FIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_SWB_FIR_COEFFS);
+
+ for(count=0;count<TOTAL_NETWORK_NUMBER;count++)
+ {
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ }
+
+ if(Header.Param_Header_Layer3== 0x20) // Version 2.0.
+ {
+ l1sp_setAllSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_NB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_NB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllSpeechMic1IirCoeff((kal_int16 *)Temp_speech_NB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS);
+ l1sp_setAllSpeechMic2IirCoeff((kal_int16 *)Temp_speech_NB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS);
+ l1sp_setAllWBSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_WB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllWBSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_WB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllWBSpeechMic1IirCoeff((kal_int16 *)Temp_speech_WB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS);
+ l1sp_setAllWBSpeechMic2IirCoeff((kal_int16 *)Temp_speech_WB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS);
+ l1sp_setAllSWBSpeechIirCoeff_InputOnly((kal_int16 *)Temp_speech_SWB_IIR_IN_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllSWBSpeechIirCoeff_OutputOnly((kal_int16 *)Temp_speech_SWB_IIR_OUT_para, TOTAL_NETWORK_NUMBER * NUM_IIR_COEFFS);
+ l1sp_setAllSWBSpeechMic1IirCoeff((kal_int16 *)Temp_speech_SWB_MIC1_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC1_IIR_COEFFS);
+ l1sp_setAllSWBSpeechMic2IirCoeff((kal_int16 *)Temp_speech_SWB_MIC2_IIR_para, TOTAL_NETWORK_NUMBER * NUM_MIC2_IIR_COEFFS);
+ // l1sp_set par
+ for(count=0;count<TOTAL_NETWORK_NUMBER;count++)
+ {
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+ 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]);
+
+ }
+
+ }
+
+#if defined(__SPEECH_WW_OPERATOR_SCORE_ENHANCE__)
+ spe_setMagiCon();
+ if(Mode!=0xF)
+ {
+ if(Mode == SPH_MODE_HAC)
+ {
+ spe_setHacModeNeeded(true);
+ }
+ else if(Mode == SPH_MODE_AUX1) //Magi con
+ {
+ Mode = SPH_MODE_LOUDSPK;
+ }
+ // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) Mode );
+ L1SP_SetSpeechEnhanceAndFir(Mode, SPH_ENH_AND_FIR_UPDATE_TYPE_ALL);
+ }
+ else
+ {
+
+ SetSpeechEnhancement(true);
+
+ }
+
+#else
+ spe_DisableMagiCon();
+ if(Mode!=0xF)
+ {
+
+ if(Mode == SPH_MODE_HAC)
+ {
+ spe_setHacModeNeeded(true);
+ }
+ else if(Mode == SPH_MODE_EARPHONE)
+ {
+ spe_setMagiCon();
+ }
+ else if(Mode == SPH_MODE_AUX1) //Magi con
+ {
+ Mode = SPH_MODE_LOUDSPK;
+ spe_setMagiCon();
+
+ }
+ // Spc_SetSpeechEnhMode_Adaptation( (kal_uint8) Mode );
+ L1SP_SetSpeechEnhanceAndFir(Mode, SPH_ENH_AND_FIR_UPDATE_TYPE_ALL);
+ }
+ else
+ {
+
+ SetSpeechEnhancement(true);
+
+ }
+#endif
+ }
+
+ break;
+
+ case Vol_in_general_unit:
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_general_unit, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+ SetSpeechEnhancement(false);
+ SetSpeechEnhancement(true);
+ }
+ break;
+
+ case Vol_in_DMNR:
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_dmnrUnit(&Header, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+
+ SetSpeechEnhancement(false);
+ SetSpeechEnhancement(true);
+ }
+ break;
+ case Vol_in_MagiClarity:
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_MagiClarity, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+ }
+ break;
+ case Vol_in_echoRefforUsbAudio:
+ {
+ kal_uint16 procLen=0;
+ curOffset = spc_dynamicParameterParser_volInUnit(Vol_in_echoRefforUsbAudio, curOffset, unProcLen, comeFrom, &procLen);
+ unProcLen = unProcLen - procLen;
+ }
+ break;
+ default:
+
+ MD_TRC_SPC_SPE_ASSERT_CHECK(Header.SphUnitMagiNum,0,0);
+ ASSERT(0); //NOT SUPPORT THE MAGIC NUM
+ break;
+ }
+
+ kal_prompt_trace(MOD_L1SP, "unProclen=%d with SphUnitMagiNum=%x", unProcLen, Header.SphUnitMagiNum);
+
+ if(NULL!=newOffset) {
+ *newOffset = curOffset;
+ }
+ if(NULL!=procLen) {
+ *procLen = (length - unProcLen);
+ }
+ return Header.SphUnitMagiNum;
+
+}
+
+uint16 spc_ReceiveDynamicParameter(const kal_uint16 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom)
+{
+ kal_uint16 curOffset;
+
+
+ // Header Check
+ spcBufInfo info;
+ curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom);
+
+
+ ASSERT(info.syncWord == 0xA2A2);
+ ASSERT((info.type) == AUD_CCCI_STRMBUF_TYPE_DYNAMCI_PAR_TYPE); //just use the bit[0:3] to inidicate the type.
+ ASSERT(info.length == (length-6));
+
+ return spc_dynamicParameterParser_dispatcher(curOffset, length-sizeof(spcBufInfo), comeFrom, NULL, NULL);
+}
+#endif
+
+
+kal_uint16 get_spcGetEpofTimes(enum_EPOF_event EPOF_event)
+{
+ return( (gSpc.spcGetEpofTimes) & EPOF_event );
+}
+
+void set_spcGetEpofTimes(enum_EPOF_event EPOF_event, int on)
+{
+ if(on)
+ gSpc.spcGetEpofTimes |= EPOF_event;
+ else
+ gSpc.spcGetEpofTimes &= (~EPOF_event);
+}
+
+
+// ============================================================================
+#define ILM_SPC_CUST_DUMP_BUF_LEN 2560
+typedef struct{
+ LOCAL_PARA_HDR
+ //raw information from eMAC
+ uint16 dumpLen;
+ uint16 dumpBuf[ILM_SPC_CUST_DUMP_BUF_LEN];
+}ilm_spc_cust_dump_t;
+
+void spc_customDump(uint16 bufLen, uint16 *dumpBuf)
+{
+
+ ilm_spc_cust_dump_t *ilm;
+ uint16 len = bufLen;
+ uint16 idx = 0;
+
+ // static int32 i=0;
+
+ if ( 0 == bufLen)
+ return;
+
+ while(len > ILM_SPC_CUST_DUMP_BUF_LEN) {
+ ilm = (ilm_spc_cust_dump_t *)construct_local_para( sizeof(ilm_spc_cust_dump_t), TD_CTRL);
+ ilm->dumpLen = ILM_SPC_CUST_DUMP_BUF_LEN;
+ memcpy((ilm->dumpBuf), &(dumpBuf[idx]), sizeof(uint16)*ILM_SPC_CUST_DUMP_BUF_LEN);
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_CUST_DUMP_REQ, (local_para_struct *)ilm, NULL);
+
+ idx = idx + ILM_SPC_CUST_DUMP_BUF_LEN;
+ len = len - ILM_SPC_CUST_DUMP_BUF_LEN;
+
+ // i++;
+ }
+
+
+ ilm = (ilm_spc_cust_dump_t *)construct_local_para( sizeof(ilm_spc_cust_dump_t), TD_CTRL);
+ ilm->dumpLen = len;
+ memcpy((ilm->dumpBuf), &(dumpBuf[idx]), sizeof(uint16)*len);
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_CUST_DUMP_REQ, (local_para_struct *)ilm, NULL);
+
+ // i++;
+
+ // kal_prompt_trace(MOD_L1SP, "spc_customDump' i=%d", i);
+}
+
+void spc_sendCustomDump(void *ilm)
+{
+ uint16 bufLen;
+ uint16 *dumpBuf;
+ uint16 lenInByte;
+ spcBufInfo info;
+ bool sendResult = true;
+
+ // static int32 j=0;
+
+ bufLen = ((ilm_spc_cust_dump_t *)(ilm))->dumpLen;
+ dumpBuf = ((ilm_spc_cust_dump_t *)(ilm))->dumpBuf;
+
+ if(NULL == dumpBuf || 0 == bufLen)
+ return;
+
+ lenInByte = (bufLen <<1);
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_STRMBUF_TYPE_CUST_DUMP;
+ info.length = lenInByte;
+
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo),
+ (void *)(dumpBuf), lenInByte, NULL, 0,
+ SPCIO_MSG_FROM_SPC_CUST_DUMP_NOTIFY);
+
+ if(false == sendResult) {
+ // leave log here
+ MD_TRC_SPC_CUST_DUMP_DROP();
+ }
+
+}
+
+// Remind: DebugInfo[15] also control this. loopback point
+void spc_dev_LoopbackPoint_DVT(kal_uint16 point){
+ switch(point){
+
+ case 0:
+ AFE_SetConn0(0x54321076); //default value, case 0 : reset
+ break;
+ case 1:
+ AFE_SetConn0(0x54321010); // O17, O18
+ break;
+ case 2:
+ AFE_SetConn0(0x54321032); // O23, O24
+ break;
+ case 3:
+ AFE_SetConn0(0x54321054); // O25
+ break;
+ case 4:
+ AFE_SetConn0(0x54321045); // O25_swap
+ break;
+ case 5:
+ AFE_SetConn0(0x54327676); // DL -> UL
+ break;
+ default:
+ kal_prompt_trace(MOD_L1SP, "[LPBK_DVT] invalid value, set 0x54321076");
+ AFE_SetConn0(0x54321076);
+ }
+}
+
+#if defined(__ECALL_SUPPORT__)
+void spc_eCall_SDT_Open(void)
+{
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY);
+ eCall_IVS_Open(aud_ecall_event_callback);
+ eCall_IVS_PutMSD(eCall_Msd,140,0); // DEFAULT PAR
+}
+
+void spc_eCall_SDT_Close(void)
+{
+ eCall_IVS_Close();
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE);
+}
+
+void spc_eCall_IVS_Open(void)
+{
+ eCall_IVS_Close();
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_ENABLE);
+ eCall_IVS_Open(aud_ecall_event_callback);
+ eCall_IVS_PutMSD(eCall_Msd,140,0);
+}
+
+void spc_eCall_IVS_Close(void)
+{
+ eCall_IVS_Close();
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY);
+ eCall_IVS_Open(aud_ecall_event_callback);
+}
+
+void spc_eCall_PSAP_Open(void)
+{
+ eCall_IVS_Close();
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_DISABLE); // Set ivs ststus=disable
+ eCall_PSAP_Open(aud_ecall_event_callback);
+}
+
+void spc_eCall_PSAP_Close(void)
+{
+ eCall_PSAP_Close();
+ spc_Set_Ecall_Lib_Status(SPC_ECALL_SDT_ONLY);// Set ivs ststus=SDT detect
+ eCall_IVS_Open(aud_ecall_event_callback);
+}
+
+void spc_eCall_Msd_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ kal_uint16 curOffSet;
+
+ curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info,comeFrom);
+
+ ASSERT(info.syncWord == 0xA2A2);
+ ASSERT(info.type == AUD_CCCI_ECALL_MSD_TYPE);
+
+ //ASSERT(info.length == (length - sizeof(spcBufInfo)));
+ SpcIo_GetDataFromAp(curOffSet, 140, eCall_Msd,comeFrom);
+ eCall_IVS_PutMSD(eCall_Msd,140,1);
+
+
+}
+
+void spc_eCall_TX_CTRL_Data(kal_uint16 offset, kal_int16 length,SPC_MSG_FROM_T comeFrom)
+{
+ spcBufInfo info;
+ kal_uint16 curOffSet;
+ uint32 i;
+ Int16 eCall_TX_Temp[800];
+
+
+ if(gSpc.eCall_Ctrl_Seq_Switch == 0)
+ {
+ return;
+ }
+
+
+ curOffSet = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &info, comeFrom);
+ ASSERT(info.syncWord == 0xA2A2);
+ ASSERT(info.type == AUD_CCCI_ECALL_MSD_TYPE);
+ //ASSERT(info.length == (length - sizeof(spcBufInfo)));
+ memset(eCall_TX_Temp, 0, 800*sizeof(short));
+ curOffSet = SpcIo_GetDataFromAp(curOffSet, 1600, &eCall_TX_Temp, comeFrom);
+
+ MD_TRC_SPC_ECALL_CHECK_TX_CTRL_HEADER(eCall_TX_Temp[0]);
+ if(eCall_TX_Temp[0] == 0xAA)
+ {
+ memset(eCall_TX_CTRL_SEQ_State, 0, 800*sizeof(int16));
+ memcpy(eCall_TX_CTRL_SEQ_State, eCall_TX_Temp, 800*sizeof(int16));
+
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+ else if(eCall_TX_Temp[0] == 0xBB)
+ {
+ memset(eCall_TX_CTRL_SEQ_dlData, 0, 800*sizeof(int16));
+ memcpy(eCall_TX_CTRL_SEQ_dlData, eCall_TX_Temp, 800*sizeof(int16));
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+ else if(eCall_TX_Temp[0] == 0xCC)
+ {
+ memset(eCall_TX_CTRL_SEQ_dlMetric, 0, 800*sizeof(short));
+ memcpy(eCall_TX_CTRL_SEQ_dlMetric, eCall_TX_Temp, 800*sizeof(int16));
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+
+
+}
+
+void Set_eCall_Par_Crtl_Switch(kal_uint8 Switch)
+{
+
+ gSpc.eCall_Ctrl_Seq_Switch = Switch;
+ MD_TRC_ECALL_IVS_SEND_PAR_CTRL_SWITCH(gSpc.eCall_Ctrl_Seq_Switch);
+}
+
+void spc_eCall_RX_CTRL_Data(uint16 header)
+{
+
+ spcBufInfo info;
+ bool sendResult = true;
+ info.syncWord = 0x2A2A;
+ info.type = AUD_CCCI_ECALL_MSD_TYPE;
+ info.length = 1600;
+ uint32 i;
+
+ if(gSpc.eCall_Ctrl_Seq_Switch == 0)
+ {
+ return;
+ }
+
+ if(header == 0xDD )
+ {
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_State, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY);
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+ else if(header == 0xEE)
+ {
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_dlData, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY);
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+ else if (header == 0xFF)
+ {
+ sendResult = SpcIO_WriteDataToAp(&info, sizeof(spcBufInfo), eCall_RX_CTRL_SEQ_dlMetric, info.length, NULL, 0,SPCIO_MSG_FROM_SPC_ECALL_RX_CTRL_PAR_NOTIFY);
+ for(i=0;i<30;i++)
+ {
+ 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]);
+ }
+ }
+
+ if(sendResult == false) {
+ MD_TRC_SPC_SEND_DATA_TO_AP_FAIL();
+ }
+}
+
+void spc_eCall_Handshake_Info_Notify (uint16 header,uint32 data)
+{
+ MD_TRC_ECALL_IVS_ECALL_HANDSHAKE_INFO_NOTIFY(header,data);
+ SpcIO_SendMsgToAp( SPCIO_MSG_FROM_ECALL_HANDSHAKE_INFO_ACK, header, data);
+}
+
+void spc_Set_Ecall_Lib_Status(uint8 status)
+{
+ gSpc.eCall_LIB_Status = status;
+}
+
+uint8 spc_Get_Ecall_Lib_Status(void)
+{
+ return gSpc.eCall_LIB_Status;
+}
+
+#if defined(__L5_SUPPORT__)
+void spc_L5ECALL_Status_Info_Callback(kal_uint16 status, kal_uint32 data){
+ ilm_SP_L5ECALL_Status_INFO_t *local_para;
+ local_para = (ilm_SP_L5ECALL_Status_INFO_t *) construct_local_para( sizeof(ilm_SP_L5ECALL_Status_INFO_t), TD_CTRL );
+ local_para->Status = status;
+ local_para->Data = data;
+ msg_send6(MOD_L1SP, MOD_L5UECALL, L1SP_L5UECALL_SAP, MSG_ID_L5UECALL_L1SP_ECALL_STATUS_IND, (local_para_struct *)local_para, NULL);
+}
+#endif
+#endif
+
+#if defined(_SPE_ENH_DSP_PARSE_)
+
+void spc_ReceiveEMIParInfo(const kal_uint32 offset, const kal_uint16 length, SPC_MSG_FROM_T comeFrom)
+{
+
+ //kal_int16 procLen;
+ kal_uint16 curOffset;
+ spcBufInfo header;
+ spc_sph_on_info_t info;
+ kal_uint32 EMI_Offset;
+
+
+ //unsigned short Common_Para[NUM_COMMON_PARAS];
+ //unsigned short Dbg_Para[16];
+
+ #if defined(SPH_CHIP_BACK_PHONECALL_USE)
+ return;
+ #endif // SPH_CHIP_BACK_PHONECALL_USE
+
+ //header
+ curOffset = SpcIo_GetDataFromAp(offset, sizeof(spcBufInfo), &header, comeFrom);
+ //header checking
+
+ ASSERT(header.syncWord == 0xA2A2);
+ ASSERT( (header.type == AUD_CCCI_STRMBUF_TYPE_SPH_INFO) );
+ ASSERT(header.length == (length - sizeof(spcBufInfo)));
+
+ curOffset = SpcIo_GetDataFromAp(curOffset, sizeof(spc_sph_on_info_t), &info, comeFrom);
+ 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]);
+ 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]);
+ L1SP_LoadCommonSpeechPara((uint16 *) info.common_param);
+ L1Audio_SetDebugInfo((uint16 *) info.debug_info);
+ VMREC_ConfigEpl();
+ spc_dev_LoopbackPoint_DVT(info.debug_info[15]);
+ MD_TRC_SPC_SPE_CHECK_EMI_SPEECH_INFO(2,info.param_usip_index,info.param_usip_len,info.param_shm_valid, info.param_path);
+ EMI_Offset =0;
+ if(info.param_path == 2 && info.param_shm_valid ==1 )
+ {
+ EMI_Offset =( info.param_usip_index + EMI_SPE_PAR_OFFSET)/2 ;
+ //memcpy(Common_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) +EMI_Offset+EMI_NEED_3K_0+ EMI_MD_COMMON_PAR_OFFSET), sizeof(unsigned short) * NUM_COMMON_PARAS);
+ // memcpy(Dbg_Para, (((unsigned short *)(SP_GetSphParamBufAddr())) + EMI_Offset +EMI_NEED_3K_0+EMI_MD_DBG_PAR_OFFSET), sizeof(unsigned short) * 16);
+ //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]);
+ //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]);
+ // L1SP_LoadCommonSpeechPara((uint16 *)Common_Para);
+ //L1Audio_SetDebugInfo((uint16 *)Dbg_Para);
+ l1sp_SetParEMIInfo(EMI_Offset,info.param_usip_len);
+ SetSpeechEnhancement(true);
+ }else if (info.param_path == 2 && info.param_shm_valid ==2 ) //use previous par.
+ {
+ SetSpeechEnhancement(true);
+ }
+ else
+ {
+ // need use MD default par
+ l1sp_SetParEMIInfo(EMI_MD_DEFAULT_OFFSET,EMI_MD_DEFAULT_LEN);
+ //L1SP_LoadCommonSpeechPara((uint16 *)Speech_Common_Para);
+ // L1Audio_SetDebugInfo((uint16 *)Debug_Info_Para);
+ SetSpeechEnhancement(true);
+
+ }
+
+}
+
+#endif
+
+void spc_setLoopback_dl_ul(kal_bool enable){
+ kal_prompt_trace(MOD_L1SP, "[set_spcLoopback_dl_ul] %d", enable);
+
+ ilm_SPC_SETLOOPBACK_DL_UL_t *local_para;
+
+ local_para = (ilm_SPC_SETLOOPBACK_DL_UL_t *) construct_local_para( sizeof(ilm_SPC_SETLOOPBACK_DL_UL_t), TD_CTRL );
+ local_para -> enable = enable;
+
+ msg_send6(MOD_L1SP, MOD_MED, AUDIO_SAP, MSG_ID_AUDIO_M2M_SPC_SETLOOPBACK_DL_UL, (local_para_struct *)local_para, NULL);
+
+}
diff --git a/mcu/driver/audio/src/v1/speech_dvt.c b/mcu/driver/audio/src/v1/speech_dvt.c
new file mode 100644
index 0000000..e6ac1df
--- /dev/null
+++ b/mcu/driver/audio/src/v1/speech_dvt.c
@@ -0,0 +1,544 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2013
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * speech_dvt.c
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * Speech DVT codes
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#if defined(__ENABLE_SPEECH_DVT__)
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "string.h"
+// #include "l1audio_def.h"
+#include "am.h"
+#include "media.h"
+#include "l1sp_trc.h"
+#include "spc_io.h"
+#include "spc_drv.h" // including "sp_drv.h"
+#include "pcm4way.h"
+
+extern void Spc_AcousticLoopback(kal_uint8 uParam);
+extern void spc_RecordStart(uint8 format, uint8 sampleRateIdx, uint8 channelNumIdx);
+extern void spc_RecordStop(void);
+
+// Bit 0 => 0: NB 1: WB
+// Bit 1 => 0: Idle 1: Call
+// Bit 2 => 0: P2W 1: P4W
+// Bit 3 => 0: Enable PNW test 1: Disable PNW test
+typedef enum {
+ PNW_TEST_P2W_IDLE_NB = 0x0,
+ PNW_TEST_P2W_IDLE_WB = 0x1,
+ PNW_TEST_P2W_CALL_NB = 0x2,
+ PNW_TEST_P2W_CALL_WB = 0x3,
+ PNW_TEST_P4W_IDLE_NB = 0x4,
+ PNW_TEST_P4W_IDLE_WB = 0x5,
+ PNW_TEST_P4W_CALL_NB = 0x6,
+ PNW_TEST_P4W_CALL_WB = 0x7,
+ PNW_TEST_NONE = 0x8
+} PNW_TEST_TYPE;
+
+#define IS_NB(a) ((a & 0x1) == 0)
+#define IS_WB(a) ((a & 0x1) != 0)
+#define IS_IDLE(a) ((a & 0x2) == 0)
+#define IS_CALL(a) ((a & 0x2) != 0)
+#define IS_P2W(a) ((a & 0x4) == 0)
+#define IS_P4W(a) ((a & 0x4) != 0)
+#define IS_ENABLE(a) ((a & 0x8) == 0)
+#define IS_DISABLE(a) ((a & 0x8) != 0)
+
+static kal_uint32 pnw_test_type = (kal_uint32)PNW_TEST_P2W_IDLE_NB;
+
+// ----------------------------------------------------------------------------
+// Loopback
+// ----------------------------------------------------------------------------
+
+#define PNW_TEST_FRM_BUF_CNT 32 // REMIND : must be pow of 2
+#define PNW_TEST_FRM_SIZE 320 // Unit : sample
+#define PNW_TEST_DELAY 12 // Unit : 20ms
+#define MOD_BUF_CNT(a) (a & (PNW_TEST_FRM_BUF_CNT - 1))
+
+#define P2W_UL_CONFIG (PNW_ENBLE + USE_D2M_PATH + DATA_SELECT_AFTER_ENH + MCU_SET_P2W_ON)
+#define P2W_DL_CONFIG (PNW_ENBLE + USE_M2D_PATH + MCU_SET_P2W_ON)
+#define P4W_UL_CONFIG (PNW_ENBLE + USE_D2M_PATH + USE_M2D_PATH + DATA_SELECT_AFTER_ENH + MCU_SET_P4W_ON)
+#define P4W_DL_CONFIG (PNW_ENBLE + USE_D2M_PATH + USE_M2D_PATH + MCU_SET_P4W_ON)
+
+static kal_uint16 PNW_Test_UL_Buf[PNW_TEST_FRM_BUF_CNT][PNW_TEST_FRM_SIZE];
+static kal_uint16 PNW_Test_DL_Buf[PNW_TEST_FRM_BUF_CNT][PNW_TEST_FRM_SIZE];
+
+typedef struct {
+ kal_uint32 delay;
+ kal_uint32 w_idx;
+ kal_uint32 r_idx;
+ kal_uint32 UL_w_idx;
+ kal_uint32 UL_r_idx;
+ kal_uint32 DL_w_idx;
+ kal_uint32 DL_r_idx;
+} PNW_TEST_STRUCT;
+
+static PNW_TEST_STRUCT pnw_test_handle;
+
+static void PNW_Test_UL_Hisr(void)
+{
+ kal_uint32 w_idx;
+ kal_uint32 r_idx;
+
+ // Get read / write index
+ if (IS_P2W(pnw_test_type))
+ {
+ w_idx = pnw_test_handle.w_idx;
+ r_idx = pnw_test_handle.r_idx;
+ }
+ else
+ {
+ w_idx = pnw_test_handle.UL_w_idx;
+ r_idx = pnw_test_handle.UL_r_idx;
+ }
+
+ // Get from microphone
+ if (w_idx - r_idx < PNW_TEST_FRM_BUF_CNT)
+ {
+ kal_uint16 *p_buf = (kal_uint16 *)PNW_Test_UL_Buf[MOD_BUF_CNT(w_idx)];
+
+ if (IS_P2W(pnw_test_type))
+ {
+ PCM2WAY_GetFromMic(p_buf);
+ }
+ else
+ {
+ PCM4WAY_GetFromMic(p_buf);
+ }
+
+ MD_TRC_SPC_AC_LOOPBACK_FROM_MIC(p_buf[0], p_buf[1], p_buf[2], p_buf[3]);
+
+ w_idx++;
+ }
+ else
+ {
+ MD_TRC_SPC_AC_LOOPBACK_SKIP_MIC();
+ }
+
+ // Put to speech encode, only for P4W
+ if (IS_P4W(pnw_test_type))
+ {
+ if (w_idx - r_idx >= pnw_test_handle.delay)
+ {
+ kal_uint16 *p_buf = (kal_uint16 *)PNW_Test_UL_Buf[MOD_BUF_CNT(r_idx)];
+
+ PCM4WAY_PutToSE(p_buf);
+
+ MD_TRC_SPC_AC_LOOPBACK_TO_SE(p_buf[0], p_buf[1], p_buf[2], p_buf[3]);
+
+ r_idx++;
+ }
+ else
+ {
+ PCM4WAY_FillSE(0);
+ MD_TRC_SPC_AC_LOOPBACK_FILL_SE();
+ }
+ }
+
+ // Update read / write index
+ if (IS_P2W(pnw_test_type))
+ {
+ pnw_test_handle.w_idx = w_idx;
+ pnw_test_handle.r_idx = r_idx;
+ }
+ else
+ {
+ pnw_test_handle.UL_w_idx = w_idx;
+ pnw_test_handle.UL_r_idx = r_idx;
+ }
+
+ return;
+}
+
+static void PNW_Test_DL_Hisr(void)
+{
+ kal_uint32 w_idx;
+ kal_uint32 r_idx;
+
+ // Get read / write index
+ if (IS_P2W(pnw_test_type))
+ {
+ w_idx = pnw_test_handle.w_idx;
+ r_idx = pnw_test_handle.r_idx;
+ }
+ else
+ {
+ w_idx = pnw_test_handle.DL_w_idx;
+ r_idx = pnw_test_handle.DL_r_idx;
+ }
+
+ // Get from speech decode, only for P4W
+ if (IS_P4W(pnw_test_type))
+ {
+ if (w_idx - r_idx < PNW_TEST_FRM_BUF_CNT)
+ {
+ kal_uint16 *p_buf = (kal_uint16 *)PNW_Test_DL_Buf[MOD_BUF_CNT(w_idx)];
+
+ PCM4WAY_GetFromSD(p_buf);
+
+ MD_TRC_SPC_AC_LOOPBACK_FROM_SD(p_buf[0], p_buf[1], p_buf[2], p_buf[3]);
+
+ w_idx++;
+ }
+ else
+ {
+ MD_TRC_SPC_AC_LOOPBACK_SKIP_SD();
+ }
+ }
+
+ // Put to speaker
+ if (w_idx - r_idx >= pnw_test_handle.delay)
+ {
+ kal_uint16 *p_buf;
+
+ if (IS_P2W(pnw_test_type))
+ {
+ p_buf = (kal_uint16 *)PNW_Test_UL_Buf[MOD_BUF_CNT(r_idx)];
+
+ PCM2WAY_PutToSpk(p_buf);
+ }
+ else
+ {
+ p_buf = (kal_uint16 *)PNW_Test_DL_Buf[MOD_BUF_CNT(r_idx)];
+
+ PCM4WAY_PutToSpk(p_buf);
+ }
+
+ MD_TRC_SPC_AC_LOOPBACK_TO_SPK(p_buf[0], p_buf[1], p_buf[2], p_buf[3]);
+
+ r_idx++;
+ }
+ else
+ {
+ MD_TRC_SPC_AC_LOOPBACK_FILL_SPK();
+
+ if (IS_P2W(pnw_test_type))
+ {
+ PCM2WAY_FillSpk(0);
+ }
+ else
+ {
+ PCM4WAY_FillSpk(0);
+ }
+ }
+
+ // Update read / write index
+ if (IS_P2W(pnw_test_type))
+ {
+ pnw_test_handle.w_idx = w_idx;
+ pnw_test_handle.r_idx = r_idx;
+ }
+ else
+ {
+ pnw_test_handle.DL_w_idx = w_idx;
+ pnw_test_handle.DL_r_idx = r_idx;
+ }
+
+ MD_TRC_SPC_AC_LOOPBACK_UL_DL_INDEX(w_idx, r_idx, 0, 0);
+
+ return;
+}
+
+// uParam bit 0 => 1: on, 0: off
+void Spc_PCMNWay_DVT_Test(kal_uint8 uParam)
+{
+ if (IS_DISABLE(pnw_test_type))
+ {
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]PNW test is disabled (test type = %x)", pnw_test_type);
+ Spc_AcousticLoopback(uParam);
+ }
+ else if (uParam & 0x1)
+ {
+ // Setup
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]PNW start (test type = %x)", pnw_test_type);
+ memset(&pnw_test_handle, 0, sizeof(PNW_TEST_STRUCT));
+ memset(PNW_Test_UL_Buf, 0, sizeof(kal_uint16) * PNW_TEST_FRM_BUF_CNT * PNW_TEST_FRM_SIZE);
+ memset(PNW_Test_DL_Buf, 0, sizeof(kal_uint16) * PNW_TEST_FRM_BUF_CNT * PNW_TEST_FRM_SIZE);
+ pnw_test_handle.delay = PNW_TEST_DELAY;
+
+ // Enable
+ if (IS_CALL(pnw_test_type) && !AM_IsSpeechOn())
+ {
+ L1SP_Speech_On(RAT_2G_MODE);
+ L1SP_SpeechLoopBackEnable(KAL_TRUE);
+ }
+
+ if (IS_P2W(pnw_test_type))
+ {
+ if (IS_NB(pnw_test_type))
+ {
+ PCM2Way_SetFormat(P2W_FORMAT_NORMAL);
+ }
+ else
+ {
+ PCM2Way_SetFormat(P2W_FORMAT_WB_NORMAL);
+ }
+ }
+
+ switch(pnw_test_type)
+ {
+ case PNW_TEST_P2W_IDLE_NB:
+ case PNW_TEST_P2W_IDLE_WB:
+ Extended_PCM2WAY_Start(PNW_Test_DL_Hisr, PNW_Test_UL_Hisr, P2W_APP_TYPE_VOIP, P2W_UL_CONFIG, P2W_DL_CONFIG);
+ break;
+ case PNW_TEST_P2W_CALL_NB:
+ case PNW_TEST_P2W_CALL_WB:
+ Extended_PCM2WAY_Start(PNW_Test_DL_Hisr, PNW_Test_UL_Hisr, P2W_APP_TYPE_UNDER_CALL, P2W_UL_CONFIG, P2W_DL_CONFIG);
+ break;
+ case PNW_TEST_P4W_IDLE_NB:
+ Extended_PCM4WAY_Start(PNW_Test_DL_Hisr, PNW_Test_UL_Hisr, P4W_APP_TYPE_WITHOUT_CALL, P4W_UL_CONFIG, P4W_DL_CONFIG);
+ break;
+ case PNW_TEST_P4W_IDLE_WB:
+ Extended_PCM4WAY_Start(PNW_Test_DL_Hisr, PNW_Test_UL_Hisr, P4W_APP_TYPE_WITHOUT_CALL_WB, P4W_UL_CONFIG, P4W_DL_CONFIG);
+ break;
+ case PNW_TEST_P4W_CALL_NB:
+ case PNW_TEST_P4W_CALL_WB:
+ Extended_PCM4WAY_Start(PNW_Test_DL_Hisr, PNW_Test_UL_Hisr, P4W_APP_TYPE_UNDER_CALL, P4W_UL_CONFIG, P4W_DL_CONFIG);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]PNW stop (test type = %x)", pnw_test_type);
+ switch(pnw_test_type)
+ {
+ case PNW_TEST_P2W_IDLE_NB:
+ case PNW_TEST_P2W_IDLE_WB:
+ Extended_PCM2WAY_Stop(P2W_APP_TYPE_VOIP);
+ break;
+ case PNW_TEST_P2W_CALL_NB:
+ case PNW_TEST_P2W_CALL_WB:
+ Extended_PCM2WAY_Stop(P2W_APP_TYPE_UNDER_CALL);
+ break;
+ case PNW_TEST_P4W_IDLE_NB:
+ Extended_PCM4WAY_Stop(P4W_APP_TYPE_WITHOUT_CALL);
+ break;
+ case PNW_TEST_P4W_IDLE_WB:
+ Extended_PCM4WAY_Stop(P4W_APP_TYPE_WITHOUT_CALL_WB);
+ break;
+ case PNW_TEST_P4W_CALL_NB:
+ case PNW_TEST_P4W_CALL_WB:
+ Extended_PCM4WAY_Stop(P4W_APP_TYPE_UNDER_CALL);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return;
+}
+
+static kal_bool f_sph_DVT_pnw_via_rec_on = KAL_FALSE;
+
+void Spc_PCMNWay_DVT_Test_by_Rec_Button(kal_uint8 uParam, uint8 format, uint8 sampling_rate_idx, uint8 ch_num_idx)
+{
+ if (f_sph_DVT_pnw_via_rec_on && IS_ENABLE(pnw_test_type) && IS_CALL(pnw_test_type))
+ {
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]PNW Call via Rec %s", uParam & 0x1 ? "on" : "off");
+ Spc_PCMNWay_DVT_Test(uParam);
+ }
+ else
+ {
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Back to Rec, is start %d, flag %d, is enable %d, is call", uParam & 0x1, f_sph_DVT_pnw_via_rec_on, IS_ENABLE(pnw_test_type), IS_CALL(pnw_test_type));
+ if (uParam & 0x1)
+ {
+ spc_RecordStart(format, sampling_rate_idx, ch_num_idx);
+ }
+ else
+ {
+ spc_RecordStop();
+ }
+ }
+
+ return;
+}
+
+static kal_bool f_sph_DVT_fwe_on = KAL_TRUE;
+
+kal_bool Is_Sph_DVT_Enable_FWE(void)
+{
+ return f_sph_DVT_fwe_on;
+}
+
+typedef enum {
+ BT_MODE_TEST_NONE = 0x0,
+ BT_MODE_TEST_NB = 0x1,
+ BT_MODE_TEST_WB = 0x2
+} BT_MODE_TEST_TYPE;
+
+static kal_uint32 sph_DVT_BT_mode = (kal_uint32)BT_MODE_TEST_NONE;
+
+kal_bool Is_Sph_DVT_BT_Mode_NB(void)
+{
+ return (kal_bool)(sph_DVT_BT_mode == BT_MODE_TEST_NB);
+}
+
+kal_bool Is_Sph_DVT_BT_Mode_WB(void)
+{
+ return (kal_bool)(sph_DVT_BT_mode == BT_MODE_TEST_WB);
+}
+
+void Speech_DVT_Test_Main(kal_char *string)
+{
+ if (strcmp(string, "P2W_Idle_NB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P2W_IDLE_NB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P2W idle NB");
+ }
+ else if(strcmp(string, "P2W_Idle_WB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P2W_IDLE_WB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P2W idle WB");
+ }
+ else if(strcmp(string, "P2W_Call_NB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P2W_CALL_NB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P2W call NB");
+ }
+ else if(strcmp(string, "P2W_Call_WB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P2W_CALL_WB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P2W call WB");
+ }
+ else if (strcmp(string, "P4W_Idle_NB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P4W_IDLE_NB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P4W idle NB");
+ }
+ else if(strcmp(string, "P4W_Idle_WB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P4W_IDLE_WB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P4W idle WB");
+ }
+ else if(strcmp(string, "P4W_Call_NB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P4W_CALL_NB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P4W call NB");
+ }
+ else if(strcmp(string, "P4W_Call_WB")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_P4W_CALL_WB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]P4W call WB");
+ }
+ else if(strcmp(string, "PNW_None")==0)
+ {
+ pnw_test_type = (kal_uint32)PNW_TEST_NONE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]PNW none");
+ }
+ else if(strcmp(string, "Enable_FWE")==0)
+ {
+ f_sph_DVT_fwe_on = KAL_TRUE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Enable FWE");
+ }
+ else if(strcmp(string, "Disable_FWE")==0)
+ {
+ f_sph_DVT_fwe_on = KAL_FALSE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Disable FWE");
+ }
+ else if(strcmp(string, "Enable_PNW_Call_Via_Rec")==0)
+ {
+ f_sph_DVT_pnw_via_rec_on = KAL_TRUE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Enable PNW via Rec");
+ }
+ else if(strcmp(string, "Disable_PNW_Call_Via_Rec")==0)
+ {
+ f_sph_DVT_pnw_via_rec_on = KAL_FALSE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Disable PNW via Rec");
+ }
+ else if(strcmp(string, "Enable_BT_Mode_NB")==0)
+ {
+ sph_DVT_BT_mode = (kal_uint32)BT_MODE_TEST_NB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Enable BT Mode NB");
+ }
+ else if(strcmp(string, "Enable_BT_Mode_WB")==0)
+ {
+ sph_DVT_BT_mode = (kal_uint32)BT_MODE_TEST_WB;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Enable BT Mode WB");
+ }
+ else if(strcmp(string, "Disable_BT_Mode")==0)
+ {
+ sph_DVT_BT_mode = (kal_uint32)BT_MODE_TEST_NONE;
+ kal_prompt_trace(MOD_L1SP, "[Speech DVT]Disable BT Mode");
+ }
+
+ return;
+}
+
+#endif // defined(__ENABLE_SPEECH_DVT__)
+
diff --git a/mcu/driver/audio/src/v1/speech_service.c b/mcu/driver/audio/src/v1/speech_service.c
new file mode 100644
index 0000000..635ff11
--- /dev/null
+++ b/mcu/driver/audio/src/v1/speech_service.c
@@ -0,0 +1,137 @@
+
+#include "l1aud_common_def.h"
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "l1sp_trc.h"
+
+#include "speech_service.h"
+#include "audio_msgid.h"
+#include "dhl_trace.h"
+#include "svc_sap.h"
+
+extern kal_uint16 L1Audio_GetDebugInfo( kal_uint8 index );
+extern void dhl_log_primitive(ilm_struct *ilm);
+
+SPLog_t SPLog;
+kal_uint16 bt_tx_seq = 0;
+kal_uint16 bt_rx_seq = 0;
+
+
+/* API definition */
+void SPLog_GetFlagSetting()
+{
+#ifdef __MODEM_LOGGING_SUPPORT__
+ SPLog.flag = L1Audio_GetDebugInfo(1);
+ MD_TRC_SPLOG_GET_DBG_FLAG(SPLog.flag);
+// kal_prompt_trace(MOD_L1SP, "[DBG_LOG]flag %x, msg_begin id %d\r\n", SPLog.flag, MSG_ID_AUDIO_LOGGING_BEGIN);
+#else
+#endif
+}
+
+void SPLog_LogSingleData(kal_uint32 msg_id, kal_uint32 data_length, void *data)
+{
+#ifdef __MODEM_LOGGING_SUPPORT__
+ if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1)))
+{
+ ilm_struct current_ilm;
+ singleData_struct *local_para;
+ kal_uint32 i;
+
+// kal_prompt_trace(MOD_L1SP, "[SP_LOG_SINGLE]ID %x", msg_id);
+ current_ilm.src_mod_id = MOD_L1SP;
+ current_ilm.dest_mod_id = MOD_DHL_READER;
+ current_ilm.sap_id = INVALID_SAP;
+ current_ilm.msg_id = msg_id;
+ current_ilm.peer_buff_ptr = NULL;
+
+ current_ilm.local_para_ptr = construct_local_para(sizeof(singleData_struct),TD_CTRL);
+ local_para = (singleData_struct *)current_ilm.local_para_ptr;
+
+ local_para->local_hdr_len = 4; /*size of LOCAL_PARA_HDR */
+ local_para->data_len = data_length;
+ for(i = 0; i < data_length; i++){
+ local_para->data[i] = *((kal_uint8 *)data+i);
+ }
+
+ dhl_log_primitive(¤t_ilm);
+ destroy_ilm(¤t_ilm);
+}
+#else
+#endif
+}
+
+void SPLog_LogData(kal_uint32 msg_id, kal_uint32 data_length, void *data)
+{
+#ifdef __MODEM_LOGGING_SUPPORT__
+ if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1)))
+{
+ ilm_struct current_ilm;
+ data_struct *local_para;
+ kal_uint32 i;
+
+// kal_prompt_trace(MOD_L1SP, "[SP_LOG_DATA]ID %x", msg_id);
+ current_ilm.src_mod_id = MOD_L1SP;
+ current_ilm.dest_mod_id = MOD_DHL_READER;
+ current_ilm.sap_id = INVALID_SAP;
+ current_ilm.msg_id = msg_id;
+ current_ilm.peer_buff_ptr = NULL;
+
+ current_ilm.local_para_ptr = construct_local_para(sizeof(data_struct),TD_CTRL);
+ local_para = (data_struct *)current_ilm.local_para_ptr;
+ local_para->local_hdr_len = 4; // size of LOCAL_PARA_HDR
+ local_para->opcode = 1; //0: header 1: data log 2:end
+ switch(msg_id) {
+ case MSG_ID_AUDIO_LOGGING_BT_TX:
+ local_para->log_seq = bt_tx_seq++;
+ break;
+ case MSG_ID_AUDIO_LOGGING_BT_RX:
+ local_para->log_seq = bt_rx_seq++;
+ break;
+ default:
+ local_para->log_seq = 0;
+ break;
+ }
+ local_para->data_len = data_length;
+ for(i = 0; i < data_length; i++){
+ local_para->data[i] = *((kal_uint8 *)data+i);
+ }
+ dhl_log_primitive(¤t_ilm);
+ destroy_ilm(¤t_ilm);
+}
+#else
+#endif
+}
+void SPLog_LogDbgInfo(kal_uint32 msg_id, kal_uint8 opcode, void *data)
+{
+#ifdef __MODEM_LOGGING_SUPPORT__
+ if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1)))
+{
+ ilm_struct current_ilm;
+ dbgInfo_struct *local_para;
+ kal_uint32 i;
+
+// kal_prompt_trace(MOD_L1SP, "[SP_DBG_INFO]ID %x", msg_id);
+ current_ilm.src_mod_id = MOD_L1SP;
+ current_ilm.dest_mod_id = MOD_DHL_READER;
+ current_ilm.sap_id = INVALID_SAP;
+ current_ilm.msg_id = msg_id;
+ current_ilm.peer_buff_ptr = NULL;
+
+ current_ilm.local_para_ptr = construct_local_para(sizeof(dbgInfo_struct),TD_CTRL);
+ local_para = (dbgInfo_struct *)current_ilm.local_para_ptr;
+
+ local_para->local_hdr_len = 4; //size of LOCAL_PARA_HDR
+ local_para->opcode = opcode; //0: header 1: data log 2:end
+ for(i = 0; i < 2; i++){
+ local_para->reserved[i] = *((kal_uint8 *)data+i);
+ }
+
+ dhl_log_primitive(¤t_ilm);
+ destroy_ilm(¤t_ilm);
+}
+#else
+#endif
+}
+
+
diff --git a/mcu/driver/audio/src/v1/streamrb.c b/mcu/driver/audio/src/v1/streamrb.c
new file mode 100644
index 0000000..bfaf84b
--- /dev/null
+++ b/mcu/driver/audio/src/v1/streamrb.c
@@ -0,0 +1,488 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * StreamRB.c
+ *
+ * Project:
+ * --------
+ * MOLY_sw
+ *
+ * Description:
+ * ------------
+ * StreamRB interface and driver, providing stream ring buffer utility
+ *
+ * Author:
+ * -------
+ * -------
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*****************************************************************************
+* C O M P I L E R F L A G S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* E X T E R N A L R E F E R E N C E S
+******************************************************************************
+*/
+#include "kal_public_api.h"
+#include "string.h"
+
+#include "l1aud_common_def.h"
+#include "streamrb.h"
+/*****************************************************************************
+* C O N S T A N T S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* D A T A T Y P E S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* P U B L I C D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* P R I V A T E D A T A
+******************************************************************************
+*/
+
+/*****************************************************************************
+* M A C R O S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N D E C L A R A T I O N S
+******************************************************************************
+*/
+
+/*****************************************************************************
+* F U N C T I O N S
+******************************************************************************
+*/
+
+
+/*
+ * Description
+ * ---------
+ * The function initializes the ring buffer instance.
+ *
+ * Syntax
+ * ---------
+ * bool StreamRB_Init( StreamRB *rb, uint8 *buffer, int32 buffer_size )
+ *
+ * where
+ * rb The ring buffer instance
+ * buffer Address of the memory allocated for the ring buffer
+ * buffer_size Size of the memory allocated for the ring buffer
+ *
+ * Return Value
+ * ---------
+ * true
+ * false
+ */
+bool StreamRB_Init( StreamRB *rb, uint8 *buffer, int32 buffer_size )
+{
+ ASSERT( rb!=NULL );
+
+ memset( buffer, 0, buffer_size*sizeof(uint8) );
+ rb->buffer = buffer;
+ rb->size = buffer_size;
+ rb->read = 0;
+ rb->write = 0;
+
+ return true;
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function returns the available free space of the ring buffer instance.
+ *
+ * Syntax
+ * ---------
+ * int32 StreamRB_GetFreeSpace( StreamRB *rb )
+ *
+ * where
+ * rb The ring buffer instance
+ *
+ * Return Value
+ * ---------
+ * the free space in words
+ */
+int32 StreamRB_GetFreeSpace( StreamRB *rb )
+{
+ int32 count;
+
+ ASSERT( rb!=NULL );
+
+ count = rb->read - rb->write - 1;
+ if( 0>count )
+ count += rb->size;
+ return count;
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function returns available data count of the ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * int32 StreamRB_GetDataCount( StreamRB *rb )
+ *
+ * where
+ * rb The ring buffer instance
+ *
+ * Return Value
+ * ---------
+ * the data count in words
+ */
+int32 StreamRB_GetDataCount( StreamRB *rb )
+{
+ int32 count;
+
+ ASSERT( rb!=NULL );
+
+ count = rb->write - rb->read;
+ if( 0>count )
+ count += rb->size;
+ return count;
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function copies data from a linear array to a ring buffer instance.
+ * The free space of the ring buffer instance shall be enough, or assertion will happen
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_Write( StreamRB *dest_rb, uint8 *src_buffer, int32 size )
+ *
+ * where
+ * dest_rb The ring buffer instance
+ * src_buffer Address of the linear array
+ * size Size of copy
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_Write( StreamRB *dest_rb, uint8 *src_buffer, int32 size )
+{
+ uint8 *write_ptr;
+ int32 write_cnt;
+/// kal_prompt_trace(MOD_L1SP, "StreamRB_Write size=%d",size);
+ ASSERT( dest_rb!=NULL );
+ ASSERT( StreamRB_GetFreeSpace( dest_rb )>=size );
+
+ StreamRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size ) write_cnt = size;
+
+ if( src_buffer == (uint8 *)NULL ){
+ memset( write_ptr, 0, write_cnt*sizeof(uint8) );
+/// kal_prompt_trace(MOD_L1SP, "StreamRB_Write Null");
+ }else{
+ memcpy( write_ptr, src_buffer, write_cnt*sizeof(uint8) );
+/// kal_prompt_trace(MOD_L1SP, "StreamRB_Write %x %x %x %x", write_ptr, *(src_buffer+0),*(src_buffer+1),*(src_buffer+2));
+ }
+
+ StreamRB_ShiftWritePointer( dest_rb, write_cnt );
+ size -= write_cnt;
+
+ if( size>0 )
+ {
+ if( src_buffer != (uint8 *)NULL )
+ {
+ src_buffer += write_cnt;
+ }
+
+ StreamRB_GetWriteBlock( dest_rb, &write_ptr, &write_cnt );
+ if( write_cnt>size )
+ {
+ write_cnt = size;
+ }
+
+ if( src_buffer == (uint8 *)NULL )
+ {
+ memset( write_ptr, 0, write_cnt*sizeof(uint8) );
+ }
+ else
+ {
+ memcpy( write_ptr, src_buffer, write_cnt*sizeof(uint8) );
+ }
+
+ StreamRB_ShiftWritePointer( dest_rb, write_cnt );
+ }
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function copies data from a ring buffer instance to a linear array
+ * The data count of the ring buffer instance shall be enough, or assertion will happen
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_Read( StreamRB *src_rb, uint8 *dest_buffer, int32 size )
+ *
+ * where
+ * src_rb The ring buffer instance
+ * dest_buffer Address of the linear array
+ * size Size of copy
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_Read( StreamRB *src_rb, uint8 *dest_buffer, int32 size )
+{
+ uint8 *read_ptr;
+ int32 read_cnt;
+/// kal_prompt_trace(MOD_L1SP, "StreamRB_Read size=%d",size);
+ ASSERT( src_rb!=NULL );
+ ASSERT( StreamRB_GetDataCount( src_rb )>=size );
+
+ StreamRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size )
+ {
+ read_cnt = size;
+ }
+ memcpy( dest_buffer, read_ptr, read_cnt*sizeof(uint8) );
+ StreamRB_ShiftReadPointer( src_rb, read_cnt );
+ size -= read_cnt;
+
+ if( size>0 )
+ {
+ dest_buffer += read_cnt;
+ StreamRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size )
+ {
+ read_cnt = size;
+ }
+ memcpy( dest_buffer, read_ptr, read_cnt*sizeof(uint8) );
+ StreamRB_ShiftReadPointer( src_rb, read_cnt );
+ }
+}
+
+
+/*void StreamRB_ShiftReadPointer2( StreamRB *src_rb, int32 size )
+{
+ uint8 *read_ptr;
+ int32 read_cnt;
+
+ ASSERT( src_rb!=NULL );
+ ASSERT( StreamRB_GetDataCount( src_rb )>=size );
+
+ StreamRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size )
+ {
+ read_cnt = size;
+ }
+ //memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ StreamRB_ShiftReadPointer( src_rb, read_cnt );
+ size -= read_cnt;
+
+ if( size>0 )
+ {
+ //dest_buffer += read_cnt;
+ StreamRB_GetReadBlock( src_rb, &read_ptr, &read_cnt );
+ if( read_cnt>size )
+ {
+ read_cnt = size;
+ }
+ // memcpy( dest_buffer, read_ptr, read_cnt*sizeof(int16) );
+ StreamRB_ShiftReadPointer( src_rb, read_cnt );
+ }
+}*/
+
+
+/*
+ * Description
+ * ---------
+ * The function returns the linear write block and its size of a ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_GetWriteBlock( StreamRB *dest_rb, uint8 **write_ptr, int32 *write_cnt )
+ *
+ * where
+ * dest_rb The ring buffer instance
+ * write_ptr Address of the memory to put the address of the linear write block
+ * write_cnt Address of the memory to put the size of the linear write block
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_GetWriteBlock( StreamRB *dest_rb, uint8 **write_ptr, int32 *write_cnt )
+{
+ int32 cnt;
+
+ ASSERT( (dest_rb!=NULL) && (write_ptr!=NULL) && (write_cnt!=NULL) );
+
+ if( dest_rb->read>dest_rb->write )
+ cnt = dest_rb->read - dest_rb->write - 1;
+ else if( dest_rb->read==0 )
+ cnt = dest_rb->size - dest_rb->write - 1;
+ else
+ cnt = dest_rb->size - dest_rb->write;
+
+ *write_cnt = cnt;
+ *write_ptr = &dest_rb->buffer[dest_rb->write];
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function returns the linear read block and its size of a ring buffer instance
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_GetReadBlock( StreamRB *src_rb, uint8 **read_ptr, int32 *read_cnt )
+ *
+ * where
+ * src_rb The ring buffer instance
+ * read_ptr Address of the memory to put the address of the linear read block
+ * read_cnt Address of the memory to put the size of the linear read block
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_GetReadBlock( StreamRB *src_rb, uint8 **read_ptr, int32 *read_cnt )
+{
+ int32 cnt;
+
+ ASSERT( (src_rb!=NULL) && (read_ptr!=NULL) && (read_cnt!=NULL) );
+
+ if( src_rb->write == src_rb->read )
+ cnt = 0;
+ else if( src_rb->write>src_rb->read )
+ cnt = src_rb->write - src_rb->read;
+ else
+ cnt = src_rb->size - src_rb->read;
+
+ *read_cnt = cnt;
+ *read_ptr = &src_rb->buffer[src_rb->read];
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function shifts the write pointer of a ring buffer instance in circular way
+ * Use this with StreamRB_GetWriteBlock
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_ShiftWritePointer( StreamRB *rb, int32 shamt )
+ *
+ * where
+ * rb The ring buffer instance
+ * shamt shift amount
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_ShiftWritePointer( StreamRB *rb, int32 shamt )
+{
+ ASSERT( rb!=NULL );
+
+ rb->write += shamt;
+ if( rb->write>=rb->size )
+ rb->write -= rb->size;
+}
+
+
+/*
+ * Description
+ * ---------
+ * The function shifts the read pointer of a ring buffer instance in circular way
+ * Use this with StreamRB_GetReadBlock
+ *
+ * Syntax
+ * ---------
+ * void StreamRB_ShiftReadPointer( StreamRB *rb, int32 shamt )
+ *
+ * where
+ * rb The ring buffer instance
+ * shamt shift amount
+ *
+ * Return Value
+ * ---------
+ * none
+ */
+void StreamRB_ShiftReadPointer( StreamRB *rb, int32 shamt )
+{
+ ASSERT( rb!=NULL );
+
+ rb->read += shamt;
+ if( rb->read>=rb->size )
+ rb->read -= rb->size;
+}
+
diff --git a/mcu/driver/audio/src/v1/tone2.c b/mcu/driver/audio/src/v1/tone2.c
new file mode 100644
index 0000000..2abf925
--- /dev/null
+++ b/mcu/driver/audio/src/v1/tone2.c
@@ -0,0 +1,840 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * tone.c
+ *
+ * Project:
+ * --------
+ * MTK6208
+ *
+ * Description:
+ * ------------
+ * Tone Interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "dcl.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "media.h"
+#include "afe.h"
+#include "am.h"
+#include "speech_def.h"
+// #include "audio_def.h"
+#include "afe_def.h"
+
+
+
+#define KT_INIT_AMP 0x3FFF
+#define TONE_INIT_AMP 0x1FFF
+
+static struct
+{
+ const L1SP_Tones *tonelist;
+ const L1SP_QTMF *curr_qtmf;
+ void (*handler)(void);
+ uint32 gpt;
+ uint16 aud_id;
+ uint16 amp;
+ bool bQTMF;
+ bool isRun;
+} tone;
+
+static struct
+{
+ uint32 gpt;
+ uint16 aud_id;
+ int8 lock;
+ uint8 volume1;
+ int8 digital_gain_index;
+ bool isRun;
+} keytone;
+
+
+#define DSP_QTMF_FREQ(f1,f2,f3,f4) { DSP_TONE_F2A = (f1); \
+ DSP_TONE_F2B = (f2); \
+ DSP_TONE_F1A = (tone.bQTMF)?(f3):0; \
+ DSP_TONE_F1B = (tone.bQTMF)?(f4):0; \
+ Data_Sync_Barrier(); }
+
+#define DSP_KT_FREQ(f1,f2) { DSP_TONE_F2A = (f1); \
+ DSP_TONE_F2B = (f2); \
+ Data_Sync_Barrier(); }
+
+/* When Audio Ramp Down Enable, MCU waits until Audio RampDown of DSP. If the time of DSP's RampDown exceeds this value, the beginning part of Tone maybe be cut */
+#define SW_WAIT_AUDIO_RAMPDOWN (6)
+
+/* ------------------------------------------------------------------------------ */
+/* Functions for Playing Comfort Tones */
+/* ------------------------------------------------------------------------------ */
+static void tonePlayOff( void *data );
+
+void toneStop_FlushQueue( void *data )
+{
+ if(AM_IsToneOn())
+ {
+ SGPT_CTRL_START_T start;
+ start.u2Tick = 1;
+ start.pfCallback = toneStop_FlushQueue;
+ start.vPara = data;
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ } else {
+ L1Audio_ClearFlag( tone.aud_id );
+ }
+}
+
+static void toneStop( void *data )
+{
+ uint16 tone_ctrl;
+ SGPT_CTRL_START_T start;
+
+ if( !L1Audio_CheckFlag( tone.aud_id ) )
+ return;
+ tone_ctrl = (DSP_TONE_CTRL2 << 8) + DSP_TONE_CTRL1;
+ switch( tone_ctrl ) {
+ case 0:
+ if (tone.isRun) {
+ tone.isRun = false;
+ tone.bQTMF = false;
+ AM_ToneOff();
+ DP_KT_ATT = 0;
+ Data_Sync_Barrier();
+ L1Audio_SetEvent( tone.aud_id, 0 );
+
+ // unapply hardware mute during tone playback
+ *AFE_AMCU_CON1 &= ~0x30;
+ Data_Sync_Barrier();
+
+#if defined(__BT_SUPPORT__)
+ if( L1SP_GetSpeechMode() == SPH_MODE_LINEIN_VIA_BT_CORDLESS )
+ {
+ *DP_AUDIO_PAR = (*DP_AUDIO_PAR & 0xFF) | 0x1000; // set back to cordless mode
+ Data_Sync_Barrier();
+ }
+#endif
+ }
+ start.u2Tick = 1;
+ start.pfCallback = toneStop_FlushQueue;
+ start.vPara = data;
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ break;
+ case 0x202:
+ DSP_TONE_CTRL1 = 4;
+ DSP_TONE_CTRL2 = 4;
+ Data_Sync_Barrier();
+ default:
+ start.u2Tick = 1;
+ start.pfCallback = toneStop;
+ start.vPara = data;
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ break;
+ }
+}
+
+static void tonePlayOn( void *data )
+{
+ uint16 dura;
+
+ if( tone.bQTMF )
+ tone.curr_qtmf = (L1SP_QTMF *)tone.tonelist + (uint32)data;
+ else
+ tone.curr_qtmf = (L1SP_QTMF *)(tone.tonelist + (uint32)data);
+
+ // apply hardware mute during tone playback
+ *AFE_AMCU_CON1 |= 0x0C;
+ Data_Sync_Barrier();
+ DSP_QTMF_FREQ( tone.curr_qtmf->freq1, tone.curr_qtmf->freq2,
+ tone.curr_qtmf->freq3, tone.curr_qtmf->freq4 );
+ DSP_TONE_CTRL1 = 1;
+ DSP_TONE_CTRL2 = 1;
+ Data_Sync_Barrier();
+
+ if( ( dura = tone.curr_qtmf->on_duration / 10 ) > 0 ) {
+ SGPT_CTRL_START_T start;
+ start.u2Tick = dura;
+ start.pfCallback = tonePlayOff;
+ start.vPara = 0;
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ }
+}
+
+static void toneMute( void *data )
+{
+ int32 dura = (int32)data;
+ uint16 tone_ctrl;
+ SGPT_CTRL_START_T start;
+
+ tone_ctrl = (DSP_TONE_CTRL2 << 8) + DSP_TONE_CTRL1;
+ switch( tone_ctrl ) {
+ case 0:
+ start.u2Tick = dura+1;
+ start.pfCallback = tonePlayOn;
+ start.vPara = (void *)(kal_uint32)tone.curr_qtmf->next_tone;
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ break;
+ case 0x202:
+ DSP_TONE_CTRL1 = 4;
+ DSP_TONE_CTRL2 = 4;
+ Data_Sync_Barrier();
+ default:
+ start.u2Tick = 1;
+ start.pfCallback = toneMute;
+ start.vPara = (void*)((dura>0)?dura-1:0);
+ DclSGPT_Control( tone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ break;
+ }
+}
+
+static void tonePlayOff( void *data )
+{
+ uint16 dura = tone.curr_qtmf->off_duration / 10;
+ if( dura == 0 )
+ toneStop( 0 );
+ else
+ toneMute( (void*)(kal_uint32)dura );
+}
+
+static void toneHandler( void *data ) /* This function works in L1Audio Task */
+{
+ (void)data;
+ if( tone.handler != 0 )
+ tone.handler();
+}
+
+void toneInit( uint16 aud_id )
+{
+ tone.aud_id = aud_id;
+ tone.handler = 0;
+ L1Audio_SetEventHandler( aud_id, toneHandler );
+ tone.gpt = DclSGPT_Open( DCL_GPT_CB ,0 );
+ DSP_TONE_CTRL1 = 0;
+
+ tone.amp = TONE_INIT_AMP;
+ tone.bQTMF = false;
+
+ DP_KT_ATT = 0;
+ Data_Sync_Barrier();
+#ifdef ANALOG_AFE_PATH_EXIST
+ AFE_TurnOnFIR( L1SP_TONE );
+#endif // ANALOG_AFE_PATH_EXIST
+}
+
+/* ------------------------------------------------------------------------------ */
+/* Tone Interface */
+/* ------------------------------------------------------------------------------ */
+void TONE_SetOutputDevice( uint8 device )
+{
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif
+}
+
+void TONE_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif
+}
+
+/*****************************************************************************
+* FUNCTION
+* TONE_PlayQTMF
+* DESCRIPTION
+* This function is used to play comfort tones.
+* Totally 4 frequencies can be generated
+*
+* PARAMETERS
+* tonelist - QTMF list
+* RETURNS
+* None.
+* GLOBALS AFFECTED
+* None
+*****************************************************************************/
+void TONE_PlayQTMF( const L1SP_QTMF *tonelist )
+{
+ if( L1Audio_CheckFlag( tone.aud_id ) )
+ return;
+ tone.bQTMF = true;
+ TONE_Play((const L1SP_Tones *)tonelist);
+}
+
+/*****************************************************************************
+* FUNCTION
+* TONE_Play
+* DESCRIPTION
+* This function is used to play comfort tones.
+*
+* PARAMETERS
+* tonelist - Tone list
+* RETURNS
+* None.
+* GLOBALS AFFECTED
+* None
+*****************************************************************************/
+void TONE_Play( const L1SP_Tones *tonelist )
+{
+ // FIXME:
+ return;
+
+ if(AM_IsSpeechOn()){/* Prevent Speech from being muted, becuase Tone/KT with volume = 0 results in DigitalGain = 0 */
+/*
+ uint8 volume;
+
+#ifdef ANALOG_AFE_PATH_EXIST
+ int8 digital_gain_index;
+ AFE_GetOutputVolume(L1SP_TONE, &volume, &digital_gain_index);
+#else
+ AFE_DigitalOnly_GetOutputVolume(L1SP_TONE, &volume);
+#endif // ANALOG_AFE_PATH_EXIST
+ if(0 == volume)
+ return;
+*/
+
+ }
+
+ if( L1Audio_CheckFlag( tone.aud_id ) )
+ return;
+ if( L1Audio_CheckFlag( keytone.aud_id ) ) {
+ KT_Stop();
+ while( L1Audio_CheckFlag( keytone.aud_id ) )
+ kal_sleep_task( AUD_1TICK(1) );
+ }
+
+ if( AM_IsSpeechOn() )
+ {
+ DP_KT_ATT = 0x4000;
+ Data_Sync_Barrier();
+ }
+
+#if defined(__BT_SUPPORT__)
+ if( L1SP_IsBluetoothOn() ){
+ if( L1SP_GetSpeechMode() == SPH_MODE_LINEIN_VIA_BT_CORDLESS )
+ *DP_AUDIO_PAR = (*DP_AUDIO_PAR & 0xFF) | 0x2000; // set to earphone mode
+ DSP_TONE_AMP1 = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */
+ DSP_TONE_AMP2 = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */
+ }else
+#endif
+ {
+ DSP_TONE_AMP1 = tone.amp;
+ DSP_TONE_AMP2 = tone.amp;
+ }
+ Data_Sync_Barrier();
+ L1Audio_SetFlag( tone.aud_id );
+ tone.tonelist = tonelist;
+ AM_ToneOn();
+ tonePlayOn( 0 );
+ tone.isRun = true;
+}
+
+/*****************************************************************************
+* FUNCTION
+* TONE_Stop
+* DESCRIPTION
+* This function is used to stop playing comfort tones.
+*
+* PARAMETERS
+* None
+* RETURNS
+* None
+* GLOBALS AFFECTED
+* None
+*****************************************************************************/
+void TONE_Stop( void )
+{
+ DclSGPT_Control(tone.gpt ,SGPT_CMD_STOP, 0);
+ toneStop( 0 );
+}
+
+void TONE_StopAndWait( void )
+{
+ int I;
+
+ AM_FlushQFunction();
+ TONE_Stop();
+
+ for( I = 0; ; I++ ) {
+ if ( !AM_IsToneOn() )
+ break;
+
+ ASSERT_REBOOT(I < 20);
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ kal_sleep_task( AUD_1TICK(2) );//wait AFE also updated
+}
+
+void TONE_SetAmplitude( int16 amp )
+{
+ tone.amp = (uint16)amp;
+}
+
+void TONE_SetFIR( bool enable )
+{
+ if( enable ) {
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif // ANALOG_AFE_PATH_EXIST
+ }else{
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif
+ }
+}
+
+void TONE_SetHandler( void (*handler)(void) )
+{
+ tone.handler = handler;
+}
+
+/* ------------------------------------------------------------------------------ */
+/* Keytone Interface */
+/* ------------------------------------------------------------------------------ */
+void ktStop_FlushQueue( void *data )
+{
+ if(AM_IsKeyToneOn())
+ {
+ SGPT_CTRL_START_T start;
+ start.u2Tick = 1;
+ start.pfCallback = ktStop_FlushQueue;
+ start.vPara = data;
+ DclSGPT_Control( keytone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ } else {
+ L1Audio_ClearFlag( keytone.aud_id );
+ }
+}
+
+static void ktStop( void *data )
+{
+ SGPT_CTRL_START_T start;
+ if( !L1Audio_CheckFlag( keytone.aud_id ) )
+ return;
+ switch( DSP_TONE_CTRL2 ) {
+ case 0:
+ if (keytone.isRun) {
+ keytone.isRun = false;
+ AM_KeyToneOff();
+ }
+ start.u2Tick = 1;
+ start.pfCallback = ktStop_FlushQueue;
+ start.vPara = data;
+ DclSGPT_Control( keytone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ //L1Audio_ClearFlag( keytone.aud_id );
+ break;
+ case 2:
+ DSP_TONE_CTRL2 = 4;
+ Data_Sync_Barrier();
+ default:
+ start.u2Tick = 1;
+ start.pfCallback = ktStop;
+ start.vPara = data;
+ DclSGPT_Control( keytone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ break;
+ }
+}
+
+void ktInit( uint16 aud_id )
+{
+ keytone.aud_id = aud_id;
+ keytone.lock = 0;
+ keytone.volume1 = 160;
+ keytone.digital_gain_index = 0;
+ keytone.gpt = DclSGPT_Open(DCL_GPT_CB,0);
+ DSP_TONE_CTRL2 = 0;
+ DSP_TONE_AMP2 = KT_INIT_AMP;
+ Data_Sync_Barrier();
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif
+}
+
+void ktLock( void )
+{
+
+ ASSERT( keytone.lock < 8 );
+
+ keytone.lock++;
+
+}
+
+void ktUnlock( void )
+{
+
+ ASSERT( keytone.lock > 0 );
+
+ keytone.lock--;
+
+}
+
+void KT_SetOutputDevice( uint8 device )
+{
+ if( L1Audio_CheckFlag( keytone.aud_id ) ) {
+ KT_Stop();
+ while( L1Audio_CheckFlag( keytone.aud_id ) )
+ kal_sleep_task( AUD_1TICK(1) );
+ }
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+#endif
+}
+
+void KT_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+ keytone.volume1 = volume1;
+ keytone.digital_gain_index = digital_gain_index;
+}
+
+/*****************************************************************************
+* FUNCTION
+* KT_Play
+* DESCRIPTION
+* This function is used to play keytone.
+*
+* PARAMETERS
+* freq1 - The first frequency
+* freq2 - The second frequency
+* duration - Duration of the tone
+* RETURNS
+* None.
+* GLOBALS AFFECTED
+* None
+*****************************************************************************/
+
+void KT_Play( uint16 freq1, uint16 freq2, uint16 duration )
+{
+ // FIXME:
+ return;
+ // endif
+
+ if( keytone.lock > 0 || keytone.volume1 == 0 )
+ return;
+
+ if( L1Audio_CheckFlag( keytone.aud_id ) )
+ return;
+
+#if !defined(__DISABLE_SKIP_KEYTONE_DURING_TONE_PLAY__)
+ if( L1Audio_CheckFlag( tone.aud_id ) )
+ return;
+#endif
+
+ if( L1Audio_CheckFlag( tone.aud_id ) ) {
+ TONE_Stop();
+ while( L1Audio_CheckFlag( tone.aud_id ) )
+ kal_sleep_task( AUD_1TICK(1) );
+ }
+
+ /* When Tone/KT with volume = 0 lets AFE set DigitalGain = 0, it causes the side effect. At the same time, Speech is muted, becuase digital gain is 0 */
+ if(AM_IsSpeechOn()){
+/*
+ uint8 volume;
+#ifdef ANALOG_AFE_PATH_EXIST
+ int8 digital_gain_index;
+ AFE_GetOutputVolume(L1SP_TONE, &volume, &digital_gain_index);
+#else
+ AFE_DigitalOnly_GetOutputVolume(L1SP_TONE, &volume);
+#endif // ANALOG_AFE_PATH_EXIST
+ if(0 == volume)
+ return;
+*/
+ }
+
+ L1Audio_SetFlag( keytone.aud_id );
+
+ /* keytone in speech mode, need special care */
+#if defined(__BT_SUPPORT__)
+ if( L1SP_IsBluetoothOn() ) {
+ DSP_TONE_AMP2 = KT_INIT_AMP >> 2; /* degrade bluetooth keytone volume by 12dB */
+ Data_Sync_Barrier();
+#if 0
+/* under construction !*/
+/* under construction !*/
+#else //#if 0
+ // FIXME: take care here! still no implement
+ ASSERT(0);
+#endif //#if 0
+ }
+ else
+#endif
+ if( AM_IsSpeechOn() ) { // && AFE_GetOutputDevice(L1SP_KEYTONE)==AFE_GetOutputDevice(L1SP_SPEECH) ) {
+#if 0 // def ANALOG_AFE_PATH_EXIST
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else
+ DSP_TONE_AMP2 = KT_INIT_AMP;
+#endif // ANALOG_AFE_PATH_EXIST
+ Data_Sync_Barrier();
+ }
+ else {
+ DSP_TONE_AMP2 = KT_INIT_AMP;
+ Data_Sync_Barrier();
+#if 0
+/* under construction !*/
+/* under construction !*/
+#else //#if 0
+ // FIXME: take care here! still no implement
+ ASSERT(0);
+#endif //#if 0
+ }
+
+ DSP_KT_FREQ( freq1, freq2 );
+ DSP_TONE_CTRL2 = 1;
+ Data_Sync_Barrier();
+ keytone.isRun = true;
+
+ AM_KeyToneOn();
+ if( (duration = duration / 10) > 0 ) {
+ SGPT_CTRL_START_T start;
+ start.u2Tick = duration;
+ start.pfCallback = ktStop;
+ start.vPara = 0;
+ DclSGPT_Control( keytone.gpt, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ }
+}
+
+/*****************************************************************************
+* FUNCTION
+* KT_Stop
+* DESCRIPTION
+* This function is used to stop key tone playing.
+*****************************************************************************/
+void KT_Stop( void )
+{
+ DclSGPT_Control( keytone.gpt, SGPT_CMD_STOP, 0);
+ ktStop( 0 );
+}
+
+void KT_StopAndWait(void)
+{
+ int I;
+
+ AM_FlushQFunction();
+ KT_Stop();
+
+ for( I = 0; ; I++ ) {
+ if ( !AM_IsKeyToneOn() )
+ break;
+
+ ASSERT_REBOOT(I < 20);
+ kal_sleep_task( AUD_1TICK(2) );
+ }
+ kal_sleep_task( AUD_1TICK(2) );//wait AFE also updated
+}
+
+void KT_SetAmplitude( int16 amp )
+{
+ DSP_TONE_AMP2 = amp;
+ Data_Sync_Barrier();
+}
+
+void KT_SetFIR( bool enable )
+{
+ if( enable ){
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ } else {
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+}
+
+/* To indicate if the keytone can be play */
+kal_bool KT_IsPlayable(void)
+{
+ if( keytone.lock > 0 || keytone.volume1 == 0 )
+ return KAL_FALSE;
+ if( L1Audio_CheckFlag( keytone.aud_id ) || L1Audio_CheckFlag( tone.aud_id ) )
+ return KAL_FALSE;
+ return KAL_TRUE;
+}
diff --git a/mcu/driver/audio/src/v1/tone_drv.c b/mcu/driver/audio/src/v1/tone_drv.c
new file mode 100644
index 0000000..1244f31
--- /dev/null
+++ b/mcu/driver/audio/src/v1/tone_drv.c
@@ -0,0 +1,1306 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * Tone_Drv.c
+ *
+ * Project:
+ * --------
+ * MTK Feature Phone
+ *
+ * Description:
+ * ------------
+ * DTMF tone driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_trace.h"
+#include "dcl.h"
+#include "reg_base.h"
+#include "sync_data.h"
+
+//#include "l1d_reg.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "media.h"
+#include "afe.h"
+#include "afe_def.h"
+#include "am.h"
+#include "speech_def.h"
+// #include "audio_def.h"
+#include "afe_def.h"
+#include "l1audio_trace_utmd.h"
+#include "l1sp_trc.h"
+#include "tone_drv.h"
+#include "sal_exp.h"
+
+#if defined(__CVSD_CODEC_SUPPORT__)
+#include "bt_sco_drv.h"
+#endif
+
+//#pragma arm section code="SECONDARY_ROCODE"
+
+typedef struct _st_DTMF_DSP
+{
+ kal_uint32 uGPT;
+ const L1SP_Tones *pToneList;
+ const L1SP_QTMF *pCurrQtmf;
+ kal_uint16 uCurrentNode;
+ DTMF_DSP_STATE uState;
+ kal_bool fIsQTMF;
+} st_DTMF_DSP;
+
+typedef struct _st_tone
+{
+ const L1SP_Tones *pToneList;
+ const L1SP_QTMF *pCurrQtmf;
+ kal_uint16 uAudId;
+ kal_uint16 amp;
+ void (*fpHandler)(void);
+ //kal_bool fDspToneRunning;
+ //kal_bool fMcuToneRunning;
+ kal_bool fToneRunning;
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ kal_int8 digital_gain_index;
+ TONE_TYPE type;
+ kal_bool fIsQTMF;
+} st_tone;
+
+typedef struct _st_keytone
+{
+ L1SP_Tones dtmf;
+ kal_uint16 uAudId;
+ kal_uint8 lock;
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ kal_int8 digital_gain_index;
+ kal_uint32 gain;
+ //kal_bool fDspToneRunning;
+ //kal_bool fMcuToneRunning;
+ kal_bool fToneRunning;
+
+ TONE_TYPE type;
+ kal_bool fIsQTMF;
+} st_keytone;
+
+static st_DTMF_DSP DTMF_DSP;
+static st_tone tone[TOTAL_TONE_NUM];
+static st_keytone keytone[TOTAL_TONE_NUM];
+
+
+#define DSP_TONE_IDLE 0
+#define DSP_TONE_START 1
+#define DSP_TONE_RUNING 2
+#define DSP_TONE_STOP 4
+
+#define DSP_WAIT_TIME 10 //ms
+#define DSP_STOP_AND_WAIT_MAX_TICK 40 //tick
+/*
+#define DSP_QTMF_FREQ(f1,f2,f3,f4) { SAL_KT2_FREQ1 = (f1); \
+ SAL_KT2_FREQ2 = (f2); \
+ SAL_KT1_FREQ1 = (DTMF_DSP.fIsQTMF)?(f3):0; \
+ SAL_KT1_FREQ2 = (DTMF_DSP.fIsQTMF)?(f4):0; \
+ Data_Sync_Barrier(); }
+*/
+// temp remove for fix build warning
+// static void dtmf_dsp_PlayOn( void *data );
+static void dtmf_dsp_PlayOff( void *data );
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else
+/* under construction !*/
+#endif
+/* under construction !*/
+#endif
+/*
+// temp remove for fix build warning
+static const L1SP_QTMF *dtmf_dsp_GetNextTone(const L1SP_Tones *ppToneList, const L1SP_QTMF *pCurrQTMF, kal_bool fIsQTMF)
+{
+ const L1SP_QTMF *pNextQTMF;
+ if(fIsQTMF)
+ {
+ pNextQTMF = (L1SP_QTMF *)ppToneList + pCurrQTMF->next_tone;
+ }
+ else
+ {
+ pNextQTMF = (L1SP_QTMF *)(ppToneList + pCurrQTMF->next_tone);
+ }
+ return pNextQTMF;
+}
+*/
+
+
+static void dtmf_dsp_SetTimer(kal_uint32 uMsec, void(*fpCallback)( void *pData ))
+{
+ kal_uint16 uDur = uMsec / 10;
+ if(uDur)
+ {
+ SGPT_CTRL_START_T start;
+ start.u2Tick = uDur;
+ start.pfCallback = fpCallback;
+ start.vPara = NULL;
+ DclSGPT_Control( DTMF_DSP.uGPT, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
+ }
+}
+
+static void dtmf_dsp_StopTimer()
+{
+ DclSGPT_Control(DTMF_DSP.uGPT ,SGPT_CMD_STOP, 0);
+}
+
+static void dtmf_dsp_TurnOffDSP(kal_uint32 arg1, void* arg2)
+{
+
+ if(DTMF_DSP.uState != DTMF_DSP_STATE_ENDING)
+ {
+ return;
+ }
+ if(keytone[DSP_TONE].fToneRunning)
+ {
+ AM_KeyToneOff();
+// SAL_KT_ATT_GAIN = 0;
+// Data_Sync_Barrier();
+ keytone[DSP_TONE].fToneRunning = KAL_FALSE;
+ L1Audio_ClearFlag( keytone[DSP_TONE].uAudId );
+ }
+ else if(tone[DSP_TONE].fToneRunning)
+ {
+ AM_ToneOff();
+// SAL_KT_ATT_GAIN = 0;
+// Data_Sync_Barrier();
+ tone[DSP_TONE].fToneRunning = KAL_FALSE;
+ L1Audio_ClearFlag( tone[DSP_TONE].uAudId );
+ }
+ DTMF_DSP.uState = DTMF_DSP_STATE_IDLE;
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+
+static void dtmf_dsp_end( void *fWait )
+{
+ if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE)
+ {
+ return;
+ }
+ dtmf_dsp_StopTimer();
+// if(SAL_KT1_FSM == DSP_TONE_RUNING)
+// {
+// SAL_KT1_FSM = DSP_TONE_STOP;
+// Data_Sync_Barrier();
+// }
+// if(SAL_KT2_FSM == DSP_TONE_RUNING)
+// {
+// SAL_KT2_FSM = DSP_TONE_STOP;
+// Data_Sync_Barrier();
+// }
+// if(SAL_KT1_FSM != DSP_TONE_IDLE || SAL_KT2_FSM != DSP_TONE_IDLE)
+// {
+// dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_end);
+// }
+// else
+// {
+// DTMF_DSP.uState = DTMF_DSP_STATE_ENDING;
+// }
+
+ if(fWait) //in task, stop and wait
+ {
+ kal_int32 I =0;
+ while(DTMF_DSP.uState != DTMF_DSP_STATE_ENDING && DTMF_DSP.uState != DTMF_DSP_STATE_IDLE )
+ {
+
+ //kal_uint16 TONE_CTRL1, TONE_CTRL2; //unused
+ //TONE_CTRL1 = SAL_KT1_FSM;
+ //TONE_CTRL2 = SAL_KT2_FSM;
+ kal_sleep_task( AUD_1TICK(1) );
+ //kal_prompt_trace(MOD_L1SP,"dtmf_dsp_end, TONE_CTRL1[%d]: %d, TONE_CTRL2[%d]: %d", (kal_uint32)DSP_TONE_CTRL1, TONE_CTRL1, (kal_uint32)DSP_TONE_CTRL2, TONE_CTRL2 );
+ ASSERT(I < DSP_STOP_AND_WAIT_MAX_TICK);
+ I++;
+ }
+ dtmf_dsp_TurnOffDSP(0, NULL);
+ }
+ else if(DTMF_DSP.uState == DTMF_DSP_STATE_ENDING) // in timer isr
+ {
+ L1Audio_InProcCall(dtmf_dsp_TurnOffDSP, 0, NULL);
+ }
+}
+
+/*
+// temp remove for fix build warning
+static void dtmf_dsp_PlayOn( void *data )
+{
+ MD_TRC_DTMF_DSP_PLAYON_ENTER();
+ if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE)
+ {
+ return;
+ }
+ DTMF_DSP.pCurrQtmf = dtmf_dsp_GetNextTone( DTMF_DSP.pToneList, DTMF_DSP.pCurrQtmf, DTMF_DSP.fIsQTMF);
+// if(SAL_KT1_FSM == DSP_TONE_IDLE && SAL_KT2_FSM == DSP_TONE_IDLE)
+// {
+// kal_trace( TRACE_FUNC,DTMF_DSP_PLAYON_1);
+// //DSP_QTMF_FREQ( DTMF_DSP.pCurrQtmf->freq1, DTMF_DSP.pCurrQtmf->freq2, DTMF_DSP.pCurrQtmf->freq3, DTMF_DSP.pCurrQtmf->freq4 );
+// SAL_KT1_FSM = DSP_TONE_START;
+// SAL_KT2_FSM = DSP_TONE_START;
+// Data_Sync_Barrier();
+// dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->on_duration, dtmf_dsp_PlayOff);
+// }
+// else
+// { kal_trace( TRACE_FUNC,DTMF_DSP_PLAYON_2);
+// dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_PlayOn);
+// }
+ MD_TRC_DTMF_DSP_PLAYON_LEAVE();
+}
+*/
+
+static void dtmf_dsp_PlayOff( void *data )
+{
+ MD_TRC_DTMF_DSP_PLAYOFF_ENTER();
+ if(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE)
+ {
+ return;
+ }
+// if(SAL_KT1_FSM == DSP_TONE_RUNING && SAL_KT2_FSM == DSP_TONE_RUNING)
+// {
+// SAL_KT1_FSM = DSP_TONE_STOP;
+// SAL_KT2_FSM = DSP_TONE_STOP;
+// Data_Sync_Barrier();
+// if(DTMF_DSP.pCurrQtmf->off_duration)
+// {
+// kal_trace( TRACE_FUNC,DTMF_DSP_PLAYOFF_1);
+// dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->off_duration, dtmf_dsp_PlayOn);
+// DTMF_DSP.uCurrentNode = DTMF_DSP.pCurrQtmf->next_tone;
+// }
+// else
+// {
+// kal_trace( TRACE_FUNC,DTMF_DSP_PLAYOFF_2);
+// dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_end);
+// }
+// }
+// else
+// {
+// dtmf_dsp_SetTimer( DSP_WAIT_TIME, dtmf_dsp_PlayOff);
+// }
+ MD_TRC_DTMF_DSP_PLAYOFF_LEAVE();
+}
+
+static void dtmf_dsp_Start()
+{
+ MD_TRC_DTMF_DSP_START_ENTER();
+ dtmf_dsp_StopTimer();
+ ASSERT(DTMF_DSP.uState == DTMF_DSP_STATE_IDLE);
+ DTMF_DSP.uState = DTMF_DSP_STATE_PLAYING;
+ DTMF_DSP.uCurrentNode = 0;
+ //DSP_QTMF_FREQ( DTMF_DSP.pCurrQtmf->freq1, DTMF_DSP.pCurrQtmf->freq2, DTMF_DSP.pCurrQtmf->freq3, DTMF_DSP.pCurrQtmf->freq4 );
+// SAL_KT1_FSM = DSP_TONE_START;
+// SAL_KT2_FSM = DSP_TONE_START;
+// Data_Sync_Barrier();
+ dtmf_dsp_SetTimer( DTMF_DSP.pCurrQtmf->on_duration, dtmf_dsp_PlayOff);
+ MD_TRC_DTMF_DSP_START_LEAVE();
+}
+
+
+static void DTMF_DSP_Play( const L1SP_Tones *pToneList, kal_bool fIsQtmf, kal_bool fIsKeytone )
+{
+#if 1
+ MD_TRC_DTMF_DSP_PLAY_ENTER();
+ KT_StopAndWait();
+ TONE_StopAndWait();
+ DTMF_DSP.fIsQTMF = fIsQtmf;
+ DTMF_DSP.pCurrQtmf = (const L1SP_QTMF *)pToneList;
+ if(fIsKeytone)
+ {
+ L1Audio_SetFlag( keytone[DSP_TONE].uAudId );
+ }
+ else
+ {
+ L1Audio_SetFlag( tone[DSP_TONE].uAudId );
+ if( AM_IsSpeechOn() ) //only apply on tone
+ {
+// SAL_KT_ATT_GAIN = 0x4000;
+// Data_Sync_Barrier();
+ }
+ }
+
+#if defined(__BT_SUPPORT__)
+ if( L1SP_IsBluetoothOn() )
+ {
+// SAL_KT1_AMP = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */
+// SAL_KT2_AMP = (TONE_INIT_AMP >> 2); /* degrade bluetooth tone volume by 12dB */
+// Data_Sync_Barrier();
+ // *DP_VSBT_CTRL |= 0x1; // output to both BT and voice DAC
+ }
+ else
+#endif
+ {
+// SAL_KT1_AMP = tone[DSP_TONE].amp;
+// SAL_KT2_AMP = tone[DSP_TONE].amp;
+// Data_Sync_Barrier();
+ }
+ if(fIsKeytone)
+ {
+ keytone[DSP_TONE].fToneRunning = KAL_TRUE;
+ AM_KeyToneOn();
+ }
+ else
+ {
+ tone[DSP_TONE].fToneRunning = KAL_TRUE;
+ AM_ToneOn();
+ }
+ dtmf_dsp_Start();
+ MD_TRC_DTMF_DSP_PLAY_LEAVE();
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__BT_SUPPORT__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+
+static void DTMF_DSP_Stop( kal_bool fWait)
+{
+ dtmf_dsp_end( (void*)fWait );
+}
+
+void toneInit( uint16 uAudId, uint16 id_num )
+{
+ ASSERT( id_num < TOTAL_TONE_NUM );
+
+ tone[id_num].type = id_num;
+
+ if(id_num == DSP_TONE)
+ {
+ DTMF_DSP.uGPT = DclSGPT_Open( DCL_GPT_CB ,0 );
+ tone[DSP_TONE].uAudId = uAudId;
+ tone[DSP_TONE].amp = TONE_INIT_AMP;
+// SAL_KT_ATT_GAIN = 0;
+// SAL_KT1_FSM = 0;
+// SAL_KT2_FSM = 0;
+// Data_Sync_Barrier();
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+ else
+ {
+ tone[id_num].uAudId = uAudId;
+ tone[id_num].amp = TONE_INIT_AMP;
+ }
+/* DTMF_DSP.uGPT = DclSGPT_Open( DCL_GPT_CB ,0 );
+ tone.uAudId = uAudId;
+ tone.amp = TONE_INIT_AMP;
+ SAL_KT_ATT_GAIN = 0;
+ SAL_KT1_FSM = 0;
+ SAL_KT2_FSM = 0;
+ Data_Sync_Barrier();
+#ifdef ANALOG_AFE_PATH_EXIST
+ AFE_TurnOnFIR( L1SP_TONE );
+#endif */
+}
+
+void ktInit( uint16 uAudId, uint16 id_num )
+{
+ ASSERT( id_num < TOTAL_TONE_NUM );
+
+ keytone[id_num].type = id_num;
+
+ if(id_num == DSP_TONE)
+ {
+ keytone[DSP_TONE].uAudId = uAudId;
+ keytone[DSP_TONE].lock = 0;
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ keytone[DSP_TONE].gain = 0;
+ keytone[DSP_TONE].digital_gain_index = 0;
+// SAL_KT2_AMP = KT_INIT_AMP;
+// Data_Sync_Barrier();
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+ else
+ {
+ keytone[id_num].uAudId = uAudId;
+ keytone[id_num].lock = 0;
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ keytone[id_num].gain = 0;
+ keytone[id_num].digital_gain_index = 0;
+ }
+/* keytone.uAudId = uAudId;
+ keytone.lock = 0;
+#ifdef ANALOG_AFE_PATH_EXIST
+ keytone.volume1 = 160;
+#endif
+ keytone.gain = 0;
+ keytone.digital_gain_index = 0;
+ SAL_KT2_AMP = KT_INIT_AMP;
+ Data_Sync_Barrier();
+#ifdef ANALOG_AFE_PATH_EXIST
+ AFE_TurnOnFIR( L1SP_KEYTONE );
+#endif */
+}
+
+void ktLock( void )
+{
+ ASSERT( keytone[DSP_TONE].lock < DTMF_KEYTONE_LOCK_MAX_COUNT );
+
+ keytone[DSP_TONE].lock++;
+}
+
+void ktUnlock( void )
+{
+ ASSERT( keytone[DSP_TONE].lock > 0 );
+
+ keytone[DSP_TONE].lock--;
+}
+
+void TONE_SetOutputDevice( uint8 device )
+{
+ //DTMF_MCU_StopAndWait();
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+}
+
+void TONE_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ tone[DSP_TONE].digital_gain_index = digital_gain_index;
+}
+
+void TONE_SetOutputGainControl( uint32 gain )
+{
+#if defined(__GAIN_TABLE_SUPPORT__)
+ //AFE_SetOutputGainControl( L1SP_TONE, gain );
+#endif
+}
+
+kal_bool TONE_DspPlayable(void)
+{
+
+ // kal_uint8 iDigiGainIndex;
+
+ if(/*AM_IsAVsyncOn() || AM_IsDAIMode() ||*/ AM_IsAudioPlaybackOn() != -1)
+ return KAL_FALSE;
+ if(tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning )
+ return KAL_FALSE;
+ if(keytone[DSP_TONE].lock)
+ return KAL_FALSE;
+
+ // RIMIND: if uVolume == 0 (mute, the function return KAL_FALSE;
+/*
+#ifdef ANALOG_AFE_PATH_EXIST
+{
+ kal_uint8 uVolume;
+ AFE_GetOutputVolume(L1SP_TONE, &uVolume, &iDigiGainIndex);
+}
+#else //#if 0
+ AFE_DigitalOnly_GetOutputVolume(L1SP_TONE, &iDigiGainIndex );
+#endif //#if 0
+
+#ifdef ANALOG_AFE_PATH_EXIST
+ if(0 == uVolume || tone[DSP_TONE].volume1 == 0)
+ return KAL_FALSE;
+#endif
+*/
+ return KAL_TRUE;
+}
+
+void TONE_Play( const L1SP_Tones *pToneList, TONE_TYPE type)
+{
+ ASSERT( type < TOTAL_TONE_NUM );
+
+#if defined(__AUDIO_NOT_SUPPORTED__)
+ return;
+#endif
+
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+
+// if(AM_IsAfeOn()) return;
+ MD_TRC_TONEPLAY(0);
+
+ if(type == DSP_TONE)
+ {
+
+ // [RIMIND]for idel DSP tone play, please remind to set digital gain
+ // AFE_DigitalOnly_SetDigitalGain( L1SP_TONE, tone[DSP_TONE].digital_gain_index );
+
+
+ MD_TRC_TONEPLAY(1);
+ if(!TONE_DspPlayable())
+ {
+ MD_TRC_TONEPLAY(2);
+ return;
+ }
+ DTMF_DSP.fIsQTMF = KAL_FALSE;
+ tone[DSP_TONE].fIsQTMF = KAL_FALSE;
+ DTMF_DSP.uCurrentNode = 0;
+ DTMF_DSP.pToneList = pToneList;
+ tone[DSP_TONE].fToneRunning = KAL_TRUE;
+ DTMF_DSP_Play((const L1SP_Tones *)pToneList, tone[DSP_TONE].fIsQTMF/*DTMF_DSP.fIsQTMF*/, KAL_FALSE);
+ MD_TRC_TONEPLAY(3);
+ }
+ else
+ {
+ tone[type].fIsQTMF = KAL_FALSE;
+
+ //tone[type].type = type;
+
+ MD_TRC_TONEPLAY(5);
+ tone[type].fToneRunning = KAL_TRUE;
+ DTMF_MCU_Play((const L1SP_Tones *)pToneList, tone[type].fIsQTMF/*DTMF_DSP.fIsQTMF*/, KAL_FALSE);
+
+ //AM_ToneOn();
+
+ MD_TRC_TONEPLAY(6);
+ }
+
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /*#if 0*/
+}
+
+void TONE_PlayQTMF( const L1SP_QTMF *pToneList )
+{
+ //DTMF_DSP.fIsQTMF = KAL_TRUE;
+ //TONE_Play((const L1SP_Tones *)pToneList);
+}
+
+
+void TONE_Stop( TONE_TYPE type )
+{
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ MD_TRC_TONESTOP();
+
+ if(type == DSP_TONE)
+ {
+ if(tone[DSP_TONE].fToneRunning)
+ {
+ DTMF_DSP_Stop(KAL_FALSE);
+ }
+ }
+ else
+ {
+ if(tone[type].fToneRunning)
+ {
+ DTMF_MCU_Stop(KAL_FALSE);
+ tone[type].fToneRunning = KAL_FALSE;
+ }
+ }
+/* if(tone.fDspToneRunning)
+ {
+ DTMF_DSP_Stop(KAL_FALSE);
+ }
+ else if(tone.fMcuToneRunning)
+ {
+ DTMF_MCU_Stop(KAL_FALSE);
+ tone.fMcuToneRunning = KAL_FALSE;
+ }*/
+}
+
+void TONE_StopAndWait( void )
+{
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ if(!tone[DSP_TONE].fToneRunning)
+ {
+ return;
+ }
+ AM_FlushQFunction();
+ DTMF_DSP_Stop(KAL_TRUE);
+}
+
+void TONE_SetAmplitude( int16 amp )
+{
+ //tone.amp = (uint16)amp;
+ tone[DSP_TONE].amp = (uint16)amp;
+}
+
+void TONE_SetFIR( bool enable )
+{
+ if( enable )
+ {
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+ else
+ {
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+}
+
+void TONE_SetHandler( void (*fpHandler)(void), TONE_TYPE type )
+{
+ //tone.fpHandler = fpHandler; //callback when tone stop done
+ tone[type].fpHandler = fpHandler; //callback when tone stop done
+}
+
+kal_bool KT_DspPlayable(void)
+{
+
+ // kal_uint8 iDigiGainIndex;
+
+ if(/*AM_IsAVsyncOn() || AM_IsDAIMode() || */AM_IsAudioPlaybackOn() != -1)
+ return KAL_FALSE;
+ if(tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning )
+ return KAL_FALSE;
+ if(keytone[DSP_TONE].lock)
+ return KAL_FALSE;
+
+
+ // REMIND, if keytone volume is 0 (mute). it should return KAL_FALSE
+
+/*
+ AFE_DigitalOnly_GetOutputVolume(L1SP_KEYTONE, &iDigiGainIndex );
+*/
+
+/*
+#ifdef ANALOG_AFE_PATH_EXIST
+ if(0 == uVolume || keytone[DSP_TONE].volume1 == 0)
+ return KAL_FALSE;
+#endif
+*/
+
+ return KAL_TRUE;
+}
+
+void KT_SetOutputDevice( uint8 device )
+{
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ KT_StopAndWait();
+ if(DTMF_MCU_IsKeytonePlaying()) // && device != AFE_GetOutputDevice(L1SP_KEYTONE)) single output
+ {
+ DTMF_MCU_StopAndWait();
+ }
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+}
+
+void KT_SetOutputVolume( uint8 volume1, int8 digital_gain_index )
+{
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ keytone[DSP_TONE].digital_gain_index = digital_gain_index;
+}
+
+bool PcmSink_IsAudioRuning()
+{
+ return false;
+}
+
+void KT_SetOutputGainControl( uint32 gain )
+{
+#if defined(__GAIN_TABLE_SUPPORT__)
+ //keytone.gain = gain;
+ keytone[DSP_TONE].gain = gain;
+ AFE_SetOutputGainControl(L1SP_KEYTONE, gain);
+#endif
+}
+
+void KT_Play( kal_uint16 freq1, kal_uint16 freq2, kal_uint16 duration, TONE_TYPE type) //duration in msec
+{
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ MD_TRC_KTPLAY(0);
+#if defined(KEYTONE_DEBUG)
+ Keytone_Debug_Entry(freq1, freq2);
+ return;
+#endif
+#if defined(__AUDIO_NOT_SUPPORTED__)
+ return;
+#endif
+
+
+ if(type == DSP_TONE)
+ {
+ MD_TRC_KTPLAY(1);
+
+ // [RIMIND]for idel DSP tone play, please remind to set digital gain
+ // AFE_DigitalOnly_SetDigitalGain( L1SP_KEYTONE, keytone[DSP_TONE].digital_gain_index );
+
+ if(!KT_DspPlayable())
+ {
+ MD_TRC_KTPLAY(2);
+ return;
+ }
+
+ keytone[DSP_TONE].dtmf.freq1 = freq1;
+ keytone[DSP_TONE].dtmf.freq2 = freq2;
+ keytone[DSP_TONE].dtmf.on_duration = duration;
+ keytone[DSP_TONE].dtmf.off_duration = 0;
+ //keytone[DSP_TONE].type = type;
+ MD_TRC_KTPLAY(3);
+
+ DTMF_DSP_Play((const L1SP_Tones *)&keytone[DSP_TONE].dtmf, KAL_FALSE, KAL_TRUE);
+ MD_TRC_KTPLAY(4);
+ }
+ else
+ {
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+ if(PcmSink_IsAudioRuning() || DTMF_MCU_IsTonePlaying() /*|| AM_IsAfeOn()*/)
+ {
+ return; //disable keytone during audio playback
+ }
+#endif //defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+
+ MD_TRC_KTPLAY(5);
+ keytone[type].dtmf.freq1 = freq1;
+ keytone[type].dtmf.freq2 = freq2;
+ keytone[type].dtmf.on_duration = duration;
+ keytone[type].dtmf.off_duration = 0;
+ //keytone[DSP_TONE].type = type;
+
+ MD_TRC_KTPLAY(6);
+ keytone[type].fToneRunning = KAL_TRUE;
+ DTMF_MCU_Play((const L1SP_Tones *)&keytone[type].dtmf, KAL_FALSE, KAL_TRUE);
+
+ MD_TRC_KTPLAY(7);
+ }
+
+#if 0
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /*#if 1*/
+}
+
+void KT_Stop( TONE_TYPE type )
+{
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ MD_TRC_KTSTOP();
+
+ if(type == DSP_TONE)
+ {
+ if(keytone[DSP_TONE].fToneRunning)
+ {
+ DTMF_DSP_Stop(KAL_FALSE);
+ }
+ }
+ else
+ {
+ if(keytone[type].fToneRunning)
+ {
+ DTMF_MCU_Stop(KAL_TRUE);
+ keytone[type].fToneRunning = KAL_FALSE;
+ }
+ }
+ return;
+
+/* if(keytone.fDspToneRunning)
+ {
+ DTMF_DSP_Stop(KAL_FALSE);
+ }else
+ if(keytone.fMcuToneRunning)
+ {
+ DTMF_MCU_Stop(KAL_TRUE);
+ keytone.fMcuToneRunning = KAL_FALSE;
+ }
+ return;*/
+}
+
+void KT_StopAndWait()
+{
+
+
+#ifndef __VOLTE_SUPPORT__
+ return;
+#endif //#ifndef __VOLTE_SUPPORT__
+
+ //if(!keytone.fDspToneRunning)
+ if(!keytone[DSP_TONE].fToneRunning)
+ {
+ return;
+ }
+ AM_FlushQFunction();
+ DTMF_DSP_Stop(KAL_TRUE);
+}
+
+void KT_SetAmplitude( int16 amp )
+{
+// SAL_KT2_AMP = amp;
+// Data_Sync_Barrier();
+}
+
+void KT_SetFIR( bool enable )
+{
+ if( enable )
+ {
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+ else
+ {
+#if 0
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+}
+
+kal_bool KT_IsPlayable(void)
+{
+ // kal_uint8 uVolume;
+ // kal_int8 iDigiGainIndex;
+ if(keytone[DSP_TONE].fToneRunning)//(dtmf_dsp_DspToneCase())
+ {
+ return KT_DspPlayable();
+ }
+ else
+ {
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+ if(PcmSink_IsAudioRuning() || tone[DSP_TONE].fToneRunning || keytone[DSP_TONE].fToneRunning)
+ {
+ return KAL_FALSE; //disable keytone during audio playback
+ }
+#endif
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif //#if 0
+ }
+ return KAL_FALSE;
+
+/*
+ kal_uint8 uVolume;
+ kal_int8 iDigiGainIndex;
+ if( DSP_TONE == keytone.type )//(dtmf_dsp_DspToneCase())
+ {
+ return KT_DspPlayable();
+ }
+ else
+ {
+#if defined(__MCU_DTMF_SUPPORT__) //&& !defined( MED_MODEM )
+ if(PcmSink_IsAudioRuning() || tone.fDspToneRunning || keytone.fDspToneRunning)
+ {
+ return KAL_FALSE; //disable keytone during audio playback
+ }
+
+#endif
+ AFE_GetOutputVolume(L1SP_KEYTONE, &uVolume, &iDigiGainIndex);
+#ifdef ANALOG_AFE_PATH_EXIST
+ if(0 == uVolume || keytone.volume1 == 0)
+ {
+ return KAL_FALSE;
+ }
+#endif
+ }
+*/
+}
+
+//#pragma arm section
+
diff --git a/mcu/driver/audio/src/v1/vm.c b/mcu/driver/audio/src/v1/vm.c
new file mode 100644
index 0000000..d310759
--- /dev/null
+++ b/mcu/driver/audio/src/v1/vm.c
@@ -0,0 +1,2772 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename:
+ * ---------
+ * vm.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * VM recording/playback
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "string.h"
+#include "reg_base.h"
+#include "kal_trace.h"
+
+#include "speech_def.h"
+#include "l1aud_common_def.h"
+#include "l1audio.h"
+#include "l1audio_trace_utmd.h"
+#include "l1audio_voc_utmd.h"
+#include "sp_drv.h"
+#include "pcm4way.h"
+#include "am.h"
+#include "media.h"
+#include "afe.h"
+#include "l1sp_trc.h"
+#include "l1audio_sph_trc.h"
+#include "sal_exp.h"
+#include "sal_def.h"
+#include "vm.h"
+#include "gmss_public.h"
+
+/* ------------------------------------------------------------------------------ */
+#define VM_4G_G_SERIAL_DEBUG
+
+#if defined( __UMTS_RAT__ )
+#define _EXTRA_LOG_FOR_BIT_TRUE_
+#endif
+
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+extern kal_bool g_bNeedExtraLog;
+#endif
+
+/* ------------------------------------------------------------------------------ */
+#define VM_STATE_RECORD 0x1
+#define VM_STATE_STOP 0x10
+#define VM_STATE_RECORD_STOP 0x20 // entering vmStop
+
+#define VM_VM_MAGIC_HEADER 0xBB88
+
+#define VM_VM_CTRL_UL_ON 0x0001
+#define VM_VM_CTRL_DL_ON 0x0001
+
+#define VM_EPL_1STSET_RECORD_FLAG 0x0001
+#define VM_EPL_2NDSET_RECORD_FLAG 0x0002
+#define VM_VM_RECORD_FLAG 0x0004
+#define VM_EPL_REFMIC_RECORD_FLAG 0x0008
+#define VM_EPL_ECHOREF_RECORD_FLAG 0x0010
+#define VM_EPL_3RDMIC_RECORD_FLAG 0x0020
+#define VM_EPL_2NDECHOREF_RECORD_FLAG 0x0040
+#define VM_EPL_ALL_RECORD_FLAG (VM_EPL_1STSET_RECORD_FLAG + VM_EPL_2NDSET_RECORD_FLAG + VM_EPL_REFMIC_RECORD_FLAG + VM_EPL_ECHOREF_RECORD_FLAG + VM_EPL_3RDMIC_RECORD_FLAG + VM_EPL_2NDECHOREF_RECORD_FLAG)
+
+#define VM_EPL_BAND_UL0_SHIFT 0
+#define VM_EPL_BAND_UL1_SHIFT 2
+#define VM_EPL_BAND_DL0_SHIFT 4
+#define VM_EPL_BAND_DL1_SHIFT 6
+#define VM_EPL_BAND_UL2_SHIFT 8
+#define VM_EPL_BAND_UL4_SHIFT 10
+#define VM_EPL_BAND_UL3_SHIFT 12
+#define VM_EPL_BAND_UL5_SHIFT 14
+
+#define VM_VM_HEADER_SIZE 6
+#define VM_VM_CONTROL_SIZE 10
+#define VM_VM_MAX_HB_WORD_SIZE ((160+2)*3) // EVS_128000: 2560 bits = 160 words, UL + DL + DL2
+
+#define VM_VM_SCH_DBGINFO_SIZE 100
+#define VM_VM_ENH_DBGINFO_SIZE 160
+#define VM_VM_DRV_DBGINFO_SIZE 20
+#define VM_VM_SVC_DBGINFO_SIZE 20
+#define VM_VM_DBGINFO_TOTAL_SIZE (VM_VM_SCH_DBGINFO_SIZE + VM_VM_ENH_DBGINFO_SIZE + VM_VM_DRV_DBGINFO_SIZE + VM_VM_SVC_DBGINFO_SIZE)
+
+#define VM_VM_BUFFER_SIZE (VM_VM_HEADER_SIZE + VM_VM_CONTROL_SIZE + VM_VM_MAX_HB_WORD_SIZE + VM_VM_DBGINFO_TOTAL_SIZE)
+
+#define VM_EPL_1STSET_SIZE (SAL_FB_PCM_SIZE + SAL_FB_PCM_SIZE + 2)
+#define VM_EPL_2NDSET_SIZE (SAL_FB_PCM_SIZE + SAL_FB_PCM_SIZE + 2)
+#define VM_EPL_REFMIC_SIZE (SAL_FB_PCM_SIZE + 2 + 2)
+#define VM_EPL_ECHOREF_SIZE (SAL_FB_PCM_SIZE + 2)
+#define VM_EPL_3RDMIC_SIZE (SAL_FB_PCM_SIZE + 2)
+#define VM_EPL_2NDECHOREF_SIZE (SAL_FB_PCM_SIZE + 2)
+
+#define VM_EPL_PCM_BUFFER_SIZE VM_EPL_1STSET_SIZE
+#define VM_EPL_TOTAL_SIZE (VM_EPL_1STSET_SIZE + VM_EPL_2NDSET_SIZE + VM_EPL_REFMIC_SIZE + VM_EPL_ECHOREF_SIZE + VM_EPL_3RDMIC_SIZE + VM_EPL_2NDECHOREF_SIZE)
+
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+#define G_CODEC_UL_INFO_HEADER_MAGIC_NUMBER (0x6666)
+#define G_CODEC_DL_INFO_HEADER_MAGIC_NUMBER (0x6667)
+//G.722 bitstream 20ms 160byte
+//G.711 bitstream 10ms 80byte
+//store max 4frame
+#define G_CODEC_MAX_FRAME_NUMBER (4)
+//stream_size+stream
+#define G_CODEC_BITSTREAM_BUFFER_BYTE_SIZE (1*2+80)
+//lost_info + system_time + codec + codec_parameters
+#define G_CODEC_UL_INFO_BYTE_SIZE (4*2)
+//lost_info + system_time + codec + codec_parameters + DL_PCM_buffer_size
+#define G_CODEC_DL_INFO_BYTE_SIZE (5*2)
+//header_magic_number+info_size+info_struct
+#define G_CODEC_UL_INFO_TOTAL_BYTE_SIZE (2*2+G_CODEC_UL_INFO_BYTE_SIZE)
+//header_magic_number+info_size+info_struct
+#define G_CODEC_DL_INFO_TOTAL_BYTE_SIZE (2*2+G_CODEC_DL_INFO_BYTE_SIZE)
+//total byte size
+#define G_CODEC_UL_BITSTREAM_TOTAL_BYTE_SIZE ((G_CODEC_UL_INFO_TOTAL_BYTE_SIZE+G_CODEC_BITSTREAM_BUFFER_BYTE_SIZE)*G_CODEC_MAX_FRAME_NUMBER)
+#define G_CODEC_DL_BITSTREAM_TOTAL_BYTE_SIZE ((G_CODEC_DL_INFO_TOTAL_BYTE_SIZE+G_CODEC_BITSTREAM_BUFFER_BYTE_SIZE)*G_CODEC_MAX_FRAME_NUMBER)
+#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+#define G_CODEC_MAX_HB_WORD_SIZE (((G_CODEC_UL_BITSTREAM_TOTAL_BYTE_SIZE+1)>>1) + ((G_CODEC_DL_BITSTREAM_TOTAL_BYTE_SIZE+1)>>1))
+//#define VMREC_OUTPUT_BUF_SIZE (2 * (VM_VM_BUFFER_SIZE + VM_EPL_TOTAL_SIZE + G_CODEC_MAX_HB_WORD_SIZE))
+#define VMREC_OUTPUT_BUF_SIZE 8000 // [REMIND] Please notify AP speech owner when vm buffer change
+#else
+//#define VMREC_OUTPUT_BUF_SIZE (2 * (VM_VM_BUFFER_SIZE + VM_EPL_TOTAL_SIZE))
+#define VMREC_OUTPUT_BUF_SIZE 8000 // [REMIND] Please notify AP speech owner when vm buffer change
+#endif
+
+#define VM_3G_NETWORK_INFO_LEN 7
+
+/* ------------------------------------------------------------------------------ */
+static struct
+{
+ kal_spinlockid lockId;
+ void (*vm_hdlr)(void); // callback function for vm logging
+ bool isVocOn; // only use under call AM_IsSpeechOn()
+ bool isVmLOn; // only use under call AM_IsSpeechOn()
+ bool isMosaic;
+
+ uint16 audId;
+ uint16 state; // record DSP runnning status (including 2 hisr)
+
+ uint16 record_info; // record flag, only use to control EPL record though it also has VM record flag
+
+ uint16 control_1;
+ uint16 control_2;
+ uint16 control_3;
+ uint16 control_4;
+ uint16 control_5;
+ uint16 control_6;
+ uint16 control_7;
+ uint16 control_8;
+ uint16 control_9;
+ uint16 control_10;
+
+ uint16 evs_cur_sd_mode;
+ uint16 sc_len;
+ uint16 sd_len; // sd1_len + sd2_len
+
+ uint16 vm_lost_count; // For record EPL dummy
+ uint16 pcm_lost_count; // For record EPL dummy
+ uint16 vm_counter; // For record EPL dummy
+
+ uint16 *vmBuf; // point to buffer for VM
+ uint16 *pcmBuf; // point to temp buffer to get EPL from DSP in N times
+
+ // related to 'vmRecOutputBuf', which is cycular buffer use to buffer formatted vm data from dsp
+ uint16 pOutputBufWrite;
+ uint16 pOutputBufRead;
+ uint16 outputBufSize;
+} vm;
+
+uint16 vm3GNetworkInfo[VM_3G_NETWORK_INFO_LEN];
+
+static kal_uint16 vmBuffer[VM_VM_BUFFER_SIZE];
+static kal_uint16 vmEPLPCMInputBuf[VM_EPL_PCM_BUFFER_SIZE];
+static kal_uint16 vmRecOutputBuf[VMREC_OUTPUT_BUF_SIZE];
+
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+static kal_uint32 vmGCodecULBitstreamBuf[(G_CODEC_UL_BITSTREAM_TOTAL_BYTE_SIZE + 3) / sizeof(kal_uint32)];
+static kal_uint32 vmGCodecDLBitstreamBuf[(G_CODEC_DL_BITSTREAM_TOTAL_BYTE_SIZE + 3) / sizeof(kal_uint32)];
+static kal_uint32 vmGCodecULBufWritePos;
+static kal_uint32 vmGCodecDLBufWritePos;
+static kal_uint32 vmGCodecULBufLastHeaderPos;
+static kal_uint32 vmGCodecDLBufLastHeaderPos;
+static kal_uint16 *p16vmGCodecULBitstreamBuf;
+static kal_uint16 *p16vmGCodecDLBitstreamBuf;
+#endif
+
+/* ------------------------------------------------------------------------------ */
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+void vmInitGCodecULBuf(void)
+{
+ //memset(vmGCodecULBitstreamBuf, 0, sizeof(vmGCodecULBitstreamBuf));
+ p16vmGCodecULBitstreamBuf = (kal_uint16 *)vmGCodecULBitstreamBuf;
+ vmGCodecULBufWritePos = 0;
+ vmGCodecULBufLastHeaderPos = 0;
+}
+
+void vmInitGCodecDLBuf(void)
+{
+ //memset(vmGCodecDLBitstreamBuf, 0, sizeof(vmGCodecDLBitstreamBuf));
+ p16vmGCodecDLBitstreamBuf = (kal_uint16 *)vmGCodecDLBitstreamBuf;
+ vmGCodecDLBufWritePos = 0;
+ vmGCodecDLBufLastHeaderPos = 0;
+}
+#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+
+void vmStoreGCodecULStream(vmGCodecULInfo *pstvmGCodecULInfo, kal_uint16 u16StreamSize, kal_uint8 *pu8StreamData)
+{
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ kal_uint32 u32TotalBufferSize = sizeof(vmGCodecULBitstreamBuf) >> 1;
+ //bytesize: G_CODEC_UL_INFO_TOTAL_BYTE_SIZE + stream_size + stream_data[]
+ //>>1 => 2byte size
+ kal_uint32 u32NeedSize = (G_CODEC_UL_INFO_TOTAL_BYTE_SIZE + 2 + u16StreamSize + 1) >> 1;
+ kal_uint32 i, j;
+ kal_uint16 u16tempData;
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_ULSTREAM_ENTER();
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+
+ // dsp status check
+ if (vm.state != VM_STATE_RECORD)
+ {
+ return;
+ }
+
+ // application status check
+ if ( (false == vm.isVocOn) && (false == vm.isVmLOn)) // (false == vm.isIdleVmOn) &&
+ {
+ return;
+ }
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_ULSTREAM_INFO1(u32TotalBufferSize, vmGCodecULBufWritePos, ((u16StreamSize + 1) >> 1), u16StreamSize);
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+
+ if ( (u32TotalBufferSize - vmGCodecULBufWritePos) >= u32NeedSize )
+ {
+ vmGCodecULBufLastHeaderPos = vmGCodecULBufWritePos;
+
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = G_CODEC_UL_INFO_HEADER_MAGIC_NUMBER;
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = G_CODEC_UL_INFO_BYTE_SIZE >> 1;
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = pstvmGCodecULInfo->drop_info;
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = (kal_uint16)(ust_get_current_time() / 1000); //ust_get_current_time(): unit is micro second (us) => ust_get_current_time()/1000: unit is ms
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = pstvmGCodecULInfo->codec;
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = pstvmGCodecULInfo->codec_parameters;
+ vmGCodecULBufWritePos++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = u16StreamSize;
+ vmGCodecULBufWritePos++;
+ j = 0;
+ for (i = 0; i < (u16StreamSize >> 1); i++)
+ {
+ u16tempData = pu8StreamData[j];
+ j++;
+ u16tempData = (u16tempData << 8) | pu8StreamData[j];
+ j++;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = u16tempData;
+ vmGCodecULBufWritePos++;
+ }
+ if (u16StreamSize & 0x01)
+ {
+ u16tempData = pu8StreamData[j];
+ u16tempData = (u16tempData << 8) | u16tempData;
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufWritePos] = u16tempData;
+ vmGCodecULBufWritePos++;
+ }
+ }
+ else
+ {
+ MD_TRC_VM_GFORM_ULSTREAM_INFO2(u32NeedSize, u32TotalBufferSize - vmGCodecULBufWritePos);
+ if (vmGCodecULBufWritePos != 0)
+ {
+ p16vmGCodecULBitstreamBuf[vmGCodecULBufLastHeaderPos + 2] += 0x0100;
+ }
+ else
+ {
+ MD_TRC_VM_GFORM_ULSTREAM_INFO3(u32NeedSize, u32TotalBufferSize);
+ }
+ }
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_ULSTREAM_EXIT();
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+}
+
+void vmStoreGCodecDLStream(vmGCodecDLInfo *pstvmGCodecDLInfo, kal_uint16 u16StreamSize, kal_uint8 *pu8StreamData)
+{
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ kal_uint32 u32TotalBufferSize = sizeof(vmGCodecDLBitstreamBuf) >> 1;
+ //bytesize: G_CODEC_DL_INFO_TOTAL_BYTE_SIZE + stream_size + stream_data[]
+ //>>1 => 2byte size
+ kal_uint32 u32NeedSize = (G_CODEC_DL_INFO_TOTAL_BYTE_SIZE + 2 + u16StreamSize + 1) >> 1;
+ kal_uint32 i, j;
+ kal_uint16 u16tempData;
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_DLSTREAM_ENTER();
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+
+ // dsp status check
+ if (vm.state != VM_STATE_RECORD)
+ {
+ return;
+ }
+
+ // application status check
+ if ( (false == vm.isVocOn) && (false == vm.isVmLOn)) // (false == vm.isIdleVmOn) &&
+ {
+ return;
+ }
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_DLSTREAM_INFO1(u32TotalBufferSize, vmGCodecDLBufWritePos, ((u16StreamSize + 1) >> 1), u16StreamSize);
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+
+ if ( (u32TotalBufferSize - vmGCodecDLBufWritePos) >= u32NeedSize )
+ {
+ vmGCodecDLBufLastHeaderPos = vmGCodecDLBufWritePos;
+
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = G_CODEC_DL_INFO_HEADER_MAGIC_NUMBER;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = G_CODEC_DL_INFO_BYTE_SIZE >> 1;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = pstvmGCodecDLInfo->drop_info;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = (kal_uint16)(ust_get_current_time() / 1000); //ust_get_current_time(): unit is micro second (us) => ust_get_current_time()/1000: unit is ms
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = pstvmGCodecDLInfo->codec;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = pstvmGCodecDLInfo->codec_parameters;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = pstvmGCodecDLInfo->DL_PCM_size;
+ vmGCodecDLBufWritePos++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = u16StreamSize;
+ vmGCodecDLBufWritePos++;
+ j = 0;
+ for (i = 0; i < (u16StreamSize >> 1); i++)
+ {
+ u16tempData = pu8StreamData[j];
+ j++;
+ u16tempData = (u16tempData << 8) | pu8StreamData[j];
+ j++;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = u16tempData;
+ vmGCodecDLBufWritePos++;
+ }
+ if (u16StreamSize & 0x01)
+ {
+ u16tempData = pu8StreamData[j];
+ u16tempData = (u16tempData << 8) | u16tempData;
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufWritePos] = u16tempData;
+ vmGCodecDLBufWritePos++;
+ }
+ }
+ else
+ {
+ MD_TRC_VM_GFORM_DLSTREAM_INFO2(u32NeedSize, u32TotalBufferSize - vmGCodecDLBufWritePos);
+ if (vmGCodecDLBufWritePos != 0)
+ {
+ p16vmGCodecDLBitstreamBuf[vmGCodecDLBufLastHeaderPos + 2] += 0x0100;
+ }
+ else
+ {
+ MD_TRC_VM_GFORM_DLSTREAM_INFO3(u32NeedSize, u32TotalBufferSize);
+ }
+ }
+
+#ifdef VM_4G_G_SERIAL_DEBUG
+ MD_TRC_VM_GFORM_DLSTREAM_EXIT();
+#endif //#ifdef VM_4G_G_SERIAL_DEBUG
+#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+}
+
+void vmSet3GNetworkInfo( uint32 *l1_info, uint16 crc_result, uint16 buf_status, uint8 dl_count )
+{
+ kal_int16 tpc_SIR_lta, dpdch_SIR_lta, TFCI_max_corr, I;
+ uint32 l1Info, s_value;
+ if ( l1_info == NULL ) {
+ l1Info = 0;
+ tpc_SIR_lta = 0;
+ dpdch_SIR_lta = 0;
+ TFCI_max_corr = 0;
+ s_value = 0;
+ } else {
+ l1Info = l1_info[1];
+ tpc_SIR_lta = l1_info[4];
+ dpdch_SIR_lta = l1_info[5];
+ TFCI_max_corr = l1_info[6];
+ s_value = l1_info[3];
+ }
+ I = (uint16)(l1Info & 0xFFFF);
+ vm3GNetworkInfo[4] = I;
+
+ I = (uint16)(l1Info >> 16);
+ vm3GNetworkInfo[5] = I;
+
+ vm3GNetworkInfo[3] = crc_result;
+
+
+ vm3GNetworkInfo[6] = (uint16)((s_value >= 32767) ? 32767 : s_value); //s_value
+
+ vm3GNetworkInfo[0] = (uint16)tpc_SIR_lta;
+ vm3GNetworkInfo[1] = (uint16)dpdch_SIR_lta;
+ vm3GNetworkInfo[2] = (uint16)TFCI_max_corr;
+}
+
+static uint16 vmEPLBandSet(uint16 u2EPLBufLen, uint16 u2EPLBufShift)
+{
+ uint16 u2vmEPLBand = 0;
+ if (u2EPLBufLen == SAL_NB_PCM_SIZE)
+ {
+ u2vmEPLBand = SAL_NB;
+ }
+ else if (u2EPLBufLen == SAL_WB_PCM_SIZE)
+ {
+ u2vmEPLBand = SAL_WB;
+ }
+ else if (u2EPLBufLen == SAL_SWB_PCM_SIZE)
+ {
+ u2vmEPLBand = SAL_SWB;
+ }
+ else if (u2EPLBufLen == SAL_FB_PCM_SIZE)
+ {
+ u2vmEPLBand = SAL_FB;
+ }
+ return u2vmEPLBand << u2EPLBufShift;
+}
+
+bool VM_CodIsAMR(uint16 codec_mode)
+{
+ if ((codec_mode <= SAL_COD_AMR475 && codec_mode >= SAL_COD_AMR122) ||
+ (codec_mode >= SAL_COD_AWB660 && codec_mode <= SAL_COD_AWB2385))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool VM_CodIsEVS(uint16 codec_mode)
+{
+ if ((codec_mode >= SAL_COD_EVSMIN && codec_mode <= SAL_COD_EVSMAX))
+ {
+ return true;
+ }
+ return false;
+}
+
+/* ------------------------------------------------------------------------------ */
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+void vmFormatter_gseries(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+
+ sc_mode = SAL_COD_AMR122;
+ sd_mode = SAL_COD_AMR122;
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: TX type
+ //[11:11]: (no use) SP flag
+ //[13:12]: Call mode
+ I = 0; // Tx: NO_DATA
+ vm.control_1 = (I << 7) | (sc_mode << 1) | (vm.control_1 & 1);
+
+ // if Call mode = 2G, vm.control_1 = vm.control_1 | 0x0000;
+ if (L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON)
+ vm.control_1 = vm.control_1 | 0x3000; // Call mode = 4G
+ else if (SAL_3G_Mode())
+ vm.control_1 = vm.control_1 | 0x1000; // Call mode = 3G
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: RX type
+ //[15:11]: (no use) [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ I = 0; // Rx: NO_DATA
+ vm.control_2 = (I << 7) | (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if ( g_bNeedExtraLog )
+ MD_TRC_VM_SP3G_VM_L1T(J);
+#endif
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < sc_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_GSeries SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ addr = vmfrm->dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SCH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+#endif //#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+
+#if defined(__EVS_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+EVS_VM_ID VM_EVS_Get_Codec_ID(SP4G_Codec EVSCod)
+{
+ EVS_VM_ID VM_Codec_ID = 0;
+ switch (EVSCod)
+ {
+ case SP4G_CODEC_EVS_08K_005_9:
+ case SP4G_CODEC_EVS_16K_005_9:
+ case SP4G_CODEC_EVS_32K_005_9:
+ case SP4G_CODEC_EVS_48K_005_9:
+ VM_Codec_ID = EVS_PRI590;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_06_60:
+ VM_Codec_ID = EVS_AWB660;
+ break;
+
+ case SP4G_CODEC_EVS_08K_007_2:
+ case SP4G_CODEC_EVS_16K_007_2:
+ case SP4G_CODEC_EVS_32K_007_2:
+ case SP4G_CODEC_EVS_48K_007_2:
+ VM_Codec_ID = EVS_PRI720;
+ break;
+
+ case SP4G_CODEC_EVS_08K_008_0:
+ case SP4G_CODEC_EVS_16K_008_0:
+ case SP4G_CODEC_EVS_32K_008_0:
+ case SP4G_CODEC_EVS_48K_008_0:
+ VM_Codec_ID = EVS_PRI800;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_08_85:
+ VM_Codec_ID = EVS_AWB885;
+ break;
+
+ case SP4G_CODEC_EVS_08K_009_6:
+ case SP4G_CODEC_EVS_16K_009_6:
+ case SP4G_CODEC_EVS_32K_009_6:
+ case SP4G_CODEC_EVS_48K_009_6:
+ VM_Codec_ID = EVS_PRI960;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_12_65:
+ VM_Codec_ID = EVS_AWB1265;
+ break;
+
+ case SP4G_CODEC_EVS_08K_013_2:
+ case SP4G_CODEC_EVS_16K_013_2:
+ case SP4G_CODEC_EVS_32K_013_2:
+ case SP4G_CODEC_EVS_48K_013_2:
+ VM_Codec_ID = EVS_PRI1320;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_14_25:
+ VM_Codec_ID = EVS_AWB1425;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_15_85:
+ VM_Codec_ID = EVS_AWB1585;
+ break;
+
+ case SP4G_CODEC_EVS_08K_016_4:
+ case SP4G_CODEC_EVS_16K_016_4:
+ case SP4G_CODEC_EVS_32K_016_4:
+ case SP4G_CODEC_EVS_48K_016_4:
+ VM_Codec_ID = EVS_PRI1640;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_18_25:
+ VM_Codec_ID = EVS_AWB1825;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_19_85:
+ VM_Codec_ID = EVS_AWB1985;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_23_05:
+ VM_Codec_ID = EVS_AWB2305;
+ break;
+
+ case SP4G_CODEC_EVS_AWB_23_85:
+ VM_Codec_ID = EVS_AWB2385;
+ break;
+
+ case SP4G_CODEC_EVS_08K_024_4:
+ case SP4G_CODEC_EVS_16K_024_4:
+ case SP4G_CODEC_EVS_32K_024_4:
+ case SP4G_CODEC_EVS_48K_024_4:
+ VM_Codec_ID = EVS_PRI2440;
+ break;
+
+ case SP4G_CODEC_EVS_08K_032_0:
+ case SP4G_CODEC_EVS_16K_032_0:
+ case SP4G_CODEC_EVS_32K_032_0:
+ case SP4G_CODEC_EVS_48K_032_0:
+ VM_Codec_ID = EVS_PRI3200;
+ break;
+
+ case SP4G_CODEC_EVS_08K_048_0:
+ case SP4G_CODEC_EVS_16K_048_0:
+ case SP4G_CODEC_EVS_32K_048_0:
+ case SP4G_CODEC_EVS_48K_048_0:
+ VM_Codec_ID = EVS_PRI4800;
+ break;
+
+ case SP4G_CODEC_EVS_08K_064_0:
+ case SP4G_CODEC_EVS_16K_064_0:
+ case SP4G_CODEC_EVS_32K_064_0:
+ case SP4G_CODEC_EVS_48K_064_0:
+ VM_Codec_ID = EVS_PRI6400;
+ break;
+
+ case SP4G_CODEC_EVS_08K_096_0:
+ case SP4G_CODEC_EVS_16K_096_0:
+ case SP4G_CODEC_EVS_32K_096_0:
+ case SP4G_CODEC_EVS_48K_096_0:
+ VM_Codec_ID = EVS_PRI9600;
+ break;
+
+ case SP4G_CODEC_EVS_08K_128_0:
+ case SP4G_CODEC_EVS_16K_128_0:
+ case SP4G_CODEC_EVS_32K_128_0:
+ case SP4G_CODEC_EVS_48K_128_0:
+ VM_Codec_ID = EVS_PRI12800;
+ break;
+
+ case SP4G_CODEC_EVS_08K_002_4_SID:
+ case SP4G_CODEC_EVS_08K_000_0_REV:
+ case SP4G_CODEC_EVS_08K_000_0_LOST:
+ case SP4G_CODEC_EVS_08K_000_0_NODATA:
+
+ case SP4G_CODEC_EVS_16K_002_4_SID:
+ case SP4G_CODEC_EVS_16K_000_0_REV:
+ case SP4G_CODEC_EVS_16K_000_0_LOST:
+ case SP4G_CODEC_EVS_16K_000_0_NODATA:
+
+ case SP4G_CODEC_EVS_32K_002_4_SID:
+ case SP4G_CODEC_EVS_32K_000_0_REV:
+ case SP4G_CODEC_EVS_32K_000_0_LOST:
+ case SP4G_CODEC_EVS_32K_000_0_NODATA:
+
+ case SP4G_CODEC_EVS_48K_002_4_SID:
+ case SP4G_CODEC_EVS_48K_000_0_REV:
+ case SP4G_CODEC_EVS_48K_000_0_LOST:
+ case SP4G_CODEC_EVS_48K_000_0_NODATA:
+
+ case SP4G_CODEC_EVS_AWB_02_00_SID:
+ case SP4G_CODEC_EVS_AWB_00_00_REV0:
+ case SP4G_CODEC_EVS_AWB_00_00_REV1:
+ case SP4G_CODEC_EVS_AWB_00_00_REV2:
+ case SP4G_CODEC_EVS_AWB_00_00_REV3:
+ case SP4G_CODEC_EVS_AWB_00_00_LOST:
+ case SP4G_CODEC_EVS_AWB_00_00_NODATA:
+ VM_Codec_ID = EVS_SID_LOST_NODATA;
+ break;
+
+ default:
+ VM_Codec_ID = EVS_UNDEF;
+ break;
+ }
+ return VM_Codec_ID;
+}
+
+void vmFormatter_evs(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+ uint16 sc_mode_invalid = 0, sd_mode_invalid = 0;
+
+ sc_mode = VM_EVS_Get_Codec_ID(SAL_EVS_Get_Codec_Mode(SAL_EVS_TX_CODEC_MODE));
+
+ if (sc_mode == EVS_UNDEF)
+ {
+ sc_mode_invalid = 1;
+ sc_mode = EVS_PRI1640;
+ }
+
+ sd_mode = VM_EVS_Get_Codec_ID(SAL_EVS_Get_Codec_Mode(SAL_EVS_RX_CODEC_MODE));
+
+ if (sd_mode == EVS_SID_LOST_NODATA) // DL only, For EVS Codec ID: REV and LOST
+ {
+ if (vm.evs_cur_sd_mode == EVS_UNDEF)
+ sd_mode = VM_EVS_Get_Codec_ID(SAL_Get_DL_CodecMode()); //Codec mode of call open
+ else
+ sd_mode = vm.evs_cur_sd_mode;
+ }
+
+ if (sd_mode == EVS_UNDEF)
+ {
+ sd_mode_invalid = 1;
+ sd_mode = EVS_PRI1640;
+ }
+
+ vm.evs_cur_sd_mode = sd_mode;
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: (no use) TX type
+ //[11:11]: (no use) SP flag
+ //[13:12]: Call mode
+ vm.control_1 = (sc_mode << 1) | (vm.control_1 & 1);
+ vm.control_1 = vm.control_1 | 0x3000; // Call mode = 4G
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: (no use) RX type
+ //[15:11]: (no use) [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ vm.control_2 = (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if ( g_bNeedExtraLog )
+ MD_TRC_VM_SP3G_VM_L1T(J);
+#endif
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ if (sc_mode_invalid)
+ {
+ *vmBuf++ = SAL_EVS_SPEECH_GOOD_FRAME;
+ *vmBuf++ = 328; //EVS 16.4 HB Len
+ }
+ else
+ {
+ *vmBuf++ = SAL_EVS_Get_Enc_BFI();
+ *vmBuf++ = SAL_EVS_Get_Enc_HBLen();
+ }
+
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < (sc_len - 2); I++ )
+ {
+ if (sc_mode_invalid)
+ *vmBuf++ = 0;
+ else
+ *vmBuf++ = *addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ if (sd_mode_invalid)
+ {
+ *vmBuf++ = SAL_EVS_SPEECH_GOOD_FRAME;
+ *vmBuf++ = 328; //EVS 16.4 HB Len
+ }
+ else
+ {
+ *vmBuf++ = SAL_EVS_Get_Dec_BFI(SAL_4G_RX_FIRST_FRM);
+ *vmBuf++ = SAL_EVS_Get_Dec_HBLen(SAL_4G_RX_FIRST_FRM);
+ }
+
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < (sd_len - 2); I++ )
+ {
+ if (sd_mode_invalid)
+ *vmBuf++ = 0;
+ else
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ if (sd_mode_invalid)
+ {
+ *vmBuf++ = SAL_EVS_SPEECH_GOOD_FRAME;
+ *vmBuf++ = 328; //EVS 16.4 HB Len
+ }
+ else
+ {
+ *vmBuf++ = SAL_EVS_Get_Dec_BFI(SAL_4G_RX_SECOND_FRM);
+ *vmBuf++ = SAL_EVS_Get_Dec_HBLen(SAL_4G_RX_SECOND_FRM);
+ }
+
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < (sd_len - 2); I++ )
+ {
+ if (sd_mode_invalid)
+ *vmBuf++ = 0;
+ else
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_EVS SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ // SCH Dbg Info 0
+ addr = vmfrm->dbgInfo_addr;
+ *vmBuf = (*addr) & 0xEA;
+ *vmBuf = *vmBuf | (SAL_EVS_SPEECH_BAD_FRAME == SAL_EVS_Get_Enc_BFI()) | ((SAL_EVS_SPEECH_BAD_FRAME == SAL_EVS_Get_Dec_BFI(SAL_4G_RX_FIRST_FRM)) << 2);
+ vmBuf++;
+
+ // SCH Dbg Info 1
+ *vmBuf = (SAL_EVS_Get_PCMBW()) | ((SAL_EVS_Get_PCMBW()) << 2) | ((SAL_EVS_Get_Enc_MaxRate()) << 4);
+ *vmBuf = *vmBuf | ((SAL_EVS_Get_Enc_CA_Enable()) << 6) | ((SAL_EVS_Get_Enc_CA_RF_FEC_Indicator()) << 7) | ((SAL_EVS_Get_Enc_CA_RF_FEC_Offset()) << 8);
+ *vmBuf = *vmBuf | ((SAL_EVS_Get_Dec_CA_FrmMode(SAL_4G_RX_FIRST_FRM)) << 11) | ((SAL_EVS_Get_Dec_CA_FrmMode(SAL_4G_RX_SECOND_FRM)) << 13);
+ vmBuf++;
+
+ // SCH Dbg Info 2
+ *vmBuf++ = SAL_EVS_Get_Enc_HBLen();
+
+ // SCH Dbg Info 3
+ *vmBuf++ = SAL_EVS_Get_Dec_HBLen(SAL_4G_RX_FIRST_FRM);
+
+ // SCH Dbg Info 4
+ *vmBuf++ = SAL_EVS_Get_Dec_HBLen(SAL_4G_RX_SECOND_FRM);
+
+ // SCH Dbg Info reserved
+ addr = vmfrm->dbgInfo_addr + 5;
+ for ( I = 0; I < (VM_VM_SCH_DBGINFO_SIZE - 5); I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+#endif
+
+void vmFormatter_amr(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+ uint16 sc_mode_invalid = 0;
+
+ sc_mode = vmfrm->enc_mode;
+ sd_mode = vmfrm->dec_mode;
+ if ((VM_CodIsAMR(sc_mode)) == false)
+ {
+ sc_mode = sd_mode;
+ sc_mode_invalid = 1;
+ }
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: TX type
+ //[11:11]: (no use) SP flag
+ //[13:12]: Call mode
+ if (sc_mode_invalid)
+ {
+ I = 0; // Tx: NO_DATA
+ }
+ else
+ {
+ I = vmfrm->enc_hdr & 0x3; // Tx: bit0, bit1
+ }
+ vm.control_1 = (I << 7) | (sc_mode << 1) | (vm.control_1 & 1);
+
+ // if Call mode = 2G, vm.control_1 = vm.control_1 | 0x0000;
+ if (L1SP_GetState() == L1SP_STATE_4G_SPEECH_ON)
+ vm.control_1 = vm.control_1 | 0x3000; // Call mode = 4G
+ else if (SAL_3G_Mode())
+ vm.control_1 = vm.control_1 | 0x1000; // Call mode = 3G
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: RX type
+ //[15:11]: (no use) [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ I = (vmfrm->dec_hdr & 0xE) >> 1; // Rx: bit1, bit2, bit3
+ vm.control_2 = (I << 7) | (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if ( g_bNeedExtraLog )
+ MD_TRC_VM_SP3G_VM_L1T(J);
+#endif
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < sc_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_AMR SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ addr = vmfrm->dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SCH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+
+void vmFormatter_4g(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ if ( SP4G_IsGCodecMode() )
+ {
+ vmFormatter_gseries(vmBuf, vmfrm);
+ return;
+ }
+#endif
+
+#if defined(__EVS_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ if (VM_CodIsEVS(vmfrm->dec_mode) == true)
+ {
+ vmFormatter_evs(vmBuf, vmfrm);
+ return;
+ }
+#endif
+
+ vmFormatter_amr(vmBuf, vmfrm);
+}
+
+void vmFormatter_c2k(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+ uint16 sc_mode_invalid = 0;
+
+ sc_mode = vmfrm->enc_mode;
+ sd_mode = vmfrm->dec_mode;
+ if (sc_mode != sd_mode)
+ {
+ sc_mode = sd_mode;
+ sc_mode_invalid = 1;
+ }
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: TX type
+ //[11:11]: (no use) SP flag
+ //[13:12]: Call mode
+ if (sc_mode_invalid)
+ {
+ I = 0; // Tx: NO_DATA
+ }
+ else
+ {
+ I = vmfrm->enc_hdr; // Tx
+ }
+ vm.control_1 = (I << 7) | (sc_mode << 1) | (vm.control_1 & 1);
+ vm.control_1 = vm.control_1 | 0x2000; // Call mode = C2K
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: RX type
+ //[15:11]: (no use) [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ I = vmfrm->dec_hdr; // Rx
+ vm.control_2 = (I << 7) | (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ // TODO: c2k [trace]
+#endif
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < sc_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_C2K SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ addr = vmfrm->dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SCH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+
+void vmFormatter_standby(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+ uint16 sc_mode_invalid = 0;
+
+ sc_mode = vmfrm->enc_mode;
+ sd_mode = vmfrm->dec_mode;
+ if ((VM_CodIsAMR(sc_mode)) == false)
+ {
+ sc_mode = sd_mode;
+ sc_mode_invalid = 1;
+ }
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: TX type
+ //[11:11]: (no use) SP flag
+ //[13:12]: Call mode
+ if (sc_mode_invalid)
+ {
+ I = 0; // Tx: NO_DATA
+ }
+ else
+ {
+ I = vmfrm->enc_hdr & 0x3; // Tx: bit0, bit1
+ }
+ vm.control_1 = (I << 7) | (sc_mode << 1) | (vm.control_1 & 1);
+ vm.control_1 = vm.control_1 | 0x1000; // Call mode = 3G
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: RX type
+ //[15:11]: (no use) [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ I = (vmfrm->dec_hdr & 0xE) >> 1; // Rx: bit1, bit2, bit3
+ vm.control_2 = (I << 7) | (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ if ( g_bNeedExtraLog )
+ MD_TRC_VM_SP3G_VM_L1T(J);
+#endif
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < sc_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_Standby SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ addr = vmfrm->dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SCH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+
+void vmFormatter_vm(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ volatile uint16 *addr;
+ uint16 I, sc_mode, sd_mode, sc_len, sd_len;
+ uint32 J;
+ uint16 sc_mode_invalid = 0;
+
+ sc_mode = vmfrm->enc_mode;
+ sd_mode = vmfrm->dec_mode;
+ if (sc_mode != sd_mode)
+ {
+ sc_mode = sd_mode;
+ sc_mode_invalid = 1;
+ }
+
+ sc_len = AM_GetSpeechPatternLength(sc_mode);
+ //ASSERT_REBOOT( sc_len > 0 );
+ sd_len = AM_GetSpeechPatternLength(sd_mode);
+ //ASSERT_REBOOT( sd_len > 0 );
+
+ //[0:0]: UL on
+ //[6:1]: UL mode
+ //[10:7]: (no use) TX type
+ //[11:11]: SP flag
+ //[13:12]: Call mode
+ if (sc_mode_invalid)
+ {
+ I = 0; // sp_flag: Silence
+ }
+ else
+ {
+ I = (vmfrm->enc_hdr & 0x2) >> 1; // sp_flag: bit1
+ }
+ vm.control_1 = (I << 11) | (sc_mode << 1) | (vm.control_1 & 1);
+ // if Call mode = 2G, vm.control_1 = vm.control_1 | 0x0000;
+
+ //[0:0]: DL on
+ //[6:1]: DL mode
+ //[10:7]: (no use) RX type
+ //[15:11]: [12:11] SID flag, [13] TAF, [14] UFI, [15] BFI
+ I = (vmfrm->dec_hdr & 0x3E) >> 1; // BFI, UFI, TAF, SID
+ vm.control_2 = (I << 11) | (sd_mode << 1) | (vm.control_2 & 1);
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf head %x", vmBuf);
+
+ *vmBuf++ = VM_VM_MAGIC_HEADER;
+ J = L1SP_GetState();
+ I = (uint16)( ( VM_VM_DBGINFO_TOTAL_SIZE << 3 ) | J);
+ *vmBuf++ = I;
+ *vmBuf++ = VM_VM_RECORD_FLAG;
+ *vmBuf++ = 0; //reset EPL band
+ J = fma_get_glb_ts() & 0xFFFFFFFF;
+ I = (uint16)(J & 0xFFFF);
+ *vmBuf++ = I;
+ I = (uint16)(J >> 16);
+ *vmBuf++ = I;
+ vm.vm_counter++;
+
+ //Chip ID
+ vm.control_3 = VM_CHIP_ID;
+
+ //[1:0]: DL frm cnt
+ //[7:2]: DL2 mode
+ //[11:8]: DL2 RX type
+ //[13:12]: Codec band
+ //[15:14]: Expert mode (By VLP)
+ vm.control_4 = (vmfrm->dec_frm_num & 0x3) | ((sd_mode & 0x3F) << 2) | ((vmfrm->dec_hdr_1 & 0xE) << 8) | ((SAL_VM_Get_CodBand() & 0x3) << 12);
+
+ //[15:0]: TS control
+ vm.control_5 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_CTRL);
+
+ //[7:0]: TS target scale
+ //[12:8]: TS max scale
+ vm.control_6 = (SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_TARGET_SCALE) & 0xFF) | ((SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_MAX_SCALE) & 0x1F) << 8);
+
+ //[10:0]: TS output size 1
+ vm.control_7 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_1);
+
+ //[10:0]: TS output size 2
+ vm.control_8 = SAL_VM_Get_TS_Info(SAL_VM_TS_INFO_OUTPUT_SIZE_2);
+
+ // record vm control value
+ *vmBuf++ = vm.control_1;
+ *vmBuf++ = vm.control_2;
+ *vmBuf++ = vm.control_3;
+ *vmBuf++ = vm.control_4;
+ *vmBuf++ = vm.control_5;
+ *vmBuf++ = vm.control_6;
+ *vmBuf++ = vm.control_7;
+ *vmBuf++ = vm.control_8;
+ *vmBuf++ = vm.control_9;
+ *vmBuf++ = vm.control_10;
+
+ // record UL data
+ vm.sc_len = 0;
+ if ( vm.control_1 & 1 )
+ {
+ addr = vmfrm->enc_hb_addr;
+ for ( I = 0; I < sc_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sc_len += sc_len;
+ }
+
+ // record DL data
+ vm.sd_len = 0;
+ if ( vm.control_2 & 1 )
+ {
+ addr = vmfrm->dec_hb_addr;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+
+ if (vmfrm->dec_frm_num == 2)
+ {
+ addr = vmfrm->dec_hb_addr_1;
+ for ( I = 0; I < sd_len; I++ )
+ {
+ *vmBuf++ = *addr++;
+ if (L1SP_GetState() == L1SP_STATE_2G_SPEECH_ON)
+ addr++;
+ }
+ vm.sd_len += sd_len;
+ }
+ }
+
+ kal_prompt_trace(MOD_L1SP, "Formatter_VM SC Len= %d, SD Len= %d, Dec_Cnt= %d", vm.sc_len, vm.sd_len, vmfrm->dec_frm_num);
+
+ // Debug info
+ addr = vmfrm->dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SCH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ addr = vmfrm->enh_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_ENH_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ for (I = 0; I < VM_VM_DRV_DBGINFO_SIZE; I++)
+ {
+ if (I < VM_3G_NETWORK_INFO_LEN)
+ *vmBuf++ = vm3GNetworkInfo[I];
+ else
+ *vmBuf++ = 0;
+ }
+
+ addr = vmfrm->svc_dbgInfo_addr;
+ for ( I = 0; I < VM_VM_SVC_DBGINFO_SIZE; I++ )
+ *vmBuf++ = *addr++;
+
+ kal_prompt_trace(MOD_L1SP, "vmBuf tail %x", vmBuf);
+}
+
+void vmFormatter_2g(uint16 *vmBuf, Sal_VM_Frame *vmfrm)
+{
+ if (VM_CodIsAMR(vmfrm->dec_mode) == true)
+ {
+ vmFormatter_amr(vmBuf, vmfrm);
+ }
+ else
+ {
+ vmFormatter_vm(vmBuf, vmfrm);
+ }
+}
+
+/* ------------------------------------------------------------------------------ */
+/**
+ @buf1: pointer to pcm buf1,
+ @len1:length of buf1, unit is word(2byte)
+ @buf2:pointer to pcm buf2
+ @len2: length of buf2. unit is word(2byte)
+*/
+void VmRec_GetReadBufs(kal_uint32 *add1, kal_uint16 *len1, kal_uint32 *add2, kal_uint16 *len2)
+{
+ if (vm.pOutputBufWrite >= vm.pOutputBufRead) // write > read, 1 buf segment
+ {
+ *add1 = (kal_uint32)(&vmRecOutputBuf[vm.pOutputBufRead]);
+ *len1 = (vm.pOutputBufWrite - vm.pOutputBufRead);
+ *add2 = 0;
+ *len2 = 0;
+ }
+ else //write < read, 2 buf segment
+ {
+ *add1 = (kal_uint32)(&vmRecOutputBuf[vm.pOutputBufRead]);
+ *len1 = (vm.outputBufSize - vm.pOutputBufRead);
+ *add2 = (kal_uint32)(vmRecOutputBuf);
+ *len2 = (vm.pOutputBufWrite);
+ }
+}
+
+/**
+ @len: unit is word
+*/
+void VmRec_ReadDataDone(uint16 len)
+{
+ vm.pOutputBufRead += len;
+ if ( vm.pOutputBufRead >= vm.outputBufSize)
+ vm.pOutputBufRead = vm.pOutputBufRead - vm.outputBufSize;
+}
+
+//use this function instead of Media_WriteDataDone to avoid media.waiting false usage
+int32 vmRec_queryOutputBufFreeSpace(void)
+{
+ int32 count;
+
+ count = vm.pOutputBufRead + vm.outputBufSize - vm.pOutputBufWrite - 1;
+
+ if ( count >= vm.outputBufSize )
+ count -= vm.outputBufSize;
+ return count;
+}
+
+void vmRec_getWriteBuffer(uint16 **buffer, uint32 *bufLen)
+{
+ int32 count;
+
+ if ( vm.pOutputBufRead > vm.pOutputBufWrite )
+ count = vm.pOutputBufRead - vm.pOutputBufWrite - 1;
+ else if ( vm.pOutputBufRead == 0 )
+ count = vm.outputBufSize - vm.pOutputBufWrite - 1;
+ else
+ count = vm.outputBufSize - vm.pOutputBufWrite;
+
+ *buffer = &vmRecOutputBuf[vm.pOutputBufWrite];
+ *bufLen = (uint32)count;
+}
+
+static void vmRec_writeDataDone(uint32 len)
+{
+ vm.pOutputBufWrite += len;
+ if ( vm.pOutputBufWrite >= vm.outputBufSize)
+ vm.pOutputBufWrite = vm.pOutputBufWrite - vm.outputBufSize;
+}
+
+static void vocWriteVocToCatcher(uint16 vmLen, uint16 *vmBuf)
+{
+ uint32 len = vmLen * 2;
+ uint16 *buf = vmBuf;
+
+ while (len > 1000)
+ {
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)buf, 1000);
+ buf += 500;
+ len -= 1000;
+ }
+ tst_vc_response(TVCI_VM_LOGGING, (const kal_uint8*)buf, len);
+}
+
+static void vmRec_writeVmToOutputBuf(uint16 vmLen, uint16 *vmBuf) // a frame of VM must be written to MB
+{
+ uint16 *toPtr;
+ uint32 segment, I;
+
+ vmRec_getWriteBuffer( &toPtr, &segment );
+
+ if (segment > vmLen)
+ segment = vmLen;
+
+ for ( I = segment ; I > 0 ; I-- ) {
+ *toPtr++ = *vmBuf++;
+ }
+
+ vmRec_writeDataDone( segment );
+
+ // second segment
+ vmLen -= segment; // unprocess length
+ if (vmLen > 0 )
+ {
+ vmRec_getWriteBuffer( &toPtr, &segment );
+
+ if (segment > vmLen)
+ segment = vmLen;
+
+ for ( I = segment ; I > 0 ; I-- ) {
+ *toPtr++ = *vmBuf++;
+ }
+ vmRec_writeDataDone( segment );
+ }
+ return;
+}
+
+static void voc4WayPcmRecord( volatile uint16* ul_addr, uint16 ul_len, volatile uint16* dl_addr, uint16 dl_len)
+{
+ uint16 *buf;
+
+ buf = vm.pcmBuf;
+ // header for record 1st set of UL-DL PCM data
+ *buf++ = (vm.vm_lost_count << 8) + vm.pcm_lost_count;
+ *buf++ = vm.vm_counter ;
+
+ // make it interleave
+ // Uplink
+ EMI_ReadFromDSP((uint16*)buf, ul_addr, ul_len);
+ buf += ul_len;
+
+ // Downlink
+ EMI_ReadFromDSP((uint16*)buf, dl_addr, dl_len);
+
+ buf = vm.pcmBuf;
+
+ vocWriteVocToCatcher(ul_len + dl_len + 2, buf);
+}
+
+static void vm4WayPcmRecord(volatile uint16 *ul_addr, uint16 ul_len, volatile uint16 *dl_addr, uint16 dl_len)
+{
+ uint32 I, tmp = 0;
+ uint16 *buf, *mBuf;
+ uint16 logsize;
+
+ logsize = ul_len + dl_len + 2;
+
+ buf = vm.pcmBuf;
+ // header for record 1st set of UL-DL PCM data
+ *buf++ = (vm.vm_lost_count << 8) + vm.pcm_lost_count;
+ *buf++ = vm.vm_counter ;
+
+ // Uplink
+ EMI_ReadFromDSP((uint16*)buf, ul_addr, ul_len);
+ buf += ul_len;
+
+ // Downlink
+ EMI_ReadFromDSP((uint16*)buf, dl_addr, dl_len);
+
+ buf = vm.pcmBuf;
+
+ vmRec_getWriteBuffer( &mBuf, &tmp );
+ if ( tmp > logsize )
+ tmp = logsize;
+ //for( I = tmp ; I > 0 ; I-- ) {
+ // *mBuf++ = *buf++;
+ //}
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+
+ vmRec_writeDataDone(tmp);
+
+ tmp = logsize - tmp; // tmp is size did not write to Buffer
+ if ( (int32)tmp > 0 )
+ {
+ vmRec_getWriteBuffer( &mBuf, &I );
+
+ if (I >= tmp)
+ {
+ //for( I = tmp ; I > 0 ; I--) {
+ // *mBuf++ = *buf++;
+ //}
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+
+ vmRec_writeDataDone( tmp );
+ }
+ else
+ {
+ MD_TRC_VM_REC_HISR_PCM_DATA_LOST(0);
+ }
+ }
+}
+
+static void vmRefMic_AGC_PcmRecord( bool isToVoc, volatile uint16 *addr, uint16 len )
+{
+ uint32 I, tmp = 0;
+ uint16 *buf, *mBuf;
+ uint16 logsize;
+
+ logsize = len + 2 + 2;
+
+ buf = vm.pcmBuf;
+ *buf++ = (vm.vm_lost_count << 8) + vm.pcm_lost_count;
+ *buf++ = vm.vm_counter ;
+
+ { //RefMic
+ EMI_ReadFromDSP((uint16*)buf, addr, len);
+ buf += len;
+ *buf++ = SAL_AGC_GetSWGain(0);
+ *buf = SAL_AGC_GetSWGain(1);
+ }
+
+ buf = vm.pcmBuf;
+
+ if (isToVoc)
+ {
+ vocWriteVocToCatcher(logsize, buf);
+ }
+ else // normal vm process
+ {
+ vmRec_getWriteBuffer( &mBuf, &tmp );
+ if ( tmp > logsize )
+ tmp = logsize;
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+
+ vmRec_writeDataDone(tmp);
+
+ tmp = logsize - tmp;
+ if ( (int32)tmp > 0 )
+ {
+ vmRec_getWriteBuffer( &mBuf, &I );
+ if (I >= tmp)
+ {
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+ vmRec_writeDataDone(tmp);
+ }
+ else
+ {
+ MD_TRC_VM_REC_HISR_PCM_DATA_LOST(0);
+ }
+ }
+ }
+}
+
+static void vmEchoRefPcmRecord( bool isToVoc, volatile uint16 *addr, uint16 len )
+{
+ uint32 I, tmp = 0;
+ uint16 *buf, *mBuf;
+ uint16 logsize;
+
+ logsize = len + 2;
+
+ buf = vm.pcmBuf;
+ *buf++ = (vm.vm_lost_count << 8) + vm.pcm_lost_count;
+ *buf++ = vm.vm_counter ;
+
+ EMI_ReadFromDSP((uint16*)buf, addr, len);
+ buf = vm.pcmBuf;
+
+ if (isToVoc)
+ {
+ vocWriteVocToCatcher(logsize, buf);
+ }
+ else // normal vm process
+ {
+ vmRec_getWriteBuffer( &mBuf, &tmp );
+ if ( tmp > logsize )
+ tmp = logsize;
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+
+ vmRec_writeDataDone(tmp);
+
+ tmp = logsize - tmp;
+ if ( (int32)tmp > 0 )
+ {
+ vmRec_getWriteBuffer( &mBuf, &I );
+ if (I >= tmp)
+ {
+ kal_mem_cpy(mBuf, buf, tmp << 1);
+ buf += tmp;
+ mBuf += tmp;
+ vmRec_writeDataDone(tmp);
+ }
+ else
+ {
+ MD_TRC_VM_REC_HISR_PCM_DATA_LOST(0);
+ }
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------------ */
+void vmTchPcmRecordHisr(void *param)
+{
+ uint16 u2VM_total_size; // VM + EPL_PCM + EPL_dummy
+ uint16 u2VM_buffer_size; // VM
+ uint16 u2VM_size; // Dbg Info size + EPL PCM size
+ uint16 u2EPL_PCM_size = 0;
+ uint16 u2EPL_dummy_size = 0;
+ uint16 *buf;
+ Sal_EPL_Frame eplfrm_t;
+
+ if (KAL_SPINLOCK_NOT_AVAILABLE == kal_take_spinlock(vm.lockId, KAL_NO_WAIT))
+ {
+ MD_TRC_VM_HISR_LOCK_NOT_AVALIABLE(2);
+ goto leaveEplHisr;
+ }
+
+ // dsp status check
+ if ( vm.state != VM_STATE_RECORD )
+ {
+ goto leaveEplProc;
+ }
+
+ // application status check
+ if ( (false == vm.isVocOn) && (false == vm.isVmLOn))
+ {
+ goto leaveEplProc;
+ }
+
+ SAL_EPL_GetFrame(&eplfrm_t);
+
+ if (vm.record_info & VM_EPL_1STSET_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul_pre_len + eplfrm_t.dl_pre_len;
+ u2EPL_dummy_size += 2;
+ }
+ if (vm.record_info & VM_EPL_2NDSET_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul_pos_len + eplfrm_t.dl_pos_len;
+ u2EPL_dummy_size += 2;
+ }
+ if (vm.record_info & VM_EPL_REFMIC_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul2_pos_len;
+ u2EPL_dummy_size += 4;
+ }
+ if (vm.record_info & VM_EPL_ECHOREF_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul4_pos_len;
+ u2EPL_dummy_size += 2;
+ }
+ if (vm.record_info & VM_EPL_3RDMIC_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul3_pos_len;
+ u2EPL_dummy_size += 2;
+ }
+ if (vm.record_info & VM_EPL_2NDECHOREF_RECORD_FLAG) {
+ u2EPL_PCM_size += eplfrm_t.ul5_pos_len;
+ u2EPL_dummy_size += 2;
+ }
+
+ // handing the total size u2VM_total_size (vm + pcm buffer) in word(2byte)
+ buf = vm.vmBuf;
+
+ if (buf[0] == VM_VM_MAGIC_HEADER) //already buffer VM, (normal case)
+ {
+ u2VM_size = VM_VM_DBGINFO_TOTAL_SIZE + u2EPL_PCM_size;
+ u2VM_buffer_size = VM_VM_HEADER_SIZE + VM_VM_CONTROL_SIZE + vm.sc_len + vm.sd_len + VM_VM_DBGINFO_TOTAL_SIZE;
+ kal_prompt_trace(MOD_L1SP, "TchPcmRecordHisr SC Len= %d, SD Len= %d", vm.sc_len, vm.sd_len);
+ }
+ else // case when previous vmbufer is missing! Save the pcm data with empty vm
+ {
+ u2VM_size = u2EPL_PCM_size;
+ u2VM_buffer_size = VM_VM_HEADER_SIZE;
+ }
+ u2VM_total_size = u2VM_buffer_size + u2EPL_PCM_size + u2EPL_dummy_size;
+
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul_pre_len, VM_EPL_BAND_UL0_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul_pos_len, VM_EPL_BAND_UL1_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.dl_pre_len, VM_EPL_BAND_DL0_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.dl_pos_len, VM_EPL_BAND_DL1_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul2_pos_len, VM_EPL_BAND_UL2_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul4_pos_len, VM_EPL_BAND_UL4_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul3_pos_len, VM_EPL_BAND_UL3_SHIFT);
+ buf[3] |= vmEPLBandSet(eplfrm_t.ul5_pos_len, VM_EPL_BAND_UL5_SHIFT);
+
+ kal_prompt_trace(MOD_L1SP, "UL_PRE %d, UL_POS %d, DL_PRE %d, DL_POS %d, UL2 %d, UL3 %d, UL4 %d, UL5 %d", eplfrm_t.ul_pre_len, eplfrm_t.ul_pos_len, eplfrm_t.dl_pre_len, eplfrm_t.dl_pos_len, eplfrm_t.ul2_pos_len, eplfrm_t.ul3_pos_len, eplfrm_t.ul4_pos_len, eplfrm_t.ul5_pos_len);
+ kal_prompt_trace(MOD_L1SP, "Band %x", buf[3]);
+
+ //when vm logging and VOC are both on, only send the data to vm logging to reduce log size
+ if (vm.isVmLOn)
+ {
+ if (vmRec_queryOutputBufFreeSpace() < u2VM_total_size)
+ {
+ // drop this log and add counter
+ vm.pcm_lost_count++;
+ MD_TRC_VM_REC_HISR_VM_DATA_LOST(vm.vm_lost_count, 1);
+ goto leaveEplProc;
+ }
+ else
+ {
+ uint32 timestamp;
+ buf[0] = VM_VM_MAGIC_HEADER;
+ buf[1] = (u2VM_size << 3) | (L1SP_GetState()) ;
+ buf[2] |= (vm.record_info & VM_EPL_ALL_RECORD_FLAG);
+ // buf[3] is set in previous
+ timestamp = fma_get_glb_ts() & 0xFFFFFFFF;
+ buf[4] = (uint16)(timestamp & 0xFFFF); // Lo
+ buf[5] = (uint16)(timestamp >> 16); // High
+
+ vmRec_writeVmToOutputBuf(u2VM_buffer_size, buf);
+
+ //pcm bufs
+ if (vm.record_info & VM_EPL_1STSET_RECORD_FLAG)
+ vm4WayPcmRecord(eplfrm_t.ul_pre_buf, eplfrm_t.ul_pre_len, eplfrm_t.dl_pre_buf, eplfrm_t.dl_pre_len);
+
+ if (vm.record_info & VM_EPL_2NDSET_RECORD_FLAG)
+ vm4WayPcmRecord(eplfrm_t.ul_pos_buf, eplfrm_t.ul_pos_len, eplfrm_t.dl_pos_buf, eplfrm_t.dl_pos_len);
+
+ if (vm.record_info & VM_EPL_REFMIC_RECORD_FLAG)
+ vmRefMic_AGC_PcmRecord(false, eplfrm_t.ul2_pos_buf, eplfrm_t.ul2_pos_len);
+
+ if (vm.record_info & VM_EPL_ECHOREF_RECORD_FLAG)
+ vmEchoRefPcmRecord(false, eplfrm_t.ul4_pos_buf, eplfrm_t.ul4_pos_len);
+
+ if (vm.record_info & VM_EPL_3RDMIC_RECORD_FLAG)
+ vmEchoRefPcmRecord(false, eplfrm_t.ul3_pos_buf, eplfrm_t.ul3_pos_len);
+
+ if (vm.record_info & VM_EPL_2NDECHOREF_RECORD_FLAG)
+ vmEchoRefPcmRecord(false, eplfrm_t.ul5_pos_buf, eplfrm_t.ul5_pos_len);
+ }
+ }
+ else // VOC
+ {
+ // fill vm buffer header
+ uint32 timestamp;
+ buf[0] = VM_VM_MAGIC_HEADER;
+ buf[1] = (u2VM_size << 3) | (L1SP_GetState()) ;
+ buf[2] |= (vm.record_info & VM_EPL_ALL_RECORD_FLAG);
+ // buf[3] is set in previous
+ timestamp = fma_get_glb_ts() & 0xFFFFFFFF;
+ buf[4] = (uint16)(timestamp & 0xFFFF); // Lo
+ buf[5] = (uint16)(timestamp >> 16); // High
+
+ vocWriteVocToCatcher(u2VM_buffer_size, buf);
+
+ if (vm.record_info & VM_EPL_1STSET_RECORD_FLAG)
+ voc4WayPcmRecord(eplfrm_t.ul_pre_buf, eplfrm_t.ul_pre_len, eplfrm_t.dl_pre_buf, eplfrm_t.dl_pre_len);
+
+ if (vm.record_info & VM_EPL_2NDSET_RECORD_FLAG)
+ voc4WayPcmRecord(eplfrm_t.ul_pos_buf, eplfrm_t.ul_pos_len, eplfrm_t.dl_pos_buf, eplfrm_t.dl_pos_len);
+
+ if (vm.record_info & VM_EPL_REFMIC_RECORD_FLAG)
+ vmRefMic_AGC_PcmRecord(true, eplfrm_t.ul2_pos_buf, eplfrm_t.ul2_pos_len);
+
+ if (vm.record_info & VM_EPL_ECHOREF_RECORD_FLAG)
+ vmEchoRefPcmRecord(true, eplfrm_t.ul4_pos_buf, eplfrm_t.ul4_pos_len);
+
+ if (vm.record_info & VM_EPL_3RDMIC_RECORD_FLAG)
+ vmEchoRefPcmRecord(true, eplfrm_t.ul3_pos_buf, eplfrm_t.ul3_pos_len);
+
+ if (vm.record_info & VM_EPL_2NDECHOREF_RECORD_FLAG)
+ vmEchoRefPcmRecord(true, eplfrm_t.ul5_pos_buf, eplfrm_t.ul5_pos_len);
+ }
+
+ vm.pcm_lost_count = 0;
+ buf[0] = 0;
+ buf[1] = 0;
+ buf[2] = 0;
+ buf[3] = 0;
+
+leaveEplProc:
+ kal_give_spinlock(vm.lockId);
+
+ if (vm.vm_hdlr) {
+ vm.vm_hdlr();
+ }
+
+leaveEplHisr:
+ return;
+}
+
+void vmTchRecordHisr(void *param)
+{
+ uint16 u2VM_buffer_size;
+ uint16 *vmBuf;
+ uint8 sp_state = L1SP_GetState();
+
+ if (KAL_SPINLOCK_NOT_AVAILABLE == kal_take_spinlock(vm.lockId, KAL_NO_WAIT))
+ {
+ MD_TRC_VM_HISR_LOCK_NOT_AVALIABLE(1);
+ goto leaveHisr;
+ }
+
+ // check dsp status
+ if ( vm.state != VM_STATE_RECORD )
+ {
+ goto leaveProc;
+ }
+
+ // check application status
+ if ( (false == vm.isVocOn) && (false == vm.isVmLOn))
+ {
+ goto leaveProc;
+ }
+
+ // just logging
+#if defined(__MA_L1__)
+ if (!(L1SP_GetState() == L1SP_STATE_3G_SPEECH_ON || L1SP_GetState() == L1SP_STATE_3G324M_SPEECH_ON))
+ {
+ uint8 rx_type, tx_type, BFI;
+ uint16 rx_debug;
+ rx_debug = *DSP_RX_TCH_S(0, 0);
+ tx_type = *DSP_RX_TCH_S(0, 0) & 0x3;
+ rx_type = (rx_debug >> 1) & 0x7;
+ BFI = (rx_debug >> 5) & 0x1; //speechBFI
+ if ( rx_type < 3 ) //non-amr
+ rx_type = 8 + (rx_type << 1) + BFI;
+ BFI = (rx_debug >> 8) & 0xFF; //BER
+ MD_TRC_L1Audio_Msg_SPEECH_FRAME( L1SP_Speech_TX_Type(tx_type), L1SP_Speech_RX_Type(rx_type), BFI);
+ MD_TRC_L1Audio_Msg_VM_DEBUG( DP2_3G_debug_info0, DP2_3G_debug_info1, DP2_3G_debug_info7 );
+ }
+#endif
+
+ // process previous buffer
+ vmBuf = vm.vmBuf;
+
+ if (vmBuf[0] == VM_VM_MAGIC_HEADER) //already buffer VM
+ {
+ u2VM_buffer_size = VM_VM_HEADER_SIZE + VM_VM_CONTROL_SIZE + vm.sc_len + vm.sd_len + VM_VM_DBGINFO_TOTAL_SIZE;
+ kal_prompt_trace(MOD_L1SP, "TchRecordHisr SC Len= %d, SD Len= %d", vm.sc_len, vm.sd_len);
+
+ //when vm logging and VOC are both on, only send the data to vm logging to reduce log size
+ if (vm.isVmLOn)
+ {
+ if (vmRec_queryOutputBufFreeSpace() < u2VM_buffer_size)
+ {
+ // drop this log and add counter
+ vm.vm_lost_count++;
+ MD_TRC_VM_REC_HISR_VM_DATA_LOST(vm.vm_lost_count, 2);
+ goto leaveProc;
+ }
+ else
+ {
+ vmRec_writeVmToOutputBuf(u2VM_buffer_size, vmBuf);
+ }
+ }
+ else
+ {
+ vocWriteVocToCatcher(u2VM_buffer_size, vmBuf);
+ }
+
+ vm.vm_lost_count = 0;
+ vmBuf[0] = 0;
+ vmBuf[1] = 0;
+ vmBuf[2] = 0;
+ vmBuf[3] = 0;
+ }
+
+ // formatting
+ Sal_VM_Frame vmfrm_t;
+
+ switch (sp_state)
+ {
+ case L1SP_STATE_4G_SPEECH_ON:
+ SAL_VM_GetFrame3G(&vmfrm_t);
+ vmFormatter_4g(vmBuf, &vmfrm_t);
+ break;
+ case L1SP_STATE_3G_SPEECH_ON:
+ case L1SP_STATE_3G324M_SPEECH_ON:
+ SAL_VM_GetFrame3G(&vmfrm_t);
+ vmFormatter_amr(vmBuf, &vmfrm_t);
+ break;
+ case L1SP_STATE_C2K_SPEECH_ON:
+ SAL_VM_GetFrameC2K(&vmfrm_t);
+ vmFormatter_c2k(vmBuf, &vmfrm_t);
+ break;
+ default:
+ if (L1SP_Get_isStandByMode() || pcmEx_isRunInIdleMode())
+ {
+ SAL_VM_GetFrame3G(&vmfrm_t);
+ vmFormatter_standby(vmBuf, &vmfrm_t);
+ }
+ else
+ {
+ SAL_VM_GetFrame2G(&vmfrm_t);
+ vmFormatter_2g(vmBuf, &vmfrm_t);
+ }
+ break;
+ }
+
+leaveProc:
+ kal_give_spinlock(vm.lockId);
+
+ if (vm.vm_hdlr)
+ {
+ vm.vm_hdlr();
+ }
+
+leaveHisr:
+ SP_updateEmCodecEvent();
+ return;
+}
+
+void VM_Init(void)
+{
+ vm.lockId = kal_create_spinlock("VM_LOCK");
+}
+
+void VMREC_ConfigEpl(void)
+{
+ // only support phone call VM record dynamic change from AP side
+ if (vm.isVocOn || vm.isVmLOn)
+ {
+ kal_uint16 recordInfo = L1Audio_GetDebugInfo(VM_DEBUG_INFO);
+
+ if (ChkL1ClsFltr_L1Audio_VoC_TRACE_EPL())
+ {
+ recordInfo |= (VM_EPL_1STSET_RECORD_FLAG + VM_EPL_2NDSET_RECORD_FLAG);
+ recordInfo |= VM_EPL_REFMIC_RECORD_FLAG;
+ recordInfo |= VM_EPL_ECHOREF_RECORD_FLAG;
+ recordInfo |= VM_EPL_3RDMIC_RECORD_FLAG;
+ recordInfo |= VM_EPL_2NDECHOREF_RECORD_FLAG;
+ }
+
+ MD_TRC_VM_REC_DEBUG_INFO(recordInfo);
+
+ // config to open, and did not open yet
+ if (((recordInfo & (VM_EPL_1STSET_RECORD_FLAG + VM_EPL_2NDSET_RECORD_FLAG)) != 0)
+ && ((vm.record_info & (VM_EPL_1STSET_RECORD_FLAG + VM_EPL_2NDSET_RECORD_FLAG)) == 0))
+ {
+ //EPL open
+ recordInfo |= VM_EPL_REFMIC_RECORD_FLAG;
+ recordInfo |= VM_EPL_ECHOREF_RECORD_FLAG;
+ recordInfo |= VM_EPL_3RDMIC_RECORD_FLAG;
+ recordInfo |= VM_EPL_2NDECHOREF_RECORD_FLAG;
+
+ // Initial
+ vm.record_info = recordInfo;
+ vm.vm_lost_count = 0;
+ vm.pcm_lost_count = 0;
+ vm.vm_counter = 0;
+
+ vm.pcmBuf = vmEPLPCMInputBuf;
+ memset(vmEPLPCMInputBuf, 0, sizeof(uint16)*VM_EPL_PCM_BUFFER_SIZE);
+
+ // Enable EPL
+ L1Audio_HookHisrHandler(DP_D2C_VMEPL_REC_INT, (L1Audio_EventHandler)vmTchPcmRecordHisr, 0);
+ AM_PCM8K_RecordOn(AM_PCM8KREC_APP_TYPE_VMEPL, 0);
+ }
+ }
+}
+
+/**
+ @vm_hdlr: handler
+ @isVoc: is call from vm over catcher.
+*/
+void VMREC_Start(void (*vm_hdlr)(void), bool isVoc)
+{
+ if (AM_IsAmInSpeechState())
+ {
+ //decide the open
+ bool isAlreadyOn = (vm.isVocOn || vm.isVmLOn);
+
+ if (isVoc)
+ {
+ //ASSERT(!vm.isVocOn); // prevent re-entry
+ vm.isVocOn = true;
+ }
+ else // normal vm
+ {
+ //ASSERT(!vm.isVmLOn); // prevent re-entry
+ vm.isVmLOn = true;
+ vm.vm_hdlr = vm_hdlr;
+ }
+
+#ifdef __SENSITIVE_DATA_MOSAIC__
+ if (dhl_mask_sensitive_trace_on())
+ {
+ vm.isMosaic = true;
+ return;
+ }
+ else
+ {
+ vm.isMosaic = false;
+ }
+#endif
+
+ //already on
+ if (isAlreadyOn)
+ {
+ VMREC_ConfigEpl();
+ return;
+ }
+ else
+ {
+ // Initial
+ vm.audId = L1Audio_GetAudioID();
+ L1Audio_SetFlag(vm.audId); //Be careful.Before Locking SleepMode, to access DSP sherrif tasks much time. So access DSP must be after SetFlag
+
+ vm.state = VM_STATE_RECORD;
+
+ vm.control_1 = VM_VM_CTRL_UL_ON;
+ vm.control_2 = VM_VM_CTRL_DL_ON;
+ vm.control_3 = VM_CHIP_ID;
+ vm.control_4 = 0;
+ vm.control_5 = 0;
+ vm.control_6 = 0;
+ vm.control_7 = 0;
+ vm.control_8 = 0;
+ vm.control_9 = 0;
+ vm.control_10 = 0;
+
+ vm.evs_cur_sd_mode = EVS_UNDEF;
+ vm.sc_len = 0;
+ vm.sd_len = 0;
+
+ //vm buffer initital
+ vm.vmBuf = vmBuffer;
+ memset(vm.vmBuf, 0, sizeof(uint16)*VM_VM_BUFFER_SIZE);
+
+ // output buffer initial
+ vm.pOutputBufWrite = 0;
+ vm.pOutputBufRead = 0;
+ vm.outputBufSize = VMREC_OUTPUT_BUF_SIZE;
+ memset(vmRecOutputBuf, 0, sizeof(uint16)*VMREC_OUTPUT_BUF_SIZE);
+
+ VMREC_ConfigEpl();
+
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ //G-serial codec buffer initial
+ {
+ vmInitGCodecULBuf();
+ vmInitGCodecDLBuf();
+ }
+#endif
+
+#if defined(__UMTS_RAT__)
+#if defined(_EXTRA_LOG_FOR_BIT_TRUE_)
+ //TDD load need to reduce trace
+ if (SP_3G_SIM_FDD_ACTIVE == L1SP_GetSIMStatus() &&
+ (((int)L1Audio_GetDebugInfo(SPH_DEBUGINFO))& SPH_DEBUGINFO12_BIT1))
+ {
+ g_bNeedExtraLog = KAL_TRUE;
+ }
+#endif
+#endif
+ // enalbe normal VM record
+ L1Audio_HookHisrHandler(DP_D2C_VM_REC_INT, (L1Audio_EventHandler)vmTchRecordHisr, 0);
+ AM_VMRecordOn();
+ }
+ }
+}
+
+/**
+ @isVoc: is call from voice over cater. true is yes; false is no.
+*/
+void VMREC_Stop( bool isVoc)
+{
+ // check voc & vm are both closed.
+ if (AM_IsAmInSpeechState())
+ {
+ if (isVoc)
+ {
+ //ASSERT(vm.isVocOn == true);
+ kal_take_spinlock(vm.lockId, KAL_INFINITE_WAIT);
+ vm.isVocOn = false;
+ kal_give_spinlock(vm.lockId);
+
+ if (vm.isVmLOn) //still another need vm
+ {
+ return;
+ }
+ }
+ else //record vm from media
+ {
+ //ASSERT(vm.isVmLOn == true);
+ kal_take_spinlock(vm.lockId, KAL_INFINITE_WAIT);
+ vm.isVmLOn = false;
+ vm.vm_hdlr = NULL;
+ kal_give_spinlock(vm.lockId);
+
+ if (vm.isVocOn) //still another need vm
+ {
+ return;
+ }
+ }
+
+#ifdef __SENSITIVE_DATA_MOSAIC__
+ {
+ if (vm.isMosaic)
+ {
+ return;
+ }
+ }
+#endif
+
+ if (VM_STATE_RECORD == vm.state)
+ {
+ kal_take_spinlock(vm.lockId, KAL_INFINITE_WAIT);
+ vm.state = VM_STATE_RECORD_STOP;
+ kal_give_spinlock(vm.lockId);
+
+ if (vm.record_info & (VM_EPL_1STSET_RECORD_FLAG + VM_EPL_2NDSET_RECORD_FLAG))
+ {
+ AM_PCM8K_RecordOff(false, AM_PCM8KREC_APP_TYPE_VMEPL);
+ L1Audio_UnhookHisrHandler(DP_D2C_VMEPL_REC_INT); // EPL record unhook
+
+ vm.pcmBuf = NULL;
+ }
+
+ AM_VMRecordOff();
+ L1Audio_UnhookHisrHandler(DP_D2C_VM_REC_INT); // vm record unhook
+
+ vm.vmBuf = NULL;
+ vm.state = VM_STATE_STOP;
+ vm.record_info = 0;
+
+ // output buffer clean
+ vm.pOutputBufWrite = 0;
+ vm.pOutputBufRead = 0;
+ vm.outputBufSize = 0;
+ memset(vmRecOutputBuf, 0, sizeof(uint16)*VMREC_OUTPUT_BUF_SIZE);
+
+#if defined(__G_CODEC_SUPPORT__) && defined(__VOLTE_SUPPORT__)
+ //G-serial codec buffer initial
+ {
+ vmInitGCodecULBuf();
+ vmInitGCodecDLBuf();
+ }
+#endif
+
+ // release sleep mode
+ L1Audio_ClearFlag(vm.audId);
+ L1Audio_FreeAudioID(vm.audId);
+ }
+ }
+}
diff --git a/mcu/driver/audio/src/v1/wm8904_config.c b/mcu/driver/audio/src/v1/wm8904_config.c
new file mode 100644
index 0000000..44abe1e
--- /dev/null
+++ b/mcu/driver/audio/src/v1/wm8904_config.c
@@ -0,0 +1,1194 @@
+
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+#include "stack_config.h"
+#include "kal_trace.h"
+
+
+// #include "l1audio_def.h"
+#include "l1sp_trc.h"
+#include "l1aud_common_def.h"
+
+#ifdef CONNECT_WM8904
+
+#include "dcl.h"
+#include "dcl_i2c.h"
+
+// ------------------------- added for 8904 -----------------------------------
+
+I2C_CONFIG_T wm8904_i2c_ctrl_para;
+kal_bool is_dvt_initialized = KAL_FALSE;
+DCL_HANDLE wm8904_i2c_handle = 0;
+
+kal_uint8 i2c_write_register_table[NUM_I2C_WRITE_TAB][NUM_WRITE_I2C_SINGLE_REG][LEN_WRITE_I2C_SINGLE_REG] =
+{
+ { // MIC_8k_LongSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_8k_LongSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_8k_LongSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_LongSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_LongSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_LongSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_8k_ShortSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_8k_ShortSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_8k_ShortSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_ShortSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_ShortSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_8k_ShortSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x24, 0x00},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x02},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_LongSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_LongSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_LongSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_LongSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_LongSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_LongSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x93},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_ShortSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_ShortSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // MIC_16k_ShortSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x01},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x12},
+ {0x2F, 0x00, 0x12},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_ShortSync_Analog_Bypass
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x0F},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_ShortSync_Digital_Loopback
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x01, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+ { // LINEIN_16k_ShortSync_Phone_Call
+ {0x00, 0x00, 0x00},
+ {0x04, 0x00, 0x19},
+ {0x05, 0x00, 0x43},
+ {0x06, 0x00, 0x00},
+ {0x07, 0x00, 0x00},
+ {0x0C, 0x00, 0x03},
+ {0x0E, 0x00, 0x03},
+ {0x12, 0x00, 0x0F},
+ {0x14, 0x8C, 0x5E},
+ {0x15, 0x18, 0x02},
+ {0x18, 0x00, 0x50},
+ {0x19, 0x00, 0x83},
+ {0x1A, 0x00, 0xF4},
+ {0x1B, 0x00, 0x20},
+ {0x1E, 0x00, 0xA5},
+ {0x1F, 0x00, 0xA5},
+ {0x21, 0x00, 0x00},
+ {0x24, 0x00, 0xC0},
+ {0x25, 0x00, 0xC0},
+ {0x26, 0x00, 0x00},
+ {0x2C, 0x00, 0x05},
+ {0x2D, 0x00, 0x05},
+ {0x2E, 0x00, 0x00},
+ {0x2F, 0x00, 0x00},
+ {0x39, 0x00, 0x39},
+ {0x3A, 0x00, 0xB9},
+ {0x3D, 0x00, 0x00},
+ {0x43, 0x00, 0x03},
+ {0x4B, 0x00, 0x05},
+ {0x4C, 0x00, 0xFD},
+ {0x79, 0x00, 0x09},
+ {0x5A, 0x00, 0xFF},
+ {0x62, 0x00, 0x01},
+ {0x68, 0x00, 0x05},
+ {0x74, 0x00, 0x06},
+ {0x75, 0x07, 0x01},
+ {0x76, 0x00, 0x00},
+ {0x77, 0x0C, 0x00},
+ {0x78, 0x00, 0x05},
+ {0x74, 0x00, 0x07},
+ {0x16, 0x40, 0x0A},
+ {0x16, 0x40, 0x0E},
+ },
+};
+
+
+
+void Config_WM8904(kal_int32 tab)
+{
+ if(tab==-1)
+ return;
+
+ kal_prompt_trace (MOD_L1SP,"[Scholar]Config_WM8904 with table : %d", tab);
+ kal_prompt_trace (MOD_L1SP,"[Scholar]Base Address : %d", i2c_write_register_table);
+
+ // For I2C control (SCL, SDA)
+ // GPIO 70 71
+ // SCL
+ *(volatile uint16 *)(0xA0070100) |= 0x0040; // GPIO DIR : 70
+ *(volatile uint16 *)(0xA0070300) |= 0x0040; // GPIO PULLEN : 70
+ *(volatile uint16 *)(0xA0070500) |= 0x0040; // GPIO PULLSEL : 70
+ *(volatile uint16 *)(0xA0070700) &= ~0x0040; // GPIO DINV : 70
+ *(volatile uint16 *)(0xA0072100) &= ~0x0F00; // GPIO MODE : 70
+ *(volatile uint16 *)(0xA0072100) |= 0x0100; // GPIO MODE :70
+
+ // SDA
+ *(volatile uint16 *)(0xA0070100) |= 0x0080; // GPIO DIR : 71
+ *(volatile uint16 *)(0xA0070300) |= 0x0080; // GPIO PULLEN : 71
+ *(volatile uint16 *)(0xA0070500) |= 0x0080; // GPIO PULLSEL : 71
+ *(volatile uint16 *)(0xA0070700) &= ~0x0080; // GPIO DINV : 71
+ *(volatile uint16 *)(0xA0072100) &= ~0xF000; // GPIO MODE : 71
+ *(volatile uint16 *)(0xA0072100) |= 0x1000; // GPIO MODE : 71
+
+ if (is_dvt_initialized == KAL_FALSE)
+ {
+ DclSI2C_Initialize();
+ is_dvt_initialized = KAL_TRUE;
+ }
+
+ if (wm8904_i2c_handle == 0)
+ {
+ wm8904_i2c_handle = DclSI2C_Open(DCL_I2C, DCL_I2C_OWNER_AUDIO);
+
+ ASSERT(wm8904_i2c_handle != DCL_HANDLE_INVALID);
+ ASSERT(wm8904_i2c_handle != DCL_HANDLE_OCCUPIED);
+ }
+
+ wm8904_i2c_ctrl_para.eOwner = DCL_I2C_OWNER_AUDIO;
+ wm8904_i2c_ctrl_para.fgGetHandleWait = KAL_TRUE;
+ wm8904_i2c_ctrl_para.u1SlaveAddress = 0x34;
+ wm8904_i2c_ctrl_para.u1DelayLen = 0;
+ wm8904_i2c_ctrl_para.eTransactionMode = DCL_I2C_TRANSACTION_FAST_MODE;
+ wm8904_i2c_ctrl_para.u4FastModeSpeed = 300;
+ wm8904_i2c_ctrl_para.u4HSModeSpeed = 0;
+ wm8904_i2c_ctrl_para.fgEnableDMA = KAL_FALSE;
+
+ {
+ DCL_STATUS_T rt;
+
+ rt = DclSI2C_Configure(wm8904_i2c_handle, (DCL_CONFIGURE_T *)&wm8904_i2c_ctrl_para);
+
+ if (STATUS_OK != rt)
+ {
+ kal_prompt_trace (MOD_L1SP,"[Scholar]I2C configuration status not ok: %d", rt);
+ // ASSERT(0);
+ return;
+ }
+ }
+
+
+ {
+ kal_int32 i;
+
+ for (i = 0; i < NUM_WRITE_I2C_SINGLE_REG; i++)
+ {
+ { // Write I2C
+ DCL_STATUS_T rt;
+ I2C_CTRL_SINGLE_WRITE_T write_data;
+
+ kal_prompt_trace (MOD_L1SP,"[Scholar]I2C single write: %d, %d, %d", i2c_write_register_table[tab][i][0], i2c_write_register_table[tab][i][1], i2c_write_register_table[tab][i][2]);
+
+ write_data.pu1Data = (DCL_UINT8 *)i2c_write_register_table[tab][i];
+ write_data.u4DataLen = LEN_WRITE_I2C_SINGLE_REG;
+ rt = DclSI2C_Control(wm8904_i2c_handle, I2C_CMD_SINGLE_WRITE, (DCL_CTRL_DATA_T *)&write_data);
+ if (STATUS_OK != rt)
+ {
+ kal_prompt_trace (MOD_L1SP,"[Scholar]After single write, I2C status not ok: %d", rt);
+ // ASSERT(0);
+ }
+ }
+
+ { // Write and read I2C
+ DCL_STATUS_T rt;
+ I2C_CTRL_WRITE_AND_READE_T write_n_read;
+ kal_uint8 i2c_register_buffer[2] = {0};
+
+ write_n_read.pu1InData = (DCL_UINT8 *)i2c_register_buffer;
+ write_n_read.u4InDataLen = LEN_READ_I2C_SINGLE_OUT;
+ write_n_read.pu1OutData = (DCL_UINT8 *)i2c_write_register_table[tab][i];
+ write_n_read.u4OutDataLen = LEN_READ_I2C_SINGLE_REG;
+ rt = DclSI2C_Control(wm8904_i2c_handle, I2C_CMD_WRITE_AND_READ, (DCL_CTRL_DATA_T *)&write_n_read);
+ if (STATUS_OK != rt)
+ {
+ kal_prompt_trace (MOD_L1SP,"[Scholar]After write and read, I2C status not ok: %d", rt);
+ // ASSERT(0);
+ return;
+ }
+
+ kal_prompt_trace (MOD_L1SP,"[Scholar]I2C read back : %d, %d", i2c_register_buffer[0], i2c_register_buffer[1]);
+ }
+ }
+ }
+}
+
+
+#endif // CONNECT_WM8904
+