@@ -1,6 +1,8 @@
drm_tegra_bo_get_handle
+drm_tegra_bo_get_name
drm_tegra_bo_map
drm_tegra_bo_new
+drm_tegra_bo_open
drm_tegra_bo_ref
drm_tegra_bo_unmap
drm_tegra_bo_unref
@@ -244,3 +244,53 @@ drm_public int drm_tegra_bo_unmap(struct drm_tegra_bo *bo)
return 0;
}
+
+drm_public int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name)
+{
+ struct drm_tegra *drm = bo->drm;
+ struct drm_gem_flink args;
+ int err;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
+
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_FLINK, &args);
+ if (err < 0)
+ return err;
+
+ if (name)
+ *name = args.name;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop)
+{
+ struct drm_gem_open args;
+ struct drm_tegra_bo *bo;
+ int err;
+
+ bo = drm_tegra_bo_alloc(drm, 0, flags, 0);
+ if (!bo)
+ return -ENOMEM;
+
+ memset(&args, 0, sizeof(args));
+ args.name = name;
+
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &args);
+ if (err < 0)
+ goto free;
+
+ bo->handle = args.handle;
+ bo->size = args.size;
+
+ *bop = bo;
+
+ return 0;
+
+free:
+ free(bo);
+ return err;
+}
@@ -44,5 +44,8 @@ int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);
int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr);
int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
+int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);
+int drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop);
#endif /* __DRM_TEGRA_H__ */