mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-23 23:37:48 -05:00
Update PawnIO SMBus driver to use standardized API between all drivers, add NCT6793 driver, and remove WinRing0 SMBus drivers
This commit is contained in:
@@ -277,7 +277,7 @@ void DetectENESMBusMotherboardControllers(std::vector<i2c_smbus_interface*> &bus
|
||||
// Add ENE (ASUS Aura) motherboard controllers
|
||||
IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
{
|
||||
if(busses[bus]->pci_subsystem_vendor == ASUS_SUB_VEN || busses[bus]->pci_subsystem_vendor == 0)
|
||||
if(busses[bus]->pci_subsystem_vendor == ASUS_SUB_VEN || busses[bus]->pci_subsystem_vendor == 0 || busses[bus]->pci_subsystem_vendor == 0xFFFF)
|
||||
{
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
|
||||
@@ -431,6 +431,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/PawnIO/PawnIOLib.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/PawnIO/modules/SmbusPIIX4.bin )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/PawnIO/modules/SmbusI801.bin )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/PawnIO/modules/SmbusNCT6793.bin )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/PawnIO/modules/LpcIO.bin )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
first.depends = $(first) copydata
|
||||
export(first.depends)
|
||||
|
||||
BIN
dependencies/PawnIO/modules/LpcIO.bin
vendored
BIN
dependencies/PawnIO/modules/LpcIO.bin
vendored
Binary file not shown.
BIN
dependencies/PawnIO/modules/SmbusI801.bin
vendored
BIN
dependencies/PawnIO/modules/SmbusI801.bin
vendored
Binary file not shown.
BIN
dependencies/PawnIO/modules/SmbusNCT6793.bin
vendored
Normal file
BIN
dependencies/PawnIO/modules/SmbusNCT6793.bin
vendored
Normal file
Binary file not shown.
BIN
dependencies/PawnIO/modules/SmbusPIIX4.bin
vendored
BIN
dependencies/PawnIO/modules/SmbusPIIX4.bin
vendored
Binary file not shown.
@@ -232,12 +232,12 @@ bool i2c_smbus_nct6775_detect()
|
||||
case SIO_NCT6793_ID:
|
||||
case SIO_NCT6796_ID:
|
||||
case SIO_NCT6798_ID:
|
||||
// Create new nct6775 bus and zero out the PCI ID information
|
||||
// Create new nct6775 bus and invalidate the PCI ID information
|
||||
bus = new i2c_smbus_nct6775();
|
||||
bus->pci_vendor = 0;
|
||||
bus->pci_device = 0;
|
||||
bus->pci_subsystem_vendor = 0;
|
||||
bus->pci_subsystem_device = 0;
|
||||
bus->pci_vendor = 0xFFFF;
|
||||
bus->pci_device = 0xFFFF;
|
||||
bus->pci_subsystem_vendor = 0xFFFF;
|
||||
bus->pci_subsystem_device = 0xFFFF;
|
||||
|
||||
// Set logical device register to get SMBus base address
|
||||
superio_outb(sioaddr, SIO_REG_LOGDEV, SIO_LOGDEV_SMBUS);
|
||||
|
||||
@@ -22,11 +22,52 @@ std::unordered_map<std::string, int> i2c_smbus_pawnio::using_handle;
|
||||
|
||||
i2c_smbus_pawnio::i2c_smbus_pawnio(HANDLE handle, std::string name)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Store bus information |
|
||||
| TODO: Remove name field once all drivers use the same |
|
||||
| ioctl names |
|
||||
\*-----------------------------------------------------*/
|
||||
this->handle = handle;
|
||||
this->name = name;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get driver settings |
|
||||
\*-----------------------------------------------------*/
|
||||
json drivers_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Drivers");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get bus information |
|
||||
\*-----------------------------------------------------*/
|
||||
const SIZE_T in_size = 1;
|
||||
ULONG64 in[in_size] = {0};
|
||||
const SIZE_T out_size = 3;
|
||||
ULONG64 out[out_size];
|
||||
SIZE_T return_size;
|
||||
HRESULT status;
|
||||
|
||||
status = pawnio_execute(handle, "ioctl_identity", in, in_size, out, out_size, &return_size);
|
||||
|
||||
if(!status)
|
||||
{
|
||||
this->pci_vendor = (out[2] & 0x000000000000FFFF);
|
||||
this->pci_device = (out[2] & 0x00000000FFFF0000) >> 16;
|
||||
this->pci_subsystem_vendor = (out[2] & 0x0000FFFF0000FFFF) >> 32;
|
||||
this->pci_subsystem_device = (out[2] & 0xFFFF000000000000) >> 48;
|
||||
|
||||
char name_str[9];
|
||||
name_str[0] = (out[0] & 0x00000000000000FF);
|
||||
name_str[1] = (out[0] & 0x000000000000FF00) >> 8;
|
||||
name_str[2] = (out[0] & 0x0000000000FF0000) >> 16;
|
||||
name_str[3] = (out[0] & 0x00000000FF000000) >> 24;
|
||||
name_str[4] = (out[0] & 0x000000FF00000000) >> 32;
|
||||
name_str[5] = (out[0] & 0x0000FF0000000000) >> 40;
|
||||
name_str[6] = (out[0] & 0x00FF000000000000) >> 48;
|
||||
name_str[7] = (out[0] & 0xFF00000000000000) >> 56;
|
||||
name_str[8] = 0;
|
||||
|
||||
strncpy( this->device_name, name_str, 512 );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get shared SMBus access setting |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -45,14 +86,6 @@ i2c_smbus_pawnio::i2c_smbus_pawnio(HANDLE handle, std::string name)
|
||||
global_smbus_access_handle = CreateMutexA(NULL, FALSE, GLOBAL_SMBUS_MUTEX_NAME);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Store bus information |
|
||||
| TODO: Remove name field once all drivers use the same |
|
||||
| ioctl names |
|
||||
\*-----------------------------------------------------*/
|
||||
this->handle = handle;
|
||||
this->name = name;
|
||||
|
||||
using_handle[name]++;
|
||||
}
|
||||
|
||||
@@ -75,207 +108,52 @@ i2c_smbus_pawnio::~i2c_smbus_pawnio()
|
||||
}
|
||||
}
|
||||
|
||||
s32 i2c_smbus_pawnio::pawnio_read(u8 addr, char /*read_write*/, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
SIZE_T return_size;
|
||||
|
||||
switch(size)
|
||||
{
|
||||
case I2C_SMBUS_BYTE:
|
||||
{
|
||||
const SIZE_T in_size = 1;
|
||||
ULONG64 in[in_size] = {addr};
|
||||
const SIZE_T out_size = 1;
|
||||
ULONG64 out[out_size];
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO read_byte ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_read_byte").c_str(), in, in_size, out, out_size, &return_size);
|
||||
data->byte = (u8)out[0];
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
{
|
||||
const SIZE_T in_size = 2;
|
||||
ULONG64 in[in_size] = {addr, command};
|
||||
const SIZE_T out_size = 1;
|
||||
ULONG64 out[out_size];
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO read_byte_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_read_byte_data").c_str(), in, in_size, out, out_size, &return_size);
|
||||
data->byte = (u8)out[0];
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
{
|
||||
const SIZE_T in_size = 2;
|
||||
ULONG64 in[in_size] = {addr, command};
|
||||
const SIZE_T out_size = 1;
|
||||
ULONG64 out[out_size];
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO read_word_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_read_word_data").c_str(), in, in_size, out, out_size, &return_size);
|
||||
data->word = (u16)out[0];
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
{
|
||||
const SIZE_T in_size = 2;
|
||||
ULONG64 in[in_size] = {addr, command};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Calculate output data buffer size |
|
||||
| Pawn only deals with 64-bit cells, divide by |
|
||||
| 8 to convert bytes to qwords. |
|
||||
| The first cell is also the length. |
|
||||
\*---------------------------------------------*/
|
||||
const SIZE_T out_size = 1 + (I2C_SMBUS_BLOCK_MAX / 8);
|
||||
ULONG64 out[out_size];
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO read_block_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_read_block_data").c_str(), in, in_size, out, out_size, &return_size);
|
||||
|
||||
if(status)
|
||||
{
|
||||
return(-EIO);
|
||||
}
|
||||
|
||||
if(out[0] == 0 || out[0] > I2C_SMBUS_BLOCK_MAX)
|
||||
{
|
||||
return(-EPROTO);
|
||||
}
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Unpack bytes from 64bit Pawn cells |
|
||||
\*---------------------------------------------*/
|
||||
u8 *out_bytes = (u8*)(&out[1]);
|
||||
memcpy(&data->block[1], out_bytes, out[0]);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
default:
|
||||
return(-EOPNOTSUPP);
|
||||
}
|
||||
}
|
||||
|
||||
s32 i2c_smbus_pawnio::pawnio_write(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
SIZE_T return_size;
|
||||
|
||||
switch(size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
{
|
||||
const SIZE_T in_size = 2;
|
||||
ULONG64 in[in_size] = {addr, (u8)read_write};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO write_quick ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_write_quick").c_str(), in, in_size, NULL, 0, &return_size);
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_BYTE:
|
||||
{
|
||||
const SIZE_T in_size = 2;
|
||||
ULONG64 in[in_size] = {addr, data->byte};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO write_byte ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_write_byte").c_str(), in, in_size, NULL, 0, &return_size);
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
{
|
||||
const SIZE_T in_size = 3;
|
||||
ULONG64 in[in_size] = {addr, command, data->byte};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO write_byte_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_write_byte_data").c_str(), in, in_size, NULL, 0, &return_size);
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
{
|
||||
const SIZE_T in_size = 3;
|
||||
ULONG64 in[in_size] = {addr, command, data->word};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO write_word_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_write_word_data").c_str(), in, in_size, NULL, 0, &return_size);
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
{
|
||||
SIZE_T len = data->block[0];
|
||||
if(len == 0 || len > I2C_SMBUS_BLOCK_MAX)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
const SIZE_T in_size = 3 + (I2C_SMBUS_BLOCK_MAX/8);
|
||||
ULONG64 in[3 + (I2C_SMBUS_BLOCK_MAX/8)] = {addr, command, len};
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Pack bytes into 64bit Pawn cells |
|
||||
\*---------------------------------------------*/
|
||||
u8 *in_bytes = (u8*)&in[3];
|
||||
memcpy(in_bytes, &data->block[1], len);
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Execute PawnIO write_block_data ioctl |
|
||||
\*---------------------------------------------*/
|
||||
HRESULT status = pawnio_execute(handle, ("ioctl_" + name + "_write_block_data").c_str(), in, in_size, NULL, 0, &return_size);
|
||||
|
||||
return(status ? -EIO : 0);
|
||||
}
|
||||
|
||||
default:
|
||||
return(-EOPNOTSUPP);
|
||||
}
|
||||
}
|
||||
|
||||
s32 i2c_smbus_pawnio::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Lock SMBus mutex |
|
||||
\*-----------------------------------------------------*/
|
||||
if(global_smbus_access_handle != NULL)
|
||||
{
|
||||
WaitForSingleObject(global_smbus_access_handle, INFINITE);
|
||||
}
|
||||
|
||||
int status = -ENXIO;
|
||||
/*-----------------------------------------------------*\
|
||||
| Pack input data |
|
||||
\*-----------------------------------------------------*/
|
||||
const SIZE_T in_size = 9;
|
||||
ULONG64 in[in_size];
|
||||
const SIZE_T out_size = 5;
|
||||
ULONG64 out[out_size];
|
||||
SIZE_T return_size;
|
||||
HRESULT status;
|
||||
|
||||
if(read_write && size != I2C_SMBUS_QUICK) {
|
||||
status = pawnio_read(addr, read_write, command, size, data);
|
||||
}
|
||||
else
|
||||
in[0] = addr;
|
||||
in[1] = read_write;
|
||||
in[2] = command;
|
||||
in[3] = size;
|
||||
|
||||
if(data != NULL)
|
||||
{
|
||||
status = pawnio_write(addr, read_write, command, size, data);
|
||||
memcpy( &in[4], data, sizeof(i2c_smbus_data));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Perform SMBus transfer |
|
||||
\*-----------------------------------------------------*/
|
||||
status = pawnio_execute(handle, "ioctl_smbus_xfer", in, in_size, out, out_size, &return_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Unpack output data |
|
||||
\*-----------------------------------------------------*/
|
||||
if(data != NULL)
|
||||
{
|
||||
memcpy( data, &out[0], sizeof(i2c_smbus_data));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Unlock SMBus mutex |
|
||||
\*-----------------------------------------------------*/
|
||||
if(global_smbus_access_handle != NULL)
|
||||
{
|
||||
ReleaseMutex(global_smbus_access_handle);
|
||||
@@ -289,7 +167,6 @@ s32 i2c_smbus_pawnio::i2c_xfer(u8 /*addr*/, char /*read_write*/, int* /*size*/,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// TODO: Find a better place for this function
|
||||
HRESULT i2c_smbus_pawnio::start_pawnio(std::string filename, PHANDLE phandle)
|
||||
{
|
||||
char exePath[MAX_PATH];
|
||||
@@ -415,141 +292,52 @@ bool i2c_smbus_pawnio_detect()
|
||||
}
|
||||
|
||||
i2c_smbus_interface * bus;
|
||||
HRESULT hres;
|
||||
Wmi wmi;
|
||||
HANDLE pawnio_handle;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Query WMI for Win32_PnPSignedDriver entries with |
|
||||
| names matching "SMBUS" or "SM BUS". These devices |
|
||||
| may be browsed under Device Manager -> System Devices |
|
||||
| Try to load Intel (i801) SMBus driver |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<QueryObj> q_res_PnPSignedDriver;
|
||||
hres = wmi.query("SELECT * FROM Win32_PnPSignedDriver WHERE Description LIKE '%SMBUS%' OR Description LIKE '%SM BUS%'", q_res_PnPSignedDriver);
|
||||
|
||||
if(hres)
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusI801.bin", &pawnio_handle) == S_OK)
|
||||
{
|
||||
LOG_INFO("WMI query failed, I2C bus detection aborted");
|
||||
return(false);
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "i801");
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| For each detected SMBus adapter, try enumerating it |
|
||||
| as either AMD (piix4) or Intel (i801) |
|
||||
| Try to load AMD (PIIX4) SMBus driver - primary bus |
|
||||
\*-----------------------------------------------------*/
|
||||
for(QueryObj &i : q_res_PnPSignedDriver)
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusPIIX4.bin", &pawnio_handle) == S_OK)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Intel SMBus controllers do show I/O resources in |
|
||||
| Device Manager. Analysis of many Intel boards |
|
||||
| has shown that Intel SMBus adapter I/O space |
|
||||
| varies between boards. We can query |
|
||||
| Win32_PnPAllocatedResource entries and look up |
|
||||
| the PCI device ID to find the allocated I/O space.|
|
||||
| |
|
||||
| Intel SMBus adapters use the i801 driver |
|
||||
| Select port 0 |
|
||||
\*-------------------------------------------------*/
|
||||
if((i["Manufacturer"].find("Intel") != std::string::npos)
|
||||
|| (i["Manufacturer"].find("INTEL") != std::string::npos))
|
||||
{
|
||||
std::string pnp_str = i["DeviceID"];
|
||||
piix4_port_sel(pawnio_handle, 0);
|
||||
|
||||
std::size_t ven_loc = pnp_str.find("VEN_");
|
||||
std::size_t dev_loc = pnp_str.find("DEV_");
|
||||
std::size_t sub_loc = pnp_str.find("SUBSYS_");
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "piix4");
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
|
||||
std::string ven_str = pnp_str.substr(ven_loc + 4, 4);
|
||||
std::string dev_str = pnp_str.substr(dev_loc + 4, 4);
|
||||
std::string sbv_str = pnp_str.substr(sub_loc + 11, 4);
|
||||
std::string sbd_str = pnp_str.substr(sub_loc + 7, 4);
|
||||
|
||||
int ven_id = (int)std::stoul(ven_str, nullptr, 16);
|
||||
int dev_id = (int)std::stoul(dev_str, nullptr, 16);
|
||||
int sbv_id = (int)std::stoul(sbv_str, nullptr, 16);
|
||||
int sbd_id = (int)std::stoul(sbd_str, nullptr, 16);
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Create bus |
|
||||
\*---------------------------------------------*/
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusI801.bin", &pawnio_handle) != S_OK)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "i801");
|
||||
bus->pci_vendor = ven_id;
|
||||
bus->pci_device = dev_id;
|
||||
bus->pci_subsystem_vendor = sbv_id;
|
||||
bus->pci_subsystem_device = sbd_id;
|
||||
strncpy(bus->device_name, i["Description"].c_str(), sizeof bus->device_name);
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| AMD SMBus adapters use the PIIX4 driver |
|
||||
/*-----------------------------------------------------*\
|
||||
| Try to load AMD (PIIX4 SMBus driver - secondary bus |
|
||||
\*-----------------------------------------------------*/
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusPIIX4.bin", &pawnio_handle) == S_OK)
|
||||
{
|
||||
/*--------------------------------------------------*\
|
||||
| Select port 1 |
|
||||
\*-------------------------------------------------*/
|
||||
else if(i["Manufacturer"].find("Advanced Micro Devices, Inc") != std::string::npos)
|
||||
{
|
||||
std::string pnp_str = i["DeviceID"];
|
||||
piix4_port_sel(pawnio_handle, 1);
|
||||
|
||||
std::size_t ven_loc = pnp_str.find("VEN_");
|
||||
std::size_t dev_loc = pnp_str.find("DEV_");
|
||||
std::size_t sub_loc = pnp_str.find("SUBSYS_");
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "piix4");
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
|
||||
std::string ven_str = pnp_str.substr(ven_loc + 4, 4);
|
||||
std::string dev_str = pnp_str.substr(dev_loc + 4, 4);
|
||||
std::string sbv_str = pnp_str.substr(sub_loc + 11, 4);
|
||||
std::string sbd_str = pnp_str.substr(sub_loc + 7, 4);
|
||||
|
||||
int ven_id = (int)std::stoul(ven_str, nullptr, 16);
|
||||
int dev_id = (int)std::stoul(dev_str, nullptr, 16);
|
||||
int sbv_id = (int)std::stoul(sbv_str, nullptr, 16);
|
||||
int sbd_id = (int)std::stoul(sbd_str, nullptr, 16);
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Create primary bus |
|
||||
\*---------------------------------------------*/
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusPIIX4.bin", &pawnio_handle) != S_OK)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Select port 0 |
|
||||
\*---------------------------------------------*/
|
||||
piix4_port_sel(pawnio_handle, 0);
|
||||
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "piix4");
|
||||
bus->pci_vendor = ven_id;
|
||||
bus->pci_device = dev_id;
|
||||
bus->pci_subsystem_vendor = sbv_id;
|
||||
bus->pci_subsystem_device = sbd_id;
|
||||
strncpy(bus->device_name, i["Description"].c_str(), sizeof bus->device_name);
|
||||
strncat(bus->device_name, " port 0", sizeof bus->device_name);
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Create secondary bus |
|
||||
\*---------------------------------------------*/
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusPIIX4.bin", &pawnio_handle) != S_OK)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Select port 1 |
|
||||
\*---------------------------------------------*/
|
||||
piix4_port_sel(pawnio_handle, 1);
|
||||
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "piix4");
|
||||
bus->pci_vendor = ven_id;
|
||||
bus->pci_device = dev_id;
|
||||
bus->pci_subsystem_vendor = sbv_id;
|
||||
bus->pci_subsystem_device = sbd_id;
|
||||
strncpy(bus->device_name, i["Description"].c_str(), sizeof bus->device_name);
|
||||
strncat(bus->device_name, " port 1", sizeof bus->device_name);
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Try to load Nuvoton (NCT6793) SMBus driver |
|
||||
\*-----------------------------------------------------*/
|
||||
if(i2c_smbus_pawnio::start_pawnio("SmbusNCT6793.bin", &pawnio_handle) == S_OK)
|
||||
{
|
||||
bus = new i2c_smbus_pawnio(pawnio_handle, "NCT6793");
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
@@ -62,6 +62,9 @@ std::string i2c_detect(i2c_smbus_interface * bus, int mode)
|
||||
case MODE_READ:
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
break;
|
||||
case MODE_READ_DATA:
|
||||
res = bus->i2c_smbus_read_byte_data(slave_addr, 0);
|
||||
break;
|
||||
default:
|
||||
if ((i + j >= 0x30 && i + j <= 0x37)
|
||||
|| (i + j >= 0x50 && i + j <= 0x5F))
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_READ_DATA 3
|
||||
#define MODE_FUNC 4
|
||||
|
||||
std::string i2c_detect(i2c_smbus_interface * bus, int mode);
|
||||
|
||||
|
||||
@@ -966,6 +966,7 @@
|
||||
|
||||
#define IF_MOBO_SMBUS(ven, dev) \
|
||||
if((ven == 0) || \
|
||||
((ven == 0xFFFF) && (dev == 0xFFFF)) || \
|
||||
((ven == AMD_VEN) && (dev == AMD_FCH_SMBUS_DEV)) || \
|
||||
((ven == INTEL_VEN) && (dev == INTEL_ICH10_SMBUS_DEV)) || \
|
||||
((ven == INTEL_VEN) && (dev == INTEL_SUNRISE_POINT_H_SMBUS_DEV)) || \
|
||||
|
||||
@@ -46,6 +46,7 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>&
|
||||
ui->SMBusDetectionModeBox->addItem("Auto");
|
||||
ui->SMBusDetectionModeBox->addItem("Quick");
|
||||
ui->SMBusDetectionModeBox->addItem("Read");
|
||||
ui->SMBusDetectionModeBox->addItem("Read Data");
|
||||
|
||||
ui->SMBusDetectionModeBox->setCurrentIndex(0);
|
||||
}
|
||||
@@ -104,6 +105,10 @@ void OpenRGBSystemInfoPage::on_DetectButton_clicked()
|
||||
case 2:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_READ).c_str());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_READ_DATA).c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user