0xless / battmngr

Battery manager to handle system performance modes and charge modes through acpi_calls (for ideapad 15are05/14are05/14alc05).
GNU General Public License v3.0
18 stars 3 forks source link

Find and support other laptops that use acpi_calls #1

Open 0xless opened 3 years ago

0xless commented 3 years ago

Laptops like 14are05 also use acpi_calls to manage battery/system modes. It would be great to find and support these devices.

zenitraM commented 3 years ago

:wave: I have hacked your script to make it work on my Ideapad 5 14alc05 here: https://github.com/zenitraM/battmngr/commit/dd5d691596a10e1c812d615ecfccb2cbe3a1d6b0

ACPI calls to set modes are the same, but configuration is read back slightly different, the same way as in the Ideapad 5 14are05.

0xless commented 3 years ago

@zenitraM Awesome! Thanks for the interest in my project. In future I'll probably expand the capabilities of battmngr using a config file containing the calls/values for each supported laptop.

I'm sure I'll use your work to support the 14alc05!

0xless commented 2 years ago

Hi @zenitraM, I was looking into supporting more laptops, would you mind posting the output of: sudo dmidecode -s system-product-name? Also, if you are interested in helping me supporting more laptops feel free to contact me, you can find my contact info on lessonsec.com

I will need testers so it would be nice to keep in contact.

zenitraM commented 2 years ago

Hey @0xless, the output for that is 82LM which matches the whole model number (82LM005VSP).

I will try and send you an email soon, can't promise a lot of contributing time atm but I can help with testing.

zenitraM commented 2 years ago

BTW it seems that at least the power mode is now settable on kernels >5.12 (tested on 5.13.8-arch1-1) directly via /sys/firmware/acpi:

# cat platform_profile_choices 
low-power balanced performance
# battmngr -r
Intelligent Cooling
# echo balanced >platform_profile
# battmngr -r
Intelligent Cooling
# echo performance >platform_profile
# battmngr -r
Extreme Performance

Setting the mode via battmngr doesn't seem to update when reading the value back via sysfs, so maybe the kernel does not notice when the ACPI calls are done out of band:

# battmngr -r
Intelligent Cooling
# cat platform_profile
balanced
# battmngr -r
Intelligent Cooling
# battmngr -s 3
# battmngr -r
Battery Saving
# cat platform_profile
balanced
# echo performance >platform_profile
# battmngr -r
Extreme Performance
0xless commented 2 years ago

hi @zenitraM, I finally worked on supporting Ideapad 14alc05 (82LM), I have yet to test the support, but you can find a new version of battmngr here: https://github.com/0xless/battmngr/tree/experimental_support Hope it works fine, if you could report issues or the correct working of the version it would be awesome!

I'm also considering to include the possibility to set both power modes (from the article you linked) and battery conservation modes (like ideapad-cm does) as fallback options in case a laptop is not fully supported.

rezad1393 commented 2 years ago

I also have the same laptop but the 5700u model. which is 82lm0076ax model.

this app doesnt work on mine with this massage. with this error in dmesg acpi_call: Cannot get handle: Error: AE_NOT_FOUND Unrecognized battery mode, please retry

0xless commented 2 years ago

hi @rezad1393, did you use the main or the experimental support branch? The experimental support branch should be equivalent to @zenitraM fork, but it's yet to be tested.

Can you also provide the command or commands that cause this error to show? Do you also have windows installed on your laptop?

Thanks!

rezad1393 commented 2 years ago

I install from archlinux aur which I think means that it was the main one.

sudo battmngr -r                     
Unrecognized battery mode, please retry
rezad1393 commented 2 years ago

btw @zenitraM did you test charge threshold change? does this laptop even support changing the treshhold? have you got windows on it too? can the vintage app from lenovo (or what ever it is called) change threshold on this laptop? also does this laptop support charging from usb-c ? I am afraid to test that and fry the mainboard.

0xless commented 2 years ago

I install from archlinux aur which I think means that it was the main one.

sudo battmngr -r                     
Unrecognized battery mode, please retry

@rezad1393 please try the experimental support version, I'm positive it will work on your laptop. The main branch doesn't support your laptop model. If you do, please let me know how it goes!

rezad1393 commented 2 years ago

I downladed a zip from that branch and tested and it seemed to work. I check the battery conservative mode with ideapad-cm because I have tested that app and saw the result.

by the way how can I be sure that my laptop supports rapid charge? because the performance mode I can test by going to bios and see if it is changed and battery conservation mode also I can tested with tested app ideapad-cm but the rapid-charge I cant test.

0xless commented 2 years ago

Thanks for testing the branch!

Using the command battmngr -rc you can get the rapid charge status and the battery conservation mode status.

rezad1393 commented 2 years ago

btw I get a lot of these in journal Sep 17 02:39:27 laptop org_kde_powerdevil[2449]: Warning from helper: Failed to open "/sys/class/power_supply/BAT1/charge_start_threshold" for reading Sep 17 02:39:27 laptop org_kde_powerdevil[2449]: Warning from helper: Failed to open "/sys/class/power_supply/BAT1/charge_stop_threshold" for reading Sep 17 02:39:27 laptop org_kde_powerdevil[2449]: org.kde.powerdevil: org.kde.powerdevil.chargethresholdhelper.getthreshold failed "Charge thresholds not supported"

I know that if I poweroff my laptop with ac attacked the battey wont go over 60 so I know that laptop hardware supports this and it is not in linux software. but these messages and lack of data from lenovo that has said nothing for this laptop still worries me. I hoped that @zenitraM would have read my massages and tested this laptop with windows if he has windows to see if the vintage lenovo app does suppor this in windows. if he can test for rapid charge that would be awesome too.

zenitraM commented 2 years ago

@0xless was able to test the experimental branch - works fine! All modes seem to work for me

@rezad1393 on my laptop on Windows on Lenovo Vantage both battery conservation and rapid charge modes are present and supported. However I don't think charging the threshold percent is available on the app, you can only enable/disable the battery conservation which limits charge always at 60%, which I think is different from charge_start_threshold. This works for me just fine in Linux or any OS. I suspect the charge_start_threshold setting by powerdevil is not supported on this laptop.

For the rapid charge you can check the current battery charging watts with: awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now

Depending on the charger when rapid charge is enabled the watts go slightly higher, from 36W to up to 40W,

rezad1393 commented 2 years ago

awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now 0 W :)

@zenitraM thank you for the detailed answer. so this laptop supports rapidcharge? which pin power charger? my charger is not usb-c. btw do you know if the usb-c beside the power port, charges the laptop?

btw I learned that if you want to specify the laptop model you can use lenovo site and use serial number and it will give you the model AND the sub-model which together are called Machine Type Model. so both our laptops are 82LM IdeaPad 5 14ALC05 which mean lenovo amd luciene and 14 inch but the ram and cpu model and wifi (and maybe ssd and wifi) is not the same. my submodel is 0076ax which makes Machine Type Model it 82lm0076ax.

for example my wifi in realtek 8822ce which after some time gets some weird issue: ping from other device on network to it goes high like 300ms. now I am ranting :)

btw @zenitraM is there anyway I can add you on matrix? so if I have some question I can maybe ask you about them? I live in iran and replacing this laptop if I mess alot with it and bork it is not easy or cheap.

mh4ckt3mh4ckt1c4s commented 2 years ago

Hello, I'm using Arch on my new Laptop, a Lenovo Ideapad Gaming 3 15ARH05. I installed battmngr with the AUR but it ain't working completely for me (the battery conservation / system charge is, but not the system performance). I also tried to do it by hand as explained in the arch wiki without success (it returned a acpi_call: Cannot get handle: Error: AE_NOT_FOUND error). The sudo dmidecode -s system-product-name on my machine give me 82EY. Feel free to ask me for more info if needed.

pm4rcin commented 2 years ago

@0xless was able to test the experimental branch - works fine! All modes seem to work for me

