From 148e466b807bb547a49891c6d691f98854157aeb Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 30 Dec 2023 01:27:04 +0600 Subject: [PATCH 1/2] Implement BAR swap for Matrox Mystique 220 Revision ID now properly indicates a Mystique 220 card --- src/video/vid_mga.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 6e85cfe5e..66a7dca71 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -5676,9 +5676,9 @@ mystique_pci_read(UNUSED(int func), int addr, void *priv) mystique_t *mystique = (mystique_t *) priv; uint8_t ret = 0x00; - if (mystique->type >= MGA_2164W) + if (mystique->type >= MGA_1164SG) { - /* Millennium II and later Matrox cards swap MGABASE1 and 2. */ + /* Mystique 220, Millennium II and later Matrox cards swap MGABASE1 and 2. */ if (addr >= 0x10 && addr <= 0x13) addr += 0x4; else if (addr >= 0x14 && addr <= 0x17) @@ -5718,7 +5718,7 @@ mystique_pci_read(UNUSED(int func), int addr, void *priv) break; /*Fast DEVSEL timing*/ case 0x08: - ret = 0; + ret = (mystique->type == MGA_1164SG) ? 3 : 0; break; /*Revision ID*/ case 0x09: ret = 0; @@ -5837,9 +5837,9 @@ mystique_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) { mystique_t *mystique = (mystique_t *) priv; - if (mystique->type >= MGA_2164W) + if (mystique->type >= MGA_1164SG) { - /* Millennium II and later Matrox cards swap MGABASE1 and 2. */ + /* Mystique 220, Millennium II and later Matrox cards swap MGABASE1 and 2. */ if (addr >= 0x10 && addr <= 0x13) addr += 0x4; else if (addr >= 0x14 && addr <= 0x17) From 4d7fd68bbc5440d5bfb6f234e9afe7e9ec46b8e4 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 30 Dec 2023 02:10:45 +0600 Subject: [PATCH 2/2] Millennium and Millennium 2: Enable gamma correction only for 24+ bpp TVP3026 datasheet poorly or doesn't document at all gamma correction for 15/16 bpp --- src/video/vid_mga.c | 7 +++++-- src/video/vid_tvp3026_ramdac.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 66a7dca71..d30b2d681 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -947,9 +947,12 @@ mystique_recalctimings(svga_t *svga) svga->hdisp = (svga->crtc[1] + 1) << 3; svga->hdisp_time = svga->hdisp; svga->rowoffset = svga->crtc[0x13] | ((mystique->crtcext_regs[0] & CRTCX_R0_OFFSET_MASK) << 4); - svga->lut_map = !!(mystique->xmiscctrl & XMISCCTRL_RAMCS); + + if (mystique->type != MGA_2164W && mystique->type != MGA_2064W) + svga->lut_map = !!(mystique->xmiscctrl & XMISCCTRL_RAMCS); + if (mystique->type >= MGA_1064SG) - svga->ma_latch = ((mystique->crtcext_regs[0] & CRTCX_R0_STARTADD_MASK) << 16) | (svga->crtc[0xc] << 8) | svga->crtc[0xd]; + svga->ma_latch = ((mystique->crtcext_regs[0] & CRTCX_R0_STARTADD_MASK) << 16) | (svga->crtc[0xc] << 8) | svga->crtc[0xd]; if ((mystique->pci_regs[0x41] & (OPTION_INTERLEAVE >> 8))) { svga->rowoffset <<= 1; diff --git a/src/video/vid_tvp3026_ramdac.c b/src/video/vid_tvp3026_ramdac.c index 611527a35..008f89a8b 100644 --- a/src/video/vid_tvp3026_ramdac.c +++ b/src/video/vid_tvp3026_ramdac.c @@ -515,6 +515,8 @@ tvp3026_recalctimings(void *priv, svga_t *svga) const tvp3026_ramdac_t *ramdac = (tvp3026_ramdac_t *) priv; svga->interlace = (ramdac->ccr & 0x40); + /* TODO: Figure out gamma correction for 15/16 bpp color. */ + svga->lut_map = !!(svga->bpp >= 24 && (ramdac->true_color & 0xf0) != 0x00); } void