6 static void crtc_write(int reg, unsigned char val);
7 static unsigned char crtc_read(int reg);
9 int vga_setmode(int mode)
11 struct dpmi_regs regs = {0};
13 regs.eax = mode; /* func 00 | mode */
14 dpmi_int(0x10, ®s);
18 static unsigned short crtc_modex_regs[] = {
19 0x0d06, /* vertical total */
20 0x3e07, /* vcount overflow bit */
21 0x4109, /* double-scan */
22 0xea10, /* vsync start */
23 0xac11, /* vsync end & protect */
24 0xdf12, /* vertical visible */
25 0x0014, /* no dword mode */
26 0xe715, /* vblank start */
27 0x0616, /* vblank end */
28 0xe317, /* byte mode */
32 int vga_setmodex(void)
39 /* disable chain-4 (C4=0, O/E=1 (sequential), EM=1 (extmem), A/G=0 (gfx) */
40 outpw(VGA_SC_ADDR_PORT, VGA_SC_MEMMODE_REG | 0x0600);
42 outpw(VGA_SC_ADDR_PORT, VGA_SC_RESET_REG | 0x0100);
43 /* 25mhz dot clock, 60hz scan */
44 outp(VGA_MISC_PORT, VGA_MISC_480 | VGA_MISC_PG1 | VGA_MISC_CLK25 |
45 VGA_MISC_CPUEN | VGA_MISC_COLOR);
46 /* return reset high */
47 outpw(VGA_SC_ADDR_PORT, VGA_SC_RESET_REG | 0x0300);
49 /* disable CRTC write-protect */
50 crtc_write(CRTC_VRETEND_REG, crtc_read(CRTC_VRETEND_REG) & ~CRTC_VRETEND_PR);
51 /* change CRTC registers */
52 for(i=0; crtc_modex_regs[i]; i++) {
53 outpw(VGA_CRTC_PORT, crtc_modex_regs[i]);
57 memset(VGA_FBADDR, 3, 320 * 240 / 4);
61 static void crtc_write(int reg, unsigned char val)
63 outpw(VGA_CRTC_ADDR_PORT, reg | ((unsigned int)val << 8));
66 static unsigned char crtc_read(int reg)
68 outp(VGA_CRTC_ADDR_PORT, reg);
69 return inp(VGA_CRTC_DATA_PORT);