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