hal: QCV changes for remaining HAL compile time feature
flags

Removed all feature flags except those that are hardware
specific, legacy features, non-LA features.
Moved following features to runtime enable:
- HFP
- EXT_HW_PLUGIN
- HDMI_PASSTHROUGH
- BATTERY_LISTENER
- INCALL_MUSIC
- CONCURRENT_CAPTURE
- COMPRESS_IN_CAPTURE
- HWDEP_CAL
- RECORD_PLAY_CONCURRENCY

Disabled AUTO_HAL compiletime flag temporarily after
discussing with Derek Chen. Will be re-enabled as
runtime flag later.
Change-Id: I55a58ca405b58be99e1873a5198fa201c0525725
diff --git a/hal/Android.mk b/hal/Android.mk
index f98f9c1..e3396bb 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -111,252 +111,27 @@
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 LOCAL_SRC_FILES := \
+    ahal_config_helper.cpp \
     audio_hw.c \
-    voice.c \
+    acdb.c \
     platform_info.c \
     $(AUDIO_PLATFORM)/platform.c \
-    acdb.c \
-    ahal_config_helper.cpp
+    voice.c
 
 LOCAL_SRC_FILES += audio_extn/audio_extn.c \
                    audio_extn/audio_feature_manager.c \
                    audio_extn/audio_hidl.cpp \
-                   audio_extn/utils.c \
-                   audio_extn/source_track.c \
-                   voice_extn/voice_extn.c \
+                   audio_extn/compress_in.c \
                    audio_extn/fm.c \
+                   audio_extn/keep_alive.c \
+                   audio_extn/source_track.c \
+                   audio_extn/usb.c \
+                   audio_extn/utils.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
-
-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
-endif
-
-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_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_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_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_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_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
-    LOCAL_SRC_FILES += audio_extn/usb.c
-#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_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
-
-# 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_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_DTS_EAGLE)),true)
-    LOCAL_CFLAGS += -DDTS_EAGLE
-    LOCAL_SRC_FILES += audio_extn/dts_eagle.c
-endif
-
-ifeq ($(strip $(DOLBY_DDP)),true)
-    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
-    LOCAL_SRC_FILES += audio_extn/dolby.c
-endif
-
-ifeq ($(strip $(DS1_DOLBY_DAP)),true)
-    LOCAL_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
-ifneq ($(strip $(DOLBY_DDP)),true)
-    LOCAL_SRC_FILES += audio_extn/dolby.c
-endif
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
-    LOCAL_CFLAGS += -DFLAC_OFFLOAD_ENABLED
-#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VORBIS_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
-#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_WMA_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DWMA_OFFLOAD_ENABLED
-#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DALAC_OFFLOAD_ENABLED
-#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_APE_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DAPE_OFFLOAD_ENABLED
-#    LOCAL_CFLAGS += -DCOMPRESS_METADATA_NEEDED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24)),true)
-       LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED_24
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AAC_ADTS_OFFLOAD)),true)
-    LOCAL_CFLAGS += -DAAC_ADTS_OFFLOAD_ENABLED
-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
-
-# 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
-    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
-ifneq ($(strip $(DOLBY_DDP)),true)
-    ifneq ($(strip $(DS1_DOLBY_DAP)),true)
-        LOCAL_SRC_FILES += audio_extn/dolby.c
-    endif
-endif
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH)),true)
-    LOCAL_CFLAGS += -DHDMI_PASSTHROUGH_ENABLED
-    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
-
-#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
-    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/qaf/
-    LOCAL_SRC_FILES += audio_extn/qaf.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE)),true)
-    LOCAL_CFLAGS += -DCONCURRENT_CAPTURE_ENABLED
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_INPUT)),true)
-    LOCAL_CFLAGS += -DCOMPRESS_INPUT_ENABLED
-    LOCAL_SRC_FILES += audio_extn/compress_in.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE)),true)
-    LOCAL_CFLAGS += -DCONCURRENT_CAPTURE_ENABLED
-endif
-
-ifeq ($(strip $(BOARD_SUPPORTS_QAHW)),true)
-    LOCAL_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
-    LOCAL_SRC_FILES += audio_hw_extn_api.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_BT_HAL)),true)
-    LOCAL_CFLAGS += -DAUDIO_EXTN_BT_HAL_ENABLED
-    LOCAL_SRC_FILES += audio_extn/bt_hal.c
-endif
+                   voice_extn/voice_extn.c
 
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     liblog \
     libcutils \
     libtinyalsa \
@@ -368,7 +143,8 @@
     libhwbinder \
     libhidlbase \
     libhidltransport \
-    libprocessgroup
+    libprocessgroup \
+    libutils
 
 LOCAL_C_INCLUDES += \
     external/tinyalsa/include \
@@ -382,46 +158,114 @@
     $(LOCAL_PATH)/audio_extn \
     $(LOCAL_PATH)/voice_extn
 
+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
+
+
+# Hardware specific feature
+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
+endif
+
+LOCAL_CFLAGS += -DUSE_VENDOR_EXTN
+
+# Legacy feature
+ifdef MULTIPLE_HW_VARIANTS_ENABLED
+  LOCAL_CFLAGS += -DHW_VARIANTS_ENABLED
+  LOCAL_SRC_FILES += $(AUDIO_PLATFORM)/hw_info.c
+endif
+
+# Legacy feature
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DTS_EAGLE)),true)
+    LOCAL_CFLAGS += -DDTS_EAGLE
+    LOCAL_SRC_FILES += audio_extn/dts_eagle.c
+endif
+
+# Legacy feature
+ifeq ($(strip $(DOLBY_DDP)),true)
+    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
+    LOCAL_SRC_FILES += audio_extn/dolby.c
+endif
+
+# Legacy feature
+ifeq ($(strip $(DS1_DOLBY_DAP)),true)
+    LOCAL_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
+ifneq ($(strip $(DOLBY_DDP)),true)
+    LOCAL_SRC_FILES += audio_extn/dolby.c
+endif
+endif
+
+# Legacy feature
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
+    LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
+    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
+ifneq ($(strip $(DOLBY_DDP)),true)
+    ifneq ($(strip $(DS1_DOLBY_DAP)),true)
+        LOCAL_SRC_FILES += audio_extn/dolby.c
+    endif
+endif
+endif
+
+# NonLA feature
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAF)),true)
+    LOCAL_CFLAGS += -DQAF_EXTN_ENABLED
+    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/qaf/
+    LOCAL_SRC_FILES += audio_extn/qaf.c
+endif
+
+# Hardware specific feature
+ifeq ($(strip $(BOARD_SUPPORTS_QAHW)),true)
+    LOCAL_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
+    LOCAL_SRC_FILES += audio_hw_extn_api.c
+endif
+
+# Hardware specific feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true)
     LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED
     LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-listen
     LOCAL_SRC_FILES += audio_extn/listen.c
 endif
 
+# Hardware specific feature
 ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true)
         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
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_SUPPORTED_EXTERNAL_BT)),true)
   LOCAL_CFLAGS += -DEXTERNAL_BT_SUPPORTED
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_FLICKER_SENSOR_INPUT)),true)
   LOCAL_CFLAGS += -DFLICKER_SENSOR_INPUT
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_NO_AUDIO_OUT)),true)
   LOCAL_CFLAGS += -DNO_AUDIO_OUT
 endif
 
+#  NonLA feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXT_HDMI)),true)
     LOCAL_CFLAGS += -DAUDIO_EXTERNAL_HDMI_ENABLED
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH)),true)
-    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-parsers
-    LOCAL_SHARED_LIBRARIES += libaudioparsers
-endif
 endif
 
+# Hardware specific feature
 ifeq ($(strip $(BOARD_SUPPORTS_SOUND_TRIGGER)),true)
     ST_FEATURE_ENABLE := true
 endif
 
+# Hardware specific feature
 ifeq ($(strip $(BOARD_SUPPORTS_SOUND_TRIGGER_HAL)),true)
     ST_FEATURE_ENABLE := true
 endif
 
+# Hardware specific feature
 ifeq ($(ST_FEATURE_ENABLE), true)
     LOCAL_CFLAGS += -DSOUND_TRIGGER_ENABLED
     LOCAL_CFLAGS += -DSOUND_TRIGGER_PLATFORM_NAME=$(TARGET_BOARD_PLATFORM)
@@ -432,10 +276,12 @@
 endif
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUXPCM_BT)),true)
     LOCAL_CFLAGS += -DAUXPCM_BT_ENABLED
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PM_SUPPORT)),true)
     LOCAL_CFLAGS += -DPM_SUPPORT_ENABLED
     LOCAL_SRC_FILES += audio_extn/pm.c
@@ -443,52 +289,44 @@
     LOCAL_SHARED_LIBRARIES += libperipheral_client
 endif
 
-# ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DISPLAY_PORT)),true)
-#     LOCAL_CFLAGS += -DDISPLAY_PORT_ENABLED
-# endif
 
+# Hardare specific featre
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GEF_SUPPORT)),true)
     LOCAL_CFLAGS += -DAUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
     LOCAL_SRC_FILES += audio_extn/gef.c
 endif
 
+# Hardware specific feature
 ifeq ($(strip $($AUDIO_FEATURE_ADSP_HDLR_ENABLED)),true)
     LOCAL_CFLAGS += -DAUDIO_EXTN_ADSP_HDLR_ENABLED
     LOCAL_SRC_FILES += audio_extn/adsp_hdlr.c
 endif
 
+
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DYNAMIC_LOG)), true)
     LOCAL_CFLAGS += -DDYNAMIC_LOG_ENABLED
     LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-log-utils
     LOCAL_SHARED_LIBRARIES += libaudio_log_utils
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DYNAMIC_ECNS)),true)
-    LOCAL_CFLAGS += -DDYNAMIC_ECNS_ENABLED
-endif
-
+# Hardware specific feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INSTANCE_ID)), true)
     LOCAL_CFLAGS += -DINSTANCE_ID_ENABLED
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_BATTERY_LISTENER)), true)
-    LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED
-    LOCAL_SRC_FILES += audio_extn/battery_listener.cpp
-    LOCAL_SHARED_LIBRARIES += android.hardware.health@1.0 android.hardware.health@2.0 \
-                              libbase libutils android.hardware.power@1.2
-    LOCAL_STATIC_LIBRARIES := libhealthhalutils
-endif
-
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KEEP_ALIVE_ARM_FFV)), true)
     LOCAL_CFLAGS += -DRUN_KEEP_ALIVE_IN_ARM_FFV
 endif
 
+# Legacy feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FFV)), true)
     LOCAL_CFLAGS += -DFFV_ENABLED
     LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio-noship/include/ffv
     LOCAL_SRC_FILES += audio_extn/ffv.c
 endif
 
+# Hardware Specific feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AHAL_EXT)),true)
     LOCAL_CFLAGS += -DAHAL_EXT_ENABLED
     LOCAL_SHARED_LIBRARIES += vendor.qti.hardware.audiohalext@1.0
@@ -500,31 +338,16 @@
 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_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
     LOCAL_CPPFLAGS += --coverage -fprofile-arcs -ftest-coverage
     LOCAL_STATIC_LIBRARIES += libprofile_rt
 endif
 
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUTO_HAL)),true)
-    LOCAL_CFLAGS += -DAUDIO_EXTN_AUTO_HAL_ENABLED
-    LOCAL_SRC_FILES += audio_extn/auto_hal.c
-endif
-
-ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXT_HW_PLUGIN)),true)
-    LOCAL_CFLAGS += -DEXT_HW_PLUGIN_ENABLED
-    LOCAL_SRC_FILES += audio_extn/ext_hw_plugin.c
-endif
+#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUTO_HAL)),true)
+#    LOCAL_CFLAGS += -DAUDIO_EXTN_AUTO_HAL_ENABLED
+#    LOCAL_SRC_FILES += audio_extn/auto_hal.c
+#endif
 
 LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
 
diff --git a/hal/ahal_config_helper.cpp b/hal/ahal_config_helper.cpp
index 1aac8c2..cfc673e 100644
--- a/hal/ahal_config_helper.cpp
+++ b/hal/ahal_config_helper.cpp
@@ -107,7 +107,7 @@
         true,        /* COMPRESS_METADATA_NEEDED */
         false,       /* INCALL_MUSIC */
         false,       /* COMPRESS_VOIP */
-        true,        /* DYNAMIC_ECNS */
+        true         /* DYNAMIC_ECNS */
     };
 #else
     if (isVendorEnhancedFwk) {
@@ -192,7 +192,7 @@
             false,       /* COMPRESS_METADATA_NEEDED */
             true,        /* INCALL_MUSIC */
             false,       /* COMPRESS_VOIP */
-            false,       /* DYNAMIC_ECNS */
+            false        /* DYNAMIC_ECNS */
         };
     }
 #endif
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index 5c65268..c11956b 100755
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -5,7 +5,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE:= libsndmonitor
+LOCAL_MODULE := libsndmonitor
 LOCAL_MODULE_OWNER := third_party
 LOCAL_VENDOR_MODULE := true
 
@@ -57,7 +57,7 @@
 #--------------------------------------------
 include $(CLEAR_VARS)
 
-LOCAL_MODULE:= libcomprcapture
+LOCAL_MODULE := libcomprcapture
 LOCAL_MODULE_OWNER := third_party
 LOCAL_VENDOR_MODULE := true
 
@@ -65,7 +65,7 @@
 
 ifneq ($(filter sdm845 sdm710 qcs605 msmnile kona lito $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
   MULTIPLE_HW_VARIANTS_ENABLED := true
 endif
 
@@ -116,14 +116,14 @@
 #-------------------------------------------
 include $(CLEAR_VARS)
 
-LOCAL_MODULE:= libssrec
+LOCAL_MODULE := libssrec
 LOCAL_VENDOR_MODULE := true
 
 AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
 
 ifneq ($(filter sdm845 sdm710 msmnile kona lito $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
   MULTIPLE_HW_VARIANTS_ENABLED := true
 endif
 
@@ -175,7 +175,7 @@
 #--------------------------------------------
 include $(CLEAR_VARS)
 
-LOCAL_MODULE:= libhdmiedid
+LOCAL_MODULE := libhdmiedid
 LOCAL_MODULE_OWNER := third_party
 LOCAL_VENDOR_MODULE := true
 
@@ -184,7 +184,7 @@
 
 ifneq ($(filter sdm845 sdm710 msmnile kona lito $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
 endif
 
 LOCAL_SRC_FILES:= \
@@ -236,10 +236,10 @@
 
 ifneq ($(filter sdm845 sdm710 msmnile kona lito $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
 endif
 
-LOCAL_MODULE:= libspkrprot
+LOCAL_MODULE := libspkrprot
 LOCAL_MODULE_OWNER := third_party
 LOCAL_VENDOR_MODULE := true
 
@@ -290,10 +290,10 @@
 
 ifneq ($(filter sdm845 sdm710 msmnile kona lito $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
 endif
 
-LOCAL_MODULE:= libcirrusspkrprot
+LOCAL_MODULE := libcirrusspkrprot
 LOCAL_MODULE_OWNER := third_party
 LOCAL_VENDOR_MODULE := true
 
@@ -342,7 +342,7 @@
 #-------------------------------------------
 include $(CLEAR_VARS)
 
-LOCAL_MODULE:= liba2dpoffload
+LOCAL_MODULE := liba2dpoffload
 LOCAL_VENDOR_MODULE := true
 
 PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
@@ -350,7 +350,7 @@
 
 ifneq ($(filter sdm845 sdm710 msmnile kona lito $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
-  AUDIO_PLATFORM = msm8974
+  AUDIO_PLATFORM := msm8974
   MULTIPLE_HW_VARIANTS_ENABLED := true
 endif
 
@@ -394,3 +394,313 @@
 LOCAL_HEADER_LIBRARIES += libhardware_headers
 LOCAL_HEADER_LIBRARIES += libsystem_headers
 include $(BUILD_SHARED_LIBRARY)
+
+#-------------------------------------------
+#            Build EXT_HW_PLUGIN LIB
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libexthwplugin
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 msmnile kona $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM := msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        ext_hw_plugin.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioroute \
+    libaudioutils \
+    libcutils \
+    libdl \
+    libexpat \
+    liblog \
+    libtinyalsa \
+    libtinycompress
+
+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)
+
+#-------------------------------------------
+#            Build HFP LIB
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libhfp
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 msmnile kona $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM := msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        hfp.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioroute \
+    libaudioutils \
+    libcutils \
+    libdl \
+    libexpat \
+    liblog \
+    libtinyalsa \
+    libtinycompress
+
+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)
+
+#-------------------------------------------
+#            Build HDMI PASSTHROUGH
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libhdmipassthru
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 msmnile kona $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM := msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        passthru.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+    -DDTSHD_PARSER_ENABLED
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioparsers \
+    libaudioroute \
+    libaudioutils \
+    libcutils \
+    libdl \
+    libexpat \
+    liblog \
+    libtinyalsa \
+    libtinycompress
+
+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 \
+    vendor/qcom/proprietary/mm-audio/audio-parsers/inc \
+    $(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)
+
+#-------------------------------------------
+#            Build BATTERY_LISTENER
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libbatterylistener
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 msmnile kona $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM := msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+        battery_listener.cpp
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable \
+    -DDTSHD_PARSER_ENABLED
+
+LOCAL_SHARED_LIBRARIES := \
+    android.hardware.health@1.0 \
+    android.hardware.health@2.0 \
+    android.hardware.power@1.2 \
+    libaudioroute \
+    libaudioutils \
+    libbase \
+    libcutils \
+    libdl \
+    libexpat \
+    libhidlbase \
+    libhidltransport \
+    liblog \
+    libtinyalsa \
+    libtinycompress \
+    libutils \
+
+LOCAL_STATIC_LIBRARIES := \
+    libhealthhalutils
+
+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 \
+    vendor/qcom/proprietary/mm-audio/audio-parsers/inc \
+    $(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)
+
+#-------------------------------------------
+#            Build HWDEP_CAL
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libhwdepcal
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 msmnile kona $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
+  # B-family platform uses msm8974 code base
+  AUDIO_PLATFORM := msm8974
+  MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+# LOCAL_SRC_FILES:= \
+#         hwdep_cal.c
+
+LOCAL_CFLAGS += \
+    -Wall \
+    -Werror \
+    -Wno-unused-function \
+    -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+    libaudioroute \
+    libaudioutils \
+    libcutils \
+    libdl \
+    libexpat \
+    liblog \
+    libtinyalsa \
+    libtinycompress
+
+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/audio_extn.c b/hal/audio_extn/audio_extn.c
index f440362..99df5ac 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -93,6 +93,17 @@
 int keep_alive_set_parameters(struct audio_device *adev,
                                          struct str_parms *parms);
 
+bool cin_applicable_stream(struct stream_in *in);
+bool cin_attached_usecase(audio_usecase_t uc_id);
+bool cin_format_supported(audio_format_t format);
+size_t cin_get_buffer_size(struct stream_in *in);
+int cin_start_input_stream(struct stream_in *in);
+void cin_stop_input_stream(struct stream_in *in);
+void cin_close_input_stream(struct stream_in *in);
+int cin_read(struct stream_in *in, void *buffer,
+                        size_t bytes, size_t *bytes_read);
+int cin_configure_input_stream(struct stream_in *in);
+
 void audio_extn_set_snd_card_split(const char* in_snd_card_name)
 {
     /* sound card name follows below mentioned convention
@@ -164,6 +175,11 @@
 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;
+static bool audio_extn_record_play_concurrency_enabled = false;
+static bool audio_extn_hdmi_passthru_enabled = false;
+static bool audio_extn_concurrent_capture_enabled = false;
+static bool audio_extn_compress_in_enabled = false;
+static bool audio_extn_battery_listener_enabled = false;
 
 #define AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL "aanc_noise_level"
 #define AUDIO_PARAMETER_KEY_ANC        "anc_enabled"
@@ -491,7 +507,7 @@
 void anc_headset_feature_init(bool is_feature_enabled)
 {
     audio_extn_anc_headset_feature_enabled = is_feature_enabled;
-    ALOGD(":: %s: ---- Feature FM_POWER_OPT is %s----", __func__,
+    ALOGD(":: %s: ---- Feature ANC_HEADSET is %s----", __func__,
                                     is_feature_enabled? "ENABLED": "NOT ENABLED");
 
 }
@@ -1185,7 +1201,7 @@
             goto feature_disabled;
         }
 
-        // options functions, can be NULL
+        // optional functions, can be NULL
 
         spkr_prot_set_parameters = NULL;
         fbsp_set_parameters = NULL;
@@ -1758,6 +1774,9 @@
 typedef void (*hwdep_cal_send_t)(int, void*);
 static hwdep_cal_send_t hwdep_cal_send;
 
+
+//If feature is enabled, please copy hwdep_cal.c in the audio_extn dir
+//Current lib doesn't have any src files
 void hwdep_cal_feature_init(bool is_feature_enabled)
 {
     ALOGD("%s: Called with feature %s", __func__, is_feature_enabled?"Enabled":"NOT Enabled");
@@ -2948,21 +2967,25 @@
 void fm_feature_init(bool is_feature_enabled)
 {
     audio_extn_fm_power_opt_enabled = is_feature_enabled;
-    ALOGD(":: %s: ---- Feature FM_POWER_OPT is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
+    ALOGD("%s: ---- Feature FM_POWER_OPT is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
 }
 
 
 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);
+    if(audio_extn_fm_power_opt_enabled) {
+       ALOGD("%s: Enter", __func__);
+       fm_get_parameters(query, reply);
+    }
 }
 
 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);
+    if(audio_extn_fm_power_opt_enabled) {
+       ALOGD("%s: Enter", __func__);
+       fm_set_parameters(adev, parms);
+    }
 }
 //END: FM_POWER_OPT_FEATURE ================================================================
 
@@ -3718,6 +3741,763 @@
 }
 
 // END: A2DP_OFFLOAD =====================================================================
+
+// START: HFP ======================================================================
+#ifdef __LP64__
+#define HFP_LIB_PATH "/vendor/lib64/libhfp.so"
+#else
+#define HFP_LIB_PATH "/vendor/lib/libhfp.so"
+#endif
+
+static void *hfp_lib_handle = NULL;
+
+typedef void (*hfp_init_t)(hfp_init_config_t);
+static hfp_init_t hfp_init;
+
+typedef bool (*hfp_is_active_t)(struct audio_device *adev);
+static hfp_is_active_t hfp_is_active;
+
+typedef audio_usecase_t (*hfp_get_usecase_t)();
+static hfp_get_usecase_t hfp_get_usecase;
+
+typedef int (*hfp_set_mic_mute_t)(struct audio_device *dev, bool state);
+static hfp_set_mic_mute_t hfp_set_mic_mute;
+
+typedef void (*hfp_set_parameters_t)(struct audio_device *adev,
+                                           struct str_parms *parms);
+static hfp_set_parameters_t hfp_set_parameters;
+
+typedef int (*hfp_set_mic_mute2_t)(struct audio_device *adev, bool state);
+static hfp_set_mic_mute2_t hfp_set_mic_mute2;
+
+int hfp_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
+        hfp_lib_handle = dlopen(HFP_LIB_PATH, RTLD_NOW);
+
+        if (!hfp_lib_handle) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        if (!(hfp_init = (hfp_init_t)dlsym(
+                            hfp_lib_handle, "hfp_init")) ||
+            !(hfp_is_active =
+                 (hfp_is_active_t)dlsym(
+                            hfp_lib_handle, "hfp_is_active")) ||
+            !(hfp_get_usecase =
+                 (hfp_get_usecase_t)dlsym(
+                            hfp_lib_handle, "hfp_get_usecase")) ||
+            !(hfp_set_mic_mute =
+                 (hfp_set_mic_mute_t)dlsym(
+                            hfp_lib_handle, "hfp_set_mic_mute")) ||
+            !(hfp_set_mic_mute2 =
+                 (hfp_set_mic_mute2_t)dlsym(
+                            hfp_lib_handle, "hfp_set_mic_mute2")) ||
+            !(hfp_set_parameters =
+                 (hfp_set_parameters_t)dlsym(
+                            hfp_lib_handle, "hfp_set_parameters"))) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+        hfp_init_config_t init_config;
+        init_config.fp_platform_set_mic_mute = platform_set_mic_mute;
+        init_config.fp_platform_get_pcm_device_id = platform_get_pcm_device_id;
+        init_config.fp_platform_set_echo_reference = platform_set_echo_reference;
+        init_config.fp_platform_set_mic_mute = platform_set_mic_mute;
+        init_config.fp_select_devices = select_devices;
+        init_config.fp_audio_extn_ext_hw_plugin_usecase_start =
+                                        audio_extn_ext_hw_plugin_usecase_start;
+        init_config.fp_audio_extn_ext_hw_plugin_usecase_stop =
+                                        audio_extn_ext_hw_plugin_usecase_stop;
+        init_config.fp_get_usecase_from_list = get_usecase_from_list;
+        init_config.fp_disable_audio_route = disable_audio_route;
+        init_config.fp_disable_snd_device = disable_snd_device;
+        init_config.fp_voice_get_mic_mute = voice_get_mic_mute;
+
+        hfp_init(init_config);
+        ALOGD("%s:: ---- Feature HFP is Enabled ----", __func__);
+        return 0;
+    }
+
+feature_disabled:
+    if (hfp_lib_handle) {
+        dlclose(hfp_lib_handle);
+        hfp_lib_handle = NULL;
+    }
+
+    hfp_init = NULL;
+    hfp_is_active = NULL;
+    hfp_get_usecase = NULL;
+    hfp_set_mic_mute = NULL;
+    hfp_set_mic_mute2 = NULL;
+    hfp_set_parameters = NULL;
+
+    ALOGW(":: %s: ---- Feature HFP is disabled ----", __func__);
+    return -ENOSYS;
+}
+
+bool audio_extn_hfp_is_active(struct audio_device *adev)
+{
+    return ((hfp_is_active) ?
+                    hfp_is_active(adev): false);
+}
+
+audio_usecase_t audio_extn_hfp_get_usecase()
+{
+    return ((hfp_get_usecase) ?
+                    hfp_get_usecase(): -1);
+}
+
+int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state)
+{
+    return ((hfp_set_mic_mute) ?
+                    hfp_set_mic_mute(adev, state): -1);
+}
+
+void audio_extn_hfp_set_parameters(struct audio_device *adev,
+                                           struct str_parms *parms)
+{
+    ((hfp_set_parameters) ?
+                    hfp_set_parameters(adev, parms): NULL);
+}
+
+int audio_extn_hfp_set_mic_mute2(struct audio_device *adev, bool state)
+{
+    return ((hfp_set_mic_mute2) ?
+                    hfp_set_mic_mute2(adev, state): -1);
+}
+// END: HFP ========================================================================
+
+// START: EXT_HW_PLUGIN ===================================================================
+#ifdef __LP64__
+#define EXT_HW_PLUGIN_LIB_PATH "/vendor/lib64/libexthwplugin.so"
+#else
+#define EXT_HW_PLUGIN_LIB_PATH "/vendor/lib/libexthwplugin.so"
+#endif
+
+static void *ext_hw_plugin_lib_handle = NULL;
+
+typedef void* (*ext_hw_plugin_init_t)(struct audio_device*,
+                                        ext_hw_plugin_init_config_t init_config);
+static ext_hw_plugin_init_t ext_hw_plugin_init;
+
+typedef int (*ext_hw_plugin_deinit_t)(void*);
+static ext_hw_plugin_deinit_t ext_hw_plugin_deinit;
+
+typedef int(*ext_hw_plugin_usecase_start_t)(void*, struct audio_usecase*);
+static ext_hw_plugin_usecase_start_t ext_hw_plugin_usecase_start;
+
+typedef int(*ext_hw_plugin_usecase_stop_t)(void*, struct audio_usecase*);
+static ext_hw_plugin_usecase_stop_t ext_hw_plugin_usecase_stop;
+
+typedef int(*ext_hw_plugin_set_parameters_t)(void*, struct str_parms*);
+static ext_hw_plugin_set_parameters_t ext_hw_plugin_set_parameters;
+
+typedef int(*ext_hw_plugin_get_parameters_t)(void*,
+                                        struct str_parms*, struct str_parms*);
+static ext_hw_plugin_get_parameters_t ext_hw_plugin_get_parameters;
+
+typedef int(*ext_hw_plugin_set_mic_mute_t)(void*, bool);
+static ext_hw_plugin_set_mic_mute_t ext_hw_plugin_set_mic_mute;
+
+typedef int(*ext_hw_plugin_get_mic_mute_t)(void*, bool*);
+static ext_hw_plugin_get_mic_mute_t ext_hw_plugin_get_mic_mute;
+
+typedef int(*ext_hw_plugin_set_audio_gain_t)(void*, struct audio_usecase*, uint32_t);
+static ext_hw_plugin_set_audio_gain_t ext_hw_plugin_set_audio_gain;
+
+
+int ext_hw_plugin_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
+        ext_hw_plugin_lib_handle = dlopen(EXT_HW_PLUGIN_LIB_PATH, RTLD_NOW);
+
+        if (!ext_hw_plugin_lib_handle) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+    if (!(ext_hw_plugin_init = (ext_hw_plugin_init_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_init")) ||
+            !(ext_hw_plugin_deinit =
+                 (ext_hw_plugin_deinit_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_deinit")) ||
+            !(ext_hw_plugin_usecase_start =
+                 (ext_hw_plugin_usecase_start_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_usecase_start")) ||
+            !(ext_hw_plugin_usecase_stop =
+                 (ext_hw_plugin_usecase_stop_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_usecase_stop")) ||
+            !(ext_hw_plugin_set_parameters =
+                 (ext_hw_plugin_set_parameters_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_set_parameters")) ||
+            !(ext_hw_plugin_get_parameters =
+                 (ext_hw_plugin_get_parameters_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_get_parameters")) ||
+            !(ext_hw_plugin_set_mic_mute =
+                 (ext_hw_plugin_set_mic_mute_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_set_mic_mute")) ||
+            !(ext_hw_plugin_get_mic_mute =
+                 (ext_hw_plugin_get_mic_mute_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_get_mic_mute")) ||
+            !(ext_hw_plugin_set_audio_gain =
+                 (ext_hw_plugin_set_audio_gain_t)dlsym(
+                            ext_hw_plugin_lib_handle, "ext_hw_plugin_set_audio_gain"))) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+        ALOGD("%s:: ---- Feature EXT_HW_PLUGIN is Enabled ----", __func__);
+        return 0;
+    }
+
+feature_disabled:
+    if (ext_hw_plugin_lib_handle) {
+        dlclose(ext_hw_plugin_lib_handle);
+        ext_hw_plugin_lib_handle = NULL;
+    }
+
+    ext_hw_plugin_init = NULL;
+    ext_hw_plugin_deinit = NULL;
+    ext_hw_plugin_usecase_start = NULL;
+    ext_hw_plugin_usecase_stop = NULL;
+    ext_hw_plugin_set_parameters = NULL;
+    ext_hw_plugin_get_parameters = NULL;
+    ext_hw_plugin_set_mic_mute = NULL;
+    ext_hw_plugin_get_mic_mute = NULL;
+    ext_hw_plugin_set_audio_gain = NULL;
+
+    ALOGW(":: %s: ---- Feature EXT_HW_PLUGIN is disabled ----", __func__);
+    return -ENOSYS;
+}
+
+void* audio_extn_ext_hw_plugin_init(struct audio_device *adev)
+{
+    if(ext_hw_plugin_init) {
+        ext_hw_plugin_init_config_t ext_hw_plugin_init_config;
+        ext_hw_plugin_init_config.fp_audio_route_apply_and_update_path =
+                                              audio_route_apply_and_update_path;
+        return ext_hw_plugin_init(adev, ext_hw_plugin_init_config);
+    }
+    else
+        return NULL;
+}
+
+int audio_extn_ext_hw_plugin_deinit(void *plugin)
+{
+    return ((ext_hw_plugin_deinit) ?
+                            ext_hw_plugin_deinit(plugin): -1);
+}
+
+int audio_extn_ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase)
+{
+    return ((ext_hw_plugin_usecase_start) ?
+                            ext_hw_plugin_usecase_start(plugin, usecase): -1);
+}
+
+int audio_extn_ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase)
+{
+    return ((ext_hw_plugin_usecase_stop) ?
+                            ext_hw_plugin_usecase_stop(plugin, usecase): -1);
+}
+
+int audio_extn_ext_hw_plugin_set_parameters(void *plugin,
+                                           struct str_parms *parms)
+{
+    return ((ext_hw_plugin_set_parameters) ?
+                            ext_hw_plugin_set_parameters(plugin, parms): -1);
+}
+
+int audio_extn_ext_hw_plugin_get_parameters(void *plugin,
+                  struct str_parms *query, struct str_parms *reply)
+{
+    return ((ext_hw_plugin_get_parameters) ?
+                        ext_hw_plugin_get_parameters(plugin, query, reply): -1);
+}
+
+int audio_extn_ext_hw_plugin_set_mic_mute(void *plugin, bool mute)
+{
+    return ((ext_hw_plugin_set_mic_mute) ?
+                        ext_hw_plugin_set_mic_mute(plugin, mute): -1);
+}
+
+int audio_extn_ext_hw_plugin_get_mic_mute(void *plugin, bool *mute)
+{
+    return ((ext_hw_plugin_get_mic_mute) ?
+                        ext_hw_plugin_get_mic_mute(plugin, mute): -1);
+}
+
+int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
+            struct audio_usecase *usecase, uint32_t gain)
+{
+    return ((ext_hw_plugin_set_audio_gain) ?
+                        ext_hw_plugin_set_audio_gain(plugin, usecase, gain): -1);
+}
+// END: EXT_HW_PLUGIN ===================================================================
+
+// START: RECORD_PLAY_CONCURRENCY =======================================================
+void record_play_concurency_feature_init(bool is_feature_enabled)
+{
+    audio_extn_record_play_concurrency_enabled = is_feature_enabled;
+    ALOGD("%s: ---- Feature RECORD_PLAY_CONCURRENCY is %s----", __func__,
+                                        is_feature_enabled? "ENABLED": "NOT ENABLED");
+}
+
+bool audio_extn_is_record_play_concurrency_enabled()
+{
+    return audio_extn_record_play_concurrency_enabled;
+}
+// END: RECORD_PLAY_CONCURRENCY =========================================================
+
+// START: HDMI_PASSTHROUGH ==================================================
+#ifdef __LP64__
+#define HDMI_PASSTHRU_LIB_PATH "/vendor/lib64/libhdmipassthru.so"
+#else
+#define HDMI_PASSTHRU_LIB_PATH "/vendor/lib/libhdmipassthru.so"
+#endif
+
+static void *hdmi_passthru_lib_handle = NULL;
+
+typedef bool (*passthru_is_convert_supported_t)(struct audio_device *,
+                                                 struct stream_out *);
+static passthru_is_convert_supported_t passthru_is_convert_supported;
+
+typedef bool (*passthru_is_passt_supported_t)(struct stream_out *);
+static passthru_is_passt_supported_t passthru_is_passt_supported;
+
+typedef void (*passthru_update_stream_configuration_t)(
+        struct audio_device *, struct stream_out *, const void *, size_t);
+static passthru_update_stream_configuration_t passthru_update_stream_configuration;
+
+typedef bool (*passthru_is_passthrough_stream_t)(struct stream_out *);
+static passthru_is_passthrough_stream_t passthru_is_passthrough_stream;
+
+typedef int (*passthru_get_buffer_size_t)(audio_offload_info_t*);
+static passthru_get_buffer_size_t passthru_get_buffer_size;
+
+typedef int (*passthru_set_volume_t)(struct stream_out *, int);
+static passthru_set_volume_t passthru_set_volume;
+
+typedef int (*passthru_set_latency_t)(struct stream_out *, int);
+static passthru_set_latency_t passthru_set_latency;
+
+typedef bool (*passthru_is_supported_format_t)(audio_format_t);
+static passthru_is_supported_format_t passthru_is_supported_format;
+
+typedef bool (*passthru_should_drop_data_t)(struct stream_out * out);
+static passthru_should_drop_data_t passthru_should_drop_data;
+
+typedef void (*passthru_on_start_t)(struct stream_out *out);
+static passthru_on_start_t passthru_on_start;
+
+typedef void (*passthru_on_stop_t)(struct stream_out *out);
+static passthru_on_stop_t passthru_on_stop;
+
+typedef void (*passthru_on_pause_t)(struct stream_out *out);
+static passthru_on_pause_t passthru_on_pause;
+
+typedef int (*passthru_set_parameters_t)(struct audio_device *adev,
+                                       struct str_parms *parms);
+static passthru_set_parameters_t passthru_set_parameters;
+
+typedef bool (*passthru_is_enabled_t)();
+static passthru_is_enabled_t passthru_is_enabled;
+
+typedef bool (*passthru_is_active_t)();
+static passthru_is_active_t passthru_is_active;
+
+typedef void (*passthru_init_t)(passthru_init_config_t);
+static passthru_init_t passthru_init;
+
+typedef bool (*passthru_should_standby_t)(struct stream_out *out);
+static passthru_should_standby_t passthru_should_standby;
+
+typedef int (*passthru_get_channel_count_t)(struct stream_out *out);
+static passthru_get_channel_count_t passthru_get_channel_count;
+
+typedef int (*passthru_update_dts_stream_configuration_t)(struct stream_out *out,
+        const void *buffer, size_t bytes);
+static passthru_update_dts_stream_configuration_t passthru_update_dts_stream_configuration;
+
+typedef bool (*passthru_is_direct_passthrough_t)(struct stream_out *out);
+static passthru_is_direct_passthrough_t passthru_is_direct_passthrough;
+
+typedef bool (*passthru_is_supported_backend_edid_cfg_t)(struct audio_device *adev,
+                                                   struct stream_out *out);
+static passthru_is_supported_backend_edid_cfg_t passthru_is_supported_backend_edid_cfg;
+
+bool audio_extn_passthru_is_convert_supported(struct audio_device *adev,
+                                                 struct stream_out *out)
+{
+    return (passthru_is_convert_supported ? passthru_is_convert_supported(adev, out) : false);
+}
+
+bool audio_extn_passthru_is_passthrough_stream(struct stream_out *out)
+{
+    return (passthru_is_passthrough_stream ?
+                passthru_is_passthrough_stream(out) : false);
+}
+
+void audio_extn_passthru_update_stream_configuration(
+        struct audio_device *adev, struct stream_out *out,
+        const void *buffer, size_t bytes)
+{
+    (passthru_update_stream_configuration ?
+                passthru_update_stream_configuration(adev, out, buffer, bytes) : 0);
+}
+
+bool audio_extn_passthru_is_passt_supported(struct stream_out *out)
+{
+    return (passthru_is_passt_supported)? passthru_is_passt_supported(out): false;
+}
+
+int audio_extn_passthru_get_buffer_size(audio_offload_info_t* info)
+{
+    return (passthru_get_buffer_size)? passthru_get_buffer_size(info): 0;
+}
+
+int audio_extn_passthru_set_volume(struct stream_out *out, int mute)
+{
+    return (passthru_set_volume)? passthru_set_volume(out, mute): 0;
+}
+
+int audio_extn_passthru_set_latency(struct stream_out *out, int latency)
+{
+    return (passthru_set_latency)? passthru_set_latency(out, latency): 0;
+}
+
+bool audio_extn_passthru_is_supported_format(audio_format_t format)
+{
+    return (passthru_is_supported_format)? passthru_is_supported_format(format): false;
+}
+
+bool audio_extn_passthru_should_drop_data(struct stream_out * out)
+{
+    return (passthru_should_drop_data)? passthru_should_drop_data(out): false;
+}
+
+void audio_extn_passthru_on_start(struct stream_out *out)
+{
+    (passthru_on_start)? passthru_on_start(out): 0;
+}
+
+void audio_extn_passthru_on_stop(struct stream_out *out)
+{
+    (passthru_on_stop)? passthru_on_stop(out): 0;
+}
+
+void audio_extn_passthru_on_pause(struct stream_out *out)
+{
+    (passthru_on_pause)? passthru_on_pause(out): 0;
+}
+
+int audio_extn_passthru_set_parameters(struct audio_device *adev,
+                                       struct str_parms *parms)
+{
+    return (passthru_set_parameters)?
+                            passthru_set_parameters(adev, parms): false;
+}
+
+bool audio_extn_passthru_is_enabled()
+{
+    return (passthru_is_enabled)? passthru_is_enabled(): false;
+}
+
+bool audio_extn_passthru_is_active()
+{
+     return (passthru_is_active)? passthru_is_active(): false;
+}
+
+bool audio_extn_passthru_should_standby(struct stream_out *out)
+{
+    return (passthru_should_standby)? passthru_should_standby(out): false;
+}
+int audio_extn_passthru_get_channel_count(struct stream_out *out)
+{
+    return (passthru_get_channel_count)? passthru_get_channel_count(out): 0;
+}
+
+int audio_extn_passthru_update_dts_stream_configuration(struct stream_out *out,
+        const void *buffer, size_t bytes)
+{
+    return (passthru_update_dts_stream_configuration)?
+                        passthru_update_dts_stream_configuration(out, buffer, bytes): 0;
+}
+
+bool audio_extn_passthru_is_direct_passthrough(struct stream_out *out)
+{
+    return (passthru_is_direct_passthrough)? passthru_is_direct_passthrough(out): false;
+}
+
+bool audio_extn_passthru_is_supported_backend_edid_cfg(struct audio_device *adev,
+                                                   struct stream_out *out)
+{
+    return (passthru_is_supported_backend_edid_cfg)?
+                            passthru_is_supported_backend_edid_cfg(adev, out): false;
+}
+bool audio_extn_is_hdmi_passthru_enabled()
+{
+    return audio_extn_hdmi_passthru_enabled;
+}
+
+void hdmi_passthrough_feature_init(bool is_feature_enabled)
+{
+    ALOGD("%s: Called with feature %s", __func__,
+                  is_feature_enabled ? "Enabled" : "NOT Enabled");
+
+    audio_extn_hdmi_passthru_enabled = is_feature_enabled;
+    if (is_feature_enabled) {
+        // dlopen lib
+        hdmi_passthru_lib_handle = dlopen(HDMI_PASSTHRU_LIB_PATH, RTLD_NOW);
+
+        if (!hdmi_passthru_lib_handle) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+    if (!(passthru_init = (passthru_init_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_init")) ||
+            !(passthru_is_convert_supported =
+                 (passthru_is_convert_supported_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_convert_supported")) ||
+            !(passthru_is_passthrough_stream =
+                 (passthru_is_passthrough_stream_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_passthrough_stream")) ||
+            !(passthru_get_buffer_size =
+                 (passthru_get_buffer_size_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_get_buffer_size")) ||
+            !(passthru_set_volume =
+                 (passthru_set_volume_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_set_volume")) ||
+            !(passthru_set_latency =
+                 (passthru_set_latency_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_set_latency")) ||
+            !(passthru_is_supported_format =
+                 (passthru_is_supported_format_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_supported_format")) ||
+            !(passthru_should_drop_data =
+                 (passthru_should_drop_data_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_should_drop_data")) ||
+            !(passthru_on_start =
+                 (passthru_on_start_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_on_start")) ||
+            !(passthru_on_stop =
+                 (passthru_on_stop_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_on_stop")) ||
+            !(passthru_on_pause =
+                 (passthru_on_pause_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_on_pause")) ||
+            !(passthru_set_parameters =
+                 (passthru_set_parameters_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_set_parameters")) ||
+            (passthru_is_enabled =
+                 (passthru_is_enabled_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_enabled")) ||
+            (passthru_is_active =
+                 (passthru_is_active_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_active")) ||
+            (passthru_should_standby =
+                 (passthru_should_standby_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_should_standby")) ||
+            (passthru_get_channel_count =
+                 (passthru_get_channel_count_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_get_channel_count")) ||
+            (passthru_update_dts_stream_configuration =
+                 (passthru_update_dts_stream_configuration_t)dlsym(
+                            hdmi_passthru_lib_handle,
+                            "passthru_update_dts_stream_configuration")) ||
+            (passthru_is_direct_passthrough =
+                 (passthru_is_direct_passthrough_t)dlsym(
+                            hdmi_passthru_lib_handle, "passthru_is_direct_passthrough")) ||
+            (passthru_is_supported_backend_edid_cfg =
+                 (passthru_is_supported_backend_edid_cfg_t)dlsym(
+                            hdmi_passthru_lib_handle,
+                            "passthru_is_supported_backend_edid_cfg"))) {
+            ALOGE("%s: dlsym failed", __func__);
+            goto feature_disabled;
+        }
+
+        passthru_init_config_t init_config;
+        init_config.fp_platform_is_edid_supported_format =
+                                                    platform_is_edid_supported_format;
+        init_config.fp_platform_set_device_params = platform_set_device_params;
+        init_config.fp_platform_edid_get_max_channels = platform_edid_get_max_channels;
+        init_config.fp_platform_get_output_snd_device = platform_get_output_snd_device;
+        init_config.fp_platform_get_codec_backend_cfg = platform_get_codec_backend_cfg;
+        init_config.fp_platform_get_snd_device_name = platform_get_snd_device_name;
+        init_config.fp_platform_is_edid_supported_sample_rate =
+                                                platform_is_edid_supported_sample_rate;
+        init_config.fp_audio_extn_keep_alive_start = audio_extn_keep_alive_start;
+        init_config.fp_audio_extn_keep_alive_stop = audio_extn_keep_alive_stop;
+        init_config.fp_audio_extn_utils_is_dolby_format =
+                                                    audio_extn_utils_is_dolby_format;
+        passthru_init(init_config);
+        ALOGD("%s:: ---- Feature HDMI_PASSTHROUGH is Enabled ----", __func__);
+    }
+
+feature_disabled:
+    if (hdmi_passthru_lib_handle) {
+        dlclose(hdmi_passthru_lib_handle);
+        hdmi_passthru_lib_handle = NULL;
+    }
+
+    passthru_init = NULL;
+    passthru_is_convert_supported = NULL;
+    passthru_is_passthrough_stream = NULL;
+    passthru_get_buffer_size = NULL;
+    passthru_set_volume = NULL;
+    passthru_set_latency = NULL;
+    passthru_is_supported_format = NULL;
+    passthru_should_drop_data = NULL;
+    passthru_on_start = NULL;
+    passthru_on_stop = NULL;
+    passthru_on_pause = NULL;
+    passthru_set_parameters = NULL;
+    passthru_is_enabled = NULL;
+    passthru_is_active = NULL;
+    passthru_should_standby = NULL;
+    passthru_get_channel_count = NULL;
+    passthru_update_dts_stream_configuration = NULL;
+    passthru_is_direct_passthrough = NULL;
+    passthru_is_supported_backend_edid_cfg = NULL;
+
+    ALOGW(":: %s: ---- Feature HDMI_PASSTHROUGH is disabled ----", __func__);
+}
+// END: HDMI_PASSTHROUGH ==================================================
+
+// START: CONCURRENT_CAPTURE ==================================================
+bool audio_extn_is_concurrent_capture_enabled()
+{
+    return audio_extn_concurrent_capture_enabled;
+}
+
+void concurrent_capture_feature_init(bool is_feature_enabled)
+{
+    audio_extn_concurrent_capture_enabled = is_feature_enabled;
+    ALOGD("%s: ---- Feature CONCURRENT_CAPTURE is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
+}
+// END: CONCURRENT_CAPTURE ====================================================
+
+// START: COMPRESS_IN ==================================================
+void compress_in_feature_init(bool is_feature_enabled)
+{
+    audio_extn_compress_in_enabled = is_feature_enabled;
+    ALOGD("%s: ---- Feature COMPRESS_IN is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
+}
+
+bool audio_extn_cin_applicable_stream(struct stream_in *in)
+{
+    return (audio_extn_compress_in_enabled? cin_applicable_stream(in): false);
+}
+bool audio_extn_cin_attached_usecase(audio_usecase_t uc_id)
+{
+    return (audio_extn_compress_in_enabled? cin_attached_usecase(uc_id): false);
+}
+bool audio_extn_cin_format_supported(audio_format_t format)
+{
+    return (audio_extn_compress_in_enabled? cin_format_supported(format): false);
+}
+size_t audio_extn_cin_get_buffer_size(struct stream_in *in)
+{
+    return (audio_extn_compress_in_enabled? cin_get_buffer_size(in): 0);
+}
+int audio_extn_cin_start_input_stream(struct stream_in *in)
+{
+    return (audio_extn_compress_in_enabled? cin_start_input_stream(in): -1);
+}
+void audio_extn_cin_stop_input_stream(struct stream_in *in)
+{
+    (audio_extn_compress_in_enabled? cin_stop_input_stream(in): NULL);
+}
+void audio_extn_cin_close_input_stream(struct stream_in *in)
+{
+    (audio_extn_compress_in_enabled? cin_close_input_stream(in): NULL);
+}
+int audio_extn_cin_read(struct stream_in *in, void *buffer,
+                        size_t bytes, size_t *bytes_read)
+{
+    return (audio_extn_compress_in_enabled?
+                            cin_read(in, buffer, bytes, bytes_read): -1);
+}
+int audio_extn_cin_configure_input_stream(struct stream_in *in)
+{
+    return (audio_extn_compress_in_enabled? cin_configure_input_stream(in): -1);
+}
+// END: COMPRESS_IN ====================================================
+
+// START: BATTERY_LISTENER ==================================================
+#ifdef __LP64__
+#define BATTERY_LISTENER_LIB_PATH "/vendor/lib64/libbatterylistener.so"
+#else
+#define BATTERY_LISTENER_LIB_PATH "/vendor/lib/libbatterylistener.so"
+#endif
+
+static void *batt_listener_lib_handle = NULL;
+
+typedef void (*batt_listener_init_t)(battery_status_change_fn_t);
+static batt_listener_init_t batt_listener_init;
+
+typedef void (*batt_listener_deinit_t)();
+static batt_listener_deinit_t batt_listener_deinit;
+
+typedef bool (*batt_prop_is_charging_t)();
+static batt_prop_is_charging_t batt_prop_is_charging;
+
+void battery_listener_feature_init(bool is_feature_enabled)
+{
+    audio_extn_battery_listener_enabled = is_feature_enabled;
+    ALOGD("%s: ---- Feature BATTERY_LISTENER is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
+    if (is_feature_enabled) {
+        // dlopen lib
+        batt_listener_lib_handle = dlopen(BATTERY_LISTENER_LIB_PATH, RTLD_NOW);
+
+        if (!batt_listener_lib_handle) {
+            ALOGE("%s: dlopen failed", __func__);
+            goto feature_disabled;
+        }
+        if (!(batt_listener_init = (batt_listener_init_t)dlsym(
+                            batt_listener_lib_handle, "battery_properties_listener_init")) ||
+                !(batt_listener_deinit =
+                     (batt_listener_deinit_t)dlsym(
+                        batt_listener_lib_handle, "battery_properties_listener_deinit")) ||
+                !(batt_prop_is_charging =
+                     (batt_prop_is_charging_t)dlsym(
+                        batt_listener_lib_handle, "battery_properties_is_charging"))) {
+             ALOGE("%s: dlsym failed", __func__);
+                goto feature_disabled;
+        }
+    }
+
+    feature_disabled:
+    if (batt_listener_lib_handle) {
+        dlclose(batt_listener_lib_handle);
+        batt_listener_lib_handle = NULL;
+    }
+
+    batt_listener_init = NULL;
+    batt_listener_deinit = NULL;
+    batt_prop_is_charging = NULL;
+    ALOGW(":: %s: ---- Feature BATTERY_LISTENER is disabled ----", __func__);
+}
+
+void audio_extn_battery_properties_listener_init(battery_status_change_fn_t fn)
+{
+    if(batt_listener_init)
+        batt_listener_init(fn);
+}
+void audio_extn_battery_properties_listener_deinit()
+{
+    if(batt_listener_deinit)
+        batt_listener_deinit();
+}
+bool audio_extn_battery_properties_is_charging()
+{
+    return (batt_prop_is_charging)? batt_prop_is_charging(): false;
+}
+
 void audio_extn_feature_init(int is_running_with_enhanced_fwk)
 {
     is_running_vendor_enhanced_fwk = is_running_with_enhanced_fwk;
@@ -3802,6 +4582,27 @@
             case HWDEP_CAL:
                 hwdep_cal_feature_init(enable);
                 break;
+            case HFP:
+                hfp_feature_init(enable);
+                break;
+            case EXT_HW_PLUGIN:
+                ext_hw_plugin_feature_init(enable);
+                break;
+            case RECORD_PLAY_CONCURRENCY:
+                record_play_concurency_feature_init(enable);
+                break;
+            case HDMI_PASSTHROUGH:
+                hdmi_passthrough_feature_init(enable);
+                break;
+            case CONCURRENT_CAPTURE:
+                concurrent_capture_feature_init(enable);
+                break;
+            case COMPRESS_IN_CAPTURE:
+                compress_in_feature_init(enable);
+                break;
+            case BATTERY_LISTENER:
+                battery_listener_feature_init(enable);
+                break;
             default:
                 break;
         }
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 863916b..7b5695c 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -42,10 +42,9 @@
 #include "adsp_hdlr.h"
 #include "audio_hidl.h"
 #include "ip_hdlr_intf.h"
-#include "battery_listener.h"
 #include "platform_api.h"
 #include "edid.h"
-
+#include "battery_listener.h"
 
 #define AUDIO_PARAMETER_DUAL_MONO  "dual_mono"
 
@@ -57,44 +56,14 @@
 #define AUDIO_DEVICE_IN_HDMI_ARC (AUDIO_DEVICE_BIT_IN | 0x8000000)
 #endif
 
-#ifndef INCALL_MUSIC_ENABLED
-#define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x80000000 //0x8000
-#endif
+// #ifndef INCALL_MUSIC_ENABLED
+// #define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x80000000 //0x8000
+// #endif
 
 #ifndef AUDIO_DEVICE_OUT_FM_TX
 #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
-
-#ifndef WMA_OFFLOAD_ENABLED
-#define AUDIO_FORMAT_WMA 0x12000000UL
-#define AUDIO_FORMAT_WMA_PRO 0x13000000UL
-#endif
-
-#ifndef ALAC_OFFLOAD_ENABLED
-#define AUDIO_FORMAT_ALAC 0x1C000000UL
-#endif
-
-#ifndef APE_OFFLOAD_ENABLED
-#define AUDIO_FORMAT_APE 0x1D000000UL
-#endif
-
-#ifndef AAC_ADTS_OFFLOAD_ENABLED
-#define AUDIO_FORMAT_AAC_ADTS 0x1E000000UL
-#define AUDIO_FORMAT_AAC_ADTS_LC   (AUDIO_FORMAT_AAC_ADTS |\
-                                      AUDIO_FORMAT_AAC_SUB_LC)
-#define AUDIO_FORMAT_AAC_ADTS_HE_V1 (AUDIO_FORMAT_AAC_ADTS |\
-                                      AUDIO_FORMAT_AAC_SUB_HE_V1)
-#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
 #define AUDIO_FORMAT_AAC_LATM_LC   (AUDIO_FORMAT_AAC_LATM |\
@@ -136,13 +105,8 @@
 int audio_extn_parse_compress_metadata(struct stream_out *out,
                                        struct str_parms *parms);
 
-#ifdef AUDIO_EXTN_FORMATS_ENABLED
 #define AUDIO_OUTPUT_BIT_WIDTH ((config->offload_info.bit_width == 32) ? 24\
                                    :config->offload_info.bit_width)
-#else
-#define AUDIO_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH)
-#define compress_set_next_track_param(compress, codec_options) (0)
-#endif
 
 #ifndef AUDIO_HW_EXTN_API_ENABLED
 #define compress_set_metadata(compress, metadata) (0)
@@ -199,7 +163,6 @@
 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);
 
@@ -277,7 +240,6 @@
 
 
 bool audio_extn_is_hifi_audio_enabled(void);
-bool audio_extn_is_hifi_audio_enabled(void);
 bool audio_extn_is_hifi_audio_supported(void);
 
 //START: AFE_PROXY_FEATURE
@@ -581,37 +543,39 @@
     EXT_DISPLAY_TYPE_HDMI,
     EXT_DISPLAY_TYPE_DP
 };
-
+// START: HDMI_PASSTHROUGH ==================================================
 /* Used to limit sample rate for TrueHD & EC3 */
 #define HDMI_PASSTHROUGH_MAX_SAMPLE_RATE 192000
 
-#ifndef HDMI_PASSTHROUGH_ENABLED
-#define audio_extn_passthru_update_stream_configuration(adev, out, buffer, bytes)  (0)
-#define audio_extn_passthru_is_convert_supported(adev, out)                   (0)
-#define audio_extn_passthru_is_passt_supported(adev, out)                     (0)
-#define audio_extn_passthru_is_passthrough_stream(out)                        (0)
-#define audio_extn_passthru_get_buffer_size(info)                             (0)
-#define audio_extn_passthru_set_volume(out, mute)                             (0)
-#define audio_extn_passthru_set_latency(out, latency)                         (0)
-#define audio_extn_passthru_is_supported_format(f) (0)
-#define audio_extn_passthru_should_drop_data(o) (0)
-#define audio_extn_passthru_on_start(o) do {} while(0)
-#define audio_extn_passthru_on_stop(o) do {} while(0)
-#define audio_extn_passthru_on_pause(o) do {} while(0)
-#define audio_extn_passthru_is_enabled() (0)
-#define audio_extn_passthru_is_active() (0)
-#define audio_extn_passthru_set_parameters(a, p) (-ENOSYS)
-#define audio_extn_passthru_init(a) do {} while(0)
-#define audio_extn_passthru_should_standby(o) (1)
-#define audio_extn_passthru_get_channel_count(out) (0)
-#define audio_extn_passthru_update_dts_stream_configuration(out, buffer, bytes) (-ENOSYS)
-#define audio_extn_passthru_is_direct_passthrough(out)	(0)
-#define audio_extn_passthru_is_supported_backend_edid_cfg(adev, out) (0)
-#else
+typedef bool (*fp_platform_is_edid_supported_format_t)(void*, int);
+typedef int (*fp_platform_set_device_params_t)(struct stream_out*, int, int);
+typedef int (*fp_platform_edid_get_max_channels_t)(void*);
+typedef snd_device_t (*fp_platform_get_output_snd_device_t)(void*, struct stream_out*);
+typedef int (*fp_platform_get_codec_backend_cfg_t)(struct audio_device*,
+                                                snd_device_t, struct audio_backend_cfg*);
+typedef bool (*fp_platform_is_edid_supported_sample_rate_t)(void*, int);
+
+typedef void (*fp_audio_extn_keep_alive_start_t)(ka_mode_t);
+typedef void (*fp_audio_extn_keep_alive_stop_t)(ka_mode_t);
+typedef bool (*fp_audio_extn_utils_is_dolby_format_t)(audio_format_t);
+
+
+typedef struct passthru_init_config {
+  fp_platform_is_edid_supported_format_t fp_platform_is_edid_supported_format;
+  fp_platform_set_device_params_t fp_platform_set_device_params;
+  fp_platform_edid_get_max_channels_t fp_platform_edid_get_max_channels;
+  fp_platform_get_output_snd_device_t fp_platform_get_output_snd_device;
+  fp_platform_get_codec_backend_cfg_t fp_platform_get_codec_backend_cfg;
+  fp_platform_get_snd_device_name_t fp_platform_get_snd_device_name;
+  fp_platform_is_edid_supported_sample_rate_t fp_platform_is_edid_supported_sample_rate;
+  fp_audio_extn_keep_alive_start_t fp_audio_extn_keep_alive_start;
+  fp_audio_extn_keep_alive_stop_t fp_audio_extn_keep_alive_stop;
+  fp_audio_extn_utils_is_dolby_format_t fp_audio_extn_utils_is_dolby_format;
+} passthru_init_config_t;
+
 bool audio_extn_passthru_is_convert_supported(struct audio_device *adev,
                                                  struct stream_out *out);
-bool audio_extn_passthru_is_passt_supported(struct audio_device *adev,
-                                         struct stream_out *out);
+bool audio_extn_passthru_is_passt_supported(struct stream_out *out);
 void audio_extn_passthru_update_stream_configuration(
         struct audio_device *adev, struct stream_out *out,
         const void *buffer, size_t bytes);
@@ -628,7 +592,6 @@
                                        struct str_parms *parms);
 bool audio_extn_passthru_is_enabled();
 bool audio_extn_passthru_is_active();
-void audio_extn_passthru_init(struct audio_device *adev);
 bool audio_extn_passthru_should_standby(struct stream_out *out);
 int audio_extn_passthru_get_channel_count(struct stream_out *out);
 int audio_extn_passthru_update_dts_stream_configuration(struct stream_out *out,
@@ -636,22 +599,75 @@
 bool audio_extn_passthru_is_direct_passthrough(struct stream_out *out);
 bool audio_extn_passthru_is_supported_backend_edid_cfg(struct audio_device *adev,
                                                    struct stream_out *out);
-#endif
+bool audio_extn_is_hdmi_passthru_enabled();
 
-#ifndef HFP_ENABLED
-#define audio_extn_hfp_is_active(adev)                  (0)
-#define audio_extn_hfp_get_usecase()                    (-1)
-#define hfp_set_mic_mute(dev, state)                    (0)
-#define audio_extn_hfp_set_parameters(adev, parms)      (0)
-#define audio_extn_hfp_set_mic_mute(adev, state)        (0)
-#else
+// END: HDMI_PASSTHROUGH ==================================================
+// START: HFP FEATURE ==================================================
 bool audio_extn_hfp_is_active(struct audio_device *adev);
 audio_usecase_t audio_extn_hfp_get_usecase();
-int hfp_set_mic_mute(struct audio_device *dev, bool state);
+int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state);
 void audio_extn_hfp_set_parameters(struct audio_device *adev,
                                            struct str_parms *parms);
-int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state);
-#endif
+int audio_extn_hfp_set_mic_mute2(struct audio_device *adev, bool state);
+
+typedef int (*fp_platform_set_mic_mute_t)(void *, bool);
+//typedef int (*fp_platform_get_pcm_device_id_t)(audio_usecase_t, int);
+typedef void (*fp_platform_set_echo_reference_t)(struct audio_device *, bool,
+                                                            audio_devices_t);
+typedef int (*fp_select_devices_t)(struct audio_device *, audio_usecase_t);
+typedef int (*fp_audio_extn_ext_hw_plugin_usecase_start_t)(void *,
+                                                      struct audio_usecase *);
+typedef int (*fp_audio_extn_ext_hw_plugin_usecase_stop_t)(void *,
+                                                      struct audio_usecase *);
+//typedef struct audio_usecase (*fp_get_usecase_from_list_t)(const struct audio_device *,
+//                                                                  audio_usecase_t);
+typedef int (*fp_disable_audio_route_t)(struct audio_device *,
+                                                struct audio_usecase *);
+typedef int (*fp_disable_snd_device_t)(struct audio_device *, snd_device_t);
+typedef bool (*fp_voice_get_mic_mute_t)(struct audio_device *);
+
+typedef struct hfp_init_config {
+    fp_platform_set_mic_mute_t                   fp_platform_set_mic_mute;
+    fp_platform_get_pcm_device_id_t              fp_platform_get_pcm_device_id;
+    fp_platform_set_echo_reference_t             fp_platform_set_echo_reference;
+    fp_select_devices_t                          fp_select_devices;
+    fp_audio_extn_ext_hw_plugin_usecase_start_t  fp_audio_extn_ext_hw_plugin_usecase_start;
+    fp_audio_extn_ext_hw_plugin_usecase_stop_t   fp_audio_extn_ext_hw_plugin_usecase_stop;
+    fp_get_usecase_from_list_t                   fp_get_usecase_from_list;
+    fp_disable_audio_route_t                     fp_disable_audio_route;
+    fp_disable_snd_device_t                      fp_disable_snd_device;
+    fp_voice_get_mic_mute_t                      fp_voice_get_mic_mute;
+} hfp_init_config_t;
+
+
+// END: HFP FEATURE ==================================================
+
+// START: EXT_HW_PLUGIN FEATURE ==================================================
+void* audio_extn_ext_hw_plugin_init(struct audio_device *adev);
+int audio_extn_ext_hw_plugin_deinit(void *plugin);
+int audio_extn_ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase);
+int audio_extn_ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase);
+int audio_extn_ext_hw_plugin_set_parameters(void *plugin,
+                                           struct str_parms *parms);
+int audio_extn_ext_hw_plugin_get_parameters(void *plugin,
+                  struct str_parms *query, struct str_parms *reply);
+int audio_extn_ext_hw_plugin_set_mic_mute(void *plugin, bool mute);
+int audio_extn_ext_hw_plugin_get_mic_mute(void *plugin, bool *mute);
+int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
+            struct audio_usecase *usecase, uint32_t gain);
+
+typedef int   (*fp_audio_route_apply_and_update_path_t)(struct audio_route*, const char*);
+
+typedef struct ext_hw_plugin_init_config {
+    fp_audio_route_apply_and_update_path_t    fp_audio_route_apply_and_update_path;
+} ext_hw_plugin_init_config_t;
+// END: EXT_HW_PLUGIN FEATURE ==================================================
+
+// START: BATTERY_LISTENER FEATURE ==================================================
+void audio_extn_battery_properties_listener_init(battery_status_change_fn_t fn);
+void audio_extn_battery_properties_listener_deinit();
+bool audio_extn_battery_properties_is_charging();
+// END: BATTERY_LISTENER FEATURE ==================================================
 
 int audio_extn_utils_send_app_type_gain(struct audio_device *adev,
                                         int app_type,
@@ -941,7 +957,7 @@
 
 #endif /* AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED */
 
-#ifdef COMPRESS_INPUT_ENABLED
+// START: COMPRESS_INPUT_ENABLED ===============================
 bool audio_extn_cin_applicable_stream(struct stream_in *in);
 bool audio_extn_cin_attached_usecase(audio_usecase_t uc_id);
 bool audio_extn_cin_format_supported(audio_format_t format);
@@ -952,17 +968,7 @@
 int audio_extn_cin_read(struct stream_in *in, void *buffer,
                         size_t bytes, size_t *bytes_read);
 int audio_extn_cin_configure_input_stream(struct stream_in *in);
-#else
-#define audio_extn_cin_applicable_stream(in) (false)
-#define audio_extn_cin_attached_usecase(uc_id) (false)
-#define audio_extn_cin_format_supported(format) (false)
-#define audio_extn_cin_get_buffer_size(in) (0)
-#define audio_extn_cin_start_input_stream(in) (0)
-#define audio_extn_cin_stop_input_stream(in) (0)
-#define audio_extn_cin_close_input_stream(in) (0)
-#define audio_extn_cin_read(in, buffer, bytes, bytes_read) (0)
-#define audio_extn_cin_configure_input_stream(in) (0)
-#endif
+// END: COMPRESS_INPUT_ENABLED ===============================
 
 //START: SOURCE_TRACKING_FEATURE ==============================================
 int audio_extn_get_soundfocus_data(const struct audio_device *adev,
@@ -1146,6 +1152,9 @@
 
 int audio_extn_utils_get_license_params(const struct audio_device *adev,  struct audio_license_params *lic_params);
 
+/*
+ * TODO: AUTO TEAM to convert following feature flag to runtime flag enable
+*/
 #ifndef AUDIO_EXTN_AUTO_HAL_ENABLED
 #define audio_extn_auto_hal_init(adev)                (0)
 #define audio_extn_auto_hal_deinit()                  (0)
@@ -1169,31 +1178,6 @@
                                 audio_patch_handle_t handle);
 #endif
 
-#ifndef EXT_HW_PLUGIN_ENABLED
-#define audio_extn_ext_hw_plugin_init(adev)                (0)
-#define audio_extn_ext_hw_plugin_deinit(plugin)              (0)
-#define audio_extn_ext_hw_plugin_usecase_start(plugin, usecase) (0)
-#define audio_extn_ext_hw_plugin_usecase_stop(plugin, usecase) (0)
-#define audio_extn_ext_hw_plugin_set_parameters(plugin, parms) (0)
-#define audio_extn_ext_hw_plugin_get_parameters(plugin, query, reply) (0)
-#define audio_extn_ext_hw_plugin_set_mic_mute(plugin, mute) (0)
-#define audio_extn_ext_hw_plugin_get_mic_mute(plugin, mute) (0)
-#define audio_extn_ext_hw_plugin_set_audio_gain(plugin, usecase, gain) (0)
-#else
-void* audio_extn_ext_hw_plugin_init(struct audio_device *adev);
-int audio_extn_ext_hw_plugin_deinit(void *plugin);
-int audio_extn_ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase);
-int audio_extn_ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase);
-int audio_extn_ext_hw_plugin_set_parameters(void *plugin,
-                                           struct str_parms *parms);
-int audio_extn_ext_hw_plugin_get_parameters(void *plugin,
-                  struct str_parms *query, struct str_parms *reply);
-int audio_extn_ext_hw_plugin_set_mic_mute(void *plugin, bool mute);
-int audio_extn_ext_hw_plugin_get_mic_mute(void *plugin, bool *mute);
-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);
@@ -1211,4 +1195,6 @@
 void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out);
 
 void audio_extn_set_cpu_affinity();
+bool audio_extn_is_record_play_concurrency_enabled();
+bool audio_extn_is_concurrent_capture_enabled();
 #endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/battery_listener.cpp b/hal/audio_extn/battery_listener.cpp
index 5f19443..55db095 100644
--- a/hal/audio_extn/battery_listener.cpp
+++ b/hal/audio_extn/battery_listener.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+* 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
@@ -228,19 +228,19 @@
 } // namespace android
 
 extern "C" {
-void audio_extn_battery_properties_listener_init(battery_status_change_fn_t fn)
+void battery_properties_listener_init(battery_status_change_fn_t fn)
 {
     android::batteryPropertiesListenerInit([=](bool charging) {
                                                fn(charging);
                                           });
 }
 
-void audio_extn_battery_properties_listener_deinit()
+void battery_properties_listener_deinit()
 {
     android::batteryPropertiesListenerDeinit();
 }
 
-bool audio_extn_battery_properties_is_charging()
+bool battery_properties_is_charging()
 {
     return android::batteryPropertiesListenerIsCharging();
 }
diff --git a/hal/audio_extn/battery_listener.h b/hal/audio_extn/battery_listener.h
index 2fcd010..a34b358 100644
--- a/hal/audio_extn/battery_listener.h
+++ b/hal/audio_extn/battery_listener.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+* 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
@@ -26,19 +26,13 @@
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-#ifdef BATTERY_LISTENER_ENABLED
 #ifdef __cplusplus
 extern "C" {
 #endif
 typedef void (* battery_status_change_fn_t)(bool);
-void audio_extn_battery_properties_listener_init(battery_status_change_fn_t fn);
-void audio_extn_battery_properties_listener_deinit();
-bool audio_extn_battery_properties_is_charging();
+void battery_properties_listener_init(battery_status_change_fn_t fn);
+void battery_properties_listener_deinit();
+bool battery_properties_is_charging();
 #ifdef __cplusplus
 }
 #endif
-#else
-#define audio_extn_battery_properties_listener_init(fn) do { } while(0)
-#define audio_extn_battery_properties_listener_deinit() do { } while(0)
-#define audio_extn_battery_properties_is_charging() (false)
-#endif
diff --git a/hal/audio_extn/compress_in.c b/hal/audio_extn/compress_in.c
index 3066f3c..56905d6 100644
--- a/hal/audio_extn/compress_in.c
+++ b/hal/audio_extn/compress_in.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-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
@@ -31,11 +31,11 @@
 /*#define LOG_NDEBUG 0*/
 #define LOG_NDDEBUG 0
 
-#ifdef COMPRESS_INPUT_ENABLED
 #include <cutils/log.h>
 #include <cutils/properties.h>
 #include <cutils/str_parms.h>
 #include <cutils/log.h>
+#include <pthread.h>
 
 #include "audio_hw.h"
 #include "platform.h"
@@ -89,7 +89,7 @@
 
 static pthread_mutex_t cin_lock = PTHREAD_MUTEX_INITIALIZER;
 
-bool audio_extn_cin_applicable_stream(struct stream_in *in)
+bool cin_applicable_stream(struct stream_in *in)
 {
     if (in->flags & (AUDIO_INPUT_FLAG_COMPRESS | AUDIO_INPUT_FLAG_TIMESTAMP))
         return true;
@@ -97,14 +97,14 @@
     return false;
 }
 
-/* all audio_extn_cin_xxx calls must be made on an input
- * only after validating that input against audio_extn_cin_attached_usecase
+/* all cin_xxx calls must be made on an input
+ * only after validating that input against cin_attached_usecase
  * except below calls
- * 1. audio_extn_cin_applicable_stream(in)
- * 2. audio_extn_cin_configure_input_stream(in)
+ * 1. cin_applicable_stream(in)
+ * 2. cin_configure_input_stream(in)
  */
 
-bool audio_extn_cin_attached_usecase(audio_usecase_t uc_id)
+bool cin_attached_usecase(audio_usecase_t uc_id)
 {
     unsigned int i;
 
@@ -157,7 +157,7 @@
     pthread_mutex_unlock(&cin_lock);
 }
 
-bool audio_extn_cin_format_supported(audio_format_t format)
+bool cin_format_supported(audio_format_t format)
 {
     if (format == AUDIO_FORMAT_IEC61937)
         return true;
@@ -165,7 +165,7 @@
         return false;
 }
 
-size_t audio_extn_cin_get_buffer_size(struct stream_in *in)
+size_t cin_get_buffer_size(struct stream_in *in)
 {
     size_t sz = 0;
     cin_private_data_t *cin_data = (cin_private_data_t *) in->cin_extn;
@@ -180,7 +180,7 @@
     return sz;
 }
 
-int audio_extn_cin_start_input_stream(struct stream_in *in)
+int cin_start_input_stream(struct stream_in *in)
 {
     int ret = -EINVAL;
     struct audio_device *adev = in->dev;
@@ -203,7 +203,7 @@
     return ret;
 }
 
-void audio_extn_cin_stop_input_stream(struct stream_in *in)
+void cin_stop_input_stream(struct stream_in *in)
 {
     cin_private_data_t *cin_data = (cin_private_data_t *) in->cin_extn;
 
@@ -214,7 +214,7 @@
     }
 }
 
-void audio_extn_cin_close_input_stream(struct stream_in *in)
+void cin_close_input_stream(struct stream_in *in)
 {
     cin_private_data_t *cin_data = (cin_private_data_t *) in->cin_extn;
 
@@ -226,7 +226,7 @@
     free_cin_usecase(in->usecase);
 }
 
-int audio_extn_cin_read(struct stream_in *in, void *buffer,
+int cin_read(struct stream_in *in, void *buffer,
                         size_t bytes, size_t *bytes_read)
 {
     int ret = -EINVAL;
@@ -266,7 +266,7 @@
     return ret;
 }
 
-int audio_extn_cin_configure_input_stream(struct stream_in *in)
+int cin_configure_input_stream(struct stream_in *in)
 {
     struct audio_device *adev = in->dev;
     struct audio_config config = {.format = 0};
@@ -333,7 +333,6 @@
     return ret;
 
 err_config:
-    audio_extn_cin_close_input_stream(in);
+    cin_close_input_stream(in);
     return ret;
 }
-#endif /* COMPRESS_INPUT_ENABLED end */
diff --git a/hal/audio_extn/ext_hw_plugin.c b/hal/audio_extn/ext_hw_plugin.c
index 67ac3e7..f6c4799 100644
--- a/hal/audio_extn/ext_hw_plugin.c
+++ b/hal/audio_extn/ext_hw_plugin.c
@@ -41,6 +41,20 @@
 #include "audio_hal_plugin.h"
 
 
+// - 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;
+
+fp_audio_route_apply_and_update_path_t fp_audio_route_apply_and_update_path;
+
 #ifdef EXT_HW_PLUGIN_ENABLED
 
 typedef int32_t (*audio_hal_plugin_init_t)(void);
@@ -63,7 +77,86 @@
 /* This can be defined in platform specific file or use compile flag */
 #define LIB_PLUGIN_DRIVER "libaudiohalplugin.so"
 
-void* audio_extn_ext_hw_plugin_init(struct audio_device *adev)
+/* Note: Due to ADP H/W design, SoC TERT/SEC TDM CLK and FSYNC lines are
+ * both connected with CODEC and a single master is needed to provide
+ * consistent CLK and FSYNC to slaves, hence configuring SoC TERT TDM as
+ * single master and bring up a dummy hostless from TERT to SEC to ensure
+ * both slave SoC SEC TDM and CODEC are driven upon system boot. */
+static void ext_hw_plugin_enable_adev_hostless(void *plugin)
+{
+    struct ext_hw_plugin_data *my_plugin =
+        (struct ext_hw_plugin_data *)plugin;
+    char mixer_path[MIXER_PATH_MAX_LENGTH];
+
+    ALOGI("%s: Enable TERT -> SEC Hostless", __func__);
+
+    strlcpy(mixer_path, "dummy-hostless", MIXER_PATH_MAX_LENGTH);
+    ALOGD("%s: apply mixer and update path: %s", __func__, mixer_path);
+    if (audio_route_apply_and_update_path(my_plugin->adev->audio_route,
+            mixer_path)) {
+        ALOGE("%s: %s not supported, continue", __func__, mixer_path);
+        return;
+    }
+
+    /* TERT TDM TX 7 HOSTLESS to SEC TDM RX 7 HOSTLESS */
+    int pcm_dev_rx = 48, pcm_dev_tx = 49;
+    struct pcm_config pcm_config_lb = {
+        .channels = 1,
+        .rate = 48000,
+        .period_size = 240,
+        .period_count = 2,
+        .format = PCM_FORMAT_S16_LE,
+        .start_threshold = 0,
+        .stop_threshold = INT_MAX,
+        .avail_min = 0,
+    };
+
+    my_plugin->adev_hostless.pcm_tx = pcm_open(my_plugin->adev->snd_card,
+                                   pcm_dev_tx,
+                                   PCM_IN, &pcm_config_lb);
+    if (my_plugin->adev_hostless.pcm_tx &&
+        !pcm_is_ready(my_plugin->adev_hostless.pcm_tx)) {
+        ALOGE("%s: %s", __func__,
+            pcm_get_error(my_plugin->adev_hostless.pcm_tx));
+        return;
+    }
+    my_plugin->adev_hostless.pcm_rx = pcm_open(my_plugin->adev->snd_card,
+                                   pcm_dev_rx,
+                                   PCM_OUT, &pcm_config_lb);
+    if (my_plugin->adev_hostless.pcm_rx &&
+        !pcm_is_ready(my_plugin->adev_hostless.pcm_rx)) {
+        ALOGE("%s: %s", __func__,
+            pcm_get_error(my_plugin->adev_hostless.pcm_rx));
+        return;
+    }
+
+    if (pcm_start(my_plugin->adev_hostless.pcm_tx) < 0) {
+        ALOGE("%s: pcm start for pcm tx failed", __func__);
+        return;
+    }
+    if (pcm_start(my_plugin->adev_hostless.pcm_rx) < 0) {
+        ALOGE("%s: pcm start for pcm rx failed", __func__);
+        return;
+    }
+}
+
+static void ext_hw_plugin_disable_adev_hostless(void *plugin)
+{
+    struct ext_hw_plugin_data *my_plugin = (struct ext_hw_plugin_data *)plugin;
+
+    ALOGI("%s: Disable TERT -> SEC Hostless", __func__);
+
+    if (my_plugin->adev_hostless.pcm_tx) {
+        pcm_close(my_plugin->adev_hostless.pcm_tx);
+        my_plugin->adev_hostless.pcm_tx = NULL;
+    }
+    if (my_plugin->adev_hostless.pcm_rx) {
+        pcm_close(my_plugin->adev_hostless.pcm_rx);
+        my_plugin->adev_hostless.pcm_rx = NULL;
+    }
+}
+
+void* ext_hw_plugin_init(struct audio_device *adev, ext_hw_plugin_init_config_t init_config)
 {
     int32_t ret = 0;
     struct ext_hw_plugin_data *my_plugin = NULL;
@@ -76,7 +169,7 @@
     }
 
     my_plugin->adev = adev;
-
+    fp_audio_route_apply_and_update_path = init_config.fp_audio_route_apply_and_update_path;
     (void)audio_extn_auto_hal_enable_hostless();
 
     my_plugin->plugin_handle = dlopen(LIB_PLUGIN_DRIVER, RTLD_NOW);
@@ -116,7 +209,7 @@
             goto plugin_init_fail;
         }
     }
-
+    ext_hw_plugin_enable_adev_hostless(my_plugin);
     my_plugin->mic_mute = false;
     return my_plugin;
 
@@ -127,7 +220,7 @@
     return NULL;
 }
 
