Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpacpi-bat: charge thresholds not honored #8

Open
xlz opened this issue Jan 27, 2012 · 3 comments
Open

tpacpi-bat: charge thresholds not honored #8

xlz opened this issue Jan 27, 2012 · 3 comments

Comments

@xlz
Copy link

xlz commented Jan 27, 2012

I tested tpacpi-bat with my S420 (~=E420s). It has only one battery. All calls only work with battery 1 not 0, except inhibitCharge. But inhibitCharge 1 0 will cause hard freeze, so I have to use inhibitCharge 0 0 to turn it off.

The primary goal is to set charge threshold, but it seems not honored. The battery keeps charging after its remaining capacity is higher than the set threshold. The return codes also seem changed:

root@laptop:# ./tpacpi-bat -v stopChargeThreshold 1 99; ./tpacpi-bat -v stopChargeThreshold 1; ./tpacpi-bat -v startChargeThreshold 1
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCSS 0x163
Response: 0x0
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCSG 0x1
Response: 0x3e3
227
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCTG 0x1
Response: 0x3e3
227
root@laptop:# ./tpacpi-bat -v stopChargeThreshold 1 0; ./tpacpi-bat -v stopChargeThreshold 1; ./tpacpi-bat -v startChargeThreshold 1
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCSS 0x100
Response: 0x0
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCSG 0x1
Response: 0x380
128
Call    : \_SB.PCI0.LPCB.EC0.HKEY.BCTG 0x1
Response: 0x380
128

And startChargeThreshold call has the same effect as stopChargeThreshold. Okay, is it that Lenovo thinks we only need stopChargeThreshold? But at least one should work.

Any suggestion on what I can do or test now? I have enough time to read the DSDT.dsl of mine and the ACPI spec to hack this.

@teleshoes
Copy link
Owner

im sorry; i only have a w520 and i dont see those codes.
yea, bat=0 behaves inconsistently for me.
if you work out what to do, please post back and ill test it with mine immediately and merge it in. good luck!

as a workaround, if inhibitCharge works, you could write a script that wakes up every 5 minutes and inhibitsCharge for 5 minutes if the battery life is over a given threshold.

rem=`cat /proc/acpi/battery/BAT0/state | grep remaining | grep -o '[0-9]*'`
full=`cat /proc/acpi/battery/BAT0/info | grep last | grep -o '[0-9]*'`
thresh=80
if [ `echo "$rem/$full*100 > $thresh" | bc -l` == 1 ]; then tpacpi-bat inhibitCharge 0 5; fi

@xlz
Copy link
Author

xlz commented Jan 28, 2012

I mean, how did you figure out this black magic? I want to work further on this direction, only if I know the right method. My code reading stopped here:

Method (PSIF, 2, NotSerialized)
{
    Return (SMI (0x14, 0x05, Arg0, Arg1, Zero))
}

What is the SMI method and what does this mean...

@teleshoes
Copy link
Owner

ah. it is in fact black magic, an unfathomable font of wisdom and arcane sourcery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants