diff options
author | Chia-I Wu <olvaffe@gmail.com> | 2010-10-08 23:08:34 -0400 |
---|---|---|
committer | Chia-I Wu <olvaffe@gmail.com> | 2010-12-09 20:01:34 -0500 |
commit | bf21df37c65a959269180ebc215447e2e6bd38fc (patch) | |
tree | 6594b9d5f505033622957caca3280819350dcf0f /src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | |
parent | 17935c0191b4c5adb68dd59df23282caef869875 (diff) |
android: Use __mmap2 in winsys/svga.
Diffstat (limited to 'src/gallium/winsys/svga/drm/vmw_screen_ioctl.c')
-rw-r--r-- | src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c index d92ba389d3..847f2c789b 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c @@ -46,6 +46,24 @@ #include <errno.h> #include <unistd.h> +#ifdef PIPE_OS_ANDROID +extern void* __mmap2(void*, size_t, int, int, int, size_t); + +#define MMAP2_SHIFT 12 +static INLINE void* vmw_mmap(void *addr, size_t size, int prot, int flags, int fd, unsigned long long offset) +{ + if ( offset & ((1UL << MMAP2_SHIFT)-1) ) { + errno = EINVAL; + return MAP_FAILED; + } + + return __mmap2(addr, size, prot, flags, fd, (size_t)(offset >> MMAP2_SHIFT)); +} + +#else +#define vmw_mmap(addr, size, prot, flags, fd, offset) mmap(addr, size, prot, flags, fd, offset) +#endif + struct vmw_region { SVGAGuestPtr ptr; @@ -106,7 +124,7 @@ vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws, VMW_FUNC; - map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, + map = vmw_mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, vws->ioctl.drm_fd, fifo_offset); if (map == MAP_FAILED) { @@ -388,7 +406,7 @@ vmw_ioctl_region_map(struct vmw_region *region) region->ptr.gmrId, region->ptr.offset); if (region->data == NULL) { - map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED, + map = vmw_mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED, region->drm_fd, region->map_handle); if (map == MAP_FAILED) { debug_printf("%s: Map failed.\n", __FUNCTION__); |