Jump to content

HP DVx AppleACPIBatteryManager Driver


  • Please log in to reply
73 replies to this topic

#41
manmal

manmal

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 441 posts

Looks like you need some additional work in your _GPE._L* methods to Notify the PWRB device and anything else you want woken up.
DO NOT COPY AND PASTE THE FOLLOWING as I have highly customized my DSDT, renamed a bunch of things, etc. so just use this as a reference to fix your own:
[


Hi glsy, thanks for your advice, i will try adding such stuff in my dsdt adapting to my names.
Would you share your dsdt ? It's just for reference... I won't use it by myself but i will give a look if everything else looks like it should.
Another question... which bootloader are you using with dv8 ? and which kind of smbios.plist (MBP51,55,61,62,71)?
Thanks!
Mal

#42
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North

Hi glsy, thanks for your advice, i will try adding such stuff in my dsdt adapting to my names.
Would you share your dsdt ? It's just for reference... I won't use it by myself but i will give a look if everything else looks like it should.
Another question... which bootloader are you using with dv8 ? and which kind of smbios.plist (MBP51,55,61,62,71)?
Thanks!
Mal


Hi Mal. Someday I'll release my DSDT once I fully comment it and I'm happy with it. I've been learning all about DSDT and making all of the modifications myself from scratch (no auto patchers) so I understand how it all works and I'm to the point where I can read and write the stuff :wacko:

I'm using Merklot's Chameleon branch specifically for the kernel auto-patch function to fix the LAPIC BIOS, and I'm using MacBookPro6,2 for smbios.plist as that was the closest to my DV8 at the time, however I plan to look at the newer MBP (7,x and 8,x) models for details/hints/fixes soon.

#43
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North
Question: Does anyone have idle sleep (aka auto sleep) working?

Idle sleep is via the Energy Saver preferences timeouts and is different than forced sleep via the Apple "Sleep" menu. See this technical Q&A note for details:

http://developer.app...340/_index.html

The reason I ask is that I think the issue with auto sleep is not with the battery driver. After much testing and reading, I believe the issue is that some other driver or software on the system is canceling the auto sleep functionality (again, see note above).

The battery driver just reports battery status up to the power management (PM) layer and doesn't send any details telling the system to sleep. Normally a power policy maker, such as the Energy Saver preferences application defines a power policy that the PM layer implements, and its the PM layer that tells the system to sleep/power down. All drivers (kexts) that control a device that might consume power will hook themselves into the PM layer and they will receive messages when the system is about to auto sleep, etc. However, drivers can reply to this message and cancel auto sleep, but they cannot cancel forced sleep.

Its not clear to me yet what happens if a driver *doesn't* properly handle sleep messages but do hook into the PM layer. I suspect this type of driver would prevent the PM layer from sleeping the machine because it wouldn't send either a "yes, sleep the system" nor a "no, cancel sleep" reply to PM layer message and leave and outstanding hook into the PM layer.

Also, my research indicates this issue with auto sleep happens on real Macs too :) Another possibility might be that the DVD drive is not listed as "Apple Shipping Drive" in system profiler, but rather "Generic" and therefore the system doesn't know how to power it off. I do hear my DVD drive seeking/grinding after the display is turned off when auto sleep should happen, so there might be some merit to this.

Anyway, no solution yet but I've got many paths I can go down at the moment so its just a matter of trying to determine what will be the shortest to the end goal :)

#44
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,486 posts
  • Gender:Male
  • Location:Tru, Venezuela
Hi gsly, thank you very much for your hard work. About "Apple Shipping Drive" (see this thread courtesy by Andy), but even applied, no luck with autosleep. Maybe you are right... about "how" or when to power it off automatically.

#45
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK

Question: Does anyone have idle sleep (aka auto sleep) working?

Idle sleep is via the Energy Saver preferences timeouts and is different than forced sleep via the Apple "Sleep" menu. See this technical Q&A note for details:

http://developer.app...340/_index.html

The reason I ask is that I think the issue with auto sleep is not with the battery driver. After much testing and reading, I believe the issue is that some other driver or software on the system is canceling the auto sleep functionality (again, see note above).

