hal: enable dynamic audio HAL feature extensions

Move audio and voice extension feature to seperate
dynamic libraries. Loading these libraries will be
controlled from config store based on target. These
flags can be changed at runtime

Change-Id: I042450768243124ea80945efac0821984f96b9bf
diff --git a/Android.mk b/Android.mk
index 060bee6..29fc8c6 100644
--- a/Android.mk
+++ b/Android.mk
@@ -11,6 +11,7 @@
 else
 include $(MY_LOCAL_PATH)/hal/Android.mk
 endif
+include $(MY_LOCAL_PATH)/hal/audio_extn/Android.mk
 include $(MY_LOCAL_PATH)/voice_processing/Android.mk
 include $(MY_LOCAL_PATH)/mm-audio/Android.mk
 include $(MY_LOCAL_PATH)/visualizer/Android.mk
diff --git a/hal/Android.mk b/hal/Android.mk
index 9485d6b..a67ce7c 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -105,7 +105,15 @@
         acdb.c
 
 LOCAL_SRC_FILES += audio_extn/audio_extn.c \
-                   audio_extn/utils.c
+                   audio_extn/audio_feature_manager.c \
+                   audio_extn/utils.c \
+                   audio_extn/source_track.c \
+                   voice_extn/voice_extn.c \
+                   audio_extn/fm.c \
+                   voice_extn/compress_voip.c \
+                   audio_extn/keep_alive.c
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
 LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
 LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 
@@ -117,114 +125,104 @@
 
 LOCAL_CFLAGS += -DUSE_VENDOR_EXTN
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_EDID)),true)
-    LOCAL_CFLAGS += -DHDMI_EDID
-    LOCAL_SRC_FILES += edid.c
-endif
-
-ifeq ($(strip $(AUDIO_USE_DEEP_AS_PRIMARY_OUTPUT)),true)
-    LOCAL_CFLAGS += -DUSE_DEEP_AS_PRIMARY_OUTPUT
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_EDID)),true)
+#     LOCAL_CFLAGS += -DHDMI_EDID
+#     LOCAL_SRC_FILES += edid.c
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true)
     LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ANC_HEADSET)),true)
-    LOCAL_CFLAGS += -DANC_HEADSET_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ANC_HEADSET)),true)
+#     LOCAL_CFLAGS += -DANC_HEADSET_ENABLED
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HIFI_AUDIO)),true)
-    LOCAL_CFLAGS += -DHIFI_AUDIO_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HIFI_AUDIO)),true)
+#     LOCAL_CFLAGS += -DHIFI_AUDIO_ENABLED
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RAS)),true)
-    LOCAL_CFLAGS += -DRAS_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RAS)),true)
+#     LOCAL_CFLAGS += -DRAS_ENABLED
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VBAT_MONITOR)),true)
-    LOCAL_CFLAGS += -DVBAT_MONITOR_ENABLED
-endif
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VBAT_MONITOR)),true)
+#    LOCAL_CFLAGS += -DVBAT_MONITOR_ENABLED
+#endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FLUENCE)),true)
-    LOCAL_CFLAGS += -DFLUENCE_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FLUENCE)),true)
+#     LOCAL_CFLAGS += -DFLUENCE_ENABLED
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true)
     LOCAL_CFLAGS += -DAFE_PROXY_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE)),true)
-    LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE)),true)
+#     LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM_POWER_OPT)),true)
-    LOCAL_CFLAGS += -DFM_POWER_OPT
-    LOCAL_SRC_FILES += audio_extn/fm.c
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM_POWER_OPT)),true)
+#     LOCAL_CFLAGS += -DFM_POWER_OPT
+#     LOCAL_SRC_FILES += audio_extn/fm.c
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_TUNNEL)),true)
-    LOCAL_CFLAGS += -DUSB_TUNNEL_ENABLED
+
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_TUNNEL)),true)
+#    LOCAL_CFLAGS += -DUSB_TUNNEL_ENABLED
     LOCAL_SRC_FILES += audio_extn/usb.c
-endif
+#endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_SIDETONE_VOLUME)),true)
-    LOCAL_CFLAGS += -DUSB_SIDETONE_VOLUME
-endif
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_SIDETONE_VOLUME)),true)
+#    LOCAL_CFLAGS += -DUSB_SIDETONE_VOLUME
+#endif
+
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_BURST_MODE)), true)
+#    LOCAL_CFLAGS += -DUSB_BURST_MODE_ENABLED
+#endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HFP)),true)
     LOCAL_CFLAGS += -DHFP_ENABLED
     LOCAL_SRC_FILES += audio_extn/hfp.c
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CUSTOMSTEREO)),true)
-    LOCAL_CFLAGS += -DCUSTOM_STEREO_ENABLED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SSR)),true)
-    LOCAL_CFLAGS += -DSSR_ENABLED
-    LOCAL_SRC_FILES += audio_extn/ssr.c
-    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/surround_sound_3mic/
-    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc/
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS)),true)
-    LOCAL_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED
-    LOCAL_SRC_FILES += voice_extn/voice_extn.c
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CUSTOMSTEREO)),true)
+#     LOCAL_CFLAGS += -DCUSTOM_STEREO_ENABLED
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INCALL_MUSIC)),true)
     LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED
 endif
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_VOIP)),true)
-    LOCAL_CFLAGS += -DCOMPRESS_VOIP_ENABLED
-    LOCAL_SRC_FILES += voice_extn/compress_voip.c
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_VOIP)),true)
+#     LOCAL_CFLAGS += -DCOMPRESS_VOIP_ENABLED
+#     LOCAL_SRC_FILES += voice_extn/compress_voip.c
+# endif
 
-endif
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FORMATS)),true)
   LOCAL_CFLAGS += -DAUDIO_EXTN_FORMATS_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SPKR_PROTECTION)),true)
-  LOCAL_CFLAGS += -DSPKR_PROT_ENABLED
-  LOCAL_SRC_FILES += audio_extn/spkr_protection.c
-endif
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SPKR_PROTECTION)),true)
+#  LOCAL_CFLAGS += -DSPKR_PROT_ENABLED
+#  LOCAL_SRC_FILES += audio_extn/spkr_protection.c
+#endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_BG_CAL)),true)
   LOCAL_CFLAGS += -DBG_CODEC_CAL
 endif
 
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CIRRUS_SPKR_PROTECTION)),true)
+#     LOCAL_CFLAGS += -DSPKR_PROT_ENABLED
+#     LOCAL_SRC_FILES += audio_extn/cirrus_playback.c
+# endif
+
 ifdef MULTIPLE_HW_VARIANTS_ENABLED
   LOCAL_CFLAGS += -DHW_VARIANTS_ENABLED
   LOCAL_SRC_FILES += $(AUDIO_PLATFORM)/hw_info.c
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_CAPTURE)),true)
-    LOCAL_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED
-    LOCAL_SRC_FILES += audio_extn/compress_capture.c
-endif
-
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DTS_EAGLE)),true)
     LOCAL_CFLAGS += -DDTS_EAGLE
     LOCAL_SRC_FILES += audio_extn/dts_eagle.c
@@ -244,28 +242,27 @@
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
     LOCAL_CFLAGS += -DFLAC_OFFLOAD_ENABLED
-    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
 endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VORBIS_OFFLOAD)),true)
     LOCAL_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
-    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-
+#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
 endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_WMA_OFFLOAD)),true)
     LOCAL_CFLAGS += -DWMA_OFFLOAD_ENABLED
-    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
 endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD)),true)
     LOCAL_CFLAGS += -DALAC_OFFLOAD_ENABLED
-    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
 endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_APE_OFFLOAD)),true)
     LOCAL_CFLAGS += -DAPE_OFFLOAD_ENABLED
-    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
 endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24)),true)
@@ -276,18 +273,20 @@
     LOCAL_CFLAGS += -DAAC_ADTS_OFFLOAD_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DEV_ARBI)),true)
-    LOCAL_CFLAGS += -DDEV_ARBI_ENABLED
-    LOCAL_SRC_FILES += audio_extn/dev_arbi.c
-endif
+# # Removing flag as feature below is no longer needed
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DEV_ARBI)),true)
+#     LOCAL_CFLAGS += -DDEV_ARBI_ENABLED
+#     LOCAL_SRC_FILES += audio_extn/dev_arbi.c
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true)
     LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ACDB_LICENSE)), true)
-    LOCAL_CFLAGS += -DDOLBY_ACDB_LICENSE
-endif
+# Removing following flag as dolby is not being used on mobile targets
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ACDB_LICENSE)), true)
+#     LOCAL_CFLAGS += -DDOLBY_ACDB_LICENSE
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
     LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
@@ -304,25 +303,16 @@
     LOCAL_SRC_FILES += audio_extn/passthru.c
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KEEP_ALIVE)),true)
-    LOCAL_CFLAGS += -DKEEP_ALIVE_ENABLED
-    LOCAL_SRC_FILES += audio_extn/keep_alive.c
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KEEP_ALIVE)),true)
+#     LOCAL_CFLAGS += -DKEEP_ALIVE_ENABLED
+#     LOCAL_SRC_FILES += audio_extn/keep_alive.c
+# endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SOURCE_TRACKING)),true)
-    LOCAL_CFLAGS += -DSOURCE_TRACKING_ENABLED
-    LOCAL_SRC_FILES += audio_extn/source_track.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_A2DP_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DA2DP_OFFLOAD_ENABLED
-    LOCAL_SRC_FILES += audio_extn/a2dp.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_IP_HDLR_ENABLED)),true)
-    LOCAL_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
-    LOCAL_SRC_FILES += audio_extn/ip_hdlr_intf.c
-endif
+#This feature is depricated, file disabled
+#ifeq ($(strip $(AUDIO_FEATURE_IP_HDLR_ENABLED)),true)
+#    LOCAL_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
+#    LOCAL_SRC_FILES += audio_extn/ip_hdlr_intf.c
+#endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAF)),true)
     LOCAL_CFLAGS += -DQAF_EXTN_ENABLED
@@ -349,7 +339,7 @@
     liblog \
     libcutils \
     libtinyalsa \
-    libtinycompress_vendor \
+    libtinycompress \
     libaudioroute \
     libdl \
     libaudioutils \
@@ -427,9 +417,9 @@
     LOCAL_SHARED_LIBRARIES += libperipheral_client
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DISPLAY_PORT)),true)
-    LOCAL_CFLAGS += -DDISPLAY_PORT_ENABLED
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DISPLAY_PORT)),true)
+#     LOCAL_CFLAGS += -DDISPLAY_PORT_ENABLED
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GEF_SUPPORT)),true)
     LOCAL_CFLAGS += -DAUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
@@ -455,10 +445,6 @@
     LOCAL_CFLAGS += -DINSTANCE_ID_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_BURST_MODE)), true)
-    LOCAL_CFLAGS += -DUSB_BURST_MODE_ENABLED
-endif
-
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_BATTERY_LISTENER)), true)
     LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED
     LOCAL_SRC_FILES += audio_extn/battery_listener.cpp
@@ -483,10 +469,15 @@
 LOCAL_COPY_HEADERS_TO   := mm-audio
 LOCAL_COPY_HEADERS      := audio_extn/audio_defs.h
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SND_MONITOR)), true)
-    LOCAL_CFLAGS += -DSND_MONITOR_ENABLED
-    LOCAL_SRC_FILES += audio_extn/sndmonitor.c
-endif
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SND_MONITOR)), true)
+#     LOCAL_CFLAGS += -DSND_MONITOR_ENABLED
+#     LOCAL_SRC_FILES += audio_extn/sndmonitor.c
+# endif
+
+# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MAXX_AUDIO)), true)
+#     LOCAL_CFLAGS += -DMAXXAUDIO_QDSP_ENABLED
+#     LOCAL_SRC_FILES += audio_extn/maxxaudio.c
+# endif
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GCOV)),true)
     LOCAL_CFLAGS += --coverage -fprofile-arcs -ftest-coverage
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
new file mode 100644
index 0000000..3897ba4
--- /dev/null
+++ b/hal/audio_extn/Android.mk
@@ -0,0 +1,399 @@
+#--------------------------------------------
+#          Build SND_MONITOR LIB
+#--------------------------------------------
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= libsndmonitor
+LOCAL_MODULE_OWNER := third_party
+LOCAL_PROPRIETARY_MODULE := true
+
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+LOCAL_SRC_FILES:= \
+        sndmonitor.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+
+LOCAL_SHARED_LIBRARIES := \
+	libaudioutils \
+	libcutils \
+	liblog \
+	libtinyalsa \
+	libtinycompress \
+	libaudioroute \
+	libdl \
+	libexpat
+
+LOCAL_C_INCLUDES := \
+	external/tinyalsa/include \
+	external/tinycompress/include \
+	system/media/audio_utils/include \
+	external/expat/lib \
+	$(call include-path-for, audio-route) \
+	vendor/qcom/opensource/audio-hal/primary-hal/hal \
+	$(call include-path-for, audio-effects)
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+  LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+  LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
+
+#--------------------------------------------
+#          Build COMPRESS_CAPTURE LIB
+#--------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= libcomprcapture
+LOCAL_MODULE_OWNER := third_party
+LOCAL_PROPRIETARY_MODULE := true
+
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 qcs605 msmnile $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        compress_capture.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+
+LOCAL_SHARED_LIBRARIES := \
+	libaudioutils \
+	libcutils \
+	liblog \
+	libtinyalsa \
+	libtinycompress \
+	libaudioroute \
+	libdl \
+	libexpat
+
+LOCAL_C_INCLUDES := \
+	external/tinyalsa/include \
+	external/tinycompress/include \
+	system/media/audio_utils/include \
+	external/expat/lib \
+	$(call include-path-for, audio-route) \
+	vendor/qcom/opensource/audio-hal/primary-hal/hal \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/$(AUDIO_PLATFORM) \
+	$(call include-path-for, audio-effects)
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+  LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+  LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
+
+#-------------------------------------------
+#            Build SSREC LIB
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= libssrec
+LOCAL_VENDOR_MODULE := true
+
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 msmnile $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= ssr.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioutils \
+    libcutils \
+    liblog \
+    libtinyalsa \
+    libtinycompress \
+    libaudioroute \
+    libdl \
+    libexpat
+
+LOCAL_C_INCLUDES := \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/$(AUDIO_PLATFORM) \
+    external/tinyalsa/include \
+    external/tinycompress/include \
+    external/expat/lib \
+    system/media/audio_utils/include \
+    $(call include-path-for, audio-route) \
+    $(call include-path-for, audio-effects) \
+    $(TARGET_OUT_HEADERS)/mm-audio/surround_sound_3mic/ \
+    $(TARGET_OUT_HEADERS)/common/inc/
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+  LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+  LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+#include $(BUILD_SHARED_LIBRARY)
+
+#--------------------------------------------
+#          Build HDMI_EDID LIB
+#--------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= libhdmiedid
+LOCAL_MODULE_OWNER := third_party
+LOCAL_PROPRIETARY_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 msmnile $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+endif
+
+LOCAL_SRC_FILES:= \
+        edid.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+
+LOCAL_SHARED_LIBRARIES := \
+	libaudioutils \
+	libcutils \
+	liblog \
+	libtinyalsa \
+	libtinycompress \
+	libaudioroute \
+	libdl \
+	libexpat
+
+LOCAL_C_INCLUDES := \
+	external/tinyalsa/include \
+	external/tinycompress/include \
+	system/media/audio_utils/include \
+	external/expat/lib \
+	$(call include-path-for, audio-route) \
+	$(PRIMARY_HAL_PATH) \
+	$(PRIMARY_HAL_PATH)/$(AUDIO_PLATFORM) \
+	$(call include-path-for, audio-effects)
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+  LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+  LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
+
+#--------------------------------------------
+#          Build SPKR_PROTECT LIB
+#--------------------------------------------
+include $(CLEAR_VARS)
+
+ifneq ($(filter sdm845 msmnile $(MSMSTEPPE) $(TRINKET) kona,$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+endif
+
+LOCAL_MODULE:= libspkrprot
+LOCAL_MODULE_OWNER := third_party
+LOCAL_PROPRIETARY_MODULE := true
+
+LOCAL_SRC_FILES:= \
+        spkr_protection.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+
+LOCAL_CFLAGS += -DSPKR_PROT_ENABLED
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioutils \
+    libcutils \
+    liblog \
+    libtinyalsa \
+    libtinycompress \
+    libaudioroute \
+    libdl \
+    libexpat
+
+LOCAL_C_INCLUDES := \
+    external/tinyalsa/include \
+    external/tinycompress/include \
+    system/media/audio_utils/include \
+    external/expat/lib \
+    $(call include-path-for, audio-route) \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/audio_extn \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/$(AUDIO_PLATFORM) \
+    vendor/qcom/opensource/audio-kernel/include/uapi/ \
+    $(call include-path-for, audio-effects)
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
+#====================================================================================================
+# --- enable 3rd Party Spkr-prot lib
+#====================================================================================================
+
+include $(CLEAR_VARS)
+
+ifneq ($(filter sdm845 msmnile $(MSMSTEPPE) $(TRINKET) kona,$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+endif
+
+LOCAL_MODULE:= libcirrusspkrprot
+LOCAL_MODULE_OWNER := third_party
+LOCAL_PROPRIETARY_MODULE := true
+
+LOCAL_SRC_FILES:= \
+        cirrus_playback.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+
+LOCAL_CFLAGS += -DENABLE_CIRRUS_DETECTION
+LOCAL_CFLAGS += -DCIRRUS_FACTORY_CALIBRATION
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioutils \
+    libcutils \
+    liblog \
+    libtinyalsa \
+    libaudioroute \
+    libdl \
+    libexpat
+
+LOCAL_C_INCLUDES := \
+    external/tinyalsa/include \
+    external/tinycompress/include \
+    system/media/audio_utils/include \
+    external/expat/lib \
+    $(call include-path-for, audio-route) \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/audio_extn \
+    vendor/qcom/opensource/audio-hal/primary-hal/hal/$(AUDIO_PLATFORM) \
+    vendor/qcom/opensource/audio-kernel/include/uapi/ \
+    $(call include-path-for, audio-effects)
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
+
+#-------------------------------------------
+#            Build A2DP_OFFLOAD LIB
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= liba2dpoffload
+LOCAL_PROPRIETARY_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 msmnile $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM = msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        a2dp.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioutils \
+    libcutils \
+    liblog \
+    libtinyalsa \
+    libtinycompress \
+    libaudioroute \
+    libdl \
+    libexpat
+
+LOCAL_C_INCLUDES := \
+    $(PRIMARY_HAL_PATH) \
+    $(PRIMARY_HAL_PATH)/$(AUDIO_PLATFORM) \
+    external/tinyalsa/include \
+    external/tinycompress/include \
+    external/expat/lib \
+    system/media/audio_utils/include \
+    $(call include-path-for, audio-route) \
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+  LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+  LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index b193d67..fb71083 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -49,7 +49,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef A2DP_OFFLOAD_ENABLED
 #define AUDIO_PARAMETER_A2DP_STARTED "A2dpStarted"
 #define BT_IPC_SOURCE_LIB_NAME  "libbthost_if.so"
 #define BT_IPC_SINK_LIB_NAME    "libbthost_if_sink.so"
@@ -228,6 +227,10 @@
     PEAK_BIT_RATE,
 } frame_control_type_t;
 
+// --- external function dependency ---
+fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
+fp_check_a2dp_restore_t fp_check_a2dp_restore;
+
 /* PCM config for ABR Feedback hostless front end */
 static struct pcm_config pcm_config_abr = {
     .channels = 1,
@@ -782,7 +785,7 @@
     }
 
     // Open hostless front end and prepare ABR Tx path
-    abr_device_id = platform_get_pcm_device_id(USECASE_AUDIO_A2DP_ABR_FEEDBACK,
+    abr_device_id = fp_platform_get_pcm_device_id(USECASE_AUDIO_A2DP_ABR_FEEDBACK,
                                                PCM_CAPTURE);
     if (!a2dp.abr_config.abr_tx_handle) {
         a2dp.abr_config.abr_tx_handle = pcm_open(a2dp.adev->snd_card,
@@ -2157,11 +2160,11 @@
     return is_configured;
 }
 
-int audio_extn_a2dp_start_playback()
+int a2dp_start_playback()
 {
     int ret = 0;
 
-    ALOGD("audio_extn_a2dp_start_playback start");
+    ALOGD("a2dp_start_playback start");
 
     if(!(a2dp.bt_lib_source_handle && a2dp.audio_source_start
        && a2dp.audio_get_enc_config)) {
@@ -2209,7 +2212,7 @@
     return ret;
 }
 
-uint64_t audio_extn_a2dp_get_decoder_latency()
+uint64_t a2dp_get_decoder_latency()
 {
     uint32_t latency = 0;
 
@@ -2232,7 +2235,7 @@
     uint64_t system_latency = 0;
     bool is_complete = false;
 
-    system_latency = audio_extn_a2dp_get_decoder_latency();
+    system_latency = a2dp_get_decoder_latency();
 
     if (a2dp.audio_sink_session_setup_complete(system_latency) == 0) {
         is_complete = true;
@@ -2240,11 +2243,22 @@
     return is_complete;
 }
 
-int audio_extn_a2dp_start_capture()
+bool a2dp_sink_is_ready()
+{
+    bool ret = false;
+
+    if ((a2dp.bt_state_sink != A2DP_STATE_DISCONNECTED) &&
+        (a2dp.is_a2dp_offload_supported) &&
+        (a2dp.audio_sink_check_a2dp_ready))
+           ret = a2dp.audio_sink_check_a2dp_ready();
+    return ret;
+}
+
+int a2dp_start_capture()
 {
     int ret = 0;
 
-    ALOGD("audio_extn_a2dp_start_capture start");
+    ALOGD("a2dp_start_capture start");
 
     if(!(a2dp.bt_lib_sink_handle && a2dp.audio_sink_start
        && a2dp.audio_get_dec_config)) {
@@ -2262,7 +2276,7 @@
            a2dp.a2dp_sink_started = false;
         } else {
 
-           if(!audio_extn_a2dp_sink_is_ready()) {
+           if(!a2dp_sink_is_ready()) {
                 ALOGD("Wait for capture ready not successful");
                 ret = -ETIMEDOUT;
            }
@@ -2382,11 +2396,11 @@
     }
 }
 
-int audio_extn_a2dp_stop_playback()
+int a2dp_stop_playback()
 {
     int ret =0;
 
-    ALOGV("audio_extn_a2dp_stop_playback start");
+    ALOGV("a2dp_stop_playback start");
     if(!(a2dp.bt_lib_source_handle && a2dp.audio_source_stop)) {
         ALOGE("a2dp handle is not identified, Ignoring stop request");
         return -ENOSYS;
@@ -2420,11 +2434,11 @@
     return 0;
 }
 
-int audio_extn_a2dp_stop_capture()
+int a2dp_stop_capture()
 {
     int ret =0;
 
-    ALOGV("audio_extn_a2dp_stop_capture start");
+    ALOGV("a2dp_stop_capture start");
     if(!(a2dp.bt_lib_sink_handle && a2dp.audio_sink_stop)) {
         ALOGE("a2dp handle is not identified, Ignoring stop request");
         return -ENOSYS;
@@ -2450,7 +2464,7 @@
     return 0;
 }
 
-int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
+int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
 {
      int ret = 0, val, status = 0;
      char value[32]={0};
@@ -2522,7 +2536,7 @@
                     if (uc_info->type == PCM_PLAYBACK &&
                          (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                         pthread_mutex_unlock(&a2dp.adev->lock);
-                        check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
+                        fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
                         pthread_mutex_lock(&a2dp.adev->lock);
                     }
                 }
@@ -2563,7 +2577,7 @@
                     if (uc_info->type == PCM_PLAYBACK &&
                          (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                         pthread_mutex_unlock(&a2dp.adev->lock);
-                        check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
+                        fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
                         pthread_mutex_lock(&a2dp.adev->lock);
                     }
                 }
@@ -2587,12 +2601,12 @@
      return status;
 }
 
-void audio_extn_a2dp_set_handoff_mode(bool is_on)
+void a2dp_set_handoff_mode(bool is_on)
 {
     a2dp.is_handoff_in_progress = is_on;
 }
 
-bool audio_extn_a2dp_is_force_device_switch()
+bool a2dp_is_force_device_switch()
 {
     //During encoder reconfiguration mode, force a2dp device switch
     // Or if a2dp device is selected but earlier start failed ( as a2dp
@@ -2600,17 +2614,17 @@
     return a2dp.is_handoff_in_progress || !a2dp.a2dp_source_started;
 }
 
-void audio_extn_a2dp_get_enc_sample_rate(int *sample_rate)
+void a2dp_get_enc_sample_rate(int *sample_rate)
 {
     *sample_rate = a2dp.enc_sampling_rate;
 }
 
-void audio_extn_a2dp_get_dec_sample_rate(int *sample_rate)
+void a2dp_get_dec_sample_rate(int *sample_rate)
 {
     *sample_rate = a2dp.dec_sampling_rate;
 }
 
-bool audio_extn_a2dp_source_is_ready()
+bool a2dp_source_is_ready()
 {
     bool ret = false;
 
@@ -2624,23 +2638,13 @@
     return ret;
 }
 
-bool audio_extn_a2dp_sink_is_ready()
-{
-    bool ret = false;
-
-    if ((a2dp.bt_state_sink != A2DP_STATE_DISCONNECTED) &&
-        (a2dp.is_a2dp_offload_supported) &&
-        (a2dp.audio_sink_check_a2dp_ready))
-           ret = a2dp.audio_sink_check_a2dp_ready();
-    return ret;
-}
-
-bool audio_extn_a2dp_source_is_suspended()
+bool a2dp_source_is_suspended()
 {
     return a2dp.a2dp_source_suspended;
 }
 
-void audio_extn_a2dp_init (void *adev)
+void a2dp_init(void *adev,
+               a2dp_offload_init_config_t *init_config)
 {
   a2dp.adev = (struct audio_device*)adev;
   a2dp.bt_lib_source_handle = NULL;
@@ -2658,6 +2662,12 @@
   a2dp.abr_config.imc_instance = 0;
   a2dp.abr_config.abr_tx_handle = NULL;
   a2dp.is_tws_mono_mode_on = false;
+
+  // init function pointers
+  fp_platform_get_pcm_device_id =
+              init_config->fp_platform_get_pcm_device_id;
+  fp_check_a2dp_restore = init_config->fp_check_a2dp_restore;
+
   reset_a2dp_enc_config_params();
   reset_a2dp_source_dec_config_params();
   reset_a2dp_sink_dec_config_params();
@@ -2672,7 +2682,7 @@
   update_offload_codec_capabilities();
 }
 
-uint32_t audio_extn_a2dp_get_encoder_latency()
+uint32_t a2dp_get_encoder_latency()
 {
     uint32_t latency = 0;
     int avsync_runtime_prop = 0;
@@ -2734,7 +2744,7 @@
     return latency;
 }
 
-int audio_extn_a2dp_get_parameters(struct str_parms *query,
+int a2dp_get_parameters(struct str_parms *query,
                                    struct str_parms *reply)
 {
     int ret, val = 0;
@@ -2750,4 +2760,3 @@
 
     return 0;
 }
-#endif // A2DP_OFFLOAD_ENABLED
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 2d18d96..e0b07c6 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -46,14 +46,14 @@
 #include <cutils/properties.h>
 #include <log/log.h>
 #include <unistd.h>
-
 #include "audio_hw.h"
 #include "audio_extn.h"
+#include "voice_extn.h"
 #include "audio_defs.h"
 #include "platform.h"
 #include "platform_api.h"
 #include "edid.h"
-
+#include "audio_feature_manager.h"
 #include "sound/compress_params.h"
 
 #ifdef DYNAMIC_LOG_ENABLED
@@ -67,6 +67,9 @@
 #define MAX_NUM_CHANNELS 8
 #define Q14_GAIN_UNITY 0x4000
 
+static bool is_running_on_stock_version = true;
+static bool is_compress_meta_data_enabled = false;
+
 struct snd_card_split cur_snd_card_split = {
     .device = {0},
     .snd_card = {0},
@@ -78,6 +81,17 @@
     return &cur_snd_card_split;
 }
 
+void fm_set_parameters(struct audio_device *adev,
+                                  struct str_parms *parms);
+void fm_get_parameters(struct str_parms *query, struct str_parms *reply);
+
+void keep_alive_init(struct audio_device *adev);
+void keep_alive_deinit();
+void keep_alive_start(ka_mode_t ka_mode);
+void keep_alive_stop(ka_mode_t ka_mode);
+int keep_alive_set_parameters(struct audio_device *adev,
+                                         struct str_parms *parms);
+
 void audio_extn_set_snd_card_split(const char* in_snd_card_name)
 {
     /* sound card name follows below mentioned convention
@@ -139,6 +153,16 @@
 };
 
 static struct audio_extn_module aextnmod;
+static bool audio_extn_fm_power_opt_enabled = false;
+static bool audio_extn_keep_alive_enabled = false;
+static bool audio_extn_hifi_audio_enabled = false;
+static bool audio_extn_ras_feature_enabled = false;
+static bool audio_extn_kpi_optimize_feature_enabled = false;
+static bool audio_extn_display_port_feature_enabled = false;
+static bool audio_extn_fluence_feature_enabled = false;
+static bool audio_extn_custom_stereo_feature_enabled = false;
+static bool audio_extn_anc_headset_feature_enabled = false;
+static bool audio_extn_vbat_enabled = false;
 
 #define AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL "aanc_noise_level"
 #define AUDIO_PARAMETER_KEY_ANC        "anc_enabled"
@@ -161,6 +185,8 @@
 * this is done when device switch happens by setting audioparamter
 */
 
+#define IS_BIT_SET(NUM, bitno) (NUM & (1 << bitno))
+
 #define EXT_DISPLAY_PLUG_STATUS_NOTIFY_ENABLE 0x30
 
 static ssize_t update_sysfs_node(const char *path, const char *data, size_t len)
@@ -312,124 +338,6 @@
     }
 }
 
-#ifndef SOURCE_TRACKING_ENABLED
-#define audio_extn_source_track_set_parameters(adev, parms) (0)
-#define audio_extn_source_track_get_parameters(adev, query, reply) (0)
-#else
-void audio_extn_source_track_set_parameters(struct audio_device *adev,
-                                            struct str_parms *parms);
-void audio_extn_source_track_get_parameters(const struct audio_device *adev,
-                                            struct str_parms *query,
-                                            struct str_parms *reply);
-#endif
-
-#ifndef CUSTOM_STEREO_ENABLED
-#define audio_extn_customstereo_set_parameters(adev, parms)         (0)
-#else
-void audio_extn_customstereo_set_parameters(struct audio_device *adev,
-                                           struct str_parms *parms)
-{
-    int ret = 0;
-    char value[32]={0};
-    bool custom_stereo_state = false;
-    const char *mixer_ctl_name = "Set Custom Stereo OnOff";
-    struct mixer_ctl *ctl;
-
-    ALOGV("%s", __func__);
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_CUSTOM_STEREO, value,
-                            sizeof(value));
-    if (ret >= 0) {
-        if (!strncmp("true", value, sizeof("true")) || atoi(value))
-            custom_stereo_state = true;
-
-        if (custom_stereo_state == aextnmod.custom_stereo_enabled)
-            return;
-
-        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
-        if (!ctl) {
-            ALOGE("%s: Could not get ctl for mixer cmd - %s",
-                  __func__, mixer_ctl_name);
-            return;
-        }
-        if (mixer_ctl_set_value(ctl, 0, custom_stereo_state) < 0) {
-            ALOGE("%s: Could not set custom stereo state %d",
-                  __func__, custom_stereo_state);
-            return;
-        }
-        aextnmod.custom_stereo_enabled = custom_stereo_state;
-        ALOGV("%s: Setting custom stereo state success", __func__);
-    }
-}
-
-void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out)
-{
-    struct audio_device *adev = out->dev;
-    struct mixer_ctl *ctl;
-    char mixer_ctl_name[128];
-    int cust_ch_mixer_cfg[128], len = 0;
-    int ip_channel_cnt = audio_channel_count_from_out_mask(out->channel_mask);
-    int pcm_device_id = platform_get_pcm_device_id(out->usecase, PCM_PLAYBACK);
-    int op_channel_cnt= 2;
-    int i, j, err;
-
-    ALOGV("%s", __func__);
-    if (!out->started) {
-        out->set_dual_mono = true;
-        goto exit;
-    }
-
-    ALOGD("%s: i/p channel count %d, o/p channel count %d, pcm id %d", __func__,
-           ip_channel_cnt, op_channel_cnt, pcm_device_id);
-
-    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
-             "Audio Stream %d Channel Mix Cfg", pcm_device_id);
-    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
-    if (!ctl) {
-        ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
-        __func__, mixer_ctl_name);
-        goto exit;
-    }
-
-    /* Output channel count corresponds to backend configuration channels.
-     * Input channel count corresponds to ASM session channels.
-     * Set params is called with channels that need to be selected from
-     * input to generate output.
-     * ex: "8,2" to downmix from 8 to 2 i.e. to downmix from 8 to 2,
-     *
-     * This mixer control takes values in the following sequence:
-     * - input channel count(m)
-     * - output channel count(n)
-     * - weight coeff for [out ch#1, in ch#1]
-     * ....
-     * - weight coeff for [out ch#1, in ch#m]
-     *
-     * - weight coeff for [out ch#2, in ch#1]
-     * ....
-     * - weight coeff for [out ch#2, in ch#m]
-     *
-     * - weight coeff for [out ch#n, in ch#1]
-     * ....
-     * - weight coeff for [out ch#n, in ch#m]
-     *
-     * To get dualmono ouptu weightage coeff is calculated as Unity gain
-     * divided by number of input channels.
-     */
-    cust_ch_mixer_cfg[len++] = ip_channel_cnt;
-    cust_ch_mixer_cfg[len++] = op_channel_cnt;
-    for (i = 0; i < op_channel_cnt; i++) {
-         for (j = 0; j < ip_channel_cnt; j++) {
-              cust_ch_mixer_cfg[len++] = Q14_GAIN_UNITY/ip_channel_cnt;
-         }
-    }
-
-    err = mixer_ctl_set_array(ctl, cust_ch_mixer_cfg, len);
-    if (err)
-        ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
-exit:
-    return;
-}
-#endif /* CUSTOM_STEREO_ENABLED */
-
 #ifndef DTS_EAGLE
 #define audio_extn_hpx_set_parameters(adev, parms)         (0)
 #define audio_extn_hpx_get_parameters(query, reply)  (0)
@@ -501,37 +409,28 @@
 }
 #endif
 
-#ifdef HIFI_AUDIO_ENABLED
-bool audio_extn_is_hifi_audio_enabled(void)
+// START: VBAT =============================================================
+void vbat_feature_init(bool is_feature_enabled)
 {
-    ALOGV("%s: status: %d", __func__, aextnmod.hifi_audio_enabled);
-    return (aextnmod.hifi_audio_enabled ? true: false);
+    audio_extn_vbat_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature VBAT is %s ----",
+                  __func__, is_feature_enabled ? "ENABLED": " NOT ENABLED");
 }
 
-bool audio_extn_is_hifi_audio_supported(void)
-{
-    /*
-     * for internal codec, check for hifiaudio property to enable hifi audio
-     */
-    if (property_get_bool("persist.vendor.audio.hifi.int_codec", false))
-    {
-        ALOGD("%s: hifi audio supported on internal codec", __func__);
-        aextnmod.hifi_audio_enabled = 1;
-    }
-
-    return (aextnmod.hifi_audio_enabled ? true: false);
-}
-#endif
-
-#ifdef VBAT_MONITOR_ENABLED
 bool audio_extn_is_vbat_enabled(void)
 {
+    if (!audio_extn_vbat_enabled)
+        return false;
+
     ALOGD("%s: status: %d", __func__, aextnmod.vbat_enabled);
     return (aextnmod.vbat_enabled ? true: false);
 }
 
 bool audio_extn_can_use_vbat(void)
 {
+    if (!audio_extn_vbat_enabled)
+        return false;
+
     char prop_vbat_enabled[PROPERTY_VALUE_MAX] = "false";
 
     property_get("persist.vendor.audio.vbat.enabled", prop_vbat_enabled, "0");
@@ -545,12 +444,18 @@
 
 bool audio_extn_is_bcl_enabled(void)
 {
+    if (!audio_extn_vbat_enabled)
+        return false;
+
     ALOGD("%s: status: %d", __func__, aextnmod.bcl_enabled);
     return (aextnmod.bcl_enabled ? true: false);
 }
 
 bool audio_extn_can_use_bcl(void)
 {
+    if (!audio_extn_vbat_enabled)
+        return false;
+
     char prop_bcl_enabled[PROPERTY_VALUE_MAX] = "false";
 
     property_get("persist.vendor.audio.bcl.enabled", prop_bcl_enabled, "0");
@@ -561,28 +466,16 @@
     ALOGD("%s: bcl.enabled property is set to %s", __func__, prop_bcl_enabled);
     return (aextnmod.bcl_enabled ? true: false);
 }
-#endif
 
-#ifdef RAS_ENABLED
-bool audio_extn_is_ras_enabled(void)
+// START: ANC_HEADSET -------------------------------------------------------
+void anc_headset_feature_init(bool is_feature_enabled)
 {
-    ALOGD("%s: status: %d", __func__, aextnmod.ras_enabled);
-    return (aextnmod.ras_enabled ? true: false);
+    audio_extn_anc_headset_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature FM_POWER_OPT is %s----", __func__,
+                                    is_feature_enabled? "ENABLED": "NOT ENABLED");
+
 }
 
-bool audio_extn_can_use_ras(void)
-{
-    if (property_get_bool("persist.vendor.audio.ras.enabled", false))
-        aextnmod.ras_enabled = 1;
-
-    ALOGD("%s: ras.enabled property is set to %d", __func__, aextnmod.ras_enabled);
-    return (aextnmod.ras_enabled ? true: false);
-}
-#endif
-
-#ifndef ANC_HEADSET_ENABLED
-#define audio_extn_set_anc_parameters(adev, parms)       (0)
-#else
 bool audio_extn_get_anc_enabled(void)
 {
     ALOGD("%s: anc_enabled:%d", __func__, aextnmod.anc_enabled);
@@ -591,26 +484,31 @@
 
 bool audio_extn_should_use_handset_anc(int in_channels)
 {
-    char prop_aanc[PROPERTY_VALUE_MAX] = "false";
+    if (audio_extn_anc_headset_feature_enabled) {
+        char prop_aanc[PROPERTY_VALUE_MAX] = "false";
 
-    property_get("persist.vendor.audio.aanc.enable", prop_aanc, "0");
-    if (!strncmp("true", prop_aanc, 4)) {
-        ALOGD("%s: AANC enabled in the property", __func__);
-        aextnmod.aanc_enabled = 1;
+        property_get("persist.vendor.audio.aanc.enable", prop_aanc, "0");
+        if (!strncmp("true", prop_aanc, 4)) {
+            ALOGD("%s: AANC enabled in the property", __func__);
+            aextnmod.aanc_enabled = 1;
+        }
+
+        return (aextnmod.aanc_enabled && aextnmod.anc_enabled
+                && (in_channels == 1));
     }
-
-    return (aextnmod.aanc_enabled && aextnmod.anc_enabled
-            && (in_channels == 1));
+    return false;
 }
 
 bool audio_extn_should_use_fb_anc(void)
 {
   char prop_anc[PROPERTY_VALUE_MAX] = "feedforward";
 
-  property_get("persist.vendor.audio.headset.anc.type", prop_anc, "0");
-  if (!strncmp("feedback", prop_anc, sizeof("feedback"))) {
-    ALOGD("%s: FB ANC headset type enabled\n", __func__);
-    return true;
+  if (audio_extn_anc_headset_feature_enabled) {
+      property_get("persist.vendor.audio.headset.anc.type", prop_anc, "0");
+      if (!strncmp("feedback", prop_anc, sizeof("feedback"))) {
+        ALOGD("%s: FB ANC headset type enabled\n", __func__);
+        return true;
+      }
   }
   return false;
 }
@@ -623,15 +521,17 @@
     struct mixer_ctl *ctl = NULL;
     const char *mixer_ctl_name = "AANC Noise Level";
 
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL, value,
+    if(audio_extn_anc_headset_feature_enabled) {
+        ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL, value,
                             sizeof(value));
-    if (ret >= 0) {
-        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
-        if (ctl)
-            mixer_ctl_set_value(ctl, 0, atoi(value));
-        else
-            ALOGW("%s: Not able to get mixer ctl: %s",
-                  __func__, mixer_ctl_name);
+        if (ret >= 0) {
+            ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+            if (ctl)
+                mixer_ctl_set_value(ctl, 0, atoi(value));
+            else
+                ALOGW("%s: Not able to get mixer ctl: %s",
+                      __func__, mixer_ctl_name);
+        }
     }
 }
 
@@ -646,6 +546,9 @@
     struct str_parms *reply_44_1;
     struct str_parms *parms_disable_44_1;
 
+    if(!audio_extn_anc_headset_feature_enabled)
+        return;
+
     ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_ANC, value,
                             sizeof(value));
     if (ret >= 0) {
@@ -715,66 +618,8 @@
 
     ALOGD("%s: anc_enabled:%d", __func__, aextnmod.anc_enabled);
 }
-#endif /* ANC_HEADSET_ENABLED */
+// END: ANC_HEADSET -------------------------------------------------------
 
-#ifndef FLUENCE_ENABLED
-#define audio_extn_set_fluence_parameters(adev, parms) (0)
-#define audio_extn_get_fluence_parameters(adev, query, reply) (0)
-#else
-void audio_extn_set_fluence_parameters(struct audio_device *adev,
-                                            struct str_parms *parms)
-{
-    int ret = 0, err;
-    char value[32];
-    struct listnode *node;
-    struct audio_usecase *usecase;
-
-    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FLUENCE,
-                                 value, sizeof(value));
-    ALOGV_IF(err >= 0, "%s: Set Fluence Type to %s", __func__, value);
-    if (err >= 0) {
-        ret = platform_set_fluence_type(adev->platform, value);
-        if (ret != 0) {
-            ALOGE("platform_set_fluence_type returned error: %d", ret);
-        } else {
-            /*
-             *If the fluence is manually set/reset, devices
-             *need to get updated for all the usecases
-             *i.e. audio and voice.
-             */
-             list_for_each(node, &adev->usecase_list) {
-                 usecase = node_to_item(node, struct audio_usecase, list);
-                 select_devices(adev, usecase->id);
-             }
-        }
-    }
-}
-
-int audio_extn_get_fluence_parameters(const struct audio_device *adev,
-                       struct str_parms *query, struct str_parms *reply)
-{
-    int ret = 0, err;
-    char value[256] = {0};
-
-    err = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE, value,
-                                                          sizeof(value));
-    if (err >= 0) {
-        ret = platform_get_fluence_type(adev->platform, value, sizeof(value));
-        if (ret >= 0) {
-            ALOGV("%s: Fluence Type is %s", __func__, value);
-            str_parms_add_str(reply, AUDIO_PARAMETER_KEY_FLUENCE, value);
-        } else
-            goto done;
-    }
-done:
-    return ret;
-}
-#endif /* FLUENCE_ENABLED */
-
-#ifndef AFE_PROXY_ENABLED
-#define audio_extn_set_afe_proxy_parameters(adev, parms)  (0)
-#define audio_extn_get_afe_proxy_parameters(adev, query, reply) (0)
-#else
 static int32_t afe_proxy_set_channel_mapping(struct audio_device *adev,
                                                      int channel_count)
 {
@@ -834,6 +679,11 @@
     struct mixer_ctl *ctl = NULL;
     const char *mixer_ctl_name = "PROXY_RX Channels";
 
+    if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) {
+        ALOGW("%s: AFE_PROXY is disabled", __func__);
+        return -ENOSYS;
+    }
+
     ALOGD("%s: entry", __func__);
     /* use the existing channel count set by hardware params to
     configure the back end for stereo as usb/a2dp would be
@@ -910,6 +760,11 @@
     int ret = 0;
     int channels = aextnmod.proxy_channel_num;
 
+    if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) {
+        ALOGW("%s: AFE_PROXY is disabled", __func__);
+        return -ENOSYS;
+    }
+
     switch (channels) {
         /*
          * Do not handle stereo output in Multi-channel cases
@@ -934,11 +789,15 @@
 
 int32_t audio_extn_get_afe_proxy_channel_count()
 {
+
+    if (!audio_feature_manager_is_feature_enabled(AFE_PROXY)) {
+        ALOGW("%s: AFE_PROXY is disabled", __func__);
+        return -ENOSYS;
+    }
+
     return aextnmod.proxy_channel_num;
 }
 
-#endif /* AFE_PROXY_ENABLED */
-
 static int get_active_offload_usecases(const struct audio_device *adev,
                                        struct str_parms *query,
                                        struct str_parms *reply)
@@ -963,8 +822,1515 @@
     return ret;
 }
 
+void compress_meta_data_feature_init(bool is_featuer_enabled)
+{
+    is_compress_meta_data_enabled = is_featuer_enabled;
+}
+
+bool if_compress_meta_data_feature_enabled()
+{
+    return is_compress_meta_data_enabled;
+}
+
+//START: USB_OFFLOAD ==========================================================
+// LIB is part of hal lib, so no need for dlopen and getting function pointer
+// rather have function declared here
+
+void usb_init(void *adev);
+void usb_deinit();
+void usb_add_device(audio_devices_t device, int card);
+void usb_remove_device(audio_devices_t device, int card);
+bool usb_is_config_supported(unsigned int *bit_width,
+                                        unsigned int *sample_rate,
+                                        unsigned int *ch,
+                                        bool is_playback);
+int usb_enable_sidetone(int device, bool enable);
+void usb_set_sidetone_gain(struct str_parms *parms,
+                                     char *value, int len);
+bool usb_is_capture_supported();
+int usb_get_max_channels(bool playback);
+int usb_get_max_bit_width(bool playback);
+int usb_get_sup_sample_rates(bool type, uint32_t *sr, uint32_t l);
+bool usb_is_tunnel_supported();
+bool usb_alive(int card);
+bool usb_connected(struct str_parms *parms);
+unsigned long usb_find_service_interval(bool min, bool playback);
+int usb_altset_for_service_interval(bool is_playback,
+                                               unsigned long service_interval,
+                                               uint32_t *bit_width,
+                                               uint32_t *sample_rate,
+                                               uint32_t *channel_count);
+int usb_set_service_interval(bool playback,
+                                        unsigned long service_interval,
+                                        bool *reconfig);
+int usb_get_service_interval(bool playback,
+                                        unsigned long *service_interval);
+int usb_check_and_set_svc_int(struct audio_usecase *uc_info,
+                                         bool starting_output_stream);
+bool usb_is_reconfig_req();
+void usb_set_reconfig(bool is_required);
+
+static bool is_usb_offload_enabled = false;
+static bool is_usb_burst_mode_enabled = false;
+static bool is_usb_sidetone_vol_enabled = false;
+
+void usb_offload_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    is_usb_offload_enabled = is_feature_enabled;
+}
+
+void usb_offload_burst_mode_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    is_usb_burst_mode_enabled = is_feature_enabled;
+}
+
+void usb_offload_sidetone_volume_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    is_usb_sidetone_vol_enabled = is_feature_enabled;
+}
+
+bool audio_extn_usb_is_sidetone_volume_enabled()
+{
+    return is_usb_sidetone_vol_enabled;
+}
+
+void audio_extn_usb_init(void *adev)
+{
+    if (is_usb_offload_enabled)
+        usb_init(adev);
+}
+
+
+void audio_extn_usb_deinit()
+{
+    if (is_usb_offload_enabled)
+        usb_deinit();
+}
+
+void audio_extn_usb_add_device(audio_devices_t device, int card)
+{
+    if (is_usb_offload_enabled)
+        usb_add_device(device, card);
+}
+
+void audio_extn_usb_remove_device(audio_devices_t device, int card)
+{
+    if (is_usb_offload_enabled)
+        usb_remove_device(device, card);
+}
+
+bool audio_extn_usb_is_config_supported(unsigned int *bit_width,
+                                        unsigned int *sample_rate,
+                                        unsigned int *ch,
+                                        bool is_playback)
+{
+    bool ret_val = false;
+    if (is_usb_offload_enabled)
+        ret_val = usb_is_config_supported(bit_width, sample_rate, ch, is_playback);
+
+    return ret_val;
+}
+
+int audio_extn_usb_enable_sidetone(int device, bool enable)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled)
+        ret_val = usb_enable_sidetone(device, enable);
+
+    return ret_val;
+}
+
+void audio_extn_usb_set_sidetone_gain(struct str_parms *parms,
+                                      char *value, int len)
+{
+    if (is_usb_offload_enabled)
+        usb_set_sidetone_gain(parms, value, len);
+}
+
+bool audio_extn_usb_is_capture_supported()
+{
+    bool ret_val = false;
+    if (is_usb_offload_enabled)
+        ret_val = usb_is_capture_supported();
+
+    return ret_val;
+}
+
+int audio_extn_usb_get_max_channels(bool playback)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled)
+        ret_val = usb_get_max_channels(playback);
+
+    return ret_val;
+}
+
+int audio_extn_usb_get_max_bit_width(bool playback)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled)
+        ret_val = usb_get_max_bit_width(playback);
+
+    return ret_val;
+}
+
+
+int audio_extn_usb_get_sup_sample_rates(bool type, uint32_t *sr, uint32_t l)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled)
+        ret_val = usb_get_sup_sample_rates(type, sr, l);
+
+    return ret_val;
+}
+
+bool audio_extn_usb_is_tunnel_supported()
+{
+    bool ret_val = false;
+    if (is_usb_offload_enabled)
+        ret_val = usb_is_tunnel_supported();
+
+    return ret_val;
+}
+
+bool audio_extn_usb_alive(int card)
+{
+    bool ret_val = false;
+    if (is_usb_offload_enabled)
+        ret_val = usb_alive(card);
+
+    return ret_val;
+}
+
+bool audio_extn_usb_connected(struct str_parms *parms)
+{
+    bool ret_val = false;
+    if (is_usb_offload_enabled)
+        ret_val = usb_connected(parms);
+
+    return ret_val;
+}
+
+unsigned long audio_extn_usb_find_service_interval(bool min, bool playback)
+{
+    unsigned long ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_find_service_interval(min, playback);
+
+    return ret_val;
+}
+
+int audio_extn_usb_altset_for_service_interval(bool is_playback,
+                                               unsigned long service_interval,
+                                               uint32_t *bit_width,
+                                               uint32_t *sample_rate,
+                                               uint32_t *channel_count)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_altset_for_service_interval(is_playback, service_interval,
+                                         bit_width, sample_rate, channel_count);
+
+    return ret_val;
+}
+
+int audio_extn_usb_set_service_interval(bool playback,
+                                        unsigned long service_interval,
+                                        bool *reconfig)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_set_service_interval(playback, service_interval, reconfig);
+
+    return ret_val;
+}
+
+int audio_extn_usb_get_service_interval(bool playback,
+                                        unsigned long *service_interval)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_get_service_interval(playback, service_interval);
+
+    return ret_val;
+}
+
+int audio_extn_usb_check_and_set_svc_int(struct audio_usecase *uc_info,
+                                         bool starting_output_stream)
+{
+    int ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_check_and_set_svc_int(uc_info, starting_output_stream);
+
+    return ret_val;
+}
+
+bool audio_extn_usb_is_reconfig_req()
+{
+    bool ret_val = 0;
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        ret_val = usb_is_reconfig_req();
+
+    return ret_val;
+}
+
+void audio_extn_usb_set_reconfig(bool is_required)
+{
+    if (is_usb_offload_enabled && is_usb_burst_mode_enabled)
+        usb_set_reconfig(is_required);
+}
+
+//END: USB_OFFLOAD ===========================================================
+
+//START: SPEAKER_PROTECTION ==========================================================
+#ifdef __LP64__
+#define SPKR_PROT_LIB_PATH  "/vendor/lib64/libspkrprot.so"
+#define CIRRUS_SPKR_PROT_LIB_PATH  "/vendor/lib64/libcirrusspkrprot.so"
+#else
+#define SPKR_PROT_LIB_PATH  "/vendor/lib/libspkrprot.so"
+#define CIRRUS_SPKR_PROT_LIB_PATH  "/vendor/lib/libcirrusspkrprot.so"
+#endif
+
+static void *spkr_prot_lib_handle = NULL;
+
+typedef void (*spkr_prot_init_t)(void *, spkr_prot_init_config_t);
+static spkr_prot_init_t spkr_prot_init;
+
+typedef int (*spkr_prot_deinit_t)();
+static spkr_prot_deinit_t spkr_prot_deinit;
+
+typedef int (*spkr_prot_start_processing_t)(snd_device_t);
+static spkr_prot_start_processing_t spkr_prot_start_processing;
+
+typedef void (*spkr_prot_stop_processing_t)(snd_device_t);
+static spkr_prot_stop_processing_t spkr_prot_stop_processing;
+
+typedef bool (*spkr_prot_is_enabled_t)();
+static spkr_prot_is_enabled_t spkr_prot_is_enabled;
+
+typedef void (*spkr_prot_calib_cancel_t)(void *);
+static spkr_prot_calib_cancel_t spkr_prot_calib_cancel;
+
+typedef void (*spkr_prot_set_parameters_t)(struct str_parms *,
+                                           char *, int);
+static spkr_prot_set_parameters_t spkr_prot_set_parameters;
+
+typedef int (*fbsp_set_parameters_t)(struct str_parms *);
+static fbsp_set_parameters_t fbsp_set_parameters;
+
+typedef int (*fbsp_get_parameters_t)(struct str_parms *,
+                                   struct str_parms *);
+static fbsp_get_parameters_t fbsp_get_parameters;
+
+typedef int (*get_spkr_prot_snd_device_t)(snd_device_t);
+static get_spkr_prot_snd_device_t get_spkr_prot_snd_device;
+
+void spkr_prot_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        if (is_running_on_stock_version)
+            spkr_prot_lib_handle = dlopen(CIRRUS_SPKR_PROT_LIB_PATH, RTLD_NOW);
+        else
+            spkr_prot_lib_handle = dlopen(SPKR_PROT_LIB_PATH, RTLD_NOW);
+
+        if (spkr_prot_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //if mandatoy functions are not found, disble feature
+
+        // Mandatory functions
+        if (((spkr_prot_init =
+             (spkr_prot_init_t)dlsym(spkr_prot_lib_handle, "spkr_prot_init")) == NULL) ||
+            ((spkr_prot_deinit =
+             (spkr_prot_deinit_t)dlsym(spkr_prot_lib_handle, "spkr_prot_deinit")) == NULL) ||
+            ((spkr_prot_start_processing =
+             (spkr_prot_start_processing_t)dlsym(spkr_prot_lib_handle, "spkr_prot_start_processing")) == NULL) ||
+            ((spkr_prot_stop_processing =
+             (spkr_prot_stop_processing_t)dlsym(spkr_prot_lib_handle, "spkr_prot_stop_processing")) == NULL) ||
+            ((spkr_prot_is_enabled =
+             (spkr_prot_is_enabled_t)dlsym(spkr_prot_lib_handle, "spkr_prot_is_enabled")) == NULL) ||
+            ((spkr_prot_calib_cancel =
+             (spkr_prot_calib_cancel_t)dlsym(spkr_prot_lib_handle, "spkr_prot_calib_cancel")) == NULL) ||
+            ((get_spkr_prot_snd_device =
+             (get_spkr_prot_snd_device_t)dlsym(spkr_prot_lib_handle, "get_spkr_prot_snd_device")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        // options functions, can be NULL
+
+        spkr_prot_set_parameters = NULL;
+        fbsp_set_parameters = NULL;
+        fbsp_get_parameters = NULL;
+        if ((spkr_prot_set_parameters =
+             (spkr_prot_set_parameters_t)dlsym(spkr_prot_lib_handle, "spkr_prot_set_parameters")) == NULL) {
+            ALOGW("%s: dlsym failed for spkr_prot_set_parameters", __func__);
+        }
+
+        if ((fbsp_set_parameters =
+             (fbsp_set_parameters_t)dlsym(spkr_prot_lib_handle, "fbsp_set_parameters")) == NULL) {
+            ALOGW("%s: dlsym failed for fbsp_set_parameters", __func__);
+        }
+
+        if ((fbsp_get_parameters =
+             (fbsp_get_parameters_t)dlsym(spkr_prot_lib_handle, "fbsp_get_parameters")) == NULL) {
+            ALOGW("%s: dlsym failed for fbsp_get_parameters", __func__);
+        }
+
+        ALOGD("%s:: ---- Feature SPKR_PROT is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (spkr_prot_lib_handle) {
+        dlclose(spkr_prot_lib_handle);
+        spkr_prot_lib_handle = NULL;
+    }
+
+    spkr_prot_init = NULL;
+    spkr_prot_deinit = NULL;
+    spkr_prot_start_processing = NULL;
+    spkr_prot_stop_processing = NULL;
+    spkr_prot_is_enabled = NULL;
+    spkr_prot_calib_cancel = NULL;
+    spkr_prot_set_parameters = NULL;
+    fbsp_set_parameters = NULL;
+    fbsp_get_parameters = NULL;
+    get_spkr_prot_snd_device = NULL;
+
+    ALOGW(":: %s: ---- Feature SPKR_PROT is disabled ----", __func__);
+    return;
+}
+
+void audio_extn_spkr_prot_init(void *adev) {
+    if (spkr_prot_init != NULL) {
+        // init function pointers
+        spkr_prot_init_config_t spkr_prot_config_val;
+        spkr_prot_config_val.fp_read_line_from_file = read_line_from_file;
+        spkr_prot_config_val.fp_get_usecase_from_list = get_usecase_from_list;
+        spkr_prot_config_val.fp_disable_snd_device  = disable_snd_device;
+        spkr_prot_config_val.fp_enable_snd_device = enable_snd_device;
+        spkr_prot_config_val.fp_disable_audio_route = disable_audio_route;
+        spkr_prot_config_val.fp_enable_audio_route = enable_audio_route;
+        spkr_prot_config_val.fp_platform_set_snd_device_backend = platform_set_snd_device_backend;
+        spkr_prot_config_val.fp_platform_get_snd_device_name_extn = platform_get_snd_device_name_extn;
+        spkr_prot_config_val.fp_platform_get_default_app_type_v2 = platform_get_default_app_type_v2;
+        spkr_prot_config_val.fp_platform_send_audio_calibration = platform_send_audio_calibration;
+        spkr_prot_config_val.fp_platform_get_pcm_device_id = platform_get_pcm_device_id;
+        spkr_prot_config_val.fp_platform_get_snd_device_name = platform_get_snd_device_name;
+        spkr_prot_config_val.fp_platform_spkr_prot_is_wsa_analog_mode = platform_spkr_prot_is_wsa_analog_mode;
+        spkr_prot_config_val.fp_platform_get_vi_feedback_snd_device = platform_get_vi_feedback_snd_device;
+        spkr_prot_config_val.fp_platform_get_spkr_prot_snd_device = platform_get_spkr_prot_snd_device;
+        spkr_prot_config_val.fp_platform_check_and_set_codec_backend_cfg = platform_check_and_set_codec_backend_cfg;
+        spkr_prot_config_val.fp_audio_extn_get_snd_card_split = audio_extn_get_snd_card_split;
+        spkr_prot_config_val.fp_audio_extn_is_vbat_enabled = audio_extn_is_vbat_enabled;
+
+        spkr_prot_init(adev, spkr_prot_config_val);
+    }
+
+    return;
+}
+
+int audio_extn_spkr_prot_deinit() {
+    int ret_val = 0;
+
+    if (spkr_prot_deinit != NULL)
+        ret_val = spkr_prot_deinit();
+
+    return ret_val;
+}
+
+int audio_extn_spkr_prot_start_processing(snd_device_t snd_device) {
+    int ret_val = 0;
+
+    if (spkr_prot_start_processing != NULL)
+        ret_val = spkr_prot_start_processing(snd_device);
+
+    return ret_val;
+}
+
+void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device)
+{
+    if (spkr_prot_stop_processing != NULL)
+        spkr_prot_stop_processing(snd_device);
+
+    return;
+}
+
+bool audio_extn_spkr_prot_is_enabled()
+{
+    bool ret_val = false;
+
+    if (spkr_prot_is_enabled != NULL)
+        ret_val = spkr_prot_is_enabled();
+
+    return ret_val;
+}
+
+void audio_extn_spkr_prot_calib_cancel(void *adev)
+{
+    if (spkr_prot_calib_cancel != NULL)
+        spkr_prot_calib_cancel(adev);
+
+    return;
+}
+
+void audio_extn_spkr_prot_set_parameters(struct str_parms *parms,
+                                         char *value, int len)
+{
+    if (spkr_prot_set_parameters != NULL)
+        spkr_prot_set_parameters(parms, value, len);
+
+    return;
+}
+
+int audio_extn_fbsp_set_parameters(struct str_parms *parms)
+{
+    int ret_val = 0;
+
+    if (fbsp_set_parameters != NULL)
+        ret_val = fbsp_set_parameters(parms);
+
+    return ret_val;
+}
+
+int audio_extn_fbsp_get_parameters(struct str_parms *query,
+                                   struct str_parms *reply)
+{
+    int ret_val = 0;
+
+    if (fbsp_get_parameters != NULL)
+        ret_val = fbsp_get_parameters(query, reply);
+
+    return ret_val;
+}
+
+int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device)
+{
+    int ret_val = snd_device;
+
+    if (get_spkr_prot_snd_device != NULL)
+        ret_val = get_spkr_prot_snd_device(snd_device);
+
+    return ret_val;
+}
+
+//END: SPEAKER_PROTECTION ==========================================================
+
+//START: EXTERNAL_QDSP ================================================================
+#ifdef __LP64__
+#define EXTERNAL_QDSP_LIB_PATH  "/vendor/lib64/libextqdsp.so"
+#else
+#define EXTERNAL_QDSP_LIB_PATH  "/vendor/lib/libextqdsp.so"
+#endif
+
+static void *external_qdsp_lib_handle = NULL;
+
+typedef void (*external_qdsp_init_t)(void *);
+static external_qdsp_init_t external_qdsp_init;
+
+typedef void (*external_qdsp_deinit_t)(void);
+static external_qdsp_deinit_t external_qdsp_deinit;
+
+typedef bool (*external_qdsp_set_state_t)(struct audio_device *,
+                                        int , float , bool);
+static external_qdsp_set_state_t external_qdsp_set_state;
+
+typedef void (*external_qdsp_set_device_t)(struct audio_usecase *);
+static external_qdsp_set_device_t external_qdsp_set_device;
+
+typedef void (*external_qdsp_set_parameter_t)(struct audio_device *,
+                                              struct str_parms *);
+static external_qdsp_set_parameter_t external_qdsp_set_parameter;
+
+typedef bool (*external_qdsp_supported_usb_t)(void);
+static external_qdsp_supported_usb_t external_qdsp_supported_usb;
+
+void external_qdsp_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        external_qdsp_lib_handle = dlopen(EXTERNAL_QDSP_LIB_PATH, RTLD_NOW);
+        if (external_qdsp_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((external_qdsp_init =
+             (external_qdsp_init_t)dlsym(external_qdsp_lib_handle, "ma_init")) == NULL) ||
+            ((external_qdsp_deinit =
+             (external_qdsp_deinit_t)dlsym(external_qdsp_lib_handle, "ma_deinit")) == NULL) ||
+            ((external_qdsp_set_state =
+             (external_qdsp_set_state_t)dlsym(external_qdsp_lib_handle, "set_state")) == NULL) ||
+            ((external_qdsp_set_device =
+             (external_qdsp_set_device_t)dlsym(external_qdsp_lib_handle, "set_device")) == NULL) ||
+            ((external_qdsp_set_parameter =
+             (external_qdsp_set_parameter_t)dlsym(external_qdsp_lib_handle, "set_parameters")) == NULL) ||
+            ((external_qdsp_supported_usb =
+             (external_qdsp_supported_usb_t)dlsym(external_qdsp_lib_handle, "supported_usb")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature EXTERNAL_QDSP is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (external_qdsp_lib_handle) {
+        dlclose(external_qdsp_lib_handle);
+        external_qdsp_lib_handle = NULL;
+    }
+
+    external_qdsp_init = NULL;
+    external_qdsp_deinit = NULL;
+    external_qdsp_set_state = NULL;
+    external_qdsp_set_device = NULL;
+    external_qdsp_set_parameter = NULL;
+    external_qdsp_supported_usb = NULL;
+
+    ALOGW(":: %s: ---- Feature EXTERNAL_QDSP is disabled ----", __func__);
+    return;
+}
+
+void audio_extn_qdsp_init(void *platform) {
+    if (external_qdsp_init != NULL)
+        external_qdsp_init(platform);
+
+    return;
+}
+
+void audio_extn_qdsp_deinit() {
+    if (external_qdsp_deinit != NULL)
+        external_qdsp_deinit();
+
+    return;
+}
+
+bool audio_extn_qdsp_set_state(struct audio_device *adev, int stream_type,
+                             float vol, bool active) {
+    bool ret_val = false;
+
+    if (external_qdsp_set_state != NULL)
+        ret_val = external_qdsp_set_state(adev, stream_type, vol, active);
+
+    return ret_val;
+}
+
+void audio_extn_qdsp_set_device(struct audio_usecase *usecase) {
+    if (external_qdsp_set_device != NULL)
+        external_qdsp_set_device(usecase);
+
+    return;
+}
+
+void audio_extn_qdsp_set_parameters(struct audio_device *adev,
+                                  struct str_parms *parms) {
+    if (external_qdsp_set_parameter != NULL)
+        external_qdsp_set_parameter(adev, parms);
+
+    return;
+}
+
+bool audio_extn_qdsp_supported_usb() {
+    bool ret_val = false;
+
+    if (external_qdsp_supported_usb != NULL)
+        ret_val = external_qdsp_supported_usb();
+
+    return ret_val;
+}
+
+
+//END: EXTERNAL_QDSP ================================================================
+
+//START: EXTERNAL_SPEAKER ================================================================
+#ifdef __LP64__
+#define EXTERNAL_SPKR_LIB_PATH  "/vendor/lib64/libextspkr.so"
+#else
+#define EXTERNAL_SPKR_LIB_PATH  "/vendor/lib/libextspkr.so"
+#endif
+
+static void *external_speaker_lib_handle = NULL;
+
+typedef void* (*external_speaker_init_t)(struct audio_device *);
+static external_speaker_init_t external_speaker_init;
+
+typedef void (*external_speaker_deinit_t)(void *);
+static external_speaker_deinit_t external_speaker_deinit;
+
+typedef void (*external_speaker_update_t)(void *);
+static external_speaker_update_t external_speaker_update;
+
+typedef void (*external_speaker_set_mode_t)(void *, audio_mode_t);
+static external_speaker_set_mode_t external_speaker_set_mode;
+
+typedef void (*external_speaker_set_voice_vol_t)(void *, float);
+static external_speaker_set_voice_vol_t external_speaker_set_voice_vol;
+
+
+void external_speaker_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        external_speaker_lib_handle = dlopen(EXTERNAL_SPKR_LIB_PATH, RTLD_NOW);
+        if (external_speaker_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((external_speaker_init =
+             (external_speaker_init_t)dlsym(external_speaker_lib_handle, "extspk_init")) == NULL) ||
+            ((external_speaker_deinit =
+             (external_speaker_deinit_t)dlsym(external_speaker_lib_handle, "extspk_deinit")) == NULL) ||
+            ((external_speaker_update =
+             (external_speaker_update_t)dlsym(external_speaker_lib_handle, "extspk_update")) == NULL) ||
+            ((external_speaker_set_mode =
+             (external_speaker_set_mode_t)dlsym(external_speaker_lib_handle, "extspk_set_mode")) == NULL) ||
+            ((external_speaker_set_voice_vol =
+             (external_speaker_set_voice_vol_t)dlsym(external_speaker_lib_handle, "extspk_set_voice_vol")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature EXTERNAL_SPKR is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (external_speaker_lib_handle) {
+        dlclose(external_speaker_lib_handle);
+        external_speaker_lib_handle = NULL;
+    }
+
+    external_speaker_init = NULL;
+    external_speaker_deinit = NULL;
+    external_speaker_update = NULL;
+    external_speaker_set_mode = NULL;
+    external_speaker_set_voice_vol = NULL;
+
+    ALOGW(":: %s: ---- Feature EXTERNAL_SPKR is disabled ----", __func__);
+    return;
+}
+
+void *audio_extn_extspk_init(struct audio_device *adev) {
+    void* ret_val = NULL;
+
+    if (external_speaker_init != NULL)
+        ret_val = external_speaker_init(adev);
+
+    return ret_val;
+}
+
+void audio_extn_extspk_deinit(void *extn) {
+    if (external_speaker_deinit != NULL)
+        external_speaker_deinit(extn);
+
+    return;
+}
+
+void audio_extn_extspk_update(void* extn) {
+    if (external_speaker_update != NULL)
+        external_speaker_update(extn);
+
+    return;
+}
+
+void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode) {
+    if (external_speaker_set_mode != NULL)
+        external_speaker_set_mode(extn, mode);
+
+    return;
+}
+
+void audio_extn_extspk_set_voice_vol(void* extn, float vol) {
+    if (external_speaker_set_voice_vol != NULL)
+        external_speaker_set_voice_vol(extn, vol);
+
+    return;
+}
+
+//END: EXTERNAL_SPEAKER ================================================================
+
+
+//START: EXTERNAL_SPEAKER_TFA ================================================================
+#ifdef __LP64__
+#define EXTERNAL_SPKR_TFA_LIB_PATH  "/vendor/lib64/libextspkr_tfa.so"
+#else
+#define EXTERNAL_SPKR_TFA_LIB_PATH  "/vendor/lib/libextspkr_tfa.so"
+#endif
+
+static void *external_speaker_tfa_lib_handle = NULL;
+
+typedef int (*external_speaker_tfa_enable_t)(void);
+static external_speaker_tfa_enable_t external_speaker_tfa_enable;
+
+typedef void (*external_speaker_tfa_disable_t)(snd_device_t);
+static external_speaker_tfa_disable_t external_speaker_tfa_disable;
+
+typedef void (*external_speaker_tfa_set_mode_t)();
+static external_speaker_tfa_set_mode_t external_speaker_tfa_set_mode;
+
+typedef void (*external_speaker_tfa_set_mode_bt_t)();
+static external_speaker_tfa_set_mode_bt_t external_speaker_tfa_set_mode_bt;
+
+typedef void (*external_speaker_tfa_update_t)(void);
+static external_speaker_tfa_update_t external_speaker_tfa_update;
+
+typedef void (*external_speaker_tfa_set_voice_vol_t)(float);
+static external_speaker_tfa_set_voice_vol_t external_speaker_tfa_set_voice_vol;
+
+typedef int (*external_speaker_tfa_init_t)(struct audio_device *);
+static external_speaker_tfa_init_t external_speaker_tfa_init;
+
+typedef void (*external_speaker_tfa_deinit_t)(void);
+static external_speaker_tfa_deinit_t external_speaker_tfa_deinit;
+
+typedef bool (*external_speaker_tfa_is_supported_t)(void);
+static external_speaker_tfa_is_supported_t external_speaker_tfa_is_supported;
+
+void external_speaker_tfa_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        external_speaker_tfa_lib_handle = dlopen(EXTERNAL_SPKR_TFA_LIB_PATH, RTLD_NOW);
+        if (external_speaker_tfa_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((external_speaker_tfa_enable =
+             (external_speaker_tfa_enable_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_enable_speaker")) == NULL) ||
+            ((external_speaker_tfa_disable =
+             (external_speaker_tfa_disable_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_disable_speaker")) == NULL) ||
+            ((external_speaker_tfa_set_mode =
+             (external_speaker_tfa_set_mode_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_set_mode")) == NULL) ||
+            ((external_speaker_tfa_set_mode_bt =
+             (external_speaker_tfa_set_mode_bt_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_set_mode_bt")) == NULL) ||
+            ((external_speaker_tfa_update =
+             (external_speaker_tfa_update_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_update")) == NULL) ||
+            ((external_speaker_tfa_set_voice_vol =
+             (external_speaker_tfa_set_voice_vol_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_set_voice_vol")) == NULL) ||
+            ((external_speaker_tfa_init =
+             (external_speaker_tfa_init_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_init")) == NULL) ||
+            ((external_speaker_tfa_deinit =
+             (external_speaker_tfa_deinit_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_deinit")) == NULL) ||
+            ((external_speaker_tfa_is_supported =
+             (external_speaker_tfa_is_supported_t)dlsym(external_speaker_tfa_lib_handle, "tfa_98xx_is_supported")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature EXTERNAL_SPKR is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (external_speaker_tfa_lib_handle) {
+        dlclose(external_speaker_tfa_lib_handle);
+        external_speaker_tfa_lib_handle = NULL;
+    }
+
+    external_speaker_tfa_enable = NULL;
+    external_speaker_tfa_disable = NULL;
+    external_speaker_tfa_set_mode = NULL;
+    external_speaker_tfa_update = NULL;
+    external_speaker_tfa_set_voice_vol = NULL;
+    external_speaker_tfa_init = NULL;
+    external_speaker_tfa_deinit = NULL;
+    external_speaker_tfa_is_supported = NULL;
+
+    ALOGW(":: %s: ---- Feature EXTERNAL_SPKR_TFA is disabled ----", __func__);
+    return;
+}
+
+int audio_extn_external_speaker_tfa_enable_speaker() {
+    int ret_val = 0;
+
+    if (external_speaker_tfa_enable != NULL)
+        ret_val = external_speaker_tfa_enable();
+
+    return ret_val;
+}
+
+void audio_extn_external_speaker_tfa_disable_speaker(snd_device_t snd_device) {
+    if (external_speaker_tfa_disable != NULL)
+        external_speaker_tfa_disable(snd_device);
+
+    return;
+}
+
+void audio_extn_external_speaker_tfa_set_mode(bool is_mode_bt) {
+    if (is_mode_bt && (external_speaker_tfa_set_mode_bt != NULL))
+        external_speaker_tfa_set_mode_bt();
+    else if (external_speaker_tfa_set_mode != NULL)
+        external_speaker_tfa_set_mode();
+
+    return;
+}
+
+void audio_extn_external_speaker_tfa_update() {
+    if (external_speaker_tfa_update != NULL)
+        external_speaker_tfa_update();
+
+    return;
+}
+
+void audio_extn_external_speaker_tfa_set_voice_vol(float vol) {
+    if (external_speaker_tfa_set_voice_vol != NULL)
+        external_speaker_tfa_set_voice_vol(vol);
+
+    return;
+}
+
+int  audio_extn_external_tfa_speaker_init(struct audio_device *adev) {
+    int ret_val = 0;
+
+    if (external_speaker_tfa_init != NULL)
+        ret_val = external_speaker_tfa_init(adev);
+
+    return ret_val;
+}
+
+void audio_extn_external_speaker_tfa_deinit() {
+    if (external_speaker_tfa_deinit != NULL)
+        external_speaker_tfa_deinit();
+
+    return;
+}
+
+bool audio_extn_external_speaker_tfa_is_supported() {
+    bool ret_val = false;
+
+    if (external_speaker_tfa_is_supported != NULL)
+        ret_val = external_speaker_tfa_is_supported;
+
+    return ret_val;
+}
+
+
+//END: EXTERNAL_SPEAKER_TFA ================================================================
+
+
+//START: HWDEP_CAL ================================================================
+#ifdef __LP64__
+#define HWDEP_CAL_LIB_PATH  "/vendor/lib64/libhwdepcal.so"
+#else
+#define HWDEP_CAL_LIB_PATH  "/vendor/lib/libhwdepcal.so"
+#endif
+
+static void *hwdep_cal_lib_handle = NULL;
+
+typedef void (*hwdep_cal_send_t)(int, void*);
+static hwdep_cal_send_t hwdep_cal_send;
+
+void hwdep_cal_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        hwdep_cal_lib_handle = dlopen(HWDEP_CAL_LIB_PATH, RTLD_NOW);
+        if (hwdep_cal_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if ((hwdep_cal_send =
+            (hwdep_cal_send_t)dlsym(hwdep_cal_lib_handle, "hwdep_cal_send")) == NULL) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature HWDEP_CAL is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (hwdep_cal_lib_handle) {
+        dlclose(hwdep_cal_lib_handle);
+        hwdep_cal_lib_handle = NULL;
+    }
+
+    hwdep_cal_send = NULL;
+
+    ALOGW(":: %s: ---- Feature HWDEP_CAL is disabled ----", __func__);
+    return;
+}
+
+void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle)
+{
+    if (hwdep_cal_send != NULL)
+        hwdep_cal_send(snd_card, acdb_handle);
+
+    return;
+}
+
+
+//END: HWDEP_CAL =====================================================================
+
+
+//START: DSM_FEEDBACK ================================================================
+#ifdef __LP64__
+#define DSM_FEEDBACK_LIB_PATH  "/vendor/lib64/libdsmfeedback.so"
+#else
+#define DSM_FEEDBACK_LIB_PATH  "/vendor/lib/libdsmfeedback.so"
+#endif
+
+static void *dsm_feedback_lib_handle = NULL;
+
+typedef void (*dsm_feedback_enable_t)(struct audio_device*, snd_device_t, bool);
+static dsm_feedback_enable_t dsm_feedback_enable;
+
+void dsm_feedback_feature_init (bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        dsm_feedback_lib_handle = dlopen(DSM_FEEDBACK_LIB_PATH, RTLD_NOW);
+        if (dsm_feedback_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if ((dsm_feedback_enable =
+            (dsm_feedback_enable_t)dlsym(dsm_feedback_lib_handle, "dsm_feedback_enable")) == NULL) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature DSM_FEEDBACK is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (dsm_feedback_lib_handle) {
+        dlclose(dsm_feedback_lib_handle);
+        dsm_feedback_lib_handle = NULL;
+    }
+
+    dsm_feedback_enable = NULL;
+
+    ALOGW(":: %s: ---- Feature DSM_FEEDBACK is disabled ----", __func__);
+    return;
+}
+
+void audio_extn_dsm_feedback_enable(struct audio_device *adev, snd_device_t snd_device, bool benable)
+{
+    if (dsm_feedback_enable != NULL)
+        dsm_feedback_enable(adev, snd_device, benable);
+
+    return;
+}
+
+//END:   DSM_FEEDBACK ================================================================
+
+//START: SND_MONITOR_FEATURE ================================================================
+#ifdef __LP64__
+#define SND_MONITOR_PATH  "/vendor/lib64/libsndmonitor.so"
+#else
+#define SND_MONITOR_PATH  "/vendor/lib/libsndmonitor.so"
+#endif
+static void *snd_mnt_lib_handle = NULL;
+
+typedef int (*snd_mon_init_t)();
+static snd_mon_init_t snd_mon_init;
+typedef int (*snd_mon_deinit_t)();
+static snd_mon_deinit_t snd_mon_deinit;
+typedef int (*snd_mon_register_listener_t)(void *, snd_mon_cb);
+static snd_mon_register_listener_t snd_mon_register_listener;
+typedef int (*snd_mon_unregister_listener_t)(void *);
+static snd_mon_unregister_listener_t snd_mon_unregister_listener;
+
+void snd_mon_feature_init (bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        snd_mnt_lib_handle = dlopen(SND_MONITOR_PATH, RTLD_NOW);
+        if (snd_mnt_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((snd_mon_init = (snd_mon_init_t)dlsym(snd_mnt_lib_handle,"snd_mon_init")) == NULL) ||
+            ((snd_mon_deinit = (snd_mon_deinit_t)dlsym(snd_mnt_lib_handle,"snd_mon_deinit")) == NULL) ||
+            ((snd_mon_register_listener = (snd_mon_register_listener_t)dlsym(snd_mnt_lib_handle,"snd_mon_register_listener")) == NULL) ||
+            ((snd_mon_unregister_listener = (snd_mon_unregister_listener_t)dlsym(snd_mnt_lib_handle,"snd_mon_unregister_listener")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+        ALOGD("%s:: ---- Feature SND_MONITOR is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (snd_mnt_lib_handle) {
+        dlclose(snd_mnt_lib_handle);
+        snd_mnt_lib_handle = NULL;
+    }
+
+    snd_mon_init                = NULL;
+    snd_mon_deinit              = NULL;
+    snd_mon_register_listener   = NULL;
+    snd_mon_unregister_listener = NULL;
+    ALOGW(":: %s: ---- Feature SND_MONITOR is disabled ----", __func__);
+    return;
+}
+
+int audio_extn_snd_mon_init()
+{
+    int ret = 0;
+    if (snd_mon_init != NULL)
+        ret = snd_mon_init();
+
+    return ret;
+}
+
+int audio_extn_snd_mon_deinit()
+{
+    int ret = 0;
+    if (snd_mon_deinit != NULL)
+        ret = snd_mon_deinit();
+
+    return ret;
+}
+
+int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb)
+{
+    int ret = 0;
+    if (snd_mon_register_listener != NULL)
+        ret = snd_mon_register_listener(stream, cb);
+
+    return ret;
+}
+
+int audio_extn_snd_mon_unregister_listener(void *stream)
+{
+    int ret = 0;
+    if (snd_mon_unregister_listener != NULL)
+        ret = snd_mon_unregister_listener(stream);
+
+    return ret;
+}
+
+//END: SND_MONITOR_FEATURE ================================================================
+
+//START: SOURCE_TRACKING_FEATURE ==============================================
+int get_soundfocus_data(const struct audio_device *adev,
+                                   struct sound_focus_param *payload);
+int get_sourcetrack_data(const struct audio_device *adev,
+                                    struct source_tracking_param *payload);
+int set_soundfocus_data(struct audio_device *adev,
+                                   struct sound_focus_param *payload);
+void source_track_set_parameters(struct audio_device *adev,
+                                            struct str_parms *parms);
+void source_track_get_parameters(const struct audio_device *adev,
+                                            struct str_parms *query,
+                                            struct str_parms *reply);
+
+static bool is_src_trkn_enabled = false;
+
+void src_trkn_feature_init(bool is_feature_enabled) {
+    is_src_trkn_enabled = is_feature_enabled;
+
+    if (is_src_trkn_enabled) {
+        ALOGD("%s:: ---- Feature SOURCE_TRACKING is Enabled ----", __func__);
+        return;
+    }
+
+    ALOGW(":: %s: ---- Feature SOURCE_TRACKING is disabled ----", __func__);
+}
+
+int audio_extn_get_soundfocus_data(const struct audio_device *adev,
+                                   struct sound_focus_param *payload) {
+    int ret = 0;
+
+    if (is_src_trkn_enabled)
+        ret = get_soundfocus_data(adev, payload);
+
+    return ret;
+}
+
+int audio_extn_get_sourcetrack_data(const struct audio_device *adev,
+                                    struct source_tracking_param *payload) {
+    int ret = 0;
+
+    if (is_src_trkn_enabled)
+        ret = get_sourcetrack_data(adev, payload);
+
+    return ret;
+}
+
+int audio_extn_set_soundfocus_data(struct audio_device *adev,
+                                   struct sound_focus_param *payload) {
+    int ret = 0;
+
+    if (is_src_trkn_enabled)
+        ret = set_soundfocus_data(adev, payload);
+
+    return ret;
+}
+
+void audio_extn_source_track_set_parameters(struct audio_device *adev,
+                                            struct str_parms *parms) {
+    if (is_src_trkn_enabled)
+        source_track_set_parameters(adev, parms);
+}
+
+void audio_extn_source_track_get_parameters(const struct audio_device *adev,
+                                            struct str_parms *query,
+                                            struct str_parms *reply) {
+    if (is_src_trkn_enabled)
+        source_track_get_parameters(adev, query, reply);
+}
+//END: SOURCE_TRACKING_FEATURE ================================================
+
+//START: SSREC_FEATURE ==========================================================
+#ifdef __LP64__
+#define SSREC_LIB_PATH  "/vendor/lib64/libssrec.so"
+#else
+#define SSREC_LIB_PATH  "/vendor/lib/libssrec.so"
+#endif
+
+static void *ssrec_lib_handle = NULL;
+
+typedef bool (*ssr_check_usecase_t)(struct stream_in *);
+static ssr_check_usecase_t ssr_check_usecase;
+
+typedef int (*ssr_set_usecase_t)(struct stream_in *,
+                                 struct audio_config *,
+                                 bool *);
+static ssr_set_usecase_t ssr_set_usecase;
+
+typedef int32_t (*ssr_init_t)(struct stream_in *,
+                              int num_out_chan);
+static ssr_init_t ssr_init;
+
+typedef int32_t (*ssr_deinit_t)();
+static ssr_deinit_t ssr_deinit;
+
+typedef void (*ssr_update_enabled_t)();
+static ssr_update_enabled_t ssr_update_enabled;
+
+typedef bool (*ssr_get_enabled_t)();
+static ssr_get_enabled_t ssr_get_enabled;
+
+typedef int32_t (*ssr_read_t)(struct audio_stream_in *,
+                              void *,
+                              size_t);
+static ssr_read_t ssr_read;
+
+typedef void (*ssr_set_parameters_t)(struct audio_device *,
+                                     struct str_parms *);
+static ssr_set_parameters_t ssr_set_parameters;
+
+typedef void (*ssr_get_parameters_t)(const struct audio_device *,
+                                     struct str_parms *,
+                                     struct str_parms *);
+static ssr_get_parameters_t ssr_get_parameters;
+
+typedef struct stream_in *(*ssr_get_stream_t)();
+static ssr_get_stream_t ssr_get_stream;
+
+void ssrec_feature_init(bool is_feature_enabled) {
+
+    if (is_feature_enabled) {
+        ssrec_lib_handle = dlopen(SSREC_LIB_PATH, RTLD_NOW);
+        if (ssrec_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+
+        if (((ssr_check_usecase = (ssr_check_usecase_t)dlsym(ssrec_lib_handle, "ssr_check_usecase")) == NULL) ||
+            ((ssr_set_usecase = (ssr_set_usecase_t)dlsym(ssrec_lib_handle, "ssr_set_usecase")) == NULL) ||
+            ((ssr_init = (ssr_init_t)dlsym(ssrec_lib_handle, "ssr_init")) == NULL) ||
+            ((ssr_deinit = (ssr_deinit_t)dlsym(ssrec_lib_handle, "ssr_deinit")) == NULL) ||
+            ((ssr_update_enabled = (ssr_update_enabled_t)dlsym(ssrec_lib_handle, "ssr_update_enabled")) == NULL) ||
+            ((ssr_get_enabled = (ssr_get_enabled_t)dlsym(ssrec_lib_handle, "ssr_get_enabled")) == NULL) ||
+            ((ssr_read = (ssr_read_t)dlsym(ssrec_lib_handle, "ssr_read")) == NULL) ||
+            ((ssr_set_parameters = (ssr_set_parameters_t)dlsym(ssrec_lib_handle, "ssr_set_parameters")) == NULL) ||
+            ((ssr_get_parameters = (ssr_get_parameters_t)dlsym(ssrec_lib_handle, "ssr_get_parameters")) == NULL) ||
+            ((ssr_get_stream = (ssr_get_stream_t)dlsym(ssrec_lib_handle, "ssr_get_stream")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature SSREC is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if(ssrec_lib_handle) {
+        dlclose(ssrec_lib_handle);
+        ssrec_lib_handle = NULL;
+    }
+
+    ssr_check_usecase = NULL;
+    ssr_set_usecase = NULL;
+    ssr_init = NULL;
+    ssr_deinit = NULL;
+    ssr_update_enabled = NULL;
+    ssr_get_enabled = NULL;
+    ssr_read = NULL;
+    ssr_set_parameters = NULL;
+    ssr_get_parameters = NULL;
+    ssr_get_stream = NULL;
+
+    ALOGW(":: %s: ---- Feature SSREC is disabled ----", __func__);
+}
+
+bool audio_extn_ssr_check_usecase(struct stream_in *in) {
+    bool ret = false;
+
+    if (ssrec_lib_handle != NULL)
+        ret = ssr_check_usecase(in);
+
+    return ret;
+}
+
+int audio_extn_ssr_set_usecase(struct stream_in *in,
+                               struct audio_config *config,
+                               bool *channel_mask_updated) {
+    int ret = 0;
+
+    if (ssrec_lib_handle != NULL)
+        ret = ssr_set_usecase(in, config, channel_mask_updated);
+
+    return ret;
+}
+
+int32_t audio_extn_ssr_init(struct stream_in *in,
+                            int num_out_chan) {
+    int32_t ret = 0;
+
+    if (ssrec_lib_handle != NULL)
+        ret = ssr_init(in, num_out_chan);
+
+    return ret;
+}
+
+int32_t audio_extn_ssr_deinit() {
+    int32_t ret = 0;
+
+    if (ssrec_lib_handle != NULL)
+        ret = ssr_deinit();
+
+    return ret;
+}
+
+void audio_extn_ssr_update_enabled() {
+
+    if (ssrec_lib_handle)
+        ssr_update_enabled();
+}
+
+bool audio_extn_ssr_get_enabled() {
+    bool ret = false;
+
+    if (ssrec_lib_handle)
+        ret = ssr_get_enabled();
+
+    return ret;
+}
+
+int32_t audio_extn_ssr_read(struct audio_stream_in *stream,
+                            void *buffer,
+                            size_t bytes) {
+    int32_t ret = 0;
+
+    if (ssrec_lib_handle)
+        ret = ssr_read(stream, buffer, bytes);
+
+    return ret;
+}
+
+void audio_extn_ssr_set_parameters(struct audio_device *adev,
+                                   struct str_parms *parms) {
+
+    if (ssrec_lib_handle)
+        ssr_set_parameters(adev, parms);
+}
+
+void audio_extn_ssr_get_parameters(const struct audio_device *adev,
+                                   struct str_parms *query,
+                                   struct str_parms *reply) {
+
+    if (ssrec_lib_handle)
+        ssr_get_parameters(adev, query, reply);
+}
+
+struct stream_in *audio_extn_ssr_get_stream() {
+    struct stream_in *ret = NULL;
+
+    if (ssrec_lib_handle)
+        ret = ssr_get_stream();
+
+    return ret;
+}
+//END: SSREC_FEATURE ============================================================
+
+//START: COMPRESS_CAPTURE_FEATURE ================================================================
+#ifdef __LP64__
+#define COMPRESS_CAPTURE_PATH  "/vendor/lib64/libcomprcapture.so"
+#else
+#define COMPRESS_CAPTURE_PATH  "/vendor/lib/libcomprcapture.so"
+#endif
+static void *compr_cap_lib_handle = NULL;
+
+typedef void (*compr_cap_init_t)(struct stream_in*);
+static compr_cap_init_t compr_cap_init;
+
+typedef void (*compr_cap_deinit_t)();
+static compr_cap_deinit_t compr_cap_deinit;
+
+typedef bool (*compr_cap_enabled_t)();
+static compr_cap_enabled_t compr_cap_enabled;
+
+typedef bool (*compr_cap_format_supported_t)(audio_format_t);
+static compr_cap_format_supported_t compr_cap_format_supported;
+
+typedef bool (*compr_cap_usecase_supported_t)(audio_usecase_t);
+static compr_cap_usecase_supported_t compr_cap_usecase_supported;
+
+typedef size_t (*compr_cap_get_buffer_size_t)(audio_usecase_t);
+static compr_cap_get_buffer_size_t compr_cap_get_buffer_size;
+
+typedef int (*compr_cap_read_t)(struct stream_in*, void*, size_t);
+static compr_cap_read_t compr_cap_read;
+
+void compr_cap_feature_init(bool is_feature_enabled)
+{
+    if(is_feature_enabled) {
+        //dlopen lib
+        compr_cap_lib_handle = dlopen(COMPRESS_CAPTURE_PATH, RTLD_NOW);
+        if (compr_cap_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((compr_cap_init = (compr_cap_init_t)dlsym(compr_cap_lib_handle,"compr_cap_init")) == NULL) ||
+            ((compr_cap_deinit = (compr_cap_deinit_t)dlsym(compr_cap_lib_handle,"compr_cap_deinit")) == NULL) ||
+            ((compr_cap_enabled = (compr_cap_enabled_t)dlsym(compr_cap_lib_handle,"compr_cap_enabled")) == NULL) ||
+            ((compr_cap_format_supported = (compr_cap_format_supported_t)dlsym(compr_cap_lib_handle,"compr_cap_format_supported")) == NULL) ||
+            ((compr_cap_usecase_supported = (compr_cap_usecase_supported_t)dlsym(compr_cap_lib_handle,"compr_cap_usecase_supported")) == NULL) ||
+            ((compr_cap_get_buffer_size = (compr_cap_get_buffer_size_t)dlsym(compr_cap_lib_handle,"compr_cap_get_buffer_size")) == NULL) ||
+            ((compr_cap_read = (compr_cap_read_t)dlsym(compr_cap_lib_handle,"compr_cap_read")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature COMPRESS_CAPTURE is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (compr_cap_lib_handle) {
+        dlclose(compr_cap_lib_handle);
+        compr_cap_lib_handle = NULL;
+    }
+
+    compr_cap_init                 = NULL;
+    compr_cap_deinit               = NULL;
+    compr_cap_enabled              = NULL;
+    compr_cap_format_supported     = NULL;
+    compr_cap_usecase_supported    = NULL;
+    compr_cap_get_buffer_size      = NULL;
+    compr_cap_read                 = NULL;
+
+    ALOGW(":: %s: ---- Feature COMPRESS_CAPTURE is disabled ----", __func__);
+    return;
+}
+
+void audio_extn_compr_cap_init(struct stream_in* instream)
+{
+    if (compr_cap_init != NULL)
+        compr_cap_init(instream);
+
+    return;
+}
+
+void audio_extn_compr_cap_deinit()
+{
+    if(compr_cap_deinit)
+        compr_cap_deinit();
+
+    return;
+}
+
+bool audio_extn_compr_cap_enabled()
+{
+    bool ret_val = false;
+
+    if (compr_cap_enabled)
+        ret_val = compr_cap_enabled();
+
+    return ret_val;
+}
+
+bool audio_extn_compr_cap_format_supported(audio_format_t format)
+{
+    bool ret_val = false;
+
+    if (compr_cap_format_supported != NULL)
+        ret_val =  compr_cap_format_supported(format);
+
+    return ret_val;
+}
+
+bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase)
+{
+    bool ret_val = false;
+
+    if (compr_cap_usecase_supported != NULL)
+        ret_val =  compr_cap_usecase_supported(usecase);
+
+    return ret_val;
+}
+
+size_t audio_extn_compr_cap_get_buffer_size(audio_format_t format)
+{
+    size_t ret_val = 0;
+
+    if (compr_cap_get_buffer_size != NULL)
+        ret_val =  compr_cap_get_buffer_size(format);
+
+    return ret_val;
+}
+
+size_t audio_extn_compr_cap_read(struct stream_in *in,
+                                        void *buffer, size_t bytes)
+{
+    size_t ret_val = 0;
+
+    if (compr_cap_read != NULL)
+        ret_val =  compr_cap_read(in, buffer, bytes);
+
+    return ret_val;
+}
+
+
 void audio_extn_init(struct audio_device *adev)
 {
+    //fix-me: check running on vendor enhanced build
+    //is_running_on_stock_version = !isRunningWithVendorEnhancedFramework();
+    audio_extn_feature_init();
     aextnmod.anc_enabled = 0;
     aextnmod.aanc_enabled = 0;
     aextnmod.custom_stereo_enabled = 0;
@@ -982,73 +2348,16 @@
     audio_extn_aptx_dec_set_license(adev);
 }
 
-void audio_extn_set_parameters(struct audio_device *adev,
-                               struct str_parms *parms)
-{
-   bool a2dp_reconfig = false;
-
-   audio_extn_set_aanc_noise_level(adev, parms);
-   audio_extn_set_anc_parameters(adev, parms);
-   audio_extn_set_fluence_parameters(adev, parms);
-   audio_extn_set_afe_proxy_parameters(adev, parms);
-   audio_extn_fm_set_parameters(adev, parms);
-   audio_extn_sound_trigger_set_parameters(adev, parms);
-   audio_extn_listen_set_parameters(adev, parms);
-   audio_extn_ssr_set_parameters(adev, parms);
-   audio_extn_hfp_set_parameters(adev, parms);
-   audio_extn_dts_eagle_set_parameters(adev, parms);
-   audio_extn_a2dp_set_parameters(parms, &a2dp_reconfig);
-   audio_extn_ddp_set_parameters(adev, parms);
-   audio_extn_ds2_set_parameters(adev, parms);
-   audio_extn_customstereo_set_parameters(adev, parms);
-   audio_extn_hpx_set_parameters(adev, parms);
-   audio_extn_pm_set_parameters(parms);
-   audio_extn_source_track_set_parameters(adev, parms);
-   audio_extn_fbsp_set_parameters(parms);
-   audio_extn_keep_alive_set_parameters(adev, parms);
-   audio_extn_passthru_set_parameters(adev, parms);
-   audio_extn_ext_disp_set_parameters(adev, parms);
-   audio_extn_qaf_set_parameters(adev, parms);
-   if (adev->offload_effects_set_parameters != NULL)
-       adev->offload_effects_set_parameters(parms);
-   audio_extn_set_aptx_dec_bt_addr(adev, parms);
-   audio_extn_ffv_set_parameters(adev, parms);
-   audio_extn_ext_hw_plugin_set_parameters(adev->ext_hw_plugin, parms);
-}
-
-void audio_extn_get_parameters(const struct audio_device *adev,
-                              struct str_parms *query,
-                              struct str_parms *reply)
-{
-    char *kv_pairs = NULL;
-    audio_extn_get_afe_proxy_parameters(adev, query, reply);
-    audio_extn_get_fluence_parameters(adev, query, reply);
-    audio_extn_ssr_get_parameters(adev, query, reply);
-    get_active_offload_usecases(adev, query, reply);
-    audio_extn_dts_eagle_get_parameters(adev, query, reply);
-    audio_extn_hpx_get_parameters(query, reply);
-    audio_extn_source_track_get_parameters(adev, query, reply);
-    audio_extn_fbsp_get_parameters(query, reply);
-    audio_extn_sound_trigger_get_parameters(adev, query, reply);
-    audio_extn_fm_get_parameters(query, reply);
-    if (adev->offload_effects_get_parameters != NULL)
-        adev->offload_effects_get_parameters(query, reply);
-    audio_extn_ext_hw_plugin_get_parameters(adev->ext_hw_plugin, query, reply);
-
-    kv_pairs = str_parms_to_str(reply);
-    ALOGD_IF(kv_pairs != NULL, "%s: returns %s", __func__, kv_pairs);
-    free(kv_pairs);
-}
-
-#ifndef COMPRESS_METADATA_NEEDED
-#define audio_extn_parse_compress_metadata(out, parms) (0)
-#else
 int audio_extn_parse_compress_metadata(struct stream_out *out,
                                        struct str_parms *parms)
 {
     int ret = 0;
     char value[32];
 
+    if (!if_compress_meta_data_feature_enabled()) {
+        return ret;
+    }
+
     if (out->format == AUDIO_FORMAT_FLAC) {
         ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE, value, sizeof(value));
         if (ret >= 0) {
@@ -1280,7 +2589,6 @@
 
     return ret;
 }
-#endif
 
 #ifdef AUXPCM_BT_ENABLED
 int32_t audio_extn_read_xml(struct audio_device *adev, uint32_t mixer_card,
@@ -1310,85 +2618,6 @@
 }
 #endif /* AUXPCM_BT_ENABLED */
 
-#ifdef KPI_OPTIMIZE_ENABLED
-typedef int (*perf_lock_acquire_t)(int, int, int*, int);
-typedef int (*perf_lock_release_t)(int);
-
-static void *qcopt_handle;
-static perf_lock_acquire_t perf_lock_acq;
-static perf_lock_release_t perf_lock_rel;
-
-char opt_lib_path[512] = {0};
-
-int audio_extn_perf_lock_init(void)
-{
-    int ret = 0;
-    if (qcopt_handle == NULL) {
-        if (property_get("ro.vendor.extension_library",
-                         opt_lib_path, NULL) <= 0) {
-            ALOGE("%s: Failed getting perf property \n", __func__);
-            ret = -EINVAL;
-            goto err;
-        }
-        if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) {
-            ALOGE("%s: Failed to open perf handle \n", __func__);
-            ret = -EINVAL;
-            goto err;
-        } else {
-            perf_lock_acq = (perf_lock_acquire_t)dlsym(qcopt_handle,
-                                                       "perf_lock_acq");
-            if (perf_lock_acq == NULL) {
-                ALOGE("%s: Perf lock Acquire NULL \n", __func__);
-                dlclose(qcopt_handle);
-                ret = -EINVAL;
-                goto err;
-            }
-            perf_lock_rel = (perf_lock_release_t)dlsym(qcopt_handle,
-                                                       "perf_lock_rel");
-            if (perf_lock_rel == NULL) {
-                ALOGE("%s: Perf lock Release NULL \n", __func__);
-                dlclose(qcopt_handle);
-                ret = -EINVAL;
-                goto err;
-            }
-            ALOGE("%s: Perf lock handles Success \n", __func__);
-        }
-    }
-err:
-    return ret;
-}
-
-void audio_extn_perf_lock_acquire(int *handle, int duration,
-                                 int *perf_lock_opts, int size)
-{
-
-    if (!perf_lock_opts || !size || !perf_lock_acq || !handle) {
-        ALOGE("%s: Incorrect params, Failed to acquire perf lock, err ",
-              __func__);
-        return;
-    }
-    /*
-     * Acquire performance lock for 1 sec during device path bringup.
-     * Lock will be released either after 1 sec or when perf_lock_release
-     * function is executed.
-     */
-    *handle = perf_lock_acq(*handle, duration, perf_lock_opts, size);
-    if (*handle <= 0)
-        ALOGE("%s: Failed to acquire perf lock, err: %d\n",
-              __func__, *handle);
-}
-
-void audio_extn_perf_lock_release(int *handle)
-{
-    if (perf_lock_rel && handle && (*handle > 0)) {
-        perf_lock_rel(*handle);
-        *handle = 0;
-    } else {
-        ALOGE("%s: Perf lock release error \n", __func__);
-    }
-}
-#endif /* KPI_OPTIMIZE_ENABLED */
-
 static int audio_extn_set_multichannel_mask(struct audio_device *adev,
                                             struct stream_in *in,
                                             struct audio_config *config,
@@ -1697,22 +2926,904 @@
     return 0;
 }
 
-// TODO: remove after ext spkr file added
-void *audio_extn_extspk_init(struct audio_device *adev __unused)
+//START: FM_POWER_OPT_FEATURE ================================================================
+void fm_feature_init(bool is_feature_enabled)
 {
-    return NULL;
+    audio_extn_fm_power_opt_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature FM_POWER_OPT is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
 }
-void audio_extn_extspk_deinit(void *extn __unused)
+
+
+void audio_extn_fm_get_parameters(struct str_parms *query, struct str_parms *reply)
 {
+    if(audio_extn_fm_power_opt_enabled)
+        fm_get_parameters(query, reply);
 }
-void audio_extn_extspk_update(void* extn __unused)
+
+void audio_extn_fm_set_parameters(struct audio_device *adev,
+                                  struct str_parms *parms)
 {
+    if(audio_extn_fm_power_opt_enabled)
+        fm_set_parameters(adev, parms);
 }
-void audio_extn_extspk_set_mode(void* extn __unused,
-                                audio_mode_t mode __unused)
+//END: FM_POWER_OPT_FEATURE ================================================================
+
+//START: HDMI_EDID =========================================================================
+#ifdef __LP64__
+#define HDMI_EDID_LIB_PATH  "/vendor/lib64/libhdmiedid.so"
+#else
+#define HDMI_EDID_LIB_PATH  "/vendor/lib/libhdmiedid.so"
+#endif
+
+static void *hdmi_edid_lib_handle = NULL;
+
+typedef bool (*hdmi_edid_is_supported_sr_t)(edid_audio_info*, int);
+static hdmi_edid_is_supported_sr_t hdmi_edid_is_supported_sr;
+
+typedef bool (*hdmi_edid_is_supported_bps_t)(edid_audio_info*, int);
+static hdmi_edid_is_supported_bps_t hdmi_edid_is_supported_bps;
+
+typedef int (*hdmi_edid_get_highest_supported_sr_t)(edid_audio_info*);
+static hdmi_edid_get_highest_supported_sr_t hdmi_edid_get_highest_supported_sr;
+
+typedef bool (*hdmi_edid_get_sink_caps_t)(edid_audio_info*, char*);
+static hdmi_edid_get_sink_caps_t hdmi_edid_get_sink_caps;
+
+void hdmi_edid_feature_init(bool is_feature_enabled)
 {
+    ALOGD("%s: HDMI_EDID feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
+    if (is_feature_enabled) {
+        //dlopen lib
+        hdmi_edid_lib_handle = dlopen(HDMI_EDID_LIB_PATH, RTLD_NOW);
+        if (hdmi_edid_lib_handle == NULL) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        //map each function
+        //on any faliure to map any function, disble feature
+        if (((hdmi_edid_is_supported_sr =
+             (hdmi_edid_is_supported_sr_t)dlsym(hdmi_edid_lib_handle, 
+                                                "edid_is_supported_sr")) == NULL) ||
+            ((hdmi_edid_is_supported_bps =
+             (hdmi_edid_is_supported_bps_t)dlsym(hdmi_edid_lib_handle,
+                                                "edid_is_supported_bps")) == NULL) ||
+            ((hdmi_edid_get_highest_supported_sr =
+             (hdmi_edid_get_highest_supported_sr_t)dlsym(hdmi_edid_lib_handle, 
+                                                "edid_get_highest_supported_sr")) == NULL) ||
+            ((hdmi_edid_get_sink_caps =
+             (hdmi_edid_get_sink_caps_t)dlsym(hdmi_edid_lib_handle, 
+                                                "edid_get_sink_caps")) == NULL)) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        ALOGD("%s:: ---- Feature HDMI_EDID is Enabled ----", __func__);
+        return;
+    }
+
+feature_disabled:
+    if (hdmi_edid_lib_handle) {
+        dlclose(hdmi_edid_lib_handle);
+        hdmi_edid_lib_handle = NULL;
+    }
+
+    hdmi_edid_is_supported_sr = NULL;
+    hdmi_edid_is_supported_bps = NULL;
+    hdmi_edid_get_highest_supported_sr = NULL;
+    hdmi_edid_get_sink_caps = NULL;
+    ALOGW(":: %s: ---- Feature HDMI_EDID is disabled ----", __func__);
+    return;
 }
-void audio_extn_extspk_set_voice_vol(void* extn __unused,
-                                     float vol __unused)
+
+bool audio_extn_edid_is_supported_sr(edid_audio_info* info, int sr)
 {
+    bool ret = false;
+
+    if(hdmi_edid_is_supported_sr != NULL)
+        ret = hdmi_edid_is_supported_sr(info, sr);
+    return ret;
+}
+
+bool audio_extn_edid_is_supported_bps(edid_audio_info* info, int bps)
+{
+    bool ret = false;
+
+    if(hdmi_edid_is_supported_bps != NULL)
+        ret = hdmi_edid_is_supported_bps(info, bps);
+    return ret;
+}
+int audio_extn_edid_get_highest_supported_sr(edid_audio_info* info)
+{
+    int ret = -1;
+
+    if(hdmi_edid_get_highest_supported_sr != NULL)
+        ret = hdmi_edid_get_highest_supported_sr(info);
+    return ret;
+}
+
+bool audio_extn_edid_get_sink_caps(edid_audio_info* info, char *edid_data)
+{
+    bool ret = false;
+
+    if(hdmi_edid_get_sink_caps != NULL)
+        ret = hdmi_edid_get_sink_caps(info, edid_data);
+    return ret;
+}
+
+//END: HDMI_EDID =========================================================================
+
+
+//START: KEEP_ALIVE =========================================================================
+
+void keep_alive_feature_init(bool is_feature_enabled)
+{
+    audio_extn_keep_alive_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature KEEP_ALIVE is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+void audio_extn_keep_alive_init(struct audio_device *adev)
+{
+    if(audio_extn_keep_alive_enabled)
+        keep_alive_init(adev);
+}
+
+void audio_extn_keep_alive_deinit()
+{
+    if(audio_extn_keep_alive_enabled)
+        keep_alive_deinit();
+}
+
+void audio_extn_keep_alive_start(ka_mode_t ka_mode)
+{
+    if(audio_extn_keep_alive_enabled)
+        keep_alive_start(ka_mode);
+}
+
+void audio_extn_keep_alive_stop(ka_mode_t ka_mode)
+{
+    if(audio_extn_keep_alive_enabled)
+        keep_alive_stop(ka_mode);
+}
+
+bool audio_extn_keep_alive_is_active()
+{
+    bool ret = false;
+    return ret;
+}
+
+int audio_extn_keep_alive_set_parameters(struct audio_device *adev,
+                                         struct str_parms *parms)
+{
+    int ret = -1;
+    if(audio_extn_keep_alive_enabled)
+        return keep_alive_set_parameters(adev, parms);
+    return ret;
+}
+//END: KEEP_ALIVE =========================================================================
+
+//START: HIFI_AUDIO =========================================================================
+void hifi_audio_feature_init(bool is_feature_enabled)
+{
+    audio_extn_hifi_audio_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature HIFI_AUDIO is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+bool audio_extn_is_hifi_audio_enabled(void)
+{
+    bool ret = false;
+    if(audio_extn_hifi_audio_enabled)
+    {
+        ALOGV("%s: status: %d", __func__, aextnmod.hifi_audio_enabled);
+        return (aextnmod.hifi_audio_enabled ? true: false);
+    }
+    return ret;
+}
+
+bool audio_extn_is_hifi_audio_supported(void)
+{
+    bool ret = false;
+
+    if(audio_extn_hifi_audio_enabled)
+    {
+        /*
+         * for internal codec, check for hifiaudio property to enable hifi audio
+         */
+        if (property_get_bool("persist.vendor.audio.hifi.int_codec", false))
+        {
+            ALOGD("%s: hifi audio supported on internal codec", __func__);
+            aextnmod.hifi_audio_enabled = 1;
+        }
+        return (aextnmod.hifi_audio_enabled ? true: false);
+    }
+    return ret;
+}
+
+//END: HIFI_AUDIO =========================================================================
+
+//START: RAS =============================================================================
+void ras_feature_init(bool is_feature_enabled)
+{
+    audio_extn_ras_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature RAS_FEATURE is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+bool audio_extn_is_ras_enabled(void)
+{
+    bool ret = false;
+
+    if(audio_extn_ras_feature_enabled)
+    {
+        ALOGD("%s: status: %d", __func__, aextnmod.ras_enabled);
+        return (aextnmod.ras_enabled ? true: false);
+    }
+    return ret;
+}
+
+bool audio_extn_can_use_ras(void)
+{
+    bool ret = false;
+
+    if(audio_extn_ras_feature_enabled)
+    {
+        if (property_get_bool("persist.vendor.audio.ras.enabled", false))
+            aextnmod.ras_enabled = 1;
+        ALOGD("%s: ras.enabled property is set to %d", __func__, aextnmod.ras_enabled);
+        return (aextnmod.ras_enabled ? true: false);
+    }
+    return ret;
+}
+
+//END: RAS ===============================================================================
+
+//START: KPI_OPTIMIZE =============================================================================
+void kpi_optimize_feature_init(bool is_feature_enabled)
+{
+    audio_extn_kpi_optimize_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature KPI_OPTIMIZE is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+typedef int (*perf_lock_acquire_t)(int, int, int*, int);
+typedef int (*perf_lock_release_t)(int);
+
+static void *qcopt_handle;
+static perf_lock_acquire_t perf_lock_acq;
+static perf_lock_release_t perf_lock_rel;
+
+char opt_lib_path[512] = {0};
+
+int audio_extn_perf_lock_init(void)
+{
+    int ret = 0;
+
+    //if feature is disabled, exit immediately
+    if(!audio_extn_kpi_optimize_feature_enabled)
+        goto err;
+
+    if (qcopt_handle == NULL) {
+        if (property_get("ro.vendor.extension_library",
+                         opt_lib_path, NULL) <= 0) {
+            ALOGE("%s: Failed getting perf property \n", __func__);
+            ret = -EINVAL;
+            goto err;
+        }
+        if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) {
+            ALOGE("%s: Failed to open perf handle \n", __func__);
+            ret = -EINVAL;
+            goto err;
+        } else {
+            perf_lock_acq = (perf_lock_acquire_t)dlsym(qcopt_handle,
+                                                       "perf_lock_acq");
+            if (perf_lock_acq == NULL) {
+                ALOGE("%s: Perf lock Acquire NULL \n", __func__);
+                dlclose(qcopt_handle);
+                ret = -EINVAL;
+                goto err;
+            }
+            perf_lock_rel = (perf_lock_release_t)dlsym(qcopt_handle,
+                                                       "perf_lock_rel");
+            if (perf_lock_rel == NULL) {
+                ALOGE("%s: Perf lock Release NULL \n", __func__);
+                dlclose(qcopt_handle);
+                ret = -EINVAL;
+                goto err;
+            }
+            ALOGE("%s: Perf lock handles Success \n", __func__);
+        }
+    }
+err:
+    return ret;
+}
+
+void audio_extn_perf_lock_acquire(int *handle, int duration,
+                                 int *perf_lock_opts, int size)
+{
+    if (audio_extn_kpi_optimize_feature_enabled)
+    {
+        if (!perf_lock_opts || !size || !perf_lock_acq || !handle) {
+            ALOGE("%s: Incorrect params, Failed to acquire perf lock, err ",
+                  __func__);
+            return;
+        }
+        /*
+         * Acquire performance lock for 1 sec during device path bringup.
+         * Lock will be released either after 1 sec or when perf_lock_release
+         * function is executed.
+         */
+        *handle = perf_lock_acq(*handle, duration, perf_lock_opts, size);
+        if (*handle <= 0)
+            ALOGE("%s: Failed to acquire perf lock, err: %d\n",
+                  __func__, *handle);
+    }
+}
+
+void audio_extn_perf_lock_release(int *handle)
+{
+    if (audio_extn_kpi_optimize_feature_enabled) {
+         if (perf_lock_rel && handle && (*handle > 0)) {
+            perf_lock_rel(*handle);
+            *handle = 0;
+        } else
+            ALOGE("%s: Perf lock release error \n", __func__);
+    }
+}
+
+//END: KPI_OPTIMIZE =============================================================================
+
+//START: DISPLAY_PORT =============================================================================
+void display_port_feature_init(bool is_feature_enabled)
+{
+    audio_extn_display_port_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature DISPLAY_PORT is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+bool audio_extn_is_display_port_enabled()
+{
+    return audio_extn_display_port_feature_enabled;
+}
+//END: DISPLAY_PORT ===============================================================================
+//START: FLUENCE =============================================================================
+void fluence_feature_init(bool is_feature_enabled)
+{
+    audio_extn_fluence_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature FLUENCE is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+bool audio_extn_is_fluence_enabled()
+{
+    return audio_extn_fluence_feature_enabled;
+}
+
+void audio_extn_set_fluence_parameters(struct audio_device *adev,
+                                            struct str_parms *parms)
+{
+    int ret = 0, err;
+    char value[32];
+    struct listnode *node;
+    struct audio_usecase *usecase;
+
+    if (audio_extn_is_fluence_enabled()) {
+        err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FLUENCE,
+                                 value, sizeof(value));
+        ALOGV_IF(err >= 0, "%s: Set Fluence Type to %s", __func__, value);
+        if (err >= 0) {
+            ret = platform_set_fluence_type(adev->platform, value);
+            if (ret != 0) {
+                ALOGE("platform_set_fluence_type returned error: %d", ret);
+            } else {
+                /*
+                 *If the fluence is manually set/reset, devices
+                 *need to get updated for all the usecases
+                 *i.e. audio and voice.
+                 */
+                 list_for_each(node, &adev->usecase_list) {
+                     usecase = node_to_item(node, struct audio_usecase, list);
+                     select_devices(adev, usecase->id);
+                 }
+            }
+        }
+
+    }
+}
+
+int audio_extn_get_fluence_parameters(const struct audio_device *adev,
+                       struct str_parms *query, struct str_parms *reply)
+{
+    int ret = -1, err;
+    char value[256] = {0};
+
+    if (audio_extn_is_fluence_enabled()) {
+        err = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE, value,
+                                                          sizeof(value));
+        if (err >= 0) {
+            ret = platform_get_fluence_type(adev->platform, value, sizeof(value));
+            if (ret >= 0) {
+                ALOGV("%s: Fluence Type is %s", __func__, value);
+                str_parms_add_str(reply, AUDIO_PARAMETER_KEY_FLUENCE, value);
+            } else
+                goto done;
+        }
+    }
+done:
+    return ret;
+}
+//END: FLUENCE ===============================================================================
+//START: CUSTOM_STEREO =============================================================================
+void custom_stereo_feature_init(bool is_feature_enabled)
+{
+    audio_extn_custom_stereo_feature_enabled = is_feature_enabled;
+    ALOGD(":: %s: ---- Feature CUSTOM_STEREO is %s ----", __func__, is_feature_enabled? "ENABLED": " NOT ENABLED");
+}
+
+bool audio_extn_is_custom_stereo_enabled()
+{
+    return audio_extn_custom_stereo_feature_enabled;
+}
+
+void audio_extn_customstereo_set_parameters(struct audio_device *adev,
+                                           struct str_parms *parms)
+{
+    int ret = 0;
+    char value[32]={0};
+    bool custom_stereo_state = false;
+    const char *mixer_ctl_name = "Set Custom Stereo OnOff";
+    struct mixer_ctl *ctl;
+
+    ALOGV("%s", __func__);
+
+    if (audio_extn_custom_stereo_feature_enabled) {
+        ret = str_parms_get_str(parms, AUDIO_PARAMETER_CUSTOM_STEREO, value,
+                            sizeof(value));
+        if (ret >= 0) {
+            if (!strncmp("true", value, sizeof("true")) || atoi(value))
+                custom_stereo_state = true;
+
+            if (custom_stereo_state == aextnmod.custom_stereo_enabled)
+                return;
+
+            ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+            if (!ctl) {
+                ALOGE("%s: Could not get ctl for mixer cmd - %s",
+                      __func__, mixer_ctl_name);
+                return;
+            }
+            if (mixer_ctl_set_value(ctl, 0, custom_stereo_state) < 0) {
+                ALOGE("%s: Could not set custom stereo state %d",
+                      __func__, custom_stereo_state);
+                return;
+            }
+            aextnmod.custom_stereo_enabled = custom_stereo_state;
+            ALOGV("%s: Setting custom stereo state success", __func__);
+        }
+    }
+}
+
+void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out)
+{
+    struct audio_device *adev = out->dev;
+    struct mixer_ctl *ctl;
+    char mixer_ctl_name[128];
+    int cust_ch_mixer_cfg[128], len = 0;
+    int ip_channel_cnt = audio_channel_count_from_out_mask(out->channel_mask);
+    int pcm_device_id = platform_get_pcm_device_id(out->usecase, PCM_PLAYBACK);
+    int op_channel_cnt= 2;
+    int i, j, err;
+
+    ALOGV("%s", __func__);
+
+    if (audio_extn_custom_stereo_feature_enabled) {
+        if (!out->started) {
+        out->set_dual_mono = true;
+        goto exit;
+        }
+
+        ALOGD("%s: i/p channel count %d, o/p channel count %d, pcm id %d", __func__,
+               ip_channel_cnt, op_channel_cnt, pcm_device_id);
+
+        snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
+                 "Audio Stream %d Channel Mix Cfg", pcm_device_id);
+        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+        if (!ctl) {
+            ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+            __func__, mixer_ctl_name);
+            goto exit;
+        }
+
+        /* Output channel count corresponds to backend configuration channels.
+         * Input channel count corresponds to ASM session channels.
+         * Set params is called with channels that need to be selected from
+         * input to generate output.
+         * ex: "8,2" to downmix from 8 to 2 i.e. to downmix from 8 to 2,
+         *
+         * This mixer control takes values in the following sequence:
+         * - input channel count(m)
+         * - output channel count(n)
+         * - weight coeff for [out ch#1, in ch#1]
+         * ....
+         * - weight coeff for [out ch#1, in ch#m]
+         *
+         * - weight coeff for [out ch#2, in ch#1]
+         * ....
+         * - weight coeff for [out ch#2, in ch#m]
+         *
+         * - weight coeff for [out ch#n, in ch#1]
+         * ....
+         * - weight coeff for [out ch#n, in ch#m]
+         *
+         * To get dualmono ouptu weightage coeff is calculated as Unity gain
+         * divided by number of input channels.
+         */
+        cust_ch_mixer_cfg[len++] = ip_channel_cnt;
+        cust_ch_mixer_cfg[len++] = op_channel_cnt;
+        for (i = 0; i < op_channel_cnt; i++) {
+             for (j = 0; j < ip_channel_cnt; j++) {
+                  cust_ch_mixer_cfg[len++] = Q14_GAIN_UNITY/ip_channel_cnt;
+             }
+        }
+
+        err = mixer_ctl_set_array(ctl, cust_ch_mixer_cfg, len);
+        if (err)
+            ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
+
+    }
+exit:
+    return;
+}
+//END: CUSTOM_STEREO =============================================================================
+// START: A2DP_OFFLOAD ===================================================================
+#ifdef __LP64__
+#define A2DP_OFFLOAD_LIB_PATH "/vendor/lib64/liba2dpoffload.so"
+#else
+#define A2DP_OFFLOAD_LIB_PATH "/vendor/lib/liba2dpoffload.so"
+#endif
+
+static void *a2dp_lib_handle = NULL;
+
+typedef void (*a2dp_init_t)(void *, a2dp_offload_init_config_t *);
+static a2dp_init_t a2dp_init;
+
+typedef int (*a2dp_start_playback_t)();
+static a2dp_start_playback_t a2dp_start_playback;
+
+typedef int (*a2dp_stop_playback_t)();
+static a2dp_stop_playback_t a2dp_stop_playback;
+
+typedef int (*a2dp_set_parameters_t)(struct str_parms *,
+                                     bool *);
+static a2dp_set_parameters_t a2dp_set_parameters;
+
+typedef int (*a2dp_get_parameters_t)(struct str_parms *,
+                                   struct str_parms *);
+static a2dp_get_parameters_t a2dp_get_parameters;
+
+typedef bool (*a2dp_is_force_device_switch_t)();
+static a2dp_is_force_device_switch_t a2dp_is_force_device_switch;
+
+typedef void (*a2dp_set_handoff_mode_t)(bool);
+static a2dp_set_handoff_mode_t a2dp_set_handoff_mode;
+
+typedef void (*a2dp_get_enc_sample_rate_t)(int *);
+static a2dp_get_enc_sample_rate_t a2dp_get_enc_sample_rate;
+
+typedef void (*a2dp_get_dec_sample_rate_t)(int *);
+static a2dp_get_dec_sample_rate_t a2dp_get_dec_sample_rate;
+
+typedef uint32_t (*a2dp_get_encoder_latency_t)();
+static a2dp_get_encoder_latency_t a2dp_get_encoder_latency;
+
+typedef bool (*a2dp_sink_is_ready_t)();
+static a2dp_sink_is_ready_t a2dp_sink_is_ready;
+
+typedef bool (*a2dp_source_is_ready_t)();
+static a2dp_source_is_ready_t a2dp_source_is_ready;
+
+typedef bool (*a2dp_source_is_suspended_t)();
+static a2dp_source_is_suspended_t a2dp_source_is_suspended;
+
+typedef int (*a2dp_start_capture_t)();
+static a2dp_start_capture_t a2dp_start_capture;
+
+typedef int (*a2dp_stop_capture_t)();
+static a2dp_stop_capture_t a2dp_stop_capture;
+
+int a2dp_offload_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__,
+                  is_feature_enabled ? "Enabled" : "NOT Enabled");
+    if (is_feature_enabled) {
+        // dlopen lib
+        a2dp_lib_handle = dlopen(A2DP_OFFLOAD_LIB_PATH, RTLD_NOW);
+
+        if (!a2dp_lib_handle) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+
+        if (!(a2dp_init = (a2dp_init_t)dlsym(a2dp_lib_handle, "a2dp_init")) ||
+            !(a2dp_start_playback =
+                 (a2dp_start_playback_t)dlsym(a2dp_lib_handle, "a2dp_start_playback")) ||
+            !(a2dp_stop_playback =
+                 (a2dp_stop_playback_t)dlsym(a2dp_lib_handle, "a2dp_stop_playback")) ||
+            !(a2dp_set_parameters =
+                 (a2dp_set_parameters_t)dlsym(a2dp_lib_handle, "a2dp_set_parameters")) ||
+            !(a2dp_get_parameters =
+                 (a2dp_get_parameters_t)dlsym(a2dp_lib_handle, "a2dp_get_parameters")) ||
+            !(a2dp_is_force_device_switch =
+                 (a2dp_is_force_device_switch_t)dlsym(
+                                    a2dp_lib_handle, "a2dp_is_force_device_switch")) ||
+            !(a2dp_set_handoff_mode =
+                 (a2dp_set_handoff_mode_t)dlsym(
+                                          a2dp_lib_handle, "a2dp_set_handoff_mode")) ||
+            !(a2dp_get_enc_sample_rate =
+                 (a2dp_get_enc_sample_rate_t)dlsym(
+                                       a2dp_lib_handle, "a2dp_get_enc_sample_rate")) ||
+            !(a2dp_get_dec_sample_rate =
+                 (a2dp_get_dec_sample_rate_t)dlsym(
+                                       a2dp_lib_handle, "a2dp_get_dec_sample_rate")) ||
+            !(a2dp_get_encoder_latency =
+                 (a2dp_get_encoder_latency_t)dlsym(
+                                       a2dp_lib_handle, "a2dp_get_encoder_latency")) ||
+            !(a2dp_sink_is_ready =
+                 (a2dp_sink_is_ready_t)dlsym(a2dp_lib_handle, "a2dp_sink_is_ready")) ||
+            !(a2dp_source_is_ready =
+                 (a2dp_source_is_ready_t)dlsym(a2dp_lib_handle, "a2dp_source_is_ready")) ||
+            !(a2dp_source_is_suspended =
+                 (a2dp_source_is_suspended_t)dlsym(
+                                       a2dp_lib_handle, "a2dp_source_is_suspended")) ||
+            !(a2dp_start_capture =
+                 (a2dp_start_capture_t)dlsym(a2dp_lib_handle, "a2dp_start_capture")) ||
+            !(a2dp_stop_capture =
+                 (a2dp_stop_capture_t)dlsym(a2dp_lib_handle, "a2dp_stop_capture"))) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+        ALOGD("%s:: ---- Feature A2DP_OFFLOAD is Enabled ----", __func__);
+        return 0;
+    }
+
+feature_disabled:
+    if (a2dp_lib_handle) {
+        dlclose(a2dp_lib_handle);
+        a2dp_lib_handle = NULL;
+    }
+
+    a2dp_init = NULL;
+    a2dp_start_playback= NULL;
+    a2dp_stop_playback = NULL;
+    a2dp_set_parameters = NULL;
+    a2dp_get_parameters = NULL;
+    a2dp_is_force_device_switch = NULL;
+    a2dp_set_handoff_mode = NULL;
+    a2dp_get_enc_sample_rate = NULL;
+    a2dp_get_dec_sample_rate = NULL;
+    a2dp_get_encoder_latency = NULL;
+    a2dp_sink_is_ready = NULL;
+    a2dp_source_is_ready = NULL;
+    a2dp_source_is_suspended = NULL;
+    a2dp_start_capture = NULL;
+    a2dp_stop_capture = NULL;
+
+    ALOGW(":: %s: ---- Feature A2DP_OFFLOAD is disabled ----", __func__);
+    return -ENOSYS;
+}
+
+void audio_extn_a2dp_init(void *adev)
+{
+    if (a2dp_init) {
+        a2dp_offload_init_config_t *a2dp_init_config = NULL;
+        a2dp_init_config->fp_platform_get_pcm_device_id = platform_get_pcm_device_id;
+        a2dp_init_config->fp_check_a2dp_restore = check_a2dp_restore;
+
+        a2dp_init(adev, a2dp_init_config);
+    }
+}
+
+int audio_extn_a2dp_start_playback()
+{
+    return (a2dp_start_playback ? a2dp_start_playback() : 0);
+}
+
+int audio_extn_a2dp_stop_playback()
+{
+    return (a2dp_stop_playback ? a2dp_stop_playback() : 0);
+}
+
+int audio_extn_a2dp_set_parameters(struct str_parms *parms,
+                                   bool *reconfig)
+{
+    return (a2dp_set_parameters ?
+                    a2dp_set_parameters(parms, reconfig) : 0);
+}
+
+int audio_extn_a2dp_get_parameters(struct str_parms *query,
+                                   struct str_parms *reply)
+{
+    return (a2dp_get_parameters ?
+                    a2dp_get_parameters(query, reply) : 0);
+}
+
+bool audio_extn_a2dp_is_force_device_switch()
+{
+    return (a2dp_is_force_device_switch ?
+                a2dp_is_force_device_switch() : false);
+}
+
+void audio_extn_a2dp_set_handoff_mode(bool is_on)
+{
+    if (a2dp_set_handoff_mode)
+        a2dp_set_handoff_mode(is_on);
+}
+
+void audio_extn_a2dp_get_enc_sample_rate(int *sample_rate)
+{
+    if (a2dp_get_enc_sample_rate)
+        a2dp_get_enc_sample_rate(sample_rate);
+}
+
+void audio_extn_a2dp_get_dec_sample_rate(int *sample_rate)
+{
+    if (a2dp_get_dec_sample_rate)
+        a2dp_get_dec_sample_rate(sample_rate);
+}
+
+uint32_t audio_extn_a2dp_get_encoder_latency()
+{
+    return (a2dp_get_encoder_latency ?
+                a2dp_get_encoder_latency() : 0);
+}
+
+bool audio_extn_a2dp_sink_is_ready()
+{
+    return (a2dp_sink_is_ready ?
+                a2dp_sink_is_ready() : false);
+}
+
+bool audio_extn_a2dp_source_is_ready()
+{
+    return (a2dp_source_is_ready ?
+                a2dp_source_is_ready() : false);
+}
+
+bool audio_extn_a2dp_source_is_suspended()
+{
+    return (a2dp_source_is_suspended ?
+                a2dp_source_is_suspended() : false);
+}
+
+int audio_extn_a2dp_start_capture()
+{
+    return (a2dp_start_capture ? a2dp_start_capture() : 0);
+}
+
+int audio_extn_a2dp_stop_capture()
+{
+    return (a2dp_stop_capture ? a2dp_stop_capture() : 0);
+}
+
+// END: A2DP_OFFLOAD =====================================================================
+void audio_extn_feature_init()
+{
+    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);
+            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 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;
+            default:
+                break;
+        }
+    }
+}
+
+void audio_extn_set_parameters(struct audio_device *adev,
+                               struct str_parms *parms)
+{
+   bool a2dp_reconfig = false;
+
+   audio_extn_set_aanc_noise_level(adev, parms);
+   audio_extn_set_anc_parameters(adev, parms);
+   audio_extn_set_fluence_parameters(adev, parms);
+   audio_extn_set_afe_proxy_parameters(adev, parms);
+   audio_extn_fm_set_parameters(adev, parms);
+   audio_extn_sound_trigger_set_parameters(adev, parms);
+   audio_extn_listen_set_parameters(adev, parms);
+   audio_extn_ssr_set_parameters(adev, parms);
+   audio_extn_hfp_set_parameters(adev, parms);
+   audio_extn_dts_eagle_set_parameters(adev, parms);
+   audio_extn_a2dp_set_parameters(parms, &a2dp_reconfig);
+   audio_extn_ddp_set_parameters(adev, parms);
+   audio_extn_ds2_set_parameters(adev, parms);
+   audio_extn_customstereo_set_parameters(adev, parms);
+   audio_extn_hpx_set_parameters(adev, parms);
+   audio_extn_pm_set_parameters(parms);
+   audio_extn_source_track_set_parameters(adev, parms);
+   audio_extn_fbsp_set_parameters(parms);
+   audio_extn_keep_alive_set_parameters(adev, parms);
+   audio_extn_passthru_set_parameters(adev, parms);
+   audio_extn_ext_disp_set_parameters(adev, parms);
+   audio_extn_qaf_set_parameters(adev, parms);
+   if (adev->offload_effects_set_parameters != NULL)
+       adev->offload_effects_set_parameters(parms);
+   audio_extn_set_aptx_dec_bt_addr(adev, parms);
+   audio_extn_ffv_set_parameters(adev, parms);
+   audio_extn_ext_hw_plugin_set_parameters(adev->ext_hw_plugin, parms);
+}
+
+void audio_extn_get_parameters(const struct audio_device *adev,
+                              struct str_parms *query,
+                              struct str_parms *reply)
+{
+    char *kv_pairs = NULL;
+    audio_extn_get_afe_proxy_parameters(adev, query, reply);
+    audio_extn_get_fluence_parameters(adev, query, reply);
+    audio_extn_ssr_get_parameters(adev, query, reply);
+    get_active_offload_usecases(adev, query, reply);
+    audio_extn_dts_eagle_get_parameters(adev, query, reply);
+    audio_extn_hpx_get_parameters(query, reply);
+    audio_extn_source_track_get_parameters(adev, query, reply);
+    audio_extn_fbsp_get_parameters(query, reply);
+    audio_extn_sound_trigger_get_parameters(adev, query, reply);
+    audio_extn_fm_get_parameters(query, reply);
+    if (adev->offload_effects_get_parameters != NULL)
+        adev->offload_effects_get_parameters(query, reply);
+    audio_extn_ext_hw_plugin_get_parameters(adev->ext_hw_plugin, query, reply);
+
+    kv_pairs = str_parms_to_str(reply);
+    ALOGD_IF(kv_pairs != NULL, "%s: returns %s", __func__, kv_pairs);
+    free(kv_pairs);
 }
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 92cd4a3..928bd2c 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -42,13 +42,12 @@
 #include "adsp_hdlr.h"
 #include "ip_hdlr_intf.h"
 #include "battery_listener.h"
+#include "platform_api.h"
+#include "edid.h"
+
 
 #define AUDIO_PARAMETER_DUAL_MONO  "dual_mono"
 
-#ifndef AFE_PROXY_ENABLED
-#define AUDIO_DEVICE_OUT_PROXY 0x40000
-#endif
-
 #ifndef AUDIO_DEVICE_IN_PROXY
 #define AUDIO_DEVICE_IN_PROXY (AUDIO_DEVICE_BIT_IN | 0x1000000)
 #endif
@@ -65,6 +64,8 @@
 #define AUDIO_DEVICE_OUT_FM_TX 0x8000000
 #endif
 
+#if 0
+// these formats should have been enabled by default now
 #ifndef FLAC_OFFLOAD_ENABLED
 #define AUDIO_FORMAT_FLAC 0x1B000000UL
 #endif
@@ -91,6 +92,7 @@
 #define AUDIO_FORMAT_AAC_ADTS_HE_V2  (AUDIO_FORMAT_AAC_ADTS |\
                                       AUDIO_FORMAT_AAC_SUB_HE_V2)
 #endif
+#endif
 
 #ifndef AUDIO_FORMAT_AAC_LATM
 #define AUDIO_FORMAT_AAC_LATM 0x80000000UL
@@ -130,12 +132,8 @@
 #define AUDIO_OUTPUT_FLAG_INTERACTIVE 0x4000000
 #endif
 
-#ifndef COMPRESS_METADATA_NEEDED
-#define audio_extn_parse_compress_metadata(out, parms) (0)
-#else
 int audio_extn_parse_compress_metadata(struct stream_out *out,
                                        struct str_parms *parms);
-#endif
 
 #ifdef AUDIO_EXTN_FORMATS_ENABLED
 #define AUDIO_OUTPUT_BIT_WIDTH ((config->offload_info.bit_width == 32) ? 24\
@@ -151,6 +149,107 @@
 #endif
 
 #define MAX_LENGTH_MIXER_CONTROL_IN_INT                  (128)
+#define HW_INFO_ARRAY_MAX_SIZE 32
+
+struct snd_card_split {
+    char device[HW_INFO_ARRAY_MAX_SIZE];
+    char snd_card[HW_INFO_ARRAY_MAX_SIZE];
+    char form_factor[HW_INFO_ARRAY_MAX_SIZE];
+};
+
+struct snd_card_split *audio_extn_get_snd_card_split();
+
+// -- function pointers needed for audio extn
+typedef void (*fp_platform_make_cal_cfg_t)(acdb_audio_cal_cfg_t *, int, int,
+                                         int, int, int, uint32_t, uint16_t,
+                                         uint32_t, bool);
+typedef int (*fp_platform_send_audio_cal_t)(void *, acdb_audio_cal_cfg_t *,
+                                            void *, int, bool);
+typedef int (*fp_platform_get_audio_cal_t)(void *, acdb_audio_cal_cfg_t *,
+                                           void *, int *, bool);
+typedef int (*fp_platform_store_audio_cal_t)(void *, acdb_audio_cal_cfg_t *,
+                                             void *, int);
+typedef int (*fp_platform_retrieve_audio_cal_t)(void *, acdb_audio_cal_cfg_t *,
+                                             void *, int *);
+
+typedef struct gef_init_config {
+    fp_platform_make_cal_cfg_t         fp_platform_make_cal_cfg;
+    fp_platform_send_audio_cal_t       fp_platform_send_audio_cal;
+    fp_platform_get_audio_cal_t        fp_platform_get_audio_cal;
+    fp_platform_store_audio_cal_t      fp_platform_store_audio_cal;
+    fp_platform_retrieve_audio_cal_t   fp_platform_retrieve_audio_cal;
+} gef_init_config_t;
+
+typedef int (*fp_read_line_from_file_t)(const char *, char *, size_t);
+typedef struct audio_usecase *(*fp_get_usecase_from_list_t)(const struct audio_device *,
+                                            audio_usecase_t);
+typedef int (*fp_enable_disable_snd_device_t)(struct audio_device *, snd_device_t);
+typedef int (*fp_enable_disable_audio_route_t)(struct audio_device *, struct audio_usecase *);
+typedef int (*fp_platform_set_snd_device_backend_t)(snd_device_t, const char *,
+                                    const char *);
+typedef int (*fp_platform_get_snd_device_name_extn_t)(void *platform, snd_device_t snd_device,
+                                      char *device_name);
+typedef int (*fp_platform_get_default_app_type_v2_t)(void *, usecase_type_t);
+typedef int (*fp_platform_send_audio_calibration_t)(void *, struct audio_usecase *,
+                                                   int, int);
+typedef int (*fp_platform_get_pcm_device_id_t)(audio_usecase_t, int);
+typedef const char *(*fp_platform_get_snd_device_name_t)(snd_device_t);
+typedef int (*fp_platform_spkr_prot_is_wsa_analog_mode_t)(void *);
+typedef int (*fp_platform_get_snd_device_t)(snd_device_t);
+typedef bool(*fp_platform_check_and_set_codec_backend_cfg_t)(struct audio_device*,
+                                      struct audio_usecase *, snd_device_t);
+
+typedef struct snd_card_split *(*fp_audio_extn_get_snd_card_split_t)();
+typedef bool (*fp_audio_extn_is_vbat_enabled_t)(void);
+
+struct spkr_prot_init_config {
+    fp_read_line_from_file_t                       fp_read_line_from_file;
+    fp_get_usecase_from_list_t                     fp_get_usecase_from_list;
+    fp_enable_disable_snd_device_t                 fp_disable_snd_device;
+    fp_enable_disable_snd_device_t                 fp_enable_snd_device;
+    fp_enable_disable_audio_route_t                fp_disable_audio_route;
+    fp_enable_disable_audio_route_t                fp_enable_audio_route;
+    fp_platform_set_snd_device_backend_t           fp_platform_set_snd_device_backend;
+    fp_platform_get_snd_device_name_extn_t         fp_platform_get_snd_device_name_extn;
+    fp_platform_get_default_app_type_v2_t          fp_platform_get_default_app_type_v2;
+    fp_platform_send_audio_calibration_t           fp_platform_send_audio_calibration;
+    fp_platform_get_pcm_device_id_t                fp_platform_get_pcm_device_id;
+    fp_platform_get_snd_device_name_t              fp_platform_get_snd_device_name;
+    fp_platform_spkr_prot_is_wsa_analog_mode_t     fp_platform_spkr_prot_is_wsa_analog_mode;
+    fp_platform_get_snd_device_t                   fp_platform_get_vi_feedback_snd_device;
+    fp_platform_get_snd_device_t                   fp_platform_get_spkr_prot_snd_device;
+    fp_platform_check_and_set_codec_backend_cfg_t  fp_platform_check_and_set_codec_backend_cfg;
+    fp_audio_extn_get_snd_card_split_t             fp_audio_extn_get_snd_card_split;
+    fp_audio_extn_is_vbat_enabled_t                fp_audio_extn_is_vbat_enabled;
+};
+
+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();
+//START: SND_MONITOR_FEATURE ===========================================
+void snd_mon_feature_init (bool is_feature_enabled);
+typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms);
+
+int audio_extn_snd_mon_init();
+int audio_extn_snd_mon_deinit();
+int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb);
+int audio_extn_snd_mon_unregister_listener(void *stream);
+//END: SND_MONITOR_FEATURE   ===========================================
+
+//START: EXTN_QDSP_PLUGIN    ===========================================
+
+void audio_extn_qdsp_init(void *platform);
+void audio_extn_qdsp_deinit();
+bool audio_extn_qdsp_set_state(struct audio_device *adev, int stream_type,
+                             float vol, bool active);
+void audio_extn_qdsp_set_device(struct audio_usecase *usecase);
+void audio_extn_qdsp_set_parameters(struct audio_device *adev,
+                                  struct str_parms *parms);
+bool audio_extn_qdsp_supported_usb();
+
+//END: EXTN_QDSP_PLUGIN      ===========================================
 
 void audio_extn_set_parameters(struct audio_device *adev,
                                struct str_parms *parms);
@@ -159,115 +258,35 @@
                                struct str_parms *query,
                                struct str_parms *reply);
 
-// TODO: remove once maxx audio file is added
-#ifndef MAXXAUDIO_QDSP_ENABLED
-#define audio_extn_ma_init(platform)                                (0)
-#define audio_extn_ma_deinit()                                      (0)
-#define audio_extn_ma_set_device(usecase)                           (0)
-#define audio_extn_ma_set_parameters(adev, param)                   (0)
-#define audio_extn_ma_supported_usb()                               (false)
-#else
-void audio_extn_ma_init(void *platform __unused)
-{
-}
-void audio_extn_ma_deinit()
-{
-}
-void audio_extn_ma_set_device(struct audio_usecase *usecase __unused)
-{
-}
-void audio_extn_ma_set_parameters(struct audio_device *adev __unused,
-                                  struct str_parms *parms __unused)
-{
-}
-bool audio_extn_ma_supported_usb()
-{
-    return false;
-}
-#endif
 
-#ifndef ANC_HEADSET_ENABLED
-#define audio_extn_get_anc_enabled()                     (0)
-#define audio_extn_should_use_fb_anc()                   (0)
-#define audio_extn_should_use_handset_anc(in_channels)   (0)
-#define audio_extn_set_aanc_noise_level(adev, parms)     (0)
-#else
 bool audio_extn_get_anc_enabled(void);
 bool audio_extn_should_use_fb_anc(void);
 bool audio_extn_should_use_handset_anc(int in_channels);
 void audio_extn_set_aanc_noise_level(struct audio_device *adev,
                                      struct str_parms *parms);
-#endif
 
-#ifndef VBAT_MONITOR_ENABLED
-#define audio_extn_is_vbat_enabled()                     (0)
-#define audio_extn_can_use_vbat()                        (0)
-#define audio_extn_is_bcl_enabled()                     (0)
-#define audio_extn_can_use_bcl()                        (0)
-#else
 bool audio_extn_is_vbat_enabled(void);
 bool audio_extn_can_use_vbat(void);
 bool audio_extn_is_bcl_enabled(void);
 bool audio_extn_can_use_bcl(void);
-#endif
 
-#ifndef RAS_ENABLED
-#define audio_extn_is_ras_enabled()                      (0)
-#define audio_extn_can_use_ras()                         (0)
-#else
+void ras_feature_init(bool is_feature_enabled);
 bool audio_extn_is_ras_enabled(void);
 bool audio_extn_can_use_ras(void);
-#endif
 
-#ifndef HIFI_AUDIO_ENABLED
-#define audio_extn_is_hifi_audio_enabled()               (0)
-#define audio_extn_is_hifi_audio_supported()             (0)
-#else
+
+bool audio_extn_is_hifi_audio_enabled(void);
 bool audio_extn_is_hifi_audio_enabled(void);
 bool audio_extn_is_hifi_audio_supported(void);
-#endif
 
-#ifndef FLUENCE_ENABLED
-#define audio_extn_set_fluence_parameters(adev, parms) (0)
-#define audio_extn_get_fluence_parameters(adev, query, reply) (0)
-#else
-void audio_extn_set_fluence_parameters(struct audio_device *adev,
-                                           struct str_parms *parms);
-int audio_extn_get_fluence_parameters(const struct audio_device *adev,
-                  struct str_parms *query, struct str_parms *reply);
-#endif
-
-#ifndef AFE_PROXY_ENABLED
-#define audio_extn_set_afe_proxy_channel_mixer(adev,channel_count)     (0)
-#define audio_extn_read_afe_proxy_channel_masks(out)                   (0)
-#define audio_extn_get_afe_proxy_channel_count()                       (0)
-#else
+//START: AFE_PROXY_FEATURE
 int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev,
-                                                    int channel_count);
+                                               int channel_count);
 int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out);
 int32_t audio_extn_get_afe_proxy_channel_count();
+//END: AFE_PROXY_FEATURE
 
-#endif
-
-#ifndef USB_TUNNEL_ENABLED
-#define audio_extn_usb_init(adev)                                      (0)
-#define audio_extn_usb_deinit()                                        (0)
-#define audio_extn_usb_add_device(device, card)                        (0)
-#define audio_extn_usb_remove_device(device, card)                     (0)
-#define audio_extn_usb_is_config_supported(bit_width, sample_rate, ch, pb) \
-                        (*bit_width=0, *sample_rate=0, *ch=0, 0)
-#define audio_extn_usb_enable_sidetone(device, enable)                 (0)
-#define audio_extn_usb_set_sidetone_gain(parms, value, len)            (0)
-#define audio_extn_usb_is_capture_supported()                          (0)
-#define audio_extn_usb_get_max_channels(p)                             (0)
-#define audio_extn_usb_get_max_bit_width(p)                            (0)
-#define audio_extn_usb_get_sup_sample_rates(t, s, l)                   (0)
-#define audio_extn_usb_is_tunnel_supported()                           (0)
-#define audio_extn_usb_alive(adev)                                     (false)
-#define audio_extn_usb_connected(parms)                                (0)
-#undef USB_BURST_MODE_ENABLED
-#undef USB_SIDETONE_VOLUME
-#else
+/// ---- USB feature ---------------------------------------------------------------
 void audio_extn_usb_init(void *adev);
 void audio_extn_usb_deinit();
 void audio_extn_usb_add_device(audio_devices_t device, int card);
@@ -286,17 +305,6 @@
 bool audio_extn_usb_is_tunnel_supported();
 bool audio_extn_usb_alive(int card);
 bool audio_extn_usb_connected(struct str_parms *parms);
-#endif
-
-#ifndef USB_BURST_MODE_ENABLED
-#define audio_extn_usb_find_service_interval(m, p)                     (0)
-#define audio_extn_usb_altset_for_service_interval(p, si, bw, sr, ch)  (-1)
-#define audio_extn_usb_set_service_interval(p, si, recfg)              (-1)
-#define audio_extn_usb_get_service_interval(p, si)                     (-1)
-#define audio_extn_usb_check_and_set_svc_int(uc,ss)                    (0)
-#define audio_extn_usb_is_reconfig_req()                               (0)
-#define audio_extn_usb_set_reconfig(isreq)                             (0)
-#else
 unsigned long audio_extn_usb_find_service_interval(bool min, bool playback);
 int audio_extn_usb_altset_for_service_interval(bool is_playback,
                                                unsigned long service_interval,
@@ -312,35 +320,11 @@
                                          bool starting_output_stream);
 bool audio_extn_usb_is_reconfig_req();
 void audio_extn_usb_set_reconfig(bool is_required);
-#endif
+bool audio_extn_usb_is_sidetone_volume_enabled();
+//------------------------------------------------------------------------------------
 
-#ifndef USB_SIDETONE_VOLUME
-#define audio_extn_usb_get_sidetone_volume(card_info)              (0)
-#define audio_extn_usb_set_sidetone_volume(card_info, en, i)       (0)
-#else
-void audio_extn_usb_get_sidetone_volume(struct usb_card_config *usb_card_info);
-void audio_extn_usb_set_sidetone_volume(struct usb_card_config *usb_card_info,
-                                        bool enable,
-                                        int index);
-#endif
-
-#ifndef A2DP_OFFLOAD_ENABLED
-#define audio_extn_a2dp_init(adev)                       (0)
-#define audio_extn_a2dp_start_playback()                 (0)
-#define audio_extn_a2dp_stop_playback()                  (0)
-#define audio_extn_a2dp_set_parameters(parms, reconfig)  (0)
-#define audio_extn_a2dp_get_parameters(query, reply)     (0)
-#define audio_extn_a2dp_is_force_device_switch()         (0)
-#define audio_extn_a2dp_set_handoff_mode(is_on)          (0)
-#define audio_extn_a2dp_get_enc_sample_rate(sample_rate) (0)
-#define audio_extn_a2dp_get_dec_sample_rate(sample_rate) (0)
-#define audio_extn_a2dp_get_encoder_latency()            (0)
-#define audio_extn_a2dp_sink_is_ready()                  (0)
-#define audio_extn_a2dp_source_is_ready()                (0)
-#define audio_extn_a2dp_source_is_suspended()            (0)
-#define audio_extn_a2dp_start_capture()                  (0)
-#define audio_extn_a2dp_stop_capture()                   (0)
-#else
+// START: A2DP_OFFLOAD FEATURE ==================================================
+int a2dp_offload_feature_init(bool is_feature_enabled);
 void audio_extn_a2dp_init(void *adev);
 int audio_extn_a2dp_start_playback();
 int audio_extn_a2dp_stop_playback();
@@ -357,20 +341,18 @@
 bool audio_extn_a2dp_source_is_suspended();
 int audio_extn_a2dp_start_capture();
 int audio_extn_a2dp_stop_capture();
-#endif
 
-#ifndef SSR_ENABLED
-#define audio_extn_ssr_check_usecase(in)                                  (0)
-#define audio_extn_ssr_set_usecase(in, config, channel_mask_updated)      (0)
-#define audio_extn_ssr_init(in, num_out_chan)                             (0)
-#define audio_extn_ssr_deinit()                                           (0)
-#define audio_extn_ssr_update_enabled()                                   (0)
-#define audio_extn_ssr_get_enabled()                                      (0)
-#define audio_extn_ssr_read(stream, buffer, bytes)                        (0)
-#define audio_extn_ssr_set_parameters(adev, parms)                        (0)
-#define audio_extn_ssr_get_parameters(adev, parms, reply)                 (0)
-#define audio_extn_ssr_get_stream()                                       (0)
-#else
+// --- Function pointers from audio_extn needed by A2DP_OFFLOAD
+typedef int (*fp_check_a2dp_restore_t)(struct audio_device *,
+                                       struct stream_out *, bool);
+struct a2dp_offload_init_config {
+    fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
+    fp_check_a2dp_restore_t fp_check_a2dp_restore;
+};
+typedef struct a2dp_offload_init_config a2dp_offload_init_config_t;
+// END: A2DP_OFFLOAD FEATURE ====================================================
+
+//START: SSRRC_FEATURE ==========================================================
 bool audio_extn_ssr_check_usecase(struct stream_in *in);
 int audio_extn_ssr_set_usecase(struct stream_in *in,
                                          struct audio_config *config,
@@ -388,7 +370,8 @@
                                    struct str_parms *query,
                                    struct str_parms *reply);
 struct stream_in *audio_extn_ssr_get_stream();
-#endif
+//END: SSREC_FEATURE ============================================================
+
 int audio_extn_check_and_set_multichannel_usecase(struct audio_device *adev,
                                                   struct stream_in *in,
                                                   struct audio_config *config,
@@ -479,13 +462,6 @@
 
 #define HW_INFO_ARRAY_MAX_SIZE 32
 
-struct snd_card_split {
-    char device[HW_INFO_ARRAY_MAX_SIZE];
-    char snd_card[HW_INFO_ARRAY_MAX_SIZE];
-    char form_factor[HW_INFO_ARRAY_MAX_SIZE];
-};
-
-struct snd_card_split *audio_extn_get_snd_card_split();
 void audio_extn_set_snd_card_split(const char* in_snd_card_name);
 void *audio_extn_extspk_init(struct audio_device *adev);
 void audio_extn_extspk_deinit(void *extn);
@@ -500,18 +476,7 @@
                             const char* mixer_xml_path,
                             const char* mixer_xml_path_auxpcm);
 #endif /* AUXPCM_BT_ENABLED */
-#ifndef SPKR_PROT_ENABLED
-#define audio_extn_spkr_prot_init(adev)       (0)
-#define audio_extn_spkr_prot_deinit()         (0)
-#define audio_extn_spkr_prot_start_processing(snd_device)    (-EINVAL)
-#define audio_extn_spkr_prot_calib_cancel(adev) (0)
-#define audio_extn_spkr_prot_stop_processing(snd_device)     (0)
-#define audio_extn_spkr_prot_is_enabled() (false)
-#define audio_extn_spkr_prot_set_parameters(parms, value, len)   (0)
-#define audio_extn_fbsp_set_parameters(parms)   (0)
-#define audio_extn_fbsp_get_parameters(query, reply)   (0)
-#define audio_extn_get_spkr_prot_snd_device(snd_device) (snd_device)
-#else
+
 void audio_extn_spkr_prot_init(void *adev);
 int audio_extn_spkr_prot_deinit();
 int audio_extn_spkr_prot_start_processing(snd_device_t snd_device);
@@ -524,17 +489,10 @@
 int audio_extn_fbsp_get_parameters(struct str_parms *query,
                                    struct str_parms *reply);
 int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device);
-#endif
 
-#ifndef COMPRESS_CAPTURE_ENABLED
-#define audio_extn_compr_cap_init(in)                     (0)
-#define audio_extn_compr_cap_enabled()                    (0)
-#define audio_extn_compr_cap_format_supported(format)     (0)
-#define audio_extn_compr_cap_usecase_supported(usecase)   (0)
-#define audio_extn_compr_cap_get_buffer_size(format)      (0)
-#define audio_extn_compr_cap_read(in, buffer, bytes)      (0)
-#define audio_extn_compr_cap_deinit()                     (0)
-#else
+
+// START: COMPRESS_CAPTURE FEATURE =========================
+void compr_cap_feature_init(bool is_feature_enabled);
 void audio_extn_compr_cap_init(struct stream_in *in);
 bool audio_extn_compr_cap_enabled();
 bool audio_extn_compr_cap_format_supported(audio_format_t format);
@@ -543,7 +501,7 @@
 size_t audio_extn_compr_cap_read(struct stream_in *in,
                                         void *buffer, size_t bytes);
 void audio_extn_compr_cap_deinit();
-#endif
+// END: COMPRESS_CAPTURE FEATURE =========================
 
 #ifndef DTS_EAGLE
 #define audio_extn_dts_eagle_set_parameters(adev, parms)     (0)
@@ -690,23 +648,20 @@
 int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state);
 #endif
 
-#ifndef DSM_FEEDBACK_ENABLED
-#define audio_extn_dsm_feedback_enable(adev, snd_device, benable)  (0)
-#else
+int audio_extn_utils_send_app_type_gain(struct audio_device *adev,
+                                        int app_type,
+                                        int *gain);
+
 void audio_extn_dsm_feedback_enable(struct audio_device *adev,
                          snd_device_t snd_device,
                          bool benable);
-#endif
+void dsm_feedback_feature_init (bool is_feature_enabled);
 
 int audio_extn_utils_send_app_type_gain(struct audio_device *adev,
                                         int app_type,
                                         int *gain);
 
-#ifndef HWDEP_CAL_ENABLED
-#define  audio_extn_hwdep_cal_send(snd_card, acdb_handle) (0)
-#else
 void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle);
-#endif
 
 #ifndef DEV_ARBI_ENABLED
 #define audio_extn_dev_arbi_init()                  (0)
@@ -838,17 +793,13 @@
 size_t audio_extn_utils_convert_format_24_8_to_8_24(void *buf, size_t bytes);
 int get_snd_codec_id(audio_format_t format);
 
-#ifndef KPI_OPTIMIZE_ENABLED
-#define audio_extn_perf_lock_init() (0)
-#define audio_extn_perf_lock_acquire(handle, duration, opts, size) (0)
-#define audio_extn_perf_lock_release(handle) (0)
-#else
+void kpi_optimize_feature_init(bool is_feature_enabled);
 int audio_extn_perf_lock_init(void);
 void audio_extn_perf_lock_acquire(int *handle, int duration,
                                  int *opts, int size);
 void audio_extn_perf_lock_release(int *handle);
 
-#endif /* KPI_OPTIMIZE_ENABLED */
+
 
 #ifndef AUDIO_EXTERNAL_HDMI_ENABLED
 #define audio_utils_set_hdmi_channel_status(out, buffer, bytes) (0)
@@ -909,14 +860,6 @@
 #define audio_extn_bt_hal_get_device(...)             NULL
 #endif
 
-#ifndef KEEP_ALIVE_ENABLED
-#define audio_extn_keep_alive_init(adev) do {} while(0)
-#define audio_extn_keep_alive_deinit() do {} while(0)
-#define audio_extn_keep_alive_start(ka_mode) do {} while(0)
-#define audio_extn_keep_alive_stop(ka_mode) do {} while(0)
-#define audio_extn_keep_alive_is_active() (false)
-#define audio_extn_keep_alive_set_parameters(adev, parms) (0)
-#else
 void audio_extn_keep_alive_init(struct audio_device *adev);
 void audio_extn_keep_alive_deinit();
 void audio_extn_keep_alive_start(ka_mode_t ka_mode);
@@ -924,7 +867,7 @@
 bool audio_extn_keep_alive_is_active();
 int audio_extn_keep_alive_set_parameters(struct audio_device *adev,
                                          struct str_parms *parms);
-#endif
+
 
 #ifndef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
 
@@ -993,19 +936,6 @@
 
 #endif /* AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED */
 
-typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms);
-#ifndef SND_MONITOR_ENABLED
-#define audio_extn_snd_mon_init()           (0)
-#define audio_extn_snd_mon_deinit()         (0)
-#define audio_extn_snd_mon_register_listener(stream, cb) (0)
-#define audio_extn_snd_mon_unregister_listener(stream) (0)
-#else
-int audio_extn_snd_mon_init();
-int audio_extn_snd_mon_deinit();
-int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb);
-int audio_extn_snd_mon_unregister_listener(void *stream);
-#endif
-
 #ifdef COMPRESS_INPUT_ENABLED
 bool audio_extn_cin_applicable_stream(struct stream_in *in);
 bool audio_extn_cin_attached_usecase(audio_usecase_t uc_id);
@@ -1029,42 +959,23 @@
 #define audio_extn_cin_configure_input_stream(in) (0)
 #endif
 
-#ifndef SOURCE_TRACKING_ENABLED
-static int __unused audio_extn_get_soundfocus_data(
-                                   const struct audio_device *adev __unused,
-                                   struct sound_focus_param *payload __unused)
-{
-    return -ENOSYS;
-}
-static int __unused audio_extn_get_sourcetrack_data(
-                                   const struct audio_device *adev __unused,
-                                   struct source_tracking_param *payload __unused)
-{
-    return -ENOSYS;
-}
-static int __unused audio_extn_set_soundfocus_data(
-                                   struct audio_device *adev __unused,
-                                   struct sound_focus_param *payload __unused)
-{
-    return -ENOSYS;
-}
-#else
+//START: SOURCE_TRACKING_FEATURE ==============================================
 int audio_extn_get_soundfocus_data(const struct audio_device *adev,
                                    struct sound_focus_param *payload);
 int audio_extn_get_sourcetrack_data(const struct audio_device *adev,
                                     struct source_tracking_param *payload);
 int audio_extn_set_soundfocus_data(struct audio_device *adev,
                                    struct sound_focus_param *payload);
-#endif
+void audio_extn_source_track_set_parameters(struct audio_device *adev,
+                                            struct str_parms *parms);
+void audio_extn_source_track_get_parameters(const struct audio_device *adev,
+                                            struct str_parms *query,
+                                            struct str_parms *reply);
+//END: SOURCE_TRACKING_FEATURE ================================================
 
-#ifndef FM_POWER_OPT
-#define audio_extn_fm_set_parameters(adev, parms) (0)
-#define audio_extn_fm_get_parameters(query, reply) (0)
-#else
 void audio_extn_fm_set_parameters(struct audio_device *adev,
                                    struct str_parms *parms);
 void audio_extn_fm_get_parameters(struct str_parms *query, struct str_parms *reply);
-#endif
 
 #ifndef APTX_DECODER_ENABLED
 #define audio_extn_aptx_dec_set_license(adev); (0)
@@ -1228,11 +1139,6 @@
 void audio_extn_ffv_append_ec_ref_dev_name(char *device_name);
 #endif
 
-#ifndef CUSTOM_STEREO_ENABLED
-#define audio_extn_send_dual_mono_mixing_coefficients(out) (0)
-#else
-void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out);
-#endif
 int audio_extn_utils_get_license_params(const struct audio_device *adev,  struct audio_license_params *lic_params);
 
 #ifndef EXT_HW_PLUGIN_ENABLED
@@ -1259,4 +1165,20 @@
 int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
             struct audio_usecase *usecase, uint32_t gain);
 #endif
+
+bool audio_extn_edid_is_supported_sr(edid_audio_info* info, int sr);
+bool audio_extn_edid_is_supported_bps(edid_audio_info* info, int bps);
+int audio_extn_edid_get_highest_supported_sr(edid_audio_info* info);
+bool audio_extn_edid_get_sink_caps(edid_audio_info* info, char *edid_data);
+
+bool audio_extn_is_display_port_enabled();
+
+bool audio_extn_is_fluence_enabled();
+void audio_extn_set_fluence_parameters(struct audio_device *adev,
+                                           struct str_parms *parms);
+int audio_extn_get_fluence_parameters(const struct audio_device *adev,
+                  struct str_parms *query, struct str_parms *reply);
+
+bool audio_extn_is_custom_stereo_enabled();
+void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out);
 #endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/audio_feature_manager.c b/hal/audio_extn/audio_feature_manager.c
new file mode 100644
index 0000000..a399800
--- /dev/null
+++ b/hal/audio_extn/audio_feature_manager.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_TAG "audio_feature_manager"
+/*#define LOG_NDEBUG 0*/
+#define LOG_NDDEBUG 0
+
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <cutils/properties.h>
+#include <log/log.h>
+#include <unistd.h>
+#include "audio_feature_manager.h"
+#include <cutils/str_parms.h>
+
+static bool feature_bit_map[MAX_SUPPORTED_FEATURE] = {0};
+
+static void set_default_feature_flags() {
+    ALOGI(":: %s: Enter", __func__);
+    feature_bit_map[SND_MONITOR] = true;
+}
+
+static void set_dynamic_feature_flags() {
+    ALOGI(":: %s: Enter", __func__);
+    // TBD: Dynamically init feature bit
+}
+
+static void set_feature_flags() {
+    ALOGI(":: %s: Enter", __func__);
+    set_default_feature_flags();
+    set_dynamic_feature_flags();
+}
+
+void audio_feature_manager_init() {
+    ALOGI(":: %s: Enter", __func__);
+    set_feature_flags();
+}
+
+bool audio_feature_manager_is_feature_enabled(audio_ext_feature feature) {
+    bool ret_val = false;
+
+    if (feature >= 0 && feature < MAX_SUPPORTED_FEATURE)
+        ret_val = feature_bit_map[feature];
+
+    return ret_val;
+}
diff --git a/hal/audio_extn/audio_feature_manager.h b/hal/audio_extn/audio_feature_manager.h
new file mode 100644
index 0000000..424dc4f
--- /dev/null
+++ b/hal/audio_extn/audio_feature_manager.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AUDIO_FEATURE_MANAGER_H
+#define AUDIO_FEATURE_MANAGER_H
+
+#include <cutils/str_parms.h>
+
+
+enum audio_ext_feature_t {
+    SND_MONITOR = 0,
+    COMPRESS_CAPTURE,
+    SOURCE_TRACK,
+    SSREC,
+    AUDIOSPHERE,
+    AFE_PROXY,
+    USE_DEEP_AS_PRIMARY_OUTPUT,
+    HDMI_EDID,
+    KEEP_ALIVE,
+    HIFI_AUDIO,
+    RECEIVER_AIDED_STEREO,
+    KPI_OPTIMIZE,
+    DISPLAY_PORT,
+    FLUENCE,
+    CUSTOM_STEREO,
+    ANC_HEADSET,
+    DSM_FEEDBACK,
+    USB_OFFLOAD,
+    USB_OFFLOAD_BURST_MODE,
+    USB_OFFLOAD_SIDETONE_VOLM,
+    A2DP_OFFLOAD,
+    VBAT,
+    COMPRESS_METADATA_NEEDED,
+    VOICE_START = COMPRESS_METADATA_NEEDED,
+    COMPRESS_VOIP,
+    DYNAMIC_ECNS,
+    MAX_SUPPORTED_FEATURE
+};
+
+typedef enum audio_ext_feature_t audio_ext_feature;
+
+void audio_feature_manager_init();
+bool audio_feature_manager_is_feature_enabled(audio_ext_feature feature);
+
+#endif /* AUDIO_FEATURE_MANAGER_H */
diff --git a/hal/audio_extn/cirrus_playback.c b/hal/audio_extn/cirrus_playback.c
index 25fe258..f1b46d9 100644
--- a/hal/audio_extn/cirrus_playback.c
+++ b/hal/audio_extn/cirrus_playback.c
@@ -37,6 +37,16 @@
 #include <cutils/properties.h>
 #include "audio_extn.h"
 
+// - external function dependency -
+static fp_platform_get_snd_device_name_t fp_platform_get_snd_device_name;
+static fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
+static fp_get_usecase_from_list_t fp_get_usecase_from_list;
+static fp_enable_disable_snd_device_t fp_disable_snd_device;
+static fp_enable_disable_snd_device_t  fp_enable_snd_device;
+static fp_enable_disable_audio_route_t fp_disable_audio_route;
+static fp_enable_disable_audio_route_t fp_enable_audio_route;
+static fp_audio_extn_get_snd_card_split_t fp_audio_extn_get_snd_card_split;
+
 struct cirrus_playback_session {
     void *adev_handle;
     pthread_mutex_t fb_prot_mutex;
@@ -130,19 +140,7 @@
 #define CRUS_SP_IOCTL_SET_CALIB _IOWR(CRUS_SP_IOCTL_MAGIC, 222, void *)
 
 
-
-static struct pcm_config pcm_config_cirrus_tx = {
-    .channels = 2,
-    .rate = 48000,
-    .period_size = 320,
-    .period_count = 4,
-    .format = PCM_FORMAT_S16_LE,
-    .start_threshold = 0,
-    .stop_threshold = INT_MAX,
-    .avail_min = 0,
-};
-
-static struct pcm_config pcm_config_cirrus_rx = {
+struct pcm_config pcm_config_cirrus_rx = {
     .channels = 8,
     .rate = 48000,
     .period_size = 320,
@@ -153,6 +151,17 @@
     .avail_min = 0,
 };
 
+struct pcm_config pcm_config_cirrus_tx = {
+    .channels = 2,
+    .rate = 48000,
+    .period_size = 320,
+    .period_count = 4,
+    .format = PCM_FORMAT_S16_LE,
+    .start_threshold = 0,
+    .stop_threshold = INT_MAX,
+    .avail_min = 0,
+};
+
 static struct cirrus_playback_session handle;
 
 #ifdef CIRRUS_FACTORY_CALIBRATION
@@ -165,7 +174,7 @@
 static void *audio_extn_cirrus_failure_detect_thread();
 #endif
 
-void audio_extn_spkr_prot_init(void *adev) {
+void spkr_prot_init(void *adev, spkr_prot_init_config_t spkr_prot_init_config_val) {
     ALOGI("%s: Initialize Cirrus Logic Playback module", __func__);
 
     memset(&handle, 0, sizeof(handle));
@@ -177,6 +186,16 @@
     handle.adev_handle = adev;
     handle.state = INIT;
 
+    // init function pointers
+    fp_platform_get_snd_device_name = spkr_prot_init_config_val.fp_platform_get_snd_device_name;
+    fp_platform_get_pcm_device_id = spkr_prot_init_config_val.fp_platform_get_pcm_device_id;
+    fp_get_usecase_from_list =  spkr_prot_init_config_val.fp_get_usecase_from_list;
+    fp_disable_snd_device = spkr_prot_init_config_val.fp_disable_snd_device;
+    fp_enable_snd_device = spkr_prot_init_config_val.fp_enable_snd_device;
+    fp_disable_audio_route = spkr_prot_init_config_val.fp_disable_audio_route;
+    fp_enable_audio_route = spkr_prot_init_config_val.fp_enable_audio_route;
+    fp_audio_extn_get_snd_card_split = spkr_prot_init_config_val.fp_audio_extn_get_snd_card_split;
+
     pthread_mutex_init(&handle.fb_prot_mutex, NULL);
 
 #ifdef CIRRUS_FACTORY_CALIBRATION
@@ -190,7 +209,7 @@
 #endif
 }
 
-void audio_extn_spkr_prot_deinit(void *adev __unused) {
+int spkr_prot_deinit() {
     ALOGV("%s: Entry", __func__);
 
 #ifdef ENABLE_CIRRUS_DETECTION
@@ -200,6 +219,7 @@
     pthread_mutex_destroy(&handle.fb_prot_mutex);
 
     ALOGV("%s: Exit", __func__);
+    return 0;
 }
 
 #ifdef CIRRUS_FACTORY_CALIBRATION
@@ -390,7 +410,8 @@
     char *filename = NULL;
     int ret = 0, default_uc = 0;
     struct snd_card_split *snd_split_handle = NULL;
-    snd_split_handle = audio_extn_get_snd_card_split();
+
+    snd_split_handle = fp_audio_extn_get_snd_card_split();
 
     ALOGI("%s: Loading usecase tuning configs", __func__);
 
@@ -487,9 +508,9 @@
     uc_info_rx->out_snd_device = SND_DEVICE_OUT_SPEAKER;
     list_add_tail(&adev->usecase_list, &uc_info_rx->list);
 
-    enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER);
-    enable_audio_route(adev, uc_info_rx);
-    pcm_dev_rx_id = platform_get_pcm_device_id(uc_info_rx->id, PCM_PLAYBACK);
+    fp_enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER);
+    fp_enable_audio_route(adev, uc_info_rx);
+    pcm_dev_rx_id = fp_platform_get_pcm_device_id(uc_info_rx->id, PCM_PLAYBACK);
 
     if (pcm_dev_rx_id < 0) {
         ALOGE("%s: Invalid pcm device for usecase (%d)",
@@ -530,8 +551,9 @@
         pcm_close(handle.pcm_rx);
         handle.pcm_rx = NULL;
     }
-    disable_audio_route(adev, uc_info_rx);
-    disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER);
+
+    fp_disable_audio_route(adev, uc_info_rx);
+    fp_disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER);
     list_remove(&uc_info_rx->list);
     free(uc_info_rx);
     pthread_mutex_unlock(&adev->lock);
@@ -798,7 +820,7 @@
 }
 #endif
 
-int audio_extn_spkr_prot_start_processing(snd_device_t snd_device) {
+int spkr_prot_start_processing(snd_device_t snd_device) {
     struct audio_usecase *uc_info_tx;
     struct audio_device *adev = handle.adev_handle;
     int32_t pcm_dev_tx_id = -1, ret = 0;
@@ -817,7 +839,7 @@
     }
 
     audio_route_apply_and_update_path(adev->audio_route,
-                                      platform_get_snd_device_name(snd_device));
+                                      fp_platform_get_snd_device_name(snd_device));
 
     pthread_mutex_lock(&handle.fb_prot_mutex);
     uc_info_tx->id = USECASE_AUDIO_SPKR_CALIB_TX;
@@ -828,10 +850,10 @@
 
     list_add_tail(&adev->usecase_list, &uc_info_tx->list);
 
-    enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
-    enable_audio_route(adev, uc_info_tx);
+    fp_enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
+    fp_enable_audio_route(adev, uc_info_tx);
 
-    pcm_dev_tx_id = platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
+    pcm_dev_tx_id = fp_platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
 
     if (pcm_dev_tx_id < 0) {
         ALOGE("%s: Invalid pcm device for usecase (%d)",
@@ -875,8 +897,8 @@
             handle.pcm_tx = NULL;
         }
 
-        disable_audio_route(adev, uc_info_tx);
-        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
+        fp_disable_audio_route(adev, uc_info_tx);
+        fp_disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
         list_remove(&uc_info_tx->list);
         free(uc_info_tx);
     }
@@ -886,7 +908,7 @@
     return ret;
 }
 
-void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device) {
+void spkr_prot_stop_processing(snd_device_t snd_device) {
     struct audio_usecase *uc_info_tx;
     struct audio_device *adev = handle.adev_handle;
 
@@ -895,7 +917,7 @@
     pthread_mutex_lock(&handle.fb_prot_mutex);
 
     handle.state = IDLE;
-    uc_info_tx = get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_TX);
+    uc_info_tx = fp_get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_TX);
 
     if (uc_info_tx) {
         if (handle.pcm_tx) {
@@ -904,13 +926,13 @@
             handle.pcm_tx = NULL;
         }
 
-        disable_audio_route(adev, uc_info_tx);
-        disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
+        fp_disable_audio_route(adev, uc_info_tx);
+        fp_disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
         list_remove(&uc_info_tx->list);
         free(uc_info_tx);
 
         audio_route_reset_path(adev->audio_route,
-                               platform_get_snd_device_name(snd_device));
+                               fp_platform_get_snd_device_name(snd_device));
     }
 
     pthread_mutex_unlock(&handle.fb_prot_mutex);
@@ -918,11 +940,11 @@
     ALOGV("%s: Exit", __func__);
 }
 
-bool audio_extn_spkr_prot_is_enabled() {
+bool spkr_prot_is_enabled() {
     return true;
 }
 
-int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device) {
+int get_spkr_prot_snd_device(snd_device_t snd_device) {
     switch(snd_device) {
     case SND_DEVICE_OUT_SPEAKER:
     case SND_DEVICE_OUT_SPEAKER_REVERSE:
@@ -936,6 +958,6 @@
     }
 }
 
-void audio_extn_spkr_prot_calib_cancel(__unused void *adev) {
+void spkr_prot_calib_cancel(__unused void *adev) {
     // FIXME: wait or cancel audio_extn_cirrus_run_calibration
 }
diff --git a/hal/audio_extn/compress_capture.c b/hal/audio_extn/compress_capture.c
index 671796c..f0aeec2 100644
--- a/hal/audio_extn/compress_capture.c
+++ b/hal/audio_extn/compress_capture.c
@@ -29,8 +29,8 @@
 #include <cutils/log.h>
 
 #include "audio_hw.h"
-#include "platform.h"
-#include "platform_api.h"
+//#include "platform.h"
+//#include "platform_api.h"
 
 #include "sound/compress_params.h"
 #include "sound/compress_offload.h"
@@ -57,7 +57,7 @@
 };
 
 
-void audio_extn_compr_cap_init(struct stream_in *in)
+void compr_cap_init(struct stream_in *in)
 {
     in->usecase = USECASE_AUDIO_RECORD_COMPRESS;
     in->config.channels = COMPRESS_IN_CONFIG_CHANNELS;
@@ -67,7 +67,7 @@
     c_in_mod.in_buf = (uint8_t*)calloc(1, in->config.period_size*2);
 }
 
-void audio_extn_compr_cap_deinit()
+void compr_cap_deinit()
 {
     if (c_in_mod.in_buf) {
         free(c_in_mod.in_buf);
@@ -75,7 +75,7 @@
     }
 }
 
-bool audio_extn_compr_cap_enabled()
+bool compr_cap_enabled()
 {
     char prop_value[PROPERTY_VALUE_MAX] = {0};
     bool tunnel_encode = false;
@@ -87,7 +87,7 @@
         return false;
 }
 
-bool audio_extn_compr_cap_format_supported(audio_format_t format)
+bool compr_cap_format_supported(audio_format_t format)
 {
     if (format == AUDIO_FORMAT_AMR_WB)
         return true;
@@ -96,7 +96,7 @@
 }
 
 
-bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase)
+bool compr_cap_usecase_supported(audio_usecase_t usecase)
 {
     if ((usecase == USECASE_AUDIO_RECORD_COMPRESS) ||
         (usecase == USECASE_INCALL_REC_UPLINK_COMPRESS) ||
@@ -108,7 +108,7 @@
 }
 
 
-size_t audio_extn_compr_cap_get_buffer_size(audio_format_t format)
+size_t compr_cap_get_buffer_size(audio_format_t format)
 {
     if (format == AUDIO_FORMAT_AMR_WB)
         /*One AMR WB frame is 61 bytes. Return that to the caller.
@@ -118,7 +118,7 @@
         return 0;
 }
 
-size_t audio_extn_compr_cap_read(struct stream_in * in,
+size_t compr_cap_read(struct stream_in * in,
     void *buffer, size_t bytes)
 {
     int ret;
diff --git a/hal/edid.c b/hal/audio_extn/edid.c
similarity index 100%
rename from hal/edid.c
rename to hal/audio_extn/edid.c
diff --git a/hal/edid.h b/hal/audio_extn/edid.h
similarity index 92%
rename from hal/edid.h
rename to hal/audio_extn/edid.h
index a7578e6..7c71ab4 100644
--- a/hal/edid.h
+++ b/hal/audio_extn/edid.h
@@ -113,30 +113,8 @@
     unsigned int  channel_mask;
 } edid_audio_info;
 
-#ifdef HDMI_EDID
 bool edid_is_supported_sr(edid_audio_info* info, int sr);
 bool edid_is_supported_bps(edid_audio_info* info, int bps);
 int edid_get_highest_supported_sr(edid_audio_info* info);
 bool edid_get_sink_caps(edid_audio_info* info, char *edid_data);
-#else
-static bool __unused edid_is_supported_sr(edid_audio_info* info __unused, int sr __unused)
-{
-    return false;
-}
-static bool __unused edid_is_supported_bps(edid_audio_info* info __unused, int bps __unused)
-{
-    return false;
-}
-
-static bool __unused edid_get_sink_caps(edid_audio_info* info __unused, char* edid_data __unused)
-{
-    return false;
-}
-
-static int __unused edid_get_highest_supported_sr(edid_audio_info* info __unused)
-{
-    return 0;
-}
-#endif
-
 #endif /* EDID_H */
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index d08d498..3c1ec68 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -38,7 +38,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef FM_POWER_OPT
 #define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
 #define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume"
 #define AUDIO_PARAMETER_KEY_REC_PLAY_CONC "rec_play_conc_on"
@@ -251,7 +250,7 @@
     return ret;
 }
 
-void audio_extn_fm_get_parameters(struct str_parms *query, struct str_parms *reply)
+void fm_get_parameters(struct str_parms *query, struct str_parms *reply)
 {
     int ret, val;
     char value[32]={0};
@@ -264,7 +263,7 @@
     }
 }
 
-void audio_extn_fm_set_parameters(struct audio_device *adev,
+void fm_set_parameters(struct audio_device *adev,
                                   struct str_parms *parms)
 {
     int ret, val;
@@ -387,4 +386,3 @@
 exit:
     ALOGV("%s: exit", __func__);
 }
-#endif /* FM_POWER_OPT end */
diff --git a/hal/audio_extn/keep_alive.c b/hal/audio_extn/keep_alive.c
index 90875d9..20214aa 100644
--- a/hal/audio_extn/keep_alive.c
+++ b/hal/audio_extn/keep_alive.c
@@ -37,6 +37,7 @@
 #include "audio_extn.h"
 #include "platform_api.h"
 #include <platform.h>
+#include <pthread.h>
 
 #ifdef DYNAMIC_LOG_ENABLED
 #include <log_xml_parser.h>
@@ -114,7 +115,7 @@
     pthread_cond_signal(&ka.cond);
 }
 
-void audio_extn_keep_alive_init(struct audio_device *adev)
+void keep_alive_init(struct audio_device *adev)
 {
     ka.userdata = adev;
     ka.state = STATE_IDLE;
@@ -146,7 +147,7 @@
     ALOGV("%s init done", __func__);
 }
 
-void audio_extn_keep_alive_deinit()
+void keep_alive_deinit()
 {
     if (ka.state == STATE_DEINIT || ka.state == STATE_DISABLED)
         return;
@@ -191,7 +192,7 @@
     return out_device;
 }
 
-void audio_extn_keep_alive_start(ka_mode_t ka_mode)
+void keep_alive_start(ka_mode_t ka_mode)
 {
     struct audio_device * adev = (struct audio_device *)ka.userdata;
     audio_devices_t out_devices = AUDIO_DEVICE_NONE;
@@ -300,7 +301,7 @@
     return rc;
 }
 
-void audio_extn_keep_alive_stop(ka_mode_t ka_mode)
+void keep_alive_stop(ka_mode_t ka_mode)
 {
     struct audio_device * adev = (struct audio_device *)ka.userdata;
     audio_devices_t out_devices;
@@ -365,7 +366,7 @@
     return 0;
 }
 
-int audio_extn_keep_alive_set_parameters(struct audio_device *adev __unused,
+int keep_alive_set_parameters(struct audio_device *adev __unused,
                                          struct str_parms *parms __unused)
 {
     char value[32];
diff --git a/hal/audio_extn/maxxaudio.c b/hal/audio_extn/maxxaudio.c
index fc65332..5f2a7f0 100644
--- a/hal/audio_extn/maxxaudio.c
+++ b/hal/audio_extn/maxxaudio.c
@@ -41,29 +41,40 @@
 #define CAL_PRESIST_STR "cal_persist"
 #define CAL_SAMPLERATE_STR "cal_samplerate"
 
-#define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_initialize"
-#define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_uninitialize"
-#define MA_QDSP_SET_LR_SWAP "maxxaudio_qdsp_set_lr_swap"
-#define MA_QDSP_SET_MODE "maxxaudio_qdsp_set_sound_mode"
-#define MA_QDSP_SET_VOL "maxxaudio_qdsp_set_volume"
-#define MA_QDSP_SET_VOLT "maxxaudio_qdsp_set_volume_table"
+#define MA_QDSP_PARAM_INIT      "maxxaudio_qdsp_initialize"
+#define MA_QDSP_PARAM_DEINIT    "maxxaudio_qdsp_uninitialize"
+#define MA_QDSP_SET_LR_SWAP     "maxxaudio_qdsp_set_lr_swap"
+#define MA_QDSP_SET_MODE        "maxxaudio_qdsp_set_sound_mode"
+#define MA_QDSP_SET_VOL         "maxxaudio_qdsp_set_volume"
+#define MA_QDSP_SET_VOLT        "maxxaudio_qdsp_set_volume_table"
+#define MA_QDSP_SET_PARAM       "maxxaudio_qdsp_set_parameter"
 
-#define SUPPORT_DEV "Blackbird"
+#define SUPPORT_DEV "18d1:5033" // Blackbird usbid
 #define SUPPORTED_USB 0x01
 
-struct ma_audio_cal_settings {
-    int app_type;
-    audio_devices_t device;
-};
+typedef unsigned int effective_scope_flag_t;
+const effective_scope_flag_t EFFECTIVE_SCOPE_RTC = 1 << 0;   /* RTC  */
+const effective_scope_flag_t EFFECTIVE_SCOPE_ACDB = 1 << 1;  /* ACDB */
+const effective_scope_flag_t EFFECTIVE_SCOPE_ALL = EFFECTIVE_SCOPE_RTC | EFFECTIVE_SCOPE_ACDB;
+const effective_scope_flag_t EFFECTIVE_SCOPE_NONE = 0;
+const effective_scope_flag_t EFFECTIVE_SCOPE_DEFAULT = EFFECTIVE_SCOPE_NONE;
 
-struct ma_state {
-    float vol;
-    bool active;
-};
+const unsigned int AUDIO_CAL_SETTINGS_VERSION_MAJOR = 2;
+const unsigned int AUDIO_CAL_SETTINGS_VERSION_MINOR = 0;
+const unsigned int AUDIO_CAL_SETTINGS_VERSION_MAJOR_DEFAULT = AUDIO_CAL_SETTINGS_VERSION_MAJOR;
+const unsigned int AUDIO_CAL_SETTINGS_VERSION_MINOR_DEFAULT = AUDIO_CAL_SETTINGS_VERSION_MINOR;
+
+const unsigned int VALUE_AUTO = 0xFFFFFFFF;
+const unsigned int APP_TYPE_AUTO = VALUE_AUTO;
+const unsigned int APP_TYPE_DEFAULT = APP_TYPE_AUTO;
+const unsigned int DEVICE_AUTO = VALUE_AUTO;
+const unsigned int DEVICE_DEFAULT = DEVICE_AUTO;
+
+const unsigned int MAAP_OUTPUT_GAIN = 27;
 
 typedef enum MA_STREAM_TYPE {
-    STREAM_MIN_STREAM_TYPES,
-    STREAM_VOICE = STREAM_MIN_STREAM_TYPES,
+    STREAM_MIN_TYPES = 0,
+    STREAM_VOICE = STREAM_MIN_TYPES,
     STREAM_SYSTEM,
     STREAM_RING,
     STREAM_MUSIC,
@@ -76,8 +87,31 @@
     MA_CMD_VOL,
     MA_CMD_SWAP_ENABLE,
     MA_CMD_SWAP_DISABLE,
+    MA_CMD_SOFT_MUTE_ENABLE,
+    MA_CMD_SOFT_MUTE_DISABLE,
 } ma_cmd_t;
 
+typedef struct ma_audio_cal_version {
+    unsigned int major;
+    unsigned int minor;
+} ma_audio_cal_version_t;
+
+typedef struct ma_audio_cal_common_settings {
+    unsigned int app_type;
+    unsigned int device;
+} ma_audio_cal_common_settings_t;
+
+struct ma_audio_cal_settings {
+    ma_audio_cal_version_t version;
+    ma_audio_cal_common_settings_t common;
+    effective_scope_flag_t effect_scope_flag;
+};
+
+struct ma_state {
+    float vol;
+    bool active;
+};
+
 typedef void *ma_audio_cal_handle_t;
 typedef int (*set_audio_cal_t)(const char *);
 
@@ -100,6 +134,10 @@
                                       const struct ma_audio_cal_settings *,
                                       size_t, struct ma_state *);
 
+typedef bool (*ma_set_param_t)(ma_audio_cal_handle_t,
+                               const struct ma_audio_cal_settings *,
+                               unsigned int, double);
+
 struct ma_platform_data {
     void *waves_handle;
     void *platform;
@@ -110,6 +148,8 @@
     ma_set_sound_mode_t      ma_set_sound_mode;
     ma_set_volume_t          ma_set_volume;
     ma_set_volume_table_t    ma_set_volume_table;
+    ma_set_param_t           ma_set_param;
+    bool speaker_lr_swap;
 };
 
 ma_audio_cal_handle_t g_ma_audio_cal_handle = NULL;
@@ -132,20 +172,6 @@
                                    audio_cal_settings, swap);
 }
 
-static bool ma_set_sound_mode_l(
-    const struct ma_audio_cal_settings *audio_cal_settings, int sound_mode)
-{
-    return my_data->ma_set_sound_mode(g_ma_audio_cal_handle,
-                                      audio_cal_settings, sound_mode);
-}
-
-static bool ma_set_volume_l(
-    const struct ma_audio_cal_settings *audio_cal_settings, double volume)
-{
-    return my_data->ma_set_volume(g_ma_audio_cal_handle, audio_cal_settings,
-                                  volume);
-}
-
 static bool ma_set_volume_table_l(
     const struct ma_audio_cal_settings *audio_cal_settings,
     size_t num_streams, struct ma_state *volume_table)
@@ -155,6 +181,14 @@
                                         volume_table);
 }
 
+static bool ma_set_param_l(
+    const struct ma_audio_cal_settings *audio_cal_settings,
+    unsigned int index, double value)
+{
+    return my_data->ma_set_param(g_ma_audio_cal_handle,
+                                 audio_cal_settings, index, value);
+}
+
 static inline bool valid_usecase(struct audio_usecase *usecase)
 {
     if ((usecase->type == PCM_PLAYBACK) &&
@@ -165,8 +199,9 @@
         /* support devices */
         ((usecase->devices & AUDIO_DEVICE_OUT_SPEAKER) ||
          (usecase->devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) ||
-         /* TODO: enable A2DP when it is ready */
-         (usecase->devices & AUDIO_DEVICE_OUT_ALL_USB)))
+         (audio_is_usb_out_device(usecase->devices) &&
+          audio_extn_ma_supported_usb())))
+        /* TODO: enable A2DP when it is ready */
 
         return true;
 
@@ -182,46 +217,48 @@
     ma_stream_type_t i = 0;
 
     for (i = 0; i < STREAM_MAX_TYPES; i++)
-        if (ma_cur_state_table[i].active &&
-                (ma_cur_state_table[i].vol != 0))
+        if (ma_cur_state_table[i].active)
             return true;
 
     return false;
 }
 
+static void ma_cal_init(struct ma_audio_cal_settings *ma_cal)
+{
+    ma_cal->version.major = AUDIO_CAL_SETTINGS_VERSION_MAJOR_DEFAULT;
+    ma_cal->version.minor = AUDIO_CAL_SETTINGS_VERSION_MINOR_DEFAULT;
+    ma_cal->common.app_type = APP_TYPE_DEFAULT;
+    ma_cal->common.device = DEVICE_DEFAULT;
+    ma_cal->effect_scope_flag = EFFECTIVE_SCOPE_ALL;
+}
+
 static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd)
 {
     int i = 0;
     bool ret = false;
-    float vol = 0;
     struct listnode *node;
     struct audio_usecase *usecase;
-    struct ma_audio_cal_settings *ma_cal = NULL;
+    struct ma_audio_cal_settings ma_cal;
 
-    // alloct
-    ma_cal = (struct ma_audio_cal_settings *)malloc(sizeof(struct ma_audio_cal_settings));
-
-    if (ma_cal == NULL) {
-        ALOGE("%s: ma_cal alloct fail", __func__);
-        return ret;
-    }
+    ma_cal_init(&ma_cal);
 
     list_for_each(node, &adev->usecase_list) {
         usecase = node_to_item(node, struct audio_usecase, list);
         if (valid_usecase(usecase)) {
-            ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type;
-            ma_cal->device = usecase->stream.out->devices;
+            ma_cal.common.app_type = usecase->stream.out->app_type_cfg.app_type;
+            ma_cal.common.device = usecase->stream.out->devices;
             ALOGV("%s: send usecase(%d) app_type(%d) device(%d)",
-                      __func__, usecase->id, ma_cal->app_type, ma_cal->device);
+                      __func__, usecase->id, ma_cal.common.app_type,
+                      ma_cal.common.device);
 
             switch (cmd) {
                 case MA_CMD_VOL:
-                    ret = ma_set_volume_table_l(ma_cal, STREAM_MAX_TYPES,
+                    ret = ma_set_volume_table_l(&ma_cal, STREAM_MAX_TYPES,
                                                 ma_cur_state_table);
                     if (ret)
-                        ALOGV("Waves: ma_set_volume_table_l success");
+                        ALOGV("ma_set_volume_table_l success");
                     else
-                        ALOGE("Waves: ma_set_volume_table_l %f returned with error.", vol);
+                        ALOGE("ma_set_volume_table_l returned with error.");
 
                     ALOGV("%s: send volume table === Start", __func__);
                     for (i = 0; i < STREAM_MAX_TYPES; i++)
@@ -230,26 +267,49 @@
                               ma_cur_state_table[i].active ? "T" : "F");
                     ALOGV("%s: send volume table === End", __func__);
                     break;
+
                 case MA_CMD_SWAP_ENABLE:
-                    ret = ma_set_lr_swap_l(ma_cal, true);
-                    if (ret)
-                        ALOGV("Waves: ma_set_lr_swap_l enable returned with success.");
-                    else
-                        ALOGE("Waves: ma_set_lr_swap_l enable returned with error.");
+                    /* lr swap only enable for speaker path */
+                    if (ma_cal.common.device & AUDIO_DEVICE_OUT_SPEAKER) {
+                        ret = ma_set_lr_swap_l(&ma_cal, true);
+                        if (ret)
+                            ALOGV("ma_set_lr_swap_l enable returned with success.");
+                        else
+                            ALOGE("ma_set_lr_swap_l enable returned with error.");
+                    }
                     break;
+
                 case MA_CMD_SWAP_DISABLE:
-                    ret = ma_set_lr_swap_l(ma_cal, false);
+                    ret = ma_set_lr_swap_l(&ma_cal, false);
                     if (ret)
-                        ALOGV("Waves: ma_set_lr_swap_l disable returned with success.");
+                        ALOGV("ma_set_lr_swap_l disable returned with success.");
                     else
-                        ALOGE("Waves: ma_set_lr_swap_l disable returned with error.");
+                        ALOGE("ma_set_lr_swap_l disable returned with error.");
                     break;
+
+                case MA_CMD_SOFT_MUTE_ENABLE:
+                    if (usecase->id == USECASE_AUDIO_PLAYBACK_LOW_LATENCY) break;
+
+                    ma_cal.effect_scope_flag = EFFECTIVE_SCOPE_RTC;
+                    ret = ma_set_param_l(&ma_cal, MAAP_OUTPUT_GAIN, -96);
+                    if (!ret)
+                        ALOGE("soft mute enable returned with error.");
+                    break;
+
+                case MA_CMD_SOFT_MUTE_DISABLE:
+                    if (usecase->id == USECASE_AUDIO_PLAYBACK_LOW_LATENCY) break;
+
+                    ma_cal.effect_scope_flag = EFFECTIVE_SCOPE_RTC;
+                    ret = ma_set_param_l(&ma_cal, MAAP_OUTPUT_GAIN, 0);
+                    if (!ret)
+                        ALOGE("soft mute disable returned with error.");
+                    break;
+
                 default:
                     ALOGE("%s: unsupported cmd %d", __func__, cmd);
             }
         }
     }
-    free(ma_cal);
 
     return ret;
 }
@@ -282,14 +342,6 @@
 
 static void ma_set_swap_l(struct audio_device *adev, bool enable)
 {
-    // do platform LR swap if it enables on Waves effect
-    // but there is no Waves implementation
-    if (!my_data) {
-        platform_check_and_set_swap_lr_channels(adev, enable);
-        ALOGV("%s: maxxaudio isn't initialized.", __func__);
-        return;
-    }
-
     if (enable)
         check_and_send_all_audio_cal(adev, MA_CMD_SWAP_ENABLE);
     else
@@ -305,7 +357,7 @@
     char *idd;
 
     if (enable) {
-        ret = snprintf(path, sizeof(path), "/proc/asound/card%u/id", card);
+        ret = snprintf(path, sizeof(path), "/proc/asound/card%u/usbid", card);
         if (ret < 0) {
             ALOGE("%s: failed on snprintf (%d) to path %s\n",
                   __func__, ret, path);
@@ -325,10 +377,10 @@
         idd = strtok(id, "\n");
 
         if (find_sup_dev(idd)) {
-            ALOGV("%s: support device name is %s", __func__, id);
+            ALOGV("%s: support usbid is %s", __func__, id);
             g_supported_dev |= SUPPORTED_USB;
         } else
-            ALOGV("%s: device %s isn't found from %s", __func__, id, SUPPORT_DEV);
+            ALOGV("%s: usbid %s isn't found from %s", __func__, id, SUPPORT_DEV);
     } else {
         g_supported_dev &= ~SUPPORTED_USB;
     }
@@ -417,6 +469,13 @@
              ALOGE("%s: dlsym error %s for ma_set_volume_table", __func__, dlerror());
              goto error;
          }
+
+         my_data->ma_set_param = (ma_set_param_t)dlsym(
+                                  my_data->waves_handle, MA_QDSP_SET_PARAM);
+         if (!my_data->ma_set_param) {
+             ALOGE("%s: dlsym error %s for ma_set_param", __func__, dlerror());
+             goto error;
+         }
     }
 
     /* get preset table */
@@ -480,6 +539,8 @@
         ma_cur_state_table[i].active = false;
     }
 
+    my_data->speaker_lr_swap = false;
+
     return;
 
 error:
@@ -509,27 +570,42 @@
                              float vol, bool active)
 {
     bool ret = false;
-    ma_stream_type_t stype = (ma_stream_type_t)stream_type;
+    bool first_enable = false;
+    struct ma_state pr_mstate;
 
-    ALOGV("%s: stream[%d] vol[%f] active[%s]",
-          __func__, stream_type, vol, active ? "true" : "false");
+    if (stream_type >= STREAM_MAX_TYPES ||
+        stream_type < STREAM_MIN_TYPES) {
+        ALOGE("%s: stream_type %d out of range.", __func__, stream_type);
+        return ret;
+    }
 
     if (!my_data) {
         ALOGV("%s: maxxaudio isn't initialized.", __func__);
         return ret;
     }
 
-    // update condition
-    // 1. start track: active and volume isn't zero
-    // 2. stop track: no tracks are active
-    if ((active && vol != 0) ||
-        (!active)) {
-        pthread_mutex_lock(&my_data->lock);
+    ALOGV("%s: stream[%d] vol[%f] active[%s]",
+          __func__, stream_type, vol, active ? "true" : "false");
 
-        ma_cur_state_table[stype].vol = vol;
-        ma_cur_state_table[stype].active = active;
-        if (is_active())
-            ret = check_and_send_all_audio_cal(adev, MA_CMD_VOL);
+    pr_mstate.vol = ma_cur_state_table[(ma_stream_type_t)stream_type].vol;
+    pr_mstate.active = ma_cur_state_table[(ma_stream_type_t)stream_type].active;
+
+    // update condition: vol or active state changes
+    if (pr_mstate.vol != vol || pr_mstate.active != active) {
+
+        pthread_mutex_lock(&my_data->lock);
+        // get active state before updating
+        first_enable = (!is_active()) && active;
+
+        ma_cur_state_table[(ma_stream_type_t)stream_type].vol = vol;
+        ma_cur_state_table[(ma_stream_type_t)stream_type].active = active;
+
+        if (first_enable) //all F -> one of T
+            ret = check_and_send_all_audio_cal(adev, MA_CMD_SOFT_MUTE_DISABLE);
+        else if (!is_active()) // all F
+            ret = check_and_send_all_audio_cal(adev, MA_CMD_SOFT_MUTE_ENABLE);
+
+        ret = check_and_send_all_audio_cal(adev, MA_CMD_VOL);
 
         pthread_mutex_unlock(&my_data->lock);
     }
@@ -540,9 +616,7 @@
 void audio_extn_ma_set_device(struct audio_usecase *usecase)
 {
     int i = 0;
-    int u_index = -1;
-    float vol = 0;
-    struct ma_audio_cal_settings *ma_cal = NULL;
+    struct ma_audio_cal_settings ma_cal;
 
     if (!my_data) {
         ALOGV("%s: maxxaudio isn't initialized.", __func__);
@@ -554,61 +628,67 @@
         return;
     }
 
-    ma_cal = (struct ma_audio_cal_settings *)malloc(sizeof(struct ma_audio_cal_settings));
+    ma_cal_init(&ma_cal);
 
     /* update audio_cal and send it */
-    if (ma_cal != NULL){
-        ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type;
-        ma_cal->device = usecase->stream.out->devices;
-        ALOGV("%s: send usecase(%d) app_type(%d) device(%d)",
-                      __func__, usecase->id, ma_cal->app_type, ma_cal->device);
+    ma_cal.common.app_type = usecase->stream.out->app_type_cfg.app_type;
+    ma_cal.common.device = usecase->stream.out->devices;
+    ALOGV("%s: send usecase(%d) app_type(%d) device(%d)",
+              __func__, usecase->id, ma_cal.common.app_type,
+              ma_cal.common.device);
 
-        pthread_mutex_lock(&my_data->lock);
+    pthread_mutex_lock(&my_data->lock);
 
-        if (is_active()) {
-            ALOGV("%s: send volume table === Start", __func__);
-            for (i = 0; i < STREAM_MAX_TYPES; i++)
-                ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i,
-                    ma_cur_state_table[i].vol,
-                    ma_cur_state_table[i].active ? "T" : "F");
-            ALOGV("%s: send volume table === End", __func__);
+    if (is_active()) {
+        if (ma_cal.common.device & AUDIO_DEVICE_OUT_SPEAKER)
+            ma_set_swap_l(usecase->stream.out->dev, my_data->speaker_lr_swap);
+        else
+            ma_set_swap_l(usecase->stream.out->dev, false);
 
-            if (!ma_set_volume_table_l(ma_cal,
-                                       STREAM_MAX_TYPES,
-                                       ma_cur_state_table))
-                ALOGE("Waves: ma_set_volume_table_l %f returned with error.", vol);
-            else
-                ALOGV("Waves: ma_set_volume_table_l success");
+        ALOGV("%s: send volume table === Start", __func__);
+        for (i = 0; i < STREAM_MAX_TYPES; i++)
+            ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i,
+                   ma_cur_state_table[i].vol,
+                   ma_cur_state_table[i].active ? "T" : "F");
+        ALOGV("%s: send volume table === End", __func__);
 
-        }
-        pthread_mutex_unlock(&my_data->lock);
-        free(ma_cal);
-    } else {
-        ALOGE("%s: ma_cal alloct fail", __func__);
+        if (!ma_set_volume_table_l(&ma_cal,
+                                   STREAM_MAX_TYPES,
+                                   ma_cur_state_table))
+            ALOGE("ma_set_volume_table_l returned with error.");
+        else
+            ALOGV("ma_set_volume_table_l success");
+
     }
+    pthread_mutex_unlock(&my_data->lock);
 }
 
 void audio_extn_ma_set_parameters(struct audio_device *adev,
                                   struct str_parms *parms)
 {
     int ret;
-    bool ret_b;
     int val;
     char value[128];
 
     // do LR swap and usb recognition
     ret = str_parms_get_int(parms, "rotation", &val);
     if (ret >= 0) {
+        if (!my_data) {
+            ALOGV("%s: maxxaudio isn't initialized.", __func__);
+            return;
+        }
+
         switch (val) {
         case 270:
-            ma_set_swap_l(adev, true);
+            my_data->speaker_lr_swap = true;
             break;
         case 0:
         case 90:
         case 180:
-            ma_set_swap_l(adev, false);
+            my_data->speaker_lr_swap = false;
             break;
         }
+        ma_set_swap_l(adev, my_data->speaker_lr_swap);
     }
 
     // check connect status
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index 3351e6f..b0495ea 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -659,7 +659,7 @@
 
 // --- public APIs --- //
 
-int audio_extn_snd_mon_deinit()
+int snd_mon_deinit()
 {
     if (!sndmonitor.initcheck)
         return -1;
@@ -675,7 +675,7 @@
     return 0;
 }
 
-int audio_extn_snd_mon_init()
+int snd_mon_init()
 {
     sndmonitor.notify = snd_mon_update;
     sndmonitor.target = NULL; // unused for now
@@ -717,7 +717,7 @@
     return -ENODEV;
 }
 
-int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb)
+int snd_mon_register_listener(void *stream, snd_mon_cb cb)
 {
     if (!sndmonitor.initcheck) {
         ALOGW("sndmonitor initcheck failed, cannot register");
@@ -727,7 +727,7 @@
     return add_listener(stream, cb);
 }
 
-int audio_extn_snd_mon_unregister_listener(void *stream)
+int snd_mon_unregister_listener(void *stream)
 {
     if (!sndmonitor.initcheck) {
         ALOGW("sndmonitor initcheck failed, cannot deregister");
diff --git a/hal/audio_extn/source_track.c b/hal/audio_extn/source_track.c
index 507aa7e..064fad8 100644
--- a/hal/audio_extn/source_track.c
+++ b/hal/audio_extn/source_track.c
@@ -47,7 +47,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef SOURCE_TRACKING_ENABLED
 /* Audio Paramater Key to identify the list of start angles.
  * Starting angle (in degrees) defines the boundary starting angle for each sector.
  */
@@ -500,7 +499,7 @@
     }
 }
 
-int audio_extn_get_soundfocus_data(const struct audio_device *adev,
+int get_soundfocus_data(const struct audio_device *adev,
                                    struct sound_focus_param *payload)
 {
     int ret = 0;
@@ -515,7 +514,7 @@
     return ret ;
 }
 
-int audio_extn_get_sourcetrack_data(const struct audio_device *adev,
+int get_sourcetrack_data(const struct audio_device *adev,
                               struct source_tracking_param *payload)
 {
     int ret = 0;
@@ -530,7 +529,7 @@
     return ret ;
 }
 
-void audio_extn_source_track_get_parameters(const struct audio_device *adev,
+void source_track_get_parameters(const struct audio_device *adev,
                                             struct str_parms *query,
                                             struct str_parms *reply)
 {
@@ -605,7 +604,7 @@
     return ret;
 }
 
-int audio_extn_set_soundfocus_data(struct audio_device *adev,
+int set_soundfocus_data(struct audio_device *adev,
                               struct sound_focus_param *payload)
 {
     int ret = 0;
@@ -616,7 +615,7 @@
     return ret ;
 }
 
-void audio_extn_source_track_set_parameters(struct audio_device *adev,
+void source_track_set_parameters(struct audio_device *adev,
                                             struct str_parms *parms)
 {
     int len, ret;
@@ -695,4 +694,3 @@
         free(value);
     return;
 }
-#endif /* SOURCE_TRACKING_ENABLED end */
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 08ecb7a..d123dd1 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -146,6 +146,25 @@
 #define AUDIO_PARAMETER_KEY_FBSP_CFG_FTM_TIME       "fbsp_cfg_ftm_time"
 #define AUDIO_PARAMETER_KEY_FBSP_GET_FTM_PARAM      "get_ftm_param"
 
+// - external function dependency -
+static fp_read_line_from_file_t fp_read_line_from_file;
+static fp_get_usecase_from_list_t fp_get_usecase_from_list;
+static fp_enable_disable_snd_device_t fp_disable_snd_device;
+static fp_enable_disable_snd_device_t  fp_enable_snd_device;
+static fp_enable_disable_audio_route_t fp_disable_audio_route;
+static fp_enable_disable_audio_route_t fp_enable_audio_route;
+static fp_platform_set_snd_device_backend_t fp_platform_set_snd_device_backend;
+static fp_platform_get_snd_device_name_extn_t fp_platform_get_snd_device_name_extn;
+static fp_platform_get_default_app_type_v2_t fp_platform_get_default_app_type_v2;
+static fp_platform_send_audio_calibration_t fp_platform_send_audio_calibration;
+static fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
+static fp_platform_get_snd_device_name_t fp_platform_get_snd_device_name;
+static fp_platform_spkr_prot_is_wsa_analog_mode_t fp_platform_spkr_prot_is_wsa_analog_mode;
+static fp_platform_get_snd_device_t fp_platform_get_vi_feedback_snd_device;
+static fp_platform_get_snd_device_t fp_platform_get_spkr_prot_snd_device;
+static fp_platform_check_and_set_codec_backend_cfg_t fp_platform_check_and_set_codec_backend_cfg;
+static fp_audio_extn_is_vbat_enabled_t fp_audio_extn_is_vbat_enabled;
+
 /*Modes of Speaker Protection*/
 enum speaker_protection_mode {
     SPKR_PROTECTION_DISABLED = -1,
@@ -296,6 +315,10 @@
 static int vi_feed_no_channels;
 static struct spkr_tz_names tz_names;
 
+int get_spkr_prot_snd_device(snd_device_t snd_device) {
+    return snd_device;
+}
+
 /*===========================================================================
 FUNCTION get_tzn
 
@@ -344,7 +367,7 @@
                 continue;
             snprintf(name, MAX_PATH, TZ_TYPE, tzn);
             ALOGV("Opening %s\n", name);
-            read_line_from_file(name, buf, sizeof(buf));
+            fp_read_line_from_file(name, buf, sizeof(buf));
             if (strlen(buf) > 0)
                 buf[strlen(buf) - 1] = '\0';
             if (!strcmp(buf, sensor_name)) {
@@ -377,7 +400,7 @@
    }
 }
 
-void audio_extn_spkr_prot_calib_cancel(void *adev)
+void spkr_prot_calib_cancel(void *adev)
 {
     pthread_t threadid;
     struct audio_usecase *uc_info;
@@ -387,7 +410,7 @@
         ALOGE("%s: Invalid params", __func__);
         return;
     }
-    uc_info = get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_RX);
+    uc_info = fp_get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_RX);
     if (uc_info) {
             pthread_mutex_lock(&handle.mutex_spkr_prot);
             pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex);
@@ -566,12 +589,12 @@
         pthread_cond_destroy(&handle.spkr_prot_thermalsync);
     }
 }
-static void audio_extn_check_wsa(struct audio_device *adev,
+static void check_wsa(struct audio_device *adev,
                 unsigned int num_of_spkrs, bool *wsa_is_8815)
 {
     unsigned int i = 0;
     if (!handle.wsa_found ||
-        platform_spkr_prot_is_wsa_analog_mode(adev)){
+        fp_platform_spkr_prot_is_wsa_analog_mode(adev)){
         for (i = 0; i < num_of_spkrs; i++)
             wsa_is_8815[i] = false;
 
@@ -587,7 +610,7 @@
         wsa_is_8815[SP_V2_SPKR_2] = true;
 }
 
-int audio_extn_set_wcd_boost_max_state(struct audio_device *adev,
+int set_wcd_boost_max_state(struct audio_device *adev,
                 int boost_max_state, int wsa_num)
 {
     struct mixer_ctl *ctl = NULL;
@@ -613,7 +636,7 @@
     return 0;
 }
 
-int audio_extn_set_wsa_boost_level(struct audio_device *adev,
+int set_wsa_boost_level(struct audio_device *adev,
                 int wsa_num, int boost_table_index)
 {
     struct mixer_ctl *ctl;
@@ -643,7 +666,7 @@
     return 0;
 }
 
-static int audio_extn_spkr_boost_update(struct audio_device *adev,
+static int spkr_boost_update(struct audio_device *adev,
                 unsigned int wsa_num, unsigned int *index, bool spkr2_is_mono)
 {
     float dcr = 0;
@@ -680,14 +703,14 @@
     if (spkr2_is_mono)
         wsa_to_set = SP_V2_SPKR_2;
 
-    ret = audio_extn_set_wcd_boost_max_state(adev, boost_max_state, wsa_to_set);
+    ret = set_wcd_boost_max_state(adev, boost_max_state, wsa_to_set);
     if (ret < 0) {
         ALOGE("%s: failed to set wcd max boost state.",
             __func__);
         return -EINVAL;
     }
 
-    ret = audio_extn_set_wsa_boost_level(adev, wsa_to_set, r0_index);
+    ret = set_wsa_boost_level(adev, wsa_to_set, r0_index);
     if (ret < 0) {
         ALOGE("%s: failed to set wsa boost level.",
             __func__);
@@ -699,7 +722,7 @@
     return 0;
 }
 
-static void audio_extn_set_boost_and_limiter(struct audio_device *adev,
+static void set_boost_and_limiter(struct audio_device *adev,
                 bool spv3_enable, unsigned int afe_api_version)
 {
     int chn = 0;
@@ -715,7 +738,7 @@
      * follow lookup table based on R0 impediance regardless
      * of spv2 or spv3.
      */
-    audio_extn_check_wsa(adev, vi_feed_no_channels, wsa_is_8815);
+    check_wsa(adev, vi_feed_no_channels, wsa_is_8815);
     if (vi_feed_no_channels == 1 && wsa_is_8815[SP_V2_SPKR_2])
         spkr2_is_mono_speaker = true;
     /*
@@ -728,7 +751,7 @@
         if (spkr2_is_mono_speaker)
             chn_in_use = SP_V2_SPKR_2;
         if (wsa_is_8815[chn_in_use] &&
-            !audio_extn_spkr_boost_update(adev, chn,
+            !spkr_boost_update(adev, chn,
                                     &r0_index, spkr2_is_mono_speaker)) {
             handle.limiter_th[chn] = spv3_limiter_th_q27_table[r0_index];
             handle.sp_version = SP_V3;
@@ -793,21 +816,21 @@
     uc_info_rx->type = PCM_PLAYBACK;
     uc_info_rx->in_snd_device = SND_DEVICE_NONE;
     uc_info_rx->stream.out = adev->primary_output;
-    if (audio_extn_is_vbat_enabled())
+    if (fp_audio_extn_is_vbat_enabled())
         uc_info_rx->out_snd_device = SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT;
     else
         uc_info_rx->out_snd_device = SND_DEVICE_OUT_SPEAKER_PROTECTED;
     disable_rx = true;
     list_add_tail(&adev->usecase_list, &uc_info_rx->list);
-    platform_check_and_set_codec_backend_cfg(adev, uc_info_rx,
+    fp_platform_check_and_set_codec_backend_cfg(adev, uc_info_rx,
                                              uc_info_rx->out_snd_device);
-    if (audio_extn_is_vbat_enabled())
-         enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT);
+    if (fp_audio_extn_is_vbat_enabled())
+         fp_enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT);
     else
-         enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
-    enable_audio_route(adev, uc_info_rx);
+         fp_enable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
+    fp_enable_audio_route(adev, uc_info_rx);
 
-    pcm_dev_rx_id = platform_get_pcm_device_id(uc_info_rx->id, PCM_PLAYBACK);
+    pcm_dev_rx_id = fp_platform_get_pcm_device_id(uc_info_rx->id, PCM_PLAYBACK);
     ALOGV("%s: pcm device id %d", __func__, pcm_dev_rx_id);
     if (pcm_dev_rx_id < 0) {
         ALOGE("%s: Invalid pcm device for usecase (%d)",
@@ -837,10 +860,10 @@
 
     disable_tx = true;
     list_add_tail(&adev->usecase_list, &uc_info_tx->list);
-    enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
-    enable_audio_route(adev, uc_info_tx);
+    fp_enable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
+    fp_enable_audio_route(adev, uc_info_tx);
 
-    pcm_dev_tx_id = platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
+    pcm_dev_tx_id = fp_platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
     ALOGV("%s: pcm device id %d", __func__, pcm_dev_tx_id);
     if (pcm_dev_tx_id < 0) {
         ALOGE("%s: Invalid pcm device for usecase (%d)",
@@ -929,9 +952,9 @@
                   __func__);
             uc_info_tx->in_snd_device = SND_DEVICE_IN_HANDSET_MIC;
             uc_info_tx->out_snd_device = SND_DEVICE_NONE;
-            app_type = platform_get_default_app_type_v2(adev->platform,
+            app_type = fp_platform_get_default_app_type_v2(adev->platform,
                                                 PCM_CAPTURE);
-            platform_send_audio_calibration(adev->platform, uc_info_tx,
+            fp_platform_send_audio_calibration(adev->platform, uc_info_tx,
                                                     app_type, 8000);
         }
         if (!status.status) {
@@ -959,16 +982,16 @@
         }
         if (disable_rx) {
             list_remove(&uc_info_rx->list);
-            if (audio_extn_is_vbat_enabled())
-                disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT);
+            if (fp_audio_extn_is_vbat_enabled())
+                fp_disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT);
             else
-                disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
-            disable_audio_route(adev, uc_info_rx);
+                fp_disable_snd_device(adev, SND_DEVICE_OUT_SPEAKER_PROTECTED);
+            fp_disable_audio_route(adev, uc_info_rx);
         }
         if (disable_tx) {
             list_remove(&uc_info_tx->list);
-            disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
-            disable_audio_route(adev, uc_info_tx);
+            fp_disable_snd_device(adev, SND_DEVICE_IN_CAPTURE_VI_FEEDBACK);
+            fp_disable_audio_route(adev, uc_info_tx);
         }
         if (uc_info_rx) free(uc_info_rx);
         if (uc_info_tx) free(uc_info_tx);
@@ -1094,7 +1117,7 @@
                 handle.spkr_prot_mode = MSM_SPKR_PROT_CALIBRATED;
             close(acdb_fd);
 
-            audio_extn_set_boost_and_limiter(adev, spv3_enable, afe_api_version);
+            set_boost_and_limiter(adev, spv3_enable, afe_api_version);
 
             pthread_exit(0);
             return NULL;
@@ -1278,7 +1301,7 @@
         dlclose(handle.thermal_handle);
     handle.thermal_handle = NULL;
 
-    audio_extn_set_boost_and_limiter(adev, spv3_enable, afe_api_version);
+    set_boost_and_limiter(adev, spv3_enable, afe_api_version);
 
     pthread_exit(0);
     return NULL;
@@ -1295,7 +1318,7 @@
     return 0;
 }
 
-void audio_extn_spkr_prot_set_parameters(struct str_parms *parms,
+void spkr_prot_set_parameters(struct str_parms *parms,
                                          char *value, int len)
 {
     int err;
@@ -1534,7 +1557,7 @@
     pthread_mutex_unlock(&handle.cal_wait_cond_mutex);
 }
 
-int audio_extn_fbsp_set_parameters(struct str_parms *parms)
+int fbsp_set_parameters(struct str_parms *parms)
 {
     int ret= 0 , err;
     char *value = NULL;
@@ -1623,7 +1646,7 @@
     return ret;
 }
 
-int audio_extn_fbsp_get_parameters(struct str_parms *query,
+int fbsp_get_parameters(struct str_parms *query,
                                    struct str_parms *reply)
 {
     int err = 0;
@@ -1649,7 +1672,7 @@
     return err;
 }
 
-void audio_extn_spkr_prot_init(void *adev)
+void spkr_prot_init(void *adev, spkr_prot_init_config_t spkr_prot_init_config_val)
 {
     char value[PROPERTY_VALUE_MAX];
     int result = 0;
@@ -1674,6 +1697,24 @@
         ALOGD("%s: Speaker protection disabled", __func__);
         return;
     }
+    // init function pointers
+    fp_read_line_from_file = spkr_prot_init_config_val.fp_read_line_from_file;
+    fp_get_usecase_from_list =  spkr_prot_init_config_val.fp_get_usecase_from_list;
+    fp_disable_snd_device = spkr_prot_init_config_val.fp_disable_snd_device;
+    fp_enable_snd_device = spkr_prot_init_config_val.fp_enable_snd_device;
+    fp_disable_audio_route = spkr_prot_init_config_val.fp_disable_audio_route;
+    fp_enable_audio_route = spkr_prot_init_config_val.fp_enable_audio_route;
+    fp_platform_set_snd_device_backend = spkr_prot_init_config_val.fp_platform_set_snd_device_backend;
+    fp_platform_get_snd_device_name_extn = spkr_prot_init_config_val.fp_platform_get_snd_device_name_extn;
+    fp_platform_get_default_app_type_v2 = spkr_prot_init_config_val.fp_platform_get_default_app_type_v2;
+    fp_platform_send_audio_calibration = spkr_prot_init_config_val.fp_platform_send_audio_calibration;
+    fp_platform_get_pcm_device_id = spkr_prot_init_config_val.fp_platform_get_pcm_device_id;
+    fp_platform_get_snd_device_name = spkr_prot_init_config_val.fp_platform_get_snd_device_name;
+    fp_platform_spkr_prot_is_wsa_analog_mode = spkr_prot_init_config_val.fp_platform_spkr_prot_is_wsa_analog_mode;
+    fp_platform_get_vi_feedback_snd_device = spkr_prot_init_config_val.fp_platform_get_vi_feedback_snd_device;
+    fp_platform_get_spkr_prot_snd_device = spkr_prot_init_config_val.fp_platform_get_spkr_prot_snd_device;
+    fp_platform_check_and_set_codec_backend_cfg = spkr_prot_init_config_val.fp_platform_check_and_set_codec_backend_cfg;
+    fp_audio_extn_is_vbat_enabled = spkr_prot_init_config_val.fp_audio_extn_is_vbat_enabled;
     handle.adev_handle = adev;
     handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED;
     handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE;
@@ -1693,7 +1734,7 @@
     pthread_mutex_init(&handle.cal_wait_cond_mutex, NULL);
     pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
     if (handle.wsa_found) {
-        if (platform_spkr_prot_is_wsa_analog_mode(adev) == 1) {
+        if (fp_platform_spkr_prot_is_wsa_analog_mode(adev) == 1) {
             ALOGD("%s: WSA analog mode", __func__);
             pcm_config_skr_prot.channels = WSA_ANALOG_MODE_CHANNELS;
         }
@@ -1773,14 +1814,14 @@
         char platform[PROPERTY_VALUE_MAX];
         property_get("ro.board.platform", platform, "");
         if (!strncmp("apq8084", platform, sizeof("apq8084"))) {
-            platform_set_snd_device_backend(SND_DEVICE_OUT_VOICE_SPEAKER,
+            fp_platform_set_snd_device_backend(SND_DEVICE_OUT_VOICE_SPEAKER,
                                             "speaker-protected",
                                             "SLIMBUS_0_RX");
         }
     }
 }
 
-int audio_extn_spkr_prot_deinit()
+int spkr_prot_deinit()
 {
     int result = 0;
 
@@ -1801,7 +1842,7 @@
     return 0;
 }
 
-int audio_extn_select_spkr_prot_cal_data(snd_device_t snd_device)
+int select_spkr_prot_cal_data(snd_device_t snd_device)
 {
     struct audio_cal_info_spk_prot_cfg protCfg;
     int acdb_fd = -1;
@@ -1841,7 +1882,7 @@
     return ret;
 }
 
-int audio_extn_spkr_prot_start_processing(snd_device_t snd_device)
+int spkr_prot_start_processing(snd_device_t snd_device)
 {
     struct audio_usecase *uc_info_tx;
     struct audio_device *adev = handle.adev_handle;
@@ -1856,23 +1897,23 @@
        ALOGE("%s: Invalid params", __func__);
        return -EINVAL;
     }
-    snd_device = platform_get_spkr_prot_snd_device(snd_device);
+    snd_device = fp_platform_get_spkr_prot_snd_device(snd_device);
     if (handle.spkr_prot_mode == MSM_SPKR_PROT_CALIBRATED) {
-        ret = audio_extn_select_spkr_prot_cal_data(snd_device);
+        ret = select_spkr_prot_cal_data(snd_device);
         if (ret) {
             ALOGE("%s: Setting speaker protection cal data failed", __func__);
             return ret;
         }
     }
 
-    in_snd_device = platform_get_vi_feedback_snd_device(snd_device);
+    in_snd_device = fp_platform_get_vi_feedback_snd_device(snd_device);
     spkr_prot_set_spkrstatus(true);
     uc_info_tx = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
     if (!uc_info_tx) {
         return -ENOMEM;
     }
 
-    if (platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0) {
+    if (fp_platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0) {
         ALOGE("%s: Invalid sound device returned", __func__);
         return -EINVAL;
     }
@@ -1889,10 +1930,10 @@
         uc_info_tx->out_snd_device = SND_DEVICE_NONE;
         handle.pcm_tx = NULL;
         list_add_tail(&adev->usecase_list, &uc_info_tx->list);
-        enable_snd_device(adev, in_snd_device);
-        enable_audio_route(adev, uc_info_tx);
+        fp_enable_snd_device(adev, in_snd_device);
+        fp_enable_audio_route(adev, uc_info_tx);
 
-        pcm_dev_tx_id = platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
+        pcm_dev_tx_id = fp_platform_get_pcm_device_id(uc_info_tx->id, PCM_CAPTURE);
         if (pcm_dev_tx_id < 0) {
             ALOGE("%s: Invalid pcm device for usecase (%d)",
                   __func__, uc_info_tx->id);
@@ -1920,9 +1961,9 @@
               __func__);
         uc_info_tx->in_snd_device = SND_DEVICE_IN_HANDSET_MIC;
         uc_info_tx->out_snd_device = SND_DEVICE_NONE;
-        app_type = platform_get_default_app_type_v2(adev->platform,
+        app_type = fp_platform_get_default_app_type_v2(adev->platform,
                                             PCM_CAPTURE);
-        platform_send_audio_calibration(adev->platform, uc_info_tx,
+        fp_platform_send_audio_calibration(adev->platform, uc_info_tx,
                                                 app_type, 8000);
     }
     if (ret) {
@@ -1934,8 +1975,8 @@
         uc_info_tx->type = PCM_CAPTURE;
         uc_info_tx->in_snd_device = in_snd_device;
         uc_info_tx->out_snd_device = SND_DEVICE_NONE;
-        disable_snd_device(adev, in_snd_device);
-        disable_audio_route(adev, uc_info_tx);
+        fp_disable_snd_device(adev, in_snd_device);
+        fp_disable_audio_route(adev, uc_info_tx);
         free(uc_info_tx);
     } else
         handle.spkr_processing_state = SPKR_PROCESSING_IN_PROGRESS;
@@ -1944,27 +1985,27 @@
     return ret;
 }
 
-void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device)
+void spkr_prot_stop_processing(snd_device_t snd_device)
 {
     struct audio_usecase *uc_info_tx;
     struct audio_device *adev = handle.adev_handle;
     snd_device_t in_snd_device;
 
     ALOGV("%s: Entry", __func__);
-    snd_device = platform_get_spkr_prot_snd_device(snd_device);
+    snd_device = fp_platform_get_spkr_prot_snd_device(snd_device);
     spkr_prot_set_spkrstatus(false);
-    in_snd_device = platform_get_vi_feedback_snd_device(snd_device);
+    in_snd_device = fp_platform_get_vi_feedback_snd_device(snd_device);
 
     pthread_mutex_lock(&handle.mutex_spkr_prot);
     if (adev && handle.spkr_processing_state == SPKR_PROCESSING_IN_PROGRESS) {
-        uc_info_tx = get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_TX);
+        uc_info_tx = fp_get_usecase_from_list(adev, USECASE_AUDIO_SPKR_CALIB_TX);
         if (handle.pcm_tx)
             pcm_close(handle.pcm_tx);
         handle.pcm_tx = NULL;
-        disable_snd_device(adev, in_snd_device);
+        fp_disable_snd_device(adev, in_snd_device);
         if (uc_info_tx) {
             list_remove(&uc_info_tx->list);
-            disable_audio_route(adev, uc_info_tx);
+            fp_disable_audio_route(adev, uc_info_tx);
             free(uc_info_tx);
         }
     }
@@ -1972,16 +2013,18 @@
     pthread_mutex_unlock(&handle.mutex_spkr_prot);
     if (adev)
         audio_route_reset_and_update_path(adev->audio_route,
-                                      platform_get_snd_device_name(snd_device));
+                                      fp_platform_get_snd_device_name(snd_device));
     ALOGV("%s: Exit", __func__);
 }
 
-bool audio_extn_spkr_prot_is_enabled()
+bool spkr_prot_is_enabled()
 {
     return handle.spkr_prot_enable;
 }
 
-int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device) {
-    return snd_device;
+void spkr_prot_is_enabled_init()
+{
+
 }
+
 #endif /*SPKR_PROT_ENABLED*/
diff --git a/hal/audio_extn/ssr.c b/hal/audio_extn/ssr.c
index 15eaaef..d83b508 100644
--- a/hal/audio_extn/ssr.c
+++ b/hal/audio_extn/ssr.c
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 #include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
 #include <pthread.h>
 #include <cutils/sched_policy.h>
 #include <sys/resource.h>
@@ -44,7 +44,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef SSR_ENABLED
 #define COEFF_ARRAY_SIZE            4
 #define FILT_SIZE                   ((512+1)* 6)  /* # ((FFT bins)/2+1)*numOutputs */
 #define SSR_CHANNEL_OUTPUT_NUM      6
@@ -313,7 +312,7 @@
     return ret;
 }
 
-void audio_extn_ssr_update_enabled()
+void ssr_update_enabled()
 {
     char ssr_enabled[PROPERTY_VALUE_MAX] = "false";
 
@@ -327,7 +326,7 @@
     }
 }
 
-bool audio_extn_ssr_get_enabled()
+bool ssr_get_enabled()
 {
     ALOGV("%s: is_ssr_enabled:%d is_ssr_mode_on:%d ", __func__, ssrmod.is_ssr_enabled, ssrmod.is_ssr_mode_on);
 
@@ -337,13 +336,13 @@
     return false;
 }
 
-bool  audio_extn_ssr_check_usecase(struct stream_in *in) {
+bool  ssr_check_usecase(struct stream_in *in) {
     int ret = false;
     int channel_count = audio_channel_count_from_in_mask(in->channel_mask);
     audio_devices_t devices = in->device;
     audio_source_t source = in->source;
 
-    if ((audio_extn_ssr_get_enabled()) &&
+    if ((ssr_get_enabled()) &&
             ((channel_count == 2) || (channel_count == 6)) &&
             ((AUDIO_SOURCE_MIC == source) || (AUDIO_SOURCE_CAMCORDER == source)) &&
             ((AUDIO_DEVICE_IN_BUILTIN_MIC == devices) || (AUDIO_DEVICE_IN_BACK_MIC == devices)) &&
@@ -355,39 +354,6 @@
     return ret;
 }
 
-int audio_extn_ssr_set_usecase(struct stream_in *in,
-                               struct audio_config *config,
-                               bool *update_params)
-{
-    int ret = -EINVAL;
-    int channel_count = audio_channel_count_from_in_mask(in->channel_mask);
-    audio_channel_representation_t representation =
-                  audio_channel_mask_get_representation(in->channel_mask);
-    *update_params = false;
-
-    if (audio_extn_ssr_check_usecase(in)) {
-
-        if (representation == AUDIO_CHANNEL_REPRESENTATION_INDEX) {
-            /* update params in case channel representation index.
-             * on returning error, flinger will retry with supported representation passed
-             */
-            ALOGD("%s: SSR supports only channel representation position, channel_mask(%#x)"
-                              ,__func__, config->channel_mask);
-            config->channel_mask = AUDIO_CHANNEL_IN_6;
-            ret = 0;
-            *update_params = true;
-        } else {
-            if (!audio_extn_ssr_init(in, channel_count)) {
-                ALOGD("%s: Created SSR session succesfully", __func__);
-                ret = 0;
-            } else {
-                ALOGE("%s: Unable to start SSR record session", __func__);
-            }
-        }
-    }
-    return ret;
-}
-
 static void pcm_buffer_queue_push(struct pcm_buffer_queue **queue,
                                   struct pcm_buffer_queue *node)
 {
@@ -440,12 +406,58 @@
     }
 }
 
-struct stream_in *audio_extn_ssr_get_stream()
+struct stream_in *ssr_get_stream()
 {
     return ssrmod.in;
 }
 
-int32_t audio_extn_ssr_init(struct stream_in *in, int num_out_chan)
+int32_t ssr_deinit()
+{
+    ALOGV("%s: entry", __func__);
+    deinit_ssr_process_thread();
+
+    if (ssrmod.drc_obj) {
+        ssrmod.drc_deinit(ssrmod.drc_obj);
+        ssrmod.drc_obj = NULL;
+    }
+
+    if (ssrmod.surround_obj) {
+
+        if (ssrmod.ssr_3mic) {
+            ssrmod.surround_rec_deinit(ssrmod.surround_obj);
+            ssrmod.surround_obj = NULL;
+        }
+        if (ssrmod.surround_raw_buffer) {
+            free(ssrmod.surround_raw_buffer);
+            ssrmod.surround_raw_buffer = NULL;
+        }
+        if (ssrmod.fp_input)
+            fclose(ssrmod.fp_input);
+        if (ssrmod.fp_output)
+            fclose(ssrmod.fp_output);
+    }
+
+    if(ssrmod.drc_handle) {
+        dlclose(ssrmod.drc_handle);
+        ssrmod.drc_handle = NULL;
+    }
+
+    if(ssrmod.surround_rec_handle) {
+        dlclose(ssrmod.surround_rec_handle);
+        ssrmod.surround_rec_handle = NULL;
+    }
+
+    ssrmod.in = NULL;
+    //SSR session can be closed due to device switch
+    //Do not force reset ssr mode
+
+    //ssrmod.is_ssr_mode_on = false;
+    ALOGV("%s: exit", __func__);
+
+    return 0;
+}
+
+int32_t ssr_init(struct stream_in *in, int num_out_chan)
 {
     uint32_t ret = -1;
     char c_multi_ch_dump[128] = {0};
@@ -455,10 +467,10 @@
 
     if (ssrmod.surround_obj != NULL) {
         ALOGV("%s: reinitializing surround sound library", __func__);
-        audio_extn_ssr_deinit();
+        ssr_deinit();
     }
 
-    if (audio_extn_ssr_get_enabled()) {
+    if (ssr_get_enabled()) {
         ssrmod.ssr_3mic = 1;
     } else {
         ALOGE(" Rejecting SSR -- init is called without enabling SSR");
@@ -577,54 +589,41 @@
     return 0;
 
 fail:
-    (void) audio_extn_ssr_deinit();
+    (void) ssr_deinit();
     return ret;
 }
 
-int32_t audio_extn_ssr_deinit()
+int ssr_set_usecase(struct stream_in *in,
+                               struct audio_config *config,
+                               bool *update_params)
 {
-    ALOGV("%s: entry", __func__);
-    deinit_ssr_process_thread();
+    int ret = -EINVAL;
+    int channel_count = audio_channel_count_from_in_mask(in->channel_mask);
+    audio_channel_representation_t representation =
+                  audio_channel_mask_get_representation(in->channel_mask);
+    *update_params = false;
 
-    if (ssrmod.drc_obj) {
-        ssrmod.drc_deinit(ssrmod.drc_obj);
-        ssrmod.drc_obj = NULL;
-    }
+    if (ssr_check_usecase(in)) {
 
-    if (ssrmod.surround_obj) {
-
-        if (ssrmod.ssr_3mic) {
-            ssrmod.surround_rec_deinit(ssrmod.surround_obj);
-            ssrmod.surround_obj = NULL;
+        if (representation == AUDIO_CHANNEL_REPRESENTATION_INDEX) {
+            /* update params in case channel representation index.
+             * on returning error, flinger will retry with supported representation passed
+             */
+            ALOGD("%s: SSR supports only channel representation position, channel_mask(%#x)"
+                              ,__func__, config->channel_mask);
+            config->channel_mask = AUDIO_CHANNEL_IN_6;
+            ret = 0;
+            *update_params = true;
+        } else {
+            if (!ssr_init(in, channel_count)) {
+                ALOGD("%s: Created SSR session succesfully", __func__);
+                ret = 0;
+            } else {
+                ALOGE("%s: Unable to start SSR record session", __func__);
+            }
         }
-        if (ssrmod.surround_raw_buffer) {
-            free(ssrmod.surround_raw_buffer);
-            ssrmod.surround_raw_buffer = NULL;
-        }
-        if (ssrmod.fp_input)
-            fclose(ssrmod.fp_input);
-        if (ssrmod.fp_output)
-            fclose(ssrmod.fp_output);
     }
-
-    if(ssrmod.drc_handle) {
-        dlclose(ssrmod.drc_handle);
-        ssrmod.drc_handle = NULL;
-    }
-
-    if(ssrmod.surround_rec_handle) {
-        dlclose(ssrmod.surround_rec_handle);
-        ssrmod.surround_rec_handle = NULL;
-    }
-
-    ssrmod.in = NULL;
-    //SSR session can be closed due to device switch
-    //Do not force reset ssr mode
-
-    //ssrmod.is_ssr_mode_on = false;
-    ALOGV("%s: exit", __func__);
-
-    return 0;
+    return ret;
 }
 
 static void *ssr_process_thread(void *context __unused)
@@ -699,7 +698,7 @@
     pthread_exit(NULL);
 }
 
-int32_t audio_extn_ssr_read(struct audio_stream_in *stream,
+int32_t ssr_read(struct audio_stream_in *stream,
                        void *buffer, size_t bytes)
 {
     struct stream_in *in = (struct stream_in *)stream;
@@ -755,7 +754,7 @@
     return ret;
 }
 
-void audio_extn_ssr_set_parameters(struct audio_device *adev __unused,
+void ssr_set_parameters(struct audio_device *adev __unused,
                                    struct str_parms *parms)
 {
     int err;
@@ -791,7 +790,7 @@
     }
 }
 
-void audio_extn_ssr_get_parameters(const struct audio_device *adev __unused,
+void ssr_get_parameters(const struct audio_device *adev __unused,
                                    struct str_parms *parms,
                                    struct str_parms *reply)
 {
@@ -822,4 +821,3 @@
     }
 }
 
-#endif /* SSR_ENABLED */
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 3b2f1b3..9981ef0 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -44,7 +44,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef USB_TUNNEL_ENABLED
 #define USB_BUFF_SIZE           2048
 #define CHANNEL_NUMBER_STR      "Channels: "
 #define PLAYBACK_PROFILE_STR    "Playback:"
@@ -117,6 +116,62 @@
     "Mic Playback Switch",
 };
 
+static const char * const usb_sidetone_volume_str[] = {
+    "Sidetone Playback Volume",
+    "Mic Playback Volume",
+};
+
+static int usb_get_sidetone_gain(struct usb_card_config *card_info)
+{
+    int gain = card_info->usb_sidetone_vol_min + usbmod->sidetone_gain;
+    if (gain > card_info->usb_sidetone_vol_max)
+        gain = card_info->usb_sidetone_vol_max;
+    return gain;
+}
+
+static void usb_get_sidetone_volume(struct usb_card_config *usb_card_info)
+{
+    struct mixer_ctl *ctl;
+    unsigned int index;
+
+    if (!audio_extn_usb_is_sidetone_volume_enabled())
+        return;
+
+    for (index = 0;
+         index < sizeof(usb_sidetone_volume_str)/sizeof(usb_sidetone_volume_str[0]);
+         index++) {
+        ctl = mixer_get_ctl_by_name(usb_card_info->usb_snd_mixer,
+                                    usb_sidetone_volume_str[index]);
+        if (ctl) {
+            usb_card_info->usb_sidetone_index[USB_SIDETONE_VOLUME_INDEX] = index;
+            usb_card_info->usb_sidetone_vol_min = mixer_ctl_get_range_min(ctl);
+            usb_card_info->usb_sidetone_vol_max = mixer_ctl_get_range_max(ctl);
+            break;
+        }
+    }
+}
+
+static void usb_set_sidetone_volume(struct usb_card_config *usb_card_info,
+                                        bool enable, int index)
+{
+    struct mixer_ctl *ctl;
+
+    if (!audio_extn_usb_is_sidetone_volume_enabled())
+        return;
+
+    ctl = mixer_get_ctl_by_name(usb_card_info->usb_snd_mixer,
+                                usb_sidetone_volume_str[index]);
+
+    if (ctl == NULL)
+        ALOGV("%s: sidetone gain mixer command is not found",
+              __func__);
+    else if (enable)
+        mixer_ctl_set_value(ctl, 0,
+                            usb_get_sidetone_gain(usb_card_info));
+}
+
+
+
 static void usb_mixer_print_enum(struct mixer_ctl *ctl)
 {
     unsigned int num_enums;
@@ -320,7 +375,7 @@
     return 0;
 }
 
-static int usb_get_service_interval(const char *interval_str_start,
+static int get_usb_service_interval(const char *interval_str_start,
                                     struct usb_device_config *usb_device_info)
 {
     unsigned long interval = 0;
@@ -530,7 +585,7 @@
         interval_str_start = strstr(str_start, DATA_PACKET_INTERVAL_STR);
         if (interval_str_start != NULL) {
             interval_str_start += strlen(DATA_PACKET_INTERVAL_STR);
-            ret = usb_get_service_interval(interval_str_start, usb_device_info);
+            ret = get_usb_service_interval(interval_str_start, usb_device_info);
             if (ret < 0) {
                 ALOGE("%s: error unable to get service interval, assume default",
                       __func__);
@@ -607,7 +662,7 @@
         }
     }
 
-    audio_extn_usb_get_sidetone_volume(usb_card_info);
+    usb_get_sidetone_volume(usb_card_info);
 
     if ((usb_card_info->usb_snd_mixer != NULL) && (usb_audio_debug_enable))
         usb_soundcard_list_controls(usb_card_info->usb_snd_mixer);
@@ -898,7 +953,7 @@
     return is_usb_supported;
 }
 
-void audio_extn_usb_set_sidetone_gain(struct str_parms *parms,
+void usb_set_sidetone_gain(struct str_parms *parms,
                                 char *value, int len)
 {
     int err;
@@ -914,7 +969,7 @@
     return;
 }
 
-int audio_extn_usb_enable_sidetone(int device, bool enable)
+int usb_enable_sidetone(int device, bool enable)
 {
     int ret = -ENODEV;
     struct listnode *node_i;
@@ -938,7 +993,7 @@
                     break;
 
                 if ((i = card_info->usb_sidetone_index[USB_SIDETONE_VOLUME_INDEX]) != -1) {
-                    audio_extn_usb_set_sidetone_volume(card_info, enable, i);
+                    usb_set_sidetone_volume(card_info, enable, i);
                 }
 
                 ret = 0;
@@ -949,7 +1004,7 @@
     return ret;
 }
 
-bool audio_extn_usb_is_config_supported(unsigned int *bit_width,
+bool usb_is_config_supported(unsigned int *bit_width,
                                         unsigned int *sample_rate,
                                         unsigned int *ch,
                                         bool is_playback)
@@ -982,7 +1037,7 @@
     return is_usb_supported;
 }
 
-int audio_extn_usb_get_max_channels(bool is_playback)
+int usb_get_max_channels(bool is_playback)
 {
     struct listnode *node_i, *node_j;
     struct usb_device_config *dev_info;
@@ -1004,7 +1059,7 @@
     return max_ch;
 }
 
-int audio_extn_usb_get_max_bit_width(bool is_playback)
+int usb_get_max_bit_width(bool is_playback)
 {
     struct listnode *node_i, *node_j;
     struct usb_device_config *dev_info;
@@ -1026,7 +1081,7 @@
     return max_bw;
 }
 
-int audio_extn_usb_get_sup_sample_rates(bool is_playback,
+int usb_get_sup_sample_rates(bool is_playback,
                                         uint32_t *sample_rates,
                                         uint32_t sample_rate_size)
 {
@@ -1046,7 +1101,7 @@
     return i;
 }
 
-bool audio_extn_usb_is_capture_supported()
+bool usb_is_capture_supported()
 {
     if (usbmod == NULL) {
         ALOGE("%s: USB device object is NULL", __func__);
@@ -1056,12 +1111,12 @@
     return usbmod->is_capture_supported;
 }
 
-bool audio_extn_usb_is_tunnel_supported()
+bool usb_is_tunnel_supported()
 {
     return true;
 }
 
-void audio_extn_usb_add_device(audio_devices_t device, int card)
+void usb_add_device(audio_devices_t device, int card)
 {
     struct usb_card_config *usb_card_info;
     char check_debug_enable[PROPERTY_VALUE_MAX];
@@ -1134,7 +1189,7 @@
     return;
 }
 
-void audio_extn_usb_remove_device(audio_devices_t device, int card)
+void usb_remove_device(audio_devices_t device, int card)
 {
     struct listnode *node_i, *temp_i;
     struct listnode *node_j, *temp_j;
@@ -1187,15 +1242,14 @@
     return;
 }
 
-bool audio_extn_usb_alive(int card) {
+bool usb_alive(int card) {
     char path[PATH_MAX] = {0};
     // snprintf should never fail
     (void) snprintf(path, sizeof(path), "/proc/asound/card%u/stream0", card);
     return access(path, F_OK) == 0;
 }
 
-#ifdef USB_BURST_MODE_ENABLED
-unsigned long audio_extn_usb_find_service_interval(bool min,
+unsigned long usb_find_service_interval(bool min,
                                                    bool playback) {
     struct usb_card_config *card_info = NULL;
     struct usb_device_config *dev_info = NULL;
@@ -1219,7 +1273,7 @@
     return interval_us;
 }
 
-int audio_extn_usb_altset_for_service_interval(bool playback,
+int usb_altset_for_service_interval(bool playback,
                                                unsigned long service_interval,
                                                uint32_t *bit_width,
                                                uint32_t *sample_rate,
@@ -1285,7 +1339,7 @@
 #undef SET_OR_RETURN_ON_ERROR
 }
 
-int audio_extn_usb_get_service_interval(bool playback,
+int usb_get_service_interval(bool playback,
                                         unsigned long *service_interval)
 {
     const char *ctl_name = "USB_AUDIO_RX service_interval";
@@ -1306,7 +1360,7 @@
     return 0;
 }
 
-int audio_extn_usb_set_service_interval(bool playback,
+int usb_set_service_interval(bool playback,
                                         unsigned long service_interval,
                                         bool *reconfig)
 {
@@ -1326,7 +1380,7 @@
         return -1;
     }
 
-    if (audio_extn_usb_get_service_interval(playback,
+    if (usb_get_service_interval(playback,
                                             &current_service_interval) != 0) {
         ALOGE("%s Unable to get current service interval", __func__);
         return -1;
@@ -1341,7 +1395,7 @@
     return 0;
 }
 
-int audio_extn_usb_check_and_set_svc_int(struct audio_usecase *uc_info,
+int usb_check_and_set_svc_int(struct audio_usecase *uc_info,
                                          bool starting_output_stream)
 {
     struct listnode *node = NULL;
@@ -1389,9 +1443,9 @@
     ALOGV("%s: burst mode(%d).", __func__,burst_mode);
 
     service_interval =
-            audio_extn_usb_find_service_interval(!burst_mode, true /*playback*/);
+            usb_find_service_interval(!burst_mode, true /*playback*/);
 
-    audio_extn_usb_set_service_interval(true /*playback*/,
+    usb_set_service_interval(true /*playback*/,
                                         service_interval,
                                         &reconfig);
 
@@ -1401,29 +1455,28 @@
     return 0;
 }
 
-bool audio_extn_usb_is_reconfig_req()
+bool usb_is_reconfig_req()
 {
     return usbmod->usb_reconfig;
 }
 
-void audio_extn_usb_set_reconfig(bool is_required)
+void usb_set_reconfig(bool is_required)
 {
     usbmod->usb_reconfig = is_required;
 }
-#endif /* USB_BURST_MODE_ENABLED end */
 
-bool audio_extn_usb_connected(struct str_parms *parms) {
+bool usb_connected(struct str_parms *parms) {
     int card = -1;
     struct listnode *node_i = NULL;
     struct usb_card_config *usb_card_info = NULL;
     bool usb_connected = false;
 
     if ((parms != NULL) && str_parms_get_int(parms, "card", &card) >= 0) {
-        usb_connected = audio_extn_usb_alive(card);
+        usb_connected = usb_alive(card);
     } else {
         list_for_each(node_i, &usbmod->usb_card_conf_list) {
             usb_card_info = node_to_item(node_i, struct usb_card_config, list);
-            if (audio_extn_usb_alive(usb_card_info->usb_card)) {
+            if (usb_alive(usb_card_info->usb_card)) {
                 usb_connected = true;
                 break;
             }
@@ -1432,7 +1485,7 @@
     return usb_connected;
 }
 
-void audio_extn_usb_init(void *adev)
+void usb_init(void *adev)
 {
     if (usbmod == NULL) {
         usbmod = calloc(1, sizeof(struct usb_module));
@@ -1453,61 +1506,10 @@
     return;
 }
 
-void audio_extn_usb_deinit(void)
+void usb_deinit(void)
 {
     if (NULL != usbmod){
         free(usbmod);
         usbmod = NULL;
     }
 }
-
-#ifdef USB_SIDETONE_VOLUME
-static const char * const usb_sidetone_volume_str[] = {
-    "Sidetone Playback Volume",
-    "Mic Playback Volume",
-};
-
-static int usb_get_sidetone_gain(struct usb_card_config *card_info)
-{
-    int gain = card_info->usb_sidetone_vol_min + usbmod->sidetone_gain;
-    if (gain > card_info->usb_sidetone_vol_max)
-        gain = card_info->usb_sidetone_vol_max;
-    return gain;
-}
-
-void audio_extn_usb_get_sidetone_volume(struct usb_card_config *usb_card_info)
-{
-    struct mixer_ctl *ctl;
-    unsigned int index;
-
-    for (index = 0;
-         index < sizeof(usb_sidetone_volume_str)/sizeof(usb_sidetone_volume_str[0]);
-         index++) {
-        ctl = mixer_get_ctl_by_name(usb_card_info->usb_snd_mixer,
-                                    usb_sidetone_volume_str[index]);
-        if (ctl) {
-            usb_card_info->usb_sidetone_index[USB_SIDETONE_VOLUME_INDEX] = index;
-            usb_card_info->usb_sidetone_vol_min = mixer_ctl_get_range_min(ctl);
-            usb_card_info->usb_sidetone_vol_max = mixer_ctl_get_range_max(ctl);
-            break;
-        }
-    }
-}
-
-void audio_extn_usb_set_sidetone_volume(struct usb_card_config *usb_card_info,
-                                        bool enable, int index)
-{
-    struct mixer_ctl *ctl;
-
-    ctl = mixer_get_ctl_by_name(usb_card_info->usb_snd_mixer,
-                                usb_sidetone_volume_str[index]);
-
-    if (ctl == NULL)
-        ALOGV("%s: sidetone gain mixer command is not found",
-              __func__);
-    else if (enable)
-        mixer_ctl_set_value(ctl, 0,
-                            usb_get_sidetone_gain(usb_card_info));
-}
-#endif /* USB_SIDETONE_VOLUME end */
-#endif /* USB_TUNNEL_ENABLED end */
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index ad4e4b8..0d43e02 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -164,7 +164,6 @@
     STRING_TO_ENUM(AUDIO_FORMAT_DTS_HD),
     STRING_TO_ENUM(AUDIO_FORMAT_DOLBY_TRUEHD),
     STRING_TO_ENUM(AUDIO_FORMAT_IEC61937),
-#ifdef AUDIO_EXTN_FORMATS_ENABLED
     STRING_TO_ENUM(AUDIO_FORMAT_E_AC3_JOC),
     STRING_TO_ENUM(AUDIO_FORMAT_WMA),
     STRING_TO_ENUM(AUDIO_FORMAT_WMA_PRO),
@@ -179,7 +178,6 @@
     STRING_TO_ENUM(AUDIO_FORMAT_FLAC),
     STRING_TO_ENUM(AUDIO_FORMAT_ALAC),
     STRING_TO_ENUM(AUDIO_FORMAT_APE),
-    STRING_TO_ENUM(AUDIO_FORMAT_E_AC3_JOC),
     STRING_TO_ENUM(AUDIO_FORMAT_AAC_LC),
     STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V1),
     STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V2),
@@ -193,7 +191,6 @@
     STRING_TO_ENUM(AUDIO_FORMAT_AAC_LATM_HE_V1),
     STRING_TO_ENUM(AUDIO_FORMAT_AAC_LATM_HE_V2),
     STRING_TO_ENUM(AUDIO_FORMAT_APTX),
-#endif
 };
 
 /* payload structure avt_device drift query */
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index f8c5563..37c749b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -61,7 +61,6 @@
 #include <cutils/properties.h>
 #include <cutils/atomic.h>
 #include <cutils/sched_policy.h>
-
 #include <hardware/audio_effect.h>
 #include <hardware/audio_alsaops.h>
 #include <system/thread_defs.h>
@@ -75,6 +74,7 @@
 #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"
@@ -103,13 +103,11 @@
 #define PROXY_OPEN_RETRY_COUNT           100
 #define PROXY_OPEN_WAIT_TIME             20
 
-#ifndef USE_DEEP_AS_PRIMARY_OUTPUT
-#define USECASE_AUDIO_PLAYBACK_PRIMARY USECASE_AUDIO_PLAYBACK_LOW_LATENCY
-#define PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY pcm_config_low_latency
-#else
-#define USECASE_AUDIO_PLAYBACK_PRIMARY USECASE_AUDIO_PLAYBACK_DEEP_BUFFER
-#define PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY pcm_config_deep_buffer
-#endif
+#define GET_USECASE_AUDIO_PLAYBACK_PRIMARY(db) \
+         (db)? USECASE_AUDIO_PLAYBACK_DEEP_BUFFER : \
+               USECASE_AUDIO_PLAYBACK_LOW_LATENCY
+#define GET_PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY(db) \
+         (db)? pcm_config_deep_buffer : pcm_config_low_latency
 
 #define ULL_PERIOD_SIZE (DEFAULT_OUTPUT_SAMPLING_RATE/1000)
 #define DEFAULT_VOIP_BUF_DURATION_MS 20
@@ -683,8 +681,7 @@
      return ret_val;
 }
 
-#ifdef MAXXAUDIO_QDSP_ENABLED
-bool audio_hw_send_ma_parameter(int stream_type, float vol, bool active)
+bool audio_hw_send_qdsp_parameter(int stream_type, float vol, bool active)
 {
     bool ret = false;
     ALOGV("%s: enter ...", __func__);
@@ -693,7 +690,7 @@
 
     if (adev != NULL && adev->platform != NULL) {
         pthread_mutex_lock(&adev->lock);
-        ret = audio_extn_ma_set_state(adev, stream_type, vol, active);
+        ret = audio_extn_qdsp_set_state(adev, stream_type, vol, active);
         pthread_mutex_unlock(&adev->lock);
     }
 
@@ -702,9 +699,6 @@
     ALOGV("%s: exit with ret %d", __func__, ret);
     return ret;
 }
-#else
-#define audio_hw_send_ma_parameter(stream_type, vol, active) (0)
-#endif
 
 static bool is_supported_format(audio_format_t format)
 {
@@ -880,7 +874,6 @@
     }
 }
 
-#ifdef DYNAMIC_ECNS_ENABLED
 static int send_effect_enable_disable_mixer_ctl(struct audio_device *adev,
                           struct audio_effect_config effect_config,
                           unsigned int param_value)
@@ -941,13 +934,16 @@
 }
 
 static int enable_disable_effect(struct audio_device *adev, int effect_type, bool enable)
-{
+{ 
     struct audio_effect_config effect_config;
     struct audio_usecase *usecase = NULL;
     int ret = 0;
     unsigned int param_value = 0;
     struct stream_in *in = adev->active_input;
 
+    if(!voice_extn_is_dynamic_ecns_enabled())
+        return ENOSYS;
+
     if (!in) {
         ALOGE("%s: Invalid input stream", __func__);
         return -EINVAL;
@@ -989,6 +985,8 @@
 
 static void check_and_enable_effect(struct audio_device *adev)
 {
+    if(!voice_extn_is_dynamic_ecns_enabled())
+        return;
 
     if (adev->active_input->enable_aec) {
         enable_disable_effect(adev, EFFECT_AEC, true);
@@ -999,10 +997,6 @@
         enable_disable_effect(adev, EFFECT_NS, true);
     }
 }
-#else
-#define enable_disable_effect(x, y, z) ENOSYS
-#define check_and_enable_effect(x) ENOSYS
-#endif
 
 int pcm_ioctl(struct pcm *pcm, int request, ...)
 {
@@ -2417,7 +2411,7 @@
     }
     enable_audio_route(adev, usecase);
 
-    audio_extn_ma_set_device(usecase);
+    audio_extn_qdsp_set_device(usecase);
 
     /* If input stream is already running then effect needs to be
        applied on the new input device that's being enabled here.  */
@@ -2892,7 +2886,7 @@
     int ret = 0;
 
     setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
-    set_sched_policy(0, SP_FOREGROUND);
+    //set_sched_policy(0, SP_FOREGROUND);
     prctl(PR_SET_NAME, (unsigned long)"Offload Callback", 0, 0, 0);
 
     ALOGV("%s", __func__);
@@ -4875,7 +4869,7 @@
             out->send_new_metadata = 0;
             if (out->send_next_track_params && out->is_compr_metadata_avail) {
                 ALOGD("copl(%p):send next track params in gapless", out);
-                compress_set_next_track_param(out->compr, &(out->compr_config.codec->options));
+                // compress_set_next_track_param(out->compr, &(out->compr_config.codec->options));
                 out->send_next_track_params = false;
                 out->is_compr_metadata_avail = false;
             }
@@ -4970,9 +4964,8 @@
                      __func__, frames, frame_size, bytes_to_write);
 
             if (out->usecase == USECASE_INCALL_MUSIC_UPLINK ||
-#ifndef COMPRESS_VOIP_ENABLED
-                out->usecase == USECASE_AUDIO_PLAYBACK_VOIP ||
-#endif
+                (out->usecase == USECASE_AUDIO_PLAYBACK_VOIP
+                    && !voice_extn_is_compress_voip_supported()) ||
                 out->usecase == USECASE_INCALL_MUSIC_UPLINK2) {
                 size_t channel_count = audio_channel_count_from_out_mask(out->channel_mask);
                 int16_t *src = (int16_t *)buffer;
@@ -6309,6 +6302,8 @@
     bool is_usb_dev = audio_is_usb_out_device(devices) &&
                       (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_AS_PRIMARY_OUTPUT);
 
     if (is_usb_dev && (!audio_extn_usb_connected(NULL))) {
         is_usb_dev = false;
@@ -6444,31 +6439,32 @@
         out->config.format = pcm_format_from_audio_format(out->format);
     }
 
-    /* Init use case and pcm_config */
-#ifndef COMPRESS_VOIP_ENABLED
-    if (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX) &&
-        (out->sample_rate == 8000 || out->sample_rate == 16000 ||
-         out->sample_rate == 32000 || out->sample_rate == 48000)) {
-        //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
-        out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
-        out->usecase = USECASE_AUDIO_PLAYBACK_VOIP;
-        out->format = AUDIO_FORMAT_PCM_16_BIT;
+    /* Check for VOIP usecase */
+    if(out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) {
+        if (!voice_extn_is_compress_voip_supported()) {
+            if (out->sample_rate == 8000 || out->sample_rate == 16000 ||
+             out->sample_rate == 32000 || out->sample_rate == 48000) {
+                //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
+                out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+                out->usecase = USECASE_AUDIO_PLAYBACK_VOIP;
+                out->format = AUDIO_FORMAT_PCM_16_BIT;
 
-        out->config = default_pcm_config_voip_copp;
-        out->config.period_size = VOIP_IO_BUF_SIZE(out->sample_rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
-        out->config.rate = out->sample_rate;
-
-#else
-    if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION || voice_extn_compress_voip_is_active(out->dev)) &&
-               (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) &&
-               (voice_extn_compress_voip_is_config_supported(config))) {
-        ret = voice_extn_compress_voip_open_output_stream(out);
-        if (ret != 0) {
-            ALOGE("%s: Compress voip output cannot be opened, error:%d",
-                  __func__, ret);
-            goto error_open;
+                out->config = default_pcm_config_voip_copp;
+                out->config.period_size = VOIP_IO_BUF_SIZE(out->sample_rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
+                out->config.rate = out->sample_rate;
+            }
+        } else {
+                if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
+                    voice_extn_compress_voip_is_active(out->dev)) &&
+                       (voice_extn_compress_voip_is_config_supported(config))) {
+                    ret = voice_extn_compress_voip_open_output_stream(out);
+                    if (ret != 0) {
+                        ALOGE("%s: Compress voip output cannot be opened, error:%d",
+                              __func__, ret);
+                        goto error_open;
+                    }
+                }
         }
-#endif
     } else if (audio_is_linear_pcm(out->format) &&
         out->flags == AUDIO_OUTPUT_FLAG_NONE && is_usb_dev) {
         out->channel_mask = config->channel_mask;
@@ -6900,8 +6896,8 @@
             out->config = pcm_config_deep_buffer;
         } else {
             /* primary path is the default path selected if no other outputs are available/suitable */
-            out->usecase = USECASE_AUDIO_PLAYBACK_PRIMARY;
-            out->config = PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY;
+            out->usecase = GET_USECASE_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary);
+            out->config = GET_PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary);
         }
         out->hal_ip_format = format = out->format;
         out->config.format = hal_format_to_pcm(out->hal_ip_format);
@@ -6936,7 +6932,7 @@
                                                 devices, out->flags, out->hal_op_format, out->sample_rate,
                                                 out->bit_width, out->channel_mask, out->profile,
                                                 &out->app_type_cfg);
-    if ((out->usecase == USECASE_AUDIO_PLAYBACK_PRIMARY) ||
+    if ((out->usecase == GET_USECASE_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary)) ||
         (flags & AUDIO_OUTPUT_FLAG_PRIMARY)) {
         /* Ensure the default output is not selected twice */
         if(adev->primary_output == NULL)
@@ -7271,7 +7267,7 @@
     }
 
     audio_extn_hfp_set_parameters(adev, parms);
-    audio_extn_ma_set_parameters(adev, parms);
+    audio_extn_qdsp_set_parameters(adev, parms);
 
     status = audio_extn_a2dp_set_parameters(parms, &a2dp_reconfig);
     if (ret >= 0 && a2dp_reconfig) {
@@ -7550,36 +7546,36 @@
                        config->sample_rate == 48000);
     bool valid_ch = audio_channel_count_from_in_mask(in->channel_mask) == 1;
 
-#ifndef COMPRESS_VOIP_ENABLED
-    if (valid_rate && valid_ch &&
+    if(!voice_extn_is_compress_voip_supported()) {
+        if (valid_rate && valid_ch &&
         in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) {
         in->usecase = USECASE_AUDIO_RECORD_VOIP;
         in->config = default_pcm_config_voip_copp;
         in->config.period_size = VOIP_IO_BUF_SIZE(in->sample_rate,
                                                   DEFAULT_VOIP_BUF_DURATION_MS,
                                                   DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
-    } else {
-        ALOGW("%s No valid input in voip, use defaults"
-               "sample rate %u, channel mask 0x%X",
-               __func__, config->sample_rate, in->channel_mask);
-    }
-    in->config.rate = config->sample_rate;
-    in->sample_rate = config->sample_rate;
-#else
-    //XXX needed for voice_extn_compress_voip_open_input_stream
-    in->config.rate = config->sample_rate;
-    if ((in->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
-         voice_extn_compress_voip_is_active(in->dev)) &&
-        (voice_extn_compress_voip_is_format_supported(in->format)) &&
-        valid_rate && valid_ch) {
-        voice_extn_compress_voip_open_input_stream(in);
-        // update rate entries to match config from AF
+        } else {
+            ALOGW("%s No valid input in voip, use defaults"
+                   "sample rate %u, channel mask 0x%X",
+                   __func__, config->sample_rate, in->channel_mask);
+        }
         in->config.rate = config->sample_rate;
         in->sample_rate = config->sample_rate;
     } else {
-        ALOGW("%s compress voip not active, use defaults", __func__);
+        //XXX needed for voice_extn_compress_voip_open_input_stream
+        in->config.rate = config->sample_rate;
+        if ((in->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
+             voice_extn_compress_voip_is_active(in->dev)) &&
+            (voice_extn_compress_voip_is_format_supported(in->format)) &&
+            valid_rate && valid_ch) {
+            voice_extn_compress_voip_open_input_stream(in);
+            // update rate entries to match config from AF
+            in->config.rate = config->sample_rate;
+            in->sample_rate = config->sample_rate;
+        } else {
+            ALOGW("%s compress voip not active, use defaults", __func__);
+        }
     }
-#endif
     return 0;
 }
 
@@ -8197,7 +8193,7 @@
         audio_extn_snd_mon_unregister_listener(adev);
         audio_extn_sound_trigger_deinit(adev);
         audio_extn_listen_deinit(adev);
-        audio_extn_ma_deinit();
+        audio_extn_qdsp_deinit();
         audio_extn_extspk_deinit(adev->extspk);
         audio_extn_utils_release_streams_cfg_lists(
                       &adev->streams_output_cfg_list,
@@ -8496,6 +8492,7 @@
         }
     }
     audio_extn_init(adev);
+    voice_extn_init(adev);
     audio_extn_listen_init(adev, adev->snd_card);
     audio_extn_gef_init(adev);
     audio_extn_hw_loopback_init(adev);
@@ -8613,7 +8610,7 @@
         ALOGV("new period_multiplier = %d", af_period_multiplier);
     }
 
-    audio_extn_ma_init(adev->platform);
+    audio_extn_qdsp_init(adev->platform);
 
     adev->multi_offload_enable = property_get_bool("vendor.audio.offload.multiple.enabled", false);
     pthread_mutex_unlock(&adev_init_lock);
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index eb2cecc..d5ae0fb 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4044,26 +4044,27 @@
          return my_data->ext_disp_type;
     }
 
-#ifdef DISPLAY_PORT_ENABLED
-    struct audio_device *adev = my_data->adev;
-    struct mixer_ctl *ctl;
-    char *mixer_ctl_name = "External Display Type";
+    if (audio_extn_is_display_port_enabled()) {
+        struct audio_device *adev = my_data->adev;
+        struct mixer_ctl *ctl;
+        char *mixer_ctl_name = "External Display Type";
 
-    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
-    if (!ctl) {
-        ALOGE("%s: Could not get ctl for mixer cmd - %s",
-              __func__, mixer_ctl_name);
-        return -EINVAL;
+        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+        if (!ctl) {
+            ALOGE("%s: Could not get ctl for mixer cmd - %s",
+                  __func__, mixer_ctl_name);
+            return -EINVAL;
+        }
+
+        disp_type = mixer_ctl_get_value(ctl, 0);
+        if (disp_type == EXT_DISPLAY_TYPE_NONE) {
+             ALOGE("%s: Invalid external display type: %d", __func__, disp_type);
+             return -EINVAL;
+        }
+    }else {
+            disp_type = EXT_DISPLAY_TYPE_HDMI;
     }
 
-    disp_type = mixer_ctl_get_value(ctl, 0);
-    if (disp_type == EXT_DISPLAY_TYPE_NONE) {
-         ALOGE("%s: Invalid external display type: %d", __func__, disp_type);
-         return -EINVAL;
-    }
-#else
-    disp_type = EXT_DISPLAY_TYPE_HDMI;
-#endif
     my_data->ext_disp_type = disp_type;
     ALOGD("%s: ext disp type:%s", __func__, (disp_type == EXT_DISPLAY_TYPE_DP) ? "DisplayPort" : "HDMI");
     return disp_type;
@@ -4395,8 +4396,7 @@
     return snd_device;
 }
 
-#ifdef DYNAMIC_ECNS_ENABLED
-static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+static snd_device_t get_snd_device_for_voice_comm_ecns_enabled(struct platform_data *my_data,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
@@ -4435,8 +4435,8 @@
 
     return snd_device;
 }
-#else
-static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+
+static snd_device_t get_snd_device_for_voice_comm_ecns_disabled(struct platform_data *my_data,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
@@ -4543,7 +4543,16 @@
 
     return snd_device;
 }
-#endif //DYNAMIC_ECNS_ENABLED
+
+static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+                                                  audio_devices_t out_device,
+                                                  audio_devices_t in_device)
+{
+    if(voice_extn_is_dynamic_ecns_enabled())
+        return get_snd_device_for_voice_comm_ecns_enabled(my_data, out_device, in_device);
+    else
+        return get_snd_device_for_voice_comm_ecns_disabled(my_data, out_device, in_device);
+}
 
 snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
 {
@@ -6206,17 +6215,17 @@
         max_supported_channels = platform_edid_get_max_channels(my_data);
 
         //Check EDID info for supported samplerate
-        if (!edid_is_supported_sr(edid_info,sample_rate)) {
+        if (!audio_extn_edid_is_supported_sr(edid_info,sample_rate)) {
             //check to see if current BE sample rate is supported by EDID
             //else assign the highest sample rate supported by EDID
-            if (edid_is_supported_sr(edid_info,my_data->current_backend_cfg[backend_idx].sample_rate))
+            if (audio_extn_edid_is_supported_sr(edid_info,my_data->current_backend_cfg[backend_idx].sample_rate))
                 sample_rate = my_data->current_backend_cfg[backend_idx].sample_rate;
             else
-                sample_rate = edid_get_highest_supported_sr(edid_info);
+                sample_rate = audio_extn_edid_get_highest_supported_sr(edid_info);
         }
 
         //Check EDID info for supported bit width
-        if (!edid_is_supported_bps(edid_info,bit_width)) {
+        if (!audio_extn_edid_is_supported_bps(edid_info,bit_width)) {
             //reset to current sample rate
             bit_width = my_data->current_backend_cfg[backend_idx].bit_width;
         }
@@ -7211,7 +7220,7 @@
     edid_data[0] = count;
     memcpy(&edid_data[1], block, count);
 
-    if (!edid_get_sink_caps(info, edid_data)) {
+    if (!audio_extn_edid_get_sink_caps(info, edid_data)) {
         ALOGE("%s: Failed to get extn disp sink capabilities", __func__);
         goto fail;
     }
@@ -7420,7 +7429,7 @@
     ret = platform_get_edid_info(platform);
     info = (edid_audio_info *)my_data->edid_info;
     if (ret == 0 && info != NULL) {
-        return edid_is_supported_sr(info, sample_rate);
+        return audio_extn_edid_is_supported_sr(info, sample_rate);
     }
 
     return false;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 37eae22..329da7b 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1477,10 +1477,10 @@
     }
 
     if (enable) {
-#ifndef COMPRESS_VOIP_ENABLED
-        if (adev->mode == AUDIO_MODE_IN_COMMUNICATION)
-            strlcat(ec_ref_mixer_path, "-voip", MIXER_PATH_MAX_LENGTH);
-#endif
+        if (!voice_extn_is_compress_voip_supported()) {
+            if (adev->mode == AUDIO_MODE_IN_COMMUNICATION)
+                strlcat(ec_ref_mixer_path, "-voip", MIXER_PATH_MAX_LENGTH);    
+        }        
         /*
          * If native audio device reference count > 0, then apply codec EC otherwise
          * fallback to Speakers with VBat if enabled or default
@@ -4473,27 +4473,26 @@
          return my_data->ext_disp_type;
     }
 
-#ifdef DISPLAY_PORT_ENABLED
-    struct audio_device *adev = my_data->adev;
-    struct mixer_ctl *ctl;
-    char *mixer_ctl_name = "External Display Type";
+    if (audio_extn_is_display_port_enabled()) {
+        struct audio_device *adev = my_data->adev;
+        struct mixer_ctl *ctl;
+        char *mixer_ctl_name = "External Display Type";
 
-    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
-    if (!ctl) {
-        ALOGE("%s: Could not get ctl for mixer cmd - %s",
-              __func__, mixer_ctl_name);
-        return -EINVAL;
+        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+        if (!ctl) {
+            ALOGE("%s: Could not get ctl for mixer cmd - %s",
+                  __func__, mixer_ctl_name);
+            return -EINVAL;
+        }
+
+        disp_type = mixer_ctl_get_value(ctl, 0);
+        if (disp_type == EXT_DISPLAY_TYPE_NONE) {
+             ALOGE("%s: Invalid external display type: %d", __func__, disp_type);
+             return -EINVAL;
+        }
+    } else {
+        disp_type = EXT_DISPLAY_TYPE_HDMI;
     }
-
-    disp_type = mixer_ctl_get_value(ctl, 0);
-    if (disp_type == EXT_DISPLAY_TYPE_NONE) {
-         ALOGE("%s: Invalid external display type: %d", __func__, disp_type);
-         return -EINVAL;
-    }
-#else
-    disp_type = EXT_DISPLAY_TYPE_HDMI;
-#endif
-
     my_data->ext_disp_type = disp_type;
     ALOGD("%s: ext disp type:%s", __func__, (disp_type == EXT_DISPLAY_TYPE_DP) ? "DisplayPort" : "HDMI");
     return disp_type;
@@ -4835,7 +4834,7 @@
     } else if (devices &
                 (AUDIO_DEVICE_OUT_USB_DEVICE |
                  AUDIO_DEVICE_OUT_USB_HEADSET)) {
-        if (audio_extn_ma_supported_usb())
+        if (audio_extn_qdsp_supported_usb())
             snd_device = SND_DEVICE_OUT_USB_HEADSET_SPEC;
         else if (audio_extn_usb_is_capture_supported())
             snd_device = SND_DEVICE_OUT_USB_HEADSET;
@@ -4862,8 +4861,7 @@
     return snd_device;
 }
 
-#ifdef DYNAMIC_ECNS_ENABLED
-static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+static snd_device_t get_snd_device_for_voice_comm_ecns_enabled(struct platform_data *my_data,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
@@ -4906,8 +4904,8 @@
 
     return snd_device;
 }
-#else
-static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+
+static snd_device_t get_snd_device_for_voice_comm_ecns_disabled(struct platform_data *my_data,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
@@ -5032,7 +5030,16 @@
 
     return snd_device;
 }
-#endif //DYNAMIC_ECNS_ENABLED
+
+static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+                                                  audio_devices_t out_device,
+                                                  audio_devices_t in_device)
+{
+    if(voice_extn_is_dynamic_ecns_enabled())
+        return get_snd_device_for_voice_comm_ecns_enabled(my_data, out_device, in_device);
+    else
+        return get_snd_device_for_voice_comm_ecns_disabled(my_data, out_device, in_device);
+}
 
 snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
 {
@@ -7098,17 +7105,17 @@
         max_supported_channels = platform_edid_get_max_channels(my_data);
 
         //Check EDID info for supported samplerate
-        if (!edid_is_supported_sr(edid_info,sample_rate)) {
+        if (!audio_extn_edid_is_supported_sr(edid_info,sample_rate)) {
             //check to see if current BE sample rate is supported by EDID
             //else assign the highest sample rate supported by EDID
-            if (edid_is_supported_sr(edid_info,my_data->current_backend_cfg[backend_idx].sample_rate))
+            if (audio_extn_edid_is_supported_sr(edid_info,my_data->current_backend_cfg[backend_idx].sample_rate))
                 sample_rate = my_data->current_backend_cfg[backend_idx].sample_rate;
             else
-                sample_rate = edid_get_highest_supported_sr(edid_info);
+                sample_rate = audio_extn_edid_get_highest_supported_sr(edid_info);
         }
 
         //Check EDID info for supported bit width
-        if (!edid_is_supported_bps(edid_info,bit_width)) {
+        if (!audio_extn_edid_is_supported_bps(edid_info,bit_width)) {
             //reset to current sample rate
             bit_width = my_data->current_backend_cfg[backend_idx].bit_width;
         }
@@ -8128,7 +8135,7 @@
     edid_data[0] = count;
     memcpy(&edid_data[1], block, count);
 
-    if (!edid_get_sink_caps(info, edid_data)) {
+    if (!audio_extn_edid_get_sink_caps(info, edid_data)) {
         ALOGE("%s: Failed to get extn disp sink capabilities", __func__);
         goto fail;
     }
@@ -8433,7 +8440,7 @@
     ret = platform_get_edid_info(platform);
     info = (edid_audio_info *)my_data->edid_info;
     if (ret == 0 && info != NULL) {
-        return edid_is_supported_sr(info, sample_rate);
+        return audio_extn_edid_is_supported_sr(info, sample_rate);
     }
 
     return false;
@@ -8448,7 +8455,7 @@
     ret = platform_get_edid_info(platform);
     info = (edid_audio_info *)my_data->edid_info;
     if (ret == 0 && info != NULL) {
-        return edid_get_highest_supported_sr(info);
+        return audio_extn_edid_get_highest_supported_sr(info);
     }
 
     return 0;
@@ -9423,3 +9430,4 @@
 {
     return -ENOSYS;
 }
+
diff --git a/hal/voice.h b/hal/voice.h
index d257e1b..9612edd 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -23,11 +23,7 @@
 #define BASE_SESS_IDX       0
 #define VOICE_SESS_IDX     (BASE_SESS_IDX)
 
-#ifdef MULTI_VOICE_SESSION_ENABLED
 #define MAX_VOICE_SESSIONS 7
-#else
-#define MAX_VOICE_SESSIONS 1
-#endif
 
 #define BASE_CALL_STATE     1
 #define CALL_INACTIVE       (BASE_CALL_STATE)
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 890f508..003a3ed 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -250,6 +250,404 @@
     return 0;
 }
 
+int compress_voip_set_parameters(struct audio_device *adev,
+                                             struct str_parms *parms)
+{
+    char value[32]={0};
+    int ret = 0, err, rate;
+    bool flag;
+    char *kv_pairs = str_parms_to_str(parms);
+
+    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
+
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
+                            value, sizeof(value));
+    if (err >= 0) {
+        rate = atoi(value);
+        voip_set_rate(adev, rate);
+    }
+
+    memset(value, 0, sizeof(value));
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_DTX_MODE,
+                            value, sizeof(value));
+    if (err >= 0) {
+        flag = false;
+        if (strcmp(value, AUDIO_PARAMETER_VALUE_VOIP_TRUE) == 0)
+            flag = true;
+        voip_set_dtx(adev, flag);
+    }
+
+    ALOGV("%s: exit", __func__);
+    free(kv_pairs);
+    return ret;
+}
+
+void compress_voip_get_parameters(struct str_parms *query,
+                                             struct str_parms *reply)
+{
+    int ret;
+    char value[32]={0};
+
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
+                            value, sizeof(value));
+    if (ret >= 0) {
+        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
+                          voip_data.out_stream_count);
+    }
+
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
+                            value, sizeof(value));
+    if (ret >= 0) {
+        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
+                          voip_data.sample_rate);
+    }
+}
+
+void compress_voip_out_get_parameters(struct stream_out *out,
+                                                 struct str_parms *query,
+                                                 struct str_parms *reply)
+{
+    int ret;
+    char value[32]={0};
+
+    ALOGD("%s: enter", __func__);
+
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_CHECK, value, sizeof(value));
+
+    if (ret >= 0) {
+        if (out->usecase == USECASE_COMPRESS_VOIP_CALL)
+            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, true);
+        else
+            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
+    }
+
+    ALOGV("%s: exit", __func__);
+}
+
+void compress_voip_in_get_parameters(struct stream_in *in,
+                                                struct str_parms *query,
+                                                struct str_parms *reply)
+{
+    int ret;
+    char value[32]={0};
+    char *kv_pairs = NULL;
+
+    ALOGV("%s: enter", __func__);
+
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_CHECK, value, sizeof(value));
+
+    if (ret >= 0) {
+        if (in->usecase == USECASE_COMPRESS_VOIP_CALL)
+            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, true);
+        else
+            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
+    }
+
+    kv_pairs = str_parms_to_str(reply);
+    ALOGD_IF(kv_pairs != NULL, "%s: exit: return - %s", __func__, kv_pairs);
+    free(kv_pairs);
+}
+
+int compress_voip_out_get_buffer_size(struct stream_out *out)
+{
+    if (out->config.rate == 48000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_FB;
+    else if (out->config.rate== 32000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_SWB;
+    else if (out->config.rate == 16000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_WB;
+    else
+        return COMPRESS_VOIP_IO_BUF_SIZE_NB;
+
+}
+
+int compress_voip_in_get_buffer_size(struct stream_in *in)
+{
+    if (in->config.rate == 48000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_FB;
+    else if (in->config.rate== 32000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_SWB;
+    else if (in->config.rate == 16000)
+        return COMPRESS_VOIP_IO_BUF_SIZE_WB;
+    else
+        return COMPRESS_VOIP_IO_BUF_SIZE_NB;
+}
+
+int compress_voip_open_output_stream(struct stream_out *out)
+{
+    int ret;
+
+    ALOGD("%s: enter", __func__);
+
+    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_MONO;
+    out->channel_mask = AUDIO_CHANNEL_OUT_MONO;
+    out->usecase = USECASE_COMPRESS_VOIP_CALL;
+    if (out->sample_rate == 48000)
+        out->config = pcm_config_voip_fb;
+    else if (out->sample_rate == 32000)
+        out->config = pcm_config_voip_swb;
+    else if (out->sample_rate == 16000)
+        out->config = pcm_config_voip_wb;
+    else
+        out->config = pcm_config_voip_nb;
+
+    voip_data.out_stream = out;
+    voip_data.out_stream_count++;
+    voip_data.sample_rate = out->sample_rate;
+    ret = voip_set_mode(out->dev, out->format);
+
+    ALOGV("%s: exit", __func__);
+    return ret;
+}
+
+int compress_voip_open_input_stream(struct stream_in *in)
+{
+    int ret;
+
+    ALOGD("%s: enter", __func__);
+
+    if ((voip_data.sample_rate != 0) &&
+        (voip_data.sample_rate != in->config.rate)) {
+        ret = -ENOTSUP;
+        goto done;
+    } else {
+        voip_data.sample_rate = in->config.rate;
+    }
+
+    ret = voip_set_mode(in->dev, in->format);
+    if (ret < 0)
+        goto done;
+
+    in->usecase = USECASE_COMPRESS_VOIP_CALL;
+    if (in->config.rate == 48000)
+        in->config = pcm_config_voip_fb;
+    else if (in->config.rate == 32000)
+        in->config = pcm_config_voip_swb;
+    else if (in->config.rate == 16000)
+        in->config = pcm_config_voip_wb;
+    else
+        in->config = pcm_config_voip_nb;
+
+    voip_data.in_stream_count++;
+
+done:
+    ALOGV("%s: exit, ret=%d", __func__, ret);
+    return ret;
+}
+
+int compress_voip_start_output_stream(struct stream_out *out)
+{
+    int ret = 0;
+    struct audio_device *adev = out->dev;
+    struct audio_usecase *uc_info;
+
+    ALOGD("%s: enter", __func__);
+
+    if (CARD_STATUS_OFFLINE == out->card_status ||
+        CARD_STATUS_OFFLINE == adev->card_status) {
+        ret = -ENETRESET;
+        ALOGE("%s: sound card is not active/SSR returning error %d ", __func__, ret);
+        goto error;
+    }
+
+    if (out->devices & AUDIO_DEVICE_OUT_ALL_SCO) {
+         if (!adev->bt_sco_on) {
+             ALOGE("%s: SCO profile is not ready, return error", __func__);
+             ret = -EAGAIN;
+             goto error;
+         }
+    }
+
+    if (!voip_data.out_stream_count)
+        ret = compress_voip_open_output_stream(out);
+
+    ret = voip_start_call(adev, &out->config);
+    out->pcm = voip_data.pcm_rx;
+    uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
+    if (uc_info) {
+        uc_info->stream.out = out;
+        uc_info->devices = out->devices;
+    } else {
+        ret = -EINVAL;
+        ALOGE("%s: exit(%d): failed to get use case info", __func__, ret);
+        goto error;
+    }
+
+error:
+    ALOGV("%s: exit: status(%d)", __func__, ret);
+    return ret;
+}
+
+int compress_voip_start_input_stream(struct stream_in *in)
+{
+    int ret = 0;
+    struct audio_device *adev = in->dev;
+
+    ALOGD("%s: enter", __func__);
+
+    if (CARD_STATUS_OFFLINE == in->card_status ||
+        CARD_STATUS_OFFLINE == adev->card_status) {
+        ret = -ENETRESET;
+        ALOGE("%s: sound card is not active/SSR returning error %d ", __func__, ret);
+        goto error;
+    }
+
+    if (audio_is_bluetooth_sco_device(in->device) && !adev->bt_sco_on) {
+        ret = -EIO;
+        ALOGE("%s SCO is not ready return error %d", __func__,ret);
+        goto error;
+    }
+
+    if (!voip_data.in_stream_count)
+        ret = compress_voip_open_input_stream(in);
+
+    adev->active_input = in;
+    ret = voip_start_call(adev, &in->config);
+    in->pcm = voip_data.pcm_tx;
+
+error:
+    ALOGV("%s: exit: status(%d)", __func__, ret);
+    return ret;
+}
+
+int compress_voip_close_output_stream(struct audio_stream *stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    struct audio_device *adev = out->dev;
+    int ret = 0;
+
+    ALOGD("%s: enter", __func__);
+    if (voip_data.out_stream_count > 0) {
+        voip_data.out_stream_count--;
+        ret = voip_stop_call(adev);
+        voip_data.out_stream = NULL;
+        out->pcm = NULL;
+    }
+
+    ALOGV("%s: exit: status(%d)", __func__, ret);
+    return ret;
+}
+
+int compress_voip_close_input_stream(struct audio_stream *stream)
+{
+    struct stream_in *in = (struct stream_in *)stream;
+    struct audio_device *adev = in->dev;
+    int status = 0;
+
+    ALOGD("%s: enter", __func__);
+
+    if(voip_data.in_stream_count > 0) {
+       voip_data.in_stream_count--;
+       status = voip_stop_call(adev);
+       adev->active_input = get_next_active_input(adev);
+       in->pcm = NULL;
+    }
+
+    ALOGV("%s: exit: status(%d)", __func__, status);
+    return status;
+}
+
+
+int compress_voip_set_volume(struct audio_device *adev, float volume)
+{
+    int vol, err = 0;
+
+    ALOGV("%s: enter", __func__);
+
+    if (volume < 0.0) {
+        volume = 0.0;
+    } else if (volume > 1.0) {
+        volume = 1.0;
+    }
+
+    vol = lrint(volume * 100.0);
+
+    /* Voice volume levels from android are mapped to driver volume levels as follows.
+     * 0 -> 5, 20 -> 4, 40 ->3, 60 -> 2, 80 -> 1, 100 -> 0
+     * So adjust the volume to get the correct volume index in driver
+     */
+    vol = 100 - vol;
+
+    err = voip_set_volume(adev, vol);
+
+    ALOGV("%s: exit: status(%d)", __func__, err);
+
+    return err;
+}
+
+int compress_voip_set_mic_mute(struct audio_device *adev, bool state)
+{
+    int err = 0;
+
+    ALOGV("%s: enter", __func__);
+
+    err = voip_set_mic_mute(adev, state);
+
+    ALOGV("%s: exit: status(%d)", __func__, err);
+    return err;
+}
+
+bool compress_voip_pcm_prop_check()
+{
+    char prop_value[PROPERTY_VALUE_MAX] = {0};
+
+    property_get("vendor.voice.path.for.pcm.voip", prop_value, "0");
+    if (!strncmp("true", prop_value, sizeof("true")))
+    {
+        ALOGD("%s: VoIP PCM property is enabled", __func__);
+        return true;
+    }
+    else
+        return false;
+}
+
+bool compress_voip_is_active(const struct audio_device *adev)
+{
+    struct audio_usecase *voip_usecase = NULL;
+    voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
+
+    if (voip_usecase != NULL)
+        return true;
+    else
+        return false;
+}
+
+bool compress_voip_is_format_supported(audio_format_t format)
+{
+    if (format == AUDIO_FORMAT_PCM_16_BIT &&
+       compress_voip_pcm_prop_check())
+       return true;
+    else
+       return false;
+}
+
+bool compress_voip_is_config_supported(struct audio_config *config)
+{
+    bool ret = false;
+
+    ret = compress_voip_is_format_supported(config->format);
+    if (ret) {
+        if ((popcount(config->channel_mask) == 1) &&
+            (config->sample_rate == 8000 || config->sample_rate == 16000 ||
+             config->sample_rate == 32000 || config->sample_rate == 48000))
+            ret = ((voip_data.sample_rate == 0) ? true:
+                    (voip_data.sample_rate == config->sample_rate));
+        else
+            ret = false;
+    }
+    return ret;
+}
+
+bool compress_voip_is_started(struct audio_device *adev)
+{
+    bool ret = false;
+    if (compress_voip_is_active(adev) &&
+        voip_data.pcm_tx && voip_data.pcm_rx)
+        ret = true;
+
+    return ret;
+}
+
 static int voip_stop_call(struct audio_device *adev)
 {
     int ret = 0;
@@ -401,7 +799,7 @@
         pcm_start(voip_data.pcm_rx);
 
         voice_set_sidetone(adev, uc_info->out_snd_device, true);
-        voice_extn_compress_voip_set_volume(adev, adev->voice.volume);
+        compress_voip_set_volume(adev, adev->voice.volume);
     } else {
         ALOGV("%s: voip usecase is already enabled", __func__);
         if (voip_data.out_stream)
@@ -418,401 +816,4 @@
 
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
-}
-
-int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
-                                             struct str_parms *parms)
-{
-    char value[32]={0};
-    int ret = 0, err, rate;
-    bool flag;
-    char *kv_pairs = str_parms_to_str(parms);
-
-    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
-
-    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
-                            value, sizeof(value));
-    if (err >= 0) {
-        rate = atoi(value);
-        voip_set_rate(adev, rate);
-    }
-
-    memset(value, 0, sizeof(value));
-    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_DTX_MODE,
-                            value, sizeof(value));
-    if (err >= 0) {
-        flag = false;
-        if (strcmp(value, AUDIO_PARAMETER_VALUE_VOIP_TRUE) == 0)
-            flag = true;
-        voip_set_dtx(adev, flag);
-    }
-
-    ALOGV("%s: exit", __func__);
-    free(kv_pairs);
-    return ret;
-}
-
-void voice_extn_compress_voip_get_parameters(struct str_parms *query,
-                                             struct str_parms *reply)
-{
-    int ret;
-    char value[32]={0};
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
-                            value, sizeof(value));
-    if (ret >= 0) {
-        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
-                          voip_data.out_stream_count);
-    }
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
-                            value, sizeof(value));
-    if (ret >= 0) {
-        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
-                          voip_data.sample_rate);
-    }
-}
-
-void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
-                                                 struct str_parms *query,
-                                                 struct str_parms *reply)
-{
-    int ret;
-    char value[32]={0};
-
-    ALOGD("%s: enter", __func__);
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_CHECK, value, sizeof(value));
-
-    if (ret >= 0) {
-        if (out->usecase == USECASE_COMPRESS_VOIP_CALL)
-            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, true);
-        else
-            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
-    }
-
-    ALOGV("%s: exit", __func__);
-}
-
-void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
-                                                struct str_parms *query,
-                                                struct str_parms *reply)
-{
-    int ret;
-    char value[32]={0};
-    char *kv_pairs = NULL;
-
-    ALOGV("%s: enter", __func__);
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_CHECK, value, sizeof(value));
-
-    if (ret >= 0) {
-        if (in->usecase == USECASE_COMPRESS_VOIP_CALL)
-            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, true);
-        else
-            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
-    }
-
-    kv_pairs = str_parms_to_str(reply);
-    ALOGD_IF(kv_pairs != NULL, "%s: exit: return - %s", __func__, kv_pairs);
-    free(kv_pairs);
-}
-
-int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *out)
-{
-    if (out->config.rate == 48000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_FB;
-    else if (out->config.rate== 32000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_SWB;
-    else if (out->config.rate == 16000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_WB;
-    else
-        return COMPRESS_VOIP_IO_BUF_SIZE_NB;
-
-}
-
-int voice_extn_compress_voip_in_get_buffer_size(struct stream_in *in)
-{
-    if (in->config.rate == 48000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_FB;
-    else if (in->config.rate== 32000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_SWB;
-    else if (in->config.rate == 16000)
-        return COMPRESS_VOIP_IO_BUF_SIZE_WB;
-    else
-        return COMPRESS_VOIP_IO_BUF_SIZE_NB;
-}
-
-int voice_extn_compress_voip_start_output_stream(struct stream_out *out)
-{
-    int ret = 0;
-    struct audio_device *adev = out->dev;
-    struct audio_usecase *uc_info;
-
-    ALOGD("%s: enter", __func__);
-
-    if (CARD_STATUS_OFFLINE == out->card_status ||
-        CARD_STATUS_OFFLINE == adev->card_status) {
-        ret = -ENETRESET;
-        ALOGE("%s: sound card is not active/SSR returning error %d ", __func__, ret);
-        goto error;
-    }
-
-    if (out->devices & AUDIO_DEVICE_OUT_ALL_SCO) {
-         if (!adev->bt_sco_on) {
-             ALOGE("%s: SCO profile is not ready, return error", __func__);
-             ret = -EAGAIN;
-             goto error;
-         }
-    }
-
-    if (!voip_data.out_stream_count)
-        ret = voice_extn_compress_voip_open_output_stream(out);
-
-    ret = voip_start_call(adev, &out->config);
-    out->pcm = voip_data.pcm_rx;
-    uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
-    if (uc_info) {
-        uc_info->stream.out = out;
-        uc_info->devices = out->devices;
-    } else {
-        ret = -EINVAL;
-        ALOGE("%s: exit(%d): failed to get use case info", __func__, ret);
-        goto error;
-    }
-
-error:
-    ALOGV("%s: exit: status(%d)", __func__, ret);
-    return ret;
-}
-
-int voice_extn_compress_voip_start_input_stream(struct stream_in *in)
-{
-    int ret = 0;
-    struct audio_device *adev = in->dev;
-
-    ALOGD("%s: enter", __func__);
-
-    if (CARD_STATUS_OFFLINE == in->card_status ||
-        CARD_STATUS_OFFLINE == adev->card_status) {
-        ret = -ENETRESET;
-        ALOGE("%s: sound card is not active/SSR returning error %d ", __func__, ret);
-        goto error;
-    }
-
-    if (audio_is_bluetooth_sco_device(in->device) && !adev->bt_sco_on) {
-        ret = -EIO;
-        ALOGE("%s SCO is not ready return error %d", __func__,ret);
-        goto error;
-    }
-
-    if (!voip_data.in_stream_count)
-        ret = voice_extn_compress_voip_open_input_stream(in);
-
-    adev->active_input = in;
-    ret = voip_start_call(adev, &in->config);
-    in->pcm = voip_data.pcm_tx;
-
-error:
-    ALOGV("%s: exit: status(%d)", __func__, ret);
-    return ret;
-}
-
-int voice_extn_compress_voip_close_output_stream(struct audio_stream *stream)
-{
-    struct stream_out *out = (struct stream_out *)stream;
-    struct audio_device *adev = out->dev;
-    int ret = 0;
-
-    ALOGD("%s: enter", __func__);
-    if (voip_data.out_stream_count > 0) {
-        voip_data.out_stream_count--;
-        ret = voip_stop_call(adev);
-        voip_data.out_stream = NULL;
-        out->pcm = NULL;
-    }
-
-    ALOGV("%s: exit: status(%d)", __func__, ret);
-    return ret;
-}
-
-int voice_extn_compress_voip_open_output_stream(struct stream_out *out)
-{
-    int ret;
-
-    ALOGD("%s: enter", __func__);
-
-    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_MONO;
-    out->channel_mask = AUDIO_CHANNEL_OUT_MONO;
-    out->usecase = USECASE_COMPRESS_VOIP_CALL;
-    if (out->sample_rate == 48000)
-        out->config = pcm_config_voip_fb;
-    else if (out->sample_rate == 32000)
-        out->config = pcm_config_voip_swb;
-    else if (out->sample_rate == 16000)
-        out->config = pcm_config_voip_wb;
-    else
-        out->config = pcm_config_voip_nb;
-
-    voip_data.out_stream = out;
-    voip_data.out_stream_count++;
-    voip_data.sample_rate = out->sample_rate;
-    ret = voip_set_mode(out->dev, out->format);
-
-    ALOGV("%s: exit", __func__);
-    return ret;
-}
-
-int voice_extn_compress_voip_close_input_stream(struct audio_stream *stream)
-{
-    struct stream_in *in = (struct stream_in *)stream;
-    struct audio_device *adev = in->dev;
-    int status = 0;
-
-    ALOGD("%s: enter", __func__);
-
-    if(voip_data.in_stream_count > 0) {
-       voip_data.in_stream_count--;
-       status = voip_stop_call(adev);
-       adev->active_input = get_next_active_input(adev);
-       in->pcm = NULL;
-    }
-
-    ALOGV("%s: exit: status(%d)", __func__, status);
-    return status;
-}
-
-int voice_extn_compress_voip_open_input_stream(struct stream_in *in)
-{
-    int ret;
-
-    ALOGD("%s: enter", __func__);
-
-    if ((voip_data.sample_rate != 0) &&
-        (voip_data.sample_rate != in->config.rate)) {
-        ret = -ENOTSUP;
-        goto done;
-    } else {
-        voip_data.sample_rate = in->config.rate;
-    }
-
-    ret = voip_set_mode(in->dev, in->format);
-    if (ret < 0)
-        goto done;
-
-    in->usecase = USECASE_COMPRESS_VOIP_CALL;
-    if (in->config.rate == 48000)
-        in->config = pcm_config_voip_fb;
-    else if (in->config.rate == 32000)
-        in->config = pcm_config_voip_swb;
-    else if (in->config.rate == 16000)
-        in->config = pcm_config_voip_wb;
-    else
-        in->config = pcm_config_voip_nb;
-
-    voip_data.in_stream_count++;
-
-done:
-    ALOGV("%s: exit, ret=%d", __func__, ret);
-    return ret;
-}
-
-int voice_extn_compress_voip_set_volume(struct audio_device *adev, float volume)
-{
-    int vol, err = 0;
-
-    ALOGV("%s: enter", __func__);
-
-    if (volume < 0.0) {
-        volume = 0.0;
-    } else if (volume > 1.0) {
-        volume = 1.0;
-    }
-
-    vol = lrint(volume * 100.0);
-
-    /* Voice volume levels from android are mapped to driver volume levels as follows.
-     * 0 -> 5, 20 -> 4, 40 ->3, 60 -> 2, 80 -> 1, 100 -> 0
-     * So adjust the volume to get the correct volume index in driver
-     */
-    vol = 100 - vol;
-
-    err = voip_set_volume(adev, vol);
-
-    ALOGV("%s: exit: status(%d)", __func__, err);
-
-    return err;
-}
-
-int voice_extn_compress_voip_set_mic_mute(struct audio_device *adev, bool state)
-{
-    int err = 0;
-
-    ALOGV("%s: enter", __func__);
-
-    err = voip_set_mic_mute(adev, state);
-
-    ALOGV("%s: exit: status(%d)", __func__, err);
-    return err;
-}
-
-bool voice_extn_compress_voip_pcm_prop_check()
-{
-    char prop_value[PROPERTY_VALUE_MAX] = {0};
-
-    property_get("vendor.voice.path.for.pcm.voip", prop_value, "0");
-    if (!strncmp("true", prop_value, sizeof("true")))
-    {
-        ALOGD("%s: VoIP PCM property is enabled", __func__);
-        return true;
-    }
-    else
-        return false;
-}
-
-bool voice_extn_compress_voip_is_active(const struct audio_device *adev)
-{
-    struct audio_usecase *voip_usecase = NULL;
-    voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
-
-    if (voip_usecase != NULL)
-        return true;
-    else
-        return false;
-}
-
-bool voice_extn_compress_voip_is_format_supported(audio_format_t format)
-{
-    if (format == AUDIO_FORMAT_PCM_16_BIT &&
-       voice_extn_compress_voip_pcm_prop_check())
-       return true;
-    else
-       return false;
-}
-
-bool voice_extn_compress_voip_is_config_supported(struct audio_config *config)
-{
-    bool ret = false;
-
-    ret = voice_extn_compress_voip_is_format_supported(config->format);
-    if (ret) {
-        if ((popcount(config->channel_mask) == 1) &&
-            (config->sample_rate == 8000 || config->sample_rate == 16000 ||
-             config->sample_rate == 32000 || config->sample_rate == 48000))
-            ret = ((voip_data.sample_rate == 0) ? true:
-                    (voip_data.sample_rate == config->sample_rate));
-        else
-            ret = false;
-    }
-    return ret;
-}
-
-bool voice_extn_compress_voip_is_started(struct audio_device *adev)
-{
-    bool ret = false;
-    if (voice_extn_compress_voip_is_active(adev) &&
-        voip_data.pcm_tx && voip_data.pcm_rx)
-        ret = true;
-
-    return ret;
-}
+}
\ No newline at end of file
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index b170608..b6a1879 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -35,6 +35,7 @@
 #include "platform.h"
 #include "platform_api.h"
 #include "voice_extn.h"
+#include "audio_feature_manager.h"
 
 #ifdef DYNAMIC_LOG_ENABLED
 #include <log_xml_parser.h>
@@ -83,8 +84,37 @@
     .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
 };
 
+static bool voice_extn_compress_voip_enabled = false;
+static bool voice_extn_dynamic_ecns_feature_enabled = false;
+
 int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active);
 
+int compress_voip_set_parameters(struct audio_device *adev,
+                                             struct str_parms *parms);
+void compress_voip_get_parameters(struct str_parms *query,
+                                             struct str_parms *reply);
+void compress_voip_out_get_parameters(struct stream_out *out,
+                                                 struct str_parms *query,
+                                                 struct str_parms *reply);
+void compress_voip_in_get_parameters(struct stream_in *in,
+                                                struct str_parms *query,
+                                                struct str_parms *reply);
+int compress_voip_out_get_buffer_size(struct stream_out *out);
+int compress_voip_in_get_buffer_size(struct stream_in *in);
+int compress_voip_start_output_stream(struct stream_out *out);
+int compress_voip_start_input_stream(struct stream_in *in);
+int compress_voip_close_output_stream(struct audio_stream *stream);
+int compress_voip_open_output_stream(struct stream_out *out);
+int compress_voip_close_input_stream(struct audio_stream *stream);
+int compress_voip_open_input_stream(struct stream_in *in);
+int compress_voip_set_volume(struct audio_device *adev, float volume);
+int compress_voip_set_mic_mute(struct audio_device *adev, bool state);
+bool compress_voip_pcm_prop_check();
+bool compress_voip_is_active(const struct audio_device *adev);
+bool compress_voip_is_format_supported(audio_format_t format);
+bool compress_voip_is_config_supported(struct audio_config *config);
+bool compress_voip_is_started(struct audio_device *adev);
+
 static bool is_valid_call_state(int call_state)
 {
     if (call_state < CALL_INACTIVE || call_state > CALL_LOCAL_HOLD)
@@ -360,6 +390,36 @@
     return 0;
 }
 
+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");
+}
+
+bool voice_extn_is_dynamic_ecns_enabled()
+{
+    return voice_extn_dynamic_ecns_feature_enabled;
+}
+
+void voice_extn_feature_init()
+{
+    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;
+            default:
+                break;
+        }
+    }
+}
+
 void voice_extn_init(struct audio_device *adev)
 {
     adev->voice.session[VOICE_SESS_IDX].vsid =  VOICE_VSID;
@@ -369,6 +429,18 @@
     adev->voice.session[VOWLAN_SESS_IDX].vsid = VOWLAN_VSID;
     adev->voice.session[MMODE1_SESS_IDX].vsid = VOICEMMODE1_VSID;
     adev->voice.session[MMODE2_SESS_IDX].vsid = VOICEMMODE2_VSID;
+    voice_extn_feature_init();
+}
+
+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,
@@ -576,7 +648,10 @@
         }
         str_parms_add_str(reply, AUDIO_PARAMETER_KEY_ALL_CALL_STATES, value);
     }
-    voice_extn_compress_voip_get_parameters(query, reply);
+    if(voice_extn_compress_voip_enabled)
+        voice_extn_compress_voip_get_parameters(query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
 
     str = str_parms_to_str(reply);
     ALOGV_IF(str != NULL, "%s: exit: returns \"%s\"", __func__, str);
@@ -587,14 +662,21 @@
                                    struct str_parms *query,
                                    struct str_parms *reply)
 {
-    voice_extn_compress_voip_out_get_parameters(out, query, reply);
+    if(voice_extn_compress_voip_enabled)
+        voice_extn_compress_voip_out_get_parameters(out, query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
 }
 
 void voice_extn_in_get_parameters(struct stream_in *in,
                                   struct str_parms *query,
                                   struct str_parms *reply)
 {
-    voice_extn_compress_voip_in_get_parameters(in, query, reply);
+    if(voice_extn_compress_voip_enabled)
+        voice_extn_compress_voip_in_get_parameters(in, query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    
 }
 
 #ifdef INCALL_MUSIC_ENABLED
@@ -612,3 +694,199 @@
     return 0;
 }
 #endif
+
+int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
+                                             struct str_parms *parms) 
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_set_parameters(adev, parms);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+void voice_extn_compress_voip_get_parameters(struct str_parms *query,
+                                             struct str_parms *reply)
+{
+    if(voice_extn_compress_voip_enabled)
+        compress_voip_get_parameters(query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+}
+
+
+void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
+                                                 struct str_parms *query,
+                                                 struct str_parms *reply)
+{
+    if(voice_extn_compress_voip_enabled)
+        compress_voip_out_get_parameters(out, query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+}
+
+void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
+                                                struct str_parms *query,
+                                                struct str_parms *reply)
+{
+    if(voice_extn_compress_voip_enabled)
+        compress_voip_in_get_parameters(in, query, reply);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+}
+
+int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *out)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_out_get_buffer_size(out);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+int voice_extn_compress_voip_in_get_buffer_size(struct stream_in *in)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_in_get_buffer_size(in);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+
+int voice_extn_compress_voip_start_output_stream(struct stream_out *out)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_start_output_stream(out);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+
+int voice_extn_compress_voip_start_input_stream(struct stream_in *in)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_start_input_stream(in);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+int voice_extn_compress_voip_close_output_stream(struct audio_stream *stream)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_close_output_stream(stream);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+
+int voice_extn_compress_voip_close_input_stream(struct audio_stream *stream)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_close_input_stream(stream);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+int voice_extn_compress_voip_open_output_stream(struct stream_out *out)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_open_output_stream(out);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+
+int voice_extn_compress_voip_open_input_stream(struct stream_in *in)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_open_input_stream(in);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+int voice_extn_compress_voip_set_volume(struct audio_device *adev, float volume)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_set_volume(adev, volume);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+int voice_extn_compress_voip_set_mic_mute(struct audio_device *adev, bool state)
+{
+    int ret = -1;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_set_mic_mute(adev, state);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+bool voice_extn_compress_voip_pcm_prop_check()
+{
+    bool ret = false;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_pcm_prop_check();
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+bool voice_extn_compress_voip_is_active(const struct audio_device *adev)
+{
+    bool ret = false;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_is_active(adev);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+bool voice_extn_compress_voip_is_format_supported(audio_format_t format)
+{
+    bool ret = false;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_is_format_supported(format);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+bool voice_extn_compress_voip_is_config_supported(struct audio_config *config)
+{
+    bool ret = false;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_is_config_supported(config);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
+bool voice_extn_compress_voip_is_started(struct audio_device *adev)
+{
+    bool ret = false;
+    if(voice_extn_compress_voip_enabled)
+        ret = compress_voip_is_started(adev);
+    else
+        ALOGE("%s: COMPRESS_VOIP feature is not enabled", __func__);
+    return ret;
+}
+
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index 69ec3b7..51afe47 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -20,13 +20,12 @@
 #ifndef VOICE_EXTN_H
 #define VOICE_EXTN_H
 
-#ifdef MULTI_VOICE_SESSION_ENABLED
+void voice_extn_init(struct audio_device *adev);
 int voice_extn_start_call(struct audio_device *adev);
 int voice_extn_stop_call(struct audio_device *adev);
 int voice_extn_get_session_from_use_case(struct audio_device *adev,
                                          const audio_usecase_t usecase_id,
                                          struct voice_session **session);
-void voice_extn_init(struct audio_device *adev);
 int voice_extn_set_parameters(struct audio_device *adev,
                               struct str_parms *parms);
 void voice_extn_get_parameters(const struct audio_device *adev,
@@ -53,68 +52,9 @@
     return -ENOSYS;
 }
 #endif
-#else
-static int __unused voice_extn_start_call(struct audio_device *adev __unused)
-{
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_stop_call(struct audio_device *adev __unused)
-{
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_get_session_from_use_case(struct audio_device *adev __unused,
-                                                const audio_usecase_t usecase_id __unused,
-                                                struct voice_session **session __unused)
-{
-    return -ENOSYS;
-}
-
-static void __unused voice_extn_init(struct audio_device *adev __unused)
-{
-}
-
-static int __unused voice_extn_set_parameters(struct audio_device *adev __unused,
-                                     struct str_parms *parms __unused)
-{
-    return -ENOSYS;
-}
-
-static void __unused voice_extn_get_parameters(const struct audio_device *adev __unused,
-                                      struct str_parms *query __unused,
-                                      struct str_parms *reply __unused)
-{
-}
-
-static int __unused voice_extn_is_call_state_active(struct audio_device *adev __unused,
-                                           bool *is_call_active __unused)
-{
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_get_active_session_id(struct audio_device *adev __unused,
-                                            uint32_t *session_id __unused)
-{
-    return -ENOSYS;
-}
-
-static void __unused voice_extn_in_get_parameters(struct stream_in *in __unused,
-                                         struct str_parms *query __unused,
-                                         struct str_parms *reply __unused)
-{
-}
-
-static void __unused voice_extn_out_get_parameters(struct stream_out *out __unused,
-                                          struct str_parms *query __unused,
-                                          struct str_parms *reply __unused)
-{
-}
-#endif
 
 int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                   struct stream_out *out);
-#ifdef COMPRESS_VOIP_ENABLED
 int voice_extn_compress_voip_close_output_stream(struct audio_stream *stream);
 int voice_extn_compress_voip_open_output_stream(struct stream_out *out);
 
@@ -148,153 +88,11 @@
 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);
-#else
-static int __unused voice_extn_compress_voip_close_output_stream(
-                                     struct audio_stream *stream __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
+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);
+bool voice_extn_is_dynamic_ecns_enabled();
 
-static int __unused voice_extn_compress_voip_open_output_stream(
-                                         struct stream_out *out __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_close_input_stream(
-                                    struct audio_stream *stream __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_open_input_stream(
-                                          struct stream_in *in __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_out_get_buffer_size(
-                                       struct stream_out *stream __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_in_get_buffer_size(
-                                           struct stream_in *in __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_start_input_stream(
-                                           struct stream_in *in __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_start_output_stream(
-                                          struct stream_out *out __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_set_mic_mute(
-                                struct audio_device *adev __unused,
-                                bool state __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return 0;
-}
-
-static int __unused voice_extn_compress_voip_set_volume(
-                              struct audio_device *adev __unused,
-                              float volume __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return 0;
-}
-
-static int __unused voice_extn_compress_voip_select_devices(
-                                  struct audio_device *adev __unused,
-                                  snd_device_t *out_snd_device __unused,
-                                  snd_device_t *in_snd_device __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static int __unused voice_extn_compress_voip_set_parameters(
-                                  struct audio_device *adev __unused,
-                                  struct str_parms *parms __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return -ENOSYS;
-}
-
-static void __unused voice_extn_compress_voip_get_parameters(
-                                     struct str_parms *query __unused,
-                                     struct str_parms *reply __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-}
-
-static void __unused voice_extn_compress_voip_out_get_parameters(
-                                          struct stream_out *out __unused,
-                                          struct str_parms *query __unused,
-                                          struct str_parms *reply __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-}
-
-static void __unused voice_extn_compress_voip_in_get_parameters(
-                                           struct stream_in *in __unused,
-                                           struct str_parms *query __unused,
-                                           struct str_parms *reply __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-}
-
-static bool __unused voice_extn_compress_voip_pcm_prop_check()
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return false;
-}
-
-static bool __unused  voice_extn_compress_voip_is_active(
-                         const struct audio_device *adev __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return false;
-}
-
-static bool __unused voice_extn_compress_voip_is_format_supported(
-                                            audio_format_t format __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return true;
-}
-
-static bool __unused voice_extn_compress_voip_is_config_supported(
-                                      struct audio_config *config __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return true;
-}
-
-static bool __unused voice_extn_compress_voip_is_started(
-                               struct audio_device *adev __unused)
-{
-    ALOGV("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
-    return false;
-}
-
-#endif
 
 #endif //VOICE_EXTN_H
diff --git a/post_proc/Android.mk b/post_proc/Android.mk
index fcaf378..86bbf98 100644
--- a/post_proc/Android.mk
+++ b/post_proc/Android.mk
@@ -3,6 +3,7 @@
 
 include $(CLEAR_VARS)
 
+LOCAL_CFLAGS := -DLIB_AUDIO_HAL="/vendor/lib/hw/audio.primary."$(TARGET_BOARD_PLATFORM)".so"
 LOCAL_CFLAGS += -Wno-unused-variable
 LOCAL_CFLAGS += -Wno-sign-compare
 LOCAL_CFLAGS += -Wno-unused-parameter
@@ -29,17 +30,13 @@
         virtualizer.c \
         reverb.c \
         effect_api.c \
-        effect_util.c
+        effect_util.c \
+        asphere.c
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS)),true)
-    LOCAL_CFLAGS += -DHW_ACCELERATED_EFFECTS
-    LOCAL_SRC_FILES += hw_accelerator.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUDIOSPHERE)),true)
-    LOCAL_CFLAGS += -DAUDIOSPHERE_ENABLED
-    LOCAL_SRC_FILES += asphere.c
-endif
+# HW_ACCELERATED has been disabled by default since msm8996. File doesn't
+# compile cleanly on tip so don't want to include it, but keeping this
+# as a reference.
+# LOCAL_SRC_FILES += hw_accelerator.c
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INSTANCE_ID)), true)
     LOCAL_CFLAGS += -DINSTANCE_ID_ENABLED
@@ -84,7 +81,8 @@
         external/tinyalsa/include \
         $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
 	$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include \
-        $(call include-path-for, audio-effects)
+        $(call include-path-for, audio-effects) \
+        vendor/qcom/opensource/audio-hal/primary-hal/hal/audio_extn/
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
   LOCAL_HEADER_LIBRARIES += audio_kernel_headers
diff --git a/post_proc/Makefile.am b/post_proc/Makefile.am
index 54602a2..bd29473 100644
--- a/post_proc/Makefile.am
+++ b/post_proc/Makefile.am
@@ -20,7 +20,6 @@
 endif
 
 if AUDIOSPHERE
-AM_CFLAGS += -DAUDIOSPHERE_ENABLED
 c_sources += asphere.c
 endif
 
diff --git a/post_proc/asphere.c b/post_proc/asphere.c
index 54555d3..0ff55e5 100644
--- a/post_proc/asphere.c
+++ b/post_proc/asphere.c
@@ -33,6 +33,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <dlfcn.h>
 #include <stdbool.h>
 #include <sys/stat.h>
 #include <log/log.h>
@@ -41,6 +42,7 @@
 #include <cutils/properties.h>
 #include <hardware/audio_effect.h>
 #include <pthread.h>
+#include <audio_feature_manager.h>
 #include "bundle.h"
 #include "equalizer.h"
 #include "bass_boost.h"
@@ -56,6 +58,10 @@
 
 #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,
@@ -84,6 +90,7 @@
 
 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)
 {
@@ -162,9 +169,26 @@
 static void asphere_init_once() {
     ALOGD("%s", __func__);
     pthread_mutex_init(&asphere.lock, NULL);
-    asphere.init_status = 1;
-    asphere_get_values_from_mixer();
-    asphere_create_app_notification_node();
+
+    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_enable")) != 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);
+
+    asphere.init_status = 0;
 }
 
 static int asphere_init() {
@@ -179,14 +203,8 @@
     bool enable = false;
     int strength = -1;
     char value[32] = {0};
-    char propValue[PROPERTY_VALUE_MAX] = {0};
     bool set_enable = false, set_strength = false;
 
-    if (!property_get("vendor.audio.pp.asphere.enabled", propValue, "false") ||
-        (strncmp("true", propValue, 4) != 0)) {
-        ALOGV("%s: property not set!!! not doing anything", __func__);
-        return;
-    }
     if (asphere_init() != 1) {
         ALOGW("%s: init check failed!!!", __func__);
         return;
@@ -221,14 +239,8 @@
                                       struct str_parms *reply)
 {
     char value[32] = {0};
-    char propValue[PROPERTY_VALUE_MAX] = {0};
     int ret;
 
-    if (!property_get("vendor.audio.pp.asphere.enabled", propValue, "false") ||
-        (strncmp("true", propValue, 4) != 0)) {
-        ALOGV("%s: property not set!!! not doing anything", __func__);
-        return;
-    }
     if (asphere_init() != 1) {
         ALOGW("%s: init check failed!!!", __func__);
         return;
@@ -278,14 +290,8 @@
                                       struct listnode *created_effects)
 {
     struct listnode *node;
-    char propValue[PROPERTY_VALUE_MAX] = {0};
 
     ALOGV("%s: effect %0x", __func__, context->desc->type.timeLow);
-    if (!property_get("vendor.audio.pp.asphere.enabled", propValue, "false") ||
-        (strncmp("true", propValue, 4) != 0)) {
-        ALOGV("%s: property not set!!! not doing anything", __func__);
-        return;
-    }
     if (asphere_init() != 1) {
         ALOGW("%s: init check failed!!!", __func__);
         return;
diff --git a/post_proc/asphere.h b/post_proc/asphere.h
index d0e6830..3babd1d 100644
--- a/post_proc/asphere.h
+++ b/post_proc/asphere.h
@@ -34,17 +34,11 @@
 #include <cutils/list.h>
 #include "bundle.h"
 
-#ifdef AUDIOSPHERE_ENABLED
 void asphere_get_parameters(struct str_parms *query,
                             struct str_parms *reply);
 void asphere_set_parameters(struct str_parms *reply);
 void handle_asphere_on_effect_enabled(bool enable,
                                       effect_context_t *context,
                                       struct listnode *created_effects);
-#else
-#define asphere_get_parameters(query, reply) (0)
-#define asphere_set_parameters(parms)  (0)
-#define handle_asphere_on_effect_enabled(enable, context, created_effects) (0)
-#endif /* AUDIOSPHERE_ENABLED */
 
 #endif /* OFFLOAD_ASPHERE_H_ */
diff --git a/post_proc/ma_listener.c b/post_proc/ma_listener.c
index 02d45d3..04a9047 100644
--- a/post_proc/ma_listener.c
+++ b/post_proc/ma_listener.c
@@ -42,7 +42,8 @@
                                                             i == AUDIO_STREAM_NOTIFICATION ? "Notification":\
                                                             "--INVALID--"); \
 
-#define MA_SET_STATE "audio_hw_send_ma_parameter"
+
+#define MA_SET_STATE "audio_hw_send_qdsp_parameter"
 #define HAL_VENDOR_PATH "/vendor/lib/hw"
 
 enum {
diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c
index 0750052..f8a488f 100644
--- a/post_proc/virtualizer.c
+++ b/post_proc/virtualizer.c
@@ -25,12 +25,21 @@
 #include <tinyalsa/asoundlib.h>
 #include <sound/audio_effects.h>
 #include <audio_effects/effect_virtualizer.h>
+#include <audio_feature_manager.h>
+#include <dlfcn.h>
+#include <unistd.h>
 
 #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()
@@ -104,13 +113,16 @@
  *  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;
+    }
+
     switch (device) {
     case AUDIO_DEVICE_OUT_SPEAKER:
     case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
     case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
-#ifdef AFE_PROXY_ENABLED
-    case AUDIO_DEVICE_OUT_PROXY:
-#endif
     case AUDIO_DEVICE_OUT_AUX_DIGITAL:
     case AUDIO_DEVICE_OUT_USB_ACCESSORY:
     case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:
@@ -470,6 +482,20 @@
     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_enable");
+            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;