switch to X86_SOURCES
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_ioctl.c
index a388720aba11e4bc287623b453e5c45ef297c99e..c5707a02807752810d4b22bb1ba3c54bde2e2ed9 100644 (file)
@@ -34,8 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Gareth Hughes <gareth@valinux.com>
  *   Keith Whitwell <keith@tungstengraphics.com>
  */
+
 #include <sched.h>
-#include <errno.h>
+#include <errno.h> 
 
 #include "glheader.h"
 #include "imports.h"
@@ -48,6 +49,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_tcl.h"
 #include "radeon_sanity.h"
 
+#define STANDALONE_MMIO
 #include "radeon_macros.h"  /* for INREG() */
 
 #include "vblank.h"
@@ -79,30 +81,21 @@ static void radeon_emit_state_list( radeonContextPtr rmesa,
 {
    struct radeon_state_atom *state, *tmp;
    char *dest;
-
-   /* From Felix Kuhling: similar to some other lockups, glaxium will
-    * lock with what we believe to be a normal command stream, but
-    * sprinkling some magic waits arounds allows it to run
-    * uninterrupted.  This has a slight effect on q3 framerates, but
-    * it might now be possible to remove the zbs hack, below.
-    *
-    * Felix reports that this can be narrowed down to just
-    * tcl,tex0,tex1 state, but that's pretty much every statechange,
-    * so let's just put the wait in always (unless Felix wants to
-    * narrow it down further...)
+   int i, size, texunits;
+
+   /* It appears that some permutations of state atoms lock up the
+    * chip.  Therefore we make sure that state atoms are emitted in a
+    * fixed order. First mark all dirty state atoms and then go
+    * through all state atoms in a well defined order and emit only
+    * the marked ones.
+    * FIXME: This requires knowledge of which state atoms exist.
+    * FIXME: Is the zbs hack below still needed?
     */
-   if (1) {
-      drmRadeonCmdHeader *cmd;
-      cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, sizeof(*cmd), 
-                                                    __FUNCTION__ );
-      cmd->wait.cmd_type = RADEON_CMD_WAIT;
-      cmd->wait.flags = RADEON_WAIT_3D;
-   }
-
+   size = 0;
    foreach_s( state, tmp, list ) {
       if (state->check( rmesa->glCtx )) {
-        dest = radeonAllocCmdBuf( rmesa, state->cmd_size * 4, __FUNCTION__);
-        memcpy( dest, state->cmd, state->cmd_size * 4);
+        size += state->cmd_size;
+        state->dirty = GL_TRUE;
         move_to_head( &(rmesa->hw.clean), state );
         if (RADEON_DEBUG & DEBUG_STATE) 
            print_state_atom( state );
@@ -110,6 +103,47 @@ static void radeon_emit_state_list( radeonContextPtr rmesa,
       else if (RADEON_DEBUG & DEBUG_STATE)
         fprintf(stderr, "skip state %s\n", state->name);
    }
+   /* short cut */
+   if (!size)
+       return;
+
+   dest = radeonAllocCmdBuf( rmesa, size * 4, __FUNCTION__);
+   texunits = rmesa->glCtx->Const.MaxTextureUnits;
+
+#define EMIT_ATOM(ATOM) \
+do { \
+   if (rmesa->hw.ATOM.dirty) { \
+      rmesa->hw.ATOM.dirty = GL_FALSE; \
+      memcpy( dest, rmesa->hw.ATOM.cmd, rmesa->hw.ATOM.cmd_size * 4); \
+      dest += rmesa->hw.ATOM.cmd_size * 4; \
+   } \
+} while (0)
+
+   EMIT_ATOM (ctx);
+   EMIT_ATOM (set);
+   EMIT_ATOM (lin);
+   EMIT_ATOM (msk);
+   EMIT_ATOM (vpt);
+   EMIT_ATOM (tcl);
+   EMIT_ATOM (msc);
+   for (i = 0; i < texunits; ++i) {
+       EMIT_ATOM (tex[i]);
+       EMIT_ATOM (txr[i]);
+   }
+   EMIT_ATOM (zbs);
+   EMIT_ATOM (mtl);
+   for (i = 0; i < 3 + texunits; ++i)
+       EMIT_ATOM (mat[i]);
+   for (i = 0; i < 8; ++i)
+       EMIT_ATOM (lit[i]);
+   for (i = 0; i < 6; ++i)
+       EMIT_ATOM (ucp[i]);
+   EMIT_ATOM (eye);
+   EMIT_ATOM (grd);
+   EMIT_ATOM (fog);
+   EMIT_ATOM (glt);
+
+#undef EMIT_ATOM
 }
 
 
@@ -159,10 +193,9 @@ extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
                                GLuint primitive,
                                GLuint vertex_nr )
 {
-   drmRadeonCmdHeader *cmd;
+   drm_radeon_cmd_header_t *cmd;
 
 
-   assert(rmesa->dri.drmMinor >= 3); 
    assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
    
    radeonEmitState( rmesa );
@@ -172,7 +205,7 @@ extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
              rmesa->store.cmd_used/4);
    
 #if RADEON_OLD_PACKETS
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 6 * sizeof(*cmd),
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 6 * sizeof(*cmd),
                                                  __FUNCTION__ );
    cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
    cmd[1].i = RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM | (3 << 16);
