changeset 597:f18b29e27be5

First attempt at MCSI voice path automatic switching The function is implemented at the ACI level in both aci2 and aci3, successfully avoids triggering the DSP bug on the first call, but the shutdown of MCSI upon call completion is not working properly yet in either version.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 27 Mar 2019 22:18:35 +0000
parents e4d46979846f
children 717ed17d82c6
files src/aci2/aci/aci_cmh.h src/aci2/aci/ati_audio.c src/aci2/aci/ati_cmd.c src/aci2/aci/hl_audio_drv.c src/g23m-aci/aci/aci_cmh.h src/g23m-aci/aci/ati_audio.c src/g23m-aci/aci/ati_cmd.c src/g23m-aci/aci/hl_audio_drv.c
diffstat 8 files changed, 133 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/aci2/aci/aci_cmh.h	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/aci2/aci/aci_cmh.h	Wed Mar 27 22:18:35 2019 +0000
@@ -481,6 +481,7 @@
   /* FreeCalypso additions */
   AT_CMD_AT_SPKR,
   AT_CMD_AT_VPATH,
+  AT_CMD_AT_VSEL,
   AT_CMD_AT_SND,
   AT_CMD_AT_E1,
   AT_CMD_AT_E1STOP,
--- a/src/aci2/aci/ati_audio.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/aci2/aci/ati_audio.c	Wed Mar 27 22:18:35 2019 +0000
@@ -168,6 +168,8 @@
 }
 
 #ifdef CONFIG_TARGET_FCDEV3B
+extern UBYTE aci_digital_voice_autoswitch;
+
 /* AT@VPATH - configure digital voice path */
 GLOBAL T_ATI_RSLT atAtVPATH ( char *cl, UBYTE srcId )
 {
@@ -212,6 +214,33 @@
 
 	return (ATI_CMPL);
 }
+
+/* AT@VSEL - configure digital voice path automatic operation */
+GLOBAL T_ATI_RSLT atAtVSEL ( char *cl, UBYTE srcId )
+{
+	int vsel_int;
+
+	TRACE_FUNCTION("atAtVSEL()");
+
+	cl = parse(cl, "D", &vsel_int);
+	if (!cl)
+		return (ATI_FAIL);
+	if (vsel_int != 0 && vsel_int != 1)
+		return (ATI_FAIL);
+	aci_digital_voice_autoswitch = vsel_int;
+	return (ATI_CMPL);
+}
+
+GLOBAL T_ATI_RSLT queatAtVSEL (char *cl, UBYTE srcId)
+{
+	char *me="@VSEL: ";
+
+	TRACE_FUNCTION("queatAtVSEL()");
+
+	sprintf(g_sa, "%s%u", me, aci_digital_voice_autoswitch);
+	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+	return (ATI_CMPL);
+}
 #endif
 
 static char melody_E1_name[AUDIO_PATH_NAME_MAX_SIZE];
