Linux-libre 3.17.4-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / nouveau / core / include / engine / fifo.h
1 #ifndef __NOUVEAU_FIFO_H__
2 #define __NOUVEAU_FIFO_H__
3
4 #include <core/namedb.h>
5 #include <core/gpuobj.h>
6 #include <core/engine.h>
7 #include <core/event.h>
8
9 struct nouveau_fifo_chan {
10         struct nouveau_namedb base;
11         struct nouveau_dmaobj *pushdma;
12         struct nouveau_gpuobj *pushgpu;
13         void __iomem *user;
14         u64 addr;
15         u32 size;
16         u16 chid;
17         atomic_t refcnt; /* NV04_NVSW_SET_REF */
18 };
19
20 static inline struct nouveau_fifo_chan *
21 nouveau_fifo_chan(void *obj)
22 {
23         return (void *)nv_namedb(obj);
24 }
25
26 #define nouveau_fifo_channel_create(p,e,c,b,a,s,n,m,d)                         \
27         nouveau_fifo_channel_create_((p), (e), (c), (b), (a), (s), (n),        \
28                                      (m), sizeof(**d), (void **)d)
29 #define nouveau_fifo_channel_init(p)                                           \
30         nouveau_namedb_init(&(p)->base)
31 #define nouveau_fifo_channel_fini(p,s)                                         \
32         nouveau_namedb_fini(&(p)->base, (s))
33
34 int  nouveau_fifo_channel_create_(struct nouveau_object *,
35                                   struct nouveau_object *,
36                                   struct nouveau_oclass *,
37                                   int bar, u32 addr, u32 size, u32 push,
38                                   u64 engmask, int len, void **);
39 void nouveau_fifo_channel_destroy(struct nouveau_fifo_chan *);
40
41 #define _nouveau_fifo_channel_init _nouveau_namedb_init
42 #define _nouveau_fifo_channel_fini _nouveau_namedb_fini
43
44 void _nouveau_fifo_channel_dtor(struct nouveau_object *);
45 int  _nouveau_fifo_channel_map(struct nouveau_object *, u64 *, u32 *);
46 u32  _nouveau_fifo_channel_rd32(struct nouveau_object *, u64);
47 void _nouveau_fifo_channel_wr32(struct nouveau_object *, u64, u32);
48 int  _nouveau_fifo_channel_ntfy(struct nouveau_object *, u32, struct nvkm_event **);
49
50 struct nouveau_fifo_base {
51         struct nouveau_gpuobj base;
52 };
53
54 #define nouveau_fifo_context_create(p,e,c,g,s,a,f,d)                           \
55         nouveau_gpuobj_create((p), (e), (c), 0, (g), (s), (a), (f), (d))
56 #define nouveau_fifo_context_destroy(p)                                        \
57         nouveau_gpuobj_destroy(&(p)->base)
58 #define nouveau_fifo_context_init(p)                                           \
59         nouveau_gpuobj_init(&(p)->base)
60 #define nouveau_fifo_context_fini(p,s)                                         \
61         nouveau_gpuobj_fini(&(p)->base, (s))
62
63 #define _nouveau_fifo_context_dtor _nouveau_gpuobj_dtor
64 #define _nouveau_fifo_context_init _nouveau_gpuobj_init
65 #define _nouveau_fifo_context_fini _nouveau_gpuobj_fini
66 #define _nouveau_fifo_context_rd32 _nouveau_gpuobj_rd32
67 #define _nouveau_fifo_context_wr32 _nouveau_gpuobj_wr32
68
69 struct nouveau_fifo {
70         struct nouveau_engine base;
71
72         struct nvkm_event cevent; /* channel creation event */
73         struct nvkm_event uevent; /* async user trigger */
74
75         struct nouveau_object **channel;
76         spinlock_t lock;
77         u16 min;
78         u16 max;
79
80         int  (*chid)(struct nouveau_fifo *, struct nouveau_object *);
81         void (*pause)(struct nouveau_fifo *, unsigned long *);
82         void (*start)(struct nouveau_fifo *, unsigned long *);
83 };
84
85 static inline struct nouveau_fifo *
86 nouveau_fifo(void *obj)
87 {
88         return (void *)nv_device(obj)->subdev[NVDEV_ENGINE_FIFO];
89 }
90
91 #define nouveau_fifo_create(o,e,c,fc,lc,d)                                     \
92         nouveau_fifo_create_((o), (e), (c), (fc), (lc), sizeof(**d), (void **)d)
93 #define nouveau_fifo_init(p)                                                   \
94         nouveau_engine_init(&(p)->base)
95 #define nouveau_fifo_fini(p,s)                                                 \
96         nouveau_engine_fini(&(p)->base, (s))
97
98 int nouveau_fifo_create_(struct nouveau_object *, struct nouveau_object *,
99                          struct nouveau_oclass *, int min, int max,
100                          int size, void **);
101 void nouveau_fifo_destroy(struct nouveau_fifo *);
102 const char *
103 nouveau_client_name_for_fifo_chid(struct nouveau_fifo *fifo, u32 chid);
104
105 #define _nouveau_fifo_init _nouveau_engine_init
106 #define _nouveau_fifo_fini _nouveau_engine_fini
107
108 extern struct nouveau_oclass *nv04_fifo_oclass;
109 extern struct nouveau_oclass *nv10_fifo_oclass;
110 extern struct nouveau_oclass *nv17_fifo_oclass;
111 extern struct nouveau_oclass *nv40_fifo_oclass;
112 extern struct nouveau_oclass *nv50_fifo_oclass;
113 extern struct nouveau_oclass *nv84_fifo_oclass;
114 extern struct nouveau_oclass *nvc0_fifo_oclass;
115 extern struct nouveau_oclass *nve0_fifo_oclass;
116 extern struct nouveau_oclass *gk20a_fifo_oclass;
117 extern struct nouveau_oclass *nv108_fifo_oclass;
118
119 int  nouveau_fifo_uevent_ctor(void *, u32, struct nvkm_notify *);
120 void nouveau_fifo_uevent(struct nouveau_fifo *);
121
122 void nv04_fifo_intr(struct nouveau_subdev *);
123 int  nv04_fifo_context_attach(struct nouveau_object *, struct nouveau_object *);
124
125 #endif