blob: 323fc10de2d6b2bd99ff080b514a27f6466b8880 [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 Hellstromfb17f182011-08-31 07:42:53 +0000193 uint32_t max_gmr_pages;
194 uint32_t memory_size;
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200195 bool has_gmr;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000196 struct mutex hw_mutex;
197
198 /*
199 * VGA registers.
200 */
201
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200202 struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS];
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000203 uint32_t vga_width;
204 uint32_t vga_height;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000205 uint32_t vga_bpp;
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200206 uint32_t vga_bpl;
Jakob Bornecrantzd7e19582010-05-28 11:21:59 +0200207 uint32_t vga_pitchlock;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000208
Thomas Hellstrom7c4f7782010-06-01 11:38:17 +0200209 uint32_t num_displays;
210
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000211 /*
212 * Framebuffer info.
213 */
214
215 void *fb_info;
216 struct vmw_legacy_display *ldu_priv;
217 struct vmw_overlay *overlay_priv;
218
219 /*
220 * Context and surface management.
221 */
222
223 rwlock_t resource_lock;
224 struct idr context_idr;
225 struct idr surface_idr;
226 struct idr stream_idr;
227
228 /*
229 * Block lastclose from racing with firstopen.
230 */
231
232 struct mutex init_mutex;
233
234 /*
235 * A resource manager for kernel-only surfaces and
236 * contexts.
237 */
238
239 struct ttm_object_device *tdev;
240
241 /*
242 * Fencing and IRQs.
243 */
244
Thomas Hellstrom85b9e482010-02-08 09:57:25 +0000245 atomic_t fence_seq;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000246 wait_queue_head_t fence_queue;
247 wait_queue_head_t fifo_queue;
248 atomic_t fence_queue_waiters;
249 atomic_t fifo_queue_waiters;
250 uint32_t last_read_sequence;
251 spinlock_t irq_lock;
252
253 /*
254 * Device state
255 */
256
257 uint32_t traces_state;
258 uint32_t enable_state;
259 uint32_t config_done_state;
260
261 /**
262 * Execbuf
263 */
264 /**
265 * Protected by the cmdbuf mutex.
266 */
267
268 struct vmw_sw_context ctx;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000269 struct mutex cmdbuf_mutex;
270
271 /**
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000272 * Operating mode.
273 */
274
275 bool stealth;
276 bool is_opened;
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200277 bool enable_fb;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000278
279 /**
280 * Master management.
281 */
282
283 struct vmw_master *active_master;
284 struct vmw_master fbdev_master;
Thomas Hellstromd9f36a02010-01-13 22:28:43 +0100285 struct notifier_block pm_nb;
Thomas Hellstrom094e0fa2010-10-05 12:43:00 +0200286 bool suspended;
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200287
288 struct mutex release_mutex;
289 uint32_t num_3d_resources;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000290};
291
292static inline struct vmw_private *vmw_priv(struct drm_device *dev)
293{
294 return (struct vmw_private *)dev->dev_private;
295}
296
297static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv)
298{
299 return (struct vmw_fpriv *)file_priv->driver_priv;
300}
301
302static inline struct vmw_master *vmw_master(struct drm_master *master)
303{
304 return (struct vmw_master *) master->driver_priv;
305}
306
307static inline void vmw_write(struct vmw_private *dev_priv,
308 unsigned int offset, uint32_t value)
309{
310 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
311 outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT);
312}
313
314static inline uint32_t vmw_read(struct vmw_private *dev_priv,
315 unsigned int offset)
316{
317 uint32_t val;
318
319 outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
320 val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT);
321 return val;
322}
323
Thomas Hellstrom05730b32011-08-31 07:42:52 +0000324int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga);
325void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga);
Thomas Hellstrom30c78bb2010-10-01 10:21:48 +0200326
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000327/**
328 * GMR utilities - vmwgfx_gmr.c
329 */
330
331extern int vmw_gmr_bind(struct vmw_private *dev_priv,
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200332 struct page *pages[],
333 unsigned long num_pages,
334 int gmr_id);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000335extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
336
337/**
338 * Resource utilities - vmwgfx_resource.c
339 */
340
341extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv);
342extern void vmw_resource_unreference(struct vmw_resource **p_res);
343extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
344extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
345 struct drm_file *file_priv);
346extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
347 struct drm_file *file_priv);
348extern int vmw_context_check(struct vmw_private *dev_priv,
349 struct ttm_object_file *tfile,
Thomas Hellstrombe38ab62011-08-31 07:42:54 +0000350 int id,
351 struct vmw_resource **p_res);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000352extern void vmw_surface_res_free(struct vmw_resource *res);
353extern int vmw_surface_init(struct vmw_private *dev_priv,
354 struct vmw_surface *srf,
355 void (*res_free) (struct vmw_resource *res));
Thomas Hellstrom7a73ba72009-12-22 16:53:41 +0100356extern 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);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000360extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
361 struct drm_file *file_priv);
362extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
363 struct drm_file *file_priv);
364extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
365 struct drm_file *file_priv);
366extern int vmw_surface_check(struct vmw_private *dev_priv,
367 struct ttm_object_file *tfile,
Thomas Hellstrom7a73ba72009-12-22 16:53:41 +0100368 uint32_t handle, int *id);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000369extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo);
370extern 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));
375extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
376 struct drm_file *file_priv);
377extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
378 struct drm_file *file_priv);
379extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
380 uint32_t cur_validate_node);
381extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
382extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
383 uint32_t id, struct vmw_dma_buffer **out);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000384extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
385 struct vmw_dma_buffer *bo);
386extern int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv,
387 struct vmw_dma_buffer *bo);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000388extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
389 struct drm_file *file_priv);
390extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
391 struct drm_file *file_priv);
392extern 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
397
398/**
399 * Misc Ioctl functionality - vmwgfx_ioctl.c
400 */
401
402extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
403 struct drm_file *file_priv);
404extern int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data,
405 struct drm_file *file_priv);
406
407/**
408 * Fifo utilities - vmwgfx_fifo.c
409 */
410
411extern int vmw_fifo_init(struct vmw_private *dev_priv,
412 struct vmw_fifo_state *fifo);
413extern void vmw_fifo_release(struct vmw_private *dev_priv,
414 struct vmw_fifo_state *fifo);
415extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes);
416extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
417extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
418 uint32_t *sequence);
419extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
420extern int vmw_fifo_mmap(struct file *filp, struct vm_area_struct *vma);
Jakob Bornecrantz8e19a952010-01-30 03:38:06 +0000421extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv);
Jakob Bornecrantzd7e19582010-05-28 11:21:59 +0200422extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000423
424/**
425 * TTM glue - vmwgfx_ttm_glue.c
426 */
427
428extern int vmw_ttm_global_init(struct vmw_private *dev_priv);
429extern void vmw_ttm_global_release(struct vmw_private *dev_priv);
430extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma);
431
432/**
433 * TTM buffer object driver - vmwgfx_buffer.c
434 */
435
436extern struct ttm_placement vmw_vram_placement;
437extern struct ttm_placement vmw_vram_ne_placement;
Thomas Hellstrom8ba51522010-01-16 16:05:05 +0100438extern struct ttm_placement vmw_vram_sys_placement;
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200439extern struct ttm_placement vmw_vram_gmr_placement;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000440extern struct ttm_placement vmw_sys_placement;
441extern struct ttm_bo_driver vmw_bo_driver;
442extern int vmw_dma_quiescent(struct drm_device *dev);
443
444/**
445 * Command submission - vmwgfx_execbuf.c
446 */
447
448extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
449 struct drm_file *file_priv);
450
451/**
452 * IRQs and wating - vmwgfx_irq.c
453 */
454
455extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS);
456extern int vmw_wait_fence(struct vmw_private *dev_priv, bool lazy,
457 uint32_t sequence, bool interruptible,
458 unsigned long timeout);
459extern void vmw_irq_preinstall(struct drm_device *dev);
460extern int vmw_irq_postinstall(struct drm_device *dev);
461extern void vmw_irq_uninstall(struct drm_device *dev);
462extern bool vmw_fence_signaled(struct vmw_private *dev_priv,
463 uint32_t sequence);
464extern int vmw_fence_wait_ioctl(struct drm_device *dev, void *data,
465 struct drm_file *file_priv);
466extern int vmw_fallback_wait(struct vmw_private *dev_priv,
467 bool lazy,
468 bool fifo_idle,
469 uint32_t sequence,
470 bool interruptible,
471 unsigned long timeout);
Thomas Hellstrom1925d452010-05-28 11:21:57 +0200472extern void vmw_update_sequence(struct vmw_private *dev_priv,
473 struct vmw_fifo_state *fifo_state);
474
475
476/**
477 * Rudimentary fence objects currently used only for throttling -
478 * vmwgfx_fence.c
479 */
480
481extern void vmw_fence_queue_init(struct vmw_fence_queue *queue);
482extern void vmw_fence_queue_takedown(struct vmw_fence_queue *queue);
483extern int vmw_fence_push(struct vmw_fence_queue *queue,
484 uint32_t sequence);
485extern int vmw_fence_pull(struct vmw_fence_queue *queue,
486 uint32_t signaled_sequence);
487extern int vmw_wait_lag(struct vmw_private *dev_priv,
488 struct vmw_fence_queue *queue, uint32_t us);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000489
490/**
491 * Kernel framebuffer - vmwgfx_fb.c
492 */
493
494int vmw_fb_init(struct vmw_private *vmw_priv);
495int vmw_fb_close(struct vmw_private *dev_priv);
496int vmw_fb_off(struct vmw_private *vmw_priv);
497int vmw_fb_on(struct vmw_private *vmw_priv);
498
499/**
500 * Kernel modesetting - vmwgfx_kms.c
501 */
502
503int vmw_kms_init(struct vmw_private *dev_priv);
504int vmw_kms_close(struct vmw_private *dev_priv);
505int vmw_kms_save_vga(struct vmw_private *vmw_priv);
506int vmw_kms_restore_vga(struct vmw_private *vmw_priv);
507int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
508 struct drm_file *file_priv);
509void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv);
510void vmw_kms_cursor_snoop(struct vmw_surface *srf,
511 struct ttm_object_file *tfile,
512 struct ttm_buffer_object *bo,
513 SVGA3dCmdHeader *header);
Michel Dänzer0bef23f2011-08-31 07:42:50 +0000514int vmw_kms_write_svga(struct vmw_private *vmw_priv,
515 unsigned width, unsigned height, unsigned pitch,
516 unsigned bpp, unsigned depth);
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200517int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
518 struct drm_file *file_priv);
Thomas Hellstrom3a939a52010-10-05 12:43:03 +0200519void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
Thomas Hellstrome133e732010-10-05 12:43:04 +0200520bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
521 uint32_t pitch,
522 uint32_t height);
Thomas Hellstrom7a1c2f62010-10-01 10:21:49 +0200523u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000524
525/**
526 * Overlay control - vmwgfx_overlay.c
527 */
528
529int vmw_overlay_init(struct vmw_private *dev_priv);
530int vmw_overlay_close(struct vmw_private *dev_priv);
531int vmw_overlay_ioctl(struct drm_device *dev, void *data,
532 struct drm_file *file_priv);
533int vmw_overlay_stop_all(struct vmw_private *dev_priv);
534int vmw_overlay_resume_all(struct vmw_private *dev_priv);
535int vmw_overlay_pause_all(struct vmw_private *dev_priv);
536int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out);
537int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id);
538int vmw_overlay_num_overlays(struct vmw_private *dev_priv);
539int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
540
541/**
Thomas Hellstrom135cba02010-10-26 21:21:47 +0200542 * GMR Id manager
543 */
544
545extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;
546
547/**
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000548 * Inline helper functions
549 */
550
551static inline void vmw_surface_unreference(struct vmw_surface **srf)
552{
553 struct vmw_surface *tmp_srf = *srf;
554 struct vmw_resource *res = &tmp_srf->res;
555 *srf = NULL;
556
557 vmw_resource_unreference(&res);
558}
559
560static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf)
561{
562 (void) vmw_resource_reference(&srf->res);
563 return srf;
564}
565
566static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf)
567{
568 struct vmw_dma_buffer *tmp_buf = *buf;
569 struct ttm_buffer_object *bo = &tmp_buf->base;
570 *buf = NULL;
571
572 ttm_bo_unref(&bo);
573}
574
575static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf)
576{
577 if (ttm_bo_reference(&buf->base))
578 return buf;
579 return NULL;
580}
581
582#endif