Lines Matching refs:buf
14 mem_alloc_bo(struct vugbm_buffer *buf) in mem_alloc_bo() argument
16 buf->mmap = g_malloc(buf->width * buf->height * 4); in mem_alloc_bo()
17 buf->stride = buf->width * 4; in mem_alloc_bo()
22 mem_free_bo(struct vugbm_buffer *buf) in mem_free_bo() argument
24 g_free(buf->mmap); in mem_free_bo()
28 mem_map_bo(struct vugbm_buffer *buf) in mem_map_bo() argument
30 return buf->mmap != NULL; in mem_map_bo()
34 mem_unmap_bo(struct vugbm_buffer *buf) in mem_unmap_bo() argument
54 udmabuf_get_size(struct vugbm_buffer *buf) in udmabuf_get_size() argument
56 return ROUND_UP(buf->width * buf->height * 4, qemu_real_host_page_size()); in udmabuf_get_size()
60 udmabuf_alloc_bo(struct vugbm_buffer *buf) in udmabuf_alloc_bo() argument
64 buf->memfd = memfd_create("udmabuf-bo", MFD_ALLOW_SEALING); in udmabuf_alloc_bo()
65 if (buf->memfd < 0) { in udmabuf_alloc_bo()
69 ret = ftruncate(buf->memfd, udmabuf_get_size(buf)); in udmabuf_alloc_bo()
71 close(buf->memfd); in udmabuf_alloc_bo()
75 ret = fcntl(buf->memfd, F_ADD_SEALS, F_SEAL_SHRINK); in udmabuf_alloc_bo()
77 close(buf->memfd); in udmabuf_alloc_bo()
81 buf->stride = buf->width * 4; in udmabuf_alloc_bo()
87 udmabuf_free_bo(struct vugbm_buffer *buf) in udmabuf_free_bo() argument
89 close(buf->memfd); in udmabuf_free_bo()
93 udmabuf_map_bo(struct vugbm_buffer *buf) in udmabuf_map_bo() argument
95 buf->mmap = mmap(NULL, udmabuf_get_size(buf), in udmabuf_map_bo()
96 PROT_READ | PROT_WRITE, MAP_SHARED, buf->memfd, 0); in udmabuf_map_bo()
97 if (buf->mmap == MAP_FAILED) { in udmabuf_map_bo()
105 udmabuf_get_fd(struct vugbm_buffer *buf, int *fd) in udmabuf_get_fd() argument
108 .memfd = buf->memfd, in udmabuf_get_fd()
110 .size = udmabuf_get_size(buf), in udmabuf_get_fd()
113 *fd = ioctl(buf->dev->fd, UDMABUF_CREATE, &create); in udmabuf_get_fd()
119 udmabuf_unmap_bo(struct vugbm_buffer *buf) in udmabuf_unmap_bo() argument
121 munmap(buf->mmap, udmabuf_get_size(buf)); in udmabuf_unmap_bo()
133 alloc_bo(struct vugbm_buffer *buf) in alloc_bo() argument
135 struct gbm_device *dev = buf->dev->dev; in alloc_bo()
137 assert(!buf->bo); in alloc_bo()
139 buf->bo = gbm_bo_create(dev, buf->width, buf->height, in alloc_bo()
140 buf->format, in alloc_bo()
143 if (buf->bo) { in alloc_bo()
144 buf->stride = gbm_bo_get_stride(buf->bo); in alloc_bo()
152 free_bo(struct vugbm_buffer *buf) in free_bo() argument
154 gbm_bo_destroy(buf->bo); in free_bo()
158 map_bo(struct vugbm_buffer *buf) in map_bo() argument
162 buf->mmap = gbm_bo_map(buf->bo, 0, 0, buf->width, buf->height, in map_bo()
164 &buf->mmap_data); in map_bo()
166 assert(stride == buf->stride); in map_bo()
168 return buf->mmap != NULL; in map_bo()
172 unmap_bo(struct vugbm_buffer *buf) in unmap_bo() argument
174 gbm_bo_unmap(buf->bo, buf->mmap_data); in unmap_bo()
178 get_fd(struct vugbm_buffer *buf, int *fd) in get_fd() argument
180 *fd = gbm_bo_get_fd(buf->bo); in get_fd()
250 vugbm_buffer_map(struct vugbm_buffer *buf) in vugbm_buffer_map() argument
252 struct vugbm_device *dev = buf->dev; in vugbm_buffer_map()
254 return dev->map_bo(buf); in vugbm_buffer_map()
258 vugbm_buffer_unmap(struct vugbm_buffer *buf) in vugbm_buffer_unmap() argument
260 struct vugbm_device *dev = buf->dev; in vugbm_buffer_unmap()
262 dev->unmap_bo(buf); in vugbm_buffer_unmap()