From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: "Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Lee Jones" <lee.jones@linaro.org>,
"Daniel Thompson" <daniel.thompson@linaro.org>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/4] backlight: pwm_bl: fix cie1913 comments and constant
Date: Tue, 8 Oct 2019 14:03:24 +0200 [thread overview]
Message-ID: <20191008120327.24208-2-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20191008120327.24208-1-linux@rasmusvillemoes.dk>
The "break-even" point for the two formulas is L==8, which is also
what the code actually implements. [Incidentally, at that point one
has Y=0.008856, not 0.08856].
Moreover, all the sources I can find say the linear factor is 903.3
rather than 902.3, which makes sense since then the formulas agree at
L==8, both yielding the 0.008856 figure to four significant digits.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/video/backlight/pwm_bl.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 746eebc411df..cc44a02e95c7 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -155,8 +155,8 @@ static const struct backlight_ops pwm_backlight_ops = {
*
* The CIE 1931 lightness formula is what actually describes how we perceive
* light:
- * Y = (L* / 902.3) if L* ≤ 0.08856
- * Y = ((L* + 16) / 116)^3 if L* > 0.08856
+ * Y = (L* / 903.3) if L* ≤ 8
+ * Y = ((L* + 16) / 116)^3 if L* > 8
*
* Where Y is the luminance, the amount of light coming out of the screen, and
* is a number between 0.0 and 1.0; and L* is the lightness, how bright a human
@@ -169,9 +169,15 @@ static u64 cie1931(unsigned int lightness, unsigned int scale)
{
u64 retval;
+ /*
+ * @lightness is given as a number between 0 and 1, expressed
+ * as a fixed-point number in scale @scale. Convert to a
+ * percentage, still expressed as a fixed-point number, so the
+ * above formulas can be applied.
+ */
lightness *= 100;
if (lightness <= (8 * scale)) {
- retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9023);
+ retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9033);
} else {
retval = int_pow((lightness + (16 * scale)) / 116, 3);
retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale));
--
2.20.1
next prev parent reply other threads:[~2019-10-08 12:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 12:03 [PATCH v2 0/4] backlight: pwm_bl: optimizations and small fix for cie1913 Rasmus Villemoes
2019-10-08 12:03 ` Rasmus Villemoes [this message]
2019-10-14 7:27 ` [PATCH v2 1/4] backlight: pwm_bl: fix cie1913 comments and constant Lee Jones
2019-10-23 20:21 ` Rasmus Villemoes
2019-10-08 12:03 ` [PATCH v2 2/4] backlight: pwm_bl: eliminate a 64/32 division Rasmus Villemoes
2019-10-14 7:27 ` Lee Jones
2019-10-08 12:03 ` [PATCH v2 3/4] backlight: pwm_bl: drop use of int_pow() Rasmus Villemoes
2019-10-14 7:27 ` Lee Jones
2019-10-08 12:03 ` [PATCH v2 4/4] backlight: pwm_bl: switch to power-of-2 base for fixed-point math Rasmus Villemoes
2019-10-14 7:27 ` Lee Jones
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=20191008120327.24208-2-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.thompson@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--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=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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