From patchwork Thu Mar 21 21:36:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Semler X-Patchwork-Id: 2317001 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 1E79940213 for ; Thu, 21 Mar 2013 21:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27600E6250 for ; Thu, 21 Mar 2013 14:38:56 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by gabe.freedesktop.org (Postfix) with ESMTP id CEA9BE5F86 for ; Thu, 21 Mar 2013 14:38:43 -0700 (PDT) Received: by mail-vb0-f52.google.com with SMTP id fa15so2197679vbb.25 for ; Thu, 21 Mar 2013 14:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=uxDoauK/JwwJL8DjiC9MrMmAOcPBDAM2ZzV31yBlf24=; b=JAPwNXNoFCR6+N6VkJylnHU4Iln3dnEmlF8Ort1NcqdRVpKKhn1mehNZDwPPRRzraL p5oFKriNqhVAvvfMmIwZyAF3SRT7mpCBqSuKaZPshN3sewsBqHsOJedLcravbSnm8h8q So50GaTC9dfDEQxyIMEkuhS2B2HYtuoFIEBkeiZ/UTNHST1h3D9bAOhGfctlCmCSgnc1 70plwzIKi7qSLbGigClHvZ7AM2oTthRseDMJ46auTvTX45pySyv/SK3+kG75shFEIMN8 CVVAikfbSAd73ZG1ziR8hEP6C7NgbIMxqFY7cO/hPcPHOUjpqLc9Bx6UIQvvRAKE58iJ nf7g== X-Received: by 10.220.222.72 with SMTP id if8mr15485689vcb.61.1363901923166; Thu, 21 Mar 2013 14:38:43 -0700 (PDT) Received: from localhost.localdomain (c-71-230-10-110.hsd1.pa.comcast.net. [71.230.10.110]) by mx.google.com with ESMTPS id y8sm43242022vei.5.2013.03.21.14.38.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 21 Mar 2013 14:38:42 -0700 (PDT) From: Dylan Semler 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 Message-Id: <1363901775-3510-2-git-send-email-dylan.semler@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1363901775-3510-1-git-send-email-dylan.semler@gmail.com> References: <1363901775-3510-1-git-send-email-dylan.semler@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Signed-off-by: Dylan Semler --- 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);