public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/8] drm/i915: Extract tiled geometry calculation into a helper function
Date: Fri,  8 May 2015 13:02:39 +0100	[thread overview]
Message-ID: <1431086563-4498-5-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1431086563-4498-1-git-send-email-tvrtko.ursulin@linux.intel.com>

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

It will be used twice with support for planar NV12.

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

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index f5709d4..65c9d36 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2680,6 +2680,24 @@ rotate_pages(dma_addr_t *in, unsigned int width, unsigned int height,
 	}
 }
 
+static unsigned long
+intel_calc_tiled_geometry(struct drm_device *dev,
+			  struct intel_rotation_info *rot_info,
+			  unsigned int *width_pages,
+			  unsigned int *height_pages,
+			  unsigned int plane)
+{
+	unsigned int tile_height, tile_pitch;
+
+	tile_height = intel_tile_height(dev, rot_info->pixel_format,
+					rot_info->fb_modifier, plane);
+	tile_pitch = PAGE_SIZE / tile_height;
+	*width_pages = DIV_ROUND_UP(rot_info->pitch, tile_pitch);
+	*height_pages = DIV_ROUND_UP(rot_info->height, tile_height);
+
+	return (*width_pages) * (*height_pages);
+}
+
 static struct sg_table *
 intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view,
 			  struct drm_i915_gem_object *obj)
@@ -2691,19 +2709,14 @@ intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view,
 	unsigned long i;
 	dma_addr_t *page_addr_list;
 	struct sg_table *st;
-	unsigned int tile_pitch, tile_height;
 	unsigned int width_pages, height_pages;
 	int ret = -ENOMEM;
 
 	pages = obj->base.size / PAGE_SIZE;
 
 	/* Calculate tiling geometry. */
-	tile_height = intel_tile_height(dev, rot_info->pixel_format,
-					rot_info->fb_modifier, 0);
-	tile_pitch = PAGE_SIZE / tile_height;
-	width_pages = DIV_ROUND_UP(rot_info->pitch, tile_pitch);
-	height_pages = DIV_ROUND_UP(rot_info->height, tile_height);
-	rot_pages = width_pages * height_pages;
+	rot_pages = intel_calc_tiled_geometry(dev, rot_info,
+					      &width_pages, &height_pages, 0);
 
 	/* Allocate a temporary list of source pages for random access. */
 	page_addr_list = drm_malloc_ab(pages, sizeof(dma_addr_t));
-- 
2.4.0

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

  parent reply	other threads:[~2015-05-08 12:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 12:02 [PATCH 0/8] NV12 90/270 rotated GGTT mapping Tvrtko Ursulin
2015-05-08 12:02 ` [PATCH 1/8] drm/i915: Remove duplicated intel_tile_height declaration Tvrtko Ursulin
2015-05-11 10:26   ` Daniel Vetter
2015-05-08 12:02 ` [PATCH 2/8] drm/i915: Support planar formats in tile height calculations Tvrtko Ursulin
2015-05-08 12:02 ` [PATCH 3/8] drm/i915: Remove pointless calculation in intel_rotate_fb_obj_pages Tvrtko Ursulin
2015-05-08 12:02 ` Tvrtko Ursulin [this message]
2015-05-08 12:02 ` [PATCH 5/8] drm/i915: Support appending to the rotated pages mapping Tvrtko Ursulin
2015-05-08 12:02 ` [PATCH 6/8] drm/i915: Support NV12 in rotated GGTT mapping Tvrtko Ursulin
2015-05-08 12:02 ` [PATCH 7/8] drm/i915: Enable querying offset of UV plane with intel_plane_obj_offset Tvrtko Ursulin
2015-05-08 12:02 ` [PATCH 8/8] drm/i915: Allow NV12 with 90/270 rotation Tvrtko Ursulin
2015-05-11  3:52   ` shuang.he
2015-05-08 14:59 ` [PATCH 0/8] NV12 90/270 rotated GGTT mapping Damien Lespiau
2015-05-08 15:05   ` 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=1431086563-4498-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox