nouveau_fence.h revision 1.5 1 #ifndef __NOUVEAU_FENCE_H__
2 #define __NOUVEAU_FENCE_H__
3
4 struct nouveau_drm;
5
6 struct nouveau_fence {
7 struct list_head head;
8 struct list_head work;
9 struct kref kref;
10
11 bool sysmem;
12 bool done;
13
14 struct nouveau_channel *channel;
15 unsigned long timeout;
16 u32 sequence;
17 };
18
19 int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
20 struct nouveau_fence **);
21 struct nouveau_fence *
22 nouveau_fence_ref(struct nouveau_fence *);
23 void nouveau_fence_unref(struct nouveau_fence **);
24
25 int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
26 bool nouveau_fence_done(struct nouveau_fence *);
27 void nouveau_fence_work(struct nouveau_fence *, void (*)(void *), void *);
28 int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
29 int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);
30
31 /*
32 * struct nouveau_fence_chan:
33 *
34 * State common to all fences in a single nouveau_channel.
35 */
36 struct nouveau_fence_chan {
37 struct list_head pending;
38 struct list_head flip;
39 struct list_head done;
40
41 int (*emit)(struct nouveau_fence *);
42 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
43 struct nouveau_channel *);
44 u32 (*read)(struct nouveau_channel *);
45 int (*emit32)(struct nouveau_channel *, u64, u32);
46 int (*sync32)(struct nouveau_channel *, u64, u32);
47
48 spinlock_t lock;
49 drm_waitqueue_t waitqueue;
50 volatile unsigned refcnt;
51 u32 sequence;
52 };
53
54 /*
55 * struct nouveau_fence_priv:
56 *
57 * Device-specific operations on fences.
58 */
59 struct nouveau_fence_priv {
60 void (*dtor)(struct nouveau_drm *);
61 bool (*suspend)(struct nouveau_drm *);
62 void (*resume)(struct nouveau_drm *);
63 int (*context_new)(struct nouveau_channel *);
64 void (*context_del)(struct nouveau_channel *);
65
66 bool uevent;
67 };
68
69 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
70
71 void nouveau_fence_context_new(struct nouveau_fence_chan *);
72 void nouveau_fence_context_del(struct nouveau_fence_chan *);
73
74 int nv04_fence_create(struct nouveau_drm *);
75 int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
76
77 int nv10_fence_emit(struct nouveau_fence *);
78 int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
79 struct nouveau_channel *);
80 u32 nv10_fence_read(struct nouveau_channel *);
81 void nv10_fence_context_del(struct nouveau_channel *);
82 void nv10_fence_destroy(struct nouveau_drm *);
83 int nv10_fence_create(struct nouveau_drm *);
84
85 int nv17_fence_create(struct nouveau_drm *);
86 void nv17_fence_resume(struct nouveau_drm *drm);
87
88 int nv50_fence_create(struct nouveau_drm *);
89 int nv84_fence_create(struct nouveau_drm *);
90 int nvc0_fence_create(struct nouveau_drm *);
91
92 int nouveau_flip_complete(void *chan);
93
94 struct nv84_fence_chan {
95 struct nouveau_fence_chan base;
96 struct nouveau_vma vma;
97 struct nouveau_vma vma_gart;
98 struct nouveau_vma dispc_vma[4];
99 };
100
101 struct nv84_fence_priv {
102 struct nouveau_fence_priv base;
103 struct nouveau_bo *bo;
104 struct nouveau_bo *bo_gart;
105 u32 *suspend;
106 };
107
108 u64 nv84_fence_crtc(struct nouveau_channel *, int);
109 int nv84_fence_context_new(struct nouveau_channel *);
110
111 #endif
112