1 #ifndef __NV50_KMS_WNDW_H__
2 #define __NV50_KMS_WNDW_H__
3 #define nv50_wndw(p) container_of((p), struct nv50_wndw, plane)
4 #include "disp.h"
5 #include "atom.h"
6 #include "lut.h"
7 
8 struct nv50_wndw_ctxdma {
9 	struct list_head head;
10 	struct nvif_object object;
11 };
12 
13 struct nv50_wndw {
14 	const struct nv50_wndw_func *func;
15 	const struct nv50_wimm_func *immd;
16 	int id;
17 	struct nv50_disp_interlock interlock;
18 
19 	struct {
20 		struct nvif_object *parent;
21 		struct list_head list;
22 	} ctxdma;
23 
24 	struct drm_plane plane;
25 
26 	struct nv50_lut ilut;
27 
28 	struct nv50_dmac wndw;
29 	struct nv50_dmac wimm;
30 
31 	u16 ntfy;
32 	u16 sema;
33 	u32 data;
34 };
35 
36 int nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *,
37 		   enum drm_plane_type, const char *name, int index,
38 		   const u32 *format, enum nv50_disp_interlock_type,
39 		   u32 interlock_data, u32 heads, struct nv50_wndw **);
40 void nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock,
41 			 struct nv50_wndw_atom *);
42 void nv50_wndw_flush_clr(struct nv50_wndw *, u32 *interlock, bool flush,
43 			 struct nv50_wndw_atom *);
44 void nv50_wndw_ntfy_enable(struct nv50_wndw *, struct nv50_wndw_atom *);
45 int nv50_wndw_wait_armed(struct nv50_wndw *, struct nv50_wndw_atom *);
46 
47 struct nv50_wndw_func {
48 	int (*acquire)(struct nv50_wndw *, struct nv50_wndw_atom *asyw,
49 		       struct nv50_head_atom *asyh);
50 	void (*release)(struct nv50_wndw *, struct nv50_wndw_atom *asyw,
51 			struct nv50_head_atom *asyh);
52 	void (*prepare)(struct nv50_wndw *, struct nv50_head_atom *asyh,
53 			struct nv50_wndw_atom *asyw);
54 
55 	int (*sema_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
56 	int (*sema_clr)(struct nv50_wndw *);
57 	void (*ntfy_reset)(struct nouveau_bo *, u32 offset);
58 	int (*ntfy_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
59 	int (*ntfy_clr)(struct nv50_wndw *);
60 	int (*ntfy_wait_begun)(struct nouveau_bo *, u32 offset,
61 			       struct nvif_device *);
62 	void (*ilut)(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyh, int size);
63 	void (*csc)(struct nv50_wndw *, struct nv50_wndw_atom *,
64 		    const struct drm_color_ctm *);
65 	int (*csc_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
66 	int (*csc_clr)(struct nv50_wndw *);
67 	bool ilut_identity;
68 	int  ilut_size;
69 	bool olut_core;
70 	int (*xlut_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
71 	int (*xlut_clr)(struct nv50_wndw *);
72 	int (*image_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
73 	int (*image_clr)(struct nv50_wndw *);
74 	int (*scale_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
75 	int (*blend_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
76 
77 	int (*update)(struct nv50_wndw *, u32 *interlock);
78 };
79 
80 extern const struct drm_plane_funcs nv50_wndw;
81 
82 void base507c_ntfy_reset(struct nouveau_bo *, u32);
83 int base507c_ntfy_set(struct nv50_wndw *, struct nv50_wndw_atom *);
84 int base507c_ntfy_clr(struct nv50_wndw *);
85 int base507c_ntfy_wait_begun(struct nouveau_bo *, u32, struct nvif_device *);
86 int base507c_image_clr(struct nv50_wndw *);
87 int base507c_update(struct nv50_wndw *, u32 *);
88 
89 void base907c_csc(struct nv50_wndw *, struct nv50_wndw_atom *,
90 		  const struct drm_color_ctm *);
91 
92 struct nv50_wimm_func {
93 	int (*point)(struct nv50_wndw *, struct nv50_wndw_atom *);
94 
95 	int (*update)(struct nv50_wndw *, u32 *interlock);
96 };
97 
98 extern const struct nv50_wimm_func curs507a;
99 bool curs507a_space(struct nv50_wndw *);
100 
101 static inline __must_check int
102 nvif_chan_wait(struct nv50_dmac *dmac, u32 size)
103 {
104 	struct nv50_wndw *wndw = container_of(dmac, typeof(*wndw), wimm);
105 	return curs507a_space(wndw) ? 0 : -ETIMEDOUT;
106 }
107 
108 int wndwc37e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
109 		 struct nv50_wndw **);
110 int wndwc37e_new_(const struct nv50_wndw_func *, struct nouveau_drm *,
111 		  enum drm_plane_type type, int index, s32 oclass, u32 heads,
112 		  struct nv50_wndw **);
113 int wndwc37e_acquire(struct nv50_wndw *, struct nv50_wndw_atom *,
114 		     struct nv50_head_atom *);
115 void wndwc37e_release(struct nv50_wndw *, struct nv50_wndw_atom *,
116 		      struct nv50_head_atom *);
117 int wndwc37e_sema_set(struct nv50_wndw *, struct nv50_wndw_atom *);
118 int wndwc37e_sema_clr(struct nv50_wndw *);
119 int wndwc37e_ntfy_set(struct nv50_wndw *, struct nv50_wndw_atom *);
120 int wndwc37e_ntfy_clr(struct nv50_wndw *);
121 int wndwc37e_image_clr(struct nv50_wndw *);
122 int wndwc37e_blend_set(struct nv50_wndw *, struct nv50_wndw_atom *);
123 int wndwc37e_update(struct nv50_wndw *, u32 *);
124 
125 int wndwc57e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
126 		 struct nv50_wndw **);
127 void wndwc57e_ilut(struct nv50_wndw *, struct nv50_wndw_atom *, int);
128 int wndwc57e_ilut_set(struct nv50_wndw *, struct nv50_wndw_atom *);
129 int wndwc57e_ilut_clr(struct nv50_wndw *);
130 int wndwc57e_csc_set(struct nv50_wndw *, struct nv50_wndw_atom *);
131 int wndwc57e_csc_clr(struct nv50_wndw *);
132 
133 int wndwc67e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
134 		 struct nv50_wndw **);
135 
136 int nv50_wndw_new(struct nouveau_drm *, enum drm_plane_type, int index,
137 		  struct nv50_wndw **);
138 #endif
139