Commit 9bd7e9f7 authored by Dave Airlie's avatar Dave Airlie

drm: core/personality split for 2.6 kernel

This changeset gets rid of the DRM() macros and implements a core DRM module
linked to a per graphics card personality module..

Remove old 2.4 module parameters and switch to 2.6 module parameters 

From: Jon Smirl <jonsmirl@gmail.com> and Dave Airlie <airlied@linux.ie>
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent f9adb741
......@@ -52,7 +52,7 @@
# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
static unsigned long DRM(ati_alloc_pcigart_table)( void )
static unsigned long drm_ati_alloc_pcigart_table( void )
{
unsigned long address;
struct page *page;
......@@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void )
return address;
}
static void DRM(ati_free_pcigart_table)( unsigned long address )
static void drm_ati_free_pcigart_table( unsigned long address )
{
struct page *page;
int i;
......@@ -91,7 +91,7 @@ static void DRM(ati_free_pcigart_table)( unsigned long address )
free_pages( address, ATI_PCIGART_TABLE_ORDER );
}
int DRM(ati_pcigart_init)( drm_device_t *dev,
int drm_ati_pcigart_init( drm_device_t *dev,
unsigned long *addr,
dma_addr_t *bus_addr)
{
......@@ -106,7 +106,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done;
}
address = DRM(ati_alloc_pcigart_table)();
address = drm_ati_alloc_pcigart_table();
if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done;
......@@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE);
if (bus_address == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_free_pcigart_table)( address );
drm_ati_free_pcigart_table( address );
address = 0;
goto done;
}
......@@ -142,7 +142,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE);
if (entry->busaddr[i] == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_pcigart_cleanup)( dev, address, bus_address );
drm_ati_pcigart_cleanup( dev, address, bus_address );
address = 0;
bus_address = 0;
goto done;
......@@ -169,7 +169,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
return ret;
}
int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
int drm_ati_pcigart_cleanup( drm_device_t *dev,
unsigned long addr,
dma_addr_t bus_addr)
{
......@@ -199,7 +199,7 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
}
if ( addr ) {
DRM(ati_free_pcigart_table)( addr );
drm_ati_free_pcigart_table( addr );
}
return 1;
......
......@@ -218,7 +218,8 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
*/
#define DRM_MEM_ERROR(area, fmt, arg...) \
printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
DRM(mem_stats)[area].name , ##arg)
drm_mem_stats[area].name , ##arg)
#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
/**
......@@ -230,7 +231,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
#if DRM_DEBUG_CODE
#define DRM_DEBUG(fmt, arg...) \
do { \
if ( DRM(flags) & DRM_FLAG_DEBUG ) \
if ( drm_debug ) \
printk(KERN_DEBUG \
"[" DRM_NAME ":%s] " fmt , \
__FUNCTION__ , ##arg); \
......@@ -292,6 +293,18 @@ do { \
} \
} while (0)
/**
* Copy and IOCTL return string to user space
*/
#define DRM_COPY( name, value ) \
len = strlen( value ); \
if ( len > name##_len ) len = name##_len; \
name##_len = strlen( value ); \
if ( len && name ) { \
if ( copy_to_user( name, value, len ) ) \
return -EFAULT; \
}
/**
* Ioctl function type.
*
......@@ -478,7 +491,7 @@ typedef struct drm_agp_mem {
/**
* AGP data.
*
* \sa DRM(agp_init)() and drm_device::agp.
* \sa drm_agp_init() and drm_device::agp.
*/
typedef struct drm_agp_head {
DRM_AGP_KERN agp_info; /**< AGP device information */
......@@ -543,12 +556,12 @@ struct drm_device;
struct drm_driver_fn {
int (*preinit)(struct drm_device *);
int (*postinit)(struct drm_device *);
void (*prerelease)(struct drm_device *, struct file *filp);
void (*pretakedown)(struct drm_device *);
int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *);
int (*dma_ioctl)( DRM_IOCTL_ARGS );
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);
......@@ -560,6 +573,7 @@ struct drm_driver_fn {
void (*kernel_context_switch_unlock)(struct drm_device *dev, drm_lock_t *lock);
int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
/* these have to be filled in */
int (*postinit)(struct drm_device *, unsigned long flags);
irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
void (*irq_preinstall)(struct drm_device *dev);
void (*irq_postinstall)(struct drm_device *dev);
......@@ -568,12 +582,17 @@ struct drm_driver_fn {
unsigned long (*get_map_ofs)(drm_map_t *map);
unsigned long (*get_reg_ofs)(struct drm_device *dev);
void (*set_version)(struct drm_device *dev, drm_set_version_t *sv);
int (*version)(drm_version_t *version);
u32 driver_features;
int dev_priv_size;
drm_ioctl_desc_t *ioctls;
int num_ioctls;
struct pci_driver pci_driver;
};
/**
* DRM device structure.
*/
typedef struct drm_device {
const char *name; /**< Simple driver name */
char *unique; /**< Unique identifier: e.g., busid */
int unique_len; /**< Length of unique field */
dev_t device; /**< Device number for mknod */
......@@ -699,10 +718,8 @@ typedef struct drm_device {
struct file_operations *fops; /**< file operations */
struct proc_dir_entry *dev_root; /**< proc directory entry */
struct drm_driver_fn fn_tbl;
struct drm_driver_fn *fn_tbl;
drm_local_map_t *agp_buffer_map;
int dev_priv_size;
u32 driver_features;
} drm_device_t;
typedef struct drm_minor {
......@@ -714,16 +731,9 @@ typedef struct drm_minor {
struct proc_dir_entry *dev_root; /**< proc directory entry */
} drm_minor_t;
typedef struct drm_global {
unsigned int cards_limit;
drm_minor_t *minors;
struct class_simple *drm_class;
struct proc_dir_entry *proc_root;
} drm_global_t;
static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature)
{
return ((dev->driver_features & feature) ? 1 : 0);
return ((dev->fn_tbl->driver_features & feature) ? 1 : 0);
}
#if __OS_HAS_AGP
......@@ -744,228 +754,238 @@ static inline int drm_core_has_MTRR(struct drm_device *dev)
#define drm_core_has_MTRR(dev) (0)
#endif
extern void DRM(driver_register_fns)(struct drm_device *dev);
/******************************************************************/
/** \name Internal function definitions */
/*@{*/
/* Misc. support (drm_init.h) */
extern int DRM(flags);
extern void DRM(parse_options)( char *s );
extern int DRM(cpu_valid)( void );
extern int drm_flags;
extern void drm_parse_options( char *s );
extern int drm_cpu_valid( void );
/* Driver support (drm_drv.h) */
extern int DRM(version)(struct inode *inode, struct file *filp,
extern int drm_init(struct drm_driver_fn *driver_fn);
extern void drm_exit(struct drm_driver_fn *driver_fn);
extern int drm_version(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(open)(struct inode *inode, struct file *filp);
extern int DRM(release)(struct inode *inode, struct file *filp);
extern int DRM(ioctl)(struct inode *inode, struct file *filp,
extern int drm_open(struct inode *inode, struct file *filp);
extern int drm_release(struct inode *inode, struct file *filp);
extern int drm_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(lock)(struct inode *inode, struct file *filp,
extern int drm_lock(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(unlock)(struct inode *inode, struct file *filp,
extern int drm_unlock(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev,
const struct pci_device_id *ent, struct drm_driver_fn *driver_fn);
/* Device support (drm_fops.h) */
extern int DRM(open_helper)(struct inode *inode, struct file *filp,
extern int drm_open_helper(struct inode *inode, struct file *filp,
drm_device_t *dev);
extern int DRM(flush)(struct file *filp);
extern int DRM(fasync)(int fd, struct file *filp, int on);
extern int drm_flush(struct file *filp);
extern int drm_fasync(int fd, struct file *filp, int on);
/* Mapping support (drm_vm.h) */
extern void DRM(vm_open)(struct vm_area_struct *vma);
extern void DRM(vm_close)(struct vm_area_struct *vma);
extern void DRM(vm_shm_close)(struct vm_area_struct *vma);
extern int DRM(mmap_dma)(struct file *filp,
extern void drm_vm_open(struct vm_area_struct *vma);
extern void drm_vm_close(struct vm_area_struct *vma);
extern void drm_vm_shm_close(struct vm_area_struct *vma);
extern int drm_mmap_dma(struct file *filp,
struct vm_area_struct *vma);
extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait);
extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count, loff_t *off);
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off);
/* Memory management support (drm_memory.h) */
extern void DRM(mem_init)(void);
extern int DRM(mem_info)(char *buf, char **start, off_t offset,
#include "drm_memory.h"
extern void drm_mem_init(void);
extern int drm_mem_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
extern void *drm_calloc(size_t nmemb, size_t size, int area);
extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
int area);
extern unsigned long DRM(alloc_pages)(int order, int area);
extern void DRM(free_pages)(unsigned long address, int order,
extern unsigned long drm_alloc_pages(int order, int area);
extern void drm_free_pages(unsigned long address, int order,
int area);
extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev);
extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
extern void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev);
extern void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
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);
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(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
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_bind_agp(DRM_AGP_MEM *handle, unsigned int start);
extern int drm_unbind_agp(DRM_AGP_MEM *handle);
/* 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,
unsigned int cmd, unsigned long arg);
extern int DRM(getunique)(struct inode *inode, struct file *filp,
extern int drm_getunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(setunique)(struct inode *inode, struct file *filp,
extern int drm_setunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(getmap)(struct inode *inode, struct file *filp,
extern int drm_getmap(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(getclient)(struct inode *inode, struct file *filp,
extern int drm_getclient(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(getstats)(struct inode *inode, struct file *filp,
extern int drm_getstats(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(setversion)(struct inode *inode, struct file *filp,
extern int drm_setversion(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Context IOCTL support (drm_context.h) */
extern int DRM(resctx)( struct inode *inode, struct file *filp,
extern int drm_resctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(addctx)( struct inode *inode, struct file *filp,
extern int drm_addctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(modctx)( struct inode *inode, struct file *filp,
extern int drm_modctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(getctx)( struct inode *inode, struct file *filp,
extern int drm_getctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(switchctx)( struct inode *inode, struct file *filp,
extern int drm_switchctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(newctx)( struct inode *inode, struct file *filp,
extern int drm_newctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(rmctx)( struct inode *inode, struct file *filp,
extern int drm_rmctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
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(drm_device_t *dev, int old, int new);
extern int drm_context_switch_complete(drm_device_t *dev, int new);
extern int DRM(ctxbitmap_init)( drm_device_t *dev );
extern void DRM(ctxbitmap_cleanup)( 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_free( drm_device_t *dev, int ctx_handle );
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 );
extern int DRM(getsareactx)( struct inode *inode, struct file *filp,
extern int drm_getsareactx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
/* Drawable IOCTL support (drm_drawable.h) */
extern int DRM(adddraw)(struct inode *inode, struct file *filp,
extern int drm_adddraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
extern int drm_rmdraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Authentication IOCTL support (drm_auth.h) */
extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
drm_magic_t magic);
extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
extern int DRM(getmagic)(struct inode *inode, struct file *filp,
extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
extern int drm_getmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(authmagic)(struct inode *inode, struct file *filp,
extern int drm_authmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Placeholder for ioctls past */
extern int DRM(noop)(struct inode *inode, struct file *filp,
extern int drm_noop(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Locking IOCTL support (drm_lock.h) */
extern int DRM(lock_take)(__volatile__ unsigned int *lock,
extern int drm_lock_take(__volatile__ unsigned int *lock,
unsigned int context);
extern int DRM(lock_transfer)(drm_device_t *dev,
extern int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock,
unsigned int context);
extern int DRM(lock_free)(drm_device_t *dev,
extern int drm_lock_free(drm_device_t *dev,
__volatile__ unsigned int *lock,
unsigned int context);
extern int DRM(notifier)(void *priv);
extern int drm_notifier(void *priv);
/* Buffer management support (drm_bufs.h) */
extern int DRM(order)( unsigned long size );
extern int DRM(addmap)( struct inode *inode, struct file *filp,
extern int drm_order( unsigned long size );
extern int drm_addmap( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(rmmap)( struct inode *inode, struct file *filp,
extern int drm_rmmap( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(addbufs)( struct inode *inode, struct file *filp,
extern int drm_addbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(infobufs)( struct inode *inode, struct file *filp,
extern int drm_infobufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(markbufs)( struct inode *inode, struct file *filp,
extern int drm_markbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(freebufs)( struct inode *inode, struct file *filp,
extern int drm_freebufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
extern int drm_mapbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
/* DMA support (drm_dma.h) */
extern int DRM(dma_setup)(drm_device_t *dev);
extern void DRM(dma_takedown)(drm_device_t *dev);
extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
extern void DRM(reclaim_buffers)( struct file *filp );
extern int drm_dma_setup(drm_device_t *dev);
extern void drm_dma_takedown(drm_device_t *dev);
extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
extern void drm_core_reclaim_buffers( struct file *filp );
/* IRQ support (drm_irq.h) */
extern int DRM(control)( struct inode *inode, struct file *filp,
extern int drm_control( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int DRM(irq_install)( drm_device_t *dev );
extern int DRM(irq_uninstall)( drm_device_t *dev );
extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS );
extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
extern int drm_irq_install( drm_device_t *dev );
extern int drm_irq_uninstall( drm_device_t *dev );
extern irqreturn_t drm_irq_handler( DRM_IRQ_ARGS );
extern void drm_driver_irq_preinstall( drm_device_t *dev );
extern void drm_driver_irq_postinstall( drm_device_t *dev );
extern void drm_driver_irq_uninstall( drm_device_t *dev );
extern int drm_wait_vblank(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
extern void DRM(vbl_send_signals)( drm_device_t *dev );
extern int drm_vblank_wait(drm_device_t *dev, unsigned int *vbl_seq);
extern void drm_vbl_send_signals( drm_device_t *dev );
/* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void);
extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
extern drm_agp_head_t *drm_agp_init(void);
extern void drm_agp_uninit(void);
extern int drm_agp_acquire(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern void DRM(agp_do_release)(void);
extern int DRM(agp_release)(struct inode *inode, struct file *filp,
extern void drm_agp_do_release(void);
extern int drm_agp_release(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
extern int drm_agp_enable(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_info)(struct inode *inode, struct file *filp,
extern int drm_agp_info(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
extern int drm_agp_alloc(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_free)(struct inode *inode, struct file *filp,
extern int drm_agp_free(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
extern int drm_agp_unbind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
extern int drm_agp_bind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
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_bind_memory)(DRM_AGP_MEM *handle, off_t start);
extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
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_bind_memory(DRM_AGP_MEM *handle, off_t start);
extern int drm_agp_unbind_memory(DRM_AGP_MEM *handle);
/* Stub support (drm_stub.h) */
extern int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent);
extern int DRM(put_minor)(drm_device_t *dev);
extern drm_global_t *DRM(global);
extern int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver_fn *driver_fn);
extern int drm_put_minor(drm_device_t *dev);
extern unsigned int drm_debug;
extern unsigned int drm_cards_limit;
extern drm_minor_t *drm_minors;
extern struct class_simple *drm_class;
extern struct proc_dir_entry *drm_proc_root;
extern struct file_operations drm_stub_fops;
/* Proc support (drm_proc.h) */
extern int DRM(proc_init)(drm_device_t *dev,
extern int drm_proc_init(drm_device_t *dev,
int minor,
struct proc_dir_entry *root,
struct proc_dir_entry **dev_root);
extern int DRM(proc_cleanup)(int minor,
extern int drm_proc_cleanup(int minor,
struct proc_dir_entry *root,
struct proc_dir_entry *dev_root);
/* Scatter Gather Support (drm_scatter.h) */
extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
extern void drm_sg_cleanup(drm_sg_mem_t *entry);
extern int drm_sg_alloc(struct inode *inode, struct file *filp,
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);
/* 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,
unsigned long *addr,
dma_addr_t *bus_addr);
extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
extern int drm_ati_pcigart_cleanup(drm_device_t *dev,
unsigned long addr,
dma_addr_t bus_addr);
......@@ -973,18 +993,18 @@ extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
/* Inline replacements for DRM_IOREMAP macros */
static __inline__ void drm_core_ioremap(struct drm_map *map, struct drm_device *dev)
{
map->handle = DRM(ioremap)( map->offset, map->size, dev );
map->handle = drm_ioremap( map->offset, map->size, dev );
}
static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, struct drm_device *dev)
{
map->handle = DRM(ioremap_nocache)(map->offset, map->size, dev);
map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
}
static __inline__ void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
{
if ( map->handle && map->size )
DRM(ioremapfree)( map->handle, map->size, dev );
drm_ioremapfree( map->handle, map->size, dev );
}
static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
......@@ -1006,25 +1026,25 @@ static __inline__ void drm_core_dropmap(struct drm_map *map)
#ifndef DEBUG_MEMORY
/** Wrapper around kmalloc() */
static __inline__ void *DRM(alloc)(size_t size, int area)
static __inline__ void *drm_alloc(size_t size, int area)
{
return kmalloc(size, GFP_KERNEL);
}
/** Wrapper around kfree() */
static __inline__ void DRM(free)(void *pt, size_t size, int area)
static __inline__ void drm_free(void *pt, size_t size, int area)
{
kfree(pt);
}
#else
extern void *DRM(alloc)(size_t size, int area);
extern void DRM(free)(void *pt, size_t size, int area);
extern void *drm_alloc(size_t size, int area);
extern void drm_free(void *pt, size_t size, int area);
#endif
/*@}*/
extern unsigned long DRM(core_get_map_ofs)(drm_map_t *map);
extern unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev);
extern unsigned long drm_core_get_map_ofs(drm_map_t *map);
extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
#endif /* __KERNEL__ */
#endif
......@@ -56,7 +56,7 @@ static const drm_agp_t *drm_agp = NULL;
* Verifies the AGP device has been initialized and acquired and fills in the
* drm_agp_info structure with the information in drm_agp_head::agp_info.
*/
int DRM(agp_info)(struct inode *inode, struct file *filp,
int drm_agp_info(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -95,7 +95,7 @@ int DRM(agp_info)(struct inode *inode, struct file *filp,
* Verifies the AGP device hasn't been acquired before and calls
* drm_agp->acquire().
*/
int DRM(agp_acquire)(struct inode *inode, struct file *filp,
int drm_agp_acquire(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -125,7 +125,7 @@ int DRM(agp_acquire)(struct inode *inode, struct file *filp,
*
* Verifies the AGP device has been acquired and calls drm_agp->release().
*/
int DRM(agp_release)(struct inode *inode, struct file *filp,
int drm_agp_release(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -144,7 +144,7 @@ int DRM(agp_release)(struct inode *inode, struct file *filp,
*
* Calls drm_agp->release().
*/
void DRM(agp_do_release)(void)
void drm_agp_do_release(void)
{
if (drm_agp->release)
drm_agp->release();
......@@ -162,7 +162,7 @@ void DRM(agp_do_release)(void)
* Verifies the AGP device has been acquired but not enabled, and calls
* drm_agp->enable().
*/
int DRM(agp_enable)(struct inode *inode, struct file *filp,
int drm_agp_enable(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -194,7 +194,7 @@ int DRM(agp_enable)(struct inode *inode, struct file *filp,
* Verifies the AGP device is present and has been acquired, allocates the
* memory via alloc_agp() and creates a drm_agp_mem entry for it.
*/
int DRM(agp_alloc)(struct inode *inode, struct file *filp,
int drm_agp_alloc(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -210,7 +210,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
return -EINVAL;
if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
if (!(entry = DRM(alloc)(sizeof(*entry), DRM_MEM_AGPLISTS)))
if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
return -ENOMEM;
memset(entry, 0, sizeof(*entry));
......@@ -218,8 +218,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request.type;
if (!(memory = DRM(alloc_agp)(pages, type))) {
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
if (!(memory = drm_alloc_agp(pages, type))) {
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -ENOMEM;
}
......@@ -239,8 +239,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
if (copy_to_user(argp, &request, sizeof(request))) {
dev->agp->memory = entry->next;
dev->agp->memory->prev = NULL;
DRM(free_agp)(memory, pages);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
drm_free_agp(memory, pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -EFAULT;
}
return 0;
......@@ -255,7 +255,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
*
* Walks through drm_agp_head::memory until finding a matching handle.
*/
static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev,
static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t *dev,
unsigned long handle)
{
drm_agp_mem_t *entry;
......@@ -279,7 +279,7 @@ static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev,
* Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function.
*/
int DRM(agp_unbind)(struct inode *inode, struct file *filp,
int drm_agp_unbind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -292,11 +292,11 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp,
return -EINVAL;
if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request)))
return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle)))
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL;
if (!entry->bound)
return -EINVAL;
ret = DRM(unbind_agp)(entry->memory);
ret = drm_unbind_agp(entry->memory);
if (ret == 0)
entry->bound = 0;
return ret;
......@@ -315,7 +315,7 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp,
* is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function.
*/
int DRM(agp_bind)(struct inode *inode, struct file *filp,
int drm_agp_bind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -329,12 +329,12 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp,
return -EINVAL;
if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request)))
return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle)))
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL;
if (entry->bound)
return -EINVAL;
page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE;
if ((retcode = DRM(bind_agp)(entry->memory, page)))
if ((retcode = drm_bind_agp(entry->memory, page)))
return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT);
DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
......@@ -356,7 +356,7 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp,
* unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in.
*/
int DRM(agp_free)(struct inode *inode, struct file *filp,
int drm_agp_free(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -368,10 +368,10 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
return -EINVAL;
if (copy_from_user(&request, (drm_agp_buffer_t __user *)arg, sizeof(request)))
return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle)))
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL;
if (entry->bound)
DRM(unbind_agp)(entry->memory);
drm_unbind_agp(entry->memory);
if (entry->prev)
entry->prev->next = entry->next;
......@@ -381,8 +381,8 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
if (entry->next)
entry->next->prev = entry->prev;
DRM(free_agp)(entry->memory, entry->pages);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0;
}
......@@ -395,18 +395,18 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
* via the inter_module_* functions. Creates and initializes a drm_agp_head
* structure.
*/
drm_agp_head_t *DRM(agp_init)(void)
drm_agp_head_t *drm_agp_init(void)
{
drm_agp_head_t *head = NULL;
drm_agp = DRM_AGP_GET;
if (drm_agp) {
if (!(head = DRM(alloc)(sizeof(*head), DRM_MEM_AGPLISTS)))
if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
return NULL;
memset((void *)head, 0, sizeof(*head));
drm_agp->copy_info(&head->agp_info);
if (head->agp_info.chipset == NOT_SUPPORTED) {
DRM(free)(head, sizeof(*head), DRM_MEM_AGPLISTS);
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS);
return NULL;
}
head->memory = NULL;
......@@ -426,14 +426,14 @@ drm_agp_head_t *DRM(agp_init)(void)
*
* Releases the pointer in ::drm_agp.
*/
void DRM(agp_uninit)(void)
void drm_agp_uninit(void)
{
DRM_AGP_PUT;
drm_agp = NULL;
}
/** Calls drm_agp->allocate_memory() */
DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type)
DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type)
{
if (!drm_agp->allocate_memory)
return NULL;
......@@ -441,7 +441,7 @@ DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type)
}
/** Calls drm_agp->free_memory() */
int DRM(agp_free_memory)(DRM_AGP_MEM *handle)
int drm_agp_free_memory(DRM_AGP_MEM *handle)
{
if (!handle || !drm_agp->free_memory)
return 0;
......@@ -450,7 +450,7 @@ int DRM(agp_free_memory)(DRM_AGP_MEM *handle)
}
/** Calls drm_agp->bind_memory() */
int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start)
int drm_agp_bind_memory(DRM_AGP_MEM *handle, off_t start)
{
if (!handle || !drm_agp->bind_memory)
return -EINVAL;
......@@ -458,7 +458,7 @@ int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start)
}
/** Calls drm_agp->unbind_memory() */
int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle)
int drm_agp_unbind_memory(DRM_AGP_MEM *handle)
{
if (!handle || !drm_agp->unbind_memory)
return -EINVAL;
......
......@@ -44,7 +44,7 @@
* The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be
* a power of 2.
*/
static int DRM(hash_magic)(drm_magic_t magic)
static int drm_hash_magic(drm_magic_t magic)
{
return magic & (DRM_HASH_SIZE-1);
}
......@@ -59,11 +59,11 @@ static int DRM(hash_magic)(drm_magic_t magic)
* the one with matching magic number, while holding the drm_device::struct_sem
* lock.
*/
static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
{
drm_file_t *retval = NULL;
drm_magic_entry_t *pt;
int hash = DRM(hash_magic)(magic);
int hash = drm_hash_magic(magic);
down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
......@@ -87,15 +87,15 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
* associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock.
*/
int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
{
int hash;
drm_magic_entry_t *entry;
DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic);
entry = DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC);
hash = drm_hash_magic(magic);
entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
if (!entry) return -ENOMEM;
memset(entry, 0, sizeof(*entry));
entry->magic = magic;
......@@ -124,7 +124,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
* Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock.
*/
int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
{
drm_magic_entry_t *prev = NULL;
drm_magic_entry_t *pt;
......@@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic);
hash = drm_hash_magic(magic);
down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
......@@ -152,7 +152,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
}
up(&dev->struct_sem);
DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
return -EINVAL;
}
......@@ -170,7 +170,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
* searches an unique non-zero magic number and add it associating it with \p
* filp.
*/
int DRM(getmagic)(struct inode *inode, struct file *filp,
int drm_getmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
static drm_magic_t sequence = 0;
......@@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
if (!sequence) ++sequence; /* reserve 0 */
auth.magic = sequence++;
spin_unlock(&lock);
} while (DRM(find_file)(dev, auth.magic));
} while (drm_find_file(dev, auth.magic));
priv->magic = auth.magic;
DRM(add_magic)(dev, priv, auth.magic);
drm_add_magic(dev, priv, auth.magic);
}
DRM_DEBUG("%u\n", auth.magic);
......@@ -210,7 +210,7 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
*
* Checks if \p filp is associated with the magic number passed in \arg.
*/
int DRM(authmagic)(struct inode *inode, struct file *filp,
int drm_authmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -221,9 +221,9 @@ int DRM(authmagic)(struct inode *inode, struct file *filp,
if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth)))
return -EFAULT;
DRM_DEBUG("%u\n", auth.magic);
if ((file = DRM(find_file)(dev, auth.magic))) {
if ((file = drm_find_file(dev, auth.magic))) {
file->authenticated = 1;
DRM(remove_magic)(dev, auth.magic);
drm_remove_magic(dev, auth.magic);
return 0;
}
return -EINVAL;
......
......@@ -45,7 +45,7 @@
*
* \todo Can be made faster.
*/
int DRM(order)( unsigned long size )
int drm_order( unsigned long size )
{
int order;
unsigned long tmp;
......@@ -58,6 +58,7 @@ int DRM(order)( unsigned long size )
return order;
}
EXPORT_SYMBOL(drm_order);
/**
* Ioctl to specify a range of memory that is available for mapping by a non-root process.
......@@ -72,7 +73,7 @@ int DRM(order)( unsigned long size )
* type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
* applicable and if supported by the kernel.
*/
int DRM(addmap)( struct inode *inode, struct file *filp,
int drm_addmap( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -83,12 +84,12 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
if ( !(filp->f_mode & 3) ) return -EACCES; /* Require read/write */
map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS );
map = drm_alloc( sizeof(*map), DRM_MEM_MAPS );
if ( !map )
return -ENOMEM;
if ( copy_from_user( map, argp, sizeof(*map) ) ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EFAULT;
}
......@@ -97,13 +98,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
* when processes fork.
*/
if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EINVAL;
}
DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n",
map->offset, map->size, map->type );
if ( (map->offset & (~PAGE_MASK)) || (map->size & (~PAGE_MASK)) ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EINVAL;
}
map->mtrr = -1;
......@@ -115,7 +116,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__)
if ( map->offset + map->size < map->offset ||
map->offset < virt_to_phys(high_memory) ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EINVAL;
}
#endif
......@@ -130,16 +131,16 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
}
}
if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size,
map->handle = drm_ioremap( map->offset, map->size,
dev );
break;
case _DRM_SHM:
map->handle = vmalloc_32(map->size);
DRM_DEBUG( "%lu %d %p\n",
map->size, DRM(order)( map->size ), map->handle );
map->size, drm_order( map->size ), map->handle );
if ( !map->handle ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -ENOMEM;
}
map->offset = (unsigned long)map->handle;
......@@ -147,7 +148,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
/* Prevent a 2nd X Server from creating a 2nd lock */
if (dev->lock.hw_lock != NULL) {
vfree( map->handle );
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EBUSY;
}
dev->sigdata.lock =
......@@ -165,20 +166,20 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
break;
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
}
map->offset += dev->sg->handle;
break;
default:
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return -EINVAL;
}
list = DRM(alloc)(sizeof(*list), DRM_MEM_MAPS);
list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
if(!list) {
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
}
memset(list, 0, sizeof(*list));
......@@ -216,7 +217,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
*
* \sa addmap().
*/
int DRM(rmmap)(struct inode *inode, struct file *filp,
int drm_rmmap(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -252,7 +253,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
}
map = r_list->map;
list_del(list);
DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
drm_free(list, sizeof(*list), DRM_MEM_MAPS);
for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
if (pt->vma->vm_private_data == map) found_maps++;
......@@ -271,7 +272,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
DRM_DEBUG("mtrr_del = %d\n", retcode);
}
}
DRM(ioremapfree)(map->handle, map->size, dev);
drm_ioremapfree(map->handle, map->size, dev);
break;
case _DRM_SHM:
vfree(map->handle);
......@@ -280,7 +281,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
case _DRM_SCATTER_GATHER:
break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
up(&dev->struct_sem);
return 0;
......@@ -293,19 +294,19 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
*
* Frees any pages and buffers associated with the given entry.
*/
static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry)
static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry)
{
int i;
if (entry->seg_count) {
for (i = 0; i < entry->seg_count; i++) {
if (entry->seglist[i]) {
DRM(free_pages)(entry->seglist[i],
drm_free_pages(entry->seglist[i],
entry->page_order,
DRM_MEM_DMA);
}
}
DRM(free)(entry->seglist,
drm_free(entry->seglist,
entry->seg_count *
sizeof(*entry->seglist),
DRM_MEM_SEGS);
......@@ -316,12 +317,12 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry)
if (entry->buf_count) {
for (i = 0; i < entry->buf_count; i++) {
if (entry->buflist[i].dev_private) {
DRM(free)(entry->buflist[i].dev_private,
drm_free(entry->buflist[i].dev_private,
entry->buflist[i].dev_priv_size,
DRM_MEM_BUFS);
}
}
DRM(free)(entry->buflist,
drm_free(entry->buflist,
entry->buf_count *
sizeof(*entry->buflist),
DRM_MEM_BUFS);
......@@ -344,7 +345,7 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry)
* reallocates the buffer list of the same size order to accommodate the new
* buffers.
*/
int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
int drm_addbufs_agp( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -373,7 +374,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
order = DRM(order)( request.size );
order = drm_order( request.size );
size = 1 << order;
alignment = (request.flags & _DRM_PAGE_ALIGN)
......@@ -417,7 +418,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
return -EINVAL;
}
entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist),
entry->buflist = drm_alloc( count * sizeof(*entry->buflist),
DRM_MEM_BUFS );
if ( !entry->buflist ) {
up( &dev->struct_sem );
......@@ -447,13 +448,13 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
buf->dev_private = DRM(alloc)( buf->dev_priv_size,
buf->dev_priv_size = dev->fn_tbl->dev_priv_size;
buf->dev_private = drm_alloc( buf->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
DRM(cleanup_buf_error)(entry);
drm_cleanup_buf_error(dev,entry);
up( &dev->struct_sem );
atomic_dec( &dev->buf_alloc );
return -ENOMEM;
......@@ -470,14 +471,14 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
DRM_DEBUG( "byte_count: %d\n", byte_count );
temp_buflist = DRM(realloc)( dma->buflist,
temp_buflist = drm_realloc( dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count)
* sizeof(*dma->buflist),
DRM_MEM_BUFS );
if(!temp_buflist) {
/* Free the entry because it isn't valid */
DRM(cleanup_buf_error)(entry);
drm_cleanup_buf_error(dev,entry);
up( &dev->struct_sem );
atomic_dec( &dev->buf_alloc );
return -ENOMEM;
......@@ -509,7 +510,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
}
#endif /* __OS_HAS_AGP */
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 )
{
drm_file_t *priv = filp->private_data;
......@@ -540,7 +541,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
order = DRM(order)( request.size );
order = drm_order( request.size );
size = 1 << order;
DRM_DEBUG( "count=%d, size=%d (%d), order=%d, queue_count=%d\n",
......@@ -577,7 +578,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
return -EINVAL;
}
entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist),
entry->buflist = drm_alloc( count * sizeof(*entry->buflist),
DRM_MEM_BUFS );
if ( !entry->buflist ) {
up( &dev->struct_sem );
......@@ -586,10 +587,10 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
}
memset( entry->buflist, 0, count * sizeof(*entry->buflist) );
entry->seglist = DRM(alloc)( count * sizeof(*entry->seglist),
entry->seglist = drm_alloc( count * sizeof(*entry->seglist),
DRM_MEM_SEGS );
if ( !entry->seglist ) {
DRM(free)( entry->buflist,
drm_free( entry->buflist,
count * sizeof(*entry->buflist),
DRM_MEM_BUFS );
up( &dev->struct_sem );
......@@ -601,14 +602,14 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
/* Keep the original pagelist until we know all the allocations
* have succeeded
*/
temp_pagelist = DRM(alloc)( (dma->page_count + (count << page_order))
temp_pagelist = drm_alloc( (dma->page_count + (count << page_order))
* sizeof(*dma->pagelist),
DRM_MEM_PAGES );
if (!temp_pagelist) {
DRM(free)( entry->buflist,
drm_free( entry->buflist,
count * sizeof(*entry->buflist),
DRM_MEM_BUFS );
DRM(free)( entry->seglist,
drm_free( entry->seglist,
count * sizeof(*entry->seglist),
DRM_MEM_SEGS );
up( &dev->struct_sem );
......@@ -627,13 +628,13 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
page_count = 0;
while ( entry->buf_count < count ) {
page = DRM(alloc_pages)( page_order, DRM_MEM_DMA );
page = drm_alloc_pages( page_order, DRM_MEM_DMA );
if ( !page ) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
entry->seg_count = count;
DRM(cleanup_buf_error)(entry);
DRM(free)( temp_pagelist,
drm_cleanup_buf_error(dev, entry);
drm_free( temp_pagelist,
(dma->page_count + (count << page_order))
* sizeof(*dma->pagelist),
DRM_MEM_PAGES );
......@@ -665,15 +666,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
buf->dev_private = DRM(alloc)( dev->dev_priv_size,
buf->dev_priv_size = dev->fn_tbl->dev_priv_size;
buf->dev_private = drm_alloc( buf->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
entry->seg_count = count;
DRM(cleanup_buf_error)(entry);
DRM(free)( temp_pagelist,
drm_cleanup_buf_error(dev,entry);
drm_free( temp_pagelist,
(dma->page_count + (count << page_order))
* sizeof(*dma->pagelist),
DRM_MEM_PAGES );
......@@ -689,15 +690,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
byte_count += PAGE_SIZE << page_order;
}
temp_buflist = DRM(realloc)( dma->buflist,
temp_buflist = drm_realloc( dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count)
* sizeof(*dma->buflist),
DRM_MEM_BUFS );
if (!temp_buflist) {
/* Free the entry because it isn't valid */
DRM(cleanup_buf_error)(entry);
DRM(free)( temp_pagelist,
drm_cleanup_buf_error(dev,entry);
drm_free( temp_pagelist,
(dma->page_count + (count << page_order))
* sizeof(*dma->pagelist),
DRM_MEM_PAGES );
......@@ -715,7 +716,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
* with the new one.
*/
if (dma->page_count) {
DRM(free)(dma->pagelist,
drm_free(dma->pagelist,
dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES);
}
......@@ -739,7 +740,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
}
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 )
{
drm_file_t *priv = filp->private_data;
......@@ -769,7 +770,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
return -EFAULT;
count = request.count;
order = DRM(order)( request.size );
order = drm_order( request.size );
size = 1 << order;
alignment = (request.flags & _DRM_PAGE_ALIGN)
......@@ -813,7 +814,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
return -EINVAL;
}
entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist),
entry->buflist = drm_alloc( count * sizeof(*entry->buflist),
DRM_MEM_BUFS );
if ( !entry->buflist ) {
up( &dev->struct_sem );
......@@ -843,13 +844,13 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
buf->dev_private = DRM(alloc)( dev->dev_priv_size,
buf->dev_priv_size = dev->fn_tbl->dev_priv_size;
buf->dev_private = drm_alloc( buf->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
DRM(cleanup_buf_error)(entry);
drm_cleanup_buf_error(dev,entry);
up( &dev->struct_sem );
atomic_dec( &dev->buf_alloc );
return -ENOMEM;
......@@ -867,14 +868,14 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
DRM_DEBUG( "byte_count: %d\n", byte_count );
temp_buflist = DRM(realloc)( dma->buflist,
temp_buflist = drm_realloc( dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count)
* sizeof(*dma->buflist),
DRM_MEM_BUFS );
if(!temp_buflist) {
/* Free the entry because it isn't valid */
DRM(cleanup_buf_error)(entry);
drm_cleanup_buf_error(dev,entry);
up( &dev->struct_sem );
atomic_dec( &dev->buf_alloc );
return -ENOMEM;
......@@ -919,7 +920,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
* addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
* PCI memory respectively.
*/
int DRM(addbufs)( struct inode *inode, struct file *filp,
int drm_addbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_buf_desc_t request;
......@@ -935,13 +936,13 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
#if __OS_HAS_AGP
if ( request.flags & _DRM_AGP_BUFFER )
return DRM(addbufs_agp)( inode, filp, cmd, arg );
return drm_addbufs_agp( inode, filp, cmd, arg );
else
#endif
if ( request.flags & _DRM_SG_BUFFER )
return DRM(addbufs_sg)( inode, filp, cmd, arg );
return drm_addbufs_sg( inode, filp, cmd, arg );
else
return DRM(addbufs_pci)( inode, filp, cmd, arg );
return drm_addbufs_pci( inode, filp, cmd, arg );
}
......@@ -962,7 +963,7 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
* lock, preventing of allocating more buffers after this call. Information
* about each requested buffer is then copied into user space.
*/
int DRM(infobufs)( struct inode *inode, struct file *filp,
int drm_infobufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -1047,7 +1048,7 @@ int DRM(infobufs)( struct inode *inode, struct file *filp,
*
* \note This ioctl is deprecated and mostly never used.
*/
int DRM(markbufs)( struct inode *inode, struct file *filp,
int drm_markbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -1069,7 +1070,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
DRM_DEBUG( "%d, %d, %d\n",
request.size, request.low_mark, request.high_mark );
order = DRM(order)( request.size );
order = drm_order( request.size );
if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) return -EINVAL;
entry = &dma->bufs[order];
......@@ -1096,7 +1097,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
* Calls free_buffer() for each used buffer.
* This function is primarily used for debugging.
*/
int DRM(freebufs)( struct inode *inode, struct file *filp,
int drm_freebufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -1134,7 +1135,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
current->pid );
return -EINVAL;
}
DRM(free_buffer)( dev, buf );
drm_free_buffer( dev, buf );
}
return 0;
......@@ -1153,7 +1154,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
* about each buffer into user space. The PCI buffers are already mapped on the
* addbufs_pci() call.
*/
int DRM(mapbufs)( struct inode *inode, struct file *filp,
int drm_mapbufs( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......
......@@ -56,7 +56,7 @@
* in drm_device::context_sareas, while holding the drm_device::struct_sem
* lock.
*/
void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle )
{
if ( ctx_handle < 0 ) goto failed;
if ( !dev->ctx_bitmap ) goto failed;
......@@ -84,7 +84,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
* drm_device::context_sareas to accommodate the new entry while holding the
* drm_device::struct_sem lock.
*/
int DRM(ctxbitmap_next)( drm_device_t *dev )
int drm_ctxbitmap_next( drm_device_t *dev )
{
int bit;
......@@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if(dev->context_sareas) {
drm_map_t **ctx_sareas;
ctx_sareas = DRM(realloc)(dev->context_sareas,
ctx_sareas = drm_realloc(dev->context_sareas,
(dev->max_context - 1) *
sizeof(*dev->context_sareas),
dev->max_context *
......@@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
dev->context_sareas[bit] = NULL;
} else {
/* max_context == 1 at this point */
dev->context_sareas = DRM(alloc)(
dev->context_sareas = drm_alloc(
dev->max_context *
sizeof(*dev->context_sareas),
DRM_MEM_MAPS);
......@@ -142,13 +142,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
* Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock.
*/
int DRM(ctxbitmap_init)( drm_device_t *dev )
int drm_ctxbitmap_init( drm_device_t *dev )
{
int i;
int temp;
down(&dev->struct_sem);
dev->ctx_bitmap = (unsigned long *) DRM(alloc)( PAGE_SIZE,
dev->ctx_bitmap = (unsigned long *) drm_alloc( PAGE_SIZE,
DRM_MEM_CTXBITMAP );
if ( dev->ctx_bitmap == NULL ) {
up(&dev->struct_sem);
......@@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
up(&dev->struct_sem);
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
temp = DRM(ctxbitmap_next)( dev );
temp = drm_ctxbitmap_next( dev );
DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
}
......@@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
* Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock.
*/
void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
void drm_ctxbitmap_cleanup( drm_device_t *dev )
{
down(&dev->struct_sem);
if( dev->context_sareas ) DRM(free)( dev->context_sareas,
if( dev->context_sareas ) drm_free( dev->context_sareas,
sizeof(*dev->context_sareas) *
dev->max_context,
DRM_MEM_MAPS );
DRM(free)( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP );
drm_free( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP );
up(&dev->struct_sem);
}
......@@ -204,7 +204,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
* Gets the map from drm_device::context_sareas with the handle specified and
* returns its handle.
*/
int DRM(getsareactx)(struct inode *inode, struct file *filp,
int drm_getsareactx(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -243,7 +243,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp,
* Searches the mapping specified in \p arg and update the entry in
* drm_device::context_sareas with it.
*/
int DRM(setsareactx)(struct inode *inode, struct file *filp,
int drm_setsareactx(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -297,7 +297,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
*
* Attempt to set drm_device::context_flag.
*/
int DRM(context_switch)( drm_device_t *dev, int old, int new )
int drm_context_switch( drm_device_t *dev, int old, int new )
{
if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" );
......@@ -326,7 +326,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new )
* hardware lock is held, clears the drm_device::context_flag and wakes up
* drm_device::context_wait.
*/
int DRM(context_switch_complete)( drm_device_t *dev, int new )
int drm_context_switch_complete( drm_device_t *dev, int new )
{
dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
dev->last_switch = jiffies;
......@@ -353,7 +353,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new )
* \param arg user argument pointing to a drm_ctx_res structure.
* \return zero on success or a negative number on failure.
*/
int DRM(resctx)( struct inode *inode, struct file *filp,
int drm_resctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_ctx_res_t res;
......@@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp,
*
* Get a new handle for the context and copy to userspace.
*/
int DRM(addctx)( struct inode *inode, struct file *filp,
int drm_addctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( copy_from_user( &ctx, argp, sizeof(ctx) ) )
return -EFAULT;
ctx.handle = DRM(ctxbitmap_next)( dev );
ctx.handle = drm_ctxbitmap_next( dev );
if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
/* Skip kernel's context and get a new one. */
ctx.handle = DRM(ctxbitmap_next)( dev );
ctx.handle = drm_ctxbitmap_next( dev );
}
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle == -1 ) {
......@@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( ctx.handle != DRM_KERNEL_CONTEXT )
{
if (dev->fn_tbl.context_ctor)
dev->fn_tbl.context_ctor(dev, ctx.handle);
if (dev->fn_tbl->context_ctor)
dev->fn_tbl->context_ctor(dev, ctx.handle);
}
ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
ctx_entry = drm_alloc( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n");
return -ENOMEM;
......@@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
return 0;
}
int DRM(modctx)( struct inode *inode, struct file *filp,
int drm_modctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
/* This does nothing */
......@@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp,
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*/
int DRM(getctx)( struct inode *inode, struct file *filp,
int drm_getctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_ctx_t __user *argp = (void __user *)arg;
......@@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp,
*
* Calls context_switch().
*/
int DRM(switchctx)( struct inode *inode, struct file *filp,
int drm_switchctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle );
return DRM(context_switch)( dev, dev->last_context, ctx.handle );
return drm_context_switch( dev, dev->last_context, ctx.handle );
}
/**
......@@ -510,7 +510,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
*
* Calls context_switch_complete().
*/
int DRM(newctx)( struct inode *inode, struct file *filp,
int drm_newctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle );
DRM(context_switch_complete)( dev, ctx.handle );
drm_context_switch_complete( dev, ctx.handle );
return 0;
}
......@@ -537,7 +537,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
*
* If not the special kernel context, calls ctxbitmap_free() to free the specified context.
*/
int DRM(rmctx)( struct inode *inode, struct file *filp,
int drm_rmctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
priv->remove_auth_on_close = 1;
}
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor)
dev->fn_tbl.context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
if (dev->fn_tbl->context_dtor)
dev->fn_tbl->context_dtor(dev, ctx.handle);
drm_ctxbitmap_free( dev, ctx.handle );
}
down( &dev->ctxlist_sem );
......@@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->handle == ctx.handle ) {
list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST );
drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count;
}
}
......
......@@ -20,21 +20,15 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"
#include "drm_auth.h"
#include "drm_agpsupport.h"
#include "drm_bufs.h"
#include "drm_context.h"
#include "drm_dma.h"
#include "drm_irq.h"
#include "drm_drawable.h"
#include "drm_drv.h"
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
#include "drm_scatter.h"
#define DRIVER_NAME "drm"
#define DRIVER_DESC "DRM shared core routines"
#define DRIVER_DATE "20040925"
#define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 0
#define DRIVER_PATCHLEVEL 0
......@@ -43,11 +43,11 @@
*
* Allocate and initialize a drm_device_dma structure.
*/
int DRM(dma_setup)( drm_device_t *dev )
int drm_dma_setup( drm_device_t *dev )
{
int i;
dev->dma = DRM(alloc)( sizeof(*dev->dma), DRM_MEM_DRIVER );
dev->dma = drm_alloc( sizeof(*dev->dma), DRM_MEM_DRIVER );
if ( !dev->dma )
return -ENOMEM;
......@@ -67,7 +67,7 @@ int DRM(dma_setup)( drm_device_t *dev )
* Free all pages associated with DMA buffers, the buffers and pages lists, and
* finally the the drm_device::dma structure itself.
*/
void DRM(dma_takedown)(drm_device_t *dev)
void drm_dma_takedown(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
int i, j;
......@@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) {
if (dma->bufs[i].seglist[j]) {
DRM(free_pages)(dma->bufs[i].seglist[j],
drm_free_pages(dma->bufs[i].seglist[j],
dma->bufs[i].page_order,
DRM_MEM_DMA);
}
}
DRM(free)(dma->bufs[i].seglist,
drm_free(dma->bufs[i].seglist,
dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist),
DRM_MEM_SEGS);
......@@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) {
if (dma->bufs[i].buflist[j].dev_private) {
DRM(free)(dma->bufs[i].buflist[j].dev_private,
drm_free(dma->bufs[i].buflist[j].dev_private,
dma->bufs[i].buflist[j].dev_priv_size,
DRM_MEM_BUFS);
}
}
DRM(free)(dma->bufs[i].buflist,
drm_free(dma->bufs[i].buflist,
dma->bufs[i].buf_count *
sizeof(*dma->bufs[0].buflist),
DRM_MEM_BUFS);
......@@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev)
}
if (dma->buflist) {
DRM(free)(dma->buflist,
drm_free(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
DRM_MEM_BUFS);
}
if (dma->pagelist) {
DRM(free)(dma->pagelist,
drm_free(dma->pagelist,
dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES);
}
DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
dev->dma = NULL;
}
......@@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev)
*
* Resets the fields of \p buf.
*/
void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
{
if (!buf) return;
......@@ -154,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
*
* Frees each buffer associated with \p filp not already on the hardware.
*/
void DRM(core_reclaim_buffers)( struct file *filp )
void drm_core_reclaim_buffers( struct file *filp )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
......@@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp )
if (dma->buflist[i]->filp == filp) {
switch (dma->buflist[i]->list) {
case DRM_LIST_NONE:
DRM(free_buffer)(dev, dma->buflist[i]);
drm_free_buffer(dev, dma->buflist[i]);
break;
case DRM_LIST_WAIT:
dma->buflist[i]->list = DRM_LIST_RECLAIM;
......@@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp )
}
}
}
EXPORT_SYMBOL(drm_core_reclaim_buffers);
......@@ -36,7 +36,7 @@
#include "drmP.h"
/** No-op. */
int DRM(adddraw)(struct inode *inode, struct file *filp,
int drm_adddraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_draw_t draw;
......@@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp,
}
/** No-op. */
int DRM(rmdraw)(struct inode *inode, struct file *filp,
int drm_rmdraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
return 0; /* NOOP */
......
......@@ -21,7 +21,7 @@
*
* #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls )
*
* #define DRM(x) mga_##x
* #define drm_x mga_##x
* \endcode
*/
......@@ -52,116 +52,95 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef DRIVER_IOCTLS
#define DRIVER_IOCTLS
#endif
#ifndef MODULE
/** Use an additional macro to avoid preprocessor troubles */
#define DRM_OPTIONS_FUNC DRM(options)
/**
* Called by the kernel to parse command-line options passed via the
* boot-loader (e.g., LILO). It calls the insmod option routine,
* parse_options().
*/
static int __init DRM(options)( char *str )
{
DRM(parse_options)( str );
return 1;
}
__setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
#undef DRM_OPTIONS_FUNC
#endif
#include "drmP.h"
#include "drm_core.h"
struct file_operations DRM(fops) = {
struct file_operations drm_fops = {
.owner = THIS_MODULE,
.open = DRM(open),
.flush = DRM(flush),
.release = DRM(release),
.ioctl = DRM(ioctl),
.mmap = DRM(mmap),
.fasync = DRM(fasync),
.poll = DRM(poll),
.read = DRM(read),
.open = drm_open,
.flush = drm_flush,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = drm_mmap,
.fasync = drm_fasync,
.poll = drm_poll,
.read = drm_read,
};
/** Ioctl table */
drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
[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_ADD_CTX)] = { DRM(addctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { DRM(infobufs), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 },
drm_ioctl_desc_t drm_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_by_busid, 0, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { drm_getmap, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { drm_getclient, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { drm_getstats, 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { drm_setversion, 0, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_noop, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_noop, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { drm_rmmap, 1, 0 },
[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_ADD_CTX)] = { drm_addctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { drm_lock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { drm_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_noop, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 },
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 },
#if __OS_HAS_AGP
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 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_ENABLE)] = { drm_agp_enable, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
#endif
[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_ALLOC)] = { drm_sg_alloc, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
DRIVER_IOCTLS
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0, 0 },
};
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls )
static int DRM(setup)( drm_device_t *dev )
static int drm_setup( drm_device_t *dev )
{
int i;
int ret;
if (dev->fn_tbl.presetup)
if (dev->fn_tbl->presetup)
{
ret=dev->fn_tbl.presetup(dev);
ret=dev->fn_tbl->presetup(dev);
if (ret!=0)
return ret;
}
......@@ -173,7 +152,7 @@ static int DRM(setup)( drm_device_t *dev )
if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
{
i = DRM(dma_setup)( dev );
i = drm_dma_setup( dev );
if ( i < 0 )
return i;
}
......@@ -186,13 +165,13 @@ static int DRM(setup)( drm_device_t *dev )
dev->magiclist[i].tail = NULL;
}
dev->maplist = DRM(alloc)(sizeof(*dev->maplist),
dev->maplist = drm_alloc(sizeof(*dev->maplist),
DRM_MEM_MAPS);
if(dev->maplist == NULL) return -ENOMEM;
memset(dev->maplist, 0, sizeof(*dev->maplist));
INIT_LIST_HEAD(&dev->maplist->head);
dev->ctxlist = DRM(alloc)(sizeof(*dev->ctxlist),
dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist),
DRM_MEM_CTXLIST);
if(dev->ctxlist == NULL) return -ENOMEM;
memset(dev->ctxlist, 0, sizeof(*dev->ctxlist));
......@@ -234,8 +213,8 @@ static int DRM(setup)( drm_device_t *dev )
* drm_select_queue fails between the time the interrupt is
* initialized and the time the queues are initialized.
*/
if (dev->fn_tbl.postsetup)
dev->fn_tbl.postsetup(dev);
if (dev->fn_tbl->postsetup)
dev->fn_tbl->postsetup(dev);
return 0;
}
......@@ -250,7 +229,7 @@ static int DRM(setup)( drm_device_t *dev )
*
* \sa drm_device and setup().
*/
static int DRM(takedown)( drm_device_t *dev )
static int drm_takedown( drm_device_t *dev )
{
drm_magic_entry_t *pt, *next;
drm_map_t *map;
......@@ -261,22 +240,22 @@ static int DRM(takedown)( drm_device_t *dev )
DRM_DEBUG( "\n" );
if (dev->fn_tbl.pretakedown)
dev->fn_tbl.pretakedown(dev);
if (dev->fn_tbl->pretakedown)
dev->fn_tbl->pretakedown(dev);
if ( dev->irq_enabled ) DRM(irq_uninstall)( dev );
if ( dev->irq_enabled ) drm_irq_uninstall( dev );
down( &dev->struct_sem );
del_timer( &dev->timer );
if ( dev->devname ) {
DRM(free)( dev->devname, strlen( dev->devname ) + 1,
drm_free( dev->devname, strlen( dev->devname ) + 1,
DRM_MEM_DRIVER );
dev->devname = NULL;
}
if ( dev->unique ) {
DRM(free)( dev->unique, strlen( dev->unique ) + 1,
drm_free( dev->unique, strlen( dev->unique ) + 1,
DRM_MEM_DRIVER );
dev->unique = NULL;
dev->unique_len = 0;
......@@ -285,7 +264,7 @@ static int DRM(takedown)( drm_device_t *dev )
for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) {
for ( pt = dev->magiclist[i].head ; pt ; pt = next ) {
next = pt->next;
DRM(free)( pt, sizeof(*pt), DRM_MEM_MAGIC );
drm_free( pt, sizeof(*pt), DRM_MEM_MAGIC );
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
......@@ -299,13 +278,13 @@ static int DRM(takedown)( drm_device_t *dev )
intact until drv_cleanup is called. */
for ( entry = dev->agp->memory ; entry ; entry = nexte ) {
nexte = entry->next;
if ( entry->bound ) DRM(unbind_agp)( entry->memory );
DRM(free_agp)( entry->memory, entry->pages );
DRM(free)( entry, sizeof(*entry), DRM_MEM_AGPLISTS );
if ( entry->bound ) drm_unbind_agp( entry->memory );
drm_free_agp( entry->memory, entry->pages );
drm_free( entry, sizeof(*entry), DRM_MEM_AGPLISTS );
}
dev->agp->memory = NULL;
if ( dev->agp->acquired ) DRM(agp_do_release)();
if ( dev->agp->acquired ) drm_agp_do_release();
dev->agp->acquired = 0;
dev->agp->enabled = 0;
......@@ -315,7 +294,7 @@ static int DRM(takedown)( drm_device_t *dev )
if ( dev->vmalist ) {
for ( vma = dev->vmalist ; vma ; vma = vma_next ) {
vma_next = vma->next;
DRM(free)( vma, sizeof(*vma), DRM_MEM_VMAS );
drm_free( vma, sizeof(*vma), DRM_MEM_VMAS );
}
dev->vmalist = NULL;
}
......@@ -337,7 +316,7 @@ static int DRM(takedown)( drm_device_t *dev )
DRM_DEBUG( "mtrr_del=%d\n", retcode );
}
}
DRM(ioremapfree)( map->handle, map->size, dev );
drm_ioremapfree( map->handle, map->size, dev );
break;
case _DRM_SHM:
vfree(map->handle);
......@@ -351,30 +330,30 @@ static int DRM(takedown)( drm_device_t *dev )
case _DRM_SCATTER_GATHER:
/* Handle it */
if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) {
DRM(sg_cleanup)(dev->sg);
drm_sg_cleanup(dev->sg);
dev->sg = NULL;
}
break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
list_del( list );
DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS);
drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS);
}
DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
dev->maplist = NULL;
}
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist ) {
for ( i = 0 ; i < dev->queue_count ; i++ ) {
if ( dev->queuelist[i] ) {
DRM(free)( dev->queuelist[i],
drm_free( dev->queuelist[i],
sizeof(*dev->queuelist[0]),
DRM_MEM_QUEUES );
dev->queuelist[i] = NULL;
}
}
DRM(free)( dev->queuelist,
drm_free( dev->queuelist,
dev->queue_slots * sizeof(*dev->queuelist),
DRM_MEM_QUEUES );
dev->queuelist = NULL;
......@@ -382,7 +361,7 @@ static int DRM(takedown)( drm_device_t *dev )
dev->queue_count = 0;
if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
DRM(dma_takedown)( dev );
drm_dma_takedown( dev );
if ( dev->lock.hw_lock ) {
dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
......@@ -394,20 +373,7 @@ static int DRM(takedown)( drm_device_t *dev )
return 0;
}
static void DRM(init_fn_table)(struct drm_device *dev)
{
dev->fn_tbl.reclaim_buffers = DRM(core_reclaim_buffers);
dev->fn_tbl.get_map_ofs = DRM(core_get_map_ofs);
dev->fn_tbl.get_reg_ofs = DRM(core_get_reg_ofs);
}
#include "drm_pciids.h"
static struct pci_device_id DRM(pciidlist)[] = {
DRM(PCI_IDS)
};
int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_device_id *ent)
int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver_fn *driver_fn)
{
int retcode;
......@@ -416,8 +382,7 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d
sema_init( &dev->struct_sem, 1 );
sema_init( &dev->ctxlist_sem, 1 );
dev->name = DRIVER_NAME;
dev->fops = &DRM(fops);
dev->fops = &drm_fops;
dev->pdev = pdev;
#ifdef __alpha__
......@@ -431,10 +396,7 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d
dev->pci_func = PCI_FUNC(pdev->devfn);
dev->irq = pdev->irq;
/* dev_priv_size can be changed by a driver in driver_register_fns */
dev->dev_priv_size = sizeof(u32);
/* the DRM has 6 basic counters - drivers add theirs in register_fns */
/* the DRM has 6 basic counters */
dev->counters = 6;
dev->types[0] = _DRM_STAT_LOCK;
dev->types[1] = _DRM_STAT_OPENS;
......@@ -443,16 +405,14 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d
dev->types[4] = _DRM_STAT_LOCKS;
dev->types[5] = _DRM_STAT_UNLOCKS;
DRM(init_fn_table)(dev);
DRM(driver_register_fns)(dev);
if (dev->fn_tbl.preinit)
if ((retcode = dev->fn_tbl.preinit(dev)))
dev->fn_tbl = driver_fn;
if (dev->fn_tbl->preinit)
if ((retcode = dev->fn_tbl->preinit(dev)))
goto error_out_unreg;
if (drm_core_has_AGP(dev)) {
dev->agp = DRM(agp_init)();
dev->agp = drm_agp_init();
if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" );
retcode = -EINVAL;
......@@ -467,7 +427,7 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d
}
}
retcode = DRM(ctxbitmap_init)( dev );
retcode = drm_ctxbitmap_init( dev );
if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
goto error_out_unreg;
......@@ -475,31 +435,17 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d
dev->device = MKDEV(DRM_MAJOR, dev->minor );
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(pdev));
if (dev->fn_tbl.postinit)
if ((retcode = dev->fn_tbl.postinit(dev)))
goto error_out_unreg;
/* postinit is a required function to display the signon banner */
if ((retcode = dev->fn_tbl->postinit(dev, ent->driver_data)))
goto error_out_unreg;
return 0;
error_out_unreg:
DRM(takedown)(dev);
drm_takedown(dev);
return retcode;
}
#ifdef MODULE
static char *drm_opts = NULL;
#endif
MODULE_PARM( drm_opts, "s" );
/**
* Module initialization. Called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported).
......@@ -513,7 +459,7 @@ MODULE_PARM( drm_opts, "s" );
* Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
* after the initialization for driver customization.
*/
static int __init drm_init( void )
int drm_init( struct drm_driver_fn *driver_fn )
{
struct pci_dev *pdev = NULL;
struct pci_device_id *pid;
......@@ -521,25 +467,22 @@ static int __init drm_init( void )
DRM_DEBUG( "\n" );
#ifdef MODULE
DRM(parse_options)( drm_opts );
#endif
DRM(mem_init)();
drm_mem_init();
for (i=0; DRM(pciidlist)[i].vendor != 0; i++) {
pid = &DRM(pciidlist[i]);
for (i=0; driver_fn->pci_driver.id_table[i].vendor != 0; i++) {
pid = (struct pci_device_id *)&driver_fn->pci_driver.id_table[i];
pdev=NULL;
/* pass back in pdev to account for multiple identical cards */
while ((pdev = pci_get_subsys(pid->vendor, pid->device, pid->subvendor, pid->subdevice, pdev)) != NULL) {
/* stealth mode requires a manual probe */
pci_dev_get(pdev);
DRM(probe)(pdev, pid);
drm_probe(pdev, pid, driver_fn);
}
}
return 0;
}
EXPORT_SYMBOL(drm_init);
/**
* Called via cleanup_module() at module unload time.
......@@ -548,7 +491,7 @@ static int __init drm_init( void )
*
* \sa drm_init().
*/
static void __exit drm_cleanup( drm_device_t *dev )
static void drm_cleanup( drm_device_t *dev )
{
DRM_DEBUG( "\n" );
......@@ -557,9 +500,9 @@ static void __exit drm_cleanup( drm_device_t *dev )
return;
}
DRM(takedown)( dev );
drm_takedown( dev );
DRM(ctxbitmap_cleanup)( dev );
drm_ctxbitmap_cleanup( dev );
if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
dev->agp && dev->agp->agp_mtrr >= 0) {
......@@ -571,45 +514,105 @@ static void __exit drm_cleanup( drm_device_t *dev )
}
if (drm_core_has_AGP(dev) && dev->agp ) {
DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
drm_agp_uninit();
drm_free( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL;
}
if (dev->fn_tbl.postcleanup)
dev->fn_tbl.postcleanup(dev);
if (dev->fn_tbl->postcleanup)
dev->fn_tbl->postcleanup(dev);
if ( DRM(put_minor)(dev) )
if ( drm_put_minor(dev) )
DRM_ERROR( "Cannot unload module\n" );
}
static void __exit drm_exit (void)
void drm_exit (struct drm_driver_fn *driver_fn)
{
int i;
drm_device_t *dev;
drm_device_t *dev = NULL;
drm_minor_t *minor;
DRM_DEBUG( "\n" );
if (DRM(global)) {
for (i = 0; DRM(global) && (i < DRM(global)->cards_limit); i++) {
minor = &DRM(global)->minors[i];
dev = minor->dev;
for (i = 0; i < drm_cards_limit; i++) {
minor = &drm_minors[i];
if (!minor->dev)
continue;
if (minor->dev->fn_tbl!=driver_fn)
continue;
if ((minor->type == DRM_MINOR_PRIMARY) && (dev->fops == &DRM(fops))) {
/* release the pci driver */
if (dev->pdev)
pci_dev_put(dev->pdev);
drm_cleanup(dev);
}
}
}
dev = minor->dev;
}
if (dev) {
/* release the pci driver */
if (dev->pdev)
pci_dev_put(dev->pdev);
drm_cleanup(dev);
}
DRM_INFO( "Module unloaded\n" );
}
EXPORT_SYMBOL(drm_exit);
static int __init drm_core_init(void)
{
int ret = -ENOMEM;
drm_cards_limit = (drm_cards_limit < DRM_MAX_MINOR + 1 ? drm_cards_limit : DRM_MAX_MINOR + 1);
drm_minors = drm_calloc(drm_cards_limit,
sizeof(*drm_minors), DRM_MEM_STUB);
if(!drm_minors)
goto err_p1;
if (register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops))
goto err_p1;
drm_class = class_simple_create(THIS_MODULE, "drm");
if (IS_ERR(drm_class)) {
printk (KERN_ERR "DRM: Error creating drm class.\n");
ret = PTR_ERR(drm_class);
goto err_p2;
}
drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL);
if (!drm_proc_root) {
DRM_ERROR("Cannot create /proc/dri\n");
ret = -1;
goto err_p3;
}
DRM_INFO( "Initialized %s %d.%d.%d %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE
);
return 0;
err_p3:
class_simple_destroy(drm_class);
err_p2:
unregister_chrdev(DRM_MAJOR, "drm");
drm_free(drm_minors, sizeof(*drm_minors) * drm_cards_limit, DRM_MEM_STUB);
err_p1:
return ret;
}
static void __exit drm_core_exit (void)
{
remove_proc_entry("dri", NULL);
class_simple_destroy(drm_class);
unregister_chrdev(DRM_MAJOR, "drm");
drm_free(drm_minors, sizeof(*drm_minors) *
drm_cards_limit, DRM_MEM_STUB);
}
module_init( drm_init );
module_exit( drm_exit );
module_init( drm_core_init );
module_exit( drm_core_exit );
/**
......@@ -623,33 +626,22 @@ module_exit( drm_exit );
*
* Fills in the version information in \p arg.
*/
int DRM(version)( struct inode *inode, struct file *filp,
int drm_version( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_version_t __user *argp = (void __user *)arg;
drm_version_t version;
int len;
int ret;
if ( copy_from_user( &version, argp, sizeof(version) ) )
return -EFAULT;
#define DRM_COPY( name, value ) \
len = strlen( value ); \
if ( len > name##_len ) len = name##_len; \
name##_len = strlen( value ); \
if ( len && name ) { \
if ( copy_to_user( name, value, len ) ) \
return -EFAULT; \
}
version.version_major = DRIVER_MAJOR;
version.version_minor = DRIVER_MINOR;
version.version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version.name, DRIVER_NAME );
DRM_COPY( version.date, DRIVER_DATE );
DRM_COPY( version.desc, DRIVER_DESC );
/* version is a required function to return the personality module version */
if ((ret = dev->fn_tbl->version(&version)))
return ret;
if ( copy_to_user( argp, &version, sizeof(version) ) )
return -EFAULT;
return 0;
......@@ -666,32 +658,33 @@ int DRM(version)( struct inode *inode, struct file *filp,
* increments the device open count. If the open count was previous at zero,
* i.e., it's the first that the device is open, then calls setup().
*/
int DRM(open)( struct inode *inode, struct file *filp )
int drm_open( struct inode *inode, struct file *filp )
{
drm_device_t *dev = NULL;
int minor = iminor(inode);
int retcode = 0;
if (!((minor >= 0) && (minor < DRM(global)->cards_limit)))
if (!((minor >= 0) && (minor < drm_cards_limit)))
return -ENODEV;
dev = DRM(global)->minors[minor].dev;
dev = drm_minors[minor].dev;
if (!dev)
return -ENODEV;
retcode = DRM(open_helper)( inode, filp, dev );
retcode = drm_open_helper( inode, filp, dev );
if ( !retcode ) {
atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
spin_lock( &dev->count_lock );
if ( !dev->open_count++ ) {
spin_unlock( &dev->count_lock );
return DRM(setup)( dev );
return drm_setup( dev );
}
spin_unlock( &dev->count_lock );
}
return retcode;
}
EXPORT_SYMBOL(drm_open);
/**
* Release file.
......@@ -705,7 +698,7 @@ int DRM(open)( struct inode *inode, struct file *filp )
* data from its list and free it. Decreases the open count and if it reaches
* zero calls takedown().
*/
int DRM(release)( struct inode *inode, struct file *filp )
int drm_release( struct inode *inode, struct file *filp )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev;
......@@ -716,8 +709,8 @@ int DRM(release)( struct inode *inode, struct file *filp )
DRM_DEBUG( "open_count = %d\n", dev->open_count );
if (dev->fn_tbl.prerelease)
dev->fn_tbl.prerelease(dev, filp);
if (dev->fn_tbl->prerelease)
dev->fn_tbl->prerelease(dev, filp);
/* ========================================================
* Begin inline drm_release
......@@ -733,10 +726,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
filp,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) );
if (dev->fn_tbl.release)
dev->fn_tbl.release(dev, filp);
if (dev->fn_tbl->release)
dev->fn_tbl->release(dev, filp);
DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
drm_lock_free( dev, &dev->lock.hw_lock->lock,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) );
/* FIXME: may require heavy-handed reset of
......@@ -744,7 +737,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
processed via a callback to the X
server. */
}
else if ( dev->fn_tbl.release && priv->lock_count && dev->lock.hw_lock ) {
else if ( dev->fn_tbl->release && priv->lock_count && dev->lock.hw_lock ) {
/* The lock is required to reclaim buffers */
DECLARE_WAITQUEUE( entry, current );
......@@ -756,7 +749,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
retcode = -EINTR;
break;
}
if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
if ( drm_lock_take( &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ) ) {
dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
......@@ -773,19 +766,19 @@ int DRM(release)( struct inode *inode, struct file *filp )
__set_current_state(TASK_RUNNING);
remove_wait_queue( &dev->lock.lock_queue, &entry );
if( !retcode ) {
if (dev->fn_tbl.release)
dev->fn_tbl.release(dev, filp);
DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
if (dev->fn_tbl->release)
dev->fn_tbl->release(dev, filp);
drm_lock_free( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT );
}
}
if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
{
dev->fn_tbl.reclaim_buffers(filp);
dev->fn_tbl->reclaim_buffers(filp);
}
DRM(fasync)( -1, filp, 0 );
drm_fasync( -1, filp, 0 );
down( &dev->ctxlist_sem );
if ( !list_empty( &dev->ctxlist->head ) ) {
......@@ -794,13 +787,13 @@ int DRM(release)( struct inode *inode, struct file *filp )
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->tag == priv &&
pos->handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor)
dev->fn_tbl.context_dtor(dev, pos->handle);
if (dev->fn_tbl->context_dtor)
dev->fn_tbl->context_dtor(dev, pos->handle);
DRM(ctxbitmap_free)( dev, pos->handle );
drm_ctxbitmap_free( dev, pos->handle );
list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST );
drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count;
}
}
......@@ -827,10 +820,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
up( &dev->struct_sem );
if (dev->fn_tbl.free_filp_priv)
dev->fn_tbl.free_filp_priv(dev, priv);
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 );
/* ========================================================
* End inline drm_release
......@@ -849,7 +842,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
spin_unlock( &dev->count_lock );
unlock_kernel();
return DRM(takedown)( dev );
return drm_takedown( dev );
}
spin_unlock( &dev->count_lock );
......@@ -857,6 +850,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
return retcode;
}
EXPORT_SYMBOL(drm_release);
/**
* Called whenever a process performs an ioctl on /dev/drm.
......@@ -870,15 +864,15 @@ int DRM(release)( struct inode *inode, struct file *filp )
* Looks up the ioctl function in the ::ioctls table, checking for root
* previleges if so required, and dispatches to the respective function.
*/
int DRM(ioctl)( struct inode *inode, struct file *filp,
int drm_ioctl( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_ioctl_desc_t *ioctl;
drm_ioctl_t *func;
int nr = DRM_IOCTL_NR(cmd);
int retcode = 0;
unsigned int nr = DRM_IOCTL_NR(cmd);
int retcode = -EINVAL;
atomic_inc( &dev->ioctl_count );
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
......@@ -887,27 +881,35 @@ int DRM(ioctl)( struct inode *inode, struct file *filp,
DRM_DEBUG( "pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
current->pid, cmd, nr, (long)old_encode_dev(dev->device),
priv->authenticated );
if ( nr >= DRIVER_IOCTL_COUNT ) {
if (nr < DRIVER_IOCTL_COUNT)
ioctl = &drm_ioctls[nr];
else if ((nr >= DRM_COMMAND_BASE) || (nr < DRM_COMMAND_BASE + dev->fn_tbl->num_ioctls))
ioctl = &dev->fn_tbl->ioctls[nr - DRM_COMMAND_BASE];
else
goto err_i1;
func = ioctl->func;
/* is there a local override? */
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->fn_tbl->dma_ioctl)
func = dev->fn_tbl->dma_ioctl;
if ( !func ) {
DRM_DEBUG( "no function\n" );
retcode = -EINVAL;
} else if ( ( ioctl->root_only && !capable( CAP_SYS_ADMIN ) )||
( ioctl->auth_needed && !priv->authenticated ) ) {
retcode = -EACCES;
} else {
ioctl = &DRM(ioctls)[nr];
func = ioctl->func;
if ( !func ) {
DRM_DEBUG( "no function\n" );
retcode = -EINVAL;
} else if ( ( ioctl->root_only && !capable( CAP_SYS_ADMIN ) )||
( ioctl->auth_needed && !priv->authenticated ) ) {
retcode = -EACCES;
} else {
retcode = func( inode, filp, cmd, arg );
}
retcode = func( inode, filp, cmd, arg );
}
err_i1:
atomic_dec( &dev->ioctl_count );
if (retcode) DRM_DEBUG( "ret = %x\n", retcode);
return retcode;
}
EXPORT_SYMBOL(drm_ioctl);
/**
* Lock ioctl.
......@@ -920,7 +922,7 @@ int DRM(ioctl)( struct inode *inode, struct file *filp,
*
* Add the current task to the lock wait queue, and attempt to take to lock.
*/
int DRM(lock)( struct inode *inode, struct file *filp,
int drm_lock( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -956,7 +958,7 @@ int DRM(lock)( struct inode *inode, struct file *filp,
ret = -EINTR;
break;
}
if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
if ( drm_lock_take( &dev->lock.hw_lock->lock,
lock.context ) ) {
dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
......@@ -981,22 +983,22 @@ int DRM(lock)( struct inode *inode, struct file *filp,
sigaddset( &dev->sigmask, SIGTTOU );
dev->sigdata.context = lock.context;
dev->sigdata.lock = dev->lock.hw_lock;
block_all_signals( DRM(notifier),
block_all_signals( drm_notifier,
&dev->sigdata, &dev->sigmask );
if (dev->fn_tbl.dma_ready && (lock.flags & _DRM_LOCK_READY))
dev->fn_tbl.dma_ready(dev);
if (dev->fn_tbl->dma_ready && (lock.flags & _DRM_LOCK_READY))
dev->fn_tbl->dma_ready(dev);
if ( dev->fn_tbl.dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT ))
return dev->fn_tbl.dma_quiescent(dev);
if ( dev->fn_tbl->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT ))
return dev->fn_tbl->dma_quiescent(dev);
/* dev->fn_tbl.kernel_context_switch isn't used by any of the x86
/* dev->fn_tbl->kernel_context_switch isn't used by any of the x86
* drivers but is used by the Sparc driver.
*/
if (dev->fn_tbl.kernel_context_switch &&
if (dev->fn_tbl->kernel_context_switch &&
dev->last_context != lock.context) {
dev->fn_tbl.kernel_context_switch(dev, dev->last_context,
dev->fn_tbl->kernel_context_switch(dev, dev->last_context,
lock.context);
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
......@@ -1015,7 +1017,7 @@ int DRM(lock)( struct inode *inode, struct file *filp,
*
* Transfer and free the lock.
*/
int DRM(unlock)( struct inode *inode, struct file *filp,
int drm_unlock( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -1036,13 +1038,13 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
/* kernel_context_switch isn't used by any of the x86 drm
* modules but is required by the Sparc driver.
*/
if (dev->fn_tbl.kernel_context_switch_unlock)
dev->fn_tbl.kernel_context_switch_unlock(dev, &lock);
if (dev->fn_tbl->kernel_context_switch_unlock)
dev->fn_tbl->kernel_context_switch_unlock(dev, &lock);
else {
DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
drm_lock_transfer( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT );
if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
if ( drm_lock_free( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ) ) {
DRM_ERROR( "\n" );
}
......
......@@ -49,18 +49,18 @@
* Creates and initializes a drm_file structure for the file private data in \p
* filp and add it into the double linked list in \p dev.
*/
int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev)
{
int minor = iminor(inode);
drm_file_t *priv;
int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL;
if (!drm_cpu_valid()) return -EINVAL;
DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
priv = DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
if(!priv) return -ENOMEM;
memset(priv, 0, sizeof(*priv));
......@@ -73,8 +73,8 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->authenticated = capable(CAP_SYS_ADMIN);
priv->lock_count = 0;
if (dev->fn_tbl.open_helper) {
ret=dev->fn_tbl.open_helper(dev, priv);
if (dev->fn_tbl->open_helper) {
ret=dev->fn_tbl->open_helper(dev, priv);
if (ret < 0)
goto out_free;
}
......@@ -113,13 +113,13 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
return 0;
out_free:
DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
filp->private_data=NULL;
return ret;
}
/** No-op. */
int DRM(flush)(struct file *filp)
int drm_flush(struct file *filp)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
......@@ -128,9 +128,10 @@ int DRM(flush)(struct file *filp)
current->pid, (long)old_encode_dev(dev->device), dev->open_count);
return 0;
}
EXPORT_SYMBOL(drm_flush);
/** No-op. */
int DRM(fasync)(int fd, struct file *filp, int on)
int drm_fasync(int fd, struct file *filp, int on)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
......@@ -141,16 +142,17 @@ int DRM(fasync)(int fd, struct file *filp, int on)
if (retcode < 0) return retcode;
return 0;
}
EXPORT_SYMBOL(drm_fasync);
/** No-op. */
unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
{
return 0;
}
/** No-op. */
ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count, loff_t *off)
ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off)
{
return 0;
}
......@@ -35,88 +35,12 @@
#include "drmP.h"
/** Debug flags. Set by parse_option(). */
#if 0
int DRM(flags) = DRM_FLAG_DEBUG;
#else
int DRM(flags) = 0;
#endif
/**
* Parse a single option.
*
* \param s option string.
*
* \sa See parse_options() for details.
*/
static void DRM(parse_option)(char *s)
{
char *c, *r;
DRM_DEBUG("\"%s\"\n", s);
if (!s || !*s) return;
for (c = s; *c && *c != ':'; c++); /* find : or \0 */
if (*c) r = c + 1; else r = NULL; /* remember remainder */
*c = '\0'; /* terminate */
if (!strcmp(s, "debug")) {
DRM(flags) |= DRM_FLAG_DEBUG;
DRM_INFO("Debug messages ON\n");
return;
}
DRM_ERROR("\"%s\" is not a valid option\n", s);
return;
}
/**
* Parse the insmod "drm_opts=" options, or the command-line
* options passed to the kernel via LILO.
*
* \param s contains option_list without the 'drm_opts=' part.
*
* The grammar of the format is as
* follows:
*
* \code
* drm ::= 'drm_opts=' option_list
* option_list ::= option [ ';' option_list ]
* option ::= 'device:' major
* | 'debug'
* | 'noctx'
* major ::= INTEGER
* \endcode
*
* - device=major,minor specifies the device number used for /dev/drm
* - if major == 0 then the misc device is used
* - if major == 0 and minor == 0 then dynamic misc allocation is used
* - debug=on specifies that debugging messages will be printk'd
* - debug=trace specifies that each function call will be logged via printk
* - debug=off turns off all debugging options
*
* \todo Actually only the \e presence of the 'debug' option is currently
* checked.
*/
void DRM(parse_options)(char *s)
{
char *h, *t, *n;
DRM_DEBUG("\"%s\"\n", s ?: "");
if (!s || !*s) return;
for (h = t = n = s; h && *h; h = n) {
for (; *t && *t != ';'; t++); /* find ; or \0 */
if (*t) n = t + 1; else n = NULL; /* remember next */
*t = '\0'; /* terminate */
DRM(parse_option)(h); /* parse */
}
}
/**
* Check whether DRI will run on this CPU.
*
* \return non-zero if the DRI will run on this CPU, or zero otherwise.
*/
int DRM(cpu_valid)(void)
int drm_cpu_valid(void)
{
#if defined(__i386__)
if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
......
......@@ -34,6 +34,7 @@
*/
#include "drmP.h"
#include "drm_core.h"
#include "linux/pci.h"
......@@ -48,7 +49,7 @@
*
* Copies the bus id from drm_device::unique into user space.
*/
int DRM(getunique)(struct inode *inode, struct file *filp,
int drm_getunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -82,7 +83,7 @@ int DRM(getunique)(struct inode *inode, struct file *filp,
* in interface version 1.1 and will return EBUSY when setversion has requested
* version 1.1 or greater.
*/
int DRM(setunique)(struct inode *inode, struct file *filp,
int drm_setunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -98,19 +99,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
if (!u.unique_len || u.unique_len > 1024) return -EINVAL;
dev->unique_len = u.unique_len;
dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER);
dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
if(!dev->unique) return -ENOMEM;
if (copy_from_user(dev->unique, u.unique, dev->unique_len))
return -EFAULT;
dev->unique[dev->unique_len] = '\0';
dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2,
dev->devname = drm_alloc(strlen(dev->fn_tbl->pci_driver.name) + strlen(dev->unique) + 2,
DRM_MEM_DRIVER);
if (!dev->devname)
return -ENOMEM;
sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
sprintf(dev->devname, "%s@%s", dev->fn_tbl->pci_driver.name, dev->unique);
/* Return error if the busid submitted doesn't match the device's actual
* busid.
......@@ -131,25 +132,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
}
static int
DRM(set_busid)(drm_device_t *dev)
drm_set_busid(drm_device_t *dev)
{
if (dev->unique != NULL)
return EBUSY;
dev->unique_len = 20;
dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER);
dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
if (dev->unique == NULL)
return ENOMEM;
snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
dev->devname = DRM(alloc)(strlen(dev->name) + dev->unique_len + 2,
dev->devname = drm_alloc(strlen(dev->fn_tbl->pci_driver.name) + dev->unique_len + 2,
DRM_MEM_DRIVER);
if (dev->devname == NULL)
return ENOMEM;
sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
sprintf(dev->devname, "%s@%s", dev->fn_tbl->pci_driver.name, dev->unique);
return 0;
}
......@@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev)
* Searches for the mapping with the specified offset and copies its information
* into userspace
*/
int DRM(getmap)( struct inode *inode, struct file *filp,
int drm_getmap( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -228,7 +229,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
* Searches for the client with the specified index and copies its information
* into userspace
*/
int DRM(getclient)( struct inode *inode, struct file *filp,
int drm_getclient( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp,
*
* \return zero on success or a negative number on failure.
*/
int DRM(getstats)( struct inode *inode, struct file *filp,
int drm_getstats( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp,
return 0;
}
#define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2
int DRM(setversion)(DRM_IOCTL_ARGS)
int drm_setversion(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_set_version_t sv;
......@@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
/*
* Version 1.1 includes tying of DRM to specific device
*/
DRM(set_busid)(dev);
drm_set_busid(dev);
}
}
......@@ -342,8 +340,8 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL;
if (dev->fn_tbl.set_version)
dev->fn_tbl.set_version(dev, &sv);
if (dev->fn_tbl->set_version)
dev->fn_tbl->set_version(dev, &sv);
}
return 0;
}
......@@ -50,7 +50,7 @@
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal
* to that of the device that this DRM instance attached to.
*/
int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
int drm_irq_by_busid(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
......@@ -86,10 +86,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
* \param irq IRQ number.
*
* Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver
* \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions
* \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions
* before and after the installation.
*/
int DRM(irq_install)( drm_device_t *dev )
int drm_irq_install( drm_device_t *dev )
{
int ret;
unsigned long sh_flags=0;
......@@ -128,13 +128,13 @@ int DRM(irq_install)( drm_device_t *dev )
}
/* Before installing handler */
dev->fn_tbl.irq_preinstall(dev);
dev->fn_tbl->irq_preinstall(dev);
/* Install handler */
if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
sh_flags = SA_SHIRQ;
ret = request_irq( dev->irq, dev->fn_tbl.irq_handler,
ret = request_irq( dev->irq, dev->fn_tbl->irq_handler,
sh_flags, dev->devname, dev );
if ( ret < 0 ) {
down( &dev->struct_sem );
......@@ -144,7 +144,7 @@ int DRM(irq_install)( drm_device_t *dev )
}
/* After installing handler */
dev->fn_tbl.irq_postinstall(dev);
dev->fn_tbl->irq_postinstall(dev);
return 0;
}
......@@ -154,9 +154,9 @@ int DRM(irq_install)( drm_device_t *dev )
*
* \param dev DRM device.
*
* Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq.
* Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq.
*/
int DRM(irq_uninstall)( drm_device_t *dev )
int drm_irq_uninstall( drm_device_t *dev )
{
int irq_enabled;
......@@ -173,12 +173,13 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
dev->fn_tbl.irq_uninstall(dev);
dev->fn_tbl->irq_uninstall(dev);
free_irq( dev->irq, dev );
return 0;
}
EXPORT_SYMBOL(drm_irq_uninstall);
/**
* IRQ control ioctl.
......@@ -191,7 +192,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
*
* Calls irq_install() or irq_uninstall() according to \p arg.
*/
int DRM(control)( struct inode *inode, struct file *filp,
int drm_control( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -210,11 +211,11 @@ int DRM(control)( struct inode *inode, struct file *filp,
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq)
return -EINVAL;
return DRM(irq_install)( dev );
return drm_irq_install( dev );
case DRM_UNINST_HANDLER:
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0;
return DRM(irq_uninstall)( dev );
return drm_irq_uninstall( dev );
default:
return -EINVAL;
}
......@@ -239,7 +240,7 @@ int DRM(control)( struct inode *inode, struct file *filp,
*
* If a signal is not requested, then calls vblank_wait().
*/
int DRM(wait_vblank)( DRM_IOCTL_ARGS )
int drm_wait_vblank( DRM_IOCTL_ARGS )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
......@@ -300,7 +301,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
if ( !( vbl_sig = DRM(alloc)( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) {
if ( !( vbl_sig = drm_alloc( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) {
return -ENOMEM;
}
......@@ -316,8 +317,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else {
if (dev->fn_tbl.vblank_wait)
ret = dev->fn_tbl.vblank_wait( dev, &vblwait.request.sequence );
if (dev->fn_tbl->vblank_wait)
ret = dev->fn_tbl->vblank_wait( dev, &vblwait.request.sequence );
do_gettimeofday( &now );
vblwait.reply.tval_sec = now.tv_sec;
......@@ -339,7 +340,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
*
* If a signal is not requested, then calls vblank_wait().
*/
void DRM(vbl_send_signals)( drm_device_t *dev )
void drm_vbl_send_signals( drm_device_t *dev )
{
struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig;
......@@ -356,7 +357,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del( list );
DRM(free)( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER );
drm_free( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER );
dev->vbl_pending--;
}
......@@ -364,5 +365,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags );
}
EXPORT_SYMBOL(drm_vbl_send_signals);
......@@ -36,7 +36,7 @@
#include "drmP.h"
/** No-op ioctl. */
int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
int drm_noop(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("\n");
......@@ -52,7 +52,7 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
*
* Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction.
*/
int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new, prev;
......@@ -90,7 +90,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
* Resets the lock file pointer.
* Marks the lock as held by the given context, via the \p cmpxchg instruction.
*/
int DRM(lock_transfer)(drm_device_t *dev,
int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new, prev;
......@@ -115,7 +115,7 @@ int DRM(lock_transfer)(drm_device_t *dev,
* Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
* waiting on the lock queue.
*/
int DRM(lock_free)(drm_device_t *dev,
int drm_lock_free(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new, prev;
......@@ -147,7 +147,7 @@ int DRM(lock_free)(drm_device_t *dev,
* \return one if the signal should be delivered normally, or zero if the
* signal should be blocked.
*/
int DRM(notifier)(void *priv)
int drm_notifier(void *priv)
{
drm_sigdata_t *s = (drm_sigdata_t *)priv;
unsigned int old, new, prev;
......
......@@ -195,161 +195,3 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
}
#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
/** No-op. */
void DRM(mem_init)(void)
{
}
/**
* Called when "/proc/dri/%dev%/mem" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param len requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*
* No-op.
*/
int DRM(mem_info)(char *buf, char **start, off_t offset,
int len, int *eof, void *data)
{
return 0;
}
/** Wrapper around kmalloc() */
void *DRM(calloc)(size_t nmemb, size_t size, int area)
{
void *addr;
addr = kmalloc(size * nmemb, GFP_KERNEL);
if (addr != NULL)
memset((void *)addr, 0, size * nmemb);
return addr;
}
/** Wrapper around kmalloc() and kfree() */
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
kfree(oldpt);
}
return pt;
}
/**
* Allocate pages.
*
* \param order size order.
* \param area memory area. (Not used.)
* \return page address on success, or zero on failure.
*
* Allocate and reserve free pages.
*/
unsigned long DRM(alloc_pages)(int order, int area)
{
unsigned long address;
unsigned long bytes = PAGE_SIZE << order;
unsigned long addr;
unsigned int sz;
address = __get_free_pages(GFP_KERNEL, order);
if (!address)
return 0;
/* Zero */
memset((void *)address, 0, bytes);
/* Reserve */
for (addr = address, sz = bytes;
sz > 0;
addr += PAGE_SIZE, sz -= PAGE_SIZE) {
SetPageReserved(virt_to_page(addr));
}
return address;
}
/**
* Free pages.
*
* \param address address of the pages to free.
* \param order size order.
* \param area memory area. (Not used.)
*
* Unreserve and free pages allocated by alloc_pages().
*/
void DRM(free_pages)(unsigned long address, int order, int area)
{
unsigned long bytes = PAGE_SIZE << order;
unsigned long addr;
unsigned int sz;
if (!address)
return;
/* Unreserve */
for (addr = address, sz = bytes;
sz > 0;
addr += PAGE_SIZE, sz -= PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
}
free_pages(address, order);
}
/** Wrapper around drm_ioremap() */
void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return drm_ioremap(offset, size, dev);
}
/** Wrapper around drm_ioremap_nocache() */
void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return drm_ioremap_nocache(offset, size, dev);
}
/** Wrapper around drm_iounmap() */
void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
{
drm_ioremapfree(pt, size, dev);
}
#if __OS_HAS_AGP
/** Wrapper around agp_allocate_memory() */
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{
return DRM(agp_allocate_memory)(pages, type);
}
/** Wrapper around agp_free_memory() */
int DRM(free_agp)(DRM_AGP_MEM *handle, int pages)
{
return DRM(agp_free_memory)(handle) ? 0 : -EINVAL;
}
/** Wrapper around agp_bind_memory() */
int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start)
{
return DRM(agp_bind_memory)(handle, start);
}
/** Wrapper around agp_unbind_memory() */
int DRM(unbind_agp)(DRM_AGP_MEM *handle)
{
return DRM(agp_unbind_memory)(handle);
}
#endif /* agp */
#endif /* debug_memory */
......@@ -39,18 +39,18 @@
#include "drmP.h"
static int DRM(name_info)(char *buf, char **start, off_t offset,
static int drm_name_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
static int DRM(vm_info)(char *buf, char **start, off_t offset,
static int drm_vm_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
static int DRM(clients_info)(char *buf, char **start, off_t offset,
static int drm_clients_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
static int DRM(queues_info)(char *buf, char **start, off_t offset,
static int drm_queues_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
static int DRM(bufs_info)(char *buf, char **start, off_t offset,
static int drm_bufs_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
#if DRM_DEBUG_CODE
static int DRM(vma_info)(char *buf, char **start, off_t offset,
static int drm_vma_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
#endif
......@@ -60,18 +60,18 @@ static int DRM(vma_info)(char *buf, char **start, off_t offset,
struct drm_proc_list {
const char *name; /**< file name */
int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/
} DRM(proc_list)[] = {
{ "name", DRM(name_info) },
{ "mem", DRM(mem_info) },
{ "vm", DRM(vm_info) },
{ "clients", DRM(clients_info) },
{ "queues", DRM(queues_info) },
{ "bufs", DRM(bufs_info) },
} drm_proc_list[] = {
{ "name", drm_name_info },
{ "mem", drm_mem_info },
{ "vm", drm_vm_info },
{ "clients", drm_clients_info },
{ "queues", drm_queues_info },
{ "bufs", drm_bufs_info },
#if DRM_DEBUG_CODE
{ "vma", DRM(vma_info) },
{ "vma", drm_vma_info },
#endif
};
#define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
#define DRM_PROC_ENTRIES (sizeof(drm_proc_list)/sizeof(drm_proc_list[0]))
/**
* Initialize the DRI proc filesystem for a device.
......@@ -86,7 +86,7 @@ struct drm_proc_list {
* "/proc/dri/%minor%/", and each entry in proc_list as
* "/proc/dri/%minor%/%name%".
*/
int DRM(proc_init)(drm_device_t *dev, int minor,
int drm_proc_init(drm_device_t *dev, int minor,
struct proc_dir_entry *root,
struct proc_dir_entry **dev_root)
{
......@@ -102,18 +102,18 @@ int DRM(proc_init)(drm_device_t *dev, int minor,
}
for (i = 0; i < DRM_PROC_ENTRIES; i++) {
ent = create_proc_entry(DRM(proc_list)[i].name,
ent = create_proc_entry(drm_proc_list[i].name,
S_IFREG|S_IRUGO, *dev_root);
if (!ent) {
DRM_ERROR("Cannot create /proc/dri/%s/%s\n",
name, DRM(proc_list)[i].name);
name, drm_proc_list[i].name);
for (j = 0; j < i; j++)
remove_proc_entry(DRM(proc_list)[i].name,
remove_proc_entry(drm_proc_list[i].name,
*dev_root);
remove_proc_entry(name, root);
return -1;
}
ent->read_proc = DRM(proc_list)[i].f;
ent->read_proc = drm_proc_list[i].f;
ent->data = dev;
}
......@@ -131,7 +131,7 @@ int DRM(proc_init)(drm_device_t *dev, int minor,
*
* Remove all proc entries created by proc_init().
*/
int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
int drm_proc_cleanup(int minor, struct proc_dir_entry *root,
struct proc_dir_entry *dev_root)
{
int i;
......@@ -140,7 +140,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
if (!root || !dev_root) return 0;
for (i = 0; i < DRM_PROC_ENTRIES; i++)
remove_proc_entry(DRM(proc_list)[i].name, dev_root);
remove_proc_entry(drm_proc_list[i].name, dev_root);
sprintf(name, "%d", minor);
remove_proc_entry(name, root);
......@@ -160,7 +160,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
*
* Prints the device name together with the bus id if available.
*/
static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
static int drm_name_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -176,9 +176,9 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
if (dev->unique) {
DRM_PROC_PRINT("%s 0x%lx %s\n",
dev->name, (long)old_encode_dev(dev->device), dev->unique);
dev->fn_tbl->pci_driver.name, (long)old_encode_dev(dev->device), dev->unique);
} else {
DRM_PROC_PRINT("%s 0x%lx\n", dev->name, (long)old_encode_dev(dev->device));
DRM_PROC_PRINT("%s 0x%lx\n", dev->fn_tbl->pci_driver.name, (long)old_encode_dev(dev->device));
}
if (len > request + offset) return request;
......@@ -199,7 +199,7 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
*
* Prints information about all mappings in drm_device::maplist.
*/
static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
static int drm__vm_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -255,14 +255,14 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
/**
* Simply calls _vm_info() while holding the drm_device::struct_sem lock.
*/
static int DRM(vm_info)(char *buf, char **start, off_t offset, int request,
static int drm_vm_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
int ret;
down(&dev->struct_sem);
ret = DRM(_vm_info)(buf, start, offset, request, eof, data);
ret = drm__vm_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem);
return ret;
}
......@@ -278,7 +278,7 @@ static int DRM(vm_info)(char *buf, char **start, off_t offset, int request,
* \param data private data.
* \return number of written bytes.
*/
static int DRM(_queues_info)(char *buf, char **start, off_t offset,
static int drm__queues_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -325,14 +325,14 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset,
/**
* Simply calls _queues_info() while holding the drm_device::struct_sem lock.
*/
static int DRM(queues_info)(char *buf, char **start, off_t offset, int request,
static int drm_queues_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
int ret;
down(&dev->struct_sem);
ret = DRM(_queues_info)(buf, start, offset, request, eof, data);
ret = drm__queues_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem);
return ret;
}
......@@ -348,7 +348,7 @@ static int DRM(queues_info)(char *buf, char **start, off_t offset, int request,
* \param data private data.
* \return number of written bytes.
*/
static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request,
static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -395,14 +395,14 @@ static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request,
/**
* Simply calls _bufs_info() while holding the drm_device::struct_sem lock.
*/
static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request,
static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
int ret;
down(&dev->struct_sem);
ret = DRM(_bufs_info)(buf, start, offset, request, eof, data);
ret = drm__bufs_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem);
return ret;
}
......@@ -418,7 +418,7 @@ static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request,
* \param data private data.
* \return number of written bytes.
*/
static int DRM(_clients_info)(char *buf, char **start, off_t offset,
static int drm__clients_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -452,21 +452,21 @@ static int DRM(_clients_info)(char *buf, char **start, off_t offset,
/**
* Simply calls _clients_info() while holding the drm_device::struct_sem lock.
*/
static int DRM(clients_info)(char *buf, char **start, off_t offset,
static int drm_clients_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
int ret;
down(&dev->struct_sem);
ret = DRM(_clients_info)(buf, start, offset, request, eof, data);
ret = drm__clients_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem);
return ret;
}
#if DRM_DEBUG_CODE
static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request,
static int drm__vma_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
......@@ -523,14 +523,14 @@ static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request,
return len - offset;
}
static int DRM(vma_info)(char *buf, char **start, off_t offset, int request,
static int drm_vma_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
drm_device_t *dev = (drm_device_t *)data;
int ret;
down(&dev->struct_sem);
ret = DRM(_vma_info)(buf, start, offset, request, eof, data);
ret = drm__vma_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem);
return ret;
}
......
......@@ -37,7 +37,7 @@
#define DEBUG_SCATTER 0
void DRM(sg_cleanup)( drm_sg_mem_t *entry )
void drm_sg_cleanup( drm_sg_mem_t *entry )
{
struct page *page;
int i;
......@@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry )
vfree( entry->virtual );
DRM(free)( entry->busaddr,
drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
DRM(free)( entry->pagelist,
drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES );
DRM(free)( entry,
drm_free( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
}
int DRM(sg_alloc)( struct inode *inode, struct file *filp,
int drm_sg_alloc( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
if ( copy_from_user( &request, argp, sizeof(request) ) )
return -EFAULT;
entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS );
entry = drm_alloc( sizeof(*entry), DRM_MEM_SGLISTS );
if ( !entry )
return -ENOMEM;
......@@ -92,22 +92,22 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
entry->pages = pages;
entry->pagelist = DRM(alloc)( pages * sizeof(*entry->pagelist),
entry->pagelist = drm_alloc( pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES );
if ( !entry->pagelist ) {
DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS );
drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS );
return -ENOMEM;
}
memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
entry->busaddr = drm_alloc( pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
if ( !entry->busaddr ) {
DRM(free)( entry->pagelist,
drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES );
DRM(free)( entry,
drm_free( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
return -ENOMEM;
......@@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
entry->virtual = vmalloc_32( pages << PAGE_SHIFT );
if ( !entry->virtual ) {
DRM(free)( entry->busaddr,
drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
DRM(free)( entry->pagelist,
drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES );
DRM(free)( entry,
drm_free( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
return -ENOMEM;
......@@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
request.handle = entry->handle;
if ( copy_to_user( argp, &request, sizeof(request) ) ) {
DRM(sg_cleanup)( entry );
drm_sg_cleanup( entry );
return -EFAULT;
}
......@@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
return 0;
failed:
DRM(sg_cleanup)( entry );
drm_sg_cleanup( entry );
return -ENOMEM;
}
int DRM(sg_free)( struct inode *inode, struct file *filp,
int drm_sg_free( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
......@@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
DRM_DEBUG( "sg free virtual = %p\n", entry->virtual );
DRM(sg_cleanup)( entry );
drm_sg_cleanup( entry );
return 0;
}
......@@ -31,21 +31,27 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include "drmP.h"
#include "drm_core.h"
static unsigned int cards_limit = 16; /* Enough for one machine */
static unsigned int debug = 0; /* 1 to enable debug output */
unsigned int drm_cards_limit = 16; /* Enough for one machine */
unsigned int drm_debug = 0; /* 1 to enable debug output */
EXPORT_SYMBOL(drm_debug);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards");
MODULE_PARM_DESC(debug, "Enable debug output");
MODULE_PARM_DESC(drm_cards_limit, "Maximum number of graphics cards");
MODULE_PARM_DESC(drm_debug, "Enable debug output");
module_param(cards_limit, int, 0444);
module_param(debug, int, 0666);
module_param_named(cards_limit, drm_cards_limit, int, 0444);
module_param_named(debug, drm_debug, int, 0666);
drm_global_t *DRM(global);
drm_minor_t *drm_minors;
struct class_simple *drm_class;
struct proc_dir_entry *drm_proc_root;
/**
* File \c open operation.
......@@ -65,10 +71,10 @@ static int stub_open(struct inode *inode, struct file *filp)
DRM_DEBUG("\n");
if (!((minor >= 0) && (minor < DRM(global)->cards_limit)))
if (!((minor >= 0) && (minor < drm_cards_limit)))
return -ENODEV;
dev = DRM(global)->minors[minor].dev;
dev = drm_minors[minor].dev;
if (!dev)
return -ENODEV;
......@@ -84,7 +90,7 @@ static int stub_open(struct inode *inode, struct file *filp)
}
/** File operations structure */
static struct file_operations DRM(stub_fops) = {
struct file_operations drm_stub_fops = {
.owner = THIS_MODULE,
.open = stub_open
};
......@@ -94,43 +100,44 @@ static struct file_operations DRM(stub_fops) = {
*
* \param pdev PCI device structure
* \param ent entry from the PCI ID table with device type flags
* \return negative number on failure.
* \return zero on success or a negative number on failure.
*
* Search an empty entry and initialize it to the given parameters, and
* create the proc init entry via proc_init().
* Attempt to gets inter module "drm" information. If we are first
* then register the character device and inter module information.
* Try and register, if we fail to register, backout previous work.
*/
static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent)
int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver_fn *driver_fn)
{
struct class_device *dev_class;
drm_device_t *dev;
int ret;
int minor;
drm_minor_t *minors = &DRM(global)->minors[0];
drm_minor_t *minors = &drm_minors[0];
DRM_DEBUG("\n");
for (minor=0; minor<DRM(global)->cards_limit; minor++, minors++) {
for (minor = 0; minor < drm_cards_limit; minor++, minors++) {
if (minors->type == DRM_MINOR_FREE) {
DRM_DEBUG("assigning minor %d\n", minor);
dev = DRM(calloc)(1, sizeof(*dev), DRM_MEM_STUB);
dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB);
if (!dev)
return -ENOMEM;
*minors = (drm_minor_t){.dev = dev, .type=DRM_MINOR_PRIMARY};
dev->minor = minor;
if ((ret=DRM(fill_in_dev)(dev, pdev, ent))) {
if ((ret=drm_fill_in_dev(dev, pdev, ent, driver_fn))) {
printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
goto err_g1;
}
if ((ret = DRM(proc_init)(dev, minor, DRM(global)->proc_root, &dev->dev_root))) {
if ((ret = drm_proc_init(dev, minor, drm_proc_root, &minors->dev_root))) {
printk (KERN_ERR "DRM: Failed to initialize /proc/dri.\n");
goto err_g1;
}
pci_enable_device(pdev);
dev_class = class_simple_device_add(DRM(global)->drm_class,
dev_class = class_simple_device_add(drm_class,
MKDEV(DRM_MAJOR, minor), &pdev->dev, "card%d", minor);
if (IS_ERR(dev_class)) {
printk(KERN_ERR "DRM: Error class_simple_device_add.\n");
......@@ -145,12 +152,13 @@ static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent)
DRM_ERROR("out of minors\n");
return -ENOMEM;
err_g2:
DRM(proc_cleanup)(minor, DRM(global)->proc_root, minors->dev_root);
drm_proc_cleanup(minor, drm_proc_root, minors->dev_root);
err_g1:
*minors = (drm_minor_t){.dev = NULL, .type = DRM_MINOR_FREE};
DRM(free)(dev, sizeof(*dev), DRM_MEM_STUB);
drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
return ret;
}
EXPORT_SYMBOL(drm_probe);
/**
......@@ -163,112 +171,18 @@ static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent)
* "drm" data, otherwise unregisters the "drm" data, frees the stub list and
* unregisters the character device.
*/
int DRM(put_minor)(drm_device_t *dev)
int drm_put_minor(drm_device_t *dev)
{
drm_minor_t *minors = &DRM(global)->minors[dev->minor];
int i;
drm_minor_t *minors = &drm_minors[dev->minor];
DRM_DEBUG("release minor %d\n", dev->minor);
DRM(proc_cleanup)(dev->minor, DRM(global)->proc_root, dev->dev_root);
drm_proc_cleanup(dev->minor, drm_proc_root, minors->dev_root);
class_simple_device_remove(MKDEV(DRM_MAJOR, dev->minor));
*minors = (drm_minor_t){.dev = NULL, .type = DRM_MINOR_FREE};
DRM(free)(dev, sizeof(*dev), DRM_MEM_STUB);
drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
/* if any device pointers are non-NULL we are not the last module */
for (i=0; i<DRM(global)->cards_limit; i++) {
if (DRM(global)->minors[i].type != DRM_MINOR_FREE) {
DRM_DEBUG("inter_module_put called\n");
inter_module_put("drm");
return 0;
}
}
DRM_DEBUG("unregistering inter_module.\n");
inter_module_unregister("drm");
remove_proc_entry("dri", NULL);
class_simple_destroy(DRM(global)->drm_class);
unregister_chrdev(DRM_MAJOR, "drm");
DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) *
DRM(global)->cards_limit, DRM_MEM_STUB);
DRM(free)(DRM(global), sizeof(*DRM(global)), DRM_MEM_STUB);
DRM(global) = NULL;
return 0;
}
/**
* Register.
*
* \param pdev - PCI device structure
* \param ent entry from the PCI ID table with device type flags
* \return zero on success or a negative number on failure.
*
* Attempt to gets inter module "drm" information. If we are first
* then register the character device and inter module information.
* Try and register, if we fail to register, backout previous work.
*/
int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
{
drm_global_t *global;
int ret = -ENOMEM;
DRM_DEBUG("\n");
/* use the inter_module_get to check - as if the same module
registers chrdev twice it succeeds */
global = (drm_global_t *)inter_module_get("drm");
if (global) {
DRM(global) = global;
global = NULL;
} else {
DRM_DEBUG("first probe\n");
global = DRM(calloc)(1, sizeof(*global), DRM_MEM_STUB);
if(!global)
return -ENOMEM;
global->cards_limit = (cards_limit < DRM_MAX_MINOR + 1 ? cards_limit : DRM_MAX_MINOR + 1);
global->minors = DRM(calloc)(global->cards_limit,
sizeof(*global->minors), DRM_MEM_STUB);
if(!global->minors)
goto err_p1;
if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops)))
goto err_p1;
global->drm_class = class_simple_create(THIS_MODULE, "drm");
if (IS_ERR(global->drm_class)) {
printk (KERN_ERR "DRM: Error creating drm class.\n");
ret = PTR_ERR(global->drm_class);
goto err_p2;
}
global->proc_root = create_proc_entry("dri", S_IFDIR, NULL);
if (!global->proc_root) {
DRM_ERROR("Cannot create /proc/dri\n");
ret = -1;
goto err_p3;
}
DRM_DEBUG("calling inter_module_register\n");
inter_module_register("drm", THIS_MODULE, global);
DRM(global) = global;
}
if ((ret = get_minor(pdev, ent))) {
if (global)
goto err_p3;
return ret;
}
return 0;
err_p3:
class_simple_destroy(global->drm_class);
err_p2:
unregister_chrdev(DRM_MAJOR, "drm");
DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB);
err_p1:
DRM(free)(global, sizeof(*global), DRM_MEM_STUB);
DRM(global) = NULL;
return ret;
}
......@@ -47,7 +47,7 @@
* 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)
{
drm_file_t *priv = vma->vm_file->private_data;
......@@ -112,7 +112,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return NOPAGE_SIGBUS; /* Disallow mremap */
}
#else /* __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)
{
return NOPAGE_SIGBUS;
......@@ -129,7 +129,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
* Get the the mapping, find the real physical page to map, get the page, and
* return it.
*/
static __inline__ struct page *DRM(do_vm_shm_nopage)(struct vm_area_struct *vma,
static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address)
{
drm_map_t *map = (drm_map_t *)vma->vm_private_data;
......@@ -160,7 +160,7 @@ static __inline__ struct page *DRM(do_vm_shm_nopage)(struct vm_area_struct *vma,
* Deletes map information if we are the last
* person to close a mapping and it's not in the global maplist.
*/
void DRM(vm_shm_close)(struct vm_area_struct *vma)
void drm_vm_shm_close(struct vm_area_struct *vma)
{
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
......@@ -186,7 +186,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
} else {
dev->vmalist = pt->next;
}
DRM(free)(pt, sizeof(*pt), DRM_MEM_VMAS);
drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
} else {
prev = pt;
}
......@@ -215,7 +215,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode);
}
DRM(ioremapfree)(map->handle, map->size, dev);
drm_ioremapfree(map->handle, map->size, dev);
break;
case _DRM_SHM:
vfree(map->handle);
......@@ -224,7 +224,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
case _DRM_SCATTER_GATHER:
break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
}
up(&dev->struct_sem);
......@@ -239,7 +239,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
*
* Determine the page number from the page offset and get it from drm_device_dma::pagelist.
*/
static __inline__ struct page *DRM(do_vm_dma_nopage)(struct vm_area_struct *vma,
static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address)
{
drm_file_t *priv = vma->vm_file->private_data;
......@@ -273,7 +273,7 @@ static __inline__ struct page *DRM(do_vm_dma_nopage)(struct vm_area_struct *vma,
*
* Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
*/
static __inline__ struct page *DRM(do_vm_sg_nopage)(struct vm_area_struct *vma,
static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address)
{
drm_map_t *map = (drm_map_t *)vma->vm_private_data;
......@@ -302,89 +302,89 @@ static __inline__ struct page *DRM(do_vm_sg_nopage)(struct vm_area_struct *vma,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
static struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_nopage(struct vm_area_struct *vma,
unsigned long address,
int *type) {
if (type) *type = VM_FAULT_MINOR;
return DRM(do_vm_nopage)(vma, address);
return drm_do_vm_nopage(vma, address);
}
static struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address,
int *type) {
if (type) *type = VM_FAULT_MINOR;
return DRM(do_vm_shm_nopage)(vma, address);
return drm_do_vm_shm_nopage(vma, address);
}
static struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address,
int *type) {
if (type) *type = VM_FAULT_MINOR;
return DRM(do_vm_dma_nopage)(vma, address);
return drm_do_vm_dma_nopage(vma, address);
}
static struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address,
int *type) {
if (type) *type = VM_FAULT_MINOR;
return DRM(do_vm_sg_nopage)(vma, address);
return drm_do_vm_sg_nopage(vma, address);
}
#else /* LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0) */
static struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_nopage(struct vm_area_struct *vma,
unsigned long address,
int unused) {
return DRM(do_vm_nopage)(vma, address);
return drm_do_vm_nopage(vma, address);
}
static struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address,
int unused) {
return DRM(do_vm_shm_nopage)(vma, address);
return drm_do_vm_shm_nopage(vma, address);
}
static struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address,
int unused) {
return DRM(do_vm_dma_nopage)(vma, address);
return drm_do_vm_dma_nopage(vma, address);
}
static struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address,
int unused) {
return DRM(do_vm_sg_nopage)(vma, address);
return drm_do_vm_sg_nopage(vma, address);
}
#endif
/** AGP virtual memory operations */
static struct vm_operations_struct DRM(vm_ops) = {
.nopage = DRM(vm_nopage),
.open = DRM(vm_open),
.close = DRM(vm_close),
static struct vm_operations_struct drm_vm_ops = {
.nopage = drm_vm_nopage,
.open = drm_vm_open,
.close = drm_vm_close,
};
/** Shared virtual memory operations */
static struct vm_operations_struct DRM(vm_shm_ops) = {
.nopage = DRM(vm_shm_nopage),
.open = DRM(vm_open),
.close = DRM(vm_shm_close),
static struct vm_operations_struct drm_vm_shm_ops = {
.nopage = drm_vm_shm_nopage,
.open = drm_vm_open,
.close = drm_vm_shm_close,
};
/** DMA virtual memory operations */
static struct vm_operations_struct DRM(vm_dma_ops) = {
.nopage = DRM(vm_dma_nopage),
.open = DRM(vm_open),
.close = DRM(vm_close),
static struct vm_operations_struct drm_vm_dma_ops = {
.nopage = drm_vm_dma_nopage,
.open = drm_vm_open,
.close = drm_vm_close,
};
/** Scatter-gather virtual memory operations */
static struct vm_operations_struct DRM(vm_sg_ops) = {
.nopage = DRM(vm_sg_nopage),
.open = DRM(vm_open),
.close = DRM(vm_close),
static struct vm_operations_struct drm_vm_sg_ops = {
.nopage = drm_vm_sg_nopage,
.open = drm_vm_open,
.close = drm_vm_close,
};
......@@ -396,7 +396,7 @@ static struct vm_operations_struct DRM(vm_sg_ops) = {
* Create a new drm_vma_entry structure as the \p vma private data entry and
* add it to drm_device::vmalist.
*/
void DRM(vm_open)(struct vm_area_struct *vma)
void drm_vm_open(struct vm_area_struct *vma)
{
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
......@@ -406,7 +406,7 @@ void DRM(vm_open)(struct vm_area_struct *vma)
vma->vm_start, vma->vm_end - vma->vm_start);
atomic_inc(&dev->vma_count);
vma_entry = DRM(alloc)(sizeof(*vma_entry), DRM_MEM_VMAS);
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
if (vma_entry) {
down(&dev->struct_sem);
vma_entry->vma = vma;
......@@ -425,7 +425,7 @@ void DRM(vm_open)(struct vm_area_struct *vma)
* Search the \p vma private data entry in drm_device::vmalist, unlink it, and
* free it.
*/
void DRM(vm_close)(struct vm_area_struct *vma)
void drm_vm_close(struct vm_area_struct *vma)
{
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
......@@ -443,7 +443,7 @@ void DRM(vm_close)(struct vm_area_struct *vma)
} else {
dev->vmalist = pt->next;
}
DRM(free)(pt, sizeof(*pt), DRM_MEM_VMAS);
drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
break;
}
}
......@@ -460,7 +460,7 @@ void DRM(vm_close)(struct vm_area_struct *vma)
* Sets the virtual memory area operations structure to vm_dma_ops, the file
* pointer, and calls vm_open().
*/
int DRM(mmap_dma)(struct file *filp, 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;
......@@ -480,7 +480,7 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
}
unlock_kernel();
vma->vm_ops = &DRM(vm_dma_ops);
vma->vm_ops = &drm_vm_dma_ops;
#if LINUX_VERSION_CODE <= 0x02040e /* KERNEL_VERSION(2,4,14) */
vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
......@@ -489,16 +489,17 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
#endif
vma->vm_file = filp; /* Needed for drm_vm_open() */
DRM(vm_open)(vma);
drm_vm_open(vma);
return 0;
}
unsigned long DRM(core_get_map_ofs)(drm_map_t *map)
unsigned long drm_core_get_map_ofs(drm_map_t *map)
{
return map->offset;
}
EXPORT_SYMBOL(drm_core_get_map_ofs);
unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
unsigned long drm_core_get_reg_ofs(struct drm_device *dev)
{
#ifdef __alpha__
return dev->hose->dense_mem_base - dev->hose->mem_space->start;
......@@ -506,6 +507,7 @@ unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
return 0;
#endif
}
EXPORT_SYMBOL(drm_core_get_reg_ofs);
/**
* mmap DMA memory.
......@@ -520,7 +522,7 @@ unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
* according to the mapping type and remaps the pages. Finally sets the file
* pointer and calls vm_open().
*/
int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
int drm_mmap(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
......@@ -543,7 +545,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
&& (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
#endif
)
return DRM(mmap_dma)(filp, vma);
return drm_mmap_dma(filp, vma);
/* A sequential search of a linked list is
fine here because: 1) there will only be
......@@ -558,7 +560,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map;
if (!map) continue;
off = dev->fn_tbl.get_map_ofs(map);
off = dev->fn_tbl->get_map_ofs(map);
if (off == VM_OFFSET(vma)) break;
}
......@@ -592,7 +594,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
#if defined(__powerpc__)
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
#endif
vma->vm_ops = &DRM(vm_ops);
vma->vm_ops = &drm_vm_ops;
break;
}
/* fall through to _DRM_FRAME_BUFFER... */
......@@ -613,7 +615,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
if (map->type != _DRM_AGP)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
#endif
offset = dev->fn_tbl.get_reg_ofs(dev);
offset = dev->fn_tbl->get_reg_ofs(dev);
#ifdef __sparc__
if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
VM_OFFSET(vma) + offset,
......@@ -630,10 +632,10 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
" offset = 0x%lx\n",
map->type,
vma->vm_start, vma->vm_end, VM_OFFSET(vma) + offset);
vma->vm_ops = &DRM(vm_ops);
vma->vm_ops = &drm_vm_ops;
break;
case _DRM_SHM:
vma->vm_ops = &DRM(vm_shm_ops);
vma->vm_ops = &drm_vm_shm_ops;
vma->vm_private_data = (void *)map;
/* Don't let this area swap. Change when
DRM_KERNEL advisory is supported. */
......@@ -644,7 +646,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
#endif
break;
case _DRM_SCATTER_GATHER:
vma->vm_ops = &DRM(vm_sg_ops);
vma->vm_ops = &drm_vm_sg_ops;
vma->vm_private_data = (void *)map;
#if LINUX_VERSION_CODE <= 0x02040e /* KERNEL_VERSION(2,4,14) */
vma->vm_flags |= VM_LOCKED;
......@@ -662,6 +664,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
#endif
vma->vm_file = filp; /* Needed for drm_vm_open() */
DRM(vm_open)(vma);
drm_vm_open(vma);
return 0;
}
......@@ -210,9 +210,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr;
}
#include "drm_core.h"
/* This functions must be here since it references DRM(numdevs)
/* This functions must be here since it references drm_numdevs)
* which drm_drv.h declares.
*/
static int ffb_presetup(drm_device_t *dev)
......@@ -227,13 +225,13 @@ static int ffb_presetup(drm_device_t *dev)
return -ENODEV;
/* Find our instance number by finding our device in dev structure */
for (i = 0; i < DRM(numdevs); i++) {
temp_dev = &(DRM(device)[i]);
for (i = 0; i < drm_numdevs; i++) {
temp_dev = &(drm_device[i]);
if(temp_dev == dev)
break;
}
if (i == DRM(numdevs))
if (i == drm_numdevs)
return -ENODEV;
ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
......
......@@ -30,7 +30,6 @@
*
*/
#include "i810.h"
#include "drmP.h"
#include "drm.h"
#include "i810_drm.h"
......@@ -110,12 +109,12 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
}
static struct file_operations i810_buffer_fops = {
.open = DRM(open),
.flush = DRM(flush),
.release = DRM(release),
.ioctl = DRM(ioctl),
.open = drm_open,
.flush = drm_flush,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i810_mmap_buffers,
.fasync = DRM(fasync),
.fasync = drm_fasync,
};
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
......@@ -237,7 +236,7 @@ int i810_dma_cleanup(drm_device_t *dev)
* is freed, it's too late.
*/
if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled)
DRM(irq_uninstall)(dev);
drm_irq_uninstall(dev);
if (dev->dev_private) {
int i;
......@@ -245,7 +244,7 @@ int i810_dma_cleanup(drm_device_t *dev)
(drm_i810_private_t *) dev->dev_private;
if (dev_priv->ring.virtual_start) {
DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
drm_ioremapfree((void *) dev_priv->ring.virtual_start,
dev_priv->ring.Size, dev);
}
if (dev_priv->hw_status_page) {
......@@ -255,7 +254,7 @@ int i810_dma_cleanup(drm_device_t *dev)
/* Need to rewrite hardware status page */
I810_WRITE(0x02080, 0x1ffff000);
}
DRM(free)(dev->dev_private, sizeof(drm_i810_private_t),
drm_free(dev->dev_private, sizeof(drm_i810_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
......@@ -263,7 +262,7 @@ int i810_dma_cleanup(drm_device_t *dev)
drm_buf_t *buf = dma->buflist[ i ];
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
if ( buf_priv->kernel_virtual && buf->total )
DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev);
drm_ioremapfree(buf_priv->kernel_virtual, buf->total, dev);
}
}
return 0;
......@@ -334,7 +333,7 @@ static int i810_freelist_init(drm_device_t *dev, drm_i810_private_t *dev_priv)
*buf_priv->in_use = I810_BUF_FREE;
buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address,
buf_priv->kernel_virtual = drm_ioremap(buf->bus_address,
buf->total, dev);
}
return 0;
......@@ -386,7 +385,7 @@ static int i810_dma_initialize(drm_device_t *dev,
dev_priv->ring.End = init->ring_end;
dev_priv->ring.Size = init->ring_size;
dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base +
dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base +
init->ring_start,
init->ring_size, dev);
......@@ -510,7 +509,7 @@ int i810_dma_init(struct inode *inode, struct file *filp,
if (retcode)
return retcode;
dev_priv = DRM(alloc)(sizeof(drm_i810_private_t),
dev_priv = drm_alloc(sizeof(drm_i810_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
......@@ -524,7 +523,7 @@ int i810_dma_init(struct inode *inode, struct file *filp,
sizeof(drm_i810_init_t))) {
return -EFAULT;
}
dev_priv = DRM(alloc)(sizeof(drm_i810_private_t),
dev_priv = drm_alloc(sizeof(drm_i810_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
......@@ -1388,35 +1387,20 @@ int i810_flip_bufs(struct inode *inode, struct file *filp,
return 0;
}
static void i810_driver_pretakedown(drm_device_t *dev)
void i810_driver_pretakedown(drm_device_t *dev)
{
i810_dma_cleanup( dev );
}
static void i810_driver_release(drm_device_t *dev, struct file *filp)
void i810_driver_release(drm_device_t *dev, struct file *filp)
{
i810_reclaim_buffers(filp);
}
static int i810_driver_dma_quiescent(drm_device_t *dev)
int i810_driver_dma_quiescent(drm_device_t *dev)
{
i810_dma_quiescent( dev );
return 0;
}
void i810_driver_register_fns(drm_device_t *dev)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE;
dev->dev_priv_size = sizeof(drm_i810_buf_priv_t);
dev->fn_tbl.pretakedown = i810_driver_pretakedown;
dev->fn_tbl.release = i810_driver_release;
dev->fn_tbl.dma_quiescent = i810_driver_dma_quiescent;
dev->fn_tbl.reclaim_buffers = i810_reclaim_buffers;
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
}
......@@ -199,21 +199,37 @@ typedef struct _drm_i810_sarea {
/* i810 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t)
#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t)
#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t)
#define DRM_IOCTL_I810_FLUSH DRM_IO( 0x43)
#define DRM_IOCTL_I810_GETAGE DRM_IO( 0x44)
#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t)
#define DRM_IOCTL_I810_SWAP DRM_IO( 0x46)
#define DRM_IOCTL_I810_COPY DRM_IOW( 0x47, drm_i810_copy_t)
#define DRM_IOCTL_I810_DOCOPY DRM_IO( 0x48)
#define DRM_IOCTL_I810_OV0INFO DRM_IOR( 0x49, drm_i810_overlay_t)
#define DRM_IOCTL_I810_FSTATUS DRM_IO ( 0x4a)
#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( 0x4b)
#define DRM_IOCTL_I810_MC DRM_IOW( 0x4c, drm_i810_mc_t)
#define DRM_IOCTL_I810_RSTATUS DRM_IO ( 0x4d )
#define DRM_IOCTL_I810_FLIP DRM_IO ( 0x4e )
#define DRM_I810_INIT 0x00
#define DRM_I810_VERTEX 0x01
#define DRM_I810_CLEAR 0x02
#define DRM_I810_FLUSH 0x03
#define DRM_I810_GETAGE 0x04
#define DRM_I810_GETBUF 0x05
#define DRM_I810_SWAP 0x06
#define DRM_I810_COPY 0x07
#define DRM_I810_DOCOPY 0x08
#define DRM_I810_OV0INFO 0x09
#define DRM_I810_FSTATUS 0x0a
#define DRM_I810_OV0FLIP 0x0b
#define DRM_I810_MC 0x0c
#define DRM_I810_RSTATUS 0x0d
#define DRM_I810_FLIP 0x0e
#define DRM_IOCTL_I810_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t)
#define DRM_IOCTL_I810_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t)
#define DRM_IOCTL_I810_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t)
#define DRM_IOCTL_I810_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_I810_FLUSH)
#define DRM_IOCTL_I810_GETAGE DRM_IO( DRM_COMMAND_BASE + DRM_I810_GETAGE)
#define DRM_IOCTL_I810_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t)
#define DRM_IOCTL_I810_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_I810_SWAP)
#define DRM_IOCTL_I810_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t)
#define DRM_IOCTL_I810_DOCOPY DRM_IO( DRM_COMMAND_BASE + DRM_I810_DOCOPY)
#define DRM_IOCTL_I810_OV0INFO DRM_IOR( DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t)
#define DRM_IOCTL_I810_FSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FSTATUS)
#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_OV0FLIP)
#define DRM_IOCTL_I810_MC DRM_IOW( DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t)
#define DRM_IOCTL_I810_RSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_RSTATUS)
#define DRM_IOCTL_I810_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FLIP)
typedef struct _drm_i810_clear {
int clear_color;
......
......@@ -31,10 +31,101 @@
*/
#include <linux/config.h>
#include "i810.h"
#include "drmP.h"
#include "drm.h"
#include "i810_drm.h"
#include "i810_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
static int postinit( struct drm_device *dev, unsigned long flags )
{
/* i810 has 4 more counters */
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
i810_PCI_IDS
};
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_I810_INIT)] = { i810_dma_init, 1, 1 },
[DRM_IOCTL_NR(DRM_I810_VERTEX)] = { i810_dma_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_CLEAR)] = { i810_clear_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_FLUSH)] = { i810_flush_ioctl, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_GETAGE)] = { i810_getage, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_GETBUF)] = { i810_getbuf, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_SWAP)] = { i810_swap_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_COPY)] = { i810_copybuf, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_DOCOPY)] = { i810_docopy, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_OV0INFO)] = { i810_ov0_info, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_FSTATUS)] = { i810_fstatus, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = { i810_ov0_flip, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_MC)] = { i810_dma_mc, 1, 1 },
[DRM_IOCTL_NR(DRM_I810_RSTATUS)] = { i810_rstatus, 1, 0 },
[DRM_IOCTL_NR(DRM_I810_FLIP)] = { i810_flip_bufs, 1, 0 }
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE,
.dev_priv_size = sizeof(drm_i810_buf_priv_t),
.pretakedown = i810_driver_pretakedown,
.release = i810_driver_release,
.dma_quiescent = i810_driver_dma_quiescent,
.reclaim_buffers = i810_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
},
};
static int __init i810_init(void)
{
return drm_init(&driver_fn);
}
static void __exit i810_exit(void)
{
drm_exit(&driver_fn);
}
module_init(i810_init);
module_exit(i810_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -32,6 +32,29 @@
#ifndef _I810_DRV_H_
#define _I810_DRV_H_
/* General customization:
*/
#define DRIVER_AUTHOR "VA Linux Systems Inc."
#define DRIVER_NAME "i810"
#define DRIVER_DESC "Intel i810"
#define DRIVER_DATE "20030605"
/* Interface history
*
* 1.1 - XFree86 4.1
* 1.2 - XvMC interfaces
* - XFree86 4.2
* 1.2.1 - Disable copying code (leave stub ioctls for backwards compatibility)
* - Remove requirement for interrupt (leave stubs again)
* 1.3 - Add page flipping.
* 1.4 - fix DRM interface
*/
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 4
#define DRIVER_PATCHLEVEL 0
typedef struct drm_i810_buf_priv {
u32 *in_use;
int my_use_idx;
......@@ -127,18 +150,22 @@ extern int i810_dma_mc(struct inode *inode, struct file *filp,
extern void i810_dma_quiescent(drm_device_t *dev);
int i810_dma_vertex(struct inode *inode, struct file *filp,
extern int i810_dma_vertex(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
int i810_swap_bufs(struct inode *inode, struct file *filp,
extern int i810_swap_bufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
int i810_clear_bufs(struct inode *inode, struct file *filp,
extern int i810_clear_bufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
int i810_flip_bufs(struct inode *inode, struct file *filp,
extern int i810_flip_bufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_driver_dma_quiescent(drm_device_t *dev);
extern void i810_driver_release(drm_device_t *dev, struct file *filp);
extern void i810_driver_pretakedown(drm_device_t *dev);
#define I810_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle)
#define I810_ADDR(reg) (I810_BASE(reg) + reg)
......
......@@ -31,7 +31,6 @@
*
*/
#include "i830.h"
#include "drmP.h"
#include "drm.h"
#include "i830_drm.h"
......@@ -111,12 +110,12 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
}
static struct file_operations i830_buffer_fops = {
.open = DRM(open),
.flush = DRM(flush),
.release = DRM(release),
.ioctl = DRM(ioctl),
.open = drm_open,
.flush = drm_flush,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i830_mmap_buffers,
.fasync = DRM(fasync),
.fasync = drm_fasync,
};
int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
......@@ -237,7 +236,7 @@ int i830_dma_cleanup(drm_device_t *dev)
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->irq_enabled ) drm_irq_uninstall(dev);
if (dev->dev_private) {
int i;
......@@ -245,7 +244,7 @@ int i830_dma_cleanup(drm_device_t *dev)
(drm_i830_private_t *) dev->dev_private;
if (dev_priv->ring.virtual_start) {
DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
drm_ioremapfree((void *) dev_priv->ring.virtual_start,
dev_priv->ring.Size, dev);
}
if (dev_priv->hw_status_page) {
......@@ -256,7 +255,7 @@ int i830_dma_cleanup(drm_device_t *dev)
I830_WRITE(0x02080, 0x1ffff000);
}
DRM(free)(dev->dev_private, sizeof(drm_i830_private_t),
drm_free(dev->dev_private, sizeof(drm_i830_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
......@@ -264,7 +263,7 @@ int i830_dma_cleanup(drm_device_t *dev)
drm_buf_t *buf = dma->buflist[ i ];
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
if ( buf_priv->kernel_virtual && buf->total )
DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev);
drm_ioremapfree(buf_priv->kernel_virtual, buf->total, dev);
}
}
return 0;
......@@ -339,7 +338,7 @@ static int i830_freelist_init(drm_device_t *dev, drm_i830_private_t *dev_priv)
*buf_priv->in_use = I830_BUF_FREE;
buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address,
buf_priv->kernel_virtual = drm_ioremap(buf->bus_address,
buf->total, dev);
}
return 0;
......@@ -392,7 +391,7 @@ static int i830_dma_initialize(drm_device_t *dev,
dev_priv->ring.End = init->ring_end;
dev_priv->ring.Size = init->ring_size;
dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base +
dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base +
init->ring_start,
init->ring_size, dev);
......@@ -475,7 +474,7 @@ int i830_dma_init(struct inode *inode, struct file *filp,
switch(init.func) {
case I830_INIT_DMA:
dev_priv = DRM(alloc)(sizeof(drm_i830_private_t),
dev_priv = drm_alloc(sizeof(drm_i830_private_t),
DRM_MEM_DRIVER);
if(dev_priv == NULL) return -ENOMEM;
retcode = i830_dma_initialize(dev, dev_priv, &init);
......@@ -1582,43 +1581,19 @@ int i830_setparam( struct inode *inode, struct file *filp, unsigned int cmd,
}
static void i830_driver_pretakedown(drm_device_t *dev)
void i830_driver_pretakedown(drm_device_t *dev)
{
i830_dma_cleanup( dev );
}
static void i830_driver_release(drm_device_t *dev, struct file *filp)
void i830_driver_release(drm_device_t *dev, struct file *filp)
{
i830_reclaim_buffers(filp);
}
static int i830_driver_dma_quiescent(drm_device_t *dev)
int i830_driver_dma_quiescent(drm_device_t *dev)
{
i830_dma_quiescent( dev );
return 0;
}
void i830_driver_register_fns(drm_device_t *dev)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE;
#if USE_IRQS
dev->driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ;
#endif
dev->dev_priv_size = sizeof(drm_i830_buf_priv_t);
dev->fn_tbl.pretakedown = i830_driver_pretakedown;
dev->fn_tbl.release = i830_driver_release;
dev->fn_tbl.dma_quiescent = i830_driver_dma_quiescent;
dev->fn_tbl.reclaim_buffers = i830_reclaim_buffers;
#if USE_IRQS
dev->fn_tbl.irq_preinstall = i830_driver_irq_preinstall;
dev->fn_tbl.irq_postinstall = i830_driver_irq_postinstall;
dev->fn_tbl.irq_uninstall = i830_driver_irq_uninstall;
dev->fn_tbl.irq_handler = i830_driver_irq_handler;
#endif
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
}
......@@ -251,20 +251,35 @@ typedef struct _drm_i830_sarea {
/* I830 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
#define DRM_IOCTL_I830_INIT DRM_IOW( 0x40, drm_i830_init_t)
#define DRM_IOCTL_I830_VERTEX DRM_IOW( 0x41, drm_i830_vertex_t)
#define DRM_IOCTL_I830_CLEAR DRM_IOW( 0x42, drm_i830_clear_t)
#define DRM_IOCTL_I830_FLUSH DRM_IO ( 0x43)
#define DRM_IOCTL_I830_GETAGE DRM_IO ( 0x44)
#define DRM_IOCTL_I830_GETBUF DRM_IOWR(0x45, drm_i830_dma_t)
#define DRM_IOCTL_I830_SWAP DRM_IO ( 0x46)
#define DRM_IOCTL_I830_COPY DRM_IOW( 0x47, drm_i830_copy_t)
#define DRM_IOCTL_I830_DOCOPY DRM_IO ( 0x48)
#define DRM_IOCTL_I830_FLIP DRM_IO ( 0x49)
#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(0x4a, drm_i830_irq_emit_t)
#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( 0x4b, drm_i830_irq_wait_t)
#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(0x4c, drm_i830_getparam_t)
#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(0x4d, drm_i830_setparam_t)
#define DRM_I830_INIT 0x00
#define DRM_I830_VERTEX 0x01
#define DRM_I830_CLEAR 0x02
#define DRM_I830_FLUSH 0x03
#define DRM_I830_GETAGE 0x04
#define DRM_I830_GETBUF 0x05
#define DRM_I830_SWAP 0x06
#define DRM_I830_COPY 0x07
#define DRM_I830_DOCOPY 0x08
#define DRM_I830_FLIP 0x09
#define DRM_I830_IRQ_EMIT 0x0a
#define DRM_I830_IRQ_WAIT 0x0b
#define DRM_I830_GETPARAM 0x0c
#define DRM_I830_SETPARAM 0x0d
#define DRM_IOCTL_I830_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_INIT, drm_i830_init_t)
#define DRM_IOCTL_I830_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_VERTEX, drm_i830_vertex_t)
#define DRM_IOCTL_I830_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_CLEAR, drm_i830_clear_t)
#define DRM_IOCTL_I830_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLUSH)
#define DRM_IOCTL_I830_GETAGE DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_GETAGE)
#define DRM_IOCTL_I830_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETBUF, drm_i830_dma_t)
#define DRM_IOCTL_I830_SWAP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_SWAP)
#define DRM_IOCTL_I830_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_COPY, drm_i830_copy_t)
#define DRM_IOCTL_I830_DOCOPY DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_DOCOPY)
#define DRM_IOCTL_I830_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLIP)
#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_EMIT, drm_i830_irq_emit_t)
#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_WAIT, drm_i830_irq_wait_t)
#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETPARAM, drm_i830_getparam_t)
#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_SETPARAM, drm_i830_setparam_t)
typedef struct _drm_i830_clear {
int clear_color;
......
......@@ -33,10 +33,109 @@
*/
#include <linux/config.h>
#include "i830.h"
#include "drmP.h"
#include "drm.h"
#include "i830_drm.h"
#include "i830_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
int postinit( struct drm_device *dev, unsigned long flags )
{
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
i830_PCI_IDS
};
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_I830_INIT)] = { i830_dma_init, 1, 1 },
[DRM_IOCTL_NR(DRM_I830_VERTEX)] = { i830_dma_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_CLEAR)] = { i830_clear_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_FLUSH)] = { i830_flush_ioctl, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_GETAGE)] = { i830_getage, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_GETBUF)] = { i830_getbuf, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_SWAP)] = { i830_swap_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_COPY)] = { i830_copybuf, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_DOCOPY)] = { i830_docopy, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_FLIP)] = { i830_flip_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = { i830_irq_emit, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = { i830_irq_wait, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_GETPARAM)] = { i830_getparam, 1, 0 },
[DRM_IOCTL_NR(DRM_I830_SETPARAM)] = { i830_setparam, 1, 0 }
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE,
#if USE_IRQS
.driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ,
#endif
.dev_priv_size = sizeof(drm_i830_buf_priv_t),
.pretakedown = i830_driver_pretakedown,
.release = i830_driver_release,
.dma_quiescent = i830_driver_dma_quiescent,
.reclaim_buffers = i830_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
#if USE_IRQS
.irq_preinstall = i830_driver_irq_preinstall,
.irq_postinstall = i830_driver_irq_postinstall,
.irq_uninstall = i830_driver_irq_uninstall,
.irq_handler = i830_driver_irq_handler,
#endif
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init i830_init(void)
{
return drm_init(&driver_fn);
}
static void __exit i830_exit(void)
{
drm_exit(&driver_fn);
}
module_init(i830_init);
module_exit(i830_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -32,6 +32,36 @@
#ifndef _I830_DRV_H_
#define _I830_DRV_H_
/* General customization:
*/
#define DRIVER_AUTHOR "VA Linux Systems Inc."
#define DRIVER_NAME "i830"
#define DRIVER_DESC "Intel 830M"
#define DRIVER_DATE "20021108"
/* Interface history:
*
* 1.1: Original.
* 1.2: ?
* 1.3: New irq emit/wait ioctls.
* New pageflip ioctl.
* New getparam ioctl.
* State for texunits 3&4 in sarea.
* New (alternative) layout for texture state.
*/
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 3
#define DRIVER_PATCHLEVEL 2
/* Driver will work either way: IRQ's save cpu time when waiting for
* the card, but are subject to subtle interactions between bios,
* hardware and the driver.
*/
/* XXX: Add vblank support? */
#define USE_IRQS 0
typedef struct drm_i830_buf_priv {
u32 *in_use;
int my_use_idx;
......@@ -140,6 +170,9 @@ extern irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS );
extern void i830_driver_irq_preinstall( drm_device_t *dev );
extern void i830_driver_irq_postinstall( drm_device_t *dev );
extern void i830_driver_irq_uninstall( drm_device_t *dev );
extern void i830_driver_pretakedown(drm_device_t *dev);
extern void i830_driver_release(drm_device_t *dev, struct file *filp);
extern int i830_driver_dma_quiescent(drm_device_t *dev);
#define I830_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle)
......
......@@ -26,7 +26,6 @@
*
*/
#include "i830.h"
#include "drmP.h"
#include "drm.h"
#include "i830_drm.h"
......
......@@ -7,7 +7,6 @@
*
**************************************************************************/
#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
......@@ -84,7 +83,7 @@ int i915_dma_cleanup(drm_device_t * dev)
* is freed, it's too late.
*/
if (dev->irq)
DRM(irq_uninstall) (dev);
drm_irq_uninstall (dev);
if (dev->dev_private) {
drm_i915_private_t *dev_priv =
......@@ -102,7 +101,7 @@ int i915_dma_cleanup(drm_device_t * dev)
I915_WRITE(0x02080, 0x1ffff000);
}
DRM(free) (dev->dev_private, sizeof(drm_i915_private_t),
drm_free (dev->dev_private, sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
......@@ -242,7 +241,7 @@ int i915_dma_init(DRM_IOCTL_ARGS)
switch (init.func) {
case I915_INIT_DMA:
dev_priv = DRM(alloc) (sizeof(drm_i915_private_t),
dev_priv = drm_alloc (sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return DRM_ERR(ENOMEM);
......@@ -720,7 +719,7 @@ int i915_setparam(DRM_IOCTL_ARGS)
return 0;
}
static void i915_driver_pretakedown(drm_device_t *dev)
void i915_driver_pretakedown(drm_device_t *dev)
{
if ( dev->dev_private ) {
drm_i915_private_t *dev_priv = dev->dev_private;
......@@ -729,7 +728,7 @@ static void i915_driver_pretakedown(drm_device_t *dev)
i915_dma_cleanup( dev );
}
static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_i915_private_t *dev_priv = dev->dev_private;
......@@ -737,19 +736,3 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
void i915_driver_register_fns(drm_device_t *dev)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED;
dev->fn_tbl.pretakedown = i915_driver_pretakedown;
dev->fn_tbl.prerelease = i915_driver_prerelease;
dev->fn_tbl.irq_preinstall = i915_driver_irq_preinstall;
dev->fn_tbl.irq_postinstall = i915_driver_irq_postinstall;
dev->fn_tbl.irq_uninstall = i915_driver_irq_uninstall;
dev->fn_tbl.irq_handler = i915_driver_irq_handler;
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
}
......@@ -61,18 +61,31 @@ typedef struct _drm_i915_sarea {
/* I915 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
#define DRM_IOCTL_I915_INIT DRM_IOW( 0x40, drm_i915_init_t)
#define DRM_IOCTL_I915_FLUSH DRM_IO ( 0x41)
#define DRM_IOCTL_I915_FLIP DRM_IO ( 0x42)
#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( 0x43, drm_i915_batchbuffer_t)
#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(0x44, drm_i915_irq_emit_t)
#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( 0x45, drm_i915_irq_wait_t)
#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(0x46, drm_i915_getparam_t)
#define DRM_IOCTL_I915_SETPARAM DRM_IOW( 0x47, drm_i915_setparam_t)
#define DRM_IOCTL_I915_ALLOC DRM_IOWR(0x48, drm_i915_mem_alloc_t)
#define DRM_IOCTL_I915_FREE DRM_IOW( 0x49, drm_i915_mem_free_t)
#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( 0x4a, drm_i915_mem_init_heap_t)
#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( 0x4b, drm_i915_cmdbuffer_t)
#define DRM_I915_INIT 0x00
#define DRM_I915_FLUSH 0x01
#define DRM_I915_FLIP 0x02
#define DRM_I915_BATCHBUFFER 0x03
#define DRM_I915_IRQ_EMIT 0x04
#define DRM_I915_IRQ_WAIT 0x05
#define DRM_I915_GETPARAM 0x06
#define DRM_I915_SETPARAM 0x07
#define DRM_I915_ALLOC 0x08
#define DRM_I915_FREE 0x09
#define DRM_I915_INIT_HEAP 0x0a
#define DRM_I915_CMDBUFFER 0x0b
#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
#define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
#define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
#define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
/* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware.
......
......@@ -8,10 +8,100 @@
*
**************************************************************************/
#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
#include "i915_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
int postinit( struct drm_device *dev, unsigned long flags )
{
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
i915_PCI_IDS
};
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_I915_INIT)] = { i915_dma_init, 1, 1 },
[DRM_IOCTL_NR(DRM_I915_FLUSH)] = { i915_flush_ioctl, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_FLIP)] = { i915_flip_bufs, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = { i915_batchbuffer, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = { i915_irq_emit, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = { i915_irq_wait, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_GETPARAM)] = { i915_getparam, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_SETPARAM)] = { i915_setparam, 1, 1 },
[DRM_IOCTL_NR(DRM_I915_ALLOC)] = { i915_mem_alloc, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_FREE)] = { i915_mem_free, 1, 0 },
[DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = { i915_mem_init_heap, 1, 1 },
[DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = { i915_cmdbuffer, 1, 0 }
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
.pretakedown = i915_driver_pretakedown,
.prerelease = i915_driver_prerelease,
.irq_preinstall = i915_driver_irq_preinstall,
.irq_postinstall = i915_driver_irq_postinstall,
.irq_uninstall = i915_driver_irq_uninstall,
.irq_handler = i915_driver_irq_handler,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init i915_init(void)
{
return drm_init(&driver_fn);
}
static void __exit i915_exit(void)
{
drm_exit(&driver_fn);
}
module_init(i915_init);
module_exit(i915_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -10,6 +10,28 @@
#ifndef _I915_DRV_H_
#define _I915_DRV_H_
/* General customization:
*/
#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
#define DRIVER_NAME "i915"
#define DRIVER_DESC "Intel Graphics"
#define DRIVER_DATE "20040405"
/* Interface history:
*
* 1.1: Original.
*/
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
/* We use our own dma mechanisms, not the drm template code. However,
* the shared IRQ code is useful to us:
*/
#define __HAVE_PM 1
typedef struct _drm_i915_ring_buffer {
int tail_mask;
unsigned long Start;
......@@ -66,6 +88,8 @@ extern int i915_getparam(DRM_IOCTL_ARGS);
extern int i915_setparam(DRM_IOCTL_ARGS);
extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
extern void i915_kernel_lost_context(drm_device_t * dev);
extern void i915_driver_pretakedown(drm_device_t *dev);
extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS);
......
......@@ -7,7 +7,6 @@
*
**************************************************************************/
#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
......
......@@ -7,7 +7,6 @@
*
**************************************************************************/
#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
......@@ -75,7 +74,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
......@@ -91,7 +90,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
......@@ -148,7 +147,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
......@@ -156,7 +155,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
......@@ -164,14 +163,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
*heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
......@@ -211,7 +210,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
......@@ -228,10 +227,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
......
......@@ -33,7 +33,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
......@@ -308,7 +307,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
int i;
DRM_DEBUG( "count=%d\n", dma->buf_count );
dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
dev_priv->head = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
......@@ -320,7 +319,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
entry = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
return DRM_ERR(ENOMEM);
......@@ -357,7 +356,7 @@ static void mga_freelist_cleanup( drm_device_t *dev )
entry = dev_priv->head;
while ( entry ) {
next = entry->next;
DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
drm_free( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
entry = next;
}
......@@ -458,7 +457,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
int ret;
DRM_DEBUG( "\n" );
dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
dev_priv = drm_alloc( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
return DRM_ERR(ENOMEM);
......@@ -634,7 +633,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->irq_enabled ) drm_irq_uninstall(dev);
if ( dev->dev_private ) {
drm_mga_private_t *dev_priv = dev->dev_private;
......@@ -650,7 +649,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
mga_freelist_cleanup( dev );
}
DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
drm_free( dev->dev_private, sizeof(drm_mga_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
......@@ -798,30 +797,13 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
static void mga_driver_pretakedown(drm_device_t *dev)
void mga_driver_pretakedown(drm_device_t *dev)
{
mga_do_cleanup_dma( dev );
}
static int mga_driver_dma_quiescent(drm_device_t *dev)
int mga_driver_dma_quiescent(drm_device_t *dev)
{
drm_mga_private_t *dev_priv = dev->dev_private;
return mga_do_wait_for_idle( dev_priv );
}
void mga_driver_register_fns(drm_device_t *dev)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
dev->fn_tbl.pretakedown = mga_driver_pretakedown;
dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
dev->fn_tbl.vblank_wait = mga_driver_vblank_wait;
dev->fn_tbl.irq_preinstall = mga_driver_irq_preinstall;
dev->fn_tbl.irq_postinstall = mga_driver_irq_postinstall;
dev->fn_tbl.irq_uninstall = mga_driver_irq_uninstall;
dev->fn_tbl.irq_handler = mga_driver_irq_handler;
dev->counters += 3;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
}
......@@ -30,9 +30,99 @@
*/
#include <linux/config.h>
#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
#include "mga_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
static int postinit( struct drm_device *dev, unsigned long flags )
{
dev->counters += 3;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
mga_PCI_IDS
};
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_MGA_INIT)] = { mga_dma_init, 1, 1 },
[DRM_IOCTL_NR(DRM_MGA_FLUSH)] = { mga_dma_flush, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_RESET)] = { mga_dma_reset, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_SWAP)] = { mga_dma_swap, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_CLEAR)] = { mga_dma_clear, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_VERTEX)] = { mga_dma_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_INDICES)] = { mga_dma_indices, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_ILOAD)] = { mga_dma_iload, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_BLIT)] = { mga_dma_blit, 1, 0 },
[DRM_IOCTL_NR(DRM_MGA_GETPARAM)]= { mga_getparam, 1, 0 },
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
.pretakedown = mga_driver_pretakedown,
.dma_quiescent = mga_driver_dma_quiescent,
.vblank_wait = mga_driver_vblank_wait,
.irq_preinstall = mga_driver_irq_preinstall,
.irq_postinstall = mga_driver_irq_postinstall,
.irq_uninstall = mga_driver_irq_uninstall,
.irq_handler = mga_driver_irq_handler,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = mga_dma_buffers,
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init mga_init(void)
{
return drm_init(&driver_fn);
}
static void __exit mga_exit(void)
{
drm_exit(&driver_fn);
}
module_init(mga_init);
module_exit(mga_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -31,6 +31,19 @@
#ifndef __MGA_DRV_H__
#define __MGA_DRV_H__
/* General customization:
*/
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
#define DRIVER_NAME "mga"
#define DRIVER_DESC "Matrox G200/G400"
#define DRIVER_DATE "20021029"
#define DRIVER_MAJOR 3
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
typedef struct drm_mga_primary_buffer {
u8 *start;
u8 *end;
......@@ -104,6 +117,8 @@ extern int mga_dma_init( DRM_IOCTL_ARGS );
extern int mga_dma_flush( DRM_IOCTL_ARGS );
extern int mga_dma_reset( DRM_IOCTL_ARGS );
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
extern void mga_driver_pretakedown(drm_device_t *dev);
extern int mga_driver_dma_quiescent(drm_device_t *dev);
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
......
......@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
......@@ -50,7 +49,7 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM(vbl_send_signals)( dev );
drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
......
......@@ -32,7 +32,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
......
......@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
......
......@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
......@@ -355,7 +354,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "\n" );
dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
......@@ -544,7 +543,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
......@@ -561,7 +560,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart) ) {
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
......@@ -590,7 +589,7 @@ int r128_do_cleanup_cce( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->irq_enabled ) drm_irq_uninstall(dev);
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
......@@ -606,13 +605,13 @@ int r128_do_cleanup_cce( drm_device_t *dev )
} else
#endif
{
if (!DRM(ati_pcigart_cleanup)( dev,
if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
DRM(free)( dev->dev_private, sizeof(drm_r128_private_t),
drm_free( dev->dev_private, sizeof(drm_r128_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
......@@ -771,7 +770,7 @@ static int r128_freelist_init( drm_device_t *dev )
drm_r128_freelist_t *entry;
int i;
dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
......@@ -783,7 +782,7 @@ static int r128_freelist_init( drm_device_t *dev )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
entry = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( !entry ) return DRM_ERR(ENOMEM);
......
......@@ -30,11 +30,108 @@
*/
#include <linux/config.h>
#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
#include "r128_drv.h"
#include "ati_pcigart.h"
#include "drm_core.h"
#include "drm_pciids.h"
static int postinit( struct drm_device *dev, unsigned long flags )
{
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
r128_PCI_IDS
};
/* Interface history:
*
* ?? - ??
* 2.4 - Add support for ycbcr textures (no new ioctls)
* 2.5 - Add FLIP ioctl, disable FULLSCREEN.
*/
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_R128_INIT)] = { r128_cce_init, 1, 1 },
[DRM_IOCTL_NR(DRM_R128_CCE_START)] = { r128_cce_start, 1, 1 },
[DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = { r128_cce_stop, 1, 1 },
[DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = { r128_cce_reset, 1, 1 },
[DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = { r128_cce_idle, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_RESET)] = { r128_engine_reset, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = { r128_fullscreen, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_SWAP)] = { r128_cce_swap, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_FLIP)] = { r128_cce_flip, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_CLEAR)] = { r128_cce_clear, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_VERTEX)] = { r128_cce_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_INDICES)] = { r128_cce_indices, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_BLIT)] = { r128_cce_blit, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_DEPTH)] = { r128_cce_depth, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_STIPPLE)] = { r128_cce_stipple, 1, 0 },
[DRM_IOCTL_NR(DRM_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 },
[DRM_IOCTL_NR(DRM_R128_GETPARAM)] = { r128_getparam, 1, 0 },
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
.dev_priv_size = sizeof(drm_r128_buf_priv_t),
.prerelease = r128_driver_prerelease,
.pretakedown = r128_driver_pretakedown,
.vblank_wait = r128_driver_vblank_wait,
.irq_preinstall = r128_driver_irq_preinstall,
.irq_postinstall = r128_driver_irq_postinstall,
.irq_uninstall = r128_driver_irq_uninstall,
.irq_handler = r128_driver_irq_handler,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = r128_cce_buffers,
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init r128_init(void)
{
return drm_init(&driver_fn);
}
static void __exit r128_exit(void)
{
drm_exit(&driver_fn);
}
module_init(r128_init);
module_exit(r128_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -28,12 +28,25 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
* Michel Dnzer <daenzerm@student.ethz.ch>
* Michel D�zer <daenzerm@student.ethz.ch>
*/
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
/* General customization:
*/
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
#define DRIVER_NAME "r128"
#define DRIVER_DESC "ATI Rage 128"
#define DRIVER_DATE "20030725"
#define DRIVER_MAJOR 2
#define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 0
#define GET_RING_HEAD(dev_priv) R128_READ( R128_PM4_BUFFER_DL_RPTR )
typedef struct drm_r128_freelist {
......@@ -148,6 +161,8 @@ extern irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS );
extern void r128_driver_irq_preinstall( drm_device_t *dev );
extern void r128_driver_irq_postinstall( drm_device_t *dev );
extern void r128_driver_irq_uninstall( drm_device_t *dev );
extern void r128_driver_pretakedown(drm_device_t *dev);
extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* Register definitions, register access macros and drmAddMap constants
* for Rage 128 kernel driver.
......
......@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
......@@ -50,7 +49,7 @@ irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM(vbl_send_signals)( dev );
drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
......
......@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
......@@ -926,24 +925,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
drm_free( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
DRM(free)( mask, mask_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
......@@ -970,7 +969,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
DRM(free)( mask, mask_size, DRM_MEM_BUFS );
drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
......@@ -994,7 +993,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
......@@ -1016,54 +1015,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
DRM(free)( mask, mask_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
......@@ -1090,7 +1089,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
DRM(free)( mask, mask_size, DRM_MEM_BUFS );
drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
......@@ -1114,9 +1113,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
......@@ -1184,23 +1183,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
......@@ -1228,8 +1227,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
drm_free( x, xbuf_size, DRM_MEM_BUFS );
drm_free( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
......@@ -1695,7 +1694,7 @@ int r128_getparam( DRM_IOCTL_ARGS )
return 0;
}
static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
......@@ -1705,20 +1704,8 @@ static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_pretakedown(drm_device_t *dev)
{
r128_do_cleanup_cce( dev );
}
void r128_driver_register_fns(drm_device_t *dev)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
dev->fn_tbl.prerelease = r128_driver_prerelease;
dev->fn_tbl.pretakedown = r128_driver_pretakedown;
dev->fn_tbl.vblank_wait = r128_driver_vblank_wait;
dev->fn_tbl.irq_preinstall = r128_driver_irq_preinstall;
dev->fn_tbl.irq_postinstall = r128_driver_irq_postinstall;
dev->fn_tbl.irq_uninstall = r128_driver_irq_uninstall;
dev->fn_tbl.irq_handler = r128_driver_irq_handler;
}
......@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
......@@ -1006,7 +1005,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
drm_radeon_private_t *dev_priv;
DRM_DEBUG( "\n" );
dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
dev_priv = drm_alloc( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
......@@ -1233,7 +1232,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
......@@ -1247,7 +1246,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
} else
#endif
{
if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart)) {
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
......@@ -1279,7 +1278,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
if ( dev->irq_enabled ) drm_irq_uninstall(dev);
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
......@@ -1295,13 +1294,13 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
} else
#endif
{
if (!DRM(ati_pcigart_cleanup)( dev,
if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
DRM(free)( dev->dev_private, sizeof(drm_radeon_private_t),
drm_free( dev->dev_private, sizeof(drm_radeon_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
......
......@@ -31,11 +31,145 @@
#include <linux/config.h>
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
#include "radeon_drv.h"
#include "ati_pcigart.h"
#include "drm_core.h"
#include "drm_pciids.h"
static int postinit( struct drm_device *dev, unsigned long flags )
{
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
radeon_PCI_IDS
};
/* Interface history:
*
* 1.1 - ??
* 1.2 - Add vertex2 ioctl (keith)
* - Add stencil capability to clear ioctl (gareth, keith)
* - Increase MAX_TEXTURE_LEVELS (brian)
* 1.3 - Add cmdbuf ioctl (keith)
* - Add support for new radeon packets (keith)
* - Add getparam ioctl (keith)
* - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
* 1.4 - Add scratch registers to get_param ioctl.
* 1.5 - Add r200 packets to cmdbuf ioctl
* - Add r200 function to init ioctl
* - Add 'scalar2' instruction to cmdbuf
* 1.6 - Add static GART memory manager
* Add irq handler (won't be turned on unless X server knows to)
* Add irq ioctls and irq_active getparam.
* Add wait command for cmdbuf ioctl
* Add GART offset query for getparam
* 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5]
* and R200_PP_CUBIC_OFFSET_F1_[0..5].
* Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
* R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian)
* 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
* Add 'GET' queries for starting additional clients on different VT's.
* 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl.
* Add texture rectangle support for r100.
* 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which
* clients use to tell the DRM where they think the framebuffer is
* located in the card's address space
* 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
* and GL_EXT_blend_[func|equation]_separate on r200
*/
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_RADEON_CP_INIT)] = { radeon_cp_init, 1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_CP_START)] = { radeon_cp_start, 1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_CP_STOP)] = { radeon_cp_stop, 1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_CP_RESET)] = { radeon_cp_reset, 1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_CP_IDLE)] = { radeon_cp_idle, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_CP_RESUME)] = { radeon_cp_resume, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_RESET)] = { radeon_engine_reset, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_FULLSCREEN)] = { radeon_fullscreen, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_SWAP)] = { radeon_cp_swap, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_CLEAR)] = { radeon_cp_clear, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_VERTEX)] = { radeon_cp_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_INDICES)] = { radeon_cp_indices, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_TEXTURE)] = { radeon_cp_texture, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_STIPPLE)] = { radeon_cp_stipple, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_INDIRECT)] = { radeon_cp_indirect, 1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_VERTEX2)] = { radeon_cp_vertex2, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_CMDBUF)] = { radeon_cp_cmdbuf, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_GETPARAM)] = { radeon_cp_getparam, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_FLIP)] = { radeon_cp_flip, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_ALLOC)] = { radeon_mem_alloc, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_FREE)] = { radeon_mem_free, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_INIT_HEAP)] = { radeon_mem_init_heap,1, 1 },
[DRM_IOCTL_NR(DRM_RADEON_IRQ_EMIT)] = { radeon_irq_emit, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 },
[DRM_IOCTL_NR(DRM_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 },
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
.dev_priv_size = sizeof(drm_radeon_buf_priv_t),
.prerelease = radeon_driver_prerelease,
.pretakedown = radeon_driver_pretakedown,
.open_helper = radeon_driver_open_helper,
.vblank_wait = radeon_driver_vblank_wait,
.irq_preinstall = radeon_driver_irq_preinstall,
.irq_postinstall = radeon_driver_irq_postinstall,
.irq_uninstall = radeon_driver_irq_uninstall,
.irq_handler = radeon_driver_irq_handler,
.free_filp_priv = radeon_driver_free_filp_priv,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = radeon_cp_buffers,
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init radeon_init(void)
{
return drm_init(&driver_fn);
}
static void __exit radeon_exit(void)
{
drm_exit(&driver_fn);
}
module_init(radeon_init);
module_exit(radeon_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -31,6 +31,19 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
/* General customization:
*/
#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
#define DRIVER_NAME "radeon"
#define DRIVER_DESC "ATI Radeon"
#define DRIVER_DATE "20020828"
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 11
#define DRIVER_PATCHLEVEL 0
#define GET_RING_HEAD(dev_priv) DRM_READ32( (dev_priv)->ring_rptr, 0 )
#define SET_RING_HEAD(dev_priv,val) DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
......@@ -210,6 +223,14 @@ extern irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS );
extern void radeon_driver_irq_preinstall( drm_device_t *dev );
extern void radeon_driver_irq_postinstall( drm_device_t *dev );
extern void radeon_driver_irq_uninstall( drm_device_t *dev );
extern void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp);
extern void radeon_driver_pretakedown(drm_device_t *dev);
extern int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv);
extern void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv);
extern int radeon_preinit( struct drm_device *dev, unsigned long flags );
extern int radeon_postinit( struct drm_device *dev, unsigned long flags );
extern int radeon_postcleanup( struct drm_device *dev );
/* Flags for stats.boxes
*/
......
......@@ -27,10 +27,9 @@
*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Michel Dänzer <michel@daenzer.net>
* Michel Dzer <michel@daenzer.net>
*/
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
......@@ -78,7 +77,7 @@ irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM(vbl_send_signals)( dev );
drm_vbl_send_signals( dev );
}
/* Acknowledge interrupts we handle */
......@@ -223,7 +222,7 @@ int radeon_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
void radeon_driver_irq_preinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
......@@ -234,7 +233,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
radeon_acknowledge_irqs( dev_priv );
}
void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
void radeon_driver_irq_postinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
......@@ -247,7 +246,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
RADEON_SW_INT_ENABLE );
}
void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
void radeon_driver_irq_uninstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
if (!dev_priv)
......
......@@ -29,7 +29,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
......@@ -44,7 +43,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
......@@ -60,7 +59,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
......@@ -118,7 +117,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
drm_free(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
......@@ -126,7 +125,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
drm_free(p, sizeof(*q), DRM_MEM_BUFS );
}
}
......@@ -134,14 +133,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
*heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
drm_free( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
......@@ -180,7 +179,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
......@@ -197,10 +196,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
drm_free( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
......
......@@ -27,7 +27,6 @@
* Kevin E. Martin <martin@valinux.com>
*/
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
......@@ -1597,7 +1596,7 @@ static int radeon_do_init_pageflip( drm_device_t *dev )
return 0;
}
/* Called whenever a client dies, from DRM(release).
/* Called whenever a client dies, from drm_release.
* NOTE: Lock isn't necessarily held when this is called!
*/
int radeon_do_cleanup_pageflip( drm_device_t *dev )
......@@ -2554,7 +2553,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
*
* DRM infrastructure takes care of reclaiming dma buffers.
*/
static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
......@@ -2566,17 +2565,17 @@ static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
static void radeon_driver_pretakedown(drm_device_t *dev)
void radeon_driver_pretakedown(drm_device_t *dev)
{
radeon_do_release(dev);
}
static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
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);
radeon_priv = (struct drm_radeon_driver_file_fields *)drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv)
return -ENOMEM;
......@@ -2590,24 +2589,9 @@ static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
}
static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
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)
{
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper;
dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
dev->fn_tbl.vblank_wait = radeon_driver_vblank_wait;
dev->fn_tbl.irq_preinstall = radeon_driver_irq_preinstall;
dev->fn_tbl.irq_postinstall = radeon_driver_irq_postinstall;
dev->fn_tbl.irq_uninstall = radeon_driver_irq_uninstall;
dev->fn_tbl.irq_handler = radeon_driver_irq_handler;
drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
}
......@@ -3,12 +3,21 @@
#define __SIS_DRM_H__
/* SiS specific ioctls */
#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(0x44, drm_sis_mem_t)
#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t)
#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(0x53, drm_sis_agp_t)
#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(0x54, drm_sis_mem_t)
#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t)
#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( 0x56, drm_sis_fb_t)
#define NOT_USED_0_3
#define DRM_SIS_FB_ALLOC 0x04
#define DRM_SIS_FB_FREE 0x05
#define NOT_USED_6_12
#define DRM_SIS_AGP_INIT 0x13
#define DRM_SIS_AGP_ALLOC 0x14
#define DRM_SIS_AGP_FREE 0x15
#define DRM_SIS_FB_INIT 0x16
#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
/*
#define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
#define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49)
......
......@@ -26,9 +26,82 @@
*/
#include <linux/config.h>
#include "sis.h"
#include "drmP.h"
#include "sis_drm.h"
#include "sis_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
static int postinit( struct drm_device *dev, unsigned long flags )
{
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
sisdrv_PCI_IDS
};
static drm_ioctl_desc_t ioctls[] = {
[DRM_IOCTL_NR(DRM_SIS_FB_ALLOC)] = { sis_fb_alloc, 1, 0 },
[DRM_IOCTL_NR(DRM_SIS_FB_FREE)] = { sis_fb_free, 1, 0 },
[DRM_IOCTL_NR(DRM_SIS_AGP_INIT)] = { sis_ioctl_agp_init, 1, 1 },
[DRM_IOCTL_NR(DRM_SIS_AGP_ALLOC)] = { sis_ioctl_agp_alloc, 1, 0 },
[DRM_IOCTL_NR(DRM_SIS_AGP_FREE)] = { sis_ioctl_agp_free, 1, 0 },
[DRM_IOCTL_NR(DRM_SIS_FB_INIT)] = { sis_fb_init, 1, 1 }
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR,
.context_ctor = sis_init_context,
.context_dtor = sis_final_context,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init sis_init(void)
{
return drm_init(&driver_fn);
}
static void __exit sis_exit(void)
{
drm_exit(&driver_fn);
}
module_init(sis_init);
module_exit(sis_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
......@@ -28,6 +28,17 @@
#ifndef _SIS_DRV_H_
#define _SIS_DRV_H_
/* General customization:
*/
#define DRIVER_AUTHOR "SIS"
#define DRIVER_NAME "sis"
#define DRIVER_DESC "SIS 300/630/540"
#define DRIVER_DATE "20030826"
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
#include "sis_ds.h"
typedef struct drm_sis_private {
......@@ -42,4 +53,7 @@ extern int sis_ioctl_agp_alloc( DRM_IOCTL_ARGS );
extern int sis_ioctl_agp_free( DRM_IOCTL_ARGS );
extern int sis_fb_init( DRM_IOCTL_ARGS );
extern int sis_init_context(drm_device_t *dev, int context);
extern int sis_final_context(drm_device_t *dev, int context);
#endif
......@@ -28,7 +28,6 @@
*
*/
#include "sis.h"
#include "drmP.h"
#include "drm.h"
#include "sis_ds.h"
......@@ -42,7 +41,7 @@ set_t *setInit(void)
int i;
set_t *set;
set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
if (set != NULL) {
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i + 1;
......@@ -128,7 +127,7 @@ int setNext(set_t *set, ITEM_TYPE *item)
int setDestroy(set_t *set)
{
DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
......@@ -167,7 +166,7 @@ memHeap_t *mmInit(int ofs,
if (size <= 0)
return NULL;
blocks = (TMemBlock *)DRM(calloc)(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
blocks = (TMemBlock *)drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks->ofs = ofs;
blocks->size = size;
......@@ -202,7 +201,7 @@ memHeap_t *mmAddRange( memHeap_t *heap,
int size )
{
PMemBlock blocks;
blocks = (TMemBlock *)DRM(calloc)(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
blocks = (TMemBlock *)drm_calloc(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks[0].size = size;
blocks[0].free = 1;
......@@ -229,7 +228,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
......@@ -242,7 +241,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
......@@ -295,7 +294,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
DRM(free)(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
return 1;
}
return 0;
......@@ -380,7 +379,7 @@ void mmDestroy(memHeap_t *heap)
p = (TMemBlock *)heap;
while (p != NULL) {
q = p->next;
DRM(free)(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
drm_free(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
p = q;
}
}
......@@ -28,7 +28,6 @@
*
*/
#include "sis.h"
#include "drmP.h"
#include "sis_drm.h"
#include "sis_drv.h"
......@@ -159,7 +158,7 @@ int sis_fb_init( DRM_IOCTL_ARGS )
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *)data, sizeof(fb));
if (dev_priv == NULL) {
dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
......@@ -247,7 +246,7 @@ int sis_ioctl_agp_init( DRM_IOCTL_ARGS )
drm_sis_agp_t agp;
if (dev_priv == NULL) {
dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
......@@ -404,10 +403,3 @@ int sis_final_context(struct drm_device *dev, int context)
return 1;
}
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_dtor = sis_final_context;
}
......@@ -31,13 +31,68 @@
*/
#include <linux/config.h>
#include "tdfx.h"
#include "drmP.h"
#include "tdfx_drv.h"
#include "drm_core.h"
#include "drm_pciids.h"
void DRM(driver_register_fns)(drm_device_t *dev)
static int postinit( struct drm_device *dev, unsigned long flags )
{
dev->driver_features = DRIVER_USE_MTRR;
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE,
dev->minor,
pci_pretty_name(dev->pdev)
);
return 0;
}
static int version( drm_version_t *version )
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY( version->name, DRIVER_NAME );
DRM_COPY( version->date, DRIVER_DATE );
DRM_COPY( version->desc, DRIVER_DESC );
return 0;
}
static struct pci_device_id pciidlist[] = {
tdfx_PCI_IDS
};
static struct drm_driver_fn driver_fn = {
.driver_features = DRIVER_USE_MTRR,
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
}
};
static int __init tdfx_init(void)
{
return drm_init(&driver_fn);
}
static void __exit tdfx_exit(void)
{
drm_exit(&driver_fn);
}
module_init(tdfx_init);
module_exit(tdfx_exit);
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights");
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