From patchwork Tue Apr 2 17:03:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barnes X-Patchwork-Id: 2379411 Return-Path: X-Original-To: patchwork-intel-gfx@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 044813FDDA for ; Tue, 2 Apr 2013 17:06:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E85BCE5E0D for ; Tue, 2 Apr 2013 10:06:57 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from oproxy13-pub.unifiedlayer.com (oproxy13-pub.unifiedlayer.com [69.89.16.30]) by gabe.freedesktop.org (Postfix) with SMTP id 94F72E5DDD for ; Tue, 2 Apr 2013 10:04:23 -0700 (PDT) Received: (qmail 7107 invoked by uid 0); 2 Apr 2013 17:04:22 -0000 Received: from unknown (HELO box514.bluehost.com) (74.220.219.114) by oproxy13.unifiedlayer.com with SMTP; 2 Apr 2013 17:04:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuousgeek.org; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:To:From; bh=S3CbUu35DKrXFI6N+xG+IcZ+nnJxi4zqs4rkplptp6w=; b=igdNPipUIoYPwS08bIKWI2K89WucrLghSOYlR6+hfuoW1KalWF6+6O+vwKBFU3INuqy6rej2LEqkThz+vVPjk1hwQFrGdSvJgjWLKFWB30bJUEEINwkniIEcqR8oWR5r; Received: from [67.161.37.189] (port=54872 helo=localhost.localdomain) by box514.bluehost.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.80) (envelope-from ) id 1UN4dB-0006iJ-UK for intel-gfx@lists.freedesktop.org; Tue, 02 Apr 2013 11:04:22 -0600 From: Jesse Barnes To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Apr 2013 10:03:50 -0700 Message-Id: <1364922237-3620-7-git-send-email-jbarnes@virtuousgeek.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1364922237-3620-1-git-send-email-jbarnes@virtuousgeek.org> References: <1364922237-3620-1-git-send-email-jbarnes@virtuousgeek.org> X-Identified-User: {10642:box514.bluehost.com:virtuous:virtuousgeek.org} {sentby:smtp auth 67.161.37.189 authed with jbarnes@virtuousgeek.org} Subject: [Intel-gfx] [PATCH 06/13] drm/i915: Validate that the framebuffer accommodates the current mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org From: Chris Wilson As we retrieve the mode from the BIOS it may be constructed using different assumptions for its configuration, such as utilizing the panel fitter in a conflicting manner. As such the associated framebuffer may be insufficient for our setup, and so we need to reject the current mode and install our own. Jesse: This should probably be put into a new state readout function separate from the fb code Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_display.c | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index d1dd1ec..3741fe8 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6580,27 +6580,40 @@ intel_framebuffer_create_for_mode(struct drm_device *dev, return intel_framebuffer_create(dev, &mode_cmd, obj); } +static bool +mode_fits_in_fb(struct drm_display_mode *mode, + struct drm_framebuffer *fb) +{ + struct drm_i915_gem_object *obj; + int min_pitch; + + min_pitch = intel_framebuffer_pitch_for_width(mode->hdisplay, + fb->bits_per_pixel); + if (fb->pitches[0] < min_pitch) + return false; + + obj = to_intel_framebuffer(fb)->obj; + if (obj == NULL) + return false; + + if (obj->base.size < mode->vdisplay * fb->pitches[0]) + return false; + + return true; +} + static struct drm_framebuffer * mode_fits_in_fbdev(struct drm_device *dev, struct drm_display_mode *mode) { struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_i915_gem_object *obj; struct drm_framebuffer *fb; if (dev_priv->fbdev == NULL) return NULL; - obj = dev_priv->fbdev->ifb.obj; - if (obj == NULL) - return NULL; - fb = &dev_priv->fbdev->ifb.base; - if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay, - fb->bits_per_pixel)) - return NULL; - - if (obj->base.size < mode->vdisplay * fb->pitches[0]) + if (!mode_fits_in_fb(mode, fb)) return NULL; return fb; @@ -9277,6 +9290,11 @@ setup_pipes: if (crtc->base.enabled) crtc->mode_valid = intel_crtc_get_mode(&crtc->base, &crtc->base.mode); + + if (crtc->base.fb && + !mode_fits_in_fb(&crtc->base.mode, crtc->base.fb)) + crtc->mode_valid = false; + if (crtc->mode_valid) { DRM_DEBUG_KMS("found active mode: "); drm_mode_debug_printmodeline(&crtc->base.mode);