From ed91cbc6bfcb4cc275e3441e9d181fdaa857c2fc Mon Sep 17 00:00:00 2001 From: Eduardo Date: Wed, 25 Nov 2026 12:03:04 +0000 Subject: [PATCH] drm/apple: m4: colour matrix (CTM) on the internal panel 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 --- drivers/gpu/drm/apple/apple_drv.c | 7 +- drivers/gpu/drm/apple/dcp.c | 3 +- drivers/gpu/drm/apple/iomfb.c | 3 + drivers/gpu/drm/apple/iomfb_m4.c | 86 +++++++++ drivers/gpu/drm/apple/iomfb_m4.h | 10 + .../selftests/drivers/gpu/apple-dcp/README | 10 + .../drivers/gpu/apple-dcp/lifecycle.py | 1 + .../selftests/drivers/gpu/apple-dcp/m4.py | 177 +++++++++++++++++- .../selftests/drivers/gpu/apple-dcp/run.py | 1 + 9 files changed, 290 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index 08c173fc6e8e0..22270fdc41411 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -1959,8 +1959,11 @@ static int apple_probe_per_dcp(struct device *dev, return ret; drm_crtc_helper_add(&crtc->base, &apple_crtc_helper_funcs); - /* T8132 has no qualified CTM transaction. */ - if (!iomfb_is_m4(dcp_data)) { + /* The M4 panel takes a colour matrix and no gamma table. */ + if (iomfb_is_m4(dcp_data)) { + if (iomfb_m4_has_ctm(dcp_data)) + drm_crtc_enable_color_mgmt(&crtc->base, 0, true, 0); + } else { unsigned int gamma_size = dcp_gamma_lut_size(dcp); drm_crtc_enable_color_mgmt(&crtc->base, 0, true, gamma_size); diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index c4934fcb3fef3..6a735369920ff 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -2461,7 +2461,8 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_commit *commi crtc_state = drm_atomic_get_new_crtc_state(commit, crtc); if (!crtc_state) return 0; - if (crtc_state->vrr_enabled || crtc_state->ctm || + if (crtc_state->vrr_enabled || + (crtc_state->ctm && !iomfb_m4_has_ctm(dcp)) || crtc_state->degamma_lut || crtc_state->gamma_lut) return -EINVAL; if (!crtc_state->enable) diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index b507be69895a7..fbfeac6825057 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -5041,6 +5041,9 @@ void dcp_flush(struct drm_crtc *crtc, struct drm_atomic_commit *commit) if (!new || !new->active) return; ret = iomfb_m4_error(dcp); + /* The colour matrix goes with this commit's frame, else the one shown. */ + if (!ret && new->color_mgmt_changed && iomfb_m4_has_ctm(dcp)) + ret = iomfb_m4_set_ctm(dcp, new->ctm ? new->ctm->data : NULL, !plane); /* A CRTC-only commit publishes no new framebuffer. */ if (!ret && plane) { /* A notch-free mode is scanned out below the notch rows. */ diff --git a/drivers/gpu/drm/apple/iomfb_m4.c b/drivers/gpu/drm/apple/iomfb_m4.c index dd3e573e89044..bb93b0680faf3 100644 --- a/drivers/gpu/drm/apple/iomfb_m4.c +++ b/drivers/gpu/drm/apple/iomfb_m4.c @@ -218,6 +218,13 @@ struct iomfb_m4 { struct drm_framebuffer *uncertain_fb; struct dcp_m4_frame active_frame; u64 flips, blanks, brightness_swaps; + /* + * The internal panel's colour matrix as the firmware takes it, whether + * the CRTC ever asked for one (until then the firmware keeps its own), + * and whether the next frame sends it + */ + u64 ctm[9]; + bool ctm_set, ctm_pending; struct delayed_work idle_cache; /* * Framebuffer references a window let go of, put @@ -3570,6 +3577,78 @@ static int iomfb_m4_swap(struct iomfb_m4 *dcp, const struct dcp_m4_frame *frame) return ret; } +/* + * Send the pending colour matrix, before the swap that is to show it: set_matrix + * (A423) at location 9, as iomfb_v26_6.c does. A refused matrix leaves the + * previous one in place and the frame goes out all the same; only a transport + * failure, which has failed the session, is returned. + */ +static int iomfb_m4_send_ctm(struct iomfb_m4 *dcp) +{ + struct iomfb_set_matrix_req req = { .location = 9 }; + struct iomfb_set_matrix_resp resp = {}; + int ret; + + lockdep_assert_held(&dcp->lock); + if (!dcp->ctm_pending) + return 0; + memcpy(req.matrix, dcp->ctm, sizeof(req.matrix)); + ret = dcp_m4_runtime_call(dcp->runtime, 423, false, &req, sizeof(req), + &resp, sizeof(resp)); + if (ret) + return ret; + dcp->ctm_pending = false; + if (resp.ret) + dev_warn_ratelimited(dcp->dev, "colour matrix not applied (status %u)\n", + resp.ret); + return 0; +} + +bool iomfb_m4_has_ctm(struct apple_dcp *owner) +{ + return owner->v26_6 && !owner->v26_6->external; +} + +/* + * The CRTC's colour matrix as of a commit (NULL: none), for the commit's own + * frame or, with @present, for the frame on screen presented again. Nothing is + * sent until the CRTC first has a matrix, nor for an unchanged one. + */ +int iomfb_m4_set_ctm(struct apple_dcp *owner, const struct drm_color_ctm *ctm, bool present) +{ + struct iomfb_m4 *dcp = owner->v26_6; + u64 fw[9]; + int ret = 0; + + if (!dcp || dcp->external || !dcp->runtime) + return 0; + dcp_ctm_to_fw(fw, ctm); + mutex_lock(&dcp->lock); + if (!ctm && !dcp->ctm_set) + goto out; + if (!dcp->ctm_set || memcmp(fw, dcp->ctm, sizeof(fw))) { + memcpy(dcp->ctm, fw, sizeof(fw)); + dcp->ctm_set = true; + dcp->ctm_pending = true; + } + /* Blanked or powered down: the frame that powers it up sends it. */ + if (!present || !dcp->ctm_pending || !dcp->active_frame.dva || dcp->display_off || + dcp->gated || dcp->powered_off) + goto out; + ret = dcp_m4_runtime_live(dcp->runtime); + if (!ret) + ret = iomfb_m4_send_ctm(dcp); + if (!ret) + ret = iomfb_m4_swap(dcp, &dcp->active_frame); + if (ret) + dcp_m4_failed(dcp, ret); + else + iomfb_m4_idle_cache_kick(dcp); +out: + mutex_unlock(&dcp->lock); + return ret; +} + /* As iomfb_m4_present(), @dst_y panel rows down: a notch-free frame. */ int iomfb_m4_present_at(struct apple_dcp *owner, struct drm_framebuffer *fb, dma_addr_t dva, size_t mapped, u32 dst_y) @@ -3611,6 +3690,10 @@ int iomfb_m4_present_at(struct apple_dcp *owner, struct drm_framebuffer *fb, dcp->display_on_us_max); } } + if (ret) + goto out; + /* A new colour matrix goes out before the frame it is to be seen with. */ + ret = iomfb_m4_send_ctm(dcp); if (ret) goto out; /* Keep the source before the first work descriptor can become visible. */ @@ -3723,6 +3806,9 @@ static int dcp_m4_set_power_state(struct iomfb_m4 *dcp, bool on) ret = -EIO; dcp_m4_failed(dcp, ret); } + /* The firmware may lose the colour matrix with the display off. */ + if (!ret && !on && dcp->ctm_set) + dcp->ctm_pending = true; /* A display powered back up starts outside the idle cache. */ if (!ret && on) { dcp->runtime->idle_state = 0; diff --git a/drivers/gpu/drm/apple/iomfb_m4.h b/drivers/gpu/drm/apple/iomfb_m4.h index dce9aeec38448..bd8dbb75dc924 100644 --- a/drivers/gpu/drm/apple/iomfb_m4.h +++ b/drivers/gpu/drm/apple/iomfb_m4.h @@ -10,6 +10,7 @@ struct apple_dcp; struct device; struct dentry; +struct drm_color_ctm; struct drm_connector; struct drm_edid; struct drm_display_mode; @@ -89,6 +90,9 @@ int iomfb_m4_present(struct apple_dcp *dcp, struct drm_framebuffer *fb, int iomfb_m4_present_at(struct apple_dcp *dcp, struct drm_framebuffer *fb, dma_addr_t dva, size_t mapped, u32 dst_y); int iomfb_m4_blank(struct apple_dcp *dcp); +/* The internal panel's CRTC colour matrix (DRM CTM; NULL: none). */ +bool iomfb_m4_has_ctm(struct apple_dcp *dcp); +int iomfb_m4_set_ctm(struct apple_dcp *dcp, const struct drm_color_ctm *ctm, bool present); int iomfb_m4_suspend(struct apple_dcp *dcp); int iomfb_m4_resume(struct apple_dcp *dcp); void iomfb_m4_configure_backlight(struct apple_dcp *dcp); @@ -181,6 +185,12 @@ static inline int iomfb_m4_present_at(struct apple_dcp *dcp, struct drm_framebuf return -ENODEV; } static inline int iomfb_m4_blank(struct apple_dcp *dcp) { return -ENODEV; } +static inline bool iomfb_m4_has_ctm(struct apple_dcp *dcp) { return false; } +static inline int iomfb_m4_set_ctm(struct apple_dcp *dcp, const struct drm_color_ctm *ctm, + bool present) +{ + return -ENODEV; +} static inline int iomfb_m4_suspend(struct apple_dcp *dcp) { return -ENODEV; } static inline int iomfb_m4_resume(struct apple_dcp *dcp) { return -ENODEV; } static inline void iomfb_m4_configure_backlight(struct apple_dcp *dcp) { } diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/README b/tools/testing/selftests/drivers/gpu/apple-dcp/README index 633702781763c..58bd1a0bb25d2 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/README +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/README @@ -159,6 +159,16 @@ changed value, a missing or duplicated ID 2, a second preferred element and more elements than the profile allows. This does not show what the firmware reports on hardware. +The m4-panel-ctm case runs the actual colour-matrix, present and blank +functions with a mock set_matrix transport. Nothing is sent until the CRTC +first has a matrix, and an unchanged one is not sent again. A matrix goes out +as set_matrix (A423, location 9, two's complement Q32.32) before the swap of +its commit's frame, or before the frame on screen presented again for a +commit without one; while blanked it waits for the frame that powers the +display up. A refused matrix leaves frames going; a failed transport fails the +session before any swap. Whether the firmware applies the matrix is a hardware +question. + run-native-m4-kms.py defaults to dry run; --compile-only needs libdrm development headers and never opens DRM. Explicit --execute requires root, an exact fresh source/Image/boot identity, the common appledrm module, a stopped display diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py index 2bb432d69584b..a0789d41db657 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py @@ -1942,6 +1942,7 @@ def vrr(root): struct drm_crtc_state *c) { (void)s; (void)c; assert(d->fw_compat == DCP_FIRMWARE_V_27_0); peer_checks++; return d->peer_check; } static int iomfb_m4_error(struct apple_dcp *d) { (void)d; assert(false); return -ENODEV; } +static bool iomfb_m4_has_ctm(struct apple_dcp *d) { (void)d; assert(false); return false; } static int iomfb_m4_get_mode(struct apple_dcp *d,struct drm_display_mode *m) { (void)d; (void)m; assert(false); return -ENODEV; } static unsigned drm_plane_mask(void *p) { (void)p; assert(false); return 0; } diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py index 2609da8596417..71595c1dba119 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py @@ -13,7 +13,7 @@ import zlib from pathlib import Path -from common import block, run_unit +from common import apple_function, block, run_unit HERE = Path(__file__).resolve().parent APPLE = Path('drivers/gpu/drm/apple') @@ -708,8 +708,11 @@ def gate(root): ''' -def blank(root): +def backend(root): + """The actual present/blank and colour-matrix paths over a bounded mock transport.""" backend = (root / APPLE / 'iomfb_m4.c').read_text() + iomfb_h = (root / APPLE / 'iomfb.h').read_text() + core = (root / 'drivers/gpu/drm/drm_color_mgmt.c').read_text() backlight = (root / APPLE / 'dcp_backlight.c').read_text() functions = '\n'.join(block(backlight, name) for name in ( 'bool dcp_backlight_active(', 'int dcp_backlight_dpms(', @@ -742,6 +745,19 @@ def blank(root): typedef int64_t s64; typedef s64 ktime_t; #define max(x,y) ((x)>(y)?(x):(y)) +#define BIT_ULL(n) (1ULL << (n)) +#define WARN_ON(x) ((void)(x)) +#define clamp_val(v, lo, hi) ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v)) +#define dev_warn_ratelimited(d, ...) ((void)(d), printf(__VA_ARGS__)) +struct drm_color_ctm { u64 matrix[9]; }; +''' + block(core, 'u64 drm_color_ctm_s31_32_to_qm_n(') + '\n' + apple_function(root, 'dcp_ctm_to_fw') + '\n' + \ + block(iomfb_h, 'struct iomfb_set_matrix_req {') + ' __attribute__((packed));\n' + \ + block(iomfb_h, 'struct iomfb_set_matrix_resp {') + ' __attribute__((packed));\n' + r''' +_Static_assert(sizeof(struct iomfb_set_matrix_req) == 80, "set_matrix request"); +/* What the firmware saw, in order: M a set_matrix, P a power-up, S a swap. */ +static char events[64]; +static void event(char c) +{ size_t n=strlen(events); assert(n+1lock==1); cache_kicks++; } static unsigned power_offs,power_ons; static int dcp_m4_set_power_state(struct iomfb_m4 *dcp,bool on) -{ assert(dcp->lock==1); if(on) power_ons++; else power_offs++; return 0; } +{ assert(dcp->lock==1); if(on) { power_ons++; event('P'); } else power_offs++; return 0; } +/* The transport of set_matrix: the request as sent, the status to reply. */ +static unsigned matrix_calls; +static u8 matrix_request[80]; +static u32 matrix_status; +static int matrix_error; +static int dcp_m4_runtime_call(void *cookie,unsigned method,bool remote,const void *in, + u32 in_size,void *out,u32 out_size) +{ + struct dcp_m4_runtime *r=cookie; + assert(r->dcp->lock==1 && method==423 && !remote); + assert(in_size==sizeof(matrix_request) && out_size==4); + memcpy(matrix_request,in,in_size); matrix_calls++; event('M'); + /* A failed call fails the session, as dcp_m4_runtime_call_stream() does. */ + if(matrix_error) { dcp_m4_failed(r->dcp,matrix_error); return matrix_error; } + put_unaligned_le32(matrix_status,out); + return 0; +} static int dcp_m4_runtime_live(struct dcp_m4_runtime *r) { return r->dcp->error; } static int iomfb_m4_power_ungate(struct iomfb_m4 *dcp) { @@ -816,6 +853,7 @@ def blank(root): struct dcp_m4_swap_state swap={0}; u32 before=r->dcp->owner->backlight.state.actual; assert(r->dcp->lock==1); + event('S'); assert(!dcp_m4_swap_encode(bytes,sizeof(bytes),++publications,frame,brightness,nits)); assert(!dcp_m4_swap_begin(&swap,publications)); carried_brightness=brightness; carried_nits=nits; @@ -830,8 +868,13 @@ def blank(root): return 0; } ''' + functions + '\n' + '\n'.join(block(backend, name) for name in ( - 'static int iomfb_m4_swap(', 'int iomfb_m4_present_at(', 'int iomfb_m4_present(', - 'int iomfb_m4_blank(')) + r''' + 'static int iomfb_m4_swap(', 'static int iomfb_m4_send_ctm(', 'bool iomfb_m4_has_ctm(', + 'int iomfb_m4_set_ctm(', 'int iomfb_m4_present_at(', + 'int iomfb_m4_present(', 'int iomfb_m4_blank(')) + + +def blank(root): + return backend(root) + r''' int main(void) { for(order=0;order<2;order++) { @@ -913,6 +956,7 @@ def blank(root): assert(fb.refs==1 && !dcp.active_fb); ungate_error=0; power_gate_ms=0; } + assert(!matrix_calls); puts("PASS DPMS-off blank carries zero before delayed work and completes only after both exact receipts"); puts("PASS actual present/blank retain active+uncertain DMA framebuffer references across a missing receipt"); puts("PASS a present while the display is powered off for sleep is refused without a reference"); @@ -922,6 +966,129 @@ def blank(root): ''' +def ctm(root): + """The panel's colour matrix: when set_matrix goes out, what it carries, and its failures.""" + return backend(root) + r''' +#define NEG (1ULL << 63) +static u64 coefficient(int i) +{ u64 v=0; for(int b=7;b>=0;b--) v=v<<8|matrix_request[4+8*i+b]; return v; } +static void expect(const char *seen) +{ if(strcmp(events,seen)) printf("FAIL events %s, expected %s\\n",events,seen); assert(!strcmp(events,seen)); events[0]=0; } +int main(void) +{ + struct drm_format_info fmt={.format=DRM_FORMAT_XRGB8888,.num_planes=1}; + struct drm_framebuffer fb={.format=&fmt,.width=2560,.height=1664,.pitches={10240},.refs=1}; + struct apple_dcp owner={0}; + struct iomfb_m4 dcp={.owner=&owner}; + struct dcp_m4_runtime runtime={.dcp=&dcp}; + /* 4000 K-like: red kept, green and blue lowered, one negative term. */ + struct drm_color_ctm warm={{1ULL<<32,0,0, 0,0xc0000000ULL,0, NEG|0x10000000ULL,0,0x80000000ULL}}; + struct drm_color_ctm warmer=warm; + order=1; + owner.v26_6=&dcp; dcp.runtime=&runtime; + assert(!dcp_bl_init(&owner.backlight.state,500,true,120,false,0)); + assert(iomfb_m4_has_ctm(&owner)); + + /* No matrix asked for (every enable says color_mgmt_changed): nothing sent. */ + assert(!iomfb_m4_set_ctm(&owner,NULL,true)); + assert(!iomfb_m4_set_ctm(&owner,NULL,false)); + assert(!iomfb_m4_present(&owner,&fb,0x10000100000ULL,0x2000000)); + expect("S"); + assert(!matrix_calls && !dcp.ctm_set); + + /* With a frame: the matrix, then that frame's swap. */ + assert(!iomfb_m4_set_ctm(&owner,&warm,false)); + assert(!matrix_calls && dcp.ctm_pending); + assert(!iomfb_m4_present(&owner,&fb,0x10000100000ULL,0x2000000)); + expect("MS"); + assert(matrix_calls==1 && !dcp.ctm_pending); + assert(get_unaligned_le32(matrix_request)==9); /* location */ + assert(coefficient(0)==1ULL<<32 && coefficient(4)==0xc0000000ULL); + assert(coefficient(6)==0xfffffffff0000000ULL); /* -1/16, two's complement */ + assert(coefficient(8)==0x80000000ULL && !matrix_request[76]); /* not null */ + + /* Unchanged (a brightness commit, say): not sent again, alone or with a frame. */ + assert(!iomfb_m4_set_ctm(&owner,&warm,true)); + assert(!iomfb_m4_set_ctm(&owner,&warm,false)); + assert(!iomfb_m4_present(&owner,&fb,0x10000100000ULL,0x2000000)); + expect("S"); + assert(matrix_calls==1); + + /* A commit without a frame: the matrix, then the frame on screen again. */ + unsigned refs=fb.refs; + warmer.matrix[8]=0x40000000ULL; + assert(!iomfb_m4_set_ctm(&owner,&warmer,true)); + expect("MS"); + assert(matrix_calls==2 && coefficient(8)==0x40000000ULL && fb.refs==refs && dcp.active_fb==&fb); + + /* Back to none: the identity goes out. */ + assert(!iomfb_m4_set_ctm(&owner,NULL,true)); + expect("MS"); + for(int i=0;i<9;i++) + assert(coefficient(i)==(i%4==0 ? 1ULL<<32 : 0)); + + /* Blanked: kept until the frame that powers the display up, then sent first. */ + assert(!iomfb_m4_blank(&owner)); + expect("S"); + assert(!iomfb_m4_set_ctm(&owner,&warm,true)); + assert(!events[0] && dcp.ctm_pending); + assert(!iomfb_m4_present(&owner,&fb,0x10000100000ULL,0x2000000)); + expect("PMS"); + + /* Refused: the frame is still shown, and only a new matrix is sent again. */ + matrix_status=2; + assert(!iomfb_m4_set_ctm(&owner,&warmer,true)); + expect("MS"); + assert(!dcp.error && !dcp.ctm_pending); + matrix_status=0; + assert(!iomfb_m4_present(&owner,&fb,0x10000100000ULL,0x2000000)); + expect("S"); + assert(!iomfb_m4_set_ctm(&owner,&warm,true)); + expect("MS"); + assert(matrix_calls==6); + + /* A failed transport fails the session: no swap follows, the frame on screen stays. */ + { + struct drm_framebuffer next=fb; + struct apple_dcp o2={0}; + struct iomfb_m4 d2={.owner=&o2}; + struct dcp_m4_runtime r2={.dcp=&d2}; + o2.v26_6=&d2; d2.runtime=&r2; next.refs=1; + assert(!dcp_bl_init(&o2.backlight.state,500,true,120,false,0)); + assert(!iomfb_m4_present(&o2,&fb,0x10000100000ULL,0x2000000)); + expect("S"); + refs=fb.refs; + matrix_error=-ETIMEDOUT; + assert(!iomfb_m4_set_ctm(&o2,&warm,false)); + assert(iomfb_m4_present(&o2,&next,0x10000300000ULL,0x2000000)==-ETIMEDOUT); + expect("M"); + assert(d2.error==-ETIMEDOUT && d2.active_fb==&fb && fb.refs==refs && next.refs==1); + matrix_error=0; + } + + /* An external DCP has no matrix. */ + { + struct apple_dcp o3={0}; + struct iomfb_m4 d3={.owner=&o3,.external=true}; + struct dcp_m4_runtime r3={.dcp=&d3}; + o3.v26_6=&d3; d3.runtime=&r3; + assert(!iomfb_m4_has_ctm(&o3)); + assert(!iomfb_m4_set_ctm(&o3,&warm,true) && !events[0] && !d3.ctm_set); + } + /* Shown frames restart the idle-cache countdown; nothing here powers down. */ + assert(cache_kicks && !scheduled && !ungates); + (void)cancelled; (void)ons_at_ungate; (void)deferred_kicks; (void)power_offs; + (void)carried_nits; (void)carried_brightness; + puts("PASS no set_matrix until a matrix is asked for, and none for an unchanged one"); + puts("PASS set_matrix (location 9, two's complement Q32.32) goes before the swap that shows it"); + puts("PASS a frameless commit presents the frame on screen again; blanked, the power-up frame carries it"); + puts("PASS a refused matrix leaves frames going; a failed transport fails the session before any swap"); + puts("PASS an external DCP offers no matrix"); + return 0; +} +''' + + # macOS's preferred internal-panel timings (ID 2), horizontal then vertical, in # the profile's field order. The J604's also come from its fixture report. TIMING_FIELDS = ('Active', 'Total', 'FrontPorch', 'SyncWidth', 'BackPorch', diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index a5d887fb62a72..97c7cc07c2f86 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -90,6 +90,7 @@ def main(): ('m4', 'm4-notch-frame', m4.notch, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), ('m4', 'm4-producer-retirement', m4.prepare, ((),), ('-Wno-unused-function',)), ('m4', 'm4-dpms-retirement', m4.blank, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), + ('m4', 'm4-panel-ctm', m4.ctm, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), ('m4', 'm4-power-gate', m4.gate, ((),), ('-Wno-unused-function',)), ('m4', 'm4-dart-consumer', m4.dart, ((),), ('-Wno-unused-function',)), ('m4', 'm4-panel-timing', m4.timing, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')),