display: Remove get_lcd_timeout_from_settings() 87/293487/6
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 30 May 2023 05:49:57 +0000 (14:49 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 5 Jun 2023 06:30:09 +0000 (15:30 +0900)
get_lcd_timeout_from_settings initializes timeout value for each display state,
it is called from display_init().
Every plugins needs initializing timeout value, thus it is moved to core.

This function is added to below display.
int display_initialize_display_state_timeout_from_setting(void);
-> This function gets timeout value from setting and sets for each state timeout.

Change-Id: I892672785490d266cae7224909c03d45cf0c07e1
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/display-plugin.c
src/display/display-plugin.h
src/display/display.c
src/display/display.h

index 66c0ad2..ea7897e 100644 (file)
@@ -318,38 +318,6 @@ inline void lcd_off_procedure(enum device_flags flag)
        enter_doze();
 }
 
-/* get configurations from setting */
-static int get_lcd_timeout_from_settings(void)
-{
-       int i;
-       int val = 0;
-
-       for (i = 0; i < S_END; i++) {
-               switch (states[i].state) {
-               case S_NORMAL:
-                       get_run_timeout(&val);
-                       break;
-               case S_LCDDIM:
-                       get_dim_timeout(&val);
-                       break;
-               case S_LCDOFF:
-                       val = display_conf.lcdoff_timeout;
-                       break;
-               default:
-                       /* This state doesn't need to set time out. */
-                       val = 0;
-                       break;
-               }
-               if (val > 0)
-                       states[i].timeout = val;
-
-               _I("State(%s) timeout(%d) ms", states[i].name,
-                       states[i].timeout);
-       }
-
-       return 0;
-}
-
 static void update_display_time(void)
 {
        int run_timeout, val;
@@ -1670,7 +1638,7 @@ static void display_init(void *data)
                        break;
                case INIT_INTERFACE:
                        if (display_conf.timeout_enable)
-                               get_lcd_timeout_from_settings();
+                               display_initialize_display_state_timeout_from_setting();
                        ret = init_sysfs(flags);
                        break;
                case INIT_POLL:
index 279b614..427173c 100644 (file)
@@ -325,38 +325,6 @@ inline void lcd_off_procedure(enum device_flags flag)
        enter_doze();
 }
 
-/* get configurations from setting */
-static int get_lcd_timeout_from_settings(void)
-{
-       int i;
-       int val = 0;
-
-       for (i = 0; i < S_END; i++) {
-               switch (states[i].state) {
-               case S_NORMAL:
-                       get_run_timeout(&val);
-                       break;
-               case S_LCDDIM:
-                       get_dim_timeout(&val);
-                       break;
-               case S_LCDOFF:
-                       val = display_conf.lcdoff_timeout;
-                       break;
-               default:
-                       /* This state doesn't need to set time out. */
-                       val = 0;
-                       break;
-               }
-               if (val > 0)
-                       states[i].timeout = val;
-
-               _I("State(%s) timeout(%d) ms", states[i].name,
-                       states[i].timeout);
-       }
-
-       return 0;
-}
-
 static void update_display_time(void)
 {
        int run_timeout, val;
@@ -1676,7 +1644,7 @@ static void display_init(void *data)
                        break;
                case INIT_INTERFACE:
                        if (display_conf.timeout_enable)
-                               get_lcd_timeout_from_settings();
+                               display_initialize_display_state_timeout_from_setting();
                        ret = init_sysfs(flags);
                        break;
                case INIT_POLL:
index ca50f46..dff8f4b 100644 (file)
@@ -318,38 +318,6 @@ inline void lcd_off_procedure(enum device_flags flag)
        enter_doze();
 }
 
-/* get configurations from setting */
-static int get_lcd_timeout_from_settings(void)
-{
-       int i;
-       int val = 0;
-
-       for (i = 0; i < S_END; i++) {
-               switch (states[i].state) {
-               case S_NORMAL:
-                       get_run_timeout(&val);
-                       break;
-               case S_LCDDIM:
-                       get_dim_timeout(&val);
-                       break;
-               case S_LCDOFF:
-                       val = display_conf.lcdoff_timeout;
-                       break;
-               default:
-                       /* This state doesn't need to set time out. */
-                       val = 0;
-                       break;
-               }
-               if (val > 0)
-                       states[i].timeout = val;
-
-               _I("State(%s) timeout(%d) ms", states[i].name,
-                       states[i].timeout);
-       }
-
-       return 0;
-}
-
 static void update_display_time(void)
 {
        int run_timeout, val;
@@ -1667,7 +1635,7 @@ static void display_init(void *data)
                        break;
                case INIT_INTERFACE:
                        if (display_conf.timeout_enable)
-                               get_lcd_timeout_from_settings();
+                               display_initialize_display_state_timeout_from_setting();
                        ret = init_sysfs(flags);
                        break;
                case INIT_POLL:
index 48ccc0d..34a86a2 100644 (file)
@@ -612,38 +612,6 @@ inline void lcd_off_procedure(enum device_flags flag)
        enter_doze();
 }
 
