[Feature][ZXW-65]merged P49 base code

Change-Id: I3e09c0c3d47483bc645f02310380ecb7fc6f4041
diff --git a/ap/lib/libvoice/voice_api.c b/ap/lib/libvoice/voice_api.c
index ba07e83..3494e74 100755
--- a/ap/lib/libvoice/voice_api.c
+++ b/ap/lib/libvoice/voice_api.c
@@ -42,6 +42,9 @@
 extern int mix_set_vp_path(struct mixer *mixer, char path);

 extern int mix_get_vp_path(struct mixer *mixer, int *path);

 extern int mix_get_voice_path(struct mixer *mixer, int *path);

+extern int mix_set_vploop(struct mixer *mixer, int path);

+extern int mix_get_vploop(struct mixer *mixer, int *state);

+

 

 

 	

@@ -422,3 +425,112 @@
     return 0;

 }

 

+int ap_audio_set_loopback_enable(int dev_mode,int enable)

+{

+

+	struct mixer *voice_mixer = NULL;

+    int ret = 0;

+    struct pcm_config config_voice = {0};

+

+	

+	printf("%s: start dev_mode=%d,enable=%d!\n",__func__, dev_mode,enable);

+

+	if ((dev_mode < T_OUTPUT_HANDSET ) ||(dev_mode >= T_OUTPUT_MAX)){

+		printf("%s: dev_mode not support, dev_mode=%d!\n",__func__, dev_mode);

+		return -1;

+	}

+	if ((enable != 0 )&&(enable != 1)){

+		printf("%s: enable val not support, enable=%d!\n",__func__, enable);

+		return -1;

+	}

+	if(enable == 1){

+

+		//open mixer dev for  control

+		voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);

+		if (!voice_mixer) {

+			printf("voice_mixer open failed!\n");

+			return -1;

+		}

+

+		//config mixer dev

+		ret = mix_set_voice_path(voice_mixer, dev_mode);

+		printf("mix_set_voice_path ret=%d!\n",ret);

+		

+		ret = mix_set_vploop(voice_mixer, dev_mode);

+		printf("mix_set_vploop ret=%d!\n",ret);

+

+		//close mixer

+		mixer_close(voice_mixer);

+		voice_mixer = NULL;

+

+		

+

+

+

+		

+	}

+	else{

+

+		//open mixer dev for  control

+		voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);

+		if (!voice_mixer) {

+			printf("voice_mixer open failed!\n");

+			return -1;

+		}

+

+

+	    ret = mix_set_vploop(voice_mixer, VP_PATH_OFF);

+		//close mixer

+		mixer_close(voice_mixer);

+		voice_mixer = NULL;

+

+		

+		printf("mix_set_vploop off end ret=%d!\n",ret);

+		

+		

+	

+

+

+	}

+ 

+	//return 0;

+

+	printf("%s: end enable=%d!\n",__func__, enable);

+

+	return ret;

+	

+	

+}

+

+

+

+int ap_audio_get_loopback_enable(int *p_enable)

+{

+	struct mixer *voice_mixer = NULL;

+	int ret = 0;

+	printf("%s: start!\n",__func__);

+

+	//open mixer dev for  control

+	voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);

+	if (!voice_mixer) {

+		printf("voice_mixer open failed!\n");

+		return -1;

+	}

+

+	//config mixer dev

+	ret = mix_get_vploop(voice_mixer, p_enable);

+	if((*p_enable != 0 ) &&(*p_enable != 1)){

+		printf("%s: p_enable not support, *p_enable=%d!\n",__func__, *p_enable);

+		ret = -1;

+	}

+	printf("%s: end *p_enable=%d!\n",__func__, *p_enable);

+

+	//close mixer

+	mixer_close(voice_mixer);

+	voice_mixer = NULL;

+

+	return ret;

+	

+}

+

+

diff --git a/ap/lib/libvoice/voiceipc.c b/ap/lib/libvoice/voiceipc.c
index 998d7a5..de88327 100755
--- a/ap/lib/libvoice/voiceipc.c
+++ b/ap/lib/libvoice/voiceipc.c
@@ -22,8 +22,10 @@
 extern int sc_audio_get_tx_voice_mute_state(int *p_mute);

 extern int sc_audio_set_rx_voice_mute_state(int mute);

 extern int sc_audio_get_rx_voice_mute_state(int *p_mute);

-extern int sc_audio_set_loopback_enable_state(int enable);

-extern int sc_audio_get_loopback_enable_state(int *p_enable);

+//extern int sc_audio_set_loopback_enable_state(int enable);

+//extern int sc_audio_get_loopback_enable_state(int *p_enable);

+int ap_audio_set_loopback_enable(int dev_mode,int enable);

+int ap_audio_get_loopback_enable(int *p_enable);

 

 static int voice_ipc_fd = -1;

 static voice_ipc_control_msg voice_ctrl_recvmsg[IPC_VOICE_FUNC_MAX] = {0};

@@ -400,11 +402,15 @@
 {

     int ret = VOICEIPC_OK;

     int msg_len = 0;

-    int enable = 0;

+	int dev_mode = 0,enable = 0;

 

     //memcpy(&dev_mode, msg.param, msg.param_len);

-    enable = *((int *)msg.param);

-    ret = sc_audio_set_loopback_enable_state(enable);

+    //enable = *((int *)msg.param);

+	memcpy(&dev_mode, msg.param, sizeof(int));

+	memcpy(&enable, msg.param+sizeof(int), sizeof(int));

+	

+    //ret = sc_audio_set_loopback_enable_state(enable);

+	ret = ap_audio_set_loopback_enable(dev_mode,enable);

 

     //msg.func_id不变

     msg.param_len = sizeof(int);

@@ -425,8 +431,8 @@
     int *p_enable = NULL;

 

     p_enable = (int *)msg.param;

-    ret = sc_audio_get_loopback_enable_state(p_enable);

-	

+    //ret = sc_audio_get_loopback_enable_state(p_enable);

+    ret = ap_audio_get_loopback_enable(p_enable);	

     //msg.func_id不变

     msg.param_len = sizeof(int);

     if(0 == ret)