mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-05-12 11:43:16 -04:00
usb: fix get_max_packet_size is called before endpoints are allocated
retrive the requirements like others rather than callback Change-Id: I20efce76a418ebd7aa6943f02e53b3f7a8fd2797
This commit is contained in:
parent
8873cbb57e
commit
142e1864ef
7 changed files with 16 additions and 33 deletions
|
|
@ -299,9 +299,9 @@ static int as_playback_freq_idx; /* audio playback streaming frequency index (in
|
|||
|
||||
static struct usb_class_driver_ep_allocation ep_allocs[2] = {
|
||||
/* output isochronous endpoint */
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_OUT, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_OUT, .optional = false, .mps = -1},
|
||||
/* input feedback isochronous endpoint */
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_IN, .optional = false, .mps = -1},
|
||||
};
|
||||
|
||||
#define EP_ISO_OUT (ep_allocs[0].ep)
|
||||
|
|
|
|||
|
|
@ -30,10 +30,11 @@
|
|||
/* Common api, implemented by all class drivers */
|
||||
|
||||
struct usb_class_driver_ep_allocation {
|
||||
uint8_t type; /* by driver, required ep type. USB_ENDPOINT_XFER_* */
|
||||
uint8_t dir; /* by driver, required ep dir. DIR_{IN,OUT} */
|
||||
uint8_t ep; /* by core, allocated ep. > 0 are valid but can be 0 if optional==true */
|
||||
bool optional; /* by driver, set true to mark this requirement to be optional */
|
||||
uint8_t type:2; /* by driver, required ep type. USB_ENDPOINT_XFER_* */
|
||||
uint8_t dir:1; /* by driver, required ep dir. DIR_{IN,OUT} */
|
||||
bool optional:1; /* by driver, set true to mark this requirement to be optional */
|
||||
int16_t mps; /* by driver, desired max packet size, or -1 for device driver default */
|
||||
};
|
||||
|
||||
struct usb_class_driver {
|
||||
|
|
@ -130,11 +131,6 @@ struct usb_class_driver {
|
|||
* Mandatory function if alternate interface support is needed */
|
||||
int (*get_interface)(int interface);
|
||||
|
||||
/* Asks the driver max packet size for the endpoint.
|
||||
* Drivers can returns desired value in bytes,
|
||||
* or -1 to use the device controller default */
|
||||
int (*get_max_packet_size)(int ep);
|
||||
|
||||
/* Invoked by USB_NOTIFY_CLASS_DRIVER
|
||||
Optional function */
|
||||
void (*notify_event)(intptr_t data);
|
||||
|
|
|
|||
|
|
@ -651,8 +651,7 @@ retry:
|
|||
|
||||
/* driver specific check */
|
||||
const int ep = epnum | (req->dir == DIR_OUT ? USB_DIR_OUT : USB_DIR_IN);
|
||||
const int ps = driver->get_max_packet_size ? driver->get_max_packet_size(ep) : -1;
|
||||
if(!usb_drv_ep_allocate(&cstate->ep_alloc_ctx, ep, req->type, ps)) {
|
||||
if(!usb_drv_ep_allocate(&cstate->ep_alloc_ctx, ep, req->type, req->mps)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ static bool currently_sending = false;
|
|||
static int usb_interface;
|
||||
|
||||
static struct usb_class_driver_ep_allocation ep_allocs[1] = {
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = false, .mps = -1},
|
||||
};
|
||||
|
||||
#define EP_IN (ep_allocs[0].ep)
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@
|
|||
|
||||
struct usb_class_driver_ep_allocation usb_iap_ep_allocs[2] = {
|
||||
/* uac input */
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_ISOC, .dir = DIR_IN, .optional = false, .mps = 1024},
|
||||
/* hid input */
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = false, .mps = 64},
|
||||
};
|
||||
|
||||
/* interface 0 (audio control) */
|
||||
|
|
@ -442,17 +442,6 @@ static int usb_iap_get_interface(int intf) {
|
|||
return stream.alt;
|
||||
}
|
||||
|
||||
static int usb_iap_get_max_packet_size(int ep) {
|
||||
if(ep == AS_EP_IN) {
|
||||
return 1024;
|
||||
} else if(ep == HID_EP_IN) {
|
||||
return 64;
|
||||
} else {
|
||||
panicf("unexpected endpoint number %d", ep);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_iap_init(void) {
|
||||
LOG("init");
|
||||
}
|
||||
|
|
@ -706,6 +695,5 @@ struct usb_class_driver usb_cdrv_iap = {
|
|||
.control_request = usb_iap_control_request,
|
||||
.set_interface = usb_iap_set_interface,
|
||||
.get_interface = usb_iap_get_interface,
|
||||
.get_max_packet_size = usb_iap_get_max_packet_size,
|
||||
.notify_event = usb_iap_notify_event,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ static int buffer_transitlength;
|
|||
static bool active = false;
|
||||
|
||||
static struct usb_class_driver_ep_allocation ep_allocs[3] = {
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_OUT, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = true},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_IN, .optional = false, .mps = -1},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_OUT, .optional = false, .mps = -1},
|
||||
{.type = USB_ENDPOINT_XFER_INT, .dir = DIR_IN, .optional = true, .mps = -1},
|
||||
};
|
||||
|
||||
#define EP_IN (ep_allocs[0].ep)
|
||||
|
|
|
|||
|
|
@ -323,8 +323,8 @@ static bool locked[NUM_DRIVES];
|
|||
static int usb_interface;
|
||||
|
||||
static struct usb_class_driver_ep_allocation ep_allocs[2] = {
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_IN, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_OUT, .optional = false},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_IN, .optional = false, .mps = -1},
|
||||
{.type = USB_ENDPOINT_XFER_BULK, .dir = DIR_OUT, .optional = false, .mps = -1},
|
||||
};
|
||||
|
||||
#define EP_IN (ep_allocs[0].ep)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue