X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=xf86drm.c;h=d900b4bd7340dc9cfda615f807b7eb28e046423c;hb=0599f2fd6aea0421a91d9297dcd454aa416dfbaa;hp=4791a053155b052a1e09be8d856057e62de944b2;hpb=1eb2860b4bd0306dddc5b2f2dc7403aa65c5e476;p=platform%2Fupstream%2Flibdrm.git diff --git a/xf86drm.c b/xf86drm.c index 4791a05..d900b4b 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -48,7 +48,6 @@ #include #define stat_t struct stat #include -#include #include #include @@ -58,6 +57,7 @@ #endif #include "xf86drm.h" +#include "libdrm.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #define DRM_MAJOR 145 @@ -104,12 +104,16 @@ void drmSetServerInfo(drmServerInfoPtr info) * This function is a wrapper around vfprintf(). */ -static int drmDebugPrint(const char *format, va_list ap) +static int DRM_PRINTFLIKE(1, 0) +drmDebugPrint(const char *format, va_list ap) { return vfprintf(stderr, format, ap); } -static int (*drm_debug_print)(const char *format, va_list ap) = drmDebugPrint; +typedef int DRM_PRINTFLIKE(1, 0) (*debug_msg_func_t)(const char *format, + va_list ap); + +static debug_msg_func_t drm_debug_print = drmDebugPrint; void drmMsg(const char *format, ...) @@ -129,7 +133,7 @@ drmMsg(const char *format, ...) } void -drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char *format, va_list ap)) +drmSetDebugMsgFunction(debug_msg_func_t debug_msg_ptr) { drm_debug_print = debug_msg_ptr; } @@ -499,7 +503,7 @@ static int drmOpenByBusid(const char *busid) sv.drm_di_minor = 1; sv.drm_dd_major = -1; /* Don't care */ sv.drm_dd_minor = -1; /* Don't care */ - drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n",fd); + drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n"); drmSetInterfaceVersion(fd, &sv); } buf = drmGetBusid(fd); @@ -537,19 +541,6 @@ static int drmOpenByName(const char *name) int fd; drmVersionPtr version; 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; - } - } - } /* * Open the first minor number that matches the driver name and isn't @@ -823,6 +814,13 @@ int drmGetCap(int fd, uint64_t capability, uint64_t *value) return 0; } +int drmSetClientCap(int fd, uint64_t capability, uint64_t value) +{ + struct drm_set_client_cap cap = { capability, value }; + + return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap); +} + /** * Free the bus ID information. * @@ -1139,7 +1137,7 @@ 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); + *address = drm_mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle); if (*address == MAP_FAILED) return -errno; return 0; @@ -1159,7 +1157,7 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address) */ int drmUnmap(drmAddress address, drmSize size) { - return munmap(address, size); + return drm_munmap(address, size); } drmBufInfoPtr drmGetBufInfo(int fd) @@ -1266,7 +1264,7 @@ int drmUnmapBufs(drmBufMapPtr bufs) int i; for (i = 0; i < bufs->count; i++) { - munmap(bufs->list[i].address, bufs->list[i].total); + drm_munmap(bufs->list[i].address, bufs->list[i].total); } drmFree(bufs->list);