From 61bb8c4defa2cf570796d2840fca8ffcd573202d Mon Sep 17 00:00:00 2001
From: codeworkx <daniel.hillenbrand@codeworkx.de>
Date: Thu, 21 Jun 2012 05:40:51 +0200
Subject: smdk4x12: lights: battery led support

Change-Id: Ida4e7bd998251ec07a9874f695d1fef9f97a1b0c
---
 exynos4/exynos4x12/liblights/lights.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/exynos4/exynos4x12/liblights/lights.c b/exynos4/exynos4x12/liblights/lights.c
index ba0f0fc..8b5288f 100644
--- a/exynos4/exynos4x12/liblights/lights.c
+++ b/exynos4/exynos4x12/liblights/lights.c
@@ -191,6 +191,30 @@ static int set_light_leds_notifications(struct light_device_t *dev,
     return set_light_leds(state, 0);
 }
 
+static int set_light_battery(struct light_device_t *dev,
+            struct light_state_t const *state)
+{
+    struct led_config led;
+    int brightness = rgb_to_brightness(state);
+    unsigned int colorRGB;
+
+    colorRGB = state->color;
+
+    if (brightness == 0) {
+        led.red = 0;
+        led.green = 0;
+        led.blue = 0;
+        snprintf(led.blink, MAX_WRITE_CMD, "0x000000 0 0");
+    } else {
+        led.red = (colorRGB >> 16) & 0xFF;
+        led.green = (colorRGB >> 8) & 0xFF;
+        led.blue = colorRGB & 0xFF;
+        snprintf(led.blink, MAX_WRITE_CMD, "0x%x %d %d", colorRGB, state->flashOnMS, state->flashOffMS);
+    }
+
+    return write_leds(led);
+}
+
 static int set_light_leds_attention(struct light_device_t *dev,
             struct light_state_t const *state)
 {
@@ -209,6 +233,8 @@ static int open_lights(const struct hw_module_t *module, char const *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;
     else
         return -EINVAL;
 
-- 
cgit v1.1