dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dylan Semler <dylan.semler@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.
Date: Thu, 21 Mar 2013 17:36:14 -0400	[thread overview]
Message-ID: <1363901775-3510-2-git-send-email-dylan.semler@gmail.com> (raw)
In-Reply-To: <1363901775-3510-1-git-send-email-dylan.semler@gmail.com>


Signed-off-by: Dylan Semler <dylan.semler@gmail.com>
---
 drivers/gpu/drm/drm_edid.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP		(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING	(1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE			(1 << 8)
 
 struct detailed_mode_closure {
 	struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
 	{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };
 
+static struct edid_quirk_force_mode {
+	char vendor[4];
+	int product_id;
+	int hdisplay;
+	int vdisplay;
+	int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
 	return closure.modes;
 }
 
+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+		     int vdisplay, int vrefresh)
+{
+	struct drm_display_mode *mode;
+	struct drm_device *dev = connector->dev;
+	int num_modes = 0;
+
+	/* sanity check display parameters */
+	if (hdisplay < 0)
+		return 0;
+	if (vdisplay < 0)
+		return 0;
+	if (vrefresh < 0)
+		return 0;
+
+	mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+	if (mode) {
+		mode->type |= DRM_MODE_TYPE_PREFERRED;
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+	return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+		      u32 quirks)
+{
+	struct edid_quirk_force_mode *quirk_mode;
+	int i, num_modes = 0;
+
+	for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+		quirk_mode = &edid_quirk_force_mode_list[i];
+
+		if (edid_vendor(edid, quirk_mode->vendor) &&
+		    (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+			num_modes = do_force_quirk_modes(connector,
+					quirk_mode->hdisplay,
+					quirk_mode->vdisplay,
+					quirk_mode->vrefresh);
+		}
+	}
+	return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK	0x01
 #define VIDEO_BLOCK     0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 
 	if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
 		edid_fixup_preferred(connector, quirks);
+	if (quirks & EDID_QUIRK_FORCE_MODE)
+		num_modes += add_force_quirk_modes(connector, edid, quirks);
 
 	drm_add_display_info(edid, &connector->display_info);
 
-- 
1.7.11.7

  reply	other threads:[~2013-03-21 21:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 21:36 Enhance EDID quirks to allow forcing a mode Dylan Semler
2013-03-21 21:36 ` Dylan Semler [this message]
2013-03-22 13:54   ` [PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block Alex Deucher
2013-03-21 21:36 ` [PATCH 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+ Dylan Semler
2013-03-21 21:42 ` Enhance EDID quirks to allow forcing a mode Dylan Semler
2013-03-22  8:48   ` Daniel Vetter
2013-03-22 13:46     ` Dylan Semler
2013-03-22 13:48       ` [PATCH v2 0/2] " Dylan Semler
2013-03-22 13:48         ` [PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block Dylan Semler
2013-03-22 13:48         ` [PATCH v2 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+ Dylan Semler
2013-03-23 12:54         ` [PATCH v2 0/2] Enhance EDID quirks to allow forcing a mode Daniel Vetter
2013-03-22 13:50   ` Alex Deucher
2013-03-22 14:02     ` Dylan Semler
2013-03-22 14:41       ` Daniel Vetter
2013-03-22 15:29         ` Dylan Semler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363901775-3510-2-git-send-email-dylan.semler@gmail.com \
    --to=dylan.semler@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox