1
2
3#include <linux/module.h>
4
5#include <drm/drm_gem_ttm_helper.h>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
24 const struct drm_gem_object *gem)
25{
26 static const char * const plname[] = {
27 [ TTM_PL_SYSTEM ] = "system",
28 [ TTM_PL_TT ] = "tt",
29 [ TTM_PL_VRAM ] = "vram",
30 [ TTM_PL_PRIV ] = "priv",
31
32 [ 16 ] = "cached",
33 [ 17 ] = "uncached",
34 [ 18 ] = "wc",
35 [ 19 ] = "contig",
36
37 [ 21 ] = "pinned",
38 [ 22 ] = "topdown",
39 };
40 const struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
41
42 drm_printf_indent(p, indent, "placement=");
43 drm_print_bits(p, bo->mem.placement, plname, ARRAY_SIZE(plname));
44 drm_printf(p, "\n");
45
46 if (bo->mem.bus.is_iomem)
47 drm_printf_indent(p, indent, "bus.offset=%lx\n",
48 (unsigned long)bo->mem.bus.offset);
49}
50EXPORT_SYMBOL(drm_gem_ttm_print_info);
51
52
53
54
55
56
57
58
59
60
61
62
63int drm_gem_ttm_vmap(struct drm_gem_object *gem,
64 struct dma_buf_map *map)
65{
66 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
67
68 return ttm_bo_vmap(bo, map);
69}
70EXPORT_SYMBOL(drm_gem_ttm_vmap);
71
72
73
74
75
76
77
78
79
80void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
81 struct dma_buf_map *map)
82{
83 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
84
85 ttm_bo_vunmap(bo, map);
86}
87EXPORT_SYMBOL(drm_gem_ttm_vunmap);
88
89
90
91
92
93
94
95
96
97int drm_gem_ttm_mmap(struct drm_gem_object *gem,
98 struct vm_area_struct *vma)
99{
100 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
101 int ret;
102
103 ret = ttm_bo_mmap_obj(vma, bo);
104 if (ret < 0)
105 return ret;
106
107
108
109
110
111 drm_gem_object_put(gem);
112
113 return 0;
114}
115EXPORT_SYMBOL(drm_gem_ttm_mmap);
116
117MODULE_DESCRIPTION("DRM gem ttm helpers");
118MODULE_LICENSE("GPL");
119