aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2011-02-28 17:23:15 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2011-02-28 17:23:15 +0000
commit1c49736857cfe0b562e2f1e100ab2307e882a9e6 (patch)
tree47ed63016899826a83fbbc10b56bb53c1b6d65cd /lib
parent898899d9ddbd15925a9d3c6b1da0d426dbc6351b (diff)
downloadsrc-1c49736857cfe0b562e2f1e100ab2307e882a9e6.tar.gz
src-1c49736857cfe0b562e2f1e100ab2307e882a9e6.zip
- Add support for software pre-scaling of ISOCHRONOUS transfers.
MFC after: 14 days Approved by: thompsa (mentor)
Notes
Notes: svn path=/head/; revision=219100
Diffstat (limited to 'lib')
-rw-r--r--lib/libusb/libusb10.c18
-rw-r--r--lib/libusb/libusb20.310
-rw-r--r--lib/libusb/libusb20.c14
-rw-r--r--lib/libusb/libusb20.h3
-rw-r--r--lib/libusb/libusb20_int.h2
-rw-r--r--lib/libusb/libusb20_ugen20.c5
6 files changed, 30 insertions, 22 deletions
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 3b8d567dae9b..fa50ea784dfb 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -51,7 +51,6 @@ struct libusb_context *usbi_default_context = NULL;
/* Prototypes */
static struct libusb20_transfer *libusb10_get_transfer(struct libusb20_device *, uint8_t, uint8_t);
-static int libusb10_get_maxframe(struct libusb20_device *, libusb_transfer *);
static int libusb10_get_buffsize(struct libusb20_device *, libusb_transfer *);
static int libusb10_convert_error(uint8_t status);
static void libusb10_complete_transfer(struct libusb20_transfer *, struct libusb_super_transfer *, int);
@@ -810,25 +809,14 @@ libusb_free_transfer(struct libusb_transfer *uxfer)
free(sxfer);
}
-static int
+static uint32_t
libusb10_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer)
{
- int ret;
- int usb_speed;
-
- usb_speed = libusb20_dev_get_speed(pdev);
+ uint32_t ret;
switch (xfer->type) {
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- switch (usb_speed) {
- case LIBUSB20_SPEED_LOW:
- case LIBUSB20_SPEED_FULL:
- ret = 60 * 1;
- break;
- default:
- ret = 60 * 8;
- break;
- }
+ ret = 60 | LIBUSB20_MAX_FRAME_PRE_SCALE; /* 60ms */
break;
case LIBUSB_TRANSFER_TYPE_CONTROL:
ret = 2;
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index a6dc890a70b4..93dfe18cf5be 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -261,6 +261,16 @@ The actual buffer size can be greater than
and is returned by
.Fn libusb20_tr_get_max_total_length .
.
+If
+.Fa max_frame_count
+is OR'ed with LIBUSB20_MAX_FRAME_PRE_SCALE the remaining part of the
+argument is converted from milliseconds into the actual number of
+frames rounded up, when this function returns.
+This flag is only valid for ISOCHRONOUS transfers and has no effect
+for other transfer types.
+The actual number of frames setup is found by calling
+.Fn libusb20_tr_get_max_frames .
+.
This function returns zero upon success.
.
Non-zero return values indicate a LIBUSB20_ERROR value.
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index f8edfc38d343..bcaa1e47ff13 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -156,14 +156,20 @@ libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
uint32_t MaxFrameCount, uint8_t ep_no)
{
uint32_t size;
+ uint8_t pre_scale;
int error;
- if (xfer->is_opened) {
+ if (xfer->is_opened)
return (LIBUSB20_ERROR_BUSY);
+ if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) {
+ MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE;
+ pre_scale = 1;
+ } else {
+ pre_scale = 0;
}
- if (MaxFrameCount == 0) {
+ if (MaxFrameCount == 0)
return (LIBUSB20_ERROR_INVALID_PARAM);
- }
+
xfer->maxFrames = MaxFrameCount;
size = MaxFrameCount * sizeof(xfer->pLength[0]);
@@ -182,7 +188,7 @@ libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
memset(xfer->ppBuffer, 0, size);
error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
- MaxFrameCount, ep_no);
+ MaxFrameCount, ep_no, pre_scale);
if (error) {
free(xfer->ppBuffer);
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index d16c6a628ea6..958a379ed254 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -197,8 +197,9 @@ struct libusb20_quirk {
char quirkname[64 - 12];
};
-/* USB transfer operations */
+#define LIBUSB20_MAX_FRAME_PRE_SCALE (1U << 31)
+/* USB transfer operations */
int libusb20_tr_close(struct libusb20_transfer *xfer);
int libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t max_buf_size, uint32_t max_frame_count, uint8_t ep_no);
struct libusb20_transfer *libusb20_tr_get_pointer(struct libusb20_device *pdev, uint16_t tr_index);
diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h
index 64885f28877e..2ecfb4770a39 100644
--- a/lib/libusb/libusb20_int.h
+++ b/lib/libusb/libusb20_int.h
@@ -110,7 +110,7 @@ typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t
typedef int (libusb20_check_connected_t)(struct libusb20_device *pdev);
/* USB transfer specific */
-typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no);
+typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no, uint8_t pre_scale);
typedef int (libusb20_tr_close_t)(struct libusb20_transfer *xfer);
typedef int (libusb20_tr_clear_stall_sync_t)(struct libusb20_transfer *xfer);
typedef void (libusb20_tr_submit_t)(struct libusb20_transfer *xfer);
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 5b7d5e85a063..933d7286b679 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -736,11 +736,14 @@ ugen20_process(struct libusb20_device *pdev)
static int
ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
- uint32_t MaxFrameCount, uint8_t ep_no)
+ uint32_t MaxFrameCount, uint8_t ep_no, uint8_t pre_scale)
{
struct usb_fs_open temp;
struct usb_fs_endpoint *fsep;
+ if (pre_scale)
+ MaxFrameCount |= USB_FS_MAX_FRAMES_PRE_SCALE;
+
memset(&temp, 0, sizeof(temp));
fsep = xfer->pdev->privBeData;