Subversion Repositories Kolibri OS

Rev

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

Rev 3747 Rev 3763
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 
-
 
60
#include 
59
//#include 
61
 
60
//#include 
62
//#include 
61
//#include 
63
//#include 
62
//#include 
64
//#include 
63
//#include 
65
//#include 
64
#include 
66
#include 
65
#include 
67
#include 
66
#include 
68
#include 
67
//#include     /* For (un)lock_kernel */
69
//#include     /* For (un)lock_kernel */
68
//#include 
70
//#include 
69
//#include 
71
//#include 
70
//#include 
72
//#include 
71
#include 
73
#include 
72
//#include 
74
//#include 
73
//#include 
75
//#include 
74
//#include 
76
//#include 
75
//#include 
77
//#include 
76
//#include 
78
//#include 
77
//#include 
79
//#include 
78
 
80
 
79
#include 
81
#include 
80
 
82
 
81
 
83
 
82
#include "drm.h"
84
#include "drm.h"
83
 
85
 
84
#include 
86
#include 
85
 
87
 
86
#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)))
87
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
89
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
88
 
90
 
89
struct module;
91
struct module;
90
 
92
 
91
struct drm_file;
93
struct drm_file;
92
struct drm_device;
94
struct drm_device;
93
 
95
 
94
struct device_node;
96
struct device_node;
95
struct videomode;
97
struct videomode;
96
//#include 
98
//#include 
97
#include 
99
#include 
98
#include 
100
#include 
99
 
101
 
100
#define KHZ2PICOS(a) (1000000000UL/(a))
102
#define KHZ2PICOS(a) (1000000000UL/(a))
101
 
103
 
102
/* get_scanout_position() return flags */
104
/* get_scanout_position() return flags */
103
#define DRM_SCANOUTPOS_VALID        (1 << 0)
105
#define DRM_SCANOUTPOS_VALID        (1 << 0)
104
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
106
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
105
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
107
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
106
 
108
 
107
 
109
 
108
 
110
 
109
#define DRM_UT_CORE 		0x01
111
#define DRM_UT_CORE 		0x01
110
#define DRM_UT_DRIVER		0x02
112
#define DRM_UT_DRIVER		0x02
111
#define DRM_UT_KMS          0x04
113
#define DRM_UT_KMS          0x04
112
#define DRM_UT_PRIME		0x08
114
#define DRM_UT_PRIME		0x08
113
/*
115
/*
114
 * Three debug levels are defined.
116
 * Three debug levels are defined.
115
 * drm_core, drm_driver, drm_kms
117
 * drm_core, drm_driver, drm_kms
116
 * drm_core level can be used in the generic drm code. For example:
118
 * drm_core level can be used in the generic drm code. For example:
117
 * 	drm_ioctl, drm_mm, drm_memory
119
 * 	drm_ioctl, drm_mm, drm_memory
118
 * The macro definition of DRM_DEBUG is used.
120
 * The macro definition of DRM_DEBUG is used.
119
 * 	DRM_DEBUG(fmt, args...)
121
 * 	DRM_DEBUG(fmt, args...)
120
 * 	The debug info by using the DRM_DEBUG can be obtained by adding
122
 * 	The debug info by using the DRM_DEBUG can be obtained by adding
121
 * 	the boot option of "drm.debug=1".
123
 * 	the boot option of "drm.debug=1".
122
 *
124
 *
123
 * drm_driver level can be used in the specific drm driver. It is used
125
 * drm_driver level can be used in the specific drm driver. It is used
124
 * to add the debug info related with the drm driver. For example:
126
 * to add the debug info related with the drm driver. For example:
125
 * i915_drv, i915_dma, i915_gem, radeon_drv,
127
 * i915_drv, i915_dma, i915_gem, radeon_drv,
126
 * 	The macro definition of DRM_DEBUG_DRIVER can be used.
128
 * 	The macro definition of DRM_DEBUG_DRIVER can be used.
127
 * 	DRM_DEBUG_DRIVER(fmt, args...)
129
 * 	DRM_DEBUG_DRIVER(fmt, args...)
128
 * 	The debug info by using the DRM_DEBUG_DRIVER can be obtained by
130
 * 	The debug info by using the DRM_DEBUG_DRIVER can be obtained by
129
 * 	adding the boot option of "drm.debug=0x02"
131
 * 	adding the boot option of "drm.debug=0x02"
130
 *
132
 *
131
 * drm_kms level can be used in the KMS code related with specific drm driver.
133
 * drm_kms level can be used in the KMS code related with specific drm driver.
132
 * It is used to add the debug info related with KMS mode. For example:
134
 * It is used to add the debug info related with KMS mode. For example:
133
 * the connector/crtc ,
135
 * the connector/crtc ,
134
 * 	The macro definition of DRM_DEBUG_KMS can be used.
136
 * 	The macro definition of DRM_DEBUG_KMS can be used.
135
 * 	DRM_DEBUG_KMS(fmt, args...)
137
 * 	DRM_DEBUG_KMS(fmt, args...)
136
 * 	The debug info by using the DRM_DEBUG_KMS can be obtained by
138
 * 	The debug info by using the DRM_DEBUG_KMS can be obtained by
137
 * 	adding the boot option of "drm.debug=0x04"
139
 * 	adding the boot option of "drm.debug=0x04"
138
 *
140
 *
139
 * If we add the boot option of "drm.debug=0x06", we can get the debug info by
141
 * If we add the boot option of "drm.debug=0x06", we can get the debug info by
140
 * using the DRM_DEBUG_KMS and DRM_DEBUG_DRIVER.
142
 * using the DRM_DEBUG_KMS and DRM_DEBUG_DRIVER.
141
 * If we add the boot option of "drm.debug=0x05", we can get the debug info by
143
 * If we add the boot option of "drm.debug=0x05", we can get the debug info by
142
 * using the DRM_DEBUG_KMS and DRM_DEBUG.
144
 * using the DRM_DEBUG_KMS and DRM_DEBUG.
143
 */
145
 */
144
 
146
 
145
extern __printf(4, 5)
147
extern __printf(4, 5)
146
void drm_ut_debug_printk(unsigned int request_level,
148
void drm_ut_debug_printk(unsigned int request_level,
147
				const char *prefix,
149
				const char *prefix,
148
				const char *function_name,
150
				const char *function_name,
149
				const char *format, ...);
151
				const char *format, ...);
150
extern __printf(2, 3)
152
extern __printf(2, 3)
151
int drm_err(const char *func, const char *format, ...);
153
int drm_err(const char *func, const char *format, ...);
152
 
154
 
153
/***********************************************************************/
155
/***********************************************************************/
154
/** \name DRM template customization defaults */
156
/** \name DRM template customization defaults */
155
/*@{*/
157
/*@{*/
156
 
158
 
157
/* driver capabilities and requirements mask */
159
/* driver capabilities and requirements mask */
158
#define DRIVER_USE_AGP     0x1
160
#define DRIVER_USE_AGP     0x1
159
#define DRIVER_REQUIRE_AGP 0x2
161
#define DRIVER_REQUIRE_AGP 0x2
160
#define DRIVER_USE_MTRR    0x4
162
#define DRIVER_USE_MTRR    0x4
161
#define DRIVER_PCI_DMA     0x8
163
#define DRIVER_PCI_DMA     0x8
162
#define DRIVER_SG          0x10
164
#define DRIVER_SG          0x10
163
#define DRIVER_HAVE_DMA    0x20
165
#define DRIVER_HAVE_DMA    0x20
164
#define DRIVER_HAVE_IRQ    0x40
166
#define DRIVER_HAVE_IRQ    0x40
165
#define DRIVER_IRQ_SHARED  0x80
167
#define DRIVER_IRQ_SHARED  0x80
166
#define DRIVER_IRQ_VBL     0x100
168
#define DRIVER_IRQ_VBL     0x100
167
#define DRIVER_DMA_QUEUE   0x200
169
#define DRIVER_DMA_QUEUE   0x200
168
#define DRIVER_FB_DMA      0x400
170
#define DRIVER_FB_DMA      0x400
169
#define DRIVER_IRQ_VBL2    0x800
171
#define DRIVER_IRQ_VBL2    0x800
170
#define DRIVER_GEM         0x1000
172
#define DRIVER_GEM         0x1000
171
#define DRIVER_MODESET     0x2000
173
#define DRIVER_MODESET     0x2000
172
#define DRIVER_PRIME       0x4000
174
#define DRIVER_PRIME       0x4000
173
 
175
 
174
#define DRIVER_BUS_PCI 0x1
176
#define DRIVER_BUS_PCI 0x1
175
#define DRIVER_BUS_PLATFORM 0x2
177
#define DRIVER_BUS_PLATFORM 0x2
176
#define DRIVER_BUS_USB 0x3
178
#define DRIVER_BUS_USB 0x3
177
 
179
 
178
/***********************************************************************/
180
/***********************************************************************/
179
/** \name Begin the DRM... */
181
/** \name Begin the DRM... */
180
/*@{*/
182
/*@{*/
181
 
183
 
182
#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then
184
#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then
183
				     also include looping detection. */
185
				     also include looping detection. */
184
 
186
 
185
#define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
187
#define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
186
#define DRM_KERNEL_CONTEXT    0	 /**< Change drm_resctx if changed */
188
#define DRM_KERNEL_CONTEXT    0	 /**< Change drm_resctx if changed */
187
#define DRM_RESERVED_CONTEXTS 1	 /**< Change drm_resctx if changed */
189
#define DRM_RESERVED_CONTEXTS 1	 /**< Change drm_resctx if changed */
188
#define DRM_LOOPING_LIMIT     5000000
190
#define DRM_LOOPING_LIMIT     5000000
189
#define DRM_TIME_SLICE	      (HZ/20)  /**< Time slice for GLXContexts */
191
#define DRM_TIME_SLICE	      (HZ/20)  /**< Time slice for GLXContexts */
190
#define DRM_LOCK_SLICE	      1	/**< Time slice for lock, in jiffies */
192
#define DRM_LOCK_SLICE	      1	/**< Time slice for lock, in jiffies */
191
 
193
 
192
#define DRM_FLAG_DEBUG	  0x01
194
#define DRM_FLAG_DEBUG	  0x01
193
 
195
 
194
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
196
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
195
#define DRM_MAP_HASH_OFFSET 0x10000000
197
#define DRM_MAP_HASH_OFFSET 0x10000000
196
 
198
 
197
/*@}*/
199
/*@}*/
198
 
200
 
199
/***********************************************************************/
201
/***********************************************************************/
200
/** \name Macros to make printk easier */
202
/** \name Macros to make printk easier */
201
/*@{*/
203
/*@{*/
202
 
204
 
203
/**
205
/**
204
 * Error output.
206
 * Error output.
205
 *
207
 *
206
 * \param fmt printf() like format string.
208
 * \param fmt printf() like format string.
207
 * \param arg arguments
209
 * \param arg arguments
208
 */
210
 */
209
#define DRM_ERROR(fmt, ...)				\
211
#define DRM_ERROR(fmt, ...)				\
210
	drm_err(__func__, fmt, ##__VA_ARGS__)
212
	drm_err(__func__, fmt, ##__VA_ARGS__)
211
 
213
 
212
#define DRM_INFO(fmt, ...)				\
214
#define DRM_INFO(fmt, ...)				\
213
	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
215
	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
214
 
216
 
215
/**
217
/**
216
 * Debug output.
218
 * Debug output.
217
 *
219
 *
218
 * \param fmt printf() like format string.
220
 * \param fmt printf() like format string.
219
 * \param arg arguments
221
 * \param arg arguments
220
 */
222
 */
221
#if DRM_DEBUG_CODE
223
#if DRM_DEBUG_CODE
222
#define DRM_DEBUG(fmt, ...)                                 \
224
#define DRM_DEBUG(fmt, ...)                                 \
223
    do {                                                    \
225
    do {                                                    \
224
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
226
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
225
	} while (0)
227
	} while (0)
226
 
228
 
227
#define DRM_DEBUG_DRIVER(fmt, ...)                          \
229
#define DRM_DEBUG_DRIVER(fmt, ...)                          \
228
    do {                                                    \
230
    do {                                                    \
229
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
231
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
230
	} while (0)
232
	} while (0)
231
#define DRM_DEBUG_KMS(fmt, ...)              \
233
#define DRM_DEBUG_KMS(fmt, ...)              \
232
	do {								\
234
	do {								\
233
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
235
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
234
	} while (0)
236
	} while (0)
235
#define DRM_DEBUG_PRIME(fmt, ...)                    \
237
#define DRM_DEBUG_PRIME(fmt, ...)                    \
236
	do {								\
238
	do {								\
237
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
239
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
238
	} while (0)
240
	} while (0)
239
#define DRM_LOG(fmt, ...)                        \
241
#define DRM_LOG(fmt, ...)                        \
240
	do {								\
242
	do {								\
241
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
243
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
242
	} while (0)
244
	} while (0)
243
#define DRM_LOG_KMS(fmt, ...)                    \
245
#define DRM_LOG_KMS(fmt, ...)                    \
244
	do {								\
246
	do {								\
245
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
247
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
246
	} while (0)
248
	} while (0)
247
#define DRM_LOG_MODE(fmt, ...)                   \
249
#define DRM_LOG_MODE(fmt, ...)                   \
248
	do {								\
250
	do {								\
249
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
251
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
250
	} while (0)
252
	} while (0)
251
#define DRM_LOG_DRIVER(fmt, ...)                 \
253
#define DRM_LOG_DRIVER(fmt, ...)                 \
252
	do {								\
254
	do {								\
253
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
255
    printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__);  \
254
	} while (0)
256
	} while (0)
255
#else
257
#else
256
#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
258
#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
257
#define DRM_DEBUG_KMS(fmt, args...)	do { } while (0)
259
#define DRM_DEBUG_KMS(fmt, args...)	do { } while (0)
258
#define DRM_DEBUG_PRIME(fmt, args...)	do { } while (0)
260
#define DRM_DEBUG_PRIME(fmt, args...)	do { } while (0)
259
#define DRM_DEBUG(fmt, arg...)		 do { } while (0)
261
#define DRM_DEBUG(fmt, arg...)		 do { } while (0)
260
#define DRM_LOG(fmt, arg...)		do { } while (0)
262
#define DRM_LOG(fmt, arg...)		do { } while (0)
261
#define DRM_LOG_KMS(fmt, args...) do { } while (0)
263
#define DRM_LOG_KMS(fmt, args...) do { } while (0)
262
#define DRM_LOG_MODE(fmt, arg...) do { } while (0)
264
#define DRM_LOG_MODE(fmt, arg...) do { } while (0)
263
#define DRM_LOG_DRIVER(fmt, arg...) do { } while (0)
265
#define DRM_LOG_DRIVER(fmt, arg...) do { } while (0)
264
 
266
 
265
#endif
267
#endif
266
 
268
 
267
/*@}*/
269
/*@}*/
268
 
270
 
269
/***********************************************************************/
271
/***********************************************************************/
270
/** \name Internal types and structures */
272
/** \name Internal types and structures */
271
/*@{*/
273
/*@{*/
272
 
274
 
273
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
275
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
274
 
276
 
275
#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
277
#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
276
#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
278
#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
277
 
279
 
278
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
280
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
279
 
281
 
280
/**
282
/**
281
 * Test that the hardware lock is held by the caller, returning otherwise.
283
 * Test that the hardware lock is held by the caller, returning otherwise.
282
 *
284
 *
283
 * \param dev DRM device.
285
 * \param dev DRM device.
284
 * \param filp file pointer of the caller.
286
 * \param filp file pointer of the caller.
285
 */
287
 */
286
#define LOCK_TEST_WITH_RETURN( dev, _file_priv )				\
288
#define LOCK_TEST_WITH_RETURN( dev, _file_priv )				\
287
do {										\
289
do {										\
288
	if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) ||	\
290
	if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) ||	\
289
	    _file_priv->master->lock.file_priv != _file_priv)	{		\
291
	    _file_priv->master->lock.file_priv != _file_priv)	{		\
290
		DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
292
		DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
291
			   __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
293
			   __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
292
			   _file_priv->master->lock.file_priv, _file_priv);	\
294
			   _file_priv->master->lock.file_priv, _file_priv);	\
293
		return -EINVAL;							\
295
		return -EINVAL;							\
294
	}									\
296
	}									\
295
} while (0)
297
} while (0)
296
 
298
 
297
#if 0
299
#if 0
298
/**
300
/**
299
 * Ioctl function type.
301
 * Ioctl function type.
300
 *
302
 *
301
 * \param inode device inode.
303
 * \param inode device inode.
302
 * \param file_priv DRM file private pointer.
304
 * \param file_priv DRM file private pointer.
303
 * \param cmd command.
305
 * \param cmd command.
304
 * \param arg argument.
306
 * \param arg argument.
305
 */
307
 */
306
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
308
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
307
			struct drm_file *file_priv);
309
			struct drm_file *file_priv);
308
 
310
 
309
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
311
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
310
			       unsigned long arg);
312
			       unsigned long arg);
311
 
313
 
312
#define DRM_IOCTL_NR(n)                _IOC_NR(n)
314
#define DRM_IOCTL_NR(n)                _IOC_NR(n)
313
#define DRM_MAJOR       226
315
#define DRM_MAJOR       226
314
 
316
 
315
#define DRM_AUTH	0x1
317
#define DRM_AUTH	0x1
316
#define	DRM_MASTER	0x2
318
#define	DRM_MASTER	0x2
317
#define DRM_ROOT_ONLY	0x4
319
#define DRM_ROOT_ONLY	0x4
318
#define DRM_CONTROL_ALLOW 0x8
320
#define DRM_CONTROL_ALLOW 0x8
319
#define DRM_UNLOCKED	0x10
321
#define DRM_UNLOCKED	0x10
320
 
322
 
321
struct drm_ioctl_desc {
323
struct drm_ioctl_desc {
322
	unsigned int cmd;
324
	unsigned int cmd;
323
	int flags;
325
	int flags;
324
	drm_ioctl_t *func;
326
	drm_ioctl_t *func;
325
	unsigned int cmd_drv;
327
	unsigned int cmd_drv;
326
	const char *name;
328
	const char *name;
327
};
329
};
328
 
330
 
329
/**
331
/**
330
 * Creates a driver or general drm_ioctl_desc array entry for the given
332
 * Creates a driver or general drm_ioctl_desc array entry for the given
331
 * ioctl, for use by drm_ioctl().
333
 * ioctl, for use by drm_ioctl().
332
 */
334
 */
333
 
335
 
334
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)			\
336
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)			\
335
	[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
337
	[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
336
 
338
 
337
struct drm_magic_entry {
339
struct drm_magic_entry {
338
	struct list_head head;
340
	struct list_head head;
339
	struct drm_hash_item hash_item;
341
	struct drm_hash_item hash_item;
340
	struct drm_file *priv;
342
	struct drm_file *priv;
341
};
343
};
342
 
344
 
343
struct drm_vma_entry {
345
struct drm_vma_entry {
344
	struct list_head head;
346
	struct list_head head;
345
	struct vm_area_struct *vma;
347
	struct vm_area_struct *vma;
346
	pid_t pid;
348
	pid_t pid;
347
};
349
};
348
 
350
 
349
/**
351
/**
350
 * DMA buffer.
352
 * DMA buffer.
351
 */
353
 */
352
struct drm_buf {
354
struct drm_buf {
353
	int idx;		       /**< Index into master buflist */
355
	int idx;		       /**< Index into master buflist */
354
	int total;		       /**< Buffer size */
356
	int total;		       /**< Buffer size */
355
	int order;		       /**< log-base-2(total) */
357
	int order;		       /**< log-base-2(total) */
356
	int used;		       /**< Amount of buffer in use (for DMA) */
358
	int used;		       /**< Amount of buffer in use (for DMA) */
357
	unsigned long offset;	       /**< Byte offset (used internally) */
359
	unsigned long offset;	       /**< Byte offset (used internally) */
358
	void *address;		       /**< Address of buffer */
360
	void *address;		       /**< Address of buffer */
359
	unsigned long bus_address;     /**< Bus address of buffer */
361
	unsigned long bus_address;     /**< Bus address of buffer */
360
	struct drm_buf *next;	       /**< Kernel-only: used for free list */
362
	struct drm_buf *next;	       /**< Kernel-only: used for free list */
361
	__volatile__ int waiting;      /**< On kernel DMA queue */
363
	__volatile__ int waiting;      /**< On kernel DMA queue */
362
	__volatile__ int pending;      /**< On hardware DMA queue */
364
	__volatile__ int pending;      /**< On hardware DMA queue */
363
	struct drm_file *file_priv;    /**< Private of holding file descr */
365
	struct drm_file *file_priv;    /**< Private of holding file descr */
364
	int context;		       /**< Kernel queue for this buffer */
366
	int context;		       /**< Kernel queue for this buffer */
365
	int while_locked;	       /**< Dispatch this buffer while locked */
367
	int while_locked;	       /**< Dispatch this buffer while locked */
366
	enum {
368
	enum {
367
		DRM_LIST_NONE = 0,
369
		DRM_LIST_NONE = 0,
368
		DRM_LIST_FREE = 1,
370
		DRM_LIST_FREE = 1,
369
		DRM_LIST_WAIT = 2,
371
		DRM_LIST_WAIT = 2,
370
		DRM_LIST_PEND = 3,
372
		DRM_LIST_PEND = 3,
371
		DRM_LIST_PRIO = 4,
373
		DRM_LIST_PRIO = 4,
372
		DRM_LIST_RECLAIM = 5
374
		DRM_LIST_RECLAIM = 5
373
	} list;			       /**< Which list we're on */
375
	} list;			       /**< Which list we're on */
374
 
376
 
375
	int dev_priv_size;		 /**< Size of buffer private storage */
377
	int dev_priv_size;		 /**< Size of buffer private storage */
376
	void *dev_private;		 /**< Per-buffer private storage */
378
	void *dev_private;		 /**< Per-buffer private storage */
377
};
379
};
378
 
380
 
379
/** bufs is one longer than it has to be */
381
/** bufs is one longer than it has to be */
380
struct drm_waitlist {
382
struct drm_waitlist {
381
	int count;			/**< Number of possible buffers */
383
	int count;			/**< Number of possible buffers */
382
	struct drm_buf **bufs;		/**< List of pointers to buffers */
384
	struct drm_buf **bufs;		/**< List of pointers to buffers */
383
	struct drm_buf **rp;			/**< Read pointer */
385
	struct drm_buf **rp;			/**< Read pointer */
384
	struct drm_buf **wp;			/**< Write pointer */
386
	struct drm_buf **wp;			/**< Write pointer */
385
	struct drm_buf **end;		/**< End pointer */
387
	struct drm_buf **end;		/**< End pointer */
386
	spinlock_t read_lock;
388
	spinlock_t read_lock;
387
	spinlock_t write_lock;
389
	spinlock_t write_lock;
388
};
390
};
389
 
391
 
390
struct drm_freelist {
392
struct drm_freelist {
391
	int initialized;	       /**< Freelist in use */
393
	int initialized;	       /**< Freelist in use */
392
	atomic_t count;		       /**< Number of free buffers */
394
	atomic_t count;		       /**< Number of free buffers */
393
	struct drm_buf *next;	       /**< End pointer */
395
	struct drm_buf *next;	       /**< End pointer */
394
 
396
 
395
	wait_queue_head_t waiting;     /**< Processes waiting on free bufs */
397
	wait_queue_head_t waiting;     /**< Processes waiting on free bufs */
396
	int low_mark;		       /**< Low water mark */
398
	int low_mark;		       /**< Low water mark */
397
	int high_mark;		       /**< High water mark */
399
	int high_mark;		       /**< High water mark */
398
	atomic_t wfh;		       /**< If waiting for high mark */
400
	atomic_t wfh;		       /**< If waiting for high mark */
399
	spinlock_t lock;
401
	spinlock_t lock;
400
};
402
};
401
#endif
403
#endif
402
 
404
 
403
typedef struct drm_dma_handle {
405
typedef struct drm_dma_handle {
404
	dma_addr_t busaddr;
406
	dma_addr_t busaddr;
405
	void *vaddr;
407
	void *vaddr;
406
	size_t size;
408
	size_t size;
407
} drm_dma_handle_t;
409
} drm_dma_handle_t;
408
 
410
 
409
#if 0
411
#if 0
410
/**
412
/**
411
 * Buffer entry.  There is one of this for each buffer size order.
413
 * Buffer entry.  There is one of this for each buffer size order.
412
 */
414
 */
413
struct drm_buf_entry {
415
struct drm_buf_entry {
414
	int buf_size;			/**< size */
416
	int buf_size;			/**< size */
415
	int buf_count;			/**< number of buffers */
417
	int buf_count;			/**< number of buffers */
416
	struct drm_buf *buflist;		/**< buffer list */
418
	struct drm_buf *buflist;		/**< buffer list */
417
	int seg_count;
419
	int seg_count;
418
	int page_order;
420
	int page_order;
419
	struct drm_dma_handle **seglist;
421
	struct drm_dma_handle **seglist;
420
 
422
 
421
	struct drm_freelist freelist;
423
	struct drm_freelist freelist;
422
};
424
};
423
 
425
 
424
/* Event queued up for userspace to read */
426
/* Event queued up for userspace to read */
425
struct drm_pending_event {
427
struct drm_pending_event {
426
	struct drm_event *event;
428
	struct drm_event *event;
427
	struct list_head link;
429
	struct list_head link;
428
	struct drm_file *file_priv;
430
	struct drm_file *file_priv;
429
	pid_t pid; /* pid of requester, no guarantee it's valid by the time
431
	pid_t pid; /* pid of requester, no guarantee it's valid by the time
430
		      we deliver the event, for tracing only */
432
		      we deliver the event, for tracing only */
431
	void (*destroy)(struct drm_pending_event *event);
433
	void (*destroy)(struct drm_pending_event *event);
432
};
434
};
433
 
435
 
434
/* initial implementaton using a linked list - todo hashtab */
436
/* initial implementaton using a linked list - todo hashtab */
435
struct drm_prime_file_private {
437
struct drm_prime_file_private {
436
	struct list_head head;
438
	struct list_head head;
437
	struct mutex lock;
439
	struct mutex lock;
438
};
440
};
439
#endif
441
#endif
440
 
442
 
441
/** File private data */
443
/** File private data */
442
struct drm_file {
444
struct drm_file {
443
	struct list_head lhead;
445
	struct list_head lhead;
444
	unsigned long lock_count;
446
	unsigned long lock_count;
445
 
447
 
446
	/** Mapping of mm object handles to object pointers. */
448
	/** Mapping of mm object handles to object pointers. */
447
	struct idr object_idr;
449
	struct idr object_idr;
448
	/** Lock for synchronization of access to object_idr. */
450
	/** Lock for synchronization of access to object_idr. */
449
	spinlock_t table_lock;
451
	spinlock_t table_lock;
450
 
452
 
451
	void *driver_priv;
453
	void *driver_priv;
452
 
454
 
453
	struct list_head fbs;
455
	struct list_head fbs;
454
 
456
 
455
	wait_queue_head_t event_wait;
457
	wait_queue_head_t event_wait;
456
	struct list_head event_list;
458
	struct list_head event_list;
457
	int event_space;
459
	int event_space;
458
};
460
};
459
 
461
 
460
#if 0
462
#if 0
461
/** Wait queue */
463
/** Wait queue */
462
struct drm_queue {
464
struct drm_queue {
463
	atomic_t use_count;		/**< Outstanding uses (+1) */
465
	atomic_t use_count;		/**< Outstanding uses (+1) */
464
	atomic_t finalization;		/**< Finalization in progress */
466
	atomic_t finalization;		/**< Finalization in progress */
465
	atomic_t block_count;		/**< Count of processes waiting */
467
	atomic_t block_count;		/**< Count of processes waiting */
466
	atomic_t block_read;		/**< Queue blocked for reads */
468
	atomic_t block_read;		/**< Queue blocked for reads */
467
	wait_queue_head_t read_queue;	/**< Processes waiting on block_read */
469
	wait_queue_head_t read_queue;	/**< Processes waiting on block_read */
468
	atomic_t block_write;		/**< Queue blocked for writes */
470
	atomic_t block_write;		/**< Queue blocked for writes */
469
	wait_queue_head_t write_queue;	/**< Processes waiting on block_write */
471
	wait_queue_head_t write_queue;	/**< Processes waiting on block_write */
470
	atomic_t total_queued;		/**< Total queued statistic */
472
	atomic_t total_queued;		/**< Total queued statistic */
471
	atomic_t total_flushed;		/**< Total flushes statistic */
473
	atomic_t total_flushed;		/**< Total flushes statistic */
472
	atomic_t total_locks;		/**< Total locks statistics */
474
	atomic_t total_locks;		/**< Total locks statistics */
473
	enum drm_ctx_flags flags;	/**< Context preserving and 2D-only */
475
	enum drm_ctx_flags flags;	/**< Context preserving and 2D-only */
474
	struct drm_waitlist waitlist;	/**< Pending buffers */
476
	struct drm_waitlist waitlist;	/**< Pending buffers */
475
	wait_queue_head_t flush_queue;	/**< Processes waiting until flush */
477
	wait_queue_head_t flush_queue;	/**< Processes waiting until flush */
476
};
478
};
477
 
479
 
478
/**
480
/**
479
 * Lock data.
481
 * Lock data.
480
 */
482
 */
481
struct drm_lock_data {
483
struct drm_lock_data {
482
	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
484
	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
483
	/** Private of lock holder's file (NULL=kernel) */
485
	/** Private of lock holder's file (NULL=kernel) */
484
	struct drm_file *file_priv;
486
	struct drm_file *file_priv;
485
	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
487
	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
486
	unsigned long lock_time;	/**< Time of last lock in jiffies */
488
	unsigned long lock_time;	/**< Time of last lock in jiffies */
487
	spinlock_t spinlock;
489
	spinlock_t spinlock;
488
	uint32_t kernel_waiters;
490
	uint32_t kernel_waiters;
489
	uint32_t user_waiters;
491
	uint32_t user_waiters;
490
	int idle_has_lock;
492
	int idle_has_lock;
491
};
493
};
492
 
494
 
493
/**
495
/**
494
 * DMA data.
496
 * DMA data.
495
 */
497
 */
496
struct drm_device_dma {
498
struct drm_device_dma {
497
 
499
 
498
	struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];	/**< buffers, grouped by their size order */
500
	struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];	/**< buffers, grouped by their size order */
499
	int buf_count;			/**< total number of buffers */
501
	int buf_count;			/**< total number of buffers */
500
	struct drm_buf **buflist;		/**< Vector of pointers into drm_device_dma::bufs */
502
	struct drm_buf **buflist;		/**< Vector of pointers into drm_device_dma::bufs */
501
	int seg_count;
503
	int seg_count;
502
	int page_count;			/**< number of pages */
504
	int page_count;			/**< number of pages */
503
	unsigned long *pagelist;	/**< page list */
505
	unsigned long *pagelist;	/**< page list */
504
	unsigned long byte_count;
506
	unsigned long byte_count;
505
	enum {
507
	enum {
506
		_DRM_DMA_USE_AGP = 0x01,
508
		_DRM_DMA_USE_AGP = 0x01,
507
		_DRM_DMA_USE_SG = 0x02,
509
		_DRM_DMA_USE_SG = 0x02,
508
		_DRM_DMA_USE_FB = 0x04,
510
		_DRM_DMA_USE_FB = 0x04,
509
		_DRM_DMA_USE_PCI_RO = 0x08
511
		_DRM_DMA_USE_PCI_RO = 0x08
510
	} flags;
512
	} flags;
511
 
513
 
512
};
514
};
513
 
515
 
514
/**
516
/**
515
 * AGP memory entry.  Stored as a doubly linked list.
517
 * AGP memory entry.  Stored as a doubly linked list.
516
 */
518
 */
517
struct drm_agp_mem {
519
struct drm_agp_mem {
518
	unsigned long handle;		/**< handle */
520
	unsigned long handle;		/**< handle */
519
	DRM_AGP_MEM *memory;
521
	DRM_AGP_MEM *memory;
520
	unsigned long bound;		/**< address */
522
	unsigned long bound;		/**< address */
521
	int pages;
523
	int pages;
522
	struct list_head head;
524
	struct list_head head;
523
};
525
};
524
 
526
 
525
/**
527
/**
526
 * AGP data.
528
 * AGP data.
527
 *
529
 *
528
 * \sa drm_agp_init() and drm_device::agp.
530
 * \sa drm_agp_init() and drm_device::agp.
529
 */
531
 */
530
struct drm_agp_head {
532
struct drm_agp_head {
531
	DRM_AGP_KERN agp_info;		/**< AGP device information */
533
	DRM_AGP_KERN agp_info;		/**< AGP device information */
532
	struct list_head memory;
534
	struct list_head memory;
533
	unsigned long mode;		/**< AGP mode */
535
	unsigned long mode;		/**< AGP mode */
534
	struct agp_bridge_data *bridge;
536
	struct agp_bridge_data *bridge;
535
	int enabled;			/**< whether the AGP bus as been enabled */
537
	int enabled;			/**< whether the AGP bus as been enabled */
536
	int acquired;			/**< whether the AGP device has been acquired */
538
	int acquired;			/**< whether the AGP device has been acquired */
537
	unsigned long base;
539
	unsigned long base;
538
	int agp_mtrr;
540
	int agp_mtrr;
539
	int cant_use_aperture;
541
	int cant_use_aperture;
540
	unsigned long page_mask;
542
	unsigned long page_mask;
541
};
543
};
542
 
544
 
543
/**
545
/**
544
 * Scatter-gather memory.
546
 * Scatter-gather memory.
545
 */
547
 */
546
struct drm_sg_mem {
548
struct drm_sg_mem {
547
	unsigned long handle;
549
	unsigned long handle;
548
	void *virtual;
550
	void *virtual;
549
	int pages;
551
	int pages;
550
	struct page **pagelist;
552
	struct page **pagelist;
551
	dma_addr_t *busaddr;
553
	dma_addr_t *busaddr;
552
};
554
};
553
 
555
 
554
struct drm_sigdata {
556
struct drm_sigdata {
555
	int context;
557
	int context;
556
	struct drm_hw_lock *lock;
558
	struct drm_hw_lock *lock;
557
};
559
};
558
 
560
 
559
#endif
561
#endif
560
 
562
 
561
 
563
 
562
/**
564
/**
563
 * Kernel side of a mapping
565
 * Kernel side of a mapping
564
 */
566
 */
565
struct drm_local_map {
567
struct drm_local_map {
566
	resource_size_t offset;	 /**< Requested physical address (0 for SAREA)*/
568
	resource_size_t offset;	 /**< Requested physical address (0 for SAREA)*/
567
	unsigned long size;	 /**< Requested physical size (bytes) */
569
	unsigned long size;	 /**< Requested physical size (bytes) */
568
	enum drm_map_type type;	 /**< Type of memory to map */
570
	enum drm_map_type type;	 /**< Type of memory to map */
569
	enum drm_map_flags flags;	 /**< Flags */
571
	enum drm_map_flags flags;	 /**< Flags */
570
	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
572
	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
571
				 /**< Kernel-space: kernel-virtual address */
573
				 /**< Kernel-space: kernel-virtual address */
572
	int mtrr;		 /**< MTRR slot used */
574
	int mtrr;		 /**< MTRR slot used */
573
};
575
};
574
 
576
 
575
typedef struct drm_local_map drm_local_map_t;
577
typedef struct drm_local_map drm_local_map_t;
576
 
578
 
577
#if 0
579
#if 0
578
/**
580
/**
579
 * Mappings list
581
 * Mappings list
580
 */
582
 */
581
struct drm_map_list {
583
struct drm_map_list {
582
	struct list_head head;		/**< list head */
584
	struct list_head head;		/**< list head */
583
	struct drm_hash_item hash;
585
	struct drm_hash_item hash;
584
	struct drm_local_map *map;	/**< mapping */
586
	struct drm_local_map *map;	/**< mapping */
585
	uint64_t user_token;
587
	uint64_t user_token;
586
	struct drm_master *master;
588
	struct drm_master *master;
587
	struct drm_mm_node *file_offset_node;	/**< fake offset */
589
	struct drm_mm_node *file_offset_node;	/**< fake offset */
588
};
590
};
589
 
591
 
590
/**
592
/**
591
 * Context handle list
593
 * Context handle list
592
 */
594
 */
593
struct drm_ctx_list {
595
struct drm_ctx_list {
594
	struct list_head head;		/**< list head */
596
	struct list_head head;		/**< list head */
595
	drm_context_t handle;		/**< context handle */
597
	drm_context_t handle;		/**< context handle */
596
	struct drm_file *tag;		/**< associated fd private data */
598
	struct drm_file *tag;		/**< associated fd private data */
597
};
599
};
598
 
600
 
599
/* location of GART table */
601
/* location of GART table */
600
#define DRM_ATI_GART_MAIN 1
602
#define DRM_ATI_GART_MAIN 1
601
#define DRM_ATI_GART_FB   2
603
#define DRM_ATI_GART_FB   2
602
 
604
 
603
#define DRM_ATI_GART_PCI 1
605
#define DRM_ATI_GART_PCI 1
604
#define DRM_ATI_GART_PCIE 2
606
#define DRM_ATI_GART_PCIE 2
605
#define DRM_ATI_GART_IGP 3
607
#define DRM_ATI_GART_IGP 3
606
 
608
 
607
struct drm_ati_pcigart_info {
609
struct drm_ati_pcigart_info {
608
	int gart_table_location;
610
	int gart_table_location;
609
	int gart_reg_if;
611
	int gart_reg_if;
610
	void *addr;
612
	void *addr;
611
	dma_addr_t bus_addr;
613
	dma_addr_t bus_addr;
612
	dma_addr_t table_mask;
614
	dma_addr_t table_mask;
613
	struct drm_dma_handle *table_handle;
615
	struct drm_dma_handle *table_handle;
614
	struct drm_local_map mapping;
616
	struct drm_local_map mapping;
615
	int table_size;
617
	int table_size;
616
};
618
};
617
 
619
 
618
/**
620
/**
619
 * GEM specific mm private for tracking GEM objects
621
 * GEM specific mm private for tracking GEM objects
620
 */
622
 */
621
struct drm_gem_mm {
623
struct drm_gem_mm {
622
	struct drm_mm offset_manager;	/**< Offset mgmt for buffer objects */
624
	struct drm_mm offset_manager;	/**< Offset mgmt for buffer objects */
623
	struct drm_open_hash offset_hash; /**< User token hash table for maps */
625
	struct drm_open_hash offset_hash; /**< User token hash table for maps */
624
};
626
};
625
 
627
 
626
#endif
628
#endif
627
 
629
 
628
/**
630
/**
629
 * This structure defines the drm_mm memory object, which will be used by the
631
 * This structure defines the drm_mm memory object, which will be used by the
630
 * DRM for its buffer objects.
632
 * DRM for its buffer objects.
631
 */
633
 */
632
struct drm_gem_object {
634
struct drm_gem_object {
633
	/** Reference count of this object */
635
	/** Reference count of this object */
634
	struct kref refcount;
636
	struct kref refcount;
635
 
637
 
636
	/** Handle count of this object. Each handle also holds a reference */
638
	/** Handle count of this object. Each handle also holds a reference */
637
	atomic_t handle_count; /* number of handles on this object */
639
	atomic_t handle_count; /* number of handles on this object */
638
 
640
 
639
	/** Related drm device */
641
	/** Related drm device */
640
	struct drm_device *dev;
642
	struct drm_device *dev;
641
 
643
 
642
	/** File representing the shmem storage */
644
	/** File representing the shmem storage */
643
	struct file *filp;
645
	struct file *filp;
644
 
646
 
645
	/* Mapping info for this object */
647
	/* Mapping info for this object */
646
 
648
 
647
	/**
649
	/**
648
	 * Size of the object, in bytes.  Immutable over the object's
650
	 * Size of the object, in bytes.  Immutable over the object's
649
	 * lifetime.
651
	 * lifetime.
650
	 */
652
	 */
651
	size_t size;
653
	size_t size;
652
 
654
 
653
	/**
655
	/**
654
	 * Global name for this object, starts at 1. 0 means unnamed.
656
	 * Global name for this object, starts at 1. 0 means unnamed.
655
	 * Access is covered by the object_name_lock in the related drm_device
657
	 * Access is covered by the object_name_lock in the related drm_device
656
	 */
658
	 */
657
	int name;
659
	int name;
658
 
660
 
659
	/**
661
	/**
660
	 * Memory domains. These monitor which caches contain read/write data
662
	 * Memory domains. These monitor which caches contain read/write data
661
	 * related to the object. When transitioning from one set of domains
663
	 * related to the object. When transitioning from one set of domains
662
	 * to another, the driver is called to ensure that caches are suitably
664
	 * to another, the driver is called to ensure that caches are suitably
663
	 * flushed and invalidated
665
	 * flushed and invalidated
664
	 */
666
	 */
665
	uint32_t read_domains;
667
	uint32_t read_domains;
666
	uint32_t write_domain;
668
	uint32_t write_domain;
667
 
669
 
668
	/**
670
	/**
669
	 * While validating an exec operation, the
671
	 * While validating an exec operation, the
670
	 * new read/write domain values are computed here.
672
	 * new read/write domain values are computed here.
671
	 * They will be transferred to the above values
673
	 * They will be transferred to the above values
672
	 * at the point that any cache flushing occurs
674
	 * at the point that any cache flushing occurs
673
	 */
675
	 */
674
	uint32_t pending_read_domains;
676
	uint32_t pending_read_domains;
675
	uint32_t pending_write_domain;
677
	uint32_t pending_write_domain;
676
 
678
 
677
	void *driver_private;
679
	void *driver_private;
678
};
680
};
679
 
681
 
680
#include 
682
#include 
681
 
683
 
682
/* per-master structure */
684
/* per-master structure */
683
struct drm_master {
685
struct drm_master {
684
 
686
 
685
	struct kref refcount; /* refcount for this master */
687
	struct kref refcount; /* refcount for this master */
686
 
688
 
687
	struct list_head head; /**< each minor contains a list of masters */
689
	struct list_head head; /**< each minor contains a list of masters */
688
	struct drm_minor *minor; /**< link back to minor we are a master for */
690
	struct drm_minor *minor; /**< link back to minor we are a master for */
689
 
691
 
690
	char *unique;			/**< Unique identifier: e.g., busid */
692
	char *unique;			/**< Unique identifier: e.g., busid */
691
	int unique_len;			/**< Length of unique field */
693
	int unique_len;			/**< Length of unique field */
692
	int unique_size;		/**< amount allocated */
694
	int unique_size;		/**< amount allocated */
693
 
695
 
694
	int blocked;			/**< Blocked due to VC switch? */
696
	int blocked;			/**< Blocked due to VC switch? */
695
 
697
 
696
	/** \name Authentication */
698
	/** \name Authentication */
697
	/*@{ */
699
	/*@{ */
698
//   struct drm_open_hash magiclist;
700
//   struct drm_open_hash magiclist;
699
//   struct list_head magicfree;
701
//   struct list_head magicfree;
700
	/*@} */
702
	/*@} */
701
 
703
 
702
//   struct drm_lock_data lock;  /**< Information on hardware lock */
704
//   struct drm_lock_data lock;  /**< Information on hardware lock */
703
 
705
 
704
	void *driver_priv; /**< Private structure for driver to use */
706
	void *driver_priv; /**< Private structure for driver to use */
705
};
707
};
706
 
708
 
707
#if 0
709
#if 0
708
 
710
 
709
/* Size of ringbuffer for vblank timestamps. Just double-buffer
711
/* Size of ringbuffer for vblank timestamps. Just double-buffer
710
 * in initial implementation.
712
 * in initial implementation.
711
 */
713
 */
712
#define DRM_VBLANKTIME_RBSIZE 2
714
#define DRM_VBLANKTIME_RBSIZE 2
713
 
715
 
714
/* Flags and return codes for get_vblank_timestamp() driver function. */
716
/* Flags and return codes for get_vblank_timestamp() driver function. */
715
#define DRM_CALLED_FROM_VBLIRQ 1
717
#define DRM_CALLED_FROM_VBLIRQ 1
716
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
718
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
717
#define DRM_VBLANKTIME_INVBL             (1 << 1)
719
#define DRM_VBLANKTIME_INVBL             (1 << 1)
718
 
720
 
719
/* get_scanout_position() return flags */
721
/* get_scanout_position() return flags */
720
#define DRM_SCANOUTPOS_VALID        (1 << 0)
722
#define DRM_SCANOUTPOS_VALID        (1 << 0)
721
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
723
#define DRM_SCANOUTPOS_INVBL        (1 << 1)
722
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
724
#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
723
 
725
 
724
struct drm_bus {
726
struct drm_bus {
725
	int bus_type;
727
	int bus_type;
726
	int (*get_irq)(struct drm_device *dev);
728
	int (*get_irq)(struct drm_device *dev);
727
	const char *(*get_name)(struct drm_device *dev);
729
	const char *(*get_name)(struct drm_device *dev);
728
	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
730
	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
729
	int (*set_unique)(struct drm_device *dev, struct drm_master *master,
731
	int (*set_unique)(struct drm_device *dev, struct drm_master *master,
730
			  struct drm_unique *unique);
732
			  struct drm_unique *unique);
731
	int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
733
	int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
732
	/* hooks that are for PCI */
734
	/* hooks that are for PCI */
733
	int (*agp_init)(struct drm_device *dev);
735
	int (*agp_init)(struct drm_device *dev);
734
 
736
 
735
};
737
};
736
 
