Merge "sdm: Set connector mode on power off"
diff --git a/config/sdm845.mk b/config/sdm845.mk
index 34f6fdf..b7be15b 100644
--- a/config/sdm845.mk
+++ b/config/sdm845.mk
@@ -31,14 +31,9 @@
 TARGET_USES_DRM_PP := true
 
 PRODUCT_PROPERTY_OVERRIDES += \
-    debug.mdpcomp.logs=0 \
-    debug.sf.enable_hwc_vds=0 \
+    debug.sf.enable_hwc_vds=1 \
     persist.demo.hdmirotationlock=false \
     ro.vendor.display.cabl=2 \
-    vendor.gralloc.disable_ubwc=0 \
-    vendor.display.disable_scaler=0 \
-    vendor.display.disable_secure_inline_rotator=1 \
-    vendor.display.prefer_source_split=1 \
     debug.sf.hw=0 \
     debug.egl.hw=0 \
     debug.sf.latch_unsignaled=1
diff --git a/include/display_properties.h b/include/display_properties.h
index 7295899..df29eb0 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -88,12 +88,13 @@
 
 #define DISABLE_HDR_LUT_GEN                  DISPLAY_PROP("disable_hdr_lut_gen")
 #define ENABLE_DEFAULT_COLOR_MODE            DISPLAY_PROP("enable_default_color_mode")
-#define DISABLE_HDR                          DISPLAY_PROP("disable_hdr")
+#define DISABLE_HDR                          DISPLAY_PROP("hwc_disable_hdr")
 
 #define HDR_CONFIG_PROP                      RO_DISPLAY_PROP("hdr.config")
 #define QDCM_PCC_TRANS_PROP                  DISPLAY_PROP("qdcm.pcc_for_trans")
 #define QDCM_DIAGONAL_MATRIXMODE_PROP        DISPLAY_PROP("qdcm.diagonal_matrix_mode")
 #define QDCM_DISABLE_TIMEOUT_PROP            PERSIST_DISPLAY_PROP("qdcm.disable_timeout")
 
+#define ZERO_SWAP_INTERVAL                   "vendor.debug.egl.swapinterval"
 
 #endif  // __DISPLAY_PROPERTIES_H__
diff --git a/libdebug/Android.mk b/libdebug/Android.mk
index 3e7ce25..e975a22 100644
--- a/libdebug/Android.mk
+++ b/libdebug/Android.mk
@@ -4,11 +4,9 @@
 LOCAL_MODULE                  := libdisplaydebug
 LOCAL_VENDOR_MODULE           := true
 LOCAL_MODULE_TAGS             := optional
-LOCAL_C_INCLUDES              := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
 LOCAL_SHARED_LIBRARIES        := libdl
 LOCAL_CFLAGS                  := -DLOG_TAG=\"SDM\" -Wall -std=c++11 -Werror -fno-operator-names
 LOCAL_CLANG                   := true
-LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_SRC_FILES               := debug_handler.cpp
 LOCAL_COPY_HEADERS_TO         := qcom/display
 LOCAL_COPY_HEADERS            := debug_handler.h
diff --git a/libdebug/debug_handler.h b/libdebug/debug_handler.h
index 0ae5c28..81795e4 100644
--- a/libdebug/debug_handler.h
+++ b/libdebug/debug_handler.h
@@ -47,9 +47,9 @@
 #define DLOGV_IF(tag, format, ...) DLOG_IF(tag, Verbose, format, ##__VA_ARGS__)
 
 #define DLOGE(format, ...) DLOG(Error, format, ##__VA_ARGS__)
-#define DLOGD(format, ...) DLOG(Warning, format, ##__VA_ARGS__)
-#define DLOGW(format, ...) DLOG(Info, format, ##__VA_ARGS__)
-#define DLOGI(format, ...) DLOG(Debug, format, ##__VA_ARGS__)
+#define DLOGW(format, ...) DLOG(Warning, format, ##__VA_ARGS__)
+#define DLOGI(format, ...) DLOG(Info, format, ##__VA_ARGS__)
+#define DLOGD(format, ...) DLOG(Debug, format, ##__VA_ARGS__)
 #define DLOGV(format, ...) DLOG(Verbose, format, ##__VA_ARGS__)
 
 #define DTRACE_BEGIN(custom_string) display::DebugHandler::Get()->BeginTrace( \
