Merge "PAL: Add support to vote NLPI for SVA GMM"
diff --git a/configs/crow/resourcemanager_crow_idp.xml b/configs/crow/resourcemanager_crow_idp.xml
index 87c99db..23c336b 100644
--- a/configs/crow/resourcemanager_crow_idp.xml
+++ b/configs/crow/resourcemanager_crow_idp.xml
@@ -1474,6 +1474,7 @@
                 <sound_model_info>
                     <first_stage_module_params>
                         <param module_type="GMM" />
+                        <param lpi_supported="false"/>
                         <param load_sound_model_ids="0xC0000008, 0x0800104C" />
                         <param wakeup_config_ids="0xC0000008, 0x08001049" />
                         <param buffering_config_ids="0xC0000008, 0x08001044" />
diff --git a/configs/crow/resourcemanager_crow_idp_wcd9395_aatc.xml b/configs/crow/resourcemanager_crow_idp_wcd9395_aatc.xml
index 524cc3f..459d534 100644
--- a/configs/crow/resourcemanager_crow_idp_wcd9395_aatc.xml
+++ b/configs/crow/resourcemanager_crow_idp_wcd9395_aatc.xml
@@ -1474,6 +1474,7 @@
                 <sound_model_info>
                     <first_stage_module_params>
                         <param module_type="GMM" />
+                        <param lpi_supported="false"/>
                         <param load_sound_model_ids="0xC0000008, 0x0800104C" />
                         <param wakeup_config_ids="0xC0000008, 0x08001049" />
                         <param buffering_config_ids="0xC0000008, 0x08001044" />
diff --git a/configs/crow/resourcemanager_crow_idp_wcd9395_dmic.xml b/configs/crow/resourcemanager_crow_idp_wcd9395_dmic.xml
index 8c548df..3b033d2 100644
--- a/configs/crow/resourcemanager_crow_idp_wcd9395_dmic.xml
+++ b/configs/crow/resourcemanager_crow_idp_wcd9395_dmic.xml
@@ -1474,6 +1474,7 @@
                 <sound_model_info>
                     <first_stage_module_params>
                         <param module_type="GMM" />
+                        <param lpi_supported="false"/>
                         <param load_sound_model_ids="0xC0000008, 0x0800104C" />
                         <param wakeup_config_ids="0xC0000008, 0x08001049" />
                         <param buffering_config_ids="0xC0000008, 0x08001044" />
diff --git a/configs/crow/resourcemanager_crow_idp_wcd9395_wcd_dmic.xml b/configs/crow/resourcemanager_crow_idp_wcd9395_wcd_dmic.xml
index 8c548df..3b033d2 100644
--- a/configs/crow/resourcemanager_crow_idp_wcd9395_wcd_dmic.xml
+++ b/configs/crow/resourcemanager_crow_idp_wcd9395_wcd_dmic.xml
@@ -1474,6 +1474,7 @@
                 <sound_model_info>
                     <first_stage_module_params>
                         <param module_type="GMM" />
+                        <param lpi_supported="false"/>
                         <param load_sound_model_ids="0xC0000008, 0x0800104C" />
                         <param wakeup_config_ids="0xC0000008, 0x08001049" />
                         <param buffering_config_ids="0xC0000008, 0x08001044" />
diff --git a/configs/crow/resourcemanager_crow_qrd.xml b/configs/crow/resourcemanager_crow_qrd.xml
index 1fe922e..03cda18 100644
--- a/configs/crow/resourcemanager_crow_qrd.xml
+++ b/configs/crow/resourcemanager_crow_qrd.xml
@@ -1475,6 +1475,7 @@
                 <sound_model_info>
                     <first_stage_module_params>
                         <param module_type="GMM" />
+                        <param lpi_supported="false"/>
                         <param load_sound_model_ids="0xC0000008, 0x0800104C" />
                         <param wakeup_config_ids="0xC0000008, 0x08001049" />
                         <param buffering_config_ids="0xC0000008, 0x08001044" />
diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index 9347a33..d037720 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -1762,8 +1762,10 @@
         return ret;
     }
 
-    lpi_stream = (sleep_monitor_vote_type_[type] == LPI_VOTE &&
-                 !IsTransitToNonLPIOnChargingSupported() && (!force_nlpi_vote));
+    if (sleep_monitor_vote_type_[type] == LPI_VOTE) {
+        lpi_stream = (!force_nlpi_vote && str->ConfigSupportLPI() &&
+                      !IsTransitToNonLPIOnChargingSupported());
+    }
 
     mSleepMonitorMutex.lock();
     if (vote) {
diff --git a/stream/inc/Stream.h b/stream/inc/Stream.h
index 6385a0e..e7f1b81 100644
--- a/stream/inc/Stream.h
+++ b/stream/inc/Stream.h
@@ -248,6 +248,7 @@
                                    struct pal_mmap_buffer *info __unused) {return -EINVAL;}
     virtual int32_t GetMmapPosition(struct pal_mmap_position *position __unused) {return -EINVAL;}
     virtual int32_t getTagsWithModuleInfo(size_t *size __unused, uint8_t *payload __unused) {return -EINVAL;};
+    virtual bool ConfigSupportLPI() {return true;}; //Only LPI streams can update their vote to NLPI
     int32_t getStreamAttributes(struct pal_stream_attributes *sattr);
     int32_t getModifiers(struct modifier_kv *modifiers,uint32_t *noOfModifiers);
     const std::string& getStreamSelector() const;
diff --git a/stream/inc/StreamSoundTrigger.h b/stream/inc/StreamSoundTrigger.h
index c8cef55..9da6d26 100644
--- a/stream/inc/StreamSoundTrigger.h
+++ b/stream/inc/StreamSoundTrigger.h
@@ -165,6 +165,7 @@
     int32_t EnableLPI(bool is_enable);
     int32_t setECRef(std::shared_ptr<Device> dev, bool is_enable) override;
     int32_t setECRef_l(std::shared_ptr<Device> dev, bool is_enable) override;
+    bool ConfigSupportLPI() override;
     void TransitTo(int32_t state_id);
 
     friend class PalRingBufferReader;
diff --git a/stream/src/StreamSoundTrigger.cpp b/stream/src/StreamSoundTrigger.cpp
index 8ae6c4a..2014c1d 100644
--- a/stream/src/StreamSoundTrigger.cpp
+++ b/stream/src/StreamSoundTrigger.cpp
@@ -3489,6 +3489,20 @@
 
     return status;
 }
+bool StreamSoundTrigger::ConfigSupportLPI() {
+
+    bool lpi = true;
+    bool config_support_lpi = true;
+
+    if (sm_cfg_ && sm_cfg_->GetVUIFirstStageConfig(model_type_))
+        config_support_lpi =
+               sm_cfg_->GetVUIFirstStageConfig(model_type_)->IsLpiSupported();
+
+    if (!config_support_lpi || !vui_ptfm_info_->GetLpiEnable())
+        lpi = false;
+
+    return lpi;
+}
 
 int32_t StreamSoundTrigger::ssrDownHandler() {
     int32_t status = 0;
diff --git a/utils/inc/VoiceUIPlatformInfo.h b/utils/inc/VoiceUIPlatformInfo.h
index a035ed2..dc68035 100644
--- a/utils/inc/VoiceUIPlatformInfo.h
+++ b/utils/inc/VoiceUIPlatformInfo.h
@@ -100,6 +100,7 @@
 
     st_module_type_t GetModuleType() const { return module_type_; }
     std::string GetModuleName() const { return module_name_; }
+    bool IsLpiSupported() const { return lpi_supported_; }
     uint32_t GetModuleTagId(st_param_id_type_t param_id) const {
         return module_tag_ids_[param_id];
     }
@@ -108,6 +109,7 @@
     }
 
 private:
+    bool lpi_supported_;
     st_module_type_t module_type_;
     std::string module_name_;
     uint32_t module_tag_ids_[MAX_PARAM_IDS];
diff --git a/utils/src/VoiceUIPlatformInfo.cpp b/utils/src/VoiceUIPlatformInfo.cpp
index 7fac943..6c70312 100644
--- a/utils/src/VoiceUIPlatformInfo.cpp
+++ b/utils/src/VoiceUIPlatformInfo.cpp
@@ -113,7 +113,8 @@
 
 VUIFirstStageConfig::VUIFirstStageConfig() :
     module_type_(ST_MODULE_TYPE_GMM),
-    module_name_("GMM")
+    module_name_("GMM"),
+    lpi_supported_(true)
 {
     for (int i = 0; i < MAX_PARAM_IDS; i++) {
         module_tag_ids_[i] = 0;
@@ -145,6 +146,8 @@
                 }
                 PAL_DBG(LOG_TAG, "Module name:%s, type:%d",
                         module_name_.c_str(), module_type_);
+            } else if (!strcmp(attribs[i], "lpi_supported")) {
+                lpi_supported_ = !strcmp(attribs[++i], "true");
             } else {
                 uint32_t index = 0;