summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
authorArthur Huillet <arthur.huillet@free.fr>2007-07-11 02:33:12 +0200
committerArthur Huillet <arthur.huillet@free.fr>2007-07-11 02:34:00 +0200
commit04e4922c0c407a9f0cfe268f62130891e98fc682 (patch)
treede5b2345aa038456fe6d2d955b685a800fa3a41c /bsd-core
parent023f7d9c0064f912415c92a85c3a9d722191909f (diff)
Made drm_sg_alloc accessible from inside the DRM - drm_sg_alloc_ioctl is the ioctl wrapper
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/drmP.h3
-rw-r--r--bsd-core/drm_drv.c2
-rw-r--r--bsd-core/drm_scatter.c39
3 files changed, 27 insertions, 17 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 9ba3d502..6e05b58f 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -915,6 +915,7 @@ int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
/* Scatter Gather Support (drm_scatter.c) */
void drm_sg_cleanup(drm_sg_mem_t *entry);
+int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request);
#ifdef __FreeBSD__
/* sysctl support (drm_sysctl.h) */
@@ -989,7 +990,7 @@ int drm_agp_unbind_ioctl(DRM_IOCTL_ARGS);
int drm_agp_bind_ioctl(DRM_IOCTL_ARGS);
/* Scatter Gather Support (drm_scatter.c) */
-int drm_sg_alloc(DRM_IOCTL_ARGS);
+int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS);
int drm_sg_free(DRM_IOCTL_ARGS);
/* consistent PCI memory functions (drm_pci.c) */
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index baaeb43c..069774c1 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -117,7 +117,7 @@ static drm_ioctl_desc_t drm_ioctls[256] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
- [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
+ [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0 },
diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c
index 9dc280a4..46222f18 100644
--- a/bsd-core/drm_scatter.c
+++ b/bsd-core/drm_scatter.c
@@ -40,28 +40,20 @@ void drm_sg_cleanup(drm_sg_mem_t *entry)
free(entry, M_DRM);
}
-int drm_sg_alloc(DRM_IOCTL_ARGS)
+int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
{
- DRM_DEVICE;
- drm_scatter_gather_t request;
drm_sg_mem_t *entry;
unsigned long pages;
- int i;
-
- DRM_DEBUG( "%s\n", __FUNCTION__ );
if ( dev->sg )
return EINVAL;
- DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
- sizeof(request) );
-
entry = malloc(sizeof(*entry), M_DRM, M_WAITOK | M_ZERO);
if ( !entry )
return ENOMEM;
pages = round_page(request.size) / PAGE_SIZE;
- DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
+ DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages );
entry->pages = pages;
@@ -86,11 +78,7 @@ int drm_sg_alloc(DRM_IOCTL_ARGS)
DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );
entry->virtual = (void *)entry->handle;
- request.handle = entry->handle;
-
- DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data,
- request,
- sizeof(request) );
+ request->handle = entry->handle;
DRM_LOCK();
if (dev->sg) {
@@ -101,6 +89,27 @@ int drm_sg_alloc(DRM_IOCTL_ARGS)
dev->sg = entry;
DRM_UNLOCK();
+}
+
+int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS)
+{
+ DRM_DEVICE;
+ drm_scatter_gather_t request;
+ int ret;
+
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+
+ DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
+ sizeof(request) );
+
+ ret = drm_sg_alloc(dev, &request);
+ if ( ret ) return ret;
+
+ DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data,
+ request,
+ sizeof(request) );
+
return 0;
}