Merge "config: activate AUDIO_USE_STUB_HAL for audiolite"
diff --git a/configs/bengal/bengal.mk b/configs/bengal/bengal.mk
index e3bc4e4..c46d9eb 100644
--- a/configs/bengal/bengal.mk
+++ b/configs/bengal/bengal.mk
@@ -15,16 +15,92 @@
 USE_CUSTOM_AUDIO_POLICY := 1
 AUDIO_FEATURE_QSSI_COMPLIANCE := true
 AUDIO_FEATURE_ENABLED_COMPRESS_CAPTURE := false
-AUDIO_FEATURE_ENABLED_COMPRESS_INPUT := true
-AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE := true
 AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := false
 AUDIO_FEATURE_ENABLED_DYNAMIC_ECNS := true
 AUDIO_FEATURE_ENABLED_EXTN_FORMATS := true
+AUDIO_FEATURE_ENABLED_PCM_OFFLOAD := true
+AUDIO_FEATURE_ENABLED_DTS_EAGLE := false
+BOARD_USES_SRS_TRUEMEDIA := false
+DTS_CODEC_M_ := false
+AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS := false
+AUDIO_FEATURE_ENABLED_A2DP_OFFLOAD := true
+AUDIO_FEATURE_ENABLED_AHAL_EXT := false
+DOLBY_ENABLE := false
+endif
+
+AUDIO_FEATURE_ENABLED_DLKM := true
+BOARD_SUPPORTS_GCS := false
+AUDIO_FEATURE_ENABLED_INSTANCE_ID := true
+AUDIO_USE_DEEP_AS_PRIMARY_OUTPUT := false
+AUDIO_FEATURE_ENABLED_VBAT_MONITOR := true
+AUDIO_FEATURE_ENABLED_NT_PAUSE_TIMEOUT := true
+AUDIO_FEATURE_ENABLED_CUSTOMSTEREO := true
+AUDIO_FEATURE_ENABLED_FLUENCE := true
+#AUDIO_FEATURE_ENABLED_KEEP_ALIVE := true
+AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP := false
+AUDIO_FEATURE_ENABLED_INCALL_MUSIC := true
+AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true
+AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE := true
+AUDIO_FEATURE_ENABLED_SPKR_PROTECTION := true
+AUDIO_FEATURE_ENABLED_ACDB_LICENSE := false
+AUDIO_FEATURE_ENABLED_DEV_ARBI := false
+MM_AUDIO_ENABLED_FTM := true
+TARGET_USES_QCOM_MM_AUDIO := true
+BOARD_SUPPORTS_QAHW := false
+AUDIO_FEATURE_ENABLED_RAS := true
+AUDIO_FEATURE_ENABLED_SND_MONITOR := true
+AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := true
+##AUDIO_FEATURE_FLAGS
+
+ifeq ($(TARGET_1G_DDR_RAM), true)
+AUDIO_FEATURE_ENABLED_AUDIOSPHERE := false
+AUDIO_FEATURE_ENABLED_3D_AUDIO := false
+BOARD_SUPPORTS_SOUND_TRIGGER := false
+AUDIO_FEATURE_ENABLED_HFP := false
+AUDIO_FEATURE_ENABLED_SVA_MULTI_STAGE := false
+BOARD_SUPPORTS_OPENSOURCE_STHAL := false
+AUDIO_DO_NOT_USE_OMX_CODEC := true
+AUDIO_FEATURE_ENABLED_COMPRESS_INPUT := false
+AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE := false
+AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER := false
+AUDIO_FEATURE_ENABLED_EXTN_RESAMPLER := false
+AUDIO_FEATURE_ENABLED_FM_POWER_OPT := false
+AUDIO_FEATURE_ENABLED_HDMI_SPK := false
+AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24 := false
+AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_VORBIS_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_WMA_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_APE_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_AAC_ADTS_OFFLOAD := false
+AUDIO_FEATURE_ENABLED_MPEGH_SW_DECODER := false
+AUDIO_FEATURE_ENABLED_PROXY_DEVICE := false
+AUDIO_FEATURE_ENABLED_SSR := false
+MM_AUDIO_ENABLED_SAFX := false
+AUDIO_FEATURE_ENABLED_USB_TUNNEL := false
+AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT := false
+AUDIO_FEATURE_ENABLED_ANC_HEADSET := false
+AUDIO_FEATURE_ENABLED_HDMI_EDID := false
+AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH := false
+AUDIO_FEATURE_ENABLED_DISPLAY_PORT := false
+AUDIO_FEATURE_ENABLED_DYNAMIC_LOG := false
+AUDIO_FEATURE_ENABLED_SOURCE_TRACKING := false
+AUDIO_FEATURE_ENABLED_GEF_SUPPORT := false
+AUDIO_FEATURE_ENABLED_USB_BURST_MODE := false
+PURGE_UNUSED_MEMORY := true
+else
+AUDIO_FEATURE_ENABLED_AUDIOSPHERE := true
+AUDIO_FEATURE_ENABLED_3D_AUDIO := true
+BOARD_SUPPORTS_SOUND_TRIGGER := true
+AUDIO_FEATURE_ENABLED_HFP := true
+AUDIO_FEATURE_ENABLED_SVA_MULTI_STAGE := true
+BOARD_SUPPORTS_OPENSOURCE_STHAL := true
+AUDIO_FEATURE_ENABLED_COMPRESS_INPUT := true
+AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE := true
 AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER := true
 AUDIO_FEATURE_ENABLED_EXTN_RESAMPLER := true
 AUDIO_FEATURE_ENABLED_FM_POWER_OPT := true
 AUDIO_FEATURE_ENABLED_HDMI_SPK := true
-AUDIO_FEATURE_ENABLED_PCM_OFFLOAD := true
 AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24 := true
 AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD := true
 AUDIO_FEATURE_ENABLED_VORBIS_OFFLOAD := true
@@ -35,56 +111,18 @@
 AUDIO_FEATURE_ENABLED_MPEGH_SW_DECODER := true
 AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true
 AUDIO_FEATURE_ENABLED_SSR := true
-AUDIO_FEATURE_ENABLED_DTS_EAGLE := false
-BOARD_USES_SRS_TRUEMEDIA := false
-DTS_CODEC_M_ := false
 MM_AUDIO_ENABLED_SAFX := true
-AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS := false
-AUDIO_FEATURE_ENABLED_AUDIOSPHERE := true
 AUDIO_FEATURE_ENABLED_USB_TUNNEL := true
-AUDIO_FEATURE_ENABLED_A2DP_OFFLOAD := true
-AUDIO_FEATURE_ENABLED_3D_AUDIO := true
-AUDIO_FEATURE_ENABLED_AHAL_EXT := false
 AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT := true
-DOLBY_ENABLE := false
-endif
-
-AUDIO_FEATURE_ENABLED_DLKM := true
-BOARD_SUPPORTS_SOUND_TRIGGER := true
-BOARD_SUPPORTS_GCS := false
-AUDIO_FEATURE_ENABLED_INSTANCE_ID := true
-AUDIO_USE_DEEP_AS_PRIMARY_OUTPUT := false
-AUDIO_FEATURE_ENABLED_VBAT_MONITOR := true
-AUDIO_FEATURE_ENABLED_NT_PAUSE_TIMEOUT := true
 AUDIO_FEATURE_ENABLED_ANC_HEADSET := true
-AUDIO_FEATURE_ENABLED_CUSTOMSTEREO := true
-AUDIO_FEATURE_ENABLED_FLUENCE := true
 AUDIO_FEATURE_ENABLED_HDMI_EDID := true
 AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH := true
-#AUDIO_FEATURE_ENABLED_KEEP_ALIVE := true
 AUDIO_FEATURE_ENABLED_DISPLAY_PORT := true
-AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP := false
-AUDIO_FEATURE_ENABLED_HFP := true
-AUDIO_FEATURE_ENABLED_INCALL_MUSIC := true
-AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true
-AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE := true
-AUDIO_FEATURE_ENABLED_SPKR_PROTECTION := true
-AUDIO_FEATURE_ENABLED_ACDB_LICENSE := false
-AUDIO_FEATURE_ENABLED_DEV_ARBI := false
 AUDIO_FEATURE_ENABLED_DYNAMIC_LOG := true
