Linux Audio

Check our new training course

Loading...
v5.4
  1/*
  2 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  4 * Copyright (c) 2009-2010, Code Aurora Forum.
  5 * All rights reserved.
  6 *
  7 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  8 * Author: Gareth Hughes <gareth@valinux.com>
  9 *
 10 * Permission is hereby granted, free of charge, to any person obtaining a
 11 * copy of this software and associated documentation files (the "Software"),
 12 * to deal in the Software without restriction, including without limitation
 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14 * and/or sell copies of the Software, and to permit persons to whom the
 15 * Software is furnished to do so, subject to the following conditions:
 16 *
 17 * The above copyright notice and this permission notice (including the next
 18 * paragraph) shall be included in all copies or substantial portions of the
 19 * Software.
 20 *
 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 27 * OTHER DEALINGS IN THE SOFTWARE.
 28 */
 29
 30#ifndef _DRM_FILE_H_
 31#define _DRM_FILE_H_
 32
 33#include <linux/types.h>
 34#include <linux/completion.h>
 35#include <linux/idr.h>
 36
 37#include <uapi/drm/drm.h>
 38
 39#include <drm/drm_prime.h>
 40
 41struct dma_fence;
 42struct drm_file;
 43struct drm_device;
 
 44struct device;
 
 
 
 45
 46/*
 47 * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
 48 * header include loops we need it here for now.
 49 */
 50
 51/* Note that the order of this enum is ABI (it determines
 52 * /dev/dri/renderD* numbers).
 
 
 
 53 */
 54enum drm_minor_type {
 55	DRM_MINOR_PRIMARY,
 56	DRM_MINOR_CONTROL,
 57	DRM_MINOR_RENDER,
 
 58};
 59
 60/**
 61 * struct drm_minor - DRM device minor structure
 62 *
 63 * This structure represents a DRM minor number for device nodes in /dev.
 64 * Entirely opaque to drivers and should never be inspected directly by drivers.
 65 * Drivers instead should only interact with &struct drm_file and of course
 66 * &struct drm_device, which is also where driver-private data and resources can
 67 * be attached to.
 68 */
 69struct drm_minor {
 70	/* private: */
 71	int index;			/* Minor device number */
 72	int type;                       /* Control or render */
 73	struct device *kdev;		/* Linux device */
 74	struct drm_device *dev;
 75
 
 76	struct dentry *debugfs_root;
 77
 78	struct list_head debugfs_list;
 79	struct mutex debugfs_lock; /* Protects debugfs_list. */
 80};
 81
 82/**
 83 * struct drm_pending_event - Event queued up for userspace to read
 84 *
 85 * This represents a DRM event. Drivers can use this as a generic completion
 86 * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
 87 * and also the DRM-specific &struct drm_event delivery mechanism.
 88 */
 89struct drm_pending_event {
 90	/**
 91	 * @completion:
 92	 *
 93	 * Optional pointer to a kernel internal completion signalled when
 94	 * drm_send_event() is called, useful to internally synchronize with
 95	 * nonblocking operations.
 96	 */
 97	struct completion *completion;
 98
 99	/**
100	 * @completion_release:
101	 *
102	 * Optional callback currently only used by the atomic modeset helpers
103	 * to clean up the reference count for the structure @completion is
104	 * stored in.
105	 */
106	void (*completion_release)(struct completion *completion);
107
108	/**
109	 * @event:
110	 *
111	 * Pointer to the actual event that should be sent to userspace to be
112	 * read using drm_read(). Can be optional, since nowadays events are
113	 * also used to signal kernel internal threads with @completion or DMA
114	 * transactions using @fence.
115	 */
116	struct drm_event *event;
117
118	/**
119	 * @fence:
120	 *
121	 * Optional DMA fence to unblock other hardware transactions which
122	 * depend upon the nonblocking DRM operation this event represents.
123	 */
124	struct dma_fence *fence;
125
126	/**
127	 * @file_priv:
128	 *
129	 * &struct drm_file where @event should be delivered to. Only set when
130	 * @event is set.
131	 */
132	struct drm_file *file_priv;
133
134	/**
135	 * @link:
136	 *
137	 * Double-linked list to keep track of this event. Can be used by the
138	 * driver up to the point when it calls drm_send_event(), after that
139	 * this list entry is owned by the core for its own book-keeping.
140	 */
141	struct list_head link;
142
143	/**
144	 * @pending_link:
145	 *
146	 * Entry on &drm_file.pending_event_list, to keep track of all pending
147	 * events for @file_priv, to allow correct unwinding of them when
148	 * userspace closes the file before the event is delivered.
149	 */
150	struct list_head pending_link;
151};
152
153/**
154 * struct drm_file - DRM file private data
155 *
156 * This structure tracks DRM state per open file descriptor.
157 */
158struct drm_file {
159	/**
160	 * @authenticated:
161	 *
162	 * Whether the client is allowed to submit rendering, which for legacy
163	 * nodes means it must be authenticated.
164	 *
165	 * See also the :ref:`section on primary nodes and authentication
166	 * <drm_primary_node>`.
167	 */
168	bool authenticated;
169
170	/**
171	 * @stereo_allowed:
172	 *
173	 * True when the client has asked us to expose stereo 3D mode flags.
174	 */
175	bool stereo_allowed;
176
177	/**
178	 * @universal_planes:
179	 *
180	 * True if client understands CRTC primary planes and cursor planes
181	 * in the plane list. Automatically set when @atomic is set.
182	 */
183	bool universal_planes;
184
185	/** @atomic: True if client understands atomic properties. */
186	bool atomic;
187
188	/**
189	 * @aspect_ratio_allowed:
190	 *
191	 * True, if client can handle picture aspect ratios, and has requested
192	 * to pass this information along with the mode.
193	 */
194	bool aspect_ratio_allowed;
195
196	/**
197	 * @writeback_connectors:
198	 *
199	 * True if client understands writeback connectors
200	 */
201	bool writeback_connectors;
202
203	/**
 
 
 
 
 
 
 
 
 
 
 
204	 * @is_master:
205	 *
206	 * This client is the creator of @master. Protected by struct
207	 * &drm_device.master_mutex.
208	 *
209	 * See also the :ref:`section on primary nodes and authentication
210	 * <drm_primary_node>`.
211	 */
212	bool is_master;
213
214	/**
 
 
 
 
 
 
 
 
 
 
 
 
215	 * @master:
216	 *
217	 * Master this node is currently associated with. Only relevant if
218	 * drm_is_primary_client() returns true. Note that this only
219	 * matches &drm_device.master if the master is the currently active one.
 
 
 
 
 
 
 
 
 
 
 
 
 
220	 *
221	 * See also @authentication and @is_master and the :ref:`section on
222	 * primary nodes and authentication <drm_primary_node>`.
223	 */
224	struct drm_master *master;
225
226	/** @pid: Process that opened this file. */
227	struct pid *pid;
 
 
 
 
 
 
 
 
 
 
 
 
 
228
229	/** @magic: Authentication magic, see @authenticated. */
230	drm_magic_t magic;
231
232	/**
233	 * @lhead:
234	 *
235	 * List of all open files of a DRM device, linked into
236	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
237	 */
238	struct list_head lhead;
239
240	/** @minor: &struct drm_minor for this file. */
241	struct drm_minor *minor;
242
243	/**
244	 * @object_idr:
245	 *
246	 * Mapping of mm object handles to object pointers. Used by the GEM
247	 * subsystem. Protected by @table_lock.
248	 */
249	struct idr object_idr;
250
251	/** @table_lock: Protects @object_idr. */
252	spinlock_t table_lock;
253
254	/** @syncobj_idr: Mapping of sync object handles to object pointers. */
255	struct idr syncobj_idr;
256	/** @syncobj_table_lock: Protects @syncobj_idr. */
257	spinlock_t syncobj_table_lock;
258
259	/** @filp: Pointer to the core file structure. */
260	struct file *filp;
261
262	/**
263	 * @driver_priv:
264	 *
265	 * Optional pointer for driver private data. Can be allocated in
266	 * &drm_driver.open and should be freed in &drm_driver.postclose.
267	 */
268	void *driver_priv;
269
270	/**
271	 * @fbs:
272	 *
273	 * List of &struct drm_framebuffer associated with this file, using the
274	 * &drm_framebuffer.filp_head entry.
275	 *
276	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
277	 * the framebuffer object to prevent it from untimely disappearing.
278	 */
279	struct list_head fbs;
280
281	/** @fbs_lock: Protects @fbs. */
282	struct mutex fbs_lock;
283
284	/**
285	 * @blobs:
286	 *
287	 * User-created blob properties; this retains a reference on the
288	 * property.
289	 *
290	 * Protected by @drm_mode_config.blob_lock;
291	 */
292	struct list_head blobs;
293
294	/** @event_wait: Waitqueue for new events added to @event_list. */
295	wait_queue_head_t event_wait;
296
297	/**
298	 * @pending_event_list:
299	 *
300	 * List of pending &struct drm_pending_event, used to clean up pending
301	 * events in case this file gets closed before the event is signalled.
302	 * Uses the &drm_pending_event.pending_link entry.
303	 *
304	 * Protect by &drm_device.event_lock.
305	 */
306	struct list_head pending_event_list;
307
308	/**
309	 * @event_list:
310	 *
311	 * List of &struct drm_pending_event, ready for delivery to userspace
312	 * through drm_read(). Uses the &drm_pending_event.link entry.
313	 *
314	 * Protect by &drm_device.event_lock.
315	 */
316	struct list_head event_list;
317
318	/**
319	 * @event_space:
320	 *
321	 * Available event space to prevent userspace from
322	 * exhausting kernel memory. Currently limited to the fairly arbitrary
323	 * value of 4KB.
324	 */
325	int event_space;
326
327	/** @event_read_lock: Serializes drm_read(). */
328	struct mutex event_read_lock;
329
330	/**
331	 * @prime:
332	 *
333	 * Per-file buffer caches used by the PRIME buffer sharing code.
334	 */
335	struct drm_prime_file_private prime;
336
337	/* private: */
338#if IS_ENABLED(CONFIG_DRM_LEGACY)
339	unsigned long lock_count; /* DRI1 legacy lock count */
340#endif
 
 
 
 
 
 
 
341};
342
343/**
344 * drm_is_primary_client - is this an open file of the primary node
345 * @file_priv: DRM file
346 *
347 * Returns true if this is an open file of the primary node, i.e.
348 * &drm_file.minor of @file_priv is a primary minor.
349 *
350 * See also the :ref:`section on primary nodes and authentication
351 * <drm_primary_node>`.
352 */
353static inline bool drm_is_primary_client(const struct drm_file *file_priv)
354{
355	return file_priv->minor->type == DRM_MINOR_PRIMARY;
356}
357
358/**
359 * drm_is_render_client - is this an open file of the render node
360 * @file_priv: DRM file
361 *
362 * Returns true if this is an open file of the render node, i.e.
363 * &drm_file.minor of @file_priv is a render minor.
364 *
365 * See also the :ref:`section on render nodes <drm_render_node>`.
366 */
367static inline bool drm_is_render_client(const struct drm_file *file_priv)
368{
369	return file_priv->minor->type == DRM_MINOR_RENDER;
370}
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372int drm_open(struct inode *inode, struct file *filp);
 
373ssize_t drm_read(struct file *filp, char __user *buffer,
374		 size_t count, loff_t *offset);
375int drm_release(struct inode *inode, struct file *filp);
 
376__poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
377int drm_event_reserve_init_locked(struct drm_device *dev,
378				  struct drm_file *file_priv,
379				  struct drm_pending_event *p,
380				  struct drm_event *e);
381int drm_event_reserve_init(struct drm_device *dev,
382			   struct drm_file *file_priv,
383			   struct drm_pending_event *p,
384			   struct drm_event *e);
385void drm_event_cancel_free(struct drm_device *dev,
386			   struct drm_pending_event *p);
387void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
388void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
390#endif /* _DRM_FILE_H_ */
v6.13.7
  1/*
  2 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  4 * Copyright (c) 2009-2010, Code Aurora Forum.
  5 * All rights reserved.
  6 *
  7 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  8 * Author: Gareth Hughes <gareth@valinux.com>
  9 *
 10 * Permission is hereby granted, free of charge, to any person obtaining a
 11 * copy of this software and associated documentation files (the "Software"),
 12 * to deal in the Software without restriction, including without limitation
 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14 * and/or sell copies of the Software, and to permit persons to whom the
 15 * Software is furnished to do so, subject to the following conditions:
 16 *
 17 * The above copyright notice and this permission notice (including the next
 18 * paragraph) shall be included in all copies or substantial portions of the
 19 * Software.
 20 *
 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 27 * OTHER DEALINGS IN THE SOFTWARE.
 28 */
 29
 30#ifndef _DRM_FILE_H_
 31#define _DRM_FILE_H_
 32
 33#include <linux/types.h>
 34#include <linux/completion.h>
 35#include <linux/idr.h>
 36
 37#include <uapi/drm/drm.h>
 38
 39#include <drm/drm_prime.h>
 40
 41struct dma_fence;
 42struct drm_file;
 43struct drm_device;
 44struct drm_printer;
 45struct device;
 46struct file;
 47
 48extern struct xarray drm_minors_xa;
 49
 50/*
 51 * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
 52 * header include loops we need it here for now.
 53 */
 54
 55/* Note that the values of this enum are ABI (it determines
 56 * /dev/dri/renderD* numbers).
 57 *
 58 * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
 59 * be implemented before we hit any future
 60 */
 61enum drm_minor_type {
 62	DRM_MINOR_PRIMARY = 0,
 63	DRM_MINOR_CONTROL = 1,
 64	DRM_MINOR_RENDER = 2,
 65	DRM_MINOR_ACCEL = 32,
 66};
 67
 68/**
 69 * struct drm_minor - DRM device minor structure
 70 *
 71 * This structure represents a DRM minor number for device nodes in /dev.
 72 * Entirely opaque to drivers and should never be inspected directly by drivers.
 73 * Drivers instead should only interact with &struct drm_file and of course
 74 * &struct drm_device, which is also where driver-private data and resources can
 75 * be attached to.
 76 */
 77struct drm_minor {
 78	/* private: */
 79	int index;			/* Minor device number */
 80	int type;                       /* Control or render or accel */
 81	struct device *kdev;		/* Linux device */
 82	struct drm_device *dev;
 83
 84	struct dentry *debugfs_symlink;
 85	struct dentry *debugfs_root;
 
 
 
 86};
 87
 88/**
 89 * struct drm_pending_event - Event queued up for userspace to read
 90 *
 91 * This represents a DRM event. Drivers can use this as a generic completion
 92 * mechanism, which supports kernel-internal &struct completion, &struct dma_fence
 93 * and also the DRM-specific &struct drm_event delivery mechanism.
 94 */
 95struct drm_pending_event {
 96	/**
 97	 * @completion:
 98	 *
 99	 * Optional pointer to a kernel internal completion signalled when
100	 * drm_send_event() is called, useful to internally synchronize with
101	 * nonblocking operations.
102	 */
103	struct completion *completion;
104
105	/**
106	 * @completion_release:
107	 *
108	 * Optional callback currently only used by the atomic modeset helpers
109	 * to clean up the reference count for the structure @completion is
110	 * stored in.
111	 */
112	void (*completion_release)(struct completion *completion);
113
114	/**
115	 * @event:
116	 *
117	 * Pointer to the actual event that should be sent to userspace to be
118	 * read using drm_read(). Can be optional, since nowadays events are
119	 * also used to signal kernel internal threads with @completion or DMA
120	 * transactions using @fence.
121	 */
122	struct drm_event *event;
123
124	/**
125	 * @fence:
126	 *
127	 * Optional DMA fence to unblock other hardware transactions which
128	 * depend upon the nonblocking DRM operation this event represents.
129	 */
130	struct dma_fence *fence;
131
132	/**
133	 * @file_priv:
134	 *
135	 * &struct drm_file where @event should be delivered to. Only set when
136	 * @event is set.
137	 */
138	struct drm_file *file_priv;
139
140	/**
141	 * @link:
142	 *
143	 * Double-linked list to keep track of this event. Can be used by the
144	 * driver up to the point when it calls drm_send_event(), after that
145	 * this list entry is owned by the core for its own book-keeping.
146	 */
147	struct list_head link;
148
149	/**
150	 * @pending_link:
151	 *
152	 * Entry on &drm_file.pending_event_list, to keep track of all pending
153	 * events for @file_priv, to allow correct unwinding of them when
154	 * userspace closes the file before the event is delivered.
155	 */
156	struct list_head pending_link;
157};
158
159/**
160 * struct drm_file - DRM file private data
161 *
162 * This structure tracks DRM state per open file descriptor.
163 */
164struct drm_file {
165	/**
166	 * @authenticated:
167	 *
168	 * Whether the client is allowed to submit rendering, which for legacy
169	 * nodes means it must be authenticated.
170	 *
171	 * See also the :ref:`section on primary nodes and authentication
172	 * <drm_primary_node>`.
173	 */
174	bool authenticated;
175
176	/**
177	 * @stereo_allowed:
178	 *
179	 * True when the client has asked us to expose stereo 3D mode flags.
180	 */
181	bool stereo_allowed;
182
183	/**
184	 * @universal_planes:
185	 *
186	 * True if client understands CRTC primary planes and cursor planes
187	 * in the plane list. Automatically set when @atomic is set.
188	 */
189	bool universal_planes;
190
191	/** @atomic: True if client understands atomic properties. */
192	bool atomic;
193
194	/**
195	 * @aspect_ratio_allowed:
196	 *
197	 * True, if client can handle picture aspect ratios, and has requested
198	 * to pass this information along with the mode.
199	 */
200	bool aspect_ratio_allowed;
201
202	/**
203	 * @writeback_connectors:
204	 *
205	 * True if client understands writeback connectors
206	 */
207	bool writeback_connectors;
208
209	/**
210	 * @was_master:
211	 *
212	 * This client has or had, master capability. Protected by struct
213	 * &drm_device.master_mutex.
214	 *
215	 * This is used to ensure that CAP_SYS_ADMIN is not enforced, if the
216	 * client is or was master in the past.
217	 */
218	bool was_master;
219
220	/**
221	 * @is_master:
222	 *
223	 * This client is the creator of @master. Protected by struct
224	 * &drm_device.master_mutex.
225	 *
226	 * See also the :ref:`section on primary nodes and authentication
227	 * <drm_primary_node>`.
228	 */
229	bool is_master;
230
231	/**
232	 * @supports_virtualized_cursor_plane:
233	 *
234	 * This client is capable of handling the cursor plane with the
235	 * restrictions imposed on it by the virtualized drivers.
236	 *
237	 * This implies that the cursor plane has to behave like a cursor
238	 * i.e. track cursor movement. It also requires setting of the
239	 * hotspot properties by the client on the cursor plane.
240	 */
241	bool supports_virtualized_cursor_plane;
242
243	/**
244	 * @master:
245	 *
246	 * Master this node is currently associated with. Protected by struct
247	 * &drm_device.master_mutex, and serialized by @master_lookup_lock.
248	 *
249	 * Only relevant if drm_is_primary_client() returns true. Note that
250	 * this only matches &drm_device.master if the master is the currently
251	 * active one.
252	 *
253	 * To update @master, both &drm_device.master_mutex and
254	 * @master_lookup_lock need to be held, therefore holding either of
255	 * them is safe and enough for the read side.
256	 *
257	 * When dereferencing this pointer, either hold struct
258	 * &drm_device.master_mutex for the duration of the pointer's use, or
259	 * use drm_file_get_master() if struct &drm_device.master_mutex is not
260	 * currently held and there is no other need to hold it. This prevents
261	 * @master from being freed during use.
262	 *
263	 * See also @authentication and @is_master and the :ref:`section on
264	 * primary nodes and authentication <drm_primary_node>`.
265	 */
266	struct drm_master *master;
267
268	/** @master_lookup_lock: Serializes @master. */
269	spinlock_t master_lookup_lock;
270
271	/**
272	 * @pid: Process that is using this file.
273	 *
274	 * Must only be dereferenced under a rcu_read_lock or equivalent.
275	 *
276	 * Updates are guarded with dev->filelist_mutex and reference must be
277	 * dropped after a RCU grace period to accommodate lockless readers.
278	 */
279	struct pid __rcu *pid;
280
281	/** @client_id: A unique id for fdinfo */
282	u64 client_id;
283
284	/** @magic: Authentication magic, see @authenticated. */
285	drm_magic_t magic;
286
287	/**
288	 * @lhead:
289	 *
290	 * List of all open files of a DRM device, linked into
291	 * &drm_device.filelist. Protected by &drm_device.filelist_mutex.
292	 */
293	struct list_head lhead;
294
295	/** @minor: &struct drm_minor for this file. */
296	struct drm_minor *minor;
297
298	/**
299	 * @object_idr:
300	 *
301	 * Mapping of mm object handles to object pointers. Used by the GEM
302	 * subsystem. Protected by @table_lock.
303	 */
304	struct idr object_idr;
305
306	/** @table_lock: Protects @object_idr. */
307	spinlock_t table_lock;
308
309	/** @syncobj_idr: Mapping of sync object handles to object pointers. */
310	struct idr syncobj_idr;
311	/** @syncobj_table_lock: Protects @syncobj_idr. */
312	spinlock_t syncobj_table_lock;
313
314	/** @filp: Pointer to the core file structure. */
315	struct file *filp;
316
317	/**
318	 * @driver_priv:
319	 *
320	 * Optional pointer for driver private data. Can be allocated in
321	 * &drm_driver.open and should be freed in &drm_driver.postclose.
322	 */
323	void *driver_priv;
324
325	/**
326	 * @fbs:
327	 *
328	 * List of &struct drm_framebuffer associated with this file, using the
329	 * &drm_framebuffer.filp_head entry.
330	 *
331	 * Protected by @fbs_lock. Note that the @fbs list holds a reference on
332	 * the framebuffer object to prevent it from untimely disappearing.
333	 */
334	struct list_head fbs;
335
336	/** @fbs_lock: Protects @fbs. */
337	struct mutex fbs_lock;
338
339	/**
340	 * @blobs:
341	 *
342	 * User-created blob properties; this retains a reference on the
343	 * property.
344	 *
345	 * Protected by @drm_mode_config.blob_lock;
346	 */
347	struct list_head blobs;
348
349	/** @event_wait: Waitqueue for new events added to @event_list. */
350	wait_queue_head_t event_wait;
351
352	/**
353	 * @pending_event_list:
354	 *
355	 * List of pending &struct drm_pending_event, used to clean up pending
356	 * events in case this file gets closed before the event is signalled.
357	 * Uses the &drm_pending_event.pending_link entry.
358	 *
359	 * Protect by &drm_device.event_lock.
360	 */
361	struct list_head pending_event_list;
362
363	/**
364	 * @event_list:
365	 *
366	 * List of &struct drm_pending_event, ready for delivery to userspace
367	 * through drm_read(). Uses the &drm_pending_event.link entry.
368	 *
369	 * Protect by &drm_device.event_lock.
370	 */
371	struct list_head event_list;
372
373	/**
374	 * @event_space:
375	 *
376	 * Available event space to prevent userspace from
377	 * exhausting kernel memory. Currently limited to the fairly arbitrary
378	 * value of 4KB.
379	 */
380	int event_space;
381
382	/** @event_read_lock: Serializes drm_read(). */
383	struct mutex event_read_lock;
384
385	/**
386	 * @prime:
387	 *
388	 * Per-file buffer caches used by the PRIME buffer sharing code.
389	 */
390	struct drm_prime_file_private prime;
391
392	/**
393	 * @client_name:
394	 *
395	 * Userspace-provided name; useful for accounting and debugging.
396	 */
397	const char *client_name;
398
399	/**
400	 * @client_name_lock: Protects @client_name.
401	 */
402	struct mutex client_name_lock;
403};
404
405/**
406 * drm_is_primary_client - is this an open file of the primary node
407 * @file_priv: DRM file
408 *
409 * Returns true if this is an open file of the primary node, i.e.
410 * &drm_file.minor of @file_priv is a primary minor.
411 *
412 * See also the :ref:`section on primary nodes and authentication
413 * <drm_primary_node>`.
414 */
415static inline bool drm_is_primary_client(const struct drm_file *file_priv)
416{
417	return file_priv->minor->type == DRM_MINOR_PRIMARY;
418}
419
420/**
421 * drm_is_render_client - is this an open file of the render node
422 * @file_priv: DRM file
423 *
424 * Returns true if this is an open file of the render node, i.e.
425 * &drm_file.minor of @file_priv is a render minor.
426 *
427 * See also the :ref:`section on render nodes <drm_render_node>`.
428 */
429static inline bool drm_is_render_client(const struct drm_file *file_priv)
430{
431	return file_priv->minor->type == DRM_MINOR_RENDER;
432}
433
434/**
435 * drm_is_accel_client - is this an open file of the compute acceleration node
436 * @file_priv: DRM file
437 *
438 * Returns true if this is an open file of the compute acceleration node, i.e.
439 * &drm_file.minor of @file_priv is a accel minor.
440 *
441 * See also :doc:`Introduction to compute accelerators subsystem
442 * </accel/introduction>`.
443 */
444static inline bool drm_is_accel_client(const struct drm_file *file_priv)
445{
446	return file_priv->minor->type == DRM_MINOR_ACCEL;
447}
448
449void drm_file_update_pid(struct drm_file *);
450
451struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
452void drm_minor_release(struct drm_minor *minor);
453
454int drm_open(struct inode *inode, struct file *filp);
455int drm_open_helper(struct file *filp, struct drm_minor *minor);
456ssize_t drm_read(struct file *filp, char __user *buffer,
457		 size_t count, loff_t *offset);
458int drm_release(struct inode *inode, struct file *filp);
459int drm_release_noglobal(struct inode *inode, struct file *filp);
460__poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
461int drm_event_reserve_init_locked(struct drm_device *dev,
462				  struct drm_file *file_priv,
463				  struct drm_pending_event *p,
464				  struct drm_event *e);
465int drm_event_reserve_init(struct drm_device *dev,
466			   struct drm_file *file_priv,
467			   struct drm_pending_event *p,
468			   struct drm_event *e);
469void drm_event_cancel_free(struct drm_device *dev,
470			   struct drm_pending_event *p);
471void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
472void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
473void drm_send_event_timestamp_locked(struct drm_device *dev,
474				     struct drm_pending_event *e,
475				     ktime_t timestamp);
476
477/**
478 * struct drm_memory_stats - GEM object stats associated
479 * @shared: Total size of GEM objects shared between processes
480 * @private: Total size of GEM objects
481 * @resident: Total size of GEM objects backing pages
482 * @purgeable: Total size of GEM objects that can be purged (resident and not active)
483 * @active: Total size of GEM objects active on one or more engines
484 *
485 * Used by drm_print_memory_stats()
486 */
487struct drm_memory_stats {
488	u64 shared;
489	u64 private;
490	u64 resident;
491	u64 purgeable;
492	u64 active;
493};
494
495enum drm_gem_object_status;
496
497void drm_print_memory_stats(struct drm_printer *p,
498			    const struct drm_memory_stats *stats,
499			    enum drm_gem_object_status supported_status,
500			    const char *region);
501
502void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file);
503void drm_show_fdinfo(struct seq_file *m, struct file *f);
504
505struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags);
506
507#endif /* _DRM_FILE_H_ */