Lines Matching refs:bo
42 static void drm_tegra_bo_free(struct drm_tegra_bo *bo) in drm_tegra_bo_free() argument
44 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_free()
47 if (bo->map) in drm_tegra_bo_free()
48 munmap(bo->map, bo->size); in drm_tegra_bo_free()
51 args.handle = bo->handle; in drm_tegra_bo_free()
55 free(bo); in drm_tegra_bo_free()
115 struct drm_tegra_bo *bo; in drm_tegra_bo_new() local
121 bo = calloc(1, sizeof(*bo)); in drm_tegra_bo_new()
122 if (!bo) in drm_tegra_bo_new()
125 atomic_set(&bo->ref, 1); in drm_tegra_bo_new()
126 bo->flags = flags; in drm_tegra_bo_new()
127 bo->size = size; in drm_tegra_bo_new()
128 bo->drm = drm; in drm_tegra_bo_new()
138 free(bo); in drm_tegra_bo_new()
142 bo->handle = args.handle; in drm_tegra_bo_new()
144 *bop = bo; in drm_tegra_bo_new()
153 struct drm_tegra_bo *bo; in drm_tegra_bo_wrap() local
158 bo = calloc(1, sizeof(*bo)); in drm_tegra_bo_wrap()
159 if (!bo) in drm_tegra_bo_wrap()
162 atomic_set(&bo->ref, 1); in drm_tegra_bo_wrap()
163 bo->handle = handle; in drm_tegra_bo_wrap()
164 bo->flags = flags; in drm_tegra_bo_wrap()
165 bo->size = size; in drm_tegra_bo_wrap()
166 bo->drm = drm; in drm_tegra_bo_wrap()
168 *bop = bo; in drm_tegra_bo_wrap()
177 struct drm_tegra_bo *bo; in drm_tegra_bo_name_ref() local
207 int drm_tegra_bo_name_get(struct drm_tegra_bo *bo, uint32_t *name) in drm_tegra_bo_name_get() argument
212 args.handle = bo->handle; in drm_tegra_bo_name_get()
214 *name = bo->name; in drm_tegra_bo_name_get()
218 ret = drmIoctl(bo->drm->fd, DRM_IOCTL_GEM_FLINK, &args); in drm_tegra_bo_name_get()
224 bo->name = args.name; in drm_tegra_bo_name_get()
225 *name = bo->name; in drm_tegra_bo_name_get()
231 struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo) in drm_tegra_bo_ref() argument
233 if (bo) in drm_tegra_bo_ref()
234 atomic_inc(&bo->ref); in drm_tegra_bo_ref()
236 return bo; in drm_tegra_bo_ref()
240 void drm_tegra_bo_unref(struct drm_tegra_bo *bo) in drm_tegra_bo_unref() argument
242 if (bo && atomic_dec_and_test(&bo->ref)) in drm_tegra_bo_unref()
243 drm_tegra_bo_free(bo); in drm_tegra_bo_unref()
247 int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle) in drm_tegra_bo_get_handle() argument
249 if (!bo || !handle) in drm_tegra_bo_get_handle()
252 *handle = bo->handle; in drm_tegra_bo_get_handle()
258 int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr) in drm_tegra_bo_map() argument
260 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_map()
262 if (!bo->map) { in drm_tegra_bo_map()
267 args.handle = bo->handle; in drm_tegra_bo_map()
274 bo->offset = args.offset; in drm_tegra_bo_map()
276 bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, in drm_tegra_bo_map()
277 drm->fd, bo->offset); in drm_tegra_bo_map()
278 if (bo->map == MAP_FAILED) { in drm_tegra_bo_map()
279 bo->map = NULL; in drm_tegra_bo_map()
285 *ptr = bo->map; in drm_tegra_bo_map()
291 int drm_tegra_bo_unmap(struct drm_tegra_bo *bo) in drm_tegra_bo_unmap() argument
293 if (!bo) in drm_tegra_bo_unmap()
296 if (!bo->map) in drm_tegra_bo_unmap()
299 if (munmap(bo->map, bo->size)) in drm_tegra_bo_unmap()
302 bo->map = NULL; in drm_tegra_bo_unmap()
308 int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags) in drm_tegra_bo_get_flags() argument
311 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_get_flags()
314 if (!bo) in drm_tegra_bo_get_flags()
318 args.handle = bo->handle; in drm_tegra_bo_get_flags()
332 int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags) in drm_tegra_bo_set_flags() argument
335 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_set_flags()
338 if (!bo) in drm_tegra_bo_set_flags()
342 args.handle = bo->handle; in drm_tegra_bo_set_flags()
354 int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo, in drm_tegra_bo_get_tiling() argument
358 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_get_tiling()
361 if (!bo) in drm_tegra_bo_get_tiling()
365 args.handle = bo->handle; in drm_tegra_bo_get_tiling()
381 int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo, in drm_tegra_bo_set_tiling() argument
385 struct drm_tegra *drm = bo->drm; in drm_tegra_bo_set_tiling()
388 if (!bo) in drm_tegra_bo_set_tiling()
392 args.handle = bo->handle; in drm_tegra_bo_set_tiling()