From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v3 04/21] drm/i915: Support for extra alignment for tiled surfaces
Date: Mon, 15 Feb 2016 22:54:42 +0200 [thread overview]
Message-ID: <1455569699-27905-5-git-send-email-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <1455569699-27905-1-git-send-email-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
SKL+ needs >4K alignment for tiled surfaces, so make
intel_compute_page_offset() handle it.
The way we do it is first we compute the closest tile boundary
as before, and then figure out how many tiles we need to go
to reach the desired alignment. The difference in the offset
is then added into the x/y offsets.
v2: Be less confusing wrt. units (pixels vs. bytes) (Daniel)
v3: Use u32 for offsets
Have intel_adjust_tile_offset() return the new offset (will be
useful later)
Add an offset_aligned variable (Daniel)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/intel_display.c | 50 ++++++++++++++++++++++++++++++++----
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index dcf379c29523..fe8d534a3334 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2461,6 +2461,35 @@ static void intel_unpin_fb_obj(struct drm_framebuffer *fb,
}
/*
+ * Adjust the tile offset by moving the difference into
+ * the x/y offsets.
+ *
+ * Input tile dimensions and pitch must already be
+ * rotated to match x and y, and in pixel units.
+ */
+static u32 intel_adjust_tile_offset(int *x, int *y,
+ unsigned int tile_width,
+ unsigned int tile_height,
+ unsigned int tile_size,
+ unsigned int pitch_tiles,
+ u32 old_offset,
+ u32 new_offset)
+{
+ unsigned int tiles;
+
+ WARN_ON(old_offset & (tile_size - 1));
+ WARN_ON(new_offset & (tile_size - 1));
+ WARN_ON(new_offset > old_offset);
+
+ tiles = (old_offset - new_offset) / tile_size;
+
+ *y += tiles / pitch_tiles * tile_height;
+ *x += tiles % pitch_tiles * tile_width;
+
+ return new_offset;
+}
+
+/*
* Computes the linear offset to the base tile and adjusts
* x, y. bytes per pixel is assumed to be a power-of-two.
*
@@ -2475,6 +2504,12 @@ u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv,
unsigned int pitch,
unsigned int rotation)
{
+ u32 offset, offset_aligned, alignment;
+
+ alignment = intel_surf_alignment(dev_priv, fb_modifier);
+ if (alignment)
+ alignment--;
+
if (fb_modifier != DRM_FORMAT_MOD_NONE) {
unsigned int tile_size, tile_width, tile_height;
unsigned int tile_rows, tiles, pitch_tiles;
@@ -2496,16 +2531,21 @@ u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv,
tiles = *x / tile_width;
*x %= tile_width;
- return (tile_rows * pitch_tiles + tiles) * tile_size;
- } else {
- unsigned int alignment = intel_linear_alignment(dev_priv) - 1;
- unsigned int offset;
+ offset = (tile_rows * pitch_tiles + tiles) * tile_size;
+ offset_aligned = offset & ~alignment;
+ intel_adjust_tile_offset(x, y, tile_width, tile_height,
+ tile_size, pitch_tiles,
+ offset, offset_aligned);
+ } else {
offset = *y * pitch + *x * cpp;
+ offset_aligned = offset & ~alignment;
+
*y = (offset & alignment) / pitch;
*x = ((offset & alignment) - *y * pitch) / cpp;
- return offset & ~alignment;
}
+
+ return offset_aligned;
}
static int i9xx_format_to_fourcc(int format)
--
2.4.10
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-02-15 20:55 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 20:54 [PATCH v3 00/21] drm/i915: Handle fb->offsets[] and rewrite fb rotation handling to be more generic (v3) ville.syrjala
2016-02-15 20:54 ` [PATCH 01/21] drm/i915: Account for the size of the chroma plane for the rotated gtt view ville.syrjala
2016-02-16 11:40 ` Tvrtko Ursulin
2016-02-16 11:49 ` Ville Syrjälä
2016-02-17 12:51 ` Joonas Lahtinen
2016-02-15 20:54 ` [PATCH 02/21] drm/i915: s/tile_width/tile_width_bytes/ ville.syrjala
2016-02-16 16:21 ` Daniel Vetter
2016-02-15 20:54 ` [PATCH v4 03/21] drm/i915: Pass 90/270 vs. 0/180 rotation info for intel_gen4_compute_page_offset() ville.syrjala
2016-02-16 16:23 ` Daniel Vetter
2016-02-15 20:54 ` ville.syrjala [this message]
2016-02-16 16:26 ` [PATCH v3 04/21] drm/i915: Support for extra alignment for tiled surfaces Daniel Vetter
2016-02-15 20:54 ` [PATCH v2 05/21] drm/i915: Don't pass plane+plane_state to intel_pin_and_fence_fb_obj() ville.syrjala
2016-02-15 20:54 ` [PATCH 06/21] drm/i915: Pass drm_frambuffer to intel_compute_page_offset() ville.syrjala
2016-02-15 20:54 ` [PATCH v2 07/21] drm/i915: Reorganize intel_rotation_info ville.syrjala
2016-02-15 20:54 ` [PATCH 08/21] drm/i915: Move the NULL sg handling out from rotate_pages() ville.syrjala
2016-02-15 20:54 ` [PATCH 09/21] drm/i915: Embed rotation_info under intel_framebuffer ville.syrjala
2016-03-01 11:00 ` Ville Syrjälä
2016-02-15 20:54 ` [PATCH v4 10/21] drm/i915: Rewrite fb rotation GTT handling ville.syrjala
[not found] ` <DBEE2697754A7A4EAA940D4FF7143C6250E38A75@BGSMSX102.gar.corp.intel.com>
2016-05-02 17:31 ` FW: " Thulasimani, Sivakumar
2016-05-02 18:40 ` Ville Syrjälä
2016-05-02 18:48 ` Chris Wilson
2016-02-15 20:54 ` [PATCH v3 11/21] drm/i915: Don't pass pitch to intel_compute_page_offset() ville.syrjala
2016-02-15 20:54 ` [PATCH 12/21] drm/i915: Move SKL hw stride calculation into a helper ville.syrjala
2016-02-15 20:54 ` [PATCH 13/21] drm/i915: Pass around plane_state instead of fb+rotation ville.syrjala
2016-02-15 20:54 ` [PATCH 14/21] drm/i915: Use fb modifiers for display tiling decisions ville.syrjala
2016-03-17 8:15 ` Matthew Auld
2016-02-15 20:54 ` [PATCH 15/21] drm/i915: Adjust obj tiling vs. fb modifier rules ville.syrjala
2016-03-17 8:08 ` Matthew Auld
2016-02-15 20:54 ` [PATCH 16/21] drm/i915: Limit fb x offset due to fences ville.syrjala
2016-02-15 20:54 ` [PATCH 17/21] drm/i915: Allow calling intel_adjust_tile_offset() multiple times ville.syrjala
2016-02-15 20:54 ` [PATCH 18/21] drm/i915: Make intel_adjust_tile_offset() work for linear buffers ville.syrjala
2016-02-15 20:54 ` [PATCH 19/21] drm/i915: Compute display surface offset in the plane check hook for SKL+ ville.syrjala
2016-02-15 20:54 ` [PATCH 20/21] drm/i915: Deal with NV12 CbCr plane AUX surface on SKL+ ville.syrjala
2016-02-15 20:54 ` [PATCH v2 21/21] drm/i915: Make sure fb offset is (macro)pixel aligned ville.syrjala
2016-02-16 11:28 ` ✗ Fi.CI.BAT: failure for drm/i915: Handle fb->offsets[] and rewrite fb rotation handling to be more generic (v3) Patchwork
2016-02-25 17:46 ` Ville Syrjälä
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=1455569699-27905-5-git-send-email-ville.syrjala@linux.intel.com \
--to=ville.syrjala@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;
as well as URLs for NNTP newsgroup(s).