core/backendoutput: make auto-brightness better respect user's intentions
The auto-brightness curve has historically held a fixed number of control points, distributed uniformly across the full range of brightness values. While this has worked reasonably well in cases where the user prefers to utilize their display device's full range of brightness values via a roughly linear mapping from ambient lightness levels, it lacks adequate resolution in cases where the user wants to map a broad range of lightness levels to a narrow range of brightness values.
As an example, suppose the user wants brightness 0% at 2 lux, 10% for 3-30 lux, 20% at 100 lux, and 100% at 3000 lux. (This is a realistic curve for the Framework Laptop 16, whose LCD panel has an insanely bright backlight.) The existing algorithm provides no way to effect such a curve.
Introduce a new auto-brightness curve having a variable number of arbitrary control points (initially just one: 100% at 0 lux). Whenever the user makes a manual brightness adjustment, insert a new control point that precisely maps the ambient lightness level to the user's chosen brightness value. Then, to keep the curve strictly non-decreasing, delete any brighter control points at lower lightness levels and any dimmer control points at higher lightness levels. To constrain the number of control points on the curve, retain only the points having the lowest and highest lightness values for each distinct brightness value.
Backward compatibility with the old serialization format is implemented so that users will not notice any change in behavior upon upgrading except that their future manual brightness adjustments will effect more nuance in the resulting auto-brightness curve.