Do not automatically save after each change on Asus Aura GPUs.

This commit is contained in:
karliss1 2023-12-25 18:50:50 +00:00 committed by Adam Honse
parent b05f954d35
commit f8a837f106
4 changed files with 59 additions and 32 deletions

View file

@ -7,6 +7,7 @@
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "AsusAuraGPUController.h" #include "AsusAuraGPUController.h"
#include "pci_ids.h"
#include <cstring> #include <cstring>
AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev) AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev)
@ -52,25 +53,16 @@ unsigned char AuraGPUController::GetLEDBlue()
return(AuraGPURegisterRead(AURA_GPU_REG_BLUE)); return(AuraGPURegisterRead(AURA_GPU_REG_BLUE));
} }
void AuraGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes void AuraGPUController::SetLEDColors(unsigned char red, unsigned char green, unsigned char blue)
{ {
AuraGPURegisterWrite(AURA_GPU_REG_RED, red); AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green); AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue); AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
} }
void AuraGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}
void AuraGPUController::SetMode(unsigned char mode) void AuraGPUController::SetMode(unsigned char mode)
{ {
AuraGPURegisterWrite(AURA_GPU_REG_MODE, mode); AuraGPURegisterWrite(AURA_GPU_REG_MODE, mode);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
} }
unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg) unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg)
@ -81,4 +73,21 @@ unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg)
void AuraGPUController::AuraGPURegisterWrite(unsigned char reg, unsigned char val) void AuraGPUController::AuraGPURegisterWrite(unsigned char reg, unsigned char val)
{ {
bus->i2c_smbus_write_byte_data(dev, reg, val); bus->i2c_smbus_write_byte_data(dev, reg, val);
} }
bool AuraGPUController::SaveOnlyApplies()
{
switch (bus->pci_subsystem_device)
{
case ASUS_VEGA64_STRIX:
return false;
}
// Behavior on other GPU models is unknown and needs to be tested.
// Assume the safest option to prevent damaage from excessive writes.
return false;
}
void AuraGPUController::Save()
{
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}

View file

@ -23,7 +23,7 @@ enum
AURA_GPU_REG_BLUE = 0x06, /* AURA GPU BLUE Register */ AURA_GPU_REG_BLUE = 0x06, /* AURA GPU BLUE Register */
AURA_GPU_REG_MODE = 0x07, /* AURA GPU Mode Selection Register */ AURA_GPU_REG_MODE = 0x07, /* AURA GPU Mode Selection Register */
AURA_GPU_REG_SYNC = 0x0C, /* AURA GPU "Sync" Register */ AURA_GPU_REG_SYNC = 0x0C, /* AURA GPU "Sync" Register */
AURA_GPU_REG_APPLY = 0x0E, /* AURA GPU Apply Chnages Register */ AURA_GPU_REG_APPLY = 0x0E, /* AURA GPU Save or Apply Register */
}; };
enum enum
@ -48,17 +48,18 @@ public:
unsigned char GetLEDRed(); unsigned char GetLEDRed();
unsigned char GetLEDGreen(); unsigned char GetLEDGreen();
unsigned char GetLEDBlue(); unsigned char GetLEDBlue();
void SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue); void SetLEDColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode); void SetMode(unsigned char mode);
void Save();
unsigned char AuraGPURegisterRead(unsigned char reg); unsigned char AuraGPURegisterRead(unsigned char reg);
void AuraGPURegisterWrite(unsigned char reg, unsigned char val); void AuraGPURegisterWrite(unsigned char reg, unsigned char val);
bool SaveOnlyApplies();
bool direct = false; // Temporary solution to check if we are in "Direct" mode bool direct = false; // Temporary solution to check if we are in "Direct" mode
private: private:
char device_name[16]; char device_name[16];
i2c_smbus_interface * bus; i2c_smbus_interface * bus;
aura_gpu_dev_id dev; aura_gpu_dev_id dev;
}; };

View file

