display: Add support for legacy Wide Color Gamut

- Add extended range in ColorMetadata.
- Send ColorPrimaryTransfer info from color modes to Strategy,
  which will be used in determining the blend color space.
- Remove handling color primaries or gamut in HWC2.
- Handle invalid format or unsupported range in SDM.
- Remove FEATURE_WIDE_COLOR and enable by default.

Change-Id: If429e9fffdcdc59c18f1b5ef5d074efddd97f2af
Crs-fixed: 2215125
diff --git a/sdm/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp
index 216d1cd..e6eed76 100644
--- a/sdm/libs/core/comp_manager.cpp
+++ b/sdm/libs/core/comp_manager.cpp
@@ -25,6 +25,7 @@
 #include <utils/constants.h>
 #include <utils/debug.h>
 #include <core/buffer_allocator.h>
+#include <vector>
 
 #include "comp_manager.h"
 #include "strategy.h"
@@ -539,4 +540,14 @@
   return true;
 }
 
+DisplayError CompManager::SetColorModesInfo(Handle display_ctx,
+                                            const std::vector<PrimariesTransfer> &colormodes_cs) {
+  DisplayCompositionContext *display_comp_ctx =
+      reinterpret_cast<DisplayCompositionContext *>(display_ctx);
+
+  display_comp_ctx->strategy->SetColorModesInfo(colormodes_cs);
+
+  return kErrorNone;
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/comp_manager.h b/sdm/libs/core/comp_manager.h
index 7fe4482..eb2b470 100644
--- a/sdm/libs/core/comp_manager.h
+++ b/sdm/libs/core/comp_manager.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2018, 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 met:
@@ -29,6 +29,7 @@
 #include <private/extension_interface.h>
 #include <utils/locker.h>
 #include <bitset>
+#include <vector>
 
 #include "strategy.h"
 #include "resource_default.h"
@@ -73,6 +74,8 @@
   DisplayError SetCompositionState(Handle display_ctx, LayerComposition composition_type,
                                    bool enable);
   DisplayError ControlDpps(bool enable);
+  DisplayError SetColorModesInfo(Handle display_ctx,
+                                 const std::vector<PrimariesTransfer> &colormodes_cs);
 
  private:
   static const int kMaxThermalLevel = 3;
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index b60fcfa..2381322 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -43,6 +43,23 @@
 
 namespace sdm {
 
+static ColorPrimaries GetColorPrimariesFromAttribute(const std::string &gamut) {
+  if (gamut.find(kDisplayP3) != std::string::npos || gamut.find(kDcip3) != std::string::npos) {
+    return ColorPrimaries_DCIP3;
+  } else if (gamut.find(kHdr) != std::string::npos || gamut.find("bt2020") != std::string::npos ||
+             gamut.find("BT2020") != std::string::npos) {
+    // BT2020 is hdr, but the dynamicrange of kHdr means its BT2020
+    return ColorPrimaries_BT2020;
+  } else if (gamut.find(kSrgb) != std::string::npos) {
+    return ColorPrimaries_BT709_5;
+  } else if (gamut.find(kNative) != std::string::npos) {
+    DLOGW("Native Gamut found, returning default: sRGB");
+    return ColorPrimaries_BT709_5;
+  }
+
+  return ColorPrimaries_BT709_5;
+}
+
 // TODO(user): Have a single structure handle carries all the interface pointers and variables.
 DisplayBase::DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
                          HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler,
@@ -102,6 +119,13 @@
     goto CleanupOnError;
   }
 
+  if (color_modes_cs_.size() > 0) {
+    error = comp_manager_->SetColorModesInfo(display_comp_ctx_, color_modes_cs_);
+    if (error) {
+      DLOGW("SetColorModesInfo failed on display = %d", display_type_);
+    }
+  }
+
   if (hw_info_intf_) {
     HWResourceInfo hw_resource_info = HWResourceInfo();
     hw_info_intf_->GetHWResourceInfo(&hw_resource_info);
@@ -153,6 +177,9 @@
       break;
     }
     hw_layers_info.app_layer_count++;
+    if (!gpu_fallback_) {
+      gpu_fallback_ = NeedsGpuFallback(layer);
+    }
   }
 
   DLOGD_IF(kTagDisplay, "LayerStack layer_count: %d, app_layer_count: %d, gpu_target_index: %d, "
@@ -214,6 +241,7 @@
   lock_guard<recursive_mutex> obj(recursive_mutex_);
   DisplayError error = kErrorNone;
   needs_validate_ = true;
+  gpu_fallback_ = false;
 
   if (!active_) {
     return kErrorPermission;
@@ -399,7 +427,7 @@
   HWResourceInfo hw_resource_info = HWResourceInfo();
   hw_info_intf_->GetHWResourceInfo(&hw_resource_info);
   // hdr can be supported by display when target and panel supports HDR.
-  fixed_info->hdr_supported = (hw_resource_info.has_hdr && hw_panel_info_.hdr_enabled);
+  fixed_info->hdr_supported = (hw_resource_info.has_hdr);  // && hw_panel_info_.hdr_enabled);
   // Populate luminance values only if hdr will be supported on that display
   fixed_info->max_luminance = fixed_info->hdr_supported ? hw_panel_info_.peak_luminance: 0;
   fixed_info->average_luminance = fixed_info->hdr_supported ? hw_panel_info_.average_luminance : 0;
@@ -743,7 +771,9 @@
     return kErrorNotSupported;
   }
 
-  DLOGV_IF(kTagQDCM, "Number of modes from color manager = %d", num_color_modes_);
+  DLOGV_IF(kTagQDCM, "Display = %d Number of modes from color manager = %d", display_type_,
+           num_color_modes_);
+
   *mode_count = num_color_modes_;
 
   return kErrorNone;
@@ -981,6 +1011,12 @@
       DLOGE("failed to initial modes\n");
       return error;
     }
