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