diff options
author | Yingxi Yu <yingxi.yu@intel.com> | 2013-11-06 04:08:33 +0100 |
---|---|---|
committer | Jerry Zhang <zhangjerry@google.com> | 2017-05-31 14:47:40 -0700 |
commit | b1b9785dd933cd0275dbcd6d010994cf6fad7737 (patch) | |
tree | 3cfc2c7ba5d83720fa2906d01c4d7f5ed717afd2 | |
parent | e6a041fd86c717011ac416e848e3ec8f2c835afb (diff) | |
download | libmtp-b1b9785dd933cd0275dbcd6d010994cf6fad7737.tar.gz |
USB3 device support
Signed-off-by: Yingxi Yu <yingxi.yu@intel.com>
Signed-off-by: Linus Walleij <triad@df.lth.se>
(cherry picked from commit 4a9e6046319ad834b924031d74f50e58b88d7d84)
Change-Id: I44124d2222d86251b852290192527cb6a03c3e84
-rw-r--r-- | src/libusb-glue.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libusb-glue.c b/src/libusb-glue.c index cdddfca..e46cfc5 100644 --- a/src/libusb-glue.c +++ b/src/libusb-glue.c @@ -805,6 +805,7 @@ libusb_glue_error (PTPParams *params, const char *format, ...) #define CONTEXT_BLOCK_SIZE_1 0x3e00 #define CONTEXT_BLOCK_SIZE_2 0x200 #define CONTEXT_BLOCK_SIZE CONTEXT_BLOCK_SIZE_1+CONTEXT_BLOCK_SIZE_2 + static short ptp_read_func ( unsigned long size, PTPDataHandler *handler,void *data, @@ -818,6 +819,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); @@ -1235,6 +1253,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) { @@ -1248,7 +1270,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); |