summaryrefslogtreecommitdiffstats
path: root/liblight
diff options
context:
space:
mode:
authorKalimochoAz <calimochoazucarado@gmail.com>2011-12-18 16:46:37 +0100
committerKalimochoAz <calimochoazucarado@gmail.com>2011-12-18 16:46:37 +0100
commit0036ecd8d2b7bc48758147293387e534d985c1e5 (patch)
treeb6a1894fdf873a58a9d3aba4076ba5811556cfc0 /liblight
parent2538cbd4349b3b8da33f78837f9b0f1a11aef02d (diff)
downloaddevice_samsung_crespo-0036ecd8d2b7bc48758147293387e534d985c1e5.zip
device_samsung_crespo-0036ecd8d2b7bc48758147293387e534d985c1e5.tar.gz
device_samsung_crespo-0036ecd8d2b7bc48758147293387e534d985c1e5.tar.bz2
Update bin kernel
Added LED Notificatio
Diffstat (limited to 'liblight')
-rwxr-xr-xliblight/lights.c28
1 files changed, 25 insertions, 3 deletions
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 <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;
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;