Move correct i2c bus detection for AMD GPUs to separate header file

This commit is contained in:
Michal Malý
2025-08-06 23:16:20 +02:00
parent f5fc3ff450
commit 4e0c09efd4
2 changed files with 40 additions and 24 deletions

View File

@@ -7,12 +7,12 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "Detector.h"
#include "SapphireNitroGlowV1Controller.h"
#include "SapphireNitroGlowV3Controller.h"
#include "RGBController_SapphireNitroGlowV1.h"
#include "RGBController_SapphireNitroGlowV3.h"
#include "i2c_amd_gpu.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
@@ -34,31 +34,9 @@ enum
* *
\******************************************************************************************/
static const char * RECOGNIZED_I2C_BUS_NAMES[] = {
"AMD ADL",
"AMDGPU DM i2c OEM bus",
nullptr
};
bool IsRecognizedI2CBus(i2c_smbus_interface* bus)
{
size_t idx = 0;
const char *name;
while((name = RECOGNIZED_I2C_BUS_NAMES[idx++]) != nullptr)
{
if(std::strcmp(name, bus->device_name) == 0)
{
return true;
}
}
return false;
}
bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char address)
{
if (!IsRecognizedI2CBus(bus))
if(bus->pci_vendor == AMD_GPU_VEN && !is_amd_gpu_i2c_bus(bus))
{
return false;
}