18c2ecf20Sopenharmony_ci#ifndef __NV50_KMS_H__
28c2ecf20Sopenharmony_ci#define __NV50_KMS_H__
38c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
48c2ecf20Sopenharmony_ci#include <nvif/mem.h>
58c2ecf20Sopenharmony_ci#include <nvif/push.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include "nouveau_display.h"
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cistruct nv50_msto;
108c2ecf20Sopenharmony_cistruct nouveau_encoder;
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct nv50_disp {
138c2ecf20Sopenharmony_ci	struct nvif_disp *disp;
148c2ecf20Sopenharmony_ci	struct nv50_core *core;
158c2ecf20Sopenharmony_ci	struct nvif_object caps;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define NV50_DISP_SYNC(c, o)                                ((c) * 0x040 + (o))
188c2ecf20Sopenharmony_ci#define NV50_DISP_CORE_NTFY                       NV50_DISP_SYNC(0      , 0x00)
198c2ecf20Sopenharmony_ci#define NV50_DISP_WNDW_SEM0(c)                    NV50_DISP_SYNC(1 + (c), 0x00)
208c2ecf20Sopenharmony_ci#define NV50_DISP_WNDW_SEM1(c)                    NV50_DISP_SYNC(1 + (c), 0x10)
218c2ecf20Sopenharmony_ci#define NV50_DISP_WNDW_NTFY(c)                    NV50_DISP_SYNC(1 + (c), 0x20)
228c2ecf20Sopenharmony_ci#define NV50_DISP_BASE_SEM0(c)                    NV50_DISP_WNDW_SEM0(0 + (c))
238c2ecf20Sopenharmony_ci#define NV50_DISP_BASE_SEM1(c)                    NV50_DISP_WNDW_SEM1(0 + (c))
248c2ecf20Sopenharmony_ci#define NV50_DISP_BASE_NTFY(c)                    NV50_DISP_WNDW_NTFY(0 + (c))
258c2ecf20Sopenharmony_ci#define NV50_DISP_OVLY_SEM0(c)                    NV50_DISP_WNDW_SEM0(4 + (c))
268c2ecf20Sopenharmony_ci#define NV50_DISP_OVLY_SEM1(c)                    NV50_DISP_WNDW_SEM1(4 + (c))
278c2ecf20Sopenharmony_ci#define NV50_DISP_OVLY_NTFY(c)                    NV50_DISP_WNDW_NTFY(4 + (c))
288c2ecf20Sopenharmony_ci	struct nouveau_bo *sync;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	struct mutex mutex;
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic inline struct nv50_disp *
348c2ecf20Sopenharmony_cinv50_disp(struct drm_device *dev)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci	return nouveau_display(dev)->priv;
378c2ecf20Sopenharmony_ci}
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistruct nv50_disp_interlock {
408c2ecf20Sopenharmony_ci	enum nv50_disp_interlock_type {
418c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_CORE = 0,
428c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_CURS,
438c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_BASE,
448c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_OVLY,
458c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_WNDW,
468c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK_WIMM,
478c2ecf20Sopenharmony_ci		NV50_DISP_INTERLOCK__SIZE
488c2ecf20Sopenharmony_ci	} type;
498c2ecf20Sopenharmony_ci	u32 data;
508c2ecf20Sopenharmony_ci	u32 wimm;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_civoid corec37d_ntfy_init(struct nouveau_bo *, u32);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_civoid head907d_olut_load(struct drm_color_lut *, int size, void __iomem *);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct nv50_chan {
588c2ecf20Sopenharmony_ci	struct nvif_object user;
598c2ecf20Sopenharmony_ci	struct nvif_device *device;
608c2ecf20Sopenharmony_ci};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct nv50_dmac {
638c2ecf20Sopenharmony_ci	struct nv50_chan base;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	struct nvif_push _push;
668c2ecf20Sopenharmony_ci	struct nvif_push *push;
678c2ecf20Sopenharmony_ci	u32 *ptr;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	struct nvif_object sync;
708c2ecf20Sopenharmony_ci	struct nvif_object vram;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	/* Protects against concurrent pushbuf access to this channel, lock is
738c2ecf20Sopenharmony_ci	 * grabbed by evo_wait (if the pushbuf reservation is successful) and
748c2ecf20Sopenharmony_ci	 * dropped again by evo_kick. */
758c2ecf20Sopenharmony_ci	struct mutex lock;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	u32 cur;
788c2ecf20Sopenharmony_ci	u32 put;
798c2ecf20Sopenharmony_ci	u32 max;
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistruct nv50_outp_atom {
838c2ecf20Sopenharmony_ci	struct list_head head;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	struct drm_encoder *encoder;
868c2ecf20Sopenharmony_ci	bool flush_disable;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	union nv50_outp_atom_mask {
898c2ecf20Sopenharmony_ci		struct {
908c2ecf20Sopenharmony_ci			bool ctrl:1;
918c2ecf20Sopenharmony_ci		};
928c2ecf20Sopenharmony_ci		u8 mask;
938c2ecf20Sopenharmony_ci	} set, clr;
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciint nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
978c2ecf20Sopenharmony_ci		     const s32 *oclass, u8 head, void *data, u32 size,
988c2ecf20Sopenharmony_ci		     s64 syncbuf, struct nv50_dmac *dmac);
998c2ecf20Sopenharmony_civoid nv50_dmac_destroy(struct nv50_dmac *);
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/*
1028c2ecf20Sopenharmony_ci * For normal encoders this just returns the encoder. For active MST encoders,
1038c2ecf20Sopenharmony_ci * this returns the real outp that's driving displays on the topology.
1048c2ecf20Sopenharmony_ci * Inactive MST encoders return NULL, since they would have no real outp to
1058c2ecf20Sopenharmony_ci * return anyway.
1068c2ecf20Sopenharmony_ci */
1078c2ecf20Sopenharmony_cistruct nouveau_encoder *nv50_real_outp(struct drm_encoder *encoder);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciu32 *evo_wait(struct nv50_dmac *, int nr);
1108c2ecf20Sopenharmony_civoid evo_kick(u32 *, struct nv50_dmac *);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ciextern const u64 disp50xx_modifiers[];
1138c2ecf20Sopenharmony_ciextern const u64 disp90xx_modifiers[];
1148c2ecf20Sopenharmony_ciextern const u64 wndwc57e_modifiers[];
1158c2ecf20Sopenharmony_ci#endif
116