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 | |
Thomas Hellstrom | 8aea528 | 2010-10-05 12:43:09 +0200 | [diff] [blame] | 42 | #define VMWGFX_DRIVER_DATE "20100927" |
Jakob Bornecrantz | a87897e | 2010-02-09 21:29:47 +0000 | [diff] [blame] | 43 | #define VMWGFX_DRIVER_MAJOR 1 |
Thomas Hellstrom | 8aea528 | 2010-10-05 12:43:09 +0200 | [diff] [blame] | 44 | #define VMWGFX_DRIVER_MINOR 4 |
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 |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 49 | #define VMWGFX_MAX_VALIDATIONS 2048 |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 50 | #define VMWGFX_MAX_DISPLAYS 16 |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 51 | #define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 52 | |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 53 | #define VMW_PL_GMR TTM_PL_PRIV0 |
| 54 | #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 |
| 55 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 56 | struct vmw_fpriv { |
| 57 | struct drm_master *locked_master; |
| 58 | struct ttm_object_file *tfile; |
| 59 | }; |
| 60 | |
| 61 | struct vmw_dma_buffer { |
| 62 | struct ttm_buffer_object base; |
| 63 | struct list_head validate_list; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 64 | bool gmr_bound; |
| 65 | uint32_t cur_validate_node; |
| 66 | bool on_validate_list; |
| 67 | }; |
| 68 | |
| 69 | struct 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 Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 78 | bool on_validate_list; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 79 | /* 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 | |
| 88 | struct vmw_cursor_snooper { |
| 89 | struct drm_crtc *crtc; |
| 90 | size_t age; |
| 91 | uint32_t *image; |
| 92 | }; |
| 93 | |
| 94 | struct 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 Bornecrantz | 5ffdb65 | 2010-01-30 03:38:08 +0000 | [diff] [blame] | 102 | bool scanout; |
| 103 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 104 | /* TODO so far just a extra pointer */ |
| 105 | struct vmw_cursor_snooper snooper; |
| 106 | }; |
| 107 | |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 108 | struct vmw_fence_queue { |
| 109 | struct list_head head; |
| 110 | struct timespec lag; |
| 111 | struct timespec lag_time; |
| 112 | spinlock_t lock; |
| 113 | }; |
| 114 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 115 | struct vmw_fifo_state { |
| 116 | unsigned long reserved_size; |
| 117 | __le32 *dynamic_buffer; |
| 118 | __le32 *static_buffer; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 119 | unsigned long static_buffer_size; |
| 120 | bool using_bounce_buffer; |
| 121 | uint32_t capabilities; |
Thomas Hellstrom | 85b9e48 | 2010-02-08 09:57:25 +0000 | [diff] [blame] | 122 | struct mutex fifo_mutex; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 123 | struct rw_semaphore rwsem; |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 124 | struct vmw_fence_queue fence_queue; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | struct vmw_relocation { |
| 128 | SVGAGuestPtr *location; |
| 129 | uint32_t index; |
| 130 | }; |
| 131 | |
| 132 | struct vmw_sw_context{ |
| 133 | struct ida bo_list; |
| 134 | uint32_t last_cid; |
| 135 | bool cid_valid; |
| 136 | uint32_t last_sid; |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 137 | uint32_t sid_translation; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 138 | bool sid_valid; |
| 139 | struct ttm_object_file *tfile; |
| 140 | struct list_head validate_nodes; |
| 141 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; |
| 142 | uint32_t cur_reloc; |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 143 | struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 144 | uint32_t cur_val_buf; |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 145 | uint32_t *cmd_bounce; |
| 146 | uint32_t cmd_bounce_size; |
| 147 | struct vmw_resource *resources[VMWGFX_MAX_VALIDATIONS]; |
| 148 | uint32_t num_ref_resources; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | struct vmw_legacy_display; |
| 152 | struct vmw_overlay; |
| 153 | |
| 154 | struct vmw_master { |
| 155 | struct ttm_lock lock; |
Thomas Hellstrom | 3a939a5 | 2010-10-05 12:43:03 +0200 | [diff] [blame] | 156 | struct mutex fb_surf_mutex; |
| 157 | struct list_head fb_surf; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 160 | struct vmw_vga_topology_state { |
| 161 | uint32_t width; |
| 162 | uint32_t height; |
| 163 | uint32_t primary; |
| 164 | uint32_t pos_x; |
| 165 | uint32_t pos_y; |
| 166 | }; |
| 167 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 168 | struct vmw_private { |
| 169 | struct ttm_bo_device bdev; |
| 170 | struct ttm_bo_global_ref bo_global_ref; |
Dave Airlie | ba4420c | 2010-03-09 10:56:52 +1000 | [diff] [blame] | 171 | struct drm_global_reference mem_global_ref; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 172 | |
| 173 | struct vmw_fifo_state fifo; |
| 174 | |
| 175 | struct drm_device *dev; |
| 176 | unsigned long vmw_chipset; |
| 177 | unsigned int io_start; |
| 178 | uint32_t vram_start; |
| 179 | uint32_t vram_size; |
| 180 | uint32_t mmio_start; |
| 181 | uint32_t mmio_size; |
| 182 | uint32_t fb_max_width; |
| 183 | uint32_t fb_max_height; |
| 184 | __le32 __iomem *mmio_virt; |
| 185 | int mmio_mtrr; |
| 186 | uint32_t capabilities; |
| 187 | uint32_t max_gmr_descriptors; |
| 188 | uint32_t max_gmr_ids; |
Thomas Hellstrom | fb17f18 | 2011-08-31 07:42:53 +0000 | [diff] [blame] | 189 | uint32_t max_gmr_pages; |
| 190 | uint32_t memory_size; |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 191 | bool has_gmr; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 192 | struct mutex hw_mutex; |
| 193 | |
| 194 | /* |
| 195 | * VGA registers. |
| 196 | */ |
| 197 | |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 198 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 199 | uint32_t vga_width; |
| 200 | uint32_t vga_height; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 201 | uint32_t vga_bpp; |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 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; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 265 | struct mutex cmdbuf_mutex; |
| 266 | |
| 267 | /** |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 268 | * Operating mode. |
| 269 | */ |
| 270 | |
| 271 | bool stealth; |
| 272 | bool is_opened; |
Thomas Hellstrom | 30c78bb | 2010-10-01 10:21:48 +0200 | [diff] [blame] | 273 | bool enable_fb; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * Master management. |
| 277 | */ |
| 278 | |
| 279 | struct vmw_master *active_master; |
| 280 | struct vmw_master fbdev_master; |
Thomas Hellstrom | d9f36a0 | 2010-01-13 22:28:43 +0100 | [diff] [blame] | 281 | struct notifier_block pm_nb; |
Thomas Hellstrom | 094e0fa | 2010-10-05 12:43:00 +0200 | [diff] [blame] | 282 | bool suspended; |
Thomas Hellstrom | 30c78bb | 2010-10-01 10:21:48 +0200 | [diff] [blame] | 283 | |
| 284 | struct mutex release_mutex; |
| 285 | uint32_t num_3d_resources; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) |
| 289 | { |
| 290 | return (struct vmw_private *)dev->dev_private; |
| 291 | } |
| 292 | |
| 293 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) |
| 294 | { |
| 295 | return (struct vmw_fpriv *)file_priv->driver_priv; |
| 296 | } |
| 297 | |
| 298 | static inline struct vmw_master *vmw_master(struct drm_master *master) |
| 299 | { |
| 300 | return (struct vmw_master *) master->driver_priv; |
| 301 | } |
| 302 | |
| 303 | static inline void vmw_write(struct vmw_private *dev_priv, |
| 304 | unsigned int offset, uint32_t value) |
| 305 | { |
| 306 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
| 307 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); |
| 308 | } |
| 309 | |
| 310 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, |
| 311 | unsigned int offset) |
| 312 | { |
| 313 | uint32_t val; |
| 314 | |
| 315 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
| 316 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); |
| 317 | return val; |
| 318 | } |
| 319 | |
Thomas Hellstrom | 05730b3 | 2011-08-31 07:42:52 +0000 | [diff] [blame] | 320 | int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga); |
| 321 | void vmw_3d_resource_dec(struct vmw_private *dev_priv, bool hide_svga); |
Thomas Hellstrom | 30c78bb | 2010-10-01 10:21:48 +0200 | [diff] [blame] | 322 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 323 | /** |
| 324 | * GMR utilities - vmwgfx_gmr.c |
| 325 | */ |
| 326 | |
| 327 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 328 | struct page *pages[], |
| 329 | unsigned long num_pages, |
| 330 | int gmr_id); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 331 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
| 332 | |
| 333 | /** |
| 334 | * Resource utilities - vmwgfx_resource.c |
| 335 | */ |
| 336 | |
| 337 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); |
| 338 | extern void vmw_resource_unreference(struct vmw_resource **p_res); |
| 339 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); |
| 340 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, |
| 341 | struct drm_file *file_priv); |
| 342 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, |
| 343 | struct drm_file *file_priv); |
| 344 | extern int vmw_context_check(struct vmw_private *dev_priv, |
| 345 | struct ttm_object_file *tfile, |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 346 | int id, |
| 347 | struct vmw_resource **p_res); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 348 | extern void vmw_surface_res_free(struct vmw_resource *res); |
| 349 | extern int vmw_surface_init(struct vmw_private *dev_priv, |
| 350 | struct vmw_surface *srf, |
| 351 | void (*res_free) (struct vmw_resource *res)); |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 352 | extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, |
| 353 | struct ttm_object_file *tfile, |
| 354 | uint32_t handle, |
| 355 | struct vmw_surface **out); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 356 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
| 357 | struct drm_file *file_priv); |
| 358 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, |
| 359 | struct drm_file *file_priv); |
| 360 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, |
| 361 | struct drm_file *file_priv); |
| 362 | extern int vmw_surface_check(struct vmw_private *dev_priv, |
| 363 | struct ttm_object_file *tfile, |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 364 | uint32_t handle, int *id); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 365 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
| 366 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, |
| 367 | struct vmw_dma_buffer *vmw_bo, |
| 368 | size_t size, struct ttm_placement *placement, |
| 369 | bool interuptable, |
| 370 | void (*bo_free) (struct ttm_buffer_object *bo)); |
| 371 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
| 372 | struct drm_file *file_priv); |
| 373 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, |
| 374 | struct drm_file *file_priv); |
| 375 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, |
| 376 | uint32_t cur_validate_node); |
| 377 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); |
| 378 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, |
| 379 | uint32_t id, struct vmw_dma_buffer **out); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 380 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, |
| 381 | struct vmw_dma_buffer *bo); |
| 382 | extern int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv, |
| 383 | struct vmw_dma_buffer *bo); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 384 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
| 385 | struct drm_file *file_priv); |
| 386 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, |
| 387 | struct drm_file *file_priv); |
| 388 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, |
| 389 | struct ttm_object_file *tfile, |
| 390 | uint32_t *inout_id, |
| 391 | struct vmw_resource **out); |
| 392 | |
| 393 | |
| 394 | /** |
| 395 | * Misc Ioctl functionality - vmwgfx_ioctl.c |
| 396 | */ |
| 397 | |
| 398 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
| 399 | struct drm_file *file_priv); |
Thomas Hellstrom | f63f6a5 | 2011-09-01 20:18:41 +0000 | [diff] [blame^] | 400 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
| 401 | struct drm_file *file_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 402 | |
| 403 | /** |
| 404 | * Fifo utilities - vmwgfx_fifo.c |
| 405 | */ |
| 406 | |
| 407 | extern int vmw_fifo_init(struct vmw_private *dev_priv, |
| 408 | struct vmw_fifo_state *fifo); |
| 409 | extern void vmw_fifo_release(struct vmw_private *dev_priv, |
| 410 | struct vmw_fifo_state *fifo); |
| 411 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); |
| 412 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); |
| 413 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, |
| 414 | uint32_t *sequence); |
| 415 | extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); |
Jakob Bornecrantz | 8e19a95 | 2010-01-30 03:38:06 +0000 | [diff] [blame] | 416 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 417 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 418 | |
| 419 | /** |
| 420 | * TTM glue - vmwgfx_ttm_glue.c |
| 421 | */ |
| 422 | |
| 423 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); |
| 424 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); |
| 425 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); |
| 426 | |
| 427 | /** |
| 428 | * TTM buffer object driver - vmwgfx_buffer.c |
| 429 | */ |
| 430 | |
| 431 | extern struct ttm_placement vmw_vram_placement; |
| 432 | extern struct ttm_placement vmw_vram_ne_placement; |
Thomas Hellstrom | 8ba5152 | 2010-01-16 16:05:05 +0100 | [diff] [blame] | 433 | extern struct ttm_placement vmw_vram_sys_placement; |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 434 | extern struct ttm_placement vmw_vram_gmr_placement; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 435 | extern struct ttm_placement vmw_sys_placement; |
| 436 | extern struct ttm_bo_driver vmw_bo_driver; |
| 437 | extern int vmw_dma_quiescent(struct drm_device *dev); |
| 438 | |
| 439 | /** |
| 440 | * Command submission - vmwgfx_execbuf.c |
| 441 | */ |
| 442 | |
| 443 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, |
| 444 | struct drm_file *file_priv); |
| 445 | |
| 446 | /** |
| 447 | * IRQs and wating - vmwgfx_irq.c |
| 448 | */ |
| 449 | |
| 450 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); |
| 451 | extern int vmw_wait_fence(struct vmw_private *dev_priv, bool lazy, |
| 452 | uint32_t sequence, bool interruptible, |
| 453 | unsigned long timeout); |
| 454 | extern void vmw_irq_preinstall(struct drm_device *dev); |
| 455 | extern int vmw_irq_postinstall(struct drm_device *dev); |
| 456 | extern void vmw_irq_uninstall(struct drm_device *dev); |
| 457 | extern bool vmw_fence_signaled(struct vmw_private *dev_priv, |
| 458 | uint32_t sequence); |
| 459 | extern int vmw_fence_wait_ioctl(struct drm_device *dev, void *data, |
| 460 | struct drm_file *file_priv); |
| 461 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
| 462 | bool lazy, |
| 463 | bool fifo_idle, |
| 464 | uint32_t sequence, |
| 465 | bool interruptible, |
| 466 | unsigned long timeout); |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 467 | extern void vmw_update_sequence(struct vmw_private *dev_priv, |
| 468 | struct vmw_fifo_state *fifo_state); |
| 469 | |
| 470 | |
| 471 | /** |
| 472 | * Rudimentary fence objects currently used only for throttling - |
| 473 | * vmwgfx_fence.c |
| 474 | */ |
| 475 | |
| 476 | extern void vmw_fence_queue_init(struct vmw_fence_queue *queue); |
| 477 | extern void vmw_fence_queue_takedown(struct vmw_fence_queue *queue); |
| 478 | extern int vmw_fence_push(struct vmw_fence_queue *queue, |
| 479 | uint32_t sequence); |
| 480 | extern int vmw_fence_pull(struct vmw_fence_queue *queue, |
| 481 | uint32_t signaled_sequence); |
| 482 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
| 483 | struct vmw_fence_queue *queue, uint32_t us); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 484 | |
| 485 | /** |
| 486 | * Kernel framebuffer - vmwgfx_fb.c |
| 487 | */ |
| 488 | |
| 489 | int vmw_fb_init(struct vmw_private *vmw_priv); |
| 490 | int vmw_fb_close(struct vmw_private *dev_priv); |
| 491 | int vmw_fb_off(struct vmw_private *vmw_priv); |
| 492 | int vmw_fb_on(struct vmw_private *vmw_priv); |
| 493 | |
| 494 | /** |
| 495 | * Kernel modesetting - vmwgfx_kms.c |
| 496 | */ |
| 497 | |
| 498 | int vmw_kms_init(struct vmw_private *dev_priv); |
| 499 | int vmw_kms_close(struct vmw_private *dev_priv); |
| 500 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); |
| 501 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); |
| 502 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, |
| 503 | struct drm_file *file_priv); |
| 504 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); |
| 505 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, |
| 506 | struct ttm_object_file *tfile, |
| 507 | struct ttm_buffer_object *bo, |
| 508 | SVGA3dCmdHeader *header); |
Michel Dänzer | 0bef23f | 2011-08-31 07:42:50 +0000 | [diff] [blame] | 509 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
| 510 | unsigned width, unsigned height, unsigned pitch, |
| 511 | unsigned bpp, unsigned depth); |
Thomas Hellstrom | 3a939a5 | 2010-10-05 12:43:03 +0200 | [diff] [blame] | 512 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
Thomas Hellstrom | e133e73 | 2010-10-05 12:43:04 +0200 | [diff] [blame] | 513 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
| 514 | uint32_t pitch, |
| 515 | uint32_t height); |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 516 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 517 | |
| 518 | /** |
| 519 | * Overlay control - vmwgfx_overlay.c |
| 520 | */ |
| 521 | |
| 522 | int vmw_overlay_init(struct vmw_private *dev_priv); |
| 523 | int vmw_overlay_close(struct vmw_private *dev_priv); |
| 524 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, |
| 525 | struct drm_file *file_priv); |
| 526 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); |
| 527 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); |
| 528 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); |
| 529 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); |
| 530 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); |
| 531 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); |
| 532 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); |
| 533 | |
| 534 | /** |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 535 | * GMR Id manager |
| 536 | */ |
| 537 | |
| 538 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
| 539 | |
| 540 | /** |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 541 | * Inline helper functions |
| 542 | */ |
| 543 | |
| 544 | static inline void vmw_surface_unreference(struct vmw_surface **srf) |
| 545 | { |
| 546 | struct vmw_surface *tmp_srf = *srf; |
| 547 | struct vmw_resource *res = &tmp_srf->res; |
| 548 | *srf = NULL; |
| 549 | |
| 550 | vmw_resource_unreference(&res); |
| 551 | } |
| 552 | |
| 553 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) |
| 554 | { |
| 555 | (void) vmw_resource_reference(&srf->res); |
| 556 | return srf; |
| 557 | } |
| 558 | |
| 559 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) |
| 560 | { |
| 561 | struct vmw_dma_buffer *tmp_buf = *buf; |
| 562 | struct ttm_buffer_object *bo = &tmp_buf->base; |
| 563 | *buf = NULL; |
| 564 | |
| 565 | ttm_bo_unref(&bo); |
| 566 | } |
| 567 | |
| 568 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) |
| 569 | { |
| 570 | if (ttm_bo_reference(&buf->base)) |
| 571 | return buf; |
| 572 | return NULL; |
| 573 | } |
| 574 | |
| 575 | #endif |