display: Relocate default_proc_change_state()/default_proc_change_state_action() 00/294800/5
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 26 Jun 2023 07:29:40 +0000 (16:29 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 29 Jun 2023 04:56:35 +0000 (13:56 +0900)
Above two functions are used for display-lock related functions.
default_proc_change_state_action() sets pm_cur_state and occurs state_action.
default_proc_change_state() occurs next state action when the specific condition is met.

These functions are added to display-plugin.
- bool display_plugin_state_is_there_proc_change_state(void);
- int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid);

These functions are added to display-state-transition.
- void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout);
- int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid);

Newly added functions should also be refactored.

Change-Id: I85476642bb4b4c4fc5c607ce6ce0591736d1a014
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/ambient-mode.c
src/display/core.h
src/display/display-plugin.c
src/display/display-plugin.h
src/display/display-state-transition.c
src/display/display-state-transition.h

index 5828ccd..c407545 100644 (file)
  * @{
  */
 
-#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
-
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct display_backlight_ops *backlight_ops;
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
-static int default_proc_change_state(unsigned int cond, pid_t pid);
-static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
-
 static struct state states[S_END] = {
        { S_START,    "S_START",    NULL,          NULL,           NULL,          NULL            },
        { S_NORMAL,   "S_NORMAL",   NULL,          NULL,           NULL,          NULL            },
@@ -99,8 +94,6 @@ static struct state states[S_END] = {
        { S_POWEROFF, "S_POWEROFF", NULL,          NULL,           NULL,          NULL            },
 };
 
-#define TIMEOUT_NONE           (-1)
-
 #define DELAYED_INIT_WATING_TIME       60000   /* 1 minute */
 
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
@@ -169,69 +162,6 @@ static const char* __device_flags_to_string(enum device_flags flags)
                return UNKNOWN_STR;
 }
 
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
-       struct state *st;
-
-       set_pm_old_state(get_pm_cur_state());
-       set_pm_cur_state(next);
-
-       st = &states[get_pm_cur_state()];
-
-       if (timeout < 0)
-               display_state_transition_do_state_action(st->timeout);
-       else
-               display_state_transition_do_state_action(timeout);
-
-}
-
-static int default_proc_change_state(unsigned int cond, pid_t pid)
-{
-       enum state_t next;
-
-       next = GET_COND_STATE(cond);
-       _I("Change process(%d) state to %s.", pid, states[next].name);
-
-       switch (next) {
-       case S_NORMAL:
-               if (display_panel_get_dpms_cached_state() != DPMS_ON)
-                       display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
-               display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDDIM:
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDOFF:
-               if (display_panel_get_dpms_cached_state() == DPMS_ON)
-                       display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
-               if (set_custom_lcdon_timeout(0))
-                       display_state_transition_update_display_state_timeout_by_priority();
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_SLEEP:
-               _I("Dangerous requests.");
-               /* at first LCD_OFF and then goto sleep */
-               /* state transition */
-               default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
-               display_lock_release_lock_all(S_NORMAL);
-               display_lock_release_lock_all(S_LCDDIM);
-               display_lock_release_lock_all(S_LCDOFF);
-               if (display_panel_is_lcd_on_state_broadcasted()) {
-                       _I("broadcast lcd off signal at non-lcd device");
-                       broadcast_lcd_off(SIGNAL_PRE, 0);
-                       broadcast_lcd_off(SIGNAL_POST, 0);
-               }
-               default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static void proc_condition_lock(PMMsg *data)
 {
        char pname[PATH_MAX];
@@ -251,7 +181,7 @@ static void proc_condition_lock(PMMsg *data)
 
        if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
            (pm_get_power_lock() == POWER_UNLOCK))
-               proc_change_state(data->cond, INTERNAL_LOCK_PM);
+               display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
 
        ret = display_lock_request_lock(state, pid, data->timeout);
        if (ret == -EALREADY)
@@ -412,7 +342,7 @@ int poll_callback(int condition, PMMsg *data)
                proc_condition(data);
 
                if (IS_COND_REQUEST_CHANGE(data->cond))
-                       proc_change_state(data->cond, data->pid);
+                       display_state_transition_do_proc_change_state(data->cond, data->pid);
        }
 
        return 0;
@@ -559,6 +489,7 @@ static int display_probe(void *data)
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
        dp->is_lcdon_blocked = is_lcdon_blocked;
+       dp->proc_change_state = NULL;
        setup_display_plugin_backlight_ops(dp);
 
        /* check display feature */
index 71fb929..ea1349b 100644 (file)
@@ -79,8 +79,6 @@
  * @{
  */
 
-#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
-
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -88,9 +86,6 @@ static struct display_backlight_ops *backlight_ops;
 
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
-static int default_proc_change_state(unsigned int cond, pid_t pid);
-static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
-
 static struct state states[S_END] = {
        { S_START,    "S_START",    NULL,          NULL,           NULL,          NULL            },
        { S_NORMAL,   "S_NORMAL",   NULL,          NULL,           NULL,          NULL            },
@@ -101,8 +96,6 @@ static struct state states[S_END] = {
        { S_POWEROFF, "S_POWEROFF", NULL,          NULL,           NULL,          NULL            },
 };
 
-#define TIMEOUT_NONE           (-1)
-
 #define DELAYED_INIT_WATING_TIME       60000   /* 1 minute */
 
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
@@ -176,21 +169,6 @@ static const char* __device_flags_to_string(enum device_flags flags)
                return UNKNOWN_STR;
 }
 
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
-       struct state *st;
-
-       set_pm_old_state(get_pm_cur_state());
-       set_pm_cur_state(next);
-
-       st = &states[get_pm_cur_state()];
-
-       if (timeout < 0)
-               display_state_transition_do_state_action(st->timeout);
-       else
-               display_state_transition_do_state_action(timeout);
-}
-
 static int default_proc_change_state(unsigned int cond, pid_t pid)
 {
        enum state_t next;
@@ -203,10 +181,10 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                if (display_panel_get_dpms_cached_state() != DPMS_ON)
                        display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
                display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_LCDDIM:
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_LCDOFF:
                if (display_panel_get_dpms_cached_state() == DPMS_ON) {
@@ -217,13 +195,13 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                }
                if (set_custom_lcdon_timeout(0))
                        display_state_transition_update_display_state_timeout_by_priority();
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_SLEEP:
                _I("Dangerous requests.");
                /* at first LCD_OFF and then goto sleep */
                /* state transition */
-               default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+               display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
                display_lock_release_lock_all(S_LCDOFF);
@@ -232,7 +210,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                        broadcast_lcd_off(SIGNAL_PRE, 0);
                        broadcast_lcd_off(SIGNAL_POST, 0);
                }
-               default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+               display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
                break;
 
        default:
@@ -261,7 +239,7 @@ static void proc_condition_lock(PMMsg *data)
 
        if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
            (pm_get_power_lock() == POWER_UNLOCK))
