display: Remove plugin initialized display states 94/313094/2
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 19 Jun 2024 02:03:05 +0000 (11:03 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 19 Jun 2024 05:06:00 +0000 (14:06 +0900)
The core operations has changed to only work on top of default states.
Only wearable is working with its own states but it can figure out
the states by its plugin functions internally regardless of the default
states. Likewise, the core operations are not using the plugin states
if it works in a default way. Therefore, as the deviced core states
and plugin states are totally working independently, the deviced core
has changed not to manage plugin states.

Change-Id: I3e08d77285bfb87a8be0925548b0987b3f78e2cd
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
plugins/wearable/display/powersaver.c
src/display/display-lock.c
src/display/display-misc.c
src/display/display-plugin.c
src/display/display-plugin.h
src/display/display-state-transition.c
src/display/display-state-transition.h
src/display/display.c

index 59e7c8d5575acb9c0e68ad3039b9b891bfa411af..46d7641a49854606da69d358c1c2c1674dc37fa7 100644 (file)
 
 static struct display_plugin *disp_plgn;
 
-static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_DIM,   "SYSCOMMON_DEVICED_DISPLAY_STATE_DIM",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_OFF,   "SYSCOMMON_DEVICED_DISPLAY_STATE_OFF",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP,    "SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP",    NULL,          NULL,           NULL,          NULL            },
-};
-
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
 #define LONG_PRESS_INTERVAL             400       /* 0.4 seconds */
 #define SAMPLING_INTERVAL              1       /* 1 sec */
@@ -129,17 +121,6 @@ inline const struct syscommon_deviced_display_config* get_var_display_config()
        return &display_conf;
 }
 
-inline struct syscommon_deviced_display_state_info* state_st(enum syscommon_deviced_display_state state)
-{
-       return &states[state];
-}
-
-static void init_display_states(void *data)
-{
-       struct display_plugin *dp = (struct display_plugin *) data;
-       for(int i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; i++)
-               dp->display_states[i] = &states[i];
-}
 /**
  * Power manager Main
  *
@@ -149,7 +130,6 @@ static int display_probe(void *data)
        struct display_plugin *dp = (struct display_plugin *) data;
        assert(dp);
 
-       init_display_states(dp);
        dp->proc_change_state = NULL;
 
        return 0;
index 2e3af290a4771bcb0a1b5f01288d9144772ec893..001b24689780d41596d831c761f04a5c5e5a5371 100644 (file)
 
 static struct display_plugin *disp_plgn;
 
-static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_DIM,   "SYSCOMMON_DEVICED_DISPLAY_STATE_DIM",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_OFF,   "SYSCOMMON_DEVICED_DISPLAY_STATE_OFF",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP,    "SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP",    NULL,          NULL,           NULL,          NULL            },
-};
-
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
 #define LONG_PRESS_INTERVAL             2       /* 2 seconds */
 #define SAMPLING_INTERVAL              1       /* 1 sec */
@@ -128,17 +120,6 @@ inline const struct syscommon_deviced_display_config* get_var_display_config()
        return &display_conf;
 }
 
-inline struct syscommon_deviced_display_state_info* state_st(enum syscommon_deviced_display_state state)
-{
-       return &states[state];
-}
-
-static void init_display_states(void *data)
-{
-       struct display_plugin *dp = (struct display_plugin *) data;
-       for(int i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; i++)
-               dp->display_states[i] = &states[i];
-}
 /**
  * Power manager Main
  *
@@ -148,7 +129,6 @@ static int display_probe(void *data)
        struct display_plugin *dp = (struct display_plugin *) data;
        assert(dp);
 
-       init_display_states(dp);
        dp->proc_change_state = NULL;
 
        return 0;
index e4035348215aa0ef9721688aa7eb7ad919fbb42c..623cb21b12416411edf2a4910c23b729acceeaef 100644 (file)
@@ -101,8 +101,9 @@ static bool lcdon_broadcast = true;
 /* default transition, action fuctions */
 static int default_trans(int evt);
 static int default_action(int timeout);
+int wearable_default_trans(enum syscommon_deviced_display_state state, int evt);
 
-static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
+struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
        { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
        { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   default_trans, default_action, NULL,          NULL            },
        { SYSCOMMON_DEVICED_DISPLAY_STATE_DIM,   "SYSCOMMON_DEVICED_DISPLAY_STATE_DIM",   default_trans, default_action, NULL,          NULL            },
@@ -110,6 +111,18 @@ static struct syscommon_deviced_display_state_info states[SYSCOMMON_DEVICED_DISP
        { SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP,    "SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP",    default_trans, default_action, NULL,          NULL            },
 };
 
+int wearable_default_trans(enum syscommon_deviced_display_state state, int evt)
+{
+       return states[state].trans(evt);
+}
+
+int wearable_state_set_timeout(enum syscommon_deviced_display_state state, int timeout)
+{
+       states[state].timeout = timeout;
+
+       return 0;
+}
+
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
 #define LONG_PRESS_INTERVAL             500       /* 0.5 seconds */
 #define SAMPLING_INTERVAL              1       /* 1 sec */
@@ -833,12 +846,6 @@ static void init_lcd_operation(void)
                display_register_dependent_device(ops);
 }
 
-static void init_display_states(void *data)
-{
-       struct display_plugin *dp = (struct display_plugin *) data;
-       for(int i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; i++)
-               dp->display_states[i] = &states[i];
-}
 /**
  * Power manager Main
  *
@@ -848,7 +855,6 @@ static int display_probe(void *data)
        struct display_plugin *dp = (struct display_plugin *) data;
        assert(dp);
 
-       init_display_states(dp);
        /**
         * FIXME: They should be connected via plugin interfaces
         *
index 4246739f6121f68a48e7b32608701059b5b8af4e..8d544586e1355c203eb2a914190c478bf6d9fb32 100644 (file)
@@ -31,6 +31,9 @@
 #include "powersaver.h"
 #include "setting.h"
 
+extern int wearable_default_trans(enum syscommon_deviced_display_state state, int evt);
+extern int wearable_state_set_timeout(enum syscommon_deviced_display_state state, int timeout);
+
 static int set_powersaver_mode(int mode)
 {
        int timeout;
@@ -56,8 +59,8 @@ static int set_powersaver_mode(int mode)
        display_backlight_update_by_default_brightness();
        get_run_timeout(&timeout);
 
-       display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, timeout);
-       display_plugin_state_do_default_trans(get_pm_cur_state(), EVENT_INPUT);
+       wearable_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, timeout);
+       wearable_default_trans(get_pm_cur_state(), EVENT_INPUT);
 
        return 0;
 }
index ab71f19270a2d9423f23cfb71380dcd0421394b3..e04648cf6e6da8dff85158bcbb92d84ebb1c2608 100644 (file)
@@ -282,7 +282,7 @@ static void broadcast_lock_watchdog_expired(pid_t pid, enum syscommon_deviced_di
        time(&now);
        diff = difftime(now, locktime);
 
-       display_plugin_state_get_name(state, &state_name);
+       display_state_get_name(state, &state_name);
        CRITICAL_LOG("%s(%d) has held %s lock for a long time(%.0f s).",
                        appid ? appid : "NULL", pid, state_name + 2, diff);
 
@@ -389,7 +389,7 @@ static gboolean lock_expired_callback(gpointer data)
 
        dl = (struct display_lock *) data;
 
-       display_plugin_state_get_name(dl->state, &stname);
+       display_state_get_name(dl->state, &stname);
        _I("Display lock expired, state=%s pid=%d", stname, dl->pid);
 
        if (dl->state == SYSCOMMON_DEVICED_DISPLAY_STATE_OFF)
@@ -583,7 +583,7 @@ static void print_lock_info(gpointer data, gpointer udata)
 
        display_misc_get_process_name((pid_t)dl->pid, pname);
        ctime_r(&dl->time, time);
-       display_plugin_state_get_name(dl->state, &stname);
+       display_state_get_name(dl->state, &stname);
 
        snprintf(buf, sizeof(buf), " %d: [%s] locked by pid %d %s %s\n", *index, stname, dl->pid, pname, time);
        ret = write(fd, buf, strlen(buf));
@@ -649,7 +649,7 @@ static void proc_condition_lock(PMMsg *data)
        if (state == SYSCOMMON_DEVICED_DISPLAY_STATE_OFF)
                set_process_active(true, pid);
 
-       display_plugin_state_get_name(state, &state_name);
+       display_state_get_name(state, &state_name);
        _I("[%s] locked by %5d with %u ms", state_name, pid, data->timeout);
 
        if (pid < DEVICED_EVENT_BASE) {
@@ -702,7 +702,7 @@ static void proc_condition_unlock(PMMsg *data)
        if (state == SYSCOMMON_DEVICED_DISPLAY_STATE_OFF)
                set_process_active(false, pid);
 
-       display_plugin_state_get_name(state, &state_name);
+       display_state_get_name(state, &state_name);
        _I("[%s] unlocked by %5d", state_name, pid);
 
        if (pid < DEVICED_EVENT_BASE) {
@@ -759,12 +759,12 @@ int display_lock_proc_condition(PMMsg *data)
        if (flags == 0) {
                /* guard time for suspend */
                if (current == SYSCOMMON_DEVICED_DISPLAY_STATE_OFF) {
-                       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &timeout);
+                       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &timeout);
                        display_state_transition_reset_state_transition_timeout(timeout);
                }
        } else {
                if (flags & PM_FLAG_RESET_TIMER) {
-                       display_plugin_state_get_timeout(current, &timeout);
+                       display_state_get_timeout(current, &timeout);
                        display_state_transition_reset_state_transition_timeout(timeout);
                }
        }
