[FreeBSD] Use driver features macros and flags
Signed-off-by: Robert Noland <rnoland@2hip.net>main
parent
2649103bf9
commit
2b27804715
|
@ -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) */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
Loading…
Reference in New Issue