[Feature][ZXW-237]merge P54U03 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: Id39ef8b992af691eab09c01d4ea26da89e5f4049
diff --git a/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy.bin b/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy.bin
index 994d772..1856dab 100755
--- a/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy.bin
+++ b/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy.bin
Binary files differ
diff --git a/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy_out.7z b/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy_out.7z
index 34f4813..3632ced 100755
--- a/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy_out.7z
+++ b/cp/phy/bin/zx297520v3/merge_lte_220a1_bin/ps/evb_cpuphy_out.7z
Binary files differ
diff --git a/cp/ps/driver/inc/misc/drvs_voiceprocess.h b/cp/ps/driver/inc/misc/drvs_voiceprocess.h
index 570a460..a3f11e1 100755
--- a/cp/ps/driver/inc/misc/drvs_voiceprocess.h
+++ b/cp/ps/driver/inc/misc/drvs_voiceprocess.h
@@ -185,20 +185,19 @@
 

 } T_HalAudioLoopTestPra;

 

-#ifdef ECALL_SUPPORT

 typedef enum

 {

     ECALL_ST_INIT = 0,

-	ECALL_ST_OPEN,				

-	ECALL_ST_START,		

-    ECALL_ST_IDLE,

-    ECALL_ST_RX_IDLE,

-    ECALL_ST_TX_IDLE,

-    ECALL_ST_INUSE,

-    ECALL_ST_RX_INUSE,

-    ECALL_ST_TX_INUSE,     

-	ECALL_ST_STOP,

-	ECALL_ST_CLOSE,	

+	ECALL_ST_OPEN,//1				

+	ECALL_ST_START,//2			

+    ECALL_ST_IDLE,//3	

+    ECALL_ST_RX_IDLE,//4	

+    ECALL_ST_TX_IDLE,//5	

+    ECALL_ST_INUSE,//6	

+    ECALL_ST_RX_INUSE,//7	

+    ECALL_ST_TX_INUSE,//8	     

+	ECALL_ST_STOP,//9	

+	ECALL_ST_CLOSE,//10		

     ECALL_ST_MAX

 } T_Ecall_State;

 

@@ -210,14 +209,13 @@
 	ZOSS_SEMAPHORE_ID wrSemaphore; 

 	ZOSS_SEMAPHORE_ID rdSemaphore;

 	T_Ecall_State ecallSta;

-    T_Ecall_State ecallRxSta;

-	T_Ecall_State ecallTxSta;	

+    T_Ecall_State ecallRxSta;//two state,idle/inuse

+	T_Ecall_State ecallTxSta;//two state,idle/inuse	

 	unsigned char* rxDataBuf;

 	unsigned char* txDataBuf;

 	int dataBufSize;

 

 } T_Hal_EcallData; 

-#endif

 

 typedef struct

 {

@@ -283,9 +281,7 @@
     BOOL vpLoopBkRunning;//23 

 	BOOL rxMuteEn; //24

 	BOOL firstRegZCATFlag; //25

-#ifdef ECALL_SUPPORT	

 	T_Hal_EcallData	ecallData;//26

-#endif	

 } T_zDrvVoice_GbVar; //T_zDrvVoice_GbVar

 

 typedef struct

diff --git a/cp/ps/driver/inc/misc/drvs_volte.h b/cp/ps/driver/inc/misc/drvs_volte.h
index 980e0e3..63ce768 100755
--- a/cp/ps/driver/inc/misc/drvs_volte.h
+++ b/cp/ps/driver/inc/misc/drvs_volte.h
@@ -60,7 +60,6 @@
 

 } T_DrvVoice_3G_Opt;

 

-#ifdef ECALL_SUPPORT

  typedef struct 

  {

 	 

@@ -69,7 +68,6 @@
 	 SINT32 (*drv_Ecall_Write)(UINT8 *pBuf,UINT32 inSize);		

  

  } T_DrvEcall_Opt;

-#endif

 

  typedef struct 

  {

@@ -93,8 +91,7 @@
 SINT32 zDrvVolte_AmrDecoder(UINT8 *pInputBuf,UINT32 inSize,UINT8 *pOutputBuf,UINT32* pPutSize);

 VOID zDrvVolte_AmrEncoderDeinit(VOID);

 VOID zDrvVolte_AmrDecoderDeinit(VOID);

-#ifdef ECALL_SUPPORT

 VOID zDrvEcall_SetCallbacks(T_DrvEcall_Opt ecallObj);

-#endif

+

 #endif

 

diff --git a/cp/ps/driver/src/chipsets/src/audio_base/audio_lib/amr/lib/armv7-a/GCC/amr.a b/cp/ps/driver/src/chipsets/src/audio_base/audio_lib/amr/lib/armv7-a/GCC/amr.a
index e0cef6a..dd137ab 100755
--- a/cp/ps/driver/src/chipsets/src/audio_base/audio_lib/amr/lib/armv7-a/GCC/amr.a
+++ b/cp/ps/driver/src/chipsets/src/audio_base/audio_lib/amr/lib/armv7-a/GCC/amr.a
Binary files differ
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voiceprocess.c b/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voiceprocess.c
index efec067..784a254 100755
--- a/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voiceprocess.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voiceprocess.c
@@ -302,7 +302,7 @@
 #ifdef VB_DATA_LOSS_TEST

 

 	if((timer_cb_count%1000 ) == 0){

-		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:timer_cb_count(%d)\n",__func__,timer_cb_count);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:timer_cb_count(%d)\n",__FUNCTION__,timer_cb_count);

 		if(timer_cb_count> 10000000) 

 			timer_cb_count=0;

 	}

@@ -354,7 +354,7 @@
 	read_pos = voice_buff[DOWN_LINK]->read_pos;

 	write_pos = voice_buff[DOWN_LINK]->write_pos;	

 	if(vb_write_count == 0){

-		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: first read_pos=%d write_pos=%d \n",__func__,read_pos,write_pos);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: first read_pos=%d write_pos=%d \n",__FUNCTION__,read_pos,write_pos);

 	}

 

 	

@@ -363,7 +363,7 @@
    		 first_full_flag++;

 		VB_INT_OVERFLOW(first_full_flag);

 		if(first_full_flag == 1)

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: writebuffer is full  read_pos %d,write_pos %d,vb_write_count %d,count %d\n",__func__,read_pos,write_pos,vb_write_count,count);

+			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: writebuffer is full  read_pos %d,write_pos %d,vb_write_count %d,count %d\n",__FUNCTION__,read_pos,write_pos,vb_write_count,count);

 		return DRV_ERROR_FULL;

 	}

 	else {

@@ -390,7 +390,7 @@
 	read_pos = voice_buff[UP_LINK]->read_pos;

 	write_pos = voice_buff[UP_LINK]->write_pos;

 	if(vb_read_count == 0){

-		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: first read_pos=%d write_pos=%d \n",__func__,read_pos,write_pos);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: first read_pos=%d write_pos=%d \n",__FUNCTION__,read_pos,write_pos);

 	}

 

 	if ((count > 0) && (count <= MAX_BUF_SIZE))  {

@@ -398,7 +398,7 @@
 			first_empty_flag++;

 			VB_INT_OVERFLOW(first_empty_flag);

 			if(first_empty_flag ==1)

-				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: readbuffer is empty,read_pos %d,write_pos %d,vb_read_count %d,count %d\n",__func__,read_pos,write_pos,vb_read_count,count);

+				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: readbuffer is empty,read_pos %d,write_pos %d,vb_read_count %d,count %d\n",__FUNCTION__,read_pos,write_pos,vb_read_count,count);

 			//add memset,del return . edit for  far end hear near end repreat voice pcm, FROM MBB TEST

 			

 		#ifndef  VB_DATA_LOSS_TEST

@@ -518,6 +518,17 @@
 

 

 #ifdef ECALL_SUPPORT

+int eWrErr = 0;

+UINT8 e_reg_flag = 0;

+

+UINT32 e_startCount = 0;

+UINT32 e_stopCount = 0;

+UINT32 e_wrCount = 0;

+UINT32 e_rdCount = 0;

+T_Ecall_State preEcallRxSta = 0;

+T_Ecall_State preEcallTxSta = 0;	

+

+//tx

 SINT32 rdsem_count_Init(T_Sem_Owner owner)

 {

 	UINT32 i = 0;

@@ -528,6 +539,20 @@
 	    rdSem = g_voiceVar.ecallData.rdSemaphore;		

 		semCount = zOss_GetSemaphoreCount(rdSem);

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "rdsem_count_Init owner=%d, rxSem count=%d\n",owner,semCount);

+#if 1

+		Count = 1 - semCount;	

+		if(Count > 0) {

+			for(i = 0; i < Count; i++) {

+				zOss_PutSemaphore(rdSem);

+			}

+		} else if(Count < 0) {

+			Count = 0 - Count;

+			for(i = 0; i < Count; i++) {

+				zOss_GetSemaphore(rdSem, ZOSS_NO_WAIT);

+			}

+		}

+		

+#else

 

 		Count = semCount;

 		if(Count > 0)  {

@@ -535,10 +560,12 @@
 				zOss_GetSemaphore(rdSem, ZOSS_NO_WAIT);

 			}

 		}