738
 
737
/**
739
/**
738
 * DRM driver structure. This structure represent the common code for
740
 * DRM driver structure. This structure represent the common code for
739
 * a family of cards. There will one drm_device for each card present
741
 * a family of cards. There will one drm_device for each card present
740
 * in this family
742
 * in this family
741
 */
743
 */
742
struct drm_driver {
744
struct drm_driver {
743
	int (*load) (struct drm_device *, unsigned long flags);
745
	int (*load) (struct drm_device *, unsigned long flags);
744
	int (*firstopen) (struct drm_device *);
746
	int (*firstopen) (struct drm_device *);
745
	int (*open) (struct drm_device *, struct drm_file *);
747
	int (*open) (struct drm_device *, struct drm_file *);
746
	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
748
	void (*preclose) (struct drm_device *, struct drm_file *file_priv);
747
	void (*postclose) (struct drm_device *, struct drm_file *);
749
	void (*postclose) (struct drm_device *, struct drm_file *);
748
	void (*lastclose) (struct drm_device *);
750
	void (*lastclose) (struct drm_device *);
749
	int (*unload) (struct drm_device *);
751
	int (*unload) (struct drm_device *);
750
	int (*suspend) (struct drm_device *, pm_message_t state);
752
	int (*suspend) (struct drm_device *, pm_message_t state);
751
	int (*resume) (struct drm_device *);
753
	int (*resume) (struct drm_device *);
752
	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
754
	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
753
	int (*dma_quiescent) (struct drm_device *);
755
	int (*dma_quiescent) (struct drm_device *);
754
	int (*context_dtor) (struct drm_device *dev, int context);
756
	int (*context_dtor) (struct drm_device *dev, int context);
755
 
757
 
756
	/**
758
	/**
757
	 * get_vblank_counter - get raw hardware vblank counter
759
	 * get_vblank_counter - get raw hardware vblank counter
758
	 * @dev: DRM device
760
	 * @dev: DRM device
759
	 * @crtc: counter to fetch
761
	 * @crtc: counter to fetch
760
	 *
762
	 *
761
	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
763
	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
762
	 * If a device doesn't have a hardware counter, the driver can simply
764
	 * If a device doesn't have a hardware counter, the driver can simply
763
	 * return the value of drm_vblank_count. The DRM core will account for
765
	 * return the value of drm_vblank_count. The DRM core will account for
764
	 * missed vblank events while interrupts where disabled based on system
766
	 * missed vblank events while interrupts where disabled based on system
765
	 * timestamps.
767
	 * timestamps.
766
	 *
768
	 *
767
	 * Wraparound handling and loss of events due to modesetting is dealt
769
	 * Wraparound handling and loss of events due to modesetting is dealt
768
	 * with in the DRM core code.
770
	 * with in the DRM core code.
769
	 *
771
	 *
770
	 * RETURNS
772
	 * RETURNS
771
	 * Raw vblank counter value.
773
	 * Raw vblank counter value.
772
	 */
774
	 */
773
	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
775
	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
774
 
776
 
775
	/**
777
	/**
776
	 * enable_vblank - enable vblank interrupt events
778
	 * enable_vblank - enable vblank interrupt events
777
	 * @dev: DRM device
779
	 * @dev: DRM device
778
	 * @crtc: which irq to enable
780
	 * @crtc: which irq to enable
779
	 *
781
	 *
780
	 * Enable vblank interrupts for @crtc.  If the device doesn't have
782
	 * Enable vblank interrupts for @crtc.  If the device doesn't have
781
	 * a hardware vblank counter, this routine should be a no-op, since
783
	 * a hardware vblank counter, this routine should be a no-op, since
782
	 * interrupts will have to stay on to keep the count accurate.
784
	 * interrupts will have to stay on to keep the count accurate.
783
	 *
785
	 *
784
	 * RETURNS
786
	 * RETURNS
785
	 * Zero on success, appropriate errno if the given @crtc's vblank
787
	 * Zero on success, appropriate errno if the given @crtc's vblank
786
	 * interrupt cannot be enabled.
788
	 * interrupt cannot be enabled.
787
	 */
789
	 */
788
	int (*enable_vblank) (struct drm_device *dev, int crtc);
790
	int (*enable_vblank) (struct drm_device *dev, int crtc);
789
 
791
 
790
	/**
792
	/**
791
	 * disable_vblank - disable vblank interrupt events
793
	 * disable_vblank - disable vblank interrupt events
792
	 * @dev: DRM device
794
	 * @dev: DRM device
793
	 * @crtc: which irq to enable
795
	 * @crtc: which irq to enable
794
	 *
796
	 *
795
	 * Disable vblank interrupts for @crtc.  If the device doesn't have
797
	 * Disable vblank interrupts for @crtc.  If the device doesn't have
796
	 * a hardware vblank counter, this routine should be a no-op, since
798
	 * a hardware vblank counter, this routine should be a no-op, since
797
	 * interrupts will have to stay on to keep the count accurate.
799
	 * interrupts will have to stay on to keep the count accurate.
798
	 */
800
	 */
799
	void (*disable_vblank) (struct drm_device *dev, int crtc);
801
	void (*disable_vblank) (struct drm_device *dev, int crtc);
800
 
802
 
801
	/**
803
	/**
802
	 * Called by \c drm_device_is_agp.  Typically used to determine if a
804
	 * Called by \c drm_device_is_agp.  Typically used to determine if a
803
	 * card is really attached to AGP or not.
805
	 * card is really attached to AGP or not.
804
	 *
806
	 *
805
	 * \param dev  DRM device handle
807
	 * \param dev  DRM device handle
806
	 *
808
	 *
807
	 * \returns
809
	 * \returns
808
	 * One of three values is returned depending on whether or not the
810
	 * One of three values is returned depending on whether or not the
809
	 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
811
	 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
810
	 * (return of 1), or may or may not be AGP (return of 2).
812
	 * (return of 1), or may or may not be AGP (return of 2).
811
	 */
813
	 */
812
	int (*device_is_agp) (struct drm_device *dev);
814
	int (*device_is_agp) (struct drm_device *dev);
813
 
815
 
814
	/**
816
	/**
815
	 * Called by vblank timestamping code.
817
	 * Called by vblank timestamping code.
816
	 *
818
	 *
817
	 * Return the current display scanout position from a crtc.
819
	 * Return the current display scanout position from a crtc.
818
	 *
820
	 *
819
	 * \param dev  DRM device.
821
	 * \param dev  DRM device.
820
	 * \param crtc Id of the crtc to query.
822
	 * \param crtc Id of the crtc to query.
821
	 * \param *vpos Target location for current vertical scanout position.
823
	 * \param *vpos Target location for current vertical scanout position.
822
	 * \param *hpos Target location for current horizontal scanout position.
824
	 * \param *hpos Target location for current horizontal scanout position.
823
	 *
825
	 *
824
	 * Returns vpos as a positive number while in active scanout area.
826
	 * Returns vpos as a positive number while in active scanout area.
825
	 * Returns vpos as a negative number inside vblank, counting the number
827
	 * Returns vpos as a negative number inside vblank, counting the number
826
	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
828
	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
827
	 * until start of active scanout / end of vblank."
829
	 * until start of active scanout / end of vblank."
828
	 *
830
	 *
829
	 * \return Flags, or'ed together as follows:
831
	 * \return Flags, or'ed together as follows:
830
	 *
832
	 *
831
	 * DRM_SCANOUTPOS_VALID = Query successful.
833
	 * DRM_SCANOUTPOS_VALID = Query successful.
832
	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
834
	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
833
	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
835
	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
834
	 * this flag means that returned position may be offset by a constant
836
	 * this flag means that returned position may be offset by a constant
835
	 * but unknown small number of scanlines wrt. real scanout position.
837
	 * but unknown small number of scanlines wrt. real scanout position.
836
	 *
838
	 *
837
	 */
839
	 */
838
	int (*get_scanout_position) (struct drm_device *dev, int crtc,
840
	int (*get_scanout_position) (struct drm_device *dev, int crtc,
839
				     int *vpos, int *hpos);
841
				     int *vpos, int *hpos);
840
 
842
 
841
	/**
843
	/**
842
	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
844
	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
843
	 * timestamp when the most recent VBLANK interval ended or will end.
845
	 * timestamp when the most recent VBLANK interval ended or will end.
844
	 *
846
	 *
845
	 * Specifically, the timestamp in @vblank_time should correspond as
847
	 * Specifically, the timestamp in @vblank_time should correspond as
846
	 * closely as possible to the time when the first video scanline of
848
	 * closely as possible to the time when the first video scanline of
847
	 * the video frame after the end of VBLANK will start scanning out,
849
	 * the video frame after the end of VBLANK will start scanning out,
848
	 * the time immediately after end of the VBLANK interval. If the
850
	 * the time immediately after end of the VBLANK interval. If the
849
	 * @crtc is currently inside VBLANK, this will be a time in the future.
851
	 * @crtc is currently inside VBLANK, this will be a time in the future.
850
	 * If the @crtc is currently scanning out a frame, this will be the
852
	 * If the @crtc is currently scanning out a frame, this will be the
851
	 * past start time of the current scanout. This is meant to adhere
853
	 * past start time of the current scanout. This is meant to adhere
852
	 * to the OpenML OML_sync_control extension specification.
854
	 * to the OpenML OML_sync_control extension specification.
853
	 *
855
	 *
854
	 * \param dev dev DRM device handle.
856
	 * \param dev dev DRM device handle.
855
	 * \param crtc crtc for which timestamp should be returned.
857
	 * \param crtc crtc for which timestamp should be returned.
856
	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
858
	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
857
	 *                   Implementation should strive to provide timestamp
859
	 *                   Implementation should strive to provide timestamp
858
	 *                   with an error of at most *max_error nanoseconds.
860
	 *                   with an error of at most *max_error nanoseconds.
859
	 *                   Returns true upper bound on error for timestamp.
861
	 *                   Returns true upper bound on error for timestamp.
860
	 * \param *vblank_time Target location for returned vblank timestamp.
862
	 * \param *vblank_time Target location for returned vblank timestamp.
861
	 * \param flags 0 = Defaults, no special treatment needed.
863
	 * \param flags 0 = Defaults, no special treatment needed.
862
	 * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
864
	 * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
863
	 *	        irq handler. Some drivers need to apply some workarounds
865
	 *	        irq handler. Some drivers need to apply some workarounds
864
	 *              for gpu-specific vblank irq quirks if flag is set.
866
	 *              for gpu-specific vblank irq quirks if flag is set.
865
	 *
867
	 *
866
	 * \returns
868
	 * \returns
867
	 * Zero if timestamping isn't supported in current display mode or a
869
	 * Zero if timestamping isn't supported in current display mode or a
868
	 * negative number on failure. A positive status code on success,
870
	 * negative number on failure. A positive status code on success,
869
	 * which describes how the vblank_time timestamp was computed.
871
	 * which describes how the vblank_time timestamp was computed.
870
	 */
872
	 */
871
	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
873
	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
872
				     int *max_error,
874
				     int *max_error,
873
				     struct timeval *vblank_time,
875
				     struct timeval *vblank_time,
874
				     unsigned flags);
876
				     unsigned flags);
875
 
877
 
876
	/* these have to be filled in */
878
	/* these have to be filled in */
877
 
879
 
878
	irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
880
	irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
879
	void (*irq_preinstall) (struct drm_device *dev);
881
	void (*irq_preinstall) (struct drm_device *dev);
880
	int (*irq_postinstall) (struct drm_device *dev);
882
	int (*irq_postinstall) (struct drm_device *dev);
881
	void (*irq_uninstall) (struct drm_device *dev);
883
	void (*irq_uninstall) (struct drm_device *dev);
882
	void (*set_version) (struct drm_device *dev,
884
	void (*set_version) (struct drm_device *dev,
883
			     struct drm_set_version *sv);
885
			     struct drm_set_version *sv);
884
 
886
 
885
	/* Master routines */
887
	/* Master routines */
886
	int (*master_create)(struct drm_device *dev, struct drm_master *master);
888
	int (*master_create)(struct drm_device *dev, struct drm_master *master);
887
	void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
889
	void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
888
	/**
890
	/**
889
	 * master_set is called whenever the minor master is set.
891
	 * master_set is called whenever the minor master is set.
890
	 * master_drop is called whenever the minor master is dropped.
892
	 * master_drop is called whenever the minor master is dropped.
891
	 */
893
	 */
892
 
894
 
893
	int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
895
	int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
894
			  bool from_open);
896
			  bool from_open);
895
	void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
897
	void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
896
			    bool from_release);
898
			    bool from_release);
897
 
899
 
898
	int (*debugfs_init)(struct drm_minor *minor);
900
	int (*debugfs_init)(struct drm_minor *minor);
899
	void (*debugfs_cleanup)(struct drm_minor *minor);
901
	void (*debugfs_cleanup)(struct drm_minor *minor);
900
 
902
 
901
	/**
903
	/**
902
	 * Driver-specific constructor for drm_gem_objects, to set up
904
	 * Driver-specific constructor for drm_gem_objects, to set up
903
	 * obj->driver_private.
905
	 * obj->driver_private.
904
	 *
906
	 *
905
	 * Returns 0 on success.
907
	 * Returns 0 on success.
906
	 */
908
	 */
907
	int (*gem_init_object) (struct drm_gem_object *obj);
909
	int (*gem_init_object) (struct drm_gem_object *obj);
908
	void (*gem_free_object) (struct drm_gem_object *obj);
910
	void (*gem_free_object) (struct drm_gem_object *obj);
909
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
911
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
910
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
912
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
911
 
913
 
912
	/* prime: */
914
	/* prime: */
913
	/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
915
	/* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
914
	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
916
	int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
915
				uint32_t handle, uint32_t flags, int *prime_fd);
917
				uint32_t handle, uint32_t flags, int *prime_fd);
916
	/* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
918
	/* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
917
	int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
919
	int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
918
				int prime_fd, uint32_t *handle);
920
				int prime_fd, uint32_t *handle);
919
	/* export GEM -> dmabuf */
921
	/* export GEM -> dmabuf */
920
	struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
922
	struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
921
				struct drm_gem_object *obj, int flags);
923
				struct drm_gem_object *obj, int flags);
922
	/* import dmabuf -> GEM */
924
	/* import dmabuf -> GEM */
923
	struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
925
	struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
924
				struct dma_buf *dma_buf);
926
				struct dma_buf *dma_buf);
925
 
927
 
926
	/* vga arb irq handler */
928
	/* vga arb irq handler */
927
	void (*vgaarb_irq)(struct drm_device *dev, bool state);
929
	void (*vgaarb_irq)(struct drm_device *dev, bool state);
928
 
930
 
929
	/* dumb alloc support */
931
	/* dumb alloc support */
930
	int (*dumb_create)(struct drm_file *file_priv,
932
	int (*dumb_create)(struct drm_file *file_priv,
931
			   struct drm_device *dev,
933
			   struct drm_device *dev,
932
			   struct drm_mode_create_dumb *args);
934
			   struct drm_mode_create_dumb *args);
933
	int (*dumb_map_offset)(struct drm_file *file_priv,
935
	int (*dumb_map_offset)(struct drm_file *file_priv,
934
			       struct drm_device *dev, uint32_t handle,
936
			       struct drm_device *dev, uint32_t handle,
935
			       uint64_t *offset);
937
			       uint64_t *offset);
936
	int (*dumb_destroy)(struct drm_file *file_priv,
938
	int (*dumb_destroy)(struct drm_file *file_priv,
937
			    struct drm_device *dev,
939
			    struct drm_device *dev,
938
			    uint32_t handle);
940
			    uint32_t handle);
939
 
941
 
940
	/* Driver private ops for this object */
942
	/* Driver private ops for this object */
941
	const struct vm_operations_struct *gem_vm_ops;
943
	const struct vm_operations_struct *gem_vm_ops;
942
 
944
 
943
	int major;
945
	int major;
944
	int minor;
946
	int minor;
945
	int patchlevel;
947
	int patchlevel;
946
	char *name;
948
	char *name;
947
	char *desc;
949
	char *desc;
948
	char *date;
950
	char *date;
949
 
951
 
950
	u32 driver_features;
952
	u32 driver_features;
951
	int dev_priv_size;
953
	int dev_priv_size;
952
	struct drm_ioctl_desc *ioctls;
954
	struct drm_ioctl_desc *ioctls;
953
	int num_ioctls;
955
	int num_ioctls;
954
	const struct file_operations *fops;
956
	const struct file_operations *fops;
955
	union {
957
	union {
956
		struct pci_driver *pci;
958
		struct pci_driver *pci;
957
		struct platform_device *platform_device;
959
		struct platform_device *platform_device;
958
		struct usb_driver *usb;
960
		struct usb_driver *usb;
959
	} kdriver;
961
	} kdriver;
960
	struct drm_bus *bus;
962
	struct drm_bus *bus;
961
 
963
 
962
	/* List of devices hanging off this driver */
964
	/* List of devices hanging off this driver */
963
	struct list_head device_list;
965
	struct list_head device_list;
964
};
966
};
965
 
967
 
966
#endif
968
#endif
967
 
969
 
968
#define DRM_IRQ_ARGS            int irq, void *arg 
970
#define DRM_IRQ_ARGS            int irq, void *arg 
969
 
971
 
970
struct drm_driver {
972
struct drm_driver {
971
	int (*open) (struct drm_device *, struct drm_file *);
973
	int (*open) (struct drm_device *, struct drm_file *);
972
 
974
 
973
    irqreturn_t (*irq_handler) (DRM_IRQ_ARGS);
975
    irqreturn_t (*irq_handler) (DRM_IRQ_ARGS);
974
    void (*irq_preinstall) (struct drm_device *dev);
976
    void (*irq_preinstall) (struct drm_device *dev);
975
    int (*irq_postinstall) (struct drm_device *dev);
977
    int (*irq_postinstall) (struct drm_device *dev);
976
 
978
 
977
	int (*gem_init_object) (struct drm_gem_object *obj);
979
	int (*gem_init_object) (struct drm_gem_object *obj);
978
	void (*gem_free_object) (struct drm_gem_object *obj);
980
	void (*gem_free_object) (struct drm_gem_object *obj);
979
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
981
	int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
980
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
982
	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
981
	u32 driver_features;
983
	u32 driver_features;
982
}; 
984
}; 
983
 
985
 
984
 
986
 
985
#define DRM_MINOR_UNASSIGNED 0
987
#define DRM_MINOR_UNASSIGNED 0
986
#define DRM_MINOR_LEGACY 1
988
#define DRM_MINOR_LEGACY 1
987
#define DRM_MINOR_CONTROL 2
989
#define DRM_MINOR_CONTROL 2
988
#define DRM_MINOR_RENDER 3
990
#define DRM_MINOR_RENDER 3
989
 
991
 
990
 
992
 
991
/**
993
/**
992
 * debugfs node list. This structure represents a debugfs file to
994
 * debugfs node list. This structure represents a debugfs file to
993
 * be created by the drm core
995
 * be created by the drm core
994
 */
996
 */
995
struct drm_debugfs_list {
997
struct drm_debugfs_list {
996
	const char *name; /** file name */
998
	const char *name; /** file name */
997
//   int (*show)(struct seq_file*, void*); /** show callback */
999
//   int (*show)(struct seq_file*, void*); /** show callback */
998
	u32 driver_features; /**< Required driver features for this entry */
1000
	u32 driver_features; /**< Required driver features for this entry */
999
};
1001
};
1000
 
1002
 
1001
/**
1003
/**
1002
 * debugfs node structure. This structure represents a debugfs file.
1004
 * debugfs node structure. This structure represents a debugfs file.
1003
 */
1005
 */
1004
struct drm_debugfs_node {
1006
struct drm_debugfs_node {
1005
	struct list_head list;
1007
	struct list_head list;
1006
	struct drm_minor *minor;
1008
	struct drm_minor *minor;
1007
	struct drm_debugfs_list *debugfs_ent;
1009
	struct drm_debugfs_list *debugfs_ent;
1008
	struct dentry *dent;
1010
	struct dentry *dent;
1009
};
1011
};
1010
 
1012
 
1011
/**
1013
/**
1012
 * Info file list entry. This structure represents a debugfs or proc file to
1014
 * Info file list entry. This structure represents a debugfs or proc file to
1013
 * be created by the drm core
1015
 * be created by the drm core
1014
 */
1016
 */
1015
struct drm_info_list {
1017
struct drm_info_list {
1016
	const char *name; /** file name */
1018
	const char *name; /** file name */
1017
//   int (*show)(struct seq_file*, void*); /** show callback */
1019
//   int (*show)(struct seq_file*, void*); /** show callback */
1018
	u32 driver_features; /**< Required driver features for this entry */
1020
	u32 driver_features; /**< Required driver features for this entry */
1019
	void *data;
1021
	void *data;
1020
};
1022
};
1021
 
1023
 
1022
/**
1024
/**
1023
 * debugfs node structure. This structure represents a debugfs file.
1025
 * debugfs node structure. This structure represents a debugfs file.
1024
 */
1026
 */
1025
struct drm_info_node {
1027
struct drm_info_node {
1026
	struct list_head list;
1028
	struct list_head list;
1027
	struct drm_minor *minor;
1029
	struct drm_minor *minor;
1028
	struct drm_info_list *info_ent;
1030
	struct drm_info_list *info_ent;
1029
	struct dentry *dent;
1031
	struct dentry *dent;
1030
};
1032
};
1031
 
1033
 
1032
/**
1034
/**
1033
 * DRM minor structure. This structure represents a drm minor number.
1035
 * DRM minor structure. This structure represents a drm minor number.
1034
 */
1036
 */
1035
struct drm_minor {
1037
struct drm_minor {
1036
	int index;			/**< Minor device number */
1038
	int index;			/**< Minor device number */
1037
	int type;                       /**< Control or render */
1039
	int type;                       /**< Control or render */
1038
//   dev_t device;           /**< Device number for mknod */
1040
//   dev_t device;           /**< Device number for mknod */
1039
//   struct device kdev;     /**< Linux device */
1041
//   struct device kdev;     /**< Linux device */
1040
	struct drm_device *dev;
1042
	struct drm_device *dev;
1041
 
1043
 
1042
//   struct proc_dir_entry *proc_root;  /**< proc directory entry */
1044
//   struct proc_dir_entry *proc_root;  /**< proc directory entry */
1043
//   struct drm_info_node proc_nodes;
1045
//   struct drm_info_node proc_nodes;
1044
//   struct dentry *debugfs_root;
1046
//   struct dentry *debugfs_root;
1045
//   struct drm_info_node debugfs_nodes;
1047
//   struct drm_info_node debugfs_nodes;
1046
 
1048
 
1047
    struct drm_master *master; /* currently active master for this node */
1049
    struct drm_master *master; /* currently active master for this node */
1048
//   struct list_head master_list;
1050
//   struct list_head master_list;
1049
//   struct drm_mode_group mode_group;
1051
//   struct drm_mode_group mode_group;
1050
};
1052
};
1051
 
1053
 
1052
/* mode specified on the command line */
1054
/* mode specified on the command line */
1053
struct drm_cmdline_mode {
1055
struct drm_cmdline_mode {
1054
	bool specified;
1056
	bool specified;
1055
	bool refresh_specified;
1057
	bool refresh_specified;
1056
	bool bpp_specified;
1058
	bool bpp_specified;
1057
	int xres, yres;
1059
	int xres, yres;
1058
	int bpp;
1060
	int bpp;
1059
	int refresh;
1061
	int refresh;
1060
	bool rb;
1062
	bool rb;
1061
	bool interlace;
1063
	bool interlace;
1062
	bool cvt;
1064
	bool cvt;
1063
	bool margins;
1065
	bool margins;
1064
	enum drm_connector_force force;
1066
	enum drm_connector_force force;
1065
};
1067
};
1066
 
1068
 
1067
 
1069
 
1068
 
1070
 
1069
/**
1071
/**
1070
 * DRM device structure. This structure represent a complete card that
1072
 * DRM device structure. This structure represent a complete card that
1071
 * may contain multiple heads.
1073
 * may contain multiple heads.
1072
 */
1074
 */
1073
struct drm_device {
1075
struct drm_device {
1074
	struct list_head driver_item;	/**< list of devices per driver */
1076
	struct list_head driver_item;	/**< list of devices per driver */
1075
	char *devname;			/**< For /proc/interrupts */
1077
	char *devname;			/**< For /proc/interrupts */
1076
	int if_version;			/**< Highest interface version set */
1078
	int if_version;			/**< Highest interface version set */
1077
 
1079
 
1078
	/** \name Locks */
1080
	/** \name Locks */
1079
	/*@{ */
1081
	/*@{ */
1080
    spinlock_t count_lock;      /**< For inuse, drm_device::open_count, drm_device::buf_use */
1082
    spinlock_t count_lock;      /**< For inuse, drm_device::open_count, drm_device::buf_use */
1081
	struct mutex struct_mutex;	/**< For others */
1083
	struct mutex struct_mutex;	/**< For others */
1082
	/*@} */
1084
	/*@} */
1083
 
1085
 
1084
	/** \name Usage Counters */
1086
	/** \name Usage Counters */
1085
	/*@{ */
1087
	/*@{ */
1086
	int open_count;			/**< Outstanding files open */
1088
	int open_count;			/**< Outstanding files open */
1087
   atomic_t ioctl_count;       /**< Outstanding IOCTLs pending */
1089
   atomic_t ioctl_count;       /**< Outstanding IOCTLs pending */
1088
   atomic_t vma_count;     /**< Outstanding vma areas open */
1090
   atomic_t vma_count;     /**< Outstanding vma areas open */
1089
	int buf_use;			/**< Buffers in use -- cannot alloc */
1091
	int buf_use;			/**< Buffers in use -- cannot alloc */
1090
   atomic_t buf_alloc;     /**< Buffer allocation in progress */
1092
   atomic_t buf_alloc;     /**< Buffer allocation in progress */
1091
	/*@} */
1093
	/*@} */
1092
 
1094
 
1093
	/** \name Performance counters */
1095
	/** \name Performance counters */
1094
	/*@{ */
1096
	/*@{ */
1095
	unsigned long counters;
1097
	unsigned long counters;
1096
//   enum drm_stat_type types[15];
1098
//   enum drm_stat_type types[15];
1097
   atomic_t counts[15];
1099
   atomic_t counts[15];
1098
	/*@} */
1100
	/*@} */
1099
 
1101
 
1100
	struct list_head filelist;
1102
	struct list_head filelist;
1101
 
1103
 
1102
	/** \name Memory management */
1104
	/** \name Memory management */
1103
	/*@{ */
1105
	/*@{ */
1104
	struct list_head maplist;	/**< Linked list of regions */
1106
	struct list_head maplist;	/**< Linked list of regions */
1105
	int map_count;			/**< Number of mappable regions */
1107
	int map_count;			/**< Number of mappable regions */
1106
//   struct drm_open_hash map_hash;  /**< User token hash table for maps */
1108
//   struct drm_open_hash map_hash;  /**< User token hash table for maps */
1107
 
1109
 
1108
	/** \name Context handle management */
1110
	/** \name Context handle management */
1109
	/*@{ */
1111
	/*@{ */
1110
	struct list_head ctxlist;	/**< Linked list of context handles */
1112
	struct list_head ctxlist;	/**< Linked list of context handles */
1111
	int ctx_count;			/**< Number of context handles */
1113
	int ctx_count;			/**< Number of context handles */
1112
	struct mutex ctxlist_mutex;	/**< For ctxlist */
1114
	struct mutex ctxlist_mutex;	/**< For ctxlist */
1113
 
1115
 
1114
	struct idr ctx_idr;
1116
	struct idr ctx_idr;
1115
 
1117
 
1116
	struct list_head vmalist;	/**< List of vmas (for debugging) */
1118
	struct list_head vmalist;	/**< List of vmas (for debugging) */
1117
 
1119
 
1118
	/*@} */
1120
	/*@} */
1119
 
1121
 
1120
	/** \name DMA support */
1122
	/** \name DMA support */
1121
	/*@{ */
1123
	/*@{ */
1122
//   struct drm_device_dma *dma;     /**< Optional pointer for DMA support */
1124
//   struct drm_device_dma *dma;     /**< Optional pointer for DMA support */
1123
	/*@} */
1125
	/*@} */
1124
 
1126
 
1125
	/** \name Context support */
1127
	/** \name Context support */
1126
	/*@{ */
1128
	/*@{ */
1127
	int irq_enabled;		/**< True if irq handler is enabled */
1129
	int irq_enabled;		/**< True if irq handler is enabled */
1128
	__volatile__ long context_flag;	/**< Context swapping flag */
1130
	__volatile__ long context_flag;	/**< Context swapping flag */
1129
	__volatile__ long interrupt_flag; /**< Interruption handler flag */
1131
	__volatile__ long interrupt_flag; /**< Interruption handler flag */
1130
	__volatile__ long dma_flag;	/**< DMA dispatch flag */
1132
	__volatile__ long dma_flag;	/**< DMA dispatch flag */
1131
//   wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
1133
//   wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
1132
	int last_checked;		/**< Last context checked for DMA */
1134
	int last_checked;		/**< Last context checked for DMA */
1133
	int last_context;		/**< Last current context */
1135
	int last_context;		/**< Last current context */
1134
	unsigned long last_switch;	/**< jiffies at last context switch */
1136
	unsigned long last_switch;	/**< jiffies at last context switch */
1135
	/*@} */
1137
	/*@} */
1136
 
1138
 
1137
//   struct work_struct work;
1139
//   struct work_struct work;
1138
	/** \name VBLANK IRQ support */
1140
	/** \name VBLANK IRQ support */
1139
	/*@{ */
1141
	/*@{ */
1140
 
1142
 
1141
	/*
1143
	/*
1142
	 * At load time, disabling the vblank interrupt won't be allowed since
1144
	 * At load time, disabling the vblank interrupt won't be allowed since
1143
	 * old clients may not call the modeset ioctl and therefore misbehave.
1145
	 * old clients may not call the modeset ioctl and therefore misbehave.
1144
	 * Once the modeset ioctl *has* been called though, we can safely
1146
	 * Once the modeset ioctl *has* been called though, we can safely
1145
	 * disable them when unused.
1147
	 * disable them when unused.
1146
	 */
1148
	 */
1147
	int vblank_disable_allowed;
1149
	int vblank_disable_allowed;
1148
 
1150
 
1149
//   wait_queue_head_t *vbl_queue;   /**< VBLANK wait queue */
1151
//   wait_queue_head_t *vbl_queue;   /**< VBLANK wait queue */
1150
   atomic_t *_vblank_count;        /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
1152
   atomic_t *_vblank_count;        /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
1151
	struct timeval *_vblank_time;   /**< timestamp of current vblank_count (drivers must alloc right number of fields) */
1153
	struct timeval *_vblank_time;   /**< timestamp of current vblank_count (drivers must alloc right number of fields) */
1152
	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
1154
	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
1153
   spinlock_t vbl_lock;
1155
   spinlock_t vbl_lock;
1154
   atomic_t *vblank_refcount;      /* number of users of vblank interruptsper crtc */
1156
   atomic_t *vblank_refcount;      /* number of users of vblank interruptsper crtc */
1155
	u32 *last_vblank;               /* protected by dev->vbl_lock, used */
1157
	u32 *last_vblank;               /* protected by dev->vbl_lock, used */
1156
					/* for wraparound handling */
1158
					/* for wraparound handling */
1157
	int *vblank_enabled;            /* so we don't call enable more than
1159
	int *vblank_enabled;            /* so we don't call enable more than
1158
					   once per disable */
1160
					   once per disable */
1159
	int *vblank_inmodeset;          /* Display driver is setting mode */
1161
	int *vblank_inmodeset;          /* Display driver is setting mode */
1160
	u32 *last_vblank_wait;		/* Last vblank seqno waited per CRTC */
1162
	u32 *last_vblank_wait;		/* Last vblank seqno waited per CRTC */
1161
//   struct timer_list vblank_disable_timer;
1163
//   struct timer_list vblank_disable_timer;
1162
 
1164
 
1163
	u32 max_vblank_count;           /**< size of vblank counter register */
1165
	u32 max_vblank_count;           /**< size of vblank counter register */
1164
 
1166
 
1165
	/**
1167
	/**
1166
	 * List of events
1168
	 * List of events
1167
	 */
1169
	 */
1168
	struct list_head vblank_event_list;
1170
	struct list_head vblank_event_list;
1169
	spinlock_t event_lock;
1171
	spinlock_t event_lock;
1170
 
1172
 
1171
	/*@} */
1173
	/*@} */
1172
//   cycles_t ctx_start;
1174
//   cycles_t ctx_start;
1173
//   cycles_t lck_start;
1175
//   cycles_t lck_start;
1174
 
1176
 
1175
//   struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
1177
//   struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
1176
//   wait_queue_head_t buf_readers;  /**< Processes waiting to read */
1178
//   wait_queue_head_t buf_readers;  /**< Processes waiting to read */
1177
//   wait_queue_head_t buf_writers;  /**< Processes waiting to ctx switch */
1179
//   wait_queue_head_t buf_writers;  /**< Processes waiting to ctx switch */
1178
 
1180
 
1179
//   struct drm_agp_head *agp;   /**< AGP data */
1181
//   struct drm_agp_head *agp;   /**< AGP data */
1180
 
1182
 
1181
	struct device *dev;             /**< Device structure */
1183
	struct device *dev;             /**< Device structure */
1182
	struct pci_dev *pdev;		/**< PCI device structure */
1184
	struct pci_dev *pdev;		/**< PCI device structure */
1183
	int pci_vendor;			/**< PCI vendor id */
1185
	int pci_vendor;			/**< PCI vendor id */
1184
	int pci_device;			/**< PCI device id */
1186
	int pci_device;			/**< PCI device id */
1185
	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
1187
	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
1186
	void *dev_private;		/**< device private data */
1188
	void *dev_private;		/**< device private data */
1187
	void *mm_private;
1189
	void *mm_private;
1188
    struct address_space *dev_mapping;
1190
    struct address_space *dev_mapping;
1189
//   struct drm_sigdata sigdata;    /**< For block_all_signals */
1191
//   struct drm_sigdata sigdata;    /**< For block_all_signals */
1190
//   sigset_t sigmask;
1192
//   sigset_t sigmask;
1191
 
1193
 
1192
	struct drm_driver *driver;
1194
	struct drm_driver *driver;
1193
//   struct drm_local_map *agp_buffer_map;
1195
//   struct drm_local_map *agp_buffer_map;
1194
//   unsigned int agp_buffer_token;
1196
//   unsigned int agp_buffer_token;
1195
//   struct drm_minor *control;      /**< Control node for card */
1197
//   struct drm_minor *control;      /**< Control node for card */
1196
   struct drm_minor *primary;      /**< render type primary screen head */
1198
   struct drm_minor *primary;      /**< render type primary screen head */
1197
 
1199
 
1198
        struct drm_mode_config mode_config;	/**< Current mode config */
1200
        struct drm_mode_config mode_config;	/**< Current mode config */
1199
 
1201
 
1200
	/** \name GEM information */
1202
	/** \name GEM information */
1201
	/*@{ */
1203
	/*@{ */
1202
   spinlock_t object_name_lock;
1204
   spinlock_t object_name_lock;
1203
	struct idr object_name_idr;
1205
	struct idr object_name_idr;
1204
	/*@} */
1206
	/*@} */
1205
	int switch_power_state;
1207
	int switch_power_state;
1206
 
1208
 
1207
	atomic_t unplugged; /* device has been unplugged or gone away */
1209
	atomic_t unplugged; /* device has been unplugged or gone away */
1208
};
1210
};
1209
 