-int32_t audio_extn_ext_hw_plugin_deinit(void *plugin)
+int32_t ext_hw_plugin_deinit(void *plugin)
 {
     int32_t ret = 0;
     struct ext_hw_plugin_data *my_plugin = (struct ext_hw_plugin_data *)plugin;
@@ -136,7 +229,7 @@
         ALOGE("[%s] NULL plugin pointer",__func__);
         return -EINVAL;
     }
-
+    ext_hw_plugin_disable_adev_hostless(my_plugin);
     if (my_plugin->audio_hal_plugin_deinit) {
         ret = my_plugin->audio_hal_plugin_deinit();
         if (ret) {
@@ -195,7 +288,7 @@
     return ret;
 }
 
-int32_t audio_extn_ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase)
+int32_t ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase)
 {
     int32_t ret = 0;
     struct ext_hw_plugin_data *my_plugin = (struct ext_hw_plugin_data *)plugin;
@@ -332,7 +425,7 @@
     return ret;
 }
 
-int32_t audio_extn_ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase)
+int32_t ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase)
 {
     int32_t ret = 0;
     struct ext_hw_plugin_data *my_plugin = (struct ext_hw_plugin_data *)plugin;
@@ -531,7 +624,7 @@
 }
 
 
-int32_t audio_extn_ext_hw_plugin_set_parameters(void *plugin, struct str_parms *parms)
+int32_t ext_hw_plugin_set_parameters(void *plugin, struct str_parms *parms)
 {
 
     char *value = NULL;
@@ -975,7 +1068,7 @@
     return ret;
 }
 
