summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intel_memory.c2
-rw-r--r--src/intel_video.c38
-rw-r--r--src/legacy/i810/i810_accel.c2
-rw-r--r--src/legacy/i810/i810_common.h2
-rw-r--r--src/legacy/i810/i810_driver.c3
-rw-r--r--src/legacy/i810/i810_video.c18
-rw-r--r--src/xvmc/i915_xvmc.c4
7 files changed, 33 insertions, 36 deletions
diff --git a/src/intel_memory.c b/src/intel_memory.c
index 47444ebe..b42e6d79 100644
--- a/src/intel_memory.c
+++ b/src/intel_memory.c
@@ -167,7 +167,7 @@ intel_check_display_stride(ScrnInfoPtr scrn, int stride, Bool tiling)
*/
static inline int intel_pad_drawable_width(int width)
{
- return (width + 63) & ~63;
+ return ALIGN(width, 64);
}
/**
diff --git a/src/intel_video.c b/src/intel_video.c
index e0a5c534..cde596cb 100644
--- a/src/intel_video.c
+++ b/src/intel_video.c
@@ -1277,10 +1277,10 @@ intel_clip_video_helper(ScrnInfoPtr scrn,
*top = y1 >> 16;
*left = (x1 >> 16) & ~1;
- *npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - *left;
+ *npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - *left;
if (is_planar_fourcc(id)) {
*top &= ~1;
- *nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - *top;
+ *nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - *top;
} else
*nlines = ((y2 + 0xffff) >> 16) - *top;
@@ -1385,32 +1385,32 @@ intel_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, sh
int id)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
- int pitchAlignMask;
+ int pitchAlign;
/* Only needs to be DWORD-aligned for textured on i915, but overlay has
* stricter requirements.
*/
if (adaptor_priv->textured) {
- pitchAlignMask = 3;
+ pitchAlign = 4;
} else {
if (IS_I965G(intel))
/* Actually the alignment is 64 bytes, too. But the
* stride must be at least 512 bytes. Take the easy fix
* and align on 512 bytes unconditionally. */
- pitchAlignMask = 511;
+ pitchAlign = 512;
else if (IS_I830(intel) || IS_845G(intel))
/* Harsh, errata on these chipsets limit the stride to be
* a multiple of 256 bytes.
*/
- pitchAlignMask = 255;
+ pitchAlign = 256;
else
- pitchAlignMask = 63;
+ pitchAlign = 64;
}
#if INTEL_XVMC
/* for i915 xvmc, hw requires 1kb aligned surfaces */
if ((id == FOURCC_XVMC) && IS_I915(intel))
- pitchAlignMask = 0x3ff;
+ pitchAlign = 1024;
#endif
/* Determine the desired destination pitch (representing the chroma's pitch,
@@ -1418,26 +1418,20 @@ intel_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, sh
*/
if (is_planar_fourcc(id)) {
if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- *dstPitch =
- ((height / 2) + pitchAlignMask) & ~pitchAlignMask;
- *dstPitch2 =
- (height + pitchAlignMask) & ~pitchAlignMask;
+ *dstPitch = ALIGN((height / 2), pitchAlign);
+ *dstPitch2 = ALIGN(height, pitchAlign);
*size = *dstPitch * width * 3;
} else {
- *dstPitch =
- ((width / 2) + pitchAlignMask) & ~pitchAlignMask;
- *dstPitch2 =
- (width + pitchAlignMask) & ~pitchAlignMask;
+ *dstPitch = ALIGN((width / 2), pitchAlign);
+ *dstPitch2 = ALIGN(width, pitchAlign);
*size = *dstPitch * height * 3;
}
} else {
if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- *dstPitch =
- ((height << 1) + pitchAlignMask) & ~pitchAlignMask;
+ *dstPitch = ALIGN((height << 1), pitchAlign);
*size = *dstPitch * width;
} else {
- *dstPitch =
- ((width << 1) + pitchAlignMask) & ~pitchAlignMask;
+ *dstPitch = ALIGN((width << 1), pitchAlign);
*size = *dstPitch * height;
}
*dstPitch2 = 0;
@@ -1472,8 +1466,8 @@ intel_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
int size;
if (is_planar_fourcc(id)) {
- srcPitch = (width + 0x3) & ~0x3;
- srcPitch2 = ((width >> 1) + 0x3) & ~0x3;
+ srcPitch = ALIGN(width, 0x4);
+ srcPitch2 = ALIGN((width >> 1), 0x4);
} else {
srcPitch = width << 1;
}
diff --git a/src/legacy/i810/i810_accel.c b/src/legacy/i810/i810_accel.c
index ae4a6544..9aa3e42c 100644
--- a/src/legacy/i810/i810_accel.c
+++ b/src/legacy/i810/i810_accel.c
@@ -129,7 +129,7 @@ I810AccelInit(ScreenPtr pScreen)
*/
if (pI810->Scratch.Size != 0) {
int i;
- int width = ((pScrn->displayWidth + 31) & ~31) / 8;
+ int width = ALIGN(pScrn->displayWidth, 32) / 8;
int nr_buffers = pI810->Scratch.Size / width;
unsigned char *ptr = pI810->FbBase + pI810->Scratch.Start;
diff --git a/src/legacy/i810/i810_common.h b/src/legacy/i810/i810_common.h
index ea28f4ab..a526f736 100644
--- a/src/legacy/i810/i810_common.h
+++ b/src/legacy/i810/i810_common.h
@@ -50,6 +50,8 @@
#define KB(x) ((x) * 1024)
#define MB(x) ((x) * KB(1024))
+#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
+
/* Using usleep() makes things noticably slow. */
#if 0
#define DELAY(x) usleep(x)
diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c
index 3fc9d044..3637e25c 100644
--- a/src/legacy/i810/i810_driver.c
+++ b/src/legacy/i810/i810_driver.c
@@ -1545,8 +1545,7 @@ I810AllocateFront(ScrnInfoPtr pScrn)
if (!I810AllocLow(&(pI810->FrontBuffer),
&(pI810->SysMem),
- ((pI810->FbMemBox.x2 *
- pI810->FbMemBox.y2 * pI810->cpp) + 4095) & ~4095)) {
+ ALIGN((pI810->FbMemBox.x2 * pI810->FbMemBox.y2 * pI810->cpp), 4096))) {
xf86DrvMsg(pScrn->scrnIndex,
X_WARNING, "Framebuffer allocation failed\n");
return FALSE;
diff --git a/src/legacy/i810/i810_video.c b/src/legacy/i810/i810_video.c
index 7e3db8c7..68dc471a 100644
--- a/src/legacy/i810/i810_video.c
+++ b/src/legacy/i810/i810_video.c
@@ -750,14 +750,14 @@ I810DisplayVideo(
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
- swidth = (width + 7) & ~7;
+ swidth = ALIGN(width, 8);
overlay->SWID = (swidth << 15) | swidth;
overlay->SWIDQW = (swidth << 12) | (swidth >> 3);
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
- swidth = ((width + 3) & ~3) << 1;
+ swidth = ALIGN(width, 4) << 1;
overlay->SWID = swidth;
overlay->SWIDQW = swidth >> 3;
break;
@@ -1013,15 +1013,15 @@ I810PutImage(
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
- srcPitch = (width + 3) & ~3;
- dstPitch = ((width >> 1) + 7) & ~7; /* of chroma */
+ srcPitch = ALIGN(width, 4);
+ dstPitch = ALIGN((width >> 1), 8); /* of chroma */
size = dstPitch * height * 3;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
srcPitch = (width << 1);
- dstPitch = (srcPitch + 7) & ~7;
+ dstPitch = ALIGN(srcPitch, 8);
size = dstPitch * height;
break;
}
@@ -1062,13 +1062,13 @@ I810PutImage(
/* copy data */
top = y1 >> 16;
left = (x1 >> 16) & ~1;
- npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+ npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - left;
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
top &= ~1;
- nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - top;
I810CopyPlanarData(pScrn, buf, srcPitch, dstPitch, height, top, left,
nlines, npixels, id);
break;
@@ -1213,8 +1213,8 @@ I810AllocateSurface(
if((w > 1024) || (h > 1024))
return BadAlloc;
- w = (w + 1) & ~1;
- pitch = ((w << 1) + 15) & ~15;
+ w = ALIGN(w, 2);
+ pitch = ALIGN((w << 1), 16);
bpp = pScrn->bitsPerPixel >> 3;
size = ((pitch * h) + bpp - 1) / bpp;
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index 9ad8d01a..21a11491 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -31,7 +31,9 @@
#include "i915_structs.h"
#include "i915_program.h"
-#define STRIDE(w) (((w) + 0x3ff) & ~0x3ff)
+#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
+
+#define STRIDE(w) (ALIGN((w), 1024))
#define SIZE_Y420(w, h) (h * STRIDE(w))
#define SIZE_UV420(w, h) ((h >> 1) * STRIDE(w >> 1))
#define SIZE_YUV420(w, h) (SIZE_Y420(w,h) + SIZE_UV420(w,h) * 2)