Jump to content

HP DVx ACPI 3.x/4.x Battery Driver (10.6/10.7)


gsly
 Share

229 posts in this topic

Recommended Posts

Hello, gsly and everyone,

 

First of all thanks gsly for your time and effort and thanks a lot for sharing your knowledge with us. I'm a total newbie when it comes to DSDT stuff. I tried to edit/compare the DSDT but i'm totally lost :( Can you please help me with editing my DSDT file for battery fix?

I'm attaching my DSDT file, i was able to patch it to get audio from AppleHDA but again i'm completely lost with this battery stuff. I would really appriciate if you can edit my DSDT to make my battery work.

 

Thanks a lot. Happy Holidays

 

Its Fixed! (See Post#127)

 

HP DV7 3080CA specs.

 

i7 720QM | PM55 chip | nVidia GT230m 1GB | 6GB RAM | Corsair F120 SSD | WD Black 500 HD

DSDT-westendmtl.zip

Link to comment
Share on other sites

Hello, gsly and everyone,

 

First of all thanks gsly for your time and effort and thanks a lot for sharing your knowledge with us. I'm a total newbie when it comes to DSDT stuff. I tried to edit/compare the DSDT but i'm totally lost :( Can you please help me with editing my DSDT file for battery fix?

I'm attaching my DSDT file, i was able to patch it to get audio from AppleHDA but again i'm completely lost with this battery stuff. I would really appriciate if you can edit my DSDT to make my battery work.

 

Thanks a lot. Happy Holidays

 

 

HP DV7 3080CA specs.

 

i7 720QM | PM55 chip | nVidia GT230m 1GB | 6GB RAM | Corsair F120 SSD | WD Black 500 HD

 

Hi everyone,

 

I was able to fix my DSDT :D It works. Thanks gsly.

However, when i placed the kext in the E/E it was not loading but it is loading fine when i placed it in S/L/E.

The DSDTSE shows (Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 5 Optimizations) and someone here please help me to optimize my DSDT. I'm attaching my fixed DSDT file.

westendmtl-dsdt-fixed.zip

Link to comment
Share on other sites

Hi everyone,

 

I was able to fix my DSDT :D It works. Thanks gsly.

However, when i placed the kext in the E/E it was not loading but it is loading fine when i placed it in S/L/E.

The DSDTSE shows (Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 5 Optimizations) and someone here please help me to optimize my DSDT. I'm attaching my fixed DSDT file.

If you are using a kernel cache in Lion, that is why it is working in S/L/E only. If you are using SL or not using a kernel cache, you need to regenerate the extensions cache. There are many other threads on here about how to do both so please search on this.

If your DSDT compiles without errors and is working then ignore the optimization. This is just compiler speak for rewriting some programmers inefficient code. :)

Link to comment
Share on other sites

  • 2 weeks later...

Hello my laptop is an Asus device. Some dsdt values are different than as in HP dsdt. First i started to read acpi spesifications to understand the language. So i can dissect my code and try to understand what it means. But there is some parts that i can't understand yet. For example my _BIF method starts like this:

If (LNot (^^SBRG.EC0.BATP (Zero)))
{
Return (NBIF)
}

And the BATP method looks like this:

Method (BATP, 1, Serialized)
{
If (Arg0)
{
	Return (DCP2)
}
Else
{
	Return (DCPF)
}
}

Since we send zero to BATP method it should return DCPF and DCPF is in Field (RAMW, AnyAcc, NoLock, Preserve) and declerated like DCPF 8,

Here first question is coming. What kind of data is DCPF? Is it boolean or integer or char? (I'm c/c++ programmer).

Let's assume LNot(DCPF) produces a boolean true value and then _BIF returns NBIF. According to acpi specs _BIF method returns a package. Like this:

Package {
Power Unit						 // Integer (DWORD)
Design Capacity					// Integer (DWORD)
Last Full Charge Capacity		  // Integer (DWORD)
Battery Technology				 // Integer (DWORD)
Design Voltage					 // Integer (DWORD)
Design Capacity of Warning		 // Integer (DWORD)
Design Capacity of Low			 // Integer (DWORD)
Battery Capacity Granularity 1	 // Integer (DWORD)
Battery Capacity Granularity 2	 // Integer (DWORD)
Model Number					   // String (ASCIIZ)
Serial Number					  // String (ASCIIZ)
Battery Type					   // String (ASCIIZ)
OEM Information					// String (ASCIIZ)
}

 

My NBIF decleration looks like this:

Name (NBIF, Package (0x0D)
{
Zero,
Ones,
Ones,
One,
Ones,
Ones,
Ones,
Ones,
Ones,
"",
"",
"",
""
})

How can this zero, one and ones match? what does ones mean? Is it hex looks like 0x11111111 or what? Thank you. That's all for now.

Link to comment
Share on other sites

Hello my laptop is an Asus device. Some dsdt values are different than as in HP dsdt. First i started to read acpi spesifications to understand the language. So i can dissect my code and try to understand what it means. But there is some parts that i can't understand yet. For example my _BIF method starts like this:

...

Since we send zero to BATP method it should return DCPF and DCPF is in Field (RAMW, AnyAcc, NoLock, Preserve) and declerated like DCPF 8,

Here first question is coming. What kind of data is DCPF? Is it boolean or integer or char? (I'm c/c++ programmer).

DCPF is defined as 8-bits so in C speak, it would be an unsigned char. DCPF likely stands for (D)irect ©urrent (P)resence (F)lag and is likely hardwired to one of the battery battery bays. DCP2 would be for a second battery and if your laptop doesn't have this, its likely Asus is just using generic DSDT methods amoung their models and that is why Zero is always passed in as your model likely only has one battery.

Let's assume LNot(DCPF) produces a boolean true value and then _BIF returns NBIF. According to acpi specs _BIF method returns a package. Like this:

...

How can this zero, one and ones match? what does ones mean? Is it hex looks like 0x11111111 or what? Thank you. That's all for now.

NBIF is a package that would be returned when no battery is present (DCPF = 0) and if you look at the AML keyword "Ones", it returns a constant integer (unsigned) where all bits a set to 1. If you then look at the package spec, you'll see that 0xFFFFFFFF is "Unknown" or in C speak:

#define UNKNOWN 0xFFFFFFFF

BTW, this "unknown" value is important as the battery driver looks for this value returned by DSDT methods to determine if the value should be used or not for calculations, etc.

Link to comment
Share on other sites

I'm running a Lenovo Thinkpad T510 (currently with 10.6.8) and I've been reading lots of DSDT/battery related threads trying to solve 2 problems: 1) getting the battery fully recognized by the system and the status to show up in istats 2) better detection for my "slice battery" (the second battery that attaches to the bottom of the computer). I'm hoping some DSDT edits can help with these, and to prepare for Lion when I install it in the future.

 

It seems I have a similar battery section of my DSDT as gothic860 (with a Thinkpad W520 earlier in this topic), with several lines that start with "SB" (like SBCH) under the EC device. Unlike him, my battery isn't detected, except by voodoobattery. No cycle information, no health information, etc.

 

I've tried using the B1B2 and similar methods to break up all the SBxx lines into 8 bit chunks, then installing the modified AppleSmartBatteryManagery, but there's something I'm not doing right in the DSDT.

 

Besides this I have a fully working system.

 

Thanks to any who might be able to help. Attached is the DSDT with the battery edits I've done, and then one with my other system edits but nothing related to the battery.

T510 DSDT.zip

Link to comment
Share on other sites

Hi glsy,

 

as the other user stated a few posts up i also have an Asus notebook but i am no programmer and have been banging my head about Lion`s dsdt battery fix for a week now but its a no go for me still. I have a working dsdt for 10.6.8 / 10.7 but the battery icon doesnt show (rollback form AppleACPI from 10.6.8 is working but no info in system profiler). I have made it for the battery to show in statusbar and sys info with the AppleACPISmartBatteryManager.kext, but when i unplug the power it always shows 0%. So, could you have a look in my dsdt please? :)

 

Thanks in advance buddy,

 

cheers

dsdt.aml.zip

Link to comment
Share on other sites

I'm running a Lenovo Thinkpad T510 (currently with 10.6.8) and I've been reading lots of DSDT/battery related threads trying to solve 2 problems: 1) getting the battery fully recognized by the system and the status to show up in istats 2) better detection for my "slice battery" (the second battery that attaches to the bottom of the computer). I'm hoping some DSDT edits can help with these, and to prepare for Lion when I install it in the future.

 

It seems I have a similar battery section of my DSDT as gothic860 (with a Thinkpad W520 earlier in this topic), with several lines that start with "SB" (like SBCH) under the EC device. Unlike him, my battery isn't detected, except by voodoobattery. No cycle information, no health information, etc.

 

I've tried using the B1B2 and similar methods to break up all the SBxx lines into 8 bit chunks, then installing the modified AppleSmartBatteryManagery, but there's something I'm not doing right in the DSDT.

 

Besides this I have a fully working system.

 

Thanks to any who might be able to help. Attached is the DSDT with the battery edits I've done, and then one with my other system edits but nothing related to the battery.

You still have 16-bit references. See SBDC and SBDV referenced in the GBIF method (called by _BIF). You must remove all the 16-bit references otherwise the AppleACPIPlatform.kext's ACPI parser throws a fit... I should probably look into building a tool based on the ACPICA parser code so people can run their DSDT through it and get a report on the issues...

Focus on getting just _BIF working (comment the rest) and then we'll see about getting multiple battery support going. The current battery driver doesn't support more than one battery (yet) so disable one of them via the _STA method. If you are willing to test, I think I could add multiple battery support to the driver, however I doubt Apple has multiple battery support in OSX in terms of things like the System Profiler, but you never know...

Link to comment
Share on other sites

Hi glsy, as the other user stated a few posts up i also have an Asus notebook but i am no programmer and have been banging my head about Lion`s dsdt battery fix for a week now but its a no go for me still. I have a working dsdt for 10.6.8 / 10.7 but the battery icon doesnt show (rollback form AppleACPI from 10.6.8 is working but no info in system profiler). I have made it for the battery to show in statusbar and sys info with the AppleACPISmartBatteryManager.kext, but when i unplug the power it always shows 0%. So, could you have a look in my dsdt please? :) Thanks in advance buddy, cheers

System Profiler will only show information from registry when the key/driver is named AppleSmartBatteryManager.kext, but I see you later figured that out. Look at the _BST method if there is no battery status as more than likely this method is not correctly returning units according to the specification. Try hardcoding some values like this:


Method (_BST, 0, NotSerialized)
{
   Store (0x01, Index (PBST, Zero))    // Battery state = discharging
   Store (0xC8, Index (PBST, One))     // Battery present rate = 200 mW/mA
   Store (0x3E8, Index (PBST, 0x02))   // Battery remaining capacity = 1000 mWh/mAh
   Store (0x2710, Index (PBST, 0x03))  // Battery present voltage = 10000 mV or 10V

   Return (PBST)
}

and see if that shows in SP. Then try adding in the existing code without the checks on OSFG and BAFG to make sure these aren't set incorrectly, etc.

Good luck!

Link to comment
Share on other sites

Trying to convert the remaining two references to 8-bit, SBDC and SBDV, using the technique described here by Zprood. Unfortunately, I just can't quite figure this out, as it's not working like the others--I get compile errors.

 

FIrst SBDC. Original code has 4 references:

 

					Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0),
					SBDC,   16,
