display: Remove poll_callback() from all display plugins 08/294808/6
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 27 Jun 2023 02:02:25 +0000 (11:02 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Thu, 29 Jun 2023 04:56:37 +0000 (13:56 +0900)
The role of poll_callback() is only causing transition according to the conditions.
To replace this function, poll_callback() is separated into two funcs and added.

These are added to display-state-transition.
- int display_state_transition_do_state_transition_by_input_poll_event(void);
- int display_state_transition_do_state_transition_by_pm_control_event(PMMsg *data);
    -> It causes display state transition by a specific trigger condition.

To refactor these functions, this function is also added to display.
- bool display_is_display_ops_started_status(void);
    -> It checks if display ops status is DEVICE_OPS_STATUS_START or not.

Change-Id: I3833e7881101bfd81c7855b14ffdf4aa74a590bf
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
14 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/core.c
plugins/mobile/display/key-filter.c
plugins/tv/display/core.c
plugins/tv/display/key-filter.c
plugins/wearable/display/core.c
plugins/wearable/display/key-filter.c
src/display/core.h
src/display/display-state-transition.c
src/display/display-state-transition.h
src/display/display.c
src/display/display.h
src/display/plugin-common/poll.c

index 65ac690..adf5192 100644 (file)
@@ -172,39 +172,6 @@ static void sig_hup(int signo)
        pm_save_logdump();
 }
 
-int poll_callback(int condition, PMMsg *data)
-{
-       static time_t last_t;
-       time_t now;
-
-       display_get_display_ops_status(&status);
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("Display logic is not started.");
-               return -ECANCELED;
-       }
-
-       if (condition == INPUT_POLL_EVENT) {
-               if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
-                       _I("Input event signal at Display Off");
-               time(&now);
-               if ((last_t != now) ||
-                   (get_pm_cur_state() == S_LCDOFF) ||
-                   (get_pm_cur_state() == S_SLEEP)) {
-                       display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
-                       last_t = now;
-               }
-       }
-
-       if (condition == PM_CONTROL_EVENT) {
-               display_lock_proc_condition(data);
-
-               if (IS_COND_REQUEST_CHANGE(data->cond))
-                       display_state_transition_do_proc_change_state(data->cond, data->pid);
-       }
-
-       return 0;
-}
-
 static void check_seed_status(void)
 {
        int ret = -1;
index 31928d6..3b6d84a 100644 (file)
@@ -136,7 +136,7 @@ static void longkey_pressed(void)
                /* change state - LCD on */
                if (disp_plgn->pm_change_internal)
                        disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
-               poll_callback(INPUT_POLL_EVENT, NULL);
+               display_state_transition_do_state_transition_by_input_poll_event();
        }
 
        if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
@@ -712,7 +712,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned
                return;
 
        /* lcd on or update lcd timeout */
-       poll_callback(INPUT_POLL_EVENT, NULL);
+       display_state_transition_do_state_transition_by_input_poll_event();
 }
 
 static int delayed_init_done(void *data)
index 3fdf1f6..7cca5d8 100644 (file)
@@ -230,39 +230,6 @@ static void sig_hup(int signo)
        pm_save_logdump();
 }
 
-int poll_callback(int condition, PMMsg *data)
-{
-       static time_t last_t;
-       time_t now;
-
-       display_get_display_ops_status(&status);
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("Display logic is not started.");
-               return -ECANCELED;
-       }
-
-       if (condition == INPUT_POLL_EVENT) {
-               if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
-                       _I("Input event signal at Display Off");
-               time(&now);
-               if ((last_t != now) ||
-                   (get_pm_cur_state() == S_LCDOFF) ||
-                   (get_pm_cur_state() == S_SLEEP)) {
-                       display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
-                       last_t = now;
-               }
-       }
-
-       if (condition == PM_CONTROL_EVENT) {
-               display_lock_proc_condition(data);
-
-               if (IS_COND_REQUEST_CHANGE(data->cond))
-                       display_state_transition_do_proc_change_state(data->cond, data->pid);
-       }
-
-       return 0;
-}
-
 static void check_seed_status(void)
 {
        int ret = -1;
index 1498d4e..2124a8c 100644 (file)
@@ -128,7 +128,7 @@ static void longkey_pressed(void)
                /* change state - LCD on */
                if (disp_plgn->pm_change_internal)
                        disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
-               poll_callback(INPUT_POLL_EVENT, NULL);
+               display_state_transition_do_state_transition_by_input_poll_event();
        }
 
        if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
