Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
[cascardo/linux.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                 void (*magic)(struct nvkm_output *);
46         } sor;
47         struct {
48                 int nr;
49                 int (*power)(NV50_DISP_MTHD_V1);
50                 u8 type[3];
51         } pior;
52 };
53
54 struct nv50_disp_impl {
55         struct nouveau_disp_impl base;
56         struct {
57                 const struct nv50_disp_mthd_chan *core;
58                 const struct nv50_disp_mthd_chan *base;
59                 const struct nv50_disp_mthd_chan *ovly;
60                 int prev;
61         } mthd;
62         struct {
63                 int (*scanoutpos)(NV50_DISP_MTHD_V0);
64         } head;
65 };
66
67 int nv50_disp_main_scanoutpos(NV50_DISP_MTHD_V0);
68 int nv50_disp_main_mthd(struct nouveau_object *, u32, void *, u32);
69
70 int nvd0_disp_main_scanoutpos(NV50_DISP_MTHD_V0);
71
72 int nv50_dac_power(NV50_DISP_MTHD_V1);
73 int nv50_dac_sense(NV50_DISP_MTHD_V1);
74
75 int nva3_hda_eld(NV50_DISP_MTHD_V1);
76 int nvd0_hda_eld(NV50_DISP_MTHD_V1);
77
78 int nv84_hdmi_ctrl(NV50_DISP_MTHD_V1);
79 int nva3_hdmi_ctrl(NV50_DISP_MTHD_V1);
80 int nvd0_hdmi_ctrl(NV50_DISP_MTHD_V1);
81 int nve0_hdmi_ctrl(NV50_DISP_MTHD_V1);
82
83 int nv50_sor_power(NV50_DISP_MTHD_V1);
84
85 int nv94_sor_dp_train_init(struct nv50_disp_priv *, int, int, int, u16, u16,
86                            u32, struct dcb_output *);
87 int nv94_sor_dp_train_fini(struct nv50_disp_priv *, int, int, int, u16, u16,
88                            u32, struct dcb_output *);
89 int nv94_sor_dp_train(struct nv50_disp_priv *, int, int, u16, u16, u32,
90                       struct dcb_output *);
91 int nv94_sor_dp_lnkctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
92                        struct dcb_output *);
93 int nv94_sor_dp_drvctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
94                        struct dcb_output *);
95
96 int nvd0_sor_dp_train(struct nv50_disp_priv *, int, int, u16, u16, u32,
97                       struct dcb_output *);
98 int nvd0_sor_dp_lnkctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
99                        struct dcb_output *);
100 int nvd0_sor_dp_drvctl(struct nv50_disp_priv *, int, int, int, u16, u16, u32,
101                        struct dcb_output *);
102
103 int nv50_pior_power(NV50_DISP_MTHD_V1);
104
105 struct nv50_disp_base {
106         struct nouveau_parent base;
107         struct nouveau_ramht *ramht;
108         u32 chan;
109 };
110
111 struct nv50_disp_chan_impl {
112         struct nouveau_ofuncs base;
113         int chid;
114         int  (*attach)(struct nouveau_object *, struct nouveau_object *, u32);
115         void (*detach)(struct nouveau_object *, int);
116 };
117
118 struct nv50_disp_chan {
119         struct nouveau_namedb base;
120         int chid;
121 };
122
123 int  nv50_disp_chan_ntfy(struct nouveau_object *, u32, struct nvkm_event **);
124 int  nv50_disp_chan_map(struct nouveau_object *, u64 *, u32 *);
125 u32  nv50_disp_chan_rd32(struct nouveau_object *, u64);
126 void nv50_disp_chan_wr32(struct nouveau_object *, u64, u32);
127 extern const struct nvkm_event_func nv50_disp_chan_uevent;
128 int  nv50_disp_chan_uevent_ctor(struct nouveau_object *, void *, u32,
129                                 struct nvkm_notify *);
130 void nv50_disp_chan_uevent_send(struct nv50_disp_priv *, int);
131
132 extern const struct nvkm_event_func nvd0_disp_chan_uevent;
133
134 #define nv50_disp_chan_init(a)                                                 \
135         nouveau_namedb_init(&(a)->base)
136 #define nv50_disp_chan_fini(a,b)                                               \
137         nouveau_namedb_fini(&(a)->base, (b))
138
139 struct nv50_disp_dmac {
140         struct nv50_disp_chan base;
141         struct nouveau_dmaobj *pushdma;
142         u32 push;
143 };
144
145 void nv50_disp_dmac_dtor(struct nouveau_object *);
146
147 struct nv50_disp_pioc {
148         struct nv50_disp_chan base;
149 };
150
151 void nv50_disp_pioc_dtor(struct nouveau_object *);
152
153 struct nv50_disp_mthd_list {
154         u32 mthd;
155         u32 addr;
156         struct {
157                 u32 mthd;
158                 u32 addr;
159                 const char *name;
160         } data[];
161 };
162
163 struct nv50_disp_mthd_chan {
164         const char *name;
165         u32 addr;
166         struct {
167                 const char *name;
168                 int nr;
169                 const struct nv50_disp_mthd_list *mthd;
170         } data[];
171 };
172
173 extern struct nv50_disp_chan_impl nv50_disp_core_ofuncs;
174 int nv50_disp_core_ctor(struct nouveau_object *, struct nouveau_object *,
175                         struct nouveau_oclass *, void *, u32,
176                         struct nouveau_object **);
177 extern const struct nv50_disp_mthd_list nv50_disp_core_mthd_base;
178 extern const struct nv50_disp_mthd_list nv50_disp_core_mthd_sor;
179 extern const struct nv50_disp_mthd_list nv50_disp_core_mthd_pior;
180 extern struct nv50_disp_chan_impl nv50_disp_base_ofuncs;
181 int nv50_disp_base_ctor(struct nouveau_object *, struct nouveau_object *,
182                         struct nouveau_oclass *, void *, u32,
183                         struct nouveau_object **);
184 extern const struct nv50_disp_mthd_list nv50_disp_base_mthd_image;
185 extern struct nv50_disp_chan_impl nv50_disp_ovly_ofuncs;
186 int nv50_disp_ovly_ctor(struct nouveau_object *, struct nouveau_object *,
187                         struct nouveau_oclass *, void *, u32,
188                         struct nouveau_object **);
189 extern const struct nv50_disp_mthd_list nv50_disp_ovly_mthd_base;
190 extern struct nv50_disp_chan_impl nv50_disp_oimm_ofuncs;
191 int nv50_disp_oimm_ctor(struct nouveau_object *, struct nouveau_object *,
192                         struct nouveau_oclass *, void *, u32,
193                         struct nouveau_object **);
194 extern struct nv50_disp_chan_impl nv50_disp_curs_ofuncs;
195 int nv50_disp_curs_ctor(struct nouveau_object *, struct nouveau_object *,
196                         struct nouveau_oclass *, void *, u32,
197                         struct nouveau_object **);
198 extern struct nouveau_ofuncs nv50_disp_main_ofuncs;
199 int  nv50_disp_main_ctor(struct nouveau_object *, struct nouveau_object *,
200                          struct nouveau_oclass *, void *, u32,
201                          struct nouveau_object **);
202 void nv50_disp_main_dtor(struct nouveau_object *);
203 extern struct nouveau_omthds nv50_disp_main_omthds[];
204 extern struct nouveau_oclass nv50_disp_cclass;
205 void nv50_disp_mthd_chan(struct nv50_disp_priv *, int debug, int head,
206                          const struct nv50_disp_mthd_chan *);
207 void nv50_disp_intr_supervisor(struct work_struct *);
208 void nv50_disp_intr(struct nouveau_subdev *);
209 extern const struct nvkm_event_func nv50_disp_vblank_func;
210
211 extern const struct nv50_disp_mthd_chan nv84_disp_core_mthd_chan;
212 extern const struct nv50_disp_mthd_list nv84_disp_core_mthd_dac;
213 extern const struct nv50_disp_mthd_list nv84_disp_core_mthd_head;
214 extern const struct nv50_disp_mthd_chan nv84_disp_base_mthd_chan;
215 extern const struct nv50_disp_mthd_chan nv84_disp_ovly_mthd_chan;
216
217 extern const struct nv50_disp_mthd_chan nv94_disp_core_mthd_chan;
218
219 extern struct nv50_disp_chan_impl nvd0_disp_core_ofuncs;
220 extern const struct nv50_disp_mthd_list nvd0_disp_core_mthd_base;
221 extern const struct nv50_disp_mthd_list nvd0_disp_core_mthd_dac;
222 extern const struct nv50_disp_mthd_list nvd0_disp_core_mthd_sor;
223 extern const struct nv50_disp_mthd_list nvd0_disp_core_mthd_pior;
224 extern struct nv50_disp_chan_impl nvd0_disp_base_ofuncs;
225 extern struct nv50_disp_chan_impl nvd0_disp_ovly_ofuncs;
226 extern const struct nv50_disp_mthd_chan nvd0_disp_base_mthd_chan;
227 extern struct nv50_disp_chan_impl nvd0_disp_oimm_ofuncs;
228 extern struct nv50_disp_chan_impl nvd0_disp_curs_ofuncs;
229 extern struct nouveau_ofuncs nvd0_disp_main_ofuncs;
230 extern struct nouveau_oclass nvd0_disp_cclass;
231 void nvd0_disp_intr_supervisor(struct work_struct *);
232 void nvd0_disp_intr(struct nouveau_subdev *);
233 extern const struct nvkm_event_func nvd0_disp_vblank_func;
234
235 extern const struct nv50_disp_mthd_chan nve0_disp_core_mthd_chan;
236 extern const struct nv50_disp_mthd_chan nve0_disp_ovly_mthd_chan;
237
238 extern struct nvkm_output_dp_impl nv50_pior_dp_impl;
239 extern struct nouveau_oclass *nv50_disp_outp_sclass[];
240
241 extern struct nvkm_output_dp_impl nv94_sor_dp_impl;
242 int nv94_sor_dp_lnk_pwr(struct nvkm_output_dp *, int);
243 extern struct nouveau_oclass *nv94_disp_outp_sclass[];
244
245 extern struct nvkm_output_dp_impl nvd0_sor_dp_impl;
246 int nvd0_sor_dp_lnk_ctl(struct nvkm_output_dp *, int, int, bool);
247 extern struct nouveau_oclass *nvd0_disp_outp_sclass[];
248
249 void gm204_sor_magic(struct nvkm_output *outp);
250 extern struct nvkm_output_dp_impl gm204_sor_dp_impl;
251
252 #endif