mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] backlight: pwm_bl: fix cie1913 comments and constant
@ 2019-09-19 14:06 Rasmus Villemoes
  2019-09-19 14:06 ` [PATCH 2/5] backlight: pwm_bl: eliminate a 64/32 division Rasmus Villemoes
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Rasmus Villemoes @ 2019-09-19 14:06 UTC (permalink / raw)
  To: Thierry Reding, Lee Jones, Daniel Thompson, Jingoo Han,
	Bartlomiej Zolnierkiewicz
  Cc: Rasmus Villemoes, linux-pwm, dri-devel, linux-fbdev, linux-kernel

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.

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 2201b8c78641..be36be1cacb7 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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-10-08 10:43 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 14:06 [PATCH 1/5] backlight: pwm_bl: fix cie1913 comments and constant Rasmus Villemoes
2019-09-19 14:06 ` [PATCH 2/5] backlight: pwm_bl: eliminate a 64/32 division Rasmus Villemoes
2019-10-07 15:13   ` Daniel Thompson
2019-09-19 14:06 ` [PATCH 3/5] backlight: pwm_bl: drop use of int_pow() Rasmus Villemoes
2019-10-07 15:28   ` Daniel Thompson
2019-10-07 18:43     ` Rasmus Villemoes
2019-10-08  9:31       ` Daniel Thompson
2019-10-08 10:02         ` Rasmus Villemoes
2019-10-08 10:43           ` Daniel Thompson
2019-09-19 14:06 ` [PATCH 4/5] backlight: pwm_bl: switch to power-of-2 base for fixed-point math Rasmus Villemoes
2019-10-07 15:32   ` Daniel Thompson
2019-09-19 14:06 ` [PATCH 5/5] lib/math: remove int_pow() Rasmus Villemoes
2019-09-19 14:36   ` Andy Shevchenko
2019-09-21 15:19   ` kbuild test robot
2019-09-21 15:22   ` kbuild test robot
2019-09-20 10:14 ` [PATCH 1/5] backlight: pwm_bl: fix cie1913 comments and constant Daniel Thompson
2019-09-20 10:36   ` Rasmus Villemoes
2019-10-07 15:08 ` Daniel Thompson

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®