The battery driver just reports battery status up to the power management (PM) layer and doesn't send any details telling the system to sleep. Normally a power policy maker, such as the Energy Saver preferences application defines a power policy that the PM layer implements, and its the PM layer that tells the system to sleep/power down. All drivers (kexts) that control a device that might consume power will hook themselves into the PM layer and they will receive messages when the system is about to auto sleep, etc. However, drivers can reply to this message and cancel auto sleep, but they cannot cancel forced sleep.

Its not clear to me yet what happens if a driver *doesn't* properly handle sleep messages but do hook into the PM layer. I suspect this type of driver would prevent the PM layer from sleeping the machine because it wouldn't send either a "yes, sleep the system" nor a "no, cancel sleep" reply to PM layer message and leave and outstanding hook into the PM layer.

Also, my research indicates this issue with auto sleep happens on real Macs too :unsure: Another possibility might be that the DVD drive is not listed as "Apple Shipping Drive" in system profiler, but rather "Generic" and therefore the system doesn't know how to power it off. I do hear my DVD drive seeking/grinding after the display is turned off when auto sleep should happen, so there might be some merit to this.

Anyway, no solution yet but I've got many paths I can go down at the moment so its just a matter of trying to determine what will be the shortest to the end goal :|

I have auto sleep working both on battery and power cord. Today, I used OSX on battery and it gave me the low battery warning at some point. I waited until two minutes was left but it didn't appear to be going into sleep (it wasn't in idle I went on using it) so I put it into sleep manually. I'll test it again and wait till the end :blowup:

It is true that auto sleep is complicated I have only got it working recently when I applied various DSDT fixes that might have affected sleep i.e black screen on wake when sleep mode 3 is used, Sata fixes that prevent HDX from waking up etc. and also started to use some new kexts. But I don't really know what made the trick. Finally, my blue-ray drive is also seen as Generic and yet, it is true that some DVD drives prevent sleep.

This is irrelevant but I started to use 64 bit and at first, OSX felt more snappy but I thought it was just a placebo effect then I ran Geekbench 64 bit and it amazes me that there has been ~400 points difference in GeekBench score in my case. I always thought that it wouldn't make that difference. Lesson learn. It does.

Do let me know if you want me to test anything apart from the one I mentioned above.

P.S: Your last sentence reminded me of the poem of Robert Frost "The Road Not Taken" :)

#46
manmal

manmal

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 441 posts
hi glsy!
any news on ACPIBattery to behave like real macs (expecially letting system go to sleep when battery is low-level) ?
Plz let us know ...
Thanks!
Mal

#47
3.14r2

3.14r2

    The Round One

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,333 posts
  • Location:Molvania
Reporting success with HP Pavilion DV1660se notebook. It is the first kext to work properly! I suspect the DSDT edit was very useful too.

Both battery and AC adapter are detected properly (with a slight delay though ~1min). Charge calculations are also shown properly (like in Windows/Linux).

Sleep doesn't work as it did before... Not a big deal though ;)

Thank you very much!!!

#48
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK
I don't know if guys also noticed this, iStat Pro doesn't detect battery by default. There is patched version of iStat Pro by Slice, which detects it. I was wondering if does this give a clue about the power loss on battery. May be OS X doesn't detect the battery as the way it should be. It might've stated the obvious ;)

Thank you,

#49
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North

I don't know if guys also noticed this, iStat Pro doesn't detect battery by default. There is patched version of iStat Pro by Slice, which detects it. I was wondering if does this give a clue about the power loss on battery. May be OS X doesn't detect the battery as the way it should be. It might've stated the obvious :thumbsup_anim:

Thank you,

I had a look at what Slice changed although it wasn't easy because the latest unchanged version is newer and much different, but I saw what I suspected. It was the same issue I had with coconutBattery.

In the latter case, coconutBattery queries the IO registry for battery information (in this app, by running a script and parsing the output I suspect) using the value AppleSmartBattery. As the driver in this thread is based on an old Apple driver, the same classes are used so the battery information gets put under the AppleACPIBattery tree. Hence, coconutBattery doesn't see a battery in my Hackintosh.

I believe Slice just patched "AppleSmartBattery" to "AppleACPIBattery " (note the latter is smaller by one character) so iStatPro would be able to find the values.

I do recall looking into this by searching for AppleSmartBattery in the Extensions binaries and a few other locations to see in any parts of the system were hardwired like this but perhaps I should revisit this path.

#50
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK

I had a look at what Slice changed although it wasn't easy because the latest unchanged version is newer and much different, but I saw what I suspected. It was the same issue I had with coconutBattery.

In the latter case, coconutBattery queries the IO registry for battery information (in this app, by running a script and parsing the output I suspect) using the value AppleSmartBattery. As the driver in this thread is based on an old Apple driver, the same classes are used so the battery information gets put under the AppleACPIBattery tree. Hence, coconutBattery doesn't see a battery in my Hackintosh.

I believe Slice just patched "AppleSmartBattery" to "AppleACPIBattery " (note the latter is smaller by one character) so iStatPro would be able to find the values.

I do recall looking into this by searching for AppleSmartBattery in the Extensions binaries and a few other locations to see in any parts of the system were hardwired like this but perhaps I should revisit this path.

Hello gsly,

Thank you for this detailed response.

Recently, I experienced power loss on low battery and now my battery is being reported as service battery, which is another way of saying that "I am dying" :blink:. I guess it was just trigger as I was already expecting such a thing.
It's been more than two years so it will die eventually.

I know Lion is not out yet but any chance you've tried the kext on Lion?
What is the current situation of the development both on Lion and Snow Leopard?

Thanks,

#51
rog53

rog53

    InsanelyMac Protégé

  • Members
  • Pip
  • 2 posts
Hi Gsly,

As you suggested I am posting my issue with battery detection in this thread. I have an asus g53SW the battery portion does not seem to work. Not only I get garbage for model information, it always show the battery condition as "Replace Now" , this is a brand new less than 4 weeks machine.

By looking at the code, it seems to me perhaps the right events are not implemented or not being triggered correctly.
I do appreciate any help you could give me.

Thanks
rog53

Attached Files



#52
artimess

artimess

    InsanelyMac Protégé

  • Members
  • PipPip
  • 97 posts

The following implements a battery manager driver for HP DVx laptops. There are two pieces required to make this work, the AppleACPIBatteryManager.kext (driver) and a DSDT edit.

The driver is generic and will probably work on other platforms that properly implement the _BST and _BIF methods in their DSDT. As the HP _BST method on DVx isn't (IMHO) implemented correctly, DVx owners will also have to implement the DSDT edit so that the _BST method returns proper values to the driver in order to calculate the time remaining (to charge or discharge) value.

This was tested on an HP DV8 but will likely work on any DVx model that implements a similar DSDT method. Also, I have only tested this on a 32-bit kernel, but it should work on a 64-bit kernel as the driver has been compiled to a 10.6 32/64-bit universal (FAT) binary.

There are two zip files below, a debug and release version. The debug version outputs messages to kernel.log and the release version does not, otherwise they are identical.

Step 1: DSDT Edit

In your DSDT.dsl, locate the method UPBS that should look like this:

Method (UPBS, 0, NotSerialized)
			 {
				 Store (^^PCI0.LPCB.EC0.MBRM, Local5)
				 If (LNot (And (Local5, 0x8000)))
				 {
					 ShiftRight (Local5, 0x05, Local5)
					 ShiftLeft (Local5, 0x05, Local5)
					 If (LNotEqual (Local5, DerefOf (Index (PBST, 0x02))))
					 {
						 If (LEqual (^^PCI0.LPCB.EC0.BACR, One))
						 {
							 Store (FABL, Index (PBST, 0x02))
						 }
						 Else
						 {
							 Store (Local5, Index (PBST, 0x02))
						 }
					 }
				 }
 
				 Store (^^PCI0.LPCB.EC0.MBCV, Index (PBST, 0x03))
				 Store (^^PCI0.LPCB.EC0.MBST, Index (PBST, Zero))
			 }
If your method matches the above, replace it with:
Method (UPBS, 0, NotSerialized)
			 {
				 Store (^^PCI0.LPCB.EC0.MBST, Index (PBST, Zero))
				 ^^PCI0.LPCB.EC0.SMRD (0x09, 0x16, 0x0A, RefOf (Local0))
				 Store (Local0, Index (PBST, One))
				 ^^PCI0.LPCB.EC0.SMRD (0x09, 0x16, 0x0F, RefOf (Local1))
				 Store (Local1, Index (PBST, 0x02))
				 ^^PCI0.LPCB.EC0.SMRD (0x09, 0x16, 0x09, RefOf (Local2))
				 Store (Local2, Index (PBST, 0x03))
			 }
