From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Barnes Subject: [PATCH 08/13] drm/i915: Validate that the framebuffer accommodates the current mode Date: Tue, 19 Feb 2013 13:31:43 -0800 Message-ID: <1361309508-4901-9-git-send-email-jbarnes@virtuousgeek.org> References: <1361309508-4901-1-git-send-email-jbarnes@virtuousgeek.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from oproxy14-pub.unifiedlayer.com (oproxy14-pub.unifiedlayer.com [67.222.51.224]) by gabe.freedesktop.org (Postfix) with SMTP id 24845E666A for ; Tue, 19 Feb 2013 13:31:54 -0800 (PST) Received: from [67.161.37.189] (port=56006 helo=localhost.localdomain) by box514.bluehost.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.80) (envelope-from ) id 1U7un3-0004Pz-36 for intel-gfx@lists.freedesktop.org; Tue, 19 Feb 2013 14:31:53 -0700 In-Reply-To: <1361309508-4901-1-git-send-email-jbarnes@virtuousgeek.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@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. 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 8ca47e5..0a2279e 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6450,27 +6450,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; @@ -9127,6 +9140,11 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, 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); -- 1.7.9.5