summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungjae Cho <y0.cho@samsung.com>2020-07-02 14:04:29 +0900
committerYoungjae Cho <y0.cho@samsung.com>2020-07-03 10:40:46 +0900
commit33e9f23e7a03fd55803ba16a41ba2a05ef4c1e8d (patch)
tree1bd6e19c65971a60939a89ff0c3b558f75eca388
parent98a88baede0742695f3124107b8eb1e789c5cebc (diff)
downloaddeviced-33e9f23e7a03fd55803ba16a41ba2a05ef4c1e8d.tar.gz
deviced-33e9f23e7a03fd55803ba16a41ba2a05ef4c1e8d.tar.bz2
deviced-33e9f23e7a03fd55803ba16a41ba2a05ef4c1e8d.zip
Fix brightness control on turning on lcd from AOD
Move restoring default brightness to display-handler.c /* LCDON from AOD */ if (old_level != default_brightness) change_brightness_transit(old_level, default_brightness); Before this patch, auto_brightenss_control() changes brightness on receiving SPECIFIC_MODE_OFF(0) even when someone holds brightness. As originally intended, if someone is holding brightness, that brightness must be maintained even if SPECIFIC_MODE_OFF comes. But the code which was added in consideration of the AOD state also worked in hold state, changing brightness unintentionally. The code restoring default brightness moved to display-handler.c which is in charge of LCDON and AOD. By doing this, auto_brightness_control() is now only works within LCDON state, no need to care about other than LCDON states. Change-Id: I067b93bfede7e745e631719eea17a3d4c53aa292 Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
-rw-r--r--plugins/wearable/display/auto-brightness-sensorhub.c20
-rw-r--r--plugins/wearable/display/display-handler.c50
2 files changed, 42 insertions, 28 deletions
diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c
index a1ae4e94..b3aac8bb 100644
--- a/plugins/wearable/display/auto-brightness-sensorhub.c
+++ b/plugins/wearable/display/auto-brightness-sensorhub.c
@@ -46,9 +46,6 @@ static void change_brightness_transit(int start, int end)
static void set_brightness_level(int level)
{
- int old_level = 0;
- int default_brightness;
-
if (pm_cur_state != S_NORMAL)
return;
/*
@@ -63,9 +60,6 @@ static void set_brightness_level(int level)
return;
}
- backlight_ops.get_brightness(&old_level);
- default_brightness = backlight_ops.get_default_brt();
-
switch (level) {
case LBM_LEVEL:
/*
@@ -88,15 +82,15 @@ static void set_brightness_level(int level)
break;
case SPECIFIC_MODE_OFF:
/*
- * received HBM disable
- * unset hbm state and change brightness to setting value
+ * Disable LBM or HBM.
+ * If the flag hold is set when disabling LBM, brightness remains
+ * held brightness. (FYI. HBM and Hold cannot be both enabled, so
+ * no need to consider hold flag when disabling HBM)
+ * Otherwise, brightness changes to default or dim brightness
+ * depending on flag lowdim.
*/
auto_brightness_control(BR_HBM_OFF, BR_IMPLICIT);
auto_brightness_control(BR_LBM_OFF, BR_IMPLICIT);
-
- /* LCDON from AOD */
- if (old_level != default_brightness)
- change_brightness_transit(old_level, default_brightness);
break;
default:
/*
@@ -110,8 +104,6 @@ static void set_brightness_level(int level)
auto_brightness_control(BR_SET_BRIGHTNESS, level);
break;
}
-
- device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
}
static void set_default_brightness(void)
diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c
index 281b6ced..67636b36 100644
--- a/plugins/wearable/display/display-handler.c
+++ b/plugins/wearable/display/display-handler.c
@@ -44,20 +44,27 @@ enum charging_lcd_state {
};
static guint autobrt_timer;
-static bool lcdon_from_aod;
static int autobrtlevel;
-static gboolean display_autobrt_changed(gpointer data)
-{
+static bool aod_clock_displayed; /* True while AOD screen is displayed */
+static gboolean lcdon_from_aod_cb(gpointer data)
+{
int level = (int) data;
autobrt_timer = 0;
+ backlight_ops.transit_state(DPMS_ON);
display_info.set_brightness_level(level);
+ /* lcdon is completed, aod disappered */
+ aod_clock_displayed = false;
+
return G_SOURCE_REMOVE;
}
+/* For AOD state, there is race condition between
+ * HomeScreen dbus signal and AutoBrightnessChanged dbus method call.
+ * Cannot decide which one arrives first */
static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn,
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
@@ -74,18 +81,22 @@ static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn,
}
if (display_info.set_brightness_level) {
- if (autobrt_timer)
+ if (autobrt_timer) {
g_source_remove(autobrt_timer);
+ autobrt_timer = 0;
+ }
+
+ device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
/* When display state changes from AOD to LCDON, brightness change
* effect seems sluggish because of heavy load of jobs for turning on
* display. So delay this brightness change a bit to avoid this
* heavy loaded time and therefore make it change smoothly. */
- if (lcdon_from_aod) {
- autobrtlevel = level;
- autobrt_timer = g_timeout_add(200, display_autobrt_changed, (gpointer)level);
- } else {
- display_autobrt_changed((gpointer)level);
+ if (aod_clock_displayed) {
+ autobrtlevel = level; /* reserve the level, defer applying */
+ autobrt_timer = g_timeout_add(200, lcdon_from_aod_cb, (gpointer)level);
+ } else { /* S_NORMAL state or LCDON from usual OFF state, not from AOD */
+ display_info.set_brightness_level(level);
}
} else {
ret = -ENOTSUP;
@@ -118,13 +129,24 @@ static void aod_change_signal(GDBusConnection *conn,
/* clock-viewer send "clockchanged" as signal parameter when AOD->LCDON.
* On catching this signal, do change brightness immediately. */
if (!strcmp(screen, CLOCK_CHANGED)) {
- lcdon_from_aod = false;
- if (autobrt_timer) {
+ /* aod_clock_displayed can be false if this clockchanged siganl arrives after 200ms timeout.
+ * In this situation, there is noting to do because all the
+ * brightness-related task, which should have been done in this routine,
+ * have been performed by timeout callback, lcdon_from_aod_cb(). */
+ if (!aod_clock_displayed)
+ return;
+
+ backlight_ops.transit_state(DPMS_ON);
+ if (autobrt_timer) { /* if there is reserved level, apply it */
g_source_remove(autobrt_timer);
- display_autobrt_changed((gpointer)autobrtlevel);
+ autobrt_timer = 0;
+ display_info.set_brightness_level(autobrtlevel);
}
+ /* lcdon is completed, aod disappered */
+ aod_clock_displayed = false;
} else if (!strcmp(screen, CLOCK_END)) {
- lcdon_from_aod = true;
+ /* lcdoff is completed, aod showed up */
+ aod_clock_displayed = true;
}
out:
@@ -168,7 +190,7 @@ static void display_handler_init(void *data)
prepare_level_handler();
register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed);
- lcdon_from_aod = false;
+ aod_clock_displayed = false;
ret = subscribe_dbus_signal(NULL,
DEVICED_OBJECT_PATH,
DEVICED_INTERFACE_NAME,