]> Pileus Git - ~andy/linux/blob - drivers/gpu/drm/nouveau/nouveau_bo.h
drm/nouveau: pull nouveau_bo definitions into their own header
[~andy/linux] / drivers / gpu / drm / nouveau / nouveau_bo.h
1 #ifndef __NOUVEAU_BO_H__
2 #define __NOUVEAU_BO_H__
3
4 struct nouveau_channel;
5 struct nouveau_vma;
6
7 struct nouveau_tile_reg {
8         bool used;
9         struct nouveau_fence *fence;
10 };
11
12 struct nouveau_bo {
13         struct ttm_buffer_object bo;
14         struct ttm_placement placement;
15         u32 valid_domains;
16         u32 placements[3];
17         u32 busy_placements[3];
18         struct ttm_bo_kmap_obj kmap;
19         struct list_head head;
20
21         /* protected by ttm_bo_reserve() */
22         struct drm_file *reserved_by;
23         struct list_head entry;
24         int pbbo_index;
25         bool validate_mapped;
26
27         struct list_head vma_list;
28         unsigned page_shift;
29
30         u32 tile_mode;
31         u32 tile_flags;
32         struct nouveau_tile_reg *tile;
33
34         struct drm_gem_object *gem;
35         int pin_refcnt;
36
37         struct ttm_bo_kmap_obj dma_buf_vmap;
38         int vmapping_count;
39 };
40
41 static inline struct nouveau_bo *
42 nouveau_bo(struct ttm_buffer_object *bo)
43 {
44         return container_of(bo, struct nouveau_bo, bo);
45 }
46
47 static inline int
48 nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
49 {
50         struct nouveau_bo *prev;
51
52         if (!pnvbo)
53                 return -EINVAL;
54         prev = *pnvbo;
55
56         *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
57         if (prev) {
58                 struct ttm_buffer_object *bo = &prev->bo;
59
60                 ttm_bo_unref(&bo);
61         }
62
63         return 0;
64 }
65
66 extern struct ttm_bo_driver nouveau_bo_driver;
67
68 void nouveau_bo_move_init(struct nouveau_channel *);
69 int  nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
70                     u32 tile_mode, u32 tile_flags, struct sg_table *sg,
71                     struct nouveau_bo **);
72 int  nouveau_bo_pin(struct nouveau_bo *, u32 flags);
73 int  nouveau_bo_unpin(struct nouveau_bo *);
74 int  nouveau_bo_map(struct nouveau_bo *);
75 void nouveau_bo_unmap(struct nouveau_bo *);
76 void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
77 u16  nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
78 void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
79 u32  nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
80 void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
81 void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
82 int  nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
83                          bool no_wait_reserve, bool no_wait_gpu);
84
85 struct nouveau_vma *
86 nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
87
88 int  nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
89                         struct nouveau_vma *);
90 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
91
92 #endif