summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index f224091e..818853ee 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -455,7 +455,7 @@ bool gem_create__has_stolen_support(int fd)
if (has_stolen_support < 0) {
memset(&gp, 0, sizeof(gp));
- gp.param = 36; /* CREATE_VERSION */
+ gp.param = 38; /* CREATE_VERSION */
gp.value = &val;
/* Do we have the extended gem_create_ioctl? */
@@ -1230,6 +1230,52 @@ bool gem_has_bsd2(int fd)
has_bsd2 = has_param(fd, LOCAL_I915_PARAM_HAS_BSD2);
return has_bsd2;
}
+
+struct local_i915_gem_get_aperture {
+ __u64 aper_size;
+ __u64 aper_available_size;
+ __u64 version;
+ __u64 map_total_size;
+ __u64 stolen_total_size;
+};
+#define DRM_I915_GEM_GET_APERTURE 0x23
+#define LOCAL_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct local_i915_gem_get_aperture)
+/**
+ * gem_total_mappable_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total mappable size.
+ *
+ * Returns: Total mappable address space size.
+ */
+uint64_t gem_total_mappable_size(int fd)
+{
+ struct local_i915_gem_get_aperture aperture;
+
+ memset(&aperture, 0, sizeof(aperture));
+ do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+ return aperture.map_total_size;
+}
+
+/**
+ * gem_total_stolen_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total stolen size.
+ *
+ * Returns: Total stolen memory.
+ */
+uint64_t gem_total_stolen_size(int fd)
+{
+ struct local_i915_gem_get_aperture aperture;
+
+ memset(&aperture, 0, sizeof(aperture));
+ do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+ return aperture.stolen_total_size;
+}
+
/**
* gem_available_aperture_size:
* @fd: open i915 drm file descriptor