File: /usr/include/linux/agp_backend.h
1 /*
2 * AGPGART module version 0.99
3 * Copyright (C) 1999 Jeff Hartmann
4 * Copyright (C) 1999 Precision Insight, Inc.
5 * Copyright (C) 1999 Xi Graphics, Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27 #ifndef _AGP_BACKEND_H
28 #define _AGP_BACKEND_H 1
29
30 #ifndef TRUE
31 #define TRUE 1
32 #endif
33
34 #ifndef FALSE
35 #define FALSE 0
36 #endif
37
38 #define AGPGART_VERSION_MAJOR 0
39 #define AGPGART_VERSION_MINOR 99
40
41 enum chipset_type {
42 NOT_SUPPORTED,
43 INTEL_GENERIC,
44 INTEL_LX,
45 INTEL_BX,
46 INTEL_GX,
47 INTEL_I810,
48 INTEL_I815,
49 INTEL_I840,
50 INTEL_I850,
51 VIA_GENERIC,
52 VIA_VP3,
53 VIA_MVP3,
54 VIA_MVP4,
55 VIA_APOLLO_PRO,
56 VIA_APOLLO_KX133,
57 VIA_APOLLO_KT133,
58 SIS_GENERIC,
59 AMD_GENERIC,
60 AMD_IRONGATE,
61 ALI_M1541,
62 ALI_M1621,
63 ALI_M1631,
64 ALI_M1632,
65 ALI_M1641,
66 ALI_M1647,
67 ALI_M1651,
68 ALI_GENERIC
69 };
70
71 typedef struct _agp_version {
72 u16 major;
73 u16 minor;
74 } agp_version;
75
76 typedef struct _agp_kern_info {
77 agp_version version;
78 struct pci_dev *device;
79 enum chipset_type chipset;
80 unsigned long mode;
81 off_t aper_base;
82 size_t aper_size;
83 int max_memory; /* In pages */
84 int current_memory;
85 } agp_kern_info;
86
87 /*
88 * The agp_memory structure has information
89 * about the block of agp memory allocated.
90 * A caller may manipulate the next and prev
91 * pointers to link each allocated item into
92 * a list. These pointers are ignored by the
93 * backend. Everything else should never be
94 * written to, but the caller may read any of
95 * the items to detrimine the status of this
96 * block of agp memory.
97 *
98 */
99
100 typedef struct _agp_memory {
101 int key;
102 struct _agp_memory *next;
103 struct _agp_memory *prev;
104 size_t page_count;
105 int num_scratch_pages;
106 unsigned long *memory;
107 off_t pg_start;
108 u32 type;
109 u32 physical;
110 u8 is_bound;
111 u8 is_flushed;
112 } agp_memory;
113
114 #define AGP_NORMAL_MEMORY 0
115
116 extern void agp_free_memory(agp_memory *);
117
118 /*
119 * agp_free_memory :
120 *
121 * This function frees memory associated with
122 * an agp_memory pointer. It is the only function
123 * that can be called when the backend is not owned
124 * by the caller. (So it can free memory on client
125 * death.)
126 *
127 * It takes an agp_memory pointer as an argument.
128 *
129 */
130
131 extern agp_memory *agp_allocate_memory(size_t, u32);
132
133 /*
134 * agp_allocate_memory :
135 *
136 * This function allocates a group of pages of
137 * a certain type.
138 *
139 * It takes a size_t argument of the number of pages, and
140 * an u32 argument of the type of memory to be allocated.
141 * Every agp bridge device will allow you to allocate
142 * AGP_NORMAL_MEMORY which maps to physical ram. Any other
143 * type is device dependant.
144 *
145 * It returns NULL whenever memory is unavailable.
146 *
147 */
148
149 extern void agp_copy_info(agp_kern_info *);
150
151 /*
152 * agp_copy_info :
153 *
154 * This function copies information about the
155 * agp bridge device and the state of the agp
156 * backend into an agp_kern_info pointer.
157 *
158 * It takes an agp_kern_info pointer as an
159 * argument. The caller should insure that
160 * this pointer is valid.
161 *
162 */
163
164 extern int agp_bind_memory(agp_memory *, off_t);
165
166 /*
167 * agp_bind_memory :
168 *
169 * This function binds an agp_memory structure
170 * into the graphics aperture translation table.
171 *
172 * It takes an agp_memory pointer and an offset into
173 * the graphics aperture translation table as arguments
174 *
175 * It returns -EINVAL if the pointer == NULL.
176 * It returns -EBUSY if the area of the table
177 * requested is already in use.
178 *
179 */
180
181 extern int agp_unbind_memory(agp_memory *);
182
183 /*
184 * agp_unbind_memory :
185 *
186 * This function removes an agp_memory structure
187 * from the graphics aperture translation table.
188 *
189 * It takes an agp_memory pointer as an argument.
190 *
191 * It returns -EINVAL if this piece of agp_memory
192 * is not currently bound to the graphics aperture
193 * translation table or if the agp_memory
194 * pointer == NULL
195 *
196 */
197
198 extern void agp_enable(u32);
199
200 /*
201 * agp_enable :
202 *
203 * This function initializes the agp point-to-point
204 * connection.
205 *
206 * It takes an agp mode register as an argument
207 *
208 */
209
210 extern int agp_backend_acquire(void);
211
212 /*
213 * agp_backend_acquire :
214 *
215 * This Function attempts to acquire the agp
216 * backend.
217 *
218 * returns -EBUSY if agp is in use,
219 * returns 0 if the caller owns the agp backend
220 */
221
222 extern void agp_backend_release(void);
223
224 /*
225 * agp_backend_release :
226 *
227 * This Function releases the lock on the agp
228 * backend.
229 *
230 * The caller must insure that the graphics
231 * aperture translation table is read for use
232 * by another entity. (Ensure that all memory
233 * it bound is unbound.)
234 *
235 */
236
237 typedef struct {
238 void (*free_memory)(agp_memory *);
239 agp_memory *(*allocate_memory)(size_t, u32);
240 int (*bind_memory)(agp_memory *, off_t);
241 int (*unbind_memory)(agp_memory *);
242 void (*enable)(u32);
243 int (*acquire)(void);
244 void (*release)(void);
245 void (*copy_info)(agp_kern_info *);
246 } drm_agp_t;
247
248 extern const drm_agp_t *drm_agp_p;
249
250 /*
251 * Interface between drm and agp code. When agp initializes, it makes
252 * the above structure available via inter_module_register(), drm might
253 * use it. Keith Owens <kaos@ocs.com.au> 28 Oct 2000.
254 */
255
256 #endif /* _AGP_BACKEND_H */
257