drm/i915: Use intel_tile_{size,width,height}() in intel_gen4_compute_page_offset()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 12 Jan 2016 19:08:35 +0000 (21:08 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 13 Jan 2016 16:46:41 +0000 (18:46 +0200)
Make intel_gen4_compute_page_offset() ready for other tiling formats
besied X-tile by getting the tile dimensions through
intel_tile_{size,width,height}().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1452625717-9713-6-git-send-email-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/intel_display.c

index 79900341f9443a5fa5414809a9b5661acd695526..8a76e29256ef2f87a744fc12eeb5c102c13a7cef 100644 (file)
@@ -2464,15 +2464,20 @@ unsigned long intel_gen4_compute_page_offset(struct drm_i915_private *dev_priv,
                                             unsigned int pitch)
 {
        if (fb_modifier != DRM_FORMAT_MOD_NONE) {
+               unsigned int tile_size, tile_width, tile_height;
                unsigned int tile_rows, tiles;
 
-               tile_rows = *y / 8;
-               *y %= 8;
+               tile_size = intel_tile_size(dev_priv);
+               tile_width = intel_tile_width(dev_priv, fb_modifier, cpp);
+               tile_height = tile_size / tile_width;
+
+               tile_rows = *y / tile_height;
+               *y %= tile_height;
 
-               tiles = *x / (512/cpp);
-               *x %= 512/cpp;
+               tiles = *x / (tile_width/cpp);
+               *x %= tile_width/cpp;
 
-               return tile_rows * pitch * 8 + tiles * 4096;
+               return tile_rows * pitch * tile_height + tiles * tile_size;
        } else {
                unsigned int alignment = intel_linear_alignment(dev_priv) - 1;
                unsigned int offset;