Contribute
Register

Battery is always 100% charged when unplugged

Status
Not open for further replies.
For the sheer experiment I have installed your dst_battery_hack.zip from post #154 and it works!
Power source is battery now and I see remaining time.
Screen Shot 2012-11-01 at 11.28.40 PM.png
 
For the sheer experiment I have installed your dst_battery_hack.zip from post #154 and it works!
Power source is battery now and I see remaining time.
View attachment 36695

I wondered...

Eventually, this might have to become part of the normal dsdt patches, but I don't really understand why it is necessary on some systems (and I don't really understand why HP put that code in there in the first place0. But you're only the 2nd to have this issue (I think), and I don't know what kind of side effects might happen if the patch was made default.
 
So that's the diff between original and yours dsdt:

6672c6672,6675
< And (0xFFFFFFFFFFFFFFFE, Local0, Local0)
---
> If (And (Local0, One))
> {
> Store (Or (Local0, 0x0100), Local0)
> }
6676c6679,6682
< And (0xFFFFFFFFFFFFFFFD, Local0, Local0)
---
> If (And (Local0, 0x02))
> {
> Store (Or (Local0, 0x0200), Local0)
> }
6686c6692
< Store (Local0, Index (DerefOf (Index (NBST, Arg0)), Zero))
---
> Store (Or (Local0, 0x10), Local0)
6695a6702
> Store (Or (Local0, 0x20), Local0)
6699a6707
> Store (Or (Local0, 0x40), Local0)
6707c6715
< Store (Zero, Local3)
---
> Store (Or (Local0, 0x80), Local0)
6710a6719
> Store (Local0, Index (DerefOf (Index (NBST, Arg0)), Zero))
 
So that's the diff between original and yours dsdt:

6672c6672,6675
< And (0xFFFFFFFFFFFFFFFE, Local0, Local0)
---
> If (And (Local0, One))
> {
> Store (Or (Local0, 0x0100), Local0)
> }
6676c6679,6682
< And (0xFFFFFFFFFFFFFFFD, Local0, Local0)
---
> If (And (Local0, 0x02))
> {
> Store (Or (Local0, 0x0200), Local0)
> }
6686c6692
< Store (Local0, Index (DerefOf (Index (NBST, Arg0)), Zero))
---
> Store (Or (Local0, 0x10), Local0)
6695a6702
> Store (Or (Local0, 0x20), Local0)
6699a6707
> Store (Or (Local0, 0x40), Local0)
6707c6715
< Store (Zero, Local3)
---
> Store (Or (Local0, 0x80), Local0)
6710a6719
> Store (Local0, Index (DerefOf (Index (NBST, Arg0)), Zero))

If I remember right it really boils down to just two lines in the dsdt, from Method BTST:

Code:
                        If (LEqual (GACS (), One))
                        {
                            And (0xFFFFFFFFFFFFFFFE, Local0, Local0)  // THIS ONE
                        }
                        Else
                        {
                            And (0xFFFFFFFFFFFFFFFD, Local0, Local0) // AND, THIS ONE
                        }

If you comment those two lines out, or remove the whole if/else section there, I think you will get the same result...

You are seeing more diffs because I was setting special bits in the battery status (unused bits per ACPI spec) just so I could see what path the code was taking.
 
Yes, you're right.
The same effect. What do these lines do, by the way?
 
Yes, you're right.
The same effect. What do these lines do, by the way?

Well, we can only guess, as we don't really have the inside knowledge that HP has, but...

Prior to that code block, Local0 contains the battery status as read from the EC (I know this because it eventually gets stored in the return for the ACPI standard _BST method). For the most part, that call to GACS reads from a variable called ACST (after calling UPAD, to "update" it...). By the names, we could guess that ACST stands for "AC status", and GACS stands for "Get AC status." So you can see that the if statement is checking for "AC status" == 1, which one could assume would be when the AC adapter is connected. So the logic is a bit of a "sanity" check on what the EC is returning for battery status as far as charging/discharging... clearing bits that wouldn't make sense depending on the state of an AC adapter being plugged/unplugged. Pretty much this in pseudo-code:

Code:
if (ac-adapter-is-connected)
   clear-discharging-bit  // can't be discharging if running on AC
else
   clear-charging-bit  // can't be charging if AC unplugged

By removing the "sanity check," we are just trusting what the EC is returning for battery status with regard to charging/discharging status. Why the code doesn't work on certain laptops and why it was put there in the first place... nobody knows.
 
Thanks a lot for the explanation.
Now i understand what i am doing :)
Thanks again.
 
Status
Not open for further replies.
Back
Top