1 #ifndef __NV50_KMS_H__
2 #define __NV50_KMS_H__
3 #include <nvif/mem.h>
4 
5 #include "nouveau_display.h"
6 
7 struct nv50_msto;
8 
9 struct nv50_disp {
10 	struct nvif_disp *disp;
11 	struct nv50_core *core;
12 	struct nvif_object caps;
13 
14 #define NV50_DISP_SYNC(c, o)                                ((c) * 0x040 + (o))
15 #define NV50_DISP_CORE_NTFY                       NV50_DISP_SYNC(0      , 0x00)
16 #define NV50_DISP_WNDW_SEM0(c)                    NV50_DISP_SYNC(1 + (c), 0x00)
17 #define NV50_DISP_WNDW_SEM1(c)                    NV50_DISP_SYNC(1 + (c), 0x10)
18 #define NV50_DISP_WNDW_NTFY(c)                    NV50_DISP_SYNC(1 + (c), 0x20)
19 #define NV50_DISP_BASE_SEM0(c)                    NV50_DISP_WNDW_SEM0(0 + (c))
20 #define NV50_DISP_BASE_SEM1(c)                    NV50_DISP_WNDW_SEM1(0 + (c))
21 #define NV50_DISP_BASE_NTFY(c)                    NV50_DISP_WNDW_NTFY(0 + (c))
22 #define NV50_DISP_OVLY_SEM0(c)                    NV50_DISP_WNDW_SEM0(4 + (c))
23 #define NV50_DISP_OVLY_SEM1(c)                    NV50_DISP_WNDW_SEM1(4 + (c))
24 #define NV50_DISP_OVLY_NTFY(c)                    NV50_DISP_WNDW_NTFY(4 + (c))
25 	struct nouveau_bo *sync;
26 
27 	struct mutex mutex;
28 };
29 
30 static inline struct nv50_disp *
31 nv50_disp(struct drm_device *dev)
32 {
33 	return nouveau_display(dev)->priv;
34 }
35 
36 struct nv50_disp_interlock {
37 	enum nv50_disp_interlock_type {
38 		NV50_DISP_INTERLOCK_CORE = 0,
39 		NV50_DISP_INTERLOCK_CURS,
40 		NV50_DISP_INTERLOCK_BASE,
41 		NV50_DISP_INTERLOCK_OVLY,
42 		NV50_DISP_INTERLOCK_WNDW,
43 		NV50_DISP_INTERLOCK_WIMM,
44 		NV50_DISP_INTERLOCK__SIZE
45 	} type;
46 	u32 data;
47 	u32 wimm;
48 };
49 
50 void corec37d_ntfy_init(struct nouveau_bo *, u32);
51 
52 void head907d_olut_load(struct drm_color_lut *, int size, void __iomem *);
53 
54 struct nv50_chan {
55 	struct nvif_object user;
56 	struct nvif_device *device;
57 };
58 
59 struct nv50_dmac {
60 	struct nv50_chan base;
61 
62 	struct nvif_mem push;
63 	u32 *ptr;
64 
65 	struct nvif_object sync;
66 	struct nvif_object vram;
67 
68 	/* Protects against concurrent pushbuf access to this channel, lock is
69 	 * grabbed by evo_wait (if the pushbuf reservation is successful) and
70 	 * dropped again by evo_kick. */
71 	struct mutex lock;
72 };
73 
74 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
75 		     const s32 *oclass, u8 head, void *data, u32 size,
76 		     u64 syncbuf, struct nv50_dmac *dmac);
77 void nv50_dmac_destroy(struct nv50_dmac *);
78 
79 u32 *evo_wait(struct nv50_dmac *, int nr);
80 void evo_kick(u32 *, struct nv50_dmac *);
81 
82 extern const u64 disp50xx_modifiers[];
83 extern const u64 disp90xx_modifiers[];
84 extern const u64 wndwc57e_modifiers[];
85 
86 #define evo_mthd(p, m, s) do {						\
87 	const u32 _m = (m), _s = (s);					\
88 	if (drm_debug_enabled(DRM_UT_KMS))				\
89 		pr_err("%04x %d %s\n", _m, _s, __func__);		\
90 	*((p)++) = ((_s << 18) | _m);					\
91 } while(0)
92 
93 #define evo_data(p, d) do {						\
94 	const u32 _d = (d);						\
95 	if (drm_debug_enabled(DRM_UT_KMS))				\
96 		pr_err("\t%08x\n", _d);					\
97 	*((p)++) = _d;							\
98 } while(0)
99 #endif
100