1 /*
2  * This file is part of OpenCorsairLink.
3  * Copyright (C) 2017-2019  Sean Nelson <audiohacked@gmail.com>
4 
5  * OpenCorsairLink is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * any later version.
9 
10  * OpenCorsairLink is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with OpenCorsairLink.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _PROTOCOL_ASETEKPRO_H
20 #define _PROTOCOL_ASETEKPRO_H
21 
22 #include <stdint.h>
23 
24 /*
25  * These two defines are used to translage options into different item:
26  *   - an enum for values
27  *   - a list of string values
28  *
29  */
30 #define GENERATE_ENUM(ENUM) ENUM,
31 #define GENERATE_STRING(STRING) #STRING,
32 
33 // This will be used to build AsetekProSpeed and AsetekProSpeed_String
34 #define FOREACH_ASETEKPROSPEED(speed) \
35     speed(AsetekProSpeedSlow) \
36     speed(AsetekProSpeedMedium) \
37     speed(AsetekProSpeedFast)
38 
39 enum AsetekProSpeed
40 {
41     FOREACH_ASETEKPROSPEED(GENERATE_ENUM)
42 };
43 
44 static const char *AsetekProSpeed_String[] =
45 {
46     FOREACH_ASETEKPROSPEED(GENERATE_STRING)
47 };
48 
49 // This will be used to build AsetekProPumpNodes and AsetekProPumpModes_String
50 #define FOREACH_ASETEKPROPUMPMODES(mode) \
51 	mode(AsetekProPumpQuiet) \
52 	mode(AsetekProPumpBalanced) \
53 	mode(AsetekProPumpPerformance)
54 
55 enum AsetekProPumpModes
56 {
57     FOREACH_ASETEKPROPUMPMODES(GENERATE_ENUM)
58 };
59 
60 static const char *AsetekProPumpModes_String[] =
61 {
62     FOREACH_ASETEKPROPUMPMODES(GENERATE_STRING)
63 };
64 
65 enum AsetekProOperations
66 {
67     AsetekProPumpSpeedWrite = 0x30,
68     AsetekProPumpSpeedRead = 0x31,
69     AsetekProPumpModeWrite = 0x32,
70     AsetekProPumpModeRead = 0x33,
71     AsetekProFanWrite = 0x40,
72     AsetekProFanRead = 0x41,
73     AsetekProFanFixedPWMWrite = 0x42,
74     AsetekProFanFixedRPMWrite = 0x43,
75     AsetekProReadTemp = 0xa9,
76     AsetekProReadFirmwareVersion = 0xaa,
77     AsetekProReadHardwareVersion = 0xab
78 };
79 
80 
81 #define ASETEKPRO_FAN_TABLE_QUIET( x ) \
82     x[0].temperature = 0x10;        \
83     x[1].temperature = 0x14;        \
84     x[2].temperature = 0x20;        \
85     x[3].temperature = 0x28;        \
86     x[4].temperature = 0x32;        \
87     x[5].temperature = 0x37;        \
88     x[6].temperature = 0x3c;        \
89     x[0].speed = 0x19;              \
90     x[1].speed = 0x19;              \
91     x[2].speed = 0x27;              \
92     x[3].speed = 0x32;              \
93     x[4].speed = 0x4b;              \
94     x[5].speed = 0x5a;              \
95     x[6].speed = 0x64;
96 
97 #define ASETEKPRO_FAN_TABLE_BALANCED( x ) \
98     x[0].temperature = 0x10;           \
99     x[1].temperature = 0x14;           \
100     x[2].temperature = 0x20;           \
101     x[3].temperature = 0x28;           \
102     x[4].temperature = 0x32;           \
103     x[5].temperature = 0x37;           \
104     x[6].temperature = 0x3c;           \
105     x[0].speed = 0x19;                 \
106     x[1].speed = 0x19;                 \
107     x[2].speed = 0x27;                 \
108     x[3].speed = 0x32;                 \
109     x[4].speed = 0x4b;                 \
110     x[5].speed = 0x5a;                 \
111     x[6].speed = 0x64;
112 
113 #define ASETEKPRO_FAN_TABLE_EXTREME( x ) \
114     x[0].temperature = 0x10;          \
115     x[1].temperature = 0x14;          \
116     x[2].temperature = 0x19;          \
117     x[3].temperature = 0x1e;          \
118     x[4].temperature = 0x24;          \
119     x[5].temperature = 0x30;          \
120     x[6].temperature = 0x3c;          \
121     x[0].speed = 0x32;                \
122     x[1].speed = 0x32;                \
123     x[2].speed = 0x32;                \
124     x[3].speed = 0x4b;                \
125     x[4].speed = 0x55;                \
126     x[5].speed = 0x5d;                \
127     x[6].speed = 0x64;
128 
129 int
130 corsairlink_asetekpro_firmware_id(
131     struct corsair_device_info* dev,
132     struct libusb_device_handle* handle,
133     char* firmware,
134     uint8_t firmware_size );
135 
136 int
137 corsairlink_asetekpro_hardware_version(
138     struct corsair_device_info* dev,
139     struct libusb_device_handle* handle);
140 
141 /* Fan */
142 int
143 corsairlink_asetekpro_fan_count(
144     struct corsair_device_info* dev,
145     struct libusb_device_handle* handle,
146     struct fan_control* ctrl );
147 
148 int
149 corsairlink_asetekpro_fan_mode_read(
150     struct corsair_device_info* dev,
151     struct libusb_device_handle* handle,
152     struct fan_control* ctrl );
153 
154 // int corsairlink_asetekpro_fan_mode(
155 //     struct corsair_device_info* dev,
156 //     struct libusb_device_handle* handle,
157 //     struct fan_control* ctrl );
158 
159 int
160 corsairlink_asetekpro_fan_mode_performance(
161     struct corsair_device_info* dev,
162     struct libusb_device_handle* handle,
163     struct fan_control* ctrl );
164 
165 int
166 corsairlink_asetekpro_fan_mode_balanced(
167     struct corsair_device_info* dev,
168     struct libusb_device_handle* handle,
169     struct fan_control* ctrl );
170 
171 int
172 corsairlink_asetekpro_fan_mode_quiet(
173     struct corsair_device_info* dev,
174     struct libusb_device_handle* handle,
175     struct fan_control* ctrl );
176 
177 int
178 corsairlink_asetekpro_fan_curve(
179     struct corsair_device_info* dev,
180     struct libusb_device_handle* handle,
181     struct fan_control* ctrl );
182 
183 int
184 corsairlink_asetekpro_fan_speed(
185     struct corsair_device_info* dev,
186     struct libusb_device_handle* handle,
187     struct fan_control* ctrl );
188 
189 int
190 corsairlink_asetekpro_fan_print_mode(
191     uint8_t mode, uint16_t data, char* modestr, uint8_t modestr_size );
192 
193 
194 /* led */
195 int
196 corsairlink_asetekpro_led_static_color(
197     struct corsair_device_info* dev,
198     struct libusb_device_handle* handle,
199     struct led_control* ctrl );
200 
201 int
202 corsairlink_asetekpro_led_blink(
203     struct corsair_device_info* dev,
204     struct libusb_device_handle* handle,
205     struct led_control* ctrl );
206 
207 int
208 corsairlink_asetekpro_led_color_pulse(
209     struct corsair_device_info* dev,
210     struct libusb_device_handle* handle,
211     struct led_control* ctrl );
212 
213 int
214 corsairlink_asetekpro_led_color_shift(
215     struct corsair_device_info* dev,
216     struct libusb_device_handle* handle,
217     struct led_control* ctrl );
218 
219 int
220 corsairlink_asetekpro_led_rainbow(
221     struct corsair_device_info* dev,
222     struct libusb_device_handle* handle,
223     struct led_control* ctrl );
224 
225 int
226 corsairlink_asetekpro_led_temperature(
227     struct corsair_device_info* dev,
228     struct libusb_device_handle* handle,
229     struct led_control* ctrl );
230 
231 int
232 corsairlink_asetekpro_fan_mode_rpm(
233     struct corsair_device_info* dev,
234     struct libusb_device_handle* handle,
235     struct fan_control* ctrl );
236 
237 int
238 corsairlink_asetekpro_fan_mode_pwm(
239     struct corsair_device_info* dev,
240     struct libusb_device_handle* handle,
241     struct fan_control* ctrl );
242 
243 /* pump */
244 int
245 corsairlink_asetekpro_pump_mode_read(
246     struct corsair_device_info* dev,
247     struct libusb_device_handle* handle,
248     struct pump_control* ctrl );
249 
250 int
251 corsairlink_asetekpro_pump_mode_quiet(
252     struct corsair_device_info* dev,
253     struct libusb_device_handle* handle,
254     struct pump_control* ctrl );
255 
256 int
257 corsairlink_asetekpro_pump_mode_balanced(
258     struct corsair_device_info* dev,
259     struct libusb_device_handle* handle,
260     struct pump_control* ctrl );
261 
262 int
263 corsairlink_asetekpro_pump_mode_performance(
264     struct corsair_device_info* dev,
265     struct libusb_device_handle* handle,
266     struct pump_control* ctrl );
267 
268 int
269 corsairlink_asetekpro_pump_speed(
270     struct corsair_device_info* dev,
271     struct libusb_device_handle* handle,
272     struct pump_control* ctrl );
273 
274 /* temperature */
275 int
276 corsairlink_asetekpro_tempsensorscount(
277     struct corsair_device_info* dev,
278     struct libusb_device_handle* handle,
279     uint8_t* temperature_sensors_count );
280 
281 int
282 corsairlink_asetekpro_temperature(
283     struct corsair_device_info* dev,
284     struct libusb_device_handle* handle,
285     uint8_t selector,
286     double* temperature );
287 #endif
288