drm/i915: cache the EDID for eDP panels
Subsystems (2)
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.
v2: fix potential NULL derefs in intel_dp_get_edid_modes and
intel_dp_get_edid (Jani)
copy full EDID length, including extension blocks (Takashi) free EDID on teardown (Takashi)
v3: malloc a new EDID buffer that's big enough for the memcpy (Chris)
References: https://bugs.freedesktop.org/show_bug.cgi?id=46856
--- drivers/gpu/drm/i915/intel_dp.c | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +40 -6
@@ -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; };/**
@@ -2121,10 +2124,19 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) {struct intel_dp *intel_dp =intel_attached_dp (connector);struct edid *edid; +int size; + +if (is_edp (intel_dp) && intel_dp->edid) { + size = (intel_dp->edid->extensions +1 ) *EDID_LENGTH ; + edid =kmalloc (size,GFP_KERNEL ); +if (!edid) +return NULL ; + +memcpy (edid, intel_dp->edid, size); +return edid; + } -ironlake_edp_panel_vdd_on (intel_dp); edid =drm_get_edid (connector, adapter); -ironlake_edp_panel_vdd_off (intel_dp, false);return edid; }
@@ -2134,9 +2146,17 @@ intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adastruct intel_dp *intel_dp =intel_attached_dp (connector);int ret; -ironlake_edp_panel_vdd_on (intel_dp); +if (is_edp (intel_dp) && intel_dp->edid) { +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; }
@@ -2326,6 +2346,7 @@ static void intel_dp_encoder_destroy(struct drm_encoder *encoder)i2c_del_adapter (&intel_dp->adapter);drm_encoder_cleanup (encoder);if (is_edp (intel_dp)) { +kfree (intel_dp->edid);cancel_delayed_work_sync (&intel_dp->panel_vdd_work);ironlake_panel_vdd_off_sync (intel_dp); }
@@ -2509,11 +2530,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 );
@@ -2581,9 +2605,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
Quoted 22 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.
v2: fix potential NULL derefs in
intel_dp_get_edid_modesand
intel_dp_get_edid(Jani)
copy full EDID length, including extension blocks (Takashi) free EDID on teardown (Takashi)
v3: malloc a new EDID buffer that's big enough for the memcpy (Chris)References: https://bugs.freedesktop.org/show_bug.cgi?id=46856
Signed-off-by Jesse Barnes <[email protected]>---
drivers/gpu/drm/i915/intel_dp.c +6
-0@@ -2121,10 +2124,19 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) {struct intel_dp *intel_dp =intel_attached_dp (connector);struct edid *edid; +int size; + +if (is_edp (intel_dp) && intel_dp->edid) { + size = (intel_dp->edid->extensions +1 ) *EDID_LENGTH ; + edid =kmalloc (size,GFP_KERNEL ); +if (!edid)
drivers/gpu/drm/i915/intel_dp.c intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) · line 2140
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +5
-2+return NULL ; + +memcpy (edid, intel_dp->edid, size); +return edid; + } -ironlake_edp_panel_vdd_on (intel_dp); edid =drm_get_edid (connector, adapter); -ironlake_edp_panel_vdd_off (intel_dp, false);return edid;
This makes me a little uneasy, as the wording here makes it sound like it is possible for us to initiate a DP aux xfer without raising VDD on the eDP panel. Having made the decision to retreive the EDID for a panel only once, we should use that result for all future queries i.e. if it was NULL during init, assume it will be NULL now as well. (I hope nobody brings out an eDP-to-HDMI dongle!)
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 29 lines · On Thu, 14 Jun 2012 19:37:32 +0100 Chris Wilson <[email protected]>…
Quoted 28 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.
v2: fix potential NULL derefs in
intel_dp_get_edid_modesand
intel_dp_get_edid(Jani)
copy full EDID length, including extension blocks (Takashi) free EDID on teardown (Takashi)
v3: malloc a new EDID buffer that's big enough for the memcpy (Chris)References: https://bugs.freedesktop.org/show_bug.cgi?id=46856
Signed-off-by Jesse Barnes <[email protected]>---
drivers/gpu/drm/i915/intel_dp.c +11
-0@@ -2121,10 +2124,19 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) {struct intel_dp *intel_dp =intel_attached_dp (connector);struct edid *edid; +int size; + +if (is_edp (intel_dp) && intel_dp->edid) { + size = (intel_dp->edid->extensions +1 ) *EDID_LENGTH ; + edid =kmalloc (size,GFP_KERNEL ); +if (!edid) +return NULL ; + +memcpy (edid, intel_dp->edid, size); +return edid; + }
Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) · line 2140
Quoted 4 lines
drivers/gpu/drm/i915/intel_dp.c +0
-2-ironlake_edp_panel_vdd_on (intel_dp); edid =drm_get_edid (connector, adapter); -ironlake_edp_panel_vdd_off (intel_dp, false);return edid;This makes me a little uneasy, as the wording here makes it sound like it is possible for us to initiate a DP aux xfer without raising VDD on the eDP panel. Having made the decision to retreive the EDID for a panel only once, we should use that result for all future queries i.e. if it was NULL during init, assume it will be NULL now as well. (I hope nobody brings out an eDP-to-HDMI dongle!)
Oh good call. Now that I'm checking for whether we have a cached edid I should leave the aux toggling in...
Thanks,
Jesse
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center