lib: helper to convert gem_hanlde to drm_intel_bo

This commit is contained in:
Daniel Vetter 2012-10-02 10:32:10 +02:00
parent 9d1a3587ac
commit df7edaab90
2 changed files with 20 additions and 1 deletions

View File

@ -45,6 +45,23 @@
/* This file contains a bunch of wrapper functions to directly use gem ioctls. /* This file contains a bunch of wrapper functions to directly use gem ioctls.
* Mostly useful to write kernel tests. */ * 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 static int
is_intel(int fd) 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_status_t status;
cairo_t *cr; cairo_t *cr;
char buf[128]; char buf[128];
int ret;
unsigned int fb_id; unsigned int fb_id;
surface = paint_allocate_surface(fd, width, height, depth, bpp, surface = paint_allocate_surface(fd, width, height, depth, bpp,

View File

@ -37,6 +37,9 @@
#include "xf86drmMode.h" #include "xf86drmMode.h"
#include "intel_batchbuffer.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_get_card(int master);
int drm_open_any(void); int drm_open_any(void);
int drm_open_any_master(void); int drm_open_any_master(void);