Skip to contentSkip to conversation

drm/i915: cache the EDID for eDP panels

PATCH In review Jesse Barnes 5 participants 9 messages Jun 5, 2012 – Jun 14, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: cache the EDID for eDP panels

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

---
 drivers/gpu/drm/i915/intel_dp.c |   43 +++++++++++++++++++++++++++++++++------
 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +37 -6
index 9b2effc..e47ae37 100644
@@ -32,6 +32,7 @@
 #include "drm.h"
 #include "drm_crtc.h"
 #include "drm_crtc_helper.h"
+#include "drm_edid.h"
 #include "intel_drv.h"
 #include "i915_drm.h"
 #include "i915_drv.h"
@@ -67,6 +68,8 @@ struct intel_dp {
 	struct drm_display_mode *panel_fixed_mode;  /* for eDP */
 	struct delayed_work panel_vdd_work;
 	bool want_panel_vdd;
+	struct edid *edid; /* cached EDID for eDP */
+	int edid_mode_count;
 };
 
 /**
@@ -2094,9 +2097,16 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	struct edid	*edid;
 
-	ironlake_edp_panel_vdd_on(intel_dp);
+	if (is_edp(intel_dp)) {
+		edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+		if (!edid)
+			return NULL;
+
+		memcpy(edid, intel_dp->edid, EDID_LENGTH);
+		return edid;
+	}
+
 	edid = drm_get_edid(connector, adapter);
-	ironlake_edp_panel_vdd_off(intel_dp, false);
 	return edid;
 }
 
@@ -2106,9 +2116,17 @@ intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *ada
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	int	ret;
 
-	ironlake_edp_panel_vdd_on(intel_dp);
+	if (is_edp(intel_dp)) {
+		drm_mode_connector_update_edid_property(connector,
+							intel_dp->edid);
+		ret = drm_add_edid_modes(connector, intel_dp->edid);
+		drm_edid_to_eld(connector,
+				intel_dp->edid);
+		connector->display_info.raw_edid = NULL;
+		return intel_dp->edid_mode_count;
+	}
+
 	ret = intel_ddc_get_modes(connector, adapter);
-	ironlake_edp_panel_vdd_off(intel_dp, false);
 	return ret;
 }
 
@@ -2479,11 +2497,14 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 			break;
 	}
 
+	intel_dp_i2c_init(intel_dp, intel_connector, name);
+
 	/* Cache some DPCD data in the eDP case */
 	if (is_edp(intel_dp)) {
 		bool ret;
 		struct edp_power_seq	cur, vbt;
 		u32 pp_on, pp_off, pp_div;
+		struct edid *edid;
 
 		pp_on = I915_READ(PCH_PP_ON_DELAYS);
 		pp_off = I915_READ(PCH_PP_OFF_DELAYS);
@@ -2551,9 +2572,19 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 			intel_dp_destroy(&intel_connector->base);
 			return;
 		}
-	}
 
-	intel_dp_i2c_init(intel_dp, intel_connector, name);
+		ironlake_edp_panel_vdd_on(intel_dp);
+		edid = drm_get_edid(connector, &intel_dp->adapter);
+		if (edid) {
+			drm_mode_connector_update_edid_property(connector,
+								edid);
+			intel_dp->edid_mode_count =
+				drm_add_edid_modes(connector, edid);
+			drm_edid_to_eld(connector, edid);
+			intel_dp->edid = edid;
+		}
+		ironlake_edp_panel_vdd_off(intel_dp, false);
+	}
 
 	intel_encoder->hot_plug = intel_dp_hot_plug;
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Jesse Barnes

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

Maybe we could harmonise more of the common panel tasks between LVDS and eDP, and help fight code duplication?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 8 lines · On Tue, 05 Jun 2012 22:02:25 +0100 Chris Wilson <[email protected]>…
Quoted 4 lines · Jesse Barnes

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

Maybe we could harmonise more of the common panel tasks between LVDS and eDP, and help fight code duplication?

Yeah that makes sense. Not sure how much this conflicts with Daniel's hot plug rework either; there's likely some overlap.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#4 lore raw
Quoted 6 lines · On Tue, 05 Jun 2012 22:38:02 +0100 Chris Wilson <[email protected]>…
Quoted 2 lines · Jesse Barnes

Yeah that makes sense. Not sure how much this conflicts with Daniel's hot plug rework either; there's likely some overlap.

We could have made that Daniel's problem.... ;)
http://lists.freedesktop.org/archives/intel-gfx/2011-April/010401.html

Hey look I even reviewed it.

Pick up the pieces, Daniel! :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#5 lore raw
Quoted 7 lines · Jesse Barnes
Quoted 4 lines · On Tue, 05 Jun 2012 22:38:02 +0100 Chris Wilson <[email protected]>…
Quoted 2 lines · Jesse Barnes

Yeah that makes sense. Not sure how much this conflicts with Daniel's hot plug rework either; there's likely some overlap.

Quoted 6 lines
Quoted 2 lines

We could have made that Daniel's problem.... ;)
http://lists.freedesktop.org/archives/intel-gfx/2011-April/010401.html

Hey look I even reviewed it.

Pick up the pieces, Daniel! :)

I agree looks nice. Can I ask for a resend? Afaics all the stuff got acks/r-bs safe for patch 6 (maybe just drop that one). And I agree with Jesse's bikeshed on patch 8, is_panel sounds more like what we want.

Dunno about patch 10, killing that pointless flicker would certainly be nice. I guess we could just merge it and see what happens, then claim innonce when getting caught with our hands in the cookie jar ;-)

Oh, and I don't think there's much overlap with the hpd stuff of mine, that only caches edids at ->detect time and relies on core drm changes to make calls to ->detect happen less often.
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
maintainer
#6 lore raw
In reply to Jesse Barnes

Hi Jesse, please find a couple of comments below.

BR,
Jani.

Quoted 30 lines · Jesse Barnes

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

---
 drivers/gpu/drm/i915/intel_dp.c |   43 +++++++++++++++++++++++++++++++++------
 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +3 -0
index 9b2effc..e47ae37 100644
@@ -32,6 +32,7 @@
 #include "drm.h"
 #include "drm_crtc.h"
 #include "drm_crtc_helper.h"
+#include "drm_edid.h"
 #include "intel_drv.h"
 #include "i915_drm.h"
 #include "i915_drv.h"
@@ -67,6 +68,8 @@ struct intel_dp {
 	struct drm_display_mode *panel_fixed_mode;  /* for eDP */
 	struct delayed_work panel_vdd_work;
 	bool want_panel_vdd;
+	struct edid *edid; /* cached EDID for eDP */
+	int edid_mode_count;
 };
 
 /**

drivers/gpu/drm/i915/intel_dp.c intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) · line 2105

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +6 -1
@@ -2094,9 +2097,16 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	struct edid	*edid;
 
-	ironlake_edp_panel_vdd_on(intel_dp);
+	if (is_edp(intel_dp)) {
+		edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+		if (!edid)
+			return NULL;
+
+		memcpy(edid, intel_dp->edid, EDID_LENGTH);

I suppose it may be justified to use EDID_LENGTH rather than sizeof(*edid) here, but would it be too paranoid to stick this somewhere?

	BUILD_BUG_ON(sizeof(struct edid) != EDID_LENGTH);
Quoted 44 lines
drivers/gpu/drm/i915/intel_dp.c +16 -3
+		return edid;
+	}
+
 	edid = drm_get_edid(connector, adapter);
-	ironlake_edp_panel_vdd_off(intel_dp, false);
 	return edid;
 }
 
@@ -2106,9 +2116,17 @@ intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *ada
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	int	ret;
 
-	ironlake_edp_panel_vdd_on(intel_dp);
+	if (is_edp(intel_dp)) {
+		drm_mode_connector_update_edid_property(connector,
+							intel_dp->edid);
+		ret = drm_add_edid_modes(connector, intel_dp->edid);
+		drm_edid_to_eld(connector,
+				intel_dp->edid);
+		connector->display_info.raw_edid = NULL;
+		return intel_dp->edid_mode_count;
+	}
+
 	ret = intel_ddc_get_modes(connector, adapter);
-	ironlake_edp_panel_vdd_off(intel_dp, false);
 	return ret;
 }
 
@@ -2479,11 +2497,14 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 			break;
 	}
 
+	intel_dp_i2c_init(intel_dp, intel_connector, name);
+
 	/* Cache some DPCD data in the eDP case */
 	if (is_edp(intel_dp)) {
 		bool ret;
 		struct edp_power_seq	cur, vbt;
 		u32 pp_on, pp_off, pp_div;
+		struct edid *edid;
 
 		pp_on = I915_READ(PCH_PP_ON_DELAYS);
 		pp_off = I915_READ(PCH_PP_OFF_DELAYS);

drivers/gpu/drm/i915/intel_dp.c intel_dp_init(struct drm_device *dev, int output_reg) · line 2578

Quoted 9 lines
drivers/gpu/drm/i915/intel_dp.c +3 -2
@@ -2551,9 +2572,19 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 			intel_dp_destroy(&intel_connector->base);
 			return;
 		}
-	}
 
-	intel_dp_i2c_init(intel_dp, intel_connector, name);
+		ironlake_edp_panel_vdd_on(intel_dp);
+		edid = drm_get_edid(connector, &intel_dp->adapter);
+		if (edid) {

This if condition makes me believe it's possible edid == NULL, but if that happens, I think the additions to intel_dp_get_edid() and intel_dp_get_edid_modes() would oops.

Quoted 19 lines
drivers/gpu/drm/i915/intel_dp.c +9 -0
+			drm_mode_connector_update_edid_property(connector,
+								edid);
+			intel_dp->edid_mode_count =
+				drm_add_edid_modes(connector, edid);
+			drm_edid_to_eld(connector, edid);
+			intel_dp->edid = edid;
+		}
+		ironlake_edp_panel_vdd_off(intel_dp, false);
+	}
 
 	intel_encoder->hot_plug = intel_dp_hot_plug;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
In reply to Jesse Barnes

At Tue, 5 Jun 2012 16:54:27 -0400,

Quoted 32 lines · Jesse Barnes

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

---
 drivers/gpu/drm/i915/intel_dp.c |   43 +++++++++++++++++++++++++++++++++------
 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +3 -0
index 9b2effc..e47ae37 100644
@@ -32,6 +32,7 @@
 #include "drm.h"
 #include "drm_crtc.h"
 #include "drm_crtc_helper.h"
+#include "drm_edid.h"
 #include "intel_drv.h"
 #include "i915_drm.h"
 #include "i915_drv.h"
@@ -67,6 +68,8 @@ struct intel_dp {
 	struct drm_display_mode *panel_fixed_mode;  /* for eDP */
 	struct delayed_work panel_vdd_work;
 	bool want_panel_vdd;
+	struct edid *edid; /* cached EDID for eDP */
+	int edid_mode_count;
 };
 
 /**
@@ -2094,9 +2097,16 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
 	struct intel_dp *intel_dp = intel_attached_dp(connector);

drivers/gpu/drm/i915/intel_dp.c intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) · line 2106

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +7 -1
 	struct edid	*edid;
 
-	ironlake_edp_panel_vdd_on(intel_dp);
+	if (is_edp(intel_dp)) {
+		edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+		if (!edid)
+			return NULL;
+
+		memcpy(edid, intel_dp->edid, EDID_LENGTH);
+		return edid;

It might be bigger than EDID_LENGTH when it contains extensions. Better to create a helper function like drm_copy_edid()?

Also, there is no kfree() corresponding to intel_dp->edid, so a small memory leak when unloading the module. (Ditto for intel_lvds.c, BTW)

Takashi

#8 lore raw
Quoted 7 lines · On Wed, 06 Jun 2012 09:36:44 +0200 Takashi Iwai <[email protected]> wrote:

At Tue, 5 Jun 2012 16:54:27 -0400,

Quoted 5 lines · Jesse Barnes

They aren't going anywhere, and probing on DDC can cause the panel to blank briefly, so read them up front and cache them for later queries.

Ok I think I fixed the issues you and Jani reported, thanks for the review.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center