+    if (color_modes_cs_.size() > 0) {
+      error = comp_manager_->SetColorModesInfo(display_comp_ctx_, color_modes_cs_);
+      if (error) {
+        DLOGW("SetColorModesInfo failed on display = %d", display_type_);
+      }
+    }
   } else {
     return kErrorParameters;
   }
@@ -1440,8 +1476,21 @@
         if (it == color_mode_attr_map_.end()) {
           color_mode_attr_map_.insert(std::make_pair(color_modes_[i].name, var));
         }
+        std::vector<PrimariesTransfer> pt_list = {};
+        GetColorPrimaryTransferFromAttributes(var, &pt_list);
+        for (const PrimariesTransfer &pt : pt_list) {
+          if (std::find(color_modes_cs_.begin(), color_modes_cs_.end(), pt) ==
+              color_modes_cs_.end()) {
+            color_modes_cs_.push_back(pt);
+          }
+        }
       }
     }
+    PrimariesTransfer pt = {};
+    if (std::find(color_modes_cs_.begin(), color_modes_cs_.end(), pt) ==
+        color_modes_cs_.end()) {
+      color_modes_cs_.push_back(pt);
+    }
   }
 
   return kErrorNone;
@@ -1479,8 +1528,7 @@
 DisplayError DisplayBase::HandleHDR(LayerStack *layer_stack) {
   DisplayError error = kErrorNone;
 
-  if (display_type_ != kPrimary) {
-    // Handling is needed for only primary displays
+  if (!NeedsHdrHandling()) {
     return kErrorNone;
   }
 
@@ -1515,8 +1563,7 @@
 DisplayError DisplayBase::ValidateHDR(LayerStack *layer_stack) {
   DisplayError error = kErrorNone;
 
-  if (display_type_ != kPrimary) {
-    // Handling is needed for only primary displays
+  if (!NeedsHdrHandling()) {
     return kErrorNone;
   }
 
@@ -1643,6 +1690,7 @@
   color_modes_.clear();
   color_mode_map_.clear();
   color_mode_attr_map_.clear();
+  color_modes_cs_.clear();
 
   if (color_mgr_) {
     delete color_mgr_;
@@ -1656,4 +1704,56 @@
     color_mode_attr_map_.clear();
     num_color_modes_ = 0;
 }
+
+bool DisplayBase::NeedsGpuFallback(const Layer *layer) {
+  const LayerBufferFormat &format = layer->input_buffer.format;
+  const ColorRange &range = layer->input_buffer.color_metadata.range;
+
+  if (format == kFormatInvalid || range == Range_Extended) {
+    DLOGV_IF(kTagDisplay, "Format = %d Range = %d", format, range);
+    // when there is invalid format or extended range fall back to GPU
+    return true;
+  }
+
+  return false;
+}
+
+bool DisplayBase::NeedsHdrHandling() {
+  if (display_type_ != kPrimary || !num_color_modes_ || gpu_fallback_) {
+    // No HDR Handling for non-primary displays or when color modes are not present or
+    // if frame is falling back to GPU
+    return false;
+  }
+  return true;
+}
+
+void DisplayBase::GetColorPrimaryTransferFromAttributes(const AttrVal &attr,
+    std::vector<PrimariesTransfer> *supported_pt) {
+  std::string attribute_field = {};
+  if (attr.empty()) {
+    return;
+  }
+
+  for (auto &it : attr) {
+    if ((it.first.find(kColorGamutAttribute) != std::string::npos) ||
+        (it.first.find(kDynamicRangeAttribute) != std::string::npos)) {
+      attribute_field = it.second;
+      PrimariesTransfer pt = {};
+      pt.primaries = GetColorPrimariesFromAttribute(attribute_field);
+      if (pt.primaries == ColorPrimaries_BT709_5) {
+        pt.transfer = Transfer_sRGB;
+        supported_pt->push_back(pt);
+      } else if (pt.primaries == ColorPrimaries_DCIP3) {
+        pt.transfer = Transfer_Gamma2_2;
+        supported_pt->push_back(pt);
+      } else if (pt.primaries == ColorPrimaries_BT2020) {
+        pt.transfer = Transfer_SMPTE_ST2084;
+        supported_pt->push_back(pt);
+        pt.transfer = Transfer_HLG;
+        supported_pt->push_back(pt);
+      }
+    }
+  }
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index bd597c9..a46ed7a 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -119,6 +119,7 @@
                                               LayerBufferFormat format,
                                               const ColorMetaData &color_metadata);
   virtual std::string Dump();
+  virtual DisplayError InitializeColorModes();
 
  protected:
   DisplayError BuildLayerStackStats(LayerStack *layer_stack);
@@ -137,7 +138,6 @@
                                  uint32_t *new_mixer_height);
   DisplayError ReconfigureMixer(uint32_t width, uint32_t height);
   bool NeedsDownScale(const LayerRect &src_rect, const LayerRect &dst_rect, bool needs_rotation);
-  DisplayError InitializeColorModes();
   void DeInitializeColorModes();
   DisplayError SetColorModeInternal(const std::string &color_mode);
   DisplayError GetValueOfModeAttribute(const AttrVal &attr, const std::string &type,
@@ -147,6 +147,10 @@
   DisplayState GetLastPowerMode();
   void SetPUonDestScaler();
   void ClearColorInfo();
+  bool NeedsGpuFallback(const Layer *layer);
+  bool NeedsHdrHandling();
+  void GetColorPrimaryTransferFromAttributes(const AttrVal &attr,
+      std::vector<PrimariesTransfer> *supported_pt);
 
   recursive_mutex recursive_mutex_;
   DisplayType display_type_;
@@ -179,6 +183,7 @@
   ColorModeMap color_mode_map_ = {};
   typedef std::map<std::string, AttrVal> ColorModeAttrMap;
   ColorModeAttrMap color_mode_attr_map_ = {};
+  std::vector<PrimariesTransfer> color_modes_cs_ = {};  // Gamut+Gamma(color space) of color mode
   HWDisplayAttributes display_attributes_ = {};
   HWMixerAttributes mixer_attributes_ = {};
   DisplayConfigVariableInfo fb_config_ = {};
@@ -189,6 +194,7 @@
   bool hdr_mode_ = false;
   int disable_hdr_lut_gen_ = 0;
   DisplayState last_power_mode_ = kStateOff;
+  bool gpu_fallback_ = false;
 };
 
 }  // namespace sdm
diff --git a/sdm/libs/core/display_hdmi.cpp b/sdm/libs/core/display_hdmi.cpp
index 2076fe5..3582fa7 100644
--- a/sdm/libs/core/display_hdmi.cpp
+++ b/sdm/libs/core/display_hdmi.cpp
@@ -96,6 +96,8 @@
     DLOGE("Failed to create hardware events interface. Error = %d", error);
   }
 
+  InitializeColorModes();
+
   current_refresh_rate_ = hw_panel_info_.max_fps;
 
   return error;
@@ -306,5 +308,26 @@
   return kErrorNone;
 }
 
+DisplayError DisplayHDMI::InitializeColorModes() {
+  PrimariesTransfer pt = {};
+  color_modes_cs_.push_back(pt);
+
+  if (!hw_panel_info_.hdr_enabled) {
+    return kErrorNone;
+  }
+
+  pt.primaries = ColorPrimaries_BT2020;
+  if (hw_panel_info_.hdr_eotf & kHdrEOTFHDR10) {
+    pt.transfer = Transfer_SMPTE_ST2084;
+    color_modes_cs_.push_back(pt);
+  }
+  if (hw_panel_info_.hdr_eotf & kHdrEOTFHLG) {
+    pt.transfer = Transfer_HLG;
+    color_modes_cs_.push_back(pt);
+  }
+
+  return kErrorNone;
+}
+
 }  // namespace sdm
 
diff --git a/sdm/libs/core/display_hdmi.h b/sdm/libs/core/display_hdmi.h
index 64aa6c7..70bc145 100644
--- a/sdm/libs/core/display_hdmi.h
+++ b/sdm/libs/core/display_hdmi.h
@@ -46,6 +46,7 @@
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate);
   virtual bool IsUnderscanSupported();
   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level);
+  virtual DisplayError InitializeColorModes();
 
   // Implement the HWEventHandlers
   virtual DisplayError VSync(int64_t timestamp);
