Enable color temperature developer setting
Add a switch in Developer Settings to enable "cool" color temperature
mode.
Bug: 26110238
Change-Id: I669ae4ddf58d6654b154692afc7d0689227617b2
diff --git a/msm8994/libhwcomposer/hwc.cpp b/msm8994/libhwcomposer/hwc.cpp
index fc0842b..1e5a8a4 100644
--- a/msm8994/libhwcomposer/hwc.cpp
+++ b/msm8994/libhwcomposer/hwc.cpp
@@ -249,6 +249,34 @@
}
}
+static void hwc_configure_color_temp(hwc_composer_device_1* dev) {
+ hwc_context_t* ctx = (hwc_context_t*)(dev);
+ char value[PROPERTY_VALUE_MAX];
+ bool cool;
+
+ property_get("persist.sys.debug.color_temp", value, "x");
+ cool = (value[0] == '1');
+
+ if ((value[0] == '0' || value[0] == '1') &&
+ cool != ctx->mCoolColorTemperatureEnabled) {
+ ctx->mCoolColorTemperatureEnabled = cool;
+
+ ALOGI("Color temperature change. Cool = %d", cool ? 1 : 0);
+
+ int fd = open("/sys/class/graphics/fb0/color_temp", O_WRONLY);
+ if (fd >= 0) {
+ if (cool)
+ write(fd, "1", 2);
+ else
+ write(fd, "0", 2);
+ close(fd);
+ } else {
+ ALOGE("Failed to open color_temp file with result=%d", fd);
+ }
+ }
+}
+
+
static int hwc_prepare_primary(hwc_composer_device_1 *dev,
hwc_display_contents_1_t *list) {
ATRACE_CALL();
@@ -515,6 +543,9 @@
return -EINVAL;
}
+ // Configure the color temperature
+ hwc_configure_color_temp(dev);
+
ALOGD_IF(POWER_MODE_DEBUG, "%s: Done setting mode %d on display %d",
__FUNCTION__, mode, dpy);
return ret;
diff --git a/msm8994/libhwcomposer/hwc_utils.cpp b/msm8994/libhwcomposer/hwc_utils.cpp
index 98c4166..3234d65 100644
--- a/msm8994/libhwcomposer/hwc_utils.cpp
+++ b/msm8994/libhwcomposer/hwc_utils.cpp
@@ -393,6 +393,8 @@
// Initializing boot anim completed check to false
ctx->mDefaultModeApplied = false;
+ ctx->mCoolColorTemperatureEnabled = false;
+
// Initialize gpu perfomance hint related parameters
property_get("sys.hwc.gpu_perf_mode", value, "0");
#ifdef QCOM_BSP
diff --git a/msm8994/libhwcomposer/hwc_utils.h b/msm8994/libhwcomposer/hwc_utils.h
index c9f35e5..2e4b3f4 100644
--- a/msm8994/libhwcomposer/hwc_utils.h
+++ b/msm8994/libhwcomposer/hwc_utils.h
@@ -683,6 +683,8 @@
bool mDefaultModeApplied;
//Manages color modes
qhwc::ColorMode *mColorMode;
+ // Indicates whether cool color temperature is enabled.
+ bool mCoolColorTemperatureEnabled;
};
namespace qhwc {