summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth Hughes <gareth@users.sourceforge.net>2000-10-11 14:13:44 +0000
committerGareth Hughes <gareth@users.sourceforge.net>2000-10-11 14:13:44 +0000
commitce71d0abb92783b8b6077f42cf261842e06e17f8 (patch)
treeb9119857c70251ab7a7446175768f31b5077ff31
parent4f1b6b9f2bd339d28d1624c3f737ca6183378338 (diff)
- Enable client-side throttling again.
- Work around CCE start/stop/reset issues for now.
-rw-r--r--linux/r128_cce.c15
-rw-r--r--linux/r128_drm.h7
-rw-r--r--linux/r128_drv.h7
-rw-r--r--linux/r128_state.c20
4 files changed, 34 insertions, 15 deletions
diff --git a/linux/r128_cce.c b/linux/r128_cce.c
index cb84b760..a58277bb 100644
--- a/linux/r128_cce.c
+++ b/linux/r128_cce.c
@@ -490,8 +490,11 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
- dev_priv->submit_age = 0;
- R128_WRITE( R128_VB_AGE_REG, dev_priv->submit_age );
+ dev_priv->sarea_priv->last_frame = 0;
+ R128_WRITE( R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame );
+
+ dev_priv->sarea_priv->last_dispatch = 0;
+ R128_WRITE( R128_LAST_VB_REG, dev_priv->sarea_priv->last_dispatch );
r128_cce_init_ring_buffer( dev );
r128_cce_load_microcode( dev_priv );
@@ -555,6 +558,8 @@ int r128_cce_start( struct inode *inode, struct file *filp,
DRM_ERROR( "r128_cce_start called without lock held\n" );
return -EINVAL;
}
+ if ( !dev_priv )
+ return -EINVAL;
if ( dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 )
return 0;
@@ -577,6 +582,8 @@ int r128_cce_stop( struct inode *inode, struct file *filp,
DRM_ERROR( "r128_cce_stop called without lock held\n" );
return -EINVAL;
}
+ if ( !dev_priv )
+ return -EINVAL;
if ( !dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 )
return 0;
@@ -609,6 +616,8 @@ int r128_cce_reset( struct inode *inode, struct file *filp,
DRM_ERROR( "r128_cce_reset called without lock held\n" );
return -EINVAL;
}
+ if ( !dev_priv )
+ return -EINVAL;
if ( !dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 )
return 0;
@@ -686,7 +695,7 @@ drm_buf_t *r128_freelist_get( drm_device_t *dev )
}
for ( t = 0 ; t < dev_priv->usec_timeout ; t++ ) {
- u32 done_age = R128_READ( R128_VB_AGE_REG );
+ u32 done_age = R128_READ( R128_LAST_VB_REG );
for ( i = 0 ; i < dma->buf_count ; i++ ) {
buf = dma->buflist[i];
diff --git a/linux/r128_drm.h b/linux/r128_drm.h
index 8afbdaa3..c67aa8d6 100644
--- a/linux/r128_drm.h
+++ b/linux/r128_drm.h
@@ -134,9 +134,16 @@ typedef struct drm_r128_sarea {
unsigned int vertsize;
unsigned int vc_format;
+ /* The current cliprects, or a subset thereof.
+ */
drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
unsigned int nbox;
+ /* Counters for client-side throttling of rendering clients.
+ */
+ unsigned int last_frame;
+ unsigned int last_dispatch;
+
drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
int tex_age[R128_NR_TEX_HEAPS];
int ctx_owner;
diff --git a/linux/r128_drv.h b/linux/r128_drv.h
index d51f4af0..69240eed 100644
--- a/linux/r128_drv.h
+++ b/linux/r128_drv.h
@@ -63,8 +63,6 @@ typedef struct drm_r128_private {
drm_r128_freelist_t *head;
drm_r128_freelist_t *tail;
- unsigned int submit_age;
-
int usec_timeout;
int is_pci;
@@ -346,8 +344,9 @@ extern int r128_context_switch_complete(drm_device_t *dev, int new);
#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
-#define R128_MAX_VB_AGE 0xffffffff
-#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0
+#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0
+#define R128_LAST_VB_REG R128_GUI_SCRATCH_REG1
+#define R128_MAX_VB_AGE 0xffffffff
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
diff --git a/linux/r128_state.c b/linux/r128_state.c
index 4b0e7a9c..1e080840 100644
--- a/linux/r128_state.c
+++ b/linux/r128_state.c
@@ -477,14 +477,18 @@ static void r128_cce_dispatch_swap( drm_device_t *dev )
ADVANCE_RING();
}
-#if 0
+ /* Increment the frame counter. The client-side 3D driver must
+ * throttle the framerate by waiting for this value before
+ * performing the swapbuffer ioctl.
+ */
+ dev_priv->sarea_priv->last_frame++;
+
BEGIN_RING( 2 );
- OUT_RING( CCE_PACKET0( R128_SWAP_AGE_REG, 0 ) );
- OUT_RING( r128ctx->lastSwapAge );
+ OUT_RING( CCE_PACKET0( R128_LAST_FRAME_REG, 0 ) );
+ OUT_RING( dev_priv->sarea_priv->last_frame );
ADVANCE_RING();
-#endif
}
static void r128_cce_dispatch_vertex( drm_device_t *dev,
@@ -552,8 +556,8 @@ static void r128_cce_dispatch_vertex( drm_device_t *dev,
/* Emit the vertex buffer age */
BEGIN_RING( 2 );
- OUT_RING( CCE_PACKET0( R128_VB_AGE_REG, 0 ) );
- OUT_RING( dev_priv->submit_age );
+ OUT_RING( CCE_PACKET0( R128_LAST_VB_REG, 0 ) );
+ OUT_RING( dev_priv->sarea_priv->last_dispatch );
ADVANCE_RING();
@@ -561,10 +565,10 @@ static void r128_cce_dispatch_vertex( drm_device_t *dev,
/* FIXME: Check dispatched field */
buf_priv->dispatched = 0;
- buf_priv->age = dev_priv->submit_age;
+ buf_priv->age = dev_priv->sarea_priv->last_dispatch;
}
- dev_priv->submit_age++;
+ dev_priv->sarea_priv->last_dispatch++;
#if 0
if ( dev_priv->submit_age == R128_MAX_VB_AGE ) {