From 485403ac65c70a9baf8324feae0472117fd112a9 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 10 Nov 2021 15:37:12 -0300 Subject: [PATCH] Fix TGUI DDC read bug --- src/video/vid_tgui9440.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 6c4faf170..04ff8b1d5 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -606,15 +606,17 @@ tgui_in(uint16_t addr, void *p) return svga->crtcreg; case 0x3D5: temp = svga->crtc[svga->crtcreg]; - if (!(svga->crtc[0x37] & 0x04)) { - temp &= 0xfd; - if (i2c_gpio_get_scl(tgui->i2c)) - temp |= 0x02; - } - if (!(svga->crtc[0x37] & 0x08)) { - temp &= 0xfe; - if (i2c_gpio_get_sda(tgui->i2c)) - temp |= 0x01; + if (svga->crtcreg == 0x37) { + if (!(temp & 0x04)) { + temp &= ~0x02; + if (i2c_gpio_get_scl(tgui->i2c)) + temp |= 0x02; + } + if (!(temp & 0x08)) { + temp &= ~0x01; + if (i2c_gpio_get_sda(tgui->i2c)) + temp |= 0x01; + } } return temp; case 0x3d8: