vgabios: Add support for VBE get/set dac palette format (func 08).
authorKevin O'Connor <kevin@koconnor.net>
Sat, 4 Feb 2012 16:08:39 +0000 (11:08 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 4 Feb 2012 16:08:39 +0000 (11:08 -0500)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
vgasrc/bochsvga.c
vgasrc/bochsvga.h
vgasrc/stdvga.c
vgasrc/stdvga.h
vgasrc/vbe.c
vgasrc/vgahw.h

index 9210004466b7a94c4cba0182e90d8eb7dd783b1c..0a36afc5f3a11389807bf93b0f2a5d00ceff16d4 100644 (file)
@@ -180,6 +180,27 @@ bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val)
     return 0;
 }
 
+int
+bochsvga_get_dacformat(struct vgamode_s *vmode_g)
+{
+    u16 en = dispi_read(VBE_DISPI_INDEX_ENABLE);
+    return (en & VBE_DISPI_8BIT_DAC) ? 8 : 6;
+}
+
+int
+bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val)
+{
+    u16 en = dispi_read(VBE_DISPI_INDEX_ENABLE);
+    if (val == 6)
+        en &= ~VBE_DISPI_8BIT_DAC;
+    else if (val == 8)
+        en |= VBE_DISPI_8BIT_DAC;
+    else
+        return -1;
+    dispi_write(VBE_DISPI_INDEX_ENABLE, en);
+    return 0;
+}
+
 
 /****************************************************************
  * Mode setting
index 57b2b6915c1f4bd64523e3874d18fd08eafa4275..78a9e0a535ebae9cfc7c69df84923e6b053cfaee 100644 (file)
@@ -60,6 +60,8 @@ int bochsvga_get_linelength(struct vgamode_s *vmode_g);
 int bochsvga_set_linelength(struct vgamode_s *vmode_g, int val);
 int bochsvga_get_displaystart(struct vgamode_s *vmode_g);
 int bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val);
+int bochsvga_get_dacformat(struct vgamode_s *vmode_g);
+int bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val);
 int bochsvga_set_mode(struct vgamode_s *vmode_g, int flags);
 int bochsvga_init(void);
 
index dcc51a86dd226a5f27bb3aed620d5b94eea0a6d8..1b552db6affb68321ddd789da07f1de2b5fc9ec3 100644 (file)
@@ -326,6 +326,18 @@ stdvga_set_displaystart(struct vgamode_s *vmode_g, int val)
     return 0;
 }
 
+int
+stdvga_get_dacformat(struct vgamode_s *vmode_g)
+{
+    return -1;
+}
+
+int
+stdvga_set_dacformat(struct vgamode_s *vmode_g, int val)
+{
+    return -1;
+}
+
 
 /****************************************************************
  * Save/Restore state
index 4933723b6f062089c867f9147a862ee782f5d0cf..000a0972462ead6d836874149edf13cc3d069640 100644 (file)
@@ -126,6 +126,8 @@ int stdvga_get_linelength(struct vgamode_s *vmode_g);
 int stdvga_set_linelength(struct vgamode_s *vmode_g, int val);
 int stdvga_get_displaystart(struct vgamode_s *vmode_g);
 int stdvga_set_displaystart(struct vgamode_s *vmode_g, int val);
+int stdvga_get_dacformat(struct vgamode_s *vmode_g);
+int stdvga_set_dacformat(struct vgamode_s *vmode_g, int val);
 void stdvga_save_state(u16 seg, struct saveVideoHardware *info);
 void stdvga_restore_state(u16 seg, struct saveVideoHardware *info);
 void stdvga_enable_video_addressing(u8 disable);
index 77b09344c5019a15bfa24a53603f6727108ba09e..0ee69b4ad8257df408ff47b38e3ca45307719b3f 100644 (file)
@@ -305,8 +305,29 @@ fail:
 static void
 vbe_104f08(struct bregs *regs)
 {
-    debug_stub(regs);
-    regs->ax = 0x0100;
+    struct vgamode_s *vmode_g = get_current_mode();
+    if (! vmode_g)
+        goto fail;
+    u8 memmodel = GET_GLOBAL(vmode_g->memmodel);
+    if (memmodel == MM_DIRECT || memmodel == MM_YUV) {
+        regs->ax = 0x034f;
+        return;
+    }
+    if (regs->bl > 1)
+        goto fail;
+    if (regs->bl == 0) {
+        int ret = vgahw_set_dacformat(vmode_g, regs->bh);
+        if (ret < 0)
+            goto fail;
+    }
+    int ret = vgahw_get_dacformat(vmode_g);
+    if (ret < 0)
+        goto fail;
+    regs->bh = ret;
+    regs->ax = 0x004f;
+    return;
+fail:
+    regs->ax = 0x014f;
 }
 
 static void
index af6b06896bf280e2ce3ef92b49a9748519275f9e..585ae3dada6ace516d4f03637f3163eb09f3c81d 100644 (file)
@@ -93,4 +93,16 @@ static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
     return stdvga_set_displaystart(vmode_g, val);
 }
 
+static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
+    if (CONFIG_VGA_BOCHS)
+        return bochsvga_get_dacformat(vmode_g);
+    return stdvga_get_dacformat(vmode_g);
+}
+
+static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
+    if (CONFIG_VGA_BOCHS)
+        return bochsvga_set_dacformat(vmode_g, val);
+    return stdvga_set_dacformat(vmode_g, val);
+}
+
 #endif // vgahw.h