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