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