diff options
Diffstat (limited to 'libdrm')
-rw-r--r-- | libdrm/xf86drm.c | 664 | ||||
-rw-r--r-- | libdrm/xf86drm.h | 2 | ||||
-rw-r--r-- | libdrm/xf86drmHash.c | 19 | ||||
-rw-r--r-- | libdrm/xf86drmRandom.c | 19 | ||||
-rw-r--r-- | libdrm/xf86drmSL.c | 22 | ||||
-rw-r--r-- | libdrm/xf86mm.h | 58 |
6 files changed, 404 insertions, 380 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index a815ed7a..1f242fe3 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -31,10 +31,6 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -96,7 +92,7 @@ static drmServerInfoPtr drm_server_info; void drmSetServerInfo(drmServerInfoPtr info) { - drm_server_info = info; + drm_server_info = info; } /** @@ -110,7 +106,7 @@ void drmSetServerInfo(drmServerInfoPtr info) static int drmDebugPrint(const char *format, va_list ap) { - return vfprintf(stderr, format, ap); + return vfprintf(stderr, format, ap); } static int (*drm_debug_print)(const char *format, va_list ap) = drmDebugPrint; @@ -135,26 +131,28 @@ drmMsg(const char *format, ...) void drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char *format, va_list ap)) { - drm_debug_print = debug_msg_ptr; + drm_debug_print = debug_msg_ptr; } static void *drmHashTable = NULL; /* Context switch callbacks */ void *drmGetHashTable(void) { - return drmHashTable; + return drmHashTable; } void *drmMalloc(int size) { void *pt; - if ((pt = malloc(size))) memset(pt, 0, size); + if ((pt = malloc(size))) + memset(pt, 0, size); return pt; } void drmFree(void *pt) { - if (pt) free(pt); + if (pt) + free(pt); } /* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */ @@ -190,7 +188,8 @@ drmHashEntry *drmGetEntry(int fd) void *value; drmHashEntry *entry; - if (!drmHashTable) drmHashTable = drmHashCreate(); + if (!drmHashTable) + drmHashTable = drmHashCreate(); if (drmHashLookup(drmHashTable, key, &value)) { entry = drmMalloc(sizeof(*entry)); @@ -280,14 +279,15 @@ static int drmOpenDevice(long dev, int minor) drmMsg("drmOpenDevice: node name is %s\n", buf); if (drm_server_info) { - drm_server_info->get_perms(&serv_group, &serv_mode); - devmode = serv_mode ? serv_mode : DRM_DEV_MODE; - devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); - group = (serv_group >= 0) ? serv_group : DRM_DEV_GID; + drm_server_info->get_perms(&serv_group, &serv_mode); + devmode = serv_mode ? serv_mode : DRM_DEV_MODE; + devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); + group = (serv_group >= 0) ? serv_group : DRM_DEV_GID; } if (stat(DRM_DIR_NAME, &st)) { - if (!isroot) return DRM_ERR_NOT_ROOT; + if (!isroot) + return DRM_ERR_NOT_ROOT; mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE); chown(DRM_DIR_NAME, 0, 0); /* root:root */ chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE); @@ -295,37 +295,41 @@ static int drmOpenDevice(long dev, int minor) /* Check if the device node exists and create it if necessary. */ if (stat(buf, &st)) { - if (!isroot) return DRM_ERR_NOT_ROOT; + if (!isroot) + return DRM_ERR_NOT_ROOT; remove(buf); mknod(buf, S_IFCHR | devmode, dev); } if (drm_server_info) { - chown(buf, user, group); - chmod(buf, devmode); + chown(buf, user, group); + chmod(buf, devmode); } fd = open(buf, O_RDWR, 0); drmMsg("drmOpenDevice: open result is %d, (%s)\n", fd, fd < 0 ? strerror(errno) : "OK"); - if (fd >= 0) return fd; + if (fd >= 0) + return fd; /* Check if the device node is not what we expect it to be, and recreate it * and try again if so. */ if (st.st_rdev != dev) { - if (!isroot) return DRM_ERR_NOT_ROOT; + if (!isroot) + return DRM_ERR_NOT_ROOT; remove(buf); mknod(buf, S_IFCHR | devmode, dev); if (drm_server_info) { - chown(buf, user, group); - chmod(buf, devmode); + chown(buf, user, group); + chmod(buf, devmode); } } fd = open(buf, O_RDWR, 0); drmMsg("drmOpenDevice: open result is %d, (%s)\n", fd, fd < 0 ? strerror(errno) : "OK"); - if (fd >= 0) return fd; + if (fd >= 0) + return fd; drmMsg("drmOpenDevice: Open failed\n"); remove(buf); @@ -350,10 +354,12 @@ static int drmOpenMinor(int minor, int create) int fd; char buf[64]; - if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); + if (create) + return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); - if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; + if ((fd = open(buf, O_RDWR, 0)) >= 0) + return fd; return -errno; } @@ -377,7 +383,8 @@ int drmAvailable(void) if ((fd = drmOpenMinor(0, 1)) < 0) { #ifdef __linux__ /* Try proc for backward Linux compatibility */ - if (!access("/proc/dri/0", R_OK)) return 1; + if (!access("/proc/dri/0", R_OK)) + return 1; #endif return 0; } @@ -428,7 +435,8 @@ static int drmOpenByBusid(const char *busid) drmFreeBusid(buf); return fd; } - if (buf) drmFreeBusid(buf); + if (buf) + drmFreeBusid(buf); close(fd); } } @@ -458,16 +466,16 @@ static int drmOpenByName(const char *name) char * id; if (!drmAvailable()) { - if (!drm_server_info) - return -1; - else { - /* try to load the kernel module now */ - if (!drm_server_info->load_module(name)) { - drmMsg("[drm] failed to load kernel module \"%s\"\n", - name); - return -1; - } - } + if (!drm_server_info) { + return -1; + } + else { + /* try to load the kernel module now */ + if (!drm_server_info->load_module(name)) { + drmMsg("[drm] failed to load kernel module \"%s\"\n", name); + return -1; + } + } } /* @@ -552,16 +560,13 @@ int drmOpen(const char *name, const char *busid) if (!drmAvailable() && name != NULL && drm_server_info) { /* try to load the kernel */ if (!drm_server_info->load_module(name)) { - drmMsg("[drm] failed to load kernel module \"%s\"\n", - name); + drmMsg("[drm] failed to load kernel module \"%s\"\n", name); return -1; } } if (busid) { - int fd; - - fd = drmOpenByBusid(busid); + int fd = drmOpenByBusid(busid); if (fd >= 0) return fd; } @@ -584,7 +589,8 @@ int drmOpen(const char *name, const char *busid) */ void drmFreeVersion(drmVersionPtr v) { - if (!v) return; + if (!v) + return; drmFree(v->name); drmFree(v->date); drmFree(v->desc); @@ -603,7 +609,8 @@ void drmFreeVersion(drmVersionPtr v) */ static void drmFreeKernelVersion(drm_version_t *v) { - if (!v) return; + if (!v) + return; drmFree(v->name); drmFree(v->date); drmFree(v->desc); @@ -760,9 +767,11 @@ char *drmGetBusid(int fd) u.unique_len = 0; u.unique = NULL; - if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL; + if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) + return NULL; u.unique = drmMalloc(u.unique_len + 1); - if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL; + if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) + return NULL; u.unique[u.unique_len] = '\0'; return u.unique; @@ -799,7 +808,8 @@ int drmGetMagic(int fd, drm_magic_t * magic) drm_auth_t auth; *magic = 0; - if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) return -errno; + if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) + return -errno; *magic = auth.magic; return 0; } @@ -809,7 +819,8 @@ int drmAuthMagic(int fd, drm_magic_t magic) drm_auth_t auth; auth.magic = magic; - if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) return -errno; + if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) + return -errno; return 0; } @@ -873,8 +884,10 @@ int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type, map.handle = 0; map.type = type; map.flags = flags; - if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno; - if (handle) *handle = (drm_handle_t)map.handle; + if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) + return -errno; + if (handle) + *handle = (drm_handle_t)map.handle; return 0; } @@ -884,7 +897,8 @@ int drmRmMap(int fd, drm_handle_t handle) map.handle = (void *)handle; - if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno; + if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) + return -errno; return 0; } @@ -916,7 +930,8 @@ int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags, request.flags = flags; request.agp_start = agp_offset; - if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) return -errno; + if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) + return -errno; return request.count; } @@ -928,9 +943,11 @@ int drmMarkBufs(int fd, double low, double high) info.count = 0; info.list = NULL; - if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return -EINVAL; + if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) + return -EINVAL; - if (!info.count) return -EINVAL; + if (!info.count) + return -EINVAL; if (!(info.list = drmMalloc(info.count * sizeof(*info.list)))) return -ENOMEM; @@ -976,7 +993,8 @@ int drmFreeBufs(int fd, int count, int *list) request.count = count; request.list = list; - if (ioctl(fd, DRM_IOCTL_FREE_BUFS, &request)) return -errno; + if (ioctl(fd, DRM_IOCTL_FREE_BUFS, &request)) + return -errno; return 0; } @@ -1024,7 +1042,8 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address) { static unsigned long pagesize_mask = 0; - if (fd < 0) return -EINVAL; + if (fd < 0) + return -EINVAL; if (!pagesize_mask) pagesize_mask = getpagesize() - 1; @@ -1032,7 +1051,8 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address) size = (size + pagesize_mask) & ~pagesize_mask; *address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle); - if (*address == MAP_FAILED) return -errno; + if (*address == MAP_FAILED) + return -errno; return 0; } @@ -1062,7 +1082,8 @@ drmBufInfoPtr drmGetBufInfo(int fd) info.count = 0; info.list = NULL; - if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return NULL; + if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) + return NULL; if (info.count) { if (!(info.list = drmMalloc(info.count * sizeof(*info.list)))) @@ -1112,9 +1133,11 @@ drmBufMapPtr drmMapBufs(int fd) bufs.count = 0; bufs.list = NULL; bufs.virtual = NULL; - if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) return NULL; + if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) + return NULL; - if (!bufs.count) return NULL; + if (!bufs.count) + return NULL; if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list)))) return NULL; @@ -1269,20 +1292,25 @@ drm_context_t *drmGetReservedContextList(int fd, int *count) res.count = 0; res.contexts = NULL; - if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL; + if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) + return NULL; - if (!res.count) return NULL; + if (!res.count) + return NULL; - if (!(list = drmMalloc(res.count * sizeof(*list)))) return NULL; + if (!(list = drmMalloc(res.count * sizeof(*list)))) + return NULL; if (!(retval = drmMalloc(res.count * sizeof(*retval)))) { drmFree(list); return NULL; } res.contexts = list; - if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL; + if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) + return NULL; - for (i = 0; i < res.count; i++) retval[i] = list[i].handle; + for (i = 0; i < res.count; i++) + retval[i] = list[i].handle; drmFree(list); *count = res.count; @@ -1317,7 +1345,8 @@ int drmCreateContext(int fd, drm_context_t *handle) drm_ctx_t ctx; ctx.flags = 0; /* Modified with functions below */ - if (ioctl(fd, DRM_IOCTL_ADD_CTX, &ctx)) return -errno; + if (ioctl(fd, DRM_IOCTL_ADD_CTX, &ctx)) + return -errno; *handle = ctx.handle; return 0; } @@ -1327,7 +1356,8 @@ int drmSwitchToContext(int fd, drm_context_t context) drm_ctx_t ctx; ctx.handle = context; - if (ioctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx)) return -errno; + if (ioctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx)) + return -errno; return 0; } @@ -1343,9 +1373,12 @@ int drmSetContextFlags(int fd, drm_context_t context, drm_context_tFlags flags) */ ctx.handle = context; ctx.flags = 0; - if (flags & DRM_CONTEXT_PRESERVED) ctx.flags |= _DRM_CONTEXT_PRESERVED; - if (flags & DRM_CONTEXT_2DONLY) ctx.flags |= _DRM_CONTEXT_2DONLY; - if (ioctl(fd, DRM_IOCTL_MOD_CTX, &ctx)) return -errno; + if (flags & DRM_CONTEXT_PRESERVED) + ctx.flags |= _DRM_CONTEXT_PRESERVED; + if (flags & DRM_CONTEXT_2DONLY) + ctx.flags |= _DRM_CONTEXT_2DONLY; + if (ioctl(fd, DRM_IOCTL_MOD_CTX, &ctx)) + return -errno; return 0; } @@ -1355,10 +1388,13 @@ int drmGetContextFlags(int fd, drm_context_t context, drm_ctx_t ctx; ctx.handle = context; - if (ioctl(fd, DRM_IOCTL_GET_CTX, &ctx)) return -errno; + if (ioctl(fd, DRM_IOCTL_GET_CTX, &ctx)) + return -errno; *flags = 0; - if (ctx.flags & _DRM_CONTEXT_PRESERVED) *flags |= DRM_CONTEXT_PRESERVED; - if (ctx.flags & _DRM_CONTEXT_2DONLY) *flags |= DRM_CONTEXT_2DONLY; + if (ctx.flags & _DRM_CONTEXT_PRESERVED) + *flags |= DRM_CONTEXT_PRESERVED; + if (ctx.flags & _DRM_CONTEXT_2DONLY) + *flags |= DRM_CONTEXT_2DONLY; return 0; } @@ -1383,14 +1419,16 @@ int drmDestroyContext(int fd, drm_context_t handle) { drm_ctx_t ctx; ctx.handle = handle; - if (ioctl(fd, DRM_IOCTL_RM_CTX, &ctx)) return -errno; + if (ioctl(fd, DRM_IOCTL_RM_CTX, &ctx)) + return -errno; return 0; } int drmCreateDrawable(int fd, drm_drawable_t *handle) { drm_draw_t draw; - if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) return -errno; + if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) + return -errno; *handle = draw.handle; return 0; } @@ -1399,7 +1437,8 @@ int drmDestroyDrawable(int fd, drm_drawable_t handle) { drm_draw_t draw; draw.handle = handle; - if (ioctl(fd, DRM_IOCTL_RM_DRAW, &draw)) return -errno; + if (ioctl(fd, DRM_IOCTL_RM_DRAW, &draw)) + return -errno; return 0; } @@ -1414,7 +1453,8 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, update.num = num; update.data = (unsigned long long)(unsigned long)data; - if (ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update)) return -errno; + if (ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update)) + return -errno; return 0; } @@ -1433,7 +1473,8 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, */ int drmAgpAcquire(int fd) { - if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) + return -errno; return 0; } @@ -1450,7 +1491,8 @@ int drmAgpAcquire(int fd) */ int drmAgpRelease(int fd) { - if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) + return -errno; return 0; } @@ -1472,7 +1514,8 @@ int drmAgpEnable(int fd, unsigned long mode) drm_agp_mode_t m; m.mode = mode; - if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) + return -errno; return 0; } @@ -1502,8 +1545,10 @@ int drmAgpAlloc(int fd, unsigned long size, unsigned long type, b.size = size; b.handle = 0; b.type = type; - if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) return -errno; - if (address != 0UL) *address = b.physical; + if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) + return -errno; + if (address != 0UL) + *address = b.physical; *handle = b.handle; return 0; } @@ -1527,7 +1572,8 @@ int drmAgpFree(int fd, drm_handle_t handle) b.size = 0; b.handle = handle; - if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) + return -errno; return 0; } @@ -1551,7 +1597,8 @@ int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset) b.handle = handle; b.offset = offset; - if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) + return -errno; return 0; } @@ -1574,7 +1621,8 @@ int drmAgpUnbind(int fd, drm_handle_t handle) b.handle = handle; b.offset = 0; - if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) + return -errno; return 0; } @@ -1594,7 +1642,8 @@ int drmAgpVersionMajor(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return -errno; return i.agp_version_major; } @@ -1614,7 +1663,8 @@ int drmAgpVersionMinor(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return -errno; return i.agp_version_minor; } @@ -1634,7 +1684,8 @@ unsigned long drmAgpGetMode(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.mode; } @@ -1654,7 +1705,8 @@ unsigned long drmAgpBase(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.aperture_base; } @@ -1674,7 +1726,8 @@ unsigned long drmAgpSize(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.aperture_size; } @@ -1694,7 +1747,8 @@ unsigned long drmAgpMemoryUsed(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.memory_used; } @@ -1714,7 +1768,8 @@ unsigned long drmAgpMemoryAvail(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.memory_allowed; } @@ -1734,7 +1789,8 @@ unsigned int drmAgpVendorId(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.id_vendor; } @@ -1754,7 +1810,8 @@ unsigned int drmAgpDeviceId(int fd) { drm_agp_info_t i; - if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) + return 0; return i.id_device; } @@ -1765,7 +1822,8 @@ int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle) *handle = 0; sg.size = size; sg.handle = 0; - if (ioctl(fd, DRM_IOCTL_SG_ALLOC, &sg)) return -errno; + if (ioctl(fd, DRM_IOCTL_SG_ALLOC, &sg)) + return -errno; *handle = sg.handle; return 0; } @@ -1776,7 +1834,8 @@ int drmScatterGatherFree(int fd, drm_handle_t handle) sg.size = 0; sg.handle = handle; - if (ioctl(fd, DRM_IOCTL_SG_FREE, &sg)) return -errno; + if (ioctl(fd, DRM_IOCTL_SG_FREE, &sg)) + return -errno; return 0; } @@ -1806,12 +1865,21 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl) int drmError(int err, const char *label) { switch (err) { - case DRM_ERR_NO_DEVICE: fprintf(stderr, "%s: no device\n", label); break; - case DRM_ERR_NO_ACCESS: fprintf(stderr, "%s: no access\n", label); break; - case DRM_ERR_NOT_ROOT: fprintf(stderr, "%s: not root\n", label); break; - case DRM_ERR_INVALID: fprintf(stderr, "%s: invalid args\n", label);break; + case DRM_ERR_NO_DEVICE: + fprintf(stderr, "%s: no device\n", label); + break; + case DRM_ERR_NO_ACCESS: + fprintf(stderr, "%s: no access\n", label); + break; + case DRM_ERR_NOT_ROOT: + fprintf(stderr, "%s: not root\n", label); + break; + case DRM_ERR_INVALID: + fprintf(stderr, "%s: invalid args\n", label); + break; default: - if (err < 0) err = -err; + if (err < 0) + err = -err; fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) ); break; } @@ -1837,7 +1905,8 @@ int drmCtlInstHandler(int fd, int irq) ctl.func = DRM_INST_HANDLER; ctl.irq = irq; - if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno; + if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) + return -errno; return 0; } @@ -1859,7 +1928,8 @@ int drmCtlUninstHandler(int fd) ctl.func = DRM_UNINST_HANDLER; ctl.irq = 0; - if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno; + if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) + return -errno; return 0; } @@ -1875,7 +1945,8 @@ int drmFinish(int fd, int context, drmLockFlags flags) if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL; if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES; if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES; - if (ioctl(fd, DRM_IOCTL_FINISH, &lock)) return -errno; + if (ioctl(fd, DRM_IOCTL_FINISH, &lock)) + return -errno; return 0; } @@ -1900,7 +1971,8 @@ int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum) p.busnum = busnum; p.devnum = devnum; p.funcnum = funcnum; - if (ioctl(fd, DRM_IOCTL_IRQ_BUSID, &p)) return -errno; + if (ioctl(fd, DRM_IOCTL_IRQ_BUSID, &p)) + return -errno; return p.irq; } @@ -1927,7 +1999,8 @@ void *drmGetContextTag(int fd, drm_context_t context) drmHashEntry *entry = drmGetEntry(fd); void *value; - if (drmHashLookup(entry->tagTable, context, &value)) return NULL; + if (drmHashLookup(entry->tagTable, context, &value)) + return NULL; return value; } @@ -1940,7 +2013,8 @@ int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, map.ctx_id = ctx_id; map.handle = (void *)handle; - if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) return -errno; + if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) + return -errno; return 0; } @@ -1951,8 +2025,10 @@ int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, map.ctx_id = ctx_id; - if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno; - if (handle) *handle = (drm_handle_t)map.handle; + if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) + return -errno; + if (handle) + *handle = (drm_handle_t)map.handle; return 0; } @@ -1964,7 +2040,8 @@ int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size, drm_map_t map; map.offset = idx; - if (ioctl(fd, DRM_IOCTL_GET_MAP, &map)) return -errno; + if (ioctl(fd, DRM_IOCTL_GET_MAP, &map)) + return -errno; *offset = map.offset; *size = map.size; *type = map.type; @@ -1980,7 +2057,8 @@ int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid, drm_client_t client; client.idx = idx; - if (ioctl(fd, DRM_IOCTL_GET_CLIENT, &client)) return -errno; + if (ioctl(fd, DRM_IOCTL_GET_CLIENT, &client)) + return -errno; *auth = client.auth; *pid = client.pid; *uid = client.uid; @@ -1994,7 +2072,8 @@ int drmGetStats(int fd, drmStatsT *stats) drm_stats_t s; int i; - if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) return -errno; + if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) + return -errno; stats->count = 0; memset(stats, 0, sizeof(*stats)); @@ -2296,7 +2375,7 @@ int drmFenceCreate(int fd, unsigned flags, int class, unsigned type, int drmFenceBuffers(int fd, unsigned flags, drmFence *fence) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.flags = flags; arg.op = drm_fence_buffers; @@ -2313,7 +2392,7 @@ int drmFenceBuffers(int fd, unsigned flags, drmFence *fence) int drmFenceDestroy(int fd, const drmFence *fence) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.handle = fence->handle; arg.op = drm_fence_destroy; @@ -2325,7 +2404,7 @@ int drmFenceDestroy(int fd, const drmFence *fence) int drmFenceReference(int fd, unsigned handle, drmFence *fence) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.handle = handle; arg.op = drm_fence_reference; @@ -2342,7 +2421,7 @@ int drmFenceReference(int fd, unsigned handle, drmFence *fence) int drmFenceUnreference(int fd, const drmFence *fence) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.handle = fence->handle; arg.op = drm_fence_unreference; @@ -2354,7 +2433,7 @@ int drmFenceUnreference(int fd, const drmFence *fence) int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.handle = fence->handle; arg.type = flush_type; @@ -2369,8 +2448,8 @@ int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type) int drmFenceUpdate(int fd, drmFence *fence) { - drm_fence_arg_t arg; - + drm_fence_arg_t arg; + memset(&arg, 0, sizeof(arg)); arg.handle = fence->handle; arg.op = drm_fence_signaled; @@ -2385,13 +2464,9 @@ int drmFenceUpdate(int fd, drmFence *fence) int drmFenceSignaled(int fd, drmFence *fence, unsigned fenceType, int *signaled) { - int - ret; - if ((fence->flags & DRM_FENCE_FLAG_SHAREABLE) || ((fenceType & fence->signaled) != fenceType)) { - - ret = drmFenceFlush(fd, fence, fenceType); + int ret = drmFenceFlush(fd, fence, fenceType); if (ret) return ret; } @@ -2503,7 +2578,7 @@ void drmBOFreeList(drmBOList *list) DRMLISTDEL(l); node = DRMLISTENTRY(drmBONode, l, head); free(node); - l = list->free.next; + l = list->list.next; list->numCurrent--; list->numOnList--; } @@ -2518,8 +2593,8 @@ void drmBOFreeList(drmBOList *list) } } -int drmBOResetList(drmBOList *list) { - +int drmBOResetList(drmBOList *list) +{ drmMMListHead *l; int ret; @@ -2528,7 +2603,7 @@ int drmBOResetList(drmBOList *list) { return ret; l = list->list.next; - while(l != &list->list) { + while (l != &list->list) { DRMLISTDEL(l); DRMLISTADD(l, &list->free); list->numOnList--; @@ -2551,7 +2626,8 @@ static drmBONode *drmAddListItem(drmBOList *list, drmBO *item, return NULL; } list->numCurrent++; - } else { + } + else { DRMLISTDEL(l); node = DRMLISTENTRY(drmBONode, l, head); } @@ -2588,7 +2664,6 @@ drmBO *drmBOListBuf(void *iterator) drmBONode *node; drmMMListHead *l = (drmMMListHead *) iterator; node = DRMLISTENTRY(drmBONode, l, head); - return node->buf; } @@ -2603,8 +2678,7 @@ int drmBOCreateList(int numTarget, drmBOList *list) return drmAdjustListNodes(list); } -static void drmBOCopyReply(const drm_bo_arg_reply_t *rep, - drmBO *buf) +static void drmBOCopyReply(const drm_bo_arg_reply_t *rep, drmBO *buf) { buf->handle = rep->handle; buf->flags = rep->flags; @@ -2617,8 +2691,6 @@ static void drmBOCopyReply(const drm_bo_arg_reply_t *rep, buf->replyFlags = rep->rep_flags; buf->pageAlignment = rep->page_alignment; } - - int drmBOCreate(int fd, unsigned long start, unsigned long size, unsigned pageAlignment, void *user_buffer, drm_bo_type_t type, @@ -2708,7 +2780,6 @@ int drmBODestroy(int fd, drmBO *buf) int drmBOReference(int fd, unsigned handle, drmBO *buf) { - drm_bo_arg_t arg; drm_bo_arg_request_t *req = &arg.d.req; drm_bo_arg_reply_t *rep = &arg.d.rep; @@ -2740,7 +2811,6 @@ int drmBOUnReference(int fd, drmBO *buf) drm_bo_arg_t 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)) { (void) munmap(buf->mapVirtual, buf->start + buf->size); @@ -2774,7 +2844,6 @@ int drmBOUnReference(int fd, drmBO *buf) int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint, void **address) { - drm_bo_arg_t arg; drm_bo_arg_request_t *req = &arg.d.req; drm_bo_arg_reply_t *rep = &arg.d.rep; @@ -2814,7 +2883,7 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint, } while (ret != 0 && errno == EAGAIN); if (ret) - return ret; + return -errno; if (!arg.handled) return -EFAULT; if (rep->ret) @@ -2834,7 +2903,6 @@ int drmBOUnmap(int fd, drmBO *buf) drm_bo_arg_request_t *req = &arg.d.req; drm_bo_arg_reply_t *rep = &arg.d.rep; - memset(&arg, 0, sizeof(arg)); req->handle = buf->handle; req->op = drm_bo_unmap; @@ -2868,9 +2936,9 @@ int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask, do{ ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg); } while (ret && errno == EAGAIN); - + if (ret) - return ret; + return -errno; if (!arg.handled) return -EFAULT; if (rep->ret) @@ -2892,12 +2960,12 @@ int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle) req->handle = buf->handle; req->mask = flags; req->arg_handle = fenceHandle; - req->op = drm_bo_validate; + req->op = drm_bo_fence; ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg); - + if (ret) - return ret; + return -errno; if (!arg.handled) return -EFAULT; if (rep->ret) @@ -2917,9 +2985,9 @@ int drmBOInfo(int fd, drmBO *buf) req->op = drm_bo_info; ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg); - + if (ret) - return ret; + return -errno; if (!arg.handled) return -EFAULT; if (rep->ret) @@ -2947,7 +3015,7 @@ int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint) } while (ret && errno == EAGAIN); if (ret) - return ret; + return -errno; if (!arg.handled) return -EFAULT; if (rep->ret) @@ -2963,7 +3031,8 @@ int drmBOBusy(int fd, drmBO *buf, int *busy) !(buf->replyFlags & DRM_BO_REP_BUSY)) { *busy = 0; return 0; - } else { + } + else { int ret = drmBOInfo(fd, buf); if (ret) return ret; @@ -2999,7 +3068,8 @@ int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags, *newItem = 1; cur->arg0 = flags; cur->arg1 = mask; - } else { + } + else { unsigned memMask = (cur->arg1 | mask) & DRM_BO_MASK_MEM; unsigned memFlags = cur->arg0 & flags & memMask; @@ -3031,134 +3101,129 @@ int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags, int drmBOValidateList(int fd, drmBOList *list) { - - drmBONode *node; - drmMMListHead *l; - drm_bo_arg_t *arg, *first; - drm_bo_arg_request_t *req; - drm_bo_arg_reply_t *rep; - drm_u64_t *prevNext = NULL; - drmBO *buf; - int ret; - - first = NULL; - - for (l = list->list.next; l != &list->list; l = l->next) { - node = DRMLISTENTRY(drmBONode, l, head); - - arg = &node->bo_arg; - req = &arg->d.req; - - if (!first) - first = arg; - - if (prevNext) - *prevNext = (unsigned long) arg; - - memset(arg, 0, sizeof(*arg)); - prevNext = &arg->next; - req->handle = node->buf->handle; - req->op = drm_bo_validate; - req->mask = node->arg0; - req->hint = 0; - req->arg_handle = node->arg1; - } - - if (!first) - return 0; + drmBONode *node; + drmMMListHead *l; + drm_bo_arg_t *arg, *first; + drm_bo_arg_request_t *req; + drm_bo_arg_reply_t *rep; + drm_u64_t *prevNext = NULL; + drmBO *buf; + int ret; + + first = NULL; - do{ - ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first); - } while (ret && errno == EAGAIN); + for (l = list->list.next; l != &list->list; l = l->next) { + node = DRMLISTENTRY(drmBONode, l, head); + + arg = &node->bo_arg; + req = &arg->d.req; + if (!first) + first = arg; - if (ret) - return -errno; + if (prevNext) + *prevNext = (unsigned long) arg; + + memset(arg, 0, sizeof(*arg)); + prevNext = &arg->next; + req->handle = node->buf->handle; + req->op = drm_bo_validate; + req->mask = node->arg0; + req->hint = 0; + req->arg_handle = node->arg1; + } - for (l = list->list.next; l != &list->list; l = l->next) { - node = DRMLISTENTRY(drmBONode, l, head); - arg = &node->bo_arg; - rep = &arg->d.rep; - - if (!arg->handled) { - drmMsg("Unhandled request\n"); - return -EFAULT; - } - if (rep->ret) - return rep->ret; - - buf = node->buf; - drmBOCopyReply(rep, buf); - } - - return 0; + if (!first) + return 0; + + do { + ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first); + } while (ret && errno == EAGAIN); + + if (ret) + return -errno; + + for (l = list->list.next; l != &list->list; l = l->next) { + node = DRMLISTENTRY(drmBONode, l, head); + arg = &node->bo_arg; + rep = &arg->d.rep; + + if (!arg->handled) { + drmMsg("Unhandled request\n"); + return -EFAULT; + } + if (rep->ret) + return rep->ret; + + buf = node->buf; + drmBOCopyReply(rep, buf); + } + + return 0; } int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle) { - - drmBONode *node; - drmMMListHead *l; - drm_bo_arg_t *arg, *first; - drm_bo_arg_request_t *req; - drm_bo_arg_reply_t *rep; - drm_u64_t *prevNext = NULL; - drmBO *buf; - unsigned fence_flags; - int ret; - - first = NULL; - - for (l = list->list.next; l != &list->list; l = l->next) { - node = DRMLISTENTRY(drmBONode, l, head); - - arg = &node->bo_arg; - req = &arg->d.req; - - if (!first) - first = arg; - - if (prevNext) - *prevNext = (unsigned long) arg; - - memset(arg, 0, sizeof(*arg)); - prevNext = &arg->next; - req->handle = node->buf->handle; - req->op = drm_bo_fence; - req->mask = node->arg0; - req->arg_handle = fenceHandle; - } - - if (!first) - return 0; + drmBONode *node; + drmMMListHead *l; + drm_bo_arg_t *arg, *first; + drm_bo_arg_request_t *req; + drm_bo_arg_reply_t *rep; + drm_u64_t *prevNext = NULL; + drmBO *buf; + unsigned fence_flags; + int ret; + + first = NULL; + + for (l = list->list.next; l != &list->list; l = l->next) { + node = DRMLISTENTRY(drmBONode, l, head); + + arg = &node->bo_arg; + req = &arg->d.req; - ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first); + if (!first) + first = arg; - if (ret) - return -errno; + if (prevNext) + *prevNext = (unsigned long) arg; + + memset(arg, 0, sizeof(*arg)); + prevNext = &arg->next; + req->handle = node->buf->handle; + req->op = drm_bo_fence; + req->mask = node->arg0; + req->arg_handle = fenceHandle; + } - for (l = list->list.next; l != &list->list; l = l->next) { - node = DRMLISTENTRY(drmBONode, l, head); + if (!first) + return 0; - arg = &node->bo_arg; - rep = &arg->d.rep; - - if (!arg->handled) - return -EFAULT; - if (rep->ret) - return rep->ret; - drmBOCopyReply(rep, node->buf); - } + ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first); + + if (ret) + return -errno; + + for (l = list->list.next; l != &list->list; l = l->next) { + node = DRMLISTENTRY(drmBONode, l, head); + arg = &node->bo_arg; + rep = &arg->d.rep; + if (!arg->handled) + return -EFAULT; + if (rep->ret) + return rep->ret; + drmBOCopyReply(rep, node->buf); + } - return 0; + return 0; } int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize, unsigned memType) { drm_mm_init_arg_t arg; - + memset(&arg, 0, sizeof(arg)); arg.req.op = mm_init; arg.req.p_offset = pOffset; @@ -3167,7 +3232,6 @@ int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize, if (ioctl(fd, DRM_IOCTL_MM_INIT, &arg)) return -errno; - return 0; } @@ -3175,14 +3239,12 @@ int drmMMTakedown(int fd, unsigned memType) { drm_mm_init_arg_t arg; - memset(&arg, 0, sizeof(arg)); arg.req.op = mm_takedown; arg.req.mem_type = memType; if (ioctl(fd, DRM_IOCTL_MM_INIT, &arg)) return -errno; - return 0; } @@ -3198,8 +3260,7 @@ int drmMMLock(int fd, unsigned memType) do{ ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg); } while (ret && errno == EAGAIN); - - return ret; + return -errno; } int drmMMUnlock(int fd, unsigned memType) @@ -3214,15 +3275,14 @@ int drmMMUnlock(int fd, unsigned memType) do{ ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg); } while (ret && errno == EAGAIN); - - return ret; + return -errno; } #define DRM_MAX_FDS 16 static struct { - char *BusID; - int fd; - int refcount; + char *BusID; + int fd; + int refcount; } connection[DRM_MAX_FDS]; static int nr_fds = 0; @@ -3231,50 +3291,50 @@ int drmOpenOnce(void *unused, const char *BusID, int *newlyopened) { - int i; - int fd; + int i; + int fd; - for (i = 0; i < nr_fds; i++) - if (strcmp(BusID, connection[i].BusID) == 0) { - connection[i].refcount++; - *newlyopened = 0; - return connection[i].fd; - } - - fd = drmOpen(unused, BusID); - if (fd <= 0 || nr_fds == DRM_MAX_FDS) - return fd; + for (i = 0; i < nr_fds; i++) + if (strcmp(BusID, connection[i].BusID) == 0) { + connection[i].refcount++; + *newlyopened = 0; + return connection[i].fd; + } + + fd = drmOpen(unused, BusID); + if (fd <= 0 || nr_fds == DRM_MAX_FDS) + return fd; - connection[nr_fds].BusID = strdup(BusID); - connection[nr_fds].fd = fd; - connection[nr_fds].refcount = 1; - *newlyopened = 1; + connection[nr_fds].BusID = strdup(BusID); + connection[nr_fds].fd = fd; + connection[nr_fds].refcount = 1; + *newlyopened = 1; - if (0) - fprintf(stderr, "saved connection %d for %s %d\n", - nr_fds, connection[nr_fds].BusID, - strcmp(BusID, connection[nr_fds].BusID)); + if (0) + fprintf(stderr, "saved connection %d for %s %d\n", + nr_fds, connection[nr_fds].BusID, + strcmp(BusID, connection[nr_fds].BusID)); - nr_fds++; + nr_fds++; - return fd; + return fd; } void drmCloseOnce(int fd) { - int i; + int i; - for (i = 0; i < nr_fds; i++) { - if (fd == connection[i].fd) { - if (--connection[i].refcount == 0) { - drmClose(connection[i].fd); - free(connection[i].BusID); + for (i = 0; i < nr_fds; i++) { + if (fd == connection[i].fd) { + if (--connection[i].refcount == 0) { + drmClose(connection[i].fd); + free(connection[i].BusID); - if (i < --nr_fds) - connection[i] = connection[nr_fds]; + if (i < --nr_fds) + connection[i] = connection[nr_fds]; - return; - } - } - } + return; + } + } + } } diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h index e84b23d7..d4260cc9 100644 --- a/libdrm/xf86drm.h +++ b/libdrm/xf86drm.h @@ -31,8 +31,6 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.26 2003/08/16 19:26:37 dawes Exp $ */ - #ifndef _XF86DRM_H_ #define _XF86DRM_H_ diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c index a1908d09..d1ade063 100644 --- a/libdrm/xf86drmHash.c +++ b/libdrm/xf86drmHash.c @@ -25,8 +25,6 @@ * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.4 2001/03/21 18:08:54 dawes Exp $ - * * DESCRIPTION * * This file contains a straightforward implementation of a fixed-sized @@ -70,25 +68,14 @@ * */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif +#include <stdio.h> +#include <stdlib.h> #define HASH_MAIN 0 -#if HASH_MAIN -# include <stdio.h> -# include <stdlib.h> -#else +#if !HASH_MAIN # include "drm.h" # include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif #endif #define HASH_MAGIC 0xdeadbeef diff --git a/libdrm/xf86drmRandom.c b/libdrm/xf86drmRandom.c index 3f5bf611..61ffb078 100644 --- a/libdrm/xf86drmRandom.c +++ b/libdrm/xf86drmRandom.c @@ -25,8 +25,6 @@ * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 2000/06/17 00:03:34 martin Exp $ - * * DESCRIPTION * * This file contains a simple, straightforward implementation of the Park @@ -73,25 +71,14 @@ * */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif +#include <stdio.h> +#include <stdlib.h> #define RANDOM_MAIN 0 -#if RANDOM_MAIN -# include <stdio.h> -# include <stdlib.h> -#else +#if !RANDOM_MAIN # include "drm.h" # include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif #endif #define RANDOM_MAGIC 0xfeedbeef diff --git a/libdrm/xf86drmSL.c b/libdrm/xf86drmSL.c index ab2cc098..ce60648d 100644 --- a/libdrm/xf86drmSL.c +++ b/libdrm/xf86drmSL.c @@ -25,8 +25,6 @@ * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.3 2000/06/17 00:03:34 martin Exp $ - * * DESCRIPTION * * This file contains a straightforward skip list implementation.n @@ -40,26 +38,16 @@ * */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif +#include <stdio.h> +#include <stdlib.h> #define SL_MAIN 0 -#if SL_MAIN -# include <stdio.h> -# include <stdlib.h> -# include <sys/time.h> -#else +#if !SL_MAIN # include "drm.h" # include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif +#else +# include <sys/time.h> #endif #define SL_LIST_MAGIC 0xfacade00LU diff --git a/libdrm/xf86mm.h b/libdrm/xf86mm.h index bd0d2812..b3822d4d 100644 --- a/libdrm/xf86mm.h +++ b/libdrm/xf86mm.h @@ -60,7 +60,7 @@ typedef struct _drmMMListHead (__item)->next = (__item); \ } while (0) -#define DRMLISTADD(__item, __list) \ +#define DRMLISTADD(__item, __list) \ do { \ (__item)->prev = (__list); \ (__item)->next = (__list)->next; \ @@ -93,16 +93,18 @@ typedef struct _drmMMListHead #define DRMLISTENTRY(__type, __item, __field) \ ((__type *)(((char *) (__item)) - offsetof(__type, __field))) -typedef struct _drmFence{ - unsigned handle; - int class; - unsigned type; - unsigned flags; - unsigned signaled; - unsigned pad[4]; /* for future expansion */ +typedef struct _drmFence +{ + unsigned handle; + int class; + unsigned type; + unsigned flags; + unsigned signaled; + unsigned pad[4]; /* for future expansion */ } drmFence; -typedef struct _drmBO{ +typedef struct _drmBO +{ drm_bo_type_t type; unsigned handle; drm_u64_t mapHandle; @@ -121,8 +123,8 @@ typedef struct _drmBO{ unsigned pad[8]; /* for future expansion */ } drmBO; - -typedef struct _drmBONode { +typedef struct _drmBONode +{ drmMMListHead head; drmBO *buf; drm_bo_arg_t bo_arg; @@ -138,22 +140,24 @@ typedef struct _drmBOList { drmMMListHead free; } drmBOList; -/* Fencing */ - -extern int drmFenceCreate(int fd, unsigned flags, int class, - unsigned type, - drmFence *fence); -extern int drmFenceDestroy(int fd, const drmFence *fence); -extern int drmFenceReference(int fd, unsigned handle, drmFence *fence); -extern int drmFenceUnreference(int fd, const drmFence *fence); -extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type); -extern int drmFenceSignaled(int fd, drmFence *fence, - unsigned fenceType, int *signaled); -extern int drmFenceWait(int fd, unsigned flags, drmFence *fence, - unsigned flush_type); -extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence, - unsigned emit_type); -extern int drmFenceBuffers(int fd, unsigned flags, drmFence *fence); + +/* + * Fence functions. + */ + +extern int drmFenceCreate(int fd, unsigned flags, int class, + unsigned type, drmFence *fence); +extern int drmFenceDestroy(int fd, const drmFence *fence); +extern int drmFenceReference(int fd, unsigned handle, drmFence *fence); +extern int drmFenceUnreference(int fd, const drmFence *fence); +extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type); +extern int drmFenceSignaled(int fd, drmFence *fence, + unsigned fenceType, int *signaled); +extern int drmFenceWait(int fd, unsigned flags, drmFence *fence, + unsigned flush_type); +extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence, + unsigned emit_type); +extern int drmFenceBuffers(int fd, unsigned flags, drmFence *fence); /* |