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