From: Yunhee Seo Date: Tue, 27 Jun 2023 07:30:45 +0000 (+0900) Subject: display: Remove check_seed_status() X-Git-Tag: accepted/tizen/unified/dev/20230726.115933~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=237c137c630e6738239b52c4adfd8b61eea03a0d;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Remove check_seed_status() The check_seed_status() name and role is unclear. Thus it is removed and devided to 3 funcs. These functions are added to display core. - void display_set_initial_brightness(void); -> It checks default brightness and set initial brightness value. - void display_set_initial_battery_flag(void); -> It checks battery status and set battery status to pm_status_flag. - void display_set_initial_lockscreen_status(void); -> It checks lockscreen state and set initial lockscreen timeout value. To relocate these, this function is added to display-plugin. - int display_plugin_config_get_pm_default_brightness(int *pm_default_brightness); Change-Id: Ia1be19b5c0d5643e42c5c56a5b8df9483d25ad9b Signed-off-by: Yunhee Seo --- diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index adf5192..bbc1382 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -172,59 +172,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static void check_seed_status(void) -{ - int ret = -1; - int tmp = 0; - int bat_state; - int brt = 0; - int lock_state; - int lock_screen_timeout = 0; - - ret = get_setting_brightness(&tmp); - if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) { - _I("Failed to read vconf value for brightness."); - brt = display_conf.pm_default_brightness; - if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) { - ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt); - if (ret < 0) - _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); - } - tmp = brt; - } - _I("Set brightness(%d) from setting app.", tmp); - display_backlight_set_default_brightness(tmp); - display_backlight_set_brightness(tmp); - - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - } - - /* lock screen check */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0) { - lock_state = -1; - _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" - " for lock screen.", lock_screen_timeout); - } - - return; -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -440,7 +387,9 @@ static void display_init(void *data) pm_history_init(); #endif init_lcd_operation(); - check_seed_status(); + 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) { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 7cca5d8..49e0db2 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -230,61 +230,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static void check_seed_status(void) -{ - int ret = -1; - int tmp = 0; - int bat_state; - int brt = 0; - int lock_state; - int lock_screen_timeout = 0; - - display_misc_set_battery_charging_status_flag(); - - ret = get_setting_brightness(&tmp); - if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) { - _I("Failed to read vconf value for brightness."); - brt = display_conf.pm_default_brightness; - if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) { - ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt); - if (ret < 0) - _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); - } - tmp = brt; - } - _I("Set brightness(%d) from setting app.", tmp); - display_backlight_set_default_brightness(tmp); - display_backlight_set_brightness(tmp); - - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - } - - /* lock screen check */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0) { - lock_state = -1; - _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" - " for lock screen.", lock_screen_timeout); - } - - return; -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -496,7 +441,10 @@ static void display_init(void *data) pm_history_init(); #endif init_lcd_operation(); - check_seed_status(); + 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) { diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 3badf8d..635e3f3 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -172,59 +172,6 @@ static void sig_hup(int signo) pm_save_logdump(); } -static void check_seed_status(void) -{ - int ret = -1; - int tmp = 0; - int bat_state; - int brt = 0; - int lock_state; - int lock_screen_timeout = 0; - - ret = get_setting_brightness(&tmp); - if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) { - _I("Failed to read vconf value for brightness."); - brt = display_conf.pm_default_brightness; - if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) { - ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt); - if (ret < 0) - _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); - } - tmp = brt; - } - _I("Set brightness(%d) from setting app.", tmp); - display_backlight_set_default_brightness(tmp); - display_backlight_set_brightness(tmp); - - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) { - display_set_power_save_mode_flag(true); - set_pm_status_flag(LOWBT_FLAG); - } - } - - /* lock screen check */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0) { - lock_state = -1; - _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" - " for lock screen.", lock_screen_timeout); - } - - return; -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -437,7 +384,9 @@ static void display_init(void *data) pm_history_init(); #endif init_lcd_operation(); - check_seed_status(); + 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) { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 6dfa725..5e03f28 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -940,61 +940,6 @@ static int update_setting(int key_idx, int val) return 0; } -static void check_seed_status(void) -{ - int ret = -1; - int tmp = 0; - int bat_state; - int brt = 0; - int lock_state; - int lock_screen_timeout = 0; - - display_misc_set_battery_charging_status_flag(); - - ret = get_setting_brightness(&tmp); - if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) { - _I("Failed to read vconf value for brightness."); - brt = display_conf.pm_default_brightness; - if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) { - ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt); - if (ret < 0) - _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); - } - tmp = brt; - } - _I("Set brightness(%d) from setting app.", tmp); - display_backlight_set_default_brightness(tmp); - display_backlight_set_brightness(tmp); - - ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state); - if (ret < 0) { - bat_state = VCONFKEY_SYSMAN_BAT_NORMAL; - _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); - } - if (display_misc_is_low_battery_state(bat_state)) { - if (!(get_pm_status_flag() & CHRGR_FLAG)) { - default_saving_mode(true); - set_pm_status_flag(LOWBT_FLAG); - } - } - - /* lock screen check */ - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); - if (ret < 0) { - lock_state = -1; - _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" - " for lock screen.", lock_screen_timeout); - } - - return; -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -1239,7 +1184,10 @@ static void display_init(void *data) pm_history_init(); #endif init_lcd_operation(); - check_seed_status(); + 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) { diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index cd74cee..06426d9 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -362,6 +362,19 @@ int display_plugin_config_get_dimming(int *dimming) return -EOPNOTSUPP; } +int display_plugin_config_get_pm_default_brightness(int *pm_default_brightness) +{ + if (!pm_default_brightness) + return -EINVAL; + + if (!g_display_plugin.config) + return -EOPNOTSUPP; + + *pm_default_brightness = g_display_plugin.config->pm_default_brightness; + + return 0; +} + 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 c61a156..728e01f 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -127,5 +127,6 @@ 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); +int display_plugin_config_get_pm_default_brightness(int *pm_default_brightness); #endif //__DISPLAY_PLUGIN_H__ diff --git a/src/display/display.c b/src/display/display.c index ca65e89..3282a7f 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -303,6 +303,67 @@ void display_add_timer_for_waiting_dpms_init(void) _E("Failed to add display_panel_init_dpms timeout."); } +void display_set_initial_brightness(void) +{ + int ret = -1; + int brightness = 0; + int default_brightness = 0; + + ret = get_setting_brightness(&brightness); + if (ret != 0 || (brightness < PM_MIN_BRIGHTNESS || brightness > PM_MAX_BRIGHTNESS)) { + _I("Failed to read vconf value for brightness."); + display_plugin_config_get_pm_default_brightness(&default_brightness); + if (brightness < PM_MIN_BRIGHTNESS || brightness > PM_MAX_BRIGHTNESS) { + ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, default_brightness); + if (ret < 0) + _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno()); + } + brightness = default_brightness; + } + _I("Set brightness(%d) from setting app.", brightness); + display_backlight_set_default_brightness(brightness); + display_backlight_set_brightness(brightness); +} + +/* FIXME: This function should be moved to battery module after battery plguin/module refactoring */ +void display_set_initial_battery_flag(void) +{ + int ret = -1; + int battery_state = 0; + + ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &battery_state); + if (ret < 0) { + battery_state = VCONFKEY_SYSMAN_BAT_NORMAL; + _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno()); + } + + if (display_misc_is_low_battery_state(battery_state)) { + if (!(get_pm_status_flag() & CHRGR_FLAG)) { + display_set_power_save_mode_flag(true); + set_pm_status_flag(LOWBT_FLAG); + } + } +} + +void display_set_initial_lockscreen_status(void) +{ + int ret = -1; + int lock_state = 0; + int lock_screen_timeout = 0; + + ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state); + if (ret < 0) { + lock_state = -1; + _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) { + display_plugin_state_set_timeout(S_NORMAL, lock_screen_timeout); + _I("LCD NORMAL timeout(%d ms) is set for lock screen.", lock_screen_timeout); + } +} + static int display_probe(void *data) { display_plugin_device_ops = find_device("display-plugin"); diff --git a/src/display/display.h b/src/display/display.h index ce9793e..48c7d35 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -62,5 +62,8 @@ void display_set_display_ops_status(enum device_ops_status dev_ops_status); int display_get_display_ops_status(enum device_ops_status *dev_ops_status); void display_set_power_save_mode_flag(int onoff); void display_add_timer_for_waiting_dpms_init(void); +void display_set_initial_brightness(void); +void display_set_initial_battery_flag(void); +void display_set_initial_lockscreen_status(void); #endif //__DISPLAY_H__