File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
framework_lib/src/chromium_ec Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ pub enum EcCommands {
4646 RebootEc = 0x00D2 ,
4747 /// Get information about PD controller power
4848 UsbPdPowerInfo = 0x0103 ,
49+ RgbKbdSetColor = 0x013A ,
50+ RgbKbd = 0x013B ,
4951
5052 // Framework specific commands
5153 /// 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 {
518518 }
519519}
520520
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+
521552// --- Framework Specific commands ---
522553
523554#[ repr( C , packed) ]
Original file line number Diff line number Diff line change @@ -893,6 +893,21 @@ impl CrosEc {
893893 let res = request. send_command ( self ) ?;
894894 Ok ( res. val == 1 )
895895 }
896+
897+ pub fn rgbkbd_set_color ( & self , start_key : u8 , colors : Vec < RgbS > ) -> EcResult < ( ) > {
898+ let mut request = EcRequestRgbKbdSetColor {
899+ start_key,
900+ length : colors. len ( ) as u8 ,
901+ color : [ ( ) ; EC_RGBKBD_MAX_KEY_COUNT ] . map ( |( ) | Default :: default ( ) ) ,
902+ } ;
903+
904+ for ( i, color) in colors. iter ( ) . enumerate ( ) {
905+ request. color [ i] = * color;
906+ }
907+
908+ let _res = request. send_command ( self ) ?;
909+ Ok ( ( ) )
910+ }
896911}
897912
898913#[ cfg_attr( not( feature = "uefi" ) , derive( clap:: ValueEnum ) ) ]
You can’t perform that action at this time.
0 commit comments