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