video: pwm_backlight: support PWM polarity setting
The latest kernel PWM drivers enable the polarity settings. When system run from U-Boot to kerenl, if there are differences in polarity set or duty cycle, the PMW will re-init: close -> set polarity and duty cycle -> enable the PWM. The pwm_backlight would be unstable, might be screen flashing. Change-Id: I7c026c9756e013f0ac99e43b09b633dc83268ce9 Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
parent
bab0c55c3c
commit
f462f55341
|
|
@ -20,6 +20,7 @@ struct pwm_backlight_priv {
|
||||||
struct udevice *pwm;
|
struct udevice *pwm;
|
||||||
uint channel;
|
uint channel;
|
||||||
uint period_ns;
|
uint period_ns;
|
||||||
|
bool polarity;
|
||||||
uint default_level;
|
uint default_level;
|
||||||
uint min_level;
|
uint min_level;
|
||||||
uint max_level;
|
uint max_level;
|
||||||
|
|
@ -45,6 +46,12 @@ static int pwm_backlight_enable(struct udevice *dev)
|
||||||
mdelay(120);
|
mdelay(120);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = pwm_set_invert(priv->pwm, priv->channel, priv->polarity);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to invert PWM\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
duty_cycle = priv->period_ns * (priv->default_level - priv->min_level) /
|
duty_cycle = priv->period_ns * (priv->default_level - priv->min_level) /
|
||||||
(priv->max_level - priv->min_level + 1);
|
(priv->max_level - priv->min_level + 1);
|
||||||
ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
|
ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
|
||||||
|
|
@ -136,6 +143,7 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
|
||||||
}
|
}
|
||||||
priv->channel = args.args[0];
|
priv->channel = args.args[0];
|
||||||
priv->period_ns = args.args[1];
|
priv->period_ns = args.args[1];
|
||||||
|
priv->polarity = args.args[2];
|
||||||
|
|
||||||
index = dev_read_u32_default(dev, "default-brightness-level", 255);
|
index = dev_read_u32_default(dev, "default-brightness-level", 255);
|
||||||
cell = dev_read_prop(dev, "brightness-levels", &len);
|
cell = dev_read_prop(dev, "brightness-levels", &len);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue