linux-stable/drivers/video
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
..
backlight backlight: pwm_bl: Fix interpolation 2020-11-04 15:54:57 +00:00
console parisc/sticon: Add user font support 2020-10-15 08:12:59 +02:00
fbdev ARM: SoC platform updates 2020-10-24 10:33:08 -07:00
logo .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
display_timing.c
hdmi.c drm-misc-next for v5.9: 2020-06-24 15:45:51 +10:00
Kconfig
Makefile
of_display_timing.c
of_videomode.c
vgastate.c
videomode.c