mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-21 21:47:54 -05:00
Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions
This commit is contained in:
@@ -8,32 +8,23 @@
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "DetectionManager.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"
|
||||
#include "RGBController_SapphireNitroGlowV1.h"
|
||||
#include "RGBController_SapphireNitroGlowV3.h"
|
||||
#include "SapphireNitroGlowV1Controller.h"
|
||||
#include "SapphireNitroGlowV3Controller.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| I2C Addresses for Sapphire Nitro Glow RGB |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| I2C Addresses for Sapphire Nitro Glow RGB |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
SAPPHIRE_NITRO_GLOW_V1_ADDR = 0x55,
|
||||
SAPPHIRE_NITRO_GLOW_V3_ADDR = 0x28,
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForSapphireGPUController *
|
||||
* *
|
||||
* Tests the given address to see if an Sapphire controller exists there. First *
|
||||
* does a byte read to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
if(bus->pci_vendor == AMD_GPU_VEN && !is_amd_gpu_i2c_bus(bus))
|
||||
@@ -43,37 +34,37 @@ bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char addres
|
||||
|
||||
//Read a byte to test for presence
|
||||
return bus->i2c_smbus_read_byte(address) >= 0;
|
||||
} /* TestForSapphireGPUController() */
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSapphireGPUControllers *
|
||||
* *
|
||||
* Detect Sapphire GPU controllers on the enumerated I2C buses. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSapphireV1Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
|
||||
DetectedControllers DetectSapphireV1Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
|
||||
if(TestForSapphireGPUController(bus, i2c_addr))
|
||||
{
|
||||
SapphireNitroGlowV1Controller* new_sapphire_gpu = new SapphireNitroGlowV1Controller(bus, i2c_addr, name);
|
||||
RGBController_SapphireNitroGlowV1* new_controller = new RGBController_SapphireNitroGlowV1(new_sapphire_gpu);
|
||||
SapphireNitroGlowV1Controller* controller = new SapphireNitroGlowV1Controller(bus, i2c_addr, name);
|
||||
RGBController_SapphireNitroGlowV1* rgb_controller = new RGBController_SapphireNitroGlowV1(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(new_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectSapphireV1Controllers() */
|
||||
|
||||
void DetectSapphireV3Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
DetectedControllers DetectSapphireV3Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
|
||||
if(TestForSapphireGPUController(bus, i2c_addr))
|
||||
{
|
||||
SapphireNitroGlowV3Controller* new_sapphire_gpu = new SapphireNitroGlowV3Controller(bus, i2c_addr, name);
|
||||
RGBController_SapphireNitroGlowV3* new_controller = new RGBController_SapphireNitroGlowV3(new_sapphire_gpu);
|
||||
SapphireNitroGlowV3Controller* controller = new SapphireNitroGlowV3Controller(bus, i2c_addr, name);
|
||||
RGBController_SapphireNitroGlowV3* rgb_controller = new RGBController_SapphireNitroGlowV3(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(new_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectSapphireV3Controllers() */
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
REGISTER_I2C_PCI_DETECTOR("Sapphire Radeon RX 470/480 Nitro+", DetectSapphireV1Controllers, AMD_GPU_VEN, AMD_POLARIS_DEV, SAPPHIRE_LEGACY_SUB_VEN, SAPPHIRE_LEGACY_POLARIS_NITRO_PLUS_SUB_DEV, SAPPHIRE_NITRO_GLOW_V1_ADDR);
|
||||
REGISTER_I2C_PCI_DETECTOR("Sapphire Radeon RX 570/580/590 Nitro+", DetectSapphireV1Controllers, AMD_GPU_VEN, AMD_POLARIS_DEV, SAPPHIRE_SUB_VEN, SAPPHIRE_POLARIS_NITRO_PLUS_SUB_DEV1, SAPPHIRE_NITRO_GLOW_V1_ADDR);
|
||||
|
||||
Reference in New Issue
Block a user