index 05c73aa3ca2a59d60eb28ecfb239db544ffb339e..50c0256f2eee05d43e4be6d3980c961666c7de08 100644 (file)
@@ -170,9 +170,9 @@ static void print_info(int fd)
        const char *current_state_name;
        enum syscommon_deviced_display_state current;
 
-       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_timeout);
-       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_timeout);
-       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &off_stata_timeout);
+       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_timeout);
+       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_timeout);
+       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &off_stata_timeout);
 
        if (fd < 0)
                return;
@@ -189,9 +189,9 @@ static void print_info(int fd)
        if (ret < 0)
                _E("Write() failed: %d", errno);
 
-       display_plugin_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_name);
-       display_plugin_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_name);
-       display_plugin_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &off_state_name);
+       display_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_name);
+       display_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_name);
+       display_state_get_name(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, &off_state_name);
        snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
                 (display_lock_is_state_locked(SYSCOMMON_DEVICED_DISPLAY_STATE_ON)) ? normal_state_name : "-",
                 (display_lock_is_state_locked(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM)) ? dim_state_name : "-",
@@ -202,7 +202,7 @@ static void print_info(int fd)
 
        ret = display_state_get_current(&current);
        if (ret == 0) {
-               display_plugin_state_get_name(current, &current_state_name);
+               display_state_get_name(current, &current_state_name);
                snprintf(buf, sizeof(buf), "Current State: %s\n", current_state_name);
                ret = write(fd, buf, strlen(buf));
                if (ret < 0)
index 1e7da7109c84b8e6f716252a2ba0dd2b16fdba57..503d8904f5b7fe999b9504bb66b83f5355325f0a 100644 (file)
 struct display_plugin g_display_plugin;
 
 /* FIXME: Below functions are temorary to separtate display state transition functions */
-int display_plugin_state_do_default_trans(enum syscommon_deviced_display_state state, int evt)
-{
-       if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->trans)
-               return g_display_plugin.display_states[state]->trans(evt);
-
-       return -EOPNOTSUPP;
-}
-
-bool display_plugin_state_is_there_default_trans(enum syscommon_deviced_display_state state)
-{
-       if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->trans)
-               return true;
-
-       return false;
-}
-
-int display_plugin_state_get_name(enum syscommon_deviced_display_state state, const char **state_name)
-{
-       if (!state_name)
-               return -EINVAL;
-
-       if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->name) {
-               *state_name = g_display_plugin.display_states[state]->name;
-               return 0;
-       }
-
-       *state_name = NULL;
-       return -EOPNOTSUPP;
-}
-
-int display_plugin_state_set_timeout(enum syscommon_deviced_display_state state, int state_timeout)
-{
-       if (g_display_plugin.display_states[state]) {
-               g_display_plugin.display_states[state]->timeout = state_timeout;
-               return 0;
-       }
-
-       return -EOPNOTSUPP;
-}
-
-int display_plugin_state_get_timeout(enum syscommon_deviced_display_state state, int* state_timeout)
-{
-       if (!state_timeout)
-               return -EINVAL;
-
-       if (g_display_plugin.display_states[state]) {
-               *state_timeout = g_display_plugin.display_states[state]->timeout;
-               return 0;
-       }
-
-       return -EOPNOTSUPP;
-}
-
-int display_plugin_state_get_state_by_state_index(int state_index, enum syscommon_deviced_display_state *state)
-{
-       if (!state)
-               return -EINVAL;
-
-       if (g_display_plugin.display_states[state_index]) {
-               *state = g_display_plugin.display_states[state_index]->state;
-               return 0;
-       }
-
-       return -EOPNOTSUPP;
-}
 
 bool display_plugin_state_is_there_proc_change_state(void)
 {
index b942e5d4c9c95f847ebc8ddde15d4b9c3712ce6c..e8261cfc912ee8f594690cfdf02269e2a5fd890a 100644 (file)
 
 struct display_plugin {
        int (*proc_change_state) (unsigned int cond, pid_t pid);
-
-       struct syscommon_deviced_display_state_info* display_states[SYSCOMMON_DEVICED_DISPLAY_STATE_END];
 };
 extern struct display_plugin g_display_plugin;
 
-/* FIXME: function names will be redefined */
-int display_plugin_state_do_default_trans(enum syscommon_deviced_display_state state, int evt);
-bool display_plugin_state_is_there_default_trans(enum syscommon_deviced_display_state state);
-int display_plugin_state_get_name(enum syscommon_deviced_display_state state, const char **state_name);
-int display_plugin_state_set_timeout(enum syscommon_deviced_display_state state, int state_timeout);
-int display_plugin_state_get_timeout(enum syscommon_deviced_display_state state, int *state_timeout);
-int display_plugin_state_get_state_by_state_index(int state_index, enum syscommon_deviced_display_state *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);
index 289d3c6f5aa26d5cdf2ef22879c677b8b02fc85e..af70bf60b546c208b3efe54a65a241b32a73b608 100644 (file)
@@ -60,6 +60,16 @@ static int trans_table[SYSCOMMON_DEVICED_DISPLAY_STATE_END][EVENT_END] = {
        { SYSCOMMON_DEVICED_DISPLAY_STATE_OFF,   SYSCOMMON_DEVICED_DISPLAY_STATE_ON   }, /* SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP */
 };
 
+struct syscommon_deviced_display_state_info g_display_states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = { 0, };
+static struct syscommon_deviced_display_state_info default_states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
+       { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
+       { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
+       { SYSCOMMON_DEVICED_DISPLAY_STATE_DIM,   "SYSCOMMON_DEVICED_DISPLAY_STATE_DIM",   NULL,          NULL,           NULL,          NULL            },
+       { SYSCOMMON_DEVICED_DISPLAY_STATE_OFF,   "SYSCOMMON_DEVICED_DISPLAY_STATE_OFF",   NULL,          NULL,           NULL,          NULL            },
+       { SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP,    "SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP",    NULL,          NULL,           NULL,          NULL            },
+};
+
+
 static int display_state_transition_do_state_action(int timeout);
 
 static bool is_display_state_valid(enum syscommon_deviced_display_state display_state)
@@ -324,6 +334,13 @@ int display_state_transition_set_transition_table_display_state(enum syscommon_d
        return 0;
 }
 
+int display_state_get_name(enum syscommon_deviced_display_state state, const char **name)
+{
+       *name = default_states[state].name;
+
+       return 0;
+}
+
 static void remove_state_transition(void)
 {
        if (state_transition_timer_id) {
@@ -335,7 +352,7 @@ static void remove_state_transition(void)
 static gboolean state_transition_timeout_handler(void *data)
 {
        const char *state_name = NULL;
-       display_plugin_state_get_name(current, &state_name);
+       display_state_get_name(current, &state_name);
        _I("Time out state %s", state_name);
 
        remove_state_transition();
@@ -386,7 +403,7 @@ int display_state_transition_set_custom_timeout(enum syscommon_deviced_display_s
                custom_dim_timeout = timeout;
                break;
        default:
-               display_plugin_state_get_name(state, &state_name);
+               display_state_get_name(state, &state_name);
                _W("%s state has no custom timeout", state_name);
                return -EPERM;
        }
@@ -409,7 +426,7 @@ int display_state_transition_get_custom_timeout(enum syscommon_deviced_display_s
                break;
        default:
                *timeout = 0;
-               display_plugin_state_get_name(state, &state_name);
+               display_state_get_name(state, &state_name);
                _W("There is no specific timeout value for %s state", state_name);
        }
        return 0;
@@ -437,6 +454,20 @@ void display_state_transition_update_lock_screen_timeout(int timeout)
        display_state_transition_update_display_state_timeout_by_priority();
 }
 
+int display_state_get_timeout(enum syscommon_deviced_display_state state, int *timeout)
+{
+       *timeout = g_display_states[state].timeout;
+
+       return 0;
+}
+
+int display_state_set_timeout(enum syscommon_deviced_display_state state, int timeout)
+{
+       g_display_states[state].timeout = timeout;
+       
+       return 0;
+}
+
 void display_state_transition_update_display_state_timeout_by_priority(void)
 {
        int run_timeout, val;
@@ -446,8 +477,8 @@ void display_state_transition_update_display_state_timeout_by_priority(void)
 
        /* first priority : custom timeout */
        if (custom_normal_timeout > 0) {
-               display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, custom_normal_timeout);
-               display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, custom_dim_timeout);
+               display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, custom_normal_timeout);
+               display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, custom_dim_timeout);
                _I("CUSTOM : timeout is set by normal(%u ms), dim(%u ms)",
                    custom_normal_timeout, custom_dim_timeout);
                return;
@@ -457,7 +488,7 @@ void display_state_transition_update_display_state_timeout_by_priority(void)
        if ((get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
            !get_lock_screen_bg_state()) {
                /* timeout is different according to key or event. */
-               display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, lock_screen_timeout);
+               display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, lock_screen_timeout);
                _I("LOCK: Timeout(%d ms) is set by normal.",
                    lock_screen_timeout);
                return;
@@ -475,13 +506,13 @@ void display_state_transition_update_display_state_timeout_by_priority(void)
                _I("LCD always on.");
        }
 
-       display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, run_timeout);
+       display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, run_timeout);
 
        get_dim_timeout(&val);
-       display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, val);
+       display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, val);
 
-       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_timeout);
-       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_timeout);
+       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &normal_state_timeout);
+       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, &dim_state_timeout);
        _I("Normal: NORMAL timeout is set by %d ms", normal_state_timeout);
        _I("Normal: DIM timeout is set by %d ms", dim_state_timeout);
 }
@@ -594,16 +625,13 @@ int display_state_transition_do_state_transition(enum syscommon_deviced_display_
        if (!display_state_transition_is_display_state_support_transition(state))
                return -EPERM;
 
-       if (display_plugin_state_is_there_default_trans(state))
-               return display_plugin_state_do_default_trans(state, evt_type);
-
        display_state_transition_get_next_transition_display_state(current, &next_state, evt_type);
 
        /* check conditions */
        ret = display_state_transition_check_state_transition_condition(current, next_state);
        if (ret < 0) {
-               display_plugin_state_get_name(current, &current_state_name);
-               display_plugin_state_get_name(next_state, &next_state_name);
+               display_state_get_name(current, &current_state_name);
+               display_state_get_name(next_state, &next_state_name);
                /* There is a condition. */
                _I("%s locked. Trans to %s failed.", current_state_name, next_state_name);
                return -EPERM;
@@ -630,7 +658,7 @@ int display_state_transition_do_state_transition(enum syscommon_deviced_display_
                        (syscommon_is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
-                       display_plugin_state_get_timeout(current, &timeout);
+                       display_state_get_timeout(current, &timeout);
                        display_state_transition_do_state_action(timeout);
                }
        }
@@ -711,7 +739,7 @@ static int display_state_transition_do_state_action(int timeout)
                        time(&last_update_time);
                        last_timeout = timeout;
                } else {
-                       display_plugin_state_get_name(current, &state_name);
+                       display_state_get_name(current, &state_name);
                        _I("Timout set: %s state %d ms", state_name, timeout);
                }
        }
