64-bit IOCTL integer (Michel Dänzer & Brian Paul)
parent
2057406470
commit
279e8d26c6
|
@ -2237,6 +2237,8 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
|
||||||
int drmFenceCreate(int fd, int shareable, int class,unsigned type,
|
int drmFenceCreate(int fd, int shareable, int class,unsigned type,
|
||||||
int emit,
|
int emit,
|
||||||
drmFence *fence)
|
drmFence *fence)
|
||||||
|
@ -2362,36 +2364,13 @@ int drmFenceWait(int fd, drmFence *fence, unsigned flush_type,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long drmUL(drm_u64_t val)
|
|
||||||
{
|
|
||||||
unsigned long ret = val.lo;
|
|
||||||
if (sizeof(ret) == 8) {
|
|
||||||
int shift = 32;
|
|
||||||
ret |= (val.hi << shift);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static drm_u64_t drmU64(unsigned long val)
|
|
||||||
{
|
|
||||||
drm_u64_t ret;
|
|
||||||
ret.lo = val & 0xFFFFFFFFUL;
|
|
||||||
if (sizeof(val) == 8) {
|
|
||||||
int shift = 32;
|
|
||||||
ret.hi = val >> shift;
|
|
||||||
} else {
|
|
||||||
ret.hi = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
|
int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
|
||||||
{
|
{
|
||||||
drm_ttm_arg_t arg;
|
drm_ttm_arg_t arg;
|
||||||
|
|
||||||
arg.op = drm_ttm_create;
|
arg.op = drm_ttm_create;
|
||||||
arg.flags = flags;
|
arg.flags = flags;
|
||||||
arg.size = drmU64(size);
|
arg.size = size;
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_TTM, &arg))
|
if (ioctl(fd, DRM_IOCTL_TTM, &arg))
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -2399,7 +2378,7 @@ int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
|
||||||
ttm->handle = arg.handle;
|
ttm->handle = arg.handle;
|
||||||
ttm->user_token = (drm_handle_t) arg.user_token;
|
ttm->user_token = (drm_handle_t) arg.user_token;
|
||||||
ttm->flags = arg.flags;
|
ttm->flags = arg.flags;
|
||||||
ttm->size = drmUL(arg.size);
|
ttm->size = arg.size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2426,7 +2405,7 @@ int drmTTMReference(int fd, unsigned handle, drmTTM *ttm)
|
||||||
ttm->handle = arg.handle;
|
ttm->handle = arg.handle;
|
||||||
ttm->user_token = (drm_handle_t) arg.user_token;
|
ttm->user_token = (drm_handle_t) arg.user_token;
|
||||||
ttm->flags = arg.flags;
|
ttm->flags = arg.flags;
|
||||||
ttm->size = drmUL(arg.size);
|
ttm->size = arg.size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2446,3 +2425,4 @@ drm_handle_t drmTTMMapHandle(int fd, const drmTTM *ttm)
|
||||||
(void) fd;
|
(void) fd;
|
||||||
return ttm->user_token;
|
return ttm->user_token;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -952,9 +952,9 @@ typedef struct drm_buffer_object{
|
||||||
drm_ttm_object_t *ttm_object;
|
drm_ttm_object_t *ttm_object;
|
||||||
drm_ttm_backend_list_t *ttm_region;
|
drm_ttm_backend_list_t *ttm_region;
|
||||||
void __user *user_pages;
|
void __user *user_pages;
|
||||||
|
unsigned long num_pages;
|
||||||
|
|
||||||
atomic_t mapped;
|
atomic_t mapped;
|
||||||
|
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
uint32_t mask_hint;
|
uint32_t mask_hint;
|
||||||
|
@ -1360,32 +1360,6 @@ extern int drm_fence_ioctl(DRM_IOCTL_ARGS);
|
||||||
|
|
||||||
extern int drm_bo_ioctl(DRM_IOCTL_ARGS);
|
extern int drm_bo_ioctl(DRM_IOCTL_ARGS);
|
||||||
|
|
||||||
/*
|
|
||||||
* Convenience drm_u64_t functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
static __inline__ unsigned long drm_ul(drm_u64_t val)
|
|
||||||
{
|
|
||||||
unsigned long ret = val.lo;
|
|
||||||
#if (BITS_PER_LONG == 64)
|
|
||||||
ret |= (val.hi << 32);
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline__ drm_u64_t drm_u64(unsigned long val)
|
|
||||||
{
|
|
||||||
drm_u64_t ret;
|
|
||||||
|
|
||||||
ret.lo = val & 0xFFFFFFFFUL;
|
|
||||||
#if (BITS_PER_LONG == 64)
|
|
||||||
ret.hi = val >> 32;
|
|
||||||
#else
|
|
||||||
ret.hi = 0;
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Inline replacements for DRM_IOREMAP macros */
|
/* Inline replacements for DRM_IOREMAP macros */
|
||||||
static __inline__ void drm_core_ioremap(struct drm_map *map,
|
static __inline__ void drm_core_ioremap(struct drm_map *map,
|
||||||
|
|
|
@ -531,6 +531,7 @@ static int drm_buffer_object_validate(drm_device_t *dev, drm_buffer_object_t *bo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int drm_buffer_object_create(drm_file_t *priv,
|
int drm_buffer_object_create(drm_file_t *priv,
|
||||||
int size,
|
int size,
|
||||||
drm_bo_type_t type,
|
drm_bo_type_t type,
|
||||||
|
@ -544,6 +545,7 @@ int drm_buffer_object_create(drm_file_t *priv,
|
||||||
drm_buffer_object_t *bo;
|
drm_buffer_object_t *bo;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint32_t ttm_flags = 0;
|
uint32_t ttm_flags = 0;
|
||||||
|
drm_ttm_t *ttm;
|
||||||
|
|
||||||
bo = drm_calloc(1, sizeof(*bo), DRM_MEM_BUFOBJ);
|
bo = drm_calloc(1, sizeof(*bo), DRM_MEM_BUFOBJ);
|
||||||
|
|
||||||
|
@ -567,11 +569,35 @@ int drm_buffer_object_create(drm_file_t *priv,
|
||||||
goto out_err;
|
goto out_err;
|
||||||
break;
|
break;
|
||||||
case drm_bo_type_ttm:
|
case drm_bo_type_ttm:
|
||||||
|
if (buffer_start & ~PAGE_MASK) {
|
||||||
|
DRM_ERROR("Illegal buffer object start\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
bo->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||||
|
if (!bo->num_pages) {
|
||||||
|
DRM_ERROR("Illegal buffer object size\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
bo->ttm_object = drm_lookup_ttm_object(priv, ttm_handle, 1);
|
bo->ttm_object = drm_lookup_ttm_object(priv, ttm_handle, 1);
|
||||||
|
if (!bo->ttm_object) {
|
||||||
|
DRM_ERROR("Could not find buffer object TTM\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
ttm = drm_ttm_from_object(bo->ttm_object);
|
||||||
|
ret = drm_create_ttm_region(ttm, buffer_start >> PAGE_SHIFT,
|
||||||
|
bo->num_pages, 0, &bo->ttm_region);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
break;
|
break;
|
||||||
case drm_bo_type_user:
|
case drm_bo_type_user:
|
||||||
|
if (buffer_start & ~PAGE_MASK) {
|
||||||
|
DRM_ERROR("Illegal buffer object start\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
bo->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||||
bo->user_pages = (void __user *)buffer_start;
|
bo->user_pages = (void __user *)buffer_start;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -635,8 +661,8 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
|
||||||
rep.handled = 0;
|
rep.handled = 0;
|
||||||
switch (req->op) {
|
switch (req->op) {
|
||||||
case drm_bo_create: {
|
case drm_bo_create: {
|
||||||
unsigned long buffer_start = drm_ul(req->buffer_start);
|
unsigned long buffer_start = req->buffer_start;
|
||||||
rep.ret = drm_buffer_object_create(priv, drm_ul(req->size),
|
rep.ret = drm_buffer_object_create(priv, req->size,
|
||||||
req->type, req->arg_handle,
|
req->type, req->arg_handle,
|
||||||
req->mask, req->hint,
|
req->mask, req->hint,
|
||||||
buffer_start,
|
buffer_start,
|
||||||
|
@ -687,7 +713,7 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
|
||||||
default:
|
default:
|
||||||
rep.ret = -EINVAL;
|
rep.ret = -EINVAL;
|
||||||
}
|
}
|
||||||
next = drm_ul(req->next);
|
next = req->next;
|
||||||
rep.handled = 1;
|
rep.handled = 1;
|
||||||
arg.rep = rep;
|
arg.rep = rep;
|
||||||
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
|
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
|
||||||
|
|
|
@ -888,7 +888,7 @@ int drm_ttm_ioctl(DRM_IOCTL_ARGS)
|
||||||
switch(arg.op) {
|
switch(arg.op) {
|
||||||
case drm_ttm_create:
|
case drm_ttm_create:
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
size = drm_ul(arg.size);
|
size = arg.size;
|
||||||
ret = drm_ttm_object_create(dev, size, arg.flags, &entry);
|
ret = drm_ttm_object_create(dev, size, arg.flags, &entry);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
@ -929,7 +929,7 @@ int drm_ttm_ioctl(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
arg.handle = entry->base.hash.key;
|
arg.handle = entry->base.hash.key;
|
||||||
arg.user_token = entry->map_list.user_token;
|
arg.user_token = entry->map_list.user_token;
|
||||||
arg.size = drm_u64(entry->map_list.map->size);
|
arg.size = entry->map_list.map->size;
|
||||||
drm_ttm_object_deref_locked(dev, entry);
|
drm_ttm_object_deref_locked(dev, entry);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,11 @@ extern int drm_ttm_add_mm_to_list(drm_ttm_t * ttm, struct mm_struct *mm);
|
||||||
extern void drm_ttm_delete_mm(drm_ttm_t * ttm, struct mm_struct *mm);
|
extern void drm_ttm_delete_mm(drm_ttm_t * ttm, struct mm_struct *mm);
|
||||||
extern int drm_ttm_ioctl(DRM_IOCTL_ARGS);
|
extern int drm_ttm_ioctl(DRM_IOCTL_ARGS);
|
||||||
|
|
||||||
|
static __inline__ drm_ttm_t *drm_ttm_from_object(drm_ttm_object_t *to)
|
||||||
|
{
|
||||||
|
return (drm_ttm_t *) to->map_list.map->offset;
|
||||||
|
}
|
||||||
|
|
||||||
#define DRM_MASK_VAL(dest, mask, val) \
|
#define DRM_MASK_VAL(dest, mask, val) \
|
||||||
(dest) = ((dest) & ~(mask)) | ((val) & (mask));
|
(dest) = ((dest) & ~(mask)) | ((val) & (mask));
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,12 @@
|
||||||
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
|
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
#if defined(__KERNEL__)
|
||||||
|
typedef __u64 drm_u64_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long long drm_u64_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned int drm_handle_t;
|
typedef unsigned int drm_handle_t;
|
||||||
#else
|
#else
|
||||||
typedef unsigned long drm_handle_t; /**< To mapped regions */
|
typedef unsigned long drm_handle_t; /**< To mapped regions */
|
||||||
|
@ -630,10 +636,7 @@ typedef struct drm_set_version {
|
||||||
int drm_dd_minor;
|
int drm_dd_minor;
|
||||||
} drm_set_version_t;
|
} drm_set_version_t;
|
||||||
|
|
||||||
typedef struct drm_u64{
|
#ifdef __linux__
|
||||||
unsigned lo;
|
|
||||||
unsigned hi;
|
|
||||||
}drm_u64_t;
|
|
||||||
|
|
||||||
#define DRM_FENCE_FLAG_EMIT 0x00000001
|
#define DRM_FENCE_FLAG_EMIT 0x00000001
|
||||||
#define DRM_FENCE_FLAG_SHAREABLE 0x00000002
|
#define DRM_FENCE_FLAG_SHAREABLE 0x00000002
|
||||||
|
@ -739,7 +742,7 @@ typedef union drm_bo_arg{
|
||||||
drm_bo_arg_request_t req;
|
drm_bo_arg_request_t req;
|
||||||
drm_bo_arg_reply_t rep;
|
drm_bo_arg_reply_t rep;
|
||||||
} drm_bo_arg_t;
|
} drm_bo_arg_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Ioctls Definitions
|
* \name Ioctls Definitions
|
||||||
|
@ -806,8 +809,10 @@ typedef union drm_bo_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)
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
#define DRM_IOCTL_FENCE DRM_IOWR(0x3b, drm_fence_arg_t)
|
#define DRM_IOCTL_FENCE DRM_IOWR(0x3b, drm_fence_arg_t)
|
||||||
#define DRM_IOCTL_TTM DRM_IOWR(0x3c, drm_ttm_arg_t)
|
#define DRM_IOCTL_TTM DRM_IOWR(0x3c, drm_ttm_arg_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue