mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-23 23:37:48 -05:00
Check for bus name when looking for Sapphire GPU RGB controls
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "Detector.h"
|
||||
#include "SapphireNitroGlowV1Controller.h"
|
||||
#include "SapphireNitroGlowV3Controller.h"
|
||||
@@ -33,21 +34,34 @@ enum
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
static const char * RECOGNIZED_I2C_BUS_NAMES[] = {
|
||||
"AMD ADL",
|
||||
"AMDGPU DM i2c OEM bus",
|
||||
nullptr
|
||||
};
|
||||
|
||||
bool IsRecognizedI2CBus(i2c_smbus_interface* bus)
|
||||
{
|
||||
bool pass = false;
|
||||
int res;
|
||||
size_t idx = 0;
|
||||
|
||||
//Read a byte to test for presence
|
||||
res = bus->i2c_smbus_read_byte(address);
|
||||
|
||||
if (res >= 0)
|
||||
const char *name;
|
||||
while((name = RECOGNIZED_I2C_BUS_NAMES[idx++]) != nullptr)
|
||||
{
|
||||
pass = true;
|
||||
if (std::strcmp(name, bus->bus_name) == 0) return true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
if (!IsRecognizedI2CBus(bus))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Read a byte to test for presence
|
||||
return bus->i2c_smbus_read_byte(address) >= 0;
|
||||
} /* TestForSapphireGPUController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
|
||||
@@ -74,6 +74,7 @@ bool i2c_smbus_linux_detect()
|
||||
{
|
||||
i2c_smbus_linux * bus;
|
||||
char device_string[1024];
|
||||
char device_path[1024];
|
||||
DIR * dir;
|
||||
char driver_path[512];
|
||||
struct dirent * ent;
|
||||
@@ -109,6 +110,7 @@ bool i2c_smbus_linux_detect()
|
||||
if(test_fd)
|
||||
{
|
||||
memset(device_string, 0x00, sizeof(device_string));
|
||||
memset(device_path, 0x00, sizeof(device_string));
|
||||
|
||||
if(read(test_fd, device_string, sizeof(device_string)) < 0)
|
||||
{
|
||||
@@ -220,9 +222,9 @@ bool i2c_smbus_linux_detect()
|
||||
close(test_fd);
|
||||
}
|
||||
|
||||
strcpy(device_string, "/dev/");
|
||||
strcat(device_string, ent->d_name);
|
||||
test_fd = open(device_string, O_RDWR);
|
||||
strcpy(device_path, "/dev/");
|
||||
strcat(device_path, ent->d_name);
|
||||
test_fd = open(device_path, O_RDWR);
|
||||
|
||||
if (test_fd < 0)
|
||||
{
|
||||
@@ -230,7 +232,8 @@ bool i2c_smbus_linux_detect()
|
||||
}
|
||||
|
||||
bus = new i2c_smbus_linux();
|
||||
strcpy(bus->device_name, device_string);
|
||||
strcpy(bus->device_name, device_path);
|
||||
strcpy(bus->bus_name, device_string);
|
||||
bus->handle = test_fd;
|
||||
bus->pci_device = pci_device;
|
||||
bus->pci_vendor = pci_vendor;
|
||||
|
||||
@@ -130,6 +130,7 @@ i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context, int adapter_index
|
||||
this->pci_subsystem_device = sbd_id;
|
||||
this->port_id = 1;
|
||||
strcpy(this->device_name, "AMD ADL");
|
||||
strcpy(this->bus_name, "AMD ADL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class i2c_smbus_interface
|
||||
{
|
||||
public:
|
||||
char device_name[512];
|
||||
char bus_name[512];
|
||||
|
||||
int port_id;
|
||||
int pci_device;
|
||||
|
||||
Reference in New Issue
Block a user