changeset 226:67fe1b3f4bd7

aci2: added some AT commands for exercising audio functions
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Oct 2016 08:39:11 +0000
parents b16d79c550a2
children 763120534e54
files components/aci-classic src/aci2/aci/aci_cmh.h src/aci2/aci/ati_audio.c src/aci2/aci/ati_cmd.c
diffstat 4 files changed, 164 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/components/aci-classic	Mon Oct 24 05:50:25 2016 +0000
+++ b/components/aci-classic	Mon Oct 24 08:39:11 2016 +0000
@@ -145,6 +145,7 @@
 
 cfile_str2ind $SRCDIR/ati_src_rvt.c
 cfile_str2ind $SRCDIR/ati_omcompat.c
+cfile_str2ind $SRCDIR/ati_audio.c
 
 # ACI stuff
 cfile_str2ind $SRCDIR/aci_aci.c
--- a/src/aci2/aci/aci_cmh.h	Mon Oct 24 05:50:25 2016 +0000
+++ b/src/aci2/aci/aci_cmh.h	Mon Oct 24 08:39:11 2016 +0000
@@ -471,12 +471,19 @@
   AT_CMD_P_CMGMDU  =  248,     /* %CMGMDU command id */
   AT_CMD_P_CMGL    =  249,
   AT_CMD_P_CMGR    =  250,
+  /* Openmoko additions */
   AT_CMD_P_ST	     =  251,	/* sidetone level */
   AT_CMD_P_AUL	   =  252,	/* Audio Table Load */
   AT_CMD_P_POFF		 =  253,  /* Power Off GSM */
   AT_CMD_P_RST		 =  254,  /* Reset GSM */
   AT_CMD_P_SC		 =  255,  /* Set IMEI */
   AT_CMD_P_BAND		 =  256,  /* Get RF band */
+  /* FreeCalypso additions */
+  AT_CMD_AT_SND,
+  AT_CMD_AT_E1,
+  AT_CMD_AT_E2,
+  AT_CMD_AT_E2LSI,
+  /* terminator */
   AT_CMD_MAX                  /* maximum command id */
 } T_ACI_AT_CMD;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/aci2/aci/ati_audio.c	Mon Oct 24 08:39:11 2016 +0000
@@ -0,0 +1,142 @@
+/*
+ * This ATI module and the AT commands implemented therein are a FreeCalypso
+ * addition.  The purpose of these AT commands is to exercise the audio
+ * capabilities of the firmware - by using these commands, you should be
+ * able to emit sounds from the speaker or record voice from the microphone
+ * without needing to be in a call, and without bringing up GSM at all.
+ */
+
+#ifndef ATI_AUDIO_C
+#define ATI_AUDIO_C
+
+#include "aci_all.h"
+
+#include <ctype.h>
+#include <string.h>
+
+#include "aci_cmh.h"
+#include "ati_cmd.h"
+#include "aci_cmd.h"
+#include "aci_io.h"
+#include "aci_cmd.h"
+#include "l4_tim.h"
+#include "line_edit.h"
+#include "aci_lst.h"
+
+#include "pcm.h"
+#include "audio.h"
+#include "aci.h"
+#include "rx.h"
+#include "pwr.h"
+#include "l4_tim.h"
+
+#ifdef GPRS
+#ifdef DTI
+#include "dti.h"
+#include "dti_conn_mng.h"
+#include "dti_cntrl_mng.h"
+#endif /* DTI */
+#include "gaci.h"
+#include "gaci_cmh.h"
+#include "gaci_cmd.h"
+#endif  /* GPRS */
+
+#include "aci_mem.h"
+#include "aci_prs.h"
+
+#include "ati_int.h"
+
+#ifndef _SIMULATION_
+#include "ffs/ffs.h"
+#endif
+
+#ifdef FF_ATI_BAT
+
+#include "typedefs.h"
+#include "gdd.h"
+#include "bat.h"
+
+#include "ati_bat.h"
+
+#endif /*FF_ATI_BAT*/
+
+#include "audio/audio_api.h"
+#include "audio.h"	/* Condat */
+
+/* AT@SND - emit sound through Condat API */
+GLOBAL T_ATI_RSLT atAtSND ( char *cl, UBYTE srcId )
+{
+	UBYTE sound_id = TONES_KEYBEEP;
+
+	cl = parse(cl, "x", &sound_id);
+	audio_PlaySoundID(AUDIO_SPEAKER, sound_id, 0, AUDIO_PLAY_ONCE);
+	return (ATI_CMPL);
+}
+
+static void audio_callback(void *event_from_audio)
+{
+	/* do nothing at this time */
+}
+
+/* AT@E1 - play an E1 format melody */
+GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E1_PARAMETER e1_param;
+	T_RV_RETURN return_path;
+
+	e1_param.melody_name[0] = 0;
+	cl = parse(cl, "s", (LONG)(sizeof(e1_param.melody_name) - 1),
+		   e1_param.melody_name);
+	if (!e1_param.melody_name[0])
+		return (ATI_FAIL);
+	e1_param.loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE;
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK)
+		return (ATI_CMPL);
+	else
+		return (ATI_FAIL);
+}
+
+/* AT@E2 - play an E2 format melody */
+GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E2_PARAMETER e2_param;
+	T_RV_RETURN return_path;
+
+	e2_param.melody_E2_name[0] = 0;
+	cl = parse(cl, "s", (LONG)(sizeof(e2_param.melody_E2_name) - 1),
+		   e2_param.melody_E2_name);
+	if (!e2_param.melody_E2_name[0])
+		return (ATI_FAIL);
+	e2_param.E2_loopback = AUDIO_MELODY_NO_LOOPBACK;
+	e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE;
+
+	return_path.addr_id        = NULL;
+	return_path.callback_func  = audio_callback;
+	if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK)
+		return (ATI_CMPL);
+	else
+		return (ATI_FAIL);
+}
+
+/* AT@E2LSI - load melody E2 instrument list file */
+GLOBAL T_ATI_RSLT atAtE2LSI ( char *cl, UBYTE srcId )
+{
+	T_AUDIO_MELODY_E2_LOAD_FILE_INSTR_PARAMETER e2_lsi_param;
+
+	e2_lsi_param.melody_E2_file_name[0] = 0;
+	cl = parse(cl, "s", (LONG)(sizeof(e2_lsi_param.melody_E2_file_name)-1),
+		   e2_lsi_param.melody_E2_file_name);
+	if (!e2_lsi_param.melody_E2_file_name[0])
+		return (ATI_FAIL);
+
+	if (audio_melody_E2_load_file_instruments(&e2_lsi_param) == AUDIO_OK)
+		return (ATI_CMPL);
+	else
+		return (ATI_FAIL);
+}
+
+#endif /* ATI_AUDIO_C */
--- a/src/aci2/aci/ati_cmd.c	Mon Oct 24 05:50:25 2016 +0000
+++ b/src/aci2/aci/ati_cmd.c	Mon Oct 24 08:39:11 2016 +0000
@@ -662,7 +662,7 @@
 
 EXTERN T_ATI_RSLT tesatPercentCMGL(CHAR *cl, UBYTE srcId);
 
-/* FreeCalypso replicating Openmoko's additions */
+/* Openmoko's additions */
 EXTERN T_ATI_RSLT atAtST (CHAR *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT queatAtST (CHAR *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtAUL (CHAR *cl, UBYTE srcId);
@@ -671,6 +671,12 @@
 EXTERN T_ATI_RSLT atAtRST (CHAR *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtBAND (CHAR *cl, UBYTE srcId);
 
+/* FreeCalypso additions */
+EXTERN T_ATI_RSLT atAtSND (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtE1 (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtE2 (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtE2LSI (char *cl, UBYTE srcId);
+
 LOCAL const ATCommand_bas cmds_bas[] =
 {
   {"A", atA,       0,       0     },
@@ -1051,11 +1057,18 @@
     {"%CMGMDU",    AT_CMD_P_CMGMDU,   setatPercentCMGMDU, 0,        0,                0},
     {"%CMGL",          AT_CMD_P_CMGL, atPercentCMGL,      tesatPercentCMGL, NULL,      0},
     {"%CMGR",          AT_CMD_P_CMGR, atPercentCMGR,      NULL,             NULL,      0},
+    /* Openmoko additions */
     {"@ST",       AT_CMD_P_ST,   atAtST,       test_gen,       queatAtST,    "%s: (-26,-23,-20,-17,-14,-11,-8,-5,-2,1)"},
     {"@AUL",       AT_CMD_P_AUL,   atAtAUL,       test_gen,       queatAtAUL,    "%s: (0)"},
     {"@POFF",       AT_CMD_P_POFF,   atAtPOFF,       0,       0,    0},
     {"@RST",       AT_CMD_P_RST,   atAtRST,       0,       0,    0},
     {"@BAND",     AT_CMD_P_BAND,   atAtBAND,     0,       0,    0},
+    /* FreeCalypso additions */
+    {"@SND",	AT_CMD_AT_SND,   atAtSND,	0,	0,	0},
+    {"@E1",	AT_CMD_AT_E1,    atAtE1,	0,	0,	0},
+    {"@E2",	AT_CMD_AT_E2,    atAtE2,	0,	0,	0},
+    {"@E2LSI",	AT_CMD_AT_E2LSI, atAtE2LSI,	0,	0,	0},
+    /* terminator */
     {NULL,0,0,0,0,0}
 };