[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.bin b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.bin
new file mode 100644
index 0000000..20f44b7
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.bin
@@ -0,0 +1,34 @@
+all: $(DIR_MAKEFILE)/audio-ctrl-service-bin
+
+LDFLAGS= -Wl,--hash-style=gnu -Wl,--copy-dt-needed-entries
+
+INCLUDE= ${BB_INCLUDE_ADD} \
+ -I./$(DIR_MAKEFILE) \
+ -I=${includedir}/libspeech_drv \
+ -I=${includedir}
+
+CSRC= $(DIR_MAKEFILE)/audio-ctrl-service.c
+
+LIB_INCLUDE = -llog \
+ -lxml2 \
+ -lpthread \
+ -lfake_libspeech_drv \
+ -lspeech_drv \
+ -lasound \
+ -lmodemafectrl \
+ -lsamplerate \
+ -laudioparamparser
+
+CFLAGS = -DMTK_YOCTO_AUDIO \
+ -DMTK_SPEECH_VM_SUPPORT \
+ -DMTK_SPEECH_BGS_SUPPORT \
+# -DMTK_AUDIO_BRINGUP \
+# -DMTK_DUMMY_AUDIO_PARSER \
+# -DMTK_SPH_PARAM_V1 \
+# -DMTK_SPEECH_RECORD_SUPPORT \
+
+$(DIR_MAKEFILE)/audio-ctrl-service-bin:
+ $(CC) ${CSRC} ${LDFLAGS} ${CFLAGS} $(INCLUDE) $(LIB_INCLUDE) -o audio-ctrl-service
+
+clean:
+ rm -f audio-ctrl-service
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.interface b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.interface
new file mode 100644
index 0000000..fe23f22
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/Makefile.interface
@@ -0,0 +1,14 @@
+all: $(DIR_MAKEFILE)/audio-ctrl-service-interface
+
+$(DIR_MAKEFILE)/audio-ctrl-service-interface:
+ $(CC) -c -fPIC -I./$(DIR_MAKEFILE) $(DIR_MAKEFILE)/audio-ctrl-service-interface.c
+ install -d $(DIR_MAKEFILE)
+ install -d $(BUILD_OBJ)
+ mv *.o $(BUILD_OBJ)
+ $(CXX) -shared -Wl,-soname,libaudio-ctrl-service-interface.so.1 -o libaudio-ctrl-service-interface.so.1.0.0 $(BUILD_OBJ)/*.o
+ cp -af $(DIR_MAKEFILE)/audio_ctrl_service_api.h ./
+
+clean:
+ rm -rf $(BUILD_OBJ)
+ rm -f libaudio-ctrl-service-interface.so.1.0.0
+ rm -f audio_ctrl_service_api.h
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service-interface.c b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service-interface.c
new file mode 100644
index 0000000..ab4f8fe
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service-interface.c
@@ -0,0 +1,404 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <stdint.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <semaphore.h>
+#include "audio_ctrl_service_inner_api.h"
+
+enum {
+ UPPER_CALL,
+ LOWER_CALL,
+};
+
+static int do_IPC_call(const char *cmd, int dir);
+static int do_IPC_call_with_size(const char *cmd, int size, int dir);
+static int do_IPC_call_with_return_data(const char *cmd, char *dest,
+ int dest_size, int dir);
+static int do_IPC_call_general(const char *cmd, int size, char *dest,
+ int dest_size, int dir);
+
+//#define IPC_SEQ_DEBUG
+
+//turn on or off speech
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_speech_on(int speech_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SPEECH_ON, speech_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//turn on or off ecall_speech
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_ecall_speech_on(int speech_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_ECALL_ON, speech_on);
+ return do_IPC_call(buf, UPPER_CALL);
+ }
+
+//turn on or off M2M speech
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_M2M_speech_on(int speech_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_M2M_CALL_ON, speech_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+//turn on or off BT speech
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_bt_speech_on(int speech_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_BT_SPEECH_ON, speech_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//set dl gain (-64dB~17dB)
+//return value: default device setting
+int audio_ctrl_service_set_dl_volume(int Db) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_DL_VOLUME, Db);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//data cb from modem
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_record_data_cb(int data_size, const char *data) {
+ static char buf[IPC_DATA_SIZE_MAX]; //need larger size for record data
+ int str_length;
+ int ret = 0;
+ str_length = sprintf(buf, "%d,%d,",
+ FUNC_AUDIO_CTRL_INCALL_SERVICE_RECORD_DATA_CB,
+ data_size);
+ memcpy(&buf[str_length], data, data_size);
+ return do_IPC_call_with_size(buf, data_size + str_length, LOWER_CALL);
+}
+
+//start record data from modem (buf_size in bytes)
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_record_start(int buf_size) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_INCALL_RECORD_START, buf_size);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//stop record data from modem
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_record_stop() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_INCALL_RECORD_STOP);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//pointer of buffer in audio-ctrl-service
+//return value: if success, return pointer location (in bytes)
+// or a negitive error number
+int audio_ctrl_service_inCall_record_pointer() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_INCALL_RECORD_POINTER);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//record watermark
+//return value: if success, return watermark (in bytes)
+// or a negitive error number
+int audio_ctrl_service_inCall_record_get_watermark() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_INCALL_RECORD_GET_WATERMARK);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//read data from audio-ctrl-service(in bytes)
+//now only support 16bits record
+//return value: if success, return read size (in bytes)
+// or a negitive error number
+int audio_ctrl_service_inCall_record_get_data(int data_size, char *dest) {
+ static char buf[16];
+ char *ret_ptr;
+ assert(dest);
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_INCALL_RECORD_GET_DATA,
+ data_size);
+ return do_IPC_call_with_return_data(buf, dest, data_size, UPPER_CALL);
+}
+
+//start send data to modem
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_playback_start() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_INCALL_PLAYBACK_START);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//stop send data to modem
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_playback_stop() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_INCALL_PLAYBACK_STOP);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//playback send data to modem
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_inCall_playback_send_data(int data_size, const char *data) {
+ static char buf[IPC_DATA_SIZE_MAX]; //need larger size for playback data
+ int str_length;
+
+ str_length = sprintf(buf, "%d,%d,",
+ FUNC_AUDIO_CTRL_INCALL_PLAYBACK_SEND_DATA,
+ data_size);
+ memcpy(&buf[str_length], data, data_size);
+ return do_IPC_call_with_size(buf, data_size + str_length, UPPER_CALL);
+}
+
+//check if speech on or off
+//return value: 0 if off, positive num if on, or a negitive error number
+int audio_ctrl_service_is_speech_on() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_IS_SPEECH_ON);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//check if speech on or off
+//return value: 0 if off, positive num if on, or a negitive error number
+int audio_ctrl_service_is_bt_speech_on() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_IS_BT_SPEECH_ON);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get speech dl gain
+//return value: dl gain value (in dB)
+int audio_ctrl_service_get_dl_gain() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_DL_GAIN);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get record period size
+//return value: positive number for period size(in bytes), or a negitive error number
+int audio_ctrl_service_get_record_period_size() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_PERIOD_SIZE);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get max record buffer size
+//return value: positive number for buffer size(in bytes), or a negitive error number
+int audio_ctrl_service_get_record_max_buffer_size() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_MAX_BUFFER_SIZE);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get playback period size
+//return value: positive number for period size(in bytes), or a negitive error number
+int audio_ctrl_service_get_playback_period_size() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_PERIOD_SIZE);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get max playback buffer size
+//return value: positive number for buffer size(in bytes), or a negitive error number
+int audio_ctrl_service_get_playback_max_buffer_size() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_MAX_BUFFER_SIZE);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//turn on/off vmlog
+//return value: from libspeech_drv
+int audio_ctrl_service_vmlog_on(int vmlog_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_VMLOG_ON, vmlog_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get vmlog on/off status
+//return value: 1 for vmlog on and 0 for vmlog off
+int audio_ctrl_service_get_vmlog_on() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_VMLOG_ON);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get bt_wbs on/off status
+//return value: 1 for vmlog on and 0 for vmlog off
+int audio_ctrl_service_get_bt_wbs() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_BT_WBS);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//set on/off bt_wbs
+//return value: from libspeech_drv
+int audio_ctrl_service_set_bt_wbs(int bt_wbs_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_BT_WBS, bt_wbs_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//set bt dl gain (0 ~ 15)
+//return value: 0 if success, or a negitive error number
+int audio_ctrl_service_set_bt_dl_gain(int vol) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_BT_DL_GAIN, vol);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get bt dl gain
+//return value: bt dl value
+int audio_ctrl_service_get_bt_dl_gain() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_BT_DL_GAIN);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get BT_HAS_ECNR on/off status
+//return value: 1 for vmlog on and 0 for vmlog off
+int audio_ctrl_service_get_bt_client_has_ecnr() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_BT_CLIENT_HAS_ECNR);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//set on/off BT_HAS_ECNR
+//return value: from libspeech_drv
+int audio_ctrl_service_set_bt_client_has_ecnr(int bt_client_ecnr_on) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_BT_CLIENT_HAS_ECNR, bt_client_ecnr_on);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//get SWITCH_BT_IN_CALL on/off status
+//return value: 1 for vmlog on and 0 for vmlog off
+int audio_ctrl_service_get_use_bt_in_call() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_GET_USE_BT_IN_CALL);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//switch BT on/off during call
+//return value: from libspeech_drv
+int audio_ctrl_service_set_use_bt_in_call(int turn_on_bt_in_call) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_USE_BT_IN_CALL, turn_on_bt_in_call);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//modem reset
+//return value: 0 (always success)
+int audio_ctrl_service_reset() {
+ static char buf[16];
+ sprintf(buf, "%d", FUNC_AUDIO_CTRL_SERVICE_RESET_INNER);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+//DL:0 /UL:1 mute
+//return value: 0 (always success)
+int audio_ctrl_service_set_mute(int path, int is_mute) {
+ static char buf[16];
+ if (path == SPEECH_DL) {
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_DL_MUTE, is_mute);
+ return do_IPC_call(buf, UPPER_CALL);
+ } else {
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_SET_UL_MUTE, is_mute);
+ return do_IPC_call(buf, UPPER_CALL);
+ }
+}
+
+int audio_ctrl_service_get_mute(int path) {
+ static char buf[16];
+ sprintf(buf, "%d,%d", FUNC_AUDIO_CTRL_SERVICE_GET_MUTE, path);
+ return do_IPC_call(buf, UPPER_CALL);
+}
+
+/*
+ * private method for IPC call interface
+ */
+static inline int do_IPC_call(const char *cmd, int dir) {
+ return do_IPC_call_general(cmd, 0, 0, 0, dir);
+}
+
+static inline int do_IPC_call_with_size(const char *cmd, int size, int dir) {
+ return do_IPC_call_general(cmd, size, 0, 0, dir);
+}
+
+static int do_IPC_call_with_return_data(const char *cmd, char *dest,
+ int dest_size, int dir) {
+ return do_IPC_call_general(cmd, 0, dest, dest_size, dir);
+}
+
+#define AUDIO_CTRL_SERVICE_IPC_UPPER_SEM "AUDIO_CTRL_SERVICE_IPC_UPPER_SEM"
+#define AUDIO_CTRL_SERVICE_IPC_LOWER_SEM "AUDIO_CTRL_SERVICE_IPC_LOWER_SEM"
+
+static int do_IPC_call_general(const char *cmd, int size, char *dest,
+ int dest_size, int dir) {
+ int send_cmd_handler;
+ int receive_cmd_handler;
+ int read_size, call_result, record_size;
+ static char buf[IPC_DATA_SIZE_MAX];
+ char *data_str;
+ int ret;
+ sem_t *sem_ipc;
+#ifdef IPC_SEQ_DEBUG
+ int cmd_int;
+
+ cmd_int = atoi(cmd);
+ printf("%s, cmd_int: %d, size: %d\n", __func__, cmd_int, size);
+ fflush(stdout);
+#endif
+
+ if (dir == UPPER_CALL) {
+ sem_ipc = sem_open(AUDIO_CTRL_SERVICE_IPC_UPPER_SEM, O_CREAT, 0644, 1);
+ if (sem_ipc == SEM_FAILED) {
+ printf("%s sem_open failed, WTF = = \n", __func__);
+ return errno;
+ }
+ sem_wait(sem_ipc);
+
+ send_cmd_handler = open(ACS_IPC_FOR_UPPER_RCV, O_WRONLY);
+ receive_cmd_handler = open(ACS_IPC_FOR_UPPER_SEND, O_RDONLY);
+ } else { /*LOWER_CALL*/
+ sem_ipc = sem_open(AUDIO_CTRL_SERVICE_IPC_LOWER_SEM, O_CREAT, 0644, 1);
+ if (sem_ipc == SEM_FAILED) {
+ printf("%s sem_open failed, WTF = = \n", __func__);
+ return errno;
+ }
+ sem_wait(sem_ipc);
+
+ send_cmd_handler = open(ACS_IPC_FOR_LOWER_RCV, O_WRONLY);
+ receive_cmd_handler = open(ACS_IPC_FOR_LOWER_SEND, O_RDONLY);
+ }
+
+ if (!size) {
+ write(send_cmd_handler, cmd, strlen(cmd));
+ } else {
+ write(send_cmd_handler, cmd, size);
+ }
+
+ read_size = read(receive_cmd_handler, buf, IPC_DATA_SIZE_MAX);
+ buf[read_size] = '\0';
+
+ close(receive_cmd_handler);
+ close(send_cmd_handler);
+
+ if (!dest) { //no extra data contained
+ call_result = atoi(buf);
+ } else {
+ strtok_r(buf, ",", &data_str);
+ call_result = atoi(buf);
+ record_size = read_size - (data_str - buf);
+ assert(dest_size >= record_size);
+ memcpy(dest, data_str, record_size);
+ }
+
+ sem_post(sem_ipc);
+
+ return call_result;
+}
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service.c b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service.c
new file mode 100644
index 0000000..eb63e4b
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio-ctrl-service.c
@@ -0,0 +1,1358 @@
+#include "AudioParamParser.h"
+#include "AudioParamParserPriv.h"
+#include "xml_parser_def.h"
+#include "default_para.h"
+#include "speech_drv.h"
+#include "modem_afe_ctrl.h"
+#include "audio_ctrl_service_inner_api.h"
+
+#include "speech_UT_header.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <syslog.h>
+#include <samplerate.h>
+
+//#define RECORD_USE_UT_SOURCE
+//#define PLAYBACK_USE_UT_SINK
+#include <log/log.h>
+#define ALOGD SLOGD
+#define ALOGI SLOGI
+#define ALOGW SLOGW
+#define ALOGE SLOGE
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "audio-ctrl-service"
+
+//#define UT_LOG
+#ifdef UT_LOG
+#define AUDIO_V_LOG ALOGD
+#else
+#define AUDIO_V_LOG
+#endif
+
+#define SPEECH_DRV_RETRY_TIME 3
+#define SPEECH_DRV_RETRY_US 20000 //20ms
+#define SPEECH_DRV_BGS_INTERVAL_US 20000 //20ms
+
+#define MAX_REC_BUF_SIZE 3200//16000Hz 16bytes 100ms
+#define MD_PCM_RECORD_HEADER_SYNC 0x1234
+
+char *g_record_buf;
+int g_want_to_speech_off_after_record_off;
+
+int g_record_buf_size;
+int g_record_read_virt_idx;
+int g_record_write_virt_idx;
+int g_record_virt_boundry;
+
+int g_is_bgs_on;
+
+/* SRC for inCall record UL*/
+
+#define RECORD_SRC_BUF_SIZE 160 //in frame
+#define RECORD_DST_BUF_SIZE 320 //in frame
+#define RECORD_SRC_RATIO 2.0
+const int g_converter_type = SRC_SINC_MEDIUM_QUALITY;
+SRC_DATA g_incall_record_src_data;
+SRC_STATE *g_incall_record_src_state;
+float *g_incall_record_src_buffer;
+float *g_incall_record_dst_buffer;
+int16_t g_incall_record_dst_int_buffer[RECORD_DST_BUF_SIZE];
+
+pthread_mutex_t g_mutex_record = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t g_mutex_playback = PTHREAD_MUTEX_INITIALIZER;
+
+/* modem pcm record package header*/
+typedef struct md_pcm_record_header {
+ uint16_t u16SyncWord;
+ uint16_t u16RawPcmDir;
+ uint16_t u16Freq;
+ uint16_t u16Length;
+ uint16_t u16Channel;
+ uint16_t u16BitFormat;
+} MD_PCM_RECORD_HEADER;
+
+
+static void parameterChanged(AppHandle *appHandle, const char *audioTypeName);
+
+static void *speech_flow_upper_func_operator(void *arg);
+static void *speech_flow_lower_func_operator(void *arg);
+static void *speech_flow_dummy_sender(void *arg);
+
+static void updateVolume(int xmlType);
+static void updateDlGain(void);
+static void updateUlGain(void);
+
+const struct xml_param paramVolume[PARAM_NUM] = {
+ {
+ .id = XML_SPEECH_VOLUME,
+ .xml_type_name = "SpeechVol",
+ .update_xml_callback = updateVolume,
+ },
+ {
+ .id = XML_VOLUME,
+ .xml_type_name = "Volume",
+ .update_xml_callback = updateVolume,
+ },
+ {
+ .id = XML_GAIN_MAP_DL,
+ .xml_type_name = "VolumeGainMapUL",
+ .update_xml_callback = updateVolume,
+ },
+ {
+ .id = XML_GAIN_MAP_UL,
+ .xml_type_name = "VolumeGainMap",
+ .update_xml_callback = updateVolume,
+ },
+};
+#define DL_VOLUME_IDX_MIN 1
+#define DL_VOLUME_IDX_MAX 7
+
+static int g_is_speech_on;
+static int g_current_output_device;
+
+static int g_bt_wbs_on = FUNC_SET_BT_WB_default;
+static int g_bt_client_has_ecnr;
+static int g_volume_index;
+static int g_speaker_type;
+
+
+/* IPC variable*/
+static pthread_t g_pthread_speech_flow_upper_rcv;
+static pthread_t g_pthread_speech_flow_lower_rcv;
+static pthread_t g_pthread_speech_flow_dummy_send;
+
+static int g_ipc_upper_rcv_handler;
+static int g_ipc_upper_send_handler;
+static int g_ipc_lower_rcv_handler;
+static int g_ipc_lower_send_handler;
+
+
+int main() {
+ int paramIndex = 0;
+ AppOps *appOps = NULL;
+ AppHandle *appHandle = NULL;
+ struct stat st = {0};
+
+#if !defined(MTK_DUMMY_AUDIO_PARSER)
+ appOps = appOpsGetInstance();
+ if (appOps == NULL) {
+ ALOGE("%s(), line %d ERROR", __func__, __LINE__);
+ return 1;
+ } else {
+ appHandle = appOps->appHandleGetInstance();
+
+ /* Wait for initial done */
+ usleep(100 * 1000);//100ms
+
+ /* Set the debug level to warn*/
+ appOps->appSetDebugLevel(WARN_LEVEL);
+
+ /* register callback func */
+ appOps->appHandleRegXmlChangedCb(appHandle, parameterChanged);
+ }
+#endif
+ if (stat("/tmp/audio_ctrl_service", &st) == -1) {
+ mkdir("/tmp/audio_ctrl_service", 0700);
+ }
+
+ /* for service init */
+ mkfifo(ACS_IPC_FOR_UPPER_RCV, 0600);
+ mkfifo(ACS_IPC_FOR_UPPER_SEND, 0600);
+ mkfifo(ACS_IPC_FOR_LOWER_RCV, 0600);
+ mkfifo(ACS_IPC_FOR_LOWER_SEND, 0600);
+
+ pthread_create(&g_pthread_speech_flow_upper_rcv, NULL, speech_flow_upper_func_operator, NULL);
+ pthread_create(&g_pthread_speech_flow_lower_rcv, NULL, speech_flow_lower_func_operator, NULL);
+ pthread_create(&g_pthread_speech_flow_dummy_send, NULL, speech_flow_dummy_sender, NULL);
+
+ while (1) {
+ sleep(1000000);
+ }
+#if !defined(MTK_DUMMY_AUDIO_PARSER)
+ /* Release appHandle resources */
+ appOps->appHandleUninit(appHandle);
+#endif
+
+ return 0;
+}
+
+static void *speech_flow_upper_func_operator(void *arg) {
+ char buf[IPC_DATA_SIZE_MAX];
+ int size = 0, function_type = 0, first_param = 0;
+ int str_output_size = 0;
+ int func_result;
+ char *first_param_str;
+ char *second_param_str;
+ char buf_response[IPC_DATA_SIZE_MAX];
+ char *buf_for_get_data = buf; //use the buffer to get data out for ioplugin
+
+ ALOGD("%s()", __func__);
+ g_ipc_upper_rcv_handler = open(ACS_IPC_FOR_UPPER_RCV, O_RDONLY);
+ g_ipc_upper_send_handler = open(ACS_IPC_FOR_UPPER_SEND, O_WRONLY);
+ set_phonecall_rate(PHONECALL_SAMPLE_RATE);
+ g_volume_index = 4;//valid range: 0~7, 0 for mute
+ g_current_output_device = AUDIO_DEVICE_OUT_SPEAKER;
+ g_speaker_type = AUDIO_SPK_EXTAMP_LO;
+
+ while (1) {
+ size = read(g_ipc_upper_rcv_handler, buf, IPC_DATA_SIZE_MAX);
+ if (!size) {
+ ALOGE("%s(), IPC data size=%d, reset fifo!", __func__, size);
+ close(g_ipc_upper_rcv_handler);
+ g_ipc_upper_rcv_handler = open(ACS_IPC_FOR_UPPER_RCV, O_RDONLY);
+ continue;
+ }
+ /* finish string */
+ buf[size] = '\0';
+
+ /* parse string */
+ strtok_r(buf, ",", &first_param_str);
+ function_type = atoi(buf);
+ AUDIO_V_LOG("%s(), function_type=%d", __func__, function_type);
+ switch (function_type) {
+ case FUNC_AUDIO_CTRL_SERVICE_SPEECH_ON:
+ first_param = atoi(first_param_str);
+ pthread_mutex_lock(&g_mutex_record); //for g_want_to_speech_off_after_record_off
+ func_result = audio_ctrl_service_speech_on_inner(first_param, AUDIO_DEVICE_OUT_SPEAKER);
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_M2M_CALL_ON:
+ first_param = atoi(first_param_str);
+ strtok_r(first_param_str, ",", &second_param_str);
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_M2M_Call_on_inner(first_param);
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_ECALL_ON:
+ first_param = atoi(first_param_str);
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_ECall_on_inner(first_param);
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_DL_VOLUME:
+ case FUNC_AUDIO_CTRL_SERVICE_SET_BT_DL_GAIN:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_volume_index_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_BT_DL_GAIN:
+ func_result = audio_ctrl_service_get_volume_index_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_SPEAKER_TYPE:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_speaker_type_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+
+#if defined(MTK_SPEECH_RECORD_SUPPORT)
+ case FUNC_AUDIO_CTRL_INCALL_RECORD_START:
+ first_param = atoi(first_param_str);
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_start_inner(first_param);
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_RECORD_STOP:
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_stop_inner();
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_RECORD_POINTER:
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_pointer_inner();
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_RECORD_GET_WATERMARK:
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_get_watermark_inner();
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_RECORD_GET_DATA:
+ first_param = atoi(first_param_str);
+ //use the "buf" to get data out for ioplugin
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_get_data_inner
+ (first_param, buf_for_get_data);
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d,", func_result);
+ if (func_result > 0) {
+ memcpy(buf_response + str_output_size, buf_for_get_data,
+ func_result);
+ str_output_size += func_result;
+ }
+ break;
+#endif
+#if defined(MTK_SPEECH_BGS_SUPPORT)
+ case FUNC_AUDIO_CTRL_INCALL_PLAYBACK_START:
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_inCall_playback_start_inner();
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_PLAYBACK_STOP:
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_inCall_playback_stop_inner();
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_PLAYBACK_SEND_DATA:
+ first_param = atoi(first_param_str);
+ strtok_r(first_param_str, ",", &second_param_str);
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_inCall_playback_send_data_inner
+ (first_param, second_param_str);
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_INCALL_PLAYBACK_SIMULATION:
+ first_param = atoi(first_param_str);
+ pthread_mutex_lock(&g_mutex_playback);
+ func_result = audio_ctrl_service_inCall_playback_simulation(first_param);
+ pthread_mutex_unlock(&g_mutex_playback);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+#endif
+ case FUNC_AUDIO_CTRL_SERVICE_IS_SPEECH_ON:
+ func_result = audio_ctrl_service_is_speech_on_inner(AUDIO_DEVICE_OUT_SPEAKER);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_PERIOD_SIZE:
+ func_result = audio_ctrl_service_get_record_period_size_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_PERIOD_SIZE:
+ func_result = audio_ctrl_service_get_playback_period_size_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_MAX_BUFFER_SIZE:
+ func_result = audio_ctrl_service_get_record_max_buffer_size_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_MAX_BUFFER_SIZE:
+ func_result = audio_ctrl_service_get_playback_max_buffer_size_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+
+#if defined(MTK_SPEECH_VM_SUPPORT)
+ case FUNC_AUDIO_CTRL_SERVICE_VMLOG_ON:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_vmlog_on_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_VMLOG_ON:
+ func_result = audio_ctrl_service_get_vmlog_on_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+#endif
+ case FUNC_AUDIO_CTRL_SERVICE_BT_SPEECH_ON:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_speech_on_inner(first_param, AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_IS_BT_SPEECH_ON:
+ func_result = audio_ctrl_service_is_speech_on_inner(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_BT_WBS:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_bt_wbs_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_BT_WBS:
+ func_result = audio_ctrl_service_get_bt_wbs_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+#if !defined(MTK_AUDIO_BRINGUP)
+ case FUNC_AUDIO_CTRL_SERVICE_SET_BT_CLIENT_HAS_ECNR:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_bt_client_has_ecnr_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_BT_CLIENT_HAS_ECNR:
+ func_result = audio_ctrl_service_get_bt_client_has_ecnr_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_USE_BT_IN_CALL:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_use_bt_in_call_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+#endif
+ case FUNC_AUDIO_CTRL_SERVICE_GET_USE_BT_IN_CALL:
+ func_result = audio_ctrl_service_get_use_bt_in_call_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_RESET_INNER:
+ func_result = audio_ctrl_service_reset_inner();
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_DL_MUTE:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_mute_inner(SPEECH_DL, first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_SET_UL_MUTE:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_set_mute_inner(SPEECH_UL, first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ case FUNC_AUDIO_CTRL_SERVICE_GET_MUTE:
+ first_param = atoi(first_param_str);
+ func_result = audio_ctrl_service_get_mute_inner(first_param);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+ default:
+ break;
+ }
+
+ /*send result*/
+ write(g_ipc_upper_send_handler, buf_response, str_output_size);
+
+ }
+ close(g_ipc_upper_send_handler);
+ close(g_ipc_upper_rcv_handler);
+}
+
+static void *speech_flow_lower_func_operator(void *arg) {
+ char buf[IPC_DATA_SIZE_MAX];
+ int size = 0, function_type = 0, first_param = 0;
+ int str_output_size = 0;
+ int func_result;
+ char *first_param_str;
+ char *second_param_str;
+ char buf_response[IPC_DATA_SIZE_MAX];
+ char *buf_for_get_data = buf; //use the buffer to get data out for ioplugin
+
+ AUDIO_V_LOG("%s()", __func__);
+ g_ipc_lower_rcv_handler = open(ACS_IPC_FOR_LOWER_RCV, O_RDONLY);
+ g_ipc_lower_send_handler = open(ACS_IPC_FOR_LOWER_SEND, O_WRONLY);
+ while (1) {
+ size = read(g_ipc_lower_rcv_handler, buf, IPC_DATA_SIZE_MAX);
+ if (!size) {
+ ALOGE("%s(), IPC data size=%d, reset fifo!", __func__, size);
+ close(g_ipc_lower_rcv_handler);
+ g_ipc_lower_rcv_handler = open(ACS_IPC_FOR_LOWER_RCV, O_RDONLY);
+ continue;
+ }
+ /* finish string */
+ buf[size] = '\0';
+
+ /* parse string */
+ strtok_r(buf, ",", &first_param_str);
+ function_type = atoi(buf);
+ switch (function_type) {
+#if defined(MTK_SPEECH_RECORD_SUPPORT)
+ case FUNC_AUDIO_CTRL_INCALL_SERVICE_RECORD_DATA_CB:
+ first_param = atoi(first_param_str);
+ strtok_r(first_param_str, ",", &second_param_str);
+ pthread_mutex_lock(&g_mutex_record);
+ func_result = audio_ctrl_service_inCall_record_data_cb_inner
+ (first_param, second_param_str);
+ pthread_mutex_unlock(&g_mutex_record);
+ str_output_size = sprintf(buf_response, "%d", func_result);
+ break;
+#endif
+ default:
+ break;
+ }
+
+ /*send result*/
+ write(g_ipc_lower_send_handler, buf_response, str_output_size);
+
+ }
+ close(g_ipc_lower_send_handler);
+ close(g_ipc_lower_rcv_handler);
+}
+
+
+static void *speech_flow_dummy_sender(void *arg) {
+ int dummy_handler = 0;
+ AUDIO_V_LOG("%s()", __func__);
+ dummy_handler = open(ACS_IPC_FOR_UPPER_RCV, O_WRONLY);
+ dummy_handler = open(ACS_IPC_FOR_LOWER_RCV, O_WRONLY);
+ while (1) {
+ sleep(1000000);
+ }
+ close(dummy_handler);
+}
+
+static void parameterChanged(AppHandle *appHandle, const char *audioTypeName) {
+ AppOps *appOps = NULL;
+ int paramIndex;
+ AUDIO_V_LOG("%s()", __func__);
+#if defined(MTK_DUMMY_AUDIO_PARSER)
+ return;
+#else
+ appOps = appOpsGetInstance();
+ if (appOps == NULL) {
+ ALOGE("%s(), LINE %d ERROR", __func__, __LINE__);
+ return;
+ }
+
+ if (appOps->appHandleReloadAudioType(appHandle, audioTypeName) == APP_ERROR) {
+ ALOGE("%s(), Reload xml fail! (audioType = %s)", __func__, audioTypeName);
+ return;
+ }
+
+ for (paramIndex = 0; paramIndex < PARAM_NUM; paramIndex++) {
+ if (!strcmp(audioTypeName, paramVolume[paramIndex].xml_type_name)
+ && paramVolume[paramIndex].update_xml_callback) {
+ paramVolume[paramIndex].update_xml_callback(paramVolume[paramIndex].id);
+ }
+ }
+#endif
+}
+
+
+static void updateUlAnalogGain() {
+ int ul_ana_gain = 0, ret = 0;
+
+ /* digital part */
+#if !defined(MTK_AUDIO_BRINGUP)
+ ul_ana_gain = speechdrv_get_ul_analog_gain();
+#endif
+ ALOGD("%s(), get ul analog gain value: %d, valid range(0~30 dB)", __func__, ul_ana_gain);
+ /* analog part */
+ ret = set_UL_analog_gain(ul_ana_gain);
+ if (ret < 0)
+ ALOGE("%s(), set ul analog volume error, gain value: %d, errno: %d",
+ __func__, ul_ana_gain, ret);
+}
+
+static void updateDlAnalogGain(void) {
+ int dl_ana_gain = 0, ret = 0;
+
+ /* analog part */
+#if !defined(MTK_AUDIO_BRINGUP)
+ dl_ana_gain = speechdrv_get_dl_analog_gain();
+#endif
+ ALOGD("%s(), get dl analog gain value: %d, valid range(-40~8 dB)", __func__, dl_ana_gain);
+
+ /* analog part */
+ ret = set_DL_analog_gain(dl_ana_gain);
+ if (ret < 0)
+ ALOGE("%s(), set dl analog volume error, gain value: %d, errno: %d",
+ __func__, dl_ana_gain, ret);
+}
+
+static void updateDigitalGain() {
+ int ret = 0, retry_counter_analog = 5, retry = 1;
+ int retry_speech_drv_ite = 0;
+ int dl_ana_gain = 0;
+
+ /* digital part ul/dl*/
+ do {
+#if !defined(MTK_AUDIO_BRINGUP)
+ ret = speechdrv_set_volume_index(g_volume_index, g_current_output_device);
+#endif
+ ++retry_speech_drv_ite;
+ if (!ret) {
+ break;
+ }
+ usleep(SPEECH_DRV_RETRY_US);
+ } while (ret && retry_speech_drv_ite < SPEECH_DRV_RETRY_TIME);
+
+ if (ret < 0)
+ ALOGE("%s(), set dl volume index error, g_volume_index: %d, errno: %d",
+ __func__, g_volume_index, ret);
+
+}
+
+static void updateVolume(int xmlType) {
+ ALOGD("%s(), xml name = %s", __func__, paramVolume[xmlType].xml_type_name);
+ updateDigitalGain();
+ if (xmlType != XML_GAIN_MAP_UL) {
+ updateDlAnalogGain();
+ }
+ if (xmlType != XML_GAIN_MAP_DL) {
+ updateUlAnalogGain();
+ }
+}
+
+//for bring up
+int audio_ctrl_service_speech_on_inner(int enable, int output_device) {
+ int ret;
+ int retry_ite = 0;
+ int device_mode = 0;
+ int input_device;
+ int outputDevice;
+
+ ALOGD("%s(), enable=%d, output_device=0x%x", __func__, enable, output_device);
+ if (enable == g_is_speech_on) {
+ ALOGE("%s(), speech on status no change! g_is_speech_on: %d",
+ __func__, g_is_speech_on);
+ return 0;
+ }
+
+ g_is_speech_on = enable;
+ if (output_device == AUDIO_DEVICE_OUT_SPEAKER) {
+ input_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
+ g_current_output_device = AUDIO_DEVICE_OUT_SPEAKER;
+ } else {
+ input_device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
+ g_current_output_device = AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
+ }
+
+ do {
+ if (enable || !g_record_buf) {
+ //force to speaker , main mic
+ ret = speechdrv_set_speech_on(enable, input_device, g_current_output_device);
+ ++retry_ite;
+ if (!ret) {
+ break;
+ }
+ } else { //recording!!
+ ALOGE("%s(), record is still on, Will auto sppech off after record off, don't worry!", __func__);
+ g_want_to_speech_off_after_record_off = 1;
+ ret = 0;
+ break;
+ }
+ usleep(SPEECH_DRV_RETRY_US);
+ } while (retry_ite < SPEECH_DRV_RETRY_TIME);
+
+ if (ret) {
+ return ret;
+ }
+
+ if (enable) {
+ if (output_device == AUDIO_DEVICE_OUT_SPEAKER) {
+ device_mode = get_default_device();
+ enable_phone_call_AFE_path(device_mode);
+ usleep(100 * 1000);//100ms
+ updateVolume(XML_SPEECH_VOLUME);
+ } else {
+ enable_phone_call_AFE_path(DEV_BT);
+ usleep(100 * 1000);//100ms
+ updateDigitalGain();
+ }
+ } else {
+ disable_phone_call_AFE_path();
+ }
+
+ return 0;
+}
+
+int audio_ctrl_service_M2M_Call_on_inner(int enable) {
+ int ret;
+ int retry_ite = 0;
+ int input_device;
+
+ ALOGD("%s(), enable=%d", __func__, enable);
+ if (enable == g_is_speech_on) {
+ ALOGE("%s(), speech on status no change! g_is_speech_on: %d",
+ __func__, g_is_speech_on);
+ return 0;
+ }
+
+ g_is_speech_on = enable;
+
+ input_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
+ g_current_output_device = AUDIO_DEVICE_OUT_SPEAKER;
+
+ do {
+ if (enable || !g_record_buf) {
+ //force to speaker , main mic
+ ret = speechdrv_set_speech_on(enable, input_device, g_current_output_device);
+ ++retry_ite;
+ if (!ret) {
+ break;
+ }
+ } else { //recording!!
+ ALOGE("%s(), record is still on, Will auto sppech off after record off, don't worry!", __func__);
+ g_want_to_speech_off_after_record_off = 1;
+ ret = 0;
+ break;
+ }
+ usleep(SPEECH_DRV_RETRY_US);
+ } while (retry_ite < SPEECH_DRV_RETRY_TIME);
+
+ if (ret) {
+ return ret;
+ }
+
+ return 0;
+}
+
+int audio_ctrl_service_ECall_on_inner(int enable) {
+ int ret;
+ int retry_ite = 0;
+ int device_mode = 0;
+ int input_device;
+ int outputDevice;
+
+ ALOGD("%s(), enable=%d", __func__, enable);
+ if (enable == g_is_speech_on) {
+ ALOGE("%s(), speech on status no change! g_is_speech_on: %d",
+ __func__, g_is_speech_on);
+ return 0;
+ }
+
+ g_is_speech_on = enable;
+ input_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
+ g_current_output_device = AUDIO_DEVICE_OUT_SPEAKER;
+
+ do {
+ if (enable || !g_record_buf) {
+ //force to speaker , main mic
+ ret = speechdrv_set_speech_on(enable, input_device, g_current_output_device);
+ ++retry_ite;
+ if (!ret) {
+ break;
+ }
+ } else { //recording!!
+ ALOGE("%s(), record is still on, Will auto sppech off after record off, don't worry!", __func__);
+ g_want_to_speech_off_after_record_off = 1;
+ ret = 0;
+ break;
+ }
+ usleep(SPEECH_DRV_RETRY_US);
+ } while (retry_ite < SPEECH_DRV_RETRY_TIME);
+
+ if (ret) {
+ return ret;
+ }
+
+ if (enable) {
+ device_mode = get_default_device();
+ enable_phone_call_AFE_path(device_mode);
+ usleep(100 * 1000);//100ms
+ updateVolume(XML_SPEECH_VOLUME);
+ } else {
+ disable_phone_call_AFE_path();
+ }
+
+ return 0;
+}
+
+int audio_ctrl_service_set_volume_index_inner(int volumeIdx) {
+ ALOGD("%s(), volumeIdx=%d, valid range (%d~%d)", __func__, volumeIdx, DL_VOLUME_IDX_MIN, DL_VOLUME_IDX_MAX);
+ if (volumeIdx > DL_VOLUME_IDX_MAX || volumeIdx < DL_VOLUME_IDX_MIN) {
+ ALOGE("%s(), Invalid DL gain value: %d, valid range (%d~%d)",
+ __func__, volumeIdx, DL_VOLUME_IDX_MIN, DL_VOLUME_IDX_MAX);
+ return -1;
+ }
+ g_volume_index = volumeIdx;
+ updateVolume(XML_SPEECH_VOLUME);
+ return 0;
+}
+
+int audio_ctrl_service_set_speaker_type_inner(int type) {
+ if (g_speaker_type == type) {
+ AUDIO_V_LOG("%s(), the same speaker type(0x%x), return.", __func__, g_speaker_type);
+ return 0;
+ }
+ speechdrv_set_speaker_type(type);
+ return 0;
+}
+
+int audio_ctrl_service_get_volume_index_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return g_volume_index;
+}
+
+#if defined(MTK_SPEECH_RECORD_SUPPORT)
+int audio_ctrl_service_inCall_record_start_inner(int buf_size) {
+ int ret;
+
+ AUDIO_V_LOG("%s()", __func__);
+ if (buf_size > MAX_REC_BUF_SIZE || buf_size <= 0 || buf_size % 2) {
+ return -EINVAL;
+ }
+ if (g_record_buf) {
+ ALOGE("%s(), record already open!", __func__);
+ return -EBUSY;
+ }
+ g_record_buf_size = buf_size;
+ g_record_buf = malloc(g_record_buf_size);
+ g_record_read_virt_idx = 0;
+ g_record_write_virt_idx = 0;
+ g_record_virt_boundry = buf_size * 1000;
+
+#ifndef RECORD_USE_UT_SOURCE
+ // ret = speechdrv_set_RecordOn(RECORD_TYPE_MIX);
+#else
+ ret = tmp_recordOn();
+#endif
+
+ if (ret < 0) {
+ free(g_record_buf);
+ }
+
+ return ret;
+}
+
+int audio_ctrl_service_inCall_record_stop_inner() {
+ int ret;
+
+ AUDIO_V_LOG("%s()", __func__);
+ if (!g_record_buf) {
+ ALOGE("%s(), record not start!", __func__);
+ return -EINVAL;
+ }
+#ifndef RECORD_USE_UT_SOURCE
+
+ // ret = speechdrv_set_RecordOff(RECORD_TYPE_MIX);
+
+ if (g_want_to_speech_off_after_record_off) {
+ // int ret_speech_off = speechdrv_set_speech_on(0, 0);
+ if (ret_speech_off) {
+ ALOGE("%s(), speechdrv_set_speech_on failed! err %d", __func__,
+ ret_speech_off);
+ }
+ g_want_to_speech_off_after_record_off = 0;
+ }
+#else
+ ret = tmp_recordOff();
+#endif
+ free(g_record_buf);
+ g_record_buf = 0;
+ return ret;
+}
+
+
+int audio_ctrl_service_inCall_record_get_watermark_inner() {
+ int watermark;
+
+ if (!g_record_buf) {
+ ALOGE("%s(), record not start!", __func__);
+ return -EINVAL;
+ }
+ watermark = (g_record_write_virt_idx - g_record_read_virt_idx + g_record_virt_boundry) % g_record_virt_boundry;
+ if (watermark > g_record_buf_size) { //XRUN
+ ALOGE("%s(), XRUN reset ptr", __func__);
+ g_record_write_virt_idx = g_record_read_virt_idx;
+ return -EPIPE;
+ }
+
+ return watermark;
+}
+
+int audio_ctrl_service_inCall_record_pointer_inner() {
+ int watermark;
+
+ AUDIO_V_LOG("%s()", __func__);
+ if (!g_record_buf) {
+ ALOGE("%s(), record not start!", __func__);
+ return -EINVAL;
+ }
+
+ watermark = audio_ctrl_service_inCall_record_get_watermark_inner();
+ if (watermark < 0) {
+ return watermark;
+ }
+ return (g_record_write_virt_idx % g_record_buf_size);
+}
+
+int check_copy_twice(int virt_ptr, int buf_size, int size) {
+ if (virt_ptr % buf_size + size > buf_size) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+int audio_ctrl_service_inCall_record_get_data_inner(int data_size, char *dest) {
+ int watermark;
+ int size_to_take;
+ int copy_twice = 0;
+ int read_phy_idx = g_record_read_virt_idx % g_record_buf_size;
+ int first_copy_size;
+
+ AUDIO_V_LOG("%s()", __func__);
+ if (!g_record_buf) {
+ ALOGE("%s(), record not start!", __func__);
+ return -EINVAL;
+ }
+
+ watermark = audio_ctrl_service_inCall_record_get_watermark_inner();
+ if (watermark < 0) {
+ return watermark;
+ }
+
+ size_to_take = (data_size < watermark) ? data_size : watermark;
+ copy_twice = check_copy_twice(g_record_read_virt_idx, g_record_buf_size, size_to_take);
+
+ if (!copy_twice) {
+ memcpy(dest, g_record_buf + read_phy_idx, size_to_take);
+ } else {
+ first_copy_size = g_record_buf_size - read_phy_idx;
+ memcpy(dest, g_record_buf + read_phy_idx, first_copy_size);
+ dest += first_copy_size;
+ memcpy(dest, g_record_buf, size_to_take - first_copy_size);
+ }
+ g_record_read_virt_idx += size_to_take;
+ g_record_read_virt_idx %= g_record_virt_boundry;
+ return size_to_take;
+}
+
+int audio_ctrl_service_inCall_record_data_cb_pcm(int data_size, char *data) {
+ int copy_twice = 0;
+ int write_phy_idx = g_record_write_virt_idx % g_record_buf_size;
+ int first_copy_size;
+
+ if (!g_record_buf) {
+ return -EINVAL;
+ }
+
+ copy_twice = check_copy_twice(g_record_write_virt_idx, g_record_buf_size, data_size);
+ if (!copy_twice) {
+ memcpy(g_record_buf + write_phy_idx, data, data_size);
+ } else {
+ first_copy_size = g_record_buf_size - write_phy_idx;
+ memcpy(g_record_buf + write_phy_idx, data, first_copy_size);
+ data += first_copy_size;
+ memcpy(g_record_buf, data, data_size - first_copy_size);
+ }
+
+ g_record_write_virt_idx += data_size;
+ g_record_write_virt_idx %= g_record_virt_boundry;
+ return data_size;
+}
+
+int16_t *do_record_8k_to_16k_src(int16_t *src, int size_byte) {
+ int offset, err;
+ int16_t *dst_buf;
+ assert(size_byte == RECORD_SRC_BUF_SIZE * 2);
+ if (!g_incall_record_src_state) { //not init
+ g_incall_record_src_state = src_new(g_converter_type, 1, &err);
+ if (!g_incall_record_src_state) {
+ ALOGE("%s(), src_new failed err=%d", __func__, err);
+ return NULL;
+ }
+ assert(!g_incall_record_src_buffer);
+ assert(!g_incall_record_dst_buffer);
+ g_incall_record_src_buffer = calloc(1, sizeof(float) * RECORD_SRC_BUF_SIZE);
+ g_incall_record_dst_buffer = calloc(1, sizeof(float) * RECORD_DST_BUF_SIZE);
+
+ g_incall_record_src_data.data_in = g_incall_record_src_buffer;
+ g_incall_record_src_data.data_out = g_incall_record_dst_buffer;
+ g_incall_record_src_data.src_ratio = RECORD_SRC_RATIO;
+ g_incall_record_src_data.end_of_input = 0;
+ }
+
+ /* do convert */
+ g_incall_record_src_data.input_frames = RECORD_SRC_BUF_SIZE;
+ g_incall_record_src_data.output_frames = RECORD_DST_BUF_SIZE;
+ src_short_to_float_array(src, g_incall_record_src_buffer, RECORD_SRC_BUF_SIZE);
+ err = src_process(g_incall_record_src_state, &g_incall_record_src_data);
+ if (err) {
+ ALOGE("%s(), src_process failed %d", __func__, err);
+ return NULL;
+ }
+
+ dst_buf = g_incall_record_dst_int_buffer;
+ if (g_incall_record_src_data.output_frames > g_incall_record_src_data.output_frames_gen) {
+ offset = g_incall_record_src_data.output_frames - g_incall_record_src_data.output_frames_gen;
+ } else {
+ offset = 0;
+ }
+
+ src_float_to_short_array(g_incall_record_dst_buffer, dst_buf + offset,
+ g_incall_record_src_data.output_frames_gen);
+
+ return dst_buf;
+}
+
+int audio_ctrl_service_inCall_record_data_cb_inner(int data_size, char *data) {
+ MD_PCM_RECORD_HEADER *md_pcm_record_header;
+ char *data_process_ptr = data;
+ char *pcm_data_ptr;
+ uint16_t syncWord;
+ uint16_t rawPcmDir;
+ uint16_t freq;
+ uint16_t pcmLength;
+ uint16_t channel;
+ uint16_t bitFormat;
+
+ int16_t *ul_data_ptr = 0;
+ int ul_data_ptr_size;
+ int ul_data_rate;
+ int16_t *dl_data_ptr = 0;
+ int dl_data_ptr_size;
+ int dl_data_rate;
+
+ int total_data_size;
+ int16_t *total_data_ptr;
+
+ int i, j;
+ int ret;
+
+ while (data_process_ptr < data + data_size) {
+ md_pcm_record_header = (MD_PCM_RECORD_HEADER *)data_process_ptr;
+ syncWord = md_pcm_record_header->u16SyncWord;
+ rawPcmDir = md_pcm_record_header->u16RawPcmDir;
+ freq = md_pcm_record_header->u16Freq;
+ pcmLength = md_pcm_record_header->u16Length;
+ channel = md_pcm_record_header->u16Channel;
+ bitFormat = md_pcm_record_header->u16BitFormat;
+ pcm_data_ptr = data_process_ptr + sizeof(MD_PCM_RECORD_HEADER);
+
+ if (syncWord != MD_PCM_RECORD_HEADER_SYNC) {
+ ALOGE("%s(), Invalid packet, sync word: 0x%x", __func__, syncWord);
+ return 0;
+ }
+
+ if (rawPcmDir == RECORD_TYPE_UL) {
+ assert(!ul_data_ptr);
+ ul_data_ptr = (uint16_t *)pcm_data_ptr;
+ ul_data_ptr_size = pcmLength;
+ ul_data_rate = freq;
+ assert(channel == 1);
+ } else {
+ assert(!dl_data_ptr);
+ dl_data_ptr = (uint16_t *)pcm_data_ptr;
+ dl_data_ptr_size = pcmLength;
+ dl_data_rate = freq;
+ assert(channel == 1);
+ }
+
+ data_process_ptr += sizeof(MD_PCM_RECORD_HEADER) + pcmLength;
+ }
+
+ assert(ul_data_ptr);
+ assert(dl_data_ptr);
+ //only UL can be 8k or 16k, DL must be 16k
+ total_data_size = dl_data_ptr_size;
+ assert(!(total_data_size % ul_data_ptr_size));
+
+ total_data_ptr = malloc(total_data_size);
+
+ if (ul_data_ptr_size < total_data_size) {
+ ul_data_ptr = do_record_8k_to_16k_src(ul_data_ptr, ul_data_ptr_size);
+ if (!ul_data_ptr) {
+ return -EINVAL;
+ }
+ ul_data_ptr_size *= 2;
+ }
+
+ assert(total_data_size == ul_data_ptr_size);
+ //MIX sound
+ for (i = 0; i < ul_data_ptr_size / 2; ++i) {
+ total_data_ptr[i] = ul_data_ptr[i] >> 1;
+ }
+
+ for (i = 0; i < dl_data_ptr_size / 2; ++i) {
+ total_data_ptr[i] += dl_data_ptr[i] >> 1;
+ }
+
+ //write data
+ ret = audio_ctrl_service_inCall_record_data_cb_pcm(total_data_size, total_data_ptr);
+ free(total_data_ptr);
+ return ret;
+}
+#endif
+
+#if defined(MTK_SPEECH_BGS_SUPPORT)
+int audio_ctrl_service_inCall_playback_start_inner() {
+#ifndef PLAYBACK_USE_UT_SINK
+ int ret;
+ AUDIO_V_LOG("%s()", __func__);
+ if (!g_is_bgs_on) {
+ ret = speechdrv_bgs_open(PHONECALL_SAMPLE_RATE);
+ g_is_bgs_on = 1;
+ } else {
+ ALOGE("%s(), already start!", __func__);
+ return 0;
+ }
+ return 0;
+#else
+ return UT_BGSOn();
+#endif
+}
+
+int audio_ctrl_service_inCall_playback_stop_inner() {
+#ifndef PLAYBACK_USE_UT_SINK
+ AUDIO_V_LOG("%s()", __func__);
+ speechdrv_bgs_close();
+ g_is_bgs_on = 0;
+ return 0;
+#else
+ return UT_BGSOff();
+#endif
+}
+static const uint16_t table_1k_tone_16000_hz[] = {
+ 0x0000, 0x30FC, 0x5A82, 0x7641,
+ 0x7FFF, 0x7641, 0x5A82, 0x30FB,
+ 0x0001, 0xCF05, 0xA57E, 0x89C0,
+ 0x8001, 0x89BF, 0xA57E, 0xCF05
+};
+static const uint32_t kSizeSinewaveTable = sizeof(table_1k_tone_16000_hz);
+
+int audio_ctrl_service_inCall_playback_send_data_inner(int data_size, void *data_buf) {
+#ifndef PLAYBACK_USE_UT_SINK
+ int ret;
+ int write_size;
+ int written_size = 0;
+ int try_cnt = 20;
+ if (!g_is_bgs_on) {
+ ALOGE("%s(), not running!", __func__);
+ return 0;
+ }
+
+ while (data_size > 0) {
+ write_size = (data_size > PLAYBACK_BUF_SIZE) ? PLAYBACK_BUF_SIZE : data_size;
+ AUDIO_V_LOG("%s(), sample rate: %d, data_size: %d, write_size: %d",
+ __func__, PHONECALL_SAMPLE_RATE, data_size, write_size);
+ ret = speechdrv_bgs_write(data_buf, write_size);
+ if (ret < 0) {
+ ALOGE("%s(), write to BGS error! ret: %d", __func__, ret);
+ break;
+ }
+ data_size -= ret;
+ data_buf += ret;
+ written_size += ret;
+ --try_cnt;
+ if (try_cnt <= 0) {
+ break;
+ }
+ usleep(SPEECH_DRV_BGS_INTERVAL_US);
+ }
+ return written_size;
+
+#else
+ return UT_BGSSendData(data_buf, data_size);
+#endif
+}
+
+int audio_ctrl_service_inCall_playback_simulation(int data_ms) {
+ uint32_t total_size = PHONECALL_SAMPLE_RATE * 2 * data_ms / 1000;
+ uint32_t buffer_size = PLAYBACK_PERIOD_SIZE;
+ uint32_t total_left = total_size, buffer_count = buffer_size, consume_byte = 0;
+ char buffer[PLAYBACK_PERIOD_SIZE] = {0};
+
+ ALOGD("+%s(), data_ms = %d, total_size = %d, buffer_size = %d",
+ __func__, data_ms, total_size, buffer_size);
+ audio_ctrl_service_inCall_playback_start_inner();
+ while (total_left > 0) {
+ uint32_t count = 0;
+ if (total_left > buffer_size) {
+ buffer_count = buffer_size;
+ } else {
+ buffer_count = total_left;
+ }
+ while (buffer_count > kSizeSinewaveTable) {
+ memcpy(buffer + count, table_1k_tone_16000_hz, kSizeSinewaveTable);
+ count += kSizeSinewaveTable;
+ buffer_count -= kSizeSinewaveTable;
+ }
+ if (buffer_count > 0) {
+ memcpy(buffer + count, table_1k_tone_16000_hz, buffer_count);
+ count += buffer_count;
+ }
+ consume_byte = audio_ctrl_service_inCall_playback_send_data_inner(buffer_size, buffer);
+ total_left -= count;
+ }
+ audio_ctrl_service_inCall_playback_stop_inner();
+ ALOGD("-%s(), data_ms = %d, total_size = %d, total_left = %d",
+ __func__, data_ms, total_size, total_left);
+ return total_size;
+}
+#endif
+
+int audio_ctrl_service_is_speech_on_inner(int output_device) {
+ int result = 0;
+ if (!g_is_speech_on) {
+ result = 0;
+ return result;
+ }
+ if (output_device == g_current_output_device) {
+ result = 1;
+ } else {
+ result = 0;
+ }
+ AUDIO_V_LOG("%s(), result = %d, output_device=0x%x", __func__, result, output_device);
+ return result;
+}
+
+int audio_ctrl_service_get_record_period_size_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return RECORD_PERIOD_SIZE;
+}
+
+int audio_ctrl_service_get_playback_period_size_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return PLAYBACK_PERIOD_SIZE;
+}
+
+int audio_ctrl_service_get_record_max_buffer_size_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return RECORD_MAX_BUFFER_SIZE;
+}
+
+int audio_ctrl_service_get_playback_max_buffer_size_inner() {
+ ALOGE("%s()", __func__);
+ return PLAYBACK_MAX_BUFFER_SIZE;
+}
+
+#if defined(MTK_SPEECH_VM_SUPPORT)
+/* for vmlog, need to record if vmlog on */
+int g_vmlog_on;
+int audio_ctrl_service_vmlog_on_inner(int vmlog_on) {
+ g_vmlog_on = vmlog_on;
+ return speechdrv_set_vm_on(vmlog_on);
+}
+
+int audio_ctrl_service_get_vmlog_on_inner() {
+ return g_vmlog_on;
+}
+#endif
+
+/* for BT setting */
+int audio_ctrl_service_set_bt_wbs_inner(int bt_wbs_on) {
+ AUDIO_V_LOG("%s()", __func__);
+ g_bt_wbs_on = !!bt_wbs_on;
+ set_BT_WB(g_bt_wbs_on);
+ speechdrv_set_bt_wbs(g_bt_wbs_on);
+ return 0;
+}
+
+int audio_ctrl_service_get_bt_wbs_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return g_bt_wbs_on;
+}
+
+int audio_ctrl_service_set_bt_client_has_ecnr_inner(int bt_client_ecnr_on) {
+ if (g_bt_client_has_ecnr == bt_client_ecnr_on) {
+ AUDIO_V_LOG("%s(), the same bt_nrec(0x%x) during voice call.", __func__, g_current_output_device);
+ return 0;
+ }
+ AUDIO_V_LOG("%s(), bt_client_ecnr_on(%d->%d)", __func__, g_bt_client_has_ecnr, bt_client_ecnr_on);
+ g_bt_client_has_ecnr = bt_client_ecnr_on;
+
+ return speechdrv_set_bt_nrec(bt_client_ecnr_on);
+}
+
+int audio_ctrl_service_get_bt_client_has_ecnr_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ return g_bt_client_has_ecnr;
+}
+
+#if !defined(MTK_AUDIO_BRINGUP)
+int audio_ctrl_service_set_use_bt_in_call_inner(int turn_on_bt_in_call) {
+ AUDIO_V_LOG("%s()", __func__);
+ int new_output_device = AUDIO_DEVICE_NONE;
+ int input_device = AUDIO_DEVICE_NONE;
+
+ //if not in call, do nothing
+ if (!g_is_speech_on) { return 0; }
+ if (turn_on_bt_in_call) {
+ new_output_device = AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
+ } else {
+ new_output_device = AUDIO_DEVICE_OUT_SPEAKER;
+ }
+ if (new_output_device == g_current_output_device) {
+ AUDIO_V_LOG("%s(), the same output device(0x%x) during voice call.",
+ __func__, g_current_output_device);
+ return 0;
+ }
+ g_current_output_device = new_output_device;
+ if (g_current_output_device == AUDIO_DEVICE_OUT_SPEAKER) {
+ input_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
+ } else {
+ input_device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
+ }
+
+ AUDIO_V_LOG("%s(), output device(0x%x), input_device(0x%x).",
+ __func__, g_current_output_device, input_device);
+ if (g_current_output_device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
+ dynamic_switch_phone_call_path(DEV_BT);
+ } else {
+ dynamic_switch_phone_call_path(get_default_device());
+ }
+ speechdrv_change_speech_device(input_device, g_current_output_device);
+ updateVolume(XML_SPEECH_VOLUME);
+
+ return 0;
+}
+#endif
+
+int audio_ctrl_service_get_use_bt_in_call_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ if (!g_is_speech_on) { return 0; }
+ return (g_current_output_device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET);
+}
+
+int audio_ctrl_service_reset_inner() {
+ AUDIO_V_LOG("%s()", __func__);
+ g_want_to_speech_off_after_record_off = 0;
+ if (g_is_speech_on) {
+ disable_phone_call_AFE_path();
+ }
+ g_is_speech_on = 0;
+ return 0;
+}
+
+/* DL:0 UL:1 */
+int g_dl_mute_on;
+int g_ul_mute_on;
+int audio_ctrl_service_set_mute_inner(int path, int is_mute) {
+ AUDIO_V_LOG("%s()", __func__);
+ if (path == SPEECH_DL) {
+ g_dl_mute_on = is_mute;
+ speechdrv_set_dl_mute(g_dl_mute_on);
+ } else {
+ g_ul_mute_on = is_mute;
+ speechdrv_set_ul_mute(g_ul_mute_on);
+ }
+ return 0;
+}
+
+int audio_ctrl_service_get_mute_inner(int path) {
+ AUDIO_V_LOG("%s()", __func__);
+ if (path == SPEECH_DL) {
+ return g_dl_mute_on;
+ } else {
+ return g_ul_mute_on;
+ }
+}
+
+#if defined(MTK_SPEECH_BGS_SUPPORT)
+/* for BGS UT */
+
+static const char const *g_BGS_file_path = "/tmp/bgs_UT.pcm";
+FILE *g_UT_file;
+
+int UT_BGSOn() {
+ g_UT_file = fopen(g_BGS_file_path, "w");
+ if (!g_UT_file) {
+ return -EIO;
+ }
+ return 0;
+}
+int UT_BGSOff() {
+ if (g_UT_file) {
+ fclose(g_UT_file);
+ }
+ g_UT_file = 0;
+ return 0;
+}
+int UT_BGSSendData(void *buf, int buf_size) {
+ int sleep_time_ms = buf_size * 1000 / PHONECALL_SAMPLE_RATE / 2;
+ if (!g_UT_file) {
+ ALOGE("%s(), plz send data after turn on", __func__);
+ return 0;
+ }
+ fwrite(buf, 1, buf_size, g_UT_file);
+ return buf_size;
+}
+#endif
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_api.h b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_api.h
new file mode 100644
index 0000000..8a6423f
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_api.h
@@ -0,0 +1,64 @@
+#ifndef _AUDIO_CTRL_SERVICE_API_H_
+#define _AUDIO_CTRL_SERVICE_API_H_
+
+int audio_ctrl_service_speech_on(int speech_on);
+int audio_ctrl_service_set_dl_volume(int Db);
+
+/* API for M2M speech on */
+int audio_ctrl_service_M2M_speech_on(int speech_on);
+
+/* API for ecall speech on */
+int audio_ctrl_service_ecall_speech_on(int speech_on);
+
+
+/* API for BT speech on */
+int audio_ctrl_service_bt_speech_on(int speech_on);
+
+/* API for libspeech_drv inCall record callback*/
+int audio_ctrl_service_inCall_record_data_cb(int data_size, const char* data);
+
+/* APIs for ioplugin record */
+int audio_ctrl_service_inCall_record_start(int buf_size);
+int audio_ctrl_service_inCall_record_stop();
+int audio_ctrl_service_inCall_record_pointer();
+int audio_ctrl_service_inCall_record_get_watermark();
+int audio_ctrl_service_inCall_record_get_data(int data_size, char* dest);
+
+/* APIs for ioplugin playback */
+int audio_ctrl_service_inCall_playback_start();
+int audio_ctrl_service_inCall_playback_stop();
+int audio_ctrl_service_inCall_playback_send_data(int data_size, const char* data_buf);
+
+/* APIs for state check */
+int audio_ctrl_service_is_speech_on();
+int audio_ctrl_service_is_bt_speech_on();
+int audio_ctrl_service_get_dl_gain();
+
+/* APIs for parameters get */
+int audio_ctrl_service_get_record_period_size();
+int audio_ctrl_service_get_playback_period_size();
+int audio_ctrl_service_get_record_max_buffer_size();
+int audio_ctrl_service_get_playback_max_buffer_size();
+
+/* APIs for vm log enable/disable */
+int audio_ctrl_service_vmlog_on(int vmlog_on);
+int audio_ctrl_service_get_vmlog_on();
+
+/* APIs for bt setting */
+int audio_ctrl_service_get_bt_wbs();
+int audio_ctrl_service_set_bt_wbs(int bt_wbs_on);
+int audio_ctrl_service_get_bt_dl_gain();
+int audio_ctrl_service_set_bt_dl_gain(int vol);
+int audio_ctrl_service_set_bt_client_has_ecnr(int bt_client_ecnr_on);
+int audio_ctrl_service_get_bt_client_has_ecnr();
+int audio_ctrl_service_set_use_bt_in_call(int trun_on_bt_in_call);
+int audio_ctrl_service_get_use_bt_in_call();
+
+/* APIs for reset call */
+int audio_ctrl_service_reset();
+
+/* APIs for mute call */
+int audio_ctrl_service_set_mute(int path, int is_mute);
+int audio_ctrl_service_get_mute(int path);
+
+#endif
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_inner_api.h b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_inner_api.h
new file mode 100644
index 0000000..f4f8dd6
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/audio_ctrl_service_inner_api.h
@@ -0,0 +1,123 @@
+#ifndef _AUDIO_CTRL_SERVICE_INNER_API_H_
+#define _AUDIO_CTRL_SERVICE_INNER_API_H_
+
+#define ACS_IPC_FOR_UPPER_SEND "/tmp/audio_ctrl_service/speech_flow_upper_send"
+#define ACS_IPC_FOR_UPPER_RCV "/tmp/audio_ctrl_service/speech_flow_upper_rcv"
+
+#define ACS_IPC_FOR_LOWER_SEND "/tmp/audio_ctrl_service/speech_flow_lower_send"
+#define ACS_IPC_FOR_LOWER_RCV "/tmp/audio_ctrl_service/speech_flow_lower_rcv"
+
+#define FUNC_AUDIO_CTRL_SERVICE_SPEECH_ON 0
+#define FUNC_AUDIO_CTRL_SERVICE_SET_DL_VOLUME 1
+#define FUNC_AUDIO_CTRL_INCALL_SERVICE_RECORD_DATA_CB 2
+#define FUNC_AUDIO_CTRL_INCALL_RECORD_START 3
+#define FUNC_AUDIO_CTRL_INCALL_RECORD_STOP 4
+#define FUNC_AUDIO_CTRL_INCALL_RECORD_POINTER 5
+#define FUNC_AUDIO_CTRL_INCALL_RECORD_GET_WATERMARK 6
+#define FUNC_AUDIO_CTRL_INCALL_RECORD_GET_DATA 7
+#define FUNC_AUDIO_CTRL_INCALL_PLAYBACK_START 8
+#define FUNC_AUDIO_CTRL_INCALL_PLAYBACK_STOP 9
+#define FUNC_AUDIO_CTRL_INCALL_PLAYBACK_SEND_DATA 10
+#define FUNC_AUDIO_CTRL_SERVICE_IS_SPEECH_ON 11
+#define FUNC_AUDIO_CTRL_SERVICE_GET_DL_GAIN 12
+
+#define FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_PERIOD_SIZE 13
+#define FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_PERIOD_SIZE 14
+#define FUNC_AUDIO_CTRL_SERVICE_GET_RECORD_MAX_BUFFER_SIZE 15
+#define FUNC_AUDIO_CTRL_SERVICE_GET_PLAYBACK_MAX_BUFFER_SIZE 16
+
+#define FUNC_AUDIO_CTRL_SERVICE_VMLOG_ON 17
+#define FUNC_AUDIO_CTRL_SERVICE_GET_VMLOG_ON 18
+
+#define FUNC_AUDIO_CTRL_SERVICE_BT_SPEECH_ON 19
+#define FUNC_AUDIO_CTRL_SERVICE_IS_BT_SPEECH_ON 20
+
+#define FUNC_AUDIO_CTRL_SERVICE_SET_BT_WBS 21
+#define FUNC_AUDIO_CTRL_SERVICE_GET_BT_WBS 22
+
+#define FUNC_AUDIO_CTRL_SERVICE_SET_BT_DL_GAIN 23
+#define FUNC_AUDIO_CTRL_SERVICE_GET_BT_DL_GAIN 24
+
+#define FUNC_AUDIO_CTRL_SERVICE_SET_BT_CLIENT_HAS_ECNR 25
+#define FUNC_AUDIO_CTRL_SERVICE_GET_BT_CLIENT_HAS_ECNR 26
+
+#define FUNC_AUDIO_CTRL_SERVICE_SET_USE_BT_IN_CALL 27
+#define FUNC_AUDIO_CTRL_SERVICE_GET_USE_BT_IN_CALL 28
+
+#define FUNC_AUDIO_CTRL_SERVICE_RESET_INNER 29
+#define FUNC_AUDIO_CTRL_SERVICE_SET_SPEAKER_TYPE 30
+
+#define FUNC_AUDIO_CTRL_SERVICE_SET_DL_MUTE 31
+#define FUNC_AUDIO_CTRL_SERVICE_SET_UL_MUTE 32
+#define FUNC_AUDIO_CTRL_SERVICE_GET_MUTE 33
+#define FUNC_AUDIO_CTRL_INCALL_PLAYBACK_SIMULATION 34
+#define FUNC_AUDIO_CTRL_M2M_CALL_ON 35
+#define FUNC_AUDIO_CTRL_ECALL_ON 36
+
+
+#define IPC_DATA_SIZE_MAX 2048
+#define RECORD_PERIOD_SIZE 640
+#define RECORD_MAX_BUFFER_SIZE 1920
+#define PHONECALL_SAMPLE_RATE 32000
+#define PLAYBACK_PERIOD_SIZE \
+ ((2 * 1 * PHONECALL_SAMPLE_RATE * 20) / 1000)
+#define PLAYBACK_BUF_SIZE 2048
+#define PLAYBACK_MAX_BUFFER_SIZE PLAYBACK_PERIOD_SIZE * 2
+enum {
+ SPEECH_DL,
+ SPEECH_UL,
+};
+
+/* APIs for speech */
+int audio_ctrl_service_speech_on_inner(int enable, int output_device);
+int audio_ctrl_service_is_speech_on_inner(int output_device);
+int audio_ctrl_service_set_volume_index_inner(int volumeIdx);
+int audio_ctrl_service_get_volume_index_inner();
+int audio_ctrl_service_set_speaker_type_inner(int type);
+int audio_ctrl_service_M2M_Call_on_inner(int enable);
+int audio_ctrl_service_ECall_on_inner(int enable);
+
+
+/* API for libspeech_drv inCall record callback*/
+int audio_ctrl_service_inCall_record_data_cb_inner(int data_size, char* data);
+
+/* APIs for ioplugin record*/
+int audio_ctrl_service_inCall_record_start_inner(int buf_size);
+int audio_ctrl_service_inCall_record_stop_inner();
+int audio_ctrl_service_inCall_record_pointer_inner();
+int audio_ctrl_service_inCall_record_get_watermark_inner();
+int audio_ctrl_service_inCall_record_get_data_inner(int data_size, char* dest);
+
+/* APIs for ioplugin playback*/
+int audio_ctrl_service_inCall_playback_start_inner();
+int audio_ctrl_service_inCall_playback_stop_inner();
+int audio_ctrl_service_inCall_playback_send_data_inner(int data_size, void* data_buf);
+int audio_ctrl_service_inCall_playback_simulation(int data_ms);
+
+/* APIs for parameters get */
+int audio_ctrl_service_get_record_period_size_inner();
+int audio_ctrl_service_get_playback_period_size_inner();
+int audio_ctrl_service_get_record_max_buffer_size_inner();
+int audio_ctrl_service_get_playback_max_buffer_size_inner();
+
+/* APIs for vmlog */
+int audio_ctrl_service_vmlog_on_inner(int vmlog_on);
+int audio_ctrl_service_get_vmlog_on_inner();
+
+/* APIs for BT ctrl */
+int audio_ctrl_service_set_bt_wbs_inner(int bt_wbs_on);
+int audio_ctrl_service_get_bt_wbs_inner();
+ int audio_ctrl_service_set_bt_client_has_ecnr_inner(int bt_client_ecnr_on);
+int audio_ctrl_service_get_bt_client_has_ecnr_inner();
+int audio_ctrl_service_set_use_bt_in_call_inner(int trun_on_bt_in_call);
+int audio_ctrl_service_get_use_bt_in_call_inner();
+
+/* APIs for reset call */
+int audio_ctrl_service_reset_inner();
+
+/* API for set DL/UL mute */
+int audio_ctrl_service_set_mute_inner(int path, int is_mute);
+int audio_ctrl_service_get_mute_inner(int path);
+
+#endif
+
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/default_para.h b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/default_para.h
new file mode 100644
index 0000000..64aff70
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/default_para.h
@@ -0,0 +1,349 @@
+#ifndef _DEFAULT_PARA_H_
+#define _DEFAULT_PARA_H_
+
+#define BT_COMP_FILTER (1 << 15)
+#define BT_SYNC_DELAY 86
+
+#define DEFAULT_SPEECH_NORMAL_MODE_PARA \
+ 0x80, 0xFD, 0x4004, 0x1F, 0xE007, 0x081F, 0xD045, 0x00, 0x00, 0x11E4, 0x263, \
+ 0x0000, 0x5008, 0x173, 0x17, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0F, \
+ 0xF0F, 0xF0F, 0xF0F, 0xF0F, 0x0, 0x2828, 0x5050, 0x7878, 0xA0A0
+
+#define DEFAULT_SPEECH_EARPHONE_MODE_PARA \
+ 0x0, 0xFD, 0x2A04, 0x1F, 0xE007, 0x1F, 0x195, 0x40, 0x110, 0x10E5, 0x263, 0x0, \
+ 0x5008, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x0
+
+#define DEFAULT_SPEECH_BT_EARPHONE_MODE_PARA \
+ 0x0, 0xFD, 0x2A04, 0x1F, 0xD00F, 0x1F, 0x195, 0x0, 0x50, 0x10E5, 0xA263, 0x0, \
+ 0xD008, 0x0, 0x0, 0x56, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0,0x0,0x0,0x0,0x0
+
+#define DEFAULT_SPEECH_LOUDSPK_MODE_PARA \
+ 0x60, 0xE0, 0x1488, 0x1F, 0xE007, 0x601F, 0x195, 0x84, 0x54, 0x10E5, 0x263, 0x0, \
+ 0x5008, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0
+
+#define DEFAULT_SPEECH_CARKIT_MODE_PARA \
+ 96, 224, 5256, 31, 57351, 24607, 400, 132, \
+ 84, 4325, 611, 0, 20488, 0, 0, 0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA \
+ 0, 479, 10756, 28, 53255, 31, 400, 0, \
+ 4048, 4325, 611, 0, 20488 | BT_COMP_FILTER, 0, 0, BT_SYNC_DELAY, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_SPEECH_AUX1_MODE_PARA \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_SPEECH_AUX2_MODE_PARA \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+#define DEFAULT_WB_SPEECH_NORMAL_MODE_PARA \
+ 0x80, 0xFD, 0x4004, 0x1F, 0xE007, 0x081F, 0xD045, 0x00, 0x00, 0x11E4, 0x263, \
+ 0x0000, 0x5008, 0x173, 0x17, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, \
+ 0x0, 0x0, 0x0, 0x0, 0x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+#define DEFAULT_WB_SPEECH_CARKIT_MODE_PARA \
+ 96, 224, 5256, 31, 57607, 24607, 400, 132, \
+ 84, 4325, 611, 0, 16392, 0, 0, 0 , \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_WB_SPEECH_BT_CORDLESS_MODE_PARA \
+ 0, 479, 10756, 28, 53511, 31, 400, 0, \
+ 4048, 4325, 611, 0, 16392 | BT_COMP_FILTER, 0, 0, BT_SYNC_DELAY, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_WB_SPEECH_AUX1_MODE_PARA \
+ 96, 224, 5256, 31, 57607, 0, 400, 0, 4112, 4325, 11, 0, 0, 0, 0, 0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+#define DEFAULT_WB_SPEECH_AUX2_MODE_PARA \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+/* For FIR in/out*/
+/* 0: Input FIR coefficients for 2G/3G Normal mode */
+/* 1: Input FIR coefficients for 2G/3G/VoIP Headset mode */
+/* 2: Input FIR coefficients for 2G/3G Handfree mode */
+/* 3: Input FIR coefficients for 2G/3G/VoIP BT mode */
+/* 4: Input FIR coefficients for VoIP Normal mode */
+/* 5: Input FIR coefficients for VoIP Handfree mode */
+#define SPEECH_INPUT_FIR_COEF \
+ 32767, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \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, 0, 0, 0, 0, 0, 0, 0, \
+\
+ 32767, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+\
+ 32767, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+
+
+#endif
+
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/speech_UT_header.h b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/speech_UT_header.h
new file mode 100644
index 0000000..cc01912
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/speech_UT_header.h
@@ -0,0 +1,14 @@
+#ifndef _SPEECH_TMP_HEADER_H_
+#define _SPEECH_TMP_HEADER_H_
+
+/* for record */
+int tmp_recordOn();
+int tmp_recordOff();
+
+/* for playback */
+
+int UT_BGSOn();
+int UT_BGSOff();
+int UT_BGSSendData(void *buf, int buf_size);
+
+#endif
\ No newline at end of file
diff --git a/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/xml_parser_def.h b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/xml_parser_def.h
new file mode 100644
index 0000000..fdf34e6
--- /dev/null
+++ b/src/multimedia/audio-misc/audio-ctrl-service/audio_big_sw/xml_parser_def.h
@@ -0,0 +1,19 @@
+#ifndef _XML_PARSER_DEF_H_
+#define _XML_PARSER_DEF_H_
+#include "mixer_ctrl.h"
+
+struct xml_param {
+ int id;
+ char const * xml_type_name;
+ void (*update_xml_callback)(int);
+};
+
+ enum {
+ XML_SPEECH_VOLUME = 0,
+ XML_VOLUME,
+ XML_GAIN_MAP_DL,
+ XML_GAIN_MAP_UL,
+ PARAM_NUM,
+};
+
+#endif