Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- techmik@techmik-acer ~ $ diff -bBw ~/Desktop/kang-lights.c ~/Desktop/neldar-lights.c
- 1a2,3
- > * modified by Michael Richter
- > *
- 3c5
- < * Copyright (C) 2011 <kang@insecure.ws>
- ---
- > * Copyright (C) 2010 Michael Richter (alias neldar)
- 17a20,21
- >
- > //#define LOG_NDEBUG 0
- 21a28
- > #include <unistd.h>
- 28a38,39
- > /******************************************************************************/
- >
- 30a42,58
- > static int g_haveTrackballLight = 0;
- > static struct light_state_t g_notification;
- > static struct light_state_t g_battery;
- > static int g_backlight = 170; //modified by mr
- > static int g_trackball = -1;
- > static int g_buttons = 0;
- > static int g_attention = 0;
- >
- >
- > // begin modified by mr
- > char const*const LCD_FILE
- > = "/sys/class/backlight/s5p_bl/brightness";
- >
- > #if 0
- > /* samsung does have this sys/file in their liblights, may be they
- > * implemented a specific light intensity/lcd-backlight brightness function
- > */
- 32,33c60,73
- < char const *const LCD_FILE = "/sys/class/backlight/s5p_bl/brightness";
- < char const *const LED_FILE = "/sys/class/misc/notification/led";
- ---
- > char const*const LIGHTSENSOR_FILE
- > = "/sys/class/lightsensor/switch_cmd/lightsensor_file_state";
- > #endif
- >
- > char const*const BUTTON_FILE
- > = "/sys/class/misc/melfas_touchkey/brightness";
- >
- > char const*const NOTIFICATION_FILE
- > = "/sys/class/misc/backlightnotification/notification_led";
- >
- > //end modified by mr
- > /**
- > * device methods
- > */
- 35c75
- < static int write_int(char const *path, int value)
- ---
- > void init_globals(void)
- 37,38c77,78
- < int fd;
- < static int already_warned;
- ---
- > // init the mutex
- > pthread_mutex_init(&g_lock, NULL);
- 40c80
- < already_warned = 0;
- ---
- > }
- 42,43c82,86
- < LOGV("write_int: path %s, value %d", path, value);
- < fd = open(path, O_RDWR);
- ---
- > static int
- > write_int(char const* path, int value)
- > {
- > int fd;
- > static int already_warned = 0;
- 44a88
- > fd = open(path, O_RDWR);
- 60c104,105
- < static int rgb_to_brightness(struct light_state_t const *state)
- ---
- > static int
- > is_lit(struct light_state_t const* state)
- 62c107,108
- < int color = state->color & 0x00ffffff;
- ---
- > return state->color & 0x00ffffff;
- > }
- 63a110,113
- > static int
- > rgb_to_brightness(struct light_state_t const* state)
- > {
- > int color = state->color & 0x00ffffff;
- 68c118,119
- < static int set_light_notifications(struct light_device_t* dev,
- ---
- > static int
- > set_light_backlight(struct light_device_t* dev,
- 70a122
- > int err = 0;
- 72,73d123
- < int v = 0;
- < int ret = 0;
- 75,83c125,126
- <
- < 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);
- ---
- > g_backlight = brightness;
- > err = write_int(LCD_FILE, brightness);
- 85c128
- < return ret;
- ---
- > return err;
- 88c131,132
- < static int set_light_backlight(struct light_device_t *dev,
- ---
- > static int
- > set_light_buttons(struct light_device_t* dev,
- 92,93c136
- < int brightness = rgb_to_brightness(state);
- <
- ---
- > int on = is_lit(state);
- 95,96c138,139
- < err = write_int(LCD_FILE, brightness);
- <
- ---
- > g_buttons = on;
- > err = write_int(BUTTON_FILE, on?1:2);
- 101c144,160
- < static int close_lights(struct light_device_t *dev)
- ---
- > static int
- > set_light_notifications(struct light_device_t* dev,
- > struct light_state_t const* state)
- > {
- > int err = 0;
- > int on = is_lit(state);
- > LOGV("%s color=%08x flashMode=%d flashOnMS=%d flashOffMS=%d\n", __func__,
- > state->color, state->flashMode, state->flashOnMS, state->flashOffMS);
- > pthread_mutex_lock(&g_lock);
- > g_buttons = on;
- > err = write_int(NOTIFICATION_FILE, on?1:0);
- > pthread_mutex_unlock(&g_lock);
- > return err;
- > }
- > /** Close the lights device */
- > static int
- > close_lights(struct light_device_t *dev)
- 103,104c162
- < LOGV("close_light is called");
- < if (dev)
- ---
- > if (dev) {
- 106c164
- <
- ---
- > }
- 109a168,175
- >
- > /******************************************************************************/
- >
- > /**
- > * module methods
- > */
- >
- > /** Open a new instance of a lights device using name */
- 115,118c181
- <
- < LOGV("open_lights: open with %s", name);
- <
- < if (0 == strcmp(LIGHT_ID_BACKLIGHT, name))
- ---
- > if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
- 120c183,192
- < else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
- ---
- > }
- > else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) {
- > set_light = set_light_buttons;
- > }
- > #if 0 //modified by mr
- > else if (0 == strcmp(LIGHT_ID_BATTERY, name)) {
- > set_light = set_light_battery; //to notification
- > }
- > #endif
- > else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) {
- 122c194,195
- < else
- ---
- > }
- > else {
- 123a197
- > }
- 125c199,200
- < pthread_mutex_init(&g_lock, NULL);
- ---
- >
- > pthread_once(&g_init, init_globals);
- 144a220,222
- > /*
- > * The lights Module
- > */
- 150,151c228,229
- < .name = "lights Module",
- < .author = "Google, Inc.",
- ---
- > .name = "Samsung i9000 custom lights module",
- > .author = "Michael Richter (alias mr)",
- techmik@techmik-acer ~ $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement