All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [RFC 5/6] drm/i915: Allow fb modifier to set framebuffer tiling
Date: Fri, 30 Jan 2015 17:36:57 +0000	[thread overview]
Message-ID: <1422639418-28845-6-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1422639418-28845-1-git-send-email-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Use the fb modifier if it was specified over object tiling mode.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 40 +++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e22afbe..ca69da0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12671,6 +12671,20 @@ static const struct drm_framebuffer_funcs intel_fb_funcs = {
 	.create_handle = intel_user_framebuffer_create_handle,
 };
 
+static unsigned int
+intel_fb_modifier_to_tiling(u64 modifier)
+{
+	switch (modifier) {
+	case I915_FORMAT_MOD_X_TILED:
+		return I915_TILING_X;
+	default:
+	case I915_FORMAT_MOD_NONE:
+		break;
+	}
+
+	return I915_TILING_NONE;
+}
+
 static int intel_framebuffer_init(struct drm_device *dev,
 				  struct intel_framebuffer *intel_fb,
 				  struct drm_mode_fb_cmd2 *mode_cmd,
@@ -12678,11 +12692,23 @@ static int intel_framebuffer_init(struct drm_device *dev,
 {
 	int aligned_height;
 	int pitch_limit;
+	unsigned int tiling_mode = obj->tiling_mode;
 	int ret;
 
 	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
 
-	if (obj->tiling_mode == I915_TILING_Y) {
+	if (mode_cmd->flags & DRM_MODE_FB_MODIFIERS) {
+		tiling_mode =
+			intel_fb_modifier_to_tiling(mode_cmd->modifier[0]);
+		if (tiling_mode != obj->tiling_mode &&
+			obj->tiling_mode != I915_TILING_NONE) {
+			DRM_ERROR("Tiling modifier mismatch %u vs obj %u!\n",
+					tiling_mode, obj->tiling_mode);
+			return -EINVAL;
+		}
+	}
+
+	if (tiling_mode == I915_TILING_Y) {
 		DRM_DEBUG("hardware does not support tiling Y\n");
 		return -EINVAL;
 	}
@@ -12696,12 +12722,12 @@ static int intel_framebuffer_init(struct drm_device *dev,
 	if (INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev)) {
 		pitch_limit = 32*1024;
 	} else if (INTEL_INFO(dev)->gen >= 4) {
-		if (obj->tiling_mode)
+		if (tiling_mode)
 			pitch_limit = 16*1024;
 		else
 			pitch_limit = 32*1024;
 	} else if (INTEL_INFO(dev)->gen >= 3) {
-		if (obj->tiling_mode)
+		if (tiling_mode)
 			pitch_limit = 8*1024;
 		else
 			pitch_limit = 16*1024;
@@ -12711,12 +12737,12 @@ static int intel_framebuffer_init(struct drm_device *dev,
 
 	if (mode_cmd->pitches[0] > pitch_limit) {
 		DRM_DEBUG("%s pitch (%d) must be at less than %d\n",
-			  obj->tiling_mode ? "tiled" : "linear",
+			  tiling_mode ? "tiled" : "linear",
 			  mode_cmd->pitches[0], pitch_limit);
 		return -EINVAL;
 	}
 
-	if (obj->tiling_mode != I915_TILING_NONE &&
+	if (tiling_mode != I915_TILING_NONE && obj->stride &&
 	    mode_cmd->pitches[0] != obj->stride) {
 		DRM_DEBUG("pitch (%d) must match tiling stride (%d)\n",
 			  mode_cmd->pitches[0], obj->stride);
@@ -12771,7 +12797,7 @@ static int intel_framebuffer_init(struct drm_device *dev,
 		return -EINVAL;
 
 	aligned_height = intel_fb_align_height(dev, mode_cmd->height,
-					       obj->tiling_mode);
+					       tiling_mode);
 	/* FIXME drm helper for size checks (especially planar formats)? */
 	if (obj->base.size < aligned_height * mode_cmd->pitches[0])
 		return -EINVAL;
@@ -12779,7 +12805,7 @@ static int intel_framebuffer_init(struct drm_device *dev,
 	drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd);
 	intel_fb->obj = obj;
 	intel_fb->obj->framebuffer_references++;
-	intel_fb->tiling_mode = obj->tiling_mode;
+	intel_fb->tiling_mode = tiling_mode;
 
 	ret = drm_framebuffer_init(dev, &intel_fb->base, &intel_fb_funcs);
 	if (ret) {
-- 
2.2.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-01-30 17:37 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 17:36 [RFC 0/6] Use framebuffer modifiers for tiled display Tvrtko Ursulin
2015-01-30 17:36 ` [RFC 1/6] RFC: drm: add support for tiled/compressed/etc modifier in addfb2 Tvrtko Ursulin
2015-01-30 17:36 ` [RFC 2/6] drm/i915: Add tiled framebuffer modifiers Tvrtko Ursulin
2015-02-02  9:41   ` Daniel Vetter
2015-02-02  9:58     ` [Intel-gfx] " Daniel Vetter
2015-02-02 10:23       ` Tvrtko Ursulin
2015-02-02 15:55         ` [Intel-gfx] " Daniel Vetter
2015-02-02 15:58         ` Daniel Vetter
2015-02-02 16:35           ` Rob Clark
2015-02-02 16:32     ` [Intel-gfx] " Rob Clark
2015-02-02 16:42       ` Tvrtko Ursulin
2015-02-02 16:59         ` Daniel Vetter
2015-02-02 19:25           ` Rob Clark
2015-01-30 17:36 ` [RFC 3/6] drm/i915: Set up fb modifier on initial takeover Tvrtko Ursulin
2015-01-30 17:36 ` [RFC 4/6] drm/i915: Use framebuffer tiling mode for display purposes Tvrtko Ursulin
2015-02-02  9:49   ` Daniel Vetter
2015-02-02 10:29     ` Tvrtko Ursulin
2015-02-02 17:09       ` Daniel Vetter
2015-01-30 17:36 ` Tvrtko Ursulin [this message]
2015-02-02  9:54   ` [RFC 5/6] drm/i915: Allow fb modifier to set framebuffer tiling Daniel Vetter
2015-02-02 10:36     ` Tvrtko Ursulin
2015-02-02 17:15       ` Daniel Vetter
2015-02-02 17:30         ` Tvrtko Ursulin
2015-02-02 20:17           ` Daniel Vetter
2015-02-03 10:41             ` Tvrtko Ursulin
2015-02-03 11:41               ` Daniel Vetter
2015-01-30 17:36 ` [RFC 6/6] drm/i915: Announce support for framebuffer modifiers Tvrtko Ursulin
2015-02-02  9:51   ` Daniel Vetter
2015-02-03 17:22 ` [RFC v2 0/4] Use framebuffer modifiers for tiled display Tvrtko Ursulin
2015-02-03 17:22   ` [PATCH 1/4] RFC: drm: add support for tiled/compressed/etc modifier in addfb2 Tvrtko Ursulin
2015-02-03 17:22   ` [PATCH 2/4] drm/i915: Add tiled framebuffer modifiers Tvrtko Ursulin
2015-02-03 17:22   ` [PATCH 3/4] drm/i915: Use frame buffer modifiers for tiled display Tvrtko Ursulin
2015-02-03 19:47     ` Daniel Vetter
2015-02-04 10:01       ` Tvrtko Ursulin
2015-02-04 14:25         ` Daniel Vetter
2015-02-04 15:09           ` Tvrtko Ursulin
2015-02-04 15:33             ` Daniel Vetter
2015-02-04 15:44               ` Tvrtko Ursulin
2015-02-05 14:14                 ` Daniel Vetter
2015-02-03 17:22   ` [PATCH 4/4] drm/i915: Announce support for framebuffer modifiers Tvrtko Ursulin
2015-02-05 14:41 ` [RFC v3 0/4] Use framebuffer modifiers for tiled display Tvrtko Ursulin
2015-02-05 14:41   ` [PATCH 1/4] RFC: drm: add support for tiled/compressed/etc modifier in addfb2 Tvrtko Ursulin
2015-02-05 15:06     ` Daniel Stone
2015-02-05 14:41   ` [PATCH 2/4] drm/i915: Add tiled framebuffer modifiers Tvrtko Ursulin
2015-02-09 16:55     ` Daniel Vetter
2015-02-09 16:58     ` Daniel Vetter
2015-02-05 14:41   ` [PATCH 3/4] drm/i915: Use frame buffer modifiers for tiled display Tvrtko Ursulin
2015-02-05 14:41   ` [PATCH 4/4] drm/i915: Announce support for framebuffer modifiers Tvrtko Ursulin
2015-02-08  6:00     ` shuang.he
     [not found]     ` <6c3329$kb0jfs@orsmga002.jf.intel.com>
2015-02-08 12:43       ` He, Shuang
2015-02-08 12:44     ` shuang.he
2015-02-06 17:26   ` [PATCH 3/4 v3] drm/i915: Use frame buffer modifiers for tiled display Tvrtko Ursulin

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=1422639418-28845-6-git-send-email-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --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.