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 atomic_set(&bo->refcnt, 1); in bo_from_handle()
191 drmHashInsert(dev->handle_table, handle, bo); in bo_from_handle()
192 return bo; in bo_from_handle()
199 struct omap_bo *bo = NULL; in omap_bo_new_impl() local
214 bo = bo_from_handle(dev, req.handle); in omap_bo_new_impl()
218 bo->size = round_up(size.tiled.width, PAGE_SIZE) * size.tiled.height; in omap_bo_new_impl()
220 bo->size = size.bytes; in omap_bo_new_impl()
223 return bo; in omap_bo_new_impl()
226 free(bo); in omap_bo_new_impl()
261 drm_public struct omap_bo *omap_bo_ref(struct omap_bo *bo) in omap_bo_ref() argument
263 atomic_inc(&bo->refcnt); in omap_bo_ref()
264 return bo; in omap_bo_ref()
268 static int get_buffer_info(struct omap_bo *bo) in get_buffer_info() argument
271 .handle = bo->handle, in get_buffer_info()
273 int ret = drmCommandWriteRead(bo->dev->fd, DRM_OMAP_GEM_INFO, in get_buffer_info()
280 bo->offset = req.offset; in get_buffer_info()
281 bo->size = req.size; in get_buffer_info()
290 struct omap_bo *bo = NULL; in omap_bo_from_name() local
301 bo = lookup_bo(dev, req.handle); in omap_bo_from_name()
302 if (!bo) { in omap_bo_from_name()
303 bo = bo_from_handle(dev, req.handle); in omap_bo_from_name()
304 bo->name = name; in omap_bo_from_name()
309 return bo; in omap_bo_from_name()
313 free(bo); in omap_bo_from_name()
324 struct omap_bo *bo = NULL; in omap_bo_from_dmabuf() local
337 bo = lookup_bo(dev, req.handle); in omap_bo_from_dmabuf()
338 if (!bo) { in omap_bo_from_dmabuf()
339 bo = bo_from_handle(dev, req.handle); in omap_bo_from_dmabuf()
344 return bo; in omap_bo_from_dmabuf()
348 free(bo); in omap_bo_from_dmabuf()
353 drm_public void omap_bo_del(struct omap_bo *bo) in omap_bo_del() argument
355 if (!bo) { in omap_bo_del()
359 if (!atomic_dec_and_test(&bo->refcnt)) in omap_bo_del()
362 if (bo->map) { in omap_bo_del()
363 munmap(bo->map, bo->size); in omap_bo_del()
366 if (bo->fd) { in omap_bo_del()
367 close(bo->fd); in omap_bo_del()
370 if (bo->handle) { in omap_bo_del()
372 .handle = bo->handle, in omap_bo_del()
375 drmHashDelete(bo->dev->handle_table, bo->handle); in omap_bo_del()
376 drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req); in omap_bo_del()
380 omap_device_del(bo->dev); in omap_bo_del()
382 free(bo); in omap_bo_del()
386 drm_public int omap_bo_get_name(struct omap_bo *bo, uint32_t *name) in omap_bo_get_name() argument
388 if (!bo->name) { in omap_bo_get_name()
390 .handle = bo->handle, in omap_bo_get_name()
394 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req); in omap_bo_get_name()
399 bo->name = req.name; in omap_bo_get_name()
402 *name = bo->name; in omap_bo_get_name()
407 drm_public uint32_t omap_bo_handle(struct omap_bo *bo) in omap_bo_handle() argument
409 return bo->handle; in omap_bo_handle()
415 drm_public int omap_bo_dmabuf(struct omap_bo *bo) in omap_bo_dmabuf() argument
417 if (!bo->fd) { in omap_bo_dmabuf()
419 .handle = bo->handle, in omap_bo_dmabuf()
424 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req); in omap_bo_dmabuf()
429 bo->fd = req.fd; in omap_bo_dmabuf()
431 return dup(bo->fd); in omap_bo_dmabuf()
434 drm_public uint32_t omap_bo_size(struct omap_bo *bo) in omap_bo_size() argument
436 if (!bo->size) { in omap_bo_size()
437 get_buffer_info(bo); in omap_bo_size()
439 return bo->size; in omap_bo_size()
442 drm_public void *omap_bo_map(struct omap_bo *bo) in omap_bo_map() argument
444 if (!bo->map) { in omap_bo_map()
445 if (!bo->offset) { in omap_bo_map()
446 get_buffer_info(bo); in omap_bo_map()
449 bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE, in omap_bo_map()
450 MAP_SHARED, bo->dev->fd, bo->offset); in omap_bo_map()
451 if (bo->map == MAP_FAILED) { in omap_bo_map()
452 bo->map = NULL; in omap_bo_map()
455 return bo->map; in omap_bo_map()
458 drm_public int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op) in omap_bo_cpu_prep() argument
461 .handle = bo->handle, in omap_bo_cpu_prep()
464 return drmCommandWrite(bo->dev->fd, in omap_bo_cpu_prep()
468 drm_public int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op) in omap_bo_cpu_fini() argument
471 .handle = bo->handle, in omap_bo_cpu_fini()
475 return drmCommandWrite(bo->dev->fd, in omap_bo_cpu_fini()