Re: [PATCH 2/3] backlight: pwm_bl: Artificially add 0% during interpolation

From: Daniel Vetter
Date: Mon Sep 07 2020 - 03:50:42 EST


On Fri, Sep 04, 2020 at 12:38:22PM +0100, Daniel Thompson wrote:
> On Mon, Jul 20, 2020 at 09:25:21PM -0700, Alexandru Stan wrote:
> > Some displays need the low end of the curve cropped in order to make
> > them happy. In that case we still want to have the 0% point, even though
> > anything between 0% and 5%(example) would be skipped.
>
> For backlights it is not defined that 0 means off and, to be honest, 0
> means off is actually rather weird for anything except transflexive
> or front lit reflective displays[1]. There is a problem on several
> systems that when the backlight slider is reduced to zero you can't
> see the screen properly to turn it back up. This patch looks like it
> would make that problem worse by hurting systems with will written
> device trees.
>
> There is some nasty legacy here: some backlight displays that are off
> at zero and that sucks because userspace doesn't know whether zero is
> off or lowest possible setting.
>
> Nevertheless perhaps a better way to handle this case is for 0 to map to
> 5% power and for the userspace to turn the backlight on/off as final
> step in an animated backlight fade out (and one again for a fade in).

Afaik chromeos encodes "0 means off" somewhere in there stack. We've
gotten similar patches for the i915 backlight driver when we started
obeying the panel's lower limit in our pwm backlight driver thing that's
sometimes used instead of acpi.

There's also the problem that with fancy panels with protocol (dsi, edp,
...) shutting of the backlight completely out of the proper power sequence
hangs the panel (for some panels at least), so providing a backlight off
that doesn't go through the drm modeset sequence isn't always possible.

It's a bit a mess indeed :-/
-Daniel

>
>
> Daniel.
>
> >
> > Signed-off-by: Alexandru Stan <amstan@xxxxxxxxxxxx>
> > ---
> >
> > drivers/video/backlight/pwm_bl.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> > index 5193a72305a2..b24711ddf504 100644
> > --- a/drivers/video/backlight/pwm_bl.c
> > +++ b/drivers/video/backlight/pwm_bl.c
> > @@ -349,6 +349,14 @@ static int pwm_backlight_parse_dt(struct device *dev,
> > /* Fill in the last point, since no line starts here. */
> > table[x2] = y2;
> >
> > + /*
> > + * If we don't start at 0 yet we're increasing, assume
> > + * the dts wanted to crop the low end of the range, so
> > + * insert a 0 to provide a display off mode.
> > + */
> > + if (table[0] > 0 && table[0] < table[num_levels - 1])
> > + table[0] = 0;
> > +
> > /*
> > * As we use interpolation lets remove current
> > * brightness levels table and replace for the
> > --
> > 2.27.0
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch