i965: Reduce repeated calculation of the attribute-offset-in-VUE.
[mesa.git] / src / mesa / drivers / dri / r128 / r128_ioctl.c
index 7f9f7a923ea4adca80526684f31bd78736853705..56758d971c32986e6c992d6d1498aeba033e5f9e 100644 (file)
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c,v 1.10 2002/12/16 16:18:53 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -33,21 +32,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <errno.h>
 
+#define STANDALONE_MMIO
 #include "r128_context.h"
 #include "r128_state.h"
 #include "r128_ioctl.h"
-#include "imports.h"
-#include "macros.h"
+#include "main/imports.h"
+#include "main/macros.h"
 
 #include "swrast/swrast.h"
 
 #include "vblank.h"
-
-#ifdef _SOLO
-/* temporary - should really split r128_reg.h into r128_reg.h & r128_macros.h
- * like the radeon */
-#include "r128_macros.h"
-#endif
+#include "mmio.h"
+#include "drirenderbuffer.h"
 
 #define R128_TIMEOUT        2048
 #define R128_IDLE_RETRY       32
@@ -106,13 +102,13 @@ drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa )
 
 void r128FlushVerticesLocked( r128ContextPtr rmesa )
 {
-   XF86DRIClipRectPtr pbox = rmesa->pClipRects;
+   drm_clip_rect_t *pbox = rmesa->pClipRects;
    int nbox = rmesa->numClipRects;
    drmBufPtr buffer = rmesa->vert_buf;
    int count = rmesa->num_verts;
    int prim = rmesa->hw_primitive;
    int fd = rmesa->driScreen->fd;
-   drmR128Vertex vertex;
+   drm_r128_vertex_t vertex;
    int i;
 
    rmesa->num_verts = 0;
@@ -142,13 +138,13 @@ void r128FlushVerticesLocked( r128ContextPtr rmesa )
       vertex.idx = buffer->idx;
       vertex.count = count;
       vertex.discard = 1;
-      drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(drmR128Vertex) );
+      drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) );
    }
    else
    {
       for ( i = 0 ; i < nbox ; ) {
         int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
         int discard = 0;
 
         rmesa->sarea->nbox = nr - i;
@@ -168,7 +164,7 @@ void r128FlushVerticesLocked( r128ContextPtr rmesa )
          vertex.idx = buffer->idx;
          vertex.count = count;
          vertex.discard = discard;
-         drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(drmR128Vertex) );
+         drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) );
       }
    }
 
@@ -187,7 +183,7 @@ void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
                         GLint offset, GLint pitch, GLint format,
                         GLint x, GLint y, GLint width, GLint height )
 {
-   drmR128Blit blit;
+   drm_r128_blit_t blit;
    GLint ret;
 
    blit.idx = buffer->idx;
@@ -200,7 +196,7 @@ void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
    blit.height = height;
 
    ret = drmCommandWrite( rmesa->driFd, DRM_R128_BLIT, 
-                          &blit, sizeof(drmR128Blit) );
+                          &blit, sizeof(blit) );
 
    if ( ret ) {
       UNLOCK_HARDWARE( rmesa );
@@ -220,6 +216,7 @@ static void delay( void ) {
 
 #define R128_MAX_OUTSTANDING   2
 
+
 /* Throttle the frame rate -- only allow one pending swap buffers
  * request at a time.
  * GH: We probably don't want a timeout here, as we can wait as
@@ -229,12 +226,12 @@ static void delay( void ) {
 static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
 {
    unsigned char *R128MMIO = rmesa->r128Screen->mmio.map;
-   CARD32 frame;
    int i;
    int wait = 0;
 
    while ( 1 ) {
-      frame = INREG( R128_LAST_FRAME_REG );
+      uint32_t frame = read_MMIO_LE32( R128MMIO, R128_LAST_FRAME_REG );
+
       if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) {
         break;
       }
@@ -251,7 +248,7 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
+void r128CopyBuffer( __DRIdrawable *dPriv )
 {
    r128ContextPtr rmesa;
    GLint nbox, i, ret;
@@ -266,7 +263,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
    if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
       fprintf( stderr, "\n********************************\n" );
       fprintf( stderr, "\n%s( %p )\n\n",
-              __FUNCTION__, rmesa->glCtx );
+              __FUNCTION__, (void *)rmesa->glCtx );
       fflush( stderr );
    }
 
@@ -284,19 +281,19 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
    }
 
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+   driWaitForVBlank( dPriv, &missed_target );
    LOCK_HARDWARE( rmesa );
 
    nbox = dPriv->numClipRects; /* must be in locked region */
 
    for ( i = 0 ; i < nbox ; ) {
       GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , nbox );
-      XF86DRIClipRectPtr box = dPriv->pClipRects;
-      XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t *b = rmesa->sarea->boxes;
       GLint n = 0;
 
       for ( ; i < nr ; i++ ) {
-        *b++ = *(XF86DRIClipRectRec *)&box[i];
+        *b++ = box[i];
         n++;
       }
       rmesa->sarea->nbox = n;
@@ -330,7 +327,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
 #endif
 }
 
-void r128PageFlip( const __DRIdrawablePrivate *dPriv )
+void r128PageFlip( __DRIdrawable *dPriv )
 {
    r128ContextPtr rmesa;
    GLint ret;
@@ -344,7 +341,7 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
 
    if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
       fprintf( stderr, "\n%s( %p ): page=%d\n\n",
-              __FUNCTION__, rmesa->glCtx, rmesa->sarea->pfCurrentPage );
+              __FUNCTION__, (void *)rmesa->glCtx, rmesa->sarea->pfCurrentPage );
    }
 
    FLUSH_BATCH( rmesa );
