Compare commits
15
Commits
master
...
xpg_ssd_devel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
165d0f7790 | ||
|
|
ebd509b768 | ||
|
|
b1ad55e882 | ||
|
|
8402f23907 | ||
|
|
5196ff7772 | ||
|
|
571e4f4d38 | ||
|
|
b7db46cdd4 | ||
|
|
4dc181646f | ||
|
|
301abd69fa | ||
|
|
a6e7c7229c | ||
|
|
bb2b1bb071 | ||
|
|
b8f6c79bce | ||
|
|
dd090a54da | ||
|
|
a6a7e404f3 | ||
|
|
8255af7fe7 |
@@ -0,0 +1,431 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_XPGSpectrixS40G.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_XPGSpectrixS40G.h"
|
||||
|
||||
int RGBController_XPGSpectrixS40G::GetDeviceMode()
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Determine starting mode by reading the mode and direct registers |
|
||||
\*-----------------------------------------------------------------*/
|
||||
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
|
||||
int color_mode = MODE_COLORS_PER_LED;
|
||||
int speed = aura->AuraRegisterRead(AURA_REG_SPEED);
|
||||
int direction = aura->AuraRegisterRead(AURA_REG_DIRECTION);
|
||||
|
||||
if(aura->AuraRegisterRead(AURA_REG_DIRECT))
|
||||
{
|
||||
dev_mode = 0xFFFF;
|
||||
}
|
||||
|
||||
switch(dev_mode)
|
||||
{
|
||||
case AURA_MODE_OFF:
|
||||
case AURA_MODE_RAINBOW:
|
||||
case AURA_MODE_SPECTRUM_CYCLE:
|
||||
case AURA_MODE_RANDOM_FLICKER:
|
||||
color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE:
|
||||
dev_mode = AURA_MODE_CHASE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_BREATHING:
|
||||
dev_mode = AURA_MODE_BREATHING;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE:
|
||||
dev_mode = AURA_MODE_CHASE_FADE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
}
|
||||
|
||||
for(std::size_t mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
modes[mode].color_mode = color_mode;
|
||||
|
||||
if(modes[mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[mode].speed = speed;
|
||||
}
|
||||
|
||||
if(modes[mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
modes[mode].direction = direction;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceUpdateLEDs()
|
||||
{
|
||||
if(GetMode() == 0)
|
||||
{
|
||||
aura->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetAllColorsEffect(&colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for (std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++)
|
||||
{
|
||||
int led = zones[zone].leds[led_idx].value;
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_XPGSpectrixS40G::RGBController_XPGSpectrixS40G(XPGSpectrixS40GController * aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
version = aura->GetDeviceName();
|
||||
location = aura->GetDeviceLocation();
|
||||
if((version.find("DIMM_LED") != std::string::npos) || (version.find("AUDA") != std::string::npos) )
|
||||
{
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "ASUS Aura DRAM";
|
||||
}
|
||||
else
|
||||
{
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
name = "ASUS Aura Motherboard";
|
||||
}
|
||||
vendor = "ASUS";
|
||||
description = "ASUS Aura SMBus Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_MANUAL_SAVE;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = AURA_SPEED_SLOWEST;
|
||||
Breathing.speed_max = AURA_SPEED_FASTEST;
|
||||
Breathing.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
Flashing.speed_min = AURA_SPEED_SLOWEST;
|
||||
Flashing.speed_max = AURA_SPEED_FASTEST;
|
||||
Flashing.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.speed_min = AURA_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = AURA_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed_min = AURA_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = AURA_SPEED_FASTEST;
|
||||
Rainbow.speed = AURA_SPEED_NORMAL;
|
||||
Rainbow.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode ChaseFade;
|
||||
ChaseFade.name = "Chase Fade";
|
||||
ChaseFade.value = AURA_MODE_CHASE_FADE;
|
||||
ChaseFade.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
ChaseFade.color_mode = MODE_COLORS_PER_LED;
|
||||
ChaseFade.speed_min = AURA_SPEED_SLOWEST;
|
||||
ChaseFade.speed_max = AURA_SPEED_FASTEST;
|
||||
ChaseFade.speed = AURA_SPEED_NORMAL;
|
||||
ChaseFade.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
Chase.color_mode = MODE_COLORS_PER_LED;
|
||||
Chase.speed_min = AURA_SPEED_SLOWEST;
|
||||
Chase.speed_max = AURA_SPEED_FASTEST;
|
||||
Chase.speed = AURA_SPEED_NORMAL;
|
||||
ChaseFade.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode RandomFlicker;
|
||||
RandomFlicker.name = "Random Flicker";
|
||||
RandomFlicker.value = AURA_MODE_RANDOM_FLICKER;
|
||||
RandomFlicker.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
RandomFlicker.color_mode = MODE_COLORS_NONE;
|
||||
RandomFlicker.speed_min = AURA_SPEED_SLOWEST;
|
||||
RandomFlicker.speed_max = AURA_SPEED_FASTEST;
|
||||
RandomFlicker.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(RandomFlicker);
|
||||
|
||||
SetupZones();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Initialize active mode |
|
||||
\*-------------------------------------------------*/
|
||||
//active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
RGBController_XPGSpectrixS40G::~RGBController_XPGSpectrixS40G()
|
||||
{
|
||||
delete aura;
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::SetupZones()
|
||||
{
|
||||
std::vector<int> aura_led_map;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Search through all LEDs and create zones for each channel |
|
||||
| type |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t led_idx = 0; led_idx < aura->GetLEDCount(); led_idx++)
|
||||
{
|
||||
bool matched = false;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Search through existing zones to make sure we don't |
|
||||
| create a duplicate zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t existing_zone_idx = 0; existing_zone_idx < zones.size(); existing_zone_idx++)
|
||||
{
|
||||
if (aura->GetChannelName(led_idx) == zones[existing_zone_idx].name)
|
||||
{
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If zone does not already exist, create it |
|
||||
\*---------------------------------------------------------*/
|
||||
if (matched == false)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set zone name to channel name |
|
||||
\*---------------------------------------------------------*/
|
||||
new_zone->name = aura->GetChannelName(led_idx);
|
||||
|
||||
new_zone->leds_count = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Find all LEDs with this channel type and add them to zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t zone_led_idx = 0; zone_led_idx < aura->GetLEDCount(); zone_led_idx++)
|
||||
{
|
||||
if (aura->GetChannelName(zone_led_idx) == new_zone->name)
|
||||
{
|
||||
new_zone->leds_count++;
|
||||
aura_led_map.push_back(zone_led_idx);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Aura zones have fixed size, so set min and max to count |
|
||||
\*---------------------------------------------------------*/
|
||||
new_zone->leds_min = new_zone->leds_count;
|
||||
new_zone->leds_max = new_zone->leds_count;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If this zone has more than one LED, mark it as linear type|
|
||||
\*---------------------------------------------------------*/
|
||||
if(new_zone->leds_count > 1)
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new zone to zones vector |
|
||||
\*---------------------------------------------------------*/
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create LED entries for each zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = zones[zone_idx].name + " LED ";
|
||||
new_led->name.append(std::to_string(led_idx + 1));
|
||||
|
||||
new_led->value = aura_led_map[led_idx];
|
||||
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize colors for each LED |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
unsigned int led = leds[led_idx].value;
|
||||
unsigned char red = aura->GetLEDRed(led);
|
||||
unsigned char grn = aura->GetLEDGreen(led);
|
||||
unsigned char blu = aura->GetLEDBlue(led);
|
||||
|
||||
colors[led_idx] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceUpdateMode()
|
||||
{
|
||||
if (modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int new_mode = modes[active_mode].value;
|
||||
int new_speed = 0;
|
||||
int new_direction = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_RANDOM)
|
||||
{
|
||||
switch(new_mode)
|
||||
{
|
||||
case AURA_MODE_CHASE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE;
|
||||
break;
|
||||
case AURA_MODE_BREATHING:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_BREATHING;
|
||||
break;
|
||||
case AURA_MODE_CHASE_FADE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
new_speed = modes[active_mode].speed;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
new_direction = AURA_DIRECTION_FORWARD;
|
||||
break;
|
||||
|
||||
case MODE_DIRECTION_RIGHT:
|
||||
new_direction = AURA_DIRECTION_REVERSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aura->SetMode(new_mode, new_speed, new_direction);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceSaveMode()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
aura->SaveMode();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_XPGSpectrixS40G.h |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
|
||||
class RGBController_XPGSpectrixS40G : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_XPGSpectrixS40G(XPGSpectrixS40GController* spectrix_ptr);
|
||||
~RGBController_XPGSpectrixS40G();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
int GetDeviceMode();
|
||||
|
||||
private:
|
||||
XPGSpectrixS40GController* aura;
|
||||
};
|
||||
@@ -0,0 +1,340 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GController.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
#include <malloc.h>
|
||||
#include <cstring>
|
||||
#include "LogManager.h"
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Functions for submitting NVME admin passthrough command taken from |
|
||||
| libnvme: https://github.com/linux-nvme/libnvme |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_passthru_cmd)
|
||||
|
||||
static int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
|
||||
struct nvme_passthru_cmd *cmd, uint32_t *result)
|
||||
{
|
||||
int err = ioctl(fd, ioctl_cmd, cmd);
|
||||
|
||||
if (err >= 0 && result)
|
||||
*result = cmd->result;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int nvme_passthru(int fd, unsigned long ioctl_cmd, uint8_t opcode,
|
||||
uint8_t flags, uint16_t rsvd, uint32_t nsid, uint32_t cdw2,
|
||||
uint32_t cdw3, uint32_t cdw10, uint32_t cdw11, uint32_t cdw12,
|
||||
uint32_t cdw13, uint32_t cdw14, uint32_t cdw15, uint32_t data_len,
|
||||
void *data, uint32_t metadata_len, void *metadata,
|
||||
uint32_t timeout_ms, uint32_t *result)
|
||||
{
|
||||
struct nvme_passthru_cmd cmd = {
|
||||
.opcode = opcode,
|
||||
.flags = flags,
|
||||
.rsvd1 = rsvd,
|
||||
.nsid = nsid,
|
||||
.cdw2 = cdw2,
|
||||
.cdw3 = cdw3,
|
||||
.metadata = (uint64_t)(uintptr_t)metadata,
|
||||
.addr = (uint64_t)(uintptr_t)data,
|
||||
.metadata_len = metadata_len,
|
||||
.data_len = data_len,
|
||||
.cdw10 = cdw10,
|
||||
.cdw11 = cdw11,
|
||||
.cdw12 = cdw12,
|
||||
.cdw13 = cdw13,
|
||||
.cdw14 = cdw14,
|
||||
.cdw15 = cdw15,
|
||||
.timeout_ms = timeout_ms,
|
||||
};
|
||||
|
||||
return nvme_submit_passthru(fd, ioctl_cmd, &cmd, result);
|
||||
}
|
||||
|
||||
int nvme_admin_passthru(int fd, uint8_t opcode, uint8_t flags, uint16_t rsvd,
|
||||
uint32_t nsid, uint32_t cdw2, uint32_t cdw3, uint32_t cdw10,
|
||||
uint32_t cdw11, uint32_t cdw12, uint32_t cdw13, uint32_t cdw14,
|
||||
uint32_t cdw15, uint32_t data_len, void *data,
|
||||
uint32_t metadata_len, void *metadata, uint32_t timeout_ms,
|
||||
uint32_t *result)
|
||||
{
|
||||
return nvme_passthru(fd, NVME_IOCTL_ADMIN_CMD, opcode, flags, rsvd,
|
||||
nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13,
|
||||
cdw14, cdw15, data_len, data, metadata_len,
|
||||
metadata, timeout_ms, result);
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
#include <cstring>
|
||||
|
||||
static const char* aura_channels[] = /* Aura channel strings */
|
||||
{
|
||||
"Audio",
|
||||
"Backplate",
|
||||
"Back I/O",
|
||||
"Center",
|
||||
"Center",
|
||||
"DRAM",
|
||||
"PCIe",
|
||||
"RGB Header",
|
||||
"RGB Header 2",
|
||||
"RGB Header",
|
||||
"Unknown",
|
||||
};
|
||||
|
||||
XPGSpectrixS40GController::XPGSpectrixS40GController(int fd, aura_dev_id dev)
|
||||
{
|
||||
nvme_fd = fd;
|
||||
this->dev = dev;
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
led_count = 8;
|
||||
}
|
||||
|
||||
XPGSpectrixS40GController::~XPGSpectrixS40GController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string XPGSpectrixS40GController::GetDeviceName()
|
||||
{
|
||||
return("SSD");
|
||||
}
|
||||
|
||||
std::string XPGSpectrixS40GController::GetDeviceLocation()
|
||||
{
|
||||
return("I2C: SSD");
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetChannel(unsigned int led)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
const char * XPGSpectrixS40GController::GetChannelName(unsigned int led)
|
||||
{
|
||||
switch (config_table[channel_cfg + led])
|
||||
{
|
||||
case (unsigned char)AURA_LED_CHANNEL_AUDIO:
|
||||
return(aura_channels[0]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACKPLATE:
|
||||
return(aura_channels[1]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACK_IO:
|
||||
return(aura_channels[2]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER:
|
||||
return(aura_channels[3]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER_START:
|
||||
return(aura_channels[4]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_DRAM:
|
||||
return(aura_channels[5]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_PCIE:
|
||||
return(aura_channels[6]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER:
|
||||
return(aura_channels[7]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_2:
|
||||
return(aura_channels[8]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_3:
|
||||
return(aura_channels[9]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(aura_channels[10]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int XPGSpectrixS40GController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDRed(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led )));
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDGreen(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDBlue(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SaveMode()
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_SAVE_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetAllColorsDirect(RGBColor* colors)
|
||||
{
|
||||
unsigned char* color_buf = new unsigned char[led_count * 3];
|
||||
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
|
||||
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
|
||||
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg, color_buf, led_count * 3);
|
||||
|
||||
delete color_buf;
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetAllColorsEffect(RGBColor* colors)
|
||||
{
|
||||
unsigned char* color_buf = new unsigned char[led_count * 3];
|
||||
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
|
||||
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
|
||||
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg, color_buf, led_count * 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
|
||||
delete[] color_buf;
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetDirect(unsigned char direct)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_DIRECT, direct);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg + ( 3 * led ), colors, 3);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg + (3 * led), colors, 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetMode(unsigned char mode, unsigned char speed, unsigned char direction)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_MODE, mode);
|
||||
AuraRegisterWrite(AURA_REG_SPEED, speed);
|
||||
AuraRegisterWrite(AURA_REG_DIRECTION, direction);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraUpdateDeviceName()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
device_name[i] = AuraRegisterRead(AURA_REG_DEVICE_NAME + i);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
struct nvme_passthru_cmd cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(nvme_passthru_cmd));
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
cfg.opcode = 0xFB;
|
||||
cfg.nsid = 0x00000031;
|
||||
cfg.cdw12 = (corrected_reg << 16) | (dev << 1);
|
||||
cfg.cdw13 = 0x01100001;
|
||||
cfg.data_len = 1;
|
||||
|
||||
unsigned char data[1];
|
||||
|
||||
data[0] = val;
|
||||
|
||||
unsigned char metadata[1];
|
||||
unsigned int result;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Send the command to the device |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
nvme_admin_passthru(nvme_fd, cfg.opcode, cfg.flags, cfg.rsvd1,
|
||||
cfg.nsid, cfg.cdw2, cfg.cdw3, cfg.cdw10,
|
||||
cfg.cdw11, cfg.cdw12, cfg.cdw13, cfg.cdw14,
|
||||
cfg.cdw15, cfg.data_len, data, cfg.metadata_len,
|
||||
metadata, cfg.timeout_ms, &result);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
struct nvme_passthru_cmd cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(nvme_passthru_cmd));
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
cfg.opcode = 0xFB;
|
||||
cfg.nsid = 0x00000031;
|
||||
cfg.cdw12 = (corrected_reg << 16) | (dev << 1);
|
||||
cfg.cdw13 = 0x03100000 | sz;
|
||||
cfg.data_len = sz;
|
||||
|
||||
unsigned char metadata[1];
|
||||
unsigned int result;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Send the command to the device |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
nvme_admin_passthru(nvme_fd, cfg.opcode, cfg.flags, cfg.rsvd1,
|
||||
cfg.nsid, cfg.cdw2, cfg.cdw3, cfg.cdw10,
|
||||
cfg.cdw11, cfg.cdw12, cfg.cdw13, cfg.cdw14,
|
||||
cfg.cdw15, cfg.data_len, data, cfg.metadata_len,
|
||||
metadata, cfg.timeout_ms, &result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GController.h |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define XPG_SPECTRIX_LED_COUNT ( 8 )
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char aura_dev_id;
|
||||
typedef unsigned short aura_register;
|
||||
|
||||
#define AURA_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
#define AURA_SAVE_VAL 0xAA /* Value for Save Changes */
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
|
||||
AURA_REG_MICRON_CHECK = 0x1030, /* If "Micron" appears here, skip */
|
||||
AURA_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
|
||||
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
AURA_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
AURA_REG_MODE = 0x8021, /* Mode Selection Register */
|
||||
AURA_REG_SPEED = 0x8022, /* Speed Control Register */
|
||||
AURA_REG_DIRECTION = 0x8023, /* Direction Control Register */
|
||||
AURA_REG_APPLY = 0x80A0, /* Apply Changes Register */
|
||||
AURA_REG_SLOT_INDEX = 0x80F8, /* Slot Index Register (RAM only) */
|
||||
AURA_REG_I2C_ADDRESS = 0x80F9, /* I2C Address Register (RAM only) */
|
||||
AURA_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
|
||||
AURA_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MODE_OFF = 0, /* OFF mode */
|
||||
AURA_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
AURA_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
AURA_MODE_CHASE = 9, /* Chase effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
AURA_NUMBER_MODES /* Number of Aura modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_SPEED_SLOWEST = 0x04, /* Slowest effect speed */
|
||||
AURA_SPEED_SLOW = 0x03, /* Slow effect speed */
|
||||
AURA_SPEED_NORMAL = 0x02, /* Normal effect speed */
|
||||
AURA_SPEED_FAST = 0x01, /* Fast effect speed */
|
||||
AURA_SPEED_FASTEST = 0x00, /* Fastest effect speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_DIRECTION_FORWARD = 0x0, /* Forward effect direction */
|
||||
AURA_DIRECTION_REVERSE = 0x1, /* Reverse effect direction */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
|
||||
AURA_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
|
||||
AURA_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
|
||||
AURA_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
|
||||
AURA_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
|
||||
AURA_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
struct nvme_passthru_cmd
|
||||
{
|
||||
uint8_t opcode;
|
||||
uint8_t flags;
|
||||
uint16_t rsvd1;
|
||||
uint32_t nsid;
|
||||
uint32_t cdw2;
|
||||
uint32_t cdw3;
|
||||
uint64_t metadata;
|
||||
uint64_t addr;
|
||||
uint32_t metadata_len;
|
||||
uint32_t data_len;
|
||||
uint32_t cdw10;
|
||||
uint32_t cdw11;
|
||||
uint32_t cdw12;
|
||||
uint32_t cdw13;
|
||||
uint32_t cdw14;
|
||||
uint32_t cdw15;
|
||||
uint32_t timeout_ms;
|
||||
uint32_t result;
|
||||
};
|
||||
|
||||
class XPGSpectrixS40GController
|
||||
{
|
||||
public:
|
||||
XPGSpectrixS40GController(int fd, aura_dev_id dev);
|
||||
~XPGSpectrixS40GController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned char GetChannel(unsigned int led);
|
||||
const char* GetChannelName(unsigned int led);
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
unsigned char GetLEDBlue(unsigned int led);
|
||||
void SaveMode();
|
||||
void SetAllColorsDirect(RGBColor* colors);
|
||||
void SetAllColorsEffect(RGBColor* colors);
|
||||
void SetDirect(unsigned char direct);
|
||||
void SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction);
|
||||
|
||||
void AuraUpdateDeviceName();
|
||||
|
||||
unsigned char AuraRegisterRead(aura_register reg);
|
||||
void AuraRegisterWrite(aura_register reg, unsigned char val);
|
||||
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
int nvme_fd;
|
||||
char device_name[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
aura_register direct_reg;
|
||||
aura_register effect_reg;
|
||||
unsigned char channel_cfg;
|
||||
aura_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_XPGSpectrixS40G.h"
|
||||
#include <vector>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
XPGSpectrixS40GController* new_controller;
|
||||
RGBController_XPGSpectrixS40G* new_rgbcontroller;
|
||||
|
||||
int nvme_fd = open("/dev/nvme0", O_RDWR);
|
||||
|
||||
if(nvme_fd > 0)
|
||||
{
|
||||
new_controller = new XPGSpectrixS40GController(nvme_fd, 0x67);
|
||||
new_rgbcontroller = new RGBController_XPGSpectrixS40G(new_controller);
|
||||
|
||||
rgb_controllers.push_back(new_rgbcontroller);
|
||||
}
|
||||
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
REGISTER_DETECTOR("XPG Spectrix S40G NVMe", DetectSpectrixS40GControllers);
|
||||
@@ -0,0 +1,431 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_XPGSpectrixS40G.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_XPGSpectrixS40G.h"
|
||||
|
||||
int RGBController_XPGSpectrixS40G::GetDeviceMode()
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Determine starting mode by reading the mode and direct registers |
|
||||
\*-----------------------------------------------------------------*/
|
||||
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
|
||||
int color_mode = MODE_COLORS_PER_LED;
|
||||
int speed = aura->AuraRegisterRead(AURA_REG_SPEED);
|
||||
int direction = aura->AuraRegisterRead(AURA_REG_DIRECTION);
|
||||
|
||||
if(aura->AuraRegisterRead(AURA_REG_DIRECT))
|
||||
{
|
||||
dev_mode = 0xFFFF;
|
||||
}
|
||||
|
||||
switch(dev_mode)
|
||||
{
|
||||
case AURA_MODE_OFF:
|
||||
case AURA_MODE_RAINBOW:
|
||||
case AURA_MODE_SPECTRUM_CYCLE:
|
||||
case AURA_MODE_RANDOM_FLICKER:
|
||||
color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE:
|
||||
dev_mode = AURA_MODE_CHASE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_BREATHING:
|
||||
dev_mode = AURA_MODE_BREATHING;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE:
|
||||
dev_mode = AURA_MODE_CHASE_FADE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
}
|
||||
|
||||
for(std::size_t mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
modes[mode].color_mode = color_mode;
|
||||
|
||||
if(modes[mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[mode].speed = speed;
|
||||
}
|
||||
|
||||
if(modes[mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
modes[mode].direction = direction;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceUpdateLEDs()
|
||||
{
|
||||
if(GetMode() == 0)
|
||||
{
|
||||
aura->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetAllColorsEffect(&colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for (std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++)
|
||||
{
|
||||
int led = zones[zone].leds[led_idx].value;
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_XPGSpectrixS40G::RGBController_XPGSpectrixS40G(XPGSpectrixS40GController * aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
version = aura->GetDeviceName();
|
||||
location = aura->GetDeviceLocation();
|
||||
if((version.find("DIMM_LED") != std::string::npos) || (version.find("AUDA") != std::string::npos) )
|
||||
{
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "ASUS Aura DRAM";
|
||||
}
|
||||
else
|
||||
{
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
name = "ASUS Aura Motherboard";
|
||||
}
|
||||
vendor = "ASUS";
|
||||
description = "ASUS Aura SMBus Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_MANUAL_SAVE;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = AURA_SPEED_SLOWEST;
|
||||
Breathing.speed_max = AURA_SPEED_FASTEST;
|
||||
Breathing.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
Flashing.speed_min = AURA_SPEED_SLOWEST;
|
||||
Flashing.speed_max = AURA_SPEED_FASTEST;
|
||||
Flashing.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.speed_min = AURA_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = AURA_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed_min = AURA_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = AURA_SPEED_FASTEST;
|
||||
Rainbow.speed = AURA_SPEED_NORMAL;
|
||||
Rainbow.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode ChaseFade;
|
||||
ChaseFade.name = "Chase Fade";
|
||||
ChaseFade.value = AURA_MODE_CHASE_FADE;
|
||||
ChaseFade.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
ChaseFade.color_mode = MODE_COLORS_PER_LED;
|
||||
ChaseFade.speed_min = AURA_SPEED_SLOWEST;
|
||||
ChaseFade.speed_max = AURA_SPEED_FASTEST;
|
||||
ChaseFade.speed = AURA_SPEED_NORMAL;
|
||||
ChaseFade.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_MANUAL_SAVE;
|
||||
Chase.color_mode = MODE_COLORS_PER_LED;
|
||||
Chase.speed_min = AURA_SPEED_SLOWEST;
|
||||
Chase.speed_max = AURA_SPEED_FASTEST;
|
||||
Chase.speed = AURA_SPEED_NORMAL;
|
||||
ChaseFade.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode RandomFlicker;
|
||||
RandomFlicker.name = "Random Flicker";
|
||||
RandomFlicker.value = AURA_MODE_RANDOM_FLICKER;
|
||||
RandomFlicker.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
RandomFlicker.color_mode = MODE_COLORS_NONE;
|
||||
RandomFlicker.speed_min = AURA_SPEED_SLOWEST;
|
||||
RandomFlicker.speed_max = AURA_SPEED_FASTEST;
|
||||
RandomFlicker.speed = AURA_SPEED_NORMAL;
|
||||
modes.push_back(RandomFlicker);
|
||||
|
||||
SetupZones();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Initialize active mode |
|
||||
\*-------------------------------------------------*/
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
RGBController_XPGSpectrixS40G::~RGBController_XPGSpectrixS40G()
|
||||
{
|
||||
delete aura;
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::SetupZones()
|
||||
{
|
||||
std::vector<int> aura_led_map;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Search through all LEDs and create zones for each channel |
|
||||
| type |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t led_idx = 0; led_idx < aura->GetLEDCount(); led_idx++)
|
||||
{
|
||||
bool matched = false;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Search through existing zones to make sure we don't |
|
||||
| create a duplicate zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t existing_zone_idx = 0; existing_zone_idx < zones.size(); existing_zone_idx++)
|
||||
{
|
||||
if (aura->GetChannelName(led_idx) == zones[existing_zone_idx].name)
|
||||
{
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If zone does not already exist, create it |
|
||||
\*---------------------------------------------------------*/
|
||||
if (matched == false)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set zone name to channel name |
|
||||
\*---------------------------------------------------------*/
|
||||
new_zone->name = aura->GetChannelName(led_idx);
|
||||
|
||||
new_zone->leds_count = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Find all LEDs with this channel type and add them to zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for (std::size_t zone_led_idx = 0; zone_led_idx < aura->GetLEDCount(); zone_led_idx++)
|
||||
{
|
||||
if (aura->GetChannelName(zone_led_idx) == new_zone->name)
|
||||
{
|
||||
new_zone->leds_count++;
|
||||
aura_led_map.push_back(zone_led_idx);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Aura zones have fixed size, so set min and max to count |
|
||||
\*---------------------------------------------------------*/
|
||||
new_zone->leds_min = new_zone->leds_count;
|
||||
new_zone->leds_max = new_zone->leds_count;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If this zone has more than one LED, mark it as linear type|
|
||||
\*---------------------------------------------------------*/
|
||||
if(new_zone->leds_count > 1)
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new zone to zones vector |
|
||||
\*---------------------------------------------------------*/
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create LED entries for each zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = zones[zone_idx].name + " LED ";
|
||||
new_led->name.append(std::to_string(led_idx + 1));
|
||||
|
||||
new_led->value = aura_led_map[led_idx];
|
||||
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize colors for each LED |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
unsigned int led = leds[led_idx].value;
|
||||
unsigned char red = aura->GetLEDRed(led);
|
||||
unsigned char grn = aura->GetLEDGreen(led);
|
||||
unsigned char blu = aura->GetLEDBlue(led);
|
||||
|
||||
colors[led_idx] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceUpdateMode()
|
||||
{
|
||||
if (modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int new_mode = modes[active_mode].value;
|
||||
int new_speed = 0;
|
||||
int new_direction = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_RANDOM)
|
||||
{
|
||||
switch(new_mode)
|
||||
{
|
||||
case AURA_MODE_CHASE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE;
|
||||
break;
|
||||
case AURA_MODE_BREATHING:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_BREATHING;
|
||||
break;
|
||||
case AURA_MODE_CHASE_FADE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
new_speed = modes[active_mode].speed;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
new_direction = AURA_DIRECTION_FORWARD;
|
||||
break;
|
||||
|
||||
case MODE_DIRECTION_RIGHT:
|
||||
new_direction = AURA_DIRECTION_REVERSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aura->SetMode(new_mode, new_speed, new_direction);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_XPGSpectrixS40G::DeviceSaveMode()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
aura->SaveMode();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_XPGSpectrixS40G.h |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
|
||||
class RGBController_XPGSpectrixS40G : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_XPGSpectrixS40G(XPGSpectrixS40GController* spectrix_ptr);
|
||||
~RGBController_XPGSpectrixS40G();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
int GetDeviceMode();
|
||||
|
||||
private:
|
||||
XPGSpectrixS40GController* aura;
|
||||
};
|
||||
@@ -0,0 +1,575 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GController.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
#include <malloc.h>
|
||||
#include <cstring>
|
||||
#include "LogManager.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include <winioctl.h>
|
||||
#include <nvme.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
int XPGSpectrixS40GController::SetHandle(wchar_t buff[MAX_PATH])
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
|
||||
wcscpy(path, L"\\\\?\\");
|
||||
wcsncat(path, buff, MAX_PATH - 4);
|
||||
|
||||
for(size_t i = 0; i < MAX_PATH && path[i] != '\0'; i++)
|
||||
{
|
||||
path[i] = tolower(path[i]);
|
||||
}
|
||||
|
||||
wprintf(L"%s\n", path);
|
||||
|
||||
hDevice = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)0x0, OPEN_EXISTING, 0x0, (HANDLE)0x0);
|
||||
|
||||
if(hDevice == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
#include <cstring>
|
||||
|
||||
static const char* aura_channels[] = /* Aura channel strings */
|
||||
{
|
||||
"Audio",
|
||||
"Backplate",
|
||||
"Back I/O",
|
||||
"Center",
|
||||
"Center",
|
||||
"DRAM",
|
||||
"PCIe",
|
||||
"RGB Header",
|
||||
"RGB Header 2",
|
||||
"RGB Header",
|
||||
"Unknown",
|
||||
};
|
||||
|
||||
XPGSpectrixS40GController::XPGSpectrixS40GController(wchar_t dev_name[MAX_PATH], aura_dev_id dev)
|
||||
{
|
||||
this->dev = dev;
|
||||
|
||||
SetHandle(dev_name);
|
||||
|
||||
AuraUpdateDeviceName();
|
||||
|
||||
// Read the device configuration table
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
config_table[i] = AuraRegisterRead(AURA_REG_CONFIG_TABLE + i);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| If this is running with TRACE or higher loglevel then |
|
||||
| dump the entire Feature list to log |
|
||||
\*-----------------------------------------------------------------*/
|
||||
if(LogManager::get()->getLoglevel() >= LL_TRACE)
|
||||
{
|
||||
LOG_TRACE("[ENE SMBus] ENE config table for 0x%02X:", dev);
|
||||
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[0], config_table[1], config_table[2], config_table[3],
|
||||
config_table[4], config_table[5], config_table[6], config_table[7],
|
||||
config_table[8], config_table[9], config_table[10], config_table[11],
|
||||
config_table[12], config_table[13], config_table[14], config_table[15]);
|
||||
|
||||
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[16], config_table[17], config_table[18], config_table[19],
|
||||
config_table[20], config_table[21], config_table[22], config_table[23],
|
||||
config_table[24], config_table[25], config_table[26], config_table[27],
|
||||
config_table[28], config_table[29], config_table[30], config_table[31]);
|
||||
|
||||
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[32], config_table[33], config_table[34], config_table[35],
|
||||
config_table[36], config_table[37], config_table[38], config_table[39],
|
||||
config_table[40], config_table[41], config_table[42], config_table[43],
|
||||
config_table[44], config_table[45], config_table[46], config_table[47]);
|
||||
|
||||
LOG_TRACE(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", config_table[48], config_table[49], config_table[50], config_table[51],
|
||||
config_table[52], config_table[53], config_table[54], config_table[55],
|
||||
config_table[56], config_table[57], config_table[58], config_table[59],
|
||||
config_table[60], config_table[61], config_table[62], config_table[63]);
|
||||
}
|
||||
|
||||
// Read LED count from configuration table
|
||||
led_count = config_table[AURA_CONFIG_LED_COUNT];
|
||||
|
||||
// LED-0116 - First generation motherboard controller
|
||||
if (strcmp(device_name, "LED-0116") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// DIMM_LED-0102 - First generation DRAM controller (Trident Z RGB)
|
||||
else if (strcmp(device_name, "DIMM_LED-0102") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// AUDA0-E6K5-0101 - Second generation DRAM controller (Geil Super Luce)
|
||||
else if (strcmp(device_name, "AUDA0-E6K5-0101") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// AUMA0-E6K5-0106 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0106") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0105 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0105") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0104 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0104") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E8K4-0101 - First generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E8K4-0101") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// AUMA0-E6K5-0107 - Second generation GPU controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0107") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
|
||||
// Read LED count from configuration table
|
||||
//led_count = config_table[ENE_CONFIG_LED_COUNT_0107];
|
||||
}
|
||||
// AUDA0-E6K5--100 - Second generation NVMe SSD controller
|
||||
else if (strcmp(device_name, "AUDA0-E6K5--100") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// Assume first generation controller if string does not match
|
||||
else
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
XPGSpectrixS40GController::~XPGSpectrixS40GController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string XPGSpectrixS40GController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string XPGSpectrixS40GController::GetDeviceLocation()
|
||||
{
|
||||
return("SSD");
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetChannel(unsigned int led)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
const char * XPGSpectrixS40GController::GetChannelName(unsigned int led)
|
||||
{
|
||||
switch (config_table[channel_cfg + led])
|
||||
{
|
||||
case (unsigned char)AURA_LED_CHANNEL_AUDIO:
|
||||
return(aura_channels[0]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACKPLATE:
|
||||
return(aura_channels[1]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACK_IO:
|
||||
return(aura_channels[2]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER:
|
||||
return(aura_channels[3]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER_START:
|
||||
return(aura_channels[4]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_DRAM:
|
||||
return(aura_channels[5]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_PCIE:
|
||||
return(aura_channels[6]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER:
|
||||
return(aura_channels[7]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_2:
|
||||
return(aura_channels[8]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_3:
|
||||
return(aura_channels[9]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(aura_channels[10]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int XPGSpectrixS40GController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDRed(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led )));
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDGreen(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::GetLEDBlue(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SaveMode()
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_SAVE_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetAllColorsDirect(RGBColor* colors)
|
||||
{
|
||||
unsigned char* color_buf = new unsigned char[led_count * 3];
|
||||
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
|
||||
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
|
||||
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg, color_buf, led_count * 3);
|
||||
|
||||
delete color_buf;
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetAllColorsEffect(RGBColor* colors)
|
||||
{
|
||||
unsigned char* color_buf = new unsigned char[led_count * 3];
|
||||
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
|
||||
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
|
||||
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg, color_buf, led_count * 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
|
||||
delete[] color_buf;
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetDirect(unsigned char direct)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_DIRECT, direct);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg + ( 3 * led ), colors, 3);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg + (3 * led), colors, 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::SetMode(unsigned char mode, unsigned char speed, unsigned char direction)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_MODE, mode);
|
||||
AuraRegisterWrite(AURA_REG_SPEED, speed);
|
||||
AuraRegisterWrite(AURA_REG_DIRECTION, direction);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraUpdateDeviceName()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
device_name[i] = AuraRegisterRead(AURA_REG_DEVICE_NAME + i);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char XPGSpectrixS40GController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
if(hDevice != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold STORAGE_PROTOCOL_COMMAND |
|
||||
| Size must be enough for the STORAGE_PROTOCOL_COMMAND struct plus the command |
|
||||
| data. Subtract sizeof(DWORD) as the Command field in the structure overlaps |
|
||||
| the actual command data. |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char buffer[sizeof(STORAGE_PROTOCOL_COMMAND) + (sizeof(DWORD) * 34) - sizeof(DWORD)] = {0};
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create STORAGE_PROTOCOL_COMMAND pointer and point it to the buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PSTORAGE_PROTOCOL_COMMAND command = (PSTORAGE_PROTOCOL_COMMAND)buffer;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Fill in STORAGE_PROTOCOL_COMMAND structure |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
command->Version = STORAGE_PROTOCOL_STRUCTURE_VERSION;
|
||||
command->Length = sizeof(STORAGE_PROTOCOL_COMMAND);
|
||||
command->ProtocolType = ProtocolTypeNvme;
|
||||
command->Flags = STORAGE_PROTOCOL_COMMAND_FLAG_ADAPTER_REQUEST;
|
||||
command->ReturnStatus = 0x00000000;
|
||||
command->ErrorCode = 0x00000000;
|
||||
command->CommandLength = STORAGE_PROTOCOL_COMMAND_LENGTH_NVME;
|
||||
command->ErrorInfoLength = 0x00000040;
|
||||
command->DataToDeviceTransferLength = 0x00000000;
|
||||
command->DataFromDeviceTransferLength = 0x00000001;
|
||||
command->TimeOutValue = 0x00000001;
|
||||
command->ErrorInfoOffset = 0x00000090;
|
||||
command->DataToDeviceBufferOffset = 0x00000000;
|
||||
command->DataFromDeviceBufferOffset = 0x000000D0;
|
||||
command->CommandSpecific = STORAGE_PROTOCOL_SPECIFIC_NVME_ADMIN_COMMAND;
|
||||
command->Reserved0 = 0x00000000;
|
||||
command->FixedProtocolReturnData = 0x00000000;
|
||||
command->Reserved1[0] = 0x00000000;
|
||||
command->Reserved1[1] = 0x00000000;
|
||||
command->Reserved1[2] = 0x00000000;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create ENE Register Write command, filling in the appropriate register and |
|
||||
| value |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PNVME_COMMAND CommandValue = (PNVME_COMMAND)command->Command;
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
CommandValue->CDW0.OPC = 0xFA;
|
||||
CommandValue->u.GENERAL.CDW12 = (corrected_reg << 16) | (dev << 1);
|
||||
CommandValue->u.GENERAL.CDW13 = 0x81100001;
|
||||
|
||||
DWORD ExtraValue[18] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Send the STORAGE_PROTOCOL_COMMAND to the device |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
DWORD bytesreturned = 0;
|
||||
bool result = DeviceIoControl(hDevice, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), &bytesreturned, (LPOVERLAPPED)0x0);
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Copy the ENE Register Write extra data into the STORAGE_PROTOCOL_COMMAND |
|
||||
| buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
memcpy(ExtraValue, &command->Command + sizeof(NVME_COMMAND), sizeof(ExtraValue));
|
||||
|
||||
return(ExtraValue[16]);
|
||||
}
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
if(hDevice != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold STORAGE_PROTOCOL_COMMAND |
|
||||
| Size must be enough for the STORAGE_PROTOCOL_COMMAND struct plus the command |
|
||||
| data. Subtract sizeof(DWORD) as the Command field in the structure overlaps |
|
||||
| the actual command data. |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char buffer[sizeof(STORAGE_PROTOCOL_COMMAND) + (sizeof(DWORD) * 34) - sizeof(DWORD)];
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create STORAGE_PROTOCOL_COMMAND pointer and point it to the buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PSTORAGE_PROTOCOL_COMMAND command = (PSTORAGE_PROTOCOL_COMMAND)buffer;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Fill in STORAGE_PROTOCOL_COMMAND structure |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
command->Version = STORAGE_PROTOCOL_STRUCTURE_VERSION;
|
||||
command->Length = sizeof(STORAGE_PROTOCOL_COMMAND);
|
||||
command->ProtocolType = ProtocolTypeNvme;
|
||||
command->Flags = STORAGE_PROTOCOL_COMMAND_FLAG_ADAPTER_REQUEST;
|
||||
command->ReturnStatus = 0x00000000;
|
||||
command->ErrorCode = 0x00000000;
|
||||
command->CommandLength = STORAGE_PROTOCOL_COMMAND_LENGTH_NVME;
|
||||
command->ErrorInfoLength = 0x00000040;
|
||||
command->DataToDeviceTransferLength = 0x00000001;
|
||||
command->DataFromDeviceTransferLength = 0x00000000;
|
||||
command->TimeOutValue = 0x00000001;
|
||||
command->ErrorInfoOffset = 0x00000090;
|
||||
command->DataToDeviceBufferOffset = 0x000000D0;
|
||||
command->DataFromDeviceBufferOffset = 0x00000000;
|
||||
command->CommandSpecific = STORAGE_PROTOCOL_SPECIFIC_NVME_ADMIN_COMMAND;
|
||||
command->Reserved0 = 0x00000000;
|
||||
command->FixedProtocolReturnData = 0x00000000;
|
||||
command->Reserved1[0] = 0x00000000;
|
||||
command->Reserved1[1] = 0x00000000;
|
||||
command->Reserved1[2] = 0x00000000;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create ENE Register Write command, filling in the appropriate register and |
|
||||
| value |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PNVME_COMMAND CommandValue = (PNVME_COMMAND)command->Command;
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
CommandValue->CDW0.OPC = 0xFB;
|
||||
CommandValue->u.GENERAL.CDW12 = (corrected_reg << 16) | (dev << 1);
|
||||
CommandValue->u.GENERAL.CDW13 = 0x01100001;
|
||||
|
||||
DWORD ExtraValue[18] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
|
||||
ExtraValue[16] = val;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Copy the ENE Register Write extra data into the STORAGE_PROTOCOL_COMMAND |
|
||||
| buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
memcpy(&command->Command + sizeof(NVME_COMMAND), ExtraValue, sizeof(ExtraValue));
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Send the STORAGE_PROTOCOL_COMMAND to the device |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
DeviceIoControl(hDevice, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
|
||||
void XPGSpectrixS40GController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
if(hDevice != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold STORAGE_PROTOCOL_COMMAND |
|
||||
| Size must be enough for the STORAGE_PROTOCOL_COMMAND struct plus the command |
|
||||
| data. Subtract sizeof(DWORD) as the Command field in the structure overlaps |
|
||||
| the actual command data. |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char buffer[sizeof(STORAGE_PROTOCOL_COMMAND) + (sizeof(DWORD) * 39) - sizeof(DWORD)];
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create STORAGE_PROTOCOL_COMMAND pointer and point it to the buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PSTORAGE_PROTOCOL_COMMAND command = (PSTORAGE_PROTOCOL_COMMAND)buffer;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Fill in STORAGE_PROTOCOL_COMMAND structure |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
command->Version = STORAGE_PROTOCOL_STRUCTURE_VERSION;
|
||||
command->Length = sizeof(STORAGE_PROTOCOL_COMMAND);
|
||||
command->ProtocolType = ProtocolTypeNvme;
|
||||
command->Flags = STORAGE_PROTOCOL_COMMAND_FLAG_ADAPTER_REQUEST;
|
||||
command->ReturnStatus = 0x00000000;
|
||||
command->ErrorCode = 0x00000000;
|
||||
command->CommandLength = STORAGE_PROTOCOL_COMMAND_LENGTH_NVME;
|
||||
command->ErrorInfoLength = 0x00000040;
|
||||
command->DataToDeviceTransferLength = sz;
|
||||
command->DataFromDeviceTransferLength = 0x00000000;
|
||||
command->TimeOutValue = 0x00000001;
|
||||
command->ErrorInfoOffset = 0x00000090;
|
||||
command->DataToDeviceBufferOffset = 0x000000D0;
|
||||
command->DataFromDeviceBufferOffset = 0x00000000;
|
||||
command->CommandSpecific = STORAGE_PROTOCOL_SPECIFIC_NVME_ADMIN_COMMAND;
|
||||
command->Reserved0 = 0x00000000;
|
||||
command->FixedProtocolReturnData = 0x00000000;
|
||||
command->Reserved1[0] = 0x00000000;
|
||||
command->Reserved1[1] = 0x00000000;
|
||||
command->Reserved1[2] = 0x00000000;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create ENE Register Write Block command, filling in the appropriate register |
|
||||
| and value |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
PNVME_COMMAND CommandValue = (PNVME_COMMAND)command->Command;
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
CommandValue->CDW0.OPC = 0xFB;
|
||||
CommandValue->u.GENERAL.CDW12 = (corrected_reg << 16) | (dev << 1);
|
||||
CommandValue->u.GENERAL.CDW13 = 0x03100000 | sz;
|
||||
|
||||
DWORD ExtraValue[23] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000 };
|
||||
|
||||
memcpy(&ExtraValue[16], data, sz);
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Copy the ENE Register Write Block extra data into the |
|
||||
| STORAGE_PROTOCOL_COMMAND buffer |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
memcpy(&command->Command + sizeof(NVME_COMMAND), ExtraValue, sizeof(ExtraValue));
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Send the STORAGE_PROTOCOL_COMMAND to the device |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
DeviceIoControl(hDevice, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GController.h |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define XPG_SPECTRIX_LED_COUNT ( 8 )
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char aura_dev_id;
|
||||
typedef unsigned short aura_register;
|
||||
|
||||
#define AURA_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
#define AURA_SAVE_VAL 0xAA /* Value for Save Changes */
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
|
||||
AURA_REG_MICRON_CHECK = 0x1030, /* If "Micron" appears here, skip */
|
||||
AURA_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
|
||||
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
AURA_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
AURA_REG_MODE = 0x8021, /* Mode Selection Register */
|
||||
AURA_REG_SPEED = 0x8022, /* Speed Control Register */
|
||||
AURA_REG_DIRECTION = 0x8023, /* Direction Control Register */
|
||||
AURA_REG_APPLY = 0x80A0, /* Apply Changes Register */
|
||||
AURA_REG_SLOT_INDEX = 0x80F8, /* Slot Index Register (RAM only) */
|
||||
AURA_REG_I2C_ADDRESS = 0x80F9, /* I2C Address Register (RAM only) */
|
||||
AURA_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
|
||||
AURA_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MODE_OFF = 0, /* OFF mode */
|
||||
AURA_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
AURA_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
AURA_MODE_CHASE = 9, /* Chase effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
AURA_NUMBER_MODES /* Number of Aura modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_SPEED_SLOWEST = 0x04, /* Slowest effect speed */
|
||||
AURA_SPEED_SLOW = 0x03, /* Slow effect speed */
|
||||
AURA_SPEED_NORMAL = 0x02, /* Normal effect speed */
|
||||
AURA_SPEED_FAST = 0x01, /* Fast effect speed */
|
||||
AURA_SPEED_FASTEST = 0x00, /* Fastest effect speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_DIRECTION_FORWARD = 0x0, /* Forward effect direction */
|
||||
AURA_DIRECTION_REVERSE = 0x1, /* Reverse effect direction */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
|
||||
AURA_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
|
||||
AURA_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
|
||||
AURA_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
|
||||
AURA_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
|
||||
AURA_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
class XPGSpectrixS40GController
|
||||
{
|
||||
public:
|
||||
XPGSpectrixS40GController(wchar_t dev_name[MAX_PATH], aura_dev_id dev);
|
||||
~XPGSpectrixS40GController();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Windows specific function that allows the devices |
|
||||
| handle to be passed from elsewhere once detected |
|
||||
\*-----------------------------------------------------*/
|
||||
int SetHandle(wchar_t dev_name[MAX_PATH]);
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned char GetChannel(unsigned int led);
|
||||
const char* GetChannelName(unsigned int led);
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
unsigned char GetLEDBlue(unsigned int led);
|
||||
void SaveMode();
|
||||
void SetAllColorsDirect(RGBColor* colors);
|
||||
void SetAllColorsEffect(RGBColor* colors);
|
||||
void SetDirect(unsigned char direct);
|
||||
void SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction);
|
||||
|
||||
void AuraUpdateDeviceName();
|
||||
|
||||
unsigned char AuraRegisterRead(aura_register reg);
|
||||
void AuraRegisterWrite(aura_register reg, unsigned char val);
|
||||
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
HANDLE hDevice;
|
||||
char device_name[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
aura_register direct_reg;
|
||||
aura_register effect_reg;
|
||||
unsigned char channel_cfg;
|
||||
aura_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| XPGSpectrixS40GControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for XPG's Spectrix S40G NVMe |
|
||||
| |
|
||||
| NicolasNewman 25th Mar 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "XPGSpectrixS40GController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_XPGSpectrixS40G.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define DEVBUFSIZE (128 * 1024)
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
|
||||
int Search(wchar_t *dev_name)
|
||||
{
|
||||
wchar_t buff[DEVBUFSIZE] = L"";
|
||||
int wchar_count;
|
||||
|
||||
wchar_count = QueryDosDeviceW(NULL, buff, DEVBUFSIZE);
|
||||
|
||||
if(wchar_count == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < wchar_count; i++)
|
||||
{
|
||||
if(wcsstr(buff + i, L"SCSI#Disk&Ven_NVMe&Prod_XPG_SPECTRIX_S40#"))
|
||||
{
|
||||
wcsncpy(dev_name, buff + i, MAX_PATH);
|
||||
(dev_name)[MAX_PATH - 1] = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += wcslen(buff + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectXPGSpectrixS40GControllers *
|
||||
* *
|
||||
* Tests for the existance of a file descriptor matching *
|
||||
* SCSI#Disk&Ven_NVMe&Prod_XPG_SPECTRIX_S40# on Windows machines *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
XPGSpectrixS40GController* new_xpg_s40g;
|
||||
RGBController_XPGSpectrixS40G* new_controller;
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices
|
||||
wchar_t dev_name[MAX_PATH];
|
||||
|
||||
if(Search(dev_name))
|
||||
{
|
||||
new_xpg_s40g = new XPGSpectrixS40GController(dev_name, 0x67);
|
||||
|
||||
new_controller = new RGBController_XPGSpectrixS40G(new_xpg_s40g);
|
||||
|
||||
new_controller->name = "XPG Spectrix S40G";
|
||||
new_controller->vendor = "XPG";
|
||||
new_controller->type = DEVICE_TYPE_STORAGE;
|
||||
|
||||
rgb_controllers.push_back(new_controller);
|
||||
|
||||
}
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
REGISTER_DETECTOR("XPG Spectrix S40G NVMe", DetectSpectrixS40GControllers);
|
||||
+12
@@ -936,6 +936,7 @@ win32:INCLUDEPATH +=
|
||||
dependencies/openrazer-win32 \
|
||||
wmi/ \
|
||||
Controllers/AsusTUFLaptopController \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/ \
|
||||
|
||||
win32:SOURCES += \
|
||||
# dependencies/hidapi/hidapi.c \
|
||||
@@ -1038,6 +1039,9 @@ win32:SOURCES +=
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.cpp \
|
||||
Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazerWindows.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/XPGSpectrixS40GController.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/XPGSpectrixS40GControllerDetect.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/RGBController_XPGSpectrixS40G.cpp \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/display-library/include/adl_defines.h \
|
||||
@@ -1054,6 +1058,8 @@ win32:HEADERS +=
|
||||
AutoStart/AutoStart-Windows.h \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.h \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazerWindows.h \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/XPGSpectrixS40GController.h \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/RGBController_XPGSpectrixS40G.h \
|
||||
|
||||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
LIBS += \
|
||||
@@ -1137,6 +1143,7 @@ unix:!macx {
|
||||
INCLUDEPATH += \
|
||||
Controllers/FaustusController \
|
||||
Controllers/LinuxLEDController \
|
||||
Controllers/XPGSpectrixS40GControllerWindows/ \
|
||||
|
||||
HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
@@ -1145,6 +1152,8 @@ unix:!macx {
|
||||
Controllers/LinuxLEDController/LinuxLEDController.h \
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.h \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazer.h \
|
||||
Controllers/XPGSpectrixS40GControllerLinux/XPGSpectrixS40GController.h \
|
||||
Controllers/XPGSpectrixS40GControllerLinux/RGBController_XPGSpectrixS40G.h \
|
||||
|
||||
LIBS += \
|
||||
-lusb-1.0 \
|
||||
@@ -1191,6 +1200,9 @@ unix:!macx {
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.cpp \
|
||||
Controllers/OpenRazerController/OpenRazerDetect.cpp \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazer.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerLinux/XPGSpectrixS40GController.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerLinux/XPGSpectrixS40GControllerDetect.cpp \
|
||||
Controllers/XPGSpectrixS40GControllerLinux/RGBController_XPGSpectrixS40G.cpp \
|
||||
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
# Set up install paths #
|
||||
|
||||
@@ -1605,6 +1605,8 @@ std::string device_type_to_str(device_type type)
|
||||
return "Light";
|
||||
case DEVICE_TYPE_SPEAKER:
|
||||
return "Speaker";
|
||||
case DEVICE_TYPE_STORAGE:
|
||||
return "Storage";
|
||||
case DEVICE_TYPE_VIRTUAL:
|
||||
return "Virtual";
|
||||
default:
|
||||
|
||||
@@ -131,6 +131,7 @@ enum
|
||||
DEVICE_TYPE_LIGHT,
|
||||
DEVICE_TYPE_SPEAKER,
|
||||
DEVICE_TYPE_VIRTUAL,
|
||||
DEVICE_TYPE_STORAGE,
|
||||
DEVICE_TYPE_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ static QString GetIconString(device_type type, bool dark)
|
||||
case DEVICE_TYPE_VIRTUAL:
|
||||
filename = "virtual";
|
||||
break;
|
||||
case DEVICE_TYPE_STORAGE:
|
||||
filename = "storage";
|
||||
break;
|
||||
default:
|
||||
filename = "unknown";
|
||||
break;
|
||||
|
||||
@@ -46,5 +46,7 @@
|
||||
<file>wireless_dark.png</file>
|
||||
<file>console.png</file>
|
||||
<file>console_dark.png</file>
|
||||
<file>storage.png</file>
|
||||
<file>storage_dark.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Reference in New Issue
Block a user