Lines Matching refs:bo

56 	/* The handle_table is used to track GEM bo handles associated w/
62 * to an invalid handle (and possible a GEM bo that is already
163 struct omap_bo *bo = NULL;
164 if (!drmHashLookup(dev->handle_table, handle, (void **)&bo)) {
166 bo = omap_bo_ref(bo);
168 return bo;
175 struct omap_bo *bo = calloc(sizeof(*bo), 1);
176 if (!bo) {
180 bo->dev = omap_device_ref(dev);
181 bo->handle = handle;
182 bo->fd = -1;
183 atomic_set(&bo->refcnt, 1);
185 drmHashInsert(dev->handle_table, handle, bo);
186 return bo;
193 struct omap_bo *bo = NULL;
208 bo = bo_from_handle(dev, req.handle);
212 bo->size = round_up(size.tiled.width, PAGE_SIZE) * size.tiled.height;
214 bo->size = size.bytes;
217 return bo;
220 free(bo);
255 drm_public struct omap_bo *omap_bo_ref(struct omap_bo *bo)
257 atomic_inc(&bo->refcnt);
258 return bo;
262 static int get_buffer_info(struct omap_bo *bo)
265 .handle = bo->handle,
267 int ret = drmCommandWriteRead(bo->dev->fd, DRM_OMAP_GEM_INFO,
274 bo->offset = req.offset;
275 bo->size = req.size;
284 struct omap_bo *bo = NULL;
295 bo = lookup_bo(dev, req.handle);
296 if (!bo) {
297 bo = bo_from_handle(dev, req.handle);
298 bo->name = name;
303 return bo;
307 free(bo);
318 struct omap_bo *bo = NULL;
331 bo = lookup_bo(dev, req.handle);
332 if (!bo) {
333 bo = bo_from_handle(dev, req.handle);
338 return bo;
342 free(bo);
347 drm_public void omap_bo_del(struct omap_bo *bo)
349 if (!bo) {
353 if (!atomic_dec_and_test(&bo->refcnt))
356 if (bo->map) {
357 munmap(bo->map, bo->size);
360 if (bo->fd >= 0) {
361 close(bo->fd);
364 if (bo->handle) {
366 drmHashDelete(bo->dev->handle_table, bo->handle);
367 drmCloseBufferHandle(bo->dev->fd, bo->handle);
371 omap_device_del(bo->dev);
373 free(bo);
377 drm_public int omap_bo_get_name(struct omap_bo *bo, uint32_t *name)
379 if (!bo->name) {
381 .handle = bo->handle,
385 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req);
390 bo->name = req.name;
393 *name = bo->name;
398 drm_public uint32_t omap_bo_handle(struct omap_bo *bo)
400 return bo->handle;
406 drm_public int omap_bo_dmabuf(struct omap_bo *bo)
408 if (bo->fd < 0) {
410 .handle = bo->handle,
415 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req);
420 bo->fd = req.fd;
422 return dup(bo->fd);
425 drm_public uint32_t omap_bo_size(struct omap_bo *bo)
427 if (!bo->size) {
428 get_buffer_info(bo);
430 return bo->size;
433 drm_public void *omap_bo_map(struct omap_bo *bo)
435 if (!bo->map) {
436 if (!bo->offset) {
437 get_buffer_info(bo);
440 bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE,
441 MAP_SHARED, bo->dev->fd, bo->offset);
442 if (bo->map == MAP_FAILED) {
443 bo->map = NULL;
446 return bo->map;
449 drm_public int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op)
452 .handle = bo->handle,
455 return drmCommandWrite(bo->dev->fd,
459 drm_public int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op)
462 .handle = bo->handle,
466 return drmCommandWrite(bo->dev->fd,