From 228f5569a9fedfe5e5532a4ad7e920ba29765301 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 30 Nov 2026 19:36:29 +1100 Subject: [PATCH] drm/apple: offer a firmware 27 ProMotion panel's fixed rates as paced modes Firmware 27 lists the T6050 internal panel's fixed rates next to its 120 Hz timing: 60, 59.94, 50, 48 and 47.95 Hz, each marked IsPromoted, the set macOS offers. Linux offered only 120 Hz, because a mode set away from the 120 Hz timing crashes the DCP (dcp_mode_settable()). The panel does not need that mode set: it shows each swap on the first 240 Hz tick after the swap arrives (dcp_refresh_swap_paced()). So offer each fixed rate as a mode of its own that keeps the DCP on the 120 Hz timing of its size, and pace the swaps to the rate: - dcp_find_mode() gives a paced rate's 120 Hz entry, so a mode set, dcp_mode_settable() and every firmware call see that timing only. - Switching between paced rates of one timing is no mode set (apple_connector_rate_fastset()), as with the notch geometries. - iomfb_pace_hold() holds a paced swap until its due time, kept whole periods apart, so 60 and 48 Hz are whole ticks and 59.94, 50 and 47.95 Hz keep their average. A swap a period late starts again from the last swap shown. VRR_ENABLED turns the pacing off. Only while the panel runs the 120 Hz timing; a panel iBoot left at 60 Hz keeps just that. This covers every firmware 27 internal panel whose DCP sets hw.only_120hz_modes, the flag dcp_mode_settable() already keys the 120 Hz restriction on: the T6050 today, the T6031 and T6030 once their flags land. The panel EDID's range also started at its lowest timing (47 Hz), which is what compositors show as the VRR range; take the paced floor (24 Hz) instead. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/apple_drv.c | 29 ++++ drivers/gpu/drm/apple/dcp-display-metadata.c | 3 + drivers/gpu/drm/apple/dcp-display-metadata.h | 2 + drivers/gpu/drm/apple/dcp-internal.h | 12 ++ drivers/gpu/drm/apple/dcp.c | 16 +++ drivers/gpu/drm/apple/iomfb.c | 125 +++++++++++++++++- drivers/gpu/drm/apple/iomfb_template.c | 3 + drivers/gpu/drm/apple/parser-test.c | 46 ++++++- tools/asahi/dcpext26-queue-tests.py | 7 +- .../drivers/gpu/apple-dcp/desktop.py | 3 + .../selftests/drivers/gpu/apple-dcp/rate.py | 2 +- 11 files changed, 242 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index a30a1a863622f..8fbeed230b646 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -1536,6 +1536,34 @@ static int apple_connector_notch_fastset(struct drm_connector *conn, return drm_atomic_add_affected_planes(state, new->crtc); } +/* + * The panel's paced rates (dcp_paced_rates()) are one timing to the DCP: + * switching between them changes only how the swaps are paced, so it is no + * mode set (a mode set away from that timing crashes the T6050 DCP). + */ +static void apple_connector_rate_fastset(struct drm_connector *conn, + struct drm_atomic_commit *state, + struct drm_connector_state *new) +{ + struct platform_device *pdev; + struct drm_crtc_state *old_cs, *new_cs; + + if (conn->funcs != &apple_connector_funcs || !new->crtc) + return; + pdev = READ_ONCE(to_apple_connector(conn)->dcp); + if (!pdev) + return; + old_cs = drm_atomic_get_old_crtc_state(state, new->crtc); + new_cs = drm_atomic_get_new_crtc_state(state, new->crtc); + if (!old_cs || !new_cs || !new_cs->mode_changed || new_cs->active_changed || + new_cs->connectors_changed || !old_cs->active || !new_cs->active || + old_cs->enable != new_cs->enable || + !dcp_paced_fastset(platform_get_drvdata(pdev), &old_cs->mode, &new_cs->mode)) + return; + new_cs->mode_changed = false; + drm_mode_copy(&new_cs->adjusted_mode, &new_cs->mode); +} + static int apple_connector_atomic_check(struct drm_connector *conn, struct drm_atomic_commit *state) { @@ -1549,6 +1577,7 @@ static int apple_connector_atomic_check(struct drm_connector *conn, ret = apple_connector_notch_fastset(conn, state, new); if (ret) return ret; + apple_connector_rate_fastset(conn, state, new); if (blob && (blob->length != sizeof(struct hdr_output_metadata) || !dcp_hdr_is_type1(blob->data))) diff --git a/drivers/gpu/drm/apple/dcp-display-metadata.c b/drivers/gpu/drm/apple/dcp-display-metadata.c index 1e393c2ea9d2b..5dc52cc1403f8 100644 --- a/drivers/gpu/drm/apple/dcp-display-metadata.c +++ b/drivers/gpu/drm/apple/dcp-display-metadata.c @@ -531,6 +531,9 @@ const struct drm_edid *dcp_panel_edid(const struct dcp_display_metadata *metadat } if (!timing || clock > 2550000) return ERR_PTR(-ERANGE); + /* A swap-paced panel takes any rate down to its lowest, not only its timings'. */ + if (metadata->vrr_min_hz && metadata->vrr_min_hz < min_v) + min_v = metadata->vrr_min_hz; memcpy(block.header, "\x00\xff\xff\xff\xff\xff\xff\x00", 8); block.product_id.manufacturer_name = cpu_to_be16(manufacturer); diff --git a/drivers/gpu/drm/apple/dcp-display-metadata.h b/drivers/gpu/drm/apple/dcp-display-metadata.h index 9a12bebaacbf2..8d82f63b56631 100644 --- a/drivers/gpu/drm/apple/dcp-display-metadata.h +++ b/drivers/gpu/drm/apple/dcp-display-metadata.h @@ -20,6 +20,8 @@ struct dcp_display_metadata { u32 max_luminance, max_fall, min_luminance; /* 16.16 cd/m2 */ /* DCP_METADATA_DEFAULT_*: what the sink left out, so the EDID leaves undefined */ u32 defaults; + /* A swap-paced panel's lowest rate (dcp_refresh_swap_paced()); 0 if none */ + u32 vrr_min_hz; }; #define DCP_METADATA_DEFAULT_SIZE BIT(0) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index 556a975a6b80c..85819526e5ed9 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -78,6 +78,8 @@ struct iomfb_transaction { bool brightness_only; bool presentation; bool completed; + /* A paced rate's frame time (dcp_paced_rates()); 0 sends at once. */ + u32 pace_ns; }; struct apple_dcp_typec_port; @@ -1459,6 +1461,13 @@ struct apple_dcp { struct delayed_work backlight_retry; /* A firmware 27 panel's EDR ramp on a still frame (iomfb_edr_tick()) */ struct delayed_work edr_tick; + /* + * A paced rate's timeline (iomfb_pace_hold()): when the next + * swap is due to be shown, and when the last one was. + */ + struct hrtimer pace_timer; + ktime_t pace_next; + ktime_t last_complete; unsigned long deadline; unsigned int queued; bool stopped; @@ -1671,6 +1680,9 @@ int dcp_backlight_update(struct apple_dcp *dcp); void dcp_backlight_s2r_restore(struct apple_dcp *dcp); s32 dcp_ext_backlight_value(struct apple_dcp *dcp); bool dcp_has_panel(struct apple_dcp *dcp); +bool dcp_paced_rates(struct apple_dcp *dcp); +bool dcp_paced_fastset(struct apple_dcp *dcp, const struct drm_display_mode *old, + const struct drm_display_mode *new); extern int fw27_panel_boot_mode; extern int notify_clients_form; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index eb76920e0ea28..61512e77b806d 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -79,6 +79,7 @@ #include "dcp-fabric.h" #include "dcp-hdmi.h" #include "dcp-syslog.h" +#include "dcp-refresh.h" #include "dcp-internal.h" #include "j613-25g83.h" #include "dcp-external-bw.h" @@ -1669,6 +1670,19 @@ bool dcp_panel_metadata_current(struct apple_dcp *dcp, u64 generation) return valid; } +/* The lowest rate a firmware 27 panel's timings are paced to, 0 for none. */ +static u32 dcp_panel_paced_min(struct apple_dcp *dcp, const struct dcp_display_mode *modes, + unsigned int count) +{ + u32 low, high, min = 0; + + for (unsigned int i = 0; i < count && dcp->fw_compat == DCP_FIRMWARE_V_27_0; i++) + if (dcp_refresh_swap_paced((u32)drm_mode_vrefresh(&modes[i].mode) << 16, + modes[i].vrr, dcp_has_panel(dcp), &low, &high)) + min = low >> 16; + return min; +} + const struct drm_edid *dcp_panel_edid_snapshot(struct apple_dcp *dcp, const struct dcp_display_mode *modes, unsigned int count, u64 *generation) @@ -1700,6 +1714,8 @@ const struct drm_edid *dcp_panel_edid_snapshot(struct apple_dcp *dcp, metadata.max_fall = metadata.max_luminance; metadata.min_luminance = 0; } + /* Its range reaches the lowest rate the panel paces. */ + metadata.vrr_min_hz = dcp_panel_paced_min(dcp, modes, count); /* The caller supplies the same retained catalog it is publishing. */ edid = size ? drm_edid_alloc(raw, size) : dcp_panel_edid(&metadata, dcp->panel.color_target, modes, count, diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index f0a4c291f58f8..5adf8da36604a 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -515,6 +515,48 @@ static void iomfb_queue_advance(struct apple_dcp *dcp) schedule_work(&dcp->iomfb.work); } +/* Sent this early, a swap makes the panel's tick at its due time. */ +#define IOMFB_PACE_LEAD_NS (2 * NSEC_PER_MSEC) + +static enum hrtimer_restart iomfb_pace_fire(struct hrtimer *timer) +{ + struct apple_dcp *dcp = container_of(timer, struct apple_dcp, iomfb.pace_timer); + + schedule_work(&dcp->iomfb.work); + return HRTIMER_NORESTART; +} + +/* + * Whether a paced swap waits for its due time (dcp_paced_rates()). The due + * times are whole periods apart, so a rate that is no whole number of panel + * ticks keeps its average; a swap a period or more late starts them again from + * the last swap shown. Other transactions leave the schedule alone. + */ +static bool iomfb_pace_hold(struct apple_dcp *dcp, struct iomfb_transaction *transaction) +{ + ktime_t now = ktime_get(), due, last; + + if (!transaction->presentation) + return false; + if (!transaction->pace_ns) { + dcp->iomfb.pace_next = 0; + return false; + } + due = dcp->iomfb.pace_next; + if (!due || ktime_before(ktime_add_ns(due, transaction->pace_ns), now)) { + last = READ_ONCE(dcp->iomfb.last_complete); + due = last ? ktime_add_ns(last, transaction->pace_ns) : now; + } + if (ktime_before(now, ktime_sub_ns(due, IOMFB_PACE_LEAD_NS))) { + dcp->iomfb.pace_next = due; + hrtimer_start(&dcp->iomfb.pace_timer, + ktime_sub_ns(due, IOMFB_PACE_LEAD_NS), HRTIMER_MODE_ABS); + return true; + } + dcp->iomfb.pace_next = ktime_add_ns(due, transaction->pace_ns); + return false; +} + static void iomfb_queue_work(struct work_struct *work) { struct apple_dcp *dcp = container_of(work, struct apple_dcp, iomfb.work); @@ -532,6 +574,8 @@ static void iomfb_queue_work(struct work_struct *work) transaction = list_first_entry(&dcp->iomfb.pending, struct iomfb_transaction, link); + if (iomfb_pace_hold(dcp, transaction)) + goto unlock; list_del(&transaction->link); dcp->iomfb.queued--; dcp->iomfb.active = transaction; @@ -711,6 +755,8 @@ void iomfb_queue_init(struct apple_dcp *dcp) INIT_DELAYED_WORK(&dcp->iomfb.timeout, iomfb_queue_timeout); INIT_DELAYED_WORK(&dcp->iomfb.backlight_retry, iomfb_backlight_retry); INIT_DELAYED_WORK(&dcp->iomfb.edr_tick, iomfb_edr_tick); + hrtimer_setup(&dcp->iomfb.pace_timer, iomfb_pace_fire, CLOCK_MONOTONIC, + HRTIMER_MODE_ABS); atomic_set(&dcp->iomfb.opaque_x_state, IOMFB_OPAQUE_X_WAITING); } @@ -761,6 +807,7 @@ void iomfb_queue_stop(struct apple_dcp *dcp) spin_unlock_irqrestore(&dcp->iomfb.callback_lock, flags); iomfb_discard_pending(dcp); mutex_unlock(&dcp->iomfb.lock); + hrtimer_cancel(&dcp->iomfb.pace_timer); cancel_work_sync(&dcp->iomfb.work); cancel_work_sync(&dcp->iomfb.callback_work); while ((item = iomfb_pop_callback(dcp))) @@ -3828,6 +3875,49 @@ bool dcp_notch_mode_known(struct apple_dcp *dcp, const struct drm_display_mode * dcp_notch_twin_of(&fixed, mode, dcp->notch_rows); } +/* + * Firmware 27 lists the ProMotion panel's fixed rates (60, 59.94, 50, 48 and + * 47.95 Hz, each "IsPromoted") with its 120 Hz timing: the set macOS offers. + * A mode set to one of them crashes the T6050 internal DCP (see + * dcp_mode_settable()), but the panel shows each swap on the first 240 Hz tick + * after it arrives (dcp_refresh_swap_paced()). So such a rate is offered as a + * mode that keeps the DCP on the 120 Hz timing of its size, and the swaps are + * paced to the rate (iomfb_pace_hold()): 60 and 48 Hz are whole ticks, the + * others land on the nearest tick and keep their average. Only while the + * panel runs that 120 Hz timing: a panel iBoot left at 60 Hz keeps just that. + */ +bool dcp_paced_rates(struct apple_dcp *dcp) +{ + u32 boot = READ_ONCE(dcp->boot_rate); + + return dcp->hw.only_120hz_modes && dcp->fw_compat == DCP_FIRMWARE_V_27_0 && + (!boot || boot == 120) && dcp_has_panel(dcp); +} + +static bool dcp_mode_is_promotion(const struct drm_display_mode *mode) +{ + return dcp_refresh_is_promotion((u32)drm_mode_vrefresh(mode) << 16); +} + +/* The timing the DCP runs for @found: its own, or for a paced rate the 120 Hz one. */ +static const struct dcp_display_mode * +dcp_paced_base(struct apple_dcp *dcp, const struct dcp_display_mode *modes, + unsigned int count, const struct dcp_display_mode *found) +{ + unsigned int i; + + if (!dcp_paced_rates(dcp) || dcp_mode_is_promotion(&found->mode)) + return found; + for (i = 0; i < count; i++) + if (!modes[i].automatic_rgb8_quirk && + modes[i].mode.hdisplay == found->mode.hdisplay && + modes[i].mode.vdisplay == found->mode.vdisplay && + dcp_mode_is_promotion(&modes[i].mode)) + return &modes[i]; + /* No 120 Hz timing of its size: dcp_mode_settable() refuses it. */ + return found; +} + static const struct dcp_display_mode * dcp_find_mode(struct apple_dcp *dcp, const struct drm_display_mode *mode) { @@ -3842,7 +3932,7 @@ dcp_find_mode(struct apple_dcp *dcp, const struct drm_display_mode *mode) DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_CLOCK)) { if (!modes[i].automatic_rgb8_quirk) - return &modes[i]; + return dcp_paced_base(dcp, modes, count, &modes[i]); mutex_lock(&dcp->hpd_mutex); mutex_lock(&dcp->dcpavserv.lock); spin_lock_irqsave(&dcp->metadata.lock, flags); @@ -3872,6 +3962,31 @@ bool lookup_mode(struct apple_dcp *dcp, const struct drm_display_mode *mode, return true; } +/* Two modes the DCP runs as one timing: paced rates of the same size. */ +bool dcp_paced_fastset(struct apple_dcp *dcp, const struct drm_display_mode *old, + const struct drm_display_mode *new) +{ + const struct dcp_display_mode *a, *b; + + if (!dcp_paced_rates(dcp)) + return false; + a = dcp_find_mode(dcp, old); + b = dcp_find_mode(dcp, new); + return a && a == b; +} + +/* A paced rate's frame time in ns, 0 for a mode the swaps need no pacing for. */ +static u32 dcp_pace_ns(struct apple_dcp *dcp, const struct drm_crtc_state *state) +{ + const struct drm_display_mode *mode = &state->mode; + + if (!state->active || state->vrr_enabled || !dcp_paced_rates(dcp) || + mode->clock <= 0 || !mode->htotal || !mode->vtotal || + dcp_mode_is_promotion(mode)) + return 0; + return div_u64((u64)mode->htotal * mode->vtotal * 1000000ULL, mode->clock); +} + /* * H17P keeps the mode the bootloader programmed and never sends * set_digital_out_mode (see DCP_INHERIT_BOOT_MODE in iomfb_template.c), so a @@ -3897,10 +4012,11 @@ static bool dcp_mode_settable(struct apple_dcp *dcp, * from the timing iBoot left the panel at: 120 -> 60 Hz, and 60 -> * 120 Hz when macOS left it at 60 Hz. Offer only the rate the * firmware reported at start (dcp_rtk_syslog_boot_rate()), 120 Hz - * when it reported none. + * when it reported none. A paced rate runs that timing + * (dcp_paced_rates()): dcp_find_mode() gave its 120 Hz entry. */ if (dcp->hw.only_120hz_modes && - drm_mode_vrefresh(mode) != (READ_ONCE(dcp->boot_rate) ?: 120)) + drm_mode_vrefresh(&dcp_mode->mode) != (READ_ONCE(dcp->boot_rate) ?: 120)) return false; return true; @@ -5040,6 +5156,7 @@ static void iomfb_queue_atomic(struct apple_dcp *dcp, struct drm_crtc *crtc, struct drm_atomic_commit *state) { struct iomfb_atomic_transaction *atomic; + struct drm_crtc_state *crtc_state; int ret; if (READ_ONCE(dcp->iomfb.presentation_paused) || @@ -5056,6 +5173,8 @@ static void iomfb_queue_atomic(struct apple_dcp *dcp, struct drm_crtc *crtc, atomic->state = drm_atomic_commit_get(state); atomic->crtc = crtc; atomic->dcp = dcp; + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + atomic->transaction.pace_ns = crtc_state ? dcp_pace_ns(dcp, crtc_state) : 0; ret = iomfb_queue(dcp, &atomic->transaction); if (!ret) return; diff --git a/drivers/gpu/drm/apple/iomfb_template.c b/drivers/gpu/drm/apple/iomfb_template.c index e6cf4103ab089..1d50dbbd4f516 100644 --- a/drivers/gpu/drm/apple/iomfb_template.c +++ b/drivers/gpu/drm/apple/iomfb_template.c @@ -907,6 +907,9 @@ static void dcp_report_swap_complete(struct apple_dcp *dcp, u32 id, ktime_t now, dcp->have_swap_complete = true; dcp_swap_watchdog_complete(dcp); if (retire) { + /* Where a paced rate's next swap is due from (iomfb_pace_hold()). */ + if (shown) + WRITE_ONCE(dcp->iomfb.last_complete, now); dcp_release_retained_framebuffers(dcp, id); dcp_drm_crtc_page_flip(dcp, now); } diff --git a/drivers/gpu/drm/apple/parser-test.c b/drivers/gpu/drm/apple/parser-test.c index 340e1157108d6..5df0998bf592b 100644 --- a/drivers/gpu/drm/apple/parser-test.c +++ b/drivers/gpu/drm/apple/parser-test.c @@ -1475,6 +1475,28 @@ static void parser_panel_identity(struct kunit *test) KUNIT_EXPECT_EQ(test, raw->detailed_timings[3].data.other_data.data.range.max_vfreq, 120); KUNIT_EXPECT_EQ(test, modes[0].mode.clock, 540005); drm_edid_free(edid); + + /* + * A firmware 27 panel: fixed 60 and 120 Hz timings, paced down to 24 Hz + * (vrr_min_hz). Its range starts there, not at its lowest timing. + */ + modes[1].vrr = false; + modes[1].min_vrr = 0; + modes[1].max_vrr = 0; + metadata.vrr_min_hz = 24; + edid = dcp_panel_edid(&metadata, NULL, modes, 2, 345, 223); + KUNIT_ASSERT_FALSE(test, IS_ERR(edid)); + raw = drm_edid_raw(edid); + KUNIT_EXPECT_EQ(test, raw->detailed_timings[3].data.other_data.data.range.min_vfreq, 24); + KUNIT_EXPECT_EQ(test, raw->detailed_timings[3].data.other_data.data.range.max_vfreq, 121); + drm_edid_free(edid); + /* Without it the lowest timing (60 Hz) is the floor, as before. */ + metadata.vrr_min_hz = 0; + edid = dcp_panel_edid(&metadata, NULL, modes, 2, 345, 223); + KUNIT_ASSERT_FALSE(test, IS_ERR(edid)); + raw = drm_edid_raw(edid); + KUNIT_EXPECT_EQ(test, raw->detailed_timings[3].data.other_data.data.range.min_vfreq, 60); + drm_edid_free(edid); } static const struct dcp_display_mode panel_color_mode = { @@ -2096,7 +2118,8 @@ static void parser_desktop_metadata_timing(struct kunit *test) /* * The M5 internal DCP (firmware 27) crashes on any set_digital_out_mode that * is not the 120 Hz boot timing (3024x1986@60 killed the co-processor). The - * connector must refuse every other mode of the internal panel. + * connector must refuse every other timing of the internal panel; its other + * rates are offered only as paced modes of the 120 Hz timing. */ static void parser_internal_v27_only_120hz(struct kunit *test) { @@ -2104,6 +2127,7 @@ static void parser_internal_v27_only_120hz(struct kunit *test) struct apple_dcp *dcp = kunit_kzalloc(test, sizeof(*dcp), GFP_KERNEL); struct platform_device *pipeline = kunit_kzalloc(test, sizeof(*pipeline), GFP_KERNEL); struct apple_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); + struct dcp_display_mode found; unsigned int i; KUNIT_ASSERT_NOT_NULL(test, catalog); @@ -2142,6 +2166,26 @@ static void parser_internal_v27_only_120hz(struct kunit *test) KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[1].mode), MODE_OK); dcp->boot_rate = 0; + /* + * The panel's other rates are paced (dcp_paced_rates()): offered, run on + * the 120 Hz timing, and switched to without a mode set. + */ + dcp->panel.width_mm = 302; + KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[0].mode), MODE_OK); + KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[1].mode), MODE_OK); + KUNIT_EXPECT_TRUE(test, lookup_mode(dcp, &catalog[1].mode, &found)); + KUNIT_EXPECT_EQ(test, found.timing_mode_id, 2); + KUNIT_EXPECT_TRUE(test, dcp_paced_fastset(dcp, &catalog[0].mode, &catalog[1].mode)); + /* Left at 60 Hz by iBoot: no pacing, its own 60 Hz timing only. */ + dcp->boot_rate = 60; + KUNIT_EXPECT_FALSE(test, dcp_paced_fastset(dcp, &catalog[0].mode, &catalog[1].mode)); + KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[0].mode), MODE_BAD); + KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[1].mode), MODE_OK); + KUNIT_EXPECT_TRUE(test, lookup_mode(dcp, &catalog[1].mode, &found)); + KUNIT_EXPECT_EQ(test, found.timing_mode_id, 3); + dcp->boot_rate = 0; + dcp->panel.width_mm = 0; + /* The T8142 Air internal DCP (60 Hz panel, firmware 27.0) and the T6050 dcpext keep every mode. */ dcp->hw.only_120hz_modes = false; KUNIT_EXPECT_EQ(test, dcp_mode_valid(&connector->base, &catalog[0].mode), MODE_OK); diff --git a/tools/asahi/dcpext26-queue-tests.py b/tools/asahi/dcpext26-queue-tests.py index cb1b0caabeecf..5fd5fea550d15 100644 --- a/tools/asahi/dcpext26-queue-tests.py +++ b/tools/asahi/dcpext26-queue-tests.py @@ -72,7 +72,7 @@ def function(name): #define current NULL static unsigned long jiffies; struct apple_dcp; -struct iomfb_transaction {struct list_head link;void (*start)(struct apple_dcp *,struct iomfb_transaction *);void (*release)(struct iomfb_transaction *);bool brightness_only,presentation,completed,backlight_failed;}; +struct iomfb_transaction {struct list_head link;void (*start)(struct apple_dcp *,struct iomfb_transaction *);void (*release)(struct iomfb_transaction *);bool brightness_only,presentation,completed,backlight_failed;u32 pace_ns;}; struct iomfb_scanout_h17p {int request;struct drm_framebuffer *fb[4];struct list_head link;}; struct apple_dcp { void *dev;bool s2r_scanout_stale,s2r_scanout_hold,sleep_v27_closed; @@ -92,6 +92,11 @@ def function(name): static unsigned flushed; static void iomfb_flush_h17p(struct apple_dcp *d,struct drm_crtc *c,struct drm_atomic_commit *s){assert(d->iomfb.next_scanout);flushed++;d->present_state_h17p.pending=true;} #define iomfb_flush_v27 iomfb_flush_h17p +/* Paced rates (dcp_paced_rates()) are an internal panel's: none here. */ +struct drm_crtc_state; +static struct drm_crtc_state *drm_atomic_get_new_crtc_state(struct drm_atomic_commit *s,struct drm_crtc *c){return NULL;} +static u32 dcp_pace_ns(struct apple_dcp *d,const struct drm_crtc_state *c){return 0;} +static bool iomfb_pace_hold(struct apple_dcp *d,struct iomfb_transaction *t){return false;} ''' names = ['ext26_scanout_bytes', 'iomfb_scanout_release_h17p', 'iomfb_scanout_prepare_h17p', 'iomfb_scanout_put_h17p', diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py b/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py index 2973318e17192..5a9b096a4fc0e 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py @@ -425,6 +425,9 @@ def panel_identity(root, output=None): helpers = '\n'.join(block(source, name) for name in ( 'void dcp_panel_metadata_replace(', 'static bool dcp_panel_edid_has_identity(', 'void dcp_panel_edid_receive(', 'bool dcp_panel_metadata_current(', 'const struct drm_edid *dcp_panel_edid_snapshot(')) + # A desktop 26.6 panel is not paced (dcp_panel_paced_min() is firmware 27's). + helpers = ('static u32 dcp_panel_paced_min(struct apple_dcp *d, const struct dcp_display_mode *m,' + ' unsigned int n) { (void)d; (void)m; (void)n; return 0; }\n') + helpers backend = (root / 'drivers/gpu/drm/apple/iomfb_v26_6_desktop.c').read_text() dictionary = block((root/'drivers/gpu/drm/apple/parser.c').read_text(), 'static int parse_panel_edid_value(') dictionary += block((root/'drivers/gpu/drm/apple/parser.c').read_text(), 'int parse_panel_edid_data(') diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py index 8c4267a2dc8f7..ae3e1c1903859 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py @@ -1068,7 +1068,7 @@ def publication(root): + mode_helpers) # The desktop 26.6 VRR filter is gone once that firmware takes adaptive sync. vrr_filter = block(iomfb,'static bool dcp_mode_vrr_supported(')+'\n' if 'static bool dcp_mode_vrr_supported(' in iomfb else '' - publication = block(iomfb,'static void dcp_clear_connector_edid(')+'\n'+block(iomfb,'static void dcp_consume_edid_invalidation(')+mode_helpers+vrr_filter+block(iomfb,'int dcp_get_modes(')+block(iomfb,'static const struct dcp_display_mode *\ndcp_find_mode(')+block(iomfb,'bool lookup_mode(') + publication = block(iomfb,'static void dcp_clear_connector_edid(')+'\n'+block(iomfb,'static void dcp_consume_edid_invalidation(')+mode_helpers+vrr_filter+block(iomfb,'int dcp_get_modes(')+'\n/* No paced rates here (dcp_paced_rates() is a T6050 panel\'s): a mode runs its own timing. */\nstatic const struct dcp_display_mode *dcp_paced_base(struct apple_dcp *d, const struct dcp_display_mode *m, unsigned int n, const struct dcp_display_mode *found){(void)d;(void)m;(void)n;return found;}\n'+block(iomfb,'static const struct dcp_display_mode *\ndcp_find_mode(')+block(iomfb,'bool lookup_mode(') if 'dcp_edid_sdr(' in publication: # Keep extracting the real publication path, including its SDR helper. # Model only kernel allocation/DRM ownership at the host boundary.