mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 21:25:19 -05:00
USB AMSv2: use tables for usb_drv_port_speed() and usb_drv_mps_by_type()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28044 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f1adafc05a
commit
ca0e95ad08
1 changed files with 21 additions and 24 deletions
|
|
@ -640,34 +640,31 @@ void INT_USB(void)
|
||||||
|
|
||||||
int usb_drv_port_speed(void)
|
int usb_drv_port_speed(void)
|
||||||
{
|
{
|
||||||
switch(extract(DSTS, enumspd))
|
static const uint8_t speed[4] = {
|
||||||
{
|
[DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ] = 1,
|
||||||
case DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ:
|
[DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ] = 0,
|
||||||
return 1;
|
[DSTS_ENUMSPD_FS_PHY_48MHZ] = 0,
|
||||||
case DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ:
|
[DSTS_ENUMSPD_LS_PHY_6MHZ] = 0,
|
||||||
case DSTS_ENUMSPD_FS_PHY_48MHZ:
|
};
|
||||||
return 0;
|
|
||||||
break;
|
unsigned enumspd = extract(DSTS, enumspd);
|
||||||
case DSTS_ENUMSPD_LS_PHY_6MHZ:
|
|
||||||
panicf("usb-drv: LS is not supported");
|
if(enumspd == DSTS_ENUMSPD_LS_PHY_6MHZ)
|
||||||
return 0;
|
panicf("usb-drv: LS is not supported");
|
||||||
default:
|
|
||||||
panicf("usb-drv: wtf is this speed ?");
|
return speed[enumspd & 3];
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long usb_drv_mps_by_type(int type)
|
static unsigned long usb_drv_mps_by_type(int type)
|
||||||
{
|
{
|
||||||
bool hs = usb_drv_port_speed();
|
static const uint16_t mps[4][2] = {
|
||||||
switch(type)
|
/* type fs hs */
|
||||||
{
|
[USB_ENDPOINT_XFER_CONTROL] = { 64, 64 },
|
||||||
case USB_ENDPOINT_XFER_CONTROL: return 64;
|
[USB_ENDPOINT_XFER_ISOC] = { 1023, 1024 },
|
||||||
case USB_ENDPOINT_XFER_BULK: return hs ? 512 : 64;
|
[USB_ENDPOINT_XFER_BULK] = { 64, 512 },
|
||||||
case USB_ENDPOINT_XFER_INT: return hs ? 1024 : 64;
|
[USB_ENDPOINT_XFER_INT] = { 64, 1024 },
|
||||||
case USB_ENDPOINT_XFER_ISOC: return hs ? 1024 : 1023;
|
};
|
||||||
default: return 0;
|
return mps[type & 3][usb_drv_port_speed() & 1];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_drv_request_endpoint(int type, int dir)
|
int usb_drv_request_endpoint(int type, int dir)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue