Subversion Repositories Kolibri OS

Rev

Rev 5056 | Rev 5270 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5056 Rev 5178
1
/**
1
/**
2
 * \file drmP.h
2
 * \file drmP.h
3
 * Private header for Direct Rendering Manager
3
 * Private header for Direct Rendering Manager
4
 *
4
 *
5
 * \author Rickard E. (Rik) Faith 
5
 * \author Rickard E. (Rik) Faith 
6
 * \author Gareth Hughes 
6
 * \author Gareth Hughes 
7
 */
7
 */
8
 
8
 
9
/*
9
/*
10
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
10
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
11
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12
 * Copyright (c) 2009-2010, Code Aurora Forum.
12
 * Copyright (c) 2009-2010, Code Aurora Forum.
13
 * All rights reserved.
13
 * All rights reserved.
14
 *
14
 *
15
 * Permission is hereby granted, free of charge, to any person obtaining a
15
 * Permission is hereby granted, free of charge, to any person obtaining a
16
 * copy of this software and associated documentation files (the "Software"),
16
 * copy of this software and associated documentation files (the "Software"),
17
 * to deal in the Software without restriction, including without limitation
17
 * to deal in the Software without restriction, including without limitation
18
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19
 * and/or sell copies of the Software, and to permit persons to whom the
19
 * and/or sell copies of the Software, and to permit persons to whom the
20
 * Software is furnished to do so, subject to the following conditions:
20
 * Software is furnished to do so, subject to the following conditions:
21
 *
21
 *
22
 * The above copyright notice and this permission notice (including the next
22
 * The above copyright notice and this permission notice (including the next
23
 * paragraph) shall be included in all copies or substantial portions of the
23
 * paragraph) shall be included in all copies or substantial portions of the
24
 * Software.
24
 * Software.
25
 *
25
 *
26
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
28
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
29
 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29
 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
30
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
31
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32
 * OTHER DEALINGS IN THE SOFTWARE.
32
 * OTHER DEALINGS IN THE SOFTWARE.
33
 */
33
 */
34
 
34
 
35
#ifndef _DRM_P_H_
35
#ifndef _DRM_P_H_
36
#define _DRM_P_H_
36
#define _DRM_P_H_
37
 
37
 
38
#define iowrite32(v, addr)      writel((v), (addr))
38
#define iowrite32(v, addr)      writel((v), (addr))
39
 
39
 
40
#ifdef __KERNEL__
40
#ifdef __KERNEL__
41
#ifdef __alpha__
41
#ifdef __alpha__
42
/* add include of current.h so that "current" is defined
42
/* add include of current.h so that "current" is defined
43
 * before static inline funcs in wait.h. Doing this so we
43
 * before static inline funcs in wait.h. Doing this so we
44
 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
44
 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
45
#include 
45
#include 
46
#endif				/* __alpha__ */
46
#endif				/* __alpha__ */
47
 
47
 
48
#include 
48
#include 
49
 
49
 
50
#include 
50
#include 
51
#include 
51
#include 
52
#include 
52
#include 
53
#include 
53
#include 
54
#include 
54
#include 
55
#include 
55
#include 
56
#include 
56
#include 
57
#include 
57
#include 
58
 
58
 
59
#include 
59
#include 
60
#include 
60
#include 
61
 
61
 
62
#include 
62
#include 
63
//#include 
63
//#include 
64
#include 
64
#include 
65
#include 
65
#include 
66
#include 
66
#include 
67
#include 
67
#include 
68
 
68
 
69
#include 
69
#include 
70
#include 
70
#include 
71
//#include 
71
//#include 
72
#include 
72
#include 
73
 
73
 
74
//#include 
74
//#include 
75
//#include 
75
//#include 
76
//#include 
76
//#include 
77
//#include 
77
//#include 
78
 
78
 
79
#include 
79
#include 
80
#include 
80
#include 
81
 
81
 
82
 
82
 
83
#include 
83
#include 
84
#include 
84
#include 
85
 
85
 
86
#include 
86
#include 
87
 
87
 
88
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
88
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
89
 
89
 
90
struct module;
90
struct module;
91
 
91
 
92
struct drm_file;
92
struct drm_file;
93
struct drm_device;
93
struct drm_device;
94
 
94
 
95
struct device_node;
95
struct device_node;
96
struct videomode;
96
struct videomode;
97
struct reservation_object;
97
struct reservation_object;
98
 
98
 
99
struct inode;
99
struct inode;
100
struct poll_table_struct;
100
struct poll_table_struct;
101
struct drm_lock_data;
101
struct drm_lock_data;
102
 
102
 
103
struct sg_table;
103
struct sg_table;
104
struct dma_buf;
104
struct dma_buf;
105
 
105
 
106
//#include 
106
//#include 
107
#include 
107
#include 
108
#include 
108
#include 
109
 
109
 
110
#define KHZ2PICOS(a) (1000000000UL/(a))
110
#define KHZ2PICOS(a) (1000000000UL/(a))
111
 
111
 
112
/* Flags and return codes for get_vblank_timestamp() driver function. */
112
/* Flags and return codes for get_vblank_timestamp() driver function. */
113
#define DRM_CALLED_FROM_VBLIRQ 1
113
#define DRM_CALLED_FROM_VBLIRQ 1
114
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
114
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
115
#define DRM_VBLANKTIME_INVBL             (1 << 1)
115
#define DRM_VBLANKTIME_INVBL             (1 << 1)
116
 
116
 
117
 
117
 
118
/* get_scanout_position() return flags */
118
/* get_scanout_position() return flags */
119
#define DRM_SCANOUTPOS_VALID        (1 << 0)
119
#define DRM_SCANOUTPOS_VALID        (1 << 0)
120
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
120
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
121
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
121
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
122
 
122
 
123
/*
123
/*
124
 * 4 debug categories are defined:
124
 * 4 debug categories are defined:
125
 *
125
 *
126
 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
126
 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
127
 *	 This is the category used by the DRM_DEBUG() macro.
127
 *	 This is the category used by the DRM_DEBUG() macro.
128
 *
128
 *
129
 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
129
 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
130
 *	   This is the category used by the DRM_DEBUG_DRIVER() macro.
130
 *	   This is the category used by the DRM_DEBUG_DRIVER() macro.
131
 *
131
 *
132
 * KMS: used in the modesetting code.
132
 * KMS: used in the modesetting code.
133
 *	This is the category used by the DRM_DEBUG_KMS() macro.
133
 *	This is the category used by the DRM_DEBUG_KMS() macro.
134
 *
134
 *
135
 * PRIME: used in the prime code.
135
 * PRIME: used in the prime code.
136
 *	  This is the category used by the DRM_DEBUG_PRIME() macro.
136
 *	  This is the category used by the DRM_DEBUG_PRIME() macro.
137
 *
137
 *
138
 * Enabling verbose debug messages is done through the drm.debug parameter,
138
 * Enabling verbose debug messages is done through the drm.debug parameter,
139
 * each category being enabled by a bit.
139
 * each category being enabled by a bit.
140
 *
140
 *
141
 * drm.debug=0x1 will enable CORE messages
141
 * drm.debug=0x1 will enable CORE messages
142
 * drm.debug=0x2 will enable DRIVER messages
142
 * drm.debug=0x2 will enable DRIVER messages
143
 * drm.debug=0x3 will enable CORE and DRIVER messages
143
 * drm.debug=0x3 will enable CORE and DRIVER messages
144
 * ...
144
 * ...
145
 * drm.debug=0xf will enable all messages
145
 * drm.debug=0xf will enable all messages
146
 *
146
 *
147
 * An interesting feature is that it's possible to enable verbose logging at
147
 * An interesting feature is that it's possible to enable verbose logging at
148
 * run-time by echoing the debug value in its sysfs node:
148
 * run-time by echoing the debug value in its sysfs node:
149
 *   # echo 0xf > /sys/module/drm/parameters/debug
149
 *   # echo 0xf > /sys/module/drm/parameters/debug
150
 */
150
 */
151
#define DRM_UT_CORE 		0x01
151
#define DRM_UT_CORE 		0x01
152
#define DRM_UT_DRIVER		0x02
152
#define DRM_UT_DRIVER		0x02
153
#define DRM_UT_KMS          0x04
153
#define DRM_UT_KMS          0x04
154
#define DRM_UT_PRIME		0x08
154
#define DRM_UT_PRIME		0x08
155
 
155
 
156
extern __printf(2, 3)
156
extern __printf(2, 3)
157
void drm_ut_debug_printk(const char *function_name,
157
void drm_ut_debug_printk(const char *function_name,
158
				const char *format, ...);
158
				const char *format, ...);
159
extern __printf(2, 3)
159
extern __printf(2, 3)
160
int drm_err(const char *func, const char *format, ...);
160
int drm_err(const char *func, const char *format, ...);
161
 
161
 
162
/***********************************************************************/
162
/***********************************************************************/
163
/** \name DRM template customization defaults */
163
/** \name DRM template customization defaults */
164
/*@{*/
164
/*@{*/
165
 
165
 
166
/* driver capabilities and requirements mask */
166
/* driver capabilities and requirements mask */
167
#define DRIVER_USE_AGP     0x1
167
#define DRIVER_USE_AGP     0x1
168
#define DRIVER_PCI_DMA     0x8
168
#define DRIVER_PCI_DMA     0x8
169
#define DRIVER_SG          0x10
169
#define DRIVER_SG          0x10
170
#define DRIVER_HAVE_DMA    0x20
170
#define DRIVER_HAVE_DMA    0x20
171
#define DRIVER_HAVE_IRQ    0x40
171
#define DRIVER_HAVE_IRQ    0x40
172
#define DRIVER_IRQ_SHARED  0x80
172
#define DRIVER_IRQ_SHARED  0x80
173
#define DRIVER_GEM         0x1000
173
#define DRIVER_GEM         0x1000
174
#define DRIVER_MODESET     0x2000
174
#define DRIVER_MODESET     0x2000
175
#define DRIVER_PRIME       0x4000
175
#define DRIVER_PRIME       0x4000
176
#define DRIVER_RENDER      0x8000
176
#define DRIVER_RENDER      0x8000
177
 
177
 
178
#define DRIVER_BUS_PCI 0x1
178
#define DRIVER_BUS_PCI 0x1
179
#define DRIVER_BUS_PLATFORM 0x2
179
#define DRIVER_BUS_PLATFORM 0x2
180
#define DRIVER_BUS_USB 0x3
180
#define DRIVER_BUS_USB 0x3
181
#define DRIVER_BUS_HOST1X 0x4
181
#define DRIVER_BUS_HOST1X 0x4
182
 
182
 
183
/***********************************************************************/
183
/***********************************************************************/
184
/** \name Begin the DRM... */
184
/** \name Begin the DRM... */
185
/*@{*/
185
/*@{*/
186
 
186
 
187
#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then
187
#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then
188
				     also include looping detection. */
188
				     also include looping detection. */
189
 
189
 
190
#define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
190
#define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
191
 
191
 
192
#define DRM_MAP_HASH_OFFSET 0x10000000
192
#define DRM_MAP_HASH_OFFSET 0x10000000
193
 
193
 
194
/*@}*/
194
/*@}*/
195
 
195
 
196
/***********************************************************************/
196
/***********************************************************************/
197
/** \name Macros to make printk easier */
197
/** \name Macros to make printk easier */
198
/*@{*/
198
/*@{*/
199
 
199
 
200
/**
200
/**
201
 * Error output.
201
 * Error output.
202
 *
202
 *
203
 * \param fmt printf() like format string.
203
 * \param fmt printf() like format string.
204
 * \param arg arguments
204
 * \param arg arguments
205
 */
205
 */
206
#define DRM_ERROR(fmt, ...)				\
206
#define DRM_ERROR(fmt, ...)				\
207
	drm_err(__func__, fmt, ##__VA_ARGS__)
207
	drm_err(__func__, fmt, ##__VA_ARGS__)
208
 
208
 
209
/**
209
/**
210
 * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
210
 * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
211
 *
211
 *
212
 * \param fmt printf() like format string.
212
 * \param fmt printf() like format string.
213
 * \param arg arguments
213
 * \param arg arguments
214
 */
214
 */
215
#define DRM_ERROR_RATELIMITED(fmt, ...)				\
215
#define DRM_ERROR_RATELIMITED(fmt, ...)				\
216
({									\
216
({									\
217
	static DEFINE_RATELIMIT_STATE(_rs,				\
217
	static DEFINE_RATELIMIT_STATE(_rs,				\
218
				      DEFAULT_RATELIMIT_INTERVAL,	\
218
				      DEFAULT_RATELIMIT_INTERVAL,	\
219
				      DEFAULT_RATELIMIT_BURST);		\
219
				      DEFAULT_RATELIMIT_BURST);		\
220
									\
220
									\
221
	if (__ratelimit(&_rs))						\
221
	if (__ratelimit(&_rs))						\
222
		drm_err(__func__, fmt, ##__VA_ARGS__);			\
222
		drm_err(__func__, fmt, ##__VA_ARGS__);			\
223
})
223
})
224
 
224
 
225
#define DRM_INFO(fmt, ...)				\
225
#define DRM_INFO(fmt, ...)				\
226
	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
226
	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
227
 
227
 
228
#define DRM_INFO_ONCE(fmt, ...)				\
228
#define DRM_INFO_ONCE(fmt, ...)				\
229
	printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
229
	printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
230
 
230
 
231
/**
231
/**
232
 * Debug output.
232
 * Debug output.
233
 *
233
 *
234
 * \param fmt printf() like format string.
234
 * \param fmt printf() like format string.
235
 * \param arg arguments
235
 * \param arg arguments
236
 */
236
 */
237
#if DRM_DEBUG_CODE
237
#if DRM_DEBUG_CODE
238
#define DRM_DEBUG(fmt, args...)						\
238
#define DRM_DEBUG(fmt, args...)						\
239
    do {                                                    \
239
    do {                                                    \
240
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
240
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
241
	} while (0)
241
	} while (0)
242
 
242
 
243
#define DRM_DEBUG_DRIVER(fmt, args...)					\
243
#define DRM_DEBUG_DRIVER(fmt, args...)					\
244
    do {                                                    \
244
    do {                                                    \
245
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
245
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
246
	} while (0)
246
	} while (0)
247
#define DRM_DEBUG_KMS(fmt, args...)					\
247
#define DRM_DEBUG_KMS(fmt, args...)					\
248
	do {								\
248
	do {								\
249
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
249
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
250
	} while (0)
250
	} while (0)
251
#define DRM_DEBUG_PRIME(fmt, args...)					\
251
#define DRM_DEBUG_PRIME(fmt, args...)					\
252
	do {								\
252
	do {								\
253
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
253
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args);  \
254
	} while (0)
254
	} while (0)
255
#else
255
#else
256
#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
256
#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
257
#define DRM_DEBUG_KMS(fmt, args...)	do { } while (0)
257
#define DRM_DEBUG_KMS(fmt, args...)	do { } while (0)
258
#define DRM_DEBUG_PRIME(fmt, args...)	do { } while (0)
258
#define DRM_DEBUG_PRIME(fmt, args...)	do { } while (0)
259
#define DRM_DEBUG(fmt, arg...)		 do { } while (0)
259
#define DRM_DEBUG(fmt, arg...)		 do { } while (0)
260
#endif
260
#endif
261
 
261
 
262
/*@}*/
262
/*@}*/
263
 
263
 
264
/***********************************************************************/
264
/***********************************************************************/
265
/** \name Internal types and structures */
265
/** \name Internal types and structures */
266
/*@{*/
266
/*@{*/
267
 
267
 
268
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
268
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
269
 
269
 
270
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
270
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
271
 
271
 
272
/**
272
/**
273
 * Test that the hardware lock is held by the caller, returning otherwise.
273
 * Test that the hardware lock is held by the caller, returning otherwise.
274
 *
274
 *
275
 * \param dev DRM device.
275
 * \param dev DRM device.
276
 * \param filp file pointer of the caller.
276
 * \param filp file pointer of the caller.
277
 */
277
 */
278
#define LOCK_TEST_WITH_RETURN( dev, _file_priv )				\
278
#define LOCK_TEST_WITH_RETURN( dev, _file_priv )				\
279
do {										\
279
do {										\
280
	if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) ||	\
280
	if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) ||	\
281
	    _file_priv->master->lock.file_priv != _file_priv)	{		\
281
	    _file_priv->master->lock.file_priv != _file_priv)	{		\
282
		DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
282
		DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
283
			   __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
283
			   __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
284
			   _file_priv->master->lock.file_priv, _file_priv);	\
284
			   _file_priv->master->lock.file_priv, _file_priv);	\
285
		return -EINVAL;							\
285
		return -EINVAL;							\
286
	}									\
286
	}									\
287
} while (0)
287
} while (0)
288
 
288
 
289
/**
289
/**
290
 * Ioctl function type.
290
 * Ioctl function type.
291
 *
291
 *
292
 * \param inode device inode.
292
 * \param inode device inode.
293
 * \param file_priv DRM file private pointer.
293
 * \param file_priv DRM file private pointer.
294
 * \param cmd command.
294
 * \param cmd command.
295
 * \param arg argument.
295
 * \param arg argument.
296
 */
296
 */
297
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
297
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
298
			struct drm_file *file_priv);
298
			struct drm_file *file_priv);
299
 
299
 
300
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
300
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
301
			       unsigned long arg);
301
			       unsigned long arg);
302
 
302
 
303
#define DRM_IOCTL_NR(n)                _IOC_NR(n)
303
#define DRM_IOCTL_NR(n)                _IOC_NR(n)
304
#define DRM_MAJOR       226
304
#define DRM_MAJOR       226
305
 
305
 
306
#define DRM_AUTH	0x1
306
#define DRM_AUTH	0x1
307
#define	DRM_MASTER	0x2
307
#define	DRM_MASTER	0x2
308
#define DRM_ROOT_ONLY	0x4
308
#define DRM_ROOT_ONLY	0x4
309
#define DRM_CONTROL_ALLOW 0x8
309
#define DRM_CONTROL_ALLOW 0x8
310
#define DRM_UNLOCKED	0x10
310
#define DRM_UNLOCKED	0x10
311
#define DRM_RENDER_ALLOW 0x20
311
#define DRM_RENDER_ALLOW 0x20
312
 
312
 
313
struct drm_ioctl_desc {
313
struct drm_ioctl_desc {
314
	unsigned int cmd;
314
	unsigned int cmd;
315
	int flags;
315
	int flags;
316
	drm_ioctl_t *func;
316
	drm_ioctl_t *func;
317
	unsigned int cmd_drv;
317
	unsigned int cmd_drv;
318
	const char *name;
318
	const char *name;
319
};
319
};
320
 
320
 
321
/**
321
/**
322
 * Creates a driver or general drm_ioctl_desc array entry for the given
322
 * Creates a driver or general drm_ioctl_desc array entry for the given
323
 * ioctl, for use by drm_ioctl().
323
 * ioctl, for use by drm_ioctl().
324
 */
324
 */
325
 
325
 