@@ -733,7 +761,7 @@ static int display_state_transition_do_state_action(int timeout)
        if ((previous == SYSCOMMON_DEVICED_DISPLAY_STATE_ON) && (current != SYSCOMMON_DEVICED_DISPLAY_STATE_ON)) {
                time(&now);
                diff = difftime(now, last_update_time);
-               display_plugin_state_get_name(current, &state_name);
+               display_state_get_name(current, &state_name);
                _I("SYSCOMMON_DEVICED_DISPLAY_STATE_ON is changed to %s (timeout=%d ms diff=%.0f s).",
                        state_name, last_timeout, diff);
        }
@@ -832,7 +860,7 @@ void display_state_transition_do_proc_change_state_action(enum syscommon_deviced
        previous = current;
        current = next;
 
-       display_plugin_state_get_timeout(current, &state_timeout);
+       display_state_get_timeout(current, &state_timeout);
 
        if (timeout < 0)
                display_state_transition_do_state_action(state_timeout);
@@ -861,7 +889,7 @@ int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid)
                return display_plugin_state_proc_change_state(cond, pid);
 
        next = GET_COND_STATE(cond);
-       display_plugin_state_get_name(next, &state_name);
+       display_state_get_name(next, &state_name);
        _I("Change process(%d) state to %s.", pid, state_name);
 
        switch (next) {
@@ -933,3 +961,17 @@ int display_state_transition_request_state_transition_with_option(pid_t pid, int
 
        return 0;
 }
+
+int display_state_load_state_info(void)
+{
+       int ret;
+
+       ret = syscommon_plugin_deviced_display_load_state_info(g_display_states);
+       if (ret == -ENOTSUP || ret == EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend");
+               for (int i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; ++i)
+                       g_display_states[i] = default_states[i];
+       }
+
+       return 0;
+}
index 957c42ae75e8ac8e32469f9e30a15b5c2a51eb72..e877391632bfaebfd5f33f43e47498923771b596 100644 (file)
 
 #define LOCK_SCREEN_INPUT_TIMEOUT      10000
 
+/**
+ * FIXME: Add getter/setter for this and hide it into source code
+ */
+extern struct syscommon_deviced_display_state_info
+g_display_states[SYSCOMMON_DEVICED_DISPLAY_STATE_END];
+
+int display_state_load_state_info(void);
+int display_state_get_name(enum syscommon_deviced_display_state state, const char **name);
 int display_state_set_current(enum syscommon_deviced_display_state state, enum deviced_event event);
 int display_state_get_current(enum syscommon_deviced_display_state *state);
 int display_state_get_previous(enum syscommon_deviced_display_state *state);
 
+int display_state_get_timeout(enum syscommon_deviced_display_state state, int *timeout);
+int display_state_set_timeout(enum syscommon_deviced_display_state state, int timeout);
 int display_state_transition_get_next_transition_display_state(enum syscommon_deviced_display_state from_state, enum syscommon_deviced_display_state *to_state, int evt_type);
 int display_state_transition_set_transition_table_display_state(enum syscommon_deviced_display_state display_state, enum syscommon_deviced_display_state set_state, int evt_type);
 bool display_state_transition_is_there_state_transition_timer(void);
index afedd0b5cba28c7c4ecc59d8b65617dfce64b45e..7f1864bf2ac690a3a82920fbc6997bb97761f1b9 100644 (file)
@@ -50,14 +50,6 @@ static enum syscommon_deviced_display_orientation g_display_init_direction;
 static bool g_display_hal_backend_available = false;
 static GList *display_dependent_device_ops;
 static enum device_ops_status display_ops_status = DEVICE_OPS_STATUS_UNINIT;
-static struct syscommon_deviced_display_state_info default_states[SYSCOMMON_DEVICED_DISPLAY_STATE_END] = {
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_START,    "SYSCOMMON_DEVICED_DISPLAY_STATE_START",    NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_ON,   "SYSCOMMON_DEVICED_DISPLAY_STATE_ON",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_DIM,   "SYSCOMMON_DEVICED_DISPLAY_STATE_DIM",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_OFF,   "SYSCOMMON_DEVICED_DISPLAY_STATE_OFF",   NULL,          NULL,           NULL,          NULL            },
-       { SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP,    "SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP",    NULL,          NULL,           NULL,          NULL            },
-};
-
 extern void init_save_userlock(void);
 
 inline unsigned int get_pm_status_flag(void)