-/* get configurations from setting */
-static int get_lcd_timeout_from_settings(void)
-{
-       int i;
-       int val = 0;
-
-       for (i = 0; i < S_END; i++) {
-               switch (states[i].state) {
-               case S_NORMAL:
-                       get_run_timeout(&val);
-                       break;
-               case S_LCDDIM:
-                       get_dim_timeout(&val);
-                       break;
-               case S_LCDOFF:
-                       val = display_conf.lcdoff_timeout;
-                       break;
-               default:
-                       /* This state doesn't need to set time out. */
-                       val = 0;
-                       break;
-               }
-               if (val > 0)
-                       states[i].timeout = val;
-
-               _I("State(%s) timeout(%d) ms", states[i].name,
-                       states[i].timeout);
-       }
-
-       return 0;
-}
-
 static void update_display_time(void)
 {
        int run_timeout, val;
@@ -2069,7 +2037,7 @@ static void display_init(void *data)
                        break;
                case INIT_INTERFACE:
                        if (display_conf.timeout_enable)
-                               get_lcd_timeout_from_settings();
+                               display_initialize_display_state_timeout_from_setting();
                        ret = init_sysfs(flags);
                        break;
                case INIT_POLL:
index 1f8b80a..14d1863 100644 (file)
@@ -211,6 +211,19 @@ int display_plugin_state_get_timeout(enum state_t state, int* state_timeout)
        return -EOPNOTSUPP;
 }
 
+int display_plugin_state_get_state_by_state_index(int state_index, enum state_t *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;
+}
+
 int display_plugin_config_get_timeout_enable(bool *timeout_enable)
 {
        if (!timeout_enable)
@@ -224,6 +237,19 @@ int display_plugin_config_get_timeout_enable(bool *timeout_enable)
        return -EOPNOTSUPP;
 }
 
+int display_plugin_config_get_lcdoff_timeout(int *lcdoff_timeout)
+{
+       if (!lcdoff_timeout)
+               return -EINVAL;
+
+       if (g_display_plugin.config) {
+               *lcdoff_timeout = g_display_plugin.config->lcdoff_timeout;
+               return 0;
+       }
+
+       return -EOPNOTSUPP;
+}
+
 int display_plugin_set_dim_state(bool on)
 {
        if (g_display_plugin.set_dim_state) {
index 5f61b75..e66a7c4 100644 (file)
@@ -101,8 +101,10 @@ int display_plugin_state_do_default_check(enum state_t state, int curr, int next
 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: display config getter/setter is also temporary in this file */
 int display_plugin_config_get_timeout_enable(bool *timeout_enable);
+int display_plugin_config_get_lcdoff_timeout(int *lcdoff_timeout);
 
 #endif //__DISPLAY_PLUGIN_H__
index dd89a24..0fe45c8 100644 (file)
@@ -157,6 +157,41 @@ bool display_dimstay_check(void)
        return false;
 }
 
+int display_initialize_display_state_timeout_from_setting(void)
+{
+       int i;
+       int val = 0;
+       const char* state_name = NULL;
+       enum state_t state = S_START;
+
+       for (i = 0; i < S_END; i++) {
+               display_plugin_state_get_state_by_state_index(i, &state);
+               switch (state) {
+               case S_NORMAL:
+                       get_run_timeout(&val);
+                       break;
+               case S_LCDDIM:
+                       get_dim_timeout(&val);
+                       break;
+               case S_LCDOFF:
+                       display_plugin_config_get_lcdoff_timeout(&val);
+                       break;
+               default:
+                       /* This state doesn't need to set time out. */
+                       val = 0;
+                       break;
+               }
+               if (val > 0) {
+                       display_plugin_state_set_timeout(i, val);
+               }
+
+               display_plugin_state_get_name(i, &state_name);
+               _I("State(%s) timeout(%d) ms", state_name, val);
+       }
+
+       return 0;
+}
+
 static int display_probe(void *data)
 {
        display_plugin_device_ops = find_device("display-plugin");
index c8943dc..42b0096 100644 (file)
@@ -56,5 +56,6 @@ void display_stop_dependent_device(unsigned long flags);
 void display_register_dependent_device(const struct device_ops *ops);
 void display_unregister_dependent_device(void);
 bool display_dimstay_check(void);
+int display_initialize_display_state_timeout_from_setting(void);
 
 #endif //__DISPLAY_H__