1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include "vmwgfx_drv.h"
34#include <linux/dma-buf.h>
35#include <drm/ttm/ttm_object.h>
36
37
38
39
40
41
42static int vmw_prime_map_attach(struct dma_buf *dma_buf,
43 struct device *target_dev,
44 struct dma_buf_attachment *attach)
45{
46 return -ENOSYS;
47}
48
49static void vmw_prime_map_detach(struct dma_buf *dma_buf,
50 struct dma_buf_attachment *attach)
51{
52}
53
54static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach,
55 enum dma_data_direction dir)
56{
57 return ERR_PTR(-ENOSYS);
58}
59
60static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
61 struct sg_table *sgb,
62 enum dma_data_direction dir)
63{
64}
65
66static void *vmw_prime_dmabuf_vmap(struct dma_buf *dma_buf)
67{
68 return NULL;
69}
70
71static void vmw_prime_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
72{
73}
74
75static void *vmw_prime_dmabuf_kmap_atomic(struct dma_buf *dma_buf,
76 unsigned long page_num)
77{
78 return NULL;
79}
80
81static void vmw_prime_dmabuf_kunmap_atomic(struct dma_buf *dma_buf,
82 unsigned long page_num, void *addr)
83{
84
85}
86static void *vmw_prime_dmabuf_kmap(struct dma_buf *dma_buf,
87 unsigned long page_num)
88{
89 return NULL;
90}
91
92static void vmw_prime_dmabuf_kunmap(struct dma_buf *dma_buf,
93 unsigned long page_num, void *addr)
94{
95
96}
97
98static int vmw_prime_dmabuf_mmap(struct dma_buf *dma_buf,
99 struct vm_area_struct *vma)
100{
101 WARN_ONCE(true, "Attempted use of dmabuf mmap. Bad.\n");
102 return -ENOSYS;
103}
104
105const struct dma_buf_ops vmw_prime_dmabuf_ops = {
106 .attach = vmw_prime_map_attach,
107 .detach = vmw_prime_map_detach,
108 .map_dma_buf = vmw_prime_map_dma_buf,
109 .unmap_dma_buf = vmw_prime_unmap_dma_buf,
110 .release = NULL,
111 .kmap = vmw_prime_dmabuf_kmap,
112 .kmap_atomic = vmw_prime_dmabuf_kmap_atomic,
113 .kunmap = vmw_prime_dmabuf_kunmap,
114 .kunmap_atomic = vmw_prime_dmabuf_kunmap_atomic,
115 .mmap = vmw_prime_dmabuf_mmap,
116 .vmap = vmw_prime_dmabuf_vmap,
117 .vunmap = vmw_prime_dmabuf_vunmap,
118};
119
120int vmw_prime_fd_to_handle(struct drm_device *dev,
121 struct drm_file *file_priv,
122 int fd, u32 *handle)
123{
124 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
125
126 return ttm_prime_fd_to_handle(tfile, fd, handle);
127}
128
129int vmw_prime_handle_to_fd(struct drm_device *dev,
130 struct drm_file *file_priv,
131 uint32_t handle, uint32_t flags,
132 int *prime_fd)
133{
134 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
135
136 return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
137}
138