summaryrefslogtreecommitdiffstats
path: root/charger
diff options
context:
space:
mode:
authorAdrian DC <radian.dc@gmail.com>2016-08-14 11:44:31 +0200
committerSteve Kondik <shade@chemlab.org>2016-08-14 21:53:37 -0700
commitcadd0be0896dcf4af2b263350261cfa9dc98c7da (patch)
treeb5260e2c989393bb16b09954e5b3dfb0a616cf34 /charger
parent75956207503ca4f5023c1d2b587594c517e7e28f (diff)
downloadvendor_replicant-cadd0be0896dcf4af2b263350261cfa9dc98c7da.zip
vendor_replicant-cadd0be0896dcf4af2b263350261cfa9dc98c7da.tar.gz
vendor_replicant-cadd0be0896dcf4af2b263350261cfa9dc98c7da.tar.bz2
cm: charger: Add support for double backlight displays
* Some devices using AMS AS36xx LEDs controllers are using 2 backlight paths to light the display, mostly on Sony Huashan and Sony Blue board devices * Although most of the displays have interlaced backlights and the half dark path can be hard to see, other displays have a top / bottom path that make half the screen on / off * Control the backlight level of both path if the device does have BACKLIGHT_PATH set, and if present, SECONDARY_BACKLIGHT_PATH * Leave the HEALTD_BACKLIGHT_LEVEL config accessible to override the default 100 / 255 brightness used in healthd Change-Id: If774c3e66acedddf7ba676581e7c88b7e83a66b6 Signed-off-by: Adrian DC <radian.dc@gmail.com>
Diffstat (limited to 'charger')
-rw-r--r--charger/Android.mk9
-rw-r--r--charger/healthd_board_cm.cpp40
2 files changed, 49 insertions, 0 deletions
diff --git a/charger/Android.mk b/charger/Android.mk
index 0f5e55f..0492ad9 100644
--- a/charger/Android.mk
+++ b/charger/Android.mk
@@ -7,6 +7,15 @@ LOCAL_CFLAGS := -Werror
LOCAL_C_INCLUDES := \
system/core/healthd \
bootable/recovery
+ifneq ($(BACKLIGHT_PATH),)
+ LOCAL_CFLAGS += -DHEALTHD_BACKLIGHT_PATH=\"$(BACKLIGHT_PATH)\"
+endif
+ifneq ($(SECONDARY_BACKLIGHT_PATH),)
+ LOCAL_CFLAGS += -DHEALTHD_SECONDARY_BACKLIGHT_PATH=\"$(SECONDARY_BACKLIGHT_PATH)\"
+endif
+ifneq ($(HEALTHD_BACKLIGHT_LEVEL),)
+ LOCAL_CFLAGS += -DHEALTHD_BACKLIGHT_LEVEL=$(HEALTHD_BACKLIGHT_LEVEL)
+endif
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
diff --git a/charger/healthd_board_cm.cpp b/charger/healthd_board_cm.cpp
index c5aa3e6..8d38e5a 100644
--- a/charger/healthd_board_cm.cpp
+++ b/charger/healthd_board_cm.cpp
@@ -365,9 +365,49 @@ void healthd_board_mode_charger_battery_update(
{
}
+#ifdef HEALTHD_BACKLIGHT_PATH
+#ifndef HEALTHD_BACKLIGHT_LEVEL
+#define HEALTHD_BACKLIGHT_LEVEL 100
+#endif
+
+void healthd_board_mode_charger_set_backlight(bool on)
+{
+ int fd;
+ char buffer[10];
+
+ memset(buffer, '\0', sizeof(buffer));
+ fd = open(HEALTHD_BACKLIGHT_PATH, O_RDWR);
+ if (fd < 0) {
+ LOGE("Could not open backlight node : %s\n", strerror(errno));
+ return;
+ }
+ LOGV("Enabling backlight\n");
+ snprintf(buffer, sizeof(buffer), "%d\n", on ? HEALTHD_BACKLIGHT_LEVEL : 0);
+ if (write(fd, buffer, strlen(buffer)) < 0) {
+ LOGE("Could not write to backlight : %s\n", strerror(errno));
+ }
+ close(fd);
+
+#ifdef HEALTHD_SECONDARY_BACKLIGHT_PATH
+ fd = open(HEALTHD_SECONDARY_BACKLIGHT_PATH, O_RDWR);
+ if (fd < 0) {
+ LOGE("Could not open second backlight node : %s\n", strerror(errno));
+ return;
+ }
+ LOGV("Enabling secondary backlight\n");
+ if (write(fd, buffer, strlen(buffer)) < 0) {
+ LOGE("Could not write to second backlight : %s\n", strerror(errno));
+ return;
+ }
+ close(fd);
+#endif
+}
+
+#else
void healthd_board_mode_charger_set_backlight(bool)
{
}
+#endif
void healthd_board_mode_charger_init(void)
{