-               proc_change_state(data->cond, INTERNAL_LOCK_PM);
+               display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
 
        ret = display_lock_request_lock(state, pid, data->timeout);
        if (ret == -EALREADY)
@@ -421,7 +399,7 @@ int poll_callback(int condition, PMMsg *data)
                proc_condition(data);
 
                if (IS_COND_REQUEST_CHANGE(data->cond))
-                       proc_change_state(data->cond, data->pid);
+                       display_state_transition_do_proc_change_state(data->cond, data->pid);
        }
 
        return 0;
@@ -570,6 +548,7 @@ static int display_probe(void *data)
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
        dp->is_lcdon_blocked = is_lcdon_blocked;
+       dp->proc_change_state = default_proc_change_state;
        setup_display_plugin_backlight_ops(dp);
 
        /**
index 223c38e..6609df9 100644 (file)
@@ -77,8 +77,6 @@
  * @{
  */
 
-#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
-
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -86,9 +84,6 @@ static struct display_backlight_ops *backlight_ops;
 
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
-static int default_proc_change_state(unsigned int cond, pid_t pid);
-static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
-
 static struct state states[S_END] = {
        { S_START,    "S_START",    NULL,          NULL,           NULL,          NULL            },
        { S_NORMAL,   "S_NORMAL",   NULL,          NULL,           NULL,          NULL            },
@@ -99,8 +94,6 @@ static struct state states[S_END] = {
        { S_POWEROFF, "S_POWEROFF", NULL,          NULL,           NULL,          NULL            },
 };
 
-#define TIMEOUT_NONE           (-1)
-
 #define DELAYED_INIT_WATING_TIME       60000   /* 1 minute */
 
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
@@ -169,68 +162,6 @@ static const char* __device_flags_to_string(enum device_flags flags)
                return UNKNOWN_STR;
 }
 
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
-       struct state *st;
-
-       set_pm_old_state(get_pm_cur_state());
-       set_pm_cur_state(next);
-
-       st = &states[get_pm_cur_state()];
-
-       if (timeout < 0)
-               display_state_transition_do_state_action(st->timeout);
-       else
-               display_state_transition_do_state_action(timeout);
-}
-
-static int default_proc_change_state(unsigned int cond, pid_t pid)
-{
-       enum state_t next;
-
-       next = GET_COND_STATE(cond);
-       _I("Change process(%d) state to %s.", pid, states[next].name);
-
-       switch (next) {
-       case S_NORMAL:
-               if (display_panel_get_dpms_cached_state() != DPMS_ON)
-                       display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
-               display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDDIM:
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDOFF:
-               if (display_panel_get_dpms_cached_state() == DPMS_ON)
-                       display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
-               if (set_custom_lcdon_timeout(0))
-                       display_state_transition_update_display_state_timeout_by_priority();
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_SLEEP:
-               _I("Dangerous requests.");
-               /* at first LCD_OFF and then goto sleep */
-               /* state transition */
-               default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
-               display_lock_release_lock_all(S_NORMAL);
-               display_lock_release_lock_all(S_LCDDIM);
-               display_lock_release_lock_all(S_LCDOFF);
-               if (display_panel_is_lcd_on_state_broadcasted()) {
-                       _I("broadcast lcd off signal at non-lcd device");
-                       broadcast_lcd_off(SIGNAL_PRE, 0);
-                       broadcast_lcd_off(SIGNAL_POST, 0);
-               }
-               default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static void proc_condition_lock(PMMsg *data)
 {
        char pname[PATH_MAX];
@@ -250,7 +181,7 @@ static void proc_condition_lock(PMMsg *data)
 
        if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
            (pm_get_power_lock() == POWER_UNLOCK))
-               proc_change_state(data->cond, INTERNAL_LOCK_PM);
+               display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
 
        ret = display_lock_request_lock(state, pid, data->timeout);
        if (ret == -EALREADY)
@@ -411,7 +342,7 @@ int poll_callback(int condition, PMMsg *data)
                proc_condition(data);
 
                if (IS_COND_REQUEST_CHANGE(data->cond))
-                       proc_change_state(data->cond, data->pid);
+                       display_state_transition_do_proc_change_state(data->cond, data->pid);
        }
 
        return 0;
@@ -559,6 +490,7 @@ static int display_probe(void *data)
        dp->display_off_by_reason = NULL;
        dp->default_saving_mode = NULL;
        dp->is_lcdon_blocked = is_lcdon_blocked;
+       dp->proc_change_state = NULL;
        setup_display_plugin_backlight_ops(dp);
 
        /**
index e5e7d73..2f4d3f0 100644 (file)
@@ -85,7 +85,6 @@
  * @{
  */
 
-#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
 #define LATE_LCD_TRANSIT               1
 
 extern void init_save_userlock(void);
@@ -106,9 +105,6 @@ static bool lcdon_broadcast = true;
 static int default_trans(int evt);
 static int default_action(int timeout);
 
-static int default_proc_change_state(unsigned int cond, pid_t pid);
-static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
-
 static struct state states[S_END] = {
        { S_START,    "S_START",    NULL,          NULL,           NULL,          NULL            },
        { S_NORMAL,   "S_NORMAL",   default_trans, default_action, NULL,          NULL            },
@@ -119,8 +115,6 @@ static struct state states[S_END] = {
        { S_POWEROFF, "S_POWEROFF", NULL,          NULL,           NULL,          NULL            },
 };
 
-#define TIMEOUT_NONE           (-1)
-
 #define DELAYED_INIT_WATING_TIME       60000   /* 1 minute */
 
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
@@ -587,23 +581,6 @@ int display_off_by_reason(const char *reason)
        return 0;
 }
 
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
-       struct state *st;
-
-       set_pm_old_state(get_pm_cur_state());
-       set_pm_cur_state(next);
-
-       st = &states[get_pm_cur_state()];
-
-       if (st && st->action) {
-               if (timeout < 0)
-                       st->action(st->timeout);
-               else
-                       st->action(timeout);
-       }
-}
-
 static int default_proc_change_state(unsigned int cond, pid_t pid)
 {
        enum state_t next;
@@ -616,23 +593,23 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                if (check_lcd_is_on() == false)
                        display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
                display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_LCDDIM:
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_LCDOFF:
                if (display_panel_get_dpms_cached_state() == DPMS_ON)
                        lcd_off_procedure(LCD_OFF_BY_EVENT);
                if (set_custom_lcdon_timeout(0))
                        display_state_transition_update_display_state_timeout_by_priority();
-               default_proc_change_state_action(next, -1);
+               display_state_transition_do_proc_change_state_action(next, -1);
                break;
        case S_SLEEP:
                _I("Dangerous requests.");
                /* at first LCD_OFF and then goto sleep */
                /* state transition */
-               default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+               display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
                display_lock_release_lock_all(S_NORMAL);
                display_lock_release_lock_all(S_LCDDIM);
                display_lock_release_lock_all(S_LCDOFF);
@@ -641,7 +618,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                        broadcast_lcd_off(SIGNAL_PRE, 0);
                        broadcast_lcd_off(SIGNAL_POST, 0);
                }
