@@ -72,6 +72,9 @@ use sha2::{Digest, Sha256, Sha384, Sha512};
7272//use smbioslib::*;
7373use smbioslib:: { DefinedStruct , SMBiosInformation } ;
7474
75+ #[ cfg( any( target_os = "linux" , target_os = "windows" ) ) ]
76+ use nvml_wrapper:: { enum_wrappers:: device:: TemperatureSensor , Nvml } ;
77+
7578use crate :: chromium_ec:: { CrosEc , CrosEcDriverType , HardwareDeviceType } ;
7679
7780#[ cfg( feature = "uefi" ) ]
@@ -363,6 +366,8 @@ fn print_pd_details(ec: &CrosEc) {
363366#[ cfg( feature = "hidapi" ) ]
364367const NOT_SET : & str = "NOT SET" ;
365368
369+ const UNKNOWN : & str = "Unknown" ;
370+
366371#[ cfg( feature = "rusb" ) ]
367372fn print_audio_card_details ( ) {
368373 check_synaptics_fw_version ( ) ;
@@ -767,6 +772,88 @@ fn print_versions(ec: &CrosEc) {
767772 }
768773 }
769774 }
775+
776+ #[ cfg( any( target_os = "linux" , target_os = "windows" ) ) ]
777+ print_nvidia_details ( ) ;
778+ }
779+
780+ #[ cfg( any( target_os = "linux" , target_os = "windows" ) ) ]
781+ fn print_nvidia_details ( ) {
782+ let nvml = match Nvml :: init ( ) {
783+ Ok ( nvml) => nvml,
784+ Err ( err) => {
785+ debug ! ( "Nvidia, library init fail: {:?}" , err) ;
786+ return ;
787+ }
788+ } ;
789+ // Get the first `Device` (GPU) in the system
790+ let device = match nvml. device_by_index ( 0 ) {
791+ Ok ( device) => device,
792+ Err ( err) => {
793+ debug ! ( "Nvidia, device not found: {:?}" , err) ;
794+ return ;
795+ }
796+ } ;
797+
798+ println ! ( "NVIDIA GPU" ) ;
799+ // GeForce
800+ info ! ( " BRAND: {:?}" , device. brand( ) ) ;
801+ println ! (
802+ " Name: {}" ,
803+ device. name( ) . unwrap_or( UNKNOWN . to_string( ) )
804+ ) ;
805+ println ! ( " Architecture: {:?}" , device. architecture( ) ) ;
806+ println ! (
807+ " VBIOS Version: {}" ,
808+ device. vbios_version( ) . unwrap_or( UNKNOWN . to_string( ) )
809+ ) ;
810+ println ! (
811+ " INFO ROM Ver: {}" ,
812+ device
813+ . info_rom_image_version( )
814+ . unwrap_or( UNKNOWN . to_string( ) )
815+ ) ;
816+ println ! ( " PCI Info: {:X?}" , device. pci_info( ) ) ;
817+ println ! ( " Performance State:{:?}" , device. performance_state( ) ) ;
818+ println ! (
819+ " Pwr Mgmt Limit Df:{:?}mW" ,
820+ device. power_management_limit_default( )
821+ ) ;
822+ // NotSupported
823+ println ! (
824+ " Pwr Mgmt Limit: {:?}mW" ,
825+ device. power_management_limit( )
826+ ) ;
827+ println ! (
828+ " Pwr Mgmt Limit Cs:{:?}" ,
829+ device. power_management_limit_constraints( )
830+ ) ;
831+ println ! ( " Pwr Usage: {:?}mW" , device. power_usage( ) ) ;
832+ println ! (
833+ " Total Energy: {:?}mJ" ,
834+ device. total_energy_consumption( )
835+ ) ;
836+ // 0/NotSupported right now
837+ println ! ( " Serialnum: {:?}" , device. serial( ) ) ;
838+ println ! (
839+ " Throttle Reason: {:?}" ,
840+ device. current_throttle_reasons( )
841+ ) ;
842+ println ! (
843+ " Temperature: {:?}C" ,
844+ device. temperature( TemperatureSensor :: Gpu )
845+ ) ;
846+ //println!(" Temperature Thres:{:?}C", device.temperature_threshold());
847+ println ! ( " Util Rate: {:?}" , device. utilization_rates( ) ) ;
848+ println ! ( " Memory Info: {:?}" , device. memory_info( ) ) ;
849+ // Not supported
850+ println ! ( " Part Number: {:?}" , device. board_part_number( ) ) ;
851+ println ! ( " Board ID: {:?}" , device. board_id( ) ) ;
852+ // 0
853+ println ! ( " Num Fans: {:?}" , device. num_fans( ) ) ;
854+ // Works
855+ println ! ( " Display Active?: {:?}" , device. is_display_active( ) ) ;
856+ println ! ( " Display Conn?: {:?}" , device. is_display_connected( ) ) ;
770857}
771858
772859fn print_esrt ( ) {
0 commit comments