Module Name:    xsrc
Committed By:   macallan
Date:           Fri Jun 26 18:17:42 UTC 2009

Modified Files:
        xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus:
            netbsdSbus.c

Log Message:
add sparcDriverName() - from Sbus.c


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
    xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c
diff -u xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c:1.1 xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c:1.2
--- xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c:1.1	Fri Oct 24 19:34:08 2008
+++ xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bus/netbsdSbus.c	Fri Jun 26 18:17:42 2009
@@ -22,6 +22,10 @@
  */
 /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c,v 1.2 2001/10/28 03:34:01 tsi Exp $ */
 
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -537,6 +541,60 @@
     return i;
 }
 
+static char *
+promWalkGetDriverName(int node, int oldnode)
+{
+    int nextnode;
+    int len;
+    char *prop;
+    int devId, i;
+
+    prop = promGetProperty("device_type", &len);
+    if (prop && (len > 0)) do {
+	if (!strcmp(prop, "display")) {
+	    prop = promGetProperty("name", &len);
+	    if (!prop || len <= 0)
+		break;
+	    while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
+		prop++;
+	    for (i = 0; sbusDeviceTable[i].devId; i++)
+		if (!strcmp(prop, sbusDeviceTable[i].promName))
+		    break;
+	    devId = sbusDeviceTable[i].devId;
+	    if (!devId)
+		break;
+	    if (sbusDeviceTable[i].driverName)
+	    	return sbusDeviceTable[i].driverName;
+	}
+    } while (0);
+
+    nextnode = promGetChild(node);
+    if (nextnode) {
+	char *name;
+	name = promWalkGetDriverName(nextnode, node);
+	if (name)
+	    return name;
+    }
+
+    nextnode = promGetSibling(node);
+    if (nextnode)
+	return promWalkGetDriverName(nextnode, node);
+    return NULL;
+}
+
+char *
+sparcDriverName(void)
+{
+    char *name;
+
+    if (sparcPromInit() < 0)
+	    return NULL;
+    promGetSibling(0);
+    name = promWalkGetDriverName(promRootNode, 0);
+    sparcPromClose();
+    return name;
+}
+
 pointer
 xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size)
 {

Reply via email to