Repository navigation
drm/apple: m4: colour matrix (CTM) on the internal panel - #3262
themartiano wants to merge 1 commit into
Conversation
The M4 panel's CRTC has no CTM property, so a compositor's night light has nowhere to put its matrix: aquamarine says "crtc doesn't support CTM" and Hyprland's hyprsunset does nothing. The other 26.x paths have it. Send it with set_matrix (A423, location 9, nine signed Q32.32 coefficients), as iomfb_v26_6.c does: that firmware has this one's method numbers and swap record. Attach a CTM, and no gamma table, to the panel's CRTC, and send the matrix before the swap of the frame it belongs to. A commit without a frame presents the frame on screen again, as a brightness change does. Nothing is sent until the CRTC first has a matrix, nor for an unchanged one. With the display off it waits for the frame that powers it up, and it is sent again after each power-down in case the firmware lost it. External outputs stay as they are. Dylan Ironside wrote the same change independently for omarchy-j604 (patch 0533, "drm/apple: m4: give the internal T8132 panel a colour matrix"): the same call, location and conversion, from a work item after the swap. The m4-panel-ctm host case runs the matrix, present and blank functions against a mock transport. Seen on a J713 (26.6.2) with an earlier tree: the firmware accepts the matrix, hyprsunset at 3500 K turns the panel warm, and it stays so over DPMS off and on. Link: https://github.com/IronsideXXVI/omarchy-j604/blob/main/kernel/patches/0533-drm-apple-m4-give-the-internal-T8132-panel-a-colour-.patch Signed-off-by: Eduardo <git@martiano.me>
f64bbee to
ed91cbc
Compare
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
maralcbr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at ed91cbc6bfcb
Blockers:
- Hardware row at head: the 2026-11-26 J713 rows ran at
f64bbee8c7b5/1b3721363d80, before a rebase that conflicted insideiomfb_m4_present_at()(the function that sends the matrix) andm4.py. Please post a J713 row ated91cbc6bfcb(or a batched M4 candidate containing it unchanged on currentmain), ideally also checking that the warm matrix holds over DPMS off/on, idle-cache entry/exit, and one deep sleep. Once posted, this is ready to approve and merge without a full re-review.
Checked: code is clean with no blockers; no Apple material, no new chip/board/firmware gates, no new parameters, DCO matches author; CRTC color-mgmt attachment, atomic_check, off-to-on enable (color_mgmt_changed), framed and frameless commits, dcp->lock serialization, transport failure vs firmware status refusal, A423 request layout vs iomfb_v26_6.c, power-down re-mark, and host selftests (m4-dpms-retirement, m4-panel-ctm built with -Wall -Werror + ASan/UBSan at head and merged with main 6ee70d49) verified; hosted CI (Apple build and KUnit, Host tests, pr-text) is green at ed91cbc6bfcb.
Evidence
drivers/gpu/drm/apple/apple_drv.c:1962-1966,iomfb_m4.c:3607-3610,dcp.c:2464-2466: CTM-only property is attached solely whereiomfb_m4_has_ctm()is true (v26_6 && !external, both set iniomfb_m4_init()beforecomponent_add()); M4 external outputs still refuse CTM and all M4 outputs refuse gamma/degamma; non-M4 CRTCs are unchanged.drivers/gpu/drm/apple/apple_drv.c:694, 1230-1232&iomfb.c:5041-5046: enables run before planes and setcolor_mgmt_changed = true, so a CTM set while!new->activeis applied on re-enable.drivers/gpu/drm/apple/iomfb_m4.c:3586-3646, 3679-3701: with a frame,iomfb_m4_present_at()sends A423 after power-up and before swap; frameless commits re-presentactive_frameunderdcp->lockand kick idle-cache, matchingiomfb_m4_backlight_work(). Unchanged matrices and initial NULL-CTM commits send nothing.drivers/gpu/drm/apple/iomfb_m4.c:2037-2041, 3598-3604: transport failures fail the session insidedcp_m4_runtime_call_stream()with no swap following; firmware status refusal warns ratelimited and lets frames proceed.drivers/gpu/drm/apple/iomfb.h:452-457vsiomfb_v26_6.c:1590-1596: 80-byte packediomfb_set_matrix_req(location 9 at 0, nine Q32.32 coefficients viadcp_ctm_to_fw()at 4, null flag 0 at 76) matchesiomfb_v26_6.c.drivers/gpu/drm/apple/iomfb_m4.c:3809-3811:dcp_m4_set_power_state(dcp, false)setsctm_pending = truewhenctm_set, covering blank, power-gate, and suspend/resume.- Local host tests (
-Wall -Werror, ASan/UBSan) at head and merged withmain(6ee70d49c228, clean 3-way merge):m4-dpms-retirementPASS (4/4),m4-panel-ctmPASS (5/5). - Hosted CI at
ed91cbc6bfcb:Apple build and KUnitpass,Host testspass,pr-textpass. - Non-blocking notes:
tools/testing/selftests/drivers/gpu/apple-dcp/m4.py:817mocksdcp_m4_set_power_state(), so removingiomfb_m4.c:3809-3811still passesm4-panel-ctm(the blank case only re-sends because it changes the matrix); exercising the real power-state re-mark would close that test gap.iomfb_m4.c:3623-3624returns before saving the matrix when!dcp->runtime(unreachable in practice, but saving first is cheap).
There was a problem hiding this comment.
Verdict: MERGE at ed91cbc
Checked: The CTM property and atomic admission use the same internal M4 predicate. The conversion reuses the existing DRM CTM path, programs an update before its frame, and sends an identity matrix on removal. CRTC-only updates re-present the live framebuffer. Powered-off panels keep the update pending for the next frame. The current-head build, host tests, and DCP KUnit passed.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving at ed91cbc6bfcb. I read the whole diff and found nothing that has to change.
What I checked
- The CTM property and the atomic check use the same test (
iomfb_m4_has_ctm(): a 26.6 M4 pipe that isn't external). Every other CRTC and the M4 external outputs behave as on main. - Nothing is sent until the CRTC first has a matrix, and an unchanged one isn't sent again, so a desktop without night light sees no new call.
- The matrix goes out before the swap that shows it, under
dcp->lock. A commit without a frame presents the shown frame again without taking another framebuffer reference. While the display is off it waits for the frame that powers it up, and each power-down marks it to be sent again. - A refused matrix is warned about and frames go on. A failed call fails the session before any swap, as for the other runtime calls.
- It merges cleanly on main
dc4d6f065001together with #3273, #3261, #2070 and #3951, anddrivers/gpu/drm/apple/compiles there (arm64, GCC,W=1, no warning in a line this PR touches).
Row still owed before merge: J713 on 26.6.2 at this head (or in a batch that contains it unchanged): warm matrix set and cleared, still there after DPMS off/on, after idle and after one deep sleep, 0 new kernel errors. The earlier rows were before the rebase that touched iomfb_m4_present_at().
What: The M4 panel's CRTC has no CTM, so night light (hyprsunset) does nothing. Attach a CTM, with no gamma table, to the panel's CRTC and send it with set_matrix (A423, location 9) before the frame it belongs to, as the firmware 26.6 path of the J613 (
iomfb_v26_6.c) does.Tested: J713 (13-inch M4 MacBook Air, firmware 26.6.2) at
f64bbee8c7b5, 2026-11-26: PASS. The panel's CRTC (38) has a CTM property; a warm matrix (r 1.000, g 0.695, b 0.430) reached it and identity was restored after, in three runs; a person saw the panel turn clearly warm and come back (second run; in the first they were watching the external display, which correctly stayed unchanged). The kernel (7.3.0-0.next2) was mainba29027e1580merged with all our M4 display and other branches and #2814, #2797, #2807, #2672, not this branch alone. This commit's tree is identical to the one booted (1b3721363d80; only the Signed-off-by was added). Regression on that kernel: 0 failed units, no oops, crash or stall, 10/10 deep sleeps without kernel errors (no SELinux on this image). Host: newm4-panel-ctmcase and the apple-dcp host suite 96/96; KUnit 565 run, 563 pass, 1 skip, 1 fail that main has too (apple-dcpaud-no-sio); W=1 build.Rebased onto main
9177b2d474f8on 2026-12-02; head nowed91cbc6bfcb. Conflicts with #2814 iniomfb_m4.c(itsiomfb_m4_present_at()and this PR's matrix functions at the same place; both kept) and in the host casem4.py(the case now also extractsiomfb_m4_present_at()). The newm4-panel-ctmhost case passes. Host checks re-run at the new head: W=1 arm64 build ofdrivers/gpu/drm/apple/, 0 warnings; checkpatch --strict clean; KUnitdcp-fabric,dcp-topology,dcp-display(the suites CI picks for these files) on arm64 QEMU: no failures (one case skips in each of two suites); apple-dcp host suite, no new failures (14 cases fail to compile with this container's newer compiler on main itself, and the same 14 here). The hardware rows above are from before the rebase.Risk: two-way door · M4 internal panels on firmware 26.6.2 (J713, J715, J604). Other Macs: the CTM is attached only where
iomfb_m4_has_ctm()is true (an M4 26.6 pipe that is not external); every other CRTC keeps the CTM and gamma table it had, and M4 external outputs still refuse a CTM. Today's DTs enable the M4 DCP on J604, J713 and J715. On those, night light starts working; nothing is sent until userspace sets a matrix, so a desktop without one is unchanged.Not yet: a matrix held across DPMS, the idle cache and a deep sleep at this head (DPMS off and on was seen on an older tree); whether A428 (#3076, T6041) is needed on this firmware: this sends A423 only, as
iomfb_v26_6.cdoes, and the panel visibly changed.Details
m4-panel-ctmhost case runs the matrix, present and blank functions against a mock transport.Credit: Dylan Ironside wrote the same change independently for omarchy-j604 (patch 0533): the same call, location and conversion, from a work item after the swap. Linked in the commit.
Evidence
J713 test runs of 2026-11-26 on 7.3.0-0.next2 (one display run, two repeats):
Host, at the old head
1b3721363d80(same tree): apple-dcp host suite 96/96 (newm4-panel-ctm); KUnitapple*on arm64 QEMU 565 run, 563 pass, 1 skip, 1 fail (apple-dcpaud-no-sio, fails on main too); W=1 build clean; checkpatch--strictonly asked for the Signed-off-by (now added).