display: Move display blink functions from plugin to core display module 07/288907/9
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 24 Feb 2023 08:17:58 +0000 (17:17 +0900)
committeryunhee <yuni.seo@samsung.com>
Mon, 20 Mar 2023 08:01:56 +0000 (17:01 +0900)
Remove and redefine display blink functions.
These functions are added to below display-backlight.

void display_backlight_set_blink(int timeout)
-> This function set display blink behavior by adding timeout callback.
void display_backlight_unset_blink(void)
-> This function remove blink callback function after DUMP_MODE_WAITING_TIME time.

Change-Id: Iafe293ff9ff8ad65b971885bfd949e037bcffa40
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/iot-headed/display/device-interface.c
plugins/mobile/display/device-interface.c
plugins/tv/display/device-interface.c
plugins/wearable/display/device-interface.c
src/display/device-interface.h
src/display/display-backlight.c
src/display/display-backlight.h
src/display/display-dbus.c

index 1648dd2..e93dedd 100644 (file)
@@ -53,7 +53,6 @@
 
 #define LCD_PHASED_MAX_BRIGHTNESS      100
 #define LCD_PHASED_DELAY               10000   /* microsecond */
-#define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
@@ -72,7 +71,6 @@ static struct _backlight_ops backlight_ops;
 static int force_brightness;
 static int dpms_running_state = DPMS_SETTING_DONE;
 static bool display_dev_available = false;
-static guint release_timer;
 static const struct display_config *display_conf;
 
 inline struct _backlight_ops *get_var_backlight_ops(void)
@@ -314,57 +312,6 @@ static int backlight_transit_state(int state)
        return 0;
 }
 
-static gboolean blink_cb(gpointer data)
-{
-       static bool flag;
-
-       set_brightness(flag ? PM_MAX_BRIGHTNESS : PM_MIN_BRIGHTNESS);
-
-       flag = !flag;
-
-       return G_SOURCE_CONTINUE;
-}
-
-static void blink(int timeout)
-{
-       static guint timer;
-
-       if (timer) {
-               g_source_remove(timer);
-               timer = 0;
-       }
-
-       if (timeout < 0) {
-               _E("timeout value is invalid %d", timeout);
-               return;
-       }
-
-       if (timeout == 0) {
-               display_backlight_update_by_default_brightness();
-               return;
-       }
-
-       timer = g_timeout_add(timeout, blink_cb, NULL);
-}
-
-static gboolean release_blink_cb(gpointer data)
-{
-       blink(0);
-
-       release_timer = 0;
-       return G_SOURCE_REMOVE;
-}
-
-static void release_blink(void)
-{
-       if (release_timer) {
-               g_source_remove(release_timer);
-               release_timer = 0;
-       }
-
-       release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -381,8 +328,6 @@ static struct _backlight_ops backlight_ops = {
        .restore_brightness_func = restore_brightness_func,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
-       .blink = blink,
-       .release_blink = release_blink,
 };
 
 int display_service_load(void)
index 0d5ea50..b967e3d 100644 (file)
@@ -54,7 +54,6 @@
 
 #define LCD_PHASED_MAX_BRIGHTNESS      100
 #define LCD_PHASED_DELAY               10000   /* microsecond */
-#define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
@@ -71,7 +70,6 @@ static struct _backlight_ops backlight_ops;
 static int force_brightness;
 static int dpms_running_state = DPMS_SETTING_DONE;
 static bool display_dev_available = false;
-static guint release_timer;
 static const struct display_config *display_conf;
 
 inline struct _backlight_ops *get_var_backlight_ops(void)
@@ -313,57 +311,6 @@ static int backlight_transit_state(int state)
        return 0;
 }
 
-static gboolean blink_cb(gpointer data)
-{
-       static bool flag;
-
-       set_brightness(flag ? PM_MAX_BRIGHTNESS : PM_MIN_BRIGHTNESS);
-
-       flag = !flag;
-
-       return G_SOURCE_CONTINUE;
-}
-
-static void blink(int timeout)
-{
-       static guint timer;
-
-       if (timer) {
-               g_source_remove(timer);
-               timer = 0;
-       }
-
-       if (timeout < 0) {
-               _E("timeout value is invalid %d", timeout);
-               return;
-       }
-
-       if (timeout == 0) {
-               display_backlight_update_by_default_brightness();
-               return;
-       }
-
-       timer = g_timeout_add(timeout, blink_cb, NULL);
-}
-
-static gboolean release_blink_cb(gpointer data)
-{
-       blink(0);
-
-       release_timer = 0;
-       return G_SOURCE_REMOVE;
-}
-
-static void release_blink(void)
-{
-       if (release_timer) {
-               g_source_remove(release_timer);
-               release_timer = 0;
-       }
-
-       release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -380,8 +327,6 @@ static struct _backlight_ops backlight_ops = {
        .restore_brightness_func = restore_brightness_func,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
-       .blink = blink,
-       .release_blink = release_blink,
 };
 
 int display_service_load(void)
index c4f60e7..2382b31 100644 (file)
@@ -53,7 +53,6 @@
 
 #define LCD_PHASED_MAX_BRIGHTNESS      100
 #define LCD_PHASED_DELAY               10000   /* microsecond */
-#define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
@@ -72,7 +71,6 @@ static struct _backlight_ops backlight_ops;
 static int force_brightness;
 static int dpms_running_state = DPMS_SETTING_DONE;
 static bool display_dev_available = false;
-static guint release_timer;
 static const struct display_config *display_conf;
 
 inline struct _backlight_ops *get_var_backlight_ops(void)
@@ -314,57 +312,6 @@ static int backlight_transit_state(int state)
        return 0;
 }
 
-static gboolean blink_cb(gpointer data)
-{
-       static bool flag;
-
-       set_brightness(flag ? PM_MAX_BRIGHTNESS : PM_MIN_BRIGHTNESS);
-
-       flag = !flag;
-
-       return G_SOURCE_CONTINUE;
-}
-
-static void blink(int timeout)
-{
-       static guint timer;
-
-       if (timer) {
-               g_source_remove(timer);
-               timer = 0;
-       }
-
-       if (timeout < 0) {
-               _E("timeout value is invalid %d", timeout);
-               return;
-       }
-
-       if (timeout == 0) {
-               display_backlight_update_by_default_brightness();
-               return;
-       }
-
-       timer = g_timeout_add(timeout, blink_cb, NULL);
-}
-
-static gboolean release_blink_cb(gpointer data)
-{
-       blink(0);
-
-       release_timer = 0;
-       return G_SOURCE_REMOVE;
-}
-
-static void release_blink(void)
-{
-       if (release_timer) {
-               g_source_remove(release_timer);
-               release_timer = 0;
-       }
-
-       release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -381,8 +328,6 @@ static struct _backlight_ops backlight_ops = {
        .restore_brightness_func = restore_brightness_func,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
-       .blink = blink,
-       .release_blink = release_blink,
 };
 
 int display_service_load(void)
index 11a7c4a..5fa17b0 100644 (file)
@@ -56,7 +56,6 @@
 
 #define LCD_PHASED_MAX_BRIGHTNESS      100
 #define LCD_PHASED_DELAY               10000   /* microsecond */
-#define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
@@ -78,7 +77,6 @@ static struct battery_plugin *battery_plgn;
 static int force_brightness;
 static int dpms_running_state = DPMS_SETTING_DONE;
 static bool display_dev_available = false;
-static guint release_timer;
 static int aod_max_level = -1;
 static int aod_normal_level = -1;
 static int aod_min_level = -1;
@@ -379,57 +377,6 @@ static int backlight_transit_state(int state)
        return 0;
 }
 
