drm_agpsupport.h revision 1.5.16.1 1 /* $NetBSD: drm_agpsupport.h,v 1.5.16.1 2018/09/06 06:56:35 pgoyette Exp $ */
2
3 #ifndef _DRM_AGPSUPPORT_H_
4 #define _DRM_AGPSUPPORT_H_
5
6 #include <linux/agp_backend.h>
7 #include <linux/kernel.h>
8 #include <linux/list.h>
9 #include <linux/mm.h>
10 #include <linux/mutex.h>
11 #include <linux/types.h>
12 #include <uapi/drm/drm.h>
13
14 #ifdef __NetBSD__
15 #include <drm/drm_agp_netbsd.h>
16 #endif
17
18 struct drm_device;
19 struct drm_file;
20
21 struct drm_agp_hooks {
22 void __pci_iomem *
23 (*agph_borrow)(struct drm_device *, unsigned, bus_size_t);
24 void (*agph_flush)(void);
25
26 struct drm_agp_head *
27 (*agph_init)(struct drm_device *);
28 void (*agph_clear)(struct drm_device *);
29 int (*agph_acquire)(struct drm_device *);
30 int (*agph_release)(struct drm_device *);
31 int (*agph_enable)(struct drm_device *, struct drm_agp_mode);
32 int (*agph_info)(struct drm_device *, struct drm_agp_info *);
33 int (*agph_alloc)(struct drm_device *, struct drm_agp_buffer *);
34 int (*agph_free)(struct drm_device *, struct drm_agp_buffer *);
35 int (*agph_bind)(struct drm_device *, struct drm_agp_binding *);
36 int (*agph_unbind)(struct drm_device *, struct drm_agp_binding *);
37
38 int (*agph_acquire_ioctl)(struct drm_device *, void *,
39 struct drm_file *);
40 int (*agph_release_ioctl)(struct drm_device *, void *,
41 struct drm_file *);
42 int (*agph_enable_ioctl)(struct drm_device *, void *,
43 struct drm_file *);
44 int (*agph_info_ioctl)(struct drm_device *, void *,
45 struct drm_file *);
46 int (*agph_alloc_ioctl)(struct drm_device *, void *,
47 struct drm_file *);
48 int (*agph_free_ioctl)(struct drm_device *, void *,
49 struct drm_file *);
50 int (*agph_bind_ioctl)(struct drm_device *, void *,
51 struct drm_file *);
52 int (*agph_unbind_ioctl)(struct drm_device *, void *,
53 struct drm_file *);
54 };
55
56 struct drm_agp_head {
57 const struct drm_agp_hooks *hooks;
58 struct agp_kern_info agp_info;
59 struct list_head memory;
60 unsigned long mode;
61 struct agp_bridge_data *bridge;
62 int enabled;
63 int acquired;
64 unsigned long base;
65 int agp_mtrr;
66 int cant_use_aperture;
67 unsigned long page_mask;
68 };
69
70 #if IS_ENABLED(CONFIG_AGP)
71
72 #ifdef __NetBSD__
73 static inline void drm_free_agp(struct agp_bridge_data *, struct agp_memory *, int);
74 static inline int drm_bind_agp(struct agp_bridge_data *, struct agp_memory *, unsigned);
75 static inline int drm_unbind_agp(struct agp_bridge_data *, struct agp_memory *);
76 #else
77 void drm_free_agp(struct agp_memory * handle, int pages);
78 int drm_bind_agp(struct agp_memory * handle, unsigned int start);
79 int drm_unbind_agp(struct agp_memory * handle);
80 #endif
81 struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
82 struct page **pages,
83 unsigned long num_pages,
84 uint32_t gtt_offset,
85 uint32_t type);
86
87 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
88 void drm_agp_clear(struct drm_device *dev);
89 int drm_agp_acquire(struct drm_device *dev);
90 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
91 struct drm_file *file_priv);
92 int drm_agp_release(struct drm_device *dev);
93 int drm_agp_release_ioctl(struct drm_device *dev, void *data,
94 struct drm_file *file_priv);
95 int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
96 int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
97 struct drm_file *file_priv);
98 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
99 int drm_agp_info_ioctl(struct drm_device *dev, void *data,
100 struct drm_file *file_priv);
101 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
102 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
103 struct drm_file *file_priv);
104 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
105 int drm_agp_free_ioctl(struct drm_device *dev, void *data,
106 struct drm_file *file_priv);
107 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
108 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
109 struct drm_file *file_priv);
110 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
111 int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
112 struct drm_file *file_priv);
113
114 #ifdef __NetBSD__
115 void __pci_iomem *drm_agp_borrow(struct drm_device *, unsigned, bus_size_t);
116 void drm_agp_flush(void);
117 void drm_agp_fini(struct drm_device *);
118 int drm_agp_register(const struct drm_agp_hooks *);
119 int drm_agp_deregister(const struct drm_agp_hooks *);
120 void drm_agp_hooks_init(void);
121 void drm_agp_hooks_fini(void);
122 int drmkms_agp_guarantee_initialized(void);
123 #endif
124
125 #else /* CONFIG_AGP */
126
127 #if !defined(__NetBSD__)
128
129 static inline void drm_free_agp(struct agp_memory * handle, int pages)
130 {
131 }
132
133 static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
134 {
135 return -ENODEV;
136 }
137
138 static inline int drm_unbind_agp(struct agp_memory * handle)
139 {
140 return -ENODEV;
141 }
142
143 #endif
144
145 static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
146 struct page **pages,
147 unsigned long num_pages,
148 uint32_t gtt_offset,
149 uint32_t type)
150 {
151 return NULL;
152 }
153
154 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
155 {
156 return NULL;
157 }
158
159 static inline void drm_agp_clear(struct drm_device *dev)
160 {
161 }
162
163 static inline int drm_agp_acquire(struct drm_device *dev)
164 {
165 return -ENODEV;
166 }
167
168 static inline int drm_agp_release(struct drm_device *dev)
169 {
170 return -ENODEV;
171 }
172
173 static inline int drm_agp_enable(struct drm_device *dev,
174 struct drm_agp_mode mode)
175 {
176 return -ENODEV;
177 }
178
179 static inline int drm_agp_info(struct drm_device *dev,
180 struct drm_agp_info *info)
181 {
182 return -ENODEV;
183 }
184
185 static inline int drm_agp_alloc(struct drm_device *dev,
186 struct drm_agp_buffer *request)
187 {
188 return -ENODEV;
189 }
190
191 static inline int drm_agp_free(struct drm_device *dev,
192 struct drm_agp_buffer *request)
193 {
194 return -ENODEV;
195 }
196
197 static inline int drm_agp_unbind(struct drm_device *dev,
198 struct drm_agp_binding *request)
199 {
200 return -ENODEV;
201 }
202
203 static inline int drm_agp_bind(struct drm_device *dev,
204 struct drm_agp_binding *request)
205 {
206 return -ENODEV;
207 }
208
209 #endif /* CONFIG_AGP */
210
211 #endif /* _DRM_AGPSUPPORT_H_ */
212