diff options
-rw-r--r-- | linux-core/i915_gem.c | 43 | ||||
-rw-r--r-- | shared-core/i915_dma.c | 2 | ||||
-rw-r--r-- | shared-core/i915_drm.h | 22 | ||||
-rw-r--r-- | shared-core/i915_drv.h | 4 |
4 files changed, 68 insertions, 3 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); } - diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c index 821b2a95..73f843c8 100644 --- a/shared-core/i915_dma.c +++ b/shared-core/i915_dma.c @@ -1126,6 +1126,8 @@ struct drm_ioctl_desc i915_ioctls[] = { #endif DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), }; int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h index 52d1f31f..4d113e4c 100644 --- a/shared-core/i915_drm.h +++ b/shared-core/i915_drm.h @@ -178,6 +178,8 @@ typedef struct drm_i915_sarea { #define DRM_I915_EXECBUFFER 0x12 #define DRM_I915_GEM_INIT 0x13 #define DRM_I915_GEM_EXECBUFFER 0x14 +#define DRM_I915_GEM_PIN 0x15 +#define DRM_I915_GEM_UNPIN 0x16 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -197,8 +199,10 @@ typedef struct drm_i915_sarea { #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) #define DRM_IOCTL_I915_MMIO DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_MMIO, drm_i915_mmio) #define DRM_IOCTL_I915_EXECBUFFER DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_EXECBUFFER, struct drm_i915_execbuffer) -#define DRM_IOCTL_I915_MM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init) -#define DRM_IOCTL_I915_MM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_execbuffer) +#define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init) +#define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer) +#define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin) +#define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin) /* Asynchronous page flipping: */ @@ -479,4 +483,18 @@ struct drm_i915_gem_execbuffer { struct drm_clip_rect *cliprects; }; +struct drm_i915_gem_pin { + /** Handle of the buffer to be pinned. */ + uint32_t handle; + + /** Returned GTT offset of the buffer. */ + uint64_t offset; +}; + +struct drm_i915_gem_unpin { + /** Handle of the buffer to be unpinned. */ + uint32_t handle; +}; + + #endif /* _I915_DRM_H_ */ diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index 431fc433..801ac99e 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -362,6 +362,10 @@ int i915_gem_init_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); int i915_gem_execbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv); +int i915_gem_pin_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); +int i915_gem_unpin_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); int i915_gem_init_object(struct drm_device *dev, struct drm_gem_object *obj); void i915_gem_free_object(struct drm_device *dev, struct drm_gem_object *obj); |