vmwgfx_drv.h 21 KB

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