@@ -361,7 +358,7 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+   driWaitForVBlank( dPriv, &missed_target );
    LOCK_HARDWARE( rmesa );
 
    /* The kernel will have been initialized to perform page flipping
@@ -376,16 +373,12 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
       exit( 1 );
    }
 
-   if ( rmesa->sarea->pfCurrentPage == 1 ) {
-        rmesa->drawOffset = rmesa->r128Screen->frontOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->frontPitch;
-   } else {
-        rmesa->drawOffset = rmesa->r128Screen->backOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->backPitch;
-   }
+   /* Get ready for drawing next frame.  Update the renderbuffers'
+    * flippedOffset/Pitch fields so we draw into the right place.
+    */
+   driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
+                        rmesa->sarea->pfCurrentPage);
 
-   rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
-                                     (rmesa->drawOffset >> 5));
    rmesa->new_state |= R128_NEW_WINDOW;
 
    /* FIXME: Do we need this anymore? */
@@ -405,15 +398,16 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
  * Buffer clear
  */
 
-static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
-                        GLint cx, GLint cy, GLint cw, GLint ch )
+static void r128Clear( GLcontext *ctx, GLbitfield mask )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
-   drmR128Clear clear;
+   __DRIdrawable *dPriv = rmesa->driDrawable;
+   drm_r128_clear_t clear;
    GLuint flags = 0;
    GLint i;
    GLint ret;
+   GLuint depthmask = 0;
+   GLint cx, cy, cw, ch;
 
    if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
       fprintf( stderr, "%s:\n", __FUNCTION__ );
@@ -432,36 +426,44 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
       rmesa->new_state = save_state & ~R128_NEW_MASKS;
    }
 
-   if ( mask & DD_FRONT_LEFT_BIT ) {
-      flags |= DRM_R128_FRONT_BUFFER;
-      mask &= ~DD_FRONT_LEFT_BIT;
+   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+      flags |= R128_FRONT;
+      mask &= ~BUFFER_BIT_FRONT_LEFT;
    }
 
-   if ( mask & DD_BACK_LEFT_BIT ) {
-      flags |= DRM_R128_BACK_BUFFER;
-      mask &= ~DD_BACK_LEFT_BIT;
+   if ( mask & BUFFER_BIT_BACK_LEFT ) {
+      flags |= R128_BACK;
+      mask &= ~BUFFER_BIT_BACK_LEFT;
    }
 
-   if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
-      flags |= DRM_R128_DEPTH_BUFFER;
-      mask &= ~DD_DEPTH_BIT;
+   if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
+      flags |= R128_DEPTH;
+      /* if we're at 16 bits, extra plane mask won't hurt */
+      depthmask |= 0x00ffffff;
+      mask &= ~BUFFER_BIT_DEPTH;
    }
