Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 1 | #ifndef __NOUVEAU_FENCE_H__ |
| 2 | #define __NOUVEAU_FENCE_H__ |
| 3 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 4 | struct nouveau_drm; |
| 5 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 6 | struct nouveau_fence { |
| 7 | struct list_head head; |
Ben Skeggs | c4c7044 | 2013-05-07 09:48:30 +1000 | [diff] [blame] | 8 | struct list_head work; |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 9 | struct kref kref; |
| 10 | |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 11 | bool sysmem; |
| 12 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 13 | struct nouveau_channel *channel; |
| 14 | unsigned long timeout; |
| 15 | u32 sequence; |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 16 | }; |
| 17 | |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 18 | int nouveau_fence_new(struct nouveau_channel *, bool sysmem, |
| 19 | struct nouveau_fence **); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 20 | struct nouveau_fence * |
| 21 | nouveau_fence_ref(struct nouveau_fence *); |
| 22 | void nouveau_fence_unref(struct nouveau_fence **); |
| 23 | |
| 24 | int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *); |
| 25 | bool nouveau_fence_done(struct nouveau_fence *); |
Ben Skeggs | c4c7044 | 2013-05-07 09:48:30 +1000 | [diff] [blame] | 26 | void nouveau_fence_work(struct nouveau_fence *, void (*)(void *), void *); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 27 | int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr); |
| 28 | int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 29 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 30 | struct nouveau_fence_chan { |
| 31 | struct list_head pending; |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 32 | struct list_head flip; |
| 33 | |
Ben Skeggs | 827520c | 2013-02-14 13:20:17 +1000 | [diff] [blame] | 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 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 41 | spinlock_t lock; |
| 42 | u32 sequence; |
| 43 | }; |
| 44 | |
| 45 | struct nouveau_fence_priv { |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 46 | void (*dtor)(struct nouveau_drm *); |
| 47 | bool (*suspend)(struct nouveau_drm *); |
| 48 | void (*resume)(struct nouveau_drm *); |
Ben Skeggs | e193b1d | 2012-07-19 10:51:42 +1000 | [diff] [blame] | 49 | int (*context_new)(struct nouveau_channel *); |
| 50 | void (*context_del)(struct nouveau_channel *); |
Ben Skeggs | e18c080 | 2013-01-31 14:57:33 +1000 | [diff] [blame] | 51 | |
| 52 | wait_queue_head_t waiting; |
| 53 | bool uevent; |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 54 | }; |
| 55 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 56 | #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence) |
| 57 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 58 | void nouveau_fence_context_new(struct nouveau_fence_chan *); |
| 59 | void nouveau_fence_context_del(struct nouveau_fence_chan *); |
| 60 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 61 | int nv04_fence_create(struct nouveau_drm *); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 62 | int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32); |
| 63 | |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 64 | int nv10_fence_emit(struct nouveau_fence *); |
| 65 | int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *, |
| 66 | struct nouveau_channel *); |
| 67 | u32 nv10_fence_read(struct nouveau_channel *); |
| 68 | void nv10_fence_context_del(struct nouveau_channel *); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 69 | void nv10_fence_destroy(struct nouveau_drm *); |
| 70 | int nv10_fence_create(struct nouveau_drm *); |
Ben Skeggs | 60e5cb7 | 2013-02-14 12:59:36 +1000 | [diff] [blame] | 71 | |
| 72 | int nv17_fence_create(struct nouveau_drm *); |
Marcin Slusarz | f20ebd0 | 2012-12-25 18:13:22 +0100 | [diff] [blame] | 73 | void nv17_fence_resume(struct nouveau_drm *drm); |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 74 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 75 | int nv50_fence_create(struct nouveau_drm *); |
| 76 | int nv84_fence_create(struct nouveau_drm *); |
| 77 | int nvc0_fence_create(struct nouveau_drm *); |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 78 | |
| 79 | int nouveau_flip_complete(void *chan); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 80 | |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 81 | struct nv84_fence_chan { |
| 82 | struct nouveau_fence_chan base; |
| 83 | struct nouveau_vma vma; |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 84 | struct nouveau_vma vma_gart; |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 85 | struct nouveau_vma dispc_vma[4]; |
| 86 | }; |
| 87 | |
| 88 | struct nv84_fence_priv { |
| 89 | struct nouveau_fence_priv base; |
| 90 | struct nouveau_bo *bo; |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 91 | struct nouveau_bo *bo_gart; |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 92 | u32 *suspend; |
| 93 | }; |
| 94 | |
| 95 | u64 nv84_fence_crtc(struct nouveau_channel *, int); |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 96 | int nv84_fence_context_new(struct nouveau_channel *); |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 97 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 98 | #endif |