All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilija Hadzic <ihadzic@research.bell-labs.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] libdrm: add functions for render node manipulation
Date: Thu, 29 Mar 2012 12:46:45 -0400	[thread overview]
Message-ID: <1333039606-2576-2-git-send-email-ihadzic@research.bell-labs.com> (raw)
In-Reply-To: <1333039606-2576-1-git-send-email-ihadzic@research.bell-labs.com>

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@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

  reply	other threads:[~2012-03-29 16:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 16:46 libdrm part of the render-node patch series Ilija Hadzic
2012-03-29 16:46 ` Ilija Hadzic [this message]
2012-03-29 16:46 ` [PATCH 2/2] tests: add render_node tests Ilija Hadzic
2012-04-12 18:24 [RFC v2] libdrm part of the render-node patch series Ilija Hadzic
2012-04-12 18:24 ` [PATCH 1/2] libdrm: add functions for render node manipulation Ilija Hadzic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333039606-2576-2-git-send-email-ihadzic@research.bell-labs.com \
    --to=ihadzic@research.bell-labs.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.