Blame view

include/drm/drmP.h 35.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
d7d2c48e5   David Herrmann   drm: move remaini...
2
3
   * Internal Header for the Direct Rendering Manager
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
   * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
   * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
dcdb16740   Jordan Crouse   drm: Add support ...
6
   * Copyright (c) 2009-2010, Code Aurora Forum.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
   * All rights reserved.
   *
d7d2c48e5   David Herrmann   drm: move remaini...
9
10
11
   * Author: Rickard E. (Rik) Faith <faith@valinux.com>
   * Author: Gareth Hughes <gareth@valinux.com>
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
   * Permission is hereby granted, free of charge, to any person obtaining a
   * copy of this software and associated documentation files (the "Software"),
   * to deal in the Software without restriction, including without limitation
   * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   * and/or sell copies of the Software, and to permit persons to whom the
   * Software is furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice (including the next
   * paragraph) shall be included in all copies or substantial portions of the
   * Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   * OTHER DEALINGS IN THE SOFTWARE.
   */
  
  #ifndef _DRM_P_H_
  #define _DRM_P_H_
969939087   David Herrmann   drm: order includ...
34
35
36
37
  #include <linux/agp_backend.h>
  #include <linux/cdev.h>
  #include <linux/dma-mapping.h>
  #include <linux/file.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
  #include <linux/fs.h>
969939087   David Herrmann   drm: order includ...
39
40
  #include <linux/highmem.h>
  #include <linux/idr.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  #include <linux/init.h>
969939087   David Herrmann   drm: order includ...
42
  #include <linux/io.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
  #include <linux/jiffies.h>
969939087   David Herrmann   drm: order includ...
44
45
46
  #include <linux/kernel.h>
  #include <linux/kref.h>
  #include <linux/miscdevice.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
  #include <linux/mm.h>
30e2fb188   Dave Airlie   sem2mutex: driver...
48
  #include <linux/mutex.h>
969939087   David Herrmann   drm: order includ...
49
50
51
  #include <linux/pci.h>
  #include <linux/platform_device.h>
  #include <linux/poll.h>
5d13d425e   Rob Clark   drm: add DRM_ERRO...
52
  #include <linux/ratelimit.h>
077675c1e   Chris Wilson   drm: Convert prim...
53
  #include <linux/rbtree.h>
969939087   David Herrmann   drm: order includ...
54
55
  #include <linux/sched.h>
  #include <linux/slab.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
  #include <linux/types.h>
d6db65644   David Herrmann   drm: merge drm_me...
57
  #include <linux/vmalloc.h>
969939087   David Herrmann   drm: order includ...
58
  #include <linux/workqueue.h>
1b47aaf9a   Gustavo Padovan   drm/fence: add fe...
59
  #include <linux/fence.h>
969939087   David Herrmann   drm: order includ...
60
61
  
  #include <asm/mman.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
  #include <asm/pgalloc.h>
969939087   David Herrmann   drm: order includ...
63
  #include <asm/uaccess.h>
d7d2c48e5   David Herrmann   drm: move remaini...
64
65
66
67
68
  #include <uapi/drm/drm.h>
  #include <uapi/drm/drm_mode.h>
  
  #include <drm/drm_agpsupport.h>
  #include <drm/drm_crtc.h>
ae4df11a0   Laurent Pinchart   drm: Move format-...
69
  #include <drm/drm_fourcc.h>
d7d2c48e5   David Herrmann   drm: move remaini...
70
  #include <drm/drm_global.h>
969939087   David Herrmann   drm: order includ...
71
  #include <drm/drm_hashtab.h>
d7d2c48e5   David Herrmann   drm: move remaini...
72
  #include <drm/drm_mem_util.h>
969939087   David Herrmann   drm: order includ...
73
74
  #include <drm/drm_mm.h>
  #include <drm/drm_os_linux.h>
19218e482   David Howells   UAPI: Refer to th...
75
  #include <drm/drm_sarea.h>
0de23977c   David Herrmann   drm/gem: convert ...
76
  #include <drm/drm_vma_manager.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77

de4772542   Paul Gortmaker   include: replace ...
78
  struct module;
c153f45f9   Eric Anholt   drm: Replace DRM_...
79
80
  struct drm_file;
  struct drm_device;
cc5ea5947   David Herrmann   drm: move AGP def...
81
  struct drm_agp_head;
ba8286fab   Daniel Vetter   drm: Move legacy ...
82
83
84
  struct drm_local_map;
  struct drm_device_dma;
  struct drm_dma_handle;
d9fc9413f   Daniel Vetter   drm: Extract <drm...
85
  struct drm_gem_object;
3b96a0b14   Daniel Vetter   drm: document drm...
86
  struct drm_master;
34a67dd7f   Daniel Vetter   drm: Extract&Docu...
87
  struct drm_vblank_crtc;
c153f45f9   Eric Anholt   drm: Replace DRM_...
88

edb37a95c   Steffen Trumtrar   drm_modes: add of...
89
  struct device_node;
ebc64e453   Steffen Trumtrar   drm_modes: add vi...
90
  struct videomode;
3aac4502f   Maarten Lankhorst   dma-buf: use rese...
91
  struct reservation_object;
b5e9c1a25   Maarten Lankhorst   drm: Pass dma-buf...
92
  struct dma_buf_attachment;
ebc64e453   Steffen Trumtrar   drm_modes: add vi...
93

87fdff81c   Zhao Yakui   DRM: Add the expl...
94
  /*
346fea63a   Robert Foss   include/drm: Rewo...
95
   * The following categories are defined:
1414b76c1   Lespiau, Damien   drm: Refresh the ...
96
97
98
99
100
101
   *
   * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
   *	 This is the category used by the DRM_DEBUG() macro.
   *
   * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
   *	   This is the category used by the DRM_DEBUG_DRIVER() macro.
87fdff81c   Zhao Yakui   DRM: Add the expl...
102
   *
1414b76c1   Lespiau, Damien   drm: Refresh the ...
103
104
   * KMS: used in the modesetting code.
   *	This is the category used by the DRM_DEBUG_KMS() macro.
87fdff81c   Zhao Yakui   DRM: Add the expl...
105
   *
1414b76c1   Lespiau, Damien   drm: Refresh the ...
106
107
   * PRIME: used in the prime code.
   *	  This is the category used by the DRM_DEBUG_PRIME() macro.
87fdff81c   Zhao Yakui   DRM: Add the expl...
108
   *
17a38d9c2   Daniel Vetter   drm: Add DRM_DEBU...
109
110
111
   * ATOMIC: used in the atomic code.
   *	  This is the category used by the DRM_DEBUG_ATOMIC() macro.
   *
235fabe09   Ville Syrjälä   drm: Add DRM_DEBU...
112
113
114
   * VBL: used for verbose debug message in the vblank code
   *	  This is the category used by the DRM_DEBUG_VBL() macro.
   *
1414b76c1   Lespiau, Damien   drm: Refresh the ...
115
116
117
118
119
120
121
   * Enabling verbose debug messages is done through the drm.debug parameter,
   * each category being enabled by a bit.
   *
   * drm.debug=0x1 will enable CORE messages
   * drm.debug=0x2 will enable DRIVER messages
   * drm.debug=0x3 will enable CORE and DRIVER messages
   * ...
235fabe09   Ville Syrjälä   drm: Add DRM_DEBU...
122
   * drm.debug=0x3f will enable all messages
1414b76c1   Lespiau, Damien   drm: Refresh the ...
123
124
125
126
   *
   * An interesting feature is that it's possible to enable verbose logging at
   * run-time by echoing the debug value in its sysfs node:
   *   # echo 0xf > /sys/module/drm/parameters/debug
87fdff81c   Zhao Yakui   DRM: Add the expl...
127
   */
c4e68a583   Sean Paul   drm: Introduce DR...
128
  #define DRM_UT_NONE		0x00
1414b76c1   Lespiau, Damien   drm: Refresh the ...
129
130
131
132
  #define DRM_UT_CORE 		0x01
  #define DRM_UT_DRIVER		0x02
  #define DRM_UT_KMS		0x04
  #define DRM_UT_PRIME		0x08
17a38d9c2   Daniel Vetter   drm: Add DRM_DEBU...
133
  #define DRM_UT_ATOMIC		0x10
235fabe09   Ville Syrjälä   drm: Add DRM_DEBU...
134
  #define DRM_UT_VBL		0x20
4fefcb270   yakui_zhao   drm: add separate...
135

c4e68a583   Sean Paul   drm: Introduce DR...
136
137
138
139
  extern __printf(6, 7)
  void drm_dev_printk(const struct device *dev, const char *level,
  		    unsigned int category, const char *function_name,
  		    const char *prefix, const char *format, ...);
6bd488db8   Joe Perches   drm: Simplify drm...
140
  extern __printf(3, 4)
c4e68a583   Sean Paul   drm: Introduce DR...
141
  void drm_printk(const char *level, unsigned int category,
c4e68a583   Sean Paul   drm: Introduce DR...
142
  		const char *format, ...);
5ad3d8831   Joe Perches   drm: Create and u...
143

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144
145
146
147
148
149
  /***********************************************************************/
  /** 
  ame DRM template customization defaults */
  /*@{*/
  
  /* driver capabilities and requirements mask */
0e975980d   Peter Antoine   drm: Turn off Leg...
150
  #define DRIVER_USE_AGP			0x1
3cbf6a5de   Daniel Vetter   drm: Mark up lega...
151
  #define DRIVER_LEGACY			0x2
0e975980d   Peter Antoine   drm: Turn off Leg...
152
153
154
155
156
157
158
159
160
161
162
  #define DRIVER_PCI_DMA			0x8
  #define DRIVER_SG			0x10
  #define DRIVER_HAVE_DMA			0x20
  #define DRIVER_HAVE_IRQ			0x40
  #define DRIVER_IRQ_SHARED		0x80
  #define DRIVER_GEM			0x1000
  #define DRIVER_MODESET			0x2000
  #define DRIVER_PRIME			0x4000
  #define DRIVER_RENDER			0x8000
  #define DRIVER_ATOMIC			0x10000
  #define DRIVER_KMS_LEGACY_CONTEXT	0x20000
8410ea3b9   Dave Airlie   drm: rework PCI/p...
163

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
  /***********************************************************************/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
165
166
167
  /** 
  ame Macros to make printk easier */
  /*@{*/
30b0da8d5   Dave Gordon   drm: extra printk...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
  #define _DRM_PRINTK(once, level, fmt, ...)				\
  	do {								\
  		printk##once(KERN_##level "[" DRM_NAME "] " fmt,	\
  			     ##__VA_ARGS__);				\
  	} while (0)
  
  #define DRM_INFO(fmt, ...)						\
  	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
  #define DRM_NOTE(fmt, ...)						\
  	_DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
  #define DRM_WARN(fmt, ...)						\
  	_DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
  
  #define DRM_INFO_ONCE(fmt, ...)						\
  	_DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
  #define DRM_NOTE_ONCE(fmt, ...)						\
  	_DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
  #define DRM_WARN_ONCE(fmt, ...)						\
  	_DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
188
189
190
191
192
  /**
   * Error output.
   *
   * \param fmt printf() like format string.
   * \param arg arguments
   */
c4e68a583   Sean Paul   drm: Introduce DR...
193
194
195
196
  #define DRM_DEV_ERROR(dev, fmt, ...)					\
  	drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
  		       fmt, ##__VA_ARGS__)
  #define DRM_ERROR(fmt, ...)						\
6bd488db8   Joe Perches   drm: Simplify drm...
197
  	drm_printk(KERN_ERR, DRM_UT_NONE, fmt,	##__VA_ARGS__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
198

5d13d425e   Rob Clark   drm: add DRM_ERRO...
199
200
201
202
203
204
  /**
   * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
   *
   * \param fmt printf() like format string.
   * \param arg arguments
   */
c4e68a583   Sean Paul   drm: Introduce DR...
205
  #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)			\
5d13d425e   Rob Clark   drm: add DRM_ERRO...
206
207
208
209
210
211
  ({									\
  	static DEFINE_RATELIMIT_STATE(_rs,				\
  				      DEFAULT_RATELIMIT_INTERVAL,	\
  				      DEFAULT_RATELIMIT_BURST);		\
  									\
  	if (__ratelimit(&_rs))						\
c4e68a583   Sean Paul   drm: Introduce DR...
212
  		DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__);			\
5d13d425e   Rob Clark   drm: add DRM_ERRO...
213
  })
c4e68a583   Sean Paul   drm: Introduce DR...
214
215
  #define DRM_ERROR_RATELIMITED(fmt, ...)					\
  	DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
5d13d425e   Rob Clark   drm: add DRM_ERRO...
216

c4e68a583   Sean Paul   drm: Introduce DR...
217
218
219
  #define DRM_DEV_INFO(dev, fmt, ...)					\
  	drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt,	\
  		       ##__VA_ARGS__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
220

c4e68a583   Sean Paul   drm: Introduce DR...
221
222
223
224
225
226
227
228
  #define DRM_DEV_INFO_ONCE(dev, fmt, ...)				\
  ({									\
  	static bool __print_once __read_mostly;				\
  	if (!__print_once) {						\
  		__print_once = true;					\
  		DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__);			\
  	}								\
  })
48b8f6315   Jani Nikula   drm: add DRM_INFO...
229

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
230
231
  /**
   * Debug output.
b5e89ed53   Dave Airlie   drm: lindent the ...
232
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
235
   * \param fmt printf() like format string.
   * \param arg arguments
   */
c4e68a583   Sean Paul   drm: Introduce DR...
236
237
238
  #define DRM_DEV_DEBUG(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt,	\
  		       ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
239
240
  #define DRM_DEBUG(fmt, ...)						\
  	drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
4fefcb270   yakui_zhao   drm: add separate...
241

c4e68a583   Sean Paul   drm: Introduce DR...
242
243
244
  #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "",	\
  		       fmt, ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
245
246
  #define DRM_DEBUG_DRIVER(fmt, ...)					\
  	drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
c4e68a583   Sean Paul   drm: Introduce DR...
247
248
249
250
  
  #define DRM_DEV_DEBUG_KMS(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt,	\
  		       ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
251
252
  #define DRM_DEBUG_KMS(fmt, ...)					\
  	drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
c4e68a583   Sean Paul   drm: Introduce DR...
253
254
255
256
  
  #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "",	\
  		       fmt, ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
257
258
  #define DRM_DEBUG_PRIME(fmt, ...)					\
  	drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
c4e68a583   Sean Paul   drm: Introduce DR...
259
260
261
262
  
  #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "",	\
  		       fmt, ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
263
264
  #define DRM_DEBUG_ATOMIC(fmt, ...)					\
  	drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
c4e68a583   Sean Paul   drm: Introduce DR...
265
266
267
268
  
  #define DRM_DEV_DEBUG_VBL(dev, fmt, args...)				\
  	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt,	\
  		       ##args)
6bd488db8   Joe Perches   drm: Simplify drm...
269
270
  #define DRM_DEBUG_VBL(fmt, ...)					\
  	drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
271

c4e68a583   Sean Paul   drm: Introduce DR...
272
273
274
275
276
277
278
279
280
  #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...)	\
  ({									\
  	static DEFINE_RATELIMIT_STATE(_rs,				\
  				      DEFAULT_RATELIMIT_INTERVAL,	\
  				      DEFAULT_RATELIMIT_BURST);		\
  	if (__ratelimit(&_rs))						\
  		drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level,	\
  			       __func__, "", fmt, ##args);		\
  })
27528c667   Lyude   drm: Add ratelimi...
281
282
283
284
285
286
287
  
  /**
   * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
   *
   * \param fmt printf() like format string.
   * \param arg arguments
   */
c4e68a583   Sean Paul   drm: Introduce DR...
288
289
  #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...)			\
  	DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
27528c667   Lyude   drm: Add ratelimi...
290
  #define DRM_DEBUG_RATELIMITED(fmt, args...)				\
c4e68a583   Sean Paul   drm: Introduce DR...
291
292
293
  	DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
  #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...)		\
  	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
27528c667   Lyude   drm: Add ratelimi...
294
  #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...)			\
c4e68a583   Sean Paul   drm: Introduce DR...
295
296
297
  	DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
  #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...)		\
  	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
27528c667   Lyude   drm: Add ratelimi...
298
  #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...)				\
c4e68a583   Sean Paul   drm: Introduce DR...
299
300
301
  	DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
  #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...)		\
  	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
27528c667   Lyude   drm: Add ratelimi...
302
  #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...)			\
c4e68a583   Sean Paul   drm: Introduce DR...
303
  	DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
27528c667   Lyude   drm: Add ratelimi...
304

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
305
  /*@}*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
306
307
308
309
  /***********************************************************************/
  /** 
  ame Internal types and structures */
  /*@{*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
310
  #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
311
312
  
  /**
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
313
314
315
   * Ioctl function type.
   *
   * \param inode device inode.
6c340eac0   Eric Anholt   drm: Replace filp...
316
   * \param file_priv DRM file private pointer.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
317
318
319
   * \param cmd command.
   * \param arg argument.
   */
c153f45f9   Eric Anholt   drm: Replace DRM_...
320
321
  typedef int drm_ioctl_t(struct drm_device *dev, void *data,
  			struct drm_file *file_priv);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
322

9a1866450   Dave Airlie   drm: 32/64-bit DR...
323
324
  typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
  			       unsigned long arg);
1a95916f5   Kristian Høgsberg   drm: Add compatib...
325
326
  #define DRM_IOCTL_NR(n)                _IOC_NR(n)
  #define DRM_MAJOR       226
a7a2cc315   Dave Airlie   drm: move ioctl f...
327
328
329
  #define DRM_AUTH	0x1
  #define	DRM_MASTER	0x2
  #define DRM_ROOT_ONLY	0x4
f453ba046   Dave Airlie   DRM: add mode set...
330
  #define DRM_CONTROL_ALLOW 0x8
ed8b67040   Arnd Bergmann   drm: convert drm_...
331
  #define DRM_UNLOCKED	0x10
1793126fc   David Herrmann   drm: implement ex...
332
  #define DRM_RENDER_ALLOW 0x20
a7a2cc315   Dave Airlie   drm: move ioctl f...
333

c153f45f9   Eric Anholt   drm: Replace DRM_...
334
335
  struct drm_ioctl_desc {
  	unsigned int cmd;
a7a2cc315   Dave Airlie   drm: move ioctl f...
336
  	int flags;
c972d750e   Richard Kennedy   drm: reorder stru...
337
  	drm_ioctl_t *func;
b9434d0f1   Chris Cummins   drm: Use names of...
338
  	const char *name;
c153f45f9   Eric Anholt   drm: Replace DRM_...
339
340
341
342
343
344
  };
  
  /**
   * Creates a driver or general drm_ioctl_desc array entry for the given
   * ioctl, for use by drm_ioctl().
   */
1b2f14896   Dave Airlie   drm: block usersp...
345

066626d5d   Emil Velikov   drm: line wrap DR...
346
347
348
349
350
351
352
  #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
  	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
  		.cmd = DRM_IOCTL_##ioctl,				\
  		.func = _func,						\
  		.flags = _flags,					\
  		.name = #ioctl						\
  	 }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
353

c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
354
355
  /* Event queued up for userspace to read */
  struct drm_pending_event {
3b24f7d67   Daniel Vetter   drm/atomic: Add s...
356
  	struct completion *completion;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
357
  	struct drm_event *event;
1b47aaf9a   Gustavo Padovan   drm/fence: add fe...
358
  	struct fence *fence;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
359
  	struct list_head link;
681047b48   Daniel Vetter   drm: Clean up pen...
360
  	struct list_head pending_link;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
361
  	struct drm_file *file_priv;
b9c2c9ae8   Jesse Barnes   drm: add per-even...
362
363
  	pid_t pid; /* pid of requester, no guarantee it's valid by the time
  		      we deliver the event, for tracing only */
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
364
  };
