Subversion Repositories Kolibri OS

Rev

Rev 3243 | Rev 3262 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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