Move Super IO functionality to its own file to make it easier to write an MSI-RGB driver
This commit is contained in:
parent
befa9baf20
commit
4672d4a686
4 changed files with 112 additions and 66 deletions
67
OpenRGB.cpp
67
OpenRGB.cpp
|
|
@ -13,15 +13,12 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <regex>
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "i2c_smbus_i801.h"
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include "super_io.h"
|
||||
#include "wmi.h"
|
||||
#include "inpout32.h"
|
||||
|
||||
#pragma comment(lib, "inpout32.lib")
|
||||
#else /* WIN32 */
|
||||
|
||||
#include "i2c_smbus_linux.h"
|
||||
|
|
@ -36,68 +33,6 @@ std::vector<i2c_smbus_interface*> busses;
|
|||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
#ifdef WIN32
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Nuvoton Super IO constants *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define SIO_NCT5577_ID 0xC330 /* Device ID for NCT5577D (C333) */
|
||||
#define SIO_NCT6102_ID 0x1060 /* Device ID for NCT6102D/6106D (1061) */
|
||||
#define SIO_NCT6793_ID 0xd120 /* Device ID for NCT6793D (D121) */
|
||||
#define SIO_NCT6796_ID 0xd420 /* Device ID for NCT6796D (D421) */
|
||||
#define SIO_REG_LOGDEV 0x07 /* Logical Device Register */
|
||||
#define SIO_REG_DEVID 0x20 /* Device ID Register */
|
||||
#define SIO_REG_SMBA 0x62 /* SMBus Base Address Register */
|
||||
#define SIO_LOGDEV_SMBUS 0x0B /* Logical Device for SMBus */
|
||||
#define SIO_ID_MASK 0xFFF8 /* Device ID mask */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_enter *
|
||||
* *
|
||||
* Put the Super IO chip into Extended Function Mode *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_enter(int ioreg)
|
||||
{
|
||||
Out32(ioreg, 0x87);
|
||||
Out32(ioreg, 0x87);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_outb *
|
||||
* *
|
||||
* Write a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_outb(int ioreg, int reg, int val)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
Out32(ioreg + 1, val);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_inb *
|
||||
* *
|
||||
* Read a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int superio_inb(int ioreg, int reg)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
return Inp32(ioreg + 1);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNuvotonI2CBusses (Windows) *
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ INCLUDEPATH += \
|
|||
i2c_tools/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
super_io/ \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
|
|
@ -46,6 +47,7 @@ SOURCES += \
|
|||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/hsv.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
super_io/super_io.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
|
|
@ -115,6 +117,7 @@ HEADERS += \
|
|||
qt/OpenRGBSystemInfoPage.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
super_io/super_io.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
|
|
|
|||
77
super_io/super_io.cpp
Normal file
77
super_io/super_io.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*-----------------------------------------*\
|
||||
| super_io.cpp |
|
||||
| |
|
||||
| Functions for interfacing with Super-IO |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "super_io.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
|
||||
#pragma comment(lib, "inpout32.lib")
|
||||
#else
|
||||
#include <sys/io.h>
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_enter *
|
||||
* *
|
||||
* Put the Super IO chip into Extended Function Mode *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_enter(int ioreg)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, 0x87);
|
||||
Out32(ioreg, 0x87);
|
||||
#else
|
||||
outb_p(0x87, ioreg);
|
||||
outb_p(0x87, ioreg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_outb *
|
||||
* *
|
||||
* Write a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_outb(int ioreg, int reg, int val)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, reg);
|
||||
Out32(ioreg + 1, val);
|
||||
#else
|
||||
outb_p(reg, ioreg);
|
||||
outb_p(val, ioreg + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_inb *
|
||||
* *
|
||||
* Read a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int superio_inb(int ioreg, int reg)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, reg);
|
||||
return Inp32(ioreg + 1);
|
||||
#else
|
||||
outb_p(reg, ioreg);
|
||||
return inb_p(ioreg + 1);
|
||||
#endif
|
||||
}
|
||||
31
super_io/super_io.h
Normal file
31
super_io/super_io.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*-----------------------------------------*\
|
||||
| super_io.h |
|
||||
| |
|
||||
| Functions for interfacing with Super-IO |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Nuvoton Super IO constants *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define SIO_NCT5577_ID 0xC330 /* Device ID for NCT5577D (C333) */
|
||||
#define SIO_NCT6102_ID 0x1060 /* Device ID for NCT6102D/6106D (1061) */
|
||||
#define SIO_NCT6793_ID 0xd120 /* Device ID for NCT6793D (D121) */
|
||||
#define SIO_NCT6795_ID 0xd350 /* Device ID for NCT6795D (D350) */
|
||||
#define SIO_NCT6796_ID 0xd420 /* Device ID for NCT6796D (D421) */
|
||||
#define SIO_NCT6797_ID 0xd450 /* Device ID for NCT6797D (D450) */
|
||||
#define SIO_REG_LOGDEV 0x07 /* Logical Device Register */
|
||||
#define SIO_REG_DEVID 0x20 /* Device ID Register */
|
||||
#define SIO_REG_SMBA 0x62 /* SMBus Base Address Register */
|
||||
#define SIO_LOGDEV_SMBUS 0x0B /* Logical Device for SMBus */
|
||||
#define SIO_ID_MASK 0xFFF8 /* Device ID mask */
|
||||
|
||||
void superio_enter(int ioreg);
|
||||
|
||||
void superio_outb(int ioreg, int reg, int val);
|
||||
|
||||
int superio_inb(int ioreg, int reg);
|
||||
Loading…
Add table
Add a link
Reference in a new issue