@ -45,11 +45,15 @@ int RGBController_AuraGPU::GetDeviceMode()
@name Asus Aura GPU @name Asus Aura GPU
@category GPU @category GPU
@type SMBus @type SMBus
@save :x: @save :tools:
@direct :white_check_mark: @direct :white_check_mark:
@effects :white_check_mark: @effects :white_check_mark:
@detectors DetectAsusAuraGPUControllers @detectors DetectAsusAuraGPUControllers
@comment @comment On some models save command might function like apply.
Known models with correctly working save: ASUS Vega 64 Strix.
This may result in changes not applying until user clicks
"save to device". Contact OpenRGB developers if you have one
of the affected models.
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr) RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr)
@ -69,38 +73,44 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr)
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
unsigned int save_flags = 0;
if(!controller->SaveOnlyApplies())
{
save_flags |= MODE_FLAG_MANUAL_SAVE;
}
mode Off; mode Off;
Off.name = "Off"; Off.name = "Off";
Off.value = AURA_GPU_MODE_OFF; Off.value = AURA_GPU_MODE_OFF;
Off.flags = 0; Off.flags = save_flags;
Off.color_mode = MODE_COLORS_NONE; Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off); modes.push_back(Off);
mode Static; mode Static;
Static.name = "Static"; Static.name = "Static";
Static.value = AURA_GPU_MODE_STATIC; Static.value = AURA_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | save_flags;
Static.color_mode = MODE_COLORS_PER_LED; Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static); modes.push_back(Static);
mode Breathing; mode Breathing;
Breathing.name = "Breathing"; Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING; Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR; Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | save_flags;
Breathing.color_mode = MODE_COLORS_PER_LED; Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing); modes.push_back(Breathing);
mode Flashing; mode Flashing;
Flashing.name = "Flashing"; Flashing.name = "Flashing";
Flashing.value = AURA_GPU_MODE_FLASHING; Flashing.value = AURA_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR; Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | save_flags;
Flashing.color_mode = MODE_COLORS_PER_LED; Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing); modes.push_back(Flashing);
mode Spectrum_Cycle; mode Spectrum_Cycle;
Spectrum_Cycle.name = "Spectrum Cycle"; Spectrum_Cycle.name = "Spectrum Cycle";
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE; Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE ;
Spectrum_Cycle.flags = 0; Spectrum_Cycle.flags = save_flags;
Spectrum_Cycle.color_mode = MODE_COLORS_NONE; Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle); modes.push_back(Spectrum_Cycle);
@ -162,14 +172,11 @@ void RGBController_AuraGPU::DeviceUpdateLEDs()
unsigned char grn = RGBGetGValue(colors[led]); unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]); unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0) controller->SetLEDColors(red, grn, blu);
{ }
controller->SetLEDColorsDirect(red, grn, blu); if (controller->SaveOnlyApplies() && GetMode() != 0)
} {
else controller->Save();
{
controller->SetLEDColorsEffect(red, grn, blu);
}
} }
} }
@ -192,7 +199,7 @@ void RGBController_AuraGPU::DeviceUpdateMode()
{ {
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode // Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
case AURA_GPU_MODE_OFF: case AURA_GPU_MODE_OFF:
controller->SetLEDColorsEffect(0, 0, 0); controller->SetLEDColors(0, 0, 0);
new_mode = AURA_GPU_MODE_STATIC; new_mode = AURA_GPU_MODE_STATIC;
break; break;
@ -204,4 +211,13 @@ void RGBController_AuraGPU::DeviceUpdateMode()
} }
controller->SetMode(new_mode); controller->SetMode(new_mode);
if (controller->SaveOnlyApplies())
{
controller->Save();
}
}
void RGBController_AuraGPU::DeviceSaveMode()
{
controller->Save();
} }

View file

@ -26,6 +26,7 @@ public:
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void DeviceUpdateMode(); void DeviceUpdateMode();
void DeviceSaveMode();
private: private:
AuraGPUController* controller; AuraGPUController* controller;