1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 * Copyright 2009 Intel Corporation; author H. Peter Anvin
7 * This file is part of the Linux kernel, and is made available under
8 * the terms of the GNU General Public License version 2.
10 * ----------------------------------------------------------------------- */
13 * Common all-VGA modes
19 static struct mode_info vga_modes
[] = {
20 { VIDEO_80x25
, 80, 25, 0 },
21 { VIDEO_8POINT
, 80, 50, 0 },
22 { VIDEO_80x43
, 80, 43, 0 },
23 { VIDEO_80x28
, 80, 28, 0 },
24 { VIDEO_80x30
, 80, 30, 0 },
25 { VIDEO_80x34
, 80, 34, 0 },
26 { VIDEO_80x60
, 80, 60, 0 },
29 static struct mode_info ega_modes
[] = {
30 { VIDEO_80x25
, 80, 25, 0 },
31 { VIDEO_8POINT
, 80, 43, 0 },
34 static struct mode_info cga_modes
[] = {
35 { VIDEO_80x25
, 80, 25, 0 },
38 static __videocard video_vga
;
40 /* Set basic 80x25 mode */
41 static u8
vga_set_basic_mode(void)
43 struct biosregs ireg
, oreg
;
49 /* Query current mode */
51 intcall(0x10, &ireg
, &oreg
);
54 if (mode
!= 3 && mode
!= 7)
58 ireg
.ax
= mode
; /* AH=0: set mode */
59 intcall(0x10, &ireg
, NULL
);
64 static void vga_set_8font(void)
66 /* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
74 intcall(0x10, &ireg
, NULL
);
76 /* Use alternate print screen */
79 intcall(0x10, &ireg
, NULL
);
81 /* Turn off cursor emulation */
84 intcall(0x10, &ireg
, NULL
);
86 /* Cursor is scan lines 6-7 */
89 intcall(0x10, &ireg
, NULL
);
92 static void vga_set_14font(void)
94 /* Set 9x14 font - 80x28 on VGA */
102 intcall(0x10, &ireg
, NULL
);
104 /* Turn off cursor emulation */
107 intcall(0x10, &ireg
, NULL
);
109 /* Cursor is scan lines 11-12 */
112 intcall(0x10, &ireg
, NULL
);
115 static void vga_set_80x43(void)
117 /* Set 80x43 mode on VGA (not EGA) */
118 struct biosregs ireg
;
125 intcall(0x10, &ireg
, NULL
);
127 /* Reset video mode */
129 intcall(0x10, &ireg
, NULL
);
134 /* I/O address of the VGA CRTC */
137 return (inb(0x3cc) & 1) ? 0x3d4 : 0x3b4;
140 static void vga_set_480_scanlines(void)
142 u16 crtc
; /* CRTC base address */
143 u8 csel
; /* CRTC miscellaneous output register */
147 out_idx(0x0c, crtc
, 0x11); /* Vertical sync end, unlock CR0-7 */
148 out_idx(0x0b, crtc
, 0x06); /* Vertical total */
149 out_idx(0x3e, crtc
, 0x07); /* Vertical overflow */
150 out_idx(0xea, crtc
, 0x10); /* Vertical sync start */
151 out_idx(0xdf, crtc
, 0x12); /* Vertical display end */
152 out_idx(0xe7, crtc
, 0x15); /* Vertical blank start */
153 out_idx(0x04, crtc
, 0x16); /* Vertical blank end */
160 static void vga_set_vertical_end(int lines
)
162 u16 crtc
; /* CRTC base address */
163 u8 ovfw
; /* CRTC overflow register */
168 ovfw
= 0x3c | ((end
>> (8-1)) & 0x02) | ((end
>> (9-6)) & 0x40);
170 out_idx(ovfw
, crtc
, 0x07); /* Vertical overflow */
171 out_idx(end
, crtc
, 0x12); /* Vertical display end */
174 static void vga_set_80x30(void)
176 vga_set_480_scanlines();
177 vga_set_vertical_end(30*16);
180 static void vga_set_80x34(void)
182 vga_set_480_scanlines();
184 vga_set_vertical_end(34*14);
187 static void vga_set_80x60(void)
189 vga_set_480_scanlines();
191 vga_set_vertical_end(60*8);
194 static int vga_set_mode(struct mode_info
*mode
)
196 /* Set the basic mode */
197 vga_set_basic_mode();
199 /* Override a possibly broken BIOS */
203 switch (mode
->mode
) {
230 * Note: this probe includes basic information required by all
231 * systems. It should be executed first, by making sure
232 * video-vga.c is listed first in the Makefile.
234 static int vga_probe(void)
236 static const char *card_name
[] = {
237 "CGA/MDA/HGC", "EGA", "VGA"
239 static struct mode_info
*mode_lists
[] = {
244 static int mode_count
[] = {
245 sizeof(cga_modes
)/sizeof(struct mode_info
),
246 sizeof(ega_modes
)/sizeof(struct mode_info
),
247 sizeof(vga_modes
)/sizeof(struct mode_info
),
250 struct biosregs ireg
, oreg
;
255 ireg
.bl
= 0x10; /* Check EGA/VGA */
256 intcall(0x10, &ireg
, &oreg
);
259 boot_params
.screen_info
.orig_video_ega_bx
= oreg
.bx
;
262 /* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
263 if (oreg
.bl
!= 0x10) {
266 intcall(0x10, &ireg
, &oreg
);
268 if (oreg
.al
== 0x1a) {
269 adapter
= ADAPTER_VGA
;
271 boot_params
.screen_info
.orig_video_isVGA
= 1;
274 adapter
= ADAPTER_EGA
;
277 adapter
= ADAPTER_CGA
;
280 video_vga
.modes
= mode_lists
[adapter
];
281 video_vga
.card_name
= card_name
[adapter
];
282 return mode_count
[adapter
];
285 static __videocard video_vga
= {
288 .set_mode
= vga_set_mode
,