+#endif		

     }

+

 	return DRV_SUCCESS;

 }

-

+//rx

 SINT32 wrsem_count_Init(T_Sem_Owner owner)

 {

 	UINT32 i = 0;

@@ -552,8 +579,8 @@
 		semCount = zOss_GetSemaphoreCount(wrSem);

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "wrsem_count_Init owner=%d, txSem count=%d \n",owner,semCount);

 

-		

-		Count = 3 - semCount;	

+#if 1

+		Count = 1 - semCount;	

 		if(Count > 0) {

 			for(i = 0; i < Count; i++) {

 				zOss_PutSemaphore(wrSem);

@@ -564,8 +591,20 @@
 				zOss_GetSemaphore(wrSem, ZOSS_NO_WAIT);

 			}

 		}

+

+#else

+

+		Count = semCount;

+		if(Count > 0)  {

+			for(i = 0; i < Count; i++) {

+				zOss_GetSemaphore(wrSem, ZOSS_NO_WAIT);

+			}

+		}

+

+#endif	

     }

- 

+

+    eWrErr = 0;

 	return DRV_SUCCESS;

 }

 void ecallTimerCallBack(SINT32 para)

@@ -605,10 +644,6 @@
 	}

 	g_voiceVar.ecallData.ecallSta = ECALL_ST_INIT;	

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Init success. \r\n");

-

-

-

-

 	

 	return DRV_SUCCESS;	

 }

@@ -642,7 +677,6 @@
 	{

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open error: fs =%d\n", fs);

 		return DRV_ERR_INVALID_PARAM;

-

 	}

 

 

@@ -665,7 +699,8 @@
 	g_voiceVar.ecallData.ecallRxSta = ECALL_ST_RX_IDLE;

 	g_voiceVar.ecallData.ecallTxSta = ECALL_ST_TX_IDLE;

 

-	

+	e_startCount = 0;

+    e_stopCount = 0;

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open  end!\n");

 

 	return DRV_SUCCESS;

@@ -679,7 +714,7 @@
 

 	if (g_voiceVar.ecallData.ecallSta ==  ECALL_ST_CLOSE)

 	{

-		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Close error: ecallSta =%d\n", g_voiceVar.ecallData.ecallSta);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Close repeat: ecallSta =%d\n", g_voiceVar.ecallData.ecallSta);

 		return DRV_ERR_NOT_OPENED;

 	}

 

@@ -692,11 +727,17 @@
 	zOss_Free(g_voiceVar.ecallData.rxDataBuf);

 	zOss_Free(g_voiceVar.ecallData.txDataBuf);

 

+

 	g_voiceVar.ecallData.dataBufSize = 0;

 	g_voiceVar.ecallData.rxDataBuf = NULL;

 	g_voiceVar.ecallData.txDataBuf = NULL;

 	g_voiceVar.ecallData.ecallSta = ECALL_ST_CLOSE;

+	g_voiceVar.ecallData.ecallRxSta = ECALL_ST_RX_IDLE;

+	g_voiceVar.ecallData.ecallTxSta = ECALL_ST_TX_IDLE;

+	preEcallRxSta = ECALL_ST_RX_IDLE;	    

+	preEcallTxSta = ECALL_ST_TX_IDLE;

 

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s e_startCount=%d e_stopCount=%d \n",__FUNCTION__,e_startCount,e_stopCount);

 	

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Close  end!\n");

 

@@ -707,22 +748,30 @@
 }

 

 

+

 SINT32 ecall_Start(VOID)

 {

 	SINT32 ret = DRV_SUCCESS;

 

-	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Start start\n");

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s start e_startCount=%d \n",__FUNCTION__,e_startCount);

+	if(g_voiceVar.ecallData.ecallSta == ECALL_ST_START)

+	{

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Start repeat ecallSta=%d\n",g_voiceVar.ecallData.ecallSta);

+		return DRV_ERR_OPEN_TIMES;

+	}	

 	if((g_voiceVar.ecallData.ecallSta != ECALL_ST_OPEN)&&(g_voiceVar.ecallData.ecallSta != ECALL_ST_STOP))

 	{

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Start not support ecallSta=%d\n",g_voiceVar.ecallData.ecallSta);

-		ret = DRV_ERR_START_TIMES;

+		return DRV_ERR_START_TIMES;

 	}

 

 

 	zOss_StartTimer(g_voiceVar.ecallData.timerId, 20, ecallTimerCallBack, 0);

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Start zOss_StartTimer start\n");

 	g_voiceVar.ecallData.ecallSta = ECALL_ST_START;	

-	

+	e_startCount++;

+	e_wrCount = 0;

+	e_rdCount = 0;	

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,  "ecall_Start end \n");

 

 	return DRV_SUCCESS;

@@ -731,10 +780,12 @@
 SINT32 ecall_Stop(VOID)

 {

 	SINT32  ret = DRV_SUCCESS;

-	if(g_voiceVar.ecallData.ecallSta != ECALL_ST_STOP)

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s start e_stopCount=%d \n",__FUNCTION__,e_stopCount);

+	

+	if((g_voiceVar.ecallData.ecallSta == ECALL_ST_STOP)||(g_voiceVar.ecallData.ecallSta == ECALL_ST_CLOSE))

 	{

-		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Stop not support ecallSta=%d\n",g_voiceVar.ecallData.ecallSta);

-		ret = DRV_ERR_START_TIMES;

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Stop repeat ecallSta=%d\n",g_voiceVar.ecallData.ecallSta);

+		return DRV_ERR_START_TIMES;

 	}  

 

 	zOss_PutSemaphore(g_voiceVar.ecallData.rdSemaphore);

@@ -744,6 +795,11 @@
 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Stop zOss_StopTimer\n");

 

 	g_voiceVar.ecallData.ecallSta = ECALL_ST_STOP;	

+    e_stopCount ++;

+

+	

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: e_rdCount=%d e_wrCount=%d \n",__FUNCTION__,e_rdCount,e_wrCount);

+

 

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Stop end\n");

 	return ret;

@@ -756,40 +812,37 @@
 	

 	if(g_voiceVar.ecallData.opt.drv_Get_Ecall_State == NULL)

 	{	

+	

 	    zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "update_ecall_state get__ecall_state fun not register!\n");

 		return DRV_ERR_NOT_SUPPORTED;

 	}

+	if((dir != DIR_TX)&&(dir != DIR_RX))

