1/*	$NetBSD: nv50.h,v 1.3 2021/12/18 23:45:35 riastradh Exp $	*/
2
3/* SPDX-License-Identifier: MIT */
4#ifndef __NV50_DISP_H__
5#define __NV50_DISP_H__
6
7#include <linux/workqueue.h>
8
9#define nv50_disp(p) container_of((p), struct nv50_disp, base)
10#include "priv.h"
11struct nvkm_head;
12
13#include <core/enum.h>
14
15struct nv50_disp {
16	const struct nv50_disp_func *func;
17	struct nvkm_disp base;
18
19	struct workqueue_struct *wq;
20	struct work_struct supervisor;
21	u32 super;
22
23	struct nvkm_event uevent;
24
25	struct {
26		unsigned long mask;
27		int nr;
28	} wndw, head, dac;
29
30	struct {
31		unsigned long mask;
32		int nr;
33		u32 lvdsconf;
34	} sor;
35
36	struct {
37		unsigned long mask;
38		int nr;
39		u8 type[3];
40	} pior;
41
42	struct nvkm_gpuobj *inst;
43	struct nvkm_ramht *ramht;
44
45	struct nv50_disp_chan *chan[81];
46};
47
48void nv50_disp_super_1(struct nv50_disp *);
49void nv50_disp_super_1_0(struct nv50_disp *, struct nvkm_head *);
50void nv50_disp_super_2_0(struct nv50_disp *, struct nvkm_head *);
51void nv50_disp_super_2_1(struct nv50_disp *, struct nvkm_head *);
52void nv50_disp_super_2_2(struct nv50_disp *, struct nvkm_head *);
53void nv50_disp_super_3_0(struct nv50_disp *, struct nvkm_head *);
54
55int nv50_disp_new_(const struct nv50_disp_func *, struct nvkm_device *,
56		   int index, struct nvkm_disp **);
57
58struct nv50_disp_func {
59	int (*init)(struct nv50_disp *);
60	void (*fini)(struct nv50_disp *);
61	void (*intr)(struct nv50_disp *);
62	void (*intr_error)(struct nv50_disp *, int chid);
63
64	const struct nvkm_event_func *uevent;
65	void (*super)(struct work_struct *);
66
67	const struct nvkm_disp_oclass *root;
68
69	struct {
70		int (*cnt)(struct nvkm_disp *, unsigned long *mask);
71		int (*new)(struct nvkm_disp *, int id);
72	} wndw, head, dac, sor, pior;
73
74	u16 ramht_size;
75};
76
77int nv50_disp_init(struct nv50_disp *);
78void nv50_disp_fini(struct nv50_disp *);
79void nv50_disp_intr(struct nv50_disp *);
80void nv50_disp_super(struct work_struct *);
81extern const struct nvkm_enum nv50_disp_intr_error_type[];
82
83int gf119_disp_init(struct nv50_disp *);
84void gf119_disp_fini(struct nv50_disp *);
85void gf119_disp_intr(struct nv50_disp *);
86void gf119_disp_super(struct work_struct *);
87void gf119_disp_intr_error(struct nv50_disp *, int);
88
89void gv100_disp_fini(struct nv50_disp *);
90void gv100_disp_intr(struct nv50_disp *);
91void gv100_disp_super(struct work_struct *);
92int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *);
93
94void nv50_disp_dptmds_war_2(struct nv50_disp *, struct dcb_output *);
95void nv50_disp_dptmds_war_3(struct nv50_disp *, struct dcb_output *);
96void nv50_disp_update_sppll1(struct nv50_disp *);
97
98extern const struct nvkm_event_func nv50_disp_chan_uevent;
99int  nv50_disp_chan_uevent_ctor(struct nvkm_object *, void *, u32,
100				struct nvkm_notify *);
101void nv50_disp_chan_uevent_send(struct nv50_disp *, int);
102
103extern const struct nvkm_event_func gf119_disp_chan_uevent;
104extern const struct nvkm_event_func gv100_disp_chan_uevent;
105#endif
106