led: Support touchkey led 90/40290/1 tizen_3.0.2015.q2_common tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/common/20150605.080111 accepted/tizen/mobile/20150605.092352 accepted/tizen/tv/20150605.092303 accepted/tizen/wearable/20150605.092330 submit/tizen/20150604.080213 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release tizen_3.0.m2.a1_mobile_release tizen_3.0.m2.a1_tv_release
authorJiyoung Yun <jy910.yun@samsung.com>
Tue, 2 Jun 2015 03:47:18 +0000 (12:47 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Tue, 2 Jun 2015 03:47:18 +0000 (12:47 +0900)
When user press the touch key on the bottom,
deviced turns on light during a given timeout (default 1.5s).

Change-Id: I88a08c69231ba465b9cab8f527e9113903a5cc8e
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
hw/led/led.c

index a65fee3..850907a 100644 (file)
 #define CAMERA_BACK_PATH       "/sys/class/leds/ktd2692-flash"
 #endif
 
+#ifndef TOUCH_KEY_PATH
+#define TOUCH_KEY_PATH          "/sys/class/leds/sec_touchkey"
+#endif
+
+#define GET_BRIGHTNESS(val)     (((val) >> 24) & 0xFF)
+
 static int camera_back_set_state(struct led_state *state)
 {
        static int max = -1;
@@ -66,6 +72,34 @@ static int camera_back_set_state(struct led_state *state)
        return 0;
 }
 
+static int touch_key_set_state(struct led_state *state)
+{
+       static int max = -1;
+       int brt, r;
+
+       if (!state)
+               return -EINVAL;
+
+       if (state->type == LED_TYPE_BLINK)
+               return -ENOTSUP;
+
+       /* if there is a max brightness of led */
+       if (max < 0) {
+               r = sys_get_int(TOUCH_KEY_PATH"/max_brightness", &max);
+               if (r < 0)
+                       return r;
+       }
+
+       brt = GET_BRIGHTNESS(state->color);
+       brt = brt / 255.f * max;
+
+       r = sys_set_int(TOUCH_KEY_PATH"/brightness", brt);
+       if (r < 0)
+               return r;
+
+       return 0;
+}
+
 static int led_open(struct hw_info *info,
                const char *id, struct hw_common **common)
 {
@@ -74,7 +108,8 @@ static int led_open(struct hw_info *info,
        if (!info || !id || !common)
                return -EINVAL;
 
-       if (strcmp(id, LED_ID_CAMERA_BACK) != 0)
+       if (strcmp(id, LED_ID_CAMERA_BACK) != 0 &&
+           strcmp(id, LED_ID_TOUCH_KEY) != 0)
                return -ENOTSUP;
 
        led_dev = calloc(1, sizeof(struct led_device));
@@ -85,6 +120,8 @@ static int led_open(struct hw_info *info,
 
        if (!strcmp(id, LED_ID_CAMERA_BACK))
                led_dev->set_state = camera_back_set_state;
+       else if (!strcmp(id, LED_ID_TOUCH_KEY))
+               led_dev->set_state = touch_key_set_state;
 
        *common = (struct hw_common *)led_dev;
        return 0;