99 * LibreHardwareMonitor; Linux Kernel; OpenRGB; WinRing0 (QCute)
1010 */
1111
12+ using RAMSPDToolkit . Extensions ;
1213using RAMSPDToolkit . Logging ;
14+ using RAMSPDToolkit . Windows . Driver ;
15+ using RAMSPDToolkit . Windows . Driver . Implementations ;
1316using OS = RAMSPDToolkit . Software . OperatingSystem ;
1417
1518namespace RAMSPDToolkit . I2CSMBus
@@ -21,7 +24,7 @@ public static class SMBusManager
2124 {
2225 #region Fields
2326
24- static List < SMBusInterface > _RegisteredSMBuses = new List < SMBusInterface > ( ) ;
27+ static List < SMBusInterface > _RegisteredSMBuses = new ( ) ;
2528
2629 #endregion
2730
@@ -44,6 +47,26 @@ public static IReadOnlyList<SMBusInterface> RegisteredSMBuses
4447
4548 #region Public
4649
50+ /// <summary>
51+ /// Adds your own implementation of an instance of <see cref="SMBusInterface"/> to <see cref="RegisteredSMBuses"/>.
52+ /// </summary>
53+ /// <param name="smbus">SMBus instance to add.</param>
54+ public static void AddSMBus ( SMBusInterface smbus )
55+ {
56+ _RegisteredSMBuses . Add ( smbus ) ;
57+ }
58+
59+ /// <summary>
60+ /// Removes specified instance of <see cref="SMBusInterface"/> from <see cref="RegisteredSMBuses"/>.
61+ /// </summary>
62+ /// <param name="smbus">SMBus instance to remove.</param>
63+ /// <returns>True if SMBus is successfully removed; otherwise false.<br/>
64+ /// This method also returns false if SMBus was not found in <see cref="RegisteredSMBuses"/>.</returns>
65+ public static bool RemoveSMBus ( SMBusInterface smbus )
66+ {
67+ return _RegisteredSMBuses . Remove ( smbus ) ;
68+ }
69+
4770 /// <summary>
4871 /// Gets first SMBus in <see cref="RegisteredSMBuses"/> with specified type.
4972 /// </summary>
@@ -67,20 +90,29 @@ public static void DetectSMBuses()
6790
6891 if ( OS . IsWindows ( ) )
6992 {
70- //smbusDetectMethods.Add(I2CSMBusAmdAdl.SMBusDetect);
71-
72- if ( UseWMI )
93+ if ( DriverManager . DriverImplementation == DriverImplementation . PawnIO )
7394 {
74- smbusDetectMethods . Add ( SMBusI801 . SMBusDetect ) ;
75- smbusDetectMethods . Add ( SMBusPiix4 . SMBusDetect ) ;
95+ smbusDetectMethods . Add ( SMBusPawnIO . SMBusDetect ) ;
7696 }
7797 else
7898 {
79- smbusDetectMethods . Add ( WindowsSMBusDetector . DetectSMBuses ) ;
99+ if ( DriverManager . DriverImplementation . Any ( DriverImplementation . WinRing0 , DriverImplementation . Custom ) )
100+ {
101+ if ( UseWMI )
102+ {
103+ smbusDetectMethods . Add ( SMBusI801 . SMBusDetect ) ;
104+ smbusDetectMethods . Add ( SMBusPiix4 . SMBusDetect ) ;
105+ }
106+ else
107+ {
108+ smbusDetectMethods . Add ( WindowsSMBusDetector . DetectSMBuses ) ;
109+ }
110+
111+ //smbusDetectMethods.Add(I2CSMBusAmdAdl.SMBusDetect);
112+ //smbusDetectMethods.Add(SMBusNVAPI .SMBusDetect);
113+ smbusDetectMethods . Add ( SMBusNCT6775 . SMBusDetect ) ;
114+ }
80115 }
81-
82- //smbusDetectMethods.Add(SMBusNVAPI .SMBusDetect);
83- smbusDetectMethods . Add ( SMBusNCT6775 . SMBusDetect ) ;
84116 }
85117 else if ( OS . IsLinux ( ) )
86118 {
@@ -96,14 +128,5 @@ public static void DetectSMBuses()
96128 }
97129
98130 #endregion
99-
100- #region Internal
101-
102- internal static void AddSMBus ( SMBusInterface smbus )
103- {
104- _RegisteredSMBuses . Add ( smbus ) ;
105- }
106-
107- #endregion
108131 }
109132}
0 commit comments