xf86-video-ati: Branch 'master'

Alex Deucher agd5f at kemper.freedesktop.org
Wed Nov 25 09:35:59 PST 2009


 src/radeon_dri2.c |   38 +++++---------------------------------
 src/radeon_dri2.h |    2 +-
 2 files changed, 6 insertions(+), 34 deletions(-)

New commits:
commit 05551295c5e0946745163f17e5c1d3d41b94bcbf
Author: Kristian Høgsberg <krh at bitplanet.net>
Date:   Tue Nov 24 21:09:03 2009 -0500

    dri2: Use drmGetDeviceNameFromFd() instead of open coded loop.

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 56c00a3..103972f 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -330,45 +330,13 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     RADEONInfoPtr info = RADEONPTR(pScrn);
     DRI2InfoRec dri2_info = { 0 };
-    int fd;
-    char *bus_id;
-    char *tmp_bus_id;
-    int cmp;
-    int i;
 
     if (!info->useEXA) {
         xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DRI2 requires EXA\n");
         return FALSE;
     }
 
-    /* The whole drmOpen thing is a fiasco and we need to find a way
-     * back to just using open(2).  For now, however, lets just make
-     * things worse with even more ad hoc directory walking code to
-     * discover the device file name. */
-    bus_id = DRICreatePCIBusID(info->PciInfo);
-    for (i = 0; i < DRM_MAX_MINOR; i++) {
-        sprintf(info->dri2.device_name, DRM_DEV_NAME, DRM_DIR_NAME, i);
-        fd = open(info->dri2.device_name, O_RDWR);
-        if (fd < 0)
-            continue;
-
-        tmp_bus_id = drmGetBusid(fd);
-        close(fd);
-        if (tmp_bus_id == NULL)
-            continue;
-
-        cmp = strcmp(tmp_bus_id, bus_id);
-        drmFree(tmp_bus_id);
-        if (cmp == 0)
-            break;
-    }
-    xfree(bus_id);
-
-    if (i == DRM_MAX_MINOR) {
-        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                   "DRI2: failed to open drm device\n");
-        return FALSE;
-    }
+    info->dri2.device_name = drmGetDeviceNameFromFd(info->dri2.drm_fd);
 
     if ( (info->ChipFamily >= CHIP_FAMILY_R600) ) {
         dri2_info.driverName = R600_DRIVER_NAME;
@@ -397,7 +365,11 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
 
 void radeon_dri2_close_screen(ScreenPtr pScreen)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+
     DRI2CloseScreen(pScreen);
+    drmFree(info->dri2.device_name);
 }
 
 #endif
diff --git a/src/radeon_dri2.h b/src/radeon_dri2.h
index 899a626..c391e73 100644
--- a/src/radeon_dri2.h
+++ b/src/radeon_dri2.h
@@ -30,7 +30,7 @@
 struct radeon_dri2 {
     int         drm_fd;
     Bool        enabled;
-    char        device_name[64];
+    char	*device_name;
 };
 
 #ifdef RADEON_DRI2


More information about the xorg-commit mailing list