diff options
author | Yingxi Yu <yingxi.yu@intel.com> | 2013-11-04 02:15:20 +0100 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2013-11-04 02:15:20 +0100 |
commit | 77ad0b15fecacb415dc508168919cc3c4583dd36 (patch) | |
tree | bcaf354d7613a37025b733039326de96f7d67fdf /src/libopenusb1-glue.c | |
parent | 2ad5b720731014737c5ab8781362e7b3faa713ec (diff) | |
download | libmtp-77ad0b15fecacb415dc508168919cc3c4583dd36.tar.gz |
USB 3.0 support.
This adds support for USB 3.0 capable MTP devices.
Signed-off-by: Yingxi Yu <yingxi.yu@intel.com>
Signed-off-by: Linus Walleij <triad@df.lth.se>
Diffstat (limited to 'src/libopenusb1-glue.c')
-rw-r--r-- | src/libopenusb1-glue.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/libopenusb1-glue.c b/src/libopenusb1-glue.c index 55a4961..af3c549 100644 --- a/src/libopenusb1-glue.c +++ b/src/libopenusb1-glue.c @@ -803,6 +803,19 @@ ptp_read_func( unsigned long written; unsigned char *bytes; int expect_terminator_byte = 0; + unsigned long usb_inep_maxpacket_size; + unsigned long context_block_size_1; + unsigned long context_block_size_2; + + usb_inep_maxpacket_size = ptp_usb->inep_maxpacket; + if (usb_inep_maxpacket_size == 0x400) { + context_block_size_1 = CONTEXT_BLOCK_SIZE_1 - 0x200; + context_block_size_2 = CONTEXT_BLOCK_SIZE_2 + 0x200; + } + else { + context_block_size_1 = CONTEXT_BLOCK_SIZE_1; + context_block_size_2 = CONTEXT_BLOCK_SIZE_2; + } struct openusb_bulk_request bulk; // This is the largest block we'll need to read in. @@ -822,11 +835,11 @@ ptp_read_func( } } else if (curread == 0) // we are first packet, but not last packet - toread = CONTEXT_BLOCK_SIZE_1; - else if (toread == CONTEXT_BLOCK_SIZE_1) - toread = CONTEXT_BLOCK_SIZE_2; - else if (toread == CONTEXT_BLOCK_SIZE_2) - toread = CONTEXT_BLOCK_SIZE_1; + toread = context_block_size_1; + else if (toread == context_block_size_1) + toread = context_block_size_2; + else if (toread == context_block_size_2) + toread = context_block_size_1; else LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", (unsigned int) toread, (unsigned int) (size - curread)); @@ -1266,6 +1279,10 @@ static uint16_t ptp_usb_getpacket(PTPParams *params, PTPDataHandler memhandler; uint16_t ret; unsigned char *x = NULL; + unsigned long packet_size; + PTP_USB *ptp_usb = (PTP_USB *) params->data; + + packet_size = ptp_usb->inep_maxpacket; /* read the header and potentially the first data */ if (params->response_packet_size > 0) { @@ -1279,7 +1296,7 @@ static uint16_t ptp_usb_getpacket(PTPParams *params, return PTP_RC_OK; } ptp_init_recv_memory_handler(&memhandler); - ret = ptp_read_func(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, &memhandler, params->data, rlen, 0); + ret = ptp_read_func(packet_size, &memhandler, params->data, rlen, 0); ptp_exit_recv_memory_handler(&memhandler, &x, rlen); if (x) { memcpy(packet, x, *rlen); |