diff options
author | David Dawes | 2001-07-30 14:59:39 -0500 |
---|---|---|
committer | David Dawes | 2001-07-30 14:59:39 -0500 |
commit | 56bd9c207770d41a497f3e8237a1099dd9d4cd91 (patch) | |
tree | 528632e9ff74ae98caa8c55d4a8f201669c00e93 /libdrm/xf86drm.c | |
parent | 84a5e7108773d5a5ff7242e1460c98e3acb178a8 (diff) | |
download | libdrm-56bd9c207770d41a497f3e8237a1099dd9d4cd91.tar.gz libdrm-56bd9c207770d41a497f3e8237a1099dd9d4cd91.tar.xz libdrm-56bd9c207770d41a497f3e8237a1099dd9d4cd91.zip |
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/xf86drm.c')
-rw-r--r-- | libdrm/xf86drm.c | 62 |
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 @@ | |||
55 | # include <sys/ioctl.h> | 55 | # include <sys/ioctl.h> |
56 | # include <sys/mman.h> | 56 | # include <sys/mman.h> |
57 | # include <sys/time.h> | 57 | # include <sys/time.h> |
58 | # include <stdarg.h> | ||
58 | # ifdef DRM_USE_MALLOC | 59 | # ifdef DRM_USE_MALLOC |
59 | # define _DRM_MALLOC malloc | 60 | # define _DRM_MALLOC malloc |
60 | # define _DRM_FREE free | 61 | # define _DRM_FREE free |
@@ -107,6 +108,28 @@ extern unsigned long _bus_base(void); | |||
107 | #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) | 108 | #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) |
108 | #endif | 109 | #endif |
109 | 110 | ||
111 | #define DRM_MSG_VERBOSITY 3 | ||
112 | |||
113 | static void | ||
114 | drmMsg(const char *format, ...) | ||
115 | { | ||
116 | va_list ap; | ||
117 | |||
118 | #ifndef XFree86Server | ||
119 | const char *env; | ||
120 | if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) | ||
121 | #endif | ||
122 | { | ||
123 | va_start(ap, format); | ||
124 | #ifdef XFree86Server | ||
125 | xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap); | ||
126 | #else | ||
127 | vfprintf(stderr, format, ap); | ||
128 | #endif | ||
129 | va_end(ap); | ||
130 | } | ||
131 | } | ||
132 | |||
110 | static void *drmHashTable = NULL; /* Context switch callbacks */ | 133 | static void *drmHashTable = NULL; /* Context switch callbacks */ |
111 | 134 | ||
112 | typedef struct drmHashEntry { | 135 | typedef struct drmHashEntry { |
@@ -182,6 +205,8 @@ static int drmOpenDevice(long dev, int minor) | |||
182 | gid_t group = DRM_DEV_GID; | 205 | gid_t group = DRM_DEV_GID; |
183 | #endif | 206 | #endif |
184 | 207 | ||
208 | drmMsg("drmOpenDevice: minor is %d\n", minor); | ||
209 | |||
185 | #if defined(XFree86Server) | 210 | #if defined(XFree86Server) |
186 | devmode = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE; | 211 | devmode = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE; |
187 | dirmode = (devmode & S_IRUSR) ? S_IXUSR : 0; | 212 | dirmode = (devmode & S_IRUSR) ? S_IXUSR : 0; |
@@ -203,6 +228,7 @@ static int drmOpenDevice(long dev, int minor) | |||
203 | #endif | 228 | #endif |
204 | 229 | ||
205 | sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); | 230 | sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); |
231 | drmMsg("drmOpenDevice: node name is %s\n", buf); | ||
206 | if (stat(buf, &st) || st.st_rdev != dev) { | 232 | if (stat(buf, &st) || st.st_rdev != dev) { |
207 | if (!isroot) return DRM_ERR_NOT_ROOT; | 233 | if (!isroot) return DRM_ERR_NOT_ROOT; |
208 | remove(buf); | 234 | remove(buf); |
@@ -213,7 +239,11 @@ static int drmOpenDevice(long dev, int minor) | |||
213 | chmod(buf, devmode); | 239 | chmod(buf, devmode); |
214 | #endif | 240 | #endif |
215 | 241 | ||
216 | if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; | 242 | fd = open(buf, O_RDWR, 0); |
243 | drmMsg("drmOpenDevice: open result is %d, (%s)\n", | ||
244 | fd, fd < 0 ? strerror(errno) : "OK"); | ||
245 | if (fd >= 0) return fd; | ||
246 | drmMsg("drmOpenDevice: Open failed\n"); | ||
217 | remove(buf); | 247 | remove(buf); |
218 | return -errno; | 248 | return -errno; |
219 | } | 249 | } |
@@ -261,9 +291,13 @@ static int drmOpenByBusid(const char *busid) | |||
261 | int fd; | 291 | int fd; |
262 | const char *buf; | 292 | const char *buf; |
263 | 293 | ||
294 | drmMsg("drmOpenByBusid: busid is %s\n", busid); | ||
264 | for (i = 0; i < DRM_MAX_MINOR; i++) { | 295 | for (i = 0; i < DRM_MAX_MINOR; i++) { |
265 | if ((fd = drmOpenMinor(i, 0)) >= 0) { | 296 | fd = drmOpenMinor(i, 1); |
297 | drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); | ||
298 | if (fd >= 0) { | ||
266 | buf = drmGetBusid(fd); | 299 | buf = drmGetBusid(fd); |
300 | drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf); | ||
267 | if (buf && !strcmp(buf, busid)) { | 301 | if (buf && !strcmp(buf, busid)) { |
268 | drmFreeBusid(buf); | 302 | drmFreeBusid(buf); |
269 | return fd; | 303 | return fd; |
@@ -280,6 +314,7 @@ static int drmOpenByName(const char *name) | |||
280 | int i; | 314 | int i; |
281 | int fd; | 315 | int fd; |
282 | drmVersionPtr version; | 316 | drmVersionPtr version; |
317 | char * id; | ||
283 | 318 | ||
284 | if (!drmAvailable()) { | 319 | if (!drmAvailable()) { |
285 | #if !defined(XFree86Server) | 320 | #if !defined(XFree86Server) |
@@ -294,15 +329,30 @@ static int drmOpenByName(const char *name) | |||
294 | #endif | 329 | #endif |
295 | } | 330 | } |
296 | 331 | ||
332 | /* | ||
333 | * Open the first minor number that matches the driver name and isn't | ||
334 | * already in use. If it's in use it will have a busid assigned already. | ||
335 | */ | ||
297 | for (i = 0; i < DRM_MAX_MINOR; i++) { | 336 | for (i = 0; i < DRM_MAX_MINOR; i++) { |
298 | if ((fd = drmOpenMinor(i, 1)) >= 0) { | 337 | if ((fd = drmOpenMinor(i, 1)) >= 0) { |
299 | if ((version = drmGetVersion(fd))) { | 338 | if ((version = drmGetVersion(fd))) { |
300 | if (!strcmp(version->name, name)) { | 339 | if (!strcmp(version->name, name)) { |
301 | drmFreeVersion(version); | 340 | drmFreeVersion(version); |
302 | return fd; | 341 | id = drmGetBusid(fd); |
342 | drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL"); | ||
343 | if (!id || !*id) { | ||
344 | if (id) { | ||
345 | drmFreeBusid(id); | ||
346 | } | ||
347 | return fd; | ||
348 | } else { | ||
349 | drmFreeBusid(id); | ||
350 | } | ||
351 | } else { | ||
352 | drmFreeVersion(version); | ||
303 | } | 353 | } |
304 | drmFreeVersion(version); | ||
305 | } | 354 | } |
355 | close(fd); | ||
306 | } | 356 | } |
307 | } | 357 | } |
308 | 358 | ||
@@ -459,7 +509,9 @@ int drmSetBusid(int fd, const char *busid) | |||
459 | u.unique = (char *)busid; | 509 | u.unique = (char *)busid; |
460 | u.unique_len = strlen(busid); | 510 | u.unique_len = strlen(busid); |
461 | 511 | ||
462 | if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) return -errno; | 512 | if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) { |
513 | return -errno; | ||
514 | } | ||
463 | return 0; | 515 | return 0; |
464 | } | 516 | } |
465 | 517 | ||