Get r128 basically working: Hook up the driver's dma ioctl, use the proper

offset into the driver ioctl array, and don't make the ctx bitmap
    conditional.
main
Eric Anholt 2004-11-06 21:18:49 +00:00
parent ae7a171313
commit 7bdccfd0bb
5 changed files with 41 additions and 12 deletions

View File

@ -607,6 +607,7 @@ struct drm_device {
int (*postsetup)(struct drm_device *); int (*postsetup)(struct drm_device *);
void (*open_helper)(struct drm_device *, drm_file_t *); void (*open_helper)(struct drm_device *, drm_file_t *);
void (*release)(struct drm_device *, void *filp); void (*release)(struct drm_device *, void *filp);
int (*dma_ioctl)(DRM_IOCTL_ARGS);
void (*dma_ready)(struct drm_device *); void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *); int (*dma_quiescent)(struct drm_device *);
int (*dma_flush_block_and_flush)(struct drm_device *, int context, int (*dma_flush_block_and_flush)(struct drm_device *, int context,
@ -646,7 +647,6 @@ struct drm_device {
unsigned use_irq :1; unsigned use_irq :1;
unsigned use_vbl_irq :1; unsigned use_vbl_irq :1;
unsigned use_mtrr :1; unsigned use_mtrr :1;
unsigned use_ctxbitmap :1;
/* End of driver-config section */ /* End of driver-config section */
char *unique; /* Unique identifier: e.g., busid */ 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_freebufs(DRM_IOCTL_ARGS);
int drm_mapbufs(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) */ /* IRQ support (drm_irq.c) */
int drm_control(DRM_IOCTL_ARGS); int drm_control(DRM_IOCTL_ARGS);
int drm_wait_vblank(DRM_IOCTL_ARGS); int drm_wait_vblank(DRM_IOCTL_ARGS);

View File

@ -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;
}
}

View File

@ -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_INFO_BUFS)] = { drm_infobufs, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 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_CONTROL)] = { drm_control, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 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);
retcode = drm_ctxbitmap_init(dev); if (retcode != 0) {
if (retcode != 0) { DRM_ERROR("Cannot allocate memory for context bitmap.\n");
DRM_ERROR("Cannot allocate memory for context bitmap.\n"); goto error;
goto error;
}
} }
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n", 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); destroy_dev(dev->devnode);
#endif #endif
if (dev->use_ctxbitmap) drm_ctxbitmap_cleanup(dev);
drm_ctxbitmap_cleanup(dev);
if (dev->agp && dev->agp->mtrr) { if (dev->agp && dev->agp->mtrr) {
int __unused retcode; int __unused retcode;
@ -858,13 +856,23 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
#endif /* __NetBSD__ */ #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; return EINVAL;
}
ioctl = &drm_ioctls[nr]; ioctl = &drm_ioctls[nr];
/* It's not a core DRM ioctl, try driver-specific. */ /* 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]; ioctl = &dev->driver_ioctls[nr];
}
func = ioctl->func; func = ioctl->func;
if (func == NULL) { 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); 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); return DRM_ERR(retcode);
} }

View File

@ -54,6 +54,7 @@ static void r128_configure(drm_device_t *dev)
dev->irq_postinstall = r128_driver_irq_postinstall; dev->irq_postinstall = r128_driver_irq_postinstall;
dev->irq_uninstall = r128_driver_irq_uninstall; dev->irq_uninstall = r128_driver_irq_uninstall;
dev->irq_handler = r128_driver_irq_handler; dev->irq_handler = r128_driver_irq_handler;
dev->dma_ioctl = r128_cce_buffers;
/* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/ /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/
/* XXX dev->get_map_ofs = drm_core_get_map_ofs; /* XXX dev->get_map_ofs = drm_core_get_map_ofs;
dev->get_reg_ofs = drm_core_get_reg_ofs;*/ dev->get_reg_ofs = drm_core_get_reg_ofs;*/

View File

@ -52,6 +52,7 @@ static void radeon_configure(drm_device_t *dev)
dev->irq_postinstall = radeon_driver_irq_postinstall; dev->irq_postinstall = radeon_driver_irq_postinstall;
dev->irq_uninstall = radeon_driver_irq_uninstall; dev->irq_uninstall = radeon_driver_irq_uninstall;
dev->irq_handler = radeon_driver_irq_handler; dev->irq_handler = radeon_driver_irq_handler;
dev->dma_ioctl = radeon_cp_buffers;
/* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/ /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/
/* XXX dev->get_map_ofs = drm_core_get_map_ofs; /* XXX dev->get_map_ofs = drm_core_get_map_ofs;
dev->get_reg_ofs = drm_core_get_reg_ofs;*/ dev->get_reg_ofs = drm_core_get_reg_ofs;*/