diff options
author | yokota <yokota@FreeBSD.org> | 1999-03-29 15:10:56 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 1999-03-29 15:10:56 +0000 |
commit | 3600be6523af1ff0bf135c44b14e764ab17e5341 (patch) | |
tree | 550f50bf922fe1bd485176b71a170b27fd0f7a5c /sys/i386/isa/vesa.c | |
parent | 90737013b9f92cb267ef67f5a763b35444f48076 (diff) | |
download | FreeBSD-src-3600be6523af1ff0bf135c44b14e764ab17e5341.zip FreeBSD-src-3600be6523af1ff0bf135c44b14e764ab17e5341.tar.gz |
Another round of fix for palette loading.
- Don't try to change DAC width when unnecessary.
- Convert 8 bit DAC data to 6 bit DAC data before unloading the vesa
KLD module.
Diffstat (limited to 'sys/i386/isa/vesa.c')
-rw-r--r-- | sys/i386/isa/vesa.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/sys/i386/isa/vesa.c b/sys/i386/isa/vesa.c index 08ca064..5f303ed 100644 --- a/sys/i386/isa/vesa.c +++ b/sys/i386/isa/vesa.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: vesa.c,v 1.19 1999/03/18 04:38:16 jlemon Exp $ + * $Id: vesa.c,v 1.20 1999/03/18 20:13:20 jlemon Exp $ */ #include "vga.h" @@ -152,6 +152,7 @@ static char *vesa_revstr = NULL; static int int10_set_mode(int mode); static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode); static int vesa_bios_set_mode(int mode); +static int vesa_bios_get_dac(void); static int vesa_bios_set_dac(int bits); static int vesa_bios_save_palette(int start, int colors, u_char *palette, int bits); @@ -235,6 +236,21 @@ vesa_bios_set_mode(int mode) } static int +vesa_bios_get_dac(void) +{ + struct vm86frame vmf; + int err; + + bzero(&vmf, sizeof(vmf)); + vmf.vmf_eax = 0x4f08; + vmf.vmf_ebx = 1; /* get DAC width */ + err = vm86_intcall(0x10, &vmf); + if ((err != 0) || (vmf.vmf_eax != 0x4f)) + return 6; /* XXX */ + return ((vmf.vmf_ebx >> 8) & 0x00ff); +} + +static int vesa_bios_set_dac(int bits) { struct vm86frame vmf; @@ -841,12 +857,14 @@ vesa_save_palette(video_adapter_t *adp, u_char *palette) int bits; int error; - if ((adp == vesa_adp) && (vesa_adp_info->v_flags & V_DAC8) - && ((bits = vesa_bios_set_dac(8)) > 6)) { + if ((adp == vesa_adp) && (vesa_adp_info->v_flags & V_DAC8) + && VESA_MODE(adp->va_mode)) { + bits = vesa_bios_get_dac(); error = vesa_bios_save_palette(0, 256, palette, bits); - vesa_bios_set_dac(6); if (error == 0) return 0; + if (bits != 6) + return error; } return (*prevvidsw->save_palette)(adp, palette); @@ -855,16 +873,19 @@ vesa_save_palette(video_adapter_t *adp, u_char *palette) static int vesa_load_palette(video_adapter_t *adp, u_char *palette) { +#if notyet int bits; int error; if ((adp == vesa_adp) && (vesa_adp_info->v_flags & V_DAC8) - && ((bits = vesa_bios_set_dac(8)) > 6)) { + && VESA_MODE(adp->va_mode) && ((bits = vesa_bios_set_dac(8)) > 6)) { error = vesa_bios_load_palette(0, 256, palette, bits); - vesa_bios_set_dac(6); if (error == 0) return 0; + if (vesa_bios_set_dac(6) != 6) + return 1; } +#endif /* notyet */ return (*prevvidsw->load_palette)(adp, palette); } @@ -1075,7 +1096,9 @@ vesa_load(void) static int vesa_unload(void) { + u_char palette[256*3]; int error; + int bits; int s; /* if the adapter is currently in a VESA mode, don't unload */ @@ -1089,8 +1112,16 @@ vesa_unload(void) s = spltty(); if ((error = vesa_unload_ioctl()) == 0) { if (vesa_adp != NULL) { - if (vesa_adp_info->v_flags & V_DAC8) - vesa_bios_set_dac(6); + if (vesa_adp_info->v_flags & V_DAC8) { + bits = vesa_bios_get_dac(); + if (bits > 6) { + vesa_bios_save_palette(0, 256, + palette, bits); + vesa_bios_set_dac(6); + vesa_bios_load_palette(0, 256, + palette, 6); + } + } vesa_adp->va_flags &= ~V_ADP_VESA; vidsw[vesa_adp->va_index] = prevvidsw; } |