Skip to content

Commit

Permalink
Impl polling mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EmotionalLove authored Aug 13, 2019
1 parent 216d500 commit cadc275
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions VoodooI2CSynaptics/VoodooI2CSynapticsDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ void VoodooI2CSynapticsDevice::releaseResources() {
interrupt_source->release();
interrupt_source = NULL;
}

if (interrupt_simulator) {
interrupt_simulator->disable();
work_loop->removeEventSource(interrupt_simulator);
interrupt_simulator->release();
interrupt_simulator = NULL;
}

if (work_loop) {
work_loop->release();
Expand Down Expand Up @@ -221,14 +228,23 @@ bool VoodooI2CSynapticsDevice::start(IOService* api) {
goto exit;
}

/* Sasha - Attempt implementation of polling */
interrupt_source = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &VoodooI2CSynapticsDevice::interruptOccured), api, 0);
if (!interrupt_source) {
IOLog("%s::%s Could not get interrupt event source\n", getName(), name);
goto exit;
IOLog("%s::%s Could not get interrupt event source\n, trying to fallback on polling.", getName(), name);
interrupt_simulator = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &VoodooI2CSynapticsDevice::simulateInterrupt));
if (!interrupt_simulator) {
IOLog("%s::%s Could not get timer event source\n", getName(), name);
goto exit;
}
work_loop->addEventSource(interrupt_simulator);
interrupt_simulator->setTimeoutMS(200);
IOLog("%s::%s Polling mode initialisation succeeded.", getName(), name);
} else {
work_loop->addEventSource(interrupt_source);
interrupt_source->enable();
}

work_loop->addEventSource(interrupt_source);
interrupt_source->enable();
/* End Sasha */

PMinit();
api->joinPMtree(this);
Expand Down Expand Up @@ -1062,3 +1078,9 @@ void VoodooI2CSynapticsDevice::unpublish_multitouch_interface() {
mt_interface = NULL;
}
}

/* Sasha - impl polling */
void VoodooI2CSynapticsDevice::simulateInterrupt(OSObject* owner, IOTimerEventSource *timer) {
interruptOccured(owner, NULL, NULL);
interrupt_simulator->setTimeoutMS(INTERRUPT_SIMULATOR_TIMEOUT);
}

0 comments on commit cadc275

Please sign in to comment.