1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
9 * ----------------------------------------------------------------------- */
12 * arch/i386/boot/video-vga.c
14 * Common all-VGA modes
20 static struct mode_info vga_modes
[] = {
21 { VIDEO_80x25
, 80, 25, 0 },
22 { VIDEO_8POINT
, 80, 50, 0 },
23 { VIDEO_80x43
, 80, 43, 0 },
24 { VIDEO_80x28
, 80, 28, 0 },
25 { VIDEO_80x30
, 80, 30, 0 },
26 { VIDEO_80x34
, 80, 34, 0 },
27 { VIDEO_80x60
, 80, 60, 0 },
30 static struct mode_info ega_modes
[] = {
31 { VIDEO_80x25
, 80, 25, 0 },
32 { VIDEO_8POINT
, 80, 43, 0 },
35 static struct mode_info cga_modes
[] = {
36 { VIDEO_80x25
, 80, 25, 0 },
39 __videocard video_vga
;
41 /* Set basic 80x25 mode */
42 static u8
vga_set_basic_mode(void)
48 #ifdef CONFIG_VIDEO_400_HACK
49 if (adapter
>= ADAPTER_VGA
) {
51 : : "a" (0x1202), "b" (0x0030)
52 : "ecx", "edx", "esi", "edi");
59 : : "ebx", "ecx", "edx", "esi", "edi");
64 rows
= rdfs8(0x484); /* rows minus one */
66 #ifndef CONFIG_VIDEO_400_HACK
67 if ((ax
== 0x5003 || ax
== 0x5007) &&
68 (rows
== 0 || rows
== 24))
72 if (mode
!= 3 && mode
!= 7)
79 : : "ebx", "ecx", "edx", "esi", "edi");
84 static void vga_set_8font(void)
86 /* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
89 asm volatile(INT10
: : "a" (0x1112), "b" (0));
91 /* Use alternate print screen */
92 asm volatile(INT10
: : "a" (0x1200), "b" (0x20));
94 /* Turn off cursor emulation */
95 asm volatile(INT10
: : "a" (0x1201), "b" (0x34));
97 /* Cursor is scan lines 6-7 */
98 asm volatile(INT10
: : "a" (0x0100), "c" (0x0607));
101 static void vga_set_14font(void)
103 /* Set 9x14 font - 80x28 on VGA */
106 asm volatile(INT10
: : "a" (0x1111), "b" (0));
108 /* Turn off cursor emulation */
109 asm volatile(INT10
: : "a" (0x1201), "b" (0x34));
111 /* Cursor is scan lines 11-12 */
112 asm volatile(INT10
: : "a" (0x0100), "c" (0x0b0c));
115 static void vga_set_80x43(void)
117 /* Set 80x43 mode on VGA (not EGA) */
120 asm volatile(INT10
: : "a" (0x1201), "b" (0x30));
122 /* Reset video mode */
123 asm volatile(INT10
: : "a" (0x0003));
128 /* I/O address of the VGA CRTC */
131 return (inb(0x3cc) & 1) ? 0x3d4 : 0x3b4;
134 static void vga_set_480_scanlines(int end
)
141 out_idx(0x0c, crtc
, 0x11); /* Vertical sync end, unlock CR0-7 */
142 out_idx(0x0b, crtc
, 0x06); /* Vertical total */
143 out_idx(0x3e, crtc
, 0x07); /* Vertical overflow */
144 out_idx(0xea, crtc
, 0x10); /* Vertical sync start */
145 out_idx(end
, crtc
, 0x12); /* Vertical display end */
146 out_idx(0xe7, crtc
, 0x15); /* Vertical blank start */
147 out_idx(0x04, crtc
, 0x16); /* Vertical blank end */
154 static void vga_set_80x30(void)
156 vga_set_480_scanlines(0xdf);
159 static void vga_set_80x34(void)
162 vga_set_480_scanlines(0xdb);
165 static void vga_set_80x60(void)
168 vga_set_480_scanlines(0xdf);
171 static int vga_set_mode(struct mode_info
*mode
)
173 /* Set the basic mode */
174 vga_set_basic_mode();
176 /* Override a possibly broken BIOS */
180 switch (mode
->mode
) {
207 * Note: this probe includes basic information required by all
208 * systems. It should be executed first, by making sure
209 * video-vga.c is listed first in the Makefile.
211 static int vga_probe(void)
213 static const char *card_name
[] = {
214 "CGA/MDA/HGC", "EGA", "VGA"
216 static struct mode_info
*mode_lists
[] = {
221 static int mode_count
[] = {
222 sizeof(cga_modes
)/sizeof(struct mode_info
),
223 sizeof(ega_modes
)/sizeof(struct mode_info
),
224 sizeof(vga_modes
)/sizeof(struct mode_info
),
229 : "=b" (boot_params
.screen_info
.orig_video_ega_bx
)
230 : "a" (0x1200), "b" (0x10) /* Check EGA/VGA */
231 : "ecx", "edx", "esi", "edi");
233 /* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
234 if ((u8
)boot_params
.screen_info
.orig_video_ega_bx
!= 0x10) {
239 : "ebx", "ecx", "edx", "esi", "edi");
241 if (vga_flag
== 0x1a) {
242 adapter
= ADAPTER_VGA
;
243 boot_params
.screen_info
.orig_video_isVGA
= 1;
245 adapter
= ADAPTER_EGA
;
248 adapter
= ADAPTER_CGA
;
251 video_vga
.modes
= mode_lists
[adapter
];
252 video_vga
.card_name
= card_name
[adapter
];
253 return mode_count
[adapter
];
256 __videocard video_vga
=
260 .set_mode
= vga_set_mode
,