Rework led hal
authorlokilee73 <changjoo.lee@samsung.com>
Fri, 15 Jan 2021 10:55:13 +0000 (19:55 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 18 Jan 2021 03:34:15 +0000 (12:34 +0900)
Change-Id: I22edb80dbd4a936068c0960cc618cd1762c17bc0
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/led/led.c

index 84b6efc..70850ea 100644 (file)
 #define CAMERA_BACK_PATH    "/sys/class/leds/torch-sec1"
 #endif
 
-static int camera_back_set_state(struct led_state *state)
+static int camera_back_set_state(enum led_device_type type, struct led_state *state)
 {
        static int max = -1;
        int brt, r;
 
-       if (!state) {
+       if ((type != CAMERA_BACK) || !state) {
                _E("wrong parameter");
                return -EINVAL;
        }
@@ -69,25 +69,45 @@ static int camera_back_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;
 
-       led_funcs->set_state = camera_back_set_state;
+       led_device->camera_front = NULL;
+       led_device->notification = NULL;
+       led_device->touch_key = NULL;
+       led_device->camera_back = calloc(1, sizeof(struct led_funcs));
+       if (!led_device->camera_back) {
+               free(led_device);
+               return -ENOMEM;
+       }
+
+       led_device->camera_back->set_state = camera_back_set_state;
+       led_device->camera_back->get_state = NULL;
+       led_device->camera_back->get_number = NULL;
+       led_device->camera_back->set_num = NULL;
+       led_device->camera_back->get_max_num = NULL;
+       led_device->camera_back->keyled_set_state = NULL;
+       led_device->camera_back->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->camera_back);
+       free(led_device);
+
        return 0;
 }