WSL2-Linux-Kernel/drivers/video/backlight
Alexandru Stan 789eb04b6c backlight: pwm_bl: Fix interpolation
The previous behavior was a little unexpected, its properties/problems:
1. It was designed to generate strictly increasing values (no repeats)
2. It had quantization errors when calculating step size. Resulting in
unexpected jumps near the end of some segments.

Example settings:
	brightness-levels = <0 1 2 4 8 16 32 64 128 256>;
	num-interpolated-steps = <16>;

Whenever num-interpolated-steps was larger than the distance
between 2 consecutive brightness levels the table would get really
discontinuous. The slope of the interpolation would stick with
integers only and if it was 0 the whole line segment would get skipped.

The distances between 1 2 4 and 8 would be 1 (property #1 fighting us),
and only starting with 16 it would start to interpolate properly.

Property #1 is not enough. The goal here is more than just monotonically
increasing. We should still care about the shape of the curve. Repeated
points might be desired if we're in the part of the curve where we want
to go slow (aka slope near 0).

Problem #2 is plainly a bug. Imagine if the 64 entry was 63 instead,
the calculated slope on the 32-63 segment will be almost half as it
should be.

The most expected and simplest algorithm for interpolation is linear
interpolation, which would handle both problems.
Let's just implement that!

Take pairs of points from the brightness-levels array and linearly
interpolate between them. On the X axis (what userspace sees) we'll
now have equally sized intervals (num-interpolated-steps sized,
as opposed to before where we were at the mercy of quantization).

Signed-off-by: Alexandru Stan <amstan@chromium.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-11-04 15:54:57 +00:00
..
88pm860x_bl.c
Kconfig backlight: Add Kinetic KTD253 backlight driver 2020-08-28 11:48:04 +01:00
Makefile backlight: Add Kinetic KTD253 backlight driver 2020-08-28 11:48:04 +01:00
aat2870_bl.c
adp5520_bl.c
adp8860_bl.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
adp8870_bl.c
ams369fg06.c
apple_bl.c
arcxcnn_bl.c
as3711_bl.c
backlight.c
bd6107.c
corgi_lcd.c
cr_bllcd.c
da903x_bl.c
da9052_bl.c
ep93xx_bl.c
gpio_backlight.c
hp680_bl.c
hx8357.c
ili922x.c
ili9320.c
ili9320.h
ipaq_micro_bl.c
jornada720_bl.c
jornada720_lcd.c
kb3886_bl.c
ktd253-backlight.c backlight: Add Kinetic KTD253 backlight driver 2020-08-28 11:48:04 +01:00
l4f00242t03.c
lcd.c
led_bl.c
lm3533_bl.c
lm3630a_bl.c
lm3639_bl.c
lms283gf05.c
lms501kf03.c
locomolcd.c
lp855x_bl.c
lp8788_bl.c
ltv350qv.c
ltv350qv.h
lv5207lp.c
max8925_bl.c
omap1_bl.c
otm3225a.c
pandora_bl.c
pcf50633-backlight.c
platform_lcd.c
pwm_bl.c backlight: pwm_bl: Fix interpolation 2020-11-04 15:54:57 +00:00
qcom-wled.c
rave-sp-backlight.c
sky81452-backlight.c backlight: sky81452-backlight: Fix refcount imbalance on error 2020-08-28 10:25:54 +01:00
tdo24m.c
tosa_bl.c backlight: tosa_bl: Include the right header 2020-09-08 12:31:19 +01:00
tosa_bl.h
tosa_lcd.c backlight: tosa_lcd: Include the right header 2020-09-08 12:30:02 +01:00
tps65217_bl.c
vgg2432a4.c
wm831x_bl.c