summaryrefslogtreecommitdiff
path: root/shared-core
diff options
context:
space:
mode:
Diffstat (limited to 'shared-core')
-rw-r--r--shared-core/i915_dma.c31
-rw-r--r--shared-core/mach64_dma.c38
-rw-r--r--shared-core/mach64_drv.h4
-rw-r--r--shared-core/mga_dma.c46
-rw-r--r--shared-core/r128_cce.c31
-rw-r--r--shared-core/r128_drv.h1
-rw-r--r--shared-core/r128_state.c30
-rw-r--r--shared-core/radeon_cp.c56
-rw-r--r--shared-core/radeon_drv.h9
-rw-r--r--shared-core/radeon_state.c49
-rw-r--r--shared-core/sis_drv.h2
-rw-r--r--shared-core/sis_mm.c10
-rw-r--r--shared-core/via_drv.c1
-rw-r--r--shared-core/via_drv.h1
-rw-r--r--shared-core/via_map.c4
-rw-r--r--shared-core/via_mm.c10
16 files changed, 224 insertions, 99 deletions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index fc1b356f..72573cbb 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -94,7 +94,7 @@ int i915_dma_cleanup(drm_device_t *dev)
(drm_i915_private_t *) dev->dev_private;
if (dev_priv->ring.virtual_start) {
- DRM_IOREMAPFREE( &dev_priv->ring.map, dev);
+ drm_core_ioremapfree( &dev_priv->ring.map, dev);
}
if (dev_priv->hw_status_page) {
@@ -135,8 +135,8 @@ static int i915_initialize(drm_device_t *dev,
i915_dma_cleanup(dev);
return DRM_ERR(EINVAL);
}
-
- DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset );
+
+ dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset);
if(!dev_priv->mmio_map) {
dev->dev_private = (void *)dev_priv;
i915_dma_cleanup(dev);
@@ -159,7 +159,7 @@ static int i915_initialize(drm_device_t *dev,
dev_priv->ring.map.flags = 0;
dev_priv->ring.map.mtrr = 0;
- DRM_IOREMAP( &dev_priv->ring.map, dev );
+ drm_core_ioremap( &dev_priv->ring.map, dev );
if (dev_priv->ring.map.handle == NULL) {
dev->dev_private = (void *) dev_priv;
@@ -770,3 +770,26 @@ int i915_setparam( DRM_IOCTL_ARGS )
return 0;
}
+
+static void i915_driver_pretakedown(drm_device_t *dev)
+{
+ if ( dev->dev_private ) {
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ i915_mem_takedown( &(dev_priv->agp_heap) );
+ }
+ i915_dma_cleanup( dev );
+}
+
+static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+{
+ if ( dev->dev_private ) {
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ i915_mem_release( dev, filp, dev_priv->agp_heap );
+ }
+}
+
+void i915_driver_register_fns(drm_device_t *dev)
+{
+ dev->fn_tbl.pretakedown = i915_driver_pretakedown;
+ dev->fn_tbl.prerelease = i915_driver_prerelease;
+}
diff --git a/shared-core/mach64_dma.c b/shared-core/mach64_dma.c
index 60663422..0acb784d 100644
--- a/shared-core/mach64_dma.c
+++ b/shared-core/mach64_dma.c
@@ -655,14 +655,14 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
mach64_do_cleanup_dma(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
+ dev_priv->fb = drm_core_findmap(dev, init->fb_offset);
if (!dev_priv->fb) {
DRM_ERROR("can not find frame buffer map!\n");
dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
+ dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if (!dev_priv->mmio) {
DRM_ERROR("can not find mmio map!\n");
dev->dev_private = (void *)dev_priv;
@@ -675,14 +675,14 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
init->sarea_priv_offset);
if( !dev_priv->is_pci ) {
- DRM_FIND_MAP( dev_priv->ring_map, init->ring_offset );
+ dev_priv->ring_map = drm_core_findmap(dev, init->ring_offset);
if ( !dev_priv->ring_map ) {
DRM_ERROR( "can not find ring map!\n" );
dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return DRM_ERR(EINVAL);
}
- DRM_IOREMAP( dev_priv->ring_map, dev );
+ drm_core_ioremap( dev_priv->ring_map, dev );
if ( !dev_priv->ring_map->handle ) {
DRM_ERROR( "can not ioremap virtual address for"
" descriptor ring\n" );
@@ -690,23 +690,26 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
mach64_do_cleanup_dma( dev );
return DRM_ERR(ENOMEM);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if ( !dev_priv->buffers ) {
+ dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
+ if ( !dev->agp_buffer_map ) {
DRM_ERROR( "can not find dma buffer map!\n" );
dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_IOREMAP( dev_priv->buffers, dev );
- if ( !dev_priv->buffers->handle ) {
+ /* there might be a nicer way to do this -
+ dev isn't passed all the way though the mach64 - DA */
+ dev_priv->dev_buffers = dev->agp_buffer_map;
+
+ drm_core_ioremap( dev->agp_buffer_map, dev );
+ if ( !dev->agp_buffer_map->handle ) {
DRM_ERROR( "can not ioremap virtual address for"
" dma buffer\n" );
dev->dev_private = (void *) dev_priv;
mach64_do_cleanup_dma( dev );
return DRM_ERR(ENOMEM);
}
- DRM_FIND_MAP( dev_priv->agp_textures,
- init->agp_textures_offset );
+ dev_priv->agp_textures = drm_core_findmap(dev, init->agp_textures_offset);
if (!dev_priv->agp_textures) {
DRM_ERROR( "can not find agp texture region!\n" );
dev->dev_private = (void *)dev_priv;
@@ -987,11 +990,11 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
}
} else {
if ( dev_priv->ring_map )
- DRM_IOREMAPFREE( dev_priv->ring_map, dev );
+ drm_core_ioremapfree( dev_priv->ring_map, dev );
}
- if ( dev_priv->buffers )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map )
+ drm_core_ioremapfree( dev->agp_buffer_map, dev );
mach64_destroy_freelist( dev );
@@ -1323,3 +1326,12 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
+static void mach64_driver_pretakedown(drm_device_t *dev)
+{
+ mach64_do_cleanup_dma( dev );
+}
+
+void mach64_driver_register_fns(drm_device_t *dev)
+{
+ dev->fn_tbl.pretakedown = mach64_driver_pretakedown;
+}
diff --git a/shared-core/mach64_drv.h b/shared-core/mach64_drv.h
index 4331cde5..d009d29e 100644
--- a/shared-core/mach64_drv.h
+++ b/shared-core/mach64_drv.h
@@ -92,7 +92,7 @@ typedef struct drm_mach64_private {
drm_local_map_t *fb;
drm_local_map_t *mmio;
drm_local_map_t *ring_map;
- drm_local_map_t *buffers;
+ drm_local_map_t *dev_buffers; /* this is a pointer to a structure in dev */
drm_local_map_t *agp_textures;
} drm_mach64_private_t;
@@ -791,7 +791,7 @@ do { \
#define GETBUFPTR( __buf ) \
((dev_priv->is_pci) ? \
((u32 *)(__buf)->address) : \
- ((u32 *)((char *)dev_priv->buffers->handle + (__buf)->offset)))
+ ((u32 *)((char *)dev_priv->dev_buffers->handle + (__buf)->offset)))
#define GETBUFADDR( __buf ) ((u32)(__buf)->bus_address)
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c
index 76fbf714..4a38b7d9 100644
--- a/shared-core/mga_dma.c
+++ b/shared-core/mga_dma.c
@@ -500,7 +500,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
+ dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if(!dev_priv->mmio) {
DRM_ERROR( "failed to find mmio region!\n" );
/* Assign dev_private so we can do cleanup. */
@@ -508,7 +508,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->status, init->status_offset );
+ dev_priv->status = drm_core_findmap(dev, init->status_offset);
if(!dev_priv->status) {
DRM_ERROR( "failed to find status page!\n" );
/* Assign dev_private so we can do cleanup. */
@@ -516,8 +516,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
-
- DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
+ dev_priv->warp = drm_core_findmap(dev, init->warp_offset);
if(!dev_priv->warp) {
DRM_ERROR( "failed to find warp microcode region!\n" );
/* Assign dev_private so we can do cleanup. */
@@ -525,7 +524,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->primary, init->primary_offset );
+ dev_priv->primary = drm_core_findmap(dev, init->primary_offset);
if(!dev_priv->primary) {
DRM_ERROR( "failed to find primary dma region!\n" );
/* Assign dev_private so we can do cleanup. */
@@ -533,8 +532,8 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
+ if(!dev->agp_buffer_map) {
DRM_ERROR( "failed to find dma buffer region!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -546,13 +545,13 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
(drm_mga_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
- DRM_IOREMAP( dev_priv->warp, dev );
- DRM_IOREMAP( dev_priv->primary, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ drm_core_ioremap( dev_priv->warp, dev );
+ drm_core_ioremap( dev_priv->primary, dev );
+ drm_core_ioremap( dev->agp_buffer_map, dev );
if(!dev_priv->warp->handle ||
!dev_priv->primary->handle ||
- !dev_priv->buffers->handle ) {
+ !dev->agp_buffer_map->handle ) {
DRM_ERROR( "failed to ioremap agp regions!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -643,11 +642,11 @@ int mga_do_cleanup_dma( drm_device_t *dev )
drm_mga_private_t *dev_priv = dev->dev_private;
if ( dev_priv->warp != NULL )
- DRM_IOREMAPFREE( dev_priv->warp, dev );
+ drm_core_ioremapfree( dev_priv->warp, dev );
if ( dev_priv->primary != NULL )
- DRM_IOREMAPFREE( dev_priv->primary, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ drm_core_ioremapfree( dev_priv->primary, dev );
+ if ( dev->agp_buffer_map != NULL )
+ drm_core_ioremapfree( dev->agp_buffer_map, dev );
if ( dev_priv->head != NULL ) {
mga_freelist_cleanup( dev );
@@ -800,3 +799,20 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
+
+static void mga_driver_pretakedown(drm_device_t *dev)
+{
+ mga_do_cleanup_dma( dev );
+}
+
+static int mga_driver_dma_quiescent(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ return mga_do_wait_for_idle( dev_priv );
+}
+
+void mga_driver_register_fns(drm_device_t *dev)
+{
+ dev->fn_tbl.pretakedown = mga_driver_pretakedown;
+ dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
+}
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index 22d38b70..43fa9b51 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -467,29 +467,29 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
+ dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->cce_ring, init->ring_offset );
+ dev_priv->cce_ring = drm_core_findmap(dev, init->ring_offset);
if(!dev_priv->cce_ring) {
DRM_ERROR("could not find cce ring region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
+ dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset);
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -497,8 +497,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
}
if ( !dev_priv->is_pci ) {
- DRM_FIND_MAP( dev_priv->agp_textures,
- init->agp_textures_offset );
+ dev_priv->agp_textures = drm_core_findmap(dev, init->agp_textures_offset);
if(!dev_priv->agp_textures) {
DRM_ERROR("could not find agp texture region!\n");
dev->dev_private = (void *)dev_priv;
@@ -513,12 +512,12 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
#if __REALLY_HAVE_AGP
if ( !dev_priv->is_pci ) {
- DRM_IOREMAP( dev_priv->cce_ring, dev );
- DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ drm_core_ioremap( dev_priv->cce_ring, dev );
+ drm_core_ioremap( dev_priv->ring_rptr, dev );
+ drm_core_ioremap( dev->agp_buffer_map, dev );
if(!dev_priv->cce_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("Could not ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -531,7 +530,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(void *)dev_priv->cce_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
}
#if __REALLY_HAVE_AGP
@@ -601,11 +600,11 @@ int r128_do_cleanup_cce( drm_device_t *dev )
#if __REALLY_HAVE_AGP
if ( !dev_priv->is_pci ) {
if ( dev_priv->cce_ring != NULL )
- DRM_IOREMAPFREE( dev_priv->cce_ring, dev );
+ drm_core_ioremapfree( dev_priv->cce_ring, dev );
if ( dev_priv->ring_rptr != NULL )
- DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ drm_core_ioremapfree( dev_priv->ring_rptr, dev );
+ if ( dev->agp_buffer_map != NULL )
+ drm_core_ioremapfree( dev->agp_buffer_map, dev );
} else
#endif
{
diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h
index 9df32e56..12ca9b4f 100644
--- a/shared-core/r128_drv.h
+++ b/shared-core/r128_drv.h
@@ -100,7 +100,6 @@ typedef struct drm_r128_private {
drm_local_map_t *mmio;
drm_local_map_t *cce_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *agp_textures;
} drm_r128_private_t;
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index 34ebcae1..88d7715a 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -667,7 +667,7 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = cpu_to_le32( R128_CCE_PACKET2 );
}
@@ -713,7 +713,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
drm_r128_buf_priv_t *buf_priv = buf->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
int format = sarea_priv->vc_format;
- int offset = dev_priv->buffers->offset - dev_priv->cce_buffers_offset;
+ int offset = dev->agp_buffer_map->offset - dev_priv->cce_buffers_offset;
int prim = buf_priv->prim;
u32 *data;
int dwords;
@@ -733,7 +733,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
dwords = (end - start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle
+ data = (u32 *)((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[0] = cpu_to_le32( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM,
@@ -857,7 +857,7 @@ static int r128_cce_dispatch_blit( DRMFILE filp,
dwords = (blit->width * blit->height) >> dword_shift;
- data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
+ data = (u32 *)((char *)dev->agp_buffer_map->handle + buf->offset);
data[0] = cpu_to_le32( CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ) );
data[1] = cpu_to_le32( (R128_GMC_DST_PITCH_OFFSET_CNTL |
@@ -1694,3 +1694,25 @@ int r128_getparam( DRM_IOCTL_ARGS )
return 0;
}
+
+static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+{
+ if ( dev->dev_private ) {
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ if ( dev_priv->page_flipping ) {
+ r128_do_cleanup_pageflip( dev );
+ }
+ }
+}
+
+static void r128_driver_pretakedown(drm_device_t *dev)
+{
+ r128_do_cleanup_cce( dev );
+}
+
+void r128_driver_register_fns(drm_device_t *dev)
+{
+ dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ dev->fn_tbl.prerelease = r128_driver_prerelease;
+ dev->fn_tbl.pretakedown = r128_driver_pretakedown;
+}
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c
index 4efb6c2a..f634a345 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -1108,33 +1108,33 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
+ dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->cp_ring, init->ring_offset );
+ dev_priv->cp_ring = drm_core_findmap(dev, init->ring_offset);
if(!dev_priv->cp_ring) {
DRM_ERROR("could not find cp ring region!\n");
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
+ dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset);
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
if ( init->gart_textures_offset ) {
- DRM_FIND_MAP( dev_priv->gart_textures, init->gart_textures_offset );
+ dev_priv->gart_textures = drm_core_findmap(dev, init->gart_textures_offset);
if ( !dev_priv->gart_textures ) {
DRM_ERROR("could not find GART texture region!\n");
radeon_do_cleanup_cp(dev);
@@ -1147,13 +1147,13 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
init->sarea_priv_offset);
#if __REALLY_HAVE_AGP
- if (dev_priv->flags & CHIP_IS_AGP) {
- DRM_IOREMAP( dev_priv->cp_ring, dev );
- DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ if ( dev_priv->flags & CHIP_IS_AGP ) {
+ drm_core_ioremap( dev_priv->cp_ring, dev );
+ drm_core_ioremap( dev_priv->ring_rptr, dev );
+ drm_core_ioremap( dev->agp_buffer_map, dev );
if(!dev_priv->cp_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("could not find ioremap agp regions!\n");
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
@@ -1165,14 +1165,14 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(void *)dev_priv->cp_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
DRM_DEBUG( "dev_priv->cp_ring->handle %p\n",
dev_priv->cp_ring->handle );
DRM_DEBUG( "dev_priv->ring_rptr->handle %p\n",
dev_priv->ring_rptr->handle );
- DRM_DEBUG( "dev_priv->buffers->handle %p\n",
- dev_priv->buffers->handle );
+ DRM_DEBUG( "dev->agp_buffer_map->handle %p\n",
+ dev->agp_buffer_map->handle );
}
dev_priv->fb_location = ( RADEON_READ( RADEON_MC_FB_LOCATION )
@@ -1197,12 +1197,12 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
#if __REALLY_HAVE_AGP
if (dev_priv->flags & CHIP_IS_AGP)
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base
+ dev_priv->gart_vm_start);
else
#endif
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->sg->handle
+ dev_priv->gart_vm_start);
@@ -1268,19 +1268,20 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
#if __REALLY_HAVE_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
if ( dev_priv->cp_ring != NULL )
- DRM_IOREMAPFREE( dev_priv->cp_ring, dev );
+ drm_core_ioremapfree( dev_priv->cp_ring, dev );
if ( dev_priv->ring_rptr != NULL )
- DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ drm_core_ioremapfree( dev_priv->ring_rptr, dev );
+ if ( dev->agp_buffer_map != NULL )
+ drm_core_ioremapfree( dev->agp_buffer_map, dev );
} else
#endif
{
if (!DRM(ati_pcigart_cleanup)( dev,
- dev_priv->phys_pci_gart,
- dev_priv->bus_pci_gart ))
+ dev_priv->phys_pci_gart,
+ dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
+
{
int flags = dev_priv->flags;
memset(dev_priv, 0, sizeof(*dev_priv));
@@ -1734,12 +1735,12 @@ static int radeon_register_regions(struct pci_dev *pdev) {
/* request the mem regions */
if (!request_mem_region (pci_resource_start( pdev, 2 ),
pci_resource_len(pdev, 2), DRIVER_NAME)) {
- printk(KERN_ERR DRIVER_NAME ": cannot reserve MMIO region\n");
+ DRM_ERROR("cannot reserve MMIO region\n");
return retcode;
}
if (!request_mem_region (pci_resource_start( pdev, 0 ),
pci_resource_len(pdev, 0), DRIVER_NAME)) {
- printk(KERN_ERR DRIVER_NAME ": cannot reserve FB region\n");
+ DRM_ERROR("cannot reserve FB region\n");
return retcode;
}
return 0;
@@ -1751,7 +1752,7 @@ static void radeon_release_regions(struct pci_dev *pdev) {
}
/* Always create a map record for MMIO and FB memory, done from DRIVER_POSTINIT */
-int radeon_preinit( drm_device_t *dev, unsigned long flags )
+int radeon_preinit( struct drm_device *dev, unsigned long flags )
{
int retcode = -EINVAL;
u32 save, temp;
@@ -1788,12 +1789,12 @@ int radeon_preinit( drm_device_t *dev, unsigned long flags )
return 0;
}
-int radeon_postinit( drm_device_t *dev, unsigned long flags )
+int radeon_postinit( struct drm_device *dev, unsigned long flags )
{
return 0;
}
-void radeon_postcleanup( drm_device_t *dev )
+int radeon_postcleanup( struct drm_device *dev )
{
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -1803,4 +1804,5 @@ void radeon_postcleanup( drm_device_t *dev )
radeon_release_regions(dev->pdev);
dev->dev_private = NULL;
+ return 0;
}
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index eb2d4dca..4b66e5be 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -83,7 +83,7 @@ struct mem_block {
typedef struct drm_radeon_private {
- u32 flags; /* see radeon_chip_flags */
+ uint32_t flags; /* see radeon_chip_flags */
drm_radeon_ring_buffer_t ring;
drm_radeon_sarea_t *sarea_priv;
@@ -152,7 +152,6 @@ typedef struct drm_radeon_private {
drm_local_map_t *mmio;
drm_local_map_t *cp_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *gart_textures;
struct mem_block *gart_heap;
@@ -738,9 +737,9 @@ do { \
} while (0)
extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
-extern int radeon_preinit( drm_device_t *dev, unsigned long flags );
-extern int radeon_postinit( drm_device_t *dev, unsigned long flags );
-extern void radeon_postcleanup( drm_device_t *dev );
+extern int radeon_preinit( struct drm_device *dev, unsigned long flags );
+extern int radeon_postinit( struct drm_device *dev, unsigned long flags );
+extern int radeon_postcleanup( struct drm_device *dev );
#define CP_PACKET0( reg, n ) \
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index 10a6629a..4a7bfd2d 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -1247,7 +1247,7 @@ static void radeon_cp_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = RADEON_CP_PACKET2;
}
@@ -1301,7 +1301,7 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
dwords = (prim->finish - prim->start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle +
+ data = (u32 *)((char *)dev->agp_buffer_map->handle +
elt_buf->offset + prim->start);
data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
@@ -1445,7 +1445,7 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
/* Dispatch the indirect buffer.
*/
- buffer = (u32*)((char*)dev_priv->buffers->handle + buf->offset);
+ buffer = (u32*)((char*)dev->agp_buffer_map->handle + buf->offset);
dwords = size / 4;
buffer[0] = CP_PACKET3( RADEON_CNTL_HOSTDATA_BLT, dwords + 6 );
buffer[1] = (RADEON_GMC_DST_PITCH_OFFSET_CNTL |
@@ -2547,3 +2547,46 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
return 0;
}
+
+/* When a client dies:
+ * - Check for and clean up flipped page state
+ * - Free any alloced GART memory.
+ *
+ * DRM infrastructure takes care of reclaiming dma buffers.
+ */
+static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+{
+ if ( dev->dev_private ) {
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+ if ( dev_priv->page_flipping ) {
+ radeon_do_cleanup_pageflip( dev );
+ }
+ radeon_mem_release( filp, dev_priv->gart_heap );
+ radeon_mem_release( filp, dev_priv->fb_heap );
+ }
+}
+
+static void radeon_driver_pretakedown(drm_device_t *dev)
+{
+ radeon_do_release(dev);
+}
+
+static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+{
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+ if ( dev_priv )
+ filp_priv->radeon_fb_delta = dev_priv->fb_location;
+ else
+ filp_priv->radeon_fb_delta = 0;
+}
+
+void radeon_driver_register_fns(struct drm_device *dev)
+{
+ dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
+ dev->fn_tbl.preinit = radeon_preinit;
+ dev->fn_tbl.postinit = radeon_postinit;
+ dev->fn_tbl.postcleanup = radeon_postcleanup;
+ dev->fn_tbl.prerelease = radeon_driver_prerelease;
+ dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
+ dev->fn_tbl.open_helper = radeon_driver_open_helper;
+}
diff --git a/shared-core/sis_drv.h b/shared-core/sis_drv.h
index 814a7ae1..1ca618cf 100644
--- a/shared-core/sis_drv.h
+++ b/shared-core/sis_drv.h
@@ -31,8 +31,6 @@
#include "sis_ds.h"
typedef struct drm_sis_private {
- drm_map_t *buffers;
-
memHeap_t *AGPHeap;
memHeap_t *FBHeap;
} drm_sis_private_t;
diff --git a/shared-core/sis_mm.c b/shared-core/sis_mm.c
index cbfab011..233843d5 100644
--- a/shared-core/sis_mm.c
+++ b/shared-core/sis_mm.c
@@ -330,7 +330,7 @@ int sis_ioctl_agp_free( DRM_IOCTL_ARGS )
return 0;
}
-int sis_init_context(drm_device_t *dev, int context)
+int sis_init_context(struct drm_device *dev, int context)
{
int i;
@@ -362,7 +362,7 @@ int sis_init_context(drm_device_t *dev, int context)
return 1;
}
-int sis_final_context(drm_device_t *dev, int context)
+int sis_final_context(struct drm_device *dev, int context)
{
int i;
@@ -408,3 +408,9 @@ int sis_final_context(drm_device_t *dev, int context)
return 1;
}
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = sis_init_context;
+ dev->fn_tbl.context_dtor = sis_final_context;
+}
diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c
index 6f41f1fc..ad4903bb 100644
--- a/shared-core/via_drv.c
+++ b/shared-core/via_drv.c
@@ -65,3 +65,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+
diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h
index a0ed1e60..9677b7f3 100644
--- a/shared-core/via_drv.h
+++ b/shared-core/via_drv.h
@@ -33,7 +33,6 @@ typedef struct drm_via_private {
drm_map_t *fb;
drm_map_t *mmio;
unsigned long agpAddr;
- drm_map_t *buffers;
wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
} drm_via_private_t;
diff --git a/shared-core/via_map.c b/shared-core/via_map.c
index 53260927..afafadf1 100644
--- a/shared-core/via_map.c
+++ b/shared-core/via_map.c
@@ -47,14 +47,14 @@ int via_do_init_map(drm_device_t *dev, drm_via_init_t *init)
return -EINVAL;
}
- DRM_FIND_MAP(dev_priv->fb, init->fb_offset);
+ dev_priv->fb = drm_core_findmap(dev, init->fb_offset);
if (!dev_priv->fb) {
DRM_ERROR("could not find framebuffer!\n");
dev->dev_private = (void *)dev_priv;
via_do_cleanup_map(dev);
return -EINVAL;
}
- DRM_FIND_MAP(dev_priv->mmio, init->mmio_offset);
+ dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if (!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
diff --git a/shared-core/via_mm.c b/shared-core/via_mm.c
index dae5aaf0..be6184ca 100644
--- a/shared-core/via_mm.c
+++ b/shared-core/via_mm.c
@@ -103,7 +103,7 @@ int via_fb_init( DRM_IOCTL_ARGS )
return 0;
}
-int via_init_context(drm_device_t *dev, int context)
+int via_init_context(struct drm_device *dev, int context)
{
int i;
@@ -134,7 +134,7 @@ int via_init_context(drm_device_t *dev, int context)
return 1;
}
-int via_final_context(drm_device_t *dev, int context)
+int via_final_context(struct drm_device *dev, int context)
{
int i;
for (i=0; i<MAX_CONTEXT; i++)
@@ -345,3 +345,9 @@ int via_agp_free(drm_via_mem_t* mem)
EXPORT_SYMBOL(via_fb_alloc);
EXPORT_SYMBOL(via_fb_free);
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = via_init_context;
+ dev->fn_tbl.context_dtor = via_final_context;
+}