FreeCalypso > hg > fc-magnetite
changeset 247:294c26c07561
aci3: started adding Openmoko and FreeCalypso AT commands
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Jul 2017 06:52:58 +0000 |
parents | a33da2d26a31 |
children | 35b17d54773d |
files | components/aci-tcs3 src/g23m-aci/aci/aci_cmh.h src/g23m-aci/aci/ati_audio.c src/g23m-aci/aci/ati_cmd.c |
diffstat | 4 files changed, 380 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/components/aci-tcs3 Mon Jul 24 06:18:10 2017 +0000 +++ b/components/aci-tcs3 Mon Jul 24 06:52:58 2017 +0000 @@ -150,6 +150,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/g23m-aci/aci/aci_cmh.h Mon Jul 24 06:18:10 2017 +0000 +++ b/src/g23m-aci/aci/aci_cmh.h Mon Jul 24 06:52:58 2017 +0000 @@ -518,6 +518,24 @@ #endif AT_CMD_P_PBCI, /* %PBCI command id */ AT_CMD_CVHU, /* +CVHU command id */ + /* Openmoko additions */ + AT_CMD_P_ST, /* sidetone level */ + AT_CMD_P_AUL, /* Audio Table Load */ + AT_CMD_P_POFF, /* Power Off GSM */ + AT_CMD_P_RST, /* Reset GSM */ + AT_CMD_P_BAND, /* Get RF band */ + /* FreeCalypso additions */ + AT_CMD_AT_SND, + AT_CMD_AT_E1, + AT_CMD_AT_E2, + AT_CMD_AT_E2LSI, + AT_CMD_AT_TONE, + AT_CMD_AT_TSTOP, + AT_CMD_AT_VMP, + AT_CMD_AT_VMPS, + AT_CMD_AT_VMR, + AT_CMD_AT_VMRS, + /* terminator */ AT_CMD_MAX, /* maximum command id */ AT_CMD_BIGGEST = 0x0000ffff /* To avoid the lint warning 650 */ } T_ACI_AT_CMD;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/g23m-aci/aci/ati_audio.c Mon Jul 24 06:52:58 2017 +0000 @@ -0,0 +1,320 @@ +/* + * 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. + * + * Our corrected implementation of the AT@AUL command (originally added + * by Openmoko) has been moved into this module as well. + */ + +#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 */ +} + +/* + * PURPOSE : @AUL command (Audio table load) + */ + +static char aul_name[AUDIO_MODE_FILENAME_MAX_SIZE]; + +GLOBAL T_ATI_RSLT atAtAUL (char *cl, UBYTE srcId) +{ + T_AUDIO_MODE_LOAD aul_param; + T_RV_RETURN return_path; + + TRACE_FUNCTION("atAtAUL()"); + + cl = parse(cl, "S", (LONG)(sizeof(aul_param.audio_mode_filename)), + aul_param.audio_mode_filename); + if (!cl || !aul_param.audio_mode_filename[0]) + return (ATI_FAIL); + + /* Openmoko backward compatibility */ + if (isdigit(aul_param.audio_mode_filename[0]) && + !aul_param.audio_mode_filename[1]) + sprintf(aul_param.audio_mode_filename, "para%c", + aul_param.audio_mode_filename[0]); + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_mode_load(&aul_param, return_path) == AUDIO_OK) { + strcpy(aul_name, aul_param.audio_mode_filename); + return (ATI_CMPL); + } else + return (ATI_FAIL); +} + +GLOBAL T_ATI_RSLT queatAtAUL (char *cl, UBYTE srcId) +{ + char *me="@AUL: "; + + TRACE_FUNCTION("queatAtAUL()"); + + if (aul_name[0]) + sprintf(g_sa, "%s/aud/%s.cfg", me, aul_name); + else + sprintf(g_sa, "%s", me); + + io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); + + return (ATI_CMPL); +} + +/* 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; + + cl = parse(cl, "S", (LONG)(sizeof(e1_param.melody_name)), + e1_param.melody_name); + if (!cl || !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; + + cl = parse(cl, "S", (LONG)(sizeof(e2_param.melody_E2_name)), + e2_param.melody_E2_name); + if (!cl || !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; + + cl = parse(cl, "S", (LONG)(sizeof(e2_lsi_param.melody_E2_file_name)), + e2_lsi_param.melody_E2_file_name); + if (!cl || !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); +} + +/* AT@TONE - exercise TONES through RiViera Audio Service API */ +GLOBAL T_ATI_RSLT atAtTONE ( char *cl, UBYTE srcId ) +{ + int tone_start[3], tone_stop[3], tone_freq[3], tone_ampl[3]; + int frame_dur, sequence_dur, period_dur, repetition; + int i; + T_AUDIO_TONES_PARAMETER t; + T_RV_RETURN return_path; + + cl = parse(cl, "DDDDDDDDDDDDDDDD", + &tone_start[0], &tone_stop[0], &tone_freq[0], &tone_ampl[0], + &tone_start[1], &tone_stop[1], &tone_freq[1], &tone_ampl[1], + &tone_start[2], &tone_stop[2], &tone_freq[2], &tone_ampl[2], + &frame_dur, &sequence_dur, &period_dur, &repetition); + if (!cl) + return (ATI_FAIL); + for (i = 0; i < 3; i++) { + t.tones[i].start_tone = tone_start[i]; + t.tones[i].stop_tone = tone_stop[i]; + t.tones[i].frequency_tone = tone_freq[i]; + t.tones[i].amplitude_tone = -tone_ampl[i]; + } + t.frame_duration = frame_dur; + t.sequence_duration = sequence_dur; + t.period_duration = period_dur; + t.repetition = repetition; + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_tones_start(&t, return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +/* AT@TSTOP - stop tones started with AT@TONE */ +GLOBAL T_ATI_RSLT atAtTSTOP ( char *cl, UBYTE srcId ) +{ + T_RV_RETURN return_path; + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_tones_stop(return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +/* AT@VMP - play back a voice memo recording */ +GLOBAL T_ATI_RSLT atAtVMP ( char *cl, UBYTE srcId ) +{ + T_AUDIO_VM_PLAY_PARAMETER play_param; + T_RV_RETURN return_path; + + cl = parse(cl, "S", (LONG)(sizeof(play_param.memo_name)), + play_param.memo_name); + if (!cl || !play_param.memo_name[0]) + return (ATI_FAIL); + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_vm_play_start(&play_param, return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +/* AT@VMPS - stop VM play started with AT@VMP */ +GLOBAL T_ATI_RSLT atAtVMPS ( char *cl, UBYTE srcId ) +{ + T_RV_RETURN return_path; + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_vm_play_stop(return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +static const T_AUDIO_TONES_PARAMETER recorder_warning_tone = { + 0, 500, 1400, -5, + 0, 500, 0, 0, + 0, 500, 0, 0, + 500, 500, 15000, TONE_INFINITE +}; + +/* AT@VMR - record a voice memo */ +GLOBAL T_ATI_RSLT atAtVMR ( char *cl, UBYTE srcId ) +{ + T_AUDIO_VM_RECORD_PARAMETER record_param; + int duration = 0, compression = 0; + LONG mic_gain = 0x100, network_gain = 0x100; + T_RV_RETURN return_path; + + cl = parse(cl, "Sddyy", (LONG)(sizeof(record_param.memo_name)), + record_param.memo_name, &duration, &compression, + &mic_gain, &network_gain); + if (!cl || !record_param.memo_name[0] || !duration) + return (ATI_FAIL); + record_param.memo_duration = duration; + record_param.compression_mode = compression; + record_param.microphone_gain = mic_gain; + record_param.network_gain = network_gain; + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_vm_record_start(&record_param, + (T_AUDIO_TONES_PARAMETER *) + &recorder_warning_tone, + return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +/* AT@VMRS - stop VM recording started with AT@VMR */ +GLOBAL T_ATI_RSLT atAtVMRS ( char *cl, UBYTE srcId ) +{ + T_RV_RETURN return_path; + + return_path.addr_id = NULL; + return_path.callback_func = audio_callback; + if (audio_vm_record_stop(return_path) == AUDIO_OK) + return (ATI_CMPL); + else + return (ATI_FAIL); +} + +#endif /* ATI_AUDIO_C */
--- a/src/g23m-aci/aci/ati_cmd.c Mon Jul 24 06:18:10 2017 +0000 +++ b/src/g23m-aci/aci/ati_cmd.c Mon Jul 24 06:52:58 2017 +0000 @@ -730,6 +730,27 @@ EXTERN T_ATI_RSLT setatPlusCVHU( char *cl, UBYTE srcId); EXTERN T_ATI_RSLT queatPlusCVHU( char *cl, UBYTE srcId); +/* Openmoko 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); +EXTERN T_ATI_RSLT queatAtAUL (CHAR *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtPOFF (CHAR *cl, UBYTE srcId); +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); +EXTERN T_ATI_RSLT atAtTONE (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtTSTOP (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtVMP (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtVMPS (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtVMR (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT atAtVMRS (char *cl, UBYTE srcId); + LOCAL const ATCommand_bas cmds_bas[] = { {"A", atA, 0, 0 }, @@ -1161,6 +1182,26 @@ {"%CMGRS", AT_CMD_P_CMGRS, setatPercentCMGRS, test_gen, queatPercentCMGRS, "%s: (0-2)"}, #endif /* REL99 */ {"+CVHU", AT_CMD_CVHU, setatPlusCVHU, test_gen, queatPlusCVHU, "%s: (0-2)"}, + /* Openmoko additions */ + {"@AUL", AT_CMD_P_AUL, atAtAUL, test_gen, queatAtAUL, "%s: (0)"}, +#if 0 + {"@ST", AT_CMD_P_ST, atAtST, test_gen, queatAtST, "%s: (-26,-23,-20,-17,-14,-11,-8,-5,-2,1)"}, + {"@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}, +#endif + /* 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}, + {"@TONE", AT_CMD_AT_TONE, atAtTONE, 0, 0, 0}, + {"@TSTOP", AT_CMD_AT_TSTOP, atAtTSTOP, 0, 0, 0}, + {"@VMP", AT_CMD_AT_VMP, atAtVMP, 0, 0, 0}, + {"@VMPS", AT_CMD_AT_VMPS, atAtVMPS, 0, 0, 0}, + {"@VMR", AT_CMD_AT_VMR, atAtVMR, 0, 0, 0}, + {"@VMRS", AT_CMD_AT_VMRS, atAtVMRS, 0, 0, 0}, + /* terminator */ {NULL,AT_CMD_NONE,NULL,NULL,NULL,NULL} };