1211
 
1210
#define DRM_SWITCH_POWER_ON 0
1212
#define DRM_SWITCH_POWER_ON 0
1211
#define DRM_SWITCH_POWER_OFF 1
1213
#define DRM_SWITCH_POWER_OFF 1
1212
#define DRM_SWITCH_POWER_CHANGING 2
1214
#define DRM_SWITCH_POWER_CHANGING 2
1213
 
1215
 
1214
static __inline__ int drm_core_check_feature(struct drm_device *dev,
1216
static __inline__ int drm_core_check_feature(struct drm_device *dev,
1215
					     int feature)
1217
					     int feature)
1216
{
1218
{
1217
	return ((dev->driver->driver_features & feature) ? 1 : 0);
1219
	return ((dev->driver->driver_features & feature) ? 1 : 0);
1218
}
1220
}
1219
 
1221
 
1220
static inline int drm_dev_to_irq(struct drm_device *dev)
1222
static inline int drm_dev_to_irq(struct drm_device *dev)
1221
{
1223
{
1222
	return dev->pdev->irq;
1224
	return dev->pdev->irq;
1223
}
1225
}
1224
 
1226
 
1225
#if 0
1227
#if 0
1226
 
1228
 
1227
#ifdef __alpha__
1229
#ifdef __alpha__
1228
#define drm_get_pci_domain(dev) dev->hose->index
1230
#define drm_get_pci_domain(dev) dev->hose->index
1229
#else
1231
#else
1230
#define drm_get_pci_domain(dev) 0
1232
#define drm_get_pci_domain(dev) 0
1231
#endif
1233
#endif
1232
 
1234
 
1233
#if __OS_HAS_AGP
1235
#if __OS_HAS_AGP
1234
static inline int drm_core_has_AGP(struct drm_device *dev)
1236
static inline int drm_core_has_AGP(struct drm_device *dev)
1235
{
1237
{
1236
	return drm_core_check_feature(dev, DRIVER_USE_AGP);
1238
	return drm_core_check_feature(dev, DRIVER_USE_AGP);
1237
}
1239
}
1238
#else
1240
#else
1239
#define drm_core_has_AGP(dev) (0)
1241
#define drm_core_has_AGP(dev) (0)
1240
#endif
1242
#endif
1241
 
1243
 
1242
#if __OS_HAS_MTRR
1244
#if __OS_HAS_MTRR
1243
static inline int drm_core_has_MTRR(struct drm_device *dev)
1245
static inline int drm_core_has_MTRR(struct drm_device *dev)
1244
{
1246
{
1245
	return drm_core_check_feature(dev, DRIVER_USE_MTRR);
1247
	return drm_core_check_feature(dev, DRIVER_USE_MTRR);
1246
}
1248
}
1247
 
1249
 
1248
#define DRM_MTRR_WC		MTRR_TYPE_WRCOMB
1250
#define DRM_MTRR_WC		MTRR_TYPE_WRCOMB
1249
 
1251
 
1250
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1252
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1251
			       unsigned int flags)
1253
			       unsigned int flags)
1252
{
1254
{
1253
	return mtrr_add(offset, size, flags, 1);
1255
	return mtrr_add(offset, size, flags, 1);
1254
}
1256
}
1255
 
1257
 
1256
static inline int drm_mtrr_del(int handle, unsigned long offset,
1258
static inline int drm_mtrr_del(int handle, unsigned long offset,
1257
			       unsigned long size, unsigned int flags)
1259
			       unsigned long size, unsigned int flags)
1258
{
1260
{
1259
	return mtrr_del(handle, offset, size);
1261
	return mtrr_del(handle, offset, size);
1260
}
1262
}
1261
 
1263
 
1262
#else
1264
#else
1263
#define drm_core_has_MTRR(dev) (0)
1265
#define drm_core_has_MTRR(dev) (0)
1264
 
1266
 
1265
#define DRM_MTRR_WC		0
1267
#define DRM_MTRR_WC		0
1266
 
1268
 
1267
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1269
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1268
			       unsigned int flags)
1270
			       unsigned int flags)
1269
{
1271
{
1270
	return 0;
1272
	return 0;
1271
}
1273
}
1272
 
1274
 
1273
static inline int drm_mtrr_del(int handle, unsigned long offset,
1275
static inline int drm_mtrr_del(int handle, unsigned long offset,
1274
			       unsigned long size, unsigned int flags)
1276
			       unsigned long size, unsigned int flags)
1275
{
1277
{
1276
	return 0;
1278
	return 0;
1277
}
1279
}
1278
#endif
1280
#endif
1279
 
1281
 
1280
/******************************************************************/
1282
/******************************************************************/
1281
/** \name Internal function definitions */
1283
/** \name Internal function definitions */
1282
/*@{*/
1284
/*@{*/
1283
 
1285
 
1284
				/* Driver support (drm_drv.h) */
1286
				/* Driver support (drm_drv.h) */
1285
extern long drm_ioctl(struct file *filp,
1287
extern long drm_ioctl(struct file *filp,
1286
		     unsigned int cmd, unsigned long arg);
1288
		     unsigned int cmd, unsigned long arg);
1287
extern long drm_compat_ioctl(struct file *filp,
1289
extern long drm_compat_ioctl(struct file *filp,
1288
			     unsigned int cmd, unsigned long arg);
1290
			     unsigned int cmd, unsigned long arg);
1289
extern int drm_lastclose(struct drm_device *dev);
1291
extern int drm_lastclose(struct drm_device *dev);
1290
 
1292
 
1291
				/* Device support (drm_fops.h) */
1293
				/* Device support (drm_fops.h) */
1292
extern struct mutex drm_global_mutex;
1294
extern struct mutex drm_global_mutex;
1293
extern int drm_open(struct inode *inode, struct file *filp);
1295
extern int drm_open(struct inode *inode, struct file *filp);
1294
extern int drm_stub_open(struct inode *inode, struct file *filp);
1296
extern int drm_stub_open(struct inode *inode, struct file *filp);
1295
extern int drm_fasync(int fd, struct file *filp, int on);
1297
extern int drm_fasync(int fd, struct file *filp, int on);
1296
extern ssize_t drm_read(struct file *filp, char __user *buffer,
1298
extern ssize_t drm_read(struct file *filp, char __user *buffer,
1297
			size_t count, loff_t *offset);
1299
			size_t count, loff_t *offset);
1298
extern int drm_release(struct inode *inode, struct file *filp);
1300
extern int drm_release(struct inode *inode, struct file *filp);
1299
 
1301
 
1300
				/* Mapping support (drm_vm.h) */
1302
				/* Mapping support (drm_vm.h) */
1301
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1303
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1302
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1304
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1303
extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
1305
extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
1304
extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
1306
extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
1305
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1307
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1306
 
1308
 
1307
				/* Memory management support (drm_memory.h) */
1309
				/* Memory management support (drm_memory.h) */
1308
#include 
1310
#include 
1309
extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
1311
extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
1310
extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1312
extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1311
extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
1313
extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
1312
				       struct page **pages,
1314
				       struct page **pages,
1313
				       unsigned long num_pages,
1315
				       unsigned long num_pages,
1314
				       uint32_t gtt_offset,
1316
				       uint32_t gtt_offset,
1315
				       uint32_t type);
1317
				       uint32_t type);
1316
extern int drm_unbind_agp(DRM_AGP_MEM * handle);
1318
extern int drm_unbind_agp(DRM_AGP_MEM * handle);
1317
 
1319
 
1318
				/* Misc. IOCTL support (drm_ioctl.h) */
1320
				/* Misc. IOCTL support (drm_ioctl.h) */
1319
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1321
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1320
			    struct drm_file *file_priv);
1322
			    struct drm_file *file_priv);
1321
extern int drm_getunique(struct drm_device *dev, void *data,
1323
extern int drm_getunique(struct drm_device *dev, void *data,
1322
			 struct drm_file *file_priv);
1324
			 struct drm_file *file_priv);
1323
extern int drm_setunique(struct drm_device *dev, void *data,
1325
extern int drm_setunique(struct drm_device *dev, void *data,
1324
			 struct drm_file *file_priv);
1326
			 struct drm_file *file_priv);
1325
extern int drm_getmap(struct drm_device *dev, void *data,
1327
extern int drm_getmap(struct drm_device *dev, void *data,
1326
		      struct drm_file *file_priv);
1328
		      struct drm_file *file_priv);
1327
extern int drm_getclient(struct drm_device *dev, void *data,
1329
extern int drm_getclient(struct drm_device *dev, void *data,
1328
			 struct drm_file *file_priv);
1330
			 struct drm_file *file_priv);
1329
extern int drm_getstats(struct drm_device *dev, void *data,
1331
extern int drm_getstats(struct drm_device *dev, void *data,
1330
			struct drm_file *file_priv);
1332
			struct drm_file *file_priv);
1331
extern int drm_getcap(struct drm_device *dev, void *data,
1333
extern int drm_getcap(struct drm_device *dev, void *data,
1332
		      struct drm_file *file_priv);
1334
		      struct drm_file *file_priv);
1333
extern int drm_setversion(struct drm_device *dev, void *data,
1335
extern int drm_setversion(struct drm_device *dev, void *data,
1334
			  struct drm_file *file_priv);
1336
			  struct drm_file *file_priv);
1335
extern int drm_noop(struct drm_device *dev, void *data,
1337
extern int drm_noop(struct drm_device *dev, void *data,
1336
		    struct drm_file *file_priv);
1338
		    struct drm_file *file_priv);
1337
 
1339
 
1338
				/* Context IOCTL support (drm_context.h) */
1340
				/* Context IOCTL support (drm_context.h) */
