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