| .. | .. |
|---|
| 17 | 17 | struct drm_sg_mem; |
|---|
| 18 | 18 | struct drm_local_map; |
|---|
| 19 | 19 | struct drm_vma_offset_manager; |
|---|
| 20 | +struct drm_vram_mm; |
|---|
| 20 | 21 | struct drm_fb_helper; |
|---|
| 21 | 22 | |
|---|
| 22 | 23 | struct inode; |
|---|
| .. | .. |
|---|
| 24 | 25 | struct pci_dev; |
|---|
| 25 | 26 | struct pci_controller; |
|---|
| 26 | 27 | |
|---|
| 28 | + |
|---|
| 27 | 29 | /** |
|---|
| 28 | | - * DRM device structure. This structure represent a complete card that |
|---|
| 30 | + * enum drm_switch_power - power state of drm device |
|---|
| 31 | + */ |
|---|
| 32 | + |
|---|
| 33 | +enum switch_power_state { |
|---|
| 34 | + /** @DRM_SWITCH_POWER_ON: Power state is ON */ |
|---|
| 35 | + DRM_SWITCH_POWER_ON = 0, |
|---|
| 36 | + |
|---|
| 37 | + /** @DRM_SWITCH_POWER_OFF: Power state is OFF */ |
|---|
| 38 | + DRM_SWITCH_POWER_OFF = 1, |
|---|
| 39 | + |
|---|
| 40 | + /** @DRM_SWITCH_POWER_CHANGING: Power state is changing */ |
|---|
| 41 | + DRM_SWITCH_POWER_CHANGING = 2, |
|---|
| 42 | + |
|---|
| 43 | + /** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */ |
|---|
| 44 | + DRM_SWITCH_POWER_DYNAMIC_OFF = 3, |
|---|
| 45 | +}; |
|---|
| 46 | + |
|---|
| 47 | +/** |
|---|
| 48 | + * struct drm_device - DRM device structure |
|---|
| 49 | + * |
|---|
| 50 | + * This structure represent a complete card that |
|---|
| 29 | 51 | * may contain multiple heads. |
|---|
| 30 | 52 | */ |
|---|
| 31 | 53 | struct drm_device { |
|---|
| 32 | | - struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
|---|
| 33 | | - int if_version; /**< Highest interface version set */ |
|---|
| 54 | + /** |
|---|
| 55 | + * @legacy_dev_list: |
|---|
| 56 | + * |
|---|
| 57 | + * List of devices per driver for stealth attach cleanup |
|---|
| 58 | + */ |
|---|
| 59 | + struct list_head legacy_dev_list; |
|---|
| 34 | 60 | |
|---|
| 35 | | - /** \name Lifetime Management */ |
|---|
| 36 | | - /*@{ */ |
|---|
| 37 | | - struct kref ref; /**< Object ref-count */ |
|---|
| 38 | | - struct device *dev; /**< Device structure of bus-device */ |
|---|
| 39 | | - struct drm_driver *driver; /**< DRM driver managing the device */ |
|---|
| 40 | | - void *dev_private; /**< DRM driver private data */ |
|---|
| 41 | | - struct drm_minor *primary; /**< Primary node */ |
|---|
| 42 | | - struct drm_minor *render; /**< Render node */ |
|---|
| 61 | + /** @if_version: Highest interface version set */ |
|---|
| 62 | + int if_version; |
|---|
| 63 | + |
|---|
| 64 | + /** @ref: Object ref-count */ |
|---|
| 65 | + struct kref ref; |
|---|
| 66 | + |
|---|
| 67 | + /** @dev: Device structure of bus-device */ |
|---|
| 68 | + struct device *dev; |
|---|
| 69 | + |
|---|
| 70 | + /** |
|---|
| 71 | + * @managed: |
|---|
| 72 | + * |
|---|
| 73 | + * Managed resources linked to the lifetime of this &drm_device as |
|---|
| 74 | + * tracked by @ref. |
|---|
| 75 | + */ |
|---|
| 76 | + struct { |
|---|
| 77 | + /** @managed.resources: managed resources list */ |
|---|
| 78 | + struct list_head resources; |
|---|
| 79 | + /** @managed.final_kfree: pointer for final kfree() call */ |
|---|
| 80 | + void *final_kfree; |
|---|
| 81 | + /** @managed.lock: protects @managed.resources */ |
|---|
| 82 | + spinlock_t lock; |
|---|
| 83 | + } managed; |
|---|
| 84 | + |
|---|
| 85 | + /** @driver: DRM driver managing the device */ |
|---|
| 86 | + struct drm_driver *driver; |
|---|
| 87 | + |
|---|
| 88 | + /** |
|---|
| 89 | + * @dev_private: |
|---|
| 90 | + * |
|---|
| 91 | + * DRM driver private data. This is deprecated and should be left set to |
|---|
| 92 | + * NULL. |
|---|
| 93 | + * |
|---|
| 94 | + * Instead of using this pointer it is recommended that drivers use |
|---|
| 95 | + * devm_drm_dev_alloc() and embed struct &drm_device in their larger |
|---|
| 96 | + * per-device structure. |
|---|
| 97 | + */ |
|---|
| 98 | + void *dev_private; |
|---|
| 99 | + |
|---|
| 100 | + /** @primary: Primary node */ |
|---|
| 101 | + struct drm_minor *primary; |
|---|
| 102 | + |
|---|
| 103 | + /** @render: Render node */ |
|---|
| 104 | + struct drm_minor *render; |
|---|
| 105 | + |
|---|
| 106 | + /** |
|---|
| 107 | + * @registered: |
|---|
| 108 | + * |
|---|
| 109 | + * Internally used by drm_dev_register() and drm_connector_register(). |
|---|
| 110 | + */ |
|---|
| 43 | 111 | bool registered; |
|---|
| 44 | 112 | |
|---|
| 45 | | - /* currently active master for this device. Protected by master_mutex */ |
|---|
| 113 | + /** |
|---|
| 114 | + * @master: |
|---|
| 115 | + * |
|---|
| 116 | + * Currently active master for this device. |
|---|
| 117 | + * Protected by &master_mutex |
|---|
| 118 | + */ |
|---|
| 46 | 119 | struct drm_master *master; |
|---|
| 120 | + |
|---|
| 121 | + /** |
|---|
| 122 | + * @driver_features: per-device driver features |
|---|
| 123 | + * |
|---|
| 124 | + * Drivers can clear specific flags here to disallow |
|---|
| 125 | + * certain features on a per-device basis while still |
|---|
| 126 | + * sharing a single &struct drm_driver instance across |
|---|
| 127 | + * all devices. |
|---|
| 128 | + */ |
|---|
| 129 | + u32 driver_features; |
|---|
| 47 | 130 | |
|---|
| 48 | 131 | /** |
|---|
| 49 | 132 | * @unplugged: |
|---|
| .. | .. |
|---|
| 53 | 136 | */ |
|---|
| 54 | 137 | bool unplugged; |
|---|
| 55 | 138 | |
|---|
| 56 | | - struct inode *anon_inode; /**< inode for private address-space */ |
|---|
| 57 | | - char *unique; /**< unique name of the device */ |
|---|
| 58 | | - /*@} */ |
|---|
| 139 | + /** @anon_inode: inode for private address-space */ |
|---|
| 140 | + struct inode *anon_inode; |
|---|
| 59 | 141 | |
|---|
| 60 | | - /** \name Locks */ |
|---|
| 61 | | - /*@{ */ |
|---|
| 62 | | - struct mutex struct_mutex; /**< For others */ |
|---|
| 63 | | - struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
|---|
| 64 | | - /*@} */ |
|---|
| 142 | + /** @unique: Unique name of the device */ |
|---|
| 143 | + char *unique; |
|---|
| 65 | 144 | |
|---|
| 66 | | - /** \name Usage Counters */ |
|---|
| 67 | | - /*@{ */ |
|---|
| 68 | | - int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
|---|
| 69 | | - spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
|---|
| 70 | | - int buf_use; /**< Buffers in use -- cannot alloc */ |
|---|
| 71 | | - atomic_t buf_alloc; /**< Buffer allocation in progress */ |
|---|
| 72 | | - /*@} */ |
|---|
| 145 | + /** |
|---|
| 146 | + * @struct_mutex: |
|---|
| 147 | + * |
|---|
| 148 | + * Lock for others (not &drm_minor.master and &drm_file.is_master) |
|---|
| 149 | + * |
|---|
| 150 | + * WARNING: |
|---|
| 151 | + * Only drivers annotated with DRIVER_LEGACY should be using this. |
|---|
| 152 | + */ |
|---|
| 153 | + struct mutex struct_mutex; |
|---|
| 73 | 154 | |
|---|
| 155 | + /** |
|---|
| 156 | + * @master_mutex: |
|---|
| 157 | + * |
|---|
| 158 | + * Lock for &drm_minor.master and &drm_file.is_master |
|---|
| 159 | + */ |
|---|
| 160 | + struct mutex master_mutex; |
|---|
| 161 | + |
|---|
| 162 | + /** |
|---|
| 163 | + * @open_count: |
|---|
| 164 | + * |
|---|
| 165 | + * Usage counter for outstanding files open, |
|---|
| 166 | + * protected by drm_global_mutex |
|---|
| 167 | + */ |
|---|
| 168 | + atomic_t open_count; |
|---|
| 169 | + |
|---|
| 170 | + /** @filelist_mutex: Protects @filelist. */ |
|---|
| 74 | 171 | struct mutex filelist_mutex; |
|---|
| 172 | + /** |
|---|
| 173 | + * @filelist: |
|---|
| 174 | + * |
|---|
| 175 | + * List of userspace clients, linked through &drm_file.lhead. |
|---|
| 176 | + */ |
|---|
| 75 | 177 | struct list_head filelist; |
|---|
| 76 | 178 | |
|---|
| 77 | 179 | /** |
|---|
| 78 | 180 | * @filelist_internal: |
|---|
| 79 | 181 | * |
|---|
| 80 | | - * List of open DRM files for in-kernel clients. Protected by @filelist_mutex. |
|---|
| 182 | + * List of open DRM files for in-kernel clients. |
|---|
| 183 | + * Protected by &filelist_mutex. |
|---|
| 81 | 184 | */ |
|---|
| 82 | 185 | struct list_head filelist_internal; |
|---|
| 83 | 186 | |
|---|
| 84 | 187 | /** |
|---|
| 85 | 188 | * @clientlist_mutex: |
|---|
| 86 | 189 | * |
|---|
| 87 | | - * Protects @clientlist access. |
|---|
| 190 | + * Protects &clientlist access. |
|---|
| 88 | 191 | */ |
|---|
| 89 | 192 | struct mutex clientlist_mutex; |
|---|
| 90 | 193 | |
|---|
| 91 | 194 | /** |
|---|
| 92 | 195 | * @clientlist: |
|---|
| 93 | 196 | * |
|---|
| 94 | | - * List of in-kernel clients. Protected by @clientlist_mutex. |
|---|
| 197 | + * List of in-kernel clients. Protected by &clientlist_mutex. |
|---|
| 95 | 198 | */ |
|---|
| 96 | 199 | struct list_head clientlist; |
|---|
| 97 | | - |
|---|
| 98 | | - /** \name Memory management */ |
|---|
| 99 | | - /*@{ */ |
|---|
| 100 | | - struct list_head maplist; /**< Linked list of regions */ |
|---|
| 101 | | - struct drm_open_hash map_hash; /**< User token hash table for maps */ |
|---|
| 102 | | - |
|---|
| 103 | | - /** \name Context handle management */ |
|---|
| 104 | | - /*@{ */ |
|---|
| 105 | | - struct list_head ctxlist; /**< Linked list of context handles */ |
|---|
| 106 | | - struct mutex ctxlist_mutex; /**< For ctxlist */ |
|---|
| 107 | | - |
|---|
| 108 | | - struct idr ctx_idr; |
|---|
| 109 | | - |
|---|
| 110 | | - struct list_head vmalist; /**< List of vmas (for debugging) */ |
|---|
| 111 | | - |
|---|
| 112 | | - /*@} */ |
|---|
| 113 | | - |
|---|
| 114 | | - /** \name DMA support */ |
|---|
| 115 | | - /*@{ */ |
|---|
| 116 | | - struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
|---|
| 117 | | - /*@} */ |
|---|
| 118 | | - |
|---|
| 119 | | - /** \name Context support */ |
|---|
| 120 | | - /*@{ */ |
|---|
| 121 | | - |
|---|
| 122 | | - __volatile__ long context_flag; /**< Context swapping flag */ |
|---|
| 123 | | - int last_context; /**< Last current context */ |
|---|
| 124 | | - /*@} */ |
|---|
| 125 | 200 | |
|---|
| 126 | 201 | /** |
|---|
| 127 | 202 | * @irq_enabled: |
|---|
| .. | .. |
|---|
| 131 | 206 | * to true manually. |
|---|
| 132 | 207 | */ |
|---|
| 133 | 208 | bool irq_enabled; |
|---|
| 209 | + |
|---|
| 210 | + /** |
|---|
| 211 | + * @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers. |
|---|
| 212 | + */ |
|---|
| 134 | 213 | int irq; |
|---|
| 135 | 214 | |
|---|
| 136 | 215 | /** |
|---|
| .. | .. |
|---|
| 158 | 237 | */ |
|---|
| 159 | 238 | struct drm_vblank_crtc *vblank; |
|---|
| 160 | 239 | |
|---|
| 161 | | - spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
|---|
| 240 | + /** |
|---|
| 241 | + * @vblank_time_lock: |
|---|
| 242 | + * |
|---|
| 243 | + * Protects vblank count and time updates during vblank enable/disable |
|---|
| 244 | + */ |
|---|
| 245 | + spinlock_t vblank_time_lock; |
|---|
| 246 | + /** |
|---|
| 247 | + * @vbl_lock: Top-level vblank references lock, wraps the low-level |
|---|
| 248 | + * @vblank_time_lock. |
|---|
| 249 | + */ |
|---|
| 162 | 250 | spinlock_t vbl_lock; |
|---|
| 163 | 251 | |
|---|
| 164 | 252 | /** |
|---|
| .. | .. |
|---|
| 182 | 270 | * |
|---|
| 183 | 271 | * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set. |
|---|
| 184 | 272 | */ |
|---|
| 185 | | - u32 max_vblank_count; /**< size of vblank counter register */ |
|---|
| 273 | + u32 max_vblank_count; |
|---|
| 274 | + |
|---|
| 275 | + /** @vblank_event_list: List of vblank events */ |
|---|
| 276 | + struct list_head vblank_event_list; |
|---|
| 186 | 277 | |
|---|
| 187 | 278 | /** |
|---|
| 188 | | - * List of events |
|---|
| 279 | + * @event_lock: |
|---|
| 280 | + * |
|---|
| 281 | + * Protects @vblank_event_list and event delivery in |
|---|
| 282 | + * general. See drm_send_event() and drm_send_event_locked(). |
|---|
| 189 | 283 | */ |
|---|
| 190 | | - struct list_head vblank_event_list; |
|---|
| 191 | 284 | spinlock_t event_lock; |
|---|
| 192 | 285 | |
|---|
| 193 | | - /*@} */ |
|---|
| 286 | + /** @agp: AGP data */ |
|---|
| 287 | + struct drm_agp_head *agp; |
|---|
| 194 | 288 | |
|---|
| 195 | | - struct drm_agp_head *agp; /**< AGP data */ |
|---|
| 289 | + /** @pdev: PCI device structure */ |
|---|
| 290 | + struct pci_dev *pdev; |
|---|
| 196 | 291 | |
|---|
| 197 | | - struct pci_dev *pdev; /**< PCI device structure */ |
|---|
| 198 | 292 | #ifdef __alpha__ |
|---|
| 293 | + /** @hose: PCI hose, only used on ALPHA platforms. */ |
|---|
| 199 | 294 | struct pci_controller *hose; |
|---|
| 200 | 295 | #endif |
|---|
| 296 | + /** @num_crtcs: Number of CRTCs on this device */ |
|---|
| 297 | + unsigned int num_crtcs; |
|---|
| 201 | 298 | |
|---|
| 202 | | - struct drm_sg_mem *sg; /**< Scatter gather memory */ |
|---|
| 203 | | - unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
|---|
| 299 | + /** @mode_config: Current mode config */ |
|---|
| 300 | + struct drm_mode_config mode_config; |
|---|
| 301 | + |
|---|
| 302 | + /** @object_name_lock: GEM information */ |
|---|
| 303 | + struct mutex object_name_lock; |
|---|
| 304 | + |
|---|
| 305 | + /** @object_name_idr: GEM information */ |
|---|
| 306 | + struct idr object_name_idr; |
|---|
| 307 | + |
|---|
| 308 | + /** @vma_offset_manager: GEM information */ |
|---|
| 309 | + struct drm_vma_offset_manager *vma_offset_manager; |
|---|
| 310 | + |
|---|
| 311 | + /** @vram_mm: VRAM MM memory manager */ |
|---|
| 312 | + struct drm_vram_mm *vram_mm; |
|---|
| 313 | + |
|---|
| 314 | + /** |
|---|
| 315 | + * @switch_power_state: |
|---|
| 316 | + * |
|---|
| 317 | + * Power state of the client. |
|---|
| 318 | + * Used by drivers supporting the switcheroo driver. |
|---|
| 319 | + * The state is maintained in the |
|---|
| 320 | + * &vga_switcheroo_client_ops.set_gpu_state callback |
|---|
| 321 | + */ |
|---|
| 322 | + enum switch_power_state switch_power_state; |
|---|
| 323 | + |
|---|
| 324 | + /** |
|---|
| 325 | + * @fb_helper: |
|---|
| 326 | + * |
|---|
| 327 | + * Pointer to the fbdev emulation structure. |
|---|
| 328 | + * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini(). |
|---|
| 329 | + */ |
|---|
| 330 | + struct drm_fb_helper *fb_helper; |
|---|
| 331 | + |
|---|
| 332 | + /* Everything below here is for legacy driver, never use! */ |
|---|
| 333 | + /* private: */ |
|---|
| 334 | +#if IS_ENABLED(CONFIG_DRM_LEGACY) |
|---|
| 335 | + /* Context handle management - linked list of context handles */ |
|---|
| 336 | + struct list_head ctxlist; |
|---|
| 337 | + |
|---|
| 338 | + /* Context handle management - mutex for &ctxlist */ |
|---|
| 339 | + struct mutex ctxlist_mutex; |
|---|
| 340 | + |
|---|
| 341 | + /* Context handle management */ |
|---|
| 342 | + struct idr ctx_idr; |
|---|
| 343 | + |
|---|
| 344 | + /* Memory management - linked list of regions */ |
|---|
| 345 | + struct list_head maplist; |
|---|
| 346 | + |
|---|
| 347 | + /* Memory management - user token hash table for maps */ |
|---|
| 348 | + struct drm_open_hash map_hash; |
|---|
| 349 | + |
|---|
| 350 | + /* Context handle management - list of vmas (for debugging) */ |
|---|
| 351 | + struct list_head vmalist; |
|---|
| 352 | + |
|---|
| 353 | + /* Optional pointer for DMA support */ |
|---|
| 354 | + struct drm_device_dma *dma; |
|---|
| 355 | + |
|---|
| 356 | + /* Context swapping flag */ |
|---|
| 357 | + __volatile__ long context_flag; |
|---|
| 358 | + |
|---|
| 359 | + /* Last current context */ |
|---|
| 360 | + int last_context; |
|---|
| 361 | + |
|---|
| 362 | + /* Lock for &buf_use and a few other things. */ |
|---|
| 363 | + spinlock_t buf_lock; |
|---|
| 364 | + |
|---|
| 365 | + /* Usage counter for buffers in use -- cannot alloc */ |
|---|
| 366 | + int buf_use; |
|---|
| 367 | + |
|---|
| 368 | + /* Buffer allocation in progress */ |
|---|
| 369 | + atomic_t buf_alloc; |
|---|
| 204 | 370 | |
|---|
| 205 | 371 | struct { |
|---|
| 206 | 372 | int context; |
|---|
| .. | .. |
|---|
| 210 | 376 | struct drm_local_map *agp_buffer_map; |
|---|
| 211 | 377 | unsigned int agp_buffer_token; |
|---|
| 212 | 378 | |
|---|
| 213 | | - struct drm_mode_config mode_config; /**< Current mode config */ |
|---|
| 214 | | - |
|---|
| 215 | | - /** \name GEM information */ |
|---|
| 216 | | - /*@{ */ |
|---|
| 217 | | - struct mutex object_name_lock; |
|---|
| 218 | | - struct idr object_name_idr; |
|---|
| 219 | | - struct drm_vma_offset_manager *vma_offset_manager; |
|---|
| 220 | | - /*@} */ |
|---|
| 221 | | - int switch_power_state; |
|---|
| 222 | | - |
|---|
| 223 | | - /** |
|---|
| 224 | | - * @fb_helper: |
|---|
| 225 | | - * |
|---|
| 226 | | - * Pointer to the fbdev emulation structure. |
|---|
| 227 | | - * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini(). |
|---|
| 228 | | - */ |
|---|
| 229 | | - struct drm_fb_helper *fb_helper; |
|---|
| 379 | + /* Scatter gather memory */ |
|---|
| 380 | + struct drm_sg_mem *sg; |
|---|
| 381 | +#endif |
|---|
| 230 | 382 | }; |
|---|
| 231 | 383 | |
|---|
| 232 | 384 | #endif |
|---|