Skip to content

drm/apple: hold brightness requests at the panel's floor - #3105

Merged
RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
chrisohearn:feat/k114s-brightness-floor
Dec 1, 2026
Merged

RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
chrisohearn:feat/k114s-brightness-floor

Conversation

@chrisohearn

@chrisohearn chrisohearn commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What: An optional apple,min-brightness in a panel node raises any brightness request below it, zero included, to that level on the nits backlight, and the backlight device reads the raised level back. Without the property nothing changes. Blanking and DPMS off still present 0, and suspend behaves as before. Today a write of 0 to apple-panel-bl presents 0 nits, the level DPMS off presents; what 0 nits shows on this OLED has not been observed. Related: #2844 (see Details).
Tested: on a K114s (Mac17,13) at this head: one boot of a kernel built from it with a local tree carrying apple,min-brightness = <10>; the probe logs the floor, writes of 1 and 9 to apple-panel-bl read back 10 (sysfs value; luminance not measured), 0 failed units, no new kernel errors; 31 apple-dcp-backlight KUnit cases pass in QEMU and dt_binding_check passes (hardware row in the comments).
Risk: two-way door for the driver; the property is DT binding surface (one-way once released). Applies to the H17P, firmware 27, M4 and 14.7 nits panels; desktop 26.x firmware does not read the property. No tree sets it, so no Mac changes.
Not yet: a write of 0 and the presented luminance below the floor, on hardware. The K114s device tree user is #3181 (below).

Details
Evidence
Check Result
Host run of drivers/gpu/drm/apple/dcp_backlight_test.c (user-space build with stand-in KUnit headers, the compile line of tests/brightness/run-dcp-backlight-host.sh) 29 case(s), 0 failed, including backlight_floor_test; with the floor line replaced by return nits; the same case fails (dcp_bl_prepare ... == -114)
Build, this kernel's .config plus KUNIT=y and DRM_APPLE_KUNIT_TEST=m, clang 23.1.3, W=1 dcp.o, dcp_backlight.o, dcp_backlight_test.o: no warnings
checkpatch.pl --strict binding 0/0, driver 0/0
make dt_binding_check not run: dtschema is not installed here. The YAML parses
Probe line on the K114s, 2026-11-24, earlier cut of this change, tree sets 10 apple-dcp 48ae00000.dcp: brightness requests below 10 nits are raised to 10 nits (the earlier cut logged it in dcp.c; this cut logs it from dcp_backlight_configure(), not rebooted)
Backlight read on the K114s, nothing written apple-panel-bl, max_brightness 1000, brightness 200, actual_brightness 200, type platform
Write steps with the floor, kernel 7.3.0-17.v272-11, 2026-11-15/16, three runs starting levels 500, 1000 and 850, stepping down to 10 and back: brightness and actual_brightness equal the written level at every step. The result files record no observation of the panel. I saw the panel dim and recover in the first run, the D5 run of 2026-11-15 (record). No run went below the floor, so the floor itself was not exercised on hardware
Not observed a write of 0 (never made on the real panel), what 0 or 10 nits shows on this OLED, behaviour across suspend with the floor

Links: #2844 (backlight off at level 0), K114s boot report #142 (comment).

A panel node may name the lowest level at which the panel shows a lit
picture, in the unit of apple,max-brightness. The driver change that
follows raises requests below it to it. Turning the display off is not a
request and is not affected.

Signed-off-by: Chris O'Hearn <[email protected]>
The nits backlight (firmware 27) accepts every level from 0 to
apple,max-brightness, and a brightness-only present carries the level to
the firmware as written. A write of 0 to the backlight device therefore
presents 0 nits, the level DPMS off presents. What 0 nits shows on an
OLED panel has not been observed, so such a panel may need a lowest
level that a request can reach.

Read an optional apple,min-brightness from the panel node, in the same
nits as apple,max-brightness. A request below it, zero included, is
raised to it, and the backlight device reads the raised level back.
Blanking and DPMS off are not requests and still present zero.
A level the loader reported below the floor stays until the first
request. Without the property, or with one that is not below the
maximum, nothing changes. The floor is applied, and logged, on the H17P, firmware 27, M4 and
14.7 nits panels; a panel on the DAC path of older firmware and desktop
26.x firmware do not read it.

backlight_floor_test covers the floor, the unchanged zero without it,
the display-off cases and the loader level. Built as a user-space
program with stand-in headers all 29 cases of the file pass, and
backlight_floor_test fails with the floor removed; not run under KUnit.

On one K114s (firmware 27.2) a build carrying an earlier cut of this
change logs "brightness requests below 10 nits are raised to 10 nits" at
probe. In three runs, writes stepping from 500, 1000 or 850 nits down to
10 and back read back unchanged; in the first run the panel was seen to
dim and recover. No run wrote below the floor, so the floor itself was not
exercised on the hardware.

Signed-off-by: Chris O'Hearn <[email protected]>
@chrisohearn
chrisohearn force-pushed the feat/k114s-brightness-floor branch from 6301e6e to 040c06c Compare November 25, 2026 01:03
@chrisohearn

Copy link
Copy Markdown
Contributor Author

K114s (Mac17,13, T6050) at 040c06ca5353: PASS, one boot of a kernel built from this head.

  • Build: this head plus the local K114s carries (70 commits; this PR replaces the earlier local binding and floor cuts, and two Centauri patches were already in the branch), with this Mac's config. Booted once from the Backup slot by a one-shot. OS firmware 27.2, system firmware 27.3 beta.
  • Device tree: the configured tree (not part of this PR) carries apple,min-brightness = <10> in the panel node; the booted tree read back 0x0000000a. The probe logged apple-dcp 48ae00000.dcp: brightness requests below 10 nits are raised to 10 nits.
  • Below the floor on hardware: writing 1 and then 9 to /sys/class/backlight/apple-panel-bl/brightness read back 10 each time (the sysfs value this PR sets; the presented luminance was not measured). The starting level, 500, was restored after each write.
  • Regression counts on the same boot: 0 failed units (system and user), no new kernel error lines against the previous kernel (r3f), 0 Oops/WARNING lines. Panel (120 Hz), GPU, camera, light sensor, SEP and audio services present.
  • Offline: a separate built-in KUnit build, run in QEMU, passed 31 of 31 apple-dcp-backlight cases, including the floor case. dt_binding_check for apple,dcp.yaml passed.
  • Not checked: a write of 0 (only positive requests were made), the luminance the panel presents below the floor, behaviour across suspend with the floor, and a second K114s.

This covers the boot, the write below the floor (as a sysfs read-back), dt_binding_check and KUnit under "Not yet". A device tree user in this series is still open, so the PR stays a draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@chrisohearn checking open drafts today. To come out of draft, this still needs:

  • A test run at the current head on a Mac with the hardware it touches, then mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

@chrisohearn

Copy link
Copy Markdown
Contributor Author

Thanks for the check. The hardware row at the current head (040c06ca5353) is above: one boot of a kernel built from this head, writes below the floor read back 10, 0 failed units, no new kernel errors, 31 KUnit cases and dt_binding_check passing.

The device tree user is #3181, which sets apple,min-brightness = <10>; in the K114s panel node. It is stacked on #2009's panel node, so it follows once #2009 is rebased. No tree sets the property today, so this change alters nothing on any Mac until a user lands. Marking this ready for review.

@chrisohearn
chrisohearn marked this pull request as ready for review November 26, 2026 20:19
@chrisohearn
chrisohearn requested review from a team as code owners November 26, 2026 20:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T21:54:59.155598Z 0c42db3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 040c06ca53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread drivers/gpu/drm/apple/dcp_backlight.h Outdated
return -ENODATA;
if (nits > state->maximum)
return -ERANGE;
nits = dcp_bl_floor(state, nits);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve inherited levels across blank-only updates

When a configured floor exceeds the inherited target (for example, loader level 4 with a floor of 10), the backlight core calls this function for BL_CORE_FBBLANK and BL_CORE_SUSPENDED transitions with the unchanged brightness value. Applying the floor before distinguishing those state-only transitions changes state->target to 10, and dcp_set_brightness() also rewrites the sysfs value, so resume or unblank restores 10 even though no brightness request occurred; blank/suspend-only updates need to preserve the inherited target until the first actual brightness write.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 08ea507e: not ready yet

Check Detail
CI at head running running: KUnit isp, KUnit jpeg, KUnit prores, KUnit scaler, KUnit macsmc, KUnit clpc
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 08ea507e
Conflicts ok none
PR text ok Risk: two-way · for the driver; the property is DT binding surface ( once released). Applies to the H17P, firmware 27, M4 and 14.7 nits panels; desktop 26.x firmware does not read the property. No tree sets it, so no Mac changes.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 040c06ca: fix first (one small change, below). Not a blocker for the approach.

Blockers

  • The Codex P2 finding is real. Blank and suspend changes reach dcp_bl_request() with the level unchanged, and the floor is applied before that case is recognised. So a loader level below the floor (e.g. 4 with a floor of 10) becomes 10 on the first FB blank or suspend, and dcp_set_brightness() writes 10 back to sysfs. No brightness write happened, which breaks the PR's own rule: "a loader level below the floor stays until the first request". Host repro on this head: loader 4, floor 10, request(4, blank) then request(4, unblank) gives target=10.

