From patchwork Fri Mar 14 21:37:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jesse Barnes X-Patchwork-Id: 3837331 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E825ABF540 for ; Sat, 15 Mar 2014 13:37:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D933620374 for ; Sat, 15 Mar 2014 13:37:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7B3F42026C for ; Sat, 15 Mar 2014 13:37:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C65928907C; Sat, 15 Mar 2014 06:37:22 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by gabe.freedesktop.org (Postfix) with SMTP id 59E7E89078 for ; Sat, 15 Mar 2014 06:37:19 -0700 (PDT) Received: (qmail 4552 invoked by uid 0); 14 Mar 2014 21:37:19 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy3.mail.unifiedlayer.com with SMTP; 14 Mar 2014 21:37:19 -0000 Received: from box514.bluehost.com ([74.220.219.114]) by cmgw3 with id dgdD1n00c2UhLwi01gdGsE; Fri, 14 Mar 2014 22:37:18 -0600 X-Authority-Analysis: v=2.1 cv=RodWckWK c=1 sm=1 tr=0 a=9W6Fsu4pMcyimqnCr1W0/w==:117 a=9W6Fsu4pMcyimqnCr1W0/w==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=HyZ6GqqJHTgA:10 a=3ROhxo7VqVMA:10 a=IkcTkHD0fZMA:10 a=TBVoxVdAAAAA:8 a=GhZ5P8ky69gA:10 a=pGLkceISAAAA:8 a=RnevF5AdJrTHst2odzEA:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 a=rW6DTWptwo0A:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuousgeek.org; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=7xfYPRyHvtTLHsqWUk8r5/3/Juuj2n+JDQlmMVy8p48=; b=tswn698/eXkUXy9pL8De6ITh/a6tT6m5iA0kYcrPS7/MMbLo+FGuFWntGGMuL++m1lyX3OJVmrxDJbi8j8IKbPyzdC7oGW4dOCiPeUTXYCRdaQqFwVHIps48zVfI8wqq; Received: from [67.161.37.189] (port=34980 helo=localhost.localdomain) by box514.bluehost.com with esmtpsa (UNKNOWN:CAMELLIA256-SHA:256) (Exim 4.80) (envelope-from ) id 1WOZn1-0007tS-4s; Fri, 14 Mar 2014 15:37:15 -0600 From: Jesse Barnes To: intel-gfx@lists.freedesktop.org Date: Fri, 14 Mar 2014 14:37:10 -0700 Message-Id: <1394833031-4055-3-git-send-email-jbarnes@virtuousgeek.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394833031-4055-1-git-send-email-jbarnes@virtuousgeek.org> References: <1394833031-4055-1-git-send-email-jbarnes@virtuousgeek.org> MIME-Version: 1.0 X-Identified-User: {10642:box514.bluehost.com:virtuous:virtuousgeek.org} {sentby:smtp auth 67.161.37.189 authed with jbarnes@virtuousgeek.org} Cc: dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 3/4] drm/i915: use current mode if the size matches the preferred 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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: Kristian Høgsberg The BIOS may set a native mode that doesn't quite match the preferred mode timings. It should be ok to use however if it uses the same size, so try to avoid a mode set in that case. Signed-off-by: Kristian Høgsberg Signed-off-by: Jesse Barnes --- drivers/gpu/drm/drm_modes.c | 8 ++++++++ drivers/gpu/drm/i915/intel_fbdev.c | 37 ++++++++++++++++++------------------ include/drm/drm_crtc.h | 2 ++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index b073315..7d2dda4 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -894,6 +894,14 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, } EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); +bool drm_mode_same_size(const struct drm_display_mode *mode1, + const struct drm_display_mode *mode2) +{ + return mode1->vdisplay == mode2->vdisplay && + mode1->hdisplay == mode2->hdisplay; +} +EXPORT_SYMBOL(drm_mode_same_size); + /** * drm_mode_validate_size - make sure modes adhere to size constraints * @dev: DRM device diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index d6d78c8..f81e3db 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c @@ -369,31 +369,30 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, /* go for command line mode first */ modes[i] = drm_pick_cmdline_mode(fb_conn, width, height); - /* try for preferred next */ + /* try for preferred next or match current */ if (!modes[i]) { + struct drm_display_mode *preferred; + DRM_DEBUG_KMS("looking for preferred mode on connector %d\n", fb_conn->connector->base.id); - modes[i] = drm_has_preferred_mode(fb_conn, width, - height); - } - - /* last resort: use current mode */ - if (!modes[i]) { - /* - * IMPORTANT: We want to use the adjusted mode (i.e. - * after the panel fitter upscaling) as the initial - * config, not the input mode, which is what crtc->mode - * usually contains. But since our current fastboot - * code puts a mode derived from the post-pfit timings - * into crtc->mode this works out correctly. We don't - * use hwmode anywhere right now, so use it for this - * since the fb helper layer wants a pointer to - * something we own. - */ + preferred = drm_has_preferred_mode(fb_conn, width, + height); intel_mode_from_pipe_config(&encoder->crtc->hwmode, &to_intel_crtc(encoder->crtc)->config); - modes[i] = &encoder->crtc->hwmode; + modes[i] = &encoder->crtc->hwmode; + + if (preferred && + !drm_mode_same_size(preferred, modes[i])) { + DRM_DEBUG_KMS("using preferred mode %s " + "instead of current mode %s " + "on connector %d\n", + preferred->name, + modes[i]->name, + fb_conn->connector->base.id); + modes[i] = preferred; + } } + crtcs[i] = new_crtc; DRM_DEBUG_KMS("connector %s on crtc %d: %s\n", diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f764654..d5ebe3b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1020,6 +1020,8 @@ extern bool drm_mode_equal(const struct drm_display_mode *mode1, const struct dr extern bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2); extern int drm_mode_width(const struct drm_display_mode *mode); extern int drm_mode_height(const struct drm_display_mode *mode); +extern bool drm_mode_same_size(const struct drm_display_mode *mode1, + const struct drm_display_mode *mode2); /* for us by fb module */ extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);