johnfanv2 / LenovoLegionLinux

Driver and tools for controlling Lenovo Legion laptops in Linux including fan control and power mode.
https://github.com/johnfanv2/LenovoLegionLinux
GNU General Public License v2.0
1.48k stars 53 forks source link

Lenovo Ideapad Gaming 3 15ACH6 Power plan in Gnome #45

Closed ghost closed 1 year ago

ghost commented 1 year ago

Fan control and other Legion stuff will never be supported for this laptop but when i was testing i noticed that power profiles also didn't work

Is there any way to make them work with gnome power profile daemon so we get better integration , would make Linux much nicer to use IDK if it's possible tho

ghost commented 1 year ago

Trying to build the modules gives me this long error on Ubuntu 22.10 live usb

errorlog.txt

ghost commented 1 year ago

System Information Manufacturer: LENOVO Product Name: 82K2 Version: IdeaPad Gaming 3 15ACH6 Wake-up Type: Power Switch SKU Number: LENOVO_MT_82K2_BU_idea_FM_IdeaPad Gaming 3 15ACH6 Family: IdeaPad Gaming 3 15ACH6

Handle 0x0020, DMI type 12, 5 bytes System Configuration Options Option 1: String1 for Type12 Equipment Manufacturer Option 2: String2 for Type12 Equipment Manufacturer Option 3: String3 for Type12 Equipment Manufacturer Option 4: String4 for Type12 Equipment Manufacturer

Handle 0x0030, DMI type 32, 20 bytes System Boot Information Status: No errors detected

dmidecode 3.4

Getting SMBIOS data from sysfs. SMBIOS 3.3.0 present. Table at 0xCB703000.

Handle 0x0000, DMI type 0, 26 bytes BIOS Information Vendor: LENOVO Version: H3CN37WW(V2.07) Release Date: 12/22/2022 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 16 MB Characteristics: PCI is supported BIOS is upgradeable BIOS shadowing is allowed Boot from CD is supported Selectable boot is supported EDD is supported Japanese floppy for NEC 9800 1.2 MB is supported (int 13h) Japanese floppy for Toshiba 1.2 MB is supported (int 13h) 5.25"/360 kB floppy services are supported (int 13h) 5.25"/1.2 MB floppy services are supported (int 13h) 3.5"/720 kB floppy services are supported (int 13h) 3.5"/2.88 MB floppy services are supported (int 13h) 8042 keyboard services are supported (int 9h) CGA/mono video services are supported (int 10h) ACPI is supported USB legacy is supported BIOS boot specification is supported Targeted content distribution is supported UEFI is supported BIOS Revision: 1.37 Firmware Revision: 1.37

Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: LENOVO Product Name: 82K2 Version: IdeaPad Gaming 3 15ACH6 Serial Number: MP27A03J UUID: 1e1c717a-9f52-11ec-810f-e4a8dfba67a7 Wake-up Type: Power Switch SKU Number: LENOVO_MT_82K2_BU_idea_FM_IdeaPad Gaming 3 15ACH6 Family: IdeaPad Gaming 3 15ACH6

Handle 0x0002, DMI type 2, 16 bytes Base Board Information Manufacturer: LENOVO Product Name: LNVNB161216 Version: No DPK Serial Number: MP27A03J Asset Tag: NO Asset Tag Features: Board is a hosting board Board is replaceable Location In Chassis: Base Board Chassis Location Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0

Handle 0x0003, DMI type 3, 23 bytes Chassis Information Manufacturer: LENOVO Type: Notebook Lock: Not Present Version: IdeaPad Gaming 3 15ACH6 Serial Number: MP27A03J Asset Tag: NO Asset Tag Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None OEM Information: 0x00000000 Height: Unspecified Number Of Power Cords: 1 Contained Elements: 0 SKU Number: Chassis SKU

