vgabios: Unify X_set_mode() functions.
[seabios.git] / vgasrc / clext.c
index 764d05b3a25bcff77a34a0b7bc316aa04b23c497..f468002c712a1a7fcaae4b57c6fe46d165ecf0de 100644 (file)
@@ -5,7 +5,8 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "vgabios.h" // cirrus_init
+#include "clext.h" // clext_init
+#include "vgabios.h" // VBE_VENDOR_STRING
 #include "biosvar.h" // GET_GLOBAL
 #include "util.h" // dprintf
 #include "bregs.h" // struct bregs
@@ -327,14 +328,6 @@ cirrus_switch_mode_setregs(u16 *data, u16 port)
     }
 }
 
-static u16
-cirrus_get_crtc(void)
-{
-    if (inb(VGAREG_READ_MISC_OUTPUT) & 1)
-        return VGAREG_VGA_CRTC_ADDRESS;
-    return VGAREG_MDA_CRTC_ADDRESS;
-}
-
 static void
 cirrus_switch_mode(struct cirrus_mode_s *table)
 {
@@ -342,7 +335,7 @@ cirrus_switch_mode(struct cirrus_mode_s *table)
     outw(0x1206, VGAREG_SEQU_ADDRESS);
     cirrus_switch_mode_setregs(GET_GLOBAL(table->seq), VGAREG_SEQU_ADDRESS);
     cirrus_switch_mode_setregs(GET_GLOBAL(table->graph), VGAREG_GRDC_ADDRESS);
-    cirrus_switch_mode_setregs(GET_GLOBAL(table->crtc), cirrus_get_crtc());
+    cirrus_switch_mode_setregs(GET_GLOBAL(table->crtc), stdvga_get_crtc());
 
     outb(0x00, VGAREG_PEL_MASK);
     inb(VGAREG_PEL_MASK);
@@ -353,12 +346,12 @@ cirrus_switch_mode(struct cirrus_mode_s *table)
     outb(0xff, VGAREG_PEL_MASK);
 
     u8 vesacolortype = GET_GLOBAL(table->vesacolortype);
-    u8 v = vgahw_get_single_palette_reg(0x10) & 0xfe;
+    u8 v = stdvga_get_single_palette_reg(0x10) & 0xfe;
     if (vesacolortype == 3)
         v |= 0x41;
     else if (vesacolortype)
         v |= 0x01;
-    vgahw_set_single_palette_reg(0x10, v);
+    stdvga_set_single_palette_reg(0x10, v);
 }
 
 static u8
@@ -400,22 +393,22 @@ cirrus_clear_vram(u16 param)
 }
 
 int
-cirrus_set_video_mode(u8 mode, u8 noclearmem)
+clext_set_mode(int mode, int flags)
 {
     dprintf(1, "cirrus mode %d\n", mode);
     SET_BDA(vbe_mode, 0);
     struct cirrus_mode_s *table_g = cirrus_get_modeentry(mode);
     if (table_g) {
         cirrus_switch_mode(table_g);
-        if (!noclearmem)
+        if (!(flags & MF_NOCLEARMEM))
             cirrus_clear_vram(0xffff);
         SET_BDA(video_mode, mode);
-        return 1;
+        return 0;
     }
     table_g = cirrus_get_modeentry(0xfe);
     cirrus_switch_mode(table_g);
     dprintf(1, "cirrus mode switch regular\n");
-    return 0;
+    return stdvga_set_mode(mode, flags);
 }
 
 static int
@@ -433,7 +426,7 @@ cirrus_check(void)
 static void
 cirrus_extbios_80h(struct bregs *regs)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x27, crtc_addr);
     u8 v = inb(crtc_addr + 1);
     if (v == 0xa0)
@@ -458,7 +451,7 @@ cirrus_extbios_81h(struct bregs *regs)
 static void
 cirrus_extbios_82h(struct bregs *regs)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x27, crtc_addr);
     regs->al = inb(crtc_addr + 1) & 0x03;
     regs->ah = 0xAF;
@@ -596,7 +589,7 @@ cirrus_get_bpp_bytes(void)
 static void
 cirrus_set_line_offset(u16 new_line_offset)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x13, crtc_addr);
     outb(new_line_offset / 8, crtc_addr + 1);
 
@@ -608,7 +601,7 @@ cirrus_set_line_offset(u16 new_line_offset)
 static u16
 cirrus_get_line_offset(void)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x13, crtc_addr);
     u8 reg13 = inb(crtc_addr + 1);
     outb(0x1b, crtc_addr);
@@ -648,7 +641,7 @@ cirrus_get_line_offset_entry(struct cirrus_mode_s *table_g)
 static void
 cirrus_set_start_addr(u32 addr)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x0d, crtc_addr);
     outb(addr, crtc_addr + 1);
 
@@ -668,7 +661,7 @@ cirrus_set_start_addr(u32 addr)
 static u32
 cirrus_get_start_addr(void)
 {
-    u16 crtc_addr = cirrus_get_crtc();
+    u16 crtc_addr = stdvga_get_crtc();
     outb(0x0c, crtc_addr);
     u8 b2 = inb(crtc_addr + 1);
 
@@ -940,7 +933,7 @@ cirrus_vesa(struct bregs *regs)
  ****************************************************************/
 
 void
-cirrus_init(void)
+clext_init(void)
 {
     dprintf(1, "cirrus init\n");
     if (! cirrus_check())