# Makefile for the drm device driver. This driver provides support for
# the Direct Rendering Infrastructure (DRI) in XFree86 4.x.
#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now inherited from the
-# parent makes..
-#
-
-O_OBJS :=
-OX_OBJS :=
-M_OBJS :=
-MX_OBJS :=
-
-# Object file lists.
-
-obj-y :=
-obj-m :=
-obj-n :=
-obj- :=
-
-SUB_DIRS :=
-MOD_SUB_DIRS := $(SUB_DIRS)
-ALL_SUB_DIRS := $(SUB_DIRS)
+# drm.o is a fake target -- it is never built
+# The real targets are in the module-list
O_TARGET := drm.o
module-list := gamma.o tdfx.o r128.o ffb.o mga.o i810.o
export-objs := $(patsubst %.o,%_drv.o,$(module-list))
+# libs-objs are included in every module so that radical changes to the
+# architecture of the DRM support library can be made at a later time.
+#
+# The downside is that each module is larger, and a system that uses
+# more than one module (i.e., a dual-head system) will use more memory
+# (but a system that uses exactly one module will use the same amount of
+# memory).
+#
+# The upside is that if the DRM support library ever becomes insufficient
+# for new families of cards, a new library can be implemented for those new
+# cards without impacting the drivers for the old cards. This is significant,
+# because testing architectural changes to old cards may be impossible, and
+# may delay the implementation of a better architecture. We've traded slight
+# memory waste (in the dual-head case) for greatly improved long-term
+# maintainability.
+#
lib-objs := init.o memory.o proc.o auth.o context.o drawable.o bufs.o
lib-objs += lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o
-ifneq ($(CONFIG_AGP),)
+ifeq ($(CONFIG_AGP),y)
lib-objs += agpsupport.o
+else
+ ifeq ($(CONFIG_AGP),m)
+ lib-objs += agpsupport.o
+ endif
endif
gamma-objs := $(lib-objs) gamma_drv.o gamma_dma.o
include $(TOPDIR)/Rules.make
gamma.o: $(gamma-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(gamma-objs)
+ $(LD) -r -o $@ $(gamma-objs)
tdfx.o: $(tdfx-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(tdfx-objs)
+ $(LD) -r -o $@ $(tdfx-objs)
mga.o: $(mga-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(mga-objs)
+ $(LD) -r -o $@ $(mga-objs)
i810.o: $(i810-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(i810-objs)
+ $(LD) -r -o $@ $(i810-objs)
r128.o: $(r128-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(r128-objs)
+ $(LD) -r -o $@ $(r128-objs)
ffb.o: $(ffb-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(ffb-objs)
+ $(LD) -r -o $@ $(ffb-objs)
#include <linux/pci.h>
#include <linux/wrapper.h>
#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <asm/io.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
#include <asm/mtrr.h>
#endif
#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
-#define DRM_AGP
-#endif
-#ifdef DRM_AGP
#include <linux/types.h>
#include <linux/agp_backend.h>
#endif
wait_queue_head_t waiting; /* Processes waiting on free bufs */
} drm_device_dma_t;
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
typedef struct drm_agp_mem {
unsigned long handle;
agp_memory *memory;
/* Context support */
int irq; /* Interrupt used by board */
- __volatile__ int context_flag; /* Context swapping flag */
- __volatile__ int interrupt_flag;/* Interruption handler flag */
- __volatile__ int dma_flag; /* DMA dispatch flag */
+ __volatile__ long context_flag; /* Context swapping flag */
+ __volatile__ long interrupt_flag; /* Interruption handler flag */
+ __volatile__ long dma_flag; /* DMA dispatch flag */
struct timer_list timer; /* Timer for delaying ctx switch */
wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
int last_checked; /* Last context checked for DMA */
wait_queue_head_t buf_readers; /* Processes waiting to read */
wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
drm_agp_head_t *agp;
#endif
unsigned long *ctx_bitmap;
extern void *drm_ioremap(unsigned long offset, unsigned long size);
extern void drm_ioremapfree(void *pt, unsigned long size);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
extern agp_memory *drm_alloc_agp(int pages, u32 type);
extern int drm_free_agp(agp_memory *handle, int pages);
extern int drm_bind_agp(agp_memory *handle, unsigned int start);
extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
extern int drm_context_switch(drm_device_t *dev, int old, int new);
extern int drm_context_switch_complete(drm_device_t *dev, int new);
-extern void drm_wakeup(drm_device_t *dev, drm_buf_t *buf);
extern void drm_clear_next_buffer(drm_device_t *dev);
extern int drm_select_queue(drm_device_t *dev,
void (*wrapper)(unsigned long));
extern int drm_ctxbitmap_next(drm_device_t *dev);
extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* AGP/GART support (agpsupport.c) */
extern drm_agp_head_t *drm_agp_init(void);
extern void drm_agp_uninit(void);
#define __NO_VERSION__
#include "drmP.h"
#include "i810_drv.h"
-
#include <linux/interrupt.h> /* For task queue support */
/* in case we don't have a 2.3.99-pre6 kernel or later: */
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_i810_private_t *dev_priv = dev->dev_private;
- drm_buf_t *buf = dev_priv->mmap_buffer;
- drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev;
+ drm_i810_private_t *dev_priv;
+ drm_buf_t *buf;
+ drm_i810_buf_priv_t *buf_priv;
+
+ lock_kernel();
+ dev = priv->dev;
+ dev_priv = dev->dev_private;
+ buf = dev_priv->mmap_buffer;
+ buf_priv = buf->dev_private;
vma->vm_flags |= (VM_IO | VM_DONTCOPY);
vma->vm_file = filp;
buf_priv->currently_mapped = I810_BUF_MAPPED;
+ unlock_kernel();
if (remap_page_range(vma->vm_start,
VM_OFFSET(vma),
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "i810_drv.h"
-
-EXPORT_SYMBOL(i810_init);
-EXPORT_SYMBOL(i810_cleanup);
-
#define I810_NAME "i810"
#define I810_DESC "Intel I810"
#define I810_DATE "20000719"
MODULE_DESCRIPTION("Intel I810");
MODULE_PARM(i810, "s");
-module_init(i810_init);
-module_exit(i810_cleanup);
-
#ifndef MODULE
/* i810_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
/* i810_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int i810_init(void)
+static int i810_init(void)
{
int retcode;
drm_device_t *dev = &i810_device;
/* i810_cleanup is called via cleanup_module at module unload time. */
-void i810_cleanup(void)
+static void i810_cleanup(void)
{
drm_device_t *dev = &i810_device;
}
}
+module_init(i810_init);
+module_exit(i810_cleanup);
+
+
int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int i810_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
current->pid, dev->device, dev->open_count);
up(&dev->struct_sem);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- return i810_takedown(dev);
+ unlock_kernel();
+ return i810_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ spin_unlock(&dev->count_lock);
+ unlock_kernel();
return retcode;
}
} drm_i810_private_t;
/* i810_drv.c */
-extern int i810_init(void);
-extern void i810_cleanup(void);
extern int i810_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_open(struct inode *inode, struct file *filp);
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "mga_drv.h"
-EXPORT_SYMBOL(mga_init);
-EXPORT_SYMBOL(mga_cleanup);
#define MGA_NAME "mga"
#define MGA_DESC "Matrox g200/g400"
MODULE_DESCRIPTION("Matrox g200/g400");
MODULE_PARM(mga, "s");
-module_init(mga_init);
-module_exit(mga_cleanup);
-
#ifndef MODULE
/* mga_options is called by the kernel to parse command-line options passed
* via the boot-loader (e.g., LILO). It calls the insmod option routine,
/* mga_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int mga_init(void)
+static int mga_init(void)
{
int retcode;
drm_device_t *dev = &mga_device;
/* mga_cleanup is called via cleanup_module at module unload time. */
-void mga_cleanup(void)
+static void mga_cleanup(void)
{
drm_device_t *dev = &mga_device;
}
}
+module_init(mga_init);
+module_exit(mga_cleanup);
+
+
int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int mga_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
current->pid, dev->device, dev->open_count);
up(&dev->struct_sem);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return mga_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ spin_unlock(&dev->count_lock);
+ unlock_kernel();
return retcode;
}
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "r128_drv.h"
-EXPORT_SYMBOL(r128_init);
-EXPORT_SYMBOL(r128_cleanup);
#define R128_NAME "r128"
#define R128_DESC "ATI Rage 128"
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
[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 },
MODULE_DESCRIPTION("r128");
MODULE_PARM(r128, "s");
-module_init(r128_init);
-module_exit(r128_cleanup);
-
#ifndef MODULE
/* r128_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* Clear AGP information */
if (dev->agp) {
drm_agp_mem_t *entry;
/* r128_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int r128_init(void)
+static int r128_init(void)
{
int retcode;
drm_device_t *dev = &r128_device;
drm_mem_init();
drm_proc_init(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
dev->agp = drm_agp_init();
if (dev->agp == NULL) {
DRM_ERROR("Cannot initialize agpgart module.\n");
/* r128_cleanup is called via cleanup_module at module unload time. */
-void r128_cleanup(void)
+static void r128_cleanup(void)
{
drm_device_t *dev = &r128_device;
}
drm_ctxbitmap_cleanup(dev);
r128_takedown(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
if (dev->agp) {
drm_agp_uninit();
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
#endif
}
+module_init(r128_init);
+module_exit(r128_cleanup);
+
+
int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
}
spin_unlock(&dev->count_lock);
}
+
return retcode;
}
int r128_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return r128_takedown(dev);
}
spin_unlock(&dev->count_lock);
}
+
+ unlock_kernel();
return retcode;
}
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "tdfx_drv.h"
-EXPORT_SYMBOL(tdfx_init);
-EXPORT_SYMBOL(tdfx_cleanup);
#define TDFX_NAME "tdfx"
#define TDFX_DESC "3dfx Banshee/Voodoo3+"
[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
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
[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},
MODULE_DESCRIPTION("tdfx");
MODULE_PARM(tdfx, "s");
-module_init(tdfx_init);
-module_exit(tdfx_cleanup);
-
#ifndef MODULE
/* tdfx_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* Clear AGP information */
if (dev->agp) {
drm_agp_mem_t *temp;
/* tdfx_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int tdfx_init(void)
+static int tdfx_init(void)
{
int retcode;
drm_device_t *dev = &tdfx_device;
drm_mem_init();
drm_proc_init(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
dev->agp = drm_agp_init();
#endif
if((retcode = drm_ctxbitmap_init(dev))) {
/* tdfx_cleanup is called via cleanup_module at module unload time. */
-void tdfx_cleanup(void)
+static void tdfx_cleanup(void)
{
drm_device_t *dev = &tdfx_device;
}
drm_ctxbitmap_cleanup(dev);
tdfx_takedown(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
if (dev->agp) {
drm_agp_uninit();
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
#endif
}
+module_init(tdfx_init);
+module_exit(tdfx_cleanup);
+
+
int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int tdfx_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
+
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return tdfx_takedown(dev);
}
spin_unlock(&dev->count_lock);
}
+
+ unlock_kernel();
return retcode;
}
# Makefile for the drm device driver. This driver provides support for
# the Direct Rendering Infrastructure (DRI) in XFree86 4.x.
#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (ie not a .c file).
-#
-# Note 2! The CFLAGS definitions are now inherited from the
-# parent makes..
-#
-
-O_OBJS :=
-OX_OBJS :=
-M_OBJS :=
-MX_OBJS :=
-
-# Object file lists.
-
-obj-y :=
-obj-m :=
-obj-n :=
-obj- :=
-
-SUB_DIRS :=
-MOD_SUB_DIRS := $(SUB_DIRS)
-ALL_SUB_DIRS := $(SUB_DIRS)
+# drm.o is a fake target -- it is never built
+# The real targets are in the module-list
O_TARGET := drm.o
module-list := gamma.o tdfx.o r128.o ffb.o mga.o i810.o
export-objs := $(patsubst %.o,%_drv.o,$(module-list))
+# libs-objs are included in every module so that radical changes to the
+# architecture of the DRM support library can be made at a later time.
+#
+# The downside is that each module is larger, and a system that uses
+# more than one module (i.e., a dual-head system) will use more memory
+# (but a system that uses exactly one module will use the same amount of
+# memory).
+#
+# The upside is that if the DRM support library ever becomes insufficient
+# for new families of cards, a new library can be implemented for those new
+# cards without impacting the drivers for the old cards. This is significant,
+# because testing architectural changes to old cards may be impossible, and
+# may delay the implementation of a better architecture. We've traded slight
+# memory waste (in the dual-head case) for greatly improved long-term
+# maintainability.
+#
lib-objs := init.o memory.o proc.o auth.o context.o drawable.o bufs.o
lib-objs += lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o
-ifneq ($(CONFIG_AGP),)
+ifeq ($(CONFIG_AGP),y)
lib-objs += agpsupport.o
+else
+ ifeq ($(CONFIG_AGP),m)
+ lib-objs += agpsupport.o
+ endif
endif
gamma-objs := $(lib-objs) gamma_drv.o gamma_dma.o
include $(TOPDIR)/Rules.make
gamma.o: $(gamma-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(gamma-objs)
+ $(LD) -r -o $@ $(gamma-objs)
tdfx.o: $(tdfx-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(tdfx-objs)
+ $(LD) -r -o $@ $(tdfx-objs)
mga.o: $(mga-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(mga-objs)
+ $(LD) -r -o $@ $(mga-objs)
i810.o: $(i810-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(i810-objs)
+ $(LD) -r -o $@ $(i810-objs)
r128.o: $(r128-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(r128-objs)
+ $(LD) -r -o $@ $(r128-objs)
ffb.o: $(ffb-objs)
- $(LD) $(LD_RFLAG) -r -o $@ $(ffb-objs)
+ $(LD) -r -o $@ $(ffb-objs)
CFLAGS= -O2 $(WARNINGS)
WARNINGS= -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \
- -Wstrict-prototypes -Wshadow -Wnested-externs \
- -Winline -Wpointer-arith
+ -Wstrict-prototypes -Wnested-externs \
+ -Wpointer-arith
+# -Wshadow -Winline -- make output too noisy
MODCFLAGS= $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer
PRGCFLAGS= $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
-D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
endif
ifeq ($(AGP),1)
-MODCFLAGS += -DDRM_AGP
+MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE
DRMOBJS += agpsupport.o
MODS += mga.o i810.o
-$(RM) -f $@
$(AR) rcs $@ $(DRMOBJS)
+gamma_drv.o: gamma_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
gamma.o: $(GAMMAOBJS) $(LIBS)
$(LD) -r $^ -o $@
+tdfx_drv.o: tdfx_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
tdfx.o: $(TDFXOBJS) $(LIBS)
$(LD) -r $^ -o $@
+r128_drv.o: r128_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
r128.o: $(R128OBJS) $(LIBS)
$(LD) -r $^ -o $@
ifeq ($(AGP),1)
+mga_drv.o: mga_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
mga.o: $(MGAOBJS) $(LIBS)
$(LD) -r $^ -o $@
+i810_drv.o: i810_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
i810.o: $(I810OBJS) $(LIBS)
$(LD) -r $^ -o $@
endif
%.po: %.c
$(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@
-
$(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
#define __NO_VERSION__
#include "drmP.h"
+#include <linux/module.h>
drm_agp_func_t drm_agp = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
dev->lock.hw_lock = map->handle; /* Pointer to lock */
}
break;
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
case _DRM_AGP:
map->offset = map->offset + dev->agp->base;
break;
#include <linux/pci.h>
#include <linux/wrapper.h>
#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <asm/io.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
#include <asm/mtrr.h>
#endif
#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
-#define DRM_AGP
-#endif
-#ifdef DRM_AGP
#include <linux/types.h>
#include <linux/agp_backend.h>
#endif
wait_queue_head_t waiting; /* Processes waiting on free bufs */
} drm_device_dma_t;
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
typedef struct drm_agp_mem {
unsigned long handle;
agp_memory *memory;
/* Context support */
int irq; /* Interrupt used by board */
- __volatile__ int context_flag; /* Context swapping flag */
- __volatile__ int interrupt_flag;/* Interruption handler flag */
- __volatile__ int dma_flag; /* DMA dispatch flag */
+ __volatile__ long context_flag; /* Context swapping flag */
+ __volatile__ long interrupt_flag; /* Interruption handler flag */
+ __volatile__ long dma_flag; /* DMA dispatch flag */
struct timer_list timer; /* Timer for delaying ctx switch */
wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
int last_checked; /* Last context checked for DMA */
wait_queue_head_t buf_readers; /* Processes waiting to read */
wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
drm_agp_head_t *agp;
#endif
unsigned long *ctx_bitmap;
extern void *drm_ioremap(unsigned long offset, unsigned long size);
extern void drm_ioremapfree(void *pt, unsigned long size);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
extern agp_memory *drm_alloc_agp(int pages, u32 type);
extern int drm_free_agp(agp_memory *handle, int pages);
extern int drm_bind_agp(agp_memory *handle, unsigned int start);
extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
extern int drm_context_switch(drm_device_t *dev, int old, int new);
extern int drm_context_switch_complete(drm_device_t *dev, int new);
-extern void drm_wakeup(drm_device_t *dev, drm_buf_t *buf);
extern void drm_clear_next_buffer(drm_device_t *dev);
extern int drm_select_queue(drm_device_t *dev,
void (*wrapper)(unsigned long));
extern int drm_ctxbitmap_next(drm_device_t *dev);
extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* AGP/GART support (agpsupport.c) */
extern drm_agp_head_t *drm_agp_init(void);
extern void drm_agp_uninit(void);
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "gamma_drv.h"
-#include <linux/pci.h>
-#include <linux/smp_lock.h> /* For (un)lock_kernel */
-EXPORT_SYMBOL(gamma_init);
-EXPORT_SYMBOL(gamma_cleanup);
#ifndef PCI_DEVICE_ID_3DLABS_GAMMA
#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
MODULE_PARM(devices, "i");
MODULE_PARM_DESC(devices,
"devices=x, where x is the number of MX chips on card\n");
-
-module_init(gamma_init);
-module_exit(gamma_cleanup);
-
#ifndef MODULE
/* gamma_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
/* gamma_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int gamma_init(void)
+static int gamma_init(void)
{
int retcode;
drm_device_t *dev = &gamma_device;
/* gamma_cleanup is called via cleanup_module at module unload time. */
-void gamma_cleanup(void)
+static void gamma_cleanup(void)
{
drm_device_t *dev = &gamma_device;
gamma_takedown(dev);
}
+module_init(gamma_init);
+module_exit(gamma_cleanup);
+
+
int gamma_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int gamma_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
- DRM_DEBUG("open_count = %d\n", dev->open_count);
lock_kernel();
+ dev = priv->dev;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- retcode = gamma_takedown(dev);
unlock_kernel();
- return retcode;
+ return gamma_takedown(dev);
}
spin_unlock(&dev->count_lock);
}
#define _GAMMA_DRV_H_
/* gamma_drv.c */
-extern int gamma_init(void);
-extern void gamma_cleanup(void);
extern int gamma_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int gamma_open(struct inode *inode, struct file *filp);
*
*/
-#include <linux/sched.h>
-
#define __NO_VERSION__
#include "drmP.h"
#include "i810_drv.h"
#define __NO_VERSION__
#include "drmP.h"
#include "i810_drv.h"
-
#include <linux/interrupt.h> /* For task queue support */
/* in case we don't have a 2.3.99-pre6 kernel or later: */
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_i810_private_t *dev_priv = dev->dev_private;
- drm_buf_t *buf = dev_priv->mmap_buffer;
- drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev;
+ drm_i810_private_t *dev_priv;
+ drm_buf_t *buf;
+ drm_i810_buf_priv_t *buf_priv;
+
+ lock_kernel();
+ dev = priv->dev;
+ dev_priv = dev->dev_private;
+ buf = dev_priv->mmap_buffer;
+ buf_priv = buf->dev_private;
vma->vm_flags |= (VM_IO | VM_DONTCOPY);
vma->vm_file = filp;
buf_priv->currently_mapped = I810_BUF_MAPPED;
+ unlock_kernel();
if (remap_page_range(vma->vm_start,
VM_OFFSET(vma),
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "i810_drv.h"
-
-EXPORT_SYMBOL(i810_init);
-EXPORT_SYMBOL(i810_cleanup);
-
#define I810_NAME "i810"
#define I810_DESC "Intel I810"
#define I810_DATE "20000719"
MODULE_DESCRIPTION("Intel I810");
MODULE_PARM(i810, "s");
-module_init(i810_init);
-module_exit(i810_cleanup);
-
#ifndef MODULE
/* i810_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
/* i810_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int i810_init(void)
+static int i810_init(void)
{
int retcode;
drm_device_t *dev = &i810_device;
/* i810_cleanup is called via cleanup_module at module unload time. */
-void i810_cleanup(void)
+static void i810_cleanup(void)
{
drm_device_t *dev = &i810_device;
}
}
+module_init(i810_init);
+module_exit(i810_cleanup);
+
+
int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int i810_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
current->pid, dev->device, dev->open_count);
up(&dev->struct_sem);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
- return i810_takedown(dev);
+ unlock_kernel();
+ return i810_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ spin_unlock(&dev->count_lock);
+ unlock_kernel();
return retcode;
}
} drm_i810_private_t;
/* i810_drv.c */
-extern int i810_init(void);
-extern void i810_cleanup(void);
extern int i810_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_open(struct inode *inode, struct file *filp);
*/
#define __NO_VERSION__
+#include <linux/config.h>
#include "drmP.h"
typedef struct drm_mem_stats {
}
}
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
agp_memory *drm_alloc_agp(int pages, u32 type)
{
agp_memory *handle;
*
*/
-#include <linux/sched.h>
-
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "mga_drv.h"
-EXPORT_SYMBOL(mga_init);
-EXPORT_SYMBOL(mga_cleanup);
#define MGA_NAME "mga"
#define MGA_DESC "Matrox g200/g400"
MODULE_DESCRIPTION("Matrox g200/g400");
MODULE_PARM(mga, "s");
-module_init(mga_init);
-module_exit(mga_cleanup);
-
#ifndef MODULE
/* mga_options is called by the kernel to parse command-line options passed
* via the boot-loader (e.g., LILO). It calls the insmod option routine,
/* mga_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int mga_init(void)
+static int mga_init(void)
{
int retcode;
drm_device_t *dev = &mga_device;
/* mga_cleanup is called via cleanup_module at module unload time. */
-void mga_cleanup(void)
+static void mga_cleanup(void)
{
drm_device_t *dev = &mga_device;
}
}
+module_init(mga_init);
+module_exit(mga_cleanup);
+
+
int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int mga_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
current->pid, dev->device, dev->open_count);
up(&dev->struct_sem);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return mga_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ spin_unlock(&dev->count_lock);
+ unlock_kernel();
return retcode;
}
} drm_mga_private_t;
/* mga_drv.c */
-extern int mga_init(void);
-extern void mga_cleanup(void);
extern int mga_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int mga_open(struct inode *inode, struct file *filp);
} else {
DRM_PROC_PRINT("lock none\n");
}
- DRM_PROC_PRINT("context_flag 0x%08x\n", dev->context_flag);
- DRM_PROC_PRINT("interrupt_flag 0x%08x\n", dev->interrupt_flag);
- DRM_PROC_PRINT("dma_flag 0x%08x\n", dev->dma_flag);
+ DRM_PROC_PRINT("context_flag 0x%08lx\n", dev->context_flag);
+ DRM_PROC_PRINT("interrupt_flag 0x%08lx\n", dev->interrupt_flag);
+ DRM_PROC_PRINT("dma_flag 0x%08lx\n", dev->dma_flag);
DRM_PROC_PRINT("queue_count %10d\n", dev->queue_count);
DRM_PROC_PRINT("last_context %10d\n", dev->last_context);
*/
#define __NO_VERSION__
+#include <linux/config.h>
#include "drmP.h"
#include "r128_drv.h"
#include "linux/un.h"
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
int r128_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
sizeof(request),
-EFAULT);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
if (request.flags & _DRM_AGP_BUFFER)
return r128_addbufs_agp(inode, filp, cmd, arg);
else
*
*/
-#include <linux/sched.h>
-
#define __NO_VERSION__
#include "drmP.h"
#include "r128_drv.h"
static int r128_alloc_queue(drm_device_t *dev)
{
-#if 0
- static int context = 0;
-#endif
-
return drm_ctxbitmap_next(dev);
}
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "r128_drv.h"
-EXPORT_SYMBOL(r128_init);
-EXPORT_SYMBOL(r128_cleanup);
#define R128_NAME "r128"
#define R128_DESC "ATI Rage 128"
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
[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 },
MODULE_DESCRIPTION("r128");
MODULE_PARM(r128, "s");
-module_init(r128_init);
-module_exit(r128_cleanup);
-
#ifndef MODULE
/* r128_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* Clear AGP information */
if (dev->agp) {
drm_agp_mem_t *entry;
/* r128_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int r128_init(void)
+static int r128_init(void)
{
int retcode;
drm_device_t *dev = &r128_device;
drm_mem_init();
drm_proc_init(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
dev->agp = drm_agp_init();
if (dev->agp == NULL) {
DRM_ERROR("Cannot initialize agpgart module.\n");
/* r128_cleanup is called via cleanup_module at module unload time. */
-void r128_cleanup(void)
+static void r128_cleanup(void)
{
drm_device_t *dev = &r128_device;
}
drm_ctxbitmap_cleanup(dev);
r128_takedown(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
if (dev->agp) {
drm_agp_uninit();
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
#endif
}
+module_init(r128_init);
+module_exit(r128_cleanup);
+
+
int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
}
spin_unlock(&dev->count_lock);
}
+
return retcode;
}
int r128_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return r128_takedown(dev);
}
spin_unlock(&dev->count_lock);
}
+
+ unlock_kernel();
return retcode;
}
} drm_r128_buf_priv_t;
/* r128_drv.c */
-extern int r128_init(void);
-extern void r128_cleanup(void);
extern int r128_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int r128_open(struct inode *inode, struct file *filp);
*
*/
-#include <linux/sched.h>
-
#define __NO_VERSION__
#include "drmP.h"
#include "tdfx_drv.h"
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "tdfx_drv.h"
-EXPORT_SYMBOL(tdfx_init);
-EXPORT_SYMBOL(tdfx_cleanup);
#define TDFX_NAME "tdfx"
#define TDFX_DESC "3dfx Banshee/Voodoo3+"
[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
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
[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},
MODULE_DESCRIPTION("tdfx");
MODULE_PARM(tdfx, "s");
-module_init(tdfx_init);
-module_exit(tdfx_cleanup);
-
#ifndef MODULE
/* tdfx_options is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
/* Clear AGP information */
if (dev->agp) {
drm_agp_mem_t *temp;
/* tdfx_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
-int tdfx_init(void)
+static int tdfx_init(void)
{
int retcode;
drm_device_t *dev = &tdfx_device;
drm_mem_init();
drm_proc_init(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
dev->agp = drm_agp_init();
#endif
if((retcode = drm_ctxbitmap_init(dev))) {
/* tdfx_cleanup is called via cleanup_module at module unload time. */
-void tdfx_cleanup(void)
+static void tdfx_cleanup(void)
{
drm_device_t *dev = &tdfx_device;
}
drm_ctxbitmap_cleanup(dev);
tdfx_takedown(dev);
-#ifdef DRM_AGP
+#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
if (dev->agp) {
drm_agp_uninit();
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
#endif
}
+module_init(tdfx_init);
+module_exit(tdfx_cleanup);
+
+
int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
int tdfx_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
+
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return tdfx_takedown(dev);
}
spin_unlock(&dev->count_lock);
}
+
+ unlock_kernel();
return retcode;
}
#define _TDFX_DRV_H_
/* tdfx_drv.c */
-extern int tdfx_init(void);
-extern void tdfx_cleanup(void);
extern int tdfx_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int tdfx_open(struct inode *inode, struct file *filp);
DRM_DEBUG("0x%08lx,0x%08lx\n",
vma->vm_start, vma->vm_end - vma->vm_start);
atomic_inc(&dev->vma_count);
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ /* The map can exist after the fd is closed. */
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
+
#if DRM_DEBUG_CODE
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
DRM_DEBUG("0x%08lx,0x%08lx\n",
vma->vm_start, vma->vm_end - vma->vm_start);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_dec(&dev->vma_count);
#if DRM_DEBUG_CODE
int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
+ drm_device_t *dev;
+ drm_device_dma_t *dma;
unsigned long length = vma->vm_end - vma->vm_start;
+ lock_kernel();
+ dev = priv->dev;
+ dma = dev->dma;
DRM_DEBUG("start = 0x%lx, end = 0x%lx, offset = 0x%lx\n",
vma->vm_start, vma->vm_end, VM_OFFSET(vma));
/* Length must match exact page count */
- if ((length >> PAGE_SHIFT) != dma->page_count) return -EINVAL;
+ if ((length >> PAGE_SHIFT) != dma->page_count) {
+ unlock_kernel();
+ return -EINVAL;
+ }
+ unlock_kernel();
vma->vm_ops = &drm_vm_dma_ops;
vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */