diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-10-18 00:30:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-10-18 00:30:44 +0000 |
commit | 05ffbaed02e3834f258a70f48c3adf9c4d5e0150 (patch) | |
tree | 3cfc2c7ba5d83720fa2906d01c4d7f5ed717afd2 | |
parent | 7ed2065db3ab9851f47426f3a35ba7045ce528b2 (diff) | |
parent | b1b9785dd933cd0275dbcd6d010994cf6fad7737 (diff) | |
download | libmtp-05ffbaed02e3834f258a70f48c3adf9c4d5e0150.tar.gz |
Merge changes I44124d22,I8d01048f
* changes:
USB3 device support
libmtp: Support > 4GB file transfers
-rw-r--r-- | src/libmtp.c | 8 | ||||
-rw-r--r-- | src/libusb-glue.c | 24 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/libmtp.c b/src/libmtp.c index b8dc50e..8c86cde 100644 --- a/src/libmtp.c +++ b/src/libmtp.c @@ -5787,8 +5787,12 @@ static int send_file_object_info(LIBMTP_mtpdevice_t *device, LIBMTP_file_t *file if (FLAG_ONLY_7BIT_FILENAMES(ptp_usb)) { strip_7bit_from_utf8(new_file.Filename); } - // We lose precision here. - new_file.ObjectCompressedSize = (uint32_t) filedata->filesize; + if (filedata->filesize > 0xFFFFFFFFL) { + // This is a kludge in the MTP standard for large files. + new_file.ObjectCompressedSize = (uint32_t) 0xFFFFFFFF; + } else { + new_file.ObjectCompressedSize = (uint32_t) filedata->filesize; + } new_file.ObjectFormat = of; new_file.StorageID = store; new_file.ParentObject = localph; 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); |