1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVKM_DISP_HEAD_H__
3 #define __NVKM_DISP_HEAD_H__
4 #include "priv.h"
5 
6 struct nvkm_head {
7 	const struct nvkm_head_func *func;
8 	struct nvkm_disp *disp;
9 	int id;
10 
11 	struct list_head head;
12 
13 	struct nvkm_head_state {
14 		u16 htotal;
15 		u16 hsynce;
16 		u16 hblanke;
17 		u16 hblanks;
18 		u16 vtotal;
19 		u16 vsynce;
20 		u16 vblanke;
21 		u16 vblanks;
22 		u32 hz;
23 
24 		/* Prior to GF119, these are set by the OR. */
25 		struct {
26 			u8 depth;
27 		} or;
28 	} arm, asy;
29 };
30 
31 int nvkm_head_new_(const struct nvkm_head_func *, struct nvkm_disp *, int id);
32 void nvkm_head_del(struct nvkm_head **);
33 int nvkm_head_mthd_scanoutpos(struct nvkm_object *,
34 			      struct nvkm_head *, void *, u32);
35 struct nvkm_head *nvkm_head_find(struct nvkm_disp *, int id);
36 
37 struct nvkm_head_func {
38 	void (*state)(struct nvkm_head *, struct nvkm_head_state *);
39 	void (*rgpos)(struct nvkm_head *, u16 *hline, u16 *vline);
40 	void (*rgclk)(struct nvkm_head *, int div);
41 	void (*vblank_get)(struct nvkm_head *);
42 	void (*vblank_put)(struct nvkm_head *);
43 };
44 
45 void nv50_head_rgpos(struct nvkm_head *, u16 *, u16 *);
46 
47 #define HEAD_MSG(h,l,f,a...) do {                                              \
48 	struct nvkm_head *_h = (h);                                            \
49 	nvkm_##l(&_h->disp->engine.subdev, "head-%d: "f"\n", _h->id, ##a);     \
50 } while(0)
51 #define HEAD_WARN(h,f,a...) HEAD_MSG((h), warn, f, ##a)
52 #define HEAD_DBG(h,f,a...) HEAD_MSG((h), debug, f, ##a)
53 
54 int nv04_head_new(struct nvkm_disp *, int id);
55 
56 int nv50_head_cnt(struct nvkm_disp *, unsigned long *);
57 int nv50_head_new(struct nvkm_disp *, int id);
58 
59 int gf119_head_cnt(struct nvkm_disp *, unsigned long *);
60 int gf119_head_new(struct nvkm_disp *, int id);
61 void gf119_head_rgclk(struct nvkm_head *, int);
62 
63 int gv100_head_cnt(struct nvkm_disp *, unsigned long *);
64 int gv100_head_new(struct nvkm_disp *, int id);
65 #endif
66