From 4e1b763e5054c50a234edafedcc47119aa3e75dd Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 10 Mar 2020 18:02:20 +0900 Subject: [PATCH] Introduce 3 level AOD brightness Change-Id: Iae0ca878f7702e72cccf9ff54f26da59e3b3e78e Signed-off-by: Youngjae Cho --- plugins/wearable/display/device-interface.c | 41 ++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) mode change 100644 => 100755 plugins/wearable/display/device-interface.c diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c old mode 100644 new mode 100755 index eb6414d..b03e5c4 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -43,6 +43,7 @@ #include "device-node.h" #include "display/display-dpms.h" #include "battery-monitor.h" +#include "battery/power-supply.h" #define SET_SUSPEND_TIME 0.5 @@ -89,6 +90,9 @@ static bool vital_sleep; static int dpms_running_state = DPMS_SETTING_DONE; static struct display_device *display_dev; static guint release_timer; +static int aod_max_level = -1; +static int aod_normal_level = -1; +static int aod_min_level = -1; struct display_device *display_dev_get(void) { @@ -808,12 +812,23 @@ static int backlight_transit_state(int state) { int brt, val; int start, end; + static int aod_brightness_level; backlight_ops.get_brightness(&brt); if (state == DPMS_OFF) { start = brt; - end = display_conf.aod_enter_level; + + /* There are three levels of AOD brightness: max, normal, min brightness. + * At first, AOD brightness is set to normal level when charger is connected, + * otherwise set to max. And then, if the current brightness is lower than this + * initialized AOD brightness, set AOD brightness to min level brightness. */ + if (battery.online_type && aod_normal_level > 0) + aod_brightness_level = aod_normal_level; + else if (aod_max_level > 0) + aod_brightness_level = aod_max_level; + else + aod_brightness_level = display_conf.aod_enter_level; /* * The value of backlight_ops.get_brightness is system brightness. @@ -822,18 +837,24 @@ static int backlight_transit_state(int state) */ get_brightness(&val); - if (val > display_conf.aod_enter_level) - backlight_ops.transit_brt(start, end, display_conf.brightness_change_step); + if ((val < aod_brightness_level) && (aod_min_level > 0)) + aod_brightness_level = aod_min_level; + + if (val > aod_brightness_level) { + _D("backlight transit start %d end %d DPMS OFF", start, aod_brightness_level); + backlight_ops.transit_brt(start, aod_brightness_level, display_conf.brightness_change_step); + } } else { /* prevent transit effect when another effect is already executed */ - if (brt != display_conf.aod_enter_level) { + if (brt != aod_brightness_level) { _W("effect is already executed brt(%d) aod_level(%d)", - brt, display_conf.aod_enter_level); + brt, aod_brightness_level); return 0; } - start = display_conf.aod_enter_level; + start = aod_brightness_level; end = default_brightness; + _D("backlight transit start %d end %d DPMS ON", start, end); backlight_ops.transit_brt(start, end, display_conf.brightness_change_step); } @@ -965,7 +986,15 @@ int display_service_load(void) return -EPERM; } + if (display_dev && display_dev->get_aod_brightness) { + r = display_dev->get_aod_brightness(&aod_max_level, &aod_normal_level, &aod_min_level); + if (r == 0) { + _I("Use various AOD brightness : max %d, normal %d, min %d", aod_max_level, aod_normal_level, aod_min_level); + } + } + _D("Display device structure load success."); + return 0; } -- 2.7.4