diff mbox

[02/03] libdrm: export context_{get, set}param and I915_CONTEXT_PARAM_NO_ZEROMAP

Message ID 20150520140141.GC13974@boom (mailing list archive)
State New, archived
Headers show

Commit Message

David Weinehall May 20, 2015, 2:01 p.m. UTC
Provide helper functions for the context_{get,set}param ioctls,
as well as the I915_CONTEXT_PARAM_NO_ZEROMAP parameter.

Signed-off-by: David Weinehall <david.weinehall@intel.com>
---
 configure.ac             |    2 -
 include/drm/i915_drm.h   |    1 
 intel/intel_bufmgr.h     |    4 +++
 intel/intel_bufmgr_gem.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 78a0010d851f..e48fb7e87c52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ 
 
 AC_PREREQ([2.63])
 AC_INIT([libdrm],
-        [2.4.61],
+        [2.4.62],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
         [libdrm])
 
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index ded43b1cb117..a658d1cc367a 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -1101,6 +1101,7 @@  struct drm_i915_gem_context_param {
 	__u32 size;
 	__u64 param;
 #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
+#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
 	__u64 value;
 };
 
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 285919e4c40d..b9af2361735d 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -203,6 +203,10 @@  int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns);
 
 drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr);
 void drm_intel_gem_context_destroy(drm_intel_context *ctx);
+int drm_intel_gem_context_get_param(drm_intel_context *ctx,
+				    uint64_t param, uint64_t *value);
+int drm_intel_gem_context_set_param(drm_intel_context *ctx,
+				    uint64_t param, uint64_t value);
 int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
 				  int used, unsigned int flags);
 
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 60c06fccfb20..53378df2ecdf 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3326,6 +3326,63 @@  drm_intel_gem_context_destroy(drm_intel_context *ctx)
 }
 
 int
+drm_intel_gem_context_get_param(drm_intel_context *ctx,
+				uint64_t param, uint64_t *value)
+{
+	drm_intel_bufmgr_gem *bufmgr_gem;
+	struct drm_i915_gem_context_param ctx_param;
+	int ret;
+
+	if (ctx == NULL)
+		return -EINVAL;
+
+	memclear(ctx_param);
+
+	bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr;
+
+	ctx_param.ctx_id = ctx->ctx_id;
+	ctx_param.param = param;
+
+	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM,
+		       &ctx_param);
+	if (ret != 0)
+		fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM failed: %s\n",
+			strerror(errno));
+	else
+		*value = ctx_param.value;
+
+	return ret;
+}
+
+int
+drm_intel_gem_context_set_param(drm_intel_context *ctx,
+				uint64_t param, uint64_t value)
+{
+	drm_intel_bufmgr_gem *bufmgr_gem;
+	struct drm_i915_gem_context_param ctx_param;
+	int ret;
+
+	if (ctx == NULL)
+		return -EINVAL;
+
+	memclear(ctx_param);
+
+	bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr;
+
+	ctx_param.ctx_id = ctx->ctx_id;
+	ctx_param.param = param;
+	ctx_param.value = value;
+
+	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM,
+		       &ctx_param);
+	if (ret != 0)
+		fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s (%d); %d\n",
+			strerror(errno), errno, ret);
+
+	return ret;
+}
+
+int
 drm_intel_get_reset_stats(drm_intel_context *ctx,
 			  uint32_t *reset_count,
 			  uint32_t *active,