lib: helper to convert gem_hanlde to drm_intel_bo
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 2 Oct 2012 08:32:10 +0000 (10:32 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 2 Oct 2012 08:32:10 +0000 (10:32 +0200)
lib/drmtest.c
lib/drmtest.h

index 585ebe4..d217a1d 100644 (file)
 /* This file contains a bunch of wrapper functions to directly use gem ioctls.
  * Mostly useful to write kernel tests. */
 
+drm_intel_bo *
+gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, const char *name, uint32_t handle)
+{
+       struct drm_gem_flink flink;
+       int ret;
+       drm_intel_bo *bo;
+
+       flink.handle = handle;
+       ret = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
+       assert(ret == 0);
+
+       bo = drm_intel_bo_gem_create_from_name(bufmgr, name, flink.name);
+       assert(bo);
+
+       return bo;
+}
+
 static int
 is_intel(int fd)
 {
@@ -768,7 +785,6 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
        cairo_status_t status;
        cairo_t *cr;
        char buf[128];
-       int ret;
        unsigned int fb_id;
 
        surface = paint_allocate_surface(fd, width, height, depth, bpp,
index 31951ed..738d1a2 100644 (file)
@@ -37,6 +37,9 @@
 #include "xf86drmMode.h"
 #include "intel_batchbuffer.h"
 
+drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
+                                      const char *name, uint32_t handle);
+
 int drm_get_card(int master);
 int drm_open_any(void);
 int drm_open_any_master(void);