-int audio_extn_ext_hw_plugin_get_parameters(void *plugin,
+int ext_hw_plugin_get_parameters(void *plugin,
                   struct str_parms *query, struct str_parms *reply)
 {
     char *value = NULL;
@@ -1412,7 +1505,7 @@
     return ret;
 }
 
-int audio_extn_ext_hw_plugin_set_mic_mute(void *plugin, bool mute)
+int ext_hw_plugin_set_mic_mute(void *plugin, bool mute)
 {
     struct ext_hw_plugin_data *my_plugin = NULL;
     audio_hal_plugin_codec_set_pp_mute_t pp_mute;
@@ -1454,7 +1547,7 @@
     return ret;
 }
 
-int audio_extn_ext_hw_plugin_get_mic_mute(void *plugin, bool *mute)
+int ext_hw_plugin_get_mic_mute(void *plugin, bool *mute)
 {
     struct ext_hw_plugin_data *my_plugin = (struct ext_hw_plugin_data *)plugin;
 
@@ -1469,7 +1562,7 @@
     return 0;
 }
 
-int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
+int ext_hw_plugin_set_audio_gain(void *plugin,
             struct audio_usecase *usecase, uint32_t gain)
 {
     int32_t ret = 0;
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index 3c1ec68..f4b9d8f 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -31,6 +31,7 @@
 #include "platform_api.h"
 #include <stdlib.h>
 #include <cutils/str_parms.h>
+#include <audio_extn.h>
 
 #ifdef DYNAMIC_LOG_ENABLED
 #include <log_xml_parser.h>
@@ -368,21 +369,21 @@
         ALOGV("%s: set_fm_volume from param restore volume", __func__);
     }
 
-#ifdef RECORD_PLAY_CONCURRENCY
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC,
+    if(audio_extn_is_record_play_concurrency_enabled()) {
+        ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC,
                                value, sizeof(value));
-    if ((ret >= 0)
-          && (fmmod.is_fm_running == true)) {
+        if ((ret >= 0)
+              && (fmmod.is_fm_running == true)) {
 
-        if (!strncmp("true", value, sizeof("true")))
-            ALOGD("Record play concurrency ON Forcing FM device reroute");
-        else
-            ALOGD("Record play concurrency OFF Forcing FM device reroute");
+            if (!strncmp("true", value, sizeof("true")))
+                ALOGD("Record play concurrency ON Forcing FM device reroute");
+            else
+                ALOGD("Record play concurrency OFF Forcing FM device reroute");
 
-        select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
-        fm_set_volume(adev, fmmod.fm_volume, false);
+            select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
+            fm_set_volume(adev, fmmod.fm_volume, false);
+        }
     }
-#endif
 exit:
     ALOGV("%s: exit", __func__);
 }
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index c82e875..55551dc 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -46,7 +46,6 @@
 #include <log_utils.h>
 #endif
 
