[Feature][ZXW-33]merge ZXW 0428 version

Change-Id: I11f167edfea428d9fab198ff00ff1364932d1b0b
diff --git a/ap/lib/libatext/Makefile b/ap/lib/libatext/Makefile
index 0e39b78..4abe2ee 100644
--- a/ap/lib/libatext/Makefile
+++ b/ap/lib/libatext/Makefile
@@ -33,6 +33,15 @@
 LDFLAGS += -shared
 
 
+ifeq ($(USE_VOICE_AT),yes)
+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include
+CFLAGS += -I$(zte_lib_path)/libvoice/include
+LDLIBS += -L$(zte_lib_path)/libvoice
+LDLIBS += -lvoice
+LDLIBS += -L$(zte_lib_path)/libtinyalsa
+LDLIBS += -ltinyalsa
+endif
+
 all: $(LIB_STATIC) $(LIB_SHARED)
 
 $(LIB_STATIC) : $(OBJS)
diff --git a/ap/lib/libatext/ext_audio_func.c b/ap/lib/libatext/ext_audio_func.c
new file mode 100755
index 0000000..f1b45a7
--- /dev/null
+++ b/ap/lib/libatext/ext_audio_func.c
@@ -0,0 +1,508 @@
+/************************************************************************

+*¹¦ÄܽéÉÜ£ºÆ½Ì¨ÄÚ²¿À©Õ¹at¿Í»§¶ËºÍ·þÎñ¶Ë×¢²á£¬ËùÓÐ×¢²á¾ùÔÚext_regist_init½Ó¿ÚÖÐÍê³É£¬ÓÉat_ctlÔÚÆô¶¯Ê±µ÷ÓÃ

+*¸ºÔðÈË£º

+*±¸·ÝÈË£º

+*ÐÞ¸ÄÈÕ£º

+*ÐÞ¸ÄÄÚÈÝ£º

+*°æ±¾ºÅ£º

+************************************************************************/

+#if (APP_OS_TYPE == APP_OS_LINUX)

+#include "at_msg.h"

+#include "at_com.h"

+#include "at_context.h"

+#include "ext_dev_func.h"

+#include "ext_cmux_func.h"

+#ifdef _USE_VOICE_ALSA

+#include "tinyalsa/audio_mixer_ctrl.h"

+#include "voice_lib.h"

+#endif

+//#include "ext_regist.h"

+//#include "softap_api.h"

+//#include "at_utils.h"

+//#include "pub/drvs_ret.h"

+//#include "earpiece_api.h"

+#define DRV_SUCCESS 0

+

+/*

+typedef enum

+{

+    VP_PATH_HANDSET    =0,     

+    VP_PATH_SPEAKER,  		

+    VP_PATH_HEADSET,                     

+    VP_PATH_BLUETOOTH,                    

+    VP_PATH_BLUETOOTH_NO_NR,                    

+    VP_PATH_HSANDSPK,

+    

+    VP_PATH_OFF = 255,					

+    

+    MAX_VP_PATH = VP_PATH_OFF               

+}T_ZDrv_VpPath;

+*/

+/*	Voice input channel selection. */

+typedef enum

+{

+	CODEC_INPUT_MICPHONE	=0, 					/*input path in earphone mic*/

+	CODEC_INPUT_HEADSET,							   /*input path in headset*/

+	CODEC_INPUT_BLUETOOTH,							 /*input path in bluetooth*/

+	CODEC_INPUT_HANDSFREE,							 /*input path in mic(handsfree)*/

+	

+	MAX_CODEC_INPUT_PATH			   

+} T_ZDrv_CodecInputPath;

+

+/*	Voice output channel selection. */

+typedef enum

+{

+	CODEC_OUTPUT_RECEIVER	 =0,				/*output path in receiver*/

+	CODEC_OUTPUT_SPEAKER,						  /*output path in speaker*/

+	CODEC_OUTPUT_HEADSET,						  /*output path in headset*/

+	CODEC_OUTPUT_BLUETOOTH, 					/*output path in bluetooth*/

+	CODEC_OUTPUT_HSANDSPK,					   /*output path in both headset and speaker*/

+	

+	

+	MAX_CODEC_OUTPUT_PATH			   

+}T_ZDrv_CodecOutputPath;

+#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT

+extern SINT32 halEarp_Open(VOID);

