35 #include <linux/module.h>
36 #include <linux/slab.h>
58 if (!dev->agp || !dev->agp->acquired)
61 kern = &dev->agp->agp_info;
64 info->
mode = kern->mode;
78 struct drm_file *file_priv)
103 if (dev->agp->acquired)
107 dev->agp->acquired = 1;
125 int drm_agp_acquire_ioctl(
struct drm_device *dev,
void *data,
126 struct drm_file *file_priv)
128 return drm_agp_acquire((
struct drm_device *) file_priv->minor->dev);
141 if (!dev->agp || !dev->agp->acquired)
144 dev->agp->acquired = 0;
149 int drm_agp_release_ioctl(
struct drm_device *dev,
void *data,
150 struct drm_file *file_priv)
152 return drm_agp_release(dev);
167 if (!dev->agp || !dev->agp->acquired)
170 dev->agp->mode = mode.
mode;
172 dev->agp->enabled = 1;
178 int drm_agp_enable_ioctl(
struct drm_device *dev,
void *data,
179 struct drm_file *file_priv)
183 return drm_agp_enable(dev, *mode);
200 struct drm_agp_mem *
entry;
205 if (!dev->agp || !dev->agp->acquired)
210 memset(entry, 0,
sizeof(*entry));
219 entry->handle = (
unsigned long)memory->key + 1;
220 entry->memory = memory;
222 entry->pages = pages;
223 list_add(&entry->head, &dev->agp->memory);
225 request->
handle = entry->handle;
226 request->
physical = memory->physical;
233 int drm_agp_alloc_ioctl(
struct drm_device *dev,
void *data,
234 struct drm_file *file_priv)
238 return drm_agp_alloc(dev, request);
250 static struct drm_agp_mem *drm_agp_lookup_entry(
struct drm_device * dev,
253 struct drm_agp_mem *
entry;
256 if (entry->handle == handle)
276 struct drm_agp_mem *
entry;
279 if (!dev->agp || !dev->agp->acquired)
281 if (!(entry = drm_agp_lookup_entry(dev, request->
handle)))
285 ret = drm_unbind_agp(entry->memory);
293 int drm_agp_unbind_ioctl(
struct drm_device *dev,
void *data,
294 struct drm_file *file_priv)
298 return drm_agp_unbind(dev, request);
316 struct drm_agp_mem *
entry;
320 if (!dev->agp || !dev->agp->acquired)
322 if (!(entry = drm_agp_lookup_entry(dev, request->
handle)))
327 if ((retcode = drm_bind_agp(entry->memory, page)))
329 entry->bound = dev->agp->base + (page <<
PAGE_SHIFT);
330 DRM_DEBUG(
"base = 0x%lx entry->bound = 0x%lx\n",
331 dev->agp->base, entry->bound);
337 int drm_agp_bind_ioctl(
struct drm_device *dev,
void *data,
338 struct drm_file *file_priv)
342 return drm_agp_bind(dev, request);
361 struct drm_agp_mem *
entry;
363 if (!dev->agp || !dev->agp->acquired)
365 if (!(entry = drm_agp_lookup_entry(dev, request->
handle)))
368 drm_unbind_agp(entry->memory);
372 drm_free_agp(entry->memory, entry->pages);
380 int drm_agp_free_ioctl(
struct drm_device *dev,
void *data,
381 struct drm_file *file_priv)
385 return drm_agp_free(dev, request);
397 struct drm_agp_head *drm_agp_init(
struct drm_device *dev)
403 memset((
void *)head, 0,
sizeof(*head));
419 INIT_LIST_HEAD(&head->memory);
420 head->cant_use_aperture = head->agp_info.cant_use_aperture;
421 head->page_mask = head->agp_info.page_mask;
422 head->base = head->agp_info.aper_base;
448 DRM_ERROR(
"Failed to allocate memory for %ld pages\n",
454 mem->pages[i] = pages[i];
455 mem->page_count = num_pages;
457 mem->is_flushed =
true;
460 DRM_ERROR(
"Failed to bind AGP memory: %d\n", ret);