Sync with Linux 2.4.0-test6-pre2

main
Rik Faith 2000-08-04 10:04:55 +00:00
parent bcad118182
commit f3ae6786f8
32 changed files with 333 additions and 283 deletions

View File

@ -2,39 +2,38 @@
# 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
@ -71,19 +70,19 @@ MIX_OBJS := $(sort $(filter $(export-objs), $(int-m)))
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)

View File

@ -44,6 +44,8 @@
#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>
@ -51,9 +53,6 @@
#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
@ -410,7 +409,7 @@ typedef struct drm_device_dma {
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;
@ -499,9 +498,9 @@ typedef struct drm_device {
/* 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 */
@ -524,7 +523,7 @@ typedef struct drm_device {
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;
@ -601,7 +600,7 @@ extern void drm_free_pages(unsigned long address, int order,
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);
@ -644,7 +643,6 @@ extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
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));
@ -725,7 +723,7 @@ extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
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);

View File

@ -33,7 +33,6 @@
#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: */
@ -156,16 +155,23 @@ static struct file_operations i810_buffer_fops = {
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),

View File

@ -30,16 +30,9 @@
*/
#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"
@ -132,9 +125,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -348,7 +338,7 @@ static int i810_takedown(drm_device_t *dev)
/* 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;
@ -407,7 +397,7 @@ int i810_init(void)
/* 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;
@ -428,6 +418,10 @@ void i810_cleanup(void)
}
}
module_init(i810_init);
module_exit(i810_cleanup);
int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -469,7 +463,9 @@ int i810_open(struct inode *inode, struct file *filp)
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++) {
@ -484,9 +480,11 @@ int i810_open(struct inode *inode, struct file *filp)
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);
@ -548,7 +546,9 @@ int i810_release(struct inode *inode, struct file *filp)
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) {
@ -557,12 +557,15 @@ int i810_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -77,8 +77,6 @@ typedef struct drm_i810_private {
} 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);

View File

@ -31,13 +31,8 @@
*/
#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"
@ -131,9 +126,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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,
@ -345,7 +337,7 @@ static int mga_takedown(drm_device_t *dev)
/* 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;
@ -410,7 +402,7 @@ int mga_init(void)
/* 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;
@ -442,6 +434,10 @@ void mga_cleanup(void)
}
}
module_init(mga_init);
module_exit(mga_cleanup);
int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -483,7 +479,9 @@ int mga_open(struct inode *inode, struct file *filp)
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++) {
@ -498,9 +496,11 @@ int mga_open(struct inode *inode, struct file *filp)
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);
@ -562,7 +562,9 @@ int mga_release(struct inode *inode, struct file *filp)
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) {
@ -571,12 +573,15 @@ int mga_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -30,13 +30,8 @@
*/
#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"
@ -99,7 +94,7 @@ static drm_ioctl_desc_t r128_ioctls[] = {
[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 },
@ -127,9 +122,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -244,7 +236,7 @@ static int r128_takedown(drm_device_t *dev)
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;
@ -331,7 +323,7 @@ static int r128_takedown(drm_device_t *dev)
/* 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;
@ -356,7 +348,7 @@ int r128_init(void)
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");
@ -395,7 +387,7 @@ int r128_init(void)
/* 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;
@ -409,7 +401,7 @@ void r128_cleanup(void)
}
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);
@ -418,6 +410,10 @@ void r128_cleanup(void)
#endif
}
module_init(r128_init);
module_exit(r128_cleanup);
int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -459,7 +455,9 @@ int r128_open(struct inode *inode, struct file *filp)
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++) {
@ -468,18 +466,23 @@ int r128_open(struct inode *inode, struct file *filp)
}
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) {
@ -488,13 +491,17 @@ int r128_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -31,13 +31,8 @@
*/
#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+"
@ -94,7 +89,7 @@ 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
#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},
@ -115,9 +110,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -230,7 +222,7 @@ static int tdfx_takedown(drm_device_t *dev)
}
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;
@ -306,7 +298,7 @@ static int tdfx_takedown(drm_device_t *dev)
/* 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;
@ -330,7 +322,7 @@ int tdfx_init(void)
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))) {
@ -354,7 +346,7 @@ int tdfx_init(void)
/* 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;
@ -368,7 +360,7 @@ void tdfx_cleanup(void)
}
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);
@ -377,6 +369,10 @@ void tdfx_cleanup(void)
#endif
}
module_init(tdfx_init);
module_exit(tdfx_cleanup);
int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -418,7 +414,9 @@ int tdfx_open(struct inode *inode, struct file *filp)
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++) {
@ -433,12 +431,17 @@ int tdfx_open(struct inode *inode, struct file *filp)
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) {
@ -447,13 +450,17 @@ int tdfx_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -2,39 +2,38 @@
# 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
@ -71,19 +70,19 @@ MIX_OBJS := $(sort $(filter $(export-objs), $(int-m)))
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)

View File

@ -71,8 +71,9 @@ INC= /usr/include
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 \
@ -128,7 +129,7 @@ AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
endif
ifeq ($(AGP),1)
MODCFLAGS += -DDRM_AGP
MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE
DRMOBJS += agpsupport.o
MODS += mga.o i810.o
@ -164,19 +165,29 @@ libdrm.a: $(DRMOBJS)
-$(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
@ -200,7 +211,6 @@ ChangeLog:
%.po: %.c
$(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@
$(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)

View File

@ -30,6 +30,7 @@
#define __NO_VERSION__
#include "drmP.h"
#include <linux/module.h>
drm_agp_func_t drm_agp = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };

View File

@ -106,7 +106,7 @@ int drm_addmap(struct inode *inode, struct file *filp, unsigned int cmd,
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;

View File

@ -44,6 +44,8 @@
#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>
@ -51,9 +53,6 @@
#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
@ -410,7 +409,7 @@ typedef struct drm_device_dma {
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;
@ -499,9 +498,9 @@ typedef struct drm_device {
/* 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 */
@ -524,7 +523,7 @@ typedef struct drm_device {
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;
@ -601,7 +600,7 @@ extern void drm_free_pages(unsigned long address, int order,
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);
@ -644,7 +643,6 @@ extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
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));
@ -725,7 +723,7 @@ extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
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);

