@@ -642,17 +642,50 @@ static int ld9040_power(struct ld9040 *lcd, int power)
return ret;
}
+static int ld9040_early_set_power(struct lcd_device *ld, int power)
+{
+ struct ld9040 *lcd = lcd_get_data(ld);
+ int ret = 0;
+
+ if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN &&
+ power != FB_BLANK_NORMAL) {
+ dev_err(lcd->dev, "power value should be 0, 1 or 4.\n");
+
+ return -EINVAL;
+ }
+
+ if (!power_is_on(power) && power_is_on(lcd->power)) {
+ ret = ld9040_power(lcd, power);
+ if (!ret)
+ lcd->power = power;
+ }
+
+ return ret;
+}
+
static int ld9040_set_power(struct lcd_device *ld, int power)
{
struct ld9040 *lcd = lcd_get_data(ld);
+ struct backlight_device *bd = lcd->bd;
+ int ret = 0;
if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN &&
power != FB_BLANK_NORMAL) {
dev_err(lcd->dev, "power value should be 0, 1 or 4.\n");
+
return -EINVAL;
}
- return ld9040_power(lcd, power);
+ if (power_is_on(power) && !power_is_on(lcd->power)) {
+ ret = ld9040_power(lcd, power);
+ if (!ret)
+ lcd->power = power;
+
+ ld9040_gamma_ctl(lcd, bd->props.brightness);
+ } else
+ ld9040_early_set_power(ld, power);
+
+ return ret;
}
static int ld9040_get_power(struct lcd_device *ld)
@@ -689,6 +722,7 @@ static int ld9040_set_brightness(struct backlight_device *bd)
}
static struct lcd_ops ld9040_lcd_ops = {
+ .early_set_power = ld9040_early_set_power,
.set_power = ld9040_set_power,
.get_power = ld9040_get_power,
};