summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorMichał Winiarski <michal.winiarski@intel.com>2017-10-16 11:05:16 +0200
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2017-10-17 10:26:30 +0300
commit131ad520cb44c7dafacc6ef327d9fa6cda9067ab (patch)
tree2a37ff7dfdc99faf8ef5722c4614bfac813df228 /lib/ioctl_wrappers.c
parent588555f779095a9d282f414aec22e5532891ecdc (diff)
lib/i915: Move context related helpers to lib/i915/gem_context
We'd like to make ioctl_wrappers a bit thinner, and we plan to add new helpers in the following patch. Let's move context related helpers before adding more content. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c157
1 files changed, 1 insertions, 156 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 87511fc6..7ad2b7b0 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -894,161 +894,6 @@ int gem_madvise(int fd, uint32_t handle, int state)
return madv.retained;
}
-/**
- * gem_context_create:
- * @fd: open i915 drm file descriptor
- *
- * This wraps the CONTEXT_CREATE ioctl, which is used to allocate a new
- * context. Note that similarly to gem_set_caching() this wrapper skips on
- * kernels and platforms where context support is not available.
- *
- * Returns: The id of the allocated context.
- */
-uint32_t gem_context_create(int fd)
-{
- struct drm_i915_gem_context_create create;
-
- memset(&create, 0, sizeof(create));
- if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) {
- int err = -errno;
- igt_skip_on(err == -ENODEV || errno == -EINVAL);
- igt_assert_eq(err, 0);
- }
- igt_assert(create.ctx_id != 0);
- errno = 0;
-
- return create.ctx_id;
-}
-
-int __gem_context_destroy(int fd, uint32_t ctx_id)
-{
- struct drm_i915_gem_context_destroy destroy;
- int ret;
-
- memset(&destroy, 0, sizeof(destroy));
- destroy.ctx_id = ctx_id;
-
- ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
- if (ret)
- return -errno;
- return 0;
-}
-
-/**
- * gem_context_destroy:
- * @fd: open i915 drm file descriptor
- * @ctx_id: i915 context id
- *
- * This wraps the CONTEXT_DESTROY ioctl, which is used to free a context.
- */
-void gem_context_destroy(int fd, uint32_t ctx_id)
-{
- struct drm_i915_gem_context_destroy destroy;
-
- memset(&destroy, 0, sizeof(destroy));
- destroy.ctx_id = ctx_id;
-
- do_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
-}
-
-int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_GETPARAM 0x34
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
- if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p))
- return -errno;
-
- errno = 0;
- return 0;
-}
-
-/**
- * gem_context_get_param:
- * @fd: open i915 drm file descriptor
- * @p: i915 context parameter
- *
- * This wraps the CONTEXT_GET_PARAM ioctl, which is used to get a context
- * parameter.
- */
-void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
-{
- igt_assert(__gem_context_get_param(fd, p) == 0);
-}
-
-
-int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_SETPARAM 0x35
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
- if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p))
- return -errno;
-
- errno = 0;
- return 0;
-}
-/**
- * gem_context_set_param:
- * @fd: open i915 drm file descriptor
- * @p: i915 context parameter
- *
- * This wraps the CONTEXT_SET_PARAM ioctl, which is used to set a context
- * parameter.
- */
-void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
-{
- igt_assert(__gem_context_set_param(fd, p) == 0);
-}
-
-/**
- * gem_context_require_param:
- * @fd: open i915 drm file descriptor
- * @param: i915 context parameter
- *
- * Feature test macro to query whether context parameter support for @param
- * is available. Automatically skips through igt_require() if not.
- */
-void gem_context_require_param(int fd, uint64_t param)
-{
- struct local_i915_gem_context_param p;
-
- p.context = 0;
- p.param = param;
- p.value = 0;
- p.size = 0;
-
- igt_require(igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
-}
-
-void gem_context_require_bannable(int fd)
-{
- static int has_ban_period = -1;
- static int has_bannable = -1;
-
- if (has_bannable < 0) {
- struct local_i915_gem_context_param p;
-
- p.context = 0;
- p.param = LOCAL_CONTEXT_PARAM_BANNABLE;
- p.value = 0;
- p.size = 0;
-
- has_bannable = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
- }
-
- if (has_ban_period < 0) {
- struct local_i915_gem_context_param p;
-
- p.context = 0;
- p.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
- p.value = 0;
- p.size = 0;
-
- has_ban_period = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
- }
-
- igt_require(has_ban_period || has_bannable);
-}
-
int __gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t flags, uint32_t *handle)
{
struct local_i915_gem_userptr userptr;
@@ -1455,7 +1300,7 @@ uint64_t gem_aperture_size(int fd)
memset(&p, 0, sizeof(p));
p.param = 0x3;
- if (ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0) {
+ if (__gem_context_get_param(fd, &p) == 0) {
aperture_size = p.value;
} else {
struct drm_i915_gem_get_aperture aperture;