@@ -416,8 +416,7 @@ static gboolean display_on_cb(void *data)
            current_state_in_on() == false) {
                broadcast_lcdon_by_powerkey();
                display_panel_lcd_on_direct(LCD_ON_BY_POWER_KEY);
-
-               poll_callback(INPUT_POLL_EVENT, NULL);
+               display_state_transition_do_state_transition_by_input_poll_event();
        }
 
        return G_SOURCE_REMOVE;
@@ -739,7 +738,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned
                return;
 
        /* lcd on or update lcd timeout */
-       poll_callback(INPUT_POLL_EVENT, NULL);
+       display_state_transition_do_state_transition_by_input_poll_event();
 }
 
 static int delayed_init_done(void *data)
index eb0d2c5..3badf8d 100644 (file)
@@ -172,39 +172,6 @@ static void sig_hup(int signo)
        pm_save_logdump();
 }
 
-int poll_callback(int condition, PMMsg *data)
-{
-       static time_t last_t;
-       time_t now;
-
-       display_get_display_ops_status(&status);
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("Display logic is not started.");
-               return -ECANCELED;
-       }
-
-       if (condition == INPUT_POLL_EVENT) {
-               if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
-                       _I("Input event signal at Display Off");
-               time(&now);
-               if ((last_t != now) ||
-                   (get_pm_cur_state() == S_LCDOFF) ||
-                   (get_pm_cur_state() == S_SLEEP)) {
-                       display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
-                       last_t = now;
-               }
-       }
-
-       if (condition == PM_CONTROL_EVENT) {
-               display_lock_proc_condition(data);
-
-               if (IS_COND_REQUEST_CHANGE(data->cond))
-                       display_state_transition_do_proc_change_state(data->cond, data->pid);
-       }
-
-       return 0;
-}
-
 static void check_seed_status(void)
 {
        int ret = -1;
index 5422373..f6e4a48 100644 (file)
@@ -136,7 +136,7 @@ static void longkey_pressed(void)
                /* change state - LCD on */
                if (disp_plgn->pm_change_internal)
                        disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
-               poll_callback(INPUT_POLL_EVENT, NULL);
+               display_state_transition_do_state_transition_by_input_poll_event();
        }
 
        if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
@@ -706,7 +706,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned
                return;
 
        /* lcd on or update lcd timeout */
-       poll_callback(INPUT_POLL_EVENT, NULL);
+       display_state_transition_do_state_transition_by_input_poll_event();
 }
 
 static int delayed_init_done(void *data)
index 7ebd0c6..6dfa725 100644 (file)
@@ -851,39 +851,6 @@ static void default_saving_mode(int onoff)
        }
 }
 
-int poll_callback(int condition, PMMsg *data)
-{
-       static time_t last_t;
-       time_t now;
-
-       display_get_display_ops_status(&status);
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("Display logic is not started.");
-               return -ECANCELED;
-       }
-
-       if (condition == INPUT_POLL_EVENT) {
-               if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
-                       _I("Input event signal at Display Off");
-               time(&now);
-               if ((last_t != now) ||
-                   (get_pm_cur_state() == S_LCDOFF) ||
-                   (get_pm_cur_state() == S_SLEEP)) {
-                       states[get_pm_cur_state()].trans(EVENT_INPUT);
-                       last_t = now;
-               }
-       }
-
-       if (condition == PM_CONTROL_EVENT) {
-               display_lock_proc_condition(data);
-
-               if (IS_COND_REQUEST_CHANGE(data->cond))
-                       display_state_transition_do_proc_change_state(data->cond, data->pid);
-       }
-
-       return 0;
-}
-
 static int update_setting(int key_idx, int val)
 {
        int ret;
index a09263e..51a874f 100644 (file)
@@ -127,7 +127,7 @@ static void longkey_pressed(void)
                /* change state - LCD on */
                if (disp_plgn->pm_change_internal)
                        disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
-               poll_callback(INPUT_POLL_EVENT, NULL);
+               display_state_transition_do_state_transition_by_input_poll_event();
        }
 
        if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
