summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-11-27 15:32:43 +0100
committerThierry Reding <treding@nvidia.com>2014-11-27 17:20:32 +0100
commitf99522e678dbbaffeca9462a8edcbe900574dc12 (patch)
tree32cceb8018648474e208c12056f80367282e32b9
parentd3ad65db4215f5fb5419d78a14c12833d5ed150a (diff)
tegra: Implement drm_tegra_bo_{get,set}_tiling()
These two functions are simple wrappers around the corresponding IOCTLs and operate on drm_tegra_bo objects. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--tegra/tegra.c51
-rw-r--r--tegra/tegra.h10
2 files changed, 61 insertions, 0 deletions
diff --git a/tegra/tegra.c b/tegra/tegra.c
index 614ab965..f8d40786 100644
--- a/tegra/tegra.c
+++ b/tegra/tegra.c
@@ -292,3 +292,54 @@ int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags)
return 0;
}
+
+drm_public
+int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo,
+ struct drm_tegra_bo_tiling *tiling)
+{
+ struct drm_tegra_gem_get_tiling args;
+ struct drm_tegra *drm = bo->drm;
+ int err;
+
+ if (!bo)
+ return -EINVAL;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
+
+ err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_GET_TILING, &args,
+ sizeof(args));
+ if (err < 0)
+ return -errno;
+
+ if (tiling) {
+ tiling->mode = args.mode;
+ tiling->value = args.value;
+ }
+
+ return 0;
+}
+
+drm_public
+int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo,
+ const struct drm_tegra_bo_tiling *tiling)
+{
+ struct drm_tegra_gem_set_tiling args;
+ struct drm_tegra *drm = bo->drm;
+ int err;
+
+ if (!bo)
+ return -EINVAL;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
+ args.mode = tiling->mode;
+ args.value = tiling->value;
+
+ err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_SET_TILING, &args,
+ sizeof(args));
+ if (err < 0)
+ return -errno;
+
+ return 0;
+}
diff --git a/tegra/tegra.h b/tegra/tegra.h
index a8624180..31b0995a 100644
--- a/tegra/tegra.h
+++ b/tegra/tegra.h
@@ -47,4 +47,14 @@ int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags);
int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags);
+struct drm_tegra_bo_tiling {
+ uint32_t mode;
+ uint32_t value;
+};
+
+int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo,
+ struct drm_tegra_bo_tiling *tiling);
+int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo,
+ const struct drm_tegra_bo_tiling *tiling);
+
#endif /* __DRM_TEGRA_H__ */