Handle 0x0004, DMI type 4, 48 bytes Processor Information Socket Designation: FP6 Type: Central Processor Family: Zen Manufacturer: Advanced Micro Devices, Inc. ID: 00 0F A5 00 FF FB 8B 17 Signature: Family 25, Model 80, Stepping 0 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) PSE-36 (36-bit page size extension) CLFSH (CLFLUSH instruction supported) MMX (MMX technology supported) FXSR (FXSAVE and FXSTOR instructions supported) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) HTT (Multi-threading) Version: AMD Ryzen 5 5600H with Radeon Graphics
Voltage: 1.2 V External Clock: 100 MHz Max Speed: 4250 MHz Current Speed: 3300 MHz Status: Populated, Enabled Upgrade: None L1 Cache Handle: 0x0005 L2 Cache Handle: 0x0006 L3 Cache Handle: 0x0007 Serial Number: Unknown Asset Tag: Unknown Part Number: Unknown Core Count: 6 Core Enabled: 6 Thread Count: 12 Characteristics: 64-bit capable Multi-Core Hardware Thread Execute Protection Enhanced Virtualization Power/Performance Control

Handle 0x0005, DMI type 7, 27 bytes Cache Information Socket Designation: L1 - Cache Configuration: Enabled, Not Socketed, Level 1 Operational Mode: Write Back Location: Internal Installed Size: 384 kB Maximum Size: 384 kB Supported SRAM Types: Pipeline Burst Installed SRAM Type: Pipeline Burst Speed: 1 ns Error Correction Type: Multi-bit ECC System Type: Unified Associativity: 8-way Set-associative

Handle 0x0006, DMI type 7, 27 bytes Cache Information Socket Designation: L2 - Cache Configuration: Enabled, Not Socketed, Level 2 Operational Mode: Write Back Location: Internal Installed Size: 3 MB Maximum Size: 3 MB Supported SRAM Types: Pipeline Burst Installed SRAM Type: Pipeline Burst Speed: 1 ns Error Correction Type: Multi-bit ECC System Type: Unified Associativity: 8-way Set-associative

Handle 0x0007, DMI type 7, 27 bytes Cache Information Socket Designation: L3 - Cache Configuration: Enabled, Not Socketed, Level 3 Operational Mode: Write Back Location: Internal Installed Size: 16 MB Maximum Size: 16 MB Supported SRAM Types: Pipeline Burst Installed SRAM Type: Pipeline Burst Speed: 1 ns Error Correction Type: Multi-bit ECC System Type: Unified Associativity: 16-way Set-associative

Handle 0x0008, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J137 Internal Connector Type: None External Reference Designator: Keyboard External Connector Type: PS/2 Port Type: Keyboard Port

Handle 0x0009, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J140 Internal Connector Type: None External Reference Designator: Touch pad External Connector Type: PS/2 Port Type: Mouse Port

Handle 0x000A, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J7 Internal Connector Type: None External Reference Designator: ISP CAM External Connector Type: Other Port Type: Other

Handle 0x000B, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J49 Internal Connector Type: None External Reference Designator: USB 3.1 A P0 External Connector Type: Access Bus (USB) Port Type: USB

Handle 0x000C, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J70 Internal Connector Type: None External Reference Designator: USB 3.1 A P1 External Connector Type: Access Bus (USB) Port Type: USB

Handle 0x000D, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J39 Internal Connector Type: None External Reference Designator: USB 3.1 Type-C P0 External Connector Type: USB Type-C Receptacle Port Type: USB

Handle 0x000E, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J43 Internal Connector Type: None External Reference Designator: USB 3.1 Type-C P1 External Connector Type: USB Type-C Receptacle Port Type: USB

Handle 0x000F, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J115 Internal Connector Type: None External Reference Designator: Network External Connector Type: RJ-45 Port Type: Network Port

Handle 0x0010, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J136 Internal Connector Type: SAS/SATA Plug Receptacle External Reference Designator: Sata HDD External Connector Type: SAS/SATA Plug Receptacle Port Type: SATA

Handle 0x0011, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J138 Internal Connector Type: SAS/SATA Plug Receptacle External Reference Designator: Sata ODD External Connector Type: SAS/SATA Plug Receptacle Port Type: SATA

Handle 0x0012, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J6 Internal Connector Type: None External Reference Designator: DP CONN External Connector Type: None Port Type: Video Port

Handle 0x0013, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J9 Internal Connector Type: None External Reference Designator: eDP CONN External Connector Type: None Port Type: Video Port

Handle 0x0014, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J129 Internal Connector Type: None External Reference Designator: Microphone External Connector Type: Mini Jack (headphones) Port Type: Audio Port

Handle 0x0015, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J120 Internal Connector Type: None External Reference Designator: Headphone External Connector Type: Mini Jack (headphones) Port Type: Audio Port