@@ -61,6 +62,7 @@
   uint32_t GetBestConfig(HWS3DMode s3d_mode);
   void GetScanSupport();
   void SetS3DMode(LayerStack *layer_stack);
+
   static const int kPropertyMax = 256;
 
   bool underscan_supported_ = false;
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
index d682070..dd32d58 100644
--- a/sdm/libs/core/strategy.cpp
+++ b/sdm/libs/core/strategy.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2018, 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 met:
@@ -24,6 +24,7 @@
 
 #include <utils/constants.h>
 #include <utils/debug.h>
+#include <vector>
 
 #include "strategy.h"
 #include "utils/rect.h"
@@ -247,4 +248,11 @@
   return kErrorNotSupported;
 }
 
+DisplayError Strategy::SetColorModesInfo(const std::vector<PrimariesTransfer> &colormodes_cs) {
+  if (strategy_intf_) {
+    return strategy_intf_->SetColorModesInfo(colormodes_cs);
+  }
+  return kErrorNotSupported;
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/strategy.h b/sdm/libs/core/strategy.h
index b75a3dd..b52b187 100644
--- a/sdm/libs/core/strategy.h
+++ b/sdm/libs/core/strategy.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2018, 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 met:
@@ -28,6 +28,7 @@
 #include <core/display_interface.h>
 #include <private/extension_interface.h>
 #include <core/buffer_allocator.h>
+#include <vector>
 
 namespace sdm {
 
@@ -53,6 +54,7 @@
   DisplayError SetCompositionState(LayerComposition composition_type, bool enable);
   DisplayError Purge();
   DisplayError SetIdleTimeoutMs(uint32_t active_ms);
+  DisplayError SetColorModesInfo(const std::vector<PrimariesTransfer> &colormodes_cs);
 
  private:
   void GenerateROI();
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index 483d7e7..26e4bae 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -46,9 +46,5 @@
                                  hwc_buffer_allocator.cpp \
                                  hwc_display_external_test.cpp
 
-ifeq ($(TARGET_HAS_WIDE_COLOR_DISPLAY), true)
-    LOCAL_CFLAGS += -DFEATURE_WIDE_COLOR
-endif
-
 include $(BUILD_SHARED_LIBRARY)
 endif
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 45a5c3d..efc44a2 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -50,24 +50,6 @@
 
 namespace sdm {
 
-// This weight function is needed because the color primaries are not sorted by gamut size
-static ColorPrimaries WidestPrimaries(ColorPrimaries p1, ColorPrimaries p2) {
-  int weight = 10;
-  int lp1 = p1, lp2 = p2;
-  // TODO(user) add weight to other wide gamut primaries
-  if (lp1 == ColorPrimaries_BT2020) {
-    lp1 *= weight;
-  }
-  if (lp1 == ColorPrimaries_BT2020) {
-    lp2 *= weight;
-  }
-  if (lp1 >= lp2) {
-    return p1;
-  } else {
-    return p2;
-  }
-}
-
 HWCColorMode::HWCColorMode(DisplayInterface *display_intf) : display_intf_(display_intf) {}
 
 HWC2::Error HWCColorMode::Init() {
@@ -493,15 +475,12 @@
   layer_stack_ = LayerStack();
   display_rect_ = LayerRect();
   metadata_refresh_rate_ = 0;
-  auto working_primaries = ColorPrimaries_BT709_5;
   bool secure_display_active = false;
   layer_stack_.flags.animating = animating_;
 
   uint32_t color_mode_count = 0;
   display_intf_->GetColorModeCount(&color_mode_count);
 
-  bool extended_range = false;
-
   // Add one layer for fb target
   // TODO(user): Add blit target layers
   for (auto hwc_layer : layer_set_) {
@@ -517,19 +496,9 @@
     }
 
     if (!hwc_layer->ValidateAndSetCSC()) {
-#ifdef FEATURE_WIDE_COLOR
       layer->flags.skip = true;
-#endif
     }
 
-    auto range = hwc_layer->GetLayerDataspace() & HAL_DATASPACE_RANGE_MASK;
-    if (range == HAL_DATASPACE_RANGE_EXTENDED) {
-      extended_range = true;
-    }
-
-    working_primaries = WidestPrimaries(working_primaries,
-                                        layer->input_buffer.color_metadata.colorPrimaries);
-
     // set default composition as GPU for SDM
     layer->composition = kCompositionGPU;
 
@@ -626,20 +595,6 @@
     layer_stack_.layers.push_back(layer);
   }
 
-
-#ifdef FEATURE_WIDE_COLOR
-  for (auto hwc_layer : layer_set_) {
-    auto layer = hwc_layer->GetSDMLayer();
-    if (layer->input_buffer.color_metadata.colorPrimaries != working_primaries &&
-        !hwc_layer->SupportLocalConversion(working_primaries)) {
-      layer->flags.skip = true;
-    }
-    if (layer->flags.skip) {
-      layer_stack_.flags.skip_present = true;
-    }
-  }
-#endif
-
   // TODO(user): Set correctly when SDM supports geometry_changes as bitmask
   layer_stack_.flags.geometry_changed = UINT32(geometry_changes_ > 0);
   // Append client target to the layer stack
@@ -649,7 +604,7 @@
   // fall back frame composition to GPU when client target is 10bit
   // TODO(user): clarify the behaviour from Client(SF) and SDM Extn -
   // when handling 10bit FBT, as it would affect blending
-  if (Is10BitFormat(sdm_client_target->input_buffer.format) || extended_range) {
+  if (Is10BitFormat(sdm_client_target->input_buffer.format)) {
     // Must fall back to client composition
     MarkLayersForClientComposition();
   }
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index 20978d0..a9be2bc 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -86,7 +86,7 @@
       *color_primary = ColorPrimaries_BT2020;
       break;
     default:
-      DLOGV_IF(kTagClient, "Unsupported Standard Request = %d", standard);
+      DLOGE("Unsupported Standard Request = %d", standard);
       supported_csc = false;
   }
   return supported_csc;
@@ -124,7 +124,7 @@
   return supported_transfer;
 }
 
-void GetRange(const int32_t &dataspace, ColorRange *color_range) {
+bool GetRange(const int32_t &dataspace, ColorRange *color_range) {
   auto range = dataspace & HAL_DATASPACE_RANGE_MASK;
   switch (range) {
     case HAL_DATASPACE_RANGE_FULL:
@@ -133,10 +133,14 @@
     case HAL_DATASPACE_RANGE_LIMITED:
       *color_range = Range_Limited;
       break;
-    default:
-      DLOGV_IF(kTagClient, "Unsupported Range Request = %d", range);
+    case HAL_DATASPACE_RANGE_EXTENDED:
+      *color_range = Range_Extended;
       break;
+    default:
+      DLOGE("Unsupported Range Request = %d", range);
+      return false;
   }
+  return true;
 }
 
 bool IsBT2020(const ColorPrimaries &color_primary) {
@@ -153,16 +157,14 @@
 bool GetSDMColorSpace(const int32_t &dataspace, ColorMetaData *color_metadata) {
   bool valid = false;
   valid = GetColorPrimary(dataspace, &(color_metadata->colorPrimaries));
-  if (!valid) {
-    return valid;
+  if (valid) {
+    valid = GetTransfer(dataspace, &(color_metadata->transfer));
   }
-  valid = GetTransfer(dataspace, &(color_metadata->transfer));
-  if (!valid) {
-    return valid;
+  if (valid) {
+    valid = GetRange(dataspace, &(color_metadata->range));
   }
-  GetRange(dataspace, &(color_metadata->range));
 
-  return true;
+  return valid;
 }
 
 // Layer operations
@@ -799,16 +801,6 @@
   return kErrorNone;
 }
 
-
-
-bool HWCLayer::SupportLocalConversion(ColorPrimaries working_primaries) {
-  if (layer_->input_buffer.color_metadata.colorPrimaries <= ColorPrimaries_BT601_6_525 &&
-      working_primaries <= ColorPrimaries_BT601_6_525) {
-    return true;
-  }
-  return false;
-}
-
 bool HWCLayer::ValidateAndSetCSC() {
   if (client_requested_ != HWC2::Composition::Device &&
       client_requested_ != HWC2::Composition::Cursor) {
@@ -818,7 +810,6 @@
 
   LayerBuffer *layer_buffer = &layer_->input_buffer;
   bool use_color_metadata = true;
-#ifdef FEATURE_WIDE_COLOR
   ColorMetaData csc = {};
   if (dataspace_ != HAL_DATASPACE_UNKNOWN) {
     use_color_metadata = false;
@@ -831,7 +822,6 @@
     layer_buffer->color_metadata.colorPrimaries = csc.colorPrimaries;
     layer_buffer->color_metadata.range = csc.range;
   }
-#endif
 
   if (IsBT2020(layer_buffer->color_metadata.colorPrimaries)) {
      // android_dataspace_t doesnt support mastering display and light levels
diff --git a/sdm/libs/hwc2/hwc_layers.h b/sdm/libs/hwc2/hwc_layers.h
index 2a4d4b4..7d978c8 100644
--- a/sdm/libs/hwc2/hwc_layers.h
+++ b/sdm/libs/hwc2/hwc_layers.h
@@ -42,7 +42,7 @@
 DisplayError SetCSC(const private_handle_t *pvt_handle, ColorMetaData *color_metadata);
 bool GetColorPrimary(const int32_t &dataspace, ColorPrimaries *color_primary);
 bool GetTransfer(const int32_t &dataspace, GammaTransfer *gamma_transfer);
-void GetRange(const int32_t &dataspace, ColorRange *color_range);
+bool GetRange(const int32_t &dataspace, ColorRange *color_range);
 bool GetSDMColorSpace(const int32_t &dataspace, ColorMetaData *color_metadata);
 bool IsBT2020(const ColorPrimaries &color_primary);
 enum GeometryChanges {
@@ -92,7 +92,6 @@
   int32_t PopBackReleaseFence(void);
   int32_t PopFrontReleaseFence(void);
   bool ValidateAndSetCSC();
-  bool SupportLocalConversion(ColorPrimaries working_primaries);
   void ResetValidation() { needs_validate_ = false; }
   bool NeedsValidation() { return (needs_validate_ || geometry_changes_); }
   bool IsSingleBuffered() { return single_buffer_; }