+	{

+				

+		ret = DRV_ERR_INVALID_PARAM;	

+		

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state  dir not support return, dir = %d ret=%d\n",dir,ret);

+	}	

 

 	if(g_voiceVar.ecallData.opt.drv_Get_Ecall_State() == 1)	

 	{						

-		if((dir == DIR_RX)&&(g_voiceVar.ecallData.ecallRxSta != ECALL_ST_RX_INUSE))

+		if(dir == DIR_RX)

 		{

-			wrsem_count_Init(ECALL_SEM);

-			g_voiceVar.ecallData.ecallRxSta = ECALL_ST_RX_INUSE;

-			//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state rx state change old ecallRxSta = %d\n", g_voiceVar.ecallData.ecallRxSta);

 			

-		}

-		else if((dir == DIR_TX)&&(g_voiceVar.ecallData.ecallTxSta != ECALL_ST_TX_INUSE))

-		{

-

-			rdsem_count_Init(ECALL_SEM);			

-			g_voiceVar.ecallData.ecallTxSta = ECALL_ST_TX_INUSE;	

-			//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state tx state change old ecallTxSta = %d\n", g_voiceVar.ecallData.ecallTxSta);

-			

-		}

-		else if(dir == DIR_RX)

-		{

+			preEcallRxSta = g_voiceVar.ecallData.ecallRxSta;

 			g_voiceVar.ecallData.ecallRxSta = ECALL_ST_RX_INUSE;

+			//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state rx state change to ecallRxSta = %d\n", g_voiceVar.ecallData.ecallRxSta);

+			

 		}

 		else if(dir == DIR_TX)

 		{

+

+			preEcallTxSta = g_voiceVar.ecallData.ecallTxSta;			

 			g_voiceVar.ecallData.ecallTxSta = ECALL_ST_TX_INUSE;	

-		}		

-		else

-		{

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state return 1,but dir not support dir = %d\n",dir);

-			ret = DRV_ERR_INVALID_PARAM;			

-		}	

+			//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state tx state change to ecallTxSta = %d\n", g_voiceVar.ecallData.ecallTxSta);

+			

+		}

+	

 		

 

 	}

@@ -797,46 +850,28 @@
 	{

 	    if(dir == DIR_RX)

 		{

+			preEcallRxSta = g_voiceVar.ecallData.ecallRxSta;		

 			g_voiceVar.ecallData.ecallRxSta = ECALL_ST_RX_IDLE;	

 		

 	    }

 		else if(dir == DIR_TX)

 		{

+			preEcallTxSta = g_voiceVar.ecallData.ecallTxSta;		

 			g_voiceVar.ecallData.ecallTxSta = ECALL_ST_TX_IDLE;

 

 		}

-		else

-		{

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state return 0,but dir not support dir = %d\n",dir);

-			ret = DRV_ERR_INVALID_PARAM;

-

-		}		

+		

 

 	}	

-	if((g_voiceVar.ecallData.ecallRxSta == ECALL_ST_RX_IDLE)&&(g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_IDLE))

-	{

-		if(g_voiceVar.ecallData.ecallSta == ECALL_ST_START)

-		{

-	    	ret = ecall_Stop();	

-			if (ret != DRV_SUCCESS)

-			{

-				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state ecall_Start err\n");

-			}

-		}

-		

-	}

-	else

-	{

-		if(g_voiceVar.ecallData.ecallSta != ECALL_ST_START)

-		{

-			ret = ecall_Start();

-			if (ret != DRV_SUCCESS)

-			{

-				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state ecall_Stop err\n");

-			}		

-		}

-	}

 	

+	if((dir == DIR_TX)&&( preEcallTxSta == ECALL_ST_TX_IDLE)&&(g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_INUSE))

+	{

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:dir=%d ecallSta=%d ecallRxSta=%d ecallTxSta=%d preEcallRxSta=%d preEcallTxSta=%d \n",__FUNCTION__,dir,g_voiceVar.ecallData.ecallSta, \

+			g_voiceVar.ecallData.ecallRxSta,g_voiceVar.ecallData.ecallTxSta,preEcallRxSta,preEcallTxSta);

+		rdsem_count_Init(ECALL_SEM);

+

+	}

+		

 	return ret;

 }

 

@@ -854,13 +889,14 @@
 		return DRV_ERR_INVALID_PARAM;

 	}

 

-	if ((g_voiceVar.ecallData.ecallSta == ECALL_ST_INIT)||(g_voiceVar.ecallData.ecallSta == ECALL_ST_CLOSE) ) 

+	if ((g_voiceVar.ecallData.ecallSta == ECALL_ST_INIT)||(g_voiceVar.ecallData.ecallSta == ECALL_ST_CLOSE)) 

 	{

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_GetRxBuf error, invalid ecallSta = %d\n", g_voiceVar.ecallData.ecallSta);

 	

 		return DRV_ERR_NOT_OPENED;

 	}

-	if ((g_voiceVar.ecallData.txDataBuf == NULL) || (g_voiceVar.ecallData.dataBufSize == 0)) 

+	

+	if ((g_voiceVar.ecallData.rxDataBuf == NULL) || (g_voiceVar.ecallData.dataBufSize == 0)) 

 	{

 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_GetRxBuf error, return para is null !\n");

 		return DRV_ERROR;

@@ -1114,18 +1150,20 @@
 	{	

 		return DRV_ERR_NOT_SUPPORTED;

 	}

-	if( g_voiceVar.ecallData.ecallRxSta == ECALL_ST_RX_INUSE)

-	{

-		zOss_GetSemaphore(g_voiceVar.ecallData.wrSemaphore, 60);

+

+	ret = zOss_GetSemaphore(g_voiceVar.ecallData.wrSemaphore, 20);

+	if(ret == ZOSS_SUCCESS){

 		ret = g_voiceVar.ecallData.opt.drv_Ecall_Write(pBuf, uiLen);

+		e_wrCount++;

 	}

-	else

-	{

-		ret = g_voiceVar.ecallData.opt.drv_Ecall_Write(pBuf, uiLen);		

+	else{

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: get sem timeout ret=%d \n",__FUNCTION__,ret);

 		

-	}	

+	}

+

 	return ret;

 }

+

 SINT32 ecall_Read(const UINT8 **pBuf, UINT32 *uiLen)

 {

 	int ret = 0;

@@ -1136,14 +1174,16 @@
 	}

 	if( g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_INUSE)

 	{

-	    zOss_GetSemaphore(g_voiceVar.ecallData.rdSemaphore,  60);

-		ret = g_voiceVar.ecallData.opt.drv_Ecall_Read(*pBuf, uiLen);

+	    ret = zOss_GetSemaphore(g_voiceVar.ecallData.rdSemaphore,  20);

+		if(ret == ZOSS_SUCCESS){

+			ret = g_voiceVar.ecallData.opt.drv_Ecall_Read(*pBuf, uiLen);

+			e_rdCount++;

+		}

+		else{

+			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: get sem timeout ret=%d \n",__FUNCTION__,ret);

+			

+		}		

 	}

-	else

-	{

-		ret = zDrvExtAudio_Read(pBuf, uiLen);

-	}

-

 

 	return ret;

 }

@@ -1302,6 +1342,10 @@
     zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "cp drv_dtmftx_report, dtmf_string=%c, string_len=%d\n", *dtmf_string, string_len);

 }

 #endif

+

+UINT32 ext_aRdCount = 0;

+UINT32 ext_aRdFBufCount = 0;

