Properly detect I2C initialization fail on Linux and fix dialog always being displayed even when I2C initialization was successful
This commit is contained in:
parent
de4231f3ea
commit
c74a9849c0
2 changed files with 23 additions and 9 deletions
|
|
@ -1108,17 +1108,20 @@ void ResourceManager::DetectDevicesThreadFunction()
|
|||
| If any i2c interfaces failed to detect due to an |
|
||||
| error condition, show a dialog |
|
||||
\*-------------------------------------------------*/
|
||||
LOG_DIALOG("One or more I2C/SMBus interfaces failed to initialize.\r"
|
||||
if(i2c_interface_fail)
|
||||
{
|
||||
LOG_DIALOG("One or more I2C/SMBus interfaces failed to initialize.\r"
|
||||
#ifdef _WIN32
|
||||
"On Windows, this is usually caused by a failure to load the inpout32 driver.\r"
|
||||
"You must run OpenRGB as administrator at least once to allow inpout32 to set up.\r"
|
||||
"On Windows, this is usually caused by a failure to load the inpout32 driver.\r"
|
||||
"You must run OpenRGB as administrator at least once to allow inpout32 to set up.\r"
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
"On Linux, this is usually because the i2c-dev module is not loaded.\r"
|
||||
"You must load the i2c-dev module along with the correct i2c driver for your motherboard.\r"
|
||||
"This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.\r"
|
||||
"On Linux, this is usually because the i2c-dev module is not loaded.\r"
|
||||
"You must load the i2c-dev module along with the correct i2c driver for your motherboard.\r"
|
||||
"This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.\r"
|
||||
#endif
|
||||
"See https://help.openrgb.org for additional troubleshooting.");
|
||||
"See https://help.openrgb.org for additional troubleshooting.");
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceManager::StopDeviceDetection()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ bool i2c_smbus_linux_detect()
|
|||
char driver_path[512];
|
||||
struct dirent * ent;
|
||||
int test_fd;
|
||||
int ret = true;
|
||||
char path[1024];
|
||||
char buff[100];
|
||||
unsigned short pci_device, pci_vendor, pci_subsystem_device, pci_subsystem_vendor;
|
||||
|
|
@ -58,6 +59,12 @@ bool i2c_smbus_linux_detect()
|
|||
|
||||
// Loop through all entries in i2c-adapter list
|
||||
ent = readdir(dir);
|
||||
|
||||
if(ent == NULL)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(ent != NULL)
|
||||
{
|
||||
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
|
||||
|
|
@ -142,7 +149,7 @@ bool i2c_smbus_linux_detect()
|
|||
if (test_fd < 0)
|
||||
{
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
bus = new i2c_smbus_linux();
|
||||
|
|
@ -155,13 +162,17 @@ bool i2c_smbus_linux_detect()
|
|||
bus->port_id = port_id;
|
||||
ResourceManager::get()->RegisterI2CBus(bus);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ent = readdir(dir);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return(true);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
REGISTER_I2C_BUS_DETECTOR(i2c_smbus_linux_detect);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue