From 161dc64c6d7435630850b7e25f56e4551a9d4fb1 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 14 Jun 2023 16:17:34 +0900 Subject: [PATCH] display: Relocate lcd_on_direct() lcd_on_direct() is used to lcd turn on directly by key-event, proc_change_state.. etc. It is called under the specific condition. To relocate lcd_on_direct(), update_display_locktime() is also relocated. For wearable plugin, this wrapper is added. - int display_plugin_lcd_on_procedure(int state, enum device_flags flag); New functions are added below display-state-transition - void display_state_transition_update_lock_screen_timeout(int timeout); -> This function sets lock screen timeout value and update. It replaces update_display_locktime() New function is added below display-panel - void display_panel_lcd_on_direct(enum device_flags flags); -> This replaces lcd_on_direct() Change-Id: I5628e230ec0fcc9a0ff36b31966ffbda85d92d69 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 36 +++++---------------------------- plugins/iot-headed/display/key-filter.c | 2 +- plugins/mobile/display/core.c | 36 +++++---------------------------- plugins/mobile/display/key-filter.c | 4 ++-- plugins/tv/display/core.c | 36 +++++---------------------------- plugins/tv/display/key-filter.c | 2 +- plugins/wearable/display/core.c | 36 +++++---------------------------- plugins/wearable/display/key-filter.c | 2 +- src/display/core.h | 1 - src/display/display-panel.c | 25 +++++++++++++++++++++++ src/display/display-panel.h | 1 + src/display/display-plugin.c | 10 +++++++++ src/display/display-plugin.h | 2 ++ src/display/display-state-transition.c | 6 ++++++ src/display/display-state-transition.h | 1 + 15 files changed, 70 insertions(+), 130 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 4ce86f0..eb679ec 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -184,33 +184,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static void update_display_locktime(int time) -{ - display_state_transition_set_lock_screen_timeout(time); - display_state_transition_update_display_state_timeout_by_priority(); -} - -void lcd_on_direct(enum device_flags flags) -{ - enum hal_device_power_transition_reason reason; - - if (flags & LCD_ON_BY_POWER_KEY) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY; - else if (flags & LCD_ON_BY_TOUCH) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN; - else - reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; - - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL); - set_pm_cur_state(S_NORMAL); - - _D("lcd is on directly"); - display_panel_update_lcd_on_timeval(); - display_panel_lcd_on_procedure(LCD_NORMAL, flags); - - update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); -} - static gboolean timer_refresh_cb(gpointer data) { struct state *st; @@ -233,7 +206,7 @@ int custom_lcdon(int timeout) return -EINVAL; if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_GESTURE); + display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -310,7 +283,7 @@ int display_on_by_reason(const char *reason, int timeout) } if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(flag); + display_panel_lcd_on_direct(flag); _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -390,8 +363,8 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) switch (next) { case S_NORMAL: if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_EVENT); - update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT); + 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: @@ -959,6 +932,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->set_dim_state = NULL; dp->get_device_flags = NULL; + dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 02504d8..31928d6 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -214,7 +214,7 @@ static inline bool switch_on_lcd(enum device_flags flags) else if (flags & LCD_ON_BY_TOUCH) _I("Display on by Touch_wakeup event"); - lcd_on_direct(flags); + display_panel_lcd_on_direct(flags); return true; } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 29f8b80..e0d37ab 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -191,33 +191,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static void update_display_locktime(int time) -{ - display_state_transition_set_lock_screen_timeout(time); - display_state_transition_update_display_state_timeout_by_priority(); -} - -void lcd_on_direct(enum device_flags flags) -{ - enum hal_device_power_transition_reason reason; - - if (flags & LCD_ON_BY_POWER_KEY) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY; - else if (flags & LCD_ON_BY_TOUCH) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN; - else - reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; - - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL); - set_pm_cur_state(S_NORMAL); - - _D("lcd is on directly"); - display_panel_update_lcd_on_timeval(); - display_panel_lcd_on_procedure(LCD_NORMAL, flags); - - update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); -} - static gboolean timer_refresh_cb(gpointer data) { struct state *st; @@ -240,7 +213,7 @@ int custom_lcdon(int timeout) return -EINVAL; if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_GESTURE); + display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -317,7 +290,7 @@ int display_on_by_reason(const char *reason, int timeout) } if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(flag); + display_panel_lcd_on_direct(flag); _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -396,8 +369,8 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) switch (next) { case S_NORMAL: if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_EVENT); - update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT); + 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: @@ -968,6 +941,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->set_dim_state = NULL; dp->get_device_flags = NULL; + dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 36bb59f..1498d4e 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -204,7 +204,7 @@ static inline bool switch_on_lcd(enum device_flags flags) else if (flags & LCD_ON_BY_TOUCH) _I("Display on by Touch_wakeup event"); - lcd_on_direct(flags); + display_panel_lcd_on_direct(flags); return true; } @@ -415,7 +415,7 @@ static gboolean display_on_cb(void *data) if (display_panel_get_dpms_cached_state() != DPMS_ON || current_state_in_on() == false) { broadcast_lcdon_by_powerkey(); - lcd_on_direct(LCD_ON_BY_POWER_KEY); + display_panel_lcd_on_direct(LCD_ON_BY_POWER_KEY); poll_callback(INPUT_POLL_EVENT, NULL); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index e35377c..8d46c7a 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -184,33 +184,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static void update_display_locktime(int time) -{ - display_state_transition_set_lock_screen_timeout(time); - display_state_transition_update_display_state_timeout_by_priority(); -} - -void lcd_on_direct(enum device_flags flags) -{ - enum hal_device_power_transition_reason reason; - - if (flags & LCD_ON_BY_POWER_KEY) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY; - else if (flags & LCD_ON_BY_TOUCH) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN; - else - reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; - - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL); - set_pm_cur_state(S_NORMAL); - - _D("lcd is on directly"); - display_panel_update_lcd_on_timeval(); - display_panel_lcd_on_procedure(LCD_NORMAL, flags); - - update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); -} - static gboolean timer_refresh_cb(gpointer data) { struct state *st; @@ -233,7 +206,7 @@ int custom_lcdon(int timeout) return -EINVAL; if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_GESTURE); + display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -310,7 +283,7 @@ int display_on_by_reason(const char *reason, int timeout) } if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(flag); + display_panel_lcd_on_direct(flag); _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -389,8 +362,8 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) switch (next) { case S_NORMAL: if (display_panel_get_dpms_cached_state() != DPMS_ON) - lcd_on_direct(LCD_ON_BY_EVENT); - update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT); + 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: @@ -959,6 +932,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->set_dim_state = NULL; dp->get_device_flags = NULL; + dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index b46816d..5422373 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -214,7 +214,7 @@ static inline bool switch_on_lcd(enum device_flags flags) else if (flags & LCD_ON_BY_TOUCH) _I("Display on by Touch_wakeup event"); - lcd_on_direct(flags); + display_panel_lcd_on_direct(flags); return true; } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 08b3d6c..d6685e8 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -394,12 +394,6 @@ static void lcd_off_procedure(enum device_flags flag) enter_doze(); } -static void update_display_locktime(int time) -{ - display_state_transition_set_lock_screen_timeout(time); - display_state_transition_update_display_state_timeout_by_priority(); -} - static void set_dim_state(bool on) { _I("Dim state is %d.", on); @@ -407,27 +401,6 @@ static void set_dim_state(bool on) states[get_pm_cur_state()].trans(EVENT_INPUT); } -void lcd_on_direct(enum device_flags flags) -{ - enum hal_device_power_transition_reason reason; - - if (flags & LCD_ON_BY_POWER_KEY) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY; - else if (flags & LCD_ON_BY_TOUCH) - reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN; - else - reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; - - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL); - set_pm_cur_state(S_NORMAL); - - _D("lcd is on directly"); - display_panel_update_lcd_on_timeval(); - lcd_on_procedure(LCD_NORMAL, flags); - - update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); -} - static inline bool check_lcd_is_on(void) { if (display_panel_get_dpms_cached_state() != DPMS_ON) @@ -476,7 +449,7 @@ int custom_lcdon(int timeout) return -EINVAL; if (check_lcd_is_on() == false) - lcd_on_direct(LCD_ON_BY_GESTURE); + display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); /* Exceptional case: * During tutorial, reset timeout by default timeout, not the given timeout */ @@ -568,7 +541,7 @@ int display_on_by_reason(const char *reason, int timeout) } if (check_lcd_is_on() == false) - lcd_on_direct(flag); + display_panel_lcd_on_direct(flag); _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) @@ -658,8 +631,8 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) switch (next) { case S_NORMAL: if (check_lcd_is_on() == false) - lcd_on_direct(LCD_ON_BY_EVENT); - update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT); + 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: @@ -1427,6 +1400,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->set_dim_state = set_dim_state; dp->get_device_flags = get_device_flags; + dp->lcd_on_procedure = lcd_on_procedure; dp->lcd_off_procedure = lcd_off_procedure; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index e7b33e1..a09263e 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -211,7 +211,7 @@ static inline bool switch_on_lcd(enum device_flags flags) else if (flags & LCD_ON_BY_TOUCH) _I("Display on by Touch_wakeup event"); - lcd_on_direct(flags); + display_panel_lcd_on_direct(flags); return true; } diff --git a/src/display/core.h b/src/display/core.h index d7b662a..a0b2ba2 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -124,7 +124,6 @@ int display_on_by_reason(const char *reason, int timeout); int display_off_by_reason(const char *reason); int set_lcd_timeout(int on, int dim, const char *name); int custom_lcdon(int timeout); -void lcd_on_direct(enum device_flags flags); void broadcast_lcd_off_late(enum device_flags flags); /* auto-brightness.c */ diff --git a/src/display/display-panel.c b/src/display/display-panel.c index 813bedb..4a32682 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -18,6 +18,7 @@ #include #include "shared/log.h" +#include "power/power.h" #include "power/power-suspend.h" #include "power/power-doze.h" #include "ambient-mode.h" @@ -25,6 +26,7 @@ #include "display-misc.h" #include "display-panel.h" #include "display-signal.h" +#include "display-state-transition.h" #include "led/touch-key.h" #define MAX_WHITE_BALANCE_GAIN 2047 @@ -217,6 +219,8 @@ void display_panel_lcd_on_procedure(int state, enum device_flags flag) display_plugin_get_device_flags(&flags); flags |= flag; + if (display_plugin_lcd_on_procedure(state, flag) == 0) + return; /* * Display on procedure * step 1. leave doze @@ -306,6 +310,27 @@ void display_panel_lcd_off_procedure(enum device_flags flag) enter_doze(); } +void display_panel_lcd_on_direct(enum device_flags flags) +{ + enum hal_device_power_transition_reason reason; + + if (flags & LCD_ON_BY_POWER_KEY) + reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY; + else if (flags & LCD_ON_BY_TOUCH) + reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN; + else + reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; + + power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL); + set_pm_cur_state(S_NORMAL); + + _D("lcd is on directly"); + display_panel_update_lcd_on_timeval(); + display_panel_lcd_on_procedure(LCD_NORMAL, flags); + + display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_INPUT_TIMEOUT); +} + bool display_panel_is_lcd_on_state_broadcasted(void) { return lcd_on_broadcasted; diff --git a/src/display/display-panel.h b/src/display/display-panel.h index e6bb4c6..dc4bdbe 100644 --- a/src/display/display-panel.h +++ b/src/display/display-panel.h @@ -34,6 +34,7 @@ void display_panel_set_lcd_paneloff_mode(bool on); void display_panel_get_lcd_paneloff_mode(bool *on); void display_panel_lcd_on_procedure(int state, enum device_flags flag); void display_panel_lcd_off_procedure(enum device_flags flag); +void display_panel_lcd_on_direct(enum device_flags flags); bool display_panel_is_lcd_on_state_broadcasted(void); void display_panel_update_lcd_on_timeval(void); int display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(int *diff_time); diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index c46b17b..7d06704 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -99,6 +99,16 @@ int display_plugin_auto_brightness_control(enum brightness_request_e request, in return 0; } +int display_plugin_lcd_on_procedure(int state, enum device_flags flag) +{ + if (g_display_plugin.lcd_on_procedure) { + g_display_plugin.lcd_on_procedure(state, flag); + return 0; + } + + return -EOPNOTSUPP; +} + int display_plugin_lcd_off_procedure(enum device_flags flag) { if (g_display_plugin.lcd_off_procedure) { diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 9b256f4..97bd50b 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -67,6 +67,7 @@ struct display_plugin { /* FIXME: function names will be redefined */ void (*set_dim_state) (bool on); int (*get_device_flags) (unsigned long *device_flags); + void (*lcd_on_procedure) (int state, enum device_flags flag); void (*lcd_off_procedure) (enum device_flags flag); struct display_config *config; @@ -87,6 +88,7 @@ const char* display_plugin_device_flags_to_string(enum device_flags flags); int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness); int display_plugin_set_dim_state(bool on); int display_plugin_get_device_flags(unsigned long *device_flags); +int display_plugin_lcd_on_procedure(int state, enum device_flags flag); int display_plugin_lcd_off_procedure(enum device_flags flag); int display_plugin_backlight_get_lcd_power(void); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 72ada04..5935680 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -184,6 +184,12 @@ int display_state_transition_get_lock_screen_timeout(int *timeout) return 0; } +void display_state_transition_update_lock_screen_timeout(int timeout) +{ + display_state_transition_set_lock_screen_timeout(time); + display_state_transition_update_display_state_timeout_by_priority(); +} + void display_state_transition_update_display_state_timeout_by_priority(void) { int run_timeout, val; diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index 9182243..ee1955a 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -36,6 +36,7 @@ int display_state_transition_set_custom_timeout(enum state_t state, unsigned int int display_state_transition_get_custom_timeout(enum state_t state, unsigned int *timeout); int display_state_transition_set_lock_screen_timeout(int timeout); int display_state_transition_get_lock_screen_timeout(int *timeout); +void display_state_transition_update_lock_screen_timeout(int timeout); void display_state_transition_update_display_state_timeout_by_priority(void); int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state); int display_state_transition_update_lcdoff_reason(int source); -- 2.7.4