diff --git a/sdm/include/private/color_interface.h b/sdm/include/private/color_interface.h
index 884df5e..9802e1d 100644
--- a/sdm/include/private/color_interface.h
+++ b/sdm/include/private/color_interface.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2015-2018, The Linux Foundataion. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -30,6 +30,7 @@
 #ifndef __COLOR_INTERFACE_H__
 #define __COLOR_INTERFACE_H__
 
+#include <string>
 #include "core/sdm_types.h"
 #include "color_params.h"
 
@@ -93,6 +94,8 @@
                                             AttrVal *query) = 0;
   virtual DisplayError ColorIntfGetDefaultModeID(PPFeaturesConfig *out_features,
                                                  uint32_t disp_id, int32_t *mode_id) = 0;
+  virtual DisplayError ColorIntfGetActiveMode(PPFeaturesConfig *out_features,
+                                              int32_t disp_id, std::string *mode) = 0;
 
  protected:
   virtual ~ColorInterface() {}
diff --git a/sdm/libs/core/color_manager.cpp b/sdm/libs/core/color_manager.cpp
index 4c33a25..f348eca 100644
--- a/sdm/libs/core/color_manager.cpp
+++ b/sdm/libs/core/color_manager.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015 - 2017, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2015 - 2018, The Linux Foundataion. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -31,6 +31,7 @@
 #include <private/color_interface.h>
 #include <utils/constants.h>
 #include <utils/debug.h>
+#include <string>
 #include "color_manager.h"
 
 #define __CLASS__ "ColorManager"
@@ -246,4 +247,8 @@
   return color_intf_->ColorIntfGetDefaultModeID(&pp_features_, 0, mode_id);
 }
 
+DisplayError ColorManagerProxy::ColorMgrGetActiveMode(std::string *mode) {
+  return color_intf_->ColorIntfGetActiveMode(&pp_features_, 0, mode);
+}
+
 }  // namespace sdm
diff --git a/sdm/libs/core/color_manager.h b/sdm/libs/core/color_manager.h
index db050af..d29422e 100644
--- a/sdm/libs/core/color_manager.h
+++ b/sdm/libs/core/color_manager.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2015-2018, The Linux Foundataion. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -36,6 +36,7 @@
 #include <private/color_interface.h>
 #include <utils/sys.h>
 #include <utils/debug.h>
+#include <string>
 #include "hw_interface.h"
 
 namespace sdm {
@@ -72,6 +73,7 @@
   DisplayError ColorMgrGetModeInfo(int32_t mode_id, AttrVal *query);
   DisplayError ColorMgrSetColorTransform(uint32_t length, const double *trans_data);
   DisplayError ColorMgrGetDefaultModeID(int32_t *mode_id);
+  DisplayError ColorMgrGetActiveMode(std::string *mode);
   bool NeedsPartialUpdateDisable();
   DisplayError Commit();
 
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 0a7ee35..5ae6c18 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -401,8 +401,14 @@
 
   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);
+  bool hdr_supported = hw_resource_info.has_hdr;
+  HWDisplayInterfaceInfo hw_disp_info = {};
+  hw_info_intf_->GetFirstDisplayInterfaceType(&hw_disp_info);
+  if (hw_disp_info.type == kHDMI) {
+    hdr_supported = (hdr_supported && hw_panel_info_.hdr_enabled);
+  }
+
+  fixed_info->hdr_supported = hdr_supported;
   // 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;
@@ -1470,6 +1476,10 @@
     // Do not apply HDR Mode when hdr lut generation is disabled
     if (set) {
       color_mode = "hal_hdr";
+      error = color_mgr_->ColorMgrGetActiveMode(&current_color_mode_);
+      if (error != kErrorNone) {
+        DLOGW("Failed to get active color mode");
+      }
       if (IsSupportColorModeAttribute(current_color_mode_)) {
         bool found_hdr = false;
         error = GetHdrColorMode(&color_mode, &found_hdr);
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index a744df6..dd049de 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -370,7 +370,7 @@
   }
 
   int property_swap_interval = 1;
-  HWCDebugHandler::Get()->GetProperty("debug.egl.swapinterval", &property_swap_interval);
+  HWCDebugHandler::Get()->GetProperty(ZERO_SWAP_INTERVAL, &property_swap_interval);
   if (property_swap_interval == 0) {
     swap_interval_zero_ = true;
   }