summaryrefslogtreecommitdiff
path: root/bsd-core/drm_context.c
diff options
context:
space:
mode:
authorJesse Barnes <jesse.barnes@intel.com>2007-10-30 12:52:46 -0700
committerJesse Barnes <jesse.barnes@intel.com>2007-10-30 12:52:46 -0700
commit91aae7e683786a48547872b0a5fa92b2232e02c0 (patch)
treea30c8022886d61add4a4c2e073fa07f29d7745a7 /bsd-core/drm_context.c
parent7e9ea55a2f052cc939ba9bbf9edac39798344b7a (diff)
parent79744d730c90019edd367eee4a8ec1fa22d53402 (diff)
Merge branch 'master' into vblank-rework, fixup remaining drivers
Conflicts: linux-core/drmP.h linux-core/drm_drv.c linux-core/drm_irq.c shared-core/i915_drv.h shared-core/i915_irq.c shared-core/mga_drv.h shared-core/mga_irq.c shared-core/radeon_drv.h shared-core/radeon_irq.c Merge in the latest master bits and update the remaining drivers (except mach64 which math_b is working on). Also remove the 9xx hack from the i915 driver; it seems to be correct.
Diffstat (limited to 'bsd-core/drm_context.c')
-rw-r--r--bsd-core/drm_context.c136
1 files changed, 53 insertions, 83 deletions
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index 8e009540..4155ee92 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -1,6 +1,3 @@
-/* drm_context.h -- IOCTLs for generic contexts -*- linux-c -*-
- * Created: Fri Nov 24 18:31:37 2000 by gareth@valinux.com
- */
/*-
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
@@ -31,6 +28,10 @@
*
*/
+/** @file drm_context.c
+ * Implementation of the context management ioctls.
+ */
+
#include "drmP.h"
/* ================================================================
@@ -109,7 +110,7 @@ int drm_ctxbitmap_init(drm_device_t *dev)
dev->ctx_bitmap = malloc(PAGE_SIZE, M_DRM, M_NOWAIT | M_ZERO);
if ( dev->ctx_bitmap == NULL ) {
DRM_UNLOCK();
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
dev->context_sareas = NULL;
dev->max_context = -1;
@@ -136,48 +137,39 @@ void drm_ctxbitmap_cleanup(drm_device_t *dev)
* Per Context SAREA Support
*/
-int drm_getsareactx( DRM_IOCTL_ARGS )
+int drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv )
{
- DRM_DEVICE;
- drm_ctx_priv_map_t request;
+ drm_ctx_priv_map_t *request = data;
drm_local_map_t *map;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
- sizeof(request) );
-
DRM_LOCK();
- if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
+ if (dev->max_context < 0 ||
+ request->ctx_id >= (unsigned) dev->max_context) {
DRM_UNLOCK();
- return DRM_ERR(EINVAL);
+ return EINVAL;
}
- map = dev->context_sareas[request.ctx_id];
+ map = dev->context_sareas[request->ctx_id];
DRM_UNLOCK();
- request.handle = map->handle;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_priv_map_t *)data, request, sizeof(request) );
+ request->handle = map->handle;
return 0;
}
-int drm_setsareactx( DRM_IOCTL_ARGS )
+int drm_setsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_ctx_priv_map_t request;
+ drm_ctx_priv_map_t *request = data;
drm_local_map_t *map = NULL;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
- sizeof(request) );
-
DRM_LOCK();
TAILQ_FOREACH(map, &dev->maplist, link) {
- if (map->handle == request.handle) {
+ if (map->handle == request->handle) {
if (dev->max_context < 0)
goto bad;
- if (request.ctx_id >= (unsigned) dev->max_context)
+ if (request->ctx_id >= (unsigned) dev->max_context)
goto bad;
- dev->context_sareas[request.ctx_id] = map;
+ dev->context_sareas[request->ctx_id] = map;
DRM_UNLOCK();
return 0;
}
@@ -185,7 +177,7 @@ int drm_setsareactx( DRM_IOCTL_ARGS )
bad:
DRM_UNLOCK();
- return DRM_ERR(EINVAL);
+ return EINVAL;
}
/* ================================================================
@@ -196,7 +188,7 @@ int drm_context_switch(drm_device_t *dev, int old, int new)
{
if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" );
- return DRM_ERR(EBUSY);
+ return EBUSY;
}
DRM_DEBUG( "Context switch from %d to %d\n", old, new );
@@ -225,120 +217,98 @@ int drm_context_switch_complete(drm_device_t *dev, int new)
return 0;
}
-int drm_resctx(DRM_IOCTL_ARGS)
+int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- drm_ctx_res_t res;
+ drm_ctx_res_t *res = data;
drm_ctx_t ctx;
int i;
- DRM_COPY_FROM_USER_IOCTL( res, (drm_ctx_res_t *)data, sizeof(res) );
-
- if ( res.count >= DRM_RESERVED_CONTEXTS ) {
+ if ( res->count >= DRM_RESERVED_CONTEXTS ) {
bzero(&ctx, sizeof(ctx));
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
ctx.handle = i;
- if ( DRM_COPY_TO_USER( &res.contexts[i],
+ if ( DRM_COPY_TO_USER( &res->contexts[i],
&ctx, sizeof(ctx) ) )
- return DRM_ERR(EFAULT);
+ return EFAULT;
}
}
- res.count = DRM_RESERVED_CONTEXTS;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_res_t *)data, res, sizeof(res) );
+ res->count = DRM_RESERVED_CONTEXTS;
return 0;
}
-int drm_addctx(DRM_IOCTL_ARGS)
+int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ drm_ctx_t *ctx = data;
- ctx.handle = drm_ctxbitmap_next(dev);
- if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
+ ctx->handle = drm_ctxbitmap_next(dev);
+ if ( ctx->handle == DRM_KERNEL_CONTEXT ) {
/* Skip kernel's context and get a new one. */
- ctx.handle = drm_ctxbitmap_next(dev);
+ ctx->handle = drm_ctxbitmap_next(dev);
}
- DRM_DEBUG( "%d\n", ctx.handle );
- if ( ctx.handle == -1 ) {
+ DRM_DEBUG( "%d\n", ctx->handle );
+ if ( ctx->handle == -1 ) {
DRM_DEBUG( "Not enough free contexts.\n" );
/* Should this return -EBUSY instead? */
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
- if (dev->driver.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT) {
+ if (dev->driver.context_ctor && ctx->handle != DRM_KERNEL_CONTEXT) {
DRM_LOCK();
- dev->driver.context_ctor(dev, ctx.handle);
+ dev->driver.context_ctor(dev, ctx->handle);
DRM_UNLOCK();
}
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
-
return 0;
}
-int drm_modctx(DRM_IOCTL_ARGS)
+int drm_modctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
/* This does nothing */
return 0;
}
-int drm_getctx(DRM_IOCTL_ARGS)
+int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ drm_ctx_t *ctx = data;
/* This is 0, because we don't handle any context flags */
- ctx.flags = 0;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
+ ctx->flags = 0;
return 0;
}
-int drm_switchctx(DRM_IOCTL_ARGS)
+int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_ctx_t ctx;
+ drm_ctx_t *ctx = data;
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- DRM_DEBUG( "%d\n", ctx.handle );
- return drm_context_switch(dev, dev->last_context, ctx.handle);
+ DRM_DEBUG( "%d\n", ctx->handle );
+ return drm_context_switch(dev, dev->last_context, ctx->handle);
}
-int drm_newctx(DRM_IOCTL_ARGS)
+int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ drm_ctx_t *ctx = data;
- DRM_DEBUG( "%d\n", ctx.handle );
- drm_context_switch_complete(dev, ctx.handle);
+ DRM_DEBUG( "%d\n", ctx->handle );
+ drm_context_switch_complete(dev, ctx->handle);
return 0;
}
-int drm_rmctx(DRM_IOCTL_ARGS)
+int drm_rmctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ drm_ctx_t *ctx = data;
- DRM_DEBUG( "%d\n", ctx.handle );
- if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
+ DRM_DEBUG( "%d\n", ctx->handle );
+ if ( ctx->handle != DRM_KERNEL_CONTEXT ) {
if (dev->driver.context_dtor) {
DRM_LOCK();
- dev->driver.context_dtor(dev, ctx.handle);
+ dev->driver.context_dtor(dev, ctx->handle);
DRM_UNLOCK();
}
- drm_ctxbitmap_free(dev, ctx.handle);
+ drm_ctxbitmap_free(dev, ctx->handle);
}
return 0;