drm/nouveau: port all engines to new engine module format
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpu / drm / nouveau / nouveau_bo.h
blobc42aea9fb546efe3ea1ccbac0d385858d2519e0d
1 #ifndef __NOUVEAU_BO_H__
2 #define __NOUVEAU_BO_H__
4 struct nouveau_channel;
5 struct nouveau_fence;
6 struct nouveau_vma;
8 struct nouveau_bo {
9 struct ttm_buffer_object bo;
10 struct ttm_placement placement;
11 u32 valid_domains;
12 u32 placements[3];
13 u32 busy_placements[3];
14 struct ttm_bo_kmap_obj kmap;
15 struct list_head head;
17 /* protected by ttm_bo_reserve() */
18 struct drm_file *reserved_by;
19 struct list_head entry;
20 int pbbo_index;
21 bool validate_mapped;
23 struct list_head vma_list;
24 unsigned page_shift;
26 u32 tile_mode;
27 u32 tile_flags;
28 struct nouveau_drm_tile *tile;
30 struct drm_gem_object *gem;
31 int pin_refcnt;
33 struct ttm_bo_kmap_obj dma_buf_vmap;
34 int vmapping_count;
37 static inline struct nouveau_bo *
38 nouveau_bo(struct ttm_buffer_object *bo)
40 return container_of(bo, struct nouveau_bo, bo);
43 static inline int
44 nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
46 struct nouveau_bo *prev;
48 if (!pnvbo)
49 return -EINVAL;
50 prev = *pnvbo;
52 *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
53 if (prev) {
54 struct ttm_buffer_object *bo = &prev->bo;
56 ttm_bo_unref(&bo);
59 return 0;
62 extern struct ttm_bo_driver nouveau_bo_driver;
64 void nouveau_bo_move_init(struct nouveau_channel *);
65 int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
66 u32 tile_mode, u32 tile_flags, struct sg_table *sg,
67 struct nouveau_bo **);
68 int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
69 int nouveau_bo_unpin(struct nouveau_bo *);
70 int nouveau_bo_map(struct nouveau_bo *);
71 void nouveau_bo_unmap(struct nouveau_bo *);
72 void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
73 u16 nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
74 void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
75 u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
76 void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
77 void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
78 int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
79 bool no_wait_reserve, bool no_wait_gpu);
81 struct nouveau_vma *
82 nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
84 int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
85 struct nouveau_vma *);
86 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
88 /* TODO: submit equivalent to TTM generic API upstream? */
89 static inline void __iomem *
90 nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
92 bool is_iomem;
93 void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual(
94 &nvbo->kmap, &is_iomem);
95 WARN_ON_ONCE(ioptr && !is_iomem);
96 return ioptr;
99 #endif