326
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)			\
326
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)			\
327
	[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
327
	[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
328
 
328
 
329
#if 0
329
#if 0
330
struct drm_magic_entry {
330
struct drm_magic_entry {
331
	struct list_head head;
331
	struct list_head head;
332
	struct drm_hash_item hash_item;
332
	struct drm_hash_item hash_item;
333
	struct drm_file *priv;
333
	struct drm_file *priv;
334
};
334
};
335
 
335
 
336
struct drm_vma_entry {
336
struct drm_vma_entry {
337
	struct list_head head;
337
	struct list_head head;
338
	struct vm_area_struct *vma;
338
	struct vm_area_struct *vma;
339
	pid_t pid;
339
	pid_t pid;
340
};
340
};
341
 
341
 
342
/**
342
/**
343
 * DMA buffer.
343
 * DMA buffer.
344
 */
344
 */
345
struct drm_buf {
345
struct drm_buf {
346
	int idx;		       /**< Index into master buflist */
346
	int idx;		       /**< Index into master buflist */
347
	int total;		       /**< Buffer size */
347
	int total;		       /**< Buffer size */
348
	int order;		       /**< log-base-2(total) */
348
	int order;		       /**< log-base-2(total) */
349
	int used;		       /**< Amount of buffer in use (for DMA) */
349
	int used;		       /**< Amount of buffer in use (for DMA) */
350
	unsigned long offset;	       /**< Byte offset (used internally) */
350
	unsigned long offset;	       /**< Byte offset (used internally) */
351
	void *address;		       /**< Address of buffer */
351
	void *address;		       /**< Address of buffer */
352
	unsigned long bus_address;     /**< Bus address of buffer */
352
	unsigned long bus_address;     /**< Bus address of buffer */
353
	struct drm_buf *next;	       /**< Kernel-only: used for free list */
353
	struct drm_buf *next;	       /**< Kernel-only: used for free list */
354
	__volatile__ int waiting;      /**< On kernel DMA queue */
354
	__volatile__ int waiting;      /**< On kernel DMA queue */
355
	__volatile__ int pending;      /**< On hardware DMA queue */
355
	__volatile__ int pending;      /**< On hardware DMA queue */
356
	struct drm_file *file_priv;    /**< Private of holding file descr */
356
	struct drm_file *file_priv;    /**< Private of holding file descr */
357
	int context;		       /**< Kernel queue for this buffer */
357
	int context;		       /**< Kernel queue for this buffer */
358
	int while_locked;	       /**< Dispatch this buffer while locked */
358
	int while_locked;	       /**< Dispatch this buffer while locked */
359
	enum {
359
	enum {
360
		DRM_LIST_NONE = 0,
360
		DRM_LIST_NONE = 0,
361
		DRM_LIST_FREE = 1,
361
		DRM_LIST_FREE = 1,
362
		DRM_LIST_WAIT = 2,
362
		DRM_LIST_WAIT = 2,
363
		DRM_LIST_PEND = 3,
363
		DRM_LIST_PEND = 3,
364
		DRM_LIST_PRIO = 4,
364
		DRM_LIST_PRIO = 4,
365
		DRM_LIST_RECLAIM = 5
365
		DRM_LIST_RECLAIM = 5
366
	} list;			       /**< Which list we're on */
366
	} list;			       /**< Which list we're on */
367
 
367
 
368
	int dev_priv_size;		 /**< Size of buffer private storage */
368
	int dev_priv_size;		 /**< Size of buffer private storage */
369
	void *dev_private;		 /**< Per-buffer private storage */
369
	void *dev_private;		 /**< Per-buffer private storage */
370
};
370
};
371
 
371
 
372
/** bufs is one longer than it has to be */
372
/** bufs is one longer than it has to be */
373
struct drm_waitlist {
373
struct drm_waitlist {
374
	int count;			/**< Number of possible buffers */
374
	int count;			/**< Number of possible buffers */
375
	struct drm_buf **bufs;		/**< List of pointers to buffers */
375
	struct drm_buf **bufs;		/**< List of pointers to buffers */
376
	struct drm_buf **rp;			/**< Read pointer */
376
	struct drm_buf **rp;			/**< Read pointer */
377
	struct drm_buf **wp;			/**< Write pointer */
377
	struct drm_buf **wp;			/**< Write pointer */
378
	struct drm_buf **end;		/**< End pointer */
378
	struct drm_buf **end;		/**< End pointer */
379
	spinlock_t read_lock;
379
	spinlock_t read_lock;
380
	spinlock_t write_lock;
380
	spinlock_t write_lock;
381
};
381
};
382
#endif
382
#endif
383
 
383
 
384
 
384
 
385
typedef struct drm_dma_handle {
385
typedef struct drm_dma_handle {
386
	dma_addr_t busaddr;
386
	dma_addr_t busaddr;
387
	void *vaddr;
387
	void *vaddr;
388
	size_t size;
388
	size_t size;
389
} drm_dma_handle_t;
389
} drm_dma_handle_t;
390
 
390
 
391
/**
391
/**
392
 * Buffer entry.  There is one of this for each buffer size order.
392
 * Buffer entry.  There is one of this for each buffer size order.
393
 */
393
 */
394
struct drm_buf_entry {
394
struct drm_buf_entry {
395
	int buf_size;			/**< size */
395
	int buf_size;			/**< size */
396
	int buf_count;			/**< number of buffers */
396
	int buf_count;			/**< number of buffers */
397
	struct drm_buf *buflist;		/**< buffer list */
397
	struct drm_buf *buflist;		/**< buffer list */
398
	int seg_count;
398
	int seg_count;
399
	int page_order;
399
	int page_order;
400
	struct drm_dma_handle **seglist;
400
	struct drm_dma_handle **seglist;
401
 
401
 
402
	int low_mark;			/**< Low water mark */
402
	int low_mark;			/**< Low water mark */
403
	int high_mark;			/**< High water mark */
403
	int high_mark;			/**< High water mark */
404
};
404
};
405
 
405
 
406
/* Event queued up for userspace to read */
406
/* Event queued up for userspace to read */
407
struct drm_pending_event {
407
struct drm_pending_event {
408
	struct drm_event *event;
408
	struct drm_event *event;
409
	struct list_head link;
409
	struct list_head link;
410
	struct drm_file *file_priv;
410
	struct drm_file *file_priv;
411
	pid_t pid; /* pid of requester, no guarantee it's valid by the time
411
	pid_t pid; /* pid of requester, no guarantee it's valid by the time
412
		      we deliver the event, for tracing only */
412
		      we deliver the event, for tracing only */
413
	void (*destroy)(struct drm_pending_event *event);
413
	void (*destroy)(struct drm_pending_event *event);
414
};
414
};
415
 
415
 
416
/* initial implementaton using a linked list - todo hashtab */
416
/* initial implementaton using a linked list - todo hashtab */
417
struct drm_prime_file_private {
417
struct drm_prime_file_private {
418
	struct list_head head;
418
	struct list_head head;
419
	struct mutex lock;
419
	struct mutex lock;
420
};
420
};
421
 
421
 
422
/** File private data */
422
/** File private data */
423
struct drm_file {
423
struct drm_file {
424
	unsigned authenticated :1;
424
	unsigned authenticated :1;
425
	/* Whether we're master for a minor. Protected by master_mutex */
425
	/* Whether we're master for a minor. Protected by master_mutex */
426
	unsigned is_master :1;
426
	unsigned is_master :1;
427
	/* true when the client has asked us to expose stereo 3D mode flags */
427
	/* true when the client has asked us to expose stereo 3D mode flags */
428
	unsigned stereo_allowed :1;
428
	unsigned stereo_allowed :1;
429
	/*
429
	/*
430
	 * true if client understands CRTC primary planes and cursor planes
430
	 * true if client understands CRTC primary planes and cursor planes
431
	 * in the plane list
431
	 * in the plane list
432
	 */
432
	 */
433
	unsigned universal_planes:1;
433
	unsigned universal_planes:1;
434
	struct list_head lhead;
434
	struct list_head lhead;
435
	unsigned long lock_count;
435
	unsigned long lock_count;
436
 
436
 
437
	/** Mapping of mm object handles to object pointers. */
437
	/** Mapping of mm object handles to object pointers. */
438
	struct idr object_idr;
438
	struct idr object_idr;
439
	/** Lock for synchronization of access to object_idr. */
439
	/** Lock for synchronization of access to object_idr. */
440
	spinlock_t table_lock;
440
	spinlock_t table_lock;
441
 
441
 
442
	void *driver_priv;
442
	void *driver_priv;
443
 
443
 
444
	struct drm_master *master; /* master this node is currently associated with
444
	struct drm_master *master; /* master this node is currently associated with
445
				      N.B. not always minor->master */
445
				      N.B. not always minor->master */
446
	/**
446
	/**
447
	 * fbs - List of framebuffers associated with this file.
447
	 * fbs - List of framebuffers associated with this file.
448
	 *
448
	 *
449
	 * Protected by fbs_lock. Note that the fbs list holds a reference on
449
	 * Protected by fbs_lock. Note that the fbs list holds a reference on
450
	 * the fb object to prevent it from untimely disappearing.
450
	 * the fb object to prevent it from untimely disappearing.
451
	 */
451
	 */
452
	struct list_head fbs;
452
	struct list_head fbs;
453
	struct mutex fbs_lock;
453
	struct mutex fbs_lock;
454
 
454
 
455
	wait_queue_head_t event_wait;
455
	wait_queue_head_t event_wait;
456
	struct list_head event_list;
456
	struct list_head event_list;
457
	int event_space;
457
	int event_space;
458
};
458
};
459
 
459
 
460
#if 0
460
#if 0
461
/**
461
/**
462
 * Lock data.
462
 * Lock data.
463
 */
463
 */
464
struct drm_lock_data {
464
struct drm_lock_data {
465
	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
465
	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
466
	/** Private of lock holder's file (NULL=kernel) */
466
	/** Private of lock holder's file (NULL=kernel) */
467
	struct drm_file *file_priv;
467
	struct drm_file *file_priv;
468
	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
468
	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
469
	unsigned long lock_time;	/**< Time of last lock in jiffies */
469
	unsigned long lock_time;	/**< Time of last lock in jiffies */
470
	spinlock_t spinlock;
470
	spinlock_t spinlock;
471
	uint32_t kernel_waiters;
471
	uint32_t kernel_waiters;
472
	uint32_t user_waiters;
472
	uint32_t user_waiters;
473
	int idle_has_lock;
473
	int idle_has_lock;
474
};
474
};
475
 
475
 
476
/**
476
/**
477
 * DMA data.
477
 * DMA data.
478
 */
478
 */
479
struct drm_device_dma {
479
struct drm_device_dma {
480
 
480
 
481
	struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];	/**< buffers, grouped by their size order */
481
	struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];	/**< buffers, grouped by their size order */
482
	int buf_count;			/**< total number of buffers */
482
	int buf_count;			/**< total number of buffers */
483
	struct drm_buf **buflist;		/**< Vector of pointers into drm_device_dma::bufs */
483
	struct drm_buf **buflist;		/**< Vector of pointers into drm_device_dma::bufs */
484
	int seg_count;
484
	int seg_count;
485
	int page_count;			/**< number of pages */
485
	int page_count;			/**< number of pages */
486
	unsigned long *pagelist;	/**< page list */
486
	unsigned long *pagelist;	/**< page list */
487
	unsigned long byte_count;
487
	unsigned long byte_count;
488
	enum {
488
	enum {
489
		_DRM_DMA_USE_AGP = 0x01,
489
		_DRM_DMA_USE_AGP = 0x01,
490
		_DRM_DMA_USE_SG = 0x02,
490
		_DRM_DMA_USE_SG = 0x02,
491
		_DRM_DMA_USE_FB = 0x04,
491
		_DRM_DMA_USE_FB = 0x04,
492
		_DRM_DMA_USE_PCI_RO = 0x08
492
		_DRM_DMA_USE_PCI_RO = 0x08
493
	} flags;
493
	} flags;
494
 
494
 
495
};
495
};
496
 
496
 
497
/**
497
/**
498
 * AGP memory entry.  Stored as a doubly linked list.
498
 * AGP memory entry.  Stored as a doubly linked list.
499
 */
499
 */
500
struct drm_agp_mem {
500
struct drm_agp_mem {
501
	unsigned long handle;		/**< handle */
501
	unsigned long handle;		/**< handle */
502
	struct agp_memory *memory;
502
	struct agp_memory *memory;
503
	unsigned long bound;		/**< address */
503
	unsigned long bound;		/**< address */
504
	int pages;
504
	int pages;
505
	struct list_head head;
505
	struct list_head head;
506
};
506
};
507
 
507
 
508
/**
508
/**
509
 * AGP data.
509
 * AGP data.
510
 *
510
 *
511
 * \sa drm_agp_init() and drm_device::agp.
511
 * \sa drm_agp_init() and drm_device::agp.
512
 */
512
 */
513
struct drm_agp_head {
513
struct drm_agp_head {
514
	struct agp_kern_info agp_info;		/**< AGP device information */
514
	struct agp_kern_info agp_info;		/**< AGP device information */
515
	struct list_head memory;
515
	struct list_head memory;
516
	unsigned long mode;		/**< AGP mode */
516
	unsigned long mode;		/**< AGP mode */
517
	struct agp_bridge_data *bridge;
517
	struct agp_bridge_data *bridge;
518
	int enabled;			/**< whether the AGP bus as been enabled */
518
	int enabled;			/**< whether the AGP bus as been enabled */
519
	int acquired;			/**< whether the AGP device has been acquired */
519
	int acquired;			/**< whether the AGP device has been acquired */
520
	unsigned long base;
520
	unsigned long base;
521
	int agp_mtrr;
521
	int agp_mtrr;
522
	int cant_use_aperture;
522
	int cant_use_aperture;
523
	unsigned long page_mask;
523
	unsigned long page_mask;
524
};
524
};
525
 
525
 
526
/**
526
/**
527
 * Scatter-gather memory.
527
 * Scatter-gather memory.
528
 */
528
 */
529
struct drm_sg_mem {
529
struct drm_sg_mem {
530
	unsigned long handle;
530
	unsigned long handle;
531
	void *virtual;
531
	void *virtual;
532
	int pages;
532
	int pages;
533
	struct page **pagelist;
533
	struct page **pagelist;
534
	dma_addr_t *busaddr;
534
	dma_addr_t *busaddr;
535
};
535
};
536
 
536
 
537
struct drm_sigdata {
537
struct drm_sigdata {
538
	int context;
538
	int context;
539
	struct drm_hw_lock *lock;
539
	struct drm_hw_lock *lock;
540
};
540
};
541
 
541
 
542
#endif
542
#endif
543
 
543
 
544
/**
544
/**
545
 * Kernel side of a mapping
545
 * Kernel side of a mapping
546
 */
546
 */
547
struct drm_local_map {
547
struct drm_local_map {
548
	resource_size_t offset;	 /**< Requested physical address (0 for SAREA)*/
548
	resource_size_t offset;	 /**< Requested physical address (0 for SAREA)*/
549
	unsigned long size;	 /**< Requested physical size (bytes) */
549
	unsigned long size;	 /**< Requested physical size (bytes) */
550
	enum drm_map_type type;	 /**< Type of memory to map */
550
	enum drm_map_type type;	 /**< Type of memory to map */
551
	enum drm_map_flags flags;	 /**< Flags */
551
	enum drm_map_flags flags;	 /**< Flags */
552
	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
552
	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
553
				 /**< Kernel-space: kernel-virtual address */
553
				 /**< Kernel-space: kernel-virtual address */
554
	int mtrr;		 /**< MTRR slot used */
554
	int mtrr;		 /**< MTRR slot used */
555
};
555
};
556
 
556
 
557
typedef struct drm_local_map drm_local_map_t;
557
typedef struct drm_local_map drm_local_map_t;
558
 
558
 
559
/**
559
/**
560
 * Mappings list
560
 * Mappings list
561
 */
561
 */
562
struct drm_map_list {
562
struct drm_map_list {
563
	struct list_head head;		/**< list head */
563
	struct list_head head;		/**< list head */
564
	struct drm_hash_item hash;
564
	struct drm_hash_item hash;
565
	struct drm_local_map *map;	/**< mapping */
565
	struct drm_local_map *map;	/**< mapping */
566
	uint64_t user_token;
566
	uint64_t user_token;
567
	struct drm_master *master;
567
	struct drm_master *master;
568
};
568
};
569
 
569
 
570
/* location of GART table */
570
/* location of GART table */
571
#define DRM_ATI_GART_MAIN 1
571
#define DRM_ATI_GART_MAIN 1
572
#define DRM_ATI_GART_FB   2
572
#define DRM_ATI_GART_FB   2
573
 
573
 
574
#define DRM_ATI_GART_PCI 1
574
#define DRM_ATI_GART_PCI 1
575
#define DRM_ATI_GART_PCIE 2
575
#define DRM_ATI_GART_PCIE 2
576
#define DRM_ATI_GART_IGP 3
576
#define DRM_ATI_GART_IGP 3
577
 
577
 
578
struct drm_ati_pcigart_info {
578
struct drm_ati_pcigart_info {
579
	int gart_table_location;
579
	int gart_table_location;
580
	int gart_reg_if;
580
	int gart_reg_if;
581
	void *addr;
581
	void *addr;
582
	dma_addr_t bus_addr;
582
	dma_addr_t bus_addr;
583
	dma_addr_t table_mask;
583
	dma_addr_t table_mask;
584
	struct drm_dma_handle *table_handle;
584
	struct drm_dma_handle *table_handle;
585
	struct drm_local_map mapping;
585
	struct drm_local_map mapping;
586
	int table_size;
586
	int table_size;
587
};
587
};
588
 
588
 
589
/**
589
/**
590
 * This structure defines the drm_mm memory object, which will be used by the
590
 * This structure defines the drm_mm memory object, which will be used by the
591
 * DRM for its buffer objects.
591
 * DRM for its buffer objects.
592
 */
592
 */
593
struct drm_gem_object {
593
struct drm_gem_object {
594
	/** Reference count of this object */
594
	/** Reference count of this object */
595
	struct kref refcount;
595
	struct kref refcount;
596
 
596
 
597
	/**
597
	/**
598
	 * handle_count - gem file_priv handle count of this object
598
	 * handle_count - gem file_priv handle count of this object
599
	 *
599
	 *
600
	 * Each handle also holds a reference. Note that when the handle_count
600
	 * Each handle also holds a reference. Note that when the handle_count
601
	 * drops to 0 any global names (e.g. the id in the flink namespace) will
601
	 * drops to 0 any global names (e.g. the id in the flink namespace) will
602
	 * be cleared.
602
	 * be cleared.
603
	 *
603
	 *
604
	 * Protected by dev->object_name_lock.
604
	 * Protected by dev->object_name_lock.
605
	 * */
605
	 * */
606
	unsigned handle_count;
606
	unsigned handle_count;
607
 
607
 
608
	/** Related drm device */
608
	/** Related drm device */
609
	struct drm_device *dev;
609
	struct drm_device *dev;
610
 
610
 
611
	/** File representing the shmem storage */
611
	/** File representing the shmem storage */
612
	struct file *filp;
612
	struct file *filp;
613
 
613
 
614
	/* Mapping info for this object */
614
	/* Mapping info for this object */
615
	struct drm_vma_offset_node vma_node;
615
	struct drm_vma_offset_node vma_node;
616
 
616
 
617
	/**
617
	/**
618
	 * Size of the object, in bytes.  Immutable over the object's
618
	 * Size of the object, in bytes.  Immutable over the object's
619
	 * lifetime.
619
	 * lifetime.
620
	 */
620
	 */
621
	size_t size;
621
	size_t size;
622
 
622
 
623
	/**
623
	/**
624
	 * Global name for this object, starts at 1. 0 means unnamed.
624
	 * Global name for this object, starts at 1. 0 means unnamed.
625
	 * Access is covered by the object_name_lock in the related drm_device
625
	 * Access is covered by the object_name_lock in the related drm_device
626
	 */
626
	 */
627
	int name;
627
	int name;
628
 
628
 
629
	/**
629
	/**
630
	 * Memory domains. These monitor which caches contain read/write data
630
	 * Memory domains. These monitor which caches contain read/write data
631
	 * related to the object. When transitioning from one set of domains
631
	 * related to the object. When transitioning from one set of domains
632
	 * to another, the driver is called to ensure that caches are suitably
632
	 * to another, the driver is called to ensure that caches are suitably
633
	 * flushed and invalidated
633
	 * flushed and invalidated
634
	 */
634
	 */
635
	uint32_t read_domains;
635
	uint32_t read_domains;
636
	uint32_t write_domain;
636
	uint32_t write_domain;
637
 
637
 
638
	/**
638
	/**
639
	 * While validating an exec operation, the
639
	 * While validating an exec operation, the
640
	 * new read/write domain values are computed here.
640
	 * new read/write domain values are computed here.
641
	 * They will be transferred to the above values
641
	 * They will be transferred to the above values
642
	 * at the point that any cache flushing occurs
642
	 * at the point that any cache flushing occurs
643
	 */
643
	 */
644
	uint32_t pending_read_domains;
644
	uint32_t pending_read_domains;
645
	uint32_t pending_write_domain;
645
	uint32_t pending_write_domain;
646
 
646
 
647
	/**
647
	/**
648
	 * dma_buf - dma buf associated with this GEM object
648
	 * dma_buf - dma buf associated with this GEM object
649
	 *
649
	 *
650
	 * Pointer to the dma-buf associated with this gem object (either
650
	 * Pointer to the dma-buf associated with this gem object (either
651
	 * through importing or exporting). We break the resulting reference
651
	 * through importing or exporting). We break the resulting reference
652
	 * loop when the last gem handle for this object is released.
652
	 * loop when the last gem handle for this object is released.
653
	 *
653
	 *
654
	 * Protected by obj->object_name_lock
654
	 * Protected by obj->object_name_lock
655
	 */
655
	 */
656
	struct dma_buf *dma_buf;
656
	struct dma_buf *dma_buf;
657
 
657
 
658
};
658
};
659
 
659
 
660
#include 
660
#include 
661
 
661
 
662
/**
662
/**
663
 * struct drm_master - drm master structure
663
 * struct drm_master - drm master structure
664
 *
664
 *
665
 * @refcount: Refcount for this master object.
665
 * @refcount: Refcount for this master object.
666
 * @minor: Link back to minor char device we are master for. Immutable.
666
 * @minor: Link back to minor char device we are master for. Immutable.
667
 * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
667
 * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
668
 * @unique_len: Length of unique field. Protected by drm_global_mutex.
668
 * @unique_len: Length of unique field. Protected by drm_global_mutex.
669
 * @unique_size: Amount allocated. Protected by drm_global_mutex.
669
 * @unique_size: Amount allocated. Protected by drm_global_mutex.
670
 * @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
670
 * @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
671
 * @magicfree: List of used authentication tokens. Protected by struct_mutex.
671
 * @magicfree: List of used authentication tokens. Protected by struct_mutex.
672
 * @lock: DRI lock information.
672
 * @lock: DRI lock information.
673
 * @driver_priv: Pointer to driver-private information.
673
 * @driver_priv: Pointer to driver-private information.
674
 */
674
 */
675
struct drm_master {
675
struct drm_master {
676
	struct kref refcount;
676
	struct kref refcount;
677
	struct drm_minor *minor;
677
	struct drm_minor *minor;
678
	char *unique;
678
	char *unique;
679
	int unique_len;
679
	int unique_len;
680
	int unique_size;
680
	int unique_size;
681
//	struct drm_open_hash magiclist;
681
//	struct drm_open_hash magiclist;
682
//	struct list_head magicfree;
682
//	struct list_head magicfree;
683
//	struct drm_lock_data lock;
683
//	struct drm_lock_data lock;
684
	void *driver_priv;
684
	void *driver_priv;
685
};
685
};
686
 
686
 
687
/* Size of ringbuffer for vblank timestamps. Just double-buffer
687
/* Size of ringbuffer for vblank timestamps. Just double-buffer
688
 * in initial implementation.
688
 * in initial implementation.
689
 */
689
 */
690
#define DRM_VBLANKTIME_RBSIZE 2
690
#define DRM_VBLANKTIME_RBSIZE 2
691
 
691
 
692
/* Flags and return codes for get_vblank_timestamp() driver function. */
692
/* Flags and return codes for get_vblank_timestamp() driver function. */
693
#define DRM_CALLED_FROM_VBLIRQ 1
693
#define DRM_CALLED_FROM_VBLIRQ 1
694
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
694
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
695
#define DRM_VBLANKTIME_INVBL             (1 << 1)
695
#define DRM_VBLANKTIME_INVBL             (1 << 1)
696
 
696
 
697
/* get_scanout_position() return flags */
697
/* get_scanout_position() return flags */
698
#define DRM_SCANOUTPOS_VALID        (1 << 0)
698
#define DRM_SCANOUTPOS_VALID        (1 << 0)
699
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
699
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
700
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
700
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
701
 
701
 
702
struct drm_bus {
702
struct drm_bus {
703
	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
703
	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
704
};
704
};
705
 
705
 
706
/**
706
/**
707
 * DRM driver structure. This structure represent the common code for
707
 * DRM driver structure. This structure represent the common code for
708
 * a family of cards. There will one drm_device for each card present
708
 * a family of cards. There will one drm_device for each card present
709
 * in this family
709
 * in this family
710
 */
710
 */
711
struct drm_driver {
711
struct drm_driver {
712
	int (*load) (struct drm_device *, unsigned long flags);
712
	int (*load) (struct drm_device *, unsigned long flags);
713
	int (*open) (struct drm_device *, struct drm_file *);
713
	int (*open) (struct drm_device *, struct drm_file *);
714
 
714
 
715
	/**
715
	/**
716
	 * get_vblank_counter - get raw hardware vblank counter
716
	 * get_vblank_counter - get raw hardware vblank counter
717
	 * @dev: DRM device
717
	 * @dev: DRM device
718
	 * @crtc: counter to fetch
718
	 * @crtc: counter to fetch
719
	 *
719
	 *
720
	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
720
	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
721
	 * If a device doesn't have a hardware counter, the driver can simply
721
	 * If a device doesn't have a hardware counter, the driver can simply
722
	 * return the value of drm_vblank_count. The DRM core will account for
722
	 * return the value of drm_vblank_count. The DRM core will account for
723
	 * missed vblank events while interrupts where disabled based on system
723
	 * missed vblank events while interrupts where disabled based on system
724
	 * timestamps.
724
	 * timestamps.
725
	 *
725
	 *
726
	 * Wraparound handling and loss of events due to modesetting is dealt
726
	 * Wraparound handling and loss of events due to modesetting is dealt
727
	 * with in the DRM core code.
727
	 * with in the DRM core code.
728
	 *
728
	 *
729
	 * RETURNS
729
	 * RETURNS
730
	 * Raw vblank counter value.
730
	 * Raw vblank counter value.
731
	 */
731
	 */
732
	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
732
	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
733
 
733
 
734
	/**
734
	/**
735
	 * enable_vblank - enable vblank interrupt events
735
	 * enable_vblank - enable vblank interrupt events
736
	 * @dev: DRM device
736
	 * @dev: DRM device
737
	 * @crtc: which irq to enable
737
	 * @crtc: which irq to enable
738
	 *
738
	 *
739
	 * Enable vblank interrupts for @crtc.  If the device doesn't have
739
	 * Enable vblank interrupts for @crtc.  If the device doesn't have
740
	 * a hardware vblank counter, this routine should be a no-op, since
740
	 * a hardware vblank counter, this routine should be a no-op, since
741
	 * interrupts will have to stay on to keep the count accurate.
741
	 * interrupts will have to stay on to keep the count accurate.
742
	 *
742
	 *
743
	 * RETURNS
743
	 * RETURNS
744
	 * Zero on success, appropriate errno if the given @crtc's vblank
744
	 * Zero on success, appropriate errno if the given @crtc's vblank
745
	 * interrupt cannot be enabled.
745
	 * interrupt cannot be enabled.
746
	 */
746
	 */
747
	int (*enable_vblank) (struct drm_device *dev, int crtc);
747
	int (*enable_vblank) (struct drm_device *dev, int crtc);
748
 
748
 
749
	/**
749
	/**
750
	 * disable_vblank - disable vblank interrupt events
750
	 * disable_vblank - disable vblank interrupt events
751
	 * @dev: DRM device
751
	 * @dev: DRM device
752
	 * @crtc: which irq to enable
752
	 * @crtc: which irq to enable
753
	 *
753
	 *
754
	 * Disable vblank interrupts for @crtc.  If the device doesn't have
754
	 * Disable vblank interrupts for @crtc.  If the device doesn't have
755
	 * a hardware vblank counter, this routine should be a no-op, since
755
	 * a hardware vblank counter, this routine should be a no-op, since
756
	 * interrupts will have to stay on to keep the count accurate.
756
	 * interrupts will have to stay on to keep the count accurate.
757
	 */
757
	 */
758
	void (*disable_vblank) (struct drm_device *dev, int crtc);
758
	void (*disable_vblank) (struct drm_device *dev, int crtc);
759
	/**
759
	/**
760
	 * Called by vblank timestamping code.
760
	 * Called by vblank timestamping code.
761
	 *
761
	 *
762
	 * Return the current display scanout position from a crtc, and an
762
	 * Return the current display scanout position from a crtc, and an
763
	 * optional accurate ktime_get timestamp of when position was measured.
763
	 * optional accurate ktime_get timestamp of when position was measured.
764
	 *
764
	 *
765
	 * \param dev  DRM device.
765
	 * \param dev  DRM device.
766
	 * \param crtc Id of the crtc to query.
766
	 * \param crtc Id of the crtc to query.
767
	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
767
	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
768
	 * \param *vpos Target location for current vertical scanout position.
768
	 * \param *vpos Target location for current vertical scanout position.
769
	 * \param *hpos Target location for current horizontal scanout position.
769
	 * \param *hpos Target location for current horizontal scanout position.
770
	 * \param *stime Target location for timestamp taken immediately before
770
	 * \param *stime Target location for timestamp taken immediately before
771
	 *               scanout position query. Can be NULL to skip timestamp.
771
	 *               scanout position query. Can be NULL to skip timestamp.
772
	 * \param *etime Target location for timestamp taken immediately after
772
	 * \param *etime Target location for timestamp taken immediately after
773
	 *               scanout position query. Can be NULL to skip timestamp.
773
	 *               scanout position query. Can be NULL to skip timestamp.
774
	 *
774
	 *
775
	 * Returns vpos as a positive number while in active scanout area.
775
	 * Returns vpos as a positive number while in active scanout area.
776
	 * Returns vpos as a negative number inside vblank, counting the number
776
	 * Returns vpos as a negative number inside vblank, counting the number
777
	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
777
	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
778
	 * until start of active scanout / end of vblank."
778
	 * until start of active scanout / end of vblank."
779
	 *
779
	 *
780
	 * \return Flags, or'ed together as follows:
780
	 * \return Flags, or'ed together as follows:
781
	 *
781
	 *
782
	 * DRM_SCANOUTPOS_VALID = Query successful.
782
	 * DRM_SCANOUTPOS_VALID = Query successful.
783
	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
783
	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
784
	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
784
	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
785
	 * this flag means that returned position may be offset by a constant
785
	 * this flag means that returned position may be offset by a constant
786
	 * but unknown small number of scanlines wrt. real scanout position.
786
	 * but unknown small number of scanlines wrt. real scanout position.
787
	 *
787
	 *
788
	 */
788
	 */
789
	int (*get_scanout_position) (struct drm_device *dev, int crtc,
789
	int (*get_scanout_position) (struct drm_device *dev, int crtc,
790
				     unsigned int flags,
790
				     unsigned int flags,
791
                     int *vpos, int *hpos, void *stime,
791
                     int *vpos, int *hpos, void *stime,
792
                     void *etime);
792
                     void *etime);
793
 
793
 
794
	/**
794
	/**
795
	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
795
	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
796
	 * timestamp when the most recent VBLANK interval ended or will end.
796
	 * timestamp when the most recent VBLANK interval ended or will end.
797
	 *
797
	 *
798
	 * Specifically, the timestamp in @vblank_time should correspond as
798
	 * Specifically, the timestamp in @vblank_time should correspond as
799
	 * closely as possible to the time when the first video scanline of
799
	 * closely as possible to the time when the first video scanline of
800
	 * the video frame after the end of VBLANK will start scanning out,
800
	 * the video frame after the end of VBLANK will start scanning out,
801
	 * the time immediately after end of the VBLANK interval. If the
801
	 * the time immediately after end of the VBLANK interval. If the
802
	 * @crtc is currently inside VBLANK, this will be a time in the future.
802
	 * @crtc is currently inside VBLANK, this will be a time in the future.
803
	 * If the @crtc is currently scanning out a frame, this will be the
803
	 * If the @crtc is currently scanning out a frame, this will be the
804
	 * past start time of the current scanout. This is meant to adhere
804
	 * past start time of the current scanout. This is meant to adhere
805
	 * to the OpenML OML_sync_control extension specification.
805
	 * to the OpenML OML_sync_control extension specification.
806
	 *
806
	 *
807
	 * \param dev dev DRM device handle.
807
	 * \param dev dev DRM device handle.
808
	 * \param crtc crtc for which timestamp should be returned.
808
	 * \param crtc crtc for which timestamp should be returned.
809
	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
809
	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
810
	 *                   Implementation should strive to provide timestamp
810
	 *                   Implementation should strive to provide timestamp
811
	 *                   with an error of at most *max_error nanoseconds.
811
	 *                   with an error of at most *max_error nanoseconds.
812
	 *                   Returns true upper bound on error for timestamp.
812
	 *                   Returns true upper bound on error for timestamp.
813
	 * \param *vblank_time Target location for returned vblank timestamp.
813
	 * \param *vblank_time Target location for returned vblank timestamp.
814
	 * \param flags 0 = Defaults, no special treatment needed.
814
	 * \param flags 0 = Defaults, no special treatment needed.
815
	 * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
815
	 * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
816
	 *	        irq handler. Some drivers need to apply some workarounds
816
	 *	        irq handler. Some drivers need to apply some workarounds
817
	 *              for gpu-specific vblank irq quirks if flag is set.
817
	 *              for gpu-specific vblank irq quirks if flag is set.
818
	 *
818
	 *
819
	 * \returns
819
	 * \returns
820
	 * Zero if timestamping isn't supported in current display mode or a
820
	 * Zero if timestamping isn't supported in current display mode or a
821
	 * negative number on failure. A positive status code on success,
821
	 * negative number on failure. A positive status code on success,
822
	 * which describes how the vblank_time timestamp was computed.
822
	 * which describes how the vblank_time timestamp was computed.
823
	 */
823
	 */
824
	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
824
	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
825
				     int *max_error,
825
				     int *max_error,
826
				     struct timeval *vblank_time,
826
				     struct timeval *vblank_time,
827
				     unsigned flags);
827
				     unsigned flags);
828
 
828
 
829
	/* these have to be filled in */
829
	/* these have to be filled in */
830
 
830
 
831
	irqreturn_t(*irq_handler) (int irq, void *arg);
831
	irqreturn_t(*irq_handler) (int irq, void *arg);
832
	void (*irq_preinstall) (struct drm_device *dev);
832
	void (*irq_preinstall) (struct drm_device *dev);
833
	int (*irq_postinstall) (struct drm_device *dev);
833
	int (*irq_postinstall) (struct drm_device *dev);
834
	void (*irq_uninstall) (struct drm_device *dev);
834
	void (*irq_uninstall) (struct drm_device *dev);
835
 
835
 
836
	/**
836
	/**
837
	 * Driver-specific constructor for drm_gem_objects, to set up
837
	 * Driver-specific constructor for drm_gem_objects, to set up
838
	 * obj->driver_private.
838
	 * obj->driver_private.
839
	 *
839
	 *
840
	 * Returns 0 on success.
840
	 * Returns 0 on success.
841
	 */
841
	 */
842
	void (*gem_free_object) (struct drm_gem_object *obj);
842
	void (*gem_free_object) (struct drm_gem_object *obj);
843
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
843
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
844
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
844
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
845
	u32 driver_features;
845
	u32 driver_features;
846
	int dev_priv_size;
846
	int dev_priv_size;
847
};
847
};
848
 
848
 
849
enum drm_minor_type {
849
enum drm_minor_type {
850
	DRM_MINOR_LEGACY,
850
	DRM_MINOR_LEGACY,
851
	DRM_MINOR_CONTROL,
851
	DRM_MINOR_CONTROL,
852
	DRM_MINOR_RENDER,
852
	DRM_MINOR_RENDER,
853
	DRM_MINOR_CNT,
853
	DRM_MINOR_CNT,
854
};
854
};
855
 
855
 
856
/**
856
/**
857
 * Info file list entry. This structure represents a debugfs or proc file to
857
 * Info file list entry. This structure represents a debugfs or proc file to
858
 * be created by the drm core
858
 * be created by the drm core
859
 */
859
 */
860
struct drm_info_list {
860
struct drm_info_list {
861
	const char *name; /** file name */
861
	const char *name; /** file name */
862
//   int (*show)(struct seq_file*, void*); /** show callback */
862
//   int (*show)(struct seq_file*, void*); /** show callback */
863
	u32 driver_features; /**< Required driver features for this entry */
863
	u32 driver_features; /**< Required driver features for this entry */
864
	void *data;
864
	void *data;
865
};
865
};
866
 
866
 
867
/**
867
/**
868
 * debugfs node structure. This structure represents a debugfs file.
868
 * debugfs node structure. This structure represents a debugfs file.
869
 */
869
 */
870
struct drm_info_node {
870
struct drm_info_node {
871
	struct list_head list;
871
	struct list_head list;
872
	struct drm_minor *minor;
872
	struct drm_minor *minor;
873
	const struct drm_info_list *info_ent;
873
	const struct drm_info_list *info_ent;
874
	struct dentry *dent;
874
	struct dentry *dent;
875
};
875
};
876
 
876
 
877
/**
877
/**
878
 * DRM minor structure. This structure represents a drm minor number.
878
 * DRM minor structure. This structure represents a drm minor number.
879
 */
879
 */
880
struct drm_minor {
880
struct drm_minor {
881
	int index;			/**< Minor device number */
881
	int index;			/**< Minor device number */
882
	int type;                       /**< Control or render */
882
	int type;                       /**< Control or render */
883
//   struct device kdev;     /**< Linux device */
883
//   struct device kdev;     /**< Linux device */
884
	struct drm_device *dev;
884
	struct drm_device *dev;
885
 
885
 
886
	struct dentry *debugfs_root;
886
	struct dentry *debugfs_root;
887
 
887
 
888
	struct list_head debugfs_list;
888
	struct list_head debugfs_list;
889
	struct mutex debugfs_lock; /* Protects debugfs_list. */
889
	struct mutex debugfs_lock; /* Protects debugfs_list. */
890
 
890
 
891
	/* currently active master for this node. Protected by master_mutex */
891
	/* currently active master for this node. Protected by master_mutex */
892
	struct drm_master *master;
892
	struct drm_master *master;
893
	struct drm_mode_group mode_group;
893
	struct drm_mode_group mode_group;
894
};
894
};
895
 
895
 
896
 
896
 
897
 
897
 
898
/**
898
/**
899
 * DRM device structure. This structure represent a complete card that
899
 * DRM device structure. This structure represent a complete card that
900
 * may contain multiple heads.
900
 * may contain multiple heads.
901
 */
901
 */
902
struct drm_device {
902
struct drm_device {
903
	struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
903
	struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
904
	int if_version;			/**< Highest interface version set */
904
	int if_version;			/**< Highest interface version set */
905
 
905
 
906
	struct device *dev;		/**< Device structure of bus-device */
906
	struct device *dev;		/**< Device structure of bus-device */
907
	struct drm_driver *driver;	/**< DRM driver managing the device */
907
	struct drm_driver *driver;	/**< DRM driver managing the device */
908
	void *dev_private;		/**< DRM driver private data */
908
	void *dev_private;		/**< DRM driver private data */
909
	struct drm_minor *primary;		/**< Primary node */
909
	struct drm_minor *primary;		/**< Primary node */
910
	atomic_t unplugged;			/**< Flag whether dev is dead */
910
	atomic_t unplugged;			/**< Flag whether dev is dead */
911
	/** \name Locks */
911
	/** \name Locks */
912
	/*@{ */
912
	/*@{ */
913
	struct mutex struct_mutex;	/**< For others */
913
	struct mutex struct_mutex;	/**< For others */
914
	struct mutex master_mutex;      /**< For drm_minor::master and drm_file::is_master */
914
	struct mutex master_mutex;      /**< For drm_minor::master and drm_file::is_master */
915
	/*@} */
915
	/*@} */
916
 
916
 
917
	/** \name Usage Counters */
917
	/** \name Usage Counters */
918
	/*@{ */
918
	/*@{ */
919
	int open_count;			/**< Outstanding files open, protected by drm_global_mutex. */
919
	int open_count;			/**< Outstanding files open, protected by drm_global_mutex. */
920
	spinlock_t buf_lock;		/**< For drm_device::buf_use and a few other things. */
920
	spinlock_t buf_lock;		/**< For drm_device::buf_use and a few other things. */
921
	int buf_use;			/**< Buffers in use -- cannot alloc */
921
	int buf_use;			/**< Buffers in use -- cannot alloc */
922
   atomic_t buf_alloc;     /**< Buffer allocation in progress */
922
   atomic_t buf_alloc;     /**< Buffer allocation in progress */
923
	/*@} */
923
	/*@} */
924
 
924
 
925
	struct list_head filelist;
925
	struct list_head filelist;
926
 
926
 
927
	/** \name Memory management */
927
	/** \name Memory management */
928
	/*@{ */
928
	/*@{ */
929
	struct list_head maplist;	/**< Linked list of regions */
929
	struct list_head maplist;	/**< Linked list of regions */
930
 
930
 
931
	/** \name Context handle management */
931
	/** \name Context handle management */
932
	/*@{ */
932
	/*@{ */
933
	struct list_head ctxlist;	/**< Linked list of context handles */
933
	struct list_head ctxlist;	/**< Linked list of context handles */
934
	struct mutex ctxlist_mutex;	/**< For ctxlist */
934
	struct mutex ctxlist_mutex;	/**< For ctxlist */
935
 
935
 
936
	struct idr ctx_idr;
936
	struct idr ctx_idr;
937
 
937
 
938
	struct list_head vmalist;	/**< List of vmas (for debugging) */
938
	struct list_head vmalist;	/**< List of vmas (for debugging) */
939
 
939
 
940
	/*@} */
940
	/*@} */
941
 
941
 
942
	/** \name DMA support */
942
	/** \name DMA support */
943
	/*@{ */
943
	/*@{ */
944
//   struct drm_device_dma *dma;     /**< Optional pointer for DMA support */
944
//   struct drm_device_dma *dma;     /**< Optional pointer for DMA support */
945
	/*@} */
945
	/*@} */
946
 
946
 
947
	/** \name Context support */
947
	/** \name Context support */
948
	/*@{ */
948
	/*@{ */
949
	bool irq_enabled;		/**< True if irq handler is enabled */
949
	bool irq_enabled;		/**< True if irq handler is enabled */
950
	int irq;
950
	int irq;
951
 
951
 
952
	__volatile__ long context_flag;	/**< Context swapping flag */
952
	__volatile__ long context_flag;	/**< Context swapping flag */
953
	int last_context;		/**< Last current context */
953
	int last_context;		/**< Last current context */
954
	/*@} */
954
	/*@} */
955
 
955
 
956
	/** \name VBLANK IRQ support */
956
	/** \name VBLANK IRQ support */
957
	/*@{ */
957
	/*@{ */
958
 
958
 
959
	/*
959
	/*
960
	 * At load time, disabling the vblank interrupt won't be allowed since
960
	 * At load time, disabling the vblank interrupt won't be allowed since
961
	 * old clients may not call the modeset ioctl and therefore misbehave.
961
	 * old clients may not call the modeset ioctl and therefore misbehave.
962
	 * Once the modeset ioctl *has* been called though, we can safely
962
	 * Once the modeset ioctl *has* been called though, we can safely
963
	 * disable them when unused.
963
	 * disable them when unused.
964
	 */
964
	 */
965
	bool vblank_disable_allowed;
965
	bool vblank_disable_allowed;
966
 
966
 
967
	/* array of size num_crtcs */
967
	/* array of size num_crtcs */
968
	struct drm_vblank_crtc *vblank;
968
	struct drm_vblank_crtc *vblank;
969
 
969
 
970
	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
970
	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
971
	spinlock_t vbl_lock;
971
	spinlock_t vbl_lock;
972
 
972
 
973
	u32 max_vblank_count;           /**< size of vblank counter register */
973
	u32 max_vblank_count;           /**< size of vblank counter register */
974
 
974
 
975
	/**
975
	/**
976
	 * List of events
976
	 * List of events
977
	 */
977
	 */
978
	struct list_head vblank_event_list;
978
	struct list_head vblank_event_list;
979
	spinlock_t event_lock;
979
	spinlock_t event_lock;
980
 
980
 
981
	/*@} */
981
	/*@} */
982
 
982
 
983
//   struct drm_agp_head *agp;   /**< AGP data */
983
//   struct drm_agp_head *agp;   /**< AGP data */
984
 
984
 
985
	struct pci_dev *pdev;		/**< PCI device structure */
985
	struct pci_dev *pdev;		/**< PCI device structure */
986
 
986
 
987
	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
987
	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
988
 
988
 
989
 
989
 
990
        struct drm_mode_config mode_config;	/**< Current mode config */
990
        struct drm_mode_config mode_config;	/**< Current mode config */
991
 
991
 
992
	/** \name GEM information */
992
	/** \name GEM information */
993
	/*@{ */
993
	/*@{ */
994
	struct mutex object_name_lock;
994
	struct mutex object_name_lock;
995
	struct idr object_name_idr;
995
	struct idr object_name_idr;
996
	struct drm_vma_offset_manager *vma_offset_manager;
996
	struct drm_vma_offset_manager *vma_offset_manager;
997
	/*@} */
997
	/*@} */
998
	int switch_power_state;
998
	int switch_power_state;
999
};
999
};
1000
 
1000
 
1001
#define DRM_SWITCH_POWER_ON 0
1001
#define DRM_SWITCH_POWER_ON 0
1002
#define DRM_SWITCH_POWER_OFF 1
1002
#define DRM_SWITCH_POWER_OFF 1
1003
#define DRM_SWITCH_POWER_CHANGING 2
1003
#define DRM_SWITCH_POWER_CHANGING 2
1004
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
1004
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
1005
 
1005
 
1006
static __inline__ int drm_core_check_feature(struct drm_device *dev,
1006
static __inline__ int drm_core_check_feature(struct drm_device *dev,
1007
					     int feature)
1007
					     int feature)
1008
{
1008
{
1009
	return ((dev->driver->driver_features & feature) ? 1 : 0);
1009
	return ((dev->driver->driver_features & feature) ? 1 : 0);
1010
}
1010
}
1011
 
1011
 
1012
static inline void drm_device_set_unplugged(struct drm_device *dev)
1012
static inline void drm_device_set_unplugged(struct drm_device *dev)
1013
{
1013
{
1014
	smp_wmb();
1014
	smp_wmb();
1015
	atomic_set(&dev->unplugged, 1);
1015
	atomic_set(&dev->unplugged, 1);
1016
}
1016
}
1017
 
1017
 
1018
static inline int drm_device_is_unplugged(struct drm_device *dev)
1018
static inline int drm_device_is_unplugged(struct drm_device *dev)
1019
{
1019
{
1020
	int ret = atomic_read(&dev->unplugged);
1020
	int ret = atomic_read(&dev->unplugged);
1021
	smp_rmb();
1021
	smp_rmb();
1022
	return ret;
1022
	return ret;
1023
}
1023
}
1024
 
1024
 
1025
 
1025
 
1026
/******************************************************************/
1026
/******************************************************************/
1027
/** \name Internal function definitions */
1027
/** \name Internal function definitions */
1028
/*@{*/
1028
/*@{*/
1029
 
1029
 
1030
				/* Driver support (drm_drv.h) */
1030
				/* Driver support (drm_drv.h) */
1031
extern long drm_ioctl(struct file *filp,
1031
extern long drm_ioctl(struct file *filp,
1032
		     unsigned int cmd, unsigned long arg);
1032
		     unsigned int cmd, unsigned long arg);
1033
extern long drm_compat_ioctl(struct file *filp,
1033
extern long drm_compat_ioctl(struct file *filp,
1034
			     unsigned int cmd, unsigned long arg);
1034
			     unsigned int cmd, unsigned long arg);
1035
extern int drm_lastclose(struct drm_device *dev);
1035
extern int drm_lastclose(struct drm_device *dev);
1036
extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
1036
extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
1037
 
1037
 
1038
				/* Device support (drm_fops.h) */
1038
				/* Device support (drm_fops.h) */
1039
extern struct mutex drm_global_mutex;
1039
extern struct mutex drm_global_mutex;
1040
extern int drm_open(struct inode *inode, struct file *filp);
1040
extern int drm_open(struct inode *inode, struct file *filp);
1041
extern ssize_t drm_read(struct file *filp, char __user *buffer,
1041
extern ssize_t drm_read(struct file *filp, char __user *buffer,
1042
			size_t count, loff_t *offset);
1042
			size_t count, loff_t *offset);
1043
extern int drm_release(struct inode *inode, struct file *filp);
1043
extern int drm_release(struct inode *inode, struct file *filp);
1044
 
1044
 
1045
				/* Mapping support (drm_vm.h) */
1045
				/* Mapping support (drm_vm.h) */
1046
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1046
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1047
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1047
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1048
extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
1048
extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
1049
extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
1049
extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
1050
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1050
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1051
 
1051
 
1052
				/* Memory management support (drm_memory.h) */
1052
				/* Memory management support (drm_memory.h) */
1053
#include 
1053
#include 
1054
 
1054
 
1055
 
1055
 
1056
				/* Misc. IOCTL support (drm_ioctl.h) */
1056
				/* Misc. IOCTL support (drm_ioctl.h) */
1057
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1057
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1058
			    struct drm_file *file_priv);
1058
			    struct drm_file *file_priv);
1059
extern int drm_getunique(struct drm_device *dev, void *data,
1059
extern int drm_getunique(struct drm_device *dev, void *data,
1060
			 struct drm_file *file_priv);
1060
			 struct drm_file *file_priv);
1061
extern int drm_setunique(struct drm_device *dev, void *data,
1061
extern int drm_setunique(struct drm_device *dev, void *data,
1062
			 struct drm_file *file_priv);
1062
			 struct drm_file *file_priv);
1063
extern int drm_getmap(struct drm_device *dev, void *data,
1063
extern int drm_getmap(struct drm_device *dev, void *data,
1064
		      struct drm_file *file_priv);
1064
		      struct drm_file *file_priv);
1065
extern int drm_getclient(struct drm_device *dev, void *data,
1065
extern int drm_getclient(struct drm_device *dev, void *data,
1066
			 struct drm_file *file_priv);
1066
			 struct drm_file *file_priv);
1067
extern int drm_getstats(struct drm_device *dev, void *data,
1067
extern int drm_getstats(struct drm_device *dev, void *data,
1068
			struct drm_file *file_priv);
1068
			struct drm_file *file_priv);
1069
extern int drm_getcap(struct drm_device *dev, void *data,
1069
extern int drm_getcap(struct drm_device *dev, void *data,
1070
		      struct drm_file *file_priv);
1070
		      struct drm_file *file_priv);
1071
extern int drm_setclientcap(struct drm_device *dev, void *data,
1071
extern int drm_setclientcap(struct drm_device *dev, void *data,
1072
			    struct drm_file *file_priv);
1072
			    struct drm_file *file_priv);
1073
extern int drm_setversion(struct drm_device *dev, void *data,
1073
extern int drm_setversion(struct drm_device *dev, void *data,
1074
			  struct drm_file *file_priv);
1074
			  struct drm_file *file_priv);
1075
extern int drm_noop(struct drm_device *dev, void *data,
1075
extern int drm_noop(struct drm_device *dev, void *data,
1076
		    struct drm_file *file_priv);
1076
		    struct drm_file *file_priv);
1077
 
1077
 
1078
				/* Authentication IOCTL support (drm_auth.h) */
1078
				/* Authentication IOCTL support (drm_auth.h) */
1079
extern int drm_getmagic(struct drm_device *dev, void *data,
1079
extern int drm_getmagic(struct drm_device *dev, void *data,
1080
			struct drm_file *file_priv);
1080
			struct drm_file *file_priv);
1081
extern int drm_authmagic(struct drm_device *dev, void *data,
1081
extern int drm_authmagic(struct drm_device *dev, void *data,
1082
			 struct drm_file *file_priv);
1082
			 struct drm_file *file_priv);
1083
extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
1083
extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
1084
 
1084
 
1085
/* Cache management (drm_cache.c) */
1085
/* Cache management (drm_cache.c) */
1086
void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1086
void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1087
void drm_clflush_sg(struct sg_table *st);
1087
void drm_clflush_sg(struct sg_table *st);
1088
void drm_clflush_virt_range(void *addr, unsigned long length);
1088
void drm_clflush_virt_range(void *addr, unsigned long length);
1089
 
1089
 
1090
				/* Locking IOCTL support (drm_lock.h) */
1090
				/* Locking IOCTL support (drm_lock.h) */
1091
extern int drm_lock(struct drm_device *dev, void *data,
1091
extern int drm_lock(struct drm_device *dev, void *data,
1092
		    struct drm_file *file_priv);
1092
		    struct drm_file *file_priv);
1093
extern int drm_unlock(struct drm_device *dev, void *data,
1093
extern int drm_unlock(struct drm_device *dev, void *data,
1094
		      struct drm_file *file_priv);
1094
		      struct drm_file *file_priv);
1095
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1095
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1096
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1096
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1097
extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1097
extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1098
 
1098
 
1099
/*
1099
/*
1100
 * These are exported to drivers so that they can implement fencing using
1100
 * These are exported to drivers so that they can implement fencing using
1101
 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1101
 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1102
 */
1102
 */
1103
 
1103
 
1104
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1104
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1105
 
1105
 
1106
				/* Buffer management support (drm_bufs.h) */
1106
				/* Buffer management support (drm_bufs.h) */
1107
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1107
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1108
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1108
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1109
extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
1109
extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
1110
		      unsigned int size, enum drm_map_type type,
1110
		      unsigned int size, enum drm_map_type type,
1111
		      enum drm_map_flags flags, struct drm_local_map **map_ptr);
1111
		      enum drm_map_flags flags, struct drm_local_map **map_ptr);
1112
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1112
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1113
			    struct drm_file *file_priv);
1113
			    struct drm_file *file_priv);
1114
extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
1114
extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
1115
extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
1115
extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
1116
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1116
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1117
			   struct drm_file *file_priv);
1117
			   struct drm_file *file_priv);
1118
extern int drm_addbufs(struct drm_device *dev, void *data,
1118
extern int drm_addbufs(struct drm_device *dev, void *data,
1119
		       struct drm_file *file_priv);
1119
		       struct drm_file *file_priv);
1120
extern int drm_infobufs(struct drm_device *dev, void *data,
1120
extern int drm_infobufs(struct drm_device *dev, void *data,
1121
			struct drm_file *file_priv);
1121
			struct drm_file *file_priv);
1122
extern int drm_markbufs(struct drm_device *dev, void *data,
1122
extern int drm_markbufs(struct drm_device *dev, void *data,
1123
			struct drm_file *file_priv);
1123
			struct drm_file *file_priv);
1124
extern int drm_freebufs(struct drm_device *dev, void *data,
1124
extern int drm_freebufs(struct drm_device *dev, void *data,
1125
			struct drm_file *file_priv);
1125
			struct drm_file *file_priv);
1126
extern int drm_mapbufs(struct drm_device *dev, void *data,
1126
extern int drm_mapbufs(struct drm_device *dev, void *data,
1127
		       struct drm_file *file_priv);
1127
		       struct drm_file *file_priv);
1128
extern int drm_dma_ioctl(struct drm_device *dev, void *data,
1128
extern int drm_dma_ioctl(struct drm_device *dev, void *data,
1129
			 struct drm_file *file_priv);
1129
			 struct drm_file *file_priv);
1130
 
1130
 
1131
				/* DMA support (drm_dma.h) */
1131
				/* DMA support (drm_dma.h) */
1132
extern int drm_legacy_dma_setup(struct drm_device *dev);
1132
extern int drm_legacy_dma_setup(struct drm_device *dev);
1133
extern void drm_legacy_dma_takedown(struct drm_device *dev);
1133
extern void drm_legacy_dma_takedown(struct drm_device *dev);
1134
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1134
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1135
extern void drm_core_reclaim_buffers(struct drm_device *dev,
1135
extern void drm_core_reclaim_buffers(struct drm_device *dev,
1136
				     struct drm_file *filp);
1136
				     struct drm_file *filp);
1137
 
1137
 
1138
				/* IRQ support (drm_irq.h) */
1138
				/* IRQ support (drm_irq.h) */
1139
extern int drm_control(struct drm_device *dev, void *data,
1139
extern int drm_control(struct drm_device *dev, void *data,
1140
		       struct drm_file *file_priv);
1140
		       struct drm_file *file_priv);
1141
extern int drm_irq_install(struct drm_device *dev, int irq);
1141
extern int drm_irq_install(struct drm_device *dev, int irq);
1142
extern int drm_irq_uninstall(struct drm_device *dev);
1142
extern int drm_irq_uninstall(struct drm_device *dev);
1143
 
1143
 
1144
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1144
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1145
extern int drm_wait_vblank(struct drm_device *dev, void *data,
1145
extern int drm_wait_vblank(struct drm_device *dev, void *data,
1146
			   struct drm_file *filp);
1146
			   struct drm_file *filp);
1147
extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1147
extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1148
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1148
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1149
				     struct timeval *vblanktime);
1149
				     struct timeval *vblanktime);
1150
extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1150
extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1151
				     struct drm_pending_vblank_event *e);
1151
				     struct drm_pending_vblank_event *e);
1152
extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1152
extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1153
extern int drm_vblank_get(struct drm_device *dev, int crtc);
1153
extern int drm_vblank_get(struct drm_device *dev, int crtc);
1154
extern void drm_vblank_put(struct drm_device *dev, int crtc);
1154
extern void drm_vblank_put(struct drm_device *dev, int crtc);
1155
extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
1155
extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
1156
extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
1156
extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
1157
extern void drm_vblank_off(struct drm_device *dev, int crtc);
1157
extern void drm_vblank_off(struct drm_device *dev, int crtc);
1158
extern void drm_vblank_on(struct drm_device *dev, int crtc);
1158
extern void drm_vblank_on(struct drm_device *dev, int crtc);
1159
extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
1159
extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
1160
extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
1160
extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
1161
extern void drm_vblank_cleanup(struct drm_device *dev);
1161
extern void drm_vblank_cleanup(struct drm_device *dev);
1162
 
1162
 
1163
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1163
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1164
				     struct timeval *tvblank, unsigned flags);
1164
				     struct timeval *tvblank, unsigned flags);
1165
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1165
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1166
						 int crtc, int *max_error,
1166
						 int crtc, int *max_error,
1167
						 struct timeval *vblank_time,
1167
						 struct timeval *vblank_time,
1168
						 unsigned flags,
1168
						 unsigned flags,
1169
						 const struct drm_crtc *refcrtc,
1169
						 const struct drm_crtc *refcrtc,
1170
						 const struct drm_display_mode *mode);
1170
						 const struct drm_display_mode *mode);
1171
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
1171
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
1172
					    const struct drm_display_mode *mode);
1172
					    const struct drm_display_mode *mode);
1173
 
1173
 
1174
 
1174
 
1175
/* Modesetting support */
1175
/* Modesetting support */
1176
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1176
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1177
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1177
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1178
extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1178
extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1179
			   struct drm_file *file_priv);
1179
			   struct drm_file *file_priv);
1180
 
1180
 
1181
				/* AGP/GART support (drm_agpsupport.h) */
1181
				/* AGP/GART support (drm_agpsupport.h) */
1182
 
1182
 
1183
				/* Stub support (drm_stub.h) */
1183
				/* Stub support (drm_stub.h) */
1184
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1184
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1185
			       struct drm_file *file_priv);
1185
			       struct drm_file *file_priv);
1186
extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1186
extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1187
				struct drm_file *file_priv);
1187
				struct drm_file *file_priv);
1188
struct drm_master *drm_master_create(struct drm_minor *minor);
1188
struct drm_master *drm_master_create(struct drm_minor *minor);
1189
extern struct drm_master *drm_master_get(struct drm_master *master);
1189
extern struct drm_master *drm_master_get(struct drm_master *master);
1190
extern void drm_master_put(struct drm_master **master);
1190
extern void drm_master_put(struct drm_master **master);
1191
 
1191
 
1192
extern void drm_put_dev(struct drm_device *dev);
1192
extern void drm_put_dev(struct drm_device *dev);
1193
extern void drm_unplug_dev(struct drm_device *dev);
1193
extern void drm_unplug_dev(struct drm_device *dev);
1194
extern unsigned int drm_debug;
1194
extern unsigned int drm_debug;
1195
 
1195
 
1196
#if 0
1196
#if 0
1197
extern unsigned int drm_vblank_offdelay;
1197
extern unsigned int drm_vblank_offdelay;
1198
extern unsigned int drm_timestamp_precision;
1198
extern unsigned int drm_timestamp_precision;
1199
extern unsigned int drm_timestamp_monotonic;
1199
extern unsigned int drm_timestamp_monotonic;
1200
 
1200
 
1201
extern struct class *drm_class;
1201
extern struct class *drm_class;
1202
 
1202
 
1203
extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
1203
extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
1204
#endif
1204
#endif
1205
				/* Debugfs support */
1205
				/* Debugfs support */
1206
#if defined(CONFIG_DEBUG_FS)
1206
#if defined(CONFIG_DEBUG_FS)
1207
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1207
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1208
			    struct dentry *root);
1208
			    struct dentry *root);
1209
extern int drm_debugfs_create_files(const struct drm_info_list *files,
1209
extern int drm_debugfs_create_files(const struct drm_info_list *files,
1210
				    int count, struct dentry *root,
1210
				    int count, struct dentry *root,
1211
                                    struct drm_minor *minor);
1211
                                    struct drm_minor *minor);
1212
extern int drm_debugfs_remove_files(const struct drm_info_list *files,
1212
extern int drm_debugfs_remove_files(const struct drm_info_list *files,
1213
				    int count, struct drm_minor *minor);
1213
				    int count, struct drm_minor *minor);
1214
extern int drm_debugfs_cleanup(struct drm_minor *minor);
1214
extern int drm_debugfs_cleanup(struct drm_minor *minor);
1215
extern int drm_debugfs_connector_add(struct drm_connector *connector);
1215
extern int drm_debugfs_connector_add(struct drm_connector *connector);
1216
extern void drm_debugfs_connector_remove(struct drm_connector *connector);
1216
extern void drm_debugfs_connector_remove(struct drm_connector *connector);
1217
#else
1217
#else
1218
static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1218
static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1219
				   struct dentry *root)
1219
				   struct dentry *root)
1220
{
1220
{
1221
	return 0;
1221
	return 0;
1222
}
1222
}
1223
 
1223
 
1224
static inline int drm_debugfs_create_files(const struct drm_info_list *files,
1224
static inline int drm_debugfs_create_files(const struct drm_info_list *files,
1225
					   int count, struct dentry *root,
1225
					   int count, struct dentry *root,
1226
					   struct drm_minor *minor)
1226
					   struct drm_minor *minor)
1227
{
1227
{
1228
	return 0;
1228
	return 0;
1229
}
1229
}
1230
 
1230
 
1231
static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
1231
static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
1232
					   int count, struct drm_minor *minor)
1232
					   int count, struct drm_minor *minor)
1233
{
1233
{
1234
	return 0;
1234
	return 0;
1235
}
1235
}
1236
 
1236
 
1237
static inline int drm_debugfs_cleanup(struct drm_minor *minor)
1237
static inline int drm_debugfs_cleanup(struct drm_minor *minor)
1238
{
1238
{
1239
	return 0;
1239
	return 0;
1240
}
1240
}
1241
 
1241
 
1242
static inline int drm_debugfs_connector_add(struct drm_connector *connector)
1242
static inline int drm_debugfs_connector_add(struct drm_connector *connector)
1243
{
1243
{
1244
	return 0;
1244
	return 0;
1245
}
1245
}
1246
static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
1246
static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
1247
{
1247
{
1248
}
1248
}
1249
 
