minui: Allow devices to blank/unblank using LCD backlight
* Some devices rely on the LCD backlight to blank/unblank the display,
support them by allowing a custom LCD backlight path to be used.
Change-Id: I8406b4b55cd7a2afc4f8f8ba65de2c53b949489d
diff --git a/minui/Android.mk b/minui/Android.mk
index 9bda6dd..d889587 100644
--- a/minui/Android.mk
+++ b/minui/Android.mk
@@ -31,4 +31,8 @@
LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
endif
+ifneq ($(TARGET_RECOVERY_LCD_BACKLIGHT_PATH),)
+ LOCAL_CFLAGS += -DRECOVERY_LCD_BACKLIGHT_PATH=$(TARGET_RECOVERY_LCD_BACKLIGHT_PATH)
+endif
+
include $(BUILD_STATIC_LIBRARY)
diff --git a/minui/graphics.c b/minui/graphics.c
index 8998d9f..ff39674 100644
--- a/minui/graphics.c
+++ b/minui/graphics.c
@@ -437,9 +437,21 @@
void gr_fb_blank(bool blank)
{
+#ifdef RECOVERY_LCD_BACKLIGHT_PATH
+ int fd;
+
+ fd = open(RECOVERY_LCD_BACKLIGHT_PATH, O_RDWR);
+ if (fd < 0) {
+ perror("cannot open LCD backlight");
+ return;
+ }
+ write(fd, blank ? "000" : "127", 3);
+ close(fd);
+#else
int ret;
ret = ioctl(gr_fb_fd, FBIOBLANK, blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
if (ret < 0)
perror("ioctl(): blank");
+#endif
}