Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RehabMan committed Aug 27, 2017
2 parents 91f259a + 583f1ce commit 4181a3d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Build
build/*
!build/readme.txt
DerivedData
Distribute
ACPIBatteryManager.xcodeproj/project.xcworkspace/xcuserdata
Expand Down
15 changes: 14 additions & 1 deletion AppleSmartBatteryManager/AppleSmartBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ bool AppleSmartBattery::start(IOService *provider)
setProperty( kIOPMPSPostDishargeWaitSecondsKey, kPostDischargeWaitSeconds, NUM_BITS);

// zero out battery state with argument (do_set == true)
fStartupFastPoll = 10;
fPollingInterval = kQuickPollInterval;
clearBatteryState(false);

// some DSDT implementations aren't ready to read the EC yet, so avoid false reading
Expand Down Expand Up @@ -452,6 +454,16 @@ bool AppleSmartBattery::pollBatteryState(int path)
fPollTimer->cancelTimeout();
if (!fPollingOverridden)
{
// at startup, polling is quick for slow to respond ACPI implementations
if (fStartupFastPoll)
{
DebugLog("fStartupFastPoll=%d\n", fStartupFastPoll);
--fStartupFastPoll;
if (!fStartupFastPoll)
fPollingInterval = kDefaultPollInterval;
}

DebugLog("fRealAC=%d, fACConnected=%d\n", fRealAC, fACConnected);
if (-1 == fRealAC || fRealAC == fACConnected)
{
// Restart timer with standard polling interval
Expand Down Expand Up @@ -1809,7 +1821,8 @@ IOReturn AppleSmartBattery::setBatteryBST(OSArray *acpibat_bst)

DebugLog("Battery is charged.\n");
}


fStartupFastPoll = 0;
if (!fPollingOverridden && fMaxCapacity) {
/*
* Conditionally set polling interval to 1 second if we're
Expand Down
4 changes: 2 additions & 2 deletions AppleSmartBatteryManager/AppleSmartBattery.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ class EXPORT AppleSmartBattery : public IOPMPowerSource
UInt32 convertWattsToAmps(UInt32 watts, bool useDesignVoltage);

private:

UInt32 fPowerUnit;
UInt32 fDesignVoltage;
UInt32 fCurrentVoltage;
Expand Down Expand Up @@ -359,6 +358,7 @@ class EXPORT AppleSmartBattery : public IOPMPowerSource
UInt32 fManufactureDate;

int fRealAC;
int fStartupFastPoll;

public:

Expand All @@ -370,4 +370,4 @@ class EXPORT AppleSmartBattery : public IOPMPowerSource

};

#endif
#endif
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ http://www.tonymacx86.com/hp-probook/69472-battery-manager-fix-boot-without-batt
- Fix problem with Activity Monitor "Energy" tab, by changing class names to AppleSmartBatteryManager and AppleSmartBattery


2017-04-28 v1.70.3

- Add quick polling for the first 10 seconds of startup for the case the EC/ACPI does not respond correctly at startup. This quick poll will be cancelled once a battery status is succesfully acquired, or after the 10 seconds.


2016-11-18 v1.70.2

- Fix problem where incorrect _BST code returns status of "discharging" when at full charge, AC adapter still plugged in.
Expand Down
4 changes: 2 additions & 2 deletions SSDT-BATC.dsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ DefinitionBlock ("", "SSDT", 2, "hack", "BATC", 0)
Scope(_SB.PCI0.LPC.EC)
{
External(BAT0, DeviceObj)
External(BAT0._HID, StrObj)
External(BAT0._HID, IntObj)
External(BAT0._STA, MethodObj)
External(BAT0._BIF, MethodObj)
External(BAT0._BST, MethodObj)
External(BAT1, DeviceObj)
External(BAT1._HID, StrObj)
External(BAT1._HID, IntObj)
External(BAT1._STA, MethodObj)
External(BAT1._BIF, MethodObj)
External(BAT1._BST, MethodObj)
Expand Down
1 change: 1 addition & 0 deletions build/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Locaton for build products

0 comments on commit 4181a3d

Please sign in to comment.