@@ -158,13 +150,12 @@ bool display_dimstay_check(void)
 
 int display_initialize_display_state_timeout_from_setting(void)
 {
-       int i;
        int val = 0;
        const char* state_name = NULL;
-       enum syscommon_deviced_display_state state = SYSCOMMON_DEVICED_DISPLAY_STATE_START;
+       enum syscommon_deviced_display_state state;
 
-       for (i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; i++) {
-               display_plugin_state_get_state_by_state_index(i, &state);
+       for (state = SYSCOMMON_DEVICED_DISPLAY_STATE_START;
+                       state < SYSCOMMON_DEVICED_DISPLAY_STATE_END; ++state) {
                switch (state) {
                case SYSCOMMON_DEVICED_DISPLAY_STATE_ON:
                        get_run_timeout(&val);
@@ -181,10 +172,10 @@ int display_initialize_display_state_timeout_from_setting(void)
                        break;
                }
                if (val > 0) {
-                       display_plugin_state_set_timeout(i, val);
+                       display_state_set_timeout(state, val);
                }
 
-               display_plugin_state_get_name(i, &state_name);
+               display_state_get_name(state, &state_name);
                _I("State(%s) timeout(%d) ms", state_name, val);
        }
 
@@ -301,7 +292,7 @@ static gboolean delayed_dpms_init_done(gpointer data)
                display_panel_lcd_on_procedure(LCD_NORMAL, DEVICED_EVENT_DEVICE_READY);
                display_config_get_timeout_enable(&timeout_enable);
                if (timeout_enable) {
-                       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &timeout);
+                       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &timeout);
                        /* check minimun lcd on time */
                        if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
                                timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
@@ -383,7 +374,7 @@ void display_set_initial_lockscreen_status(void)
        set_lock_screen_state(lock_state);
        display_state_transition_get_lock_screen_timeout(&lock_screen_timeout);
        if (lock_state == VCONFKEY_IDLE_LOCK) {
-               display_plugin_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, lock_screen_timeout);
+               display_state_set_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, lock_screen_timeout);
                _I("LCD NORMAL timeout(%d ms) is set for lock screen.", lock_screen_timeout);
        }
 }
@@ -529,9 +520,7 @@ static int display_probe(void *data)
                }
        }
 
-       for (int i = 0; i < SYSCOMMON_DEVICED_DISPLAY_STATE_END; ++i)
-               if (!g_display_plugin.display_states[i])
-                       g_display_plugin.display_states[i] = &default_states[i];
+       display_state_load_state_info();
 
        ret = display_load_config();
        if (ret < 0)
@@ -564,7 +553,6 @@ static void display_init(void *data)
        unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
        enum syscommon_deviced_display_state current;
 
-
        g_unix_signal_add(SIGHUP, handle_sighup, (gpointer) SIGHUP);
 
        if (display_plugin_device_ops && display_plugin_device_ops->init)
@@ -668,7 +656,7 @@ static void display_init(void *data)
 
                display_set_display_ops_status(DEVICE_OPS_STATUS_START);
                if (timeout_enable) {
-                       display_plugin_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &timeout);
+                       display_state_get_timeout(SYSCOMMON_DEVICED_DISPLAY_STATE_ON, &timeout);
                        /* check minimun lcd on time */
                        if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) {
                                timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);