r600g: handle DRM_API_HANDLE_TYPE_KMS in buffer_get_handle
authorMarek Olšák <maraeo@gmail.com>
Sun, 20 Jun 2010 01:50:44 +0000 (03:50 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 20 Jun 2010 01:59:32 +0000 (03:59 +0200)
src/gallium/winsys/r600/drm/r600_drm.c

index b772ff0dd9f107c86d5b9596b62bbddc39b27a5a..803049d58c99d7a3a1fb88547a02d7ea591a7338 100644 (file)
@@ -48,19 +48,22 @@ boolean r600_buffer_get_handle(struct radeon *rw,
                               struct winsys_handle *whandle)
 {
        struct drm_gem_flink flink;
-       struct r600_buffer* rbuffer;
-       int r;
+       struct r600_buffer* rbuffer = (struct r600_buffer*)buf;
 
-       rbuffer = (struct r600_buffer*)buf;
-       if (!rbuffer->flink) {
-               flink.handle = rbuffer->bo->handle;
-               r = ioctl(rw->fd, DRM_IOCTL_GEM_FLINK, &flink);
-               if (r) {
-                       return FALSE;
+       if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
+               if (!rbuffer->flink) {
+                       flink.handle = rbuffer->bo->handle;
+
+                       if (ioctl(rw->fd, DRM_IOCTL_GEM_FLINK, &flink)) {
+                               return FALSE;
+                       }
+
+                       rbuffer->flink = flink.name;
                }
-               rbuffer->flink = flink.name;
+               whandle->handle = rbuffer->flink;
+       } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
+               whandle->handle = rbuffer->bo->handle;
        }
-       whandle->handle = rbuffer->flink;
        return TRUE;
 }