summaryrefslogtreecommitdiffstats
path: root/liblight
diff options
context:
space:
mode:
authorAraemo <araemo@gmail.com>2013-02-13 21:32:49 -0500
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-07-12 06:15:25 -0700
commit889f4e58cb47a94671aa162a6fe252f9ee44b24a (patch)
tree889d218035a1ab7b8acfc9ba3959c84f629908da /liblight
parent82593a44157ded87f7f31c20d82abb9eb682598f (diff)
downloaddevice_samsung_aries-common-889f4e58cb47a94671aa162a6fe252f9ee44b24a.zip
device_samsung_aries-common-889f4e58cb47a94671aa162a6fe252f9ee44b24a.tar.gz
device_samsung_aries-common-889f4e58cb47a94671aa162a6fe252f9ee44b24a.tar.bz2
Enhance liblights to support touchkey backlight
Adds the necessary function to control capacitive key backlight from userspace Set BOARD_BUTTON_LIGHTS_PATH in BoardConfig to the relevant device node path to enable this Used by Infuse4g at least - May be applicable to other devices? (epicmtd has a similar function in their liblights) Change-Id: I2bebd6a8b2dc7624c42c78e9862246f10725a000
Diffstat (limited to 'liblight')
-rw-r--r--liblight/Android.mk4
-rw-r--r--liblight/lights.c22
2 files changed, 26 insertions, 0 deletions
diff --git a/liblight/Android.mk b/liblight/Android.mk
index 9933c34..8c4ae27 100644
--- a/liblight/Android.mk
+++ b/liblight/Android.mk
@@ -28,5 +28,9 @@ LOCAL_MODULE := lights.aries
LOCAL_MODULE_TAGS := optional
+ifdef BOARD_BUTTON_LIGHTS_PATH
+ LOCAL_CFLAGS += -DBUTTONS_FILE=\"$(BOARD_BUTTON_LIGHTS_PATH)\"
+endif
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/liblight/lights.c b/liblight/lights.c
index 86feb9d..47bd5ce 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -98,6 +98,24 @@ static int set_light_backlight(struct light_device_t *dev,
return err;
}
+#ifdef BUTTONS_FILE
+static int set_light_buttons(struct light_device_t *dev,
+ struct light_state_t const *state)
+{
+ int touch_led_control = !!(state->color & 0x00ffffff);
+ int res;
+
+ ALOGD("set_light_buttons: color=%#010x, tlc=%u.", state->color,
+ touch_led_control);
+
+ pthread_mutex_lock(&g_lock);
+ res = write_int(BUTTONS_FILE, touch_led_control);
+ pthread_mutex_unlock(&g_lock);
+
+ return res;
+}
+#endif
+
static int close_lights(struct light_device_t *dev)
{
ALOGV("close_light is called");
@@ -119,6 +137,10 @@ static int open_lights(const struct hw_module_t *module, char const *name,
set_light = set_light_backlight;
else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
set_light = set_light_notifications;
+#ifdef BUTTONS_FILE
+ else if (0 == strcmp(LIGHT_ID_BUTTONS, name))
+ set_light = set_light_buttons;
+#endif
else
return -EINVAL;