sdm: Reduce scope of lock in deinit

HWEventsInterface::Destroy tries to shutdown the event thread,
but it is not able to do so while holding the recursive mutex,
since there is a race where the idle power collapse event is also
received at the same time, which tries to acquire the recursive
mutex.

Fixes test Hwc2Test.SET_VSYNC_ENABLED*
Change-Id: I5dfe75b25606c19156ee12073dacda43541dd9cf
CRs-Fixed: 2028722
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 93970a4..503f71e 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -121,17 +121,18 @@
 }
 
 DisplayError DisplayBase::Deinit() {
-  lock_guard<recursive_mutex> obj(recursive_mutex_);
+  {  // Scope for lock
+    lock_guard<recursive_mutex> obj(recursive_mutex_);
+    color_modes_.clear();
+    color_mode_map_.clear();
 
-  color_modes_.clear();
-  color_mode_map_.clear();
+    if (color_mgr_) {
+      delete color_mgr_;
+      color_mgr_ = NULL;
+    }
 
-  if (color_mgr_) {
-    delete color_mgr_;
-    color_mgr_ = NULL;
+    comp_manager_->UnregisterDisplay(display_comp_ctx_);
   }
-
-  comp_manager_->UnregisterDisplay(display_comp_ctx_);
   HWEventsInterface::Destroy(hw_events_intf_);
   HWInterface::Destroy(hw_intf_);