Commit | Line | Data |
---|---|---|
de2ba664 AM |
1 | /* |
2 | * Tegra host1x GEM implementation | |
3 | * | |
4 | * Copyright (c) 2012-2013, NVIDIA Corporation. | |
5 | * | |
9a2ac2dc TR |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
de2ba664 AM |
9 | */ |
10 | ||
11 | #ifndef __HOST1X_GEM_H | |
12 | #define __HOST1X_GEM_H | |
13 | ||
35d747a8 TR |
14 | #include <linux/host1x.h> |
15 | ||
de2ba664 AM |
16 | #include <drm/drm.h> |
17 | #include <drm/drmP.h> | |
18 | ||
c134f019 TR |
19 | #define TEGRA_BO_BOTTOM_UP (1 << 0) |
20 | ||
21 | enum tegra_bo_tiling_mode { | |
22 | TEGRA_BO_TILING_MODE_PITCH, | |
23 | TEGRA_BO_TILING_MODE_TILED, | |
24 | TEGRA_BO_TILING_MODE_BLOCK, | |
25 | }; | |
26 | ||
27 | struct tegra_bo_tiling { | |
28 | enum tegra_bo_tiling_mode mode; | |
29 | unsigned long value; | |
30 | }; | |
773af77f | 31 | |
de2ba664 AM |
32 | struct tegra_bo { |
33 | struct drm_gem_object gem; | |
34 | struct host1x_bo base; | |
773af77f | 35 | unsigned long flags; |
3800391d | 36 | struct sg_table *sgt; |
de2ba664 AM |
37 | dma_addr_t paddr; |
38 | void *vaddr; | |
c134f019 TR |
39 | |
40 | struct tegra_bo_tiling tiling; | |
de2ba664 AM |
41 | }; |
42 | ||
43 | static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem) | |
44 | { | |
45 | return container_of(gem, struct tegra_bo, gem); | |
46 | } | |
47 | ||
773af77f TR |
48 | struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size, |
49 | unsigned long flags); | |
de2ba664 | 50 | struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file, |
773af77f TR |
51 | struct drm_device *drm, |
52 | unsigned int size, | |
53 | unsigned long flags, | |
54 | unsigned int *handle); | |
de2ba664 | 55 | void tegra_bo_free_object(struct drm_gem_object *gem); |
de2ba664 AM |
56 | int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm, |
57 | struct drm_mode_create_dumb *args); | |
58 | int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm, | |
59 | uint32_t handle, uint64_t *offset); | |
de2ba664 AM |
60 | |
61 | int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma); | |
62 | ||
63 | extern const struct vm_operations_struct tegra_bo_vm_ops; | |
64 | ||
3800391d TR |
65 | struct dma_buf *tegra_gem_prime_export(struct drm_device *drm, |
66 | struct drm_gem_object *gem, | |
67 | int flags); | |
68 | struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm, | |
69 | struct dma_buf *buf); | |
70 | ||
de2ba664 | 71 | #endif |