diff options
Diffstat (limited to 'bsd/tdfx')
-rw-r--r-- | bsd/tdfx/Makefile | 4 | ||||
-rw-r--r-- | bsd/tdfx/tdfx_context.c | 23 | ||||
-rw-r--r-- | bsd/tdfx/tdfx_drv.c | 60 | ||||
-rw-r--r-- | bsd/tdfx/tdfx_drv.h | 4 |
4 files changed, 68 insertions, 23 deletions
diff --git a/bsd/tdfx/Makefile b/bsd/tdfx/Makefile index e0ff8ffa..471a5fbf 100644 --- a/bsd/tdfx/Makefile +++ b/bsd/tdfx/Makefile @@ -4,7 +4,7 @@ KMOD = tdfx SRCS = tdfx_drv.c tdfx_context.c SRCS += device_if.h bus_if.h pci_if.h CFLAGS += ${DEBUG_FLAGS} -I.. -KERN = /usr/src/sys +KMODDEPS = drm @: ln -sf /sys @ @@ -12,4 +12,4 @@ KERN = /usr/src/sys machine: ln -sf /sys/i386/include machine -.include "/usr/src/sys/conf/kmod.mk" +.include <bsd.kmod.mk> diff --git a/bsd/tdfx/tdfx_context.c b/bsd/tdfx/tdfx_context.c index 0aecf762..5a334058 100644 --- a/bsd/tdfx/tdfx_context.c +++ b/bsd/tdfx/tdfx_context.c @@ -1,8 +1,8 @@ /* tdfx_context.c -- IOCTLs for tdfx contexts -*- c -*- * Created: Thu Oct 7 10:50:22 1999 by faith@precisioninsight.com - * Revised: Sat Oct 9 23:39:56 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,8 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $PI$ - * $XFree86$ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> * */ @@ -36,9 +37,7 @@ extern drm_ctx_t tdfx_res_ctx; static int tdfx_alloc_queue(drm_device_t *dev) { - static int context = 0; - - return ++context; /* Should this reuse contexts in the future? */ + return drm_ctxbitmap_next(dev); } int tdfx_context_switch(drm_device_t *dev, int old, int new) @@ -135,6 +134,12 @@ tdfx_addctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p) ctx.handle = tdfx_alloc_queue(dev); } DRM_DEBUG("%d\n", ctx.handle); + if (ctx.handle == -1) { + DRM_DEBUG("Not enough free contexts.\n"); + /* Should this return -EBUSY instead? */ + return ENOMEM; + } + *(drm_ctx_t *) data = ctx; return 0; } @@ -189,13 +194,11 @@ tdfx_newctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p) int tdfx_rmctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p) { + drm_device_t *dev = kdev->si_drv1; drm_ctx_t ctx; ctx = *(drm_ctx_t *) data; - DRM_DEBUG("%d\n", ctx.handle); - /* This is currently a noop because we - don't reuse context values. Perhaps we - should? */ + drm_ctxbitmap_free(dev, ctx.handle); return 0; } diff --git a/bsd/tdfx/tdfx_drv.c b/bsd/tdfx/tdfx_drv.c index 573cfcf1..91e7d560 100644 --- a/bsd/tdfx/tdfx_drv.c +++ b/bsd/tdfx/tdfx_drv.c @@ -1,8 +1,8 @@ /* tdfx.c -- tdfx driver -*- c -*- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com - * Revised: Tue Oct 12 08:51:35 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,8 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $PI$ - * $XFree86$ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> * */ @@ -35,13 +36,16 @@ #include <pci/pcivar.h> MODULE_DEPEND(tdfx, drm, 1, 1, 1); +#ifdef DRM_AGP +MODULE_DEPEND(tdfx, agp, 1, 1, 1); +#endif #define TDFX_NAME "tdfx" #define TDFX_DESC "tdfx" #define TDFX_DATE "19991009" -#define TDFX_MAJOR 0 +#define TDFX_MAJOR 1 #define TDFX_MINOR 0 -#define TDFX_PATCHLEVEL 1 +#define TDFX_PATCHLEVEL 0 static int tdfx_init(device_t nbdev); static void tdfx_cleanup(device_t nbdev); @@ -153,6 +157,16 @@ static drm_ioctl_desc_t tdfx_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { tdfx_lock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { tdfx_unlock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, +#ifdef DRM_AGP + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_unbind, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_bind, 1, 1}, +#endif }; #define TDFX_IOCTL_COUNT DRM_ARRAY_SIZE(tdfx_ioctls) @@ -259,6 +273,26 @@ tdfx_takedown(drm_device_t *dev) } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } +#ifdef DRM_AGP + /* Clear AGP information */ + if (dev->agp) { + drm_agp_mem_t *temp; + drm_agp_mem_t *temp_next; + + temp = dev->agp->memory; + while(temp != NULL) { + temp_next = temp->next; + drm_free_agp(temp->handle, temp->pages); + drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); + temp = temp_next; + } + + if (dev->agp->acquired) + agp_release(dev->agp->agpdev); + drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); + dev->agp = NULL; + } +#endif /* Clear vma list (only built for debugging) */ if (dev->vmalist) { @@ -312,8 +346,6 @@ tdfx_takedown(drm_device_t *dev) } lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc); - device_unbusy(dev->device); - return 0; } @@ -323,6 +355,7 @@ static int tdfx_init(device_t nbdev) { drm_device_t *dev = device_get_softc(nbdev); + int retcode; DRM_DEBUG("\n"); @@ -347,6 +380,16 @@ tdfx_init(device_t nbdev) drm_sysctl_init(dev); TAILQ_INIT(&dev->files); +#ifdef DRM_AGP + dev->agp = drm_agp_init(); +#endif + if((retcode = drm_ctxbitmap_init(dev))) { + DRM_ERROR("Cannot allocate memory for context bitmap.\n"); + drm_sysctl_cleanup(dev); + tdfx_takedown(dev); + return retcode; + } + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", TDFX_NAME, TDFX_MAJOR, @@ -372,7 +415,7 @@ tdfx_cleanup(device_t nbdev) DRM_INFO("Module unloaded\n"); - device_busy(dev->device); + drm_ctxbitmap_cleanup(dev); tdfx_takedown(dev); } @@ -447,6 +490,7 @@ tdfx_close(dev_t kdev, int flags, int fmt, struct proc *p) return EBUSY; } simple_unlock(&dev->count_lock); + device_unbusy(dev->device); return tdfx_takedown(dev); } simple_unlock(&dev->count_lock); diff --git a/bsd/tdfx/tdfx_drv.h b/bsd/tdfx/tdfx_drv.h index 213f8ef1..5b27e052 100644 --- a/bsd/tdfx/tdfx_drv.h +++ b/bsd/tdfx/tdfx_drv.h @@ -1,8 +1,8 @@ /* tdfx_drv.h -- Private header for tdfx driver -*- c -*- * Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com - * Revised: Sat Oct 9 23:38:19 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,8 +24,6 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $PI$ - * $XFree86$ * */ |