Commit 8ae6a2d2 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://drm.bkbits.net/drm-fntbl

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents f9677ef9 e4279631
...@@ -73,22 +73,22 @@ ...@@ -73,22 +73,22 @@
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include "drm.h" #include "drm.h"
#include "drm_os_linux.h" #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
#include "drm_os_linux.h"
/***********************************************************************/ /***********************************************************************/
/** \name DRM template customization defaults */ /** \name DRM template customization defaults */
/*@{*/ /*@{*/
#ifndef __HAVE_AGP /* driver capabilities and requirements mask */
#define __HAVE_AGP 0 #define DRIVER_USE_AGP 0x1
#endif #define DRIVER_REQUIRE_AGP 0x2
#ifndef __HAVE_MTRR #define DRIVER_USE_MTRR 0x4
#define __HAVE_MTRR 0 #define DRIVER_PCI_DMA 0x8
#endif #define DRIVER_SG 0x10
#ifndef __HAVE_CTX_BITMAP
#define __HAVE_CTX_BITMAP 0
#endif
#ifndef __HAVE_DMA #ifndef __HAVE_DMA
#define __HAVE_DMA 0 #define __HAVE_DMA 0
#endif #endif
...@@ -96,14 +96,6 @@ ...@@ -96,14 +96,6 @@
#define __HAVE_IRQ 0 #define __HAVE_IRQ 0
#endif #endif
#define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
defined(CONFIG_AGP_MODULE)))
#define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
#define __REALLY_HAVE_SG (__HAVE_SG)
/*@}*/
/***********************************************************************/ /***********************************************************************/
/** \name Begin the DRM... */ /** \name Begin the DRM... */
/*@{*/ /*@{*/
...@@ -419,9 +411,7 @@ typedef struct drm_file { ...@@ -419,9 +411,7 @@ typedef struct drm_file {
struct drm_device *dev; struct drm_device *dev;
int remove_auth_on_close; int remove_auth_on_close;
unsigned long lock_count; unsigned long lock_count;
#ifdef DRIVER_FILE_FIELDS void *driver_priv;
DRIVER_FILE_FIELDS;
#endif
} drm_file_t; } drm_file_t;
/** Wait queue */ /** Wait queue */
...@@ -479,7 +469,6 @@ typedef struct drm_device_dma { ...@@ -479,7 +469,6 @@ typedef struct drm_device_dma {
/*@}*/ /*@}*/
} drm_device_dma_t; } drm_device_dma_t;
#if __REALLY_HAVE_AGP
/** /**
* AGP memory entry. Stored as a doubly linked list. * AGP memory entry. Stored as a doubly linked list.
*/ */
...@@ -508,7 +497,6 @@ typedef struct drm_agp_head { ...@@ -508,7 +497,6 @@ typedef struct drm_agp_head {
int cant_use_aperture; int cant_use_aperture;
unsigned long page_mask; unsigned long page_mask;
} drm_agp_head_t; } drm_agp_head_t;
#endif
/** /**
* Scatter-gather memory. * Scatter-gather memory.
...@@ -569,7 +557,8 @@ struct drm_driver_fn { ...@@ -569,7 +557,8 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *); int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *); int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *); int (*postsetup)(struct drm_device *);
void (*open_helper)(struct drm_device *, drm_file_t *); int (*open_helper)(struct drm_device *, drm_file_t *);
void (*free_filp_priv)(struct drm_device *, drm_file_t *);
void (*release)(struct drm_device *, struct file *filp); void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *); void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *); int (*dma_quiescent)(struct drm_device *);
...@@ -685,9 +674,7 @@ typedef struct drm_device { ...@@ -685,9 +674,7 @@ typedef struct drm_device {
wait_queue_head_t buf_readers; /**< Processes waiting to read */ wait_queue_head_t buf_readers; /**< Processes waiting to read */
wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
#if __REALLY_HAVE_AGP
drm_agp_head_t *agp; /**< AGP data */ drm_agp_head_t *agp; /**< AGP data */
#endif
struct pci_dev *pdev; /**< PCI device structure */ struct pci_dev *pdev; /**< PCI device structure */
int pci_domain; /**< PCI bus domain number */ int pci_domain; /**< PCI bus domain number */
...@@ -710,8 +697,32 @@ typedef struct drm_device { ...@@ -710,8 +697,32 @@ typedef struct drm_device {
struct drm_driver_fn fn_tbl; struct drm_driver_fn fn_tbl;
drm_local_map_t *agp_buffer_map; drm_local_map_t *agp_buffer_map;
int dev_priv_size; int dev_priv_size;
u32 driver_features;
} drm_device_t; } drm_device_t;
static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature)
{
return ((dev->driver_features & feature) ? 1 : 0);
}
#if __OS_HAS_AGP
static inline int drm_core_has_AGP(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_AGP);
}
#else
#define drm_core_has_AGP(dev) (0)
#endif
#if __OS_HAS_MTRR
static inline int drm_core_has_MTRR(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_MTRR);
}
#else
#define drm_core_has_MTRR(dev) (0)
#endif
extern void DRM(driver_register_fns)(struct drm_device *dev); extern void DRM(driver_register_fns)(struct drm_device *dev);
/******************************************************************/ /******************************************************************/
...@@ -768,12 +779,10 @@ extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, ...@@ -768,12 +779,10 @@ extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
drm_device_t *dev); drm_device_t *dev);
extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev); extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
#if __REALLY_HAVE_AGP
extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type); extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type);
extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages); extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages);
extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start); extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
extern int DRM(unbind_agp)(DRM_AGP_MEM *handle); extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
#endif
/* Misc. IOCTL support (drm_ioctl.h) */ /* Misc. IOCTL support (drm_ioctl.h) */
extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp, extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
...@@ -810,10 +819,8 @@ extern int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -810,10 +819,8 @@ extern int DRM(rmctx)( struct inode *inode, struct file *filp,
extern int DRM(context_switch)(drm_device_t *dev, int old, int new); 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 int DRM(context_switch_complete)(drm_device_t *dev, int new);
#if __HAVE_CTX_BITMAP
extern int DRM(ctxbitmap_init)( drm_device_t *dev ); extern int DRM(ctxbitmap_init)( drm_device_t *dev );
extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
#endif
extern int DRM(setsareactx)( struct inode *inode, struct file *filp, extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
...@@ -900,7 +907,6 @@ extern void DRM(irq_immediate_bh)( void *dev ); ...@@ -900,7 +907,6 @@ extern void DRM(irq_immediate_bh)( void *dev );
#endif #endif
#if __REALLY_HAVE_AGP
/* AGP/GART support (drm_agpsupport.h) */ /* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void); extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void); extern void DRM(agp_uninit)(void);
...@@ -925,7 +931,6 @@ extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type); ...@@ -925,7 +931,6 @@ extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type);
extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle);
extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start); extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
#endif
/* Stub support (drm_stub.h) */ /* Stub support (drm_stub.h) */
int DRM(stub_register)(const char *name, int DRM(stub_register)(const char *name,
...@@ -942,14 +947,12 @@ extern int DRM(proc_cleanup)(int minor, ...@@ -942,14 +947,12 @@ extern int DRM(proc_cleanup)(int minor,
struct proc_dir_entry *root, struct proc_dir_entry *root,
struct proc_dir_entry *dev_root); struct proc_dir_entry *dev_root);
#ifdef __HAVE_SG
/* Scatter Gather Support (drm_scatter.h) */ /* Scatter Gather Support (drm_scatter.h) */
extern void DRM(sg_cleanup)(drm_sg_mem_t *entry); extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
extern int DRM(sg_alloc)(struct inode *inode, struct file *filp, extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int DRM(sg_free)(struct inode *inode, struct file *filp, extern int DRM(sg_free)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
#endif
/* ATI PCIGART support (ati_pcigart.h) */ /* ATI PCIGART support (ati_pcigart.h) */
extern int DRM(ati_pcigart_init)(drm_device_t *dev, extern int DRM(ati_pcigart_init)(drm_device_t *dev,
......
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
#include "drmP.h" #include "drmP.h"
#include <linux/module.h> #include <linux/module.h>
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp") #define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
#define DRM_AGP_PUT inter_module_put("drm_agp") #define DRM_AGP_PUT inter_module_put("drm_agp")
...@@ -466,4 +465,4 @@ int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle) ...@@ -466,4 +465,4 @@ int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle)
return drm_agp->unbind_memory(handle); return drm_agp->unbind_memory(handle);
} }
#endif /* __REALLY_HAVE_AGP */ #endif /* __OS_HAS_AGP */
...@@ -36,14 +36,6 @@ ...@@ -36,14 +36,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include "drmP.h" #include "drmP.h"
#ifndef __HAVE_PCI_DMA
#define __HAVE_PCI_DMA 0
#endif
#ifndef __HAVE_SG
#define __HAVE_SG 0
#endif
/** /**
* Compute size order. Returns the exponent of the smaller power of two which * Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number. * is greater or equal to given number.
...@@ -130,13 +122,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp, ...@@ -130,13 +122,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
#if __REALLY_HAVE_MTRR if (drm_core_has_MTRR(dev)) {
if ( map->type == _DRM_FRAME_BUFFER || if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) { (map->flags & _DRM_WRITE_COMBINING) ) {
map->mtrr = mtrr_add( map->offset, map->size, map->mtrr = mtrr_add( map->offset, map->size,
MTRR_TYPE_WRCOMB, 1 ); MTRR_TYPE_WRCOMB, 1 );
}
} }
#endif
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size, map->handle = DRM(ioremap)( map->offset, map->size,
dev ); dev );
...@@ -162,15 +154,15 @@ int DRM(addmap)( struct inode *inode, struct file *filp, ...@@ -162,15 +154,15 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
dev->lock.hw_lock = map->handle; /* Pointer to lock */ dev->lock.hw_lock = map->handle; /* Pointer to lock */
} }
break; break;
#if __REALLY_HAVE_AGP
case _DRM_AGP: case _DRM_AGP:
if (drm_core_has_AGP(dev)) {
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
map->offset += dev->agp->base; map->offset += dev->agp->base;
map->mtrr = dev->agp->agp_mtrr; /* for getmap */ map->mtrr = dev->agp->agp_mtrr; /* for getmap */
}
break; break;
#endif
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
if (!dev->sg) { if (!dev->sg) {
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
...@@ -270,15 +262,15 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, ...@@ -270,15 +262,15 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR if (drm_core_has_MTRR(dev)) {
if (map->mtrr >= 0) { if (map->mtrr >= 0) {
int retcode; int retcode;
retcode = mtrr_del(map->mtrr, retcode = mtrr_del(map->mtrr,
map->offset, map->offset,
map->size); map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
}
} }
#endif
DRM(ioremapfree)(map->handle, map->size, dev); DRM(ioremapfree)(map->handle, map->size, dev);
break; break;
case _DRM_SHM: case _DRM_SHM:
...@@ -340,7 +332,7 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry) ...@@ -340,7 +332,7 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry)
} }
} }
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
/** /**
* Add AGP buffers for DMA transfers (ioctl). * Add AGP buffers for DMA transfers (ioctl).
* *
...@@ -517,9 +509,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, ...@@ -517,9 +509,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc ); atomic_dec( &dev->buf_alloc );
return 0; return 0;
} }
#endif /* __REALLY_HAVE_AGP */ #endif /* __OS_HAS_AGP */
#if __HAVE_PCI_DMA
int DRM(addbufs_pci)( struct inode *inode, struct file *filp, int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
...@@ -544,6 +535,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, ...@@ -544,6 +535,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
drm_buf_t **temp_buflist; drm_buf_t **temp_buflist;
drm_buf_desc_t __user *argp = (void __user *)arg; drm_buf_desc_t __user *argp = (void __user *)arg;
if (!drm_core_check_feature(dev, DRIVER_PCI_DMA)) return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) ) if ( copy_from_user( &request, argp, sizeof(request) ) )
...@@ -749,9 +741,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, ...@@ -749,9 +741,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
return 0; return 0;
} }
#endif /* __HAVE_PCI_DMA */
#if __HAVE_SG
int DRM(addbufs_sg)( struct inode *inode, struct file *filp, int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
...@@ -774,6 +764,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, ...@@ -774,6 +764,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
int i; int i;
drm_buf_t **temp_buflist; drm_buf_t **temp_buflist;
if (!drm_core_check_feature(dev, DRIVER_SG)) return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) ) if ( copy_from_user( &request, argp, sizeof(request) ) )
...@@ -915,7 +907,6 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, ...@@ -915,7 +907,6 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc ); atomic_dec( &dev->buf_alloc );
return 0; return 0;
} }
#endif /* __HAVE_SG */
/** /**
* Add buffers for DMA transfers (ioctl). * Add buffers for DMA transfers (ioctl).
...@@ -940,21 +931,15 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, ...@@ -940,21 +931,15 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
sizeof(request) ) ) sizeof(request) ) )
return -EFAULT; return -EFAULT;
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( request.flags & _DRM_AGP_BUFFER ) if ( request.flags & _DRM_AGP_BUFFER )
return DRM(addbufs_agp)( inode, filp, cmd, arg ); return DRM(addbufs_agp)( inode, filp, cmd, arg );
else else
#endif #endif
#if __HAVE_SG
if ( request.flags & _DRM_SG_BUFFER ) if ( request.flags & _DRM_SG_BUFFER )
return DRM(addbufs_sg)( inode, filp, cmd, arg ); return DRM(addbufs_sg)( inode, filp, cmd, arg );
else else
#endif
#if __HAVE_PCI_DMA
return DRM(addbufs_pci)( inode, filp, cmd, arg ); return DRM(addbufs_pci)( inode, filp, cmd, arg );
#else
return -EINVAL;
#endif
} }
...@@ -1185,8 +1170,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp, ...@@ -1185,8 +1170,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
if ( request.count >= dma->buf_count ) { if ( request.count >= dma->buf_count ) {
if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) || if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) ||
(__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) { (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) {
drm_map_t *map = dev->agp_buffer_map; drm_map_t *map = dev->agp_buffer_map;
if ( !map ) { if ( !map ) {
......
...@@ -42,11 +42,6 @@ ...@@ -42,11 +42,6 @@
#include "drmP.h" #include "drmP.h"
#if !__HAVE_CTX_BITMAP
#error "__HAVE_CTX_BITMAP must be defined"
#endif
/******************************************************************/ /******************************************************************/
/** \name Context bitmap support */ /** \name Context bitmap support */
/*@{*/ /*@{*/
...@@ -580,3 +575,4 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -580,3 +575,4 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
} }
/*@}*/ /*@}*/
...@@ -52,12 +52,7 @@ ...@@ -52,12 +52,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef __MUST_HAVE_AGP
#define __MUST_HAVE_AGP 0
#endif
#ifndef __HAVE_CTX_BITMAP
#define __HAVE_CTX_BITMAP 0
#endif
#ifndef __HAVE_IRQ #ifndef __HAVE_IRQ
#define __HAVE_IRQ 0 #define __HAVE_IRQ 0
#endif #endif
...@@ -70,9 +65,6 @@ ...@@ -70,9 +65,6 @@
#ifndef __HAVE_COUNTERS #ifndef __HAVE_COUNTERS
#define __HAVE_COUNTERS 0 #define __HAVE_COUNTERS 0
#endif #endif
#ifndef __HAVE_SG
#define __HAVE_SG 0
#endif
#ifndef DRIVER_IOCTLS #ifndef DRIVER_IOCTLS
#define DRIVER_IOCTLS #define DRIVER_IOCTLS
...@@ -133,10 +125,8 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -133,10 +125,8 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
#if __HAVE_CTX_BITMAP
[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 },
#endif
[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 },
...@@ -166,7 +156,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -166,7 +156,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
#endif #endif
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, [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_RELEASE)] = { DRM(agp_release), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 },
...@@ -177,10 +167,8 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -177,10 +167,8 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 },
#endif #endif
#if __HAVE_SG
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
#endif
#ifdef __HAVE_VBL_IRQ #ifdef __HAVE_VBL_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
...@@ -367,9 +355,8 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -367,9 +355,8 @@ static int DRM(takedown)( drm_device_t *dev )
dev->magiclist[i].head = dev->magiclist[i].tail = NULL; dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
} }
#if __REALLY_HAVE_AGP
/* Clear AGP information */ /* Clear AGP information */
if ( dev->agp ) { if (drm_core_has_AGP(dev) && dev->agp) {
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
drm_agp_mem_t *nexte; drm_agp_mem_t *nexte;
...@@ -388,7 +375,6 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -388,7 +375,6 @@ static int DRM(takedown)( drm_device_t *dev )
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
} }
#endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
if ( dev->vmalist ) { if ( dev->vmalist ) {
...@@ -407,15 +393,15 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -407,15 +393,15 @@ static int DRM(takedown)( drm_device_t *dev )
switch ( map->type ) { switch ( map->type ) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR if (drm_core_has_MTRR(dev)) {
if ( map->mtrr >= 0 ) { if ( map->mtrr >= 0 ) {
int retcode; int retcode;
retcode = mtrr_del( map->mtrr, retcode = mtrr_del( map->mtrr,
map->offset, map->offset,
map->size ); map->size );
DRM_DEBUG( "mtrr_del=%d\n", retcode ); DRM_DEBUG( "mtrr_del=%d\n", retcode );
}
} }
#endif
DRM(ioremapfree)( map->handle, map->size, dev ); DRM(ioremapfree)( map->handle, map->size, dev );
break; break;
case _DRM_SHM: case _DRM_SHM:
...@@ -428,15 +414,11 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -428,15 +414,11 @@ static int DRM(takedown)( drm_device_t *dev )
*/ */
break; break;
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
/* Handle it, but do nothing, if HAVE_SG /* Handle it */
* isn't defined. if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) {
*/
#if __HAVE_SG
if(dev->sg) {
DRM(sg_cleanup)(dev->sg); DRM(sg_cleanup)(dev->sg);
dev->sg = NULL; dev->sg = NULL;
} }
#endif
break; break;
} }
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
...@@ -488,9 +470,7 @@ static struct pci_device_id DRM(pciidlist)[] = { ...@@ -488,9 +470,7 @@ static struct pci_device_id DRM(pciidlist)[] = {
static int DRM(probe)(struct pci_dev *pdev) static int DRM(probe)(struct pci_dev *pdev)
{ {
drm_device_t *dev; drm_device_t *dev;
#if __HAVE_CTX_BITMAP
int retcode; int retcode;
#endif
int i; int i;
int is_compat = 0; int is_compat = 0;
...@@ -540,34 +520,32 @@ static int DRM(probe)(struct pci_dev *pdev) ...@@ -540,34 +520,32 @@ static int DRM(probe)(struct pci_dev *pdev)
if (dev->fn_tbl.preinit) if (dev->fn_tbl.preinit)
dev->fn_tbl.preinit(dev); dev->fn_tbl.preinit(dev);
#if __REALLY_HAVE_AGP if (drm_core_has_AGP(dev))
dev->agp = DRM(agp_init)(); {
#if __MUST_HAVE_AGP dev->agp = DRM(agp_init)();
if ( dev->agp == NULL ) { if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" ); DRM_ERROR( "Cannot initialize the agpgart module.\n" );
DRM(stub_unregister)(dev->minor); DRM(stub_unregister)(dev->minor);
DRM(takedown)( dev ); DRM(takedown)( dev );
return -EINVAL; return -EINVAL;
}
if (drm_core_has_MTRR(dev)) {
if (dev->agp)
dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024,
MTRR_TYPE_WRCOMB,
1 );
}
} }
#endif
#if __REALLY_HAVE_MTRR
if (dev->agp)
dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024,
MTRR_TYPE_WRCOMB,
1 );
#endif
#endif
#if __HAVE_CTX_BITMAP
retcode = DRM(ctxbitmap_init)( dev ); retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) { if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
DRM(stub_unregister)(dev->minor); DRM(stub_unregister)(dev->minor);
DRM(takedown)( dev ); DRM(takedown)( dev );
return retcode; return retcode;
} }
#endif
DRM(numdevs)++; /* no errors, mark it reserved */ DRM(numdevs)++; /* no errors, mark it reserved */
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
...@@ -640,29 +618,26 @@ static void __exit drm_cleanup( void ) ...@@ -640,29 +618,26 @@ static void __exit drm_cleanup( void )
DRM_INFO( "Module unloaded\n" ); DRM_INFO( "Module unloaded\n" );
} }
} }
#if __HAVE_CTX_BITMAP
DRM(ctxbitmap_cleanup)( dev ); DRM(ctxbitmap_cleanup)( dev );
#endif
#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
if ( dev->agp && dev->agp->agp_mtrr >= 0) { dev->agp && dev->agp->agp_mtrr >= 0) {
int retval; int retval;
retval = mtrr_del( dev->agp->agp_mtrr, retval = mtrr_del( dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024 ); dev->agp->agp_info.aper_size*1024*1024 );
DRM_DEBUG( "mtrr_del=%d\n", retval ); DRM_DEBUG( "mtrr_del=%d\n", retval );
} }
#endif
DRM(takedown)( dev ); DRM(takedown)( dev );
#if __REALLY_HAVE_AGP if (drm_core_has_AGP(dev) && dev->agp ) {
if ( dev->agp ) {
DRM(agp_uninit)(); DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS ); DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL; dev->agp = NULL;
} }
#endif
if (dev->fn_tbl.postcleanup) if (dev->fn_tbl.postcleanup)
dev->fn_tbl.postcleanup(dev); dev->fn_tbl.postcleanup(dev);
...@@ -860,9 +835,9 @@ int DRM(release)( struct inode *inode, struct file *filp ) ...@@ -860,9 +835,9 @@ int DRM(release)( struct inode *inode, struct file *filp )
pos->handle != DRM_KERNEL_CONTEXT ) { pos->handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor) if (dev->fn_tbl.context_dtor)
dev->fn_tbl.context_dtor(dev, pos->handle); dev->fn_tbl.context_dtor(dev, pos->handle);
#if __HAVE_CTX_BITMAP
DRM(ctxbitmap_free)( dev, pos->handle ); DRM(ctxbitmap_free)( dev, pos->handle );
#endif
list_del( &pos->head ); list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST ); DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST );
} }
...@@ -890,6 +865,9 @@ int DRM(release)( struct inode *inode, struct file *filp ) ...@@ -890,6 +865,9 @@ int DRM(release)( struct inode *inode, struct file *filp )
} }
up( &dev->struct_sem ); up( &dev->struct_sem );
if (dev->fn_tbl.free_filp_priv)
dev->fn_tbl.free_filp_priv(dev, priv);
DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES ); DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
/* ======================================================== /* ========================================================
......
...@@ -53,6 +53,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -53,6 +53,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
{ {
int minor = iminor(inode); int minor = iminor(inode);
drm_file_t *priv; drm_file_t *priv;
int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL; if (!DRM(cpu_valid)()) return -EINVAL;
...@@ -72,8 +73,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -72,8 +73,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->authenticated = capable(CAP_SYS_ADMIN); priv->authenticated = capable(CAP_SYS_ADMIN);
priv->lock_count = 0; priv->lock_count = 0;
if (dev->fn_tbl.open_helper) if (dev->fn_tbl.open_helper) {
dev->fn_tbl.open_helper(dev, priv); ret=dev->fn_tbl.open_helper(dev, priv);
if (ret < 0)
goto out_free;
}
down(&dev->struct_sem); down(&dev->struct_sem);
if (!dev->file_last) { if (!dev->file_last) {
...@@ -105,6 +109,10 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -105,6 +109,10 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif #endif
return 0; return 0;
out_free:
DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
filp->private_data=NULL;
return ret;
} }
/** No-op. */ /** No-op. */
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
*/ */
#define DEBUG_MEMORY 0 #define DEBUG_MEMORY 0
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -130,46 +130,56 @@ drm_follow_page (void *vaddr) ...@@ -130,46 +130,56 @@ drm_follow_page (void *vaddr)
return pte_pfn(*ptep) << PAGE_SHIFT; return pte_pfn(*ptep) << PAGE_SHIFT;
} }
#endif /* __REALLY_HAVE_AGP */ #else /* __OS_HAS_AGP */
static inline drm_map_t *drm_lookup_map(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline void *agp_remap(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline unsigned long drm_follow_page (void *vaddr)
{
return 0;
}
#endif
static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev) static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev)
{ {
#if __REALLY_HAVE_AGP if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
if (dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
return agp_remap(offset, size, dev); return agp_remap(offset, size, dev);
} }
#endif
return ioremap(offset, size); return ioremap(offset, size);
} }
static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size, static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
drm_device_t *dev) drm_device_t *dev)
{ {
#if __REALLY_HAVE_AGP if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
if (dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
return agp_remap(offset, size, dev); return agp_remap(offset, size, dev);
} }
#endif
return ioremap_nocache(offset, size); return ioremap_nocache(offset, size);
} }
static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev) static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev)
{ {
#if __REALLY_HAVE_AGP
/* /*
* This is a bit ugly. It would be much cleaner if the DRM API would use separate * This is a bit ugly. It would be much cleaner if the DRM API would use separate
* routines for handling mappings in the AGP space. Hopefully this can be done in * routines for handling mappings in the AGP space. Hopefully this can be done in
* a future revision of the interface... * a future revision of the interface...
*/ */
if (dev->agp && dev->agp->cant_use_aperture if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
&& ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END)) && ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END))
{ {
unsigned long offset; unsigned long offset;
...@@ -182,7 +192,6 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d ...@@ -182,7 +192,6 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
return; return;
} }
} }
#endif
iounmap(pt); iounmap(pt);
} }
...@@ -332,7 +341,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev) ...@@ -332,7 +341,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
drm_ioremapfree(pt, size, dev); drm_ioremapfree(pt, size, dev);
} }
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
/** Wrapper around agp_allocate_memory() */ /** Wrapper around agp_allocate_memory() */
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type) DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{ {
......
...@@ -352,7 +352,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev) ...@@ -352,7 +352,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
} }
} }
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type) DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{ {
......
...@@ -41,8 +41,34 @@ ...@@ -41,8 +41,34 @@
#define DRM_IRQ_ARGS int irq, void *arg, struct pt_regs *regs #define DRM_IRQ_ARGS int irq, void *arg, struct pt_regs *regs
/** AGP types */ /** AGP types */
#if __OS_HAS_AGP
#define DRM_AGP_MEM struct agp_memory #define DRM_AGP_MEM struct agp_memory
#define DRM_AGP_KERN struct agp_kern_info #define DRM_AGP_KERN struct agp_kern_info
#else
/* define some dummy types for non AGP supporting kernels */
struct no_agp_kern {
unsigned long aper_base;
unsigned long aper_size;
};
#define DRM_AGP_MEM int
#define DRM_AGP_KERN struct no_agp_kern
#endif
#if !(__OS_HAS_MTRR)
static __inline__ int mtrr_add (unsigned long base, unsigned long size,
unsigned int type, char increment)
{
return -ENODEV;
}
static __inline__ int mtrr_del (int reg, unsigned long base,
unsigned long size)
{
return -ENODEV;
}
#define MTRR_TYPE_WRCOMB 1
#endif
/** Task queue handler arguments */ /** Task queue handler arguments */
#define DRM_TASKQUEUE_ARGS void *arg #define DRM_TASKQUEUE_ARGS void *arg
......
...@@ -73,6 +73,9 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -73,6 +73,9 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
DRM_DEBUG( "%s\n", __FUNCTION__ ); DRM_DEBUG( "%s\n", __FUNCTION__ );
if (drm_core_check_feature(dev, DRIVER_SG))
return -EINVAL;
if ( dev->sg ) if ( dev->sg )
return -EINVAL; return -EINVAL;
...@@ -206,6 +209,9 @@ int DRM(sg_free)( struct inode *inode, struct file *filp, ...@@ -206,6 +209,9 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
drm_scatter_gather_t request; drm_scatter_gather_t request;
drm_sg_mem_t *entry; drm_sg_mem_t *entry;
if (drm_core_check_feature(dev, DRIVER_SG))
return -EINVAL;
if ( copy_from_user( &request, if ( copy_from_user( &request,
(drm_scatter_gather_t __user *)arg, (drm_scatter_gather_t __user *)arg,
sizeof(request) ) ) sizeof(request) ) )
......
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
* Find the right map and if it's AGP memory find the real physical page to * Find the right map and if it's AGP memory find the real physical page to
* map, get the page, increment the use count and return it. * map, get the page, increment the use count and return it.
*/ */
#if __OS_HAS_AGP
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address) unsigned long address)
{ {
#if __REALLY_HAVE_AGP
drm_file_t *priv = vma->vm_file->private_data; drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_map_t *map = NULL; drm_map_t *map = NULL;
...@@ -59,6 +59,8 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, ...@@ -59,6 +59,8 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
/* /*
* Find the right map * Find the right map
*/ */
if (!drm_core_has_AGP(dev))
goto vm_nopage_error;
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
...@@ -107,10 +109,15 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, ...@@ -107,10 +109,15 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return page; return page;
} }
vm_nopage_error: vm_nopage_error:
#endif /* __REALLY_HAVE_AGP */
return NOPAGE_SIGBUS; /* Disallow mremap */ return NOPAGE_SIGBUS; /* Disallow mremap */
} }
#else /* __OS_HAS_AGP */
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address)
{
return NOPAGE_SIGBUS;
}
#endif /* __OS_HAS_AGP */
/** /**
* \c nopage method for shared virtual memory. * \c nopage method for shared virtual memory.
...@@ -201,15 +208,13 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) ...@@ -201,15 +208,13 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
if (map->mtrr >= 0) {
int retcode; int retcode;
retcode = mtrr_del(map->mtrr, retcode = mtrr_del(map->mtrr,
map->offset, map->offset,
map->size); map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
} }
#endif
DRM(ioremapfree)(map->handle, map->size, dev); DRM(ioremapfree)(map->handle, map->size, dev);
break; break;
case _DRM_SHM: case _DRM_SHM:
...@@ -533,7 +538,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -533,7 +538,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
* --BenH. * --BenH.
*/ */
if (!VM_OFFSET(vma) if (!VM_OFFSET(vma)
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
&& (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE) && (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
#endif #endif
) )
...@@ -577,8 +582,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -577,8 +582,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_AGP: case _DRM_AGP:
#if __REALLY_HAVE_AGP if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
if (dev->agp->cant_use_aperture) {
/* /*
* On some platforms we can't talk to bus dma address from the CPU, so for * On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical * memory of type DRM_AGP, we'll deal with sorting out the real physical
...@@ -590,7 +594,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -590,7 +594,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
vma->vm_ops = &DRM(vm_ops); vma->vm_ops = &DRM(vm_ops);
break; break;
} }
#endif
/* fall through to _DRM_FRAME_BUFFER... */ /* fall through to _DRM_FRAME_BUFFER... */
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS: case _DRM_REGISTERS:
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_MTRR 1
#define DRIVER_AUTHOR "VA Linux Systems Inc." #define DRIVER_AUTHOR "VA Linux Systems Inc."
#define DRIVER_NAME "gamma" #define DRIVER_NAME "gamma"
...@@ -72,10 +70,7 @@ ...@@ -72,10 +70,7 @@
/* DMA customization: /* DMA customization:
*/ */
#define __HAVE_DMA 1 #define __HAVE_DMA 1
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 0
#define __HAVE_OLD_DMA 1 #define __HAVE_OLD_DMA 1
#define __HAVE_PCI_DMA 1
#define __HAVE_MULTIPLE_DMA_QUEUES 1 #define __HAVE_MULTIPLE_DMA_QUEUES 1
#define __HAVE_DMA_WAITQUEUE 1 #define __HAVE_DMA_WAITQUEUE 1
......
...@@ -934,6 +934,7 @@ static int gamma_driver_dma_quiescent(drm_device_t *dev) ...@@ -934,6 +934,7 @@ static int gamma_driver_dma_quiescent(drm_device_t *dev)
void gamma_driver_register_fns(drm_device_t *dev) void gamma_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA;
DRM(fops).read = gamma_fops_read; DRM(fops).read = gamma_fops_read;
DRM(fops).poll = gamma_fops_poll; DRM(fops).poll = gamma_fops_poll;
dev->fn_tbl.preinit = gamma_driver_preinit; dev->fn_tbl.preinit = gamma_driver_preinit;
......
...@@ -56,3 +56,4 @@ ...@@ -56,3 +56,4 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 1
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc." #define DRIVER_AUTHOR "VA Linux Systems Inc."
......
...@@ -1407,6 +1407,7 @@ static int i810_driver_dma_quiescent(drm_device_t *dev) ...@@ -1407,6 +1407,7 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
void i810_driver_register_fns(drm_device_t *dev) void i810_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
dev->dev_priv_size = sizeof(drm_i810_buf_priv_t); dev->dev_priv_size = sizeof(drm_i810_buf_priv_t);
dev->fn_tbl.pretakedown = i810_driver_pretakedown; dev->fn_tbl.pretakedown = i810_driver_pretakedown;
dev->fn_tbl.release = i810_driver_release; dev->fn_tbl.release = i810_driver_release;
......
...@@ -53,3 +53,4 @@ ...@@ -53,3 +53,4 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 1
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc." #define DRIVER_AUTHOR "VA Linux Systems Inc."
......
...@@ -1602,6 +1602,7 @@ static int i830_driver_dma_quiescent(drm_device_t *dev) ...@@ -1602,6 +1602,7 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
void i830_driver_register_fns(drm_device_t *dev) void i830_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
dev->dev_priv_size = sizeof(drm_i830_buf_priv_t); dev->dev_priv_size = sizeof(drm_i830_buf_priv_t);
dev->fn_tbl.pretakedown = i830_driver_pretakedown; dev->fn_tbl.pretakedown = i830_driver_pretakedown;
dev->fn_tbl.release = i830_driver_release; dev->fn_tbl.release = i830_driver_release;
......
...@@ -56,3 +56,4 @@ ...@@ -56,3 +56,4 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 1
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "Tungsten Graphics, Inc." #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
......
...@@ -732,6 +732,7 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp) ...@@ -732,6 +732,7 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
void i915_driver_register_fns(drm_device_t *dev) void i915_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
dev->fn_tbl.pretakedown = i915_driver_pretakedown; dev->fn_tbl.pretakedown = i915_driver_pretakedown;
dev->fn_tbl.prerelease = i915_driver_prerelease; dev->fn_tbl.prerelease = i915_driver_prerelease;
} }
...@@ -29,3 +29,4 @@ ...@@ -29,3 +29,4 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 1
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc." #define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
......
...@@ -813,6 +813,7 @@ static int mga_driver_dma_quiescent(drm_device_t *dev) ...@@ -813,6 +813,7 @@ static int mga_driver_dma_quiescent(drm_device_t *dev)
void mga_driver_register_fns(drm_device_t *dev) void mga_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
dev->fn_tbl.pretakedown = mga_driver_pretakedown; dev->fn_tbl.pretakedown = mga_driver_pretakedown;
dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent; dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
} }
...@@ -51,3 +51,4 @@ ...@@ -51,3 +51,4 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -36,13 +36,6 @@ ...@@ -36,13 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define __HAVE_SG 1
#define __HAVE_PCI_DMA 1
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc." #define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
#define DRIVER_NAME "r128" #define DRIVER_NAME "r128"
......
...@@ -322,7 +322,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev, ...@@ -322,7 +322,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev,
/* The manual (p. 2) says this address is in "VM space". This /* The manual (p. 2) says this address is in "VM space". This
* means it's an offset from the start of AGP space. * means it's an offset from the start of AGP space.
*/ */
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) if ( !dev_priv->is_pci )
ring_start = dev_priv->cce_ring->offset - dev->agp->base; ring_start = dev_priv->cce_ring->offset - dev->agp->base;
else else
...@@ -510,7 +510,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) ...@@ -510,7 +510,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset); init->sarea_priv_offset);
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
drm_core_ioremap( dev_priv->cce_ring, dev ); drm_core_ioremap( dev_priv->cce_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev ); drm_core_ioremap( dev_priv->ring_rptr, dev );
...@@ -533,7 +533,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) ...@@ -533,7 +533,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset; dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
} }
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) if ( !dev_priv->is_pci )
dev_priv->cce_buffers_offset = dev->agp->base; dev_priv->cce_buffers_offset = dev->agp->base;
else else
...@@ -558,7 +558,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) ...@@ -558,7 +558,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
R128_WRITE( R128_LAST_DISPATCH_REG, R128_WRITE( R128_LAST_DISPATCH_REG,
dev_priv->sarea_priv->last_dispatch ); dev_priv->sarea_priv->last_dispatch );
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( dev_priv->is_pci ) { if ( dev_priv->is_pci ) {
#endif #endif
if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart, if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
...@@ -569,7 +569,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) ...@@ -569,7 +569,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
return DRM_ERR(ENOMEM); return DRM_ERR(ENOMEM);
} }
R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart ); R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
} }
#endif #endif
...@@ -597,7 +597,7 @@ int r128_do_cleanup_cce( drm_device_t *dev ) ...@@ -597,7 +597,7 @@ int r128_do_cleanup_cce( drm_device_t *dev )
if ( dev->dev_private ) { if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_private_t *dev_priv = dev->dev_private;
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
if ( dev_priv->cce_ring != NULL ) if ( dev_priv->cce_ring != NULL )
drm_core_ioremapfree( dev_priv->cce_ring, dev ); drm_core_ioremapfree( dev_priv->cce_ring, dev );
......
...@@ -1712,6 +1712,7 @@ static void r128_driver_pretakedown(drm_device_t *dev) ...@@ -1712,6 +1712,7 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev) void r128_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG;
dev->dev_priv_size = sizeof(drm_r128_buf_priv_t); dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
dev->fn_tbl.prerelease = r128_driver_prerelease; dev->fn_tbl.prerelease = r128_driver_prerelease;
dev->fn_tbl.pretakedown = r128_driver_pretakedown; dev->fn_tbl.pretakedown = r128_driver_pretakedown;
......
...@@ -37,12 +37,6 @@ ...@@ -37,12 +37,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define __HAVE_SG 1
#define __HAVE_PCI_DMA 1
#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others." #define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
...@@ -115,9 +109,6 @@ ...@@ -115,9 +109,6 @@
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \
#define DRIVER_FILE_FIELDS \
int64_t radeon_fb_delta; \
/* DMA customization: /* DMA customization:
*/ */
#define __HAVE_DMA 1 #define __HAVE_DMA 1
......
...@@ -858,7 +858,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev, ...@@ -858,7 +858,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
( ( dev_priv->gart_vm_start - 1 ) & 0xffff0000 ) ( ( dev_priv->gart_vm_start - 1 ) & 0xffff0000 )
| ( dev_priv->fb_location >> 16 ) ); | ( dev_priv->fb_location >> 16 ) );
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
RADEON_WRITE( RADEON_MC_AGP_LOCATION, RADEON_WRITE( RADEON_MC_AGP_LOCATION,
(((dev_priv->gart_vm_start - 1 + (((dev_priv->gart_vm_start - 1 +
...@@ -885,7 +885,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev, ...@@ -885,7 +885,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
SET_RING_HEAD( dev_priv, cur_read_ptr ); SET_RING_HEAD( dev_priv, cur_read_ptr );
dev_priv->ring.tail = cur_read_ptr; dev_priv->ring.tail = cur_read_ptr;
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR, RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
dev_priv->ring_rptr->offset dev_priv->ring_rptr->offset
...@@ -1161,7 +1161,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) ...@@ -1161,7 +1161,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(drm_radeon_sarea_t *)((u8 *)dev_priv->sarea->handle + (drm_radeon_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset); init->sarea_priv_offset);
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
drm_core_ioremap( dev_priv->cp_ring, dev ); drm_core_ioremap( dev_priv->cp_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev ); drm_core_ioremap( dev_priv->ring_rptr, dev );
...@@ -1211,7 +1211,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) ...@@ -1211,7 +1211,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->gart_vm_start = dev_priv->fb_location dev_priv->gart_vm_start = dev_priv->fb_location
+ RADEON_READ( RADEON_CONFIG_APER_SIZE ); + RADEON_READ( RADEON_CONFIG_APER_SIZE );
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) if ( !dev_priv->is_pci )
dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base - dev->agp->base
...@@ -1240,7 +1240,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) ...@@ -1240,7 +1240,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK; dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
/* Turn off PCI GART */ /* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 ); radeon_set_pcigart( dev_priv, 0 );
...@@ -1286,7 +1286,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev ) ...@@ -1286,7 +1286,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
if ( dev->dev_private ) { if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
if ( dev_priv->cp_ring != NULL ) if ( dev_priv->cp_ring != NULL )
drm_core_ioremapfree( dev_priv->cp_ring, dev ); drm_core_ioremapfree( dev_priv->cp_ring, dev );
...@@ -1329,7 +1329,7 @@ static int radeon_do_resume_cp( drm_device_t *dev ) ...@@ -1329,7 +1329,7 @@ static int radeon_do_resume_cp( drm_device_t *dev )
DRM_DEBUG("Starting radeon_do_resume_cp()\n"); DRM_DEBUG("Starting radeon_do_resume_cp()\n");
#if __REALLY_HAVE_AGP #if __OS_HAS_AGP
if ( !dev_priv->is_pci ) { if ( !dev_priv->is_pci ) {
/* Turn off PCI GART */ /* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 ); radeon_set_pcigart( dev_priv, 0 );
......
...@@ -60,6 +60,9 @@ typedef struct drm_radeon_depth_clear_t { ...@@ -60,6 +60,9 @@ typedef struct drm_radeon_depth_clear_t {
u32 se_cntl; u32 se_cntl;
} drm_radeon_depth_clear_t; } drm_radeon_depth_clear_t;
struct drm_radeon_driver_file_fields {
int64_t radeon_fb_delta;
};
struct mem_block { struct mem_block {
struct mem_block *next; struct mem_block *next;
......
...@@ -43,12 +43,14 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p ...@@ -43,12 +43,14 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv, drm_file_t *filp_priv,
u32 *offset ) { u32 *offset ) {
u32 off = *offset; u32 off = *offset;
struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location && if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) ) off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0; return 0;
off += filp_priv->radeon_fb_delta; radeon_priv = filp_priv->driver_priv;
off += radeon_priv->radeon_fb_delta;
DRM_DEBUG( "offset fixed up to 0x%x\n", off ); DRM_DEBUG( "offset fixed up to 0x%x\n", off );
...@@ -2525,6 +2527,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { ...@@ -2525,6 +2527,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv; drm_file_t *filp_priv;
drm_radeon_setparam_t sp; drm_radeon_setparam_t sp;
struct drm_radeon_driver_file_fields *radeon_priv;
if ( !dev_priv ) { if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ ); DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
...@@ -2538,7 +2541,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { ...@@ -2538,7 +2541,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) { switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION: case RADEON_SETPARAM_FB_LOCATION:
filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value; radeon_priv = filp_priv->driver_priv;
radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
break; break;
default: default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param ); DRM_DEBUG( "Invalid parameter %d\n", sp.param );
...@@ -2571,19 +2575,38 @@ static void radeon_driver_pretakedown(drm_device_t *dev) ...@@ -2571,19 +2575,38 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(dev); radeon_do_release(dev);
} }
static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv) static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{ {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
struct drm_radeon_driver_file_fields *radeon_priv;
radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv)
return -ENOMEM;
filp_priv->driver_priv = radeon_priv;
if ( dev_priv ) if ( dev_priv )
filp_priv->radeon_fb_delta = dev_priv->fb_location; radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else else
filp_priv->radeon_fb_delta = 0; radeon_priv->radeon_fb_delta = 0;
return 0;
}
static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
{
struct drm_radeon_driver_file_fields *radeon_priv = filp_priv->driver_priv;
DRM(free)(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
} }
void radeon_driver_register_fns(struct drm_device *dev) void radeon_driver_register_fns(struct drm_device *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG;
dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t); dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->fn_tbl.prerelease = radeon_driver_prerelease; dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown; dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper; dev->fn_tbl.open_helper = radeon_driver_open_helper;
dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
} }
...@@ -41,10 +41,6 @@ ...@@ -41,10 +41,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_AGP 1
#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "SIS" #define DRIVER_AUTHOR "SIS"
#define DRIVER_NAME "sis" #define DRIVER_NAME "sis"
......
...@@ -46,4 +46,5 @@ ...@@ -46,4 +46,5 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
...@@ -407,6 +407,7 @@ int sis_final_context(struct drm_device *dev, int context) ...@@ -407,6 +407,7 @@ int sis_final_context(struct drm_device *dev, int context)
void DRM(driver_register_fns)(drm_device_t *dev) void DRM(driver_register_fns)(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR;
dev->fn_tbl.context_ctor = sis_init_context; dev->fn_tbl.context_ctor = sis_init_context;
dev->fn_tbl.context_dtor = sis_final_context; dev->fn_tbl.context_dtor = sis_final_context;
} }
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
/* General customization: /* General customization:
*/ */
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc." #define DRIVER_AUTHOR "VA Linux Systems Inc."
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "tdfx.h" #include "tdfx.h"
#include "drmP.h" #include "drmP.h"
#include "drm_agpsupport.h"
#include "drm_auth.h" #include "drm_auth.h"
#include "drm_bufs.h" #include "drm_bufs.h"
#include "drm_context.h" #include "drm_context.h"
...@@ -49,8 +50,10 @@ ...@@ -49,8 +50,10 @@
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
void DRM(driver_register_fns)(drm_device_t *dev) void DRM(driver_register_fns)(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_MTRR;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment