diff options
author | dawes <dawes> | 2001-05-09 21:27:52 +0000 |
---|---|---|
committer | dawes <dawes> | 2001-05-09 21:27:52 +0000 |
commit | 3cc1a7a9cf50bbad6b10d88b61867482d76946be (patch) | |
tree | 06d68d6912c2e44d01a8a0d732b8f6504fffd56b | |
parent | dd3019dafcbe668795a91194d0857a5fd26576b1 (diff) |
Make drmOpenByName() open the first matching device that isn't already open.
This is better than the previous hack.
-rw-r--r-- | xc/programs/Xserver/GL/dri/dri.c | 14 | ||||
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c | 30 |
2 files changed, 23 insertions, 21 deletions
diff --git a/xc/programs/Xserver/GL/dri/dri.c b/xc/programs/Xserver/GL/dri/dri.c index d461ad97b..790961044 100644 --- a/xc/programs/Xserver/GL/dri/dri.c +++ b/xc/programs/Xserver/GL/dri/dri.c @@ -116,7 +116,6 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) int reserved_count; int i, fd, drmWasAvailable; Bool xineramaInCore = FALSE; - char * busidArg = NULL; int err = 0; if (DRIGeneration != serverGeneration) { @@ -150,7 +149,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) tryagain: /* Note that drmOpen will try to load the kernel module, if needed. */ - fd = drmOpen(pDRIInfo->drmDriverName, busidArg ); + fd = drmOpen(pDRIInfo->drmDriverName, NULL ); if (fd < 0) { /* failed to open DRM */ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; @@ -189,17 +188,6 @@ tryagain: DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmSetBusid failed (%d, %s), %s\n", pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString, strerror(-err)); -#if 1 - /* - * If drmSetBusid() fails with EBUSY, then the device is already - * allocated. Tell drmOpen() to try the next one. - */ - if (-err == EBUSY) { - /* This is an abuse of the busid parameter, but ... */ - busidArg++; - goto tryagain; - } -#endif return FALSE; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c index 1a0ddcf6b..582d8d459 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c @@ -306,11 +306,12 @@ static int drmOpenByBusid(const char *busid) return -1; } -static int drmOpenByName(const char *name, int startminor) +static int drmOpenByName(const char *name) { int i; int fd; drmVersionPtr version; + char * id; if (!drmAvailable()) { #if !defined(XFree86Server) @@ -325,19 +326,33 @@ static int drmOpenByName(const char *name, int startminor) #endif } - for (i = startminor; i < DRM_MAX_MINOR; i++) { + /* + * 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); } } -#if 0 #ifdef __linux__ /* Backward-compatibility /proc support */ for (i = 0; i < 8; i++) { @@ -369,7 +384,6 @@ static int drmOpenByName(const char *name, int startminor) } } #endif -#endif return -1; } @@ -382,8 +396,8 @@ static int drmOpenByName(const char *name, int startminor) int drmOpen(const char *name, const char *busid) { - if ((int)busid > 100) return drmOpenByBusid(busid); - return drmOpenByName(name, (int)busid); + if (busid) return drmOpenByBusid(busid); + return drmOpenByName(name); } void drmFreeVersion(drmVersionPtr v) |