Merge "hwc2: Add HLG cap in the HDR capabilities"
diff --git a/liblight/Android.mk b/liblight/Android.mk
index cf53b2c..5720bba 100644
--- a/liblight/Android.mk
+++ b/liblight/Android.mk
@@ -17,12 +17,9 @@
 # hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
 include $(CLEAR_VARS)
 
-LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc
-LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/qdcm/inc
-
-LOCAL_SRC_FILES := lights.c lights_prv.cpp
+LOCAL_SRC_FILES := lights.c
 LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils libsdm-disp-vndapis
+LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_CFLAGS := -DLOG_TAG=\"qdlights\"
 ifeq ($(LLVM_SA), true)
diff --git a/liblight/lights.c b/liblight/lights.c
index d511395..e83be16 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014, 2017 The  Linux Foundation. All rights reserved.
+ * Copyright (C) 2014, 2017-2018 The  Linux Foundation. All rights reserved.
  * Not a contribution
  * Copyright (C) 2008 The Android Open Source Project
  *
@@ -33,7 +33,6 @@
 #include <sys/types.h>
 
 #include <hardware/lights.h>
-#include "lights_prv.h"
 
 #ifndef DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS
 #define DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS 0x80
@@ -47,7 +46,6 @@
 static struct light_state_t g_battery;
 static int g_last_backlight_mode = BRIGHTNESS_MODE_USER;
 static int g_attention = 0;
-static int g_brightness_max = 0;
 static bool g_has_persistence_node = false;
 
 char const*const RED_LED_FILE
@@ -170,28 +168,6 @@
 }
 
 static int
-set_light_backlight_ext(struct light_device_t* dev,
-        struct light_state_t const* state)
-{
-    int err = 0;
-
-    if(!dev) {
-        return -1;
-    }
-
-    int brightness = state->color & 0x00ffffff;
-    pthread_mutex_lock(&g_lock);
-
-    if (brightness >= 0 && brightness <= g_brightness_max) {
-        set_brightness_ext_level(brightness);
-    }
-
-    pthread_mutex_unlock(&g_lock);
-
-    return err;
-}
-
-static int
 set_speaker_light_locked(struct light_device_t* dev,
         struct light_state_t const* state)
 {
@@ -246,15 +222,15 @@
         if (red) {
             if (write_int(RED_BLINK_FILE, blink))
                 write_int(RED_LED_FILE, 0);
-    }
+        }
         if (green) {
             if (write_int(GREEN_BLINK_FILE, blink))
                 write_int(GREEN_LED_FILE, 0);
-    }
+        }
         if (blue) {
             if (write_int(BLUE_BLINK_FILE, blink))
                 write_int(BLUE_LED_FILE, 0);
-    }
+        }
     } else {
         write_int(RED_LED_FILE, red);
         write_int(GREEN_LED_FILE, green);
@@ -350,19 +326,8 @@
             struct light_state_t const* state);
 
     if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
-        char property[PROPERTY_VALUE_MAX];
-        property_get("persist.extend.brightness", property, "0");
-
-        if(!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
-           !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
-            property_get("persist.display.max_brightness", property, "255");
-            g_brightness_max = atoi(property);
-            set_brightness_ext_init();
-            set_light = set_light_backlight_ext;
-        } else {
-            g_has_persistence_node = !access(PERSISTENCE_FILE, F_OK);
-            set_light = set_light_backlight;
-        }
+        g_has_persistence_node = !access(PERSISTENCE_FILE, F_OK);
+        set_light = set_light_backlight;
     } else if (0 == strcmp(LIGHT_ID_BATTERY, name))
         set_light = set_light_battery;
     else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
