18c2ecf20Sopenharmony_ci#ifndef __NV50_KMS_WNDW_H__
28c2ecf20Sopenharmony_ci#define __NV50_KMS_WNDW_H__
38c2ecf20Sopenharmony_ci#define nv50_wndw(p) container_of((p), struct nv50_wndw, plane)
48c2ecf20Sopenharmony_ci#include "disp.h"
58c2ecf20Sopenharmony_ci#include "atom.h"
68c2ecf20Sopenharmony_ci#include "lut.h"
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <nvif/notify.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct nv50_wndw_ctxdma {
118c2ecf20Sopenharmony_ci	struct list_head head;
128c2ecf20Sopenharmony_ci	struct nvif_object object;
138c2ecf20Sopenharmony_ci};
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct nv50_wndw {
168c2ecf20Sopenharmony_ci	const struct nv50_wndw_func *func;
178c2ecf20Sopenharmony_ci	const struct nv50_wimm_func *immd;
188c2ecf20Sopenharmony_ci	int id;
198c2ecf20Sopenharmony_ci	struct nv50_disp_interlock interlock;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	struct {
228c2ecf20Sopenharmony_ci		struct nvif_object *parent;
238c2ecf20Sopenharmony_ci		struct list_head list;
248c2ecf20Sopenharmony_ci	} ctxdma;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	struct drm_plane plane;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	struct nv50_lut ilut;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	struct nv50_dmac wndw;
318c2ecf20Sopenharmony_ci	struct nv50_dmac wimm;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	struct nvif_notify notify;
348c2ecf20Sopenharmony_ci	u16 ntfy;
358c2ecf20Sopenharmony_ci	u16 sema;
368c2ecf20Sopenharmony_ci	u32 data;
378c2ecf20Sopenharmony_ci};
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciint nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *,
408c2ecf20Sopenharmony_ci		   enum drm_plane_type, const char *name, int index,
418c2ecf20Sopenharmony_ci		   const u32 *format, u32 heads,
428c2ecf20Sopenharmony_ci		   enum nv50_disp_interlock_type, u32 interlock_data,
438c2ecf20Sopenharmony_ci		   struct nv50_wndw **);
448c2ecf20Sopenharmony_civoid nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock,
458c2ecf20Sopenharmony_ci			 struct nv50_wndw_atom *);
468c2ecf20Sopenharmony_civoid nv50_wndw_flush_clr(struct nv50_wndw *, u32 *interlock, bool flush,
478c2ecf20Sopenharmony_ci			 struct nv50_wndw_atom *);
488c2ecf20Sopenharmony_civoid nv50_wndw_ntfy_enable(struct nv50_wndw *, struct nv50_wndw_atom *);
498c2ecf20Sopenharmony_ciint nv50_wndw_wait_armed(struct nv50_wndw *, struct nv50_wndw_atom *);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistruct nv50_wndw_func {
528c2ecf20Sopenharmony_ci	int (*acquire)(struct nv50_wndw *, struct nv50_wndw_atom *asyw,
538c2ecf20Sopenharmony_ci		       struct nv50_head_atom *asyh);
548c2ecf20Sopenharmony_ci	void (*release)(struct nv50_wndw *, struct nv50_wndw_atom *asyw,
558c2ecf20Sopenharmony_ci			struct nv50_head_atom *asyh);
568c2ecf20Sopenharmony_ci	void (*prepare)(struct nv50_wndw *, struct nv50_head_atom *asyh,
578c2ecf20Sopenharmony_ci			struct nv50_wndw_atom *asyw);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	int (*sema_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
608c2ecf20Sopenharmony_ci	int (*sema_clr)(struct nv50_wndw *);
618c2ecf20Sopenharmony_ci	void (*ntfy_reset)(struct nouveau_bo *, u32 offset);
628c2ecf20Sopenharmony_ci	int (*ntfy_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
638c2ecf20Sopenharmony_ci	int (*ntfy_clr)(struct nv50_wndw *);
648c2ecf20Sopenharmony_ci	int (*ntfy_wait_begun)(struct nouveau_bo *, u32 offset,
658c2ecf20Sopenharmony_ci			       struct nvif_device *);
668c2ecf20Sopenharmony_ci	bool (*ilut)(struct nv50_wndw *, struct nv50_wndw_atom *, int);
678c2ecf20Sopenharmony_ci	void (*csc)(struct nv50_wndw *, struct nv50_wndw_atom *,
688c2ecf20Sopenharmony_ci		    const struct drm_color_ctm *);
698c2ecf20Sopenharmony_ci	int (*csc_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
708c2ecf20Sopenharmony_ci	int (*csc_clr)(struct nv50_wndw *);
718c2ecf20Sopenharmony_ci	bool ilut_identity;
728c2ecf20Sopenharmony_ci	int  ilut_size;
738c2ecf20Sopenharmony_ci	bool olut_core;
748c2ecf20Sopenharmony_ci	int (*xlut_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
758c2ecf20Sopenharmony_ci	int (*xlut_clr)(struct nv50_wndw *);
768c2ecf20Sopenharmony_ci	int (*image_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
778c2ecf20Sopenharmony_ci	int (*image_clr)(struct nv50_wndw *);
788c2ecf20Sopenharmony_ci	int (*scale_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
798c2ecf20Sopenharmony_ci	int (*blend_set)(struct nv50_wndw *, struct nv50_wndw_atom *);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	int (*update)(struct nv50_wndw *, u32 *interlock);
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciextern const struct drm_plane_funcs nv50_wndw;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_civoid base507c_ntfy_reset(struct nouveau_bo *, u32);
878c2ecf20Sopenharmony_ciint base507c_ntfy_set(struct nv50_wndw *, struct nv50_wndw_atom *);
888c2ecf20Sopenharmony_ciint base507c_ntfy_clr(struct nv50_wndw *);
898c2ecf20Sopenharmony_ciint base507c_ntfy_wait_begun(struct nouveau_bo *, u32, struct nvif_device *);
908c2ecf20Sopenharmony_ciint base507c_image_clr(struct nv50_wndw *);
918c2ecf20Sopenharmony_ciint base507c_update(struct nv50_wndw *, u32 *);
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_civoid base907c_csc(struct nv50_wndw *, struct nv50_wndw_atom *,
948c2ecf20Sopenharmony_ci		  const struct drm_color_ctm *);
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistruct nv50_wimm_func {
978c2ecf20Sopenharmony_ci	int (*point)(struct nv50_wndw *, struct nv50_wndw_atom *);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci	int (*update)(struct nv50_wndw *, u32 *interlock);
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ciextern const struct nv50_wimm_func curs507a;
1038c2ecf20Sopenharmony_cibool curs507a_space(struct nv50_wndw *);
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistatic inline __must_check int
1068c2ecf20Sopenharmony_cinvif_chan_wait(struct nv50_dmac *dmac, u32 size)
1078c2ecf20Sopenharmony_ci{
1088c2ecf20Sopenharmony_ci	struct nv50_wndw *wndw = container_of(dmac, typeof(*wndw), wimm);
1098c2ecf20Sopenharmony_ci	return curs507a_space(wndw) ? 0 : -ETIMEDOUT;
1108c2ecf20Sopenharmony_ci}
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ciint wndwc37e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
1138c2ecf20Sopenharmony_ci		 struct nv50_wndw **);
1148c2ecf20Sopenharmony_ciint wndwc37e_new_(const struct nv50_wndw_func *, struct nouveau_drm *,
1158c2ecf20Sopenharmony_ci		  enum drm_plane_type type, int index, s32 oclass, u32 heads,
1168c2ecf20Sopenharmony_ci		  struct nv50_wndw **);
1178c2ecf20Sopenharmony_ciint wndwc37e_acquire(struct nv50_wndw *, struct nv50_wndw_atom *,
1188c2ecf20Sopenharmony_ci		     struct nv50_head_atom *);
1198c2ecf20Sopenharmony_civoid wndwc37e_release(struct nv50_wndw *, struct nv50_wndw_atom *,
1208c2ecf20Sopenharmony_ci		      struct nv50_head_atom *);
1218c2ecf20Sopenharmony_ciint wndwc37e_sema_set(struct nv50_wndw *, struct nv50_wndw_atom *);
1228c2ecf20Sopenharmony_ciint wndwc37e_sema_clr(struct nv50_wndw *);
1238c2ecf20Sopenharmony_ciint wndwc37e_ntfy_set(struct nv50_wndw *, struct nv50_wndw_atom *);
1248c2ecf20Sopenharmony_ciint wndwc37e_ntfy_clr(struct nv50_wndw *);
1258c2ecf20Sopenharmony_ciint wndwc37e_image_clr(struct nv50_wndw *);
1268c2ecf20Sopenharmony_ciint wndwc37e_blend_set(struct nv50_wndw *, struct nv50_wndw_atom *);
1278c2ecf20Sopenharmony_ciint wndwc37e_update(struct nv50_wndw *, u32 *);
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ciint wndwc57e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
1308c2ecf20Sopenharmony_ci		 struct nv50_wndw **);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciint nv50_wndw_new(struct nouveau_drm *, enum drm_plane_type, int index,
1338c2ecf20Sopenharmony_ci		  struct nv50_wndw **);
1348c2ecf20Sopenharmony_ci#endif
135