From 889f4e58cb47a94671aa162a6fe252f9ee44b24a Mon Sep 17 00:00:00 2001 From: Araemo Date: Wed, 13 Feb 2013 21:32:49 -0500 Subject: 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 --- liblight/Android.mk | 4 ++++ liblight/lights.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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; -- cgit v1.1