[Feature][ZXW-41] merged 0601 version
Change-Id: I667af6bb09d65581d455b73f8984c160b2c67ad8
diff --git a/ap/lib/libvoice/voice.c b/ap/lib/libvoice/voice.c
index fbc8bf1..33b3bed 100644
--- a/ap/lib/libvoice/voice.c
+++ b/ap/lib/libvoice/voice.c
@@ -23,6 +23,8 @@
#include <fcntl.h>
#include <tinyalsa/audio_mixer_ctrl.h>
#include "voice_lib.h"
+#include "voice_ipc.h"
+
#define VOICE_DEV_NAME "/dev/voice_device"
@@ -197,12 +199,15 @@
}
+static T_ZDrvVoice_Cfg s_cfgParam = {0};
+static int cur_vmode = MAX_AVOICE_MODE;
+
int zDrvVolte_PreOpen(T_ZDrvVolte_Cfg *cfgParam)
{
-
struct mixer *voice_mixer = NULL;
struct pcm_config config_voice = {0};
+ int ret = 0;
printf(" voice lib zDrvVolte_PreOpen!\n");
if (slic_flag_already == 1) {
@@ -218,17 +223,44 @@
return 0;
}
}
-#ifdef _ALSA_CODEC_IN_CAP
+#if defined(_ALSA_CODEC_IN_CAP) && defined(_USE_ALSA_AT_INTF)
- printf("%s: i2s and codec not need config,return!\n",__func__);
- return 0;
+
+ printf("%s: i2s and codec not need config,return!\n",__func__);
+ return 0;
+
+#elif defined(_ALSA_CODEC_IN_CAP)
+
+
+ if(cfgParam->clock_rate == 8000){
+
+ ret = cap_alsa_voice_open(AVOICE_4G_NB);
+ printf("%s:cap_alsa_voice_open clock_rate(%d) ret=%d!\n",__func__,cfgParam->clock_rate,ret);
+ cur_vmode = AVOICE_4G_NB;
+
+ }
+ else if(cfgParam->clock_rate == 16000){
+
+ ret = cap_alsa_voice_open(AVOICE_4G_WB);
+ printf("%s:cap_alsa_voice_open clock_rate(%d) ret=%d!\n",__func__,cfgParam->clock_rate,ret);
+ cur_vmode = AVOICE_4G_WB;
+ }
+ else{
+
+ printf("%s:cap_alsa_voice_open clock_rate(%d) not support!\n",__func__,cfgParam->clock_rate);
+ return -2;
+
+ }
+ s_cfgParam = *cfgParam;
+ return ret;
+
#endif
//open mixer dev for codec control
voice_mixer = mixer_open(0);
if (!voice_mixer) {
- printf("zte voice_mixer open failed!\n");
+ printf("voice_mixer open failed!\n");
return -1;
}
@@ -254,23 +286,23 @@
//23G card 0 dev 2
volte_pcm_voice_out = pcm_open(0, 1, PCM_OUT, &config_voice);
if (!pcm_is_ready(volte_pcm_voice_out)) {
- printf("zte volte_pcm_voice_out open failed!\n");
+ printf("volte_pcm_voice_out open failed!\n");
goto err_ret;
}
volte_pcm_voice_in = pcm_open(0, 1, PCM_IN, &config_voice);
if (!pcm_is_ready(volte_pcm_voice_in)) {
- printf("zte volte_pcm_voice_in open failed!\n");
+ printf("volte_pcm_voice_in open failed!\n");
goto err_ret;
}
if (0 != pcm_prepare(volte_pcm_voice_out)) {
- printf("zte volte_pcm_voice_out pcm_prepare failed!\n");
+ printf("volte_pcm_voice_out pcm_prepare failed!\n");
goto err_ret;
}
if (0 != pcm_prepare(volte_pcm_voice_in)) {
- printf("zte volte_pcm_voice_in pcm_prepare failed!\n");
+ printf("volte_pcm_voice_in pcm_prepare failed!\n");
goto err_ret;
}
return 0;
@@ -289,25 +321,49 @@
void zDrvVolte_PreClose(void)
{
+ int ret = 0;
printf(" voice lib zDrvVolte_PreClose!\n");
if (slic_flag_already == 1) {
printf(" voice slic flag already get, slic_flag=%d!\n", slic_flag);
if (slic_flag == 1) {
- return ;
+ return;
}
} else {
slic_flag = voice_GetSlicFlag();
printf(" voice slic flag get, slic_flag=%d!\n", slic_flag);
if (slic_flag == 1) {
- return ;
+ return;
}
}
-#ifdef _ALSA_CODEC_IN_CAP
+#if defined(_ALSA_CODEC_IN_CAP) && defined(_USE_ALSA_AT_INTF)
+
printf("%s: i2s and codec not need config,return!\n",__func__);
return ;
+#elif defined(_ALSA_CODEC_IN_CAP)
+ if(s_cfgParam.clock_rate == 8000){
+
+ ret = cap_alsa_voice_close(AVOICE_4G_NB);
+ printf("%s:cap_alsa_voice_close clock_rate(%d) ret=%d!\n",__func__,s_cfgParam.clock_rate,ret);
+
+ }
+ else if(s_cfgParam.clock_rate == 16000){
+
+ ret = cap_alsa_voice_close(AVOICE_4G_WB);
+ printf("%s:cap_alsa_voice_close clock_rate(%d) ret=%d!\n",__func__,s_cfgParam.clock_rate,ret);
+
+ }
+ else{
+
+ printf("%s:cap_alsa_voice_close clock_rate(%d) not support!\n",__func__,s_cfgParam.clock_rate);
+
+ }
+ return;
+
+
+
#endif