Add a 64-bit drm unsigned type for 64-bit clean IOCTLS.
Conversion functions in drmP.h and xf86drm.c.main
parent
4ddabd1562
commit
e181f594a4
|
@ -2362,25 +2362,27 @@ int drmFenceWait(int fd, drmFence *fence, unsigned flush_type,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long combine64(unsigned lo, unsigned hi)
|
static unsigned long drmUL(drm_u64_t val)
|
||||||
{
|
{
|
||||||
unsigned long ret = lo;
|
unsigned long ret = val.lo;
|
||||||
if (sizeof(ret) == 8) {
|
if (sizeof(ret) == 8) {
|
||||||
int shift = 32;
|
int shift = 32;
|
||||||
ret |= (hi << shift);
|
ret |= (val.hi << shift);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void split32(unsigned long val, unsigned *lo, unsigned *hi)
|
static drm_u64_t drmU64(unsigned long val)
|
||||||
{
|
{
|
||||||
*lo = val & 0xFFFFFFFFUL;
|
drm_u64_t ret;
|
||||||
|
ret.lo = val & 0xFFFFFFFFUL;
|
||||||
if (sizeof(val) == 8) {
|
if (sizeof(val) == 8) {
|
||||||
int shift = 32;
|
int shift = 32;
|
||||||
*hi = val >> shift;
|
ret.hi = val >> shift;
|
||||||
} else {
|
} else {
|
||||||
*hi = 0;
|
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)
|
||||||
|
@ -2389,7 +2391,7 @@ int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
|
||||||
|
|
||||||
arg.op = drm_ttm_create;
|
arg.op = drm_ttm_create;
|
||||||
arg.flags = flags;
|
arg.flags = flags;
|
||||||
split32((unsigned long) size, &arg.size_lo, &arg.size_hi);
|
arg.size = drmU64(size);
|
||||||
|
|
||||||
if (ioctl(fd, DRM_IOCTL_TTM, &arg))
|
if (ioctl(fd, DRM_IOCTL_TTM, &arg))
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -2397,7 +2399,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 = combine64(arg.size_lo, arg.size_hi);
|
ttm->size = drmUL(arg.size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2424,7 +2426,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 = combine64(arg.size_lo, arg.size_hi);
|
ttm->size = drmUL(arg.size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -497,6 +497,8 @@ do { register unsigned int __old __asm("o0"); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* General user-level programmer's API: unprivileged */
|
/* General user-level programmer's API: unprivileged */
|
||||||
extern int drmAvailable(void);
|
extern int drmAvailable(void);
|
||||||
extern int drmOpen(const char *name, const char *busid);
|
extern int drmOpen(const char *name, const char *busid);
|
||||||
|
|
|
@ -1359,26 +1359,29 @@ 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 2*32-bit to 64-bit function
|
* Convenience drm_u64_t functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static __inline__ unsigned long combine_64(uint32_t lo, uint32_t hi)
|
static __inline__ unsigned long drm_ul(drm_u64_t val)
|
||||||
{
|
{
|
||||||
unsigned long ret = lo;
|
unsigned long ret = val.lo;
|
||||||
#if (BITS_PER_LONG == 64)
|
#if (BITS_PER_LONG == 64)
|
||||||
ret |= (hi << 32);
|
ret |= (val.hi << 32);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void split_32(unsigned long val, uint32_t *lo, uint32_t *hi)
|
static __inline__ drm_u64_t drm_u64(unsigned long val)
|
||||||
{
|
{
|
||||||
*lo = val & 0xFFFFFFFFUL;
|
drm_u64_t ret;
|
||||||
|
|
||||||
|
ret.lo = val & 0xFFFFFFFFUL;
|
||||||
#if (BITS_PER_LONG == 64)
|
#if (BITS_PER_LONG == 64)
|
||||||
*hi = val >> 32;
|
ret.hi = val >> 32;
|
||||||
#else
|
#else
|
||||||
*hi = 0;
|
ret.hi = 0;
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -865,7 +865,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 = combine_64(arg.size_lo, arg.size_hi);
|
size = drm_ul(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);
|
||||||
|
@ -903,7 +903,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;
|
||||||
split_32(entry->map_list.map->size, &arg.size_lo, &arg.size_hi);
|
arg.size = drm_u64(entry->map_list.map->size);
|
||||||
atomic_dec(&entry->usage);
|
atomic_dec(&entry->usage);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
|
|
|
@ -630,6 +630,11 @@ 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{
|
||||||
|
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
|
||||||
#define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004
|
#define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004
|
||||||
|
@ -655,6 +660,22 @@ typedef struct drm_fence_arg {
|
||||||
} op;
|
} op;
|
||||||
} drm_fence_arg_t;
|
} drm_fence_arg_t;
|
||||||
|
|
||||||
|
#define DRM_TTM_FLAG_SHAREABLE 0x00000001
|
||||||
|
|
||||||
|
typedef struct drm_ttm_arg {
|
||||||
|
enum {
|
||||||
|
drm_ttm_create,
|
||||||
|
drm_ttm_destroy,
|
||||||
|
drm_ttm_reference,
|
||||||
|
drm_ttm_unreference
|
||||||
|
} op;
|
||||||
|
unsigned handle;
|
||||||
|
unsigned user_token;
|
||||||
|
drm_u64_t size;
|
||||||
|
unsigned flags;
|
||||||
|
}drm_ttm_arg_t;
|
||||||
|
|
||||||
|
|
||||||
#define DRM_BO_FLAG_READ 0x00000001
|
#define DRM_BO_FLAG_READ 0x00000001
|
||||||
#define DRM_BO_FLAG_WRITE 0x00000002
|
#define DRM_BO_FLAG_WRITE 0x00000002
|
||||||
#define DRM_BO_FLAG_EXE 0x00000004
|
#define DRM_BO_FLAG_EXE 0x00000004
|
||||||
|
@ -674,43 +695,12 @@ typedef struct drm_fence_arg {
|
||||||
#define DRM_BO_HINT_AVOID_LOCAL 0x00000002
|
#define DRM_BO_HINT_AVOID_LOCAL 0x00000002
|
||||||
#define DRM_BO_HINT_DONT_BLOCK 0x00000004
|
#define DRM_BO_HINT_DONT_BLOCK 0x00000004
|
||||||
|
|
||||||
/*
|
|
||||||
* Multiplexing ioctl argument.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct drm_bo_arg {
|
|
||||||
unsigned num_requests;
|
|
||||||
enum {
|
|
||||||
drm_op_bo,
|
|
||||||
drm_op_ttm
|
|
||||||
} op;
|
|
||||||
unsigned data_lo;
|
|
||||||
unsigned data_hi;
|
|
||||||
} drm_bo_arg_t;
|
|
||||||
|
|
||||||
#define DRM_TTM_FLAG_SHAREABLE 0x00000001
|
|
||||||
|
|
||||||
typedef struct drm_ttm_arg {
|
|
||||||
enum {
|
|
||||||
drm_ttm_create,
|
|
||||||
drm_ttm_destroy,
|
|
||||||
drm_ttm_reference,
|
|
||||||
drm_ttm_unreference
|
|
||||||
} op;
|
|
||||||
unsigned handle;
|
|
||||||
unsigned user_token;
|
|
||||||
unsigned size_lo;
|
|
||||||
unsigned size_hi;
|
|
||||||
unsigned flags;
|
|
||||||
}drm_ttm_arg_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct drm_bo_arg_request {
|
typedef struct drm_bo_arg_request {
|
||||||
unsigned handle; /* User space handle */
|
unsigned handle; /* User space handle */
|
||||||
unsigned mask;
|
unsigned mask;
|
||||||
unsigned hint;
|
unsigned hint;
|
||||||
unsigned size_lo;
|
drm_u64_t size;
|
||||||
unsigned size_hi;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
drm_bo_type_ttm,
|
drm_bo_type_ttm,
|
||||||
|
@ -718,8 +708,8 @@ typedef struct drm_bo_arg_request {
|
||||||
drm_bo_type_user
|
drm_bo_type_user
|
||||||
}type;
|
}type;
|
||||||
unsigned arg_handle;
|
unsigned arg_handle;
|
||||||
unsigned user_pointer_lo;
|
drm_u64_t user_pointer;
|
||||||
unsigned user_pointer_hi;
|
drm_u64_t next;
|
||||||
enum {
|
enum {
|
||||||
drm_bo_create,
|
drm_bo_create,
|
||||||
drm_bo_validate,
|
drm_bo_validate,
|
||||||
|
@ -733,21 +723,20 @@ typedef struct drm_bo_arg_request {
|
||||||
|
|
||||||
typedef struct drm_bo_arg_reply {
|
typedef struct drm_bo_arg_reply {
|
||||||
int ret;
|
int ret;
|
||||||
|
int handled;
|
||||||
unsigned handle;
|
unsigned handle;
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
unsigned size_lo;
|
drm_u64_t size;
|
||||||
unsigned size_hi;
|
drm_u64_t offset;
|
||||||
unsigned offset_lo;
|
|
||||||
unsigned offset_hi;
|
|
||||||
unsigned arg_handle;
|
unsigned arg_handle;
|
||||||
unsigned map_flags;
|
unsigned map_flags;
|
||||||
}drm_bo_arg_reply_t;
|
}drm_bo_arg_reply_t;
|
||||||
|
|
||||||
|
|
||||||
typedef union drm_bo_arg_data {
|
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_data_t;
|
} drm_bo_arg_t;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue