[Feature][ZXW-285]merge P56U05 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: Ied657102425a179a89ef41847170152e8a5d437c
diff --git a/ap/lib/libvoice/include/voice_ipc.h b/ap/lib/libvoice/include/voice_ipc.h
index 0041d73..c8297a0 100755
--- a/ap/lib/libvoice/include/voice_ipc.h
+++ b/ap/lib/libvoice/include/voice_ipc.h
@@ -31,6 +31,10 @@
     IPC_CAP_ALSA_VOICE_OPEN = 14,

     IPC_CAP_ALSA_VOICE_CLOSE = 15,

     IPC_UPDATE_VOICE_NVRW = 16,

+    IPC_SET_RX_VOICE_VOL_GAIN = 17,

+    IPC_GET_RX_VOICE_VOL_GAIN = 18,

+    IPC_SET_TX_VOICE_VOL_GAIN = 19,

+    IPC_GET_TX_VOICE_VOL_GAIN = 20,

 

     IPC_VOICE_FUNC_MAX

 };

@@ -67,6 +71,10 @@
 void ipc_get_voice_device_mode_rcv(voice_ipc_control_msg msg);

 void ipc_set_rx_voice_vol_rcv(voice_ipc_control_msg msg);

 void ipc_get_rx_voice_vol_rcv(voice_ipc_control_msg msg);

+void ipc_set_rx_voice_vol_gain_rcv(voice_ipc_control_msg msg);

+void ipc_get_rx_voice_vol_gain_rcv(voice_ipc_control_msg msg);

+void ipc_set_tx_voice_vol_gain_rcv(voice_ipc_control_msg msg);

+void ipc_get_tx_voice_vol_gain_rcv(voice_ipc_control_msg msg);

 void ipc_set_tx_voice_vol_rcv(voice_ipc_control_msg msg);

 void ipc_get_tx_voice_vol_rcv(voice_ipc_control_msg msg);

 void ipc_set_tx_voice_mute_state_rcv(voice_ipc_control_msg msg);

diff --git a/ap/lib/libvoice/voice_api.c b/ap/lib/libvoice/voice_api.c
index 3494e74..e9f5145 100755
--- a/ap/lib/libvoice/voice_api.c
+++ b/ap/lib/libvoice/voice_api.c
@@ -44,8 +44,10 @@
 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);

-

-

+extern int mix_set_voice_vol_gain(struct mixer *mixer, int vol_gain);

+extern int mix_get_voice_vol_gain(struct mixer *mixer, int *vol_gain);

+extern int mix_set_tx_voice_vol_gain(struct mixer *mixer, int vol_gain);

+extern int mix_get_tx_voice_vol_gain(struct mixer *mixer, int *vol_gain);

 

 	

 #define VOCIE_SND_CARD_NUM 0

@@ -224,7 +226,139 @@
 	

 }

 

+int sc_audio_set_rx_voice_vol_gain(int gain)

+{

+	struct mixer *voice_mixer = NULL;

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

 

+	if ((gain < -15 ) ||(gain > 24)){

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

+		return -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

+	mix_set_voice_vol_gain(voice_mixer, gain);

+

+	//close mixer

+	mixer_close(voice_mixer);

+	voice_mixer = NULL;

+

+

+	return 0;

+

+

+	

+	

+}

+

+int sc_audio_get_rx_voice_vol_gain(int     * p_gain)

+{

+    int ret = 0;

+	struct mixer *voice_mixer = NULL;

+

+	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

+	mix_get_voice_vol_gain(voice_mixer, p_gain);

+	

+

+	if ((*p_gain < -15 ) ||(*p_gain > 24)){

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

+		ret = -1;

+	}

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

+

+	//close mixer

+	mixer_close(voice_mixer);

+	voice_mixer = NULL;

+

+

+	return ret;

+

+	

+	

+}

+

+int sc_audio_set_tx_voice_vol_gain(int gain)

+{

+	struct mixer *voice_mixer = NULL;

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

+

+	if ((gain < -15 ) ||(gain > 24)){

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

+		return -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

+	mix_set_tx_voice_vol_gain(voice_mixer, gain);

+

+	//close mixer

+	mixer_close(voice_mixer);

+	voice_mixer = NULL;

+

+

+	return 0;

+

+

+	

+	

+}

+

+int sc_audio_get_tx_voice_vol_gain(int     * p_gain)

+{

+    int ret = 0;

+	struct mixer *voice_mixer = NULL;

+

+	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

+	mix_get_tx_voice_vol_gain(voice_mixer, p_gain);

+	

+

+	if ((*p_gain < -15 ) ||(*p_gain > 24)){

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

+		ret = -1;

+	}

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

+

+	//close mixer

+	mixer_close(voice_mixer);

+	voice_mixer = NULL;

+

+

+	return ret;

+

+	

+	

+}

 

 int sc_audio_set_tx_voice_vol(int vol)

 {

diff --git a/ap/lib/libvoice/voiceipc.c b/ap/lib/libvoice/voiceipc.c
index a3f5569..33561f0 100755
--- a/ap/lib/libvoice/voiceipc.c
+++ b/ap/lib/libvoice/voiceipc.c
@@ -23,6 +23,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_rx_voice_vol_gain(int gain);

+extern int sc_audio_get_rx_voice_vol_gain(int     * p_gain);

+extern int sc_audio_set_tx_voice_vol_gain(int gain);

+extern int sc_audio_get_tx_voice_vol_gain(int     * p_gain);

 //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);

@@ -262,6 +266,98 @@
 	}

 }

 

+void ipc_set_rx_voice_vol_gain_rcv(voice_ipc_control_msg msg)

+{

+    int ret = VOICEIPC_OK;

+    int msg_len = 0;

+    int gain = 0;

+

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

+    gain = *((int *)msg.param);

+    ret = sc_audio_set_rx_voice_vol_gain(gain);

+

+    //msg.func_id不变

+    msg.param_len = sizeof(int);

+    memcpy(msg.param, &ret, msg.param_len);

+    msg_len = VOICE_HEAD_LEN + msg.param_len;

+

+    ret = write(voice_ipc_fd, &msg, msg_len);

+    

+    if (0 >= ret){

+		printf("%s: write error(%d)!\n", __func__, ret);

+	}

+}

+

+void ipc_get_rx_voice_vol_gain_rcv(voice_ipc_control_msg msg)

+{

+    int ret = VOICEIPC_OK;

+    int msg_len = 0;

+    int *p_vol = NULL;

+

+    p_vol = (int *)msg.param;

+    ret = sc_audio_get_rx_voice_vol_gain(p_vol);

+	

+    //msg.func_id不变

+    msg.param_len = sizeof(int);

+    if(0 == ret)

+        memcpy(msg.param, p_vol, msg.param_len);

+    else

+        memcpy(msg.param, &ret, msg.param_len);

+    msg_len = VOICE_HEAD_LEN + msg.param_len;

+

+    ret = write(voice_ipc_fd, &msg, msg_len);

+    

+    if (0 >= ret){

+		printf("%s: write error(%d)!\n", __func__, ret);

+	}

+}

+

+void ipc_set_tx_voice_vol_gain_rcv(voice_ipc_control_msg msg)

+{

+    int ret = VOICEIPC_OK;

+    int msg_len = 0;

+    int gain = 0;

+

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

+    gain = *((int *)msg.param);

+    ret = sc_audio_set_tx_voice_vol_gain(gain);

+

+    //msg.func_id不变

+    msg.param_len = sizeof(int);

+    memcpy(msg.param, &ret, msg.param_len);

+    msg_len = VOICE_HEAD_LEN + msg.param_len;

+

+    ret = write(voice_ipc_fd, &msg, msg_len);

+    

+    if (0 >= ret){

+		printf("%s: write error(%d)!\n", __func__, ret);

+	}

+}

+

+void ipc_get_tx_voice_vol_gain_rcv(voice_ipc_control_msg msg)

+{

+    int ret = VOICEIPC_OK;

+    int msg_len = 0;

+    int *p_vol = NULL;

+

+    p_vol = (int *)msg.param;

+    ret = sc_audio_get_tx_voice_vol_gain(p_vol);

+	

+    //msg.func_id不变

+    msg.param_len = sizeof(int);

+    if(0 == ret)

+        memcpy(msg.param, p_vol, msg.param_len);

+    else

+        memcpy(msg.param, &ret, msg.param_len);

+    msg_len = VOICE_HEAD_LEN + msg.param_len;

+

+    ret = write(voice_ipc_fd, &msg, msg_len);

+    

+    if (0 >= ret){

+		printf("%s: write error(%d)!\n", __func__, ret);

+	}

+}

+

 void ipc_set_tx_voice_vol_rcv(voice_ipc_control_msg msg)

 {

     int ret = VOICEIPC_OK;

@@ -509,6 +605,18 @@
         case IPC_GET_RX_VOICE_VOL:

 			ipc_get_rx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);

 			break;

+        case IPC_SET_RX_VOICE_VOL_GAIN:

+			ipc_set_rx_voice_vol_gain_rcv(voice_ctrl_recvmsg[msg.func_id]);

+			break;

+        case IPC_GET_RX_VOICE_VOL_GAIN:

+			ipc_get_rx_voice_vol_gain_rcv(voice_ctrl_recvmsg[msg.func_id]);

+			break;

+        case IPC_SET_TX_VOICE_VOL_GAIN:

+			ipc_set_tx_voice_vol_gain_rcv(voice_ctrl_recvmsg[msg.func_id]);

+			break;

+        case IPC_GET_TX_VOICE_VOL_GAIN:

+			ipc_get_tx_voice_vol_gain_rcv(voice_ctrl_recvmsg[msg.func_id]);

+			break;

         case IPC_SET_TX_VOICE_VOL:

 			ipc_set_tx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);

 			break;