[haiku-commits] r36911 - in haiku/branches/components/gallium3d/src/libs/drm: . libkms tests/modetest

  • From: aljen-mlists@xxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 23 May 2010 17:43:57 +0200 (CEST)

Author: aljen
Date: 2010-05-23 17:43:57 +0200 (Sun, 23 May 2010)
New Revision: 36911
Changeset: http://dev.haiku-os.org/changeset/36911/haiku

Modified:
   haiku/branches/components/gallium3d/src/libs/drm/libkms/intel.c
   haiku/branches/components/gallium3d/src/libs/drm/libkms/nouveau.c
   haiku/branches/components/gallium3d/src/libs/drm/tests/modetest/modetest.c
   haiku/branches/components/gallium3d/src/libs/drm/xf86drm_haiku.c
Log:
Fixed memory/resource leaks


Modified: haiku/branches/components/gallium3d/src/libs/drm/libkms/intel.c
===================================================================
--- haiku/branches/components/gallium3d/src/libs/drm/libkms/intel.c     
2010-05-23 15:43:29 UTC (rev 36910)
+++ haiku/branches/components/gallium3d/src/libs/drm/libkms/intel.c     
2010-05-23 15:43:57 UTC (rev 36911)
@@ -101,6 +101,7 @@
                pitch = (pitch + 512 - 1) & ~(512 - 1);
                size = pitch * ((height + 4 - 1) & ~(4 - 1));
        } else {
+               free(bo);
                return -EINVAL;
        }
 

Modified: haiku/branches/components/gallium3d/src/libs/drm/libkms/nouveau.c
===================================================================
--- haiku/branches/components/gallium3d/src/libs/drm/libkms/nouveau.c   
2010-05-23 15:43:29 UTC (rev 36910)
+++ haiku/branches/components/gallium3d/src/libs/drm/libkms/nouveau.c   
2010-05-23 15:43:57 UTC (rev 36911)
@@ -102,6 +102,7 @@
                pitch = (pitch + 512 - 1) & ~(512 - 1);
                size = pitch * height;
        } else {
+               free(bo);
                return -EINVAL;
        }
 

Modified: 
haiku/branches/components/gallium3d/src/libs/drm/tests/modetest/modetest.c
===================================================================
--- haiku/branches/components/gallium3d/src/libs/drm/tests/modetest/modetest.c  
2010-05-23 15:43:29 UTC (rev 36910)
+++ haiku/branches/components/gallium3d/src/libs/drm/tests/modetest/modetest.c  
2010-05-23 15:43:57 UTC (rev 36911)
@@ -131,11 +131,11 @@
                        continue;
                }
                printf("%d\t%d\t%s\t0x%08x\t0x%08x\n",
-                      encoder->encoder_id,
-                      encoder->crtc_id,
-                      encoder_type_str(encoder->encoder_type),
-                      encoder->possible_crtcs,
-                      encoder->possible_clones);
+                          encoder->encoder_id,
+                          encoder->crtc_id,
+                          encoder_type_str(encoder->encoder_type),
+                          encoder->possible_crtcs,
+                          encoder->possible_clones);
                drmModeFreeEncoder(encoder);
        }
        printf("\n");
@@ -144,16 +144,16 @@
 void dump_mode(drmModeModeInfo *mode)
 {
        printf("  %s %d %d %d %d %d %d %d %d %d\n",
-              mode->name,
-              mode->vrefresh,
-              mode->hdisplay,
-              mode->hsync_start,
-              mode->hsync_end,
-              mode->htotal,
-              mode->vdisplay,
-              mode->vsync_start,
-              mode->vsync_end,
-              mode->vtotal);
+                  mode->name,
+                  mode->vrefresh,
+                  mode->hdisplay,
+                  mode->hsync_start,
+                  mode->hsync_end,
+                  mode->htotal,
+                  mode->vdisplay,
+                  mode->vsync_start,
+                  mode->vsync_end,
+                  mode->vtotal);
 }
 
 static void
@@ -186,12 +186,12 @@
                }
 
                printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\t",
