From patchwork Tue Sep 9 06:28:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 4866301 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 22ADA9F32F for ; Tue, 9 Sep 2014 06:28:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51B2F2016C for ; Tue, 9 Sep 2014 06:28:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 830E320160 for ; Tue, 9 Sep 2014 06:28:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 616946E3A9; Mon, 8 Sep 2014 23:28:31 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id B38FB6E39D; Mon, 8 Sep 2014 23:28:30 -0700 (PDT) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s896SUEe030932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Sep 2014 02:28:30 -0400 Received: from tyrion-bne-redhat-com.bne.redhat.com (dhcp-41-68.bne.redhat.com [10.64.41.68]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s896SIOx023257; Tue, 9 Sep 2014 02:28:29 -0400 From: Dave Airlie To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Tue, 9 Sep 2014 16:28:12 +1000 Message-Id: <1410244096-9854-8-git-send-email-airlied@gmail.com> In-Reply-To: <1410244096-9854-1-git-send-email-airlied@gmail.com> References: <1410244096-9854-1-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Subject: [Intel-gfx] [PATCH 07/11] drm/edid: allow patching the EDID to report monster mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Airlie This patches the EDID to add the special mode. TODO make this more generic. Signed-off-by: Dave Airlie --- 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 #include +#include /** * 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__ */