Repository navigation
drm/apple: colour matrix fixes (two's complement, refused warning, tag names, brightness correction) - #790
Conversation
DRM carries CTM coefficients as S31.32 sign-magnitude. The firmware's set_matrix takes signed two's complement Q31.32, the same encoding the display stack uses for its own conversion matrices. The template copied the DRM matrix unchanged, so any negative coefficient (a saturation change, a gamut conversion) reached the firmware as a huge negative value instead. Positive coefficients have the same bits in both encodings, which is why diagonal CTMs such as night light worked. Convert each coefficient with drm_color_ctm_s31_32_to_qm_n(), which also folds DRM's negative zero to zero, in one helper shared by the template and the J613 backend, which had its own open-coded conversion. Add a host selftest for the identity default, positive pass-through and negative values. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The set_matrix reply was ignored on every firmware family, so a refused CTM left the previous matrix on screen with nothing in the log. Check the reply status in one callback that then continues with the per-family sequence (A428 on H17P, the gamma table on desktop 26.x, else the swap). Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The surface colour primaries and transfer function are the IOSurface indices the firmware takes unchanged. Several names said something else: primaries 12 is P3-D65, not a native space; 0 is unspecified rather than sRGB; 9 is plain BT.2020; transfer 13 is sRGB rather than generic SDR and 16 is SMPTE ST 2084 (PQ) rather than generic HDR. Rename them, add the linear (8) and HLG (18) transfer functions and DCI-P3 primaries (11) used by extended-range and video surfaces, and say in the header what each value is. The values sent are unchanged. The YCbCr mapping in plane.c still sends primaries 1 for BT.601 and 2 for BT.709, although 1 is BT.709 in the IOSurface naming; that is left for a change that can be tested with video. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
On the M2 (13.5 firmware) a CTM sent with set_matrix location 9 is accepted, status 0, but the panel output does not change: a white field with a 0.5 diagonal CTM measures the same as plain white. The status only says the firmware cached the matrix. Every known working sequence follows set_matrix with brightness correction set to identity, 0x10000 (1.0 in 16.16): the H17P path already does so with A428, macOS sends A428 after each Night Shift and True Tone matrix, and the M1 bring-up sequence sends A427 after A422. Send A427 identity after set_matrix on 12.3 and 13.5 too, through one method entry shared with H17P's A428 and one callback for every firmware family that has the method. Desktop 26.x keeps its current sequence. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Hardware evidence from tonight. The merge itself waits for the retarget to integration/aurora, with Ryan. J616s one-shot of 7.3.0-aurora-prr1103c = integration/aurora f153499 + this PR + linux PRs 837 and 731, boot 6a127964. The boot is k -p3 0 with 0 AVCs, and its warning set is identical to fleet14p's. With GNOME Night Light forced on at 3500 K for 10 s, the kernel logged nothing: no refused-matrix warning and no DCP errors. The settings were put back afterwards. The panel was blanked for night rules, so this doesn't show the colour itself, and the M1 Pro/M2 brightness-correction measurement you asked to hold for is still outstanding. On the host, the apple-dcp selftests including the new colorimetry group pass in the aurora-wip test merge. |
|
Merge train (MTL, 06/11), gates passed on test tree 0412501 (integration/aurora 2661d71 + the train):
|
Colour matrix (CTM) fixes, found while checking GNOME night light and an ambient white point on the J616s, M1 Pro and M2.
Tested: J616s on fleet14d with these commits (yellow/white check, kernel -p3 0). The M1 Pro/M2 effect of the brightness correction is not measured yet (the M2's light sensor needs room light; planned for the morning), so please hold the merge for that. Host selftests 85/85, W=1 clean.
🤖 Generated with Claude Code