Lines Matching refs:bo

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