diff --git a/ap/lib/libvoice/voiceipc.c b/ap/lib/libvoice/voiceipc.c
new file mode 100755
index 0000000..198fe19
--- /dev/null
+++ b/ap/lib/libvoice/voiceipc.c
@@ -0,0 +1,402 @@
+#ifdef USE_CAP_SUPPORT
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include "voice_ipc.h"
+#include "linux/rpmsg_zx29.h"
+
+extern int sc_audio_set_voice_device_mode(int dev_mode);
+extern int sc_audio_get_voice_device_mode(int *p_dev_mode);
+extern int sc_audio_set_rx_voice_vol(int vol);
+extern int sc_audio_get_rx_voice_vol(int     * p_vol);
+extern int sc_audio_set_tx_voice_vol(int vol);
+extern int sc_audio_get_tx_voice_vol(int  *p_vol);
+extern int sc_audio_set_tx_voice_mute_state(int mute         );
+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);
+
+int voice_ipc_fd = -1;
+voice_ipc_control_msg voice_ctrl_recvmsg[IPC_VOICE_FUNC_MAX] = {0};
+
+void ipc_set_voice_device_mode(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int dev_mode = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    dev_mode = *((int *)msg.param);
+    ret = sc_audio_set_voice_device_mode(dev_mode);
+
+    //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_voice_device_mode(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int *p_dev_mode = NULL;
+
+    p_dev_mode = (int *)msg.param;
+    ret = sc_audio_get_voice_device_mode(p_dev_mode);
+	
+    //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_set_rx_voice_vol(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int vol = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    vol = *((int *)msg.param);
+    ret = sc_audio_set_rx_voice_vol(vol);
+
+    //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(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(p_vol);
+	
+    //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_set_tx_voice_vol(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int vol = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    vol = *((int *)msg.param);
+    ret = sc_audio_set_tx_voice_vol(vol);
+
+    //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(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(p_vol);
+	
+    //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_set_tx_voice_mute_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int mute = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    mute = *((int *)msg.param);
+    ret = sc_audio_set_tx_voice_mute_state(mute);
+
+    //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_mute_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int *p_mute = NULL;
+
+    p_mute = (int *)msg.param;
+    ret = sc_audio_get_tx_voice_mute_state(p_mute);
+	
+    //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_set_rx_voice_mute_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int mute = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    mute = *((int *)msg.param);
+    ret = sc_audio_set_rx_voice_mute_state(mute);
+
+    //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_mute_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int *p_mute = NULL;
+
+    p_mute = (int *)msg.param;
+    ret = sc_audio_get_rx_voice_mute_state(p_mute);
+	
+    //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_set_loopback_enable_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int enable = 0;
+
+    //memcpy(&dev_mode, msg.param, msg.param_len);
+    enable = *((int *)msg.param);
+    ret = sc_audio_set_loopback_enable_state(enable);
+
+    //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_loopback_enable_state(voice_ipc_control_msg msg)
+{
+    int ret = VOICEIPC_OK;
+    int msg_len = 0;
+    int *p_enable = NULL;
+
+    p_enable = (int *)msg.param;
+    ret = sc_audio_get_loopback_enable_state(p_enable);
+	
+    //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 voice_msg_proc(voice_ipc_control_msg msg)
+{
+	switch(msg.func_id){
+		case IPC_SET_VOICE_DEVICE_MODE:
+			ipc_set_voice_device_mode(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+		case IPC_GET_VOICE_DEVICE_MODE:
+			ipc_get_voice_device_mode(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_SET_RX_VOICE_VOL:
+			ipc_set_rx_voice_vol(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_GET_RX_VOICE_VOL:
+			ipc_get_rx_voice_vol(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_SET_TX_VOICE_VOL:
+			ipc_set_tx_voice_vol(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_GET_TX_VOICE_VOL:
+			ipc_get_tx_voice_vol(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_SET_TX_VOICE_MUTE_STATE:
+			ipc_set_tx_voice_mute_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_GET_TX_VOICE_MUTE_STATE:
+			ipc_get_tx_voice_mute_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_SET_RX_VOICE_MUTE_STATE:
+			ipc_set_rx_voice_mute_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_GET_RX_VOICE_MUTE_STATE:
+			ipc_get_rx_voice_mute_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_SET_LOOPBACK_ENABLE_STATE:
+			ipc_set_loopback_enable_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+        case IPC_GET_LOOPBACK_ENABLE_STATE:
+			ipc_get_loopback_enable_state(voice_ctrl_recvmsg[msg.func_id]);
+			break;
+		default:
+			printf("%s: msg func_id(%d) error\n", __func__, msg.func_id);
+			break;
+	}
+}
+
+void Voice_Ctrl_Rpmsg_Recv(void)
+{
+    int read_len = 0;
+    voice_ipc_control_msg tmpbuf = {0};
+    
+    for(;;){
+        read_len = 0;
+		read_len = read(voice_ipc_fd, &tmpbuf, (VOICE_HEAD_LEN + VOICE_CONTROL_MAX_LEN));
+        if (0 >= read_len){
+			continue;
+		}
+
+        //最后再改变func_id，确保其他地方判断func_id改变后有数据可读
+        memcpy(voice_ctrl_recvmsg[tmpbuf.func_id].param, tmpbuf.param, tmpbuf.param_len);
+        voice_ctrl_recvmsg[tmpbuf.func_id].param_len = tmpbuf.param_len;
+        voice_ctrl_recvmsg[tmpbuf.func_id].func_id = tmpbuf.func_id;
+        
+        voice_msg_proc(voice_ctrl_recvmsg[tmpbuf.func_id]);
+    }
+}
+
+int voice_ipc_init(void) //通道初始化
+{
+    voice_ipc_fd = open(VOICE_IPC_CONTROL_CHANNEL, O_RDWR);
+
+    if(0 > voice_ipc_fd){
+        printf("%s: open the channel(%s) error!\n", __func__, VOICE_IPC_CONTROL_CHANNEL);
+        return VOICEIPC_ERROR;
+    }
+
+    if(0 > ioctl(voice_ipc_fd, RPMSG_CREATE_CHANNEL, VOICE_IPC_CONTROL_CHANNEL_SIZE)){
+        printf("%s: ioctl RPMSG_CREATE_CHANNEL fail!\n", __func__);
+        close(voice_ipc_fd);
+        voice_ipc_fd = -1;
+        return VOICEIPC_ERROR;
+    }
+    
+    if(0 > ioctl(voice_ipc_fd, RPMSG_SET_INT_FLAG, NULL)){ //写中断
+        printf("%s: ioctl RPMSG_SET_INT_FLAG fail!\n", __func__);
+        close(voice_ipc_fd);
+        voice_ipc_fd = -1;
+        return VOICEIPC_ERROR;
+    }
+    
+    if(0 > ioctl(voice_ipc_fd, RPMSG_CLEAR_POLL_FLAG, NULL)){ //阻塞方式读数据
+        printf("%s: ioctl RPMSG_CLEAR_POLL_FLAG fail!\n", __func__);
+        close(voice_ipc_fd);
+        voice_ipc_fd = -1;
+        return VOICEIPC_ERROR;
+    }
+    return VOICEIPC_OK;
+}
+
+int main(int argc, char **argv)
+{
+    int ret = 0;
+    
+    ret = voice_ipc_init();
+    
+    if(ret < 0){
+        printf("voice_ipc_init error!\n");
+        return -1;
+    }
+
+    printf("voice_ipc_init %s create success!\n", VOICE_IPC_CONTROL_CHANNEL);
+    
+    Voice_Ctrl_Rpmsg_Recv();
+    
+    return 0;
+}
+
+#endif
