drm_device.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 inode;
  18. struct pci_dev;
  19. struct pci_controller;
  20. /**
  21. * DRM device structure. This structure represent a complete card that
  22. * may contain multiple heads.
  23. */
  24. struct drm_device {
  25. struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
  26. int if_version; /**< Highest interface version set */
  27. /** \name Lifetime Management */
  28. /*@{ */
  29. struct kref ref; /**< Object ref-count */
  30. struct device *dev; /**< Device structure of bus-device */
  31. struct drm_driver *driver; /**< DRM driver managing the device */
  32. void *dev_private; /**< DRM driver private data */
  33. struct drm_minor *control; /**< Control node */
  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. atomic_t unplugged; /**< Flag whether dev is dead */
  40. struct inode *anon_inode; /**< inode for private address-space */
  41. char *unique; /**< unique name of the device */
  42. /*@} */
  43. /** \name Locks */
  44. /*@{ */
  45. struct mutex struct_mutex; /**< For others */
  46. struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
  47. /*@} */
  48. /** \name Usage Counters */
  49. /*@{ */
  50. int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
  51. spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
  52. int buf_use; /**< Buffers in use -- cannot alloc */
  53. atomic_t buf_alloc; /**< Buffer allocation in progress */
  54. /*@} */
  55. struct mutex filelist_mutex;
  56. struct list_head filelist;
  57. /** \name Memory management */
  58. /*@{ */
  59. struct list_head maplist; /**< Linked list of regions */
  60. struct drm_open_hash map_hash; /**< User token hash table for maps */
  61. /** \name Context handle management */
  62. /*@{ */
  63. struct list_head ctxlist; /**< Linked list of context handles */
  64. struct mutex ctxlist_mutex; /**< For ctxlist */
  65. struct idr ctx_idr;
  66. struct list_head vmalist; /**< List of vmas (for debugging) */
  67. /*@} */
  68. /** \name DMA support */
  69. /*@{ */
  70. struct drm_device_dma *dma; /**< Optional pointer for DMA support */
  71. /*@} */
  72. /** \name Context support */
  73. /*@{ */
  74. __volatile__ long context_flag; /**< Context swapping flag */
  75. int last_context; /**< Last current context */
  76. /*@} */
  77. /**
  78. * @irq_enabled:
  79. *
  80. * Indicates that interrupt handling is enabled, specifically vblank
  81. * handling. Drivers which don't use drm_irq_install() need to set this
  82. * to true manually.
  83. */
  84. bool irq_enabled;
  85. int irq;
  86. /**
  87. * @vblank_disable_immediate:
  88. *
  89. * If true, vblank interrupt will be disabled immediately when the
  90. * refcount drops to zero, as opposed to via the vblank disable
  91. * timer.
  92. *
  93. * This can be set to true it the hardware has a working vblank counter
  94. * with high-precision timestamping (otherwise there are races) and the
  95. * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
  96. * appropriately. See also @max_vblank_count and
  97. * &drm_crtc_funcs.get_vblank_counter.
  98. */
  99. bool vblank_disable_immediate;
  100. /**
  101. * @vblank:
  102. *
  103. * Array of vblank tracking structures, one per &struct drm_crtc. For
  104. * historical reasons (vblank support predates kernel modesetting) this
  105. * is free-standing and not part of &struct drm_crtc itself. It must be
  106. * initialized explicitly by calling drm_vblank_init().
  107. */
  108. struct drm_vblank_crtc *vblank;
  109. spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
  110. spinlock_t vbl_lock;
  111. /**
  112. * @max_vblank_count:
  113. *
  114. * Maximum value of the vblank registers. This value +1 will result in a
  115. * wrap-around of the vblank register. It is used by the vblank core to
  116. * handle wrap-arounds.
  117. *
  118. * If set to zero the vblank core will try to guess the elapsed vblanks
  119. * between times when the vblank interrupt is disabled through
  120. * high-precision timestamps. That approach is suffering from small
  121. * races and imprecision over longer time periods, hence exposing a
  122. * hardware vblank counter is always recommended.
  123. *
  124. * If non-zeor, &drm_crtc_funcs.get_vblank_counter must be set.
  125. */
  126. u32 max_vblank_count; /**< size of vblank counter register */
  127. /**
  128. * List of events
  129. */
  130. struct list_head vblank_event_list;
  131. spinlock_t event_lock;
  132. /*@} */
  133. struct drm_agp_head *agp; /**< AGP data */
  134. struct pci_dev *pdev; /**< PCI device structure */
  135. #ifdef __alpha__
  136. struct pci_controller *hose;
  137. #endif
  138. struct drm_sg_mem *sg; /**< Scatter gather memory */
  139. unsigned int num_crtcs; /**< Number of CRTCs on this device */
  140. struct {
  141. int context;
  142. struct drm_hw_lock *lock;
  143. } sigdata;
  144. struct drm_local_map *agp_buffer_map;
  145. unsigned int agp_buffer_token;
  146. struct drm_mode_config mode_config; /**< Current mode config */
  147. /** \name GEM information */
  148. /*@{ */
  149. struct mutex object_name_lock;
  150. struct idr object_name_idr;
  151. struct drm_vma_offset_manager *vma_offset_manager;
  152. /*@} */
  153. int switch_power_state;
  154. };
  155. #endif