…

				Method (GBIF, 3, NotSerialized)
				{
…
						If (Local7)
						{
							Multiply (SBDC, 0x0A, Local0)
						}
						Else
						{
							Store (SBDC, Local0)
						}
...

	   Method (SBDC, 1, NotSerialized)
		{
			If (And (Arg0, 0x02))
			{
				BPWC (0x01)
			}
			Else
			{
				BPWC (0x00)
			}

			If (And (Arg0, 0x04))
			{
				Or (WGFL, 0x40, WGFL)
				\BLTH (0x02)
			}
			Else
			{
				And (WGFL, Not (0x40), WGFL)
				\BLTH (0x03)
			}
		}

 

I tried changing it to make it like the other edits, using the B1B2 Method

 

					Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0),
					//SBDC,   16,
					BDC0,	8,
					BDC1,	8,
…

						If (Local7)
						{
							//Multiply (SBDC, 0x0A, Local0)
							Multiply (B1B2 (BDC0, BDC1), 0x0A, Local0)
						}
						Else
						{
							//Store (SBDC, Local0)
							Store (B1B2 (BDC0, BDC1), Local0)
						}

 

(Not sure what to do with Method (SBDC...)

 

Second is SBDV. This object occurs 4 times in the original code as well

 

					Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0),
					SBDC,   16,
					SBDV,   16,
