ThinkPadLEDControl icon indicating copy to clipboard operation
ThinkPadLEDControl copied to clipboard

Keyboard light status not preserved after sleep on P14s / Windows 11

Open SaltwaterC opened this issue 3 years ago • 6 comments

Hey. Thanks for writing this application. I hit a bit of a snag with P14s i.e the keyboard backlight state isn't preserved after resuming from sleep. Everything else works as expected.

This machine doesn't have an ambient sensor, so it has only three states for keyboard backlight: off, low, high. I can control the backlight through the debug function. Straight away I could set off via 00 and high via 80 status value. By experimenting, I've determined that between 0 and 39 the backlight is off, between 40 and 79 the keyboard is low, and 80 to 99 is high, while 100+ triggers an unhandled exception.

So, the keyboard control is fine. Just the state resume after power event is broken.

System details: P14s Gen 2 AMD, Windows 11 Pro, ThinkPadLEDControl 1.6.0.7 running with WinRing0 driver.

SaltwaterC avatar Jan 23 '22 16:01 SaltwaterC

Hi

It seems that lid open/close notifications may not be broadcasted to the app on your setup... I don't know exactly, it's been quite a while since I wrote this app. Unfortunately, I do not own any ThinkPad computers anymore, and haven't looked on this in a very long time. I compiled a version with a mitigation, but there was no way to really test it on a real life machine, so I am attaching it here, maybe you can test it and see what it does, and then, if it works fine, I can push the changes to the repo as well.

The executable is in LEDControl\bin\Release, called LEDControl.exe. The source code is attached as well.

Thanks

ThinkPadLEDControl.zip

valinet avatar Jan 23 '22 17:01 valinet

Thanks. I'll have a look using that build and see whether I can reproduce it.

In the meantime, I've discovered that sometimes the resume from sleep works, but it's not 100% reliable. Eventually, it will fail to resume the status prior to lid close.

SaltwaterC avatar Jan 23 '22 21:01 SaltwaterC

Hi. I have tried your build, but it doesn't solve the problem. I believe this is related to the introduction of Modern Standby (S0), whereas SystemEvents.PowerModeChanged only supports S1-S4.

As I haven't done any Windows development for more than 15 years, fitting that bit in would require some effort. I'll probably attempt it at some point, but my path of least resistance was to extend the CLI interface of ThinkPadLEDControl and trigger a default setting (low for me) via Task Scheduler, so the basics are covered.

Not sure whether this is accepted as contribution, hence adding this patch here, rather than send a PR:

diff --git a/LEDControl/Form1.cs b/LEDControl/Form1.cs
index ad4bcc6..215b3cb 100644
--- a/LEDControl/Form1.cs
+++ b/LEDControl/Form1.cs
@@ -569,6 +569,9 @@ namespace LEDControl
                             case "LEDFnLock":
                                 LED(LEDs.Fn, PowerStates.On);
                                 break;
+                            case "LEDKeyboard":
+                                SetKeyboardLevel(LightLevel.High);
+                                break;
                             default:
                                 LED2(byte.Parse(prev), PowerStates.On);
                                 break;
@@ -592,6 +595,9 @@ namespace LEDControl
                             case "LEDFnLock":
                                 LED(LEDs.Fn, PowerStates.Off);
                                 break;
+                            case "LEDKeyboard":
+                                SetKeyboardLevel(LightLevel.Off);
+                                break;
                             default:
                                 LED2(byte.Parse(prev), PowerStates.Off);
                                 break;
@@ -620,6 +626,26 @@ namespace LEDControl
                                 break;
                         }
                         break;
+                    case "low":
+                        if (prev == "LEDKeyboard")
+                        {
+                            SetKeyboardLevel(LightLevel.Low);
+                        }
+                        else
+                        {
+                            LED2(byte.Parse(prev), PowerStates.Blink);
+                        }
+                        break;
+                    case "high":
+                        if (prev == "LEDKeyboard")
+                        {
+                            SetKeyboardLevel(LightLevel.High);
+                        }
+                        else
+                        {
+                            LED2(byte.Parse(prev), PowerStates.Blink);
+                        }
+                        break;
                 }
                 prev = s;
             }

Essentially, LEDKeyboard takes off, on (high = on as well), and low.

I created a separate task in Task Scheduler that looks almost the same as the task created by ThinkPadLEDControl, with the following differences:

  • Added a second trigger, besides the "At log on" which ThinkPadLEDControl has. This "On an event", Log: System, Source: Kernel-Power (optional to declare, the Event ID is more important), Event ID: 507. 507 is triggered when the system is exiting Modern Standby. This can be observed in Event Viewer.
  • CLI args read minimize LEDKeyboard low exit
  • Unchecked "Start the task only if the computer is on AC power"

Probably unrelated, as corelation does not equal causation, but the correlation is 100%: MediaTek MT7921 is a stack of shit. Whilst running ThinkPadLEDControl I had 3 separate situations where the Wi-Fi interface would complete dissappear after exiting Modern Standby. The odd bit is that BT would still be there (i.e they share the same M.2 board). I was never able to reproduce this without ThinkPadLEDControl running. Event Viewer was screaming about MT7921 failing to resume power for undefined reasons.

Rebooting the machine doesn't solve this, so I had to hunt the internets for nearly an hour to discover that I can reset the Wi-Fi interface by shutting down, unplug everything, then hold the power button for 1 minute (yes, all 60 seconds of them). Thanks Reddit, because Lenovo thinks that's the appropriate place for effective troubleshooting.

On top of this, I also had random bluescreens whilst rebooting, despite Lenovo claiming that they fixed these problems in the latest driver release. Spoiler alert: they haven't.

Actual solution: swap the board for Intel AX200 or AX210. Never had any trobule after swapping to AX210. My wife never had problems with AX200 in her ThinkBook.

SaltwaterC avatar Feb 06 '22 16:02 SaltwaterC

Thinkpad P53. Having same issue, it doesn't remember lit status after resuming from sleep. :/

Levan777 avatar Feb 09 '22 13:02 Levan777

I have a P14s gen2 and have similar LED resume problems. Seems sometimes it works, sometimes it doesn't.

I've modified the BIOS settings to enable real sleep mode (the one that it warns you not to do) since the battery drains extremely quickly on the default setting.

Might monitoring for Logon be an option?

idontusenumbers avatar Feb 16 '22 05:02 idontusenumbers

Might monitoring for Logon be an option?

Not really, as when the computer wakes from sleep, your user account is already logged in, you just type in the password to have the lock screen dismissed.

valinet avatar Feb 16 '22 08:02 valinet