Add helper functions to set/get GEM context parameters. Signed-off-by: David Weinehall <david.weinehall@xxxxxxxxxxxxxxx> --- intel/intel_bufmgr.h | 4 ++++ intel/intel_bufmgr_gem.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) 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..2ac00cb3be3e 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, + ¶m); + 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, + ¶m); + if (ret != 0) + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s\n", + strerror(errno)); + + return ret; +} + +int drm_intel_get_reset_stats(drm_intel_context *ctx, uint32_t *reset_count, uint32_t *active, -- 2.1.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel