From df57ea903b701669b315a48311c1535f64f5d37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Mon, 22 Apr 2013 08:20:39 +0300 Subject: gralloc: cleanup, use ALIGN macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I029aafe5a99393a4c0f7ff87f422317621fada12 Signed-off-by: Tapani Pälli --- gralloc_drm.h | 6 ++++-- gralloc_drm_intel.c | 6 +++--- gralloc_drm_nouveau.c | 1 - gralloc_drm_radeon.c | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gralloc_drm.h b/gralloc_drm.h index 8554cf7..4694185 100644 --- a/gralloc_drm.h +++ b/gralloc_drm.h @@ -31,6 +31,8 @@ extern "C" { #endif +#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) + struct gralloc_drm_t; struct gralloc_drm_bo_t; @@ -109,8 +111,8 @@ static inline void gralloc_drm_align_geometry(int format, int *width, int *heigh break; } - *width = (*width + align_w - 1) & ~(align_w - 1); - *height = (*height + align_h - 1) & ~(align_h - 1); + *width = ALIGN(*width, align_w); + *height = ALIGN(*height, align_h); if (extra_height_div) *height += *height / extra_height_div; diff --git a/gralloc_drm_intel.c b/gralloc_drm_intel.c index 50293b9..645339b 100644 --- a/gralloc_drm_intel.c +++ b/gralloc_drm_intel.c @@ -393,7 +393,7 @@ static drm_intel_bo *alloc_ibo(struct intel_info *info, max_stride /= 2; name = "gralloc-fb"; - aligned_width = (aligned_width + 63) & ~63; + aligned_width = ALIGN(aligned_width, 64); flags = BO_ALLOC_FOR_RENDER; *tiling = I915_TILING_X; @@ -441,8 +441,8 @@ static drm_intel_bo *alloc_ibo(struct intel_info *info, if (handle->usage & GRALLOC_USAGE_HW_TEXTURE) { name = "gralloc-texture"; /* see 2D texture layout of DRI drivers */ - aligned_width = (aligned_width + 3) & ~3; - aligned_height = (aligned_height + 1) & ~1; + aligned_width = ALIGN(aligned_width, 4); + aligned_height = ALIGN(aligned_height, 2); } else { name = "gralloc-buffer"; diff --git a/gralloc_drm_nouveau.c b/gralloc_drm_nouveau.c index 4536e7e..576966e 100644 --- a/gralloc_drm_nouveau.c +++ b/gralloc_drm_nouveau.c @@ -40,7 +40,6 @@ #include "gralloc_drm_priv.h" #define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) #define NVC0_TILE_HEIGHT(m) (8 << ((m) >> 4)) diff --git a/gralloc_drm_radeon.c b/gralloc_drm_radeon.c index 94dc2ed..5c77bc8 100644 --- a/gralloc_drm_radeon.c +++ b/gralloc_drm_radeon.c @@ -46,7 +46,6 @@ #define RADEON_GPU_PAGE_SIZE 4096 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) struct radeon_info { struct gralloc_drm_drv_t base; -- cgit v1.1