Merge "wlan: Add wake lock for find AP indication" into wlan-driver.lnx.1.0-dev.1.0
diff --git a/CORE/VOSS/inc/vos_diag_core_event.h b/CORE/VOSS/inc/vos_diag_core_event.h
index 6fdb45c..ac7b39b 100644
--- a/CORE/VOSS/inc/vos_diag_core_event.h
+++ b/CORE/VOSS/inc/vos_diag_core_event.h
@@ -454,6 +454,7 @@
        WIFI_POWER_EVENT_WAKELOCK_ROC,
        WIFI_POWER_EVENT_WAKELOCK_HOLD_RX,
        WIFI_POWER_EVENT_WAKELOCK_SAP,
+       WIFI_POWER_EVENT_WAKELOCK_FIND_AP_INDICATION,
 };
 
 #ifdef __cplusplus
diff --git a/CORE/WDI/CP/inc/wlan_qct_wdi_i.h b/CORE/WDI/CP/inc/wlan_qct_wdi_i.h
index a551b7d..59d0884 100644
--- a/CORE/WDI/CP/inc/wlan_qct_wdi_i.h
+++ b/CORE/WDI/CP/inc/wlan_qct_wdi_i.h
@@ -1356,6 +1356,8 @@
    wpt_uint8                  roamDelayStatsEnabled;
    /* enable/disable sendMgmtPktViaWQ5 params in ini */
    wpt_boolean                 sendMgmtPktViaWQ5;
+   /* Wake lock for keep device in awake once host gets a find AP indication */
+   vos_wake_lock_t             find_ap_lock;
 
 }WDI_ControlBlockType; 
 
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index a153bb9..d8c2dd4 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -90,6 +90,7 @@
 
 #include "pttMsgApi.h"
 #include "vos_trace.h"
+#include "vos_diag_core_event.h"
 
 #include "vos_api.h"
 
@@ -2339,7 +2340,6 @@
       goto fail_wdts_open;
     }
   }
-
   /*The WDI is initialized - set state to init */
   gWDICb.uGlobalState = WDI_INIT_ST;
   gWDICb.roamDelayStatsEnabled = vos_get_roam_delay_stats_enabled();
@@ -2353,6 +2353,8 @@
 
   wdi_register_debug_callback();
 
+  vos_wake_lock_init(&gWDICb.find_ap_lock, "find_ap_lock");
+
   return WDI_STATUS_SUCCESS;
 
   /* ERROR handlers
@@ -2700,7 +2702,7 @@
                 "Failed to delete mutex %d", wptStatus);
      WDI_ASSERT(0);
   }
-
+  vos_wake_lock_destroy(&gWDICb.find_ap_lock);
   /*Clear control block.  note that this will clear the "magic"
     which will inhibit all asynchronous callbacks*/
   WDI_CleanCB(&gWDICb);
@@ -27843,6 +27845,7 @@
 #endif
 
 #ifdef WLAN_FEATURE_APFIND
+#define FIND_AP_WAKELOCK_TIMEOUT 1000
 /**
  @brief Process QRF Preferred Network Found Indication function
 
@@ -27874,7 +27877,9 @@
      WDI_ASSERT( 0 );
      return WDI_STATUS_E_FAILURE;
   }
-
+  vos_wake_lock_timeout_release(&pWDICtx->find_ap_lock,
+                                FIND_AP_WAKELOCK_TIMEOUT,
+                                WIFI_POWER_EVENT_WAKELOCK_FIND_AP_INDICATION);
   /*Fill in the indication parameters*/
   wdiInd.wdiIndicationType = WDI_AP_FOUND_IND;
   if ( pWDICtx->wdiLowLevelIndCB )