sdm: drm: Configure DSI display topology

topology_control is a connector property that allows allocation of
additional display pipeline resources for panel correction, dither,
gamut map etc. Set the following display topology configurations:
- Allocate a Destination Scaler (DS) for the primary display.
- Allocate Destination Surface Processing Pipes (DSPP) for all built-
  in (DSI) displays.

CRs-Fixed: 2334869
Change-Id: If82362aea643ff83860fa595f9eae109f180cda8
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index 0fe0d2c..8cb300a 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -389,6 +389,12 @@
    *     uint32_t - qsync mode
    */
   CONNECTOR_SET_QSYNC_MODE,
+  /*
+   * Op: Sets topology control on this connector
+   * Arg: uint32_t - Connector ID
+   *      uint32_t - Topology control bit-mask
+   */
+  CONNECTOR_SET_TOPOLOGY_CONTROL,
 };
 
 enum struct DRMRotation {
@@ -603,6 +609,7 @@
   // Connection status of this connector
   bool is_connected;
   bool is_wb_ubwc_supported;
+  uint32_t topology_control;
 };
 
 // All DRM Connectors as map<Connector_id , connector_info>
@@ -765,6 +772,14 @@
   CONTINUOUS,
 };
 
+enum struct DRMTopologyControl {
+  NONE          = 0,
+  RESERVE_LOCK  = 1 << 0,
+  RESERVE_CLEAR = 1 << 1,
+  DSPP          = 1 << 2,
+  DEST_SCALER   = 1 << 3,
+};
+
 struct DRMSolidfillStage {
   DRMRect bounding_rect {};
   bool is_exclusion_rect = false;
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index cd08e38..e2e00e7 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -1128,6 +1128,8 @@
   }
 
   if (first_cycle_) {
+    drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_TOPOLOGY_CONTROL, token_.conn_id,
+                              topology_control_);
     drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
     drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
     drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index 9bc02b6..65fdf1a 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -213,6 +213,7 @@
   bool secure_display_active_ = false;
   uint64_t debug_dump_count_ = 0;
   bool synchronous_commit_ = false;
+  uint32_t topology_control_ = 0;
 
  private:
   std::string interface_str_ = "DSI";
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp
index 46e7b5a..5db852e 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.cpp
+++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp
@@ -63,6 +63,10 @@
   scalar_data_.resize(hw_resource_.hw_dest_scalar_info.count);
   dest_scalar_cache_.resize(hw_resource_.hw_dest_scalar_info.count);
 
+  topology_control_ = UINT32(sde_drm::DRMTopologyControl::DSPP);
+  if (hw_panel_info_.is_primary_panel) {
+    topology_control_ |= UINT32(sde_drm::DRMTopologyControl::DEST_SCALER);
+  }
   return kErrorNone;
 }