smdk4x12: lights: battery led support
authorcodeworkx <daniel.hillenbrand@codeworkx.de>
Thu, 21 Jun 2012 03:40:51 +0000 (05:40 +0200)
committercodeworkx <daniel.hillenbrand@codeworkx.de>
Thu, 21 Jun 2012 03:47:12 +0000 (05:47 +0200)
Change-Id: Ida4e7bd998251ec07a9874f695d1fef9f97a1b0c

exynos4/exynos4x12/liblights/lights.c

index ba0f0fcd140f2c8cfa8a0fec1271b49df5d0a3c2..8b5288fcbd7e84a8e265eaa4a76b7287d761905d 100644 (file)
@@ -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;