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)