[PATCH 1/2] libdrm: add functions for render node manipulation
Ilija Hadzic
ihadzic at research.bell-labs.com
Thu Mar 29 09:46:45 PDT 2012
Implement the user-space side of drm_render_node_create
and drm_render_node_remove ioctls. The new functions
are drmCreateRenderNode and drmRemoveRenderNode.
Signed-off-by: Ilija Hadzic <ihadzic at research.bell-labs.com>
---
include/drm/drm.h | 2 +
include/drm/drm_mode.h | 16 +++++++++++++
xf86drm.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
xf86drm.h | 5 ++++
4 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 8adb9d5..d5bb126 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -639,6 +639,8 @@ struct drm_get_cap {
#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_RENDER_NODE_CREATE DRM_IOWR(0x0d, struct drm_render_node_create)
+#define DRM_IOCTL_RENDER_NODE_REMOVE DRM_IOWR(0x0e, struct drm_render_node_remove)
#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/include/drm/drm_mode.h b/include/drm/drm_mode.h
index f36c61a..2998629 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -437,4 +437,20 @@ struct drm_mode_destroy_dumb {
__u32 handle;
};
+/*
+ * render node create and remove functions
+ * if crtc/encoders/connectors all == 0 then gpgpu node
+ */
+struct drm_render_node_create {
+ __u32 node_minor_id;
+ __u32 num_crtc;
+ __u32 num_encoder;
+ __u32 num_connector;
+ __u64 id_list_ptr;
+};
+
+struct drm_render_node_remove {
+ __u32 node_minor_id;
+};
+
#endif
diff --git a/xf86drm.c b/xf86drm.c
index 7def2b3..af43332 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2552,3 +2552,59 @@ char *drmGetDeviceNameFromFd(int fd)
out:
return strdup(name);
}
+
+/**
+ * Create a new render node.
+ *
+ * \param fd file descriptor.
+ * \param minor pointer where to put the minor of the new node.
+ * \param num_crtc number of CRTCs to assign to the new node.
+ * \param num_encoder number of encoders to assign to the new node.
+ * \param num_connector number of connectors to assign to the new node.
+ * \param id_list list of CRTC/encoder/connector IDs.
+ *
+ * \return zero on success, or a negative value on failure.
+ *
+ * \internal
+ * Issues an ioctl to the kernel to create a new render node
+ * and popluates the variable pointed by *minor with the new minor
+ * device number.
+ */
+int drmCreateRenderNode(int fd, int *minor,
+ int num_crtc, int num_encoder, int num_connector,
+ uint32_t *id_list)
+{
+ struct drm_render_node_create node;
+ int r;
+
+ node.num_crtc = num_crtc;
+ node.num_encoder = num_encoder;
+ node.num_connector = num_connector;
+ node.id_list_ptr = (uint64_t)(unsigned long)id_list;
+ r = drmIoctl(fd, DRM_IOCTL_RENDER_NODE_CREATE, &node);
+ if (!r)
+ *minor = node.node_minor_id;
+ return r;
+}
+
+/**
+ * Remove the render node.
+ *
+ * \param fd file descriptor.
+ * \param minor minor device number to remove.
+ *
+ * \return zero on success, or a negative value on failure.
+ *
+ * \internal
+ * Issues an ioctl to the kernel to remove a new render node
+ * identified by the file descriptor and the minor device number.
+ */
+int drmRemoveRenderNode(int fd, int minor)
+{
+ struct drm_render_node_remove node;
+ int r;
+
+ node.node_minor_id = minor;
+ r = drmIoctl(fd, DRM_IOCTL_RENDER_NODE_REMOVE, &node);
+ return r;
+}
diff --git a/xf86drm.h b/xf86drm.h
index 76eb94e..bd5b11e 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -701,6 +701,11 @@ extern void drmMsg(const char *format, ...);
extern int drmSetMaster(int fd);
extern int drmDropMaster(int fd);
+extern int drmCreateRenderNode(int fd, int *minor,
+ int num_crtc, int num_encoder, int num_connector,
+ uint32_t *id_list);
+extern int drmRemoveRenderNode(int fd, int minor);
+
#define DRM_EVENT_CONTEXT_VERSION 2
typedef struct _drmEventContext {
--
1.7.8.5
More information about the dri-devel
mailing list