Linux Audio

Check our new training course

Loading...
v6.13.7
  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_mode_config.h>
 10
 11struct drm_driver;
 12struct drm_minor;
 13struct drm_master;
 
 14struct drm_vblank_crtc;
 
 
 15struct drm_vma_offset_manager;
 16struct drm_vram_mm;
 17struct drm_fb_helper;
 18
 19struct inode;
 20
 21struct pci_dev;
 22struct pci_controller;
 23
 24
 25/**
 26 * enum switch_power_state - power state of drm device
 27 */
 28
 29enum switch_power_state {
 30	/** @DRM_SWITCH_POWER_ON: Power state is ON */
 31	DRM_SWITCH_POWER_ON = 0,
 32
 33	/** @DRM_SWITCH_POWER_OFF: Power state is OFF */
 34	DRM_SWITCH_POWER_OFF = 1,
 35
 36	/** @DRM_SWITCH_POWER_CHANGING: Power state is changing */
 37	DRM_SWITCH_POWER_CHANGING = 2,
 38
 39	/** @DRM_SWITCH_POWER_DYNAMIC_OFF: Suspended */
 40	DRM_SWITCH_POWER_DYNAMIC_OFF = 3,
 41};
 42
 43/**
 44 * struct drm_device - DRM device structure
 45 *
 46 * This structure represent a complete card that
 47 * may contain multiple heads.
 48 */
 49struct drm_device {
 50	/** @if_version: Highest interface version set */
 51	int if_version;
 52
 53	/** @ref: Object ref-count */
 54	struct kref ref;
 55
 56	/** @dev: Device structure of bus-device */
 57	struct device *dev;
 58
 59	/**
 60	 * @managed:
 61	 *
 62	 * Managed resources linked to the lifetime of this &drm_device as
 63	 * tracked by @ref.
 64	 */
 65	struct {
 66		/** @managed.resources: managed resources list */
 67		struct list_head resources;
 68		/** @managed.final_kfree: pointer for final kfree() call */
 69		void *final_kfree;
 70		/** @managed.lock: protects @managed.resources */
 71		spinlock_t lock;
 72	} managed;
 73
 74	/** @driver: DRM driver managing the device */
 75	const struct drm_driver *driver;
 76
 77	/**
 78	 * @dev_private:
 79	 *
 80	 * DRM driver private data. This is deprecated and should be left set to
 81	 * NULL.
 82	 *
 83	 * Instead of using this pointer it is recommended that drivers use
 84	 * devm_drm_dev_alloc() and embed struct &drm_device in their larger
 85	 * per-device structure.
 86	 */
 87	void *dev_private;
 88
 89	/**
 90	 * @primary:
 91	 *
 92	 * Primary node. Drivers should not interact with this
 93	 * directly. debugfs interfaces can be registered with
 94	 * drm_debugfs_add_file(), and sysfs should be directly added on the
 95	 * hardware (and not character device node) struct device @dev.
 96	 */
 97	struct drm_minor *primary;
 98
 99	/**
100	 * @render:
101	 *
102	 * Render node. Drivers should not interact with this directly ever.
103	 * Drivers should not expose any additional interfaces in debugfs or
104	 * sysfs on this node.
105	 */
106	struct drm_minor *render;
107
108	/** @accel: Compute Acceleration node */
109	struct drm_minor *accel;
110
111	/**
112	 * @registered:
113	 *
114	 * Internally used by drm_dev_register() and drm_connector_register().
115	 */
116	bool registered;
117
118	/**
119	 * @master:
120	 *
121	 * Currently active master for this device.
122	 * Protected by &master_mutex
123	 */
124	struct drm_master *master;
125
126	/**
127	 * @driver_features: per-device driver features
128	 *
129	 * Drivers can clear specific flags here to disallow
130	 * certain features on a per-device basis while still
131	 * sharing a single &struct drm_driver instance across
132	 * all devices.
133	 */
134	u32 driver_features;
 
 
 
 
 
 
 
 
 
135
136	/**
137	 * @unplugged:
138	 *
139	 * Flag to tell if the device has been unplugged.
140	 * See drm_dev_enter() and drm_dev_is_unplugged().
141	 */
142	bool unplugged;
143
144	/** @anon_inode: inode for private address-space */
145	struct inode *anon_inode;
 
 
146
147	/** @unique: Unique name of the device */
148	char *unique;
 
 
149
150	/**
151	 * @struct_mutex:
152	 *
153	 * Lock for others (not &drm_minor.master and &drm_file.is_master)
154	 *
155	 * TODO: This lock used to be the BKL of the DRM subsystem. Move the
156	 *       lock into i915, which is the only remaining user.
157	 */
158	struct mutex struct_mutex;
159
160	/**
161	 * @master_mutex:
162	 *
163	 * Lock for &drm_minor.master and &drm_file.is_master
164	 */
165	struct mutex master_mutex;
166
167	/**
168	 * @open_count:
169	 *
170	 * Usage counter for outstanding files open,
171	 * protected by drm_global_mutex
172	 */
173	atomic_t open_count;
174
175	/** @filelist_mutex: Protects @filelist. */
176	struct mutex filelist_mutex;
177	/**
178	 * @filelist:
179	 *
180	 * List of userspace clients, linked through &drm_file.lhead.
181	 */
182	struct list_head filelist;
183
184	/**
185	 * @filelist_internal:
186	 *
187	 * List of open DRM files for in-kernel clients.
188	 * Protected by &filelist_mutex.
189	 */
190	struct list_head filelist_internal;
191
192	/**
193	 * @clientlist_mutex:
194	 *
195	 * Protects &clientlist access.
196	 */
197	struct mutex clientlist_mutex;
198
199	/**
200	 * @clientlist:
201	 *
202	 * List of in-kernel clients. Protected by &clientlist_mutex.
 
 
203	 */
204	struct list_head clientlist;
 
205
206	/**
207	 * @vblank_disable_immediate:
208	 *
209	 * If true, vblank interrupt will be disabled immediately when the
210	 * refcount drops to zero, as opposed to via the vblank disable
211	 * timer.
212	 *
213	 * This can be set to true it the hardware has a working vblank counter
214	 * with high-precision timestamping (otherwise there are races) and the
215	 * driver uses drm_crtc_vblank_on() and drm_crtc_vblank_off()
216	 * appropriately. Also, see @max_vblank_count,
217	 * &drm_crtc_funcs.get_vblank_counter and
218	 * &drm_vblank_crtc_config.disable_immediate.
219	 */
220	bool vblank_disable_immediate;
221
222	/**
223	 * @vblank:
224	 *
225	 * Array of vblank tracking structures, one per &struct drm_crtc. For
226	 * historical reasons (vblank support predates kernel modesetting) this
227	 * is free-standing and not part of &struct drm_crtc itself. It must be
228	 * initialized explicitly by calling drm_vblank_init().
229	 */
230	struct drm_vblank_crtc *vblank;
231
232	/**
233	 * @vblank_time_lock:
234	 *
235	 *  Protects vblank count and time updates during vblank enable/disable
236	 */
237	spinlock_t vblank_time_lock;
238	/**
239	 * @vbl_lock: Top-level vblank references lock, wraps the low-level
240	 * @vblank_time_lock.
241	 */
242	spinlock_t vbl_lock;
243
244	/**
245	 * @max_vblank_count:
246	 *
247	 * Maximum value of the vblank registers. This value +1 will result in a
248	 * wrap-around of the vblank register. It is used by the vblank core to
249	 * handle wrap-arounds.
250	 *
251	 * If set to zero the vblank core will try to guess the elapsed vblanks
252	 * between times when the vblank interrupt is disabled through
253	 * high-precision timestamps. That approach is suffering from small
254	 * races and imprecision over longer time periods, hence exposing a
255	 * hardware vblank counter is always recommended.
256	 *
257	 * This is the statically configured device wide maximum. The driver
258	 * can instead choose to use a runtime configurable per-crtc value
259	 * &drm_vblank_crtc.max_vblank_count, in which case @max_vblank_count
260	 * must be left at zero. See drm_crtc_set_max_vblank_count() on how
261	 * to use the per-crtc value.
262	 *
263	 * If non-zero, &drm_crtc_funcs.get_vblank_counter must be set.
264	 */
265	u32 max_vblank_count;
266
267	/** @vblank_event_list: List of vblank events */
268	struct list_head vblank_event_list;
269
270	/**
271	 * @event_lock:
272	 *
273	 * Protects @vblank_event_list and event delivery in
274	 * general. See drm_send_event() and drm_send_event_locked().
275	 */
 
276	spinlock_t event_lock;
277
278	/** @num_crtcs: Number of CRTCs on this device */
279	unsigned int num_crtcs;
280
281	/** @mode_config: Current mode config */
282	struct drm_mode_config mode_config;
283
284	/** @object_name_lock: GEM information */
285	struct mutex object_name_lock;
 
 
286
287	/** @object_name_idr: GEM information */
288	struct idr object_name_idr;
289
290	/** @vma_offset_manager: GEM information */
291	struct drm_vma_offset_manager *vma_offset_manager;
 
 
292
293	/** @vram_mm: VRAM MM memory manager */
294	struct drm_vram_mm *vram_mm;
295
296	/**
297	 * @switch_power_state:
298	 *
299	 * Power state of the client.
300	 * Used by drivers supporting the switcheroo driver.
301	 * The state is maintained in the
302	 * &vga_switcheroo_client_ops.set_gpu_state callback
303	 */
304	enum switch_power_state switch_power_state;
305
306	/**
307	 * @fb_helper:
308	 *
309	 * Pointer to the fbdev emulation structure.
310	 * Set by drm_fb_helper_init() and cleared by drm_fb_helper_fini().
311	 */
312	struct drm_fb_helper *fb_helper;
313
314	/**
315	 * @debugfs_root:
316	 *
317	 * Root directory for debugfs files.
318	 */
319	struct dentry *debugfs_root;
320};
321
322#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