Skip to content

Commit

Permalink
AirportItlwm: add power state handler for IOPCIEDeviceWrapper driver,…
Browse files Browse the repository at this point in the history
… this fix the sleep/wake issue on Sonoma(#937).
  • Loading branch information
zxystd committed Feb 26, 2024
1 parent 3999899 commit 618eb94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions AirportItlwm/IOPCIEDeviceWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ OSDefineMetaClassAndStructors(IOPCIEDeviceWrapper, IOService);
#define PCI_MSIX_FLAGS_ENABLE 0x8000 /* MSI-X enable */
#define PCI_MSI_FLAGS_ENABLE 0x0001 /* MSI feature enabled */

static IOPMPowerState powerStateArray[2] =
{
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, kIOPMDeviceUsable, kIOPMPowerOn, kIOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0}
};

static void pciMsiSetEnable(IOPCIDevice *device, UInt8 msiCap, int enable)
{
UInt16 control;
Expand Down Expand Up @@ -105,6 +111,9 @@ start(IOService *provider)
IOLog("%s::super start succeed\n", getName());
UInt8 builtIn = 0;
setProperty("built-in", OSData::withBytes(&builtIn, sizeof(builtIn)));
PMinit();
registerPowerDriver(this, powerStateArray, 2);
provider->joinPMtree(this);
registerService();
return true;
}
Expand All @@ -113,5 +122,12 @@ void IOPCIEDeviceWrapper::
stop(IOService *provider)
{
XYLog("%s\n", __PRETTY_FUNCTION__);
PMstop();
super::stop(provider);
}

IOReturn IOPCIEDeviceWrapper::
setPowerState(unsigned long powerStateOrdinal, IOService *whatDevice)
{
return IOPMAckImplied;
}
3 changes: 3 additions & 0 deletions AirportItlwm/IOPCIEDeviceWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class IOPCIEDeviceWrapper : public IOService {
virtual bool start(IOService *provider) override;
virtual void stop(IOService *provider) override;
virtual IOWorkLoop* getWorkLoop() const override;
virtual IOReturn setPowerState(
unsigned long powerStateOrdinal,
IOService * whatDevice ) override;

public:
ItlHalService *fHalService;
Expand Down

0 comments on commit 618eb94

Please sign in to comment.