1
0
Fork 0
forked from len0rd/rockbox

USB retweaking: Take out the USB_REQUEST/RELEASE_DISK scheme and simply ask the USB core whether or not any drivers require exclusive access at the moment of connect. Doing anthing else just produces nasty effects on Windows because it expects some communication just for enabling the PHY and not allowing it to mount volumes if a thread doesn't ack causes annoying error message boxes. Make behavior of each USB type identical from the system perspective. Some miscellaneous changes (simplify, ata->storage naming, define only used USB_* enums values were possible).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19762 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2009-01-13 16:27:35 +00:00
parent 30414d56c9
commit 6da8b4eb49
9 changed files with 267 additions and 267 deletions

View file

@ -54,6 +54,9 @@
#include "ata.h"
#endif
#ifndef USB_MAX_CURRENT
#define USB_MAX_CURRENT 500
#endif
/*-------------------------------------------------------------------------*/
/* USB protocol descriptors: */
@ -94,7 +97,7 @@ static struct usb_config_descriptor __attribute__((aligned(2)))
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
.bMaxPower = 250, /* 500mA in 2mA units */
.bMaxPower = (USB_MAX_CURRENT+1) / 2, /* In 2mA units */
};
@ -179,7 +182,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
#ifdef USB_STORAGE
[USB_DRIVER_MASS_STORAGE] = {
.enabled = false,
.needs_exclusive_ata = true,
.needs_exclusive_storage = true,
.first_interface = 0,
.last_interface = 0,
.request_endpoints = usb_storage_request_endpoints,
@ -198,7 +201,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
#ifdef USB_SERIAL
[USB_DRIVER_SERIAL] = {
.enabled = false,
.needs_exclusive_ata = false,
.needs_exclusive_storage = false,
.first_interface = 0,
.last_interface = 0,
.request_endpoints = usb_serial_request_endpoints,
@ -217,7 +220,7 @@ static struct usb_class_driver drivers[USB_NUM_DRIVERS] =
#ifdef USB_CHARGING_ONLY
[USB_DRIVER_CHARGING_ONLY] = {
.enabled = false,
.needs_exclusive_ata = false,
.needs_exclusive_storage = false,
.first_interface = 0,
.last_interface = 0,
.request_endpoints = usb_charging_only_request_endpoints,
@ -353,13 +356,17 @@ void usb_core_exit(void)
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
if(drivers[i].enabled && drivers[i].disconnect != NULL)
{
drivers[i].disconnect ();
drivers[i].enabled = false;
}
}
if (initialized) {
usb_drv_exit();
}
initialized = false;
usb_state = DEFAULT;
logf("usb_core_exit() finished");
}
@ -392,6 +399,20 @@ bool usb_core_driver_enabled(int driver)
return drivers[driver].enabled;
}
bool usb_core_any_exclusive_storage(void)
{
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
if(drivers[i].enabled &&
drivers[i].needs_exclusive_storage)
{
return true;
}
}
return false;
}
#ifdef HAVE_HOTSWAP
void usb_core_hotswap_event(int volume,bool inserted)
{
@ -484,14 +505,6 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
usb_core_set_serial_function_id();
allocate_interfaces_and_endpoints();
for(i=0;i<USB_NUM_DRIVERS;i++) {
if(drivers[i].enabled &&
drivers[i].needs_exclusive_ata) {
usb_request_exclusive_ata();
break;
}
}
}
switch(req->bRequestType & 0x1f) {
@ -788,7 +801,7 @@ unsigned short usb_allowed_current()
{
if (usb_state == CONFIGURED)
{
return 500;
return MAX(USB_MAX_CURRENT, 100);
}
else
{