Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s
Managed validation / full (push) Failing after 8s
This commit is contained in:
1 parent
91f8b3e3c1
commit
def7920856
2271 files changed
+501225
-501178
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,146 +1,146 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusController.h |
|
||||
| |
|
||||
| Driver for ENE SMBus devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 19 Aug 2018 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#define ENE_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
#define ENE_SAVE_VAL 0xAA /* Value for Save Changes */
|
||||
#define ENE_NUM_ZONES 8 /* Number of ENE config table zones */
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
|
||||
ENE_REG_MICRON_CHECK = 0x1030, /* If "Micron" appears here, skip */
|
||||
ENE_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
|
||||
ENE_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
ENE_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
ENE_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
ENE_REG_MODE = 0x8021, /* Mode Selection Register */
|
||||
ENE_REG_SPEED = 0x8022, /* Speed Control Register */
|
||||
ENE_REG_DIRECTION = 0x8023, /* Direction Control Register */
|
||||
ENE_REG_APPLY = 0x80A0, /* Apply Changes Register */
|
||||
ENE_REG_SLOT_INDEX = 0x80F8, /* Slot Index Register (RAM only) */
|
||||
ENE_REG_I2C_ADDRESS = 0x80F9, /* I2C Address Register (RAM only) */
|
||||
ENE_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
|
||||
ENE_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_MODE_OFF = 0, /* OFF mode */
|
||||
ENE_MODE_STATIC = 1, /* Static color mode */
|
||||
ENE_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
ENE_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
ENE_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
ENE_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
ENE_MODE_CHASE = 9, /* Chase effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
ENE_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
ENE_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
ENE_MODE_DOUBLE_FADE = 14, /* Rainbow fade to dual color */
|
||||
ENE_NUMBER_MODES /* Number of Aura modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_SPEED_SLOWEST = 0x04, /* Slowest effect speed */
|
||||
ENE_SPEED_SLOW = 0x03, /* Slow effect speed */
|
||||
ENE_SPEED_NORMAL = 0x02, /* Normal effect speed */
|
||||
ENE_SPEED_FAST = 0x01, /* Fast effect speed */
|
||||
ENE_SPEED_FASTEST = 0x00, /* Fastest effect speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_DIRECTION_FORWARD = 0x0, /* Forward effect direction */
|
||||
ENE_DIRECTION_REVERSE = 0x1, /* Reverse effect direction */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_DRAM_3 = 0x0E, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
|
||||
ENE_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
|
||||
ENE_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
|
||||
ENE_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
|
||||
ENE_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
|
||||
ENE_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
ENE_CONFIG_LED_COUNT_0107 = 0x03, /* LED Count configuration offset */
|
||||
ENE_CONFIG_LED_COUNT_1110 = 0x03, /* LED Count configuration offset */
|
||||
ENE_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
|
||||
ENE_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
class ENESMBusController
|
||||
{
|
||||
public:
|
||||
ENESMBusController(ENESMBusInterface* interface, ene_dev_id dev, std::string dev_name, device_type dev_type);
|
||||
~ENESMBusController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetName();
|
||||
std::string GetVersion();
|
||||
device_type GetType();
|
||||
|
||||
const char* GetChannelName(unsigned int cfg_zone);
|
||||
unsigned int GetLEDCount(unsigned int cfg_zone);
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
unsigned char GetLEDBlue(unsigned int led);
|
||||
unsigned char GetLEDRedEffect(unsigned int led);
|
||||
unsigned char GetLEDGreenEffect(unsigned int led);
|
||||
unsigned char GetLEDBlueEffect(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);
|
||||
bool SupportsMode14();
|
||||
|
||||
void UpdateDeviceName();
|
||||
|
||||
unsigned char ENERegisterRead(ene_register reg);
|
||||
void ENERegisterWrite(ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
char device_version[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
ene_register direct_reg;
|
||||
ene_register effect_reg;
|
||||
unsigned char channel_cfg;
|
||||
ENESMBusInterface* interface;
|
||||
ene_dev_id dev;
|
||||
bool supports_mode_14;
|
||||
std::string name;
|
||||
device_type type;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusController.h |
|
||||
| |
|
||||
| Driver for ENE SMBus devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 19 Aug 2018 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#define ENE_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
#define ENE_SAVE_VAL 0xAA /* Value for Save Changes */
|
||||
#define ENE_NUM_ZONES 8 /* Number of ENE config table zones */
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
|
||||
ENE_REG_MICRON_CHECK = 0x1030, /* If "Micron" appears here, skip */
|
||||
ENE_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
|
||||
ENE_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
ENE_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
ENE_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
ENE_REG_MODE = 0x8021, /* Mode Selection Register */
|
||||
ENE_REG_SPEED = 0x8022, /* Speed Control Register */
|
||||
ENE_REG_DIRECTION = 0x8023, /* Direction Control Register */
|
||||
ENE_REG_APPLY = 0x80A0, /* Apply Changes Register */
|
||||
ENE_REG_SLOT_INDEX = 0x80F8, /* Slot Index Register (RAM only) */
|
||||
ENE_REG_I2C_ADDRESS = 0x80F9, /* I2C Address Register (RAM only) */
|
||||
ENE_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
|
||||
ENE_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_MODE_OFF = 0, /* OFF mode */
|
||||
ENE_MODE_STATIC = 1, /* Static color mode */
|
||||
ENE_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
ENE_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
ENE_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
ENE_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
ENE_MODE_CHASE = 9, /* Chase effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
ENE_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
ENE_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
ENE_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
ENE_MODE_DOUBLE_FADE = 14, /* Rainbow fade to dual color */
|
||||
ENE_NUMBER_MODES /* Number of Aura modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_SPEED_SLOWEST = 0x04, /* Slowest effect speed */
|
||||
ENE_SPEED_SLOW = 0x03, /* Slow effect speed */
|
||||
ENE_SPEED_NORMAL = 0x02, /* Normal effect speed */
|
||||
ENE_SPEED_FAST = 0x01, /* Fast effect speed */
|
||||
ENE_SPEED_FASTEST = 0x00, /* Fastest effect speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_DIRECTION_FORWARD = 0x0, /* Forward effect direction */
|
||||
ENE_DIRECTION_REVERSE = 0x1, /* Reverse effect direction */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_DRAM_3 = 0x0E, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
|
||||
ENE_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
|
||||
ENE_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
|
||||
ENE_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
|
||||
ENE_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
|
||||
ENE_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
|
||||
ENE_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
|
||||
ENE_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENE_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
ENE_CONFIG_LED_COUNT_0107 = 0x03, /* LED Count configuration offset */
|
||||
ENE_CONFIG_LED_COUNT_1110 = 0x03, /* LED Count configuration offset */
|
||||
ENE_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
|
||||
ENE_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
class ENESMBusController
|
||||
{
|
||||
public:
|
||||
ENESMBusController(ENESMBusInterface* interface, ene_dev_id dev, std::string dev_name, device_type dev_type);
|
||||
~ENESMBusController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetName();
|
||||
std::string GetVersion();
|
||||
device_type GetType();
|
||||
|
||||
const char* GetChannelName(unsigned int cfg_zone);
|
||||
unsigned int GetLEDCount(unsigned int cfg_zone);
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
unsigned char GetLEDBlue(unsigned int led);
|
||||
unsigned char GetLEDRedEffect(unsigned int led);
|
||||
unsigned char GetLEDGreenEffect(unsigned int led);
|
||||
unsigned char GetLEDBlueEffect(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);
|
||||
bool SupportsMode14();
|
||||
|
||||
void UpdateDeviceName();
|
||||
|
||||
unsigned char ENERegisterRead(ene_register reg);
|
||||
void ENERegisterWrite(ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
char device_version[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
ene_register direct_reg;
|
||||
ene_register effect_reg;
|
||||
unsigned char channel_cfg;
|
||||
ENESMBusInterface* interface;
|
||||
ene_dev_id dev;
|
||||
bool supports_mode_14;
|
||||
std::string name;
|
||||
device_type type;
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,41 +1,41 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface.h |
|
||||
| |
|
||||
| ENE SMBus interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef unsigned short ene_register;
|
||||
typedef unsigned char ene_dev_id;
|
||||
typedef unsigned int ene_interface_type;
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Known interface types |
|
||||
\*-----------------------------------------*/
|
||||
enum
|
||||
{
|
||||
ENE_INTERFACE_TYPE_I2C_SMBUS,
|
||||
ENE_INTERFACE_TYPE_SPECTRIX_S40G,
|
||||
ENE_INTERFACE_TYPE_ROG_ARION,
|
||||
};
|
||||
|
||||
class ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ENESMBusInterface() = default;
|
||||
|
||||
virtual ene_interface_type GetInterfaceType() = 0;
|
||||
virtual std::string GetLocation() = 0;
|
||||
virtual int GetMaxBlock() = 0;
|
||||
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
|
||||
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
|
||||
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface.h |
|
||||
| |
|
||||
| ENE SMBus interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef unsigned short ene_register;
|
||||
typedef unsigned char ene_dev_id;
|
||||
typedef unsigned int ene_interface_type;
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Known interface types |
|
||||
\*-----------------------------------------*/
|
||||
enum
|
||||
{
|
||||
ENE_INTERFACE_TYPE_I2C_SMBUS,
|
||||
ENE_INTERFACE_TYPE_SPECTRIX_S40G,
|
||||
ENE_INTERFACE_TYPE_ROG_ARION,
|
||||
};
|
||||
|
||||
class ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ENESMBusInterface() = default;
|
||||
|
||||
virtual ene_interface_type GetInterfaceType() = 0;
|
||||
virtual std::string GetLocation() = 0;
|
||||
virtual int GetMaxBlock() = 0;
|
||||
virtual unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg) = 0;
|
||||
virtual void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val) = 0;
|
||||
virtual void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz) = 0;
|
||||
};
|
||||
@@ -1,96 +1,96 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_ROGArion.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for ASUS ROG Arion |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 17 Sep 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "ENESMBusInterface_ROGArion.h"
|
||||
|
||||
ENESMBusInterface_ROGArion::ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path)
|
||||
{
|
||||
scsi_dev = dev_handle;
|
||||
path = dev_path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_ROGArion::~ENESMBusInterface_ROGArion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_ROGArion::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_ROG_ARION);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_ROGArion::GetLocation()
|
||||
{
|
||||
std::string str(path.begin(), path.end());
|
||||
return("SCSI: " + str);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_ROGArion::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_ROGArion::ENERegisterRead(ene_dev_id /*dev*/, ene_register /*reg*/)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| This interface does not support reading |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::ENERegisterWrite(ene_dev_id /*dev*/, ene_register reg, unsigned char val)
|
||||
{
|
||||
SendPacket(reg, &val, sizeof(unsigned char));
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::ENERegisterWriteBlock(ene_dev_id /*dev*/, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
SendPacket(reg, data, sz);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::SendPacket
|
||||
(
|
||||
ene_register reg,
|
||||
unsigned char * packet,
|
||||
unsigned char packet_sz
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold CDB |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char cdb[16] = {0};
|
||||
cdb[0] = 0xEC;
|
||||
cdb[1] = 0x41;
|
||||
cdb[2] = 0x53;
|
||||
cdb[3] = ((reg >> 8) & 0x00FF);
|
||||
cdb[4] = ( reg & 0x00FF );
|
||||
cdb[5] = 0x00;
|
||||
cdb[6] = 0x00;
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x00;
|
||||
cdb[9] = 0x00;
|
||||
cdb[10] = 0x00;
|
||||
cdb[11] = 0x00;
|
||||
cdb[12] = 0x00;
|
||||
cdb[13] = packet_sz;
|
||||
cdb[14] = 0x00;
|
||||
cdb[15] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold sense data |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char sense[32] = {0};
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Write SCSI packet |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
scsi_write(scsi_dev, packet, packet_sz, cdb, 16, sense, 32);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_ROGArion.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for ASUS ROG Arion |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 17 Sep 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "ENESMBusInterface_ROGArion.h"
|
||||
|
||||
ENESMBusInterface_ROGArion::ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path)
|
||||
{
|
||||
scsi_dev = dev_handle;
|
||||
path = dev_path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_ROGArion::~ENESMBusInterface_ROGArion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_ROGArion::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_ROG_ARION);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_ROGArion::GetLocation()
|
||||
{
|
||||
std::string str(path.begin(), path.end());
|
||||
return("SCSI: " + str);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_ROGArion::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_ROGArion::ENERegisterRead(ene_dev_id /*dev*/, ene_register /*reg*/)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| This interface does not support reading |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::ENERegisterWrite(ene_dev_id /*dev*/, ene_register reg, unsigned char val)
|
||||
{
|
||||
SendPacket(reg, &val, sizeof(unsigned char));
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::ENERegisterWriteBlock(ene_dev_id /*dev*/, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
SendPacket(reg, data, sz);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_ROGArion::SendPacket
|
||||
(
|
||||
ene_register reg,
|
||||
unsigned char * packet,
|
||||
unsigned char packet_sz
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold CDB |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char cdb[16] = {0};
|
||||
cdb[0] = 0xEC;
|
||||
cdb[1] = 0x41;
|
||||
cdb[2] = 0x53;
|
||||
cdb[3] = ((reg >> 8) & 0x00FF);
|
||||
cdb[4] = ( reg & 0x00FF );
|
||||
cdb[5] = 0x00;
|
||||
cdb[6] = 0x00;
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x00;
|
||||
cdb[9] = 0x00;
|
||||
cdb[10] = 0x00;
|
||||
cdb[11] = 0x00;
|
||||
cdb[12] = 0x00;
|
||||
cdb[13] = packet_sz;
|
||||
cdb[14] = 0x00;
|
||||
cdb[15] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold sense data |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char sense[32] = {0};
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Write SCSI packet |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
scsi_write(scsi_dev, packet, packet_sz, cdb, 16, sense, 32);
|
||||
}
|
||||
@@ -1,40 +1,40 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_ROGArion.h |
|
||||
| |
|
||||
| ENE SMBus interface for ASUS ROG Arion |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 17 Sep 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "scsiapi.h"
|
||||
|
||||
class ENESMBusInterface_ROGArion : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path);
|
||||
~ENESMBusInterface_ROGArion();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
scsi_device* scsi_dev;
|
||||
std::string path;
|
||||
|
||||
void SendPacket
|
||||
(
|
||||
ene_register reg,
|
||||
unsigned char * packet,
|
||||
unsigned char packet_sz
|
||||
);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_ROGArion.h |
|
||||
| |
|
||||
| ENE SMBus interface for ASUS ROG Arion |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 17 Sep 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "scsiapi.h"
|
||||
|
||||
class ENESMBusInterface_ROGArion : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_ROGArion(scsi_device* dev_handle, char* dev_path);
|
||||
~ENESMBusInterface_ROGArion();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
scsi_device* scsi_dev;
|
||||
std::string path;
|
||||
|
||||
void SendPacket
|
||||
(
|
||||
ene_register reg,
|
||||
unsigned char * packet,
|
||||
unsigned char packet_sz
|
||||
);
|
||||
};
|
||||
+215
-215
@@ -1,215 +1,215 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Linux.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <sys/ioctl.h>
|
||||
#include "ENESMBusInterface_SpectrixS40G_Linux.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)
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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,
|
||||
.result = 0,
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G implementation |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::ENESMBusInterface_SpectrixS40G(int fd, char* path)
|
||||
{
|
||||
this->nvme_fd = fd;
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
|
||||
{
|
||||
return("NVMe: " + path);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_SpectrixS40G::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_SpectrixS40G::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
struct nvme_passthru_cmd cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(nvme_passthru_cmd));
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
cfg.opcode = 0xFA;
|
||||
cfg.cdw12 = (corrected_reg << 16) | (dev << 1);
|
||||
cfg.cdw13 = 0x81100001;
|
||||
cfg.data_len = 1;
|
||||
|
||||
unsigned char data[1];
|
||||
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);
|
||||
|
||||
return(data[0]);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWrite(ene_dev_id dev, ene_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.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 ENESMBusInterface_SpectrixS40G::ENERegisterWriteBlock(ene_dev_id dev, ene_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.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);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Linux.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <sys/ioctl.h>
|
||||
#include "ENESMBusInterface_SpectrixS40G_Linux.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)
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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,
|
||||
.result = 0,
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G implementation |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::ENESMBusInterface_SpectrixS40G(int fd, char* path)
|
||||
{
|
||||
this->nvme_fd = fd;
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
|
||||
{
|
||||
return("NVMe: " + path);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_SpectrixS40G::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_SpectrixS40G::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
struct nvme_passthru_cmd cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(nvme_passthru_cmd));
|
||||
|
||||
unsigned short corrected_reg = ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF);
|
||||
|
||||
cfg.opcode = 0xFA;
|
||||
cfg.cdw12 = (corrected_reg << 16) | (dev << 1);
|
||||
cfg.cdw13 = 0x81100001;
|
||||
cfg.data_len = 1;
|
||||
|
||||
unsigned char data[1];
|
||||
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);
|
||||
|
||||
return(data[0]);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWrite(ene_dev_id dev, ene_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.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 ENESMBusInterface_SpectrixS40G::ENERegisterWriteBlock(ene_dev_id dev, ene_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.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);
|
||||
|
||||
}
|
||||
+32
-32
@@ -1,32 +1,32 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Linux.h |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
|
||||
class ENESMBusInterface_SpectrixS40G : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_SpectrixS40G(int fd, char* path);
|
||||
~ENESMBusInterface_SpectrixS40G();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
int nvme_fd;
|
||||
std::string path;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Linux.h |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
|
||||
class ENESMBusInterface_SpectrixS40G : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_SpectrixS40G(int fd, char* path);
|
||||
~ENESMBusInterface_SpectrixS40G();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
int nvme_fd;
|
||||
std::string path;
|
||||
};
|
||||
+261
-261
@@ -1,261 +1,261 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Windows.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include <nvme.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#include "ENESMBusInterface_SpectrixS40G_Windows.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::ENESMBusInterface_SpectrixS40G(HANDLE fd, wchar_t* path)
|
||||
{
|
||||
this->nvme_fd = fd;
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
|
||||
{
|
||||
return("NVMe: " + StringUtils::wstring_to_string(path));
|
||||
}
|
||||
|
||||
int ENESMBusInterface_SpectrixS40G::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_SpectrixS40G::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
if(nvme_fd != 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)] = {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;
|
||||
DeviceIoControl(nvme_fd, 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((unsigned char)ExtraValue[16]);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
|
||||
{
|
||||
if(nvme_fd != 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(nvme_fd, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
if(nvme_fd != 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(nvme_fd, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Windows.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include <nvme.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#include "ENESMBusInterface_SpectrixS40G_Windows.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::ENESMBusInterface_SpectrixS40G(HANDLE fd, wchar_t* path)
|
||||
{
|
||||
this->nvme_fd = fd;
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
ENESMBusInterface_SpectrixS40G::~ENESMBusInterface_SpectrixS40G()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_SpectrixS40G::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_SPECTRIX_S40G);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_SpectrixS40G::GetLocation()
|
||||
{
|
||||
return("NVMe: " + StringUtils::wstring_to_string(path));
|
||||
}
|
||||
|
||||
int ENESMBusInterface_SpectrixS40G::GetMaxBlock()
|
||||
{
|
||||
return(24);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_SpectrixS40G::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
if(nvme_fd != 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)] = {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;
|
||||
DeviceIoControl(nvme_fd, 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((unsigned char)ExtraValue[16]);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
|
||||
{
|
||||
if(nvme_fd != 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(nvme_fd, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
|
||||
void ENESMBusInterface_SpectrixS40G::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
if(nvme_fd != 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(nvme_fd, IOCTL_STORAGE_PROTOCOL_COMMAND, buffer, sizeof(buffer), buffer, sizeof(buffer), 0x0, (LPOVERLAPPED)0x0);
|
||||
}
|
||||
}
|
||||
+33
-33
@@ -1,33 +1,33 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Windows.h |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "ENESMBusInterface.h"
|
||||
|
||||
class ENESMBusInterface_SpectrixS40G : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_SpectrixS40G(HANDLE fd, wchar_t* path);
|
||||
~ENESMBusInterface_SpectrixS40G();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
HANDLE nvme_fd;
|
||||
std::wstring path;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_SpectrixS40G_Windows.h |
|
||||
| |
|
||||
| ENE SMBus interface for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "ENESMBusInterface.h"
|
||||
|
||||
class ENESMBusInterface_SpectrixS40G : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_SpectrixS40G(HANDLE fd, wchar_t* path);
|
||||
~ENESMBusInterface_SpectrixS40G();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
HANDLE nvme_fd;
|
||||
std::wstring path;
|
||||
};
|
||||
@@ -1,72 +1,72 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_i2c_smbus.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for I2C/SMBus |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "ENESMBusInterface_i2c_smbus.h"
|
||||
|
||||
ENESMBusInterface_i2c_smbus::ENESMBusInterface_i2c_smbus(i2c_smbus_interface* bus)
|
||||
{
|
||||
this->bus = bus;
|
||||
}
|
||||
|
||||
ENESMBusInterface_i2c_smbus::~ENESMBusInterface_i2c_smbus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_i2c_smbus::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_I2C_SMBUS);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_i2c_smbus::GetLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
return("I2C: " + return_string);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_i2c_smbus::GetMaxBlock()
|
||||
{
|
||||
return(3);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_i2c_smbus::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read ENE value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
}
|
||||
|
||||
void ENESMBusInterface_i2c_smbus::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write ENE value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_i2c_smbus::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write ENE block data
|
||||
if(bus->i2c_smbus_write_block_data(dev, 0x03, sz, data) == -1)
|
||||
{
|
||||
//Fall back to individual byte operations if the block operation fails
|
||||
for(unsigned int block_byte = 0; block_byte < sz; block_byte++)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, data[block_byte]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_i2c_smbus.cpp |
|
||||
| |
|
||||
| ENE SMBus interface for I2C/SMBus |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "ENESMBusInterface_i2c_smbus.h"
|
||||
|
||||
ENESMBusInterface_i2c_smbus::ENESMBusInterface_i2c_smbus(i2c_smbus_interface* bus)
|
||||
{
|
||||
this->bus = bus;
|
||||
}
|
||||
|
||||
ENESMBusInterface_i2c_smbus::~ENESMBusInterface_i2c_smbus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ene_interface_type ENESMBusInterface_i2c_smbus::GetInterfaceType()
|
||||
{
|
||||
return(ENE_INTERFACE_TYPE_I2C_SMBUS);
|
||||
}
|
||||
|
||||
std::string ENESMBusInterface_i2c_smbus::GetLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
return("I2C: " + return_string);
|
||||
}
|
||||
|
||||
int ENESMBusInterface_i2c_smbus::GetMaxBlock()
|
||||
{
|
||||
return(3);
|
||||
}
|
||||
|
||||
unsigned char ENESMBusInterface_i2c_smbus::ENERegisterRead(ene_dev_id dev, ene_register reg)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read ENE value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
}
|
||||
|
||||
void ENESMBusInterface_i2c_smbus::ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write ENE value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
}
|
||||
|
||||
void ENESMBusInterface_i2c_smbus::ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
//Write ENE register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write ENE block data
|
||||
if(bus->i2c_smbus_write_block_data(dev, 0x03, sz, data) == -1)
|
||||
{
|
||||
//Fall back to individual byte operations if the block operation fails
|
||||
for(unsigned int block_byte = 0; block_byte < sz; block_byte++)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, data[block_byte]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_i2c_smbus.h |
|
||||
| |
|
||||
| ENE SMBus interface for I2C/SMBus |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
class ENESMBusInterface_i2c_smbus : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_i2c_smbus(i2c_smbus_interface* bus);
|
||||
~ENESMBusInterface_i2c_smbus();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
i2c_smbus_interface * bus;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| ENESMBusInterface_i2c_smbus.h |
|
||||
| |
|
||||
| ENE SMBus interface for I2C/SMBus |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 21 Nov 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ENESMBusInterface.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
class ENESMBusInterface_i2c_smbus : public ENESMBusInterface
|
||||
{
|
||||
public:
|
||||
ENESMBusInterface_i2c_smbus(i2c_smbus_interface* bus);
|
||||
~ENESMBusInterface_i2c_smbus();
|
||||
|
||||
ene_interface_type GetInterfaceType();
|
||||
std::string GetLocation();
|
||||
int GetMaxBlock();
|
||||
unsigned char ENERegisterRead(ene_dev_id dev, ene_register reg);
|
||||
void ENERegisterWrite(ene_dev_id dev, ene_register reg, unsigned char val);
|
||||
void ENERegisterWriteBlock(ene_dev_id dev, ene_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
i2c_smbus_interface * bus;
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,38 +1,38 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_ENESMBus.h |
|
||||
| |
|
||||
| RGBController for ENE SMBus devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 13 Jun 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "ENESMBusController.h"
|
||||
|
||||
class RGBController_ENESMBus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_ENESMBus(ENESMBusController* controller_ptr);
|
||||
~RGBController_ENESMBus();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
ENESMBusController* controller;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_ENESMBus.h |
|
||||
| |
|
||||
| RGBController for ENE SMBus devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 13 Jun 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "ENESMBusController.h"
|
||||
|
||||
class RGBController_ENESMBus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_ENESMBus(ENESMBusController* controller_ptr);
|
||||
~RGBController_ENESMBus();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
ENESMBusController* controller;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
@@ -1,50 +1,50 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ROGArionDetect.cpp |
|
||||
| |
|
||||
| Detector for ASUS ROG Arion |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_ROGArion.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
#include "scsiapi.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectROGArionControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on ASUS ROG Arion devices *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectROGArionControllers()
|
||||
{
|
||||
scsi_device_info * info = scsi_enumerate(NULL, NULL);
|
||||
|
||||
while(info)
|
||||
{
|
||||
if(strncmp(info->vendor, "ROG", 3) == 0 && strncmp(info->product, "ESD-S1C", 7) == 0)
|
||||
{
|
||||
scsi_device * dev = scsi_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
ENESMBusInterface_ROGArion* interface = new ENESMBusInterface_ROGArion(dev, info->path);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "Asus ROG Strix Arion", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
scsi_free_enumeration(info);
|
||||
|
||||
} /* DetectROGArionControllers() */
|
||||
|
||||
REGISTER_DETECTOR("ASUS ROG Arion", DetectROGArionControllers);
|
||||
/*---------------------------------------------------------*\
|
||||
| ROGArionDetect.cpp |
|
||||
| |
|
||||
| Detector for ASUS ROG Arion |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_ROGArion.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
#include "scsiapi.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectROGArionControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on ASUS ROG Arion devices *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectROGArionControllers()
|
||||
{
|
||||
scsi_device_info * info = scsi_enumerate(NULL, NULL);
|
||||
|
||||
while(info)
|
||||
{
|
||||
if(strncmp(info->vendor, "ROG", 3) == 0 && strncmp(info->product, "ESD-S1C", 7) == 0)
|
||||
{
|
||||
scsi_device * dev = scsi_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
ENESMBusInterface_ROGArion* interface = new ENESMBusInterface_ROGArion(dev, info->path);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "Asus ROG Strix Arion", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
scsi_free_enumeration(info);
|
||||
|
||||
} /* DetectROGArionControllers() */
|
||||
|
||||
REGISTER_DETECTOR("ASUS ROG Arion", DetectROGArionControllers);
|
||||
@@ -1,93 +1,93 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| XPGSpectrixS40GDetect_Linux.cpp |
|
||||
| |
|
||||
| Detector for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_SpectrixS40G_Linux.h"
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSpectrixS40GControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on XPG Spectrix S40G NVMe devices *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSpectrixS40GControllers()
|
||||
{
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Search for /dev/nvmeX nodes with model matching "XPG SPECTRIX S40G" |
|
||||
\*---------------------------------------------------------------------*/
|
||||
unsigned int nvme_idx = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create the nvme class model path |
|
||||
\*-------------------------------------------------*/
|
||||
char nvme_dev_buf[1024];
|
||||
|
||||
snprintf(nvme_dev_buf, 1024, "/sys/class/nvme/nvme%d/model", nvme_idx);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Open the input event path to get the name |
|
||||
\*-------------------------------------------------*/
|
||||
int nvme_model_fd = open(nvme_dev_buf, O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if(nvme_model_fd < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
memset(nvme_dev_buf, 0, 1024);
|
||||
|
||||
if(read(nvme_model_fd, nvme_dev_buf, 1024) < 0)
|
||||
{
|
||||
LOG_WARNING("[XPG Spectrix S40G] Probing %d, failed to read NVMe model", nvme_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[XPG Spectrix S40G] Probing %d, model: %s", nvme_idx, nvme_dev_buf);
|
||||
}
|
||||
|
||||
close(nvme_model_fd);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if this NVMe device is a SPECTRIX S40G |
|
||||
\*-------------------------------------------------*/
|
||||
if(strncmp(nvme_dev_buf, "XPG SPECTRIX S40G", 17) == 0)
|
||||
{
|
||||
snprintf(nvme_dev_buf, 1024, "/dev/nvme%d", nvme_idx);
|
||||
|
||||
int nvme_fd = open(nvme_dev_buf, O_RDWR);
|
||||
|
||||
if(nvme_fd > 0)
|
||||
{
|
||||
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, nvme_dev_buf);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
nvme_idx++;
|
||||
}
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);
|
||||
/*---------------------------------------------------------*\
|
||||
| XPGSpectrixS40GDetect_Linux.cpp |
|
||||
| |
|
||||
| Detector for XPG Spectrix S40G (Linux) |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_SpectrixS40G_Linux.h"
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSpectrixS40GControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on XPG Spectrix S40G NVMe devices *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSpectrixS40GControllers()
|
||||
{
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Search for /dev/nvmeX nodes with model matching "XPG SPECTRIX S40G" |
|
||||
\*---------------------------------------------------------------------*/
|
||||
unsigned int nvme_idx = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create the nvme class model path |
|
||||
\*-------------------------------------------------*/
|
||||
char nvme_dev_buf[1024];
|
||||
|
||||
snprintf(nvme_dev_buf, 1024, "/sys/class/nvme/nvme%d/model", nvme_idx);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Open the input event path to get the name |
|
||||
\*-------------------------------------------------*/
|
||||
int nvme_model_fd = open(nvme_dev_buf, O_RDONLY|O_NONBLOCK);
|
||||
|
||||
if(nvme_model_fd < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
memset(nvme_dev_buf, 0, 1024);
|
||||
|
||||
if(read(nvme_model_fd, nvme_dev_buf, 1024) < 0)
|
||||
{
|
||||
LOG_WARNING("[XPG Spectrix S40G] Probing %d, failed to read NVMe model", nvme_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[XPG Spectrix S40G] Probing %d, model: %s", nvme_idx, nvme_dev_buf);
|
||||
}
|
||||
|
||||
close(nvme_model_fd);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if this NVMe device is a SPECTRIX S40G |
|
||||
\*-------------------------------------------------*/
|
||||
if(strncmp(nvme_dev_buf, "XPG SPECTRIX S40G", 17) == 0)
|
||||
{
|
||||
snprintf(nvme_dev_buf, 1024, "/dev/nvme%d", nvme_idx);
|
||||
|
||||
int nvme_fd = open(nvme_dev_buf, O_RDWR);
|
||||
|
||||
if(nvme_fd > 0)
|
||||
{
|
||||
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, nvme_dev_buf);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
nvme_idx++;
|
||||
}
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);
|
||||
@@ -1,125 +1,125 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| XPGSpectrixS40GDetect_Windows.cpp |
|
||||
| |
|
||||
| Detector for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_SpectrixS40G_Windows.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
|
||||
#define DEVBUFSIZE (128 * 1024)
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| Windows defines "interface" for some reason. Work around this |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#ifdef interface
|
||||
#undef interface
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Search *
|
||||
* *
|
||||
* Search for an NVMe device matching "XPG SPECTRIX S40G" *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
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 += (int)wcslen(buff + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* OpenDevice *
|
||||
* *
|
||||
* Open a handle to the given device path *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
HANDLE OpenDevice(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);
|
||||
|
||||
HANDLE hDevice = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)0x0, OPEN_EXISTING, 0x0, (HANDLE)0x0);
|
||||
|
||||
return(hDevice);
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSpectrixS40GControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on XPG Spectrix S40G NVMe devices *
|
||||
* *
|
||||
* Tests for the existance of a file descriptor matching *
|
||||
* SCSI#Disk&Ven_NVMe&Prod_XPG_SPECTRIX_S40# on Windows machines *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSpectrixS40GControllers()
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
wchar_t dev_name[MAX_PATH];
|
||||
|
||||
if(Search(dev_name))
|
||||
{
|
||||
HANDLE nvme_fd = OpenDevice(dev_name);
|
||||
|
||||
if(nvme_fd != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, dev_name);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
|
||||
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);
|
||||
/*---------------------------------------------------------*\
|
||||
| XPGSpectrixS40GDetect_Windows.cpp |
|
||||
| |
|
||||
| Detector for XPG Spectrix S40G (Windows) |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Detector.h"
|
||||
#include "ENESMBusController.h"
|
||||
#include "ENESMBusInterface_SpectrixS40G_Windows.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ENESMBus.h"
|
||||
|
||||
#define DEVBUFSIZE (128 * 1024)
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| Windows defines "interface" for some reason. Work around this |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#ifdef interface
|
||||
#undef interface
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Search *
|
||||
* *
|
||||
* Search for an NVMe device matching "XPG SPECTRIX S40G" *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
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 += (int)wcslen(buff + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* OpenDevice *
|
||||
* *
|
||||
* Open a handle to the given device path *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
HANDLE OpenDevice(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);
|
||||
|
||||
HANDLE hDevice = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)0x0, OPEN_EXISTING, 0x0, (HANDLE)0x0);
|
||||
|
||||
return(hDevice);
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSpectrixS40GControllers *
|
||||
* *
|
||||
* Detects ENE SMBus controllers on XPG Spectrix S40G NVMe devices *
|
||||
* *
|
||||
* Tests for the existance of a file descriptor matching *
|
||||
* SCSI#Disk&Ven_NVMe&Prod_XPG_SPECTRIX_S40# on Windows machines *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSpectrixS40GControllers()
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
wchar_t dev_name[MAX_PATH];
|
||||
|
||||
if(Search(dev_name))
|
||||
{
|
||||
HANDLE nvme_fd = OpenDevice(dev_name);
|
||||
|
||||
if(nvme_fd != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, dev_name);
|
||||
ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE);
|
||||
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectSpectrixS40GControllers() */
|
||||
|
||||
|
||||
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);
|
||||
Reference in new issue
Block a user