From patchwork Fri Aug 3 16:02:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 1274611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 21D0BDF27F for ; Sun, 5 Aug 2012 10:20:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 133A59EF2B for ; Sun, 5 Aug 2012 03:20:16 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C1559EFFD for ; Fri, 3 Aug 2012 09:02:35 -0700 (PDT) Received: from 64-126-113-183.dyn.everestkc.net ([64.126.113.183] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SxKKg-0006zy-FR; Fri, 03 Aug 2012 16:02:34 +0000 From: Seth Forshee To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 4/5] drm/i915: make intel_lvds_get_edid() more robust Date: Fri, 3 Aug 2012 11:02:20 -0500 Message-Id: <1344009741-14248-5-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1344009741-14248-1-git-send-email-seth.forshee@canonical.com> References: <1344009741-14248-1-git-send-email-seth.forshee@canonical.com> X-Mailman-Approved-At: Sun, 05 Aug 2012 03:16:42 -0700 Cc: Daniel Vetter , Andreas Heider , linux-kernel@vger.kernel.org, Matthew Garrett 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 intel_lvds_get_edid() needs to be called when switching GPUs, but it's currently making assumptions that it will only be called once and that there's always an LVDS connector present when it's called. Fix these assumptions. Signed-off-by: Seth Forshee --- drivers/gpu/drm/i915/intel_lvds.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index c1ab632..9d05a90 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c @@ -906,9 +906,18 @@ static bool intel_lvds_get_edid(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; struct drm_connector *connector = dev_priv->int_lvds_connector; - struct intel_lvds *intel_lvds = intel_attached_lvds(connector); + struct intel_lvds *intel_lvds; struct drm_display_mode *scan; /* *modes, *bios_mode; */ + if (!connector) + return false; + + intel_lvds = intel_attached_lvds(connector); + + /* If we already have an EDID, no need to check again */ + if (intel_lvds->edid) + return true; + /* * Attempt to get the fixed panel mode from DDC. Assume that the * preferred mode is the right one. @@ -939,6 +948,12 @@ static bool intel_lvds_get_edid(struct drm_device *dev) list_for_each_entry(scan, &connector->probed_modes, head) { if (scan->type & DRM_MODE_TYPE_PREFERRED) { + /* + * If we already have a preferred mode from another + * source, prefer the one from the EDID. + */ + if (intel_lvds->fixed_mode) + drm_mode_destroy(dev, intel_lvds->fixed_mode); intel_lvds->fixed_mode = drm_mode_duplicate(dev, scan); intel_find_lvds_downclock(dev,