+extern SINT32 halEarp_Close(VOID);

+extern SINT32 halEarp_GetPlugStatus(T_ZDrvEarp_State* plug_status);

+#endif

+

+#ifdef _CONFIG_USE_CODEC

+extern SINT32 halAudioConfig_ReadReg (UINT16 regPage, UINT16 regAddress, UINT16 *regValue);

+extern SINT32 halAudioConfig_WriteReg (UINT16 regPage, UINT16 regAddress, UINT16 regValue, UINT16 regMask);

+extern SINT32 halAudioConfig_DumpReg (VOID);

+

+

+int codecWrite_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	UINT8 pPtr[40] = {0};

+	int a[4] = {0};

+	//CHAR b[6] = {0};

+	//CHAR c[6] = {0};

+	//CHAR d[6] = {0};

+	UINT16 reg_page = 0;

+	UINT16 reg_index = 0;

+	UINT16 write_value = 0;

+	UINT16 write_mask = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"codecWrite_act_func, at_paras:%s \n", at_paras);

+

+	//ret = sscanf (at_str, "%[0-9],%[0-9],%[0-9],%[0-9]", a, b, c, d);

+	ret = sscanf (at_str, "%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3]);

+	reg_page = a[0];

+	reg_index = a[1];

+	write_value = a[2];

+	write_mask = a[3];

+	at_print(AT_DEBUG,"zCtrm_ExtAT_WRCODEC reg_page=0x%x, reg_index=0x%x, write_value=0x%x, write_mask=0x%x\n", reg_page, reg_index, write_value, write_mask);

+

+	if (ret == 4) {

+		ret = halAudioConfig_WriteReg (reg_page, reg_index, write_value, write_mask);

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	return AT_END;

+}

+

+int codecRead_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	at_str = at_paras;

+	UINT32 ret = DRV_SUCCESS;

+	int a[2] = {0};

+	//CHAR b[6] = {0};

+	CHAR re_str[30] = {'\0'};

+

+	UINT16 reg_page = 0;

+	UINT16 reg_index = 0;

+	UINT16 read_value = 0;

+	at_print(AT_DEBUG,"codecRead_act_func, at_paras:%s \n", at_paras);

+

+	//ret = sscanf (at_str, "%[0-9],%[0-9]", a, b);

+	ret = sscanf (at_str, "%d,%d", &a[0], &a[1]);

+	reg_page = a[0];

+	reg_index = a[1];

+	at_print(AT_DEBUG,"codecRead_act_func reg_page=0x%x, reg_index=0x%x \n", reg_page, reg_index);

+

+	if (ret == 2) {

+		ret = halAudioConfig_ReadReg (reg_page, reg_index, &read_value);

+		if (ret == DRV_SUCCESS) {

+

+			sprintf(re_str, "0x%x=0x%x\r\n" , reg_index,read_value);

+			

+			*res_msg = at_query_result_build("reg",re_str);

+

+			//*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	return AT_END;

+}

+

+int codecDump_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	at_str = at_paras;

+	UINT32 ret = DRV_SUCCESS;

+	at_print(AT_DEBUG,"codecDump_act_func, at_paras:%s \n", at_paras);

+

+	if (*at_str == '1') {

+		at_print(AT_DEBUG,"codecDump_act_func is ok. \n");

+		ret = halAudioConfig_DumpReg();

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	return AT_END;

+

+

+}

+//ƽ̨ÄÚ²¿À©Õ¹atÃüÁ·¢£¬ËùÓÐÀ©Õ¹µÄ¿Í»§¶ËºÍ·þÎñ¶ËatÃüÁ¾ùÐèÒªÔڸú¯ÊýÖУ¬¸Ãº¯Êý»áÔÚat_ctlÓ¦Óóõʼ»¯Ê±£¬Íê³ÉÉÏÊöatÃüÁîµÄ×¢²á

+

+

+int extAtSdev_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	T_ZDrv_VpPath path;

+	

+	UINT8 pPtr[40] = {0};

+	int a = 0;

+	//CHAR b[6] = {0};

+	UINT16 dev_num = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d", &a);

+	dev_num = a;

+	at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);

+

+	if (ret == 1) {

+

+		if(dev_num == 0)

+		{

+		    path = VP_PATH_HANDSET;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 1)

+		{

+		    path = VP_PATH_SPEAKER;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 2)

+		{

+		    path = VP_PATH_HEADSET;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+        else 

+        {

+			sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004");		

+		    path = VP_PATH_HANDSET;

+			*res_msg = at_err_build ("pPtr");

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+        }

+

+		ret = zDrvVp_SetPath(path);

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+		*res_msglen = strlen (*res_msg);

+		

+		return AT_END;

+	}

+	return AT_END;

+}

+int extAtRxPath_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	T_ZDrv_CodecOutputPath path;

+	

+	UINT8 pPtr[40] = {0};

+	int a[2] = {0};

+	//CHAR b[6] = {0};

+	UINT16 dev_num = 0;

+	UINT16 isenable = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d %d", &a[0], &a[1]);

+	dev_num = a[0];

+	isenable = a[1];

+	at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);

+

+	if (ret == 2) {

+

+		if(dev_num == 0)

+		{

+		    path = CODEC_OUTPUT_RECEIVER;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 1)

+		{

+		    path = CODEC_OUTPUT_SPEAKER;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 2)

+		{

+		    path = CODEC_OUTPUT_HEADSET;

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+        else 

+        {

+			sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004");		

+		    path = CODEC_OUTPUT_RECEIVER;

+			*res_msg = at_err_build ("pPtr");

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+        }

+		

+		//ret = zDrvVp_SetTxPath(CODEC_INPUT_MICPHONE, TRUE);

+		ret = zDrvVp_SetRxPath(path, isenable);

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+		*res_msglen = strlen (*res_msg);

+		

+		return AT_END;

+	}

+	return AT_END;

+}

+int extAtTxPath_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	T_ZDrv_VpPath path;

+	

+	UINT8 pPtr[40] = {0};

+	int a[2] = {0};

+	//CHAR b[6] = {0};

+	UINT16 dev_num = 0;

+	UINT16 isenable = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d %d", &a[0], &a[1]);

+	dev_num = a[0];

+	isenable = a[1];

+	at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);

+

+	if (ret == 2) {

+

+		if(dev_num == 0)

+		{

+			path = CODEC_INPUT_MICPHONE; //IN2P

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 1)

+		{

+			path = CODEC_INPUT_HANDSFREE; //CODEC_INPUT_HEADSET IN2P

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else if(dev_num == 2)

+		{

+			path = CODEC_INPUT_HEADSET; //CODEC_INPUT_HANDSFREE IN1P

+			at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);

+		}

+		else 

+		{

+			sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004"); 	

+			path = VP_PATH_HANDSET;

+			*res_msg = at_err_build ("pPtr");

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+		

+		ret = zDrvVp_SetTxPath(path, isenable);

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+		

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+		*res_msglen = strlen (*res_msg);

+		

+		return AT_END;

+	}

+	return AT_END;

+}

+#endif

+

+#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT

+int extAtEarp_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	T_ZDrv_VpPath path;

+	

+	UINT8 pPtr[40] = {0};

+	int a = 0;

+	//CHAR b[6] = {0};

+	UINT16 onOff = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d", &a);

+	onOff = a;

+	at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", onOff);

+

+	if (ret == 1) {

+		if(onOff == 1)

+		{

+			ret = halEarp_Open();

+		}

+		else

+		{

+			ret = halEarp_Close();

+		}

+		

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	

+	return AT_END;

+}

+#endif

+#ifdef _USE_VOICE_ALSA

+

+

+

+

+

+

+int extAt_VPATH_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+	int path;

+	int a = 0;

+	//CHAR b[6] = {0};

+	UINT16 onOff = 0;

+	at_str = at_paras;

+	at_print(AT_DEBUG,"extAt_VPATH_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d,%d",&path,&a);

+	onOff = a;

+	at_print(AT_DEBUG,"extAt_VPATH_act_func path =%d,onOff=0x%d\n",path, onOff);

+

+	if (ret == 2) {

+		if(onOff == 1)

+		{

+			ret = set_voice_device_mode(path);

+			printf("extAt_VPATH_act_func on vpath,ret=%d\n",ret);

+		}

+		else

+		{

+			//ret = set_voice_device_mode(path);

+			printf("extAt_VPATH_act_func off vpath not support\n");

+			

+		}		

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	

+	return AT_END;

+}

+

+int extAt_VALSA_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+

+	int mode = 0;

+    int enable = 0;