+

 SINT32 vp_Open(T_ZDrvVoice_MODE voiceMode)

 {

 	SINT32 ret = DRV_SUCCESS;

@@ -1445,14 +1489,6 @@
 #endif

 #endif

 

-#ifdef ECALL_SUPPORT

-	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

-	{

-		rdsem_count_Init(ECALL_SEM);

-		wrsem_count_Init(ECALL_SEM);

-        //zDrvEcall_SetCallbacks(t_ecallObj);//for test

-	}

-#endif		

 	g_voiceVar.muteCount = 0;

 	s_speechState.txSaveLen = 0;

 	s_speechState.rxSaveLen = 0;

@@ -1518,6 +1554,42 @@
 	vb_write_count = 0;	

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Open  init voice buffer val!\n");

 #endif

+#ifdef ECALL_SUPPORT

+		

+	

+	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

+	{

+		//zDrvEcall_SetCallbacks(t_ecallObj);//for test

+

+		if((g_voiceVar.ecallData.opt.drv_Get_Ecall_State != NULL)&&(g_voiceVar.voiceMode != VOICE_LTE_MODE))

+		{

+			e_reg_flag = 1;

+			rdsem_count_Init(ECALL_SEM);

+			wrsem_count_Init(ECALL_SEM);			

+		}

+		else

+		{

+			e_reg_flag = 0;

+

+		}

+

+	

+

+	}

+	else

+	{

+		e_reg_flag = 0;

+	

+	}

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:ecall check, voiceMode=%d,e_reg_flag=%d \n",__FUNCTION__,voiceMode,e_reg_flag);

+	

+		

+#endif		

+

+	ext_aRdCount = 0;

+	ext_aRdFBufCount = 0;

+

+

 	return DRV_SUCCESS;

 

 }

@@ -1559,7 +1631,7 @@
         zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_CfgParam zDrvVp_DtmfSoftwareStart end\n");

     }

 #ifdef ECALL_SUPPORT	

-	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

+	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(e_reg_flag == 1))

 	{

 

 	   if(g_voiceVar.volteIsWb == 1)

@@ -1574,7 +1646,20 @@
 	   if (ret != DRV_SUCCESS)

 	   {

 		   zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open error,ret=%d", ret);

+

+		   e_reg_flag = 0;

 	   }

+	   else

+	   {

+

+			ret = ecall_Start();

+			if (ret != DRV_SUCCESS)

+			{

+				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: ecall_Start err,ret=%d\n",ret);

+			}

+		

+	   }

+

 	   

 	

 	}

@@ -2170,13 +2255,19 @@
         zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Close zDrvVp_DtmfSoftwareStop end\n");

     }

 #ifdef ECALL_SUPPORT

-	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

+	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(e_reg_flag == 1))

 	{

+    	ret = ecall_Stop();	

+		if (ret != DRV_SUCCESS)

+		{

+			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "update_ecall_state ecall_Stop err,ret=%d\n",ret);

+		}	

 		ret = ecall_Close();

 		if (ret != DRV_SUCCESS)

 		{

 		   zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open error,ret=%d", ret);

 		}	

+		e_reg_flag = 0;

 	}

 #endif	

 	g_voiceVar.vpI2sStatus = VP_I2S_IDLE;

@@ -2194,9 +2285,13 @@
 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Close,s_vpState.inOutBufSize=%x\n", s_vpState.inOutBufSize);

 #if defined(CONFIG_VOICE_BUFFER_DRV) && defined(_VBUFF_IN_MULTI_CORE)

 

-	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: timer_cb_count %d,first_full_flag %d,first_empty_flag %d,vb_read_count %d,vb_write_count %d!\n",__func__,timer_cb_count,first_full_flag,first_empty_flag,vb_read_count,vb_write_count);

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: timer_cb_count %d,first_full_flag %d,first_empty_flag %d,vb_read_count %d,vb_write_count %d!\n",__FUNCTION__,timer_cb_count,first_full_flag,first_empty_flag,vb_read_count,vb_write_count);

 #endif

 

+	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: ext_aRdCount %d,ext_aRdFBufCount %d!\n",__FUNCTION__,ext_aRdCount,ext_aRdFBufCount);

+

+

+

 	return DRV_SUCCESS;

 }

 

@@ -2395,6 +2490,16 @@
 	}

 

 #endif

+#ifdef ECALL_SUPPORT

+	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(e_reg_flag == 1))

+	{

+

+		rdsem_count_Init(ECALL_SEM);

+		wrsem_count_Init(ECALL_SEM);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: ecall sem init \n",__FUNCTION__);

+		

+    }

+#endif

 	

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart end.\n");

 	return ret;

@@ -2501,7 +2606,17 @@
 		g_voiceVar.vpI2sStatus = VP_I2S_OPEN;

 		return DRV_ERROR;

 	}

+#ifdef ECALL_SUPPORT

 

+	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(e_reg_flag == 1))

+	{

+

+		rdsem_count_Init(ECALL_SEM);

+		wrsem_count_Init(ECALL_SEM);

+		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: ecall sem init \n",__FUNCTION__);

+		

+    }

+#endif

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceWorkStart end,and put sema success.\n");

 

 	return DRV_SUCCESS;

@@ -2536,16 +2651,7 @@
 	//zDrvI2s_TxRlsSemaBeforeStop(I2S_1);

 	zDrvExtAudio_RlsAllSemaBeforeStop();

 #endif

-#ifdef ECALL_SUPPORT

-	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

-	{

-    	ret = ecall_Stop();	

-		if (ret != DRV_SUCCESS)

-		{

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVp_VoiceWorkStop ecall_Stop err\n");

-		}

-	}

-#endif	

+	

 	zDrvI2s_RxRlsSemaBeforeStop(I2S_2);

 	zDrvI2s_TxRlsSemaBeforeStop(I2S_2);

 

@@ -2663,16 +2769,6 @@
 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStop zOss_StopTimer\n");

 #endif

 	}

-#ifdef ECALL_SUPPORT	

-	if(g_voiceVar.audio_ctrlFlag.isUseEcall == 1)

-	{

-    	ret = ecall_Stop();	

-		if (ret != DRV_SUCCESS)

-		{

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVolte_ReadStop ecall_Stop err\n");

-		}

-	}

-#endif

 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVolte_ReadStop\n");

 	return ret;

 }

@@ -2836,12 +2932,12 @@
 SINT32 vp_WriteDataToCodec(UINT8 *pBuf, UINT32 count)

 {

 	SINT32  ret = DRV_SUCCESS;

+	SINT32  e_ret = DRV_SUCCESS;	

 	UINT8 *write_buf = NULL;

 	UINT32 write_len = 0;

 	UINT8 *e_write_buf = NULL;

 	UINT32 e_write_len = 0;

 	UINT32 i = 0, j = 0;

-    UINT8 e_reg_flag = 0;

 #ifdef TEST_WHITE_NOISE

 	// UINT32 tempCount = 0;

 	//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "test the white noise");

@@ -2860,61 +2956,52 @@
 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_WriteDataToCodec write data length err,count=%d,writebuffersize=%d \n", count, s_speechState.i2sWriteParam.buffersize);

 		return DRV_ERR_INVALID_PARAM;

 	}

-#ifdef ECALL_SUPPORT	

-	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(g_voiceVar.ecallData.opt.drv_Get_Ecall_State != NULL))

-	{

-	 	e_reg_flag = 1;

-	}

-	else

-	{

-		e_reg_flag = 0;

+	#ifdef ECALL_SUPPORT	

 

-	}

-	

 	if(e_reg_flag == 1)

 	{		

-		ret = update_ecall_state(DIR_RX); 

-		if (ret == DRV_ERR_NOT_SUPPORTED)

+		e_ret = update_ecall_state(DIR_RX); 

+		if (e_ret == DRV_ERR_NOT_SUPPORTED)

 		{

-			zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "vp_WriteDataToCodec get__ecall_state fun not register or invalid para !\n");

+			zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "vp_WriteDataToCodec get__ecall_state fun not register or invalid para,e_ret=%d !\n",e_ret);

 	

 		}	

 	}	

-#endif

+	#endif

 

 #ifdef  CONFIG_VOICE_BUFFER_DRV  	

 

