Skip to content

drm/apple: follow the Studio Display's brightness curve on the external backlight (Andy Wei's fix, ported) - #2098

Open
joshuaswarren wants to merge 4 commits into
aurora-silicon:mainfrom
joshuaswarren:dhp4/andy-studio-brightness-aurora
Open

joshuaswarren wants to merge 4 commits into
aurora-silicon:mainfrom
joshuaswarren:dhp4/andy-studio-brightness-aurora

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Ports Andy Wei's brightness curve work (3c82dd816251) into the existing external display backlight path so displays reporting SupportsBacklightControl map 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 of bl_value. Level 0, built-in panels, and external displays without SupportsBacklightControl keep 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

  • At ea492b7d5725, host-tests and all five local rate.py cases passed.
  • The three changed driver object files compiled for arm64.
  • A host probe checked monotonicity across all 1000 nonzero levels for five luminance ranges, with the six sampled levels within 4 code units of the formula.

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.

@joshuaswarren

joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

CHANGES on 039993a

Compared with Andy's three commits (cb29890, 1207a4c, 3c82dd8).

Faithful. drivers/hid/hid-apple-display.c is byte-identical to Andy's file after his first two commits. The drivers/gpu/drm/apple hunks match his third commit, apart from the differences the body lists and the ones below. The Kconfig and Makefile hunks match.

Findings (the text must say what the code does):

  1. Reach is wider than the body says. The external flag is set for every DCP with no apple,panel child and a fixed connector type other than eDP. That includes Type-C DCPs (fixed type USB) and HDMI outputs, not only DisplayPort Studio Displays. ext_bl_force_register defaults to true, so on every machine any connected external monitor, Apple or not, gets a backlight device from the hotplug handler, and brightness writes go into the swap's bl_value. The body says "an external DisplayPort panel" and "the shared DCP backlight and swap path". Either gate the flag on an Apple display (EDID vendor), or say plainly that every external output on every machine is affected and what a non-Apple monitor does with bl_value. Andy's original has the same reach, so this is a text finding at minimum.

  2. The HID driver registers a writable backlight that does nothing. The body says hid-apple-display is added "to read the brightness the display reports". The driver also registers apple-display with an update_status that writes the report. By Andy's own account the display echoes the write and does not change. A Studio Display would then show two backlight devices, apple-display (inert) and apple-dp-bl-DP-1 (works), and a brightness tool that picks the first sets nothing. Make the HID backlight read-only, or state the limit and the double device in the body and in the Kconfig help. The Kconfig help says the driver gives brightness control, which is untrue by the same account.

  3. One commit mixes HID and DRM. Andy kept the HID driver and the DRM change in separate commits. The squash gives one HID, drm/apple: subject and a message that covers only the DRM commit. HID changes go to the HID maintainers, so split it into a HID commit and a drm/apple commit. The squash does fix a real conflict in his history: his first HID message says writes move the brightness, and his two later messages say they do not.

  4. Debug logging stays on for built-in panels. The port keeps dev_info() in dcp_set_brightness(), in dcp_backlight_register() and in the swap path (swap carries bl_value). They are not limited to external panels, so every brightness key press on a built-in panel now logs at info level on every machine. The body mentions only the H17 bl_value line. Gate them on brightness.external or use dev_dbg().

  5. Contradictory comments. The dcp_hotplug() comment says external DCPs "do not necessarily publish IOMFB_PROPERTY_NITS". The iomfb_cb_pr_publish() comment says external panels "publish this too". Andy's commit says they never publish it. Settle on one and fix the other.

  6. Unsourced claim. "Andy's testing was on an M1 Pro (t600x)" is not in any of his three commit messages. Cite it or drop it. "Checked by eye at five levels" is in his message and fine.

Checked and fine: the unconditional cancel_work_sync() of bl_register_wq and bl_update_wq in dcp_comp_unbind() is safe, because this tree initialises both in the probe before bind, so the port correctly drops Andy's move of the INIT_WORK lines. The curve interpolation stays in range (clamp to 4..600, 65 entries, code << 16 tops out at 0x7fe00000). The branch is based on the current head of integration/aurora, and git diff --check is clean. I did not rebuild or boot this; the build result is the PR's own claim.

