]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915/panel: sync panel prepared state at register
authorJani Nikula <jani.nikula@intel.com>
Fri, 6 Jun 2025 09:05:12 +0000 (12:05 +0300)
committerJani Nikula <jani.nikula@intel.com>
Wed, 11 Jun 2025 08:48:05 +0000 (11:48 +0300)
If the panel is enabled at probe, and we take over the hardware state,
the drm_panel prepared state will be out of sync. We'll need to notify
drm_panel framework about the state at probe, so it can in turn notify
the panel followers.

Cc: Lee Shawn C <shawn.c.lee@intel.com>
Tested-by: Lee Shawn C <shawn.c.lee@intel.com>
Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/a33e4fe5e9970aed9c4aef8c426c00a189149c32.1749199013.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_panel.c

index b1d549e6cf5307b1fb23a081483826ca122bdf87..f956919dc648eab507cdcca149672c1ce0173481 100644 (file)
@@ -463,6 +463,45 @@ void intel_panel_fini(struct intel_connector *connector)
        }
 }
 
+/*
+ * If the panel was already enabled at probe, and we took over the state, the
+ * panel prepared state is out of sync, and the panel followers won't be
+ * notified. We need to call drm_panel_prepare() on enabled panels.
+ *
+ * It would be natural to handle this e.g. in the connector ->sync_state hook at
+ * intel_modeset_readout_hw_state(), but that's unfortunately too early. We
+ * don't have drm_connector::kdev at that time. For now, figure out the state at
+ * ->late_register, and sync there.
+ */
+static void intel_panel_sync_state(struct intel_connector *connector)
+{
+       struct intel_display *display = to_intel_display(connector);
+       struct drm_connector_state *conn_state;
+       struct intel_crtc *crtc;
+       int ret;
+
+       ret = drm_modeset_lock(&display->drm->mode_config.connection_mutex, NULL);
+       if (ret)
+               return;
+
+       conn_state = connector->base.state;
+
+       crtc = to_intel_crtc(conn_state->crtc);
+       if (crtc) {
+               struct intel_crtc_state *crtc_state;
+
+               crtc_state = to_intel_crtc_state(crtc->base.state);
+
+               if (crtc_state->hw.active) {
+                       drm_dbg_kms(display->drm, "[CONNECTOR:%d:%s] Panel prepare\n",
+                                   connector->base.base.id, connector->base.name);
+                       intel_panel_prepare(crtc_state, conn_state);
+               }
+       }
+
+       drm_modeset_unlock(&display->drm->mode_config.connection_mutex);
+}
+
 const struct drm_panel_funcs dummy_panel_funcs = {
 };
 
@@ -513,6 +552,8 @@ int intel_panel_register(struct intel_connector *connector)
                drm_dbg_kms(display->drm, "[CONNECTOR:%d:%s] Registered panel device '%s', has fwnode: %s\n",
                            connector->base.base.id, connector->base.name,
                            dev_name(dev), str_yes_no(dev_fwnode(dev)));
+
+               intel_panel_sync_state(connector);
        }
 
 out: