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 | e5ed157 | 2011-10-04 20:13:35 +0200 | [diff] [blame] | 43 | #define VMWGFX_DRIVER_DATE "20110927" |
Thomas Hellstrom | 2ae7b03 | 2011-09-01 20:18:45 +0000 | [diff] [blame] | 44 | #define VMWGFX_DRIVER_MAJOR 2 |
Thomas Hellstrom | e5ed157 | 2011-10-04 20:13:35 +0200 | [diff] [blame] | 45 | #define VMWGFX_DRIVER_MINOR 1 |
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; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 82 | void (*remove_from_lists) (struct vmw_resource *res); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 83 | void (*hw_destroy) (struct vmw_resource *res); |
| 84 | void (*res_free) (struct vmw_resource *res); |
Thomas Hellstrom | f18c884 | 2011-10-04 20:13:31 +0200 | [diff] [blame] | 85 | struct list_head validate_head; |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 86 | struct list_head query_head; /* Protected by the cmdbuf mutex */ |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 87 | /* TODO is a generic snooper needed? */ |
| 88 | #if 0 |
| 89 | void (*snoop)(struct vmw_resource *res, |
| 90 | struct ttm_object_file *tfile, |
| 91 | SVGA3dCmdHeader *header); |
| 92 | void *snoop_priv; |
| 93 | #endif |
| 94 | }; |
| 95 | |
| 96 | struct vmw_cursor_snooper { |
| 97 | struct drm_crtc *crtc; |
| 98 | size_t age; |
| 99 | uint32_t *image; |
| 100 | }; |
| 101 | |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 102 | struct vmw_framebuffer; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 103 | struct vmw_surface_offset; |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 104 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 105 | struct vmw_surface { |
| 106 | struct vmw_resource res; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 107 | struct list_head lru_head; /* Protected by the resource lock */ |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 108 | uint32_t flags; |
| 109 | uint32_t format; |
| 110 | uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES]; |
| 111 | struct drm_vmw_size *sizes; |
| 112 | uint32_t num_sizes; |
| 113 | |
Jakob Bornecrantz | 5ffdb65 | 2010-01-30 03:38:08 +0000 | [diff] [blame] | 114 | bool scanout; |
| 115 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 116 | /* TODO so far just a extra pointer */ |
| 117 | struct vmw_cursor_snooper snooper; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 118 | struct ttm_buffer_object *backup; |
| 119 | struct vmw_surface_offset *offsets; |
| 120 | uint32_t backup_size; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 123 | struct vmw_marker_queue { |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 124 | struct list_head head; |
| 125 | struct timespec lag; |
| 126 | struct timespec lag_time; |
| 127 | spinlock_t lock; |
| 128 | }; |
| 129 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 130 | struct vmw_fifo_state { |
| 131 | unsigned long reserved_size; |
| 132 | __le32 *dynamic_buffer; |
| 133 | __le32 *static_buffer; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 134 | unsigned long static_buffer_size; |
| 135 | bool using_bounce_buffer; |
| 136 | uint32_t capabilities; |
Thomas Hellstrom | 85b9e48 | 2010-02-08 09:57:25 +0000 | [diff] [blame] | 137 | struct mutex fifo_mutex; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 138 | struct rw_semaphore rwsem; |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 139 | struct vmw_marker_queue marker_queue; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | struct vmw_relocation { |
| 143 | SVGAGuestPtr *location; |
| 144 | uint32_t index; |
| 145 | }; |
| 146 | |
| 147 | struct vmw_sw_context{ |
| 148 | struct ida bo_list; |
| 149 | uint32_t last_cid; |
| 150 | bool cid_valid; |
Thomas Hellstrom | 922ade0 | 2011-10-04 20:13:17 +0200 | [diff] [blame] | 151 | bool kernel; /**< is the called made from the kernel */ |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 152 | struct vmw_resource *cur_ctx; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 153 | uint32_t last_sid; |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 154 | uint32_t sid_translation; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 155 | bool sid_valid; |
| 156 | struct ttm_object_file *tfile; |
| 157 | struct list_head validate_nodes; |
| 158 | struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS]; |
| 159 | uint32_t cur_reloc; |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 160 | struct ttm_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS]; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 161 | uint32_t cur_val_buf; |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 162 | uint32_t *cmd_bounce; |
| 163 | uint32_t cmd_bounce_size; |
Thomas Hellstrom | f18c884 | 2011-10-04 20:13:31 +0200 | [diff] [blame] | 164 | struct list_head resource_list; |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 165 | uint32_t fence_flags; |
| 166 | struct list_head query_list; |
| 167 | struct ttm_buffer_object *cur_query_bo; |
| 168 | uint32_t cur_query_cid; |
| 169 | bool query_cid_valid; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct vmw_legacy_display; |
| 173 | struct vmw_overlay; |
| 174 | |
| 175 | struct vmw_master { |
| 176 | struct ttm_lock lock; |
Thomas Hellstrom | 3a939a5 | 2010-10-05 12:43:03 +0200 | [diff] [blame] | 177 | struct mutex fb_surf_mutex; |
| 178 | struct list_head fb_surf; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 181 | struct vmw_vga_topology_state { |
| 182 | uint32_t width; |
| 183 | uint32_t height; |
| 184 | uint32_t primary; |
| 185 | uint32_t pos_x; |
| 186 | uint32_t pos_y; |
| 187 | }; |
| 188 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 189 | struct vmw_private { |
| 190 | struct ttm_bo_device bdev; |
| 191 | struct ttm_bo_global_ref bo_global_ref; |
Dave Airlie | ba4420c | 2010-03-09 10:56:52 +1000 | [diff] [blame] | 192 | struct drm_global_reference mem_global_ref; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 193 | |
| 194 | struct vmw_fifo_state fifo; |
| 195 | |
| 196 | struct drm_device *dev; |
| 197 | unsigned long vmw_chipset; |
| 198 | unsigned int io_start; |
| 199 | uint32_t vram_start; |
| 200 | uint32_t vram_size; |
| 201 | uint32_t mmio_start; |
| 202 | uint32_t mmio_size; |
| 203 | uint32_t fb_max_width; |
| 204 | uint32_t fb_max_height; |
| 205 | __le32 __iomem *mmio_virt; |
| 206 | int mmio_mtrr; |
| 207 | uint32_t capabilities; |
| 208 | uint32_t max_gmr_descriptors; |
| 209 | uint32_t max_gmr_ids; |
Thomas Hellstrom | fb17f18 | 2011-08-31 07:42:53 +0000 | [diff] [blame] | 210 | uint32_t max_gmr_pages; |
| 211 | uint32_t memory_size; |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 212 | bool has_gmr; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 213 | struct mutex hw_mutex; |
| 214 | |
| 215 | /* |
| 216 | * VGA registers. |
| 217 | */ |
| 218 | |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 219 | struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS]; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 220 | uint32_t vga_width; |
| 221 | uint32_t vga_height; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 222 | uint32_t vga_bpp; |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 223 | uint32_t vga_bpl; |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 224 | uint32_t vga_pitchlock; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 225 | |
Thomas Hellstrom | 7c4f778 | 2010-06-01 11:38:17 +0200 | [diff] [blame] | 226 | uint32_t num_displays; |
| 227 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 228 | /* |
| 229 | * Framebuffer info. |
| 230 | */ |
| 231 | |
| 232 | void *fb_info; |
| 233 | struct vmw_legacy_display *ldu_priv; |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 234 | struct vmw_screen_object_display *sou_priv; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 235 | struct vmw_overlay *overlay_priv; |
| 236 | |
| 237 | /* |
| 238 | * Context and surface management. |
| 239 | */ |
| 240 | |
| 241 | rwlock_t resource_lock; |
| 242 | struct idr context_idr; |
| 243 | struct idr surface_idr; |
| 244 | struct idr stream_idr; |
| 245 | |
| 246 | /* |
| 247 | * Block lastclose from racing with firstopen. |
| 248 | */ |
| 249 | |
| 250 | struct mutex init_mutex; |
| 251 | |
| 252 | /* |
| 253 | * A resource manager for kernel-only surfaces and |
| 254 | * contexts. |
| 255 | */ |
| 256 | |
| 257 | struct ttm_object_device *tdev; |
| 258 | |
| 259 | /* |
| 260 | * Fencing and IRQs. |
| 261 | */ |
| 262 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 263 | atomic_t marker_seq; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 264 | wait_queue_head_t fence_queue; |
| 265 | wait_queue_head_t fifo_queue; |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 266 | int fence_queue_waiters; /* Protected by hw_mutex */ |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 267 | atomic_t fifo_queue_waiters; |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 268 | uint32_t last_read_seqno; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 269 | spinlock_t irq_lock; |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 270 | struct vmw_fence_manager *fman; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 271 | |
| 272 | /* |
| 273 | * Device state |
| 274 | */ |
| 275 | |
| 276 | uint32_t traces_state; |
| 277 | uint32_t enable_state; |
| 278 | uint32_t config_done_state; |
| 279 | |
| 280 | /** |
| 281 | * Execbuf |
| 282 | */ |
| 283 | /** |
| 284 | * Protected by the cmdbuf mutex. |
| 285 | */ |
| 286 | |
| 287 | struct vmw_sw_context ctx; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 288 | struct mutex cmdbuf_mutex; |
| 289 | |
| 290 | /** |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 291 | * Operating mode. |
| 292 | */ |
| 293 | |
| 294 | bool stealth; |
| 295 | bool is_opened; |
Thomas Hellstrom | 30c78bb | 2010-10-01 10:21:48 +0200 | [diff] [blame] | 296 | bool enable_fb; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 297 | |
| 298 | /** |
| 299 | * Master management. |
| 300 | */ |
| 301 | |
| 302 | struct vmw_master *active_master; |
| 303 | struct vmw_master fbdev_master; |
Thomas Hellstrom | d9f36a0 | 2010-01-13 22:28:43 +0100 | [diff] [blame] | 304 | struct notifier_block pm_nb; |
Thomas Hellstrom | 094e0fa | 2010-10-05 12:43:00 +0200 | [diff] [blame] | 305 | bool suspended; |
Thomas Hellstrom | 30c78bb | 2010-10-01 10:21:48 +0200 | [diff] [blame] | 306 | |
| 307 | struct mutex release_mutex; |
| 308 | uint32_t num_3d_resources; |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 309 | |
| 310 | /* |
| 311 | * Query processing. These members |
| 312 | * are protected by the cmdbuf mutex. |
| 313 | */ |
| 314 | |
| 315 | struct ttm_buffer_object *dummy_query_bo; |
| 316 | struct ttm_buffer_object *pinned_bo; |
| 317 | uint32_t query_cid; |
| 318 | bool dummy_query_bo_pinned; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 319 | |
| 320 | /* |
| 321 | * Surface swapping. The "surface_lru" list is protected by the |
| 322 | * resource lock in order to be able to destroy a surface and take |
| 323 | * it off the lru atomically. "used_memory_size" is currently |
| 324 | * protected by the cmdbuf mutex for simplicity. |
| 325 | */ |
| 326 | |
| 327 | struct list_head surface_lru; |
| 328 | uint32_t used_memory_size; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 329 | }; |
| 330 | |
| 331 | static inline struct vmw_private *vmw_priv(struct drm_device *dev) |
| 332 | { |
| 333 | return (struct vmw_private *)dev->dev_private; |
| 334 | } |
| 335 | |
| 336 | static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv) |
| 337 | { |
| 338 | return (struct vmw_fpriv *)file_priv->driver_priv; |
| 339 | } |
| 340 | |
| 341 | static inline struct vmw_master *vmw_master(struct drm_master *master) |
| 342 | { |
| 343 | return (struct vmw_master *) master->driver_priv; |
| 344 | } |
| 345 | |
| 346 | static inline void vmw_write(struct vmw_private *dev_priv, |
| 347 | unsigned int offset, uint32_t value) |
| 348 | { |
| 349 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
| 350 | outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT); |
| 351 | } |
| 352 | |
| 353 | static inline uint32_t vmw_read(struct vmw_private *dev_priv, |
| 354 | unsigned int offset) |
| 355 | { |
| 356 | uint32_t val; |
| 357 | |
| 358 | outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT); |
| 359 | val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT); |
| 360 | return val; |
| 361 | } |
| 362 | |
Thomas Hellstrom | 05730b3 | 2011-08-31 07:42:52 +0000 | [diff] [blame] | 363 | int vmw_3d_resource_inc(struct vmw_private *dev_priv, bool unhide_svga); |
| 364 | 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] | 365 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 366 | /** |
| 367 | * GMR utilities - vmwgfx_gmr.c |
| 368 | */ |
| 369 | |
| 370 | extern int vmw_gmr_bind(struct vmw_private *dev_priv, |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 371 | struct page *pages[], |
| 372 | unsigned long num_pages, |
| 373 | int gmr_id); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 374 | extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); |
| 375 | |
| 376 | /** |
| 377 | * Resource utilities - vmwgfx_resource.c |
| 378 | */ |
| 379 | |
| 380 | extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv); |
| 381 | extern void vmw_resource_unreference(struct vmw_resource **p_res); |
| 382 | extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res); |
| 383 | extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data, |
| 384 | struct drm_file *file_priv); |
| 385 | extern int vmw_context_define_ioctl(struct drm_device *dev, void *data, |
| 386 | struct drm_file *file_priv); |
| 387 | extern int vmw_context_check(struct vmw_private *dev_priv, |
| 388 | struct ttm_object_file *tfile, |
Thomas Hellstrom | be38ab6 | 2011-08-31 07:42:54 +0000 | [diff] [blame] | 389 | int id, |
| 390 | struct vmw_resource **p_res); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 391 | extern void vmw_surface_res_free(struct vmw_resource *res); |
| 392 | extern int vmw_surface_init(struct vmw_private *dev_priv, |
| 393 | struct vmw_surface *srf, |
| 394 | void (*res_free) (struct vmw_resource *res)); |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 395 | extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, |
| 396 | struct ttm_object_file *tfile, |
| 397 | uint32_t handle, |
| 398 | struct vmw_surface **out); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 399 | extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data, |
| 400 | struct drm_file *file_priv); |
| 401 | extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data, |
| 402 | struct drm_file *file_priv); |
| 403 | extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, |
| 404 | struct drm_file *file_priv); |
| 405 | extern int vmw_surface_check(struct vmw_private *dev_priv, |
| 406 | struct ttm_object_file *tfile, |
Thomas Hellstrom | 7a73ba7 | 2009-12-22 16:53:41 +0100 | [diff] [blame] | 407 | uint32_t handle, int *id); |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 408 | extern int vmw_surface_validate(struct vmw_private *dev_priv, |
| 409 | struct vmw_surface *srf); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 410 | extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo); |
| 411 | extern int vmw_dmabuf_init(struct vmw_private *dev_priv, |
| 412 | struct vmw_dma_buffer *vmw_bo, |
| 413 | size_t size, struct ttm_placement *placement, |
| 414 | bool interuptable, |
| 415 | void (*bo_free) (struct ttm_buffer_object *bo)); |
| 416 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
| 417 | struct drm_file *file_priv); |
| 418 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, |
| 419 | struct drm_file *file_priv); |
| 420 | extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo, |
| 421 | uint32_t cur_validate_node); |
| 422 | extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo); |
| 423 | extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, |
| 424 | uint32_t id, struct vmw_dma_buffer **out); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 425 | extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, |
| 426 | struct drm_file *file_priv); |
| 427 | extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, |
| 428 | struct drm_file *file_priv); |
| 429 | extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, |
| 430 | struct ttm_object_file *tfile, |
| 431 | uint32_t *inout_id, |
| 432 | struct vmw_resource **out); |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 433 | extern void vmw_resource_unreserve(struct list_head *list); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 434 | |
Jakob Bornecrantz | d991ef0 | 2011-10-04 20:13:21 +0200 | [diff] [blame] | 435 | /** |
| 436 | * DMA buffer helper routines - vmwgfx_dmabuf.c |
| 437 | */ |
| 438 | extern int vmw_dmabuf_to_placement(struct vmw_private *vmw_priv, |
| 439 | struct vmw_dma_buffer *bo, |
| 440 | struct ttm_placement *placement, |
| 441 | bool interruptible); |
| 442 | extern int vmw_dmabuf_to_vram(struct vmw_private *dev_priv, |
| 443 | struct vmw_dma_buffer *buf, |
| 444 | bool pin, bool interruptible); |
| 445 | extern int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv, |
| 446 | struct vmw_dma_buffer *buf, |
| 447 | bool pin, bool interruptible); |
| 448 | extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv, |
| 449 | struct vmw_dma_buffer *bo, |
| 450 | bool pin, bool interruptible); |
| 451 | extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, |
| 452 | struct vmw_dma_buffer *bo, |
| 453 | bool interruptible); |
Thomas Hellstrom | b37a6b9 | 2011-10-04 20:13:28 +0200 | [diff] [blame] | 454 | extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, |
| 455 | SVGAGuestPtr *ptr); |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 456 | extern void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 457 | |
| 458 | /** |
| 459 | * Misc Ioctl functionality - vmwgfx_ioctl.c |
| 460 | */ |
| 461 | |
| 462 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
| 463 | struct drm_file *file_priv); |
Thomas Hellstrom | f63f6a5 | 2011-09-01 20:18:41 +0000 | [diff] [blame] | 464 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, |
| 465 | struct drm_file *file_priv); |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 466 | extern int vmw_present_ioctl(struct drm_device *dev, void *data, |
| 467 | struct drm_file *file_priv); |
| 468 | extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data, |
| 469 | struct drm_file *file_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 470 | |
| 471 | /** |
| 472 | * Fifo utilities - vmwgfx_fifo.c |
| 473 | */ |
| 474 | |
| 475 | extern int vmw_fifo_init(struct vmw_private *dev_priv, |
| 476 | struct vmw_fifo_state *fifo); |
| 477 | extern void vmw_fifo_release(struct vmw_private *dev_priv, |
| 478 | struct vmw_fifo_state *fifo); |
| 479 | extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); |
| 480 | extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); |
| 481 | extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 482 | uint32_t *seqno); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 483 | 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] | 484 | extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 485 | extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 486 | extern int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
| 487 | uint32_t cid); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 488 | |
| 489 | /** |
| 490 | * TTM glue - vmwgfx_ttm_glue.c |
| 491 | */ |
| 492 | |
| 493 | extern int vmw_ttm_global_init(struct vmw_private *dev_priv); |
| 494 | extern void vmw_ttm_global_release(struct vmw_private *dev_priv); |
| 495 | extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); |
| 496 | |
| 497 | /** |
| 498 | * TTM buffer object driver - vmwgfx_buffer.c |
| 499 | */ |
| 500 | |
| 501 | extern struct ttm_placement vmw_vram_placement; |
| 502 | extern struct ttm_placement vmw_vram_ne_placement; |
Thomas Hellstrom | 8ba5152 | 2010-01-16 16:05:05 +0100 | [diff] [blame] | 503 | extern struct ttm_placement vmw_vram_sys_placement; |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 504 | extern struct ttm_placement vmw_vram_gmr_placement; |
Jakob Bornecrantz | d991ef0 | 2011-10-04 20:13:21 +0200 | [diff] [blame] | 505 | extern struct ttm_placement vmw_vram_gmr_ne_placement; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 506 | extern struct ttm_placement vmw_sys_placement; |
Jakob Bornecrantz | d991ef0 | 2011-10-04 20:13:21 +0200 | [diff] [blame] | 507 | extern struct ttm_placement vmw_evictable_placement; |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 508 | extern struct ttm_placement vmw_srf_placement; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 509 | extern struct ttm_bo_driver vmw_bo_driver; |
| 510 | extern int vmw_dma_quiescent(struct drm_device *dev); |
| 511 | |
| 512 | /** |
| 513 | * Command submission - vmwgfx_execbuf.c |
| 514 | */ |
| 515 | |
| 516 | extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, |
| 517 | struct drm_file *file_priv); |
Thomas Hellstrom | 922ade0 | 2011-10-04 20:13:17 +0200 | [diff] [blame] | 518 | extern int vmw_execbuf_process(struct drm_file *file_priv, |
| 519 | struct vmw_private *dev_priv, |
| 520 | void __user *user_commands, |
| 521 | void *kernel_commands, |
| 522 | uint32_t command_size, |
| 523 | uint64_t throttle_us, |
| 524 | struct drm_vmw_fence_rep __user |
| 525 | *user_fence_rep); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 526 | |
Thomas Hellstrom | e2fa3a7 | 2011-10-04 20:13:30 +0200 | [diff] [blame] | 527 | extern void |
| 528 | vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv, |
| 529 | bool only_on_cid_match, uint32_t cid); |
| 530 | |
Thomas Hellstrom | 5bb39e8 | 2011-10-04 20:13:33 +0200 | [diff] [blame] | 531 | extern int vmw_execbuf_fence_commands(struct drm_file *file_priv, |
| 532 | struct vmw_private *dev_priv, |
| 533 | struct vmw_fence_obj **p_fence, |
| 534 | uint32_t *p_handle); |
| 535 | |
| 536 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 537 | /** |
| 538 | * IRQs and wating - vmwgfx_irq.c |
| 539 | */ |
| 540 | |
| 541 | extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS); |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 542 | extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy, |
| 543 | uint32_t seqno, bool interruptible, |
| 544 | unsigned long timeout); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 545 | extern void vmw_irq_preinstall(struct drm_device *dev); |
| 546 | extern int vmw_irq_postinstall(struct drm_device *dev); |
| 547 | extern void vmw_irq_uninstall(struct drm_device *dev); |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 548 | extern bool vmw_seqno_passed(struct vmw_private *dev_priv, |
| 549 | uint32_t seqno); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 550 | extern int vmw_fallback_wait(struct vmw_private *dev_priv, |
| 551 | bool lazy, |
| 552 | bool fifo_idle, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 553 | uint32_t seqno, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 554 | bool interruptible, |
| 555 | unsigned long timeout); |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 556 | extern void vmw_update_seqno(struct vmw_private *dev_priv, |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 557 | struct vmw_fifo_state *fifo_state); |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 558 | extern void vmw_seqno_waiter_add(struct vmw_private *dev_priv); |
| 559 | extern void vmw_seqno_waiter_remove(struct vmw_private *dev_priv); |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 560 | |
| 561 | /** |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 562 | * Rudimentary fence-like objects currently used only for throttling - |
| 563 | * vmwgfx_marker.c |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 564 | */ |
| 565 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 566 | extern void vmw_marker_queue_init(struct vmw_marker_queue *queue); |
| 567 | extern void vmw_marker_queue_takedown(struct vmw_marker_queue *queue); |
| 568 | extern int vmw_marker_push(struct vmw_marker_queue *queue, |
| 569 | uint32_t seqno); |
| 570 | extern int vmw_marker_pull(struct vmw_marker_queue *queue, |
| 571 | uint32_t signaled_seqno); |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 572 | extern int vmw_wait_lag(struct vmw_private *dev_priv, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 573 | struct vmw_marker_queue *queue, uint32_t us); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 574 | |
| 575 | /** |
| 576 | * Kernel framebuffer - vmwgfx_fb.c |
| 577 | */ |
| 578 | |
| 579 | int vmw_fb_init(struct vmw_private *vmw_priv); |
| 580 | int vmw_fb_close(struct vmw_private *dev_priv); |
| 581 | int vmw_fb_off(struct vmw_private *vmw_priv); |
| 582 | int vmw_fb_on(struct vmw_private *vmw_priv); |
| 583 | |
| 584 | /** |
| 585 | * Kernel modesetting - vmwgfx_kms.c |
| 586 | */ |
| 587 | |
| 588 | int vmw_kms_init(struct vmw_private *dev_priv); |
| 589 | int vmw_kms_close(struct vmw_private *dev_priv); |
| 590 | int vmw_kms_save_vga(struct vmw_private *vmw_priv); |
| 591 | int vmw_kms_restore_vga(struct vmw_private *vmw_priv); |
| 592 | int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data, |
| 593 | struct drm_file *file_priv); |
| 594 | void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv); |
| 595 | void vmw_kms_cursor_snoop(struct vmw_surface *srf, |
| 596 | struct ttm_object_file *tfile, |
| 597 | struct ttm_buffer_object *bo, |
| 598 | SVGA3dCmdHeader *header); |
Michel Dänzer | 0bef23f | 2011-08-31 07:42:50 +0000 | [diff] [blame] | 599 | int vmw_kms_write_svga(struct vmw_private *vmw_priv, |
| 600 | unsigned width, unsigned height, unsigned pitch, |
| 601 | unsigned bpp, unsigned depth); |
Thomas Hellstrom | 3a939a5 | 2010-10-05 12:43:03 +0200 | [diff] [blame] | 602 | void vmw_kms_idle_workqueues(struct vmw_master *vmaster); |
Thomas Hellstrom | e133e737 | 2010-10-05 12:43:04 +0200 | [diff] [blame] | 603 | bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, |
| 604 | uint32_t pitch, |
| 605 | uint32_t height); |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 606 | u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc); |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 607 | int vmw_kms_present(struct vmw_private *dev_priv, |
| 608 | struct drm_file *file_priv, |
| 609 | struct vmw_framebuffer *vfb, |
| 610 | struct vmw_surface *surface, |
| 611 | uint32_t sid, int32_t destX, int32_t destY, |
| 612 | struct drm_vmw_rect *clips, |
| 613 | uint32_t num_clips); |
| 614 | int vmw_kms_readback(struct vmw_private *dev_priv, |
| 615 | struct drm_file *file_priv, |
| 616 | struct vmw_framebuffer *vfb, |
| 617 | struct drm_vmw_fence_rep __user *user_fence_rep, |
| 618 | struct drm_vmw_rect *clips, |
| 619 | uint32_t num_clips); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 620 | |
| 621 | /** |
| 622 | * Overlay control - vmwgfx_overlay.c |
| 623 | */ |
| 624 | |
| 625 | int vmw_overlay_init(struct vmw_private *dev_priv); |
| 626 | int vmw_overlay_close(struct vmw_private *dev_priv); |
| 627 | int vmw_overlay_ioctl(struct drm_device *dev, void *data, |
| 628 | struct drm_file *file_priv); |
| 629 | int vmw_overlay_stop_all(struct vmw_private *dev_priv); |
| 630 | int vmw_overlay_resume_all(struct vmw_private *dev_priv); |
| 631 | int vmw_overlay_pause_all(struct vmw_private *dev_priv); |
| 632 | int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out); |
| 633 | int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); |
| 634 | int vmw_overlay_num_overlays(struct vmw_private *dev_priv); |
| 635 | int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); |
| 636 | |
| 637 | /** |
Thomas Hellstrom | 135cba0 | 2010-10-26 21:21:47 +0200 | [diff] [blame] | 638 | * GMR Id manager |
| 639 | */ |
| 640 | |
| 641 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
| 642 | |
| 643 | /** |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 644 | * Inline helper functions |
| 645 | */ |
| 646 | |
| 647 | static inline void vmw_surface_unreference(struct vmw_surface **srf) |
| 648 | { |
| 649 | struct vmw_surface *tmp_srf = *srf; |
| 650 | struct vmw_resource *res = &tmp_srf->res; |
| 651 | *srf = NULL; |
| 652 | |
| 653 | vmw_resource_unreference(&res); |
| 654 | } |
| 655 | |
| 656 | static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf) |
| 657 | { |
| 658 | (void) vmw_resource_reference(&srf->res); |
| 659 | return srf; |
| 660 | } |
| 661 | |
| 662 | static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf) |
| 663 | { |
| 664 | struct vmw_dma_buffer *tmp_buf = *buf; |
| 665 | struct ttm_buffer_object *bo = &tmp_buf->base; |
| 666 | *buf = NULL; |
| 667 | |
| 668 | ttm_bo_unref(&bo); |
| 669 | } |
| 670 | |
| 671 | static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf) |
| 672 | { |
| 673 | if (ttm_bo_reference(&buf->base)) |
| 674 | return buf; |
| 675 | return NULL; |
| 676 | } |
| 677 | |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 678 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
| 679 | { |
| 680 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; |
| 681 | } |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 682 | #endif |