Add ASUS RTX 3070 and 3090 GPUs to ENE controller

This commit is contained in:
Adam Honse 2021-11-18 20:53:57 +00:00
parent cd80fba82c
commit e27cc4d0af
6 changed files with 160 additions and 14 deletions

View file

@ -11,6 +11,7 @@
\*-----------------------------------------*/
#include "ENESMBusController.h"
#include "LogManager.h"
#include <cstring>
static const char* ene_channels[] = /* ENE channel strings */
@ -41,6 +42,34 @@ ENESMBusController::ENESMBusController(i2c_smbus_interface* bus, ene_dev_id dev)
config_table[i] = ENERegisterRead(ENE_REG_CONFIG_TABLE + i);
}
/*-----------------------------------------------------------------*\
| If this is running with TRACE or higher loglevel then |
| dump the entire Feature list to log |
\*-----------------------------------------------------------------*/
if(LogManager::get()->getLoglevel() >= LL_TRACE)
{
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[0], config_table[1], config_table[2], config_table[3],
config_table[4], config_table[5], config_table[6], config_table[7],
config_table[8], config_table[9], config_table[10], config_table[11],
config_table[12], config_table[13], config_table[14], config_table[15]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[16], config_table[17], config_table[18], config_table[19],
config_table[20], config_table[21], config_table[22], config_table[23],
config_table[24], config_table[25], config_table[26], config_table[27],
config_table[28], config_table[29], config_table[30], config_table[31]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[32], config_table[33], config_table[34], config_table[35],
config_table[36], config_table[37], config_table[38], config_table[39],
config_table[40], config_table[41], config_table[42], config_table[43],
config_table[44], config_table[45], config_table[46], config_table[47]);
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[48], config_table[49], config_table[50], config_table[51],
config_table[52], config_table[53], config_table[54], config_table[55],
config_table[56], config_table[57], config_table[58], config_table[59],
config_table[60], config_table[61], config_table[62], config_table[63]);
}
// Read LED count from configuration table
led_count = config_table[ENE_CONFIG_LED_COUNT];
@ -93,6 +122,16 @@ ENESMBusController::ENESMBusController(i2c_smbus_interface* bus, ene_dev_id dev)
effect_reg = ENE_REG_COLORS_EFFECT;
channel_cfg = ENE_CONFIG_CHANNEL_V1;
}
// AUMA0-E6K5-0107 - Second generation GPU controller
else if (strcmp(device_name, "AUMA0-E6K5-0107") == 0)
{
direct_reg = ENE_REG_COLORS_DIRECT_V2;
effect_reg = ENE_REG_COLORS_EFFECT_V2;
channel_cfg = ENE_CONFIG_CHANNEL_V2;
// Read LED count from configuration table
led_count = config_table[ENE_CONFIG_LED_COUNT_0107];
}
// Assume first generation controller if string does not match
else
{
@ -197,6 +236,21 @@ unsigned char ENESMBusController::GetLEDBlue(unsigned int led)
return(ENERegisterRead(direct_reg + ( 3 * led ) + 1));
}
unsigned char ENESMBusController::GetLEDRedEffect(unsigned int led)
{
return(ENERegisterRead(effect_reg + ( 3 * led )));
}
unsigned char ENESMBusController::GetLEDGreenEffect(unsigned int led)
{
return(ENERegisterRead(effect_reg + ( 3 * led ) + 2));
}
unsigned char ENESMBusController::GetLEDBlueEffect(unsigned int led)
{
return(ENERegisterRead(effect_reg + ( 3 * led ) + 1));
}
void ENESMBusController::SaveMode()
{
ENERegisterWrite(ENE_REG_APPLY, ENE_SAVE_VAL);

View file

@ -91,6 +91,7 @@ enum
enum
{
ENE_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
ENE_CONFIG_LED_COUNT_0107 = 0x03, /* LED Count configuration offset */
ENE_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
ENE_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
};
@ -109,6 +110,9 @@ public:
unsigned char GetLEDRed(unsigned int led);
unsigned char GetLEDGreen(unsigned int led);
unsigned char GetLEDBlue(unsigned int led);
unsigned char GetLEDRedEffect(unsigned int led);
unsigned char GetLEDGreenEffect(unsigned int led);
unsigned char GetLEDBlueEffect(unsigned int led);
void SaveMode();
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);

View file

