mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Enric Balletbo Serra <eballetbo@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>, Doug Anderson <dianders@google.com>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Brian Norris <briannorris@google.com>,
	Guenter Roeck <groeck@google.com>,
	Lee Jones <lee.jones@linaro.org>,
	Alexandru Stan <amstan@google.com>,
	linux-leds@vger.kernel.org,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC v2 2/2] backlight: pwm_bl: compute brightness of LED linearly to human eye.
Date: Mon, 18 Dec 2017 13:53:24 +0000	[thread overview]
Message-ID: <20171218135324.ulvacip55md4g73n@oak.lan> (raw)
In-Reply-To: <CAFqH_52z9O+0ZVB-rMTCNzw+55m26fDGKeaj-Fz-ccO74+j_MA@mail.gmail.com>

On Mon, Dec 18, 2017 at 11:40:59AM +0100, Enric Balletbo Serra wrote:
> Hi Pavel,
> 
> 2017-12-15 21:57 GMT+01:00 Pavel Machek <pavel@ucw.cz>:
> > Hi!
> >
> >> Yes, I think that how you describe luminance and lightness is right,
> >> and sounds good improve the doc.
> >>
> >> To be clear the correction table for PWM values can be calculated with
> >> this code.
> >>
> >> OUTPUT_SIZE = 65535      # Output integer size
> >> INPUT_SIZE = 2047
> >>
> >> def cie1931(L):
> >>     L = L*100.0
> >>     if L <= 8:
> >>         return (L/902.3)
> >>     else:
> >>         return ((L+16.0)/116.0)**3
> >>
> >> x = range(0,int(INPUT_SIZE+1))
> >> y = [int(round(cie1931(float(L)/INPUT_SIZE)*(OUTPUT_SIZE))) for L in x]
> >
> > Can we just generate the table on the fly? Should not be hard to do in
> > fixed point, right?
> 
> This was discussed a bit in previous RFC which had the code to
> generate the table on the fly, see [1]. The use of a fixed table or an
> on the fly table is something that I'll let the maintainers to decide.
> I've no strong opinion on use the on the fly table if someone takes
> care to review deeply the fixed point maths :)

The last time we discussed this we concluded we would introduce linear
interpolation to make it easier enlarge the small tables we typically 
see in devicetree.

Having done that it seemed attractive (at least to me) to reuse any
interpolation code we get and then simply provide a "sane" default look 
up table for use by DT authors who don't really know how to map PWM on/
off times to luminance.

I did review the original fixed point code for the first RFC. IIRC some 
of the low level functions *looked* they could overflow but, on closer 
inspection, were never actually overflowed in practice due to the 
number ranges used by the callers. To be honest part of the attraction
of a LUT instead was that I wouldn't have to closely review nor ensure
all the fixed point code was properly commented ;-) .

The other item in favour of LUT was that (as Doug A. pointed out) PWM 
duty-cycle to luminance is not strictly linear. Whilst at the moment I 
am OK to discount this effect it is possible we might want to combined
the luminance to human perception values with values read out from
graphs in a datasheet.

Enric: Having said all that I don't want to give you a really heavy
       handed steer here. If you think the code was cleaner or clearer
       when using the formulae then I'd be happy to review the fixed
       point code.


Daniel.

  parent reply	other threads:[~2017-12-18 13:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 14:11 [RFC v2 0/2] backlight: pwm_bl: support linear brightness " Enric Balletbo i Serra
2017-11-16 14:11 ` [RFC v2 1/2] backlight: pwm_bl: linear interpolation between values of brightness-levels Enric Balletbo i Serra
2017-11-20 18:58   ` Rob Herring
2017-11-27 11:21     ` Enric Balletbo Serra
2017-11-27 23:55       ` Doug Anderson
2017-11-27 23:52   ` Doug Anderson
2017-12-15 14:40   ` Daniel Thompson
2017-12-18  9:47     ` Enric Balletbo Serra
2017-12-18 13:15       ` Daniel Thompson
2017-11-16 14:11 ` [RFC v2 2/2] backlight: pwm_bl: compute brightness of LED linearly to human eye Enric Balletbo i Serra
2017-11-30  0:44   ` Doug Anderson
2017-11-30 11:27     ` Daniel Thompson
2017-11-30 16:57       ` Doug Anderson
2017-11-30 18:34       ` Enric Balletbo Serra
2017-11-30 19:06         ` Doug Anderson
2017-12-15 20:57         ` Pavel Machek
2017-12-18 10:40           ` Enric Balletbo Serra
2017-12-18 12:33             ` Pavel Machek
2017-12-18 13:53             ` Daniel Thompson [this message]
2017-12-15 14:51   ` Daniel Thompson
2017-12-18 10:27     ` Enric Balletbo Serra
2017-12-18 13:31       ` Daniel Thompson
2017-12-18 16:46         ` Doug Anderson
2017-12-18 20:21           ` Daniel Thompson

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=20171218135324.ulvacip55md4g73n@oak.lan \
    --to=daniel.thompson@linaro.org \
    --cc=amstan@google.com \
    --cc=briannorris@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@google.com \
    --cc=eballetbo@gmail.com \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@google.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=jingoohan1@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=rpurdie@rpsys.net \
    /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

all inboxes | Powered by JetHome®