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 * Standard video BIOS modes
14 * We have two options for this; silent and scanned.
20 __videocard video_bios;
22 /* Set a conventional BIOS mode */
23 static int set_bios_mode(u8 mode);
25 static int bios_set_mode(struct mode_info *mi)
27 return set_bios_mode(mi->mode - VIDEO_FIRST_BIOS);
30 static int set_bios_mode(u8 mode)
35 ax = mode; /* AH=0x00 Set Video Mode */
38 : : "ebx", "ecx", "edx", "esi", "edi");
40 ax = 0x0f00; /* Get Current Video Mode */
43 : : "ebx", "ecx", "edx", "esi", "edi");
45 do_restore = 1; /* Assume video contents were lost */
46 new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */
49 return 0; /* Mode change OK */
52 if (new_mode != boot_params.screen_info.orig_video_mode) {
53 /* Mode setting failed, but we didn't end up where we
54 started. That's bad. Try to revert to the original
56 ax = boot_params.screen_info.orig_video_mode;
59 : : "ebx", "ecx", "edx", "esi", "edi");
65 static int bios_probe(void)
71 u8 saved_mode = boot_params.screen_info.orig_video_mode;
77 if (adapter != ADAPTER_EGA && adapter != ADAPTER_VGA)
83 video_bios.modes = GET_HEAP(struct mode_info, 0);
85 for (mode = 0x14; mode <= 0x7f; mode++) {
86 if (!heap_free(sizeof(struct mode_info)))
89 if (mode_defined(VIDEO_FIRST_BIOS+mode))
92 if (set_bios_mode(mode))
95 /* Try to verify that it's a text mode. */
97 /* Attribute Controller: make graphics controller disabled */
98 if (in_idx(0x3c0, 0x10) & 0x01)
101 /* Graphics Controller: verify Alpha addressing enabled */
102 if (in_idx(0x3ce, 0x06) & 0x01)
105 /* CRTC cursor location low should be zero(?) */
106 if (in_idx(crtc, 0x0f))
109 mi = GET_HEAP(struct mode_info, 1);
110 mi->mode = VIDEO_FIRST_BIOS+mode;
111 mi->depth = 0; /* text */
112 mi->x = rdfs16(0x44a);
113 mi->y = rdfs8(0x484)+1;
117 set_bios_mode(saved_mode);
122 __videocard video_bios =
126 .set_mode = bios_set_mode,
128 .xmode_first = VIDEO_FIRST_BIOS,