diff mbox

[RFC,3/7] drm: abstract override and firmware edid

Message ID 4fc38a4b6e4362f98aa6982c2bf42b880c6771b5.1482854862.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula Dec. 27, 2016, 4:21 p.m. UTC
The functional change is that if firmware edid is present, it'll still
bypass get_modes even if number of modes is 0. This is in line with
override edid handling.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_probe_helper.c | 44 ++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index fe65af8f48b9..431349673846 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -163,6 +163,32 @@  drm_connector_detect(struct drm_connector *connector, bool force)
 		connector_status_connected;
 }
 
+static bool bypass_edid(struct drm_connector *connector, int *count)
+{
+	struct edid *edid;
+
+	if (connector->override_edid) {
+		edid = (struct edid *) connector->edid_blob_ptr->data;
+
+		*count = drm_add_edid_modes(connector, edid);
+		drm_edid_to_eld(connector, edid);
+
+		return true;
+	}
+
+	edid = drm_load_edid_firmware(connector);
+	if (!IS_ERR_OR_NULL(edid)) {
+		drm_mode_connector_update_edid_property(connector, edid);
+		*count = drm_add_edid_modes(connector, edid);
+		drm_edid_to_eld(connector, edid);
+		kfree(edid);
+
+		return true;
+	}
+
+	return false;
+}
+
 /**
  * drm_helper_probe_single_connector_modes - get complete set of display modes
  * @connector: connector to probe
@@ -292,22 +318,8 @@  int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 		goto prune;
 	}
 
-	if (connector->override_edid) {
-		struct edid *edid = (struct edid *) connector->edid_blob_ptr->data;
-
-		count = drm_add_edid_modes(connector, edid);
-		drm_edid_to_eld(connector, edid);
-	} else {
-		struct edid *edid = drm_load_edid_firmware(connector);
-		if (!IS_ERR_OR_NULL(edid)) {
-			drm_mode_connector_update_edid_property(connector, edid);
-			count = drm_add_edid_modes(connector, edid);
-			drm_edid_to_eld(connector, edid);
-			kfree(edid);
-		}
-		if (count == 0)
-			count = (*connector_funcs->get_modes)(connector);
-	}
+	if (!bypass_edid(connector, &count))
+		count = (*connector_funcs->get_modes)(connector);
 
 	if (count == 0 && connector->status == connector_status_connected)
 		count = drm_add_modes_noedid(connector, 1024, 768);