drm_device.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. /** \name Memory management */
  64. /*@{ */
  65. struct list_head maplist; /**< Linked list of regions */
  66. struct drm_open_hash map_hash; /**< User token hash table for maps */
  67. /** \name Context handle management */
  68. /*@{ */
  69. struct list_head ctxlist; /**< Linked list of context handles */
  70. struct mutex ctxlist_mutex; /**< For ctxlist */
  71. struct idr ctx_idr;
  72. struct list_head vmalist; /**< List of vmas (for debugging) */
  73. /*@} */
  74. /** \name DMA support */
  75. /*@{ */
  76. struct drm_device_dma *dma; /**< Optional pointer for DMA support */
  77. /*@} */
  78. /** \name Context support */
  79. /*@{ */
  80. __volatile__ long context_flag; /**< Context swapping flag */
  81. int last_context; /**< Last current context */
  82. /*@} */
  83. /**
  84. * @irq_enabled:
  85. *
  86. * Indicates that interrupt handling is enabled, specifically vblank
  87. * handling. Drivers which don't use drm_irq_install() need to set this
  88. * to true manually.
  89. */
  90. bool irq_enabled;
  91. int irq;
  92. /**
  93. * @vblank_disable_immediate:
  94. *
  95. * If true, vblank interrupt will be disabled immediately when the
  96. * refcount drops to zero, as opposed to via the vblank disable
  97. * timer.
  98. *
  99. * This can be set to true it the hardware has a working vblank counter
  100. * with high-precision timestamping (otherwise there are races) and the
  101. * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
  102. * appropriately. See also @max_vblank_count and
  103. * &drm_crtc_funcs.get_vblank_counter.
  104. */
  105. bool vblank_disable_immediate;
  106. /**
  107. * @vblank:
  108. *
  109. * Array of vblank tracking structures, one per &struct drm_crtc. For
  110. * historical reasons (vblank support predates kernel modesetting) this
  111. * is free-standing and not part of &struct drm_crtc itself. It must be
  112. * initialized explicitly by calling drm_vblank_init().
  113. */
  114. struct drm_vblank_crtc *vblank;
  115. spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
  116. spinlock_t vbl_lock;
  117. /**
  118. * @max_vblank_count:
  119. *
  120. * Maximum value of the vblank registers. This value +1 will result in a
  121. * wrap-around of the vblank register. It is used by the vblank core to
  122. * handle wrap-arounds.
  123. *
  124. * If set to zero the vblank core will try to guess the elapsed vblanks
  125. * between times when the vblank interrupt is disabled through
  126. * high-precision timestamps. That approach is suffering from small
  127. * races and imprecision over longer time periods, hence exposing a
  128. * hardware vblank counter is always recommended.
  129. *
  130. * If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
  131. */
  132. u32 max_vblank_count; /**< size of vblank counter register */
  133. /**
  134. * List of events
  135. */
  136. struct list_head vblank_event_list;
  137. spinlock_t event_lock;
  138. /*@} */
  139. struct drm_agp_head *agp; /**< AGP data */
  140. struct pci_dev *pdev; /**< PCI device structure */
  141. #ifdef __alpha__
  142. struct pci_controller *hose;
  143. #endif
  144. struct drm_sg_mem *sg; /**< Scatter gather memory */
  145. unsigned int num_crtcs; /**< Number of CRTCs on this device */
  146. struct {
  147. int context;
  148. struct drm_hw_lock *lock;
  149. } sigdata;
  150. struct drm_local_map *agp_buffer_map;
  151. unsigned int agp_buffer_token;
  152. struct drm_mode_config mode_config; /**< Current mode config */
  153. /** \name GEM information */
  154. /*@{ */
  155. struct mutex object_name_lock;
  156. struct idr object_name_idr;
  157. struct drm_vma_offset_manager *vma_offset_manager;
  158. /*@} */
  159. int switch_power_state;
  160. /**
  161. * @fb_helper:
  162. *
  163. * Pointer to the fbdev emulation structure.
  164. * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
  165. */
  166. struct drm_fb_helper *fb_helper;
  167. };
  168. #endif