All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 6/9] drm/i915: Validate that the framebuffer accommodates the current mode
Date: Tue, 26 Mar 2013 16:33:09 -0700	[thread overview]
Message-ID: <1364340792-7278-7-git-send-email-jbarnes@virtuousgeek.org> (raw)
In-Reply-To: <1364340792-7278-1-git-send-email-jbarnes@virtuousgeek.org>

From: Chris Wilson <chris@chris-wilson.co.uk>

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 <chris@chris-wilson.co.uk>
---
 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);
-- 
1.7.9.5

  parent reply	other threads:[~2013-03-26 23:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 23:33 Updated fastboot patches Jesse Barnes
2013-03-26 23:33 ` [PATCH 1/9] drm/i915: Skip modifying PCH DREF if not changing clock sources Jesse Barnes
2013-03-28  7:27   ` Jani Nikula
2013-04-02 17:53     ` Daniel Vetter
2013-03-26 23:33 ` [PATCH 2/9] drm/i915: Split the framebuffer_info creation into a separate routine Jesse Barnes
2013-03-26 23:33 ` [PATCH 3/9] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v2 Jesse Barnes
2013-03-26 23:53   ` Chris Wilson
2013-03-27 14:07     ` Imre Deak
2013-03-26 23:33 ` [PATCH 4/9] drm/i915: Retrieve the current mode upon KMS takeover v2 Jesse Barnes
2013-03-26 23:36   ` Jesse Barnes
2013-03-27  0:13   ` Daniel Vetter
2013-03-27 15:52     ` Jesse Barnes
2013-03-26 23:33 ` [PATCH 5/9] drm/i915: Only preserve the BIOS modes if they are the preferred ones Jesse Barnes
2013-03-26 23:33 ` Jesse Barnes [this message]
2013-03-26 23:33 ` [PATCH 7/9] drm/i915: check panel fit status at update_plane time v2 Jesse Barnes
2013-03-26 23:33 ` [PATCH 8/9] drm/i915: treat no fb -> fb as simple flip instead of full mode set Jesse Barnes
2013-03-27  0:03   ` Daniel Vetter
2013-03-26 23:33 ` [PATCH 9/9] drm/i915: add debug messages for mode_valid checks Jesse Barnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364340792-7278-7-git-send-email-jbarnes@virtuousgeek.org \
    --to=jbarnes@virtuousgeek.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.