--- a/src/aci2/aci/ati_cmd.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/aci2/aci/ati_cmd.c	Wed Mar 27 22:18:35 2019 +0000
@@ -682,6 +682,8 @@
 #ifdef CONFIG_TARGET_FCDEV3B
 EXTERN T_ATI_RSLT atAtVPATH (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT queatAtVPATH (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtVSEL (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT queatAtVSEL (char *cl, UBYTE srcId);
 #endif
 EXTERN T_ATI_RSLT atAtSND (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtE1 (char *cl, UBYTE srcId);
@@ -1093,6 +1095,7 @@
 #endif
 #ifdef CONFIG_TARGET_FCDEV3B
     {"@VPATH",	AT_CMD_AT_VPATH, atAtVPATH,test_gen, queatAtVPATH,"%s: (0-2)"},
+    {"@VSEL",	AT_CMD_AT_VSEL,  atAtVSEL, test_gen, queatAtVSEL, "%s: (0,1)"},
 #endif
     {"@SND",	AT_CMD_AT_SND,   atAtSND,	0,	0,	0},
     {"@E1",	AT_CMD_AT_E1,    atAtE1,	0,	0,	0},
--- a/src/aci2/aci/hl_audio_drv.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/aci2/aci/hl_audio_drv.c	Wed Mar 27 22:18:35 2019 +0000
@@ -29,6 +29,9 @@
 #include "aci.h"
 #include "psa.h"
 #include "hl_audio_drv.h"
+#include "rv/rv_general.h"
+#include "audio/audio_api.h"
+#include "fc-target.cfg"
 
 
 
@@ -36,6 +39,10 @@
 
 LOCAL T_HL_VOCODER_STATE currVocoderState;
 
+#ifdef CONFIG_TARGET_FCDEV3B
+GLOBAL UBYTE aci_digital_voice_autoswitch;
+#endif
+
 /* This flag helps enable the vocoder interface testing for
    specific tescases 
 */
@@ -88,6 +95,12 @@
 */
 GLOBAL T_HL_VOICE_DRV_RSLT hl_drv_enable_vocoder ( void )
 {
+#ifdef CONFIG_TARGET_FCDEV3B
+  T_AUDIO_VOICE_PATH_SETTING vpath = AUDIO_BLUETOOTH_HEADSET;
+  T_AUDIO_FULL_ACCESS_WRITE audio_param;
+  T_RV_RETURN return_path = { NULL, 0 };
+#endif
+
   TRACE_FUNCTION("hl_drv_enable_vocoder()");
   /* If the vocoder is already enabled, then ignore the request */
   switch(currVocoderState)
@@ -121,6 +134,14 @@
     enable_tch_vocoder(TRUE);
     vocoder_mute_dl (FALSE);      /* un-mute speaker    */
     vocoder_mute_ul (FALSE);      /* un-mute microphone */
+  #ifdef CONFIG_TARGET_FCDEV3B
+    if (aci_digital_voice_autoswitch)
+    {
+      audio_param.variable_indentifier = AUDIO_PATH_USED;
+      audio_param.data = &vpath;
+      audio_full_access_write(&audio_param, return_path);
+    }
+  #endif
     currVocoderState = HL_VOCODER_ENABLED;
 #endif /* _SIMULATION_ */
 #endif
@@ -139,6 +160,12 @@
 */
 GLOBAL void hl_drv_disable_vocoder ( void )
 {
+#ifdef CONFIG_TARGET_FCDEV3B
+  T_AUDIO_VOICE_PATH_SETTING vpath = AUDIO_GSM_VOICE_PATH;
+  T_AUDIO_FULL_ACCESS_WRITE audio_param;
+  T_RV_RETURN return_path = { NULL, 0 };
+#endif
+
   TRACE_FUNCTION("hl_drv_disable_vocoder()");
 
   currVocoderState = HL_VOCODER_DISABLED;
@@ -150,6 +177,14 @@
   vocoder_mute_dl (TRUE);       /* mute speaker    */
   vocoder_mute_ul (TRUE);       /* mute microphone */
   enable_tch_vocoder (FALSE);   /* disable vocoder */
+#ifdef CONFIG_TARGET_FCDEV3B
+  if (aci_digital_voice_autoswitch)
+  {
+    audio_param.variable_indentifier = AUDIO_PATH_USED;
+    audio_param.data = &vpath;
+    audio_full_access_write(&audio_param, return_path);
+  }
+#endif
 #endif
 #endif
 }
@@ -200,4 +235,4 @@
 {
   vocoder_tst_flag = TRUE;
 }
-#endif
\ No newline at end of file
+#endif
--- a/src/g23m-aci/aci/aci_cmh.h	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/g23m-aci/aci/aci_cmh.h	Wed Mar 27 22:18:35 2019 +0000
@@ -527,6 +527,7 @@
   /* FreeCalypso additions */
   AT_CMD_AT_SPKR,
   AT_CMD_AT_VPATH,
+  AT_CMD_AT_VSEL,
   AT_CMD_AT_SND,
   AT_CMD_AT_E1,
   AT_CMD_AT_E1STOP,
--- a/src/g23m-aci/aci/ati_audio.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/g23m-aci/aci/ati_audio.c	Wed Mar 27 22:18:35 2019 +0000
@@ -168,6 +168,8 @@
 }
 
 #ifdef CONFIG_TARGET_FCDEV3B
+extern UBYTE aci_digital_voice_autoswitch;
+
 /* AT@VPATH - configure digital voice path */
 GLOBAL T_ATI_RSLT atAtVPATH ( char *cl, UBYTE srcId )
 {
@@ -212,6 +214,33 @@
 
 	return (ATI_CMPL);
 }
+
+/* AT@VSEL - configure digital voice path automatic operation */
+GLOBAL T_ATI_RSLT atAtVSEL ( char *cl, UBYTE srcId )
+{
+	int vsel_int;
+
+	TRACE_FUNCTION("atAtVSEL()");
+
+	cl = parse(cl, "D", &vsel_int);
+	if (!cl)
+		return (ATI_FAIL);
+	if (vsel_int != 0 && vsel_int != 1)
+		return (ATI_FAIL);
+	aci_digital_voice_autoswitch = vsel_int;
+	return (ATI_CMPL);
+}
+
+GLOBAL T_ATI_RSLT queatAtVSEL (char *cl, UBYTE srcId)
+{
+	char *me="@VSEL: ";
+
+	TRACE_FUNCTION("queatAtVSEL()");
+
+	sprintf(g_sa, "%s%u", me, aci_digital_voice_autoswitch);
+	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+	return (ATI_CMPL);
+}
 #endif
 
 static char melody_E1_name[AUDIO_PATH_NAME_MAX_SIZE];
--- a/src/g23m-aci/aci/ati_cmd.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/g23m-aci/aci/ati_cmd.c	Wed Mar 27 22:18:35 2019 +0000
@@ -750,6 +750,8 @@
 #ifdef CONFIG_TARGET_FCDEV3B
 EXTERN T_ATI_RSLT atAtVPATH (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT queatAtVPATH (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtVSEL (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT queatAtVSEL (char *cl, UBYTE srcId);
 #endif
 EXTERN T_ATI_RSLT atAtSND (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtE1 (char *cl, UBYTE srcId);
@@ -1212,6 +1214,7 @@
 #endif
 #ifdef CONFIG_TARGET_FCDEV3B
     {"@VPATH",	AT_CMD_AT_VPATH, atAtVPATH,test_gen, queatAtVPATH,"%s: (0-2)"},
+    {"@VSEL",	AT_CMD_AT_VSEL,  atAtVSEL, test_gen, queatAtVSEL, "%s: (0,1)"},
 #endif
     {"@SND",	AT_CMD_AT_SND,   atAtSND,	0,	0,	0},
     {"@E1",	AT_CMD_AT_E1,    atAtE1,	0,	0,	0},
--- a/src/g23m-aci/aci/hl_audio_drv.c	Mon Mar 18 17:56:04 2019 +0000
+++ b/src/g23m-aci/aci/hl_audio_drv.c	Wed Mar 27 22:18:35 2019 +0000
@@ -29,6 +29,9 @@
 #include "aci.h"
 #include "psa.h"
 #include "hl_audio_drv.h"
+#include "rv/rv_general.h"
+#include "audio/audio_api.h"
+#include "fc-target.cfg"
 
 #ifdef VOCODER_FUNC_INTERFACE
 #include "l4_tim.h"
@@ -43,6 +46,10 @@
 GLOBAL T_HL_VOCODER_ACTION currVocoderAction;
 #endif
 
+#ifdef CONFIG_TARGET_FCDEV3B
+GLOBAL UBYTE aci_digital_voice_autoswitch;
+#endif
+
 /* This flag helps enable the vocoder interface testing for
    specific tescases 
 */
@@ -101,6 +108,12 @@
 */
 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach)
 {
+#ifdef CONFIG_TARGET_FCDEV3B
+  T_AUDIO_VOICE_PATH_SETTING vpath;
+  T_AUDIO_FULL_ACCESS_WRITE audio_param;
+  T_RV_RETURN return_path = { NULL, 0 };
+#endif
+
   TRACE_FUNCTION("hl_drv_set_vocoder_state");
 
   #ifdef VOCODER_FUNC_INTERFACE
@@ -192,12 +205,30 @@
         enable_tch_vocoder(TRUE);
         vocoder_mute_dl (FALSE);      /* un-mute speaker    */
         vocoder_mute_ul (FALSE);      /* un-mute microphone */
+      #ifdef CONFIG_TARGET_FCDEV3B
+        if (aci_digital_voice_autoswitch)
+        {
+          vpath = AUDIO_BLUETOOTH_HEADSET;
+          audio_param.variable_indentifier = AUDIO_PATH_USED;
+          audio_param.data = &vpath;
+          audio_full_access_write(&audio_param, return_path);
+        }
+      #endif
       }
       else
       {
         vocoder_mute_dl (TRUE);       /* mute speaker    */
         vocoder_mute_ul (TRUE);       /* mute microphone */
         enable_tch_vocoder (FALSE);   /* disable vocoder */
+      #ifdef CONFIG_TARGET_FCDEV3B
+        if (aci_digital_voice_autoswitch)
+        {
+          vpath = AUDIO_GSM_VOICE_PATH;
+          audio_param.variable_indentifier = AUDIO_PATH_USED;
+          audio_param.data = &vpath;
+          audio_full_access_write(&audio_param, return_path);
+        }
+      #endif
       }
     #endif /* _SIMULATION_ */
     #endif /* VOCODER_FUNC_INTERFACE */