sdm: Set multirect mode to driver via plane property

Change-Id: Ia3b33e8761392ca211f210e6600a47dde9c768e0
CRs-Fixed: 2166036
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index 01981ca..97660ea 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -144,6 +144,12 @@
    */
   PLANE_SET_CSC_CONFIG,
   /*
+   * Op: Sets multirect mode on this plane.
+   * Arg: uint32_t - Plane ID
+   *      uint32_t - multirect mode
+   */
+  PLANE_SET_MULTIRECT_MODE,
+  /*
    * Op: Activate or deactivate a CRTC
    * Arg: uint32_t - CRTC ID
    *      uint32_t - 1 to enable, 0 to disable
@@ -429,6 +435,7 @@
   uint64_t max_pipe_bandwidth;
   uint32_t cache_size;  // cache size in bytes for inline rotation support.
   QSEEDStepVersion qseed3_version;
+  bool multirect_prop_present = false;
 };
 
 // All DRM Planes as map<Plane_id , plane_type_info> listed from highest to lowest priority
@@ -556,6 +563,12 @@
   SECURE_ONLY,
 };
 
+enum struct DRMMultiRectMode {
+  NONE = 0,
+  PARALLEL = 1,
+  SERIAL = 2,
+};
+
 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 48bf02b..c734f4c 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -98,6 +98,7 @@
 using sde_drm::DRMSecureMode;
 using sde_drm::DRMSecurityLevel;
 using sde_drm::DRMCscType;
+using sde_drm::DRMMultiRectMode;
 
 namespace sdm {
 
@@ -901,6 +902,10 @@
         DRMCscType csc_type = DRMCscType::kCscTypeMax;
         SelectCscType(layer.input_buffer, &csc_type);
         drm_atomic_intf_->Perform(DRMOps::PLANE_SET_CSC_CONFIG, pipe_id, &csc_type);
+
+        DRMMultiRectMode multirect_mode;
+        SetMultiRectMode(pipe_info->flags, &multirect_mode);
+        drm_atomic_intf_->Perform(DRMOps::PLANE_SET_MULTIRECT_MODE, pipe_id, multirect_mode);
       }
     }
   }
@@ -1152,7 +1157,6 @@
   }
 }
 
-
 void HWDeviceDRM::SetSrcConfig(const LayerBuffer &input_buffer, const HWRotatorMode &mode,
                                uint32_t *config) {
   // In offline rotation case, rotator will handle deinterlacing.
@@ -1535,4 +1539,14 @@
   }
 }
 
+void HWDeviceDRM::SetMultiRectMode(const uint32_t flags, DRMMultiRectMode *target) {
+  *target = DRMMultiRectMode::NONE;
+  if (flags & kMultiRect) {
+    *target = DRMMultiRectMode::SERIAL;
+    if (flags & kMultiRectParallelMode) {
+      *target = DRMMultiRectMode::PARALLEL;
+    }
+  }
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index edb5d58..b08c0e6 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -132,6 +132,7 @@
                        sde_drm::DRMSecurityLevel *security_level);
   bool IsResolutionSwitchEnabled() const { return resolution_switch_enabled_; }
   void SetTopology(sde_drm::DRMTopology drm_topology, HWTopology *hw_topology);
+  void SetMultiRectMode(const uint32_t flags, sde_drm::DRMMultiRectMode *target);
 
   class Registry {
    public:
diff --git a/sdm/libs/core/drm/hw_info_drm.cpp b/sdm/libs/core/drm/hw_info_drm.cpp
index 269cc16..5c69ed7 100644
--- a/sdm/libs/core/drm/hw_info_drm.cpp
+++ b/sdm/libs/core/drm/hw_info_drm.cpp
@@ -399,7 +399,7 @@
     }
     pipe_caps.id = pipe_obj.first;
     pipe_caps.master_pipe_id = pipe_obj.second.master_plane_id;
-    DLOGI("Adding %s Pipe : Id %d, master_pipe_id : Id %d",
+    DLOGI("Adding %s Pipe : Id %x, master_pipe_id : Id %x",
           name.c_str(), pipe_obj.first, pipe_obj.second.master_plane_id);
     hw_resource->hw_pipes.push_back(std::move(pipe_caps));
   }