Handle 0x0016, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J125 Internal Connector Type: None External Reference Designator: USB 2.0 A P0/1 External Connector Type: Access Bus (USB) Port Type: USB

Handle 0x0017, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J126 Internal Connector Type: None External Reference Designator: USB 2.0 A P2/3 External Connector Type: Access Bus (USB) Port Type: USB

Handle 0x0018, DMI type 8, 9 bytes Port Connector Information Internal Reference Designator: J119 Internal Connector Type: None External Reference Designator: Micro USB External Connector Type: Access Bus (USB) Port Type: USB

Handle 0x0019, DMI type 9, 17 bytes System Slot Information Designation: J10 Type: x8 PCI Express x8 Current Usage: Available Length: Short ID: 1 Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.1

Handle 0x001A, DMI type 9, 17 bytes System Slot Information Designation: J79 Type: x4 PCI Express x4 Current Usage: Available Length: Short ID: 2 Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.6

Handle 0x001B, DMI type 9, 17 bytes System Slot Information Designation: J92 Type: x1 M.2 Socket 1-SD Current Usage: Available Length: Short Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.2

Handle 0x001C, DMI type 9, 17 bytes System Slot Information Designation: J90 Type: x1 M.2 Socket 3 Current Usage: Available Length: Short Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.4

Handle 0x001D, DMI type 9, 17 bytes System Slot Information Designation: J19 Type: x2 M.2 Socket 3 Current Usage: Available Length: Short Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.7

Handle 0x001E, DMI type 9, 17 bytes System Slot Information Designation: CON1 Type: x4 PCI Express x8 Current Usage: Available Length: Short ID: 6 Characteristics: 3.3 V is provided PME signal is supported Hot-plug devices are supported Bus Address: 0200:00:01.5

Handle 0x001F, DMI type 11, 5 bytes OEM Strings String 1: Modern Preload

Handle 0x0020, DMI type 12, 5 bytes System Configuration Options Option 1: String1 for Type12 Equipment Manufacturer Option 2: String2 for Type12 Equipment Manufacturer Option 3: String3 for Type12 Equipment Manufacturer Option 4: String4 for Type12 Equipment Manufacturer

Handle 0x0021, DMI type 13, 22 bytes BIOS Language Information Language Description Format: Long Installable Languages: 4 en|US|iso8859-1 fr|FR|iso8859-1 ja|JP|unicode zh|TW|unicode Currently Installed Language: en|US|iso8859-1

Handle 0x0022, DMI type 16, 23 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 64 GB Error Information Handle: 0x0025 Number Of Devices: 2

Handle 0x0023, DMI type 17, 92 bytes Memory Device Array Handle: 0x0022 Error Information Handle: 0x0026 Total Width: 64 bits Data Width: 64 bits Size: 8 GB Form Factor: SODIMM Set: None Locator: DIMM 0 Bank Locator: P0 CHANNEL A Type: DDR4 Type Detail: Synchronous Unbuffered (Unregistered) Speed: 3200 MT/s Manufacturer: Hynix Serial Number: 2628DBAF Asset Tag: Not Specified Part Number: HMAA1GS6CJR6N-XN
Rank: 1 Configured Memory Speed: 3200 MT/s Minimum Voltage: 1.2 V Maximum Voltage: 1.2 V Configured Voltage: 1.2 V Memory Technology: DRAM Memory Operating Mode Capability: Volatile memory Firmware Version: Unknown Module Manufacturer ID: Bank 1, Hex 0xAD Module Product ID: Unknown Memory Subsystem Controller Manufacturer ID: Unknown Memory Subsystem Controller Product ID: Unknown Non-Volatile Size: None Volatile Size: 8 GB Cache Size: None Logical Size: None

Handle 0x0024, DMI type 17, 92 bytes Memory Device Array Handle: 0x0022 Error Information Handle: 0x0027 Total Width: 64 bits Data Width: 64 bits Size: 8 GB Form Factor: SODIMM Set: None Locator: DIMM 0 Bank Locator: P0 CHANNEL B Type: DDR4 Type Detail: Synchronous Unbuffered (Unregistered) Speed: 3200 MT/s Manufacturer: Hynix Serial Number: 2628E208 Asset Tag: Not Specified Part Number: HMAA1GS6CJR6N-XN
Rank: 1 Configured Memory Speed: 3200 MT/s Minimum Voltage: 1.2 V Maximum Voltage: 1.2 V Configured Voltage: 1.2 V Memory Technology: DRAM Memory Operating Mode Capability: Volatile memory Firmware Version: Unknown Module Manufacturer ID: Bank 1, Hex 0xAD Module Product ID: Unknown Memory Subsystem Controller Manufacturer ID: Unknown Memory Subsystem Controller Product ID: Unknown Non-Volatile Size: None Volatile Size: 8 GB Cache Size: None Logical Size: None

Handle 0x0025, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown

Handle 0x0026, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown

Handle 0x0027, DMI type 18, 23 bytes 32-bit Memory Error Information Type: OK Granularity: Unknown Operation: Unknown Vendor Syndrome: Unknown Memory Array Address: Unknown Device Address: Unknown Resolution: Unknown

Handle 0x0028, DMI type 19, 31 bytes Memory Array Mapped Address Starting Address: 0x00000000000 Ending Address: 0x003FFFFFFFF Range Size: 16 GB Physical Array Handle: 0x0022 Partition Width: 2

Handle 0x0029, DMI type 20, 35 bytes Memory Device Mapped Address Starting Address: 0x00000000000 Ending Address: 0x003FFFFFFFF Range Size: 16 GB Physical Device Handle: 0x0023 Memory Array Mapped Address Handle: 0x0028 Partition Row Position: Unknown Interleave Position: Unknown Interleaved Data Depth: Unknown

Handle 0x002A, DMI type 20, 35 bytes Memory Device Mapped Address Starting Address: 0x00000000000 Ending Address: 0x003FFFFFFFF Range Size: 16 GB Physical Device Handle: 0x0024 Memory Array Mapped Address Handle: 0x0028 Partition Row Position: Unknown Interleave Position: Unknown Interleaved Data Depth: Unknown

Handle 0x002B, DMI type 21, 7 bytes Built-in Pointing Device Type: Touch Pad Interface: PS/2 Buttons: 4

Handle 0x002C, DMI type 22, 26 bytes Portable Battery Location: Fake Manufacturer: -Virtual Battery 0- Manufacture Date: 08/08/2010 Serial Number: Battery 0 Name: CRB Battery 0 Chemistry: Zinc Air Design Capacity: Unknown Design Voltage: Unknown SBDS Version: Not Specified Maximum Error: Unknown OEM-specific Information: 0x00000000

Handle 0x002D, DMI type 24, 5 bytes Hardware Security Power-On Password Status: Disabled Keyboard Password Status: Disabled Administrator Password Status: Disabled Front Panel Reset Status: Disabled

Handle 0x002E, DMI type 26, 22 bytes Voltage Probe Description: Voltage Probe Description Location: Unknown Status: Unknown Maximum Value: Unknown Minimum Value: Unknown Resolution: Unknown Tolerance: Unknown Accuracy: Unknown OEM-specific Information: 0x00000000 Nominal Value: Unknown

Handle 0x002F, DMI type 27, 15 bytes Cooling Device Type: Fan Status: OK OEM-specific Information: 0x00000000 Nominal Speed: 8192 rpm Description: Cooling Device Description

Handle 0x0030, DMI type 32, 20 bytes System Boot Information Status: No errors detected

Handle 0x0031, DMI type 40, 18 bytes Additional Information 1 Referenced Handle: 0x0018 Referenced Offset: 0x05 String: PCIExpressx16 Value: 0xaa Additional Information 2 Referenced Handle: 0x0000 Referenced Offset: 0x05 String: Compiler Version: VC 9.0 Value: 0x05dc

Handle 0x0032, DMI type 41, 11 bytes Onboard Device Reference Designation: Realtek RTL8111E Ethernet LOM Type: Ethernet Status: Enabled Type Instance: 1 Bus Address: 0000:03:00.0

Handle 0x0033, DMI type 41, 11 bytes Onboard Device Reference Designation: Realtek ALC701 Type: Sound Status: Enabled Type Instance: 1 Bus Address: 00ff:ff:1f.7

Handle 0x0034, DMI type 43, 31 bytes TPM Device Vendor ID: AMD Specification Version: 2.0 Firmware Revision: 3.87 Description: TPM Device Characteristics: TPM Device characteristics not supported OEM-specific Information: 0x00000000

Handle 0x0035, DMI type 133, 5 bytes OEM-specific Type Header and Data: 85 05 35 00 01 Strings: KHOIHGIUCCHHII

Handle 0x0036, DMI type 200, 16 bytes OEM-specific Type Header and Data: C8 10 36 00 01 02 01 27 01 14 01 52 B0 C1 01 05 Strings: IdeaPad 82K2007FRM

Handle 0x0037, DMI type 248, 18 bytes OEM-specific Type Header and Data: F8 12 37 00 AC AC AA 17 00 00 00 00 00 00 00 00 00 00

Handle 0xFEFF, DMI type 127, 4 bytes End Of Table

johnfanv2 commented 1 year ago

I am currently working on the driver for another Ideapad Gaming 3 15. There it seems like it will be possible. The driver does not load for your model because an ACPI method is not available or renamed for your model. To evaluate it I would need the following information described in the sections below.

Probably power mode change might work with changes to the driver. Can you switch it with Fn + Q? Keyboard backlight might also work with changes to the driver. Does it work already? How many different levels do you have? Only on and off? A few other functions might also work with the driver. Custom fan control will probably not work as it is implemented now but might work after modification. How many different speed levels are currently used? Three or more? Does the fan control change when you change power mode with Fn + Q (e.g. in Windows)?

Inspecting WMI entries

# Install required tools
sudo apt install fwts

# Create folder for all the new files
mkdir fwts_re
cd fwts_re
sudo fwts wmi - > fwts_wmi.log

Then upload files.

Disassembling ACPI tables

# Install requiered tools
sudo apt install acpica-tools
# Create folder for all the new files
mkdir acpi_re
cd acpi_re

