summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-03-15 03:12:32 +0000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-03-15 03:12:32 +0000
commit02d80a0de93f7592e69065b0fbe5820dcdebdb44 (patch)
tree88fcbaf91ef72b0c469a10861349e43e955532df /hw
parentc1601717d536419693b3ef6e8a3d69b9f2fdc2b3 (diff)
Make xf86 linear allocator smarter when dealing with alignment constraints
when falling back to X/Y allocations. Fixes various problems of Xv allocation failures, notably with "nv" driver.
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/common/xf86fbman.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index debd828bc..a65b00bc2 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -923,7 +923,7 @@ localAllocateOffscreenLinear(
ErrorF("ALLOCATING LINEAR\n");
#endif
if ((linear = AllocateLinear(offman, length, gran, privData)))
- return linear;
+ return linear;
#ifdef DEBUG
ErrorF("NOPE, ALLOCATING AREA\n");
@@ -936,11 +936,17 @@ localAllocateOffscreenLinear(
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
- if(gran && ((gran > pitch) || (pitch % gran))) {
+ if (gran && gran > pitch) {
/* we can't match the specified alignment with XY allocations */
xfree(link);
return NULL;
}
+ if (gran && (pitch % gran)) {
+ /* pitch and granularity aren't a perfect match, let's allocate
+ * a bit more so we can align later on
+ */
+ length += gran - 1;
+ }
if(length < pitch) { /* special case */
w = length;
@@ -963,6 +969,8 @@ localAllocateOffscreenLinear(
linear->pScreen = pScreen;
linear->size = h * w;
linear->offset = (pitch * area->box.y1) + area->box.x1;
+ if (gran && linear->offset % gran)
+ linear->offset += gran - (linear->offset % gran);
linear->granularity = gran;
linear->MoveLinearCallback = moveCB;
linear->RemoveLinearCallback = removeCB;