-#ifdef HFP_ENABLED
 #define AUDIO_PARAMETER_HFP_ENABLE      "hfp_enable"
 #define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
 #define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume"
@@ -115,6 +114,18 @@
     .avail_min = 0,
 };
 
+//external feature dependency
+static fp_platform_set_mic_mute_t                   fp_platform_set_mic_mute;
+static fp_platform_get_pcm_device_id_t              fp_platform_get_pcm_device_id;
+static fp_platform_set_echo_reference_t             fp_platform_set_echo_reference;
+static fp_select_devices_t                          fp_select_devices;
+static fp_audio_extn_ext_hw_plugin_usecase_start_t  fp_audio_extn_ext_hw_plugin_usecase_start;
+static fp_audio_extn_ext_hw_plugin_usecase_stop_t   fp_audio_extn_ext_hw_plugin_usecase_stop;
+static fp_get_usecase_from_list_t                   fp_get_usecase_from_list;
+static fp_disable_audio_route_t                     fp_disable_audio_route;
+static fp_disable_snd_device_t                      fp_disable_snd_device;
+static fp_voice_get_mic_mute_t                      fp_voice_get_mic_mute;
+
 static int32_t hfp_set_volume(struct audio_device *adev, float value)
 {
     int32_t vol, ret = 0;
@@ -167,6 +178,8 @@
     struct mixer_ctl *ctl;
     int pcm_device_id = HFP_ASM_RX_TX;
 
+    ALOGD("%s: enter, value=%f", __func__, value);
+
     if (!hfpmod.is_hfp_running) {
         ALOGE("%s: HFP not active, ignoring set_hfp_mic_volume call", __func__);
         return -EIO;
@@ -209,6 +222,8 @@
     int pcm_device_id = HFP_ASM_RX_TX;
     float value = 0.0;
 
+    ALOGD("%s: enter", __func__);
+
     if (!hfpmod.is_hfp_running) {
         ALOGE("%s: HFP not active, ignoring set_hfp_mic_volume call", __func__);
         return -EIO;
@@ -247,7 +262,7 @@
 *
 * This interface is used for mic mute state control
 */
-int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state)
+int hfp_set_mic_mute(struct audio_device *adev, bool state)
 {
     int rc = 0;
 
@@ -278,7 +293,7 @@
         return 0;
     }
     adev->enable_hfp = true;
-    platform_set_mic_mute(adev->platform, false);
+    fp_platform_set_mic_mute(adev->platform, false);
 
     uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
 
@@ -294,16 +309,16 @@
 
     list_add_tail(&adev->usecase_list, &uc_info->list);
 
-    select_devices(adev, hfpmod.ucid);
+    fp_select_devices(adev, hfpmod.ucid);
 
     if ((uc_info->out_snd_device != SND_DEVICE_NONE) ||
         (uc_info->in_snd_device != SND_DEVICE_NONE)) {
-        if (audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info))
+        if (fp_audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info))
             ALOGE("%s: failed to start ext hw plugin", __func__);
     }
 