1339
extern int drm_resctx(struct drm_device *dev, void *data,
1341
extern int drm_resctx(struct drm_device *dev, void *data,
1340
		      struct drm_file *file_priv);
1342
		      struct drm_file *file_priv);
1341
extern int drm_addctx(struct drm_device *dev, void *data,
1343
extern int drm_addctx(struct drm_device *dev, void *data,
1342
		      struct drm_file *file_priv);
1344
		      struct drm_file *file_priv);
1343
extern int drm_modctx(struct drm_device *dev, void *data,
1345
extern int drm_modctx(struct drm_device *dev, void *data,
1344
		      struct drm_file *file_priv);
1346
		      struct drm_file *file_priv);
1345
extern int drm_getctx(struct drm_device *dev, void *data,
1347
extern int drm_getctx(struct drm_device *dev, void *data,
1346
		      struct drm_file *file_priv);
1348
		      struct drm_file *file_priv);
1347
extern int drm_switchctx(struct drm_device *dev, void *data,
1349
extern int drm_switchctx(struct drm_device *dev, void *data,
1348
			 struct drm_file *file_priv);
1350
			 struct drm_file *file_priv);
1349
extern int drm_newctx(struct drm_device *dev, void *data,
1351
extern int drm_newctx(struct drm_device *dev, void *data,
1350
		      struct drm_file *file_priv);
1352
		      struct drm_file *file_priv);
1351
extern int drm_rmctx(struct drm_device *dev, void *data,
1353
extern int drm_rmctx(struct drm_device *dev, void *data,
1352
		     struct drm_file *file_priv);
1354
		     struct drm_file *file_priv);
1353
 
1355
 
1354
extern int drm_ctxbitmap_init(struct drm_device *dev);
1356
extern int drm_ctxbitmap_init(struct drm_device *dev);
1355
extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
1357
extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
1356
extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
1358
extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
1357
 
1359
 
1358
extern int drm_setsareactx(struct drm_device *dev, void *data,
1360
extern int drm_setsareactx(struct drm_device *dev, void *data,
1359
			   struct drm_file *file_priv);
1361
			   struct drm_file *file_priv);
1360
extern int drm_getsareactx(struct drm_device *dev, void *data,
1362
extern int drm_getsareactx(struct drm_device *dev, void *data,
1361
			   struct drm_file *file_priv);
1363
			   struct drm_file *file_priv);
1362
 
1364
 
1363
				/* Authentication IOCTL support (drm_auth.h) */
1365
				/* Authentication IOCTL support (drm_auth.h) */
1364
extern int drm_getmagic(struct drm_device *dev, void *data,
1366
extern int drm_getmagic(struct drm_device *dev, void *data,
1365
			struct drm_file *file_priv);
1367
			struct drm_file *file_priv);
1366
extern int drm_authmagic(struct drm_device *dev, void *data,
1368
extern int drm_authmagic(struct drm_device *dev, void *data,
1367
			 struct drm_file *file_priv);
1369
			 struct drm_file *file_priv);
1368
extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
1370
extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
1369
 
1371
 
1370
/* Cache management (drm_cache.c) */
1372
/* Cache management (drm_cache.c) */
1371
void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1373
void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1372
void drm_clflush_sg(struct sg_table *st);
1374
void drm_clflush_sg(struct sg_table *st);
1373
void drm_clflush_virt_range(char *addr, unsigned long length);
1375
void drm_clflush_virt_range(char *addr, unsigned long length);
1374
 
1376
 
1375
				/* Locking IOCTL support (drm_lock.h) */
1377
				/* Locking IOCTL support (drm_lock.h) */
1376
extern int drm_lock(struct drm_device *dev, void *data,
1378
extern int drm_lock(struct drm_device *dev, void *data,
1377
		    struct drm_file *file_priv);
1379
		    struct drm_file *file_priv);
1378
extern int drm_unlock(struct drm_device *dev, void *data,
1380
extern int drm_unlock(struct drm_device *dev, void *data,
1379
		      struct drm_file *file_priv);
1381
		      struct drm_file *file_priv);
1380
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1382
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1381
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1383
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1382
extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1384
extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1383
 
1385
 
1384
/*
1386
/*
1385
 * These are exported to drivers so that they can implement fencing using
1387
 * These are exported to drivers so that they can implement fencing using
1386
 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1388
 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1387
 */
1389
 */
1388
 
1390
 
1389
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1391
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1390
 
1392
 
1391
				/* Buffer management support (drm_bufs.h) */
1393
				/* Buffer management support (drm_bufs.h) */
1392
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1394
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1393
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1395
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1394
extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
1396
extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
1395
		      unsigned int size, enum drm_map_type type,
1397
		      unsigned int size, enum drm_map_type type,
1396
		      enum drm_map_flags flags, struct drm_local_map **map_ptr);
1398
		      enum drm_map_flags flags, struct drm_local_map **map_ptr);
1397
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1399
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1398
			    struct drm_file *file_priv);
1400
			    struct drm_file *file_priv);
1399
extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
1401
extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
1400
extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
1402
extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
1401
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1403
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1402
			   struct drm_file *file_priv);
1404
			   struct drm_file *file_priv);
1403
extern int drm_addbufs(struct drm_device *dev, void *data,
1405
extern int drm_addbufs(struct drm_device *dev, void *data,
1404
		       struct drm_file *file_priv);
1406
		       struct drm_file *file_priv);
1405
extern int drm_infobufs(struct drm_device *dev, void *data,
1407
extern int drm_infobufs(struct drm_device *dev, void *data,
1406
			struct drm_file *file_priv);
1408
			struct drm_file *file_priv);
1407
extern int drm_markbufs(struct drm_device *dev, void *data,
1409
extern int drm_markbufs(struct drm_device *dev, void *data,
1408
			struct drm_file *file_priv);
1410
			struct drm_file *file_priv);
1409
extern int drm_freebufs(struct drm_device *dev, void *data,
1411
extern int drm_freebufs(struct drm_device *dev, void *data,
1410
			struct drm_file *file_priv);
1412
			struct drm_file *file_priv);
1411
extern int drm_mapbufs(struct drm_device *dev, void *data,
1413
extern int drm_mapbufs(struct drm_device *dev, void *data,
1412
		       struct drm_file *file_priv);
1414
		       struct drm_file *file_priv);
1413
extern int drm_order(unsigned long size);
1415
extern int drm_order(unsigned long size);
1414
 
1416
 
1415
				/* DMA support (drm_dma.h) */
1417
				/* DMA support (drm_dma.h) */
1416
extern int drm_dma_setup(struct drm_device *dev);
1418
extern int drm_dma_setup(struct drm_device *dev);
1417
extern void drm_dma_takedown(struct drm_device *dev);
1419
extern void drm_dma_takedown(struct drm_device *dev);
1418
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1420
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1419
extern void drm_core_reclaim_buffers(struct drm_device *dev,
1421
extern void drm_core_reclaim_buffers(struct drm_device *dev,
1420
				     struct drm_file *filp);
1422
				     struct drm_file *filp);
1421
 
1423
 
1422
				/* IRQ support (drm_irq.h) */
1424
				/* IRQ support (drm_irq.h) */
1423
extern int drm_control(struct drm_device *dev, void *data,
1425
extern int drm_control(struct drm_device *dev, void *data,
1424
		       struct drm_file *file_priv);
1426
		       struct drm_file *file_priv);
1425
extern int drm_irq_install(struct drm_device *dev);
1427
extern int drm_irq_install(struct drm_device *dev);
1426
extern int drm_irq_uninstall(struct drm_device *dev);
1428
extern int drm_irq_uninstall(struct drm_device *dev);
1427
 
1429
 
1428
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1430
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1429
extern int drm_wait_vblank(struct drm_device *dev, void *data,
1431
extern int drm_wait_vblank(struct drm_device *dev, void *data,
1430
			   struct drm_file *filp);
1432
			   struct drm_file *filp);
1431
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
1433
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
1432
extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1434
extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1433
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1435
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1434
				     struct timeval *vblanktime);
1436
				     struct timeval *vblanktime);
1435
extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1437
extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1436
				     struct drm_pending_vblank_event *e);
1438
				     struct drm_pending_vblank_event *e);
1437
extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1439
extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1438
extern int drm_vblank_get(struct drm_device *dev, int crtc);
1440
extern int drm_vblank_get(struct drm_device *dev, int crtc);
1439
extern void drm_vblank_put(struct drm_device *dev, int crtc);
1441
extern void drm_vblank_put(struct drm_device *dev, int crtc);
1440
extern void drm_vblank_off(struct drm_device *dev, int crtc);
1442
extern void drm_vblank_off(struct drm_device *dev, int crtc);
1441
extern void drm_vblank_cleanup(struct drm_device *dev);
1443
extern void drm_vblank_cleanup(struct drm_device *dev);
1442
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1444
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1443
				     struct timeval *tvblank, unsigned flags);
1445
				     struct timeval *tvblank, unsigned flags);
1444
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1446
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1445
						 int crtc, int *max_error,
1447
						 int crtc, int *max_error,
1446
						 struct timeval *vblank_time,
1448
						 struct timeval *vblank_time,
1447
						 unsigned flags,
1449
						 unsigned flags,
1448
						 struct drm_crtc *refcrtc);
1450
						 struct drm_crtc *refcrtc);
1449
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc);
1451
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc);
1450
 
1452
 
1451
extern bool
1453
extern bool
1452
drm_mode_parse_command_line_for_connector(const char *mode_option,
1454
drm_mode_parse_command_line_for_connector(const char *mode_option,
1453
					  struct drm_connector *connector,
1455
					  struct drm_connector *connector,
1454
					  struct drm_cmdline_mode *mode);
1456
					  struct drm_cmdline_mode *mode);
1455
 
1457
 
1456
extern struct drm_display_mode *
1458
extern struct drm_display_mode *
1457
drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1459
drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1458
				  struct drm_cmdline_mode *cmd);
1460
				  struct drm_cmdline_mode *cmd);
1459
 
1461
 
1460
extern int drm_display_mode_from_videomode(const struct videomode *vm,
1462
extern int drm_display_mode_from_videomode(const struct videomode *vm,
1461
					   struct drm_display_mode *dmode);
1463
					   struct drm_display_mode *dmode);
1462
extern int of_get_drm_display_mode(struct device_node *np,
1464
extern int of_get_drm_display_mode(struct device_node *np,
1463
				   struct drm_display_mode *dmode,
1465
				   struct drm_display_mode *dmode,
1464
				   int index);
1466
				   int index);
1465
 
1467
 
1466
/* Modesetting support */
1468
/* Modesetting support */
1467
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1469
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1468
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1470
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1469
extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1471
extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1470
			   struct drm_file *file_priv);
1472
			   struct drm_file *file_priv);
1471
 
1473
 
1472
				/* AGP/GART support (drm_agpsupport.h) */
1474
				/* AGP/GART support (drm_agpsupport.h) */
1473
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
1475
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
1474
extern int drm_agp_acquire(struct drm_device *dev);
1476
extern int drm_agp_acquire(struct drm_device *dev);
1475
extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
1477
extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
1476
				 struct drm_file *file_priv);
1478
				 struct drm_file *file_priv);
1477
extern int drm_agp_release(struct drm_device *dev);
1479
extern int drm_agp_release(struct drm_device *dev);
1478
extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
1480
extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
1479
				 struct drm_file *file_priv);
1481
				 struct drm_file *file_priv);
1480
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
1482
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
1481
extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
1483
extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
1482
				struct drm_file *file_priv);
1484
				struct drm_file *file_priv);
1483
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
1485
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
1484
extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
1486
extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
1485
			struct drm_file *file_priv);
1487
			struct drm_file *file_priv);
1486
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
1488
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
1487
extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
1489
extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
1488
			 struct drm_file *file_priv);
1490
			 struct drm_file *file_priv);
1489
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
1491
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
1490
extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
1492
extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
1491
			struct drm_file *file_priv);
1493
			struct drm_file *file_priv);
1492
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
1494
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
1493
extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
1495
extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
1494
			  struct drm_file *file_priv);
1496
			  struct drm_file *file_priv);
1495
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1497
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1496
extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
1498
extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
1497
			struct drm_file *file_priv);
1499
			struct drm_file *file_priv);
1498
 
1500
 
1499
				/* Stub support (drm_stub.h) */
1501
				/* Stub support (drm_stub.h) */
1500
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1502
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1501
			       struct drm_file *file_priv);
1503
			       struct drm_file *file_priv);
1502
extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1504
extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1503
				struct drm_file *file_priv);
1505
				struct drm_file *file_priv);
1504
struct drm_master *drm_master_create(struct drm_minor *minor);
1506
struct drm_master *drm_master_create(struct drm_minor *minor);
1505
extern struct drm_master *drm_master_get(struct drm_master *master);
1507
extern struct drm_master *drm_master_get(struct drm_master *master);
1506
extern void drm_master_put(struct drm_master **master);
1508
extern void drm_master_put(struct drm_master **master);
1507
 
1509
 
1508
extern void drm_put_dev(struct drm_device *dev);
1510
extern void drm_put_dev(struct drm_device *dev);
1509
extern int drm_put_minor(struct drm_minor **minor);
1511
extern int drm_put_minor(struct drm_minor **minor);
1510
extern void drm_unplug_dev(struct drm_device *dev);
1512
extern void drm_unplug_dev(struct drm_device *dev);
1511
#endif
1513
#endif
1512
 
1514
 
1513
extern unsigned int drm_debug;
1515
extern unsigned int drm_debug;
1514
 
1516
 
1515
#if 0
1517
#if 0
1516
extern unsigned int drm_vblank_offdelay;
1518
extern unsigned int drm_vblank_offdelay;
1517
extern unsigned int drm_timestamp_precision;
1519
extern unsigned int drm_timestamp_precision;
1518
extern unsigned int drm_timestamp_monotonic;
1520
extern unsigned int drm_timestamp_monotonic;
1519
 
1521
 
1520
extern struct class *drm_class;
1522
extern struct class *drm_class;
1521
extern struct proc_dir_entry *drm_proc_root;
1523
extern struct proc_dir_entry *drm_proc_root;
1522
extern struct dentry *drm_debugfs_root;
1524
extern struct dentry *drm_debugfs_root;
1523
 
1525
 
1524
extern struct idr drm_minors_idr;
1526
extern struct idr drm_minors_idr;
1525
 
1527
 
1526
extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
1528
extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
1527
 
1529
 
1528
				/* Proc support (drm_proc.h) */
1530
				/* Proc support (drm_proc.h) */
1529
extern int drm_proc_init(struct drm_minor *minor, int minor_id,
1531
extern int drm_proc_init(struct drm_minor *minor, int minor_id,
1530
			 struct proc_dir_entry *root);
1532
			 struct proc_dir_entry *root);
1531
extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
1533
extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
1532
 
1534
 
1533
				/* Debugfs support */
1535
				/* Debugfs support */
1534
#if defined(CONFIG_DEBUG_FS)
1536
#if defined(CONFIG_DEBUG_FS)
1535
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1537
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1536
			    struct dentry *root);
1538
			    struct dentry *root);
