diff options
author | Yingxi Yu <yingxi.yu@intel.com> | 2013-11-06 04:08:33 +0100 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2013-11-06 04:08:33 +0100 |
commit | 4a9e6046319ad834b924031d74f50e58b88d7d84 (patch) | |
tree | 6ae73d66cb5b86aae3af6baa059e2c40e50a8f20 /src/libusb1-glue.c | |
parent | c27ba017bbc18fcc5d436be1b4b5eb60a25de414 (diff) | |
download | libmtp-4a9e6046319ad834b924031d74f50e58b88d7d84.tar.gz |
USB3 device support
Signed-off-by: Yingxi Yu <yingxi.yu@intel.com>
Signed-off-by: Linus Walleij <triad@df.lth.se>
Diffstat (limited to 'src/libusb1-glue.c')
-rw-r--r-- | src/libusb1-glue.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/libusb1-glue.c b/src/libusb1-glue.c index 7dee45f..257b50e 100644 --- a/src/libusb1-glue.c +++ b/src/libusb1-glue.c @@ -837,7 +837,23 @@ 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; + uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id; + + //"iRiver" device special handling + if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) { + 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; + } + } // This is the largest block we'll need to read in. bytes = malloc(CONTEXT_BLOCK_SIZE); while (curread < size) { @@ -855,16 +871,21 @@ ptp_read_func ( expect_terminator_byte = 1; } } - 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; + else if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) { + //"iRiver" device special handling + 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; + else + LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", + (unsigned int) toread, (unsigned int) (size-curread)); + } else - LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", - (unsigned int) toread, (unsigned int) (size-curread)); + toread = CONTEXT_BLOCK_SIZE; LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread); @@ -1267,6 +1288,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) { @@ -1280,7 +1305,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); |