extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
-extern drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev);
-extern drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev);
+extern drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev,
+ drm_ttm_backend_t *backend);
+extern drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev,
+ drm_ttm_backend_t *backend);
/* Stub support (drm_stub.h) */
extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
DRM_DEBUG("drm_agp_clear_ttm\n");
if (mem) {
- if (mem->is_bound) {
- drm_agp_unbind_memory(mem);
- }
+ backend->unbind(backend);
agp_free_memory(mem);
}
drm_agp_ttm_priv *agp_priv;
if (backend) {
- DRM_DEBUG("drm_agp_destroy_ttm\n");
- agp_priv = (drm_agp_ttm_priv *) backend->private;
+ DRM_DEBUG("drm_agp_destroy_ttm\n");
+ agp_priv = (drm_agp_ttm_priv *) backend->private;
if (agp_priv) {
if (agp_priv->mem) {
- drm_agp_clear_ttm(backend);
+ backend->clear(backend);
}
drm_free(agp_priv, sizeof(*agp_priv), DRM_MEM_MAPPINGS);
}
- drm_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS);
+ if (backend->needs_free)
+ drm_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS);
}
}
-drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev) {
+drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev,
+ drm_ttm_backend_t *backend) {
drm_ttm_backend_t *agp_be;
drm_agp_ttm_priv *agp_priv;
- agp_be = drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
+ agp_be = (backend != NULL) ? backend:
+ drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
if (!agp_be)
return NULL;
agp_be->bind = drm_agp_bind_ttm;
agp_be->unbind = drm_agp_unbind_ttm;
agp_be->destroy = drm_agp_destroy_ttm;
+ agp_be->needs_free = (backend == NULL);
return agp_be;
}
EXPORT_SYMBOL(drm_agp_init_ttm_uncached);
-drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev) {
+drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev,
+ drm_ttm_backend_t *backend) {
drm_ttm_backend_t *agp_be;
drm_agp_ttm_priv *agp_priv;
- agp_be = drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
+
+ agp_be = (backend != NULL) ? backend:
+ drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
if (!agp_be)
return NULL;
agp_be->bind = drm_agp_bind_ttm;
agp_be->unbind = drm_agp_unbind_ttm;
agp_be->destroy = drm_agp_destroy_ttm;
+ agp_be->needs_free = (backend == NULL);
return agp_be;
}
EXPORT_SYMBOL(drm_agp_init_ttm_cached);