From a4f1122937ab6530a3bb1574810ab8a134e0eeb3 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 14 Jun 2023 20:02:40 +0900 Subject: [PATCH] display: Relocate custom_lcd_on/off() custom_lcd_on/off() is used by dbus_customlcdon/off call. These update custom timeout value and go to S_NORMAL/S_LCDOFF display state. New functions added below display-panel. - int display_panel_custom_lcd_on(int timeout); - int display_panel_custom_lcd_off(enum device_flags flag); -> These replace custom_lcd_on/off(). Change-Id: Ie6e28ade1a05212f97c4feb87ea70955ff2cddc0 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 78 +------------------------------- plugins/mobile/display/core.c | 78 +------------------------------- plugins/tv/display/core.c | 78 +------------------------------- plugins/wearable/display/core.c | 2 + src/display/core.h | 1 - src/display/display-panel.c | 74 ++++++++++++++++++++++++++++++ src/display/display-panel.h | 2 + src/display/display-plugin.c | 20 ++++++++ src/display/display-plugin.h | 4 ++ src/display/display-state-transition.c | 2 +- src/display/plugin-common/display-dbus.c | 4 +- 11 files changed, 111 insertions(+), 232 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index eb679ec..2a19bcc 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -184,82 +184,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static gboolean timer_refresh_cb(gpointer data) -{ - struct state *st; - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - -int custom_lcdon(int timeout) -{ - struct state *st; - - if (timeout <= 0) - return -EINVAL; - - if (display_panel_get_dpms_cached_state() != DPMS_ON) - display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); - - _I("Custom lcd on timeout(%d ms).", timeout); - if (set_custom_lcdon_timeout(timeout) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - g_idle_add(timer_refresh_cb, NULL); - - return 0; -} - -int custom_lcdoff(enum device_flags flag) -{ - struct state *st; - - if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) { - /* - * When another proccess is normal lock, device is received call then, - * call app can be changed to lcd state by proximity. - * If proximity is near then normal lock will be unlocked. - */ - if (flag & LCD_OFF_BY_PROXIMITY) { - _I("custom lcd off by proximity, delete normal lock"); - display_lock_release_lock_all(S_NORMAL); - } else { - _I("skip custom lcd off"); - return -ECANCELED; - } - } - - _I("custom lcd off by flag(%d)", flag); - if (display_panel_get_dpms_cached_state() == DPMS_ON) - display_panel_lcd_off_procedure(flag); - - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_LCDOFF); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - int display_on_by_reason(const char *reason, int timeout) { struct state *st; @@ -934,6 +858,8 @@ static int display_probe(void *data) dp->get_device_flags = NULL; dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; + dp->custom_lcd_on = NULL; + dp->custom_lcd_off = NULL; setup_display_plugin_backlight_ops(dp); /* check display feature */ diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index e0d37ab..e7cc52d 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -191,82 +191,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static gboolean timer_refresh_cb(gpointer data) -{ - struct state *st; - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - -int custom_lcdon(int timeout) -{ - struct state *st; - - if (timeout <= 0) - return -EINVAL; - - if (display_panel_get_dpms_cached_state() != DPMS_ON) - display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); - - _I("Custom lcd on timeout(%d ms).", timeout); - if (set_custom_lcdon_timeout(timeout) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - g_idle_add(timer_refresh_cb, NULL); - - return 0; -} - -int custom_lcdoff(enum device_flags flag) -{ - struct state *st; - - if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) { - /* - * When another proccess is normal lock, device is received call then, - * call app can be changed to lcd state by proximity. - * If proximity is near then normal lock will be unlocked. - */ - if (flag & LCD_OFF_BY_PROXIMITY) { - _I("custom lcd off by proximity, delete normal lock"); - display_lock_release_lock_all(S_NORMAL); - } else { - _I("skip custom lcd off"); - return -ECANCELED; - } - } - - _I("custom lcd off by flag(%d)", flag); - if (display_panel_get_dpms_cached_state() == DPMS_ON) - display_panel_lcd_off_procedure(flag); - - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_LCDOFF); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - int display_on_by_reason(const char *reason, int timeout) { struct state *st; @@ -943,6 +867,8 @@ static int display_probe(void *data) dp->get_device_flags = NULL; dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; + dp->custom_lcd_on = NULL; + dp->custom_lcd_off = NULL; setup_display_plugin_backlight_ops(dp); /** diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 8d46c7a..4630590 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -184,82 +184,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static gboolean timer_refresh_cb(gpointer data) -{ - struct state *st; - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - -int custom_lcdon(int timeout) -{ - struct state *st; - - if (timeout <= 0) - return -EINVAL; - - if (display_panel_get_dpms_cached_state() != DPMS_ON) - display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); - - _I("Custom lcd on timeout(%d ms).", timeout); - if (set_custom_lcdon_timeout(timeout) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_NORMAL); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - g_idle_add(timer_refresh_cb, NULL); - - return 0; -} - -int custom_lcdoff(enum device_flags flag) -{ - struct state *st; - - if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) { - /* - * When another proccess is normal lock, device is received call then, - * call app can be changed to lcd state by proximity. - * If proximity is near then normal lock will be unlocked. - */ - if (flag & LCD_OFF_BY_PROXIMITY) { - _I("custom lcd off by proximity, delete normal lock"); - display_lock_release_lock_all(S_NORMAL); - } else { - _I("skip custom lcd off"); - return -ECANCELED; - } - } - - _I("custom lcd off by flag(%d)", flag); - if (display_panel_get_dpms_cached_state() == DPMS_ON) - display_panel_lcd_off_procedure(flag); - - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(S_LCDOFF); - st = &states[get_pm_cur_state()]; - - display_state_transition_do_state_action(st->timeout); - - return 0; -} - int display_on_by_reason(const char *reason, int timeout) { struct state *st; @@ -934,6 +858,8 @@ static int display_probe(void *data) dp->get_device_flags = NULL; dp->lcd_on_procedure = NULL; dp->lcd_off_procedure = NULL; + dp->custom_lcd_on = NULL; + dp->custom_lcd_off = NULL; setup_display_plugin_backlight_ops(dp); /** diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index d6685e8..dcf753d 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1402,6 +1402,8 @@ static int display_probe(void *data) dp->get_device_flags = get_device_flags; dp->lcd_on_procedure = lcd_on_procedure; dp->lcd_off_procedure = lcd_off_procedure; + dp->custom_lcd_on = custom_lcdon; + dp->custom_lcd_off = custom_lcdoff; setup_display_plugin_backlight_ops(dp); /** diff --git a/src/display/core.h b/src/display/core.h index a0b2ba2..bdb9726 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -123,7 +123,6 @@ int custom_lcdoff(enum device_flags flag); 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 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 4a32682..ffed685 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -23,8 +23,10 @@ #include "power/power-doze.h" #include "ambient-mode.h" #include "device-interface.h" +#include "display-lock.h" #include "display-misc.h" #include "display-panel.h" +#include "display-plugin.h" #include "display-signal.h" #include "display-state-transition.h" #include "led/touch-key.h" @@ -331,6 +333,78 @@ void display_panel_lcd_on_direct(enum device_flags flags) display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_INPUT_TIMEOUT); } +static void display_state_updated_to_next_and_do_action(enum state_t next) +{ + int timeout = 0; + set_pm_old_state(get_pm_cur_state()); + set_pm_cur_state(next); + + display_plugin_state_get_timeout(get_pm_cur_state(), &timeout); + display_state_transition_do_state_action(timeout); +} + +/* FIXME: timer_refresh_cb seems legacy code, it can be removed after discussion */ +static gboolean timer_refresh_cb(gpointer data) +{ + display_state_updated_to_next_and_do_action(S_NORMAL); + return 0; +} + +int display_panel_custom_lcd_on(int timeout) +{ + if (display_plugin_custom_lcd_on(timeout) == 0) + return 0; + + if (timeout <= 0) + return -EINVAL; + + if (display_panel_get_dpms_cached_state() != DPMS_ON) + display_panel_lcd_on_direct(LCD_ON_BY_GESTURE); + + _I("Custom lcd on timeout(%d ms).", timeout); + if (set_custom_lcdon_timeout(timeout)) + display_state_transition_update_display_state_timeout_by_priority(); + + display_state_updated_to_next_and_do_action(S_NORMAL); + + g_idle_add(timer_refresh_cb, NULL); + + return 0; +} + +int display_panel_custom_lcd_off(enum device_flags flag) +{ + if (display_plugin_custom_lcd_off(flag) == 0) + return 0; + + /* check holdkey block flag in lock node */ + if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) { + /* + * When another proccess is normal lock, device is received call then, + * call app can be changed to lcd state by proximity. + * If proximity is near then normal lock will be unlocked. + */ + if (flag & LCD_OFF_BY_PROXIMITY) { + _I("custom lcd off by proximity, delete normal lock"); + display_lock_release_lock_all(S_NORMAL); + } else { + _I("skip custom lcd off"); + return -ECANCELED; + } + } + + _I("custom lcd off by flag(%d)", flag); + if (display_panel_get_dpms_cached_state() == DPMS_ON) + display_panel_lcd_off_procedure(flag); + + if (set_custom_lcdon_timeout(0) == true) + display_state_transition_update_display_state_timeout_by_priority(); + + display_state_updated_to_next_and_do_action(S_LCDOFF); + + return 0; +} + 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 dc4bdbe..4b39c72 100644 --- a/src/display/display-panel.h +++ b/src/display/display-panel.h @@ -35,6 +35,8 @@ 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); +int display_panel_custom_lcd_on(int timeout); +int display_panel_custom_lcd_off(enum device_flags flag); 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 7d06704..8ed7335 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -119,6 +119,26 @@ int display_plugin_lcd_off_procedure(enum device_flags flag) return -EOPNOTSUPP; } +int display_plugin_custom_lcd_on(int timeout) +{ + if (g_display_plugin.custom_lcd_on) { + g_display_plugin.custom_lcd_on(timeout); + return 0; + } + + return -EOPNOTSUPP; +} + +int display_plugin_custom_lcd_off(enum device_flags flag) +{ + if (g_display_plugin.custom_lcd_off) { + g_display_plugin.custom_lcd_off(flag); + return 0; + } + + return -EOPNOTSUPP; +} + int display_plugin_backlight_get_lcd_power(void) { if (g_display_plugin.backlight && g_display_plugin.backlight->get_lcd_power) diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 97bd50b..73e69b3 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -69,6 +69,8 @@ struct display_plugin { 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); + int (*custom_lcd_on) (int timeout); + int (*custom_lcd_off) (enum device_flags flag); struct display_config *config; struct display_backlight_ops *backlight; @@ -90,6 +92,8 @@ 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_custom_lcd_on(int timeout); +int display_plugin_custom_lcd_off(enum device_flags flag); int display_plugin_backlight_get_lcd_power(void); int display_plugin_backlight_set_brightness(int brightness); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 5935680..d633e78 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -186,7 +186,7 @@ int display_state_transition_get_lock_screen_timeout(int *timeout) void display_state_transition_update_lock_screen_timeout(int timeout) { - display_state_transition_set_lock_screen_timeout(time); + display_state_transition_set_lock_screen_timeout(timeout); display_state_transition_update_display_state_timeout_by_priority(); } diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index d826aaa..76c3b5c 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -839,7 +839,7 @@ static GVariant *dbus_customlcdon(GDBusConnection *conn, return g_variant_new("(i)", -ENOTSUP); } - ret = custom_lcdon(timeout); + ret = display_panel_custom_lcd_on(timeout); return g_variant_new("(i)", ret); } @@ -868,7 +868,7 @@ static GVariant *dbus_customlcdoff(GDBusConnection *conn, goto out; } - ret = custom_lcdoff(flag); + ret = display_panel_custom_lcd_off(flag); out: g_free(reason_str); -- 2.7.4