From 552508506f9bfec8d88358c4996c3d95605e6583 Mon Sep 17 00:00:00 2001 From: Johan Carlsson Date: Tue, 24 Mar 2020 15:05:26 +0100 Subject: [PATCH] usb: filter out synchronization type for isochronous endpoints Fix so that different isochronous synchronization modes can be used. It filters out the synchronization mode before sending the endpoint type to drivers. Signed-off-by: Johan Carlsson --- include/drivers/usb/usb_dc.h | 6 +++++- subsys/usb/usb_descriptor.c | 3 ++- subsys/usb/usb_device.c | 13 ++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/drivers/usb/usb_dc.h b/include/drivers/usb/usb_dc.h index fd46d06dbe5..546b34d736b 100644 --- a/include/drivers/usb/usb_dc.h +++ b/include/drivers/usb/usb_dc.h @@ -22,11 +22,15 @@ /** * USB endpoint direction and number. */ - #define USB_EP_DIR_MASK 0x80 #define USB_EP_DIR_IN 0x80 #define USB_EP_DIR_OUT 0x00 +/** + * USB endpoint Transfer Type mask. + */ +#define USB_EP_TRANSFER_TYPE_MASK 0x3 + /** * @brief USB Device Controller API * @defgroup _usb_device_controller_api USB Device Controller API diff --git a/subsys/usb/usb_descriptor.c b/subsys/usb/usb_descriptor.c index 73bb1279424..9a8394f99fe 100644 --- a/subsys/usb/usb_descriptor.c +++ b/subsys/usb/usb_descriptor.c @@ -241,7 +241,8 @@ static int usb_validate_ep_cfg_data(struct usb_ep_descriptor * const ep_descr, for (u8_t idx = 1; idx < 16; idx++) { struct usb_dc_ep_cfg_data ep_cfg; - ep_cfg.ep_type = ep_descr->bmAttributes; + ep_cfg.ep_type = (ep_descr->bmAttributes & + USB_EP_TRANSFER_TYPE_MASK); ep_cfg.ep_mps = ep_descr->wMaxPacketSize; ep_cfg.ep_addr = ep_descr->bEndpointAddress; if (ep_cfg.ep_addr & USB_EP_DIR_IN) { diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index 6a7314f0105..a126116e044 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -471,12 +471,7 @@ static bool set_endpoint(const struct usb_ep_descriptor *ep_desc) ep_cfg.ep_addr = ep_desc->bEndpointAddress; ep_cfg.ep_mps = sys_le16_to_cpu(ep_desc->wMaxPacketSize); - - if (ep_desc->bmAttributes > USB_DC_EP_INTERRUPT) { - return false; - } - - ep_cfg.ep_type = ep_desc->bmAttributes; + ep_cfg.ep_type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK; LOG_DBG("Set endpoint 0x%x type %u MPS %u", ep_cfg.ep_addr, ep_cfg.ep_type, ep_cfg.ep_mps); @@ -518,11 +513,7 @@ static bool reset_endpoint(const struct usb_ep_descriptor *ep_desc) int ret; ep_cfg.ep_addr = ep_desc->bEndpointAddress; - ep_cfg.ep_type = ep_desc->bmAttributes; - - if (ep_desc->bmAttributes > USB_DC_EP_INTERRUPT) { - return false; - } + ep_cfg.ep_type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK; LOG_DBG("Reset endpoint 0x%02x type %u", ep_cfg.ep_addr, ep_cfg.ep_type);