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