Skip to content

Commit

Permalink
Add boolean checks to prevent unfairness
Browse files Browse the repository at this point in the history
  • Loading branch information
kprinssu committed Oct 20, 2017
1 parent 4e70c1f commit bc2b9fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ xcuserdata/
*.moved-aside
*.xccheckout
*.xcscmblueprint

*.DS_Store
25 changes: 20 additions & 5 deletions VoodooI2CELAN/VoodooI2CELANTouchpadDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool VoodooI2CELANTouchpadDriver::init(OSDictionary *properties) {

awake = true;
readyForInput = false;
readInProgress = false;

return true;
}
Expand Down Expand Up @@ -321,13 +322,18 @@ bool VoodooI2CELANTouchpadDriver::initELANDevice() {
}

void VoodooI2CELANTouchpadDriver::interruptOccurred(OSObject* owner, IOInterruptEventSource* src, int intCount) {
// IOLog("ELAN: Interrupt occurred!\n");
if(readInProgress)
return;

if (!awake)
return;

readInProgress = true;

thread_t new_thread;
kern_return_t ret = kernel_thread_start(OSMemberFunctionCast(thread_continue_t, this, &VoodooI2CELANTouchpadDriver::handleELANInput), this, &new_thread);
if (ret != KERN_SUCCESS){
readInProgress = false;
IOLog("ELAN: Thread error while attempint to get input report\n");
} else {
thread_deallocate(new_thread);
Expand Down Expand Up @@ -514,6 +520,7 @@ void VoodooI2CELANTouchpadDriver::handleELANInput() {
}

commandGate->attemptAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooI2CELANTouchpadDriver::parseELANReport));
readInProgress = false;
}

void VoodooI2CELANTouchpadDriver::setELANSleepStatus(bool enable) {
Expand Down Expand Up @@ -598,12 +605,20 @@ void VoodooI2CELANTouchpadDriver::stop(IOService* provider) {
}

IOReturn VoodooI2CELANTouchpadDriver::setPowerState(unsigned long longpowerStateOrdinal, IOService* whatDevice) {
/*if (whatDevice != this)
if (whatDevice != this)
return kIOReturnInvalid;
if (longpowerStateOrdinal == 0){
if (awake){
awake = false;

for(;;) {
if(!readInProgress) {
break;
}

IOSleep(10);
}

// Off
setELANSleepStatus(false);

Expand All @@ -617,8 +632,8 @@ IOReturn VoodooI2CELANTouchpadDriver::setPowerState(unsigned long longpowerState
awake = true;
IOLog("ELAN: Woke up\n");
}
} */
IOLog("ELAN: set power state called\n");
return super::setPowerState(longpowerStateOrdinal, whatDevice);
}

return kIOPMAckImplied;
}

1 change: 1 addition & 0 deletions VoodooI2CELAN/VoodooI2CELANTouchpadDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class VoodooI2CELANTouchpadDriver : public IOService {

bool awake;
bool readyForInput;
bool readInProgress;

// Hardware dimensions
int maxHWResolutionX;
Expand Down

0 comments on commit bc2b9fa

Please sign in to comment.