Initialize the endpoints of all interfaces of the configuration to be set. Fixes stuff that needs more than one interface at the same time (ACM modems for example).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21741 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2007-07-29 21:46:10 +00:00
parent 4bef3723a1
commit 8040388202
+39 -35
View File
@@ -330,41 +330,43 @@ Device::SetConfigurationAt(uint8 index)
fCurrentConfiguration = &fConfigurations[index]; fCurrentConfiguration = &fConfigurations[index];
// Initialize all the endpoints that are now active // Initialize all the endpoints that are now active
usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[0].active; for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) {
for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active;
usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) {
Pipe *pipe = NULL; usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i];
Pipe *pipe = NULL;
switch (endpoint->descr->attributes & 0x03) { switch (endpoint->descr->attributes & 0x03) {
case 0x00: /* Control Endpoint */ case 0x00: /* Control Endpoint */
pipe = new(std::nothrow) ControlPipe(this, fDeviceAddress, pipe = new(std::nothrow) ControlPipe(this, fDeviceAddress,
endpoint->descr->endpoint_address & 0x0f, fSpeed, endpoint->descr->endpoint_address & 0x0f, fSpeed,
endpoint->descr->max_packet_size); endpoint->descr->max_packet_size);
break; break;
case 0x01: /* Isochronous Endpoint */ case 0x01: /* Isochronous Endpoint */
pipe = new(std::nothrow) IsochronousPipe(this, fDeviceAddress, pipe = new(std::nothrow) IsochronousPipe(this, fDeviceAddress,
endpoint->descr->endpoint_address & 0x0f, endpoint->descr->endpoint_address & 0x0f,
(endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out,
fSpeed, endpoint->descr->max_packet_size); fSpeed, endpoint->descr->max_packet_size);
break; break;
case 0x02: /* Bulk Endpoint */ case 0x02: /* Bulk Endpoint */
pipe = new(std::nothrow) BulkPipe(this, fDeviceAddress, pipe = new(std::nothrow) BulkPipe(this, fDeviceAddress,
endpoint->descr->endpoint_address & 0x0f, endpoint->descr->endpoint_address & 0x0f,
(endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out,
fSpeed, endpoint->descr->max_packet_size); fSpeed, endpoint->descr->max_packet_size);
break; break;
case 0x03: /* Interrupt Endpoint */ case 0x03: /* Interrupt Endpoint */
pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress, pipe = new(std::nothrow) InterruptPipe(this, fDeviceAddress,
endpoint->descr->endpoint_address & 0x0f, endpoint->descr->endpoint_address & 0x0f,
(endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out, (endpoint->descr->endpoint_address & 0x80) > 0 ? Pipe::In : Pipe::Out,
fSpeed, endpoint->descr->max_packet_size); fSpeed, endpoint->descr->max_packet_size);
break; break;
}
endpoint->handle = pipe->USBID();
} }
endpoint->handle = pipe->USBID();
} }
// Wait some for the configuration being finished // Wait some for the configuration being finished
@@ -400,11 +402,13 @@ Device::Unconfigure(bool atDeviceLevel)
if (!fCurrentConfiguration) if (!fCurrentConfiguration)
return B_OK; return B_OK;
usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[0].active; for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) {
for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) { usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active;
usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i]; for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) {
delete (Pipe *)GetStack()->GetObject(endpoint->handle); usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i];
endpoint->handle = 0; delete (Pipe *)GetStack()->GetObject(endpoint->handle);
endpoint->handle = 0;
}
} }
fCurrentConfiguration = NULL; fCurrentConfiguration = NULL;