+	

+	UINT16 onOff = 0;

+	at_str = at_paras;

+	printf("extAt_VALSA_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d,%d", &mode,&enable);

+	onOff = enable;

+	printf("extAt_VALSA_act_func mode=%d,enable=%d,ret=%d\n",mode,enable,ret);

+

+	if (ret == 2) {

+		if(onOff == 1)

+		{

+			ret = alsa_voice_open(mode);

+			printf("extAt_voice_act_func alsa_voice_open,ret=%d\n",ret);

+		}

+		else

+		{

+			ret = alsa_voice_close(mode);

+			printf("extAt_voice_act_func alsa_voice_close,ret=%d\n",ret);

+			

+		}		

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	

+	return AT_END;

+}

+

+#endif

+

+void ext_audio_regist_init(void)

+{

+	printf("ext_audio_regist_init! \n");

+

+#ifdef _CONFIG_USE_CODEC

+	register_serv_func2("WRCODEC=", 0, 0, 0, codecWrite_act_func, NULL);

+	register_serv_func2("RDCODEC=", 0, 0, 0, codecRead_act_func, NULL);

+	register_serv_func2("DUMPCODECREG=", 0, 0, 0, codecDump_act_func, NULL);

+	register_serv_func2("ExtAT_SDEV=", 0, 0, 0, extAtSdev_act_func, NULL);	

+	register_serv_func2("ExtAT_RXPATH=", 0, 0, 0, extAtRxPath_act_func, NULL);	

+	register_serv_func2("ExtAT_TXPATH=", 0, 0, 0, extAtTxPath_act_func, NULL);	

+#endif

+#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT

+	register_serv_func2("ExtAT_EARP=", 0, 0, 0, extAtEarp_act_func, NULL);

+#endif

+

+#ifdef _USE_VOICE_ALSA

+

+	register_serv_func2("VALSA=", 0, 0, 0, extAt_VALSA_act_func, NULL);

+	register_serv_func2("VPATH=", 0, 0, 0, extAt_VPATH_act_func, NULL);

+	

+#endif

+}

+

+#endif

diff --git a/ap/lib/libatext/ext_ccapp_fnc.c b/ap/lib/libatext/ext_ccapp_fnc.c
index 6e351cf..f0a6b16 100755
--- a/ap/lib/libatext/ext_ccapp_fnc.c
+++ b/ap/lib/libatext/ext_ccapp_fnc.c
@@ -226,9 +226,31 @@
     sscanf(at_paras, "%u, %u", &imsplusInd->act, &imsplusInd->rate);  

     at_print(AT_DEBUG,"[CCAPP] imsplusInd->act= %d imsplusInd->rate= %d\n", imsplusInd->act, imsplusInd->rate);

 

+#ifdef USE_CAP_SUPPORT

+    if(imsplusInd->act == 0) {//ÒôƵÉ豸¹Ø±Õ

+    }

+    else if(imsplusInd->act == 1) {//ÒôƵÉ豸¿ªÆô

+    }

+    else if(imsplusInd->act == 2) {//֪ͨ¿ªÊ¼²¥·Å±¾µØÕñÁåÒô

+    }

+    else if(imsplusInd->act == 3) {//ֹ֪ͨͣ²¥·Å±¾µØÕñÁåÒô

+        T_zCcapp_ImsplusReq imsplusReq;

+

+        imsplusReq.setfg = 0;

+        imsplusReq.act = imsplusInd->rate;

+        ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_AT_CTL, MSG_CMD_ZIMSPLUS_REQ, sizeof(T_zCcapp_ImsplusReq), (unsigned char *)&imsplusReq,0);    

+    }

+

+    if(imsplusInd->rate == 8000) {

+    }

+    else if(imsplusInd->rate == 16000) {

+    }

+#else

     ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZIMSPLUS_IND, sizeof(T_zCcApp_ImsplusInd), (unsigned char *)imsplusInd,0);

     at_print(AT_DEBUG,"[CCAPP]send IMSPLUS %d\n ",MSG_CMD_ZIMSPLUS_IND );

     free(imsplusInd);

+#endif

+

     return AT_CONTINUE;

 }

 

diff --git a/ap/lib/libatext/ext_ftp_func.c b/ap/lib/libatext/ext_ftp_func.c
index 60425af..3f4742a 100755
--- a/ap/lib/libatext/ext_ftp_func.c
+++ b/ap/lib/libatext/ext_ftp_func.c
@@ -317,7 +317,7 @@
 	};
 	memset(reqmsg, 0x00, sizeof(struct zteftp_fota_reqmsg));
 	parse_param2("%d,%s,%s,%s,%s", at_paras, p);
-	at_print(AT_NORMAL, "zteftp_fota_reqmsg %d,%s,%s,%s,%s\n", reqmsg->channel,
+	at_print(AT_NORMAL, "ftp_fota_reqmsg %d,%s,%s,%s,%s\n", reqmsg->channel,
 	         reqmsg->destination,
 	         reqmsg->file_name,
 	         reqmsg->username,
diff --git a/ap/lib/libatext/ext_normal_func.c b/ap/lib/libatext/ext_normal_func.c
index b39c0b2..90116eb 100644
--- a/ap/lib/libatext/ext_normal_func.c
+++ b/ap/lib/libatext/ext_normal_func.c
@@ -602,7 +602,7 @@
 		*res_msg = at_query_result_build("ZTELNET","1");

 		break;

 	default:

-		at_print(AT_DEBUG,"ztelnetSet_rsp:: invaild user_cmd == %d\n", user_cmd);

+		at_print(AT_DEBUG,"lnetSet_rsp:: invaild user_cmd == %d\n", user_cmd);

 		*res_msg = at_err_build(ATERR_PARAM_INVALID);

 	}

 	

@@ -1365,12 +1365,20 @@
 	int32_t simCardFlag = 0;

 	unsigned long   retCode = CPNV_ERROR;

 	int32_t	SimInserted = 0;

+	int ret = 0;

 

 	char *p[] = {

 		&simCardFlag,

 		&cardSlotFlag,

 	};

-	parse_param("%d,%d", at_paras, p);

+	

+	ret = parse_param("%d,%d", at_paras, p);

+	if (ret != AT_PARSE_OK)  // cov M

+	{

+		*res_msg = at_err_build(ATERR_PARAM_INVALID);

+		*res_msglen = strlen(*res_msg);

+		return AT_END;

+	}

 

 	at_print(AT_DEBUG,"zCardSwitch_Set_Req:simCardFlag == %d\n", simCardFlag);

 	

diff --git a/ap/lib/libatext/ext_regist.c b/ap/lib/libatext/ext_regist.c
index 2a4e3f0..e125562 100755
--- a/ap/lib/libatext/ext_regist.c
+++ b/ap/lib/libatext/ext_regist.c
@@ -30,6 +30,9 @@
 	ext_zcat_regist();

 	ext_amt_regist();

 	ext_wdt_regist_init();

+#ifdef _USE_VOICE_ALSA

+	ext_audio_regist_init();

+#endif	

 }

 

 

diff --git a/ap/lib/libatext/ext_regist.h b/ap/lib/libatext/ext_regist.h
index 1cf2466..b648ded 100644
--- a/ap/lib/libatext/ext_regist.h
+++ b/ap/lib/libatext/ext_regist.h
@@ -26,4 +26,7 @@
 

 extern int ext_is_usermode(void);

 extern int ext_kwatchtest_regist(void);

+#ifdef _USE_VOICE_ALSA

+extern void ext_audio_regist_init(void);

+#endif	

 #endif

diff --git a/ap/lib/libatext/ext_socket_func.c b/ap/lib/libatext/ext_socket_func.c
index 1019216..fe4ac1f 100755
--- a/ap/lib/libatext/ext_socket_func.c
+++ b/ap/lib/libatext/ext_socket_func.c
@@ -1456,7 +1456,7 @@
     	*res_msglen = strlen(at_str);
     	return AT_END;
     }
-	//at_print(AT_NORMAL,"zteftp_socketled_reqmsg %d\n", reqmsg->iswitch);
+	//at_print(AT_NORMAL,"ftp_socketled_reqmsg %d\n", reqmsg->iswitch);
 	*res_msg = reqmsg;
 	*res_msglen = sizeof(struct zteftp_socketled_reqmsg);
 	return AT_CONTINUE;
diff --git a/ap/lib/libatext/ext_wdt_func.c b/ap/lib/libatext/ext_wdt_func.c
index e289b5f..db6806d 100644
--- a/ap/lib/libatext/ext_wdt_func.c
+++ b/ap/lib/libatext/ext_wdt_func.c
@@ -167,14 +167,145 @@
 	return AT_END;

 }

 

+

+/*****************

+*

+*

+*/

+

+#define RPMSG_IOC_MAGIC     'R'

+

+/*ioctl cmd usd by device*/

+#define RPMSG_CREATE_CHANNEL          _IOW(RPMSG_IOC_MAGIC, 1, char *)

+#define RPMSG_GET_DATASIZE       _IOWR(RPMSG_IOC_MAGIC, 2, char *)

+#define RPMSG_SET_INT            _IOW(RPMSG_IOC_MAGIC, 3, char *)

+#define RPMSG_SET_INT_FLAG        _IOW(RPMSG_IOC_MAGIC, 4, char *)

+#define RPMSG_CLEAR_INT_FLAG      _IOW(RPMSG_IOC_MAGIC, 5, char *)

+#define RPMSG_SET_POLL_FLAG       _IOW(RPMSG_IOC_MAGIC, 6, char *)

+#define RPMSG_CLEAR_POLL_FLAG     _IOW(RPMSG_IOC_MAGIC, 7, char *)

+#define AT_CAP_DEV    "/dev/rpmsg2"

+

+ static void write_lockfile(char *filepath, char *setbuf)

+ {	

+ 	int f, len = 0;	

+	f = open(filepath, O_RDWR);	

+	if (f == -1) {

+	 	at_print(AT_DEBUG,"write_lockfile OPEN FAIL\n");

+		return;	

+	}	

+	len = strlen(setbuf);	

+	if (write(f, setbuf, len) != len) 

+	{	} 

+	else 

+	{	}

+	

+	close(f);

+}

+

+static int pm_apadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	write_lockfile("/sys/power/wake_lock", "test_wakelock");

+

+	*res_msg = at_query_result_build("delete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);	

+	return AT_END;

+}

+

+static int pm_apdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	write_lockfile("/sys/power/wake_unlock", "test_wakelock");

+

+	*res_msg = at_query_result_build("delete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	return AT_END;

+}

+

+

+static int pm_capadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+	unsigned int ctx=0x5a5a;

+	int fd, ret;

+	

+	 at_print(AT_DEBUG,"pm_capadd_wakelock\n");

+

+

+	fd =open(AT_CAP_DEV, O_RDWR);

+	if(fd<0){

+	 	at_print(AT_DEBUG,"cap add  open FAIL\n");

+		return -1;	

+	}

+

+	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		return AT_END;	

+	}		

+	ret=write(fd, &ctx, 4);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		return AT_END;	

+	}

+	

+	*res_msg = at_query_result_build("capadd_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	close(fd);

+	

+	return AT_END;

+}

+

+static int pm_capdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	unsigned int ctx=0x5a5b;

+	int fd, ret;

+	

+	 at_print(AT_DEBUG,"pm_capdelete_wakelock\n");

+

+	fd =open(AT_CAP_DEV, O_RDWR);

+	if(fd<0){

+	 	at_print(AT_DEBUG,"cap add  open FAIL\n");

+		return -1;	

+	}

+

+	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		return AT_END;	

+	}		

+	ret=write(fd, &ctx, 4);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		return AT_END;	

+	}

+

+	close(fd);

+	

+	*res_msg = at_query_result_build("capdelete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	return AT_END;

+}

 void ext_wdt_regist_init(void)

 {

 	//wdt_fd = open(ZX_SOFT_WDT_DEV, O_RDWR);

 	//ioctl(wdt_fd, ZX_WDT_SET_CHECK, FALSE);

 

 	register_serv_func2("WDT=", 0, 0, 0, wdt_act_func, NULL);

-    register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);

+	register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);

 	register_serv_func2("WDTP=", 0, 0, 0, wdt_set_nv_priority, NULL);

-    register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);

+	register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);

+

+	register_serv_func2("apadd_lock", 0, 0, 0,pm_apadd_wakelock,NULL);

+	register_serv_func2("apdel_lock", 0, 0, 0,pm_apdelete_wakelock,NULL);

+	register_serv_func2("capadd_lock", 0, 0, 0,pm_capadd_wakelock,NULL);

+	register_serv_func2("capdel_lock", 0, 0, 0,pm_capdelete_wakelock,NULL);		

 }