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 | |
2ae7b03c TH |
43 | #define VMWGFX_DRIVER_DATE "20110901" |
44 | #define VMWGFX_DRIVER_MAJOR 2 | |
45 | #define VMWGFX_DRIVER_MINOR 0 | |
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; | |
82 | void (*hw_destroy) (struct vmw_resource *res); | |
83 | void (*res_free) (struct vmw_resource *res); | |
be38ab6e | 84 | bool on_validate_list; |
fb1d9738 JB |
85 | /* TODO is a generic snooper needed? */ |
86 | #if 0 | |
87 | void (*snoop)(struct vmw_resource *res, | |
88 | struct ttm_object_file *tfile, | |
89 | SVGA3dCmdHeader *header); | |
90 | void *snoop_priv; | |
91 | #endif | |
92 | }; | |
93 | ||
94 | struct vmw_cursor_snooper { | |
95 | struct drm_crtc *crtc; | |
96 | size_t age; | |
97 | uint32_t *image; | |
98 | }; | |
99 | ||
100 | struct vmw_surface { | |
101 | struct vmw_resource res; | |
102 | uint32_t flags; | |
103 | uint32_t format; | |
104 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; | |
105 | struct drm_vmw_size *sizes; | |
106 | uint32_t num_sizes; | |
107 | ||
5ffdb658 JB |
108 | bool scanout; |
109 | ||
fb1d9738 JB |
110 | /* TODO so far just a extra pointer */ |
111 | struct vmw_cursor_snooper snooper; | |
112 | }; | |
113 | ||
6bcd8d3c | 114 | struct vmw_marker_queue { |
1925d456 TH |
115 | struct list_head head; |
116 | struct timespec lag; | |
117 | struct timespec lag_time; | |
118 | spinlock_t lock; | |
119 | }; | |
120 | ||
fb1d9738 JB |
121 | struct vmw_fifo_state { |
122 | unsigned long reserved_size; | |
123 | __le32 *dynamic_buffer; | |
124 | __le32 *static_buffer; | |
fb1d9738 JB |
125 | unsigned long static_buffer_size; |
126 | bool using_bounce_buffer; | |
127 | uint32_t capabilities; | |
85b9e487 | 128 | struct mutex fifo_mutex; |
fb1d9738 | 129 | struct rw_semaphore rwsem; |
6bcd8d3c | 130 | struct vmw_marker_queue marker_queue; |
fb1d9738 JB |
131 | }; |
132 | ||
133 | struct vmw_relocation { | |
134 | SVGAGuestPtr *location; | |
135 | uint32_t index; | |
136 | }; | |
137 | ||
138 | struct vmw_sw_context{ | |
139 | struct ida bo_list; | |
140 | uint32_t last_cid; | |
141 | bool cid_valid; | |
922ade0d | 142 | bool kernel; /**< is the called made from the kernel */ |
fb1d9738 | 143 | uint32_t last_sid; |
7a73ba74 | 144 | uint32_t sid_translation; |
fb1d9738 JB |
145 | bool sid_valid; |
146 | struct ttm_object_file *tfile; | |
147 | struct list_head validate_nodes; | |
148 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; | |
149 | uint32_t cur_reloc; | |
be38ab6e | 150 | struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
fb1d9738 | 151 | uint32_t cur_val_buf; |
be38ab6e TH |
152 | uint32_t *cmd_bounce; |
153 | uint32_t cmd_bounce_size; | |
154 | struct vmw_resource *resources[VMWGFX_MAX_VALIDATIONS]; | |
155 | uint32_t num_ref_resources; | |
fb1d9738 JB |
156 | }; |
157 | ||
158 | struct vmw_legacy_display; | |
159 | struct vmw_overlay; | |
160 | ||
161 | struct vmw_master { | |
162 | struct ttm_lock lock; | |
3a939a5e TH |
163 | struct mutex fb_surf_mutex; |
164 | struct list_head fb_surf; | |
fb1d9738 JB |
165 | }; |
166 | ||
7c4f7780 TH |
167 | struct vmw_vga_topology_state { |
168 | uint32_t width; | |
169 | uint32_t height; | |
170 | uint32_t primary; | |
171 | uint32_t pos_x; | |
172 | uint32_t pos_y; | |
173 | }; | |
174 | ||
fb1d9738 JB |
175 | struct vmw_private { |
176 | struct ttm_bo_device bdev; | |
177 | struct ttm_bo_global_ref bo_global_ref; | |
ba4420c2 | 178 | struct drm_global_reference mem_global_ref; |
fb1d9738 JB |
179 | |
180 | struct vmw_fifo_state fifo; | |
181 | ||
182 | struct drm_device *dev; | |
183 | unsigned long vmw_chipset; | |
184 | unsigned int io_start; | |
185 | uint32_t vram_start; | |
186 | uint32_t vram_size; | |
187 | uint32_t mmio_start; | |
188 | uint32_t mmio_size; | |
189 | uint32_t fb_max_width; | |
190 | uint32_t fb_max_height; | |
191 | __le32 __iomem *mmio_virt; | |
192 | int mmio_mtrr; | |
193 | uint32_t capabilities; | |
194 | uint32_t max_gmr_descriptors; | |
195 | uint32_t max_gmr_ids; | |
fb17f189 TH |
196 | uint32_t max_gmr_pages; |
197 | uint32_t memory_size; | |
135cba0d | 198 | bool has_gmr; |
fb1d9738 JB |
199 | struct mutex hw_mutex; |
200 | ||
201 | /* | |
202 | * VGA registers. | |
203 | */ | |
204 | ||
7c4f7780 | 205 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
fb1d9738 JB |
206 | uint32_t vga_width; |
207 | uint32_t vga_height; | |
fb1d9738 | 208 | uint32_t vga_bpp; |
7c4f7780 | 209 | uint32_t vga_bpl; |
d7e1958d | 210 | uint32_t vga_pitchlock; |
fb1d9738 | 211 | |
7c4f7780 TH |
212 | uint32_t num_displays; |
213 | ||
fb1d9738 JB |
214 | /* |
215 | * Framebuffer info. | |
216 | */ | |
217 | ||
218 | void *fb_info; | |
219 | struct vmw_legacy_display *ldu_priv; | |
220 | struct vmw_overlay *overlay_priv; | |
221 | ||
222 | /* | |
223 | * Context and surface management. | |
224 | */ | |
225 | ||
226 | rwlock_t resource_lock; | |
227 | struct idr context_idr; | |
228 | struct idr surface_idr; | |
229 | struct idr stream_idr; | |
230 | ||
231 | /* | |
232 | * Block lastclose from racing with firstopen. | |
233 | */ | |
234 | ||
235 | struct mutex init_mutex; | |
236 | ||
237 | /* | |
238 | * A resource manager for kernel-only surfaces and | |
239 | * contexts. | |
240 | */ | |
241 | ||
242 | struct ttm_object_device *tdev; | |
243 | ||
244 | /* | |
245 | * Fencing and IRQs. | |
246 | */ | |
247 | ||
6bcd8d3c | 248 | atomic_t marker_seq; |
fb1d9738 JB |
249 | wait_queue_head_t fence_queue; |
250 | wait_queue_head_t fifo_queue; | |
4f73a96b | 251 | int fence_queue_waiters; /* Protected by hw_mutex */ |
fb1d9738 | 252 | atomic_t fifo_queue_waiters; |
6bcd8d3c | 253 | uint32_t last_read_seqno; |
fb1d9738 | 254 | spinlock_t irq_lock; |
ae2a1040 | 255 | struct vmw_fence_manager *fman; |
fb1d9738 JB |
256 | |
257 | /* | |
258 | * Device state | |
259 | */ | |
260 | ||
261 | uint32_t traces_state; | |
262 | uint32_t enable_state; | |
263 | uint32_t config_done_state; | |
264 | ||
265 | /** | |
266 | * Execbuf | |
267 | */ | |
268 | /** | |
269 | * Protected by the cmdbuf mutex. | |
270 | */ | |
271 | ||
272 | struct vmw_sw_context ctx; | |
fb1d9738 JB |
273 | struct mutex cmdbuf_mutex; |
274 | ||
fb1d9738 JB |
275 | /** |
276 | * Operating mode. | |
277 | */ | |
278 | ||
279 | bool stealth; | |
280 | bool is_opened; | |
30c78bb8 | 281 | bool enable_fb; |
fb1d9738 JB |
282 | |
283 | /** | |
284 | * Master management. | |
285 | */ | |
286 | ||
287 | struct vmw_master *active_master; | |
288 | struct vmw_master fbdev_master; | |
d9f36a00 | 289 | struct notifier_block pm_nb; |
094e0fa8 | 290 | bool suspended; |
30c78bb8 TH |
291 | |
292 | struct mutex release_mutex; | |
293 | uint32_t num_3d_resources; | |
fb1d9738 JB |
294 | }; |
295 | ||
296 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) | |
297 | { | |
298 | return (struct vmw_private *)dev->dev_private; | |
299 | } | |
300 | ||
301 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) | |
302 | { | |
303 | return (struct vmw_fpriv *)file_priv->driver_priv; | |
304 | } | |
305 | ||
306 | static inline struct vmw_master *vmw_master(struct drm_master *master) | |
307 | { | |
308 | return (struct vmw_master *) master->driver_priv; | |
309 | } | |
310 | ||
311 | static inline void vmw_write(struct vmw_private *dev_priv, | |
312 | unsigned int offset, uint32_t value) | |
313 | { | |
314 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
315 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); | |
316 | } | |
317 | ||
318 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, | |
319 | unsigned int offset) | |
320 | { | |
321 | uint32_t val; | |
322 | ||
323 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
324 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); | |
325 | return val; | |
326 | } | |
327 | ||
05730b32 TH |
328 | int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga); |
329 | void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga); | |
30c78bb8 | 330 | |
fb1d9738 JB |
331 | /** |
332 | * GMR utilities - vmwgfx_gmr.c | |
333 | */ | |
334 | ||
335 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, | |
135cba0d TH |
336 | struct page *pages[], |
337 | unsigned long num_pages, | |
338 | int gmr_id); | |
fb1d9738 JB |
339 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
340 | ||
341 | /** | |
342 | * Resource utilities - vmwgfx_resource.c | |
343 | */ | |
344 | ||
345 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); | |
346 | extern void vmw_resource_unreference(struct vmw_resource **p_res); | |
347 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); | |
348 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, | |
349 | struct drm_file *file_priv); | |
350 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, | |
351 | struct drm_file *file_priv); | |
352 | extern int vmw_context_check(struct vmw_private *dev_priv, | |
353 | struct ttm_object_file *tfile, | |
be38ab6e TH |
354 | int id, |
355 | struct vmw_resource **p_res); | |
fb1d9738 JB |
356 | extern void vmw_surface_res_free(struct vmw_resource *res); |
357 | extern int vmw_surface_init(struct vmw_private *dev_priv, | |
358 | struct vmw_surface *srf, | |
359 | void (*res_free) (struct vmw_resource *res)); | |
7a73ba74 TH |
360 | extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, |
361 | struct ttm_object_file *tfile, | |
362 | uint32_t handle, | |
363 | struct vmw_surface **out); | |
fb1d9738 JB |
364 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
365 | struct drm_file *file_priv); | |
366 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |
367 | struct drm_file *file_priv); | |
368 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |
369 | struct drm_file *file_priv); | |
370 | extern int vmw_surface_check(struct vmw_private *dev_priv, | |
371 | struct ttm_object_file *tfile, | |
7a73ba74 | 372 | uint32_t handle, int *id); |
fb1d9738 JB |
373 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
374 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, | |
375 | struct vmw_dma_buffer *vmw_bo, | |
376 | size_t size, struct ttm_placement *placement, | |
377 | bool interuptable, | |
378 | void (*bo_free) (struct ttm_buffer_object *bo)); | |
379 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | |
380 | struct drm_file *file_priv); | |
381 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, | |
382 | struct drm_file *file_priv); | |
383 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, | |
384 | uint32_t cur_validate_node); | |
385 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); | |
386 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, | |
387 | uint32_t id, struct vmw_dma_buffer **out); | |
fb1d9738 JB |
388 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
389 | struct drm_file *file_priv); | |
390 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, | |
391 | struct drm_file *file_priv); | |
392 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, | |
393 | struct ttm_object_file *tfile, | |
394 | uint32_t *inout_id, | |
395 | struct vmw_resource **out); | |
396 | ||
d991ef03 JB |
397 | /** |
398 | * DMA buffer helper routines - vmwgfx_dmabuf.c | |
399 | */ | |
400 | extern int vmw_dmabuf_to_placement(struct vmw_private *vmw_priv, | |
401 | struct vmw_dma_buffer *bo, | |
402 | struct ttm_placement *placement, | |
403 | bool interruptible); | |
404 | extern int vmw_dmabuf_to_vram(struct vmw_private *dev_priv, | |
405 | struct vmw_dma_buffer *buf, | |
406 | bool pin, bool interruptible); | |
407 | extern int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv, | |
408 | struct vmw_dma_buffer *buf, | |
409 | bool pin, bool interruptible); | |
410 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, | |
411 | struct vmw_dma_buffer *bo, | |
412 | bool pin, bool interruptible); | |
413 | extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, | |
414 | struct vmw_dma_buffer *bo, | |
415 | bool interruptible); | |
416 | extern int vmw_dmabuf_to_system(struct vmw_private *vmw_priv, | |
417 | struct vmw_dma_buffer *bo, | |
418 | bool interruptible); | |
419 | extern void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf, | |
420 | uint32_t *gmrId, uint32_t *offset); | |
421 | extern void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf, | |
422 | SVGAGuestPtr *ptr); | |
fb1d9738 JB |
423 | |
424 | /** | |
425 | * Misc Ioctl functionality - vmwgfx_ioctl.c | |
426 | */ | |
427 | ||
428 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |
429 | struct drm_file *file_priv); | |
f63f6a59 TH |
430 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
431 | struct drm_file *file_priv); | |
fb1d9738 JB |
432 | |
433 | /** | |
434 | * Fifo utilities - vmwgfx_fifo.c | |
435 | */ | |
436 | ||
437 | extern int vmw_fifo_init(struct vmw_private *dev_priv, | |
438 | struct vmw_fifo_state *fifo); | |
439 | extern void vmw_fifo_release(struct vmw_private *dev_priv, | |
440 | struct vmw_fifo_state *fifo); | |
441 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); | |
442 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); | |
443 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, | |
6bcd8d3c | 444 | uint32_t *seqno); |
fb1d9738 | 445 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
8e19a951 | 446 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
d7e1958d | 447 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
fb1d9738 JB |
448 | |
449 | /** | |
450 | * TTM glue - vmwgfx_ttm_glue.c | |
451 | */ | |
452 | ||
453 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); | |
454 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); | |
455 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); | |
456 | ||
457 | /** | |
458 | * TTM buffer object driver - vmwgfx_buffer.c | |
459 | */ | |
460 | ||
461 | extern struct ttm_placement vmw_vram_placement; | |
462 | extern struct ttm_placement vmw_vram_ne_placement; | |
8ba5152a | 463 | extern struct ttm_placement vmw_vram_sys_placement; |
135cba0d | 464 | extern struct ttm_placement vmw_vram_gmr_placement; |
d991ef03 | 465 | extern struct ttm_placement vmw_vram_gmr_ne_placement; |
fb1d9738 | 466 | extern struct ttm_placement vmw_sys_placement; |
d991ef03 | 467 | extern struct ttm_placement vmw_evictable_placement; |
fb1d9738 JB |
468 | extern struct ttm_bo_driver vmw_bo_driver; |
469 | extern int vmw_dma_quiescent(struct drm_device *dev); | |
470 | ||
471 | /** | |
472 | * Command submission - vmwgfx_execbuf.c | |
473 | */ | |
474 | ||
475 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, | |
476 | struct drm_file *file_priv); | |
922ade0d TH |
477 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
478 | struct vmw_private *dev_priv, | |
479 | void __user *user_commands, | |
480 | void *kernel_commands, | |
481 | uint32_t command_size, | |
482 | uint64_t throttle_us, | |
483 | struct drm_vmw_fence_rep __user | |
484 | *user_fence_rep); | |
fb1d9738 JB |
485 | |
486 | /** | |
487 | * IRQs and wating - vmwgfx_irq.c | |
488 | */ | |
489 | ||
490 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); | |
6bcd8d3c TH |
491 | extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy, |
492 | uint32_t seqno, bool interruptible, | |
493 | unsigned long timeout); | |
fb1d9738 JB |
494 | extern void vmw_irq_preinstall(struct drm_device *dev); |
495 | extern int vmw_irq_postinstall(struct drm_device *dev); | |
496 | extern void vmw_irq_uninstall(struct drm_device *dev); | |
6bcd8d3c TH |
497 | extern bool vmw_seqno_passed(struct vmw_private *dev_priv, |
498 | uint32_t seqno); | |
fb1d9738 JB |
499 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
500 | bool lazy, | |
501 | bool fifo_idle, | |
6bcd8d3c | 502 | uint32_t seqno, |
fb1d9738 JB |
503 | bool interruptible, |
504 | unsigned long timeout); | |
6bcd8d3c | 505 | extern void vmw_update_seqno(struct vmw_private *dev_priv, |
1925d456 | 506 | struct vmw_fifo_state *fifo_state); |
ae2a1040 TH |
507 | extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv); |
508 | extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv); | |
1925d456 TH |
509 | |
510 | /** | |
6bcd8d3c TH |
511 | * Rudimentary fence-like objects currently used only for throttling - |
512 | * vmwgfx_marker.c | |
1925d456 TH |
513 | */ |
514 | ||
6bcd8d3c TH |
515 | extern void vmw_marker_queue_init(struct vmw_marker_queue *queue); |
516 | extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue); | |
517 | extern int vmw_marker_push(struct vmw_marker_queue *queue, | |
518 | uint32_t seqno); | |
519 | extern int vmw_marker_pull(struct vmw_marker_queue *queue, | |
520 | uint32_t signaled_seqno); | |
1925d456 | 521 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
6bcd8d3c | 522 | struct vmw_marker_queue *queue, uint32_t us); |
fb1d9738 JB |
523 | |
524 | /** | |
525 | * Kernel framebuffer - vmwgfx_fb.c | |
526 | */ | |
527 | ||
528 | int vmw_fb_init(struct vmw_private *vmw_priv); | |
529 | int vmw_fb_close(struct vmw_private *dev_priv); | |
530 | int vmw_fb_off(struct vmw_private *vmw_priv); | |
531 | int vmw_fb_on(struct vmw_private *vmw_priv); | |
532 | ||
533 | /** | |
534 | * Kernel modesetting - vmwgfx_kms.c | |
535 | */ | |
536 | ||
537 | int vmw_kms_init(struct vmw_private *dev_priv); | |
538 | int vmw_kms_close(struct vmw_private *dev_priv); | |
539 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); | |
540 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); | |
541 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, | |
542 | struct drm_file *file_priv); | |
543 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); | |
544 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |
545 | struct ttm_object_file *tfile, | |
546 | struct ttm_buffer_object *bo, | |
547 | SVGA3dCmdHeader *header); | |
0bef23f9 MD |
548 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
549 | unsigned width, unsigned height, unsigned pitch, | |
550 | unsigned bpp, unsigned depth); | |
3a939a5e | 551 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
e133e737 TH |
552 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
553 | uint32_t pitch, | |
554 | uint32_t height); | |
7a1c2f6c | 555 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
fb1d9738 JB |
556 | |
557 | /** | |
558 | * Overlay control - vmwgfx_overlay.c | |
559 | */ | |
560 | ||
561 | int vmw_overlay_init(struct vmw_private *dev_priv); | |
562 | int vmw_overlay_close(struct vmw_private *dev_priv); | |
563 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, | |
564 | struct drm_file *file_priv); | |
565 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); | |
566 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); | |
567 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); | |
568 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); | |
569 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); | |
570 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); | |
571 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); | |
572 | ||
135cba0d TH |
573 | /** |
574 | * GMR Id manager | |
575 | */ | |
576 | ||
577 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; | |
578 | ||
fb1d9738 JB |
579 | /** |
580 | * Inline helper functions | |
581 | */ | |
582 | ||
583 | static inline void vmw_surface_unreference(struct vmw_surface **srf) | |
584 | { | |
585 | struct vmw_surface *tmp_srf = *srf; | |
586 | struct vmw_resource *res = &tmp_srf->res; | |
587 | *srf = NULL; | |
588 | ||
589 | vmw_resource_unreference(&res); | |
590 | } | |
591 | ||
592 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) | |
593 | { | |
594 | (void) vmw_resource_reference(&srf->res); | |
595 | return srf; | |
596 | } | |
597 | ||
598 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) | |
599 | { | |
600 | struct vmw_dma_buffer *tmp_buf = *buf; | |
601 | struct ttm_buffer_object *bo = &tmp_buf->base; | |
602 | *buf = NULL; | |
603 | ||
604 | ttm_bo_unref(&bo); | |
605 | } | |
606 | ||
607 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) | |
608 | { | |
609 | if (ttm_bo_reference(&buf->base)) | |
610 | return buf; | |
611 | return NULL; | |
612 | } | |
613 | ||
ae2a1040 TH |
614 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
615 | { | |
616 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; | |
617 | } | |
fb1d9738 | 618 | #endif |