diff options
author | Matt Turner <mattst88@gmail.com> | 2010-08-21 17:32:24 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-22 09:52:42 +0100 |
commit | b611bced15c30f7bcd03106ce90668b684c1ada6 (patch) | |
tree | 7cd855510996cb39dbe6a454d3e36dbb2ce75b45 /src/legacy | |
parent | 8b04b350a983b89eb2d741f55baa297a933ac6ea (diff) |
Use ALIGN macro instead of open coding it.
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/legacy')
-rw-r--r-- | src/legacy/i810/i810_accel.c | 2 | ||||
-rw-r--r-- | src/legacy/i810/i810_common.h | 2 | ||||
-rw-r--r-- | src/legacy/i810/i810_driver.c | 3 | ||||
-rw-r--r-- | src/legacy/i810/i810_video.c | 18 |
4 files changed, 13 insertions, 12 deletions
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; |