@@ -190,7 +223,7 @@ extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
              __FUNCTION__,
              cmd[1].i, cmd[2].i, cmd[4].i, cmd[5].i);
 #else
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 4 * sizeof(*cmd),
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 4 * sizeof(*cmd),
                                                  __FUNCTION__ );
    cmd[0].i = 0;
    cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
@@ -248,19 +281,18 @@ GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
                                    GLuint primitive,
                                    GLuint min_nr )
 {
-   drmRadeonCmdHeader *cmd;
+   drm_radeon_cmd_header_t *cmd;
    GLushort *retval;
 
    if (RADEON_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s %d\n", __FUNCTION__, min_nr);
 
-   assert(rmesa->dri.drmMinor >= 3); 
    assert((primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
    
    radeonEmitState( rmesa );
    
 #if RADEON_OLD_PACKETS
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 
                                                  24 + min_nr*2,
                                                  __FUNCTION__ );
    cmd[0].i = 0;
@@ -276,7 +308,7 @@ GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
 
    retval = (GLushort *)(cmd+6);
 #else   
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 
                                                  16 + min_nr*2,
                                                  __FUNCTION__ );
    cmd[0].i = 0;
@@ -316,14 +348,13 @@ void radeonEmitVertexAOS( radeonContextPtr rmesa,
    rmesa->ioctl.vertex_size = vertex_size;
    rmesa->ioctl.vertex_offset = offset;
 #else
-   drmRadeonCmdHeader *cmd;
-   assert(rmesa->dri.drmMinor >= 3); 
+   drm_radeon_cmd_header_t *cmd;
 
    if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
       fprintf(stderr, "%s:  vertex_size 0x%x offset 0x%x \n",
              __FUNCTION__, vertex_size, offset);
 
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 5 * sizeof(int),
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 5 * sizeof(int),
                                                  __FUNCTION__ );
 
    cmd[0].i = 0;
@@ -348,7 +379,7 @@ void radeonEmitAOS( radeonContextPtr rmesa,
    rmesa->ioctl.vertex_offset = 
       (component[0]->aos_start + offset * component[0]->aos_stride * 4);
 #else
-   drmRadeonCmdHeader *cmd;
+   drm_radeon_cmd_header_t *cmd;
    int sz = 3 + (nr/2 * 3) + (nr & 1) * 2;
    int i;
    int *tmp;
@@ -356,9 +387,8 @@ void radeonEmitAOS( radeonContextPtr rmesa,
    if (RADEON_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-   assert(rmesa->dri.drmMinor >= 3); 
 
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, sz * sizeof(int),
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sz * sizeof(int),
                                                  __FUNCTION__ );
    cmd[0].i = 0;
    cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
@@ -402,7 +432,7 @@ void radeonEmitBlit( radeonContextPtr rmesa, /* FIXME: which drmMinor is require
                   GLint dstx, GLint dsty,
                   GLuint w, GLuint h )
 {
-   drmRadeonCmdHeader *cmd;
+   drm_radeon_cmd_header_t *cmd;
 
    if (RADEON_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
@@ -418,7 +448,7 @@ void radeonEmitBlit( radeonContextPtr rmesa, /* FIXME: which drmMinor is require
    assert( w < (1<<16) );
    assert( h < (1<<16) );
 
-   cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 8 * sizeof(int),
+   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 8 * sizeof(int),
                                                  __FUNCTION__ );
 
 
@@ -446,11 +476,11 @@ void radeonEmitBlit( radeonContextPtr rmesa, /* FIXME: which drmMinor is require
 void radeonEmitWait( radeonContextPtr rmesa, GLuint flags )
 {
    if (rmesa->dri.drmMinor >= 6) {
-      drmRadeonCmdHeader *cmd;
+      drm_radeon_cmd_header_t *cmd;
 
       assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
       
-      cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, 1 * sizeof(int),
+      cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 1 * sizeof(int),
                                                   __FUNCTION__ );
       cmd[0].i = 0;
       cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
@@ -463,7 +493,7 @@ static int radeonFlushCmdBufLocked( radeonContextPtr rmesa,
                                    const char * caller )
 {
    int ret, i;
-   drmRadeonCmdBuffer cmd;
+   drm_radeon_cmd_buffer_t cmd;
 
    if (RADEON_DEBUG & DEBUG_IOCTL) {
       fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); 
@@ -500,10 +530,10 @@ static int radeonFlushCmdBufLocked( radeonContextPtr rmesa,
 
    if (rmesa->state.scissor.enabled) {
       cmd.nbox = rmesa->state.scissor.numClipRects;
-      cmd.boxes = (drmClipRect *)rmesa->state.scissor.pClipRects;
+      cmd.boxes = rmesa->state.scissor.pClipRects;
    } else {
       cmd.nbox = rmesa->numClipRects;
-      cmd.boxes = (drmClipRect *)rmesa->pClipRects;
+      cmd.boxes = rmesa->pClipRects;
    }
 
    ret = drmCommandWrite( rmesa->dri.fd,
@@ -531,8 +561,6 @@ void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller )
    int ret;
 
              
-   assert (rmesa->dri.drmMinor >= 3);
-
    LOCK_HARDWARE( rmesa );
 
    ret = radeonFlushCmdBufLocked( rmesa, caller );
@@ -540,7 +568,7 @@ void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller )
    UNLOCK_HARDWARE( rmesa );
 
    if (ret) {
-      fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
+      fprintf(stderr, "drm_radeon_cmd_buffer_t: %d (exiting)\n", ret);
       exit(ret);
    }
 }
@@ -639,13 +667,13 @@ void radeonReleaseDmaRegion( radeonContextPtr rmesa,
       rmesa->dma.flush( rmesa );
 
    if (--region->buf->refcount == 0) {
-      drmRadeonCmdHeader *cmd;
+      drm_radeon_cmd_header_t *cmd;
 
       if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
         fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
                 region->buf->buf->idx);  
       
-      cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, sizeof(*cmd), 
+      cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sizeof(*cmd), 
                                                     __FUNCTION__ );
       cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
       cmd->dma.buf_idx = region->buf->buf->idx;
@@ -691,9 +719,6 @@ void radeonAllocDmaRegion( radeonContextPtr rmesa,
    rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
    rmesa->dma.current.start = 
       rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;  
-
-   if ( rmesa->dri.drmMinor < 3 ) 
-      radeonRefillCurrentDmaRegion( rmesa );
 }
 
 void radeonAllocDmaRegionVerts( radeonContextPtr rmesa, 
@@ -709,31 +734,29 @@ void radeonAllocDmaRegionVerts( radeonContextPtr rmesa,
  * SwapBuffers with client-side throttling
  */
 
-static CARD32 radeonGetLastFrame (radeonContextPtr rmesa) 
+static uint32_t radeonGetLastFrame (radeonContextPtr rmesa) 
 {
    unsigned char *RADEONMMIO = rmesa->radeonScreen->mmio.map;
    int ret;
-   CARD32 frame;
+   uint32_t frame;
 
    if (rmesa->dri.screen->drmMinor >= 4) {
-      drmRadeonGetParam gp;
+      drm_radeon_getparam_t gp;
 
       gp.param = RADEON_PARAM_LAST_FRAME;
-      gp.value = &frame;
+      gp.value = (int *)&frame;
       ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
                                 &gp, sizeof(gp) );
    } 
    else
       ret = -EINVAL;
 
-#ifndef __alpha__
    if ( ret == -EINVAL ) {
       frame = INREG( RADEON_LAST_FRAME_REG );
       ret = 0;
    } 
-#endif
    if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
+      fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
       exit(1);
    }
 
@@ -742,14 +765,14 @@ static CARD32 radeonGetLastFrame (radeonContextPtr rmesa)
 
 static void radeonEmitIrqLocked( radeonContextPtr rmesa )
 {
-   drmRadeonIrqEmit ie;
+   drm_radeon_irq_emit_t ie;
    int ret;
 
    ie.irq_seq = &rmesa->iw.irq_seq;
    ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT, 
                              &ie, sizeof(ie) );
    if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__, ret );
+      fprintf( stderr, "%s: drm_radeon_irq_emit_t: %d\n", __FUNCTION__, ret );
       exit(1);
    }
 }
@@ -773,7 +796,7 @@ static void radeonWaitIrq( radeonContextPtr rmesa )
 
 static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
 {
-   RADEONSAREAPrivPtr sarea = rmesa->sarea;
+   drm_radeon_sarea_t *sarea = rmesa->sarea;
 
    if (rmesa->do_irqs) {
       if (radeonGetLastFrame(rmesa) < sarea->last_frame) {
@@ -811,7 +834,7 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
    radeonContextPtr rmesa;
    GLint nbox, i, ret;
    GLboolean   missed_target;
-   uint64_t     ust;
+   int64_t ust;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -820,7 +843,7 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
    rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
 
    if ( RADEON_DEBUG & DEBUG_IOCTL ) {
-      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, rmesa->glCtx );
+      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
    }
 
    RADEON_FIREVERTICES( rmesa );
@@ -838,8 +861,8 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
 
    for ( i = 0 ; i < nbox ; ) {
       GLint nr = MIN2( i + RADEON_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++ ) {
@@ -892,8 +915,8 @@ void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
     */
    if (dPriv->numClipRects)
    {
-      XF86DRIClipRectPtr box = dPriv->pClipRects;
-      XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t *b = rmesa->sarea->boxes;
       b[0] = box[0];
       rmesa->sarea->nbox = 1;
    }
@@ -931,7 +954,8 @@ void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    RADEON_STATECHANGE( rmesa, ctx );
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset;
+   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+                                          + rmesa->radeonScreen->fbLocation;
    rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH]  = rmesa->state.color.drawPitch;
 }
 
@@ -946,9 +970,9 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 {
    radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   RADEONSAREAPrivPtr sarea = rmesa->sarea;
+   drm_radeon_sarea_t *sarea = rmesa->sarea;
    unsigned char *RADEONMMIO = rmesa->radeonScreen->mmio.map;
-   CARD32 clear;
+   uint32_t clear;
    GLuint flags = 0;
    GLuint color_mask = 0;
    GLint ret, i;
@@ -1009,23 +1033,21 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
       int ret;
 
       if (rmesa->dri.screen->drmMinor >= 4) {
-       drmRadeonGetParam gp;
+       drm_radeon_getparam_t gp;
 
        gp.param = RADEON_PARAM_LAST_CLEAR;
-       gp.value = &clear;
+       gp.value = (int *)&clear;
        ret = drmCommandWriteRead( rmesa->dri.fd,
                                   DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
       } else
        ret = -EINVAL;
 
-#ifndef __alpha__
       if ( ret == -EINVAL ) {
         clear = INREG( RADEON_LAST_CLEAR_REG );
         ret = 0;
       }
-#endif
       if ( ret ) {
-        fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
+        fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
         exit(1);
       }
       if ( RADEON_DEBUG & DEBUG_IOCTL ) {
@@ -1046,10 +1068,10 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 
    for ( i = 0 ; i < dPriv->numClipRects ; ) {
       GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
-      XF86DRIClipRectPtr box = dPriv->pClipRects;
-      XF86DRIClipRectPtr b = rmesa->sarea->boxes;
-      drmRadeonClearType clear;
-      drmRadeonClearRect depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t *b = rmesa->sarea->boxes;
+      drm_radeon_clear_t clear;
+      drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
       GLint n = 0;
 
       if ( !all ) {
@@ -1092,16 +1114,16 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
       n--;
       b = rmesa->sarea->boxes;
       for ( ; n >= 0 ; n-- ) {
-        depth_boxes[n].f[RADEON_CLEAR_X1] = (float)b[n].x1;
-        depth_boxes[n].f[RADEON_CLEAR_Y1] = (float)b[n].y1;
-        depth_boxes[n].f[RADEON_CLEAR_X2] = (float)b[n].x2;
-        depth_boxes[n].f[RADEON_CLEAR_Y2] = (float)b[n].y2;
-        depth_boxes[n].f[RADEON_CLEAR_DEPTH] = 
+        depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
+        depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
+        depth_boxes[n].f[CLEAR_X2] = (float)b[n].x2;
+        depth_boxes[n].f[CLEAR_Y2] = (float)b[n].y2;
+        depth_boxes[n].f[CLEAR_DEPTH] = 
            (float)rmesa->state.depth.clear;
       }
 
       ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
-                            &clear, sizeof(drmRadeonClearType));
+                            &clear, sizeof(drm_radeon_clear_t));
 
       if ( ret ) {
         UNLOCK_HARDWARE( rmesa );
@@ -1154,13 +1176,11 @@ void radeonFlush( GLcontext *ctx )
    if (rmesa->dma.flush)
       rmesa->dma.flush( rmesa );
 
-   if (rmesa->dri.drmMinor >= 3) {
-      if (!is_empty_list(&rmesa->hw.dirty)) 
-        radeonEmitState( rmesa );
+   if (!is_empty_list(&rmesa->hw.dirty)) 
+      radeonEmitState( rmesa );
    
-      if (rmesa->store.cmd_used)
-        radeonFlushCmdBuf( rmesa, __FUNCTION__ );
-   }
+   if (rmesa->store.cmd_used)
+      radeonFlushCmdBuf( rmesa, __FUNCTION__ );
 }
 
 /* Make sure all commands have been sent to the hardware and have