diff mbox

[v2,06/18] DRM/KMS/EDID: Don't expect extension blocks for EDID Versions < 1.3.

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

Commit Message

Egbert Eich Nov. 22, 2012, 10:22 a.m. UTC
EDID extension blogs are only expected for EDIDs version 1.3 or higher.
If an EDID with a lower version is found fix the block count in the
extension flags and return the base block.
This should help to avoid issues with older displays with broken
DDC implementations.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 drivers/gpu/drm/drm_edid.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5a0e331..da2f7fa 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -45,6 +45,8 @@ 
 
 #define EDID_EXTENSION_FLAG_OFFSET  offsetof(struct edid, extensions)
 #define EDID_CHECKSUM_OFFSET	    offsetof(struct edid, checksum)
+#define EDID_VERSION_MAJOR_OFFSET   offsetof(struct edid, version)
+#define EDID_VERSION_MINOR_OFFSET   offsetof(struct edid, revision)
 /*
  * EDID blocks out in the wild have a variety of bugs, try to collect
  * them here (note that userspace may work around broken monitors first,
@@ -346,6 +348,10 @@  drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
 	if (block[EDID_EXTENSION_FLAG_OFFSET] == 0)
 		return block;
 
+	/* don't expect extension blocks in EDID Versions < 1.3: return base block with correct extension flag */
+	if (block[EDID_VERSION_MINOR_OFFSET] < 3)
+		goto done_fix_extension_count;
+
 	new = krealloc(block, (block[EDID_EXTENSION_FLAG_OFFSET] + 1) * EDID_LENGTH, GFP_KERNEL);
 	if (!new) {
 		dev_warn(connector->dev->dev, "%s: cannot allocate memory for %d EDID blocks: truncating.\n",