View File

@ -30,15 +30,8 @@
*/
#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
@ -122,10 +115,6 @@ MODULE_PARM(gamma, "s");
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
@ -350,7 +339,7 @@ int gamma_find_devices(void)
/* 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;
@ -391,7 +380,7 @@ int gamma_init(void)
/* 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;
@ -406,6 +395,10 @@ void gamma_cleanup(void)
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)
{
@ -447,7 +440,9 @@ int gamma_open(struct inode *inode, struct file *filp)
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++) {
@ -462,13 +457,17 @@ int gamma_open(struct inode *inode, struct file *filp)
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) {
@ -481,9 +480,8 @@ int gamma_release(struct inode *inode, struct file *filp)
return -EBUSY;
}
spin_unlock(&dev->count_lock);
retcode = gamma_takedown(dev);
unlock_kernel();
return retcode;
return gamma_takedown(dev);
}
spin_unlock(&dev->count_lock);
}

View File

@ -33,8 +33,6 @@
#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);

View File

@ -29,8 +29,6 @@
*
*/
#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "i810_drv.h"

View File

@ -33,7 +33,6 @@
#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: */
@ -156,16 +155,23 @@ static struct file_operations i810_buffer_fops = {
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),

View File

@ -30,16 +30,9 @@
*/
#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"
@ -132,9 +125,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -348,7 +338,7 @@ static int i810_takedown(drm_device_t *dev)
/* 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;
@ -407,7 +397,7 @@ int i810_init(void)
/* 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;
@ -428,6 +418,10 @@ void i810_cleanup(void)
}
}
module_init(i810_init);
module_exit(i810_cleanup);
int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -469,7 +463,9 @@ int i810_open(struct inode *inode, struct file *filp)
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++) {
@ -484,9 +480,11 @@ int i810_open(struct inode *inode, struct file *filp)
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);
@ -548,7 +546,9 @@ int i810_release(struct inode *inode, struct file *filp)
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) {
@ -557,12 +557,15 @@ int i810_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -77,8 +77,6 @@ typedef struct drm_i810_private {
} 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);

View File

@ -30,6 +30,7 @@
*/
#define __NO_VERSION__
#include <linux/config.h>
#include "drmP.h"
typedef struct drm_mem_stats {
@ -330,7 +331,7 @@ void drm_ioremapfree(void *pt, unsigned long size)
}
}
#ifdef DRM_AGP
#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
agp_memory *drm_alloc_agp(int pages, u32 type)
{
agp_memory *handle;

View File

@ -29,8 +29,6 @@
*
*/
#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"

View File

@ -31,13 +31,8 @@
*/
#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"
@ -131,9 +126,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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,
@ -345,7 +337,7 @@ static int mga_takedown(drm_device_t *dev)
/* 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;
@ -410,7 +402,7 @@ int mga_init(void)
/* 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;
@ -442,6 +434,10 @@ void mga_cleanup(void)
}
}
module_init(mga_init);
module_exit(mga_cleanup);
int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -483,7 +479,9 @@ int mga_open(struct inode *inode, struct file *filp)
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++) {
@ -498,9 +496,11 @@ int mga_open(struct inode *inode, struct file *filp)
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);
@ -562,7 +562,9 @@ int mga_release(struct inode *inode, struct file *filp)
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) {
@ -571,12 +573,15 @@ int mga_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -102,8 +102,6 @@ typedef struct _drm_mga_private {
} 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);

View File

@ -521,9 +521,9 @@ static int _drm_histo_info(char *buf, char **start, off_t offset, int len,
} 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);

View File

@ -31,12 +31,13 @@
*/
#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)
{
@ -199,7 +200,7 @@ int r128_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
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

View File

@ -28,8 +28,6 @@
*
*/
#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "r128_drv.h"
@ -38,10 +36,6 @@ extern drm_ctx_t r128_res_ctx;
static int r128_alloc_queue(drm_device_t *dev)
{
#if 0
static int context = 0;
#endif
return drm_ctxbitmap_next(dev);
}

View File

@ -30,13 +30,8 @@
*/
#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"
@ -99,7 +94,7 @@ static drm_ioctl_desc_t r128_ioctls[] = {
[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 },
@ -127,9 +122,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -244,7 +236,7 @@ static int r128_takedown(drm_device_t *dev)
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;
@ -331,7 +323,7 @@ static int r128_takedown(drm_device_t *dev)
/* 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;
@ -356,7 +348,7 @@ int r128_init(void)
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");
@ -395,7 +387,7 @@ int r128_init(void)
/* 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;
@ -409,7 +401,7 @@ void r128_cleanup(void)
}
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);
@ -418,6 +410,10 @@ void r128_cleanup(void)
#endif
}
module_init(r128_init);
module_exit(r128_cleanup);
int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -459,7 +455,9 @@ int r128_open(struct inode *inode, struct file *filp)
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++) {
@ -468,18 +466,23 @@ int r128_open(struct inode *inode, struct file *filp)
}
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) {
@ -488,13 +491,17 @@ int r128_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -69,8 +69,6 @@ typedef struct drm_r128_buf_priv {
} 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);

View File

@ -30,8 +30,6 @@
*
*/
#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "tdfx_drv.h"

View File

@ -31,13 +31,8 @@
*/
#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+"
@ -94,7 +89,7 @@ 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
#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},
@ -115,9 +110,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
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
@ -230,7 +222,7 @@ static int tdfx_takedown(drm_device_t *dev)
}
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;
@ -306,7 +298,7 @@ static int tdfx_takedown(drm_device_t *dev)
/* 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;
@ -330,7 +322,7 @@ int tdfx_init(void)
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))) {
@ -354,7 +346,7 @@ int tdfx_init(void)
/* 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;
@ -368,7 +360,7 @@ void tdfx_cleanup(void)
}
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);
@ -377,6 +369,10 @@ void tdfx_cleanup(void)
#endif
}
module_init(tdfx_init);
module_exit(tdfx_cleanup);
int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@ -418,7 +414,9 @@ int tdfx_open(struct inode *inode, struct file *filp)
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++) {
@ -433,12 +431,17 @@ int tdfx_open(struct inode *inode, struct file *filp)
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) {
@ -447,13 +450,17 @@ int tdfx_release(struct inode *inode, struct file *filp)
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;
}

View File

@ -34,8 +34,6 @@
#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);

View File

@ -145,7 +145,11 @@ void drm_vm_open(struct vm_area_struct *vma)
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);
@ -170,7 +174,9 @@ void drm_vm_close(struct vm_area_struct *vma)
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
@ -193,15 +199,22 @@ void drm_vm_close(struct vm_area_struct *vma)
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 */