Rev 4075 | Rev 4111 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4075 | Serge | 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 |
||
33 | #include |
||
34 | #include |
||
35 | //#include |
||
36 | #include |
||
37 | #include |
||
38 | //#include |
||
39 | #include |
||
40 | //#include |
||
41 | #include "vmwgfx_fence.h" |
||
42 | |||
43 | #define VMWGFX_DRIVER_DATE "20120209" |
||
44 | #define VMWGFX_DRIVER_MAJOR 2 |
||
45 | #define VMWGFX_DRIVER_MINOR 4 |
||
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 |
||
53 | |||
54 | #define VMW_PL_GMR TTM_PL_PRIV0 |
||
55 | #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 |
||
56 | |||
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 |
||
61 | |||
62 | #define ioread32(addr) readl(addr) |
||
63 | |||
64 | static inline void outl(u32 v, u16 port) |
||
65 | { |
||
66 | asm volatile("outl %0,%1" : : "a" (v), "dN" (port)); |
||
67 | } |
||
68 | static inline u32 inl(u16 port) |
||
69 | { |
||
70 | u32 v; |
||
71 | asm volatile("inl %1,%0" : "=a" (v) : "dN" (port)); |
||
72 | return v; |
||
73 | } |
||
74 | |||
75 | struct ttm_lock{}; |
||
76 | struct ww_acquire_ctx{}; |
||
77 | |||
78 | struct vmw_fpriv { |
||
79 | // struct drm_master *locked_master; |
||
80 | struct ttm_object_file *tfile; |
||
81 | struct list_head fence_events; |
||
82 | }; |
||
83 | |||
84 | struct vmw_dma_buffer { |
||
85 | struct ttm_buffer_object base; |
||
86 | struct list_head res_list; |
||
87 | }; |
||
88 | |||
89 | /** |
||
90 | * struct vmw_validate_buffer - Carries validation info about buffers. |
||
91 | * |
||
92 | * @base: Validation info for TTM. |
||
93 | * @hash: Hash entry for quick lookup of the TTM buffer object. |
||
94 | * |
||
95 | * This structure contains also driver private validation info |
||
96 | * on top of the info needed by TTM. |
||
97 | */ |
||
98 | struct vmw_validate_buffer { |
||
99 | struct ttm_validate_buffer base; |
||
100 | struct drm_hash_item hash; |
||
101 | }; |
||
102 | |||
103 | struct vmw_res_func; |
||
104 | struct vmw_resource { |
||
105 | struct kref kref; |
||
106 | struct vmw_private *dev_priv; |
||
107 | int id; |
||
108 | bool avail; |
||
109 | unsigned long backup_size; |
||
110 | bool res_dirty; /* Protected by backup buffer reserved */ |
||
111 | bool backup_dirty; /* Protected by backup buffer reserved */ |
||
112 | struct vmw_dma_buffer *backup; |
||
113 | unsigned long backup_offset; |
||
114 | const struct vmw_res_func *func; |
||
115 | struct list_head lru_head; /* Protected by the resource lock */ |
||
116 | struct list_head mob_head; /* Protected by @backup reserved */ |
||
117 | void (*res_free) (struct vmw_resource *res); |
||
118 | void (*hw_destroy) (struct vmw_resource *res); |
||
119 | }; |
||
120 | |||
121 | enum vmw_res_type { |
||
122 | vmw_res_context, |
||
123 | vmw_res_surface, |
||
124 | vmw_res_stream, |
||
125 | vmw_res_max |
||
126 | }; |
||
127 | |||
128 | struct vmw_cursor_snooper { |
||
129 | struct drm_crtc *crtc; |
||
130 | size_t age; |
||
131 | uint32_t *image; |
||
132 | }; |
||
133 | |||
134 | struct vmw_framebuffer; |
||
135 | struct vmw_surface_offset; |
||
136 | |||
137 | struct vmw_surface { |
||
138 | struct vmw_resource res; |
||
139 | uint32_t flags; |
||
140 | uint32_t format; |
||
141 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; |
||
142 | struct drm_vmw_size base_size; |
||
143 | struct drm_vmw_size *sizes; |
||
144 | uint32_t num_sizes; |
||
145 | bool scanout; |
||
146 | /* TODO so far just a extra pointer */ |
||
147 | struct vmw_cursor_snooper snooper; |
||
148 | struct vmw_surface_offset *offsets; |
||
149 | SVGA3dTextureFilter autogen_filter; |
||
150 | uint32_t multisample_count; |
||
151 | }; |
||
152 | |||
153 | struct vmw_marker_queue { |
||
154 | struct list_head head; |
||
155 | struct timespec lag; |
||
156 | struct timespec lag_time; |
||
157 | spinlock_t lock; |
||
158 | }; |
||
159 | |||
160 | struct vmw_fifo_state { |
||
161 | unsigned long reserved_size; |
||
162 | __le32 *dynamic_buffer; |
||
163 | __le32 *static_buffer; |
||
164 | unsigned long static_buffer_size; |
||
165 | bool using_bounce_buffer; |
||
166 | uint32_t capabilities; |
||
167 | struct mutex fifo_mutex; |
||
168 | struct rw_semaphore rwsem; |
||
169 | struct vmw_marker_queue marker_queue; |
||
170 | }; |
||
171 | |||
172 | struct vmw_relocation { |
||
173 | SVGAGuestPtr *location; |
||
174 | uint32_t index; |
||
175 | }; |
||
176 | |||
177 | /** |
||
178 | * struct vmw_res_cache_entry - resource information cache entry |
||
179 | * |
||
180 | * @valid: Whether the entry is valid, which also implies that the execbuf |
||
181 | * code holds a reference to the resource, and it's placed on the |
||
182 | * validation list. |
||
183 | * @handle: User-space handle of a resource. |
||
184 | * @res: Non-ref-counted pointer to the resource. |
||
185 | * |
||
186 | * Used to avoid frequent repeated user-space handle lookups of the |
||
187 | * same resource. |
||
188 | */ |
||
189 | struct vmw_res_cache_entry { |
||
190 | bool valid; |
||
191 | uint32_t handle; |
||
192 | struct vmw_resource *res; |
||
193 | struct vmw_resource_val_node *node; |
||
194 | }; |
||
195 | |||
196 | struct vmw_sw_context{ |
||
197 | struct drm_open_hash res_ht; |
||
198 | bool res_ht_initialized; |
||
199 | bool kernel; /**< is the called made from the kernel */ |
||
200 | struct ttm_object_file *tfile; |
||
201 | struct list_head validate_nodes; |
||
202 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; |
||
203 | uint32_t cur_reloc; |
||
204 | struct vmw_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
||
205 | uint32_t cur_val_buf; |
||
206 | uint32_t *cmd_bounce; |
||
207 | uint32_t cmd_bounce_size; |
||
208 | struct list_head resource_list; |
||
209 | uint32_t fence_flags; |
||
210 | struct ttm_buffer_object *cur_query_bo; |
||
211 | struct list_head res_relocations; |
||
212 | uint32_t *buf_start; |
||
213 | struct vmw_res_cache_entry res_cache[vmw_res_max]; |
||
214 | struct vmw_resource *last_query_ctx; |
||
215 | bool needs_post_query_barrier; |
||
216 | struct vmw_resource *error_resource; |
||
217 | }; |
||
218 | |||
219 | struct vmw_legacy_display; |
||
220 | struct vmw_overlay; |
||
221 | |||
222 | struct vmw_master { |
||
223 | struct ttm_lock lock; |
||
224 | struct mutex fb_surf_mutex; |
||
225 | struct list_head fb_surf; |
||
226 | }; |
||
227 | |||
228 | struct vmw_vga_topology_state { |
||
229 | uint32_t width; |
||
230 | uint32_t height; |
||
231 | uint32_t primary; |
||
232 | uint32_t pos_x; |
||
233 | uint32_t pos_y; |
||
234 | }; |
||
235 | |||
236 | struct vmw_private { |
||
237 | struct ttm_bo_device bdev; |
||
238 | struct ttm_bo_global_ref bo_global_ref; |
||
239 | struct drm_global_reference mem_global_ref; |
||
240 | |||
241 | struct vmw_fifo_state fifo; |
||
242 | |||
243 | struct drm_device *dev; |
||
244 | unsigned long vmw_chipset; |
||
245 | unsigned int io_start; |
||
246 | uint32_t vram_start; |
||
247 | uint32_t vram_size; |
||
248 | uint32_t mmio_start; |
||
249 | uint32_t mmio_size; |
||
250 | uint32_t fb_max_width; |
||
251 | uint32_t fb_max_height; |
||
252 | uint32_t initial_width; |
||
253 | uint32_t initial_height; |
||
254 | __le32 __iomem *mmio_virt; |
||
255 | int mmio_mtrr; |
||
256 | uint32_t capabilities; |
||
257 | uint32_t max_gmr_descriptors; |
||
258 | uint32_t max_gmr_ids; |
||
259 | uint32_t max_gmr_pages; |
||
260 | uint32_t memory_size; |
||
261 | bool has_gmr; |
||
262 | struct mutex hw_mutex; |
||
263 | |||
264 | /* |
||
265 | * VGA registers. |
||
266 | */ |
||
267 | |||
268 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
||
269 | uint32_t vga_width; |
||
270 | uint32_t vga_height; |
||
271 | uint32_t vga_bpp; |
||
272 | uint32_t vga_bpl; |
||
273 | uint32_t vga_pitchlock; |
||
274 | |||
275 | uint32_t num_displays; |
||
276 | |||
277 | /* |
||
278 | * Framebuffer info. |
||
279 | */ |
||
280 | |||
281 | void *fb_info; |
||
282 | struct vmw_legacy_display *ldu_priv; |
||
283 | struct vmw_screen_object_display *sou_priv; |
||
284 | struct vmw_overlay *overlay_priv; |
||
285 | |||
286 | /* |
||
287 | * Context and surface management. |
||
288 | */ |
||
289 | |||
290 | rwlock_t resource_lock; |
||
291 | struct idr res_idr[vmw_res_max]; |
||
292 | /* |
||
293 | * Block lastclose from racing with firstopen. |
||
294 | */ |
||
295 | |||
296 | struct mutex init_mutex; |
||
297 | |||
298 | /* |
||
299 | * A resource manager for kernel-only surfaces and |
||
300 | * contexts. |
||
301 | */ |
||
302 | |||
303 | struct ttm_object_device *tdev; |
||
304 | |||
305 | /* |
||
306 | * Fencing and IRQs. |
||
307 | */ |
||
308 | |||
309 | atomic_t marker_seq; |
||
310 | wait_queue_head_t fence_queue; |
||
311 | wait_queue_head_t fifo_queue; |
||
312 | int fence_queue_waiters; /* Protected by hw_mutex */ |
||
313 | int goal_queue_waiters; /* Protected by hw_mutex */ |
||
314 | atomic_t fifo_queue_waiters; |
||
315 | uint32_t last_read_seqno; |
||
316 | spinlock_t irq_lock; |
||
317 | struct vmw_fence_manager *fman; |
||
318 | uint32_t irq_mask; |
||
319 | |||
320 | /* |
||
321 | * Device state |
||
322 | */ |
||
323 | |||
324 | uint32_t traces_state; |
||
325 | uint32_t enable_state; |
||
326 | uint32_t config_done_state; |
||
327 | |||
328 | /** |
||
329 | * Execbuf |
||
330 | */ |
||
331 | /** |
||
332 | * Protected by the cmdbuf mutex. |
||
333 | */ |
||
334 | |||
335 | struct vmw_sw_context ctx; |
||
336 | struct mutex cmdbuf_mutex; |
||
337 | |||
338 | /** |
||
339 | * Operating mode. |
||
340 | */ |
||
341 | |||
342 | bool stealth; |
||
343 | bool is_opened; |
||
344 | bool enable_fb; |
||
345 | |||
346 | /** |
||
347 | * Master management. |
||
348 | */ |
||
349 | |||
350 | // struct vmw_master *active_master; |
||
351 | // struct vmw_master fbdev_master; |
||
352 | // struct notifier_block pm_nb; |
||
353 | bool suspended; |
||
354 | |||
355 | struct mutex release_mutex; |
||
356 | uint32_t num_3d_resources; |
||
357 | |||
358 | /* |
||
359 | * Query processing. These members |
||
360 | * are protected by the cmdbuf mutex. |
||
361 | */ |
||
362 | |||
363 | struct ttm_buffer_object *dummy_query_bo; |
||
364 | struct ttm_buffer_object *pinned_bo; |
||
365 | uint32_t query_cid; |
||
366 | uint32_t query_cid_valid; |
||
367 | bool dummy_query_bo_pinned; |
||
368 | |||
369 | /* |
||
370 | * Surface swapping. The "surface_lru" list is protected by the |
||
371 | * resource lock in order to be able to destroy a surface and take |
||
372 | * it off the lru atomically. "used_memory_size" is currently |
||
373 | * protected by the cmdbuf mutex for simplicity. |
||
374 | */ |
||
375 | |||
376 | struct list_head res_lru[vmw_res_max]; |
||
377 | uint32_t used_memory_size; |
||
378 | }; |
||
379 | |||
380 | static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) |
||
381 | { |
||
382 | return container_of(res, struct vmw_surface, res); |
||
383 | } |
||
384 | |||
385 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) |
||
386 | { |
||
387 | return (struct vmw_private *)dev->dev_private; |
||
388 | } |
||
389 | |||
390 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) |
||
391 | { |
||
392 | return (struct vmw_fpriv *)file_priv->driver_priv; |
||
393 | } |
||
394 | |||
395 | static inline struct vmw_master *vmw_master(struct drm_master *master) |
||
396 | { |
||
397 | return (struct vmw_master *) master->driver_priv; |
||
398 | } |
||
399 | |||
400 | static inline void vmw_write(struct vmw_private *dev_priv, |
||
401 | unsigned int offset, uint32_t value) |
||
402 | { |
||
403 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
||
404 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); |
||
405 | } |
||
406 | |||
407 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, |
||
408 | unsigned int offset) |
||
409 | { |
||
410 | uint32_t val; |
||
411 | |||
412 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
||
413 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); |
||
414 | return val; |
||
415 | } |
||
416 | |||
417 | int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga); |
||
418 | void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga); |
||
419 | |||
420 | /** |
||
421 | * GMR utilities - vmwgfx_gmr.c |
||
422 | */ |
||
423 | |||
424 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, |
||
425 | struct page *pages[], |
||
426 | unsigned long num_pages, |
||
427 | int gmr_id); |
||
428 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
||
429 | |||
430 | /** |
||
431 | * Resource utilities - vmwgfx_resource.c |
||
432 | */ |
||
433 | struct vmw_user_resource_conv; |
||
434 | extern const struct vmw_user_resource_conv *user_surface_converter; |
||
435 | extern const struct vmw_user_resource_conv *user_context_converter; |
||
436 | |||
437 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); |
||
438 | extern void vmw_resource_unreference(struct vmw_resource **p_res); |
||
439 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); |
||
440 | extern int vmw_resource_validate(struct vmw_resource *res); |
||
441 | extern int vmw_resource_reserve(struct vmw_resource *res, bool no_backup); |
||
442 | extern bool vmw_resource_needs_backup(const struct vmw_resource *res); |
||
443 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, |
||
444 | struct drm_file *file_priv); |
||
445 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, |
||
446 | struct drm_file *file_priv); |
||
447 | extern int vmw_context_check(struct vmw_private *dev_priv, |
||
448 | struct ttm_object_file *tfile, |
||
449 | int id, |
||
450 | struct vmw_resource **p_res); |
||
451 | extern int vmw_user_lookup_handle(struct vmw_private *dev_priv, |
||
452 | struct ttm_object_file *tfile, |
||
453 | uint32_t handle, |
||
454 | struct vmw_surface **out_surf, |
||
455 | struct vmw_dma_buffer **out_buf); |
||
456 | extern int vmw_user_resource_lookup_handle( |
||
457 | struct vmw_private *dev_priv, |
||
458 | struct ttm_object_file *tfile, |
||
459 | uint32_t handle, |
||
460 | const struct vmw_user_resource_conv *converter, |
||
461 | struct vmw_resource **p_res); |
||
462 | extern void vmw_surface_res_free(struct vmw_resource *res); |
||
463 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
||
464 | struct drm_file *file_priv); |
||
465 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, |
||
466 | struct drm_file *file_priv); |
||
467 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, |
||
468 | struct drm_file *file_priv); |
||
469 | extern int vmw_surface_check(struct vmw_private *dev_priv, |
||
470 | struct ttm_object_file *tfile, |
||
471 | uint32_t handle, int *id); |
||
472 | extern int vmw_surface_validate(struct vmw_private *dev_priv, |
||
473 | struct vmw_surface *srf); |
||
474 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
||
475 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, |
||
476 | struct vmw_dma_buffer *vmw_bo, |
||
477 | size_t size, struct ttm_placement *placement, |
||
478 | bool interuptable, |
||
479 | void (*bo_free) (struct ttm_buffer_object *bo)); |
||
480 | extern int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, |
||
481 | struct ttm_object_file *tfile); |
||
482 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
||
483 | struct drm_file *file_priv); |
||
484 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, |
||
485 | struct drm_file *file_priv); |
||
486 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, |
||
487 | uint32_t cur_validate_node); |
||
488 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); |
||
489 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, |
||
490 | uint32_t id, struct vmw_dma_buffer **out); |
||
491 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
||
492 | struct drm_file *file_priv); |
||
493 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, |
||
494 | struct drm_file *file_priv); |
||
495 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, |
||
496 | struct ttm_object_file *tfile, |
||
497 | uint32_t *inout_id, |
||
498 | struct vmw_resource **out); |
||
499 | extern void vmw_resource_unreserve(struct vmw_resource *res, |
||
500 | struct vmw_dma_buffer *new_backup, |
||
501 | unsigned long new_backup_offset); |
||
502 | extern void vmw_resource_move_notify(struct ttm_buffer_object *bo, |
||
503 | struct ttm_mem_reg *mem); |
||
504 | extern void vmw_fence_single_bo(struct ttm_buffer_object *bo, |
||
505 | struct vmw_fence_obj *fence); |
||
506 | extern void vmw_resource_evict_all(struct vmw_private *dev_priv); |
||
507 | |||
508 | /** |
||
509 | * DMA buffer helper routines - vmwgfx_dmabuf.c |
||
510 | */ |
||
511 | extern int vmw_dmabuf_to_placement(struct vmw_private *vmw_priv, |
||
512 | struct vmw_dma_buffer *bo, |
||
513 | struct ttm_placement *placement, |
||
514 | bool interruptible); |
||
515 | extern int vmw_dmabuf_to_vram(struct vmw_private *dev_priv, |
||
516 | struct vmw_dma_buffer *buf, |
||
517 | bool pin, bool interruptible); |
||
518 | extern int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv, |
||
519 | struct vmw_dma_buffer *buf, |
||
520 | bool pin, bool interruptible); |
||
521 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, |
||
522 | struct vmw_dma_buffer *bo, |
||
523 | bool pin, bool interruptible); |
||
524 | extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, |
||
525 | struct vmw_dma_buffer *bo, |
||
526 | bool interruptible); |
||
527 | extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, |
||
528 | SVGAGuestPtr *ptr); |
||
529 | extern void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin); |
||
530 | |||
531 | /** |
||
532 | * Misc Ioctl functionality - vmwgfx_ioctl.c |
||
533 | */ |
||
534 | |||
535 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
||
536 | struct drm_file *file_priv); |
||
537 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
||
538 | struct drm_file *file_priv); |
||
539 | extern int vmw_present_ioctl(struct drm_device *dev, void *data, |
||
540 | struct drm_file *file_priv); |
||
541 | extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data, |
||
542 | struct drm_file *file_priv); |
||
543 | //extern unsigned int vmw_fops_poll(struct file *filp, |
||
544 | // struct poll_table_struct *wait); |
||
545 | extern ssize_t vmw_fops_read(struct file *filp, char __user *buffer, |
||
546 | size_t count, loff_t *offset); |
||
547 | |||
548 | /** |
||
549 | * Fifo utilities - vmwgfx_fifo.c |
||
550 | */ |
||
551 | |||
552 | extern int vmw_fifo_init(struct vmw_private *dev_priv, |
||
553 | struct vmw_fifo_state *fifo); |
||
554 | extern void vmw_fifo_release(struct vmw_private *dev_priv, |
||
555 | struct vmw_fifo_state *fifo); |
||
556 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); |
||
557 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); |
||
558 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, |
||
559 | uint32_t *seqno); |
||
560 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
||
561 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
||
562 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
||
563 | extern int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
||
564 | uint32_t cid); |
||
565 | |||
566 | /** |
||
567 | * TTM glue - vmwgfx_ttm_glue.c |
||
568 | */ |
||
569 | |||
570 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); |
||
571 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); |
||
572 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); |
||
573 | |||
574 | /** |
||
575 | * TTM buffer object driver - vmwgfx_buffer.c |
||
576 | */ |
||
577 | |||
578 | extern struct ttm_placement vmw_vram_placement; |
||
579 | extern struct ttm_placement vmw_vram_ne_placement; |
||
580 | extern struct ttm_placement vmw_vram_sys_placement; |
||
581 | extern struct ttm_placement vmw_vram_gmr_placement; |
||
582 | extern struct ttm_placement vmw_vram_gmr_ne_placement; |
||
583 | extern struct ttm_placement vmw_sys_placement; |
||
584 | extern struct ttm_placement vmw_evictable_placement; |
||
585 | extern struct ttm_placement vmw_srf_placement; |
||
586 | extern struct ttm_bo_driver vmw_bo_driver; |
||
587 | extern int vmw_dma_quiescent(struct drm_device *dev); |
||
588 | |||
589 | /** |
||
590 | * Command submission - vmwgfx_execbuf.c |
||
591 | */ |
||
592 | |||
593 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, |
||
594 | struct drm_file *file_priv); |
||
595 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
||
596 | struct vmw_private *dev_priv, |
||
597 | void __user *user_commands, |
||
598 | void *kernel_commands, |
||
599 | uint32_t command_size, |
||
600 | uint64_t throttle_us, |
||
601 | struct drm_vmw_fence_rep __user |
||
602 | *user_fence_rep, |
||
603 | struct vmw_fence_obj **out_fence); |
||
604 | extern void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv, |
||
605 | struct vmw_fence_obj *fence); |
||
606 | extern void vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv); |
||
607 | |||
608 | extern int vmw_execbuf_fence_commands(struct drm_file *file_priv, |
||
609 | struct vmw_private *dev_priv, |
||
610 | struct vmw_fence_obj **p_fence, |
||
611 | uint32_t *p_handle); |
||
612 | extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, |
||
613 | struct vmw_fpriv *vmw_fp, |
||
614 | int ret, |
||
615 | struct drm_vmw_fence_rep __user |
||
616 | *user_fence_rep, |
||
617 | struct vmw_fence_obj *fence, |
||
618 | uint32_t fence_handle); |
||
619 | |||
620 | /** |
||
621 | * IRQs and wating - vmwgfx_irq.c |
||
622 | */ |
||
623 | |||
624 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); |
||
625 | extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy, |
||
626 | uint32_t seqno, bool interruptible, |
||
627 | unsigned long timeout); |
||
628 | extern void vmw_irq_preinstall(struct drm_device *dev); |
||
629 | extern int vmw_irq_postinstall(struct drm_device *dev); |
||
630 | extern void vmw_irq_uninstall(struct drm_device *dev); |
||
631 | extern bool vmw_seqno_passed(struct vmw_private *dev_priv, |
||
632 | uint32_t seqno); |
||
633 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
||
634 | bool lazy, |
||
635 | bool fifo_idle, |
||
636 | uint32_t seqno, |
||
637 | bool interruptible, |
||
638 | unsigned long timeout); |
||
639 | extern void vmw_update_seqno(struct vmw_private *dev_priv, |
||
640 | struct vmw_fifo_state *fifo_state); |
||
641 | extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv); |
||
642 | extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv); |
||
643 | extern void vmw_goal_waiter_add(struct vmw_private *dev_priv); |
||
644 | extern void vmw_goal_waiter_remove(struct vmw_private *dev_priv); |
||
645 | |||
646 | /** |
||
647 | * Rudimentary fence-like objects currently used only for throttling - |
||
648 | * vmwgfx_marker.c |
||
649 | */ |
||
650 | |||
651 | extern void vmw_marker_queue_init(struct vmw_marker_queue *queue); |
||
652 | extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue); |
||
653 | extern int vmw_marker_push(struct vmw_marker_queue *queue, |
||
654 | uint32_t seqno); |
||
655 | extern int vmw_marker_pull(struct vmw_marker_queue *queue, |
||
656 | uint32_t signaled_seqno); |
||
657 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
||
658 | struct vmw_marker_queue *queue, uint32_t us); |
||
659 | |||
660 | /** |
||
661 | * Kernel framebuffer - vmwgfx_fb.c |
||
662 | */ |
||
663 | |||
664 | int vmw_fb_init(struct vmw_private *vmw_priv); |
||
665 | int vmw_fb_close(struct vmw_private *dev_priv); |
||
666 | int vmw_fb_off(struct vmw_private *vmw_priv); |
||
667 | int vmw_fb_on(struct vmw_private *vmw_priv); |
||
668 | |||
669 | /** |
||
670 | * Kernel modesetting - vmwgfx_kms.c |
||
671 | */ |
||
672 | |||
673 | int vmw_kms_init(struct vmw_private *dev_priv); |
||
674 | int vmw_kms_close(struct vmw_private *dev_priv); |
||
675 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); |
||
676 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); |
||
677 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, |
||
678 | struct drm_file *file_priv); |
||
679 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); |
||
680 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, |
||
681 | struct ttm_object_file *tfile, |
||
682 | struct ttm_buffer_object *bo, |
||
683 | SVGA3dCmdHeader *header); |
||
684 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
||
685 | unsigned width, unsigned height, unsigned pitch, |
||
686 | unsigned bpp, unsigned depth); |
||
687 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
||
688 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
||
689 | uint32_t pitch, |
||
690 | uint32_t height); |
||
691 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
||
692 | int vmw_enable_vblank(struct drm_device *dev, int crtc); |
||
693 | void vmw_disable_vblank(struct drm_device *dev, int crtc); |
||
694 | int vmw_kms_present(struct vmw_private *dev_priv, |
||
695 | struct drm_file *file_priv, |
||
696 | struct vmw_framebuffer *vfb, |
||
697 | struct vmw_surface *surface, |
||
698 | uint32_t sid, int32_t destX, int32_t destY, |
||
699 | struct drm_vmw_rect *clips, |
||
700 | uint32_t num_clips); |
||
701 | int vmw_kms_readback(struct vmw_private *dev_priv, |
||
702 | struct drm_file *file_priv, |
||
703 | struct vmw_framebuffer *vfb, |
||
704 | struct drm_vmw_fence_rep __user *user_fence_rep, |
||
705 | struct drm_vmw_rect *clips, |
||
706 | uint32_t num_clips); |
||
707 | int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, |
||
708 | struct drm_file *file_priv); |
||
709 | |||
710 | int vmw_dumb_create(struct drm_file *file_priv, |
||
711 | struct drm_device *dev, |
||
712 | struct drm_mode_create_dumb *args); |
||
713 | |||
714 | int vmw_dumb_map_offset(struct drm_file *file_priv, |
||
715 | struct drm_device *dev, uint32_t handle, |
||
716 | uint64_t *offset); |
||
717 | int vmw_dumb_destroy(struct drm_file *file_priv, |
||
718 | struct drm_device *dev, |
||
719 | uint32_t handle); |
||
720 | /** |
||
721 | * Overlay control - vmwgfx_overlay.c |
||
722 | */ |
||
723 | |||
724 | int vmw_overlay_init(struct vmw_private *dev_priv); |
||
725 | int vmw_overlay_close(struct vmw_private *dev_priv); |
||
726 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, |
||
727 | struct drm_file *file_priv); |
||
728 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); |
||
729 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); |
||
730 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); |
||
731 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); |
||
732 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); |
||
733 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); |
||
734 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); |
||
735 | |||
736 | /** |
||
737 | * GMR Id manager |
||
738 | */ |
||
739 | |||
740 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
||
741 | |||
742 | /** |
||
743 | * Inline helper functions |
||
744 | */ |
||
745 | |||
746 | static inline void vmw_surface_unreference(struct vmw_surface **srf) |
||
747 | { |
||
748 | struct vmw_surface *tmp_srf = *srf; |
||
749 | struct vmw_resource *res = &tmp_srf->res; |
||
750 | *srf = NULL; |
||
751 | |||
752 | vmw_resource_unreference(&res); |
||
753 | } |
||
754 | |||
755 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) |
||
756 | { |
||
757 | (void) vmw_resource_reference(&srf->res); |
||
758 | return srf; |
||
759 | } |
||
760 | |||
761 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) |
||
762 | { |
||
763 | struct vmw_dma_buffer *tmp_buf = *buf; |
||
764 | |||
765 | *buf = NULL; |
||
766 | if (tmp_buf != NULL) { |
||
767 | struct ttm_buffer_object *bo = &tmp_buf->base; |
||
768 | |||
769 | ttm_bo_unref(&bo); |
||
770 | } |
||
771 | } |
||
772 | |||
773 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) |
||
774 | { |
||
775 | if (ttm_bo_reference(&buf->base)) |
||
776 | return buf; |
||
777 | return NULL; |
||
778 | } |
||
779 | |||
780 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
||
781 | { |
||
782 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; |
||
783 | } |
||
784 | |||
4080 | Serge | 785 | typedef struct |
786 | { |
||
787 | int width; |
||
788 | int height; |
||
789 | int bpp; |
||
790 | int freq; |
||
791 | }videomode_t; |
||
4075 | Serge | 792 | |
793 | #endif> |