summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_transfer.c
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2014-03-22 17:18:44 +0000
committerhselasky <hselasky@FreeBSD.org>2014-03-22 17:18:44 +0000
commit1e89433bccdd066088e605a8eb62fb068239a36a (patch)
tree926a6f9b38860cab68716e87d3dadc003fc87133 /sys/dev/usb/usb_transfer.c
parent3b3c7827c36e5eb42ffdee05f0813da041948ee3 (diff)
downloadFreeBSD-src-1e89433bccdd066088e605a8eb62fb068239a36a.zip
FreeBSD-src-1e89433bccdd066088e605a8eb62fb068239a36a.tar.gz
MFC r263159:
Workaround for USB MIDI adapters which use non-supported values of wMaxPacketSize for BULK endpoints.
Diffstat (limited to 'sys/dev/usb/usb_transfer.c')
-rw-r--r--sys/dev/usb/usb_transfer.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c
index 5a99e54..bc70ea9 100644
--- a/sys/dev/usb/usb_transfer.c
+++ b/sys/dev/usb/usb_transfer.c
@@ -346,6 +346,7 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
usb_frcount_t n_frlengths;
usb_frcount_t n_frbuffers;
usb_frcount_t x;
+ uint16_t maxp_old;
uint8_t type;
uint8_t zmps;
@@ -433,6 +434,11 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
if (xfer->max_packet_count > parm->hc_max_packet_count) {
xfer->max_packet_count = parm->hc_max_packet_count;
}
+
+ /* store max packet size value before filtering */
+
+ maxp_old = xfer->max_packet_size;
+
/* filter "wMaxPacketSize" according to HC capabilities */
if ((xfer->max_packet_size > parm->hc_max_packet_size) ||
@@ -465,6 +471,13 @@ usbd_transfer_setup_sub(struct usb_setup_params *parm)
}
}
+ /*
+ * Check if the max packet size was outside its allowed range
+ * and clamped to a valid value:
+ */
+ if (maxp_old != xfer->max_packet_size)
+ xfer->flags_int.maxp_was_clamped = 1;
+
/* compute "max_frame_size" */
usbd_update_max_frame_size(xfer);
@@ -3432,3 +3445,13 @@ usbd_xfer_get_timestamp(struct usb_xfer *xfer)
{
return (xfer->isoc_time_complete);
}
+
+/*
+ * The following function returns non-zero if the max packet size
+ * field was clamped to a valid value. Else it returns zero.
+ */
+uint8_t
+usbd_xfer_maxp_was_clamped(struct usb_xfer *xfer)
+{
+ return (xfer->flags_int.maxp_was_clamped);
+}
OpenPOWER on IntegriCloud