public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: [PATCH 07/11] drm/edid: allow patching the EDID to report monster mode
Date: Tue,  9 Sep 2014 16:28:12 +1000	[thread overview]
Message-ID: <1410244096-9854-8-git-send-email-airlied@gmail.com> (raw)
In-Reply-To: <1410244096-9854-1-git-send-email-airlied@gmail.com>

From: Dave Airlie <airlied@redhat.com>

This patches the EDID to add the special mode.

TODO make this more generic.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 13 ++++++++++---
 drivers/gpu/drm/drm_edid.c            | 36 +++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h                |  5 ++++-
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 1f15d85..08b7140 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -31,6 +31,7 @@
 #include <drm/drmP.h>
 
 #include <drm/drm_fixed.h>
+#include <drm/drm_edid.h>
 
 /**
  * DOC: dp mst helper
@@ -2225,9 +2226,15 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_
 			goto out;
 		}
 	}
-	if (port->cached_edid)
-		edid = drm_edid_duplicate(port->cached_edid);
-	else
+	if (port->cached_edid) {
+		if (connector->has_tile && connector->tile_is_single_monitor) {
+			edid = drm_patch_edid_detailed_mode(connector->dev,
+							    port->cached_edid,
+							    3840, 2160, 60);
+		} else {
+			edid = drm_edid_duplicate(port->cached_edid);
+		}
+	} else
 		edid = drm_get_edid(connector, &port->aux.ddc);
  out:
 	drm_dp_put_port(port);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 94e8a57..3ccc2c6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3892,3 +3892,39 @@ void drm_get_displayid(struct drm_connector *connector,
 	return;
 }
 EXPORT_SYMBOL(drm_get_displayid);
+
+static void drm_patch_edid_reset_csum(struct edid *edid)
+{
+	unsigned i, sum = 0;
+	unsigned char *p = (unsigned char *)edid;
+
+	for (i = 0; i < EDID_LENGTH - 1; i++)
+		sum += p[i];
+	edid->checksum = (0x100 - (sum & 0xff)) & 0xff;
+}
+
+struct edid *drm_patch_edid_detailed_mode(struct drm_device *dev,
+					      struct edid *orig_edid,
+					      int hdisplay, int vdisplay, int vrefresh)
+{
+	struct edid *edid = drm_edid_duplicate(orig_edid);
+	struct drm_display_mode *mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, true, false, false);
+
+	int hblank = mode->htotal - mode->hdisplay;
+	int vblank = mode->vtotal - mode->vdisplay;
+
+	DRM_DEBUG_KMS("mode->clock is %d, %d\n", mode->clock, cpu_to_le16(mode->clock / 10));
+	edid->detailed_timings[1] = edid->detailed_timings[0];
+	edid->detailed_timings[0].pixel_clock = cpu_to_le16(mode->clock / 10);
+	edid->detailed_timings[0].data.pixel_data.hactive_lo = mode->hdisplay & 0xff;
+	edid->detailed_timings[0].data.pixel_data.hblank_lo = hblank & 0xff;
+	edid->detailed_timings[0].data.pixel_data.hactive_hblank_hi = (mode->hdisplay >> 4 & 0xf0) | ((hblank >> 8) & 0xf);
+	edid->detailed_timings[0].data.pixel_data.vactive_lo = mode->vdisplay & 0xff;
+	edid->detailed_timings[0].data.pixel_data.vblank_lo = vblank & 0xff;
+	edid->detailed_timings[0].data.pixel_data.vactive_vblank_hi = (mode->vdisplay >> 4 & 0xf0) | ((vblank >> 8) & 0xf);
+
+	drm_patch_edid_reset_csum(edid);
+
+	return edid;
+}
+EXPORT_SYMBOL(drm_patch_edid_detailed_mode);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 3e87f5a..17eb503 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -280,5 +280,8 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 int
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 					    const struct drm_display_mode *mode);
-
+struct drm_device;
+struct edid *drm_patch_edid_detailed_mode(struct drm_device *dev,
+					      struct edid *orig_edid,
+					      int hdisplay, int vdisplay, int vrefresh);
 #endif /* __DRM_EDID_H__ */
-- 
1.9.3

  parent reply	other threads:[~2014-09-09  6:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09  6:28 [RFC] attempting to hide 30" monitor in kernel (raw) Dave Airlie
2014-09-09  6:28 ` [PATCH 01/11] drm/mst: rework payload table allocation to conform better Dave Airlie
2014-09-09  6:28 ` [PATCH 02/11] drm/i915: add config option to enable/disable DP MST Dave Airlie
2014-09-09  7:51   ` Jani Nikula
2014-09-09  6:28 ` [PATCH 03/11] drm/mst: start caching edid for logical ports Dave Airlie
2014-09-09  6:28 ` [PATCH 04/11] drm/displayid: add some DisplayID related defines/structs Dave Airlie
2014-09-09  6:28 ` [PATCH 05/11] drm/dp/mst: add concept of base connector id Dave Airlie
2014-09-09  6:28 ` [PATCH 06/11] drm/tile: attempt to set tiled crtcs up Dave Airlie
2014-09-09  6:28 ` Dave Airlie [this message]
2014-09-09  6:28 ` [PATCH 08/11] drm/crtc: attempt to set tiled modes from userspace Dave Airlie
2014-09-09  6:28 ` [PATCH 09/11] drm/crtc: workaround userspace trying to derail crtc stealing Dave Airlie
2014-09-09  6:28 ` [PATCH 10/11] drm/tiled: add page_flip support for multi-crtc monitors Dave Airlie
2014-09-09  6:28 ` [PATCH 11/11] drm/tiled: vague attempt at waving at cursors Dave Airlie
2014-09-09  8:54 ` [RFC] attempting to hide 30" monitor in kernel (raw) Daniel Vetter

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=1410244096-9854-8-git-send-email-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@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