diff options
Diffstat (limited to 'bsd-core')
-rw-r--r-- | bsd-core/drmP.h | 5 | ||||
-rw-r--r-- | bsd-core/drm_dma.c | 13 | ||||
-rw-r--r-- | bsd-core/drm_drv.c | 33 | ||||
-rw-r--r-- | bsd-core/r128_drv.c | 1 | ||||
-rw-r--r-- | bsd-core/radeon_drv.c | 1 |
5 files changed, 41 insertions, 12 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 00c84ef7..3d96406c 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -607,6 +607,7 @@ struct drm_device { int (*postsetup)(struct drm_device *); void (*open_helper)(struct drm_device *, drm_file_t *); void (*release)(struct drm_device *, void *filp); + int (*dma_ioctl)(DRM_IOCTL_ARGS); void (*dma_ready)(struct drm_device *); int (*dma_quiescent)(struct drm_device *); int (*dma_flush_block_and_flush)(struct drm_device *, int context, @@ -646,7 +647,6 @@ struct drm_device { unsigned use_irq :1; unsigned use_vbl_irq :1; unsigned use_mtrr :1; - unsigned use_ctxbitmap :1; /* End of driver-config section */ char *unique; /* Unique identifier: e.g., busid */ @@ -882,6 +882,9 @@ int drm_markbufs(DRM_IOCTL_ARGS); int drm_freebufs(DRM_IOCTL_ARGS); int drm_mapbufs(DRM_IOCTL_ARGS); +/* DMA support (drm_dma.c) */ +int drm_dma(DRM_IOCTL_ARGS); + /* IRQ support (drm_irq.c) */ int drm_control(DRM_IOCTL_ARGS); int drm_wait_vblank(DRM_IOCTL_ARGS); diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c index 6446a844..28828703 100644 --- a/bsd-core/drm_dma.c +++ b/bsd-core/drm_dma.c @@ -130,3 +130,16 @@ void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp) } } } + +/* Call into the driver-specific DMA handler */ +int drm_dma(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + + if (dev->dma_ioctl) { + return dev->dma_ioctl(kdev, cmd, data, flags, p, filp); + } else { + DRM_DEBUG("DMA ioctl on driver with no dma handler\n"); + return EINVAL; + } +} diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 372b0f4e..21cf8f79 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -93,7 +93,8 @@ static drm_ioctl_desc_t drm_ioctls[256] = { [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, - /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ + [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { drm_dma, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 }, @@ -552,12 +553,10 @@ static int drm_init(device_t nbdev) } } - if (dev->use_ctxbitmap) { - retcode = drm_ctxbitmap_init(dev); - if (retcode != 0) { - DRM_ERROR("Cannot allocate memory for context bitmap.\n"); - goto error; - } + retcode = drm_ctxbitmap_init(dev); + if (retcode != 0) { + DRM_ERROR("Cannot allocate memory for context bitmap.\n"); + goto error; } DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n", @@ -604,8 +603,7 @@ static void drm_cleanup(drm_device_t *dev) destroy_dev(dev->devnode); #endif - if (dev->use_ctxbitmap) - drm_ctxbitmap_cleanup(dev); + drm_ctxbitmap_cleanup(dev); if (dev->agp && dev->agp->mtrr) { int __unused retcode; @@ -858,13 +856,23 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, #endif /* __NetBSD__ */ } - if (nr >= dev->max_driver_ioctl || IOCGROUP(cmd) != DRM_IOCTL_BASE) + if (IOCGROUP(cmd) != DRM_IOCTL_BASE) { + DRM_DEBUG("Bad ioctl group 0x%x\n", (int)IOCGROUP(cmd)); return EINVAL; + } ioctl = &drm_ioctls[nr]; /* It's not a core DRM ioctl, try driver-specific. */ - if (ioctl->func == NULL) + 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->max_driver_ioctl) { + DRM_DEBUG("Bad driver ioctl number, 0x%x (of 0x%x)\n", + nr, dev->max_driver_ioctl); + return EINVAL; + } ioctl = &dev->driver_ioctls[nr]; + } func = ioctl->func; if (func == NULL) { @@ -877,6 +885,9 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, retcode = func(kdev, cmd, data, flags, p, (void *)(uintptr_t)DRM_CURRENTPID); + if (retcode != 0) + DRM_DEBUG(" returning %d\n", retcode); + return DRM_ERR(retcode); } diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c index f8139ea2..da0ab1f1 100644 --- a/bsd-core/r128_drv.c +++ b/bsd-core/r128_drv.c @@ -54,6 +54,7 @@ static void r128_configure(drm_device_t *dev) dev->irq_postinstall = r128_driver_irq_postinstall; dev->irq_uninstall = r128_driver_irq_uninstall; dev->irq_handler = r128_driver_irq_handler; + dev->dma_ioctl = r128_cce_buffers; /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/ /* XXX dev->get_map_ofs = drm_core_get_map_ofs; dev->get_reg_ofs = drm_core_get_reg_ofs;*/ diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c index 5f7014e1..ef517f4c 100644 --- a/bsd-core/radeon_drv.c +++ b/bsd-core/radeon_drv.c @@ -52,6 +52,7 @@ static void radeon_configure(drm_device_t *dev) dev->irq_postinstall = radeon_driver_irq_postinstall; dev->irq_uninstall = radeon_driver_irq_uninstall; dev->irq_handler = radeon_driver_irq_handler; + dev->dma_ioctl = radeon_cp_buffers; /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/ /* XXX dev->get_map_ofs = drm_core_get_map_ofs; dev->get_reg_ofs = drm_core_get_reg_ofs;*/ |