exynos: audiohal_comv1: Add support for secril
Change-Id: I5b1227509f15f9ec5f3a9c4c1f998a7b640acf81
Signed-off-by: Francescodario Cuzzocrea <bosconovic@gmail.com>
diff --git a/libaudio/audiohal_comv1/common_audiohal/Android.mk b/libaudio/audiohal_comv1/common_audiohal/Android.mk
index 1c8e72f..d02ba58 100644
--- a/libaudio/audiohal_comv1/common_audiohal/Android.mk
+++ b/libaudio/audiohal_comv1/common_audiohal/Android.mk
@@ -22,15 +22,30 @@
LOCAL_SRC_FILES := \
audio_hw.c \
- ../odm_specific/voice_manager.c \
../odm_specific/factory_manager.c \
../odm_specific/audio_odm_impl.c
+ifeq ($(BOARD_USE_SITRIL), true)
+LOCAL_SRC_FILES += \
+ ../odm_specific/voice_manager_sit.c
+
+LOCAL_C_INCLUDES += \
+ $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril-sit \
+ $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril-sit/include
+
+LOCAL_CFLAGS += -DUSE_SITRIL
+else
+LOCAL_SRC_FILES += \
+ ../odm_specific/voice_manager_sec.c
+
+LOCAL_C_INCLUDES += \
+ $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril-sec \
+ $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril-sec/include
+endif
+
LOCAL_C_INCLUDES += \
$(TOP)/hardware/samsung_slsi-linaro/exynos/include/libaudio/audiohal_comv1 \
$(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific \
- $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril \
- $(TOP)/hardware/samsung_slsi-linaro/exynos/libaudio/audiohal_comv1/odm_specific/audioril/include \
$(call include-path-for, audio-utils)
LOCAL_HEADER_LIBRARIES := libhardware_headers
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril/Android.mk b/libaudio/audiohal_comv1/odm_specific/audioril-sec/Android.mk
similarity index 79%
rename from libaudio/audiohal_comv1/odm_specific/audioril/Android.mk
rename to libaudio/audiohal_comv1/odm_specific/audioril-sec/Android.mk
index f79131b..8806e48 100644
--- a/libaudio/audiohal_comv1/odm_specific/audioril/Android.mk
+++ b/libaudio/audiohal_comv1/odm_specific/audioril-sec/Android.mk
@@ -1,4 +1,5 @@
# Copyright (C) 2014 The Android Open Source Project
+# Copyright (C) 2023 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,14 +14,18 @@
# limitations under the License.
#
-# Audio RIL Interface for SIT
+# Audio RIL Interface for SEC
#
ifeq ($(BOARD_USE_AUDIOHAL_COMV1), true)
+ifneq ($(BOARD_USE_SITRIL), true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := sitril_interface.c
+LOCAL_SRC_FILES := secril_interface.c
+
+LOCAL_C_INCLUDES += \
+ $(TOP)/hardware/samsung_slsi-linaro/exynos/include/libaudio/audiohal_comv1
LOCAL_C_INCLUDES += ./include
@@ -33,3 +38,4 @@
include $(BUILD_SHARED_LIBRARY)
endif
+endif
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril/AudioRil.h b/libaudio/audiohal_comv1/odm_specific/audioril-sec/AudioRil.h
similarity index 66%
rename from libaudio/audiohal_comv1/odm_specific/audioril/AudioRil.h
rename to libaudio/audiohal_comv1/odm_specific/audioril-sec/AudioRil.h
index 43baa2c..05e5707 100644
--- a/libaudio/audiohal_comv1/odm_specific/audioril/AudioRil.h
+++ b/libaudio/audiohal_comv1/odm_specific/audioril-sec/AudioRil.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,9 +18,7 @@
#ifndef __AUDIO_RIL_H__
#define __AUDIO_RIL_H__
-
-#include "./include/sitril-client.h"
-
+#include "./include/secril-client.h"
// VoLTE Status : same as volte_status_t in VoiceManager
enum {
@@ -28,12 +27,16 @@
VOLTE_VIDEO
};
-
struct rilclient_intf {
/* The pointer of interface library for RIL Client*/
void *handle;
- bool connection;
+ /* The SIPC RIL Client Handle */
+ /* This will be used as parameter of RIL CLient Functions */
+ void *client;
+
+ SoundType sound_type;
+
bool extraVolume;
bool wbAmr;
bool emergencyMode;
@@ -51,17 +54,20 @@
bool call_forward;
bool usbmic_state;
+ bool hac_mode;
/* Function pointers */
- int (*ril_open_client)(void);
- int (*ril_close_client)(void);
- int (*ril_register_callback)(void *, int *);
- int (*ril_set_audio_volume)(int);
- int (*ril_set_audio_path)(int);
+ void *(*ril_open_client)(void);
+ int (*ril_close_client)(void *);
+ int (*ril_connect)(void *);
+ int (*ril_is_connected)(void *);
+ int (*ril_disconnect)(void *);
+ int (*ril_set_audio_volume)(void *, SoundType, AudioPath);
+ int (*ril_set_audio_path)(void *, AudioPath, ExtraVolume);
int (*ril_set_multi_mic)(int);
- int (*ril_set_mute)(int);
- int (*ril_set_audio_clock)(int);
- int (*ril_set_audio_loopback)(int, int);
+ int (*ril_set_mute)(void *, int);
+ int (*ril_set_audio_clock)(void *, int);
+ int (*ril_set_tty_mode)(int);
};
#endif /* __AUDIO_RIL_H__ */
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril-sec/include/secril-client.h b/libaudio/audiohal_comv1/odm_specific/audioril-sec/include/secril-client.h
new file mode 100644
index 0000000..70edcea
--- /dev/null
+++ b/libaudio/audiohal_comv1/odm_specific/audioril-sec/include/secril-client.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SECRIL_CLIENT_H__
+#define __SECRIL_CLIENT_H__
+
+typedef enum _SoundType {
+ SOUND_TYPE_NONE,
+ SOUND_TYPE_VOICE,
+ SOUND_TYPE_SPEAKER,
+ SOUND_TYPE_HEADSET,
+ SOUND_TYPE_BTVOICE
+} SoundType;
+
+typedef enum _AudioPath {
+ SOUND_AUDIO_PATH_NONE = 0,
+ SOUND_AUDIO_PATH_HANDSET = 1,
+ SOUND_AUDIO_PATH_HEADSET = 2,
+ SOUND_AUDIO_PATH_HANDSFREE = 3,
+ SOUND_AUDIO_PATH_BLUETOOTH = 4,
+ SOUND_AUDIO_PATH_STEREO_BLUETOOTH = 5,
+ SOUND_AUDIO_PATH_SPEAKRERPHONE = 6,
+ SOUND_AUDIO_PATH_35PI_HEADSET = 7,
+ SOUND_AUDIO_PATH_BT_NS_EC_OFF = 8,
+ SOUND_AUDIO_PATH_WB_BLUETOOTH = 9,
+ SOUND_AUDIO_PATH_WB_BT_NS_EC_OFF = 10,
+ SOUND_AUDIO_PATH_HANDSET_HAC = 11,
+ SOUND_AUDIO_PATH_LINEOUT = 12,
+ SOUND_AUDIO_PATH_VOLTE_HANDSET = 65,
+ SOUND_AUDIO_PATH_VOLTE_HEADSET = 66,
+ SOUND_AUDIO_PATH_VOLTE_HFK = 67,
+ SOUND_AUDIO_PATH_VOLTE_BLUETOOTH = 68,
+ SOUND_AUDIO_PATH_VOLTE_STEREO_BLUETOOTH = 69,
+ SOUND_AUDIO_PATH_VOLTE_SPEAKRERPHONE = 70,
+ SOUND_AUDIO_PATH_VOLTE_35PI_HEADSET = 71,
+ SOUND_AUDIO_PATH_VOLTE_BT_NS_EC_OFF = 72,
+ SOUND_AUDIO_PATH_VOLTE_WB_BLUETOOTH = 73,
+ SOUND_AUDIO_PATH_VOLTE_WB_BT_NS_EC_OFF = 74,
+ SOUND_AUDIO_PATH_VOLTE_HANDSET_HAC = 75,
+ SOUND_AUDIO_PATH_VOLTE_LINEOUT = 76,
+ SOUND_AUDIO_PATH_MAX
+} AudioPath;
+
+/* Voice Audio Multi-MIC */
+enum ril_audio_multimic {
+ VOICE_MULTI_MIC_OFF,
+ VOICE_MULTI_MIC_ON,
+};
+
+typedef enum _ExtraVolume {
+ ORIGINAL_PATH,
+ EXTRA_VOLUME_PATH,
+ EMERGENCY_PATH
+} ExtraVolume;
+
+typedef enum _SoundClockCondition {
+ SOUND_CLOCK_STOP,
+ SOUND_CLOCK_START
+} SoundClockCondition;
+
+typedef enum _MuteCondition {
+ TX_UNMUTE, /* 0x00: TX UnMute */
+ TX_MUTE, /* 0x01: TX Mute */
+ RX_UNMUTE, /* 0x02: RX UnMute */
+ RX_MUTE, /* 0x03: RX Mute */
+ RXTX_UNMUTE, /* 0x04: RXTX UnMute */
+ RXTX_MUTE, /* 0x05: RXTX Mute */
+} MuteCondition;
+
+enum ril_audio_clockmode {
+ VOICE_AUDIO_TURN_OFF_I2S,
+ VOICE_AUDIO_TURN_ON_I2S
+};
+
+/* Voice Call Mode */
+enum voice_call_mode {
+ VOICE_CALL_NONE = 0,
+ VOICE_CALL_CS, // CS(Circit Switched) Call
+ VOICE_CALL_PS, // PS(Packet Switched) Call
+ VOICE_CALL_MAX,
+};
+
+/* Event from RIL Audio Client */
+#define VOICE_AUDIO_EVENT_BASE 10000
+#define VOICE_AUDIO_EVENT_RINGBACK_STATE_CHANGED (VOICE_AUDIO_EVENT_BASE + 1)
+#define VOICE_AUDIO_EVENT_IMS_SRVCC_HANDOVER (VOICE_AUDIO_EVENT_BASE + 2)
+
+#endif // __SECRIL_CLIENT_H__
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.c b/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.c
new file mode 100644
index 0000000..8b2fccd
--- /dev/null
+++ b/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "secril_interface"
+#define LOG_NDEBUG 0
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <log/log.h>
+#include <unistd.h>
+
+#include "AudioRil.h"
+#include "secril_interface.h"
+#include "../voice_definition.h"
+
+/* The path of RIL Audio Client Library */
+#define RIL_CLIENT_LIBPATH "libsecril-client.so"
+
+/* Retry for RILClient Open */
+#define MAX_RETRY 10 // Try 10
+#define SLEEP_RETRY 10000 // 10ms sleep
+
+#define CP1 0 // DualCP CP1, DualMode Sim1
+#define CP2 1 // DualCP CP2, DualMode Sim2
+
+
+/******************************************************************************/
+/** **/
+/** RILClient_Interface is Singleton **/
+/** **/
+/******************************************************************************/
+static struct rilclient_intf *instance = NULL;
+
+static struct rilclient_intf* getInstance(void)
+{
+ if (instance == NULL) {
+ instance = calloc(1, sizeof(struct rilclient_intf));
+ ALOGI("proxy-%s: created RILClient Interface Instance!", __func__);
+ }
+ return instance;
+}
+
+static void destroyInstance(void)
+{
+ if (instance) {
+ free(instance);
+ instance = NULL;
+ ALOGI("proxy-%s: destroyed RILClient Interface Instance!", __func__);
+ }
+ return;
+}
+
+
+/******************************************************************************/
+/** **/
+/** Static functions for RILClient_Interface **/
+/** **/
+/******************************************************************************/
+static int map_incall_device(struct rilclient_intf *voice, audio_devices_t devices)
+{
+ int device_type = SOUND_AUDIO_PATH_NONE;
+
+ switch(devices) {
+ case AUDIO_DEVICE_OUT_EARPIECE:
+ if (voice->volte_status == VOLTE_OFF) {
+ if (voice->hac_mode)
+ device_type = SOUND_AUDIO_PATH_HANDSET_HAC;
+ else
+ device_type = SOUND_AUDIO_PATH_HANDSET;
+ } else {
+ if (voice->hac_mode)
+ device_type = SOUND_AUDIO_PATH_VOLTE_HANDSET_HAC;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_HANDSET;
+ }
+ break;
+
+ case AUDIO_DEVICE_OUT_SPEAKER:
+ if (voice->volte_status == VOLTE_OFF)
+ device_type = SOUND_AUDIO_PATH_SPEAKRERPHONE;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_SPEAKRERPHONE;
+ break;
+
+ case AUDIO_DEVICE_OUT_WIRED_HEADSET:
+ if (voice->volte_status == VOLTE_OFF)
+ device_type = SOUND_AUDIO_PATH_HEADSET;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_HEADSET;
+ break;
+
+ case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
+ if (voice->volte_status == VOLTE_OFF)
+ device_type = SOUND_AUDIO_PATH_35PI_HEADSET;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_35PI_HEADSET;
+ break;
+
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
+ if (voice->volte_status == VOLTE_OFF)
+ if (voice->btsco_ec == BT_NREC_OFF)
+ if (voice->btsco_sr == NB_SAMPLING_RATE)
+ device_type = SOUND_AUDIO_PATH_BT_NS_EC_OFF;
+ else
+ device_type = SOUND_AUDIO_PATH_WB_BT_NS_EC_OFF;
+ else
+ if (voice->btsco_sr == NB_SAMPLING_RATE)
+ device_type = SOUND_AUDIO_PATH_BLUETOOTH;
+ else
+ device_type = SOUND_AUDIO_PATH_WB_BLUETOOTH;
+ else
+ if (voice->btsco_ec == BT_NREC_OFF)
+ if (voice->btsco_sr == NB_SAMPLING_RATE)
+ device_type = SOUND_AUDIO_PATH_VOLTE_BT_NS_EC_OFF;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_WB_BT_NS_EC_OFF;
+ else
+ if (voice->btsco_sr == NB_SAMPLING_RATE)
+ device_type = SOUND_AUDIO_PATH_VOLTE_BLUETOOTH;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_WB_BLUETOOTH;
+ break;
+
+ case AUDIO_DEVICE_OUT_LINE:
+ if (voice->volte_status == VOLTE_OFF)
+ device_type = SOUND_AUDIO_PATH_LINEOUT;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_LINEOUT;
+ break;
+
+ default:
+ if (voice->volte_status == VOLTE_OFF)
+ device_type = SOUND_AUDIO_PATH_HANDSET;
+ else
+ device_type = SOUND_AUDIO_PATH_VOLTE_HANDSET;
+ break;
+ }
+
+ return device_type;
+}
+
+static SoundType map_sound_from_device(AudioPath path)
+{
+ SoundType sound_type = SOUND_TYPE_VOICE;
+
+ switch(path) {
+ case SOUND_AUDIO_PATH_SPEAKRERPHONE:
+ sound_type = SOUND_TYPE_SPEAKER;
+ break;
+ case SOUND_AUDIO_PATH_HEADSET:
+ sound_type = SOUND_TYPE_HEADSET;
+ break;
+ case SOUND_AUDIO_PATH_HANDSET:
+ default:
+ sound_type = SOUND_TYPE_VOICE;
+ break;
+ }
+
+ return sound_type;
+}
+
+/******************************************************************************/
+/** **/
+/** RILClient_Interface Functions **/
+/** **/
+/******************************************************************************/
+int SecRilOpen()
+{
+ struct rilclient_intf *rilc = NULL;
+ int ret = 0;
+
+ /* Create SecRil Audio Client Interface Structure */
+ rilc = getInstance();
+ if (!rilc) {
+ ALOGE("%s: failed to create for RILClient Interface", __func__);
+ goto create_err;
+ }
+
+ /* Initialize SecRil Audio Client Interface Structure */
+ rilc->handle = NULL;
+ rilc->extraVolume = false;
+ rilc->wbAmr = false;
+ rilc->emergencyMode = false;
+ rilc->btsco_ec = false;
+ rilc->btsco_sr = 8000;
+ rilc->audio_mode = 0;
+ rilc->audio_state = false;
+ rilc->tx_mute = false;
+ rilc->rx_mute = false;
+ rilc->dualmic = false;
+ rilc->current_modem = CP1;
+
+ rilc->realcall = false;
+ rilc->volte_status = VOLTE_OFF;
+ rilc->call_forward = false;
+
+ rilc->usbmic_state = false;
+ rilc->hac_mode = false;
+
+ /*
+ * Open & Connect SecRil Audio Client Library
+ * This library will do real connection with SecRil
+ */
+ rilc->handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW);
+ if (rilc->handle) {
+ rilc->ril_open_client = (void *(*)(void))dlsym(rilc->handle, "OpenClient_RILD");
+ rilc->ril_close_client = (int (*)(void *))dlsym(rilc->handle, "CloseClient_RILD");
+ rilc->ril_connect = (int (*)(void *))dlsym(rilc->handle, "Connect_RILD");
+ rilc->ril_is_connected = (int (*)(void *))dlsym(rilc->handle, "isConnected_RILD");
+ rilc->ril_disconnect = (int (*)(void *))dlsym(rilc->handle, "Disconnect_RILD");
+ rilc->ril_set_audio_volume = (int (*)(void *, SoundType, AudioPath))dlsym(rilc->handle, "SetCallVolume");
+ rilc->ril_set_audio_path = (int (*)(void *, AudioPath, ExtraVolume))dlsym(rilc->handle, "SetCallAudioPath");
+ rilc->ril_set_multi_mic = (int (*)(int))dlsym(rilc->handle, "SetTwoMicControl");
+ rilc->ril_set_mute = (int (*)(void *, int))dlsym(rilc->handle, "SetMute");
+ rilc->ril_set_audio_clock = (int (*)(void *, int))dlsym(rilc->handle, "SetCallClockSync");
+
+ ALOGD("%s: Succeeded in getting RIL AudioClient Interface!", __func__);
+ } else {
+ ALOGE("%s: Failed to open RIL AudioClient Interface(%s)!", __func__, RIL_CLIENT_LIBPATH);
+ goto libopen_err;
+ }
+
+ /* Early open RIL Client */
+ if (rilc->ril_open_client) {
+ for (int retry = 0; retry < MAX_RETRY; retry++) {
+ rilc->client = rilc->ril_open_client();
+ if (!rilc->client) {
+ ALOGE("%s: Failed to open RIL AudioClient! (Try %d)", __func__, retry+1);
+ usleep(SLEEP_RETRY); // 10ms
+ } else {
+ ALOGD("%s: Succeeded in opening RIL AudioClient!", __func__);
+
+ if (rilc->ril_is_connected(rilc->client))
+ ALOGD("%s: RIL Client is already connected with RIL", __func__);
+ else if (rilc->ril_connect(rilc->client)) {
+ ALOGE("%s: RIL Client cannot connect with RIL", __func__);
+ rilc->ril_close_client(rilc->client);
+ rilc->client = NULL;
+ continue;
+ }
+
+ ALOGD("%s: RIL Client is connected with RIL", __func__);
+ break;
+ }
+ }
+
+ if (!rilc->client || !rilc->ril_is_connected(rilc->client))
+ goto open_err;
+ } else {
+ ALOGE("%s: ril_open_client is not available.", __func__);
+ goto open_err;
+ }
+
+ return ret;
+
+open_err:
+ if (rilc->handle) {
+ dlclose(rilc->handle);
+ rilc->handle = NULL;
+ }
+
+libopen_err:
+ if (rilc) {
+ destroyInstance();
+ rilc = NULL;
+ }
+
+create_err:
+ return -1;
+}
+
+int SecRilClose()
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if (rilc) {
+ if (rilc->client && rilc->ril_close_client) {
+ ret = rilc->ril_close_client(rilc->client);
+ if (ret == 0)
+ ALOGD("%s: Closed RIL AudioClient", __func__);
+ else
+ ALOGE("%s: Failed to close RIL AudioClient!", __func__);
+ }
+
+ if (rilc->handle) {
+ dlclose(rilc->handle);
+ rilc->handle = NULL;
+ }
+
+ destroyInstance();
+ }
+
+ return 0;
+}
+
+int SecRilDuosInit()
+{
+ int ret = 0;
+
+ // Not Supported Dual RIL
+
+ return ret;
+}
+
+int SecRilCheckConnection()
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ if (rilc->client && rilc->ril_is_connected(rilc->client))
+ ret = 1;
+ }
+
+ return ret;
+}
+
+int SecRilSetVoiceSolution()
+{
+ int ret = 0;
+
+ // Not Supported Voice Solution by CP
+
+ return ret;
+}
+
+int SecRilSetExtraVolume(bool on)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ // Not Supported Extra Volume
+ rilc->extraVolume = on;
+ }
+
+ return ret;
+}
+
+int SecRilSetWbamr(int on)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ // Not Supported WideBand
+ rilc->wbAmr = (bool)on;
+ }
+
+ return ret;
+}
+
+int SecRilsetEmergencyMode(bool on)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ // Not Supported Emergency Mode
+ rilc->emergencyMode = on;
+ }
+
+ return ret;
+}
+
+int SecRilSetScoSolution(bool echoCancle, int sampleRate)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ // Not Supported BT SCO Solution by CP
+ rilc->btsco_ec = echoCancle;
+ rilc->btsco_sr = sampleRate;
+ }
+
+ return ret;
+}
+
+int SecRilSetVoiceVolume(int device __unused, int volume, float fvolume)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ if (rilc->ril_set_audio_volume && rilc->client)
+ rilc->ril_set_audio_volume(rilc->client, rilc->sound_type, volume);
+
+ ALOGD("%s: Volume = %d(%f)!", __func__, volume, fvolume);
+ }
+
+ return ret;
+}
+
+int SecRilSetVoicePath(int mode __unused, int device)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int path;
+ int ret = 0;
+
+ if(rilc) {
+ path = map_incall_device(rilc, device);
+ rilc->sound_type = map_sound_from_device(path);
+ if (rilc->ril_set_audio_path && rilc->client) {
+ ret = rilc->ril_set_audio_path(rilc->client, path, ORIGINAL_PATH);
+ ALOGD("%s: set Voice Path to %d!", __func__, path);
+ }
+ }
+
+ return ret;
+}
+
+int SecRilSetAudioMode(int mode, bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->audio_mode = mode;
+ rilc->audio_state = state;
+ }
+
+ return ret;
+}
+
+int SecRilSetTxMute(bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ if (rilc->ril_set_mute && rilc->client) {
+ rilc->ril_set_mute(rilc->client, (int)state);
+ }
+ rilc->tx_mute = state;
+ }
+
+ return ret;
+}
+
+int SecRilSetRxMute(bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->rx_mute = state;
+ }
+
+ return ret;
+}
+
+int SecRilSetDualMic(bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->dualmic = state;
+ }
+
+ return ret;
+}
+
+int SecRilSetLoopback(int loopbackMode __unused, int rx_device __unused, int tx_device __unused)
+{
+ return 0;
+}
+
+int SecRilSetCurrentModem(int curModem)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->current_modem = curModem;
+ }
+
+ return ret;
+}
+
+int SecRilRegisterCallback(int rilState __unused, int * __unused callback)
+{
+ return 0;
+}
+
+int SecRilSetRealCallStatus(bool on)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->realcall = on;
+ }
+
+ return ret;
+}
+
+int SecRilSetVoLTEState(int state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->volte_status = state;
+ }
+
+ return ret;
+}
+int SecRilSetHACMode(bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ rilc->hac_mode = state;
+ }
+
+ return ret;
+}
+
+void SecRilSetCallFowardingMode(bool callFwd)
+{
+ struct rilclient_intf *rilc = getInstance();
+
+ if(rilc) {
+ rilc->call_forward = callFwd;
+ }
+
+ return ;
+}
+
+void SecRilDump(int fd __unused)
+{
+ return ;
+}
+
+void SecRilCheckMultiSim()
+{
+ return ;
+}
+
+int SecRilSetSoundClkMode(int mode)
+{
+ struct rilclient_intf *rilc = getInstance();
+ int ret = 0;
+
+ if(rilc) {
+ if (rilc->ril_set_audio_clock) {
+ if (mode)
+ rilc->ril_set_audio_clock(rilc->client, VOICE_AUDIO_TURN_ON_I2S);
+ else
+ rilc->ril_set_audio_clock(rilc->client, VOICE_AUDIO_TURN_OFF_I2S);
+ }
+ }
+
+ return ret;
+}
+
+void SecRilSetUSBMicState(bool state)
+{
+ struct rilclient_intf *rilc = getInstance();
+
+ if(rilc) {
+ rilc->usbmic_state = state;
+ }
+
+ return ;
+}
+
+int SecRilSetTTYmode(int __unused ttymode)
+{
+ return 0;
+}
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.h b/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.h
new file mode 100644
index 0000000..f4ce158
--- /dev/null
+++ b/libaudio/audiohal_comv1/odm_specific/audioril-sec/secril_interface.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SECRIL_INTERFACE_H__
+#define __SECRIL_INTERFACE_H__
+
+#include <system/audio.h>
+
+int SecRilOpen();
+int SecRilClose();
+int SecRilDuosInit();
+int SecRilCheckConnection();
+int SecRilSetVoiceSolution();
+int SecRilSetExtraVolume(bool on);
+int SecRilSetWbamr(int on);
+int SecRilsetEmergencyMode(bool on);
+int SecRilSetScoSolution(bool echoCancle, int sampleRate);
+int SecRilSetVoiceVolume(int device, int volume, float fvolume);
+int SecRilSetVoicePath(int mode, int device);
+int SecRilSetTxMute(bool state);
+int SecRilSetRxMute(bool state);
+int SecRilSetAudioMode(int mode, bool state);
+int SecRilSetDualMic(bool state);
+int SecRilSetLoopback(int loopbackMode, int rx_device, int tx_device);
+int SecRilSetCurrentModem(int curModem);
+int SecRilRegisterCallback(int rilState, int* callback);
+int SecRilSetRealCallStatus(bool on);
+int SecRilSetVoLTEState(int state);
+void SecRilSetCallFowardingMode(bool callFwd);
+void SecRilDump(int fd __unused);
+void SecRilCheckMultiSim();
+int SecRilSetSoundClkMode(int mode);
+void SecRilSetUSBMicState(bool state);
+int SecRilSetHACMode(bool state);
+int SecRilSetTTYmode(int ttymode);
+
+#endif /* __SECRIL_INTERFACE_H__ */
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril/include/sitril-client.h b/libaudio/audiohal_comv1/odm_specific/audioril/include/sitril-client.h
deleted file mode 100644
index 107e75a..0000000
--- a/libaudio/audiohal_comv1/odm_specific/audioril/include/sitril-client.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __SITRIL_CLIENT_H__
-#define __SITRIL_CLIENT_H__
-
-
-/*
- * These enumerations are from \vendor\samsung_slsi\telephony\exynos-ril\external\libsitril-audiorilaudioapi.h
- */
-
-// error codes
-enum {
- RILAUDIO_ERROR_NONE,
- RILAUDIO_ERROR_NO_FILE,
- RILAUDIO_ERROR_NO_LIB_OPEN_FAIL,
- RILAUDIO_ERROR_SEND_FAIL,
- RILAUDIO_ERROR_NO_DEVICE,
- RILAUDIO_ERROR_INVALID_PARAM,
- RILAUDIO_ERROR_REGISTERATION_FAIL,
- RILAUDIO_ERROR_ALREADY_REGISTERD,
- RILAUDIO_ERROR_MAX
-};
-
-// audio path
-enum
-{
- RILAUDIO_PATH_NONE = 0,
- RILAUDIO_PATH_HANDSET = 1,
- RILAUDIO_PATH_HEADSET = 2,
- RILAUDIO_PATH_HANDSFREE = 3,
- RILAUDIO_PATH_BLUETOOTH = 4,
- RILAUDIO_PATH_STEREO_BLUETOOTH = 5,
- RILAUDIO_PATH_SPEAKRERPHONE = 6,
- RILAUDIO_PATH_35PI_HEADSET = 7,
- RILAUDIO_PATH_BT_NS_EC_OFF = 8,
- RILAUDIO_PATH_WB_BLUETOOTH = 9,
- RILAUDIO_PATH_WB_BT_NS_EC_OFF = 10,
- RILAUDIO_PATH_HANDSET_HAC = 11,
- RILAUDIO_PATH_VOLTE_HANDSET = 65,
- RILAUDIO_PATH_VOLTE_HEADSET = 66,
- RILAUDIO_PATH_VOLTE_HFK = 67,
- RILAUDIO_PATH_VOLTE_BLUETOOTH = 68,
- RILAUDIO_PATH_VOLTE_STEREO_BLUETOOTH = 69,
- RILAUDIO_PATH_VOLTE_SPEAKRERPHONE = 70,
- RILAUDIO_PATH_VOLTE_35PI_HEADSET = 71,
- RILAUDIO_PATH_VOLTE_BT_NS_EC_OFF = 72,
- RILAUDIO_PATH_VOLTE_WB_BLUETOOTH = 73,
- RILAUDIO_PATH_VOLTE_WB_BT_NS_EC_OFF = 74,
- RILAUDIO_PATH_MAX
-};
-
-// Multi MIC control
-enum {
- RILAUDIO_MULTI_MIC_OFF,
- RILAUDIO_MULTI_MIC_ON,
-};
-
-// Volume
-enum {
- RILAUDIO_VOLUME_INVALID = -1,
- RILAUDIO_VOLUME_LEVEL0 = 0,
- RILAUDIO_VOLUME_LEVEL1,
- RILAUDIO_VOLUME_LEVEL2,
- RILAUDIO_VOLUME_LEVEL3,
- RILAUDIO_VOLUME_LEVEL4,
- RILAUDIO_VOLUME_LEVEL5,
- RILAUDIO_VOLUME_LEVEL_MAX = RILAUDIO_VOLUME_LEVEL5,
-};
-
-// Mute
-enum {
- RILAUDIO_MUTE_DISABLED,
- RILAUDIO_MUTE_ENABLED,
-};
-
-// Audio clock
-enum {
- RILAUDIO_TURN_OFF_I2S,
- RILAUDIO_TURN_ON_I2S,
-};
-
-// Audio loopback
-enum {
- RILAUDIO_LOOPBACK_STOP,
- RILAUDIO_LOOPBACK_START,
-};
-
-enum {
- RILAUDIO_LOOPBACK_PATH_NA = 0, //0: N/A
- RILAUDIO_LOOPBACK_PATH_HANDSET = 1, //1: handset
- RILAUDIO_LOOPBACK_PATH_HEADSET = 2, //2: headset
- RILAUDIO_LOOPBACK_PATH_HANDSFREE = 3, //3: handsfree
- RILAUDIO_LOOPBACK_PATH_BT = 4, //4: Bluetooth
- RILAUDIO_LOOPBACK_PATH_STEREO_BT = 5, //5: stereo Bluetooth
- RILAUDIO_LOOPBACK_PATH_SPK = 6, //6: speaker phone
- RILAUDIO_LOOPBACK_PATH_35PI_HEADSET = 7, //7: 3.5pi headset
- RILAUDIO_LOOPBACK_PATH_BT_NS_EC_OFF = 8, //8: BT NS/EC off
- RILAUDIO_LOOPBACK_PATH_WB_BT = 9, //9: WB Bluetooth
- RILAUDIO_LOOPBACK_PATH_WB_BT_NS_EC_OFF = 10, //10: WB BT NS/EC
- RILAUDIO_LOOPBACK_PATH_HANDSET_HAC = 11, //11: handset HAC
-
- RILAUDIO_LOOPBACK_PATH_VOLTE_HANDSET = 65, //65: VOLTE handset
- RILAUDIO_LOOPBACK_PATH_VOLTE_HEADSET = 66, //66: VOLTE headset
- RILAUDIO_LOOPBACK_PATH_VOLTE_HANDSFREE = 67, //67: VOLTE hands
- RILAUDIO_LOOPBACK_PATH_VOLTE_BT = 68, //68: VOLTE Bluetooth
- RILAUDIO_LOOPBACK_PATH_VOLTE_STEREO_BT = 69, //69: VOLTE stere
- RILAUDIO_LOOPBACK_PATH_VOLTE_SPK = 70, //70: VOLTE speaker phone
- RILAUDIO_LOOPBACK_PATH_VOLTE_35PI_HEADSET = 71, //71: VOLTE 3.5pi
- RILAUDIO_LOOPBACK_PATH_VOLTE_BT_NS_EC_OFF = 72, //72: VOLTE BT NS
- RILAUDIO_LOOPBACK_PATH_VOLTE_WB_BT = 73, //73: VOLTE WB Blueto
- RILAUDIO_LOOPBACK_PATH_VOLTE_WB_BT_NS_EC_OFF = 74, //74: VOLTE W
-
- RILAUDIO_LOOPBACK_PATH_HEADSET_MIC1 = 129, //129: Headset ? MIC1
- RILAUDIO_LOOPBACK_PATH_HEADSET_MIC2 = 130, //130: Headset ? MIC2
- RILAUDIO_LOOPBACK_PATH_HEADSET_MIC3 = 131, //131: Headset ? MIC3
-};
-
-// event
-#define RILAUDIO_EVENT_BASE 10000
-#define RILAUDIO_EVENT_RINGBACK_STATE_CHANGED (RILAUDIO_EVENT_BASE + 1)
-#define RILAUDIO_EVENT_IMS_SRVCC_HANDOVER (RILAUDIO_EVENT_BASE + 2)
-
-#endif // __SITRIL_CLIENT_H__
\ No newline at end of file
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.c b/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.c
deleted file mode 100644
index 78665d1..0000000
--- a/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "sitril_interface"
-#define LOG_NDEBUG 0
-
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <log/log.h>
-#include <unistd.h>
-
-#include "AudioRil.h"
-#include "sitril_interface.h"
-
-
-/* The path of RIL Audio Client Library */
-#define RIL_CLIENT_LIBPATH "libsitril-audio.so"
-
-/* Retry for RILClient Open */
-#define MAX_RETRY 10 // Try 10
-#define SLEEP_RETRY 10000 // 10ms sleep
-
-#define CP1 0 // DualCP CP1, DualMode Sim1
-#define CP2 1 // DualCP CP2, DualMode Sim2
-
-
-/******************************************************************************/
-/** **/
-/** RILClient_Interface is Singleton **/
-/** **/
-/******************************************************************************/
-static struct rilclient_intf *instance = NULL;
-
-static struct rilclient_intf* getInstance(void)
-{
- if (instance == NULL) {
- instance = calloc(1, sizeof(struct rilclient_intf));
- ALOGI("proxy-%s: created RILClient Interface Instance!", __func__);
- }
- return instance;
-}
-
-static void destroyInstance(void)
-{
- if (instance) {
- free(instance);
- instance = NULL;
- ALOGI("proxy-%s: destroyed RILClient Interface Instance!", __func__);
- }
- return;
-}
-
-
-/******************************************************************************/
-/** **/
-/** Static functions for RILClient_Interface **/
-/** **/
-/******************************************************************************/
-static int map_incall_device(struct rilclient_intf *voice, audio_devices_t devices)
-{
- int device_type = RILAUDIO_PATH_NONE;
-
- switch(devices) {
- case AUDIO_DEVICE_OUT_EARPIECE:
- if (voice->volte_status == VOLTE_OFF)
- device_type = RILAUDIO_PATH_HANDSET;
- else
- device_type = RILAUDIO_PATH_VOLTE_HANDSET;
- break;
-
- case AUDIO_DEVICE_OUT_SPEAKER:
- if (voice->volte_status == VOLTE_OFF)
- device_type = RILAUDIO_PATH_SPEAKRERPHONE;
- else
- device_type = RILAUDIO_PATH_VOLTE_SPEAKRERPHONE;
- break;
-
- case AUDIO_DEVICE_OUT_WIRED_HEADSET:
- case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
- if (voice->volte_status == VOLTE_OFF)
- device_type = RILAUDIO_PATH_HEADSET;
- else
- device_type = RILAUDIO_PATH_VOLTE_HEADSET;
- break;
-
- case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
- case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
- case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
- if (voice->volte_status == VOLTE_OFF)
- device_type = RILAUDIO_PATH_STEREO_BLUETOOTH;
- else
- device_type = RILAUDIO_PATH_VOLTE_STEREO_BLUETOOTH;
- break;
-
- default:
- if (voice->volte_status == VOLTE_OFF)
- device_type = RILAUDIO_PATH_HANDSET;
- else
- device_type = RILAUDIO_PATH_VOLTE_HANDSET;
- break;
- }
-
- return device_type;
-}
-
-
-/******************************************************************************/
-/** **/
-/** RILClient_Interface Functions **/
-/** **/
-/******************************************************************************/
-int SitRilOpen()
-{
- struct rilclient_intf *rilc = NULL;
- int ret = 0;
-
- /* Create SITRIL Audio Client Interface Structure */
- rilc = getInstance();
- if (!rilc) {
- ALOGE("%s: failed to create for RILClient Interface", __func__);
- goto create_err;
- }
-
- /* Initialize SITRIL Audio Client Interface Structure */
- rilc->handle = NULL;
- rilc->connection = false;
- rilc->extraVolume = false;
- rilc->wbAmr = false;
- rilc->emergencyMode = false;
- rilc->btsco_ec = false;
- rilc->btsco_sr = 8000;
- rilc->audio_mode = 0;
- rilc->audio_state = false;
- rilc->tx_mute = false;
- rilc->rx_mute = false;
- rilc->dualmic = false;
- rilc->current_modem = CP1;
-
- rilc->realcall = false;
- rilc->volte_status = VOLTE_OFF;
- rilc->call_forward = false;
-
- rilc->usbmic_state = false;
-
- /*
- * Open & Connect SITRIL Audio Client Library
- * This library will do real connection with SITRIL
- */
- rilc->handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW);
- if (rilc->handle) {
- rilc->ril_open_client = (int (*)(void))dlsym(rilc->handle, "RilAudioOpen");
- rilc->ril_close_client = (int (*)(void))dlsym(rilc->handle, "RilAudioClose");
- rilc->ril_register_callback = (int (*)(void *, int *))dlsym(rilc->handle, "RegisterEventCallback");
- rilc->ril_set_audio_volume = (int (*)(int))dlsym(rilc->handle, "SetAudioVolume");
- rilc->ril_set_audio_path = (int (*)(int))dlsym(rilc->handle, "SetAudioPath");
- rilc->ril_set_multi_mic = (int (*)(int))dlsym(rilc->handle, "SetMultiMic");
- rilc->ril_set_mute = (int (*)(int))dlsym(rilc->handle, "SetMute");
- rilc->ril_set_audio_clock = (int (*)(int))dlsym(rilc->handle, "SetAudioClock");
- rilc->ril_set_audio_loopback = (int (*)(int, int))dlsym(rilc->handle, "SetAudioLoopback");
-
- ALOGD("%s: Succeeded in getting RIL AudioClient Interface!", __func__);
- } else {
- ALOGE("%s: Failed to open RIL AudioClient Interface(%s)!", __func__, RIL_CLIENT_LIBPATH);
- goto libopen_err;
- }
-
- /* Early open RIL Client */
- if (rilc->ril_open_client) {
- for (int retry = 0; retry < MAX_RETRY; retry++) {
- ret = rilc->ril_open_client();
- if (ret != 0) {
- ALOGE("%s: Failed to open RIL AudioClient! (Try %d)", __func__, retry+1);
- usleep(SLEEP_RETRY); // 10ms
- } else {
- ALOGD("%s: Succeeded in opening RIL AudioClient!", __func__);
- rilc->connection = true;
- break;
- }
- }
-
- if (!rilc->connection)
- goto open_err;
- } else {
- ALOGE("%s: ril_open_client is not available.", __func__);
- goto open_err;
- }
-
- return ret;
-
-open_err:
- if (rilc->handle) {
- dlclose(rilc->handle);
- rilc->handle = NULL;
- }
-
-libopen_err:
- if (rilc) {
- destroyInstance();
- rilc = NULL;
- }
-
-create_err:
- return -1;
-}
-
-int SitRilClose()
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if (rilc) {
- if (rilc->connection && rilc->ril_close_client) {
- ret = rilc->ril_close_client();
- if (ret == 0)
- ALOGD("%s: Closed RIL AudioClient", __func__);
- else
- ALOGE("%s: Failed to close RIL AudioClient!", __func__);
-
- rilc->connection = false;
- }
-
- if (rilc->handle) {
- dlclose(rilc->handle);
- rilc->handle = NULL;
- }
-
- destroyInstance();
- }
-
- return 0;
-}
-
-int SitRilDuosInit()
-{
- int ret = 0;
-
- // Not Supported Dual RIL
-
- return ret;
-}
-
-int SitRilCheckConnection()
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->connection)
- ret = 1;
- }
-
- return ret;
-}
-
-int SitRilSetVoiceSolution()
-{
- int ret = 0;
-
- // Not Supported Voice Solution by CP
-
- return ret;
-}
-
-int SitRilSetExtraVolume(bool on)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- // Not Supported Extra Volume
- rilc->extraVolume = on;
- }
-
- return ret;
-}
-
-int SitRilSetWbamr(int on)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- // Not Supported WideBand
- rilc->wbAmr = (bool)on;
- }
-
- return ret;
-}
-
-int SitRilsetEmergencyMode(bool on)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- // Not Supported Emergency Mode
- rilc->emergencyMode = on;
- }
-
- return ret;
-}
-
-int SitRilSetScoSolution(bool echoCancle, int sampleRate)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- // Not Supported BT SCO Solution by CP
- rilc->btsco_ec = echoCancle;
- rilc->btsco_sr = sampleRate;
- }
-
- return ret;
-}
-
-int SitRilSetVoiceVolume(int device __unused, int volume, float fvolume)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_set_audio_volume)
- rilc->ril_set_audio_volume(volume);
-
- ALOGD("%s: Volume = %d(%f)!", __func__, volume, fvolume);
- }
-
- return ret;
-}
-
-int SitRilSetVoicePath(int mode __unused, int device)
-{
- struct rilclient_intf *rilc = getInstance();
- int path = RILAUDIO_PATH_NONE;
- int ret = 0;
-
- if(rilc) {
- path = map_incall_device(rilc, device);
- if (rilc->ril_set_audio_path) {
- ret = rilc->ril_set_audio_path(path);
- ALOGD("%s: set Voice Path to %d!", __func__, path);
- }
- }
-
- return ret;
-}
-
-int SitRilSetAudioMode(int mode, bool state)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->audio_mode = mode;
- rilc->audio_state = state;
- }
-
- return ret;
-}
-
-int SitRilSetTxMute(bool state)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_set_mute) {
- if (state)
- rilc->ril_set_mute(RILAUDIO_MUTE_ENABLED);
- else
- rilc->ril_set_mute(RILAUDIO_MUTE_DISABLED);
- }
- rilc->tx_mute = state;
- }
-
- return ret;
-}
-
-int SitRilSetRxMute(bool state)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->rx_mute = state;
- }
-
- return ret;
-}
-
-int SitRilSetDualMic(bool state)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->dualmic = state;
- }
-
- return ret;
-}
-
-int SitRilSetLoopback(int loopbackMode __unused, int rx_device __unused, int tx_device __unused)
-{
- struct rilclient_intf *rilc = getInstance();
- int onoff = 0;
- int path = RILAUDIO_LOOPBACK_PATH_NA;
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_set_audio_loopback)
- rilc->ril_set_audio_loopback(onoff, path);
- }
-
- return ret;
-}
-
-int SitRilSetCurrentModem(int curModem)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->current_modem = curModem;
- }
-
- return ret;
-}
-
-int SitRilRegisterCallback(int rilState __unused, int * callback)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_register_callback)
- ret = rilc->ril_register_callback((void *)rilc, callback);
- }
-
- return ret;
-}
-
-int SitRilRegisterCallbackWithHandle(void * handle, int * callback)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_register_callback)
- ret = rilc->ril_register_callback((void *)handle, callback);
- }
-
- return ret;
-}
-
-int SitRilSetRealCallStatus(bool on)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->realcall = on;
- }
-
- return ret;
-}
-
-int SitRilSetVoLTEState(int state)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- rilc->volte_status = state;
- }
-
- return ret;
-}
-
-void SitRilSetCallFowardingMode(bool callFwd)
-{
- struct rilclient_intf *rilc = getInstance();
-
- if(rilc) {
- rilc->call_forward = callFwd;
- }
-
- return ;
-}
-
-void SitRilDump(int fd __unused)
-{
- return ;
-}
-
-void SitRilCheckMultiSim()
-{
- return ;
-}
-
-int SitRilSetSoundClkMode(int mode)
-{
- struct rilclient_intf *rilc = getInstance();
- int ret = 0;
-
- if(rilc) {
- if (rilc->ril_set_audio_clock) {
- if (mode)
- rilc->ril_set_audio_clock(RILAUDIO_TURN_ON_I2S);
- else
- rilc->ril_set_audio_clock(RILAUDIO_TURN_OFF_I2S);
- }
- }
-
- return ret;
-}
-
-void SitRilSetUSBMicState(bool state)
-{
- struct rilclient_intf *rilc = getInstance();
-
- if(rilc) {
- rilc->usbmic_state = state;
- }
-
- return ;
-}
diff --git a/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.h b/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.h
deleted file mode 100644
index 5e0f299..0000000
--- a/libaudio/audiohal_comv1/odm_specific/audioril/sitril_interface.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __SITRIL_INTERFACE_H__
-#define __SITRIL_INTERFACE_H__
-
-
-#include <system/audio.h>
-
-int SitRilOpen();
-int SitRilClose();
-int SitRilDuosInit();
-int SitRilCheckConnection();
-int SitRilSetVoiceSolution();
-int SitRilSetExtraVolume(bool on);
-int SitRilSetWbamr(int on);
-int SitRilsetEmergencyMode(bool on);
-int SitRilSetScoSolution(bool echoCancle, int sampleRate);
-int SitRilSetVoiceVolume(int device, int volume, float fvolume);
-int SitRilSetVoicePath(int mode, int device);
-int SitRilSetTxMute(bool state);
-int SitRilSetRxMute(bool state);
-int SitRilSetAudioMode(int mode, bool state);
-int SitRilSetDualMic(bool state);
-int SitRilSetLoopback(int loopbackMode, int rx_device, int tx_device);
-int SitRilSetCurrentModem(int curModem);
-int SitRilRegisterCallback(int rilState, int* callback);
-int SitRilRegisterCallbackWithHandle(void * handle, int * callback);
-int SitRilSetRealCallStatus(bool on);
-int SitRilSetVoLTEState(int state);
-void SitRilSetCallFowardingMode(bool callFwd);
-void SitRilDump(int fd __unused);
-void SitRilCheckMultiSim();
-int SitRilSetSoundClkMode(int mode);
-void SitRilSetUSBMicState(bool state);
-
-
-#endif /* __SITRIL_INTERFACE_H__ */
diff --git a/libaudio/audiohal_comv1/odm_specific/sit_specific.h b/libaudio/audiohal_comv1/odm_specific/sit_specific.h
deleted file mode 100644
index ed255fc..0000000
--- a/libaudio/audiohal_comv1/odm_specific/sit_specific.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AUDIOHAL_SITSPECIFIC_H__
-#define __AUDIOHAL_SITSPECIFIC_H__
-
-
-// RIL Client for Audio
-#define RIL_CLIENT_LIBPATH "/system/lib/libsitril-audio.so"
-
-#define AUDIO_PARAMETER_VOLTE_STATUS "VoLTEstate"
-
-
-/* Syncup with RIL Audio Client */
-
-/* Voice Audio Path */
-enum ril_audio_path {
- VOICE_AUIDO_PATH_NONE = 0,
-
- VOICE_AUDIO_PATH_HANDSET = 1,
- VOICE_AUIDO_PATH_HEADSET = 2,
- VOICE_AUIDO_PATH_HANDSFREE = 3,
- VOICE_AUIDO_PATH_BLUETOOTH = 4,
- VOICE_AUIDO_PATH_STEREO_BLUETOOTH = 5,
- VOICE_AUIDO_PATH_SPEAKRERPHONE = 6,
- VOICE_AUIDO_PATH_35PI_HEADSET = 7,
- VOICE_AUIDO_PATH_BT_NS_EC_OFF = 8,
- VOICE_AUIDO_PATH_WB_BLUETOOTH = 9,
- VOICE_AUIDO_PATH_WB_BT_NS_EC_OFF = 10,
- VOICE_AUIDO_PATH_HANDSET_HAC = 11,
-
- VOICE_AUIDO_PATH_VOLTE_HANDSET = 65,
- VOICE_AUIDO_PATH_VOLTE_HEADSET = 66,
- VOICE_AUIDO_PATH_VOLTE_HFK = 67,
- VOICE_AUIDO_PATH_VOLTE_BLUETOOTH = 68,
- VOICE_AUIDO_PATH_VOLTE_STEREO_BLUETOOTH = 69,
- VOICE_AUIDO_PATH_VOLTE_SPEAKRERPHONE = 70,
- VOICE_AUIDO_PATH_VOLTE_35PI_HEADSET = 71,
- VOICE_AUIDO_PATH_VOLTE_BT_NS_EC_OFF = 72,
- VOICE_AUIDO_PATH_VOLTE_WB_BLUETOOTH = 73,
- VOICE_AUIDO_PATH_VOLTE_WB_BT_NS_EC_OFF = 74,
- VOICE_AUIDO_PATH_MAX
-};
-
-/* Voice Audio Multi-MIC */
-enum ril_audio_multimic {
- VOICE_MULTI_MIC_OFF,
- VOICE_MULTI_MIC_ON,
-};
-
-/* Voice Audio Volume */
-enum ril_audio_volume {
- VOICE_AUDIO_VOLUME_INVALID = -1,
- VOICE_AUDIO_VOLUME_LEVEL0 = 0,
- VOICE_AUDIO_VOLUME_LEVEL1,
- VOICE_AUDIO_VOLUME_LEVEL2,
- VOICE_AUDIO_VOLUME_LEVEL3,
- VOICE_AUDIO_VOLUME_LEVEL4,
- VOICE_AUDIO_VOLUME_LEVEL5,
- VOICE_AUDIO_VOLUME_LEVEL_MAX = VOICE_AUDIO_VOLUME_LEVEL5,
-};
-
-/* Voice Audio Mute */
-enum ril_audio_mute {
- VOICE_AUDIO_MUTE_DISABLED,
- VOICE_AUDIO_MUTE_ENABLED,
-};
-
-/* Voice Audio Clock */
-enum ril_audio_clockmode {
- VOICE_AUDIO_TURN_OFF_I2S,
- VOICE_AUDIO_TURN_ON_I2S,
-};
-
-/* Voice Loopback */
-enum ril_audio_loopback {
- VOICE_AUDIO_LOOPBACK_STOP,
- VOICE_AUDIO_LOOPBACK_START,
-};
-
-enum ril_audio_loopback_path {
- VOICE_AUDIO_LOOPBACK_PATH_NA = 0, //0: N/A
-
- VOICE_AUDIO_LOOPBACK_PATH_HANDSET = 1, //1: handset
- VOICE_AUDIO_LOOPBACK_PATH_HEADSET = 2, //2: headset
- VOICE_AUDIO_LOOPBACK_PATH_HANDSFREE = 3, //3: handsfree
- VOICE_AUDIO_LOOPBACK_PATH_BT = 4, //4: Bluetooth
- VOICE_AUDIO_LOOPBACK_PATH_STEREO_BT = 5, //5: stereo Bluetooth
- VOICE_AUDIO_LOOPBACK_PATH_SPK = 6, //6: speaker phone
- VOICE_AUDIO_LOOPBACK_PATH_35PI_HEADSET = 7, //7: 3.5pi headset
- VOICE_AUDIO_LOOPBACK_PATH_BT_NS_EC_OFF = 8, //8: BT NS/EC off
- VOICE_AUDIO_LOOPBACK_PATH_WB_BT = 9, //9: WB Bluetooth
- VOICE_AUDIO_LOOPBACK_PATH_WB_BT_NS_EC_OFF = 10, //10: WB BT NS/EC
- VOICE_AUDIO_LOOPBACK_PATH_HANDSET_HAC = 11, //11: handset HAC
-
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_HANDSET = 65, //65: VOLTE handset
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_HEADSET = 66, //66: VOLTE headset
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_HANDSFREE = 67, //67: VOLTE hands
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_BT = 68, //68: VOLTE Bluetooth
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_STEREO_BT = 69, //69: VOLTE stere
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_SPK = 70, //70: VOLTE speaker phone
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_35PI_HEADSET = 71, //71: VOLTE 3.5pi
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_BT_NS_EC_OFF = 72, //72: VOLTE BT NS
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_WB_BT = 73, //73: VOLTE WB Blueto
- VOICE_AUDIO_LOOPBACK_PATH_VOLTE_WB_BT_NS_EC_OFF = 74, //74: VOLTE W
-
- VOICE_AUDIO_LOOPBACK_PATH_HEADSET_MIC1 = 129, //129: Headset ? MIC1
- VOICE_AUDIO_LOOPBACK_PATH_HEADSET_MIC2 = 130, //130: Headset ? MIC2
- VOICE_AUDIO_LOOPBACK_PATH_HEADSET_MIC3 = 131, //131: Headset ? MIC3
-};
-
-
-/* Event from RIL Audio Client */
-#define VOICE_AUDIO_EVENT_BASE 10000
-#define VOICE_AUDIO_EVENT_RINGBACK_STATE_CHANGED (VOICE_AUDIO_EVENT_BASE + 1)
-#define VOICE_AUDIO_EVENT_IMS_SRVCC_HANDOVER (VOICE_AUDIO_EVENT_BASE + 2)
-
-
-/* RIL Audio Client Interface Structure */
-struct rilclient_intf {
- /* The pointer of interface library for RIL Client*/
- void *handle;
-
- /* Function pointers */
- int (*ril_open_client)(void);
- int (*ril_close_client)(void);
- int (*ril_register_callback)(void *, int *);
- int (*ril_set_audio_volume)(int);
- int (*ril_set_audio_path)(int);
- int (*ril_set_multi_mic)(int);
- int (*ril_set_mute)(int);
- int (*ril_set_audio_clock)(int);
- int (*ril_set_audio_loopback)(int, int);
-};
-
-#endif // __AUDIOHAL_SITSPECIFIC_H__
diff --git a/libaudio/audiohal_comv1/odm_specific/voice_manager_sec.c b/libaudio/audiohal_comv1/odm_specific/voice_manager_sec.c
new file mode 100644
index 0000000..4269990
--- /dev/null
+++ b/libaudio/audiohal_comv1/odm_specific/voice_manager_sec.c
@@ -0,0 +1,496 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "voice_manager"
+#define LOG_NDEBUG 0
+
+#include <stdlib.h>
+#include <errno.h>
+
+#include <log/log.h>
+#include <cutils/str_parms.h>
+#include <cutils/properties.h>
+
+#include "audio_hw.h"
+#include "voice_manager.h"
+#include "secril_interface.h"
+
+#include "audio_proxy_interface.h"
+
+#define VOLUME_STEPS_DEFAULT "5"
+#define VOLUME_STEPS_PROPERTY "ro.vendor.config.vc_call_vol_steps"
+
+
+#define DEVICE_INVALID -1
+
+
+
+/*
+ * Local Functions
+ */
+static int voice_set_sco_solution(struct voice_manager *voice, bool echo_cancel, int sample_rate)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetScoSolution(echo_cancel, sample_rate);
+ }
+ return ret;
+}
+
+static int voice_set_volte_status(struct voice_manager *voice, int status)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetVoLTEState(status);
+ }
+ return ret;
+}
+
+static int voice_set_hac_mode(struct voice_manager *voice, bool status)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetHACMode(status);
+ }
+ return ret;
+}
+
+/*
+ * Status Check Functions
+ */
+bool voice_is_call_mode(struct voice_manager *voice)
+{
+ // True means Android Audio Mode is IN_CALL Mode
+ return (voice->call_status >= CALL_STATUS_INCALLMODE);
+}
+
+bool voice_is_call_active(struct voice_manager *voice)
+{
+ // True means Voice Call is working (Audio PCM for CP Call is Opened)
+ return (voice->call_status == CALL_STATUS_ACTIVE);
+}
+
+
+/*
+ * Set Functions
+ */
+int voice_set_call_mode(struct voice_manager *voice, bool on)
+{
+ int ret = 0;
+
+ if (voice->call_status == CALL_STATUS_INVALID && on) {
+ // RIL Audio Client is not connected yet, Re-Try!!!
+ ALOGD("vm-%s: RilClient is not opened yet! Retry!", __func__);
+ ret = SecRilOpen();
+ if (ret == 0)
+ voice->call_status = CALL_STATUS_CONNECTED;
+ else
+ voice->call_status = CALL_STATUS_INVALID;
+ }
+
+ if (voice->call_status == CALL_STATUS_CONNECTED && on)
+ voice->call_status = CALL_STATUS_INCALLMODE;
+ else if (voice->call_status == CALL_STATUS_INCALLMODE && !on)
+ voice->call_status = CALL_STATUS_CONNECTED;
+ else
+ ALOGE("vm-%s: Invalid Voice Call Status(%d) with %d", __func__, voice->call_status, on);
+
+ return ret;
+}
+
+int voice_set_call_active(struct voice_manager *voice, bool on)
+{
+ int ret = 0;
+
+ if (voice->call_status == CALL_STATUS_INCALLMODE && on) {
+ voice->call_status = CALL_STATUS_ACTIVE;
+ SecRilSetSoundClkMode(1);
+ } else if (voice->call_status == CALL_STATUS_ACTIVE && !on) {
+ voice->call_status = CALL_STATUS_INCALLMODE;
+ SecRilSetSoundClkMode(0);
+ } else
+ ALOGE("vm-%s: Invalid Voice Call Status(%d) with %d", __func__, voice->call_status, on);
+
+ return ret;
+}
+
+int voice_set_audio_mode(struct voice_manager *voice, int mode, bool status)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetAudioMode(mode, status);
+ }
+ return ret;
+}
+
+int voice_set_volume(struct voice_manager *voice, float volume)
+{
+ int ret = 0;
+
+ if (voice->call_status == CALL_STATUS_ACTIVE) {
+ SecRilSetVoiceVolume(voice->out_device, (int)(volume * voice->volume_steps_max), volume);
+ ALOGD("vm-%s: Volume = %d(%f)!", __func__, (int)(volume * voice->volume_steps_max), volume);
+ } else {
+ ALOGE("vm-%s: Voice is not Active", __func__);
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int voice_set_extra_volume(struct voice_manager *voice, bool on)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetExtraVolume(on);
+ }
+ return ret;
+}
+
+int voice_set_path(struct voice_manager *voice, audio_devices_t devices)
+{
+ int ret = 0;
+ int mode = AUDIO_MODE_IN_CALL;
+
+ if (voice_is_call_mode(voice)) {
+ voice->out_device = devices;
+ SecRilSetVoicePath(mode, devices);
+ } else {
+ ALOGE("%s: Voice is not created", __func__);
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int voice_set_mic_mute(struct voice_manager *voice, bool status)
+{
+ int ret = 0;
+ if (voice_is_call_mode(voice) || (voice->loopback_mode != FACTORY_LOOPBACK_OFF)) {
+ SecRilSetTxMute(status);
+ }
+ ALOGD("vm-%s: MIC Mute = %d!", __func__, status);
+ return ret;
+}
+
+int voice_set_rx_mute(struct voice_manager *voice, bool status)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetRxMute(status);
+ }
+ return ret;
+}
+
+int voice_set_usb_mic(struct voice_manager *voice, bool status)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetUSBMicState(status);
+ }
+ return ret;
+}
+
+void voice_set_call_forwarding(struct voice_manager *voice, bool callfwd)
+{
+ if (voice) {
+ SecRilSetCallFowardingMode(callfwd);
+ }
+ return;
+}
+
+void voice_set_cur_indevice_id(struct voice_manager *voice, int device)
+{
+ voice->in_device_id = device;
+ return;
+}
+
+void voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
+{
+ struct voice_manager *voice = adev->voice;
+ char value[40];
+ int ret = 0;
+
+ char *kv_pairs = str_parms_to_str(parms);
+
+ //ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
+
+ // VoLTE Status Configuration
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_VOLTE_STATUS, value, sizeof(value));
+ if (ret >= 0) {
+ if (!strcmp(value, "voice")) {
+ voice->volte_status = VOLTE_VOICE;
+ ALOGD("vm-%s: VoLTE Voice Call Start!!", __func__);
+ } else if (!strcmp(value, "end")) {
+ voice->volte_status = VOLTE_OFF;
+ ALOGD("vm-%s: VoLTE Voice Call End!!", __func__);
+ } else
+ ALOGD("vm-%s: Unknown VoLTE parameters = %s!!", __func__, value);
+
+ voice_set_volte_status(voice, voice->volte_status);
+ }
+
+ // BT SCO NREC Configuration
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
+ if (ret >= 0) {
+ if (!strcmp(value, AUDIO_PARAMETER_VALUE_ON)) {
+ voice->bluetooth_nrec = BT_NREC_ON;
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_OFF)) {
+ voice->bluetooth_nrec = BT_NREC_OFF;
+ }
+
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_BT_NREC);
+ }
+
+ // BT SCO WideBand Configuration
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_SCO_WB, value, sizeof(value));
+ if (ret >= 0) {
+ if (!strcmp(value, AUDIO_PARAMETER_VALUE_ON)) {
+ voice->bluetooth_samplerate = WB_SAMPLING_RATE;
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_OFF)) {
+ voice->bluetooth_samplerate = NB_SAMPLING_RATE;
+ }
+
+ uint32_t device = 0;
+ if (adev->primary_output)
+ device = adev->primary_output->common.requested_devices & AUDIO_DEVICE_OUT_ALL_SCO;
+
+ voice_set_sco_solution(voice, voice->bluetooth_nrec, voice->bluetooth_samplerate);
+
+ if(voice_is_call_active(voice) && (device != 0)) {
+ voice_set_path(voice, adev->primary_output->common.requested_devices);
+ }
+
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_BT_SCO_WB);
+ }
+
+ // TTY Status Configuration
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
+ if (ret >= 0) {
+ if (!strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF)) {
+ voice->tty_mode = TTY_MODE_OFF;
+ voice_set_tty_mode(voice,TTY_MODE_OFF_RIL);
+ ALOGD("vm-%s: TTY_MODE_OFF", __func__);
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_TTY_VCO)) {
+ voice->tty_mode = TTY_MODE_VCO;
+ voice_set_tty_mode(voice,TTY_MODE_VCO_RIL);
+ ALOGD("vm-%s: TTY_MODE_VCO", __func__);
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_TTY_HCO)) {
+ voice->tty_mode = TTY_MODE_HCO;
+ voice_set_tty_mode(voice,TTY_MODE_HCO_RIL);
+ ALOGD("vm-%s: TTY_MODE_HCO", __func__);
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_TTY_FULL)) {
+ voice->tty_mode = TTY_MODE_FULL;
+ voice_set_tty_mode(voice,TTY_MODE_FULL_RIL);
+ ALOGD("vm-%s: TTY_MODE_FULL", __func__);
+ } else
+ ALOGD("vm-%s: Unknown TTY_MODE parameters = %s!!", __func__, value);
+
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_TTY_MODE);
+ }
+
+ // HAC(Hearing Aid Compatibility) Status Configuration
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HAC, value, sizeof(value));
+ if (ret >= 0) {
+ if (!strcmp(value, AUDIO_PARAMETER_VALUE_HAC_ON)) {
+ voice->hac_mode = HAC_MODE_ON;
+ voice_set_hac_mode(voice,true);
+ ALOGD("vm-%s: HAC_MODE_ON", __func__);
+ } else if (!strcmp(value, AUDIO_PARAMETER_VALUE_HAC_OFF)) {
+ voice->hac_mode = HAC_MODE_OFF;
+ voice_set_hac_mode(voice,false);
+ ALOGD("vm-%s: HAC_MODE_OFF", __func__);
+ } else
+ ALOGD("vm-%s: Unknown HAC_MODE parameters = %s!!", __func__, value);
+
+ if (voice_is_call_active(voice)
+ && adev->primary_output
+ && adev->primary_output->common.requested_devices != 0) {
+ voice_set_path(voice, adev->primary_output->common.requested_devices);
+ }
+
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_HAC);
+ }
+
+ //ALOGV("%s: exit with code(%d)", __func__, ret);
+
+ free(kv_pairs);
+ return ;
+}
+
+int voice_set_callback(struct voice_manager * voice __unused, void * callback_func )
+{
+ int ret = 0;
+
+ SecRilRegisterCallback(0, callback_func);
+ return ret;
+}
+
+
+/*
+ * Get Functions
+ */
+volte_status_t voice_get_volte_status(struct voice_manager *voice)
+{
+ return voice->volte_status;
+}
+
+int voice_get_samplingrate(struct voice_manager *voice)
+{
+ return voice->voice_samplingrate;
+}
+
+int voice_get_vowifi_band(struct voice_manager *voice)
+{
+ return voice->vowifi_band;
+}
+
+int voice_get_cur_indevice_id(struct voice_manager *voice)
+{
+ return voice->in_device_id;
+}
+
+
+/*
+ * Other Functions
+ */
+int voice_set_loopback_device(struct voice_manager *voice, int mode, int rx_dev, int tx_dev)
+{
+ int ret = 0;
+ if (voice) {
+ voice->loopback_mode = mode;
+ if (rx_dev == (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER)) {
+ ALOGI("%s: Set loopback rx path as RCV (Speaker2)", __func__);
+ rx_dev = AUDIO_DEVICE_OUT_EARPIECE; // set rcv as speaker2
+ }
+ SecRilSetLoopback(mode, rx_dev, tx_dev);
+ }
+ return ret;
+}
+
+void voice_ril_dump(int fd __unused)
+{
+ SecRilDump(fd);
+}
+
+int voice_get_volume_index(struct voice_manager *voice, float volume)
+{
+ return (int)(volume * voice->volume_steps_max);
+}
+
+int voice_set_tty_mode(struct voice_manager *voice, int ttymode)
+{
+ int ret = 0;
+ if (voice) {
+ SecRilSetTTYmode(ttymode);
+ }
+ return ret;
+}
+
+int voice_callback(void * handle, int event, const void *data, unsigned int datalen)
+{
+ struct voice_manager *voice = (struct voice_manager *)handle;
+ int (*funcp)(int, const void *, unsigned int) = NULL;
+
+ ALOGD("vm-%s: Called Callback Function from RIL Audio Client!", __func__);
+ if (voice) {
+#if 0
+ switch (event) {
+ case VOICE_AUDIO_EVENT_RINGBACK_STATE_CHANGED:
+ ALOGD("vm-%s: Received RINGBACK_STATE_CHANGED event!", __func__);
+ break;
+
+ case VOICE_AUDIO_EVENT_IMS_SRVCC_HANDOVER:
+ ALOGD("vm-%s: Received IMS_SRVCC_HANDOVER event!", __func__);
+ break;
+
+ default:
+ ALOGD("vm-%s: Received Unsupported event (%d)!", __func__, event);
+ return 0;
+ }
+#endif
+ funcp = voice->callback;
+ funcp(event, data, datalen);
+ }
+
+ return 0;
+}
+
+void voice_deinit(struct voice_manager *voice)
+{
+ if (voice) {
+ /* RIL */
+ SecRilClose();
+ free(voice);
+ }
+
+ return ;
+}
+
+struct voice_manager* voice_init(void)
+{
+ struct voice_manager *voice = NULL;
+ char property[PROPERTY_VALUE_MAX];
+ int ret = 0;
+
+ voice = calloc(1, sizeof(struct voice_manager));
+ if (voice) {
+
+ // At initial time, try to connect to AudioRIL
+ ret = SecRilOpen();
+ if (ret == 0)
+ voice->call_status = CALL_STATUS_CONNECTED;
+ else
+ voice->call_status = CALL_STATUS_INVALID;
+
+ // Variables
+ voice->realcall = false;
+ voice->csvtcall = false;
+ voice->keep_call_mode = false;
+
+ voice->out_device = AUDIO_DEVICE_NONE;
+ voice->in_device_id = DEVICE_INVALID;
+ voice->bluetooth_nrec = BT_NREC_INITIALIZED;
+ voice->bluetooth_samplerate = NB_SAMPLING_RATE;
+ voice->tty_mode = TTY_MODE_OFF;
+ voice->call_forwarding = false;
+ voice->mute_voice = false;
+ voice->cur_modem = CP1;
+ voice->extra_volume = false;
+
+ voice->voice_samplingrate = VOICE_SR_NB;
+ voice->loopback_mode = FACTORY_LOOPBACK_OFF;
+
+ // VoIP
+ voice->voip_wificalling = false;
+ voice->voip_rx_active = false;
+ voice->vowifi_band = WB;
+
+ // VoLTE
+ voice->volte_status = VOLTE_OFF;
+ voice->previous_volte_status = VOLTE_OFF;
+
+ property_get(VOLUME_STEPS_PROPERTY, property, VOLUME_STEPS_DEFAULT);
+ voice->volume_steps_max = atoi(property);
+ /* this catches the case where VOLUME_STEPS_PROPERTY does not contain an integer */
+ if (voice->volume_steps_max == 0)
+ voice->volume_steps_max = atoi(VOLUME_STEPS_DEFAULT);
+
+ voice->callback = NULL;
+ }
+
+ return voice;
+}
diff --git a/libaudio/audiohal_comv1/odm_specific/voice_manager.c b/libaudio/audiohal_comv1/odm_specific/voice_manager_sit.c
similarity index 100%
rename from libaudio/audiohal_comv1/odm_specific/voice_manager.c
rename to libaudio/audiohal_comv1/odm_specific/voice_manager_sit.c