From: Ketut Putu Kumajaya Date: Tue, 7 Jan 2014 05:36:26 +0000 (+0700) Subject: exynos4x12: liblights: Fix tablets with button backlight X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e1b1ffd5fceb0c67b8fda417032fb5bfb19f0951;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git exynos4x12: liblights: Fix tablets with button backlight Also, respect the lights API and return errors when attempting to configure an absent light ID. Change-Id: Ida430fba2fbfaf646f7e02ce2bd7d9134ae8d917 --- diff --git a/exynos4/exynos4x12/liblights/Android.mk b/exynos4/exynos4x12/liblights/Android.mk index a16bab5..5392476 100644 --- a/exynos4/exynos4x12/liblights/Android.mk +++ b/exynos4/exynos4x12/liblights/Android.mk @@ -33,6 +33,11 @@ ifeq ($(BOARD_EXYNOS4X12_TABLET),true) LOCAL_CFLAGS += -DEXYNOS4X12_TABLET endif +ifeq ($(BOARD_EXYNOS4X12_TABLET_HAS_LED_BUTTONS),true) + LOCAL_CFLAGS += -DEXYNOS4X12_TABLET + LOCAL_CFLAGS += -DEXYNOS4X12_TABLET_HAS_LED_BUTTONS +endif + LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM) LOCAL_MODULE_TAGS := optional diff --git a/exynos4/exynos4x12/liblights/lights.c b/exynos4/exynos4x12/liblights/lights.c index 87fa134..c8073d5 100644 --- a/exynos4/exynos4x12/liblights/lights.c +++ b/exynos4/exynos4x12/liblights/lights.c @@ -40,7 +40,6 @@ static pthread_once_t g_init = PTHREAD_ONCE_INIT; static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; char const*const PANEL_FILE = "/sys/class/backlight/panel/brightness"; -#ifndef EXYNOS4X12_TABLET char const*const BUTTON_FILE = "/sys/class/sec/sec_touchkey/brightness"; char const*const LED_RED = "/sys/class/sec/led/led_r"; @@ -48,7 +47,6 @@ char const*const LED_GREEN = "/sys/class/sec/led/led_g"; char const*const LED_BLUE = "/sys/class/sec/led/led_b"; char const*const LED_BLINK = "/sys/class/sec/led/led_blink"; char const*const LED_BRIGHTNESS = "/sys/class/sec/led/led_br_lev"; -#endif #define MAX_WRITE_CMD 25 @@ -154,7 +152,6 @@ static int set_light_backlight(struct light_device_t *dev, { int err = 0; int brightness = rgb_to_brightness(state); - int previous_brightness = read_int(PANEL_FILE); pthread_mutex_lock(&g_lock); err = write_int(PANEL_FILE, brightness); @@ -168,9 +165,6 @@ static int set_light_buttons(struct light_device_t* dev, struct light_state_t const* state) { -#ifdef EXYNOS4X12_TABLET - return 0; -#else int err = 0; int brightness = rgb_to_brightness(state); @@ -180,30 +174,23 @@ set_light_buttons(struct light_device_t* dev, pthread_mutex_unlock(&g_lock); return err; -#endif } /* LEDs */ static int write_leds(struct led_config led) { int err = 0; -#ifndef EXYNOS4X12_TABLET pthread_mutex_lock(&g_lock); err = write_int(LED_RED, led.red); err = write_int(LED_GREEN, led.green); err = write_int(LED_BLUE, led.blue); err = write_str(LED_BLINK, led.blink); pthread_mutex_unlock(&g_lock); -#endif return err; } static int set_light_leds(struct light_state_t const *state, int type) { -#ifdef EXYNOS4X12_TABLET - return 0; -#else - struct led_config led; unsigned int colorRGB; @@ -233,7 +220,6 @@ static int set_light_leds(struct light_state_t const *state, int type) } return write_leds(led); -#endif } static int set_light_leds_notifications(struct light_device_t *dev, @@ -245,9 +231,6 @@ static int set_light_leds_notifications(struct light_device_t *dev, static int set_light_battery(struct light_device_t *dev, struct light_state_t const *state) { -#ifdef EXYNOS4X12_TABLET - return 0; -#else struct led_config led; int brightness = rgb_to_brightness(state); unsigned int colorRGB; @@ -269,7 +252,6 @@ static int set_light_battery(struct light_device_t *dev, g_BatteryStore = led; return write_leds(led); -#endif } static int set_light_leds_attention(struct light_device_t *dev, @@ -295,14 +277,18 @@ 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; +#if !defined(EXYNOS4X12_TABLET) || defined(EXYNOS4X12_TABLET_HAS_LED_BUTTONS) else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) set_light = set_light_buttons; +#endif +#ifndef EXYNOS4X12_TABLET else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) set_light = set_light_leds_notifications; else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) set_light = set_light_leds_attention; else if (0 == strcmp(LIGHT_ID_BATTERY, name)) set_light = set_light_battery; +#endif else return -EINVAL;