-static gboolean blink_cb(gpointer data)
-{
-       static bool flag;
-
-       set_brightness(flag ? PM_MAX_BRIGHTNESS : PM_MIN_BRIGHTNESS);
-
-       flag = !flag;
-
-       return G_SOURCE_CONTINUE;
-}
-
-static void blink(int timeout)
-{
-       static guint timer;
-
-       if (timer) {
-               g_source_remove(timer);
-               timer = 0;
-       }
-
-       if (timeout < 0) {
-               _E("timeout value is invalid %d", timeout);
-               return;
-       }
-
-       if (timeout == 0) {
-               display_backlight_update_by_default_brightness();
-               return;
-       }
-
-       timer = g_timeout_add(timeout, blink_cb, NULL);
-}
-
-static gboolean release_blink_cb(gpointer data)
-{
-       blink(0);
-
-       release_timer = 0;
-       return G_SOURCE_REMOVE;
-}
-
-static void release_blink(void)
-{
-       if (release_timer) {
-               g_source_remove(release_timer);
-               release_timer = 0;
-       }
-
-       release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -446,8 +393,6 @@ static struct _backlight_ops backlight_ops = {
        .restore_brightness_func = restore_brightness_func,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
-       .blink = blink,
-       .release_blink = release_blink,
        /* auto-test only function */
        .get_brightness_raw = get_brightness, /* always fetch brightness from node even LBM mode */
 };
index 034f133..2158463 100644 (file)
@@ -70,8 +70,6 @@ struct _backlight_ops {
        void (*restore_brightness_func)(void);
        int (*transit_state)(int state);
        void (*transit_brt)(int start, int end, int step);
-       void (*blink)(int timeout);
-       void (*release_blink)(void);
 };
 
 struct _backlight_ops *get_var_backlight_ops(void);
index a112d16..9b226ec 100644 (file)
 #include "display-backlight.h"
 #include "display-dpms.h"
 
+#define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
+
 static const struct display_config *display_conf;
 static struct _backlight_ops *backlight_ops;
 
 static int default_brightness;
 static int custom_brightness;
 static bool g_custom_status;
+static guint release_timer;
 
 /* FIXME: This function is for temporary use, should be fixed after plugin refactoring */
 int display_backlight_get_max_brightness(int *max_brightness)
@@ -220,6 +223,56 @@ int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin,
        return 0;
 }
 
+static gboolean blink_cb(gpointer data)
+{
+       static bool flag;
+
+       backlight_ops->set_brightness(flag ? PM_MAX_BRIGHTNESS : PM_MIN_BRIGHTNESS);
+       flag = !flag;
+
+       return G_SOURCE_CONTINUE;
+}
+
+void display_backlight_set_blink(int timeout)
+{
+       static guint blink_timer;
+
+       if (blink_timer) {
+               g_source_remove(blink_timer);
+               blink_timer = 0;
+       }
+
+       if (timeout < 0) {
+               _W("timeout value is invalid %d", timeout);
+               return;
+       }
+
+       if (timeout == 0) {
+               display_backlight_update_by_default_brightness();
+               return;
+       }
+
+       blink_timer = g_timeout_add(timeout, blink_cb, NULL);
+}
+
+static gboolean release_blink_cb(gpointer data)
+{
+       display_backlight_set_blink(0);
+
+       release_timer = 0;
+       return G_SOURCE_REMOVE;
+}
+
+void display_backlight_unset_blink(void)
+{
+       if (release_timer) {
+               g_source_remove(release_timer);
+               release_timer = 0;
+       }
+
+       release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
+}
+
 /* FIXME: This code structure should be changed to plugin api call, after plugin refactoting*/
 static void __CONSTRUCTOR__ initialize(void)
 {
index 9c7e5c3..f624c27 100644 (file)
@@ -32,5 +32,7 @@ void display_backlight_set_custom_brightness(int brightness);
 int display_backlight_update_by_custom_brightness(void);
 int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin,
                                                        float light, int *brightness);
+void display_backlight_set_blink(int timeout);
+void display_backlight_unset_blink(void);
 
 #endif /* __DISPLAY_BACKLIGHT_H__ */
\ No newline at end of file
index a67860a..091bcc5 100644 (file)
@@ -780,13 +780,13 @@ static GVariant *dbus_dumpmode(GDBusConnection *conn,
                if (disp_plgn->pm_lock_internal)
                        disp_plgn->pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
                                STAY_CUR_STATE, DUMP_MODE_WATING_TIME);
-               backlight_ops->release_blink();
+               display_backlight_unset_blink();
        } else if (!strcmp(on, "off")) {
                if (disp_plgn->pm_unlock_internal)
                        disp_plgn->pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, PM_SLEEP_MARGIN);
-               backlight_ops->blink(0);
+               display_backlight_set_blink(0);
        } else if (!strcmp(on, "blink")) {
-               backlight_ops->blink(500);
+               display_backlight_set_blink(500);
        } else {
                ret = -EINVAL;
        }