30 #include <linux/module.h>
31 #include <linux/pci.h>
33 #include <linux/slab.h>
38 #include <linux/agpgart.h>
46 #define AGPGART_VERSION_MAJOR 0
47 #define AGPGART_VERSION_MINOR 103
48 static const struct agp_version agp_current_version =
101 static const struct {
int mem,
agp; } maxes_table[] = {
113 static int agp_find_max(
void)
124 while ((memory > maxes_table[index].
mem) && (index < 8))
127 result = maxes_table[index - 1].agp +
128 ( (memory - maxes_table[index - 1].mem) *
129 (maxes_table[index].
agp - maxes_table[index - 1].
agp)) /
130 (maxes_table[index].mem - maxes_table[index - 1].mem);
139 int size_value,
rc, got_gatt=0, got_keylist=0;
142 bridge->
version = &agp_current_version;
144 if (bridge->
driver->needs_scratch_page) {
149 "can't get memory for scratch page\n");
160 size_value = bridge->
driver->fetch_size();
161 if (size_value == 0) {
162 dev_err(&bridge->
dev->dev,
"can't determine aperture size\n");
166 if (bridge->
driver->create_gatt_table(bridge)) {
168 "can't get memory for graphics translation table\n");
177 "can't allocate memory for key lists\n");
185 if (bridge->
driver->configure()) {
186 dev_err(&bridge->
dev->dev,
"error configuring host chipset\n");
196 if (bridge->
driver->needs_scratch_page) {
203 bridge->
driver->free_gatt_table(bridge);
214 if (bridge->
driver->cleanup)
215 bridge->
driver->cleanup();
216 if (bridge->
driver->free_gatt_table)
217 bridge->
driver->free_gatt_table(bridge);
222 if (bridge->
driver->agp_destroy_page &&
223 bridge->
driver->needs_scratch_page) {
239 bridge = kzalloc(
sizeof(*bridge),
GFP_KERNEL);
280 if (!try_module_get(bridge->
driver->owner)) {
281 dev_info(&bridge->
dev->dev,
"can't lock chipset driver\n");
286 error = agp_backend_initialize(bridge);
289 "agp_backend_initialize() failed\n");
297 "agp_frontend_initialize() failed\n");
301 dev_info(&bridge->
dev->dev,
"AGP aperture is %dM @ 0x%lx\n",
310 agp_backend_cleanup(bridge);
312 module_put(bridge->
driver->owner);
322 agp_backend_cleanup(bridge);
326 module_put(bridge->
driver->owner);
335 static int __init agp_init(
void)
343 static void __exit agp_exit(
void)
352 if (!
strcmp(s,
"try_unsupported"))
353 agp_try_unsupported_boot = 1;