aboutsummaryrefslogtreecommitdiff
path: root/linux-core/i915_buffer.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-01-31 14:50:57 +0100
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-01-31 14:50:57 +0100
commit3024f23c6551e219b0236041a8205bf1bc60ed94 (patch)
tree87bd9deef4a55bf887a8c0978a5ad18412bc13e5 /linux-core/i915_buffer.c
parent07fabc3fd8f00006e6117081f5183a826a6d2bbb (diff)
memory manager: Make device driver aware of different memory types.
Memory types are either fixed (on-card or pre-bound AGP) or not fixed (dynamically bound) to an aperture. They also carry information about: 1) Whether they can be mapped cached. 2) Whether they are at all mappable. 3) Whether they need an ioremap to be accessible from kernel space. In this way VRAM memory and, for example, pre-bound AGP appear identical to the memory manager. This also makes support for unmappable VRAM simple to implement.
Diffstat (limited to 'linux-core/i915_buffer.c')
-rw-r--r--linux-core/i915_buffer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/linux-core/i915_buffer.c b/linux-core/i915_buffer.c
index c3e54468..53002301 100644
--- a/linux-core/i915_buffer.c
+++ b/linux-core/i915_buffer.c
@@ -64,3 +64,36 @@ int i915_invalidate_caches(drm_device_t * dev, uint32_t flags)
return i915_emit_mi_flush(dev, flush_cmd);
}
+
+int i915_init_mem_type(drm_device_t *dev, uint32_t type,
+ drm_mem_type_manager_t *man)
+{
+ switch(type) {
+ case DRM_BO_MEM_LOCAL:
+ break;
+ case DRM_BO_MEM_TT:
+ man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE |
+ _DRM_FLAG_MEMTYPE_CACHED;
+ break;
+ case DRM_BO_MEM_PRIV0:
+ if (!(drm_core_has_AGP(dev) && dev->agp)) {
+ DRM_ERROR("AGP is not enabled for memory type %u\n",
+ (unsigned) type);
+ return -EINVAL;
+ }
+ man->io_offset = dev->agp->agp_info.aper_base;
+ man->io_size = dev->agp->agp_info.aper_size * 1024 * 1024;
+
+ man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE |
+ _DRM_FLAG_MEMTYPE_CACHED |
+ _DRM_FLAG_MEMTYPE_FIXED |
+ _DRM_FLAG_NEEDS_IOREMAP;
+
+ man->io_addr = NULL;
+ break;
+ default:
+ DRM_ERROR("Unsupported memory type %u\n", (unsigned) type);
+ return -EINVAL;
+ }
+ return 0;
+}