Suggested fix (tested on the host, see below). Apply the floor only when the call is a request:

-	nits = dcp_bl_floor(state, nits);
+	/*
+	 * A blank or suspend change arrives with the level unchanged: it is not
+	 * a request, so a loader level below the floor stays.
+	 */
+	if (nits != state->target || (state->core_blank == core_blank &&
+				       state->suspended == suspended))
+		nits = dcp_bl_floor(state, nits);

In dcp_set_brightness(), reading back state->target instead of dcp_bl_floor(state, bd->props.brightness) keeps sysfs equal to the level in every path, including the state-only ones. Please also add the blank-only and suspend-only cases to backlight_floor_test.

Checked

  • The binding is optional with minimum: 1, and no tree sets it, so no Mac changes behaviour today. The value comes from the DT, with no per-panel table and no chip or board gate.
  • dcp_bl_set_minimum() rejects a floor at or above the maximum, with a warning. Only the nits backlight paths use the floor (the DAC path is untouched), and DPMS off, blank and suspend still present 0.
  • #2844 touches different hunks, as the PR says.
Evidence

A host build of dcp_backlight.h at 040c06ca (gcc, stub kernel headers) runs the asserts of the PR's backlight_floor_test plus two new cases: blank then unblank with loader 4, and suspend with loader 4.

  • PR head: the PR's asserts pass; both new cases fail (target=10, want 4).
  • With the fix above: 0 failures, the PR's asserts included.

This was not run as kernel KUnit (QEMU) and not on hardware.

Backlight core blank and suspend transitions carry the current
brightness. Applying the floor on these transitions raises an inherited
level before the first brightness write. RyanTheTide reported that
blanking and unblanking raised an inherited level of 4 nits to 10.

Keep the target when only the blank or suspend state changes. Apply the
floor to level changes and to requests with unchanged state flags.
Read the accepted target back through the backlight device.

Extend backlight_floor_test to cover blank and suspend cycles below the
floor and same-level writes both lit and blanked.

Signed-off-by: Chris O'Hearn <[email protected]>
@chrisohearn

Copy link
Copy Markdown
Contributor Author

Thanks for reproducing this, Ryan. The driver now keeps the inherited level across blank and suspend transitions, and sysfs reads back the accepted target.

I extended backlight_floor_test to check that a 4-nit loader level survives blank/unblank and suspend/resume with a 10-nit floor. Same-value brightness writes still raise the target to 10 nits, including while the panel is blanked.

All 29 apple-dcp-backlight cases passed in arm64 QEMU at 0c42db3. I still owe the K114s hardware row at that head.

RyanTheTide
RyanTheTide previously approved these changes Nov 26, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 0c42db31: approve. Merge once CI is green and the K114s row at this head is posted.

Blockers: none. The blank/suspend finding from the last review is fixed.

Checked

  • dcp_bl_request() applies the floor only to real requests. A blank or suspend change with the level unchanged keeps a sub-floor loader level, and a same-level write still takes the floor (blanked or not).
  • sysfs now reads back state->target on every path.
  • The new test cases cover blank/unblank, suspend/resume and a same-level write while blanked.
  • The rest is unchanged from my last review: an optional DT property, no tree sets it, no gates.
Evidence

The host build of dcp_backlight.h at 0c42db31 matches the fix I tested earlier (whitespace only). It passes the earlier asserts and the blank-only and suspend-only cases: 0 failures. CI at this head is queued.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c42db3168

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +202 to +204
if (nits != state->target || (state->core_blank == core_blank &&
state->suspended == suspended))
nits = dcp_bl_floor(state, nits);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve inherited targets on same-state resume callbacks

On the firmware-27 wake path when no FB blank remains, dcp_backlight_wake_lit() pre-clears core_blank and suspended before the later backlight-core resume update, so an inherited target below the configured floor reaches this condition with unchanged nits and unchanged flags. The same-flags arm added in this revision is fresh evidence that the earlier issue remains: it raises state->target (and dcp_set_brightness() copies it to sysfs) even though the callback is state-only, so resume still changes the loader level without a brightness write; this path needs an actual-request indicator rather than treating every same-state update as a request.

Useful? React with 👍 / 👎.

Comment on lines +314 to +316
if (!ret && dcp->brightness.minimum)
floor_ret = dcp_bl_set_minimum(&dcp->backlight.state,
dcp->brightness.minimum);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Floor the M4 startup default before its first present

When apple,min-brightness is valid but greater than 120 on an M4 panel, iomfb_m4_configure_backlight() initializes the non-inherited target to 120 and this call only stores the minimum; the immediately following M4 dcp_bl_jump() marks 120 dirty, and iomfb_m4_swap() presents it. The driver therefore drives the panel below its declared lowest lit level before userspace writes brightness, potentially leaving startup black; floor non-inherited defaults before the M4 jump while retaining the below-floor exception only for loader-inherited levels.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026
@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 26, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

