Initial driver for Sapphire GPU (tested on RX580 Nitro+ on Windows)
This commit is contained in:
parent
77ecfc3b46
commit
505e2d2aa4
7 changed files with 278 additions and 0 deletions
43
Controllers/SapphireGPUController/SapphireGPUController.cpp
Normal file
43
Controllers/SapphireGPUController/SapphireGPUController.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*-----------------------------------------*\
|
||||
| SapphireGPUController.cpp |
|
||||
| |
|
||||
| Driver for Sapphire Nitro Glow GPU RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 7/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SapphireGPUController.h"
|
||||
|
||||
SapphireGPUController::SapphireGPUController(i2c_smbus_interface* bus, sapphire_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
}
|
||||
|
||||
SapphireGPUController::~SapphireGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string SapphireGPUController::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 SapphireGPUController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_BLUE, blue);
|
||||
}
|
||||
|
||||
void SapphireGPUController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_MODE, 0x04);
|
||||
}
|
||||
41
Controllers/SapphireGPUController/SapphireGPUController.h
Normal file
41
Controllers/SapphireGPUController/SapphireGPUController.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*-----------------------------------------*\
|
||||
| SapphireGPUController.h |
|
||||
| |
|
||||
| Definitions and types for Sapphire Nitro |
|
||||
| Glow GPU RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 7/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char sapphire_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
SAPPHIRE_GPU_REG_MODE = 0x00,
|
||||
SAPPHIRE_GPU_REG_BRIGHTNESS = 0x01,
|
||||
SAPPHIRE_GPU_REG_RED = 0x03,
|
||||
SAPPHIRE_GPU_REG_GREEN = 0x04,
|
||||
SAPPHIRE_GPU_REG_BLUE = 0x05,
|
||||
};
|
||||
|
||||
class SapphireGPUController
|
||||
{
|
||||
public:
|
||||
SapphireGPUController(i2c_smbus_interface* bus, sapphire_dev_id dev);
|
||||
~SapphireGPUController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
private:
|
||||
i2c_smbus_interface* bus;
|
||||
sapphire_dev_id dev;
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#include "SapphireGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_SapphireGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForSapphireGPUController *
|
||||
* *
|
||||
* Tests the given address to see if a Sapphire GPU controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForSapphireGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
int res;
|
||||
|
||||
//TODO - detection
|
||||
|
||||
return(false);
|
||||
|
||||
} /* TestForSapphireGPUController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSapphireGPUControllers *
|
||||
* *
|
||||
* Detect Sapphire GPU controllers on the enumerated I2C busses at address 0x55. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Sapphire GPU device is connected *
|
||||
* dev - I2C address of Sapphire GPU device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSapphireGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
SapphireGPUController* new_sapphire;
|
||||
RGBController_SapphireGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Sapphire GPU controller at 0x55
|
||||
if (TestForSapphireGPUController(busses[bus], 0x55))
|
||||
{
|
||||
new_sapphire = new SapphireGPUController(busses[bus], 0x55);
|
||||
new_controller = new RGBController_SapphireGPU(new_sapphire);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectSapphireGPUControllers() */
|
||||
|
|
@ -424,6 +424,7 @@ void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, st
|
|||
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 DetectSapphireGPUControllers(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);
|
||||
|
|
@ -472,6 +473,7 @@ void DetectRGBControllers(void)
|
|||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionGPUControllers(busses, rgb_controllers);
|
||||
DetectMSIGPUControllers(busses, rgb_controllers);
|
||||
DetectSapphireGPUControllers(busses, rgb_controllers);
|
||||
|
||||
//TODO: Implement better detection before enabling these controllers
|
||||
//DetectRGBFusion2SMBusControllers(busses, rgb_controllers);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ INCLUDEPATH += \
|
|||
Controllers/RGBFusion2SMBusController/ \
|
||||
Controllers/RGBFusion2USBController/ \
|
||||
Controllers/RGBFusionGPUController/ \
|
||||
Controllers/SapphireGPUController/ \
|
||||
Controllers/SteelSeriesController/ \
|
||||
Controllers/ThermaltakeRiingController/ \
|
||||
RGBController/ \
|
||||
|
|
@ -146,6 +147,7 @@ HEADERS += \
|
|||
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
|
||||
Controllers/RedragonController/RedragonK556Controller.h \
|
||||
Controllers/RedragonController/RedragonM711Controller.h \
|
||||
Controllers/SapphireGPUController/SapphireGPUController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesApexController.h \
|
||||
|
|
@ -192,6 +194,7 @@ HEADERS += \
|
|||
RGBController/RGBController_RGBFusion2SMBus.h \
|
||||
RGBController/RGBController_RGBFusion2USB.h \
|
||||
RGBController/RGBController_RGBFusionGPU.h \
|
||||
RGBController/RGBController_SapphireGPU.h \
|
||||
RGBController/RGBController_SteelSeriesRival.h \
|
||||
RGBController/RGBController_SteelSeriesSiberia.h \
|
||||
RGBController/RGBController_SteelSeriesApex.h \
|
||||
|
|
@ -295,6 +298,8 @@ SOURCES += \
|
|||
Controllers/RedragonController/RedragonK556Controller.cpp \
|
||||
Controllers/RedragonController/RedragonM711Controller.cpp \
|
||||
Controllers/RedragonController/RedragonControllerDetect.cpp \
|
||||
Controllers/SapphireGPUController/SapphireGPUController.cpp \
|
||||
Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesApexController.cpp \
|
||||
|
|
@ -343,6 +348,7 @@ SOURCES += \
|
|||
RGBController/RGBController_RGBFusion2SMBus.cpp \
|
||||
RGBController/RGBController_RGBFusion2USB.cpp \
|
||||
RGBController/RGBController_RGBFusionGPU.cpp \
|
||||
RGBController/RGBController_SapphireGPU.cpp \
|
||||
RGBController/RGBController_SteelSeriesRival.cpp \
|
||||
RGBController/RGBController_SteelSeriesSiberia.cpp \
|
||||
RGBController/RGBController_SteelSeriesApex.cpp \
|
||||
|
|
|
|||
97
RGBController/RGBController_SapphireGPU.cpp
Normal file
97
RGBController/RGBController_SapphireGPU.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_RGBFusionGPU.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Gigabyte RGB Fusion GPU Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/23/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_SapphireGPU.h"
|
||||
|
||||
RGBController_SapphireGPU::RGBController_SapphireGPU(SapphireGPUController* sapphire_ptr)
|
||||
{
|
||||
sapphire = sapphire_ptr;
|
||||
|
||||
name = "Sapphire GPU";
|
||||
description = "Sapphire GPU";
|
||||
location = sapphire->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_GPU;
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = 0;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
SetupZones();
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::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_SapphireGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
sapphire->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_SapphireGPU::UpdateMode()
|
||||
{
|
||||
sapphire->SetMode((unsigned char)modes[(unsigned int)active_mode].value, (unsigned char)modes[(unsigned int)active_mode].speed);
|
||||
}
|
||||
33
RGBController/RGBController_SapphireGPU.h
Normal file
33
RGBController/RGBController_SapphireGPU.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_SapphireGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Sapphire GPU RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 7/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SapphireGPUController.h"
|
||||
|
||||
class RGBController_SapphireGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SapphireGPU(SapphireGPUController* sapphire_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:
|
||||
SapphireGPUController* sapphire;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue