Skip to contentSkip to conversation

Modeset without a detected monitor on DDI platforms

PATCH Superseded Damien Lespiau 2 participants 3 messages Nov 29, 2013

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

Here's a tentative patch that I unfortunately can't test on HSW because my dev machine seems quite unhappy. The patch had limited testing on simulation though.

The general problem is that intel_digital_port encoders personalities (ie intel_encoder->type) are only set by ->detect() at the moment. It'd be nice to be able to set it at modeset time so any path that forces a modeset with a specific connector end up with a correct encoder type.

Signature · 1 line
Damien
#1 lore raw

PATCH 1/1 drm/i915: Set the digital port encoder personality during modeset

The ->detect() vfunc of connectors is usually responsible for setting the encoder type on intel_digital_ports when a hotplug event happens.

However we sometimes want to force a modeset on a specific connector:
- the user can ask the SETCRTC ioctl to use a connector that wasne marked as connected (because we never received a hotplug event for it). This can be also used in tests to do a modeset without the need of a plugged-in monitor.
- the command line video= option can be used to force modesets, eg.:

    video=HDMI-A-1:1024x768e

So, before we try to do anything with the DDI encoder as part of a modeset, we need to ensure that the personality of the encoder matches the selected connector.

---
 drivers/gpu/drm/i915/intel_ddi.c     | 50 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c |  2 ++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 3 files changed, 53 insertions(+)
drivers/gpu/drm/i915/intel_ddi.c +50 -0
index c8382f5..fe04a09 100644
@@ -701,6 +701,56 @@ intel_ddi_calculate_wrpll(int clock /* in Hz */,
 		      clock, *p_out, *n2_out, *r2_out);
 }
 
+/*
+ * The ->detect() vfunc of connectors is usually responsible for setting the
+ * encoder type on intel_digital_ports when a hotplug event happens.
+ *
+ * However we sometimes want to force a modeset on a specific connector:
+ *   - the user can ask the SETCRTC ioctl to use a connector that isn't marked
+ *     as connected (because we never received a hotplug event for it).
+ *     This can be also used in tests to do a modeset without the need of a
+ *     plugged-in monitor.
+ *   - the command line video= option can be used to force modesets, eg.:
+ *     video=HDMI-A-1:1024x768e
+ *
+ * So, before we try to do anything with the DDI encoder as part of a modeset,
+ * we need to ensure that the personality of the encoder matches the selected
+ * connector.
+ */
+void
+intel_ddi_ensure_encoder_type(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct intel_connector *connector;
+
+	if (!HAS_DDI(dev))
+		return;
+
+	list_for_each_entry(connector, &dev->mode_config.connector_list,
+			    base.head) {
+		int connector_type = connector->base.connector_type;
+
+		if (!connector->new_encoder)
+			continue;
+
+		if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+		    connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+			connector->new_encoder->type = INTEL_OUTPUT_HDMI;
+			continue;
+		}
+
+		if (connector_type == DRM_MODE_CONNECTOR_eDP) {
+			connector->new_encoder->type = INTEL_OUTPUT_EDP;
+			continue;
+		}
+
+		if (connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
+			connector->new_encoder->type = INTEL_OUTPUT_DISPLAYPORT;
+			continue;
+		}
+	}
+}
+
 bool intel_ddi_pll_mode_set(struct drm_crtc *crtc)
 {
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
drivers/gpu/drm/i915/intel_display.c +2 -0
index 5dff7ca..dcd7a9c 100644
@@ -9565,6 +9565,8 @@ static int __intel_set_mode(struct drm_crtc *crtc,
 	*saved_hwmode = crtc->hwmode;
 	*saved_mode = crtc->mode;
 
+	intel_ddi_ensure_encoder_type(crtc);
+
 	/* Hack: Because we don't (yet) support global modeset on multiple
 	 * crtcs, we don't keep track of the new mode for more than one crtc.
 	 * Hence simply check whether any bit is set in modeset_pipes in all the
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 2b5bcb6..ebf6ba4 100644
@@ -612,6 +612,7 @@ void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
 void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
 void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
+void intel_ddi_ensure_encoder_type(struct drm_crtc *crtc);
 bool intel_ddi_pll_mode_set(struct drm_crtc *crtc);
 void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/1 drm/i915: don't set modes for 2 connectors on the same encoder

In reply to Damien Lespiau

From: Paulo Zanoni <[email protected]>

In some cases we have more than 1 connector associated to an encoder (e.g., SDVO, Haswell DP/HDMI) and we can only set a mode for one of these connectors. If we only allowed modesets for connected connectors we would never need this patch, but since we do allow modeset for disconnected connectors we may see user space trying to set modes on the two connectors attached to the same encoder, so we need to forbid that.

This problem can be reproduced by running the following intel-gpu-tools test case:
./kms_setmode --run-subtest clone-exclusive-crtc

Thanks to Daniel Vetter for providing a version of this patch on pastebin.

Credits-to: Daniel Vetter <[email protected]>

---
 drivers/gpu/drm/i915/intel_display.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

This is in addition to Damien's patch.

drivers/gpu/drm/i915/intel_display.c +8 -4
index 9d14296..3f6037c 100644
@@ -9912,17 +9912,21 @@ intel_modeset_stage_output_state(struct drm_device *dev,
 	/* Check for any encoders that needs to be disabled. */
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
 			    base.head) {
+		int num_connectors = 0;
 		list_for_each_entry(connector,
 				    &dev->mode_config.connector_list,
 				    base.head) {
 			if (connector->new_encoder == encoder) {
 				WARN_ON(!connector->new_encoder->new_crtc);
-
-				goto next_encoder;
+				num_connectors++;
 			}
 		}
-		encoder->new_crtc = NULL;
-next_encoder:
+
+		if (num_connectors == 0)
+			encoder->new_crtc = NULL;
+		else if (num_connectors > 1)
+			return -EINVAL;
+
 		/* Only now check for crtc changes so we don't miss encoders
 		 * that will be disabled. */
 		if (&encoder->new_crtc->base != encoder->base.crtc) {
Signature · 1 line
1.8.3.1