[Nouveau] [PATCH 1/4] nouveau: add nouveau_addmap_{agp, fb, pci} functions
Pekka J Enberg
penberg at cs.helsinki.fi
Sun Mar 9 09:36:16 PDT 2008
From: Pekka Enberg <penberg at cs.helsinki.fi>
This introduces memory type specific nouveau_addmap_{agp,fb,pci} functions as a
preparatory step to cleaning up nouveau_mem_alloc().
Signed-off-by: Pekka Enberg <penberg at cs.helsinki.fi>
---
shared-core/nouveau_mem.c | 50 ++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 13 deletions(-)
Index: drm/shared-core/nouveau_mem.c
===================================================================
--- drm.orig/shared-core/nouveau_mem.c
+++ drm/shared-core/nouveau_mem.c
@@ -515,6 +515,39 @@ int nouveau_mem_init(struct drm_device *
return 0;
}
+static int nouveau_addmap(struct drm_device *dev, struct mem_block *block,
+ unsigned long offset, enum drm_map_type type)
+{
+ return drm_addmap(dev, block->start, block->size, type, 0,
+ &block->map);
+}
+
+static int nouveau_addmap_pci(struct drm_device *dev, struct mem_block *block)
+{
+ return nouveau_addmap(dev, block, block->start, _DRM_SCATTER_GATHER);
+}
+
+static int nouveau_addmap_fb(struct drm_device *dev, struct mem_block *block)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ unsigned long offset = block->start + dev_priv->fb_phys;
+
+ return nouveau_addmap(dev, block, offset, _DRM_SCATTER_GATHER);
+}
+
+static int nouveau_addmap_agp(struct drm_device *dev, struct mem_block *block)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ enum drm_map_type type;
+
+ if (dev_priv->gart_info.type == NOUVEAU_GART_SGDMA)
+ type = _DRM_SCATTER_GATHER;
+ else
+ type = _DRM_AGP;
+
+ return nouveau_addmap(dev, block, block->start, type);
+}
+
struct mem_block* nouveau_mem_alloc(struct drm_device *dev, int alignment,
uint64_t size, int flags,
struct drm_file *file_priv)
@@ -590,21 +623,12 @@ alloc_ok:
int ret = 0;
block->flags|=NOUVEAU_MEM_MAPPED;
- if (type == NOUVEAU_MEM_AGP) {
- if (dev_priv->gart_info.type != NOUVEAU_GART_SGDMA)
- ret = drm_addmap(dev, block->start, block->size,
- _DRM_AGP, 0, &block->map);
- else
- ret = drm_addmap(dev, block->start, block->size,
- _DRM_SCATTER_GATHER, 0, &block->map);
- }
+ if (type == NOUVEAU_MEM_AGP)
+ ret = nouveau_addmap_agp(dev, block);
else if (type == NOUVEAU_MEM_FB)
- ret = drm_addmap(dev, block->start + dev_priv->fb_phys,
- block->size, _DRM_FRAME_BUFFER,
- 0, &block->map);
+ ret = nouveau_addmap_fb(dev, block);
else if (type == NOUVEAU_MEM_PCI)
- ret = drm_addmap(dev, block->start, block->size,
- _DRM_SCATTER_GATHER, 0, &block->map);
+ ret = nouveau_addmap_pci(dev, block);
if (ret) {
nouveau_mem_free_block(block);
More information about the Nouveau
mailing list