[Intel-gfx] [PATCH 1/7] drm/i915/skl: Extract tile height code into a helper function

2015-03-23 Thread Tvrtko Ursulin
From: Tvrtko Ursulin tvrtko.ursu...@intel.com

It will be used in a later patch and also convert all height parameters
from int to unsigned int.

v2: Rebased for fb modifiers.
v3: Fixed v2 rebase.
v4:
   * Height should be unsigned int.
   * Make it take pixel_format for consistency and simplicity.

Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com
Reviewed-by: Michel Thierry michel.thie...@intel.com (v1)
Reviewed-by: Joonas Lahtinen joonas.lahti...@linux.intel.com (v4)
---
 drivers/gpu/drm/i915/intel_display.c | 43 +---
 drivers/gpu/drm/i915/intel_drv.h |  7 +++---
 2 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 60230dc..3b9ce89 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2233,13 +2233,12 @@ static bool need_vtd_wa(struct drm_device *dev)
return false;
 }
 
-int
-intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier)
+static unsigned int
+intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
+ uint64_t fb_format_modifier)
 {
-   int tile_height;
-   uint32_t bits_per_pixel;
+   unsigned int tile_height;
+   uint32_t pixel_bytes;
 
switch (fb_format_modifier) {
case DRM_FORMAT_MOD_NONE:
@@ -2252,20 +2251,20 @@ intel_fb_align_height(struct drm_device *dev, int 
height,
tile_height = 32;
break;
case I915_FORMAT_MOD_Yf_TILED:
-   bits_per_pixel = drm_format_plane_cpp(pixel_format, 0) * 8;
-   switch (bits_per_pixel) {
+   pixel_bytes = drm_format_plane_cpp(pixel_format, 0);
+   switch (pixel_bytes) {
default:
-   case 8:
+   case 1:
tile_height = 64;
break;
-   case 16:
-   case 32:
+   case 2:
+   case 4:
tile_height = 32;
break;
-   case 64:
+   case 8:
tile_height = 16;
break;
-   case 128:
+   case 16:
WARN_ONCE(1,
  128-bit pixels are not supported for 
display!);
tile_height = 16;
@@ -2278,7 +2277,15 @@ intel_fb_align_height(struct drm_device *dev, int height,
break;
}
 
-   return ALIGN(height, tile_height);
+   return tile_height;
+}
+
+unsigned int
+intel_fb_align_height(struct drm_device *dev, unsigned int height,
+ uint32_t pixel_format, uint64_t fb_format_modifier)
+{
+   return ALIGN(height, intel_tile_height(dev, pixel_format,
+  fb_format_modifier));
 }
 
 int
@@ -6811,7 +6818,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe, plane = crtc-plane;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7849,7 +7856,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset, stride_mult, tiling;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7957,7 +7964,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -12883,7 +12890,7 @@ static int intel_framebuffer_init(struct drm_device 
*dev,
  struct drm_mode_fb_cmd2 *mode_cmd,
  struct drm_i915_gem_object *obj)
 {
-   int aligned_height;
+   unsigned int aligned_height;
int ret;
u32 pitch_limit, stride_alignment;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d2a4de0..e974dd6 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -901,9 +901,10 @@ void intel_frontbuffer_flip(struct drm_device *dev,
intel_frontbuffer_flush(dev, frontbuffer_bits);
 }
 
-int intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier);
+unsigned int intel_fb_align_height(struct drm_device *dev,
+  unsigned int height,
+   

Re: [Intel-gfx] [PATCH 1/7] drm/i915/skl: Extract tile height code into a helper function

2015-03-18 Thread Joonas Lahtinen
On ti, 2015-03-17 at 15:45 +, Tvrtko Ursulin wrote:
 From: Tvrtko Ursulin tvrtko.ursu...@intel.com
 
 It will be used in a later patch and also convert all height parameters
 from int to unsigned int.
 
 v2: Rebased for fb modifiers.
 v3: Fixed v2 rebase.
 v4:
* Height should be unsigned int.
* Make it take pixel_format for consistency and simplicity.
 
 Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com
 Reviewed-by: Michel Thierry michel.thie...@intel.com (v1)
Reviewed-by: Joonas Lahtinen joonas.lahti...@linux.intel.com (v4)
 ---
  drivers/gpu/drm/i915/intel_display.c | 43 
 +---
  drivers/gpu/drm/i915/intel_drv.h |  7 +++---
  2 files changed, 29 insertions(+), 21 deletions(-)
 
 diff --git a/drivers/gpu/drm/i915/intel_display.c 
 b/drivers/gpu/drm/i915/intel_display.c
 index 90b460c..a307979 100644
 --- a/drivers/gpu/drm/i915/intel_display.c
 +++ b/drivers/gpu/drm/i915/intel_display.c
 @@ -2194,13 +2194,12 @@ static bool need_vtd_wa(struct drm_device *dev)
   return false;
  }
  
 -int
 -intel_fb_align_height(struct drm_device *dev, int height,
 -   uint32_t pixel_format,
 -   uint64_t fb_format_modifier)
 +static unsigned int
 +intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
 +   uint64_t fb_format_modifier)
  {
 - int tile_height;
 - uint32_t bits_per_pixel;
 + unsigned int tile_height;
 + uint32_t pixel_bytes;
  
   switch (fb_format_modifier) {
   case DRM_FORMAT_MOD_NONE:
 @@ -2213,20 +2212,20 @@ intel_fb_align_height(struct drm_device *dev, int 
 height,
   tile_height = 32;
   break;
   case I915_FORMAT_MOD_Yf_TILED:
 - bits_per_pixel = drm_format_plane_cpp(pixel_format, 0) * 8;
 - switch (bits_per_pixel) {
 + pixel_bytes = drm_format_plane_cpp(pixel_format, 0);
 + switch (pixel_bytes) {
   default:
 - case 8:
 + case 1:
   tile_height = 64;
   break;
 - case 16:
 - case 32:
 + case 2:
 + case 4:
   tile_height = 32;
   break;
 - case 64:
 + case 8:
   tile_height = 16;
   break;
 - case 128:
 + case 16:
   WARN_ONCE(1,
 128-bit pixels are not supported for 
 display!);
   tile_height = 16;
 @@ -2239,7 +2238,15 @@ intel_fb_align_height(struct drm_device *dev, int 
 height,
   break;
   }
  
 - return ALIGN(height, tile_height);
 + return tile_height;
 +}
 +
 +unsigned int
 +intel_fb_align_height(struct drm_device *dev, unsigned int height,
 +   uint32_t pixel_format, uint64_t fb_format_modifier)
 +{
 + return ALIGN(height, intel_tile_height(dev, pixel_format,
 +fb_format_modifier));
  }
  
  int
 @@ -6772,7 +6779,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
   u32 val, base, offset;
   int pipe = crtc-pipe, plane = crtc-plane;
   int fourcc, pixel_format;
 - int aligned_height;
 + unsigned int aligned_height;
   struct drm_framebuffer *fb;
   struct intel_framebuffer *intel_fb;
  
 @@ -7810,7 +7817,7 @@ skylake_get_initial_plane_config(struct intel_crtc 
 *crtc,
   u32 val, base, offset, stride_mult, tiling;
   int pipe = crtc-pipe;
   int fourcc, pixel_format;
 - int aligned_height;
 + unsigned int aligned_height;
   struct drm_framebuffer *fb;
   struct intel_framebuffer *intel_fb;
  
 @@ -7918,7 +7925,7 @@ ironlake_get_initial_plane_config(struct intel_crtc 
 *crtc,
   u32 val, base, offset;
   int pipe = crtc-pipe;
   int fourcc, pixel_format;
 - int aligned_height;
 + unsigned int aligned_height;
   struct drm_framebuffer *fb;
   struct intel_framebuffer *intel_fb;
  
 @@ -12849,7 +12856,7 @@ static int intel_framebuffer_init(struct drm_device 
 *dev,
 struct drm_mode_fb_cmd2 *mode_cmd,
 struct drm_i915_gem_object *obj)
  {
 - int aligned_height;
 + unsigned int aligned_height;
   int ret;
   u32 pitch_limit, stride_alignment;
  
 diff --git a/drivers/gpu/drm/i915/intel_drv.h 
 b/drivers/gpu/drm/i915/intel_drv.h
 index a1baaa1..5254540 100644
 --- a/drivers/gpu/drm/i915/intel_drv.h
 +++ b/drivers/gpu/drm/i915/intel_drv.h
 @@ -904,9 +904,10 @@ void intel_frontbuffer_flip(struct drm_device *dev,
   intel_frontbuffer_flush(dev, frontbuffer_bits);
  }
  
 -int intel_fb_align_height(struct drm_device *dev, int height,
 -   uint32_t pixel_format,
 -   uint64_t fb_format_modifier);
 +unsigned int intel_fb_align_height(struct drm_device *dev,
 +  

[Intel-gfx] [PATCH 1/7] drm/i915/skl: Extract tile height code into a helper function

2015-03-17 Thread Tvrtko Ursulin
From: Tvrtko Ursulin tvrtko.ursu...@intel.com

It will be used in a later patch and also convert all height parameters
from int to unsigned int.

v2: Rebased for fb modifiers.
v3: Fixed v2 rebase.
v4:
   * Height should be unsigned int.
   * Make it take pixel_format for consistency and simplicity.

Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com
Reviewed-by: Michel Thierry michel.thie...@intel.com (v1)
---
 drivers/gpu/drm/i915/intel_display.c | 43 +---
 drivers/gpu/drm/i915/intel_drv.h |  7 +++---
 2 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 90b460c..a307979 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2194,13 +2194,12 @@ static bool need_vtd_wa(struct drm_device *dev)
return false;
 }
 
-int
-intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier)
+static unsigned int
+intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
+ uint64_t fb_format_modifier)
 {
-   int tile_height;
-   uint32_t bits_per_pixel;
+   unsigned int tile_height;
+   uint32_t pixel_bytes;
 
switch (fb_format_modifier) {
case DRM_FORMAT_MOD_NONE:
@@ -2213,20 +2212,20 @@ intel_fb_align_height(struct drm_device *dev, int 
height,
tile_height = 32;
break;
case I915_FORMAT_MOD_Yf_TILED:
-   bits_per_pixel = drm_format_plane_cpp(pixel_format, 0) * 8;
-   switch (bits_per_pixel) {
+   pixel_bytes = drm_format_plane_cpp(pixel_format, 0);
+   switch (pixel_bytes) {
default:
-   case 8:
+   case 1:
tile_height = 64;
break;
-   case 16:
-   case 32:
+   case 2:
+   case 4:
tile_height = 32;
break;
-   case 64:
+   case 8:
tile_height = 16;
break;
-   case 128:
+   case 16:
WARN_ONCE(1,
  128-bit pixels are not supported for 
display!);
tile_height = 16;
@@ -2239,7 +2238,15 @@ intel_fb_align_height(struct drm_device *dev, int height,
break;
}
 
-   return ALIGN(height, tile_height);
+   return tile_height;
+}
+
+unsigned int
+intel_fb_align_height(struct drm_device *dev, unsigned int height,
+ uint32_t pixel_format, uint64_t fb_format_modifier)
+{
+   return ALIGN(height, intel_tile_height(dev, pixel_format,
+  fb_format_modifier));
 }
 
 int
@@ -6772,7 +6779,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe, plane = crtc-plane;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7810,7 +7817,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset, stride_mult, tiling;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7918,7 +7925,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -12849,7 +12856,7 @@ static int intel_framebuffer_init(struct drm_device 
*dev,
  struct drm_mode_fb_cmd2 *mode_cmd,
  struct drm_i915_gem_object *obj)
 {
-   int aligned_height;
+   unsigned int aligned_height;
int ret;
u32 pitch_limit, stride_alignment;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a1baaa1..5254540 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -904,9 +904,10 @@ void intel_frontbuffer_flip(struct drm_device *dev,
intel_frontbuffer_flush(dev, frontbuffer_bits);
 }
 
-int intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier);
+unsigned int intel_fb_align_height(struct drm_device *dev,
+  unsigned int height,
+  uint32_t pixel_format,
+   

[Intel-gfx] [PATCH 1/7] drm/i915/skl: Extract tile height code into a helper function

2015-03-05 Thread Tvrtko Ursulin
From: Tvrtko Ursulin tvrtko.ursu...@intel.com

It will be used in a later patch and also convert all height parameters
from int to unsigned int.

v2: Rebased for fb modifiers.
v3: Fixed v2 rebase.
v4:
   * Height should be unsigned int.
   * Make it take pixel_format for consistency and simplicity.

Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com
Reviewed-by: Michel Thierry michel.thie...@intel.com (v1)
---
 drivers/gpu/drm/i915/intel_display.c | 43 +---
 drivers/gpu/drm/i915/intel_drv.h |  7 +++---
 2 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 8e9e18c..bf389fc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2189,13 +2189,12 @@ static bool need_vtd_wa(struct drm_device *dev)
return false;
 }
 
-int
-intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier)
+static unsigned int
+intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
+ uint64_t fb_format_modifier)
 {
-   int tile_height;
-   uint32_t bits_per_pixel;
+   unsigned int tile_height;
+   uint32_t pixel_bytes;
 
switch (fb_format_modifier) {
case DRM_FORMAT_MOD_NONE:
@@ -2208,20 +2207,20 @@ intel_fb_align_height(struct drm_device *dev, int 
height,
tile_height = 32;
break;
case I915_FORMAT_MOD_Yf_TILED:
-   bits_per_pixel = drm_format_plane_cpp(pixel_format, 0) * 8;
-   switch (bits_per_pixel) {
+   pixel_bytes = drm_format_plane_cpp(pixel_format, 0);
+   switch (pixel_bytes) {
default:
-   case 8:
+   case 1:
tile_height = 64;
break;
-   case 16:
-   case 32:
+   case 2:
+   case 4:
tile_height = 32;
break;
-   case 64:
+   case 8:
tile_height = 16;
break;
-   case 128:
+   case 16:
WARN_ONCE(1,
  128-bit pixels are not supported for 
display!);
tile_height = 16;
@@ -2234,7 +2233,15 @@ intel_fb_align_height(struct drm_device *dev, int height,
break;
}
 
-   return ALIGN(height, tile_height);
+   return tile_height;
+}
+
+unsigned int
+intel_fb_align_height(struct drm_device *dev, unsigned int height,
+ uint32_t pixel_format, uint64_t fb_format_modifier)
+{
+   return ALIGN(height, intel_tile_height(dev, pixel_format,
+  fb_format_modifier));
 }
 
 int
@@ -6720,7 +6727,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe, plane = crtc-plane;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7758,7 +7765,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset, stride_mult, tiling;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -7866,7 +7873,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
u32 val, base, offset;
int pipe = crtc-pipe;
int fourcc, pixel_format;
-   int aligned_height;
+   unsigned int aligned_height;
struct drm_framebuffer *fb;
struct intel_framebuffer *intel_fb;
 
@@ -12791,7 +12798,7 @@ static int intel_framebuffer_init(struct drm_device 
*dev,
  struct drm_mode_fb_cmd2 *mode_cmd,
  struct drm_i915_gem_object *obj)
 {
-   int aligned_height;
+   unsigned int aligned_height;
int ret;
u32 pitch_limit, stride_alignment;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 6633674..1677ea1 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -900,9 +900,10 @@ void intel_frontbuffer_flip(struct drm_device *dev,
intel_frontbuffer_flush(dev, frontbuffer_bits);
 }
 
-int intel_fb_align_height(struct drm_device *dev, int height,
- uint32_t pixel_format,
- uint64_t fb_format_modifier);
+unsigned int intel_fb_align_height(struct drm_device *dev,
+  unsigned int height,
+  uint32_t pixel_format,
+