The host-tests failure at 0c42db31 comes from this PR. It's a compile error, not a logic one. The apple-dcp host harnesses paste dcp_backlight.h into their C units and stub only min(), so the new dcp_bl_floor() fails with call to undeclared function 'max'. Six units fail to build: panel-backlight-ramp, panel-takeover-registration, panel-brightness-takeover, desktop-brightness-notifications, desktop-brightness-keys-reports and m4-dpms-retirement (log).

One-line fix (avoids max(), no harness changes):

 static inline u32 dcp_bl_floor(const struct dcp_backlight_state *state, u32 nits)
 {
-	return max(nits, state->minimum);
+	return nits < state->minimum ? state->minimum : nits;
 }

With this on 0c42db31, tools/testing/selftests/drivers/gpu/apple-dcp/run.py (all groups) gives 95 ok, 0 not ok. Without it, the display and m4 groups fail those six units. My approval stands once this is in; the K114s row is then needed at the new head.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 26, 2026
The host test harnesses only stub min(), so the max() in dcp_bl_floor() left six apple-dcp units unbuilt. Open-code the clamp; the kernel build is unchanged.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks @chrisohearn. You have been waiting on us for two days, so we pushed the one-line fix from the earlier review ourselves as 08ea507e: dcp_bl_floor() now open-codes the clamp instead of using max(), which the host test harnesses do not stub. That was the only reason host-tests was red. The kernel build is unchanged. The apple-dcp host suite passes locally.

Next: a K114s floor row at the new head (we run it on our K114s), the review App at this head, then the merge. The two Codex notes (a resume with unchanged flags, and the M4 120-nit default above a floor) are tracked in #3579. Neither can happen until a tree sets apple,min-brightness, so they do not block this PR. You are welcome to take #3579 if you want it.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 08ea507 after CI and the K114s row

The ternary preserves the typed brightness clamp and avoids the missing max helper in the host fixture. The binding makes the floor optional, and no board enables it here. Keep the floor-enabled K114s regression and track resume/default interactions in #3579 before enabling the property in production DT.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Row (K114s, M5 Pro, T6050) at exact head 08ea507 -> PASS (floor holds across writes and blank/unblank, 0 DCP crashes).

  • Kernel: 7.3.0-k114scrj7 = the K114s stack kernel 2c040a1 (the Mac's default 7.3.0-k114sstack8) + this PR at 08ea507 (merge 31428fab). Kernel-only one-shot with the default command line. Stage 2 was a one-boot trial copy of the default (32bc264e) with only apple,min-brightness = <10> added to the panel node (max 1000), since no tree sets the property yet.
  • Boot: "brightness requests below 10 nits are raised to 10 nits" logged; the Mac booted Enforcing with 0 failed units and 0 AVC denials.
  • sysfs writes (panel on): 0, 1 and 9 read back 10 (actual 10); 10 -> 10; 11 -> 11; 200 -> 200.
  • Blank/unblank (Mutter PowerSaveMode 3/0) after writing 9: target 10, actual 0 while blanked. A write of 1 and a same-value write of 1 while blanked kept the target at 10. On unblank it came back at 10/10, a write of 0 then read 10, and a second blank/unblank cycle also came back at 10/10. Restoring the saved level 50 worked.
  • DCP: 0 crashes. The panel DCP logged no errors. The only DCP error lines came from the two external-display DCPs (DPTX remote-port timeout and DCPDP13Service admission -19 at boot, the same lines as on the default kernel, repeated at each PowerSaveMode cycle).
  • One WARNING at boot (drivers/base/core.c:1512 __device_links_no_driver from deferred probe, during the apple-admac probes), outside this PR's code. The same WARNING appears in earlier J713 boots of other kernels.

Evidence: traces/kernel/20261130-closeout-k114s-j316s-combo/k114s/. Default kernel 7.3.0-k114sstack8 and default Stage 2 restored and verified (hashes match, aura-try none, next_entry empty).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 08ea507eb7a2 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 08ea507 that the readiness check found (PR body or comment). CI: linux train L3 = main 429e7e1 + 28 approved PRs (candidate 45c2fa4b): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit dcp-fabric/dcp-topology/dcp-display/macsmc/spi-hid-apple/mt7932/asahi/sep pass; ave failed to build only because of #3153 (unused static helper under -Werror; #3153 held out) and passes with #3153 reverted from the candidate; host tests apple-dcp and apple-scaler-recovery pass. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 21b5311 into aurora-silicon:main Dec 1, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants