summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-05-01 15:40:02 -0700
committerEric Anholt <eric@anholt.net>2008-05-01 15:40:02 -0700
commit793549116ee6e9202fc7e474bd382eb19ffeb87f (patch)
tree0e8771e6e19ada35bc9638818657a206f970eac2 /linux-core
parentccd1bae0f676490a88240c62f02e072d2cf3b030 (diff)
Add pin/unpin object ioctls for gem.
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/i915_gem.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/linux-core/i915_gem.c b/linux-core/i915_gem.c
index 3e4403c7..fc9e53cf 100644
--- a/linux-core/i915_gem.c
+++ b/linux-core/i915_gem.c
@@ -328,6 +328,48 @@ err:
return ret;
}
+int
+i915_gem_pin(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_i915_gem_pin *args = data;
+ struct drm_gem_object *obj;
+ struct drm_i915_gem_object *obj_priv;
+ int ret;
+
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
+ if (obj == NULL)
+ return -EINVAL;
+
+ ret = i915_gem_object_bind_to_gtt(dev, obj);
+ if (ret != 0)
+ return ret;
+
+ obj_priv = obj->driver_private;
+ obj_priv->pin_count++;
+ args->offset = obj_priv->gtt_offset;
+
+ return 0;
+}
+
+int
+i915_gem_unpin(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_i915_gem_pin *args = data;
+ struct drm_gem_object *obj;
+ struct drm_i915_gem_object *obj_priv;
+
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
+ if (obj == NULL)
+ return -EINVAL;
+
+ obj_priv = obj->driver_private;
+ obj_priv->pin_count--;
+
+ return 0;
+}
+
int i915_gem_init_object(struct drm_device *dev, struct drm_gem_object *obj)
{
struct drm_i915_gem_object *obj_priv;
@@ -345,4 +387,3 @@ void i915_gem_free_object(struct drm_device *dev, struct drm_gem_object *obj)
{
drm_free(obj->driver_private, 1, DRM_MEM_DRIVER);
}
-