12
12
using namespace std ::chrono_literals;
13
13
#define PATRIOT_CONTROLLER_NAME " Patriot Viper"
14
14
15
+ /* *****************************************************************************************\
16
+ * *
17
+ * TestForPatriotViperController *
18
+ * *
19
+ * Tests the given address to see if a Patriot Viper controller exists there. *
20
+ * *
21
+ \******************************************************************************************/
22
+
23
+ bool TestForPatriotViperController (i2c_smbus_interface* bus, unsigned char address)
24
+ {
25
+ bool pass = false ;
26
+
27
+ int res = bus->i2c_smbus_write_quick (address, I2C_SMBUS_WRITE);
28
+
29
+ LOG_DEBUG (" [%s] Writing at address %02X, res=%02X" , PATRIOT_CONTROLLER_NAME, address, res);
30
+
31
+ if (res >= 0 )
32
+ {
33
+ pass = true ;
34
+ }
35
+
36
+ return (pass);
37
+
38
+ } /* TestForPatriotViperController() */
39
+
40
+
15
41
/* *****************************************************************************************\
16
42
* *
17
43
* DetectPatriotViperControllers *
@@ -34,57 +60,55 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses)
34
60
35
61
IF_DRAM_SMBUS (busses[bus]->pci_vendor , busses[bus]->pci_device )
36
62
{
37
- int res = busses[bus]->i2c_smbus_read_byte_data (0x36 , 0x00 );
63
+ // Check for Patriot Viper controller at 0x77
64
+ LOG_DEBUG (" [%s] Testing bus %d at address 0x77" , PATRIOT_CONTROLLER_NAME, bus);
38
65
39
- if (res < 0 )
66
+ if (TestForPatriotViperController (busses[bus], 0x77 ) )
40
67
{
41
- continue ;
42
- }
43
- std::this_thread::sleep_for (1ms);
44
-
45
- for (int slot_addr = 0x50 ; slot_addr <= 0x57 ; slot_addr++)
46
- {
47
- // Test for Patriot Viper RGB SPD at slot_addr
48
- // This test was copied from Viper RGB software
49
- // Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
50
-
51
- busses[bus]->i2c_smbus_write_byte_data (0x36 , 0x00 , 0xFF );
52
-
53
- std::this_thread::sleep_for (1ms);
54
-
55
- int res = busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x00 );
56
-
57
- LOG_DEBUG (" [%s] Trying to read 0x%02X RAM module data at 0x00 expect: 0x23 res: %02X" , PATRIOT_CONTROLLER_NAME, slot_addr, res);
58
- if (res == 0x23 )
68
+ for (int slot_addr = 0x50 ; slot_addr <= 0x57 ; slot_addr++)
59
69
{
60
- busses[bus]->i2c_smbus_write_byte_data (0x37 , 0x00 , 0xFF );
70
+ // Test for Patriot Viper RGB SPD at slot_addr
71
+ // This test was copied from Viper RGB software
72
+ // Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
73
+
74
+ busses[bus]->i2c_smbus_write_byte_data (0x36 , 0x00 , 0xFF );
61
75
62
76
std::this_thread::sleep_for (1ms);
63
77
64
- if ((busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x40 ) == 0x85 )
65
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x41 ) == 0x02 )
66
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x61 ) == 0x4D )
67
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x62 ) == 0x49 )
68
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x63 ) == 0x43 )
69
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x64 ) == 0x53 )
70
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x65 ) == 0x59 )
71
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x66 ) == 0x53 )
72
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x67 ) == 0x5f )
73
- &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x68 ) == 0x44 ))
78
+ int res = busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x00 );
79
+
80
+ LOG_DEBUG (" [%s] Trying to read 0x%02X RAM module data at 0x00 expect: 0x23 res: %02X" , PATRIOT_CONTROLLER_NAME, slot_addr, res);
81
+ if (res == 0x23 )
74
82
{
75
- LOG_DEBUG (" [%s] The 0x%02X RAM module detected" , PATRIOT_CONTROLLER_NAME, slot_addr);
76
- slots_valid |= (1 << (slot_addr - 0x50 ));
83
+ busses[bus]->i2c_smbus_write_byte_data (0x37 , 0x00 , 0xFF );
84
+
85
+ std::this_thread::sleep_for (1ms);
86
+
87
+ if ((busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x40 ) == 0x85 )
88
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x41 ) == 0x02 )
89
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x61 ) == 0x4D )
90
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x62 ) == 0x49 )
91
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x63 ) == 0x43 )
92
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x64 ) == 0x53 )
93
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x65 ) == 0x59 )
94
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x66 ) == 0x53 )
95
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x67 ) == 0x5f )
96
+ &&(busses[bus]->i2c_smbus_read_byte_data (slot_addr, 0x68 ) == 0x44 ))
97
+ {
98
+ LOG_DEBUG (" [%s] The 0x%02X RAM module detected" , PATRIOT_CONTROLLER_NAME, slot_addr);
99
+ slots_valid |= (1 << (slot_addr - 0x50 ));
100
+ }
77
101
}
78
- }
79
102
80
- std::this_thread::sleep_for (1ms);
81
- }
103
+ std::this_thread::sleep_for (1ms);
104
+ }
82
105
83
- if (slots_valid != 0 )
84
- {
85
- new_viper = new PatriotViperController (busses[bus], 0x77 , slots_valid);
86
- new_controller = new RGBController_PatriotViper (new_viper);
87
- ResourceManager::get ()->RegisterRGBController (new_controller);
106
+ if (slots_valid != 0 )
107
+ {
108
+ new_viper = new PatriotViperController (busses[bus], 0x77 , slots_valid);
109
+ new_controller = new RGBController_PatriotViper (new_viper);
110
+ ResourceManager::get ()->RegisterRGBController (new_controller);
111
+ }
88
112
}
89
113
}
90
114
}
0 commit comments