@@ -666,7 +666,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned
                return;
 
        /* lcd on or update lcd timeout */
-       poll_callback(INPUT_POLL_EVENT, NULL);
+       display_state_transition_do_state_transition_by_input_poll_event();
 }
 
 static int delayed_init_done(void *data)
index 79679ad..a1599e6 100644 (file)
@@ -105,7 +105,6 @@ typedef struct {
        unsigned int timeout;
        unsigned int timeout2;
 } PMMsg;
-extern int poll_callback(int condition, PMMsg *data);
 
 extern struct state state[S_END];
 
index 4523f95..cfab4fc 100644 (file)
@@ -391,6 +391,42 @@ int display_state_transition_do_state_transition(enum state_t state, int evt_typ
        return 0;
 }
 
+int display_state_transition_do_state_transition_by_input_poll_event(void)
+{
+       static time_t last_time;
+       time_t now;
+
+       if (!display_is_display_ops_started_status()) {
+               _E("Display logic is not started.");
+               return -ECANCELED;
+       }
+
+       if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
+               _I("Input event signal at Display Off");
+
+       time(&now);
+       if ((last_time != now) || (get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP)) {
+               display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+               last_time = now;
+       }
+
+       return 0;
+}
+
+int display_state_transition_do_state_transition_by_pm_control_event(PMMsg *data)
+{
+       if (!display_is_display_ops_started_status()) {
+               _E("Display logic is not started.");
+               return -ECANCELED;
+       }
+       display_lock_proc_condition(data);
+
+       if (IS_COND_REQUEST_CHANGE(data->cond))
+               display_state_transition_do_proc_change_state(data->cond, data->pid);
+
+       return 0;
+}
+
 /* FIXME: diff time calculation, set_wakeup_count should be discussed again later */
 int display_state_transition_do_state_action(int timeout)
 {
@@ -597,4 +633,3 @@ int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid)
 
        return 0;
 }
-
index d51199f..a7d4dd9 100644 (file)
@@ -43,6 +43,8 @@ int display_state_transition_update_lcdoff_reason(int source);
 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_transition_by_input_poll_event(void);
+int display_state_transition_do_state_transition_by_pm_control_event(PMMsg *data);
 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);
index 561571a..ca65e89 100644 (file)
@@ -199,6 +199,11 @@ int display_initialize_display_state_timeout_from_setting(void)
 /** FIXME: display_ops_status getter/setter will be removed after plugin-core separation
            This work should be proceeded in the display core
 */
+bool display_is_display_ops_started_status(void)
+{
+       return (display_ops_status == DEVICE_OPS_STATUS_START);
+}
+
 void display_set_display_ops_status(enum device_ops_status dev_ops_status)
 {
        display_ops_status = dev_ops_status;
index 436d61c..ce9793e 100644 (file)
@@ -57,6 +57,7 @@ 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);
+bool display_is_display_ops_started_status(void);
 void display_set_display_ops_status(enum device_ops_status dev_ops_status);
 int display_get_display_ops_status(enum device_ops_status *dev_ops_status);
 void display_set_power_save_mode_flag(int onoff);
index ffc2806..72347c5 100644 (file)
@@ -88,7 +88,7 @@ static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout)
        recv_data.cond = cond;
        recv_data.timeout = timeout;
 
-       poll_callback(PM_CONTROL_EVENT, &recv_data);
+       display_state_transition_do_state_transition_by_pm_control_event(&recv_data);
 
        return 0;
 }
@@ -116,7 +116,7 @@ static int __pm_unlock_internal(pid_t pid, int s_bits, int flag)
        recv_data.cond = cond;
        recv_data.timeout = 0;
 
-       poll_callback(PM_CONTROL_EVENT, &recv_data);
+       display_state_transition_do_state_transition_by_pm_control_event(&recv_data);
 
        return 0;
 }
@@ -145,7 +145,7 @@ static int __pm_change_internal(pid_t pid, int s_bits)
        recv_data.cond = cond;
        recv_data.timeout = 0;
 
-       poll_callback(PM_CONTROL_EVENT, &recv_data);
+       display_state_transition_do_state_transition_by_pm_control_event(&recv_data);
 
        return 0;
 }