@rezad1393 on my laptop on Windows on Lenovo Vantage both battery conservation and rapid charge modes are present and supported. However I don't think charging the threshold percent is available on the app, you can only enable/disable the battery conservation which limits charge always at 60%, which I think is different from charge_start_threshold. This works for me just fine in Linux or any OS. I suspect the charge_start_threshold setting by powerdevil is not supported on this laptop.

For the rapid charge you can check the current battery charging watts with: awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now

Depending on the charger when rapid charge is enabled the watts go slightly higher, from 36W to up to 40W,

Do you still have the Windows on your laptop? I'm asking because I'd like to know how did you discover ACPI calls for power profiles (intelligent cooling, max perf etc.)? Is there a way to do that on Windows?

InstinctEx commented 2 years ago

@0xless was able to test the experimental branch - works fine! All modes seem to work for me @rezad1393 on my laptop on Windows on Lenovo Vantage both battery conservation and rapid charge modes are present and supported. However I don't think charging the threshold percent is available on the app, you can only enable/disable the battery conservation which limits charge always at 60%, which I think is different from charge_start_threshold. This works for me just fine in Linux or any OS. I suspect the charge_start_threshold setting by powerdevil is not supported on this laptop. For the rapid charge you can check the current battery charging watts with: awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT1/power_now Depending on the charger when rapid charge is enabled the watts go slightly higher, from 36W to up to 40W,

Do you still have the Windows on your laptop? I'm asking because I'd like to know how did you discover ACPI calls for power profiles (intelligent cooling, max perf etc.)? Is there a way to do that on Windows?

you download windows binary tools from ACPICA, unzip the files , toggle all modes once from vantage and then create a ACPI dump from the acpidump.exe tool!

DayVeeBoi commented 2 years ago

Lenovo Legion 5 17ACH6H (Ryzen 5 & Nvidia RTX) Pop!_OS

sudo dmidecode -s system-product-name
82JY

Conservation mode and rapid charge functionality works. Similar to other reports regarding Legion models, this one uses the Fn+Q hotkey and performance mode switching does not work. It does report performance mode correctly.

rezad1393 commented 2 years ago

sudo dmidecode -s system-product-name

you can search the 'sudo dmidecode' output for "OEM-specific Type" (not grep but search) and see the complete model name.

for me the first command output will say: 82LM but the searching the complete output would get me this: OEM-specific Type Strings: IdeaPad 82LM0076AX

DayVeeBoi commented 2 years ago

you can search the 'sudo dmidecode' output for "OEM-specific Type"

IdeaPad 82JY005MCC

rezad1393 commented 2 years ago

you can search the 'sudo dmidecode' output for "OEM-specific Type"

IdeaPad 82JY005MCC

it was a suggestion. I think the first command you used will give enough info about hardware so maybe that is enough.

so I think , for example a 82JY, system would have sub-models that share the base board and so with a high chance their bios is the same. at least for my machine I can use "drivers and downloads" section of the lenovo site with just the parent model type (82lm)

the submodel would point to a model with specific type of cpu and how much ram what model of ram and what model of screen and keyboard layout and what ssd and wifi card is used.

so maybe it is not needed to be posted and may even be a privacy issue. I am sorry if I posted something that would cause harm for you later.

futurevoid commented 1 year ago

Lenovo Ideapad gaming 3 15arh7 (Ryzen 5 & Nvidia RTX) Arch linux

sudo dmidecode -s system-product-name 
82SB
Handle 0x002E, DMI type 200, 16 bytes
OEM-specific Type
Header and Data:
C8 10 2E 00 01 02 01 27 01 14 01 3D B0 C1 01 05
Strings:
IdeaPad
82SB0001US
sudo battmngr -r
Unrecognized battery mode, please retry

and nothing works

hensnenenej commented 1 year ago

Hi! Just wanted to let you know that this script is fully compatible with Ideapad 14sARH (aka Yoga slim 7 pro 2021, Ryzen 4800H; aka 82LB), it has the same ACPI calls. You should probably add this to readme.