blob: a5c47e348e22b4b9ea7e90f19a4ab55835ef239d [file] [log] [blame]
Ben Skeggsd375e7d52012-04-30 13:30:00 +10001#ifndef __NOUVEAU_FENCE_H__
2#define __NOUVEAU_FENCE_H__
3
Ben Skeggsebb945a2012-07-20 08:17:34 +10004struct nouveau_drm;
5
Ben Skeggsd375e7d52012-04-30 13:30:00 +10006struct nouveau_fence {
7 struct list_head head;
8 struct kref kref;
9
10 struct nouveau_channel *channel;
11 unsigned long timeout;
12 u32 sequence;
13
14 void (*work)(void *priv, bool signalled);
15 void *priv;
16};
17
18int nouveau_fence_new(struct nouveau_channel *, struct nouveau_fence **);
19struct nouveau_fence *
20nouveau_fence_ref(struct nouveau_fence *);
21void nouveau_fence_unref(struct nouveau_fence **);
22
23int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
24bool nouveau_fence_done(struct nouveau_fence *);
25int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
26int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100027
Ben Skeggs5e120f62012-04-30 13:55:29 +100028struct nouveau_fence_chan {
29 struct list_head pending;
Ben Skeggsf589be82012-07-22 11:55:54 +100030 struct list_head flip;
31
Ben Skeggs827520c2013-02-14 13:20:17 +100032 int (*emit)(struct nouveau_fence *);
33 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
34 struct nouveau_channel *);
35 u32 (*read)(struct nouveau_channel *);
36 int (*emit32)(struct nouveau_channel *, u64, u32);
37 int (*sync32)(struct nouveau_channel *, u64, u32);
38
Ben Skeggs5e120f62012-04-30 13:55:29 +100039 spinlock_t lock;
40 u32 sequence;
41};
42
43struct nouveau_fence_priv {
Ben Skeggsebb945a2012-07-20 08:17:34 +100044 void (*dtor)(struct nouveau_drm *);
45 bool (*suspend)(struct nouveau_drm *);
46 void (*resume)(struct nouveau_drm *);
Ben Skeggse193b1d2012-07-19 10:51:42 +100047 int (*context_new)(struct nouveau_channel *);
48 void (*context_del)(struct nouveau_channel *);
Ben Skeggse18c0802013-01-31 14:57:33 +100049
50 wait_queue_head_t waiting;
51 bool uevent;
Ben Skeggs5e120f62012-04-30 13:55:29 +100052};
53
Ben Skeggsebb945a2012-07-20 08:17:34 +100054#define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
55
Ben Skeggs5e120f62012-04-30 13:55:29 +100056void nouveau_fence_context_new(struct nouveau_fence_chan *);
57void nouveau_fence_context_del(struct nouveau_fence_chan *);
58
Ben Skeggsebb945a2012-07-20 08:17:34 +100059int nv04_fence_create(struct nouveau_drm *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100060int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
61
Ben Skeggsf589be82012-07-22 11:55:54 +100062int nv10_fence_emit(struct nouveau_fence *);
63int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
64 struct nouveau_channel *);
65u32 nv10_fence_read(struct nouveau_channel *);
66void nv10_fence_context_del(struct nouveau_channel *);
Ben Skeggsebb945a2012-07-20 08:17:34 +100067void nv10_fence_destroy(struct nouveau_drm *);
68int nv10_fence_create(struct nouveau_drm *);
Ben Skeggs60e5cb72013-02-14 12:59:36 +100069
70int nv17_fence_create(struct nouveau_drm *);
Marcin Slusarzf20ebd02012-12-25 18:13:22 +010071void nv17_fence_resume(struct nouveau_drm *drm);
Ben Skeggsf589be82012-07-22 11:55:54 +100072
Ben Skeggsebb945a2012-07-20 08:17:34 +100073int nv50_fence_create(struct nouveau_drm *);
74int nv84_fence_create(struct nouveau_drm *);
75int nvc0_fence_create(struct nouveau_drm *);
Ben Skeggsf589be82012-07-22 11:55:54 +100076
77int nouveau_flip_complete(void *chan);
Ben Skeggs5e120f62012-04-30 13:55:29 +100078
Ben Skeggsa34caf72013-02-14 09:28:37 +100079struct nv84_fence_chan {
80 struct nouveau_fence_chan base;
81 struct nouveau_vma vma;
82 struct nouveau_vma dispc_vma[4];
83};
84
85struct nv84_fence_priv {
86 struct nouveau_fence_priv base;
87 struct nouveau_bo *bo;
88 u32 *suspend;
89};
90
91u64 nv84_fence_crtc(struct nouveau_channel *, int);
Ben Skeggsbba98522013-02-14 09:37:35 +100092int nv84_fence_emit(struct nouveau_fence *);
93int nv84_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
94 struct nouveau_channel *);
Ben Skeggsa34caf72013-02-14 09:28:37 +100095u32 nv84_fence_read(struct nouveau_channel *);
96int nv84_fence_context_new(struct nouveau_channel *);
97void nv84_fence_context_del(struct nouveau_channel *);
98bool nv84_fence_suspend(struct nouveau_drm *);
99void nv84_fence_resume(struct nouveau_drm *);
100void nv84_fence_destroy(struct nouveau_drm *);
101
Ben Skeggsd375e7d52012-04-30 13:30:00 +1000102#endif