sdm: Update solid-fill to support 10-bit

Currently the solid fill is hard-coded to 8 bit depth. SDM845 hardware
supports 10 bit solid fill. Change adds the support for various bit
depth's of solid fill color.

Change-Id: I3435cad5bb0b6f9097f22b39065944cb4f20d08c
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index ca2f6ff..e2876a6 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -490,6 +490,11 @@
  DRMRect bounding_rect {};
  bool is_exclusion_rect = false;
  uint32_t color = 0xff000000; // in 8bit argb
+ uint32_t red = 0;
+ uint32_t blue = 0;
+ uint32_t green = 0;
+ uint32_t alpha = 0xff;
+ uint32_t color_bit_depth = 0;
  uint32_t z_order = 0;
  uint32_t plane_alpha = 0xff;
 };
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index b8977e2..0e44ab5 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -291,6 +291,18 @@
   uint32_t count = 0;      //!< Number of elements in the array.
 };
 
+/*! @brief This structure defines solidfill structure.
+
+  @sa LayerSolidFill
+*/
+struct LayerSolidFill {
+  uint32_t bit_depth = 0;  //!< Bit depth of solid fill colors
+  uint32_t red = 0;        //!< Red value
+  uint32_t green = 0;      //!< Green value
+  uint32_t blue = 0;       //!< Blue value
+  uint32_t alpha = 0;      //!< Alpha value
+};
+
 /*! @brief This structure defines display layer object which contains layer properties and a drawing
   buffer.
 
@@ -351,7 +363,9 @@
   uint32_t frame_rate = 0;                         //!< Rate at which frames are being updated for
                                                    //!< this layer.
 
-  uint32_t solid_fill_color = 0;                   //!< Solid color used to fill the layer when
+  uint32_t solid_fill_color = 0;                   //!< TODO: Remove this field when fb support
+                                                   //!  is deprecated.
+                                                   //!< Solid color used to fill the layer when
                                                    //!< no content is associated with the layer.
 
   LayerFlags flags;                                //!< Flags associated with this layer.
@@ -360,6 +374,7 @@
 
   Lut3d lut_3d = {};                               //!< o/p - Populated by SDM when tone mapping is
                                                    //!< needed on this layer.
+  LayerSolidFill solid_fill_info = {};             //!< solid fill info along with depth.
 };
 
 /*! @brief This structure defines a layer stack that contains layers which need to be composed and
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
index 421277a..73f3cda 100644
--- a/sdm/include/private/hw_info_types.h
+++ b/sdm/include/private/hw_info_types.h
@@ -476,6 +476,7 @@
   uint32_t color = 0;
   LayerRect roi = {};
   bool is_exclusion_rect = false;
+  LayerSolidFill solid_fill_info = {};
 };
 
 struct HWLayerConfig {
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index a5ed8a2..6d6d4d0 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -715,6 +715,7 @@
     HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
 
     if (hw_layers->config[i].use_solidfill_stage) {
+      hw_layers->config[i].hw_solidfill_stage.solid_fill_info = layer.solid_fill_info;
       AddSolidfillStage(hw_layers->config[i].hw_solidfill_stage, layer.plane_alpha);
       continue;
     }
@@ -812,7 +813,19 @@
   solidfill.is_exclusion_rect  = sf.is_exclusion_rect;
   solidfill.plane_alpha = plane_alpha;
   solidfill.z_order = sf.z_order;
-  solidfill.color = sf.color;
+  if (!sf.solid_fill_info.bit_depth) {
+    solidfill.color_bit_depth = 8;
+    solidfill.alpha = (0xff000000 & sf.color) >> 24;
+    solidfill.red = (0xff0000 & sf.color) >> 16;
+    solidfill.green = (0xff00 & sf.color) >> 8;
+    solidfill.blue = 0xff & sf.color;
+  } else {
+    solidfill.color_bit_depth = sf.solid_fill_info.bit_depth;
+    solidfill.alpha = sf.solid_fill_info.alpha;
+    solidfill.red = sf.solid_fill_info.red;
+    solidfill.green = sf.solid_fill_info.green;
+    solidfill.blue = sf.solid_fill_info.blue;
+  }
   solid_fills_.push_back(solidfill);
   DLOGI_IF(kTagDriverConfig, "Add a solidfill stage at z_order:%d argb_color:%x plane_alpha:%x",
            solidfill.z_order, solidfill.color, solidfill.plane_alpha);
diff --git a/sdm/libs/hwc2/hwc_color_manager.cpp b/sdm/libs/hwc2/hwc_color_manager.cpp
index d753fdc..5b6720a 100644
--- a/sdm/libs/hwc2/hwc_color_manager.cpp
+++ b/sdm/libs/hwc2/hwc_color_manager.cpp
@@ -171,6 +171,7 @@
 
 int HWCColorManager::SetSolidFill(const void *params, bool enable, HWCDisplay *hwc_display) {
   SCOPE_LOCK(locker_);
+  LayerSolidFill solid_fill_color;
 
   if (params) {
     solid_fill_params_ = *reinterpret_cast<const PPColorFillParams *>(params);
@@ -178,7 +179,19 @@
     solid_fill_params_ = PPColorFillParams();
   }
 
-  uint32_t solid_fill_color = Get8BitsARGBColorValue(solid_fill_params_);
+  if (solid_fill_params_.color.r_bitdepth != solid_fill_params_.color.b_bitdepth
+    || solid_fill_params_.color.r_bitdepth != solid_fill_params_.color.g_bitdepth) {
+    DLOGE("invalid bit depth r %d g %d b %d", solid_fill_params_.color.r_bitdepth,
+        solid_fill_params_.color.g_bitdepth, solid_fill_params_.color.b_bitdepth);
+    return -EINVAL;
+  }
+
+  solid_fill_color.bit_depth = solid_fill_params_.color.r_bitdepth;
+  solid_fill_color.red = solid_fill_params_.color.r;
+  solid_fill_color.blue = solid_fill_params_.color.b;
+  solid_fill_color.green = solid_fill_params_.color.g;
+  solid_fill_color.alpha = 0x3ff;
+
   if (enable) {
     LayerRect solid_fill_rect = {
       FLOAT(solid_fill_params_.rect.x), FLOAT(solid_fill_params_.rect.y),
@@ -186,10 +199,14 @@
       FLOAT(solid_fill_params_.rect.y) + FLOAT(solid_fill_params_.rect.height),
     };
 
-    hwc_display->Perform(HWCDisplayPrimary::SET_QDCM_SOLID_FILL_INFO, solid_fill_color);
+    hwc_display->Perform(HWCDisplayPrimary::SET_QDCM_SOLID_FILL_INFO, &solid_fill_color);
     hwc_display->Perform(HWCDisplayPrimary::SET_QDCM_SOLID_FILL_RECT, &solid_fill_rect);
   } else {
-    hwc_display->Perform(HWCDisplayPrimary::UNSET_QDCM_SOLID_FILL_INFO, 0);
+    solid_fill_color.red = 0;
+    solid_fill_color.blue = 0;
+    solid_fill_color.green = 0;
+    solid_fill_color.alpha = 0;
+    hwc_display->Perform(HWCDisplayPrimary::UNSET_QDCM_SOLID_FILL_INFO, &solid_fill_color);
   }
 
   return 0;
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 06d4749..0e8dc05 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -1694,7 +1694,12 @@
     solid_fill_layer_->dst_rect = rect;
 
     solid_fill_layer_->blending = kBlendingPremultiplied;
-    solid_fill_layer_->solid_fill_color = solid_fill_color_;
+    solid_fill_layer_->solid_fill_color = 0;
+    solid_fill_layer_->solid_fill_info.bit_depth = solid_fill_color_.bit_depth;
+    solid_fill_layer_->solid_fill_info.red = solid_fill_color_.red;
+    solid_fill_layer_->solid_fill_info.blue = solid_fill_color_.blue;
+    solid_fill_layer_->solid_fill_info.green = solid_fill_color_.green;
+    solid_fill_layer_->solid_fill_info.alpha = solid_fill_color_.alpha;
     solid_fill_layer_->frame_rate = 60;
     solid_fill_layer_->visible_regions.push_back(solid_fill_layer_->dst_rect);
     solid_fill_layer_->flags.updating = 1;
diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h
index e773e91..8f43737 100644
--- a/sdm/libs/hwc2/hwc_display.h
+++ b/sdm/libs/hwc2/hwc_display.h
@@ -293,7 +293,7 @@
   bool solid_fill_enable_ = false;
   Layer *solid_fill_layer_ = NULL;
   LayerRect solid_fill_rect_ = {};
-  uint32_t solid_fill_color_ = 0;
+  LayerSolidFill solid_fill_color_ = {};
   LayerRect display_rect_;
   bool validated_ = false;
   bool color_tranform_failed_ = false;
diff --git a/sdm/libs/hwc2/hwc_display_primary.cpp b/sdm/libs/hwc2/hwc_display_primary.cpp
index 1094100..64e163a 100644
--- a/sdm/libs/hwc2/hwc_display_primary.cpp
+++ b/sdm/libs/hwc2/hwc_display_primary.cpp
@@ -291,6 +291,7 @@
   va_list args;
   va_start(args, operation);
   int val = 0;
+  LayerSolidFill *solid_fill_color;
   LayerRect *rect = NULL;
 
   switch (operation) {
@@ -307,12 +308,12 @@
       SetDisplayMode(UINT32(val));
       break;
     case SET_QDCM_SOLID_FILL_INFO:
-      val = va_arg(args, int32_t);
-      SetQDCMSolidFillInfo(true, UINT32(val));
+      solid_fill_color = va_arg(args, LayerSolidFill*);
+      SetQDCMSolidFillInfo(true, *solid_fill_color);
       break;
     case UNSET_QDCM_SOLID_FILL_INFO:
-      val = va_arg(args, int32_t);
-      SetQDCMSolidFillInfo(false, UINT32(val));
+      solid_fill_color = va_arg(args, LayerSolidFill*);
+      SetQDCMSolidFillInfo(false, *solid_fill_color);
       break;
     case SET_QDCM_SOLID_FILL_RECT:
       rect = va_arg(args, LayerRect*);
@@ -348,7 +349,7 @@
   use_metadata_refresh_rate_ = enable;
 }
 
-void HWCDisplayPrimary::SetQDCMSolidFillInfo(bool enable, uint32_t color) {
+void HWCDisplayPrimary::SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color) {
   solid_fill_enable_ = enable;
   solid_fill_color_ = color;
 }
diff --git a/sdm/libs/hwc2/hwc_display_primary.h b/sdm/libs/hwc2/hwc_display_primary.h
index bf6b25f..49840c5 100644
--- a/sdm/libs/hwc2/hwc_display_primary.h
+++ b/sdm/libs/hwc2/hwc_display_primary.h
@@ -76,7 +76,7 @@
   virtual DisplayError SetDisplayMode(uint32_t mode);
   virtual DisplayError DisablePartialUpdateOneFrame();
   void ProcessBootAnimCompleted(void);
-  void SetQDCMSolidFillInfo(bool enable, uint32_t color);
+  void SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color);
   void ToggleCPUHint(bool set);
   void ForceRefreshRate(uint32_t refresh_rate);
   uint32_t GetOptimalRefreshRate(bool one_updating_layer);