hal: Retrieve ahal feature flags from audioconfigstore
Update ahal_config_helper to fetch feature flags from
audioconfigstore.
Change-Id: I91c6c21df8f781420d03c027f54d8a7529e746fd
diff --git a/hal/ahal_config_helper.cpp b/hal/ahal_config_helper.cpp
index 63f44ab..1aac8c2 100644
--- a/hal/ahal_config_helper.cpp
+++ b/hal/ahal_config_helper.cpp
@@ -30,34 +30,88 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ahal_config_helper"
-#include "ahal_config_helper.h"
#include <cutils/properties.h>
+#include <dlfcn.h>
#include <log/log.h>
+#include "ahal_config_helper.h"
struct AHalConfigHelper {
static AHalConfigHelper* mConfigHelper;
+ AHalConfigHelper() {};
- AHalConfigHelper() : isRemote(false) { };
static AHalConfigHelper* getAHalConfInstance() {
if (!mConfigHelper)
mConfigHelper = new AHalConfigHelper();
return mConfigHelper;
}
- void initDefaultConfig(bool isVendorEnhancedFwk);
- AHalValues* getAHalValues();
- inline void retrieveConfigs();
-
- AHalValues mConfigs;
- bool isRemote; // configs specified from remote
+ void initConfigHelper(bool isVendorEnhancedFwk);
+ void getAHalValues(AHalValues* *confValues);
+ AHalValues defaultConfigs;
};
AHalConfigHelper* AHalConfigHelper::mConfigHelper;
+static AHalValues* (*getAHalConfigs)() = nullptr;
-void AHalConfigHelper::initDefaultConfig(bool isVendorEnhancedFwk)
+void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk)
{
ALOGV("%s: enter", __FUNCTION__);
+
+ void *handle = dlopen(AUDIO_CONFIGSTORE_LIB_PATH, RTLD_NOW);
+ if (handle != nullptr) {
+ getAHalConfigs = (AHalValues*(*)())
+ dlsym(handle, "getAudioHalExtConfigs");
+ if (!getAHalConfigs) {
+ ALOGE("%s: Could not find symbol: %s", __FUNCTION__, dlerror());
+ handle = nullptr;
+ dlclose(handle);
+ }
+ }
+
+#ifdef LINUX_ENABLED
+ defaultConfigs = {
+ true, /* SND_MONITOR */
+ false, /* COMPRESS_CAPTURE */
+ true, /* SOURCE_TRACK */
+ true, /* SSREC */
+ true, /* AUDIOSPHERE */
+ true, /* AFE_PROXY */
+ false, /* USE_DEEP_AS_PRIMARY_OUTPUT */
+ true, /* HDMI_EDID */
+ false, /* KEEP_ALIVE */
+ false, /* HIFI_AUDIO */
+ true, /* RECEIVER_AIDED_STEREO */
+ true, /* KPI_OPTIMIZE */
+ true, /* DISPLAY_PORT */
+ true, /* FLUENCE */
+ false, /* CUSTOM_STEREO */
+ true, /* ANC_HEADSET */
+ true, /* SPKR_PROT */
+ true, /* FM_POWER_OPT */
+ false, /* EXTERNAL_QDSP */
+ false, /* EXTERNAL_SPEAKER */
+ false, /* EXTERNAL_SPEAKER_TFA */
+ false, /* HWDEP_CAL */
+ false, /* DSM_FEEDBACK */
+ true, /* USB_OFFLOAD */
+ false, /* USB_OFFLOAD_BURST_MODE */
+ false, /* USB_OFFLOAD_SIDETONE_VOLM */
+ true, /* A2DP_OFFLOAD */
+ true, /* HFP */
+ true, /* VBAT */
+ true, /* EXT_HW_PLUGIN */
+ false, /* RECORD_PLAY_CONCURRENCY */
+ true, /* HDMI_PASSTHROUGH */
+ false, /* CONCURRENT_CAPTURE */
+ false, /* COMPRESS_IN */
+ false, /* BATTERY_LISTENER */
+ true, /* COMPRESS_METADATA_NEEDED */
+ false, /* INCALL_MUSIC */
+ false, /* COMPRESS_VOIP */
+ true, /* DYNAMIC_ECNS */
+ };
+#else
if (isVendorEnhancedFwk) {
- mConfigs = {
+ defaultConfigs = {
true, /* SND_MONITOR */
false, /* COMPRESS_CAPTURE */
true, /* SOURCE_TRACK */
@@ -85,13 +139,21 @@
false, /* USB_OFFLOAD_BURST_MODE */
false, /* USB_OFFLOAD_SIDETONE_VOLM */
true, /* A2DP_OFFLOAD */
+ true, /* HFP */
true, /* VBAT */
+ true, /* EXT_HW_PLUGIN */
+ false, /* RECORD_PLAY_CONCURRENCY */
+ true, /* HDMI_PASSTHROUGH */
+ true, /* CONCURRENT_CAPTURE */
+ true, /* COMPRESS_IN */
+ true, /* BATTERY_LISTENER */
true, /* COMPRESS_METADATA_NEEDED */
+ true, /* INCALL_MUSIC */
false, /* COMPRESS_VOIP */
- false, /* DYNAMIC_ECNS */
+ true, /* DYNAMIC_ECNS */
};
} else {
- mConfigs = {
+ defaultConfigs = {
true, /* SND_MONITOR */
false, /* COMPRESS_CAPTURE */
false, /* SOURCE_TRACK */
@@ -119,54 +181,49 @@
false, /* USB_OFFLOAD_BURST_MODE */
false, /* USB_OFFLOAD_SIDETONE_VOLM */
true, /* A2DP_OFFLOAD */
+ true, /* HFP */
false, /* VBAT */
+ false, /* EXT_HW_PLUGIN */
+ false, /* RECORD_PLAY_CONCURRENCY */
+ false, /* HDMI_PASSTHROUGH */
+ true, /* CONCURRENT_CAPTURE */
+ false, /* COMPRESS_IN */
+ false, /* BATTERY_LISTENER */
false, /* COMPRESS_METADATA_NEEDED */
+ true, /* INCALL_MUSIC */
false, /* COMPRESS_VOIP */
false, /* DYNAMIC_ECNS */
};
}
+#endif
}
-AHalValues* AHalConfigHelper::getAHalValues()
+void AHalConfigHelper::getAHalValues(AHalValues* *confValues)
{
- ALOGV("%s: enter", __FUNCTION__);
- retrieveConfigs();
- return &mConfigs;
-}
+ if (getAHalConfigs != nullptr)
+ *confValues = getAHalConfigs();
-void AHalConfigHelper::retrieveConfigs()
-{
- ALOGV("%s: enter", __FUNCTION__);
- // ToDo: Add logic to query AHalValues from config store
- // once support is added to it
- return;
+ if (*confValues == nullptr) {
+ ALOGI("%s: Could not retrieve flags from configstore, setting defaults",
+ __FUNCTION__);
+ *confValues = &defaultConfigs;
+ }
}
extern "C" {
-AHalValues* confValues = nullptr;
-
void audio_extn_ahal_config_helper_init(bool is_vendor_enhanced_fwk)
{
AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
- if (confInstance)
- confInstance->initDefaultConfig(is_vendor_enhanced_fwk);
+ if (confInstance != nullptr)
+ confInstance->initConfigHelper(is_vendor_enhanced_fwk);
}
-AHalValues* audio_extn_get_feature_values()
+void audio_extn_get_feature_values(AHalValues* *confValues)
{
AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
- if (confInstance)
- confValues = confInstance->getAHalValues();
- return confValues;
-}
-
-bool audio_extn_is_config_from_remote()
-{
- AHalConfigHelper* confInstance = AHalConfigHelper::getAHalConfInstance();
- if (confInstance)
- return confInstance->isRemote;
- return false;
+ if (confInstance != nullptr)
+ confInstance->getAHalValues(confValues);
}
} // extern C
diff --git a/hal/ahal_config_helper.h b/hal/ahal_config_helper.h
index 32f575c..048b9cc 100644
--- a/hal/ahal_config_helper.h
+++ b/hal/ahal_config_helper.h
@@ -27,9 +27,14 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// ToDo: This struct must be used only if config store is disabled.
-// Use AHalValues struct from config store once support is added.
-struct AHalValues_t {
+#ifdef __LP64__
+#define AUDIO_CONFIGSTORE_LIB_PATH "/vendor/lib64/libaudioconfigstore.so"
+#else
+#define AUDIO_CONFIGSTORE_LIB_PATH "/vendor/lib/libaudioconfigstore.so"
+#endif
+
+// AHalValues must be in sync with AHalValues_t in libaudioconfigstore
+typedef struct {
bool snd_monitor_enabled;
bool compress_capture_enabled;
bool source_track_enabled;
@@ -57,20 +62,25 @@
bool usb_offload_burst_mode;
bool usb_offload_sidetone_vol_enabled;
bool a2dp_offload_enabled;
+ bool hfp_enabled;
bool vbat_enabled;
+ bool ext_hw_plugin_enabled;
+ bool record_play_concurrency;
+ bool hdmi_passthrough_enabled;
+ bool concurrent_capture_enabled;
+ bool compress_in_enabled;
+ bool battery_listener_enabled;
bool compress_metadata_needed;
+ bool incall_music_enabled;
bool compress_voip_enabled;
bool dynamic_ecns_enabled;
-};
-typedef struct AHalValues_t AHalValues;
+} AHalValues;
#ifdef __cplusplus
extern "C" {
#endif
void audio_extn_ahal_config_helper_init(bool isVendorEnhancedFwk);
-AHalValues* audio_extn_get_feature_values();
-bool audio_extn_is_config_from_remote();
+void audio_extn_get_feature_values(AHalValues* *confValues);
#ifdef __cplusplus
}
#endif
-
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 440f1d8..077ec99 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -616,7 +616,7 @@
str_parms_destroy(reply_44_1);
}
- ALOGD("%s: anc_enabled:%d", __func__, aextnmod.anc_enabled);
+ ALOGV("%s: anc_enabled:%d", __func__, aextnmod.anc_enabled);
}
// END: ANC_HEADSET -------------------------------------------------------
diff --git a/hal/audio_extn/audio_feature_manager.c b/hal/audio_extn/audio_feature_manager.c
index bc996a2..9c49ea3 100644
--- a/hal/audio_extn/audio_feature_manager.c
+++ b/hal/audio_extn/audio_feature_manager.c
@@ -42,21 +42,18 @@
#include "voice_extn.h"
#include "audio_feature_manager.h"
-extern AHalValues* confValues;
-
#ifdef __LP64__
#define VNDK_FWK_LIB_PATH "/vendor/lib64/libqti_vndfwk_detect.so"
#else
#define VNDK_FWK_LIB_PATH "/vendor/lib/libqti_vndfwk_detect.so"
#endif
+AHalValues* confValues = NULL;
static void *vndk_fwk_lib_handle = NULL;
typedef int (*vndk_fwk_isVendorEnhancedFwk_t)();
static vndk_fwk_isVendorEnhancedFwk_t vndk_fwk_isVendorEnhancedFwk;
-
-
void audio_feature_manager_init()
{
ALOGD("%s: Enter", __func__);
@@ -78,7 +75,7 @@
ALOGD("%s: vndk_fwk_isVendorEnhancedFwk=%d", __func__, is_running_with_enhanced_fwk);
audio_extn_ahal_config_helper_init(is_running_with_enhanced_fwk);
- confValues = audio_extn_get_feature_values();
+ audio_extn_get_feature_values(&confValues);
audio_extn_feature_init(is_running_with_enhanced_fwk);
voice_extn_feature_init(is_running_with_enhanced_fwk);
@@ -92,13 +89,11 @@
{
ALOGV("%s: Enter", __func__);
-#ifdef AHAL_EXT_ENABLED
- if (!audio_extn_is_config_from_remote())
- confValues = audio_extn_get_feature_values();
-#endif /* AHAL_EXT_ENABLED */
-
- if (!confValues)
- return false;
+ if (confValues == NULL) {
+ audio_extn_get_feature_values(&confValues);
+ if (!confValues)
+ return false;
+ }
switch (feature) {
case SND_MONITOR:
@@ -155,10 +150,26 @@
return confValues->usb_offload_sidetone_vol_enabled;
case A2DP_OFFLOAD:
return confValues->a2dp_offload_enabled;
+ case HFP:
+ return confValues->hfp_enabled;
case VBAT:
return confValues->vbat_enabled;
+ case EXT_HW_PLUGIN:
+ return confValues->ext_hw_plugin_enabled;
+ case RECORD_PLAY_CONCURRENCY:
+ return confValues->record_play_concurrency;
+ case HDMI_PASSTHROUGH:
+ return confValues->hdmi_passthrough_enabled;
+ case CONCURRENT_CAPTURE:
+ return confValues->concurrent_capture_enabled;
+ case COMPRESS_IN_CAPTURE:
+ return confValues->compress_in_enabled;
+ case BATTERY_LISTENER:
+ return confValues->battery_listener_enabled;
case COMPRESS_METADATA_NEEDED:
return confValues->compress_metadata_needed;
+ case INCALL_MUSIC:
+ return confValues->incall_music_enabled;
case COMPRESS_VOIP:
return confValues->compress_voip_enabled;
case DYNAMIC_ECNS:
diff --git a/hal/audio_extn/audio_feature_manager.h b/hal/audio_extn/audio_feature_manager.h
index 7eb9558..e7f071f 100644
--- a/hal/audio_extn/audio_feature_manager.h
+++ b/hal/audio_extn/audio_feature_manager.h
@@ -54,6 +54,7 @@
USB_OFFLOAD_BURST_MODE,
USB_OFFLOAD_SIDETONE_VOLM,
A2DP_OFFLOAD,
+ HFP,
VBAT,
SPKR_PROT,
FM_POWER_OPT_FEATURE,
@@ -61,10 +62,17 @@
EXTERNAL_SPEAKER,
EXTERNAL_SPEAKER_TFA,
HWDEP_CAL,
+ EXT_HW_PLUGIN,
+ RECORD_PLAY_CONCURRENCY,
+ HDMI_PASSTHROUGH,
+ CONCURRENT_CAPTURE,
+ COMPRESS_IN_CAPTURE,
+ BATTERY_LISTENER,
COMPRESS_METADATA_NEEDED,
COMPRESS_VOIP,
VOICE_START = COMPRESS_VOIP,
DYNAMIC_ECNS,
+ INCALL_MUSIC,
MAX_SUPPORTED_FEATURE
};