Commit | Line | Data |
---|---|---|
fb1d9738 JB |
1 | /************************************************************************** |
2 | * | |
3 | * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA | |
4 | * All Rights Reserved. | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | |
7 | * copy of this software and associated documentation files (the | |
8 | * "Software"), to deal in the Software without restriction, including | |
9 | * without limitation the rights to use, copy, modify, merge, publish, | |
10 | * distribute, sub license, and/or sell copies of the Software, and to | |
11 | * permit persons to whom the Software is furnished to do so, subject to | |
12 | * the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice (including the | |
15 | * next paragraph) shall be included in all copies or substantial portions | |
16 | * of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | |
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | |
25 | * | |
26 | **************************************************************************/ | |
27 | ||
28 | #ifndef _VMWGFX_DRV_H_ | |
29 | #define _VMWGFX_DRV_H_ | |
30 | ||
31 | #include "vmwgfx_reg.h" | |
32 | #include "drmP.h" | |
33 | #include "vmwgfx_drm.h" | |
34 | #include "drm_hashtab.h" | |
d9f36a00 | 35 | #include "linux/suspend.h" |
fb1d9738 JB |
36 | #include "ttm/ttm_bo_driver.h" |
37 | #include "ttm/ttm_object.h" | |
38 | #include "ttm/ttm_lock.h" | |
39 | #include "ttm/ttm_execbuf_util.h" | |
40 | #include "ttm/ttm_module.h" | |
ae2a1040 | 41 | #include "vmwgfx_fence.h" |
fb1d9738 | 42 | |
57c5ee79 | 43 | #define VMWGFX_DRIVER_DATE "20111008" |
2ae7b03c | 44 | #define VMWGFX_DRIVER_MAJOR 2 |
57c5ee79 | 45 | #define VMWGFX_DRIVER_MINOR 2 |
f77cef3d | 46 | #define VMWGFX_DRIVER_PATCHLEVEL 0 |
fb1d9738 JB |
47 | #define VMWGFX_FILE_PAGE_OFFSET 0x00100000 |
48 | #define VMWGFX_FIFO_STATIC_SIZE (1024*1024) | |
49 | #define VMWGFX_MAX_RELOCATIONS 2048 | |
be38ab6e | 50 | #define VMWGFX_MAX_VALIDATIONS 2048 |
7c4f7780 | 51 | #define VMWGFX_MAX_DISPLAYS 16 |
be38ab6e | 52 | #define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 |
fb1d9738 | 53 | |
135cba0d TH |
54 | #define VMW_PL_GMR TTM_PL_PRIV0 |
55 | #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 | |
56 | ||
ae2a1040 TH |
57 | #define VMW_RES_CONTEXT ttm_driver_type0 |
58 | #define VMW_RES_SURFACE ttm_driver_type1 | |
59 | #define VMW_RES_STREAM ttm_driver_type2 | |
60 | #define VMW_RES_FENCE ttm_driver_type3 | |
61 | ||
fb1d9738 JB |
62 | struct vmw_fpriv { |
63 | struct drm_master *locked_master; | |
64 | struct ttm_object_file *tfile; | |
65 | }; | |
66 | ||
67 | struct vmw_dma_buffer { | |
68 | struct ttm_buffer_object base; | |
69 | struct list_head validate_list; | |
fb1d9738 JB |
70 | bool gmr_bound; |
71 | uint32_t cur_validate_node; | |
72 | bool on_validate_list; | |
73 | }; | |
74 | ||
75 | struct vmw_resource { | |
76 | struct kref kref; | |
77 | struct vmw_private *dev_priv; | |
78 | struct idr *idr; | |
79 | int id; | |
80 | enum ttm_object_type res_type; | |
81 | bool avail; | |
5bb39e81 | 82 | void (*remove_from_lists) (struct vmw_resource *res); |
fb1d9738 JB |
83 | void (*hw_destroy) (struct vmw_resource *res); |
84 | void (*res_free) (struct vmw_resource *res); | |
f18c8840 | 85 | struct list_head validate_head; |
e2fa3a76 | 86 | struct list_head query_head; /* Protected by the cmdbuf mutex */ |
fb1d9738 JB |
87 | /* TODO is a generic snooper needed? */ |
88 | #if 0 | |
89 | void (*snoop)(struct vmw_resource *res, | |
90 | struct ttm_object_file *tfile, | |
91 | SVGA3dCmdHeader *header); | |
92 | void *snoop_priv; | |
93 | #endif | |
94 | }; | |
95 | ||
96 | struct vmw_cursor_snooper { | |
97 | struct drm_crtc *crtc; | |
98 | size_t age; | |
99 | uint32_t *image; | |
100 | }; | |
101 | ||
2fcd5a73 | 102 | struct vmw_framebuffer; |
5bb39e81 | 103 | struct vmw_surface_offset; |
2fcd5a73 | 104 | |
fb1d9738 JB |
105 | struct vmw_surface { |
106 | struct vmw_resource res; | |
5bb39e81 | 107 | struct list_head lru_head; /* Protected by the resource lock */ |
fb1d9738 JB |
108 | uint32_t flags; |
109 | uint32_t format; | |
110 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; | |
111 | struct drm_vmw_size *sizes; | |
112 | uint32_t num_sizes; | |
113 | ||
5ffdb658 JB |
114 | bool scanout; |
115 | ||
fb1d9738 JB |
116 | /* TODO so far just a extra pointer */ |
117 | struct vmw_cursor_snooper snooper; | |
5bb39e81 TH |
118 | struct ttm_buffer_object *backup; |
119 | struct vmw_surface_offset *offsets; | |
120 | uint32_t backup_size; | |
fb1d9738 JB |
121 | }; |
122 | ||
6bcd8d3c | 123 | struct vmw_marker_queue { |
1925d456 TH |
124 | struct list_head head; |
125 | struct timespec lag; | |
126 | struct timespec lag_time; | |
127 | spinlock_t lock; | |
128 | }; | |
129 | ||
fb1d9738 JB |
130 | struct vmw_fifo_state { |
131 | unsigned long reserved_size; | |
132 | __le32 *dynamic_buffer; | |
133 | __le32 *static_buffer; | |
fb1d9738 JB |
134 | unsigned long static_buffer_size; |
135 | bool using_bounce_buffer; | |
136 | uint32_t capabilities; | |
85b9e487 | 137 | struct mutex fifo_mutex; |
fb1d9738 | 138 | struct rw_semaphore rwsem; |
6bcd8d3c | 139 | struct vmw_marker_queue marker_queue; |
fb1d9738 JB |
140 | }; |
141 | ||
142 | struct vmw_relocation { | |
143 | SVGAGuestPtr *location; | |
144 | uint32_t index; | |
145 | }; | |
146 | ||
147 | struct vmw_sw_context{ | |
148 | struct ida bo_list; | |
149 | uint32_t last_cid; | |
150 | bool cid_valid; | |
922ade0d | 151 | bool kernel; /**< is the called made from the kernel */ |
e2fa3a76 | 152 | struct vmw_resource *cur_ctx; |
fb1d9738 | 153 | uint32_t last_sid; |
7a73ba74 | 154 | uint32_t sid_translation; |
fb1d9738 JB |
155 | bool sid_valid; |
156 | struct ttm_object_file *tfile; | |
157 | struct list_head validate_nodes; | |
158 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; | |
159 | uint32_t cur_reloc; | |
be38ab6e | 160 | struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
fb1d9738 | 161 | uint32_t cur_val_buf; |
be38ab6e TH |
162 | uint32_t *cmd_bounce; |
163 | uint32_t cmd_bounce_size; | |
f18c8840 | 164 | struct list_head resource_list; |
e2fa3a76 TH |
165 | uint32_t fence_flags; |
166 | struct list_head query_list; | |
167 | struct ttm_buffer_object *cur_query_bo; | |
168 | uint32_t cur_query_cid; | |
169 | bool query_cid_valid; | |
fb1d9738 JB |
170 | }; |
171 | ||
172 | struct vmw_legacy_display; | |
173 | struct vmw_overlay; | |
174 | ||
175 | struct vmw_master { | |
176 | struct ttm_lock lock; | |
3a939a5e TH |
177 | struct mutex fb_surf_mutex; |
178 | struct list_head fb_surf; | |
fb1d9738 JB |
179 | }; |
180 | ||
7c4f7780 TH |
181 | struct vmw_vga_topology_state { |
182 | uint32_t width; | |
183 | uint32_t height; | |
184 | uint32_t primary; | |
185 | uint32_t pos_x; | |
186 | uint32_t pos_y; | |
187 | }; | |
188 | ||
fb1d9738 JB |
189 | struct vmw_private { |
190 | struct ttm_bo_device bdev; | |
191 | struct ttm_bo_global_ref bo_global_ref; | |
ba4420c2 | 192 | struct drm_global_reference mem_global_ref; |
fb1d9738 JB |
193 | |
194 | struct vmw_fifo_state fifo; | |
195 | ||
196 | struct drm_device *dev; | |
197 | unsigned long vmw_chipset; | |
198 | unsigned int io_start; | |
199 | uint32_t vram_start; | |
200 | uint32_t vram_size; | |
201 | uint32_t mmio_start; | |
202 | uint32_t mmio_size; | |
203 | uint32_t fb_max_width; | |
204 | uint32_t fb_max_height; | |
205 | __le32 __iomem *mmio_virt; | |
206 | int mmio_mtrr; | |
207 | uint32_t capabilities; | |
208 | uint32_t max_gmr_descriptors; | |
209 | uint32_t max_gmr_ids; | |
fb17f189 TH |
210 | uint32_t max_gmr_pages; |
211 | uint32_t memory_size; | |
135cba0d | 212 | bool has_gmr; |
fb1d9738 JB |
213 | struct mutex hw_mutex; |
214 | ||
215 | /* | |
216 | * VGA registers. | |
217 | */ | |
218 | ||
7c4f7780 | 219 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
fb1d9738 JB |
220 | uint32_t vga_width; |
221 | uint32_t vga_height; | |
fb1d9738 | 222 | uint32_t vga_bpp; |
7c4f7780 | 223 | uint32_t vga_bpl; |
d7e1958d | 224 | uint32_t vga_pitchlock; |
fb1d9738 | 225 | |
7c4f7780 TH |
226 | uint32_t num_displays; |
227 | ||
fb1d9738 JB |
228 | /* |
229 | * Framebuffer info. | |
230 | */ | |
231 | ||
232 | void *fb_info; | |
233 | struct vmw_legacy_display *ldu_priv; | |
56d1c78d | 234 | struct vmw_screen_object_display *sou_priv; |
fb1d9738 JB |
235 | struct vmw_overlay *overlay_priv; |
236 | ||
237 | /* | |
238 | * Context and surface management. | |
239 | */ | |
240 | ||
241 | rwlock_t resource_lock; | |
242 | struct idr context_idr; | |
243 | struct idr surface_idr; | |
244 | struct idr stream_idr; | |
245 | ||
246 | /* | |
247 | * Block lastclose from racing with firstopen. | |
248 | */ | |
249 | ||
250 | struct mutex init_mutex; | |
251 | ||
252 | /* | |
253 | * A resource manager for kernel-only surfaces and | |
254 | * contexts. | |
255 | */ | |
256 | ||
257 | struct ttm_object_device *tdev; | |
258 | ||
259 | /* | |
260 | * Fencing and IRQs. | |
261 | */ | |
262 | ||
6bcd8d3c | 263 | atomic_t marker_seq; |
fb1d9738 JB |
264 | wait_queue_head_t fence_queue; |
265 | wait_queue_head_t fifo_queue; | |
4f73a96b | 266 | int fence_queue_waiters; /* Protected by hw_mutex */ |
57c5ee79 | 267 | int goal_queue_waiters; /* Protected by hw_mutex */ |
fb1d9738 | 268 | atomic_t fifo_queue_waiters; |
6bcd8d3c | 269 | uint32_t last_read_seqno; |
fb1d9738 | 270 | spinlock_t irq_lock; |
ae2a1040 | 271 | struct vmw_fence_manager *fman; |
57c5ee79 | 272 | uint32_t irq_mask; |
fb1d9738 JB |
273 | |
274 | /* | |
275 | * Device state | |
276 | */ | |
277 | ||
278 | uint32_t traces_state; | |
279 | uint32_t enable_state; | |
280 | uint32_t config_done_state; | |
281 | ||
282 | /** | |
283 | * Execbuf | |
284 | */ | |
285 | /** | |
286 | * Protected by the cmdbuf mutex. | |
287 | */ | |
288 | ||
289 | struct vmw_sw_context ctx; | |
fb1d9738 JB |
290 | struct mutex cmdbuf_mutex; |
291 | ||
fb1d9738 JB |
292 | /** |
293 | * Operating mode. | |
294 | */ | |
295 | ||
296 | bool stealth; | |
297 | bool is_opened; | |
30c78bb8 | 298 | bool enable_fb; |
fb1d9738 JB |
299 | |
300 | /** | |
301 | * Master management. | |
302 | */ | |
303 | ||
304 | struct vmw_master *active_master; | |
305 | struct vmw_master fbdev_master; | |
d9f36a00 | 306 | struct notifier_block pm_nb; |
094e0fa8 | 307 | bool suspended; |
30c78bb8 TH |
308 | |
309 | struct mutex release_mutex; | |
310 | uint32_t num_3d_resources; | |
e2fa3a76 TH |
311 | |
312 | /* | |
313 | * Query processing. These members | |
314 | * are protected by the cmdbuf mutex. | |
315 | */ | |
316 | ||
317 | struct ttm_buffer_object *dummy_query_bo; | |
318 | struct ttm_buffer_object *pinned_bo; | |
319 | uint32_t query_cid; | |
320 | bool dummy_query_bo_pinned; | |
5bb39e81 TH |
321 | |
322 | /* | |
323 | * Surface swapping. The "surface_lru" list is protected by the | |
324 | * resource lock in order to be able to destroy a surface and take | |
325 | * it off the lru atomically. "used_memory_size" is currently | |
326 | * protected by the cmdbuf mutex for simplicity. | |
327 | */ | |
328 | ||
329 | struct list_head surface_lru; | |
330 | uint32_t used_memory_size; | |
fb1d9738 JB |
331 | }; |
332 | ||
333 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) | |
334 | { | |
335 | return (struct vmw_private *)dev->dev_private; | |
336 | } | |
337 | ||
338 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) | |
339 | { | |
340 | return (struct vmw_fpriv *)file_priv->driver_priv; | |
341 | } | |
342 | ||
343 | static inline struct vmw_master *vmw_master(struct drm_master *master) | |
344 | { | |
345 | return (struct vmw_master *) master->driver_priv; | |
346 | } | |
347 | ||
348 | static inline void vmw_write(struct vmw_private *dev_priv, | |
349 | unsigned int offset, uint32_t value) | |
350 | { | |
351 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
352 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); | |
353 | } | |
354 | ||
355 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, | |
356 | unsigned int offset) | |
357 | { | |
358 | uint32_t val; | |
359 | ||
360 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
361 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); | |
362 | return val; | |
363 | } | |
364 | ||
05730b32 TH |
365 | int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga); |
366 | void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga); | |
30c78bb8 | 367 | |
fb1d9738 JB |
368 | /** |
369 | * GMR utilities - vmwgfx_gmr.c | |
370 | */ | |
371 | ||
372 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, | |
135cba0d TH |
373 | struct page *pages[], |
374 | unsigned long num_pages, | |
375 | int gmr_id); | |
fb1d9738 JB |
376 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
377 | ||
378 | /** | |
379 | * Resource utilities - vmwgfx_resource.c | |
380 | */ | |
381 | ||
382 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); | |
383 | extern void vmw_resource_unreference(struct vmw_resource **p_res); | |
384 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); | |
385 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, | |
386 | struct drm_file *file_priv); | |
387 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, | |
388 | struct drm_file *file_priv); | |
389 | extern int vmw_context_check(struct vmw_private *dev_priv, | |
390 | struct ttm_object_file *tfile, | |
be38ab6e TH |
391 | int id, |
392 | struct vmw_resource **p_res); | |
fb1d9738 JB |
393 | extern void vmw_surface_res_free(struct vmw_resource *res); |
394 | extern int vmw_surface_init(struct vmw_private *dev_priv, | |
395 | struct vmw_surface *srf, | |
396 | void (*res_free) (struct vmw_resource *res)); | |
7a73ba74 TH |
397 | extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, |
398 | struct ttm_object_file *tfile, | |
399 | uint32_t handle, | |
400 | struct vmw_surface **out); | |
fb1d9738 JB |
401 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
402 | struct drm_file *file_priv); | |
403 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |
404 | struct drm_file *file_priv); | |
405 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |
406 | struct drm_file *file_priv); | |
407 | extern int vmw_surface_check(struct vmw_private *dev_priv, | |
408 | struct ttm_object_file *tfile, | |
7a73ba74 | 409 | uint32_t handle, int *id); |
5bb39e81 TH |
410 | extern int vmw_surface_validate(struct vmw_private *dev_priv, |
411 | struct vmw_surface *srf); | |
fb1d9738 JB |
412 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
413 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, | |
414 | struct vmw_dma_buffer *vmw_bo, | |
415 | size_t size, struct ttm_placement *placement, | |
416 | bool interuptable, | |
417 | void (*bo_free) (struct ttm_buffer_object *bo)); | |
418 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | |
419 | struct drm_file *file_priv); | |
420 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, | |
421 | struct drm_file *file_priv); | |
422 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, | |
423 | uint32_t cur_validate_node); | |
424 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); | |
425 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, | |
426 | uint32_t id, struct vmw_dma_buffer **out); | |
fb1d9738 JB |
427 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
428 | struct drm_file *file_priv); | |
429 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, | |
430 | struct drm_file *file_priv); | |
431 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, | |
432 | struct ttm_object_file *tfile, | |
433 | uint32_t *inout_id, | |
434 | struct vmw_resource **out); | |
5bb39e81 | 435 | extern void vmw_resource_unreserve(struct list_head *list); |
fb1d9738 | 436 | |
d991ef03 JB |
437 | /** |
438 | * DMA buffer helper routines - vmwgfx_dmabuf.c | |
439 | */ | |
440 | extern int vmw_dmabuf_to_placement(struct vmw_private *vmw_priv, | |
441 | struct vmw_dma_buffer *bo, | |
442 | struct ttm_placement *placement, | |
443 | bool interruptible); | |
444 | extern int vmw_dmabuf_to_vram(struct vmw_private *dev_priv, | |
445 | struct vmw_dma_buffer *buf, | |
446 | bool pin, bool interruptible); | |
447 | extern int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv, | |
448 | struct vmw_dma_buffer *buf, | |
449 | bool pin, bool interruptible); | |
450 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, | |
451 | struct vmw_dma_buffer *bo, | |
452 | bool pin, bool interruptible); | |
453 | extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, | |
454 | struct vmw_dma_buffer *bo, | |
455 | bool interruptible); | |
b37a6b9a TH |
456 | extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, |
457 | SVGAGuestPtr *ptr); | |
e2fa3a76 | 458 | extern void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin); |
fb1d9738 JB |
459 | |
460 | /** | |
461 | * Misc Ioctl functionality - vmwgfx_ioctl.c | |
462 | */ | |
463 | ||
464 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |
465 | struct drm_file *file_priv); | |
f63f6a59 TH |
466 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
467 | struct drm_file *file_priv); | |
2fcd5a73 JB |
468 | extern int vmw_present_ioctl(struct drm_device *dev, void *data, |
469 | struct drm_file *file_priv); | |
470 | extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data, | |
471 | struct drm_file *file_priv); | |
5438ae88 TH |
472 | extern unsigned int vmw_fops_poll(struct file *filp, |
473 | struct poll_table_struct *wait); | |
474 | extern ssize_t vmw_fops_read(struct file *filp, char __user *buffer, | |
475 | size_t count, loff_t *offset); | |
fb1d9738 JB |
476 | |
477 | /** | |
478 | * Fifo utilities - vmwgfx_fifo.c | |
479 | */ | |
480 | ||
481 | extern int vmw_fifo_init(struct vmw_private *dev_priv, | |
482 | struct vmw_fifo_state *fifo); | |
483 | extern void vmw_fifo_release(struct vmw_private *dev_priv, | |
484 | struct vmw_fifo_state *fifo); | |
485 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); | |
486 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); | |
487 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, | |
6bcd8d3c | 488 | uint32_t *seqno); |
fb1d9738 | 489 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
8e19a951 | 490 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
d7e1958d | 491 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
e2fa3a76 TH |
492 | extern int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
493 | uint32_t cid); | |
fb1d9738 JB |
494 | |
495 | /** | |
496 | * TTM glue - vmwgfx_ttm_glue.c | |
497 | */ | |
498 | ||
499 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); | |
500 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); | |
501 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); | |
502 | ||
503 | /** | |
504 | * TTM buffer object driver - vmwgfx_buffer.c | |
505 | */ | |
506 | ||
507 | extern struct ttm_placement vmw_vram_placement; | |
508 | extern struct ttm_placement vmw_vram_ne_placement; | |
8ba5152a | 509 | extern struct ttm_placement vmw_vram_sys_placement; |
135cba0d | 510 | extern struct ttm_placement vmw_vram_gmr_placement; |
d991ef03 | 511 | extern struct ttm_placement vmw_vram_gmr_ne_placement; |
fb1d9738 | 512 | extern struct ttm_placement vmw_sys_placement; |
d991ef03 | 513 | extern struct ttm_placement vmw_evictable_placement; |
5bb39e81 | 514 | extern struct ttm_placement vmw_srf_placement; |
fb1d9738 JB |
515 | extern struct ttm_bo_driver vmw_bo_driver; |
516 | extern int vmw_dma_quiescent(struct drm_device *dev); | |
517 | ||
518 | /** | |
519 | * Command submission - vmwgfx_execbuf.c | |
520 | */ | |
521 | ||
522 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, | |
523 | struct drm_file *file_priv); | |
922ade0d TH |
524 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
525 | struct vmw_private *dev_priv, | |
526 | void __user *user_commands, | |
527 | void *kernel_commands, | |
528 | uint32_t command_size, | |
529 | uint64_t throttle_us, | |
530 | struct drm_vmw_fence_rep __user | |
531 | *user_fence_rep); | |
fb1d9738 | 532 | |
e2fa3a76 TH |
533 | extern void |
534 | vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv, | |
535 | bool only_on_cid_match, uint32_t cid); | |
536 | ||
5bb39e81 TH |
537 | extern int vmw_execbuf_fence_commands(struct drm_file *file_priv, |
538 | struct vmw_private *dev_priv, | |
539 | struct vmw_fence_obj **p_fence, | |
540 | uint32_t *p_handle); | |
57c5ee79 TH |
541 | extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, |
542 | struct vmw_fpriv *vmw_fp, | |
543 | int ret, | |
544 | struct drm_vmw_fence_rep __user | |
545 | *user_fence_rep, | |
546 | struct vmw_fence_obj *fence, | |
547 | uint32_t fence_handle); | |
5bb39e81 | 548 | |
fb1d9738 JB |
549 | /** |
550 | * IRQs and wating - vmwgfx_irq.c | |
551 | */ | |
552 | ||
553 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); | |
6bcd8d3c TH |
554 | extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy, |
555 | uint32_t seqno, bool interruptible, | |
556 | unsigned long timeout); | |
fb1d9738 JB |
557 | extern void vmw_irq_preinstall(struct drm_device *dev); |
558 | extern int vmw_irq_postinstall(struct drm_device *dev); | |
559 | extern void vmw_irq_uninstall(struct drm_device *dev); | |
6bcd8d3c TH |
560 | extern bool vmw_seqno_passed(struct vmw_private *dev_priv, |
561 | uint32_t seqno); | |
fb1d9738 JB |
562 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
563 | bool lazy, | |
564 | bool fifo_idle, | |
6bcd8d3c | 565 | uint32_t seqno, |
fb1d9738 JB |
566 | bool interruptible, |
567 | unsigned long timeout); | |
6bcd8d3c | 568 | extern void vmw_update_seqno(struct vmw_private *dev_priv, |
1925d456 | 569 | struct vmw_fifo_state *fifo_state); |
ae2a1040 TH |
570 | extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv); |
571 | extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv); | |
57c5ee79 TH |
572 | extern void vmw_goal_waiter_add(struct vmw_private *dev_priv); |
573 | extern void vmw_goal_waiter_remove(struct vmw_private *dev_priv); | |
1925d456 TH |
574 | |
575 | /** | |
6bcd8d3c TH |
576 | * Rudimentary fence-like objects currently used only for throttling - |
577 | * vmwgfx_marker.c | |
1925d456 TH |
578 | */ |
579 | ||
6bcd8d3c TH |
580 | extern void vmw_marker_queue_init(struct vmw_marker_queue *queue); |
581 | extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue); | |
582 | extern int vmw_marker_push(struct vmw_marker_queue *queue, | |
583 | uint32_t seqno); | |
584 | extern int vmw_marker_pull(struct vmw_marker_queue *queue, | |
585 | uint32_t signaled_seqno); | |
1925d456 | 586 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
6bcd8d3c | 587 | struct vmw_marker_queue *queue, uint32_t us); |
fb1d9738 JB |
588 | |
589 | /** | |
590 | * Kernel framebuffer - vmwgfx_fb.c | |
591 | */ | |
592 | ||
593 | int vmw_fb_init(struct vmw_private *vmw_priv); | |
594 | int vmw_fb_close(struct vmw_private *dev_priv); | |
595 | int vmw_fb_off(struct vmw_private *vmw_priv); | |
596 | int vmw_fb_on(struct vmw_private *vmw_priv); | |
597 | ||
598 | /** | |
599 | * Kernel modesetting - vmwgfx_kms.c | |
600 | */ | |
601 | ||
602 | int vmw_kms_init(struct vmw_private *dev_priv); | |
603 | int vmw_kms_close(struct vmw_private *dev_priv); | |
604 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); | |
605 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); | |
606 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, | |
607 | struct drm_file *file_priv); | |
608 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); | |
609 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |
610 | struct ttm_object_file *tfile, | |
611 | struct ttm_buffer_object *bo, | |
612 | SVGA3dCmdHeader *header); | |
0bef23f9 MD |
613 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
614 | unsigned width, unsigned height, unsigned pitch, | |
615 | unsigned bpp, unsigned depth); | |
3a939a5e | 616 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
e133e737 TH |
617 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
618 | uint32_t pitch, | |
619 | uint32_t height); | |
7a1c2f6c | 620 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
1c482ab3 JB |
621 | int vmw_enable_vblank(struct drm_device *dev, int crtc); |
622 | void vmw_disable_vblank(struct drm_device *dev, int crtc); | |
2fcd5a73 JB |
623 | int vmw_kms_present(struct vmw_private *dev_priv, |
624 | struct drm_file *file_priv, | |
625 | struct vmw_framebuffer *vfb, | |
626 | struct vmw_surface *surface, | |
627 | uint32_t sid, int32_t destX, int32_t destY, | |
628 | struct drm_vmw_rect *clips, | |
629 | uint32_t num_clips); | |
630 | int vmw_kms_readback(struct vmw_private *dev_priv, | |
631 | struct drm_file *file_priv, | |
632 | struct vmw_framebuffer *vfb, | |
633 | struct drm_vmw_fence_rep __user *user_fence_rep, | |
634 | struct drm_vmw_rect *clips, | |
635 | uint32_t num_clips); | |
fb1d9738 JB |
636 | |
637 | /** | |
638 | * Overlay control - vmwgfx_overlay.c | |
639 | */ | |
640 | ||
641 | int vmw_overlay_init(struct vmw_private *dev_priv); | |
642 | int vmw_overlay_close(struct vmw_private *dev_priv); | |
643 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, | |
644 | struct drm_file *file_priv); | |
645 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); | |
646 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); | |
647 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); | |
648 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); | |
649 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); | |
650 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); | |
651 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); | |
652 | ||
135cba0d TH |
653 | /** |
654 | * GMR Id manager | |
655 | */ | |
656 | ||
657 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; | |
658 | ||
fb1d9738 JB |
659 | /** |
660 | * Inline helper functions | |
661 | */ | |
662 | ||
663 | static inline void vmw_surface_unreference(struct vmw_surface **srf) | |
664 | { | |
665 | struct vmw_surface *tmp_srf = *srf; | |
666 | struct vmw_resource *res = &tmp_srf->res; | |
667 | *srf = NULL; | |
668 | ||
669 | vmw_resource_unreference(&res); | |
670 | } | |
671 | ||
672 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) | |
673 | { | |
674 | (void) vmw_resource_reference(&srf->res); | |
675 | return srf; | |
676 | } | |
677 | ||
678 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) | |
679 | { | |
680 | struct vmw_dma_buffer *tmp_buf = *buf; | |
681 | struct ttm_buffer_object *bo = &tmp_buf->base; | |
682 | *buf = NULL; | |
683 | ||
684 | ttm_bo_unref(&bo); | |
685 | } | |
686 | ||
687 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) | |
688 | { | |
689 | if (ttm_bo_reference(&buf->base)) | |
690 | return buf; | |
691 | return NULL; | |
692 | } | |
693 | ||
ae2a1040 TH |
694 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
695 | { | |
696 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; | |
697 | } | |
fb1d9738 | 698 | #endif |