Get consts from OpenRGB

This commit is contained in:
Florian RICHER 2025-03-13 13:31:22 +01:00
parent f589e28d3e
commit afa51c37b3
2 changed files with 77 additions and 8 deletions

View file

@ -18,4 +18,6 @@ If is attached to driver, it appear here.
- https://github.com/torvalds/linux/blob/master/drivers/hid/hid-led.c
- https://github.com/torvalds/linux/blob/master/drivers/hid/hid-playstation.c
- https://gitlab.com/CalcProgrammer1/OpenRGB/-/blob/master/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp
- https://github.com/benburkhart1/lighting-node-pro
- https://github.com/Legion2/CorsairLightingProtocol

View file

@ -11,10 +11,6 @@
#define MSG_SIZE 64
#define RED_COLOR 0x00
#define GREEN_COLOR 0x01
#define BLUE_COLOR 0x02
static short int number_of_fan = 1;
module_param(number_of_fan, short, 0000);
MODULE_PARM_DESC(number_of_fan,
@ -24,6 +20,77 @@ enum LNP_LED_TYPE {
LNP_LED_LL120,
};
enum {
LNP_PACKET_ID_FIRMWARE =
0x02, /* Get firmware version */
LNP_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
LNP_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
LNP_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
LNP_PACKET_ID_EFFECT_CONFIG =
0x35, /* Effect mode configuration packet */
LNP_PACKET_ID_TEMPERATURE =
0x36, /* Update temperature value packet */
LNP_PACKET_ID_RESET = 0x37, /* Reset channel packet */
LNP_PACKET_ID_PORT_STATE =
0x38, /* Set port state packet */
LNP_PACKET_ID_BRIGHTNESS =
0x39, /* Set brightness packet */
LNP_PACKET_ID_LED_COUNT =
0x3A, /* Set LED count packet */
LNP_PACKET_ID_PROTOCOL =
0x3B, /* Set protocol packet */
};
enum {
LNP_DIRECT_CHANNEL_RED =
0x00, /* Red channel for direct update */
LNP_DIRECT_CHANNEL_GREEN =
0x01, /* Green channel for direct update */
LNP_DIRECT_CHANNEL_BLUE =
0x02, /* Blue channel for direct update */
};
enum {
LNP_PORT_STATE_HARDWARE =
0x01, /* Effect hardware control of channel */
LNP_PORT_STATE_SOFTWARE =
0x02, /* Direct software control of channel */
};
enum {
LNP_LED_TYPE_LED_STRIP =
0x0A, /* Corsair LED Strip Type */
LNP_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
LNP_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
LNP_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum {
LNP_CHANNEL_1 = 0x00, /* Channel 1 */
LNP_CHANNEL_2 = 0x01, /* Channel 2 */
LNP_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum {
LNP_SPEED_FAST = 0x00, /* Fast speed */
LNP_SPEED_MEDIUM = 0x01, /* Medium speed */
LNP_SPEED_SLOW = 0x02, /* Slow speed */
};
enum {
LNP_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
LNP_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
LNP_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
LNP_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
LNP_MODE_STATIC = 0x04, /* Static mode */
LNP_MODE_TEMPERATURE = 0x05, /* Temperature mode */
LNP_MODE_VISOR = 0x06, /* Visor mode */
LNP_MODE_MARQUEE = 0x07, /* Marquee mode */
LNP_MODE_BLINK = 0x08, /* Blink mode */
LNP_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
LNP_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
struct lnp_rgb_led {
struct led_classdev_mc cdev;
int led_index;
@ -93,13 +160,13 @@ static int lnp_send_fans_leds_report(struct lnp_device *led_dev)
// For green color the fifth Bytes must be equals to 0x01
// For blue color the fifth Bytes must be equals to 0x02
if (i == 1 || i == 4) {
pktcolor[4] = RED_COLOR;
pktcolor[4] = LNP_DIRECT_CHANNEL_RED;
}
if (i == 2 || i == 5) {
pktcolor[4] = GREEN_COLOR;
pktcolor[4] = LNP_DIRECT_CHANNEL_GREEN;
}
if (i == 3 || i == 6) {
pktcolor[4] = BLUE_COLOR;
pktcolor[4] = LNP_DIRECT_CHANNEL_BLUE;
}
packets[i - 1] = pktcolor;
@ -120,7 +187,7 @@ static int lnp_send_init_report(struct hid_device *hdev)
{
int ret;
u8 pkt1[MSG_SIZE] = { 0x37 };
u8 pkt1[MSG_SIZE] = { LNP_PACKET_ID_RESET };
// 0x35 - Init
u8 pkt2[MSG_SIZE] = { 0x35, 0x00, 0x00, number_of_fan << 4,
0x00, 0x01, 0x01 };