summaryrefslogtreecommitdiff
path: root/src/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'src/legacy')
-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
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 74b2fece..fa998962 100644
--- a/src/legacy/i810/i810_driver.c
+++ b/src/legacy/i810/i810_driver.c
@@ -1560,8 +1560,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 85b5b65c..91af7da5 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;
fbpitch = bpp * pScrn->displayWidth;
size = ((pitch * h) + bpp - 1) / bpp;