Initial controller code for EVGA GPUs. No detection implemented yet.
This commit is contained in:
parent
f1b7b8ba90
commit
f17cdea5b6
6 changed files with 321 additions and 0 deletions
58
Controllers/EVGAGPUController/EVGAGPUController.cpp
Normal file
58
Controllers/EVGAGPUController/EVGAGPUController.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*-----------------------------------------*\
|
||||
| EVGAGPUController.cpp |
|
||||
| |
|
||||
| Driver for EVGA GPU RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "EVGAGPUController.h"
|
||||
|
||||
EVGAGPUController::EVGAGPUController(i2c_smbus_interface* bus, evga_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
}
|
||||
|
||||
EVGAGPUController::~EVGAGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string EVGAGPUController::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);
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUController::GetRed()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_REG_RED));
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUController::GetGreen()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_REG_GREEN));
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUController::GetBlue()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_REG_BLUE));
|
||||
}
|
||||
|
||||
void EVGAGPUController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_REG_BLUE, blue);
|
||||
}
|
||||
|
||||
void EVGAGPUController::SetMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_REG_MODE, mode);
|
||||
}
|
||||
52
Controllers/EVGAGPUController/EVGAGPUController.h
Normal file
52
Controllers/EVGAGPUController/EVGAGPUController.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*-----------------------------------------*\
|
||||
| EVGAGPUController.h |
|
||||
| |
|
||||
| Definitions and types for EVGA GPU RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char evga_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_REG_MODE = 0x0C,
|
||||
EVGA_GPU_REG_RED = 0x09,
|
||||
EVGA_GPU_REG_GREEN = 0x0A,
|
||||
EVGA_GPU_REG_BLUE = 0x0B,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_MODE_OFF = 0x00,
|
||||
EVGA_GPU_MODE_CUSTOM = 0x01,
|
||||
EVGA_GPU_MODE_RAINBOW = 0x02,
|
||||
EVGA_GPU_MODE_BREATHING = 0x05,
|
||||
};
|
||||
|
||||
class EVGAGPUController
|
||||
{
|
||||
public:
|
||||
EVGAGPUController(i2c_smbus_interface* bus, evga_dev_id dev);
|
||||
~EVGAGPUController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
unsigned char GetRed();
|
||||
unsigned char GetGreen();
|
||||
unsigned char GetBlue();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
private:
|
||||
i2c_smbus_interface* bus;
|
||||
evga_dev_id dev;
|
||||
|
||||
};
|
||||
54
Controllers/EVGAGPUController/EVGAGPUControllerDetect.cpp
Normal file
54
Controllers/EVGAGPUController/EVGAGPUControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "Detector.h"
|
||||
#include "EVGAGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_EVGAGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForEVGAGPUController *
|
||||
* *
|
||||
* Tests the given address to see if a EVGA GPU controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForEVGAGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
return(false);
|
||||
} /* TestForEVGAGPUController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectEVGAGPUControllers *
|
||||
* *
|
||||
* Detect EVGA GPU controllers on the enumerated I2C busses at address 0x49. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where EVGA GPU device is connected *
|
||||
* dev - I2C address of EVGA GPU device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectEVGAGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
EVGAGPUController* new_evga;
|
||||
RGBController_EVGAGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for EVGA GPU controller at 0x49
|
||||
if (TestForEVGAGPUController(busses[bus], 0x49))
|
||||
{
|
||||
new_evga = new EVGAGPUController(busses[bus], 0x49);
|
||||
new_controller = new RGBController_EVGAGPU(new_evga);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectEVGAGPUControllers() */
|
||||
|
||||
// This detector is disabled as it does not properly detect
|
||||
//REGISTER_I2C_DETECTOR("EVGA GPU", DetectEVGAGPUControllers);
|
||||
|
|
@ -63,6 +63,7 @@ INCLUDEPATH += \
|
|||
Controllers/DuckyKeyboardController/ \
|
||||
Controllers/EKController/ \
|
||||
Controllers/EspurnaController/ \
|
||||
Controllers/EVGAGPUController/ \
|
||||
Controllers/GalaxGPUController/ \
|
||||
Controllers/GloriousModelOController/ \
|
||||
Controllers/HoltekController/ \
|
||||
|
|
@ -138,6 +139,7 @@ HEADERS += \
|
|||
Controllers/DuckyKeyboardController/DuckyKeyboardController.h \
|
||||
Controllers/EKController/EKController.h \
|
||||
Controllers/EspurnaController/EspurnaController.h \
|
||||
Controllers/EVGAGPUController/EVGAGPUController.h \
|
||||
Controllers/GalaxGPUController/GalaxGPUController.h \
|
||||
Controllers/GloriousModelOController/GloriousModelOController.h \
|
||||
Controllers/HoltekController/HoltekA070Controller.h \
|
||||
|
|
@ -195,6 +197,7 @@ HEADERS += \
|
|||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_EKController.h \
|
||||
RGBController/RGBController_Espurna.h \
|
||||
RGBController/RGBController_EVGAGPU.h \
|
||||
RGBController/RGBController_GalaxGPU.h \
|
||||
RGBController/RGBController_GloriousModelO.h \
|
||||
RGBController/RGBController_HoltekA070.h \
|
||||
|
|
@ -298,6 +301,8 @@ SOURCES += \
|
|||
Controllers/EKController/EKController.cpp \
|
||||
Controllers/EspurnaController/EspurnaController.cpp \
|
||||
Controllers/EspurnaController/EspurnaControllerDetect.cpp \
|
||||
Controllers/EVGAGPUController/EVGAGPUController.cpp \
|
||||
Controllers/EVGAGPUController/EVGAGPUControllerDetect.cpp \
|
||||
Controllers/GalaxGPUController/GalaxGPUController.cpp \
|
||||
Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp \
|
||||
Controllers/GloriousModelOController/GloriousModelOController.cpp \
|
||||
|
|
@ -385,6 +390,7 @@ SOURCES += \
|
|||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_EKController.cpp \
|
||||
RGBController/RGBController_Espurna.cpp \
|
||||
RGBController/RGBController_EVGAGPU.cpp \
|
||||
RGBController/RGBController_GalaxGPU.cpp \
|
||||
RGBController/RGBController_GloriousModelO.cpp \
|
||||
RGBController/RGBController_HoltekA070.cpp \
|
||||
|
|
|
|||
118
RGBController/RGBController_EVGAGPU.cpp
Normal file
118
RGBController/RGBController_EVGAGPU.cpp
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_EVGAGPU.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB EVGA |
|
||||
| GPU Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_EVGAGPU.h"
|
||||
|
||||
RGBController_EVGAGPU::RGBController_EVGAGPU(EVGAGPUController* evga_ptr)
|
||||
{
|
||||
evga = evga_ptr;
|
||||
|
||||
name = "EVGA GPU";
|
||||
description = "EVGA GPU";
|
||||
location = evga->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_GPU;
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = EVGA_GPU_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = EVGA_GPU_MODE_CUSTOM;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = EVGA_GPU_MODE_RAINBOW;
|
||||
Rainbow.flags = 0;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = EVGA_GPU_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device only has one LED, so create a single zone and |
|
||||
| LED for it |
|
||||
\*---------------------------------------------------------*/
|
||||
zone* new_zone = new zone();
|
||||
led* new_led = new led();
|
||||
|
||||
new_zone->name = "GPU Zone";
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
new_zone->leds_min = 1;
|
||||
new_zone->leds_max = 1;
|
||||
new_zone->leds_count = 1;
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
new_led->name = "GPU LED";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the zone and LED on to device vectors |
|
||||
\*---------------------------------------------------------*/
|
||||
leds.push_back(*new_led);
|
||||
zones.push_back(*new_zone);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
evga->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPU::DeviceUpdateMode()
|
||||
{
|
||||
evga->SetMode((unsigned char)modes[(unsigned int)active_mode].value);
|
||||
}
|
||||
33
RGBController/RGBController_EVGAGPU.h
Normal file
33
RGBController/RGBController_EVGAGPU.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_EVGAGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| EVGA GPU RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "EVGAGPUController.h"
|
||||
|
||||
class RGBController_EVGAGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_EVGAGPU(EVGAGPUController* evga_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
EVGAGPUController* evga;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue