From 498f833e38ac639fb4d31b0aee326633c75e2d44 Mon Sep 17 00:00:00 2001 From: youngjae Date: Thu, 1 Jun 2023 19:08:27 +0900 Subject: [PATCH 01/16] display: Remove unused code of key-filter Change-Id: Ia90ae16241bfc1bf2c0a427210d03552657d9a3c Signed-off-by: youngjae --- plugins/iot-headed/display/key-filter.c | 2 -- plugins/mobile/display/key-filter.c | 2 -- plugins/tv/display/key-filter.c | 2 -- plugins/wearable/display/key-filter.c | 2 -- src/display/core.h | 2 -- src/display/plugin-common/display-dbus.c | 19 ++----------------- 6 files changed, 2 insertions(+), 27 deletions(-) diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 9bf578a..0bf71c9 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -794,8 +794,6 @@ static void key_backlight_enable(bool enable) static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .set_powerkey_ignore = NULL, - .powerkey_lcdoff = NULL, .backlight_enable = key_backlight_enable, }; diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 7edd460..97a2454 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -820,8 +820,6 @@ static void key_backlight_enable(bool enable) static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .set_powerkey_ignore = NULL, - .powerkey_lcdoff = NULL, .backlight_enable = key_backlight_enable, }; diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 790ad0a..b2c0c10 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -788,8 +788,6 @@ static void key_backlight_enable(bool enable) static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .set_powerkey_ignore = NULL, - .powerkey_lcdoff = NULL, .backlight_enable = key_backlight_enable, }; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 88a736d..cf14122 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -722,8 +722,6 @@ static void keyfilter_init(void) static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .set_powerkey_ignore = NULL, - .powerkey_lcdoff = NULL, .backlight_enable = NULL, }; diff --git a/src/display/core.h b/src/display/core.h index fb1be24..2b99608 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -101,8 +101,6 @@ struct display_keyfilter_ops { void (*init)(void); void (*exit)(void); int (*check)(void *, int); - void (*set_powerkey_ignore)(int); - int (*powerkey_lcdoff)(void); void (*backlight_enable)(bool); }; diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 0acaf1a..1994bc4 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -817,29 +817,14 @@ static GVariant *dbus_powerkeyignore(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int ret = 0; - int on; - - g_variant_get(param, "(i)", &on); - - if (CHECK_OPS(keyfilter_ops, set_powerkey_ignore)) - keyfilter_ops->set_powerkey_ignore(on == 1 ? true : false); - - return g_variant_new("(i)", ret); + return g_variant_new("(i)", 0); } static GVariant *dbus_powerkeylcdoff(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { - int ret; - - if (CHECK_OPS(keyfilter_ops, powerkey_lcdoff)) - ret = keyfilter_ops->powerkey_lcdoff(); - else - ret = -ENOSYS; - - return g_variant_new("(i)", ret); + return g_variant_new("(i)", -ENOSYS); } static GVariant *dbus_customlcdon(GDBusConnection *conn, -- 2.7.4 From 919ef5e2153b92821778540ca0c43ebed3558e39 Mon Sep 17 00:00:00 2001 From: youngjae Date: Thu, 1 Jun 2023 19:52:42 +0900 Subject: [PATCH 02/16] display: led: Separate touchled control from key-filter Request for controlling touchled is now directly delivered to touchled module instead of being delivered via key-filter. To this end, the touchled module provides function below. - touchled_control_backlight(enum touchled_opt) Change-Id: I1f90ea18c85bf65f80bdf03d2ef6128c15d99765 Signed-off-by: youngjae --- plugins/iot-headed/display/core.c | 13 +++++-------- plugins/iot-headed/display/key-filter.c | 31 ++----------------------------- plugins/mobile/display/core.c | 13 +++++-------- plugins/mobile/display/key-filter.c | 31 ++----------------------------- plugins/tv/display/core.c | 13 +++++-------- plugins/tv/display/key-filter.c | 31 ++----------------------------- plugins/wearable/display/key-filter.c | 2 -- src/display/core.h | 1 - src/led/touch-key.c | 10 +++------- src/led/touch-key.h | 2 ++ 10 files changed, 26 insertions(+), 121 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index ea7897e..4aadb8c 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -71,6 +71,7 @@ #include "display-config.h" #include "display-state-transition.h" #include "shared/plugin.h" +#include "led/touch-key.h" /** * @addtogroup POWER_MANAGER @@ -267,8 +268,7 @@ void lcd_on_procedure(int state, enum device_flags flag) lcdon_broadcast = true; } - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(true); + touchled_control_backlight(TOUCHLED_DIRECT_ON); touch_blocked = false; } @@ -307,8 +307,7 @@ inline void lcd_off_procedure(enum device_flags flag) set_setting_pmstate(S_LCDOFF); - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); + touchled_control_backlight(TOUCHLED_DIRECT_OFF); display_stop_dependent_device(flags); @@ -1216,10 +1215,8 @@ static int update_setting(int key_idx, int val) break; case SETTING_LOCK_SCREEN: set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) { - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); - } + if (val == VCONFKEY_IDLE_UNLOCK) + touchled_control_backlight(TOUCHLED_DIRECT_OFF); /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 0bf71c9..27176ca 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -106,7 +106,6 @@ static bool touch_pressed = false; static int skip_lcd_off = false; static int skip_combination = false; static int bezel_wakeup = true; -static const struct device_ops *touchled; static int booting_check = true; static inline int current_state_in_on(void) @@ -543,8 +542,6 @@ static void sound_vibrate_hardkey(void) static void process_hardkey_backlight(struct input_event *pinput) { - int opt; - _E("pinput->value : %d", pinput->value); if (pinput->value == KEY_PRESSED) { /* Sound & Vibrate only in unlock state */ @@ -552,10 +549,7 @@ static void process_hardkey_backlight(struct input_event *pinput) || get_lock_screen_bg_state()) sound_vibrate_hardkey(); - if (touchled && touchled->execute) { - opt = TOUCHLED_PRESS; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_PRESS); } else if (pinput->value == KEY_RELEASED) { /* if lockscreen is idle lock */ if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) { @@ -563,10 +557,7 @@ static void process_hardkey_backlight(struct input_event *pinput) return; } - if (touchled && touchled->execute) { - opt = TOUCHLED_RELEASE; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_RELEASE); } } @@ -770,31 +761,13 @@ static void keyfilter_init(void) display_add_actor(&display_powerkey_actor); display_add_actor(&display_menukey_actor); - touchled = find_device(TOUCHLED_NAME); - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); } -static void key_backlight_enable(bool enable) -{ - int opt; - - if (!touchled || !touchled->execute) - return; - - if (enable) - opt = TOUCHLED_DIRECT_ON; - else - opt = TOUCHLED_DIRECT_OFF; - - touchled->execute(&opt); -} - static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .backlight_enable = key_backlight_enable, }; const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 427173c..6c72abe 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -72,6 +72,7 @@ #include "display-config.h" #include "display-state-transition.h" #include "shared/plugin.h" +#include "led/touch-key.h" /** * @addtogroup POWER_MANAGER @@ -274,8 +275,7 @@ void lcd_on_procedure(int state, enum device_flags flag) lcdon_broadcast = true; } - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(true); + touchled_control_backlight(TOUCHLED_DIRECT_ON); touch_blocked = false; } @@ -314,8 +314,7 @@ inline void lcd_off_procedure(enum device_flags flag) set_setting_pmstate(S_LCDOFF); - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); + touchled_control_backlight(TOUCHLED_DIRECT_OFF); display_stop_dependent_device(flags); @@ -1226,10 +1225,8 @@ static int update_setting(int key_idx, int val) break; case SETTING_LOCK_SCREEN: set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) { - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); - } + if (val == VCONFKEY_IDLE_UNLOCK) + touchled_control_backlight(TOUCHLED_DIRECT_OFF); /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 97a2454..bca2172 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -106,7 +106,6 @@ static bool touch_pressed = false; static int skip_lcd_off = false; static int skip_combination = false; static int bezel_wakeup = true; -static const struct device_ops *touchled; static int booting_check = true; static inline int current_state_in_on(void) @@ -575,8 +574,6 @@ static void sound_vibrate_hardkey(void) static void process_hardkey_backlight(struct input_event *pinput) { - int opt; - _E("pinput->value : %d", pinput->value); if (pinput->value == KEY_PRESSED) { /* Sound & Vibrate only in unlock state */ @@ -584,10 +581,7 @@ static void process_hardkey_backlight(struct input_event *pinput) || get_lock_screen_bg_state()) sound_vibrate_hardkey(); - if (touchled && touchled->execute) { - opt = TOUCHLED_PRESS; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_PRESS); } else if (pinput->value == KEY_RELEASED) { /* if lockscreen is idle lock */ if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) { @@ -595,10 +589,7 @@ static void process_hardkey_backlight(struct input_event *pinput) return; } - if (touchled && touchled->execute) { - opt = TOUCHLED_RELEASE; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_RELEASE); } } @@ -796,31 +787,13 @@ static void keyfilter_init(void) display_add_actor(&display_powerkey_actor); display_add_actor(&display_menukey_actor); - touchled = find_device(TOUCHLED_NAME); - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); } -static void key_backlight_enable(bool enable) -{ - int opt; - - if (!touchled || !touchled->execute) - return; - - if (enable) - opt = TOUCHLED_DIRECT_ON; - else - opt = TOUCHLED_DIRECT_OFF; - - touchled->execute(&opt); -} - static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .backlight_enable = key_backlight_enable, }; const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index dff8f4b..25ef935 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -70,6 +70,7 @@ #include "display-config.h" #include "display-state-transition.h" #include "shared/plugin.h" +#include "led/touch-key.h" /** * @addtogroup POWER_MANAGER @@ -267,8 +268,7 @@ void lcd_on_procedure(int state, enum device_flags flag) lcdon_broadcast = true; } - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(true); + touchled_control_backlight(TOUCHLED_DIRECT_ON); touch_blocked = false; } @@ -307,8 +307,7 @@ inline void lcd_off_procedure(enum device_flags flag) set_setting_pmstate(S_LCDOFF); - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); + touchled_control_backlight(TOUCHLED_DIRECT_OFF); display_stop_dependent_device(flags); @@ -1216,10 +1215,8 @@ static int update_setting(int key_idx, int val) break; case SETTING_LOCK_SCREEN: set_lock_screen_state(val); - if (val == VCONFKEY_IDLE_UNLOCK) { - if (CHECK_OPS(keyfilter_ops, backlight_enable)) - keyfilter_ops->backlight_enable(false); - } + if (val == VCONFKEY_IDLE_UNLOCK) + touchled_control_backlight(TOUCHLED_DIRECT_OFF); /* LCD on if lock screen show before waiting time */ if ((get_pm_cur_state() == S_NORMAL) && diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index b2c0c10..dc1db6c 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -106,7 +106,6 @@ static bool touch_pressed = false; static int skip_lcd_off = false; static int skip_combination = false; static int bezel_wakeup = true; -static const struct device_ops *touchled; static int booting_check = true; static inline int current_state_in_on(void) @@ -543,8 +542,6 @@ static void sound_vibrate_hardkey(void) static void process_hardkey_backlight(struct input_event *pinput) { - int opt; - _E("pinput->value : %d", pinput->value); if (pinput->value == KEY_PRESSED) { /* Sound & Vibrate only in unlock state */ @@ -552,10 +549,7 @@ static void process_hardkey_backlight(struct input_event *pinput) || get_lock_screen_bg_state()) sound_vibrate_hardkey(); - if (touchled && touchled->execute) { - opt = TOUCHLED_PRESS; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_PRESS); } else if (pinput->value == KEY_RELEASED) { /* if lockscreen is idle lock */ if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) { @@ -563,10 +557,7 @@ static void process_hardkey_backlight(struct input_event *pinput) return; } - if (touchled && touchled->execute) { - opt = TOUCHLED_RELEASE; - touchled->execute(&opt); - } + touchled_control_backlight(TOUCHLED_RELEASE); } } @@ -764,31 +755,13 @@ static void keyfilter_init(void) display_add_actor(&display_powerkey_actor); display_add_actor(&display_menukey_actor); - touchled = find_device(TOUCHLED_NAME); - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); } -static void key_backlight_enable(bool enable) -{ - int opt; - - if (!touchled || !touchled->execute) - return; - - if (enable) - opt = TOUCHLED_DIRECT_ON; - else - opt = TOUCHLED_DIRECT_OFF; - - touchled->execute(&opt); -} - static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .backlight_enable = key_backlight_enable, }; const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index cf14122..8c4cb04 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -45,7 +45,6 @@ #include "shared/apps.h" #include "power/power-off.h" #include "power/power-suspend.h" -#include "led/touch-key.h" #include "display-lock.h" #ifndef KEY_SCREENLOCK @@ -722,7 +721,6 @@ static void keyfilter_init(void) static const struct display_keyfilter_ops normal_keyfilter_ops = { .init = keyfilter_init, .check = check_key_filter, - .backlight_enable = NULL, }; const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; diff --git a/src/display/core.h b/src/display/core.h index 2b99608..62125e3 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -101,7 +101,6 @@ struct display_keyfilter_ops { void (*init)(void); void (*exit)(void); int (*check)(void *, int); - void (*backlight_enable)(bool); }; extern const struct display_keyfilter_ops *keyfilter_ops; diff --git a/src/led/touch-key.c b/src/led/touch-key.c index ff9db34..0d9d893 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -276,14 +276,11 @@ static void touchled_exit(void *data) touchkey_dev_available = false; } -static int touchled_execute(void *data) +int touchled_control_backlight(enum touchled_opt opt) { - int opt; - - if (!data) - return -EINVAL; + if (!touchkey_dev_available) + return -ENODEV; - opt = *(int *)data; if (opt == TOUCHLED_PRESS) process_touchkey_press(); else if (opt == TOUCHLED_RELEASE) @@ -303,7 +300,6 @@ static const struct device_ops touchled_device_ops = { .probe = touchled_probe, .init = touchled_init, .exit = touchled_exit, - .execute = touchled_execute, }; DEVICE_OPS_REGISTER(&touchled_device_ops) diff --git a/src/led/touch-key.h b/src/led/touch-key.h index 02af982..b09e788 100644 --- a/src/led/touch-key.h +++ b/src/led/touch-key.h @@ -29,4 +29,6 @@ enum touchled_opt { TOUCHLED_DIRECT_OFF, }; +int touchled_control_backlight(enum touchled_opt opt); + #endif -- 2.7.4 From 9410317de657726919dfba401f728b38f5a3b527 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 30 May 2023 20:58:47 +0900 Subject: [PATCH 03/16] display: Remove set_dim_state() from plugins. set_dim_state() was only used in ambient_set_condition(). ambient_set_condition() works at only in the wearable device. Thus, set_dim_state() is removed from iot-headed/mobile/wearable. set_dim_state() is changed to static in the wearable plugin. Change-Id: Ic3882436288e815bb765b9cd471c874246217ace Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 9 +-------- plugins/mobile/display/core.c | 9 +-------- plugins/tv/display/core.c | 9 +-------- plugins/wearable/display/core.c | 2 +- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 4aadb8c..0dcadf9 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -366,13 +366,6 @@ static void update_display_locktime(int time) update_display_time(); } -void set_dim_state(bool on) -{ - _I("Dim state is %d.", on); - update_display_time(); - states[get_pm_cur_state()].trans(EVENT_INPUT); -} - void lcd_on_direct(enum device_flags flags) { enum hal_device_power_transition_reason reason; @@ -1492,7 +1485,7 @@ static int display_probe(void *data) dp->config = &display_conf; init_display_states(dp); setup_display_plugin_backlight_ops(dp); - dp->set_dim_state = set_dim_state; + dp->set_dim_state = NULL; dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 6c72abe..33e50d8 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -373,13 +373,6 @@ static void update_display_locktime(int time) update_display_time(); } -void set_dim_state(bool on) -{ - _I("Dim state is %d.", on); - update_display_time(); - states[get_pm_cur_state()].trans(EVENT_INPUT); -} - void lcd_on_direct(enum device_flags flags) { enum hal_device_power_transition_reason reason; @@ -1502,7 +1495,7 @@ static int display_probe(void *data) dp->config = &display_conf; init_display_states(dp); setup_display_plugin_backlight_ops(dp); - dp->set_dim_state = set_dim_state; + dp->set_dim_state = NULL; dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 25ef935..968eae4 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -366,13 +366,6 @@ static void update_display_locktime(int time) update_display_time(); } -void set_dim_state(bool on) -{ - _I("Dim state is %d.", on); - update_display_time(); - states[get_pm_cur_state()].trans(EVENT_INPUT); -} - void lcd_on_direct(enum device_flags flags) { enum hal_device_power_transition_reason reason; @@ -1493,7 +1486,7 @@ static int display_probe(void *data) dp->config = &display_conf; init_display_states(dp); setup_display_plugin_backlight_ops(dp); - dp->set_dim_state = set_dim_state; + dp->set_dim_state = NULL; dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 34a86a2..7fa444b 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -661,7 +661,7 @@ static void update_display_locktime(int time) update_display_time(); } -void set_dim_state(bool on) +static void set_dim_state(bool on) { _I("Dim state is %d.", on); update_display_time(); -- 2.7.4 From dcfb7099cffc4e84c46d445960f36aa9d25dff78 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 31 May 2023 15:32:49 +0900 Subject: [PATCH 04/16] display: state-transition: Remove update_display_time() display states can have various timeout values depending on the policy. update_display_time() was used for updating timeout values accoring to the priority. In this context, display state transition occurs after a "timeout". This function is added below display-state-transition. void display_state_transition_update_display_state_timeout_by_priority(void); -> This updates timeout values depending on the policy. 1. If there are custom timeout values, then updates to that values. 2. If lockscreen is being displayed, then the screen timeout value will be set to lock_screen_timeout. 3. Lastly, timeout value will be set to default setting value. To support this, getter/setter is added for specific timeout values. Change-Id: I6cf483f17402948546d364a172334a95890238c5 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 92 +++++++++------------------- plugins/mobile/display/core.c | 91 +++++++++------------------ plugins/tv/display/core.c | 92 +++++++++------------------- plugins/wearable/display/core.c | 96 +++++++++-------------------- src/display/display-plugin.c | 13 ++++ src/display/display-plugin.h | 1 + src/display/display-state-transition.c | 108 +++++++++++++++++++++++++++++++++ src/display/display-state-transition.h | 7 +++ 8 files changed, 239 insertions(+), 261 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 0dcadf9..d2c1440 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -78,9 +78,7 @@ * @{ */ -#define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 360000000 #define GESTURE_STR "gesture" #define POWER_KEY_STR "powerkey" @@ -101,11 +99,8 @@ static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; -static unsigned int custom_normal_timeout = 0; -static unsigned int custom_dim_timeout = 0; static char *custom_change_name; static guint lock_timeout_id; -static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -317,53 +312,10 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -static void update_display_time(void) -{ - int run_timeout, val; - - /* first priority : custom timeout */ - if (custom_normal_timeout > 0) { - states[S_NORMAL].timeout = custom_normal_timeout; - states[S_LCDDIM].timeout = custom_dim_timeout; - _I("CUSTOM : timeout is set by normal(%d ms), dim(%d ms)", - custom_normal_timeout, custom_dim_timeout); - return; - } - - /* second priority : lock state */ - if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && - !get_lock_screen_bg_state()) { - /* timeout is different according to key or event. */ - states[S_NORMAL].timeout = lock_screen_timeout; - _I("LOCK: Timeout(%d ms) is set by normal.", - lock_screen_timeout); - return; - } - - /* default setting */ - get_run_timeout(&run_timeout); - - /* for sdk - * if the run_timeout is zero, it regards AlwaysOn state - */ - if (run_timeout == 0 || display_conf.lcd_always_on) { - run_timeout = ALWAYS_ON_TIMEOUT; - _I("LCD always on."); - } - - states[S_NORMAL].timeout = run_timeout; - - get_dim_timeout(&val); - states[S_LCDDIM].timeout = val; - - _I("Normal: NORMAL timeout is set by %d ms", states[S_NORMAL].timeout); - _I("Normal: DIM timeout is set by %d ms", states[S_LCDDIM].timeout); -} - static void update_display_locktime(int time) { - lock_screen_timeout = time; - update_display_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) @@ -422,7 +374,7 @@ int custom_lcdon(int timeout) _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -466,7 +418,7 @@ int custom_lcdoff(enum device_flags flag) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -507,7 +459,7 @@ int display_on_by_reason(const char *reason, int timeout) _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -603,7 +555,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); break; case S_SLEEP: @@ -869,7 +821,7 @@ static int default_trans(int evt) if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (check_lcdoff_direct() == true) { /* enter next state directly */ @@ -1155,7 +1107,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOW_BATT: @@ -1218,13 +1170,13 @@ static int update_setting(int key_idx, int val) is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; @@ -1248,6 +1200,7 @@ static void check_seed_status(void) int bat_state; int brt = 0; int lock_state; + int lock_screen_timeout = 0; /* Charging check */ if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) @@ -1287,6 +1240,7 @@ static void check_seed_status(void) _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); } set_lock_screen_state(lock_state); + display_state_transition_get_lock_screen_timeout(&lock_screen_timeout); if (lock_state == VCONFKEY_IDLE_LOCK) { states[S_NORMAL].timeout = lock_screen_timeout; _I("LCD NORMAL timeout(%d ms) is set" @@ -1337,19 +1291,23 @@ static const char *errMSG[INIT_END] = { int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) { + unsigned int custom_normal_timeout = 0; + unsigned int custom_dim_timeout = 0; + if (on == 0 && dim == 0) { _I("LCD timeout changed: default setting"); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); } else if (on < 0 || dim < 0) { _E("Failed to set value(on=%d dim=%d).", on, dim); return -EINVAL; } else { _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - custom_normal_timeout = SEC_TO_MSEC(on); - custom_dim_timeout = SEC_TO_MSEC(dim); + display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); + display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); } /* Apply new backlight time */ - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); @@ -1366,6 +1324,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = 0; } + display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); + display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); if (custom_normal_timeout == 0 && custom_dim_timeout == 0 && !holdkey_block) @@ -1374,7 +1334,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = strndup(name, strlen(name)); if (!custom_change_name) { _E("Failed to malloc."); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); return -ENOMEM; } @@ -1400,10 +1361,11 @@ void reset_lcd_timeout(GDBusConnection *conn, free(custom_change_name); custom_change_name = 0; - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 33e50d8..a5bda11 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -79,7 +79,6 @@ * @{ */ -#define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 #define ALWAYS_ON_TIMEOUT 360000000 @@ -103,11 +102,8 @@ static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; -static unsigned int custom_normal_timeout = 0; -static unsigned int custom_dim_timeout = 0; static char *custom_change_name; static guint lock_timeout_id; -static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -324,53 +320,10 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -static void update_display_time(void) -{ - int run_timeout, val; - - /* first priority : custom timeout */ - if (custom_normal_timeout > 0) { - states[S_NORMAL].timeout = custom_normal_timeout; - states[S_LCDDIM].timeout = custom_dim_timeout; - _I("CUSTOM : timeout is set by normal(%d ms), dim(%d ms)", - custom_normal_timeout, custom_dim_timeout); - return; - } - - /* second priority : lock state */ - if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && - !get_lock_screen_bg_state()) { - /* timeout is different according to key or event. */ - states[S_NORMAL].timeout = lock_screen_timeout; - _I("LOCK: Timeout(%d ms) is set by normal.", - lock_screen_timeout); - return; - } - - /* default setting */ - get_run_timeout(&run_timeout); - - /* for sdk - * if the run_timeout is zero, it regards AlwaysOn state - */ - if (run_timeout == 0 || display_conf.lcd_always_on) { - run_timeout = ALWAYS_ON_TIMEOUT; - _I("LCD always on."); - } - - states[S_NORMAL].timeout = run_timeout; - - get_dim_timeout(&val); - states[S_LCDDIM].timeout = val; - - _I("Normal: NORMAL timeout is set by %d ms", states[S_NORMAL].timeout); - _I("Normal: DIM timeout is set by %d ms", states[S_LCDDIM].timeout); -} - static void update_display_locktime(int time) { - lock_screen_timeout = time; - update_display_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) @@ -429,7 +382,7 @@ int custom_lcdon(int timeout) _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -473,7 +426,7 @@ int custom_lcdoff(enum device_flags flag) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -514,7 +467,7 @@ int display_on_by_reason(const char *reason, int timeout) _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -614,7 +567,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) lcd_off_procedure(LCD_OFF_BY_EVENT); } if (set_custom_lcdon_timeout(0)) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); break; case S_SLEEP: @@ -879,7 +832,7 @@ static int default_trans(int evt) if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (check_lcdoff_direct() == true) { /* enter next state directly */ @@ -1165,7 +1118,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOW_BATT: @@ -1228,13 +1181,13 @@ static int update_setting(int key_idx, int val) is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; @@ -1258,6 +1211,7 @@ static void check_seed_status(void) int bat_state; int brt = 0; int lock_state; + int lock_screen_timeout = 0; /* Charging check */ if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) @@ -1297,6 +1251,7 @@ static void check_seed_status(void) _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); } set_lock_screen_state(lock_state); + display_state_transition_get_lock_screen_timeout(&lock_screen_timeout); if (lock_state == VCONFKEY_IDLE_LOCK) { states[S_NORMAL].timeout = lock_screen_timeout; _I("LCD NORMAL timeout(%d ms) is set" @@ -1347,19 +1302,23 @@ static const char *errMSG[INIT_END] = { int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) { + unsigned int custom_normal_timeout = 0; + unsigned int custom_dim_timeout = 0; + if (on == 0 && dim == 0) { _I("LCD timeout changed: default setting"); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); } else if (on < 0 || dim < 0) { _E("Failed to set value(on=%d dim=%d).", on, dim); return -EINVAL; } else { _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - custom_normal_timeout = SEC_TO_MSEC(on); - custom_dim_timeout = SEC_TO_MSEC(dim); + display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); + display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); } /* Apply new backlight time */ - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); @@ -1376,6 +1335,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = 0; } + display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); + display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); if (custom_normal_timeout == 0 && custom_dim_timeout == 0 && !holdkey_block) @@ -1384,7 +1345,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = strndup(name, strlen(name)); if (!custom_change_name) { _E("Failed to malloc."); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); return -ENOMEM; } @@ -1410,10 +1372,11 @@ void reset_lcd_timeout(GDBusConnection *conn, free(custom_change_name); custom_change_name = 0; - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 968eae4..6794768 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -77,9 +77,7 @@ * @{ */ -#define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 360000000 #define GESTURE_STR "gesture" #define POWER_KEY_STR "powerkey" @@ -101,11 +99,8 @@ static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; -static unsigned int custom_normal_timeout = 0; -static unsigned int custom_dim_timeout = 0; static char *custom_change_name; static guint lock_timeout_id; -static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -317,53 +312,10 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -static void update_display_time(void) -{ - int run_timeout, val; - - /* first priority : custom timeout */ - if (custom_normal_timeout > 0) { - states[S_NORMAL].timeout = custom_normal_timeout; - states[S_LCDDIM].timeout = custom_dim_timeout; - _I("CUSTOM : timeout is set by normal(%d ms), dim(%d ms)", - custom_normal_timeout, custom_dim_timeout); - return; - } - - /* second priority : lock state */ - if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && - !get_lock_screen_bg_state()) { - /* timeout is different according to key or event. */ - states[S_NORMAL].timeout = lock_screen_timeout; - _I("LOCK: Timeout(%d ms) is set by normal.", - lock_screen_timeout); - return; - } - - /* default setting */ - get_run_timeout(&run_timeout); - - /* for sdk - * if the run_timeout is zero, it regards AlwaysOn state - */ - if (run_timeout == 0 || display_conf.lcd_always_on) { - run_timeout = ALWAYS_ON_TIMEOUT; - _I("LCD always on."); - } - - states[S_NORMAL].timeout = run_timeout; - - get_dim_timeout(&val); - states[S_LCDDIM].timeout = val; - - _I("Normal: NORMAL timeout is set by %d ms", states[S_NORMAL].timeout); - _I("Normal: DIM timeout is set by %d ms", states[S_LCDDIM].timeout); -} - static void update_display_locktime(int time) { - lock_screen_timeout = time; - update_display_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) @@ -422,7 +374,7 @@ int custom_lcdon(int timeout) _I("Custom lcd on timeout(%d ms).", timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -466,7 +418,7 @@ int custom_lcdoff(enum device_flags flag) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -507,7 +459,7 @@ int display_on_by_reason(const char *reason, int timeout) _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -603,7 +555,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); break; case S_SLEEP: @@ -869,7 +821,7 @@ static int default_trans(int evt) if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (check_lcdoff_direct() == true) { /* enter next state directly */ @@ -1155,7 +1107,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOW_BATT: @@ -1218,13 +1170,13 @@ static int update_setting(int key_idx, int val) is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; @@ -1248,6 +1200,7 @@ static void check_seed_status(void) int bat_state; int brt = 0; int lock_state; + int lock_screen_timeout = 0; /* Charging check */ if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) @@ -1287,6 +1240,7 @@ static void check_seed_status(void) _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); } set_lock_screen_state(lock_state); + display_state_transition_get_lock_screen_timeout(&lock_screen_timeout); if (lock_state == VCONFKEY_IDLE_LOCK) { states[S_NORMAL].timeout = lock_screen_timeout; _I("LCD NORMAL timeout(%d ms) is set" @@ -1337,19 +1291,23 @@ static const char *errMSG[INIT_END] = { int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) { + unsigned int custom_normal_timeout = 0; + unsigned int custom_dim_timeout = 0; + if (on == 0 && dim == 0) { _I("LCD timeout changed: default setting"); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); } else if (on < 0 || dim < 0) { _E("Failed to set value(on=%d dim=%d).", on, dim); return -EINVAL; } else { _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - custom_normal_timeout = SEC_TO_MSEC(on); - custom_dim_timeout = SEC_TO_MSEC(dim); + display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); + display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); } /* Apply new backlight time */ - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); @@ -1366,6 +1324,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = 0; } + display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); + display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); if (custom_normal_timeout == 0 && custom_dim_timeout == 0 && !holdkey_block) @@ -1374,7 +1334,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = strndup(name, strlen(name)); if (!custom_change_name) { _E("Failed to malloc."); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); return -ENOMEM; } @@ -1400,10 +1361,11 @@ void reset_lcd_timeout(GDBusConnection *conn, free(custom_change_name); custom_change_name = 0; - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 7fa444b..600c6f2 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -85,9 +85,7 @@ * @{ */ -#define LOCK_SCREEN_INPUT_TIMEOUT 10000 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 360000000 #define LATE_LCD_TRANSIT 1 #define GESTURE_STR "gesture" @@ -113,12 +111,9 @@ static void (*power_saving_func) (int onoff); static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; -static unsigned int custom_normal_timeout = 0; -static unsigned int custom_dim_timeout = 0; static char *custom_change_name; static guint lock_timeout_id; static guint transit_timer; -static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -612,59 +607,16 @@ inline void lcd_off_procedure(enum device_flags flag) enter_doze(); } -static void update_display_time(void) -{ - int run_timeout, val; - - /* first priority : custom timeout */ - if (custom_normal_timeout > 0) { - states[S_NORMAL].timeout = custom_normal_timeout; - states[S_LCDDIM].timeout = custom_dim_timeout; - _I("CUSTOM : timeout is set by normal(%d ms), dim(%d ms)", - custom_normal_timeout, custom_dim_timeout); - return; - } - - /* second priority : lock state */ - if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && - !get_lock_screen_bg_state()) { - /* timeout is different according to key or event. */ - states[S_NORMAL].timeout = lock_screen_timeout; - _I("LOCK: Timeout(%d ms) is set by normal.", - lock_screen_timeout); - return; - } - - /* default setting */ - get_run_timeout(&run_timeout); - - /* for sdk - * if the run_timeout is zero, it regards AlwaysOn state - */ - if (run_timeout == 0 || display_conf.lcd_always_on) { - run_timeout = ALWAYS_ON_TIMEOUT; - _I("LCD always on."); - } - - states[S_NORMAL].timeout = run_timeout; - - get_dim_timeout(&val); - states[S_LCDDIM].timeout = val; - - _I("Normal: NORMAL timeout is set by %d ms", states[S_NORMAL].timeout); - _I("Normal: DIM timeout is set by %d ms", states[S_LCDDIM].timeout); -} - static void update_display_locktime(int time) { - lock_screen_timeout = time; - update_display_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); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); states[get_pm_cur_state()].trans(EVENT_INPUT); } @@ -714,7 +666,7 @@ static gboolean timer_refresh_cb(gpointer data) * When the device's screen is another app, it will do turn off after 7 seconds. */ if (set_custom_lcdon_timeout(5000) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -751,7 +703,7 @@ int custom_lcdon(int timeout) } if (update) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -796,7 +748,7 @@ int custom_lcdoff(enum device_flags flag) lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -837,7 +789,7 @@ int display_on_by_reason(const char *reason, int timeout) _I("platform lcd on by %s (%d ms)", reason, timeout); if (set_custom_lcdon_timeout(timeout) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -938,7 +890,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); break; case S_SLEEP: @@ -1213,7 +1165,7 @@ static int default_trans(int evt) if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (check_lcdoff_direct() == true) { /* enter next state directly */ @@ -1511,7 +1463,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOW_BATT: @@ -1572,13 +1524,13 @@ static int update_setting(int key_idx, int val) is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); stop_lock_timer(); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); break; @@ -1602,6 +1554,7 @@ static void check_seed_status(void) int bat_state; int brt = 0; int lock_state; + int lock_screen_timeout = 0; /* Charging check */ if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0)) @@ -1641,6 +1594,7 @@ static void check_seed_status(void) _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); } set_lock_screen_state(lock_state); + display_state_transition_get_lock_screen_timeout(&lock_screen_timeout); if (lock_state == VCONFKEY_IDLE_LOCK) { states[S_NORMAL].timeout = lock_screen_timeout; _I("LCD NORMAL timeout(%d ms) is set" @@ -1691,19 +1645,23 @@ static const char *errMSG[INIT_END] = { int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) { + unsigned int custom_normal_timeout = 0; + unsigned int custom_dim_timeout = 0; + if (on == 0 && dim == 0) { _I("LCD timeout changed: default setting"); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); } else if (on < 0 || dim < 0) { _E("Failed to set value(on=%d dim=%d).", on, dim); return -EINVAL; } else { _I("LCD timeout changed: on=%ds dim=%ds", on, dim); - custom_normal_timeout = SEC_TO_MSEC(on); - custom_dim_timeout = SEC_TO_MSEC(dim); + display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on)); + display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim)); } /* Apply new backlight time */ - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); @@ -1720,6 +1678,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = 0; } + display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout); + display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout); if (custom_normal_timeout == 0 && custom_dim_timeout == 0 && !holdkey_block) @@ -1728,7 +1688,8 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) custom_change_name = strndup(name, strlen(name)); if (!custom_change_name) { _E("Failed to malloc."); - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); return -ENOMEM; } @@ -1754,10 +1715,11 @@ void reset_lcd_timeout(GDBusConnection *conn, free(custom_change_name); custom_change_name = 0; - custom_normal_timeout = custom_dim_timeout = 0; + display_state_transition_set_custom_timeout(S_NORMAL, 0); + display_state_transition_set_custom_timeout(S_LCDDIM, 0); display_lock_set_custom_holdkey_block(false); - update_display_time(); + display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); } diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 14d1863..9985701 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -250,6 +250,19 @@ int display_plugin_config_get_lcdoff_timeout(int *lcdoff_timeout) return -EOPNOTSUPP; } +int display_plugin_config_get_lcd_always_on(int *lcd_always_on) +{ + if (!lcd_always_on) + return -EINVAL; + + if (g_display_plugin.config) { + *lcd_always_on = g_display_plugin.config->lcd_always_on; + return 0; + } + + return -EOPNOTSUPP; +} + int display_plugin_set_dim_state(bool on) { if (g_display_plugin.set_dim_state) { diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index e66a7c4..fe88489 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -106,5 +106,6 @@ int display_plugin_state_get_state_by_state_index(int state_index, enum state_t /* 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); +int display_plugin_config_get_lcd_always_on(int *lcd_always_on); #endif //__DISPLAY_PLUGIN_H__ diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index d61667c..5676860 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -23,11 +23,17 @@ #include "device-interface.h" #include "display-state-transition.h" +#include "display-lock.h" #include "display-plugin.h" #include "power/power-suspend.h" #include "shared/log.h" +#define ALWAYS_ON_TIMEOUT 360000000 + static guint state_transition_timer_id; +static unsigned int custom_normal_timeout = 0; +static unsigned int custom_dim_timeout = 0; +static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT; static int trans_table[S_END][EVENT_END] = { /* Timeout, Input */ @@ -116,4 +122,106 @@ int display_state_transition_reset_state_transition_timeout(int timeout) display_plugin_state_do_default_trans(get_pm_cur_state(), EVENT_TIMEOUT); return 0; +} + +int display_state_transition_set_custom_timeout(enum state_t state, unsigned int timeout) +{ + const char *state_name = NULL; + + switch (state) { + case S_NORMAL: + custom_normal_timeout = timeout; + case S_LCDDIM: + custom_dim_timeout = timeout; + default: + display_plugin_state_get_name(state, &state_name); + _W("%s state has no custom timeout", state_name); + return -EPERM; + } + return 0; +} + +int display_state_transition_get_custom_timeout(enum state_t state, unsigned int *timeout) +{ + if (!timeout) + return -EINVAL; + + const char *state_name = NULL; + + switch (state) { + case S_NORMAL: + *timeout = custom_normal_timeout; + case S_LCDDIM: + *timeout = custom_dim_timeout; + default: + *timeout = 0; + display_plugin_state_get_name(state, &state_name); + _W("There is no specific timeout value for %s state", state_name); + } + return 0; +} + + +int display_state_transition_set_lock_screen_timeout(int timeout) +{ + lock_screen_timeout = timeout; + return 0; +} + +int display_state_transition_get_lock_screen_timeout(int *timeout) +{ + if (!timeout) + return -EINVAL; + + *timeout = lock_screen_timeout; + return 0; +} + +void display_state_transition_update_display_state_timeout_by_priority(void) +{ + int run_timeout, val; + int lcd_always_on = 0; + int normal_state_timeout = 0; + int dim_state_timeout = 0; + + /* first priority : custom timeout */ + if (custom_normal_timeout > 0) { + display_plugin_state_set_timeout(S_NORMAL, custom_normal_timeout); + display_plugin_state_set_timeout(S_LCDDIM, custom_dim_timeout); + _I("CUSTOM : timeout is set by normal(%u ms), dim(%u ms)", + custom_normal_timeout, custom_dim_timeout); + return; + } + + /* second priority : lock state */ + if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) && + !get_lock_screen_bg_state()) { + /* timeout is different according to key or event. */ + display_plugin_state_set_timeout(S_NORMAL, lock_screen_timeout); + _I("LOCK: Timeout(%d ms) is set by normal.", + lock_screen_timeout); + return; + } + + /* default setting */ + get_run_timeout(&run_timeout); + + /* for sdk + * if the run_timeout is zero, it regards AlwaysOn state + */ + display_plugin_config_get_lcd_always_on(&lcd_always_on); + if (run_timeout == 0 || lcd_always_on) { + run_timeout = ALWAYS_ON_TIMEOUT; + _I("LCD always on."); + } + + display_plugin_state_set_timeout(S_NORMAL, run_timeout); + + get_dim_timeout(&val); + display_plugin_state_set_timeout(S_LCDDIM, val); + + display_plugin_state_get_timeout(S_NORMAL, &normal_state_timeout); + display_plugin_state_get_timeout(S_LCDDIM, &dim_state_timeout); + _I("Normal: NORMAL timeout is set by %d ms", normal_state_timeout); + _I("Normal: DIM timeout is set by %d ms", dim_state_timeout); } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index a8bab4d..51762a1 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -26,9 +26,16 @@ #include "core.h" +#define LOCK_SCREEN_INPUT_TIMEOUT 10000 + int display_state_transition_get_next_transition_display_state(enum state_t from_state, enum state_t *to_state, int evt_type); int display_state_transition_set_transition_table_display_state(enum state_t display_state, enum state_t set_state, int evt_type); bool display_state_transition_is_there_state_transition_timer(void); int display_state_transition_reset_state_transition_timeout(int timeout); +int display_state_transition_set_custom_timeout(enum state_t state, unsigned int timeout); +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_display_state_timeout_by_priority(void); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file -- 2.7.4 From ef7c8c2fa4c75c90a9d7eaa94800178c5373f826 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Mon, 5 Jun 2023 19:24:02 +0900 Subject: [PATCH 05/16] display: state-transition: Remove default_check() default_check() was used for checking state transition condition. If there is any pmlock of the state checked which is not background status, it is impossible to move next state. default_check() follows same policy from all plugins. To move from current display state to next display state, this function is necessary. Thus, this function is added below display-state-transition. int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state); Change-Id: I06adb467ac81a04596f22a7b0fe9b06c3b72d248 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 52 +++++---------------------------- plugins/mobile/display/core.c | 53 +++++----------------------------- plugins/tv/display/core.c | 52 +++++---------------------------- plugins/wearable/display/core.c | 51 ++++---------------------------- src/display/display-plugin.c | 8 ----- src/display/display-plugin.h | 1 - src/display/display-state-transition.c | 52 +++++++++++++++++++++++++++++++++ src/display/display-state-transition.h | 1 + 8 files changed, 80 insertions(+), 190 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index d2c1440..8634eb6 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -113,18 +113,17 @@ static bool touch_blocked = false; /* default transition, action fuctions */ static int default_trans(int evt); static int default_action(int timeout); -static int default_check(int curr, int next); static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL }, + { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL }, + { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -798,11 +797,13 @@ static int default_trans(int evt) { struct state *st = &states[get_pm_cur_state()]; enum state_t next_state; + int ret = 0; display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); /* check conditions */ - if (st->check && !st->check(get_pm_cur_state(), next_state)) { + ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); + if (ret < 0) { /* There is a condition. */ _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, states[next_state].name); @@ -1019,45 +1020,6 @@ go_lcd_off: return 0; } -/* - * default check function - * return - * 0 : can't transit, others : transitable - */ -static int default_check(int curr, int next) -{ - int trans_cond; - - makeup_trans_condition(); - - trans_cond = get_trans_condition() & MASK_BIT; - - if (next == S_NORMAL) /* S_NORMAL is exceptional */ - return 1; - - switch (curr) { - case S_NORMAL: - trans_cond = trans_cond & MASK_NORMAL; - break; - case S_LCDDIM: - trans_cond = trans_cond & MASK_DIM; - break; - case S_LCDOFF: - trans_cond = trans_cond & MASK_OFF; - break; - default: - trans_cond = 0; - break; - } - - if (trans_cond != 0) { - print_node(curr); - return 0; - } - - return 1; /* transitable */ -} - static void default_saving_mode(int onoff) { if (onoff) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index a5bda11..e29de08 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -80,7 +80,6 @@ */ #define LOCK_SCREEN_CONTROL_TIMEOUT 5000 -#define ALWAYS_ON_TIMEOUT 360000000 #define GESTURE_STR "gesture" #define POWER_KEY_STR "powerkey" @@ -116,18 +115,17 @@ static bool touch_blocked = false; /* default transition, action fuctions */ static int default_trans(int evt); static int default_action(int timeout); -static int default_check(int curr, int next); static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL }, + { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL }, + { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -809,11 +807,13 @@ static int default_trans(int evt) { struct state *st = &states[get_pm_cur_state()]; enum state_t next_state; + int ret = 0; display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); /* check conditions */ - if (st->check && !st->check(get_pm_cur_state(), next_state)) { + ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); + if (ret < 0) { /* There is a condition. */ _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, states[next_state].name); @@ -1030,45 +1030,6 @@ go_lcd_off: return 0; } -/* - * default check function - * return - * 0 : can't transit, others : transitable - */ -static int default_check(int curr, int next) -{ - int trans_cond; - - makeup_trans_condition(); - - trans_cond = get_trans_condition() & MASK_BIT; - - if (next == S_NORMAL) /* S_NORMAL is exceptional */ - return 1; - - switch (curr) { - case S_NORMAL: - trans_cond = trans_cond & MASK_NORMAL; - break; - case S_LCDDIM: - trans_cond = trans_cond & MASK_DIM; - break; - case S_LCDOFF: - trans_cond = trans_cond & MASK_OFF; - break; - default: - trans_cond = 0; - break; - } - - if (trans_cond != 0) { - print_node(curr); - return 0; - } - - return 1; /* transitable */ -} - static void default_saving_mode(int onoff) { if (onoff) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 6794768..32a23c2 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -113,18 +113,17 @@ static bool touch_blocked = false; /* default transition, action fuctions */ static int default_trans(int evt); static int default_action(int timeout); -static int default_check(int curr, int next); static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL }, + { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL }, + { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -798,11 +797,13 @@ static int default_trans(int evt) { struct state *st = &states[get_pm_cur_state()]; enum state_t next_state; + int ret = 0; display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); /* check conditions */ - if (st->check && !st->check(get_pm_cur_state(), next_state)) { + ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); + if (ret < 0) { /* There is a condition. */ _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, states[next_state].name); @@ -1019,45 +1020,6 @@ go_lcd_off: return 0; } -/* - * default check function - * return - * 0 : can't transit, others : transitable - */ -static int default_check(int curr, int next) -{ - int trans_cond; - - makeup_trans_condition(); - - trans_cond = get_trans_condition() & MASK_BIT; - - if (next == S_NORMAL) /* S_NORMAL is exceptional */ - return 1; - - switch (curr) { - case S_NORMAL: - trans_cond = trans_cond & MASK_NORMAL; - break; - case S_LCDDIM: - trans_cond = trans_cond & MASK_DIM; - break; - case S_LCDOFF: - trans_cond = trans_cond & MASK_OFF; - break; - default: - trans_cond = 0; - break; - } - - if (trans_cond != 0) { - print_node(curr); - return 0; - } - - return 1; /* transitable */ -} - static void default_saving_mode(int onoff) { if (onoff) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 600c6f2..e3bd04d 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -126,18 +126,17 @@ static bool touch_blocked = false; /* default transition, action fuctions */ static int default_trans(int evt); static int default_action(int timeout); -static int default_check(int curr, int next); static int default_proc_change_state(unsigned int cond, pid_t pid); static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state; static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, default_check, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, default_check, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, default_check, NULL }, + { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, default_check, NULL }, + { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -1138,7 +1137,8 @@ static int default_trans(int evt) display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); /* check conditions */ - if (st->check && !st->check(get_pm_cur_state(), next_state)) { + ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); + if (ret < 0) { /* There is a condition. */ _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, states[next_state].name); @@ -1375,45 +1375,6 @@ go_lcd_off: return 0; } -/* - * default check function - * return - * 0 : can't transit, others : transitable - */ -static int default_check(int curr, int next) -{ - int trans_cond; - - makeup_trans_condition(); - - trans_cond = get_trans_condition() & MASK_BIT; - - if (next == S_NORMAL) /* S_NORMAL is exceptional */ - return 1; - - switch (curr) { - case S_NORMAL: - trans_cond = trans_cond & MASK_NORMAL; - break; - case S_LCDDIM: - trans_cond = trans_cond & MASK_DIM; - break; - case S_LCDOFF: - trans_cond = trans_cond & MASK_OFF; - break; - default: - trans_cond = 0; - break; - } - - if (trans_cond != 0) { - print_node(curr); - return 0; - } - - return 1; /* transitable */ -} - static void default_saving_mode(int onoff) { if (onoff) { diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 9985701..2e7ffac 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -166,14 +166,6 @@ int display_plugin_state_do_default_action(enum state_t state, int timeout) return -EOPNOTSUPP; } -int display_plugin_state_do_default_check(enum state_t state, int curr, int next) -{ - if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->check) - return g_display_plugin.display_states[state]->check(curr, next); - - return -EOPNOTSUPP; -} - int display_plugin_state_get_name(enum state_t state, const char **state_name) { if (!state_name) diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index fe88489..09d8aa3 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -97,7 +97,6 @@ int display_plugin_backlight_transit_brightness(int start, int end, int step); int display_plugin_state_do_default_trans(enum state_t state, int evt); bool display_plugin_state_is_there_default_trans(enum state_t state); int display_plugin_state_do_default_action(enum state_t state, int timeout); -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); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 5676860..002f838 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -224,4 +224,56 @@ void display_state_transition_update_display_state_timeout_by_priority(void) display_plugin_state_get_timeout(S_LCDDIM, &dim_state_timeout); _I("Normal: NORMAL timeout is set by %d ms", normal_state_timeout); _I("Normal: DIM timeout is set by %d ms", dim_state_timeout); +} + +static bool is_display_state_valid_for_transition(enum state_t state) +{ + switch(state) { + case S_NORMAL: + case S_LCDDIM: + case S_LCDOFF: + case S_SLEEP: + return true; + default: + return false; + } + + return false; +} + +int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state) +{ + int trans_cond; + + if (!is_display_state_valid_for_transition(cur_state)) + return -EPERM; + + makeup_trans_condition(); + + trans_cond = get_trans_condition() & MASK_BIT; + + if (next_state == S_NORMAL) /* S_NORMAL is exceptional */ + return 0; + + switch (cur_state) { + case S_NORMAL: + trans_cond = trans_cond & MASK_NORMAL; + break; + case S_LCDDIM: + trans_cond = trans_cond & MASK_DIM; + break; + case S_LCDOFF: + trans_cond = trans_cond & MASK_OFF; + break; + default: + trans_cond = 0; + break; + } + + if (trans_cond != 0) { + print_node(cur_state); + return -EPERM; + } + + return 0; /* transitable */ } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index 51762a1..caed462 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -37,5 +37,6 @@ int display_state_transition_get_custom_timeout(enum state_t state, unsigned int 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_display_state_timeout_by_priority(void); +int display_state_transition_check_state_transition_condition(enum state_t cur_state, enum state_t next_state); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file -- 2.7.4 From fc0615bae3ea4617441d83418ba04d2078e0af5c Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 16 May 2023 11:33:42 +0200 Subject: [PATCH 06/16] earjack: Properly detect initial state if more than one extcon exists Add the same logic as for USB cable in commit c9dee14b ("usb-gadget: Handle more than one extcon reporting USB cable") to properly detect initial jack state if it has been reported by more than one extcon device. Signed-off-by: Marek Szyprowski Change-Id: I0ce89c1eae22bf06eb406ffe40080f06cce89198 --- src/extcon/earjack.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 43e8db2..87fcc57 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -70,9 +70,26 @@ static void earjack_send_system_event(int status) static int earjack_update(const char *index, int status) { + static int old_status = -1; /* -1: Uninitialized, 0: disconnected, 1: connected */ + static char old_index[NAME_MAX]; int ret; - _I("Earjack changed. status=%d", status); + _I("Earjack state change reported by extcon \"%s\" from (%d) to (%d).", index ? index : "(NULL)", old_status, status); + + if (old_index[0] != '\0' && index && strncmp(old_index, index, sizeof(old_index)) != 0) { + _I("Earjack state change ignored, previously it was connected via extcon \"%s\"\n", old_index); + return 0; + } + + if (old_status == status) + return 0; + + old_index[0] = '\0'; + if (index && status != EARJACK_DISCONNECTED) { + strncpy(old_index, index, sizeof(old_index) - 1); + old_index[sizeof(old_index) - 1] = '\0'; + } + ret = vconf_set_int(VCONFKEY_SYSMAN_EARJACK, status); if (ret < 0) _E("Failed to set vconf value for earjack: %d", vconf_get_ext_errno()); @@ -82,6 +99,8 @@ static int earjack_update(const char *index, int status) display_plugin_pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); } + old_status = status; + return 0; } -- 2.7.4 From 4a55269acd802b2178c579997b2bee795618e2b4 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 1 Jun 2023 19:00:57 +0900 Subject: [PATCH 07/16] input: Make core be responsible for parsing instead of plugin Previously, The input core was just polling input event, and plugin was responsible for parsing and handling that event. The 'parsing' here means converting libinput data structure into that of the deviced. All plugins had followed same parsing logic, which had been able to become a part of the core module. Therefore, the input core now has changed to parse input event as well as polling. To pass parsed event to plugin, the input core provides two function, which can be utilized by plugin for registering callbacks. - int input_register_event_callback() - int input_unregister_event_callback() With this change, plugin can now only focus on event handling, putting parsing aside. Change-Id: I872b22ef5c33c23f9be8b804f4a0dc92848483c9 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 7 -- plugins/iot-headed/display/key-filter.c | 57 ++++----- plugins/iot-headless/input/input-handler.c | 53 +++----- plugins/mobile/display/core.c | 7 -- plugins/mobile/display/key-filter.c | 57 ++++----- plugins/tv/display/core.c | 7 -- plugins/tv/display/key-filter.c | 57 ++++----- plugins/wearable/display/core.c | 7 -- plugins/wearable/display/key-filter.c | 54 +++++---- src/display/core.h | 8 -- src/display/plugin-common/display-input.c | 129 -------------------- src/display/poll.h | 4 - src/input/input-dbus.c | 6 +- src/input/input-interface.h | 30 ----- src/input/input.c | 186 ++++++++++++++++++++++++----- src/input/input.h | 13 +- 16 files changed, 301 insertions(+), 381 deletions(-) delete mode 100644 src/display/plugin-common/display-input.c delete mode 100644 src/input/input-interface.h diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 8634eb6..a0f1c85 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -1641,10 +1641,6 @@ static void display_init(void *data) } - if (display_conf.input_support) - if (CHECK_OPS(keyfilter_ops, init)) - keyfilter_ops->init(); - set_display_init_direction(display_conf.display_init_direction); } } @@ -1661,9 +1657,6 @@ static void display_exit(void *data) /* timeout is not needed */ display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE); - if (CHECK_OPS(keyfilter_ops, exit)) - keyfilter_ops->exit(); - unregister_kernel_uevent_control(&lcd_uevent_ops); display_ops_exit(NULL); diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 27176ca..35a18b3 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -47,6 +47,7 @@ #include "power/power-suspend.h" #include "led/touch-key.h" #include "display-lock.h" +#include "input/input.h" #ifndef KEY_SCREENLOCK #define KEY_SCREENLOCK 0x98 @@ -578,7 +579,7 @@ static void update_vital_state(struct input_event *pinput) } } -static int check_key(struct input_event *pinput, int fd) +static int check_key(struct input_event *pinput) { int ignore = true; @@ -651,11 +652,16 @@ static int check_key(struct input_event *pinput, int fd) return ignore; } -static int check_key_filter(void *data, int fd) +static void check_key_filter(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue) { - struct input_event *pinput = data; + struct input_event *pinput = &(struct input_event) { + .time = time, + .type = type, + .code = keycode, + .value = keyvalue + }; int ignore = true; - static int old_fd, code, value; + static int code, value; assert(pinput); @@ -673,8 +679,7 @@ static int check_key_filter(void *data, int fd) if (pinput->code == BTN_TOUCH && !current_state_in_on()) break; if (pinput->code == code && pinput->value == value) { - _E("Same key(%d, %d) is polled [%d,%d]", - code, value, old_fd, fd); + _E("Same key(%d, %d) is polled", code, value); } gdbus_signal_emit(NULL, DEVICED_PATH_INPUT, @@ -682,12 +687,11 @@ static int check_key_filter(void *data, int fd) "key", g_variant_new("(iiii)", pinput->code, pinput->value, pinput->time.tv_sec, pinput->time.tv_usec)); - old_fd = fd; code = pinput->code; value = pinput->value; update_vital_state(pinput); - ignore = check_key(pinput, fd); + ignore = check_key(pinput); restore_custom_brightness(); break; @@ -699,6 +703,11 @@ static int check_key_filter(void *data, int fd) ignore = false; break; case EV_ABS: + if (touch_event_blocked() + && !g_display_plugin.config->touch_wakeup + && pinput->value == KEY_BEING_PRESSED) + return; + update_vital_state(pinput); if (pinput->value == KEY_PRESSED) { switch_on_lcd(LCD_ON_BY_TOUCH); @@ -720,9 +729,10 @@ static int check_key_filter(void *data, int fd) } if (ignore) - return 1; + return; - return 0; + /* lcd on or update lcd timeout */ + poll_callback(INPUT_POLL_EVENT, NULL); } static int delayed_init_done(void *data) @@ -756,30 +766,21 @@ static struct display_actor_ops display_menukey_actor = { .caps = DISPLAY_CAPA_LCDON, }; -static void keyfilter_init(void) -{ - display_add_actor(&display_powerkey_actor); - display_add_actor(&display_menukey_actor); - - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); - register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); -} - -static const struct display_keyfilter_ops normal_keyfilter_ops = { - .init = keyfilter_init, - .check = check_key_filter, -}; - -const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; - static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_var_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin variable."); - } backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_add_actor(&display_powerkey_actor); + display_add_actor(&display_menukey_actor); + + register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); + + input_register_event_callback(check_key_filter, NULL, NULL, NULL); } diff --git a/plugins/iot-headless/input/input-handler.c b/plugins/iot-headless/input/input-handler.c index 81f3978..2f02aa5 100644 --- a/plugins/iot-headless/input/input-handler.c +++ b/plugins/iot-headless/input/input-handler.c @@ -28,13 +28,12 @@ #include "shared/device-notifier.h" #include "shared/log.h" #include "shared/event.h" -#include "input/input-interface.h" #include "input-config.h" #include "input-dbus.h" +#include "input/input.h" -#define KEYVALUE_PRESS 1 -#define KEYVALUE_RELEASE 0 +static int input_event_handler_id; static gboolean level_event_detected(gpointer data) { @@ -128,66 +127,46 @@ static void stop_event_timer(struct input_config *ic) } } -static void input_handler_process_key(int keycode, int keyvalue) +static void input_handler_process_key(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue) { struct input_config *ic; + if (type != EV_KEY) + return; + _D("Key input: code=%d, value=%d", keycode, keyvalue); /* acquire tmplock on pressing key */ - if (keyvalue == KEYVALUE_PRESS) + if (keyvalue == KEY_PRESSED) device_notify(DEVICE_NOTIFIER_KEY_PRESS, (void *)(intptr_t) keycode); /* process all registered event to the keycode */ ic = find_input_config(keycode); - if (ic && keyvalue == KEYVALUE_PRESS) + if (ic && keyvalue == KEY_PRESSED) start_event_timer(ic); - else if (ic && keyvalue == KEYVALUE_RELEASE) + else if (ic && keyvalue == KEY_RELEASED) stop_event_timer(ic); /* release tmplock on releasing key */ - if (keyvalue == KEYVALUE_RELEASE) + if (keyvalue == KEY_RELEASED) device_notify(DEVICE_NOTIFIER_KEY_RELEASE, (void *)(intptr_t) keycode); } -static int input_handler_execute(void *data) +static void input_handler_init(void *data) { - struct libinput_event *e; - struct libinput_event_keyboard *ek; - int keycode, keyvalue; - - if (!data) - return 0; - - e = (struct libinput_event *) data; - - if (libinput_event_get_type(e) != LIBINPUT_EVENT_KEYBOARD_KEY) - return 0; - - ek = libinput_event_get_keyboard_event(e); - keycode = libinput_event_keyboard_get_key(ek); - keyvalue = libinput_event_keyboard_get_key_state(ek); - - input_handler_process_key(keycode, keyvalue); - - return 0; + init_input_config(); + input_register_event_callback(input_handler_process_key, NULL, NULL, &input_event_handler_id); } -static struct input_ops input_handler_ops = { - .input_handler_process_key = input_handler_process_key, -}; - -static void input_handler_init(void *data) +static void input_handler_exit(void *data) { - init_input_config(); - *(struct input_ops**)data = &input_handler_ops; + input_unregister_event_callback(input_event_handler_id); } static const struct device_ops input_handler_device_ops = { DECLARE_NAME_LEN("input-handler"), .init = input_handler_init, - .execute = input_handler_execute, - .disable_auto_init = true, /* initialized by core input module */ + .exit = input_handler_exit, }; DEVICE_OPS_REGISTER(&input_handler_device_ops) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index e29de08..fda90ef 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1647,10 +1647,6 @@ static void display_init(void *data) } - if (display_conf.input_support) - if (CHECK_OPS(keyfilter_ops, init)) - keyfilter_ops->init(); - set_display_init_direction(display_conf.display_init_direction); } } @@ -1667,9 +1663,6 @@ static void display_exit(void *data) /* timeout is not needed */ display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE); - if (CHECK_OPS(keyfilter_ops, exit)) - keyfilter_ops->exit(); - unregister_kernel_uevent_control(&lcd_uevent_ops); display_ops_exit(NULL); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index bca2172..e05a94b 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -47,6 +47,7 @@ #include "power/power-suspend.h" #include "led/touch-key.h" #include "display-lock.h" +#include "input/input.h" #ifndef KEY_SCREENLOCK #define KEY_SCREENLOCK 0x98 @@ -610,7 +611,7 @@ static void update_vital_state(struct input_event *pinput) } } -static int check_key(struct input_event *pinput, int fd) +static int check_key(struct input_event *pinput) { int ignore = true; @@ -683,11 +684,16 @@ static int check_key(struct input_event *pinput, int fd) return ignore; } -static int check_key_filter(void *data, int fd) +static void check_key_filter(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue) { - struct input_event *pinput = data; + struct input_event *pinput = &(struct input_event) { + .time = time, + .type = type, + .code = keycode, + .value = keyvalue + }; int ignore = true; - static int old_fd, code, value; + static int code, value; assert(pinput); @@ -705,15 +711,13 @@ static int check_key_filter(void *data, int fd) if (pinput->code == BTN_TOUCH && !current_state_in_on()) break; if (pinput->code == code && pinput->value == value) { - _E("Same key(%d, %d) is polled [%d,%d]", - code, value, old_fd, fd); + _E("Same key(%d, %d) is polled", code, value); } - old_fd = fd; code = pinput->code; value = pinput->value; update_vital_state(pinput); - ignore = check_key(pinput, fd); + ignore = check_key(pinput); restore_custom_brightness(); break; @@ -725,6 +729,11 @@ static int check_key_filter(void *data, int fd) ignore = false; break; case EV_ABS: + if (touch_event_blocked() + && !g_display_plugin.config->touch_wakeup + && pinput->value == KEY_BEING_PRESSED) + return; + update_vital_state(pinput); if (pinput->value == KEY_PRESSED) { switch_on_lcd(LCD_ON_BY_TOUCH); @@ -746,9 +755,10 @@ static int check_key_filter(void *data, int fd) } if (ignore) - return 1; + return; - return 0; + /* lcd on or update lcd timeout */ + poll_callback(INPUT_POLL_EVENT, NULL); } static int delayed_init_done(void *data) @@ -782,30 +792,21 @@ static struct display_actor_ops display_menukey_actor = { .caps = DISPLAY_CAPA_LCDON, }; -static void keyfilter_init(void) -{ - display_add_actor(&display_powerkey_actor); - display_add_actor(&display_menukey_actor); - - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); - register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); -} - -static const struct display_keyfilter_ops normal_keyfilter_ops = { - .init = keyfilter_init, - .check = check_key_filter, -}; - -const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; - static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_var_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin variable."); - } backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_add_actor(&display_powerkey_actor); + display_add_actor(&display_menukey_actor); + + register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); + + input_register_event_callback(check_key_filter, NULL, NULL, NULL); } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 32a23c2..1d735d0 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1638,10 +1638,6 @@ static void display_init(void *data) } - if (display_conf.input_support) - if (CHECK_OPS(keyfilter_ops, init)) - keyfilter_ops->init(); - set_display_init_direction(display_conf.display_init_direction); } } @@ -1658,9 +1654,6 @@ static void display_exit(void *data) /* timeout is not needed */ display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE); - if (CHECK_OPS(keyfilter_ops, exit)) - keyfilter_ops->exit(); - unregister_kernel_uevent_control(&lcd_uevent_ops); display_ops_exit(NULL); diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index dc1db6c..424e4a1 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -47,6 +47,7 @@ #include "power/power-suspend.h" #include "led/touch-key.h" #include "display-lock.h" +#include "input/input.h" #ifndef KEY_SCREENLOCK #define KEY_SCREENLOCK 0x98 @@ -578,7 +579,7 @@ static void update_vital_state(struct input_event *pinput) } } -static int check_key(struct input_event *pinput, int fd) +static int check_key(struct input_event *pinput) { int ignore = true; @@ -651,11 +652,16 @@ static int check_key(struct input_event *pinput, int fd) return ignore; } -static int check_key_filter(void *data, int fd) +static void check_key_filter(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue) { - struct input_event *pinput = data; + struct input_event *pinput = &(struct input_event) { + .time = time, + .type = type, + .code = keycode, + .value = keyvalue + }; int ignore = true; - static int old_fd, code, value; + static int code, value; assert(pinput); @@ -673,15 +679,13 @@ static int check_key_filter(void *data, int fd) if (pinput->code == BTN_TOUCH && !current_state_in_on()) break; if (pinput->code == code && pinput->value == value) { - _E("Same key(%d, %d) is polled [%d,%d]", - code, value, old_fd, fd); + _E("Same key(%d, %d) is polled", code, value); } - old_fd = fd; code = pinput->code; value = pinput->value; update_vital_state(pinput); - ignore = check_key(pinput, fd); + ignore = check_key(pinput); restore_custom_brightness(); break; @@ -693,6 +697,11 @@ static int check_key_filter(void *data, int fd) ignore = false; break; case EV_ABS: + if (touch_event_blocked() + && !g_display_plugin.config->touch_wakeup + && pinput->value == KEY_BEING_PRESSED) + return; + update_vital_state(pinput); if (pinput->value == KEY_PRESSED) { switch_on_lcd(LCD_ON_BY_TOUCH); @@ -714,9 +723,10 @@ static int check_key_filter(void *data, int fd) } if (ignore) - return 1; + return; - return 0; + /* lcd on or update lcd timeout */ + poll_callback(INPUT_POLL_EVENT, NULL); } static int delayed_init_done(void *data) @@ -750,30 +760,21 @@ static struct display_actor_ops display_menukey_actor = { .caps = DISPLAY_CAPA_LCDON, }; -static void keyfilter_init(void) -{ - display_add_actor(&display_powerkey_actor); - display_add_actor(&display_menukey_actor); - - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); - register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); -} - -static const struct display_keyfilter_ops normal_keyfilter_ops = { - .init = keyfilter_init, - .check = check_key_filter, -}; - -const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; - static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_var_display_plugin(); - if (!disp_plgn) { + if (!disp_plgn) _E("Failed to get display plugin variable."); - } backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_add_actor(&display_powerkey_actor); + display_add_actor(&display_menukey_actor); + + register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); + + input_register_event_callback(check_key_filter, NULL, NULL, NULL); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index e3bd04d..2c6d570 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -2049,10 +2049,6 @@ static void display_init(void *data) } - if (display_conf.input_support) - if (CHECK_OPS(keyfilter_ops, init)) - keyfilter_ops->init(); - set_display_init_direction(display_conf.display_init_direction); } } @@ -2069,9 +2065,6 @@ static void display_exit(void *data) /* timeout is not needed */ display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE); - if (CHECK_OPS(keyfilter_ops, exit)) - keyfilter_ops->exit(); - unregister_kernel_uevent_control(&lcd_uevent_ops); unregister_kernel_uevent_control(&sec_dsim_uevent_ops); diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 8c4cb04..635dfba 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -46,6 +46,7 @@ #include "power/power-off.h" #include "power/power-suspend.h" #include "display-lock.h" +#include "input/input.h" #ifndef KEY_SCREENLOCK #define KEY_SCREENLOCK 0x98 @@ -541,7 +542,7 @@ static void update_vital_state(struct input_event *pinput) } } -static int check_key(struct input_event *pinput, int fd) +static int check_key(struct input_event *pinput) { int ignore = true; @@ -610,11 +611,16 @@ static int check_key(struct input_event *pinput, int fd) return ignore; } -static int check_key_filter(void *data, int fd) +static void check_key_filter(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue) { - struct input_event *pinput = data; + struct input_event *pinput = &(struct input_event) { + .time = time, + .type = type, + .code = keycode, + .value = keyvalue + }; int ignore = true; - static int old_fd, code, value; + static int code, value; assert(pinput); @@ -632,15 +638,13 @@ static int check_key_filter(void *data, int fd) if (pinput->code == BTN_TOUCH && !current_state_in_on()) break; if (pinput->code == code && pinput->value == value) { - _E("Same key(%d, %d) is polled [%d,%d]", - code, value, old_fd, fd); + _E("Same key(%d, %d) is polled", code, value); } - old_fd = fd; code = pinput->code; value = pinput->value; update_vital_state(pinput); - ignore = check_key(pinput, fd); + ignore = check_key(pinput); restore_custom_brightness(); break; @@ -652,6 +656,11 @@ static int check_key_filter(void *data, int fd) ignore = false; break; case EV_ABS: + if (touch_event_blocked() && !ambient_get_state() + && !g_display_plugin.config->touch_wakeup + && pinput->value == KEY_BEING_PRESSED) + return; + update_vital_state(pinput); if (pinput->value == KEY_PRESSED) { switch_on_lcd(LCD_ON_BY_TOUCH); @@ -673,9 +682,10 @@ static int check_key_filter(void *data, int fd) } if (ignore) - return 1; + return; - return 0; + /* lcd on or update lcd timeout */ + poll_callback(INPUT_POLL_EVENT, NULL); } static int delayed_init_done(void *data) @@ -709,22 +719,6 @@ static struct display_actor_ops display_menukey_actor = { .caps = DISPLAY_CAPA_LCDON, }; -static void keyfilter_init(void) -{ - display_add_actor(&display_powerkey_actor); - display_add_actor(&display_menukey_actor); - - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); - register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); -} - -static const struct display_keyfilter_ops normal_keyfilter_ops = { - .init = keyfilter_init, - .check = check_key_filter, -}; - -const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops; - static void __CONSTRUCTOR__ initialize(void) { disp_plgn = get_var_display_plugin(); @@ -734,4 +728,12 @@ static void __CONSTRUCTOR__ initialize(void) backlight_ops = get_var_backlight_ops(); if (!backlight_ops) _E("Failed to get backlight operator variable."); + + display_add_actor(&display_powerkey_actor); + display_add_actor(&display_menukey_actor); + + register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb); + + input_register_event_callback(check_key_filter, NULL, NULL, NULL); } diff --git a/src/display/core.h b/src/display/core.h index 62125e3..ae7ea33 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -97,14 +97,6 @@ struct display_function_info { extern struct display_function_info display_info; -struct display_keyfilter_ops { - void (*init)(void); - void (*exit)(void); - int (*check)(void *, int); -}; - -extern const struct display_keyfilter_ops *keyfilter_ops; - typedef struct { pid_t pid; unsigned int cond; diff --git a/src/display/plugin-common/display-input.c b/src/display/plugin-common/display-input.c deleted file mode 100644 index 3b608a3..0000000 --- a/src/display/plugin-common/display-input.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include - -#include "util.h" -#include "core.h" -#include "poll.h" -#include "ambient-mode.h" -#include "display-plugin.h" - -#define SEAT_NAME "seat0" - -static void process_input(struct libinput_event *ev) -{ - static const struct device_ops *display_device_ops; - struct input_event input; - struct libinput *li; - struct libinput_event_keyboard *k; - unsigned int time; - int fd = 0; - if(!g_display_plugin.config) { - _E("Failed to get display configuration variable."); - return; - } - - if (!display_device_ops) { - display_device_ops = find_device("display"); - if (check_default(display_device_ops)) - return; - } - - /* do not operate when display stops */ - if (device_get_status(display_device_ops) - != DEVICE_OPS_STATUS_START) { - _E("display status is stop"); - return; - } - - switch (libinput_event_get_type(ev)) { - case LIBINPUT_EVENT_KEYBOARD_KEY: - k = libinput_event_get_keyboard_event(ev); - time = libinput_event_keyboard_get_time(k); - li = libinput_event_get_context(ev); - - input.time.tv_sec = MSEC_TO_SEC(time); - input.time.tv_usec = MSEC_TO_USEC(time % 1000); - input.type = EV_KEY; - input.code = libinput_event_keyboard_get_key(k); - input.value = libinput_event_keyboard_get_key_state(k); - - fd = libinput_get_fd(li); - _D("time %ld.%06ld type %d code %d value %d fd %d", - input.time.tv_sec, input.time.tv_usec, input.type, - input.code, input.value, fd); - break; - case LIBINPUT_EVENT_POINTER_MOTION: - case LIBINPUT_EVENT_POINTER_BUTTON: - input.type = EV_REL; - break; - case LIBINPUT_EVENT_TOUCH_DOWN: - input.type = EV_ABS; - input.value = KEY_PRESSED; - break; - case LIBINPUT_EVENT_TOUCH_UP: - input.type = EV_ABS; - input.value = KEY_RELEASED; - break; - case LIBINPUT_EVENT_TOUCH_MOTION: - case LIBINPUT_EVENT_TOUCH_FRAME: - if (touch_event_blocked() && !ambient_get_state() && !g_display_plugin.config->touch_wakeup) - return; - input.type = EV_ABS; - input.value = KEY_BEING_PRESSED; - break; - default: - return; - } - - if (CHECK_OPS(keyfilter_ops, check) && - keyfilter_ops->check(&input, fd) != 0) - return; - - /* lcd on or update lcd timeout */ - poll_callback(INPUT_POLL_EVENT, NULL); -} - -static int input_handler_execute(void *data) -{ - if (!data) - return 0; - - process_input(data); - - return 0; -} - -static void input_handler_init(void *data) -{ -} - -static const struct device_ops input_handler_device_ops = { - DECLARE_NAME_LEN("input-handler"), - .init = input_handler_init, - .execute = input_handler_execute, - .disable_auto_init = true, -}; - -DEVICE_OPS_REGISTER(&input_handler_device_ops) diff --git a/src/display/poll.h b/src/display/poll.h index 2b9bda2..bd79b92 100644 --- a/src/display/poll.h +++ b/src/display/poll.h @@ -66,10 +66,6 @@ enum { INTERNAL_LOCK_OVERCOOL, }; -#define KEY_RELEASED 0 -#define KEY_PRESSED 1 -#define KEY_BEING_PRESSED 2 - #define SIGNAL_NAME_LCD_CONTROL "lcdcontol" #define LCD_NORMAL 0x01 /**< NORMAL state */ diff --git a/src/input/input-dbus.c b/src/input/input-dbus.c index 750ec76..0c75bbd 100644 --- a/src/input/input-dbus.c +++ b/src/input/input-dbus.c @@ -33,7 +33,6 @@ #include "shared/common.h" #include "input.h" #include "input-dbus.h" -#include "input-interface.h" #include "input-device-manager.h" /* FIXME: input.keyboard feature check should be added and return DEVICE_ERROR_NOT_SUPPORTED */ @@ -90,7 +89,8 @@ static GVariant *dbus_emulate_key(GDBusConnection *conn, g_variant_get(param, "(ii)", &keycode, &keyvalue); - input_handler_process_key(keycode, keyvalue); + // temporarily disabled + //input_handler_process_key(keycode, keyvalue); return gdbus_new_g_variant_tuple(); } @@ -185,4 +185,4 @@ int input_dbus_init(void) return ret; } return 0; -} \ No newline at end of file +} diff --git a/src/input/input-interface.h b/src/input/input-interface.h deleted file mode 100644 index 62bbf1e..0000000 --- a/src/input/input-interface.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file input-interface.h - * @brief input interface module header - */ -#ifndef __INPUT_INTERFACE_H__ -#define __INPUT_INTERFACE_H__ - -struct input_ops { - void (*input_handler_process_key)(int keycode, int keyvalue); -}; - -#endif /* __INPUT_INTERFACE_H__ */ \ No newline at end of file diff --git a/src/input/input.c b/src/input/input.c index 23563f0..f596414 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -35,7 +36,6 @@ #include "input.h" #include "input-dbus.h" #include "input-parser.h" -#include "input-interface.h" #include "input-device-manager.h" #define SEAT_NAME "seat0" @@ -45,25 +45,109 @@ static struct libinput *li; static struct input_ops *input_plugin_ops; static guint efd; -static const struct device_ops *input_handler; +struct input_event_handler { + int id; + input_event_callback cb; + input_destroy_callback destroy_cb; + void *udata; +}; + +static GList *input_event_handler_list; + +static void invoke_input_event_callback(gpointer data, gpointer udata) +{ + struct input_event_handler *h = (struct input_event_handler *) data; + struct input_event *event = (struct input_event *) udata; + + assert(h); + assert(h->cb); + assert(event); + + /** + * TODO: At this point, system maybe just woken up for a while due to input interrupt. + * How can we guarantee all those callbacks are totally executed without system + * falling into suspend again? Autosleep may make system go suspend right after + * the key interrupt, that is, in the middle of the below callback execution. + */ + h->cb(event->time, event->type, event->code, event->value); +} + +static int convert_libinput_to_event(struct libinput_event *li_event, struct input_event *event) +{ + if (!li_event || !event) + return -EINVAL; + + switch (libinput_event_get_type(li_event)) { + case LIBINPUT_EVENT_KEYBOARD_KEY: + { + struct libinput *li = libinput_event_get_context(li_event); + struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(li_event); + unsigned int time; + int fd; + + assert(li); + assert(k); + + time = libinput_event_keyboard_get_time(k); + + event->time.tv_sec = (time / 1000); + event->time.tv_usec = MSEC_TO_USEC(time % 1000); + event->type = EV_KEY; + event->code = libinput_event_keyboard_get_key(k); + event->value = libinput_event_keyboard_get_key_state(k); + + fd = libinput_get_fd(li); + _D("time %ld.%06ld type %d code %d value %d fd %d", + event->time.tv_sec, event->time.tv_usec, event->type, + event->code, event->value, fd); + return 0; + } + case LIBINPUT_EVENT_POINTER_MOTION: + case LIBINPUT_EVENT_POINTER_BUTTON: + event->type = EV_REL; + return 0; + case LIBINPUT_EVENT_TOUCH_DOWN: + event->type = EV_ABS; + event->value = KEY_PRESSED; + return 0; + case LIBINPUT_EVENT_TOUCH_UP: + event->type = EV_ABS; + event->value = KEY_RELEASED; + return 0; + case LIBINPUT_EVENT_TOUCH_MOTION: + case LIBINPUT_EVENT_TOUCH_FRAME: + event->type = EV_ABS; + event->value = KEY_BEING_PRESSED; + return 0; + default: + return -EINVAL; + } + + // unreachable + return -EINVAL; +} static gboolean input_callback(gint fd, GIOCondition cond, void *data) { - struct libinput_event *ev; - struct libinput *input = (struct libinput *) data; + struct libinput *li = (struct libinput *) data; + struct libinput_event *li_event = NULL; - if (!input_handler) - return G_SOURCE_REMOVE; + if (!input_event_handler_list) + return G_SOURCE_CONTINUE; - if (!input) + if (!li) return G_SOURCE_CONTINUE; - libinput_dispatch(input); + libinput_dispatch(li); - while ((ev = libinput_get_event(input))) { - input_handler->execute(ev); - libinput_event_destroy(ev); - libinput_dispatch(input); + while ((li_event = libinput_get_event(li))) { + struct input_event event = { 0 , }; + + if (convert_libinput_to_event(li_event, &event) == 0) + g_list_foreach(input_event_handler_list, invoke_input_event_callback, &event); + + libinput_event_destroy(li_event); + libinput_dispatch(li); } return G_SOURCE_CONTINUE; @@ -97,26 +181,73 @@ static const struct libinput_interface interface = { .close_restricted = close_restricted, }; -void input_handler_process_key(int keycode, int keyvalue) +static int alloc_unique_id(void) { - if (input_plugin_ops && input_plugin_ops->input_handler_process_key) - input_plugin_ops->input_handler_process_key(keycode, keyvalue); + static int id = 0; + + return ++id; } -static void input_init(void *data) +int input_register_event_callback(input_event_callback cb, input_destroy_callback destroy_cb, void *udata, int *cb_id) { - int ret; - int fd; + struct input_event_handler *h = NULL; + + if (!cb) + return -EINVAL; + + h = calloc(1, sizeof(struct input_event_handler)); + if (!h) + return -ENOMEM; - /* load plugin input handler */ - input_handler = find_device("input-handler"); - if (check_default(input_handler) || input_handler->execute == NULL) { - input_handler = NULL; + *h = (struct input_event_handler) { + .id = alloc_unique_id(), + .cb = cb, + .destroy_cb = destroy_cb, + .udata = udata, + }; + + input_event_handler_list = g_list_append(input_event_handler_list, h); + + if (cb_id) + *cb_id = h->id; + + return 0; +} + +static int find_handler_by_id(gconstpointer data, gconstpointer udata) +{ + struct input_event_handler *h = (struct input_event_handler *) data; + int id = *(int *) udata; + + if (h->id == id) + return 0; + + return -1; +} + +void input_unregister_event_callback(int cb_id) +{ + struct input_event_handler *h = NULL; + GList *l = NULL; + + l = g_list_find_custom(input_event_handler_list, &cb_id, find_handler_by_id); + if (!l || !l->data) return; - } - if (input_handler->init) - input_handler->init(&input_plugin_ops); + input_event_handler_list = g_list_remove_link(input_event_handler_list, l); + h = l->data; + + if (h->destroy_cb) + h->destroy_cb(h->udata); + + free(h); + g_list_free(l); +} + +static void input_init(void *data) +{ + int ret; + int fd; if (input_plugin_ops == NULL) _E("Failed to init input_ops"); @@ -186,11 +317,6 @@ static void input_exit(void *data) if (udev) udev_unref(udev); - if (input_handler && input_handler->exit) - input_handler->exit(NULL); - - input_handler = NULL; - input_devman_exit(); } diff --git a/src/input/input.h b/src/input/input.h index 287ad30..05749fb 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -23,6 +23,15 @@ #ifndef __INPUT_H__ #define __INPUT_H__ -void input_handler_process_key(int keycode, int keyvalue); +#include -#endif /* __INPUT_H__ */ \ No newline at end of file +#define KEY_RELEASED 0 +#define KEY_PRESSED 1 +#define KEY_BEING_PRESSED 2 + +typedef void (*input_event_callback) (struct timeval, unsigned short type, unsigned short code, unsigned int value); +typedef void (*input_destroy_callback) (void *udata); +int input_register_event_callback(input_event_callback cb, input_destroy_callback destroy_cb, void *udata, int *cb_id); +void input_unregister_event_callback(int cb_id); + +#endif /* __INPUT_H__ */ -- 2.7.4 From c1a1bb7351084c7cf1331774f5ae54d6ad6d2c1a Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 8 Jun 2023 15:33:16 +0900 Subject: [PATCH 08/16] display: state-transition: Add break statement Add missing break statement for code improvement, It is reported by svace/coverity code analysis. Change-Id: If73d9b09de7cd6f2885be38938a80213c62e4c53 Signed-off-by: Yunhee Seo --- src/display/display-state-transition.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 002f838..126d77b 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -131,8 +131,10 @@ int display_state_transition_set_custom_timeout(enum state_t state, unsigned int switch (state) { case S_NORMAL: custom_normal_timeout = timeout; + break; case S_LCDDIM: custom_dim_timeout = timeout; + break; default: display_plugin_state_get_name(state, &state_name); _W("%s state has no custom timeout", state_name); @@ -151,8 +153,10 @@ int display_state_transition_get_custom_timeout(enum state_t state, unsigned int switch (state) { case S_NORMAL: *timeout = custom_normal_timeout; + break; case S_LCDDIM: *timeout = custom_dim_timeout; + break; default: *timeout = 0; display_plugin_state_get_name(state, &state_name); -- 2.7.4 From 4b06e6d1a7b7359869425567d4b5dbfbcb8521d5 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 8 Jun 2023 17:16:47 +0900 Subject: [PATCH 09/16] display: Remove unused macros There are many macros that have not been deleted when certain functions or codes are deleted before. Thus, remove unsed macros in the display plugins. Change-Id: I9a4e2b3b03082bae9fe57021281886651a107444 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 10 ---------- plugins/iot-headed/display/device-interface.c | 18 ------------------ plugins/iot-headed/display/key-filter.c | 11 ----------- plugins/mobile/display/core.c | 10 ---------- plugins/mobile/display/device-interface.c | 16 ---------------- plugins/mobile/display/key-filter.c | 10 ---------- plugins/tv/display/core.c | 10 ---------- plugins/tv/display/device-interface.c | 18 ------------------ plugins/tv/display/key-filter.c | 11 ----------- plugins/wearable/display/core.c | 10 ---------- plugins/wearable/display/device-interface.c | 20 -------------------- plugins/wearable/display/key-filter.c | 10 ---------- src/display/plugin-common/auto-brightness.c | 13 ------------- src/display/plugin-common/display-dbus.c | 5 ----- src/display/plugin-common/poll.c | 8 -------- 15 files changed, 180 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index a0f1c85..fcbafea 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -127,18 +127,8 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define SHIFT_UNLOCK 4 -#define SHIFT_CHANGE_STATE 7 -#define CHANGE_STATE_BIT 0xF00 /* 1111 0000 0000 */ -#define SHIFT_LOCK_FLAG 16 -#define SHIFT_CHANGE_TIMEOUT 20 -#define CUSTOM_TIMEOUT_BIT 0x1 -#define CUSTOM_HOLDKEY_BIT 0x2 -#define HOLD_KEY_BLOCK_BIT 0x1 #define TIMEOUT_NONE (-1) -#define S_COVER_TIMEOUT 8000 -#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT) #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index 95a4e79..245b5d0 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -46,24 +46,6 @@ #include "display-backlight.h" #include "display-panel.h" -#define TOUCH_ON 1 -#define TOUCH_OFF 0 - -#define LCD_PHASED_MAX_BRIGHTNESS 100 - -#define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so" - -#define GESTURE_STR "gesture" -#define POWERKEY_STR "powerkey" -#define EVENT_STR "event" -#define TOUCH_STR "touch" -#define TIMEOUT_STR "timeout" -#define PROXIMITY_STR "proximity" -#define PALM_STR "palm" -#define UNKNOWN_STR "unknown" - -#define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" - static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 35a18b3..b8ef405 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -56,11 +56,7 @@ #define SW_GLOVE 0x16 #endif -#define PREDEF_LEAVESLEEP "leavesleep" -#define POWEROFF_ACT "poweroff" -#define PWROFF_POPUP_ACT "pwroff_popup" #define USEC_PER_SEC 1000000 -#define CSC_CONFIG_MODE_RUNNING 1 #define CAPTURE_COMBINATION_INTERVAL 0.5 /* 0.5 second */ #define TORCH_COMBINATION_INTERVAL 0.1 /* 0.1 second */ @@ -68,17 +64,10 @@ #define LONGKEY_PRESSED_TIME 4 /* 4 second */ -#define KEY_MAX_DELAY_TIME 700 /* ms */ - #define SIGNAL_CHANGE_HARDKEY "ChangeHardkey" #define SIGNAL_LCDON_BY_POWERKEY "LCDOnByPowerkey" #define SIGNAL_LCDOFF_BY_POWERKEY "LCDOffByPowerkey" -#define NORMAL_POWER 0 -#define KEY_TEST_MODE_POWER 2 - -#define GLOVE_MODE 1 - enum key_combination_flags { KEY_COMBINATION_STOP = 0, KEY_COMBINATION_POWERKEY = BIT(0), diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index fda90ef..9545fac 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -129,18 +129,8 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define SHIFT_UNLOCK 4 -#define SHIFT_CHANGE_STATE 7 -#define CHANGE_STATE_BIT 0xF00 /* 1111 0000 0000 */ -#define SHIFT_LOCK_FLAG 16 -#define SHIFT_CHANGE_TIMEOUT 20 -#define CUSTOM_TIMEOUT_BIT 0x1 -#define CUSTOM_HOLDKEY_BIT 0x2 -#define HOLD_KEY_BLOCK_BIT 0x1 #define TIMEOUT_NONE (-1) -#define S_COVER_TIMEOUT 8000 -#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT) #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index aa1bc85..7900c9e 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -47,22 +47,6 @@ #include "power/power-boot.h" #include "power/power-suspend.h" -#define TOUCH_ON 1 -#define TOUCH_OFF 0 - -#define LCD_PHASED_MAX_BRIGHTNESS 100 - -#define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so" - -#define GESTURE_STR "gesture" -#define POWERKEY_STR "powerkey" -#define EVENT_STR "event" -#define TOUCH_STR "touch" -#define TIMEOUT_STR "timeout" -#define PROXIMITY_STR "proximity" -#define PALM_STR "palm" -#define UNKNOWN_STR "unknown" - static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index e05a94b..180262d 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -56,11 +56,8 @@ #define SW_GLOVE 0x16 #endif -#define PREDEF_LEAVESLEEP "leavesleep" -#define POWEROFF_ACT "poweroff" #define USEC_PER_SEC 1000000 #define USEC_PER_MSEC 1000 -#define CSC_CONFIG_MODE_RUNNING 1 #define CAPTURE_COMBINATION_INTERVAL 0.5 /* 0.5 second */ #define TORCH_COMBINATION_INTERVAL 0.1 /* 0.1 second */ @@ -68,17 +65,10 @@ #define LONGKEY_PRESSED_TIME 4 /* 4 second */ -#define KEY_MAX_DELAY_TIME 700 /* ms */ - #define SIGNAL_CHANGE_HARDKEY "ChangeHardkey" #define SIGNAL_LCDON_BY_POWERKEY "LCDOnByPowerkey" #define SIGNAL_LCDOFF_BY_POWERKEY "LCDOffByPowerkey" -#define NORMAL_POWER 0 -#define KEY_TEST_MODE_POWER 2 - -#define GLOVE_MODE 1 - enum key_combination_flags { KEY_COMBINATION_STOP = 0, KEY_COMBINATION_POWERKEY = BIT(0), diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 1d735d0..49e70e3 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -127,18 +127,8 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define SHIFT_UNLOCK 4 -#define SHIFT_CHANGE_STATE 7 -#define CHANGE_STATE_BIT 0xF00 /* 1111 0000 0000 */ -#define SHIFT_LOCK_FLAG 16 -#define SHIFT_CHANGE_TIMEOUT 20 -#define CUSTOM_TIMEOUT_BIT 0x1 -#define CUSTOM_HOLDKEY_BIT 0x2 -#define HOLD_KEY_BLOCK_BIT 0x1 #define TIMEOUT_NONE (-1) -#define S_COVER_TIMEOUT 8000 -#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT) #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index c9d13b7..4fc311b 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -46,24 +46,6 @@ #include "power/power-suspend.h" #include "display-lock.h" -#define TOUCH_ON 1 -#define TOUCH_OFF 0 - -#define LCD_PHASED_MAX_BRIGHTNESS 100 - -#define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so" - -#define GESTURE_STR "gesture" -#define POWERKEY_STR "powerkey" -#define EVENT_STR "event" -#define TOUCH_STR "touch" -#define TIMEOUT_STR "timeout" -#define PROXIMITY_STR "proximity" -#define PALM_STR "palm" -#define UNKNOWN_STR "unknown" - -#define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" - static struct display_backlight_ops backlight_ops; static bool display_dev_available = false; static const struct display_config *display_conf; diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 424e4a1..64628d6 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -56,11 +56,7 @@ #define SW_GLOVE 0x16 #endif -#define PREDEF_LEAVESLEEP "leavesleep" -#define POWEROFF_ACT "poweroff" -#define PWROFF_POPUP_ACT "pwroff_popup" #define USEC_PER_SEC 1000000 -#define CSC_CONFIG_MODE_RUNNING 1 #define CAPTURE_COMBINATION_INTERVAL 0.5 /* 0.5 second */ #define TORCH_COMBINATION_INTERVAL 0.1 /* 0.1 second */ @@ -68,17 +64,10 @@ #define LONGKEY_PRESSED_TIME 4 /* 4 second */ -#define KEY_MAX_DELAY_TIME 700 /* ms */ - #define SIGNAL_CHANGE_HARDKEY "ChangeHardkey" #define SIGNAL_LCDON_BY_POWERKEY "LCDOnByPowerkey" #define SIGNAL_LCDOFF_BY_POWERKEY "LCDOffByPowerkey" -#define NORMAL_POWER 0 -#define KEY_TEST_MODE_POWER 2 - -#define GLOVE_MODE 1 - enum key_combination_flags { KEY_COMBINATION_STOP = 0, KEY_COMBINATION_POWERKEY = BIT(0), diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 2c6d570..b0a7d33 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -140,18 +140,8 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define SHIFT_UNLOCK 4 -#define SHIFT_CHANGE_STATE 7 -#define CHANGE_STATE_BIT 0xF00 /* 1111 0000 0000 */ -#define SHIFT_LOCK_FLAG 16 -#define SHIFT_CHANGE_TIMEOUT 20 -#define CUSTOM_TIMEOUT_BIT 0x1 -#define CUSTOM_HOLDKEY_BIT 0x2 -#define HOLD_KEY_BLOCK_BIT 0x1 #define TIMEOUT_NONE (-1) -#define S_COVER_TIMEOUT 8000 -#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT) #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 2e06e43..018cfe5 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -50,26 +50,6 @@ #include "power/power-suspend.h" #include "shared/plugin.h" -#define TOUCH_ON 1 -#define TOUCH_OFF 0 - -#define LCD_PHASED_MAX_BRIGHTNESS 100 - -#define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so" - -#define GESTURE_STR "gesture" -#define POWERKEY_STR "powerkey" -#define EVENT_STR "event" -#define TOUCH_STR "touch" -#define BEZEL_STR "bezel" -#define TIMEOUT_STR "timeout" -#define PROXIMITY_STR "proximity" -#define PALM_STR "palm" -#define UNKNOWN_STR "unknown" - -#define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" - - static struct display_backlight_ops backlight_ops; static struct battery_plugin *battery_plgn; static bool display_dev_available = false; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 635dfba..8c1bd60 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -55,11 +55,8 @@ #define SW_GLOVE 0x16 #endif -#define PREDEF_LEAVESLEEP "leavesleep" -#define POWEROFF_ACT "poweroff" #define USEC_PER_SEC 1000000 #define USEC_PER_MSEC 1000 -#define CSC_CONFIG_MODE_RUNNING 1 #define CAPTURE_COMBINATION_INTERVAL 0.5 /* 0.5 second */ #define TORCH_COMBINATION_INTERVAL 0.1 /* 0.1 second */ @@ -67,17 +64,10 @@ #define LONGKEY_PRESSED_TIME 4 /* 4 second */ -#define KEY_MAX_DELAY_TIME 700 /* ms */ - #define SIGNAL_CHANGE_HARDKEY "ChangeHardkey" #define SIGNAL_LCDON_BY_POWERKEY "LCDOnByPowerkey" #define SIGNAL_LCDOFF_BY_POWERKEY "LCDOffByPowerkey" -#define NORMAL_POWER 0 -#define KEY_TEST_MODE_POWER 2 - -#define GLOVE_MODE 1 - enum key_combination_flags { KEY_COMBINATION_STOP = 0, KEY_COMBINATION_POWERKEY = BIT(0), diff --git a/src/display/plugin-common/auto-brightness.c b/src/display/plugin-common/auto-brightness.c index 847970a..64b4251 100644 --- a/src/display/plugin-common/auto-brightness.c +++ b/src/display/plugin-common/auto-brightness.c @@ -39,12 +39,6 @@ #include "shared/device-notifier.h" #include -#define METHOD_CHECK_SUPPORTED "CheckSupported" - -#define DISP_FORCE_SHIFT 12 -#define DISP_FORCE_CMD(prop, force) (((force) << DISP_FORCE_SHIFT) | prop) - -#define SAMPLING_INTERVAL 1 /* 1 sec */ #define MAX_SAMPLING_COUNT 3 #define MAX_FAULT 5 #define DEFAULT_AUTOMATIC_BRT 5 @@ -56,13 +50,6 @@ #define WORKING_ANGLE_MIN 0 #define WORKING_ANGLE_MAX 20 -#define BOARD_CONF_FILE "/etc/deviced/display.conf" - -#define ON_LUX -1 -#define OFF_LUX -1 -#define ON_COUNT 1 -#define OFF_COUNT 1 - static int (*_default_action) (int); static guint alc_timeout_id = 0; static guint update_timeout; diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 1994bc4..78fb314 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -56,11 +56,6 @@ #define APP_CHANGE_STATE "AppStatusChange" #define APP_TERMINATED "AppTerminated" -#define TELEPHONY_PATH "/org/tizen/telephony" -#define TELEPHONY_INTERFACE_SIM "org.tizen.telephony.Manager" -#define SIGNAL_SIM_STATUS "SimInserted" -#define SIM_CARD_NOT_PRESENT (0x0) - #ifndef VCONFKEY_LCD_BRIGHTNESS_INIT #define VCONFKEY_LCD_BRIGHTNESS_INIT "db/private/deviced/lcd_brightness_init" #endif diff --git a/src/display/plugin-common/poll.c b/src/display/plugin-common/poll.c index 1fa0b48..769c6d4 100644 --- a/src/display/plugin-common/poll.c +++ b/src/display/plugin-common/poll.c @@ -32,14 +32,6 @@ #include "display-plugin.h" #include "shared/plugin.h" -#define SHIFT_UNLOCK 4 -#define SHIFT_UNLOCK_PARAMETER 12 -#define SHIFT_CHANGE_STATE 8 -#define SHIFT_CHANGE_TIMEOUT 20 -#define LOCK_FLAG_SHIFT 16 -#define __HOLDKEY_BLOCK_BIT 0x1 -#define HOLDKEY_BLOCK_BIT (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT) - static PMMsg recv_data; int check_dimstay(int next_state, int flag) -- 2.7.4 From 78d970139203c91f225e2afcc52151777fab6136 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 7 Jun 2023 17:34:39 +0900 Subject: [PATCH 10/16] display: state-transition: Relocate update_lcdoff_source() update_lcdoff_source() is used for setting lcdoff reason. This function is called when the display state goes to lcdoff state. Same code was copied and used in all plugins. Thus, this function is added below display-state-transition int display_state_transition_update_lcdoff_reason(int source); -> This function sets the lcdoff reason to VCONFKEY_PM_LCDOFF_SOURCE. Change-Id: Idc857d4b52502612eaccb01373d984815806a153 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 22 +--------------------- plugins/iot-headed/display/key-filter.c | 5 +++-- plugins/mobile/display/core.c | 22 +--------------------- plugins/mobile/display/key-filter.c | 5 +++-- plugins/tv/display/core.c | 22 +--------------------- plugins/tv/display/key-filter.c | 5 +++-- plugins/wearable/display/core.c | 22 +--------------------- plugins/wearable/display/key-filter.c | 5 +++-- src/display/core.h | 1 - src/display/display-state-transition.c | 24 ++++++++++++++++++++++++ src/display/display-state-transition.h | 1 + src/display/plugin-common/display-dbus.c | 3 ++- 12 files changed, 43 insertions(+), 94 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index fcbafea..b1c68b1 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -714,26 +714,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -808,7 +788,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index b8ef405..5361e0e 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -394,7 +395,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -508,7 +509,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 9545fac..464d3d4 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -724,26 +724,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -818,7 +798,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 180262d..65a0de2 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -384,7 +385,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -541,7 +542,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 49e70e3..b986639 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -714,26 +714,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -808,7 +788,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 64628d6..6a44187 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -394,7 +395,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -508,7 +509,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b0a7d33..9e61e52 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1049,26 +1049,6 @@ static int proc_condition(PMMsg *data) return 0; } -void update_lcdoff_source(int source) -{ - int ret; - - switch (source) { - case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: - _I("LCD OFF by timeout."); - break; - case VCONFKEY_PM_LCDOFF_BY_POWERKEY: - _I("LCD OFF by powerkey."); - break; - default: - _E("Invalid value(%d).", source); - return; - } - ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); - if (ret < 0) - _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); -} - /* SIGHUP signal handler * For debug... print info to syslog */ @@ -1151,7 +1131,7 @@ static int default_trans(int evt) /* enter action */ if (st->action) { if (get_pm_cur_state() == S_LCDOFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) if (set_custom_lcdon_timeout(0) == true) diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 8c1bd60..2658612 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-panel.h" #include "display-backlight.h" #include "display-config.h" +#include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" #include "shared/device-notifier.h" @@ -391,7 +392,7 @@ static int lcdoff_powerkey(void) switch_off_lcd(); delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); } @@ -505,7 +506,7 @@ static int process_screenlock_key(struct input_event *pinput) if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) { delete_condition(S_NORMAL); delete_condition(S_LCDDIM); - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ if (disp_plgn->pm_change_internal) diff --git a/src/display/core.h b/src/display/core.h index ae7ea33..6a11082 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -125,7 +125,6 @@ int delete_condition(enum state_t state); 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); -void update_lcdoff_source(int source); int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name); int custom_lcdon(int timeout); void lcd_on_direct(enum device_flags flags); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 126d77b..bc06af4 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -280,4 +280,28 @@ int display_state_transition_check_state_transition_condition(enum state_t cur_s } return 0; /* transitable */ +} + +int display_state_transition_update_lcdoff_reason(int source) +{ + int ret; + + switch (source) { + case VCONFKEY_PM_LCDOFF_BY_TIMEOUT: + _I("LCD OFF by timeout."); + break; + case VCONFKEY_PM_LCDOFF_BY_POWERKEY: + _I("LCD OFF by powerkey."); + break; + default: + _E("Invalid value(%d).", source); + return -EINVAL; + } + ret = vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source); + if (ret < 0) { + _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); + return -EPERM; + } + + return 0; } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index caed462..7193a7f 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -38,5 +38,6 @@ 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_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); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file diff --git a/src/display/plugin-common/display-dbus.c b/src/display/plugin-common/display-dbus.c index 78fb314..24eb2ff 100644 --- a/src/display/plugin-common/display-dbus.c +++ b/src/display/plugin-common/display-dbus.c @@ -47,6 +47,7 @@ #include "display-lock.h" #include "display-panel.h" #include "display-config.h" +#include "display-state-transition.h" //#include "display/display.h" #include "display-backlight.h" #include "display-misc.h" @@ -361,7 +362,7 @@ static GVariant *dbus_changestate(GDBusConnection *conn, ret = disp_plgn->pm_change_internal(pid, state); if (!ret && state == LCD_OFF) - update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); out: g_free(state_str); return g_variant_new("(i)", ret); -- 2.7.4 From eb461067bfcbafae868b141cf2163a612bf4a386 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 8 Jun 2023 10:49:19 +0900 Subject: [PATCH 11/16] display: state-transition: Relocate check_lcdoff_direct() check_lcdoff_direct() is used to check if display state can go to S_LCDOFF. All plugins follows same policy of this function. Thus, this function is added below display-state-transition. - bool display_state_transition_is_possible_to_go_lcdoff(void); -> This replaces check_lcdoff_direct(). Also, new function is added below display-plugin. - int display_plugin_config_get_dimming(int *dimming); -> It gets dimming config value from the conf file. To confirm going to S_LCDOFF state, dimming value must also be checked. So, display_plugin_config_get_dimming() is added too. Change-Id: I19545fa1d6e7592a938a24e0b130302d88d81e02 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 35 +------------------------------ plugins/mobile/display/core.c | 35 +------------------------------ plugins/tv/display/core.c | 35 +------------------------------ plugins/wearable/display/core.c | 35 +------------------------------ src/display/display-plugin.c | 13 ++++++++++++ src/display/display-plugin.h | 1 + src/display/display-state-transition.c | 38 ++++++++++++++++++++++++++++++++++ src/display/display-state-transition.h | 1 + 8 files changed, 57 insertions(+), 136 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index b1c68b1..6eb4dd4 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -724,39 +724,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -int check_lcdoff_direct(void) -{ - int ret, lock, cradle; - int hdmi_state; - - if (get_pm_old_state() != S_NORMAL) - return false; - - if (get_pm_cur_state() != S_LCDDIM) - return false; - - if (!display_conf.dimming) - return true; - - lock = __get_lock_screen_state(); - if (lock != VCONFKEY_IDLE_LOCK) - return false; - - hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI); - if (hdmi_state) - return false; - - ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle); - if (ret >= 0 && cradle == DOCK_SOUND) - return false; - else if (ret < 0) - _E("Failed to get vconf value for cradle status: %d", vconf_get_ext_errno()); - - _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); - - return true; -} - /* * default transition function * 1. call check @@ -794,7 +761,7 @@ static int default_trans(int evt) if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); - if (check_lcdoff_direct() == true) { + if (display_state_transition_is_possible_to_go_lcdoff()) { /* enter next state directly */ states[get_pm_cur_state()].trans(EVENT_TIMEOUT); } else { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 464d3d4..ec49a57 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -734,39 +734,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -int check_lcdoff_direct(void) -{ - int ret, lock, cradle; - int hdmi_state; - - if (get_pm_old_state() != S_NORMAL) - return false; - - if (get_pm_cur_state() != S_LCDDIM) - return false; - - if (!display_conf.dimming) - return true; - - lock = __get_lock_screen_state(); - if (lock != VCONFKEY_IDLE_LOCK) - return false; - - hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI); - if (hdmi_state) - return false; - - ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle); - if (ret >= 0 && cradle == DOCK_SOUND) - return false; - else if (ret < 0) - _E("Failed to get vconf value for cradle status: %d", vconf_get_ext_errno()); - - _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); - - return true; -} - /* * default transition function * 1. call check @@ -804,7 +771,7 @@ static int default_trans(int evt) if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); - if (check_lcdoff_direct() == true) { + if (display_state_transition_is_possible_to_go_lcdoff()) { /* enter next state directly */ states[get_pm_cur_state()].trans(EVENT_TIMEOUT); } else { diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index b986639..168041e 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -724,39 +724,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -int check_lcdoff_direct(void) -{ - int ret, lock, cradle; - int hdmi_state; - - if (get_pm_old_state() != S_NORMAL) - return false; - - if (get_pm_cur_state() != S_LCDDIM) - return false; - - if (!display_conf.dimming) - return true; - - lock = __get_lock_screen_state(); - if (lock != VCONFKEY_IDLE_LOCK) - return false; - - hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI); - if (hdmi_state) - return false; - - ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle); - if (ret >= 0 && cradle == DOCK_SOUND) - return false; - else if (ret < 0) - _E("Failed to get vconf value for cradle status: %d", vconf_get_ext_errno()); - - _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); - - return true; -} - /* * default transition function * 1. call check @@ -794,7 +761,7 @@ static int default_trans(int evt) if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); - if (check_lcdoff_direct() == true) { + if (display_state_transition_is_possible_to_go_lcdoff()) { /* enter next state directly */ states[get_pm_cur_state()].trans(EVENT_TIMEOUT); } else { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 9e61e52..de873cb 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1059,39 +1059,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -int check_lcdoff_direct(void) -{ - int ret, lock, cradle; - int hdmi_state; - - if (get_pm_old_state() != S_NORMAL) - return false; - - if (get_pm_cur_state() != S_LCDDIM) - return false; - - if (!display_conf.dimming) - return true; - - lock = __get_lock_screen_state(); - if (lock != VCONFKEY_IDLE_LOCK) - return false; - - hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI); - if (hdmi_state) - return false; - - ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle); - if (ret >= 0 && cradle == DOCK_SOUND) - return false; - else if (ret < 0) - _E("Failed to get vconf value for cradle status: %d", vconf_get_ext_errno()); - - _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); - - return true; -} - /* * default transition function * 1. call check @@ -1137,7 +1104,7 @@ static int default_trans(int evt) if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); - if (check_lcdoff_direct() == true) { + if (display_state_transition_is_possible_to_go_lcdoff()) { /* enter next state directly */ states[get_pm_cur_state()].trans(EVENT_TIMEOUT); } else { diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 2e7ffac..176ab5d 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -255,6 +255,19 @@ int display_plugin_config_get_lcd_always_on(int *lcd_always_on) return -EOPNOTSUPP; } +int display_plugin_config_get_dimming(int *dimming) +{ + if (!dimming) + return -EINVAL; + + if (g_display_plugin.config) { + *dimming = g_display_plugin.config->dimming; + return 0; + } + + return -EOPNOTSUPP; +} + int display_plugin_set_dim_state(bool on) { if (g_display_plugin.set_dim_state) { diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 09d8aa3..820cf0f 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -106,5 +106,6 @@ int display_plugin_state_get_state_by_state_index(int state_index, enum state_t int display_plugin_config_get_timeout_enable(bool *timeout_enable); int display_plugin_config_get_lcdoff_timeout(int *lcdoff_timeout); int display_plugin_config_get_lcd_always_on(int *lcd_always_on); +int display_plugin_config_get_dimming(int *dimming); #endif //__DISPLAY_PLUGIN_H__ diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index bc06af4..4836cac 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -21,10 +21,12 @@ * @brief This file has functions related to display state transition */ +#include "core/udev.h" #include "device-interface.h" #include "display-state-transition.h" #include "display-lock.h" #include "display-plugin.h" +#include "extcon/extcon.h" #include "power/power-suspend.h" #include "shared/log.h" @@ -304,4 +306,40 @@ int display_state_transition_update_lcdoff_reason(int source) } return 0; +} + +/* FIXME: In this function, extcon checking should be considered after relocating this. */ +bool display_state_transition_is_possible_to_go_lcdoff(void) +{ + int ret, lock, cradle; + int hdmi_state; + int dimming; + + if (get_pm_old_state() != S_NORMAL) + return false; + + if (get_pm_cur_state() != S_LCDDIM) + return false; + + display_plugin_config_get_dimming(&dimming); + if (!dimming) + return true; + + lock = __get_lock_screen_state(); + if (lock != VCONFKEY_IDLE_LOCK) + return false; + + hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI); + if (hdmi_state) + return false; + + ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle); + if (ret >= 0 && cradle == DOCK_SOUND) + return false; + else if (ret < 0) + _E("Failed to get vconf value for cradle status: %d", vconf_get_ext_errno()); + + _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); + + return true; } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index 7193a7f..e114326 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -39,5 +39,6 @@ int display_state_transition_get_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); +bool display_state_transition_is_possible_to_go_lcdoff(void); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file -- 2.7.4 From 5f39ca0b4410cf4560bdae2992e48854d802dc7b Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 7 Jun 2023 16:29:32 +0900 Subject: [PATCH 12/16] display: state-transition: Relocate default_trans() default_trans() was used for display state transition. 1. It gets next display state and checks if the state transition is possible or not. 2. And then, it updates old/current display state. 3. Finally, it goes to next state transition or default_action if possible. These functions are added below display-state-transition. - int display_state_transition_do_state_transition(enum state_t state, int evt_type); -> This replaces default_trans() - bool display_state_transition_is_display_state_support_transition(enum state_t state); -> This function checks if state is support to do state transition related job. For example, 1. checking state transition condition 2. do state transition 3. do state action To check these, this function is added. Change-Id: Icc58965838e30fde2871c1c69596ffbed43e60f2 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 81 ++++++---------------------------- plugins/mobile/display/core.c | 81 ++++++---------------------------- plugins/tv/display/core.c | 81 ++++++---------------------------- src/display/display-lock.c | 2 +- src/display/display-plugin.c | 9 ++++ src/display/display-plugin.h | 1 + src/display/display-state-transition.c | 70 ++++++++++++++++++++++++++--- src/display/display-state-transition.h | 2 + src/display/plugin-common/poll.c | 7 +-- 9 files changed, 124 insertions(+), 210 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 6eb4dd4..74eb8fd 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -111,7 +111,6 @@ static bool lcdon_broadcast = true; static bool touch_blocked = false; /* default transition, action fuctions */ -static int default_trans(int evt); static int default_action(int timeout); static int default_proc_change_state(unsigned int cond, pid_t pid); @@ -119,11 +118,11 @@ static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_cha static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, + { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, + { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -709,7 +708,7 @@ static int proc_condition(PMMsg *data) } if (!display_state_transition_is_there_state_transition_timer()) - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return 0; } @@ -724,58 +723,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -/* - * default transition function - * 1. call check - * 2. transition - * 3. call enter action function - */ -static int default_trans(int evt) -{ - struct state *st = &states[get_pm_cur_state()]; - enum state_t next_state; - int ret = 0; - - display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); - - /* check conditions */ - ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); - if (ret < 0) { - /* There is a condition. */ - _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, - states[next_state].name); - return -1; - } - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(next_state); - st = &states[get_pm_cur_state()]; - - /* enter action */ - if (st->action) { - if (get_pm_cur_state() == S_LCDOFF) - display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); - - if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - if (display_state_transition_is_possible_to_go_lcdoff()) { - /* enter next state directly */ - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); - } else { - if ((get_pm_cur_state() == S_SLEEP) - && (is_emulator() == true || timeout_sleep_support == false)) - return 0; - - st->action(st->timeout); - } - } - - return 0; -} - static gboolean lcd_on_expired(void *data) { int lock_state, ret; @@ -952,7 +899,7 @@ go_suspend: go_lcd_off: if (!pm_get_power_lock_support()) { /* Resume !! */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); } return 0; } @@ -985,7 +932,7 @@ int poll_callback(int condition, PMMsg *data) if ((last_t != now) || (get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP)) { - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); last_t = now; } } @@ -1007,7 +954,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: display_state_transition_update_display_state_timeout_by_priority(); - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOW_BATT: if (display_misc_is_low_battery_state(val)) { @@ -1071,13 +1018,13 @@ static int update_setting(int key_idx, int val) stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_POWER_CUSTOM_BRIGHTNESS: if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) @@ -1208,7 +1155,7 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) /* Apply new backlight time */ display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); if (holdkey_block) { display_lock_set_custom_holdkey_block(true); @@ -1266,7 +1213,7 @@ void reset_lcd_timeout(GDBusConnection *conn, display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); } static int delayed_init_done(void *data) @@ -1390,10 +1337,10 @@ static int power_resume_from_echomem_callback(void *data) system_wakeup_flag = true; if (check_wakeup_src() == EVENT_DEVICE) /* system waked up by devices */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); else /* system waked up by user input */ - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); return 0; } diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index ec49a57..6d1244d 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -113,7 +113,6 @@ static bool lcdon_broadcast = true; static bool touch_blocked = false; /* default transition, action fuctions */ -static int default_trans(int evt); static int default_action(int timeout); static int default_proc_change_state(unsigned int cond, pid_t pid); @@ -121,11 +120,11 @@ static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_cha static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, + { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, + { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -719,7 +718,7 @@ static int proc_condition(PMMsg *data) } if (!display_state_transition_is_there_state_transition_timer()) - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return 0; } @@ -734,58 +733,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -/* - * default transition function - * 1. call check - * 2. transition - * 3. call enter action function - */ -static int default_trans(int evt) -{ - struct state *st = &states[get_pm_cur_state()]; - enum state_t next_state; - int ret = 0; - - display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); - - /* check conditions */ - ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); - if (ret < 0) { - /* There is a condition. */ - _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, - states[next_state].name); - return -1; - } - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(next_state); - st = &states[get_pm_cur_state()]; - - /* enter action */ - if (st->action) { - if (get_pm_cur_state() == S_LCDOFF) - display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); - - if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - if (display_state_transition_is_possible_to_go_lcdoff()) { - /* enter next state directly */ - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); - } else { - if ((get_pm_cur_state() == S_SLEEP) - && (is_emulator() == true || timeout_sleep_support == false)) - return 0; - - st->action(st->timeout); - } - } - - return 0; -} - static gboolean lcd_on_expired(void *data) { int lock_state, ret; @@ -962,7 +909,7 @@ go_suspend: go_lcd_off: if (!pm_get_power_lock_support()) { /* Resume !! */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); } return 0; } @@ -995,7 +942,7 @@ int poll_callback(int condition, PMMsg *data) if ((last_t != now) || (get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP)) { - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); last_t = now; } } @@ -1017,7 +964,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: display_state_transition_update_display_state_timeout_by_priority(); - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOW_BATT: if (display_misc_is_low_battery_state(val)) { @@ -1081,13 +1028,13 @@ static int update_setting(int key_idx, int val) stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_POWER_CUSTOM_BRIGHTNESS: if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) @@ -1218,7 +1165,7 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) /* Apply new backlight time */ display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); if (holdkey_block) { display_lock_set_custom_holdkey_block(true); @@ -1276,7 +1223,7 @@ void reset_lcd_timeout(GDBusConnection *conn, display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); } static int delayed_init_done(void *data) @@ -1396,10 +1343,10 @@ static int power_resume_from_echomem_callback(void *data) system_wakeup_flag = true; if (check_wakeup_src() == EVENT_DEVICE) /* system waked up by devices */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); else /* system waked up by user input */ - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); return 0; } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 168041e..33072ae 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -111,7 +111,6 @@ static bool lcdon_broadcast = true; static bool touch_blocked = false; /* default transition, action fuctions */ -static int default_trans(int evt); static int default_action(int timeout); static int default_proc_change_state(unsigned int cond, pid_t pid); @@ -119,11 +118,11 @@ static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_cha static struct state states[S_END] = { { S_START, "S_START", NULL, NULL, NULL, NULL }, - { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL }, - { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL }, - { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL }, + { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL }, + { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL }, + { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL }, { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL }, - { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL }, + { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL }, { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; @@ -709,7 +708,7 @@ static int proc_condition(PMMsg *data) } if (!display_state_transition_is_there_state_transition_timer()) - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return 0; } @@ -724,58 +723,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -/* - * default transition function - * 1. call check - * 2. transition - * 3. call enter action function - */ -static int default_trans(int evt) -{ - struct state *st = &states[get_pm_cur_state()]; - enum state_t next_state; - int ret = 0; - - display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt); - - /* check conditions */ - ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); - if (ret < 0) { - /* There is a condition. */ - _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name, - states[next_state].name); - return -1; - } - - /* state transition */ - set_pm_old_state(get_pm_cur_state()); - set_pm_cur_state(next_state); - st = &states[get_pm_cur_state()]; - - /* enter action */ - if (st->action) { - if (get_pm_cur_state() == S_LCDOFF) - display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); - - if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) - if (set_custom_lcdon_timeout(0) == true) - display_state_transition_update_display_state_timeout_by_priority(); - - if (display_state_transition_is_possible_to_go_lcdoff()) { - /* enter next state directly */ - states[get_pm_cur_state()].trans(EVENT_TIMEOUT); - } else { - if ((get_pm_cur_state() == S_SLEEP) - && (is_emulator() == true || timeout_sleep_support == false)) - return 0; - - st->action(st->timeout); - } - } - - return 0; -} - static gboolean lcd_on_expired(void *data) { int lock_state, ret; @@ -952,7 +899,7 @@ go_suspend: go_lcd_off: if (!pm_get_power_lock_support()) { /* Resume !! */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); } return 0; } @@ -985,7 +932,7 @@ int poll_callback(int condition, PMMsg *data) if ((last_t != now) || (get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP)) { - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); last_t = now; } } @@ -1007,7 +954,7 @@ static int update_setting(int key_idx, int val) switch (key_idx) { case SETTING_TO_NORMAL: display_state_transition_update_display_state_timeout_by_priority(); - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOW_BATT: if (display_misc_is_low_battery_state(val)) { @@ -1071,13 +1018,13 @@ static int update_setting(int key_idx, int val) stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_LOCK_SCREEN_BG: set_lock_screen_bg_state(val); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); break; case SETTING_POWER_CUSTOM_BRIGHTNESS: if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON) @@ -1208,7 +1155,7 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name) /* Apply new backlight time */ display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); if (holdkey_block) { display_lock_set_custom_holdkey_block(true); @@ -1266,7 +1213,7 @@ void reset_lcd_timeout(GDBusConnection *conn, display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); } static int delayed_init_done(void *data) @@ -1387,10 +1334,10 @@ static int power_resume_from_echomem_callback(void *data) system_wakeup_flag = true; if (check_wakeup_src() == EVENT_DEVICE) /* system waked up by devices */ - states[get_pm_cur_state()].trans(EVENT_DEVICE); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE); else /* system waked up by user input */ - states[get_pm_cur_state()].trans(EVENT_INPUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); return 0; } diff --git a/src/display/display-lock.c b/src/display/display-lock.c index d218a19..5b2df70 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -275,7 +275,7 @@ static gboolean delete_state_cond_callback(void *data) * 2. Released lock is one of the pm_cur_state's lock * This emulates already expired transition timer */ if (!display_state_transition_is_there_state_transition_timer() && (get_pm_cur_state() == state)) - display_plugin_state_do_default_trans(get_pm_cur_state(), EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); if (state == S_LCDOFF) set_process_active(false, pid); diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 176ab5d..3af5995 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -166,6 +166,15 @@ int display_plugin_state_do_default_action(enum state_t state, int timeout) return -EOPNOTSUPP; } +/* FIXME: default_action/default_trans naming should be changed after state transition functions are relocated */ +bool display_plugin_state_is_there_default_action(enum state_t state) +{ + if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->action) + return true; + + return false; +} + int display_plugin_state_get_name(enum state_t state, const char **state_name) { if (!state_name) diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 820cf0f..bea8205 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -97,6 +97,7 @@ int display_plugin_backlight_transit_brightness(int start, int end, int step); int display_plugin_state_do_default_trans(enum state_t state, int evt); bool display_plugin_state_is_there_default_trans(enum state_t state); int display_plugin_state_do_default_action(enum state_t state, int timeout); +bool display_plugin_state_is_there_default_action(enum state_t state); 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); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 4836cac..c7a5dff 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -92,7 +92,7 @@ static gboolean state_transition_timeout_handler(void *data) remove_state_transition(); - display_plugin_state_do_default_trans(get_pm_cur_state(), EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return G_SOURCE_REMOVE; } @@ -121,7 +121,7 @@ int display_state_transition_reset_state_transition_timeout(int timeout) state_transition_timer_id = g_timeout_add(timeout, state_transition_timeout_handler, NULL); else if (timeout == 0) - display_plugin_state_do_default_trans(get_pm_cur_state(), EVENT_TIMEOUT); + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return 0; } @@ -232,7 +232,7 @@ void display_state_transition_update_display_state_timeout_by_priority(void) _I("Normal: DIM timeout is set by %d ms", dim_state_timeout); } -static bool is_display_state_valid_for_transition(enum state_t state) +bool display_state_transition_is_display_state_support_transition(enum state_t state) { switch(state) { case S_NORMAL: @@ -251,7 +251,7 @@ int display_state_transition_check_state_transition_condition(enum state_t cur_s { int trans_cond; - if (!is_display_state_valid_for_transition(cur_state)) + if (!display_state_transition_is_display_state_support_transition(cur_state)) return -EPERM; makeup_trans_condition(); @@ -304,7 +304,6 @@ int display_state_transition_update_lcdoff_reason(int source) _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno()); return -EPERM; } - return 0; } @@ -342,4 +341,65 @@ bool display_state_transition_is_possible_to_go_lcdoff(void) _D("Goto LCDOFF direct: lock(%d) hdmi(%d) cradle(%d).", lock, hdmi_state, cradle); return true; +} + +/* FXIME: enter action logic should be discussed and considered about better logic */ +/* + * default transition function + * 1. call check + * 2. transition + * 3. call enter action function + */ +int display_state_transition_do_state_transition(enum state_t state, int evt_type) +{ + const char* current_state_name = NULL; + const char* next_state_name = NULL; + enum state_t next_state; + int ret = 0; + int timeout = 0; + + if (!display_state_transition_is_display_state_support_transition(state)) + return -EPERM; + + if (display_plugin_state_is_there_default_trans(state)) + return display_plugin_state_do_default_trans(state, evt_type); + + display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt_type); + + /* check conditions */ + ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state); + if (ret < 0) { + display_plugin_state_get_name(get_pm_cur_state(), ¤t_state_name); + display_plugin_state_get_name(next_state, &next_state_name); + /* There is a condition. */ + _I("%s locked. Trans to %s failed.", current_state_name, next_state_name); + return -EPERM; + } + + /* state transition */ + set_pm_old_state(get_pm_cur_state()); + set_pm_cur_state(next_state); + + /* enter action */ + if (display_plugin_state_is_there_default_action(get_pm_cur_state())) { + if (get_pm_cur_state() == S_LCDOFF) + display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); + + if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF)) + if (set_custom_lcdon_timeout(0) == true) + display_state_transition_update_display_state_timeout_by_priority(); + + if (display_state_transition_is_possible_to_go_lcdoff()) { + /* enter next state directly */ + display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); + } else { + if ((get_pm_cur_state() == S_SLEEP) && + (is_emulator() == true || timeout_sleep_support == false)) + return 0; + + display_plugin_state_get_timeout(get_pm_cur_state(), &timeout); + display_plugin_state_do_default_action(get_pm_cur_state(), timeout); + } + } + return 0; } \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index e114326..eeead2f 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -40,5 +40,7 @@ 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); 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); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file diff --git a/src/display/plugin-common/poll.c b/src/display/plugin-common/poll.c index 769c6d4..d9f1d1d 100644 --- a/src/display/plugin-common/poll.c +++ b/src/display/plugin-common/poll.c @@ -30,6 +30,7 @@ #include "poll.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-state-transition.h" #include "shared/plugin.h" static PMMsg recv_data; @@ -74,7 +75,7 @@ static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) if (cond < 0) return cond; - if (!display_plugin_state_is_there_default_trans(cond)) + if (!display_state_transition_is_display_state_support_transition(cond)) return -ENOTSUP; cond = SET_COND_REQUEST(cond, PM_REQUEST_LOCK); @@ -103,7 +104,7 @@ static int __pm_unlock_internal(pid_t pid, int s_bits, int flag) if (cond < 0) return cond; - if (!display_plugin_state_is_there_default_trans(cond)) + if (!display_state_transition_is_display_state_support_transition(cond)) return -ENOTSUP; cond = SET_COND_REQUEST(cond, PM_REQUEST_UNLOCK); @@ -138,7 +139,7 @@ static int __pm_change_internal(pid_t pid, int s_bits) return -ENOTSUP; } - if (!display_plugin_state_is_there_default_trans(cond)) + if (!display_state_transition_is_display_state_support_transition(cond)) return -ENOTSUP; cond = SET_COND_REQUEST(cond, PM_REQUEST_CHANGE); -- 2.7.4 From b5ee57b809a0da9fe219c048551abf9a4f46a68b Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 12 Jun 2023 17:03:04 +0900 Subject: [PATCH 13/16] input: Remove unused code of input-dbus from plugin Change-Id: I28af8d7611c138eab106b748fea3d9efc38b5e90 Signed-off-by: Youngjae Cho --- plugins/iot-headless/input/input-dbus.c | 40 ------------------------------ plugins/iot-headless/input/input-dbus.h | 6 ----- plugins/iot-headless/input/input-handler.c | 1 - 3 files changed, 47 deletions(-) delete mode 100644 plugins/iot-headless/input/input-dbus.c delete mode 100644 plugins/iot-headless/input/input-dbus.h diff --git a/plugins/iot-headless/input/input-dbus.c b/plugins/iot-headless/input/input-dbus.c deleted file mode 100644 index 8b72583..0000000 --- a/plugins/iot-headless/input/input-dbus.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include - -#include "shared/common.h" -#include "input-handler.h" -#include "core/log.h" - -static GVariant *dbus_emulate_key(GDBusConnection *conn, - const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, - GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) -{ - int keycode, keyvalue; - - g_variant_get(param, "(ii)", &keycode, &keyvalue); - - input_handler_process_key(keycode, keyvalue); - - return gdbus_new_g_variant_tuple(); -} - -static const dbus_method_s dbus_methods[] = { - { "EmulateKey", "ii", NULL, dbus_emulate_key }, -}; - -static const dbus_interface_u dbus_interface = { - .oh = NULL, - .name = DEVICED_INTERFACE_INPUT, - .methods = dbus_methods, - .nr_methods = ARRAY_SIZE(dbus_methods), -}; - -void init_input_dbus(void) -{ - int ret; - - ret = gdbus_add_object(NULL, DEVICED_PATH_INPUT, &dbus_interface); - if (ret < 0) - _W("Failed to init plugin iot-headless input dbus interface(%d)", ret); -} diff --git a/plugins/iot-headless/input/input-dbus.h b/plugins/iot-headless/input/input-dbus.h deleted file mode 100644 index 1be58c4..0000000 --- a/plugins/iot-headless/input/input-dbus.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __INPUT_DBUS_H__ -#define __INPUT_DBUS_H__ - -void init_input_dbus(void); - -#endif //__INPUT_DBUS_H__ diff --git a/plugins/iot-headless/input/input-handler.c b/plugins/iot-headless/input/input-handler.c index 2f02aa5..c332d32 100644 --- a/plugins/iot-headless/input/input-handler.c +++ b/plugins/iot-headless/input/input-handler.c @@ -30,7 +30,6 @@ #include "shared/event.h" #include "input-config.h" -#include "input-dbus.h" #include "input/input.h" static int input_event_handler_id; -- 2.7.4 From e4a5f20676cb9b32e0735c1e28f6b8185a5d8265 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Mon, 12 Jun 2023 20:43:41 +0900 Subject: [PATCH 14/16] display: Remove lcd_on_expired()/stop_lock_timer()/check_lock_screen() These functions are used when the EVENT_INPUT occurs from the below situation, S_SLEEP/S_LCDOFF --> EVENT_INPUT --> S_NORMAL check_lock_screen() checks lock_screen state, If lock_screen is not launched, this adds timeout callback for lcd_on_procedure(). stop_lock_timer() removes callback from above description. lcd_on_expired() is callback for lcd_on_procedure() after timeout. Simply, that functions checks lock screen status, and then If lock screen is not launched, go to lcd_on_procedure after timeout value. However, according to the default_action code logic, it goes to lcd_on_procedure() regardless of check_lock_screen(). Also, meaningless lcd_on_procedure() call occurs. Thus, lcd_on_expired()/stop_lock_timer()/check_lock_screen() is removed. Change-Id: Ie82889e951678260ac10e1b7c86546040aff3fc8 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 55 +-------------------------------------- plugins/mobile/display/core.c | 55 +-------------------------------------- plugins/tv/display/core.c | 55 +-------------------------------------- plugins/wearable/display/core.c | 55 +-------------------------------------- 4 files changed, 4 insertions(+), 216 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 74eb8fd..240eb3b 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -100,7 +100,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; -static guint lock_timeout_id; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -723,51 +722,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static gboolean lcd_on_expired(void *data) -{ - int lock_state, ret; - - if (lock_timeout_id) - lock_timeout_id = 0; - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK) - return G_SOURCE_REMOVE; - else if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - - /* lock screen is not launched yet, but lcd is on */ - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); - - return G_SOURCE_REMOVE; -} - -static inline void stop_lock_timer(void) -{ - if (lock_timeout_id) { - g_source_remove(lock_timeout_id); - lock_timeout_id = 0; - } -} - -static void check_lock_screen(void) -{ - int lock_state, ret; - - stop_lock_timer(); - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) - return; - - /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, - lcd_on_expired, NULL); -} - /* default enter action function */ static int default_action(int timeout) { @@ -826,9 +780,7 @@ static int default_action(int timeout) * normal state : backlight on and restore * the previous brightness */ - if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - check_lock_screen(); - else if (get_pm_old_state() == S_LCDDIM) + if (get_pm_old_state() == S_LCDDIM) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) @@ -850,7 +802,6 @@ static int default_action(int timeout) case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { - stop_lock_timer(); /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -863,9 +814,6 @@ static int default_action(int timeout) break; case S_SLEEP: - if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) - stop_lock_timer(); - if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -1015,7 +963,6 @@ static int update_setting(int key_idx, int val) display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 6d1244d..51daaac 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -102,7 +102,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; -static guint lock_timeout_id; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -733,51 +732,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static gboolean lcd_on_expired(void *data) -{ - int lock_state, ret; - - if (lock_timeout_id) - lock_timeout_id = 0; - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK) - return G_SOURCE_REMOVE; - else if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - - /* lock screen is not launched yet, but lcd is on */ - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); - - return G_SOURCE_REMOVE; -} - -static inline void stop_lock_timer(void) -{ - if (lock_timeout_id) { - g_source_remove(lock_timeout_id); - lock_timeout_id = 0; - } -} - -static void check_lock_screen(void) -{ - int lock_state, ret; - - stop_lock_timer(); - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) - return; - - /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, - lcd_on_expired, NULL); -} - /* default enter action function */ static int default_action(int timeout) { @@ -836,9 +790,7 @@ static int default_action(int timeout) * normal state : backlight on and restore * the previous brightness */ - if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - check_lock_screen(); - else if (get_pm_old_state() == S_LCDDIM) + if (get_pm_old_state() == S_LCDDIM) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) @@ -860,7 +812,6 @@ static int default_action(int timeout) case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { - stop_lock_timer(); /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -873,9 +824,6 @@ static int default_action(int timeout) break; case S_SLEEP: - if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) - stop_lock_timer(); - if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -1025,7 +973,6 @@ static int update_setting(int key_idx, int val) display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 33072ae..05826a9 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -100,7 +100,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; -static guint lock_timeout_id; static struct timeval lcdon_tv; /* * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial @@ -723,51 +722,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static gboolean lcd_on_expired(void *data) -{ - int lock_state, ret; - - if (lock_timeout_id) - lock_timeout_id = 0; - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK) - return G_SOURCE_REMOVE; - else if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - - /* lock screen is not launched yet, but lcd is on */ - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); - - return G_SOURCE_REMOVE; -} - -static inline void stop_lock_timer(void) -{ - if (lock_timeout_id) { - g_source_remove(lock_timeout_id); - lock_timeout_id = 0; - } -} - -static void check_lock_screen(void) -{ - int lock_state, ret; - - stop_lock_timer(); - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) - return; - - /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, - lcd_on_expired, NULL); -} - /* default enter action function */ static int default_action(int timeout) { @@ -826,9 +780,7 @@ static int default_action(int timeout) * normal state : backlight on and restore * the previous brightness */ - if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - check_lock_screen(); - else if (get_pm_old_state() == S_LCDDIM) + if (get_pm_old_state() == S_LCDDIM) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) @@ -850,7 +802,6 @@ static int default_action(int timeout) case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { - stop_lock_timer(); /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -863,9 +814,6 @@ static int default_action(int timeout) break; case S_SLEEP: - if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) - stop_lock_timer(); - if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -1015,7 +963,6 @@ static int update_setting(int key_idx, int val) display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index de873cb..a47192f 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -112,7 +112,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; -static guint lock_timeout_id; static guint transit_timer; static struct timeval lcdon_tv; /* @@ -1119,51 +1118,6 @@ static int default_trans(int evt) return 0; } -static gboolean lcd_on_expired(void *data) -{ - int lock_state, ret; - - if (lock_timeout_id) - lock_timeout_id = 0; - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK) - return G_SOURCE_REMOVE; - else if (ret < 0) - _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno()); - - /* lock screen is not launched yet, but lcd is on */ - if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); - - return G_SOURCE_REMOVE; -} - -static inline void stop_lock_timer(void) -{ - if (lock_timeout_id) { - g_source_remove(lock_timeout_id); - lock_timeout_id = 0; - } -} - -static void check_lock_screen(void) -{ - int lock_state, ret; - - stop_lock_timer(); - - /* check state of lock */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK) - return; - - /* Use time to check lock is done. */ - lock_timeout_id = g_timeout_add(display_conf.lock_wait_time, - lcd_on_expired, NULL); -} - /* default enter action function */ static int default_action(int timeout) { @@ -1234,9 +1188,7 @@ static int default_action(int timeout) * normal state : backlight on and restore * the previous brightness */ - if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - check_lock_screen(); - else if (get_pm_old_state() == S_LCDDIM) + if (get_pm_old_state() == S_LCDDIM) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) @@ -1258,7 +1210,6 @@ static int default_action(int timeout) case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { - stop_lock_timer(); /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -1271,9 +1222,6 @@ static int default_action(int timeout) break; case S_SLEEP: - if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) - stop_lock_timer(); - if (display_panel_get_dpms_cached_state() == DPMS_ON) lcd_off_procedure(LCD_OFF_BY_TIMEOUT); @@ -1421,7 +1369,6 @@ static int update_setting(int key_idx, int val) display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - stop_lock_timer(); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) states[get_pm_cur_state()].trans(EVENT_INPUT); -- 2.7.4 From eb986c8d42dd107f15cfb14b4ac7220d79fcc455 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Mon, 12 Jun 2023 21:46:48 +0900 Subject: [PATCH 15/16] display: Relocate touch_event_blocked() touch_event_blocked() checks touch event blocking during lcd_on/off_procedure(). For relocating lcd_on/off_procedure(), touch_event_blocked() is also relocated. This functions are added below display-misc. - int display_misc_set_touch_event_blocked(bool blocked); - bool display_misc_is_touch_event_blocked(void); -> This replaces touch_event_blocked() Change-Id: Icaa609ad4a4e168663dd85556dea2c448b5747bd Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 11 ++--------- plugins/iot-headed/display/key-filter.c | 3 ++- plugins/mobile/display/core.c | 11 ++--------- plugins/mobile/display/key-filter.c | 3 ++- plugins/tv/display/core.c | 11 ++--------- plugins/tv/display/key-filter.c | 3 ++- plugins/wearable/display/core.c | 11 ++--------- plugins/wearable/display/key-filter.c | 3 ++- src/display/core.h | 1 - src/display/display-misc.c | 12 ++++++++++++ src/display/display-misc.h | 2 ++ 11 files changed, 30 insertions(+), 41 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 240eb3b..772b225 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -107,8 +107,6 @@ static struct timeval lcdon_tv; */ static bool lcdon_broadcast = true; -static bool touch_blocked = false; - /* default transition, action fuctions */ static int default_action(int timeout); @@ -201,11 +199,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -bool touch_event_blocked(void) -{ - return touch_blocked; -} - void lcd_on_procedure(int state, enum device_flags flag) { unsigned long flags = NORMAL_MODE; @@ -252,7 +245,7 @@ void lcd_on_procedure(int state, enum device_flags flag) touchled_control_backlight(TOUCHLED_DIRECT_ON); - touch_blocked = false; + display_misc_set_touch_event_blocked(false); } inline void lcd_off_procedure(enum device_flags flag) @@ -285,7 +278,7 @@ inline void lcd_off_procedure(enum device_flags flag) /* operation */ - touch_blocked = true; + display_misc_set_touch_event_blocked(true); set_setting_pmstate(S_LCDOFF); diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 5361e0e..e0e0ae9 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-misc.h" #include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" @@ -693,7 +694,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned ignore = false; break; case EV_ABS: - if (touch_event_blocked() + if (display_misc_is_touch_event_blocked() && !g_display_plugin.config->touch_wakeup && pinput->value == KEY_BEING_PRESSED) return; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 51daaac..5206550 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -109,8 +109,6 @@ static struct timeval lcdon_tv; */ static bool lcdon_broadcast = true; -static bool touch_blocked = false; - /* default transition, action fuctions */ static int default_action(int timeout); @@ -208,11 +206,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -bool touch_event_blocked(void) -{ - return touch_blocked; -} - void lcd_on_procedure(int state, enum device_flags flag) { unsigned long flags = NORMAL_MODE; @@ -259,7 +252,7 @@ void lcd_on_procedure(int state, enum device_flags flag) touchled_control_backlight(TOUCHLED_DIRECT_ON); - touch_blocked = false; + display_misc_set_touch_event_blocked(false); } inline void lcd_off_procedure(enum device_flags flag) @@ -292,7 +285,7 @@ inline void lcd_off_procedure(enum device_flags flag) /* operation */ - touch_blocked = true; + display_misc_set_touch_event_blocked(true); set_setting_pmstate(S_LCDOFF); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 65a0de2..11d6dfb 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-misc.h" #include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" @@ -720,7 +721,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned ignore = false; break; case EV_ABS: - if (touch_event_blocked() + if (display_misc_is_touch_event_blocked() && !g_display_plugin.config->touch_wakeup && pinput->value == KEY_BEING_PRESSED) return; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 05826a9..a66afaa 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -107,8 +107,6 @@ static struct timeval lcdon_tv; */ static bool lcdon_broadcast = true; -static bool touch_blocked = false; - /* default transition, action fuctions */ static int default_action(int timeout); @@ -201,11 +199,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -bool touch_event_blocked(void) -{ - return touch_blocked; -} - void lcd_on_procedure(int state, enum device_flags flag) { unsigned long flags = NORMAL_MODE; @@ -252,7 +245,7 @@ void lcd_on_procedure(int state, enum device_flags flag) touchled_control_backlight(TOUCHLED_DIRECT_ON); - touch_blocked = false; + display_misc_set_touch_event_blocked(false); } inline void lcd_off_procedure(enum device_flags flag) @@ -285,7 +278,7 @@ inline void lcd_off_procedure(enum device_flags flag) /* operation */ - touch_blocked = true; + display_misc_set_touch_event_blocked(true); set_setting_pmstate(S_LCDOFF); diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 6a44187..50fb6d6 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-backlight.h" #include "display-ops.h" #include "display-config.h" +#include "display-misc.h" #include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" @@ -687,7 +688,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned ignore = false; break; case EV_ABS: - if (touch_event_blocked() + if (display_misc_is_touch_event_blocked() && !g_display_plugin.config->touch_wakeup && pinput->value == KEY_BEING_PRESSED) return; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index a47192f..5a8f2bf 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -120,8 +120,6 @@ static struct timeval lcdon_tv; */ static bool lcdon_broadcast = true; -static bool touch_blocked = false; - /* default transition, action fuctions */ static int default_trans(int evt); static int default_action(int timeout); @@ -452,11 +450,6 @@ static int get_device_flags(unsigned long *device_flags) return 0; } -bool touch_event_blocked(void) -{ - return touch_blocked; -} - static gboolean late_transit_on(void *data) { if (!transit_timer) @@ -532,7 +525,7 @@ void lcd_on_procedure(int state, enum device_flags flag) lcdon_broadcast = true; } - touch_blocked = false; + display_misc_set_touch_event_blocked(false); } inline void lcd_off_procedure(enum device_flags flag) @@ -565,7 +558,7 @@ inline void lcd_off_procedure(enum device_flags flag) /* operation */ - touch_blocked = true; + display_misc_set_touch_event_blocked(true); if (flags & AMBIENT_MODE) { if (ambient_get_state() == true) diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 2658612..701041a 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -37,6 +37,7 @@ #include "display-panel.h" #include "display-backlight.h" #include "display-config.h" +#include "display-misc.h" #include "display-state-transition.h" #include "shared/common.h" #include "shared/devices.h" @@ -647,7 +648,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned ignore = false; break; case EV_ABS: - if (touch_event_blocked() && !ambient_get_state() + if (display_misc_is_touch_event_blocked() && !ambient_get_state() && !g_display_plugin.config->touch_wakeup && pinput->value == KEY_BEING_PRESSED) return; diff --git a/src/display/core.h b/src/display/core.h index 6a11082..0b5d791 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -130,7 +130,6 @@ int custom_lcdon(int timeout); void lcd_on_direct(enum device_flags flags); void lcd_on_procedure(int state, enum device_flags flag); void lcd_off_procedure(enum device_flags flag); -bool touch_event_blocked(void); void broadcast_lcd_off_late(enum device_flags flags); /* auto-brightness.c */ diff --git a/src/display/display-misc.c b/src/display/display-misc.c index ec3cc91..e1d02af 100644 --- a/src/display/display-misc.c +++ b/src/display/display-misc.c @@ -38,6 +38,7 @@ #include "poll.h" static bool stay_touchscreen_off = false; +static bool touch_event_blocked = false; /* FIXME: This fucntion should be relocated under the battery module */ bool display_misc_is_low_battery_state(int val) @@ -97,6 +98,17 @@ void display_misc_get_stay_touchscreen_off(bool *on) *on = stay_touchscreen_off; } +int display_misc_set_touch_event_blocked(bool blocked) +{ + touch_event_blocked = blocked; + return 0; +} + +bool display_misc_is_touch_event_blocked(void) +{ + return touch_event_blocked; +} + /* FIXME: This fucntion should be relocated under the battery module or redefined */ static int changed_battery_health(void *data) { diff --git a/src/display/display-misc.h b/src/display/display-misc.h index 3176350..e213f81 100644 --- a/src/display/display-misc.h +++ b/src/display/display-misc.h @@ -34,5 +34,7 @@ void display_misc_get_stay_touchscreen_off(bool *on); void display_misc_register_battery_health_notifier(void); void display_misc_unregister_battery_health_notifier(void); void display_misc_save_display_log(const char *path); +int display_misc_set_touch_event_blocked(bool blocked); +bool display_misc_is_touch_event_blocked(void); #endif /* __DISPLAY_MISC_H__ */ \ No newline at end of file -- 2.7.4 From df74a37e72e8caa1ec5a4cf5fb5a453770c80210 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 13 Jun 2023 11:00:03 +0900 Subject: [PATCH 16/16] display: Relocate lcd_on/off_procedure() lcd_on/off_procedure() rules are same in all plugins except wearable. Thus, duplicated codes are removed and relocated to display-panel. These functions are added below display-panel. - void display_panel_lcd_on_procedure(int state, enum device_flags flag); -> This replaces lcd_on_procedure(), it works to turn on lcd. - void display_panel_lcd_off_procedure(enum device_flags flag); -> This replaces lcd_off_procedure(), it works to turn off lcd. - bool display_panel_is_lcd_on_state_broadcasted(void); -> With this, It is possible to know if the lcd_on/off_procedure() done. This is used as flag of lcd on/off process. This function is added below display-plugin. - int display_plugin_lcd_off_procedure(enum device_flags flag); -> This is for wearable plugin, there is lcd_off_procedure() use case in the key-filter.c Change-Id: I1a7f8268df4d45d0585fe7c8a93981cc7be4268c Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 129 ++++--------------------------- plugins/iot-headed/display/key-filter.c | 2 +- plugins/mobile/display/core.c | 131 +++++--------------------------- plugins/mobile/display/key-filter.c | 2 +- plugins/tv/display/core.c | 129 ++++--------------------------- plugins/tv/display/key-filter.c | 2 +- plugins/wearable/display/core.c | 5 +- plugins/wearable/display/key-filter.c | 2 +- src/display/core.h | 2 - src/display/display-panel.c | 107 +++++++++++++++++++++++++- src/display/display-panel.h | 3 + src/display/display-plugin.c | 10 +++ src/display/display-plugin.h | 2 + 13 files changed, 176 insertions(+), 350 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 772b225..6d0393a 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -101,11 +101,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; static struct timeval lcdon_tv; -/* - * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial - * state because it should be sent from previous state at booting time. - */ -static bool lcdon_broadcast = true; /* default transition, action fuctions */ static int default_action(int timeout); @@ -199,99 +194,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -void lcd_on_procedure(int state, enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display on procedure - * step 1. leave doze - * step 2. broadcast lcd on signal with cause - * step 3. set brightness - * step 4. set pmstate of vconf - * step 5. display on operate - * - a. display on - * - b. TSP(touch screen) and touchkey enable - * step 6. broadcast lcd on complete signal - * step 7. key backlight enable - */ - leave_doze(); - - _I("[lcdstep] 0x%lx", flags); - - /* send LCDOn dbus signal */ - if (!lcdon_broadcast) - broadcast_lcd_on(SIGNAL_PRE, flags); - - /* Update brightness level */ - if (state == LCD_DIM) - display_backlight_set_brightness_by_dim_brightness(); - else if (state == LCD_NORMAL) - display_backlight_update_by_default_brightness(); - - if (state == LCD_NORMAL) - set_setting_pmstate(S_NORMAL); - else if (state == LCD_DIM) - set_setting_pmstate(S_LCDDIM); - - display_start_dependent_device(flags); - - if (!lcdon_broadcast) { - broadcast_lcd_on(SIGNAL_POST, flags); - lcdon_broadcast = true; - } - - touchled_control_backlight(TOUCHLED_DIRECT_ON); - - display_misc_set_touch_event_blocked(false); -} - -inline void lcd_off_procedure(enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display off procedure - * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM) - * step 1. broadcast lcd off signal with cause - * step 2. set pmstate of vconf - * step 3. display off operate - * - a. display off - * - b. TSP(touch screen) and touchkey disable - * step 4. broadcast lcd off complete siganl - * step 5. enter doze mode if it is enabled - */ - _I("[lcdstep] 0x%lx", flags); - - /* notification */ - - device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL); - - if (lcdon_broadcast) { - broadcast_lcd_off(SIGNAL_PRE, flags); - lcdon_broadcast = false; - } - - /* operation */ - - display_misc_set_touch_event_blocked(true); - - set_setting_pmstate(S_LCDOFF); - - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - display_stop_dependent_device(flags); - - broadcast_lcd_off(SIGNAL_POST, flags); - device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); - - enter_doze(); -} - static void update_display_locktime(int time) { display_state_transition_set_lock_screen_timeout(time); @@ -314,7 +216,7 @@ void lcd_on_direct(enum device_flags flags) _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); - lcd_on_procedure(LCD_NORMAL, flags); + display_panel_lcd_on_procedure(LCD_NORMAL, flags); update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); } @@ -395,7 +297,7 @@ int custom_lcdoff(enum device_flags flag) _I("custom lcd off by flag(%d)", flag); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); @@ -483,7 +385,7 @@ int display_off_by_reason(const char *reason) _I("platform lcd off by %s", reason); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -533,7 +435,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) break; case S_LCDOFF: if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); @@ -546,7 +448,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) delete_condition(S_NORMAL); delete_condition(S_LCDDIM); delete_condition(S_LCDOFF); - if (lcdon_broadcast) { + if (display_panel_is_lcd_on_state_broadcasted()) { _I("broadcast lcd off signal at non-lcd device"); broadcast_lcd_off(SIGNAL_PRE, 0); broadcast_lcd_off(SIGNAL_POST, 0); @@ -777,7 +679,7 @@ static int default_action(int timeout) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); break; case S_LCDDIM: @@ -790,25 +692,25 @@ static int default_action(int timeout) display_backlight_set_brightness_by_dim_brightness(); if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - lcd_on_procedure(LCD_DIM, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE); break; case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; case S_SLEEP: if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { /* sleep state : set system mode to SUSPEND */ @@ -955,7 +857,7 @@ static int update_setting(int key_idx, int val) val == VCONFKEY_IDLE_LOCK && display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); @@ -1186,7 +1088,7 @@ static gboolean delayed_dpms_init_done(gpointer data) switch (get_pm_cur_state()) { case S_NORMAL: case S_LCDDIM: - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (display_conf.timeout_enable) { timeout = states[S_NORMAL].timeout; /* check minimun lcd on time */ @@ -1196,7 +1098,7 @@ static gboolean delayed_dpms_init_done(gpointer data) } break; case S_LCDOFF: - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); timeout = display_conf.lcdoff_timeout; display_state_transition_reset_state_transition_timeout(timeout); break; @@ -1235,6 +1137,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_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); /* check display feature */ @@ -1417,9 +1320,9 @@ static void display_init(void *data) // wm_ready = check_wm_ready(); if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); else - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_dpms_init(); } diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index e0e0ae9..c6aa7d1 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -229,7 +229,7 @@ static inline void switch_off_lcd(void) broadcast_lcdoff_by_powerkey(); - lcd_off_procedure(LCD_OFF_BY_POWER_KEY); + display_panel_lcd_off_procedure(LCD_OFF_BY_POWER_KEY); } static void check_key_combination(struct input_event *pinput) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 5206550..f7732c4 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -103,11 +103,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; static struct timeval lcdon_tv; -/* - * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial - * state because it should be sent from previous state at booting time. - */ -static bool lcdon_broadcast = true; /* default transition, action fuctions */ static int default_action(int timeout); @@ -206,99 +201,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -void lcd_on_procedure(int state, enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display on procedure - * step 1. leave doze - * step 2. broadcast lcd on signal with cause - * step 3. set brightness - * step 4. set pmstate of vconf - * step 5. display on operate - * - a. display on - * - b. TSP(touch screen) and touchkey enable - * step 6. broadcast lcd on complete signal - * step 7. key backlight enable - */ - leave_doze(); - - _I("[lcdstep] 0x%lx", flags); - - /* send LCDOn dbus signal */ - if (!lcdon_broadcast) - broadcast_lcd_on(SIGNAL_PRE, flags); - - /* Update brightness level */ - if (state == LCD_DIM) - display_backlight_set_brightness_by_dim_brightness(); - else if (state == LCD_NORMAL) - display_backlight_update_by_default_brightness(); - - if (state == LCD_NORMAL) - set_setting_pmstate(S_NORMAL); - else if (state == LCD_DIM) - set_setting_pmstate(S_LCDDIM); - - display_start_dependent_device(flags); - - if (!lcdon_broadcast) { - broadcast_lcd_on(SIGNAL_POST, flags); - lcdon_broadcast = true; - } - - touchled_control_backlight(TOUCHLED_DIRECT_ON); - - display_misc_set_touch_event_blocked(false); -} - -inline void lcd_off_procedure(enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display off procedure - * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM) - * step 1. broadcast lcd off signal with cause - * step 2. set pmstate of vconf - * step 3. display off operate - * - a. display off - * - b. TSP(touch screen) and touchkey disable - * step 4. broadcast lcd off complete siganl - * step 5. enter doze mode if it is enabled - */ - _I("[lcdstep] 0x%lx", flags); - - /* notification */ - - device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL); - - if (lcdon_broadcast) { - broadcast_lcd_off(SIGNAL_PRE, flags); - lcdon_broadcast = false; - } - - /* operation */ - - display_misc_set_touch_event_blocked(true); - - set_setting_pmstate(S_LCDOFF); - - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - display_stop_dependent_device(flags); - - broadcast_lcd_off(SIGNAL_POST, flags); - device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); - - enter_doze(); -} - static void update_display_locktime(int time) { display_state_transition_set_lock_screen_timeout(time); @@ -321,7 +223,7 @@ void lcd_on_direct(enum device_flags flags) _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); - lcd_on_procedure(LCD_NORMAL, flags); + display_panel_lcd_on_procedure(LCD_NORMAL, flags); update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); } @@ -402,7 +304,7 @@ int custom_lcdoff(enum device_flags flag) _I("custom lcd off by flag(%d)", flag); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); @@ -490,7 +392,7 @@ int display_off_by_reason(const char *reason) _I("platform lcd off by %s", reason); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -541,9 +443,9 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) case S_LCDOFF: if (display_panel_get_dpms_cached_state() == DPMS_ON) { if (get_proximity_state() == SENSOR_PROXIMITY_NEAR) - lcd_off_procedure(LCD_OFF_BY_PROXIMITY); + display_panel_lcd_off_procedure(LCD_OFF_BY_PROXIMITY); else - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); } if (set_custom_lcdon_timeout(0)) display_state_transition_update_display_state_timeout_by_priority(); @@ -557,7 +459,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) delete_condition(S_NORMAL); delete_condition(S_LCDDIM); delete_condition(S_LCDOFF); - if (lcdon_broadcast) { + if (display_panel_is_lcd_on_state_broadcasted()) { _I("broadcast lcd off signal at non-lcd device"); broadcast_lcd_off(SIGNAL_PRE, 0); broadcast_lcd_off(SIGNAL_POST, 0); @@ -787,7 +689,7 @@ static int default_action(int timeout) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); break; case S_LCDDIM: @@ -800,25 +702,25 @@ static int default_action(int timeout) display_backlight_set_brightness_by_dim_brightness(); if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - lcd_on_procedure(LCD_DIM, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE); break; case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; case S_SLEEP: if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { /* sleep state : set system mode to SUSPEND */ @@ -965,7 +867,7 @@ static int update_setting(int key_idx, int val) val == VCONFKEY_IDLE_LOCK && display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); @@ -1196,7 +1098,7 @@ static gboolean delayed_dpms_init_done(gpointer data) switch (get_pm_cur_state()) { case S_NORMAL: case S_LCDDIM: - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (display_conf.timeout_enable) { timeout = states[S_NORMAL].timeout; /* check minimun lcd on time */ @@ -1206,7 +1108,7 @@ static gboolean delayed_dpms_init_done(gpointer data) } break; case S_LCDOFF: - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); timeout = display_conf.lcdoff_timeout; display_state_transition_reset_state_transition_timeout(timeout); break; @@ -1245,6 +1147,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_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); /** @@ -1423,9 +1326,9 @@ static void display_init(void *data) // wm_ready = check_wm_ready(); if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); else - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_dpms_init(); } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 11d6dfb..a8dbe81 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -219,7 +219,7 @@ static inline void switch_off_lcd(void) broadcast_lcdoff_by_powerkey(); - lcd_off_procedure(LCD_OFF_BY_POWER_KEY); + display_panel_lcd_off_procedure(LCD_OFF_BY_POWER_KEY); } static void check_key_combination(struct input_event *pinput) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index a66afaa..e53409e 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -101,11 +101,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; static int system_wakeup_flag = false; static char *custom_change_name; static struct timeval lcdon_tv; -/* - * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial - * state because it should be sent from previous state at booting time. - */ -static bool lcdon_broadcast = true; /* default transition, action fuctions */ static int default_action(int timeout); @@ -199,99 +194,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -void lcd_on_procedure(int state, enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display on procedure - * step 1. leave doze - * step 2. broadcast lcd on signal with cause - * step 3. set brightness - * step 4. set pmstate of vconf - * step 5. display on operate - * - a. display on - * - b. TSP(touch screen) and touchkey enable - * step 6. broadcast lcd on complete signal - * step 7. key backlight enable - */ - leave_doze(); - - _I("[lcdstep] 0x%lx", flags); - - /* send LCDOn dbus signal */ - if (!lcdon_broadcast) - broadcast_lcd_on(SIGNAL_PRE, flags); - - /* Update brightness level */ - if (state == LCD_DIM) - display_backlight_set_brightness_by_dim_brightness(); - else if (state == LCD_NORMAL) - display_backlight_update_by_default_brightness(); - - if (state == LCD_NORMAL) - set_setting_pmstate(S_NORMAL); - else if (state == LCD_DIM) - set_setting_pmstate(S_LCDDIM); - - display_start_dependent_device(flags); - - if (!lcdon_broadcast) { - broadcast_lcd_on(SIGNAL_POST, flags); - lcdon_broadcast = true; - } - - touchled_control_backlight(TOUCHLED_DIRECT_ON); - - display_misc_set_touch_event_blocked(false); -} - -inline void lcd_off_procedure(enum device_flags flag) -{ - unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); - flags |= flag; - - /* - * Display off procedure - * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM) - * step 1. broadcast lcd off signal with cause - * step 2. set pmstate of vconf - * step 3. display off operate - * - a. display off - * - b. TSP(touch screen) and touchkey disable - * step 4. broadcast lcd off complete siganl - * step 5. enter doze mode if it is enabled - */ - _I("[lcdstep] 0x%lx", flags); - - /* notification */ - - device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL); - - if (lcdon_broadcast) { - broadcast_lcd_off(SIGNAL_PRE, flags); - lcdon_broadcast = false; - } - - /* operation */ - - display_misc_set_touch_event_blocked(true); - - set_setting_pmstate(S_LCDOFF); - - touchled_control_backlight(TOUCHLED_DIRECT_OFF); - - display_stop_dependent_device(flags); - - broadcast_lcd_off(SIGNAL_POST, flags); - device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); - - enter_doze(); -} - static void update_display_locktime(int time) { display_state_transition_set_lock_screen_timeout(time); @@ -314,7 +216,7 @@ void lcd_on_direct(enum device_flags flags) _D("lcd is on directly"); gettimeofday(&lcdon_tv, NULL); - lcd_on_procedure(LCD_NORMAL, flags); + display_panel_lcd_on_procedure(LCD_NORMAL, flags); update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT); } @@ -395,7 +297,7 @@ int custom_lcdoff(enum device_flags flag) _I("custom lcd off by flag(%d)", flag); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); if (set_custom_lcdon_timeout(0) == true) display_state_transition_update_display_state_timeout_by_priority(); @@ -483,7 +385,7 @@ int display_off_by_reason(const char *reason) _I("platform lcd off by %s", reason); if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(flag); + display_panel_lcd_off_procedure(flag); /* state transition */ set_pm_old_state(get_pm_cur_state()); @@ -533,7 +435,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) break; case S_LCDOFF: if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); if (set_custom_lcdon_timeout(0)) display_state_transition_update_display_state_timeout_by_priority(); default_proc_change_state_action(next, -1); @@ -546,7 +448,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) delete_condition(S_NORMAL); delete_condition(S_LCDDIM); delete_condition(S_LCDOFF); - if (lcdon_broadcast) { + if (display_panel_is_lcd_on_state_broadcasted()) { _I("broadcast lcd off signal at non-lcd device"); broadcast_lcd_off(SIGNAL_PRE, 0); broadcast_lcd_off(SIGNAL_POST, 0); @@ -777,7 +679,7 @@ static int default_action(int timeout) display_backlight_update_by_default_brightness(); if (check_lcd_is_on() == false) - lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE); break; case S_LCDDIM: @@ -790,25 +692,25 @@ static int default_action(int timeout) display_backlight_set_brightness_by_dim_brightness(); if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP)) - lcd_on_procedure(LCD_DIM, NORMAL_MODE); + display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE); break; case S_LCDOFF: if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) { /* lcd off state : turn off the backlight */ if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); } display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); if (display_panel_get_dpms_cached_state() == DPMS_ON || lcd_paneloff_mode) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); break; case S_SLEEP: if (display_panel_get_dpms_cached_state() == DPMS_ON) - lcd_off_procedure(LCD_OFF_BY_TIMEOUT); + display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT); if (!pm_get_power_lock_support()) { /* sleep state : set system mode to SUSPEND */ @@ -955,7 +857,7 @@ static int update_setting(int key_idx, int val) val == VCONFKEY_IDLE_LOCK && display_panel_get_dpms_cached_state() != DPMS_ON && is_lcdon_blocked() == LCDON_BLOCK_NONE) - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); display_state_transition_update_display_state_timeout_by_priority(); if (get_pm_cur_state() == S_NORMAL) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT); @@ -1186,7 +1088,7 @@ static gboolean delayed_dpms_init_done(gpointer data) switch (get_pm_cur_state()) { case S_NORMAL: case S_LCDDIM: - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); if (display_conf.timeout_enable) { timeout = states[S_NORMAL].timeout; /* check minimun lcd on time */ @@ -1196,7 +1098,7 @@ static gboolean delayed_dpms_init_done(gpointer data) } break; case S_LCDOFF: - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); timeout = display_conf.lcdoff_timeout; display_state_transition_reset_state_transition_timeout(timeout); break; @@ -1236,6 +1138,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_off_procedure = NULL; setup_display_plugin_backlight_ops(dp); /** @@ -1414,9 +1317,9 @@ static void display_init(void *data) // wm_ready = check_wm_ready(); if (display_panel_init_dpms()) { if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - lcd_off_procedure(LCD_OFF_BY_EVENT); + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); else - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); } else { add_timer_for_dpms_init(); } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 50fb6d6..a6c969d 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -229,7 +229,7 @@ static inline void switch_off_lcd(void) broadcast_lcdoff_by_powerkey(); - lcd_off_procedure(LCD_OFF_BY_POWER_KEY); + display_panel_lcd_off_procedure(LCD_OFF_BY_POWER_KEY); } static void check_key_combination(struct input_event *pinput) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 5a8f2bf..697b776 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -462,7 +462,7 @@ static gboolean late_transit_on(void *data) return G_SOURCE_REMOVE; } -void lcd_on_procedure(int state, enum device_flags flag) +static void lcd_on_procedure(int state, enum device_flags flag) { unsigned long flags = NORMAL_MODE; display_plugin_get_device_flags(&flags); @@ -528,7 +528,7 @@ void lcd_on_procedure(int state, enum device_flags flag) display_misc_set_touch_event_blocked(false); } -inline void lcd_off_procedure(enum device_flags flag) +static void lcd_off_procedure(enum device_flags flag) { unsigned long flags = NORMAL_MODE; display_plugin_get_device_flags(&flags); @@ -1661,6 +1661,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_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 701041a..19ae629 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -226,7 +226,7 @@ static inline void switch_off_lcd(void) broadcast_lcdoff_by_powerkey(); - lcd_off_procedure(LCD_OFF_BY_POWER_KEY); + display_panel_lcd_off_procedure(LCD_OFF_BY_POWER_KEY); } static void check_key_combination(struct input_event *pinput) diff --git a/src/display/core.h b/src/display/core.h index 0b5d791..9c07e26 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -128,8 +128,6 @@ int display_off_by_reason(const char *reason); int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name); int custom_lcdon(int timeout); void lcd_on_direct(enum device_flags flags); -void lcd_on_procedure(int state, enum device_flags flag); -void lcd_off_procedure(enum device_flags flag); 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 22542ac..2c94538 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -18,11 +18,13 @@ #include "shared/log.h" #include "power/power-suspend.h" +#include "power/power-doze.h" #include "ambient-mode.h" #include "device-interface.h" -#include "display-backlight.h" +#include "display-misc.h" #include "display-panel.h" -#include "display-plugin.h" +#include "display-signal.h" +#include "led/touch-key.h" #define MAX_WHITE_BALANCE_GAIN 2047 #define MAX_WHITE_BALANCE_OFFSET 2047 @@ -34,6 +36,7 @@ static int dpms_running_state = DPMS_SETTING_DONE; static bool lcd_paneloff_mode = false; +static bool lcd_on_broadcasted = true; /* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ int display_panel_set_dpms_state(int dpms_on, enum device_flags flags) @@ -201,6 +204,106 @@ void display_panel_get_lcd_paneloff_mode(bool *on) *on = lcd_paneloff_mode; } +void display_panel_lcd_on_procedure(int state, enum device_flags flag) +{ + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); + flags |= flag; + + /* + * Display on procedure + * step 1. leave doze + * step 2. broadcast lcd on signal with cause + * step 3. set brightness + * step 4. set pmstate of vconf + * step 5. display on operate + * - a. display on + * - b. TSP(touch screen) and touchkey enable + * step 6. broadcast lcd on complete signal + * step 7. key backlight enable + */ + leave_doze(); + + _I("[lcdstep] 0x%lx", flags); + + /* send LCDOn dbus signal */ + if (!lcd_on_broadcasted) + broadcast_lcd_on(SIGNAL_PRE, flags); + + /* Update brightness level */ + if (state == LCD_DIM) + display_backlight_set_brightness_by_dim_brightness(); + else if (state == LCD_NORMAL) + display_backlight_update_by_default_brightness(); + + if (state == LCD_NORMAL) + set_setting_pmstate(S_NORMAL); + else if (state == LCD_DIM) + set_setting_pmstate(S_LCDDIM); + + display_start_dependent_device(flags); + + if (!lcd_on_broadcasted) { + broadcast_lcd_on(SIGNAL_POST, flags); + lcd_on_broadcasted = true; + } + + touchled_control_backlight(TOUCHLED_DIRECT_ON); + + display_misc_set_touch_event_blocked(false); +} + +void display_panel_lcd_off_procedure(enum device_flags flag) +{ + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); + flags |= flag; + + if (display_plugin_lcd_off_procedure(flag) == 0) + return; + /* + * Display off procedure + * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM) + * step 1. broadcast lcd off signal with cause + * step 2. set pmstate of vconf + * step 3. display off operate + * - a. display off + * - b. TSP(touch screen) and touchkey disable + * step 4. broadcast lcd off complete siganl + * step 5. enter doze mode if it is enabled + */ + _I("[lcdstep] 0x%lx", flags); + + /* notification */ + + device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL); + + if (lcd_on_broadcasted) { + broadcast_lcd_off(SIGNAL_PRE, flags); + lcd_on_broadcasted = false; + } + + /* operation */ + + display_misc_set_touch_event_blocked(true); + + set_setting_pmstate(S_LCDOFF); + + touchled_control_backlight(TOUCHLED_DIRECT_OFF); + + display_stop_dependent_device(flags); + + broadcast_lcd_off(SIGNAL_POST, flags); + device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL); + + enter_doze(); +} + +bool display_panel_is_lcd_on_state_broadcasted(void) +{ + return lcd_on_broadcasted; +} + /* FIXME: This function is deprecated, should be fixed after plugin refactoring */ void display_panel_set_dpms_running_state(int val) { diff --git a/src/display/display-panel.h b/src/display/display-panel.h index 4cbc779..862fc35 100644 --- a/src/display/display-panel.h +++ b/src/display/display-panel.h @@ -32,6 +32,9 @@ int display_panel_set_panel_state_by_off_state(enum device_flags flags); int display_panel_set_panel_state_by_standby_state(bool standby_on); 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); +bool display_panel_is_lcd_on_state_broadcasted(void); /* Deprecated functions */ int display_panel_set_image_effect(enum display_image_effect effect); int display_panel_get_image_effect(enum display_image_effect *effect); diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 3af5995..d588965 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_off_procedure(enum device_flags flag) +{ + if (g_display_plugin.lcd_off_procedure) { + g_display_plugin.lcd_off_procedure(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 bea8205..d66dcac 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_off_procedure) (enum device_flags flag); struct display_config *config; struct display_backlight_ops *backlight; @@ -86,6 +87,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_off_procedure(enum device_flags flag); int display_plugin_backlight_get_lcd_power(void); int display_plugin_backlight_set_brightness(int brightness); -- 2.7.4