drm_device.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. #ifndef _DRM_DEVICE_H_
  2. #define _DRM_DEVICE_H_
  3. #include <linux/list.h>
  4. #include <linux/kref.h>
  5. #include <linux/mutex.h>
  6. #include <linux/idr.h>
  7. #include <drm/drm_hashtab.h>
  8. #include <drm/drm_mode_config.h>
  9. struct drm_driver;
  10. struct drm_minor;
  11. struct drm_master;
  12. struct drm_device_dma;
  13. struct drm_vblank_crtc;
  14. struct drm_sg_mem;
  15. struct drm_local_map;
  16. struct drm_vma_offset_manager;
  17. struct drm_fb_helper;
  18. struct inode;
  19. struct pci_dev;
  20. struct pci_controller;
  21. /**
  22. * DRM device structure. This structure represent a complete card that
  23. * may contain multiple heads.
  24. */
  25. struct drm_device {
  26. struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
  27. int if_version; /**< Highest interface version set */
  28. /** \name Lifetime Management */
  29. /*@{ */
  30. struct kref ref; /**< Object ref-count */
  31. struct device *dev; /**< Device structure of bus-device */
  32. struct drm_driver *driver; /**< DRM driver managing the device */
  33. void *dev_private; /**< DRM driver private data */
  34. struct drm_minor *primary; /**< Primary node */
  35. struct drm_minor *render; /**< Render node */
  36. bool registered;
  37. /* currently active master for this device. Protected by master_mutex */
  38. struct drm_master *master;
  39. /**
  40. * @unplugged:
  41. *
  42. * Flag to tell if the device has been unplugged.
  43. * See drm_dev_enter() and drm_dev_is_unplugged().
  44. */
  45. bool unplugged;
  46. struct inode *anon_inode; /**< inode for private address-space */
  47. char *unique; /**< unique name of the device */
  48. /*@} */
  49. /** \name Locks */
  50. /*@{ */
  51. struct mutex struct_mutex; /**< For others */
  52. struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
  53. /*@} */
  54. /** \name Usage Counters */
  55. /*@{ */
  56. int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
  57. spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
  58. int buf_use; /**< Buffers in use -- cannot alloc */
  59. atomic_t buf_alloc; /**< Buffer allocation in progress */
  60. /*@} */
  61. struct mutex filelist_mutex;
  62. struct list_head filelist;
  63. /**
  64. * @filelist_internal:
  65. *
  66. * List of open DRM files for in-kernel clients. Protected by @filelist_mutex.
  67. */
  68. struct list_head filelist_internal;
  69. /**
  70. * @clientlist_mutex:
  71. *
  72. * Protects @clientlist access.
  73. */
  74. struct mutex clientlist_mutex;
  75. /**
  76. * @clientlist:
  77. *
  78. * List of in-kernel clients. Protected by @clientlist_mutex.
  79. */
  80. struct list_head clientlist;
  81. /** \name Memory management */
  82. /*@{ */
  83. struct list_head maplist; /**< Linked list of regions */
  84. struct drm_open_hash map_hash; /**< User token hash table for maps */
  85. /** \name Context handle management */
  86. /*@{ */
  87. struct list_head ctxlist; /**< Linked list of context handles */
  88. struct mutex ctxlist_mutex; /**< For ctxlist */
  89. struct idr ctx_idr;
  90. struct list_head vmalist; /**< List of vmas (for debugging) */
  91. /*@} */
  92. /** \name DMA support */
  93. /*@{ */
  94. struct drm_device_dma *dma; /**< Optional pointer for DMA support */
  95. /*@} */
  96. /** \name Context support */
  97. /*@{ */
  98. __volatile__ long context_flag; /**< Context swapping flag */
  99. int last_context; /**< Last current context */
  100. /*@} */
  101. /**
  102. * @irq_enabled:
  103. *
  104. * Indicates that interrupt handling is enabled, specifically vblank
  105. * handling. Drivers which don't use drm_irq_install() need to set this
  106. * to true manually.
  107. */
  108. bool irq_enabled;
  109. int irq;
  110. /**
  111. * @vblank_disable_immediate:
  112. *
  113. * If true, vblank interrupt will be disabled immediately when the
  114. * refcount drops to zero, as opposed to via the vblank disable
  115. * timer.
  116. *
  117. * This can be set to true it the hardware has a working vblank counter
  118. * with high-precision timestamping (otherwise there are races) and the
  119. * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
  120. * appropriately. See also @max_vblank_count and
  121. * &drm_crtc_funcs.get_vblank_counter.
  122. */
  123. bool vblank_disable_immediate;
  124. /**
  125. * @vblank:
  126. *
  127. * Array of vblank tracking structures, one per &struct drm_crtc. For
  128. * historical reasons (vblank support predates kernel modesetting) this
  129. * is free-standing and not part of &struct drm_crtc itself. It must be
  130. * initialized explicitly by calling drm_vblank_init().
  131. */
  132. struct drm_vblank_crtc *vblank;
  133. spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
  134. spinlock_t vbl_lock;
  135. /**
  136. * @max_vblank_count:
  137. *
  138. * Maximum value of the vblank registers. This value +1 will result in a
  139. * wrap-around of the vblank register. It is used by the vblank core to
  140. * handle wrap-arounds.
  141. *
  142. * If set to zero the vblank core will try to guess the elapsed vblanks
  143. * between times when the vblank interrupt is disabled through
  144. * high-precision timestamps. That approach is suffering from small
  145. * races and imprecision over longer time periods, hence exposing a
  146. * hardware vblank counter is always recommended.
  147. *
  148. * This is the statically configured device wide maximum. The driver
  149. * can instead choose to use a runtime configurable per-crtc value
  150. * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
  151. * must be left at zero. See drm_crtc_set_max_vblank_count() on how
  152. * to use the per-crtc value.
  153. *
  154. * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
  155. */
  156. u32 max_vblank_count; /**< size of vblank counter register */
  157. /**
  158. * List of events
  159. */
  160. struct list_head vblank_event_list;
  161. spinlock_t event_lock;
  162. /*@} */
  163. struct drm_agp_head *agp; /**< AGP data */
  164. struct pci_dev *pdev; /**< PCI device structure */
  165. #ifdef __alpha__
  166. struct pci_controller *hose;
  167. #endif
  168. struct drm_sg_mem *sg; /**< Scatter gather memory */
  169. unsigned int num_crtcs; /**< Number of CRTCs on this device */
  170. struct {
  171. int context;
  172. struct drm_hw_lock *lock;
  173. } sigdata;
  174. struct drm_local_map *agp_buffer_map;
  175. unsigned int agp_buffer_token;
  176. struct drm_mode_config mode_config; /**< Current mode config */
  177. /** \name GEM information */
  178. /*@{ */
  179. struct mutex object_name_lock;
  180. struct idr object_name_idr;
  181. struct drm_vma_offset_manager *vma_offset_manager;
  182. /*@} */
  183. int switch_power_state;
  184. /**
  185. * @fb_helper:
  186. *
  187. * Pointer to the fbdev emulation structure.
  188. * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
  189. */
  190. struct drm_fb_helper *fb_helper;
  191. };
  192. #endif