From: Daniel Vetter Date: Tue, 2 Oct 2012 08:32:10 +0000 (+0200) Subject: lib: helper to convert gem_hanlde to drm_intel_bo X-Git-Tag: intel-gpu-tools-1.4~966 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df7edaab90517cc8d5ed0f72a8a96dbdd04f0ed7;p=profile%2Fextras%2Fintel-gpu-tools.git lib: helper to convert gem_hanlde to drm_intel_bo --- diff --git a/lib/drmtest.c b/lib/drmtest.c index 585ebe4..d217a1d 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -45,6 +45,23 @@ /* 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, diff --git a/lib/drmtest.h b/lib/drmtest.h index 31951ed..738d1a2 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -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);