drm/ttm: ioctl cleanup for buffer object - user side only
This just cleans up the xf86drm.c to what I want and drm.h, I need to fix up the kernel internals to suit these changes now. I've moved to using struct instead of typedefs for the bo and it doesn't look that bad so I'll do the same thing for mm and fence..main
parent
6a62941eca
commit
25c51f539f
183
libdrm/xf86drm.c
183
libdrm/xf86drm.c
|
@ -2598,7 +2598,7 @@ int drmBOCreateList(int numTarget, drmBOList *list)
|
||||||
return drmAdjustListNodes(list);
|
return drmAdjustListNodes(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drmBOCopyReply(const drm_bo_arg_reply_t *rep,
|
static void drmBOCopyReply(struct drm_bo_info_rep *rep,
|
||||||
drmBO *buf)
|
drmBO *buf)
|
||||||
{
|
{
|
||||||
buf->handle = rep->handle;
|
buf->handle = rep->handle;
|
||||||
|
@ -2620,9 +2620,9 @@ int drmBOCreate(int fd, unsigned long start, unsigned long size,
|
||||||
unsigned mask,
|
unsigned mask,
|
||||||
unsigned hint, drmBO *buf)
|
unsigned hint, drmBO *buf)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_create_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_create_req *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_info_rep *rep = &arg.d.rep;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(*buf));
|
memset(buf, 0, sizeof(*buf));
|
||||||
|
@ -2649,21 +2649,13 @@ int drmBOCreate(int fd, unsigned long start, unsigned long size,
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
req->op = drm_bo_create;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_CREATE, &arg);
|
||||||
} while (ret != 0 && errno == EAGAIN);
|
} while (ret != 0 && errno == EAGAIN);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
if (rep->ret) {
|
|
||||||
fprintf(stderr, "Error %d\n", rep->ret);
|
|
||||||
return rep->ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(rep, buf);
|
||||||
buf->mapVirtual = NULL;
|
buf->mapVirtual = NULL;
|
||||||
|
@ -2674,9 +2666,7 @@ int drmBOCreate(int fd, unsigned long start, unsigned long size,
|
||||||
|
|
||||||
int drmBODestroy(int fd, drmBO *buf)
|
int drmBODestroy(int fd, drmBO *buf)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_handle_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
|
||||||
|
|
||||||
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
||||||
(void) drmUnmap(buf->mapVirtual, buf->start + buf->size);
|
(void) drmUnmap(buf->mapVirtual, buf->start + buf->size);
|
||||||
|
@ -2685,17 +2675,10 @@ int drmBODestroy(int fd, drmBO *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
arg.handle = buf->handle;
|
||||||
req->op = drm_bo_destroy;
|
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
|
if (ioctl(fd, DRM_IOCTL_BO_DESTROY, &arg))
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
if (rep->ret) {
|
|
||||||
return rep->ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf->handle = 0;
|
buf->handle = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2704,22 +2687,15 @@ int drmBODestroy(int fd, drmBO *buf)
|
||||||
int drmBOReference(int fd, unsigned handle, drmBO *buf)
|
int drmBOReference(int fd, unsigned handle, drmBO *buf)
|
||||||
{
|
{
|
||||||
|
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_reference_info_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_handle_arg *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_info_rep *rep = &arg.d.rep;
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = handle;
|
req->handle = handle;
|
||||||
req->op = drm_bo_reference;
|
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
|
if (ioctl(fd, DRM_IOCTL_BO_REFERENCE, &arg))
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
if (rep->ret) {
|
|
||||||
return rep->ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(rep, buf);
|
||||||
buf->type = drm_bo_type_dc;
|
buf->type = drm_bo_type_dc;
|
||||||
|
@ -2732,10 +2708,7 @@ int drmBOReference(int fd, unsigned handle, drmBO *buf)
|
||||||
|
|
||||||
int drmBOUnReference(int fd, drmBO *buf)
|
int drmBOUnReference(int fd, drmBO *buf)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_handle_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
|
||||||
|
|
||||||
|
|
||||||
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
|
||||||
(void) munmap(buf->mapVirtual, buf->start + buf->size);
|
(void) munmap(buf->mapVirtual, buf->start + buf->size);
|
||||||
|
@ -2744,22 +2717,16 @@ int drmBOUnReference(int fd, drmBO *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
arg.handle = buf->handle;
|
||||||
req->op = drm_bo_unreference;
|
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
|
if (ioctl(fd, DRM_IOCTL_BO_UNREFERENCE, &arg))
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
if (rep->ret) {
|
|
||||||
return rep->ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf->handle = 0;
|
buf->handle = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flags can be DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE or'ed together
|
* Flags can be DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE or'ed together
|
||||||
* Hint currently be DRM_BO_HINT_DONT_BLOCK, which makes the
|
* Hint currently be DRM_BO_HINT_DONT_BLOCK, which makes the
|
||||||
|
@ -2770,9 +2737,9 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
void **address)
|
void **address)
|
||||||
{
|
{
|
||||||
|
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_map_wait_idle_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_info_req *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_info_rep *rep = &arg.d.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2797,7 +2764,6 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
req->handle = buf->handle;
|
req->handle = buf->handle;
|
||||||
req->mask = mapFlags;
|
req->mask = mapFlags;
|
||||||
req->hint = mapHint;
|
req->hint = mapHint;
|
||||||
req->op = drm_bo_map;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* May hang if the buffer object is busy.
|
* May hang if the buffer object is busy.
|
||||||
|
@ -2805,15 +2771,11 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_MAP, &arg);
|
||||||
} while (ret != 0 && errno == EAGAIN);
|
} while (ret != 0 && errno == EAGAIN);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled)
|
|
||||||
return -EFAULT;
|
|
||||||
if (rep->ret)
|
|
||||||
return rep->ret;
|
|
||||||
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(rep, buf);
|
||||||
buf->mapFlags = mapFlags;
|
buf->mapFlags = mapFlags;
|
||||||
|
@ -2823,45 +2785,37 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int drmBOUnmap(int fd, drmBO *buf)
|
int drmBOUnmap(int fd, drmBO *buf)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_handle_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
|
||||||
|
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
arg.handle = buf->handle;
|
||||||
req->op = drm_bo_unmap;
|
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg)) {
|
if (ioctl(fd, DRM_IOCTL_BO_UNMAP, &arg)) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
if (!arg.handled)
|
|
||||||
return -EFAULT;
|
|
||||||
if (rep->ret)
|
|
||||||
return rep->ret;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
|
int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
|
||||||
unsigned hint)
|
unsigned hint)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_op_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_op_req *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_arg_rep *rep = &arg.d.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
req->bo_req.handle = buf->handle;
|
||||||
req->mask = flags;
|
req->bo_req.mask = flags;
|
||||||
req->hint = hint;
|
req->bo_req.hint = hint;
|
||||||
req->arg_handle = mask; /* Encode mask in the arg_handle field :/ */
|
req->arg_handle = mask; /* Encode mask in the arg_handle field :/ */
|
||||||
req->op = drm_bo_validate;
|
req->op = drm_bo_validate;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_OP, &arg);
|
||||||
} while (ret && errno == EAGAIN);
|
} while (ret && errno == EAGAIN);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -2871,25 +2825,25 @@ int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
|
||||||
if (rep->ret)
|
if (rep->ret)
|
||||||
return rep->ret;
|
return rep->ret;
|
||||||
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(&rep->bo_info, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle)
|
int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_op_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_op_req *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_arg_rep *rep = &arg.d.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
req->bo_req.handle = buf->handle;
|
||||||
req->mask = flags;
|
req->bo_req.mask = flags;
|
||||||
req->arg_handle = fenceHandle;
|
req->arg_handle = fenceHandle;
|
||||||
req->op = drm_bo_validate;
|
req->op = drm_bo_fence;
|
||||||
|
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_OP, &arg);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -2902,51 +2856,43 @@ int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle)
|
||||||
|
|
||||||
int drmBOInfo(int fd, drmBO *buf)
|
int drmBOInfo(int fd, drmBO *buf)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_reference_info_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_handle_arg *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_info_rep *rep = &arg.d.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
req->handle = buf->handle;
|
||||||
req->op = drm_bo_info;
|
|
||||||
|
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_INFO, &arg);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled)
|
|
||||||
return -EFAULT;
|
|
||||||
if (rep->ret)
|
|
||||||
return rep->ret;
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(rep, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
|
int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
|
||||||
{
|
{
|
||||||
drm_bo_arg_t arg;
|
struct drm_bo_map_wait_idle_arg arg;
|
||||||
drm_bo_arg_request_t *req = &arg.d.req;
|
struct drm_bo_info_req *req = &arg.d.req;
|
||||||
drm_bo_arg_reply_t *rep = &arg.d.rep;
|
struct drm_bo_info_rep *rep = &arg.d.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
|
if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
|
||||||
(buf->replyFlags & DRM_BO_REP_BUSY)) {
|
(buf->replyFlags & DRM_BO_REP_BUSY)) {
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
req->handle = buf->handle;
|
req->handle = buf->handle;
|
||||||
req->op = drm_bo_wait_idle;
|
|
||||||
req->hint = hint;
|
req->hint = hint;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BO_WAIT_IDLE, &arg);
|
||||||
} while (ret && errno == EAGAIN);
|
} while (ret && errno == EAGAIN);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (!arg.handled)
|
|
||||||
return -EFAULT;
|
|
||||||
if (rep->ret)
|
|
||||||
return rep->ret;
|
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(rep, buf);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2967,7 +2913,6 @@ int drmBOBusy(int fd, drmBO *buf, int *busy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
|
int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
|
||||||
unsigned mask,
|
unsigned mask,
|
||||||
int *newItem)
|
int *newItem)
|
||||||
|
@ -3029,9 +2974,9 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
|
|
||||||
drmBONode *node;
|
drmBONode *node;
|
||||||
drmMMListHead *l;
|
drmMMListHead *l;
|
||||||
drm_bo_arg_t *arg, *first;
|
struct drm_bo_op_arg *arg, *first;
|
||||||
drm_bo_arg_request_t *req;
|
struct drm_bo_op_req *req;
|
||||||
drm_bo_arg_reply_t *rep;
|
struct drm_bo_arg_rep *rep;
|
||||||
drm_u64_t *prevNext = NULL;
|
drm_u64_t *prevNext = NULL;
|
||||||
drmBO *buf;
|
drmBO *buf;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -3052,10 +2997,10 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
|
|
||||||
memset(arg, 0, sizeof(*arg));
|
memset(arg, 0, sizeof(*arg));
|
||||||
prevNext = &arg->next;
|
prevNext = &arg->next;
|
||||||
req->handle = node->buf->handle;
|
req->bo_req.handle = node->buf->handle;
|
||||||
req->op = drm_bo_validate;
|
req->op = drm_bo_validate;
|
||||||
req->mask = node->arg0;
|
req->bo_req.mask = node->arg0;
|
||||||
req->hint = 0;
|
req->bo_req.hint = 0;
|
||||||
req->arg_handle = node->arg1;
|
req->arg_handle = node->arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3063,7 +3008,7 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first);
|
ret = ioctl(fd, DRM_IOCTL_BO_OP, first);
|
||||||
} while (ret && errno == EAGAIN);
|
} while (ret && errno == EAGAIN);
|
||||||
|
|
||||||
|
|
||||||
|
@ -3083,7 +3028,7 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
return rep->ret;
|
return rep->ret;
|
||||||
|
|
||||||
buf = node->buf;
|
buf = node->buf;
|
||||||
drmBOCopyReply(rep, buf);
|
drmBOCopyReply(&rep->bo_info, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3095,9 +3040,9 @@ int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle)
|
||||||
|
|
||||||
drmBONode *node;
|
drmBONode *node;
|
||||||
drmMMListHead *l;
|
drmMMListHead *l;
|
||||||
drm_bo_arg_t *arg, *first;
|
struct drm_bo_op_arg *arg, *first;
|
||||||
drm_bo_arg_request_t *req;
|
struct drm_bo_op_req *req;
|
||||||
drm_bo_arg_reply_t *rep;
|
struct drm_bo_arg_rep *rep;
|
||||||
drm_u64_t *prevNext = NULL;
|
drm_u64_t *prevNext = NULL;
|
||||||
drmBO *buf;
|
drmBO *buf;
|
||||||
unsigned fence_flags;
|
unsigned fence_flags;
|
||||||
|
@ -3119,16 +3064,16 @@ int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle)
|
||||||
|
|
||||||
memset(arg, 0, sizeof(*arg));
|
memset(arg, 0, sizeof(*arg));
|
||||||
prevNext = &arg->next;
|
prevNext = &arg->next;
|
||||||
req->handle = node->buf->handle;
|
req->bo_req.handle = node->buf->handle;
|
||||||
req->op = drm_bo_fence;
|
req->op = drm_bo_fence;
|
||||||
req->mask = node->arg0;
|
req->bo_req.mask = node->arg0;
|
||||||
req->arg_handle = fenceHandle;
|
req->arg_handle = fenceHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!first)
|
if (!first)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first);
|
ret = ioctl(fd, DRM_IOCTL_BO_OP, first);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -3143,7 +3088,7 @@ int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (rep->ret)
|
if (rep->ret)
|
||||||
return rep->ret;
|
return rep->ret;
|
||||||
drmBOCopyReply(rep, node->buf);
|
drmBOCopyReply(&rep->bo_info, node->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -125,7 +125,7 @@ typedef struct _drmBO{
|
||||||
typedef struct _drmBONode {
|
typedef struct _drmBONode {
|
||||||
drmMMListHead head;
|
drmMMListHead head;
|
||||||
drmBO *buf;
|
drmBO *buf;
|
||||||
drm_bo_arg_t bo_arg;
|
struct drm_bo_op_arg bo_arg;
|
||||||
unsigned long arg0;
|
unsigned long arg0;
|
||||||
unsigned long arg1;
|
unsigned long arg1;
|
||||||
} drmBONode;
|
} drmBONode;
|
||||||
|
|
|
@ -1784,6 +1784,80 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int drm_bo_create_ioctl(DRM_IOCTL_ARGS)
|
||||||
|
{
|
||||||
|
DRM_DEVICE;
|
||||||
|
drm_bo_create_arg_t arg;
|
||||||
|
unsigned long next;
|
||||||
|
drm_user_object_t *uo;
|
||||||
|
drm_buffer_object_t *entry;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!dev->bm.initialized) {
|
||||||
|
DRM_ERROR("Buffer object manager is not initialized.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg));
|
||||||
|
|
||||||
|
ret = drm_bo_lock_test(dev, filp);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = drm_buffer_object_create(priv->head->dev,
|
||||||
|
req->size, req->type, req->mask,
|
||||||
|
req->hint, req->page_alignment,
|
||||||
|
req->buffer_start, &entry);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = drm_bo_add_user_object(priv, entry,
|
||||||
|
req->mask & DRM_BO_FLAG_SHAREABLE);
|
||||||
|
if (ret) {
|
||||||
|
drm_bo_usage_deref_unlocked(entry);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_lock(&entry->mutex);
|
||||||
|
drm_bo_fill_rep_arg(entry, &rep);
|
||||||
|
mutex_unlock(&entry->mutex);
|
||||||
|
|
||||||
|
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
|
||||||
|
out:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int drm_bo_ioctl(DRM_IOCTL_ARGS)
|
||||||
|
{
|
||||||
|
DRM_DEVICE;
|
||||||
|
drm_bo_arg_t arg;
|
||||||
|
drm_bo_arg_request_t *req = &arg.d.req;
|
||||||
|
drm_bo_arg_reply_t rep;
|
||||||
|
unsigned long next;
|
||||||
|
drm_user_object_t *uo;
|
||||||
|
drm_buffer_object_t *entry;
|
||||||
|
|
||||||
|
if (!dev->bm.initialized) {
|
||||||
|
DRM_ERROR("Buffer object manager is not initialized.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg));
|
||||||
|
|
||||||
|
rep.ret = 0;
|
||||||
|
|
||||||
|
rep.ret = drm_buffer_object_unmap(priv, req->handle);
|
||||||
|
|
||||||
|
|
||||||
|
if (rep.ret == -EAGAIN)
|
||||||
|
return -EAGAIN;
|
||||||
|
|
||||||
|
|
||||||
|
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Clean the unfenced list and put on regular LRU.
|
*Clean the unfenced list and put on regular LRU.
|
||||||
*This is part of the memory manager cleanup and should only be
|
*This is part of the memory manager cleanup and should only be
|
||||||
|
|
|
@ -782,32 +782,29 @@ typedef enum {
|
||||||
drm_bo_type_kernel, /* for initial kernel allocations */
|
drm_bo_type_kernel, /* for initial kernel allocations */
|
||||||
}drm_bo_type_t;
|
}drm_bo_type_t;
|
||||||
|
|
||||||
|
struct drm_bo_info_req {
|
||||||
|
unsigned int handle;
|
||||||
|
unsigned int mask;
|
||||||
|
unsigned int hint;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct drm_bo_arg_request {
|
struct drm_bo_create_req {
|
||||||
unsigned handle; /* User space handle */
|
unsigned int mask;
|
||||||
unsigned mask;
|
unsigned int hint;
|
||||||
unsigned hint;
|
unsigned page_alignment;
|
||||||
drm_u64_t size;
|
drm_u64_t size;
|
||||||
drm_bo_type_t type;
|
drm_bo_type_t type;
|
||||||
unsigned arg_handle;
|
|
||||||
drm_u64_t buffer_start;
|
drm_u64_t buffer_start;
|
||||||
unsigned page_alignment;
|
};
|
||||||
unsigned expand_pad[4]; /*Future expansion */
|
|
||||||
enum {
|
|
||||||
drm_bo_create,
|
|
||||||
drm_bo_validate,
|
|
||||||
drm_bo_map,
|
|
||||||
drm_bo_unmap,
|
|
||||||
drm_bo_fence,
|
|
||||||
drm_bo_destroy,
|
|
||||||
drm_bo_reference,
|
|
||||||
drm_bo_unreference,
|
|
||||||
drm_bo_info,
|
|
||||||
drm_bo_wait_idle,
|
|
||||||
drm_bo_ref_fence
|
|
||||||
} op;
|
|
||||||
} drm_bo_arg_request_t;
|
|
||||||
|
|
||||||
|
struct drm_bo_op_req {
|
||||||
|
struct drm_bo_info_req bo_req;
|
||||||
|
unsigned int arg_handle;
|
||||||
|
enum {
|
||||||
|
drm_bo_validate,
|
||||||
|
drm_bo_fence,
|
||||||
|
} op;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reply flags
|
* Reply flags
|
||||||
|
@ -815,30 +812,58 @@ typedef struct drm_bo_arg_request {
|
||||||
|
|
||||||
#define DRM_BO_REP_BUSY 0x00000001
|
#define DRM_BO_REP_BUSY 0x00000001
|
||||||
|
|
||||||
typedef struct drm_bo_arg_reply {
|
struct drm_bo_info_rep {
|
||||||
int ret;
|
unsigned int handle;
|
||||||
unsigned handle;
|
unsigned int flags;
|
||||||
unsigned flags;
|
|
||||||
drm_u64_t size;
|
drm_u64_t size;
|
||||||
drm_u64_t offset;
|
drm_u64_t offset;
|
||||||
drm_u64_t arg_handle;
|
drm_u64_t arg_handle;
|
||||||
unsigned mask;
|
unsigned int mask;
|
||||||
drm_u64_t buffer_start;
|
drm_u64_t buffer_start;
|
||||||
unsigned fence_flags;
|
unsigned int fence_flags;
|
||||||
unsigned rep_flags;
|
unsigned int rep_flags;
|
||||||
unsigned page_alignment;
|
unsigned int page_alignment;
|
||||||
unsigned expand_pad[4]; /*Future expansion */
|
unsigned int expand_pad[4]; /*Future expansion */
|
||||||
}drm_bo_arg_reply_t;
|
};
|
||||||
|
|
||||||
|
struct drm_bo_arg_rep {
|
||||||
|
int ret;
|
||||||
|
struct drm_bo_info_rep bo_info;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct drm_bo_arg{
|
struct drm_bo_create_arg {
|
||||||
|
union {
|
||||||
|
struct drm_bo_create_req req;
|
||||||
|
struct drm_bo_info_rep rep;
|
||||||
|
} d;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct drm_bo_handle_arg {
|
||||||
|
unsigned int handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct drm_bo_reference_info_arg {
|
||||||
|
union {
|
||||||
|
struct drm_bo_handle_arg req;
|
||||||
|
struct drm_bo_info_rep rep;
|
||||||
|
} d;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct drm_bo_map_wait_idle_arg {
|
||||||
|
union {
|
||||||
|
struct drm_bo_info_req req;
|
||||||
|
struct drm_bo_info_rep rep;
|
||||||
|
} d;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct drm_bo_op_arg {
|
||||||
int handled;
|
int handled;
|
||||||
drm_u64_t next;
|
drm_u64_t next;
|
||||||
union {
|
union {
|
||||||
drm_bo_arg_request_t req;
|
struct drm_bo_op_req req;
|
||||||
drm_bo_arg_reply_t rep;
|
struct drm_bo_arg_rep rep;
|
||||||
} d;
|
} d;
|
||||||
} drm_bo_arg_t;
|
};
|
||||||
|
|
||||||
#define DRM_BO_MEM_LOCAL 0
|
#define DRM_BO_MEM_LOCAL 0
|
||||||
#define DRM_BO_MEM_TT 1
|
#define DRM_BO_MEM_TT 1
|
||||||
|
@ -926,9 +951,6 @@ typedef struct drm_mm_init_arg {
|
||||||
|
|
||||||
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
|
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
|
||||||
|
|
||||||
#define DRM_IOCTL_FENCE DRM_IOWR(0x3b, drm_fence_arg_t)
|
|
||||||
#define DRM_IOCTL_BUFOBJ DRM_IOWR(0x3d, drm_bo_arg_t)
|
|
||||||
|
|
||||||
#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, drm_update_draw_t)
|
#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, drm_update_draw_t)
|
||||||
|
|
||||||
#define DRM_IOCTL_MM_INIT DRM_IOWR(0xc0, drm_mm_init_arg_t)
|
#define DRM_IOCTL_MM_INIT DRM_IOWR(0xc0, drm_mm_init_arg_t)
|
||||||
|
@ -946,17 +968,15 @@ typedef struct drm_mm_init_arg {
|
||||||
#define DRM_IOCTL_FENCE_EMIT DRM_IOWR(0xcb, drm_fence_arg_t)
|
#define DRM_IOCTL_FENCE_EMIT DRM_IOWR(0xcb, drm_fence_arg_t)
|
||||||
#define DRM_IOCTL_FENCE_BUFFERS DRM_IOWR(0xcc, drm_fence_arg_t)
|
#define DRM_IOCTL_FENCE_BUFFERS DRM_IOWR(0xcc, drm_fence_arg_t)
|
||||||
|
|
||||||
#define DRM_IOCTL_BO_CREATE DRM_IOWR(0xcd, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_CREATE DRM_IOWR(0xcd, struct drm_bo_create_arg)
|
||||||
#define DRM_IOCTL_BO_DESTROY DRM_IOWR(0xce, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_DESTROY DRM_IOWR(0xce, struct drm_bo_handle_arg)
|
||||||
#define DRM_IOCTL_BO_MAP DRM_IOWR(0xcf, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_MAP DRM_IOWR(0xcf, struct drm_bo_map_wait_idle_arg)
|
||||||
#define DRM_IOCTL_BO_UNMAP DRM_IOWR(0xd0, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_UNMAP DRM_IOWR(0xd0, struct drm_bo_handle_arg)
|
||||||
#define DRM_IOCTL_BO_REFERENCE DRM_IOWR(0xd1, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_REFERENCE DRM_IOWR(0xd1, struct drm_bo_reference_info_arg)
|
||||||
#define DRM_IOCTL_BO_UNREFERENCE DRM_IOWR(0xd2, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_UNREFERENCE DRM_IOWR(0xd2, struct drm_bo_handle_arg)
|
||||||
#define DRM_IOCTL_BO_VALIDATE DRM_IOWR(0xd3, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_OP DRM_IOWR(0xd3, struct drm_bo_op_arg)
|
||||||
#define DRM_IOCTL_BO_FENCE DRM_IOWR(0xd4, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_INFO DRM_IOWR(0xd4, struct drm_bo_reference_info_arg)
|
||||||
#define DRM_IOCTL_BO_INFO DRM_IOWR(0xd5, drm_bo_arg_t)
|
#define DRM_IOCTL_BO_WAIT_IDLE DRM_IOWR(0xd5, struct drm_bo_map_wait_idle_arg)
|
||||||
#define DRM_IOCTL_BO_WAIT_IDLE DRM_IOWR(0xd6, drm_bo_arg_t)
|
|
||||||
#define DRM_IOCTL_BO_REF_FENCE DRM_IOWR(0xd7, drm_bo_arg_t)
|
|
||||||
|
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
Loading…
Reference in New Issue