diff options
author | Kevin E Martin <kem@kem.org> | 2001-03-07 19:14:39 +0000 |
---|---|---|
committer | Kevin E Martin <kem@kem.org> | 2001-03-07 19:14:39 +0000 |
commit | 7e820fc7d89d06a11f448d7093469a0c765a84a6 (patch) | |
tree | 0b0e71d032fedccb0ac40ddf7303cda2de53451a | |
parent | 78b07aa0d7a25ffbc1a2c07737fcb7597c4e6694 (diff) |
- Prepare for merge with trunksarea-1-0-0-20010307-freeze
- Change variable names to be more consistent
- Fix bug in per-context creation routine
- Fix root-only permissions for get/setsareactx IOCTLs
- Back out incomplete gamma changes
- Fix some compilation warning messages
- Various code cleanups
- Disable per-context SAREA example code for Radeon This can be re-enabled
when it is actually used by the driver. Look for '#ifdef
PER_CONTEXT_SAREA' in the client-side and ddx Radeon driver.
-rw-r--r-- | libdrm/xf86drm.c | 10 | ||||
-rw-r--r-- | linux-core/drmP.h | 4 | ||||
-rw-r--r-- | linux-core/drm_context.c | 24 | ||||
-rw-r--r-- | linux-core/drm_drv.c | 96 | ||||
-rw-r--r-- | linux/Makefile.linux | 2 | ||||
-rw-r--r-- | linux/drm.h | 8 | ||||
-rw-r--r-- | linux/drmP.h | 4 | ||||
-rw-r--r-- | linux/drm_context.h | 24 | ||||
-rw-r--r-- | linux/drm_drv.h | 96 | ||||
-rw-r--r-- | linux/gamma_dma.c | 96 | ||||
-rw-r--r-- | linux/gamma_drv.c | 6 | ||||
-rw-r--r-- | linux/gamma_drv.h | 7 | ||||
-rw-r--r-- | shared-core/drm.h | 8 | ||||
-rw-r--r-- | shared/drm.h | 8 |
14 files changed, 175 insertions, 218 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 9a063b219..f51840201 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -519,7 +519,7 @@ int drmRmMap(int fd, drmHandle handle) { drm_map_t map; - map.handle = handle; + map.handle = (void *)handle; if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno; return 0; @@ -1105,9 +1105,9 @@ int drmAddContextPrivateMapping(int fd, drmContext ctx_id, drmHandle handle) drm_ctx_priv_map_t map; map.ctx_id = ctx_id; - map.handle = handle; + map.handle = (void *)handle; - if(ioctl(fd, DRM_IOCTL_CTX_SAREA, &map)) return -errno; + if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) return -errno; return 0; } @@ -1117,8 +1117,8 @@ int drmGetContextPrivateMapping(int fd, drmContext ctx_id, drmHandlePtr handle) map.ctx_id = ctx_id; - if(ioctl(fd, DRM_IOCTL_GET_CTX_SAREA, &map)) return -errno; - if(handle) *handle = map.handle; + if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno; + if (handle) *handle = (drmHandle)map.handle; return 0; } diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 6f21c0ed0..804df4095 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -835,9 +835,9 @@ extern int DRM(notifier)(void *priv); /* Context Bitmap support (ctxbitmap.c) */ extern int DRM(ctxbitmap_init)( drm_device_t *dev ); extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); -extern int DRM(add_ctx_map)( struct inode *inode, struct file *filp, +extern int DRM(setsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(get_ctx_map)( struct inode *inode, struct file *filp, +extern int DRM(getsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* Buffer management support (bufs.c) */ diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c index 6f673ac00..8f891fd2a 100644 --- a/linux-core/drm_context.c +++ b/linux-core/drm_context.c @@ -129,7 +129,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) * Per Context SAREA Support */ -int DRM(get_ctx_map)(struct inode *inode, struct file *filp, +int DRM(getsareactx)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -137,13 +137,13 @@ int DRM(get_ctx_map)(struct inode *inode, struct file *filp, drm_ctx_priv_map_t request; drm_map_t *map; - if(copy_from_user(&request, - (drm_ctx_priv_map_t *)arg, - sizeof(request))) + if (copy_from_user(&request, + (drm_ctx_priv_map_t *)arg, + sizeof(request))) return -EFAULT; down(&dev->struct_sem); - if((int)request.ctx_id >= dev->max_context) { + if ((int)request.ctx_id >= dev->max_context) { up(&dev->struct_sem); return -EINVAL; } @@ -157,7 +157,7 @@ int DRM(get_ctx_map)(struct inode *inode, struct file *filp, return 0; } -int DRM(add_ctx_map)(struct inode *inode, struct file *filp, +int DRM(setsareactx)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -167,9 +167,9 @@ int DRM(add_ctx_map)(struct inode *inode, struct file *filp, drm_map_list_t *r_list; struct list_head *list; - if(copy_from_user(&request, - (drm_ctx_priv_map_t *)arg, - sizeof(request))) + if (copy_from_user(&request, + (drm_ctx_priv_map_t *)arg, + sizeof(request))) return -EFAULT; down(&dev->struct_sem); @@ -178,17 +178,17 @@ int DRM(add_ctx_map)(struct inode *inode, struct file *filp, if(r_list->map && r_list->map->handle == request.handle) break; } - if(list == &(dev->maplist->head)) { + if (list == &(dev->maplist->head)) { up(&dev->struct_sem); return -EINVAL; } map = r_list->map; up(&dev->struct_sem); - if(!map) return -EINVAL; + if (!map) return -EINVAL; down(&dev->struct_sem); - if((int)request.ctx_id >= dev->max_context) { + if ((int)request.ctx_id >= dev->max_context) { up(&dev->struct_sem); return -EINVAL; } diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 776b07312..05923b50b 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -118,64 +118,64 @@ static struct file_operations DRM(fops) = { }; -static drm_ioctl_desc_t DRM(ioctls)[] = { - [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_CTX_SAREA)] = { DRM(add_ctx_map), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX_SAREA)] = { DRM(get_ctx_map), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, +static drm_ioctl_desc_t DRM(ioctls)[] = { + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, #if __HAVE_DMA - [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 }, - [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 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 }, + [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. */ #if __HAVE_DMA_IRQ - [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, #endif #endif #if __REALLY_HAVE_AGP - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, #endif DRIVER_IOCTLS diff --git a/linux/Makefile.linux b/linux/Makefile.linux index 1780e697d..26eed9a5f 100644 --- a/linux/Makefile.linux +++ b/linux/Makefile.linux @@ -261,7 +261,7 @@ ChangeLog: $(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@ $(DRMOBJS): $(DRMHEADERS) -$(GAMMAOBJS): $(GAMMAHEADERS) +#$(GAMMAOBJS): $(GAMMAHEADERS) $(TDFXOBJS): $(TDFXHEADERS) ifeq ($(AGP),1) $(MGAOBJS): $(MGAHEADERS) diff --git a/linux/drm.h b/linux/drm.h index 6d366e7a0..7c65f5fc3 100644 --- a/linux/drm.h +++ b/linux/drm.h @@ -88,7 +88,6 @@ typedef struct drm_tex_region { #include "i810_drm.h" #include "r128_drm.h" #include "radeon_drm.h" -#include "gamma_drm.h" #ifdef CONFIG_DRM_SIS #include "sis_drm.h" #endif @@ -377,8 +376,8 @@ typedef struct drm_agp_info { #define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, drm_map_t) -#define DRM_IOCTL_CTX_SAREA DRM_IOW( 0x1c, drm_ctx_priv_map_t) -#define DRM_IOCTL_GET_CTX_SAREA DRM_IOWR(0x1d, drm_ctx_priv_map_t) +#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, drm_ctx_priv_map_t) +#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, drm_ctx_priv_map_t) #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t) #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t) @@ -403,9 +402,6 @@ typedef struct drm_agp_info { #define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t) #define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t) -/* Gamma specific ioctls */ -#define DRM_IOCTL_GAMMA_INIT DRM_IOW( 0x40, drm_gamma_init_t) - /* MGA specific ioctls */ #define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) #define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t) diff --git a/linux/drmP.h b/linux/drmP.h index 6f21c0ed0..804df4095 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -835,9 +835,9 @@ extern int DRM(notifier)(void *priv); /* Context Bitmap support (ctxbitmap.c) */ extern int DRM(ctxbitmap_init)( drm_device_t *dev ); extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); -extern int DRM(add_ctx_map)( struct inode *inode, struct file *filp, +extern int DRM(setsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(get_ctx_map)( struct inode *inode, struct file *filp, +extern int DRM(getsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* Buffer management support (bufs.c) */ diff --git a/linux/drm_context.h b/linux/drm_context.h index 6f673ac00..8f891fd2a 100644 --- a/linux/drm_context.h +++ b/linux/drm_context.h @@ -129,7 +129,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) * Per Context SAREA Support */ -int DRM(get_ctx_map)(struct inode *inode, struct file *filp, +int DRM(getsareactx)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -137,13 +137,13 @@ int DRM(get_ctx_map)(struct inode *inode, struct file *filp, drm_ctx_priv_map_t request; drm_map_t *map; - if(copy_from_user(&request, - (drm_ctx_priv_map_t *)arg, - sizeof(request))) + if (copy_from_user(&request, + (drm_ctx_priv_map_t *)arg, + sizeof(request))) return -EFAULT; down(&dev->struct_sem); - if((int)request.ctx_id >= dev->max_context) { + if ((int)request.ctx_id >= dev->max_context) { up(&dev->struct_sem); return -EINVAL; } @@ -157,7 +157,7 @@ int DRM(get_ctx_map)(struct inode *inode, struct file *filp, return 0; } -int DRM(add_ctx_map)(struct inode *inode, struct file *filp, +int DRM(setsareactx)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -167,9 +167,9 @@ int DRM(add_ctx_map)(struct inode *inode, struct file *filp, drm_map_list_t *r_list; struct list_head *list; - if(copy_from_user(&request, - (drm_ctx_priv_map_t *)arg, - sizeof(request))) + if (copy_from_user(&request, + (drm_ctx_priv_map_t *)arg, + sizeof(request))) return -EFAULT; down(&dev->struct_sem); @@ -178,17 +178,17 @@ int DRM(add_ctx_map)(struct inode *inode, struct file *filp, if(r_list->map && r_list->map->handle == request.handle) break; } - if(list == &(dev->maplist->head)) { + if (list == &(dev->maplist->head)) { up(&dev->struct_sem); return -EINVAL; } map = r_list->map; up(&dev->struct_sem); - if(!map) return -EINVAL; + if (!map) return -EINVAL; down(&dev->struct_sem); - if((int)request.ctx_id >= dev->max_context) { + if ((int)request.ctx_id >= dev->max_context) { up(&dev->struct_sem); return -EINVAL; } diff --git a/linux/drm_drv.h b/linux/drm_drv.h index 776b07312..05923b50b 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -118,64 +118,64 @@ static struct file_operations DRM(fops) = { }; -static drm_ioctl_desc_t DRM(ioctls)[] = { - [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_CTX_SAREA)] = { DRM(add_ctx_map), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX_SAREA)] = { DRM(get_ctx_map), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, +static drm_ioctl_desc_t DRM(ioctls)[] = { + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, #if __HAVE_DMA - [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 }, - [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 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 }, + [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. */ #if __HAVE_DMA_IRQ - [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, #endif #endif #if __REALLY_HAVE_AGP - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, #endif DRIVER_IOCTLS diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c index 1b784f80e..e2ac60616 100644 --- a/linux/gamma_dma.c +++ b/linux/gamma_dma.c @@ -37,6 +37,40 @@ #include <linux/interrupt.h> /* For task queue support */ #include <linux/delay.h> +#if 0 +#define DO_IOREMAP( _map ) \ +do { \ + (_map)->handle = DRM(ioremap)( (_map)->offset, (_map)->size ); \ +} while (0) + +#define DO_IOREMAPFREE( _map ) \ +do { \ + if ( (_map)->handle && (_map)->size ) \ + DRM(ioremapfree)( (_map)->handle, (_map)->size ); \ +} while (0) + +#define DO_FIND_MAP( _map, _offset ) \ +do { \ + int _i; \ + for ( _i = 0 ; _i < dev->map_count ; _i++ ) { \ + if ( dev->maplist[_i]->offset == _offset ) { \ + _map = dev->maplist[_i]; \ + break; \ + } \ + } \ +} while (0) +#endif + +/* WARNING!!! MAGIC NUMBER!!! The number of regions already added to the + kernel must be specified here. Currently, the number is 2. This must + match the order the X server uses for instantiating register regions , + or must be passed in a new ioctl. */ +#define GAMMA_REG(reg) \ + (2 \ + + ((reg < 0x1000) \ + ? 0 \ + : ((reg < 0x10000) ? 1 : ((reg < 0x11000) ? 2 : 3)))) + #define GAMMA_OFF(reg) \ ((reg < 0x1000) \ ? reg \ @@ -46,12 +80,7 @@ ? (reg - 0x10000) \ : (reg - 0x11000)))) -#define GAMMA_BASE(reg) ((unsigned long) \ - ((reg < 0x1000) ? dev_priv->mmio0->handle : \ - ((reg < 0x10000) ? dev_priv->mmio1->handle : \ - ((reg < 0x11000) ? dev_priv->mmio2->handle : \ - dev_priv->mmio3->handle)))) - +#define GAMMA_BASE(reg) ((unsigned long)dev->maplist[GAMMA_REG(reg)]->handle) #define GAMMA_ADDR(reg) (GAMMA_BASE(reg) + GAMMA_OFF(reg)) #define GAMMA_DEREF(reg) *(__volatile__ int *)GAMMA_ADDR(reg) #define GAMMA_READ(reg) GAMMA_DEREF(reg) @@ -78,8 +107,6 @@ static inline void gamma_dma_dispatch(drm_device_t *dev, unsigned long address, unsigned long length) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; GAMMA_WRITE(GAMMA_DMAADDRESS, virt_to_phys((void *)address)); while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4) ; @@ -88,8 +115,6 @@ static inline void gamma_dma_dispatch(drm_device_t *dev, unsigned long address, void gamma_dma_quiescent_single(drm_device_t *dev) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; while (GAMMA_READ(GAMMA_DMACOUNT)) ; while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3) @@ -106,8 +131,6 @@ void gamma_dma_quiescent_single(drm_device_t *dev) void gamma_dma_quiescent_dual(drm_device_t *dev) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; while (GAMMA_READ(GAMMA_DMACOUNT)) ; while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3) @@ -133,24 +156,18 @@ void gamma_dma_quiescent_dual(drm_device_t *dev) void gamma_dma_ready(drm_device_t *dev) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; while (GAMMA_READ(GAMMA_DMACOUNT)) ; } static inline int gamma_dma_is_ready(drm_device_t *dev) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; return !GAMMA_READ(GAMMA_DMACOUNT); } static void gamma_dma_service(int irq, void *device, struct pt_regs *regs) { drm_device_t *dev = (drm_device_t *)device; - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; drm_device_dma_t *dma = dev->dma; atomic_inc(&dev->counts[6]); /* _DRM_STAT_IRQ */ @@ -621,8 +638,6 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd, int gamma_irq_install(drm_device_t *dev, int irq) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; int retcode; if (!irq) return -EINVAL; @@ -677,8 +692,6 @@ int gamma_irq_install(drm_device_t *dev, int irq) int gamma_irq_uninstall(drm_device_t *dev) { - drm_gamma_private_t *dev_priv = (drm_gamma_private_t *) - dev->dev_private; int irq; down(&dev->struct_sem); @@ -698,6 +711,7 @@ int gamma_irq_uninstall(drm_device_t *dev) return 0; } + int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -723,41 +737,3 @@ int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd, } return 0; } - -void gamma_dma_cleanup(drm_device_t *dev) -{ - drm_gamma_private_t *dev_priv; - - if(dev->dev_private) { - dev_priv = (drm_gamma_private_t *)dev->dev_private; - DRM(free)(dev_priv, - sizeof(drm_gamma_private_t), - DRM_MEM_DRIVER); - dev->dev_private = NULL; - } -} - -int gamma_dma_init(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_gamma_init_t init; - drm_gamma_private_t *dev_priv; - - if (copy_from_user(&init, (drm_gamma_init_t *)arg, sizeof(init))) - return -EFAULT; - - dev_priv = DRM(alloc)(sizeof(drm_gamma_private_t), - DRM_MEM_DRIVER); - if(!dev_priv) return -ENOMEM; - - memset(dev_priv, 0, sizeof(drm_gamma_private_t)); - - DRM_FIND_MAP(dev_priv->mmio0, init.hControlRegs0); - DRM_FIND_MAP(dev_priv->mmio1, init.hControlRegs1); - DRM_FIND_MAP(dev_priv->mmio2, init.hControlRegs2); - DRM_FIND_MAP(dev_priv->mmio3, init.hControlRegs3); - - return 0; -} diff --git a/linux/gamma_drv.c b/linux/gamma_drv.c index ae73aca48..c24d5a33c 100644 --- a/linux/gamma_drv.c +++ b/linux/gamma_drv.c @@ -46,8 +46,7 @@ #define DRIVER_IOCTLS \ - [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { gamma_dma, 1, 0 }, \ - [DRM_IOCTL_NR(DRM_IOCTL_GAMMA_INIT)] = { gamma_dma_init, 1, 0 } + [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { gamma_dma, 1, 0 } #define __HAVE_MTRR 1 #define __HAVE_CTX_BITMAP 0 @@ -90,13 +89,14 @@ do { \ gamma_reclaim_buffers( dev, priv->pid ); \ if ( dev->dev_private ) { \ drm_gamma_private_t *dev_priv = dev->dev_private; \ + dev_priv->dispatch_status &= MGA_IN_DISPATCH; \ } \ } while (0) #endif #if 0 #define DRIVER_PRETAKEDOWN() do { \ - if ( dev->dev_private ) gamma_dma_cleanup( dev ); \ + if ( dev->dev_private ) gamma_do_cleanup_dma( dev ); \ } while (0) #endif diff --git a/linux/gamma_drv.h b/linux/gamma_drv.h index ae2ec59b4..1bfa26509 100644 --- a/linux/gamma_drv.h +++ b/linux/gamma_drv.h @@ -35,10 +35,6 @@ typedef struct drm_gamma_private { drm_map_t *buffers; - drm_map_t *mmio0; - drm_map_t *mmio1; - drm_map_t *mmio2; - drm_map_t *mmio3; } drm_gamma_private_t; #define LOCK_TEST_WITH_RETURN( dev ) \ @@ -76,8 +72,5 @@ extern int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int gamma_find_devices(void); extern int gamma_found(void); -extern void gamma_dma_cleanup(drm_device_t *dev); -extern int gamma_dma_init(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); #endif diff --git a/shared-core/drm.h b/shared-core/drm.h index 6d366e7a0..7c65f5fc3 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -88,7 +88,6 @@ typedef struct drm_tex_region { #include "i810_drm.h" #include "r128_drm.h" #include "radeon_drm.h" -#include "gamma_drm.h" #ifdef CONFIG_DRM_SIS #include "sis_drm.h" #endif @@ -377,8 +376,8 @@ typedef struct drm_agp_info { #define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, drm_map_t) -#define DRM_IOCTL_CTX_SAREA DRM_IOW( 0x1c, drm_ctx_priv_map_t) -#define DRM_IOCTL_GET_CTX_SAREA DRM_IOWR(0x1d, drm_ctx_priv_map_t) +#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, drm_ctx_priv_map_t) +#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, drm_ctx_priv_map_t) #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t) #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t) @@ -403,9 +402,6 @@ typedef struct drm_agp_info { #define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t) #define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t) -/* Gamma specific ioctls */ -#define DRM_IOCTL_GAMMA_INIT DRM_IOW( 0x40, drm_gamma_init_t) - /* MGA specific ioctls */ #define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) #define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t) diff --git a/shared/drm.h b/shared/drm.h index 6d366e7a0..7c65f5fc3 100644 --- a/shared/drm.h +++ b/shared/drm.h @@ -88,7 +88,6 @@ typedef struct drm_tex_region { #include "i810_drm.h" #include "r128_drm.h" #include "radeon_drm.h" -#include "gamma_drm.h" #ifdef CONFIG_DRM_SIS #include "sis_drm.h" #endif @@ -377,8 +376,8 @@ typedef struct drm_agp_info { #define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, drm_map_t) -#define DRM_IOCTL_CTX_SAREA DRM_IOW( 0x1c, drm_ctx_priv_map_t) -#define DRM_IOCTL_GET_CTX_SAREA DRM_IOWR(0x1d, drm_ctx_priv_map_t) +#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, drm_ctx_priv_map_t) +#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, drm_ctx_priv_map_t) #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t) #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t) @@ -403,9 +402,6 @@ typedef struct drm_agp_info { #define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t) #define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t) -/* Gamma specific ioctls */ -#define DRM_IOCTL_GAMMA_INIT DRM_IOW( 0x40, drm_gamma_init_t) - /* MGA specific ioctls */ #define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) #define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t) |