Merge "hwc: Reduce logging severity for non-critical failures"
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_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/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/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 6cc9c55..8d4d4cb 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;
@@ -3807,12 +3801,12 @@
     SetPendingPowerState(state);
   }
 
+  comp_manager_->HandleSecureEvent(display_comp_ctx_, secure_event);
   err = hw_intf_->HandleSecureEvent(secure_event, cached_qos_data_);
   if (err != kErrorNone) {
     return err;
   }
 
-  comp_manager_->HandleSecureEvent(display_comp_ctx_, secure_event);
   secure_event_ = secure_event;
   if (secure_event == kTUITransitionEnd) {
     DisplayState pending_state;
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 8f02046..4a16689 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -1903,7 +1903,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;
   }
@@ -2556,6 +2556,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) {
@@ -2572,6 +2591,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_) {
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index d4c7e88..d0bf901 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();
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/dal/hw_device_drm.cpp b/sdm/libs/dal/hw_device_drm.cpp
index 088150d..79749b8 100644
--- a/sdm/libs/dal/hw_device_drm.cpp
+++ b/sdm/libs/dal/hw_device_drm.cpp
@@ -2040,6 +2040,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_tv_drm.cpp b/sdm/libs/dal/hw_tv_drm.cpp
index ccafa85..7cc72da 100644
--- a/sdm/libs/dal/hw_tv_drm.cpp
+++ b/sdm/libs/dal/hw_tv_drm.cpp
@@ -257,6 +257,12 @@
     // LP connecter prop N/A for External
     drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 0);
   }
+
+  if (cwb_config_.cwb_disp_id == display_id_ && cwb_config_.enabled) {
+    drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, cwb_config_.token.conn_id, 0);
+    DLOGI("Teardown CWB on %d-%d", display_id_, disp_type_);
+  }
+
   ClearSolidfillStages();
   int ret = drm_atomic_intf_->Commit(true /* synchronous */, false /* retain_planes*/);
   if (ret) {