acidanthera / bugtracker

Acidanthera Bugtracker
385 stars 45 forks source link

[VirtualSMC] - Support for BCLM #1211

Closed 1alessandro1 closed 4 years ago

1alessandro1 commented 4 years ago

Hi, I wish to know if VirtualSMC supports this project

https://github.com/davidwernhart/AlDente

"writes the desired value to SMC (System Management Controller), which handles the rest, the modified SMC key is called "BCLM" (Presumably "Battery Charge Level Max")"

to handle maximum charge percentage. Could this be either done manually with the info.plist inside SMCBatteryManager maybe? @lvs1974

benbender commented 4 years ago

No, because the charging isn't controlled by VirtualSMC or SMCBatteryManager. It "simply" reads data of the battery-ACPI interface and provides those values via SMC to OSX.

Afaik there is no unified interface for controlling charging via ACPI. Its not even part of SBS (http://sbs-forum.org/specs/) afaik.

1alessandro1 commented 4 years ago

Thanks for your reply, so there is no way to put a maximum charge limit neither though ACPI (custom ssdt) or kernel extension?

benbender commented 4 years ago

Not in a general way afaik. F.e. https://github.com/zhen-zen/YogaSMC implements battery conservation for lenovo-machines. Issue can be closed I think.

zhen-zen commented 4 years ago

Thanks for your reply, so there is no way to put a maximum charge limit neither though ACPI (custom ssdt) or kernel extension?

As long as your laptop has certain methods to control it, both approach should be viable and might need some kind of driver implementation. However, the behavior of those SMC keys are not clear. Also, there might be some changes in Big Sur with the so-called "learns from your daily charging routine". For a SMC key only accessed by 3rd party application so far, I think it's an overkill to implement it via SMC if you can just evaluate the method directly.

For example, the BDVT key for "Battery Health" was discussed earlier at https://github.com/acidanthera/VirtualSMC/pull/34. However, this key is written 10+ times during boot on my laptop. Since I have suffered from a bad battery for the past two month, I hold conservative views on this feature and still restricted it on YogaSMC. Meanwhile, @hieplpvip have rolled that out in AsusSMC and I'm not sure of his discovery.

1alessandro1 commented 4 years ago

Very detailed info here. Can this be implemented as a separate kext (or ACPI) for other laptops other than Lenovos with a fork or variant of some kind?

After all, the only thing that matters is to set a maximum charge percentage != 100% Can some of the code coming from AsusSMC/YogaSMC help to build a Lilu plugin which does not conflict with VirtualSMC in order to let the user choose either to implement this (assuming it causes no trouble) or not?

zhen-zen commented 4 years ago

Actually Lilu won't be involved in a pure ACPI based kernel extension, or only for its API. For YogaSMC, you can easily create a subclass from YogaVPC or YogaWMI and implement what feature you want based on https://github.com/torvalds/linux/tree/master/drivers/platform/x86 . During the summer, I managed to finish the adaptation for ThinkPads with strong support from @benbender and @1Revenger1 although I don't own one. And I suppose it's not hard to do that.

vit9696 commented 4 years ago

I guess it is a little out of the scope of VSMC, closing as unrelated. Feel free to contribute any solution to Acidanthera or use it externally.