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" | |
41 | ||
a87897ed JB |
42 | #define VMWGFX_DRIVER_DATE "20100209" |
43 | #define VMWGFX_DRIVER_MAJOR 1 | |
d8bd19d2 | 44 | #define VMWGFX_DRIVER_MINOR 2 |
f77cef3d | 45 | #define VMWGFX_DRIVER_PATCHLEVEL 0 |
fb1d9738 JB |
46 | #define VMWGFX_FILE_PAGE_OFFSET 0x00100000 |
47 | #define VMWGFX_FIFO_STATIC_SIZE (1024*1024) | |
48 | #define VMWGFX_MAX_RELOCATIONS 2048 | |
49 | #define VMWGFX_MAX_GMRS 2048 | |
7c4f7780 | 50 | #define VMWGFX_MAX_DISPLAYS 16 |
fb1d9738 JB |
51 | |
52 | struct vmw_fpriv { | |
53 | struct drm_master *locked_master; | |
54 | struct ttm_object_file *tfile; | |
55 | }; | |
56 | ||
57 | struct vmw_dma_buffer { | |
58 | struct ttm_buffer_object base; | |
59 | struct list_head validate_list; | |
60 | struct list_head gmr_lru; | |
61 | uint32_t gmr_id; | |
62 | bool gmr_bound; | |
63 | uint32_t cur_validate_node; | |
64 | bool on_validate_list; | |
65 | }; | |
66 | ||
67 | struct vmw_resource { | |
68 | struct kref kref; | |
69 | struct vmw_private *dev_priv; | |
70 | struct idr *idr; | |
71 | int id; | |
72 | enum ttm_object_type res_type; | |
73 | bool avail; | |
74 | void (*hw_destroy) (struct vmw_resource *res); | |
75 | void (*res_free) (struct vmw_resource *res); | |
76 | ||
77 | /* TODO is a generic snooper needed? */ | |
78 | #if 0 | |
79 | void (*snoop)(struct vmw_resource *res, | |
80 | struct ttm_object_file *tfile, | |
81 | SVGA3dCmdHeader *header); | |
82 | void *snoop_priv; | |
83 | #endif | |
84 | }; | |
85 | ||
86 | struct vmw_cursor_snooper { | |
87 | struct drm_crtc *crtc; | |
88 | size_t age; | |
89 | uint32_t *image; | |
90 | }; | |
91 | ||
92 | struct vmw_surface { | |
93 | struct vmw_resource res; | |
94 | uint32_t flags; | |
95 | uint32_t format; | |
96 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; | |
97 | struct drm_vmw_size *sizes; | |
98 | uint32_t num_sizes; | |
99 | ||
5ffdb658 JB |
100 | bool scanout; |
101 | ||
fb1d9738 JB |
102 | /* TODO so far just a extra pointer */ |
103 | struct vmw_cursor_snooper snooper; | |
104 | }; | |
105 | ||
1925d456 TH |
106 | struct vmw_fence_queue { |
107 | struct list_head head; | |
108 | struct timespec lag; | |
109 | struct timespec lag_time; | |
110 | spinlock_t lock; | |
111 | }; | |
112 | ||
fb1d9738 JB |
113 | struct vmw_fifo_state { |
114 | unsigned long reserved_size; | |
115 | __le32 *dynamic_buffer; | |
116 | __le32 *static_buffer; | |
117 | __le32 *last_buffer; | |
118 | uint32_t last_data_size; | |
119 | uint32_t last_buffer_size; | |
120 | bool last_buffer_add; | |
121 | unsigned long static_buffer_size; | |
122 | bool using_bounce_buffer; | |
123 | uint32_t capabilities; | |
85b9e487 | 124 | struct mutex fifo_mutex; |
fb1d9738 | 125 | struct rw_semaphore rwsem; |
1925d456 | 126 | struct vmw_fence_queue fence_queue; |
fb1d9738 JB |
127 | }; |
128 | ||
129 | struct vmw_relocation { | |
130 | SVGAGuestPtr *location; | |
131 | uint32_t index; | |
132 | }; | |
133 | ||
134 | struct vmw_sw_context{ | |
135 | struct ida bo_list; | |
136 | uint32_t last_cid; | |
137 | bool cid_valid; | |
138 | uint32_t last_sid; | |
7a73ba74 | 139 | uint32_t sid_translation; |
fb1d9738 JB |
140 | bool sid_valid; |
141 | struct ttm_object_file *tfile; | |
142 | struct list_head validate_nodes; | |
143 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; | |
144 | uint32_t cur_reloc; | |
145 | struct ttm_validate_buffer val_bufs[VMWGFX_MAX_GMRS]; | |
146 | uint32_t cur_val_buf; | |
147 | }; | |
148 | ||
149 | struct vmw_legacy_display; | |
150 | struct vmw_overlay; | |
151 | ||
152 | struct vmw_master { | |
153 | struct ttm_lock lock; | |
154 | }; | |
155 | ||
7c4f7780 TH |
156 | struct vmw_vga_topology_state { |
157 | uint32_t width; | |
158 | uint32_t height; | |
159 | uint32_t primary; | |
160 | uint32_t pos_x; | |
161 | uint32_t pos_y; | |
162 | }; | |
163 | ||
fb1d9738 JB |
164 | struct vmw_private { |
165 | struct ttm_bo_device bdev; | |
166 | struct ttm_bo_global_ref bo_global_ref; | |
ba4420c2 | 167 | struct drm_global_reference mem_global_ref; |
fb1d9738 JB |
168 | |
169 | struct vmw_fifo_state fifo; | |
170 | ||
171 | struct drm_device *dev; | |
172 | unsigned long vmw_chipset; | |
173 | unsigned int io_start; | |
174 | uint32_t vram_start; | |
175 | uint32_t vram_size; | |
176 | uint32_t mmio_start; | |
177 | uint32_t mmio_size; | |
178 | uint32_t fb_max_width; | |
179 | uint32_t fb_max_height; | |
180 | __le32 __iomem *mmio_virt; | |
181 | int mmio_mtrr; | |
182 | uint32_t capabilities; | |
183 | uint32_t max_gmr_descriptors; | |
184 | uint32_t max_gmr_ids; | |
185 | struct mutex hw_mutex; | |
186 | ||
187 | /* | |
188 | * VGA registers. | |
189 | */ | |
190 | ||
7c4f7780 | 191 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
fb1d9738 JB |
192 | uint32_t vga_width; |
193 | uint32_t vga_height; | |
194 | uint32_t vga_depth; | |
195 | uint32_t vga_bpp; | |
196 | uint32_t vga_pseudo; | |
197 | uint32_t vga_red_mask; | |
fb1d9738 | 198 | uint32_t vga_green_mask; |
7c4f7780 TH |
199 | uint32_t vga_blue_mask; |
200 | uint32_t vga_bpl; | |
d7e1958d | 201 | uint32_t vga_pitchlock; |
fb1d9738 | 202 | |
7c4f7780 TH |
203 | uint32_t num_displays; |
204 | ||
fb1d9738 JB |
205 | /* |
206 | * Framebuffer info. | |
207 | */ | |
208 | ||
209 | void *fb_info; | |
210 | struct vmw_legacy_display *ldu_priv; | |
211 | struct vmw_overlay *overlay_priv; | |
212 | ||
213 | /* | |
214 | * Context and surface management. | |
215 | */ | |
216 | ||
217 | rwlock_t resource_lock; | |
218 | struct idr context_idr; | |
219 | struct idr surface_idr; | |
220 | struct idr stream_idr; | |
221 | ||
222 | /* | |
223 | * Block lastclose from racing with firstopen. | |
224 | */ | |
225 | ||
226 | struct mutex init_mutex; | |
227 | ||
228 | /* | |
229 | * A resource manager for kernel-only surfaces and | |
230 | * contexts. | |
231 | */ | |
232 | ||
233 | struct ttm_object_device *tdev; | |
234 | ||
235 | /* | |
236 | * Fencing and IRQs. | |
237 | */ | |
238 | ||
85b9e487 | 239 | atomic_t fence_seq; |
fb1d9738 JB |
240 | wait_queue_head_t fence_queue; |
241 | wait_queue_head_t fifo_queue; | |
242 | atomic_t fence_queue_waiters; | |
243 | atomic_t fifo_queue_waiters; | |
244 | uint32_t last_read_sequence; | |
245 | spinlock_t irq_lock; | |
246 | ||
247 | /* | |
248 | * Device state | |
249 | */ | |
250 | ||
251 | uint32_t traces_state; | |
252 | uint32_t enable_state; | |
253 | uint32_t config_done_state; | |
254 | ||
255 | /** | |
256 | * Execbuf | |
257 | */ | |
258 | /** | |
259 | * Protected by the cmdbuf mutex. | |
260 | */ | |
261 | ||
262 | struct vmw_sw_context ctx; | |
263 | uint32_t val_seq; | |
264 | struct mutex cmdbuf_mutex; | |
265 | ||
266 | /** | |
267 | * GMR management. Protected by the lru spinlock. | |
268 | */ | |
269 | ||
270 | struct ida gmr_ida; | |
271 | struct list_head gmr_lru; | |
272 | ||
273 | ||
274 | /** | |
275 | * Operating mode. | |
276 | */ | |
277 | ||
278 | bool stealth; | |
279 | bool is_opened; | |
30c78bb8 | 280 | bool enable_fb; |
fb1d9738 JB |
281 | |
282 | /** | |
283 | * Master management. | |
284 | */ | |
285 | ||
286 | struct vmw_master *active_master; | |
287 | struct vmw_master fbdev_master; | |
d9f36a00 | 288 | struct notifier_block pm_nb; |
094e0fa8 | 289 | bool suspended; |
30c78bb8 TH |
290 | |
291 | struct mutex release_mutex; | |
292 | uint32_t num_3d_resources; | |
fb1d9738 JB |
293 | }; |
294 | ||
295 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) | |
296 | { | |
297 | return (struct vmw_private *)dev->dev_private; | |
298 | } | |
299 | ||
300 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) | |
301 | { | |
302 | return (struct vmw_fpriv *)file_priv->driver_priv; | |
303 | } | |
304 | ||
305 | static inline struct vmw_master *vmw_master(struct drm_master *master) | |
306 | { | |
307 | return (struct vmw_master *) master->driver_priv; | |
308 | } | |
309 | ||
310 | static inline void vmw_write(struct vmw_private *dev_priv, | |
311 | unsigned int offset, uint32_t value) | |
312 | { | |
313 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
314 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); | |
315 | } | |
316 | ||
317 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, | |
318 | unsigned int offset) | |
319 | { | |
320 | uint32_t val; | |
321 | ||
322 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); | |
323 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); | |
324 | return val; | |
325 | } | |
326 | ||
30c78bb8 TH |
327 | int vmw_3d_resource_inc(struct vmw_private *dev_priv); |
328 | void vmw_3d_resource_dec(struct vmw_private *dev_priv); | |
329 | ||
fb1d9738 JB |
330 | /** |
331 | * GMR utilities - vmwgfx_gmr.c | |
332 | */ | |
333 | ||
334 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, | |
335 | struct ttm_buffer_object *bo); | |
336 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); | |
337 | ||
338 | /** | |
339 | * Resource utilities - vmwgfx_resource.c | |
340 | */ | |
341 | ||
342 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); | |
343 | extern void vmw_resource_unreference(struct vmw_resource **p_res); | |
344 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); | |
345 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, | |
346 | struct drm_file *file_priv); | |
347 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, | |
348 | struct drm_file *file_priv); | |
349 | extern int vmw_context_check(struct vmw_private *dev_priv, | |
350 | struct ttm_object_file *tfile, | |
351 | int id); | |
352 | extern void vmw_surface_res_free(struct vmw_resource *res); | |
353 | extern int vmw_surface_init(struct vmw_private *dev_priv, | |
354 | struct vmw_surface *srf, | |
355 | void (*res_free) (struct vmw_resource *res)); | |
7a73ba74 TH |
356 | extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, |
357 | struct ttm_object_file *tfile, | |
358 | uint32_t handle, | |
359 | struct vmw_surface **out); | |
fb1d9738 JB |
360 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
361 | struct drm_file *file_priv); | |
362 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |
363 | struct drm_file *file_priv); | |
364 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |
365 | struct drm_file *file_priv); | |
366 | extern int vmw_surface_check(struct vmw_private *dev_priv, | |
367 | struct ttm_object_file *tfile, | |
7a73ba74 | 368 | uint32_t handle, int *id); |
fb1d9738 JB |
369 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
370 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, | |
371 | struct vmw_dma_buffer *vmw_bo, | |
372 | size_t size, struct ttm_placement *placement, | |
373 | bool interuptable, | |
374 | void (*bo_free) (struct ttm_buffer_object *bo)); | |
375 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | |
376 | struct drm_file *file_priv); | |
377 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, | |
378 | struct drm_file *file_priv); | |
379 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, | |
380 | uint32_t cur_validate_node); | |
381 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); | |
382 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, | |
383 | uint32_t id, struct vmw_dma_buffer **out); | |
384 | extern uint32_t vmw_dmabuf_gmr(struct ttm_buffer_object *bo); | |
385 | extern void vmw_dmabuf_set_gmr(struct ttm_buffer_object *bo, uint32_t id); | |
386 | extern int vmw_gmr_id_alloc(struct vmw_private *dev_priv, uint32_t *p_id); | |
387 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, | |
388 | struct vmw_dma_buffer *bo); | |
389 | extern int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv, | |
390 | struct vmw_dma_buffer *bo); | |
effe1105 | 391 | extern void vmw_dmabuf_gmr_unbind(struct ttm_buffer_object *bo); |
fb1d9738 JB |
392 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
393 | struct drm_file *file_priv); | |
394 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, | |
395 | struct drm_file *file_priv); | |
396 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, | |
397 | struct ttm_object_file *tfile, | |
398 | uint32_t *inout_id, | |
399 | struct vmw_resource **out); | |
400 | ||
401 | ||
402 | /** | |
403 | * Misc Ioctl functionality - vmwgfx_ioctl.c | |
404 | */ | |
405 | ||
406 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |
407 | struct drm_file *file_priv); | |
408 | extern int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data, | |
409 | struct drm_file *file_priv); | |
410 | ||
411 | /** | |
412 | * Fifo utilities - vmwgfx_fifo.c | |
413 | */ | |
414 | ||
415 | extern int vmw_fifo_init(struct vmw_private *dev_priv, | |
416 | struct vmw_fifo_state *fifo); | |
417 | extern void vmw_fifo_release(struct vmw_private *dev_priv, | |
418 | struct vmw_fifo_state *fifo); | |
419 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); | |
420 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); | |
421 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, | |
422 | uint32_t *sequence); | |
423 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); | |
424 | extern int vmw_fifo_mmap(struct file *filp, struct vm_area_struct *vma); | |
8e19a951 | 425 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
d7e1958d | 426 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
fb1d9738 JB |
427 | |
428 | /** | |
429 | * TTM glue - vmwgfx_ttm_glue.c | |
430 | */ | |
431 | ||
432 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); | |
433 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); | |
434 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); | |
435 | ||
436 | /** | |
437 | * TTM buffer object driver - vmwgfx_buffer.c | |
438 | */ | |
439 | ||
440 | extern struct ttm_placement vmw_vram_placement; | |
441 | extern struct ttm_placement vmw_vram_ne_placement; | |
8ba5152a | 442 | extern struct ttm_placement vmw_vram_sys_placement; |
fb1d9738 JB |
443 | extern struct ttm_placement vmw_sys_placement; |
444 | extern struct ttm_bo_driver vmw_bo_driver; | |
445 | extern int vmw_dma_quiescent(struct drm_device *dev); | |
446 | ||
447 | /** | |
448 | * Command submission - vmwgfx_execbuf.c | |
449 | */ | |
450 | ||
451 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, | |
452 | struct drm_file *file_priv); | |
453 | ||
454 | /** | |
455 | * IRQs and wating - vmwgfx_irq.c | |
456 | */ | |
457 | ||
458 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); | |
459 | extern int vmw_wait_fence(struct vmw_private *dev_priv, bool lazy, | |
460 | uint32_t sequence, bool interruptible, | |
461 | unsigned long timeout); | |
462 | extern void vmw_irq_preinstall(struct drm_device *dev); | |
463 | extern int vmw_irq_postinstall(struct drm_device *dev); | |
464 | extern void vmw_irq_uninstall(struct drm_device *dev); | |
465 | extern bool vmw_fence_signaled(struct vmw_private *dev_priv, | |
466 | uint32_t sequence); | |
467 | extern int vmw_fence_wait_ioctl(struct drm_device *dev, void *data, | |
468 | struct drm_file *file_priv); | |
469 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, | |
470 | bool lazy, | |
471 | bool fifo_idle, | |
472 | uint32_t sequence, | |
473 | bool interruptible, | |
474 | unsigned long timeout); | |
1925d456 TH |
475 | extern void vmw_update_sequence(struct vmw_private *dev_priv, |
476 | struct vmw_fifo_state *fifo_state); | |
477 | ||
478 | ||
479 | /** | |
480 | * Rudimentary fence objects currently used only for throttling - | |
481 | * vmwgfx_fence.c | |
482 | */ | |
483 | ||
484 | extern void vmw_fence_queue_init(struct vmw_fence_queue *queue); | |
485 | extern void vmw_fence_queue_takedown(struct vmw_fence_queue *queue); | |
486 | extern int vmw_fence_push(struct vmw_fence_queue *queue, | |
487 | uint32_t sequence); | |
488 | extern int vmw_fence_pull(struct vmw_fence_queue *queue, | |
489 | uint32_t signaled_sequence); | |
490 | extern int vmw_wait_lag(struct vmw_private *dev_priv, | |
491 | struct vmw_fence_queue *queue, uint32_t us); | |
fb1d9738 JB |
492 | |
493 | /** | |
494 | * Kernel framebuffer - vmwgfx_fb.c | |
495 | */ | |
496 | ||
497 | int vmw_fb_init(struct vmw_private *vmw_priv); | |
498 | int vmw_fb_close(struct vmw_private *dev_priv); | |
499 | int vmw_fb_off(struct vmw_private *vmw_priv); | |
500 | int vmw_fb_on(struct vmw_private *vmw_priv); | |
501 | ||
502 | /** | |
503 | * Kernel modesetting - vmwgfx_kms.c | |
504 | */ | |
505 | ||
506 | int vmw_kms_init(struct vmw_private *dev_priv); | |
507 | int vmw_kms_close(struct vmw_private *dev_priv); | |
508 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); | |
509 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); | |
510 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, | |
511 | struct drm_file *file_priv); | |
512 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); | |
513 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, | |
514 | struct ttm_object_file *tfile, | |
515 | struct ttm_buffer_object *bo, | |
516 | SVGA3dCmdHeader *header); | |
d7e1958d JB |
517 | void vmw_kms_write_svga(struct vmw_private *vmw_priv, |
518 | unsigned width, unsigned height, unsigned pitch, | |
519 | unsigned bbp, unsigned depth); | |
d8bd19d2 JB |
520 | int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, |
521 | struct drm_file *file_priv); | |
7a1c2f6c | 522 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
fb1d9738 JB |
523 | |
524 | /** | |
525 | * Overlay control - vmwgfx_overlay.c | |
526 | */ | |
527 | ||
528 | int vmw_overlay_init(struct vmw_private *dev_priv); | |
529 | int vmw_overlay_close(struct vmw_private *dev_priv); | |
530 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, | |
531 | struct drm_file *file_priv); | |
532 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); | |
533 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); | |
534 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); | |
535 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); | |
536 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); | |
537 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); | |
538 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); | |
539 | ||
540 | /** | |
541 | * Inline helper functions | |
542 | */ | |
543 | ||
544 | static inline void vmw_surface_unreference(struct vmw_surface **srf) | |
545 | { | |
546 | struct vmw_surface *tmp_srf = *srf; | |
547 | struct vmw_resource *res = &tmp_srf->res; | |
548 | *srf = NULL; | |
549 | ||
550 | vmw_resource_unreference(&res); | |
551 | } | |
552 | ||
553 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) | |
554 | { | |
555 | (void) vmw_resource_reference(&srf->res); | |
556 | return srf; | |
557 | } | |
558 | ||
559 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) | |
560 | { | |
561 | struct vmw_dma_buffer *tmp_buf = *buf; | |
562 | struct ttm_buffer_object *bo = &tmp_buf->base; | |
563 | *buf = NULL; | |
564 | ||
565 | ttm_bo_unref(&bo); | |
566 | } | |
567 | ||
568 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) | |
569 | { | |
570 | if (ttm_bo_reference(&buf->base)) | |
571 | return buf; | |
572 | return NULL; | |
573 | } | |
574 | ||
575 | #endif |