-#if 0
-   /* FIXME: Add stencil support */
-   if ( mask & DD_STENCIL_BIT ) {
-      flags |= DRM_R128_DEPTH_BUFFER;
-      mask &= ~DD_STENCIL_BIT;
+
+   if ( mask & BUFFER_BIT_STENCIL &&
+       (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) ) {
+      flags |= R128_DEPTH;
+      depthmask |= ctx->Stencil.WriteMask[0] << 24;
+      mask &= ~BUFFER_BIT_STENCIL;
    }
-#endif
 
    if ( flags ) {
 
+      LOCK_HARDWARE( rmesa );
+
+      /* compute region after locking: */
+      cx = ctx->DrawBuffer->_Xmin;
+      cy = ctx->DrawBuffer->_Ymin;
+      cw = ctx->DrawBuffer->_Xmax - cx;
+      ch = ctx->DrawBuffer->_Ymax - cy;
+
       /* Flip top to bottom */
       cx += dPriv->x;
       cy  = dPriv->y + dPriv->h - cy - ch;
 
-      LOCK_HARDWARE( rmesa );
-
       /* FIXME: Do we actually need this?
        */
       if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) {
@@ -470,11 +472,12 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 
       for ( i = 0 ; i < rmesa->numClipRects ; ) {
         GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects );
-        XF86DRIClipRectPtr box = rmesa->pClipRects;
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *box = rmesa->pClipRects;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
         GLint n = 0;
 
-        if ( !all ) {
+        if (cw != dPriv->w || ch != dPriv->h) {
+            /* clear subregion */
            for ( ; i < nr ; i++ ) {
               GLint x = box[i].x1;
               GLint y = box[i].y1;
@@ -496,8 +499,9 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
               n++;
            }
         } else {
+            /* clear whole window */
            for ( ; i < nr ; i++ ) {
-              *b++ = *(XF86DRIClipRectPtr)&box[i];
+              *b++ = box[i];
               n++;
            }
         }
@@ -517,10 +521,10 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
          clear.clear_color = rmesa->ClearColor;
          clear.clear_depth = rmesa->ClearDepth;
          clear.color_mask = rmesa->setup.plane_3d_mask_c;
-         clear.depth_mask = ~0;
+         clear.depth_mask = depthmask;
 
          ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR,
-                                &clear, sizeof(drmR128Clear) );
+                                &clear, sizeof(clear) );
 
         if ( ret ) {
            UNLOCK_HARDWARE( rmesa );
@@ -535,7 +539,7 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
    }
 
    if ( mask )
-      _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+      _swrast_Clear( ctx, mask );
 }
 
 
@@ -545,11 +549,11 @@ static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 
 void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
                               GLuint n, GLint x, GLint y,
-                              const GLdepth depth[],
+                              const GLuint depth[],
                               const GLubyte mask[] )
 {
-   XF86DRIClipRectPtr pbox = rmesa->pClipRects;
-   drmR128Depth d;
+   drm_clip_rect_t *pbox = rmesa->pClipRects;
+   drm_r128_depth_t d;
    int nbox = rmesa->numClipRects;
    int fd = rmesa->driScreen->fd;
    int i;
@@ -569,21 +573,21 @@ void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
         rmesa->sarea->nbox = nbox;
       }
 
-      d.func = DRM_R128_WRITE_SPAN;
+      d.func = R128_WRITE_SPAN;
       d.n = n;
       d.x = (int*)&x;
       d.y = (int*)&y;
       d.buffer = (unsigned int *)depth;
       d.mask = (unsigned char *)mask;
 
-      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
 
    }
    else
    {
       for (i = 0 ; i < nbox ; ) {
         int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
 
         rmesa->sarea->nbox = nr - i;
         for ( ; i < nr ; i++) {
@@ -592,14 +596,14 @@ void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
 
         rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
 
-         d.func = DRM_R128_WRITE_SPAN;
+         d.func = R128_WRITE_SPAN;
          d.n = n;
          d.x = (int*)&x;
          d.y = (int*)&y;
          d.buffer = (unsigned int *)depth;
          d.mask = (unsigned char *)mask;
 
-         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
       }
    }
 
@@ -608,11 +612,11 @@ void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
 
 void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
                                 const GLint x[], const GLint y[],
-                                const GLdepth depth[],
+                                const GLuint depth[],
                                 const GLubyte mask[] )
 {
-   XF86DRIClipRectPtr pbox = rmesa->pClipRects;
-   drmR128Depth d;
+   drm_clip_rect_t *pbox = rmesa->pClipRects;
+   drm_r128_depth_t d;
    int nbox = rmesa->numClipRects;
    int fd = rmesa->driScreen->fd;
    int i;
@@ -632,20 +636,20 @@ void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
         rmesa->sarea->nbox = nbox;
       }
 
