aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander von Gluck IV <kallisti5@unixzen.com>2012-07-22 11:57:25 -0500
committerAlexander von Gluck IV <kallisti5@unixzen.com>2012-07-22 11:57:25 -0500
commit52b7ccf49e8215e58c9c341e013999ee1795848b (patch)
tree9137b8462e8bd0788f4a861b55dfbb3cbdb8a64b
parentb3b04af940fef90e722a590596527c6cc79920a3 (diff)
usb_serial: Probe for USB endpoints on Option devicehrev44379
* 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.
-rw-r--r--src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp54
-rw-r--r--src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp10
2 files changed, 57 insertions, 7 deletions
diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
index 2b09e67b6c..8c0de2a0f7 100644
--- a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
+++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
@@ -24,8 +24,58 @@ OptionDevice::AddDevice(const usb_configuration_info *config)
{
TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config);
- status_t status = B_OK;
- return status;
+ if (config->interface_count > 0) {
+ 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;
}
diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
index 9c888789ed..e3d1694195 100644
--- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
+++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
@@ -725,7 +725,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
/ sizeof(kFTDIDevices[0]); i++) {
if (vendorID == kFTDIDevices[i].vendorID
&& productID == kFTDIDevices[i].productID) {
- return new(std::nothrow) FTDIDevice(device, vendorID, productID,
+ return new(std::nothrow) FTDIDevice(device, vendorID, productID,
kFTDIDevices[i].deviceName);
}
}
@@ -735,7 +735,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
/ sizeof(kKLSIDevices[0]); i++) {
if (vendorID == kKLSIDevices[i].vendorID
&& productID == kKLSIDevices[i].productID) {
- return new(std::nothrow) KLSIDevice(device, vendorID, productID,
+ return new(std::nothrow) KLSIDevice(device, vendorID, productID,
kKLSIDevices[i].deviceName);
}
}
@@ -745,7 +745,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
/ sizeof(kProlificDevices[0]); i++) {
if (vendorID == kProlificDevices[i].vendorID
&& productID == kProlificDevices[i].productID) {
- return new(std::nothrow) ProlificDevice(device, vendorID, productID,
+ return new(std::nothrow) ProlificDevice(device, vendorID, productID,
kProlificDevices[i].deviceName);
}
}
@@ -755,7 +755,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
/ sizeof(kSiliconDevices[0]); i++) {
if (vendorID == kSiliconDevices[i].vendorID
&& productID == kSiliconDevices[i].productID) {
- return new(std::nothrow) SiliconDevice(device, vendorID, productID,
+ return new(std::nothrow) SiliconDevice(device, vendorID, productID,
kSiliconDevices[i].deviceName);
}
}
@@ -768,7 +768,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
/ sizeof(kOptionDevices[0]); i++) {
if (vendorID == kOptionDevices[i].vendorID
&& productID == kOptionDevices[i].productID) {
- return new(std::nothrow) OptionDevice(device, vendorID, productID,
+ return new(std::nothrow) OptionDevice(device, vendorID, productID,
kOptionDevices[i].deviceName);
}
}