-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set LIBKERN_RETURN_RETAINED * Add PS/2 stub driver * Create companion device in start instead of probe * Retain/Release companion info dictionary * Clean up PS2 stub device * Save OSSymbol in class * Save symbol in class * Update copyright
- Loading branch information
1 parent
43dac6d
commit 4750716
Showing
9 changed files
with
202 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// VoodooPS2SMBusDevice.cpp | ||
// VoodooPS2Trackpad | ||
// | ||
// Created by Avery Black on 9/13/24. | ||
// Copyright © 2024 Acidanthera. All rights reserved. | ||
// | ||
|
||
#include "VoodooPS2SMBusDevice.h" | ||
|
||
// ============================================================================= | ||
// ApplePS2SmbusDevice Class Implementation | ||
// | ||
|
||
OSDefineMetaClassAndStructors(ApplePS2SmbusDevice, IOService); | ||
|
||
ApplePS2SmbusDevice *ApplePS2SmbusDevice::withReset(bool resetNeeded, OSDictionary *data, uint8_t addr) { | ||
ApplePS2SmbusDevice *dev = OSTypeAlloc(ApplePS2SmbusDevice); | ||
|
||
if (dev == nullptr) { | ||
return nullptr; | ||
} | ||
|
||
if (!dev->init()) { | ||
OSSafeReleaseNULL(dev); | ||
return nullptr; | ||
} | ||
|
||
dev->_resetNeeded = resetNeeded; | ||
dev->_data = data; | ||
dev->_data->retain(); | ||
dev->_addr = addr; | ||
return dev; | ||
} | ||
|
||
bool ApplePS2SmbusDevice::start(IOService *provider) { | ||
if (!super::start(provider)) | ||
return false; | ||
|
||
_nub = OSDynamicCast(ApplePS2MouseDevice, provider); | ||
if (_nub == nullptr) | ||
return false; | ||
|
||
if (_resetNeeded) | ||
resetDevice(); | ||
|
||
if (_nub->startSMBusCompanion(_data, _addr) != kIOReturnSuccess) { | ||
return false; | ||
} | ||
|
||
_nub->installPowerControlAction(this, | ||
OSMemberFunctionCast(PS2PowerControlAction, this, &ApplePS2SmbusDevice::powerAction)); | ||
return true; | ||
} | ||
|
||
void ApplePS2SmbusDevice::free() { | ||
OSSafeReleaseNULL(_data); | ||
super::free(); | ||
} | ||
|
||
void ApplePS2SmbusDevice::powerAction(uint32_t ordinal) { | ||
if (ordinal == kPS2C_EnableDevice && _resetNeeded) { | ||
(void) resetDevice(); | ||
} | ||
} | ||
|
||
IOReturn ApplePS2SmbusDevice::resetDevice() { | ||
TPS2Request<> request; | ||
request.commands[0].command = kPS2C_SendCommandAndCompareAck; | ||
request.commands[0].inOrOut = kDP_SetDefaultsAndDisable; // F5 | ||
request.commandsCount = 1; | ||
_nub->submitRequestAndBlock(&request); | ||
|
||
if (request.commandsCount == 1) { | ||
DEBUG_LOG("VoodooPS2Trackpad: sending $FF failed: %d\n", request.commandsCount); | ||
return kIOReturnError; | ||
} | ||
|
||
return kIOReturnSuccess; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// VoodooPS2SMBusDevice.hpp | ||
// VoodooPS2Trackpad | ||
// | ||
// Created by Avery Black on 9/13/24. | ||
// Copyright © 2024 Acidanthera. All rights reserved. | ||
// | ||
|
||
#ifndef VoodooPS2SMBusDevice_hpp | ||
#define VoodooPS2SMBusDevice_hpp | ||
|
||
|
||
#include "../VoodooPS2Controller/ApplePS2MouseDevice.h" | ||
#include <IOKit/IOCommandGate.h> | ||
|
||
#include "VoodooPS2TrackpadCommon.h" | ||
|
||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
// ApplePS2SmbusDevice Class Declaration | ||
// Synaptics and Elans devices still need resets over PS2. This acts as a | ||
// PS/2 stub driver that attaches in lieu of the full touchpad driver to reset | ||
// on wakeups and sleep. This also prevents other devices attaching and using | ||
// the otherwise unused PS/2 interface | ||
// | ||
|
||
class EXPORT ApplePS2SmbusDevice : public IOService { | ||
typedef IOService super; | ||
OSDeclareDefaultStructors(ApplePS2SmbusDevice); | ||
public: | ||
static ApplePS2SmbusDevice *withReset(bool resetNeeded, OSDictionary *data, uint8_t addr); | ||
|
||
bool start(IOService *provider) override; | ||
void free() override; | ||
|
||
private: | ||
ApplePS2MouseDevice *_nub {nullptr}; | ||
bool _resetNeeded {false}; | ||
OSDictionary *_data {nullptr}; | ||
uint8_t _addr{0}; | ||
|
||
IOReturn resetDevice(); | ||
void powerAction(uint32_t ordinal); | ||
}; | ||
|
||
#endif /* VoodooPS2SMBusDevice_hpp */ |
Oops, something went wrong.