Home | History | Annotate | Line # | Download | only in nouveau
nouveau_fence.h revision 1.4
      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 
     40 	int  (*emit)(struct nouveau_fence *);
     41 	int  (*sync)(struct nouveau_fence *, struct nouveau_channel *,
     42 		     struct nouveau_channel *);
     43 	u32  (*read)(struct nouveau_channel *);
     44 	int  (*emit32)(struct nouveau_channel *, u64, u32);
     45 	int  (*sync32)(struct nouveau_channel *, u64, u32);
     46 
     47 	spinlock_t lock;
     48 	drm_waitqueue_t waitqueue;
     49 	volatile unsigned refcnt;
     50 	u32 sequence;
     51 };
     52 
     53 /*
     54  * struct nouveau_fence_priv:
     55  *
     56  *	Device-specific operations on fences.
     57  */
     58 struct nouveau_fence_priv {
     59 	void (*dtor)(struct nouveau_drm *);
     60 	bool (*suspend)(struct nouveau_drm *);
     61 	void (*resume)(struct nouveau_drm *);
     62 	int  (*context_new)(struct nouveau_channel *);
     63 	void (*context_del)(struct nouveau_channel *);
     64 
     65 	bool uevent;
     66 };
     67 
     68 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
     69 
     70 void nouveau_fence_context_new(struct nouveau_fence_chan *);
     71 void nouveau_fence_context_del(struct nouveau_fence_chan *);
     72 
     73 int nv04_fence_create(struct nouveau_drm *);
     74 int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
     75 
     76 int  nv10_fence_emit(struct nouveau_fence *);
     77 int  nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
     78 		     struct nouveau_channel *);
     79 u32  nv10_fence_read(struct nouveau_channel *);
     80 void nv10_fence_context_del(struct nouveau_channel *);
     81 void nv10_fence_destroy(struct nouveau_drm *);
     82 int  nv10_fence_create(struct nouveau_drm *);
     83 
     84 int  nv17_fence_create(struct nouveau_drm *);
     85 void nv17_fence_resume(struct nouveau_drm *drm);
     86 
     87 int nv50_fence_create(struct nouveau_drm *);
     88 int nv84_fence_create(struct nouveau_drm *);
     89 int nvc0_fence_create(struct nouveau_drm *);
     90 
     91 int nouveau_flip_complete(void *chan);
     92 
     93 struct nv84_fence_chan {
     94 	struct nouveau_fence_chan base;
     95 	struct nouveau_vma vma;
     96 	struct nouveau_vma vma_gart;
     97 	struct nouveau_vma dispc_vma[4];
     98 };
     99 
    100 struct nv84_fence_priv {
    101 	struct nouveau_fence_priv base;
    102 	struct nouveau_bo *bo;
    103 	struct nouveau_bo *bo_gart;
    104 	u32 *suspend;
    105 };
    106 
    107 u64  nv84_fence_crtc(struct nouveau_channel *, int);
    108 int  nv84_fence_context_new(struct nouveau_channel *);
    109 
    110 #endif
    111