Modify powersaving within the touchscreen_start() 13/223313/9
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 28 Jan 2020 11:15:51 +0000 (20:15 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 30 Jan 2020 09:37:32 +0000 (18:37 +0900)
Change-Id: I979e67d4d0caeb2095ee1e2014c368c4a009d291
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/touchscreen/touchscreen.c

index ac0175e..23b4090 100644 (file)
@@ -175,12 +175,27 @@ static int touchscreen_execute(void *data)
 
 static int touchscreen_start(enum device_flags flags)
 {
+       int state, ret;
+
        if (touchscreen_enable != DEVICE_OPS_STATUS_START)
                return 0;
 
-       touchscreen_powersaving(POWERSAVING_OFF);
+       if (!_backlight_ops || !_backlight_ops->get_lcd_power)
+               return -ENOTSUP;
+
+       /*
+        * It is safe to turn touchscreen on before powersaving on/off.
+        */
+       ret = touchscreen_set_state(TOUCHSCREEN_ON);
 
-       return touchscreen_set_state(TOUCHSCREEN_ON);
+       state = _backlight_ops->get_lcd_power();
+
+       if (state == DPMS_OFF)
+               touchscreen_powersaving(POWERSAVING_ON);
+       else
+               touchscreen_powersaving(POWERSAVING_OFF);
+
+       return ret;
 }
 
 static int touchscreen_stop(enum device_flags flags)