-               default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+               display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
                break;
 
        default:
@@ -670,7 +647,7 @@ static void proc_condition_lock(PMMsg *data)
 
        if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
            (pm_get_power_lock() == POWER_UNLOCK))
-               proc_change_state(data->cond, INTERNAL_LOCK_PM);
+               display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
 
        ret = display_lock_request_lock(state, pid, data->timeout);
        if (ret == -EALREADY)
@@ -1044,7 +1021,7 @@ int poll_callback(int condition, PMMsg *data)
                proc_condition(data);
 
                if (IS_COND_REQUEST_CHANGE(data->cond))
-                       proc_change_state(data->cond, data->pid);
+                       display_state_transition_do_proc_change_state(data->cond, data->pid);
        }
 
        return 0;
@@ -1282,6 +1259,7 @@ static int display_probe(void *data)
        dp->display_off_by_reason = display_off_by_reason;
        dp->default_saving_mode = default_saving_mode;
        dp->is_lcdon_blocked = is_lcdon_blocked;
+       dp->proc_change_state = default_proc_change_state;
        setup_display_plugin_backlight_ops(dp);
 
        /**
index 16573e2..79b000a 100644 (file)
@@ -44,7 +44,6 @@
 #define CLOCK_START                    "clockstart"
 #define CLOCK_END                      "clockend"
 #define CLOCK_CHANGED                  "clockchanged"
-#define TIMEOUT_NONE                   (-1)
 #define AMBIENT_CLOCK_WAITING_TIME     5000 /* ms */
 
 static struct display_plugin *disp_plgn;
