radeon: add bo_wait functionality

This commit is contained in:
Dave Airlie 2009-01-13 16:48:04 +10:00
parent 2b0c9c01c2
commit e9298a02ac
2 changed files with 27 additions and 1 deletions

View file

@ -66,6 +66,7 @@ struct radeon_bo_funcs {
struct radeon_bo *(*bo_unref)(struct radeon_bo *bo);
int (*bo_map)(struct radeon_bo *bo, int write);
int (*bo_unmap)(struct radeon_bo *bo);
int (*bo_wait)(struct radeon_bo *bo);
};
struct radeon_bo_manager {
@ -151,6 +152,14 @@ static inline int _radeon_bo_unmap(struct radeon_bo *bo,
return bo->bom->funcs->bo_unmap(bo);
}
static inline int _radeon_bo_wait(struct radeon_bo *bo,
const char *file,
const char *func,
int line)
{
return bo->bom->funcs->bo_wait(bo);
}
#define radeon_bo_open(bom, h, s, a, d, f)\
_radeon_bo_open(bom, h, s, a, d, f, __FILE__, __FUNCTION__, __LINE__)
#define radeon_bo_ref(bo)\
@ -163,5 +172,7 @@ static inline int _radeon_bo_unmap(struct radeon_bo *bo,
_radeon_bo_unmap(bo, __FILE__, __FUNCTION__, __LINE__)
#define radeon_bo_debug(bo, opcode)\
_radeon_bo_debug(bo, opcode, __FILE__, __FUNCTION__, __LINE__)
#define radeon_bo_wait(bo) \
_radeon_bo_wait(bo, __FILE__, __func__, __LINE__)
#endif

View file

@ -35,6 +35,7 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <errno.h>
#include "xf86drm.h"
#include "drm.h"
#include "radeon_drm.h"
@ -176,12 +177,26 @@ static int bo_unmap(struct radeon_bo *bo)
return 0;
}
static int bo_wait(struct radeon_bo *bo)
{
struct drm_radeon_gem_wait_rendering args;
int ret;
args.handle = bo->handle;
do {
ret = drmCommandWriteRead(bo->bom->fd, DRM_RADEON_GEM_WAIT_RENDERING,
&args, sizeof(args));
} while (ret == -EAGAIN);
return ret;
}
static struct radeon_bo_funcs bo_gem_funcs = {
bo_open,
bo_ref,
bo_unref,
bo_map,
bo_unmap
bo_unmap,
bo_wait
};
struct radeon_bo_manager *radeon_bo_manager_gem_ctor(int fd)