[Feature][T106][task-view-97] add interface for voice call to rtp,
modification in cp and ap and pub
Only Configure: No
Affected branch: unknown
Affected module: voice call and at
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: yes
Doc Update: no
Change-Id: I5c7bc461e790ee24805a520077ca80b5eeb7bbf1
(cherry picked from commit 13ef23011ea4cd9fc919b82e82202f09c0b2ef3e)
diff --git a/ap/lib/libatext/ext_audio_func.c b/ap/lib/libatext/ext_audio_func.c
index d12ed7d..e95b017 100755
--- a/ap/lib/libatext/ext_audio_func.c
+++ b/ap/lib/libatext/ext_audio_func.c
@@ -66,6 +66,19 @@
MAX_CODEC_OUTPUT_PATH
}T_ZDrv_CodecOutputPath;
+
+
+#ifdef _VBUFF_IN_SINGLE_CORE
+extern int vbuffer_stream_start(void);
+extern int vbuffer_stream_stop(void);
+#endif
+
+#ifdef _USE_VOICE_AT
+
+extern int voice_SetVoiceBuffer(T_VoiceBuf_Para *vb);
+extern int voice_GetVoiceBuffer(T_VoiceBuf_Para *vb);
+#endif
+
#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT
extern SINT32 halEarp_Open(VOID);
extern SINT32 halEarp_Close(VOID);
@@ -525,6 +538,134 @@
}
#endif
+#ifdef _USE_VOICE_AT
+
+int extAt_Voice_Process_set (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ char *at_str = NULL;
+ UINT32 ret = DRV_SUCCESS;
+
+ int mode = 0;
+ int vp = 0;
+
+ UINT16 onOff = 0;
+ at_str = at_paras;
+ printf("%s, at_paras:%s \n",__func__, at_paras);
+
+ ret = sscanf (at_str, "%d", &vp);
+ printf("%s: vp=%d,ret=%d\n",__func__,vp,ret);
+
+ if (ret == 1) {
+
+ ret = voice_SetVoiceProcess(&vp);
+ printf("%s: alsa_voice_open,ret=%d\n",__func__,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;
+}
+
+
+
+int extAt_Voice_Process_get(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+
+
+
+ char vp_str[32] = {0};
+ printf("%s: %s\n",__func__,at_paras);
+ int vp = voice_GetVoiceProcess();
+ if( vp < 0)
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ printf("%s: vp=%d",__func__,vp);
+
+ snprintf(vp_str, 32,"%d\r\n",vp);
+
+ *res_msg = at_query_result_build("AT+VOICEPROCESS",vp_str);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+
+
+
+int extAt_VoiceBuffer_Set (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ char *at_str = NULL;
+ UINT32 ret = DRV_SUCCESS;
+
+ int enable = 0;
+ int type = 0;
+ T_VoiceBuf_Para vb;
+ at_str = at_paras;
+ printf("%s, at_paras:%s \n",__func__, at_paras);
+
+ //ret = sscanf (at_str, "%d", &vp);
+
+ ret = sscanf (at_str, "%d,%d", &enable,&type);
+ printf("%s: enable=%d type=%d,ret=%d\n",__func__,enable,type,ret);
+
+ if (ret == 2) {
+ vb.enable = enable;
+ vb.type = type;
+
+ ret = voice_SetVoiceBuffer(&vb);
+ printf("%s: voice_SetVoiceBuffer,ret=%d\n",__func__,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;
+}
+
+
+int extAt_VoiceBuffer_Get(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ UINT32 ret = DRV_SUCCESS;
+
+ T_VoiceBuf_Para vb;
+
+
+ char vp_str[32] = {0};
+ printf("%s: %s\n",__func__,at_paras);
+ ret = voice_GetVoiceBuffer(&vb);
+ if( ret < 0)
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ printf("%s: fs=%d enable=%d type=%d",__func__,vb.fs,vb.enable,vb.type);
+
+ snprintf(vp_str, 32,"%d %d %d\r\n",vb.fs,vb.enable,vb.type);
+
+ *res_msg = at_query_result_build("AT+VOICE_BUFFER",vp_str);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+
+#endif
+
#ifdef _VBUFF_IN_SINGLE_CORE
int extAt_VBUFFER_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
{
@@ -587,13 +728,23 @@
register_serv_func2("VALSA=", 0, 0, 0, extAt_VALSA_act_func, NULL);
register_serv_func2("VPATH=", 0, 0, 0, extAt_VPATH_act_func, NULL);
register_serv_func2("CAP_VALSA=", 0, 0, 0, extAt_CAP_VALSA_act_func, NULL);
-
#endif
#ifdef _VBUFF_IN_SINGLE_CORE
register_serv_func2("VBUFFER=", 0, 0, 0, extAt_VBUFFER_act_func, NULL);
#endif
+#ifdef _USE_VOICE_AT
+register_serv_func2("VOICE_PROCESS=",0,0,0,extAt_Voice_Process_set, NULL);
+register_serv_func2("VOICE_PROCESS?",0,0,0,extAt_Voice_Process_get, NULL);
+
+register_serv_func2("VOICE_BUFFER=",0,0,0,extAt_VoiceBuffer_Set, NULL);
+register_serv_func2("VOICE_BUFFER?",0,0,0,extAt_VoiceBuffer_Get, NULL);
+#endif
+
+
+
+
}
#endif
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/amr.a b/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
index 01399c1..2078afc 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a b/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
index 5147df5..820bf26 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/chip.a b/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
index b089432..a894c29 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a b/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
index b3ff588..b7a6a70 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/public.a b/ap/lib/libps/220A1_vehicle_dc/drv/public.a
index c6e5c8c..73af441 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/public.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/public.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a b/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
index c86f9b5..123cbbb 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
Binary files differ
diff --git a/ap/lib/libvoice/Makefile b/ap/lib/libvoice/Makefile
index 7d677fb..48061f2 100755
--- a/ap/lib/libvoice/Makefile
+++ b/ap/lib/libvoice/Makefile
@@ -25,11 +25,14 @@
LIB_STATIC = libvoice.a
ifeq ($(USE_VOICE_ALSA),yes)
OBJS = voice.o alsa_call.o voice_api.o voiceipc.o
-else ifeq ($(USE_VOICE_BUFFER_IN_AP),yes)
-OBJS = voice.o voice_buffer.o
+
else
OBJS = voice.o
endif
+
+ifeq ($(USE_VOICE_BUFFER_IN_AP),yes)
+OBJS += voice_buffer.o
+endif
CFLAGS += -g
LDFLAGS += -lpthread
diff --git a/ap/lib/libvoice/include/voice_lib.h b/ap/lib/libvoice/include/voice_lib.h
index 4023dc3..2238b6b 100755
--- a/ap/lib/libvoice/include/voice_lib.h
+++ b/ap/lib/libvoice/include/voice_lib.h
@@ -55,6 +55,10 @@
int voice_Vploop(int *path);
int zDrvVolte_PreOpen(T_ZDrvVolte_Cfg *cfgParam);
void zDrvVolte_PreClose(void);
+ int voice_SetVoiceProcess(int *vp);
+ int voice_GetVoiceProcess(void);
+
+
#ifdef _VBUFF_IN_SINGLE_CORE
int vbuffer_stream_start(void);
diff --git a/ap/lib/libvoice/voice.c b/ap/lib/libvoice/voice.c
index 61b9c1e..6af0fa6 100755
--- a/ap/lib/libvoice/voice.c
+++ b/ap/lib/libvoice/voice.c
@@ -167,7 +167,7 @@
}
ret = ioctl(fd, VOICE_IOCTL_VPLOOP, path);
if (ret) {
- printf("voice_Vploop: ret=%d,path=%p.\n", ret, path);
+ printf("voice_Vploop: ret=%d,path=%d.\n", ret, *path);
close(fd);
return -1;
}
@@ -224,18 +224,20 @@
}
}
#if defined(_VBUFF_IN_SINGLE_CORE) || defined(_VBUFF_IN_MULTI_CORE)
- printf("%s: use voice buffer,return!\n",__func__);
+ printf("%s: ap use voice buffer,return!\n",__func__);
return 0;
#endif
#if defined(_ALSA_CODEC_IN_CAP) && defined(_USE_ALSA_AT_INTF)
+ printf("%s:_ALSA_CODEC_IN_CAP and at intf!\n",__func__);
- printf("%s: i2s and codec not need config,return!\n",__func__);
+ printf("%s:ap i2s and codec not need config,return!\n",__func__);
return 0;
#elif defined(_ALSA_CODEC_IN_CAP)
+ printf("%s:_ALSA_CODEC_IN_CAP!\n",__func__);
if(cfgParam->clock_rate == 8000){
@@ -261,6 +263,7 @@
#endif
+ printf("%s:ap do mixer and pcm opt!\n",__func__);
//open mixer dev for codec control
voice_mixer = mixer_open(0);
@@ -390,6 +393,93 @@
}
+int voice_SetVoiceProcess(int *vp)
+{
+ int ret = 0;
+ int fd = -1;
+ printf("%s: start vp=%d!\n",__func__,*vp);
+ fd = open(VOICE_DEV_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("%s: open voice device error.\n",__func__);
+ return -1;
+ }
+ ret = ioctl(fd, VOICE_IOCTL_SET_VP, vp);
+ if (ret) {
+ printf("%s: ret=%d,vp=%d.\n",__func__, ret, *vp);
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return 0;
+
+}
+int voice_GetVoiceProcess(void)
+{
+ int ret = 0;
+ int fd = -1;
+ int vp = 0;
+ fd = open(VOICE_DEV_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("%s: open voice device error.\n",__func__);
+ return -1;
+ }
+ ret = ioctl(fd, VOICE_IOCTL_GET_VP, &vp);
+ if (ret) {
+ printf("%s: ret=%d,vp=%d.\n",__func__, ret, vp);
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ printf("%s: vp=%d!\n",__func__,vp);
+
+ return vp;
+
+}
+
+int voice_SetVoiceBuffer(T_VoiceBuf_Para *vb)
+{
+ int ret = 0;
+ int fd = -1;
+ printf("%s: start enable=%d,type=%d!\n",__func__,vb->enable,vb->type);
+ fd = open(VOICE_DEV_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("%s: open voice device error.\n",__func__);
+ return -1;
+ }
+ ret = ioctl(fd, VOICE_IOCTL_SET_VBUF, vb);
+ if (ret) {
+ printf("%s: ret=%d.\n",__func__, ret);
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return 0;
+
+}
+
+int voice_GetVoiceBuffer(T_VoiceBuf_Para *vb)
+{
+ int ret = 0;
+ int fd = -1;
+ fd = open(VOICE_DEV_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("%s: open voice device error.\n",__func__);
+ return -1;
+ }
+ ret = ioctl(fd, VOICE_IOCTL_GET_VBUF, vb);
+ if (ret) {
+ printf("%s: ret=%d.\n",__func__, ret);
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ printf("%s: start fs=%d enable=%d,type=%d!\n",__func__,vb->fs,vb->enable,vb->type);
+
+
+ return ret;
+
+}
+
diff --git a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
index e77e5fe..78abbea 100755
--- a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
@@ -80,36 +80,39 @@
zDrvVp_AudioDataOpen(UINT32 audioType,UINT32 sampleRate);extern SINT32
zDrvVp_AudioDataClose(void);extern SINT32 zDrvVp_GetVpLoop_Wrap(VOID);extern
VOID zDrvVp_Status(UINT32*sample_rate,UINT32*voice_status);extern VOID
-zDrvVp_UpdateVoiceNv(UINT8*voice_nv_update);typedef struct cpko_section{unsigned
+zDrvVp_UpdateVoiceNv(UINT8*voice_nv_update);extern int zDrvVp_SetVoiceProc_Wrap(
+int val);extern int zDrvVp_GetVoiceProc_Wrap(void);extern int
+zDrvVp_SetVoiceBuffer_Wrap(int en,int type);extern void
+zDrvVp_GetVoiceBuffer_Wrap(int*en,int*type);typedef struct cpko_section{unsigned
int cpko_text_start;unsigned int cpko_rodata_start;unsigned int
__utran_modem_text_start;unsigned int __lte_modem_text_start;unsigned int
__comm_modem_text_start;unsigned int modem_text_end;unsigned int cpko_data_start
;unsigned int cpko_bss_start;unsigned int cpko_text_offset;}cpko_section_layout;
cpko_section_layout cpko_ps_section;int raise(int signo){return
-(0x9e6+3955-0x1959);}extern unsigned int SysEntry(void);static int
+(0x1293+3341-0x1fa0);}extern unsigned int SysEntry(void);static int
ko_Main_Thread(void*data){struct sched_param param={.sched_priority=
-MAX_USER_RT_PRIO/(0x19ec+1080-0x1e22)-(0x1448+357-0x15aa)};int ret=
-(0x20f+6386-0x1b01);sched_setscheduler(current,SCHED_FIFO,¶m);ret=SysEntry()
-;if(ret!=(0x381+2774-0xe57))panic("Main_Thread\n");param.sched_priority=
-MAX_USER_RT_PRIO-(0x839+7013-0x2370);sched_setscheduler(kthreadd_task,SCHED_FIFO
-,¶m);return(0xef+5068-0x14bb);}int zte_modem_ko_start(void){kthread_run(
+MAX_USER_RT_PRIO/(0x212a+283-0x2243)-(0xf96+4078-0x1f81)};int ret=
+(0x556+3365-0x127b);sched_setscheduler(current,SCHED_FIFO,¶m);ret=SysEntry()
+;if(ret!=(0x762+3053-0x134f))panic("Main_Thread\n");param.sched_priority=
+MAX_USER_RT_PRIO-(0x20f+9342-0x265f);sched_setscheduler(kthreadd_task,SCHED_FIFO
+,¶m);return(0xb1d+2770-0x15ef);}int zte_modem_ko_start(void){kthread_run(
ko_Main_Thread,NULL,"\x5a\x54\x45\x4d\x61\x69\x6e\x54\x68\x72\x65\x61\x64");
-return(0x12ac+2426-0x1c26);}static void cpko_sectioninfo_set(void){int ret;
-struct file*fp;mm_segment_t old_fs;loff_t cpko_pos=(0x8bd+6473-0x2206);struct
+return(0xda9+1225-0x1272);}static void cpko_sectioninfo_set(void){int ret;struct
+ file*fp;mm_segment_t old_fs;loff_t cpko_pos=(0xd79+4186-0x1dd3);struct
cpps_globalModem globalVar;fp=filp_open(
"\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x5f\x73\x65\x63\x69\x6e\x66\x6f\x2e\x62\x69\x6e"
-,(0x81a+3218-0x14ac),(0x1263+2589-0x1c80));if(IS_ERR(fp)||fp==NULL)panic(
+,(0xd6f+4364-0x1e7b),(0x1e3a+1192-0x22e2));if(IS_ERR(fp)||fp==NULL)panic(
"\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");old_fs=
get_fs();set_fs(KERNEL_DS);ret=vfs_read(fp,(char*)&cpko_ps_section,sizeof(
-cpko_section_layout),&cpko_pos);if(ret<=(0xa02+7211-0x262d))panic(
+cpko_section_layout),&cpko_pos);if(ret<=(0x1438+2416-0x1da8))panic(
"\x72\x65\x61\x64\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");filp_close(
fp,NULL);
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
fp=filp_open(
"\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x2e\x6b\x6f",
-(0xaf4+502-0xcea),(0xe41+3977-0x1dca));if(IS_ERR(fp)||fp==NULL)panic(
+(0xaf7+4826-0x1dd1),(0x16a0+1762-0x1d82));if(IS_ERR(fp)||fp==NULL)panic(
"\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");fp->f_ra.
-ra_pages=(0x370+4606-0x156e);
+ra_pages=(0x16f1+3892-0x2625);
#endif
if(cpko_ps_section.cpko_text_start){globalVar.cpko_text_start=(unsigned long)
cpko_ps_section.cpko_text_start;globalVar.cpko_rodata_start=(unsigned long)
@@ -129,7 +132,7 @@
vfree_modem_section(globalVar.cpko_text_start,globalVar.modem_text_end);
#endif
}else panic("\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");}static int
-cpko_start(void){struct cpps_callbacks callback={(0xef6+2228-0x17aa)};callback.
+cpko_start(void){struct cpps_callbacks callback={(0x386+531-0x599)};callback.
zOss_ResetNVFactory=zOss_ResetNVFactory;callback.zOss_NvramFlush=zOss_NvramFlush
;callback.zOss_NvItemWrite=zOss_NvItemWrite;callback.zOss_NvItemWriteFactory=
zOss_NvItemWriteFactory;callback.zOss_NvItemRead=zOss_NvItemRead;callback.
@@ -184,7 +187,11 @@
zDrvVp_SetPath_Wrap=zDrvVp_SetPath_Wrap;callback.zDrvVp_GetPath_Wrap=
zDrvVp_GetPath_Wrap;callback.halVoice_Open3G=halVoice_Open3G;callback.
halVoice_Close3G=halVoice_Close3G;callback.zDrvVp_GetSlicFlag=zDrvVp_GetSlicFlag
-;callback.zDrvVp_SetEchoDelay_Wrap=zDrvVp_SetEchoDelay_Wrap;callback.
+;callback.zDrvVp_SetVoiceProc_Wrap=zDrvVp_SetVoiceProc_Wrap;callback.
+zDrvVp_GetVoiceProc_Wrap=zDrvVp_GetVoiceProc_Wrap;callback.
+zDrvVp_SetVoiceBuffer_Wrap=zDrvVp_SetVoiceBuffer_Wrap;callback.
+zDrvVp_GetVoiceBuffer_Wrap=zDrvVp_GetVoiceBuffer_Wrap;callback.
+zDrvVp_SetEchoDelay_Wrap=zDrvVp_SetEchoDelay_Wrap;callback.
zDrvVp_GetEchoDelay_Wrap=zDrvVp_GetEchoDelay_Wrap;callback.
zDrvVp_SetTxNsMode_Wrap=zDrvVp_SetTxNsMode_Wrap;callback.zDrvVp_GetTxNsMode_Wrap
=zDrvVp_GetTxNsMode_Wrap;callback.zDrvVp_SetRxNsMode_Wrap=
@@ -205,5 +212,5 @@
psm_GetModemSleepFlagStatus=psm_GetModemSleepFlagStatus;
#endif
cpps_callbacks_register(&callback);cpko_sectioninfo_set();zte_modem_ko_start();
-return(0x562+5820-0x1c1e);}static int cpko_stop(void){return(0x4bc+6970-0x1ff6);
-}module_init(cpko_start);module_exit(cpko_stop);
+return(0xa8b+6811-0x2526);}static int cpko_stop(void){return(0x6d2+1995-0xe9d);}
+module_init(cpko_start);module_exit(cpko_stop);
diff --git a/ap/os/linux/linux-3.4.x/drivers/staging/Makefile b/ap/os/linux/linux-3.4.x/drivers/staging/Makefile
index a935c69..a02bedb 100755
--- a/ap/os/linux/linux-3.4.x/drivers/staging/Makefile
+++ b/ap/os/linux/linux-3.4.x/drivers/staging/Makefile
@@ -62,6 +62,6 @@
obj-$(CONFIG_CAMERA_DRV) += camera/
obj-$(CONFIG_AMR_DRV) += amrdrv/
obj-$(CONFIG_VOICE_DRV) += voicedrv/
-obj-$(CONFIG_VOICE_BUFFER_DRV) += voicebufferdrv/
+obj-y += voicebufferdrv/
obj-$(CONFIG_AUDIOMIX_DRV) += audiomixdrv/
obj-$(CONFIG_PLAT_TEST) += plat_test/
diff --git a/ap/os/linux/linux-3.4.x/drivers/staging/voicebufferdrv/Makefile b/ap/os/linux/linux-3.4.x/drivers/staging/voicebufferdrv/Makefile
index 7c8c2fd..597480a 100755
--- a/ap/os/linux/linux-3.4.x/drivers/staging/voicebufferdrv/Makefile
+++ b/ap/os/linux/linux-3.4.x/drivers/staging/voicebufferdrv/Makefile
@@ -1,5 +1,5 @@
#
# voice buffer driver.
#
-obj-$(CONFIG_VOICE_BUFFER_DRV) += voice_buffer_drv.o
-voice_buffer_drv-$(CONFIG_VOICE_BUFFER_DRV) := voice_buffer_dev.o
+obj-y += voice_buffer_drv.o
+voice_buffer_drv-y := voice_buffer_dev.o
diff --git a/ap/os/linux/linux-3.4.x/drivers/staging/voicedrv/voice.c b/ap/os/linux/linux-3.4.x/drivers/staging/voicedrv/voice.c
index a47acf0..ef8d187 100755
--- a/ap/os/linux/linux-3.4.x/drivers/staging/voicedrv/voice.c
+++ b/ap/os/linux/linux-3.4.x/drivers/staging/voicedrv/voice.c
@@ -30,6 +30,7 @@
extern int halVoice_SetVolOut(T_HalVoice_Block* pVoiceBlock);
extern int halVoice_Enable(void);
extern int halVoice_Disable(void);
+extern int zDrvVp_Loop(int);
#ifdef _USE_VEHICLE_DC
extern int zDrvVp_GetVol_Wrap(void);
@@ -39,6 +40,9 @@
extern int zDrvVp_SetMute_Wrap(bool enable);
extern bool zDrvVp_GetMute_Wrap(void);
#endif
+extern void zDrvVp_UpdateVoiceNv(unsigned char *voice_nv_update);
+extern unsigned int zOss_NvItemWrite(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);
+
static int voice_open(struct inode *ip, struct file *fp);
static int voice_release(struct inode *ip, struct file *fp);
static long voice_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
@@ -163,6 +167,29 @@
#endif
+
+
+static int voice_SetVp(int vp)
+{
+ int ret = 0;
+ ret = CPPS_FUNC(cpps_callbacks, zDrvVp_SetVoiceProc_Wrap)(vp);
+ if(ret < 0)
+ {
+ printk(KERN_ERR "vp_SetVp fail = %d\n",vp);
+ return ret;
+ }
+ return 0;
+}
+
+static int voice_GetVp(void)
+{
+ int vp;
+ vp = CPPS_FUNC(cpps_callbacks, zDrvVp_GetVoiceProc_Wrap)();
+ return vp;
+}
+
+
+
/* file operations for volte device /dev/volte_device */
static const struct file_operations voice_fops = {
.owner = THIS_MODULE,
@@ -406,7 +433,7 @@
bool para;
if (copy_from_user(¶, argp, sizeof(para))) {
- print_audio("voice_ioctl set vol copy_to_user err!\n");
+ print_audio("voice_ioctl set mute copy_to_user err!\n");
return -EFAULT;
}
ret = voice_SetMute(para);
@@ -501,6 +528,69 @@
break;
}
+ case VOICE_IOCTL_SET_VP: {
+ pr_info("voice set voice process! \n");
+ int para;
+
+ if (copy_from_user(¶, argp, sizeof(para))) {
+ print_audio("voice_ioctl set vp copy_to_user err!\n");
+ return -EFAULT;
+ }
+ ret = voice_SetVp(para);
+ break;
+ }
+
+ case VOICE_IOCTL_GET_VP: {
+ pr_info("voice get voice process! \n");
+ int vp;
+
+ vp = voice_GetVp();
+
+ if (copy_to_user(argp, &vp, sizeof(vp))) {
+ pr_err("voice_ioctl get vp copy_to_user err!\n");
+ return -EFAULT;
+ }
+ break;
+ }
+
+ case VOICE_IOCTL_GET_VBUF: {
+ int fs = 0;
+ int en = 0;
+ int type = 0;
+ T_VoiceBuf_Para vb;
+ CPPS_FUNC(cpps_callbacks, zDrvVp_Status)(&fs, NULL);
+ pr_info("voice_ioctl zDrvVp_Status fs=%d!\n", fs);
+ CPPS_FUNC(cpps_callbacks, zDrvVp_GetVoiceBuffer_Wrap)(&en,&type);
+ vb.fs = fs;
+ vb.enable = en;
+ vb.type = type;
+ pr_info("voice_ioctl GET_VBUF,enable=%d type=%d!\n",vb.enable,vb.type);
+
+ if (copy_to_user(argp, &vb, sizeof(vb))) {
+ pr_err("voice_ioctl GET_VBUF copy_to_user err!\n");
+ return -EFAULT;
+ }
+
+ break;
+ }
+
+ case VOICE_IOCTL_SET_VBUF: {
+ T_VoiceBuf_Para vb;
+
+ if (copy_from_user(&vb, argp, sizeof(vb))) {
+ print_audio("voice_ioctl SET_VBUF copy_to_user err!\n");
+ return -EFAULT;
+ }
+
+ CPPS_FUNC(cpps_callbacks, zDrvVp_SetVoiceBuffer_Wrap)(vb.enable,vb.type);
+ pr_info("voice_ioctl SET_VBUF,enable=%d type=%d!\n",vb.enable,vb.type);
+
+
+
+ break;
+ }
+
+
default: {
pr_info("voice_ioctl invalid cmd!\n");
break;
diff --git a/ap/os/linux/linux-3.4.x/drivers/staging/voltedrv/volte.c b/ap/os/linux/linux-3.4.x/drivers/staging/voltedrv/volte.c
index 2341465..262868f 100644
--- a/ap/os/linux/linux-3.4.x/drivers/staging/voltedrv/volte.c
+++ b/ap/os/linux/linux-3.4.x/drivers/staging/voltedrv/volte.c
@@ -39,6 +39,7 @@
extern int32_t zDrvVoice_WriteStop(void);
extern int32_t zDrvVoice_ReadOneFrame(uint8_t *pBuf);
extern int32_t zDrvVoice_WriteOneFrame(uint8_t *pBuf);
+ extern int zDrvVp_GetSlicFlag(void);
diff --git a/ap/os/linux/linux-3.4.x/include/linux/module.h b/ap/os/linux/linux-3.4.x/include/linux/module.h
index 2c82c91..4424555 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/module.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/module.h
@@ -21,6 +21,9 @@
#include <linux/percpu.h>
#include <asm/module.h>
#include <linux/amr_drv.h>
+
+#include <linux/volte_drv.h>
+
/* Not Yet Implemented */
#define MODULE_SUPPORTED_DEVICE(name)
@@ -743,6 +746,11 @@
void (*zDrvDtmf_Detect_RegCallbacks)(T_DrvDtmf_Detect_Opt);
int (*zDrvVp_SetPath_Wrap)(int);
int (*zDrvVp_GetSlicFlag)(void);
+ int (*zDrvVp_SetVoiceProc_Wrap)(int);
+ int (*zDrvVp_GetVoiceProc_Wrap)(void);
+ int (*zDrvVp_SetVoiceBuffer_Wrap)(int ,int );
+ void (*zDrvVp_GetVoiceBuffer_Wrap)(int *,int *);
+
int (*zDrvVp_SetEchoDelay_Wrap)(int);
int (*zDrvVp_GetEchoDelay_Wrap)(void);
int (*zDrvVp_SetTxNsMode_Wrap)(int);
diff --git a/ap/os/linux/linux-3.4.x/include/linux/volte_drv.h b/ap/os/linux/linux-3.4.x/include/linux/volte_drv.h
index 47a6c01..d281d7d 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/volte_drv.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/volte_drv.h
@@ -73,6 +73,15 @@
} T_Voice_Para;
+typedef struct {
+ uint32_t fs; //8000;16000
+ uint32_t enable; //// 0 disable;1 enable
+ uint32_t type;//0 single core;1 mult core
+
+
+} T_VoiceBuf_Para;
+
+
#ifdef __KERNEL__
struct voice_dev {
T_Voice_Para param;
@@ -97,6 +106,14 @@
#define VOICE_IOCTL_GET_FS _IOR('v', 20, int)
#define VOICE_IOCTL_SET_VOICE_NVRW _IOW('v', 21, int)
+#define VOICE_IOCTL_SET_VP _IOW('v', 22, int)
+#define VOICE_IOCTL_GET_VP _IOR('v', 23, int)
+
+#define VOICE_IOCTL_SET_VBUF _IOW('v', 24, T_VoiceBuf_Para)
+#define VOICE_IOCTL_GET_VBUF _IOR('v', 25, T_VoiceBuf_Para)
+
+
+
#ifdef __KERNEL__
#define print_audio(fmt, ...) \
printk(fmt, ##__VA_ARGS__)
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk b/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
index 4f38694..24f8ce3 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/build/config.mk
@@ -62,6 +62,9 @@
#else
#CUSTOM_MACRO += -D_CPE_AUDIO_PRJ
endif
+ifeq ($(USE_VOICE_AT),yes)
+CUSTOM_MACRO += -D_USE_VOICE_AT
+endif
ifeq ($(USE_VOICE_ALSA),yes)
CUSTOM_MACRO += -D_USE_VOICE_ALSA
endif
diff --git a/cp/ps/driver/inc/misc/drvs_voiceprocess.h b/cp/ps/driver/inc/misc/drvs_voiceprocess.h
index 67cc84d..acceb20 100755
--- a/cp/ps/driver/inc/misc/drvs_voiceprocess.h
+++ b/cp/ps/driver/inc/misc/drvs_voiceprocess.h
@@ -283,6 +283,10 @@
BOOL firstRegZCATFlag; //25
T_Hal_EcallData ecallData;//26
UINT8 voice_nv_update;//27
+ UINT8 useVoiceBuffer; // 0 not use,1 use
+ UINT8 voiceBufferType; //0 single core, 1 dual core
+
+
} T_zDrvVoice_GbVar; //T_zDrvVoice_GbVar
typedef struct
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/audio_config/audioRef_cfg.c b/cp/ps/driver/src/chipsets/src/audio_base/audio_config/audioRef_cfg.c
index 7489d52..20c1ddc 100755
--- a/cp/ps/driver/src/chipsets/src/audio_base/audio_config/audioRef_cfg.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/audio_config/audioRef_cfg.c
@@ -25,6 +25,7 @@
#include "drvs_general.h"
#include "drvs_i2s.h"
#include "drvs_voiceprocess.h"
+#include "hal_voiceprocess.h"
#include "drvs_voice_config.h"
#include "drvs_i2c.h"
#include "NvParam_drv.h"
@@ -132,7 +133,7 @@
//#define AUDIO_USE_FIXED_ADDRESS
-#define VP_INOUT_BAK_BUFFER_SIZE 0x30000 // 0x60000
+//#define VP_INOUT_BAK_BUFFER_SIZE 0x30000 // 0x60000
#define VP_INOUT_NOBAK_BUFSIZE 640
/**************************************************************************
@@ -595,7 +596,8 @@
//ret = zDrvNand_Read(OS_FLASH_VOICE_DRV_RW_NONFAC_BASE_ADDR, sizeof(audionvflag), ((UINT8 *)(&audionvflag)));
ret = zOss_NvItemRead(OS_FLASH_VOICE_DRV_RW_NONFAC_BASE_ADDR, ((UINT8 *)(&audionvflag)), sizeof(audionvflag));
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, " zDrvVoiceConfig_Init zOss_NvItemRead isVpParamInNv=%d,isUseSlicCodec=%d!\n", audionvflag.isVpParamInNv, audionvflag.isUseSlicCodec);
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, " zDrvVoiceConfig_Init zOss_NvItemRead isVpParamInNv=%d,isUseSlicCodec=%d,isUseVoiceProc=%d,isUseTdm=%d,isUseEcall=%d!\n", audionvflag.isVpParamInNv, audionvflag.isUseSlicCodec,audionvflag.isUseVoiceProc,audionvflag.isUseTdm,audionvflag.isUseEcall);
//hal_TestTopI2sConfig();
if (ret != DRV_SUCCESS)
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/audiointf/hal_audextintf.c b/cp/ps/driver/src/chipsets/src/audio_base/audiointf/hal_audextintf.c
index dff7364..db57346 100755
--- a/cp/ps/driver/src/chipsets/src/audio_base/audiointf/hal_audextintf.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/audiointf/hal_audextintf.c
@@ -193,6 +193,40 @@
{
return g_voiceVar.muteEn;
}
+
+int zDrvVp_SetVoiceProc_Wrap(int val)
+{
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: val=%d !\n",__func__,val);
+
+ g_voiceVar.audio_ctrlFlag.isUseVoiceProc = val;
+ return DRV_SUCCESS;
+}
+
+int zDrvVp_GetVoiceProc_Wrap(void)
+{
+ return g_voiceVar.audio_ctrlFlag.isUseVoiceProc;
+}
+
+int zDrvVp_SetVoiceBuffer_Wrap(int en,int type)
+{
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: en=%d,type=%d !\n",__func__,en,type);
+
+ g_voiceVar.useVoiceBuffer = en;
+ g_voiceVar.voiceBufferType = type;
+ return DRV_SUCCESS;
+}
+
+void zDrvVp_GetVoiceBuffer_Wrap(int *en,int *type)
+{
+ if((en!=NULL)&&(type!=NULL)){
+ *en = g_voiceVar.useVoiceBuffer;
+ *type = g_voiceVar.voiceBufferType;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: en=%d,type=%d !\n",__func__,*type,*en);
+ }
+}
+
+
SINT32 zDrvVp_SetRxMute_Wrap(int enable)
{
return zDrvVp_SetRxMute(enable, VOICE_DOWNLINK);
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/audiointf/voice_procintf.c b/cp/ps/driver/src/chipsets/src/audio_base/audiointf/voice_procintf.c
index 2f0e803..5146753 100644
--- a/cp/ps/driver/src/chipsets/src/audio_base/audiointf/voice_procintf.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/audiointf/voice_procintf.c
@@ -15,6 +15,10 @@
* Include files
****************************************************************************/
#include "drvs_general.h"
+
+#include "drvs_volte.h"
+#include "drvs_voiceprocess.h"
+
#include "drvs_ramlog.h"
#include <oss_clib.h>
#include <oss_kernel.h>
@@ -73,8 +77,12 @@
g_voiceVar.isUseSlicCodec = g_voiceVar.audio_ctrlFlag.isUseSlicCodec;
g_voiceVar.g_isUseTdm = g_voiceVar.audio_ctrlFlag.isUseTdm;
+
+ g_voiceVar.useVoiceBuffer = g_voiceVar.audio_ctrlFlag.isUseVoiceBuffer; // 0 not use,1 use
+ g_voiceVar.voiceBufferType = g_voiceVar.audio_ctrlFlag.selVoiceBufferType;//0 single core, 1 dual core
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, " VoiceProc_InitNvParam isUseVoiceProc=%d,isUseSlicCodec=%d,isUseTdm=%d!\n", g_voiceVar.audio_ctrlFlag.isUseVoiceProc, g_voiceVar.isUseSlicCodec, g_voiceVar.audio_ctrlFlag.isUseTdm);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, " VoiceProc_InitNvParam isUseVoiceProc=%d,isUseSlicCodec=%d,isUseTdm=%d,useVoiceBuffer=%d,voiceBufferType=%d!\n", g_voiceVar.audio_ctrlFlag.isUseVoiceProc, \
+ g_voiceVar.isUseSlicCodec, g_voiceVar.audio_ctrlFlag.isUseTdm,g_voiceVar.useVoiceBuffer,g_voiceVar.voiceBufferType);
if (g_voiceVar.audio_ctrlFlag.isUseVoiceProc == 1)
{
#ifdef _USE_NXP_AUD
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/i2s/hal_i2s.c b/cp/ps/driver/src/chipsets/src/audio_base/i2s/hal_i2s.c
index 983a92a..5ea7c1d 100755
--- a/cp/ps/driver/src/chipsets/src/audio_base/i2s/hal_i2s.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/i2s/hal_i2s.c
@@ -4322,6 +4322,37 @@
*/
VOID vp_SetTopI2sConfig(VOID)
{
+
+
+UINT32 AmrRegBit = 0;
+
+if (g_voiceVar.useVoiceBuffer == 1){
+
+
+
+ /* inter loop */
+ AmrRegBit = ARM_I2S_LOOP_CFG;
+
+ AmrRegBit &= 0xfffffe07;
+ AmrRegBit |= 0x000000a8; /* 0x000000a8 loop dsp afe(loop i2s1)--arm i2s2(loop i2s2) 0x00000150 loop dsp arm(loop i2s1)--afe i2s2(loop i2s2)*/
+
+ ARM_I2S_LOOP_CFG = AmrRegBit;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_SetTopI2sConfig ARM_I2S_LOOP_CFG=0x%x\n", ARM_I2S_LOOP_CFG);
+}
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ /* inter loop */
+ AmrRegBit = ARM_I2S_LOOP_CFG;
+
+ AmrRegBit &= 0xfffffe07;
+ AmrRegBit |= 0x000000a8; /* 0x000000a8 loop dsp afe(loop i2s1)--arm i2s2(loop i2s2) 0x00000150 loop dsp arm(loop i2s1)--afe i2s2(loop i2s2)*/
+
+ ARM_I2S_LOOP_CFG = AmrRegBit;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_SetTopI2sConfig ARM_I2S_LOOP_CFG=0x%x\n", ARM_I2S_LOOP_CFG);
+
+#endif
+
#if 0
UINT32 AmrRegBit = 0;
int ret;
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/include/hal_voicebuffer.h b/cp/ps/driver/src/chipsets/src/audio_base/include/hal_voicebuffer.h
new file mode 100755
index 0000000..a9fbd34
--- /dev/null
+++ b/cp/ps/driver/src/chipsets/src/audio_base/include/hal_voicebuffer.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name: hal_voicebuffer.h
+ * File Mark:
+* Description: Provide voicebuffer hal function prototype declaration and type declaration.
+ * Others:
+ * Version: V0.5
+ * Author: xxq
+ * Date: 2024-07-11
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification: add mute/read/write/loopback.
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _HAL_VOICEBUFFER_H
+#define _HAL_VOICEBUFFER_H
+
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+
+
+/****************************************************************************
+* Macros
+****************************************************************************/
+#define VP_BUF_LENGTH 0x7FF80 //0xFFD80 //0x7FE40 //0x4df80// (0.5M 0x80000)
+#define VP_FRAME_BUFFER_SIZE 320 //20ms 800KHZ
+#define VP_I2S_BUFFER_SIZE 320
+#define VOICE_SYNC_TIMEOUT_TIME 100
+
+ //#define VP_INOUT_BAK_BUFFER_SIZE 0x30000 // 0x60000
+#define VP_INOUT_NOBAK_BUFSIZE 640
+#define VB_MAX_INT 0x7fffffff
+#define VB_MIN_INT 0 //(0-2<<31)//0x80000000
+
+#define VB_INT_OVERFLOW(x) if((x < VB_MIN_INT)||(x > VB_MAX_INT)) x = 0;
+
+#define RPMSG_CAP_ID 1
+
+#define MAX_BUF_SIZE 640
+#define MAX_BUF_NUM 3
+
+/****************************************************************************
+* Types
+****************************************************************************/
+
+
+
+enum{
+ UP_LINK,
+ DOWN_LINK
+};
+
+struct voice_ring_buffer {
+ volatile uint read_pos;
+ volatile uint write_pos;
+ volatile char data[];
+
+};
+
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+
+SINT32 vp_Open_Vbuffer(void);
+
+SINT32 vp_Close_Vbuffer(void);
+
+SINT32 vp_VoiceI2sStart_Vbuffer(VOID);
+
+VOID vp_VoiceI2sStop_Vbuffer(VOID);
+
+SINT32 zDrvVp_VoiceWorkStop_Vbuffer(VOID);
+
+SINT32 vp_VolteReadStart_Vbuffer(VOID);
+//whole replace
+SINT32 vp_VolteReadStop_Vbuffer(VOID);
+
+SINT32 vp_VolteWriteStart_Vbuffer(VOID);
+//whole replace
+SINT32 vp_VolteWriteStop_Vbuffer(VOID);
+
+SINT32 vp_WriteDataToCodec_Vbuffer(UINT8 *pBuf, UINT32 count);
+
+SINT32 vp_ReadDataFromCodec_Vbuffer(UINT8 *pBuf, UINT32 count);
+
+SINT32 vp_CreateThreadSemaph_Vbuffer(VOID);
+
+
+
+
+#endif/*_HAL_VOICEBUFFER_H*/
+
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/tdm/hal_tdm.c b/cp/ps/driver/src/chipsets/src/audio_base/tdm/hal_tdm.c
index 322aea4..50e28da 100644
--- a/cp/ps/driver/src/chipsets/src/audio_base/tdm/hal_tdm.c
+++ b/cp/ps/driver/src/chipsets/src/audio_base/tdm/hal_tdm.c
@@ -54,6 +54,7 @@
#define TDM_DRIVER_VERSION 1
//#define ARM_TDM_LOOP_SET *((volatile unsigned int *)(ZX_SOC_SYS_BASE + 0x60))
+#define ARM_TDM_LOOP_CFG *((volatile UINT32 *)(SOC_SYS_REG_BASE+0x60))
/* version register */
#define TDM_VERSION 0x0104 /*TDM Version V1.4*/
@@ -2415,7 +2416,12 @@
memset(temp, 0, sizeof(temp));
tdmDmaState[TDM_RX].channel = DMA_CH_TDM_RX0;
tdmDmaState[TDM_RX].ch = dma_request_channel(mask, zx29_dma_filter_fn, (void*)(tdmDmaState[TDM_RX].channel));
-
+ if(!tdmDmaState[TDM_RX].ch){
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: dma_request_channel fail, dma_id(%d).\n",__func__,tdmDmaState[TDM_RX].channel);
+ return DRV_ERR_BUSY;
+
+ }
for (i = 0; i < TDM_OUT_BUF_NUM; i++) {
temp[i].dest_addr = tdmDmaState[TDM_RX].dma_phyaddr + (tdmStream->rxLen) * i;
temp[i].src_addr = ZX29_TDM_PHYS + 0x24;
@@ -2484,6 +2490,12 @@
memset(temp, 0, sizeof(temp));
tdmDmaState[TDM_TX].channel = DMA_CH_TDM_TX0;
tdmDmaState[TDM_TX].ch = dma_request_channel(mask, zx29_dma_filter_fn, (void*)(tdmDmaState[TDM_TX].channel));
+ if(!tdmDmaState[TDM_TX].ch){
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"%s: dma_request_channel fail, dma_id(%d).\n",__func__,tdmDmaState[TDM_TX].channel);
+ return DRV_ERR_BUSY;
+
+ }
for (i = 0; i < TDM_OUT_BUF_NUM; i++) {
temp[i].src_addr = tdmDmaState[TDM_TX].dma_phyaddr + (txStream->txLen) * i;
@@ -2840,6 +2852,7 @@
SINT32 ret = DRV_SUCCESS;
ret = tdm_Reset();
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvTDM_Reset , ret=%d",ret);
return ret;
}
@@ -3751,6 +3764,21 @@
VOID vp_SetTopTdmConfig(VOID)
{
+ UINT32 AmrRegBit = 0;
+
+ /* inter loop */
+ AmrRegBit = ARM_TDM_LOOP_CFG;
+
+ AmrRegBit &= 0xfffffe07;
+ AmrRegBit |= 0x000000a8; /* 0x000000a8 loop dsp afe(loop i2s1)--arm i2s2(loop i2s2) 0x00000150 loop dsp arm(loop i2s1)--afe i2s2(loop i2s2)*/
+
+ ARM_TDM_LOOP_CFG = AmrRegBit;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_SetTopTDMConfig ARM_TDM_LOOP_CFG=0x%x\n", ARM_TDM_LOOP_CFG);
+
+
+
+
#if 0
UINT32 AmrRegBit = 0;
int ret = 0;
diff --git a/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voicebuffer.c b/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voicebuffer.c
new file mode 100755
index 0000000..8d0e5f7
--- /dev/null
+++ b/cp/ps/driver/src/chipsets/src/audio_base/voiceprocess/hal_voicebuffer.c
@@ -0,0 +1,1065 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:hal_voicebuffer.c
+ * File Mark:
+ * Description: voice buffer function.
+ * Others:
+ * Version:
+ * Author: xxq
+ * Date: 2024-07-03
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification: edit for union version
+ * History 2:
+ ********************************************************************************/
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_general.h"
+#include "drvs_volte.h"
+#include "drvs_i2s.h"
+#include "drvs_voiceprocess.h"
+#include "hal_voiceprocess.h"
+#include "drvs_voice_config.h"
+//#include "hal_pcmmixer.h"
+#include "NvParam_drv.h"
+#include "drvs_io_voice.h"
+#include "hal_ringdata.h"
+#include "drvs_tdm.h"
+#include "hal_dtmf_detect.h"
+#include "hal_audio_data.h"
+//#define TEST_WHITE_NOISE
+
+//#define VB_DATA_LOSS_TEST
+#ifdef TEST_WHITE_NOISE
+#include "Fs8000_WhiteNoise_Mon.h"
+//#include "Fs8000_Sine_440Hz_Mon.h"
+#endif
+
+#include "drvs_icp.h"
+#include "drvs_rpmsg.h"
+//#include <linux/completion.h>
+#include "hal_voicebuffer.h"
+
+/****************************************************************************
+* Local Macros
+****************************************************************************/
+//#define USE_AUDIO_RING
+//#define VP_GET_TX_ALL_DATA
+
+
+/****************************************************************************
+* Local Types
+****************************************************************************/
+
+
+/****************************************************************************
+* Local Constants
+****************************************************************************/
+static SINT32 vp_Get_Add_RpMsg_Vbuffer(VOID);
+
+/****************************************************************************
+* Local Function Prototypes
+****************************************************************************/
+
+/****************************************************************************
+* Global Constants
+****************************************************************************/
+
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+//static T_zDrvVp_SpeechState *s_pSpeechState = NULL;
+extern T_zDrvVp_SpeechState s_speechState; //104 bytes
+extern T_zDrvVoice_GbVar g_voiceVar;
+extern T_zDrvVp_State s_vpState;
+
+
+#ifdef ECALL_SUPPORT
+extern int eWrErr;
+extern UINT8 e_reg_flag;
+
+#endif
+
+//for test whiteNoise
+#ifdef TEST_WHITE_NOISE
+extern UINT32 tempCount;
+extern UINT8 *pVoiceTempBuf;
+#endif
+
+
+extern T_ZDrv_VpInOutBuffer vpInOutBuffer;
+
+extern T_HalMixerToneInfo mixerToneInfo;
+
+static int vbuffer_init_flag = 0;
+
+/****************************************************************************
+* Global Function Prototypes
+****************************************************************************/
+//aduvoice config code
+
+
+
+
+
+
+extern SINT32 voice_ToneMixerData(UINT8 *pvdata, UINT32 size, UINT8 *pmixdata);//xiu gai chu sheng ming
+extern SINT32 zDrvI2S_Read_Start(T_ZDrvI2S_Id tId, T_ZDrvI2s_Params *params, T_ZDrvI2S_Cfg *ptCfg);//xiu gai chu sheng ming
+extern SINT32 zDrvI2S_Write_Start(T_ZDrvI2S_Id tId, T_ZDrvI2s_Params *params, T_ZDrvI2S_Cfg *ptCfg);//xiu gai chu sheng ming
+
+
+
+/****************************************************************************
+* Function Definitions
+****************************************************************************/
+ZOSS_TIMER_ID s_voiceTimerId ;
+ZOSS_SEMAPHORE_ID s_voiceRdSema;
+ZOSS_SEMAPHORE_ID s_voiceWrSema;
+
+//#ifdef CONFIG_VOICE_BUFFER_DRV
+//#ifdef _VBUFF_IN_MULTI_CORE
+//voice buffer use in multi core
+//#define RPMSG_CAP_ID 1
+
+
+
+int timer_cb_count = 0;
+int first_full_flag = 0;
+int first_empty_flag = 0;
+
+int vb_read_count = 0;
+int vb_write_count = 0;
+
+
+
+struct voice_ring_buffer *voice_buff[2] = {NULL,NULL};
+
+
+
+static bool voice_buff_is_full(int read_pos, int write_pos)
+{
+
+
+ if ((write_pos - read_pos) >= 20000000) {
+ write_pos = write_pos - 20000000;
+ //voice_buff[UP_LINK]->write_pos = write_pos;
+ voice_buff[DOWN_LINK]->write_pos = write_pos;
+ }
+ return ((write_pos - read_pos) == MAX_BUF_NUM);
+}
+static bool voice_buff_is_empty(int read_pos, int write_pos)
+{
+
+ return (write_pos == read_pos);
+}
+static int voice_buffer_write( char *buf, int count)
+{
+ int read_pos, write_pos;
+
+
+ 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",__FUNCTION__,read_pos,write_pos);
+ }
+
+
+ if(voice_buff_is_full(read_pos, write_pos)){
+ //zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice_buffer_read readbuffer is full \n");
+ 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",__FUNCTION__,read_pos,write_pos,vb_write_count,count);
+ return DRV_ERROR_FULL;
+ }
+ else {
+ vb_write_count++;
+
+ VB_INT_OVERFLOW(vb_write_count);
+ first_full_flag = 0;
+ zOss_Memcpy(&(voice_buff[DOWN_LINK]->data[(write_pos%MAX_BUF_NUM)*MAX_BUF_SIZE]), buf, count);
+
+ write_pos++;
+
+ voice_buff[DOWN_LINK]->write_pos = write_pos;
+
+ }
+
+ return DRV_SUCCESS;
+}
+static int voice_buffer_read(char *buf, size_t count)
+{
+ int read_pos, write_pos;
+ int* buf_int;
+ int i;
+
+ 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",__FUNCTION__,read_pos,write_pos);
+ }
+
+ if ((count > 0) && (count <= MAX_BUF_SIZE)) {
+ if(voice_buff_is_empty(read_pos, write_pos)){
+ 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",__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
+ zOss_Memset(&(voice_buff[UP_LINK]->data[(read_pos%MAX_BUF_NUM)*MAX_BUF_SIZE]),0, count);
+ zOss_Memset(buf,0, count);
+ #endif
+ //return DRV_ERROR_EMPTY;
+
+
+ }
+ else {
+
+ vb_read_count++;
+ VB_INT_OVERFLOW(vb_read_count);
+ first_empty_flag = 0;
+
+ zOss_Memcpy(buf, &(voice_buff[UP_LINK]->data[(read_pos%MAX_BUF_NUM)*MAX_BUF_SIZE]), count);
+ //zOss_Memset(&(voice_buff[UP_LINK]->data[(read_pos%MAX_BUF_NUM)*MAX_BUF_SIZE]),0, count);
+
+#ifdef VB_DATA_LOSS_TEST
+
+
+ if(vb_read_count < 5){
+ pr_info("ps :count=%d vb_read_count=%d,read_pos=%d,write_pos=%d\n",count,vb_read_count,read_pos,write_pos);
+
+
+ buf_int =( int*) &voice_buff[UP_LINK]->data[(write_pos%MAX_BUF_NUM)*MAX_BUF_SIZE];
+
+ for(i=0;i<(count/4);i++){
+ //*(buf_int+i) = i;
+ //buf_int[i] = i;
+ if(i>0x1f)
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO,"ps: *(buf_int+%d)=%d\n",i,*(buf_int+i));
+ }
+
+ }
+#endif
+ read_pos++;
+ if(read_pos == 20000000)
+ read_pos = 0;
+ voice_buff[UP_LINK]->read_pos = read_pos;
+ }
+
+
+ }
+
+
+ return DRV_SUCCESS;
+}
+
+
+//voice buffer use in single core
+extern int voicebuffer_ulqueue_read(void *buf, unsigned int size);
+extern int voicebuffer_dlqueue_write(void *buf, unsigned int size);
+extern void voice_inform_to_app(void);
+//static DECLARE_COMPLETION(s_voice_completion);
+//ZOSS_TIMER_ID s_voiceTimerId ;
+//ZOSS_SEMAPHORE_ID s_voiceRdSema;
+//ZOSS_SEMAPHORE_ID s_voiceWrSema;
+static void voiceTimerCallBack(SINT32 para)
+{
+
+
+ if (g_voiceVar.voiceBufferType == 1)//multi core
+ {
+
+
+ T_ZDrvRpMsg_Msg icp_pMsg = {0};
+
+ UINT8 s = 1;
+ icp_pMsg.actorID = RPMSG_CAP_ID;
+
+ icp_pMsg.chID = channel_41;
+ icp_pMsg.flag |= RPMSG_WRITE_INT;
+ icp_pMsg.buf = (void *)&s;
+ icp_pMsg.len = 1;
+
+
+ zOss_PutSemaphore(s_voiceWrSema);
+ zOss_PutSemaphore(s_voiceRdSema);
+ //zDrvRpMsg_Write(&icp_pMsg);
+#ifdef _USE_VEHICLE_DC
+ zDrvRpMsg_Write_Cap(&icp_pMsg);
+#endif
+ timer_cb_count++;
+ VB_INT_OVERFLOW(timer_cb_count);
+#ifdef VB_DATA_LOSS_TEST
+
+ if((timer_cb_count%1000 ) == 0){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:timer_cb_count(%d)\n",__FUNCTION__,timer_cb_count);
+ if(timer_cb_count> 10000000)
+ timer_cb_count=0;
+ }
+
+#endif
+
+
+ }
+ else{
+
+
+
+ // complete_all(&s_voice_completion);
+ zOss_PutSemaphore(s_voiceWrSema);
+ zOss_PutSemaphore(s_voiceRdSema);
+ voice_inform_to_app();
+ // zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voiceTimerCallBack timer=%u\n", cpu_clock(0)>>10);
+ }
+
+
+}
+
+
+
+
+
+static SINT32 vp_rxsem_count_Init(void)
+{
+ UINT32 i = 0;
+ UINT32 semCount = 0;
+ SINT32 Count = 0;
+
+ semCount = zOss_GetSemaphoreCount(s_voiceRdSema);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_rxsem_count_Init rxSem count=%d\n", semCount);
+
+ Count = semCount;
+ if(Count > 0) {
+ for(i = 0; i < Count; i++) {
+ zOss_GetSemaphore(s_voiceRdSema, ZOSS_NO_WAIT);
+ }
+ }
+
+ return DRV_SUCCESS;
+}
+
+static SINT32 vp_txsem_count_Init(void)
+{
+ UINT32 i = 0;
+ UINT32 semCount = 0;
+ SINT32 Count = 0;
+
+ semCount = zOss_GetSemaphoreCount(s_voiceWrSema);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_txsem_count_Init txSem count=%d \n", semCount);
+
+ Count = 3 - semCount;
+ if(Count > 0) {
+ for(i = 0; i < Count; i++) {
+ zOss_PutSemaphore(s_voiceWrSema);
+ }
+ } else if(Count < 0) {
+ Count = 0 - Count;
+ for(i = 0; i < Count; i++) {
+ zOss_GetSemaphore(s_voiceWrSema, ZOSS_NO_WAIT);
+ }
+ }
+
+ return DRV_SUCCESS;
+}
+
+
+
+
+
+SINT32 vp_Open_Vbuffer(void)
+{
+ SINT32 ret = DRV_SUCCESS;
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: start \n", __func__);
+ if (g_voiceVar.voiceBufferType == 1)//multi core
+ {
+ vp_Get_Add_RpMsg_Vbuffer();
+
+ vp_rxsem_count_Init();
+ vp_txsem_count_Init();
+ voice_buff[UP_LINK]->read_pos = 0;
+ voice_buff[UP_LINK]->write_pos = 0;
+ voice_buff[DOWN_LINK]->read_pos = 0;
+ voice_buff[DOWN_LINK]->write_pos = 0;
+ zOss_Memset(&(voice_buff[DOWN_LINK]->data[0]),0, MAX_BUF_NUM*MAX_BUF_SIZE);
+ zOss_Memset(&(voice_buff[UP_LINK]->data[0]),0, MAX_BUF_NUM*MAX_BUF_SIZE);
+ //for debug
+ timer_cb_count = 0;
+ first_full_flag = 0;
+ first_empty_flag = 0;
+
+ vb_read_count = 0;
+ vb_write_count = 0;
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Open_Vbuffer init voice buffer val!\n");
+
+
+ }else{
+
+ // INIT_COMPLETION(s_voice_copletion);
+ vp_rxsem_count_Init();
+ vp_txsem_count_Init();
+ }
+
+ return DRV_SUCCESS;
+
+}
+
+
+SINT32 vp_Close_Vbuffer(void)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ if (g_voiceVar.voiceBufferType == 1)//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",__FUNCTION__,timer_cb_count,first_full_flag,first_empty_flag,vb_read_count,vb_write_count);
+ }
+
+ return DRV_SUCCESS;
+}
+
+SINT32 vp_VoiceI2sStart_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ UINT8 *read_buf = NULL;
+ UINT8 *write_buf = NULL;
+ UINT32 read_len = 0;
+ UINT32 write_len = 0;
+
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: start.\n",__func__);
+
+
+ ret = zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer failed ret is %d .\n", ret);
+ return DRV_ERROR;
+ }
+
+ zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
+
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer VB zOss_StartTimer\n");
+
+ ret = zDrvI2S_Write_Start(I2S_2, &s_speechState.i2sWriteParam, s_vpState.pVpInnerI2sCfg);
+
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer error7:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer error12:zDrvI2S_Write I2S_2 ret=%d", ret);
+ }
+
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer error13:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart_Vbuffer error14:zDrvI2S_Write I2S_2 ret=%d", ret);
+ }
+
+ if (g_voiceVar.voiceBufferType == 1)//multi core
+ {
+
+ voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+
+ }else{
+ voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: end.\n",__func__);
+ return ret;
+}
+VOID vp_VoiceI2sStop_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+ return ret;
+}
+
+
+
+SINT32 zDrvVp_VoiceWorkStop_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ //complete_all(&s_voice_completion);
+ zOss_PutSemaphore(s_voiceRdSema);
+ zOss_PutSemaphore(s_voiceWrSema);
+ zOss_StopTimer(s_voiceTimerId);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: zOss_StopTimer\n",__func__);
+
+
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: success",__func__);
+ return DRV_SUCCESS;
+}
+
+
+SINT32 vp_VolteReadStart_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStart_Vbuffer start\n");
+
+ zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStart_Vbuffer zOss_StartTimer start\n");
+
+ return DRV_SUCCESS;
+}
+//whole replace
+SINT32 vp_VolteReadStop_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ zOss_PutSemaphore(s_voiceRdSema);
+
+ }
+ else
+ {
+
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ zOss_PutSemaphore(s_voiceRdSema);
+#else
+
+ //zDrvI2s_RxRlsSemaBeforeStop(I2S_1);
+ zDrvExtAudio_RxRlsSemaBeforeStop();
+
+#if 0//move to close lvwenhua 20150910
+ ret = zDrvExtAudio_Read_Stop();
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVolte_ReadStop I2S1 Stop wrong ret=%d", ret);
+ }
+#endif
+#endif
+
+ }
+
+ if (s_speechState.volteVpCfgEnFlag == 1)
+ {
+ ret = halVpCfg_Disable();
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: halVpCfg_Enable err ret=%x !\n",__func__, ret);
+ }
+ else
+ {
+ s_speechState.volteVpCfgEnFlag = 0;
+ }
+ }
+
+ s_speechState.volteVpReadStopFlag = 1;//together control vp s_speechState
+ if ((s_speechState.volteVpWriteStopFlag == 1) && (s_speechState.volteVpReadStopFlag == 1))
+ {
+ g_voiceVar.vpI2sStatus = VP_I2S_OPEN;
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ zOss_StopTimer(s_voiceTimerId);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: zOss_StopTimer\n",__func__);
+
+ }
+ else
+ {
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ zOss_StopTimer(s_voiceTimerId);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStop_Vbuffer zOss_StopTimer\n");
+#endif
+ }
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: end\n",__func__);
+ return ret;
+}
+
+SINT32 vp_VolteWriteStart_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+
+ //???? for check
+ if (g_voiceVar.voiceBufferType == 1)//multi core
+ {
+ voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+ else
+ {
+ voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:end \n",__func__);
+
+ return ret;
+}
+//whole replace
+SINT32 vp_VolteWriteStop_Vbuffer(VOID)
+{
+ SINT32 ret = DRV_SUCCESS;
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ zOss_PutSemaphore(s_voiceWrSema);
+
+ }
+ else
+ {
+
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ //complete_all(&s_voice_completion);
+ zOss_PutSemaphore(s_voiceWrSema);
+#else
+ //zDrvI2s_TxRlsSemaBeforeStop(I2S_1);
+ zDrvExtAudio_TxRlsSemaBeforeStop();
+#endif
+ }
+#if 0//move to close lvwenhua 20150910
+ //wait for write drain semaphore
+#ifdef VOICE_TONE_MIXER_FUNCTION
+ voice_ToneMixerStop();
+#endif
+
+ ret = zDrvExtAudio_Write_Stop();
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVolte_WriteStop I2S1 Stop wrong ret=%d", ret);
+ }
+
+ //s_VolteWriteSema = 0;
+#endif
+
+ if (s_speechState.volteVpCfgEnFlag == 1)
+ {
+ ret = halVpCfg_Disable();
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStop_Vbuffer halVpCfg_Enable err ret=%x !\n", ret);
+ }
+ else
+ {
+ s_speechState.volteVpCfgEnFlag = 0;
+ }
+ }
+
+ s_speechState.volteVpWriteStopFlag = 1;//together control vp s_speechState
+ if ((s_speechState.volteVpWriteStopFlag == 1) && (s_speechState.volteVpReadStopFlag == 1))
+ {
+ g_voiceVar.vpI2sStatus = VP_I2S_OPEN;
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+
+ zOss_StopTimer(s_voiceTimerId);
+
+ }
+ else
+ {
+
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ zOss_StopTimer(s_voiceTimerId);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStop_Vbuffer zOss_StopTimer\n");
+#endif
+ }
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStop_Vbuffer \n");
+ return ret;
+}
+
+
+/*******************************************************************************
+ * For union version
+ * Others:
+ ********************************************************************************/
+SINT32 vp_WriteDataToCodec_Vbuffer(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;
+#ifdef TEST_WHITE_NOISE
+ // UINT32 tempCount = 0;
+ //zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "test the white noise");
+ //UINT8 *pVoiceTempBuf = s_voiceTempBuffer;
+#endif
+
+
+
+ if (pBuf == NULL)
+ {
+ return DRV_ERR_INVALID_PARAM;
+ }
+
+ if (count != s_speechState.i2sWriteParam.buffersize)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_WriteDataToCodec_Vbuffer write data length err,count=%d,writebuffersize=%d \n", count, s_speechState.i2sWriteParam.buffersize);
+ return DRV_ERR_INVALID_PARAM;
+ }
+ #ifdef ECALL_SUPPORT
+
+ if(e_reg_flag == 1)
+ {
+ e_ret = update_ecall_state(DIR_RX);
+ if (e_ret == DRV_ERR_NOT_SUPPORTED)
+ {
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "vp_WriteDataToCodec_Vbuffer get__ecall_state fun not register or invalid para,e_ret=%d !\n",e_ret);
+
+ }
+ }
+ #endif
+
+
+
+ #ifdef TEST_WHITE_NOISE
+
+ 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_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))
+ {
+ voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 640, s_speechState.pVpTempRxInBuffer);
+ }
+ else
+ {
+ voice_ToneMixerData(s_speechState.pVpTempRxInBuffer, 320, s_speechState.pVpTempRxInBuffer);
+ }
+
+ }
+
+ #endif
+ if (pBuf != s_speechState.pVpTempRxInBuffer)
+ {
+ zOss_Memcpy(s_speechState.pVpTempRxInBuffer, pBuf, s_speechState.totalFrameBufSize);
+ }
+
+ if (g_voiceVar.vProcIsNormal == TRUE)
+ {
+ VoiceProc_RxProcess(& s_speechState.pVpTempRxInBuffer, & s_speechState.pVpTempRxOutPutBuffer, s_speechState.frameCount);
+ }
+ else
+ {
+ zOss_Memcpy((VOID *)(s_speechState.pVpTempRxOutPutBuffer), (VOID *) s_speechState.pVpTempRxInBuffer, s_speechState.totalFrameBufSize);
+ }
+ //wait_for_completion_timeout(&s_voice_completion, 60);
+ zOss_GetSemaphore(s_voiceWrSema, 60);
+ //#ifdef _VBUFF_IN_MULTI_CORE
+ if (g_voiceVar.voiceBufferType == 1)
+ {
+ voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+ else
+ {
+ voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+ if (g_voiceVar.voiceInVolteMode == 1)
+ {
+ s_speechState.rxSaveLen += s_speechState.totalFrameBufSize;
+ if (s_speechState.rxSaveLen >= s_speechState.inOutBufUseSize)
+ {
+ s_speechState.rxSaveLen = 0;
+ }
+ s_speechState.pVpTempRxInBuffer = s_vpState.pVpRxInBuffer + s_speechState.rxSaveLen;
+ #ifdef _USE_VP_OUTPUT_RXOUT_DATA
+ s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer + s_speechState.rxSaveLen;
+ #else
+ s_speechState.pVpTempRxOutPutBuffer = s_vpState.pVpRxOutPutBuffer;
+ #endif
+ }
+
+
+ if (s_speechState.firstWriteDataFlag == FALSE)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_WriteDataToCodec_Vbuffer first write ret=%d,tick=%d.\n", ret, zOss_GetTickCount());
+ s_speechState.firstWriteDataFlag = TRUE;
+ }
+
+ return ret;
+}
+
+
+
+SINT32 vp_ReadDataFromCodec_Vbuffer(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
+
+ if (pBuf == NULL)
+ {
+ return DRV_ERR_INVALID_PARAM;
+ }
+
+ if (count != s_speechState.i2sReadParam.buffersize)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: read data length err,count=%d,readbuffersize=%d \n",__func__, count, s_speechState.i2sReadParam.buffersize);
+ return DRV_ERR_INVALID_PARAM;
+ }
+#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_ReadDataFromCodecvp_ReadDataFromCodec get__ecall_state fun not register,ret=%d !\n",ret);
+
+ }
+ }
+#endif
+
+
+// wait_for_completion_timeout(&s_voice_completion, 60);
+ zOss_GetSemaphore(s_voiceRdSema, 60);
+ if (g_voiceVar.voiceBufferType == 1)
+ {
+ voice_buffer_read(s_speechState.pVpTempTxInBuffer, s_speechState.totalFrameBufSize);
+
+ }
+ else
+ {
+ voicebuffer_ulqueue_read(s_speechState.pVpTempTxInBuffer, s_speechState.totalFrameBufSize);
+ }
+ if (g_voiceVar.vProcIsNormal == TRUE)
+ {
+ VoiceProc_TxProcess(&s_speechState.pVpTempTxInBuffer, NULL, &s_speechState.pVpTempTxOutPutBuffer, s_speechState.frameCount);
+ }
+ else
+ {
+ zOss_Memcpy((VOID *)(s_speechState.pVpTempTxOutPutBuffer), (VOID *) s_speechState.pVpTempTxInBuffer, s_speechState.totalFrameBufSize);
+ }
+
+ if (pBuf != s_speechState.pVpTempTxOutPutBuffer)
+ {
+ zOss_Memcpy(pBuf, s_speechState.pVpTempTxOutPutBuffer, s_speechState.totalFrameBufSize);
+ }
+
+ if (g_voiceVar.voiceInVolteMode == 1)
+ {
+ // s_speechState.txSaveLen += VP_FRAME_BUFFER_SIZE;
+ s_speechState.txSaveLen += s_speechState.totalFrameBufSize;
+ if (s_speechState.txSaveLen >= s_speechState.inOutBufUseSize)
+ {
+ s_speechState.txSaveLen = 0;
+ }
+ s_speechState.pVpTempTxInBuffer = s_vpState.pVpTxInBuffer + s_speechState.txSaveLen;
+ s_speechState.pVpTempTxOutPutBuffer = s_vpState.pVpTxOutPutBuffer + s_speechState.txSaveLen;
+ }
+
+
+ if (s_speechState.firstReadDataFlag == FALSE)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_ReadDataFromCodec first read tick=%d.\n", zOss_GetTickCount());
+ s_speechState.firstReadDataFlag = TRUE;
+ }
+
+ return ret;
+}
+
+
+
+
+SINT32 vp_CreateThreadSemaph_Vbuffer(VOID)
+{
+ SINT32 ret = 0;
+//#ifdef CONFIG_VOICE_BUFFER_DRV
+// init_completion(&s_voice_completion);
+ /*
+ if(vbuffer_init_flag == 1){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vbuffer already init,return! \n");
+ return DRV_SUCCESS;
+
+ }
+ */
+ s_voiceRdSema = zOss_CreateSemaphore("voice_rx_sem", 0);
+ if(NULL == s_voiceRdSema) {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create voice_rx_sem err \n");
+ return DRV_ERROR;
+ }
+
+ s_voiceWrSema = zOss_CreateSemaphore("voice_tx_sem", 0);
+ if(NULL == s_voiceWrSema) {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create voice_tx_sem err \n");
+ return DRV_ERROR;
+ }
+
+
+
+ s_voiceTimerId = zOss_CreateTimer("voice_frameTimer", voiceTimerCallBack, 0, TRUE);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "s_voiceTimerId=%p\n", s_voiceTimerId);
+ if(!s_voiceTimerId)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice_frameTimer failed\n");
+ return DRV_ERROR;
+ }
+
+
+
+
+ //ret = zDrvRpMsg_CreateChannel(IPC_MSG_ACTOR_A9,channel_41,0x10);
+#ifdef _USE_VEHICLE_DC
+ ret = zDrvRpMsg_CreateChannel_Cap(RPMSG_CAP_ID,channel_41,0x10);
+
+ if(DRV_SUCCESS != ret) {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create rpmsg err(%d) \n",ret);
+ return DRV_ERROR;
+ }
+/*
+ volatile T_ZDrvRpMsg_Msg icp_pMsg = {0};
+ volatile unsigned int rpMsgBuf[2] = {0,0};
+ //printk( "vir_buf1:0x%x, vir_buf2:0x%x, phy_buf1:0x%x, phy_buf2:0x%x,\n",voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1]);
+ icp_pMsg.actorID = RPMSG_CAP_ID;
+ icp_pMsg.chID = channel_41;
+ icp_pMsg.flag &= ~RPMSG_READ_POLL;
+ icp_pMsg.buf = rpMsgBuf;
+ icp_pMsg.len = 8;
+
+
+ ret = zDrvRpMsg_Read_Cap(&icp_pMsg);
+ if(ret <= 0){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer rpmsg addr read fail,ret=%d \n",ret);
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps voice buffer rpmsg addr read fail,ret=%d \n",ret);
+
+
+ }
+ else{
+ #if 0
+
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[0]);
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[1]);
+ #else
+
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[0], (sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ #endif
+
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps rpmsg voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ }
+*/
+
+
+#endif
+ //vbuffer_init_flag = 1;
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_CreateThreadSemaph success. \r\n");
+ return DRV_SUCCESS;
+}
+
+
+
+
+static SINT32 vp_Get_Add_RpMsg_Vbuffer(VOID)
+{
+ SINT32 ret = 0;
+//#ifdef CONFIG_VOICE_BUFFER_DRV
+// init_completion(&s_voice_completion);
+
+ if(vbuffer_init_flag == 1){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vbuffer already init,return! \n");
+ return DRV_SUCCESS;
+
+ }
+
+ //ret = zDrvRpMsg_CreateChannel(IPC_MSG_ACTOR_A9,channel_41,0x10);
+#ifdef _USE_VEHICLE_DC
+
+ volatile T_ZDrvRpMsg_Msg icp_pMsg = {0};
+ volatile unsigned int rpMsgBuf[2] = {0,0};
+ //printk( "vir_buf1:0x%x, vir_buf2:0x%x, phy_buf1:0x%x, phy_buf2:0x%x,\n",voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1]);
+ icp_pMsg.actorID = RPMSG_CAP_ID;
+ icp_pMsg.chID = channel_41;
+ icp_pMsg.flag &= ~RPMSG_READ_POLL;
+ icp_pMsg.buf = rpMsgBuf;
+ icp_pMsg.len = 8;
+
+
+ ret = zDrvRpMsg_Read_Cap(&icp_pMsg);
+ if(ret <= 0){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer rpmsg addr read fail,ret=%d \n",ret);
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps voice buffer rpmsg addr read fail,ret=%d \n",ret);
+
+
+ }
+ else{
+ #if 0
+
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[0]);
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[1]);
+ #else
+
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[0], (sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ #endif
+
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps rpmsg voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+
+ vbuffer_init_flag = 1;
+
+ }
+
+
+
+#endif
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: success. \r\n",__func__);
+ return DRV_SUCCESS;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 f34d0b7..3296dad 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
@@ -34,9 +34,7 @@
#include "drvs_tdm.h"
#include "hal_dtmf_detect.h"
#include "hal_audio_data.h"
-//#define TEST_WHITE_NOISE
-//#define VB_DATA_LOSS_TEST
#ifdef TEST_WHITE_NOISE
#include "Fs8000_WhiteNoise_Mon.h"
//#include "Fs8000_Sine_440Hz_Mon.h"
@@ -45,40 +43,19 @@
#include "drvs_icp.h"
#include "drvs_rpmsg.h"
//#include <linux/completion.h>
+
+#include "hal_voicebuffer.h"
+
/****************************************************************************
* Local Macros
****************************************************************************/
//#define USE_AUDIO_RING
//#define VP_GET_TX_ALL_DATA
-#define VP_BUF_LENGTH 0x7FF80 //0xFFD80 //0x7FE40 //0x4df80// (0.5M 0x80000)
-#define VP_FRAME_BUFFER_SIZE 320 //20ms 800KHZ
-#define VP_I2S_BUFFER_SIZE 320
-#define VOICE_SYNC_TIMEOUT_TIME 100
-
-#define VP_INOUT_BAK_BUFFER_SIZE 0x30000 // 0x60000
-#define VP_INOUT_NOBAK_BUFSIZE 640
-#define VB_MAX_INT 0x7fffffff
-#define VB_MIN_INT 0 //(0-2<<31)//0x80000000
-
-#define VB_INT_OVERFLOW(x) if((x < VB_MIN_INT)||(x > VB_MAX_INT)) x = 0;
/****************************************************************************
* Local Types
****************************************************************************/
- typedef enum
- {
- VBUF_SEM = 0,//voice buffer
- ECALL_SEM,
- SEM_MAX
- } T_Sem_Owner;
- typedef enum
- {
- DIR_RX,
- DIR_TX,
- DIR_ALL,
- DIR_MAX
- } T_Data_Dir_Type;
/****************************************************************************
* Local Constants
@@ -104,7 +81,46 @@
* Global Variables
****************************************************************************/
//static T_zDrvVp_SpeechState *s_pSpeechState = NULL;
+#if 0
static T_zDrvVp_SpeechState s_speechState = {0}; //104 bytes
+#else
+T_zDrvVp_SpeechState s_speechState = {
+ //use for vp data process
+ .pVpTempRxInBuffer = NULL,
+ .pVpTempTxInBuffer = NULL,
+ .pVpTempRxOutPutBuffer = NULL,
+ .pVpTempTxOutPutBuffer = NULL,
+
+ .pVpI2sCfg = NULL,
+
+ .vpCfgParam = {0},
+
+ .i2sWriteParam = {0},
+ .i2sReadParam = {0},
+
+ .frameCount = 0,
+ .totalFrameBufSize = 0,
+ .inOutBufUseSize = 0,
+ .rxSaveLen = 0,
+ .txSaveLen = 0,
+ .saveLen = 0,
+
+ .pcmSlotNum = 0,
+ .pcmWbSecDataPosition = 0,
+
+ .volteVpWriteStopFlag = 0,
+ .volteVpReadStopFlag = 0,
+ . volteVpCfgEnFlag = 0,
+ .firstWriteDataFlag = FALSE,
+ .firstReadDataFlag = FALSE,
+ .i2sIsRstFlag = FALSE,
+
+};
+
+
+#endif
+
+#if 0
T_zDrvVoice_GbVar g_voiceVar =
{
@@ -138,32 +154,104 @@
#endif
0 //27 voice_nv_update
};
+#else
+T_zDrvVoice_GbVar g_voiceVar =
+{
+ .volteIsWb = 0, //volteIsWb
+ .isUseSlicCodec = 0, //isUseSlicCodec
+ .g_isUseTdm = 0, //g_isUseTdm
+ .voiceInGsmTdMode = 0, //voiceInGsmTdMode
+ .voiceInVolteMode = 0, //voiceInVolteMode
+ .innerI2sIsMaster = FALSE, //innerI2sIsMaster
+ .innerI2sIsI2sMode = TRUE, //innerI2sIsI2sMode
+ .vpLoopRuning = FALSE, //vpLoopRunning
+ .muteEn = FALSE, //muteEn
+ .vProcIsNormal = FALSE, //vProcIsNormal
+ .vpI2sStatus = VP_I2S_IDLE, //vpI2sStatus
+ .vpPath = VP_PATH_HANDSET, //vpPath
+ .vpLoopPath = VP_PATH_HANDSET, //vpLoopPath
+ .vpVol = VP_VOL_3, //vpVol
+ .voiceMode = MAX_VOICE_MODE, //voiceMode
+ .vpInitGain = -1, //vpInitGain
+ .audio_ctrlFlag = {0}, //audio_ctrlFlag
+
+ .dtmfDirSel = DTMF_IDLE, //dtmfDirSel
+ .sample_rate = 0, //sample_rate
+ .useDtmfLoop = 0, //useDtmfLoop
+ .muteCount = 0, //muteCount
+ .vpLoopBkRunning = FALSE, //vpLoopBkRunning
+ .rxMuteEn = FALSE, //rxMuteEn
+ .firstRegZCATFlag = FALSE,
+#ifdef ECALL_SUPPORT
+ .ecallData = {0}, //ecallData
+#endif
+ .voice_nv_update = 0, // voice_nv_update
+ .useVoiceBuffer = 0,// 0 not use,1 use
+ .voiceBufferType = 0, //0 single core, 1 dual core
+
+};
+
+#endif
+
+#if 0
+
static T_zDrvVp_State s_vpState =
{
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- {0},
- {0},
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
+ NULL,//1 pVpRxInBuffer
+ NULL,//2 pVpTxInBuffer
+ NULL,//3 pVpRxOutPutBuffer
+ NULL,//4 pVpTxOutPutBuffer
+ 0,//5 inOutBufSize
+ NULL,//6 pVpInnerI2sCfg
+ NULL,//7 pVpExtI2sCfg
+ NULL,//8 pVpExtI2sWbCfg
+ NULL,//9 s_pVpTdmCfg
+ NULL,//10 s_pVpTdmWbCfg
+ NULL,//11 pVpTdmCfg
+ {0},//12 pMsg
+ {0},//13 pMsgBuf[2]
+ //0,//14
+ NULL,//15 vpThread
+ NULL,//16 rcvDtmfThread
+ NULL,//17 vpSemaphore
+ NULL,//18 vpThreadQuitSema
+ NULL,//19 vpLoopThread
+ NULL,//20 vpLoopSemaphore
+ NULL//21 vpState
// {0}
};
+#else
+T_zDrvVp_State s_vpState =
+{
+ .pVpRxInBuffer = NULL,//1
+ .pVpTxInBuffer = NULL,//2
+ .pVpRxOutPutBuffer = NULL,//3
+ .pVpTxOutPutBuffer = NULL,//4
+ .inOutBufSize = 0,//5
+ .pVpInnerI2sCfg = NULL,//6
+ .pVpExtI2sCfg = NULL,//7
+ .pVpExtI2sWbCfg = NULL,//8
+ .s_pVpTdmCfg = NULL,//9
+ .s_pVpTdmWbCfg = NULL,//10
+ .pVpTdmCfg = NULL,//11
+ .pMsg = {0},//12
+ .pMsgBuf = {0},//13
+ .vpThread = NULL,//14
+ .rcvDtmfThread = NULL,//15
+ .vpSemaphore = NULL,//16
+ .vpThreadQuitSema = NULL,//17
+ .vpLoopThread = NULL,//18
+ .vpLoopSemaphore = NULL,//19
+
+ .vpState = NULL,//
+// {0}
+};
+
+
+#endif
+
+
//for test whiteNoise
#ifdef TEST_WHITE_NOISE
@@ -271,8 +359,8 @@
****************************************************************************/
#ifdef CONFIG_VOICE_BUFFER_DRV
#ifdef _VBUFF_IN_MULTI_CORE
-#define RPMSG_CAP_ID 1
-
+//#define RPMSG_CAP_ID 1
+#if 0
ZOSS_TIMER_ID s_voiceTimerId ;
ZOSS_SEMAPHORE_ID s_voiceRdSema;
ZOSS_SEMAPHORE_ID s_voiceWrSema;
@@ -283,9 +371,22 @@
int vb_read_count = 0;
int vb_write_count = 0;
+#else
+//define in hal_voicebuffer.c
+extern ZOSS_TIMER_ID s_voiceTimerId ;
+extern ZOSS_SEMAPHORE_ID s_voiceRdSema;
+extern ZOSS_SEMAPHORE_ID s_voiceWrSema;
+extern int timer_cb_count;
+extern int first_full_flag;
+extern int first_empty_flag;
-void voiceTimerCallBack(SINT32 para)
+extern int vb_read_count;
+extern int vb_write_count;
+
+#endif
+
+static void voiceTimerCallBack(SINT32 para)
{
T_ZDrvRpMsg_Msg icp_pMsg = {0};
@@ -316,22 +417,8 @@
// zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voiceTimerCallBack timer=%u\n", cpu_clock(0)>>10);
}
-#define MAX_BUF_SIZE 640
-#define MAX_BUF_NUM 3
-
-enum{
- UP_LINK,
- DOWN_LINK
-};
-
-struct voice_ring_buffer {
- volatile uint read_pos;
- volatile uint write_pos;
- volatile char data[];
-
-};
-struct voice_ring_buffer *voice_buff[2] = {NULL,NULL};
+extern struct voice_ring_buffer *voice_buff[2];
@@ -460,10 +547,10 @@
extern int voicebuffer_dlqueue_write(void *buf, unsigned int size);
extern void voice_inform_to_app(void);
//static DECLARE_COMPLETION(s_voice_completion);
-ZOSS_TIMER_ID s_voiceTimerId ;
-ZOSS_SEMAPHORE_ID s_voiceRdSema;
-ZOSS_SEMAPHORE_ID s_voiceWrSema;
-void voiceTimerCallBack(SINT32 para)
+extern ZOSS_TIMER_ID s_voiceTimerId ;
+extern ZOSS_SEMAPHORE_ID s_voiceRdSema;
+extern ZOSS_SEMAPHORE_ID s_voiceWrSema;
+static void voiceTimerCallBack(SINT32 para)
{
// complete_all(&s_voice_completion);
zOss_PutSemaphore(s_voiceWrSema);
@@ -476,7 +563,7 @@
#endif
-SINT32 vp_rxsem_count_Init(void)
+static SINT32 vp_rxsem_count_Init(void)
{
UINT32 i = 0;
UINT32 semCount = 0;
@@ -495,7 +582,7 @@
return DRV_SUCCESS;
}
-SINT32 vp_txsem_count_Init(void)
+static SINT32 vp_txsem_count_Init(void)
{
UINT32 i = 0;
UINT32 semCount = 0;
@@ -522,6 +609,7 @@
#endif
+
#ifdef ECALL_SUPPORT
int eWrErr = 0;
UINT8 e_reg_flag = 0;
@@ -533,6 +621,7 @@
T_Ecall_State preEcallRxSta = 0;
T_Ecall_State preEcallTxSta = 0;
+
//tx
SINT32 rdsem_count_Init(T_Sem_Owner owner)
{
@@ -706,7 +795,7 @@
e_startCount = 0;
e_stopCount = 0;
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open end!\n");
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open bufsize=%d end!\n",bufsize);
return DRV_SUCCESS;
@@ -758,7 +847,7 @@
{
SINT32 ret = DRV_SUCCESS;
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s start e_startCount=%d \n",__FUNCTION__,e_startCount);
+ 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);
@@ -785,7 +874,7 @@
SINT32 ecall_Stop(VOID)
{
SINT32 ret = DRV_SUCCESS;
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s start e_stopCount=%d \n",__FUNCTION__,e_stopCount);
+ 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))
{
@@ -833,7 +922,7 @@
{
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);
@@ -964,9 +1053,15 @@
return DRV_SUCCESS;
}
+
SINT32 zDrvExtAudio_Open(T_ZDrvI2s_TransMode i2sTransMode)
{
+
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
+
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -984,6 +1079,9 @@
SINT32 zDrvExtAudio_Reset()
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1000,6 +1098,9 @@
SINT32 zDrvExtAudio_Close()
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1017,6 +1118,9 @@
SINT32 zDrvExtAudio_Write_Prepare(T_ZDrvI2S_Cfg *i2sCfg, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1035,6 +1139,9 @@
T_ZDrvTdm_Params *tdmParams, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1052,6 +1159,9 @@
T_ZDrvTdm_Params *tdmParams, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1068,6 +1178,9 @@
SINT32 zDrvExtAudio_Read_Prepare(T_ZDrvI2S_Cfg *i2sCfg, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1086,6 +1199,9 @@
T_ZDrvTdm_Params *tdmParams, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1103,6 +1219,9 @@
T_ZDrvTdm_Params *tdmParams, T_ZDrvTdm_Cfg *tdmCfg)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1119,6 +1238,9 @@
SINT32 zDrvExtAudio_Write(const UINT8 *pBuf, UINT32 uiLen)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1136,6 +1258,9 @@
SINT32 zDrvExtAudio_Read(const UINT8 **pBuf, UINT32 *uiLen)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1195,9 +1320,13 @@
return ret;
}
#endif
+
SINT32 zDrvExtAudio_Write_Stop()
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1215,6 +1344,9 @@
SINT32 zDrvExtAudio_Read_Stop()
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1232,6 +1364,9 @@
SINT32 zDrvExtAudio_GetBuf(UINT8 **pBuf, UINT32 *uiLen)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1263,6 +1398,9 @@
SINT32 zDrvExtAudio_FreeBuf(UINT8 *pBuf)
{
int ret = 0;
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return ret;
+ }
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm != 1)
@@ -1279,6 +1417,10 @@
void zDrvExtAudio_RlsAllSemaBeforeStop(void)
{
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return;
+ }
+
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm == 1)
@@ -1296,6 +1438,10 @@
void zDrvExtAudio_RxRlsSemaBeforeStop(void)
{
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return;
+ }
+
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm == 1)
@@ -1311,6 +1457,10 @@
void zDrvExtAudio_TxRlsSemaBeforeStop(void)
{
+ if (g_voiceVar.useVoiceBuffer == 1){
+ return;
+ }
+
#ifdef CONFIG_VOICE_BUFFER_DRV
#else
if (g_voiceVar.g_isUseTdm == 1)
@@ -1595,7 +1745,19 @@
ext_aRdCount = 0;
ext_aRdFBufCount = 0;
+
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_Open_Vbuffer();
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Open_Vbuffer ret=%d!\n",ret);
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Open_Vbuffer useVoiceBuffer=%d voiceBufferType=%d!\n",g_voiceVar.useVoiceBuffer,g_voiceVar.voiceBufferType);
+
+
+
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Open end!\n");
return DRV_SUCCESS;
@@ -2282,7 +2444,7 @@
ret = ecall_Close();
if (ret != DRV_SUCCESS)
{
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "ecall_Open error,ret=%d", ret);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s:ecall_Close error,ret=%d",__func__,ret);
}
e_reg_flag = 0;
}
@@ -2305,6 +2467,12 @@
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
+ if(g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_Close_Vbuffer();
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_Close_Vbuffer ret=%d!\n",ret);
+
+ }
zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "%s: ext_aRdCount %d,ext_aRdFBufCount %d!\n",__FUNCTION__,ext_aRdCount,ext_aRdFBufCount);
@@ -2337,176 +2505,185 @@
// {
// zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "is the i2s loopback mode");
// }
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_VoiceI2sStart_Vbuffer();
+ }
+ else
+ {
+
#ifdef CONFIG_VOICE_BUFFER_DRV
- ret = zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S2_Read_Start failed ret is %d .\n", ret);
- return DRV_ERROR;
- }
-
- zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart VB zOss_StartTimer\n");
+ ret = zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S2_Read_Start failed ret is %d .\n", ret);
+ return DRV_ERROR;
+ }
+
+ zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart VB zOss_StartTimer\n");
- ret = zDrvI2S_Write_Start(I2S_2, &s_speechState.i2sWriteParam, s_vpState.pVpInnerI2sCfg);
+ ret = zDrvI2S_Write_Start(I2S_2, &s_speechState.i2sWriteParam, s_vpState.pVpInnerI2sCfg);
- ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error7:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error12:zDrvI2S_Write I2S_2 ret=%d", ret);
- }
-
- ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error13:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error14:zDrvI2S_Write I2S_2 ret=%d", ret);
- }
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error7:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error12:zDrvI2S_Write I2S_2 ret=%d", ret);
+ }
+
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error13:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error14:zDrvI2S_Write I2S_2 ret=%d", ret);
+ }
#ifdef _VBUFF_IN_MULTI_CORE
- voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
#else
- voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
#endif
#else
- if (g_voiceVar.isUseSlicCodec == 1)
- {
-
- if (s_speechState.i2sIsRstFlag == FALSE)
+ if (g_voiceVar.isUseSlicCodec == 1)
{
- ret = zDrvExtAudio_Reset();
- if (ret != DRV_SUCCESS)
+
+ if (s_speechState.i2sIsRstFlag == FALSE)
{
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvExtAudio_Reset() err ret=%d ", ret);
- return DRV_ERROR;
+ ret = zDrvExtAudio_Reset();
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvExtAudio_Reset() err ret=%d ", ret);
+ return DRV_ERROR;
+ }
+ s_speechState.i2sIsRstFlag = TRUE;
}
- s_speechState.i2sIsRstFlag = TRUE;
+
}
- }
+ ret = zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S2_Read_Start failed ret is %d .\n", ret);
+ return DRV_ERROR;
+ }
- ret = zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S2_Read_Start failed ret is %d .\n", ret);
- return DRV_ERROR;
- }
+ ret += zDrvExtAudio_Read_Start(&s_speechState.i2sReadParam, s_speechState.pVpI2sCfg, &s_vpTdmReadParam, s_vpState.pVpTdmCfg);
- ret += zDrvExtAudio_Read_Start(&s_speechState.i2sReadParam, s_speechState.pVpI2sCfg, &s_vpTdmReadParam, s_vpState.pVpTdmCfg);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S1_Read_Start failed ret is %d .\n", ret);
+ zDrvI2S_Read_Stop(I2S_2);
+ return DRV_ERROR;
+ }
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvI2S1_Read_Start failed ret is %d .\n", ret);
- zDrvI2S_Read_Stop(I2S_2);
- return DRV_ERROR;
- }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read_Start ret=%d", ret);
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read_Start ret=%d", ret);
+ ret = zDrvI2S_Read(I2S_2, &read_buf, &read_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read I2S_2 ret=%d", ret);
- ret = zDrvI2S_Read(I2S_2, &read_buf, &read_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read I2S_2 ret=%d", ret);
+ ret = zDrvExtAudio_Read(&read_buf, &read_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read I2S_1 ret=%d", ret);
- ret = zDrvExtAudio_Read(&read_buf, &read_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read ret=%d", ret);
- return DRV_ERROR;
- }
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart zDrvI2S_Read I2S_1 ret=%d", ret);
+ ret += zDrvExtAudio_Read_Stop();
+ ret += zDrvI2S_Read_Stop(I2S_2);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read ret=%d", ret);
+ return DRV_ERROR;
+ }
- ret += zDrvExtAudio_Read_Stop();
- ret += zDrvI2S_Read_Stop(I2S_2);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error:zDrvI2S_Read ret=%d", ret);
- return DRV_ERROR;
- }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart first read/write stop ret=%d", ret);
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart first read/write stop ret=%d", ret);
+ ret += zDrvExtAudio_Read_Start(&s_speechState.i2sReadParam, s_speechState.pVpI2sCfg, &s_vpTdmReadParam, s_vpState.pVpTdmCfg);
- ret += zDrvExtAudio_Read_Start(&s_speechState.i2sReadParam, s_speechState.pVpI2sCfg, &s_vpTdmReadParam, s_vpState.pVpTdmCfg);
+ ret += zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
- ret += zDrvI2S_Read_Start(I2S_2, &s_speechState.i2sReadParam, s_vpState.pVpInnerI2sCfg);
+ ret += zDrvExtAudio_Write_Start(&s_speechState.i2sWriteParam, s_speechState.pVpI2sCfg, &s_VpTdmWriteParam, s_vpState.pVpTdmCfg);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error4:zDrvI2S_Write_Start ret=%d", ret);
+ return DRV_ERROR;
+ }
+ ret += zDrvExtAudio_GetBuf(&write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error5:zDrvI2S_GetBuf ret=%d", ret);
+ return DRV_ERROR;
+ }
- ret += zDrvExtAudio_Write_Start(&s_speechState.i2sWriteParam, s_speechState.pVpI2sCfg, &s_VpTdmWriteParam, s_vpState.pVpTdmCfg);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error4:zDrvI2S_Write_Start ret=%d", ret);
- return DRV_ERROR;
- }
- ret += zDrvExtAudio_GetBuf(&write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error5:zDrvI2S_GetBuf ret=%d", ret);
- return DRV_ERROR;
- }
-
- zOss_Memset(write_buf, 0, write_len);
- ret += zDrvExtAudio_Write(write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error6:zDrvI2S_Write ret=%d", ret);
- return DRV_ERROR;
- }
- ret = zDrvI2S_Write_Start(I2S_2, &s_speechState.i2sWriteParam, s_vpState.pVpInnerI2sCfg);
- ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error7:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error8:zDrvI2S_Write I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- ret += zDrvExtAudio_GetBuf(&write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error9:zDrvI2S_GetBuf ret=%d", ret);
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret += zDrvExtAudio_Write(write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error10:zDrvI2S_Write ret=%d", ret);
- return DRV_ERROR;
- }
- ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error11:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error12:zDrvI2S_Write I2S_2 ret=%d", ret);
- }
+ zOss_Memset(write_buf, 0, write_len);
+ ret += zDrvExtAudio_Write(write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error6:zDrvI2S_Write ret=%d", ret);
+ return DRV_ERROR;
+ }
+ ret = zDrvI2S_Write_Start(I2S_2, &s_speechState.i2sWriteParam, s_vpState.pVpInnerI2sCfg);
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error7:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error8:zDrvI2S_Write I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ ret += zDrvExtAudio_GetBuf(&write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error9:zDrvI2S_GetBuf ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret += zDrvExtAudio_Write(write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error10:zDrvI2S_Write ret=%d", ret);
+ return DRV_ERROR;
+ }
+ ret += zDrvI2S_GetBuf(I2S_2, &write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error11:zDrvI2S_GetBuf I2S_2 ret=%d", ret);
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvI2S_Write(I2S_2, write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VoiceI2sStart error12:zDrvI2S_Write I2S_2 ret=%d", ret);
+ }
#endif
+ }
#ifdef ECALL_SUPPORT
if((g_voiceVar.audio_ctrlFlag.isUseEcall == 1)&&(e_reg_flag == 1))
{
@@ -2657,18 +2834,27 @@
zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVp_VoiceWorkStop call voice_ToneMixerStop !\n");
g_voiceVar.vpI2sStatus = VP_I2S_OPEN;
-#ifdef CONFIG_VOICE_BUFFER_DRV
- //complete_all(&s_voice_completion);
- zOss_PutSemaphore(s_voiceRdSema);
- zOss_PutSemaphore(s_voiceWrSema);
- zOss_StopTimer(s_voiceTimerId);
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVp_VoiceWorkStop zOss_StopTimer\n");
-#else
- //zDrvI2s_RxRlsSemaBeforeStop(I2S_1);
- //zDrvI2s_TxRlsSemaBeforeStop(I2S_1);
- zDrvExtAudio_RlsAllSemaBeforeStop();
-#endif
+
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = zDrvVp_VoiceWorkStop_Vbuffer();
+ }
+ else
+ {
+#ifdef CONFIG_VOICE_BUFFER_DRV
+ //complete_all(&s_voice_completion);
+ zOss_PutSemaphore(s_voiceRdSema);
+ zOss_PutSemaphore(s_voiceWrSema);
+ zOss_StopTimer(s_voiceTimerId);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "zDrvVp_VoiceWorkStop zOss_StopTimer\n");
+#else
+ //zDrvI2s_RxRlsSemaBeforeStop(I2S_1);
+ //zDrvI2s_TxRlsSemaBeforeStop(I2S_1);
+ zDrvExtAudio_RlsAllSemaBeforeStop();
+#endif
+ }
zDrvI2s_RxRlsSemaBeforeStop(I2S_2);
zDrvI2s_TxRlsSemaBeforeStop(I2S_2);
@@ -2736,10 +2922,19 @@
}
g_voiceVar.vpI2sStatus = VP_I2S_INUSE;
+
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_VolteReadStart_Vbuffer();
+ }
+ else
+ {
#ifdef CONFIG_VOICE_BUFFER_DRV
- zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStart zOss_StartTimer start\n");
-#endif
+ zOss_StartTimer(s_voiceTimerId, 20, voiceTimerCallBack, 0);
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStart zOss_StartTimer start\n");
+#endif
+ }
zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteReadStart \n");
return DRV_SUCCESS;
@@ -2748,6 +2943,15 @@
SINT32 vp_VolteReadStop(VOID)
{
SINT32 ret = DRV_SUCCESS;
+
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_VolteReadStop_Vbuffer();
+ return ret;
+ }
+
+
#ifdef CONFIG_VOICE_BUFFER_DRV
zOss_PutSemaphore(s_voiceRdSema);
#else
@@ -2844,46 +3048,54 @@
}
g_voiceVar.vpI2sStatus = VP_I2S_INUSE;
+
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ vp_VolteWriteStart_Vbuffer();
+ }
+ else
+ {
#ifdef CONFIG_VOICE_BUFFER_DRV
#ifdef _VBUFF_IN_MULTI_CORE
- voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ voice_buffer_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
#else
- voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
+ voicebuffer_dlqueue_write(s_speechState.pVpTempRxOutPutBuffer, s_speechState.totalFrameBufSize);
#endif
#else
- ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error1:zDrvI2S_GetBuf I2S_1 ret=%d", ret);
- zDrvExtAudio_Write_Stop();
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvExtAudio_Write(write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error2:zDrvI2S_Write I2S_1 ret=%d", ret);
- zDrvExtAudio_Write_Stop();
- return DRV_ERROR;
- }
- ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error3:zDrvI2S_GetBuf I2S_1 ret=%d", ret);
- zDrvExtAudio_Write_Stop();
- return DRV_ERROR;
- }
- zOss_Memset(write_buf, 0, write_len);
- ret = zDrvExtAudio_Write(write_buf, write_len);
- if (ret != DRV_SUCCESS)
- {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error4:zDrvI2S_Write I2S_1 ret=%d", ret);
- zDrvExtAudio_Write_Stop();
- return DRV_ERROR;
- }
+ ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error1:zDrvI2S_GetBuf I2S_1 ret=%d", ret);
+ zDrvExtAudio_Write_Stop();
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvExtAudio_Write(write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error2:zDrvI2S_Write I2S_1 ret=%d", ret);
+ zDrvExtAudio_Write_Stop();
+ return DRV_ERROR;
+ }
+ ret = zDrvExtAudio_GetBuf(&write_buf, &write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error3:zDrvI2S_GetBuf I2S_1 ret=%d", ret);
+ zDrvExtAudio_Write_Stop();
+ return DRV_ERROR;
+ }
+ zOss_Memset(write_buf, 0, write_len);
+ ret = zDrvExtAudio_Write(write_buf, write_len);
+ if (ret != DRV_SUCCESS)
+ {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart error4:zDrvI2S_Write I2S_1 ret=%d", ret);
+ zDrvExtAudio_Write_Stop();
+ return DRV_ERROR;
+ }
#endif
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart \n");
+ }
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_VolteWriteStart end\n");
return DRV_SUCCESS;
}
@@ -2891,6 +3103,13 @@
SINT32 vp_VolteWriteStop(VOID)
{
SINT32 ret = DRV_SUCCESS;
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_VolteWriteStop_Vbuffer();
+ return ret;
+ }
+
+
#ifdef CONFIG_VOICE_BUFFER_DRV
//complete_all(&s_voice_completion);
@@ -2961,6 +3180,11 @@
//UINT8 *pVoiceTempBuf = s_voiceTempBuffer;
#endif
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_WriteDataToCodec_Vbuffer(pBuf, count);
+ return ret;
+ }
if (pBuf == NULL)
@@ -3285,6 +3509,14 @@
UINT8 *ptemp8bit = NULL;
#endif
+ if (g_voiceVar.useVoiceBuffer == 1)
+ {
+ ret = vp_ReadDataFromCodec_Vbuffer(pBuf, count);
+ return ret;
+ }
+
+
+
if (pBuf == NULL)
{
return DRV_ERR_INVALID_PARAM;
@@ -3313,6 +3545,8 @@
// wait_for_completion_timeout(&s_voice_completion, 60);
zOss_GetSemaphore(s_voiceRdSema, 60);
#ifdef _VBUFF_IN_MULTI_CORE
+
+
voice_buffer_read(s_speechState.pVpTempTxInBuffer, s_speechState.totalFrameBufSize);
#else
@@ -3911,11 +4145,14 @@
SINT32 vp_CreateThreadSemaph(VOID)
{
+ SINT32 ret = 0;
+
s_vpState.vpSemaphore = zOss_CreateSemaphore("VpI2sReadWriteSemaphore", 0);
#ifdef _USE_WEBRTC_AUD
s_vpState.vpThread = zOss_CreateThread("vp_DataProcessThreadEntry", vp_DataProcessThreadEntry, 0, 8192, 15, 0, 1);
#else
- s_vpState.vpThread = zOss_CreateThread("vp_DataProcessThreadEntry", vp_DataProcessThreadEntry, 0, 1024, 15, 0, 1);
+ //s_vpState.vpThread = zOss_CreateThread("vp_DataProcessThreadEntry", vp_DataProcessThreadEntry, 0, 1024, 15, 0, 1);
+ s_vpState.vpThread = zOss_CreateThread("vp_DataProcessThreadEntry", vp_DataProcessThreadEntry, 0, 8192, 15, 0, 1);
#endif
#ifdef _OS_TOS
@@ -3937,6 +4174,9 @@
zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create vp Thread sem err s_vpState.vpThread=%p,s_vpState.vpSemaphore=%p !\r\n", s_vpState.vpThread, s_vpState.vpSemaphore);
return DRV_ERROR;
}
+
+
+
#ifdef CONFIG_VOICE_BUFFER_DRV
// init_completion(&s_voice_completion);
s_voiceRdSema = zOss_CreateSemaphore("voice_rx_sem", 0);
@@ -3959,50 +4199,57 @@
return DRV_ERROR;
}
#ifdef _VBUFF_IN_MULTI_CORE
- SINT32 ret = 0;
+ //SINT32 ret = 0;
- //ret = zDrvRpMsg_CreateChannel(IPC_MSG_ACTOR_A9,channel_41,0x10);
- ret = zDrvRpMsg_CreateChannel_Cap(RPMSG_CAP_ID,channel_41,0x10);
+ //ret = zDrvRpMsg_CreateChannel(IPC_MSG_ACTOR_A9,channel_41,0x10);
+ ret = zDrvRpMsg_CreateChannel_Cap(RPMSG_CAP_ID,channel_41,0x10);
- if(DRV_SUCCESS != ret) {
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create rpmsg err(%d) \n",ret);
- return DRV_ERROR;
- }
+ if(DRV_SUCCESS != ret) {
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "create rpmsg err(%d) \n",ret);
+ return DRV_ERROR;
+ }
+
+ volatile T_ZDrvRpMsg_Msg icp_pMsg = {0};
+ volatile unsigned int rpMsgBuf[2] = {0,0};
+ //printk( "vir_buf1:0x%x, vir_buf2:0x%x, phy_buf1:0x%x, phy_buf2:0x%x,\n",voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1]);
+ icp_pMsg.actorID = RPMSG_CAP_ID;
+ icp_pMsg.chID = channel_41;
+ icp_pMsg.flag &= ~RPMSG_READ_POLL;
+ icp_pMsg.buf = rpMsgBuf;
+ icp_pMsg.len = 8;
+ ret = zDrvRpMsg_Read_Cap(&icp_pMsg);
+ if(ret <= 0){
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer rpmsg addr read fail,ret=%d \n",ret);
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps voice buffer rpmsg addr read fail,ret=%d \n",ret);
- volatile T_ZDrvRpMsg_Msg icp_pMsg = {0};
- volatile unsigned int rpMsgBuf[2] = {0,0};
- //printk( "vir_buf1:0x%x, vir_buf2:0x%x, phy_buf1:0x%x, phy_buf2:0x%x,\n",voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1]);
- icp_pMsg.actorID = RPMSG_CAP_ID;
- icp_pMsg.chID = channel_41;
- icp_pMsg.flag &= ~RPMSG_READ_POLL;
- icp_pMsg.buf = rpMsgBuf;
- icp_pMsg.len = 8;
- ret = zDrvRpMsg_Read_Cap(&icp_pMsg);
- if(ret <= 0){
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer rpmsg addr read fail,ret=%d \n",ret);
- zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps voice buffer rpmsg addr read fail,ret=%d \n",ret);
-
- }
- else{
- #if 0
+ }
+ else{
+ #if 0
- voice_buff[UP_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[0]);
- voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[1]);
- #else
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[0]);
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)(rpMsgBuf[1]);
+ #else
- voice_buff[UP_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[0], (sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
- voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
- #endif
-
- zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps rpmsg voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ voice_buff[UP_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[0], (sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ voice_buff[DOWN_LINK] = (struct voice_ring_buffer *)ioremap_wc(rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ #endif
+
+ zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, "ps rpmsg voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
+ ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
+ zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
- zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "voice buffer addr,up vir buf=0x%x, down vir buf=0x%x ,up phy buf=0x%x, down phy buf=0x%x,size=%d \n" \
- ,voice_buff[0],voice_buff[1],rpMsgBuf[0],rpMsgBuf[1],(sizeof(struct voice_ring_buffer) + MAX_BUF_SIZE*MAX_BUF_NUM));
- }
+ }
#endif
+
+#else
+ //flag ctrl voicebuffer func
+ vp_CreateThreadSemaph_Vbuffer();
+
+
#endif
-
+
+
zDrvRamlog_PRINTF(RAMLOG_MOD_AUDIO, "vp_CreateThreadSemaph success. \r\n");
return DRV_SUCCESS;
}
diff --git a/pub/project/zx297520v3/include/drv/NvParam_drv.h b/pub/project/zx297520v3/include/drv/NvParam_drv.h
index 66c6f6d..95c3158 100755
--- a/pub/project/zx297520v3/include/drv/NvParam_drv.h
+++ b/pub/project/zx297520v3/include/drv/NvParam_drv.h
@@ -214,8 +214,10 @@
UINT8 isUseTxDtmfDet;
UINT8 isUseRxMixData;
UINT8 isUseTxMixData;//12
- UINT8 isUseEcall;
- UINT8 reserved[19];//32-13
+ UINT8 isUseEcall; //13
+ UINT8 isUseVoiceBuffer; //14 0 not use,1 use
+ UINT8 selVoiceBufferType; //15 0 single core, 1 dual core
+ UINT8 reserved[17];//32-15
} T_Audio_NvFlag;