Merge commit '1cd77e0b1679101cef3b83857eea5c292c494a80' into display.lnx.9.0.r1-rel

Change-Id: I309507427c04eb43eeb9747d333094d464ae8533
diff --git a/composer/QtiComposerClient.cpp b/composer/QtiComposerClient.cpp
index 2fb19e6..a8e4a9c 100644
--- a/composer/QtiComposerClient.cpp
+++ b/composer/QtiComposerClient.cpp
@@ -1376,7 +1376,7 @@
 
 bool QtiComposerClient::CommandReader::parseSetClientTarget(uint16_t length) {
   // 4 parameters followed by N rectangles
-  if ((length - 4) % 4 != 0) {
+  if (length < 4 || ((length - 4) % 4 != 0)) {
     return false;
   }
 
@@ -1957,7 +1957,7 @@
 bool QtiComposerClient::CommandReader::parseSetLayerPerFrameMetadataBlobs(uint16_t length) {
   // must have at least one metadata blob
   // of at least size 1 in queue (i.e {/*numBlobs=*/1, key, size, blob})
-  if (length < 4) {
+  if (length <= 4) {
     return false;
   }
 
@@ -1971,7 +1971,7 @@
     uint32_t blobSize = read();
     length -= 2;
 
-    if (length * sizeof(uint32_t) < blobSize) {
+    if (length * sizeof(uint32_t) < blobSize && (length % 2 != 0)) {
       return false;
     }
 
diff --git a/composer/hwc_display.cpp b/composer/hwc_display.cpp
old mode 100644
new mode 100755
index e167768..b992a04
--- a/composer/hwc_display.cpp
+++ b/composer/hwc_display.cpp
@@ -914,7 +914,8 @@
 HWC2::Error HWCDisplay::SetLayerType(hwc2_layer_t layer_id, IQtiComposerClient::LayerType type) {
   const auto map_layer = layer_map_.find(layer_id);
   if (map_layer == layer_map_.end()) {
-    DLOGE("[%" PRIu64 "] SetLayerType failed to find layer", id_);
+    DLOGW("display [%" PRIu64"]-[%" PRIu64 "] SetLayerType (%" PRIu64 ") failed to find layer",
+        id_, type_, layer_id);
     return HWC2::Error::BadLayer;
   }
 
@@ -2020,13 +2021,16 @@
         reinterpret_cast<const native_handle_t *>(layer->input_buffer.buffer_id);
     Fence::Wait(layer->input_buffer.acquire_fence);
 
-    DLOGI("Dump layer[%d] of %lu handle %p", i, layer_stack_.layers.size(), handle);
 
     if (!handle) {
-      DLOGE("Buffer handle is null");
+      DLOGW("Buffer handle is detected as null for layer: %s(%d) out of %lu layers with layer "
+            "flag value: %u", layer->layer_name.c_str(), layer->layer_id,
+            layer_stack_.layers.size(), layer->flags);
       continue;
     }
 
+    DLOGI("Dump layer[%d] of %lu handle %p", i, layer_stack_.layers.size(), handle);
+
     void *base_ptr = NULL;
     int error = buffer_allocator_->MapBuffer(handle, nullptr, &base_ptr);
     if (error != kErrorNone) {
@@ -2866,7 +2870,7 @@
                                 vsync_period_change_constraints->desiredTimeNanos);
 
   out_timeline->refreshRequired = true;
-  if (info.x_pixels != fb_width_ || info.y_pixels != fb_height_) {
+  if (is_client_up_ && (info.x_pixels != fb_width_ || info.y_pixels != fb_height_)) {
     out_timeline->refreshRequired = false;
     fb_width_ = info.x_pixels;
     fb_height_ = info.y_pixels;
@@ -3701,4 +3705,7 @@
   display_intf_->Abort();
 }
 
-} //namespace sdm
+void HWCDisplay::MarkClientActive(bool is_client_up) {
+  is_client_up_ = is_client_up ;
+}
+}  // namespace sdm
diff --git a/composer/hwc_display.h b/composer/hwc_display.h
index c38859e..017c41e 100644
--- a/composer/hwc_display.h
+++ b/composer/hwc_display.h
@@ -523,6 +523,7 @@
   virtual void SetConfigInfo(std::map<uint32_t, DisplayConfigVariableInfo>& variable_config_map,
                              int active_config_index, uint32_t num_configs) {};
   virtual void Abort();
+  virtual void MarkClientActive(bool is_client_up);
 
  protected:
   static uint32_t throttling_refresh_rate_;
@@ -703,6 +704,7 @@
   bool draw_method_set_ = false;
   bool validate_done_ = false;
   bool client_target_3_1_set_ = false;
+  bool is_client_up_ = false;
 };
 
 inline int HWCDisplay::Perform(uint32_t operation, ...) {
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 79ec0c7..7aa5ddc 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -1099,10 +1099,11 @@
   }
 
   // On SF stop, disable the idle time.
-  if (!pointer && is_idle_time_up_ && hwc_display_[HWC_DISPLAY_PRIMARY]) { // De-registering…
+  if (!pointer && is_client_up_ && hwc_display_[HWC_DISPLAY_PRIMARY]) { // De-registering…
     DLOGI("disable idle time");
     hwc_display_[HWC_DISPLAY_PRIMARY]->SetIdleTimeoutMs(0,0);
-    is_idle_time_up_ = false;
+    is_client_up_ = false;
+    hwc_display_[HWC_DISPLAY_PRIMARY]->MarkClientActive(false);
   }
 }
 
@@ -3719,23 +3720,69 @@
 
   Fence::Wait(retire_fence);
 
+  SCOPE_LOCK(pluggable_handler_lock_);
+  HWDisplaysInfo hw_displays_info = {};
+  DisplayError error = core_intf_->GetDisplaysStatus(&hw_displays_info);
+  if (error != kErrorNone) {
+    DLOGE("Failed to get connected display list. Error = %d", error);
+    return;
+  }
+
   for (hwc2_display_t display = HWC_DISPLAY_PRIMARY + 1;
     display < HWCCallbacks::kNumDisplays; display++) {
-    if (display != active_builtin_disp_id) {
-      Locker::ScopeLock lock_d(locker_[display]);
-      if (pending_power_mode_[display] && hwc_display_[display]) {
-        HWC2::Error error =
-          hwc_display_[display]->SetPowerMode(hwc_display_[display]->GetPendingPowerMode(), false);
-        if (HWC2::Error::None == error) {
-          pending_power_mode_[display] = false;
-          hwc_display_[display]->ClearPendingPowerMode();
-          pending_refresh_.set(UINT32(HWC_DISPLAY_PRIMARY));
-        } else {
-          DLOGE("SetDisplayStatus error = %d (%s)", error, to_string(error).c_str());
+    if (display == active_builtin_disp_id) {
+      continue;
+    }
+
+    Locker::ScopeLock lock_d(locker_[display]);
+    if (!pending_power_mode_[display] || !hwc_display_[display]) {
+      continue;
+    }
+
+    // check if a pluggable display which is in pending power state is already disconnected.
+    // In such cases, avoid powering up the display. It will be disconnected as part of
+    // HandlePendingHotplug.
+    bool disconnected = false;
+    hwc2_display_t client_id;
+    sdm::DisplayType disp_type;
+    for (auto &map_info : map_info_pluggable_) {
+      if (display != map_info.client_id) {
+        continue;
+      }
+
+      for (auto &iter : hw_displays_info) {
+        auto &info = iter.second;
+        if (info.display_id == map_info.sdm_id && !info.is_connected) {
+          disconnected = true;
+          break;
         }
       }
+      client_id = map_info.client_id;
+      disp_type = map_info.disp_type;
+      break;
+    }
+
+    if (disconnected) {
+      continue;
+    }
+
+    HWC2::PowerMode pending_mode = hwc_display_[display]->GetPendingPowerMode();
+
+    if (pending_mode == HWC2::PowerMode::Off || pending_mode == HWC2::PowerMode::DozeSuspend) {
+      map_active_displays_.erase(display);
+    } else {
+      map_active_displays_.insert(std::make_pair(client_id, disp_type));
+    }
+    HWC2::Error error = hwc_display_[display]->SetPowerMode(pending_mode, false);
+    if (HWC2::Error::None == error) {
+      pending_power_mode_[display] = false;
+      hwc_display_[display]->ClearPendingPowerMode();
+      pending_refresh_.set(UINT32(HWC_DISPLAY_PRIMARY));
+    } else {
+      DLOGE("SetDisplayStatus error = %d (%s)", error, to_string(error).c_str());
     }
   }
+
   secure_session_active_ = false;
 }
 
@@ -4227,6 +4274,7 @@
   {
     SEQUENCE_WAIT_SCOPE_LOCK(locker_[display]);
     DLOGI("Acquired lock for client %d display %" PRIu64, client_id, display);
+    callbacks_.Refresh(display);
     clients_waiting_for_commit_[display].set(client_id);
     locker_[display].Wait();
     if (commit_error_[display] != 0) {
diff --git a/composer/hwc_session.h b/composer/hwc_session.h
index 8886246..658ef21 100644
--- a/composer/hwc_session.h
+++ b/composer/hwc_session.h
@@ -722,7 +722,7 @@
   bool power_state_transition_[HWCCallbacks::kNumDisplays] = {};
   std::bitset<HWCCallbacks::kNumDisplays> display_ready_;
   bool secure_session_active_ = false;
-  bool is_idle_time_up_ = false;
+  bool is_client_up_ = false;
   std::shared_ptr<IPCIntf> ipc_intf_ = nullptr;
   bool primary_pending_ = true;
   Locker primary_display_lock_;
diff --git a/composer/hwc_session_services.cpp b/composer/hwc_session_services.cpp
index 12ad1ad..9ce8cd9 100644
--- a/composer/hwc_session_services.cpp
+++ b/composer/hwc_session_services.cpp
@@ -1567,7 +1567,8 @@
   if (hwc_session_->hwc_display_[HWC_DISPLAY_PRIMARY]) {
     DLOGI("enable idle time active_ms:%d inactive_ms:%d",active_ms,inactive_ms);
     hwc_session_->hwc_display_[HWC_DISPLAY_PRIMARY]->SetIdleTimeoutMs(active_ms, inactive_ms);
-    hwc_session_->is_idle_time_up_ = true;
+    hwc_session_->is_client_up_ = true;
+    hwc_session_->hwc_display_[HWC_DISPLAY_PRIMARY]->MarkClientActive(true);
     hwc_session_->idle_time_inactive_ms_ = inactive_ms;
     hwc_session_->idle_time_active_ms_ = active_ms;
     return 0;
diff --git a/include/display_properties.h b/include/display_properties.h
index 219c8c4..ca304fd 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -155,6 +155,7 @@
 #define DEMURA_SECONDARY_PANEL_OVERRIDE_HIGH    DISPLAY_PROP("demura_secondary_panel_override_high")
 // Panel Feature DemuraTn Properties
 #define ENABLE_ANTI_AGING                    DISPLAY_PROP("enable_antiaging")
+#define ENABLE_ACCELERATED_AGING             DISPLAY_PROP("enable_accelerated_aging")
 #define ANTI_AGING_SHORT_TIMER               DISPLAY_PROP("demura_short_timer")
 #define ANTI_AGING_LONG_TIMER                DISPLAY_PROP("demura_long_timer")
 #define ANTI_AGING_RECALIB_TIMER             DISPLAY_PROP("demura_recalib_timer")
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index 81f921d..a987365 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -1068,6 +1068,7 @@
   kCscYuv2Rgb2020L,
   kCscYuv2Rgb2020FR,
   kCscYuv2RgbDolbyVisionP5,
+  kCscYuv2RgbDCIP3FR,
   kCscTypeMax,
 };
 
diff --git a/sde-drm/drm_crtc.cpp b/sde-drm/drm_crtc.cpp
old mode 100644
new mode 100755
index ab66b7f..57eeeb9
--- a/sde-drm/drm_crtc.cpp
+++ b/sde-drm/drm_crtc.cpp
@@ -168,6 +168,7 @@
 #define __CLASS__ "DRMCrtcManager"
 
 void DRMCrtcManager::Init(drmModeRes *resource) {
+  lock_guard<mutex> lock(lock_);
   for (int i = 0; i < resource->count_crtcs; i++) {
     unique_ptr<DRMCrtc> crtc(new DRMCrtc(fd_, i));
     drmModeCrtc *libdrm_crtc = drmModeGetCrtc(fd_, resource->crtcs[i]);
@@ -181,10 +182,12 @@
 }
 
 void DRMCrtcManager::DumpByID(uint32_t id) {
+  lock_guard<mutex> lock(lock_);
   crtc_pool_.at(id)->Dump();
 }
 
 void DRMCrtcManager::DumpAll() {
+  lock_guard<mutex> lock(lock_);
   for (auto &crtc : crtc_pool_) {
     crtc.second->Dump();
   }
@@ -210,6 +213,7 @@
 }
 
 void DRMCrtcManager::SetScalerLUT(const DRMScalerLUTInfo &lut_info) {
+  lock_guard<mutex> lock(lock_);
   // qseed3lite lut is hardcoded in HW. No need to program from sw.
   DRMCrtcInfo info;
   crtc_pool_.begin()->second->GetInfo(&info);
@@ -232,6 +236,7 @@
 }
 
 void DRMCrtcManager::UnsetScalerLUT() {
+  lock_guard<mutex> lock(lock_);
   if (dir_lut_blob_id_) {
     drmModeDestroyPropertyBlob(fd_, dir_lut_blob_id_);
     dir_lut_blob_id_ = 0;
@@ -247,6 +252,7 @@
 }
 
 int DRMCrtcManager::GetCrtcInfo(uint32_t crtc_id, DRMCrtcInfo *info) {
+  lock_guard<mutex> lock(lock_);
   if (crtc_id == 0) {
     crtc_pool_.begin()->second->GetInfo(info);
   } else {
@@ -263,6 +269,7 @@
 }
 
 void DRMCrtcManager::GetPPInfo(uint32_t crtc_id, DRMPPFeatureInfo *info) {
+  lock_guard<mutex> lock(lock_);
   auto it = crtc_pool_.find(crtc_id);
   if (it == crtc_pool_.end()) {
     DRM_LOGE("Invalid crtc id %d", crtc_id);
@@ -274,6 +281,7 @@
 
 int DRMCrtcManager::Reserve(const std::set<uint32_t> &possible_crtc_indices,
                              DRMDisplayToken *token) {
+  lock_guard<mutex> lock(lock_);
   for (auto &item : crtc_pool_) {
     if (item.second->GetStatus() == DRMStatus::FREE) {
       if (possible_crtc_indices.find(item.second->GetIndex()) != possible_crtc_indices.end()) {
diff --git a/sde-drm/drm_plane.cpp b/sde-drm/drm_plane.cpp
index 8d5c0a5..a41f096 100644
--- a/sde-drm/drm_plane.cpp
+++ b/sde-drm/drm_plane.cpp
@@ -179,7 +179,18 @@
     { 0x0, 0x0, 0x0,},
     { 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
     { 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
-  }
+  },
+  [kCscYuv2RgbDCIP3FR] = {
+    {
+      0x100000000, 0x0, 0x194800000,
+      0x100000000, 0x7fd2800000, 0x7f8a800000,
+      0x100000000, 0x1dc800000, 0x0,
+    },
+    { 0x0, 0xfe00, 0xfe00,},
+    { 0x0, 0x0, 0x0, },
+    { 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
+    { 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
+  },
 };
 
 static struct drm_msm_fp16_csc csc_fp16_convert[kFP16CscTypeMax] = {
diff --git a/sdm/include/core/buffer_allocator.h b/sdm/include/core/buffer_allocator.h
index 63b9f8c..fb05db8 100644
--- a/sdm/include/core/buffer_allocator.h
+++ b/sdm/include/core/buffer_allocator.h
@@ -81,6 +81,17 @@
   bool trusted_ui = false;                    //!< Specifies buffer to be allocated from non-secure
                                               //!< contiguous memory.
   BufferAccessControlMap access_control;      //!< Specifies the access permission for this buffer
+
+  bool operator!=(const BufferConfig& config) const {
+    return width != config.width   ||
+           height != config.height ||
+           format != config.format ||
+           secure != config.secure ||
+           cache != config.cache   ||
+           secure_camera != config.secure_camera ||
+           gfx_client != config.gfx_client ||
+           trusted_ui != config.trusted_ui;
+  }
 };
 
 /*! @brief Holds the information about the allocated buffer.
diff --git a/sdm/include/private/extension_interface.h b/sdm/include/private/extension_interface.h
index be13a7c..e7511cc 100644
--- a/sdm/include/private/extension_interface.h
+++ b/sdm/include/private/extension_interface.h
@@ -69,6 +69,7 @@
                                           const HWResourceInfo &hw_resource_info,
                                           const HWPanelInfo &hw_panel_info,
                                           const HWMixerAttributes &mixer_attributes,
+                                          const HWDisplayAttributes &display_attributes,
                                           const DisplayConfigVariableInfo &fb_config,
                                           StrategyInterface **interface) = 0;
   virtual DisplayError DestroyStrategyExtn(StrategyInterface *interface) = 0;
diff --git a/sdm/include/private/resource_interface.h b/sdm/include/private/resource_interface.h
index 95e0969..630b140 100644
--- a/sdm/include/private/resource_interface.h
+++ b/sdm/include/private/resource_interface.h
@@ -141,7 +141,7 @@
   virtual void HandleSkipValidate(Handle display_ctx) = 0;
   virtual std::string Dump() = 0;
   virtual uint32_t GetMixerCount() = 0;
-  virtual void HandleTUITransition(bool tui_active) = 0;
+  virtual void HandleTUITransition(Handle display_ctx, bool tui_active) = 0;
 };
 
 }  // namespace sdm
diff --git a/sdm/include/private/strategy_interface.h b/sdm/include/private/strategy_interface.h
index f2025af..3593f25 100644
--- a/sdm/include/private/strategy_interface.h
+++ b/sdm/include/private/strategy_interface.h
@@ -58,6 +58,7 @@
   virtual DisplayError SetDrawMethod(const DisplayDrawMethod &draw_method) = 0;
   virtual DisplayError Reconfigure(const HWPanelInfo &hw_panel_info,
                                    const HWResourceInfo &hw_res_info,
+                                   const HWDisplayAttributes &display_attributes,
                                    const HWMixerAttributes &mixer_attributes,
                                    const DisplayConfigVariableInfo &fb_config) = 0;
   virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
diff --git a/sdm/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp
index da69d9a..be7639c 100755
--- a/sdm/libs/core/comp_manager.cpp
+++ b/sdm/libs/core/comp_manager.cpp
@@ -777,12 +777,12 @@
                             display_comp_ctx->display_resource_ctx);
   }
   if (secure_event == kTUITransitionStart) {
-    resource_intf_->HandleTUITransition(true);
+    resource_intf_->HandleTUITransition(display_comp_ctx->display_resource_ctx, true);
   }
   if (secure_event == kTUITransitionEnd) {
     resource_intf_->Perform(ResourceInterface::kCmdResetLUT,
                             display_comp_ctx->display_resource_ctx);
-    resource_intf_->HandleTUITransition(false);
+    resource_intf_->HandleTUITransition(display_comp_ctx->display_resource_ctx, false);
     safe_mode_ = false;
   }
   safe_mode_ = (secure_event == kTUITransitionStart) ? true : safe_mode_;
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 9a6f476..f14d2cb 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -1959,12 +1959,6 @@
     return kErrorNone;
   }
 
-  // Reject active config changes if qsync is in use.
-  if (needs_avr_update_ || qsync_mode_ != kQSyncModeNone) {
-    DLOGE("Failed: needs_avr_update_: %d, qsync_mode_: %d", needs_avr_update_, qsync_mode_);
-    return kErrorNotSupported;
-  }
-
   error = hw_intf_->SetDisplayAttributes(index);
   if (error != kErrorNone) {
     return error;
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 3a8d6ee..2a4bc76 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -169,18 +169,19 @@
       return error;
     }
 
-    if ((error = SetupDemura()) != kErrorNone) {
+    DisplayError tmp = kErrorNone;
+    if ((tmp = SetupDemura()) != kErrorNone) {
       // Non-fatal but not expected, log error
       DLOGE("Demura failed to initialize on display %d-%d, Error = %d", display_id_,
-            display_type_, error);
+            display_type_, tmp);
       comp_manager_->FreeDemuraFetchResources(display_id_);
       comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
       if (demura_) {
         SetDemuraIntfStatus(false);
       }
     } else if (demuratn_factory_) {
-      if ((error = SetupDemuraTn()) != kErrorNone) {
-        DLOGW("Failed to setup DemuraTn, Error = %d", error);
+      if ((tmp = SetupDemuraTn()) != kErrorNone) {
+        DLOGW("Failed to setup DemuraTn, Error = %d", tmp);
       }
     }
   } else {
@@ -254,6 +255,7 @@
         DLOGE("Unable to DeInit DemuraTn on Display %d", display_id_);
       }
     }
+    demura_dynamic_enabled_ = true;
 
     DeinitCWBBuffer();
   }
@@ -959,7 +961,7 @@
   }
 
   // Must go in NullCommit
-  if (demura_intended_ &&
+  if (demura_intended_ && demura_dynamic_enabled_ &&
       comp_manager_->GetDemuraStatusForDisplay(display_id_) && (state == kStateOff)) {
     comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
     SetDemuraIntfStatus(false);
@@ -987,7 +989,7 @@
   }
 
   // Must only happen after NullCommit and get applied in next frame
-  if (demura_intended_ &&
+  if (demura_intended_ && demura_dynamic_enabled_ &&
       !comp_manager_->GetDemuraStatusForDisplay(display_id_) && (state == kStateOn)) {
     comp_manager_->SetDemuraStatusForDisplay(display_id_, true);
     SetDemuraIntfStatus(true);
@@ -1902,7 +1904,7 @@
   }
 
   // force clear qsync mode if set by idle timeout.
-  if (qsync_mode_ !=  kQSyncModeNone && qsync_mode_ == qsync_mode) {
+  if (qsync_mode_ ==  active_qsync_mode_ && qsync_mode_ == qsync_mode) {
     DLOGW("Qsync mode already set as requested mode: qsync_mode_=%d", qsync_mode_);
     return kErrorNone;
   }
@@ -2555,6 +2557,25 @@
 
 
 // LCOV_EXCL_START
+DisplayError DisplayBuiltIn::HandleSecureEvent(SecureEvent secure_event, bool *needs_refresh) {
+  DisplayError error = kErrorNone;
+
+  error = DisplayBase::HandleSecureEvent(secure_event, needs_refresh);
+  if (error) {
+    DLOGE("Failed to handle secure event %d", secure_event);
+    return error;
+  }
+
+  if (secure_event == kTUITransitionEnd) {
+    // enable demura after TUI transition end
+    if (demura_) {
+      SetDemuraIntfStatus(true);
+    }
+  }
+
+  return error;
+}
+
 DisplayError DisplayBuiltIn::PostHandleSecureEvent(SecureEvent secure_event) {
   ClientLock lock(disp_mutex_);
   if (secure_event == kTUITransitionStart) {
@@ -2571,6 +2592,13 @@
       // Send display config information to secondary VM on TUI session start
       SendDisplayConfigs();
     }
+
+    if (secure_event == kTUITransitionStart) {
+      //  disable demura before TUI transition start
+      if (demura_) {
+        SetDemuraIntfStatus(false);
+      }
+    }
   }
   if (secure_event == kTUITransitionEnd) {
     if (vm_cb_intf_) {
@@ -2953,6 +2981,7 @@
       return kErrorUndefined;
     }
     comp_manager_->SetDemuraStatusForDisplay(display_id_, true);
+    demura_dynamic_enabled_ = true;
   } else if (!state && comp_manager_->GetDemuraStatusForDisplay(display_id_)) {
     ret = SetDemuraIntfStatus(false);
     if (ret) {
@@ -2960,6 +2989,7 @@
       return kErrorUndefined;
     }
     comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
+    demura_dynamic_enabled_ = false;
   }
 
   // Disable Partial Update for one frame.
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index d4c7e88..9ca3395 100644
--- a/sdm/libs/core/display_builtin.h
+++ b/sdm/libs/core/display_builtin.h
@@ -180,6 +180,7 @@
   DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info) override;
   DisplayError PrePrepare(LayerStack *layer_stack) override;
   DisplayError SetAlternateDisplayConfig(uint32_t *alt_config) override;
+  DisplayError HandleSecureEvent(SecureEvent secure_event, bool *needs_refresh) override;
   DisplayError PostHandleSecureEvent(SecureEvent secure_event) override;
   void InitCWBBuffer();
   void DeinitCWBBuffer();
@@ -296,6 +297,7 @@
   std::shared_ptr<DemuraTnCoreUvmIntf> demuratn_ = nullptr;
   Layer demura_layer_ = {};
   bool demura_intended_ = false;
+  bool demura_dynamic_enabled_ = true;
   bool enable_dpps_dyn_fps_ = false;
   HWDisplayMode last_panel_mode_ = kModeDefault;
   bool hdr_present_ = false;
diff --git a/sdm/libs/core/display_virtual.cpp b/sdm/libs/core/display_virtual.cpp
index 433537a..4316f8b 100644
--- a/sdm/libs/core/display_virtual.cpp
+++ b/sdm/libs/core/display_virtual.cpp
@@ -120,6 +120,9 @@
     return error;
   }
 
+  uint32_t active_index = 0;
+  hw_intf_->GetActiveConfig(&active_index);
+  hw_intf_->GetDisplayAttributes(active_index, &display_attributes);
   hw_intf_->GetHWPanelInfo(&hw_panel_info);
 
   if (set_max_lum_ != -1.0 || set_min_lum_ != -1.0) {
diff --git a/sdm/libs/core/resource_default.cpp b/sdm/libs/core/resource_default.cpp
index f76ab6f..5aaed31 100644
--- a/sdm/libs/core/resource_default.cpp
+++ b/sdm/libs/core/resource_default.cpp
@@ -392,7 +392,7 @@
   return 0;
 }
 
-void ResourceDefault::HandleTUITransition(bool tui_active) {
+void ResourceDefault::HandleTUITransition(Handle display_ctx, bool tui_active) {
 }
 
 DisplayError ResourceDefault::PostCommit(Handle display_ctx, DispLayerStack *disp_layer_stack) {
diff --git a/sdm/libs/core/resource_default.h b/sdm/libs/core/resource_default.h
index e2dc222..b246ecc 100644
--- a/sdm/libs/core/resource_default.h
+++ b/sdm/libs/core/resource_default.h
@@ -141,7 +141,7 @@
   virtual void HandleSkipValidate(Handle display_ctx);
   virtual std::string Dump();
   virtual uint32_t GetMixerCount();
-  virtual void HandleTUITransition(bool tui_active);
+  virtual void HandleTUITransition(Handle display_ctx, bool tui_active);
 
  private:
   enum PipeOwner {
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
index cb4550c..eac6652 100644
--- a/sdm/libs/core/strategy.cpp
+++ b/sdm/libs/core/strategy.cpp
@@ -20,6 +20,10 @@
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+* Changes from Qualcomm Innovation Center are provided under the following license:
+* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+* SPDX-License-Identifier: BSD-3-Clause-Clear
 */
 
 #include <utils/constants.h>
@@ -55,7 +59,8 @@
   if (extension_intf_) {
     error = extension_intf_->CreateStrategyExtn(display_id_, display_type_, buffer_allocator_,
                                                 hw_resource_info_, hw_panel_info_,
-                                                mixer_attributes_, fb_config_, &strategy_intf_);
+                                                mixer_attributes_, display_attributes_, fb_config_,
+                                                &strategy_intf_);
     if (error != kErrorNone) {
       DLOGE("Failed to create strategy for display %d-%d", display_id_, display_type_);
       return error;
@@ -219,8 +224,8 @@
                                        mixer_attributes, display_attributes, fb_config,
                                        &partial_update_intf_);
 
-  error = strategy_intf_->Reconfigure(hw_panel_info, hw_resource_info_, mixer_attributes,
-                                      fb_config);
+  error = strategy_intf_->Reconfigure(hw_panel_info, hw_resource_info_, display_attributes,
+                                      mixer_attributes, fb_config);
   if (error != kErrorNone) {
     return error;
   }
diff --git a/sdm/libs/dal/hw_device_drm.cpp b/sdm/libs/dal/hw_device_drm.cpp
index 2d0ea40..c70ff12 100644
--- a/sdm/libs/dal/hw_device_drm.cpp
+++ b/sdm/libs/dal/hw_device_drm.cpp
@@ -1970,6 +1970,9 @@
   sync_commit = true;
 #endif
 
+  // dpps commit feature ops doesn't use the obj id, set it as -1
+  drm_atomic_intf_->Perform(DRMOps::DPPS_COMMIT_FEATURE, -1);
+
   int ret = NullCommit(sync_commit /* synchronous */, false /* retain_planes*/);
   if (ret) {
     DLOGE("failed with error %d", ret);
@@ -2040,6 +2043,10 @@
       *type = ((input_buffer.color_metadata.range == Range_Full) ?
                 DRMCscType::kCscYuv2Rgb2020FR : DRMCscType::kCscYuv2Rgb2020L);
       break;
+    case ColorPrimaries_DCIP3:
+      *type = ((input_buffer.color_metadata.range == Range_Full) ?
+                DRMCscType::kCscYuv2RgbDCIP3FR : DRMCscType::kCscTypeMax);
+      break;
     default:
       break;
   }
diff --git a/sdm/libs/dal/hw_virtual_drm.cpp b/sdm/libs/dal/hw_virtual_drm.cpp
index f6f3de5..37d323f 100644
--- a/sdm/libs/dal/hw_virtual_drm.cpp
+++ b/sdm/libs/dal/hw_virtual_drm.cpp
@@ -70,6 +70,7 @@
 #include <utils/utils.h>
 #include <algorithm>
 #include <vector>
+#include <cmath>
 #include "hw_device_drm.h"
 #include "hw_virtual_drm.h"
 #include "hw_info_drm.h"
@@ -139,7 +140,8 @@
   mode.vdisplay = mode.vsync_start = mode.vsync_end = mode.vtotal =
                                        UINT16(display_attributes.y_pixels);
   mode.vrefresh = UINT32(display_attributes.fps);
-  mode.clock = (mode.htotal * mode.vtotal * mode.vrefresh) / 1000;
+
+  mode.clock = std::round(FLOAT(mode.htotal * mode.vtotal * mode.vrefresh) / 1000.00f);
   snprintf(mode.name, DRM_DISPLAY_MODE_LEN, "%dx%d", mode.hdisplay, mode.vdisplay);
   modes.push_back(mode);
   for (auto &item : connector_info_.modes) {