summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]hw/led/led.c41
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;
}