xref: /plan9-contrib/sys/src/9k/k10/screen.h (revision 45e6af3b6d7025ef7184352bb3f6852edd8de07e)
1*45e6af3bSDavid du Colombier typedef struct Cursor Cursor;
2*45e6af3bSDavid du Colombier typedef struct Cursorinfo Cursorinfo;
3*45e6af3bSDavid du Colombier struct Cursorinfo {
4*45e6af3bSDavid du Colombier 	Cursor;
5*45e6af3bSDavid du Colombier 	Lock;
6*45e6af3bSDavid du Colombier };
7*45e6af3bSDavid du Colombier 
8*45e6af3bSDavid du Colombier /* devmouse.c */
9*45e6af3bSDavid du Colombier extern void mousetrack(int, int, int, int);
10*45e6af3bSDavid du Colombier extern Point mousexy(void);
11*45e6af3bSDavid du Colombier 
12*45e6af3bSDavid du Colombier extern void mouseaccelerate(int);
13*45e6af3bSDavid du Colombier extern int m3mouseputc(Queue*, int);
14*45e6af3bSDavid du Colombier extern int m5mouseputc(Queue*, int);
15*45e6af3bSDavid du Colombier extern int mouseputc(Queue*, int);
16*45e6af3bSDavid du Colombier 
17*45e6af3bSDavid du Colombier extern Cursorinfo cursor;
18*45e6af3bSDavid du Colombier extern Cursor arrow;
19*45e6af3bSDavid du Colombier 
20*45e6af3bSDavid du Colombier /*
21*45e6af3bSDavid du Colombier  * Generic VGA registers.
22*45e6af3bSDavid du Colombier  */
23*45e6af3bSDavid du Colombier enum {
24*45e6af3bSDavid du Colombier 	MiscW		= 0x03C2,	/* Miscellaneous Output (W) */
25*45e6af3bSDavid du Colombier 	MiscR		= 0x03CC,	/* Miscellaneous Output (R) */
26*45e6af3bSDavid du Colombier 	Status0		= 0x03C2,	/* Input status 0 (R) */
27*45e6af3bSDavid du Colombier 	Status1		= 0x03DA,	/* Input Status 1 (R) */
28*45e6af3bSDavid du Colombier 	FeatureR	= 0x03CA,	/* Feature Control (R) */
29*45e6af3bSDavid du Colombier 	FeatureW	= 0x03DA,	/* Feature Control (W) */
30*45e6af3bSDavid du Colombier 
31*45e6af3bSDavid du Colombier 	Seqx		= 0x03C4,	/* Sequencer Index, Data at Seqx+1 */
32*45e6af3bSDavid du Colombier 	Crtx		= 0x03D4,	/* CRT Controller Index, Data at Crtx+1 */
33*45e6af3bSDavid du Colombier 	Grx		= 0x03CE,	/* Graphics Controller Index, Data at Grx+1 */
34*45e6af3bSDavid du Colombier 	Attrx		= 0x03C0,	/* Attribute Controller Index and Data */
35*45e6af3bSDavid du Colombier 
36*45e6af3bSDavid du Colombier 	PaddrW		= 0x03C8,	/* Palette Address Register, write */
37*45e6af3bSDavid du Colombier 	Pdata		= 0x03C9,	/* Palette Data Register */
38*45e6af3bSDavid du Colombier 	Pixmask		= 0x03C6,	/* Pixel Mask Register */
39*45e6af3bSDavid du Colombier 	PaddrR		= 0x03C7,	/* Palette Address Register, read */
40*45e6af3bSDavid du Colombier 	Pstatus		= 0x03C7,	/* DAC Status (RO) */
41*45e6af3bSDavid du Colombier 
42*45e6af3bSDavid du Colombier 	Pcolours	= 256,		/* Palette */
43*45e6af3bSDavid du Colombier 	Pred		= 0,
44*45e6af3bSDavid du Colombier 	Pgreen		= 1,
45*45e6af3bSDavid du Colombier 	Pblue		= 2,
46*45e6af3bSDavid du Colombier 
47*45e6af3bSDavid du Colombier 	Pblack		= 0x00,
48*45e6af3bSDavid du Colombier 	Pwhite		= 0xFF,
49*45e6af3bSDavid du Colombier };
50*45e6af3bSDavid du Colombier 
51*45e6af3bSDavid du Colombier #define VGAMEM()	0xA0000
52*45e6af3bSDavid du Colombier #define vgai(port)		inb(port)
53*45e6af3bSDavid du Colombier #define vgao(port, data)	outb(port, data)
54*45e6af3bSDavid du Colombier 
55*45e6af3bSDavid du Colombier extern int vgaxi(long, uchar);
56*45e6af3bSDavid du Colombier extern int vgaxo(long, uchar, uchar);
57*45e6af3bSDavid du Colombier 
58*45e6af3bSDavid du Colombier /*
59*45e6af3bSDavid du Colombier  */
60*45e6af3bSDavid du Colombier typedef struct VGAdev VGAdev;
61*45e6af3bSDavid du Colombier typedef struct VGAcur VGAcur;
62*45e6af3bSDavid du Colombier typedef struct VGAscr VGAscr;
63*45e6af3bSDavid du Colombier 
64*45e6af3bSDavid du Colombier struct VGAdev {
65*45e6af3bSDavid du Colombier 	char*	name;
66*45e6af3bSDavid du Colombier 
67*45e6af3bSDavid du Colombier 	void	(*enable)(VGAscr*);
68*45e6af3bSDavid du Colombier 	void	(*disable)(VGAscr*);
69*45e6af3bSDavid du Colombier 	void	(*page)(VGAscr*, int);
70*45e6af3bSDavid du Colombier 	void	(*linear)(VGAscr*, int, int);
71*45e6af3bSDavid du Colombier 	void	(*drawinit)(VGAscr*);
72*45e6af3bSDavid du Colombier 	int	(*fill)(VGAscr*, Rectangle, ulong);
73*45e6af3bSDavid du Colombier 	void	(*ovlctl)(VGAscr*, Chan*, void*, int);
74*45e6af3bSDavid du Colombier 	int	(*ovlwrite)(VGAscr*, void*, int, vlong);
75*45e6af3bSDavid du Colombier 	void (*flush)(VGAscr*, Rectangle);
76*45e6af3bSDavid du Colombier };
77*45e6af3bSDavid du Colombier 
78*45e6af3bSDavid du Colombier struct VGAcur {
79*45e6af3bSDavid du Colombier 	char*	name;
80*45e6af3bSDavid du Colombier 
81*45e6af3bSDavid du Colombier 	void	(*enable)(VGAscr*);
82*45e6af3bSDavid du Colombier 	void	(*disable)(VGAscr*);
83*45e6af3bSDavid du Colombier 	void	(*load)(VGAscr*, Cursor*);
84*45e6af3bSDavid du Colombier 	int	(*move)(VGAscr*, Point);
85*45e6af3bSDavid du Colombier 
86*45e6af3bSDavid du Colombier 	int	doespanning;
87*45e6af3bSDavid du Colombier };
88*45e6af3bSDavid du Colombier 
89*45e6af3bSDavid du Colombier /*
90*45e6af3bSDavid du Colombier  */
91*45e6af3bSDavid du Colombier struct VGAscr {
92*45e6af3bSDavid du Colombier 	Lock	devlock;
93*45e6af3bSDavid du Colombier 	VGAdev*	dev;
94*45e6af3bSDavid du Colombier 	Pcidev*	pci;
95*45e6af3bSDavid du Colombier 
96*45e6af3bSDavid du Colombier 	VGAcur*	cur;
97*45e6af3bSDavid du Colombier 	ulong	storage;
98*45e6af3bSDavid du Colombier 	Cursor;
99*45e6af3bSDavid du Colombier 
100*45e6af3bSDavid du Colombier 	int	useflush;
101*45e6af3bSDavid du Colombier 
102*45e6af3bSDavid du Colombier 	ulong	paddr;		/* frame buffer */
103*45e6af3bSDavid du Colombier 	void*	vaddr;
104*45e6af3bSDavid du Colombier 	int		apsize;
105*45e6af3bSDavid du Colombier 
106*45e6af3bSDavid du Colombier 	ulong	io;				/* device specific registers */
107*45e6af3bSDavid du Colombier 	ulong	*mmio;
108*45e6af3bSDavid du Colombier 
109*45e6af3bSDavid du Colombier 	ulong	colormap[Pcolours][3];
110*45e6af3bSDavid du Colombier 	int	palettedepth;
111*45e6af3bSDavid du Colombier 
112*45e6af3bSDavid du Colombier 	Memimage* gscreen;
113*45e6af3bSDavid du Colombier 	Memdata* gscreendata;
114*45e6af3bSDavid du Colombier 	Memsubfont* memdefont;
115*45e6af3bSDavid du Colombier 
116*45e6af3bSDavid du Colombier 	int	(*fill)(VGAscr*, Rectangle, ulong);
117*45e6af3bSDavid du Colombier 	int	(*scroll)(VGAscr*, Rectangle, Rectangle);
118*45e6af3bSDavid du Colombier 	void	(*blank)(VGAscr*, int);
119*45e6af3bSDavid du Colombier 	ulong	id;	/* internal identifier for driver use */
120*45e6af3bSDavid du Colombier 	int isblank;
121*45e6af3bSDavid du Colombier 	int overlayinit;
122*45e6af3bSDavid du Colombier };
123*45e6af3bSDavid du Colombier 
124*45e6af3bSDavid du Colombier extern VGAscr vgascreen[];
125*45e6af3bSDavid du Colombier 
126*45e6af3bSDavid du Colombier enum {
127*45e6af3bSDavid du Colombier 	Backgnd		= 0,	/* black */
128*45e6af3bSDavid du Colombier };
129*45e6af3bSDavid du Colombier 
130*45e6af3bSDavid du Colombier /* mouse.c */
131*45e6af3bSDavid du Colombier extern void mousectl(Cmdbuf*);
132*45e6af3bSDavid du Colombier extern void mouseresize(void);
133*45e6af3bSDavid du Colombier 
134*45e6af3bSDavid du Colombier /* screen.c */
135*45e6af3bSDavid du Colombier extern int		hwaccel;	/* use hw acceleration; default on */
136*45e6af3bSDavid du Colombier extern int		hwblank;	/* use hw blanking; default on */
137*45e6af3bSDavid du Colombier extern int		panning;	/* use virtual screen panning; default off */
138*45e6af3bSDavid du Colombier extern void addvgaseg(char*, ulong, ulong);
139*45e6af3bSDavid du Colombier extern uchar* attachscreen(Rectangle*, ulong*, int*, int*, int*);
140*45e6af3bSDavid du Colombier extern void	flushmemscreen(Rectangle);
141*45e6af3bSDavid du Colombier extern int	cursoron(int);
142*45e6af3bSDavid du Colombier extern void	cursoroff(int);
143*45e6af3bSDavid du Colombier extern void	setcursor(Cursor*);
144*45e6af3bSDavid du Colombier extern int	screensize(int, int, int, ulong);
145*45e6af3bSDavid du Colombier extern int	screenaperture(int, int);
146*45e6af3bSDavid du Colombier extern Rectangle physgscreenr;	/* actual monitor size */
147*45e6af3bSDavid du Colombier extern void	blankscreen(int);
148*45e6af3bSDavid du Colombier 
149*45e6af3bSDavid du Colombier extern VGAcur swcursor;
150*45e6af3bSDavid du Colombier extern void swcursorinit(void);
151*45e6af3bSDavid du Colombier extern void swcursorhide(void);
152*45e6af3bSDavid du Colombier extern void swcursoravoid(Rectangle);
153*45e6af3bSDavid du Colombier extern void swcursorunhide(void);
154*45e6af3bSDavid du Colombier 
155*45e6af3bSDavid du Colombier /* devdraw.c */
156*45e6af3bSDavid du Colombier extern void	deletescreenimage(void);
157*45e6af3bSDavid du Colombier extern void	resetscreenimage(void);
158*45e6af3bSDavid du Colombier extern int		drawhasclients(void);
159*45e6af3bSDavid du Colombier extern ulong	blanktime;
160*45e6af3bSDavid du Colombier extern void	setscreenimageclipr(Rectangle);
161*45e6af3bSDavid du Colombier extern void	drawflush(void);
162*45e6af3bSDavid du Colombier extern int drawidletime(void);
163*45e6af3bSDavid du Colombier extern QLock	drawlock;
164*45e6af3bSDavid du Colombier 
165*45e6af3bSDavid du Colombier /* vga.c */
166*45e6af3bSDavid du Colombier extern void	vgascreenwin(VGAscr*);
167*45e6af3bSDavid du Colombier extern void	vgaimageinit(ulong);
168*45e6af3bSDavid du Colombier extern void	vgalinearpciid(VGAscr*, int, int);
169*45e6af3bSDavid du Colombier extern void	vgalinearpci(VGAscr*);
170*45e6af3bSDavid du Colombier extern void	vgalinearaddr(VGAscr*, ulong, int);
171*45e6af3bSDavid du Colombier 
172*45e6af3bSDavid du Colombier extern void	drawblankscreen(int);
173*45e6af3bSDavid du Colombier extern void	vgablank(VGAscr*, int);
174*45e6af3bSDavid du Colombier 
175*45e6af3bSDavid du Colombier extern Lock	vgascreenlock;
176*45e6af3bSDavid du Colombier 
177*45e6af3bSDavid du Colombier #define ishwimage(i)	(vgascreen[0].gscreendata && (i)->data->bdata == vgascreen[0].gscreendata->bdata)
178