Rework led hal 30/251630/2
authorlokilee73 <changjoo.lee@samsung.com>
Mon, 18 Jan 2021 01:52:48 +0000 (10:52 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 18 Jan 2021 03:27:51 +0000 (12:27 +0900)
Change-Id: Iacc7d4aeb99039c47b05a5fee1d37d1eeab392e8
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/led/led.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 00358db..cb00e31
@@ -305,9 +305,9 @@ static int gpio_rgb_turn_on(struct led_state *state)
        return gpio_rgb_set_brightness_blink(state);
 }
 
-static int gpio_rgb_set_state(struct led_state *state)
+static int gpio_rgb_set_state(enum led_device_type type, struct led_state *state)
 {
-       if (!state)
+       if ((type != NOTIFICATION) || !state)
                return -EINVAL;
 
        switch (state->type) {
@@ -328,29 +328,50 @@ static int gpio_rgb_set_state(struct led_state *state)
 
 static int led_init(void **data)
 {
-       hal_backend_led_funcs *led_funcs;
+       hal_backend_led_funcs *led_device;
 
-       led_funcs = calloc(1, sizeof(hal_backend_led_funcs));
-       if (!led_funcs)
+       led_device = calloc(1, sizeof(hal_backend_led_funcs));
+       if (!led_device)
                return -ENOMEM;
 
        if (gpio_rgb_init_led()) {
-               free(led_funcs);
+               free(led_device);
                return -EIO;
-       } else
-               led_funcs->set_state = gpio_rgb_set_state;
+       } else {
+               led_device->camera_front = NULL;
+               led_device->camera_back = NULL;
+               led_device->touch_key = NULL;
+               led_device->notification = calloc(1, sizeof(struct led_funcs));
+               if (!led_device->notification) {
+                       free(led_device);
+                       return -ENOMEM;
+               }
+
+               led_device->notification->set_state = gpio_rgb_set_state;
+               led_device->notification->get_state = NULL;
+               led_device->notification->get_number = NULL;
+               led_device->notification->set_num = NULL;
+               led_device->notification->get_max_num = NULL;
+               led_device->notification->keyled_set_state = NULL;
+               led_device->notification->keyled_get_state = NULL;
+       }
 
-       *data = (void *)led_funcs;
+       *data = (void *)led_device;
 
        return 0;
 }
 
 static int led_exit(void *data)
 {
+       hal_backend_led_funcs *led_device;
+
        if (!data)
                return 0;
 
-       free(data);
+       led_device = (hal_backend_led_funcs *)data;
+       free(led_device->notification);
+       free(led_device);
+
        return 0;
 }