summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth Hughes <gareth@users.sourceforge.net>2000-12-02 13:10:03 +0000
committerGareth Hughes <gareth@users.sourceforge.net>2000-12-02 13:10:03 +0000
commit6c092aadf6dc810059428120be5097b52b7f544f (patch)
treeed1faedda53970ef43c0dd7c96a18e7fc0f26384
parent0f55b2b20fbf72dcddbe19c97f65111623741721 (diff)
Barebones DRM module for the Rage Pro. Enough to allow the DRI to be
initialized, but no DMA yet. Quote from the server output: ... (0): [drm] installed DRM signal handler (0): [DRI] installation complete (II) ATI(0): Direct rendering enabled ...
-rw-r--r--linux-core/mach64_drv.c9
-rw-r--r--linux/Makefile.linux17
-rw-r--r--linux/driver_tmp.h31
-rw-r--r--linux/mach64_context.c35
-rw-r--r--linux/mach64_drm.h111
-rw-r--r--linux/mach64_drv.c9
6 files changed, 189 insertions, 23 deletions
diff --git a/linux-core/mach64_drv.c b/linux-core/mach64_drv.c
index 10e906016..a0285707e 100644
--- a/linux-core/mach64_drv.c
+++ b/linux-core/mach64_drv.c
@@ -51,9 +51,12 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+#if 0
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 },
+#endif
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
@@ -69,7 +72,9 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { mach64_resctx, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+#if 0
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { mach64_dma, 1, 0 },
+#endif
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { mach64_lock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { mach64_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
@@ -97,6 +102,8 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mach64_ioctls )
+#define HAVE_CTX_BITMAP 1
+
+
#define TAG(x) mach64_##x
#include "driver_tmp.h"
-#include "context_tmp.h"
diff --git a/linux/Makefile.linux b/linux/Makefile.linux
index adf190059..8d378822b 100644
--- a/linux/Makefile.linux
+++ b/linux/Makefile.linux
@@ -11,11 +11,11 @@
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -23,7 +23,7 @@
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
-#
+#
#
# ***** NOTE NOTE NOTE NOTE NOTE *****
# To override the automatic Linux source tree determination, pass the
@@ -47,7 +47,7 @@
# **** End of SMP/MODVERSIONS detection
-MODS= gamma.o tdfx.o r128.o
+MODS= gamma.o tdfx.o r128.o mach64.o
LIBS= libdrm.a
DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \
@@ -63,6 +63,9 @@ TDFXHEADERS= tdfx_drv.h $(DRMHEADERS)
R128OBJS= r128_drv.o r128_dma.o r128_bufs.o r128_context.o
R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS)
+MACH64OBJS= mach64_drv.o mach64_context.o
+MACH64HEADERS= mach64_drv.h mach64_drm.h $(DRMHEADERS)
+
INC= /usr/include
CFLAGS= -O2 $(WARNINGS)
@@ -207,6 +210,11 @@ r128_drv.o: r128_drv.c
r128.o: $(R128OBJS) $(LIBS)
$(LD) -r $^ -o $@
+mach64_drv.o: mach64_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
+mach64.o: $(MACH64OBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+
sis.o: $(SISOBJS) $(LIBS)
$(LD) -r $^ -o $@
@@ -239,6 +247,7 @@ $(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
$(R128OBJS): $(R128HEADERS)
+$(MACH64OBJS): $(MACH64HEADERS)
ifeq ($(AGP),1)
$(MGAOBJS): $(MGAHEADERS)
$(I810OBJS): $(I810HEADERS)
diff --git a/linux/driver_tmp.h b/linux/driver_tmp.h
index 69bc1b775..d54b8fd66 100644
--- a/linux/driver_tmp.h
+++ b/linux/driver_tmp.h
@@ -124,12 +124,12 @@ static struct miscdevice TAG(misc) = {
};
#ifdef MODULE
-static char *TAG(opts) = NULL;
+static char *drm_opts = NULL;
#endif
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_PARM( TAG(opts), "s" );
+MODULE_PARM( drm_opts, "s" );
#ifndef MODULE
/* r128_options is called by the kernel to parse command-line options
@@ -358,10 +358,10 @@ static int TAG(takedown)( drm_device_t *dev )
return 0;
}
-/* r128_init is called via init_module at module load time, or via
- * linux/init/main.c (this is not currently supported). */
-
-static int __init TAG(init)( void )
+/* drm_init is called via init_module at module load time, or via
+ * linux/init/main.c (this is not currently supported).
+ */
+static int __init drm_init( void )
{
int retcode;
drm_device_t *dev = &TAG(device);
@@ -373,7 +373,7 @@ static int __init TAG(init)( void )
sema_init( &dev->struct_sem, 1 );
#ifdef MODULE
- drm_parse_options( TAG(opts) );
+ drm_parse_options( drm_opts );
#endif
DRIVER_PREINIT();
@@ -392,10 +392,7 @@ static int __init TAG(init)( void )
dev->agp = drm_agp_init();
#if MUST_HAVE_AGP
if ( dev->agp == NULL ) {
- DRM_INFO("The mga drm module requires the agpgart module"
- " to function correctly\nPlease load the agpgart"
- " module before you load the mga module\n");
- DRM_ERROR( "Cannot initialize agpgart module.\n" );
+ DRM_ERROR( "Cannot initialize the agpgart module.\n" );
drm_proc_cleanup();
misc_deregister( &TAG(misc) );
TAG(takedown)( dev );
@@ -435,9 +432,9 @@ static int __init TAG(init)( void )
return 0;
}
-/* r128_cleanup is called via cleanup_module at module unload time. */
-
-static void __exit TAG(cleanup)( void )
+/* drm_cleanup is called via cleanup_module at module unload time.
+ */
+static void __exit drm_cleanup( void )
{
drm_device_t *dev = &TAG(device);
@@ -474,8 +471,8 @@ static void __exit TAG(cleanup)( void )
#endif
}
-module_init( TAG(init) );
-module_exit( TAG(cleanup) );
+module_init( drm_init );
+module_exit( drm_cleanup );
int TAG(version)( struct inode *inode, struct file *filp,
@@ -736,7 +733,7 @@ int TAG(lock)( struct inode *inode, struct file *filp,
#if HAVE_DMA_QUEUE
if ( lock.context < 0 )
return -EINVAL;
-#elsif HAVE_MULTIPLE_DMA_QUEUES
+#elif HAVE_MULTIPLE_DMA_QUEUES
if ( lock.context < 0 || lock.context >= dev->queue_count )
return -EINVAL;
q = dev->queuelist[lock.context];
diff --git a/linux/mach64_context.c b/linux/mach64_context.c
new file mode 100644
index 000000000..88521e0c1
--- /dev/null
+++ b/linux/mach64_context.c
@@ -0,0 +1,35 @@
+/* mach64_context.c -- IOCTLs for mach64 contexts -*- linux-c -*-
+ * Created: Thu Nov 30 20:01:35 1999 by gareth@valinux.com
+ *
+ * Copyright 2000 Gareth Hughes
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "mach64_drv.h"
+
+
+#define TAG(x) mach64_##x
+#include "context_tmp.h"
diff --git a/linux/mach64_drm.h b/linux/mach64_drm.h
new file mode 100644
index 000000000..4b2c3891a
--- /dev/null
+++ b/linux/mach64_drm.h
@@ -0,0 +1,111 @@
+/* mach64_drm.h -- Public header for the mach64 driver -*- linux-c -*-
+ * Created: Thu Nov 30 20:04:32 2000 by gareth@valinux.com
+ *
+ * Copyright 2000 Gareth Hughes
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __MACH64_DRM_H__
+#define __MACH64_DRM_H__
+
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmMach64.h)
+ */
+#ifndef __MACH64_DEFINES__
+#define __MACH64_DEFINES__
+
+/* FIXME: fill this in...
+ */
+
+/* Keep these small for testing.
+ */
+#define MACH64_NR_SAREA_CLIPRECTS 8
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (mach64_sarea.h)
+ */
+#define MACH64_CARD_HEAP 0
+#define MACH64_AGP_HEAP 1
+#define MACH64_NR_TEX_HEAPS 2
+#define MACH64_NR_TEX_REGIONS 16
+#define MACH64_LOG_TEX_GRANULARITY 16
+
+#endif
+
+typedef struct drm_mach64_init {
+ enum {
+ MACH64_INIT_DMA = 0x01,
+ MACH64_CLEANUP_DMA = 0x02
+ } func;
+ int sarea_priv_offset;
+ int is_pci;
+ int cpp;
+
+ unsigned int pitch;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+
+ unsigned int texture_offset;
+ unsigned int texture_size;
+
+ unsigned int agp_texture_offset;
+ unsigned int agp_texture_size;
+
+ unsigned int mmio_offset;
+} drm_r128_init_t;
+
+
+typedef struct drm_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ int age;
+} drm_tex_region_t;
+
+typedef struct drm_mach64_sarea {
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex dma buffer.
+ */
+
+ /* FIXME: fill this in... */
+
+ /* The current cliprects, or a subset thereof.
+ */
+ drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
+ unsigned int nbox;
+
+ /* Counters for client-side throttling of rendering clients.
+ */
+ unsigned int last_frame;
+ unsigned int last_dispatch;
+
+ /* Texture memory LRU.
+ */
+ drm_tex_region_t tex_list[MACH64_NR_TEX_HEAPS][MACH64_NR_TEX_REGIONS+1];
+ int tex_age[MACH64_NR_TEX_HEAPS];
+ int ctx_owner;
+} drm_mach64_sarea_t;
+
+#endif
diff --git a/linux/mach64_drv.c b/linux/mach64_drv.c
index 10e906016..a0285707e 100644
--- a/linux/mach64_drv.c
+++ b/linux/mach64_drv.c
@@ -51,9 +51,12 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+#if 0
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 },
+#endif
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
@@ -69,7 +72,9 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { mach64_resctx, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+#if 0
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { mach64_dma, 1, 0 },
+#endif
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { mach64_lock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { mach64_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
@@ -97,6 +102,8 @@ static drm_ioctl_desc_t mach64_ioctls[] = {
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mach64_ioctls )
+#define HAVE_CTX_BITMAP 1
+
+
#define TAG(x) mach64_##x
#include "driver_tmp.h"
-#include "context_tmp.h"