3248877ea   Dave Airlie   drm: base prime/d...
365
  struct drm_prime_file_private {
3248877ea   Dave Airlie   drm: base prime/d...
366
  	struct mutex lock;
077675c1e   Chris Wilson   drm: Convert prim...
367
368
  	struct rb_root dmabufs;
  	struct rb_root handles;
3248877ea   Dave Airlie   drm: base prime/d...
369
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
370
  /** File private data */
84b1fd103   Dave Airlie   drm: remove drm_f...
371
  struct drm_file {
39868bd76   Chris Wilson   drm: Compact bool...
372
  	unsigned authenticated :1;
39868bd76   Chris Wilson   drm: Compact bool...
373
374
  	/* true when the client has asked us to expose stereo 3D mode flags */
  	unsigned stereo_allowed :1;
681e7ec73   Matt Roper   drm: Allow usersp...
375
376
377
378
379
  	/*
  	 * true if client understands CRTC primary planes and cursor planes
  	 * in the plane list
  	 */
  	unsigned universal_planes:1;
88a48e297   Rob Clark   drm: add atomic p...
380
381
  	/* true if client understands atomic properties */
  	unsigned atomic:1;
a0af2e538   Thomas Hellstrom   drm: Fix an unwan...
382
  	/*
0aae5920a   Daniel Vetter   drm: Clear up mas...
383
  	 * This client is the creator of @master.
a0af2e538   Thomas Hellstrom   drm: Fix an unwan...
384
385
  	 * Protected by struct drm_device::master_mutex.
  	 */
0aae5920a   Daniel Vetter   drm: Clear up mas...
386
  	unsigned is_master:1;
39868bd76   Chris Wilson   drm: Compact bool...
387

5fce5e0bb   Eric W. Biederman   userns: Convert d...
388
  	struct pid *pid;
b5e89ed53   Dave Airlie   drm: lindent the ...
389
  	drm_magic_t magic;
bd1b331fa   Dave Airlie   drm: cleanup use ...
390
  	struct list_head lhead;
2c14f28be   Dave Airlie   drm: reorganise m...
391
  	struct drm_minor *minor;
b5e89ed53   Dave Airlie   drm: lindent the ...
392
  	unsigned long lock_count;
7c1c2871a   Dave Airlie   drm: move to kref...
393

673a394b1   Eric Anholt   drm: Add GEM ("gr...
394
395
396
397
  	/** Mapping of mm object handles to object pointers. */
  	struct idr object_idr;
  	/** Lock for synchronization of access to object_idr. */
  	spinlock_t table_lock;
7c1c2871a   Dave Airlie   drm: move to kref...
398

6c340eac0   Eric Anholt   drm: Replace filp...
399
  	struct file *filp;
8562b3f25   Dave Airlie   drm: some minor c...
400
  	void *driver_priv;
7c1c2871a   Dave Airlie   drm: move to kref...
401

7c1c2871a   Dave Airlie   drm: move to kref...
402
  	struct drm_master *master; /* master this node is currently associated with
95c081c17   Daniel Vetter   drm: Move master ...
403
  				      N.B. not always dev->master */
4b096ac10   Daniel Vetter   drm: revamp locki...
404
405
406
407
408
409
  	/**
  	 * fbs - List of framebuffers associated with this file.
  	 *
  	 * Protected by fbs_lock. Note that the fbs list holds a reference on
  	 * the fb object to prevent it from untimely disappearing.
  	 */
f453ba046   Dave Airlie   DRM: add mode set...
410
  	struct list_head fbs;
4b096ac10   Daniel Vetter   drm: revamp locki...
411
  	struct mutex fbs_lock;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
412

e2f5d2ea4   Daniel Stone   drm/mode: Add use...
413
414
415
  	/** User-created blob properties; this retains a reference on the
  	 *  property. */
  	struct list_head blobs;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
416
  	wait_queue_head_t event_wait;
681047b48   Daniel Vetter   drm: Clean up pen...
417
  	struct list_head pending_event_list;
c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
418
419
  	struct list_head event_list;
  	int event_space;
3248877ea   Dave Airlie   drm: base prime/d...
420

9b2c0b7fb   Chris Wilson   drm: Serialise mu...
421
  	struct mutex event_read_lock;
3248877ea   Dave Airlie   drm: base prime/d...
422
  	struct drm_prime_file_private prime;
84b1fd103   Dave Airlie   drm: remove drm_f...
423
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
424

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
425
426
427
  /**
   * Lock data.
   */
55910517a   Dave Airlie   drm: detypedeffin...
428
  struct drm_lock_data {
c60ce623b   Dave Airlie   drm: remove a bun...
429
  	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
8562b3f25   Dave Airlie   drm: some minor c...
430
431
  	/** Private of lock holder's file (NULL=kernel) */
  	struct drm_file *file_priv;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
432
  	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
b5e89ed53   Dave Airlie   drm: lindent the ...
433
  	unsigned long lock_time;	/**< Time of last lock in jiffies */
040ac3204   Thomas Hellstrom   drm: fix driver d...
434
435
436
437
  	spinlock_t spinlock;
  	uint32_t kernel_waiters;
  	uint32_t user_waiters;
  	int idle_has_lock;
55910517a   Dave Airlie   drm: detypedeffin...
438
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
439

27641c3f0   Mario Kleiner   drm/vblank: Add s...
440
441
442
  /* Flags and return codes for get_vblank_timestamp() driver function. */
  #define DRM_CALLED_FROM_VBLIRQ 1
  #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
3d3cbd843   Daniel Vetter   drm: Clarify vbla...
443
  #define DRM_VBLANKTIME_IN_VBLANK         (1 << 1)
27641c3f0   Mario Kleiner   drm/vblank: Add s...
444
445
446
  
  /* get_scanout_position() return flags */
  #define DRM_SCANOUTPOS_VALID        (1 << 0)
3d3cbd843   Daniel Vetter   drm: Clarify vbla...
447
  #define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
27641c3f0   Mario Kleiner   drm/vblank: Add s...
448
  #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
673a394b1   Eric Anholt   drm: Add GEM ("gr...
449
  /**
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
450
451
452
453
   * DRM driver structure. This structure represent the common code for
   * a family of cards. There will one drm_device for each card present
   * in this family
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
454
  struct drm_driver {
22eae947b   Dave Airlie   drm: rename drive...
455
456
  	int (*load) (struct drm_device *, unsigned long flags);
  	int (*firstopen) (struct drm_device *);
84b1fd103   Dave Airlie   drm: remove drm_f...
457
  	int (*open) (struct drm_device *, struct drm_file *);
6c340eac0   Eric Anholt   drm: Replace filp...
458
  	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
84b1fd103   Dave Airlie   drm: remove drm_f...
459
  	void (*postclose) (struct drm_device *, struct drm_file *);
22eae947b   Dave Airlie   drm: rename drive...
460
461
  	void (*lastclose) (struct drm_device *);
  	int (*unload) (struct drm_device *);
c153f45f9   Eric Anholt   drm: Replace DRM_...
462
  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
b5e89ed53   Dave Airlie   drm: lindent the ...
463
  	int (*dma_quiescent) (struct drm_device *);
84b1fd103   Dave Airlie   drm: remove drm_f...
464
  	int (*context_dtor) (struct drm_device *dev, int context);
915b4d11b   David Herrmann   drm: add driver->...
465
  	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
b5e89ed53   Dave Airlie   drm: lindent the ...
466

cda173806   Dave Airlie   drm: add test for...
467
  	/**
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
468
469
  	 * get_vblank_counter - get raw hardware vblank counter
  	 * @dev: DRM device
88e72717c   Thierry Reding   drm/irq: Use unsi...
470
  	 * @pipe: counter to fetch
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
471
  	 *
3b02ab889   Laurent Pinchart   drm: Miscellaneou...
472
473
  	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
  	 * If a device doesn't have a hardware counter, the driver can simply
337790079   Liviu Dudau   drm: Update obsol...
474
  	 * use drm_vblank_no_hw_counter() function. The DRM core will account for
3b02ab889   Laurent Pinchart   drm: Miscellaneou...
475
476
  	 * missed vblank events while interrupts where disabled based on system
  	 * timestamps.
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
477
478
479
480
481
482
483
  	 *
  	 * Wraparound handling and loss of events due to modesetting is dealt
  	 * with in the DRM core code.
  	 *
  	 * RETURNS
  	 * Raw vblank counter value.
  	 */
88e72717c   Thierry Reding   drm/irq: Use unsi...
484
  	u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
485
486
487
488
  
  	/**
  	 * enable_vblank - enable vblank interrupt events
  	 * @dev: DRM device
88e72717c   Thierry Reding   drm/irq: Use unsi...
489
  	 * @pipe: which irq to enable
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
490
491
  	 *
  	 * Enable vblank interrupts for @crtc.  If the device doesn't have
337790079   Liviu Dudau   drm: Update obsol...
492
493
  	 * a hardware vblank counter, the driver should use the
  	 * drm_vblank_no_hw_counter() function that keeps a virtual counter.
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
494
495
496
497
498
  	 *
  	 * RETURNS
  	 * Zero on success, appropriate errno if the given @crtc's vblank
  	 * interrupt cannot be enabled.
  	 */
88e72717c   Thierry Reding   drm/irq: Use unsi...
499
  	int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
500
501
502
503
  
  	/**
  	 * disable_vblank - disable vblank interrupt events
  	 * @dev: DRM device
88e72717c   Thierry Reding   drm/irq: Use unsi...
504
  	 * @pipe: which irq to enable
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
505
506
  	 *
  	 * Disable vblank interrupts for @crtc.  If the device doesn't have
337790079   Liviu Dudau   drm: Update obsol...
507
508
  	 * a hardware vblank counter, the driver should use the
  	 * drm_vblank_no_hw_counter() function that keeps a virtual counter.
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
509
  	 */
88e72717c   Thierry Reding   drm/irq: Use unsi...
510
  	void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
511
512
  
  	/**
cda173806   Dave Airlie   drm: add test for...
513
514
515
516
517
518
519
520
521
522
  	 * Called by \c drm_device_is_agp.  Typically used to determine if a
  	 * card is really attached to AGP or not.
  	 *
  	 * \param dev  DRM device handle
  	 *
  	 * \returns
  	 * One of three values is returned depending on whether or not the
  	 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
  	 * (return of 1), or may or may not be AGP (return of 2).
  	 */
84b1fd103   Dave Airlie   drm: remove drm_f...
523
  	int (*device_is_agp) (struct drm_device *dev);
cda173806   Dave Airlie   drm: add test for...
524

27641c3f0   Mario Kleiner   drm/vblank: Add s...
525
526
527
  	/**
  	 * Called by vblank timestamping code.
  	 *
8f6fce03d   Mario Kleiner   drm: Push latency...
528
529
  	 * Return the current display scanout position from a crtc, and an
  	 * optional accurate ktime_get timestamp of when position was measured.
27641c3f0   Mario Kleiner   drm/vblank: Add s...
530
531
  	 *
  	 * \param dev  DRM device.
88e72717c   Thierry Reding   drm/irq: Use unsi...
532
  	 * \param pipe Id of the crtc to query.
abca9e454   Ville Syrjälä   drm: Pass 'flags'...
533
  	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
27641c3f0   Mario Kleiner   drm/vblank: Add s...
534
535
  	 * \param *vpos Target location for current vertical scanout position.
  	 * \param *hpos Target location for current horizontal scanout position.
8f6fce03d   Mario Kleiner   drm: Push latency...
536
537
538
539
  	 * \param *stime Target location for timestamp taken immediately before
  	 *               scanout position query. Can be NULL to skip timestamp.
  	 * \param *etime Target location for timestamp taken immediately after
  	 *               scanout position query. Can be NULL to skip timestamp.
3bb403bf4   Ville Syrjälä   drm: Stop using l...
540
  	 * \param mode Current display timings.
27641c3f0   Mario Kleiner   drm/vblank: Add s...
541
542
543
544
545
546
547
548
  	 *
  	 * Returns vpos as a positive number while in active scanout area.
  	 * Returns vpos as a negative number inside vblank, counting the number
  	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
  	 * until start of active scanout / end of vblank."
  	 *
  	 * \return Flags, or'ed together as follows:
  	 *
25985edce   Lucas De Marchi   Fix common misspe...
549
  	 * DRM_SCANOUTPOS_VALID = Query successful.
27641c3f0   Mario Kleiner   drm/vblank: Add s...
550
551
552
553
554
555
  	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
  	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
  	 * this flag means that returned position may be offset by a constant
  	 * but unknown small number of scanlines wrt. real scanout position.
  	 *
  	 */
88e72717c   Thierry Reding   drm/irq: Use unsi...
556
557
  	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
  				     unsigned int flags, int *vpos, int *hpos,
3bb403bf4   Ville Syrjälä   drm: Stop using l...
558
559
  				     ktime_t *stime, ktime_t *etime,
  				     const struct drm_display_mode *mode);
27641c3f0   Mario Kleiner   drm/vblank: Add s...
560
561
562
563
564
565
566
567
  
  	/**
  	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
  	 * timestamp when the most recent VBLANK interval ended or will end.
  	 *
  	 * Specifically, the timestamp in @vblank_time should correspond as
  	 * closely as possible to the time when the first video scanline of
  	 * the video frame after the end of VBLANK will start scanning out,
42b2aa86c   Justin P. Mattock   treewide: Fix typ...
568
  	 * the time immediately after end of the VBLANK interval. If the
27641c3f0   Mario Kleiner   drm/vblank: Add s...
569
570
571
572
573
574
  	 * @crtc is currently inside VBLANK, this will be a time in the future.
  	 * If the @crtc is currently scanning out a frame, this will be the
  	 * past start time of the current scanout. This is meant to adhere
  	 * to the OpenML OML_sync_control extension specification.
  	 *
  	 * \param dev dev DRM device handle.
88e72717c   Thierry Reding   drm/irq: Use unsi...
575
  	 * \param pipe crtc for which timestamp should be returned.
27641c3f0   Mario Kleiner   drm/vblank: Add s...
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
  	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
  	 *                   Implementation should strive to provide timestamp
  	 *                   with an error of at most *max_error nanoseconds.
  	 *                   Returns true upper bound on error for timestamp.
  	 * \param *vblank_time Target location for returned vblank timestamp.
  	 * \param flags 0 = Defaults, no special treatment needed.
  	 * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
  	 *	        irq handler. Some drivers need to apply some workarounds
  	 *              for gpu-specific vblank irq quirks if flag is set.
  	 *
  	 * \returns
  	 * Zero if timestamping isn't supported in current display mode or a
  	 * negative number on failure. A positive status code on success,
  	 * which describes how the vblank_time timestamp was computed.
  	 */
88e72717c   Thierry Reding   drm/irq: Use unsi...
591
  	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
27641c3f0   Mario Kleiner   drm/vblank: Add s...
592
593
594
  				     int *max_error,
  				     struct timeval *vblank_time,
  				     unsigned flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
595
  	/* these have to be filled in */
b5e89ed53   Dave Airlie   drm: lindent the ...
596

e9f0d76f3   Daniel Vetter   drm: Kill DRM_IRQ...
597
  	irqreturn_t(*irq_handler) (int irq, void *arg);
84b1fd103   Dave Airlie   drm: remove drm_f...
598
  	void (*irq_preinstall) (struct drm_device *dev);
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
599
  	int (*irq_postinstall) (struct drm_device *dev);
84b1fd103   Dave Airlie   drm: remove drm_f...
600
  	void (*irq_uninstall) (struct drm_device *dev);
22eae947b   Dave Airlie   drm: rename drive...
601

7c1c2871a   Dave Airlie   drm: move to kref...
602
603
604
  	/* Master routines */
  	int (*master_create)(struct drm_device *dev, struct drm_master *master);
  	void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
862302ffe   Thomas Hellstrom   drm: Add support ...
605
606
607
608
609
610
611
  	/**
  	 * master_set is called whenever the minor master is set.
  	 * master_drop is called whenever the minor master is dropped.
  	 */
  
  	int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
  			  bool from_open);
d6ed682eb   Daniel Vetter   drm: Refactor dro...
612
  	void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
7c1c2871a   Dave Airlie   drm: move to kref...
613

955b12def   Ben Gamari   drm: Convert proc...
614
615
  	int (*debugfs_init)(struct drm_minor *minor);
  	void (*debugfs_cleanup)(struct drm_minor *minor);
673a394b1   Eric Anholt   drm: Add GEM ("gr...
616
617
  
  	/**
9f0ba539d   Daniel Vetter   drm/gem: support ...
618
  	 * @gem_free_object: deconstructor for drm_gem_objects
673a394b1   Eric Anholt   drm: Add GEM ("gr...
619
  	 *
9f0ba539d   Daniel Vetter   drm/gem: support ...
620
621
  	 * This is deprecated and should not be used by new drivers. Use
  	 * @gem_free_object_unlocked instead.
673a394b1   Eric Anholt   drm: Add GEM ("gr...
622
  	 */
673a394b1   Eric Anholt   drm: Add GEM ("gr...
623
  	void (*gem_free_object) (struct drm_gem_object *obj);
9f0ba539d   Daniel Vetter   drm/gem: support ...
624
625
626
627
628
629
630
631
  
  	/**
  	 * @gem_free_object_unlocked: deconstructor for drm_gem_objects
  	 *
  	 * This is for drivers which are not encumbered with dev->struct_mutex
  	 * legacy locking schemes. Use this hook instead of @gem_free_object.
  	 */
  	void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
304eda329   Ben Skeggs   drm/gem: add hook...
632
633
  	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
  	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
673a394b1   Eric Anholt   drm: Add GEM ("gr...
634

10028c5ab   Eric Anholt   drm: Create a dri...
635
636
637
638
639
640
  	/**
  	 * Hook for allocating the GEM object struct, for use by core
  	 * helpers.
  	 */
  	struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
  						    size_t size);
3248877ea   Dave Airlie   drm: base prime/d...
641
642
643
644
645
646
647
648
649
650
651
652
653
  	/* prime: */
  	/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
  	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
  				uint32_t handle, uint32_t flags, int *prime_fd);
  	/* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
  	int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
  				int prime_fd, uint32_t *handle);
  	/* export GEM -> dmabuf */
  	struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
  				struct drm_gem_object *obj, int flags);
  	/* import dmabuf -> GEM */
  	struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
  				struct dma_buf *dma_buf);
89177644a   Aaron Plattner   drm: add prime he...
654
655
  	/* low-level interface used by drm_gem_prime_{import,export} */
  	int (*gem_prime_pin)(struct drm_gem_object *obj);
102d6dba3   Maarten Lankhorst   drm: add unpin fu...
656
  	void (*gem_prime_unpin)(struct drm_gem_object *obj);
3aac4502f   Maarten Lankhorst   dma-buf: use rese...
657
658
  	struct reservation_object * (*gem_prime_res_obj)(
  				struct drm_gem_object *obj);
89177644a   Aaron Plattner   drm: add prime he...
659
660
  	struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
  	struct drm_gem_object *(*gem_prime_import_sg_table)(
b5e9c1a25   Maarten Lankhorst   drm: Pass dma-buf...
661
662
  				struct drm_device *dev,
  				struct dma_buf_attachment *attach,
89177644a   Aaron Plattner   drm: add prime he...
663
664
665
  				struct sg_table *sgt);
  	void *(*gem_prime_vmap)(struct drm_gem_object *obj);
  	void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
7c397cd97   Joonyoung Shim   drm: add mmap fun...
666
667
  	int (*gem_prime_mmap)(struct drm_gem_object *obj,
  				struct vm_area_struct *vma);
3248877ea   Dave Airlie   drm: base prime/d...
668

28d520433   Dave Airlie   drm/vgaarb: add V...
669
670
  	/* vga arb irq handler */
  	void (*vgaarb_irq)(struct drm_device *dev, bool state);
ff72145ba   Dave Airlie   drm: dumb scanout...
671
672
673
674
675
676
677
678
679
680
  	/* dumb alloc support */
  	int (*dumb_create)(struct drm_file *file_priv,
  			   struct drm_device *dev,
  			   struct drm_mode_create_dumb *args);
  	int (*dumb_map_offset)(struct drm_file *file_priv,
  			       struct drm_device *dev, uint32_t handle,
  			       uint64_t *offset);
  	int (*dumb_destroy)(struct drm_file *file_priv,
  			    struct drm_device *dev,
  			    uint32_t handle);
a2c0a97b7   Jesse Barnes   drm: GEM mmap sup...
681
  	/* Driver private ops for this object */
78b68556a   Laurent Pinchart   drm: Constify gem...
682
  	const struct vm_operations_struct *gem_vm_ops;
a2c0a97b7   Jesse Barnes   drm: GEM mmap sup...
683

22eae947b   Dave Airlie   drm: rename drive...
684
685
686
687
688
689
  	int major;
  	int minor;
  	int patchlevel;
  	char *name;
  	char *desc;
  	char *date;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
690
691
  	u32 driver_features;
  	int dev_priv_size;
baa709435   Rob Clark   drm: const'ify io...
692
  	const struct drm_ioctl_desc *ioctls;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
693
  	int num_ioctls;
e08e96de9   Arjan van de Ven   drm: Make the per...
694
  	const struct file_operations *fops;
8410ea3b9   Dave Airlie   drm: rework PCI/p...
695

b3f2333de   Daniel Vetter   drm: restrict the...
696
697
  	/* List of devices hanging off this driver with stealth attach. */
  	struct list_head legacy_dev_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
698
  };
cb8a239b0   David Herrmann   drm: turn DRM_MIN...
699
  enum drm_minor_type {
a3ccc4616   David Herrmann   drm: rename DRM_M...
700
  	DRM_MINOR_PRIMARY,
cb8a239b0   David Herrmann   drm: turn DRM_MIN...
701
702
703
704
  	DRM_MINOR_CONTROL,
  	DRM_MINOR_RENDER,
  	DRM_MINOR_CNT,
  };
2c14f28be   Dave Airlie   drm: reorganise m...
705

955b12def   Ben Gamari   drm: Convert proc...
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
  /**
   * Info file list entry. This structure represents a debugfs or proc file to
   * be created by the drm core
   */
  struct drm_info_list {
  	const char *name; /** file name */
  	int (*show)(struct seq_file*, void*); /** show callback */
  	u32 driver_features; /**< Required driver features for this entry */
  	void *data;
  };
  
  /**
   * debugfs node structure. This structure represents a debugfs file.
   */
  struct drm_info_node {
  	struct list_head list;
  	struct drm_minor *minor;
ce089b547   David Howells   drm: Constify drm...
723
  	const struct drm_info_list *info_ent;
955b12def   Ben Gamari   drm: Convert proc...
724
725
  	struct dentry *dent;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
726
  /**
2c14f28be   Dave Airlie   drm: reorganise m...
727
   * DRM minor structure. This structure represents a drm minor number.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
728
   */
2c14f28be   Dave Airlie   drm: reorganise m...
729
730
731
  struct drm_minor {
  	int index;			/**< Minor device number */
  	int type;                       /**< Control or render */
5bdebb183   Dave Airlie   drm/sysfs: sort o...
732
  	struct device *kdev;		/**< Linux device */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
733
  	struct drm_device *dev;
955b12def   Ben Gamari   drm: Convert proc...
734

955b12def   Ben Gamari   drm: Convert proc...
735
  	struct dentry *debugfs_root;
b3e067c0b   Marcin Slusarz   drm: serialize ac...
736
737
738
  
  	struct list_head debugfs_list;
  	struct mutex debugfs_lock; /* Protects debugfs_list. */
84b1fd103   Dave Airlie   drm: remove drm_f...
739
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
740
741
742
743
744
  
  /**
   * DRM device structure. This structure represent a complete card that
   * may contain multiple heads.
   */
84b1fd103   Dave Airlie   drm: remove drm_f...
745
  struct drm_device {
b3f2333de   Daniel Vetter   drm: restrict the...
746
  	struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
b5e89ed53   Dave Airlie   drm: lindent the ...
747
  	int if_version;			/**< Highest interface version set */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
748

45e212d20   David Herrmann   drm: group dev-li...
749
750
751
  	/** 
  ame Lifetime Management */
  	/*@{ */
099d1c290   David Herrmann   drm: provide devi...
752
  	struct kref ref;		/**< Object ref-count */
45e212d20   David Herrmann   drm: group dev-li...
753
754
755
  	struct device *dev;		/**< Device structure of bus-device */
  	struct drm_driver *driver;	/**< DRM driver managing the device */
  	void *dev_private;		/**< DRM driver private data */
45e212d20   David Herrmann   drm: group dev-li...
756
757
758
  	struct drm_minor *control;		/**< Control node */
  	struct drm_minor *primary;		/**< Primary node */
  	struct drm_minor *render;		/**< Render node */
95c081c17   Daniel Vetter   drm: Move master ...
759
760
761
  
  	/* currently active master for this device. Protected by master_mutex */
  	struct drm_master *master;
45e212d20   David Herrmann   drm: group dev-li...
762
  	atomic_t unplugged;			/**< Flag whether dev is dead */
07b48c3ac   David Herrmann   Merge branch 'drm...
763
  	struct inode *anon_inode;		/**< inode for private address-space */
ca8e2ad71   Thierry Reding   drm: Introduce dr...
764
  	char *unique;				/**< unique name of the device */
45e212d20   David Herrmann   drm: group dev-li...
765
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
766
767
  	/** 
  ame Locks */
b5e89ed53   Dave Airlie   drm: lindent the ...
768
  	/*@{ */
30e2fb188   Dave Airlie   sem2mutex: driver...
769
  	struct mutex struct_mutex;	/**< For others */
c996fd0b9   Thomas Hellstrom   drm: Protect the ...
770
  	struct mutex master_mutex;      /**< For drm_minor::master and drm_file::is_master */
b5e89ed53   Dave Airlie   drm: lindent the ...
771
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
772
773
774
  
  	/** 
  ame Usage Counters */
b5e89ed53   Dave Airlie   drm: lindent the ...
775
  	/*@{ */
fc8fd40eb   Daniel Vetter   drm: Rip out tota...
776
  	int open_count;			/**< Outstanding files open, protected by drm_global_mutex. */
2177a2182   Daniel Vetter   drm: rename dev->...
777
  	spinlock_t buf_lock;		/**< For drm_device::buf_use and a few other things. */
b5e89ed53   Dave Airlie   drm: lindent the ...
778
779
780
  	int buf_use;			/**< Buffers in use -- cannot alloc */
  	atomic_t buf_alloc;		/**< Buffer allocation in progress */
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
781

1d2ac403a   Daniel Vetter   drm: Protect dev-...
782
  	struct mutex filelist_mutex;
bd1b331fa   Dave Airlie   drm: cleanup use ...
783
  	struct list_head filelist;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
784
785
786
  
  	/** 
  ame Memory management */
b5e89ed53   Dave Airlie   drm: lindent the ...
787
  	/*@{ */
bd1b331fa   Dave Airlie   drm: cleanup use ...
788
  	struct list_head maplist;	/**< Linked list of regions */
e0be428e6   Dave Airlie   drm: detypedef th...
789
  	struct drm_open_hash map_hash;	/**< User token hash table for maps */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
790
791
792
  
  	/** 
  ame Context handle management */
b5e89ed53   Dave Airlie   drm: lindent the ...
793
  	/*@{ */
bd1b331fa   Dave Airlie   drm: cleanup use ...
794
  	struct list_head ctxlist;	/**< Linked list of context handles */
30e2fb188   Dave Airlie   sem2mutex: driver...
795
  	struct mutex ctxlist_mutex;	/**< For ctxlist */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
796

62968144e   Dave Airlie   drm: convert drm ...
797
  	struct idr ctx_idr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
798

bd1b331fa   Dave Airlie   drm: cleanup use ...
799
  	struct list_head vmalist;	/**< List of vmas (for debugging) */
f453ba046   Dave Airlie   DRM: add mode set...
800

b5e89ed53   Dave Airlie   drm: lindent the ...
801
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
802

a344a7e7c   Daniel Vetter   drm: kill dma que...
803
804
  	/** 
  ame DMA support */
b5e89ed53   Dave Airlie   drm: lindent the ...
805
  	/*@{ */
cdd55a294   Dave Airlie   drm: detypef wait...
806
  	struct drm_device_dma *dma;		/**< Optional pointer for DMA support */
b5e89ed53   Dave Airlie   drm: lindent the ...
807
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
808
809
810
  
  	/** 
  ame Context support */
b5e89ed53   Dave Airlie   drm: lindent the ...
811
  	/*@{ */
7c1a38e39   Daniel Vetter   drm/irq: track th...
812

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
813
  	__volatile__ long context_flag;	/**< Context swapping flag */
b5e89ed53   Dave Airlie   drm: lindent the ...
814
  	int last_context;		/**< Last current context */
b5e89ed53   Dave Airlie   drm: lindent the ...
815
  	/*@} */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
816
817
  	/** 
  ame VBLANK IRQ support */
b5e89ed53   Dave Airlie   drm: lindent the ...
818
  	/*@{ */
b46004b70   Thierry Reding   drm: Move IRQ rel...
819
820
  	bool irq_enabled;
  	int irq;
b5e89ed53   Dave Airlie   drm: lindent the ...
821

0a3e67a4c   Jesse Barnes   drm: Rework vblan...
822
  	/*
00185e667   Ville Syrjälä   drm: Add dev->vbl...
823
824
825
826
827
828
829
830
  	 * If true, vblank interrupt will be disabled immediately when the
  	 * refcount drops to zero, as opposed to via the vblank disable
  	 * timer.
  	 * This can be set to true it the hardware has a working vblank
  	 * counter and the driver uses drm_vblank_on() and drm_vblank_off()
  	 * appropriately.
  	 */
  	bool vblank_disable_immediate;
5380e9293   Ville Syrjälä   drm: Collect per-...
831
832
  	/* array of size num_crtcs */
  	struct drm_vblank_crtc *vblank;
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
833

27641c3f0   Mario Kleiner   drm/vblank: Add s...
834
  	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
b5e89ed53   Dave Airlie   drm: lindent the ...
835
  	spinlock_t vbl_lock;
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
836
837
  
  	u32 max_vblank_count;           /**< size of vblank counter register */
b5e89ed53   Dave Airlie   drm: lindent the ...
838

c9a9c5e02   Kristian Høgsberg   drm: Add async ev...
839
840
841
842
843
  	/**
  	 * List of events
  	 */
  	struct list_head vblank_event_list;
  	spinlock_t event_lock;
b5e89ed53   Dave Airlie   drm: lindent the ...
844
  	/*@} */
b5e89ed53   Dave Airlie   drm: lindent the ...
845

55910517a   Dave Airlie   drm: detypedeffin...
846
  	struct drm_agp_head *agp;	/**< AGP data */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
847

b5e89ed53   Dave Airlie   drm: lindent the ...
848
  	struct pci_dev *pdev;		/**< PCI device structure */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
849
  #ifdef __alpha__
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
850
851
  	struct pci_controller *hose;
  #endif
dcdb16740   Jordan Crouse   drm: Add support ...
852
853
  
  	struct platform_device *platformdev; /**< Platform device struture */
dc5698e80   Dave Airlie   Add virtio gpu dr...
854
  	struct virtio_device *virtdev;
dcdb16740   Jordan Crouse   drm: Add support ...
855

55910517a   Dave Airlie   drm: detypedeffin...
856
  	struct drm_sg_mem *sg;	/**< Scatter gather memory */
192275612   Dave Airlie   drm: fix unsigned...
857
  	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
b5e89ed53   Dave Airlie   drm: lindent the ...
858

69d516c0a   David Herrmann   drm: inline "stru...
859
860
861
862
  	struct {
  		int context;
  		struct drm_hw_lock *lock;
  	} sigdata;
f77d390c9   Benjamin Herrenschmidt   drm: Split drm_ma...
863
  	struct drm_local_map *agp_buffer_map;
d1f2b55ad   Dave Airlie   drm: updated DRM ...
864
  	unsigned int agp_buffer_token;
bea5679f9   Michel Dänzer   drm: Add support ...
865

417009fb1   Rob Clark   drm: fix indentation
866
  	struct drm_mode_config mode_config;	/**< Current mode config */
f453ba046   Dave Airlie   DRM: add mode set...
867

673a394b1   Eric Anholt   drm: Add GEM ("gr...
868
869
870
  	/** 
  ame GEM information */
  	/*@{ */
cd4f013f3   Daniel Vetter   drm/gem: switch d...
871
  	struct mutex object_name_lock;
673a394b1   Eric Anholt   drm: Add GEM ("gr...
872
  	struct idr object_name_idr;
b04a59062   Daniel Vetter   drm: store the ge...
873
  	struct drm_vma_offset_manager *vma_offset_manager;
673a394b1   Eric Anholt   drm: Add GEM ("gr...
874
  	/*@} */
5bcf719b7   Dave Airlie   drm/switcheroo: t...
875
  	int switch_power_state;
84b1fd103   Dave Airlie   drm: remove drm_f...
876
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
877

34a67dd7f   Daniel Vetter   drm: Extract&Docu...
878
  #include <drm/drm_irq.h>
5bcf719b7   Dave Airlie   drm/switcheroo: t...
879
880
881
  #define DRM_SWITCH_POWER_ON 0
  #define DRM_SWITCH_POWER_OFF 1
  #define DRM_SWITCH_POWER_CHANGING 2
13bb9cc87   Dave Airlie   drm: allow open o...
882
  #define DRM_SWITCH_POWER_DYNAMIC_OFF 3
5bcf719b7   Dave Airlie   drm/switcheroo: t...
883

b5e89ed53   Dave Airlie   drm: lindent the ...
884
885
  static __inline__ int drm_core_check_feature(struct drm_device *dev,
  					     int feature)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
886
887
888
  {
  	return ((dev->driver->driver_features & feature) ? 1 : 0);
  }
2c07a21d6   Dave Airlie   drm: add core sup...
889
890
891
892
893
894
895
896
897
898
899
900
  static inline void drm_device_set_unplugged(struct drm_device *dev)
  {
  	smp_wmb();
  	atomic_set(&dev->unplugged, 1);
  }
  
  static inline int drm_device_is_unplugged(struct drm_device *dev)
  {
  	int ret = atomic_read(&dev->unplugged);
  	smp_rmb();
  	return ret;
  }
436830571   Thomas Hellstrom   drm: Improve on m...
901
  static inline bool drm_is_render_client(const struct drm_file *file_priv)
1793126fc   David Herrmann   drm: implement ex...
902
903
904
  {
  	return file_priv->minor->type == DRM_MINOR_RENDER;
  }
ac05dbc57   Thomas Hellstrom   drm: Make control...
905
906
907
908
  static inline bool drm_is_control_client(const struct drm_file *file_priv)
  {
  	return file_priv->minor->type == DRM_MINOR_CONTROL;
  }
436830571   Thomas Hellstrom   drm: Improve on m...
909
910
  static inline bool drm_is_primary_client(const struct drm_file *file_priv)
  {
a3ccc4616   David Herrmann   drm: rename DRM_M...
911
  	return file_priv->minor->type == DRM_MINOR_PRIMARY;
436830571   Thomas Hellstrom   drm: Improve on m...
912
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
913
914
915
916
  /******************************************************************/
  /** 
  ame Internal function definitions */
  /*@{*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
917
  				/* Driver support (drm_drv.h) */
5101020c7   Thomas Hellstrom   drm: export the D...
918
  extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
ed8b67040   Arnd Bergmann   drm: convert drm_...
919
920
  extern long drm_ioctl(struct file *filp,
  		      unsigned int cmd, unsigned long arg);
b5e89ed53   Dave Airlie   drm: lindent the ...
921
922
  extern long drm_compat_ioctl(struct file *filp,
  			     unsigned int cmd, unsigned long arg);
4beb6d9fa   Thomas Hellstrom   drm: Add a functi...
923
  extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
924

bcb877e4d   Daniel Vetter   drm: kerneldoc fo...
925
926
927
928
929
  /* File Operations (drm_fops.c) */
  int drm_open(struct inode *inode, struct file *filp);
  ssize_t drm_read(struct file *filp, char __user *buffer,
  		 size_t count, loff_t *offset);
  int drm_release(struct inode *inode, struct file *filp);
bcb877e4d   Daniel Vetter   drm: kerneldoc fo...
930
  unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
4020b220e   Daniel Vetter   drm/vblank: Use d...
931
932
933
934
  int drm_event_reserve_init_locked(struct drm_device *dev,
  				  struct drm_file *file_priv,
  				  struct drm_pending_event *p,
  				  struct drm_event *e);
2dd500f18   Daniel Vetter   drm: Add function...
935
936
937
938
939
940
  int drm_event_reserve_init(struct drm_device *dev,
  			   struct drm_file *file_priv,
  			   struct drm_pending_event *p,
  			   struct drm_event *e);
  void drm_event_cancel_free(struct drm_device *dev,
  			   struct drm_pending_event *p);
fb740cf24   Daniel Vetter   drm: Create drm_s...
941
942
  void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
  void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
943

78238757e   Daniel Vetter   drm: Purge ioctl ...
944
945
946
  /* Misc. IOCTL support (drm_ioctl.c) */
  int drm_noop(struct drm_device *dev, void *data,
  	     struct drm_file *file_priv);
4b63539bb   Daniel Vetter   drm: Define a drm...
947
948
  int drm_invalid_op(struct drm_device *dev, void *data,
  		   struct drm_file *file_priv);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
949

673a394b1   Eric Anholt   drm: Add GEM ("gr...
950
951
  /* Cache management (drm_cache.c) */
  void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
9da3da660   Chris Wilson   drm/i915: Replace...
952
  void drm_clflush_sg(struct sg_table *st);
c2d15359c   Ville Syrjälä   drm: Make drm_clf...
953
  void drm_clflush_virt_range(void *addr, unsigned long length);
673a394b1   Eric Anholt   drm: Add GEM ("gr...
954

040ac3204   Thomas Hellstrom   drm: fix driver d...
955
956
957
958
  /*
   * These are exported to drivers so that they can implement fencing using
   * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
   */
0a3e67a4c   Jesse Barnes   drm: Rework vblan...
959
  /* Modesetting support */
cc1ef118f   Thierry Reding   drm/irq: Make pip...
960
961
  extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
  extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
962

b3ac9f259   Daniel Vetter   drm: Extract drm_...
963
964
965
  /* drm_drv.c */
  void drm_put_dev(struct drm_device *dev);
  void drm_unplug_dev(struct drm_device *dev);
b5e89ed53   Dave Airlie   drm: lindent the ...
966
  extern unsigned int drm_debug;
2c14f28be   Dave Airlie   drm: reorganise m...
967

955b12def   Ben Gamari   drm: Convert proc...
968
969
  				/* Debugfs support */
  #if defined(CONFIG_DEBUG_FS)
7d74795b7   Lespiau, Damien   drm: Constify str...
970
971
972
973
974
  extern int drm_debugfs_create_files(const struct drm_info_list *files,
  				    int count, struct dentry *root,
  				    struct drm_minor *minor);
  extern int drm_debugfs_remove_files(const struct drm_info_list *files,
  				    int count, struct drm_minor *minor);
66ee52e28   Thierry Reding   drm: Implement du...
975
  #else
66ee52e28   Thierry Reding   drm: Implement du...
976
977
978
979
980
981
982
983
984
985
986
987
  static inline int drm_debugfs_create_files(const struct drm_info_list *files,
  					   int count, struct dentry *root,
  					   struct drm_minor *minor)
  {
  	return 0;
  }
  
  static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
  					   int count, struct drm_minor *minor)
  {
  	return 0;
  }
955b12def   Ben Gamari   drm: Convert proc...
988
  #endif
a4fce9cb7   Chris Wilson   drm/prime: Take a...
989
  struct dma_buf_export_info;
89177644a   Aaron Plattner   drm: add prime he...
990
  extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
56a76c012   Chris Wilson   drm/prime: Pass t...
991
992
  					    struct drm_gem_object *obj,
  					    int flags);
3248877ea   Dave Airlie   drm: base prime/d...
993
994
995
  extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
  		int *prime_fd);
89177644a   Aaron Plattner   drm: add prime he...
996
997
  extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
  		struct dma_buf *dma_buf);
3248877ea   Dave Airlie   drm: base prime/d...
998
999
  extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
  		struct drm_file *file_priv, int prime_fd, uint32_t *handle);
a4fce9cb7   Chris Wilson   drm/prime: Take a...
1000
1001
  struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
  				      struct dma_buf_export_info *exp_info);
c1d6798d2   Daniel Vetter   drm: use common d...
1002
  extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
3248877ea   Dave Airlie   drm: base prime/d...
1003

51ab7ba26   Dave Airlie   drm/prime: introd...
1004
1005
  extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
  					    dma_addr_t *addrs, int max_pages);
34eab43ed   Thierry Reding   drm/prime: Use un...
1006
  extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
3248877ea   Dave Airlie   drm: base prime/d...
1007
  extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1008

ba8286fab   Daniel Vetter   drm: Move legacy ...
1009
1010
1011
  extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
  					    size_t align);
  extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1012
1013
  
  			       /* sysfs support (drm_sysfs.c) */
f453ba046   Dave Airlie   DRM: add mode set...
1014
  extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1015

673a394b1   Eric Anholt   drm: Add GEM ("gr...
1016

1bb72532a   David Herrmann   drm: add drm_dev_...
1017
1018
  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
  				 struct device *parent);
b209aca36   Chris Wilson   drm: Export drm_d...
1019
1020
1021
  int drm_dev_init(struct drm_device *dev,
  		 struct drm_driver *driver,
  		 struct device *parent);
099d1c290   David Herrmann   drm: provide devi...
1022
1023
  void drm_dev_ref(struct drm_device *dev);
  void drm_dev_unref(struct drm_device *dev);
c22f0ace1   David Herrmann   drm: merge device...
1024
  int drm_dev_register(struct drm_device *dev, unsigned long flags);
c3a49737e   David Herrmann   drm: move device ...
1025
  void drm_dev_unregister(struct drm_device *dev);
1616c525b   David Herrmann   drm: add minor-lo...
1026
1027
1028
  
  struct drm_minor *drm_minor_acquire(unsigned int minor_id);
  void drm_minor_release(struct drm_minor *minor);
8410ea3b9   Dave Airlie   drm: rework PCI/p...
1029
1030
1031
1032
1033
  /*@}*/
  
  /* PCI section */
  static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
  {
b5e89ed53   Dave Airlie   drm: lindent the ...
1034
1035
  	if (dev->driver->device_is_agp != NULL) {
  		int err = (*dev->driver->device_is_agp) (dev);
cda173806   Dave Airlie   drm: add test for...
1036
1037
1038
1039
1040
1041
1042
  		if (err != 2) {
  			return err;
  		}
  	}
  
  	return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
  }
4efafebe7   Daniel Vetter   drm: kill the ->a...
1043
  void drm_pci_agp_destroy(struct drm_device *dev);
cda173806   Dave Airlie   drm: add test for...
1044

8410ea3b9   Dave Airlie   drm: rework PCI/p...
1045
1046
  extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
  extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
a9e3c90c9   Thierry Reding   drm: Implement dr...
1047
  #ifdef CONFIG_PCI
8410ea3b9   Dave Airlie   drm: rework PCI/p...
1048
  extern int drm_get_pci_dev(struct pci_dev *pdev,
dcdb16740   Jordan Crouse   drm: Add support ...
1049
1050
  			   const struct pci_device_id *ent,
  			   struct drm_driver *driver);
915b4d11b   David Herrmann   drm: add driver->...
1051
  extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
a9e3c90c9   Thierry Reding   drm: Implement dr...
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
  #else
  static inline int drm_get_pci_dev(struct pci_dev *pdev,
  				  const struct pci_device_id *ent,
  				  struct drm_driver *driver)
  {
  	return -ENOSYS;
  }
  
  static inline int drm_pci_set_busid(struct drm_device *dev,
  				    struct drm_master *master)
  {
  	return -ENOSYS;
  }
  #endif
8410ea3b9   Dave Airlie   drm: rework PCI/p...
1066

f42977841   Dave Airlie   drm/pci: add supp...
1067
1068
1069
1070
1071
  #define DRM_PCIE_SPEED_25 1
  #define DRM_PCIE_SPEED_50 2
  #define DRM_PCIE_SPEED_80 4
  
  extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
60d8edd41   Alex Deucher   drm: add drm_pcie...
1072
  extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
8410ea3b9   Dave Airlie   drm: rework PCI/p...
1073
1074
1075
  
  /* platform section */
  extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
8410ea3b9   Dave Airlie   drm: rework PCI/p...
1076

cc1f71942   Dave Airlie   drm: introduce dr...
1077
1078
1079
1080
1081
1082
1083
  /* returns true if currently okay to sleep */
  static __inline__ bool drm_can_sleep(void)
  {
  	if (in_atomic() || in_dbg_master() || irqs_disabled())
  		return false;
  	return true;
  }
373701b1f   Jani Nikula   drm: fix potentia...
1084
1085
  /* helper for handling conditionals in various for_each macros */
  #define for_each_if(condition) if (!(condition)) {} else
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1086
  #endif