Index: src/libopenusb1-glue.c |
diff --git a/src/libopenusb1-glue.c b/src/libopenusb1-glue.c |
index 8bd3757471a1a0b8b3b62f7fda2933da47183998..da9b935fda93a09685cfc1b97e84153eedf4aabb 100644 |
--- a/src/libopenusb1-glue.c |
+++ b/src/libopenusb1-glue.c |
@@ -661,17 +661,7 @@ LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices(LIBMTP_raw_device_t ** devices, |
} |
} |
if (!device_known) { |
- // This device is unknown to the developers |
- LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN.\n", |
- i, |
- desc.idVendor, |
- desc.idProduct); |
- LIBMTP_ERROR("Please report this VID/PID and the device model to the libmtp development team\n"); |
- /* |
- * Trying to get iManufacturer or iProduct from the device at this |
- * point would require opening a device handle, that we don't want |
- * to do right now. (Takes time for no good enough reason.) |
- */ |
+ device_unknown(i, desc.idVendor, desc.idProduct); |
} |
// Save the location on the bus |
retdevs[i].bus_location = 0; |
@@ -803,7 +793,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; |
+ } |
+ } |
struct openusb_bulk_request bulk; |
// This is the largest block we'll need to read in. |
bytes = malloc(CONTEXT_BLOCK_SIZE); |
@@ -820,16 +826,21 @@ ptp_read_func( |
toread += 1; |
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 |
- LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", |
- (unsigned int) toread, (unsigned int) (size - curread)); |
+ } 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 |
+ toread = CONTEXT_BLOCK_SIZE; |
LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread); |
@@ -866,7 +877,7 @@ ptp_read_func( |
xread--; |
} |
- int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes, &written); |
+ int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes); |
LIBMTP_USB_DEBUG("handler->putfunc ret = 0x%x\n", putfunc_ret); |
if (putfunc_ret != PTP_RC_OK) |
return putfunc_ret; |
@@ -1074,8 +1085,7 @@ memory_getfunc(PTPParams* params, void* private, |
static uint16_t |
memory_putfunc(PTPParams* params, void* private, |
- unsigned long sendlen, unsigned char *data, |
- unsigned long *putlen |
+ unsigned long sendlen, unsigned char *data |
) { |
PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*) private; |
@@ -1085,7 +1095,6 @@ memory_putfunc(PTPParams* params, void* private, |
} |
memcpy(priv->data + priv->curoff, data, sendlen); |
priv->curoff += sendlen; |
- *putlen = sendlen; |
return PTP_RC_OK; |
} |
@@ -1148,7 +1157,7 @@ ptp_exit_recv_memory_handler(PTPDataHandler *handler, |
/* send / receive functions */ |
uint16_t |
-ptp_usb_sendreq(PTPParams* params, PTPContainer* req) { |
+ptp_usb_sendreq(PTPParams* params, PTPContainer* req, int dataphase) { |
uint16_t ret; |
PTPUSBBulkContainer usbreq; |
PTPDataHandler memhandler; |
@@ -1157,7 +1166,7 @@ ptp_usb_sendreq(PTPParams* params, PTPContainer* req) { |
char txt[256]; |
- (void) ptp_render_opcode(params, req->Code, sizeof (txt), txt); |
+ (void) ptp_render_ofc(params, req->Code, sizeof (txt), txt); |
LIBMTP_USB_DEBUG("REQUEST: 0x%04x, %s\n", req->Code, txt); |
/* build appropriate USB container */ |
@@ -1196,13 +1205,13 @@ ptp_usb_sendreq(PTPParams* params, PTPContainer* req) { |
uint16_t |
ptp_usb_senddata(PTPParams* params, PTPContainer* ptp, |
- unsigned long size, PTPDataHandler *handler |
+ uint64_t size, PTPDataHandler *handler |
) { |
uint16_t ret; |
int wlen, datawlen; |
unsigned long written; |
PTPUSBBulkContainer usbdata; |
- uint32_t bytes_left_to_transfer; |
+ uint64_t bytes_left_to_transfer; |
PTPDataHandler memhandler; |
LIBMTP_USB_DEBUG("SEND DATA PHASE\n"); |
@@ -1266,6 +1275,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 +1292,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); |
@@ -1336,12 +1349,11 @@ ptp_usb_getdata(PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) { |
break; |
} |
} |
- if (usbdata.length == 0xffffffffU) { |
+ if (rlen == ptp_usb->inep_maxpacket) { |
/* Copy first part of data to 'data' */ |
putfunc_ret = |
handler->putfunc( |
- params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data, |
- &written |
+ params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data |
); |
if (putfunc_ret != PTP_RC_OK) |
return putfunc_ret; |
@@ -1352,7 +1364,7 @@ ptp_usb_getdata(PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) { |
uint16_t xret; |
xret = ptp_read_func( |
- PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, |
+ 0x20000000, |
handler, |
params->data, |
&readdata, |
@@ -1360,7 +1372,7 @@ ptp_usb_getdata(PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) { |
); |
if (xret != PTP_RC_OK) |
return xret; |
- if (readdata < PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) |
+ if (readdata < 0x20000000) |
break; |
} |
return PTP_RC_OK; |
@@ -1411,14 +1423,13 @@ ptp_usb_getdata(PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) { |
putfunc_ret = |
handler->putfunc( |
params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, |
- usbdata.payload.data, |
- &written |
+ usbdata.payload.data |
); |
if (putfunc_ret != PTP_RC_OK) |
return putfunc_ret; |
if (FLAG_NO_ZERO_READS(ptp_usb) && |
- len + PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) { |
+ len + PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) { |
LIBMTP_USB_DEBUG("Reading in extra terminating byte\n"); |
@@ -1444,8 +1455,8 @@ ptp_usb_getdata(PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) { |
xread = bulk.result.transferred_bytes; |
if (result != 1) |
- LIBMTP_INFO("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result); |
- } else if (len + PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ && params->split_header_data == 0) { |
+ LIBMTP_INFO("Could not read in extra byte for %d bytes long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, result); |
+ } else if (len + PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) { |
int zeroresult = 0, xread; |
unsigned char zerobyte = 0; |
@@ -1681,6 +1692,17 @@ ptp_usb_event_wait(PTPParams* params, PTPContainer* event) { |
} |
uint16_t |
+ptp_usb_event_async (PTPParams* params, PTPEventCbFn cb, void *user_data) { |
+ /* Unsupported */ |
+ return PTP_ERROR_CANCEL; |
+} |
+ |
+int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *tv, int *completed) { |
+ /* Unsupported */ |
+ return -12; |
+} |
+ |
+uint16_t |
ptp_usb_control_cancel_request(PTPParams *params, uint32_t transactionid) { |
PTP_USB *ptp_usb = (PTP_USB *) (params->data); |
int ret; |