diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2021-01-18 10:52:48 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2021-01-18 12:27:51 +0900 |
commit | 035a2922c8dfcd90867cf928465a4cb27a33f0ff (patch) | |
tree | ded086d4816cd5440bbfce8511f77691673a3a8a | |
parent | 94222adf65481696c65244cc03c506cfec696051 (diff) | |
download | device-manager-plugin-artik-035a2922c8dfcd90867cf928465a4cb27a33f0ff.tar.gz device-manager-plugin-artik-035a2922c8dfcd90867cf928465a4cb27a33f0ff.tar.bz2 device-manager-plugin-artik-035a2922c8dfcd90867cf928465a4cb27a33f0ff.zip |
Rework led hal
Change-Id: Iacc7d4aeb99039c47b05a5fee1d37d1eeab392e8
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r--[-rwxr-xr-x] | hw/led/led.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/hw/led/led.c b/hw/led/led.c index 00358db..cb00e31 100755..100644 --- a/hw/led/led.c +++ b/hw/led/led.c @@ -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; } |