index 4b8d73a..79679ad 100644 (file)
@@ -36,6 +36,8 @@
 #define MASK_OFF    0x4                /* 100 */
 
 #define DEFAULT_NORMAL_TIMEOUT 30
+#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
+#define TIMEOUT_NONE           (-1)
 
 #define DIM_MASK               0x000f0000
 #define MASK32                 0xffffffff
index e5df386..cd74cee 100644 (file)
@@ -297,6 +297,19 @@ int display_plugin_state_get_state_by_state_index(int state_index, enum state_t
        return -EOPNOTSUPP;
 }
 
+bool display_plugin_state_is_there_proc_change_state(void)
+{
+       return (g_display_plugin.proc_change_state != NULL);
+}
+
+int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid)
+{
+       if (!g_display_plugin.proc_change_state)
+               return -EOPNOTSUPP;
+
+       return g_display_plugin.proc_change_state(cond, pid);
+}
+
 int display_plugin_config_get_timeout_enable(bool *timeout_enable)
 {
        if (!timeout_enable)
index b2f3478..c61a156 100644 (file)
@@ -75,6 +75,7 @@ struct display_plugin {
        int (*display_off_by_reason) (const char *reason);
        void (*default_saving_mode) (int onoff);
        int (*is_lcdon_blocked) (void);
+       int (*proc_change_state) (unsigned int cond, pid_t pid);
 
        struct display_config *config;
        struct display_backlight_ops *backlight;
@@ -117,6 +118,9 @@ int display_plugin_state_get_name(enum state_t state, const char **state_name);
 int display_plugin_state_set_timeout(enum state_t state, int state_timeout);
 int display_plugin_state_get_timeout(enum state_t state, int *state_timeout);
 int display_plugin_state_get_state_by_state_index(int state_index, enum state_t *state);
+/* FIXME: This function used in the display lock related functions */
+bool display_plugin_state_is_there_proc_change_state(void);
+int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid);
 
 /* FIXME: display config getter/setter is also temporary in this file */
 int display_plugin_config_get_timeout_enable(bool *timeout_enable);
index d633e78..4523f95 100644 (file)
@@ -27,6 +27,7 @@
 #include "display-state-transition.h"
 #include "display-lock.h"
 #include "display-plugin.h"
+#include "display-signal.h"
 #include "extcon/extcon.h"
 #include "power/power.h"
 #include "power/power-suspend.h"
@@ -526,3 +527,74 @@ go_lcd_off:
        }
        return 0;
 }
+
+/* FIXME: this function is temporary, it will be refactored */
+void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout)
+{
+       int state_timeout = 0;
+
+       set_pm_old_state(get_pm_cur_state());
+       set_pm_cur_state(next);
+
+       display_plugin_state_get_timeout(get_pm_cur_state(), &state_timeout);
+
+       if (timeout < 0)
+               display_state_transition_do_state_action(state_timeout);
+       else
+               display_state_transition_do_state_action(timeout);
+
+}
+
+/* FIXME: this function is temporary, it will be refactored */
+int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid)
+{
+       enum state_t next;
+       const char *state_name = NULL;
+
+       if (display_plugin_state_is_there_proc_change_state())
+               return display_plugin_state_proc_change_state(cond, pid);
+
+       next = GET_COND_STATE(cond);
+       display_plugin_state_get_name(next, &state_name);
+       _I("Change process(%d) state to %s.", pid, state_name);
+
+       switch (next) {
+       case S_NORMAL:
+               if (display_panel_get_dpms_cached_state() != DPMS_ON)
+                       display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
+               display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
+               display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+               break;
+       case S_LCDDIM:
+               display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+               break;
+       case S_LCDOFF:
+               if (display_panel_get_dpms_cached_state() == DPMS_ON)
+                       display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
+               if (set_custom_lcdon_timeout(0))
+                       display_state_transition_update_display_state_timeout_by_priority();
+               display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+               break;
+       case S_SLEEP:
+               _I("Dangerous requests.");
+               /* at first LCD_OFF and then goto sleep */
+               /* state transition */
+               display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+               display_lock_release_lock_all(S_NORMAL);
+               display_lock_release_lock_all(S_LCDDIM);
+               display_lock_release_lock_all(S_LCDOFF);
+               if (display_panel_is_lcd_on_state_broadcasted()) {
+                       _I("broadcast lcd off signal at non-lcd device");
+                       broadcast_lcd_off(SIGNAL_PRE, 0);
+                       broadcast_lcd_off(SIGNAL_POST, 0);
+               }
+               display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
index ee1955a..d51199f 100644 (file)
@@ -44,5 +44,7 @@ bool display_state_transition_is_possible_to_go_lcdoff(void);
 int display_state_transition_do_state_transition(enum state_t state, int evt_type);
 bool display_state_transition_is_display_state_support_transition(enum state_t state);
 int display_state_transition_do_state_action(int timeout);
+void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout);
+int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid);
 
 #endif /* __DISPLAY_STATE_TRANSITION_H__ */
\ No newline at end of file