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