boot_ani: Change function signature properly 02/279102/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 2 Aug 2022 00:58:20 +0000 (09:58 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Tue, 2 Aug 2022 04:16:54 +0000 (13:16 +0900)
No functional changes

Change-Id: I17146f399618950420d8b25f32131fd821586953

src/output/boot_anim.c
src/output/output_internal.h
src/output/output_led.c

index f58a2a8..47019e5 100644 (file)
 #include "HL_UI_LED.h"
 #include "output_internal.h"
 
-typedef struct {
+struct boot_ani {
        HL_UI_LED *led;
 
        struct wl_event_source *source;
        uint32_t serial;
        int index;
-} boot_ani_t;
+};
 
 #define ANI_INTERVAL   40      //20ms
 
@@ -68,7 +68,8 @@ boot_ani_timer_cb(void *data)
        return 1;
 }
 
-void boot_ani_start(led_output_t *output)
+boot_ani_t *
+boot_ani_start(struct wl_display *display, HL_UI_LED *ui_led)
 {
        struct wl_event_loop *loop;
        boot_ani_t *ani;
@@ -76,11 +77,11 @@ void boot_ani_start(led_output_t *output)
 
        HS_TRACE("[OUTPUT] start boot-animation\n");
 
-       loop = wl_display_get_event_loop(output->display);
-       HS_CHECK(loop, return, "failed to wl_display_get_event_loop()\n");
+       loop = wl_display_get_event_loop(display);
+       HS_CHECK(loop, return NULL, "failed to wl_display_get_event_loop()\n");
 
        ani = (boot_ani_t *)calloc(sizeof(boot_ani_t), 1);
-       HS_CHECK(ani, return, "failed to alloc\n");
+       HS_CHECK(ani, return NULL, "failed to alloc\n");
 
        ani->source = wl_event_loop_add_timer(loop, boot_ani_timer_cb, ani);
        HS_CHECK(ani->source, goto err, "failed to wl_event_loop_add_timer()\n");
@@ -88,32 +89,24 @@ void boot_ani_start(led_output_t *output)
        ret = wl_event_source_timer_update(ani->source, ANI_INTERVAL);
        HS_CHECK(!ret, goto err, "failed to wl_event_source_timer_update\n");
 
-       ani->led = output->ui_led;
-       output->boot_ani = ani;
-       return;
-err:
-       if (ani) {
-               if (ani->source)
-                       wl_event_source_remove(ani->source);
+       ani->led = ui_led;
 
-               free(ani);
-       }
-       return;
-}
+       return ani;
 
-void boot_ani_stop(led_output_t *output)
-{
-       boot_ani_t *ani;
+err:
+    if (ani->source)
+        wl_event_source_remove(ani->source);
 
-       if (!output->boot_ani) return;
+    free(ani);
 
-       ani = (boot_ani_t *)output->boot_ani;
+       return NULL;
+}
 
+void
+boot_ani_stop(boot_ani_t *ani)
+{
        HL_UI_LED_Clear_All(ani->led);
        wl_event_source_remove(ani->source);
 
        free(ani);
-
-       output->boot_ani = NULL;
-       return;
 }
index 78a1da8..1404c2e 100644 (file)
@@ -32,6 +32,8 @@
 
 typedef struct led_output led_output_t;
 
+typedef struct boot_ani boot_ani_t;
+
 struct led_output {
        struct wl_display *display;
        struct ds_tbm_server *tbm_server;
@@ -42,8 +44,8 @@ struct led_output {
        struct wl_event_source *frame_done;
 
        //For booting animation
-       void *boot_ani;
+       boot_ani_t *boot_ani;
 };
 
-void boot_ani_start(led_output_t *output);
-void boot_ani_stop(led_output_t *output);
+boot_ani_t *boot_ani_start(struct wl_display *display, HL_UI_LED *ui_led);
+void boot_ani_stop(boot_ani_t *ani);
index 4b314fa..dd99103 100644 (file)
@@ -63,7 +63,7 @@ headless_output_destroy(led_output_t *output)
        HS_TRACE("Output Destroy %p", output);
 
        if (output->boot_ani) {
-               boot_ani_stop(output);
+               boot_ani_stop(output->boot_ani);
        }
 
        if (output->ui_led) {
@@ -103,7 +103,9 @@ headless_output_start_boot_ani(led_output_t *output)
        if (output->boot_ani)
                return;
 
-       boot_ani_start(output);
+       output->boot_ani = boot_ani_start(output->display, output->ui_led);
+       if (!output->boot_ani)
+               HS_ERROR("Failed to start boot animation");
 }
 
 void
@@ -112,5 +114,6 @@ headless_output_stop_boot_ani(led_output_t *output)
        if (!output->boot_ani)
                return;
 
-       boot_ani_stop(output);
+       boot_ani_stop(output->boot_ani);
+       output->boot_ani = NULL;
 }