-MM_AUDIO_ENABLED_FTM := true
-TARGET_USES_QCOM_MM_AUDIO := true
 AUDIO_FEATURE_ENABLED_SOURCE_TRACKING := true
 AUDIO_FEATURE_ENABLED_GEF_SUPPORT := true
-BOARD_SUPPORTS_QAHW := false
-AUDIO_FEATURE_ENABLED_RAS := true
-AUDIO_FEATURE_ENABLED_SND_MONITOR := true
 AUDIO_FEATURE_ENABLED_USB_BURST_MODE := true
-AUDIO_FEATURE_ENABLED_SVA_MULTI_STAGE := true
-AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := true
-##AUDIO_FEATURE_FLAGS
-
-BOARD_SUPPORTS_OPENSOURCE_STHAL := true
+endif
 
 AUDIO_HARDWARE := audio.a2dp.default
 AUDIO_HARDWARE += audio.usb.default
diff --git a/configs/lahaina/audio_platform_info_yupikidprb3.xml b/configs/lahaina/audio_platform_info_yupikidprb3.xml
index 1d928b2..fa01a79 100644
--- a/configs/lahaina/audio_platform_info_yupikidprb3.xml
+++ b/configs/lahaina/audio_platform_info_yupikidprb3.xml
@@ -179,6 +179,7 @@
         <device name="SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET" backend="headset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_HANDSET" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_HDMI" interface="SEC_MI2S_RX"/>
         <device name="SND_DEVICE_OUT_SPEAKER_EXTERNAL_1" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER_EXTERNAL_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER_REVERSE" interface="WSA_CDC_DMA_RX_0"/>
@@ -269,7 +270,7 @@
         <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC_SB" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HDMI_MIC" interface="HDMI"/>
+        <device name="SND_DEVICE_IN_HDMI_MIC" interface="PRI_MI2S_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC" interface="SLIMBUS_7_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC_NREC" interface="SLIMBUS_7_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC_WB" interface="SLIMBUS_7_TX"/>
diff --git a/configs/lahaina/yupik_overlay/mixer_paths_yupikidprb3_overlay.xml b/configs/lahaina/yupik_overlay/mixer_paths_yupikidprb3_overlay.xml
index c29ee25..b63409d 100644
--- a/configs/lahaina/yupik_overlay/mixer_paths_yupikidprb3_overlay.xml
+++ b/configs/lahaina/yupik_overlay/mixer_paths_yupikidprb3_overlay.xml
@@ -62,7 +62,7 @@
     <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia16" value="0" />
 
     <path name="hdmi">
-	<ctl name="SEC_MI2S_RX Format" value="S32_LE" />
+        <ctl name="SEC_MI2S_RX Format" value="S32_LE" />
     </path>
     <path name="low-latency-playback hdmi">
         <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia5" value="1" />
@@ -74,54 +74,54 @@
         <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia7" value="1" />
     </path>
     <path name="compress-offload-playback3 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia10" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia10" value="1" />
     </path>
     <path name="compress-offload-playback4 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia11" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia11" value="1" />
     </path>
     <path name="compress-offload-playback5 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia12" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia12" value="1" />
     </path>
     <path name="compress-offload-playback6 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia13" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia13" value="1" />
     </path>
     <path name="compress-offload-playback7 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia14" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia14" value="1" />
     </path>
     <path name="compress-offload-playback8 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia15" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia15" value="1" />
     </path>
     <path name="compress-offload-playback9 hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia16" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia16" value="1" />
     </path>
     <path name="mmap-playback hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia16" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia16" value="1" />
     </path>
     <path name="audio-playback-voip hdmi">
         <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia10" value="1" />
     </path>
     <path name="audio-ull-playback hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia8" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia8" value="1" />
     </path>
     <path name="deep-buffer-playback hdmi">
         <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia1" value="1" />
     </path>
     <path name="silence-playback hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia9" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia9" value="1" />
     </path>
     <path name="hifi-playback hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia2" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia2" value="1" />
     </path>
     <path name="multi-channel-playback hdmi">
-	<ctl name="SEC_MI2S_RX Audio Mixer MultiMedia2" value="1" />
+        <ctl name="SEC_MI2S_RX Audio Mixer MultiMedia2" value="1" />
     </path>
     <path name="audio-record hdmi-in">
-	<ctl name="MultiMedia1 Mixer PRI_MI2S_TX" value="1" />
+        <ctl name="MultiMedia1 Mixer PRI_MI2S_TX" value="1" />
     </path>
     <path name="hdmi-in">
     </path>
     <path name="audio-record-compress2 hdmi-in">
-	<ctl name="MultiMedia17 Mixer PRI_MI2S_TX" value="1" />
+        <ctl name="MultiMedia17 Mixer PRI_MI2S_TX" value="1" />
     </path>
     <path name="speaker-mic">
         <path name="dmic4"/>
diff --git a/hal/Android.mk b/hal/Android.mk
index ba6c536..820749b 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -417,6 +417,11 @@
     LOCAL_SHARED_LIBRARIES += vendor.qti.hardware.audiohalext@1.0
 endif
 
+# Memory optimization specific feature
+ifeq ($(strip $(TARGET_1G_DDR_RAM)), true)
+    LOCAL_CFLAGS += -DPURGE_UNUSED_MEM
+endif
+
 LOCAL_CFLAGS += -D_GNU_SOURCE
 LOCAL_CFLAGS += -Wall -Werror
 
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 61ccfcb..2c677d6 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -92,6 +92,7 @@
 #include "platform_api.h"
 #include "edid.h"
 #include "sound/compress_params.h"
+#include <pthread.h>
 
 #ifdef AUDIO_GKI_ENABLED
 #include "sound/audio_compressed_formats.h"
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index be20e12..55006d2 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -3315,7 +3315,7 @@
     return -EINVAL;
 }
 
-void audio_extn_utils_release_snd_device(snd_device_t snd_device)
+void audio_extn_utils_release_snd_device(snd_device_t snd_device __unused)
 {
     audio_extn_dev_arbi_release(snd_device);
     audio_extn_sound_trigger_update_device_status(snd_device,
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8442a6b..94c75a8 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3566,6 +3566,9 @@
     }
 
     enable_gcov();
+#ifdef PURGE_UNUSED_MEM
+    mallopt(M_PURGE, 0);
+#endif
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
 }
@@ -4205,6 +4208,9 @@
 
     clear_devices(&uc_info->device_list);
     free(uc_info);
+#ifdef PURGE_UNUSED_MEM
+    mallopt(M_PURGE, 0);
+#endif
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
 }
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index d71ad0f..9ff9533 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -17,7 +17,7 @@
  * limitations under the License.
  *
  * Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
  */
 
@@ -7043,6 +7043,9 @@
                     snd_device = SND_DEVICE_OUT_DISPLAY_PORT +
                         ((controller * MAX_STREAMS_PER_CONTROLLER) + stream);
                     break;
+                case EXT_DISPLAY_TYPE_HDMI:
+                    snd_device = SND_DEVICE_OUT_HDMI;
+                    break;
                 default:
                     ALOGE("%s: Invalid disp_type %d", __func__,
                            my_data->ext_disp[controller][stream].type);
@@ -9251,7 +9254,8 @@
         if (adev->dp_allowed_for_voice) {
             for (i = 0; i < MAX_CONTROLLERS; ++i) {
                 for (j = 0; j < MAX_STREAMS_PER_CONTROLLER; ++j) {
-                    if (my_data->ext_disp[i][j].type == EXT_DISPLAY_TYPE_DP) {
+                    if (my_data->ext_disp[i][j].type == EXT_DISPLAY_TYPE_DP
+                         ||  my_data->ext_disp[i][j].type == EXT_DISPLAY_TYPE_HDMI) {
                         enabled = true;
                         break;
                     }