summaryrefslogtreecommitdiff
path: root/src/lx_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lx_memory.c')
-rw-r--r--src/lx_memory.c225
1 files changed, 114 insertions, 111 deletions
diff --git a/src/lx_memory.c b/src/lx_memory.c
index d833caa..f26d280 100644
--- a/src/lx_memory.c
+++ b/src/lx_memory.c
@@ -45,11 +45,11 @@ GeodeOffscreenFreeSize(GeodeRec * pGeode)
GeodeMemPtr ptr = pGeode->offscreenList;
if (ptr == NULL)
- return pGeode->offscreenSize;
+ return pGeode->offscreenSize;
- for (; ptr->next; ptr = ptr->next) ;
+ for (; ptr->next; ptr = ptr->next);
return (pGeode->offscreenStart + pGeode->offscreenSize)
- - (ptr->offset + ptr->size);
+ - (ptr->offset + ptr->size);
}
void
@@ -62,12 +62,12 @@ GeodeFreeOffscreen(GeodeRec * pGeode, GeodeMemPtr ptr)
*/
if (ptr->prev == NULL)
- pGeode->offscreenList = ptr->next;
+ pGeode->offscreenList = ptr->next;
else
- ptr->prev->next = ptr->next;
+ ptr->prev->next = ptr->next;
if (ptr->next)
- ptr->next->prev = ptr->prev;
+ ptr->next->prev = ptr->prev;
free(ptr);
}
@@ -83,22 +83,22 @@ GeodeAllocRemainder(GeodeRec * pGeode)
GeodeMemPtr nptr, ptr = pGeode->offscreenList;
if (!pGeode->offscreenList) {
- pGeode->offscreenList = calloc(1, sizeof(*nptr));
- pGeode->offscreenList->offset = pGeode->offscreenStart;
- pGeode->offscreenList->size = pGeode->offscreenSize;
- pGeode->offscreenList->next = NULL;
- pGeode->offscreenList->prev = NULL;
+ pGeode->offscreenList = calloc(1, sizeof(*nptr));
+ pGeode->offscreenList->offset = pGeode->offscreenStart;
+ pGeode->offscreenList->size = pGeode->offscreenSize;
+ pGeode->offscreenList->next = NULL;
+ pGeode->offscreenList->prev = NULL;
- return pGeode->offscreenList;
+ return pGeode->offscreenList;
}
/* Go to the end of the list of allocated stuff */
- for (; ptr->next; ptr = ptr->next) ;
+ for (; ptr->next; ptr = ptr->next);
nptr = calloc(1, sizeof(*nptr));
nptr->offset = ptr->offset + ptr->size;
nptr->size = pGeode->offscreenSize -
- (nptr->offset - pGeode->offscreenStart);
+ (nptr->offset - pGeode->offscreenStart);
nptr->next = ptr->next;
nptr->prev = ptr;
@@ -120,46 +120,46 @@ GeodeAllocOffscreen(GeodeRec * pGeode, int size, int align)
if (!pGeode->offscreenList) {
- if (size > pGeode->offscreenSize)
- return NULL;
+ if (size > pGeode->offscreenSize)
+ return NULL;
- offset = ALIGN(pGeode->offscreenStart, align);
+ offset = ALIGN(pGeode->offscreenStart, align);
- pGeode->offscreenList = calloc(1, sizeof(*nptr));
- pGeode->offscreenList->offset = offset;
- pGeode->offscreenList->size = size;
- pGeode->offscreenList->next = NULL;
+ pGeode->offscreenList = calloc(1, sizeof(*nptr));
+ pGeode->offscreenList->offset = offset;
+ pGeode->offscreenList->size = size;
+ pGeode->offscreenList->next = NULL;
- return pGeode->offscreenList;
+ return pGeode->offscreenList;
}
while (ptr) {
- unsigned int gap;
+ unsigned int gap;
- if (ptr->next == NULL)
- gap = pGeode->offscreenSize + pGeode->offscreenStart;
+ if (ptr->next == NULL)
+ gap = pGeode->offscreenSize + pGeode->offscreenStart;
- else
- gap = ptr->next->offset;
+ else
+ gap = ptr->next->offset;
- gap = gap - (ptr->offset + ptr->size);
- gap = ALIGN(gap, align);
+ gap = gap - (ptr->offset + ptr->size);
+ gap = ALIGN(gap, align);
- if (size < gap) {
- offset = ptr->offset + ptr->size;
- offset = ALIGN(ptr->offset + ptr->size, align);
+ if (size < gap) {
+ offset = ptr->offset + ptr->size;
+ offset = ALIGN(ptr->offset + ptr->size, align);
- nptr = calloc(1, sizeof(*nptr));
- nptr->offset = offset;
- nptr->size = size;
- nptr->next = ptr->next;
- nptr->prev = ptr;
- ptr->next = nptr;
+ nptr = calloc(1, sizeof(*nptr));
+ nptr->offset = offset;
+ nptr->size = size;
+ nptr->next = ptr->next;
+ nptr->prev = ptr;
+ ptr->next = nptr;
- return nptr;
- }
+ return nptr;
+ }
- ptr = ptr->next;
+ ptr = ptr->next;
}
return NULL;
@@ -182,115 +182,118 @@ LXInitOffscreen(ScrnInfoPtr pScrni)
fbavail = pGeode->FBAvail - GP3_SCRATCH_BUFFER_SIZE;
pGeode->displaySize = MAX(pScrni->virtualX, pScrni->virtualY)
- * pGeode->Pitch;
+ * pGeode->Pitch;
pGeode->offscreenStart = pGeode->displaySize;
pGeode->offscreenSize = fbavail - pGeode->displaySize;
/* Allocate the usual memory suspects */
if (pGeode->tryCompression) {
- int size = pScrni->virtualY * LX_CB_PITCH;
-
- /* The compression buffer needs to be 16 byte aligned */
- ptr = GeodeAllocOffscreen(pGeode, size, 16);
-
- if (ptr != NULL) {
- pGeode->CBData.compression_offset = ptr->offset;
- pGeode->CBData.size = LX_CB_PITCH;
- pGeode->CBData.pitch = LX_CB_PITCH;
-
- pGeode->Compression = TRUE;
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for compression\n");
- pGeode->Compression = FALSE;
- }
+ int size = pScrni->virtualY * LX_CB_PITCH;
+
+ /* The compression buffer needs to be 16 byte aligned */
+ ptr = GeodeAllocOffscreen(pGeode, size, 16);
+
+ if (ptr != NULL) {
+ pGeode->CBData.compression_offset = ptr->offset;
+ pGeode->CBData.size = LX_CB_PITCH;
+ pGeode->CBData.pitch = LX_CB_PITCH;
+
+ pGeode->Compression = TRUE;
+ }
+ else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for compression\n");
+ pGeode->Compression = FALSE;
+ }
}
if (pGeode->tryHWCursor) {
- ptr = GeodeAllocOffscreen(pGeode,
- LX_CURSOR_HW_WIDTH * 4 * LX_CURSOR_HW_HEIGHT, 4);
-
- if (ptr != NULL) {
- pGeode->CursorStartOffset = ptr->offset;
- pGeode->HWCursor = TRUE;
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for the hardware cursor\n");
- pGeode->HWCursor = FALSE;
- }
+ ptr = GeodeAllocOffscreen(pGeode,
+ LX_CURSOR_HW_WIDTH * 4 * LX_CURSOR_HW_HEIGHT,
+ 4);
+
+ if (ptr != NULL) {
+ pGeode->CursorStartOffset = ptr->offset;
+ pGeode->HWCursor = TRUE;
+ }
+ else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the hardware cursor\n");
+ pGeode->HWCursor = FALSE;
+ }
}
if (!pGeode->NoAccel && pGeode->pExa) {
- int size;
+ int size;
- /* Try to get the scratch buffer for blending */
- pGeode->exaBfrOffset = 0;
+ /* Try to get the scratch buffer for blending */
+ pGeode->exaBfrOffset = 0;
- if (pGeode->exaBfrSz > 0) {
- ptr = GeodeAllocOffscreen(pGeode, pGeode->exaBfrSz, 4);
- if (ptr != NULL)
- pGeode->exaBfrOffset = ptr->offset;
- }
+ if (pGeode->exaBfrSz > 0) {
+ ptr = GeodeAllocOffscreen(pGeode, pGeode->exaBfrSz, 4);
+ if (ptr != NULL)
+ pGeode->exaBfrOffset = ptr->offset;
+ }
- pGeode->pExa->offScreenBase = 0;
- pGeode->pExa->memorySize = 0;
+ pGeode->pExa->offScreenBase = 0;
+ pGeode->pExa->memorySize = 0;
- /* This might cause complaints - in order to avoid using
+ /* This might cause complaints - in order to avoid using
xorg.conf as much as possible, we make assumptions about
what a "default" memory map would look like. After
discussion, we agreed that the default driver should assume
the user will want to use rotation and video overlays, and
- EXA will get whatever is leftover.
- */
+ EXA will get whatever is leftover.
+ */
- /* Get the amount of offscreen memory still left */
- size = GeodeOffscreenFreeSize(pGeode);
+ /* Get the amount of offscreen memory still left */
+ size = GeodeOffscreenFreeSize(pGeode);
- /* Align the size to a K boundary */
- size &= ~1023;
+ /* Align the size to a K boundary */
+ size &= ~1023;
- /* Allocate the EXA offscreen space */
- ptr = GeodeAllocOffscreen(pGeode, size, 4);
+ /* Allocate the EXA offscreen space */
+ ptr = GeodeAllocOffscreen(pGeode, size, 4);
- if (ptr == NULL) {
- /* If we couldn't allocate what we wanted,
- * then allocate whats left */
+ if (ptr == NULL) {
+ /* If we couldn't allocate what we wanted,
+ * then allocate whats left */
- ptr = GeodeAllocRemainder(pGeode);
- }
+ ptr = GeodeAllocRemainder(pGeode);
+ }
- if (ptr != NULL) {
- pGeode->pExa->offScreenBase = ptr->offset;
- pGeode->pExa->memorySize = ptr->offset + ptr->size;
- }
+ if (ptr != NULL) {
+ pGeode->pExa->offScreenBase = ptr->offset;
+ pGeode->pExa->memorySize = ptr->offset + ptr->size;
+ }
}
/* Show the memory map for diagnostic purposes */
xf86DrvMsg(pScrni->scrnIndex, X_INFO, "LX video memory:\n");
xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Display: 0x%x bytes\n",
- pGeode->displaySize);
+ pGeode->displaySize);
if (pGeode->Compression)
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Compression: 0x%x bytes\n",
- pScrni->virtualY * LX_CB_PITCH);
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Compression: 0x%x bytes\n",
+ pScrni->virtualY * LX_CB_PITCH);
if (pGeode->HWCursor)
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Cursor: 0x%x bytes\n",
- LX_CURSOR_HW_WIDTH * 4 * LX_CURSOR_HW_HEIGHT);
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Cursor: 0x%x bytes\n",
+ LX_CURSOR_HW_WIDTH * 4 * LX_CURSOR_HW_HEIGHT);
if (pGeode->exaBfrSz)
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, " ExaBfrSz: 0x%x bytes\n",
- pGeode->exaBfrSz);
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO, " ExaBfrSz: 0x%x bytes\n",
+ pGeode->exaBfrSz);
if (pGeode->pExa && pGeode->pExa->offScreenBase)
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, " EXA: 0x%x bytes\n",
- (unsigned int)(pGeode->pExa->memorySize -
- pGeode->pExa->offScreenBase));
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO, " EXA: 0x%x bytes\n",
+ (unsigned int) (pGeode->pExa->memorySize -
+ pGeode->pExa->offScreenBase));
xf86DrvMsg(pScrni->scrnIndex, X_INFO, " FREE: 0x%x bytes\n",
- GeodeOffscreenFreeSize(pGeode));
+ GeodeOffscreenFreeSize(pGeode));
}
/* Called as we go down, so blitz everybody */
@@ -303,9 +306,9 @@ GeodeCloseOffscreen(ScrnInfoPtr pScrni)
GeodeMemPtr nptr;
while (ptr) {
- nptr = ptr->next;
- free(ptr);
- ptr = nptr;
+ nptr = ptr->next;
+ free(ptr);
+ ptr = nptr;
}
pGeode->offscreenList = NULL;