1537
extern int drm_debugfs_create_files(struct drm_info_list *files, int count,
1539
extern int drm_debugfs_create_files(struct drm_info_list *files, int count,
1538
				    struct dentry *root, struct drm_minor *minor);
1540
				    struct dentry *root, struct drm_minor *minor);
1539
extern int drm_debugfs_remove_files(struct drm_info_list *files, int count,
1541
extern int drm_debugfs_remove_files(struct drm_info_list *files, int count,
1540
                                    struct drm_minor *minor);
1542
                                    struct drm_minor *minor);
1541
extern int drm_debugfs_cleanup(struct drm_minor *minor);
1543
extern int drm_debugfs_cleanup(struct drm_minor *minor);
1542
#endif
1544
#endif
1543
 
1545
 
1544
				/* Info file support */
1546
				/* Info file support */
1545
extern int drm_name_info(struct seq_file *m, void *data);
1547
extern int drm_name_info(struct seq_file *m, void *data);
1546
extern int drm_vm_info(struct seq_file *m, void *data);
1548
extern int drm_vm_info(struct seq_file *m, void *data);
1547
extern int drm_bufs_info(struct seq_file *m, void *data);
1549
extern int drm_bufs_info(struct seq_file *m, void *data);
1548
extern int drm_vblank_info(struct seq_file *m, void *data);
1550
extern int drm_vblank_info(struct seq_file *m, void *data);
1549
extern int drm_clients_info(struct seq_file *m, void* data);
1551
extern int drm_clients_info(struct seq_file *m, void* data);
1550
extern int drm_gem_name_info(struct seq_file *m, void *data);
1552
extern int drm_gem_name_info(struct seq_file *m, void *data);
1551
 
1553
 
1552
#if DRM_DEBUG_CODE
1554
#if DRM_DEBUG_CODE
1553
extern int drm_vma_info(struct seq_file *m, void *data);
1555
extern int drm_vma_info(struct seq_file *m, void *data);
1554
#endif
1556
#endif
1555
 
1557
 
1556
				/* Scatter Gather Support (drm_scatter.h) */
1558
				/* Scatter Gather Support (drm_scatter.h) */
1557
extern void drm_sg_cleanup(struct drm_sg_mem * entry);
1559
extern void drm_sg_cleanup(struct drm_sg_mem * entry);
1558
extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
1560
extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
1559
			struct drm_file *file_priv);
1561
			struct drm_file *file_priv);
1560
extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
1562
extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
1561
extern int drm_sg_free(struct drm_device *dev, void *data,
1563
extern int drm_sg_free(struct drm_device *dev, void *data,
1562
		       struct drm_file *file_priv);
1564
		       struct drm_file *file_priv);
1563
 
1565
 
1564
			       /* ATI PCIGART support (ati_pcigart.h) */
1566
			       /* ATI PCIGART support (ati_pcigart.h) */
1565
extern int drm_ati_pcigart_init(struct drm_device *dev,
1567
extern int drm_ati_pcigart_init(struct drm_device *dev,
1566
				struct drm_ati_pcigart_info * gart_info);
1568
				struct drm_ati_pcigart_info * gart_info);
1567
extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
1569
extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
1568
				   struct drm_ati_pcigart_info * gart_info);
1570
				   struct drm_ati_pcigart_info * gart_info);
1569
#endif
1571
#endif
1570
 
1572
 
1571
extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1573
extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1572
				       size_t align);
1574
				       size_t align);
1573
extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1575
extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1574
extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1576
extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1575
 
1577
 
1576
#if 0
1578
#if 0
1577
			       /* sysfs support (drm_sysfs.c) */
1579
			       /* sysfs support (drm_sysfs.c) */
1578
struct drm_sysfs_class;
1580
struct drm_sysfs_class;
1579
extern struct class *drm_sysfs_create(struct module *owner, char *name);
1581
extern struct class *drm_sysfs_create(struct module *owner, char *name);
1580
extern void drm_sysfs_destroy(void);
1582
extern void drm_sysfs_destroy(void);
1581
extern int drm_sysfs_device_add(struct drm_minor *minor);
1583
extern int drm_sysfs_device_add(struct drm_minor *minor);
1582
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1584
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1583
extern void drm_sysfs_device_remove(struct drm_minor *minor);
1585
extern void drm_sysfs_device_remove(struct drm_minor *minor);
1584
extern char *drm_get_connector_status_name(enum drm_connector_status status);
1586
extern char *drm_get_connector_status_name(enum drm_connector_status status);
1585
 
1587
 
1586
static inline int drm_sysfs_connector_add(struct drm_connector *connector)
1588
static inline int drm_sysfs_connector_add(struct drm_connector *connector)
1587
{ return 0; };
1589
{ return 0; };
1588
 
1590
 
1589
static inline void drm_sysfs_connector_remove(struct drm_connector *connector)
1591
static inline void drm_sysfs_connector_remove(struct drm_connector *connector)
1590
{ };
1592
{ };
1591
 
1593
 
1592
#endif
1594
#endif
1593
 
1595
 
1594
/* Graphics Execution Manager library functions (drm_gem.c) */
1596
/* Graphics Execution Manager library functions (drm_gem.c) */
1595
int drm_gem_init(struct drm_device *dev);
1597
int drm_gem_init(struct drm_device *dev);
1596
void drm_gem_destroy(struct drm_device *dev);
1598
void drm_gem_destroy(struct drm_device *dev);
1597
void drm_gem_object_release(struct drm_gem_object *obj);
1599
void drm_gem_object_release(struct drm_gem_object *obj);
1598
void drm_gem_object_free(struct kref *kref);
1600
void drm_gem_object_free(struct kref *kref);
1599
struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1601
struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1600
					    size_t size);
1602
					    size_t size);
1601
int drm_gem_object_init(struct drm_device *dev,
1603
int drm_gem_object_init(struct drm_device *dev,
1602
			struct drm_gem_object *obj, size_t size);
1604
			struct drm_gem_object *obj, size_t size);
1603
int drm_gem_private_object_init(struct drm_device *dev,
1605
int drm_gem_private_object_init(struct drm_device *dev,
1604
			struct drm_gem_object *obj, size_t size);
1606
			struct drm_gem_object *obj, size_t size);
1605
void drm_gem_object_handle_free(struct drm_gem_object *obj);
1607
void drm_gem_object_handle_free(struct drm_gem_object *obj);
1606
void drm_gem_vm_open(struct vm_area_struct *vma);
1608
void drm_gem_vm_open(struct vm_area_struct *vma);
1607
void drm_gem_vm_close(struct vm_area_struct *vma);
1609
void drm_gem_vm_close(struct vm_area_struct *vma);
1608
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1610
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1609
 
1611
 
1610
 
1612
 
1611
static inline void
1613
static inline void
1612
drm_gem_object_reference(struct drm_gem_object *obj)
1614
drm_gem_object_reference(struct drm_gem_object *obj)
1613
{
1615
{
1614
	kref_get(&obj->refcount);
1616
	kref_get(&obj->refcount);
1615
}
1617
}
1616
 
1618
 
1617
static inline void
1619
static inline void
1618
drm_gem_object_unreference(struct drm_gem_object *obj)
1620
drm_gem_object_unreference(struct drm_gem_object *obj)
1619
{
1621
{
1620
	if (obj != NULL)
1622
	if (obj != NULL)
1621
		kref_put(&obj->refcount, drm_gem_object_free);
1623
		kref_put(&obj->refcount, drm_gem_object_free);
1622
}
1624
}
1623
 
1625
 
1624
static inline void
1626
static inline void
1625
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1627
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1626
{
1628
{
1627
	if (obj != NULL) {
1629
	if (obj != NULL) {
1628
		struct drm_device *dev = obj->dev;
1630
		struct drm_device *dev = obj->dev;
1629
		mutex_lock(&dev->struct_mutex);
1631
		mutex_lock(&dev->struct_mutex);
1630
	kref_put(&obj->refcount, drm_gem_object_free);
1632
	kref_put(&obj->refcount, drm_gem_object_free);
1631
		mutex_unlock(&dev->struct_mutex);
1633
		mutex_unlock(&dev->struct_mutex);
1632
	}
1634
	}
1633
}
1635
}
1634
 
1636
 
1635
int drm_gem_handle_create(struct drm_file *file_priv,
1637
int drm_gem_handle_create(struct drm_file *file_priv,
1636
			  struct drm_gem_object *obj,
1638
			  struct drm_gem_object *obj,
1637
			  u32 *handlep);
1639
			  u32 *handlep);
1638
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1640
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1639
 
1641
 
1640
static inline void
1642
static inline void
1641
drm_gem_object_handle_reference(struct drm_gem_object *obj)
1643
drm_gem_object_handle_reference(struct drm_gem_object *obj)
1642
{
1644
{
1643
	drm_gem_object_reference(obj);
1645
	drm_gem_object_reference(obj);
1644
	atomic_inc(&obj->handle_count);
1646
	atomic_inc(&obj->handle_count);
1645
}
1647
}
1646
 
1648
 
1647
static inline void
1649
static inline void
1648
drm_gem_object_handle_unreference(struct drm_gem_object *obj)
1650
drm_gem_object_handle_unreference(struct drm_gem_object *obj)
1649
{
1651
{
1650
	if (obj == NULL)
1652
	if (obj == NULL)
1651
		return;
1653
		return;
1652
 
1654
 
1653
	if (atomic_read(&obj->handle_count) == 0)
1655
	if (atomic_read(&obj->handle_count) == 0)
1654
		return;
1656
		return;
1655
	/*
1657
	/*
1656
	 * Must bump handle count first as this may be the last
1658
	 * Must bump handle count first as this may be the last
1657
	 * ref, in which case the object would disappear before we
1659
	 * ref, in which case the object would disappear before we
1658
	 * checked for a name
1660
	 * checked for a name
1659
	 */
1661
	 */
1660
	if (atomic_dec_and_test(&obj->handle_count))
1662
	if (atomic_dec_and_test(&obj->handle_count))
1661
		drm_gem_object_handle_free(obj);
1663
		drm_gem_object_handle_free(obj);
1662
	drm_gem_object_unreference(obj);
1664
	drm_gem_object_unreference(obj);
1663
}
1665
}
1664
 
1666
 
1665
static inline void
1667
static inline void
1666
drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
1668
drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
1667
{
1669
{
1668
	if (obj == NULL)
1670
	if (obj == NULL)
1669
		return;
1671
		return;
1670
 
1672
 
1671
	if (atomic_read(&obj->handle_count) == 0)
1673
	if (atomic_read(&obj->handle_count) == 0)
1672
		return;
1674
		return;
1673
 
1675
 
1674
	/*
1676
	/*
1675
	* Must bump handle count first as this may be the last
1677
	* Must bump handle count first as this may be the last
1676
	* ref, in which case the object would disappear before we
1678
	* ref, in which case the object would disappear before we
1677
	* checked for a name
1679
	* checked for a name
1678
	*/
1680
	*/
1679
 
1681
 
1680
	if (atomic_dec_and_test(&obj->handle_count))
1682
	if (atomic_dec_and_test(&obj->handle_count))
1681
		drm_gem_object_handle_free(obj);
1683
		drm_gem_object_handle_free(obj);
1682
	drm_gem_object_unreference_unlocked(obj);
1684
	drm_gem_object_unreference_unlocked(obj);
1683
}
1685
}
1684
 
1686
 
1685
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1687
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1686
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1688
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1687
 
1689
 
1688
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1690
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1689
					     struct drm_file *filp,
1691
					     struct drm_file *filp,
1690
					     u32 handle);
1692
					     u32 handle);
1691
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1693
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1692
			struct drm_file *file_priv);
1694
			struct drm_file *file_priv);
1693
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1695
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1694
			struct drm_file *file_priv);
1696
			struct drm_file *file_priv);
1695
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1697
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1696
		       struct drm_file *file_priv);
1698
		       struct drm_file *file_priv);
1697
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1699
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1698
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1700
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1699
 
1701
 
1700
extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
1702
extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
1701
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
1703
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
1702
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
1704
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
1703
 
1705
 
1704
#if 0
1706
#if 0
1705
 
1707
 
1706
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1708
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1707
							 unsigned int token)
1709
							 unsigned int token)
1708
{
1710
{
1709
	struct drm_map_list *_entry;
1711
	struct drm_map_list *_entry;
1710
	list_for_each_entry(_entry, &dev->maplist, head)
1712
	list_for_each_entry(_entry, &dev->maplist, head)
1711
	    if (_entry->user_token == token)
1713
	    if (_entry->user_token == token)
1712
		return _entry->map;
1714
		return _entry->map;
1713
	return NULL;
1715
	return NULL;
1714
}
1716
}
1715
 
1717
 
1716
static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1718
static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1717
{
1719
{
1718
}
1720
}
1719
 
1721
 
1720
 
1722
 
1721
 
1723
 
1722
static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
1724
static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
1723
{
1725
{
1724
	if (size * nmemb <= PAGE_SIZE)
1726
	if (size * nmemb <= PAGE_SIZE)
1725
	    return kcalloc(nmemb, size, GFP_KERNEL);
1727
	    return kcalloc(nmemb, size, GFP_KERNEL);
1726
 
1728
 
1727
	if (size != 0 && nmemb > ULONG_MAX / size)
1729
	if (size != 0 && nmemb > ULONG_MAX / size)
1728
		return NULL;
1730
		return NULL;
1729
 
1731
 
1730
	return __vmalloc(size * nmemb,
1732
	return __vmalloc(size * nmemb,
1731
			 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
1733
			 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
1732
}
1734
}
1733
 
1735
 
1734
static __inline void drm_free_large(void *ptr)
1736
static __inline void drm_free_large(void *ptr)
1735
{
1737
{
1736
	if (!is_vmalloc_addr(ptr))
1738
	if (!is_vmalloc_addr(ptr))
1737
		return kfree(ptr);
1739
		return kfree(ptr);
1738
 
1740
 
1739
	vfree(ptr);
1741
	vfree(ptr);
1740
}
1742
}
1741
 
1743
 
1742
#endif
1744
#endif
1743
 
1745
 
1744
#define DRM_PCIE_SPEED_25 1
1746
#define DRM_PCIE_SPEED_25 1
1745
#define DRM_PCIE_SPEED_50 2
1747
#define DRM_PCIE_SPEED_50 2
1746
#define DRM_PCIE_SPEED_80 4
1748
#define DRM_PCIE_SPEED_80 4
1747
 
1749
 
1748
extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1750
extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1749
 
1751
 
1750
static __inline__ int drm_device_is_agp(struct drm_device *dev)
1752
static __inline__ int drm_device_is_agp(struct drm_device *dev)
1751
{
1753
{
1752
    return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1754
    return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1753
}
1755
}
1754
 
1756
 
1755
static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1757
static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1756
{
1758
{
1757
    return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1759
    return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1758
}
1760
}
1759
#endif				/* __KERNEL__ */
1761
#endif				/* __KERNEL__ */
1760
 
1762
 
1761
#define drm_sysfs_connector_add(connector)
1763
#define drm_sysfs_connector_add(connector)
1762
#define drm_sysfs_connector_remove(connector)
1764
#define drm_sysfs_connector_remove(connector)
1763
 
1765
 
1764
#define LFB_SIZE 0xC00000
1766
#define LFB_SIZE 0xC00000
1765
 
1767
 
1766
#endif
1768
#endif