This source file includes following definitions.
- vga_io_r
- vga_io_w
- vga_io_w_fast
- vga_mm_r
- vga_mm_w
- vga_mm_w_fast
- vga_r
- vga_w
- vga_w_fast
- vga_rcrt
- vga_wcrt
- vga_io_rcrt
- vga_io_wcrt
- vga_mm_rcrt
- vga_mm_wcrt
- vga_rseq
- vga_wseq
- vga_io_rseq
- vga_io_wseq
- vga_mm_rseq
- vga_mm_wseq
- vga_rgfx
- vga_wgfx
- vga_io_rgfx
- vga_io_wgfx
- vga_mm_rgfx
- vga_mm_wgfx
- vga_rattr
- vga_wattr
- vga_io_rattr
- vga_io_wattr
- vga_mm_rattr
- vga_mm_wattr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #ifndef __linux_video_vga_h__
18 #define __linux_video_vga_h__
19
20 #include <linux/types.h>
21 #include <linux/io.h>
22 #include <asm/vga.h>
23 #include <asm/byteorder.h>
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #define VGA_CRT_DC 0x3D5
39 #define VGA_CRT_DM 0x3B5
40 #define VGA_ATT_R 0x3C1
41 #define VGA_ATT_W 0x3C0
42 #define VGA_GFX_D 0x3CF
43 #define VGA_SEQ_D 0x3C5
44 #define VGA_MIS_R 0x3CC
45 #define VGA_MIS_W 0x3C2
46 #define VGA_FTC_R 0x3CA
47 #define VGA_IS1_RC 0x3DA
48 #define VGA_IS1_RM 0x3BA
49 #define VGA_PEL_D 0x3C9
50 #define VGA_PEL_MSK 0x3C6
51
52
53 #define EGA_GFX_E0 0x3CC
54 #define EGA_GFX_E1 0x3CA
55
56
57 #define VGA_CRT_IC 0x3D4
58 #define VGA_CRT_IM 0x3B4
59 #define VGA_ATT_IW 0x3C0
60 #define VGA_GFX_I 0x3CE
61 #define VGA_SEQ_I 0x3C4
62 #define VGA_PEL_IW 0x3C8
63 #define VGA_PEL_IR 0x3C7
64
65
66 #define VGA_CRT_C 0x19
67 #define VGA_ATT_C 0x15
68 #define VGA_GFX_C 0x09
69 #define VGA_SEQ_C 0x05
70 #define VGA_MIS_C 0x01
71
72
73 #define VGA_MIS_COLOR 0x01
74 #define VGA_MIS_ENB_MEM_ACCESS 0x02
75 #define VGA_MIS_DCLK_28322_720 0x04
76 #define VGA_MIS_ENB_PLL_LOAD (0x04 | 0x08)
77 #define VGA_MIS_SEL_HIGH_PAGE 0x20
78
79
80 #define VGA_CRTC_H_TOTAL 0
81 #define VGA_CRTC_H_DISP 1
82 #define VGA_CRTC_H_BLANK_START 2
83 #define VGA_CRTC_H_BLANK_END 3
84 #define VGA_CRTC_H_SYNC_START 4
85 #define VGA_CRTC_H_SYNC_END 5
86 #define VGA_CRTC_V_TOTAL 6
87 #define VGA_CRTC_OVERFLOW 7
88 #define VGA_CRTC_PRESET_ROW 8
89 #define VGA_CRTC_MAX_SCAN 9
90 #define VGA_CRTC_CURSOR_START 0x0A
91 #define VGA_CRTC_CURSOR_END 0x0B
92 #define VGA_CRTC_START_HI 0x0C
93 #define VGA_CRTC_START_LO 0x0D
94 #define VGA_CRTC_CURSOR_HI 0x0E
95 #define VGA_CRTC_CURSOR_LO 0x0F
96 #define VGA_CRTC_V_SYNC_START 0x10
97 #define VGA_CRTC_V_SYNC_END 0x11
98 #define VGA_CRTC_V_DISP_END 0x12
99 #define VGA_CRTC_OFFSET 0x13
100 #define VGA_CRTC_UNDERLINE 0x14
101 #define VGA_CRTC_V_BLANK_START 0x15
102 #define VGA_CRTC_V_BLANK_END 0x16
103 #define VGA_CRTC_MODE 0x17
104 #define VGA_CRTC_LINE_COMPARE 0x18
105 #define VGA_CRTC_REGS VGA_CRT_C
106
107
108 #define VGA_CR11_LOCK_CR0_CR7 0x80
109 #define VGA_CR17_H_V_SIGNALS_ENABLED 0x80
110
111
112 #define VGA_ATC_PALETTE0 0x00
113 #define VGA_ATC_PALETTE1 0x01
114 #define VGA_ATC_PALETTE2 0x02
115 #define VGA_ATC_PALETTE3 0x03
116 #define VGA_ATC_PALETTE4 0x04
117 #define VGA_ATC_PALETTE5 0x05
118 #define VGA_ATC_PALETTE6 0x06
119 #define VGA_ATC_PALETTE7 0x07
120 #define VGA_ATC_PALETTE8 0x08
121 #define VGA_ATC_PALETTE9 0x09
122 #define VGA_ATC_PALETTEA 0x0A
123 #define VGA_ATC_PALETTEB 0x0B
124 #define VGA_ATC_PALETTEC 0x0C
125 #define VGA_ATC_PALETTED 0x0D
126 #define VGA_ATC_PALETTEE 0x0E
127 #define VGA_ATC_PALETTEF 0x0F
128 #define VGA_ATC_MODE 0x10
129 #define VGA_ATC_OVERSCAN 0x11
130 #define VGA_ATC_PLANE_ENABLE 0x12
131 #define VGA_ATC_PEL 0x13
132 #define VGA_ATC_COLOR_PAGE 0x14
133
134 #define VGA_AR_ENABLE_DISPLAY 0x20
135
136
137 #define VGA_SEQ_RESET 0x00
138 #define VGA_SEQ_CLOCK_MODE 0x01
139 #define VGA_SEQ_PLANE_WRITE 0x02
140 #define VGA_SEQ_CHARACTER_MAP 0x03
141 #define VGA_SEQ_MEMORY_MODE 0x04
142
143
144 #define VGA_SR01_CHAR_CLK_8DOTS 0x01
145 #define VGA_SR01_SCREEN_OFF 0x20
146 #define VGA_SR02_ALL_PLANES 0x0F
147 #define VGA_SR04_EXT_MEM 0x02
148 #define VGA_SR04_SEQ_MODE 0x04
149 #define VGA_SR04_CHN_4M 0x08
150
151
152 #define VGA_GFX_SR_VALUE 0x00
153 #define VGA_GFX_SR_ENABLE 0x01
154 #define VGA_GFX_COMPARE_VALUE 0x02
155 #define VGA_GFX_DATA_ROTATE 0x03
156 #define VGA_GFX_PLANE_READ 0x04
157 #define VGA_GFX_MODE 0x05
158 #define VGA_GFX_MISC 0x06
159 #define VGA_GFX_COMPARE_MASK 0x07
160 #define VGA_GFX_BIT_MASK 0x08
161
162
163 #define VGA_GR06_GRAPHICS_MODE 0x01
164
165
166
167 #define VGA_OUT16VAL(v, r) (((v) << 8) | (r))
168
169
170 #ifdef __LITTLE_ENDIAN
171 #define VGA_OUTW_WRITE
172 #endif
173
174
175 #define VGA_SAVE_FONT0 1
176 #define VGA_SAVE_FONT1 2
177 #define VGA_SAVE_TEXT 4
178 #define VGA_SAVE_FONTS 7
179 #define VGA_SAVE_MODE 8
180 #define VGA_SAVE_CMAP 16
181
182 struct vgastate {
183 void __iomem *vgabase;
184 unsigned long membase;
185 __u32 memsize;
186 __u32 flags;
187 __u32 depth;
188 __u32 num_attr;
189 __u32 num_crtc;
190 __u32 num_gfx;
191 __u32 num_seq;
192 void *vidstate;
193 };
194
195 extern int save_vga(struct vgastate *state);
196 extern int restore_vga(struct vgastate *state);
197
198
199
200
201
202 static inline unsigned char vga_io_r (unsigned short port)
203 {
204 return inb_p(port);
205 }
206
207 static inline void vga_io_w (unsigned short port, unsigned char val)
208 {
209 outb_p(val, port);
210 }
211
212 static inline void vga_io_w_fast (unsigned short port, unsigned char reg,
213 unsigned char val)
214 {
215 outw(VGA_OUT16VAL (val, reg), port);
216 }
217
218 static inline unsigned char vga_mm_r (void __iomem *regbase, unsigned short port)
219 {
220 return readb (regbase + port);
221 }
222
223 static inline void vga_mm_w (void __iomem *regbase, unsigned short port, unsigned char val)
224 {
225 writeb (val, regbase + port);
226 }
227
228 static inline void vga_mm_w_fast (void __iomem *regbase, unsigned short port,
229 unsigned char reg, unsigned char val)
230 {
231 writew (VGA_OUT16VAL (val, reg), regbase + port);
232 }
233
234 static inline unsigned char vga_r (void __iomem *regbase, unsigned short port)
235 {
236 if (regbase)
237 return vga_mm_r (regbase, port);
238 else
239 return vga_io_r (port);
240 }
241
242 static inline void vga_w (void __iomem *regbase, unsigned short port, unsigned char val)
243 {
244 if (regbase)
245 vga_mm_w (regbase, port, val);
246 else
247 vga_io_w (port, val);
248 }
249
250
251 static inline void vga_w_fast (void __iomem *regbase, unsigned short port,
252 unsigned char reg, unsigned char val)
253 {
254 if (regbase)
255 vga_mm_w_fast (regbase, port, reg, val);
256 else
257 vga_io_w_fast (port, reg, val);
258 }
259
260
261
262
263
264
265 static inline unsigned char vga_rcrt (void __iomem *regbase, unsigned char reg)
266 {
267 vga_w (regbase, VGA_CRT_IC, reg);
268 return vga_r (regbase, VGA_CRT_DC);
269 }
270
271 static inline void vga_wcrt (void __iomem *regbase, unsigned char reg, unsigned char val)
272 {
273 #ifdef VGA_OUTW_WRITE
274 vga_w_fast (regbase, VGA_CRT_IC, reg, val);
275 #else
276 vga_w (regbase, VGA_CRT_IC, reg);
277 vga_w (regbase, VGA_CRT_DC, val);
278 #endif
279 }
280
281 static inline unsigned char vga_io_rcrt (unsigned char reg)
282 {
283 vga_io_w (VGA_CRT_IC, reg);
284 return vga_io_r (VGA_CRT_DC);
285 }
286
287 static inline void vga_io_wcrt (unsigned char reg, unsigned char val)
288 {
289 #ifdef VGA_OUTW_WRITE
290 vga_io_w_fast (VGA_CRT_IC, reg, val);
291 #else
292 vga_io_w (VGA_CRT_IC, reg);
293 vga_io_w (VGA_CRT_DC, val);
294 #endif
295 }
296
297 static inline unsigned char vga_mm_rcrt (void __iomem *regbase, unsigned char reg)
298 {
299 vga_mm_w (regbase, VGA_CRT_IC, reg);
300 return vga_mm_r (regbase, VGA_CRT_DC);
301 }
302
303 static inline void vga_mm_wcrt (void __iomem *regbase, unsigned char reg, unsigned char val)
304 {
305 #ifdef VGA_OUTW_WRITE
306 vga_mm_w_fast (regbase, VGA_CRT_IC, reg, val);
307 #else
308 vga_mm_w (regbase, VGA_CRT_IC, reg);
309 vga_mm_w (regbase, VGA_CRT_DC, val);
310 #endif
311 }
312
313
314
315
316
317
318 static inline unsigned char vga_rseq (void __iomem *regbase, unsigned char reg)
319 {
320 vga_w (regbase, VGA_SEQ_I, reg);
321 return vga_r (regbase, VGA_SEQ_D);
322 }
323
324 static inline void vga_wseq (void __iomem *regbase, unsigned char reg, unsigned char val)
325 {
326 #ifdef VGA_OUTW_WRITE
327 vga_w_fast (regbase, VGA_SEQ_I, reg, val);
328 #else
329 vga_w (regbase, VGA_SEQ_I, reg);
330 vga_w (regbase, VGA_SEQ_D, val);
331 #endif
332 }
333
334 static inline unsigned char vga_io_rseq (unsigned char reg)
335 {
336 vga_io_w (VGA_SEQ_I, reg);
337 return vga_io_r (VGA_SEQ_D);
338 }
339
340 static inline void vga_io_wseq (unsigned char reg, unsigned char val)
341 {
342 #ifdef VGA_OUTW_WRITE
343 vga_io_w_fast (VGA_SEQ_I, reg, val);
344 #else
345 vga_io_w (VGA_SEQ_I, reg);
346 vga_io_w (VGA_SEQ_D, val);
347 #endif
348 }
349
350 static inline unsigned char vga_mm_rseq (void __iomem *regbase, unsigned char reg)
351 {
352 vga_mm_w (regbase, VGA_SEQ_I, reg);
353 return vga_mm_r (regbase, VGA_SEQ_D);
354 }
355
356 static inline void vga_mm_wseq (void __iomem *regbase, unsigned char reg, unsigned char val)
357 {
358 #ifdef VGA_OUTW_WRITE
359 vga_mm_w_fast (regbase, VGA_SEQ_I, reg, val);
360 #else
361 vga_mm_w (regbase, VGA_SEQ_I, reg);
362 vga_mm_w (regbase, VGA_SEQ_D, val);
363 #endif
364 }
365
366
367
368
369
370 static inline unsigned char vga_rgfx (void __iomem *regbase, unsigned char reg)
371 {
372 vga_w (regbase, VGA_GFX_I, reg);
373 return vga_r (regbase, VGA_GFX_D);
374 }
375
376 static inline void vga_wgfx (void __iomem *regbase, unsigned char reg, unsigned char val)
377 {
378 #ifdef VGA_OUTW_WRITE
379 vga_w_fast (regbase, VGA_GFX_I, reg, val);
380 #else
381 vga_w (regbase, VGA_GFX_I, reg);
382 vga_w (regbase, VGA_GFX_D, val);
383 #endif
384 }
385
386 static inline unsigned char vga_io_rgfx (unsigned char reg)
387 {
388 vga_io_w (VGA_GFX_I, reg);
389 return vga_io_r (VGA_GFX_D);
390 }
391
392 static inline void vga_io_wgfx (unsigned char reg, unsigned char val)
393 {
394 #ifdef VGA_OUTW_WRITE
395 vga_io_w_fast (VGA_GFX_I, reg, val);
396 #else
397 vga_io_w (VGA_GFX_I, reg);
398 vga_io_w (VGA_GFX_D, val);
399 #endif
400 }
401
402 static inline unsigned char vga_mm_rgfx (void __iomem *regbase, unsigned char reg)
403 {
404 vga_mm_w (regbase, VGA_GFX_I, reg);
405 return vga_mm_r (regbase, VGA_GFX_D);
406 }
407
408 static inline void vga_mm_wgfx (void __iomem *regbase, unsigned char reg, unsigned char val)
409 {
410 #ifdef VGA_OUTW_WRITE
411 vga_mm_w_fast (regbase, VGA_GFX_I, reg, val);
412 #else
413 vga_mm_w (regbase, VGA_GFX_I, reg);
414 vga_mm_w (regbase, VGA_GFX_D, val);
415 #endif
416 }
417
418
419
420
421
422
423 static inline unsigned char vga_rattr (void __iomem *regbase, unsigned char reg)
424 {
425 vga_w (regbase, VGA_ATT_IW, reg);
426 return vga_r (regbase, VGA_ATT_R);
427 }
428
429 static inline void vga_wattr (void __iomem *regbase, unsigned char reg, unsigned char val)
430 {
431 vga_w (regbase, VGA_ATT_IW, reg);
432 vga_w (regbase, VGA_ATT_W, val);
433 }
434
435 static inline unsigned char vga_io_rattr (unsigned char reg)
436 {
437 vga_io_w (VGA_ATT_IW, reg);
438 return vga_io_r (VGA_ATT_R);
439 }
440
441 static inline void vga_io_wattr (unsigned char reg, unsigned char val)
442 {
443 vga_io_w (VGA_ATT_IW, reg);
444 vga_io_w (VGA_ATT_W, val);
445 }
446
447 static inline unsigned char vga_mm_rattr (void __iomem *regbase, unsigned char reg)
448 {
449 vga_mm_w (regbase, VGA_ATT_IW, reg);
450 return vga_mm_r (regbase, VGA_ATT_R);
451 }
452
453 static inline void vga_mm_wattr (void __iomem *regbase, unsigned char reg, unsigned char val)
454 {
455 vga_mm_w (regbase, VGA_ATT_IW, reg);
456 vga_mm_w (regbase, VGA_ATT_W, val);
457 }
458
459 #endif