display: Add default intializer for display_state 25/297725/3
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 23 Aug 2023 07:40:09 +0000 (16:40 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 23 Aug 2023 10:50:52 +0000 (10:50 +0000)
Change-Id: I2b8ba55f5a044b83ce0f37ff9454bffd14d9ee0e
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot-headed/display/core.c
src/display/display.c

index fc5c02e392928540257b4907b828e8b3896a94aa..ef9245c1401c2755d1b56554f79cc27c3b597d55 100644 (file)
  * @{
  */
 
-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 */
@@ -106,17 +98,6 @@ const struct syscommon_deviced_display_config* get_var_display_config(void)
        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
  *
@@ -127,7 +108,6 @@ static int display_probe(void *data)
        assert(dp);
 
        dp->config = &display_conf;
-       init_display_states(dp);
        dp->set_dim_state = NULL;
        dp->get_device_flags = NULL;
        dp->lcd_on_procedure = NULL;
index 39efce27fd1f4c18b86a799bfea4afc2ddb69c05..e1f3e09a5ee9c95ee5e50bd2c0695c9276bb30b8 100644 (file)
@@ -50,6 +50,13 @@ 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);
 
@@ -500,6 +507,10 @@ static int display_probe(void *data)
        if (ret < 0)
                return ret;
 
+       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];
+
        if (!g_display_plugin.config) {
                ret = syscommon_plugin_deviced_display_load_config(&g_display_plugin.config);
                if (ret < 0)