Wed Jul 24 02:46:49 2013 UTC ()
Replace extra data in struct drm_local_map by a union.

This is a tagged union; only certain variants, specified by the map's
type, need a bus space handle and a drm bus map.  They will also need
a bus space tag later.  Other variants use other data, with more to
be added in the future, probably.


(riastradh)
diff -r1.1.1.1.2.36 -r1.1.1.1.2.37 src/sys/external/bsd/drm2/dist/include/drm/drmP.h

cvs diff -r1.1.1.1.2.36 -r1.1.1.1.2.37 src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h (switch to unified diff)

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