From 0036ecd8d2b7bc48758147293387e534d985c1e5 Mon Sep 17 00:00:00 2001 From: KalimochoAz Date: Sun, 18 Dec 2011 16:46:37 +0100 Subject: Update bin kernel Added LED Notificatio --- liblight/lights.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'liblight') diff --git a/liblight/lights.c b/liblight/lights.c index ee6416a..470c217 100755 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +15,7 @@ * limitations under the License. */ +// #define LOG_NDEBUG 0 #define LOG_TAG "lights" #include #include @@ -29,13 +31,12 @@ static pthread_once_t g_init = PTHREAD_ONCE_INIT; static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; char const *const LCD_FILE = "/sys/class/backlight/s5p_bl/brightness"; +char const *const LED_FILE = "/sys/class/misc/notification/led"; static int write_int(char const *path, int value) { int fd; - static int already_warned; - - already_warned = 0; + static int already_warned = 0; LOGV("write_int: path %s, value %d", path, value); fd = open(path, O_RDWR); @@ -63,6 +64,25 @@ static int rgb_to_brightness(struct light_state_t const *state) + (150*((color>>8) & 0x00ff)) + (29*(color & 0x00ff))) >> 8; } +static int set_light_notifications(struct light_device_t* dev, + struct light_state_t const* state) +{ + int brightness = rgb_to_brightness(state); + int v = 0; + int ret = 0; + + pthread_mutex_lock(&g_lock); + if (brightness+state->color == 0 || brightness > 100) { + if (state->color & 0x00ffffff) + v = 1; + } else + v = 0; + LOGI("color %u fm %u status %u is lit %u brightness", state->color, state->flashMode, v, (state->color & 0x00ffffff), brightness); + ret = write_int(LED_FILE, v); + pthread_mutex_unlock(&g_lock); + return ret; +} + static int set_light_backlight(struct light_device_t *dev, struct light_state_t const *state) { @@ -95,6 +115,8 @@ static int open_lights(const struct hw_module_t *module, char const *name, if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) set_light = set_light_backlight; + else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) + set_light = set_light_notifications; else return -EINVAL; -- cgit v1.1