@joshuaswarren
joshuaswarren force-pushed the dhp4/andy-studio-brightness-aurora branch from 039993a to b9f460a Compare November 16, 2026 19:19
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[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.

@joshuaswarren

joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

  • The split is right: a HID commit first, then a drm/apple commit. hid-apple-display.c is still byte-identical to Andy's file after his first two commits.
  • The log lines are dev_dbg. The nits-publish path is back to the base's dcp_has_panel() check.
  • The EDID gate is correct on the value: "APP" encodes as 0x0610, and edid_maker is read with get_unaligned_be16().
  • The body now says what the flag covers and drops the unsourced M1 Pro claim. It also lists the EDID timing risk under NOT CHECKED.

1. A second external backlight path already exists on this tree (blocks). integration/aurora already registers dcp-<connector>-bl for external displays that report SupportsBacklightControl (dcp->ext_backlight, such as the Studio Display; not on 14.7 firmware). It writes bl_value in the same swap, in iomfb_template.c, and it consumes the same dcp->brightness.update flag. This PR adds a second device, apple-dp-bl-<connector>, with a different meaning for the same field. The base comment says bl_value is a signed 32-bit level from 0 to S32_MAX that DCP converts for the display. This PR says it is a 16-bit code in the upper half, on a curve. The body does not mention the existing path. On a Studio Display both can be live. The swap code consumes brightness.update once, so whichever block runs first decides which value the swap carries and the other is dropped or overwritten. Say which path is right for this display and make the PR use that one (extend dcp-*-bl, or replace it), instead of adding a second.

2. The new device names break an ordering the base relies on (blocks). The base names its external backlight dcp-%s-bl on purpose, with this comment: "Sorts after the integrated panel's apple-panel-bl in any locale: userspace that takes the first backlight as the built-in screen's (Omarchy's omarchy-hw-display) keeps the panel." Sorted names on a machine with a Studio Display attached are apple-display, apple-dp-bl-DP-1, apple-panel-bl, dcp-DP-1-bl. Both new names sort before apple-panel-bl. A tool that takes the first backlight now picks the inert HID one, or the external display, instead of the built-in screen. That is a regression of a documented property, and it happens with the Kconfig option off too for apple-dp-bl-*.

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 dcp_hotplug() and only decides whether to register. The device is registered with devm_backlight_device_register() and I found no unregister on disconnect: the unregister sites are at unbind (dcp.c, the bl_dev cleanup) and in the 14.7 path. edid_maker is also never cleared on disconnect. So after an Apple display has been connected on a DCP, apple-dp-bl-* stays, and a non-Apple monitor plugged in later gets the flush block (external && bl_dev && dac), so it receives bl_value. This is from reading the code. I did not reproduce it.

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 apple-display sorts first of all backlights (finding 2), so a first-pick tool lands on the inert one. A warning in help text does not help a tool. Second, the Kconfig help is now wrong: it says to use the apple-dp-bl-* device and says "both devices appear", but a Studio Display can show three (apple-display, apple-dp-bl-*, dcp-*-bl). My recommendation is to take the HID commit out of this PR, or make it not register a backlight class device (expose the level as a read-only attribute). The commit message also still carries Andy's first message, which says writes move the brightness, above his second message, which says they do not. Drop the first text or mark it superseded.

The branch is based on the current head of integration/aurora and git diff --check is clean. I did not rebuild or boot this; the build result is the PR's own claim.

@joshuaswarren
joshuaswarren force-pushed the dhp4/andy-studio-brightness-aurora branch from b9f460a to 05987dd Compare November 16, 2026 19:28
@joshuaswarren joshuaswarren changed the title HID, drm/apple: Studio Display brightness over HID and IOMFB (Andy Wei's fix, ported) drm/apple: follow the Studio Display's brightness curve on the external backlight (Andy Wei's fix, ported) Nov 16, 2026
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[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.

@joshuaswarren

joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

CHANGES on 05987dd

Re-review of the reduced version. The earlier findings are closed: one backlight device (dcp-<connector>-bl), no HID commit, no module parameters, no change to the built-in panel's bl_value, and edid_maker is now cleared in dcp_clear_connector_edid(). One new finding blocks. It comes from reading the code; I did not boot anything.

Blocking: edid_maker is set on one board only, so the curve is dead code everywhere else. The new gate is READ_ONCE(connector->edid_maker) == DCP_EDID_MFG_APPLE in dcp_ext_backlight_value(). The only writer is dcp_note_edid() (iomfb.c), and both of its call sites sit inside if (dcp->hw.link_report). That flag is true only in apple_dcp_hw_t6050_dcpext, and dcp_probe clears it unless dcp_j714s_ext() holds (apple,j714s and apple,t6050-dcpext). On every other machine edid_maker stays 0, so a Studio Display there keeps the linear mapping and this PR changes nothing. The body says edid_maker is "only set when the EDID arrives and printed in a log line"; it leaves out this condition, and its "Reach" line ("external displays that report SupportsBacklightControl and have the Apple EDID manufacturer") is wrong as written. The board where the curve does fire is also one where the body says the curve was not compared with the existing mapping.

Fix, either: (a) call dcp_note_edid() on every EDID publication and keep hw.link_report only on the log line in dcp_link_report(); or (b) read the manufacturer from the connector's published EDID at the point of use, instead of a cached copy. Then say in the body which machines are affected. Option (a) also makes the new WRITE_ONCE(..., 0) in dcp_clear_connector_edid() do something on those machines.

Checked and fine.

  • The table has 65 entries, rises strictly, and sits within 0.005% of a pure code ~ nits^(3/8) curve anchored at 0x7fe0 for 600 nits, so the "stretched curve" description matches the data.
  • interpolate_u16(): the largest intermediate is 64 * 596 * 1024, about 39M, so no u32 overflow. The result tops out at 0x7fe0 << 16 = 0x7fe00000, below S32_MAX, so the s32 return is safe.
  • Level 0 and levels on non-Apple EDIDs keep the old mapping. H17P external and bl_level < 0 still return -1 before the new code.

Notes, not blocking.

  • interpolate_u16() copies interpolate() (dcp_backlight.c:626) except for the element type. Store the table as u32, or let interpolate() take a const u16 *, and drop the copy.
  • If the EDID arrives after the first level is written, that swap carries the linear value and brightness.update is already consumed, so the curve applies only from the next level change. The body lists this under NOT CHECKED. The fix above does not remove it.
  • The body's open question (curve versus existing mapping on a Studio Display) is stated honestly. The code cannot answer it; it needs a measurement.

The branch is based on the current head of integration/aurora, it is one commit, and git diff --check is clean. I did not rebuild or boot this; the build result is the PR's own claim.

@joshuaswarren
joshuaswarren force-pushed the dhp4/andy-studio-brightness-aurora branch from 05987dd to fa7b021 Compare November 16, 2026 19:32
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[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.

@joshuaswarren

joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Review at head fa7b021 — draft, not booted.

Checked the asked-about points plus the EDID lifecycle:

  • interpolate() edge at 600 nits: correct. level=1000 → nits=600 → early return of the last entry, so interpolate() only ever sees nits ≤ 599 → index ≤ 63, the WARN is unreachable. level=1 → nits=4 → index 0. level=0 skips the curve entirely (linear → 0), same as before — no regression.
  • Curve shape: endpoints consistent with the panel's nits∝code^(8/3) claim (600 nits→0x7fe0, 4 nits→0x1388 ≈ 2973·nits^0.375). Monotonic across all 65 entries.
  • dcp_note_edid() on every publication: fine. Runs under mode_config.mutex, is a 128-byte crc32 + three WRITE_ONCE stores, and every drm_edid on these paths comes from drm_edid_alloc so drm_edid_raw() can't be NULL in practice — the early return is defensive only.
  • First swap before EDID: edid_maker is 0 until first publication → linear mapping. Correct.

Findings:

  1. edid_maker is now a functional input, but four EDID-retraction paths bypass dcp_clear_connector_edid() and leave it (plus edid_product/edid_crc) stale: the unrouted-port path in dcp_hotplug (~iomfb.c:1909), the !pdev early return in dcp_get_modes (~2675), the derived-EDID retract when metadata goes stale (~2809), and the derived-failure retract (~2825). After any of those, a connector with no published EDID still reports maker=APP and dcp_ext_backlight_value keeps applying the Studio curve until the next publication. Suggest zeroing the identity fields at those sites (or routing them through a shared clearer).

  2. Coverage depends on which EDID path the machine takes. Raw EDIDs give mfg "APP" → 0x0610. Firmware-derived EDIDs synthesize the manufacturer from metadata->manufacturer (dcp_metadata_block in dcp-display-metadata.c), which must also be "APP" for the Studio Display or the curve silently never applies. Worth confirming which path T6050/M5 externals take and what the firmware reports — unverified until boot.

  3. Question: maker==0x0610 matches every Apple-branded external (Pro Display XDR included), not just Studio Display. XDR's nits range differs; if it ever lands on this path the 4–600 curve may be wrong for it. Consider whether product code or a name check is warranted, or confirm XDR doesn't reach dcp_ext_backlight_value.

@joshuaswarren
joshuaswarren force-pushed the dhp4/andy-studio-brightness-aurora branch from fa7b021 to f1b2dee Compare November 16, 2026 20:08
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] For @AndyWeiBoan, and an update for the reviewers. New head f1b2deed (one commit, rebuilt; the tree compiled with clang over drivers/gpu/drm/apple/, not booted).

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 APP, product code 0. So a test on the EDID maker, or on maker plus product, cannot tell us it is a Studio Display on that machine, and the curve in this PR would not be applied there.

What is next: a tester will read the raw DisplayAttributes of the Studio Display connector (ManufacturerID, ProductID, ProductName) with the existing debugfs file, no reboot. Then the test moves to that firmware data. Until then the gate is not changed and this PR is not asking for another review.

Andy: your curve table has no Signed-off-by in the original commits, and the port needs yours. Please add it here if you are fine with the port. Also, can you say which Studio Display you measured the curve on (2022, 2026, or the XDR)? That decides how narrow the test has to be.

…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]>
@joshuaswarren
joshuaswarren force-pushed the dhp4/andy-studio-brightness-aurora branch from f1b2dee to ff8d1e4 Compare November 16, 2026 20:21
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] New head ff8d1e41 (one commit), for @AndyWeiBoan and the reviewers. It answers the review's three findings.

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 APP and product 0xAE3A, not by an EDID maker. A tester read that identity from the display's DisplayAttributes on the 14-inch M5 Max MacBook Pro (boot e115ac34): ManufacturerID APP, ProductID 0xAE3A, ProductName StudioDisplay, 2022. The same display has an empty sysfs EDID there, so the earlier EDID test could never have matched on it. The built-in panel is APP with product 0 and does not match; a Pro Display XDR has another product code and keeps the linear mapping.

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; iomfb.c is untouched.

Tests: five identity cases in the existing host test (metadata-decoder), written first (it failed to compile without the function), then passing; three mutants of the function fail it. The glue is compile-only. Built with clang, no warnings; not booted with this change.

Open: only the 2022 model is covered; the first swap after connect, before the firmware's attributes arrive, uses the linear mapping.

@joshuaswarren

joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Re-review at head ff8d1e4 — the answer to my fa7b021 review. Verdict: GREEN.

All three earlier findings are resolved:

  • Identity: dcp_metadata_is_studio_display requires manufacturer == "APP" (strncmp bounded at sizeof(char[4]), so exactly "APP\0") AND product == 0xae3a (u32 — no 16-bit folding; the rate.py case with 0x1ae3a proves it). Firmware identity replaces the EDID maker entirely, so the stale-EDID-on-retract problem is gone by construction and iomfb.c is untouched. First swap before attributes arrive: attributes_valid is false → gate returns false → linear mapping, matching the commit message. When attributes land, the next pending brightness update converges to the curve — a one-time step is possible but bounded and self-corrects.
  • Gate locking: dcp_firmware_metadata_studio_display is the same predicate dcp_firmware_edid uses for attributes — attributes_valid && dcp_metadata_matches(epoch, attributes_ticket) under spin_lock_irqsave(&dcp->metadata.lock), with dcp_firmware_metadata_enabled checked outside the lock exactly like every sibling. dcp_metadata_matches requires ticket.associated && epoch->connected && !invalidated && generation match, so a display swap invalidates the identity correctly.
  • Call context: the only caller is dcp_ext_backlight_value from do_swap in iomfb_template.c — commit-tail context where spin_lock_irqsafe is required and sufficient. metadata.lock is a leaf lock (field reads/writes only, no outbound calls while held), so no lock-order inversion.
  • interpolate edge: nits is clamped — nits >= 600 returns ext_brightness_code[64] << 16 directly; for nits in [4,599] the index math tops out at index 63 with index+1 = 64 < 65, so the WARN path is unreachable. level > DCP_EXT_BL_MAX also lands on the capped last entry — safer than the linear path's truncation.

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.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for reducing this to the curve; the identity check and locking look right. Two points:

  1. The curve is chosen by one product code (dcp-display-metadata.c, 0xae3a). If bl_value is the panel code on a code^(8/3) curve, that is a property of the field, so it holds for every display that takes it. The linear mapping in dcp_ext_backlight_value() would then be wrong for all of them. Could you apply the curve to every display that reports SupportsBacklightControl? Compute it from the stated formula (code = 0x7fe0 * (nits/max)^(3/8)), and take max/min from the DisplayAttributes max_luminance/min_luminance when the display reports them, falling back to 4..600 nits otherwise. That covers the newer Studio Display and the XDR without a product list.

  2. Which mapping is right needs a measurement. Row: a Studio Display, luminance meter at levels 1, 100, 250, 500, 750 and 1000, first on the base and then on this head. Pass: monotonic, and the measured cd/m2 is within 10% of the nits the level maps to. Then a non-Apple monitor shows no change.

Andy's Signed-off-by (already asked) is the other open item.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent]

1: Agreed: product code 0xae3a alone is too narrow if bl_value is already on the panel's EDR^(3/8) curve. Next push generalizes: any display with SupportsBacklightControl gets code = 0x7fe0 * (nits/max)^(3/8) with max_luminance/min_luminance from DisplayAttributes when present, else 4..600 nits fallback.

2 (measurement): We have not run Ryan's luminance-meter row on either base or this head. Carried Andy Signed-off-by remains open.

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 + brightnessctl steps with logged bl_value and dcp curve output (w7C, after M5 back).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks. The head is still ff8d1e4, so we'll wait for the push you described. To restate what it needs:

  • Apply the curve to every display that reports SupportsBacklightControl, not one product code (dcp-display-metadata.c, 0xae3a). Compute code = 0x7fe0 * (nits/max)^(3/8), take max/min from DisplayAttributes max_luminance/min_luminance when the display reports them, and fall back to 4..600 nits otherwise.
  • A meter row on a Studio Display at levels 1, 100, 250, 500, 750 and 1000, on the base and then on the head. Pass: monotonic, and within 10% of the mapped nits. Then show that a non-Apple monitor is unchanged.
  • Andy's Signed-off-by:.

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]>
@joshuaswarren

joshuaswarren commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@RyanTheTide

Copy link
Copy Markdown
Contributor

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:

  • Squash the two commits so the product-code table never lands. Keep Andy's origin link.
  • interpolate() lost its const (dcp_backlight.c:627), and nothing needs that now. Please restore it.
  • Level 1 now maps to the reported minimum. The test sink reports about 0.08 nits, and a reported 0 gives code 0, the same as level 0. Please include level 1 in the meter row. If it reads dark, floor the minimum at 4 nits.
  • Meter row on a Studio Display at levels 1, 100, 250, 500, 750 and 1000, base then head. Then show that a non-Apple monitor is unchanged.
  • Andy's Signed-off-by:.

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.
@joshuaswarren

joshuaswarren commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

c10f0eacec54c restores const on the interpolation table. The extracted helper failed to compile with a read-only table before the change and passed after it.

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.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

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 (c10f0eacec54). Fixture: Studio Display, one non-Apple monitor, one light meter.

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.

@AndyWeiBoan

Copy link
Copy Markdown

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).

@RyanTheTide

Copy link
Copy Markdown
Contributor

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

  • It conflicts with main. Merge main in or rebase (no force push needed: a merge commit is fine).
  • Then a test run at the final head on a Mac with the hardware it touches, and 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.

@joshuaswarren
joshuaswarren marked this pull request as ready for review November 28, 2026 11:41
@joshuaswarren
joshuaswarren requested review from a team as code owners November 28, 2026 11:41
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T11:41:48.072919Z
We couldn’t complete this review. Comment @codex review to try again.
594a05c Draft marked ready
🔒 Security Review ❌ Failed 2026-11-28T11:41:55.034464Z
We couldn’t complete this review. Comment @codex security review to try again.
594a05c Draft marked ready
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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.

@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: FINISH, then merge at 594a05cf

Blockers:

  1. Missing exact-head 594a05cf hardware verification rows (external display backlight monotonicity/luminance check plus non-Apple monitor regression check, as listed under Not yet).
  2. Queued CI checks (apple-build, host-tests, kunit, pr-text, readiness, KUnit suites) are still pending; wait for green CI.

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.
Evidence
  • Head: 594a05cf (base: main, mergeable: MERGEABLE, +57/-14 across 6 files).

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

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 594a05cf: not ready yet

Check Detail
CI at head ok 21 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 594a05cf, a Mac and a result in the PR body or a comment
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · Macs connected to external displays supporting SupportsBacklightControl (such as Apple Studio Display); built-in panels and other external monitors are unchanged.

Areas: area:display

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

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026

@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 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

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 1, 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

area:display Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (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.

3 participants