@ -59,6 +59,29 @@ static const unsigned char aura_mobo_addresses[] =
0x4F
};
/*---------------------------------------------------------------------------------*\
| This list contains ASUS GPUs which use an ENE RGB controller |
\*---------------------------------------------------------------------------------*/
typedef struct
{
int pci_vendor;
int pci_device;
int pci_subsystem_vendor;
int pci_subsystem_device;
unsigned char controller_address;
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_RTX3070_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX_3070_OC, 0x67, "ASUS ROG STRIX 3070 OC" },
{ NVIDIA_VEN, NVIDIA_RTX3090_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX_3090_024G_GAMING, 0x67, "ASUS ROG STRIX 3090 024G GAMING" },
};
/******************************************************************************************\
* *
* ENERegisterRead *
@ -117,7 +140,7 @@ bool TestForENESMBusController(i2c_smbus_interface* bus, unsigned char address)
LOG_DEBUG("[ENE SMBus] looking for devices at 0x%02X...", address);
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
int res = bus->i2c_smbus_read_byte(address);
if (res >= 0)
{
@ -280,5 +303,48 @@ void DetectENESMBusMotherboardControllers(std::vector<i2c_smbus_interface*> &bus
}
} /* DetectENESMBusMotherboardControllers() */
/******************************************************************************************\
* *
* DetectENESMBusGPUControllers *
* *
* Detects ENE (ASUS Aura) SMBus controllers on ASUS GPU devices *
* *
\******************************************************************************************/
#define GPU_CHECK_DEVICE_MESSAGE_EN "[%s] Bus %02d is a GPU and the subvendor matches the one for %s, looking for a device at %02X"
void DetectENESMBusGPUControllers(std::vector<i2c_smbus_interface*> &busses)
{
for(unsigned int bus = 0; bus < busses.size(); bus++)
{
for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++)
{
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)
{
LOG_DEBUG(GPU_CHECK_DEVICE_MESSAGE_EN, DETECTOR_NAME, bus, VENDOR_NAME, device_list[dev_idx].controller_address);
if(TestForENESMBusController(busses[bus], device_list[dev_idx].controller_address))
{
ENESMBusController* controller = new ENESMBusController(busses[bus], device_list[dev_idx].controller_address);
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
rgb_controller->name = device_list[dev_idx].name;
rgb_controller->type = DEVICE_TYPE_GPU;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
LOG_DEBUG("[ENE SMBus ASUS GPU] Testing for controller at %d failed", device_list[dev_idx].controller_address);
}
}
}
}
} /* DetectENESMBusGPUControllers() */
REGISTER_I2C_DETECTOR("ENE SMBus DRAM", DetectENESMBusDRAMControllers);
REGISTER_I2C_DETECTOR("ASUS Aura SMBus Motherboard", DetectENESMBusMotherboardControllers);
REGISTER_I2C_DETECTOR("ASUS Aura GPU (ENE)", DetectENESMBusGPUControllers);

View file

@ -202,6 +202,32 @@ int RGBController_ENESMBus::GetDeviceMode()
}
}
/*---------------------------------------------------------*\
| Initialize colors for each LED |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
unsigned int led = leds[led_idx].value;
unsigned char red;
unsigned char grn;
unsigned char blu;
if(active_mode == 0)
{
red = controller->GetLEDRed(led);
grn = controller->GetLEDGreen(led);
blu = controller->GetLEDBlue(led);
}
else
{
red = controller->GetLEDRedEffect(led);
grn = controller->GetLEDGreenEffect(led);
blu = controller->GetLEDBlueEffect(led);
}
colors[led_idx] = ToRGBColor(red, grn, blu);
}
return(active_mode);
}
@ -358,19 +384,6 @@ void RGBController_ENESMBus::SetupZones()
}
SetupColors();
/*---------------------------------------------------------*\
| Initialize colors for each LED |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
unsigned int led = leds[led_idx].value;
unsigned char red = controller->GetLEDRed(led);
unsigned char grn = controller->GetLEDGreen(led);
unsigned char blu = controller->GetLEDBlue(led);
colors[led_idx] = ToRGBColor(red, grn, blu);
}
}
void RGBController_ENESMBus::ResizeZone(int /*zone*/, int /*new_size*/)

View file

@ -65,6 +65,12 @@ s32 i2c_smbus_nvapi::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int mo
i2c_data.size = 2;
break;
case I2C_SMBUS_BLOCK_DATA:
data_buf[0] = data->block[0];
memcpy(&data_buf[1], &(data->block[1]), data->block[0]);
i2c_data.size = data->block[0] + 1;
break;
case I2C_SMBUS_I2C_BLOCK_DATA:
memcpy(&data_buf[0], &(data->block[1]), data->block[0]);
i2c_data.size = data->block[0];
@ -99,6 +105,7 @@ s32 i2c_smbus_nvapi::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int mo
data->word = (i2c_data.data[0] | (i2c_data.data[1] << 8));
break;
case I2C_SMBUS_BLOCK_DATA:
case I2C_SMBUS_I2C_BLOCK_DATA:
data->block[0] = i2c_data.size;
memcpy( &(data->block[1]), i2c_data.data, i2c_data.size);

View file

@ -133,6 +133,8 @@
#define ASUS_RX570_STRIX_O4G_GAMING_OC 0x04C2
#define ASUS_RX580_STRIX_GAMING_OC 0x0517
#define ASUS_RX580_STRIX_GAMING_TOP 0x0519
#define ASUS_ROG_STRIX_RTX_3070_OC 0x87B8
#define ASUS_ROG_STRIX_RTX_3090_024G_GAMING 0x87AF
/*-----------------------------------------------------*\
| EVGA Sub-Device IDs |