Skip to contentSkip to conversation

Rename DRM_NODE_RENDER to DRM_NODE_PRIMARY

PATCH In review Frank Binns 3 participants 5 messages Jan 14, 2015 – Jan 23, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Rename DRM_NODE_RENDER to DRM_NODE_PRIMARY

Now that there are render nodes it doesn't seem appropriate for the type of the card nodes to be DRM_NODE_RENDER. For this reason, rename this type to DRM_NODE_PRIMARY as this name better represents the purpose of these nodes.

---
 tests/dristat.c |  2 +-
 xf86drm.c       | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
tests/dristat.c +1 -1
index 4f2ee80..449aa24 100644
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
 
     for (i = 0; i < 16; i++) if (!minor || i == minor) {
 	sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
-	fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+	fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
 	if (fd >= 0) {
 	    printf("%s\n", buf);
 	    if (mask & DRM_BUSID)   getbusid(fd);
xf86drm.c +5 -5
index d900b4b..a23d029 100644
@@ -86,7 +86,7 @@
 #define DRM_MSG_VERBOSITY 3
 
 #define DRM_NODE_CONTROL 0
-#define DRM_NODE_RENDER 1
+#define DRM_NODE_PRIMARY 1
 
 static drmServerInfoPtr drm_server_info;
 
@@ -444,7 +444,7 @@ int drmAvailable(void)
     int           retval = 0;
     int           fd;
 
-    if ((fd = drmOpenMinor(0, 1, DRM_NODE_RENDER)) < 0) {
+    if ((fd = drmOpenMinor(0, 1, DRM_NODE_PRIMARY)) < 0) {
 #ifdef __linux__
 	/* Try proc for backward Linux compatibility */
 	if (!access("/proc/dri/0", R_OK))
@@ -485,7 +485,7 @@ static int drmOpenByBusid(const char *busid)
 
     drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-	fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+	fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
 	drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
 	if (fd >= 0) {
 	    /* We need to try for 1.4 first for proper PCI domain support
@@ -547,7 +547,7 @@ static int drmOpenByName(const char *name)
      * already in use.  If it's in use it will have a busid assigned already.
      */
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-	if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) {
+	if ((fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY)) >= 0) {
 	    if ((version = drmGetVersion(fd))) {
 		if (!strcmp(version->name, name)) {
 		    drmFreeVersion(version);
@@ -591,7 +591,7 @@ static int drmOpenByName(const char *name)
 			if (*pt) { /* Found busid */
 			    return drmOpenByBusid(++pt);
 			} else { /* No busid */
-			    return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_RENDER);
+			    return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_PRIMARY);
 			}
 		    }
 		}
Signature · 6 lines
1.8.5.4.gfdaaaa2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 Add new drmOpenRender function

Add a new function, drmOpenRender, that can be used to open render nodes. This can be used in the same way that drmOpenControl is used to open control nodes.

---
 xf86drm.c | 40 ++++++++++++++++++++++++++++++++++++++--
 xf86drm.h |  2 ++
 2 files changed, 40 insertions(+), 2 deletions(-)
xf86drm.c +38 -2
index a23d029..345325a 100644
@@ -87,6 +87,7 @@
 
 #define DRM_NODE_CONTROL 0
 #define DRM_NODE_PRIMARY 1
+#define DRM_NODE_RENDER 2
 
 static drmServerInfoPtr drm_server_info;
 
@@ -305,6 +306,7 @@ static int chown_check_return(const char *path, uid_t owner, gid_t group)
 static int drmOpenDevice(long dev, int minor, int type)
 {
     stat_t          st;
+    const char      *dev_name;
     char            buf[64];
     int             fd;
     mode_t          devmode = DRM_DEV_MODE, serv_mode;
@@ -312,7 +314,21 @@ static int drmOpenDevice(long dev, int minor, int type)
     uid_t           user    = DRM_DEV_UID;
     gid_t           group   = DRM_DEV_GID, serv_group;
     
-    sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor);
+    switch (type) {
+    case DRM_NODE_PRIMARY:
+	    dev_name = DRM_DEV_NAME;
+	    break;
+    case DRM_NODE_CONTROL:
+	    dev_name = DRM_CONTROL_DEV_NAME;
+	    break;
+    case DRM_NODE_RENDER:
+	    dev_name = DRM_RENDER_DEV_NAME;
+	    break;
+    default:
+	    return -EINVAL;
+    };
+
+    sprintf(buf, dev_name, DRM_DIR_NAME, minor);
     drmMsg("drmOpenDevice: node name is %s\n", buf);
 
     if (drm_server_info) {
@@ -417,11 +433,26 @@ static int drmOpenMinor(int minor, int create, int type)
 {
     int  fd;
     char buf[64];
+    const char *dev_name;
     
     if (create)
 	return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
     
-    sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor);
+    switch (type) {
+    case DRM_NODE_PRIMARY:
+	    dev_name = DRM_DEV_NAME;
+	    break;
+    case DRM_NODE_CONTROL:
+	    dev_name = DRM_CONTROL_DEV_NAME;
+	    break;
+    case DRM_NODE_RENDER:
+	    dev_name = DRM_RENDER_DEV_NAME;
+	    break;
+    default:
+	    return -EINVAL;
+    };
+
+    sprintf(buf, dev_name, DRM_DIR_NAME, minor);
     if ((fd = open(buf, O_RDWR, 0)) >= 0)
 	return fd;
     return -errno;
@@ -646,6 +677,11 @@ int drmOpenControl(int minor)
     return drmOpenMinor(minor, 0, DRM_NODE_CONTROL);
 }
 
+int drmOpenRender(int minor)
+{
+    return drmOpenMinor(minor, 0, DRM_NODE_RENDER);
+}
+
 /**
  * Free the version information returned by drmGetVersion().
  *
xf86drm.h +2 -0
index c024cc4..bfd0670 100644
@@ -79,6 +79,7 @@ extern "C" {
 #define DRM_DIR_NAME  "/dev/dri"
 #define DRM_DEV_NAME  "%s/card%d"
 #define DRM_CONTROL_DEV_NAME  "%s/controlD%d"
+#define DRM_RENDER_DEV_NAME  "%s/renderD%d"
 #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
 
 #define DRM_ERR_NO_DEVICE  (-1001)
@@ -552,6 +553,7 @@ do {	register unsigned int __old __asm("o0");		\
 extern int           drmAvailable(void);
 extern int           drmOpen(const char *name, const char *busid);
 extern int drmOpenControl(int minor);
+extern int           drmOpenRender(int minor);
 extern int           drmClose(int fd);
 extern drmVersionPtr drmGetVersion(int fd);
 extern drmVersionPtr drmGetLibVersion(int fd);
Signature · 6 lines
1.8.5.4.gfdaaaa2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Frank Binns

Ping

Quoted 64 lines · Frank Binns

Now that there are render nodes it doesn't seem appropriate for the type of the card nodes to be DRM_NODE_RENDER. For this reason, rename this type to DRM_NODE_PRIMARY as this name better represents the purpose of these nodes.

---
 tests/dristat.c |  2 +-
 xf86drm.c       | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
tests/dristat.c +1 -1
index 4f2ee80..449aa24 100644
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
 
     for (i = 0; i < 16; i++) if (!minor || i == minor) {
 	sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
-	fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+	fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
 	if (fd >= 0) {
 	    printf("%s\n", buf);
 	    if (mask & DRM_BUSID)   getbusid(fd);
xf86drm.c +4 -4
index d900b4b..a23d029 100644
@@ -86,7 +86,7 @@
 #define DRM_MSG_VERBOSITY 3
 
 #define DRM_NODE_CONTROL 0
-#define DRM_NODE_RENDER 1
+#define DRM_NODE_PRIMARY 1
 
 static drmServerInfoPtr drm_server_info;
 
@@ -444,7 +444,7 @@ int drmAvailable(void)
     int           retval = 0;
     int           fd;
 
-    if ((fd = drmOpenMinor(0, 1, DRM_NODE_RENDER)) < 0) {
+    if ((fd = drmOpenMinor(0, 1, DRM_NODE_PRIMARY)) < 0) {
 #ifdef __linux__
 	/* Try proc for backward Linux compatibility */
 	if (!access("/proc/dri/0", R_OK))
@@ -485,7 +485,7 @@ static int drmOpenByBusid(const char *busid)
 
     drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-	fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+	fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
 	drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
 	if (fd >= 0) {
 	    /* We need to try for 1.4 first for proper PCI domain support
@@ -547,7 +547,7 @@ static int drmOpenByName(const char *name)
      * already in use.  If it's in use it will have a busid assigned already.
      */
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-	if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) {
+	if ((fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY)) >= 0) {
 	    if ((version = drmGetVersion(fd))) {
 		if (!strcmp(version->name, name)) {
 		    drmFreeVersion(version);

xf86drm.c static int drmOpenByName(const char *name) · line 597

Quoted 8 lines
xf86drm.c +1 -1
@@ -591,7 +591,7 @@ static int drmOpenByName(const char *name)
 			if (*pt) { /* Found busid */
 			    return drmOpenByBusid(++pt);
 			} else { /* No busid */
-			    return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_RENDER);
+			    return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_PRIMARY);
 			}
 		    }
 		}

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/2
#4 lore raw
In reply to Frank Binns
Quoted 5 lines · Frank Binns

Now that there are render nodes it doesn't seem appropriate for the type of the card nodes to be DRM_NODE_RENDER. For this reason, rename this type to DRM_NODE_PRIMARY as this name better represents the purpose of these nodes.

looks reasonable.. for the series:

Quoted 70 lines
---
 tests/dristat.c |  2 +-
 xf86drm.c       | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
tests/dristat.c +1 -1
index 4f2ee80..449aa24 100644
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
 
     for (i = 0; i < 16; i++) if (!minor || i == minor) {
        sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
-       fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+       fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
        if (fd >= 0) {
            printf("%s\n", buf);
            if (mask & DRM_BUSID)   getbusid(fd);
xf86drm.c +5 -6
index d900b4b..a23d029 100644
@@ -86,7 +86,7 @@
 #define DRM_MSG_VERBOSITY 3
 
 #define DRM_NODE_CONTROL 0
-#define DRM_NODE_RENDER 1
+#define DRM_NODE_PRIMARY 1
 
 static drmServerInfoPtr drm_server_info;
 
@@ -444,7 +444,7 @@ int drmAvailable(void)
     int           retval = 0;
     int           fd;
 
-    if ((fd = drmOpenMinor(0, 1, DRM_NODE_RENDER)) < 0) {
+    if ((fd = drmOpenMinor(0, 1, DRM_NODE_PRIMARY)) < 0) {
 #ifdef __linux__
        /* Try proc for backward Linux compatibility */
        if (!access("/proc/dri/0", R_OK))
@@ -485,7 +485,7 @@ static int drmOpenByBusid(const char *busid)
 
     drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-       fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
+       fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
        drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
        if (fd >= 0) {
            /* We need to try for 1.4 first for proper PCI domain support
@@ -547,7 +547,7 @@ static int drmOpenByName(const char *name)
      * already in use.  If it's in use it will have a busid assigned already.
      */
     for (i = 0; i < DRM_MAX_MINOR; i++) {
-       if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) {
+       if ((fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY)) >= 0) {
            if ((version = drmGetVersion(fd))) {
                if (!strcmp(version->name, name)) {
                    drmFreeVersion(version);
@@ -591,7 +591,7 @@ static int drmOpenByName(const char *name)
                        if (*pt) { /* Found busid */
                            return drmOpenByBusid(++pt);
                        } else { /* No busid */
-                           return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_RENDER);
+                           return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_PRIMARY);
                        }
                    }
                }
--

1.8.5.4.gfdaaaa2

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel