Linux Audio

Check our new training course

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