Skip to contentSkip to conversation

drm/i915: remove pch_edp encoder state variable

PATCH Superseded Imre Deak 3 participants 19 messages May 7, 2013 – May 10, 2013

Subsystems (2)
lore
Share & tools
lore

Imre Deak

author
#0 lore raw

cover drm/i915: remove pch_edp encoder state variable

Since whether a specific eDP port is on CPU or on PCH is fixed and depends only on which digital port it is, we don't really need state tracking for it. So remove it and instead check for the port and if needed the machine type (for ValleyView).

The assumption in the code before and after the change:

Before ILK there is no eDP. Starting from ILK we can have eDP ports on port A and D:

Port A and for ValleyView port C is always a CPU side eDP port, if the port exists.

Port D is a PCH side eDP port if there is a PCH and VBT says it's an eDP port.

Tested only on IVB.

Imre Deak (6):
drm/i915: use enc_to_intel_dp() instead of opencoding the same drm/i915: hsw: replace !is_pch_edp() with port==PORT_A drm/i915: ilk-ivb: replace is_pch_edp() with port==PORT_D drm/i915: stop using is_pch_edp() in intel_dp_init_connector() drm/i915: stop using is_pch_edp() in is_cpu_edp() drm/i915: remove is_pch_edp() helpers and state variable

 drivers/gpu/drm/i915/intel_display.c |    4 +-
 drivers/gpu/drm/i915/intel_dp.c      |   79 +++++++++++++---------------------
 drivers/gpu/drm/i915/intel_drv.h     |   14 +++---
 3 files changed, 36 insertions(+), 61 deletions(-)
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 1/6 drm/i915: use enc_to_intel_dp() instead of opencoding the same

---
 drivers/gpu/drm/i915/intel_drv.h |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +5 -7
index 6e01393..c24ee02 100644
@@ -621,19 +621,17 @@ static inline struct intel_encoder *intel_attached_encoder(struct drm_connector
 	return to_intel_connector(connector)->encoder;
 }
 
-static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
-{
-	struct intel_digital_port *intel_dig_port =
-		container_of(encoder, struct intel_digital_port, base.base);
-	return &intel_dig_port->dp;
-}
-
 static inline struct intel_digital_port *
 enc_to_dig_port(struct drm_encoder *encoder)
 {
 	return container_of(encoder, struct intel_digital_port, base.base);
 }
 
+static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
+{
+	return &enc_to_dig_port(encoder)->dp;
+}
+
 static inline struct intel_digital_port *
 dp_to_dig_port(struct intel_dp *intel_dp)
 {
Signature · 1 line
1.7.10.4
author
#2 lore raw

PATCH 2/6 drm/i915: hsw: replace !is_pch_edp() with port==PORT_A

In reply to Imre Deak

On HSW the CPU side eDP is always on port-A, the PCH side eDP is always on port-D.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 0ed764d..5b689b2 100644
@@ -5976,7 +5976,7 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
 		switch (encoder->type) {
 		case INTEL_OUTPUT_EDP:
-			if (!intel_encoder_is_pch_edp(&encoder->base))
+			if (enc_to_dig_port(&encoder->base)->port == PORT_A)
 				is_cpu_edp = true;
 			break;
 		}
Signature · 1 line
1.7.10.4
author
#3 lore raw

PATCH 3/6 drm/i915: ilk-ivb: replace is_pch_edp() with port==PORT_D

In reply to Imre Deak

On ILK-IVB the PCH side eDP is always on port-D.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 5b689b2..bdf07b7 100644
@@ -5067,7 +5067,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
 			break;
 		case INTEL_OUTPUT_EDP:
 			has_panel = true;
-			if (intel_encoder_is_pch_edp(&encoder->base))
+			if (enc_to_dig_port(&encoder->base)->port == PORT_D)
 				has_pch_edp = true;
 			else
 				has_cpu_edp = true;
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH 3/6] drm/i915: ilk-ivb: replace is_pch_edp() with port==PORT_D

Quoted 12 lines · Imre Deak

On ILK-IVB the PCH side eDP is always on port-D.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 5b689b2..bdf07b7 100644

drivers/gpu/drm/i915/intel_display.c static void ironlake_init_pch_refclk(struct drm_device *dev) · line 5073

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -5067,7 +5067,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
                        break;
                case INTEL_OUTPUT_EDP:
                        has_panel = true;
-                       if (intel_encoder_is_pch_edp(&encoder->base))
+                       if (enc_to_dig_port(&encoder->base)->port == PORT_D)
                                has_pch_edp = true;
                        else
                                has_cpu_edp = true;

The only place we use that is for a debug output. Imo it's better to kill this here and move any relevant debug output to intel_dp_init (if there's anything missing).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

author
#5 lore raw

PATCH 4/6 drm/i915: stop using is_pch_edp() in intel_dp_init_connector()

In reply to Imre Deak

is_pch_edp() will be removed in a follow-up patch, so replace it with a check for the port and VBT info (for port-D eDP).

Also make things a bit clearer by using a switch on the ports.

---
 drivers/gpu/drm/i915/intel_dp.c |   32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +21 -11
index d5a3717..31c6129 100644
@@ -3010,24 +3010,34 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 		if (intel_dpd_is_edp(dev))
 			intel_dp->is_pch_edp = true;
 
+	type = DRM_MODE_CONNECTOR_DisplayPort;
 	/*
 	 * FIXME : We need to initialize built-in panels before external panels.
 	 * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup
 	 */
-	if (IS_VALLEYVIEW(dev) && port == PORT_C) {
-		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else if (port == PORT_A || is_pch_edp(intel_dp)) {
+	switch (port) {
+	case PORT_A:
 		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else {
-		/* The intel_encoder->type value may be INTEL_OUTPUT_UNKNOWN for
-		 * DDI or INTEL_OUTPUT_DISPLAYPORT for the older gens, so don't
-		 * rewrite it.
-		 */
-		type = DRM_MODE_CONNECTOR_DisplayPort;
+		break;
+	case PORT_C:
+		if (IS_VALLEYVIEW(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;
+	case PORT_D:
+		if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;
+	default:	/* silence GCC warning */
+		break;
 	}
 
+	/* The intel_encoder->type value may be INTEL_OUTPUT_UNKNOWN for
+	 * DDI or INTEL_OUTPUT_DISPLAYPORT for the older gens, so don't
+	 * rewrite it.
+	 */
+	if (type == DRM_MODE_CONNECTOR_eDP)
+		intel_encoder->type = INTEL_OUTPUT_EDP;
+
 	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
 	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
 
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [PATCH 4/6] drm/i915: stop using is_pch_edp() in intel_dp_init_connector()

Quoted 46 lines · Imre Deak

is_pch_edp() will be removed in a follow-up patch, so replace it with a check for the port and VBT info (for port-D eDP).

Also make things a bit clearer by using a switch on the ports.

---
 drivers/gpu/drm/i915/intel_dp.c |   32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +12 -11
index d5a3717..31c6129 100644
@@ -3010,24 +3010,34 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 		if (intel_dpd_is_edp(dev))
 			intel_dp->is_pch_edp = true;
 
+	type = DRM_MODE_CONNECTOR_DisplayPort;
 	/*
 	 * FIXME : We need to initialize built-in panels before external panels.
 	 * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup
 	 */
-	if (IS_VALLEYVIEW(dev) && port == PORT_C) {
-		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else if (port == PORT_A || is_pch_edp(intel_dp)) {
+	switch (port) {
+	case PORT_A:
 		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else {
-		/* The intel_encoder->type value may be INTEL_OUTPUT_UNKNOWN for
-		 * DDI or INTEL_OUTPUT_DISPLAYPORT for the older gens, so don't
-		 * rewrite it.
-		 */
-		type = DRM_MODE_CONNECTOR_DisplayPort;
+		break;
+	case PORT_C:
+		if (IS_VALLEYVIEW(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;
+	case PORT_D:
+		if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;

drivers/gpu/drm/i915/intel_dp.c intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · line 3039

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +8 -0
+	default:	/* silence GCC warning */
+		break;
 	}
 
+	/* The intel_encoder->type value may be INTEL_OUTPUT_UNKNOWN for
+	 * DDI or INTEL_OUTPUT_DISPLAYPORT for the older gens, so don't
+	 * rewrite it.
+	 */
+	if (type == DRM_MODE_CONNECTOR_eDP)
+		intel_encoder->type = INTEL_OUTPUT_EDP;

The comment is a bit confusing since now it's in the code path that can rewrite it. Perhaps add some mention of eDP to the comment as well, so that people understand that it's still valid for other kinds of connectors.

Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+
 	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
 	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
 
Signature · 6 lines
1.7.10.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
author
#7 lore raw

PATCH 5/6 drm/i915: stop using is_pch_edp() in is_cpu_edp()

In reply to Imre Deak

is_pch_edp() will be removed by the next patch, so replace it by a check for the port and device type.

---
 drivers/gpu/drm/i915/intel_dp.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +11 -6
index 31c6129..df1a446 100644
@@ -65,6 +65,13 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
 	return intel_dp->is_pch_edp;
 }
 
+static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
+{
+	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+	return intel_dig_port->base.base.dev;
+}
+
 /**
  * is_cpu_edp - is the port on the CPU and attached to an eDP panel?
  * @intel_dp: DP struct
@@ -73,14 +80,12 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
  */
 static bool is_cpu_edp(struct intel_dp *intel_dp)
 {
-	return is_edp(intel_dp) && !is_pch_edp(intel_dp);
-}
-
-static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
-{
+	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+	enum port port = intel_dig_port->port;
 
-	return intel_dig_port->base.base.dev;
+	return is_edp(intel_dp) &&
+		(port == PORT_A || (port == PORT_C && IS_VALLEYVIEW(dev)));
 }
 
 static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
Signature · 1 line
1.7.10.4
author
#8 lore raw

PATCH 6/6 drm/i915: remove is_pch_edp() helpers and state variable

In reply to Imre Deak

There are no more users for these, so remove them.

---
 drivers/gpu/drm/i915/intel_dp.c  |   36 ------------------------------------
 drivers/gpu/drm/i915/intel_drv.h |    2 --
 2 files changed, 38 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -36
index df1a446..a8c329b 100644
@@ -52,19 +52,6 @@ static bool is_edp(struct intel_dp *intel_dp)
 	return intel_dig_port->base.type == INTEL_OUTPUT_EDP;
 }
 
-/**
- * is_pch_edp - is the port on the PCH and attached to an eDP panel?
- * @intel_dp: DP struct
- *
- * Returns true if the given DP struct corresponds to a PCH DP port attached
- * to an eDP panel, false otherwise.  Helpful for determining whether we
- * may need FDI resources for a given DP output or not.
- */
-static bool is_pch_edp(struct intel_dp *intel_dp)
-{
-	return intel_dp->is_pch_edp;
-}
-
 static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
 {
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
@@ -93,25 +80,6 @@ static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
 	return enc_to_intel_dp(&intel_attached_encoder(connector)->base);
 }
 
-/**
- * intel_encoder_is_pch_edp - is the given encoder a PCH attached eDP?
- * @encoder: DRM encoder
- *
- * Return true if @encoder corresponds to a PCH attached eDP panel.  Needed
- * by intel_display.c.
- */
-bool intel_encoder_is_pch_edp(struct drm_encoder *encoder)
-{
-	struct intel_dp *intel_dp;
-
-	if (!encoder)
-		return false;
-
-	intel_dp = enc_to_intel_dp(encoder);
-
-	return is_pch_edp(intel_dp);
-}
-
 static void intel_dp_link_down(struct intel_dp *intel_dp);
 
 static int
@@ -3011,10 +2979,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 	intel_dp->DP = I915_READ(intel_dp->output_reg);
 	intel_dp->attached_connector = intel_connector;
 
-	if (HAS_PCH_SPLIT(dev) && port == PORT_D)
-		if (intel_dpd_is_edp(dev))
-			intel_dp->is_pch_edp = true;
-
 	type = DRM_MODE_CONNECTOR_DisplayPort;
 	/*
 	 * FIXME : We need to initialize built-in panels before external panels.
drivers/gpu/drm/i915/intel_drv.h +0 -2
index c24ee02..388a394 100644
@@ -451,7 +451,6 @@ struct intel_dp {
 	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
 	struct i2c_adapter adapter;
 	struct i2c_algo_dp_aux_data algo;
-	bool is_pch_edp;
 	uint8_t train_set[4];
 	int panel_power_up_delay;
 	int panel_power_down_delay;
@@ -566,7 +565,6 @@ extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
-extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
 extern int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
 extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
 				      enum plane plane);
Signature · 1 line
1.7.10.4
author
#9 lore raw

v2 cover drm/i915: remove pch_edp encoder state variable

In reply to Imre Deak

Since whether a specific eDP port is on CPU or on PCH is fixed and depends only on which digital port it is, we don't really need state tracking for it. So remove it and instead check for the port and if needed the machine type (for ValleyView).

The assumption in the code before and after the change:

Before ILK there is no eDP. Starting from ILK we can have eDP ports on port A and D:

Port A and for ValleyView port C is always a CPU side eDP port, if the port exists.

Port D is a PCH side eDP port if there is a PCH and VBT says it's an eDP port.

Tested only on IVB.

v2:
- reduce debug verbosity (Daniel)
- make comment about not setting the encoder type clearer (Ville)

Imre Deak (7):
drm/i915: use enc_to_intel_dp() instead of opencoding the same drm/i915: hsw: replace !is_pch_edp() with port==PORT_A drm/i915: ilk-ivb: replace !is_pch_edp() with port==PORT_A drm/i915: stop using is_pch_edp() in intel_dp_init_connector() drm/i915: stop using is_pch_edp() in is_cpu_edp() drm/i915: remove is_pch_edp() helpers and state variable drm/i915: print DP init debug messages from a single place

 drivers/gpu/drm/i915/intel_display.c |   24 +++-------
 drivers/gpu/drm/i915/intel_dp.c      |   84 ++++++++++++++--------------------
 drivers/gpu/drm/i915/intel_drv.h     |   14 ++----
 3 files changed, 46 insertions(+), 76 deletions(-)
Signature · 1 line
1.7.10.4
author
#10 lore raw

PATCH v2 1/7 drm/i915: use enc_to_intel_dp() instead of opencoding the same

---
 drivers/gpu/drm/i915/intel_drv.h |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +5 -7
index 6e01393..c24ee02 100644
@@ -621,19 +621,17 @@ static inline struct intel_encoder *intel_attached_encoder(struct drm_connector
 	return to_intel_connector(connector)->encoder;
 }
 
-static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
-{
-	struct intel_digital_port *intel_dig_port =
-		container_of(encoder, struct intel_digital_port, base.base);
-	return &intel_dig_port->dp;
-}
-
 static inline struct intel_digital_port *
 enc_to_dig_port(struct drm_encoder *encoder)
 {
 	return container_of(encoder, struct intel_digital_port, base.base);
 }
 
+static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
+{
+	return &enc_to_dig_port(encoder)->dp;
+}
+
 static inline struct intel_digital_port *
 dp_to_dig_port(struct intel_dp *intel_dp)
 {
Signature · 1 line
1.7.10.4
author
#11 lore raw

PATCH v2 2/7 drm/i915: hsw: replace !is_pch_edp() with port==PORT_A

In reply to Imre Deak

On HSW the CPU side eDP is always on port-A, the PCH side eDP is always on port-D.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 0ed764d..5b689b2 100644
@@ -5976,7 +5976,7 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
 		switch (encoder->type) {
 		case INTEL_OUTPUT_EDP:
-			if (!intel_encoder_is_pch_edp(&encoder->base))
+			if (enc_to_dig_port(&encoder->base)->port == PORT_A)
 				is_cpu_edp = true;
 			break;
 		}
Signature · 1 line
1.7.10.4
author
#12 lore raw

PATCH v2 3/7 drm/i915: ilk-ivb: replace !is_pch_edp() with port==PORT_A

In reply to Imre Deak

On ILK-IVB the CPU side eDP is always on port-A.

Also reduce somewhat the debug verbosity.

v2:
- reduce debug verbosity

---
 drivers/gpu/drm/i915/intel_display.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -7
index 5b689b2..bcadc19 100644
@@ -5052,7 +5052,6 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
 	u32 val, final;
 	bool has_lvds = false;
 	bool has_cpu_edp = false;
-	bool has_pch_edp = false;
 	bool has_panel = false;
 	bool has_ck505 = false;
 	bool can_ssc = false;
@@ -5067,9 +5066,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
 			break;
 		case INTEL_OUTPUT_EDP:
 			has_panel = true;
-			if (intel_encoder_is_pch_edp(&encoder->base))
-				has_pch_edp = true;
-			else
+			if (enc_to_dig_port(&encoder->base)->port == PORT_A)
 				has_cpu_edp = true;
 			break;
 		}
@@ -5083,9 +5080,8 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
 		can_ssc = true;
 	}
 
-	DRM_DEBUG_KMS("has_panel %d has_lvds %d has_pch_edp %d has_cpu_edp %d has_ck505 %d\n",
-		      has_panel, has_lvds, has_pch_edp, has_cpu_edp,
-		      has_ck505);
+	DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d\n",
+		      has_panel, has_lvds, has_ck505);
 
 	/* Ironlake: try to setup display ref clock before DPLL
 	 * enabling. This is only under driver's control after
Signature · 1 line
1.7.10.4
author
#13 lore raw

PATCH v2 4/7 drm/i915: stop using is_pch_edp() in intel_dp_init_connector()

In reply to Imre Deak

is_pch_edp() will be removed in a follow-up patch, so replace it with a check for the port and VBT info (for port-D eDP).

Also make things a bit clearer by using a switch on the ports.

v2:
- make the comment about not setting the conder type for DP clearer (Ville)

---
 drivers/gpu/drm/i915/intel_dp.c |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +22 -11
index d5a3717..42c11dd 100644
@@ -3010,24 +3010,35 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 		if (intel_dpd_is_edp(dev))
 			intel_dp->is_pch_edp = true;
 
+	type = DRM_MODE_CONNECTOR_DisplayPort;
 	/*
 	 * FIXME : We need to initialize built-in panels before external panels.
 	 * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup
 	 */
-	if (IS_VALLEYVIEW(dev) && port == PORT_C) {
-		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else if (port == PORT_A || is_pch_edp(intel_dp)) {
+	switch (port) {
+	case PORT_A:
 		type = DRM_MODE_CONNECTOR_eDP;
-		intel_encoder->type = INTEL_OUTPUT_EDP;
-	} else {
-		/* The intel_encoder->type value may be INTEL_OUTPUT_UNKNOWN for
-		 * DDI or INTEL_OUTPUT_DISPLAYPORT for the older gens, so don't
-		 * rewrite it.
-		 */
-		type = DRM_MODE_CONNECTOR_DisplayPort;
+		break;
+	case PORT_C:
+		if (IS_VALLEYVIEW(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;
+	case PORT_D:
+		if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev))
+			type = DRM_MODE_CONNECTOR_eDP;
+		break;
+	default:	/* silence GCC warning */
+		break;
 	}
 
+	/*
+	 * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but
+	 * for DP the encoder type can be set by the caller to
+	 * INTEL_OUTPUT_UNKNOWN for DDI, so don't rewrite it.
+	 */
+	if (type == DRM_MODE_CONNECTOR_eDP)
+		intel_encoder->type = INTEL_OUTPUT_EDP;
+
 	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
 	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
 
Signature · 1 line
1.7.10.4
author
#14 lore raw

PATCH v2 5/7 drm/i915: stop using is_pch_edp() in is_cpu_edp()

In reply to Imre Deak

is_pch_edp() will be removed by the next patch, so replace it by a check for the port and device type.

---
 drivers/gpu/drm/i915/intel_dp.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +11 -6
index 42c11dd..38b9cd2 100644
@@ -65,6 +65,13 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
 	return intel_dp->is_pch_edp;
 }
 
+static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
+{
+	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+	return intel_dig_port->base.base.dev;
+}
+
 /**
  * is_cpu_edp - is the port on the CPU and attached to an eDP panel?
  * @intel_dp: DP struct
@@ -73,14 +80,12 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
  */
 static bool is_cpu_edp(struct intel_dp *intel_dp)
 {
-	return is_edp(intel_dp) && !is_pch_edp(intel_dp);
-}
-
-static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
-{
+	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+	enum port port = intel_dig_port->port;
 
-	return intel_dig_port->base.base.dev;
+	return is_edp(intel_dp) &&
+		(port == PORT_A || (port == PORT_C && IS_VALLEYVIEW(dev)));
 }
 
 static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
Signature · 1 line
1.7.10.4
#15 lore raw

Re: [PATCH v2 5/7] drm/i915: stop using is_pch_edp() in is_cpu_edp()

Quoted 32 lines · Imre Deak

is_pch_edp() will be removed by the next patch, so replace it by a check for the port and device type.

---
 drivers/gpu/drm/i915/intel_dp.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +7 -2
index 42c11dd..38b9cd2 100644
@@ -65,6 +65,13 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
 	return intel_dp->is_pch_edp;
 }
 
+static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
+{
+	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+	return intel_dig_port->base.base.dev;
+}
+
 /**
  * is_cpu_edp - is the port on the CPU and attached to an eDP panel?
  * @intel_dp: DP struct
@@ -73,14 +80,12 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
  */
 static bool is_cpu_edp(struct intel_dp *intel_dp)
 {
-	return is_edp(intel_dp) && !is_pch_edp(intel_dp);
-}

drivers/gpu/drm/i915/intel_dp.c static bool is_pch_edp(struct intel_dp *intel_dp) · line 88

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +4 -4
-
-static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
-{
+	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+	enum port port = intel_dig_port->port;
 
-	return intel_dig_port->base.base.dev;
+	return is_edp(intel_dp) &&
+		(port == PORT_A || (port == PORT_C && IS_VALLEYVIEW(dev)));

Valleyview is a giant mess here, I guess we should split the vlv case from the pch_split cpu edp case. Maybe just check for port A in relevant cases and factor out vlv cases completely.

My bet is that this massive confusion is the reason that vlv dp (i.e. non-edp) is totally broken atm.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#16 lore raw

Re: [PATCH v2 5/7] drm/i915: stop using is_pch_edp() in is_cpu_edp()

Quoted 48 lines · Daniel Vetter
Quoted 32 lines · Imre Deak

is_pch_edp() will be removed by the next patch, so replace it by a check for the port and device type.

---
 drivers/gpu/drm/i915/intel_dp.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +7 -2
index 42c11dd..38b9cd2 100644
@@ -65,6 +65,13 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
 	return intel_dp->is_pch_edp;
 }
 
+static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
+{
+	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+	return intel_dig_port->base.base.dev;
+}
+
 /**
  * is_cpu_edp - is the port on the CPU and attached to an eDP panel?
  * @intel_dp: DP struct
@@ -73,14 +80,12 @@ static bool is_pch_edp(struct intel_dp *intel_dp)
  */
 static bool is_cpu_edp(struct intel_dp *intel_dp)
 {
-	return is_edp(intel_dp) && !is_pch_edp(intel_dp);
-}

drivers/gpu/drm/i915/intel_dp.c static bool is_pch_edp(struct intel_dp *intel_dp) · line 88

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +4 -4
-
-static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
-{
+	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+	enum port port = intel_dig_port->port;
 
-	return intel_dig_port->base.base.dev;
+	return is_edp(intel_dp) &&
+		(port == PORT_A || (port == PORT_C && IS_VALLEYVIEW(dev)));

Valleyview is a giant mess here, I guess we should split the vlv case from the pch_split cpu edp case. Maybe just check for port A in relevant cases and factor out vlv cases completely.

Quoted 2 lines

My bet is that this massive confusion is the reason that vlv dp (i.e. non-edp) is totally broken atm.

Could we do that as a follow-up to this? That work would have also the benefit of removing is_cpu_edp() as you hoped earlier, so it could stand on its own..

--Imre

author
#17 lore raw

PATCH v2 6/7 drm/i915: remove is_pch_edp() helpers and state variable

In reply to Imre Deak

There are no more users for these, so remove them.

---
 drivers/gpu/drm/i915/intel_dp.c  |   36 ------------------------------------
 drivers/gpu/drm/i915/intel_drv.h |    2 --
 2 files changed, 38 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -36
index 38b9cd2..42ceff5 100644
@@ -52,19 +52,6 @@ static bool is_edp(struct intel_dp *intel_dp)
 	return intel_dig_port->base.type == INTEL_OUTPUT_EDP;
 }
 
-/**
- * is_pch_edp - is the port on the PCH and attached to an eDP panel?
- * @intel_dp: DP struct
- *
- * Returns true if the given DP struct corresponds to a PCH DP port attached
- * to an eDP panel, false otherwise.  Helpful for determining whether we
- * may need FDI resources for a given DP output or not.
- */
-static bool is_pch_edp(struct intel_dp *intel_dp)
-{
-	return intel_dp->is_pch_edp;
-}
-
 static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
 {
 	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
@@ -93,25 +80,6 @@ static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
 	return enc_to_intel_dp(&intel_attached_encoder(connector)->base);
 }
 
-/**
- * intel_encoder_is_pch_edp - is the given encoder a PCH attached eDP?
- * @encoder: DRM encoder
- *
- * Return true if @encoder corresponds to a PCH attached eDP panel.  Needed
- * by intel_display.c.
- */
-bool intel_encoder_is_pch_edp(struct drm_encoder *encoder)
-{
-	struct intel_dp *intel_dp;
-
-	if (!encoder)
-		return false;
-
-	intel_dp = enc_to_intel_dp(encoder);
-
-	return is_pch_edp(intel_dp);
-}
-
 static void intel_dp_link_down(struct intel_dp *intel_dp);
 
 static int
@@ -3011,10 +2979,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 	intel_dp->DP = I915_READ(intel_dp->output_reg);
 	intel_dp->attached_connector = intel_connector;
 
-	if (HAS_PCH_SPLIT(dev) && port == PORT_D)
-		if (intel_dpd_is_edp(dev))
-			intel_dp->is_pch_edp = true;
-
 	type = DRM_MODE_CONNECTOR_DisplayPort;
 	/*
 	 * FIXME : We need to initialize built-in panels before external panels.
drivers/gpu/drm/i915/intel_drv.h +0 -2
index c24ee02..388a394 100644
@@ -451,7 +451,6 @@ struct intel_dp {
 	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
 	struct i2c_adapter adapter;
 	struct i2c_algo_dp_aux_data algo;
-	bool is_pch_edp;
 	uint8_t train_set[4];
 	int panel_power_up_delay;
 	int panel_power_down_delay;
@@ -566,7 +565,6 @@ extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
 extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
-extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
 extern int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
 extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
 				      enum plane plane);
Signature · 1 line
1.7.10.4
author
#18 lore raw

PATCH v2 7/7 drm/i915: print DP init debug messages from a single place

In reply to Imre Deak
---
 drivers/gpu/drm/i915/intel_display.c |   12 +++---------
 drivers/gpu/drm/i915/intel_dp.c      |    4 ++++
 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -9
index bcadc19..9472ebc 100644
@@ -8828,10 +8828,8 @@ static void intel_setup_outputs(struct drm_device *dev)
 				intel_hdmi_init(dev, GEN4_HDMIB, PORT_B);
 			}
 
-			if (!found && SUPPORTS_INTEGRATED_DP(dev)) {
-				DRM_DEBUG_KMS("probing DP_B\n");
+			if (!found && SUPPORTS_INTEGRATED_DP(dev))
 				intel_dp_init(dev, DP_B, PORT_B);
-			}
 		}
 
 		/* Before G4X SDVOC doesn't have its own detect register */
@@ -8847,17 +8845,13 @@ static void intel_setup_outputs(struct drm_device *dev)
 				DRM_DEBUG_KMS("probing HDMI on SDVOC\n");
 				intel_hdmi_init(dev, GEN4_HDMIC, PORT_C);
 			}
-			if (SUPPORTS_INTEGRATED_DP(dev)) {
-				DRM_DEBUG_KMS("probing DP_C\n");
+			if (SUPPORTS_INTEGRATED_DP(dev))
 				intel_dp_init(dev, DP_C, PORT_C);
-			}
 		}
 
 		if (SUPPORTS_INTEGRATED_DP(dev) &&
-		    (I915_READ(DP_D) & DP_DETECTED)) {
-			DRM_DEBUG_KMS("probing DP_D\n");
+		    (I915_READ(DP_D) & DP_DETECTED))
 			intel_dp_init(dev, DP_D, PORT_D);
-		}
 	} else if (IS_GEN2(dev))
 		intel_dvo_init(dev);
 
drivers/gpu/drm/i915/intel_dp.c +4 -0
index 42ceff5..92d1334 100644
@@ -3008,6 +3008,10 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 	if (type == DRM_MODE_CONNECTOR_eDP)
 		intel_encoder->type = INTEL_OUTPUT_EDP;
 
+	DRM_DEBUG_KMS("Adding %s connector on port %c\n",
+			type == DRM_MODE_CONNECTOR_eDP ? "eDP" : "DP",
+			port_name(port));
+
 	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
 	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
 
Signature · 1 line
1.7.10.4