diff --git a/hal/Android.mk b/hal/Android.mk index a6bd9bcd..1477e0a7 100644 --- a/hal/Android.mk +++ b/hal/Android.mk @@ -105,7 +105,6 @@ LOCAL_CFLAGS += -Wno-macro-redefined LOCAL_HEADER_LIBRARIES := libhardware_headers LOCAL_SRC_FILES := \ - ahal_config_helper.cpp \ audio_hw.c \ acdb.c \ platform_info.c \ @@ -113,7 +112,6 @@ LOCAL_SRC_FILES := \ voice.c LOCAL_SRC_FILES += audio_extn/audio_extn.c \ - audio_extn/audio_feature_manager.c \ audio_extn/audio_hidl.cpp \ audio_extn/compress_in.c \ audio_extn/fm.c \ diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c index 3d6cd4a7..11b96e77 100644 --- a/hal/audio_extn/audio_extn.c +++ b/hal/audio_extn/audio_extn.c @@ -55,7 +55,6 @@ #include "platform.h" #include "platform_api.h" #include "edid.h" -#include "audio_feature_manager.h" #include "sound/compress_params.h" #ifdef DYNAMIC_LOG_ENABLED @@ -69,7 +68,7 @@ #define MAX_NUM_CHANNELS 8 #define Q14_GAIN_UNITY 0x4000 -static int is_running_vendor_enhanced_fwk = 1; +static int is_running_vendor_enhanced_fwk = 0; static bool is_compress_meta_data_enabled = false; struct snd_card_split cur_snd_card_split = { @@ -932,7 +931,7 @@ int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev, struct mixer_ctl *ctl = NULL; const char *mixer_ctl_name = "PROXY_RX Channels"; - if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) { + if (!property_get_bool("vendor.audio.feature.afe_proxy.enable", false)) { ALOGW("%s: AFE_PROXY is disabled", __func__); return -ENOSYS; } @@ -1013,7 +1012,8 @@ int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out) int ret = 0; int channels = aextnmod.proxy_channel_num; - if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) { + if (!property_get_bool("vendor.audio.feature.afe_proxy.enable", + false)) { ALOGW("%s: AFE_PROXY is disabled", __func__); return -ENOSYS; } @@ -1043,7 +1043,8 @@ int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out) int32_t audio_extn_get_afe_proxy_channel_count() { - if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) { + if (!property_get_bool("vendor.audio.feature.afe_proxy.enable", + false)) { ALOGW("%s: AFE_PROXY is disabled", __func__); return -ENOSYS; } @@ -4989,123 +4990,121 @@ bool audio_extn_ma_supported_usb() } // END: MAXX_AUDIO ===================================================================== -void audio_extn_feature_init(int is_running_with_enhanced_fwk) +void audio_extn_feature_init() { - is_running_vendor_enhanced_fwk = is_running_with_enhanced_fwk; - for(int index = 0; index < VOICE_START; index++) - { - bool enable = audio_feature_manager_is_feature_enabled(index); - switch (index) { - case SND_MONITOR: - snd_mon_feature_init(enable); - break; - case COMPRESS_CAPTURE: - compr_cap_feature_init(enable); - break; - case DSM_FEEDBACK: - dsm_feedback_feature_init(enable); - break; - case SSREC: - ssrec_feature_init(enable); - break; - case SOURCE_TRACK: - src_trkn_feature_init(enable); - case HDMI_EDID: - hdmi_edid_feature_init(enable); - break; - case KEEP_ALIVE: - keep_alive_feature_init(enable); - break; - case HIFI_AUDIO: - hifi_audio_feature_init(enable); - break; - case RECEIVER_AIDED_STEREO: - ras_feature_init(enable); - break; - case KPI_OPTIMIZE: - kpi_optimize_feature_init(enable); - break; - case USB_OFFLOAD: - usb_offload_feature_init(enable); - break; - case USB_OFFLOAD_BURST_MODE: - usb_offload_burst_mode_feature_init(enable); - break; - case USB_OFFLOAD_SIDETONE_VOLM: - usb_offload_sidetone_volume_feature_init(enable); - break; - case A2DP_OFFLOAD: - a2dp_offload_feature_init(enable); - break; - case WSA: - wsa_feature_init(enable); - break; - case COMPRESS_METADATA_NEEDED: - compress_meta_data_feature_init(enable); - break; - case VBAT: - vbat_feature_init(enable); - break; - case DISPLAY_PORT: - display_port_feature_init(enable); - break; - case FLUENCE: - fluence_feature_init(enable); - break; - case CUSTOM_STEREO: - custom_stereo_feature_init(enable); - break; - case ANC_HEADSET: - anc_headset_feature_init(enable); - break; - case SPKR_PROT: - spkr_prot_feature_init(enable); - break; - case FM_POWER_OPT_FEATURE: - fm_feature_init(enable); - break; - case EXTERNAL_QDSP: - external_qdsp_feature_init(enable); - break; - case EXTERNAL_SPEAKER: - external_speaker_feature_init(enable); - break; - case EXTERNAL_SPEAKER_TFA: - external_speaker_tfa_feature_init(enable); - break; - case HWDEP_CAL: - hwdep_cal_feature_init(enable); - break; - case HFP: - hfp_feature_init(enable); - break; - case EXT_HW_PLUGIN: - ext_hw_plugin_feature_init(enable); - break; - case RECORD_PLAY_CONCURRENCY: - record_play_concurency_feature_init(enable); - break; - case HDMI_PASSTHROUGH: - hdmi_passthrough_feature_init(enable); - break; - case CONCURRENT_CAPTURE: - concurrent_capture_feature_init(enable); - break; - case COMPRESS_IN_CAPTURE: - compress_in_feature_init(enable); - break; - case BATTERY_LISTENER: - battery_listener_feature_init(enable); - break; - case MAXX_AUDIO: - maxx_audio_feature_init(enable); - break; - case AUDIO_ZOOM: - audiozoom_feature_init(enable); - default: - break; - } - } + is_running_vendor_enhanced_fwk = audio_extn_utils_is_vendor_enhanced_fwk(); + + // register feature init functions here + // each feature needs a vendor property + // default value added is for GSI (non vendor modified images) + snd_mon_feature_init( + property_get_bool("vendor.audio.feature.snd_mon.enable", + true)); + compr_cap_feature_init( + property_get_bool("vendor.audio.feature.compr_cap.enable", + false)); + dsm_feedback_feature_init( + property_get_bool("vendor.audio.feature.dsm_feedback.enable", + false)); + ssrec_feature_init( + property_get_bool("vendor.audio.feature.ssrec.enable", + false)); + src_trkn_feature_init( + property_get_bool("vendor.audio.feature.src_trkn.enable", + false)); + hdmi_edid_feature_init( + property_get_bool("vendor.audio.feature.hdmi_edid.enable", + false)); + keep_alive_feature_init( + property_get_bool("vendor.audio.feature.keep_alive.enable", + false)); + hifi_audio_feature_init( + property_get_bool("vendor.audio.feature.hifi_audio.enable", + false)); + ras_feature_init( + property_get_bool("vendor.audio.feature.ras.enable", + false)); + kpi_optimize_feature_init( + property_get_bool("vendor.audio.feature.kpi_optimize.enable", + false)); + usb_offload_feature_init( + property_get_bool("vendor.audio.feature.usb_offload.enable", + true)); + usb_offload_burst_mode_feature_init( + property_get_bool("vendor.audio.feature.usb_offload_burst_mode.enable", + false)); + usb_offload_sidetone_volume_feature_init( + property_get_bool("vendor.audio.feature.usb_offload_sidetone_volume.enable", + false)); + a2dp_offload_feature_init( + property_get_bool("vendor.audio.feature.a2dp_offload.enable", + false)); + wsa_feature_init( + property_get_bool("vendor.audio.feature.wsa.enable", + false)); + compress_meta_data_feature_init( + property_get_bool("vendor.audio.feature.compress_meta_data.enable", + false)); + vbat_feature_init( + property_get_bool("vendor.audio.feature.vbat.enable", + false)); + display_port_feature_init( + property_get_bool("vendor.audio.feature.display_port.enable", + false)); + fluence_feature_init( + property_get_bool("vendor.audio.feature.fluence.enable", + false)); + custom_stereo_feature_init( + property_get_bool("vendor.audio.feature.custom_stereo.enable", + false)); + anc_headset_feature_init( + property_get_bool("vendor.audio.feature.anc_headset.enable", + false)); + spkr_prot_feature_init( + property_get_bool("vendor.audio.feature.spkr_prot.enable", + true)); + fm_feature_init( + property_get_bool("vendor.audio.feature.fm.enable", + false)); + external_qdsp_feature_init( + property_get_bool("vendor.audio.feature.external_dsp.enable", + true)); + external_speaker_feature_init( + property_get_bool("vendor.audio.feature.external_speaker.enable", + true)); + external_speaker_tfa_feature_init( + property_get_bool("vendor.audio.feature.external_speaker_tfa.enable", + false)); + hwdep_cal_feature_init( + property_get_bool("vendor.audio.feature.hwdep_cal.enable", + true)); + hfp_feature_init( + property_get_bool("vendor.audio.feature.hfp.enable", + true)); + ext_hw_plugin_feature_init( + property_get_bool("vendor.audio.feature.ext_hw_plugin.enable", + false)); + record_play_concurency_feature_init( + property_get_bool("vendor.audio.feature.record_play_concurency.enable", + false)); + hdmi_passthrough_feature_init( + property_get_bool("vendor.audio.feature.hdmi_passthrough.enable", + false)); + concurrent_capture_feature_init( + property_get_bool("vendor.audio.feature.concurrent_capture.enable", + true)); + compress_in_feature_init( + property_get_bool("vendor.audio.feature.compress_in.enable", + false)); + battery_listener_feature_init( + property_get_bool("vendor.audio.feature.battery_listener.enable", + false)); + maxx_audio_feature_init( + property_get_bool("vendor.audio.feature.maxx_audio.enable", + true)); + audiozoom_feature_init( + property_get_bool("vendor.audio.feature.audiozoom.enable", + true)); } void audio_extn_set_parameters(struct audio_device *adev, diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index 043ce487..61010627 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -192,7 +192,7 @@ typedef struct spkr_prot_init_config spkr_prot_init_config_t; // call at adev init void audio_extn_init(struct audio_device *adev); -void audio_extn_feature_init(int is_running_with_enhanced_fwk); +void audio_extn_feature_init(); //START: SND_MONITOR_FEATURE =========================================== void snd_mon_feature_init (bool is_feature_enabled); typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms); diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 23436035..1d2e5e36 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -74,7 +74,6 @@ #include "audio_extn.h" #include "voice_extn.h" #include "ip_hdlr_intf.h" -#include "audio_feature_manager.h" #include "sound/compress_params.h" #include "sound/asound.h" @@ -6787,7 +6786,8 @@ int adev_open_output_stream(struct audio_hw_device *dev, (devices != AUDIO_DEVICE_OUT_USB_ACCESSORY); bool direct_dev = is_hdmi || is_usb_dev; bool use_db_as_primary = - audio_feature_manager_is_feature_enabled(USE_DEEP_BUFFER_AS_PRIMARY_OUTPUT); + property_get_bool("vendor.audio.feature.deepbuffer_as_primary.enable", + false); bool force_haptic_path = property_get_bool("vendor.audio.test_haptic", false); bool is_voip_rx = flags & AUDIO_OUTPUT_FLAG_VOIP_RX; @@ -9099,8 +9099,9 @@ static int adev_open(const hw_module_t *module, const char *name, adev->bt_sco_on = false; /* adev->cur_hdmi_channels = 0; by calloc() */ adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int)); - /* Init audio feature manager */ - audio_feature_manager_init(); + /* Init audio and voice feature */ + audio_extn_feature_init(); + voice_extn_feature_init(); voice_init(adev); list_init(&adev->usecase_list); list_init(&adev->active_inputs_list); diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c index f08c73c6..473edc2e 100644 --- a/hal/voice_extn/voice_extn.c +++ b/hal/voice_extn/voice_extn.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include "platform.h" #include "platform_api.h" #include "voice_extn.h" -#include "audio_feature_manager.h" #ifdef DYNAMIC_LOG_ENABLED #include @@ -86,7 +86,6 @@ struct pcm_config pcm_config_incall_music = { static bool voice_extn_compress_voip_enabled = false; static bool voice_extn_dynamic_ecns_feature_enabled = false; -static int voice_extn_is_running_vendor_enhanced_fwk = 1; static bool voice_extn_incall_music_enabled = false; int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active); @@ -396,43 +395,48 @@ void dynamic_ecns_feature_init(bool is_feature_enabled) { voice_extn_dynamic_ecns_feature_enabled = is_feature_enabled; ALOGD(":: %s: ---- Feature DYNAMIC_ECNS is %s ----", __func__, - is_feature_enabled? "ENABLED": " NOT ENABLED"); + is_feature_enabled ? "ENABLED" : "NOT ENABLED"); } -// START: INCALL_MUSIC =================================================================== -void incall_music_feature_init(bool is_feature_enabled) -{ - voice_extn_incall_music_enabled = is_feature_enabled; - ALOGD("%s: ---- Feature INCALL_MUSIC is %s----", __func__, - is_feature_enabled? "ENABLED": "NOT ENABLED"); -} -// END: INCALL_MUSIC =================================================================== - bool voice_extn_is_dynamic_ecns_enabled() { return voice_extn_dynamic_ecns_feature_enabled; } -void voice_extn_feature_init(int is_running_with_enhanced_fwk) +// START: INCALL_MUSIC =================================================================== +void incall_music_feature_init(bool is_feature_enabled) { - voice_extn_is_running_vendor_enhanced_fwk = is_running_with_enhanced_fwk; - for(int index = VOICE_START; index < MAX_SUPPORTED_FEATURE; index++) - { - bool enable = audio_feature_manager_is_feature_enabled(index); - switch (index) { - case COMPRESS_VOIP: - compr_voip_feature_init(enable); - break; - case DYNAMIC_ECNS: - dynamic_ecns_feature_init(enable); - break; - case INCALL_MUSIC: - incall_music_feature_init(enable); - break; - default: - break; - } - } + voice_extn_incall_music_enabled = is_feature_enabled; + ALOGV("%s: ---- Feature INCALL_MUSIC is %s----", __func__, + is_feature_enabled ? "ENABLED" : "NOT ENABLED"); +} +// END: INCALL_MUSIC =================================================================== + +void compr_voip_feature_init(bool is_feature_enabled) +{ + voice_extn_compress_voip_enabled = is_feature_enabled; + ALOGV("%s:: ---- Feature COMPRESS_VOIP is %s ----", __func__, + is_feature_enabled ? "ENABLED" : "NOT ENABLED"); +} + +bool voice_extn_is_compress_voip_supported() +{ + return voice_extn_compress_voip_enabled; +} + +void voice_extn_feature_init() +{ + // Register feature function here + // every feature should have a feature flag + compr_voip_feature_init( + property_get_bool("vendor.audio.feature.compr_voip.enable", + false)); + dynamic_ecns_feature_init( + property_get_bool("vendor.audio.feature.dynamic_ecns.enable", + false)); + incall_music_feature_init( + property_get_bool("vendor.audio.feature.incall_music.enable", + true)); } void voice_extn_init(struct audio_device *adev) @@ -446,17 +450,6 @@ void voice_extn_init(struct audio_device *adev) adev->voice.session[MMODE2_SESS_IDX].vsid = VOICEMMODE2_VSID; } -void compr_voip_feature_init(bool is_feature_enabled) -{ - voice_extn_compress_voip_enabled = is_feature_enabled; - ALOGD("%s:: ---- Feature COMPRESS_VOIP is %s ----", __func__, is_feature_enabled?"ENABLED":"NOT ENABLED"); -} - -bool voice_extn_is_compress_voip_supported() -{ - return voice_extn_compress_voip_enabled; -} - int voice_extn_get_session_from_use_case(struct audio_device *adev, const audio_usecase_t usecase_id, struct voice_session **session) diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h index 7a3b8cd4..c4f0d49b 100644 --- a/hal/voice_extn/voice_extn.h +++ b/hal/voice_extn/voice_extn.h @@ -77,7 +77,7 @@ bool voice_extn_compress_voip_is_active(const struct audio_device *adev); bool voice_extn_compress_voip_is_format_supported(audio_format_t format); bool voice_extn_compress_voip_is_config_supported(struct audio_config *config); bool voice_extn_compress_voip_is_started(struct audio_device *adev); -void voice_extn_feature_init(int is_running_with_enhanced_fwk); +void voice_extn_feature_init(); void compr_voip_feature_init(bool is_feature_enabled); bool voice_extn_is_compress_voip_supported(); void dynamic_ecns_feature_init(bool is_feature_enabled); diff --git a/post_proc/asphere.c b/post_proc/asphere.c index 7b35a778..efe07c68 100644 --- a/post_proc/asphere.c +++ b/post_proc/asphere.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ #include #include #include -#include #include "bundle.h" #include "equalizer.h" #include "bass_boost.h" @@ -58,10 +56,6 @@ #define AUDIO_ASPHERE_EVENT_NODE "/data/misc/audio_pp/event_node" -#define PRIMARY_HAL_PATH XSTR(LIB_AUDIO_HAL) -#define XSTR(x) STR(x) -#define STR(x) #x - enum { ASPHERE_ACTIVE = 0, ASPHERE_SUSPENDED, @@ -90,7 +84,6 @@ struct asphere_module { static struct asphere_module asphere; pthread_once_t asphere_once = PTHREAD_ONCE_INIT; -static bool (*is_feature_enabled)(audio_ext_feature); static int asphere_create_app_notification_node(void) { @@ -170,23 +163,14 @@ static void asphere_init_once() { ALOGD("%s", __func__); pthread_mutex_init(&asphere.lock, NULL); - if (access(PRIMARY_HAL_PATH, R_OK) == 0) { - void *hal_lib_pointer = dlopen(PRIMARY_HAL_PATH, RTLD_NOW); - if (hal_lib_pointer == NULL) - ALOGE("%s: DLOPEN failed for %s", __func__, PRIMARY_HAL_PATH); - else if ((is_feature_enabled = (bool (*)(audio_ext_feature))dlsym(hal_lib_pointer, - "audio_feature_manager_is_feature_enabled")) != NULL) { - if (is_feature_enabled(AUDIOSPHERE)) { - asphere.init_status = 1; - asphere_get_values_from_mixer(); - asphere_create_app_notification_node(); - return; - } else - ALOGW("%s: asphere feature not enabled", __func__); - } else - ALOGE("%s: dlsym failed", __func__); - } else - ALOGE("%s: not able to acces lib %s ", __func__, PRIMARY_HAL_PATH); + if (property_get_bool("vendor.audio.feature.audio_sphere.enable", false)) { + asphere.init_status = 1; + asphere_get_values_from_mixer(); + asphere_create_app_notification_node(); + return; + } else { + ALOGW("%s: asphere feature not enabled", __func__); + } asphere.init_status = 0; } diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c index 0199a511..6c08bd7d 100644 --- a/post_proc/virtualizer.c +++ b/post_proc/virtualizer.c @@ -21,25 +21,17 @@ //#define LOG_NDEBUG 0 #include +#include #include #include #include #include -#include -#include -#include #include "effect_api.h" #include "virtualizer.h" #define VIRUALIZER_MAX_LATENCY 30 -#define PRIMARY_HAL_PATH XSTR(LIB_AUDIO_HAL) -#define XSTR(x) STR(x) -#define STR(x) #x - -static bool (*is_feature_enabled)(audio_ext_feature); - #ifdef AUDIO_FEATURE_ENABLED_GCOV extern void __gcov_flush(); static void enable_gcov() @@ -113,11 +105,9 @@ int virtualizer_set_strength(virtualizer_context_t *context, uint32_t strength) * true device is applicable for effect */ bool virtualizer_is_device_supported(audio_devices_t device) { - if (is_feature_enabled != NULL && - is_feature_enabled(AFE_PROXY)) { - if (device == AUDIO_DEVICE_OUT_PROXY) - return false; - } + if ((property_get_bool("vendor.audio.feature.afe_proxy.enable", false)) && + (device == AUDIO_DEVICE_OUT_PROXY)) + return false; switch (device) { case AUDIO_DEVICE_OUT_SPEAKER: @@ -482,20 +472,6 @@ int virtualizer_init(effect_context_t *context) ALOGV("%s: ctxt %p", __func__, context); virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; - if (access(PRIMARY_HAL_PATH, R_OK) == 0) { - void *hal_lib_pointer = dlopen(PRIMARY_HAL_PATH, RTLD_NOW); - if (hal_lib_pointer == NULL) - ALOGE("%s: DLOPEN failed for %s", __func__, PRIMARY_HAL_PATH); - else { - is_feature_enabled = - (bool (*)(audio_ext_feature))dlsym(hal_lib_pointer, - "audio_feature_manager_is_feature_enabled"); - if (is_feature_enabled == NULL) - ALOGE("%s: dlsym failed", __func__); - } - } else - ALOGE("%s: not able to acces lib %s ", __func__, PRIMARY_HAL_PATH); - context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;