usb_serial: Probe for USB endpoints on Option device
* More then one serial port is common, for now we only work off of the first one detected. * Still disabled as some setup is needed.
This commit is contained in:
@@ -24,8 +24,58 @@ OptionDevice::AddDevice(const usb_configuration_info *config)
|
|||||||
{
|
{
|
||||||
TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config);
|
TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config);
|
||||||
|
|
||||||
status_t status = B_OK;
|
if (config->interface_count > 0) {
|
||||||
return status;
|
for (size_t index = 0; index < config->interface_count; index++) {
|
||||||
|
usb_interface_info *interface = config->interface[index].active;
|
||||||
|
|
||||||
|
int txEndpointID = -1;
|
||||||
|
int rxEndpointID = -1;
|
||||||
|
int irEndpointID = -1;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < interface->endpoint_count; i++) {
|
||||||
|
usb_endpoint_info *endpoint = &interface->endpoint[i];
|
||||||
|
|
||||||
|
// Find our Interrupt endpoint
|
||||||
|
if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_INTERRUPT
|
||||||
|
&& (endpoint->descr->endpoint_address
|
||||||
|
& USB_ENDPOINT_ADDR_DIR_IN) != 0) {
|
||||||
|
irEndpointID = i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find our Transmit / Receive endpoints
|
||||||
|
if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_BULK) {
|
||||||
|
if ((endpoint->descr->endpoint_address
|
||||||
|
& USB_ENDPOINT_ADDR_DIR_IN) != 0) {
|
||||||
|
rxEndpointID = i;
|
||||||
|
} else {
|
||||||
|
txEndpointID = i;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("> OptionDevice::%s: endpoint %d, tx: %d, rx: %d, ir: %d\n",
|
||||||
|
__func__, index, txEndpointID, rxEndpointID, irEndpointID);
|
||||||
|
|
||||||
|
if (txEndpointID < 0 || rxEndpointID < 0 || irEndpointID < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TRACE("> OptionDevice::%s: found at interface %d\n", __func__,
|
||||||
|
index);
|
||||||
|
usb_endpoint_info *irEndpoint = &interface->endpoint[irEndpointID];
|
||||||
|
usb_endpoint_info *txEndpoint = &interface->endpoint[irEndpointID];
|
||||||
|
usb_endpoint_info *rxEndpoint = &interface->endpoint[irEndpointID];
|
||||||
|
SetControlPipe(irEndpoint->handle);
|
||||||
|
SetReadPipe(rxEndpoint->handle);
|
||||||
|
SetWritePipe(txEndpoint->handle);
|
||||||
|
|
||||||
|
// We accept the first found serial interface
|
||||||
|
// TODO: We should set each matching interface up (can be > 1)
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user