summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorDavid Dawes <dawes@xfree86.org>2001-07-30 19:59:39 +0000
committerDavid Dawes <dawes@xfree86.org>2001-07-30 19:59:39 +0000
commit56bd9c207770d41a497f3e8237a1099dd9d4cd91 (patch)
tree528632e9ff74ae98caa8c55d4a8f201669c00e93 /libdrm
parent84a5e7108773d5a5ff7242e1460c98e3acb178a8 (diff)
Merge the multihead-1-0-0 branch into the trunk, with the exception of the
glide header files. The changes include: - Brian Paul's changes to the tdfx client-side 3D driver to make it dlopen() the correct glide library (Voodoo3 or Voodoo5). This allows both types of the glide library to co-exist, and allows Voodoo3/Voodoo5 cards to be mixed in multi-head configs. - DRM kernel driver changes to allow a driver to set up multiple instances (minor numbers), one for each card present that the driver supports. This is currently implemented and tested only for the tdfx DRM driver. - Add some missing missing <stdarg.h> includes. - Some log message cleanups. - Change the 2D tdfx driver to access VGA legacy registers via their PCI I/O space access points rather than their legacy addresses, and fix some problems with the way the VGA-related bits are initialised. Status: - With these changes, multi-head direct rendering works with multiple Voodoo3 and/or Voodoo5 cards. This has been tested with two PCI Voodoo3 cards and an AGP Voodoo5 card, and all permutations of those. Caveats: - Xinerama is not supported. If Xinerama is enabled, then direct rendering gets disabled. - The text mode on secondary screens will show junk after the X server exits. - On some hardware, starting the X server on multiple 3dfx cards will result in a hard lockup. One workaround is to enable APIC support in a uni-processor kernel, or use an SMP kernel.
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drm.c62
1 files changed, 57 insertions, 5 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index a04cf7ae..5ed8f1f8 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -55,6 +55,7 @@
# include <sys/ioctl.h>
# include <sys/mman.h>
# include <sys/time.h>
+# include <stdarg.h>
# ifdef DRM_USE_MALLOC
# define _DRM_MALLOC malloc
# define _DRM_FREE free
@@ -107,6 +108,28 @@ extern unsigned long _bus_base(void);
#define makedev(x,y) ((dev_t)(((x) << 8) | (y)))
#endif
+#define DRM_MSG_VERBOSITY 3
+
+static void
+drmMsg(const char *format, ...)
+{
+ va_list ap;
+
+#ifndef XFree86Server
+ const char *env;
+ if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose"))
+#endif
+ {
+ va_start(ap, format);
+#ifdef XFree86Server
+ xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
+#else
+ vfprintf(stderr, format, ap);
+#endif
+ va_end(ap);
+ }
+}
+
static void *drmHashTable = NULL; /* Context switch callbacks */
typedef struct drmHashEntry {
@@ -182,6 +205,8 @@ static int drmOpenDevice(long dev, int minor)
gid_t group = DRM_DEV_GID;
#endif
+ drmMsg("drmOpenDevice: minor is %d\n", minor);
+
#if defined(XFree86Server)
devmode = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE;
dirmode = (devmode & S_IRUSR) ? S_IXUSR : 0;
@@ -203,6 +228,7 @@ static int drmOpenDevice(long dev, int minor)
#endif
sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor);
+ drmMsg("drmOpenDevice: node name is %s\n", buf);
if (stat(buf, &st) || st.st_rdev != dev) {
if (!isroot) return DRM_ERR_NOT_ROOT;
remove(buf);
@@ -213,7 +239,11 @@ static int drmOpenDevice(long dev, int minor)
chmod(buf, devmode);
#endif
- if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd;
+ fd = open(buf, O_RDWR, 0);
+ drmMsg("drmOpenDevice: open result is %d, (%s)\n",
+ fd, fd < 0 ? strerror(errno) : "OK");
+ if (fd >= 0) return fd;
+ drmMsg("drmOpenDevice: Open failed\n");
remove(buf);
return -errno;
}
@@ -261,9 +291,13 @@ static int drmOpenByBusid(const char *busid)
int fd;
const char *buf;
+ drmMsg("drmOpenByBusid: busid is %s\n", busid);
for (i = 0; i < DRM_MAX_MINOR; i++) {
- if ((fd = drmOpenMinor(i, 0)) >= 0) {
+ fd = drmOpenMinor(i, 1);
+ drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
+ if (fd >= 0) {
buf = drmGetBusid(fd);
+ drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
if (buf && !strcmp(buf, busid)) {
drmFreeBusid(buf);
return fd;
@@ -280,6 +314,7 @@ static int drmOpenByName(const char *name)
int i;
int fd;
drmVersionPtr version;
+ char * id;
if (!drmAvailable()) {
#if !defined(XFree86Server)
@@ -294,15 +329,30 @@ static int drmOpenByName(const char *name)
#endif
}
+ /*
+ * Open the first minor number that matches the driver name and isn't
+ * 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)) >= 0) {
if ((version = drmGetVersion(fd))) {
if (!strcmp(version->name, name)) {
drmFreeVersion(version);
- return fd;
+ id = drmGetBusid(fd);
+ drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
+ if (!id || !*id) {
+ if (id) {
+ drmFreeBusid(id);
+ }
+ return fd;
+ } else {
+ drmFreeBusid(id);
+ }
+ } else {
+ drmFreeVersion(version);
}
- drmFreeVersion(version);
}
+ close(fd);
}
}
@@ -459,7 +509,9 @@ int drmSetBusid(int fd, const char *busid)
u.unique = (char *)busid;
u.unique_len = strlen(busid);
- if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) return -errno;
+ if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) {
+ return -errno;
+ }
return 0;
}