Lines Matching refs:bo
167 struct omap_bo *bo = NULL; in lookup_bo() local
168 if (!drmHashLookup(dev->handle_table, handle, (void **)&bo)) { in lookup_bo()
170 bo = omap_bo_ref(bo); in lookup_bo()
172 return bo; in lookup_bo()
179 struct omap_bo *bo = calloc(sizeof(*bo), 1); in bo_from_handle() local
180 if (!bo) { in bo_from_handle()
187 bo->dev = omap_device_ref(dev); in bo_from_handle()
188 bo->handle = handle; in bo_from_handle()
189 bo->fd = -1; in bo_from_handle()
190 atomic_set(&bo->refcnt, 1); in bo_from_handle()
192 drmHashInsert(dev->handle_table, handle, bo); in bo_from_handle()
193 return bo; in bo_from_handle()
200 struct omap_bo *bo = NULL; in omap_bo_new_impl() local
215 bo = bo_from_handle(dev, req.handle); in omap_bo_new_impl()
219 bo->size = round_up(size.tiled.width, PAGE_SIZE) * size.tiled.height; in omap_bo_new_impl()
221 bo->size = size.bytes; in omap_bo_new_impl()
224 return bo; in omap_bo_new_impl()
227 free(bo); in omap_bo_new_impl()
262 struct omap_bo *omap_bo_ref(struct omap_bo *bo) in omap_bo_ref() argument
264 atomic_inc(&bo->refcnt); in omap_bo_ref()
265 return bo; in omap_bo_ref()
269 static int get_buffer_info(struct omap_bo *bo) in get_buffer_info() argument
272 .handle = bo->handle, in get_buffer_info()
274 int ret = drmCommandWriteRead(bo->dev->fd, DRM_OMAP_GEM_INFO, in get_buffer_info()
281 bo->offset = req.offset; in get_buffer_info()
282 bo->size = req.size; in get_buffer_info()
291 struct omap_bo *bo = NULL; in omap_bo_from_name() local
302 bo = lookup_bo(dev, req.handle); in omap_bo_from_name()
303 if (!bo) { in omap_bo_from_name()
304 bo = bo_from_handle(dev, req.handle); in omap_bo_from_name()
305 bo->name = name; in omap_bo_from_name()
310 return bo; in omap_bo_from_name()
314 free(bo); in omap_bo_from_name()
325 struct omap_bo *bo = NULL; in omap_bo_from_dmabuf() local
338 bo = lookup_bo(dev, req.handle); in omap_bo_from_dmabuf()
339 if (!bo) { in omap_bo_from_dmabuf()
340 bo = bo_from_handle(dev, req.handle); in omap_bo_from_dmabuf()
345 return bo; in omap_bo_from_dmabuf()
349 free(bo); in omap_bo_from_dmabuf()
354 void omap_bo_del(struct omap_bo *bo) in omap_bo_del() argument
356 if (!bo) { in omap_bo_del()
360 if (!atomic_dec_and_test(&bo->refcnt)) in omap_bo_del()
363 if (bo->map) { in omap_bo_del()
364 munmap(bo->map, bo->size); in omap_bo_del()
367 if (bo->fd >= 0) { in omap_bo_del()
368 close(bo->fd); in omap_bo_del()
371 if (bo->handle) { in omap_bo_del()
373 .handle = bo->handle, in omap_bo_del()
376 drmHashDelete(bo->dev->handle_table, bo->handle); in omap_bo_del()
377 drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req); in omap_bo_del()
381 omap_device_del(bo->dev); in omap_bo_del()
383 free(bo); in omap_bo_del()
387 int omap_bo_get_name(struct omap_bo *bo, uint32_t *name) in omap_bo_get_name() argument
389 if (!bo->name) { in omap_bo_get_name()
391 .handle = bo->handle, in omap_bo_get_name()
395 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req); in omap_bo_get_name()
400 bo->name = req.name; in omap_bo_get_name()
403 *name = bo->name; in omap_bo_get_name()
408 uint32_t omap_bo_handle(struct omap_bo *bo) in omap_bo_handle() argument
410 return bo->handle; in omap_bo_handle()
416 int omap_bo_dmabuf(struct omap_bo *bo) in omap_bo_dmabuf() argument
418 if (bo->fd < 0) { in omap_bo_dmabuf()
420 .handle = bo->handle, in omap_bo_dmabuf()
425 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req); in omap_bo_dmabuf()
430 bo->fd = req.fd; in omap_bo_dmabuf()
432 return dup(bo->fd); in omap_bo_dmabuf()
435 uint32_t omap_bo_size(struct omap_bo *bo) in omap_bo_size() argument
437 if (!bo->size) { in omap_bo_size()
438 get_buffer_info(bo); in omap_bo_size()
440 return bo->size; in omap_bo_size()
443 void *omap_bo_map(struct omap_bo *bo) in omap_bo_map() argument
445 if (!bo->map) { in omap_bo_map()
446 if (!bo->offset) { in omap_bo_map()
447 get_buffer_info(bo); in omap_bo_map()
450 bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE, in omap_bo_map()
451 MAP_SHARED, bo->dev->fd, bo->offset); in omap_bo_map()
452 if (bo->map == MAP_FAILED) { in omap_bo_map()
453 bo->map = NULL; in omap_bo_map()
456 return bo->map; in omap_bo_map()
459 int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op) in omap_bo_cpu_prep() argument
462 .handle = bo->handle, in omap_bo_cpu_prep()
465 return drmCommandWrite(bo->dev->fd, in omap_bo_cpu_prep()
469 int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op) in omap_bo_cpu_fini() argument
472 .handle = bo->handle, in omap_bo_cpu_fini()
476 return drmCommandWrite(bo->dev->fd, in omap_bo_cpu_fini()