-                      connector->connector_id,
-                      connector->encoder_id,
-                      connector_status_str(connector->connection),
-                      connector_type_str(connector->connector_type),
-                      connector->mmWidth, connector->mmHeight,
-                      connector->count_modes);
+                          connector->connector_id,
+                          connector->encoder_id,
+                          connector_status_str(connector->connection),
+                          connector_type_str(connector->connector_type),
+                          connector->mmWidth, connector->mmHeight,
+                          connector->count_modes);
 
                for (j = 0; j < connector->count_encoders; j++)
                        printf("%s%d", j > 0 ? ", " : "", 
connector->encoders[j]);
@@ -202,7 +202,7 @@
 
                printf("  modes:\n");
                printf("  name refresh (Hz) hdisp hss hse htot vdisp "
-                      "vss vse vtot)\n");
+                          "vss vse vtot)\n");
                for (j = 0; j < connector->count_modes; j++)
                        dump_mode(&connector->modes[j]);
 
@@ -230,10 +230,10 @@
                        continue;
                }
                printf("%d\t%d\t(%d,%d)\t(%dx%d)\n",
-                      crtc->crtc_id,
-                      crtc->buffer_id,
-                      crtc->x, crtc->y,
-                      crtc->width, crtc->height);
+                          crtc->crtc_id,
+                          crtc->buffer_id,
+                          crtc->x, crtc->y,
+                          crtc->width, crtc->height);
                dump_mode(&crtc->mode);
 
                drmModeFreeCrtc(crtc);
@@ -257,9 +257,9 @@
                        continue;
                }
                printf("%u\t(%ux%u)\t%u\n",
-                      fb->fb_id,
-                      fb->width, fb->height,
-                      fb->pitch);
+                          fb->fb_id,
+                          fb->width, fb->height,
+                          fb->pitch);
 
                drmModeFreeFB(fb);
        }
@@ -283,7 +283,7 @@
        struct timeval start;
 
        int swap_count;
-};     
+};
 
 static void
 connector_find_mode(struct connector *c)
@@ -517,7 +517,7 @@
                new_fb_id = c->fb_id[1];
        else
                new_fb_id = c->fb_id[0];
-                       
+
        drmModePageFlip(fd, c->crtc, new_fb_id,
                        DRM_MODE_PAGE_FLIP_EVENT, c);
        c->current_fb_id = new_fb_id;
@@ -574,10 +574,10 @@
                        continue;
 
                printf("setting mode %s on connector %d, crtc %d\n",
-                      c[i].mode_str, c[i].id, c[i].crtc);
+                          c[i].mode_str, c[i].id, c[i].crtc);
 
                ret = drmModeSetCrtc(fd, c[i].crtc, fb_id, x, 0,
-                                    &c[i].id, 1, c[i].mode);
+                                        &c[i].id, 1, c[i].mode);
                x += c[i].mode->hdisplay;
 
                if (ret) {
@@ -616,7 +616,7 @@
        evctx.version = DRM_EVENT_CONTEXT_VERSION;
        evctx.vblank_handler = NULL;
        evctx.page_flip_handler = page_flip_handler;
-       
+
        while (1) {
 #if 0
                struct pollfd pfd[2];
@@ -703,7 +703,7 @@
        char *modeset = NULL;
        int i, count = 0;
        struct connector con_args[2];
-       
+
        opterr = 0;
        while ((c = getopt(argc, argv, optstr)) != -1) {
                switch (c) {
@@ -731,12 +731,12 @@
                        if (sscanf(optarg, "%d:%64s",
                                   &con_args[count].id,
                                   con_args[count].mode_str) != 2 &&
-                           sscanf(optarg, "%d@%d:%64s",
+                               sscanf(optarg, "%d@%d:%64s",
                                   &con_args[count].id,
                                   &con_args[count].crtc,
                                   con_args[count].mode_str) != 3)
                                usage(argv[0]);
-                       count++;                                      
+                       count++;
                        break;
                default:
                        usage(argv[0]);
@@ -788,5 +788,6 @@
 
        drmModeFreeResources(resources);
 
+       free(modeset);
        return 0;
 }

Modified: haiku/branches/components/gallium3d/src/libs/drm/xf86drm_haiku.c
===================================================================
--- haiku/branches/components/gallium3d/src/libs/drm/xf86drm_haiku.c    
2010-05-23 15:43:29 UTC (rev 36910)
+++ haiku/branches/components/gallium3d/src/libs/drm/xf86drm_haiku.c    
2010-05-23 15:43:57 UTC (rev 36911)
@@ -80,7 +80,7 @@
 void
 drmSetAccelerantInfoPtr(drmAccelerantInfoPtr info)
 {
-    drm_accelerant_info = info;
+       drm_accelerant_info = info;
 }
 
 
@@ -96,7 +96,7 @@
 static int
 drmDebugPrint(const char* format, va_list ap)
 {
-    return vfprintf(stderr, format, ap);
+       return vfprintf(stderr, format, ap);
 }
 
 
@@ -106,25 +106,25 @@
 void
 drmMsg(const char* format, ...)
 {
-    va_list    ap;
-    const char *env;
-    if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose"))
-        || drm_accelerant_info) {
-           va_start(ap, format);
-           if (drm_accelerant_info) {
-             drm_accelerant_info->DebugPrint(format,ap);
-           } else {
-             drm_debug_print(format, ap);
-           }
-           va_end(ap);
-    }
+       va_list ap;
+       const char *env;
+       if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose"))
+               || drm_accelerant_info) {
+               va_start(ap, format);
+               if (drm_accelerant_info) {
+                 drm_accelerant_info->DebugPrint(format,ap);
+               } else {
+                 drm_debug_print(format, ap);
+               }
+               va_end(ap);
+       }
 }
 
 
 void
 drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char* format, va_list ap))
 {
-    drm_debug_print = debug_msg_ptr;
+       drm_debug_print = debug_msg_ptr;
 }
 
 
