From patchwork Fri Mar 22 13:48:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Semler X-Patchwork-Id: 2320351 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 825FC3FD8C for ; Fri, 22 Mar 2013 13:53:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 679B4E617C for ; Fri, 22 Mar 2013 06:53:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by gabe.freedesktop.org (Postfix) with ESMTP id F1E5DE62D1 for ; Fri, 22 Mar 2013 06:51:23 -0700 (PDT) Received: by mail-vc0-f175.google.com with SMTP id hf12so3129431vcb.6 for ; Fri, 22 Mar 2013 06:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=B/34/603qfhFUw7d3sSRjgw9B4Q/SgeiMfs6bx4QIr4=; b=pTrJXgtP2QFo9CctXR75Gdh67etmuG/V3kScIxu0P+weWTzyDFToufj8kLfZc+LyKW xN4/XdY6CeDuYHqdsQchtonVOuTuXUFHLqZTHCm+hSDZLtXdRU+/7CnmWxH6HylDAayH f5MqF/ZzKkIwSk15bcWmO4wG97IU44odF8sxC7tmFDyTZCY75DzW4wYeiKACzAVNtHqv vSLd3+5HgQDkEGW3jI8sOyHgeCT9VCj3hehSQw8crGprmZUPZURDMfSMNH0OONeHQOw7 OZ0kgqf26t3f3/1kz+3tcjkY71A2x8FpxoCoccMNL1Z+eTkobphxKydcjqSE53FieccG jitQ== X-Received: by 10.52.108.10 with SMTP id hg10mr1945646vdb.34.1363960283264; Fri, 22 Mar 2013 06:51:23 -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 b7sm3062603veq.7.2013.03.22.06.51.22 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Mar 2013 06:51:22 -0700 (PDT) From: Dylan Semler To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block. Date: Fri, 22 Mar 2013 09:48:50 -0400 Message-Id: <1363960131-9554-2-git-send-email-dylan.semler@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1363960131-9554-1-git-send-email-dylan.semler@gmail.com> References: <1363960131-9554-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);