blob: 95b75000f0c910a8d5bce68855ab294f59239eff [file] [log] [blame]
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +00001/**************************************************************************
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"
Thomas Hellstromd9f36a02010-01-13 22:28:43 +010035#include "linux/suspend.h"
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000036#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
Thomas Hellstrom8aea5282010-10-05 12:43:09 +020042#define VMWGFX_DRIVER_DATE "20100927"
Jakob Bornecrantza87897e2010-02-09 21:29:47 +000043#define VMWGFX_DRIVER_MAJOR 1
Thomas Hellstrom8aea5282010-10-05 12:43:09 +020044#define VMWGFX_DRIVER_MINOR 4
Thomas Hellstromf77cef32010-02-09 19:41:55 +000045#define VMWGFX_DRIVER_PATCHLEVEL 0
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000046#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
47#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
48#define VMWGFX_MAX_RELOCATIONS 2048
Thomas Hellstrombe38ab62011-08-31 07:42:54 +000049#define VMWGFX_MAX_VALIDATIONS 2048
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +020050#define VMWGFX_MAX_DISPLAYS 16
Thomas Hellstrombe38ab62011-08-31 07:42:54 +000051#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000052
Thomas Hellstrom135cba02010-10-26 21:21:47 +020053#define VMW_PL_GMR TTM_PL_PRIV0
54#define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0
55
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000056struct vmw_fpriv {
57 struct drm_master *locked_master;
58 struct ttm_object_file *tfile;
59};
60
61struct vmw_dma_buffer {
62 struct ttm_buffer_object base;
63 struct list_head validate_list;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000064 bool gmr_bound;
65 uint32_t cur_validate_node;
66 bool on_validate_list;
67};
68
69struct vmw_resource {
70 struct kref kref;
71 struct vmw_private *dev_priv;
72 struct idr *idr;
73 int id;
74 enum ttm_object_type res_type;
75 bool avail;
76 void (*hw_destroy) (struct vmw_resource *res);
77 void (*res_free) (struct vmw_resource *res);
Thomas Hellstrombe38ab62011-08-31 07:42:54 +000078 bool on_validate_list;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000079 /* TODO is a generic snooper needed? */
80#if 0
81 void (*snoop)(struct vmw_resource *res,
82 struct ttm_object_file *tfile,
83 SVGA3dCmdHeader *header);
84 void *snoop_priv;
85#endif
86};
87
88struct vmw_cursor_snooper {
89 struct drm_crtc *crtc;
90 size_t age;
91 uint32_t *image;
92};
93
94struct vmw_surface {
95 struct vmw_resource res;
96 uint32_t flags;
97 uint32_t format;
98 uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
99 struct drm_vmw_size *sizes;
100 uint32_t num_sizes;
101
Jakob Bornecrantz5ffdb652010-01-30 03:38:08 +0000102 bool scanout;
103
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000104 /* TODO so far just a extra pointer */
105 struct vmw_cursor_snooper snooper;
106};
107
Thomas Hellstrom1925d452010-05-28 11:21:57 +0200108struct vmw_fence_queue {
109 struct list_head head;
110 struct timespec lag;
111 struct timespec lag_time;
112 spinlock_t lock;
113};
114
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000115struct vmw_fifo_state {
116 unsigned long reserved_size;
117 __le32 *dynamic_buffer;
118 __le32 *static_buffer;
119 __le32 *last_buffer;
120 uint32_t last_data_size;
121 uint32_t last_buffer_size;
122 bool last_buffer_add;
123 unsigned long static_buffer_size;
124 bool using_bounce_buffer;
125 uint32_t capabilities;
Thomas Hellstrom85b9e482010-02-08 09:57:25 +0000126 struct mutex fifo_mutex;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000127 struct rw_semaphore rwsem;
Thomas Hellstrom1925d452010-05-28 11:21:57 +0200128 struct vmw_fence_queue fence_queue;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000129};
130
131struct vmw_relocation {
132 SVGAGuestPtr *location;
133 uint32_t index;
134};
135
136struct vmw_sw_context{
137 struct ida bo_list;
138 uint32_t last_cid;
139 bool cid_valid;
140 uint32_t last_sid;
Thomas Hellstrom7a73ba72009-12-22 16:53:41 +0100141 uint32_t sid_translation;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000142 bool sid_valid;
143 struct ttm_object_file *tfile;
144 struct list_head validate_nodes;
145 struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS];
146 uint32_t cur_reloc;
Thomas Hellstrombe38ab62011-08-31 07:42:54 +0000147 struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS];
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000148 uint32_t cur_val_buf;
Thomas Hellstrombe38ab62011-08-31 07:42:54 +0000149 uint32_t *cmd_bounce;
150 uint32_t cmd_bounce_size;
151 struct vmw_resource *resources[VMWGFX_MAX_VALIDATIONS];
152 uint32_t num_ref_resources;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000153};
154
155struct vmw_legacy_display;
156struct vmw_overlay;
157
158struct vmw_master {
159 struct ttm_lock lock;
Thomas Hellstrom3a939a52010-10-05 12:43:03 +0200160 struct mutex fb_surf_mutex;
161 struct list_head fb_surf;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000162};
163
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200164struct vmw_vga_topology_state {
165 uint32_t width;
166 uint32_t height;
167 uint32_t primary;
168 uint32_t pos_x;
169 uint32_t pos_y;
170};
171
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000172struct vmw_private {
173 struct ttm_bo_device bdev;
174 struct ttm_bo_global_ref bo_global_ref;
Dave Airlieba4420c2010-03-09 10:56:52 +1000175 struct drm_global_reference mem_global_ref;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000176
177 struct vmw_fifo_state fifo;
178
179 struct drm_device *dev;
180 unsigned long vmw_chipset;
181 unsigned int io_start;
182 uint32_t vram_start;
183 uint32_t vram_size;
184 uint32_t mmio_start;
185 uint32_t mmio_size;
186 uint32_t fb_max_width;
187 uint32_t fb_max_height;
188 __le32 __iomem *mmio_virt;
189 int mmio_mtrr;
190 uint32_t capabilities;
191 uint32_t max_gmr_descriptors;
192 uint32_t max_gmr_ids;
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200193 bool has_gmr;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000194 struct mutex hw_mutex;
195
196 /*
197 * VGA registers.
198 */
199
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200200 struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS];
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000201 uint32_t vga_width;
202 uint32_t vga_height;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000203 uint32_t vga_bpp;
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200204 uint32_t vga_bpl;
Jakob Bornecrantzd7e19582010-05-28 11:21:59 +0200205 uint32_t vga_pitchlock;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000206
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200207 uint32_t num_displays;
208
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000209 /*
210 * Framebuffer info.
211 */
212
213 void *fb_info;
214 struct vmw_legacy_display *ldu_priv;
215 struct vmw_overlay *overlay_priv;
216
217 /*
218 * Context and surface management.
219 */
220
221 rwlock_t resource_lock;
222 struct idr context_idr;
223 struct idr surface_idr;
224 struct idr stream_idr;
225
226 /*
227 * Block lastclose from racing with firstopen.
228 */
229
230 struct mutex init_mutex;
231
232 /*
233 * A resource manager for kernel-only surfaces and
234 * contexts.
235 */
236
237 struct ttm_object_device *tdev;
238
239 /*
240 * Fencing and IRQs.
241 */
242
Thomas Hellstrom85b9e482010-02-08 09:57:25 +0000243 atomic_t fence_seq;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000244 wait_queue_head_t fence_queue;
245 wait_queue_head_t fifo_queue;
246 atomic_t fence_queue_waiters;
247 atomic_t fifo_queue_waiters;
248 uint32_t last_read_sequence;
249 spinlock_t irq_lock;
250
251 /*
252 * Device state
253 */
254
255 uint32_t traces_state;
256 uint32_t enable_state;
257 uint32_t config_done_state;
258
259 /**
260 * Execbuf
261 */
262 /**
263 * Protected by the cmdbuf mutex.
264 */
265
266 struct vmw_sw_context ctx;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000267 struct mutex cmdbuf_mutex;
268
269 /**
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000270 * Operating mode.
271 */
272
273 bool stealth;
274 bool is_opened;
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200275 bool enable_fb;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000276
277 /**
278 * Master management.
279 */
280
281 struct vmw_master *active_master;
282 struct vmw_master fbdev_master;
Thomas Hellstromd9f36a02010-01-13 22:28:43 +0100283 struct notifier_block pm_nb;
Thomas Hellstrom094e0fa2010-10-05 12:43:00 +0200284 bool suspended;
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200285
286 struct mutex release_mutex;
287 uint32_t num_3d_resources;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000288};
289
290static inline struct vmw_private *vmw_priv(struct drm_device *dev)
291{
292 return (struct vmw_private *)dev->dev_private;
293}
294
295static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv)
296{
297 return (struct vmw_fpriv *)file_priv->driver_priv;
298}
299
300static inline struct vmw_master *vmw_master(struct drm_master *master)
301{
302 return (struct vmw_master *) master->driver_priv;
303}
304
305static inline void vmw_write(struct vmw_private *dev_priv,
306 unsigned int offset, uint32_t value)
307{
308 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
309 outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT);
310}
311
312static inline uint32_t vmw_read(struct vmw_private *dev_priv,
313 unsigned int offset)
314{
315 uint32_t val;
316
317 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
318 val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT);
319 return val;
320}
321
Thomas Hellstrom05730b32011-08-31 07:42:52 +0000322int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga);
323void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga);
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200324
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000325/**
326 * GMR utilities - vmwgfx_gmr.c
327 */
328
329extern int vmw_gmr_bind(struct vmw_private *dev_priv,
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200330 struct page *pages[],
331 unsigned long num_pages,
332 int gmr_id);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000333extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
334
335/**
336 * Resource utilities - vmwgfx_resource.c
337 */
338
339extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv);
340extern void vmw_resource_unreference(struct vmw_resource **p_res);
341extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
342extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
343 struct drm_file *file_priv);
344extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
345 struct drm_file *file_priv);
346extern int vmw_context_check(struct vmw_private *dev_priv,
347 struct ttm_object_file *tfile,
Thomas Hellstrombe38ab62011-08-31 07:42:54 +0000348 int id,
349 struct vmw_resource **p_res);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000350extern void vmw_surface_res_free(struct vmw_resource *res);
351extern int vmw_surface_init(struct vmw_private *dev_priv,
352 struct vmw_surface *srf,
353 void (*res_free) (struct vmw_resource *res));
Thomas Hellstrom7a73ba72009-12-22 16:53:41 +0100354extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv,
355 struct ttm_object_file *tfile,
356 uint32_t handle,
357 struct vmw_surface **out);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000358extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
359 struct drm_file *file_priv);
360extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
361 struct drm_file *file_priv);
362extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
363 struct drm_file *file_priv);
364extern int vmw_surface_check(struct vmw_private *dev_priv,
365 struct ttm_object_file *tfile,
Thomas Hellstrom7a73ba72009-12-22 16:53:41 +0100366 uint32_t handle, int *id);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000367extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo);
368extern int vmw_dmabuf_init(struct vmw_private *dev_priv,
369 struct vmw_dma_buffer *vmw_bo,
370 size_t size, struct ttm_placement *placement,
371 bool interuptable,
372 void (*bo_free) (struct ttm_buffer_object *bo));
373extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
374 struct drm_file *file_priv);
375extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
376 struct drm_file *file_priv);
377extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
378 uint32_t cur_validate_node);
379extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
380extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
381 uint32_t id, struct vmw_dma_buffer **out);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000382extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
383 struct vmw_dma_buffer *bo);
384extern int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv,
385 struct vmw_dma_buffer *bo);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000386extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
387 struct drm_file *file_priv);
388extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
389 struct drm_file *file_priv);
390extern int vmw_user_stream_lookup(struct vmw_private *dev_priv,
391 struct ttm_object_file *tfile,
392 uint32_t *inout_id,
393 struct vmw_resource **out);
394
395
396/**
397 * Misc Ioctl functionality - vmwgfx_ioctl.c
398 */
399
400extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
401 struct drm_file *file_priv);
402extern int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data,
403 struct drm_file *file_priv);
404
405/**
406 * Fifo utilities - vmwgfx_fifo.c
407 */
408
409extern int vmw_fifo_init(struct vmw_private *dev_priv,
410 struct vmw_fifo_state *fifo);
411extern void vmw_fifo_release(struct vmw_private *dev_priv,
412 struct vmw_fifo_state *fifo);
413extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes);
414extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
415extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
416 uint32_t *sequence);
417extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
418extern int vmw_fifo_mmap(struct file *filp, struct vm_area_struct *vma);
Jakob Bornecrantz8e19a952010-01-30 03:38:06 +0000419extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv);
Jakob Bornecrantzd7e19582010-05-28 11:21:59 +0200420extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000421
422/**
423 * TTM glue - vmwgfx_ttm_glue.c
424 */
425
426extern int vmw_ttm_global_init(struct vmw_private *dev_priv);
427extern void vmw_ttm_global_release(struct vmw_private *dev_priv);
428extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma);
429
430/**
431 * TTM buffer object driver - vmwgfx_buffer.c
432 */
433
434extern struct ttm_placement vmw_vram_placement;
435extern struct ttm_placement vmw_vram_ne_placement;
Thomas Hellstrom8ba51522010-01-16 16:05:05 +0100436extern struct ttm_placement vmw_vram_sys_placement;
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200437extern struct ttm_placement vmw_vram_gmr_placement;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000438extern struct ttm_placement vmw_sys_placement;
439extern struct ttm_bo_driver vmw_bo_driver;
440extern int vmw_dma_quiescent(struct drm_device *dev);
441
442/**
443 * Command submission - vmwgfx_execbuf.c
444 */
445
446extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
447 struct drm_file *file_priv);
448
449/**
450 * IRQs and wating - vmwgfx_irq.c
451 */
452
453extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS);
454extern int vmw_wait_fence(struct vmw_private *dev_priv, bool lazy,
455 uint32_t sequence, bool interruptible,
456 unsigned long timeout);
457extern void vmw_irq_preinstall(struct drm_device *dev);
458extern int vmw_irq_postinstall(struct drm_device *dev);
459extern void vmw_irq_uninstall(struct drm_device *dev);
460extern bool vmw_fence_signaled(struct vmw_private *dev_priv,
461 uint32_t sequence);
462extern int vmw_fence_wait_ioctl(struct drm_device *dev, void *data,
463 struct drm_file *file_priv);
464extern int vmw_fallback_wait(struct vmw_private *dev_priv,
465 bool lazy,
466 bool fifo_idle,
467 uint32_t sequence,
468 bool interruptible,
469 unsigned long timeout);
Thomas Hellstrom1925d452010-05-28 11:21:57 +0200470extern void vmw_update_sequence(struct vmw_private *dev_priv,
471 struct vmw_fifo_state *fifo_state);
472
473
474/**
475 * Rudimentary fence objects currently used only for throttling -
476 * vmwgfx_fence.c
477 */
478
479extern void vmw_fence_queue_init(struct vmw_fence_queue *queue);
480extern void vmw_fence_queue_takedown(struct vmw_fence_queue *queue);
481extern int vmw_fence_push(struct vmw_fence_queue *queue,
482 uint32_t sequence);
483extern int vmw_fence_pull(struct vmw_fence_queue *queue,
484 uint32_t signaled_sequence);
485extern int vmw_wait_lag(struct vmw_private *dev_priv,
486 struct vmw_fence_queue *queue, uint32_t us);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000487
488/**
489 * Kernel framebuffer - vmwgfx_fb.c
490 */
491
492int vmw_fb_init(struct vmw_private *vmw_priv);
493int vmw_fb_close(struct vmw_private *dev_priv);
494int vmw_fb_off(struct vmw_private *vmw_priv);
495int vmw_fb_on(struct vmw_private *vmw_priv);
496
497/**
498 * Kernel modesetting - vmwgfx_kms.c
499 */
500
501int vmw_kms_init(struct vmw_private *dev_priv);
502int vmw_kms_close(struct vmw_private *dev_priv);
503int vmw_kms_save_vga(struct vmw_private *vmw_priv);
504int vmw_kms_restore_vga(struct vmw_private *vmw_priv);
505int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
506 struct drm_file *file_priv);
507void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv);
508void vmw_kms_cursor_snoop(struct vmw_surface *srf,
509 struct ttm_object_file *tfile,
510 struct ttm_buffer_object *bo,
511 SVGA3dCmdHeader *header);
Michel Dänzer0bef23f2011-08-31 07:42:50 +0000512int vmw_kms_write_svga(struct vmw_private *vmw_priv,
513 unsigned width, unsigned height, unsigned pitch,
514 unsigned bpp, unsigned depth);
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200515int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
516 struct drm_file *file_priv);
Thomas Hellstrom3a939a52010-10-05 12:43:03 +0200517void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
Thomas Hellstrome133e732010-10-05 12:43:04 +0200518bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
519 uint32_t pitch,
520 uint32_t height);
Thomas Hellstrom7a1c2f62010-10-01 10:21:49 +0200521u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000522
523/**
524 * Overlay control - vmwgfx_overlay.c
525 */
526
527int vmw_overlay_init(struct vmw_private *dev_priv);
528int vmw_overlay_close(struct vmw_private *dev_priv);
529int vmw_overlay_ioctl(struct drm_device *dev, void *data,
530 struct drm_file *file_priv);
531int vmw_overlay_stop_all(struct vmw_private *dev_priv);
532int vmw_overlay_resume_all(struct vmw_private *dev_priv);
533int vmw_overlay_pause_all(struct vmw_private *dev_priv);
534int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out);
535int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id);
536int vmw_overlay_num_overlays(struct vmw_private *dev_priv);
537int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
538
539/**
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200540 * GMR Id manager
541 */
542
543extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
544
545/**
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000546 * Inline helper functions
547 */
548
549static inline void vmw_surface_unreference(struct vmw_surface **srf)
550{
551 struct vmw_surface *tmp_srf = *srf;
552 struct vmw_resource *res = &tmp_srf->res;
553 *srf = NULL;
554
555 vmw_resource_unreference(&res);
556}
557
558static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf)
559{
560 (void) vmw_resource_reference(&srf->res);
561 return srf;
562}
563
564static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf)
565{
566 struct vmw_dma_buffer *tmp_buf = *buf;
567 struct ttm_buffer_object *bo = &tmp_buf->base;
568 *buf = NULL;
569
570 ttm_bo_unref(&bo);
571}
572
573static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf)
574{
575 if (ttm_bo_reference(&buf->base))
576 return buf;
577 return NULL;
578}
579
580#endif