WIP Galax RTX GPU support
Setting RGB values works. Modes still unknown.
This commit is contained in:
parent
5e0b1fa3cc
commit
12f5d6070f
6 changed files with 452 additions and 0 deletions
86
Controllers/GalaxGPUController/GalaxGPUController.cpp
Normal file
86
Controllers/GalaxGPUController/GalaxGPUController.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*-----------------------------------------*\
|
||||
| GalaxGPUController.cpp |
|
||||
| |
|
||||
| Driver for Galax / KFA2 RGB on GPUs |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 12.07.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "GalaxGPUController.h"
|
||||
#include <cstring>
|
||||
|
||||
GalaxGPUController::GalaxGPUController(i2c_smbus_interface* bus, galax_gpu_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
strcpy(device_name, "Galax RTX GPU"); // Would be nice to get the actual GPU name. Using this as a placeholder.
|
||||
}
|
||||
|
||||
GalaxGPUController::~GalaxGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string GalaxGPUController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string GalaxGPUController::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 GalaxGPUController::GetLEDRed()
|
||||
{
|
||||
return(GalaxGPURegisterRead(GALAX_RED_REGISTER));
|
||||
}
|
||||
|
||||
unsigned char GalaxGPUController::GetLEDGreen()
|
||||
{
|
||||
return(GalaxGPURegisterRead(GALAX_GREEN_REGISTER));
|
||||
}
|
||||
|
||||
unsigned char GalaxGPUController::GetLEDBlue()
|
||||
{
|
||||
return(GalaxGPURegisterRead(GALAX_BLUE_REGISTER));
|
||||
}
|
||||
|
||||
void GalaxGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes
|
||||
{
|
||||
GalaxGPURegisterWrite(GALAX_RED_REGISTER, red);
|
||||
GalaxGPURegisterWrite(GALAX_GREEN_REGISTER, green);
|
||||
GalaxGPURegisterWrite(GALAX_BLUE_REGISTER, blue);
|
||||
}
|
||||
|
||||
void GalaxGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
GalaxGPURegisterWrite(GALAX_RED_REGISTER, red);
|
||||
GalaxGPURegisterWrite(GALAX_GREEN_REGISTER, green);
|
||||
GalaxGPURegisterWrite(GALAX_BLUE_REGISTER, blue);
|
||||
}
|
||||
|
||||
void GalaxGPUController::SetMode(unsigned char mode)
|
||||
{
|
||||
//not researched yet
|
||||
|
||||
/*
|
||||
GalaxGPURegisterWrite(GALAX_MODE_REGISTER, mode);
|
||||
*/
|
||||
}
|
||||
|
||||
unsigned char GalaxGPUController::GalaxGPURegisterRead(unsigned char reg)
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, reg));
|
||||
}
|
||||
|
||||
void GalaxGPUController::GalaxGPURegisterWrite(unsigned char reg, unsigned char val)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, reg, val);
|
||||
}
|
||||
53
Controllers/GalaxGPUController/GalaxGPUController.h
Normal file
53
Controllers/GalaxGPUController/GalaxGPUController.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*-----------------------------------------*\
|
||||
| GalaxGPUController.h |
|
||||
| |
|
||||
| Driver for Galax / KFA2 RGB on GPUs |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 12.07.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char galax_gpu_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
GALAX_RED_REGISTER = 0x02, /* Red Register */
|
||||
GALAX_GREEN_REGISTER = 0x03, /* Green Register */
|
||||
GALAX_BLUE_REGISTER = 0x04, /* Blue Register */
|
||||
//GALAX_MODE_REGISTER = 0x07, /* Mode Register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
//GALAX_MODE_STATIC = 0x04,
|
||||
};
|
||||
|
||||
class GalaxGPUController
|
||||
{
|
||||
public:
|
||||
GalaxGPUController(i2c_smbus_interface* bus, galax_gpu_dev_id);
|
||||
~GalaxGPUController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned char GetLEDRed();
|
||||
unsigned char GetLEDGreen();
|
||||
unsigned char GetLEDBlue();
|
||||
void SetLEDColorsDirect(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);
|
||||
|
||||
unsigned char GalaxGPURegisterRead(unsigned char reg);
|
||||
void GalaxGPURegisterWrite(unsigned char reg, unsigned char val);
|
||||
|
||||
bool direct = false; // Temporary solution to check if we are in "Direct" mode
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
i2c_smbus_interface * bus;
|
||||
galax_gpu_dev_id dev;
|
||||
};
|
||||
68
Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp
Normal file
68
Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*-----------------------------------------*\
|
||||
| GalaxGPUControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for Galax / KFA2 RGB on GPUs |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 12.07.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "GalaxGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_GalaxGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForGalaxGPUController *
|
||||
* *
|
||||
* Tests the given address to see if a Galax GPU controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForGalaxGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
unsigned char res = bus->i2c_smbus_read_byte_data(address, 0x00);
|
||||
|
||||
if(res == 0x10 || res == 0x27) //Windows reads 0x10, Linux reads 0x27 which is correct as 0x10 is at 0x01
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForGalaxGPUController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectGalaxGPUControllers *
|
||||
* *
|
||||
* Detect Galax GPU controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectGalaxGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
GalaxGPUController* new_GalaxGPU;
|
||||
RGBController_GalaxGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for GALAX controller at 0x23
|
||||
if (TestForGalaxGPUController(busses[bus], 0x23))
|
||||
{
|
||||
new_GalaxGPU = new GalaxGPUController(busses[bus], 0x23);
|
||||
new_controller = new RGBController_GalaxGPU(new_GalaxGPU);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectGalaxGPUControllers() */
|
||||
Loading…
Add table
Add a link
Reference in a new issue