Skip to content

Commit

Permalink
video: backlight: pwm-backlight: add a forced display hold off time o…
Browse files Browse the repository at this point in the history
…ption

Add a possibility to force a display/backlight to be switched off for
a specified time. This is useful for displays which go nuts when the
off time is to short or the power-on sequence is not as expected.

Signed-off-by: Peter Fink <pfink@christ-es.de>
  • Loading branch information
pfink-christ committed Mar 4, 2020
1 parent 11d1645 commit 01e56b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Optional properties:
- pwm-off-delay-ms: Delay in ms between disabling the backlight using GPIO
(and setting PWM value to 0 at the same time) and
switching off the enable-display-gpio.
- display-hold-off-ms: Time in ms which the display enable gpio is forced off
even if the backlight is switched on immediately after
it has been turned off. This can be used if the
display is not able to cope with fast on-off-on cycles.
- brightness-levels: Array of distinct brightness levels. Typically these
are in the range from 0 to 255, but any range starting at
0 will do. The actual brightness level (PWM duty cycle)
Expand Down Expand Up @@ -52,6 +56,7 @@ Example:
enable-backlight-gpios = <&gpio 60 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
display-hold-off-ms = <20>;
};

Example using num-interpolation-steps:
Expand Down
6 changes: 6 additions & 0 deletions drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct pwm_bl_data {
bool legacy;
unsigned int pwm_on_delay;
unsigned int pwm_off_delay;
unsigned int hold_off_delay;
int (*notify)(struct device *,
int brightness);
void (*notify_after)(struct device *,
Expand Down Expand Up @@ -91,6 +92,9 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)

regulator_disable(pb->power_supply);
pb->enabled = false;

if (pb->hold_off_delay)
msleep(pb->hold_off_delay);
}

static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
Expand Down Expand Up @@ -388,6 +392,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
of_property_read_u32(node, "pwm-on-delay-ms",
&data->pwm_on_delay);
of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay);
of_property_read_u32(node, "display-hold-off-ms", &data->hold_off_delay);

data->dp_enable_gpio = -EINVAL;
data->bl_enable_gpio = -EINVAL;
Expand Down Expand Up @@ -493,6 +498,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->enabled = false;
pb->pwm_on_delay = data->pwm_on_delay;
pb->pwm_off_delay = data->pwm_off_delay;
pb->hold_off_delay = data->hold_off_delay;

pb->dp_enable_gpio = devm_gpiod_get_optional(&pdev->dev,
"display-enable", GPIOD_ASIS);
Expand Down
1 change: 1 addition & 0 deletions include/linux/pwm_backlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct platform_pwm_backlight_data {
unsigned int *levels;
unsigned int pwm_on_delay;
unsigned int pwm_off_delay;
unsigned int hold_off_delay;
/* TODO remove once all users are switched to gpiod_* API */
int dp_enable_gpio;
int bl_enable_gpio;
Expand Down

0 comments on commit 01e56b1

Please sign in to comment.