10
10
*
11
11
*
12
12
*
13
- * Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
14
- * Miran Grca, <mgrca8@gmail.com>
13
+ * Authors: Cacodemon345
15
14
*
16
- * Copyright 2008-2018 Sarah Walker.
17
- * Copyright 2016-2018 Miran Grca.
15
+ * Copyright 2023-2024 Cacodemon345
18
16
*/
19
17
#include <stdio.h>
20
18
#include <stdint.h>
34
32
#include <86box/vid_svga_render.h>
35
33
#include <86box/pci.h>
36
34
#include <86box/thread.h>
35
+ #include <86box/i2c.h>
36
+ #include <86box/vid_ddc.h>
37
37
#include <assert.h>
38
38
39
39
typedef struct chips_69000_t {
@@ -81,6 +81,8 @@ typedef struct chips_69000_t {
81
81
};
82
82
83
83
rom_t bios_rom ;
84
+
85
+ void * i2c_ddc , * ddc ;
84
86
} chips_69000_t ;
85
87
86
88
static video_timings_t timing_sis = { .type = VIDEO_PCI , .write_b = 2 , .write_w = 2 , .write_l = 4 , .read_b = 20 , .read_w = 20 , .read_l = 35 };
@@ -666,7 +668,16 @@ chips_69000_read_ext_reg(chips_69000_t* chips)
666
668
case 0x0A :
667
669
return chips -> ext_regs [index ] & 0x37 ;
668
670
case 0x63 :
669
- return 0xFF ;
671
+ {
672
+ uint8_t val = chips -> ext_regs [index ];
673
+ if (!(chips -> ext_regs [0x62 ] & 0x8 ))
674
+ val = (val & ~8 ) | (i2c_gpio_get_scl (chips -> i2c_ddc ) << 3 );
675
+
676
+ if (!(chips -> ext_regs [0x62 ] & 0x4 ))
677
+ val = (val & ~4 ) | (i2c_gpio_get_sda (chips -> i2c_ddc ) << 2 );
678
+
679
+ return val ;
680
+ }
670
681
case 0x70 :
671
682
return 0x3 ;
672
683
case 0x71 :
@@ -711,6 +722,24 @@ chips_69000_write_ext_reg(chips_69000_t* chips, uint8_t val)
711
722
case 0x62 :
712
723
chips -> ext_regs [chips -> ext_index ] = val & 0x9C ;
713
724
break ;
725
+ case 0x63 :
726
+ {
727
+ uint8_t scl = 0 , sda = 0 ;
728
+ if (chips -> ext_regs [0x62 ] & 0x8 )
729
+ scl = !!(val & 8 );
730
+ else
731
+ scl = i2c_gpio_get_scl (chips -> i2c_ddc );
732
+
733
+ if (chips -> ext_regs [0x62 ] & 0x4 )
734
+ sda = !!(val & 4 );
735
+ else
736
+ scl = i2c_gpio_get_sda (chips -> i2c_ddc );
737
+
738
+ i2c_gpio_set (chips -> i2c_ddc , scl , sda );
739
+
740
+ chips -> ext_regs [chips -> ext_index ] = val & 0x9F ;
741
+ break ;
742
+ }
714
743
case 0x67 :
715
744
chips -> ext_regs [chips -> ext_index ] = val & 0x2 ;
716
745
break ;
@@ -1285,6 +1314,9 @@ chips_69000_init(const device_t *info)
1285
1314
timer_add (& chips -> decrement_timer , chips_69000_decrement_timer , chips , 0 );
1286
1315
timer_on_auto (& chips -> decrement_timer , 1000000. / 2000. );
1287
1316
1317
+ chips -> i2c_ddc = i2c_gpio_init ("c&t_69000_mga" );
1318
+ chips -> ddc = ddc_init (i2c_gpio_get_bus (chips -> i2c_ddc ));
1319
+
1288
1320
return chips ;
1289
1321
}
1290
1322
@@ -1302,6 +1334,8 @@ chips_69000_close(void *p)
1302
1334
chips -> quit = 1 ;
1303
1335
// thread_set_event(chips->fifo_event);
1304
1336
// thread_wait(chips->accel_thread);
1337
+ ddc_close (chips -> ddc );
1338
+ i2c_gpio_close (chips -> i2c_ddc );
1305
1339
svga_close (& chips -> svga );
1306
1340
1307
1341
free (chips );
0 commit comments