Skip to contentSkip to conversation

udldrmfb: Fix EDID not working with monitors with EDID extension blocks

PATCH New Hans de Goede 1 participant 3 messages Jan 11, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 udldrmfb: Fix EDID not working with monitors with EDID extension blocks

udldrmfb only reads the main EDID block, and if that advertises extensions the drm_edid code expects them to be present, and starts reading beyond the buffer udldrmfb passes it.

Although it may be possible to read more EDID info with the udl we simpy don't know how, and even if trial and error gets it working on one device, that is no guarantee it will work on other revisions. So this patch does a simple fix in the form of patching the EDID info to report 0 extension blocks, this fixes udldrmfb only doing 1024x768 on monitors with EDID extension blocks.

---
 drivers/gpu/drm/udl/udl_connector.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/udl/udl_connector.c +8 -0
index b3b2ced..86538c9 100644
@@ -57,6 +57,14 @@ static int udl_get_modes(struct drm_connector *connector)
 
 	edid = (struct edid *)udl_get_edid(udl);
 
+	/*
+	 * We only read the main block, but if the monitor reports extension
+	 * blocks then the drm edid code expects them to be present, so patch
+	 * the extension count to 0.
+	 */
+	edid->checksum += edid->extensions;
+	edid->extensions = 0;
+
 	drm_mode_connector_update_edid_property(connector, edid);
 	ret = drm_add_edid_modes(connector, edid);
 	kfree(edid);
Signature · 1 line
1.8.0.2
#1 lore raw

PATCH 2/3 udldrmfb: udl_get_edid: usb_control_msg buffer must not be on the stack

The buffer passed to usb_control_msg may end up in scatter-gather list, and may thus not be on the stack. Having it on the stack usually works on x86, but not on other archs.

---
 drivers/gpu/drm/udl/udl_connector.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_connector.c +7 -1
index 86538c9..a8c76f4 100644
@@ -22,13 +22,17 @@
 static u8 *udl_get_edid(struct udl_device *udl)
 {
 	u8 *block;
-	char rbuf[3];
+	char *rbuf;
 	int ret, i;
 
 	block = kmalloc(EDID_LENGTH, GFP_KERNEL);
 	if (block == NULL)
 		return NULL;
 
+	rbuf = kmalloc(2, GFP_KERNEL);
+	if (rbuf == NULL)
+		goto error;
+
 	for (i = 0; i < EDID_LENGTH; i++) {
 		ret = usb_control_msg(udl->ddev->usbdev,
 				      usb_rcvctrlpipe(udl->ddev->usbdev, 0), (0x02),
@@ -42,10 +46,12 @@ static u8 *udl_get_edid(struct udl_device *udl)
 		block[i] = rbuf[1];
 	}
 
+	kfree(rbuf);
 	return block;
 
 error:
 	kfree(block);
+	kfree(rbuf);
 	return NULL;
 }
 
Signature · 1 line
1.8.0.2
#2 lore raw

PATCH 3/3 udldrmfb: udl_get_edid: drop unneeded i--

In reply to Hans de Goede

This is a left-over from when udl_get_edid returned the amount of bytes successfully read, which it no longer does.

---
 drivers/gpu/drm/udl/udl_connector.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/udl/udl_connector.c +0 -1
index a8c76f4..6d7acf4 100644
@@ -40,7 +40,6 @@ static u8 *udl_get_edid(struct udl_device *udl)
 				      HZ);
 		if (ret < 1) {
 			DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
-			i--;
 			goto error;
 		}
 		block[i] = rbuf[1];
Signature · 1 line
1.8.0.2