Compile it and install as usual.

Step 2: Install Driver

Install the kext in /Extra/Extensions, set the permissions and rebuild your kext cache. Reboot.

Hi Gysly,

Would be possible to have a version of your kext with the possibilty printing trace info?
For example calling a method and passing an string or variable to be printed in a log?
After hours of tracing the code I believe mine is corrupting some of the infomation that is used by your kext to report battery states.

Thanks,
Rog53

#53
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North

I know Lion is not out yet but any chance you've tried the kext on Lion?
What is the current situation of the development both on Lion and Snow Leopard?
Thanks,

I was able to install Lion DP3 on my DV8 last week and then DP4 came out so I'm going to start over with that (and make some install notes for a thread). Once I do that, my next goal is to get this battery driver working in Lion as well as testing the auto-sleep functionality in a relatively virgin OS (no third party software, etc) as I think in my SL environment, some piece of software is causing cancellation of the auto-sleep.

I hope to update this thread soon with the current version of the driver that adds some more functionality/options. Maybe in the next week or two.


Hi Gysly,

Would be possible to have a version of your kext with the possibilty printing trace info?
For example calling a method and passing an string or variable to be printed in a log?
After hours of tracing the code I believe mine is corrupting some of the infomation that is used by your kext to report battery states.

Thanks,
Rog53

I'll try to update this thread soon with the current version that had more debug output than the first one. I'll also look at your DSDT and maybe post some commented code/fixes if I can spot anything.

#54
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK

Recently, I experienced power loss on low battery and now my battery is being reported as service battery, which is another way of saying that "I am dying" :). I guess it was just trigger as I was already expecting such a thing.
It's been more than two years so it will die eventually.

Weird enough is that my battery, after one week, went back to normal. It was a temporary glitch I guess.

I was able to install Lion DP3 on my DV8 last week and then DP4 came out so I'm going to start over with that (and make some install notes for a thread). Once I do that, my next goal is to get this battery driver working in Lion as well as testing the auto-sleep functionality in a relatively virgin OS (no third party software, etc) as I think in my SL environment, some piece of software is causing cancellation of the auto-sleep.

For auto sleep, have you tried using Please Sleep. I tried that on my desktop and it works as expected. Also, there is a CHUD application, which comes with Xcode, called SpindownHDD.app. It shows you the current status of devices connected through SATA. As it is already known that some dvd drives cause auto sleep problem, it might be better off checking it first.

I was planing to install DP3 and then came out DP4. I hope to give it a try soon though.
Thank you for your time and effort.

#55
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North

Weird enough is that my battery, after one week, went back to normal. It was a temporary glitch I guess.

For auto sleep, have you tried using Please Sleep. I tried that on my desktop and it works as expected. Also, there is a CHUD application, which comes with Xcode, called SpindownHDD.app. It shows you the current status of devices connected through SATA. As it is already known that some dvd drives cause auto sleep problem, it might be better off checking it first.

I was planing to install DP3 and then came out DP4. I hope to give it a try soon though.
Thank you for your time and effort.

The current version of the driver (I can't recall if the one posted here does this) will pull the number of cycles and manufacture date from the battery and these combined with the "design capacity" (what the battery should hold when new) and the "last full charge capacity" (what the battery currently holds for a charge) should be a good indicator of battery health.

Interestingly, Apple's driver polls their batteries for health information as well, but it uses proprietary Smart Battery commands specific to the battery controller they use. I wasn't able to find a data-sheet or any other information for the HP battery controller to implement the same functionality.

I did play with Please Sleep but I recall it didn't help on my system. I will check into the SpindownHDD tool though to see what it shows...

I was able to get my DP4 USB installer to boot last night, but I haven't tried an install yet. For DP3 I just did a GPT install to an external drive, but for DP4 I'm going to try an MBR install (via Nawcom patch) to external drive as it seems the HP BIOS (F.25) in my DV8 won't show a GPT as a bootable drive, only MBR.

#56
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK

The current version of the driver (I can't recall if the one posted here does this) will pull the number of cycles and manufacture date from the battery and these combined with the "design capacity" (what the battery should hold when new) and the "last full charge capacity" (what the battery currently holds for a charge) should be a good indicator of battery health.

Interestingly, Apple's driver polls their batteries for health information as well, but it uses proprietary Smart Battery commands specific to the battery controller they use. I wasn't able to find a data-sheet or any other information for the HP battery controller to implement the same functionality.

I did play with Please Sleep but I recall it didn't help on my system. I will check into the SpindownHDD tool though to see what it shows...

I was able to get my DP4 USB installer to boot last night, but I haven't tried an install yet. For DP3 I just did a GPT install to an external drive, but for DP4 I'm going to try an MBR install (via Nawcom patch) to external drive as it seems the HP BIOS (F.25) in my DV8 won't show a GPT as a bootable drive, only MBR.

I am using the one in the first page and it shows the following. No Cycle Count.
Attached File  Screen_shot_2011_06_14_at_20.19.53.png   61.49KB   42 downloads
The patched version of iStat Pro shows the health level of the battery as 83% but I don't know how accurate it is.

#57
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North

I am using the one in the first page and it shows the following. No Cycle Count.
Attached File  Screen_shot_2011_06_14_at_20.19.53.png   61.49KB   42 downloads
The patched version of iStat Pro shows the health level of the battery as 83% but I don't know how accurate it is.

Here is what the current driver shows for my DV8:

Attached File  Screen_shot_2011_06_18_at_4.56.07_PM.png   59.23KB   23 downloads

I was able to install Lion DP4 today and I put the current driver on it but the OS doesn't seem to recognize there is a battery installed :) Looks like Apple changed something and I can't compile anything until I can get the Xcode version that will install on Lion as the current 4.0 tells me to update to 10.6.6 in order to install on 10.7 :D

I suspect 10.6.8 will be out *real* soon so I'll probably wait until I can update to 10.6.8 and test before updating this thread with the current driver. Hopefully by then, 10.7 will be official and I can figure out what changed...

#58
JBraddock

JBraddock

    Ph.D (Can) in Human Rights

  • Members
  • PipPipPipPipPipPipPip
  • 549 posts
  • Location:UK

Here is what the current driver shows for my DV8:

I was able to install Lion DP4 today and I put the current driver on it but the OS doesn't seem to recognize there is a battery installed :( Looks like Apple changed something and I can't compile anything until I can get the Xcode version that will install on Lion as the current 4.0 tells me to update to 10.6.6 in order to install on 10.7 :)

I suspect 10.6.8 will be out *real* soon so I'll probably wait until I can update to 10.6.8 and test before updating this thread with the current driver. Hopefully by then, 10.7 will be official and I can figure out what changed...

I want to install DP4 as well but then I know that Lion will come out next month so I don't want to spend too much time on it as it is likely that there wil one or two releases before the final version. Things might change. For now, at least, as you said, it is better to wait for 10.6.8. As far as I've read, it includes some changes that we will see on Lion i.e power management and speed step, audio.

Whenever you have something we could test, please let us know.

Thank you.

#59
gsly

gsly

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 143 posts
  • Gender:Male
  • Location:The Great White North
We were right about 10.6.8 being available soon! :)

However, Apple ain't making this easy ;) I cloned my 10.6.7 install yesterday and installed the 10.6.8 combo update (installed fine), but at reboot it looks like they changed the kernel enough that Meklort's LAPIC kernel patcher in his Chameleon branch doesn't work anymore and I got a kernel panic. Then I tried to use the "cpus=1" option to boot so the kernel wouldn't try to initialize the interrupts incorrectly but I still got a kernel panic :(

I'm thinking I may have to go on a little side project and dig into this stupid HP BIOS and see if I can patch/rewrite the processor initialization functionality so I don't have to deal with this {censored}!

I'll probably revert to 10.6.7 for now until I can get a look at the kernel source to see WTF has changed.

JBraddock, I see you have updated to 10.6.8 from another thread. Does the battery driver still work on 10.6.8? Thanks.

#60
3.14r2

3.14r2

    The Round One

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,333 posts
  • Location:Molvania

Does the battery driver still work on 10.6.8? Thanks.

50/50. No battery symbol is displayed in the menu bar (or whatever it is called), but if we look in System Preferences > Energy saver, the battery info is there. Go figure..

EDIT:
Battery info is also displayed (correctly) in System Profiler > Power

EDIT2:
Solved the other problem with no networking (renamed Apple80211Monitor.bundle) and GUESS WHAT... the icon is in the place again! Bottom line, it is working in 10.6.8.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy