[PATCH] Implement drmGetCap() to query device/driver capabilities
Ben Skeggs
skeggsb at gmail.com
Sun Feb 20 17:27:19 PST 2011
From: Ben Skeggs <bskeggs at redhat.com>
Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
---
include/drm/drm.h | 7 +++++++
xf86drm.c | 9 +++++++++
xf86drm.h | 1 +
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 2ba7136..fd06c2a 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -612,6 +612,12 @@ struct drm_gem_open {
__u64 size;
};
+/** DRM_IOCTL_GET_CAP ioctl argument type */
+struct drm_get_cap {
+ __u64 capability;
+ __u64 value;
+};
+
#include "drm_mode.h"
#define DRM_IOCTL_BASE 'd'
@@ -632,6 +638,7 @@ struct drm_gem_open {
#define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close)
#define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink)
#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)
+#define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap)
#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)
#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)
diff --git a/xf86drm.c b/xf86drm.c
index 799fcdd..5b060c9 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -810,6 +810,15 @@ drmVersionPtr drmGetLibVersion(int fd)
return (drmVersionPtr)version;
}
+uint64_t drmGetCap(int fd, uint64_t capability)
+{
+ struct drm_get_cap cap = { capability, 0 };
+
+ if (drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap))
+ return 0;
+
+ return cap.value;
+}
/**
* Free the bus ID information.
diff --git a/xf86drm.h b/xf86drm.h
index 9b89f56..1c87b7f 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -542,6 +542,7 @@ extern int drmOpenControl(int minor);
extern int drmClose(int fd);
extern drmVersionPtr drmGetVersion(int fd);
extern drmVersionPtr drmGetLibVersion(int fd);
+extern uint64_t drmGetCap(int fd, uint64_t capability);
extern void drmFreeVersion(drmVersionPtr);
extern int drmGetMagic(int fd, drm_magic_t * magic);
extern char *drmGetBusid(int fd);
--
1.7.4
More information about the dri-devel
mailing list