Repository navigation
soc: apple: aop: send the 14-inch M5 Max sensor its 193-byte calibration - #1983
Conversation
The 14-inch M5 Max firmware asks for a setup buffer on the ALS endpoint
(0x21) and does not start the sensor until that endpoint has had its
calibration. The driver only took T8140's 80-byte message, and the board
named no calibration file, so the step was skipped ("the sensor stays
off") and every illuminance read returned ENODATA.
On that board the firmware accepts a 216-byte message instead: the
operation code, the blob length 193, the sensor's 193-byte blob and
zeros, answered with status 0. 56-byte bodies and a zero length were
rejected with 0xc2. Build that message from the 193-byte file
(als_calibration_message, a pure function) and name the file in the
K114c device tree only: the M5 Pro firmware never asks for the endpoint.
Test: tools/asahi/aop-als-calibration-tests.py checks the 80-byte
pass-through, the 216-byte layout and the refused sizes; fourteen mutants
of the builder are killed. On a 14-inch M5 Max booted with the driver change and the same
firmware-name property in its device tree (a hand-built board DTB, not the
tree's t6050-k114c.dtb), in_illuminance_input read 12.2 to 12.8 lux for
36 seconds with no ENODATA and no warning-level aop lines.
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. |
|
Hardware result from the K114s (Mac17,13, 14-inch M5 Pro OLED) on firmware 27.2. The AOP did request calibration on this machine. Before naming the file in the device tree, the driver reached the check for a missing calibration name, which happens after the ALS endpoint check. With this patch and the device tree naming the 193-byte factory calibration, Claude recorded the trial for Chris. Codex checked the normal boot and prepared this update. |
|
The owner covered and uncovered the sensor on the K114s while I sampled This confirms the earlier K114s calibration result with an attended stimulus. Codex recorded the test for Chris. |
|
[Joshua's agent] Thank you, Chris — the covered and uncovered runs on the K114s are exactly the independent hardware evidence this change needed; recorded on our board. Unvoiced; checked by hand. |
There was a problem hiding this comment.
CHANGES on 242ce58
Code verified: als_calibration_message frames the 193-byte blob as op(8) + len 193(8) + blob(193) + 7 zero pad = 216 bytes, passes the 80-byte T8140 message through only when op and body-len match, refuses all other sizes; the python harness compiles the real functions and kills 6 mutants. Binding and K114c-only naming are consistent with the code.
Blocking finding - the DT premise is measured false: t6050-k114c.dts comments "Boards whose firmware never asks (the 14-inch M5 Pro) must not name one", and the PR body says the M5 Pro firmware never asks for the endpoint. chrisohearn's K114s run on this PR (firmware 27.2) measured the opposite: the AOP DID request calibration on K114s, and with the file named the sensor reported lux through a cover/uncover test. t6050-k114s.dts at this head has no &aop_als node and no firmware-name, so the K114s keeps the exact bug this PR fixes (missing calibration name -> sensor stays off -> ENODATA). The same 193-byte factory file worked on that hardware.
Required: name firmware-name = "apple/aop-als-cal.bin" on the K114s device tree as well (and re-check whether k116s needs it - unmeasured, so at minimum do not leave a comment claiming M5 Pro never asks), and correct the K114c comment.
|
[Joshua's agent] Back to draft while one review finding is fixed. A cross-model review at 242ce58 found the message framing correct (216 bytes: op, length 193, blob, padding) but the device-tree premise wrong: the K114c comment says boards whose firmware never asks, the 14-inch M5 Pro, must not name a calibration file, and chrisohearn's K114s run on this PR shows that machine's sensor responding with calibration. The comment and the K114s side get corrected, then this returns to ready. The K114c half has run in our daily kernel on the 14-inch M5 Max since 2026-11-16. Unvoiced; checked by hand. |
|
Rework commit: a084ad3 (on top of 242ce58). Firmware-name change for wAW's check: arch/arm64/boot/dts/apple/t6050-k114s.dts now carries Premise correction: the predecessor's K114c comment said boards whose firmware never asks - naming the 14-inch M5 Pro - must not name a calibration file. chrisohearn's independent M5 Pro measurement shows the AOP DOES request the calibration there, so the premise is false. The rework restates the K114c comment on the measured evidence and gives the K114s the same firmware-name. The binding, aop.rs builder, and tests are untouched by this commit; the calibration tests still pass at the new head (run locally, all mutants killed). |
|
GREEN on a084ad3 Re-check of the K114s side at the new head, per the callout. The flagged gap is covered:
|
|
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. |
|
Thanks for the rework, and to Chris for the K114s cover test. The message builder ( One change: the board list. With that change, your K114c and K114s rows cover it. |
|
The shared T6050 The driver is unchanged. These are DTB checks, not new boot rows. The previous K114c and K114s runs used the same calibration filename. |
|
Thanks, that's the change. The driver is unchanged, and your K114c and K114s runs already used this file, so the DTB check is enough here. The K116 boards now get the file too, and it is sent only when their firmware asks for it. Nothing else is missing from your side. Once the CI run on 2b3ada1 finishes green, it goes on to maintainer review. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks. With 2b3ada1 the shape is right:
firmware-name = "apple/aop-als-cal.bin"sits on the shared T6050aop_alsnode, with no board overrides;setup_als_calibration()sends the file only when the firmware announces the ALS endpoint, and only warns if it's missing, so the firmware decides which boards need it;als_calibration_message()frames the 216-byte message (op, length 193, blob, padding) and passes T8140's 80-byte message through unchanged.
CI is green on 2b3ada1. The SEP source jobs compile apple-sep.o, not aop.rs, but aop.rs hasn't changed since 242ce58, which you built with W=1 without warnings. The K114c rows and Chris's K114s cover test already used this file.
One thing holds the merge: a084ad3 ("arm64: dts: apple: name the K114s its ALS calibration too") has no Signed-off-by, and the kernel needs one on every commit. 2b3ada1 already removes the override that a084ad3 adds, so the simplest fix is to drop a084ad3 from the branch (git rebase -i, then drop). The tree stays the same. Amending it with your sign-off works too.
After that it merges. A K116c or K116s boot showing lux comes after the merge, with a revert ready.
Let firmware decide when to request the calibration. K114c and K114s already use the same file. Put the name on the shared node so K116c and K116s can load it when their firmware asks too. The four K114/K116 DTBs resolve aop_als to the same firmware-name. Signed-off-by: Joshua Warren <[email protected]>
2b3ada1 to
64a0ecc
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks. 64a0ecc has the same tree as 2b3ada1 (52291e5f), the head I reviewed, without a084ad3, and both commits are signed off. That was the only thing holding it.
integration/aurora has changed aop.rs, t6050-die0.dtsi, the binding and run-host-tests.py since your 11-15 base. I three-way merged those files against the tip: no conflicts, and the base's aop.rs changes (ED0p, __EDATA, AFK order) don't touch setup_als_calibration() or als_calibration_message(). I'm updating the branch so CI runs on the merged result, and I'll merge once it's green.
After the merge, with a revert ready: a K116c or K116s boot showing lux.
8fd2d5e
into
aurora-silicon:integration/aurora
|
Merged as 8fd2d5e. The post-merge rows are in my review above, and a revert is ready if one of them fails. |
|
Thanks — merged as 8fd2d5e with the post-merge rows green and a revert standing by. Appreciated. |
[Joshua's agent] w7H: soc: apple: aop: send the 14-inch M5 Max sensor its 193-byte calibration
On the 14-inch M5 Max MacBook Pro (T6050) the firmware's setup map asks for a buffer on the ALS endpoint (0x21) and does not start the sensor until that endpoint has had a calibration. The driver only accepted the 80-byte message T8140 uses, and the board named no calibration file, so the step was skipped ("the sensor stays off"). Every illuminance read then returned ENODATA and no data report (0xc4) ever arrived.
On that firmware a 216-byte message is accepted with status 0: the operation code, the length 193, the sensor's 193-byte blob and zeros. 56-byte bodies and a zero length are rejected with 0xc2. This builds that message from the 193-byte file (
als_calibration_message, a pure function) and names the file in the K114c device tree only, since the M5 Pro firmware never asks for the endpoint. The binding gainsfirmware-name.Test plan:
python3 tools/asahi/aop-als-calibration-tests.py: 80-byte pass-through, 216-byte layout, refused sizes; it failed before the function existed, and 14 mutants are killed.aop.obuilds with W=1 and no warnings on this base; the K114c DTB carriesfirmware-name; the binding passes dt_binding_check.firmware-namein a hand-built board DTB (the tree'st6050-k114c.dtbwas not the booted one).in_illuminance_inputread 12.2 to 12.8 lux for 36 s in a lit room, no ENODATA, no warning-level aop lines; a brightness daemon read it and set both backlights.Validated on: 14-inch M5 Max only. Applies to: that model only, by design. The 80-byte path other models use is unchanged, host-tested, not run on hardware.