…

				Method (GBIF, 3, NotSerialized)
...
						Else
						{
							If (SBDV)
							{
								Divide (0x00030D40, SBDV, Local2, Index (Arg1, 0x06))
							}
							Else
							{
								Store (0x00, Index (Arg1, 0x06))
							}
						}
…

						Store (SBDV, Index (Arg1, 0x04))

 

Tried replacing it with this:

 

					Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0),
					SBDC,   16,
					//SBDV,   16,
					BDV0,	   8,
					BDV1,	   8,
…

				Method (GBIF, 3, NotSerialized)
...
						Else
						{
							//If (SBDV)
							If (B1B2 (BDV0, BDV1))
							{
								//Divide (0x00030D40, SBDV, Local2, Index (Arg1, 0x06))
								Divide (0x00030D40, B1B2 (BDV0, BDV1), Local2, Index (Arg1, 0x06))
							}
							Else
							{
								Store (0x00, Index (Arg1, 0x06))
							}
						}
…

						//Store (SBDV, Index (Arg1, 0x04))
						Store (B1B2 (BDV0, BDV1), Index (Arg1, 0x04))

 

Followed the format of the other fixes, but these ones create compile errors. B1B2 Method is defined further up in the DSDT file.

 

Thanks, any help is appreciated. Attached is the DSDT that won't compile, and a version without any battery related edits.

T510_DSDT_noCompile.zip

Link to comment
Share on other sites

gsly,

Could you look at my DSDT, I have a HP DV7-1020US, after the edits DSDT won't compile, it has 4 errors, is that anything

special about my DSDT or something I'm not doing right. DSDT doesn't have ITOS or EC device

Device (BAT0)

{

Name (_HID, EisaId ("PNP0C0A"))

Name (_UID, One)

Name (_PCL, Package (0x01)

{

_SB

})

Method (_STA, 0, NotSerialized)

{

If (ECON)

{

Sleep (0x40)

If (^^PCI0.LPC.EC0.BAL0)

{

Sleep (0x30)

Return (0x1F)

}

}

Sleep (0x30)

Return (0x0F)

}

Name (PKG1, Package (0x0D)

{

One,

0x1290,

0x1290,

One,

0x2A30,

0x01DB,

0x0100,

0x0108,

0x0EC4,

"Primary",

"",

"Lion",

"Hewlett-Packard"

})

Method (_BIF, 0, NotSerialized)

{

If (ECON)

{

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BDC0, Local0)

Store (Local0, Index (PKG1, One))

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BFC0, Local0)

Store (Local0, Index (PKG1, 0x02))

If (Local0)

{

Divide (Local0, 0x64, Local1, Local2)

Multiply (Local2, 0x05, Local3)

Store (Local3, Index (PKG1, 0x05))

Multiply (Local2, 0x03, Local2)

Store (Local2, Index (PKG1, 0x06))

}

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BDV0, Local0)

Store (Local0, Index (PKG1, 0x04))

}

Return (PKG1)

}

Name (PKG2, Package (0x04)

{

Zero,

One,

One,

0x39D0

})

Method (_BST, 0, NotSerialized)

{

If (ECON)

{

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BST0, Local0)

And (Local0, 0x07, Local0)

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BRC0, Local1)

Sleep (0x30)

Store (^^PCI0.LPC.EC0.BPV0, Local2)

Store (Local0, Index (PKG2, Zero))

Store (Zero, Index (PKG2, One))

Store (Local1, Index (PKG2, 0x02))

Store (Local2, Index (PKG2, 0x03))

}

Return (PKG2)

}

}

Link to comment
Share on other sites

  • 4 weeks later...

Is it possible for a guide that details what keys may need changed?

Define "keys". I think the information in this topic provides sufficient detail and references to enable you to get this driver working on your platform. The hardest part is determining how each hardware vendor exposes the battery information to the operating system via ACPI, and unfortunately each vendor is different and some do not read the specifications/standards documents. If they did, this driver would work on everything...

Link to comment
Share on other sites

I have a small Problem :blush: .

I´ve modified my DSDT like Jingu explained because the Parts in the DSDT he mentioned looks exactly like mine.

But, i get always the error in the log:

AppleSmartBattery: Error: Capacity Read Zero (0)

And the capacity is show as Zero (Surprise :P ).

I`ve tried to set

UseExtendedBatteryInformationMethod to false/true

and

UseExtendedBatteryInformationMethod to true/false

but that did not help.

I have attached my unpatched DSDT, my patched DSDT and the *.diff file between the two.

Both DSDTs were compiled without an error.

DSDT.zip

Link to comment
Share on other sites

I have a small Problem :blush: .

I´ve modified my DSDT like Jingu explained because the Parts in the DSDT he mentioned looks exactly like mine.

But, i get always the error in the log:

AppleSmartBattery: Error: Capacity Read Zero (0)

And the capacity is show as Zero (Surprise :P ).

I`ve tried to set

UseExtendedBatteryInformationMethod to false/true

and

UseExtendedBatteryInformationMethod to true/false

but that did not help.

I have attached my unpatched DSDT, my patched DSDT and the *.diff file between the two.

Both DSDTs were compiled without an error.

You need to look at and understand what the BATS() method is doing. Then you should see the issues in BIF0, BIF1, etc. Basically, your laptop supports a slice battery and you are not returning the information from the right battery :)

Link to comment
Share on other sites

Thanks for your fast reply :) .

First i search in google after a explanation for the used methodes but i found nothing except other asus notebook owners who have troubles with their batteries and linux.

Then i tried to think logical about what you said/ what i know and what is in the DSDT.

If the Methode (BATS) determines if we use a slice battery or not (it couldn´t be if there is a battery or not, that is decided by Method (_STA)), it´s maybe to switch these both Store functions in each methode, but it resulted in the same "Capacity Read Zero" error.

If (BSLF)
			{
				Store (B1DC, Local0)
			}
			Else
			{
				Store (B1B2 (BDC0, BDC1), Local0)	  
			}

But any other change resulted in thousands of errors.

Then i searched after similar DSDTs and found the one for the G53 with your comments, but you did not explained the Methode (BATS). And if i look at the DSDT from Jingu i see, that his Methode (BATS) and his Methode (BIF1) etc. is the same. So why is his DSDT working?

Link to comment
Share on other sites

Thanks for your fast reply :) . First i search in google after a explanation for the used methodes but i found nothing except other asus notebook owners who have troubles with their batteries and linux. Then i tried to think logical about what you said/ what i know and what is in the DSDT. If the Methode (BATS) determines if we use a slice battery or not (it couldn´t be if there is a battery or not, that is decided by Method (_STA)), it´s maybe to switch these both Store functions in each methode, but it resulted in the same "Capacity Read Zero" error.
 If (BSLF) { Store (B1DC, Local0) } Else { Store (B1B2 (BDC0, BDC1), Local0) } 

But any other change resulted in thousands of errors. Then i searched after similar DSDTs and found the one for the G53 with your comments, but you did not explained the Methode (BATS). And if i look at the DSDT from Jingu i see, that his Methode (BATS) and his Methode (BIF1) etc. is the same. So why is his DSDT working?

The battery driver doesn't support more than one battery so you should figure out which one you want to read (if you have both installed) by removing one, using something like RW Everything in Windoze to view the referenced offsets in the embedded controller to confirm, then rip out the code for the other battery. (i.e. remove all logic statements that select the battery, etc).

 

@gsly any chance to see the source? I wanna take a look/work a bit on it. Thanks.

Sure THe KiNG. I've been meaning to set up a repository someplace and upload the source there now that it's stable. FWIW, the source is just the usual AppleACPIBattery code that has been floating around the net. I just fixed some bugs, restored some original code that handles the different units of the ACPI standard, and of course added code to support ACPI 4.x and additional non-standard information (i.e. Temp)

Link to comment
Share on other sites

The battery driver doesn't support more than one battery so you should figure out which one you want to read (if you have both installed) by removing one, using something like RW Everything in Windoze to view the referenced offsets in the embedded controller to confirm, then rip out the code for the other battery. (i.e. remove all logic statements that select the battery, etc).

That sounds great, but my notebook has neither a second battery nor a connector for it (Like all N61xx models)

And there is one more thing. I´ve searched again in Jingus DSDT after differences and found two other store function he has devided in two 8 bits via B1B2. They are both under the Method (TACH) wich is under Scope (_SB.PCI0.SBRG.EC0) (I´ve attached the diff file.) but even if this looks promising, the error stays the Same :( .

dsdtdiff.zip

Link to comment
Share on other sites

Sure THe KiNG. I've been meaning to set up a repository someplace and upload the source there now that it's stable. FWIW, the source is just the usual AppleACPIBattery code that has been floating around the net. I just fixed some bugs, restored some original code that handles the different units of the ACPI standard, and of course added code to support ACPI 4.x and additional non-standard information (i.e. Temp)

Cool!

 

Lemme know when is avail.

 

Thanks.

Link to comment
Share on other sites

I´m at a point, where i copied the 10.6.8 AppleACPIPlatform.kext to my desktop (and want to copy it alter on to S/L/E) just to get the battery workking.

But, i don´t know why, i saw, that 18seven tried with his Asus U36sd to get battery working, too. But he uses less code then Jingu, and neither he divided the registers into 8 bit nor uses B1B2, he just uses SMBUS. But with his changes i get battery percentages :D (Well, i get an error when i go to the systemprofiler and want to see informations about my battery, but who cares at the moment :P ).

I´ve attached all my dsdts and their diffs from the base dsdt.

DSDT.zip

Link to comment
Share on other sites

 Share

×
×
  • Create New...