From 581dd2a1c9cf9c1c1ae6fa843e7b233b1321c7c9 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 15 Jan 2021 19:55:13 +0900 Subject: Rework led hal Change-Id: I22edb80dbd4a936068c0960cc618cd1762c17bc0 Signed-off-by: lokilee73 --- hw/led/led.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/hw/led/led.c b/hw/led/led.c index 84b6efc..70850ea 100644 --- a/hw/led/led.c +++ b/hw/led/led.c @@ -32,12 +32,12 @@ #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; } -- cgit v1.2.3