aboutsummaryrefslogtreecommitdiffstats
path: root/tegra
diff options
context:
space:
mode:
authorSean Paul2015-02-04 12:59:05 -0600
committerSean Paul2015-02-04 22:21:56 -0600
commit5711d56833c1f071d35dcdb9b66df552b10d4dac (patch)
tree9048346976f3e6998ee67e468039307b78d1b0d6 /tegra
parent3880eeda7dd7b24fb075f97a0dc59f357e68c345 (diff)
downloadexternal-libgbm-5711d56833c1f071d35dcdb9b66df552b10d4dac.tar.gz
external-libgbm-5711d56833c1f071d35dcdb9b66df552b10d4dac.tar.xz
external-libgbm-5711d56833c1f071d35dcdb9b66df552b10d4dac.zip
libdrm: tegra: Add funcs to add/fetch name
Add functions within the tegra driver to add a name to a bo as well as fetch a bo from name. Signed-off-by: Sean Paul <seanpaul@chromium.org> Change-Id: I316a3920541040fe478eb5b07c1ef00a3a597e68
Diffstat (limited to 'tegra')
-rw-r--r--tegra/private.h1
-rw-r--r--tegra/tegra.c57
-rw-r--r--tegra/tegra.h5
3 files changed, 63 insertions, 0 deletions
diff --git a/tegra/private.h b/tegra/private.h
index 1dc6d664..1b490d40 100644
--- a/tegra/private.h
+++ b/tegra/private.h
@@ -44,6 +44,7 @@ struct drm_tegra_bo {
44 uint64_t offset; 44 uint64_t offset;
45 uint32_t flags; 45 uint32_t flags;
46 uint32_t size; 46 uint32_t size;
47 uint32_t name;
47 atomic_t ref; 48 atomic_t ref;
48 void *map; 49 void *map;
49}; 50};
diff --git a/tegra/tegra.c b/tegra/tegra.c
index f8d40786..a58a08a5 100644
--- a/tegra/tegra.c
+++ b/tegra/tegra.c
@@ -171,6 +171,63 @@ int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm,
171} 171}
172 172
173drm_public 173drm_public
174int drm_tegra_bo_name_ref(struct drm_tegra *drm, uint32_t name, uint32_t size,
175 struct drm_tegra_bo **bop)
176{
177 struct drm_tegra_bo *bo;
178 struct drm_gem_open open_args;
179 struct drm_gem_close close_args;
180 int ret;
181
182 memset(&open_args, 0, sizeof(open_args));
183
184 open_args.name = name;
185
186 ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &open_args);
187 if (ret)
188 return ret;
189
190 ret = drm_tegra_bo_wrap(bop, drm, open_args.handle, 0, size);
191 if (ret)
192 goto err;
193
194 (*bop)->name = name;
195
196 return 0;
197
198err:
199 memset(&close_args, 0, sizeof(close_args));
200 close_args.handle = open_args.handle;
201 drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &close_args);
202
203 return ret;
204}
205
206drm_public
207int drm_tegra_bo_name_get(struct drm_tegra_bo *bo, uint32_t *name)
208{
209 struct drm_gem_flink args;
210 int ret;
211
212 args.handle = bo->handle;
213
214 *name = bo->name;
215 if (*name && *name != ~0U)
216 return 0;
217
218 ret = drmIoctl(bo->drm->fd, DRM_IOCTL_GEM_FLINK, &args);
219 if (ret) {
220 *name = 0;
221 return ret;
222 }
223
224 bo->name = args.name;
225 *name = bo->name;
226
227 return 0;
228}
229
230drm_public
174struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo) 231struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo)
175{ 232{
176 if (bo) 233 if (bo)
diff --git a/tegra/tegra.h b/tegra/tegra.h
index 31b0995a..e10eab71 100644
--- a/tegra/tegra.h
+++ b/tegra/tegra.h
@@ -38,6 +38,11 @@ int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm,
38 uint32_t flags, uint32_t size); 38 uint32_t flags, uint32_t size);
39int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm, 39int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm,
40 uint32_t handle, uint32_t flags, uint32_t size); 40 uint32_t handle, uint32_t flags, uint32_t size);
41
42int drm_tegra_bo_name_ref(struct drm_tegra *drm, uint32_t name, uint32_t size,
43 struct drm_tegra_bo **bop);
44int drm_tegra_bo_name_get(struct drm_tegra_bo *bo, uint32_t *name);
45
41struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo); 46struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo);
42void drm_tegra_bo_unref(struct drm_tegra_bo *bo); 47void drm_tegra_bo_unref(struct drm_tegra_bo *bo);
43int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle); 48int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);