# List ACPI tables and copy them
ls /sys/firmware/acpi/tables/
sudo cp --no-preserve=mode /sys/firmware/acpi/tables/*SDT* .

# Disassemble tables to output DSDT.dsl
iasl -e SSDT* -d DSDT

Then upload files.

Gathering WMI info in Windows

If you have Windows, then the following information are very very useful to make use of the ACPI methods. Open powershell as admin in Windows and run the following script. It will list all available lenovo WMI methods. Copy output to a file and upload.

$wmi_classes = Get-WmiObject -Namespace 'ROOT/WMI' -List -Class "*LENOVO*"
foreach ($wmi_class in $wmi_classes){
  Write-Host "########################################"
  Write-Host "########################################"
  Write-Host "########################################"
  Write-Host "Name:" $wmi_class.Name
  Write-Host "Class Name:" $wmi_class.Name 
  Write-Host "Class GUID:" $wmi_class.Qualifiers["guid"].Value
  Write-Host "Description:" $wmi_class.Methods.Count
  Write-Host "Methods:"
  foreach ($method in $wmi_class.Methods){
    Write-Host "Name:" $method.Name
    Write-Host "WmiMethodId:" $method.Qualifiers["WmiMethodId"].Value
    Write-Host "Class Name:" $wmi_class.Name 
    Write-Host "Class GUID:" $wmi_class.Qualifiers["guid"].Value
    Write-Host "Description:" $method.Qualifiers["Description"].Value
    Write-Host "Implemented:" $method.Qualifiers["Implemented"].Value
    Write-Host ""
  }
  Write-Host ""
}
ghost commented 1 year ago

Probably power mode change might work with changes to the driver. Can you switch it with Fn + Q? Keyboard backlight might also work with changes to the driver. Does it work already? How many different levels do you have? Only on and off? A few other functions might also work with the driver. Custom fan control will probably not work as it is implemented now but might work after modification. How many different speed levels are currently used? Three or more? Does the fan control change when you change power mode with Fn + Q (e.g. in Windows)?

Yes i can switch the power mode with fn+Q and even the nvidia-powerd.service recognizes the high performance mode (after i restart the device) and gives the full 85W to the machine (On the latest 530 drivers at least)

Edit: You can also hear the fans go very loud on the performance mode even on lightweight tasks (That's how it is on Windows too so that confirms it working too)

Keyboard backlight switching also already works It has 4 states ,

State 1: Wave Left Speed 2 Brightness 1 State 2: Static Multiple Colors State 3: Blue Static Color State 4: Off

So this is the same as Windows with no drivers i suppose

Fan control is straight up locked on the firmware level and will not work even if i change some advanced bios settinga

ghost commented 1 year ago

Gathering WMI info in Windows

powershelloutput.txt

ghost commented 1 year ago

Inspecting WMI entries

fwts_wmi.log

ghost commented 1 year ago

acpi_re.zip

ghost commented 1 year ago

Tell me if i missed something but this should be it Also this was done on a live usb , tell me if that causes any log issues that arent there on a normal install

johnfanv2 commented 1 year ago

@kleidiss I pushed a new version that you can try. Please download the new version, compile again and load again to test the power mode feature:

You can also try to read or change the power mode using powerprofilesctl or powerprofilesctl set balanced etc. You have to restart the power-profile-deamon before it works, e.g. with systemctl restart power-profiles-daemon.service.

ghost commented 1 year ago

@johnfanv2 I still cant seem to load the modules i get this error anothererror.txt

johnfanv2 commented 1 year ago

@kleidiss Sorry, I had to make another change for your model. Try the new version.

ghost commented 1 year ago

Ok now the gnome profile switcher works

FN+Q changes it on the GUI perfectly

ghost commented 1 year ago

Wait i found a bug

If you click the performance mode on the GNOME Menu via a mouse it doesnt change Balanced and Power Saver Does

Yeah even in settings the performance mode seems to be read only for some reason

Still recognizes it if i change with Fn+Q tho so idk

* Please change the power mode with Fn + Q and provide the output of cat /sys/kernel/debug/legion/fancurve 

(Laptop was on quiet mode here)

EC Chip ID: ffff EC Chip Version: ffff legion_laptop features: fancurve powermode platformprofile platformprofilenotify minifancurve legion_laptop ec_readonly: 0 ACPI CFG error: 0 ACPI CFG: 4228186128 powermode access method: 3 powermode error: 0 powermode: 1 EC powermode error: 0 EC powermode: 255 ACPI powermode error: -5 ACPI powermode: 0 WMI powermode error: 0 WMI powermode: 1 has custom powermode: 0 ACPI rapidcharge error: 0 ACPI rapidcharge: 0 WMI backlight on/off: 0 WMI backlight: -5 EC minifancurve feature enabled: 0 EC minifancurve on cool: error EC lockfancontroller error: -1 EC lockfancontroller: error EC fanfullspeed error: error EC fanfullspeed status: -1 EC fan curve current point id: 10 EC fan curve points size: 10 Current fan curve in hardware (embedded controller): rpm1|rpm2|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255

root@ubuntu:~# cat /sys/firmware/acpi/platform_profile quiet

johnfanv2 commented 1 year ago

@kleidiss Thanks for the bug report. I hopefully fixed it. Can you please check the new version?

ghost commented 1 year ago

@kleidiss Thanks for the bug report. I hopefully fixed it. Can you please check the new version?

Everything working fine now Thanks

ghost commented 1 year ago

But in battery mode i noticed that performance is still available and checking the command it seems that the laptop still uses performance mode even in battery power Now idk if you can limit that to only balanced and quiet mode in battery power but you should look into it becuase it will destroy battery life

Even on battery cat /sys/firmware/acpi/platform_profile performance

johnfanv2 commented 1 year ago

@kleidiss The power mode should have the following behavior:

Now you can test keyboard backlight support. As far as I have seen from the files your provided access to the hardware is not implemented in the WMI layer. Nevertheless, please set the backlight to off, medium, full and provide the output of

cat /sys/kernel/debug/legion/fancurve 
cat  /sys/class/leds/platform::kbd_backlight/brightness

after each setting. Also provide the output once of

ls -lah  /sys/class/leds/*

It might also be supported by another driver in the kernel. To test it, please uninstall the lenovo_legion driver (this module) and make a restart. Do not load it again. Then do the test above again and provide the same output for the three states. After that you can install/load the legion driver it again.

ghost commented 1 year ago

My keyboard has full rgb so it has 5 states including off

ghost commented 1 year ago

wave (1).zip pluse (2).zip rgb_pulse (3).zip static blue (4).zip off (5).zip

ghost commented 1 year ago

I had the compress the txt files because the txt uploading was not working And one of the commands just gave a not found error but since i was copy-pasting i ran it anyway so just ignore it

In a day ill try these without the kernel modules if that's needed

johnfanv2 commented 1 year ago

ok. testing without the kernel module is not needed anymore. the keyboard backlight is neither supported by the WMI layer used by this driver nor by the ideapad driver as far as I see. I guess it is done by USB. Can you control it in Windows with LegionToolkit or Vantage? If this is important for you, you can try maybe this https://github.com/InstinctEx/lenovo-ideapad-legion-keyboard-led.

If you want, we could try getting CPU and GPU temperature. From the files you provided it seems like it would work. I would have to make small changes to the driver.

johnfanv2 commented 1 year ago

Backlight control seems to be done by USB and can be done by OpenRGB: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/2868

ghost commented 1 year ago

Backlight control seems to be done by USB and can be done by OpenRGB: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/2868

Is it already supported? I'll try tonight if so

Anyway anything else for me to test or is this module done?

johnfanv2 commented 1 year ago

If you want, we could try getting CPU and GPU temperature. From the files you provided it seems like it would work. I would have to make small changes to the driver.

johnfanv2 commented 1 year ago

@kleidiss Could you please try the new version and check if fan speeds and temperatures are now ok? I just updated it. Please also give the output of sudo cat /sys/kernel/debug/legion/fancurve (once).

ghost commented 1 year ago

sudo cat /sys/kernel/debug/legion/fancurve

EC Chip ID: ffff EC Chip Version: ffff legion_laptop features: fancurve powermode platformprofile platformprofilenotify minifancurve legion_laptop ec_readonly: 0 ACPI CFG error: 0 ACPI CFG: 4228186128 temperature access method: 3 CPU temperature error: 0 CPU temperature: 55 CPU temperature EC error: 0 CPU temperature EC: 255 CPU temperature ACPI error: -5 CPU temperature ACPI: 255 CPU temperature WMI error: 0 CPU temperature WMI: 55 CPU temperature WMI2 error: -14 CPU temperature WMI2: 55 GPU temperature error: 0 GPU temperature: 35 GPU temperature EC error: 0 GPU temperature EC: 255 GPU temperature ACPI error: -5 GPU temperature ACPI: 255 GPU temperature WMI error: 0 GPU temperature WMI: 35 GPU temperature WMI2 error: -14 GPU temperature WMI2: 35 fan speed access method: 3 1 fanspeed error: 0 1 fanspeed: 0 1 fanspeed EC error: 0 1 fanspeed EC: 65535 1 fanspeed ACPI error: -5 1 fanspeed ACPI: 65535 1 fanspeed WMI error: 0 1 fanspeed WMI: 0 1 fanspeed WMI2 error: -14 1 fanspeed WMI2: 0 2 fanspeed error: 0 2 fanspeed: 0 2 fanspeed EC error: 0 2 fanspeed EC: 65535 2 fanspeed ACPI error: -5 2 fanspeed ACPI: 65535 2 fanspeed WMI error: 0 2 fanspeed WMI: 0 2 fanspeed WMI2 error: -14 2 fanspeed WMI2: 0 powermode access method: 3 powermode error: 0 powermode: 2 powermode EC error: 0 powermode EC: 255 powermode ACPI error: -5 powermode ACPI: 0 powermode WMI error: 0 powermode WMI: 2 has custom powermode: 0 ACPI rapidcharge error: 0 ACPI rapidcharge: 0 WMI backlight 2 state: 0 WMI backlight 3 state: -5 EC minifancurve feature enabled: 0 EC minifancurve on cool: error EC lockfancontroller error: -1 EC lockfancontroller: error EC fanfullspeed error: error EC fanfullspeed status: -1 EC fan curve current point id: 10 EC fan curve points size: 10 Current fan curve in hardware (embedded controller): rpm1|rpm2|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255 25500 25500 255 255 255 255 255 255 255 255

ghost commented 1 year ago

Hey unrelated question but i was thinking Ik this is way too much to ask considering how god awful nvidia is on linux but could it be possible to also port the overclock features like vantage

Yes there is a way to already do OC but it requires to render the screen through the nvidia gpu all the time and run xorg as root and also it doesn't care about what mode you're on

johnfanv2 commented 1 year ago

@kleidiss The temperatures for CPU and GPU seem to be correct. Please get the newest version. You can check them with sensors or the GUI psensor. Do you think they are correct? Does the CPU temperature increase if you put the CPU under load? The fan speed seem to not correct. I have not found a way to access them via WMI or ACPI. Access to the EC via port IO does not seem to be possible. Accessing the EC via memory mapping might be possible but I will not implement it right now. So fan speed access is not possible right now. After this the kernel module is done except for GPU overclocking. Please test it now thoroughly and report any bugs.

I might implement GPU overclocking:

  1. Can you describe the exact steps how it is done in Windows?
  2. Can you describe the exact steps and commands+programs how it is done in Linux?
ghost commented 1 year ago

@johnfanv2

Even on Windows i cannot access the fan speed neither modfiy it so i think it's hardware locked by Lenovo Even the geforce app on windows cannot access it , same with MSI Afterburner

And about the temperatures they seem to be correct as far as i saw but i'll double check anyway

ghost commented 1 year ago
1. Can you describe the exact steps how it is done in Windows?

2. Can you describe the exact steps and commands+programs how it is done in Linux?

On Windows it just works out of the box as far as i know or maybe you need vantage services to be able to modify it i am not sure

But on Linux it's a pain in the ass https://download.nvidia.com/XFree86/Linux-x86_64/430.14/README/xconfigoptions.html#Coolbits https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Overclocking_and_cooling

But keep in mind first you need to run Xorg as root for nvidia-settings to apply the offsets Second they tend to reset after a system restart so you need to apply it each time Creating a xorg.conf on this laptop completely breaks the xorg server so you need to modify the 10-nvidia.conf on etc/x11/xorg.conf.d or usr/share/x11/xorg.conf.d Fedora doesn't seem to care about the config mentioned above and the only way to unlock the options is to run x via the dgpu so good luck with that

ghost commented 1 year ago

I can confirm the GPU temps are accurate when using sensors

Edit: I can say the same for CPU

johnfanv2 commented 1 year ago

Thanks a lot for testing all the stuff. I might do the NVIDIA stuff in the future but it seems to be a rather complicated task that I cannot do quickly.

ghost commented 1 year ago

Thanks a lot for testing all the stuff.

No problem

I might do the NVIDIA stuff in the future but it seems to be a rather complicated task that I cannot do quickly.

It's a pain the ass i wouldn't fault you if you straight up ignored it The shit nvidia uses on linux is years out of date and doesn;t even work on Wayland

johnfanv2 commented 1 year ago

There are also some features in /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/

ls /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00

aslcodeversion            gpu_ctgp2_powerlimit  leds               rapidcharge
cpu_longterm_powerlimit   gpu_ctgp_powerlimit   lockfancontroller  subsystem
cpumaxfrequency           gpu_ppab_powerlimit   modalias           thermalmode
cpu_shortterm_powerlimit  gsync                 overdrive          touchpad
driver                    hwmon                 PNP0C0A:00         uevent
driver_override           isacfitforoc          power              VPC2004:00
fan_fullspeed             issupportcpuoc        powerchargemode    winkey
firmware_node             issupportgpuoc        powermode

You can read and write to most of these files to read and set properties, e.g.

# read rapidcharge status
cat /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/rapidcharge
# enable rapidcharge status (as root)
echo 1 > /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/rapidcharge

If it returns an error, then it is not available for your model. Otherwise, you can test if it has an effect.

ghost commented 1 year ago

There are also some features in /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/

ls /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00

aslcodeversion            gpu_ctgp2_powerlimit  leds               rapidcharge
cpu_longterm_powerlimit   gpu_ctgp_powerlimit   lockfancontroller  subsystem
cpumaxfrequency           gpu_ppab_powerlimit   modalias           thermalmode
cpu_shortterm_powerlimit  gsync                 overdrive          touchpad
driver                    hwmon                 PNP0C0A:00         uevent
driver_override           isacfitforoc          power              VPC2004:00
fan_fullspeed             issupportcpuoc        powerchargemode    winkey
firmware_node             issupportgpuoc        powermode

You can read and write to most of these files to read and set properties, e.g.

# read rapidcharge status
cat /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/rapidcharge
# enable rapidcharge status (as root)
echo 1 > /sys/module/legion_laptop/drivers/platform\:legion/PNP0C09\:00/rapidcharge

If it returns an error, then it is not available for your model. Otherwise, you can test if it has an effect.

I saw it on the python gui but i use a gnome extension for these , thanks anyway