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 @@ ...@@ -52,7 +52,7 @@
# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # 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; unsigned long address;
struct page *page; struct page *page;
...@@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void ) ...@@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void )
return address; 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; struct page *page;
int i; int i;
...@@ -91,7 +91,7 @@ static void DRM(ati_free_pcigart_table)( unsigned long address ) ...@@ -91,7 +91,7 @@ static void DRM(ati_free_pcigart_table)( unsigned long address )
free_pages( address, ATI_PCIGART_TABLE_ORDER ); 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, unsigned long *addr,
dma_addr_t *bus_addr) dma_addr_t *bus_addr)
{ {
...@@ -106,7 +106,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -106,7 +106,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done; goto done;
} }
address = DRM(ati_alloc_pcigart_table)(); address = drm_ati_alloc_pcigart_table();
if ( !address ) { if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" ); DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done; goto done;
...@@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
if (bus_address == 0) { if (bus_address == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" ); DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_free_pcigart_table)( address ); drm_ati_free_pcigart_table( address );
address = 0; address = 0;
goto done; goto done;
} }
...@@ -142,7 +142,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -142,7 +142,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
if (entry->busaddr[i] == 0) { if (entry->busaddr[i] == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" ); 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; address = 0;
bus_address = 0; bus_address = 0;
goto done; goto done;
...@@ -169,7 +169,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -169,7 +169,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
return ret; return ret;
} }
int DRM(ati_pcigart_cleanup)( drm_device_t *dev, int drm_ati_pcigart_cleanup( drm_device_t *dev,
unsigned long addr, unsigned long addr,
dma_addr_t bus_addr) dma_addr_t bus_addr)
{ {
...@@ -199,7 +199,7 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev, ...@@ -199,7 +199,7 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
} }
if ( addr ) { if ( addr ) {
DRM(ati_free_pcigart_table)( addr ); drm_ati_free_pcigart_table( addr );
} }
return 1; return 1;
......
This diff is collapsed.
...@@ -56,7 +56,7 @@ static const drm_agp_t *drm_agp = NULL; ...@@ -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 * 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. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -95,7 +95,7 @@ int DRM(agp_info)(struct inode *inode, struct file *filp, ...@@ -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 * Verifies the AGP device hasn't been acquired before and calls
* drm_agp->acquire(). * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -125,7 +125,7 @@ int DRM(agp_acquire)(struct inode *inode, struct file *filp, ...@@ -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(). * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -144,7 +144,7 @@ int DRM(agp_release)(struct inode *inode, struct file *filp, ...@@ -144,7 +144,7 @@ int DRM(agp_release)(struct inode *inode, struct file *filp,
* *
* Calls drm_agp->release(). * Calls drm_agp->release().
*/ */
void DRM(agp_do_release)(void) void drm_agp_do_release(void)
{ {
if (drm_agp->release) if (drm_agp->release)
drm_agp->release(); drm_agp->release();
...@@ -162,7 +162,7 @@ void DRM(agp_do_release)(void) ...@@ -162,7 +162,7 @@ void DRM(agp_do_release)(void)
* Verifies the AGP device has been acquired but not enabled, and calls * Verifies the AGP device has been acquired but not enabled, and calls
* drm_agp->enable(). * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -194,7 +194,7 @@ int DRM(agp_enable)(struct inode *inode, struct file *filp, ...@@ -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 * 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. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -210,7 +210,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, ...@@ -210,7 +210,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
return -EINVAL; return -EINVAL;
if (copy_from_user(&request, argp, sizeof(request))) if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT; return -EFAULT;
if (!(entry = DRM(alloc)(sizeof(*entry), DRM_MEM_AGPLISTS))) if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
...@@ -218,8 +218,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, ...@@ -218,8 +218,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request.type; type = (u32) request.type;
if (!(memory = DRM(alloc_agp)(pages, type))) { if (!(memory = drm_alloc_agp(pages, type))) {
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -ENOMEM; return -ENOMEM;
} }
...@@ -239,8 +239,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, ...@@ -239,8 +239,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
if (copy_to_user(argp, &request, sizeof(request))) { if (copy_to_user(argp, &request, sizeof(request))) {
dev->agp->memory = entry->next; dev->agp->memory = entry->next;
dev->agp->memory->prev = NULL; dev->agp->memory->prev = NULL;
DRM(free_agp)(memory, pages); drm_free_agp(memory, pages);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -255,7 +255,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, ...@@ -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. * 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) unsigned long handle)
{ {
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
...@@ -279,7 +279,7 @@ static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev, ...@@ -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 * Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -292,11 +292,11 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp, ...@@ -292,11 +292,11 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp,
return -EINVAL; return -EINVAL;
if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request))) if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request)))
return -EFAULT; return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (!entry->bound) if (!entry->bound)
return -EINVAL; return -EINVAL;
ret = DRM(unbind_agp)(entry->memory); ret = drm_unbind_agp(entry->memory);
if (ret == 0) if (ret == 0)
entry->bound = 0; entry->bound = 0;
return ret; return ret;
...@@ -315,7 +315,7 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp, ...@@ -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 * is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -329,12 +329,12 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp, ...@@ -329,12 +329,12 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp,
return -EINVAL; return -EINVAL;
if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request))) if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request)))
return -EFAULT; return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (entry->bound) if (entry->bound)
return -EINVAL; return -EINVAL;
page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE; 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; return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT); entry->bound = dev->agp->base + (page << PAGE_SHIFT);
DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
...@@ -356,7 +356,7 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp, ...@@ -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 * unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -368,10 +368,10 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, ...@@ -368,10 +368,10 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
return -EINVAL; return -EINVAL;
if (copy_from_user(&request, (drm_agp_buffer_t __user *)arg, sizeof(request))) if (copy_from_user(&request, (drm_agp_buffer_t __user *)arg, sizeof(request)))
return -EFAULT; return -EFAULT;
if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (entry->bound) if (entry->bound)
DRM(unbind_agp)(entry->memory); drm_unbind_agp(entry->memory);
if (entry->prev) if (entry->prev)
entry->prev->next = entry->next; entry->prev->next = entry->next;
...@@ -381,8 +381,8 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, ...@@ -381,8 +381,8 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
if (entry->next) if (entry->next)
entry->next->prev = entry->prev; entry->next->prev = entry->prev;
DRM(free_agp)(entry->memory, entry->pages); drm_free_agp(entry->memory, entry->pages);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0; return 0;
} }
...@@ -395,18 +395,18 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, ...@@ -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 * via the inter_module_* functions. Creates and initializes a drm_agp_head
* structure. * 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_head_t *head = NULL;
drm_agp = DRM_AGP_GET; drm_agp = DRM_AGP_GET;
if (drm_agp) { if (drm_agp) {
if (!(head = DRM(alloc)(sizeof(*head), DRM_MEM_AGPLISTS))) if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
return NULL; return NULL;
memset((void *)head, 0, sizeof(*head)); memset((void *)head, 0, sizeof(*head));
drm_agp->copy_info(&head->agp_info); drm_agp->copy_info(&head->agp_info);
if (head->agp_info.chipset == NOT_SUPPORTED) { 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; return NULL;
} }
head->memory = NULL; head->memory = NULL;
...@@ -426,14 +426,14 @@ drm_agp_head_t *DRM(agp_init)(void) ...@@ -426,14 +426,14 @@ drm_agp_head_t *DRM(agp_init)(void)
* *
* Releases the pointer in ::drm_agp. * Releases the pointer in ::drm_agp.
*/ */
void DRM(agp_uninit)(void) void drm_agp_uninit(void)
{ {
DRM_AGP_PUT; DRM_AGP_PUT;
drm_agp = NULL; drm_agp = NULL;
} }
/** Calls drm_agp->allocate_memory() */ /** 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) if (!drm_agp->allocate_memory)
return NULL; return NULL;
...@@ -441,7 +441,7 @@ DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type) ...@@ -441,7 +441,7 @@ DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type)
} }
/** Calls drm_agp->free_memory() */ /** 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) if (!handle || !drm_agp->free_memory)
return 0; return 0;
...@@ -450,7 +450,7 @@ int DRM(agp_free_memory)(DRM_AGP_MEM *handle) ...@@ -450,7 +450,7 @@ int DRM(agp_free_memory)(DRM_AGP_MEM *handle)
} }
/** Calls drm_agp->bind_memory() */ /** 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) if (!handle || !drm_agp->bind_memory)
return -EINVAL; return -EINVAL;
...@@ -458,7 +458,7 @@ int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start) ...@@ -458,7 +458,7 @@ int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start)
} }
/** Calls drm_agp->unbind_memory() */ /** 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) if (!handle || !drm_agp->unbind_memory)
return -EINVAL; return -EINVAL;
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be * The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be
* a power of 2. * 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); return magic & (DRM_HASH_SIZE-1);
} }
...@@ -59,11 +59,11 @@ static int DRM(hash_magic)(drm_magic_t magic) ...@@ -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 * the one with matching magic number, while holding the drm_device::struct_sem
* lock. * 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_file_t *retval = NULL;
drm_magic_entry_t *pt; drm_magic_entry_t *pt;
int hash = DRM(hash_magic)(magic); int hash = drm_hash_magic(magic);
down(&dev->struct_sem); down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { 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) ...@@ -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 * associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock. * 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; int hash;
drm_magic_entry_t *entry; drm_magic_entry_t *entry;
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic); hash = drm_hash_magic(magic);
entry = DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
if (!entry) return -ENOMEM; if (!entry) return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
entry->magic = magic; entry->magic = magic;
...@@ -124,7 +124,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t 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 * Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock. * 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 *prev = NULL;
drm_magic_entry_t *pt; drm_magic_entry_t *pt;
...@@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) ...@@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic); hash = drm_hash_magic(magic);
down(&dev->struct_sem); down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { 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) ...@@ -152,7 +152,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
} }
up(&dev->struct_sem); up(&dev->struct_sem);
DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
return -EINVAL; return -EINVAL;
} }
...@@ -170,7 +170,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) ...@@ -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 * searches an unique non-zero magic number and add it associating it with \p
* filp. * 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) unsigned int cmd, unsigned long arg)
{ {
static drm_magic_t sequence = 0; static drm_magic_t sequence = 0;
...@@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, ...@@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
if (!sequence) ++sequence; /* reserve 0 */ if (!sequence) ++sequence; /* reserve 0 */
auth.magic = sequence++; auth.magic = sequence++;
spin_unlock(&lock); spin_unlock(&lock);
} while (DRM(find_file)(dev, auth.magic)); } while (drm_find_file(dev, auth.magic));
priv->magic = 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); DRM_DEBUG("%u\n", auth.magic);
...@@ -210,7 +210,7 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, ...@@ -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. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -221,9 +221,9 @@ int DRM(authmagic)(struct inode *inode, struct file *filp, ...@@ -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))) if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth)))
return -EFAULT; return -EFAULT;
DRM_DEBUG("%u\n", auth.magic); 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; file->authenticated = 1;
DRM(remove_magic)(dev, auth.magic); drm_remove_magic(dev, auth.magic);
return 0; return 0;
} }
return -EINVAL; return -EINVAL;
......
This diff is collapsed.
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
* in drm_device::context_sareas, while holding the drm_device::struct_sem * in drm_device::context_sareas, while holding the drm_device::struct_sem
* lock. * 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 ( ctx_handle < 0 ) goto failed;
if ( !dev->ctx_bitmap ) goto failed; if ( !dev->ctx_bitmap ) goto failed;
...@@ -84,7 +84,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) ...@@ -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::context_sareas to accommodate the new entry while holding the
* drm_device::struct_sem lock. * drm_device::struct_sem lock.
*/ */
int DRM(ctxbitmap_next)( drm_device_t *dev ) int drm_ctxbitmap_next( drm_device_t *dev )
{ {
int bit; int bit;
...@@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if(dev->context_sareas) { if(dev->context_sareas) {
drm_map_t **ctx_sareas; drm_map_t **ctx_sareas;
ctx_sareas = DRM(realloc)(dev->context_sareas, ctx_sareas = drm_realloc(dev->context_sareas,
(dev->max_context - 1) * (dev->max_context - 1) *
sizeof(*dev->context_sareas), sizeof(*dev->context_sareas),
dev->max_context * dev->max_context *
...@@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
dev->context_sareas[bit] = NULL; dev->context_sareas[bit] = NULL;
} else { } else {
/* max_context == 1 at this point */ /* max_context == 1 at this point */
dev->context_sareas = DRM(alloc)( dev->context_sareas = drm_alloc(
dev->max_context * dev->max_context *
sizeof(*dev->context_sareas), sizeof(*dev->context_sareas),
DRM_MEM_MAPS); DRM_MEM_MAPS);
...@@ -142,13 +142,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -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 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * 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 i;
int temp; int temp;
down(&dev->struct_sem); 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 ); DRM_MEM_CTXBITMAP );
if ( dev->ctx_bitmap == NULL ) { if ( dev->ctx_bitmap == NULL ) {
up(&dev->struct_sem); up(&dev->struct_sem);
...@@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) ...@@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
up(&dev->struct_sem); up(&dev->struct_sem);
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) { 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 ); DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
} }
...@@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) ...@@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
* Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * 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); 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) * sizeof(*dev->context_sareas) *
dev->max_context, dev->max_context,
DRM_MEM_MAPS ); 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); up(&dev->struct_sem);
} }
...@@ -204,7 +204,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) ...@@ -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 * Gets the map from drm_device::context_sareas with the handle specified and
* returns its handle. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -243,7 +243,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp, ...@@ -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 * Searches the mapping specified in \p arg and update the entry in
* drm_device::context_sareas with it. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -297,7 +297,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp, ...@@ -297,7 +297,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
* *
* Attempt to set drm_device::context_flag. * 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 ) ) { if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" ); DRM_ERROR( "Reentering -- FIXME\n" );
...@@ -326,7 +326,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new ) ...@@ -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 * hardware lock is held, clears the drm_device::context_flag and wakes up
* drm_device::context_wait. * 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_context = new; /* PRE/POST: This is the _only_ writer. */
dev->last_switch = jiffies; dev->last_switch = jiffies;
...@@ -353,7 +353,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new ) ...@@ -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. * \param arg user argument pointing to a drm_ctx_res structure.
* \return zero on success or a negative number on failure. * \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 ) unsigned int cmd, unsigned long arg )
{ {
drm_ctx_res_t res; drm_ctx_res_t res;
...@@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp, ...@@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp,
* *
* Get a new handle for the context and copy to userspace. * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( copy_from_user( &ctx, argp, sizeof(ctx) ) ) if ( copy_from_user( &ctx, argp, sizeof(ctx) ) )
return -EFAULT; return -EFAULT;
ctx.handle = DRM(ctxbitmap_next)( dev ); ctx.handle = drm_ctxbitmap_next( dev );
if ( ctx.handle == DRM_KERNEL_CONTEXT ) { if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
/* Skip kernel's context and get a new one. */ /* 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 ); DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle == -1 ) { if ( ctx.handle == -1 ) {
...@@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( ctx.handle != DRM_KERNEL_CONTEXT ) if ( ctx.handle != DRM_KERNEL_CONTEXT )
{ {
if (dev->fn_tbl.context_ctor) if (dev->fn_tbl->context_ctor)
dev->fn_tbl.context_ctor(dev, ctx.handle); 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 ) { if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n"); DRM_DEBUG("out of memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
return 0; 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 ) unsigned int cmd, unsigned long arg )
{ {
/* This does nothing */ /* This does nothing */
...@@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp, ...@@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp,
* \param arg user argument pointing to a drm_ctx structure. * \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure. * \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 ) unsigned int cmd, unsigned long arg )
{ {
drm_ctx_t __user *argp = (void __user *)arg; drm_ctx_t __user *argp = (void __user *)arg;
...@@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp, ...@@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp,
* *
* Calls context_switch(). * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp, ...@@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle ); 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, ...@@ -510,7 +510,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
* *
* Calls context_switch_complete(). * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, ...@@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle ); DRM_DEBUG( "%d\n", ctx.handle );
DRM(context_switch_complete)( dev, ctx.handle ); drm_context_switch_complete( dev, ctx.handle );
return 0; return 0;
} }
...@@ -537,7 +537,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, ...@@ -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. * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
priv->remove_auth_on_close = 1; priv->remove_auth_on_close = 1;
} }
if ( ctx.handle != DRM_KERNEL_CONTEXT ) { if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor) if (dev->fn_tbl->context_dtor)
dev->fn_tbl.context_dtor(dev, ctx.handle); dev->fn_tbl->context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle ); drm_ctxbitmap_free( dev, ctx.handle );
} }
down( &dev->ctxlist_sem ); down( &dev->ctxlist_sem );
...@@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) { list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->handle == ctx.handle ) { if ( pos->handle == ctx.handle ) {
list_del( &pos->head ); list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST ); drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count; --dev->ctx_count;
} }
} }
......
...@@ -20,21 +20,15 @@ ...@@ -20,21 +20,15 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"
#include "drm_auth.h" #define DRIVER_NAME "drm"
#include "drm_agpsupport.h" #define DRIVER_DESC "DRM shared core routines"
#include "drm_bufs.h" #define DRIVER_DATE "20040925"
#include "drm_context.h"
#include "drm_dma.h" #define DRM_IF_MAJOR 1
#include "drm_irq.h" #define DRM_IF_MINOR 2
#include "drm_drawable.h"
#include "drm_drv.h" #define DRIVER_MAJOR 1
#include "drm_fops.h" #define DRIVER_MINOR 0
#include "drm_init.h" #define DRIVER_PATCHLEVEL 0
#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"
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
* *
* Allocate and initialize a drm_device_dma structure. * 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; 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 ) if ( !dev->dma )
return -ENOMEM; return -ENOMEM;
...@@ -67,7 +67,7 @@ int DRM(dma_setup)( drm_device_t *dev ) ...@@ -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 * Free all pages associated with DMA buffers, the buffers and pages lists, and
* finally the the drm_device::dma structure itself. * 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; drm_device_dma_t *dma = dev->dma;
int i, j; int i, j;
...@@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
dma->bufs[i].seg_count); dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) { for (j = 0; j < dma->bufs[i].seg_count; j++) {
if (dma->bufs[i].seglist[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, dma->bufs[i].page_order,
DRM_MEM_DMA); DRM_MEM_DMA);
} }
} }
DRM(free)(dma->bufs[i].seglist, drm_free(dma->bufs[i].seglist,
dma->bufs[i].seg_count dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist), * sizeof(*dma->bufs[0].seglist),
DRM_MEM_SEGS); DRM_MEM_SEGS);
...@@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
if (dma->bufs[i].buf_count) { if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) { for (j = 0; j < dma->bufs[i].buf_count; j++) {
if (dma->bufs[i].buflist[j].dev_private) { 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, dma->bufs[i].buflist[j].dev_priv_size,
DRM_MEM_BUFS); DRM_MEM_BUFS);
} }
} }
DRM(free)(dma->bufs[i].buflist, drm_free(dma->bufs[i].buflist,
dma->bufs[i].buf_count * dma->bufs[i].buf_count *
sizeof(*dma->bufs[0].buflist), sizeof(*dma->bufs[0].buflist),
DRM_MEM_BUFS); DRM_MEM_BUFS);
...@@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev)
} }
if (dma->buflist) { if (dma->buflist) {
DRM(free)(dma->buflist, drm_free(dma->buflist,
dma->buf_count * sizeof(*dma->buflist), dma->buf_count * sizeof(*dma->buflist),
DRM_MEM_BUFS); DRM_MEM_BUFS);
} }
if (dma->pagelist) { if (dma->pagelist) {
DRM(free)(dma->pagelist, drm_free(dma->pagelist,
dma->page_count * sizeof(*dma->pagelist), dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES); 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; dev->dma = NULL;
} }
...@@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev)
* *
* Resets the fields of \p buf. * 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; if (!buf) return;
...@@ -154,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) ...@@ -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. * 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_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp ) ...@@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp )
if (dma->buflist[i]->filp == filp) { if (dma->buflist[i]->filp == filp) {
switch (dma->buflist[i]->list) { switch (dma->buflist[i]->list) {
case DRM_LIST_NONE: case DRM_LIST_NONE:
DRM(free_buffer)(dev, dma->buflist[i]); drm_free_buffer(dev, dma->buflist[i]);
break; break;
case DRM_LIST_WAIT: case DRM_LIST_WAIT:
dma->buflist[i]->list = DRM_LIST_RECLAIM; dma->buflist[i]->list = DRM_LIST_RECLAIM;
...@@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp ) ...@@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp )
} }
} }
} }
EXPORT_SYMBOL(drm_core_reclaim_buffers);
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "drmP.h" #include "drmP.h"
/** No-op. */ /** 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) unsigned int cmd, unsigned long arg)
{ {
drm_draw_t draw; drm_draw_t draw;
...@@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp, ...@@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp,
} }
/** No-op. */ /** 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) unsigned int cmd, unsigned long arg)
{ {
return 0; /* NOOP */ return 0; /* NOOP */
......
This diff is collapsed.
...@@ -49,18 +49,18 @@ ...@@ -49,18 +49,18 @@
* Creates and initializes a drm_file structure for the file private data in \p * 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. * 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); int minor = iminor(inode);
drm_file_t *priv; drm_file_t *priv;
int ret; int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL; if (!drm_cpu_valid()) return -EINVAL;
DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor); 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; if(!priv) return -ENOMEM;
memset(priv, 0, sizeof(*priv)); memset(priv, 0, sizeof(*priv));
...@@ -73,8 +73,8 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -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->authenticated = capable(CAP_SYS_ADMIN);
priv->lock_count = 0; priv->lock_count = 0;
if (dev->fn_tbl.open_helper) { if (dev->fn_tbl->open_helper) {
ret=dev->fn_tbl.open_helper(dev, priv); ret=dev->fn_tbl->open_helper(dev, priv);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
} }
...@@ -113,13 +113,13 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -113,13 +113,13 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
return 0; return 0;
out_free: out_free:
DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES); drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
filp->private_data=NULL; filp->private_data=NULL;
return ret; return ret;
} }
/** No-op. */ /** No-op. */
int DRM(flush)(struct file *filp) int drm_flush(struct file *filp)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -128,9 +128,10 @@ int DRM(flush)(struct file *filp) ...@@ -128,9 +128,10 @@ int DRM(flush)(struct file *filp)
current->pid, (long)old_encode_dev(dev->device), dev->open_count); current->pid, (long)old_encode_dev(dev->device), dev->open_count);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_flush);
/** No-op. */ /** 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_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -141,16 +142,17 @@ int DRM(fasync)(int fd, struct file *filp, int on) ...@@ -141,16 +142,17 @@ int DRM(fasync)(int fd, struct file *filp, int on)
if (retcode < 0) return retcode; if (retcode < 0) return retcode;
return 0; return 0;
} }
EXPORT_SYMBOL(drm_fasync);
/** No-op. */ /** 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; return 0;
} }
/** No-op. */ /** 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; return 0;
} }
...@@ -35,88 +35,12 @@ ...@@ -35,88 +35,12 @@
#include "drmP.h" #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. * Check whether DRI will run on this CPU.
* *
* \return non-zero if the DRI will run on this CPU, or zero otherwise. * \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 defined(__i386__)
if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
*/ */
#include "drmP.h" #include "drmP.h"
#include "drm_core.h"
#include "linux/pci.h" #include "linux/pci.h"
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
* *
* Copies the bus id from drm_device::unique into user space. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -82,7 +83,7 @@ int DRM(getunique)(struct inode *inode, struct file *filp, ...@@ -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 * in interface version 1.1 and will return EBUSY when setversion has requested
* version 1.1 or greater. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -98,19 +99,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -98,19 +99,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
if (!u.unique_len || u.unique_len > 1024) return -EINVAL; if (!u.unique_len || u.unique_len > 1024) return -EINVAL;
dev->unique_len = u.unique_len; 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(!dev->unique) return -ENOMEM;
if (copy_from_user(dev->unique, u.unique, dev->unique_len)) if (copy_from_user(dev->unique, u.unique, dev->unique_len))
return -EFAULT; return -EFAULT;
dev->unique[dev->unique_len] = '\0'; 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); DRM_MEM_DRIVER);
if (!dev->devname) if (!dev->devname)
return -ENOMEM; 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 /* Return error if the busid submitted doesn't match the device's actual
* busid. * busid.
...@@ -131,25 +132,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -131,25 +132,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
} }
static int static int
DRM(set_busid)(drm_device_t *dev) drm_set_busid(drm_device_t *dev)
{ {
if (dev->unique != NULL) if (dev->unique != NULL)
return EBUSY; return EBUSY;
dev->unique_len = 20; 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) if (dev->unique == NULL)
return ENOMEM; return ENOMEM;
snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); 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); DRM_MEM_DRIVER);
if (dev->devname == NULL) if (dev->devname == NULL)
return ENOMEM; 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; return 0;
} }
...@@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev) ...@@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev)
* Searches for the mapping with the specified offset and copies its information * Searches for the mapping with the specified offset and copies its information
* into userspace * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -228,7 +229,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp, ...@@ -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 * Searches for the client with the specified index and copies its information
* into userspace * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp, ...@@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp,
* *
* \return zero on success or a negative number on failure. * \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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp, ...@@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp,
return 0; return 0;
} }
#define DRM_IF_MAJOR 1 int drm_setversion(DRM_IOCTL_ARGS)
#define DRM_IF_MINOR 2
int DRM(setversion)(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_set_version_t sv; drm_set_version_t sv;
...@@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS) ...@@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
/* /*
* Version 1.1 includes tying of DRM to specific device * 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) ...@@ -342,8 +340,8 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR) sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL; return EINVAL;
if (dev->fn_tbl.set_version) if (dev->fn_tbl->set_version)
dev->fn_tbl.set_version(dev, &sv); dev->fn_tbl->set_version(dev, &sv);
} }
return 0; return 0;
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal * 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. * 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) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -86,10 +86,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, ...@@ -86,10 +86,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
* \param irq IRQ number. * \param irq IRQ number.
* *
* Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver * 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. * before and after the installation.
*/ */
int DRM(irq_install)( drm_device_t *dev ) int drm_irq_install( drm_device_t *dev )
{ {
int ret; int ret;
unsigned long sh_flags=0; unsigned long sh_flags=0;
...@@ -128,13 +128,13 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -128,13 +128,13 @@ int DRM(irq_install)( drm_device_t *dev )
} }
/* Before installing handler */ /* Before installing handler */
dev->fn_tbl.irq_preinstall(dev); dev->fn_tbl->irq_preinstall(dev);
/* Install handler */ /* Install handler */
if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
sh_flags = SA_SHIRQ; 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 ); sh_flags, dev->devname, dev );
if ( ret < 0 ) { if ( ret < 0 ) {
down( &dev->struct_sem ); down( &dev->struct_sem );
...@@ -144,7 +144,7 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -144,7 +144,7 @@ int DRM(irq_install)( drm_device_t *dev )
} }
/* After installing handler */ /* After installing handler */
dev->fn_tbl.irq_postinstall(dev); dev->fn_tbl->irq_postinstall(dev);
return 0; return 0;
} }
...@@ -154,9 +154,9 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -154,9 +154,9 @@ int DRM(irq_install)( drm_device_t *dev )
* *
* \param dev DRM device. * \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; int irq_enabled;
...@@ -173,12 +173,13 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -173,12 +173,13 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); 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 ); free_irq( dev->irq, dev );
return 0; return 0;
} }
EXPORT_SYMBOL(drm_irq_uninstall);
/** /**
* IRQ control ioctl. * IRQ control ioctl.
...@@ -191,7 +192,7 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -191,7 +192,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
* *
* Calls irq_install() or irq_uninstall() according to \p arg. * 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -210,11 +211,11 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -210,11 +211,11 @@ int DRM(control)( struct inode *inode, struct file *filp,
if (dev->if_version < DRM_IF_VERSION(1, 2) && if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq) ctl.irq != dev->irq)
return -EINVAL; return -EINVAL;
return DRM(irq_install)( dev ); return drm_irq_install( dev );
case DRM_UNINST_HANDLER: case DRM_UNINST_HANDLER:
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0; return 0;
return DRM(irq_uninstall)( dev ); return drm_irq_uninstall( dev );
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -239,7 +240,7 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -239,7 +240,7 @@ int DRM(control)( struct inode *inode, struct file *filp,
* *
* If a signal is not requested, then calls vblank_wait(). * 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_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -300,7 +301,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -300,7 +301,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); 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; return -ENOMEM;
} }
...@@ -316,8 +317,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -316,8 +317,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else { } else {
if (dev->fn_tbl.vblank_wait) if (dev->fn_tbl->vblank_wait)
ret = dev->fn_tbl.vblank_wait( dev, &vblwait.request.sequence ); ret = dev->fn_tbl->vblank_wait( dev, &vblwait.request.sequence );
do_gettimeofday( &now ); do_gettimeofday( &now );
vblwait.reply.tval_sec = now.tv_sec; vblwait.reply.tval_sec = now.tv_sec;
...@@ -339,7 +340,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -339,7 +340,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
* *
* If a signal is not requested, then calls vblank_wait(). * 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; struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig; drm_vbl_sig_t *vbl_sig;
...@@ -356,7 +357,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) ...@@ -356,7 +357,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del( list ); 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--; dev->vbl_pending--;
} }
...@@ -364,5 +365,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) ...@@ -364,5 +365,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags ); spin_unlock_irqrestore( &dev->vbl_lock, flags );
} }
EXPORT_SYMBOL(drm_vbl_send_signals);
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "drmP.h" #include "drmP.h"
/** No-op ioctl. */ /** 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) unsigned long arg)
{ {
DRM_DEBUG("\n"); DRM_DEBUG("\n");
...@@ -52,7 +52,7 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -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. * 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; unsigned int old, new, prev;
...@@ -90,7 +90,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) ...@@ -90,7 +90,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
* Resets the lock file pointer. * Resets the lock file pointer.
* Marks the lock as held by the given context, via the \p cmpxchg instruction. * 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) __volatile__ unsigned int *lock, unsigned int context)
{ {
unsigned int old, new, prev; unsigned int old, new, prev;
...@@ -115,7 +115,7 @@ int DRM(lock_transfer)(drm_device_t *dev, ...@@ -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 * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
* waiting on the lock queue. * 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) __volatile__ unsigned int *lock, unsigned int context)
{ {
unsigned int old, new, prev; unsigned int old, new, prev;
...@@ -147,7 +147,7 @@ int DRM(lock_free)(drm_device_t *dev, ...@@ -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 * \return one if the signal should be delivered normally, or zero if the
* signal should be blocked. * signal should be blocked.
*/ */
int DRM(notifier)(void *priv) int drm_notifier(void *priv)
{ {
drm_sigdata_t *s = (drm_sigdata_t *)priv; drm_sigdata_t *s = (drm_sigdata_t *)priv;
unsigned int old, new, prev; unsigned int old, new, prev;
......
...@@ -195,161 +195,3 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d ...@@ -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 @@ ...@@ -39,18 +39,18 @@
#include "drmP.h" #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); 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); 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); 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); 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); int request, int *eof, void *data);
#if DRM_DEBUG_CODE #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); int request, int *eof, void *data);
#endif #endif
...@@ -60,18 +60,18 @@ static int DRM(vma_info)(char *buf, char **start, off_t offset, ...@@ -60,18 +60,18 @@ static int DRM(vma_info)(char *buf, char **start, off_t offset,
struct drm_proc_list { struct drm_proc_list {
const char *name; /**< file name */ const char *name; /**< file name */
int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/ int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/
} DRM(proc_list)[] = { } drm_proc_list[] = {
{ "name", DRM(name_info) }, { "name", drm_name_info },
{ "mem", DRM(mem_info) }, { "mem", drm_mem_info },
{ "vm", DRM(vm_info) }, { "vm", drm_vm_info },
{ "clients", DRM(clients_info) }, { "clients", drm_clients_info },
{ "queues", DRM(queues_info) }, { "queues", drm_queues_info },
{ "bufs", DRM(bufs_info) }, { "bufs", drm_bufs_info },
#if DRM_DEBUG_CODE #if DRM_DEBUG_CODE
{ "vma", DRM(vma_info) }, { "vma", drm_vma_info },
#endif #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. * Initialize the DRI proc filesystem for a device.
...@@ -86,7 +86,7 @@ struct drm_proc_list { ...@@ -86,7 +86,7 @@ struct drm_proc_list {
* "/proc/dri/%minor%/", and each entry in proc_list as * "/proc/dri/%minor%/", and each entry in proc_list as
* "/proc/dri/%minor%/%name%". * "/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 *root,
struct proc_dir_entry **dev_root) struct proc_dir_entry **dev_root)
{ {
...@@ -102,18 +102,18 @@ int DRM(proc_init)(drm_device_t *dev, int minor, ...@@ -102,18 +102,18 @@ int DRM(proc_init)(drm_device_t *dev, int minor,
} }
for (i = 0; i < DRM_PROC_ENTRIES; i++) { 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); S_IFREG|S_IRUGO, *dev_root);
if (!ent) { if (!ent) {
DRM_ERROR("Cannot create /proc/dri/%s/%s\n", 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++) for (j = 0; j < i; j++)
remove_proc_entry(DRM(proc_list)[i].name, remove_proc_entry(drm_proc_list[i].name,
*dev_root); *dev_root);
remove_proc_entry(name, root); remove_proc_entry(name, root);
return -1; return -1;
} }
ent->read_proc = DRM(proc_list)[i].f; ent->read_proc = drm_proc_list[i].f;
ent->data = dev; ent->data = dev;
} }
...@@ -131,7 +131,7 @@ int DRM(proc_init)(drm_device_t *dev, int minor, ...@@ -131,7 +131,7 @@ int DRM(proc_init)(drm_device_t *dev, int minor,
* *
* Remove all proc entries created by proc_init(). * 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) struct proc_dir_entry *dev_root)
{ {
int i; int i;
...@@ -140,7 +140,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root, ...@@ -140,7 +140,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
if (!root || !dev_root) return 0; if (!root || !dev_root) return 0;
for (i = 0; i < DRM_PROC_ENTRIES; i++) 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); sprintf(name, "%d", minor);
remove_proc_entry(name, root); remove_proc_entry(name, root);
...@@ -160,7 +160,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *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. * 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -176,9 +176,9 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
if (dev->unique) { if (dev->unique) {
DRM_PROC_PRINT("%s 0x%lx %s\n", 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 { } 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; if (len > request + offset) return request;
...@@ -199,7 +199,7 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int 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. * 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -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. * 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)data; drm_device_t *dev = (drm_device_t *)data;
int ret; int ret;
down(&dev->struct_sem); 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); up(&dev->struct_sem);
return ret; return ret;
} }
...@@ -278,7 +278,7 @@ static int DRM(vm_info)(char *buf, char **start, off_t offset, int request, ...@@ -278,7 +278,7 @@ static int DRM(vm_info)(char *buf, char **start, off_t offset, int request,
* \param data private data. * \param data private data.
* \return number of written bytes. * \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) int request, int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -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. * 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)data; drm_device_t *dev = (drm_device_t *)data;
int ret; int ret;
down(&dev->struct_sem); 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); up(&dev->struct_sem);
return ret; return ret;
} }
...@@ -348,7 +348,7 @@ static int DRM(queues_info)(char *buf, char **start, off_t offset, int request, ...@@ -348,7 +348,7 @@ static int DRM(queues_info)(char *buf, char **start, off_t offset, int request,
* \param data private data. * \param data private data.
* \return number of written bytes. * \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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -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. * 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)data; drm_device_t *dev = (drm_device_t *)data;
int ret; int ret;
down(&dev->struct_sem); 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); up(&dev->struct_sem);
return ret; return ret;
} }
...@@ -418,7 +418,7 @@ static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request, ...@@ -418,7 +418,7 @@ static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request,
* \param data private data. * \param data private data.
* \return number of written bytes. * \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) int request, int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -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. * 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) int request, int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)data; drm_device_t *dev = (drm_device_t *)data;
int ret; int ret;
down(&dev->struct_sem); 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); up(&dev->struct_sem);
return ret; return ret;
} }
#if DRM_DEBUG_CODE #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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)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, ...@@ -523,14 +523,14 @@ static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request,
return len - offset; 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) int *eof, void *data)
{ {
drm_device_t *dev = (drm_device_t *)data; drm_device_t *dev = (drm_device_t *)data;
int ret; int ret;
down(&dev->struct_sem); 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); up(&dev->struct_sem);
return ret; return ret;
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#define DEBUG_SCATTER 0 #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; struct page *page;
int i; int i;
...@@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry ) ...@@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry )
vfree( entry->virtual ); vfree( entry->virtual );
DRM(free)( entry->busaddr, drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr), entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
if ( copy_from_user( &request, argp, sizeof(request) ) ) if ( copy_from_user( &request, argp, sizeof(request) ) )
return -EFAULT; return -EFAULT;
entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS ); entry = drm_alloc( sizeof(*entry), DRM_MEM_SGLISTS );
if ( !entry ) if ( !entry )
return -ENOMEM; return -ENOMEM;
...@@ -92,22 +92,22 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -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 ); DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
entry->pages = pages; entry->pages = pages;
entry->pagelist = DRM(alloc)( pages * sizeof(*entry->pagelist), entry->pagelist = drm_alloc( pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
if ( !entry->pagelist ) { if ( !entry->pagelist ) {
DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS ); drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
} }
memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); 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 ); DRM_MEM_PAGES );
if ( !entry->busaddr ) { if ( !entry->busaddr ) {
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
...@@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
entry->virtual = vmalloc_32( pages << PAGE_SHIFT ); entry->virtual = vmalloc_32( pages << PAGE_SHIFT );
if ( !entry->virtual ) { if ( !entry->virtual ) {
DRM(free)( entry->busaddr, drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr), entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
...@@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
request.handle = entry->handle; request.handle = entry->handle;
if ( copy_to_user( argp, &request, sizeof(request) ) ) { if ( copy_to_user( argp, &request, sizeof(request) ) ) {
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return -EFAULT; return -EFAULT;
} }
...@@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
return 0; return 0;
failed: failed:
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return -ENOMEM; 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 ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp, ...@@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
DRM_DEBUG( "sg free virtual = %p\n", entry->virtual ); DRM_DEBUG( "sg free virtual = %p\n", entry->virtual );
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return 0; return 0;
} }
...@@ -31,21 +31,27 @@ ...@@ -31,21 +31,27 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include <linux/module.h>
#include <linux/moduleparam.h>
#include "drmP.h" #include "drmP.h"
#include "drm_core.h"
static unsigned int cards_limit = 16; /* Enough for one machine */ unsigned int drm_cards_limit = 16; /* Enough for one machine */
static unsigned int debug = 0; /* 1 to enable debug output */ unsigned int drm_debug = 0; /* 1 to enable debug output */
EXPORT_SYMBOL(drm_debug);
MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL and additional rights"); MODULE_LICENSE("GPL and additional rights");
MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards"); MODULE_PARM_DESC(drm_cards_limit, "Maximum number of graphics cards");
MODULE_PARM_DESC(debug, "Enable debug output"); MODULE_PARM_DESC(drm_debug, "Enable debug output");
module_param(cards_limit, int, 0444); module_param_named(cards_limit, drm_cards_limit, int, 0444);
module_param(debug, int, 0666); 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. * File \c open operation.
...@@ -65,10 +71,10 @@ static int stub_open(struct inode *inode, struct file *filp) ...@@ -65,10 +71,10 @@ static int stub_open(struct inode *inode, struct file *filp)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (!((minor >= 0) && (minor < DRM(global)->cards_limit))) if (!((minor >= 0) && (minor < drm_cards_limit)))
return -ENODEV; return -ENODEV;
dev = DRM(global)->minors[minor].dev; dev = drm_minors[minor].dev;
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
...@@ -84,7 +90,7 @@ static int stub_open(struct inode *inode, struct file *filp) ...@@ -84,7 +90,7 @@ static int stub_open(struct inode *inode, struct file *filp)
} }
/** File operations structure */ /** File operations structure */
static struct file_operations DRM(stub_fops) = { struct file_operations drm_stub_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = stub_open .open = stub_open
}; };
...@@ -94,43 +100,44 @@ static struct file_operations DRM(stub_fops) = { ...@@ -94,43 +100,44 @@ static struct file_operations DRM(stub_fops) = {
* *
* \param pdev PCI device structure * \param pdev PCI device structure
* \param ent entry from the PCI ID table with device type flags * \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 * Attempt to gets inter module "drm" information. If we are first
* create the proc init entry via proc_init(). * 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; struct class_device *dev_class;
drm_device_t *dev; drm_device_t *dev;
int ret; int ret;
int minor; int minor;
drm_minor_t *minors = &DRM(global)->minors[0]; drm_minor_t *minors = &drm_minors[0];
DRM_DEBUG("\n"); 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) { if (minors->type == DRM_MINOR_FREE) {
DRM_DEBUG("assigning minor %d\n", minor); 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) if (!dev)
return -ENOMEM; return -ENOMEM;
*minors = (drm_minor_t){.dev = dev, .type=DRM_MINOR_PRIMARY}; *minors = (drm_minor_t){.dev = dev, .type=DRM_MINOR_PRIMARY};
dev->minor = minor; 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"); printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
goto err_g1; 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"); printk (KERN_ERR "DRM: Failed to initialize /proc/dri.\n");
goto err_g1; goto err_g1;
} }
pci_enable_device(pdev); 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); MKDEV(DRM_MAJOR, minor), &pdev->dev, "card%d", minor);
if (IS_ERR(dev_class)) { if (IS_ERR(dev_class)) {
printk(KERN_ERR "DRM: Error class_simple_device_add.\n"); 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) ...@@ -145,12 +152,13 @@ static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent)
DRM_ERROR("out of minors\n"); DRM_ERROR("out of minors\n");
return -ENOMEM; return -ENOMEM;
err_g2: 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: err_g1:
*minors = (drm_minor_t){.dev = NULL, .type = DRM_MINOR_FREE}; *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; return ret;
} }
EXPORT_SYMBOL(drm_probe);
/** /**
...@@ -163,112 +171,18 @@ static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -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 * "drm" data, otherwise unregisters the "drm" data, frees the stub list and
* unregisters the character device. * 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]; drm_minor_t *minors = &drm_minors[dev->minor];
int i;
DRM_DEBUG("release minor %d\n", 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)); class_simple_device_remove(MKDEV(DRM_MAJOR, dev->minor));
*minors = (drm_minor_t){.dev = NULL, .type = DRM_MINOR_FREE}; *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; 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;
}
This diff is collapsed.
...@@ -210,9 +210,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp, ...@@ -210,9 +210,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr; 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. * which drm_drv.h declares.
*/ */
static int ffb_presetup(drm_device_t *dev) static int ffb_presetup(drm_device_t *dev)
...@@ -227,13 +225,13 @@ static int ffb_presetup(drm_device_t *dev) ...@@ -227,13 +225,13 @@ static int ffb_presetup(drm_device_t *dev)
return -ENODEV; return -ENODEV;
/* Find our instance number by finding our device in dev structure */ /* Find our instance number by finding our device in dev structure */
for (i = 0; i < DRM(numdevs); i++) { for (i = 0; i < drm_numdevs; i++) {
temp_dev = &(DRM(device)[i]); temp_dev = &(drm_device[i]);
if(temp_dev == dev) if(temp_dev == dev)
break; break;
} }
if (i == DRM(numdevs)) if (i == drm_numdevs)
return -ENODEV; return -ENODEV;
ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL); ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
* *
*/ */
#include "i810.h"
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i810_drm.h" #include "i810_drm.h"
...@@ -110,12 +109,12 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) ...@@ -110,12 +109,12 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
} }
static struct file_operations i810_buffer_fops = { static struct file_operations i810_buffer_fops = {
.open = DRM(open), .open = drm_open,
.flush = DRM(flush), .flush = drm_flush,
.release = DRM(release), .release = drm_release,
.ioctl = DRM(ioctl), .ioctl = drm_ioctl,
.mmap = i810_mmap_buffers, .mmap = i810_mmap_buffers,
.fasync = DRM(fasync), .fasync = drm_fasync,
}; };
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
...@@ -237,7 +236,7 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -237,7 +236,7 @@ int i810_dma_cleanup(drm_device_t *dev)
* is freed, it's too late. * is freed, it's too late.
*/ */
if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled) if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled)
DRM(irq_uninstall)(dev); drm_irq_uninstall(dev);
if (dev->dev_private) { if (dev->dev_private) {
int i; int i;
...@@ -245,7 +244,7 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -245,7 +244,7 @@ int i810_dma_cleanup(drm_device_t *dev)
(drm_i810_private_t *) dev->dev_private; (drm_i810_private_t *) dev->dev_private;
if (dev_priv->ring.virtual_start) { 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); dev_priv->ring.Size, dev);
} }
if (dev_priv->hw_status_page) { if (dev_priv->hw_status_page) {
...@@ -255,7 +254,7 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -255,7 +254,7 @@ int i810_dma_cleanup(drm_device_t *dev)
/* Need to rewrite hardware status page */ /* Need to rewrite hardware status page */
I810_WRITE(0x02080, 0x1ffff000); 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); DRM_MEM_DRIVER);
dev->dev_private = NULL; dev->dev_private = NULL;
...@@ -263,7 +262,7 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -263,7 +262,7 @@ int i810_dma_cleanup(drm_device_t *dev)
drm_buf_t *buf = dma->buflist[ i ]; drm_buf_t *buf = dma->buflist[ i ];
drm_i810_buf_priv_t *buf_priv = buf->dev_private; drm_i810_buf_priv_t *buf_priv = buf->dev_private;
if ( buf_priv->kernel_virtual && buf->total ) 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; return 0;
...@@ -334,7 +333,7 @@ static int i810_freelist_init(drm_device_t *dev, drm_i810_private_t *dev_priv) ...@@ -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->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); buf->total, dev);
} }
return 0; return 0;
...@@ -386,7 +385,7 @@ static int i810_dma_initialize(drm_device_t *dev, ...@@ -386,7 +385,7 @@ static int i810_dma_initialize(drm_device_t *dev,
dev_priv->ring.End = init->ring_end; dev_priv->ring.End = init->ring_end;
dev_priv->ring.Size = init->ring_size; 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_start,
init->ring_size, dev); init->ring_size, dev);
...@@ -510,7 +509,7 @@ int i810_dma_init(struct inode *inode, struct file *filp, ...@@ -510,7 +509,7 @@ int i810_dma_init(struct inode *inode, struct file *filp,
if (retcode) if (retcode)
return retcode; return retcode;
dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), dev_priv = drm_alloc(sizeof(drm_i810_private_t),
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -524,7 +523,7 @@ int i810_dma_init(struct inode *inode, struct file *filp, ...@@ -524,7 +523,7 @@ int i810_dma_init(struct inode *inode, struct file *filp,
sizeof(drm_i810_init_t))) { sizeof(drm_i810_init_t))) {
return -EFAULT; return -EFAULT;
} }
dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), dev_priv = drm_alloc(sizeof(drm_i810_private_t),
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1388,35 +1387,20 @@ int i810_flip_bufs(struct inode *inode, struct file *filp, ...@@ -1388,35 +1387,20 @@ int i810_flip_bufs(struct inode *inode, struct file *filp,
return 0; return 0;
} }
static void i810_driver_pretakedown(drm_device_t *dev) void i810_driver_pretakedown(drm_device_t *dev)
{ {
i810_dma_cleanup( 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); 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 ); i810_dma_quiescent( dev );
return 0; 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 { ...@@ -199,21 +199,37 @@ typedef struct _drm_i810_sarea {
/* i810 specific ioctls /* i810 specific ioctls
* The device specific ioctl range is 0x40 to 0x79. * The device specific ioctl range is 0x40 to 0x79.
*/ */
#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t) #define DRM_I810_INIT 0x00
#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t) #define DRM_I810_VERTEX 0x01
#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t) #define DRM_I810_CLEAR 0x02
#define DRM_IOCTL_I810_FLUSH DRM_IO( 0x43) #define DRM_I810_FLUSH 0x03
#define DRM_IOCTL_I810_GETAGE DRM_IO( 0x44) #define DRM_I810_GETAGE 0x04
#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t) #define DRM_I810_GETBUF 0x05
#define DRM_IOCTL_I810_SWAP DRM_IO( 0x46) #define DRM_I810_SWAP 0x06
#define DRM_IOCTL_I810_COPY DRM_IOW( 0x47, drm_i810_copy_t) #define DRM_I810_COPY 0x07
#define DRM_IOCTL_I810_DOCOPY DRM_IO( 0x48) #define DRM_I810_DOCOPY 0x08
#define DRM_IOCTL_I810_OV0INFO DRM_IOR( 0x49, drm_i810_overlay_t) #define DRM_I810_OV0INFO 0x09
#define DRM_IOCTL_I810_FSTATUS DRM_IO ( 0x4a) #define DRM_I810_FSTATUS 0x0a
#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( 0x4b) #define DRM_I810_OV0FLIP 0x0b
#define DRM_IOCTL_I810_MC DRM_IOW( 0x4c, drm_i810_mc_t) #define DRM_I810_MC 0x0c
#define DRM_IOCTL_I810_RSTATUS DRM_IO ( 0x4d ) #define DRM_I810_RSTATUS 0x0d
#define DRM_IOCTL_I810_FLIP DRM_IO ( 0x4e ) #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 { typedef struct _drm_i810_clear {
int clear_color; int clear_color;
......
...@@ -31,10 +31,101 @@ ...@@ -31,10 +31,101 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include "i810.h"
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i810_drm.h" #include "i810_drm.h"
#include "i810_drv.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 @@ ...@@ -32,6 +32,29 @@
#ifndef _I810_DRV_H_ #ifndef _I810_DRV_H_
#define _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 { typedef struct drm_i810_buf_priv {
u32 *in_use; u32 *in_use;
int my_use_idx; int my_use_idx;
...@@ -127,18 +150,22 @@ extern int i810_dma_mc(struct inode *inode, struct file *filp, ...@@ -127,18 +150,22 @@ extern int i810_dma_mc(struct inode *inode, struct file *filp,
extern void i810_dma_quiescent(drm_device_t *dev); 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); 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); 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); 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); 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) \ #define I810_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle) dev_priv->mmio_map->handle)
#define I810_ADDR(reg) (I810_BASE(reg) + reg) #define I810_ADDR(reg) (I810_BASE(reg) + reg)
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
* *
*/ */
#include "i830.h"
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i830_drm.h" #include "i830_drm.h"
...@@ -111,12 +110,12 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf) ...@@ -111,12 +110,12 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
} }
static struct file_operations i830_buffer_fops = { static struct file_operations i830_buffer_fops = {
.open = DRM(open), .open = drm_open,
.flush = DRM(flush), .flush = drm_flush,
.release = DRM(release), .release = drm_release,
.ioctl = DRM(ioctl), .ioctl = drm_ioctl,
.mmap = i830_mmap_buffers, .mmap = i830_mmap_buffers,
.fasync = DRM(fasync), .fasync = drm_fasync,
}; };
int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma) int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
...@@ -237,7 +236,7 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -237,7 +236,7 @@ int i830_dma_cleanup(drm_device_t *dev)
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * 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) { if (dev->dev_private) {
int i; int i;
...@@ -245,7 +244,7 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -245,7 +244,7 @@ int i830_dma_cleanup(drm_device_t *dev)
(drm_i830_private_t *) dev->dev_private; (drm_i830_private_t *) dev->dev_private;
if (dev_priv->ring.virtual_start) { 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); dev_priv->ring.Size, dev);
} }
if (dev_priv->hw_status_page) { if (dev_priv->hw_status_page) {
...@@ -256,7 +255,7 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -256,7 +255,7 @@ int i830_dma_cleanup(drm_device_t *dev)
I830_WRITE(0x02080, 0x1ffff000); 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); DRM_MEM_DRIVER);
dev->dev_private = NULL; dev->dev_private = NULL;
...@@ -264,7 +263,7 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -264,7 +263,7 @@ int i830_dma_cleanup(drm_device_t *dev)
drm_buf_t *buf = dma->buflist[ i ]; drm_buf_t *buf = dma->buflist[ i ];
drm_i830_buf_priv_t *buf_priv = buf->dev_private; drm_i830_buf_priv_t *buf_priv = buf->dev_private;
if ( buf_priv->kernel_virtual && buf->total ) 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; return 0;
...@@ -339,7 +338,7 @@ static int i830_freelist_init(drm_device_t *dev, drm_i830_private_t *dev_priv) ...@@ -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->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); buf->total, dev);
} }
return 0; return 0;
...@@ -392,7 +391,7 @@ static int i830_dma_initialize(drm_device_t *dev, ...@@ -392,7 +391,7 @@ static int i830_dma_initialize(drm_device_t *dev,
dev_priv->ring.End = init->ring_end; dev_priv->ring.End = init->ring_end;
dev_priv->ring.Size = init->ring_size; 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_start,
init->ring_size, dev); init->ring_size, dev);
...@@ -475,7 +474,7 @@ int i830_dma_init(struct inode *inode, struct file *filp, ...@@ -475,7 +474,7 @@ int i830_dma_init(struct inode *inode, struct file *filp,
switch(init.func) { switch(init.func) {
case I830_INIT_DMA: 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); DRM_MEM_DRIVER);
if(dev_priv == NULL) return -ENOMEM; if(dev_priv == NULL) return -ENOMEM;
retcode = i830_dma_initialize(dev, dev_priv, &init); retcode = i830_dma_initialize(dev, dev_priv, &init);
...@@ -1582,43 +1581,19 @@ int i830_setparam( struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -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 ); 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); 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 ); i830_dma_quiescent( dev );
return 0; 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 { ...@@ -251,20 +251,35 @@ typedef struct _drm_i830_sarea {
/* I830 specific ioctls /* I830 specific ioctls
* The device specific ioctl range is 0x40 to 0x79. * The device specific ioctl range is 0x40 to 0x79.
*/ */
#define DRM_IOCTL_I830_INIT DRM_IOW( 0x40, drm_i830_init_t) #define DRM_I830_INIT 0x00
#define DRM_IOCTL_I830_VERTEX DRM_IOW( 0x41, drm_i830_vertex_t) #define DRM_I830_VERTEX 0x01
#define DRM_IOCTL_I830_CLEAR DRM_IOW( 0x42, drm_i830_clear_t) #define DRM_I830_CLEAR 0x02
#define DRM_IOCTL_I830_FLUSH DRM_IO ( 0x43) #define DRM_I830_FLUSH 0x03
#define DRM_IOCTL_I830_GETAGE DRM_IO ( 0x44) #define DRM_I830_GETAGE 0x04
#define DRM_IOCTL_I830_GETBUF DRM_IOWR(0x45, drm_i830_dma_t) #define DRM_I830_GETBUF 0x05
#define DRM_IOCTL_I830_SWAP DRM_IO ( 0x46) #define DRM_I830_SWAP 0x06
#define DRM_IOCTL_I830_COPY DRM_IOW( 0x47, drm_i830_copy_t) #define DRM_I830_COPY 0x07
#define DRM_IOCTL_I830_DOCOPY DRM_IO ( 0x48) #define DRM_I830_DOCOPY 0x08
#define DRM_IOCTL_I830_FLIP DRM_IO ( 0x49) #define DRM_I830_FLIP 0x09
#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(0x4a, drm_i830_irq_emit_t) #define DRM_I830_IRQ_EMIT 0x0a
#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( 0x4b, drm_i830_irq_wait_t) #define DRM_I830_IRQ_WAIT 0x0b
#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(0x4c, drm_i830_getparam_t) #define DRM_I830_GETPARAM 0x0c
#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(0x4d, drm_i830_setparam_t) #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 { typedef struct _drm_i830_clear {
int clear_color; int clear_color;
......
...@@ -33,10 +33,109 @@ ...@@ -33,10 +33,109 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include "i830.h"
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i830_drm.h" #include "i830_drm.h"
#include "i830_drv.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 @@ ...@@ -32,6 +32,36 @@
#ifndef _I830_DRV_H_ #ifndef _I830_DRV_H_
#define _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 { typedef struct drm_i830_buf_priv {
u32 *in_use; u32 *in_use;
int my_use_idx; int my_use_idx;
...@@ -140,6 +170,9 @@ extern irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS ); ...@@ -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_preinstall( drm_device_t *dev );
extern void i830_driver_irq_postinstall( 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_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) \ #define I830_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle) dev_priv->mmio_map->handle)
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* *
*/ */
#include "i830.h"
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i830_drm.h" #include "i830_drm.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,6 +10,28 @@ ...@@ -10,6 +10,28 @@
#ifndef _I915_DRV_H_ #ifndef _I915_DRV_H_
#define _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 { typedef struct _drm_i915_ring_buffer {
int tail_mask; int tail_mask;
unsigned long Start; unsigned long Start;
...@@ -66,6 +88,8 @@ extern int i915_getparam(DRM_IOCTL_ARGS); ...@@ -66,6 +88,8 @@ extern int i915_getparam(DRM_IOCTL_ARGS);
extern int i915_setparam(DRM_IOCTL_ARGS); extern int i915_setparam(DRM_IOCTL_ARGS);
extern int i915_cmdbuffer(DRM_IOCTL_ARGS); extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
extern void i915_kernel_lost_context(drm_device_t * dev); 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 */ /* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS); extern int i915_irq_emit(DRM_IOCTL_ARGS);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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