diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-10-07 21:59:34 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-10-07 21:59:34 +0000 |
commit | 42029dea90615aabb34095ab75e07c870aed697e (patch) | |
tree | 9352262ae24879f8db3984f0282cb13b24cae88d /sys | |
parent | 584f3a15eadcca708f1e980aa0e8f7ad0a323666 (diff) |
Move dev->driver over to being a pointer to a const struct, instead of stupidly
filling in a pre-allocated one on each attach.
Makes the code a bunch nicer, shrinks a kernel by about 1.5k on amd64,
helps with my sanity, and paves way for later changes.
Tested by a few for a couple of weeks now.
Diffstat (limited to 'sys')
34 files changed, 567 insertions, 584 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index b1126a9c8f3..6bf354fa31b 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -297,7 +297,7 @@ typedef struct drm_buf { int total; /* Buffer size */ int used; /* Amount of buffer in use (for DMA) */ unsigned long offset; /* Byte offset (used internally) */ - void *address; /* Byte offset (used internally) */ + void *address; /* KVA of buffer */ unsigned long bus_address; /* Bus address of buffer */ __volatile__ int pending; /* On hardware DMA queue */ struct drm_file *file_priv; /* Unique identifier of holding process */ @@ -471,8 +471,6 @@ struct drm_driver_info { int (*enable_vblank)(struct drm_device *, int); void (*disable_vblank)(struct drm_device *, int); - drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ - /** * Called by \c drm_device_is_agp. Typically used to determine if a * card is really attached to AGP or not. @@ -518,7 +516,7 @@ struct drm_driver_info { struct drm_device { struct device device; /* softc is an extension of struct device */ - struct drm_driver_info driver; + const struct drm_driver_info *driver; drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ u_int16_t pci_device; /* PCI device id */ diff --git a/sys/dev/pci/drm/drm_agpsupport.c b/sys/dev/pci/drm/drm_agpsupport.c index c8ea97384eb..f00cd9d92d0 100644 --- a/sys/dev/pci/drm/drm_agpsupport.c +++ b/sys/dev/pci/drm/drm_agpsupport.c @@ -42,13 +42,13 @@ void drm_agp_remove_entry(struct drm_device *, int drm_device_is_agp(struct drm_device *dev) { - if (dev->driver.device_is_agp != NULL) { + if (dev->driver->device_is_agp != NULL) { int ret; /* * device_is_agp returns a tristate, 0 = not AGP, 1 = definitely * AGP, 2 = fall back to PCI capability */ - ret = (*dev->driver.device_is_agp)(dev); + ret = (*dev->driver->device_is_agp)(dev); if (ret != DRM_MIGHT_BE_AGP) return (ret); } diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c index 7607a0d83ad..93adb5af7bd 100644 --- a/sys/dev/pci/drm/drm_bufs.c +++ b/sys/dev/pci/drm/drm_bufs.c @@ -483,7 +483,7 @@ drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request) buf->pending = 0; buf->file_priv = NULL; - buf->dev_private = drm_calloc(1, dev->driver.buf_priv_size, + buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size, DRM_MEM_BUFS); if (buf->dev_private == NULL) { /* Set count correctly so we free the proper amount. */ @@ -629,7 +629,7 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request) buf->file_priv = NULL; buf->dev_private = drm_calloc(1, - dev->driver.buf_priv_size, DRM_MEM_BUFS); + dev->driver->buf_priv_size, DRM_MEM_BUFS); if (buf->dev_private == NULL) { /* Set count so we free the proper amount. */ entry->buf_count = count; @@ -744,7 +744,7 @@ drm_do_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request) buf->pending = 0; buf->file_priv = NULL; - buf->dev_private = drm_calloc(1, dev->driver.buf_priv_size, + buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size, DRM_MEM_BUFS); if (buf->dev_private == NULL) { /* Set count correctly so we free the proper amount. */ @@ -968,8 +968,8 @@ 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 ((dev->driver->use_agp && (dma->flags & _DRM_DMA_USE_AGP)) || + (dev->driver->use_sg && (dma->flags & _DRM_DMA_USE_SG))) { drm_local_map_t *map = dev->agp_buffer_map; if (map == NULL) { diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c index 70edfbdd6fe..67538152db4 100644 --- a/sys/dev/pci/drm/drm_context.c +++ b/sys/dev/pci/drm/drm_context.c @@ -147,8 +147,8 @@ drm_addctx(struct drm_device *dev, void *data, struct drm_file *file_priv) return ENOMEM; } - if (dev->driver.context_ctor && ctx->handle != DRM_KERNEL_CONTEXT) - dev->driver.context_ctor(dev, ctx->handle); + if (dev->driver->context_ctor && ctx->handle != DRM_KERNEL_CONTEXT) + dev->driver->context_ctor(dev, ctx->handle); return 0; } @@ -171,8 +171,8 @@ drm_rmctx(struct drm_device *dev, void *data, struct drm_file *file_priv) DRM_DEBUG("%d\n", ctx->handle); if (ctx->handle != DRM_KERNEL_CONTEXT) { - if (dev->driver.context_dtor) - dev->driver.context_dtor(dev, ctx->handle); + if (dev->driver->context_dtor) + dev->driver->context_dtor(dev, ctx->handle); drm_ctxbitmap_free(dev, ctx->handle); } diff --git a/sys/dev/pci/drm/drm_dma.c b/sys/dev/pci/drm/drm_dma.c index c4012cc96c2..25309e56a93 100644 --- a/sys/dev/pci/drm/drm_dma.c +++ b/sys/dev/pci/drm/drm_dma.c @@ -70,7 +70,7 @@ drm_cleanup_buf(struct drm_device *dev, drm_buf_entry_t *entry) if (entry->buf_count) { for (i = 0; i < entry->buf_count; i++) { drm_free(entry->buflist[i].dev_private, - dev->driver.buf_priv_size, DRM_MEM_BUFS); + dev->driver->buf_priv_size, DRM_MEM_BUFS); } drm_free(entry->buflist, entry->buf_count * sizeof(*entry->buflist), DRM_MEM_BUFS); @@ -132,9 +132,9 @@ int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv) { - if (dev->driver.dma_ioctl) { + if (dev->driver->dma_ioctl) { /* shared code returns -errno */ - return -dev->driver.dma_ioctl(dev, data, file_priv); + return -dev->driver->dma_ioctl(dev, data, file_priv); } else { DRM_DEBUG("DMA ioctl on driver with no dma handler\n"); return EINVAL; diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 4b5755823fb..2c763c73b83 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -209,7 +209,6 @@ drm_attach(struct device *parent, struct device *kdev, id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), idlist); dev->id_entry = id_entry; - dev->driver.id_entry = id_entry; printf(" %s(%d)", id_entry->name, dev->unit); TAILQ_INIT(&dev->maplist); @@ -228,20 +227,20 @@ drm_attach(struct device *parent, struct device *kdev, goto error; } - if (dev->driver.load != NULL) { + if (dev->driver->load != NULL) { int retcode; /* Shared code returns -errno. */ - retcode = -dev->driver.load(dev, + retcode = -dev->driver->load(dev, dev->id_entry->driver_private); if (retcode != 0) goto error; } - if (dev->driver.use_agp) { + if (dev->driver->use_agp) { if (drm_device_is_agp(dev)) dev->agp = drm_agp_init(); - if (dev->driver.require_agp && dev->agp == NULL) { + if (dev->driver->require_agp && dev->agp == NULL) { printf(":couldn't find agp\n"); goto error; } @@ -256,8 +255,8 @@ drm_attach(struct device *parent, struct device *kdev, printf(": couldn't allocate memory for context bitmap.\n"); goto error; } - printf(", %d.%d.%d %s\n", dev->driver.major, dev->driver.minor, - dev->driver.patchlevel, dev->driver.date); + printf(", %d.%d.%d %s\n", dev->driver->major, dev->driver->minor, + dev->driver->patchlevel, dev->driver->date); return; @@ -289,8 +288,8 @@ drm_detach(struct device *self, int flags) dev->agp = NULL; } - if (dev->driver.unload != NULL) - dev->driver.unload(dev); + if (dev->driver->unload != NULL) + dev->driver->unload(dev); drm_mem_uninit(); return 0; @@ -336,10 +335,10 @@ drm_firstopen(struct drm_device *dev) if (i != 0) return i; - if (dev->driver.firstopen) - dev->driver.firstopen(dev); + if (dev->driver->firstopen) + dev->driver->firstopen(dev); - if (dev->driver.use_dma) { + if (dev->driver->use_dma) { i = drm_dma_setup(dev); if (i != 0) return i; @@ -366,8 +365,8 @@ drm_lastclose(struct drm_device *dev) DRM_DEBUG("\n"); - if (dev->driver.lastclose != NULL) - dev->driver.lastclose(dev); + if (dev->driver->lastclose != NULL) + dev->driver->lastclose(dev); if (dev->irq_enabled) drm_irq_uninstall(dev); @@ -430,13 +429,13 @@ drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv) return EFAULT; \ } - version->version_major = dev->driver.major; - version->version_minor = dev->driver.minor; - version->version_patchlevel = dev->driver.patchlevel; + version->version_major = dev->driver->major; + version->version_minor = dev->driver->minor; + version->version_patchlevel = dev->driver->patchlevel; - DRM_COPY(version->name, dev->driver.name); - DRM_COPY(version->date, dev->driver.date); - DRM_COPY(version->desc, dev->driver.desc); + DRM_COPY(version->name, dev->driver->name); + DRM_COPY(version->date, dev->driver->date); + DRM_COPY(version->desc, dev->driver->desc); return 0; } @@ -481,9 +480,9 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p) /* for compatibility root is always authenticated */ priv->authenticated = DRM_SUSER(p); - if (dev->driver.open) { + if (dev->driver->open) { /* shared code returns -errno */ - ret = -dev->driver.open(dev, priv); + ret = -dev->driver->open(dev, priv); if (ret != 0) { goto free_priv; } @@ -532,8 +531,8 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p) } DRM_UNLOCK(); - if (dev->driver.preclose != NULL) - dev->driver.preclose(dev, file_priv); + if (dev->driver->preclose != NULL) + dev->driver->preclose(dev, file_priv); DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", DRM_CURRENTPID, (long)&dev->device, dev->open_count); @@ -543,12 +542,12 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p) DRM_DEBUG("Process %d dead, freeing lock for context %d\n", 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); + if (dev->driver->reclaim_buffers_locked != NULL) + dev->driver->reclaim_buffers_locked(dev, file_priv); drm_lock_free(&dev->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - } else if (dev->driver.reclaim_buffers_locked != NULL && + } else if (dev->driver->reclaim_buffers_locked != NULL && dev->lock.hw_lock != NULL) { mtx_enter(&dev->lock.spinlock); /* The lock is required to reclaim buffers */ @@ -571,18 +570,18 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p) } mtx_leave(&dev->lock.spinlock); if (retcode == 0) { - dev->driver.reclaim_buffers_locked(dev, file_priv); + dev->driver->reclaim_buffers_locked(dev, file_priv); drm_lock_free(&dev->lock, DRM_KERNEL_CONTEXT); } } - if (dev->driver.use_dma && !dev->driver.reclaim_buffers_locked) + if (dev->driver->use_dma && !dev->driver->reclaim_buffers_locked) drm_reclaim_buffers(dev, file_priv); dev->buf_pgid = 0; - if (dev->driver.postclose != NULL) - dev->driver.postclose(dev, file_priv); + if (dev->driver->postclose != NULL) + dev->driver->postclose(dev, file_priv); DRM_LOCK(); TAILQ_REMOVE(&dev->files, file_priv, link); @@ -654,12 +653,12 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, if (ioctl->func == NULL && nr >= DRM_COMMAND_BASE) { /* The array entries begin at DRM_COMMAND_BASE ioctl nr */ nr -= DRM_COMMAND_BASE; - if (nr > dev->driver.max_ioctl) { + if (nr > dev->driver->max_ioctl) { DRM_DEBUG("Bad driver ioctl number, 0x%x (of 0x%x)\n", - nr, dev->driver.max_ioctl); + nr, dev->driver->max_ioctl); return EINVAL; } - ioctl = &dev->driver.ioctls[nr]; + ioctl = &dev->driver->ioctls[nr]; is_driver_ioctl = 1; } func = ioctl->func; diff --git a/sys/dev/pci/drm/drm_ioctl.c b/sys/dev/pci/drm/drm_ioctl.c index d351bf44f79..8d8bdf113e2 100644 --- a/sys/dev/pci/drm/drm_ioctl.c +++ b/sys/dev/pci/drm/drm_ioctl.c @@ -208,8 +208,8 @@ drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv) ver = *sv; sv->drm_di_major = DRM_IF_MAJOR; sv->drm_di_minor = DRM_IF_MINOR; - sv->drm_dd_major = dev->driver.major; - sv->drm_dd_minor = dev->driver.minor; + sv->drm_dd_major = dev->driver->major; + sv->drm_dd_minor = dev->driver->minor; if (ver.drm_di_major != -1) { if (ver.drm_di_major != DRM_IF_MAJOR || ver.drm_di_minor < 0 || @@ -227,9 +227,9 @@ drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv) } if (ver.drm_dd_major != -1) { - if (ver.drm_dd_major != dev->driver.major || + if (ver.drm_dd_major != dev->driver->major || ver.drm_dd_minor < 0 || - ver.drm_dd_minor > dev->driver.minor) + ver.drm_dd_minor > dev->driver->minor) { return EINVAL; } diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c index d3ab01c6df9..2e749dc58d6 100644 --- a/sys/dev/pci/drm/drm_irq.c +++ b/sys/dev/pci/drm/drm_irq.c @@ -66,7 +66,7 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS) struct drm_device *dev = (struct drm_device *)arg; DRM_SPINLOCK(&dev->irq_lock); - ret = dev->driver.irq_handler(arg); + ret = dev->driver->irq_handler(arg); DRM_SPINUNLOCK(&dev->irq_lock); return ret; @@ -95,7 +95,7 @@ drm_irq_install(struct drm_device *dev) mtx_init(&dev->irq_lock, IPL_BIO); /* Before installing handler */ - dev->driver.irq_preinstall(dev); + dev->driver->irq_preinstall(dev); /* Install handler */ if (pci_intr_map(&dev->pa, &ih) != 0) { @@ -112,7 +112,7 @@ drm_irq_install(struct drm_device *dev) DRM_DEBUG("%s: interrupting at %s\n", dev->device.dv_xname, istr); /* After installing handler */ - dev->driver.irq_postinstall(dev); + dev->driver->irq_postinstall(dev); return 0; err: @@ -138,7 +138,7 @@ drm_irq_uninstall(struct drm_device *dev) DRM_DEBUG("irq=%d\n", dev->irq); - dev->driver.irq_uninstall(dev); + dev->driver->irq_uninstall(dev); pci_intr_disestablish(dev->pa.pa_pc, dev->irqh); @@ -154,7 +154,7 @@ drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv) struct drm_control *ctl = data; /* Handle drivers who used to require IRQ setup no longer does. */ - if (!dev->driver.use_irq) + if (!dev->driver->use_irq) return (0); switch (ctl->func) { @@ -184,8 +184,8 @@ vblank_disable(void *arg) if (atomic_read(&dev->vblank[i].vbl_refcount) == 0 && dev->vblank[i].vbl_enabled) { dev->vblank[i].last_vblank = - dev->driver.get_vblank_counter(dev, i); - dev->driver.disable_vblank(dev, i); + dev->driver->get_vblank_counter(dev, i); + dev->driver->disable_vblank(dev, i); dev->vblank[i].vbl_enabled = 0; } } @@ -247,7 +247,7 @@ drm_update_vblank_count(struct drm_device *dev, int crtc) * note that we may have lost a full dev->max_vblank_count events if * the register is small or the interrupts were off for a long time. */ - cur_vblank = dev->driver.get_vblank_counter(dev, crtc); + cur_vblank = dev->driver->get_vblank_counter(dev, crtc); diff = cur_vblank - dev->vblank[crtc].last_vblank; if (cur_vblank < dev->vblank[crtc].last_vblank) diff += dev->max_vblank_count; @@ -265,7 +265,7 @@ drm_vblank_get(struct drm_device *dev, int crtc) atomic_add(1, &dev->vblank[crtc].vbl_refcount); if (dev->vblank[crtc].vbl_refcount == 1 && dev->vblank[crtc].vbl_enabled == 0) { - ret = dev->driver.enable_vblank(dev, crtc); + ret = dev->driver->enable_vblank(dev, crtc); if (ret) { atomic_dec(&dev->vblank[crtc].vbl_refcount); } else { diff --git a/sys/dev/pci/drm/drm_lock.c b/sys/dev/pci/drm/drm_lock.c index 9519cb137eb..de4fa1dd38c 100644 --- a/sys/dev/pci/drm/drm_lock.c +++ b/sys/dev/pci/drm/drm_lock.c @@ -118,7 +118,7 @@ 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 (dev->driver->use_dma_queue && lock->context < 0) return EINVAL; mtx_enter(&dev->lock.spinlock); @@ -143,9 +143,9 @@ drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) /* XXX: Add signal blocking here */ - if (dev->driver.dma_quiescent != NULL && + if (dev->driver->dma_quiescent != NULL && (lock->flags & _DRM_LOCK_QUIESCENT)) - dev->driver.dma_quiescent(dev); + dev->driver->dma_quiescent(dev); return 0; } diff --git a/sys/dev/pci/drm/i915_dma.c b/sys/dev/pci/drm/i915_dma.c index 55ca786db74..d55877a974b 100644 --- a/sys/dev/pci/drm/i915_dma.c +++ b/sys/dev/pci/drm/i915_dma.c @@ -247,7 +247,7 @@ static int i915_dma_resume(struct drm_device * dev) return 0; } -static int i915_dma_init(struct drm_device *dev, void *data, +int i915_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_init_t *init = data; @@ -634,7 +634,7 @@ int i915_quiescent(struct drm_device *dev) return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); } -static int i915_flush_ioctl(struct drm_device *dev, void *data, +int i915_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -643,7 +643,7 @@ static int i915_flush_ioctl(struct drm_device *dev, void *data, return i915_quiescent(dev); } -static int i915_batchbuffer(struct drm_device *dev, void *data, +int i915_batchbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -676,7 +676,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data, return ret; } -static int i915_cmdbuffer(struct drm_device *dev, void *data, +int i915_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -739,7 +739,7 @@ static int i915_do_cleanup_pageflip(struct drm_device * dev) return 0; } -static int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *file_priv) +int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_flip_t *param = data; @@ -760,7 +760,7 @@ static int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *f } -static int i915_getparam(struct drm_device *dev, void *data, +int i915_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = dev->dev_private; @@ -798,7 +798,7 @@ static int i915_getparam(struct drm_device *dev, void *data, return 0; } -static int i915_setparam(struct drm_device *dev, void *data, +int i915_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = dev->dev_private; @@ -836,7 +836,7 @@ drm_i915_mmio_entry_t mmio_table[] = { static int mmio_table_size = sizeof(mmio_table)/sizeof(drm_i915_mmio_entry_t); -static int i915_mmio(struct drm_device *dev, void *data, +int i915_mmio(struct drm_device *dev, void *data, struct drm_file *file_priv) { uint32_t buf[8]; @@ -883,7 +883,7 @@ static int i915_mmio(struct drm_device *dev, void *data, return 0; } -static int i915_set_status_page(struct drm_device *dev, void *data, +int i915_set_status_page(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = dev->dev_private; @@ -1012,28 +1012,6 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) i915_mem_release(dev, file_priv, dev_priv->agp_heap); } -struct drm_ioctl_desc i915_ioctls[] = { - DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), - DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), - DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), - DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), -}; - -int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); /** * Determine if the device really is AGP or not. diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c index 191f3105124..a089a29364d 100644 --- a/sys/dev/pci/drm/i915_drv.c +++ b/sys/dev/pci/drm/i915_drv.c @@ -35,45 +35,62 @@ #include "i915_drv.h" #include "drm_pciids.h" -void i915_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t i915_pciidlist[] = { i915_PCI_IDS }; -void -i915_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = 1; /* No dev_priv */ - dev->driver.load = i915_driver_load; - dev->driver.preclose = i915_driver_preclose; - dev->driver.lastclose = i915_driver_lastclose; - dev->driver.device_is_agp = i915_driver_device_is_agp; - dev->driver.get_vblank_counter = i915_get_vblank_counter; - dev->driver.enable_vblank = i915_enable_vblank; - dev->driver.disable_vblank = i915_disable_vblank; - dev->driver.irq_preinstall = i915_driver_irq_preinstall; - dev->driver.irq_postinstall = i915_driver_irq_postinstall; - dev->driver.irq_uninstall = i915_driver_irq_uninstall; - dev->driver.irq_handler = i915_driver_irq_handler; - - dev->driver.ioctls = i915_ioctls; - dev->driver.max_ioctl = i915_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc i915_ioctls[] = { + DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), + DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), + DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), + DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), +}; + +static const struct drm_driver_info i915_driver = { + .buf_priv_size = 1, /* No dev_priv */ + .load = i915_driver_load, + .preclose = i915_driver_preclose, + .lastclose = i915_driver_lastclose, + .device_is_agp = i915_driver_device_is_agp, + .get_vblank_counter = i915_get_vblank_counter, + .enable_vblank = i915_enable_vblank, + .disable_vblank = i915_disable_vblank, + .irq_preinstall = i915_driver_irq_preinstall, + .irq_postinstall = i915_driver_irq_postinstall, + .irq_uninstall = i915_driver_irq_uninstall, + .irq_handler = i915_driver_irq_handler, + + .ioctls = i915_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(i915_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .require_agp = 1, + .use_mtrr = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -140,7 +157,7 @@ i915drm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - i915_configure(dev); + dev->driver = &i915_driver; drm_attach(parent, self, pa, i915_pciidlist); } diff --git a/sys/dev/pci/drm/i915_drv.h b/sys/dev/pci/drm/i915_drv.h index 2f2da9365d7..f7d255cb5ec 100644 --- a/sys/dev/pci/drm/i915_drv.h +++ b/sys/dev/pci/drm/i915_drv.h @@ -245,9 +245,6 @@ enum intel_chip_family { CHIP_I965 = 0x08, }; -extern struct drm_ioctl_desc i915_ioctls[]; -extern int i915_max_ioctl; - /* i915_dma.c */ extern void i915_kernel_lost_context(struct drm_device * dev); extern int i915_driver_load(struct drm_device *, unsigned long flags); @@ -323,6 +320,17 @@ extern void intel_fini_chipset_flush_compat(struct drm_device *dev); #endif #endif +/* ioctls */ +extern int i915_dma_init(struct drm_device *, void *, struct drm_file *); +extern int i915_flush_ioctl(struct drm_device *, void *, struct drm_file *); +extern int i915_batchbuffer(struct drm_device *, void *, struct drm_file *); +extern int i915_flip_bufs(struct drm_device *, void *, struct drm_file *); +extern int i915_getparam(struct drm_device *, void *, struct drm_file *); +extern int i915_setparam(struct drm_device *, void *, struct drm_file *); +extern int i915_cmdbuffer(struct drm_device *, void *, struct drm_file *); +extern int i915_mmio(struct drm_device *, void *, struct drm_file *); +extern int i915_set_status_page(struct drm_device *, void *, struct drm_file *); + #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg)) #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val)) #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg)) diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c index 085a0de16bc..b6f81bce0dc 100644 --- a/sys/dev/pci/drm/mach64_drv.c +++ b/sys/dev/pci/drm/mach64_drv.c @@ -39,44 +39,58 @@ #include "mach64_drv.h" #include "drm_pciids.h" -void mach64_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mach64_pciidlist[] = { mach64_PCI_IDS }; -void -mach64_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = 1; /* No dev_priv */ - dev->driver.lastclose = mach64_driver_lastclose; - dev->driver.get_vblank_counter = mach64_get_vblank_counter; - dev->driver.enable_vblank = mach64_enable_vblank; - dev->driver.disable_vblank = mach64_disable_vblank; - dev->driver.irq_preinstall = mach64_driver_irq_preinstall; - dev->driver.irq_postinstall = mach64_driver_irq_postinstall; - dev->driver.irq_uninstall = mach64_driver_irq_uninstall; - dev->driver.irq_handler = mach64_driver_irq_handler; - dev->driver.dma_ioctl = mach64_dma_buffers; - - dev->driver.ioctls = mach64_ioctls; - dev->driver.max_ioctl = mach64_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +/* Interface history: + * + * 1.0 - Initial mach64 DRM + * + */ +struct drm_ioctl_desc mach64_ioctls[] = { + DRM_IOCTL_DEF(DRM_MACH64_INIT, mach64_dma_init, + DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_MACH64_CLEAR, mach64_dma_clear, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_SWAP, mach64_dma_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_IDLE, mach64_dma_idle, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_RESET, mach64_engine_reset, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_VERTEX, mach64_dma_vertex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_BLIT, mach64_dma_blit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_FLUSH, mach64_dma_flush, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MACH64_GETPARAM, mach64_get_param, DRM_AUTH), +}; + +static const struct drm_driver_info mach64_driver = { + .buf_priv_size = 1, /* No dev_priv */ + .lastclose = mach64_driver_lastclose, + .get_vblank_counter = mach64_get_vblank_counter, + .enable_vblank = mach64_enable_vblank, + .disable_vblank = mach64_disable_vblank, + .irq_preinstall = mach64_driver_irq_preinstall, + .irq_postinstall = mach64_driver_irq_postinstall, + .irq_uninstall = mach64_driver_irq_uninstall, + .irq_handler = mach64_driver_irq_handler, + .dma_ioctl = mach64_dma_buffers, + + .ioctls = mach64_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(mach64_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, + .use_pci_dma = 1, + .use_dma = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -139,7 +153,8 @@ mach64drm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - mach64_configure(dev); + dev->driver = &mach64_driver; + return drm_attach(parent, self, pa, mach64_pciidlist); } diff --git a/sys/dev/pci/drm/mach64_drv.h b/sys/dev/pci/drm/mach64_drv.h index fb8a772454d..9eac32a32db 100644 --- a/sys/dev/pci/drm/mach64_drv.h +++ b/sys/dev/pci/drm/mach64_drv.h @@ -110,9 +110,6 @@ typedef struct drm_mach64_private { drm_local_map_t *agp_textures; } drm_mach64_private_t; -extern struct drm_ioctl_desc mach64_ioctls[]; -extern int mach64_max_ioctl; - /* mach64_dma.c */ extern int mach64_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/sys/dev/pci/drm/mach64_state.c b/sys/dev/pci/drm/mach64_state.c index c82f38bb2a5..a58c7694064 100644 --- a/sys/dev/pci/drm/mach64_state.c +++ b/sys/dev/pci/drm/mach64_state.c @@ -35,25 +35,6 @@ #include "mach64_drm.h" #include "mach64_drv.h" -/* Interface history: - * - * 1.0 - Initial mach64 DRM - * - */ -struct drm_ioctl_desc mach64_ioctls[] = { - DRM_IOCTL_DEF(DRM_MACH64_INIT, mach64_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_MACH64_CLEAR, mach64_dma_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_SWAP, mach64_dma_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_IDLE, mach64_dma_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_RESET, mach64_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_VERTEX, mach64_dma_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_BLIT, mach64_dma_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_FLUSH, mach64_dma_flush, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_GETPARAM, mach64_get_param, DRM_AUTH), -}; - -int mach64_max_ioctl = DRM_ARRAY_SIZE(mach64_ioctls); - /* ================================================================ * DMA hardware state programming functions */ diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c index c1de2ae714b..6501e54a154 100644 --- a/sys/dev/pci/drm/mga_drv.c +++ b/sys/dev/pci/drm/mga_drv.c @@ -38,7 +38,6 @@ #include "drm_pciids.h" int mga_driver_device_is_agp(struct drm_device * ); -void mga_configure(struct drm_device *); /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mga_pciidlist[] = { @@ -91,43 +90,56 @@ mga_driver_device_is_agp(struct drm_device * dev) } -void -mga_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = sizeof(drm_mga_buf_priv_t); - dev->driver.load = mga_driver_load; - dev->driver.unload = mga_driver_unload; - dev->driver.lastclose = mga_driver_lastclose; - dev->driver.enable_vblank = mga_enable_vblank; - dev->driver.disable_vblank = mga_disable_vblank; - dev->driver.get_vblank_counter = mga_get_vblank_counter; - dev->driver.irq_preinstall = mga_driver_irq_preinstall; - dev->driver.irq_postinstall = mga_driver_irq_postinstall; - dev->driver.irq_uninstall = mga_driver_irq_uninstall; - dev->driver.irq_handler = mga_driver_irq_handler; - dev->driver.dma_ioctl = mga_dma_buffers; - dev->driver.dma_quiescent = mga_driver_dma_quiescent; - dev->driver.device_is_agp = mga_driver_device_is_agp; - - dev->driver.ioctls = mga_ioctls; - dev->driver.max_ioctl = mga_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc mga_ioctls[] = { + DRM_IOCTL_DEF(DRM_MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_MGA_FLUSH, mga_dma_flush, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_RESET, mga_dma_reset, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_SWAP, mga_dma_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_CLEAR, mga_dma_clear, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_VERTEX, mga_dma_vertex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_INDICES, mga_dma_indices, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_ILOAD, mga_dma_iload, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_BLIT, mga_dma_blit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_GETPARAM, mga_getparam, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_SET_FENCE, mga_set_fence, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH), + DRM_IOCTL_DEF(DRM_MGA_DMA_BOOTSTRAP, mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), +}; +static const struct drm_driver_info mga_driver = { + .buf_priv_size = sizeof(drm_mga_buf_priv_t), + .load = mga_driver_load, + .unload = mga_driver_unload, + .lastclose = mga_driver_lastclose, + .enable_vblank = mga_enable_vblank, + .disable_vblank = mga_disable_vblank, + .get_vblank_counter = mga_get_vblank_counter, + .irq_preinstall = mga_driver_irq_preinstall, + .irq_postinstall = mga_driver_irq_postinstall, + .irq_uninstall = mga_driver_irq_uninstall, + .irq_handler = mga_driver_irq_handler, + .dma_ioctl = mga_dma_buffers, + .dma_quiescent = mga_driver_dma_quiescent, + .device_is_agp = mga_driver_device_is_agp, + + .ioctls = mga_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(mga_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .require_agp = 1, + .use_mtrr = 1, + .use_dma = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -189,7 +201,7 @@ mgadrm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - mga_configure(dev); + dev->driver = &mga_driver; return drm_attach(parent, self, pa, mga_pciidlist); } diff --git a/sys/dev/pci/drm/mga_drv.h b/sys/dev/pci/drm/mga_drv.h index bf3be808297..23f9544162d 100644 --- a/sys/dev/pci/drm/mga_drv.h +++ b/sys/dev/pci/drm/mga_drv.h @@ -149,9 +149,6 @@ typedef struct drm_mga_private { unsigned int agp_size; } drm_mga_private_t; -extern struct drm_ioctl_desc mga_ioctls[]; -extern int mga_max_ioctl; - /* mga_dma.c */ extern int mga_dma_bootstrap(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -167,6 +164,15 @@ extern int mga_driver_load(struct drm_device *dev, unsigned long flags); extern int mga_driver_unload(struct drm_device * dev); extern void mga_driver_lastclose(struct drm_device * dev); extern int mga_driver_dma_quiescent(struct drm_device * dev); +extern int mga_dma_swap(struct drm_device *, void *, struct drm_file *); +extern int mga_dma_clear(struct drm_device *, void *, struct drm_file *); +extern int mga_dma_vertex(struct drm_device *, void *, struct drm_file *); +extern int mga_dma_indices(struct drm_device *, void *, struct drm_file *); +extern int mga_dma_iload(struct drm_device *, void *, struct drm_file *); +extern int mga_dma_blit(struct drm_device *, void *, struct drm_file *); +extern int mga_getparam(struct drm_device *, void *, struct drm_file *); +extern int mga_set_fence(struct drm_device *, void *, struct drm_file *); +extern int mga_wait_fence(struct drm_device *, void *, struct drm_file *); extern int mga_do_wait_for_idle(drm_mga_private_t * dev_priv); diff --git a/sys/dev/pci/drm/mga_state.c b/sys/dev/pci/drm/mga_state.c index 2da108beefd..e467856e8e9 100644 --- a/sys/dev/pci/drm/mga_state.c +++ b/sys/dev/pci/drm/mga_state.c @@ -861,7 +861,7 @@ static void mga_dma_dispatch_blit(struct drm_device * dev, drm_mga_blit_t * blit * */ -static int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -883,7 +883,7 @@ static int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *fi return 0; } -static int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -904,7 +904,7 @@ static int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *fil return 0; } -static int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -939,7 +939,7 @@ static int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *f return 0; } -static int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -974,7 +974,7 @@ static int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file * return 0; } -static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_device_dma *dma = dev->dma; drm_mga_private_t *dev_priv = dev->dev_private; @@ -1014,7 +1014,7 @@ static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *fi return 0; } -static int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -1040,7 +1040,7 @@ static int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *fil return 0; } -static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_getparam_t *param = data; @@ -1072,7 +1072,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil return 0; } -static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; u32 *fence = data; @@ -1102,7 +1102,7 @@ static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *fi return 0; } -static int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file *file_priv) +int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_mga_private_t *dev_priv = dev->dev_private; u32 *fence = data; @@ -1118,22 +1118,3 @@ static int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file *f return 0; } - -struct drm_ioctl_desc mga_ioctls[] = { - DRM_IOCTL_DEF(DRM_MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_MGA_FLUSH, mga_dma_flush, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_RESET, mga_dma_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_SWAP, mga_dma_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_CLEAR, mga_dma_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_VERTEX, mga_dma_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_INDICES, mga_dma_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_ILOAD, mga_dma_iload, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_BLIT, mga_dma_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_GETPARAM, mga_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_SET_FENCE, mga_set_fence, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_DMA_BOOTSTRAP, mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - -}; - -int mga_max_ioctl = DRM_ARRAY_SIZE(mga_ioctls); diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c index 2942e8ad5c2..3c3b1b0ee57 100644 --- a/sys/dev/pci/drm/r128_drv.c +++ b/sys/dev/pci/drm/r128_drv.c @@ -37,46 +37,62 @@ #include "r128_drv.h" #include "drm_pciids.h" -void r128_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t r128_pciidlist[] = { r128_PCI_IDS }; -void -r128_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = sizeof(drm_r128_buf_priv_t); - dev->driver.preclose = r128_driver_preclose; - dev->driver.lastclose = r128_driver_lastclose; - dev->driver.get_vblank_counter = r128_get_vblank_counter; - dev->driver.enable_vblank = r128_enable_vblank; - dev->driver.disable_vblank = r128_disable_vblank; - dev->driver.irq_preinstall = r128_driver_irq_preinstall; - dev->driver.irq_postinstall = r128_driver_irq_postinstall; - dev->driver.irq_uninstall = r128_driver_irq_uninstall; - dev->driver.irq_handler = r128_driver_irq_handler; - dev->driver.dma_ioctl = r128_cce_buffers; - - dev->driver.ioctls = r128_ioctls; - dev->driver.max_ioctl = r128_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc r128_ioctls[] = { + DRM_IOCTL_DEF(DRM_R128_INIT, r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_R128_CCE_START, r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_R128_CCE_STOP, r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_R128_CCE_RESET, r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_R128_CCE_IDLE, r128_cce_idle, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_RESET, r128_engine_reset, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_FULLSCREEN, r128_fullscreen, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_SWAP, r128_cce_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_FLIP, r128_cce_flip, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_CLEAR, r128_cce_clear, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_VERTEX, r128_cce_vertex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_INDICES, r128_cce_indices, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_BLIT, r128_cce_blit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_DEPTH, r128_cce_depth, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_STIPPLE, r128_cce_stipple, DRM_AUTH), + DRM_IOCTL_DEF(DRM_R128_INDIRECT, r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_R128_GETPARAM, r128_getparam, DRM_AUTH), +}; + +static const struct drm_driver_info r128_driver = { + .buf_priv_size = sizeof(drm_r128_buf_priv_t), + .preclose = r128_driver_preclose, + .lastclose = r128_driver_lastclose, + .get_vblank_counter = r128_get_vblank_counter, + .enable_vblank = r128_enable_vblank, + .disable_vblank = r128_disable_vblank, + .irq_preinstall = r128_driver_irq_preinstall, + .irq_postinstall = r128_driver_irq_postinstall, + .irq_uninstall = r128_driver_irq_uninstall, + .irq_handler = r128_driver_irq_handler, + .dma_ioctl = r128_cce_buffers, + + .ioctls = r128_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(r128_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, + .use_pci_dma = 1, + .use_sg = 1, + .use_dma = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -139,7 +155,7 @@ r128drm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - r128_configure(dev); + dev->driver = &r128_driver; return drm_attach(parent, self, pa, r128_pciidlist); } diff --git a/sys/dev/pci/drm/r128_drv.h b/sys/dev/pci/drm/r128_drv.h index ab8b6297ce9..bb4ebe019d0 100644 --- a/sys/dev/pci/drm/r128_drv.h +++ b/sys/dev/pci/drm/r128_drv.h @@ -131,9 +131,6 @@ typedef struct drm_r128_buf_priv { drm_r128_freelist_t *list_entry; } drm_r128_buf_priv_t; -extern struct drm_ioctl_desc r128_ioctls[]; -extern int r128_max_ioctl; - /* r128_cce.c */ extern int r128_cce_init(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -143,6 +140,16 @@ extern int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *fi extern int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv); extern void r128_freelist_reset(struct drm_device * dev); diff --git a/sys/dev/pci/drm/r128_state.c b/sys/dev/pci/drm/r128_state.c index 51a9afce7b9..6cb64880491 100644 --- a/sys/dev/pci/drm/r128_state.c +++ b/sys/dev/pci/drm/r128_state.c @@ -1241,7 +1241,7 @@ static void r128_cce_dispatch_stipple(struct drm_device * dev, u32 * stipple) * IOCTL functions */ -static int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -1305,7 +1305,7 @@ static int r128_do_cleanup_pageflip(struct drm_device * dev) * They can & should be intermixed to support multiple 3d windows. */ -static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); @@ -1323,7 +1323,7 @@ static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *fi return 0; } -static int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -1344,7 +1344,7 @@ static int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *fi return 0; } -static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -1399,7 +1399,7 @@ static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file * return 0; } -static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -1467,7 +1467,7 @@ static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file return 0; } -static int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_device_dma *dma = dev->dma; drm_r128_private_t *dev_priv = dev->dev_private; @@ -1493,7 +1493,7 @@ static int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *fi return ret; } -static int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_depth_t *depth = data; @@ -1523,7 +1523,7 @@ static int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *f return ret; } -static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_stipple_t *stipple = data; @@ -1542,7 +1542,7 @@ static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file return 0; } -static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -1614,7 +1614,7 @@ static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file return 0; } -static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) +int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_getparam_t *param = data; @@ -1657,25 +1657,3 @@ void r128_driver_lastclose(struct drm_device * dev) { r128_do_cleanup_cce(dev); } - -struct drm_ioctl_desc r128_ioctls[] = { - DRM_IOCTL_DEF(DRM_R128_INIT, r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_START, r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_STOP, r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_RESET, r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_IDLE, r128_cce_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_RESET, r128_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_FULLSCREEN, r128_fullscreen, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_SWAP, r128_cce_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_FLIP, r128_cce_flip, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_CLEAR, r128_cce_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_VERTEX, r128_cce_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_INDICES, r128_cce_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_BLIT, r128_cce_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_DEPTH, r128_cce_depth, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_STIPPLE, r128_cce_stipple, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_INDIRECT, r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_GETPARAM, r128_getparam, DRM_AUTH), -}; - -int r128_max_ioctl = DRM_ARRAY_SIZE(r128_ioctls); diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c index a98239cbac2..48938b607d2 100644 --- a/sys/dev/pci/drm/radeon_drv.c +++ b/sys/dev/pci/drm/radeon_drv.c @@ -35,8 +35,6 @@ #include "radeon_drv.h" #include "drm_pciids.h" -void radeon_configure(struct drm_device *); - int radeon_no_wb; /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ @@ -44,44 +42,72 @@ static drm_pci_id_list_t radeon_pciidlist[] = { radeon_PCI_IDS }; -void -radeon_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = sizeof(drm_radeon_buf_priv_t); - dev->driver.load = radeon_driver_load; - dev->driver.unload = radeon_driver_unload; - dev->driver.firstopen = radeon_driver_firstopen; - dev->driver.open = radeon_driver_open; - dev->driver.preclose = radeon_driver_preclose; - dev->driver.postclose = radeon_driver_postclose; - dev->driver.lastclose = radeon_driver_lastclose; - dev->driver.get_vblank_counter = radeon_get_vblank_counter; - dev->driver.enable_vblank = radeon_enable_vblank; - dev->driver.disable_vblank = radeon_disable_vblank; - dev->driver.irq_preinstall = radeon_driver_irq_preinstall; - dev->driver.irq_postinstall = radeon_driver_irq_postinstall; - dev->driver.irq_uninstall = radeon_driver_irq_uninstall; - dev->driver.irq_handler = radeon_driver_irq_handler; - dev->driver.dma_ioctl = radeon_cp_buffers; - - dev->driver.ioctls = radeon_ioctls; - dev->driver.max_ioctl = radeon_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc radeon_ioctls[] = { + DRM_IOCTL_DEF(DRM_RADEON_CP_INIT, radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_CP_START, radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_CP_STOP, radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_CP_RESET, radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_CP_IDLE, radeon_cp_idle, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_CP_RESUME, radeon_cp_resume, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_RESET, radeon_engine_reset, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_FULLSCREEN, radeon_fullscreen, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_SWAP, radeon_cp_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_CLEAR, radeon_cp_clear, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_VERTEX, radeon_cp_vertex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_INDICES, radeon_cp_indices, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_TEXTURE, radeon_cp_texture, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_STIPPLE, radeon_cp_stipple, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_INDIRECT, radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_VERTEX2, radeon_cp_vertex2, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_CMDBUF, radeon_cp_cmdbuf, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_GETPARAM, radeon_cp_getparam, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_FLIP, radeon_cp_flip, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_ALLOC, radeon_mem_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_FREE, radeon_mem_free, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_INIT_HEAP, radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_RADEON_IRQ_EMIT, radeon_irq_emit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH) +}; + +static const struct drm_driver_info radeon_driver = { + .buf_priv_size = sizeof(drm_radeon_buf_priv_t), + .load = radeon_driver_load, + .unload = radeon_driver_unload, + .firstopen = radeon_driver_firstopen, + .open = radeon_driver_open, + .preclose = radeon_driver_preclose, + .postclose = radeon_driver_postclose, + .lastclose = radeon_driver_lastclose, + .get_vblank_counter = radeon_get_vblank_counter, + .enable_vblank = radeon_enable_vblank, + .disable_vblank = radeon_disable_vblank, + .irq_preinstall = radeon_driver_irq_preinstall, + .irq_postinstall = radeon_driver_irq_postinstall, + .irq_uninstall = radeon_driver_irq_uninstall, + .irq_handler = radeon_driver_irq_handler, + .dma_ioctl = radeon_cp_buffers, + + .ioctls = radeon_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, + .use_pci_dma = 1, + .use_sg = 1, + .use_dma = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -144,7 +170,7 @@ radeondrm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - radeon_configure(dev); + dev->driver = &radeon_driver; return drm_attach(parent, self, pa, radeon_pciidlist); } diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h index 65569db9bb9..d53d377d698 100644 --- a/sys/dev/pci/drm/radeon_drv.h +++ b/sys/dev/pci/drm/radeon_drv.h @@ -328,8 +328,6 @@ typedef struct drm_radeon_kcmd_buffer { } drm_radeon_kcmd_buffer_t; extern int radeon_no_wb; -extern struct drm_ioctl_desc radeon_ioctls[]; -extern int radeon_max_ioctl; /* Check whether the given hardware address is inside the framebuffer or the * GART area. @@ -358,6 +356,21 @@ extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv); +extern int radeon_surface_alloc(struct drm_device *, void *, struct drm_file *); +extern int radeon_surface_free(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_swap(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_clear(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_vertex(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_indices(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_texture(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_flip(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_stipple(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_indirect(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_vertex2(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_cmdbuf(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_getparam(struct drm_device *, void *, struct drm_file *); +extern int radeon_cp_setparam(struct drm_device *, void *, struct drm_file *); + extern void radeon_freelist_reset(struct drm_device * dev); extern struct drm_buf *radeon_freelist_get(struct drm_device * dev); diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c index 4327cbd1329..81e8eb5458d 100644 --- a/sys/dev/pci/drm/radeon_state.c +++ b/sys/dev/pci/drm/radeon_state.c @@ -2091,7 +2091,7 @@ static void radeon_surfaces_release(struct drm_file *file_priv, /* ================================================================ * IOCTL functions */ -static int radeon_surface_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_surface_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_surface_alloc_t *alloc = data; @@ -2107,7 +2107,7 @@ static int radeon_surface_alloc(struct drm_device *dev, void *data, struct drm_f return 0; } -static int radeon_surface_free(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_surface_free(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_surface_free_t *memfree = data; @@ -2123,7 +2123,7 @@ static int radeon_surface_free(struct drm_device *dev, void *data, struct drm_fi return 0; } -static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -2178,7 +2178,7 @@ static int radeon_do_init_pageflip(struct drm_device * dev) /* Swapping and flipping are different operations, need different ioctls. * They can & should be intermixed to support multiple 3d windows. */ -static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); @@ -2196,7 +2196,7 @@ static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *f return 0; } -static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -2216,7 +2216,7 @@ static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *f return 0; } -static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_sarea_t *sarea_priv; @@ -2299,7 +2299,7 @@ static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file return 0; } -static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_sarea_t *sarea_priv; @@ -2393,7 +2393,7 @@ static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file return 0; } -static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_texture_t *tex = data; @@ -2420,7 +2420,7 @@ static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file return ret; } -static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_stipple_t *stipple = data; @@ -2439,7 +2439,7 @@ static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file return 0; } -static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -2509,7 +2509,7 @@ static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_fil return 0; } -static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_sarea_t *sarea_priv; @@ -2851,7 +2851,7 @@ static int radeon_emit_wait(struct drm_device * dev, int flags) return 0; } -static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; struct drm_device_dma *dma = dev->dma; @@ -3019,7 +3019,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file return -EINVAL; } -static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_getparam_t *param = data; @@ -3113,7 +3113,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil return 0; } -static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) +int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_setparam_t *sp = data; @@ -3231,35 +3231,3 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv) drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); } - -struct drm_ioctl_desc radeon_ioctls[] = { - DRM_IOCTL_DEF(DRM_RADEON_CP_INIT, radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_START, radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_STOP, radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_RESET, radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_IDLE, radeon_cp_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CP_RESUME, radeon_cp_resume, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_RESET, radeon_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FULLSCREEN, radeon_fullscreen, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SWAP, radeon_cp_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CLEAR, radeon_cp_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_VERTEX, radeon_cp_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INDICES, radeon_cp_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_TEXTURE, radeon_cp_texture, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_STIPPLE, radeon_cp_stipple, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INDIRECT, radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_VERTEX2, radeon_cp_vertex2, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CMDBUF, radeon_cp_cmdbuf, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_GETPARAM, radeon_cp_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FLIP, radeon_cp_flip, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_ALLOC, radeon_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FREE, radeon_mem_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INIT_HEAP, radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_IRQ_EMIT, radeon_irq_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH) -}; - -int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls); diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c index c4fe2819500..2b6bb0f24f4 100644 --- a/sys/dev/pci/drm/savage_bci.c +++ b/sys/dev/pci/drm/savage_bci.c @@ -926,7 +926,7 @@ static int savage_do_cleanup_bci(struct drm_device *dev) return 0; } -static int savage_bci_init(struct drm_device *dev, void *data, struct drm_file *file_priv) +int savage_bci_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_savage_init_t *init = data; @@ -942,7 +942,7 @@ static int savage_bci_init(struct drm_device *dev, void *data, struct drm_file * return -EINVAL; } -static int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) +int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_savage_private_t *dev_priv = dev->dev_private; drm_savage_event_emit_t *event = data; @@ -957,7 +957,7 @@ static int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_ return 0; } -static int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) +int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_savage_private_t *dev_priv = dev->dev_private; drm_savage_event_wait_t *event = data; @@ -1080,12 +1080,3 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) drm_core_reclaim_buffers(dev, file_priv); } - -struct drm_ioctl_desc savage_ioctls[] = { - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH), -}; - -int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c index 5beab274b57..56bee7f35aa 100644 --- a/sys/dev/pci/drm/savage_drv.c +++ b/sys/dev/pci/drm/savage_drv.c @@ -32,39 +32,44 @@ #include "savage_drv.h" #include "drm_pciids.h" -void savage_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t savage_pciidlist[] = { savage_PCI_IDS }; -void -savage_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t); - dev->driver.load = savage_driver_load; - dev->driver.firstopen = savage_driver_firstopen; - dev->driver.lastclose = savage_driver_lastclose; - dev->driver.unload = savage_driver_unload; - dev->driver.reclaim_buffers_locked = savage_reclaim_buffers; - dev->driver.dma_ioctl = savage_bci_buffers; - - dev->driver.ioctls = savage_ioctls; - dev->driver.max_ioctl = savage_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc savage_ioctls[] = { + DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH), +}; + +int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); + +static const struct drm_driver_info savage_driver = { + .buf_priv_size = sizeof(drm_savage_buf_priv_t), + .load = savage_driver_load, + .firstopen = savage_driver_firstopen, + .lastclose = savage_driver_lastclose, + .unload = savage_driver_unload, + .reclaim_buffers_locked = savage_reclaim_buffers, + .dma_ioctl = savage_bci_buffers, + + .ioctls = savage_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(savage_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, + .use_pci_dma = 1, + .use_dma = 1, +}; #ifdef __FreeBSD__ static int @@ -127,7 +132,7 @@ savagedrm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - savage_configure(dev); + dev->driver = &savage_driver; return drm_attach(parent, self, pa, savage_pciidlist); } diff --git a/sys/dev/pci/drm/savage_drv.h b/sys/dev/pci/drm/savage_drv.h index b9124b1ac94..0ff36178178 100644 --- a/sys/dev/pci/drm/savage_drv.h +++ b/sys/dev/pci/drm/savage_drv.h @@ -104,9 +104,6 @@ enum savage_family { S3_LAST }; -extern struct drm_ioctl_desc savage_ioctls[]; -extern int savage_max_ioctl; - #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) #define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) \ @@ -199,6 +196,9 @@ typedef struct drm_savage_private { /* ioctls */ extern int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int savage_bci_init(struct drm_device *, void *, struct drm_file *); +extern int savage_bci_event_emit(struct drm_device *, void *, struct drm_file *); +extern int savage_bci_event_wait(struct drm_device *, void *, struct drm_file *); /* BCI functions */ extern uint16_t savage_bci_emit_event(drm_savage_private_t *dev_priv, diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c index ccf9248d0aa..14c3d505ddf 100644 --- a/sys/dev/pci/drm/sis_drv.c +++ b/sys/dev/pci/drm/sis_drv.c @@ -31,33 +31,40 @@ #include "sis_drv.h" #include "drm_pciids.h" -void sis_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t sis_pciidlist[] = { sis_PCI_IDS }; -void -sis_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = 1; /* No dev_priv */ - dev->driver.context_ctor = sis_init_context; - dev->driver.context_dtor = sis_final_context; - - dev->driver.ioctls = sis_ioctls; - dev->driver.max_ioctl = sis_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +drm_ioctl_desc_t sis_ioctls[] = { + DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_fb_free, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_ioctl_agp_free, DRM_AUTH), + DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY) +}; + +int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); + +static const struct drm_driver_info sis_driver = { + .buf_priv_size = 1, /* No dev_priv */ + .context_ctor = sis_init_context, + .context_dtor = sis_final_context, + + .ioctls = sis_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(sis_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, +}; #ifdef __FreeBSD__ static int @@ -120,7 +127,7 @@ sisdrm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - sis_configure(dev); + dev->driver = &sis_driver; return drm_attach(parent, self, pa, sis_pciidlist); } diff --git a/sys/dev/pci/drm/sis_drv.h b/sys/dev/pci/drm/sis_drv.h index db532f3c3e1..f1fe9c7cf94 100644 --- a/sys/dev/pci/drm/sis_drv.h +++ b/sys/dev/pci/drm/sis_drv.h @@ -81,10 +81,14 @@ typedef struct drm_sis_private { extern int sis_init_context(struct drm_device * dev, int context); extern int sis_final_context(struct drm_device * dev, int context); +extern int sis_fb_alloc(struct drm_device *, void *, struct drm_file *); +extern int sis_fb_free(struct drm_device *, void *, struct drm_file *); +extern int sis_ioctl_agp_init(struct drm_device *, void *, struct drm_file *); +extern int sis_ioctl_agp_alloc(struct drm_device *, void *, struct drm_file *); +extern int sis_ioctl_agp_free(struct drm_device *, void *, struct drm_file *); +extern int sis_fb_init(struct drm_device *, void *, struct drm_file *); -#endif -extern struct drm_ioctl_desc sis_ioctls[]; -extern int sis_max_ioctl; +#endif #endif diff --git a/sys/dev/pci/drm/sis_mm.c b/sys/dev/pci/drm/sis_mm.c index e11939fa686..8059e7435aa 100644 --- a/sys/dev/pci/drm/sis_mm.c +++ b/sys/dev/pci/drm/sis_mm.c @@ -81,12 +81,12 @@ static int del_alloc_set(int context, int type, unsigned int val) /* fb management via fb device */ #if defined(__linux__) && defined(CONFIG_FB_SIS) -static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { return 0; } -static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_mem_t *fb = data; struct sis_memreq req; @@ -114,7 +114,7 @@ static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *fil return retval; } -static int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_mem_t fb; int retval = 0; @@ -143,7 +143,7 @@ static int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file * X driver/sisfb HW- Command- * framebuffer memory DRI heap Cursor queue */ -static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_fb_t *fb = data; @@ -166,7 +166,7 @@ static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file return 0; } -static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_mem_t *fb = data; @@ -197,7 +197,7 @@ static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *fil return retval; } -static int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_mem_t *fb = data; @@ -221,7 +221,7 @@ static int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file /* agp memory management */ -static int sis_ioctl_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_ioctl_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_agp_t *agp = data; @@ -244,7 +244,7 @@ static int sis_ioctl_agp_init(struct drm_device *dev, void *data, struct drm_fil return 0; } -static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_mem_t *agp = data; @@ -276,7 +276,7 @@ static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, struct drm_fi return retval; } -static int sis_ioctl_agp_free(struct drm_device *dev, void *data, struct drm_file *file_priv) +int sis_ioctl_agp_free(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_mem_t *agp = data; @@ -373,14 +373,3 @@ int sis_final_context(struct drm_device *dev, int context) return 1; } - -drm_ioctl_desc_t sis_ioctls[] = { - DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_fb_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_ioctl_agp_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY) -}; - -int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c index 0152b1898fd..9afd3a7855a 100644 --- a/sys/dev/pci/drm/tdfx_drv.c +++ b/sys/dev/pci/drm/tdfx_drv.c @@ -36,29 +36,25 @@ #include "drmP.h" #include "drm_pciids.h" -void tdfx_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t tdfx_pciidlist[] = { tdfx_PCI_IDS }; -void -tdfx_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = 1; /* No dev_priv */ +static const struct drm_driver_info tdfx_driver = { + .buf_priv_size = 1, /* No dev_priv */ - dev->driver.max_ioctl = 0; + .max_ioctl = 0, - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - dev->driver.major = DRIVER_MAJOR; - dev->driver.minor = DRIVER_MINOR; - dev->driver.patchlevel = DRIVER_PATCHLEVEL; + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, - dev->driver.use_mtrr = 1; -} + .use_mtrr = 1, +}; #ifdef __FreeBSD__ static int @@ -121,7 +117,7 @@ tdfxdrm_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; struct drm_device *dev = (struct drm_device *)self; - tdfx_configure(dev); + dev->driver = &tdfx_driver; return drm_attach(parent, self, pa, tdfx_pciidlist); } diff --git a/sys/dev/pci/drm/via_dma.c b/sys/dev/pci/drm/via_dma.c index 9f58bfa2bb9..8263840a3cd 100644 --- a/sys/dev/pci/drm/via_dma.c +++ b/sys/dev/pci/drm/via_dma.c @@ -742,22 +742,3 @@ via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv ) { return -EINVAL; } #endif - -struct drm_ioctl_desc via_ioctls[] = { - DRM_IOCTL_DEF(DRM_VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_FREEMEM, via_mem_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER), - DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER), - DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER), - DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_DMA_BLIT, via_dma_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH) -}; - -int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); diff --git a/sys/dev/pci/drm/via_drv.c b/sys/dev/pci/drm/via_drv.c index 09b179013ce..a90d7ea3e8e 100644 --- a/sys/dev/pci/drm/via_drv.c +++ b/sys/dev/pci/drm/via_drv.c @@ -34,45 +34,58 @@ #include "via_drv.h" #include "drm_pciids.h" -void via_configure(struct drm_device *); - /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t via_pciidlist[] = { viadrv_PCI_IDS }; -void -via_configure(struct drm_device *dev) -{ - dev->driver.buf_priv_size = 1; - dev->driver.load = via_driver_load; - dev->driver.unload = via_driver_unload; - dev->driver.context_ctor = via_init_context; - dev->driver.context_dtor = via_final_context; - dev->driver.get_vblank_counter = via_get_vblank_counter; - dev->driver.enable_vblank = via_enable_vblank; - dev->driver.disable_vblank = via_disable_vblank; - dev->driver.irq_preinstall = via_driver_irq_preinstall; - dev->driver.irq_postinstall = via_driver_irq_postinstall; - dev->driver.irq_uninstall = via_driver_irq_uninstall; - dev->driver.irq_handler = via_driver_irq_handler; - dev->driver.dma_quiescent = via_driver_dma_quiescent; - - dev->driver.ioctls = via_ioctls; - dev->driver.max_ioctl = via_max_ioctl; - - dev->driver.name = DRIVER_NAME; - dev->driver.desc = DRIVER_DESC; - dev->driver.date = DRIVER_DATE; - 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; -} +struct drm_ioctl_desc via_ioctls[] = { + DRM_IOCTL_DEF(DRM_VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_FREEMEM, via_mem_free, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER), + DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER), + DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER), + DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_DMA_BLIT, via_dma_blit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH) +}; + +static const struct drm_driver_info via_driver = { + .buf_priv_size = 1, + .load = via_driver_load, + .unload = via_driver_unload, + .context_ctor = via_init_context, + .context_dtor = via_final_context, + .get_vblank_counter = via_get_vblank_counter, + .enable_vblank = via_enable_vblank, + .disable_vblank = via_disable_vblank, + .irq_preinstall = via_driver_irq_preinstall, + .irq_postinstall = via_driver_irq_postinstall, + .irq_uninstall = via_driver_irq_uninstall, + .irq_handler = via_driver_irq_handler, + .dma_quiescent = via_driver_dma_quiescent, + + .ioctls = via_ioctls, + .max_ioctl = DRM_ARRAY_SIZE(via_ioctls), + + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, + + .use_agp = 1, + .use_mtrr = 1, + .use_irq = 1, + .use_vbl_irq = 1, +}; #ifdef __FreeBSD__ static int @@ -131,7 +144,7 @@ viadrm_attach(struct device *parent, struct device *self, void *opaque) struct pci_attach_args *pa = opaque; struct drm_device *dev = (struct drm_device *)self; - viadrm_configure(dev); + dev->driver = &via_driver; drm_attach(parent, self, pa, via_pciidlist); } diff --git a/sys/dev/pci/drm/via_drv.h b/sys/dev/pci/drm/via_drv.h index 941a2d77a07..8b061ebec19 100644 --- a/sys/dev/pci/drm/via_drv.h +++ b/sys/dev/pci/drm/via_drv.h @@ -149,9 +149,6 @@ enum via_family { #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val) -extern struct drm_ioctl_desc via_ioctls[]; -extern int via_max_ioctl; - extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv); |