From: Matthias Kaehlcke <mka@chromium.org>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Jingoo Han <jingoohan1@gmail.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Douglas Anderson <dianders@chromium.org>,
Brian Norris <briannorris@chromium.org>,
Pavel Machek <pavel@ucw.cz>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>
Subject: Re: [PATCH 4/4] backlight: pwm_bl: Set scale type for brightness curves specified in the DT
Date: Mon, 24 Jun 2019 11:54:08 -0700 [thread overview]
Message-ID: <20190624185408.GB137143@google.com> (raw)
In-Reply-To: <9ea1bb40-95a6-7a67-a8a6-ecc77a70e547@linaro.org>
Hi Daniel,
On Fri, Jun 21, 2019 at 02:10:19PM +0100, Daniel Thompson wrote:
> On 13/06/2019 20:43, Matthias Kaehlcke wrote:
> > Check if a brightness curve specified in the device tree is linear or
> > not and set the corresponding property accordingly. This makes the
> > scale type available to userspace via the 'scale' sysfs attribute.
> >
> > To determine if a curve is linear it is compared to a interpolated linear
> > curve between min and max brightness. The curve is considered linear if
> > no value deviates more than +/-5% of ${brightness_range} from their
> > interpolated value.
> >
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > drivers/video/backlight/pwm_bl.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> > index f067fe7aa35d..912407b6d67f 100644
> > --- a/drivers/video/backlight/pwm_bl.c
> > +++ b/drivers/video/backlight/pwm_bl.c
> > @@ -404,6 +404,26 @@ int pwm_backlight_brightness_default(struct device *dev,
> > }
> > #endif
> > +static bool pwm_backlight_is_linear(struct platform_pwm_backlight_data *data)
> > +{
> > + unsigned int nlevels = data->max_brightness + 1;
> > + unsigned int min_val = data->levels[0];
> > + unsigned int max_val = data->levels[nlevels - 1];
> > + unsigned int slope = (100 * (max_val - min_val)) / nlevels;
>
> Why 100 (rather than a power of 2)?
I guess it came from the decimal part of my brain, I can change it to
128 ;-)
> It would also be good to have a comment here saying what the maximum
> quantization error is. Doesn't have to be over complex just mentioning
> something like the following (assuming you agree that its true ;-) ):
>
> Multiplying by XXX means that even in pathalogical cases such as
> (max_val - min_val) == nlevels then the error at max_val is less than
> 1%.
Sounds good, thanks for the suggestion!
> With a suitable comment in the fixed point code:
> Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Thanks
prev parent reply other threads:[~2019-06-24 18:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 19:43 [PATCH 0/4] backlight: Expose brightness curve type through sysfs Matthias Kaehlcke
2019-06-13 19:43 ` [PATCH 1/4] MAINTAINERS: Add entry for stable backlight sysfs ABI documentation Matthias Kaehlcke
2019-06-19 11:05 ` Daniel Thompson
2019-06-13 19:43 ` [PATCH 2/4] backlight: Expose brightness curve type through sysfs Matthias Kaehlcke
2019-06-13 21:56 ` Matthias Kaehlcke
2019-06-13 19:43 ` [PATCH 3/4] backlight: pwm_bl: Set scale type for CIE 1931 curves Matthias Kaehlcke
2019-06-19 9:17 ` Enric Balletbo i Serra
2019-06-21 12:55 ` Daniel Thompson
2019-06-27 9:24 ` Lee Jones
2019-06-27 15:49 ` Daniel Thompson
2019-06-13 19:43 ` [PATCH 4/4] backlight: pwm_bl: Set scale type for brightness curves specified in the DT Matthias Kaehlcke
2019-06-21 13:10 ` Daniel Thompson
2019-06-24 18:54 ` Matthias Kaehlcke [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190624185408.GB137143@google.com \
--to=mka@chromium.org \
--cc=b.zolnierkie@samsung.com \
--cc=briannorris@chromium.org \
--cc=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=enric.balletbo@collabora.com \
--cc=jacek.anaszewski@gmail.com \
--cc=jingoohan1@gmail.com \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).