Commit 9cd300e0 authored by Jani Nikula's avatar Jani Nikula Committed by Daniel Vetter

drm/i915: Move cached EDID to intel_connector

Move the cached EDID from intel_dp and intel_lvds_connector to
intel_connector. Unify cached EDID handling for LVDS and eDP, in
preparation for adding more generic EDID caching later.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent ebda95a9
...@@ -2317,44 +2317,45 @@ g4x_dp_detect(struct intel_dp *intel_dp) ...@@ -2317,44 +2317,45 @@ g4x_dp_detect(struct intel_dp *intel_dp)
static struct edid * static struct edid *
intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_connector *intel_connector = to_intel_connector(connector);
struct edid *edid;
int size;
if (is_edp(intel_dp)) { /* use cached edid if we have one */
if (!intel_dp->edid) if (intel_connector->edid) {
struct edid *edid;
int size;
/* invalid edid */
if (IS_ERR(intel_connector->edid))
return NULL; return NULL;
size = (intel_dp->edid->extensions + 1) * EDID_LENGTH; size = (intel_connector->edid->extensions + 1) * EDID_LENGTH;
edid = kmalloc(size, GFP_KERNEL); edid = kmalloc(size, GFP_KERNEL);
if (!edid) if (!edid)
return NULL; return NULL;
memcpy(edid, intel_dp->edid, size); memcpy(edid, intel_connector->edid, size);
return edid; return edid;
} }
edid = drm_get_edid(connector, adapter); return drm_get_edid(connector, adapter);
return edid;
} }
static int static int
intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adapter) intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adapter)
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_connector *intel_connector = to_intel_connector(connector);
int ret;
if (is_edp(intel_dp)) { /* use cached edid if we have one */
drm_mode_connector_update_edid_property(connector, if (intel_connector->edid) {
intel_dp->edid); /* invalid edid */
ret = drm_add_edid_modes(connector, intel_dp->edid); if (IS_ERR(intel_connector->edid))
drm_edid_to_eld(connector, return 0;
intel_dp->edid);
return intel_dp->edid_mode_count; return intel_connector_update_modes(connector,
intel_connector->edid);
} }
ret = intel_ddc_get_modes(connector, adapter); return intel_ddc_get_modes(connector, adapter);
return ret;
} }
...@@ -2506,6 +2507,9 @@ intel_dp_destroy(struct drm_connector *connector) ...@@ -2506,6 +2507,9 @@ intel_dp_destroy(struct drm_connector *connector)
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct intel_connector *intel_connector = to_intel_connector(connector); struct intel_connector *intel_connector = to_intel_connector(connector);
if (!IS_ERR_OR_NULL(intel_connector->edid))
kfree(intel_connector->edid);
if (is_edp(intel_dp)) { if (is_edp(intel_dp)) {
intel_panel_destroy_backlight(dev); intel_panel_destroy_backlight(dev);
intel_panel_fini(&intel_connector->panel); intel_panel_fini(&intel_connector->panel);
...@@ -2523,7 +2527,6 @@ static void intel_dp_encoder_destroy(struct drm_encoder *encoder) ...@@ -2523,7 +2527,6 @@ static void intel_dp_encoder_destroy(struct drm_encoder *encoder)
i2c_del_adapter(&intel_dp->adapter); i2c_del_adapter(&intel_dp->adapter);
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
if (is_edp(intel_dp)) { if (is_edp(intel_dp)) {
kfree(intel_dp->edid);
cancel_delayed_work_sync(&intel_dp->panel_vdd_work); cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
ironlake_panel_vdd_off_sync(intel_dp); ironlake_panel_vdd_off_sync(intel_dp);
} }
...@@ -2810,13 +2813,17 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) ...@@ -2810,13 +2813,17 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
ironlake_edp_panel_vdd_on(intel_dp); ironlake_edp_panel_vdd_on(intel_dp);
edid = drm_get_edid(connector, &intel_dp->adapter); edid = drm_get_edid(connector, &intel_dp->adapter);
if (edid) { if (edid) {
drm_mode_connector_update_edid_property(connector, if (drm_add_edid_modes(connector, edid)) {
edid); drm_mode_connector_update_edid_property(connector, edid);
intel_dp->edid_mode_count = drm_edid_to_eld(connector, edid);
drm_add_edid_modes(connector, edid); } else {
drm_edid_to_eld(connector, edid); kfree(edid);
intel_dp->edid = edid; edid = ERR_PTR(-EINVAL);
}
} else {
edid = ERR_PTR(-ENOENT);
} }
intel_connector->edid = edid;
/* prefer fixed mode from EDID if available */ /* prefer fixed mode from EDID if available */
list_for_each_entry(scan, &connector->probed_modes, head) { list_for_each_entry(scan, &connector->probed_modes, head) {
......
...@@ -186,6 +186,9 @@ struct intel_connector { ...@@ -186,6 +186,9 @@ struct intel_connector {
/* Panel info for eDP and LVDS */ /* Panel info for eDP and LVDS */
struct intel_panel panel; struct intel_panel panel;
/* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
struct edid *edid;
}; };
struct intel_crtc { struct intel_crtc {
...@@ -367,8 +370,6 @@ struct intel_dp { ...@@ -367,8 +370,6 @@ struct intel_dp {
int backlight_off_delay; int backlight_off_delay;
struct delayed_work panel_vdd_work; struct delayed_work panel_vdd_work;
bool want_panel_vdd; bool want_panel_vdd;
struct edid *edid; /* cached EDID for eDP */
int edid_mode_count;
struct intel_connector *attached_connector; struct intel_connector *attached_connector;
}; };
......
...@@ -44,7 +44,6 @@ struct intel_lvds_connector { ...@@ -44,7 +44,6 @@ struct intel_lvds_connector {
struct intel_connector base; struct intel_connector base;
struct notifier_block lid_notifier; struct notifier_block lid_notifier;
struct edid *edid;
int fitting_mode; int fitting_mode;
}; };
...@@ -460,8 +459,14 @@ static int intel_lvds_get_modes(struct drm_connector *connector) ...@@ -460,8 +459,14 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct drm_display_mode *mode; struct drm_display_mode *mode;
if (lvds_connector->edid) /* use cached edid if we have one */
return drm_add_edid_modes(connector, lvds_connector->edid); if (lvds_connector->base.edid) {
/* invalid edid */
if (IS_ERR(lvds_connector->base.edid))
return 0;
return drm_add_edid_modes(connector, lvds_connector->base.edid);
}
mode = drm_mode_duplicate(dev, lvds_connector->base.panel.fixed_mode); mode = drm_mode_duplicate(dev, lvds_connector->base.panel.fixed_mode);
if (mode == NULL) if (mode == NULL)
...@@ -553,6 +558,9 @@ static void intel_lvds_destroy(struct drm_connector *connector) ...@@ -553,6 +558,9 @@ static void intel_lvds_destroy(struct drm_connector *connector)
if (lvds_connector->lid_notifier.notifier_call) if (lvds_connector->lid_notifier.notifier_call)
acpi_lid_notifier_unregister(&lvds_connector->lid_notifier); acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
kfree(lvds_connector->base.edid);
intel_panel_destroy_backlight(connector->dev); intel_panel_destroy_backlight(connector->dev);
intel_panel_fini(&lvds_connector->base.panel); intel_panel_fini(&lvds_connector->base.panel);
...@@ -922,6 +930,7 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -922,6 +930,7 @@ bool intel_lvds_init(struct drm_device *dev)
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_display_mode *scan; /* *modes, *bios_mode; */
struct drm_display_mode *fixed_mode = NULL; struct drm_display_mode *fixed_mode = NULL;
struct edid *edid;
struct drm_crtc *crtc; struct drm_crtc *crtc;
u32 lvds; u32 lvds;
int pipe; int pipe;
...@@ -1021,18 +1030,21 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1021,18 +1030,21 @@ bool intel_lvds_init(struct drm_device *dev)
* Attempt to get the fixed panel mode from DDC. Assume that the * Attempt to get the fixed panel mode from DDC. Assume that the
* preferred mode is the right one. * preferred mode is the right one.
*/ */
lvds_connector->edid = drm_get_edid(connector, edid = drm_get_edid(connector, intel_gmbus_get_adapter(dev_priv, pin));
intel_gmbus_get_adapter(dev_priv, pin)); if (edid) {
if (lvds_connector->edid) { if (drm_add_edid_modes(connector, edid)) {
if (drm_add_edid_modes(connector, lvds_connector->edid)) {
drm_mode_connector_update_edid_property(connector, drm_mode_connector_update_edid_property(connector,
lvds_connector->edid); edid);
} else { } else {
kfree(lvds_connector->edid); kfree(edid);
lvds_connector->edid = NULL; edid = ERR_PTR(-EINVAL);
} }
} else {
edid = ERR_PTR(-ENOENT);
} }
if (!lvds_connector->edid) { lvds_connector->base.edid = edid;
if (IS_ERR_OR_NULL(edid)) {
/* Didn't get an EDID, so /* Didn't get an EDID, so
* Set wide sync ranges so we get all modes * Set wide sync ranges so we get all modes
* handed to valid_mode for checking * handed to valid_mode for checking
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment