diff mbox

[v2,10/18] DRM/KMS/EDID: Feed 'firmware' supplied EDID blocks whenever the EDID is read (v2)

Message ID 1353579788-30637-11-git-send-email-eich@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Egbert Eich Nov. 22, 2012, 10:23 a.m. UTC
Firmware supplied EDIDs where fed in in drm_helper_probe_single_connector_modes()
in place of calling the driver supplied get_modes() function.
This has two problems:
1. Drivers don't call drm_get_edid() only from within get_modes().
2. The get_modes() replacement in drm_load_edid_firmware() provided only
   the least common denominator of what driver provided get_modes() callbacks
   do.
This patch now supplies a user provided 'firmware' EDID whenever drm_get_edid()
is called if one is available. The user supplied EDID is thus used the same way
as a display provided one (except for detecting the presence of a device thru
EDID). Also it does so not on the helper level any more, the possibility for
EDID loading now happens on the DRM KMS core level.

v2: Fixed formatting and conflicts due to reordering of commits.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 drivers/gpu/drm/drm_crtc_helper.c |    6 +-----
 drivers/gpu/drm/drm_edid.c        |    7 +++++++
 drivers/gpu/drm/drm_edid_load.c   |   22 +++++++++-------------
 include/drm/drm_edid.h            |    4 +++-
 4 files changed, 20 insertions(+), 19 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 1227adf..bc99595 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -119,11 +119,7 @@  int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 		goto prune;
 	}
 
-#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
-	count = drm_load_edid_firmware(connector);
-	if (count == 0)
-#endif
-		count = (*connector_funcs->get_modes)(connector);
+	count = (*connector_funcs->get_modes)(connector);
 
 	if (count == 0 && connector->status == connector_status_connected)
 		count = drm_add_modes_noedid(connector, 1024, 768);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9b298fc..8239c42 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -414,6 +414,13 @@  drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
 	u8 *block, *new;
 	bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS);
 
+#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
+	/* check if the user has specified a 'firmware' EDID file */
+	block = (u8 *)drm_load_edid_firmware(connector);
+	if (block)
+		return block;
+#endif
+
 	if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
 		return NULL;
 
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 38d3943..748f63b 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -114,7 +114,7 @@  static u8 generic_edid[GENERIC_EDIDS][128] = {
 	},
 };
 
-static u8 *edid_load(struct drm_connector *connector, char *name,
+static struct edid *edid_load(struct drm_connector *connector, char *name,
 			char *connector_name)
 {
 	const struct firmware *fw;
@@ -222,36 +222,32 @@  out:
 	return edid;
 }
 
-int drm_load_edid_firmware(struct drm_connector *connector)
+struct edid *
+drm_load_edid_firmware(struct drm_connector *connector)
 {
 	char *connector_name = drm_get_connector_name(connector);
 	char *edidname = edid_firmware, *last, *colon;
-	int ret;
 	struct edid *edid;
 
 	if (*edidname == '\0')
-		return 0;
+		return NULL;
 
 	colon = strchr(edidname, ':');
 	if (colon != NULL) {
 		if (strncmp(connector_name, edidname, colon - edidname))
-			return 0;
+			return NULL;
 		edidname = colon + 1;
 		if (*edidname == '\0')
-			return 0;
+			return NULL;
 	}
 
 	last = edidname + strlen(edidname) - 1;
 	if (*last == '\n')
 		*last = '\0';
 
-	edid = (struct edid *) edid_load(connector, edidname, connector_name);
+	edid = edid_load(connector, edidname, connector_name);
 	if (IS_ERR_OR_NULL(edid))
-		return 0;
+		return NULL;
 
-	drm_mode_connector_update_edid_property(connector, edid);
-	ret = drm_add_edid_modes(connector, edid);
-	kfree(edid);
-
-	return ret;
+	return edid;
 }
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 0cac551..c0a77bd 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -252,6 +252,8 @@  int drm_av_sync_delay(struct drm_connector *connector,
 		      struct drm_display_mode *mode);
 struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
 				     struct drm_display_mode *mode);
-int drm_load_edid_firmware(struct drm_connector *connector);
+#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
+struct edid *drm_load_edid_firmware(struct drm_connector *connector);
+#endif
 
 #endif /* __DRM_EDID_H__ */