sdm: Add support to simulate reduced configuration

Add support to simulate reduce plane configuration.

Change-Id: Ic4633668ff255840af3a175a66d553ee017bb27b
CRs-Fixed: 2071452
diff --git a/sdm/libs/core/drm/hw_info_drm.cpp b/sdm/libs/core/drm/hw_info_drm.cpp
index bf7a5ab..7aba977 100644
--- a/sdm/libs/core/drm/hw_info_drm.cpp
+++ b/sdm/libs/core/drm/hw_info_drm.cpp
@@ -218,6 +218,7 @@
   DLOGI("\tLinear = %d", hw_resource->linear_factor);
   DLOGI("\tScale = %d", hw_resource->scale_factor);
   DLOGI("\tFudge_factor = %d", hw_resource->extra_fudge_factor);
+  DLOGI("\tib_fudge_factor = %d", hw_resource->ib_fudge_factor);
 
   if (hw_resource->separate_rotator || hw_resource->num_dma_pipe) {
     GetHWRotatorInfo(hw_resource);
@@ -286,7 +287,42 @@
 void HWInfoDRM::GetHWPlanesInfo(HWResourceInfo *hw_resource) {
   DRMPlanesInfo planes;
   drm_mgr_intf_->GetPlanesInfo(&planes);
+
+  // To simulate reduced config.
+  uint32_t max_vig_pipes = 0;
+  uint32_t max_dma_pipes = 0;
+  Debug::GetReducedConfig(&max_vig_pipes, &max_dma_pipes);
+  uint32_t max_virtual_pipes = max_vig_pipes + max_dma_pipes;
+  uint32_t vig_pipe_count = 0;
+  uint32_t dma_pipe_count = 0;
+  uint32_t virtual_pipe_count = 0;
+
   for (auto &pipe_obj : planes) {
+    if (max_vig_pipes && max_dma_pipes) {
+      uint32_t master_plane_id = pipe_obj.second.master_plane_id;
+      if ((pipe_obj.second.type == DRMPlaneType::DMA) && (dma_pipe_count < max_dma_pipes)
+          && !master_plane_id) {
+        dma_pipe_count++;
+      } else if ((pipe_obj.second.type == DRMPlaneType::VIG) && (vig_pipe_count < max_vig_pipes)
+          && !master_plane_id) {
+        vig_pipe_count++;
+      } else if ((master_plane_id) && (virtual_pipe_count < max_virtual_pipes)) {
+        bool is_virtual = false;
+        for (auto &pipe_caps : hw_resource->hw_pipes) {
+          if (master_plane_id == pipe_caps.id) {
+            is_virtual = true;
+            virtual_pipe_count++;
+            break;
+          }
+        }
+        if (!is_virtual) {
+          continue;
+        }
+      } else {
+        continue;
+      }
+    }
+
     HWPipeCaps pipe_caps;
     string name = {};
     switch (pipe_obj.second.type) {
@@ -321,7 +357,8 @@
     }
     pipe_caps.id = pipe_obj.first;
     pipe_caps.master_pipe_id = pipe_obj.second.master_plane_id;
-    DLOGI("Adding %s Pipe : Id %d", name.c_str(), pipe_obj.first);
+    DLOGI("Adding %s Pipe : Id %d, master_pipe_id : Id %d",
+          name.c_str(), pipe_obj.first, pipe_obj.second.master_plane_id);
     hw_resource->hw_pipes.push_back(std::move(pipe_caps));
   }
 }
diff --git a/sdm/libs/utils/debug.cpp b/sdm/libs/utils/debug.cpp
index 95b4e3b..592be68 100644
--- a/sdm/libs/utils/debug.cpp
+++ b/sdm/libs/utils/debug.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -190,6 +190,22 @@
   return kErrorNone;
 }
 
+DisplayError Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) {
+  char value[64] = {};
+
+  DisplayError error = debug_.debug_handler_->GetProperty("sdm.debug.reduced_config", value);
+  if (error != kErrorNone) {
+    return error;
+  }
+
+  std::string str(value);
+
+  *num_vig_pipes = UINT32(stoi(str));
+  *num_dma_pipes = UINT32(stoi(str.substr(str.find('x') + 1)));
+
+  return kErrorNone;
+}
+
 int Debug::GetExtMaxlayers() {
   int max_external_layers = 0;
   debug_.debug_handler_->GetProperty("sdm.max_external_layers", &max_external_layers);