-      d.func = DRM_R128_WRITE_PIXELS;
+      d.func = R128_WRITE_PIXELS;
       d.n = n;
       d.x = (int*)&x;
       d.y = (int*)&y;
       d.buffer = (unsigned int *)depth;
       d.mask = (unsigned char *)mask;
 
-      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
    }
    else
    {
       for (i = 0 ; i < nbox ; ) {
         int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
 
         rmesa->sarea->nbox = nr - i;
         for ( ; i < nr ; i++) {
@@ -654,14 +658,14 @@ void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
 
         rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
 
-         d.func = DRM_R128_WRITE_PIXELS;
+         d.func = R128_WRITE_PIXELS;
          d.n = n;
          d.x = (int*)&x;
          d.y = (int*)&y;
          d.buffer = (unsigned int *)depth;
          d.mask = (unsigned char *)mask;
 
-         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
       }
    }
 
@@ -671,8 +675,8 @@ void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
 void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
                              GLuint n, GLint x, GLint y )
 {
-   XF86DRIClipRectPtr pbox = rmesa->pClipRects;
-   drmR128Depth d;
+   drm_clip_rect_t *pbox = rmesa->pClipRects;
+   drm_r128_depth_t d;
    int nbox = rmesa->numClipRects;
    int fd = rmesa->driScreen->fd;
    int i;
@@ -692,20 +696,20 @@ void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
         rmesa->sarea->nbox = nbox;
       }
 
-      d.func = DRM_R128_READ_SPAN;
+      d.func = R128_READ_SPAN;
       d.n = n;
       d.x = (int*)&x;
       d.y = (int*)&y;
       d.buffer = NULL;
       d.mask = NULL;
 
-      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
    }
    else
    {
       for (i = 0 ; i < nbox ; ) {
         int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
 
         rmesa->sarea->nbox = nr - i;
         for ( ; i < nr ; i++) {
@@ -714,14 +718,14 @@ void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
 
         rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
 
-         d.func = DRM_R128_READ_SPAN;
+         d.func = R128_READ_SPAN;
          d.n = n;
          d.x = (int*)&x;
          d.y = (int*)&y;
          d.buffer = NULL;
          d.mask = NULL;
 
-         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
       }
    }
 
@@ -731,8 +735,8 @@ void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
 void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
                                const GLint x[], const GLint y[] )
 {
-   XF86DRIClipRectPtr pbox = rmesa->pClipRects;
-   drmR128Depth d;
+   drm_clip_rect_t *pbox = rmesa->pClipRects;
+   drm_r128_depth_t d;
    int nbox = rmesa->numClipRects;
    int fd = rmesa->driScreen->fd;
    int i;
@@ -752,20 +756,20 @@ void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
         rmesa->sarea->nbox = nbox;
       }
 
-      d.func = DRM_R128_READ_PIXELS;
+      d.func = R128_READ_PIXELS;
       d.n = n;
       d.x = (int*)&x;
       d.y = (int*)&y;
       d.buffer = NULL;
       d.mask = NULL;
 
-      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+      drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
    }
    else
    {
       for (i = 0 ; i < nbox ; ) {
         int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
-        XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+        drm_clip_rect_t *b = rmesa->sarea->boxes;
 
         rmesa->sarea->nbox = nr - i;
         for ( ; i < nr ; i++) {
@@ -774,14 +778,14 @@ void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
 
         rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
 
-         d.func = DRM_R128_READ_PIXELS;
+         d.func = R128_READ_PIXELS;
          d.n = n;
          d.x = (int*)&x;
          d.y = (int*)&y;
          d.buffer = NULL;
          d.mask = NULL;
 
-         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(drmR128Depth));
+         drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
       }
    }
 
@@ -810,7 +814,7 @@ void r128WaitForIdleLocked( r128ContextPtr rmesa )
     }
 }
 
-void r128DDInitIoctlFuncs( GLcontext *ctx )
+void r128InitIoctlFuncs( struct dd_function_table *functions )
 {
-    ctx->Driver.Clear = r128DDClear;
+    functions->Clear = r128Clear;
 }