Skip to content

Commit 7495e97

Browse files
author
Jerry Fan
committed
Support Realtek RTL9209 ic
- RTL9209 is a usb to argb controller ic. - Support upto 400 ARGBs within 5 argb sinal out.
1 parent 351d7b9 commit 7495e97

21 files changed

Lines changed: 2183 additions & 0 deletions

Controllers/RtkArgbApi/argb_ctl.h

Lines changed: 339 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
/*
2+
* BSD-3-Clause
3+
*
4+
* Copyright (c) 2022 - 2024, Realtek Semiconductor Corp. All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without modification,
7+
* are permitted provided that the following conditions are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of the Realtek nor the names of its contributors may
17+
* be used to endorse or promote products derived from this software without
18+
* specific prior written permission.
19+
*
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30+
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
#ifndef _ARGB_CTL_H_
33+
#define _ARGB_CTL_H_
34+
35+
#pragma pack(1)
36+
37+
#define ARGBCTL_SIG 0x41524742
38+
#define ARGBCTL_VER 0x3
39+
40+
#define ARGBCTL_EFF_MAX_NUM 5
41+
#define ARGBCTL_ARGB_MAX 400
42+
43+
#define ARGB_COLOR_DEPTH 3
44+
45+
#define LED_SUBCMD_APPCTL 0x01
46+
#define LED_SUBCMD_RWMEM 0x02
47+
#define LED_SUBCMD_RGB_DRT 0x03
48+
#define LED_SUBCMD_SUP_SYNC 0x04
49+
#define LED_SUBCMD_SUP_ARGB 0x05
50+
#define LED_SUBCMD_SUP_TP 0x06
51+
#define LED_SUBCMD_SUP_DP 0x07
52+
#define LED_SUBCMD_ARGB_CTRL_NUM 0x08
53+
#define LED_SUBCMD_RGB_DRT_AIO 0x09
54+
55+
#ifdef __cplusplus
56+
extern "C" {
57+
#endif
58+
59+
enum ARGB_EFFECT_ID {
60+
EFF_NULL = 0x0000,
61+
EFF_ALWAYS_ON = 0x0001,
62+
EFF_BLINK = 0x0002,
63+
EFF_BREATH = 0x0003,
64+
EFF_SPECTRUM = 0x0004,
65+
EFF_SCROLL = 0x0005,
66+
EFF_RAINBOW_SCROLL = 0x0006,
67+
EFF_RUNNING_WATER = 0x0007,
68+
EFF_SLIDING = 0x0008,
69+
EFF_NEWTON_CRADLE = 0x0009,
70+
EFF_METEOR = 0x000A,
71+
EFF_RAINBOW_SLIDING = 0x000B,
72+
};
73+
74+
enum ARGB_GROUP {
75+
ARGB_GRP_0,
76+
ARGB_GRP_1,
77+
ARGB_GRP_2,
78+
ARGB_GRP_3,
79+
ARGB_GRP_4,
80+
NUM_ARGB_GRP,
81+
ARGB_GRP_NULL,
82+
};
83+
84+
enum SYNC_METHOD
85+
{
86+
SYNC_METHOD_ALL,
87+
SYNC_METHOD_AURA,
88+
SYNC_METHOD_MYSTIC,
89+
SYNC_METHOD_RTKLED,
90+
SYNC_METHOD_GBT,
91+
SYNC_METHOD_ROG_AURA,
92+
SYNC_METHOD_OPENRGB,
93+
NUM_OF_SYNC_METHOD,
94+
95+
SYNC_METHOD_LAMP = (0x80 | SYNC_METHOD_ALL),
96+
};
97+
98+
/*****************************************************************
99+
App ctl parameters
100+
*****************************************************************/
101+
enum LED_CTL
102+
{
103+
LED_CTL_FW = 0,
104+
LED_CTL_APP,
105+
LED_CTL_LAMP,
106+
};
107+
108+
/**
109+
* @brief argb ctl header
110+
*/
111+
typedef struct argbCtlHeader {
112+
uint32_t signature;
113+
uint32_t version;
114+
uint32_t header_addr;
115+
uint32_t header_size;
116+
uint32_t data_addr;
117+
uint16_t data_size;
118+
uint16_t single_data_size;
119+
uint32_t mdl_addr;
120+
uint32_t mdl_size;
121+
uint16_t rgb_num[NUM_ARGB_GRP];
122+
uint16_t bright[NUM_ARGB_GRP];
123+
uint8_t reserved[28];
124+
} argbCtlHeader;
125+
126+
/**
127+
* @brief argb ctl effect data
128+
*/
129+
typedef struct argbCtlEffn {
130+
uint16_t eff_id;
131+
uint16_t cycle;
132+
uint8_t hi_ramp;
133+
uint8_t lo_ramp;
134+
uint8_t hi_stable;
135+
uint8_t lo_stable;
136+
uint32_t prime_color;
137+
uint32_t sec_color;
138+
uint32_t sub_cmd;
139+
uint8_t *reserved;
140+
} argbCtlEffn;
141+
142+
/**
143+
* @brief argb ctl MDL attributes
144+
*/
145+
typedef struct __LampPosition
146+
{
147+
uint32_t XInMicrometers;
148+
uint32_t YInMicrometers;
149+
uint32_t ZInMicrometers;
150+
} LampPosition;
151+
typedef struct __LampAttributes
152+
{
153+
uint16_t LampId;
154+
LampPosition pos;
155+
uint32_t UpdateLatencyInMicroseconds;
156+
uint32_t LampPurposes;
157+
uint8_t RedLevelCount;
158+
uint8_t GreenLevelCount;
159+
uint8_t BlueLevelCount;
160+
uint8_t IntensityLevelCount;
161+
uint8_t IsProgrammable;
162+
uint8_t LampKey;
163+
} LampAttributes;
164+
struct LampArrayAttributesReport
165+
{
166+
uint8_t ReportId;
167+
uint16_t LampCount;
168+
uint32_t BoundingBoxWidthInMicrometers;
169+
uint32_t BoundingBoxHeightInMicrometers;
170+
uint32_t BoundingBoxDepthInMicrometers;
171+
uint32_t LampArrayKind;
172+
uint32_t MinUpdateIntervalInMicroseconds;
173+
};
174+
struct LampAttributesResponseReport
175+
{
176+
uint8_t ReportId;
177+
LampAttributes Attributes;
178+
};
179+
180+
typedef struct argbCtlMDL {
181+
struct LampArrayAttributesReport *laar;
182+
struct LampAttributesResponseReport *larr;
183+
LampPosition *poses;
184+
} argbCtlMDL;
185+
186+
/**
187+
* @brief argb parameters stored in memory
188+
*/
189+
typedef struct argbCtl {
190+
argbCtlHeader *header;
191+
argbCtlEffn *data[ARGBCTL_EFF_MAX_NUM];
192+
argbCtlMDL mdl[NUM_ARGB_GRP];
193+
uint8_t app_ctl[NUM_ARGB_GRP];
194+
uint8_t app_eff_done[NUM_ARGB_GRP];
195+
uint8_t *colors;
196+
uint8_t sync_method;
197+
uint32_t buf_size;
198+
} argbCtl;
199+
200+
int led_argb_set_appctl(dHandle fd, uint8_t grp_num, uint8_t ctl);
201+
int led_argb_get_appctl(dHandle fd, uint8_t grp_num, uint8_t *ctl);
202+
203+
int led_argb_write(dHandle fd,
204+
argbCtl *argb_ctl);
205+
int led_argb_read(dHandle fd,
206+
argbCtl *argb_ctl);
207+
int led_argb_write_rgb_direct(dHandle fd,
208+
argbCtl *argb_ctl,
209+
uint8_t *colors,
210+
uint16_t numberOfColors,
211+
uint8_t grp);
212+
int led_argb_write_rgb_direct_aio(dHandle fd,
213+
argbCtl *argb_ctl,
214+
uint8_t group_mask,
215+
uint8_t *colors,
216+
uint16_t TotalRGBNum);
217+
218+
int led_argb_init(dHandle fd,
219+
argbCtl *argb_ctl);
220+
void led_argb_deinit(argbCtl *argb_ctl);
221+
bool led_argb_check_alive(argbCtl *argb_ctl);
222+
223+
int led_argb_set_rgb_num(dHandle fd,
224+
argbCtl *argb_ctl,
225+
uint8_t grp,
226+
uint16_t num_argb,
227+
bool submit);
228+
int led_argb_get_rgb_num(dHandle fd,
229+
argbCtl *argb_ctl,
230+
uint8_t grp,
231+
uint16_t *num_argb);
232+
233+
int led_argb_get_ic_support_sync_light(dHandle fd, uint8_t sync_method);
234+
int led_argb_get_ic_support_argb(dHandle fd);
235+
236+
int led_argb_set_bright(dHandle fd,
237+
argbCtl *argb_ctl,
238+
uint8_t grp,
239+
uint16_t bright,
240+
bool submit);
241+
int led_argb_get_bright(dHandle fd,
242+
argbCtl *argb_ctl,
243+
uint8_t grp,
244+
uint16_t *bright);
245+
int led_argb_set_eff_id(dHandle fd,
246+
argbCtl *argb_ctl,
247+
uint8_t eff_i,
248+
uint16_t id,
249+
bool submit);
250+
int led_argb_get_eff_id(dHandle fd,
251+
argbCtl *argb_ctl,
252+
uint8_t eff_i,
253+
uint16_t *id);
254+
int led_argb_set_cycle(dHandle fd,
255+
argbCtl *argb_ctl,
256+
uint8_t eff_i,
257+
uint16_t cycle,
258+
bool submit);
259+
int led_argb_get_cycle(dHandle fd,
260+
argbCtl *argb_ctl,
261+
uint8_t eff_i,
262+
uint16_t *cycle);
263+
int led_argb_set_ramp(dHandle fd,
264+
argbCtl *argb_ctl,
265+
uint8_t eff_i,
266+
uint16_t ramp,
267+
bool submit);
268+
int led_argb_get_ramp(dHandle fd,
269+
argbCtl *argb_ctl,
270+
uint8_t eff_i,
271+
uint16_t *ramp);
272+
int led_argb_set_stable(dHandle fd,
273+
argbCtl *argb_ctl,
274+
uint8_t eff_i,
275+
uint16_t stable,
276+
bool submit);
277+
int led_argb_get_stable(dHandle fd,
278+
argbCtl *argb_ctl,
279+
uint8_t eff_i,
280+
uint16_t *stable);
281+
int led_argb_set_p_color(dHandle fd,
282+
argbCtl *argb_ctl,
283+
uint8_t eff_i,
284+
uint32_t p_color,
285+
bool submit);
286+
int led_argb_get_p_color(dHandle fd,
287+
argbCtl *argb_ctl,
288+
uint8_t eff_i,
289+
uint32_t *p_color);
290+
int led_argb_set_s_color(dHandle fd,
291+
argbCtl *argb_ctl,
292+
uint8_t eff_i,
293+
uint32_t s_color,
294+
bool submit);
295+
int led_argb_get_s_color(dHandle fd,
296+
argbCtl *argb_ctl,
297+
uint8_t eff_i,
298+
uint32_t *s_color);
299+
int led_argb_set_subcmd(dHandle fd,
300+
argbCtl *argb_ctl,
301+
uint8_t eff_i,
302+
uint32_t subcmd,
303+
bool submit);
304+
int led_argb_get_subcmd(dHandle fd,
305+
argbCtl *argb_ctl,
306+
uint8_t eff_i,
307+
uint32_t *subcmd);
308+
309+
int led_argb_set_ex(dHandle fd,
310+
argbCtl *argb_ctl,
311+
uint8_t eff_i,
312+
argbCtlEffn *cmd,
313+
bool submit);
314+
315+
int led_argb_set_id1(dHandle fd,
316+
argbCtl *argb_ctl,
317+
uint8_t grp,
318+
struct LampArrayAttributesReport *laar,
319+
bool submit);
320+
321+
int led_argb_set_id3(dHandle fd,
322+
argbCtl *argb_ctl,
323+
uint8_t grp,
324+
struct LampAttributesResponseReport *larr,
325+
bool submit);
326+
327+
int led_argb_set_pos(dHandle fd,
328+
argbCtl *argb_ctl,
329+
uint8_t grp,
330+
void *pos,
331+
bool submit);
332+
333+
#ifdef __cplusplus
334+
}
335+
#endif
336+
337+
#pragma pack()
338+
339+
#endif /* _ARGB_CTL_H_ */

0 commit comments

Comments
 (0)