@@ -216,11 +216,13 @@ void VoodooI2CGoodixTouchDriver::interrupt_occurred(OSObject* owner, IOInterrupt
216216 return ;
217217 if (!awake)
218218 return ;
219+ interrupt_source->disable ();
219220 read_in_progress = true ;
220221 thread_t new_thread;
221222 kern_return_t ret = kernel_thread_start (OSMemberFunctionCast (thread_continue_t , this , &VoodooI2CGoodixTouchDriver::handle_input_threaded), this , &new_thread);
222223 if (ret != KERN_SUCCESS) {
223224 read_in_progress = false ;
225+ interrupt_source->enable ();
224226 IOLog (" %s::Thread error while attemping to get input report: %d\n " , getName (), ret);
225227 } else {
226228 thread_deallocate (new_thread);
@@ -237,15 +239,25 @@ void VoodooI2CGoodixTouchDriver::handle_input_threaded() {
237239 return ;
238240 }
239241 command_gate->attemptAction (OSMemberFunctionCast (IOCommandGate::Action, this , &VoodooI2CGoodixTouchDriver::goodix_process_events));
242+ goodix_end_cmd ();
243+ interrupt_source->enable ();
240244 read_in_progress = false ;
241245}
242246
247+ IOReturn VoodooI2CGoodixTouchDriver::goodix_end_cmd () {
248+ IOReturn retVal = goodix_write_reg (GOODIX_READ_COOR_ADDR, 0 );
249+ if (retVal != kIOReturnSuccess ) {
250+ IOLog (" %s::I2C write end_cmd 0 error: %d\n " , getName (), retVal);
251+ }
252+ return retVal;
253+ }
254+
243255/* Ported from goodix.c */
244256IOReturn VoodooI2CGoodixTouchDriver::goodix_process_events () {
245257 UInt8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
246258
247259 numTouches = goodix_ts_read_input_report (point_data);
248- if (numTouches < 0 ) {
260+ if (numTouches <= 0 ) {
249261 return kIOReturnSuccess ;
250262 }
251263
@@ -259,12 +271,6 @@ IOReturn VoodooI2CGoodixTouchDriver::goodix_process_events() {
259271 goodix_ts_report_touch (&point_data[1 + GOODIX_CONTACT_SIZE * i], touches);
260272 }
261273
262- IOReturn retVal = goodix_write_reg (GOODIX_READ_COOR_ADDR, 0 );
263- if (retVal != kIOReturnSuccess ) {
264- IOLog (" %s::I2C write end_cmd error: %d\n " , getName (), retVal);
265- return retVal;
266- }
267-
268274 if (numTouches > 0 ) {
269275 // send the event into the event driver
270276 event_driver->reportTouches (touches, numTouches);
0 commit comments