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, 12 Apr 2012 14:24:31 -0400	[thread overview]
Message-ID: <1334255072-3265-2-git-send-email-ihadzic@research.bell-labs.com> (raw)
In-Reply-To: <1334255072-3265-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.

v2: - add planes

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
 include/drm/drm.h      |    2 +
 include/drm/drm_mode.h |   17 ++++++++++++++
 xf86drm.c              |   58 ++++++++++++++++++++++++++++++++++++++++++++++++
 xf86drm.h              |    6 +++++
 4 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/include/drm/drm.h b/include/drm/drm.h
index 753d2fc..7d82130 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -650,6 +650,8 @@ struct drm_prime_handle {
 #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..5e719fd 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -437,4 +437,21 @@ 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;
+	__u32 num_plane;
+	__u64 id_list_ptr;
+};
+
+struct drm_render_node_remove {
+	__u32 node_minor_id;
+};
+
 #endif
diff --git a/xf86drm.c b/xf86drm.c
index 7def2b3..eb813e0 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2552,3 +2552,61 @@ 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, int num_plane,
+			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.num_plane = num_plane;
+	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..0658a85 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -701,6 +701,12 @@ 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, int num_plane,
+			       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-04-12 18:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 18:24 [RFC v2] libdrm part of the render-node patch series Ilija Hadzic
2012-04-12 18:24 ` Ilija Hadzic [this message]
2012-04-12 18:24 ` [PATCH 2/2] tests: add render_node tests Ilija Hadzic
  -- strict thread matches above, loose matches on Subject: below --
2012-03-29 16:46 libdrm part of the render-node patch series Ilija Hadzic
2012-03-29 16:46 ` [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=1334255072-3265-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.