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 "ttm_object.h"
35#include <linux/dma-buf.h>
36
37
38
39
40
41
42static int vmw_prime_map_attach(struct dma_buf *dma_buf,
43 struct dma_buf_attachment *attach)
44{
45 return -ENOSYS;
46}
47
48static void vmw_prime_map_detach(struct dma_buf *dma_buf,
49 struct dma_buf_attachment *attach)
50{
51}
52
53static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach,
54 enum dma_data_direction dir)
55{
56 return ERR_PTR(-ENOSYS);
57}
58
59static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
60 struct sg_table *sgb,
61 enum dma_data_direction dir)
62{
63}
64
65static void *vmw_prime_dmabuf_vmap(struct dma_buf *dma_buf)
66{
67 return NULL;
68}
69
70static void vmw_prime_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
71{
72}
73
74static void *vmw_prime_dmabuf_kmap(struct dma_buf *dma_buf,
75 unsigned long page_num)
76{
77 return NULL;
78}
79
80static void vmw_prime_dmabuf_kunmap(struct dma_buf *dma_buf,
81 unsigned long page_num, void *addr)
82{
83
84}
85
86static int vmw_prime_dmabuf_mmap(struct dma_buf *dma_buf,
87 struct vm_area_struct *vma)
88{
89 WARN_ONCE(true, "Attempted use of dmabuf mmap. Bad.\n");
90 return -ENOSYS;
91}
92
93const struct dma_buf_ops vmw_prime_dmabuf_ops = {
94 .attach = vmw_prime_map_attach,
95 .detach = vmw_prime_map_detach,
96 .map_dma_buf = vmw_prime_map_dma_buf,
97 .unmap_dma_buf = vmw_prime_unmap_dma_buf,
98 .release = NULL,
99 .map = vmw_prime_dmabuf_kmap,
100 .unmap = vmw_prime_dmabuf_kunmap,
101 .mmap = vmw_prime_dmabuf_mmap,
102 .vmap = vmw_prime_dmabuf_vmap,
103 .vunmap = vmw_prime_dmabuf_vunmap,
104};
105
106int vmw_prime_fd_to_handle(struct drm_device *dev,
107 struct drm_file *file_priv,
108 int fd, u32 *handle)
109{
110 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
111
112 return ttm_prime_fd_to_handle(tfile, fd, handle);
113}
114
115int vmw_prime_handle_to_fd(struct drm_device *dev,
116 struct drm_file *file_priv,
117 uint32_t handle, uint32_t flags,
118 int *prime_fd)
119{
120 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
121
122 return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
123}
124