summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/savage/savageioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/savage/savageioctl.c')
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c527
1 files changed, 321 insertions, 206 deletions
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index ac9e055e931..dd7a84e2e72 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -37,16 +37,86 @@
#include "savagecontext.h"
#include "savageioctl.h"
#include "savage_bci.h"
-#include "savagedma.h"
+#include "savagestate.h"
#include "drm.h"
#include <sys/ioctl.h>
#include <sys/timeb.h>
-extern GLuint bcicount;
#define DEPTH_SCALE_16 ((1<<16)-1)
#define DEPTH_SCALE_24 ((1<<24)-1)
+
+void savageGetDMABuffer( savageContextPtr imesa )
+{
+ int idx = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int retcode;
+ drmBufPtr buf;
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Getting dma buffer\n");
+
+ dma.context = imesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = imesa->bufferSize;
+ dma.request_list = &idx;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
+ dma.context, dma.request_count,
+ dma.request_size);
+
+ while (1) {
+ retcode = drmDMA(imesa->driFd, &dma);
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
+ retcode,
+ dma.request_sizes[0],
+ dma.request_list[0],
+ dma.granted_count);
+
+ if (retcode == 0 &&
+ dma.request_sizes[0] &&
+ dma.granted_count)
+ break;
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "\n\nflush");
+ }
+
+ buf = &(imesa->savageScreen->bufs->list[idx]);
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr,
+ "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
+ "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n",
+ dma.request_sizes[0], dma.request_list[0],
+ buf->idx, buf->total,
+ buf->used, buf->address);
+
+ imesa->dmaVtxBuf.total = buf->total / 4;
+ imesa->dmaVtxBuf.used = 0;
+ imesa->dmaVtxBuf.flushed = 0;
+ imesa->dmaVtxBuf.idx = buf->idx;
+ imesa->dmaVtxBuf.buf = (u_int32_t *)buf->address;
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "finished getbuffer\n");
+}
+
+#if 0
+/* Still keeping this around because it demonstrates page flipping and
+ * automatic z-clear. */
static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
@@ -113,7 +183,7 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
imesa->regs.s4.zBufCtrl.ni.frameID =
~imesa->regs.s4.zBufCtrl.ni.frameID;
- imesa->dirty |= SAVAGE_UPLOAD_CTX;
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
else
{
@@ -157,8 +227,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
savageDMAFlush (imesa);
}
-struct timeb a,b;
-
static void savage_BCI_swap(savageContextPtr imesa)
{
int nbox = imesa->sarea->nbox;
@@ -186,7 +254,7 @@ static void savage_BCI_swap(savageContextPtr imesa)
imesa->readMap = (char *)imesa->apertureBase[imesa->toggle];
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
- imesa->dirty |= SAVAGE_UPLOAD_CTX;
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
bciptr = SAVAGE_GET_BCI_POINTER(imesa,3);
*(bciptr) = 0x960100B0;
*(bciptr) = (imesa->savageScreen->frontOffset);
@@ -220,97 +288,113 @@ static void savage_BCI_swap(savageContextPtr imesa)
}
}
+#endif
+
+
+static GLboolean intersect_rect( drm_clip_rect_t *out,
+ const drm_clip_rect_t *a,
+ const drm_clip_rect_t *b )
+{
+ *out = *a;
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+
+ return ((out->x1 < out->x2) && (out->y1 < out->y2));
+}
+
+
+static GLuint savageIntersectClipRects(drm_clip_rect_t *dest,
+ const drm_clip_rect_t *src,
+ GLuint nsrc,
+ const drm_clip_rect_t *clip)
+{
+ GLuint i, ndest;
+
+ for (i = 0, ndest = 0; i < nsrc; ++i, ++src) {
+ if (intersect_rect(dest, src, clip)) {
+ dest++;
+ ndest++;
+ }
+ }
+
+ return ndest;
+}
static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- drm_savage_clear_t clear;
- int i;
+ GLuint colorMask, depthMask, clearColor, clearDepth, flags;
- clear.flags = 0;
- clear.clear_color = imesa->ClearColor;
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+ clearColor = imesa->ClearColor;
if(imesa->savageScreen->zpp == 2)
- clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
+ clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
else
- clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
+ clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
- FLUSH_BATCH( imesa );
+ colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ depthMask = 0;
- if ((mask & DD_FRONT_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ){
- clear.flags |= SAVAGE_FRONT;
+ flags = 0;
+
+ if (mask & DD_FRONT_LEFT_BIT) {
+ flags |= SAVAGE_FRONT;
mask &= ~DD_FRONT_LEFT_BIT;
}
- if ((mask & DD_BACK_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ) {
- clear.flags |= SAVAGE_BACK;
+ if (mask & DD_BACK_LEFT_BIT) {
+ flags |= SAVAGE_BACK;
mask &= ~DD_BACK_LEFT_BIT;
}
if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
- clear.flags |= SAVAGE_DEPTH;
+ flags |= SAVAGE_DEPTH;
+ depthMask |=
+ (imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff;
mask &= ~DD_DEPTH_BIT;
}
if((mask & DD_STENCIL_BIT) && imesa->hw_stencil)
{
- clear.flags |= SAVAGE_STENCIL;
- mask &= ~DD_STENCIL_BIT;
+ flags |= SAVAGE_DEPTH;
+ depthMask |= 0xff000000;
+ mask &= ~DD_STENCIL_BIT;
}
- if (clear.flags) {
- LOCK_HARDWARE( imesa );
-
- /* flip top to bottom */
- cy = dPriv->h-cy-ch;
- cx += imesa->drawX;
- cy += imesa->drawY;
-
- for (i = 0 ; i < imesa->numClipRects ; ) {
- int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, imesa->numClipRects);
- drm_clip_rect_t *box = imesa->pClipRects;
- drm_clip_rect_t *b = imesa->sarea->boxes;
- int n = 0;
-
- if (!all) {
- for ( ; i < nr ; i++) {
- GLint x = box[i].x1;
- GLint y = box[i].y1;
- GLint w = box[i].x2 - x;
- GLint h = box[i].y2 - y;
-
- if (x < cx) w -= cx - x, x = cx;
- if (y < cy) h -= cy - y, y = cy;
- if (x + w > cx + cw) w = cx + cw - x;
- if (y + h > cy + ch) h = cy + ch - y;
- if (w <= 0) continue;
- if (h <= 0) continue;
-
- b->x1 = x;
- b->y1 = y;
- b->x2 = x + w;
- b->y2 = y + h;
- b++;
- n++;
- }
- } else {
- for ( ; i < nr ; i++) {
- *b++ = *(drm_clip_rect_t *)&box[i];
- n++;
- }
- }
-
- imesa->sarea->nbox = n;
-
- savage_BCI_clear(ctx,&clear);
+ savageFlushVertices(imesa);
+
+ if (flags) {
+ GLboolean depthCleared = GL_FALSE;
+ if (flags & (SAVAGE_FRONT|SAVAGE_BACK)) {
+ drm_savage_cmd_header_t *cmd;
+ cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
+ cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
+ if ((flags & SAVAGE_DEPTH) &&
+ clearDepth == clearColor && depthMask == colorMask) {
+ cmd[0].clear0.flags = flags;
+ depthCleared = GL_TRUE;
+ } else
+ cmd[0].clear0.flags = flags & (SAVAGE_FRONT|SAVAGE_BACK);
+ cmd[1].clear1.mask = colorMask;
+ cmd[1].clear1.value = clearColor;
+ }
+
+ if ((flags & SAVAGE_DEPTH) && !depthCleared) {
+ drm_savage_cmd_header_t *cmd;
+ cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
+ cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
+ cmd[0].clear0.flags = SAVAGE_DEPTH;
+ cmd[1].clear1.mask = depthMask;
+ cmd[1].clear1.value = clearDepth;
}
- UNLOCK_HARDWARE( imesa );
- imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS|SAVAGE_UPLOAD_CTX;
+ imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
}
if (mask)
@@ -318,7 +402,11 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
}
-
+/* This is necessary as to prevent annyoing stuttering effects with
+ * some games, though it does reduce the frame rate (glxgears)
+ * slightly. I believe this is due to texture uploads which do not go
+ * through the Savage command pipeline yet. */
+#define SYNC_FRAMES 1
/*
* Copy the back buffer to the front buffer.
@@ -326,11 +414,9 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
{
savageContextPtr imesa;
- drm_clip_rect_t *pbox;
- int nbox;
- int i;
- GLboolean pending;
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n================================\n", __FUNCTION__);
assert(dPriv);
assert(dPriv->driContextPriv);
@@ -342,38 +428,30 @@ void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
FLUSH_BATCH(imesa);
- LOCK_HARDWARE( imesa );
- WAIT_IDLE_EMPTY;
- PAGE_PENDING(pending);
-
- if(!pending)
- {
- pbox = dPriv->pClipRects;
- nbox = dPriv->numClipRects;
+#if SYNC_FRAMES
+ imesa->lastSwap = savageEmitEvent( imesa, 0 );
+#endif
+ if (imesa->lastSwap != 0)
+ savageWaitEvent( imesa, imesa->lastSwap );
- for (i = 0 ; i < nbox ; )
{
- int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
- drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
-
- imesa->sarea->nbox = nr - i;
-
- for ( ; i < nr ; i++)
- *b++ = pbox[i];
- savage_BCI_swap(imesa) ;
+ drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, 0);
+ cmd->cmd.cmd = SAVAGE_CMD_SWAP;
+ imesa->inSwap = GL_TRUE; /* ignore scissors in savageFlushCmdBuf */
+ savageFlushCmdBuf(imesa, GL_FALSE);
+ imesa->inSwap = GL_FALSE;
}
- }
- UNLOCK_HARDWARE( imesa );
-
+#if !SYNC_FRAMES
+ imesa->lastSwap = savageEmitEvent( imesa, 0 );
+#endif
}
/* This waits for *everybody* to finish rendering -- overkill.
*/
void savageDmaFinish( savageContextPtr imesa )
{
- savageDMAFlush(imesa);
- WAIT_IDLE_EMPTY;
+ savageWaitEvent( imesa, savageEmitEventLocked( imesa, SAVAGE_WAIT_3D ) );
}
@@ -393,152 +471,189 @@ void savageWaitAge( savageContextPtr imesa, int age )
}
+unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags )
+{
+ drm_savage_event_emit_t event;
+ int ret;
+ event.count = 0;
+ event.flags = flags;
+ ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_EMIT,
+ &event, sizeof(event) );
+ if (ret) {
+ fprintf (stderr, "emit event returned %d\n", ret);
+ exit (1);
+ }
+ return event.count;
+}
+unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags )
+{
+ unsigned int ret;
+ LOCK_HARDWARE( imesa );
+ ret = savageEmitEventLocked( imesa, flags );
+ UNLOCK_HARDWARE( imesa );
+ return ret;
+}
-void savageFlushVerticesLocked( savageContextPtr imesa )
+
+void savageWaitEvent( savageContextPtr imesa, unsigned int count )
{
- drmBufPtr buffer = imesa->vertex_dma_buffer;
+ drm_savage_event_wait_t event;
+ int ret;
+ event.count = count;
+ event.flags = 0;
+ ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_WAIT,
+ &event, sizeof(event) );
+ if (ret) {
+ fprintf (stderr, "wait event returned %d\n", ret);
+ exit (1);
+ }
+}
- if (!buffer)
- return;
- imesa->vertex_dma_buffer = NULL;
+void savageFlushVertices( savageContextPtr imesa )
+{
+ struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
+
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
- /* Lot's of stuff to do here. For now there is a fake DMA implementation
- * in savagedma.c that emits drawing commands. Cliprects are not handled
- * yet. */
- if (buffer->used) {
+ if (!buffer->total)
+ return;
+
+ if (buffer->used > buffer->flushed) {
+ drm_savage_cmd_header_t *cmd;
/* State must be updated "per primitive" because hardware
* culling must be disabled for unfilled primitives, points
* and lines. */
- savageEmitHwStateLocked (imesa);
- savageFakeVertices (imesa, buffer);
+ savageEmitChangedState (imesa);
+ cmd = savageAllocCmdBuf(imesa, 0);
+ cmd->prim.cmd = buffer == &imesa->dmaVtxBuf ?
+ SAVAGE_CMD_DMA_PRIM : SAVAGE_CMD_VB_PRIM;
+ cmd->prim.prim = imesa->HwPrim;
+ cmd->prim.skip = imesa->skip;
+ cmd->prim.start = buffer->flushed / imesa->HwVertexSize;
+ cmd->prim.count = buffer->used / imesa->HwVertexSize - cmd->prim.start;
+ buffer->flushed = buffer->used;
+ /* Make sure we don't buffer too many vertices without
+ * telling the hardware. */
+ imesa->vertsPending += cmd->prim.count;
+ if (imesa->vertsPending > SAVAGE_MAX_VERTS_PENDING) {
+ savageFlushCmdBuf(imesa, GL_FALSE);
+ imesa->vertsPending = 0;
+ }
}
}
-
-void savageFlushVertices( savageContextPtr imesa )
+void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
{
- LOCK_HARDWARE(imesa);
- savageFlushVerticesLocked (imesa);
- UNLOCK_HARDWARE(imesa);
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ drm_savage_cmdbuf_t cmdbuf;
+ drm_savage_cmd_header_t *start;
+ int ret;
+
+ /* If we lost the context we must restore the initial state (at
+ * the start of the command buffer). */
+ if (imesa->lostContext) {
+ start = imesa->cmdBuf.base;
+ imesa->lostContext = GL_FALSE;
+ } else
+ start = imesa->cmdBuf.start;
+
+ if (!imesa->dmaVtxBuf.total)
+ discard = GL_FALSE;
+
+ if ((SAVAGE_DEBUG & DEBUG_DMA) && discard)
+ fprintf (stderr, "Discarding DMA buffer, used=%u\n",
+ imesa->dmaVtxBuf.used);
+
+ cmdbuf.dma_idx = imesa->dmaVtxBuf.idx;
+ cmdbuf.discard = discard;
+ cmdbuf.vb_addr = imesa->clientVtxBuf.buf;
+ cmdbuf.vb_size = imesa->clientVtxBuf.total*4;
+ cmdbuf.vb_stride = imesa->HwVertexSize;
+ cmdbuf.cmd_addr = start;
+ cmdbuf.size = (imesa->cmdBuf.write - start);
+ if (!imesa->inSwap && imesa->glCtx->Scissor.Enabled) {
+ drm_clip_rect_t *box = dPriv->pClipRects, *ibox;
+ GLuint nbox = dPriv->numClipRects, nibox;
+ ibox = malloc(dPriv->numClipRects*sizeof(drm_clip_rect_t));
+ if (!ibox) {
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+ }
+ nibox = savageIntersectClipRects(ibox, box, nbox, &imesa->scissor_rect);
+ cmdbuf.nbox = nibox;
+ cmdbuf.box_addr = ibox;
+ } else {
+ cmdbuf.nbox = dPriv->numClipRects;
+ cmdbuf.box_addr = dPriv->pClipRects;
+ }
+
+ ret = drmCommandWrite( imesa->driFd, DRM_SAVAGE_BCI_CMDBUF,
+ &cmdbuf, sizeof(cmdbuf) );
+ if (ret) {
+ fprintf (stderr, "cmdbuf ioctl returned %d\n", ret);
+ exit(1);
+ }
+
+ if (cmdbuf.box_addr != dPriv->pClipRects) {
+ free(cmdbuf.box_addr);
+ }
+
+ if (discard) {
+ imesa->dmaVtxBuf.total = 0;
+ imesa->dmaVtxBuf.used = 0;
+ imesa->dmaVtxBuf.flushed = 0;
+ }
+ imesa->clientVtxBuf.used = 0;
+ imesa->clientVtxBuf.flushed = 0;
+
+ imesa->cmdBuf.write = imesa->cmdBuf.base;
+
+ /* Save the current state at the start of the command buffer. That
+ * state will only be emitted, if the context was lost since the
+ * last command buffer. */
+ savageEmitOldState(imesa);
+ imesa->cmdBuf.start = imesa->cmdBuf.write;
}
-int savage_check_copy(int fd)
+void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard )
{
- return 0;
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked (imesa, discard);
+ UNLOCK_HARDWARE(imesa);
}
+
static void savageDDFlush( GLcontext *ctx )
{
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
- savageFlushVerticesLocked (imesa);
- savageDMAFlush (imesa);
+ savageFlushCmdBufLocked(imesa, GL_FALSE);
UNLOCK_HARDWARE(imesa);
}
static void savageDDFinish( GLcontext *ctx )
{
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
- savageFlushVerticesLocked (imesa);
+ savageFlushCmdBufLocked(imesa, GL_FALSE);
savageDmaFinish (imesa);
UNLOCK_HARDWARE(imesa);
}
-#define ALT_STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c60))
-#define STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c00))
-#define MAXFIFO_S4 0x7F00
-#define MAXFIFO_S3D 0x7F00
-
-static GLboolean savagePagePending_s4( savageContextPtr imesa ) {
- return (ALT_STATUS_WORD0 & 0x08000000) ? GL_TRUE : GL_FALSE;
-}
-static GLboolean savagePagePending_s3d( savageContextPtr imesa ) {
- return GL_FALSE;
-}
-static void savageWaitForFIFO_s4( savageContextPtr imesa, unsigned count ) {
- int loop = 0;
- int slots = MAXFIFO_S4-count;
- while((ALT_STATUS_WORD0 & 0x001fffff) > slots && loop++ < MAXLOOP);
-}
-static void savageWaitForFIFO_s3d( savageContextPtr imesa, unsigned count ) {
- int loop = 0;
- int slots = MAXFIFO_S3D-count;
- while((STATUS_WORD0 & 0x0001ffff) > slots && loop++ < MAXLOOP);
-}
-static void savageWaitIdleEmpty_s4( savageContextPtr imesa ) {
- int loop = 0;
- while((ALT_STATUS_WORD0 & 0x00ffffff) != 0x00E00000L && loop++ < MAXLOOP);
-}
-static void savageWaitIdleEmpty_s3d( savageContextPtr imesa ) {
- int loop = 0;
- while((STATUS_WORD0 & 0x000fffff) != 0x000E0000L && loop++ < MAXLOOP);
-}
-
-GLboolean (*savagePagePending)( savageContextPtr imesa ) = NULL;
-void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count ) = NULL;
-void (*savageWaitIdleEmpty)( savageContextPtr imesa ) = NULL;
-
-
void savageDDInitIoctlFuncs( GLcontext *ctx )
{
ctx->Driver.Clear = savageDDClear;
ctx->Driver.Flush = savageDDFlush;
ctx->Driver.Finish = savageDDFinish;
- if (SAVAGE_CONTEXT( ctx )->savageScreen->chipset >= S3_SAVAGE4) {
- savagePagePending = savagePagePending_s4;
- savageWaitForFIFO = savageWaitForFIFO_s4;
- savageWaitIdleEmpty = savageWaitIdleEmpty_s4;
- } else {
- savagePagePending = savagePagePending_s3d;
- savageWaitForFIFO = savageWaitForFIFO_s3d;
- savageWaitIdleEmpty = savageWaitIdleEmpty_s3d;
- }
-}
-
-#if SAVAGE_CMD_DMA
-/* Alloc a continuous memory */
-/* return: 0 error when kernel alloc pages(can try a half memory size)
- >0 sucess
- <0 Other error*/
-int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
-{
- int ret;
- if (req ==NULL)
- return 0;
-
- if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_ALLOC_CONTINUOUS_MEM, req)) <=0)
- return ret;
-
- return 1;
-
}
-
-/* get the physics address*/
-GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer)
-{
-
- drm_savage_get_physcis_address_t req;
- int ret;
-
- req.v_address = (GLuint )pointer;
- ret = ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS,&req);
-
- return req.p_address;
-}
-
-/* free the buffer got by savageAllocDMABuffe*/
-int savageFreeDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
-{
- GLuint ret;
- if (req ==NULL)
- return 0;
-
- if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_FREE_CONTINUOUS_MEM, req)) <=0)
- return ret;
- return 1;
-
-}
-#endif