Add support for MSI RTX 2080S Gaming X Trio
This commit is contained in:
parent
b80cbe931e
commit
224f59450e
9 changed files with 671 additions and 4 deletions
74
Controllers/MSIGPUController/MSIGPUController.cpp
Normal file
74
Controllers/MSIGPUController/MSIGPUController.cpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*-----------------------------------------*\
|
||||
| MSIGPUController.cpp |
|
||||
| |
|
||||
| Driver for MSI GPUs |
|
||||
| |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "MSIGPUController.h"
|
||||
#include <cstring>
|
||||
|
||||
MSIGPUController::MSIGPUController(i2c_smbus_interface* bus)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = 0x68;
|
||||
|
||||
strcpy(device_name, "MSI RTX GPU");
|
||||
}
|
||||
|
||||
MSIGPUController::~MSIGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string MSIGPUController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string MSIGPUController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void MSIGPUController::SetRGB1(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_R1, red);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_G1, green);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_B1, blue);
|
||||
}
|
||||
|
||||
void MSIGPUController::SetRGB2(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_R2, red);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_G2, green);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_B2, blue);
|
||||
}
|
||||
|
||||
void MSIGPUController::SetRGB3(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_R3, red);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_G3, green);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_B3, blue);
|
||||
}
|
||||
|
||||
void MSIGPUController::SetMode(unsigned char mode)
|
||||
{
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_MODE, mode);
|
||||
MSIGPURegisterWrite(MSI_GPU_REG_APPLY, 0x01);
|
||||
}
|
||||
|
||||
unsigned char MSIGPUController::MSIGPURegisterRead(unsigned char reg)
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, reg));
|
||||
}
|
||||
|
||||
void MSIGPUController::MSIGPURegisterWrite(unsigned char reg, unsigned char val)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, reg, val);
|
||||
}
|
||||
79
Controllers/MSIGPUController/MSIGPUController.h
Normal file
79
Controllers/MSIGPUController/MSIGPUController.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*-----------------------------------------*\
|
||||
| MSIGPUController.h |
|
||||
| |
|
||||
| Definitions for MSI GPUs |
|
||||
| |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char msi_gpu_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
MSI_GPU_REG_BRIGHTNESS = 0x36, /* MSI GPU Brightness Register */
|
||||
MSI_GPU_REG_SPEED = 0x38, /* MSI GPU Speed Register */
|
||||
MSI_GPU_REG_UNKNOWN = 0x26, /* MSI GPU Unknown Register */
|
||||
MSI_GPU_REG_R1 = 0x30, /* MSI GPU R1 Register */
|
||||
MSI_GPU_REG_G1 = 0x31, /* MSI GPU G1 Register */
|
||||
MSI_GPU_REG_B1 = 0x32, /* MSI GPU B1 Register */
|
||||
MSI_GPU_REG_R2 = 0x27, /* MSI GPU R2 Register */
|
||||
MSI_GPU_REG_G2 = 0x28, /* MSI GPU G2 Register */
|
||||
MSI_GPU_REG_B2 = 0x29, /* MSI GPU B2 Register */
|
||||
MSI_GPU_REG_R3 = 0x2a, /* MSI GPU R3 Register */
|
||||
MSI_GPU_REG_G3 = 0x2b, /* MSI GPU G3 Register */
|
||||
MSI_GPU_REG_B3 = 0x2c, /* MSI GPU B3 Register */
|
||||
MSI_GPU_REG_MODE = 0x22, /* MSI GPU Mode Selection Register */
|
||||
MSI_GPU_REG_APPLY = 0x3f, /* MSI GPU Apply Changes Register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MSI_GPU_MODE_OFF = 0x01, /* OFF mode */
|
||||
MSI_GPU_MODE_RAINBOW = 0x08, /* Rainbow effect mode */
|
||||
MSI_GPU_MODE_STATIC = 0x13, /* Static color mode */
|
||||
MSI_GPU_MODE_RAINDROP = 0x1a, /* Raindrop effect mode */
|
||||
MSI_GPU_MODE_MAGIC = 0x07, /* Magic effect mode */
|
||||
MSI_GPU_MODE_PATROLLING = 0x05, /* Patrolling effect mode */
|
||||
MSI_GPU_MODE_STREAMING = 0x06, /* Streaming effect mode */
|
||||
MSI_GPU_MODE_LIGHTNING = 0x15, /* Lightning effect mode */
|
||||
MSI_GPU_MODE_WAVE = 0x1f, /* Wave effect mode */
|
||||
MSI_GPU_MODE_METEOR = 0x16, /* Meteor effect mode */
|
||||
MSI_GPU_MODE_STACK = 0x0d, /* Stack effect mode */
|
||||
MSI_GPU_MODE_RHYTHM = 0x0b, /* Rhythm effect mode */
|
||||
MSI_GPU_MODE_FLOWING = 0x09, /* Flowing effect mode */
|
||||
MSI_GPU_MODE_WHIRLING = 0x0f, /* Whirling effect mode */
|
||||
MSI_GPU_MODE_TWISTING = 0x11, /* Twisting effect mode */
|
||||
MSI_GPU_MODE_LAMINATING = 0x1d, /* Laminating effect mode */
|
||||
MSI_GPU_MODE_FADEIN = 0x14, /* Fadein effect mode */
|
||||
MSI_GPU_MODE_BREATHING = 0x04, /* Breathing effect mode */
|
||||
MSI_GPU_MODE_FLASHING = 0x02, /* Flashing effect mode */
|
||||
MSI_GPU_MODE_DOUBLEFLASHING = 0x03, /* Doubleflashing effect mode */
|
||||
};
|
||||
|
||||
class MSIGPUController
|
||||
{
|
||||
public:
|
||||
MSIGPUController(i2c_smbus_interface* bus);
|
||||
~MSIGPUController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
void SetRGB1(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetRGB2(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetRGB3(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
unsigned char MSIGPURegisterRead(unsigned char reg);
|
||||
void MSIGPURegisterWrite(unsigned char reg, unsigned char val);
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
i2c_smbus_interface * bus;
|
||||
msi_gpu_dev_id dev;
|
||||
};
|
||||
73
Controllers/MSIGPUController/MSIGPUControllerDetect.cpp
Normal file
73
Controllers/MSIGPUController/MSIGPUControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*-----------------------------------------*\
|
||||
| MSIGPUControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for MSI GPUs |
|
||||
| |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "MSIGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_MSIGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* IsMSIGPUController *
|
||||
* *
|
||||
* Compare PCI IDs *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool IsMSIGPUController(i2c_smbus_interface* bus)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
if (bus->port_id != 1)
|
||||
return(pass);
|
||||
|
||||
// MSI RTX 2080S Gaming X Trio
|
||||
if (bus->pci_device == 0x1e81 &&
|
||||
bus->pci_vendor == 0x10de &&
|
||||
bus->pci_subsystem_device == 0xc724 &&
|
||||
bus->pci_subsystem_vendor == 0x1462) {
|
||||
pass = true;
|
||||
}
|
||||
|
||||
// MSI RTX 2070S Gaming X Trio
|
||||
if (bus->pci_device == 0x1e84 &&
|
||||
bus->pci_vendor == 0x10de &&
|
||||
bus->pci_subsystem_device == 0xc726 &&
|
||||
bus->pci_subsystem_vendor == 0x1462) {
|
||||
pass = true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
} /* IsMSIGPUController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectMSIGPUControllers *
|
||||
* *
|
||||
* Detect MSI GPU controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectMSIGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
MSIGPUController* new_msi_gpu;
|
||||
RGBController_MSIGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
if (IsMSIGPUController(busses[bus]))
|
||||
{
|
||||
new_msi_gpu = new MSIGPUController(busses[bus]);
|
||||
new_controller = new RGBController_MSIGPU(new_msi_gpu);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectMSIGPUControllers() */
|
||||
82
OpenRGB.cpp
82
OpenRGB.cpp
|
|
@ -260,6 +260,11 @@ void DetectI2CBusses()
|
|||
char driver_path[512];
|
||||
struct dirent * ent;
|
||||
int test_fd;
|
||||
char path[1024];
|
||||
char buff[100];
|
||||
unsigned short pci_device, pci_vendor, pci_subsystem_device, pci_subsystem_vendor;
|
||||
unsigned short port_id;
|
||||
bool info;
|
||||
|
||||
// Start looking for I2C adapters in /sys/bus/i2c/devices/
|
||||
strcpy(driver_path, "/sys/bus/i2c/devices/");
|
||||
|
|
@ -291,6 +296,74 @@ void DetectI2CBusses()
|
|||
|
||||
close(test_fd);
|
||||
|
||||
// For now, only get PCI information from nVidia GPUs
|
||||
// PCI IDs are not currently obtained from the Nouveau driver
|
||||
// and GPUs using PCI IDs for detection will not work with it.
|
||||
if (sscanf(device_string, "NVIDIA i2c adapter %hu at", &port_id) == 1)
|
||||
{
|
||||
info = true;
|
||||
|
||||
// Get PCI Device
|
||||
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/device");
|
||||
test_fd = open(path, O_RDONLY);
|
||||
if (test_fd < 0)
|
||||
{
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
memset(buff, 0x00, sizeof(buff));
|
||||
read(test_fd, buff, sizeof(buff));
|
||||
buff[strlen(buff) - 1] = 0x00;
|
||||
pci_device = strtoul(buff, NULL, 16);
|
||||
close(test_fd);
|
||||
|
||||
// Get PCI Vendor
|
||||
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/vendor");
|
||||
test_fd = open(path, O_RDONLY);
|
||||
if (test_fd < 0)
|
||||
{
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
memset(buff, 0x00, sizeof(buff));
|
||||
read(test_fd, buff, sizeof(buff));
|
||||
buff[strlen(buff) - 1] = 0x00;
|
||||
pci_vendor = strtoul(buff, NULL, 16);
|
||||
close(test_fd);
|
||||
|
||||
// Get PCI Subsystem Device
|
||||
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/subsystem_device");
|
||||
test_fd = open(path, O_RDONLY);
|
||||
if (test_fd < 0)
|
||||
{
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
memset(buff, 0x00, sizeof(buff));
|
||||
read(test_fd, buff, sizeof(buff));
|
||||
buff[strlen(buff) - 1] = 0x00;
|
||||
pci_subsystem_device = strtoul(buff, NULL, 16);
|
||||
close(test_fd);
|
||||
|
||||
// Get PCI Subsystem Vendor
|
||||
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/subsystem_vendor");
|
||||
test_fd = open(path, O_RDONLY);
|
||||
if (test_fd < 0)
|
||||
{
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
memset(buff, 0x00, sizeof(buff));
|
||||
read(test_fd, buff, sizeof(buff));
|
||||
buff[strlen(buff) - 1] = 0x00;
|
||||
pci_subsystem_vendor = strtoul(buff, NULL, 16);
|
||||
close(test_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
info = false;
|
||||
}
|
||||
|
||||
strcpy(device_string, "/dev/");
|
||||
strcat(device_string, ent->d_name);
|
||||
test_fd = open(device_string, O_RDWR);
|
||||
|
|
@ -304,6 +377,13 @@ void DetectI2CBusses()
|
|||
bus = new i2c_smbus_linux();
|
||||
strcpy(bus->device_name, device_string);
|
||||
bus->handle = test_fd;
|
||||
if (info) {
|
||||
bus->pci_device = pci_device;
|
||||
bus->pci_vendor = pci_vendor;
|
||||
bus->pci_subsystem_device = pci_subsystem_device;
|
||||
bus->pci_subsystem_vendor = pci_subsystem_vendor;
|
||||
bus->port_id = port_id;
|
||||
}
|
||||
busses.push_back(bus);
|
||||
}
|
||||
}
|
||||
|
|
@ -327,6 +407,7 @@ void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::
|
|||
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2DRAMControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSIGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
|
@ -374,6 +455,7 @@ void DetectRGBControllers(void)
|
|||
DetectPatriotViperControllers(busses, rgb_controllers);
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionGPUControllers(busses, rgb_controllers);
|
||||
DetectMSIGPUControllers(busses, rgb_controllers);
|
||||
|
||||
//TODO: Implement better detection before enabling these controllers
|
||||
//DetectRGBFusion2SMBusControllers(busses, rgb_controllers);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ INCLUDEPATH += \
|
|||
Controllers/LEDStripController/ \
|
||||
Controllers/LogitechController/ \
|
||||
Controllers/MSI3ZoneController/ \
|
||||
Controllers/MSIGPUController/ \
|
||||
Controllers/MSIMysticLightController/ \
|
||||
Controllers/MSIRGBController/ \
|
||||
Controllers/NZXTHue2Controller/ \
|
||||
|
|
@ -85,7 +86,6 @@ INCLUDEPATH += \
|
|||
qt/
|
||||
|
||||
HEADERS += \
|
||||
dependencies/dmiinfo.h \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
NetworkClient.h \
|
||||
NetworkProtocol.h \
|
||||
|
|
@ -131,6 +131,7 @@ HEADERS += \
|
|||
Controllers/LogitechController/LogitechG403Controller.h \
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIGPUController/MSIGPUController.h \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.h \
|
||||
Controllers/MSIRGBController/MSIRGBController.h \
|
||||
Controllers/NZXTHue2Controller/NZXTHue2Controller.h \
|
||||
|
|
@ -174,6 +175,8 @@ HEADERS += \
|
|||
RGBController/RGBController_LogitechG403.h \
|
||||
RGBController/RGBController_LogitechG810.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIGPU.h \
|
||||
RGBController/RGBController_MSIGPU.h \
|
||||
RGBController/RGBController_MSIMysticLight.h \
|
||||
RGBController/RGBController_MSIRGB.h \
|
||||
RGBController/RGBController_Network.h \
|
||||
|
|
@ -263,6 +266,8 @@ SOURCES += \
|
|||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
Controllers/MSIGPUController/MSIGPUController.cpp \
|
||||
Controllers/MSIGPUController/MSIGPUControllerDetect.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp \
|
||||
Controllers/MSIRGBController/MSIRGBController.cpp \
|
||||
|
|
@ -322,6 +327,7 @@ SOURCES += \
|
|||
RGBController/RGBController_LogitechG403.cpp \
|
||||
RGBController/RGBController_LogitechG810.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_MSIGPU.cpp \
|
||||
RGBController/RGBController_MSIMysticLight.cpp \
|
||||
RGBController/RGBController_MSIRGB.cpp \
|
||||
RGBController/RGBController_Network.cpp \
|
||||
|
|
|
|||
309
RGBController/RGBController_MSIGPU.cpp
Normal file
309
RGBController/RGBController_MSIGPU.cpp
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_MSIGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for MSI GPU |
|
||||
| |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_MSIGPU.h"
|
||||
|
||||
static unsigned char brightness_values[] = { 0x14, 0x28, 0x3c, 0x50, 0x64 };
|
||||
static unsigned char speed_values[] = { 0x04, 0x02, 0x01 };
|
||||
|
||||
int RGBController_MSIGPU::GetDeviceMode()
|
||||
{
|
||||
int dev_mode = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_MODE);
|
||||
|
||||
for(std::size_t mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if (modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
RGBController_MSIGPU::RGBController_MSIGPU(MSIGPUController * msi_gpu_ptr)
|
||||
{
|
||||
msi_gpu = msi_gpu_ptr;
|
||||
|
||||
name = msi_gpu->GetDeviceName();
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = "MSI RTX Gaming X Trio GPU Device";
|
||||
version = "0.00.1";
|
||||
location = msi_gpu->GetDeviceLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = MSI_GPU_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = MSI_GPU_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Rainbow.speed_min = 0;
|
||||
Rainbow.speed_max = 2;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = MSI_GPU_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Raindrop;
|
||||
Raindrop.name = "Raindrop";
|
||||
Raindrop.value = MSI_GPU_MODE_RAINDROP;
|
||||
Raindrop.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Raindrop.speed_min = 0;
|
||||
Raindrop.speed_max = 2;
|
||||
Raindrop.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Raindrop);
|
||||
|
||||
mode Magic;
|
||||
Magic.name = "Magic";
|
||||
Magic.value = MSI_GPU_MODE_MAGIC;
|
||||
Magic.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Magic.speed_min = 0;
|
||||
Magic.speed_max = 2;
|
||||
Magic.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Magic);
|
||||
|
||||
mode Patrolling;
|
||||
Patrolling.name = "Patrolling";
|
||||
Patrolling.value = MSI_GPU_MODE_PATROLLING;
|
||||
Patrolling.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Patrolling.speed_min = 0;
|
||||
Patrolling.speed_max = 2;
|
||||
Patrolling.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Patrolling);
|
||||
|
||||
mode Streaming;
|
||||
Streaming.name = "Streaming";
|
||||
Streaming.value = MSI_GPU_MODE_STREAMING;
|
||||
Streaming.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Streaming.speed_min = 0;
|
||||
Streaming.speed_max = 2;
|
||||
Streaming.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Streaming);
|
||||
|
||||
mode Lightning;
|
||||
Lightning.name = "Lightning";
|
||||
Lightning.value = MSI_GPU_MODE_LIGHTNING;
|
||||
Lightning.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Lightning.speed_min = 0;
|
||||
Lightning.speed_max = 2;
|
||||
Lightning.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Lightning);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = MSI_GPU_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Wave.speed_min = 0;
|
||||
Wave.speed_max = 2;
|
||||
Wave.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Meteor;
|
||||
Meteor.name = "Meteor";
|
||||
Meteor.value = MSI_GPU_MODE_METEOR;
|
||||
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Meteor.speed_min = 0;
|
||||
Meteor.speed_max = 2;
|
||||
Meteor.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Meteor);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
Stack.value = MSI_GPU_MODE_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Stack.speed_min = 0;
|
||||
Stack.speed_max = 2;
|
||||
Stack.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode Rhythm;
|
||||
Rhythm.name = "Rhythm";
|
||||
Rhythm.value = MSI_GPU_MODE_RHYTHM;
|
||||
Rhythm.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Rhythm.speed_min = 0;
|
||||
Rhythm.speed_max = 2;
|
||||
Rhythm.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Rhythm);
|
||||
|
||||
mode Flowing;
|
||||
Flowing.name = "Flowing";
|
||||
Flowing.value = MSI_GPU_MODE_FLOWING;
|
||||
Flowing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Flowing.speed_min = 0;
|
||||
Flowing.speed_max = 2;
|
||||
Flowing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Flowing);
|
||||
|
||||
mode Whirling;
|
||||
Whirling.name = "Whirling";
|
||||
Whirling.value = MSI_GPU_MODE_WHIRLING;
|
||||
Whirling.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Whirling.speed_min = 0;
|
||||
Whirling.speed_max = 2;
|
||||
Whirling.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Whirling);
|
||||
|
||||
mode Twisting;
|
||||
Twisting.name = "Twisting";
|
||||
Twisting.value = MSI_GPU_MODE_TWISTING;
|
||||
Twisting.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Twisting.speed_min = 0;
|
||||
Twisting.speed_max = 2;
|
||||
Twisting.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Twisting);
|
||||
|
||||
mode Laminating;
|
||||
Laminating.name = "Laminating";
|
||||
Laminating.value = MSI_GPU_MODE_LAMINATING;
|
||||
Laminating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Laminating.speed_min = 0;
|
||||
Laminating.speed_max = 2;
|
||||
Laminating.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Laminating);
|
||||
|
||||
mode Fadein;
|
||||
Fadein.name = "Fadein";
|
||||
Fadein.value = MSI_GPU_MODE_FADEIN;
|
||||
Fadein.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Fadein.speed_min = 0;
|
||||
Fadein.speed_max = 2;
|
||||
Fadein.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Fadein);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = MSI_GPU_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = 0;
|
||||
Breathing.speed_max = 2;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode flashing;
|
||||
flashing.name = "Flashing";
|
||||
flashing.value = MSI_GPU_MODE_FLASHING;
|
||||
flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
flashing.speed_min = 0;
|
||||
flashing.speed_max = 2;
|
||||
flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(flashing);
|
||||
|
||||
mode doubleflashing;
|
||||
doubleflashing.name = "Doubleflashing";
|
||||
doubleflashing.value = MSI_GPU_MODE_DOUBLEFLASHING;
|
||||
doubleflashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
doubleflashing.speed_min = 0;
|
||||
doubleflashing.speed_max = 2;
|
||||
doubleflashing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(doubleflashing);
|
||||
|
||||
SetupZones();
|
||||
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone msi_gpu_zone;
|
||||
msi_gpu_zone.name = "GPU";
|
||||
msi_gpu_zone.type = ZONE_TYPE_SINGLE;
|
||||
msi_gpu_zone.leds_min = 1;
|
||||
msi_gpu_zone.leds_max = 1;
|
||||
msi_gpu_zone.leds_count = 3;
|
||||
msi_gpu_zone.matrix_map = NULL;
|
||||
zones.push_back(msi_gpu_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LED |
|
||||
\*---------------------------------------------------------*/
|
||||
led led1;
|
||||
led1.name = "Color 1";
|
||||
leds.push_back(led1);
|
||||
led led2;
|
||||
led2.name = "Color 2";
|
||||
leds.push_back(led2);
|
||||
led led3;
|
||||
led3.name = "Color 3";
|
||||
leds.push_back(led3);
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize color |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char r1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R1);
|
||||
unsigned char g1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G1);
|
||||
unsigned char b1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B1);
|
||||
unsigned char r2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R2);
|
||||
unsigned char g2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G2);
|
||||
unsigned char b2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B2);
|
||||
unsigned char r3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R3);
|
||||
unsigned char g3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G3);
|
||||
unsigned char b3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B3);
|
||||
|
||||
colors[0] = ToRGBColor(r1, g1, b1);
|
||||
colors[1] = ToRGBColor(r2, g2, b2);
|
||||
colors[2] = ToRGBColor(r3, g3, b3);
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_BRIGHTNESS, brightness_values[4]); // how to access brightness value?
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_SPEED, speed_values[modes[active_mode].speed]);
|
||||
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_UNKNOWN, 0x00);
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR) {
|
||||
if (modes[active_mode].value == MSI_GPU_MODE_FADEIN) {
|
||||
msi_gpu->SetRGB2(RGBGetRValue(colors[1]), RGBGetGValue(colors[1]), RGBGetBValue(colors[1]));
|
||||
msi_gpu->SetRGB3(RGBGetRValue(colors[2]), RGBGetGValue(colors[2]), RGBGetBValue(colors[2]));
|
||||
} else
|
||||
msi_gpu->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0]));
|
||||
}
|
||||
msi_gpu->SetMode(modes[active_mode].value);
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_MSIGPU::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
33
RGBController/RGBController_MSIGPU.h
Normal file
33
RGBController/RGBController_MSIGPU.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_MSIGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for MSI GPU |
|
||||
| |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "MSIGPUController.h"
|
||||
|
||||
class RGBController_MSIGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_MSIGPU(MSIGPUController* msi_gpu_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
MSIGPUController* msi_gpu;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
|
|
@ -17,9 +17,14 @@
|
|||
|
||||
i2c_smbus_interface::i2c_smbus_interface()
|
||||
{
|
||||
i2c_smbus_start = false;
|
||||
i2c_smbus_done = false;
|
||||
i2c_smbus_thread = new std::thread(&i2c_smbus_interface::i2c_smbus_thread_function, this);
|
||||
i2c_smbus_start = false;
|
||||
i2c_smbus_done = false;
|
||||
this->port_id = -1;
|
||||
this->pci_device = -1;
|
||||
this->pci_vendor = -1;
|
||||
this->pci_subsystem_device = -1;
|
||||
this->pci_subsystem_vendor = -1;
|
||||
i2c_smbus_thread = new std::thread(&i2c_smbus_interface::i2c_smbus_thread_function, this);
|
||||
}
|
||||
|
||||
s32 i2c_smbus_interface::i2c_smbus_write_quick(u8 addr, u8 value)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ class i2c_smbus_interface
|
|||
public:
|
||||
char device_name[512];
|
||||
|
||||
int port_id;
|
||||
int pci_device;
|
||||
int pci_vendor;
|
||||
int pci_subsystem_device;
|
||||
int pci_subsystem_vendor;
|
||||
|
||||
i2c_smbus_interface();
|
||||
virtual ~i2c_smbus_interface() = default;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue