drm/nv50-/disp: add support for completion events
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / nouveau / core / engine / disp / nv50.h
1 #ifndef __NV50_DISP_H__
2 #define __NV50_DISP_H__
3
4 #include <core/parent.h>
5 #include <core/namedb.h>
6 #include <core/engctx.h>
7 #include <core/ramht.h>
8 #include <core/event.h>
9
10 #include <engine/dmaobj.h>
11
12 #include "dport.h"
13 #include "priv.h"
14 #include "outp.h"
15 #include "outpdp.h"
16
17 #define NV50_DISP_MTHD_ struct nouveau_object *object,                         \
18         struct nv50_disp_priv *priv, void *data, u32 size
19 #define NV50_DISP_MTHD_V0 NV50_DISP_MTHD_, int head
20 #define NV50_DISP_MTHD_V1 NV50_DISP_MTHD_, int head, struct nvkm_output *outp
21
22 struct nv50_disp_priv {
23         struct nouveau_disp base;
24         struct nouveau_oclass *sclass;
25
26         struct work_struct supervisor;
27         u32 super;
28
29         struct nvkm_event uevent;
30
31         struct {
32                 int nr;
33         } head;
34         struct {
35                 int nr;
36                 int (*power)(NV50_DISP_MTHD_V1);
37                 int (*sense)(NV50_DISP_MTHD_V1);
38         } dac;
39         struct {
40                 int nr;
41                 int (*power)(NV50_DISP_MTHD_V1);
42                 int (*hda_eld)(NV50_DISP_MTHD_V1);
43                 int (*hdmi)(NV50_DISP_MTHD_V1);
44                 u32 lvdsconf;
45         } sor;
46         struct {
47                 int nr;
48                 int (*power)(NV50_DISP_MTHD_V1);
49                 u8 type[3];
50         } pior;
51 };
52
53 struct nv50_disp_impl {
54         struct nouveau_disp_impl base;
55         struct {
56                 const struct nv50_disp_mthd_chan *core;
57                 const struct nv50_disp_mthd_chan *base;
58                 const struct nv50_disp_mthd_chan *ovly;
59                 int prev;
60         } mthd;
61         struct {
62                 int (*scanoutpos)(NV50_DISP_MTHD_V0);
63         } head;
64 };
65
66 int nv50_disp_base_scanoutpos(NV50_DISP_MTHD_V0);
67 int nv50_disp_base_mthd(struct nouveau_object *, u32, void *, u32);
68
69 int nvd0_disp_base_scanoutpos(NV50_DISP_MTHD_V0);
70
71 int nv50_dac_power(NV50_DISP_MTHD_V1);
72 int nv50_dac_sense(NV50_DISP_MTHD_V1);
73
74 int nva3_hda_eld(NV50_DISP_MTHD_V1);
75 int nvd0_hda_eld(NV50_DISP_MTHD_V1);
76
77 int nv84_hdmi_ctrl(NV50_DISP_MTHD_V1);
78 int nva3_hdmi_ctrl(NV50_DISP_MTHD_V1);
79 int nvd0_hdmi_ctrl(NV50_DISP_MTHD_V1);
80
81 int nv50_sor_power(NV50_DISP_MTHD_V1);
82
83 int nv94_sor_dp_train_init(struct nv50_disp_priv *, int, int, int, u16, u16,
84                            u32, struct dcb_output *);
85 int nv94_sor_dp_train_fini(struct nv50_disp_priv *, int, int, int, u16, u16,
86                            u32, struct dcb_output *);
87 int nv94_sor_dp_train(struct nv50_disp_priv *, int, int, u16, u16, u32,
88                       struct dcb_output *);
89 int nv94_sor_dp_lnkctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
90                        struct dcb_output *);
91 int nv94_sor_dp_drvctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
92                        struct dcb_output *);
93
94 int nvd0_sor_dp_train(struct nv50_disp_priv *, int, int, u16, u16, u32,
95                       struct dcb_output *);
96 int nvd0_sor_dp_lnkctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
97                        struct dcb_output *);
98 int nvd0_sor_dp_drvctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
99                        struct dcb_output *);
100
101 int nv50_pior_power(NV50_DISP_MTHD_V1);
102
103 struct nv50_disp_base {
104         struct nouveau_parent base;
105         struct nouveau_ramht *ramht;
106         u32 chan;
107 };
108
109 struct nv50_disp_chan_impl {
110         struct nouveau_ofuncs base;
111         int chid;
112         int  (*attach)(struct nouveau_object *, struct nouveau_object *, u32);
113         void (*detach)(struct nouveau_object *, int);
114 };
115
116 struct nv50_disp_chan {
117         struct nouveau_namedb base;
118         int chid;
119 };
120
121 int  nv50_disp_chan_ntfy(struct nouveau_object *, u32, struct nvkm_event **);
122 int  nv50_disp_chan_map(struct nouveau_object *, u64 *, u32 *);
123 u32  nv50_disp_chan_rd32(struct nouveau_object *, u64);
124 void nv50_disp_chan_wr32(struct nouveau_object *, u64, u32);
125 extern const struct nvkm_event_func nv50_disp_chan_uevent;
126 int  nv50_disp_chan_uevent_ctor(struct nouveau_object *, void *, u32,
127                                 struct nvkm_notify *);
128 void nv50_disp_chan_uevent_send(struct nv50_disp_priv *, int);
129
130 extern const struct nvkm_event_func nvd0_disp_chan_uevent;
131
132 #define nv50_disp_chan_init(a)                                                 \
133         nouveau_namedb_init(&(a)->base)
134 #define nv50_disp_chan_fini(a,b)                                               \
135         nouveau_namedb_fini(&(a)->base, (b))
136
137 struct nv50_disp_dmac {
138         struct nv50_disp_chan base;
139         struct nouveau_dmaobj *pushdma;
140         u32 push;
141 };
142
143 void nv50_disp_dmac_dtor(struct nouveau_object *);
144
145 struct nv50_disp_pioc {
146         struct nv50_disp_chan base;
147 };
148
149 void nv50_disp_pioc_dtor(struct nouveau_object *);
150
151 struct nv50_disp_mthd_list {
152         u32 mthd;
153         u32 addr;
154         struct {
155                 u32 mthd;
156                 u32 addr;
157                 const char *name;
158         } data[];
159 };
160
161 struct nv50_disp_mthd_chan {
162         const char *name;
163         u32 addr;
164         struct {
165                 const char *name;
166                 int nr;
167                 const struct nv50_disp_mthd_list *mthd;
168         } data[];
169 };
170
171 extern struct nv50_disp_chan_impl nv50_disp_mast_ofuncs;
172 int nv50_disp_mast_ctor(struct nouveau_object *, struct nouveau_object *,
173                         struct nouveau_oclass *, void *, u32,
174                         struct nouveau_object **);
175 extern const struct nv50_disp_mthd_list nv50_disp_mast_mthd_base;
176 extern const struct nv50_disp_mthd_list nv50_disp_mast_mthd_sor;
177 extern const struct nv50_disp_mthd_list nv50_disp_mast_mthd_pior;
178 extern struct nv50_disp_chan_impl nv50_disp_sync_ofuncs;
179 int nv50_disp_sync_ctor(struct nouveau_object *, struct nouveau_object *,
180                         struct nouveau_oclass *, void *, u32,
181                         struct nouveau_object **);
182 extern const struct nv50_disp_mthd_list nv50_disp_sync_mthd_image;
183 extern struct nv50_disp_chan_impl nv50_disp_ovly_ofuncs;
184 int nv50_disp_ovly_ctor(struct nouveau_object *, struct nouveau_object *,
185                         struct nouveau_oclass *, void *, u32,
186                         struct nouveau_object **);
187 extern const struct nv50_disp_mthd_list nv50_disp_ovly_mthd_base;
188 extern struct nv50_disp_chan_impl nv50_disp_oimm_ofuncs;
189 int nv50_disp_oimm_ctor(struct nouveau_object *, struct nouveau_object *,
190                         struct nouveau_oclass *, void *, u32,
191                         struct nouveau_object **);
192 extern struct nv50_disp_chan_impl nv50_disp_curs_ofuncs;
193 int nv50_disp_curs_ctor(struct nouveau_object *, struct nouveau_object *,
194                         struct nouveau_oclass *, void *, u32,
195                         struct nouveau_object **);
196 extern struct nouveau_ofuncs nv50_disp_base_ofuncs;
197 int  nv50_disp_base_ctor(struct nouveau_object *, struct nouveau_object *,
198                          struct nouveau_oclass *, void *, u32,
199                          struct nouveau_object **);
200 void nv50_disp_base_dtor(struct nouveau_object *);
201 extern struct nouveau_omthds nv50_disp_base_omthds[];
202 extern struct nouveau_oclass nv50_disp_cclass;
203 void nv50_disp_mthd_chan(struct nv50_disp_priv *, int debug, int head,
204                          const struct nv50_disp_mthd_chan *);
205 void nv50_disp_intr_supervisor(struct work_struct *);
206 void nv50_disp_intr(struct nouveau_subdev *);
207 extern const struct nvkm_event_func nv50_disp_vblank_func;
208
209 extern const struct nv50_disp_mthd_chan nv84_disp_mast_mthd_chan;
210 extern const struct nv50_disp_mthd_list nv84_disp_mast_mthd_dac;
211 extern const struct nv50_disp_mthd_list nv84_disp_mast_mthd_head;
212 extern const struct nv50_disp_mthd_chan nv84_disp_sync_mthd_chan;
213 extern const struct nv50_disp_mthd_chan nv84_disp_ovly_mthd_chan;
214
215 extern const struct nv50_disp_mthd_chan nv94_disp_mast_mthd_chan;
216
217 extern struct nv50_disp_chan_impl nvd0_disp_mast_ofuncs;
218 extern const struct nv50_disp_mthd_list nvd0_disp_mast_mthd_base;
219 extern const struct nv50_disp_mthd_list nvd0_disp_mast_mthd_dac;
220 extern const struct nv50_disp_mthd_list nvd0_disp_mast_mthd_sor;
221 extern const struct nv50_disp_mthd_list nvd0_disp_mast_mthd_pior;
222 extern struct nv50_disp_chan_impl nvd0_disp_sync_ofuncs;
223 extern struct nv50_disp_chan_impl nvd0_disp_ovly_ofuncs;
224 extern const struct nv50_disp_mthd_chan nvd0_disp_sync_mthd_chan;
225 extern struct nv50_disp_chan_impl nvd0_disp_oimm_ofuncs;
226 extern struct nv50_disp_chan_impl nvd0_disp_curs_ofuncs;
227 extern struct nouveau_ofuncs nvd0_disp_base_ofuncs;
228 extern struct nouveau_oclass nvd0_disp_cclass;
229 void nvd0_disp_intr_supervisor(struct work_struct *);
230 void nvd0_disp_intr(struct nouveau_subdev *);
231 extern const struct nvkm_event_func nvd0_disp_vblank_func;
232
233 extern const struct nv50_disp_mthd_chan nve0_disp_mast_mthd_chan;
234 extern const struct nv50_disp_mthd_chan nve0_disp_ovly_mthd_chan;
235
236 extern struct nvkm_output_dp_impl nv50_pior_dp_impl;
237 extern struct nouveau_oclass *nv50_disp_outp_sclass[];
238
239 extern struct nvkm_output_dp_impl nv94_sor_dp_impl;
240 int nv94_sor_dp_lnk_pwr(struct nvkm_output_dp *, int);
241 extern struct nouveau_oclass *nv94_disp_outp_sclass[];
242
243 extern struct nvkm_output_dp_impl nvd0_sor_dp_impl;
244 extern struct nouveau_oclass *nvd0_disp_outp_sclass[];
245
246 #endif