display: Add exclusive dim timeout 66/309866/7 accepted/tizen/7.0/unified/20240419.171523
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 17 Apr 2024 12:03:55 +0000 (21:03 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 18 Apr 2024 04:48:52 +0000 (13:48 +0900)
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 <y0.cho@samsung.com>
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/setting.c
src/display/setting.h

index 3ba41ae820a433c69056118577058579e0371b1a..eae64f0fa804fae48613d5bfc090bb7a99ead49c 100644 (file)
@@ -1723,6 +1723,11 @@ static int update_setting(int key_idx, int val)
                        backlight_ops->set_custom_status(false);
                break;
 
+       case SETTING_EXCLUSIVE_DIM_TIMEOUT:
+               set_exclusive_dim_timeout(val);
+               update_display_time();
+               break;
+
        default:
                return -1;
        }
index 57d782a4a69221b18f4e0d7977078e097108c749..c173b5daa95cdb00b70b6bed2b8da0b1589f34db 100644 (file)
@@ -1738,6 +1738,11 @@ static int update_setting(int key_idx, int val)
                        backlight_ops->set_custom_status(false);
                break;
 
+       case SETTING_EXCLUSIVE_DIM_TIMEOUT:
+               set_exclusive_dim_timeout(val);
+               update_display_time();
+               break;
+
        default:
                return -1;
        }
index 9d8ff089be48f6632ab3e35b72890f3fb676494f..c99c49ffb0045e6ff588dc35a6fcfaf6a13cde9c 100644 (file)
@@ -1723,6 +1723,11 @@ static int update_setting(int key_idx, int val)
                        backlight_ops->set_custom_status(false);
                break;
 
+       case SETTING_EXCLUSIVE_DIM_TIMEOUT:
+               set_exclusive_dim_timeout(val);
+               update_display_time();
+               break;
+
        default:
                return -1;
        }
index 957893b379925ccaeea4586e329dcb1d585696bd..a707dc0de9dc4f78b64498b895c6b8ff9468f3b0 100644 (file)
@@ -1990,6 +1990,11 @@ static int update_setting(int key_idx, int val)
                        backlight_ops->set_custom_status(false);
                break;
 
+       case SETTING_EXCLUSIVE_DIM_TIMEOUT:
+               set_exclusive_dim_timeout(val);
+               update_display_time();
+               break;
+
        default:
                return -1;
        }
index cc695ff1b91884e681352343b6abbf1a9db2771c..0e01e684c859c301d4f20cc459d8c6bb435746e9 100644 (file)
@@ -30,6 +30,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
@@ -39,6 +40,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;
@@ -48,6 +50,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;
 static const struct display_config *display_conf;
 
 int (*update_pm_setting) (int key_idx, int val);
@@ -73,6 +76,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)
@@ -143,6 +156,11 @@ void get_dim_timeout(int *dim_timeout)
 {
        int vconf_timeout, on_timeout, val, ret;
 
+       if (exclusive_dim_timeout != EXCLUSIVE_DIM_TIMEOUT_UNSET) {
+               *dim_timeout = exclusive_dim_timeout;
+               return;
+       }
+
        if (custom_dim_timeout > 0) {
                *dim_timeout = custom_dim_timeout;
                return;
@@ -180,6 +198,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;
        }
 
@@ -199,6 +224,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;
 }
@@ -278,6 +308,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.");
index 284fb6223d94d6b3dc9d79d601c8103dfe09176a..94bf24b941a7aaabfcc976740a24b73cc33a56e2 100644 (file)
@@ -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,
@@ -49,6 +50,7 @@ enum {
 
 extern int (*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);