aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/i915_dma.c34
-rw-r--r--shared/i915_drm.h37
-rw-r--r--shared/i915_drv.h24
-rw-r--r--shared/i915_irq.c1
-rw-r--r--shared/i915_mem.c21
-rw-r--r--shared/mach64_dma.c48
-rw-r--r--shared/mach64_drv.h15
-rw-r--r--shared/mach64_irq.c3
-rw-r--r--shared/mach64_state.c3
-rw-r--r--shared/mga_dma.c34
-rw-r--r--shared/mga_drv.h15
-rw-r--r--shared/mga_irq.c3
-rw-r--r--shared/mga_state.c1
-rw-r--r--shared/mga_warp.c1
-rw-r--r--shared/r128_cce.c17
-rw-r--r--shared/r128_drv.h17
-rw-r--r--shared/r128_irq.c3
-rw-r--r--shared/r128_state.c102
-rw-r--r--shared/radeon_cp.c22
-rw-r--r--shared/radeon_drv.h18
-rw-r--r--shared/radeon_irq.c11
-rw-r--r--shared/radeon_mem.c21
-rw-r--r--shared/radeon_state.c32
-rw-r--r--shared/sis_drm.h21
-rw-r--r--shared/sis_drv.h11
-rw-r--r--shared/sis_ds.c17
-rw-r--r--shared/sis_mm.c12
-rw-r--r--shared/via_dma.c1
-rw-r--r--shared/via_drm.h32
-rw-r--r--shared/via_drv.c102
-rw-r--r--shared/via_ds.c16
-rw-r--r--shared/via_ds.h1
-rw-r--r--shared/via_irq.c3
-rw-r--r--shared/via_map.c5
-rw-r--r--shared/via_mm.c53
35 files changed, 338 insertions, 419 deletions
diff --git a/shared/i915_dma.c b/shared/i915_dma.c
index 1b91c60a..cf0333f6 100644
--- a/shared/i915_dma.c
+++ b/shared/i915_dma.c
@@ -7,6 +7,7 @@
*
**************************************************************************/
+#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -83,7 +84,7 @@ int i915_dma_cleanup(drm_device_t * dev)
* is freed, it's too late.
*/
if (dev->irq)
- drm_irq_uninstall (dev);
+ DRM(irq_uninstall) (dev);
if (dev->dev_private) {
drm_i915_private_t *dev_priv =
@@ -97,7 +98,7 @@ int i915_dma_cleanup(drm_device_t * dev)
#ifdef __FreeBSD__
#if __FreeBSD_version > 500000
contigfree(dev_priv->hw_status_page, PAGE_SIZE,
- drm_M_DRM);
+ DRM(M_DRM));
#endif
#else
pci_free_consistent(dev->pdev, PAGE_SIZE,
@@ -108,7 +109,7 @@ int i915_dma_cleanup(drm_device_t * dev)
I915_WRITE(0x02080, 0x1ffff000);
}
- drm_free (dev->dev_private, sizeof(drm_i915_private_t),
+ DRM(free) (dev->dev_private, sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
@@ -182,7 +183,7 @@ static int i915_initialize(drm_device_t * dev,
/* Program Hardware Status Page */
#ifdef __FreeBSD__
dev_priv->hw_status_page =
- contigmalloc(PAGE_SIZE, drm_M_DRM, M_NOWAIT, 0ul, 0, 0, 0);
+ contigmalloc(PAGE_SIZE, DRM(M_DRM), M_NOWAIT, 0ul, 0, 0, 0);
dev_priv->dma_status_page = vtophys(dev_priv->hw_status_page);
#else
dev_priv->hw_status_page =
@@ -254,7 +255,7 @@ int i915_dma_init(DRM_IOCTL_ARGS)
switch (init.func) {
case I915_INIT_DMA:
- dev_priv = drm_alloc (sizeof(drm_i915_private_t),
+ dev_priv = DRM(alloc) (sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return DRM_ERR(ENOMEM);
@@ -732,7 +733,7 @@ int i915_setparam(DRM_IOCTL_ARGS)
return 0;
}
-void i915_driver_pretakedown(drm_device_t *dev)
+static void i915_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
@@ -741,10 +742,29 @@ void i915_driver_pretakedown(drm_device_t *dev)
i915_dma_cleanup(dev);
}
-void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+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->driver_features =
+ DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
+ DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED;
+ dev->fn_tbl.pretakedown = i915_driver_pretakedown;
+ dev->fn_tbl.prerelease = i915_driver_prerelease;
+ dev->fn_tbl.irq_preinstall = i915_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = i915_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = i915_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = i915_driver_irq_handler;
+
+ dev->counters += 4;
+ dev->types[6] = _DRM_STAT_IRQ;
+ dev->types[7] = _DRM_STAT_PRIMARY;
+ dev->types[8] = _DRM_STAT_SECONDARY;
+ dev->types[9] = _DRM_STAT_DMA;
+}
diff --git a/shared/i915_drm.h b/shared/i915_drm.h
index 7e55edf4..24f4cd62 100644
--- a/shared/i915_drm.h
+++ b/shared/i915_drm.h
@@ -61,31 +61,18 @@ typedef struct _drm_i915_sarea {
/* I915 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
-#define DRM_I915_INIT 0x00
-#define DRM_I915_FLUSH 0x01
-#define DRM_I915_FLIP 0x02
-#define DRM_I915_BATCHBUFFER 0x03
-#define DRM_I915_IRQ_EMIT 0x04
-#define DRM_I915_IRQ_WAIT 0x05
-#define DRM_I915_GETPARAM 0x06
-#define DRM_I915_SETPARAM 0x07
-#define DRM_I915_ALLOC 0x08
-#define DRM_I915_FREE 0x09
-#define DRM_I915_INIT_HEAP 0x0a
-#define DRM_I915_CMDBUFFER 0x0b
-
-#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
-#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
-#define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
-#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
-#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
-#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
-#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
-#define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
-#define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
-#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
-#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
-#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
+#define DRM_IOCTL_I915_INIT DRM_IOW( 0x40, drm_i915_init_t)
+#define DRM_IOCTL_I915_FLUSH DRM_IO ( 0x41)
+#define DRM_IOCTL_I915_FLIP DRM_IO ( 0x42)
+#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( 0x43, drm_i915_batchbuffer_t)
+#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(0x44, drm_i915_irq_emit_t)
+#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( 0x45, drm_i915_irq_wait_t)
+#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(0x46, drm_i915_getparam_t)
+#define DRM_IOCTL_I915_SETPARAM DRM_IOW( 0x47, drm_i915_setparam_t)
+#define DRM_IOCTL_I915_ALLOC DRM_IOWR(0x48, drm_i915_mem_alloc_t)
+#define DRM_IOCTL_I915_FREE DRM_IOW( 0x49, drm_i915_mem_free_t)
+#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( 0x4a, drm_i915_mem_init_heap_t)
+#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( 0x4b, drm_i915_cmdbuffer_t)
/* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware.
diff --git a/shared/i915_drv.h b/shared/i915_drv.h
index f6ca92a5..7564cd09 100644
--- a/shared/i915_drv.h
+++ b/shared/i915_drv.h
@@ -10,28 +10,6 @@
#ifndef _I915_DRV_H_
#define _I915_DRV_H_
-/* General customization:
- */
-
-#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
-
-#define DRIVER_NAME "i915"
-#define DRIVER_DESC "Intel Graphics"
-#define DRIVER_DATE "20040405"
-
-/* Interface history:
- *
- * 1.1: Original.
- */
-#define DRIVER_MAJOR 1
-#define DRIVER_MINOR 1
-#define DRIVER_PATCHLEVEL 0
-
-/* We use our own dma mechanisms, not the drm template code. However,
- * the shared IRQ code is useful to us:
- */
-#define __HAVE_PM 1
-
typedef struct _drm_i915_ring_buffer {
int tail_mask;
unsigned long Start;
@@ -88,8 +66,6 @@ extern int i915_getparam(DRM_IOCTL_ARGS);
extern int i915_setparam(DRM_IOCTL_ARGS);
extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
extern void i915_kernel_lost_context(drm_device_t * dev);
-extern void i915_driver_pretakedown(drm_device_t *dev);
-extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS);
diff --git a/shared/i915_irq.c b/shared/i915_irq.c
index 581d3f22..de91aba5 100644
--- a/shared/i915_irq.c
+++ b/shared/i915_irq.c
@@ -7,6 +7,7 @@
*
**************************************************************************/
+#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
diff --git a/shared/i915_mem.c b/shared/i915_mem.c
index d54a3005..c6115b7e 100644
--- a/shared/i915_mem.c
+++ b/shared/i915_mem.c
@@ -7,6 +7,7 @@
*
**************************************************************************/
+#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -74,7 +75,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
@@ -90,7 +91,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
@@ -147,7 +148,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
@@ -155,7 +156,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS);
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
@@ -163,14 +164,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS);
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
- *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS);
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
- drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
+ DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
@@ -210,7 +211,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
@@ -227,10 +228,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
- drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
- drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
+ DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c
index c463b6cf..210a6103 100644
--- a/shared/mach64_dma.c
+++ b/shared/mach64_dma.c
@@ -28,9 +28,10 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
*/
+#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -446,7 +447,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
/* FIXME: get a dma buffer from the freelist here */
DRM_DEBUG( "Allocating data memory ...\n" );
- cpu_addr_data = drm_pci_alloc( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
+ cpu_addr_data = DRM(pci_alloc)( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
if (!cpu_addr_data || !data_handle) {
DRM_INFO( "data-memory allocation failed!\n" );
return DRM_ERR(ENOMEM);
@@ -480,7 +481,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
DRM_INFO( "resetting engine ...\n");
mach64_do_engine_reset( dev_priv );
DRM_INFO( "freeing data buffer memory.\n" );
- drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
+ DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
return DRM_ERR(EIO);
}
}
@@ -534,7 +535,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
+ DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
DRM_DEBUG( "waiting for idle...done\n" );
@@ -571,7 +572,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
+ DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
@@ -599,7 +600,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_DEBUG( "freeing data buffer memory.\n" );
- drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
+ DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
DRM_DEBUG( "returning ...\n" );
return failed;
@@ -614,7 +615,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
DRM_DEBUG( "%s\n", __FUNCTION__ );
- dev_priv = drm_alloc( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
+ dev_priv = DRM(alloc)( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -746,7 +747,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
dev_priv->ring.size = 0x4000; /* 16KB */
if ( dev_priv->is_pci ) {
- dev_priv->ring.start = drm_pci_alloc( dev, dev_priv->ring.size,
+ dev_priv->ring.start = DRM(pci_alloc)( dev, dev_priv->ring.size,
dev_priv->ring.size, 0xfffffffful,
&dev_priv->ring.handle );
@@ -975,14 +976,14 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq ) drm_irq_uninstall(dev);
+ if ( dev->irq ) DRM(irq_uninstall)(dev);
if ( dev->dev_private ) {
drm_mach64_private_t *dev_priv = dev->dev_private;
if ( dev_priv->is_pci ) {
if ( (dev_priv->ring.start != NULL) && dev_priv->ring.handle ) {
- drm_pci_free( dev, dev_priv->ring.size,
+ DRM(pci_free)( dev, dev_priv->ring.size,
dev_priv->ring.start, dev_priv->ring.handle );
}
} else {
@@ -997,7 +998,7 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
mach64_destroy_freelist( dev );
- drm_free( dev_priv, sizeof(drm_mach64_private_t),
+ DRM(free)( dev_priv, sizeof(drm_mach64_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -1084,7 +1085,7 @@ int mach64_init_freelist( drm_device_t *dev )
for ( i = 0 ; i < dma->buf_count ; i++ ) {
if ((entry =
- (drm_mach64_freelist_t *) drm_alloc(sizeof(drm_mach64_freelist_t),
+ (drm_mach64_freelist_t *) DRM(alloc)(sizeof(drm_mach64_freelist_t),
DRM_MEM_BUFLISTS)) == NULL)
return DRM_ERR(ENOMEM);
memset( entry, 0, sizeof(drm_mach64_freelist_t) );
@@ -1109,20 +1110,20 @@ void mach64_destroy_freelist( drm_device_t *dev )
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->placeholders)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->free_list)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
}
@@ -1312,7 +1313,7 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
DRM_CURRENTPID, d.request_count, dma->buf_count );
ret = DRM_ERR(EINVAL);
}
-
+
d.granted_count = 0;
if ( d.request_count )
@@ -1325,7 +1326,18 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-void mach64_driver_pretakedown(drm_device_t *dev)
+static void mach64_driver_pretakedown(drm_device_t *dev)
+{
+ mach64_do_cleanup_dma( dev );
+}
+
+void mach64_driver_register_fns(drm_device_t *dev)
{
- mach64_do_cleanup_dma( dev );
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
+ dev->fn_tbl.pretakedown = mach64_driver_pretakedown;
+ dev->fn_tbl.vblank_wait = mach64_driver_vblank_wait;
+ dev->fn_tbl.irq_preinstall = mach64_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = mach64_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = mach64_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = mach64_driver_irq_handler;
}
diff --git a/shared/mach64_drv.h b/shared/mach64_drv.h
index f047b7ef..b49e6f65 100644
--- a/shared/mach64_drv.h
+++ b/shared/mach64_drv.h
@@ -28,24 +28,12 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
*/
#ifndef __MACH64_DRV_H__
#define __MACH64_DRV_H__
-/* General customization:
- */
-
-#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca"
-
-#define DRIVER_NAME "mach64"
-#define DRIVER_DESC "DRM module for the ATI Rage Pro"
-#define DRIVER_DATE "20020904"
-
-#define DRIVER_MAJOR 1
-#define DRIVER_MINOR 0
-#define DRIVER_PATCHLEVEL 0
/* FIXME: remove these when not needed */
/* Development driver options */
@@ -114,7 +102,6 @@ extern int mach64_dma_idle( DRM_IOCTL_ARGS );
extern int mach64_dma_flush( DRM_IOCTL_ARGS );
extern int mach64_engine_reset( DRM_IOCTL_ARGS );
extern int mach64_dma_buffers( DRM_IOCTL_ARGS );
-extern void mach64_driver_pretakedown(drm_device_t *dev);
extern int mach64_init_freelist( drm_device_t *dev );
extern void mach64_destroy_freelist( drm_device_t *dev );
diff --git a/shared/mach64_irq.c b/shared/mach64_irq.c
index 966c3c10..efa0641f 100644
--- a/shared/mach64_irq.c
+++ b/shared/mach64_irq.c
@@ -34,6 +34,7 @@
* Leif Delgass <ldelgass@retinalburn.net>
*/
+#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -62,7 +63,7 @@ irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS )
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- drm_vbl_send_signals( dev );
+ DRM(vbl_send_signals)( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/mach64_state.c b/shared/mach64_state.c
index 127f67d2..ef85ffd8 100644
--- a/shared/mach64_state.c
+++ b/shared/mach64_state.c
@@ -26,9 +26,10 @@
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Leif Delgass <ldelgass@retinalburn.net>
- * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
*/
+#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
diff --git a/shared/mga_dma.c b/shared/mga_dma.c
index 896787be..0288f1c2 100644
--- a/shared/mga_dma.c
+++ b/shared/mga_dma.c
@@ -33,6 +33,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -307,7 +308,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
int i;
DRM_DEBUG( "count=%d\n", dma->buf_count );
- dev_priv->head = drm_alloc( sizeof(drm_mga_freelist_t),
+ dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -319,7 +320,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = drm_alloc( sizeof(drm_mga_freelist_t),
+ entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
return DRM_ERR(ENOMEM);
@@ -356,7 +357,7 @@ static void mga_freelist_cleanup( drm_device_t *dev )
entry = dev_priv->head;
while ( entry ) {
next = entry->next;
- drm_free( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
+ DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
entry = next;
}
@@ -457,7 +458,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
int ret;
DRM_DEBUG( "\n" );
- dev_priv = drm_alloc( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
+ dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
return DRM_ERR(ENOMEM);
@@ -633,7 +634,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq_enabled ) drm_irq_uninstall(dev);
+ if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->dev_private ) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -651,7 +652,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
mga_freelist_cleanup( dev );
}
- drm_free( dev->dev_private, sizeof(drm_mga_private_t),
+ DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -799,13 +800,30 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-void mga_driver_pretakedown(drm_device_t *dev)
+static void mga_driver_pretakedown(drm_device_t *dev)
{
mga_do_cleanup_dma( dev );
}
-int mga_driver_dma_quiescent(drm_device_t *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->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
+ dev->fn_tbl.pretakedown = mga_driver_pretakedown;
+ dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
+ dev->fn_tbl.vblank_wait = mga_driver_vblank_wait;
+ dev->fn_tbl.irq_preinstall = mga_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = mga_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = mga_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = mga_driver_irq_handler;
+
+ dev->counters += 3;
+ dev->types[6] = _DRM_STAT_IRQ;
+ dev->types[7] = _DRM_STAT_PRIMARY;
+ dev->types[8] = _DRM_STAT_SECONDARY;
+}
diff --git a/shared/mga_drv.h b/shared/mga_drv.h
index 3d8e9aef..75dcb0e9 100644
--- a/shared/mga_drv.h
+++ b/shared/mga_drv.h
@@ -31,19 +31,6 @@
#ifndef __MGA_DRV_H__
#define __MGA_DRV_H__
-/* General customization:
- */
-
-#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
-
-#define DRIVER_NAME "mga"
-#define DRIVER_DESC "Matrox G200/G400"
-#define DRIVER_DATE "20021029"
-
-#define DRIVER_MAJOR 3
-#define DRIVER_MINOR 1
-#define DRIVER_PATCHLEVEL 0
-
typedef struct drm_mga_primary_buffer {
u8 *start;
u8 *end;
@@ -117,8 +104,6 @@ extern int mga_dma_init( DRM_IOCTL_ARGS );
extern int mga_dma_flush( DRM_IOCTL_ARGS );
extern int mga_dma_reset( DRM_IOCTL_ARGS );
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
-extern void mga_driver_pretakedown(drm_device_t *dev);
-extern int mga_driver_dma_quiescent(drm_device_t *dev);
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
diff --git a/shared/mga_irq.c b/shared/mga_irq.c
index bc0b6b5d..c3185b0b 100644
--- a/shared/mga_irq.c
+++ b/shared/mga_irq.c
@@ -30,6 +30,7 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
+#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -49,7 +50,7 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- drm_vbl_send_signals( dev );
+ DRM(vbl_send_signals)( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/mga_state.c b/shared/mga_state.c
index f676e974..43659825 100644
--- a/shared/mga_state.c
+++ b/shared/mga_state.c
@@ -32,6 +32,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared/mga_warp.c b/shared/mga_warp.c
index 0a3a0cc7..de1b911f 100644
--- a/shared/mga_warp.c
+++ b/shared/mga_warp.c
@@ -27,6 +27,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared/r128_cce.c b/shared/r128_cce.c
index 809e6c8c..64c9b8be 100644
--- a/shared/r128_cce.c
+++ b/shared/r128_cce.c
@@ -28,6 +28,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -354,7 +355,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "\n" );
- dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
+ dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -543,7 +544,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -560,7 +561,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
- if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
+ if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart) ) {
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
@@ -589,7 +590,7 @@ int r128_do_cleanup_cce( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq_enabled ) drm_irq_uninstall(dev);
+ if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -607,13 +608,13 @@ int r128_do_cleanup_cce( drm_device_t *dev )
} else
#endif
{
- if (!drm_ati_pcigart_cleanup( dev,
+ if (!DRM(ati_pcigart_cleanup)( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
- drm_free( dev->dev_private, sizeof(drm_r128_private_t),
+ DRM(free)( dev->dev_private, sizeof(drm_r128_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -772,7 +773,7 @@ static int r128_freelist_init( drm_device_t *dev )
drm_r128_freelist_t *entry;
int i;
- dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t),
+ dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -784,7 +785,7 @@ static int r128_freelist_init( drm_device_t *dev )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = drm_alloc( sizeof(drm_r128_freelist_t),
+ entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( !entry ) return DRM_ERR(ENOMEM);
diff --git a/shared/r128_drv.h b/shared/r128_drv.h
index 9cec2f3e..5b91256c 100644
--- a/shared/r128_drv.h
+++ b/shared/r128_drv.h
@@ -28,25 +28,12 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
- * Michel D�zer <daenzerm@student.ethz.ch>
+ * Michel Dänzer <daenzerm@student.ethz.ch>
*/
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
-/* General customization:
- */
-#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
-
-#define DRIVER_NAME "r128"
-#define DRIVER_DESC "ATI Rage 128"
-#define DRIVER_DATE "20030725"
-
-#define DRIVER_MAJOR 2
-#define DRIVER_MINOR 5
-#define DRIVER_PATCHLEVEL 0
-
-
#define GET_RING_HEAD(dev_priv) R128_READ( R128_PM4_BUFFER_DL_RPTR )
typedef struct drm_r128_freelist {
@@ -161,8 +148,6 @@ extern irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS );
extern void r128_driver_irq_preinstall( drm_device_t *dev );
extern void r128_driver_irq_postinstall( drm_device_t *dev );
extern void r128_driver_irq_uninstall( drm_device_t *dev );
-extern void r128_driver_pretakedown(drm_device_t *dev);
-extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* Register definitions, register access macros and drmAddMap constants
* for Rage 128 kernel driver.
diff --git a/shared/r128_irq.c b/shared/r128_irq.c
index 643a3078..be1b9dac 100644
--- a/shared/r128_irq.c
+++ b/shared/r128_irq.c
@@ -30,6 +30,7 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
+#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -49,7 +50,7 @@ irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- drm_vbl_send_signals( dev );
+ DRM(vbl_send_signals)( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/r128_state.c b/shared/r128_state.c
index ed643682..5b8af9f9 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -27,6 +27,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -925,24 +926,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- drm_free( buffer, buffer_size, DRM_MEM_BUFS);
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
- mask = drm_alloc( mask_size, DRM_MEM_BUFS );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
- drm_free( mask, mask_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -969,7 +970,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- drm_free( mask, mask_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -993,7 +994,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1015,54 +1016,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
- buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
- mask = drm_alloc( mask_size, DRM_MEM_BUFS );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
- drm_free( mask, mask_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1089,7 +1090,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- drm_free( mask, mask_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1113,9 +1114,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
- drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1183,23 +1184,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1227,8 +1228,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- drm_free( x, xbuf_size, DRM_MEM_BUFS );
- drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
@@ -1694,7 +1695,7 @@ int r128_getparam( DRM_IOCTL_ARGS )
return 0;
}
-void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -1704,7 +1705,20 @@ void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-void r128_driver_pretakedown(drm_device_t *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->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
+ dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ dev->fn_tbl.prerelease = r128_driver_prerelease;
+ dev->fn_tbl.pretakedown = r128_driver_pretakedown;
+ dev->fn_tbl.vblank_wait = r128_driver_vblank_wait;
+ dev->fn_tbl.irq_preinstall = r128_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = r128_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = r128_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = r128_driver_irq_handler;
+}
diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c
index 78c41b5d..cbde7ce9 100644
--- a/shared/radeon_cp.c
+++ b/shared/radeon_cp.c
@@ -28,6 +28,7 @@
* Gareth Hughes <gareth@valinux.com>
*/
+#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -1215,7 +1216,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -1229,7 +1230,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
} else
#endif
{
- if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
+ if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart)) {
DRM_ERROR( "failed to init PCI GART!\n" );
radeon_do_cleanup_cp(dev);
@@ -1259,7 +1260,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq_enabled ) drm_irq_uninstall(dev);
+ if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
@@ -1278,7 +1279,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
} else
#endif
{
- if (!drm_ati_pcigart_cleanup( dev,
+ if (!DRM(ati_pcigart_cleanup)( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
@@ -1733,7 +1734,7 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
drm_radeon_private_t *dev_priv;
int ret = 0;
- dev_priv = drm_alloc( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
+ dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -1742,12 +1743,12 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
dev_priv->flags = flags;
/* registers */
- if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 2 ),
+ if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 2 ),
pci_resource_len( dev->pdev, 2 ), _DRM_REGISTERS, 0 )))
return ret;
/* framebuffer */
- if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 0 ),
+ if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 0 ),
pci_resource_len( dev->pdev, 0 ), _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING )))
return ret;
@@ -1775,6 +1776,11 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
return ret;
}
+int radeon_postinit( struct drm_device *dev, unsigned long flags )
+{
+ return 0;
+}
+
int radeon_postcleanup( struct drm_device *dev )
{
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -1783,7 +1789,7 @@ int radeon_postcleanup( struct drm_device *dev )
#if defined(__linux__)
radeon_delete_i2c_busses(dev);
#endif
- drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
+ DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
dev->dev_private = NULL;
return 0;
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index 75c02e7a..ccb1654f 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -31,20 +31,6 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
-/* General customization:
- */
-
-#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
-
-#define DRIVER_NAME "radeon"
-#define DRIVER_DESC "ATI Radeon"
-#define DRIVER_DATE "20020828"
-
-#define DRIVER_MAJOR 1
-#define DRIVER_MINOR 11
-#define DRIVER_PATCHLEVEL 0
-
-
enum radeon_family {
CHIP_R100,
CHIP_RS100,
@@ -261,10 +247,6 @@ extern irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS );
extern void radeon_driver_irq_preinstall( drm_device_t *dev );
extern void radeon_driver_irq_postinstall( drm_device_t *dev );
extern void radeon_driver_irq_uninstall( drm_device_t *dev );
-extern void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp);
-extern void radeon_driver_pretakedown(drm_device_t *dev);
-extern int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv);
-extern void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv);
/* Flags for stats.boxes
*/
diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c
index b7deca73..bdb3cc16 100644
--- a/shared/radeon_irq.c
+++ b/shared/radeon_irq.c
@@ -27,9 +27,10 @@
*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * Michel D�zer <michel@daenzer.net>
+ * Michel Dänzer <michel@daenzer.net>
*/
+#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -77,7 +78,7 @@ irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- drm_vbl_send_signals( dev );
+ DRM(vbl_send_signals)( dev );
}
/* Acknowledge interrupts we handle */
@@ -222,7 +223,7 @@ int radeon_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
-void radeon_driver_irq_preinstall( drm_device_t *dev ) {
+void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -233,7 +234,7 @@ void radeon_driver_irq_preinstall( drm_device_t *dev ) {
radeon_acknowledge_irqs( dev_priv );
}
-void radeon_driver_irq_postinstall( drm_device_t *dev ) {
+void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -246,7 +247,7 @@ void radeon_driver_irq_postinstall( drm_device_t *dev ) {
RADEON_SW_INT_ENABLE );
}
-void radeon_driver_irq_uninstall( drm_device_t *dev ) {
+void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/shared/radeon_mem.c b/shared/radeon_mem.c
index 17483dd1..9d7fded7 100644
--- a/shared/radeon_mem.c
+++ b/shared/radeon_mem.c
@@ -29,6 +29,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -43,7 +44,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
@@ -59,7 +60,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
@@ -117,7 +118,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- drm_free(q, sizeof(*q), DRM_MEM_BUFS );
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
@@ -125,7 +126,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- drm_free(p, sizeof(*q), DRM_MEM_BUFS );
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
}
}
@@ -133,14 +134,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS );
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
- *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS );
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
- drm_free( blocks, sizeof(*blocks), DRM_MEM_BUFS );
+ DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
@@ -179,7 +180,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
@@ -196,10 +197,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
- drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
- drm_free( *heap, sizeof(**heap),DRM_MEM_DRIVER );
+ DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index 35fb16e9..9675da92 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -27,6 +27,7 @@
* Kevin E. Martin <martin@valinux.com>
*/
+#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
@@ -1597,7 +1598,7 @@ static int radeon_do_init_pageflip( drm_device_t *dev )
return 0;
}
-/* Called whenever a client dies, from drm_release.
+/* Called whenever a client dies, from DRM(release).
* NOTE: Lock isn't necessarily held when this is called!
*/
int radeon_do_cleanup_pageflip( drm_device_t *dev )
@@ -2559,7 +2560,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
*
* DRM infrastructure takes care of reclaiming dma buffers.
*/
-void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2571,17 +2572,17 @@ void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-void radeon_driver_pretakedown(drm_device_t *dev)
+static void radeon_driver_pretakedown(drm_device_t *dev)
{
radeon_do_release(dev);
}
-int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
struct drm_radeon_driver_file_fields *radeon_priv;
- radeon_priv = (struct drm_radeon_driver_file_fields *)drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
+ radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv)
return -ENOMEM;
@@ -2595,10 +2596,27 @@ int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
return 0;
}
-void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
+static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
{
struct drm_radeon_driver_file_fields *radeon_priv = filp_priv->driver_priv;
- drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
+ DRM(free)(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
}
+void radeon_driver_register_fns(struct drm_device *dev)
+{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
+ 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;
+ dev->fn_tbl.vblank_wait = radeon_driver_vblank_wait;
+ dev->fn_tbl.irq_preinstall = radeon_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = radeon_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = radeon_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = radeon_driver_irq_handler;
+ dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
+}
diff --git a/shared/sis_drm.h b/shared/sis_drm.h
index e99c3a43..49505719 100644
--- a/shared/sis_drm.h
+++ b/shared/sis_drm.h
@@ -3,21 +3,12 @@
#define __SIS_DRM_H__
/* SiS specific ioctls */
-#define NOT_USED_0_3
-#define DRM_SIS_FB_ALLOC 0x04
-#define DRM_SIS_FB_FREE 0x05
-#define NOT_USED_6_12
-#define DRM_SIS_AGP_INIT 0x13
-#define DRM_SIS_AGP_ALLOC 0x14
-#define DRM_SIS_AGP_FREE 0x15
-#define DRM_SIS_FB_INIT 0x16
-
-#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
-#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
+#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(0x44, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(0x53, drm_sis_agp_t)
+#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(0x54, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( 0x56, drm_sis_fb_t)
/*
#define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
#define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49)
diff --git a/shared/sis_drv.h b/shared/sis_drv.h
index 7232b8f3..1ca618cf 100644
--- a/shared/sis_drv.h
+++ b/shared/sis_drv.h
@@ -28,17 +28,6 @@
#ifndef _SIS_DRV_H_
#define _SIS_DRV_H_
-/* General customization:
- */
-
-#define DRIVER_AUTHOR "SIS"
-#define DRIVER_NAME "sis"
-#define DRIVER_DESC "SIS 300/630/540"
-#define DRIVER_DATE "20030826"
-#define DRIVER_MAJOR 1
-#define DRIVER_MINOR 1
-#define DRIVER_PATCHLEVEL 0
-
#include "sis_ds.h"
typedef struct drm_sis_private {
diff --git a/shared/sis_ds.c b/shared/sis_ds.c
index 60bffa69..08391554 100644
--- a/shared/sis_ds.c
+++ b/shared/sis_ds.c
@@ -28,6 +28,7 @@
*
*/
+#include "sis.h"
#include "drmP.h"
#include "drm.h"
#include "sis_ds.h"
@@ -41,7 +42,7 @@ set_t *setInit(void)
int i;
set_t *set;
- set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
if (set != NULL) {
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i + 1;
@@ -127,7 +128,7 @@ int setNext(set_t *set, ITEM_TYPE *item)
int setDestroy(set_t *set)
{
- drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
+ DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -166,7 +167,7 @@ memHeap_t *mmInit(int ofs,
if (size <= 0)
return NULL;
- blocks = (TMemBlock *)drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)DRM(calloc)(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks->ofs = ofs;
blocks->size = size;
@@ -201,7 +202,7 @@ memHeap_t *mmAddRange( memHeap_t *heap,
int size )
{
PMemBlock blocks;
- blocks = (TMemBlock *)drm_calloc(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)DRM(calloc)(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks[0].size = size;
blocks[0].free = 1;
@@ -228,7 +229,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
@@ -241,7 +242,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
@@ -294,7 +295,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ DRM(free)(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
return 1;
}
return 0;
@@ -379,7 +380,7 @@ void mmDestroy(memHeap_t *heap)
p = (TMemBlock *)heap;
while (p != NULL) {
q = p->next;
- drm_free(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ DRM(free)(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared/sis_mm.c b/shared/sis_mm.c
index a895e0b8..27b904fc 100644
--- a/shared/sis_mm.c
+++ b/shared/sis_mm.c
@@ -28,6 +28,7 @@
*
*/
+#include "sis.h"
#include "drmP.h"
#include "sis_drm.h"
#include "sis_drv.h"
@@ -162,7 +163,7 @@ int sis_fb_init( DRM_IOCTL_ARGS )
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *)data, sizeof(fb));
if (dev_priv == NULL) {
- dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
+ dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -250,7 +251,7 @@ int sis_ioctl_agp_init( DRM_IOCTL_ARGS )
drm_sis_agp_t agp;
if (dev_priv == NULL) {
- dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
+ dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -407,3 +408,10 @@ int sis_final_context(struct drm_device *dev, int context)
return 1;
}
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR;
+ dev->fn_tbl.context_ctor = sis_init_context;
+ dev->fn_tbl.context_dtor = sis_final_context;
+}
diff --git a/shared/via_dma.c b/shared/via_dma.c
index 493c0b00..4afc5215 100644
--- a/shared/via_dma.c
+++ b/shared/via_dma.c
@@ -10,6 +10,7 @@
*
**************************************************************************/
+#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
diff --git a/shared/via_drm.h b/shared/via_drm.h
index ba94a4fe..ddc89f83 100644
--- a/shared/via_drm.h
+++ b/shared/via_drm.h
@@ -62,28 +62,16 @@
#define VIA_UPLOAD_ALL 0xff
/* VIA specific ioctls */
-#define DRM_VIA_ALLOCMEM 0x00
-#define DRM_VIA_FREEMEM 0x01
-#define DRM_VIA_AGP_INIT 0x02
-#define DRM_VIA_FB_INIT 0x03
-#define DRM_VIA_MAP_INIT 0x04
-#define DRM_VIA_DEC_FUTEX 0x05
-#define NOT_USED
-#define DRM_VIA_DMA_INIT 0x07
-#define DRM_VIA_CMDBUFFER 0x08
-#define DRM_VIA_FLUSH 0x09
-#define DRM_VIA_PCICMD 0x0a
-
-#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
-#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
-#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
-#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
-#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
-#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
-#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
-#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
-#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
-#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
+#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t)
+#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t)
+#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t)
+#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t)
+#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t)
+#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(0x45, drm_via_futex_t)
+#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(0x47, drm_via_dma_init_t)
+#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW(0x48, drm_via_cmdbuffer_t)
+#define DRM_IOCTL_VIA_FLUSH DRM_IO(0x49)
+#define DRM_IOCTL_VIA_PCICMD DRM_IOW(0x4A, drm_via_cmdbuffer_t)
/* Indices into buf.Setup where various bits of state are mirrored per
diff --git a/shared/via_drv.c b/shared/via_drv.c
index cec14e7a..7b6e1b96 100644
--- a/shared/via_drv.c
+++ b/shared/via_drv.c
@@ -23,6 +23,7 @@
*/
#include <linux/config.h>
+#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -37,95 +38,18 @@
#define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 0
-#include "drm_pciids.h"
-static int postinit( struct drm_device *dev, unsigned long flags )
-{
- DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
- DRIVER_NAME,
- DRIVER_MAJOR,
- DRIVER_MINOR,
- DRIVER_PATCHLEVEL,
- DRIVER_DATE,
- dev->minor,
- pci_pretty_name(dev->pdev)
- );
- return 0;
-}
+#define DRIVER_IOCTLS \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_FREEMEM)] = { via_mem_free, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_AGP_INIT)] = { via_agp_init, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_FB_INIT)] = { via_fb_init, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_MAP_INIT)] = { via_map_init, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0}, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_DMA_INIT)] = { via_dma_init, 1, 0}, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0}, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_FLUSH)] = { via_flush_ioctl, 1, 0}, \
+ [DRM_IOCTL_NR(DRM_IOCTL_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
-static int version( drm_version_t *version )
-{
- int len;
- version->version_major = DRIVER_MAJOR;
- version->version_minor = DRIVER_MINOR;
- version->version_patchlevel = DRIVER_PATCHLEVEL;
- DRM_COPY( version->name, DRIVER_NAME );
- DRM_COPY( version->date, DRIVER_DATE );
- DRM_COPY( version->desc, DRIVER_DESC );
- return 0;
-}
-
-static struct pci_device_id pciidlist[] = {
- viadrv_PCI_IDS
-};
-
-static drm_ioctl_desc_t ioctls[] = {
- [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = { via_mem_free, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = { via_agp_init, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = { via_fb_init, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = { via_map_init, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = { via_dma_init, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = { via_flush_ioctl, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
-};
-
-static struct drm_driver_fn driver_fn = {
- .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
- .context_ctor = via_init_context,
- .context_dtor = via_final_context,
- .vblank_wait = via_driver_vblank_wait,
- .irq_preinstall = via_driver_irq_preinstall,
- .irq_postinstall = via_driver_irq_postinstall,
- .irq_uninstall = via_driver_irq_uninstall,
- .irq_handler = via_driver_irq_handler,
- .reclaim_buffers = drm_core_reclaim_buffers,
- .get_map_ofs = drm_core_get_map_ofs,
- .get_reg_ofs = drm_core_get_reg_ofs,
- .postinit = postinit,
- .version = version,
- .ioctls = ioctls,
- .num_ioctls = DRM_ARRAY_SIZE(ioctls),
-};
-
-static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- return drm_probe(pdev, ent, &driver_fn);
-}
-
-static struct pci_driver driver = {
- .name = DRIVER_NAME,
- .id_table = pciidlist,
- .probe = probe,
- .remove = __devexit_p(drm_cleanup_pci),
-};
-
-static int __init via_init(void)
-{
- return drm_init(&driver, pciidlist, &driver_fn);
-}
-
-static void __exit via_exit(void)
-{
- drm_exit(&driver);
-}
-
-module_init(via_init);
-module_exit(via_exit);
-
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_LICENSE("GPL and additional rights");
+#include "drm_core.h"
diff --git a/shared/via_ds.c b/shared/via_ds.c
index 71af0c9b..a29204ce 100644
--- a/shared/via_ds.c
+++ b/shared/via_ds.c
@@ -38,7 +38,7 @@ set_t *via_setInit(void)
{
int i;
set_t *set;
- set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i+1;
set->list[i].alloc_next = -1;
@@ -120,7 +120,7 @@ int via_setNext(set_t *set, ITEM_TYPE *item)
int via_setDestroy(set_t *set)
{
- drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
+ DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -161,7 +161,7 @@ memHeap_t *via_mmInit(int ofs,
return 0;
- blocks = (TMemBlock *)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks->ofs = ofs;
@@ -177,7 +177,7 @@ memHeap_t *via_mmAddRange(memHeap_t *heap,
int size)
{
PMemBlock blocks;
- blocks = (TMemBlock *)drm_calloc(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)DRM(calloc)(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks[0].size = size;
@@ -206,7 +206,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -218,7 +218,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -277,7 +277,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- drm_free(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ DRM(free)(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
return 1;
}
@@ -384,7 +384,7 @@ void via_mmDestroy(memHeap_t *heap)
while (p) {
q = p->next;
- drm_free(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ DRM(free)(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared/via_ds.h b/shared/via_ds.h
index d9a60186..50ab3e7f 100644
--- a/shared/via_ds.h
+++ b/shared/via_ds.h
@@ -26,6 +26,7 @@
#ifndef _via_ds_h_
#define _via_ds_h_
+#include "via.h"
#include "drmP.h"
/* Set Data Structure */
diff --git a/shared/via_irq.c b/shared/via_irq.c
index b0a3349e..eafb1d7d 100644
--- a/shared/via_irq.c
+++ b/shared/via_irq.c
@@ -33,6 +33,7 @@
* interrupt.
*/
+#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
@@ -57,7 +58,7 @@ irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS )
if(status & VIA_IRQ_VBI_PENDING){
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- drm_vbl_send_signals(dev);
+ DRM(vbl_send_signals)(dev);
handled = 1;
}
diff --git a/shared/via_map.c b/shared/via_map.c
index b7f0b43b..f08503d4 100644
--- a/shared/via_map.c
+++ b/shared/via_map.c
@@ -21,6 +21,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
+#include "via.h"
#include "drmP.h"
#include "via_drv.h"
@@ -31,7 +32,7 @@ int via_do_init_map(drm_device_t *dev, drm_via_init_t *init)
DRM_DEBUG("%s\n", __FUNCTION__);
- dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+ dev_priv = DRM(alloc)(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
@@ -83,7 +84,7 @@ int via_do_cleanup_map(drm_device_t *dev)
via_dma_cleanup(dev);
- drm_free(dev_priv, sizeof(drm_via_private_t),
+ DRM(free)(dev_priv, sizeof(drm_via_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
}
diff --git a/shared/via_mm.c b/shared/via_mm.c
index 706f00d1..2a9be681 100644
--- a/shared/via_mm.c
+++ b/shared/via_mm.c
@@ -21,6 +21,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
+#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -174,7 +175,7 @@ int via_final_context(struct drm_device *dev, int context)
/* Linux specific until context tracking code gets ported to BSD */
/* Last context, perform cleanup */
if (dev->ctx_count == 1 && dev->dev_private) {
- if (dev->irq) drm_irq_uninstall(dev);
+ if (dev->irq) DRM(irq_uninstall)(dev);
via_do_cleanup_map(dev);
}
@@ -210,13 +211,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
drm_via_mm_t fb;
PMemBlock block;
int retval = 0;
-
+
if (!FBHeap)
return -1;
fb.size = mem->size;
fb.context = mem->context;
-
+
block = via_mmAllocMem(FBHeap, fb.size, 5, 0);
if (block) {
fb.offset = block->ofs;
@@ -233,13 +234,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
fb.free = 0;
retval = -1;
}
-
+
mem->offset = fb.offset;
mem->index = fb.free;
DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb.size,
(int)fb.offset);
-
+
return retval;
}
int via_agp_alloc(drm_via_mem_t* mem)
@@ -269,7 +270,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
agp.size = 0;
agp.free = 0;
}
-
+
mem->offset = agp.offset;
mem->index = agp.free;
@@ -281,7 +282,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
int via_mem_free( DRM_IOCTL_ARGS )
{
drm_via_mem_t mem;
-
+
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t *)data, sizeof(mem));
switch (mem.type) {
@@ -295,23 +296,22 @@ int via_mem_free( DRM_IOCTL_ARGS )
return 0;
break;
}
-
+
return -EFAULT;
}
-
int via_fb_free(drm_via_mem_t* mem)
{
drm_via_mm_t fb;
int retval = 0;
-
+
if (!FBHeap) {
return -1;
}
fb.free = mem->index;
fb.context = mem->context;
-
+
if (!fb.free)
{
return -1;
@@ -319,37 +319,50 @@ int via_fb_free(drm_via_mem_t* mem)
}
via_mmFreeMem((PMemBlock)fb.free);
-
+
if (!del_alloc_set(fb.context, VIDEO, fb.free))
{
retval = -1;
}
-
+
DRM_DEBUG("free fb, free = %d\n", fb.free);
-
+
return retval;
-}
-
+}
int via_agp_free(drm_via_mem_t* mem)
{
drm_via_mm_t agp;
-
+
int retval = 0;
agp.free = mem->index;
agp.context = mem->context;
-
+
if (!agp.free)
return -1;
via_mmFreeMem((PMemBlock)agp.free);
-
+
if (!del_alloc_set(agp.context, AGP, agp.free)) {
retval = -1;
}
DRM_DEBUG("free agp, free = %d\n", agp.free);
-
+
return retval;
}
+EXPORT_SYMBOL(via_fb_alloc);
+EXPORT_SYMBOL(via_fb_free);
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
+ dev->fn_tbl.context_ctor = via_init_context;
+ dev->fn_tbl.context_dtor = via_final_context;
+ dev->fn_tbl.vblank_wait = via_driver_vblank_wait;
+ dev->fn_tbl.irq_preinstall = via_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = via_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = via_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = via_driver_irq_handler;
+}