Repository navigation
Conversation
|
Review at 2672818 (non-author, draft). The code is small and correct; the behaviour change is the question.
Points to consider:
Assisted-by: LLM (Claude:Opus 5.5) |
|
On the three points: systemd-backlight does not restore a saved 0, it clamps to a minimum at boot unless Across a sleep: I tried it today on my local tree, which has this patch, with suspend-to-RAM and not s2idle. The panel went into the sleep at level 0. After the wake the first non-zero level lit it, 0 switched it off again and the next level lit it again, read from the ambient light sensor and the panel supply power. So the stored state does not make it skip a lit swap. I can't cover the 26.x path, I only have a machine on the older one, so as posted the same value would mean off on one and dimmest lit on the other. If you'd rather keep 0 as the dimmest lit level, I can move the off state to the backlight device's |
8aec7da to
e44da9e
Compare
The lowest entry of the backlight DAC table is still about 2 nits, so brightness level 0 only dims the panel. The poweroff swap already turns the backlight off by sending bl_power = 0, and the next swap with 0x40 brings it back. Send bl_power = 0 in an ordinary swap as well when level 0 is asked for. On a MacBook Pro 14" M1 Pro (J314s) that saves 165 mW against the lowest lit level with the picture still scanned out, and any other level lights the panel again on the next swap. Signed-off-by: Andreas Fernandez <[email protected]>
…s a DAC value The DAC tables are far finer than whole nits, and at the dim end of the range a whole nit is a step of 10 to 25 %: a slow change of level, such as one following the ambient light, is a visible staircase there. Where a swap carries a DAC value, let the backlight device count in millinits. The H17G panel shares the registration but takes whole nits in its swaps, and keeps them. The level read back is the one presented last, or before the first present the firmware's own report, in the same units. At every whole nit the DAC word is the one the whole-nit arithmetic gave (compared on the host for 0 to 520 nits, both kinds of panel). Signed-off-by: Andreas Fernandez <[email protected]>
e44da9e to
1d0c143
Compare
What: Level 0 now switches the internal panel's backlight off instead of leaving it at the dimmest lit step (about 2 nits), as the lowest step does on macOS; and where a swap carries a DAC value the backlight device counts in millinits instead of whole nits, so slow changes at the dim end are no longer a visible staircase. Takes over #3612.
Tested: J314s M1 Pro at 1d0c143 (candidate 2596602bfaf6 on main 972a566, plus a test-only commit for the HDMI rows): boots, the same failed units as plain main, the levels written from 0 to 500000 read back unchanged in
brightnessandactual_brightness.Risk: two-way door · Macs whose panel takes a DAC value in its swaps (the M1/M2 Pro and Max laptops on the firmware before desktop 26.x); the H17G path keeps whole nits.
Not yet: a lid close with the panel at 0; GNOME and KDE sliders (I run Hyprland); the first boot after the unit change with a level saved under the old kernel.
Details
Off at 0. The poweroff swap already turns the backlight off with
bl_power = 0, and the next swap with 0x40 brings it back. This sends 0 in an ordinary swap too when level 0 is asked for. The fade between two lit levels is untouched, since it only starts when both levels are above 0, so a move to 0 always takes the direct path. User space that lets the slider reach 0 gets a black panel, the same as on macOS; systemd-backlight clamps a saved 0 to its minimum at boot (Saved brightness 0 is too low; increasing to 5000), so a restart does not come up dark.Millinits. At the dim end one nit is a step of 10 to 25 %, although the DAC tables are much finer. With a DAC panel
max_brightnessgoes from 500 to 500000 on the J314s. The level read back is the one presented last, or before the first present the firmware's own report, in the same unit. At every whole nit the DAC word is the one the whole-nit arithmetic gave; I compared that on the host for 0 to 520 nits and both kinds of panel. A level at the very end of a table now gives the table's last entry instead of a WARN and the middle entry.The visible part for user space is the unit: a level saved under the old kernel is read as millinits on the first boot. systemd-backlight's 5 % floor keeps that from coming up black, but I have not run that transition. If you'd rather keep whole nits in the backlight device and expose the finer scale another way, I can rework that commit on its own.
Two commits: the off-at-0 one first, the millinits one on top.
Evidence
verify/bl-steps.shwrote a series of levels from 0 to 500000 and read each one back unchanged frombrightnessandactual_brightness. Levels in order: 0, 1000, 2000, 2500, 3000, 5000, 20000, 20500, 21000, 100000, 300000, 500000, 300000, 20000, 2000, 0.Thanks for taking a look!