1249
 
1250
#endif
1250
#endif
1251
 
1251
 
1252
				/* Info file support */
1252
				/* Info file support */
1253
extern int drm_name_info(struct seq_file *m, void *data);
1253
extern int drm_name_info(struct seq_file *m, void *data);
1254
extern int drm_vm_info(struct seq_file *m, void *data);
1254
extern int drm_vm_info(struct seq_file *m, void *data);
1255
extern int drm_bufs_info(struct seq_file *m, void *data);
1255
extern int drm_bufs_info(struct seq_file *m, void *data);
1256
extern int drm_vblank_info(struct seq_file *m, void *data);
1256
extern int drm_vblank_info(struct seq_file *m, void *data);
1257
extern int drm_clients_info(struct seq_file *m, void* data);
1257
extern int drm_clients_info(struct seq_file *m, void* data);
1258
extern int drm_gem_name_info(struct seq_file *m, void *data);
1258
extern int drm_gem_name_info(struct seq_file *m, void *data);
1259
 
1259
 
1260
#if DRM_DEBUG_CODE
1260
#if DRM_DEBUG_CODE
1261
extern int drm_vma_info(struct seq_file *m, void *data);
1261
extern int drm_vma_info(struct seq_file *m, void *data);
1262
#endif
1262
#endif
1263
 
1263
 
1264
				/* Scatter Gather Support (drm_scatter.h) */
1264
				/* Scatter Gather Support (drm_scatter.h) */
1265
extern void drm_legacy_sg_cleanup(struct drm_device *dev);
1265
extern void drm_legacy_sg_cleanup(struct drm_device *dev);
1266
extern int drm_sg_alloc(struct drm_device *dev, void *data,
1266
extern int drm_sg_alloc(struct drm_device *dev, void *data,
1267
			struct drm_file *file_priv);
1267
			struct drm_file *file_priv);
1268
extern int drm_sg_free(struct drm_device *dev, void *data,
1268
extern int drm_sg_free(struct drm_device *dev, void *data,
1269
		       struct drm_file *file_priv);
1269
		       struct drm_file *file_priv);
1270
 
1270
 
1271
			       /* ATI PCIGART support (ati_pcigart.h) */
1271
			       /* ATI PCIGART support (ati_pcigart.h) */
1272
extern int drm_ati_pcigart_init(struct drm_device *dev,
1272
extern int drm_ati_pcigart_init(struct drm_device *dev,
1273
				struct drm_ati_pcigart_info * gart_info);
1273
				struct drm_ati_pcigart_info * gart_info);
1274
extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
1274
extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
1275
				   struct drm_ati_pcigart_info * gart_info);
1275
				   struct drm_ati_pcigart_info * gart_info);
1276
 
1276
 
1277
extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1277
extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1278
				       size_t align);
1278
				       size_t align);
1279
extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1279
extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1280
extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1280
extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1281
 
1281
 
1282
#if 0
1282
#if 0
1283
			       /* sysfs support (drm_sysfs.c) */
1283
			       /* sysfs support (drm_sysfs.c) */
1284
struct drm_sysfs_class;
1284
struct drm_sysfs_class;
1285
extern struct class *drm_sysfs_create(struct module *owner, char *name);
1285
extern struct class *drm_sysfs_create(struct module *owner, char *name);
1286
extern void drm_sysfs_destroy(void);
1286
extern void drm_sysfs_destroy(void);
1287
extern struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
1287
extern struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
1288
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1288
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1289
extern int drm_sysfs_connector_add(struct drm_connector *connector);
1289
extern int drm_sysfs_connector_add(struct drm_connector *connector);
1290
extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1290
extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1291
#endif
1291
#endif
1292
 
1292
 
1293
/* Graphics Execution Manager library functions (drm_gem.c) */
1293
/* Graphics Execution Manager library functions (drm_gem.c) */
1294
int drm_gem_init(struct drm_device *dev);
1294
int drm_gem_init(struct drm_device *dev);
1295
void drm_gem_destroy(struct drm_device *dev);
1295
void drm_gem_destroy(struct drm_device *dev);
1296
void drm_gem_object_release(struct drm_gem_object *obj);
1296
void drm_gem_object_release(struct drm_gem_object *obj);
1297
void drm_gem_object_free(struct kref *kref);
1297
void drm_gem_object_free(struct kref *kref);
1298
int drm_gem_object_init(struct drm_device *dev,
1298
int drm_gem_object_init(struct drm_device *dev,
1299
			struct drm_gem_object *obj, size_t size);
1299
			struct drm_gem_object *obj, size_t size);
1300
void drm_gem_private_object_init(struct drm_device *dev,
1300
void drm_gem_private_object_init(struct drm_device *dev,
1301
			struct drm_gem_object *obj, size_t size);
1301
			struct drm_gem_object *obj, size_t size);
1302
void drm_gem_vm_open(struct vm_area_struct *vma);
1302
void drm_gem_vm_open(struct vm_area_struct *vma);
1303
void drm_gem_vm_close(struct vm_area_struct *vma);
1303
void drm_gem_vm_close(struct vm_area_struct *vma);
1304
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
1304
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
1305
		     struct vm_area_struct *vma);
1305
		     struct vm_area_struct *vma);
1306
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1306
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1307
 
1307
 
1308
#include 
1308
#include 
1309
 
1309
 
1310
static inline void
1310
static inline void
1311
drm_gem_object_reference(struct drm_gem_object *obj)
1311
drm_gem_object_reference(struct drm_gem_object *obj)
1312
{
1312
{
1313
	kref_get(&obj->refcount);
1313
	kref_get(&obj->refcount);
1314
}
1314
}
1315
 
1315
 
1316
static inline void
1316
static inline void
1317
drm_gem_object_unreference(struct drm_gem_object *obj)
1317
drm_gem_object_unreference(struct drm_gem_object *obj)
1318
{
1318
{
1319
	if (obj != NULL)
1319
	if (obj != NULL)
1320
		kref_put(&obj->refcount, drm_gem_object_free);
1320
		kref_put(&obj->refcount, drm_gem_object_free);
1321
}
1321
}
1322
 
1322
 
1323
static inline void
1323
static inline void
1324
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1324
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1325
{
1325
{
1326
	if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
1326
	if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
1327
		struct drm_device *dev = obj->dev;
1327
		struct drm_device *dev = obj->dev;
1328
 
1328
 
1329
		mutex_lock(&dev->struct_mutex);
1329
		mutex_lock(&dev->struct_mutex);
1330
		if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
1330
		if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
1331
			drm_gem_object_free(&obj->refcount);
1331
			drm_gem_object_free(&obj->refcount);
1332
		mutex_unlock(&dev->struct_mutex);
1332
		mutex_unlock(&dev->struct_mutex);
1333
	}
1333
	}
1334
}
1334
}
1335
 
1335
 
1336
int drm_gem_handle_create_tail(struct drm_file *file_priv,
1336
int drm_gem_handle_create_tail(struct drm_file *file_priv,
1337
			       struct drm_gem_object *obj,
1337
			       struct drm_gem_object *obj,
1338
			       u32 *handlep);
1338
			       u32 *handlep);
1339
int drm_gem_handle_create(struct drm_file *file_priv,
1339
int drm_gem_handle_create(struct drm_file *file_priv,
1340
			  struct drm_gem_object *obj,
1340
			  struct drm_gem_object *obj,
1341
			  u32 *handlep);
1341
			  u32 *handlep);
1342
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1342
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1343
 
1343
 
1344
 
1344
 
1345
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1345
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1346
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1346
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1347
int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
1347
int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
1348
 
1348
 
1349
struct page **drm_gem_get_pages(struct drm_gem_object *obj);
1349
struct page **drm_gem_get_pages(struct drm_gem_object *obj);
1350
void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
1350
void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
1351
		bool dirty, bool accessed);
1351
		bool dirty, bool accessed);
1352
 
1352
 
1353
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1353
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1354
					     struct drm_file *filp,
1354
					     struct drm_file *filp,
1355
					     u32 handle);
1355
					     u32 handle);
1356
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1356
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1357
			struct drm_file *file_priv);
1357
			struct drm_file *file_priv);
1358
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1358
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1359
			struct drm_file *file_priv);
1359
			struct drm_file *file_priv);
1360
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1360
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1361
		       struct drm_file *file_priv);
1361
		       struct drm_file *file_priv);
1362
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1362
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1363
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1363
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1364
 
1364
 
1365
extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
1365
extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
1366
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
1366
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
1367
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
1367
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
1368
 
1368
 
1369
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1369
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1370
							 unsigned int token)
1370
							 unsigned int token)
1371
{
1371
{
1372
	struct drm_map_list *_entry;
1372
	struct drm_map_list *_entry;
1373
	list_for_each_entry(_entry, &dev->maplist, head)
1373
	list_for_each_entry(_entry, &dev->maplist, head)
1374
	    if (_entry->user_token == token)
1374
	    if (_entry->user_token == token)
1375
		return _entry->map;
1375
		return _entry->map;
1376
	return NULL;
1376
	return NULL;
1377
}
1377
}
1378
 
1378
 
1379
static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1379
static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1380
{
1380
{
1381
}
1381
}
1382
 
1382
 
1383
#include 
1383
#include 
-
 
1384
 
-
 
1385
struct drm_device *drm_dev_alloc(struct drm_driver *driver,
-
 
1386
				 struct device *parent);
-
 
1387
void drm_dev_ref(struct drm_device *dev);
-
 
1388
void drm_dev_unref(struct drm_device *dev);
1384
 
1389
 
1385
extern int drm_fill_in_dev(struct drm_device *dev,
1390
extern int drm_fill_in_dev(struct drm_device *dev,
1386
			   const struct pci_device_id *ent,
1391
			   const struct pci_device_id *ent,
1387
			   struct drm_driver *driver);
1392
			   struct drm_driver *driver);
1388
int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1393
int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1389
/*@}*/
1394
/*@}*/
-
 
1395
 
-
 
1396
/* PCI section */
-
 
1397
static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
-
 
1398
{
-
 
1399
 
-
 
1400
	return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
-
 
1401
}
1390
 
1402
void drm_pci_agp_destroy(struct drm_device *dev);
1391
 
1403
 
1392
#if 0
1404
#if 0
1393
extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
1405
extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
1394
extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
1406
extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
1395
extern int drm_get_pci_dev(struct pci_dev *pdev,
1407
extern int drm_get_pci_dev(struct pci_dev *pdev,
1396
			   const struct pci_device_id *ent,
1408
			   const struct pci_device_id *ent,
1397
			   struct drm_driver *driver);
1409
			   struct drm_driver *driver);
1398
#endif
1410
#endif
1399
 
1411
 
1400
#define DRM_PCIE_SPEED_25 1
1412
#define DRM_PCIE_SPEED_25 1
1401
#define DRM_PCIE_SPEED_50 2
1413
#define DRM_PCIE_SPEED_50 2
1402
#define DRM_PCIE_SPEED_80 4
1414
#define DRM_PCIE_SPEED_80 4
1403
 
1415
 
1404
extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1416
extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1405
 
-
 
1406
static __inline__ int drm_device_is_agp(struct drm_device *dev)
-
 
1407
{
-
 
1408
    return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
-
 
1409
}
1417
 
1410
 
1418
 
1411
static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1419
static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1412
{
1420
{
1413
    return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1421
    return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1414
}
1422
}
1415
#endif				/* __KERNEL__ */
1423
#endif				/* __KERNEL__ */
1416
 
1424
 
1417
#define drm_sysfs_connector_add(connector)
1425
#define drm_sysfs_connector_add(connector)
1418
#define drm_sysfs_connector_remove(connector)
1426
#define drm_sysfs_connector_remove(connector)
1419
 
1427
 
1420
#define LFB_SIZE 0x1000000
1428
#define LFB_SIZE 0x1000000
1421
extern struct drm_device *main_device;
1429
extern struct drm_device *main_device;
1422
extern struct drm_file *drm_file_handlers[256];
1430
extern struct drm_file *drm_file_handlers[256];
1423
 
1431
 
1424
#endif
1432
#endif