diff --git a/Documentation/ABI/testing/sysfs-class-drm-apple-notch b/Documentation/ABI/testing/sysfs-class-drm-apple-notch new file mode 100644 index 0000000000000..75c749188dc84 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-drm-apple-notch @@ -0,0 +1,16 @@ +What: /sys/class/drm/card-eDP-/notch +Date: November 2026 +KernelVersion: 7.3 +Contact: dri-devel@lists.freedesktop.org +Description: + (RW) Present on the built-in panel connector of an Apple + display controller (appledrm) when the panel has notch rows + (apple,notch-height). Reads "shown" or "hidden": whether + compositors are offered the full panel, notch rows included, + or the notch-free geometry. It is the connector's "notch" + property. Writing "shown", "hidden" or a boolean (1/0, on/off, + y/n) commits that property and makes compositors and the + console probe the connector again. The text console always + uses the notch-free geometry. The value starts as the boot + loader's choice (chosen/asahi,show-notch). See + Documentation/gpu/apple-dcp-notch.rst. diff --git a/Documentation/gpu/apple-dcp-notch.rst b/Documentation/gpu/apple-dcp-notch.rst new file mode 100644 index 0000000000000..b24d8ea2a2c5b --- /dev/null +++ b/Documentation/gpu/apple-dcp-notch.rst @@ -0,0 +1,61 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +========================================== +Apple display: the panel notch at run time +========================================== + +A built-in panel with a camera housing has ``apple,notch-height`` rows at its +top; the boot loader fills that property from the hardware description (ADT). +The panel always runs its native timing. The driver offers each timing in two +geometries: + +* **full**: the mode covers the whole panel, the notch rows included; +* **notch-free**: the mode is ``apple,notch-height`` rows shorter. The rows + are folded into the vertical sync, so clock, totals and refresh rate are + the full mode's. The frame is scanned out below the notch and the notch + rows stay black. + +The mode a commit carries decides what is scanned out. Both geometries are +always accepted, and a switch between the two geometries of one timing is no +mode set: the CRTC stays on and the display firmware is not asked for a new +mode. + +The ``notch`` connector property +================================ + +Panels with notch rows have an enum connector property ``notch`` with the +values ``hidden`` and ``shown``. It selects the geometry compositors are +offered: + +``shown`` + while a DRM master owns the device, the full modes are offered; +``hidden`` + the notch-free modes are offered. + +The starting value is the boot loader's ``chosen/asahi,show-notch`` (``"1"``: +shown). A compositor can set the property in an atomic commit, usually +together with the matching mode. A change sends a hotplug event, so that +compositors and the console probe the connector again; a compositor that +follows hotplug events needs no further support. + +Whenever no DRM master owns the device (a text-only system, a switch to a +text VT, a compositor that dropped master or exited), only the notch-free +modes are offered whatever the property says, and the in-kernel console +probes again and uses them: the console never draws under the notch. Its +surface is notch-free, and a probe limited to that surface is offered the +notch-free modes even while a compositor shows the full panel. + +The same choice is ``/sys/class/drm/cardN-eDP-1/notch`` for scripts (see +``Documentation/ABI/testing/sysfs-class-drm-apple-notch``). Writing it commits +the property like a compositor would. + +``/sys/kernel/debug/dri/N/eDP-1/notch`` shows the notch rows, the full +panel's rows, the policy, whether a DRM master owns the device, and the rows +above the last frame scanned out. + +The physical height reported for the connector follows the offered +geometry: the panel's ``adj-height-mm`` for the notch-free one if the device +tree gives it, otherwise the full height scaled by the rows. + +The standalone firmware 14.7 and 26.6 pipes build their one mode from the +boot framebuffer and keep the boot loader's geometry for the boot. diff --git a/Documentation/gpu/apple-drm-parameters.rst b/Documentation/gpu/apple-drm-parameters.rst index 599cf050f7c81..95f3af645a8b3 100644 --- a/Documentation/gpu/apple-drm-parameters.rst +++ b/Documentation/gpu/apple-drm-parameters.rst @@ -3,11 +3,10 @@ Apple display module parameters =============================== -Use ``appledrm.show_notch=1`` to include the notch rows in the panel mode. -This common preference also applies to the M3 internal display firmware; -it replaces the platform-specific ``appledrm.t6030_show_notch`` alias. -When the boot framebuffer should cover those rows too, keep the useful -``chosen.asahi,show-notch=1`` m1n1 display preference alongside it. +The notch rows of a built-in panel are no longer a module parameter: the +boot loader's ``chosen/asahi,show-notch`` sets the starting choice and the +``notch`` connector property changes it at run time; see +:doc:`apple-dcp-notch`. The old ``appledrm.dcpext_probe`` parameter had no consumer and has been removed. External display support follows the device tree and the driver's diff --git a/Documentation/gpu/drivers.rst b/Documentation/gpu/drivers.rst index 38f99ddda7c83..73f26e5457453 100644 --- a/Documentation/gpu/drivers.rst +++ b/Documentation/gpu/drivers.rst @@ -13,6 +13,7 @@ GPU Driver Documentation asahi-usage-stats asahi-m4-bringup apple-dcp-m4 + apple-dcp-notch i915 imagination/index intel-display/index diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index 06e36e3a4a00d..e5c4f4e99671d 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -75,12 +76,58 @@ struct apple_drm_private { bool s2r_skipped; /* A dark wake left the outputs as the suspend did, for the next resume. */ bool dark_held; + /* The "notch" connector property, on panels with notch rows (dcp-notch.h). */ + struct drm_property *notch_prop; + /* Re-probe after a "notch" change: userspace and the console. */ + struct work_struct notch_hotplug; + /* The console took the display back: it re-probes its notch-free modes. */ + struct work_struct notch_console; + /* + * The console's first probe ran while a DRM master was offered the + * full panel: its modes are not its notch-free surface's until it + * re-probes, which the next master drop asks for, once. + */ + bool notch_console_stale; /* On apple_drm_pm_list while bound, for the system-sleep notifier. */ struct list_head pm_node; /* The notifier's output restore, run outside apple_drm_pm_lock. */ struct work_struct pm_resume_work; }; +static struct apple_drm_private *to_apple_drm(struct drm_device *drm) +{ + return container_of(drm, struct apple_drm_private, drm); +} + +/* A connector state with the panel's "notch" property. */ +struct apple_connector_state { + struct drm_connector_state base; + u8 notch; /* enum dcp_notch_policy */ +}; + +static struct apple_connector_state * +to_apple_connector_state(const struct drm_connector_state *state) +{ + return container_of(state, struct apple_connector_state, base); +} + +static const struct drm_connector_funcs apple_connector_funcs; + +/* The panel pipeline behind @connector if its panel has notch rows, else NULL. */ +static struct apple_dcp *apple_connector_notch_dcp(struct drm_connector *connector) +{ + struct platform_device *pdev; + struct apple_dcp *dcp; + + if (connector->funcs != &apple_connector_funcs) + return NULL; + pdev = READ_ONCE(to_apple_connector(connector)->dcp); + dcp = pdev ? platform_get_drvdata(pdev) : NULL; + + return dcp && dcp->notch_rows && dcp_notch_dynamic(dcp) && + connector->connector_type == DRM_MODE_CONNECTOR_eDP ? dcp : NULL; +} + static int apple_drm_pm_notify(struct notifier_block *nb, unsigned long action, void *data); #ifdef CONFIG_PM_SLEEP static void apple_drm_pm_resume_work(struct work_struct *work); @@ -347,10 +394,102 @@ static int apple_drm_fbdev_probe(struct drm_fb_helper *helper, } } + /* + * The console never draws under a panel's notch: its surface is the + * notch-free geometry, so every later probe of the fbdev client, which + * is bounded by its surface, picks the notch-free modes. Its first probe + * normally ran with no DRM master and picked them already; this covers + * a boot splash that held master then. + */ + drm_for_each_crtc(crtc, helper->dev) { + struct apple_dcp *dcp; + u32 rows; + + if (t8132_ext_crtc(crtc)) + continue; + dcp = platform_get_drvdata(to_apple_crtc(crtc)->dcp); + rows = READ_ONCE(dcp->notch_panel_rows); + if (!dcp->notch_rows || !dcp_notch_dynamic(dcp) || !rows || + sizes->surface_height != rows) + continue; + sizes->surface_height -= dcp->notch_rows; + sizes->fb_height = min(sizes->fb_height, sizes->surface_height); + WRITE_ONCE(to_apple_drm(helper->dev)->notch_console_stale, true); + break; + } + return drm_fbdev_dma_driver_fbdev_probe(helper, sizes); } #endif +/* + * Who owns the display decides the notch geometry offered (dcp-notch.h): a + * DRM master gets the policy, the console gets notch-free modes. Every + * probe of the console after its first is bounded by its notch-free surface + * and so picks notch-free modes whoever owns the device; only a first probe + * under a master offered the full panel (a boot splash) leaves it with full + * modes, and the first master drop after that has it re-probe. Other drops + * (greeter to session, user switch) leave the console alone. When a master + * comes back, it is offered the policy's geometry at its next probe, and its + * own mode, full or notch-free, is a fast switch either way. + */ +static void apple_drm_notch_owner(struct drm_device *drm, bool owned) +{ + struct drm_crtc *crtc; + bool notch = false; + + drm_for_each_crtc(crtc, drm) { + struct apple_dcp *dcp; + + if (t8132_ext_crtc(crtc)) + continue; + dcp = platform_get_drvdata(to_apple_crtc(crtc)->dcp); + if (!dcp || !dcp->notch_rows || !dcp_notch_dynamic(dcp)) + continue; + WRITE_ONCE(dcp->notch_owned, owned); + notch = true; + } + /* master_drop() runs under master_mutex, which the console's restore takes. */ + if (notch && !owned && !drm_dev_is_unplugged(drm) && + xchg(&to_apple_drm(drm)->notch_console_stale, false)) + schedule_work(&to_apple_drm(drm)->notch_console); +} + +static void apple_drm_master_set(struct drm_device *drm, struct drm_file *file, + bool from_open) +{ + apple_drm_notch_owner(drm, true); +} + +static void apple_drm_master_drop(struct drm_device *drm, struct drm_file *file) +{ + apple_drm_notch_owner(drm, false); +} + +static void apple_drm_notch_console(struct work_struct *work) +{ + struct drm_device *drm = &container_of(work, struct apple_drm_private, + notch_console)->drm; + int idx; + + if (!drm_dev_enter(drm, &idx)) + return; + drm_client_dev_hotplug(drm); + drm_dev_exit(idx); +} + +static void apple_drm_notch_hotplug(struct work_struct *work) +{ + struct drm_device *drm = &container_of(work, struct apple_drm_private, + notch_hotplug)->drm; + int idx; + + if (!drm_dev_enter(drm, &idx)) + return; + drm_kms_helper_hotplug_event(drm); + drm_dev_exit(idx); +} + /* * HDR is asked for by the compositor that set it, but connector properties * outlive their client. When it exits, the next client (Plymouth at @@ -451,6 +590,8 @@ static const struct drm_driver apple_drm_driver = { #endif .postclose = apple_drm_postclose, .gem_create_object = apple_drm_gem_create_object, + .master_set = apple_drm_master_set, + .master_drop = apple_drm_master_drop, .name = DRIVER_NAME, .desc = DRIVER_DESC, .major = 1, @@ -1008,10 +1149,37 @@ static const struct drm_mode_config_funcs apple_mode_config_funcs = { .fb_create = drm_gem_fb_create, }; +/* + * Publish the committed policy before completing the commit dependencies. + * Hotplug work runs after the hardware completion notification. + */ +static bool apple_commit_notch(struct drm_atomic_commit *state) +{ + struct drm_connector_state *old, *new; + struct drm_connector *conn; + bool changed = false; + int i; + + for_each_oldnew_connector_in_state(state, conn, old, new, i) { + struct apple_dcp *dcp = apple_connector_notch_dcp(conn); + u8 notch; + + if (!dcp) + continue; + notch = to_apple_connector_state(new)->notch; + if (notch == to_apple_connector_state(old)->notch) + continue; + WRITE_ONCE(dcp->notch_policy, notch); + changed = true; + } + return changed; +} + static void apple_atomic_commit_tail(struct drm_atomic_commit *state) { struct drm_plane *plane; struct drm_plane_state *old, *new; + bool notch_changed; int i; /* Retain displaced scanout even when the CRTC stays inactive. */ @@ -1034,8 +1202,11 @@ static void apple_atomic_commit_tail(struct drm_atomic_commit *state) drm_atomic_helper_commit_modeset_enables(state->dev, state); drm_atomic_helper_commit_planes(state->dev, state, DRM_PLANE_COMMIT_ACTIVE_ONLY); + notch_changed = apple_commit_notch(state); drm_atomic_helper_fake_vblank(state); drm_atomic_helper_commit_hw_done(state); + if (notch_changed) + schedule_work(&to_apple_drm(state->dev)->notch_hotplug); drm_atomic_helper_wait_for_flip_done(state->dev, state); apple_fail_lost_flips(state); drm_atomic_helper_cleanup_planes(state->dev, state); @@ -1063,31 +1234,189 @@ static void appledrm_connector_cleanup(struct drm_connector *connector) kfree(apple_connector); } -static int apple_connector_late_register(struct drm_connector *connector) +/* Probe with the client's size limit at hand (see dcp_notch_offer()). */ +static int apple_connector_fill_modes(struct drm_connector *connector, + u32 max_x, u32 max_y) { - return apple_connector_backlight_late_register(to_apple_connector(connector)); + struct drm_mode_config *config = &connector->dev->mode_config; + + to_apple_connector(connector)->probe_max_y = max_y < config->max_height ? max_y : 0; + return drm_helper_probe_single_connector_modes(connector, max_x, max_y); } -static void apple_connector_early_unregister(struct drm_connector *connector) +static void apple_connector_reset(struct drm_connector *connector) { - apple_connector_backlight_early_unregister(to_apple_connector(connector)); + struct apple_connector_state *state = kzalloc_obj(*state); + struct apple_dcp *dcp = apple_connector_notch_dcp(connector); + + if (connector->state) { + __drm_atomic_helper_connector_destroy_state(connector->state); + kfree(to_apple_connector_state(connector->state)); + connector->state = NULL; + } + if (!state) + return; + __drm_atomic_helper_connector_reset(connector, &state->base); + if (connector->max_bpc_property) { + state->base.max_requested_bpc = 12; + state->base.max_bpc = 12; + } + state->notch = dcp ? READ_ONCE(dcp->notch_policy) : DCP_NOTCH_HIDDEN; } -static void apple_connector_reset(struct drm_connector *connector) +static struct drm_connector_state * +apple_connector_duplicate_state(struct drm_connector *connector) +{ + struct apple_connector_state *state; + + if (WARN_ON(!connector->state)) + return NULL; + state = kmemdup(to_apple_connector_state(connector->state), sizeof(*state), + GFP_KERNEL); + if (!state) + return NULL; + __drm_atomic_helper_connector_duplicate_state(connector, &state->base); + return &state->base; +} + +static void apple_connector_destroy_state(struct drm_connector *connector, + struct drm_connector_state *state) +{ + __drm_atomic_helper_connector_destroy_state(state); + kfree(to_apple_connector_state(state)); +} + +static int apple_connector_atomic_set_property(struct drm_connector *connector, + struct drm_connector_state *state, + struct drm_property *property, u64 val) +{ + if (property != to_apple_drm(connector->dev)->notch_prop || + val > DCP_NOTCH_SHOWN) + return -EINVAL; + to_apple_connector_state(state)->notch = val; + return 0; +} + +static int apple_connector_atomic_get_property(struct drm_connector *connector, + const struct drm_connector_state *state, + struct drm_property *property, u64 *val) +{ + if (property != to_apple_drm(connector->dev)->notch_prop) + return -EINVAL; + *val = to_apple_connector_state(state)->notch; + return 0; +} + +static const struct drm_prop_enum_list apple_notch_names[] = { + { DCP_NOTCH_HIDDEN, "hidden" }, + { DCP_NOTCH_SHOWN, "shown" }, +}; + +/* The sysfs words, indexed by enum dcp_notch_policy. */ +static const char * const apple_notch_words[] = { "hidden", "shown" }; + +/* Commit @notch for @connector, as a compositor setting "notch" would. */ +static int apple_connector_commit_notch(struct drm_connector *connector, u8 notch) +{ + struct drm_modeset_acquire_ctx ctx; + struct drm_connector_state *cs; + struct drm_atomic_commit *state; + int ret = -ENOMEM; + + drm_modeset_acquire_init(&ctx, 0); + state = drm_atomic_commit_alloc(connector->dev); + if (!state) + goto out_ctx; + state->acquire_ctx = &ctx; +retry: + cs = drm_atomic_get_connector_state(state, connector); + ret = PTR_ERR_OR_ZERO(cs); + if (!ret) { + to_apple_connector_state(cs)->notch = notch; + ret = drm_atomic_commit(state); + } + if (ret == -EDEADLK) { + drm_atomic_commit_clear(state); + drm_modeset_backoff(&ctx); + goto retry; + } + drm_atomic_commit_put(state); +out_ctx: + drm_modeset_drop_locks(&ctx); + drm_modeset_acquire_fini(&ctx); + return ret; +} + +/* + * /sys/class/drm/cardN-eDP-1/notch: "shown" or "hidden", the same policy as + * the "notch" connector property, for scripts. + */ +static ssize_t notch_show(struct device *kdev, struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = dev_get_drvdata(kdev); + struct apple_dcp *dcp = apple_connector_notch_dcp(connector); + + if (!dcp) + return -ENODEV; + return sysfs_emit(buf, "%s\n", apple_notch_words[READ_ONCE(dcp->notch_policy) == + DCP_NOTCH_SHOWN]); +} + +static ssize_t notch_store(struct device *kdev, struct device_attribute *attr, + const char *buf, size_t len) +{ + struct drm_connector *connector = dev_get_drvdata(kdev); + int ret = sysfs_match_string(apple_notch_words, buf); + int idx; + + if (ret < 0) { + bool on; + + if (kstrtobool(buf, &on)) + return -EINVAL; + ret = on ? DCP_NOTCH_SHOWN : DCP_NOTCH_HIDDEN; + } + if (!apple_connector_notch_dcp(connector)) + return -ENODEV; + if (!drm_dev_enter(connector->dev, &idx)) + return -ENODEV; + ret = apple_connector_commit_notch(connector, ret); + drm_dev_exit(idx); + return ret ? ret : len; +} +static DEVICE_ATTR_RW(notch); + +static int apple_connector_late_register(struct drm_connector *connector) { - drm_atomic_helper_connector_reset(connector); - if (connector->state && connector->max_bpc_property) { - connector->state->max_requested_bpc = 12; - connector->state->max_bpc = 12; + int ret; + + if (apple_connector_notch_dcp(connector)) { + ret = device_create_file(connector->kdev, &dev_attr_notch); + if (ret) + return ret; } + ret = apple_connector_backlight_late_register(to_apple_connector(connector)); + if (ret) + device_remove_file(connector->kdev, &dev_attr_notch); + return ret; +} + +static void apple_connector_early_unregister(struct drm_connector *connector) +{ + apple_connector_backlight_early_unregister(to_apple_connector(connector)); + /* Nothing if it was never created. */ + device_remove_file(connector->kdev, &dev_attr_notch); } static const struct drm_connector_funcs apple_connector_funcs = { - .fill_modes = drm_helper_probe_single_connector_modes, + .fill_modes = apple_connector_fill_modes, .destroy = appledrm_connector_cleanup, .reset = apple_connector_reset, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_duplicate_state = apple_connector_duplicate_state, + .atomic_destroy_state = apple_connector_destroy_state, + .atomic_set_property = apple_connector_atomic_set_property, + .atomic_get_property = apple_connector_atomic_get_property, .detect = apple_connector_detect, .debugfs_init = apple_connector_debugfs_init, .oob_hotplug_event = apple_connector_oob_hotplug, @@ -1143,6 +1472,40 @@ static u8 apple_connector_eotf(const struct drm_connector_state *state) return hdr->hdmi_metadata_type1.eotf; } +/* + * The two notch geometries of the panel's timing (dcp-notch.h) differ only in + * where the frame is scanned out: switching between them, the console taking + * the display back or a compositor taking it, keeps the panel's mode, so it + * is no mode set (no CRTC off and on, no firmware mode set). + */ +static int apple_connector_notch_fastset(struct drm_connector *conn, + struct drm_atomic_commit *state, + struct drm_connector_state *new) +{ + struct apple_dcp *dcp = apple_connector_notch_dcp(conn); + struct drm_crtc_state *old_cs, *new_cs; + + if (!dcp || !new->crtc) + return 0; + 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 || + old_cs->vrr_enabled != new_cs->vrr_enabled || + !dcp_notch_twins(&old_cs->mode, &new_cs->mode, dcp->notch_rows) || + !dcp_notch_mode_known(dcp, &new_cs->mode)) + return 0; + new_cs->mode_changed = false; + /* No mode_fixup() runs now: the adjusted mode is the mode, as it would be. */ + drm_mode_copy(&new_cs->adjusted_mode, &new_cs->mode); + /* + * The frame moves by the notch rows: the swap that does it needs the + * CRTC's planes, which the core adds only to a mode set. + */ + return drm_atomic_add_affected_planes(state, new->crtc); +} + static int apple_connector_atomic_check(struct drm_connector *conn, struct drm_atomic_commit *state) { @@ -1150,6 +1513,12 @@ static int apple_connector_atomic_check(struct drm_connector *conn, struct drm_connector_state *new = drm_atomic_get_new_connector_state(state, conn); const struct drm_property_blob *blob = new->hdr_output_metadata; struct drm_crtc_state *crtc_state; + int ret; + + /* Before anything below asks for a real mode set again. */ + ret = apple_connector_notch_fastset(conn, state, new); + if (ret) + return ret; if (blob && (blob->length != sizeof(struct hdr_output_metadata) || !dcp_hdr_is_type1(blob->data))) @@ -1323,6 +1692,33 @@ static const struct drm_crtc_helper_funcs apple_crtc_helper_funcs = { .mode_fixup = dcp_crtc_mode_fixup, }; +/* + * "notch" (enum: hidden, shown) on a panel with notch rows: whether a + * compositor is offered the full panel height (dcp-notch.h). The modes + * follow a change; the mode a commit carries decides what is scanned out. + */ +static int apple_connector_attach_notch(struct drm_connector *connector) +{ + struct apple_drm_private *apple = to_apple_drm(connector->dev); + struct apple_dcp *dcp = apple_connector_notch_dcp(connector); + + if (!dcp) + return 0; + if (!apple->notch_prop) { + apple->notch_prop = drm_property_create_enum(connector->dev, 0, "notch", + apple_notch_names, + ARRAY_SIZE(apple_notch_names)); + if (!apple->notch_prop) + return -ENOMEM; + } + drm_object_attach_property(&connector->base, apple->notch_prop, + READ_ONCE(dcp->notch_policy)); + if (connector->state) + to_apple_connector_state(connector->state)->notch = + READ_ONCE(dcp->notch_policy); + return 0; +} + static int apple_connector_create(struct drm_device *drm, struct platform_device *dcp, struct apple_crtc *crtc, @@ -1361,6 +1757,9 @@ static int apple_connector_create(struct drm_device *drm, connector->base.polled = DRM_CONNECTOR_POLL_HPD; connector->connected = false; apple_connector_set_pipeline(connector, dcp); + ret = apple_connector_attach_notch(&connector->base); + if (ret) + goto err_cleanup; ret = drm_connector_attach_encoder(&connector->base, &encoder->base); if (ret) @@ -2098,6 +2497,8 @@ static int apple_drm_init(struct device *dev) INIT_WORK(&apple->pm_resume_work, apple_drm_pm_resume_work); #endif dev_set_drvdata(dev, apple); + INIT_WORK(&apple->notch_hotplug, apple_drm_notch_hotplug); + INIT_WORK(&apple->notch_console, apple_drm_notch_console); ret = drmm_mode_config_init(&apple->drm); if (ret) @@ -2256,6 +2657,8 @@ static int apple_drm_init(struct device *dev) if (retained_modeset) drm_modeset_unlock_all(&apple->drm); err_unbind: + disable_work_sync(&apple->notch_hotplug); + disable_work_sync(&apple->notch_console); t8132_ext_drm_fini(&apple->drm); apple_drm_quiesce_connectors(&apple->drm); component_unbind_all(dev, NULL); @@ -2286,6 +2689,9 @@ static void apple_drm_uninit(struct device *dev) apple_drm_quiesce_connectors(&apple->drm); drm_dev_unplug(&apple->drm); drm_atomic_helper_shutdown(&apple->drm); + /* No sysfs write, commit or master change queues them now. */ + disable_work_sync(&apple->notch_hotplug); + disable_work_sync(&apple->notch_console); component_unbind_all(dev, NULL); diff --git a/drivers/gpu/drm/apple/connector.c b/drivers/gpu/drm/apple/connector.c index e3c8c876a215a..0cbe9b8b5f43a 100644 --- a/drivers/gpu/drm/apple/connector.c +++ b/drivers/gpu/drm/apple/connector.c @@ -285,6 +285,19 @@ static void dcp_afk_debugfs_root(struct platform_device *pdev, int ep, struct de #endif } +/* The panel's notch state (dcp-notch.h), for checking what is on screen. */ +static int notch_show(struct seq_file *m, void *v) +{ + struct apple_dcp *dcp = m->private; + + seq_printf(m, "rows %u\npanel_rows %u\npolicy %s\nowned %u\nscanout_y %u\n", + dcp->notch_rows, READ_ONCE(dcp->notch_panel_rows), + READ_ONCE(dcp->notch_policy) == DCP_NOTCH_SHOWN ? "shown" : "hidden", + READ_ONCE(dcp->notch_owned), READ_ONCE(dcp->notch_scanout_y)); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(notch); + void apple_connector_debugfs_init(struct drm_connector *connector, struct dentry *root) { struct apple_connector *apple_con = to_apple_connector(connector); @@ -293,6 +306,8 @@ void apple_connector_debugfs_init(struct drm_connector *connector, struct dentry if (dcp && iomfb_is_m4(dcp)) iomfb_m4_debugfs_init(dcp, root); + if (dcp && dcp->notch_rows && dcp_notch_dynamic(dcp)) + debugfs_create_file("notch", 0444, root, dcp, ¬ch_fops); debugfs_create_file("ColorElements", 0444, root, apple_con, &chunk_color_fops); diff --git a/drivers/gpu/drm/apple/connector.h b/drivers/gpu/drm/apple/connector.h index 5d8c1674503fc..f32da7d3dee53 100644 --- a/drivers/gpu/drm/apple/connector.h +++ b/drivers/gpu/drm/apple/connector.h @@ -89,6 +89,12 @@ struct apple_connector { * chosen one; -1 until then, and nothing is sent. */ int bl_level; + /* + * The height limit of the probe in progress (fill_modes(), under + * mode_config.mutex): a client whose surface is shorter than the panel, + * the console's, is offered the notch-free modes (dcp-notch.h). + */ + u32 probe_max_y; }; #define to_apple_connector(x) container_of(x, struct apple_connector, base) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index f768e7b7ec8fe..3ee7a94854a1e 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -5,6 +5,7 @@ #define __APPLE_DCP_INTERNAL_H__ #include "dcp-indicator.h" +#include "dcp-notch.h" #include #include #include @@ -226,6 +227,8 @@ struct dcp_panel { int width_mm; /// panel height in millimeter int height_mm; + /// height below the notch rows (adj-height-mm), 0 if not given + u32 adj_height_mm; /// panel has a mini-LED backlight bool has_mini_led; /// peak panel luminance in nits, for EDR (0 if unknown or no EDR headroom) @@ -1043,6 +1046,8 @@ struct apple_dcp { struct mutex modes_lock; struct dcp_display_mode *modes; unsigned int nr_modes; + /* Of them, notch-free twins of the panel's timings (dcp-notch.h), last. */ + unsigned int nr_notch_twins; u64 modes_generation; u64 dimensions_generation; struct work_struct dimensions_wq; @@ -1058,7 +1063,23 @@ struct apple_dcp { /* an external display whose backlight DCP can drive */ bool ext_backlight; + /* + * Rows hidden for the whole boot, on the pipes that keep one notch + * geometry (firmware 14.7/26.6 standalone pipes); 0 elsewhere. + */ unsigned notch_height; + /* The panel's notch rows (apple,notch-height), shown or not; 0: no notch. */ + u32 notch_rows; + /* Active rows of the full panel, notch rows included (from its modes). */ + u32 notch_panel_rows; + /* enum dcp_notch_policy: the geometry asked for while a client owns the panel. */ + u8 notch_policy; + /* A DRM master owns the device (apple_drm_master_set/drop()). */ + bool notch_owned; + /* Panel rows above the last frame swapped in: the notch rows, or 0. */ + u32 notch_scanout_y; + /* The notch-free geometry is what a compositor is offered now. */ + bool notch_free_offered; /* Workqueue for sending vblank events when a dcp swap is not possible */ struct work_struct vblank_wq; @@ -1343,6 +1364,23 @@ void dcp_rtk_shmem_destroy(void *cookie, struct apple_rtkit_shmem *bfr); int dcp_retain_live_session(struct apple_dcp *dcp); /* T8132 firmware uses its own wire codec, with the common DRM/KMS owner. */ +/* The display's own timings: the catalogue less the notch-free twins. */ +static inline unsigned int dcp_nr_timings(const struct apple_dcp *dcp) +{ + return READ_ONCE(dcp->nr_modes) - READ_ONCE(dcp->nr_notch_twins); +} + +/* + * Pipes whose modes carry both notch geometries (dcp-notch.h). The + * standalone firmware 14.7/26.6 pipes build one mode from the boot + * framebuffer and keep the boot loader's geometry for the boot. + */ +static inline bool dcp_notch_dynamic(const struct apple_dcp *dcp) +{ + return dcp->fw_compat != DCP_FIRMWARE_V_14_7 && + dcp->fw_compat != DCP_FIRMWARE_V_26_6; +} + static inline bool iomfb_is_m4(const struct apple_dcp *dcp) { return IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) && diff --git a/drivers/gpu/drm/apple/dcp-m4-frame.h b/drivers/gpu/drm/apple/dcp-m4-frame.h index e51fe0a239bcb..abc59f0550b2c 100644 --- a/drivers/gpu/drm/apple/dcp-m4-frame.h +++ b/drivers/gpu/drm/apple/dcp-m4-frame.h @@ -29,13 +29,19 @@ struct dcp_m4_frame { u32 height; u32 stride; enum dcp_m4_frame_format format; + /* Panel rows above the frame: a notch-free frame starts below the notch. */ + u32 dst_y; }; +/* Most notch rows a panel frame may start below (as MAX_NOTCH_HEIGHT). */ +#define DCP_M4_MAX_DST_Y 160U + static inline int dcp_m4_frame_check(const struct dcp_m4_frame *frame) { u64 size = (u64)frame->stride * frame->height; - if (frame->width != DCP_M4_PANEL_WIDTH || frame->height != DCP_M4_PANEL_HEIGHT || + if (frame->width != DCP_M4_PANEL_WIDTH || frame->dst_y > DCP_M4_MAX_DST_Y || + frame->height + frame->dst_y != DCP_M4_PANEL_HEIGHT || frame->stride < DCP_M4_PANEL_WIDTH * 4 || frame->stride % 64 || !size || size > 0xffffffffULL || frame->backing_size < size || !frame->dva || frame->dva % 0x4000 || frame->dva >= (1ULL << 42) || @@ -78,19 +84,31 @@ static inline int dcp_m4_direct_extent(u64 dva, u64 mapped, u64 needed) return 0; } -/* Describe a qualified client framebuffer at its SID0 DVA; no CPU access. */ -static inline int dcp_m4_direct_frame(struct dcp_m4_frame *frame, u64 dva, u64 mapped, - u32 width, u32 height, u32 pitch, bool alpha) +/* + * Describe a qualified client framebuffer at its SID0 DVA, @dst_y rows down + * the panel; no CPU access. + */ +static inline int dcp_m4_direct_frame_at(struct dcp_m4_frame *frame, u64 dva, u64 mapped, + u32 width, u32 height, u32 pitch, bool alpha, + u32 dst_y) { *frame = (struct dcp_m4_frame) { .dva = dva, .backing_size = mapped, .width = width, .height = height, .stride = pitch, .format = alpha ? DCP_M4_ARGB8888 : DCP_M4_XRGB8888, + .dst_y = dst_y, }; if (dcp_m4_direct_extent(dva, mapped, (u64)pitch * height)) return -ERANGE; return dcp_m4_frame_check(frame); } +/* A full-panel client framebuffer. */ +static inline int dcp_m4_direct_frame(struct dcp_m4_frame *frame, u64 dva, u64 mapped, + u32 width, u32 height, u32 pitch, bool alpha) +{ + return dcp_m4_direct_frame_at(frame, dva, mapped, width, height, pitch, alpha, 0); +} + /* Exact single-layer fixture, not an ABI for tiled or compressed surfaces. */ static inline void dcp_m4_surface_encode(u8 *surface, const struct dcp_m4_frame *frame) { @@ -143,6 +161,7 @@ static inline int dcp_m4_frame_check_ext(const struct dcp_m4_frame *frame) u64 size = (u64)frame->stride * frame->height; if (!frame->width || !frame->height || frame->width > 3840 || frame->height > 2160 || + frame->dst_y || frame->stride < frame->width * 4 || frame->stride % 64 || !size || size > 0xffffffffULL || frame->backing_size < size || !frame->dva || frame->dva % 0x4000 || frame->dva >= (1ULL << 42) || @@ -235,6 +254,8 @@ static inline int dcp_m4_swap_encode_on(void *output, size_t length, u32 swap_id put_unaligned_le32(1, data + 0x9c); put_unaligned_le32(frame->width, data + 0xb4); put_unaligned_le32(frame->height, data + 0xb8); + /* Destination x, y, w, h: below the notch for a notch-free frame. */ + put_unaligned_le32(frame->dst_y, data + 0x110); put_unaligned_le32(frame->width, data + 0x114); put_unaligned_le32(frame->height, data + 0x118); dcp_m4_surface_encode(data + dcp_m4_pf->swap_surface, frame); diff --git a/drivers/gpu/drm/apple/dcp-notch.h b/drivers/gpu/drm/apple/dcp-notch.h new file mode 100644 index 0000000000000..c942394e1e34a --- /dev/null +++ b/drivers/gpu/drm/apple/dcp-notch.h @@ -0,0 +1,146 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * Runtime notch geometry of a built-in panel. + * + * A panel with a camera housing has apple,notch-height rows at its top that + * are only partly visible. The panel always runs its native timing; what + * changes is how much of it the OS draws on: + * + * - full: the mode covers the whole panel, notch rows included; + * - notch-free: the mode leaves out the notch rows. They are folded into + * the vertical sync, so the timing (clock, totals, rate) is + * the same, and the frame is scanned out below them; the + * rows stay black. + * + * Both geometries of a timing are in the mode catalogue, so the mode a commit + * carries chooses one, and switching between the two needs no mode set on the + * panel. Which one is offered to userspace follows a policy (the boot + * loader's choice, then the "notch" connector property or the connector's + * notch sysfs attribute) and, when no DRM master owns the device, the + * console: the console never draws under the notch. + */ +#ifndef APPLE_DCP_NOTCH_H +#define APPLE_DCP_NOTCH_H + +#ifndef DCP_NOTCH_HOST +#include +#include +#endif + +/* Values of the "notch" connector property. */ +enum dcp_notch_policy { + DCP_NOTCH_HIDDEN = 0, + DCP_NOTCH_SHOWN = 1, +}; + +/* + * Turn the full-panel @mode into its notch-free twin: @rows fewer active + * rows, folded into the vertical sync pulse. Returns false if the mode has + * no room for it. + */ +static inline bool dcp_notch_free_mode(struct drm_display_mode *mode, u32 rows) +{ + if (!rows || mode->vdisplay <= (int)rows || mode->vsync_start < mode->vdisplay) + return false; + mode->vdisplay -= rows; + mode->vsync_start -= rows; + return true; +} + +/* + * True if @free is the notch-free twin of the full-panel mode @full. DCP + * timings carry no skew or scan doubling, so those are not compared. + */ +static inline bool dcp_notch_twin_of(const struct drm_display_mode *full, + const struct drm_display_mode *free, u32 rows) +{ + return rows && full->clock == free->clock && + full->hdisplay == free->hdisplay && + full->hsync_start == free->hsync_start && + full->hsync_end == free->hsync_end && + full->htotal == free->htotal && + full->vdisplay == free->vdisplay + (int)rows && + full->vsync_start == free->vsync_start + (int)rows && + full->vsync_end == free->vsync_end && + full->vtotal == free->vtotal && + full->flags == free->flags; +} + +/* True if @a and @b are the two geometries of one timing (either order). */ +static inline bool dcp_notch_twins(const struct drm_display_mode *a, + const struct drm_display_mode *b, u32 rows) +{ + return dcp_notch_twin_of(a, b, rows) || dcp_notch_twin_of(b, a, rows); +} + +/* + * Rows to scan a frame of @mode out below: the notch rows for a notch-free + * mode of a panel @panel_rows high, 0 for a full one. + */ +static inline u32 dcp_notch_offset(const struct drm_display_mode *mode, + u32 panel_rows, u32 rows) +{ + return rows && panel_rows > rows && + mode->vdisplay == (int)(panel_rows - rows) ? rows : 0; +} + +/* + * The geometry userspace and the console are offered: the policy while a + * DRM master (a compositor, a boot splash) owns the device, notch-free + * otherwise, so that the text console never draws under the notch. + */ +static inline enum dcp_notch_policy +dcp_notch_effective(enum dcp_notch_policy policy, bool owned) +{ + return owned ? policy : DCP_NOTCH_HIDDEN; +} + +/* + * Whether a catalogue mode is offered, and as preferred: the modes of the + * effective geometry, so that a compositor follows a change of policy, and + * the notch-free ones also to a client that cannot take the full panel + * (@full_fits false: the console, whose surface is notch-free, re-probing + * while a compositor owns the device). The firmware's preferred timing + * stays preferred among what is offered. + */ +static inline bool dcp_notch_offer(bool notch_free, enum dcp_notch_policy effective, + bool full_fits, bool *preferred) +{ + bool offered = notch_free ? effective == DCP_NOTCH_HIDDEN || !full_fits : + effective == DCP_NOTCH_SHOWN && full_fits; + + *preferred = *preferred && offered; + return offered; +} + +/* + * Whether a probe offers only the notch-free geometry, which then sets the + * physical height it reports. A bounded probe (the console) gets the + * notch-free size whatever the policy, so that the size it keeps in its + * screen info does not change with the compositor's geometry. + */ +static inline bool dcp_notch_free_only(enum dcp_notch_policy effective, bool full_fits) +{ + return effective == DCP_NOTCH_HIDDEN || !full_fits; +} + +/* + * The physical height of the notch-free geometry: the panel's adj-height-mm + * if it gives one, else the full height scaled by the rows. + */ +static inline int dcp_notch_free_mm(int height_mm, u32 adj_mm, u32 full_rows, u32 free_rows) +{ + if (adj_mm) + return adj_mm; + if (!full_rows) + return height_mm; + return (int)(((u64)height_mm * free_rows + full_rows / 2) / full_rows); +} + +/* A probe limited to @max_y rows (0: none) can take the @panel_rows panel. */ +static inline bool dcp_notch_full_fits(u32 max_y, u32 panel_rows) +{ + return !max_y || !panel_rows || max_y >= panel_rows; +} + +#endif diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 9c794ebdb06e7..512dc0f588a11 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -542,9 +542,6 @@ bool dcp_h17p_external_ready(struct device_node *np) return ready; } -static bool show_notch; -module_param(show_notch, bool, 0644); -MODULE_PARM_DESC(show_notch, "Use the full display height and show the notch (also when /chosen/asahi,show-notch is \"1\")"); /* * DP/HDMI audio of external displays, on by default as on macOS: a display @@ -1428,8 +1425,11 @@ void dcp_panel_read_dimensions(struct apple_dcp *dcp, struct device_node *panel_ of_property_read_u32(panel_np, "width-mm", &dcp->panel.width_mm); /* Read the full height first: adj-height-mm is optional. */ of_property_read_u32(panel_np, "height-mm", &dcp->panel.height_mm); - if (dcp->notch_height) - of_property_read_u32(panel_np, "adj-height-mm", &dcp->panel.height_mm); + /* The notch-free geometry's height (dcp-notch.h); optional. */ + dcp->panel.adj_height_mm = 0; + of_property_read_u32(panel_np, "adj-height-mm", &dcp->panel.adj_height_mm); + if (dcp->notch_height && dcp->panel.adj_height_mm) + dcp->panel.height_mm = dcp->panel.adj_height_mm; } /* @@ -1696,10 +1696,9 @@ void dcp_set_dimensions(struct apple_dcp *dcp, u64 generation) width_mm = dcp->panel.width_mm; height_mm = dcp->panel.height_mm; } - if (connector) { - connector->display_info.width_mm = width_mm; - connector->display_info.height_mm = height_mm; - } + /* As get_modes() would: the notch-free geometry is shorter. */ + if (connector) + dcp_update_connector_dimensions(dcp, connector); for (i = 0; i < dcp->nr_modes; ++i) { dcp->modes[i].mode.width_mm = width_mm; dcp->modes[i].mode.height_mm = height_mm; @@ -1721,6 +1720,13 @@ void dcp_update_connector_dimensions(struct apple_dcp *dcp, width_mm = dcp->panel.width_mm; height_mm = dcp->panel.height_mm; } + /* The notch-free geometry is physically shorter (dcp-notch.h). */ + if (READ_ONCE(dcp->notch_free_offered)) { + u32 rows = READ_ONCE(dcp->notch_panel_rows); + + height_mm = dcp_notch_free_mm(height_mm, dcp->panel.adj_height_mm, + rows, rows - dcp->notch_rows); + } connector->display_info.width_mm = width_mm; connector->display_info.height_mm = height_mm; } @@ -2387,7 +2393,10 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_commit *commi if (!(crtc_state->plane_mask & drm_plane_mask(crtc->primary))) return -EINVAL; ret = iomfb_m4_get_mode(dcp, &mode); - return ret ? ret : drm_mode_equal(&crtc_state->mode, &mode) ? 0 : -EINVAL; + if (ret) + return ret; + /* The panel's timing, full or notch-free (dcp-notch.h). */ + return dcp_notch_mode_known(dcp, &crtc_state->mode) ? 0 : -EINVAL; } if (dcp->fw_compat == DCP_FIRMWARE_V_26_6) return iomfb_v26_6_atomic_check(dcp, crtc, commit); @@ -7370,14 +7379,21 @@ static int dcp_comp_bind_pipe(struct device *dev, struct device *main, void *dat dev_info(dev, "DCP index:%u dptx target phy: %u dptx die: %u\n", dcp->index, dcp->dptx_phy, dcp->dptx_die); - if (!show_notch && !boot_show_notch()) - ret = of_property_read_u32(dev->of_node, "apple,notch-height", - &dcp->notch_height); - - if (dcp->notch_height > MAX_NOTCH_HEIGHT) - dcp->notch_height = MAX_NOTCH_HEIGHT; - if (dcp->notch_height > 0) - dev_info(dev, "Detected display with notch of %u pixel\n", dcp->notch_height); + /* + * The notch rows are a fact of the panel; whether they are drawn on is + * the boot loader's choice first, then the user's, at run time (see + * dcp-notch.h). + */ + of_property_read_u32(dev->of_node, "apple,notch-height", &dcp->notch_rows); + dcp->notch_rows = min_t(u32, dcp->notch_rows, MAX_NOTCH_HEIGHT); + dcp->notch_policy = boot_show_notch() ? DCP_NOTCH_SHOWN : DCP_NOTCH_HIDDEN; + if (!dcp_notch_dynamic(dcp) && dcp->notch_policy == DCP_NOTCH_HIDDEN) + dcp->notch_height = dcp->notch_rows; + if (dcp->notch_rows) + dev_info(dev, "Detected display with notch of %u pixel (%s%s)\n", + dcp->notch_rows, + dcp->notch_policy == DCP_NOTCH_SHOWN ? "shown" : "hidden", + dcp_notch_dynamic(dcp) ? "" : " for this boot"); /* initialize brightness scale to a sensible default to avoid divide by 0*/ dcp->brightness.scale = 65536; diff --git a/drivers/gpu/drm/apple/dcp.h b/drivers/gpu/drm/apple/dcp.h index 4ea6ebc535f5f..8283f6c873e51 100644 --- a/drivers/gpu/drm/apple/dcp.h +++ b/drivers/gpu/drm/apple/dcp.h @@ -229,4 +229,6 @@ int dcp_peer_stop_26_6(struct apple_dcp *dcp); void dcp_peer_release_26_6(struct apple_dcp *dcp); void dcp_peer_bound_26_6(struct apple_dcp *dcp); +bool dcp_notch_mode_known(struct apple_dcp *dcp, const struct drm_display_mode *mode); + #endif diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index cbc093e132fc8..5ff1a35b9890b 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -2422,6 +2422,55 @@ struct dcp_display_mode *dcp_modes_dup(struct apple_dcp *dcp, return modes; } +/* Notch-free twins in a catalogue; dcp_notch_add_twins() puts them last. */ +static unsigned int dcp_notch_twin_count(const struct dcp_display_mode *modes, + unsigned int count) +{ + unsigned int i, twins = 0; + + for (i = 0; modes && i < count; i++) + twins += modes[i].notch_free; + return twins; +} + +/* + * Give every full-panel timing of a panel with @rows notch rows its + * notch-free twin (dcp-notch.h), after the full ones, and report the full + * panel's active rows in @panel_rows. The automatic 180 Hz exception is an + * external display's and gets none. + */ +static int dcp_notch_add_twins(struct dcp_display_mode **modes, unsigned int *count, + u32 rows, u32 *panel_rows) +{ + struct dcp_display_mode *all; + unsigned int i, n = *count, twins = 0; + + *panel_rows = 0; + if (!rows || !n) + return 0; + all = krealloc_array(*modes, 2 * n, sizeof(**modes), GFP_KERNEL | __GFP_NOWARN); + if (!all) + return -ENOMEM; + *modes = all; + for (i = 0; i < n; i++) { + struct dcp_display_mode *twin = &all[n + twins]; + + if (all[i].notch_free || all[i].automatic_rgb8_quirk) + continue; + if (all[i].mode.vdisplay > *panel_rows) + *panel_rows = all[i].mode.vdisplay; + *twin = all[i]; + if (!dcp_notch_free_mode(&twin->mode, rows)) + continue; + twin->notch_free = true; + drm_mode_set_name(&twin->mode); + all[i].notch_twin = true; + twins++; + } + *count = n + twins; + return 0; +} + /* * A display came to @dcp from another pipeline without being unplugged: * offer the modes it had there until the firmware here describes it. @@ -2446,6 +2495,7 @@ void dcp_modes_adopt(struct apple_dcp *dcp, struct apple_connector *connector, spin_lock_irqsave(&dcp->metadata.lock, flags); dcp->modes = modes; dcp->nr_modes = count; + dcp->nr_notch_twins = dcp_notch_twin_count(modes, count); spin_unlock_irqrestore(&dcp->metadata.lock, flags); dcp->modes_admitted = true; dcp->modes_provisional = true; @@ -2483,7 +2533,7 @@ int dcp_modes_replace(struct apple_dcp *dcp, struct dcp_parse_ctx *ctx, unsigned int nr_modes = 0, i; unsigned long flags; bool provisional; - u32 entries = 0; + u32 entries = 0, panel_rows = 0; int ret = 0; /* A stale transfer is refused before it is parsed, as it is published. */ @@ -2534,6 +2584,16 @@ int dcp_modes_replace(struct apple_dcp *dcp, struct dcp_parse_ctx *ctx, kfree(modes); return -EINVAL; } else { + /* A notched panel offers both geometries of its timings. */ + if (dcp->fixed_connector_type == DRM_MODE_CONNECTOR_eDP && + dcp->notch_rows && dcp_notch_dynamic(dcp)) { + ret = dcp_notch_add_twins(&modes, &nr_modes, dcp->notch_rows, + &panel_rows); + if (ret) { + kfree(modes); + return ret; + } + } for (i = 0; i < nr_modes; i++) if (modes[i].automatic_rgb8_quirk) { modes[i].unsafe_rgb8_ticket = rate_ticket; @@ -2558,6 +2618,9 @@ int dcp_modes_replace(struct apple_dcp *dcp, struct dcp_parse_ctx *ctx, modes[i].automatic_catalog_sequence = dcp->rate_proof.catalog_sequence; dcp->modes = modes; dcp->nr_modes = nr_modes; + dcp->nr_notch_twins = dcp_notch_twin_count(modes, nr_modes); + if (panel_rows) + WRITE_ONCE(dcp->notch_panel_rows, panel_rows); /* Only a complete receipt for a current cable is that cable's catalogue. */ dcp->metadata.catalog_ticket = rate_ticket; dcp->metadata.catalog_ticket.associated &= nr_modes > 0; @@ -2691,6 +2754,7 @@ void dcp_modes_release(void *data) kfree(dcp->modes); dcp->modes = NULL; dcp->nr_modes = 0; + dcp->nr_notch_twins = 0; } /* Under mode_config.mutex, in get_modes: the identity of the EDID being published. */ static void dcp_note_edid(struct apple_connector *connector, const struct drm_edid *drm_edid) @@ -2770,6 +2834,8 @@ int dcp_get_modes(struct drm_connector *connector) bool vrr_capable = false; bool physical_edid; bool pending_180hz = false, published_180hz = false; + enum dcp_notch_policy effective; + bool full_fits; u64 edid_generation = 0; u64 service_epoch = 0; unsigned int i; @@ -2786,19 +2852,55 @@ int dcp_get_modes(struct drm_connector *connector) } dcp = platform_get_drvdata(pdev); if (iomfb_is_m4(dcp)) { - struct drm_display_mode fixed; + struct drm_display_mode fixed, free; + bool preferred; + int n = 0; if (iomfb_m4_get_mode(dcp, &fixed)) return 0; - mode = drm_mode_duplicate(dev, &fixed); - if (!mode) - return 0; - drm_mode_probed_add(connector, mode); + /* Its panel timing, in both notch geometries (dcp-notch.h). */ + free = fixed; + if (dcp->notch_rows && dcp_notch_free_mode(&free, dcp->notch_rows)) { + WRITE_ONCE(dcp->notch_panel_rows, fixed.vdisplay); + drm_mode_set_name(&free); + effective = dcp_notch_effective(READ_ONCE(dcp->notch_policy), + READ_ONCE(dcp->notch_owned)); + full_fits = dcp_notch_full_fits(apple_connector->probe_max_y, + fixed.vdisplay); + preferred = true; + if (dcp_notch_offer(false, effective, full_fits, &preferred)) { + mode = drm_mode_duplicate(dev, &fixed); + if (mode) { + drm_mode_probed_add(connector, mode); + n++; + } + } + preferred = true; + mode = NULL; + if (dcp_notch_offer(true, effective, full_fits, &preferred)) { + if (!preferred) + free.type &= ~DRM_MODE_TYPE_PREFERRED; + mode = drm_mode_duplicate(dev, &free); + } + } else { + mode = drm_mode_duplicate(dev, &fixed); + } + if (mode) { + drm_mode_probed_add(connector, mode); + n++; + } of_property_read_u32(dcp->dev->of_node, "apple,panel-width-mm", &connector->display_info.width_mm); of_property_read_u32(dcp->dev->of_node, "apple,panel-height-mm", &connector->display_info.height_mm); - return 1; + /* The physical size follows the geometry this probe offers. */ + if (free.vdisplay < fixed.vdisplay && + dcp_notch_free_only(effective, full_fits)) + connector->display_info.height_mm = + dcp_notch_free_mm(connector->display_info.height_mm, + dcp->panel.adj_height_mm, fixed.vdisplay, + free.vdisplay); + return n; } modes = dcp_modes_snapshot(dcp, apple_connector, &nr_modes); @@ -2937,7 +3039,10 @@ int dcp_get_modes(struct drm_connector *connector) u32 defaults = 0; bool panel = dcp->panel_identity && dcp_has_panel(dcp); const struct drm_edid *derived = nr_modes ? - (panel ? dcp_panel_edid_snapshot(dcp, modes, nr_modes, &generation) : + /* The panel's EDID lists its timings, not their notch-free twins. */ + (panel ? dcp_panel_edid_snapshot(dcp, modes, nr_modes - + dcp_notch_twin_count(modes, nr_modes), + &generation) : dcp_firmware_edid(dcp, &generation, &defaults)) : ERR_PTR(-ENODATA); if (!IS_ERR(derived)) { @@ -2989,13 +3094,36 @@ int dcp_get_modes(struct drm_connector *connector) modes = dcp_modes_snapshot(dcp, apple_connector, &nr_modes); } /* Publish after a possibly delayed raw read, under its physical generation. */ + effective = dcp_notch_effective(READ_ONCE(dcp->notch_policy), + READ_ONCE(dcp->notch_owned)); + full_fits = dcp_notch_full_fits(apple_connector->probe_max_y, + READ_ONCE(dcp->notch_panel_rows)); + /* What this probe offers sets the reported physical size. */ + if (dcp->notch_rows && dcp_notch_dynamic(dcp)) + WRITE_ONCE(dcp->notch_free_offered, + dcp_notch_free_only(effective, full_fits)); for (i = 0; i < nr_modes; ++i) { + bool preferred = modes[i].mode.type & DRM_MODE_TYPE_PREFERRED; + + /* A timing without a twin is offered as it is. */ + if ((modes[i].notch_free || modes[i].notch_twin) && + !dcp_notch_offer(modes[i].notch_free, effective, full_fits, &preferred)) + continue; + mode = drm_mode_duplicate(dev, &modes[i].mode); if (!mode) { dev_err(dev->dev, "Failed to duplicate display mode\n"); published = 0; goto modes_done; } + if (!preferred) + mode->type &= ~DRM_MODE_TYPE_PREFERRED; + /* The notch-free geometry is physically shorter too. */ + if (modes[i].notch_free) + mode->height_mm = dcp_notch_free_mm(mode->height_mm, + dcp->panel.adj_height_mm, + READ_ONCE(dcp->notch_panel_rows), + mode->vdisplay); pending_180hz |= modes[i].automatic_rgb8_quirk && dcp_180hz_pending(dcp, &modes[i]); if (!dcp_publish_mode(dcp, connector, &modes[i], mode)) @@ -3578,6 +3706,34 @@ int dcp_crtc_check_hdr(struct apple_dcp *dcp, struct drm_crtc *crtc, return dcp_select_color_mode(mode, &req, &selected); } +/* + * Panel rows above a frame of @mode on the M4 pipe: the notch rows for the + * notch-free twin of the panel timing, else 0. From the timing the firmware + * reports, as iomfb_m4_plane_frame() checks the frame against. + */ +static u32 dcp_m4_notch_y(struct apple_dcp *dcp, const struct drm_display_mode *mode) +{ + struct drm_display_mode fixed; + + if (!dcp->notch_rows || iomfb_m4_get_mode(dcp, &fixed)) + return 0; + WRITE_ONCE(dcp->notch_panel_rows, fixed.vdisplay); + return dcp_notch_twin_of(&fixed, mode, dcp->notch_rows) ? dcp->notch_rows : 0; +} + +/* @mode is one of the panel's own, in either notch geometry (dcp-notch.h). */ +bool dcp_notch_mode_known(struct apple_dcp *dcp, const struct drm_display_mode *mode) +{ + struct drm_display_mode fixed; + + if (!iomfb_is_m4(dcp)) + return lookup_mode(dcp, mode, NULL); + if (iomfb_m4_get_mode(dcp, &fixed)) + return false; + return drm_mode_match(mode, &fixed, DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_CLOCK) || + dcp_notch_twin_of(&fixed, mode, dcp->notch_rows); +} + static const struct dcp_display_mode * dcp_find_mode(struct apple_dcp *dcp, const struct drm_display_mode *mode) { @@ -3666,7 +3822,8 @@ enum drm_mode_status dcp_mode_valid(struct drm_connector *connector, if (iomfb_is_m4(dcp)) { struct drm_display_mode fixed; - return !iomfb_m4_get_mode(dcp, &fixed) && drm_mode_equal(mode, &fixed) ? + /* The panel's timing, full or notch-free (dcp-notch.h). */ + return !iomfb_m4_get_mode(dcp, &fixed) && dcp_notch_mode_known(dcp, mode) ? MODE_OK : MODE_BAD; } @@ -3700,7 +3857,7 @@ int dcp_crtc_atomic_modeset(struct drm_crtc *crtc, if (!crtc_state || !crtc_state->active) return 0; ret = iomfb_m4_get_mode(dcp, &fixed); - return ret ? ret : drm_mode_equal(&crtc_state->mode, &fixed) ? 0 : -EINVAL; + return ret ? ret : dcp_notch_mode_known(dcp, &crtc_state->mode) ? 0 : -EINVAL; } /* Disconnect cannot pass the admission check before these RPCs finish. */ @@ -3893,7 +4050,7 @@ bool dcp_crtc_mode_fixup(struct drm_crtc *crtc, if (iomfb_is_m4(dcp)) { struct drm_display_mode fixed; - return !iomfb_m4_get_mode(dcp, &fixed) && drm_mode_equal(mode, &fixed); + return !iomfb_m4_get_mode(dcp, &fixed) && dcp_notch_mode_known(dcp, mode); } /* @@ -4502,9 +4659,14 @@ void dcp_flush(struct drm_crtc *crtc, struct drm_atomic_commit *commit) ret = iomfb_m4_error(dcp); /* A CRTC-only commit publishes no new framebuffer. */ if (!ret && plane) { + /* A notch-free mode is scanned out below the notch rows. */ + u32 dst_y = dcp_m4_notch_y(dcp, &new->mode); + obj = plane->fb ? drm_fb_dma_get_gem_obj(plane->fb, 0) : NULL; - ret = obj ? iomfb_m4_present(dcp, plane->fb, obj->dma_addr, - obj->base.size) : -EINVAL; + ret = obj ? iomfb_m4_present_at(dcp, plane->fb, obj->dma_addr, + obj->base.size, dst_y) : -EINVAL; + if (!ret) + WRITE_ONCE(dcp->notch_scanout_y, dst_y); } if (ret) dcp_drm_crtc_error(to_apple_crtc(crtc), new, -EIO); diff --git a/drivers/gpu/drm/apple/iomfb_m4.c b/drivers/gpu/drm/apple/iomfb_m4.c index da94f912821e4..782585b1144bb 100644 --- a/drivers/gpu/drm/apple/iomfb_m4.c +++ b/drivers/gpu/drm/apple/iomfb_m4.c @@ -2208,7 +2208,7 @@ static int dcp_m4_runtime_swap_full(struct dcp_m4_runtime *r, bool primary, !r->power_done || !r->background_done || !dcp->scanout)) return -EINVAL; if ((primary && frame && (check(frame) || frame->width != width || - frame->height != height)) || + frame->height + frame->dst_y != height)) || (upper && dcp_m4_upper_check_on(upper, width, height))) return -EINVAL; /* @@ -3569,8 +3569,9 @@ static int iomfb_m4_swap(struct iomfb_m4 *dcp, const struct dcp_m4_frame *frame) return ret; } -int iomfb_m4_present(struct apple_dcp *owner, struct drm_framebuffer *fb, - dma_addr_t dva, size_t mapped) +/* 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) { struct iomfb_m4 *dcp = owner->v26_6; struct drm_framebuffer *retire = NULL; @@ -3582,8 +3583,9 @@ int iomfb_m4_present(struct apple_dcp *owner, struct drm_framebuffer *fb, (fb->format->format != DRM_FORMAT_XRGB8888 && fb->format->format != DRM_FORMAT_ARGB8888)) return -EINVAL; - ret = dcp_m4_direct_frame(&frame, dva, mapped, fb->width, fb->height, - fb->pitches[0], fb->format->format == DRM_FORMAT_ARGB8888); + ret = dcp_m4_direct_frame_at(&frame, dva, mapped, fb->width, fb->height, + fb->pitches[0], fb->format->format == DRM_FORMAT_ARGB8888, + dst_y); if (ret) return ret; /* A power-down not yet started is not needed; one under way finishes first. */ @@ -3631,6 +3633,12 @@ int iomfb_m4_present(struct apple_dcp *owner, struct drm_framebuffer *fb, return ret; } +int iomfb_m4_present(struct apple_dcp *owner, struct drm_framebuffer *fb, + dma_addr_t dva, size_t mapped) +{ + return iomfb_m4_present_at(owner, fb, dva, mapped, 0); +} + int iomfb_m4_blank(struct apple_dcp *owner) { struct iomfb_m4 *dcp = owner->v26_6; diff --git a/drivers/gpu/drm/apple/iomfb_m4.h b/drivers/gpu/drm/apple/iomfb_m4.h index cfd10118d0836..dce9aeec38448 100644 --- a/drivers/gpu/drm/apple/iomfb_m4.h +++ b/drivers/gpu/drm/apple/iomfb_m4.h @@ -86,6 +86,8 @@ bool iomfb_m4_sleep_stopped(struct apple_dcp *dcp); /* The caller has waited for the producer fence before publishing the DMA GEM. */ int iomfb_m4_present(struct apple_dcp *dcp, struct drm_framebuffer *fb, dma_addr_t dva, size_t mapped); +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); int iomfb_m4_suspend(struct apple_dcp *dcp); int iomfb_m4_resume(struct apple_dcp *dcp); @@ -172,6 +174,12 @@ static inline int iomfb_m4_present(struct apple_dcp *dcp, struct drm_framebuffer { return -ENODEV; } + +static inline int iomfb_m4_present_at(struct apple_dcp *dcp, struct drm_framebuffer *fb, + dma_addr_t dva, size_t mapped, u32 dst_y) +{ + return -ENODEV; +} static inline int iomfb_m4_blank(struct apple_dcp *dcp) { 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; } diff --git a/drivers/gpu/drm/apple/iomfb_m4_present.h b/drivers/gpu/drm/apple/iomfb_m4_present.h index 6f51b936137b9..fc1ee3eba8cee 100644 --- a/drivers/gpu/drm/apple/iomfb_m4_present.h +++ b/drivers/gpu/drm/apple/iomfb_m4_present.h @@ -11,6 +11,11 @@ #include "dcp-m4-frame.h" +/* + * A frame of the @width x @height mode: the panel's, or its notch-free twin + * (dcp-notch.h), which dcp_crtc_atomic_check() admits and which starts its + * notch rows down the panel. + */ static inline int iomfb_m4_plane_frame(const struct drm_plane_state *state, u32 width, u32 height, struct dcp_m4_frame *frame) @@ -29,9 +34,11 @@ static inline int iomfb_m4_plane_frame(const struct drm_plane_state *state, obj = drm_fb_dma_get_gem_obj(fb, 0); if (!obj) return -EINVAL; - return dcp_m4_direct_frame(frame, obj->dma_addr, obj->base.size, - fb->width, fb->height, fb->pitches[0], - fb->format->format == DRM_FORMAT_ARGB8888); + return dcp_m4_direct_frame_at(frame, obj->dma_addr, obj->base.size, + fb->width, fb->height, fb->pitches[0], + fb->format->format == DRM_FORMAT_ARGB8888, + height < DCP_M4_PANEL_HEIGHT ? + DCP_M4_PANEL_HEIGHT - height : 0); } #endif diff --git a/drivers/gpu/drm/apple/iomfb_template.c b/drivers/gpu/drm/apple/iomfb_template.c index 050522f5a6fda..b610e045c9549 100644 --- a/drivers/gpu/drm/apple/iomfb_template.c +++ b/drivers/gpu/drm/apple/iomfb_template.c @@ -541,7 +541,7 @@ static bool __maybe_unused DCP_FW_NAME(dcp_fw27_keep_panel_mode)(struct apple_dc if (policy == 0 || !dcp->main_display || !dcp_has_panel(dcp)) return false; - return policy > 0 || READ_ONCE(dcp->nr_modes) == 1; + return policy > 0 || dcp_nr_timings(dcp) == 1; #else return false; #endif @@ -4120,7 +4120,7 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp, * single fixed timing it advertises, already matched above. */ if (dcp_has_panel(dcp) && dcp->main_display && - READ_ONCE(dcp->nr_modes) == 1 && !mode->vrr) { + dcp_nr_timings(dcp) == 1 && !mode->vrr) { dcp->desktop->mode_live = true; return 0; } @@ -4447,7 +4447,7 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp, dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_H17P_EXTERNAL) { dev_info(dcp->dev, "inheriting the bootloader's display mode (%u fixed timing(s))\n", - READ_ONCE(dcp->nr_modes)); + dcp_nr_timings(dcp)); complete_set_digital_out_mode(dcp, NULL, cookie); } else #if (DCP_FW_H17(DCP_FW_VER) && DCP_FW_VER >= DCP_FW_VERSION(27, 0, 0)) @@ -4595,6 +4595,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru struct DCP_FW_NAME(dcp_swap_submit_req) *req = &DCP_FW_SWAP(dcp); int plane_idx, l; int has_surface = 0; + u32 notch_y; #if !DCP_FW_DESKTOP_26(DCP_FW_VER) bool update_brightness; @@ -4656,8 +4657,12 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru req->swap.surf_ids[apl_plane->iomfb_surf] = plane->base.id; #endif - if (dcp->notch_height > 0) - req->swap.dst_rect[l].y += dcp->notch_height; + /* A notch-free mode is scanned out below the notch rows. */ + notch_y = dcp_notch_offset(&crtc_state->mode, + READ_ONCE(dcp->notch_panel_rows), + dcp->notch_rows); + WRITE_ONCE(dcp->notch_scanout_y, notch_y); + req->swap.dst_rect[l].y += dcp->notch_height + notch_y; req->surf_iova[l] = apple_state->iova; req->surf[l].base = apple_state->surf; diff --git a/drivers/gpu/drm/apple/iomfb_v26_6.c b/drivers/gpu/drm/apple/iomfb_v26_6.c index 2f0b1ffa1ae08..2497f4839d1ce 100644 --- a/drivers/gpu/drm/apple/iomfb_v26_6.c +++ b/drivers/gpu/drm/apple/iomfb_v26_6.c @@ -28,7 +28,7 @@ * Scanout is one plane, XRGB8888 or ARGB8888, linear, exactly the mode size. * Each flush is one swap, completed when the firmware reports that swap id, * and then the page-flip event is sent. The notch rows (apple,notch-height, - * unless appledrm.show_notch=1) are outside the mode and stay black. + * unless the boot loader kept them) are outside the mode and stay black. */ #include diff --git a/drivers/gpu/drm/apple/parser.h b/drivers/gpu/drm/apple/parser.h index d7edfa8721ca5..aff4b4cb45cb5 100644 --- a/drivers/gpu/drm/apple/parser.h +++ b/drivers/gpu/drm/apple/parser.h @@ -198,6 +198,10 @@ struct dcp_display_mode { u64 automatic_catalog_sequence; bool automatic_service_pending; bool has_bootstrap; + /* The notch-free twin of a full-panel timing (dcp-notch.h). */ + bool notch_free; + /* A full-panel timing that has one. */ + bool notch_twin; /* Immutable receipt provenance; never retag a cached exception. */ struct dcp_metadata_ticket unsafe_rgb8_ticket; u64 unsafe_rgb8_service_epoch; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py b/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py index 1eb7f35674986..d4be625429d7d 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/desktop.py @@ -437,7 +437,7 @@ def panel_identity(root, output=None): struct apple_dcp { int fw_compat;bool has_panel;struct {bool lock;} metadata; struct dcp_panel_identity *panel_identity; - struct {u32 width_mm,height_mm,peak_nits;const struct dcp_color_space *color_target;} panel;void *connector; + struct {u32 width_mm,height_mm,adj_height_mm,peak_nits;const struct dcp_color_space *color_target;} panel;void *connector; }; static unsigned notifications; static bool dcp_has_panel(struct apple_dcp *d) {return d->has_panel;} diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/display.py b/tools/testing/selftests/drivers/gpu/apple-dcp/display.py index e385105e186f5..a22159b54f62b 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/display.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/display.py @@ -362,6 +362,268 @@ def case(elements, expected, ranges=None, desktop=True): return prefix + parser + '\n'.join(blobs) + '\nint main(void){' + '\n'.join(checks) + 'return 0;}' +def notch(root): + """Both notch geometries of a panel timing (dcp-notch.h), through the + production parser and catalogue code: the notch-free twin is exactly the + mode the boot-time hidden notch gave, and offer, offset and ownership + follow the policy.""" + f = rate.parser_fixture(root) + iomfb = (root / 'drivers/gpu/drm/apple/iomfb.c').read_text() + twins = (block(iomfb, 'static unsigned int dcp_notch_twin_count(') + '\n' + + block(iomfb, 'static int dcp_notch_add_twins(')) + prefix = (f['prefix'] + f['epoch'] + f['metadata'] + f['header']).replace( + 'static inline ', 'static inline __attribute__((unused)) ') + # The J615 panel timing as its DCP reports it (2880x1864 at 60 Hz, from our + # own boot log), with the 64 rows of its apple,notch-height. + m = copy.deepcopy(f['timing_fixture'][0]) + m['HorizontalAttributes'].update(Active=2880, FrontPorch=8, SyncWidth=32, Total=2960) + m['VerticalAttributes'].update(Active=1864, FrontPorch=47, SyncWidth=8, Total=1961) + raw = bytearray(struct.pack(' +#include +#include +#include +typedef uint32_t u32; +#define READ_ONCE(x) (x) +#define WRITE_ONCE(x, v) ((x) = (v)) +#define xchg(p, v) __atomic_exchange_n((p), (v), __ATOMIC_SEQ_CST) +#define min(a, b) ((a) < (b) ? (a) : (b)) +enum { DCP_FIRMWARE_V_14_7, DCP_FIRMWARE_V_26_6, DCP_FIRMWARE_V_27_0, + DCP_FIRMWARE_H17P, DCP_FIRMWARE_V_13_5 }; +struct apple_dcp { int fw_compat; u32 notch_rows, notch_panel_rows; bool notch_owned; }; +struct drm_crtc { struct apple_dcp *dcp; bool ext; }; +struct drm_file { int unused; }; +struct work_struct { int scheduled; }; +struct drm_device { struct drm_crtc *crtcs; int n; bool unplugged; }; +struct apple_drm_private { + struct drm_device drm; + struct work_struct notch_console; + bool notch_console_stale; +}; +struct drm_fb_helper { struct drm_device *dev; }; +struct drm_fb_helper_surface_size { u32 surface_width, surface_height, fb_width, fb_height, + surface_bpp, surface_depth; }; +static struct apple_drm_private apple; +#define container_of(p, t, m) ((t *)((char *)(p) - __builtin_offsetof(t, m))) +static struct apple_drm_private *to_apple_drm(struct drm_device *drm) +{ return container_of(drm, struct apple_drm_private, drm); } +#define drm_for_each_crtc(c, dev) \ + for (int _i = 0; _i < (dev)->n && ((c) = &(dev)->crtcs[_i]); _i++) +static bool t8132_ext_crtc(struct drm_crtc *c) { return c->ext; } +static struct drm_crtc *to_apple_crtc(struct drm_crtc *c) { return c; } +static struct apple_dcp *platform_get_drvdata(struct apple_dcp *d) { return d; } +static bool dcp_notch_dynamic(const struct apple_dcp *dcp) +{ return dcp->fw_compat != DCP_FIRMWARE_V_14_7 && dcp->fw_compat != DCP_FIRMWARE_V_26_6; } +static bool drm_dev_is_unplugged(struct drm_device *d) { return d->unplugged; } +static int kicks; +static void schedule_work(struct work_struct *w) { w->scheduled++; kicks++; } +static int probes; +static int drm_fbdev_dma_driver_fbdev_probe(struct drm_fb_helper *h, + struct drm_fb_helper_surface_size *s) +{ (void)h; (void)s; probes++; return 0; } +''' + +NOTCH_CONSOLE_MAIN = r''' +static struct apple_dcp panel = { DCP_FIRMWARE_V_13_5, 64, 1864, false }; +static struct drm_crtc crtcs[2]; +static struct drm_file file; + +/* The console's first probe, at the height of the mode it picked. */ +static u32 first_probe(u32 rows) +{ + struct drm_fb_helper h = { &apple.drm }; + struct drm_fb_helper_surface_size s = { 2880, rows, 2880, rows, 32, 24 }; + + assert(!apple_drm_fbdev_probe(&h, &s)); + assert(s.fb_height <= s.surface_height); + return s.surface_height; +} + +int main(void) +{ + crtcs[0].dcp = &panel; + crtcs[1].dcp = &panel; crtcs[1].ext = true; + apple.drm.crtcs = crtcs; apple.drm.n = 2; + + /* A normal boot: the console probed with no master, notch-free already. */ + assert(first_probe(1800) == 1800 && !apple.notch_console_stale); + /* Every handoff afterwards leaves the console alone. */ + for (int i = 0; i < 4; i++) { + apple_drm_master_set(&apple.drm, &file, true); + assert(panel.notch_owned); + apple_drm_master_drop(&apple.drm, &file); + assert(!panel.notch_owned); + } + assert(kicks == 0); + + /* A splash held master with the notch shown: the clamp fires... */ + apple_drm_master_set(&apple.drm, &file, true); + assert(first_probe(1864) == 1800 && apple.notch_console_stale); + /* ...and only the first drop after it asks the console to re-probe. */ + apple_drm_master_drop(&apple.drm, &file); + assert(kicks == 1 && apple.notch_console.scheduled == 1 && !apple.notch_console_stale); + apple_drm_master_set(&apple.drm, &file, false); + apple_drm_master_drop(&apple.drm, &file); + assert(kicks == 1); + + /* An unplugged device schedules nothing. */ + apple_drm_master_set(&apple.drm, &file, true); + assert(first_probe(1864) == 1800 && apple.notch_console_stale); + apple.drm.unplugged = true; + apple_drm_master_drop(&apple.drm, &file); + assert(kicks == 1); + apple.drm.unplugged = false; + apple.notch_console_stale = false; + + /* Pipes that keep one geometry for the boot (14.7, 26.6): no clamp, no kick. */ + panel.fw_compat = DCP_FIRMWARE_V_26_6; + apple_drm_master_set(&apple.drm, &file, true); + assert(first_probe(1864) == 1864 && !apple.notch_console_stale); + apple_drm_master_drop(&apple.drm, &file); + assert(kicks == 1); + + /* No notch rows: nothing. */ + panel.fw_compat = DCP_FIRMWARE_V_13_5; panel.notch_rows = 0; + assert(first_probe(1864) == 1864 && !apple.notch_console_stale); + apple_drm_master_drop(&apple.drm, &file); + assert(kicks == 1 && probes == 5); + puts("PASS: notch console re-probe only after a stale first probe"); + return 0; +} +''' + +NOTCH_MAIN = r''' +int main(void) +{ + struct dcp_parse_ctx c; + struct dcp_display_mode *m, *hidden; + unsigned n = 0, nh = 0; + u32 panel = 0; + bool pref; + + /* What the boot-time hidden notch produced. */ + assert(!parse(j615, sizeof(j615), &c)); + hidden = enumerate_modes(&c, &nh, 327, 212, 64, true, false); + assert(!IS_ERR(hidden) && nh == 1 && hidden[0].mode.vdisplay == 1800); + + assert(!parse(j615, sizeof(j615), &c)); + m = enumerate_modes(&c, &n, 327, 212, 0, true, false); + assert(!IS_ERR(m) && n == 1 && m[0].mode.vdisplay == 1864); + assert(m[0].mode.vsync_start == 1911 && m[0].mode.vsync_end == 1919 && m[0].mode.vtotal == 1961); + assert(!dcp_notch_add_twins(&m, &n, 64, &panel)); + assert(n == 2 && panel == 1864 && dcp_notch_twin_count(m, n) == 1); + assert(!m[0].notch_free && m[1].notch_free && m[0].notch_twin && !m[1].notch_twin); + /* get_modes() gives the twin its physical height: adj-height-mm, else scaled by rows. */ + assert(m[0].mode.height_mm == 212 && m[1].mode.height_mm == 212); + assert(dcp_notch_free_mm(m[1].mode.height_mm, 0, 1864, m[1].mode.vdisplay) == 205); + assert(dcp_notch_free_mm(212, 199, 1864, 1800) == 199 && dcp_notch_free_mm(212, 0, 0, 1800) == 212); + /* The twin is that same mode: one timing, the notch rows folded into the sync. */ + assert(m[1].mode.vdisplay == hidden[0].mode.vdisplay && + m[1].mode.vsync_start == hidden[0].mode.vsync_start && + m[1].mode.vsync_end == hidden[0].mode.vsync_end && + m[1].mode.vtotal == hidden[0].mode.vtotal && + m[1].mode.clock == hidden[0].mode.clock && + m[1].mode.hdisplay == hidden[0].mode.hdisplay && + m[1].mode.hsync_start == hidden[0].mode.hsync_start && + m[1].mode.htotal == hidden[0].mode.htotal && + m[1].mode.flags == hidden[0].mode.flags); + assert(m[1].mode.vdisplay == 1800 && m[1].mode.vsync_start == 1847); + assert(m[1].timing_mode_id == m[0].timing_mode_id && m[1].color_mode_id == m[0].color_mode_id); + assert((m[1].mode.type & DRM_MODE_TYPE_PREFERRED) == (m[0].mode.type & DRM_MODE_TYPE_PREFERRED)); + assert(dcp_notch_twin_of(&m[0].mode, &m[1].mode, 64)); + assert(!dcp_notch_twin_of(&m[1].mode, &m[0].mode, 64)); + assert(dcp_notch_twins(&m[0].mode, &m[1].mode, 64) && dcp_notch_twins(&m[1].mode, &m[0].mode, 64)); + assert(!dcp_notch_twins(&m[0].mode, &m[1].mode, 63) && !dcp_notch_twins(&m[0].mode, &m[0].mode, 64)); + { + struct drm_display_mode other = m[1].mode; + + other.clock++; + assert(!dcp_notch_twins(&m[0].mode, &other, 64)); + } + /* Scan-out offset: below the notch for the twin only. */ + assert(dcp_notch_offset(&m[1].mode, panel, 64) == 64); + assert(dcp_notch_offset(&m[0].mode, panel, 64) == 0); + assert(dcp_notch_offset(&m[1].mode, panel, 0) == 0 && dcp_notch_offset(&m[1].mode, 0, 64) == 0); + /* A twin gets no twin of its own. */ + assert(!dcp_notch_add_twins(&m, &n, 64, &panel) && n == 3 && dcp_notch_twin_count(m, n) == 2); + assert(m[2].notch_free && m[2].mode.vdisplay == 1800); + /* A timing too short for the rows gets no twin and stays unmarked (offered as is). */ + { + unsigned k = 1; + struct dcp_display_mode *one = calloc(1, sizeof(*one)); + + one[0] = hidden[0]; + assert(!dcp_notch_add_twins(&one, &k, 1800, &panel) && k == 1 && !one[0].notch_twin); + free(one); + } + /* Nobody owns the display: the console gets the notch-free geometry. */ + assert(dcp_notch_effective(DCP_NOTCH_SHOWN, false) == DCP_NOTCH_HIDDEN); + assert(dcp_notch_effective(DCP_NOTCH_HIDDEN, false) == DCP_NOTCH_HIDDEN); + assert(dcp_notch_effective(DCP_NOTCH_SHOWN, true) == DCP_NOTCH_SHOWN); + assert(dcp_notch_effective(DCP_NOTCH_HIDDEN, true) == DCP_NOTCH_HIDDEN); + /* Offered: the effective geometry only, so a compositor follows the policy... */ + pref = true; assert(dcp_notch_offer(false, DCP_NOTCH_SHOWN, true, &pref) && pref); + pref = true; assert(!dcp_notch_offer(true, DCP_NOTCH_SHOWN, true, &pref) && !pref); + pref = true; assert(!dcp_notch_offer(false, DCP_NOTCH_HIDDEN, true, &pref) && !pref); + pref = true; assert(dcp_notch_offer(true, DCP_NOTCH_HIDDEN, true, &pref) && pref); + pref = false; assert(dcp_notch_offer(true, DCP_NOTCH_HIDDEN, true, &pref) && !pref); + /* ...and the notch-free one to the console re-probing within its surface. */ + pref = true; assert(dcp_notch_offer(true, DCP_NOTCH_SHOWN, false, &pref) && pref); + pref = true; assert(!dcp_notch_offer(false, DCP_NOTCH_SHOWN, false, &pref)); + pref = true; assert(dcp_notch_offer(true, DCP_NOTCH_HIDDEN, false, &pref) && pref); + assert(dcp_notch_full_fits(0, 1864) && dcp_notch_full_fits(1864, 1864)); + assert(!dcp_notch_full_fits(1800, 1864) && dcp_notch_full_fits(1800, 0)); + /* + * The reported physical height is the notch-free one exactly when the + * probe offers only the notch-free geometry, so the console's bounded + * re-probe keeps the size of its first probe whatever the policy. + */ + for (int e = DCP_NOTCH_HIDDEN; e <= DCP_NOTCH_SHOWN; e++) + for (int ff = 0; ff <= 1; ff++) { + bool pf = true, pu = true; + bool f_off = dcp_notch_offer(true, e, ff, &pf); + bool u_off = dcp_notch_offer(false, e, ff, &pu); + + assert(dcp_notch_free_only(e, ff) == (f_off && !u_off)); + } + assert(dcp_notch_free_only(DCP_NOTCH_SHOWN, false)); + assert(!dcp_notch_free_only(DCP_NOTCH_SHOWN, true)); + /* No notch rows: no twins. */ + { + unsigned k = 1; + u32 rows = 7; + + assert(!dcp_notch_add_twins(&hidden, &k, 0, &rows) && k == 1 && rows == 0); + } + free(hidden); + free(m); + return 0; +} +''' + + def refresh(root): h=(root/'drivers/gpu/drm/apple/dcp-refresh.h').read_text().replace('#include ','') return r''' diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py b/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py index 021f328f0ea61..d2ca8a50eb36a 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py @@ -984,7 +984,8 @@ def function(text, signature): struct { struct mutex lock; struct { u64 generation; bool connected; } epoch; } metadata; u64 typec_generation; bool typec_cable_connected; struct { size_t length; void *data; u64 av_service_epoch, automatic_connection_sequence; bool automatic_service_pending; struct test_mode_ticket mode_ticket; } chunks; - int width_mm,height_mm; struct { int width_mm,height_mm; } panel; + int width_mm,height_mm; struct { int width_mm,height_mm; unsigned adj_height_mm; } panel; + bool notch_free_offered; unsigned notch_rows,notch_panel_rows; unsigned int nr_modes; struct { struct { int width_mm,height_mm; } mode; } modes[1]; struct apple_connector *connector; struct apple_dcp_afkep *dcpavservep,*dptxep,*avep,*systemep,*ibootep,*dptx_controller_ep; @@ -1037,11 +1038,15 @@ def function(text, signature): rx_unused(apple_rtkit_ioreport_rx) rx_unused(apple_rtkit_oslog_rx) ''' - parts=[function(dcp,'void dcp_set_dimensions('), function(template,'static u8 dcpep_cb_prop_start(')] + parts=[] if 'void dcp_update_connector_dimensions(' in dcp: + notch = (root / 'drivers/gpu/drm/apple/dcp-notch.h').read_text() + if 'dcp_notch_free_mm(' in notch: + parts.append(function(notch,'static inline int dcp_notch_free_mm(')) parts.append(function(dcp,'void dcp_update_connector_dimensions(')) else: parts.append('static void dcp_update_connector_dimensions(struct apple_dcp *d, struct drm_connector *c) { (void)d; (void)c; }') + parts += [function(dcp,'void dcp_set_dimensions('), function(template,'static u8 dcpep_cb_prop_start(')] parts += [function(iomfb,'void iomfb_recv_msg('),function(af,'int afk_receive_message('), function(dcp,'static struct apple_dcp_afkep *dcp_afkep('), function(dcp,'static void dcp_recv_msg(')] @@ -1115,8 +1120,8 @@ def function(text, signature): if owned: prefix=prefix.replace('struct apple_connector { struct drm_connector base; struct work_struct hotplug_wq; };', 'struct apple_connector { struct drm_connector base; struct work_struct hotplug_wq,bl_sync_wq; };',1) - prefix=prefix.replace(' int width_mm,height_mm; struct { int width_mm,height_mm; } panel;', - ' int width_mm,height_mm; struct { int width_mm,height_mm; } panel;\n' + prefix=prefix.replace(' int width_mm,height_mm; struct { int width_mm,height_mm; unsigned adj_height_mm; } panel;\n bool notch_free_offered; unsigned notch_rows,notch_panel_rows;', + ' int width_mm,height_mm; struct { int width_mm,height_mm; unsigned adj_height_mm; } panel;\n bool notch_free_offered; unsigned notch_rows,notch_panel_rows;\n' ' struct mutex modes_lock; u64 modes_generation,dimensions_generation; struct work_struct dimensions_wq; bool ext_backlight;',1) prefix=prefix.replace('struct { size_t length; void *data;','struct { size_t length; void *data; u64 modes_generation;',1) prefix=prefix.replace('static void schedule_work(struct work_struct *w) { queue_work(&dimensions_queue,w); }',''' diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py index 3941f8bd0aebb..59d4fa0e5dc2a 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py @@ -1928,6 +1928,8 @@ def vrr(root): static bool dcp_vrr_live(struct apple_dcp *d) { return d->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP && d->main_display; } static bool iomfb_is_m4(struct apple_dcp *d) { (void)d; return false; } +static bool __attribute__((unused)) dcp_notch_mode_known(struct apple_dcp *d, + const struct drm_display_mode *m) { (void)d; (void)m; assert(false); return false; } static bool dcp_has_panel(struct apple_dcp *d) { return d->panel; } /* The firmware 27 paired-timing check (dcp-peer-runtime-v27.inc) runs on firmware 27 only. */ static unsigned int peer_checks; @@ -1938,7 +1940,7 @@ def vrr(root): 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; } -static bool drm_mode_equal(const struct drm_display_mode *a,const struct drm_display_mode *b) +static bool __attribute__((unused)) drm_mode_equal(const struct drm_display_mode *a,const struct drm_display_mode *b) { (void)a; (void)b; assert(false); return false; } /* These commits change no colour management, so no gamma table is sized. */ static int __attribute__((unused)) drm_color_lut_size(const void *blob) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py index 9d161cf7ac5b7..76d2e0848a606 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py @@ -280,6 +280,46 @@ def protocol(root): ''' +def notch(root): + # A notch-free frame (dcp-notch.h) on the J713 panel profile: 64 rows + # shorter, scanned out 64 rows down; the full frame stays at row 0. + return production(root) + r''' +int main(void) +{ + static unsigned char swap[0x1bd8]; + struct dcp_m4_frame f; + u64 dva = 0x10000100000ULL, size = 0x2000000; + + assert(!dcp_m4_direct_frame_at(&f, dva, size, 2560, 1600, 10240, false, 64)); + assert(f.dst_y == 64 && f.height == 1600); + assert(!dcp_m4_swap_encode_full(swap, sizeof(swap), 7, true, &f, NULL, 0, false, 0, + dcp_m4_frame_check)); + /* Source w,h then destination x,y,w,h of surface 0. */ + assert(get_unaligned_le32(swap + 0xb4) == 2560 && get_unaligned_le32(swap + 0xb8) == 1600); + assert(get_unaligned_le32(swap + 0x10c) == 0 && get_unaligned_le32(swap + 0x110) == 64); + assert(get_unaligned_le32(swap + 0x114) == 2560 && get_unaligned_le32(swap + 0x118) == 1600); + + assert(!dcp_m4_direct_frame(&f, dva, size, 2560, 1664, 10240, false) && f.dst_y == 0); + assert(!dcp_m4_swap_encode_full(swap, sizeof(swap), 8, true, &f, NULL, 0, false, 0, + dcp_m4_frame_check)); + assert(get_unaligned_le32(swap + 0x110) == 0 && get_unaligned_le32(swap + 0x118) == 1664); + + /* Frame and offset must cover the panel exactly, within the notch bound. */ + assert(dcp_m4_direct_frame(&f, dva, size, 2560, 1600, 10240, false) == -EINVAL); + assert(dcp_m4_direct_frame_at(&f, dva, size, 2560, 1600, 10240, false, 63) == -EINVAL); + assert(dcp_m4_direct_frame_at(&f, dva, size, 2560, 1664, 10240, false, 64) == -EINVAL); + assert(dcp_m4_direct_frame_at(&f, dva, size, 2560, 1500, 10240, false, 164) == -EINVAL); + /* An external frame has no notch. */ + f = (struct dcp_m4_frame){ .dva = dva, .backing_size = size, .width = 1920, .height = 1080, + .stride = 7680, .format = DCP_M4_XRGB8888 }; + assert(!dcp_m4_frame_check_ext(&f)); + f.dst_y = 1; + assert(dcp_m4_frame_check_ext(&f) == -EINVAL); + return 0; +} +''' + + def plane(root): source = (root / APPLE / 'plane.c').read_text() present = header_body((root / APPLE / 'iomfb_m4_present.h').read_text()) @@ -770,7 +810,8 @@ def blank(root): return 0; } ''' + functions + '\n' + '\n'.join(block(backend, name) for name in ( - 'static int iomfb_m4_swap(', 'int iomfb_m4_present(', 'int iomfb_m4_blank(')) + r''' + 'static int iomfb_m4_swap(', 'int iomfb_m4_present_at(', 'int iomfb_m4_present(', + 'int iomfb_m4_blank(')) + r''' int main(void) { for(order=0;order<2;order++) { diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py index 30eba776e8eee..743e30acc88c3 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py @@ -243,6 +243,8 @@ def timing(i, w, h, hz, pref, score, unsafe=False): #define GFP_KERNEL 0 #define kmalloc(n, f) malloc(n) #define kcalloc(n, s, f) calloc(n,s) +#define krealloc_array(p, n, s, f) realloc(p, (n) * (s)) +#define __GFP_NOWARN 0 #define kfree(p) free(p) #define mul_u32_u32(a, b) ((u64)(u32)(a) * (u32)(b)) #define DIV_ROUND_CLOSEST_ULL(n, d) (((n) + (d) / 2) / (d)) @@ -292,7 +294,9 @@ def timing(i, w, h, hz, pref, score, unsafe=False): int hdisplay, hsync_start, hsync_end, htotal, width_mm, height_mm; }; static void drm_mode_set_name(struct drm_display_mode *mode) { (void)mode; } -''' +#define DCP_NOTCH_HOST +''' + (base / 'dcp-notch.h').read_text().replace('static inline ', 'static inline __attribute__((unused)) ') + stubs = r''' struct drm_edid { struct edid raw; u8 cta[128]; size_t size; }; static const struct drm_edid *drm_edid_alloc(const void *data, size_t size) @@ -681,7 +685,7 @@ def case(value, automatic=True, internal=False, external=True, admitted=True): struct drm_edid { u8 data[256]; }; struct apple_connector { void *dcp; bool connected, drm_edid_firmware_derived, edid_invalidation_pending; - u64 drm_edid_generation, drm_edid_service_epoch; + u64 drm_edid_generation, drm_edid_service_epoch; u32 probe_max_y; const struct drm_edid *drm_edid; struct { int registration_state; } base; struct work_struct hotplug_wq, bl_sync_wq; @@ -701,6 +705,8 @@ def case(value, automatic=True, internal=False, external=True, admitted=True): void *dev, *phy, *active_typec_route; bool dptx_tunnel, usb4, typec_cable_connected, quiescing, hpd_mutex; u64 typec_generation; unsigned int nr_modes; + /* No notched panel here: the notch-free twins are the panel tests'. */ + unsigned int nr_notch_twins; u32 notch_rows, notch_panel_rows; u8 notch_policy; bool notch_owned, notch_free_offered; struct dcp_display_mode *modes; struct { bool holding, stopped; } announce; bool ext_backlight, has_panel, iomfb_template_pq; @@ -859,7 +865,7 @@ def publication(root): state = n['state'] state = state.replace('struct apple_connector {', '''struct drm_device { void *dev; struct { bool mutex; } mode_config; }; struct drm_connector { struct drm_device *dev; int registration_state; void *state; - struct { struct { unsigned min_vfreq,max_vfreq; } monitor_range; } display_info; + struct { struct { unsigned min_vfreq,max_vfreq; } monitor_range; int width_mm,height_mm; } display_info; }; struct apple_connector {''') state = state.replace(' struct { int registration_state; } base;', ' struct drm_connector base;') @@ -875,7 +881,7 @@ def publication(root): int fw_compat,width_mm,height_mm,fixed_connector_type; unsigned notch_height; bool modes_lock,modes_admitted,modes_provisional,placeholder_retried,external_native; int external_held; u64 modes_generation,dimensions_generation; struct work_struct dimensions_wq; - struct { int width_mm,height_mm; } panel; + struct { int width_mm,height_mm; unsigned adj_height_mm; } panel; struct { size_t length,received; void *data; bool contiguous,payload_complete; u64 modes_generation; u64 av_service_epoch,automatic_connection_sequence; bool automatic_service_pending; struct dcp_metadata_ticket metadata_ticket,mode_ticket; @@ -895,6 +901,7 @@ def publication(root): firmware_edid += ('static bool dcp_metadata_timing_fits(const struct drm_display_mode *m) ' '{ return m->clock > 0 && m->clock <= 655350 && !(m->clock % 10); }\n') stubs = r''' +#define dcp_notch_dynamic(d) ((void)(d), true) /* The rate/HPD fixture is an external H17P sink; it never selects M4. */ #define iomfb_is_v26_6(dcp) false #define iomfb_v26_6_get_mode(dcp,mode) (-ENODEV) @@ -1315,10 +1322,8 @@ def panel_dimensions(root): unit = unit.replace('bool modes_lock,modes_admitted,', 'bool external_physically_absent,modes_lock,modes_admitted,', 1) # The connector's physical size, which DRM keeps in display_info. - old = 'struct { struct { unsigned min_vfreq,max_vfreq; } monitor_range; } display_info;' + old = 'struct { struct { unsigned min_vfreq,max_vfreq; } monitor_range; int width_mm,height_mm; } display_info;' assert unit.count(old) == 1 - unit = unit.replace(old, 'struct { struct { unsigned min_vfreq,max_vfreq; } monitor_range; ' - 'int width_mm,height_mm; } display_info;') dcp = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() unit = unit.replace(block(unit, 'static bool __attribute__((unused)) dcp_has_panel('), block(dcp, 'bool dcp_has_panel(')) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index 2d111c5bed964..a5d887fb62a72 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -72,6 +72,8 @@ def main(): ('display', 'camera-indicator-dpms', display.indicator_dpms, ((),), ()), ('display', 'panel-brightness-takeover', display.takeover, ((),), ()), ('display', 'panel-mode-catalog', display.modes, ((),), ()), + ('display', 'panel-notch-geometry', display.notch, ((),), ()), + ('display', 'panel-notch-console', display.notch_console, ((),), ()), ('display', 'desktop-brightness-notifications', desktop.brightness_notifications, ((),), ()), ('display', 'j616s-panel-identity', lambda r: j616s.identity(r, output), ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), ('display', 'desktop-adt-identity', desktop.adt_identity, ((),), ()), @@ -85,6 +87,7 @@ def main(): ('m4', 'm4-wire-golden', lambda r: m4.golden_check(r, output), (), ()), ('m4', 'm4-protocol', m4.protocol, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), ('m4', 'm4-common-plane', m4.plane, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), + ('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-power-gate', m4.gate, ((),), ('-Wno-unused-function',)),