-    pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
-    pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
+    pcm_dev_rx_id = fp_platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
+    pcm_dev_tx_id = fp_platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
     pcm_dev_asm_rx_id = hfpmod.hfp_pcm_dev_id;
     pcm_dev_asm_tx_id = hfpmod.hfp_pcm_dev_id;
     if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0 ||
@@ -380,7 +395,7 @@
 
     /* Set mic volume by mute status, we don't provide set mic volume in phone app, only
     provide mute and unmute. */
-    audio_extn_hfp_set_mic_mute(adev, adev->mic_muted);
+    hfp_set_mic_mute(adev, adev->mic_muted);
 
     ALOGD("%s: exit: status(%d)", __func__, ret);
     return 0;
@@ -417,7 +432,7 @@
         hfpmod.hfp_pcm_tx = NULL;
     }
 
-    uc_info = get_usecase_from_list(adev, hfpmod.ucid);
+    uc_info = fp_get_usecase_from_list(adev, hfpmod.ucid);
     if (uc_info == NULL) {
         ALOGE("%s: Could not find the usecase (%d) in the list",
               __func__, hfpmod.ucid);
@@ -426,23 +441,23 @@
 
     if ((uc_info->out_snd_device != SND_DEVICE_NONE) ||
         (uc_info->in_snd_device != SND_DEVICE_NONE)) {
-        if (audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info))
+        if (fp_audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info))
             ALOGE("%s: failed to stop ext hw plugin", __func__);
     }
 
     /* 2. Disable echo reference while stopping hfp */
-    platform_set_echo_reference(adev, false, uc_info->devices);
+    fp_platform_set_echo_reference(adev, false, uc_info->devices);
 
     /* 3. Get and set stream specific mixer controls */
-    disable_audio_route(adev, uc_info);
+    fp_disable_audio_route(adev, uc_info);
 
     /* 4. Disable the rx and tx devices */
-    disable_snd_device(adev, uc_info->out_snd_device);
-    disable_snd_device(adev, uc_info->in_snd_device);
+    fp_disable_snd_device(adev, uc_info->out_snd_device);
+    fp_disable_snd_device(adev, uc_info->in_snd_device);
 
     /* Set the unmute Tx mixer control */
-    if (voice_get_mic_mute(adev)) {
-        platform_set_mic_mute(adev->platform, false);
+    if (fp_voice_get_mic_mute(adev)) {
+        fp_platform_set_mic_mute(adev->platform, false);
         ALOGD("%s: unMute HFP Tx", __func__);
     }
     adev->enable_hfp = false;
@@ -454,10 +469,26 @@
     return ret;
 }
 
-bool audio_extn_hfp_is_active(struct audio_device *adev)
+void hfp_init(hfp_init_config_t init_config)
+{
+    fp_platform_set_mic_mute = init_config.fp_platform_set_mic_mute;
+    fp_platform_get_pcm_device_id = init_config.fp_platform_get_pcm_device_id;
+    fp_platform_set_echo_reference = init_config.fp_platform_set_echo_reference;
+    fp_select_devices = init_config.fp_select_devices;
+    fp_audio_extn_ext_hw_plugin_usecase_start =
+                                init_config.fp_audio_extn_ext_hw_plugin_usecase_start;
+    fp_audio_extn_ext_hw_plugin_usecase_stop =
+                                init_config.fp_audio_extn_ext_hw_plugin_usecase_stop;
+    fp_get_usecase_from_list = init_config.fp_get_usecase_from_list;
+    fp_disable_audio_route = init_config.fp_disable_audio_route;
+    fp_disable_snd_device = init_config.fp_disable_snd_device;
+    fp_voice_get_mic_mute = init_config.fp_voice_get_mic_mute;
+}
+
+bool hfp_is_active(struct audio_device *adev)
 {
     struct audio_usecase *hfp_usecase = NULL;
-    hfp_usecase = get_usecase_from_list(adev, hfpmod.ucid);
+    hfp_usecase = fp_get_usecase_from_list(adev, hfpmod.ucid);
 
     if (hfp_usecase != NULL)
         return true;
@@ -465,13 +496,13 @@
         return false;
 }
 
-int hfp_set_mic_mute(struct audio_device *adev, bool state)
+int hfp_set_mic_mute2(struct audio_device *adev, bool state)
 {
     struct mixer_ctl *ctl;
     const char *mixer_ctl_name = "HFP TX Mute";
     long set_values[ ] = {0};
 
-    ALOGI("%s: enter, state=%d", __func__, state);
+    ALOGD("%s: enter, state=%d", __func__, state);
 
     set_values[0] = state;
     ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
@@ -485,12 +516,12 @@
     return 0;
 }
 
-audio_usecase_t audio_extn_hfp_get_usecase()
+audio_usecase_t hfp_get_usecase()
 {
     return hfpmod.ucid;
 }
 
-void audio_extn_hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
+void hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
 {
     int ret;
     int rate;
@@ -498,6 +529,8 @@
     float vol;
     char value[32]={0};
 
+    ALOGD("%s: enter", __func__);
+
     ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
                             sizeof(value));
     if (ret >= 0) {
@@ -530,7 +563,7 @@
         if (ret >= 0) {
             val = atoi(value);
             if (val > 0)
-                select_devices(adev, hfpmod.ucid);
+                fp_select_devices(adev, hfpmod.ucid);
         }
     }
 
@@ -571,4 +604,3 @@
 exit:
     ALOGV("%s Exit",__func__);
 }
-#endif /*HFP_ENABLED*/
diff --git a/hal/audio_extn/passthru.c b/hal/audio_extn/passthru.c
index 9180391..14f8b72 100644
--- a/hal/audio_extn/passthru.c
+++ b/hal/audio_extn/passthru.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-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
@@ -34,6 +34,7 @@
 #include <cutils/str_parms.h>
 #include <cutils/log.h>
 #include <unistd.h>
+#include <pthread.h>
 #include "audio_hw.h"
 #include "audio_extn.h"
 #include "platform_api.h"
@@ -82,6 +83,18 @@
     AUDIO_FORMAT_IEC61937
 };
 
+//external function depedency
+static fp_platform_is_edid_supported_format_t fp_platform_is_edid_supported_format;
+static fp_platform_set_device_params_t fp_platform_set_device_params;
+static fp_platform_edid_get_max_channels_t fp_platform_edid_get_max_channels;
+static fp_platform_get_output_snd_device_t fp_platform_get_output_snd_device;
+static fp_platform_get_codec_backend_cfg_t fp_platform_get_codec_backend_cfg;
+static fp_platform_get_snd_device_name_t fp_platform_get_snd_device_name;
+static fp_platform_is_edid_supported_sample_rate_t fp_platform_is_edid_supported_sample_rate;
+static fp_audio_extn_keep_alive_start_t fp_audio_extn_keep_alive_start;
+static fp_audio_extn_keep_alive_stop_t fp_audio_extn_keep_alive_stop;
+static fp_audio_extn_utils_is_dolby_format_t fp_audio_extn_utils_is_dolby_format;
+
 /*
  * This atomic var is incremented/decremented by the offload stream to notify
  * other pcm playback streams that a pass thru session is about to start or has
@@ -92,8 +105,7 @@
  */
 static volatile int32_t compress_passthru_active;
 
-#ifdef DTSHD_PARSER_ENABLED
-int audio_extn_passthru_update_dts_stream_configuration(struct stream_out *out,
+int passthru_update_dts_stream_configuration(struct stream_out *out,
         const void *buffer, size_t bytes)
 {
     struct audio_parser_codec_info codec_info;
@@ -115,8 +127,8 @@
     }
 
     if (!buffer || bytes <= 0) {
-        ALOGD("Invalid buffer %p size %d skipping dts stream conf update",
-                buffer, bytes);
+        ALOGD("Invalid buffer %p size %lu skipping dts stream conf update",
+                buffer, (unsigned long)bytes);
         out->sample_rate = 48000;
         out->compr_config.codec->sample_rate = out->sample_rate;
         out->compr_config.codec->ch_in = 2;
@@ -137,7 +149,7 @@
         ALOGD("dts new sample rate %d and channels %d\n",
                dtshd_tr_info.sample_rate,
                dtshd_tr_info.num_channels);
-        for (i = 0; i < sizeof(dts_transmission_sample_rates); i++) {
+        for (i = 0; i < (sizeof(dts_transmission_sample_rates)/sizeof(int)); i++) {
             if (dts_transmission_sample_rates[i] ==
                     dtshd_tr_info.sample_rate) {
                 out->sample_rate = dtshd_tr_info.sample_rate;
@@ -160,7 +172,7 @@
 
     if (!is_valid_transmission_rate) {
         ALOGE("%s:: Invalid dts transmission rate %d\n using default sample rate 48000",
-               dtshd_tr_info.sample_rate);
+                                                    __func__, dtshd_tr_info.sample_rate);
         out->sample_rate = 48000;
         out->compr_config.codec->sample_rate = out->sample_rate;
     }
@@ -173,17 +185,24 @@
     }
     return 0;
 }
-#else
-int audio_extn_passthru_update_dts_stream_configuration(
-                        struct stream_out *out __unused,
-                        const void *buffer __unused,
-                        size_t bytes __unused)
-{
-    return -ENOSYS;
-}
-#endif
 
-int audio_extn_passthru_get_channel_count(struct stream_out *out)
+bool passthru_is_supported_format(audio_format_t format)
+{
+    int32_t num_passthru_formats = sizeof(audio_passthru_formats) /
+                                    sizeof(audio_passthru_formats[0]);
+    int32_t i;
+
+    for (i = 0; i < num_passthru_formats; i++) {
+        if (format == audio_passthru_formats[i]) {
+            ALOGD("%s : pass through format is true", __func__);
+            return true;
+        }
+    }
+    ALOGD("%s : pass through format is false", __func__);
+    return false;
+}
+
+int passthru_get_channel_count(struct stream_out *out)
 {
     int channel_count = DEFAULT_HDMI_OUT_CHANNELS;
 
@@ -192,7 +211,7 @@
         return -EINVAL;
     }
 
-    if (!audio_extn_passthru_is_supported_format(out->format)) {
+    if (!passthru_is_supported_format(out->format)) {
         ALOGE("%s:: not a passthrough format %d", __func__, out->format);
         return -EINVAL;
     }
@@ -218,28 +237,12 @@
    return channel_count;
 }
 
-bool audio_extn_passthru_is_supported_format(audio_format_t format)
-{
-    int32_t num_passthru_formats = sizeof(audio_passthru_formats) /
-                                    sizeof(audio_passthru_formats[0]);
-    int32_t i;
-
-    for (i = 0; i < num_passthru_formats; i++) {
-        if (format == audio_passthru_formats[i]) {
-            ALOGD("%s : pass through format is true", __func__);
-            return true;
-        }
-    }
-    ALOGD("%s : pass through format is false", __func__);
-    return false;
-}
-
 /*
  * must be called with stream lock held
  * This function decides based on some rules whether the data
  * coming on stream out must be rendered or dropped.
  */
-bool audio_extn_passthru_should_drop_data(struct stream_out * out)
+bool passthru_should_drop_data(struct stream_out * out)
 {
     /*Drop data only
      *stream is routed to HDMI and
@@ -259,7 +262,7 @@
 }
 
 /* called with adev lock held */
-void audio_extn_passthru_on_start(struct stream_out * out)
+void passthru_on_start(struct stream_out * out)
 {
 
     uint64_t max_period_us = 0;
@@ -301,7 +304,7 @@
 }
 
 /* called with adev lock held */
-void audio_extn_passthru_on_stop(struct stream_out * out)
+void passthru_on_stop(struct stream_out * out)
 {
     if (android_atomic_acquire_load(&compress_passthru_active) > 0) {
         /*
@@ -313,17 +316,22 @@
 
     if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
         ALOGD("%s: passthru on aux digital, start keep alive", __func__);
-        audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI);
+        fp_audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI);
     }
 }
 
-void audio_extn_passthru_on_pause(struct stream_out * out __unused)
+void passthru_on_pause(struct stream_out * out __unused)
 {
     if (android_atomic_acquire_load(&compress_passthru_active) == 0)
         return;
 }
 
-int audio_extn_passthru_set_parameters(struct audio_device *adev __unused,
+bool passthru_is_active()
+{
+    return android_atomic_acquire_load(&compress_passthru_active) > 0;
+}
+
+int passthru_set_parameters(struct audio_device *adev __unused,
                                        struct str_parms *parms)
 {
     char value[32];
@@ -332,9 +340,9 @@
     if (ret >= 0) {
         int val = atoi(value);
         if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
-            if (!audio_extn_passthru_is_active()) {
+            if (!passthru_is_active()) {
                 ALOGV("%s: start keep alive on aux digital", __func__);
-                audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI);
+                fp_audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI);
             }
         }
     }
@@ -345,29 +353,38 @@
         int val = atoi(value);
         if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
             ALOGV("%s: stop keep_alive on aux digital on device", __func__);
-            audio_extn_keep_alive_stop(KEEP_ALIVE_OUT_HDMI);
+            fp_audio_extn_keep_alive_stop(KEEP_ALIVE_OUT_HDMI);
         }
     }
     return 0;
 }
 
-bool audio_extn_passthru_is_active()
+bool passthru_is_enabled() { return true; }
+
+void passthru_init(passthru_init_config_t init_config)
 {
-    return android_atomic_acquire_load(&compress_passthru_active) > 0;
+      fp_platform_is_edid_supported_format =
+                                    init_config.fp_platform_is_edid_supported_format;
+      fp_platform_set_device_params = init_config.fp_platform_set_device_params;
+      fp_platform_edid_get_max_channels =
+                                   init_config.fp_platform_edid_get_max_channels;
+      fp_platform_get_output_snd_device = init_config.fp_platform_get_output_snd_device;
+      fp_platform_get_codec_backend_cfg =
+                                         init_config.fp_platform_get_codec_backend_cfg;
+      fp_platform_get_snd_device_name = init_config.fp_platform_get_snd_device_name;
+      fp_platform_is_edid_supported_sample_rate =
+                                    init_config.fp_platform_is_edid_supported_sample_rate;
+      fp_audio_extn_keep_alive_start = init_config.fp_audio_extn_keep_alive_start;
+      fp_audio_extn_keep_alive_stop = init_config.fp_audio_extn_keep_alive_stop;
+      fp_audio_extn_utils_is_dolby_format = init_config.fp_audio_extn_utils_is_dolby_format;
 }
 
-bool audio_extn_passthru_is_enabled() { return true; }
-
-void audio_extn_passthru_init(struct audio_device *adev __unused)
-{
-}
-
-bool audio_extn_passthru_should_standby(struct stream_out * out __unused)
+bool passthru_should_standby(struct stream_out * out __unused)
 {
     return true;
 }
 
-bool audio_extn_passthru_is_convert_supported(struct audio_device *adev,
+bool passthru_is_convert_supported(struct audio_device *adev,
                                                  struct stream_out *out)
 {
 
@@ -375,9 +392,9 @@
     switch (out->format) {
     case AUDIO_FORMAT_E_AC3:
     case AUDIO_FORMAT_E_AC3_JOC:
-        if (!platform_is_edid_supported_format(adev->platform,
+        if (!fp_platform_is_edid_supported_format(adev->platform,
                                                out->format)) {
-            if (platform_is_edid_supported_format(adev->platform,
+            if (fp_platform_is_edid_supported_format(adev->platform,
                                                   AUDIO_FORMAT_AC3)) {
                 ALOGD("%s:PASSTHROUGH_CONVERT supported", __func__);
                 convert = true;
@@ -393,7 +410,7 @@
     return convert;
 }
 
-bool audio_extn_passthru_is_passt_supported(struct audio_device *adev,
+bool passthru_is_passt_supported(struct audio_device *adev,
                                          struct stream_out *out)
 {
     bool passt = false;
@@ -401,15 +418,15 @@
     case AUDIO_FORMAT_E_AC3:
     case AUDIO_FORMAT_DTS_HD:
     case AUDIO_FORMAT_DOLBY_TRUEHD:
-        if (platform_is_edid_supported_format(adev->platform, out->format)) {
+        if (fp_platform_is_edid_supported_format(adev->platform, out->format)) {
             ALOGV("%s:PASSTHROUGH supported for format %x",
                    __func__, out->format);
             passt = true;
         }
         break;
     case AUDIO_FORMAT_AC3:
-        if (platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_AC3)
-            || platform_is_edid_supported_format(adev->platform,
+        if (fp_platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_AC3)
+            || fp_platform_is_edid_supported_format(adev->platform,
             AUDIO_FORMAT_E_AC3)) {
             ALOGV("%s:PASSTHROUGH supported for format %x",
                    __func__, out->format);
@@ -418,7 +435,7 @@
         break;
     case AUDIO_FORMAT_E_AC3_JOC:
          /* Check for DDP capability in edid for JOC contents.*/
-         if (platform_is_edid_supported_format(adev->platform,
+         if (fp_platform_is_edid_supported_format(adev->platform,
              AUDIO_FORMAT_E_AC3)) {
              ALOGV("%s:PASSTHROUGH supported for format %x",
                    __func__, out->format);
@@ -426,8 +443,8 @@
          }
          break;
     case AUDIO_FORMAT_DTS:
-        if (platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_DTS)
-            || platform_is_edid_supported_format(adev->platform,
+        if (fp_platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_DTS)
+            || fp_platform_is_edid_supported_format(adev->platform,
             AUDIO_FORMAT_DTS_HD)) {
             ALOGV("%s:PASSTHROUGH supported for format %x",
                    __func__, out->format);
@@ -440,15 +457,15 @@
     return passt;
 }
 
-void audio_extn_passthru_update_stream_configuration(
+void passthru_update_stream_configuration(
         struct audio_device *adev, struct stream_out *out,
         const void *buffer __unused, size_t bytes __unused)
 {
     if(out->compr_config.codec != NULL) {
-        if (audio_extn_passthru_is_passt_supported(adev, out)) {
+        if (passthru_is_passt_supported(adev, out)) {
             ALOGV("%s:PASSTHROUGH", __func__);
             out->compr_config.codec->compr_passthr = PASSTHROUGH;
-        } else if (audio_extn_passthru_is_convert_supported(adev, out)) {
+        } else if (passthru_is_convert_supported(adev, out)) {
             ALOGV("%s:PASSTHROUGH CONVERT", __func__);
             out->compr_config.codec->compr_passthr = PASSTHROUGH_CONVERT;
         } else if (out->format == AUDIO_FORMAT_IEC61937) {
@@ -461,7 +478,7 @@
     }
 }
 
-bool audio_extn_passthru_is_passthrough_stream(struct stream_out *out)
+bool passthru_is_passthrough_stream(struct stream_out *out)
 {
     //check passthrough system property
     if (!property_get_bool("vendor.audio.offload.passthrough", false)) {
@@ -475,13 +492,13 @@
             return true;
         //direct flag, check supported formats.
         if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT) {
-            if (audio_extn_passthru_is_supported_format(out->format)) {
-                if (platform_is_edid_supported_format(out->dev->platform,
+            if (passthru_is_supported_format(out->format)) {
+                if (fp_platform_is_edid_supported_format(out->dev->platform,
                         out->format)) {
                     ALOGV("%s : return true",__func__);
                     return true;
-                } else if (audio_extn_utils_is_dolby_format(out->format) &&
-                            platform_is_edid_supported_format(out->dev->platform,
+                } else if (fp_audio_extn_utils_is_dolby_format(out->format) &&
+                            fp_platform_is_edid_supported_format(out->dev->platform,
                                 AUDIO_FORMAT_AC3)){
                     //return true for EAC3/EAC3_JOC formats
                     //if sink supports only AC3
@@ -495,16 +512,16 @@
     return false;
 }
 
-bool audio_extn_passthru_is_direct_passthrough(struct stream_out *out)
+bool passthru_is_direct_passthrough(struct stream_out *out)
 {
-    if (((out != NULL) && audio_extn_passthru_is_passthrough_stream(out)) &&
-          !audio_extn_passthru_is_convert_supported(out->dev, out))
+    if (((out != NULL) && passthru_is_passthrough_stream(out)) &&
+          !passthru_is_convert_supported(out->dev, out))
         return true;
     else
         return false;
 }
 
-int audio_extn_passthru_get_buffer_size(audio_offload_info_t* info)
+int passthru_get_buffer_size(audio_offload_info_t* info)
 {
     uint32_t fragment_size = MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE;
     char value[PROPERTY_VALUE_MAX] = {0};
@@ -532,17 +549,17 @@
 
 }
 
-int audio_extn_passthru_set_volume(struct stream_out *out,  int mute)
+int passthru_set_volume(struct stream_out *out,  int mute)
 {
-    return platform_set_device_params(out, DEVICE_PARAM_MUTE_ID, mute);
+    return fp_platform_set_device_params(out, DEVICE_PARAM_MUTE_ID, mute);
 }
 
-int audio_extn_passthru_set_latency(struct stream_out *out, int latency)
+int passthru_set_latency(struct stream_out *out, int latency)
 {
-    return platform_set_device_params(out, DEVICE_PARAM_LATENCY_ID, latency);
+    return fp_platform_set_device_params(out, DEVICE_PARAM_LATENCY_ID, latency);
 }
 
-bool audio_extn_passthru_is_supported_backend_edid_cfg(struct audio_device *adev,
+bool passthru_is_supported_backend_edid_cfg(struct audio_device *adev,
                                                    struct stream_out *out)
 {
     struct audio_backend_cfg backend_cfg;
@@ -553,11 +570,11 @@
     backend_cfg.passthrough_enabled = false;
 
     snd_device_t out_snd_device = SND_DEVICE_NONE;
-    int max_edid_channels = platform_edid_get_max_channels(out->dev->platform);
+    int max_edid_channels = fp_platform_edid_get_max_channels(out->dev->platform);
 
-    out_snd_device = platform_get_output_snd_device(adev->platform, out);
+    out_snd_device = fp_platform_get_output_snd_device(adev->platform, out);
 
-    if (platform_get_codec_backend_cfg(adev, out_snd_device, &backend_cfg)) {
+    if (fp_platform_get_codec_backend_cfg(adev, out_snd_device, &backend_cfg)) {
         ALOGE("%s: ERROR: Unable to get current backend config!!!", __func__);
         return false;
     }
@@ -565,7 +582,7 @@
     ALOGV("%s:becf: afe: bitwidth %d, samplerate %d channels %d format %d"
           ", device (%s)", __func__,  backend_cfg.bit_width,
           backend_cfg.sample_rate, backend_cfg.channels, backend_cfg.format,
-          platform_get_snd_device_name(out_snd_device));
+          fp_platform_get_snd_device_name(out_snd_device));
 
     /* Check if the channels are supported */
     if (max_edid_channels < (int)backend_cfg.channels) {
@@ -577,7 +594,7 @@
     }
 
     /* Check if the sample rate supported */
-    if (!platform_is_edid_supported_sample_rate(adev->platform,
+    if (!fp_platform_is_edid_supported_sample_rate(adev->platform,
                                        backend_cfg.sample_rate)) {
 
         ALOGE("%s: ERROR: Unsupported sample rate in passthru mode!!!"
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index c7d3bd4..6a74a4c 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -48,10 +48,8 @@
 #endif
 
 #ifdef AUDIO_EXTERNAL_HDMI_ENABLED
-#ifdef HDMI_PASSTHROUGH_ENABLED
 #include "audio_parsers.h"
 #endif
-#endif
 
 #ifdef LINUX_ENABLED
 #define AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE "/etc/audio_output_policy.conf"
@@ -129,9 +127,7 @@
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD),
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_NON_BLOCKING),
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_HW_AV_SYNC),
-#ifdef INCALL_MUSIC_ENABLED
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_INCALL_MUSIC),
-#endif
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH),
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_TIMESTAMP),
     STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_VOIP_RX),
@@ -1786,7 +1782,6 @@
      channel_status[3] |= SR_48000;
 }
 
-#ifdef HDMI_PASSTHROUGH_ENABLED
 int32_t get_compressed_channel_status(void *audio_stream_data,
                                                    uint32_t audio_frame_size,
                                                    unsigned char *channel_status,
@@ -1815,8 +1810,6 @@
 
 }
 
-#endif
-
 void get_lpcm_channel_status(uint32_t sampleRate,
                                                   unsigned char *channel_status)
 {
@@ -1873,15 +1866,14 @@
     const char *mixer_ctl_name = "IEC958 Playback PCM Stream";
     struct mixer_ctl *ctl;
     ALOGV("%s: buffer %s bytes %zd", __func__, buffer, bytes);
-#ifdef HDMI_PASSTHROUGH_ENABLED
+
     if (audio_extn_utils_is_dolby_format(out->format) &&
         /*TODO:Extend code to support DTS passthrough*/
         /*set compressed channel status bits*/
-        audio_extn_passthru_is_passthrough_stream(out)){
+        audio_extn_passthru_is_passthrough_stream(out) &&
+        audio_extn_is_hdmi_passthru_enabled()) {
         get_compressed_channel_status(buffer, bytes, channel_status, AUDIO_PARSER_CODEC_AC3);
-    } else
-#endif
-    {
+    } else {
         /*set channel status bit for LPCM*/
         get_lpcm_channel_status(out->sample_rate, channel_status);
     }
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 13fd5d1..fccf20d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -151,6 +151,7 @@
  * TODO The flag is off until more testing is done.
  */
 static const bool k_enable_extended_precision = false;
+extern int AUDIO_DEVICE_IN_ALL_CODEC_BACKEND;
 
 struct pcm_config pcm_config_deep_buffer = {
     .channels = 2,
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 5233e5c..690f771 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -283,9 +283,8 @@
     acdb_set_codec_data_t      acdb_set_codec_data;
     acdb_reload_t              acdb_reload;
     acdb_reload_v2_t           acdb_reload_v2;
-#ifdef RECORD_PLAY_CONCURRENCY
+
     bool rec_play_conc_set;
-#endif
     void *hw_info;
     acdb_send_gain_dep_cal_t   acdb_send_gain_dep_cal;
     struct csd_data *csd;
@@ -491,11 +490,9 @@
     [SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB] = "speaker-and-bt-sco-wb",
     [SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO] = "wsa-speaker-and-bt-sco",
     [SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_WB] = "wsa-speaker-and-bt-sco-wb",
-#ifdef RECORD_PLAY_CONCURRENCY
     [SND_DEVICE_OUT_VOIP_HANDSET] = "voip-handset",
     [SND_DEVICE_OUT_VOIP_SPEAKER] = "voip-speaker",
     [SND_DEVICE_OUT_VOIP_HEADPHONES] = "voip-headphones",
-#endif
 
     /* Capture sound devices */
     [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -671,11 +668,9 @@
     [SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_PROTECTED] = 124,
     [SND_DEVICE_OUT_SPEAKER_PROTECTED_RAS] = 134,
     [SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS] = 134,
-#ifdef RECORD_PLAY_CONCURRENCY
     [SND_DEVICE_OUT_VOIP_HANDSET] = 133,
     [SND_DEVICE_OUT_VOIP_SPEAKER] = 132,
     [SND_DEVICE_OUT_VOIP_HEADPHONES] = 134,
-#endif
 
     [SND_DEVICE_IN_HANDSET_MIC] = 4,
     [SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = 4,
@@ -831,11 +826,9 @@
     {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED_RAS)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_AND_VOICE_HEADPHONES)},
-#ifdef RECORD_PLAY_CONCURRENCY
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_HANDSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_SPEAKER)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_HEADPHONES)},
-#endif
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_EXTERNAL)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)},
@@ -1687,11 +1680,9 @@
     hw_interface_table[SND_DEVICE_OUT_SPEAKER_WSA] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_WSA] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_2_WSA] = strdup("SLIMBUS_0_RX");
-#ifdef RECORD_PLAY_CONCURRENCY
     hw_interface_table[SND_DEVICE_OUT_VOIP_HANDSET] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOIP_SPEAKER] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOIP_HEADPHONES] = strdup("SLIMBUS_6_RX");
-#endif
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC_AEC] = strdup("SLIMBUS_0_TX");
@@ -4056,7 +4047,6 @@
     audio_devices_t devices = out->devices;
     unsigned int sample_rate = out->sample_rate;
     int na_mode = platform_get_native_support();
-#ifdef RECORD_PLAY_CONCURRENCY
     bool use_voip_out_devices = false;
     bool prop_rec_play_enabled = false;
     char recConcPropValue[PROPERTY_VALUE_MAX];
@@ -4067,7 +4057,6 @@
     use_voip_out_devices =  prop_rec_play_enabled &&
                         (my_data->rec_play_conc_set || adev->mode == AUDIO_MODE_IN_COMMUNICATION);
     ALOGV("platform_get_output_snd_device use_voip_out_devices : %d",use_voip_out_devices);
-#endif
 
     audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
                                 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
@@ -4268,12 +4257,10 @@
 
         } else if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET
             && audio_extn_get_anc_enabled()) {
-#ifdef RECORD_PLAY_CONCURRENCY
             if (use_voip_out_devices) {
                 // ANC should be disabled for voip concurrency
                 snd_device = SND_DEVICE_OUT_VOIP_HEADPHONES;
             } else
-#endif
             {
                 if (audio_extn_should_use_fb_anc())
                     snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET;
@@ -4292,21 +4279,17 @@
         } else if (devices & AUDIO_DEVICE_OUT_LINE) {
                 snd_device = SND_DEVICE_OUT_LINE;
         }  else {
-#ifdef RECORD_PLAY_CONCURRENCY
             if (use_voip_out_devices)
                 snd_device = SND_DEVICE_OUT_VOIP_HEADPHONES;
             else
-#endif
                 snd_device = SND_DEVICE_OUT_HEADPHONES;
         }
     } else if (devices & AUDIO_DEVICE_OUT_LINE) {
         snd_device = SND_DEVICE_OUT_LINE;
     } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
-#ifdef RECORD_PLAY_CONCURRENCY
         if (use_voip_out_devices) {
             snd_device = SND_DEVICE_OUT_VOIP_SPEAKER;
         } else
-#endif
         {
             if (adev->speaker_lr_swap)
                 snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
@@ -4354,11 +4337,9 @@
     } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
         snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
     } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
-#ifdef RECORD_PLAY_CONCURRENCY
         if (use_voip_out_devices)
             snd_device = SND_DEVICE_OUT_VOIP_HANDSET;
         else
-#endif
             snd_device = SND_DEVICE_OUT_HANDSET;
     } else if (devices & AUDIO_DEVICE_OUT_PROXY) {
         channel_count = audio_extn_get_afe_proxy_channel_count();
@@ -5310,7 +5291,6 @@
         }
     }
 
-#ifdef RECORD_PLAY_CONCURRENCY
     err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC, value, sizeof(value));
     if (err >= 0) {
         if (!strncmp("true", value, sizeof("true"))) {
@@ -5321,7 +5301,6 @@
             my_data->rec_play_conc_set = false;
         }
     }
-#endif
 
    err = str_parms_get_str(parms, PLATFORM_MAX_MIC_COUNT,
                             value, sizeof(value));
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 7b1f386..b676766 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2427,6 +2427,14 @@
     list_init(&operator_info_list);
     list_init(&app_type_entry_list);
 
+    if(audio_extn_is_concurrent_capture_enabled())
+        AUDIO_DEVICE_IN_ALL_CODEC_BACKEND = (AUDIO_DEVICE_IN_BUILTIN_MIC | \
+            AUDIO_DEVICE_IN_BACK_MIC | AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN;
+    else
+        AUDIO_DEVICE_IN_ALL_CODEC_BACKEND = (AUDIO_DEVICE_IN_BUILTIN_MIC | \
+            AUDIO_DEVICE_IN_BACK_MIC | AUDIO_DEVICE_IN_WIRED_HEADSET | \
+            AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN;
+
     adev->snd_card = audio_extn_utils_open_snd_mixer(&adev->mixer);
     if (adev->snd_card < 0) {
         ALOGE("%s: Unable to find correct sound card", __func__);
@@ -2998,12 +3006,12 @@
             strdup("SLIM_6_RX SampleRate");
         //TODO: enable CONCURRENT_CAPTURE_ENABLED flag only if separate backend is defined
         //for headset-mic. This is to capture separate data from headset-mic and handset-mic.
-#ifdef CONCURRENT_CAPTURE_ENABLED
-        my_data->current_backend_cfg[HEADSET_TX_BACKEND].bitwidth_mixer_ctl =
-            strdup("SLIM_1_TX Format");
-        my_data->current_backend_cfg[HEADSET_TX_BACKEND].samplerate_mixer_ctl =
-            strdup("SLIM_1_TX SampleRate");
-#endif
+        if(audio_extn_is_concurrent_capture_enabled())
+            my_data->current_backend_cfg[HEADSET_TX_BACKEND].bitwidth_mixer_ctl =
+                                                            strdup("SLIM_1_TX Format");
+        else
+            my_data->current_backend_cfg[HEADSET_TX_BACKEND].samplerate_mixer_ctl =
+                                                            strdup("SLIM_1_TX SampleRate");
     }
 
     my_data->current_backend_cfg[USB_AUDIO_TX_BACKEND].bitwidth_mixer_ctl =
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 1642eb4..f8698e9 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -67,15 +67,8 @@
  * All these devices are handled by the internal HW codec. We can
  * enable any one of these devices at any time
  */
-#ifdef CONCURRENT_CAPTURE_ENABLED
-#define AUDIO_DEVICE_IN_ALL_CODEC_BACKEND \
-    (AUDIO_DEVICE_IN_BUILTIN_MIC | AUDIO_DEVICE_IN_BACK_MIC | \
-     AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN
-#else
-#define AUDIO_DEVICE_IN_ALL_CODEC_BACKEND \
-    (AUDIO_DEVICE_IN_BUILTIN_MIC | AUDIO_DEVICE_IN_BACK_MIC | \
-     AUDIO_DEVICE_IN_WIRED_HEADSET | AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN
-#endif
+int AUDIO_DEVICE_IN_ALL_CODEC_BACKEND;
+
 /* Sound devices specific to the platform
  * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
  * devices to enable corresponding mixer paths
diff --git a/hal/voice.c b/hal/voice.c
index 26116c6..6d515e4 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -509,7 +509,7 @@
     adev->voice.mic_mute = state;
 
     if (audio_extn_hfp_is_active(adev)) {
-        err = hfp_set_mic_mute(adev, state);
+        err = audio_extn_hfp_set_mic_mute2(adev, state);
     } else if (adev->mode == AUDIO_MODE_IN_CALL) {
        /* Use device mute if incall music delivery usecase is in progress */
         if (adev->voice.use_device_mute)
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index aaed913..1f45a64 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -87,6 +87,7 @@
 static bool voice_extn_compress_voip_enabled = false;
 static bool voice_extn_dynamic_ecns_feature_enabled = false;
 static int voice_extn_is_running_vendor_enhanced_fwk = 1;
+static bool voice_extn_incall_music_enabled = false;
 
 int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active);
 
@@ -398,6 +399,15 @@
                             is_feature_enabled? "ENABLED": " NOT ENABLED");
 }
 
+// START: INCALL_MUSIC ===================================================================
+void incall_music_feature_init(bool is_feature_enabled)
+{
+   voice_extn_incall_music_enabled = is_feature_enabled;
+    ALOGD("%s: ---- Feature INCALL_MUSIC is %s----", __func__,
+                                is_feature_enabled? "ENABLED": "NOT ENABLED");
+}
+// END: INCALL_MUSIC ===================================================================
+
 bool voice_extn_is_dynamic_ecns_enabled()
 {
     return voice_extn_dynamic_ecns_feature_enabled;
@@ -416,6 +426,9 @@
             case DYNAMIC_ECNS:
                 dynamic_ecns_feature_init(enable);
                 break;
+            case INCALL_MUSIC:
+                incall_music_feature_init(enable);
+                break;
             default:
                 break;
         }
@@ -680,21 +693,23 @@
     
 }
 
-#ifdef INCALL_MUSIC_ENABLED
+
 int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                   struct stream_out *out)
 {
-    out->usecase = USECASE_INCALL_MUSIC_UPLINK;
-    out->config = pcm_config_incall_music;
-    //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
-    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
-    out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
-    out->config.rate = out->sample_rate;
+    if(voice_extn_incall_music_enabled) {
+        out->usecase = USECASE_INCALL_MUSIC_UPLINK;
+        out->config = pcm_config_incall_music;
+        //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
+        out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
+        out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+        out->config.rate = out->sample_rate;
 
-    ALOGV("%s: mode=%d, usecase id=%d", __func__, adev->mode, out->usecase);
+        ALOGV("%s: mode=%d, usecase id=%d", __func__, adev->mode, out->usecase);
+    }
     return 0;
 }
-#endif
+
 
 int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
                                              struct str_parms *parms) 
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index d45114b..7a3b8cd 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -41,17 +41,6 @@
 void voice_extn_out_get_parameters(struct stream_out *out,
                                    struct str_parms *query,
                                    struct str_parms *reply);
-#ifdef INCALL_MUSIC_ENABLED
-int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
-                                                  struct stream_out *out);
-#else
-static int __unused voice_extn_check_and_set_incall_music_usecase(
-                                          struct audio_device *adev __unused,
-                                          struct stream_out *out __unused)
-{
-    return -ENOSYS;
-}
-#endif
 
 int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                   struct stream_out *out);