diff options
Diffstat (limited to 'bsd-core')
-rw-r--r-- | bsd-core/drmP.h | 37 | ||||
-rw-r--r-- | bsd-core/drm_bufs.c | 5 | ||||
-rw-r--r-- | bsd-core/drm_drv.c | 10 | ||||
-rw-r--r-- | bsd-core/drm_irq.c | 4 | ||||
-rw-r--r-- | bsd-core/drm_lock.c | 3 | ||||
-rw-r--r-- | bsd-core/i915_drv.c | 11 | ||||
-rw-r--r-- | bsd-core/mach64_drv.c | 11 | ||||
-rw-r--r-- | bsd-core/mga_drv.c | 11 | ||||
-rw-r--r-- | bsd-core/r128_drv.c | 12 | ||||
-rw-r--r-- | bsd-core/radeon_drv.c | 13 | ||||
-rw-r--r-- | bsd-core/savage_drv.c | 9 | ||||
-rw-r--r-- | bsd-core/sis_drv.c | 6 | ||||
-rw-r--r-- | bsd-core/tdfx_drv.c | 5 | ||||
-rw-r--r-- | bsd-core/via_drv.c | 8 |
14 files changed, 73 insertions, 72 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 9d797d79..7244b353 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -135,6 +135,17 @@ typedef struct drm_file drm_file_t; #define DRM_LINUX 0 #endif +/* driver capabilities and requirements mask */ +#define DRIVER_USE_AGP 0x1 +#define DRIVER_REQUIRE_AGP 0x2 +#define DRIVER_USE_MTRR 0x4 +#define DRIVER_PCI_DMA 0x8 +#define DRIVER_SG 0x10 +#define DRIVER_HAVE_DMA 0x20 +#define DRIVER_HAVE_IRQ 0x40 +#define DRIVER_DMA_QUEUE 0x100 + + #define DRM_HASH_SIZE 16 /* Size of key hash table */ #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */ #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */ @@ -705,16 +716,7 @@ struct drm_driver_info { const char *desc; /* Longer driver name */ const char *date; /* Date of last major changes. */ - unsigned use_agp :1; - unsigned require_agp :1; - unsigned use_sg :1; - unsigned use_dma :1; - unsigned use_pci_dma :1; - unsigned use_dma_queue :1; - unsigned use_irq :1; - unsigned use_vbl_irq :1; - unsigned use_vbl_irq2 :1; - unsigned use_mtrr :1; + u32 driver_features; }; /* Length for the array of resource pointers for drm_get_resource_*. */ @@ -832,6 +834,21 @@ struct drm_device { void (*locked_task_call)(struct drm_device *dev); }; +static __inline__ int drm_core_check_feature(struct drm_device *dev, + int feature) +{ + return ((dev->driver->driver_features & feature) ? 1 : 0); +} + +#if __OS_HAS_AGP +static inline int drm_core_has_AGP(struct drm_device *dev) +{ + return drm_core_check_feature(dev, DRIVER_USE_AGP); +} +#else +#define drm_core_has_AGP(dev) (0) +#endif + extern int drm_debug_flag; /* Device setup support (drm_drv.c) */ diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c index 2b248e47..ed13f02f 100644 --- a/bsd-core/drm_bufs.c +++ b/bsd-core/drm_bufs.c @@ -1061,8 +1061,9 @@ int drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv) if (request->count < dma->buf_count) goto done; - if ((dev->driver->use_agp && (dma->flags & _DRM_DMA_USE_AGP)) || - (dev->driver->use_sg && (dma->flags & _DRM_DMA_USE_SG))) { + if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) || + (drm_core_check_feature(dev, DRIVER_SG) && + (dma->flags & _DRM_DMA_USE_SG))) { drm_local_map_t *map = dev->agp_buffer_map; if (map == NULL) { diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 2ad54b9a..e5762cc4 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -402,7 +402,7 @@ static int drm_firstopen(struct drm_device *dev) dev->buf_use = 0; - if (dev->driver->use_dma) { + if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) { i = drm_dma_setup(dev); if (i != 0) return i; @@ -557,10 +557,11 @@ static int drm_load(struct drm_device *dev) goto error; } - if (dev->driver->use_agp) { + if (drm_core_has_AGP(dev)) { if (drm_device_is_agp(dev)) dev->agp = drm_agp_init(); - if (dev->driver->require_agp && dev->agp == NULL) { + if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && + dev->agp == NULL) { DRM_ERROR("Card isn't AGP, or couldn't initialize " "AGP.\n"); retcode = ENOMEM; @@ -814,7 +815,8 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) } } - if (dev->driver->use_dma && !dev->driver->reclaim_buffers_locked) + if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) && + !dev->driver->reclaim_buffers_locked) drm_reclaim_buffers(dev, file_priv); #if defined (__FreeBSD__) && (__FreeBSD_version >= 500000) diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c index 6d7d1265..92861036 100644 --- a/bsd-core/drm_irq.c +++ b/bsd-core/drm_irq.c @@ -272,14 +272,14 @@ int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv) /* Handle drivers whose DRM used to require IRQ setup but the * no longer does. */ - if (!dev->driver->use_irq) + if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) return 0; if (dev->if_version < DRM_IF_VERSION(1, 2) && ctl->irq != dev->irq) return EINVAL; return drm_irq_install(dev); case DRM_UNINST_HANDLER: - if (!dev->driver->use_irq) + if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) return 0; DRM_LOCK(); err = drm_irq_uninstall(dev); diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c index cb8875b8..870874bb 100644 --- a/bsd-core/drm_lock.c +++ b/bsd-core/drm_lock.c @@ -126,7 +126,8 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) lock->context, DRM_CURRENTPID, dev->lock.hw_lock->lock, lock->flags); - if (dev->driver->use_dma_queue && lock->context < 0) + if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && + lock->context < 0) return EINVAL; DRM_LOCK(); diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index d2301ddd..8f21075d 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -68,6 +68,10 @@ static int i915_resume(device_t nbdev) static void i915_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | + DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = sizeof(drm_i915_private_t); dev->driver->load = i915_driver_load; dev->driver->unload = i915_driver_unload; @@ -92,13 +96,6 @@ static void i915_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->require_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; - dev->driver->use_vbl_irq2 = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/mach64_drv.c b/bsd-core/mach64_drv.c index 726b7d24..235a925f 100644 --- a/bsd-core/mach64_drv.c +++ b/bsd-core/mach64_drv.c @@ -46,6 +46,10 @@ static drm_pci_id_list_t mach64_pciidlist[] = { static void mach64_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | + DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = 1; /* No dev_priv */ dev->driver->lastclose = mach64_driver_lastclose; dev->driver->get_vblank_counter = mach64_get_vblank_counter; @@ -66,13 +70,6 @@ static void mach64_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_pci_dma = 1; - dev->driver->use_dma = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/mga_drv.c b/bsd-core/mga_drv.c index 0e434b56..1a3ab578 100644 --- a/bsd-core/mga_drv.c +++ b/bsd-core/mga_drv.c @@ -86,6 +86,10 @@ static int mga_driver_device_is_agp(struct drm_device * dev) static void mga_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | + DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = sizeof(drm_mga_buf_priv_t); dev->driver->load = mga_driver_load; dev->driver->unload = mga_driver_unload; @@ -110,13 +114,6 @@ static void mga_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->require_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_dma = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; } diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c index d93c746d..4e76ca51 100644 --- a/bsd-core/r128_drv.c +++ b/bsd-core/r128_drv.c @@ -44,6 +44,10 @@ static drm_pci_id_list_t r128_pciidlist[] = { static void r128_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | + DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = sizeof(drm_r128_buf_priv_t); dev->driver->preclose = r128_driver_preclose; dev->driver->lastclose = r128_driver_lastclose; @@ -65,14 +69,6 @@ static void r128_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_pci_dma = 1; - dev->driver->use_sg = 1; - dev->driver->use_dma = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c index eea04ff9..fc29d37b 100644 --- a/bsd-core/radeon_drv.c +++ b/bsd-core/radeon_drv.c @@ -44,6 +44,10 @@ static drm_pci_id_list_t radeon_pciidlist[] = { static void radeon_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | + DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = sizeof(drm_radeon_buf_priv_t); dev->driver->load = radeon_driver_load; dev->driver->unload = radeon_driver_unload; @@ -70,15 +74,6 @@ static void radeon_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_pci_dma = 1; - dev->driver->use_sg = 1; - dev->driver->use_dma = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; - dev->driver->use_vbl_irq2 = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/savage_drv.c b/bsd-core/savage_drv.c index ee5166a3..8f2fa321 100644 --- a/bsd-core/savage_drv.c +++ b/bsd-core/savage_drv.c @@ -39,6 +39,10 @@ static drm_pci_id_list_t savage_pciidlist[] = { static void savage_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | + DRIVER_HAVE_DMA; + dev->driver->buf_priv_size = sizeof(drm_savage_buf_priv_t); dev->driver->load = savage_driver_load; dev->driver->firstopen = savage_driver_firstopen; @@ -56,11 +60,6 @@ static void savage_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_pci_dma = 1; - dev->driver->use_dma = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/sis_drv.c b/bsd-core/sis_drv.c index a9637763..00a24300 100644 --- a/bsd-core/sis_drv.c +++ b/bsd-core/sis_drv.c @@ -38,6 +38,9 @@ static drm_pci_id_list_t sis_pciidlist[] = { static void sis_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR; + dev->driver->buf_priv_size = 1; /* No dev_priv */ dev->driver->context_ctor = sis_init_context; dev->driver->context_dtor = sis_final_context; @@ -51,9 +54,6 @@ static void sis_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/tdfx_drv.c b/bsd-core/tdfx_drv.c index e5559999..eb263fcb 100644 --- a/bsd-core/tdfx_drv.c +++ b/bsd-core/tdfx_drv.c @@ -43,6 +43,9 @@ static drm_pci_id_list_t tdfx_pciidlist[] = { static void tdfx_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_MTRR; + dev->driver->buf_priv_size = 1; /* No dev_priv */ dev->driver->max_ioctl = 0; @@ -53,8 +56,6 @@ static void tdfx_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_mtrr = 1; } #ifdef __FreeBSD__ diff --git a/bsd-core/via_drv.c b/bsd-core/via_drv.c index 539e3ef3..3b931e28 100644 --- a/bsd-core/via_drv.c +++ b/bsd-core/via_drv.c @@ -41,6 +41,9 @@ static drm_pci_id_list_t via_pciidlist[] = { static void via_configure(struct drm_device *dev) { + dev->driver->driver_features = + DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ; + dev->driver->buf_priv_size = 1; dev->driver->load = via_driver_load; dev->driver->unload = via_driver_unload; @@ -64,11 +67,6 @@ static void via_configure(struct drm_device *dev) dev->driver->major = DRIVER_MAJOR; dev->driver->minor = DRIVER_MINOR; dev->driver->patchlevel = DRIVER_PATCHLEVEL; - - dev->driver->use_agp = 1; - dev->driver->use_mtrr = 1; - dev->driver->use_irq = 1; - dev->driver->use_vbl_irq = 1; } #ifdef __FreeBSD__ |