Skip to content

drm/apple: switch the panel backlight off at level 0 and count it in millinits - #2844

Draft
Ante042 wants to merge 2 commits into
aurora-silicon:mainfrom
Ante042:j314s-backlight-off-at-zero
Draft

Ante042 wants to merge 2 commits into
aurora-silicon:mainfrom
Ante042:j314s-backlight-off-at-zero

Conversation

@Ante042

@Ante042 Ante042 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 brightness and actual_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_brightness goes 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
  • Power at level 0 against the lowest lit level, picture still scanned out: 165 mW less on the J314s (older local 7.3 tree).
  • Read-back row on 2596602bfaf6: verify/bl-steps.sh wrote a series of levels from 0 to 500000 and read each one back unchanged from brightness and actual_brightness. Levels in order: 0, 1000, 2000, 2500, 3000, 5000, 20000, 20500, 21000, 100000, 300000, 500000, 300000, 20000, 2000, 0.
  • Earlier, on main 3a6d154 with the drafts: the ambient light sensor next to the panel rose with the level in a dark room.

Thanks for taking a look!

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at 2672818 (non-author, draft). The code is small and correct; the behaviour change is the question.

  • off is set only in the direct (non-fade) path of dcp_set_brightness(), and the fade only starts with both levels above 0, so a move to 0 always goes through it, and any level above 0 clears it on the next swap (bl_power = 0x40). The poweroff swap's own bl_power = 0 is untouched.
  • Merges cleanly on the current integration/aurora tip.

Points to consider:

  • Level 0 then means a black panel with the picture still scanned out. Userspace that treats brightness 0 as "dimmest visible" (slider at its left end, ambient-light or idle-dim code that steps down to the minimum, restore tools that write a saved value of 0 back at boot) will blank the internal panel with no way back except the brightness keys. The backlight class has bl_power for turning the light off; many drivers keep 0 visible for that reason. If off-at-0 is wanted, it needs a row showing GNOME/KDE's lowest slider step and systemd-backlight's restore behaviour on this panel, so we know nobody lands on a black screen by accident.
  • It applies only on the pre-26.x swap path, so the same brightness value would mean "off" on some firmware and "dimmest lit" on others. Whatever is decided should behave the same on both paths.
  • Not tried across a lid close / resume with the panel at 0: after resume the stored off stays true, so the panel comes back dark. That is consistent, but worth confirming it does not also skip the first lit swap when the level changes afterwards.

Assisted-by: LLM (Claude:Opus 5.5)

@Ante042

Ante042 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

On the three points:

systemd-backlight does not restore a saved 0, it clamps to a minimum at boot unless ID_BACKLIGHT_CLAMP says otherwise. This machine was restarted with the panel at 0 today and logged apple-panel-bl: Saved brightness 0 is too low; increasing to 5000 (out of 500000 on my local tree) on the way up. I have no GNOME or KDE rows, I run Hyprland, so I can't show what their sliders do at the left end.

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 bl_power instead, so a compositor that wants the light off while idle can ask for it and the left end of the slider means what it did before. Tell me which you prefer and I'll change it.

@Ante042
Ante042 force-pushed the j314s-backlight-off-at-zero branch 3 times, most recently from 8aec7da to e44da9e Compare November 29, 2026 00:38
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]>
@Ante042
Ante042 force-pushed the j314s-backlight-off-at-zero branch from e44da9e to 1d0c143 Compare November 29, 2026 21:56
@Ante042 Ante042 changed the title drm/apple: switch the panel backlight off at brightness level 0 drm/apple: switch the panel backlight off at level 0 and count it in millinits Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants