Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / gpu / drm / vmwgfx / vmwgfx_drv.h
blobdc279706ca7027d100761be6a45c54d9001534ac
1 /**************************************************************************
3 * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
4 * All Rights Reserved.
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:
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.
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.
26 **************************************************************************/
28 #ifndef _VMWGFX_DRV_H_
29 #define _VMWGFX_DRV_H_
31 #include "vmwgfx_reg.h"
32 #include "drmP.h"
33 #include "vmwgfx_drm.h"
34 #include "drm_hashtab.h"
35 #include "linux/suspend.h"
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 #include "vmwgfx_fence.h"
43 #define VMWGFX_DRIVER_DATE "20111025"
44 #define VMWGFX_DRIVER_MAJOR 2
45 #define VMWGFX_DRIVER_MINOR 3
46 #define VMWGFX_DRIVER_PATCHLEVEL 0
47 #define VMWGFX_FILE_PAGE_OFFSET 0x00100000
48 #define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
49 #define VMWGFX_MAX_RELOCATIONS 2048
50 #define VMWGFX_MAX_VALIDATIONS 2048
51 #define VMWGFX_MAX_DISPLAYS 16
52 #define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
54 #define VMW_PL_GMR TTM_PL_PRIV0
55 #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0
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
62 struct vmw_fpriv {
63 struct drm_master *locked_master;
64 struct ttm_object_file *tfile;
67 struct vmw_dma_buffer {
68 struct ttm_buffer_object base;
69 struct list_head validate_list;
70 bool gmr_bound;
71 uint32_t cur_validate_node;
72 bool on_validate_list;
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 (*remove_from_lists) (struct vmw_resource *res);
83 void (*hw_destroy) (struct vmw_resource *res);
84 void (*res_free) (struct vmw_resource *res);
85 struct list_head validate_head;
86 struct list_head query_head; /* Protected by the cmdbuf mutex */
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
96 struct vmw_cursor_snooper {
97 struct drm_crtc *crtc;
98 size_t age;
99 uint32_t *image;
102 struct vmw_framebuffer;
103 struct vmw_surface_offset;
105 struct vmw_surface {
106 struct vmw_resource res;
107 struct list_head lru_head; /* Protected by the resource lock */
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;
114 bool scanout;
116 /* TODO so far just a extra pointer */
117 struct vmw_cursor_snooper snooper;
118 struct ttm_buffer_object *backup;
119 struct vmw_surface_offset *offsets;
120 uint32_t backup_size;
123 struct vmw_marker_queue {
124 struct list_head head;
125 struct timespec lag;
126 struct timespec lag_time;
127 spinlock_t lock;
130 struct vmw_fifo_state {
131 unsigned long reserved_size;
132 __le32 *dynamic_buffer;
133 __le32 *static_buffer;
134 unsigned long static_buffer_size;
135 bool using_bounce_buffer;
136 uint32_t capabilities;
137 struct mutex fifo_mutex;
138 struct rw_semaphore rwsem;
139 struct vmw_marker_queue marker_queue;
142 struct vmw_relocation {
143 SVGAGuestPtr *location;
144 uint32_t index;
147 struct vmw_sw_context{
148 struct ida bo_list;
149 uint32_t last_cid;
150 bool cid_valid;
151 bool kernel; /**< is the called made from the kernel */
152 struct vmw_resource *cur_ctx;
153 uint32_t last_sid;
154 uint32_t sid_translation;
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;
160 struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS];
161 uint32_t cur_val_buf;
162 uint32_t *cmd_bounce;
163 uint32_t cmd_bounce_size;
164 struct list_head resource_list;
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;
172 struct vmw_legacy_display;
173 struct vmw_overlay;
175 struct vmw_master {
176 struct ttm_lock lock;
177 struct mutex fb_surf_mutex;
178 struct list_head fb_surf;
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;
189 struct vmw_private {
190 struct ttm_bo_device bdev;
191 struct ttm_bo_global_ref bo_global_ref;
192 struct drm_global_reference mem_global_ref;
194 struct vmw_fifo_state fifo;
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;
210 uint32_t max_gmr_pages;
211 uint32_t memory_size;
212 bool has_gmr;
213 struct mutex hw_mutex;
216 * VGA registers.
219 struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS];
220 uint32_t vga_width;
221 uint32_t vga_height;
222 uint32_t vga_bpp;
223 uint32_t vga_bpl;
224 uint32_t vga_pitchlock;
226 uint32_t num_displays;
229 * Framebuffer info.
232 void *fb_info;
233 struct vmw_legacy_display *ldu_priv;
234 struct vmw_screen_object_display *sou_priv;
235 struct vmw_overlay *overlay_priv;
238 * Context and surface management.
241 rwlock_t resource_lock;
242 struct idr context_idr;
243 struct idr surface_idr;
244 struct idr stream_idr;
247 * Block lastclose from racing with firstopen.
250 struct mutex init_mutex;
253 * A resource manager for kernel-only surfaces and
254 * contexts.
257 struct ttm_object_device *tdev;
260 * Fencing and IRQs.
263 atomic_t marker_seq;
264 wait_queue_head_t fence_queue;
265 wait_queue_head_t fifo_queue;
266 int fence_queue_waiters; /* Protected by hw_mutex */
267 int goal_queue_waiters; /* Protected by hw_mutex */
268 atomic_t fifo_queue_waiters;
269 uint32_t last_read_seqno;
270 spinlock_t irq_lock;
271 struct vmw_fence_manager *fman;
272 uint32_t irq_mask;
275 * Device state
278 uint32_t traces_state;
279 uint32_t enable_state;
280 uint32_t config_done_state;
283 * Execbuf
286 * Protected by the cmdbuf mutex.
289 struct vmw_sw_context ctx;
290 struct mutex cmdbuf_mutex;
293 * Operating mode.
296 bool stealth;
297 bool is_opened;
298 bool enable_fb;
301 * Master management.
304 struct vmw_master *active_master;
305 struct vmw_master fbdev_master;
306 struct notifier_block pm_nb;
307 bool suspended;
309 struct mutex release_mutex;
310 uint32_t num_3d_resources;
313 * Query processing. These members
314 * are protected by the cmdbuf mutex.
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;
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.
329 struct list_head surface_lru;
330 uint32_t used_memory_size;
333 static inline struct vmw_private *vmw_priv(struct drm_device *dev)
335 return (struct vmw_private *)dev->dev_private;
338 static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv)
340 return (struct vmw_fpriv *)file_priv->driver_priv;
343 static inline struct vmw_master *vmw_master(struct drm_master *master)
345 return (struct vmw_master *) master->driver_priv;
348 static inline void vmw_write(struct vmw_private *dev_priv,
349 unsigned int offset, uint32_t value)
351 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
352 outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT);
355 static inline uint32_t vmw_read(struct vmw_private *dev_priv,
356 unsigned int offset)
358 uint32_t val;
360 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
361 val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT);
362 return val;
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);
369 * GMR utilities - vmwgfx_gmr.c
372 extern int vmw_gmr_bind(struct vmw_private *dev_priv,
373 struct page *pages[],
374 unsigned long num_pages,
375 int gmr_id);
376 extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
379 * Resource utilities - vmwgfx_resource.c
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,
391 int id,
392 struct vmw_resource **p_res);
393 extern int vmw_user_lookup_handle(struct vmw_private *dev_priv,
394 struct ttm_object_file *tfile,
395 uint32_t handle,
396 struct vmw_surface **out_surf,
397 struct vmw_dma_buffer **out_buf);
398 extern void vmw_surface_res_free(struct vmw_resource *res);
399 extern int vmw_surface_init(struct vmw_private *dev_priv,
400 struct vmw_surface *srf,
401 void (*res_free) (struct vmw_resource *res));
402 extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv,
403 struct ttm_object_file *tfile,
404 uint32_t handle,
405 struct vmw_surface **out);
406 extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
407 struct drm_file *file_priv);
408 extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
409 struct drm_file *file_priv);
410 extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
411 struct drm_file *file_priv);
412 extern int vmw_surface_check(struct vmw_private *dev_priv,
413 struct ttm_object_file *tfile,
414 uint32_t handle, int *id);
415 extern int vmw_surface_validate(struct vmw_private *dev_priv,
416 struct vmw_surface *srf);
417 extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo);
418 extern int vmw_dmabuf_init(struct vmw_private *dev_priv,
419 struct vmw_dma_buffer *vmw_bo,
420 size_t size, struct ttm_placement *placement,
421 bool interuptable,
422 void (*bo_free) (struct ttm_buffer_object *bo));
423 extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
424 struct drm_file *file_priv);
425 extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
426 struct drm_file *file_priv);
427 extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
428 uint32_t cur_validate_node);
429 extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
430 extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
431 uint32_t id, struct vmw_dma_buffer **out);
432 extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
433 struct drm_file *file_priv);
434 extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
435 struct drm_file *file_priv);
436 extern int vmw_user_stream_lookup(struct vmw_private *dev_priv,
437 struct ttm_object_file *tfile,
438 uint32_t *inout_id,
439 struct vmw_resource **out);
440 extern void vmw_resource_unreserve(struct list_head *list);
443 * DMA buffer helper routines - vmwgfx_dmabuf.c
445 extern int vmw_dmabuf_to_placement(struct vmw_private *vmw_priv,
446 struct vmw_dma_buffer *bo,
447 struct ttm_placement *placement,
448 bool interruptible);
449 extern int vmw_dmabuf_to_vram(struct vmw_private *dev_priv,
450 struct vmw_dma_buffer *buf,
451 bool pin, bool interruptible);
452 extern int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv,
453 struct vmw_dma_buffer *buf,
454 bool pin, bool interruptible);
455 extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
456 struct vmw_dma_buffer *bo,
457 bool pin, bool interruptible);
458 extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv,
459 struct vmw_dma_buffer *bo,
460 bool interruptible);
461 extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf,
462 SVGAGuestPtr *ptr);
463 extern void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin);
466 * Misc Ioctl functionality - vmwgfx_ioctl.c
469 extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
470 struct drm_file *file_priv);
471 extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
472 struct drm_file *file_priv);
473 extern int vmw_present_ioctl(struct drm_device *dev, void *data,
474 struct drm_file *file_priv);
475 extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
476 struct drm_file *file_priv);
477 extern unsigned int vmw_fops_poll(struct file *filp,
478 struct poll_table_struct *wait);
479 extern ssize_t vmw_fops_read(struct file *filp, char __user *buffer,
480 size_t count, loff_t *offset);
483 * Fifo utilities - vmwgfx_fifo.c
486 extern int vmw_fifo_init(struct vmw_private *dev_priv,
487 struct vmw_fifo_state *fifo);
488 extern void vmw_fifo_release(struct vmw_private *dev_priv,
489 struct vmw_fifo_state *fifo);
490 extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes);
491 extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
492 extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
493 uint32_t *seqno);
494 extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
495 extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv);
496 extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv);
497 extern int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv,
498 uint32_t cid);
501 * TTM glue - vmwgfx_ttm_glue.c
504 extern int vmw_ttm_global_init(struct vmw_private *dev_priv);
505 extern void vmw_ttm_global_release(struct vmw_private *dev_priv);
506 extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma);
509 * TTM buffer object driver - vmwgfx_buffer.c
512 extern struct ttm_placement vmw_vram_placement;
513 extern struct ttm_placement vmw_vram_ne_placement;
514 extern struct ttm_placement vmw_vram_sys_placement;
515 extern struct ttm_placement vmw_vram_gmr_placement;
516 extern struct ttm_placement vmw_vram_gmr_ne_placement;
517 extern struct ttm_placement vmw_sys_placement;
518 extern struct ttm_placement vmw_evictable_placement;
519 extern struct ttm_placement vmw_srf_placement;
520 extern struct ttm_bo_driver vmw_bo_driver;
521 extern int vmw_dma_quiescent(struct drm_device *dev);
524 * Command submission - vmwgfx_execbuf.c
527 extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
528 struct drm_file *file_priv);
529 extern int vmw_execbuf_process(struct drm_file *file_priv,
530 struct vmw_private *dev_priv,
531 void __user *user_commands,
532 void *kernel_commands,
533 uint32_t command_size,
534 uint64_t throttle_us,
535 struct drm_vmw_fence_rep __user
536 *user_fence_rep);
538 extern void
539 vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,
540 bool only_on_cid_match, uint32_t cid);
542 extern int vmw_execbuf_fence_commands(struct drm_file *file_priv,
543 struct vmw_private *dev_priv,
544 struct vmw_fence_obj **p_fence,
545 uint32_t *p_handle);
546 extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
547 struct vmw_fpriv *vmw_fp,
548 int ret,
549 struct drm_vmw_fence_rep __user
550 *user_fence_rep,
551 struct vmw_fence_obj *fence,
552 uint32_t fence_handle);
555 * IRQs and wating - vmwgfx_irq.c
558 extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS);
559 extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy,
560 uint32_t seqno, bool interruptible,
561 unsigned long timeout);
562 extern void vmw_irq_preinstall(struct drm_device *dev);
563 extern int vmw_irq_postinstall(struct drm_device *dev);
564 extern void vmw_irq_uninstall(struct drm_device *dev);
565 extern bool vmw_seqno_passed(struct vmw_private *dev_priv,
566 uint32_t seqno);
567 extern int vmw_fallback_wait(struct vmw_private *dev_priv,
568 bool lazy,
569 bool fifo_idle,
570 uint32_t seqno,
571 bool interruptible,
572 unsigned long timeout);
573 extern void vmw_update_seqno(struct vmw_private *dev_priv,
574 struct vmw_fifo_state *fifo_state);
575 extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv);
576 extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv);
577 extern void vmw_goal_waiter_add(struct vmw_private *dev_priv);
578 extern void vmw_goal_waiter_remove(struct vmw_private *dev_priv);
581 * Rudimentary fence-like objects currently used only for throttling -
582 * vmwgfx_marker.c
585 extern void vmw_marker_queue_init(struct vmw_marker_queue *queue);
586 extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue);
587 extern int vmw_marker_push(struct vmw_marker_queue *queue,
588 uint32_t seqno);
589 extern int vmw_marker_pull(struct vmw_marker_queue *queue,
590 uint32_t signaled_seqno);
591 extern int vmw_wait_lag(struct vmw_private *dev_priv,
592 struct vmw_marker_queue *queue, uint32_t us);
595 * Kernel framebuffer - vmwgfx_fb.c
598 int vmw_fb_init(struct vmw_private *vmw_priv);
599 int vmw_fb_close(struct vmw_private *dev_priv);
600 int vmw_fb_off(struct vmw_private *vmw_priv);
601 int vmw_fb_on(struct vmw_private *vmw_priv);
604 * Kernel modesetting - vmwgfx_kms.c
607 int vmw_kms_init(struct vmw_private *dev_priv);
608 int vmw_kms_close(struct vmw_private *dev_priv);
609 int vmw_kms_save_vga(struct vmw_private *vmw_priv);
610 int vmw_kms_restore_vga(struct vmw_private *vmw_priv);
611 int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
612 struct drm_file *file_priv);
613 void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv);
614 void vmw_kms_cursor_snoop(struct vmw_surface *srf,
615 struct ttm_object_file *tfile,
616 struct ttm_buffer_object *bo,
617 SVGA3dCmdHeader *header);
618 int vmw_kms_write_svga(struct vmw_private *vmw_priv,
619 unsigned width, unsigned height, unsigned pitch,
620 unsigned bpp, unsigned depth);
621 void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
622 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
623 uint32_t pitch,
624 uint32_t height);
625 u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc);
626 int vmw_enable_vblank(struct drm_device *dev, int crtc);
627 void vmw_disable_vblank(struct drm_device *dev, int crtc);
628 int vmw_kms_present(struct vmw_private *dev_priv,
629 struct drm_file *file_priv,
630 struct vmw_framebuffer *vfb,
631 struct vmw_surface *surface,
632 uint32_t sid, int32_t destX, int32_t destY,
633 struct drm_vmw_rect *clips,
634 uint32_t num_clips);
635 int vmw_kms_readback(struct vmw_private *dev_priv,
636 struct drm_file *file_priv,
637 struct vmw_framebuffer *vfb,
638 struct drm_vmw_fence_rep __user *user_fence_rep,
639 struct drm_vmw_rect *clips,
640 uint32_t num_clips);
641 int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
642 struct drm_file *file_priv);
645 * Overlay control - vmwgfx_overlay.c
648 int vmw_overlay_init(struct vmw_private *dev_priv);
649 int vmw_overlay_close(struct vmw_private *dev_priv);
650 int vmw_overlay_ioctl(struct drm_device *dev, void *data,
651 struct drm_file *file_priv);
652 int vmw_overlay_stop_all(struct vmw_private *dev_priv);
653 int vmw_overlay_resume_all(struct vmw_private *dev_priv);
654 int vmw_overlay_pause_all(struct vmw_private *dev_priv);
655 int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out);
656 int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id);
657 int vmw_overlay_num_overlays(struct vmw_private *dev_priv);
658 int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
661 * GMR Id manager
664 extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
667 * Inline helper functions
670 static inline void vmw_surface_unreference(struct vmw_surface **srf)
672 struct vmw_surface *tmp_srf = *srf;
673 struct vmw_resource *res = &tmp_srf->res;
674 *srf = NULL;
676 vmw_resource_unreference(&res);
679 static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf)
681 (void) vmw_resource_reference(&srf->res);
682 return srf;
685 static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf)
687 struct vmw_dma_buffer *tmp_buf = *buf;
688 struct ttm_buffer_object *bo = &tmp_buf->base;
689 *buf = NULL;
691 ttm_bo_unref(&bo);
694 static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf)
696 if (ttm_bo_reference(&buf->base))
697 return buf;
698 return NULL;
701 static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv)
703 return (struct ttm_mem_global *) dev_priv->mem_global_ref.object;
705 #endif