Repository navigation
drm/apple: follow the Studio Display's brightness curve on the external backlight (Andy Wei's fix, ported) - #2098
Conversation
|
CHANGES on 039993a Compared with Andy's three commits (cb29890, 1207a4c, 3c82dd8). Faithful. Findings (the text must say what the code does):
Checked and fine: the unconditional |
039993a to
b9f460a
Compare
|
[Joshua's agent] New head b9f460a, now two commits (HID, then drm/apple), both by Andy. Done: a backlight is registered only when the sink's EDID manufacturer is Apple (APP); the external flag still covers non-eDP outputs but only changes the dac mapping, and no bl_value goes out without a registered backlight. The reach is stated in the body, and it is the manufacturer, not the product, so other Apple displays pass (not checked). The nits-publish path is left as it was, which removes the contradicting comments; the hotplug comment now says external Apple displays never publish nits. Added log lines are dev_dbg. The HID driver is unchanged apart from the Kconfig help, which says its apple-display backlight does not move the panel and that two devices appear; the body explains why it is kept and offers read-only or removal. M1 Pro claim dropped. Rebuilt: clang, drm/apple plus hid-apple-display.o, exit 0, no warnings. Not booted. NOT CHECKED: whether the EDID manufacturer is known at the first hotplug check. |
|
CHANGES on b9f460a Re-review against my first comment. Most of it is fixed. Two new findings from this tree block it, and I answer the question about the HID backlight at the end. Fixed and checked.
1. A second external backlight path already exists on this tree (blocks). 2. The new device names break an ordering the base relies on (blocks). The base names its external backlight 3. The "other monitors get no backlight" claim does not hold after an Apple display has been plugged in (blocks the text, probably the code). The check runs in 4. The HID backlight (the question). The disclosure text is honest and sufficient as disclosure: the PR body and the Kconfig help both say the panel does not change. It is not sufficient as a design, for two reasons. First, the name The branch is based on the current head of |
b9f460a to
05987dd
Compare
|
[Joshua's agent] New head 05987dd, one commit, reduced. (a) The existing dcp--bl path is kept as the only one: the second device, the external flag, the module parameters and the swap changes are gone. What is taken over is Andy's curve: for an Apple EDID manufacturer, level 1..1000 is read as 4..600 nits and mapped through his table into the same bl_value field; level 0 and other displays keep the linear mapping. Which mapping is right for a Studio Display I cannot show: the field and layout are the same, only the curve differs, and the evidence for the curve is Andy's, not mine; the body says so. (b) The dcp-*-bl name is unchanged, so first-pick tools keep the built-in panel. (c) edid_maker is cleared in dcp_clear_connector_edid(), and the curve is chosen per swap from it, so a later non-Apple monitor does not get it; no device is registered or unregistered by this change. The HID commit is out of this PR and on branch dhp4/andy-hid-apple-display-aurora (head 36fe3e4), not proposed, with the Kconfig help corrected. Rebuilt: clang, drm/apple, exit 0, no warnings; the HID branch builds too. Not booted. NOT CHECKED: any hardware, and edid_maker being set before the first swap after connect. |
|
CHANGES on 05987dd Re-review of the reduced version. The earlier findings are closed: one backlight device ( Blocking: Fix, either: (a) call Checked and fine.
Notes, not blocking.
The branch is based on the current head of |
05987dd to
fa7b021
Compare
|
[Joshua's agent] New head fa7b021. Done: dcp_note_edid() runs on every EDID publication, both the raw and the firmware-derived one (the link-report log line keeps its link_report gate), so edid_maker is set on every machine; the curve uses the existing interpolate() (table const, last entry used directly at 600 nits because interpolate() warns past the end), the private copy is removed; the reach line says every machine, and that the EDID CRC is now computed on each publication. Body notes the first swap before the EDID: linear mapping until edid_maker is set, order not checked, and that I did not check what a firmware-derived EDID reports as manufacturer for a Studio Display. Rebuilt: clang, drm/apple, exit 0, no warnings. Not booted. |
|
Review at head fa7b021 — draft, not booted. Checked the asked-about points plus the EDID lifecycle:
Findings:
|
fa7b021 to
f1b2dee
Compare
|
[Joshua's agent] For @AndyWeiBoan, and an update for the reviewers. New head What changed: the EDID identity the curve test reads (maker, product, CRC) is now cleared on every path that retracts the EDID. Before, a display that was replaced by one with no EDID could keep the old identity. This was a review finding. What we found on the 14-inch M5 Max with a Studio Display (tester read): the Studio Display's connector has a 0-byte sysfs EDID. The driver logs "using firmware-derived EDID metadata" for it, so the display's identity comes from the firmware's display attributes, not from an EDID the display sent. The MacBook's own panel has maker What is next: a tester will read the raw Andy: your curve table has no |
…al backlight Andy Wei's commit 3c82dd816251 (drm/apple: drive external DisplayPort panel brightness over IOMFB) found that the swap's bl_value on an Apple Studio Display is a 16 bit code in the upper half of the word, with nits going as code^(8/3), and not a level that is linear in the field. This tree already registers an external backlight (dcp-<connector>-bl) that writes bl_value, with the level mapped linearly onto S32_MAX. Only the curve is taken over: for a Studio Display, level 1..1000 is taken as 4..600 nits and mapped through Andy's table. Other displays, and level 0, keep the linear mapping. The display is recognised by the identity the firmware reports for it, manufacturer APP and product 0xae3a, not by an EDID. A 2022 Studio Display on a 14-inch M5 Max MacBook Pro publishes no EDID (its sysfs edid is empty) and the driver builds one from this identity, so a test on the EDID could not have matched there. The built-in panel is APP with product 0 or 0x0616, and other Apple displays have other product codes, so they keep the linear mapping; so do other Studio Display models until their product code is known. The test is dcp_metadata_is_studio_display(), read under the metadata lock by dcp_firmware_metadata_studio_display(), and only on a DCP that takes the sink's identity from firmware metadata. Until the firmware's attributes arrive the linear mapping is used. Andy's message for the original commit follows. ---- 3c82dd816251 drm/apple: drive external DisplayPort panel brightness over IOMFB The Apple Studio Display exposes a Monitor-page HID feature report that looks like a brightness control, and every tool out there writes to it: asdbctl, the proposed backlight/apple_bl_usb driver, hid-apple-display. On this display and firmware that report is a mirror. The value is stored and read back verbatim, the transition time is honoured in the echo, and the panel never moves -- not under Linux, and not under macOS either, where a third-party SetReport is equally inert. macOS drives it the same way it drives the built-in panel: per frame, in the IOMFB swap. Do the same. An external output has no "apple,panel" DT child, so dcp_has_panel() is false and the backlight paths were all skipped. Mark those DCPs brightness.external, register the backlight from the hotplug handler (external DCPs never publish IOMFB_PROPERTY_NITS, so the usual trigger never fires), and name it after the DRM connector -- apple-dp-bl-DP-1 -- because a machine has one DCP per output and userspace needs to tell them apart. The swap field itself needed measuring. bl_value is not nits in 16.16 despite IOMFBBrightnessLevel being exactly that: it is the same 16 bit code the built-in panel uses, in the upper half of the word. The built-in panel's table pins the curve at 0x1000 for 2 nits and 0x7fe0 for 510, i.e. nits goes as code^(8/3); ext_brightness_code[] is that curve stretched over the Studio Display's 4..600 nits. Checked by eye at 600, 380, 250, 130 and 40 nits. hid-apple-display is left in place for now -- it still reports the real brightness the display believes it has, which is how the curve above got checked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Originally-by: AndyWeiBoan (commit AndyWeiBoan/linux@3c82dd8) [joshuaswarren: ported onto integration/aurora and reduced to the curve: the second backlight device, its module parameters, the external flag and the swap changes are dropped because this tree has the external backlight; the hid-apple-display driver is not part of this change] Signed-off-by: Joshua Warren <[email protected]>
f1b2dee to
ff8d1e4
Compare
|
[Joshua's agent] New head Finding 3 (APP also matches a Pro Display XDR) and the firmware-derived-maker finding: the Studio Display is now recognised by the firmware's own identity, manufacturer Finding 1 (stale EDID identity on four retract paths): the EDID identity is no longer used for this, so that code is gone from the PR; Tests: five identity cases in the existing host test ( Open: only the 2022 model is covered; the first swap after connect, before the firmware's attributes arrive, uses the linear mapping. |
|
Re-review at head ff8d1e4 — the answer to my fa7b021 review. Verdict: GREEN. All three earlier findings are resolved:
rate.py covers the five identity cases (match, panel product 0, other product, wrong manufacturer, non-folding product). Compile-only glue is honestly disclosed; not booted. Caveats, not blockers: only the 2022 model (0xae3a) is covered — other Studio Display models keep the linear mapping until their product codes are known; and the late-attributes one-time brightness step noted above. |
|
Thanks for reducing this to the curve; the identity check and locking look right. Two points:
Andy's Signed-off-by (already asked) is the other open item. |
|
[Joshua's agent] 1: Agreed: product code 2 (measurement): We have not run Ryan's luminance-meter row on either base or this head. Carried Andy Hardware row: Studio Display + meter at levels 1/100/250/500/750/1000 nits (monotonic, within 10% of mapped nits); non-Apple external unchanged. Script: external backlight sysfs + |
|
Thanks. The head is still ff8d1e4, so we'll wait for the push you described. To restate what it needs:
Once those three are in, this can leave draft. |
Use the external backlight capability instead of a product code. Map levels 1–1000 to the sink's reported luminance range and encode the fixed-point 3/8 power in the high half of bl_value. Fall back to 4–600 nits. Keep level zero and unsupported sinks unchanged. Distinguish an absent minimum from a reported zero. The five rate cases pass. A host probe checks five ranges and six sample levels against the mathematical curve. The three changed objects compile for arm64. Signed-off-by: Joshua Warren <[email protected]>
|
ea492b7 applies the 3/8 curve to displays that report SupportsBacklightControl. It no longer matches a product code. It reads the current sink's 16.16 luminance bounds and falls back to 4 and 600 nits. Level zero and displays without the capability keep their old behavior. All five rate tests passed. A host probe checked five luminance ranges, all 1000 nonzero levels for monotonic output, and the six requested levels against the formula. The six sampled codes differed by at most four code units. The three changed arm64 objects compiled. The meter readings on the base and head, the non-Apple comparison, and Andy's own sign-off remain. This stays in draft. |
|
Thanks, ea492b7 does what we asked. The 3/8 curve covers every display with SupportsBacklightControl, the bounds come from the sink (4..600 nits when it reports none), and the product-code match is gone. Before review:
|
The interpolation helper only reads the lookup table. Accept a const table without changing the interpolation or its callers. Tested with the extracted helper and a const table using -Werror=discarded-qualifiers.
|
I left the curve and the minimum unchanged. The base and head meter rows include level 1, along with 100, 250, 500, 750 and 1000. If level 1 is dark, the minimum goes to 4 nits. The non-Apple control and Andy's sign-off are still open. The branch keeps the original patch link; the squash is still open. |
|
J775c (lobata) row request — external brightness metering (sheet row U3) Posted by Joshua's lane (wB4) from the 2026-11-20 K114c row set. We supply no image for this; it needs a tree with the J775c DTB, built on the head after squash and const restoration ( Commands: with the Studio Display and the non-Apple monitor attached, read the meter at levels 1/100/250/500/750/1000 on base and head. Pass: meter readings recorded on both heads; if level 1 is dark, report to the owner for the 4-nit floor; the non-Apple monitor is unchanged. |
|
Happy for this to go in as a port of my change. Signed-off-by: Andy Wei [email protected] The curve was measured on a Studio Display (2022). |
|
@joshuaswarren checking open drafts today. To come out of draft, this still needs:
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. |
Signed-off-by: Joshua Warren <[email protected]>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 594a05cf
Blockers:
- Missing exact-head
594a05cfhardware verification rows (external display backlight monotonicity/luminance check plus non-Apple monitor regression check, as listed underNot yet). - Queued CI checks (
apple-build,host-tests,kunit,pr-text,readiness, KUnit suites) are still pending; wait for green CI.
Checked:
594a05cfcleanly mergesmainoverea492b7d/c10f0eac(mapping external backlight levels 1..1000 linearly to reported luminance bounds withconstlookup tables); carried third-party commitff8d1e41unchanged;MERGEABLEonmain, no Apple material or private serials.
Evidence
- Head:
594a05cf(base: main,mergeable: MERGEABLE,+57/-14across 6 files).
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at 594a05cfaaab
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - 594a05cf cleanly merges main over ea492b7d / c10f0eac (mapping external backlight levels 1..1000 linearly to reported luminance bounds with const lookup tables); carried third-party commit ff8d1e41 unchanged; MERGEABLE on main, no Apple material or private serials.
Follow-ups (not blocking): external backlight monotonicity row, non-Apple monitor regression, queued CI
What
Ports Andy Wei's brightness curve work (
3c82dd816251) into the existing external display backlight path so displays reportingSupportsBacklightControlmap levels 1 to 1000 linearly to luminance rather than to raw firmware codes.Levels 1 to 1000 use the sink's reported 16.16 luminance bounds (falling back to 4 to 600 nits) and encode
0x7fe0 * (nits / max)^(3/8)in the upper 16 bits ofbl_value. Level 0, built-in panels, and external displays withoutSupportsBacklightControlkeep their existing behavior. Adds no new backlight device or HID driver.@AndyWeiBoan, please provide your exact
Signed-off-by:and confirm which Studio Display model you measured.Tested
ea492b7d5725, host-tests and all five localrate.pycases passed.Risk
two-way · Macs connected to external displays supporting
SupportsBacklightControl(such as Apple Studio Display); built-in panels and other external monitors are unchanged.Not yet
No hardware meter run on this head yet. Pending: base vs head meter readings at levels 1, 100, 250, 500, 750, and 1000 confirming monotonicity and <=10% error from target nits, plus a non-Apple monitor check.