diff options
author | KalimochoAz <calimochoazucarado@gmail.com> | 2012-07-23 03:04:48 +0200 |
---|---|---|
committer | KalimochoAz <calimochoazucarado@gmail.com> | 2012-07-23 03:04:48 +0200 |
commit | 8e8baa74c467a51dcf1338d3096875f5a0baf868 (patch) | |
tree | a2bb25cd987bd47e79f0bc2399f6dd46b42acffc /liblight | |
parent | 55709d40c8df61c6badb8a8ecab6ebfd34b95d60 (diff) | |
parent | b5f4a69e24cd5dae6c2d014b078c3a2966d14611 (diff) | |
download | device_samsung_crespo-8e8baa74c467a51dcf1338d3096875f5a0baf868.zip device_samsung_crespo-8e8baa74c467a51dcf1338d3096875f5a0baf868.tar.gz device_samsung_crespo-8e8baa74c467a51dcf1338d3096875f5a0baf868.tar.bz2 |
Merge remote-tracking branch 'github/ics' into 23072012
Conflicts:
Android.mk
BoardConfigCommon.mk
board-info.txt
device_base.mk
egl.cfg
factory-images/generate-factory-images-package.sh
kernel
overlay/frameworks/base/core/res/res/values/config.xml
Change-Id: If153de549a1a3b5145f856de6c55c825d3124a11
Diffstat (limited to 'liblight')
-rwxr-xr-x | liblight/lights.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index bee698a..7f2d91d 100755 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2011 <kang@insecure.ws> * * 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 <cutils/log.h> #include <stdint.h> @@ -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; ALOGV("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; |