diff --git a/liblight/lights_prv.cpp b/liblight/lights_prv.cpp
deleted file mode 100644
index f916ed2..0000000
--- a/liblight/lights_prv.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 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
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-
-#include <hardware/hwcomposer_defs.h>
-#include "disp_color_apis.h"
-#include "lights_prv.h"
-
-/******************************************************************************/
-static DISPAPI_HANDLE g_ctx;
-
-/**
- * device methods
- */
-
-void set_brightness_ext_init(void)
-{
-   disp_api_init((DISPAPI_HANDLE*) &g_ctx, 0);
-}
-
-int set_brightness_ext_level(int level)
-{
-    int err = disp_api_set_panel_brightness_level_ext(g_ctx, HWC_DISPLAY_PRIMARY,
-                                                 level, 0);
-
-    return err;
-}
diff --git a/liblight/lights_prv.h b/liblight/lights_prv.h
deleted file mode 100644
index e0ec736..0000000
--- a/liblight/lights_prv.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 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
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIGHTS_PRV_H
-#define LIGHTS_PRV_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void set_brightness_ext_init(void);
-extern int set_brightness_ext_level(int level);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/sdm/include/core/display_interface.h b/sdm/include/core/display_interface.h
index 1f813ac..8156ca4 100644
--- a/sdm/include/core/display_interface.h
+++ b/sdm/include/core/display_interface.h
@@ -491,14 +491,6 @@
   */
   virtual DisplayError SetPanelBrightness(int level) = 0;
 
-  /*! @brief Method to cache brightness of the primary display.
-
-    @param[in] level the new backlight level.
-
-    @return \link DisplayError \endlink
-  */
-  virtual DisplayError CachePanelBrightness(int level) = 0;
-
   /*! @brief Method to notify display about change in min HDCP encryption level.
 
     @param[in] min_enc_level minimum encryption level value.
diff --git a/sdm/include/private/color_params.h b/sdm/include/private/color_params.h
index 12e41fd..b71266c 100644
--- a/sdm/include/private/color_params.h
+++ b/sdm/include/private/color_params.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
@@ -54,7 +54,6 @@
   kEnableFrameCapture = BITMAP(6),
   kDisableFrameCapture = BITMAP(7),
   kConfigureDetailedEnhancer = BITMAP(8),
-  kInvalidatingAndkSetPanelBrightness = BITMAP(9),
   kModeSet = BITMAP(10),
   kGetDetailedEnhancerData = BITMAP(21),
   kNoAction = BITMAP(31),
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index 66f3707..9252c00 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -83,9 +83,6 @@
   virtual DisplayError SetPanelBrightness(int level) {
     return kErrorNotSupported;
   }
-  virtual DisplayError CachePanelBrightness(int level) {
-    return kErrorNotSupported;
-  }
   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) {
     return kErrorNotSupported;
   }
diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
index 718dd1e..ba83d05 100644
--- a/sdm/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -240,11 +240,6 @@
   return hw_intf_->SetPanelBrightness(level);
 }
 
-DisplayError DisplayPrimary::CachePanelBrightness(int level) {
-  lock_guard<recursive_mutex> obj(recursive_mutex_);
-  return hw_intf_->CachePanelBrightness(level);
-}
-
 DisplayError DisplayPrimary::GetRefreshRateRange(uint32_t *min_refresh_rate,
                                                  uint32_t *max_refresh_rate) {
   lock_guard<recursive_mutex> obj(recursive_mutex_);
diff --git a/sdm/libs/core/display_primary.h b/sdm/libs/core/display_primary.h
index 21ada7c..a5a3ae0 100644
--- a/sdm/libs/core/display_primary.h
+++ b/sdm/libs/core/display_primary.h
@@ -51,7 +51,6 @@
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate);
   virtual DisplayError SetPanelBrightness(int level);
   virtual DisplayError GetPanelBrightness(int *level);
-  virtual DisplayError CachePanelBrightness(int level);
 
   // Implement the HWEventHandlers
   virtual DisplayError VSync(int64_t timestamp);
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index d28d911..14d0064 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -1390,10 +1390,6 @@
   return err;
 }
 
-DisplayError HWDeviceDRM::CachePanelBrightness(int level) {
-  return kErrorNotSupported;
-}
-
 DisplayError HWDeviceDRM::GetHWScanInfo(HWScanInfo *scan_info) {
   return kErrorNotSupported;
 }
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index a0f579d..d2fa276 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -83,7 +83,6 @@
   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
   virtual DisplayError SetPanelBrightness(int level);
-  virtual DisplayError CachePanelBrightness(int level);
   virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info);
   virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format);
   virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format);
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index 1f733a0..148f866 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -496,12 +496,6 @@
   if (synchronous_commit_) {
     mdp_commit.flags |= MDP_COMMIT_WAIT_FOR_FINISH;
   }
-  if (bl_update_commit && bl_level_update_commit >= 0) {
-#ifdef MDP_COMMIT_UPDATE_BRIGHTNESS
-    mdp_commit.bl_level = (uint32_t)bl_level_update_commit;
-    mdp_commit.flags |= MDP_COMMIT_UPDATE_BRIGHTNESS;
-#endif
-  }
   if (Sys::ioctl_(device_fd_, INT(MSMFB_ATOMIC_COMMIT), &mdp_disp_commit_) < 0) {
     if (errno == ESHUTDOWN) {
       DLOGI_IF(kTagDriverConfig, "Driver is processing shutdown sequence");
@@ -556,9 +550,6 @@
     synchronous_commit_ = false;
   }
 
-  if (bl_update_commit)
-    bl_update_commit = false;
-
   return kErrorNone;
 }
 
@@ -1202,10 +1193,6 @@
   return kErrorNotSupported;
 }
 
-DisplayError HWDevice::CachePanelBrightness(int level) {
-  return kErrorNotSupported;
-}
-
 DisplayError HWDevice::GetHWScanInfo(HWScanInfo *scan_info) {
   return kErrorNotSupported;
 }
diff --git a/sdm/libs/core/fb/hw_device.h b/sdm/libs/core/fb/hw_device.h
index 353cce5..fe954ae 100644
--- a/sdm/libs/core/fb/hw_device.h
+++ b/sdm/libs/core/fb/hw_device.h
@@ -85,7 +85,6 @@
   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
   virtual DisplayError SetPanelBrightness(int level);
-  virtual DisplayError CachePanelBrightness(int level);
   virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info);
   virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format);
   virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format);
@@ -158,8 +157,6 @@
   HWDisplayAttributes display_attributes_ = {};
   HWMixerAttributes mixer_attributes_ = {};
   std::vector<mdp_destination_scaler_data> mdp_dest_scalar_data_;
-  int bl_level_update_commit = -1;
-  bool bl_update_commit = false;
 };
 
 }  // namespace sdm
diff --git a/sdm/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp
index 3f3c28e..4c72402 100644
--- a/sdm/libs/core/fb/hw_primary.cpp
+++ b/sdm/libs/core/fb/hw_primary.cpp
@@ -570,12 +570,6 @@
   return kErrorNone;
 }
 
-DisplayError HWPrimary::CachePanelBrightness(int level) {
-  bl_level_update_commit = level;
-  bl_update_commit = true;
-  return kErrorNone;
-}
-
 DisplayError HWPrimary::SetAutoRefresh(bool enable) {
   const int kWriteLength = 2;
   char buffer[kWriteLength] = {'\0'};
diff --git a/sdm/libs/core/fb/hw_primary.h b/sdm/libs/core/fb/hw_primary.h
index c6ca5a9..b385109 100644
--- a/sdm/libs/core/fb/hw_primary.h
+++ b/sdm/libs/core/fb/hw_primary.h
@@ -55,7 +55,6 @@
   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
   virtual DisplayError SetPanelBrightness(int level);
-  virtual DisplayError CachePanelBrightness(int level);
   virtual DisplayError GetPPFeaturesVersion(PPFeatureVersion *vers);
   virtual DisplayError SetPPFeatures(PPFeaturesConfig *feature_list);
   virtual DisplayError GetPanelBrightness(int *level);
diff --git a/sdm/libs/core/hw_interface.h b/sdm/libs/core/hw_interface.h
index 483a4df..cdb7cba 100644
--- a/sdm/libs/core/hw_interface.h
+++ b/sdm/libs/core/hw_interface.h
@@ -100,7 +100,6 @@
   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode) = 0;
   virtual DisplayError SetRefreshRate(uint32_t refresh_rate) = 0;
   virtual DisplayError SetPanelBrightness(int level) = 0;
-  virtual DisplayError CachePanelBrightness(int level) = 0;
   virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info) = 0;
   virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format) = 0;
   virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format) = 0;