hwc2: Check for color modes support

Check for color modes support by Display, before marking layer as HDR.

CRs-Fixed: 2102517
Change-Id: Id8595dcb322900f98556c40fde94fa88e3ec4e39
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index a89147c..d3e3379 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -462,6 +462,9 @@
   bool secure_display_active = false;
   layer_stack_.flags.animating = animating_;
 
+  uint32_t color_mode_count = 0;
+  display_intf_->GetColorModeCount(&color_mode_count);
+
   // Add one layer for fb target
   // TODO(user): Add blit target layers
   for (auto hwc_layer : layer_set_) {
@@ -534,7 +537,7 @@
     bool hdr_layer = layer->input_buffer.color_metadata.colorPrimaries == ColorPrimaries_BT2020 &&
                      (layer->input_buffer.color_metadata.transfer == Transfer_SMPTE_ST2084 ||
                      layer->input_buffer.color_metadata.transfer == Transfer_HLG);
-    if (hdr_layer && !disable_hdr_handling_) {
+    if (hdr_layer && !disable_hdr_handling_ && color_mode_count) {
       // dont honor HDR when its handling is disabled
       layer->input_buffer.flags.hdr = true;
       layer_stack_.flags.hdr_present = true;