File tree 3 files changed +48
-0
lines changed
framework_lib/src/chromium_ec
3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ pub enum EcCommands {
46
46
RebootEc = 0x00D2 ,
47
47
/// Get information about PD controller power
48
48
UsbPdPowerInfo = 0x0103 ,
49
+ RgbKbdSetColor = 0x013A ,
50
+ RgbKbd = 0x013B ,
49
51
50
52
// Framework specific commands
51
53
/// Configure the behavior of the flash notify
Original file line number Diff line number Diff line change @@ -518,6 +518,37 @@ impl EcRequest<EcResponseUsbPdPowerInfo> for EcRequestUsbPdPowerInfo {
518
518
}
519
519
}
520
520
521
+ // TODO: Actually 128, but if we go above ~80 EC returns REQUEST_TRUNCATED
522
+ // At least when I use the portio driver
523
+ pub const EC_RGBKBD_MAX_KEY_COUNT : usize = 64 ;
524
+
525
+ #[ repr( C , packed) ]
526
+ #[ derive( Default , Clone , Copy , Debug ) ]
527
+ pub struct RgbS {
528
+ pub r : u8 ,
529
+ pub g : u8 ,
530
+ pub b : u8 ,
531
+ }
532
+
533
+ #[ repr( C , packed) ]
534
+ pub struct EcRequestRgbKbdSetColor {
535
+ /// Specifies the starting key ID whose color is being changed
536
+ pub start_key : u8 ,
537
+ /// Specifies # of elements in color
538
+ pub length : u8 ,
539
+ /// RGB color data array of length up to MAX_KEY_COUNT
540
+ pub color : [ RgbS ; EC_RGBKBD_MAX_KEY_COUNT ] ,
541
+ }
542
+
543
+ #[ repr( C , packed) ]
544
+ pub struct EcResponseRgbKbdSetColor { }
545
+
546
+ impl EcRequest < EcResponseRgbKbdSetColor > for EcRequestRgbKbdSetColor {
547
+ fn command_id ( ) -> EcCommands {
548
+ EcCommands :: RgbKbdSetColor
549
+ }
550
+ }
551
+
521
552
// --- Framework Specific commands ---
522
553
523
554
#[ repr( C , packed) ]
Original file line number Diff line number Diff line change @@ -921,6 +921,21 @@ impl CrosEc {
921
921
let res = request. send_command ( self ) ?;
922
922
Ok ( res. val == 1 )
923
923
}
924
+
925
+ pub fn rgbkbd_set_color ( & self , start_key : u8 , colors : Vec < RgbS > ) -> EcResult < ( ) > {
926
+ let mut request = EcRequestRgbKbdSetColor {
927
+ start_key,
928
+ length : colors. len ( ) as u8 ,
929
+ color : [ ( ) ; EC_RGBKBD_MAX_KEY_COUNT ] . map ( |( ) | Default :: default ( ) ) ,
930
+ } ;
931
+
932
+ for ( i, color) in colors. iter ( ) . enumerate ( ) {
933
+ request. color [ i] = * color;
934
+ }
935
+
936
+ let _res = request. send_command ( self ) ?;
937
+ Ok ( ( ) )
938
+ }
924
939
}
925
940
926
941
#[ cfg_attr( not( feature = "uefi" ) , derive( clap:: ValueEnum ) ) ]
You can’t perform that action at this time.
0 commit comments