From df74a37e72e8caa1ec5a4cf5fb5a453770c80210 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 13 Jun 2023 11:00:03 +0900 Subject: [PATCH] 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