diff options
author | Eric Anholt <[email protected]> | 2015-03-23 17:17:17 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-03-24 10:39:12 -0700 |
commit | 25d60763d9c2767c279f28ac2a7eddcd245f4259 (patch) | |
tree | 94926b963e3f9254cb8fc9e5ed80f6b41725d3f4 /src/gallium/drivers/vc4 | |
parent | af3d7471943d54e692f2dd7448321a4f96e56ed2 (diff) |
vc4: Use our device-specific ioctls for create/mmap.
They don't do anything special for us, but I've been told by kernel
maintainers that relying on dumb for my acceleration-capable buffers
is not OK.
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_bufmgr.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 007786481e8..4bb2c711e16 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -65,6 +65,8 @@ struct vc4_bo * vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) { struct vc4_bo *bo; + int ret; + size = align(size, 4096); bo = vc4_bo_from_cache(screen, size, name); @@ -81,22 +83,31 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) bo->name = name; bo->private = true; - struct drm_mode_create_dumb create; - memset(&create, 0, sizeof(create)); + if (!using_vc4_simulator) { + struct drm_vc4_create_bo create; + memset(&create, 0, sizeof(create)); + + create.size = size; + + ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_CREATE_BO, &create); + bo->handle = create.handle; + } else { + struct drm_mode_create_dumb create; + memset(&create, 0, sizeof(create)); - create.width = 128; - create.bpp = 8; - create.height = (size + 127) / 128; + create.width = 128; + create.bpp = 8; + create.height = (size + 127) / 128; - int ret = drmIoctl(screen->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create); + ret = drmIoctl(screen->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create); + bo->handle = create.handle; + assert(create.size >= size); + } if (ret != 0) { fprintf(stderr, "create ioctl failure\n"); abort(); } - bo->handle = create.handle; - assert(create.size >= size); - return bo; } @@ -371,25 +382,35 @@ vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns) void * vc4_bo_map_unsynchronized(struct vc4_bo *bo) { + uint64_t offset; int ret; if (bo->map) return bo->map; - struct drm_mode_map_dumb map; - memset(&map, 0, sizeof(map)); - map.handle = bo->handle; - ret = drmIoctl(bo->screen->fd, DRM_IOCTL_MODE_MAP_DUMB, &map); + if (!using_vc4_simulator) { + struct drm_vc4_mmap_bo map; + memset(&map, 0, sizeof(map)); + map.handle = bo->handle; + ret = drmIoctl(bo->screen->fd, DRM_IOCTL_VC4_MMAP_BO, &map); + offset = map.offset; + } else { + struct drm_mode_map_dumb map; + memset(&map, 0, sizeof(map)); + map.handle = bo->handle; + ret = drmIoctl(bo->screen->fd, DRM_IOCTL_MODE_MAP_DUMB, &map); + offset = map.offset; + } if (ret != 0) { fprintf(stderr, "map ioctl failure\n"); abort(); } bo->map = mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, - bo->screen->fd, map.offset); + bo->screen->fd, offset); if (bo->map == MAP_FAILED) { fprintf(stderr, "mmap of bo %d (offset 0x%016llx, size %d) failed\n", - bo->handle, (long long)map.offset, bo->size); + bo->handle, (long long)offset, bo->size); abort(); } |