From 74225792755f9317a32d87e1190664c3d6817d47 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 13 Jul 2023 12:44:35 +0900 Subject: [PATCH] display: Relocate display initialization code Except for a specific profile, unnecessarily duplicated codes are erased. And same code is moved to display.c. Change-Id: I35c6e0693fb1e9581ecefa1f03db9fa71681084f Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 156 +------------------------ plugins/iot-headed/display/device-interface.c | 7 -- plugins/mobile/display/core.c | 157 +------------------------- plugins/mobile/display/device-interface.c | 8 -- plugins/tv/display/core.c | 154 +------------------------ plugins/tv/display/device-interface.c | 7 -- plugins/wearable/display/core.c | 149 +----------------------- plugins/wearable/display/device-interface.c | 3 +- src/display/display.c | 138 +++++++++++++++++++++- 9 files changed, 151 insertions(+), 628 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index f1607e6..1a4e4b2 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -78,8 +78,6 @@ * @{ */ -extern void init_save_userlock(void); - static struct display_plugin *disp_plgn; static struct display_backlight_ops *backlight_ops; static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT; @@ -94,8 +92,6 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ - #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ @@ -139,28 +135,6 @@ inline struct state* state_st(enum state_t state) return &states[state]; } -static void init_lcd_operation(void) -{ - const struct device_ops *ops = NULL; - - ops = find_device("display"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchkey"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchscreen"); - if (!check_default(ops)) - display_register_dependent_device(ops); -} - -static void exit_lcd_operation(void) -{ - display_unregister_dependent_device(); -} - enum { INIT_SETTING = 0, INIT_INTERFACE, @@ -170,14 +144,6 @@ enum { INIT_END }; -static const char *errMSG[INIT_END] = { - [INIT_SETTING] = "setting init error", - [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error", - [INIT_POLL] = "input devices poll init error", - [INIT_FIFO] = "FIFO poll init error", - [INIT_DBUS] = "d-bus init error", -}; - static void init_display_states(void *data) { struct display_plugin *dp = (struct display_plugin *) data; @@ -208,7 +174,6 @@ static int display_probe(void *data) dp->default_saving_mode = NULL; dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = NULL; - setup_display_plugin_backlight_ops(dp); /* check display feature */ if (!is_feature_display_supported()) @@ -226,132 +191,15 @@ static int display_probe(void *data) return 0; } -static int input_init_handler(void) -{ - if (!display_conf.input_support) - remove_device_by_devname("input"); - - return 0; -} - static void display_init(void *data) { - int ret, i; - unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); - int timeout = 0; - - _I("Start power manager."); + int ret; /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) _W("Failed to load '%s', use default value: %d", DISPLAY_CONF_FILE, ret); - - register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background); - register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground); - register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated); - - init_save_userlock(); - - for (i = INIT_SETTING; i < INIT_END; i++) { - switch (i) { - case INIT_SETTING: - ret = init_setting(NULL); - break; - case INIT_INTERFACE: - if (display_conf.timeout_enable) - display_initialize_display_state_timeout_from_setting(); - ret = init_sysfs(flags); - break; - case INIT_POLL: - _I("input init"); - ret = input_init_handler(); - - pm_lock_detector_init(); - break; - case INIT_DBUS: - _I("Dbus init."); - ret = init_pm_dbus(); - break; - } - if (ret != 0) { - _E("Failed to init: %s", errMSG[i]); - break; - } - } - - if (i == INIT_END) { - display_ops_init(NULL); -#ifdef ENABLE_PM_LOG - pm_history_init(); -#endif - init_lcd_operation(); - display_set_initial_brightness(); - display_set_initial_battery_flag(); - display_set_initial_lockscreen_status(); - - /* In smd test, TSP should be turned off if display panel is not existed. */ - if (display_panel_get_dpms_cached_state() == -ENOENT) { - _I("Display panel is not existed."); - lcd_direct_control(DPMS_OFF, NORMAL_MODE); - exit_lcd_operation(); - } - - /* wm_ready needs to be checked - * since display manager can be launched later than deviced. - * In the case, display cannot be turned on at the first booting */ - // wm_ready = check_wm_ready(); - if (display_panel_init_dpms()) { - if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); - else - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - } else { - display_add_timer_for_waiting_dpms_init(); - } - - if (display_conf.lcd_always_on) { - _I("LCD always on."); - display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT); - } - - if (flags & WITHOUT_STARTNOTI) { /* start without noti */ - _I("Start Power managing without noti"); - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, - HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL); - /* - * Lock lcd off until booting is done. - * deviced guarantees all booting script is executing. - * Last script of booting unlocks this suspend blocking state. - */ - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, - STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); - - /* Initial display state right after the booting done */ - if (is_lcdon_blocked()) - set_pm_cur_state(S_LCDOFF); - else - set_pm_cur_state(S_NORMAL); - ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state()); - if (ret < 0) - _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); - - display_set_display_ops_status(DEVICE_OPS_STATUS_START); - if (display_conf.timeout_enable) { - timeout = states[S_NORMAL].timeout; - /* check minimun lcd on time */ - if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) - timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, - STAY_CUR_STATE, timeout); - } - - } - - set_display_init_direction(display_conf.display_init_direction); - } } static void display_exit(void *data) @@ -385,7 +233,7 @@ static void display_exit(void *data) } } - exit_lcd_operation(); + display_unregister_dependent_device(); free_lock_info_list(); /* free display service */ diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index abb1969..e599fc7 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -107,13 +107,6 @@ void setup_display_plugin_backlight_ops(struct display_plugin *dp) dp->backlight = &backlight_ops; } -int init_sysfs(unsigned int flags) -{ - register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); - - return 0; -} - int exit_sysfs(void) { const struct device_ops *ops = NULL; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 197a39d..85f378d 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -79,8 +79,6 @@ * @{ */ -extern void init_save_userlock(void); - static struct display_plugin *disp_plgn; static struct display_backlight_ops *backlight_ops; @@ -96,8 +94,6 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ - #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 400 /* 0.4 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ @@ -192,28 +188,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -static void init_lcd_operation(void) -{ - const struct device_ops *ops = NULL; - - ops = find_device("display"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchkey"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchscreen"); - if (!check_default(ops)) - display_register_dependent_device(ops); -} - -static void exit_lcd_operation(void) -{ - display_unregister_dependent_device(); -} - enum { INIT_SETTING = 0, INIT_INTERFACE, @@ -223,14 +197,6 @@ enum { INIT_END }; -static const char *errMSG[INIT_END] = { - [INIT_SETTING] = "setting init error", - [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error", - [INIT_POLL] = "input devices poll init error", - [INIT_FIFO] = "FIFO poll init error", - [INIT_DBUS] = "d-bus init error", -}; - static void init_display_states(void *data) { struct display_plugin *dp = (struct display_plugin *) data; @@ -261,7 +227,6 @@ static int display_probe(void *data) dp->default_saving_mode = NULL; dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = default_proc_change_state; - setup_display_plugin_backlight_ops(dp); /** * load display service @@ -275,21 +240,9 @@ static int display_probe(void *data) return 0; } -static int input_init_handler(void) -{ - if (!display_conf.input_support) - remove_device_by_devname("input"); - - return 0; -} - static void display_init(void *data) { - int ret, i; - unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); - int timeout = 0; - - _I("Start power manager."); + int ret; /* load configutation */ ret = display_load_config(&display_conf); @@ -297,111 +250,7 @@ static void display_init(void *data) _W("Failed to load '%s', use default value: %d", DISPLAY_CONF_FILE, ret); - register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background); - register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground); - register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated); - - init_save_userlock(); - - for (i = INIT_SETTING; i < INIT_END; i++) { - switch (i) { - case INIT_SETTING: - ret = init_setting(NULL); - break; - case INIT_INTERFACE: - if (display_conf.timeout_enable) - display_initialize_display_state_timeout_from_setting(); - ret = init_sysfs(flags); - break; - case INIT_POLL: - _I("input init"); - ret = input_init_handler(); - - pm_lock_detector_init(); - break; - case INIT_DBUS: - _I("Dbus init."); - ret = init_pm_dbus(); - break; - } - if (ret != 0) { - _E("Failed to init: %s", errMSG[i]); - break; - } - } - - if (i == INIT_END) { - display_ops_init(NULL); -#ifdef ENABLE_PM_LOG - pm_history_init(); -#endif - init_lcd_operation(); - display_misc_set_battery_charging_status_flag(); - display_set_initial_brightness(); - display_set_initial_battery_flag(); - display_set_initial_lockscreen_status(); - - /* In smd test, TSP should be turned off if display panel is not existed. */ - if (display_panel_get_dpms_cached_state() == -ENOENT) { - _I("Display panel is not existed."); - lcd_direct_control(DPMS_OFF, NORMAL_MODE); - exit_lcd_operation(); - } - - /* wm_ready needs to be checked - * since display manager can be launched later than deviced. - * In the case, display cannot be turned on at the first booting */ - // wm_ready = check_wm_ready(); - if (display_panel_init_dpms()) { - if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); - else - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - } else { - display_add_timer_for_waiting_dpms_init(); - } - - if (display_conf.lcd_always_on) { - _I("LCD always on."); - display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT); - } - - if (flags & WITHOUT_STARTNOTI) { /* start without noti */ - _I("Start Power managing without noti"); - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, - HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL); - /* - * Lock lcd off until booting is done. - * deviced guarantees all booting script is executing. - * Last script of booting unlocks this suspend blocking state. - */ - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, - STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); - - /* Initial display state right after the booting done */ - if (is_lcdon_blocked()) - set_pm_cur_state(S_LCDOFF); - else - set_pm_cur_state(S_NORMAL); - ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state()); - if (ret < 0) - _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); - - display_set_display_ops_status(DEVICE_OPS_STATUS_START); - if (display_conf.timeout_enable) { - timeout = states[S_NORMAL].timeout; - /* check minimun lcd on time */ - if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) - timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, - STAY_CUR_STATE, timeout); - } - - } - - set_display_init_direction(display_conf.display_init_direction); - } + display_misc_set_battery_charging_status_flag(); } static void display_exit(void *data) @@ -435,7 +284,7 @@ static void display_exit(void *data) } } - exit_lcd_operation(); + display_unregister_dependent_device(); free_lock_info_list(); /* free display service */ diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 7c74c83..60bee65 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -123,14 +123,6 @@ void setup_display_plugin_backlight_ops(struct display_plugin *dp) dp->backlight = &backlight_ops; } -int init_sysfs(unsigned int flags) -{ - register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); - - return 0; -} - int exit_sysfs(void) { const struct device_ops *ops = NULL; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index ba2a191..5a40817 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -77,8 +77,6 @@ * @{ */ -extern void init_save_userlock(void); - static struct display_plugin *disp_plgn; static struct display_backlight_ops *backlight_ops; @@ -94,8 +92,6 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ - #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 2 /* 2 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ @@ -139,27 +135,7 @@ inline struct state* state_st(enum state_t state) return &states[state]; } -static void init_lcd_operation(void) -{ - const struct device_ops *ops = NULL; - - ops = find_device("display"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchkey"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchscreen"); - if (!check_default(ops)) - display_register_dependent_device(ops); -} -static void exit_lcd_operation(void) -{ - display_unregister_dependent_device(); -} enum { INIT_SETTING = 0, @@ -170,14 +146,6 @@ enum { INIT_END }; -static const char *errMSG[INIT_END] = { - [INIT_SETTING] = "setting init error", - [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error", - [INIT_POLL] = "input devices poll init error", - [INIT_FIFO] = "FIFO poll init error", - [INIT_DBUS] = "d-bus init error", -}; - static void init_display_states(void *data) { struct display_plugin *dp = (struct display_plugin *) data; @@ -188,7 +156,6 @@ static void init_display_states(void *data) * Power manager Main * */ - static int display_probe(void *data) { int ret; @@ -209,7 +176,6 @@ static int display_probe(void *data) dp->default_saving_mode = NULL; dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = NULL; - setup_display_plugin_backlight_ops(dp); /** * load display service @@ -223,132 +189,16 @@ static int display_probe(void *data) return 0; } -static int input_init_handler(void) -{ - if (!display_conf.input_support) - remove_device_by_devname("input"); - - return 0; -} static void display_init(void *data) { - int ret, i; - unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); - int timeout = 0; - - _I("Start power manager."); + int ret; /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) _W("Failed to load '%s', use default value: %d", DISPLAY_CONF_FILE, ret); - - register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background); - register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground); - register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated); - - init_save_userlock(); - - for (i = INIT_SETTING; i < INIT_END; i++) { - switch (i) { - case INIT_SETTING: - ret = init_setting(NULL); - break; - case INIT_INTERFACE: - if (display_conf.timeout_enable) - display_initialize_display_state_timeout_from_setting(); - ret = init_sysfs(flags); - break; - case INIT_POLL: - _I("input init"); - ret = input_init_handler(); - - pm_lock_detector_init(); - break; - case INIT_DBUS: - _I("Dbus init."); - ret = init_pm_dbus(); - break; - } - if (ret != 0) { - _E("Failed to init: %s", errMSG[i]); - break; - } - } - - if (i == INIT_END) { - display_ops_init(NULL); -#ifdef ENABLE_PM_LOG - pm_history_init(); -#endif - init_lcd_operation(); - display_set_initial_brightness(); - display_set_initial_battery_flag(); - display_set_initial_lockscreen_status(); - - /* In smd test, TSP should be turned off if display panel is not existed. */ - if (display_panel_get_dpms_cached_state() == -ENOENT) { - _I("Display panel is not existed."); - lcd_direct_control(DPMS_OFF, NORMAL_MODE); - exit_lcd_operation(); - } - - /* wm_ready needs to be checked - * since display manager can be launched later than deviced. - * In the case, display cannot be turned on at the first booting */ - // wm_ready = check_wm_ready(); - if (display_panel_init_dpms()) { - if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); - else - display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - } else { - display_add_timer_for_waiting_dpms_init(); - } - - if (display_conf.lcd_always_on) { - _I("LCD always on."); - display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT); - } - - if (flags & WITHOUT_STARTNOTI) { /* start without noti */ - _I("Start Power managing without noti"); - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, - HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL); - /* - * Lock lcd off until booting is done. - * deviced guarantees all booting script is executing. - * Last script of booting unlocks this suspend blocking state. - */ - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, - STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); - - /* Initial display state right after the booting done */ - if (is_lcdon_blocked()) - set_pm_cur_state(S_LCDOFF); - else - set_pm_cur_state(S_NORMAL); - ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state()); - if (ret < 0) - _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); - - display_set_display_ops_status(DEVICE_OPS_STATUS_START); - if (display_conf.timeout_enable) { - timeout = states[S_NORMAL].timeout; - /* check minimun lcd on time */ - if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) - timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, - STAY_CUR_STATE, timeout); - } - - } - - set_display_init_direction(display_conf.display_init_direction); - } } static void display_exit(void *data) @@ -382,7 +232,7 @@ static void display_exit(void *data) } } - exit_lcd_operation(); + display_unregister_dependent_device(); free_lock_info_list(); /* free display service */ diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 2db6d71..8935e77 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -107,13 +107,6 @@ void setup_display_plugin_backlight_ops(struct display_plugin *dp) dp->backlight = &backlight_ops; } -int init_sysfs(unsigned int flags) -{ - register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); - - return 0; -} - int exit_sysfs(void) { const struct device_ops *ops = NULL; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 082e87b..5b514e8 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -87,8 +87,6 @@ #define LATE_LCD_TRANSIT 1 -extern void init_save_userlock(void); - static struct display_plugin *disp_plgn; static struct display_backlight_ops *backlight_ops; @@ -115,8 +113,6 @@ static struct state states[S_END] = { { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL }, }; -#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ - #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */ #define LONG_PRESS_INTERVAL 500 /* 0.5 seconds */ #define SAMPLING_INTERVAL 1 /* 1 sec */ @@ -901,24 +897,11 @@ static void init_lcd_operation(void) { const struct device_ops *ops = NULL; - ops = find_device("display"); - if (!check_default(ops)) - display_register_dependent_device(ops); - - ops = find_device("touchscreen"); - if (!check_default(ops)) - display_register_dependent_device(ops); - ops = find_device("bezel"); if (!check_default(ops)) display_register_dependent_device(ops); } -static void exit_lcd_operation(void) -{ - display_unregister_dependent_device(); -} - enum { INIT_SETTING = 0, INIT_INTERFACE, @@ -928,14 +911,6 @@ enum { INIT_END }; -static const char *errMSG[INIT_END] = { - [INIT_SETTING] = "setting init error", - [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error", - [INIT_POLL] = "input devices poll init error", - [INIT_FIFO] = "FIFO poll init error", - [INIT_DBUS] = "d-bus init error", -}; - static void init_display_states(void *data) { struct display_plugin *dp = (struct display_plugin *) data; @@ -966,7 +941,6 @@ static int display_probe(void *data) dp->default_saving_mode = default_saving_mode; dp->is_lcdon_blocked = is_lcdon_blocked; dp->proc_change_state = default_proc_change_state; - setup_display_plugin_backlight_ops(dp); /** * load display service @@ -980,14 +954,6 @@ static int display_probe(void *data) return 0; } -static int input_init_handler(void) -{ - if (!display_conf.input_support) - remove_device_by_devname("input"); - - return 0; -} - static void sec_dsim_uevent_changed(struct udev_device *dev) { const char *devpath; @@ -1021,11 +987,8 @@ static const struct uevent_handler sec_dsim_uevent_ops = { static void display_init(void *data) { - int ret, i; + int ret; unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); - int timeout = 0; - - _I("Start power manager."); /* load configutation */ ret = display_load_config(&display_conf); @@ -1035,112 +998,12 @@ static void display_init(void *data) register_kernel_uevent_control(&sec_dsim_uevent_ops); - register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background); - register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground); - register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated); register_notifier(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, display_auto_brightness_sensing); - init_save_userlock(); - - for (i = INIT_SETTING; i < INIT_END; i++) { - switch (i) { - case INIT_SETTING: - ret = init_setting(update_setting); - break; - case INIT_INTERFACE: - if (display_conf.timeout_enable) - display_initialize_display_state_timeout_from_setting(); - ret = init_sysfs(flags); - break; - case INIT_POLL: - _I("input init"); - ret = input_init_handler(); - - pm_lock_detector_init(); - break; - case INIT_DBUS: - _I("Dbus init."); - ret = init_pm_dbus(); - break; - } - if (ret != 0) { - _E("Failed to init: %s", errMSG[i]); - break; - } - } - - if (i == INIT_END) { - display_ops_init(NULL); -#ifdef ENABLE_PM_LOG - pm_history_init(); -#endif - init_lcd_operation(); - display_misc_set_battery_charging_status_flag(); - display_set_initial_brightness(); - display_set_initial_battery_flag(); - display_set_initial_lockscreen_status(); - - /* In smd test, TSP should be turned off if display panel is not existed. */ - if (display_panel_get_dpms_cached_state() == -ENOENT) { - _I("Display panel is not existed."); - lcd_direct_control(DPMS_OFF, NORMAL_MODE); - exit_lcd_operation(); - } - - /* wm_ready needs to be checked - * since display manager can be launched later than deviced. - * In the case, display cannot be turned on at the first booting */ - // wm_ready = check_wm_ready(); - if (display_panel_init_dpms()) { - if (is_lcdon_blocked() != LCDON_BLOCK_NONE) - lcd_off_procedure(LCD_OFF_BY_EVENT); - else - lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); - } else { - display_add_timer_for_waiting_dpms_init(); - } - - if (display_conf.lcd_always_on) { - _I("LCD always on."); - display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT); - } - - if (flags & WITHOUT_STARTNOTI) { /* start without noti */ - _I("Start Power managing without noti"); - power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, - HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL); - /* - * Lock lcd off until booting is done. - * deviced guarantees all booting script is executing. - * Last script of booting unlocks this suspend blocking state. - */ - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, - STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); - - /* Initial display state right after the booting done */ - if (is_lcdon_blocked()) - set_pm_cur_state(S_LCDOFF); - else - set_pm_cur_state(S_NORMAL); - ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state()); - if (ret < 0) - _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); - - display_set_display_ops_status(DEVICE_OPS_STATUS_START); - if (display_conf.timeout_enable) { - timeout = states[S_NORMAL].timeout; - /* check minimun lcd on time */ - if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) - timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - - display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, - STAY_CUR_STATE, timeout); - } - - } - - set_display_init_direction(display_conf.display_init_direction); - } + init_setting(update_setting); + init_sysfs(flags); + init_lcd_operation(); + display_misc_set_battery_charging_status_flag(); } static void display_exit(void *data) @@ -1176,7 +1039,7 @@ static void display_exit(void *data) } } - exit_lcd_operation(); + display_unregister_dependent_device(); free_lock_info_list(); /* free display service */ diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 3fa8e72..6db9e32 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -254,10 +254,9 @@ void setup_display_plugin_backlight_ops(struct display_plugin *dp) dp->backlight = &backlight_ops; } +/* FIXME: This batterey plugin handle should be moved while battery backend separation */ int init_sysfs(unsigned int flags) { - register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); - if (battery_plgn->handle) { fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status"); if (fp_get_var_battery_status) { diff --git a/src/display/display.c b/src/display/display.c index 97e4f27..9c57d95 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -24,16 +24,21 @@ #include "core/udev.h" #include "shared/device-notifier.h" #include "shared/log.h" +#include "power/power.h" +#include "power/power-suspend.h" #include "device-interface.h" #include "display.h" #include "display-lock.h" #include "display-plugin.h" #include "display-config.h" #include "display-misc.h" +#include "display-ops.h" #include "display-signal.h" #include "display-state-transition.h" #include "lock-detector.h" +#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */ + static const struct device_ops *display_plugin_device_ops; static int pm_cur_state; static int pm_old_state; @@ -43,6 +48,8 @@ static bool g_display_hal_backend_available; static GList *display_dependent_device_ops; static enum device_ops_status display_ops_status = DEVICE_OPS_STATUS_UNINIT; +extern void init_save_userlock(void); + inline int get_pm_cur_state(void) { return pm_cur_state; @@ -437,6 +444,23 @@ static int delayed_init_done(void *data) return done; } +static void init_lcd_operation(void) +{ + const struct device_ops *ops = NULL; + + ops = find_device("display"); + if (!check_default(ops)) + display_register_dependent_device(ops); + + ops = find_device("touchkey"); + if (!check_default(ops)) + display_register_dependent_device(ops); + + ops = find_device("touchscreen"); + if (!check_default(ops)) + display_register_dependent_device(ops); +} + static int display_probe(void *data) { display_plugin_device_ops = find_device("display-plugin"); @@ -446,21 +470,133 @@ static int display_probe(void *data) return display_plugin_device_ops->probe(&g_display_plugin); } +static int input_init_handler(void) +{ + if (!g_display_plugin.config->input_support) + remove_device_by_devname("input"); + + return 0; +} + static void display_init(void *data) { + bool timeout_enable = false; + int lcd_always_on = 0; + int timeout = 0; + int ret = 0; + unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS); + if (!display_plugin_device_ops || !display_plugin_device_ops->init) return; g_unix_signal_add(SIGHUP, handle_sighup, (gpointer) SIGHUP); - register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + /* FIMXE: display config load should be put here*/ display_plugin_device_ops->init(data); register_kernel_uevent_control(&lcd_uevent_ops); + register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done); + register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background); + register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground); + register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated); display_signal_register_display_brightness_notifier(); display_misc_register_battery_health_notifier(); register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback); register_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback); + + init_save_userlock(); + + ret = init_setting(NULL); + if (ret != 0) + _W("Failed to init: setting init error"); + + display_plugin_config_get_timeout_enable(&timeout_enable); + if (timeout_enable) + display_initialize_display_state_timeout_from_setting(); + + register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed); + + _I("input init"); + ret = input_init_handler(); + pm_lock_detector_init(); + if (ret != 0) + _W("Failed to init: input devices poll init error"); + + _I("Dbus init."); + ret = init_pm_dbus(); + if (ret != 0) + _W("Failed to init: dbus initialization error"); + + display_ops_init(NULL); +#ifdef ENABLE_PM_LOG + pm_history_init(); +#endif + init_lcd_operation(); + display_set_initial_brightness(); + display_set_initial_battery_flag(); + display_set_initial_lockscreen_status(); + + /* In smd test, TSP should be turned off if display panel is not existed. */ + if (display_panel_get_dpms_cached_state() == -ENOENT) { + _I("Display panel is not existed."); + lcd_direct_control(DPMS_OFF, NORMAL_MODE); + display_unregister_dependent_device(); + } + + /* wm_ready needs to be checked + * since display manager can be launched later than deviced. + * In the case, display cannot be turned on at the first booting */ + // wm_ready = check_wm_ready(); + if (display_panel_init_dpms()) { + if (display_plugin_is_lcd_on_blocked() != LCDON_BLOCK_NONE) { + display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT); + } else { + display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT); + } + } else { + display_add_timer_for_waiting_dpms_init(); + } + + display_plugin_config_get_lcd_always_on(&lcd_always_on); + if (lcd_always_on) { + _I("LCD always on."); + display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT); + } + + if (flags & WITHOUT_STARTNOTI) { /* start without noti */ + _I("Start Power managing without noti"); + power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, + HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL); + /* + * Lock lcd off until booting is done. + * deviced guarantees all booting script is executing. + * Last script of booting unlocks this suspend blocking state. + */ + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, + STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); + + /* Initial display state right after the booting done */ + if (display_plugin_is_lcd_on_blocked()) + set_pm_cur_state(S_LCDOFF); + else + set_pm_cur_state(S_NORMAL); + ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state()); + if (ret < 0) + _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno()); + + display_set_display_ops_status(DEVICE_OPS_STATUS_START); + if (timeout_enable) { + display_plugin_state_get_timeout(S_NORMAL, &timeout); + /* check minimun lcd on time */ + if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) { + timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); + } + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + STAY_CUR_STATE, timeout); + } + } + + set_display_init_direction(g_display_plugin.config->display_init_direction); } static void display_exit(void *data) -- 2.7.4