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 * Standard video BIOS modes
15 * We have two options for this; silent and scanned.
21 static __videocard video_bios
;
23 /* Set a conventional BIOS mode */
24 static int set_bios_mode(u8 mode
);
26 static int bios_set_mode(struct mode_info
*mi
)
28 return set_bios_mode(mi
->mode
- VIDEO_FIRST_BIOS
);
31 static int set_bios_mode(u8 mode
)
33 struct biosregs ireg
, oreg
;
37 ireg
.al
= mode
; /* AH=0x00 Set Video Mode */
38 intcall(0x10, &ireg
, NULL
);
41 ireg
.ah
= 0x0f; /* Get Current Video Mode */
42 intcall(0x10, &ireg
, &oreg
);
44 do_restore
= 1; /* Assume video contents were lost */
46 /* Not all BIOSes are clean with the top bit */
47 new_mode
= ireg
.al
& 0x7f;
50 return 0; /* Mode change OK */
53 if (new_mode
!= boot_params
.screen_info
.orig_video_mode
) {
54 /* Mode setting failed, but we didn't end up where we
55 started. That's bad. Try to revert to the original
57 ireg
.ax
= boot_params
.screen_info
.orig_video_mode
;
58 intcall(0x10, &ireg
, NULL
);
64 static int bios_probe(void)
70 u8 saved_mode
= boot_params
.screen_info
.orig_video_mode
;
76 if (adapter
!= ADAPTER_EGA
&& adapter
!= ADAPTER_VGA
)
82 video_bios
.modes
= GET_HEAP(struct mode_info
, 0);
84 for (mode
= 0x14; mode
<= 0x7f; mode
++) {
85 if (!heap_free(sizeof(struct mode_info
)))
88 if (mode_defined(VIDEO_FIRST_BIOS
+mode
))
91 if (set_bios_mode(mode
))
94 /* Try to verify that it's a text mode. */
96 /* Attribute Controller: make graphics controller disabled */
97 if (in_idx(0x3c0, 0x10) & 0x01)
100 /* Graphics Controller: verify Alpha addressing enabled */
101 if (in_idx(0x3ce, 0x06) & 0x01)
104 /* CRTC cursor location low should be zero(?) */
105 if (in_idx(crtc
, 0x0f))
108 mi
= GET_HEAP(struct mode_info
, 1);
109 mi
->mode
= VIDEO_FIRST_BIOS
+mode
;
110 mi
->depth
= 0; /* text */
111 mi
->x
= rdfs16(0x44a);
112 mi
->y
= rdfs8(0x484)+1;
116 set_bios_mode(saved_mode
);
121 static __videocard video_bios
=
125 .set_mode
= bios_set_mode
,
127 .xmode_first
= VIDEO_FIRST_BIOS
,