@@ -134,24 +134,24 @@
 void*
 drmGetHashTable(void)
 {
-    return drmHashTable;
+       return drmHashTable;
 }
 
 
 void*
 drmMalloc(int size)
 {
-    void *pt;
-    if ((pt = malloc(size)))
-       memset(pt, 0, size);
-    return pt;
+       void *pt;
+       if ((pt = malloc(size)))
+               memset(pt, 0, size);
+       return pt;
 }
 
 void
 drmFree(void* pt)
 {
-    if (pt)
-       free(pt);
+       if (pt)
+               free(pt);
 }
 
 
@@ -159,18 +159,18 @@
 static char*
 drmStrdup(const char* s)
 {
-    char *retval;
+       char *retval;
 
-    if (!s)
-        return NULL;
+       if (!s)
+               return NULL;
 
-    retval = malloc(strlen(s) + 1);
-    if (!retval)
-        return NULL;
+       retval = malloc(strlen(s) + 1);
+       if (!retval)
+               return NULL;
 
-    strcpy(retval, s);
+       strcpy(retval, s);
 
-    return retval;
+       return retval;
 }
 
 
@@ -180,14 +180,14 @@
 int
 drmIoctl(drmAccelerantInfoPtr info, unsigned long request, void* arg)
 {
-    int        ret = -1;
-    if (!info || !info->Ioctl)
-        return -1;
+       int     ret = -1;
+       if (!info || !info->Ioctl)
+               return -1;
 
-    do {
-       ret = info->Ioctl(info->engineToken, request, arg);
-    } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
-    return ret;
+       do {
+               ret = info->Ioctl(info->engineToken, request, arg);
+       } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+       return ret;
 }
 
 
@@ -196,13 +196,13 @@
 {
 // IMPLEMENT
 #if 0
-    stat_t st;
+       stat_t st;
 
-    st.st_rdev = 0;
-    fstat(fd, &st);
-    return st.st_rdev;
+       st.st_rdev = 0;
+       fstat(fd, &st);
+       return st.st_rdev;
 #endif
-    return 0;
+       return 0;
 }
 
 
@@ -211,25 +211,25 @@
 {
 // IMPLEMENT
 #if 0
-    unsigned long key = drmGetKeyFromFd(fd);
-    void          *value;
-    drmHashEntry  *entry;
+       unsigned long key = drmGetKeyFromFd(fd);
+       void          *value;
+       drmHashEntry  *entry;
 
-    if (!drmHashTable)
+       if (!drmHashTable)
        drmHashTable = drmHashCreate();
 
-    if (drmHashLookup(drmHashTable, key, &value)) {
+       if (drmHashLookup(drmHashTable, key, &value)) {
        entry           = drmMalloc(sizeof(*entry));
        entry->fd       = fd;
        entry->f        = NULL;
        entry->tagTable = drmHashCreate();
        drmHashInsert(drmHashTable, key, entry);
-    } else {
+       } else {
        entry = value;
-    }
-    return entry;
+       }
+       return entry;
 #endif
-    return NULL;
+       return NULL;
 }
 
 
@@ -249,38 +249,38 @@
 static int
 drmMatchBusID(const char* id1, const char* id2)
 {
-    /* First, check if the IDs are exactly the same */
-    if (strcasecmp(id1, id2) == 0)
-       return 1;
+       /* First, check if the IDs are exactly the same */
+       if (strcasecmp(id1, id2) == 0)
+               return 1;
 
-    /* Try to match old/new-style PCI bus IDs. */
-    if (strncasecmp(id1, "pci", 3) == 0) {
-       unsigned int o1, b1, d1, f1;
-       unsigned int o2, b2, d2, f2;
-       int ret;
+       /* Try to match old/new-style PCI bus IDs. */
+       if (strncasecmp(id1, "pci", 3) == 0) {
+               unsigned int o1, b1, d1, f1;
+               unsigned int o2, b2, d2, f2;
+               int ret;
 
-           ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
-           if (ret != 4) {
-               o1 = 0;
-               ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
-               if (ret != 3)
-                   return 0;
-           }
+               ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
+               if (ret != 4) {
+                       o1 = 0;
+                       ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
+                       if (ret != 3)
+                       return 0;
+               }
 
-           ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
-           if (ret != 4) {
-               o2 = 0;
-               ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
-               if (ret != 3)
-                   return 0;
-           }
+               ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
+               if (ret != 4) {
+                       o2 = 0;
+                       ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
+                       if (ret != 3)
+                       return 0;
+               }
 
-           if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
-               return 0;
-           else
-           return 1;
-    }
-    return 0;
+               if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
+                       return 0;
+               else
+                       return 1;
+       }
+       return 0;
 }
 
 
@@ -329,164 +329,165 @@
 int
 drmAvailable(void)
 {
-    drmVersionPtr version;
-    int           retval = 0;
+       drmVersionPtr version;
+       int           retval = 0;
 
 /*
-    if ((version = drmGetVersion(fd))) {
+       if ((version = drmGetVersion(fd))) {
        retval = 1;
        drmFreeVersion(version);
-    }
-    close(fd);
+       }
+       close(fd);
 */
 
-    return retval;
+       return retval;
 }
 
 
 int drmOpenGraphicsDevice(int deviceNumber)
 {
-    DIR *directory = opendir("/dev/graphics");
-    if (!directory)
-        return -1;
+       DIR *directory = opendir("/dev/graphics");
+       if (!directory)
+               return -1;
 
-    int device = -1;
-    int count = 0;
-    struct dirent *entry;
-    char path[PATH_MAX];
-    while (count < deviceNumber && (entry = readdir(directory)) != NULL) {
-        if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")
-            || !strcmp(entry->d_name, "vesa"))
-                continue;
+       int device = -1;
+       int count = 0;
+       struct dirent *entry;
+       char path[PATH_MAX];
+       while (count < deviceNumber && (entry = readdir(directory)) != NULL) {
+               if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")
+                       || !strcmp(entry->d_name, "vesa"))
+                               continue;
 
-        if (device >= 0) {
-            close(device);
-            device = -1;
-        }
+               if (device >= 0) {
+                       close(device);
+                       device = -1;
+               }
 
-        sprintf(path, "/dev/graphics/%s", entry->d_name);
-        device = open(path, B_READ_WRITE);
-        if (device >= 0)
-            count++;
-    }
+               sprintf(path, "/dev/graphics/%s", entry->d_name);
+               device = open(path, B_READ_WRITE);
+               if (device >= 0)
+                       count++;
+       }
 
-    // Open VESA driver if we were not able to get a better one
-    // for debugging purpose now, vesa accelerant does not have 3D acceleration
-    if (count < deviceNumber) {
-        if (deviceNumber == 1) {
-            device = open("/dev/graphics/vesa", B_READ_WRITE);
-        } else {
-            close(device);
-            device = B_ENTRY_NOT_FOUND;
-        }
-    }
+       // Open VESA driver if we were not able to get a better one
+       // for debugging purpose now, vesa accelerant does not have 3D 
acceleration
+       if (count < deviceNumber) {
+               if (deviceNumber == 1) {
+                       device = open("/dev/graphics/vesa", B_READ_WRITE);
+               } else {
+                       close(device);
+                       device = B_ENTRY_NOT_FOUND;
+               }
+       }
 
-    return device;
+       closedir(directory);
+       return device;
 }
 
 
 status_t
 drmOpenAccelerant(int device, drmAccelerantInfoPtr info)
 {
-    char signature[1024];
-    image_id imageId = -1;
-    GetAccelerantHook accelerantHook;
-    engine_token *engineToken;
-    sync_token syncToken;
-    init_accelerant initAccelerant;
-    uninit_accelerant uninitAccelerant;
-    acquire_engine acquireEngine;
-    release_engine releaseEngine;
+       char signature[1024];
+       image_id imageId = -1;
+       GetAccelerantHook accelerantHook;
+       engine_token *engineToken;
+       sync_token syncToken;
+       init_accelerant initAccelerant;
+       uninit_accelerant uninitAccelerant;
+       acquire_engine acquireEngine;
+       release_engine releaseEngine;
 
-    if (ioctl(device, B_GET_ACCELERANT_SIGNATURE, &signature,
-            sizeof(signature)) != B_OK)
-        return B_ERROR;
+       if (ioctl(device, B_GET_ACCELERANT_SIGNATURE, &signature,
+                       sizeof(signature)) != B_OK)
+               return B_ERROR;
 
-    drmMsg("Accelerant signature is: %s\n", signature);
+       drmMsg("Accelerant signature is: %s\n", signature);
 
-    struct stat accelerantStat;
-    const static directory_which dirs[] = {
-        B_USER_ADDONS_DIRECTORY,
-        B_COMMON_ADDONS_DIRECTORY,
-        B_BEOS_ADDONS_DIRECTORY
-    };
+       struct stat accelerantStat;
+       const static directory_which dirs[] = {
+               B_USER_ADDONS_DIRECTORY,
+               B_COMMON_ADDONS_DIRECTORY,
+               B_BEOS_ADDONS_DIRECTORY
+       };
 
-    for (int32 i = 0; i < 3; i++) {
-        char path[PATH_MAX];
-        if (find_directory(dirs[i], -1, false, path, PATH_MAX) != B_OK)
-            continue;
+       for (int32 i = 0; i < 3; i++) {
+               char path[PATH_MAX];
+               if (find_directory(dirs[i], -1, false, path, PATH_MAX) != B_OK)
+                       continue;
 
-        strcat(path, "/accelerants/");
-        strcat(path, signature);
-        if (stat(path, &accelerantStat) != 0)
-            continue;
+               strcat(path, "/accelerants/");
+               strcat(path, signature);
+               if (stat(path, &accelerantStat) != 0)
+                       continue;
 
-        imageId = load_add_on(path);
-        if (imageId >= 0) {
-            if (get_image_symbol(imageId, B_ACCELERANT_ENTRY_POINT,
-                    B_SYMBOL_TYPE_ANY, (void**)(&accelerantHook)) != B_OK ) {
-                drmMsg("Unable to get B_ACCELERANT_ENTRY_POINT\n");
-                unload_add_on(imageId);
-                imageId = -1;
-                return B_ERROR;
-            }
+               imageId = load_add_on(path);
+               if (imageId >= 0) {
+                       if (get_image_symbol(imageId, B_ACCELERANT_ENTRY_POINT,
+                                       B_SYMBOL_TYPE_ANY, 
(void**)(&accelerantHook)) != B_OK ) {
+                               drmMsg("Unable to get 
B_ACCELERANT_ENTRY_POINT\n");
+                               unload_add_on(imageId);
+                               imageId = -1;
+                               return B_ERROR;
+                       }
 
-            initAccelerant = (init_accelerant)accelerantHook(
-                B_INIT_ACCELERANT, NULL);
-            if (!initAccelerant || initAccelerant(device) != B_OK) {
-                drmMsg("InitAccelerant failed\n");
-                unload_add_on(imageId);
-                imageId = -1;
-                return B_ERROR;
-            }
+                       initAccelerant = (init_accelerant)accelerantHook(
+                               B_INIT_ACCELERANT, NULL);
+                       if (!initAccelerant || initAccelerant(device) != B_OK) {
+                               drmMsg("InitAccelerant failed\n");
+                               unload_add_on(imageId);
+                               imageId = -1;
+                               return B_ERROR;
+                       }
 
-            break;
-        }
-    }
+                       break;
+               }
+       }
 
-    if (imageId < B_OK)
-        goto error;
+       if (imageId < B_OK)
+               goto error;
 
-    uninitAccelerant =
-        (uninit_accelerant)accelerantHook(B_UNINIT_ACCELERANT, NULL);
-    acquireEngine = (acquire_engine)accelerantHook(B_ACQUIRE_ENGINE, NULL);
-    releaseEngine = (release_engine)accelerantHook(B_RELEASE_ENGINE, NULL);
+       uninitAccelerant =
+               (uninit_accelerant)accelerantHook(B_UNINIT_ACCELERANT, NULL);
+       acquireEngine = (acquire_engine)accelerantHook(B_ACQUIRE_ENGINE, NULL);
+       releaseEngine = (release_engine)accelerantHook(B_RELEASE_ENGINE, NULL);
 
-    if (!uninitAccelerant || !acquireEngine || !releaseEngine) {
-        drmMsg("Failed to get basic accelerant hooks\n");
-        goto error;
-    }
+       if (!uninitAccelerant || !acquireEngine || !releaseEngine) {
+               drmMsg("Failed to get basic accelerant hooks\n");
+               goto error;
+       }
 
-    if (acquireEngine(B_3D_ACCELERATION, 0xff, &syncToken,
-            &engineToken) < B_OK) {
-        // this accelerant doesn't suppport 3D acceleration
-        goto error;
-    }
+       if (acquireEngine(B_3D_ACCELERATION, 0xff, &syncToken,
+                       &engineToken) < B_OK) {
+               // this accelerant doesn't suppport 3D acceleration
+               goto error;
+       }
 
-    releaseEngine(engineToken, &syncToken);
+       releaseEngine(engineToken, &syncToken);
 
-    // fill drmAccelerantInfo
+       // fill drmAccelerantInfo
 
-    info->device = device;
-    info->imageId = imageId;
-    info->engineToken = engineToken;
-    info->syncToken = syncToken;
-    info->AccelerantHook = accelerantHook;
-    info->InitAccelerant = initAccelerant;
-    info->UninitAccelerant = uninitAccelerant;
-    info->AcquireEngine = acquireEngine;
-    info->ReleaseEngine = releaseEngine;
-    info->GetVersion = (drm_get_version)accelerantHook(B_DRM_GET_VERSION, 
NULL);
-    info->DebugPrint = (drm_debug_printf)accelerantHook(B_DRM_DEBUG_PRINT, 
NULL);
-    info->Ioctl = (drm_ioctl)accelerantHook(B_DRM_IOCTL, NULL);
+       info->device = device;
+       info->imageId = imageId;
+       info->engineToken = engineToken;
+       info->syncToken = syncToken;
+       info->AccelerantHook = accelerantHook;
+       info->InitAccelerant = initAccelerant;
+       info->UninitAccelerant = uninitAccelerant;
+       info->AcquireEngine = acquireEngine;
+       info->ReleaseEngine = releaseEngine;
+       info->GetVersion = (drm_get_version)accelerantHook(B_DRM_GET_VERSION, 
NULL);
+       info->DebugPrint = (drm_debug_printf)accelerantHook(B_DRM_DEBUG_PRINT, 
NULL);
+       info->Ioctl = (drm_ioctl)accelerantHook(B_DRM_IOCTL, NULL);
 
-    return B_OK;
+       return B_OK;
 
 error:
-    if (uninitAccelerant)
-        uninitAccelerant();
-    unload_add_on(imageId);
-    return B_ERROR;
+       if (uninitAccelerant)
+               uninitAccelerant();
+       unload_add_on(imageId);
+       return B_ERROR;
 }
 
 
@@ -508,31 +509,31 @@
 drmAccelerantInfoPtr
 drmOpen()
 {
-    drmAccelerantInfoPtr info = drmMalloc(sizeof(*info));
+       drmAccelerantInfoPtr info = drmMalloc(sizeof(*info));
 
-    int device;
+       int device;
 
-    for (int32 i = 1; device != B_ENTRY_NOT_FOUND; i++) {
-        device = drmOpenGraphicsDevice(i);
-        if (device < 0) {
-            drmMsg("Failed to open graphics device\n");
-            continue;
-        }
+       for (int32 i = 1; device != B_ENTRY_NOT_FOUND; i++) {
+               device = drmOpenGraphicsDevice(i);
+               if (device < 0) {
+                       drmMsg("Failed to open graphics device\n");
+                       continue;
+               }
 
-        if (drmOpenAccelerant(device, info) == B_OK)
-            break;
+               if (drmOpenAccelerant(device, info) == B_OK)
+                       break;
 
-        close(device);
-        // drmOpenAccelerant() failed, try to open next graphics card
-    }
+               close(device);
+               // drmOpenAccelerant() failed, try to open next graphics card
+       }
 
-    if (device < 0) {
-        drmMsg("Can't find any accelerants\n");
-        drmFree(info);
-        return NULL;
-    }
+       if (device < 0) {
+               drmMsg("Can't find any accelerants\n");
+               drmFree(info);
+               return NULL;
+       }
 
-    return info;
+       return info;
 }
 
 
@@ -548,12 +549,12 @@
 void
 drmFreeVersion(drmVersionPtr v)
 {
-    if (!v)
-       return;
-    drmFree(v->name);
-    drmFree(v->date);
-    drmFree(v->desc);
-    drmFree(v);
+       if (!v)
+               return;
+       drmFree(v->name);
+       drmFree(v->date);
+       drmFree(v->desc);
+       drmFree(v);
 }
 
 
@@ -569,12 +570,12 @@
 static void
 drmFreeKernelVersion(drm_version_t *v)
 {
-    if (!v)
-       return;
-    drmFree(v->name);
-    drmFree(v->date);
-    drmFree(v->desc);
-    drmFree(v);
+       if (!v)
+               return;
+       drmFree(v->name);
+       drmFree(v->date);
+       drmFree(v->desc);
+       drmFree(v);
 }
 
 
@@ -591,15 +592,15 @@
 static void
 drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
 {
-    d->version_major      = s->version_major;
-    d->version_minor      = s->version_minor;
-    d->version_patchlevel = s->version_patchlevel;
-    d->name_len           = s->name_len;
-    d->name               = drmStrdup(s->name);
-    d->date_len           = s->date_len;
-    d->date               = drmStrdup(s->date);
-    d->desc_len           = s->desc_len;
-    d->desc               = drmStrdup(s->desc);
+       d->version_major      = s->version_major;
+       d->version_minor      = s->version_minor;
+       d->version_patchlevel = s->version_patchlevel;
+       d->name_len           = s->name_len;
+       d->name               = drmStrdup(s->name);
+       d->date_len           = s->date_len;
+       d->date               = drmStrdup(s->date);
+       d->desc_len           = s->desc_len;
+       d->desc               = drmStrdup(s->desc);
 }
 
 
@@ -621,39 +622,39 @@
 drmVersionPtr
 drmGetVersion(drmAccelerantInfoPtr info)
 {
-    if (!info || !info->GetVersion)
-        return NULL;
+       if (!info || !info->GetVersion)
+               return NULL;
 
-    drmVersionPtr retval;
-    drm_version_t *version = drmMalloc(sizeof(*version));
+       drmVersionPtr retval;
+       drm_version_t *version = drmMalloc(sizeof(*version));
 
-    version->name_len    = 0;
-    version->name        = NULL;
-    version->date_len    = 0;
-    version->date        = NULL;
-    version->desc_len    = 0;
-    version->desc        = NULL;
+       version->name_len    = 0;
+       version->name        = NULL;
+       version->date_len    = 0;
+       version->date        = NULL;
+       version->desc_len    = 0;
+       version->desc        = NULL;
 
-    info->GetVersion(version);
+       info->GetVersion(version);
 
-    if (version->name_len)
-       version->name = drmMalloc(version->name_len + 1);
-    if (version->date_len)
-       version->date = drmMalloc(version->date_len + 1);
-    if (version->desc_len)
-       version->desc = drmMalloc(version->desc_len + 1);
+       if (version->name_len)
+               version->name = drmMalloc(version->name_len + 1);
+       if (version->date_len)
+               version->date = drmMalloc(version->date_len + 1);
+       if (version->desc_len)
+               version->desc = drmMalloc(version->desc_len + 1);
 
-    info->GetVersion(version);
+       info->GetVersion(version);
 
-    /* The results might not be null-terminated strings, so terminate them. */
-    if (version->name_len) version->name[version->name_len] = '\0';
-    if (version->date_len) version->date[version->date_len] = '\0';
-    if (version->desc_len) version->desc[version->desc_len] = '\0';
+       /* The results might not be null-terminated strings, so terminate them. 
*/
+       if (version->name_len) version->name[version->name_len] = '\0';
+       if (version->date_len) version->date[version->date_len] = '\0';
+       if (version->desc_len) version->desc[version->desc_len] = '\0';
 
-    retval = drmMalloc(sizeof(*retval));
-    drmCopyVersion(retval, version);
-    drmFreeKernelVersion(version);
-    return retval;
+       retval = drmMalloc(sizeof(*retval));
+       drmCopyVersion(retval, version);
+       drmFreeKernelVersion(version);
+       return retval;
 }
 
 
@@ -673,23 +674,23 @@
 drmVersionPtr
 drmGetLibVersion(drmAccelerantInfoPtr info)
 {
-    drm_version_t *version = drmMalloc(sizeof(*version));
+       drm_version_t *version = drmMalloc(sizeof(*version));
 
-    /* Version history:
-     *   NOTE THIS MUST NOT GO ABOVE VERSION 1.X due to drivers needing it
-     *   revision 1.0.x = original DRM interface with no drmGetLibVersion
-     *                    entry point and many drm<Device> extensions
-     *   revision 1.1.x = added drmCommand entry points for device extensions
-     *                    added drmGetLibVersion to identify libdrm.a version
-     *   revision 1.2.x = added drmSetInterfaceVersion
-     *                    modified drmOpen to handle both busid and name
-     *   revision 1.3.x = added server + memory manager
-     */
-    version->version_major      = 1;
-    version->version_minor      = 3;
-    version->version_patchlevel = 0;
+       /* Version history:
+        *   NOTE THIS MUST NOT GO ABOVE VERSION 1.X due to drivers needing it
+        *   revision 1.0.x = original DRM interface with no drmGetLibVersion
+        *                    entry point and many drm<Device> extensions
+        *   revision 1.1.x = added drmCommand entry points for device 
extensions
+        *                    added drmGetLibVersion to identify libdrm.a 
version
+        *   revision 1.2.x = added drmSetInterfaceVersion
+        *                    modified drmOpen to handle both busid and name
+        *   revision 1.3.x = added server + memory manager
+        */
+       version->version_major      = 1;
+       version->version_minor      = 3;
+       version->version_patchlevel = 0;
 
-    return (drmVersionPtr)version;
+       return (drmVersionPtr)version;
 }
 
 
@@ -704,7 +705,7 @@
 void
 drmFreeBusid(const char* busid)
 {
-    drmFree((void*)busid);
+       drmFree((void*)busid);
 }
 
 
@@ -725,21 +726,21 @@
 {
 // IMPLEMENT
 #if 0
-    drm_unique_t u;
+       drm_unique_t u;
 
-    u.unique_len = 0;
-    u.unique     = NULL;
+       u.unique_len = 0;
+       u.unique     = NULL;
 
-    if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
+       if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
        return NULL;
-    u.unique = drmMalloc(u.unique_len + 1);
-    if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
+       u.unique = drmMalloc(u.unique_len + 1);
+       if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
        return NULL;
-    u.unique[u.unique_len] = '\0';
+       u.unique[u.unique_len] = '\0';
 

[... truncated: 1995 lines follow ...]

Other related posts:

  • » [haiku-commits] r36911 - in haiku/branches/components/gallium3d/src/libs/drm: . libkms tests/modetest - aljen-mlists