Update Gainward GPU controller to use I2C PCI detector
This commit is contained in:
parent
4f52ffd480
commit
b780c440e7
1 changed files with 42 additions and 77 deletions
|
|
@ -19,34 +19,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_V1,
|
||||
RGB_V2,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pci_vendor;
|
||||
int pci_device;
|
||||
int pci_subsystem_vendor;
|
||||
int pci_subsystem_device;
|
||||
int gpu_rgb_version;
|
||||
const char * name;
|
||||
} gpu_pci_device;
|
||||
|
||||
#define GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const gpu_pci_device device_list[] =
|
||||
{
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, GAINWARD_SUB_VEN, GAINWARD_GTX_1080_PHOENIX, RGB_V1, "Gainward GTX 1080 Phoenix" },
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, GAINWARD_SUB_VEN, GAINWARD_GTX_1080_TI_PHOENIX, RGB_V1, "Gainward GTX 1080 Ti Phoenix" },
|
||||
{ NVIDIA_VEN, NVIDIA_RTX2070S_OC_DEV, GAINWARD_SUB_VEN, NVIDIA_RTX2070S_OC_DEV, RGB_V2, "Gainward RTX 2070 Super Phantom" },
|
||||
{ NVIDIA_VEN, NVIDIA_RTX3070_DEV, GAINWARD_SUB_VEN, NVIDIA_RTX3070_DEV, RGB_V2, "Gainward RTX 3070 Phoenix" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForGainwardGPUController *
|
||||
|
|
@ -55,23 +27,29 @@ static const gpu_pci_device device_list[] =
|
|||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForGainwardGPUController(i2c_smbus_interface* bus, int gpu_rgb_version)
|
||||
bool TestForGainwardGPUController(i2c_smbus_interface* bus, uint8_t i2c_addr)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
switch (gpu_rgb_version)
|
||||
switch(i2c_addr)
|
||||
{
|
||||
case RGB_V1:
|
||||
pass = bus->i2c_smbus_write_quick(0x08, I2C_SMBUS_WRITE);
|
||||
/*-----------------------------------------------------------------*\
|
||||
| V1 Controller |
|
||||
\*-----------------------------------------------------------------*/
|
||||
case 0x08:
|
||||
pass = bus->i2c_smbus_write_quick(i2c_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
|
||||
case RGB_V2:
|
||||
/*-----------------------------------------------------------------*\
|
||||
| V2 Controller |
|
||||
\*-----------------------------------------------------------------*/
|
||||
case 0x49:
|
||||
/*-------------------------------------------------------------*\
|
||||
| This detection might need some modifications |
|
||||
| Reading 0x6F*0x73 and comparing to 0x64 might be a possibility|
|
||||
\*-------------------------------------------------------------*/
|
||||
s32 data = bus->i2c_smbus_read_byte_data(0x49, 0x0);
|
||||
s32 mode_data = bus->i2c_smbus_read_byte_data(0x49, 0xe0);
|
||||
s32 data = bus->i2c_smbus_read_byte_data(i2c_addr, 0x0);
|
||||
s32 mode_data = bus->i2c_smbus_read_byte_data(i2c_addr, 0xe0);
|
||||
pass = (data == 0x0) && (mode_data < 0x5);
|
||||
break;
|
||||
}
|
||||
|
|
@ -89,55 +67,42 @@ bool TestForGainwardGPUController(i2c_smbus_interface* bus, int gpu_rgb_version)
|
|||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectGainwardGPUControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
void DetectGainwardGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
|
||||
{
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
if(TestForGainwardGPUController(bus, i2c_addr))
|
||||
{
|
||||
/*-------------------------------------*\
|
||||
| Check for Gainward controller at 0x08 |
|
||||
\*-------------------------------------*/
|
||||
for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++)
|
||||
switch(i2c_addr)
|
||||
{
|
||||
if(busses[bus]->pci_vendor == device_list[dev_idx].pci_vendor &&
|
||||
busses[bus]->pci_device == device_list[dev_idx].pci_device &&
|
||||
busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor &&
|
||||
busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device)
|
||||
{
|
||||
|
||||
if (TestForGainwardGPUController(busses[bus], device_list[dev_idx].gpu_rgb_version))
|
||||
/*-----------------------------------------------------------------*\
|
||||
| V1 Controller |
|
||||
\*-----------------------------------------------------------------*/
|
||||
case 0x08:
|
||||
{
|
||||
switch(device_list[dev_idx].gpu_rgb_version)
|
||||
{
|
||||
case RGB_V1:
|
||||
{
|
||||
LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v1", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name );
|
||||
GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(bus, i2c_addr);
|
||||
RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(busses[bus], 0x08);
|
||||
RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller);
|
||||
rgb_controller->name = device_list[dev_idx].name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case RGB_V2:
|
||||
{
|
||||
LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v2", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name );
|
||||
|
||||
GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(busses[bus], 0x49);
|
||||
RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller);
|
||||
rgb_controller->name = device_list[dev_idx].name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
}
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| V2 Controller |
|
||||
\*-----------------------------------------------------------------*/
|
||||
case 0x49:
|
||||
{
|
||||
GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(bus, i2c_addr);
|
||||
RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectGainwardGPUControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("Gainward GPU", DetectGainwardGPUControllers);
|
||||
REGISTER_I2C_PCI_DETECTOR("Gainward GTX 1080 Phoenix" , DetectGainwardGPUControllers, NVIDIA_VEN, NVIDIA_GTX1080_DEV, GAINWARD_SUB_VEN, GAINWARD_GTX_1080_PHOENIX, 0x08);
|
||||
REGISTER_I2C_PCI_DETECTOR("Gainward GTX 1080 Ti Phoenix" , DetectGainwardGPUControllers, NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, GAINWARD_SUB_VEN, GAINWARD_GTX_1080_TI_PHOENIX, 0x08);
|
||||
REGISTER_I2C_PCI_DETECTOR("Gainward RTX 2070 Super Phantom", DetectGainwardGPUControllers, NVIDIA_VEN, NVIDIA_RTX2070S_OC_DEV, GAINWARD_SUB_VEN, NVIDIA_RTX2070S_OC_DEV, 0x49);
|
||||
REGISTER_I2C_PCI_DETECTOR("Gainward RTX 3070 Phoenix" , DetectGainwardGPUControllers, NVIDIA_VEN, NVIDIA_RTX3070_DEV, GAINWARD_SUB_VEN, NVIDIA_RTX3070_DEV, 0x49);
|
||||
Loading…
Add table
Add a link
Reference in a new issue