diff options
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 9 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_agpsupport.c | 132 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_auth.c | 37 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_bufs.c | 158 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_context.c | 56 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_dma.c | 35 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_drawable.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_drv.c | 160 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_fops.c | 30 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_ioctl.c | 49 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_irq.c | 43 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_lock.c | 25 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_memory.c | 32 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_scatter.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_sysctl.c | 18 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_vm.c | 25 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_drv.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_drv.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/sis_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/tdfx_drv.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/drm/via_drv.c | 12 |
25 files changed, 538 insertions, 409 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index a11452f9721..c3f1f5f2ce4 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -278,6 +278,7 @@ extern drm_device_t *drm_units[]; #define aprint_error printf #define aprint_normal printf #define printk printf +#define __unused /* nothing */ /* * cdev_decl() doesn't like underscore separated names. * doing this here is easier that ifdefing each of them. @@ -292,7 +293,7 @@ extern drm_device_t *drm_units[]; #endif /* __NetBSD__ */ #endif /* __NetBSD__ || __OpenBSD__ */ #define DRM_SPINLOCK_IRQSAVE(l, irqflags) do { \ - DRM_SPINLOCK(l); \ + DRM_SPINLOCK(l); \ (void)irqflags; \ } while (0) #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) DRM_SPINUNLOCK(u) @@ -320,9 +321,9 @@ enum { #elif defined(__NetBSD__) #define drm_get_device_from_kdev(_kdev) device_lookup(&drm_cd, minor(_kdev)) #elif defined(__OpenBSD__) -#define drm_get_device_from_kdev(_kdev) \ - (drm_device_t *)(minor(kdev) < DRM_MAXUNITS) ? \ - drm_units[minor(kdev)] : NULL +#define drm_get_device_from_kdev(_kdev) \ + (minor(kdev) < DRM_MAXUNITS) ? \ + drm_units[minor(kdev)] : NULL #endif #ifdef __FreeBSD__ diff --git a/sys/dev/pci/drm/drm_agpsupport.c b/sys/dev/pci/drm/drm_agpsupport.c index eb964905f0e..ac88123efd7 100644 --- a/sys/dev/pci/drm/drm_agpsupport.c +++ b/sys/dev/pci/drm/drm_agpsupport.c @@ -40,8 +40,11 @@ #include <dev/pci/pcireg.h> #endif +int drm_device_find_capability(drm_device_t *, int); +drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t *, void *); + /* Returns 1 if AGP or 0 if not. */ -static int +int drm_device_find_capability(drm_device_t *dev, int cap) { #ifdef __FreeBSD__ @@ -64,8 +67,7 @@ drm_device_find_capability(drm_device_t *dev, int cap) * Traverse the capabilities list. */ for (ptr = pci_read_config(dev->device, AGP_CAPPTR, 1); - ptr != 0; - ptr = next) { + ptr != 0; ptr = next) { u_int32_t capid = pci_read_config(dev->device, ptr, 4); next = AGP_CAPID_GET_NEXT_PTR(capid); @@ -81,14 +83,15 @@ drm_device_find_capability(drm_device_t *dev, int cap) #else #if defined(__NetBSD__) || defined (__OpenBSD__) return pci_get_capability(dev->pa.pa_pc, dev->pa.pa_tag, cap, - NULL, NULL); + NULL, NULL); #endif /* XXX: fill me in for non-FreeBSD */ return 1; #endif } -int drm_device_is_agp(drm_device_t *dev) +int +drm_device_is_agp(drm_device_t *dev) { if (dev->driver.device_is_agp != NULL) { int ret; @@ -104,12 +107,14 @@ int drm_device_is_agp(drm_device_t *dev) return (drm_device_find_capability(dev, PCIY_AGP)); } -int drm_device_is_pcie(drm_device_t *dev) +int +drm_device_is_pcie(drm_device_t *dev) { return (drm_device_find_capability(dev, PCIY_EXPRESS)); } -int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info) +int +drm_agp_info(drm_device_t * dev, drm_agp_info_t *info) { struct agp_info *kern; @@ -133,7 +138,8 @@ int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info) return 0; } -int drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { int err; drm_agp_info_t info; @@ -146,12 +152,14 @@ int drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv return 0; } -int drm_agp_acquire_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_acquire_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { return drm_agp_acquire(dev); } -int drm_agp_acquire(drm_device_t *dev) +int +drm_agp_acquire(drm_device_t *dev) { #ifndef DRM_NO_AGP int retcode; @@ -168,12 +176,14 @@ int drm_agp_acquire(drm_device_t *dev) return 0; } -int drm_agp_release_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_release_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { return drm_agp_release(dev); } -int drm_agp_release(drm_device_t * dev) +int +drm_agp_release(drm_device_t * dev) { #ifndef DRM_NO_AGP if (!dev->agp || !dev->agp->acquired) @@ -184,36 +194,39 @@ int drm_agp_release(drm_device_t * dev) return 0; } -int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode) +int +drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode) { #ifndef DRM_NO_AGP if (!dev->agp || !dev->agp->acquired) return EINVAL; - dev->agp->mode = mode.mode; + dev->agp->mode = mode.mode; agp_enable(dev->agp->agpdev, mode.mode); dev->agp->enabled = 1; #endif return 0; } -int drm_agp_enable_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_enable_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_agp_mode_t mode; - mode = *(drm_agp_mode_t *) data; + mode = *(drm_agp_mode_t *)data; return drm_agp_enable(dev, mode); } -int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) +int +drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) { #ifndef DRM_NO_AGP - drm_agp_mem_t *entry; - void *handle; - unsigned long pages; - u_int32_t type; + drm_agp_mem_t *entry; + void *handle; + unsigned long pages; + u_int32_t type; struct agp_memory_info info; if (!dev->agp || !dev->agp->acquired) @@ -234,41 +247,43 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) return ENOMEM; } - entry->handle = handle; - entry->bound = 0; - entry->pages = pages; - entry->prev = NULL; - entry->next = dev->agp->memory; + entry->handle = handle; + entry->bound = 0; + entry->pages = pages; + entry->prev = NULL; + entry->next = dev->agp->memory; if (dev->agp->memory) dev->agp->memory->prev = entry; dev->agp->memory = entry; agp_memory_info(dev->agp->agpdev, entry->handle, &info); - request->handle = (unsigned long) entry->handle; + request->handle = (unsigned long)entry->handle; request->physical = info.ami_physical; #endif return 0; } -int drm_agp_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_agp_buffer_t request; int retcode; - request = *(drm_agp_buffer_t *) data; + request = *(drm_agp_buffer_t *)data; DRM_LOCK(); retcode = drm_agp_alloc(dev, &request); DRM_UNLOCK(); - *(drm_agp_buffer_t *) data = request; + *(drm_agp_buffer_t *)data = request; return retcode; } -static drm_agp_mem_t * drm_agp_lookup_entry(drm_device_t *dev, void *handle) +drm_agp_mem_t * +drm_agp_lookup_entry(drm_device_t *dev, void *handle) { drm_agp_mem_t *entry; @@ -278,9 +293,10 @@ static drm_agp_mem_t * drm_agp_lookup_entry(drm_device_t *dev, void *handle) return NULL; } -int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request) +int +drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request) { - drm_agp_mem_t *entry; + drm_agp_mem_t *entry; int retcode; if (!dev->agp || !dev->agp->acquired) @@ -300,12 +316,13 @@ int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request) return retcode; } -int drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_agp_binding_t request; int retcode; - request = *(drm_agp_binding_t *) data; + request = *(drm_agp_binding_t *)data; DRM_LOCK(); retcode = drm_agp_unbind(dev, &request); @@ -314,11 +331,12 @@ int drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_pr return retcode; } -int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request) +int +drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request) { - drm_agp_mem_t *entry; - int retcode; - int page; + drm_agp_mem_t *entry; + int retcode; + int page; if (!dev->agp || !dev->agp->acquired) return EINVAL; @@ -340,12 +358,13 @@ int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request) return retcode; } -int drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_agp_binding_t request; int retcode; - request = *(drm_agp_binding_t *) data; + request = *(drm_agp_binding_t *)data; DRM_LOCK(); retcode = drm_agp_bind(dev, &request); @@ -354,9 +373,10 @@ int drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv return retcode; } -int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) +int +drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) { - drm_agp_mem_t *entry; + drm_agp_mem_t *entry; if (!dev->agp || !dev->agp->acquired) return EINVAL; @@ -384,7 +404,8 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) } -int drm_agp_free_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_agp_free_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_agp_buffer_t request; int retcode; @@ -398,11 +419,12 @@ int drm_agp_free_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv return retcode; } -drm_agp_head_t *drm_agp_init(void) +drm_agp_head_t * +drm_agp_init(void) { device_t agpdev; - drm_agp_head_t *head = NULL; - int agp_available = 1; + drm_agp_head_t *head = NULL; + int agp_available = 1; agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev) @@ -421,13 +443,14 @@ drm_agp_head_t *drm_agp_init(void) head->base = head->info.ai_aperture_base; head->memory = NULL; DRM_INFO("AGP at 0x%08lx %dMB\n", - (long)head->info.ai_aperture_base, - (int)(head->info.ai_aperture_size >> 20)); + (long)head->info.ai_aperture_base, + (int)(head->info.ai_aperture_size >> 20)); } return head; } -void *drm_agp_allocate_memory(size_t pages, u32 type) +void * +drm_agp_allocate_memory(size_t pages, u32 type) { device_t agpdev; @@ -438,7 +461,8 @@ void *drm_agp_allocate_memory(size_t pages, u32 type) return agp_alloc_memory(agpdev, type, pages << AGP_PAGE_SHIFT); } -int drm_agp_free_memory(void *handle) +int +drm_agp_free_memory(void *handle) { device_t agpdev; @@ -450,7 +474,8 @@ int drm_agp_free_memory(void *handle) return 1; } -int drm_agp_bind_memory(void *handle, off_t start) +int +drm_agp_bind_memory(void *handle, off_t start) { #ifndef DRM_NO_AGP device_t agpdev; @@ -465,7 +490,8 @@ int drm_agp_bind_memory(void *handle, off_t start) #endif } -int drm_agp_unbind_memory(void *handle) +int +drm_agp_unbind_memory(void *handle) { #ifndef DRM_NO_AGP device_t agpdev; diff --git a/sys/dev/pci/drm/drm_auth.c b/sys/dev/pci/drm/drm_auth.c index fdc2d777160..0994df60ba6 100644 --- a/sys/dev/pci/drm/drm_auth.c +++ b/sys/dev/pci/drm/drm_auth.c @@ -35,7 +35,13 @@ #include "drmP.h" -static int drm_hash_magic(drm_magic_t magic) +int drm_hash_magic(drm_magic_t); +drm_file_t *drm_find_file(drm_device_t *, drm_magic_t); +int drm_add_magic(drm_device_t *, drm_file_t *, drm_magic_t); +int drm_remove_magic(drm_device_t *, drm_magic_t); + +int +drm_hash_magic(drm_magic_t magic) { return magic & (DRM_HASH_SIZE-1); } @@ -43,10 +49,13 @@ static int drm_hash_magic(drm_magic_t magic) /** * Returns the file private associated with the given magic number. */ -static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) +drm_file_t * +drm_find_file(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *pt; - int hash = drm_hash_magic(magic); + int hash; + + hash = drm_hash_magic(magic); DRM_SPINLOCK_ASSERT(&dev->dev_lock); @@ -63,9 +72,10 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) * Inserts the given magic number into the hash table of used magic number * lists. */ -static 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_DEBUG("%d\n", magic); @@ -81,10 +91,10 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) if (dev->magiclist[hash].tail) { dev->magiclist[hash].tail->next = entry; - dev->magiclist[hash].tail = entry; + dev->magiclist[hash].tail = entry; } else { - dev->magiclist[hash].head = entry; - dev->magiclist[hash].tail = entry; + dev->magiclist[hash].head = entry; + dev->magiclist[hash].tail = entry; } return 0; @@ -94,11 +104,12 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) * Removes the given magic number from the hash table of used magic number * lists. */ -static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) +int +drm_remove_magic(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *prev = NULL; drm_magic_entry_t *pt; - int hash; + int hash; DRM_SPINLOCK_ASSERT(&dev->dev_lock); @@ -132,7 +143,8 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) * connection that the magic is passed over) to determine if the magic number * should be authenticated. */ -int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) { static drm_magic_t sequence = 0; drm_auth_t *auth = data; @@ -163,7 +175,8 @@ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) /** * Marks the client associated with the given magic number as authenticated. */ -int drm_authmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_authmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_auth_t *auth = data; drm_file_t *priv; diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c index 1ae799c68ca..258962091cc 100644 --- a/sys/dev/pci/drm/drm_bufs.c +++ b/sys/dev/pci/drm/drm_bufs.c @@ -37,10 +37,17 @@ #include "drmP.h" +int drm_alloc_resource(drm_device_t *, int); +void drm_cleanup_buf_error(drm_device_t *, drm_buf_entry_t *); +int drm_do_addbufs_agp(drm_device_t *, drm_buf_desc_t *); +int drm_do_addbufs_pci(drm_device_t *, drm_buf_desc_t *); +int drm_do_addbufs_sg(drm_device_t *, drm_buf_desc_t *); + /* * Compute order. Can be made faster. */ -int drm_order(unsigned long size) +int +drm_order(unsigned long size) { int order; unsigned long tmp; @@ -57,7 +64,8 @@ int drm_order(unsigned long size) * drm_get_resource_*. Note that they are not RF_ACTIVE, so there's no virtual * address for accessing them. Cleaned up at unload. */ -static int drm_alloc_resource(drm_device_t *dev, int resource) +int +drm_alloc_resource(drm_device_t *dev, int resource) { #ifdef __OpenBSD__ #define PCIR_BAR(x) (PCI_MAPS + (x) * 4) @@ -92,13 +100,13 @@ static int drm_alloc_resource(drm_device_t *dev, int resource) } dev->pcir[resource]->maptype = pci_mapreg_type(dev->pa.pa_pc, dev->pa.pa_tag, - dev->pcirid[resource]); + dev->pcirid[resource]); if(pci_mapreg_info(dev->pa.pa_pc, dev->pa.pa_tag, - dev->pcirid[resource], - dev->pcir[resource]->maptype, - &(dev->pcir[resource]->base), - &(dev->pcir[resource]->size), - &(dev->pcir[resource]->flags))) { + dev->pcirid[resource], + dev->pcir[resource]->maptype, + &(dev->pcir[resource]->base), + &(dev->pcir[resource]->size), + &(dev->pcir[resource]->flags))) { dev->pcir[resource]->base = 0; dev->pcir[resource]->size = 0; } @@ -111,7 +119,8 @@ static int drm_alloc_resource(drm_device_t *dev, int resource) } -unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource) +unsigned long +drm_get_resource_start(drm_device_t *dev, unsigned int resource) { if (drm_alloc_resource(dev, resource) != 0) return 0; @@ -123,7 +132,8 @@ unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource) #endif } -unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource) +unsigned long +drm_get_resource_len(drm_device_t *dev, unsigned int resource) { if (drm_alloc_resource(dev, resource) != 0) return 0; @@ -135,13 +145,12 @@ unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource) #endif } -int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size, +int +drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size, drm_map_type_t type, drm_map_flags_t flags, drm_local_map_t **map_ptr) { drm_local_map_t *map; int align; - /*drm_agp_mem_t *entry; - int valid;*/ /* Only allow shared memory to be removable since we only keep enough * book keeping information about shared memory to allow for removal @@ -216,7 +225,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size, case _DRM_SHM: map->handle = malloc(map->size, M_DRM, M_NOWAIT); DRM_DEBUG( "%lu %d %p\n", - map->size, drm_order(map->size), map->handle ); + map->size, drm_order(map->size), map->handle ); if ( !map->handle ) { free(map, M_DRM); DRM_LOCK(); @@ -314,7 +323,8 @@ done: return 0; } -int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_map_t *request = data; drm_local_map_t *map; @@ -347,7 +357,8 @@ int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -void drm_rmmap(drm_device_t *dev, drm_local_map_t *map) +void +drm_rmmap(drm_device_t *dev, drm_local_map_t *map) { DRM_SPINLOCK_ASSERT(&dev->dev_lock); @@ -399,7 +410,8 @@ void drm_rmmap(drm_device_t *dev, drm_local_map_t *map) * isn't in use. */ -int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_local_map_t *map; drm_map_t *request = data; @@ -425,7 +437,8 @@ int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) } -static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry) +void +drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry) { int i; @@ -448,12 +461,11 @@ static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry) } } -static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) { drm_device_dma_t *dma = dev->dma; drm_buf_entry_t *entry; - /*drm_agp_mem_t *agp_entry; - int valid*/ drm_buf_t *buf; unsigned long offset; unsigned long agp_offset; @@ -472,7 +484,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) size = 1 << order; alignment = (request->flags & _DRM_PAGE_ALIGN) - ? round_page(size) : size; + ? round_page(size) : size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; @@ -523,18 +535,18 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) offset = 0; while ( entry->buf_count < count ) { - buf = &entry->buflist[entry->buf_count]; - buf->idx = dma->buf_count + entry->buf_count; - buf->total = alignment; - buf->order = order; - buf->used = 0; + buf = &entry->buflist[entry->buf_count]; + buf->idx = dma->buf_count + entry->buf_count; + buf->total = alignment; + buf->order = order; + buf->used = 0; - buf->offset = (dma->byte_count + offset); + buf->offset = (dma->byte_count + offset); buf->bus_address = agp_offset + offset; buf->address = (void *)(agp_offset + offset); - buf->next = NULL; + buf->next = NULL; buf->pending = 0; - buf->file_priv = NULL; + buf->file_priv = NULL; buf->dev_priv_size = dev->driver.buf_priv_size; buf->dev_private = malloc(buf->dev_priv_size, M_DRM, @@ -555,7 +567,6 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) #if defined(__OpenBSD__) /* OpenBSD lacks realloc in kernel */ - /* XXX overflow */ temp_buflist = drm_realloc(dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM ); @@ -589,7 +600,8 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) return 0; } -static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) { drm_device_dma_t *dma = dev->dma; int count; @@ -612,10 +624,10 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) size = 1 << order; DRM_DEBUG( "count=%d, size=%d (%d), order=%d\n", - request->count, request->size, size, order ); + request->count, request->size, size, order ); alignment = (request->flags & _DRM_PAGE_ALIGN) - ? round_page(size) : size; + ? round_page(size) : size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; @@ -647,7 +659,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) sizeof(*dma->pagelist)); DRM_DEBUG( "pagelist: %d entries\n", - dma->page_count + (count << page_order) ); + dma->page_count + (count << page_order) ); entry->buf_size = size; entry->page_order = page_order; @@ -669,14 +681,14 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) entry->seglist[entry->seg_count++] = dmah; for ( i = 0 ; i < (1 << page_order) ; i++ ) { DRM_DEBUG( "page %d @ %p\n", - dma->page_count + page_count, - (char *)dmah->vaddr + PAGE_SIZE * i ); + dma->page_count + page_count, + (char *)dmah->vaddr + PAGE_SIZE * i ); temp_pagelist[dma->page_count + page_count++] = (long)dmah->vaddr + PAGE_SIZE * i; } for ( offset = 0 ; - offset + size <= total && entry->buf_count < count ; - offset += alignment, ++entry->buf_count ) { + offset + size <= total && entry->buf_count < count ; + offset += alignment, ++entry->buf_count ) { buf = &entry->buflist[entry->buf_count]; buf->idx = dma->buf_count + entry->buf_count; buf->total = alignment; @@ -702,7 +714,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) } DRM_DEBUG( "buffer %d @ %p\n", - entry->buf_count, buf->address ); + entry->buf_count, buf->address ); } byte_count += PAGE_SIZE << page_order; } @@ -746,7 +758,8 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) } -static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) { drm_device_dma_t *dma = dev->dma; drm_buf_entry_t *entry; @@ -768,7 +781,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) size = 1 << order; alignment = (request->flags & _DRM_PAGE_ALIGN) - ? round_page(size) : size; + ? round_page(size) : size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; @@ -796,18 +809,18 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) offset = 0; while ( entry->buf_count < count ) { - buf = &entry->buflist[entry->buf_count]; - buf->idx = dma->buf_count + entry->buf_count; - buf->total = alignment; - buf->order = order; - buf->used = 0; + buf = &entry->buflist[entry->buf_count]; + buf->idx = dma->buf_count + entry->buf_count; + buf->total = alignment; + buf->order = order; + buf->used = 0; - buf->offset = (dma->byte_count + offset); + buf->offset = (dma->byte_count + offset); buf->bus_address = agp_offset + offset; buf->address = (void *)(agp_offset + offset + dev->sg->handle); - buf->next = NULL; + buf->next = NULL; buf->pending = 0; - buf->file_priv = NULL; + buf->file_priv = NULL; buf->dev_priv_size = dev->driver.buf_priv_size; buf->dev_private = malloc(buf->dev_priv_size, M_DRM, @@ -820,7 +833,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) } DRM_DEBUG( "buffer %d @ %p\n", - entry->buf_count, buf->address ); + entry->buf_count, buf->address ); offset += alignment; entry->buf_count++; @@ -863,7 +876,8 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) return 0; } -int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) { int order, ret; @@ -898,7 +912,8 @@ int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request) return ret; } -int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) { int order, ret; @@ -938,7 +953,8 @@ int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) return ret; } -int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) +int +drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) { int order, ret; @@ -978,7 +994,8 @@ int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request) return ret; } -int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_buf_desc_t *request = data; int err; @@ -993,7 +1010,8 @@ int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) return err; } -int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_device_dma_t *dma = dev->dma; drm_buf_info_t *request = data; @@ -1028,11 +1046,11 @@ int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv) } DRM_DEBUG( "%d %d %d %d %d\n", - i, - dma->bufs[i].buf_count, - dma->bufs[i].buf_size, - dma->bufs[i].freelist.low_mark, - dma->bufs[i].freelist.high_mark ); + i, + dma->bufs[i].buf_count, + dma->bufs[i].buf_size, + dma->bufs[i].freelist.low_mark, + dma->bufs[i].freelist.high_mark ); ++count; } } @@ -1042,14 +1060,15 @@ int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv) return retcode; } -int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_device_dma_t *dma = dev->dma; drm_buf_desc_t *request = data; int order; DRM_DEBUG( "%d, %d, %d\n", - request->size, request->low_mark, request->high_mark ); + request->size, request->low_mark, request->high_mark ); order = drm_order(request->size); @@ -1072,7 +1091,8 @@ int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_device_dma_t *dma = dev->dma; drm_buf_free_t *request = data; @@ -1091,14 +1111,14 @@ int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv) } if ( idx < 0 || idx >= dma->buf_count ) { DRM_ERROR( "Index %d (of %d max)\n", - idx, dma->buf_count - 1 ); + idx, dma->buf_count - 1 ); retcode = EINVAL; break; } buf = dma->buflist[idx]; if ( buf->file_priv != file_priv ) { DRM_ERROR("Process %d freeing buffer not owned\n", - DRM_CURRENTPID); + DRM_CURRENTPID); retcode = EINVAL; break; } @@ -1109,7 +1129,8 @@ int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv) return retcode; } -int drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_device_dma_t *dma = dev->dma; int retcode = 0; @@ -1134,9 +1155,8 @@ int drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv) int i; #if defined(__NetBSD__) || defined(__OpenBSD__) -/* makedev( ,dev->unit) */ if (!vfinddev(dev->kdev, VCHR, &vn)) - return 0; /* FIXME: Shouldn't this be EINVAL or something? */ + return EINVAL; #endif /* __NetBSD__ || __OpenBSD__ */ #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c index d0b2f941f53..cb0516205ae 100644 --- a/sys/dev/pci/drm/drm_context.c +++ b/sys/dev/pci/drm/drm_context.c @@ -38,7 +38,8 @@ * Context bitmap support */ -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 || ctx_handle >= DRM_MAX_CTXBITMAP || dev->ctx_bitmap == NULL) { @@ -54,7 +55,8 @@ void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle) return; } -int drm_ctxbitmap_next(drm_device_t *dev) +int +drm_ctxbitmap_next(drm_device_t *dev) { int bit; @@ -79,11 +81,6 @@ int drm_ctxbitmap_next(drm_device_t *dev) drm_local_map_t **ctx_sareas; #if defined(__OpenBSD__) - /* - * ugly. this means that we reallocate for every time the context - * is increased past the point. since this is a malloc+memcpy this - * be fairly slow. - */ ctx_sareas = drm_realloc(dev->context_sareas, old_context * sizeof(*dev->context_sareas), dev->max_context * sizeof(*dev->context_sareas), M_DRM); @@ -115,7 +112,8 @@ int drm_ctxbitmap_next(drm_device_t *dev) return bit; } -int drm_ctxbitmap_init(drm_device_t *dev) +int +drm_ctxbitmap_init(drm_device_t *dev) { int i; int temp; @@ -138,7 +136,8 @@ int drm_ctxbitmap_init(drm_device_t *dev) return 0; } -void drm_ctxbitmap_cleanup(drm_device_t *dev) +void +drm_ctxbitmap_cleanup(drm_device_t *dev) { DRM_LOCK(); if (dev->context_sareas != NULL) @@ -151,7 +150,8 @@ void drm_ctxbitmap_cleanup(drm_device_t *dev) * Per Context SAREA Support */ -int drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv ) +int +drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv ) { drm_ctx_priv_map_t *request = data; drm_local_map_t *map; @@ -171,7 +171,8 @@ int drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv ) return 0; } -int drm_setsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_setsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_priv_map_t *request = data; drm_local_map_t *map = NULL; @@ -198,7 +199,8 @@ bad: * The actual DRM context handling routines */ -int drm_context_switch(drm_device_t *dev, int old, int new) +int +drm_context_switch(drm_device_t *dev, int old, int new) { if ( test_and_set_bit( 0, &dev->context_flag ) ) { DRM_ERROR( "Reentering -- FIXME\n" ); @@ -215,7 +217,8 @@ int drm_context_switch(drm_device_t *dev, int old, int new) return 0; } -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. */ @@ -231,7 +234,8 @@ int drm_context_switch_complete(drm_device_t *dev, int new) return 0; } -int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_res_t *res = data; drm_ctx_t ctx; @@ -242,7 +246,7 @@ int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv) for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) { ctx.handle = i; if ( DRM_COPY_TO_USER( &res->contexts[i], - &ctx, sizeof(ctx) ) ) + &ctx, sizeof(ctx) ) ) return EFAULT; } } @@ -251,19 +255,20 @@ int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_t *ctx = data; ctx->handle = drm_ctxbitmap_next(dev); 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); } DRM_DEBUG( "%d\n", ctx->handle ); if ( ctx->handle == -1 ) { DRM_DEBUG( "Not enough free contexts.\n" ); - /* Should this return -EBUSY instead? */ + /* Should this return -EBUSY instead? */ return ENOMEM; } @@ -276,13 +281,15 @@ int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_modctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_modctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { /* This does nothing */ return 0; } -int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_t *ctx = data; @@ -292,7 +299,8 @@ int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_t *ctx = data; @@ -300,7 +308,8 @@ int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv) return drm_context_switch(dev, dev->last_context, ctx->handle); } -int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_t *ctx = data; @@ -310,7 +319,8 @@ int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_rmctx(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_rmctx(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_ctx_t *ctx = data; diff --git a/sys/dev/pci/drm/drm_dma.c b/sys/dev/pci/drm/drm_dma.c index 33e37e891e0..46774b0855e 100644 --- a/sys/dev/pci/drm/drm_dma.c +++ b/sys/dev/pci/drm/drm_dma.c @@ -38,7 +38,8 @@ #include "drmP.h" -int drm_dma_setup(drm_device_t *dev) +int +drm_dma_setup(drm_device_t *dev) { dev->dma = malloc(sizeof(*dev->dma), M_DRM, M_NOWAIT | M_ZERO); @@ -50,22 +51,23 @@ int drm_dma_setup(drm_device_t *dev) return 0; } -void drm_dma_takedown(drm_device_t *dev) +void +drm_dma_takedown(drm_device_t *dev) { - drm_device_dma_t *dma = dev->dma; - int i, j; + drm_device_dma_t *dma = dev->dma; + int i, j; if (dma == NULL) return; - /* Clear dma buffers */ + /* Clear dma buffers */ for (i = 0; i <= DRM_MAX_ORDER; i++) { if (dma->bufs[i].seg_count) { DRM_DEBUG("order %d: buf_count = %d," - " seg_count = %d\n", - i, - dma->bufs[i].buf_count, - dma->bufs[i].seg_count); + " seg_count = %d\n", + i, + dma->bufs[i].buf_count, + dma->bufs[i].seg_count); for (j = 0; j < dma->bufs[i].seg_count; j++) { drm_pci_free(dev, dma->bufs[i].seglist[j]); } @@ -94,19 +96,21 @@ void drm_dma_takedown(drm_device_t *dev) } -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; - buf->pending = 0; + buf->pending = 0; buf->file_priv= NULL; - buf->used = 0; + buf->used = 0; } -void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv) +void +drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv) { drm_device_dma_t *dma = dev->dma; - int i; + int i; if (!dma) return; for (i = 0; i < dma->buf_count; i++) { @@ -127,7 +131,8 @@ void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv) } /* Call into the driver-specific DMA handler */ -int drm_dma(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_dma(drm_device_t *dev, void *data, struct drm_file *file_priv) { if (dev->driver.dma_ioctl) { diff --git a/sys/dev/pci/drm/drm_drawable.c b/sys/dev/pci/drm/drm_drawable.c index 264d4148e3d..021f348136e 100644 --- a/sys/dev/pci/drm/drm_drawable.c +++ b/sys/dev/pci/drm/drm_drawable.c @@ -35,6 +35,9 @@ #include "drmP.h" +int drm_drawable_compare(struct bsd_drm_drawable_info *, + struct bsd_drm_drawable_info *); + #ifdef __OpenBSD__ RB_PROTOTYPE(drawable_tree, bsd_drm_drawable_info, tree, drm_drawable_compare); @@ -46,7 +49,7 @@ struct bsd_drm_drawable_info { RB_ENTRY(bsd_drm_drawable_info) tree; }; -static int +int drm_drawable_compare(struct bsd_drm_drawable_info *a, struct bsd_drm_drawable_info *b) { @@ -79,7 +82,8 @@ drm_get_drawable_info(drm_device_t *dev, int handle) return NULL; } -int drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_draw_t *draw = data; struct bsd_drm_drawable_info *info; @@ -104,7 +108,8 @@ int drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_draw_t *draw = (drm_draw_t *)data; struct drm_drawable_info *info; @@ -127,7 +132,8 @@ int drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv) } } -int drm_update_draw(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_update_draw(drm_device_t *dev, void *data, struct drm_file *file_priv) { struct drm_drawable_info *info; struct drm_update_draw *update = (struct drm_update_draw *)data; diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 6dcd058e311..390d54d73da 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -47,10 +47,12 @@ int drm_debug_flag = 1; int drm_debug_flag = 0; #endif -static int drm_load(drm_device_t *dev); -static void drm_unload(drm_device_t *dev); -static drm_pci_id_list_t *drm_find_description(int vendor, int device, - drm_pci_id_list_t *idlist); +int drm_load(drm_device_t *); +void drm_unload(drm_device_t *); +drm_pci_id_list_t *drm_find_description(int , int , + drm_pci_id_list_t *); +int drm_firstopen(drm_device_t *); +int drm_lastclose(drm_device_t *); #ifdef __FreeBSD__ #define DRIVER_SOFTC(unit) \ @@ -153,7 +155,8 @@ static struct cdevsw drm_cdevsw = { #endif }; -int drm_probe(device_t dev, drm_pci_id_list_t *idlist) +int +drm_probe(device_t dev, drm_pci_id_list_t *idlist) { drm_pci_id_list_t *id_entry; int vendor, device; @@ -180,7 +183,8 @@ int drm_probe(device_t dev, drm_pci_id_list_t *idlist) return ENXIO; } -int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist) +int +drm_attach(device_t nbdev, drm_pci_id_list_t *idlist) { drm_device_t *dev; drm_pci_id_list_t *id_entry; @@ -215,7 +219,8 @@ int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist) return drm_load(dev); } -int drm_detach(device_t dev) +int +drm_detach(device_t dev) { drm_unload(device_get_softc(dev)); return 0; @@ -243,70 +248,14 @@ static struct cdevsw drm_cdevsw = { nokqfilter, D_TTY }; -#if __NetBSD_Version__ >= 106080000 -MOD_DEV("drm", DRIVER_NAME, NULL, -1, &drm_cdevsw, CDEV_MAJOR); -#else -MOD_DEV("drm", LM_DT_CHAR, CDEV_MAJOR, &drm_cdevsw); -#endif - -int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver); -static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd); - -int drm_modprobe(void); -void drm_attach(struct device *, struct pci_attach_args *, - drm_pci_id_list_t *); - -int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp, cmd, ver, drm_lkmhandle, drm_lkmhandle, drm_lkmhandle); -} - -static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd) -{ - int error = 0; - - switch(cmd) { - case LKM_E_LOAD: - if (lkmexists(lkmtp)) - return EEXIST; - - if(drm_modprobe()) - return 0; - - return 1; - - case LKM_E_UNLOAD: - if (drm_refcnt > 0) - return (EBUSY); - break; - case LKM_E_STAT: - break; - - default: - error = EIO; - break; - } - - return error; -} - -int drm_modprobe(void) -{ - struct pci_attach_args pa; - int error; - - error = pci_find_device(&pa, drm_probe, idlist); - if (error != 0) - drm_attach(&pa, 0); - - return error; -} #endif drm_device_t *drm_units[DRM_MAXUNITS]; static int init_units = 1; -int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) +int +drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) { int unit; drm_pci_id_list_t *id_entry; @@ -325,8 +274,9 @@ int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) return 0; } -void drm_attach(struct device *kdev, struct pci_attach_args *pa, - drm_pci_id_list_t *idlist) +void +drm_attach(struct device *kdev, struct pci_attach_args *pa, + drm_pci_id_list_t *idlist) { int unit; drm_device_t *dev; @@ -341,7 +291,6 @@ void drm_attach(struct device *kdev, struct pci_attach_args *pa, for(unit=0; unit<DRM_MAXUNITS; unit++) if(drm_units[unit] == NULL) break; - /* This should not happen, since drm_probe made sure there was room */ if(unit == DRM_MAXUNITS) return; dev = drm_units[unit] = (drm_device_t*)kdev; @@ -366,13 +315,15 @@ void drm_attach(struct device *kdev, struct pci_attach_args *pa, drm_load(dev); } -int drm_detach(struct device *self, int flags) +int +drm_detach(struct device *self, int flags) { drm_unload((drm_device_t *)self); return 0; } -int drm_activate(struct device *self, enum devact act) +int +drm_activate(struct device *self, enum devact act) { switch (act) { case DVACT_ACTIVATE: @@ -387,8 +338,8 @@ int drm_activate(struct device *self, enum devact act) } #endif /* __NetBSD__ || __OpenBSD__ */ -drm_pci_id_list_t *drm_find_description(int vendor, int device, - drm_pci_id_list_t *idlist) +drm_pci_id_list_t * +drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist) { int i = 0; @@ -401,7 +352,8 @@ drm_pci_id_list_t *drm_find_description(int vendor, int device, return NULL; } -static int drm_firstopen(drm_device_t *dev) +int +drm_firstopen(drm_device_t *dev) { drm_local_map_t *map; int i; @@ -410,7 +362,7 @@ static int drm_firstopen(drm_device_t *dev) /* prebuild the SAREA */ i = drm_addmap(dev, 0, SAREA_MAX, _DRM_SHM, - _DRM_CONTAINS_LOCK, &map); + _DRM_CONTAINS_LOCK, &map); if (i != 0) return i; @@ -425,13 +377,13 @@ static int drm_firstopen(drm_device_t *dev) return i; } - dev->counters = 6; - dev->types[0] = _DRM_STAT_LOCK; - dev->types[1] = _DRM_STAT_OPENS; - dev->types[2] = _DRM_STAT_CLOSES; - dev->types[3] = _DRM_STAT_IOCTLS; - dev->types[4] = _DRM_STAT_LOCKS; - dev->types[5] = _DRM_STAT_UNLOCKS; + dev->counters = 6; + dev->types[0] = _DRM_STAT_LOCK; + dev->types[1] = _DRM_STAT_OPENS; + dev->types[2] = _DRM_STAT_CLOSES; + dev->types[3] = _DRM_STAT_IOCTLS; + dev->types[4] = _DRM_STAT_LOCKS; + dev->types[5] = _DRM_STAT_UNLOCKS; for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ ) atomic_set( &dev->counts[i], 0 ); @@ -458,7 +410,8 @@ static int drm_firstopen(drm_device_t *dev) return 0; } -static int drm_lastclose(drm_device_t *dev) +int +drm_lastclose(drm_device_t *dev) { drm_magic_entry_t *pt, *next; drm_local_map_t *map; @@ -537,7 +490,8 @@ static int drm_lastclose(drm_device_t *dev) return 0; } -static int drm_load(drm_device_t *dev) +int +drm_load(drm_device_t *dev) { int retcode; @@ -616,11 +570,11 @@ static int drm_load(drm_device_t *dev) } #endif DRM_INFO("Initialized %s %d.%d.%d %s\n", - dev->driver.name, - dev->driver.major, - dev->driver.minor, - dev->driver.patchlevel, - dev->driver.date); + dev->driver.name, + dev->driver.major, + dev->driver.minor, + dev->driver.patchlevel, + dev->driver.date); return 0; @@ -636,7 +590,8 @@ error: return retcode; } -static void drm_unload(drm_device_t *dev) +void +drm_unload(drm_device_t *dev) { int i; @@ -683,8 +638,8 @@ static void drm_unload(drm_device_t *dev) if (dev->pcir[i]->mapped) { bus_space_unmap(dev->pa.pa_memt, - dev->pcir[i]->bsh, - dev->pcir[i]->size); + dev->pcir[i]->bsh, + dev->pcir[i]->size); dev->pcir[i]->mapped = 0; } free(dev->pcir[i], M_DRM); @@ -710,7 +665,8 @@ static void drm_unload(drm_device_t *dev) } -int drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_version_t *version = data; int len; @@ -735,7 +691,8 @@ int drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) +int +drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) { drm_device_t *dev = NULL; int retcode = 0; @@ -763,7 +720,8 @@ int drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) return retcode; } -int drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) +int +drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) { drm_device_t *dev = drm_get_device_from_kdev(kdev); drm_file_t *file_priv; @@ -793,17 +751,17 @@ int drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) #ifdef __FreeBSD__ DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n", - DRM_CURRENTPID, (long)dev->device, dev->open_count ); + DRM_CURRENTPID, (long)dev->device, dev->open_count ); #elif defined(__NetBSD__) || defined(__OpenBSD__) DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n", - DRM_CURRENTPID, (long)&dev->device, dev->open_count); + DRM_CURRENTPID, (long)&dev->device, dev->open_count); #endif if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && dev->lock.file_priv == file_priv) { DRM_DEBUG("Process %d dead, freeing lock for context %d\n", - DRM_CURRENTPID, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + DRM_CURRENTPID, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); if (dev->driver.reclaim_buffers_locked != NULL) dev->driver.reclaim_buffers_locked(dev, file_priv); @@ -879,7 +837,8 @@ done: /* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. */ -int drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags, +int +drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p) { drm_device_t *dev = drm_get_device_from_kdev(kdev); @@ -994,7 +953,8 @@ int drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags, return retcode; } -drm_local_map_t *drm_getsarea(drm_device_t *dev) +drm_local_map_t * +drm_getsarea(drm_device_t *dev) { drm_local_map_t *map; diff --git a/sys/dev/pci/drm/drm_fops.c b/sys/dev/pci/drm/drm_fops.c index 29836d5ccc6..0c982f88959 100644 --- a/sys/dev/pci/drm/drm_fops.c +++ b/sys/dev/pci/drm/drm_fops.c @@ -36,7 +36,8 @@ #include "drmP.h" -drm_file_t *drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p) +drm_file_t * +drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p) { uid_t uid = DRM_UID(p); pid_t pid = DRM_PID(p); @@ -52,13 +53,14 @@ drm_file_t *drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p) } /* drm_open_helper is called whenever a process opens /dev/drm. */ -int drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p, - drm_device_t *dev) +int +drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p, + drm_device_t *dev) { - int m = minor(kdev); drm_file_t *priv; - int retcode; + int m, retcode; + m = minor(kdev); if (flags & O_EXCL) return EBUSY; /* No exclusive opens */ dev->flags = flags; @@ -75,15 +77,15 @@ int drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_UNLOCK(); return ENOMEM; } - priv->uid = DRM_UID(p); - priv->pid = DRM_PID(p); + priv->uid = DRM_UID(p); + priv->pid = DRM_PID(p); - priv->refs = 1; - priv->minor = m; - priv->ioctl_count = 0; + priv->refs = 1; + priv->minor = m; + priv->ioctl_count = 0; /* for compatibility root is always authenticated */ - priv->authenticated = DRM_SUSER(p); + priv->authenticated = DRM_SUSER(p); if (dev->driver.open) { /* shared code returns -errno */ @@ -111,12 +113,14 @@ int drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p, /* The drm_read and drm_poll are stubs to prevent spurious errors * on older X Servers (4.3.0 and earlier) */ -int drm_read(DRM_CDEV kdev, struct uio *uio, int ioflag) +int +drm_read(DRM_CDEV kdev, struct uio *uio, int ioflag) { return 0; } -int drm_poll(DRM_CDEV kdev, int events, DRM_STRUCTPROC *p) +int +drm_poll(DRM_CDEV kdev, int events, DRM_STRUCTPROC *p) { return 0; } diff --git a/sys/dev/pci/drm/drm_ioctl.c b/sys/dev/pci/drm/drm_ioctl.c index 8ea59adcfc5..2750517eb08 100644 --- a/sys/dev/pci/drm/drm_ioctl.c +++ b/sys/dev/pci/drm/drm_ioctl.c @@ -35,13 +35,16 @@ #include "drmP.h" +int drm_set_busid(drm_device_t *); + /* * Beginning in revision 1.1 of the DRM interface, getunique will return * a unique in the form pci:oooo:bb:dd.f (o=domain, b=bus, d=device, f=function) * before setunique has been called. The format for the bus-specific part of * the unique is not defined for any other bus. */ -int drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_unique_t *u = data; @@ -57,7 +60,8 @@ int drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv) /* Deprecated in DRM version 1.1, and will return EBUSY when setversion has * requested version 1.1 or greater. */ -int drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_unique_t *u = data; int domain, bus, slot, func, ret; @@ -117,7 +121,7 @@ int drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv) } -static int +int drm_set_busid(drm_device_t *dev) { @@ -143,7 +147,8 @@ drm_set_busid(drm_device_t *dev) return 0; } -int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_map_t *map = data; drm_local_map_t *mapinlist; @@ -161,11 +166,11 @@ int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv) TAILQ_FOREACH(mapinlist, &dev->maplist, link) { if (i==idx) { map->offset = mapinlist->offset; - map->size = mapinlist->size; - map->type = mapinlist->type; - map->flags = mapinlist->flags; + map->size = mapinlist->size; + map->type = mapinlist->type; + map->flags = mapinlist->flags; map->handle = mapinlist->handle; - map->mtrr = mapinlist->mtrr; + map->mtrr = mapinlist->mtrr; break; } i++; @@ -179,7 +184,8 @@ int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_client_t *client = data; drm_file_t *pt; @@ -191,11 +197,11 @@ int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv) TAILQ_FOREACH(pt, &dev->files, link) { if (i==idx) { - client->auth = pt->authenticated; - client->pid = pt->pid; - client->uid = pt->uid; + client->auth = pt->authenticated; + client->pid = pt->pid; + client->uid = pt->uid; client->magic = pt->magic; - client->iocs = pt->ioctl_count; + client->iocs = pt->ioctl_count; DRM_UNLOCK(); return 0; } @@ -206,10 +212,11 @@ int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv) return EINVAL; } -int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv) { - drm_stats_t *stats = data; - int i; + drm_stats_t *stats = data; + int i; memset(stats, 0, sizeof(drm_stats_t)); @@ -218,8 +225,8 @@ int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv) for (i = 0; i < dev->counters; i++) { if (dev->types[i] == _DRM_STAT_LOCK) stats->data[i].value - = (dev->lock.hw_lock - ? dev->lock.hw_lock->lock : 0); + = (dev->lock.hw_lock + ? dev->lock.hw_lock->lock : 0); else stats->data[i].value = atomic_read(&dev->counts[i]); stats->data[i].type = dev->types[i]; @@ -235,7 +242,8 @@ int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv) #define DRM_IF_MAJOR 1 #define DRM_IF_MINOR 2 -int drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_set_version_t *sv = data; drm_set_version_t ver; @@ -279,7 +287,8 @@ int drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv) } -int drm_noop(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_noop(drm_device_t *dev, void *data, struct drm_file *file_priv) { DRM_DEBUG("\n"); return 0; diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c index 85239ac7b8d..4910bae2187 100644 --- a/sys/dev/pci/drm/drm_irq.c +++ b/sys/dev/pci/drm/drm_irq.c @@ -35,15 +35,14 @@ #include "drmP.h" #include "drm.h" +irqreturn_t drm_irq_handler_wrap(DRM_IRQ_ARGS); + #if 0 -#ifdef __Freebsd__ -static void drm_locked_task(void *context, int pending __unused); -#else -static void drm_locked_task(void *context, int pending); -#endif +void drm_locked_task(void *context, int pending __unused); #endif /* 0 */ -int drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_irq_busid_t *irq = data; @@ -91,7 +90,7 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS) #endif #ifdef __OpenBSD__ -static irqreturn_t +irqreturn_t drm_irq_handler_wrap(DRM_IRQ_ARGS) { irqreturn_t ret; @@ -105,7 +104,8 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS) } #endif -int drm_irq_install(drm_device_t *dev) +int +drm_irq_install(drm_device_t *dev) { int retcode; #if defined(__NetBSD__) || defined(__OpenBSD__) @@ -158,9 +158,6 @@ int drm_irq_install(drm_device_t *dev) if (retcode != 0) goto err; #elif defined(__NetBSD__) || defined(__OpenBSD__) -#if defined(__OpenBSD__) -#define aprint_normal printf -#endif if (pci_intr_map(&dev->pa, &ih) != 0) { retcode = ENOENT; goto err; @@ -205,7 +202,8 @@ err: return retcode; } -int drm_irq_uninstall(drm_device_t *dev) +int +drm_irq_uninstall(drm_device_t *dev) { #ifdef __FreeBSD__ int irqrid; @@ -237,7 +235,8 @@ int drm_irq_uninstall(drm_device_t *dev) return 0; } -int drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_control_t *ctl = data; int err; @@ -265,7 +264,8 @@ int drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv) } } -int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_wait_vblank_t *vblwait = data; struct timeval now; @@ -314,12 +314,14 @@ int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv) return ret; } -void drm_vbl_send_signals(drm_device_t *dev) +void +drm_vbl_send_signals(drm_device_t *dev) { } #if 0 /* disabled */ -void drm_vbl_send_signals( drm_device_t *dev ) +void +drm_vbl_send_signals( drm_device_t *dev ) { drm_vbl_sig_t *vbl_sig; unsigned int vbl_seq = atomic_read( &dev->vbl_received ); @@ -343,11 +345,8 @@ void drm_vbl_send_signals( drm_device_t *dev ) #endif #if 0 /* disabled while it's unused anywhere */ -#ifdef __FreeBSD__ -static void drm_locked_task(void *context, int pending __unused) -#else -static void drm_locked_task(void *context, int pending) -#endif +void +drm_locked_task(void *context, int pending __unused) { drm_device_t *dev = context; @@ -397,6 +396,6 @@ drm_locked_tasklet(drm_device_t *dev, void (*tasklet)(void* dev, void*)) taskqueue_enqueue(taskqueue_swi, &dev->locked_task); #else workq_add_task(NULL, WQ_WAITOK, dev->locked_task_call, - dev, NULL); + dev, NULL); #endif } diff --git a/sys/dev/pci/drm/drm_lock.c b/sys/dev/pci/drm/drm_lock.c index 60b78305ba2..798d813b0d5 100644 --- a/sys/dev/pci/drm/drm_lock.c +++ b/sys/dev/pci/drm/drm_lock.c @@ -49,27 +49,28 @@ #include "drmP.h" -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; do { old = *lock; if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT; - else new = context | _DRM_LOCK_HELD; + else new = context | _DRM_LOCK_HELD; } while (!atomic_cmpset_int(lock, old, new)); if (_DRM_LOCKING_CONTEXT(old) == context) { if (old & _DRM_LOCK_HELD) { if (context != DRM_KERNEL_CONTEXT) { DRM_ERROR("%d holds heavyweight lock\n", - context); + context); } return 0; } } if (new == (context | _DRM_LOCK_HELD)) { - /* Have lock */ + /* Have lock */ return 1; } return 0; @@ -77,8 +78,9 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) /* This takes a lock forcibly and hands it to context. Should ONLY be used inside *_unlock to give lock to kernel before calling *_dma_schedule. */ -int drm_lock_transfer(drm_device_t *dev, - __volatile__ unsigned int *lock, unsigned int context) +int +drm_lock_transfer(drm_device_t *dev, __volatile__ unsigned int *lock, + unsigned int context) { unsigned int old, new; @@ -91,8 +93,9 @@ int drm_lock_transfer(drm_device_t *dev, return 1; } -int drm_lock_free(drm_device_t *dev, - __volatile__ unsigned int *lock, unsigned int context) +int +drm_lock_free(drm_device_t *dev, __volatile__ unsigned int *lock, + unsigned int context) { unsigned int old, new; @@ -111,7 +114,8 @@ int drm_lock_free(drm_device_t *dev, return 0; } -int drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_lock_t *lock = data; int ret = 0; @@ -159,7 +163,8 @@ int drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } -int drm_unlock(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_unlock(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_lock_t *lock = data; diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c index f018402f189..8d3ae1d4a5f 100644 --- a/sys/dev/pci/drm/drm_memory.c +++ b/sys/dev/pci/drm/drm_memory.c @@ -42,7 +42,8 @@ MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures"); #endif -void drm_mem_init(void) +void +drm_mem_init(void) { #if defined(__NetBSD__) /* @@ -51,22 +52,26 @@ void drm_mem_init(void) #endif } -void drm_mem_uninit(void) +void +drm_mem_uninit(void) { } -void *drm_alloc(size_t size, int area) +void* +drm_alloc(size_t size, int area) { return malloc(size, M_DRM, M_NOWAIT); } -void *drm_calloc(size_t nmemb, size_t size, int area) +void * +drm_calloc(size_t nmemb, size_t size, int area) { /* XXX overflow checking */ return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO); } -void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) +void * +drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) { void *pt; @@ -80,12 +85,14 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) return pt; } -void drm_free(void *pt, size_t size, int area) +void +drm_free(void *pt, size_t size, int area) { free(pt, M_DRM); } -void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map) +void * +drm_ioremap(drm_device_t *dev, drm_local_map_t *map) { #ifdef __FreeBSD__ return pmap_mapdev(map->offset, map->size); @@ -95,17 +102,14 @@ void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map) map->bst = dev->pa.pa_memt; if ((ret = bus_space_map(map->bst, map->offset, map->size, BUS_SPACE_MAP_LINEAR, &map->bsh))) { - DRM_ERROR("Failed to map offset = 0x%08lx, size = 0x%08lx, type = %d, ret = %d\n", map->offset, - map->size, map->type, ret); return NULL; } - DRM_INFO("mapped offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, - map->offset, map->size); return bus_space_vaddr(map->bst, map->bsh); #endif } -void drm_ioremapfree(drm_local_map_t *map) +void +drm_ioremapfree(drm_local_map_t *map) { #ifdef __FreeBSD__ pmap_unmapdev((vm_offset_t) map->handle, map->size); @@ -134,11 +138,7 @@ drm_mtrr_add(unsigned long offset, size_t size, int flags) } int -#if defined(__OpenBSD__) -drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags) -#else drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags) -#endif { #ifndef DRM_NO_MTRR int act; diff --git a/sys/dev/pci/drm/drm_scatter.c b/sys/dev/pci/drm/drm_scatter.c index 0f1d92695ce..5ce642fb5d2 100644 --- a/sys/dev/pci/drm/drm_scatter.c +++ b/sys/dev/pci/drm/drm_scatter.c @@ -37,14 +37,16 @@ #define DEBUG_SCATTER 0 -void drm_sg_cleanup(drm_sg_mem_t *entry) +void +drm_sg_cleanup(drm_sg_mem_t *entry) { free((void *)entry->handle, M_DRM); free(entry->busaddr, M_DRM); free(entry, M_DRM); } -int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) +int +drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) { drm_sg_mem_t *entry; unsigned long pages; @@ -97,7 +99,8 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) return 0; } -int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_scatter_gather_t *request = data; int ret; @@ -108,7 +111,8 @@ int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv return ret; } -int drm_sg_free(drm_device_t *dev, void *data, struct drm_file *file_priv) +int +drm_sg_free(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_scatter_gather_t *request = data; drm_sg_mem_t *entry; diff --git a/sys/dev/pci/drm/drm_sysctl.c b/sys/dev/pci/drm/drm_sysctl.c index 69e39ef6430..43a97dfdd07 100644 --- a/sys/dev/pci/drm/drm_sysctl.c +++ b/sys/dev/pci/drm/drm_sysctl.c @@ -57,7 +57,8 @@ struct drm_sysctl_info { char name[2]; }; -int drm_sysctl_init(drm_device_t *dev) +int +drm_sysctl_init(drm_device_t *dev) { #ifndef __OpenBSD__ struct drm_sysctl_info *info; @@ -142,7 +143,8 @@ int drm_sysctl_init(drm_device_t *dev) return 0; } -int drm_sysctl_cleanup(drm_device_t *dev) +int +drm_sysctl_cleanup(drm_device_t *dev) { int error=0; #ifdef __FreeBSD__ @@ -184,7 +186,8 @@ do { \ goto done; \ } while (0) -static int drm_name_info DRM_SYSCTL_HANDLER_ARGS +static int +drm_name_info DRM_SYSCTL_HANDLER_ARGS { #ifndef __OpenBSD__ #ifdef __FreeBSD__ @@ -226,7 +229,8 @@ done: return 0; } -static int drm_vm_info DRM_SYSCTL_HANDLER_ARGS +static int +drm_vm_info DRM_SYSCTL_HANDLER_ARGS { #ifndef __OpenBSD__ #ifdef __FreeBSD__ @@ -298,7 +302,8 @@ done: return 0; } -static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS +static int +drm_bufs_info DRM_SYSCTL_HANDLER_ARGS { #ifndef __OpenBSD__ #ifdef __FreeBSD__ @@ -367,7 +372,8 @@ done: return 0; } -static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS +static int +drm_clients_info DRM_SYSCTL_HANDLER_ARGS { #ifndef __OpenBSD__ #ifdef __FreeBSD__ diff --git a/sys/dev/pci/drm/drm_vm.c b/sys/dev/pci/drm/drm_vm.c index 1e5ced998e5..cbc3039f3ea 100644 --- a/sys/dev/pci/drm/drm_vm.c +++ b/sys/dev/pci/drm/drm_vm.c @@ -29,12 +29,15 @@ #include "drm.h" #if defined(__FreeBSD__) && __FreeBSD_version >= 500102 -int drm_mmap(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr, +int +drm_mmap(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr, int prot) #elif defined(__FreeBSD__) -int drm_mmap(dev_t kdev, vm_offset_t offset, int prot) +int +drm_mmap(dev_t kdev, vm_offset_t offset, int prot) #elif defined(__NetBSD__) || defined(__OpenBSD__) -paddr_t drm_mmap(dev_t kdev, off_t offset, int prot) +paddr_t +drm_mmap(dev_t kdev, off_t offset, int prot) #endif { drm_device_t *dev = drm_get_device_from_kdev(kdev); @@ -81,13 +84,15 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot) } } - /* A sequential search of a linked list is - fine here because: 1) there will only be - about 5-10 entries in the list and, 2) a - DRI client only has to do this mapping - once, so it doesn't have to be optimized - for performance, even if the list was a - bit longer. */ + /* + * A sequential search of a linked list is + * fine here because: 1) there will only be + * about 5-10 entries in the list and, 2) a + * DRI client only has to do this mapping + * once, so it doesn't have to be optimized + * for performance, even if the list was a + * bit longer. + */ DRM_LOCK(); TAILQ_FOREACH(map, &dev->maplist, link) { if (offset >= map->offset && offset < map->offset + map->size) diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c index 6660e22edc0..61a3ba4218b 100644 --- a/sys/dev/pci/drm/i915_drv.c +++ b/sys/dev/pci/drm/i915_drv.c @@ -35,12 +35,15 @@ #include "i915_drv.h" #include "drm_pciids.h" +void i915_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t i915_pciidlist[] = { i915_PCI_IDS }; -static void i915_configure(drm_device_t *dev) +void +i915_configure(drm_device_t *dev) { dev->driver.buf_priv_size = 1; /* No dev_priv */ dev->driver.load = i915_driver_load; @@ -116,7 +119,10 @@ MODULE_DEPEND(i915, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int i915drm_probe(struct device *, void *, void *); +void i915drm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) i915drm_probe(struct device *parent, void *match, void *aux) #else @@ -127,7 +133,7 @@ i915drm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, i915_pciidlist); } -static void +void i915drm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c index 5c30420f5ee..78ef1bded92 100644 --- a/sys/dev/pci/drm/mach64_drv.c +++ b/sys/dev/pci/drm/mach64_drv.c @@ -39,12 +39,15 @@ #include "mach64_drv.h" #include "drm_pciids.h" +void mach64_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mach64_pciidlist[] = { mach64_PCI_IDS }; -static void mach64_configure(drm_device_t *dev) +void +mach64_configure(drm_device_t *dev) { dev->driver.buf_priv_size = 1; /* No dev_priv */ dev->driver.lastclose = mach64_driver_lastclose; @@ -114,7 +117,11 @@ DRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0); MODULE_DEPEND(mach64, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int + +int mach64drm_probe(struct device *, void *, void *); +void mach64drm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) mach64drm_probe(struct device *parent, void *match, void *aux) #else @@ -124,7 +131,7 @@ mach64drm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, mach64_pciidlist); } -static void +void mach64drm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c index c23c18f44ac..8732c31aaf5 100644 --- a/sys/dev/pci/drm/mga_drv.c +++ b/sys/dev/pci/drm/mga_drv.c @@ -37,6 +37,9 @@ #include "mga_drv.h" #include "drm_pciids.h" +int mga_driver_device_is_agp(drm_device_t * ); +void mga_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mga_pciidlist[] = { mga_PCI_IDS @@ -59,7 +62,8 @@ static drm_pci_id_list_t mga_pciidlist[] = { * This function needs to be filled in! The implementation in * linux-core/mga_drv.c shows what needs to be done. */ -static int mga_driver_device_is_agp(drm_device_t * dev) +int +mga_driver_device_is_agp(drm_device_t * dev) { #ifdef __FreeBSD__ device_t bus; @@ -87,7 +91,8 @@ static int mga_driver_device_is_agp(drm_device_t * dev) } -static void mga_configure(drm_device_t *dev) +void +mga_configure(drm_device_t *dev) { dev->driver.buf_priv_size = sizeof(drm_mga_buf_priv_t); dev->driver.load = mga_driver_load; @@ -164,7 +169,9 @@ MODULE_DEPEND(mga, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int mgadrm_probe(struct device *, void *, void *); +void mgadrm_attach(struct device *, struct device *, void *); +int #if defined(__OpenBSD__) mgadrm_probe(struct device *parent, void *match, void *aux) #else @@ -174,7 +181,7 @@ mgadrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, mga_pciidlist); } -static void +void mgadrm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c index a9eef3d089f..c6b32790ade 100644 --- a/sys/dev/pci/drm/r128_drv.c +++ b/sys/dev/pci/drm/r128_drv.c @@ -37,12 +37,15 @@ #include "r128_drv.h" #include "drm_pciids.h" +void r128_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t r128_pciidlist[] = { r128_PCI_IDS }; -static void r128_configure(drm_device_t *dev) +void +r128_configure(drm_device_t *dev) { dev->driver.buf_priv_size = sizeof(drm_r128_buf_priv_t); dev->driver.preclose = r128_driver_preclose; @@ -115,7 +118,10 @@ MODULE_DEPEND(r128, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int r128drm_probe(struct device *, void *, void *); +void r128drm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) r128drm_probe(struct device *parent, void *match, void *aux) #else @@ -125,7 +131,7 @@ r128drm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, r128_pciidlist); } -static void +void r128drm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c index 344493bf952..2ccd48818bc 100644 --- a/sys/dev/pci/drm/radeon_drv.c +++ b/sys/dev/pci/drm/radeon_drv.c @@ -35,6 +35,8 @@ #include "radeon_drv.h" #include "drm_pciids.h" +void radeon_configure(drm_device_t *); + int radeon_no_wb; /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ @@ -42,7 +44,8 @@ static drm_pci_id_list_t radeon_pciidlist[] = { radeon_PCI_IDS }; -static void radeon_configure(drm_device_t *dev) +void +radeon_configure(drm_device_t *dev) { dev->driver.buf_priv_size = sizeof(drm_radeon_buf_priv_t); dev->driver.load = radeon_driver_load; @@ -120,7 +123,10 @@ MODULE_DEPEND(radeon, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int radeondrm_probe(struct device *, void *, void *); +void radeondrm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) radeondrm_probe(struct device *parent, void *match, void *aux) #else @@ -130,7 +136,7 @@ radeondrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, radeon_pciidlist); } -static void +void radeondrm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c index 4c90f24d9d6..557bdbb1775 100644 --- a/sys/dev/pci/drm/savage_drv.c +++ b/sys/dev/pci/drm/savage_drv.c @@ -32,12 +32,15 @@ #include "savage_drv.h" #include "drm_pciids.h" +void savage_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t savage_pciidlist[] = { savage_PCI_IDS }; -static void savage_configure(drm_device_t *dev) +void +savage_configure(drm_device_t *dev) { dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t); dev->driver.load = savage_driver_load; @@ -105,7 +108,10 @@ MODULE_DEPEND(savage, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int savagedrm_probe(struct device *, void *, void *); +void savagedrm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) savagedrm_probe(struct device *parent, void *match, void *aux) #else @@ -115,7 +121,7 @@ savagedrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, savage_pciidlist); } -static void +void savagedrm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c index 1be5d66a62e..a986437aac8 100644 --- a/sys/dev/pci/drm/sis_drv.c +++ b/sys/dev/pci/drm/sis_drv.c @@ -31,12 +31,15 @@ #include "sis_drv.h" #include "drm_pciids.h" +void sis_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t sis_pciidlist[] = { sis_PCI_IDS }; -static void sis_configure(drm_device_t *dev) +void +sis_configure(drm_device_t *dev) { dev->driver.buf_priv_size = 1; /* No dev_priv */ dev->driver.context_ctor = sis_init_context; @@ -98,7 +101,10 @@ MODULE_DEPEND(sisdrm, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int sisdrm_probe(struct device *, void *, void *); +void sisdrm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) sisdrm_probe(struct device *parent, void *match, void *aux) #else @@ -108,7 +114,7 @@ sisdrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, sis_pciidlist); } -static void +void sisdrm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c index 36ac5d2f8c9..954446c475d 100644 --- a/sys/dev/pci/drm/tdfx_drv.c +++ b/sys/dev/pci/drm/tdfx_drv.c @@ -36,12 +36,15 @@ #include "drmP.h" #include "drm_pciids.h" +void tdfx_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t tdfx_pciidlist[] = { tdfx_PCI_IDS }; -static void tdfx_configure(drm_device_t *dev) +void +tdfx_configure(drm_device_t *dev) { dev->driver.buf_priv_size = 1; /* No dev_priv */ @@ -99,7 +102,10 @@ MODULE_DEPEND(tdfx, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int tdfxdrm_probe(struct device *, void *, void *); +void tdfxdrm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) tdfxdrm_probe(struct device *parent, void *match, void *aux) #else @@ -109,7 +115,7 @@ tdfxdrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, tdfx_pciidlist); } -static void +void tdfxdrm_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; diff --git a/sys/dev/pci/drm/via_drv.c b/sys/dev/pci/drm/via_drv.c index 6d483da9a4c..82a2374b296 100644 --- a/sys/dev/pci/drm/via_drv.c +++ b/sys/dev/pci/drm/via_drv.c @@ -34,12 +34,15 @@ #include "via_drv.h" #include "drm_pciids.h" +void via_configure(drm_device_t *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t via_pciidlist[] = { viadrv_PCI_IDS }; -static void via_configure(drm_device_t *dev) +void +via_configure(drm_device_t *dev) { dev->driver.buf_priv_size = 1; dev->driver.load = via_driver_load; @@ -107,7 +110,10 @@ MODULE_DEPEND(via, drm, 1, 1, 1); #elif defined(__NetBSD__) || defined(__OpenBSD__) -static int +int viadrm_probe(struct device *, void *, void *); +void viadrm_attach(struct device *, struct device *, void *); + +int #if defined(__OpenBSD__) viadrm_probe(struct device *parent, void *match, void *aux) #else @@ -117,7 +123,7 @@ viadrm_probe(struct device *parent, struct cfdata *match, void *aux) return drm_probe((struct pci_attach_args *)aux, via_pciidlist); } -static void +void viadrm_attach(struct device *parent, struct device *self, void *opaque) { struct pci_attach_args *pa = opaque; |