Message ID  20190919140620.324071linux@rasmusvillemoes.dk 

State  New 
Headers  show 
Series 

Related  show 
Hi Rasmus Has something gone wrong with the mail out for this patch set. I didn't get a covering letter or patch 5/5? Daniel.
On 20/09/2019 12.14, Daniel Thompson wrote: > Hi Rasmus > > Has something gone wrong with the mail out for this patch set. I didn't > get a covering letter or patch 5/5? Sorry about that. I should have included a cover letter so you'd know that patch 5 wasn't directly related to the other patches. https://lore.kernel.org/lkml/20190919140620.324075linux@rasmusvillemoes.dk/ I was removing the now unused int_pow() function, but Andy has told me there are new users in next, so it's moot. Only the first four patches are relevant. Thanks, Rasmus
On Thu, Sep 19, 2019 at 04:06:16PM +0200, Rasmus Villemoes wrote: > The "breakeven" 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. Indeed. Interestingly the following doc (with a high search rank in Google) has exactly this inconsistency and uses different values at different times: http://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm > > Signedoffby: Rasmus Villemoes <linux@rasmusvillemoes.dk> Reviewedby: Daniel Thompson <daniel.thompson@linaro.org> >  > 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 fixedpoint number in scale @scale. Convert to a > + * percentage, still expressed as a fixedpoint 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
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 fixedpoint number in scale @scale. Convert to a + * percentage, still expressed as a fixedpoint 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));
The "breakeven" 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. Signedoffby: Rasmus Villemoes <linux@rasmusvillemoes.dk>  drivers/video/backlight/pwm_bl.c  12 +++++++++ 1 file changed, 9 insertions(+), 3 deletions()