-#ifdef TEST_WHITE_NOISE

+	#ifdef TEST_WHITE_NOISE

 

-		zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pVoiceTempBuf, s_speechState.totalFrameBufSize);

+	zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pVoiceTempBuf, s_speechState.totalFrameBufSize);

 

-		pVoiceTempBuf += s_speechState.totalFrameBufSize;

-		tempCount += s_speechState.totalFrameBufSize;

-		if (tempCount >= 0x4df80)   //307200

-			//if(tempCount >= 0x4e200)   //320000

+	pVoiceTempBuf += s_speechState.totalFrameBufSize;

+	tempCount += s_speechState.totalFrameBufSize;

+	if (tempCount >= 0x4df80)   //307200

+		//if(tempCount >= 0x4e200)   //320000

+	{

+		pVoiceTempBuf = s_voiceTempBuffer;

+		tempCount = 0;

+	}

+	#endif

+

+	#ifdef VOICE_TONE_MIXER_FUNCTION

+

+	if (mixerToneInfo.StartMixer == TRUE) 

+	{

+		//voice_ToneMixerData( s_speechState.pVpTempRxInBuffer);

+		if ((g_voiceVar.voiceInVolteMode == 1) && (g_voiceVar.volteIsWb == 1)) 

 		{

-			pVoiceTempBuf = s_voiceTempBuffer;

-			tempCount = 0;

-		}

-#endif

-

-#ifdef VOICE_TONE_MIXER_FUNCTION

-

-		if (mixerToneInfo.StartMixer == TRUE) 

+			voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 640,  s_speechState.pVpTempRxInBuffer);

+		} 

+		else 

 		{

-			//voice_ToneMixerData( s_speechState.pVpTempRxInBuffer);

-			if ((g_voiceVar.voiceInVolteMode == 1) && (g_voiceVar.volteIsWb == 1)) 

-			{

-				voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 640,  s_speechState.pVpTempRxInBuffer);

-			} 

-			else 

-			{

-				voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 320,  s_speechState.pVpTempRxInBuffer);

-			}

-

+			voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 320,  s_speechState.pVpTempRxInBuffer);

 		}

 

-#endif

+	}

+

+	#endif

 	if (pBuf !=  s_speechState.pVpTempRxInBuffer)

 	{

 		zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pBuf, s_speechState.totalFrameBufSize);

@@ -2930,12 +3017,12 @@
 	}

 	//wait_for_completion_timeout(&s_voice_completion, 60);

 	zOss_GetSemaphore(s_voiceWrSema,  60);

-#ifdef _VBUFF_IN_MULTI_CORE

+	#ifdef _VBUFF_IN_MULTI_CORE

 	voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);

 

-#else

+	#else

 	voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);

-#endif

+	#endif

 	if (g_voiceVar.voiceInVolteMode == 1)

 	{

 		s_speechState.rxSaveLen += s_speechState.totalFrameBufSize;

@@ -2944,40 +3031,42 @@
 			s_speechState.rxSaveLen = 0;

 		}

 		s_speechState.pVpTempRxInBuffer = s_vpState.pVpRxInBuffer + s_speechState.rxSaveLen;

-#ifdef _USE_VP_OUTPUT_RXOUT_DATA

+		#ifdef _USE_VP_OUTPUT_RXOUT_DATA

         s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer + s_speechState.rxSaveLen;

-#else

+		#else

 		s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer;

-#endif

+		#endif

 	}

 

 #else //not defined CONFIG_VOICE_BUFFER_DRV

+

+	#ifdef ECALL_SUPPORT

+

 	if (e_reg_flag == 1)

 	{

-#ifdef ECALL_SUPPORT	

-		ret = ecall_GetRxBuf(&e_write_buf,&e_write_len);

-		if ((ret == DRV_SUCCESS) && (e_write_buf != NULL) && (e_write_len == s_speechState.i2sWriteParam.buffersize))

+	

+		e_ret = ecall_GetRxBuf(&e_write_buf,&e_write_len);

+		if ((e_ret == DRV_SUCCESS) && (e_write_buf != NULL) && (e_write_len == s_speechState.i2sWriteParam.buffersize))

 		{

 

 			zOss_Memcpy(e_write_buf, pBuf, s_speechState.totalFrameBufSize);

 

 		}

-#endif		

-		ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);

+	

 

 	}

-	else

-	{

-		ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);

-	}

+

+	#endif	

+

+	ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);	

 	if ((ret == DRV_SUCCESS) && (write_buf != NULL) && (write_len == s_speechState.i2sWriteParam.buffersize))

 	{

 		if (pBuf !=  s_speechState.pVpTempRxInBuffer)

 		{

 			zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pBuf, s_speechState.totalFrameBufSize);

 		}

-#if 0

-#ifdef TEST_WHITE_NOISE

+		#if 0

+		#ifdef TEST_WHITE_NOISE

 		zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pVoiceTempBuf, VP_I2S_BUFFER_SIZE);

 

 		pVoiceTempBuf += VP_I2S_BUFFER_SIZE;

@@ -2987,9 +3076,9 @@
 			pVoiceTempBuf = s_voiceTempBuffer;

 			tempCount = 0;

 		}

-#endif

-#endif

-#ifdef TEST_WHITE_NOISE

+		#endif

+		#endif

+		#ifdef TEST_WHITE_NOISE

 

 		zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pVoiceTempBuf, s_speechState.totalFrameBufSize);

 

@@ -3001,9 +3090,9 @@
 			pVoiceTempBuf = s_voiceTempBuffer;

 			tempCount = 0;

 		}

-#endif

+		#endif

 

-#ifdef VOICE_TONE_MIXER_FUNCTION

+		#ifdef VOICE_TONE_MIXER_FUNCTION

 

 		if (mixerToneInfo.StartMixer == TRUE)

 		{

@@ -3019,7 +3108,7 @@
 

 		}

 

-#endif

+		#endif

 

         //dtmf检测下行写入

         if((g_voiceVar.dtmfDirSel == DTMF_RX) || (g_voiceVar.dtmfDirSel == DTMF_TXRX))

@@ -3042,14 +3131,14 @@
         }

         #endif

 

-#ifdef ECALL_SUPPORT

-        if ((g_voiceVar.vProcIsNormal == TRUE)&&(g_voiceVar.ecallData.ecallRxSta != ECALL_ST_RX_INUSE))

-#else        

+		#ifdef ECALL_SUPPORT

+        if ((g_voiceVar.vProcIsNormal == TRUE)&&((e_reg_flag != 1)||((e_reg_flag == 1)&&(g_voiceVar.ecallData.ecallRxSta == ECALL_ST_RX_IDLE))))

+		#else        

 		if (g_voiceVar.vProcIsNormal == TRUE)

-#endif		

+		#endif		

 		{

 

-			ret = VoiceProc_RxProcess(& s_speechState.pVpTempRxInBuffer, & s_speechState.pVpTempRxOutPutBuffer, s_speechState.frameCount);

+			ret = VoiceProc_RxProcess(&s_speechState.pVpTempRxInBuffer, &s_speechState.pVpTempRxOutPutBuffer, s_speechState.frameCount);

 			if (ret != DRV_SUCCESS)

 			{

 				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "write to cdec VoiceProc_RxProcess err ret=%d !\n", ret);

@@ -3110,12 +3199,12 @@
 				s_speechState.rxSaveLen = 0;

 			}

 			s_speechState.pVpTempRxInBuffer = s_vpState.pVpRxInBuffer + s_speechState.rxSaveLen;

-#ifdef _USE_VP_OUTPUT_RXOUT_DATA

+			#ifdef _USE_VP_OUTPUT_RXOUT_DATA

 			s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer + s_speechState.rxSaveLen;

 

-#else

+			#else

 			s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer;

-#endif

+			#endif

 

 		}

 

@@ -3125,31 +3214,34 @@
 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_WriteDataToCodec zDrvI2S_GetBuf:I2S1:ret=%d,write_buf = %p,write_len = %d.\n", ret, write_buf, write_len);

 		return DRV_ERROR;

 	}

+	#ifdef ECALL_SUPPORT

+

+	

 	if(e_reg_flag == 1)

 	{	

-#ifdef ECALL_SUPPORT

-		ret = ecall_Write(e_write_buf, e_write_len);

-		if (ret != DRV_SUCCESS)

-		{

-			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Write err ret=%d !\n", ret);

 

-		}		

+		e_ret = ecall_Write(e_write_buf, e_write_len);

+		if (e_ret != DRV_SUCCESS)

+		{

+            eWrErr++;

+			if(eWrErr == 1)

+				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Write err ret=%d !\n", e_ret);

+

+		}	

+

+		

 		if( g_voiceVar.ecallData.ecallRxSta == ECALL_ST_RX_INUSE)

 		{

 		    zOss_Memset(write_buf, 0, write_len);//need  mute rx		

 		}

-#endif		

-		ret = zDrvExtAudio_Write(write_buf, write_len);

+	}	

+	#endif		

+	ret = zDrvExtAudio_Write(write_buf, write_len);

 

 

 

 

 

-	}

-	else

-	{

-		ret = zDrvExtAudio_Write(write_buf, write_len);

-	}

 

 #endif

 

@@ -3163,17 +3255,18 @@
 }

 

 

+

 SINT32 vp_ReadDataFromCodec(UINT8 *pBuf, UINT32 count)

 {

 	SINT32  ret = DRV_SUCCESS;

 	UINT8 *read_buf = NULL;

 	UINT32 read_len = 0;

+

 	UINT32 i = 0, j = 0;

 #ifdef CONFIG_ARCH_ZX297520V3_CPE_SWITCH

 	UINT8 temp8bit = 0;

 	UINT8 *ptemp8bit = NULL;

 #endif

-	UINT8 e_reg_flag = 0;

 

 	if (pBuf == NULL)

 	{

@@ -3185,26 +3278,14 @@
 		zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_ReadDataFromCodec read data length err,count=%d,readbuffersize=%d \n", count, s_speechState.i2sReadParam.buffersize);

 		return DRV_ERR_INVALID_PARAM;

 	}

-#ifdef ECALL_SUPPORT	

-	if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(g_voiceVar.ecallData.opt.drv_Get_Ecall_State != NULL))

-	{

-		e_reg_flag = 1;

-	}

-	else

-	{

-		e_reg_flag = 0;

-

-	}

-

-

-	

+#ifdef ECALL_SUPPORT

 

 	if(e_reg_flag == 1)

 	{		

 		ret = update_ecall_state(DIR_TX); 

 		if (ret == DRV_ERR_NOT_SUPPORTED)

 		{

-			zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "vp_ReadDataFromCodec get__ecall_state fun not register !\n");

+			zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "vp_ReadDataFromCodec get__ecall_state fun not register,ret=%d !\n",ret);

 	

 		}	

 	}	

@@ -3214,12 +3295,12 @@
 

 //	wait_for_completion_timeout(&s_voice_completion, 60);

 	zOss_GetSemaphore(s_voiceRdSema,  60);

-#ifdef _VBUFF_IN_MULTI_CORE

+	#ifdef _VBUFF_IN_MULTI_CORE

 	voice_buffer_read(s_speechState.pVpTempTxInBuffer,  s_speechState.totalFrameBufSize);

 

-#else

+	#else

 	voicebuffer_ulqueue_read(s_speechState.pVpTempTxInBuffer,  s_speechState.totalFrameBufSize);

-#endif

+	#endif

 	if (g_voiceVar.vProcIsNormal == TRUE)

 	{

 		VoiceProc_TxProcess(&s_speechState.pVpTempTxInBuffer, NULL, &s_speechState.pVpTempTxOutPutBuffer, s_speechState.frameCount);	

@@ -3246,12 +3327,10 @@
 		s_speechState.pVpTempTxOutPutBuffer = s_vpState.pVpTxOutPutBuffer + s_speechState.txSaveLen;

 	}

 	

-#else 

-#ifdef ECALL_SUPPORT

+#else //not define CONFIG_VOICE_BUFFER_DRV  

+	#ifdef ECALL_SUPPORT

 	if ((e_reg_flag == 1)&&(g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_INUSE))		

 	{	

-

-

 		ret = ecall_GetTxBuf(&read_buf,&read_len);

 		if(ret != DRV_SUCCESS)

 		{

@@ -3260,15 +3339,19 @@
 		}

 		

 		ret = ecall_Read(&read_buf, &read_len);

+		//ret = zDrvExtAudio_Read(&read_buf, &read_len);

 

 	}

 	else

 	{

 		ret = zDrvExtAudio_Read(&read_buf, &read_len);

+		ext_aRdCount ++;

+	

 	}	

-#else

+	#else//no ECALL_SUPPORT

     ret = zDrvExtAudio_Read(&read_buf, &read_len);

-#endif	

+	ext_aRdCount ++;	

+	#endif	

 	if ((ret == DRV_SUCCESS) && (read_buf != NULL) && (read_len == s_speechState.i2sReadParam.buffersize))

 	{

 		if ((s_speechState.pVpI2sCfg->tClkMode == PCM_TIME_MODE) && (s_speechState.pVpI2sCfg->tPcmSlotNum != PCM_1TIME_SLOT))

@@ -3322,7 +3405,9 @@
 		        pVpTxInAllDataBuffer=(UINT8 *)0x25500000+s_TxAllDataSaveLen;

 		#endif

 		*/

-		if (e_reg_flag != 1)

+		#ifdef ECALL_SUPPORT

+

+		if ((e_reg_flag != 1)||((e_reg_flag == 1)&&(g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_IDLE)))

 		{

 			ret = zDrvExtAudio_FreeBuf(read_buf);

 			if (ret  != DRV_SUCCESS)

@@ -3330,8 +3415,20 @@
 				zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp vp_ReadDataFromCodec err ret=%d\n", ret);

 				return DRV_ERROR;

 			}

+			ext_aRdFBufCount ++;				

+		}		

+      

+		#else //not ECALL_SUPPORT

+		ret = zDrvExtAudio_FreeBuf(read_buf);

+		if (ret  != DRV_SUCCESS)

+		{

+			zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp vp_ReadDataFromCodec err ret=%d\n", ret);

+			return DRV_ERROR;

 		}

-	#ifdef CONFIG_CP_USE_SOFT_DTMF_DETECT

+		ext_aRdFBufCount ++;	

+		#endif

+		

+		#ifdef CONFIG_CP_USE_SOFT_DTMF_DETECT

 		for (i = 0; i < (s_speechState.vpCfgParam.samples_per_frame / 80); )

 		{

 			SINT32 dtmf_ret = DRV_SUCCESS;

@@ -3346,10 +3443,11 @@
 				//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp slic_tw_dtmf_detect 2  ret=%d\n", ret);

 			}

 		}

-#endif

-//le9643

-#if 0

-//#ifdef CONFIG_ARCH_ZX297520V3_CPE_SWITCH

+		#endif

+		

+		//le9643

+		#if 0

+		//#ifdef CONFIG_ARCH_ZX297520V3_CPE_SWITCH

 

 

 		if (g_voiceVar.audio_ctrlFlag.isUseTdm == 1)

@@ -3363,7 +3461,7 @@
 				i += 2;

 			}

 		}

-#endif

+		#endif

         

         //dtmf检测上行写入

         if((g_voiceVar.dtmfDirSel == DTMF_TX) || (g_voiceVar.dtmfDirSel == DTMF_TXRX))

@@ -3383,11 +3481,11 @@
     			voice_MixerDataTx(s_speechState.pVpTempTxInBuffer, 320,  s_speechState.pVpTempTxInBuffer);

     		}

         }

-#ifdef ECALL_SUPPORT

-        if ((g_voiceVar.vProcIsNormal == TRUE)&&(g_voiceVar.ecallData.ecallTxSta != ECALL_ST_TX_INUSE))

-#else    

+		#ifdef ECALL_SUPPORT

+        if ((g_voiceVar.vProcIsNormal == TRUE)&&((e_reg_flag != 1)||((e_reg_flag == 1)&&(g_voiceVar.ecallData.ecallTxSta == ECALL_ST_TX_IDLE))))

+		#else    

 		if (g_voiceVar.vProcIsNormal == TRUE)

-#endif		

+		#endif		

 		{

 			ret = VoiceProc_TxProcess(&s_speechState.pVpTempTxInBuffer, NULL, &s_speechState.pVpTempTxOutPutBuffer, s_speechState.frameCount);

 			if (ret != DRV_SUCCESS)

@@ -5602,7 +5700,7 @@
 	zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, " zDrvVp_GetVoiceState pVoiceState=%p.\n", *pVoiceState);

 	return DRV_SUCCESS;

 }

-#ifdef ECALL_SUPPORT

+

 /*******************************************************************************

 * Function: zDrvEcall_SetOperations

 * Description: This function is used to set the ecall callback function.

@@ -5641,4 +5739,4 @@
 	//zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "drv_Ecall_Write\n");

 	return DRV_SUCCESS;

 }

-#endif

+

diff --git a/cp/ps/modem/com/src/appstart/inc/version_number.h b/cp/ps/modem/com/src/appstart/inc/version_number.h
index a100b7f..1f5d7cb 100755
--- a/cp/ps/modem/com/src/appstart/inc/version_number.h
+++ b/cp/ps/modem/com/src/appstart/inc/version_number.h
@@ -1,9 +1,9 @@
 #if defined _CHIP_ZX297520
-#define VERSION_NUMBER "7520SCV2.01.01.02P54U02"
+#define VERSION_NUMBER "7520SCV2.01.01.02P54U03"
 #endif
 #if defined _CHIP_ZX297520V2
-#define VERSION_NUMBER "7520V2SCV2.01.01.02P54U02"
+#define VERSION_NUMBER "7520V2SCV2.01.01.02P54U03"
 #endif
 #if defined _CHIP_ZX297520V3
-#define VERSION_NUMBER "7520V3SCV2.01.01.02P54U02"
+#define VERSION_NUMBER "7520V3SCV2.01.01.02P54U03"
 #endif
diff --git a/cp/ps/modem/ps/inc/atipscom.h b/cp/ps/modem/ps/inc/atipscom.h
index a1a8d07..d4a85f3 100755
--- a/cp/ps/modem/ps/inc/atipscom.h
+++ b/cp/ps/modem/ps/inc/atipscom.h
@@ -230,9 +230,10 @@
 #define Z_ATI_NV_Msisdn1                                   (BYTE)(Z_ATI_NV_BeepCall + 1)

 #define Z_ATI_NV_Msisdn2                                   (BYTE)(Z_ATI_NV_Msisdn1 + 1)

 #define Z_ATI_NV_EcallCapa                                 (BYTE)(Z_ATI_NV_Msisdn2 + 1)

-#define Z_ATI_NV_EcallNum                                 (BYTE)(Z_ATI_NV_EcallCapa + 1)

+#define Z_ATI_NV_EcallNum                                  (BYTE)(Z_ATI_NV_EcallCapa + 1)

+#define Z_ATI_NV_EcallTime                                 (BYTE)(Z_ATI_NV_EcallNum + 1)

 #ifdef BTRUNK_SUPPORT

-#define Z_ATI_NV_PttTruncUser                              (BYTE)(Z_ATI_NV_EcallNum + 1)

+#define Z_ATI_NV_PttTruncUser                              (BYTE)(Z_ATI_NV_EcallTime + 1)

 #define Z_ATI_NV_PttIOTFlag                                (BYTE)(Z_ATI_NV_PttTruncUser + 1)

 #define Z_ATI_NV_PttSubWayFlag                             (BYTE)(Z_ATI_NV_PttIOTFlag + 1)

 #define Z_ATI_NV_PrvEnd                                    (BYTE)(Z_ATI_NV_PttSubWayFlag + 0)

@@ -1310,6 +1311,13 @@
     BYTE                            abReCfgNum[Z_DEV_MAX_ECALL_NUM];

 }T_zAti_NV_EcallNum;

 

+typedef struct {

+    WORD                          wT2Time;/*T2¶¨Ê±Æ÷ʱ³¤,µ¥Î»s,³ö³§Öµ3600*/

+    WORD                          wT7Time;/*T7¶¨Ê±Æ÷ʱ³¤,µ¥Î»s£¬³ö³§Öµ20*/

+    WORD                          wT9Time;/*T9¶¨Ê±Æ÷ʱ³¤,µ¥Î»s,³ö³§Öµ3600*/

+    BYTE                          abPadding[2];

+}T_zAti_NV_EcallTime;

+

 #ifdef BTRUNK_SUPPORT

 typedef struct  

 {

diff --git a/cp/ps/modem/ps/src/nas/ati/inc/zat_api.h b/cp/ps/modem/ps/src/nas/ati/inc/zat_api.h
index 3e906c4..238bae2 100755
--- a/cp/ps/modem/ps/src/nas/ati/inc/zat_api.h
+++ b/cp/ps/modem/ps/src/nas/ati/inc/zat_api.h
@@ -222,6 +222,7 @@
     ZAT2_CC_ZECALL,

     ZAT2_CC_ZECALLCAPA,

     ZAT2_CC_ZECALLNUM,

+    ZAT2_CC_ZECALLTIMER,

     ZAT2_CC_END,       

 

     /*-----------SMSÄ£¿é-------------*/

diff --git a/cp/ps/modem/ps/src/nas/ati/inc/zat_fnc.h b/cp/ps/modem/ps/src/nas/ati/inc/zat_fnc.h
index 92c3829..9aaea8e 100755
--- a/cp/ps/modem/ps/src/nas/ati/inc/zat_fnc.h
+++ b/cp/ps/modem/ps/src/nas/ati/inc/zat_fnc.h
@@ -406,6 +406,8 @@
 T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallCapaQryReq(T_ZAt_DecCmdInfo * pDecCmdInfo);

 T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallNumSetReq(T_ZAt_DecCmdInfo * pDecCmdInfo);

 T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallNumQryReq(T_ZAt_DecCmdInfo * pDecCmdInfo);

+T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallTimerSetReq(T_ZAt_DecCmdInfo * pDecCmdInfo);

+T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallTimerQryReq(T_ZAt_DecCmdInfo * pDecCmdInfo);

 #endif

 T_ZAt_ParseCmd2MsgRslt zAt_PsDecCcCrReq( T_ZAt_DecCmdInfo * pDecCmdInfo );

 T_ZAt_ParseCmd2MsgRslt zAt_PsDecCcCrcReq( T_ZAt_DecCmdInfo * pDecCmdInfo );

diff --git a/cp/ps/modem/ps/src/nas/ati/inc/zati_com.h b/cp/ps/modem/ps/src/nas/ati/inc/zati_com.h
index 29f118d..e622d5e 100755
--- a/cp/ps/modem/ps/src/nas/ati/inc/zati_com.h
+++ b/cp/ps/modem/ps/src/nas/ati/inc/zati_com.h
@@ -560,6 +560,10 @@
 #define Z_ATI_TEST_NUM      (BYTE)0/*test num*/

 #define Z_ATI_RECFG_NUM      (BYTE)1/*reconfiguration number num*/

 

+/********************ECALL TIME************************/

+#define Z_ATI_ECALL_MAXT2_TIME        (WORD)36000

+#define Z_ATI_ECALL_MAXT7_TIME        (BYTE)200

+#define Z_ATI_ECALL_MAXT9_TIME        (WORD)36000

 

 #ifdef DSDS_VSIM

 /**********************´ý»ú²à״̬***************************/

diff --git a/cp/ps/modem/ps/src/nas/ati/src/zat_fnc.c b/cp/ps/modem/ps/src/nas/ati/src/zat_fnc.c
index 09035a2..0e6b24f 100755
--- a/cp/ps/modem/ps/src/nas/ati/src/zat_fnc.c
+++ b/cp/ps/modem/ps/src/nas/ati/src/zat_fnc.c
@@ -4231,6 +4231,84 @@
 

     return zAt_GetParseRslt(ZAT2_CMD_REPLY_DIRECT);

 }

