From: Youngjae Cho Date: Wed, 17 Apr 2024 12:03:55 +0000 (+0900) Subject: display: Add exclusive dim timeout X-Git-Tag: accepted/tizen/8.0/unified/20240524.142351~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6338f7f4691a77ea3363f9ecaafd0f61aaf619e;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Add exclusive dim timeout Timeout for dim had always been derived from screen timeout in a ratio LCD_DIM_TIMEOUT, which is 30% of total screen timeout, naturally in turn, the remaining 70% is given to normal timeout. Introduced a new timeout, exclusive dim timeout, that fixes dim timeout by itself. It is -1 by default, meaning disabled. If it is nonnegative value, dim timeout is fixed to the value regardless of the screen timeout. In such case, as dim timeout doesn't share screen timeout, normal timeout consumes the entire screen timeout as a result. The exclusive dim timeout is controlled by vconf 'db/setting/timeout_dim' and it takes time in second. For example, 1. db/setting/lcd_backlight_normal = 15 db/setting/timeout_dim = -1 => Normal(10.5s) + Dim(4.5s) : Work as before. The screen timeout is splitted into 7:3, normal state consumes 10.5s and dim state 4.5s. 2. db/setting/lcd_backlight_normal = 15 db/setting/timeout_dim = 5 => Normal(15s) + Dim(5s) : The exclusive dim timeout is 5s. The screen timeout, 15s, is not given to dim state. Therefore normal state solely consumes the entire 15s. After consuming up its 15s, it changes state to dim and the dim starts consuming its exclusive timeout, 5s. 3. db/setting/lcd_backlight_normal = 15 db/setting/timeout_dim = 0 => Normal(15s) + Dim(0s) : Same as above except that the exclusive dim timeout is 0s. It effectively skips dim state. Change-Id: Id345c7a8cae21c3dd56208185109ee738dccd909 Signed-off-by: Youngjae Cho --- diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b83d3993..508ffe91 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -51,6 +51,7 @@ #include "poll.h" #include "lock-detector.h" #include "display-ops.h" +#include "setting.h" #include "shared/devices.h" #include "shared/device-notifier.h" #include "core/udev.h" @@ -888,6 +889,11 @@ static int update_setting(int key_idx, int val) display_backlight_set_custom_status(false); break; + case SETTING_EXCLUSIVE_DIM_TIMEOUT: + set_exclusive_dim_timeout(val); + display_state_transition_update_display_state_timeout_by_priority(); + break; + default: return -1; } diff --git a/src/display/setting.c b/src/display/setting.c index 8bf4bde7..04a31aa1 100644 --- a/src/display/setting.c +++ b/src/display/setting.c @@ -35,6 +35,7 @@ #include "shared/eventsystem.h" #include "shared/plugin.h" +#define EXCLUSIVE_DIM_TIMEOUT_UNSET (-1) #define LCD_DIM_RATIO 0.3 #define LCD_MAX_DIM_TIMEOUT 7000 #define LCD_MIN_DIM_TIMEOUT 500 @@ -44,6 +45,7 @@ static const char *setting_keys[SETTING_GET_END] = { [SETTING_BRT_LEVEL] = VCONFKEY_SETAPPL_LCD_BRIGHTNESS, [SETTING_LOCK_SCREEN] = VCONFKEY_IDLE_LOCK_STATE, [SETTING_POWER_CUSTOM_BRIGHTNESS] = VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, + [SETTING_EXCLUSIVE_DIM_TIMEOUT] = VCONFKEY_SETAPPL_TIMEOUT_DIM, }; static struct display_plugin *disp_plgn; @@ -53,6 +55,7 @@ static int force_lcdtimeout = 0; static int custom_on_timeout = 0; static int custom_normal_timeout = 0; static int custom_dim_timeout = 0; +static int exclusive_dim_timeout = EXCLUSIVE_DIM_TIMEOUT_UNSET; int (*update_pm_setting) (int key_idx, int val); @@ -77,6 +80,16 @@ static gboolean display_state_send_system_event(gpointer data) return G_SOURCE_REMOVE; } +int set_exclusive_dim_timeout(int timeout) +{ + if (timeout < 0) + exclusive_dim_timeout = EXCLUSIVE_DIM_TIMEOUT_UNSET; + else + exclusive_dim_timeout = SEC_TO_MSEC(timeout); + + return 0; +} + int set_force_lcdtimeout(int timeout) { if (timeout < 0) @@ -148,6 +161,10 @@ void get_dim_timeout(int *dim_timeout) int vconf_timeout, on_timeout, val, ret; assert(g_display_plugin.config); + if (exclusive_dim_timeout != EXCLUSIVE_DIM_TIMEOUT_UNSET) { + *dim_timeout = exclusive_dim_timeout; + return; + } if (custom_dim_timeout > 0) { *dim_timeout = custom_dim_timeout; @@ -186,6 +203,13 @@ void get_run_timeout(int *timeout) if (custom_normal_timeout > 0) { *timeout = custom_normal_timeout; + /** + * The exclusive_dim_timeout doesn't share timeout with custom_normal_timeout + * in LCD_DIM_RATIO, but only consumes fixed time allocated to it. + * Therefore feed the custom_dim_timeout back to the custom_normal_timeout. + */ + if (exclusive_dim_timeout != EXCLUSIVE_DIM_TIMEOUT_UNSET) + *timeout += custom_dim_timeout; return; } @@ -205,6 +229,11 @@ void get_run_timeout(int *timeout) return; } + if (exclusive_dim_timeout != EXCLUSIVE_DIM_TIMEOUT_UNSET) { + *timeout = on_timeout; + return; + } + get_dim_timeout(&dim_timeout); *timeout = on_timeout - dim_timeout; } @@ -344,6 +373,10 @@ int display_setting_update_pm_setting(int key_idx, int val) display_backlight_set_custom_status(false); break; + case SETTING_EXCLUSIVE_DIM_TIMEOUT: + set_exclusive_dim_timeout(val); + display_state_transition_update_display_state_timeout_by_priority(); + default: return -1; } @@ -384,6 +417,12 @@ int exit_setting(void) static void __CONSTRUCTOR__ initialize(void) { + int ret; + + ret = vconf_get_int(VCONFKEY_SETAPPL_TIMEOUT_DIM, &exclusive_dim_timeout); + if (ret < 0 || exclusive_dim_timeout < 0) + exclusive_dim_timeout = EXCLUSIVE_DIM_TIMEOUT_UNSET; + disp_plgn = get_var_display_plugin(); if (!disp_plgn) { _E("Failed to get display plugin variable."); diff --git a/src/display/setting.h b/src/display/setting.h index e8e5ab75..39bf8b36 100644 --- a/src/display/setting.h +++ b/src/display/setting.h @@ -37,6 +37,7 @@ enum { SETTING_BRT_LEVEL, SETTING_LOCK_SCREEN, SETTING_POWER_CUSTOM_BRIGHTNESS, + SETTING_EXCLUSIVE_DIM_TIMEOUT, SETTING_GET_END, SETTING_PM_STATE = SETTING_GET_END, SETTING_LOW_BATT, @@ -48,6 +49,7 @@ enum { int display_setting_update_pm_setting(int key_idx, int val); +int set_exclusive_dim_timeout(int timeout); int set_force_lcdtimeout(int timeout); int get_setting_brightness(int *level);