/** * Free the widget and the associated descriptor. */ void WidgetDetectorThread::InternalFreeWidget(SerialWidgetInterface *widget) { ConnectedDescriptor *descriptor = widget->GetDescriptor(); // remove descriptor from our ss if it's there m_ss.RemoveReadDescriptor(descriptor); delete widget; FreeDescriptor(descriptor); }
/** * Called when this descriptor fails discovery */ void WidgetDetectorThread::DescriptorFailed( ConnectedDescriptor *descriptor) { m_ss.RemoveReadDescriptor(descriptor); if (descriptor->ValidReadDescriptor()) { PerformNextDiscoveryStep(descriptor); } else { FreeDescriptor(descriptor); } }
/** * Perform the next step in discovery for this descriptor. * @pre the descriptor exists in m_active_descriptors */ void WidgetDetectorThread::PerformNextDiscoveryStep( ConnectedDescriptor *descriptor) { DescriptorInfo &descriptor_info = m_active_descriptors[descriptor]; descriptor_info.second++; if (static_cast<unsigned int>(descriptor_info.second) == m_widget_detectors.size()) { OLA_INFO << "no more detectors to try for " << descriptor; FreeDescriptor(descriptor); } else { OLA_INFO << "trying stage " << descriptor_info.second << " for " << descriptor; m_ss.AddReadDescriptor(descriptor); bool ok = m_widget_detectors[descriptor_info.second]->Discover(descriptor); if (!ok) { m_ss.RemoveReadDescriptor(descriptor); FreeDescriptor(descriptor); } } }
VOID CleanupAsyncList(PEHCI_HOST_CONTROLLER hcd) { PQUEUE_TRANSFER_DESCRIPTOR Descriptor; PQUEUE_HEAD QueueHead; KIRQL OldIrql; KeAcquireSpinLock(&hcd->Lock, &OldIrql); QueueHead = hcd->CompletedListQueue; QueueHead = QueueHead->NextQueueHead; while (QueueHead != hcd->CompletedListQueue) { Descriptor = QueueHead->FirstTransferDescriptor; while (Descriptor) { if (Descriptor->Token.Bits.PIDCode == PID_CODE_SETUP_TOKEN) ReleaseMemory(hcd, Descriptor->BufferPointerVA[0]); FreeDescriptor(hcd, Descriptor); Descriptor = Descriptor->NextDescriptor; } if (QueueHead->FreeMdl) { DPRINT("Freeing Mdl %x, StartVA %x\n", QueueHead->Mdl, QueueHead->Mdl->StartVa); IoFreeMdl(QueueHead->Mdl); } QueueHead = QueueHead->NextQueueHead; } hcd->CompletedListQueue->NextQueueHead = hcd->CompletedListQueue; hcd->CompletedListQueue->PreviousQueueHead = hcd->CompletedListQueue; KeReleaseSpinLock(&hcd->Lock, OldIrql); }
/** * Called when a new widget becomes ready. Ownership of both objects transferrs * to use. */ void WidgetDetectorThread::UsbProWidgetReady( ConnectedDescriptor *descriptor, const UsbProWidgetInformation *information) { // we're no longer interested in events from this widget m_ss.RemoveReadDescriptor(descriptor); if (!m_handler) { OLA_WARN << "No callback defined for new Usb Pro Widgets."; FreeDescriptor(descriptor); delete information; return; } switch (information->esta_id) { case DMX_KING_ESTA_ID: if (information->device_id == DMX_KING_ULTRA_PRO_ID) { // The Ultra device has two outputs DispatchWidget( new UltraDMXProWidget( m_other_ss, descriptor), information); return; } else { // DMXKing devices are drop in replacements for a Usb Pro DispatchWidget( new EnttecUsbProWidget( m_other_ss, descriptor, information->esta_id, information->serial), information); return; } case GODDARD_ESTA_ID: if (information->device_id == GODDARD_DMXTER4_ID || information->device_id == GODDARD_MINI_DMXTER4_ID) { DispatchWidget( new DmxterWidget( descriptor, information->esta_id, information->serial), information); return; } break; case JESE_ESTA_ID: if (information->device_id == JESE_DMX_TRI_ID || information->device_id == JESE_RDM_TRI_ID) { DispatchWidget( new DmxTriWidget( m_other_ss, descriptor), information); return; } break; case OPEN_LIGHTING_ESTA_CODE: if (information->device_id == OPEN_LIGHTING_RGB_MIXER_ID || information->device_id == OPEN_LIGHTING_PACKETHEADS_ID) { DispatchWidget( new ArduinoWidget( descriptor, information->esta_id, information->serial), information); return; } break; } OLA_WARN << "Defaulting to a Usb Pro device"; DispatchWidget( new EnttecUsbProWidget( m_other_ss, descriptor, information->esta_id, information->serial), information); }