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