+

+T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallTimerSetReq(T_ZAt_DecCmdInfo * pDecCmdInfo)

+{

+    CHAR* pDecCmdStr = pDecCmdInfo->strParam;   /* ¼Ç¼²ÎÊý×ֶεÄÓÎ×ßÖ¸Õë */

+    CHAR strSubBuf[ZAT2_SUB_PARAM_MAX_LEN] = {0};    /* ´æ·Å½ØÈ¡µÄ²ÎÊý×Ö·û´® */

+    T_ZAt_ParseCmd2MsgRslt   prsCmd2Msg = {0};

+    T_zAti_NV_EcallTime tEcallTime = {0};

+    T_zAti_NV_EcallTime tTmpEcallTime = {0};

+    WORD wT2Time = 0;

+    WORD wT9Time = 0;

+    BYTE  bT7Time = 0;

+    BYTE  bT2TimeFg = 0;

+    BYTE  bT7TimeFg = 0;

+    BYTE  bT9TimeFg = 0;

+

+    /*+ZECALLTIMER=[<t2>[,<t7>[,<t9>]]]*/

+    if(!zAt_PsDecNextParamDecimalNumWord(&prsCmd2Msg, strSubBuf, &pDecCmdStr, &wT2Time, &bT2TimeFg)

+      || (bT2TimeFg == Z_VALID && wT2Time > Z_ATI_ECALL_MAXT2_TIME))

+    {

+        return zAt_GetParseRslt2(&prsCmd2Msg,ZAT2_CMD_PARAM_ERR);

+    }

+

+    if(!zAt_PsDecNextParamDecimalNumByte(&prsCmd2Msg, strSubBuf, &pDecCmdStr, &bT7Time, &bT7TimeFg)

+      || (bT7TimeFg == Z_VALID && bT7Time > Z_ATI_ECALL_MAXT7_TIME))

+    {

+        return zAt_GetParseRslt2(&prsCmd2Msg,ZAT2_CMD_PARAM_ERR);

+    }

+

+    if(!zAt_PsDecNextParamDecimalNumWord(&prsCmd2Msg, strSubBuf, &pDecCmdStr, &wT9Time, &bT9TimeFg)

+      || (bT9TimeFg == Z_VALID && wT9Time > Z_ATI_ECALL_MAXT9_TIME))

+    {

+        return zAt_GetParseRslt2(&prsCmd2Msg,ZAT2_CMD_PARAM_ERR);

+    }

+

+    if(strlen((const char *)pDecCmdStr) != 0)

+    {

+        return zAt_GetParseRslt2(&prsCmd2Msg,ZAT2_CMD_PARAM_ERR);

+    }

+

+    zDev_NV_AtiReadItem(Z_ATI_NV_EcallTime, (PBYTE)&tEcallTime);

+    zOss_Memcpy(&tTmpEcallTime, &tEcallTime, sizeof(T_zAti_NV_EcallTime));

+

+    if(bT2TimeFg == Z_VALID)

+    {

+        tEcallTime.wT2Time = wT2Time;

+    }

+

+    if(bT7TimeFg == Z_VALID)

+    {

+        tEcallTime.wT7Time = bT7Time;

+    }

+

+    if(bT9TimeFg == Z_VALID)

+    {

+        tEcallTime.wT9Time = wT9Time;

+    }

+

+    if(0 != memcmp(&tTmpEcallTime, &tEcallTime, sizeof(T_zAti_NV_EcallTime)))

+    {

+        zDev_NV_AtiWriteItem(Z_ATI_NV_EcallTime, (BYTE*)&tEcallTime);

+    }

+

+    zOss_Memcpy(g_zAt_EncBuf, g_zAt_OK, strlen((const char *)g_zAt_OK));

+    return zAt_GetParseRslt(ZAT2_CMD_REPLY_DIRECT);

+}

+

+T_ZAt_ParseCmd2MsgRslt zAt_PsDecEcallTimerQryReq(T_ZAt_DecCmdInfo * pDecCmdInfo)

+{

+    CHAR * pStrWalk = g_zAt_EncBuf;

+    T_zAti_NV_EcallTime tEcallTime = {0};

+

+    zDev_NV_AtiReadItem(Z_ATI_NV_EcallTime, (PBYTE)&tEcallTime);

+

+    sprintf((char *)pStrWalk, "%s+ZECALLTIMER: %d,%d,%d%s%s", g_zAt_CRLF, tEcallTime.wT2Time, 

+        tEcallTime.wT7Time, tEcallTime.wT9Time, g_zAt_CRLF, g_zAt_OK);

+

+    return zAt_GetParseRslt(ZAT2_CMD_REPLY_DIRECT);

+}

 #endif

 /*+Cr */

 T_ZAt_ParseCmd2MsgRslt zAt_PsDecCcCrReq(T_ZAt_DecCmdInfo * pDecCmdInfo)

diff --git a/cp/ps/modem/ps/src/nas/ati/src/zat_var.c b/cp/ps/modem/ps/src/nas/ati/src/zat_var.c
index e52bc2a..65050cd 100755
--- a/cp/ps/modem/ps/src/nas/ati/src/zat_var.c
+++ b/cp/ps/modem/ps/src/nas/ati/src/zat_var.c
@@ -185,6 +185,7 @@
     {   "+ZNECALLNUM",    ZAT2_CC_ZNECALLNUM,        ""          },

     {   "+ZECALLCAPA",    ZAT2_CC_ZECALLCAPA,      "+ZECALLCAPA: (0-2)"        },

     {   "+ZECALLNUM",    ZAT2_CC_ZECALLNUM,      ""      },

+    {   "+ZECALLTIMER",    ZAT2_CC_ZECALLTIMER,     "+ZECALLTIMER: (0-36000),(0-200),(0-36000)"     },

 #endif

     /********************************* SMSÄ£¿é ***********************************/

     {   "+CGSMS",      ZAT2_SMS_CGSMS,        "+CGSMS: (0-3)"                     },

@@ -915,6 +916,10 @@
     /*********************************+ZECALLNUM*****************************/

     { ZAT2_CC_ZECALLNUM,   ZAT2_CO_SET_REQ,    0,    zAt_PsDecEcallNumSetReq    },

     { ZAT2_CC_ZECALLNUM,   ZAT2_CO_QUERY_REQ,    0,    zAt_PsDecEcallNumQryReq    },

+

+    /*********************************+ZECALLTIME*****************************/

+    { ZAT2_CC_ZECALLTIMER,   ZAT2_CO_SET_REQ,    0,        zAt_PsDecEcallTimerSetReq    },

+    { ZAT2_CC_ZECALLTIMER,   ZAT2_CO_QUERY_REQ,    0,        zAt_PsDecEcallTimerQryReq    },

 #endif

     /******************************************* +CEER *********************************************/

     { ZAT2_CC_CEER,    ZAT2_CO_SET_REQ,                          0,                                 zAt_PsDecCeerSetReq      },