summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libirecovery.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/libirecovery.c b/libirecovery.c
index 81bf6d5..c186f41 100644
--- a/libirecovery.c
+++ b/libirecovery.c
@@ -262,11 +262,11 @@ int irecv_bulk_transfer(irecv_client_t client,
262 unsigned int timeout) { 262 unsigned int timeout) {
263 int ret; 263 int ret;
264 264
265 // pod2g 2011-01-01: switch to interface 1.1 for bulk transfers then switch back to 0.0
266 irecv_set_interface(client, 0, 0);
267
268#ifndef WIN32 265#ifndef WIN32
269 ret = libusb_bulk_transfer(client->handle, endpoint, data, length, transferred, timeout); 266 ret = libusb_bulk_transfer(client->handle, endpoint, data, length, transferred, timeout);
267 if (ret < 0) {
268 libusb_clear_halt(client->handle, endpoint);
269 }
270#else 270#else
271 if (endpoint==0x4) { 271 if (endpoint==0x4) {
272 ret = DeviceIoControl(client->handle, 0x220195, data, length, data, length, (PDWORD) transferred, NULL); 272 ret = DeviceIoControl(client->handle, 0x220195, data, length, data, length, (PDWORD) transferred, NULL);
@@ -275,12 +275,7 @@ int irecv_bulk_transfer(irecv_client_t client,
275 } 275 }
276 ret==0?-1:0; 276 ret==0?-1:0;
277#endif 277#endif
278 if (ret < 0) {
279 // pod2g 2010-12-28: MacOSX need a reset if read times out, also the reset seems to improve stability when switching interfaces
280 irecv_reset(client);
281 }
282 278
283 irecv_set_interface(client, 1, 1);
284 return ret; 279 return ret;
285} 280}
286 281
@@ -365,13 +360,14 @@ irecv_error_t irecv_open(irecv_client_t* pclient) {
365 client->handle = usb_handle; 360 client->handle = usb_handle;
366 client->mode = usb_descriptor.idProduct; 361 client->mode = usb_descriptor.idProduct;
367 362
363
368 error = irecv_set_configuration(client, 1); 364 error = irecv_set_configuration(client, 1);
369 if (error != IRECV_E_SUCCESS) { 365 if (error != IRECV_E_SUCCESS) {
370 return error; 366 return error;
371 } 367 }
372 368
373 if (client->mode != kDfuMode) { 369 if (client->mode != kDfuMode) {
374 // pod2g 2010-12-28: switched to interface 1.1 by default on non DFU modes 370 error = irecv_set_interface(client, 0, 0);
375 error = irecv_set_interface(client, 1, 1); 371 error = irecv_set_interface(client, 1, 1);
376 } else { 372 } else {
377 error = irecv_set_interface(client, 0, 0); 373 error = irecv_set_interface(client, 0, 0);
@@ -424,7 +420,7 @@ irecv_error_t irecv_set_interface(irecv_client_t client, int interface, int alt_
424 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; 420 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
425 421
426#ifndef WIN32 422#ifndef WIN32
427 // pod2g 2010-12-28: this crashes iBoot on MacOSX 423 // pod2g 2011-01-07: we may want to claim multiple interfaces
428 //libusb_release_interface(client->handle, client->interface); 424 //libusb_release_interface(client->handle, client->interface);
429 425
430 debug("Setting to interface %d:%d\n", interface, alt_interface); 426 debug("Setting to interface %d:%d\n", interface, alt_interface);
@@ -545,8 +541,7 @@ irecv_error_t irecv_close(irecv_client_t client) {
545#ifndef WIN32 541#ifndef WIN32
546 if (client->handle != NULL) { 542 if (client->handle != NULL) {
547 if (client->mode != kDfuMode) { 543 if (client->mode != kDfuMode) {
548 // pod2g 2010-12-28: this crashes iBoot on MacOSX 544 libusb_release_interface(client->handle, client->interface);
549 //libusb_release_interface(client->handle, client->interface);
550 } 545 }
551 libusb_close(client->handle); 546 libusb_close(client->handle);
552 client->handle = NULL; 547 client->handle = NULL;
@@ -765,9 +760,8 @@ irecv_error_t irecv_receive(irecv_client_t client) {
765 memset(buffer, '\0', BUFFER_SIZE); 760 memset(buffer, '\0', BUFFER_SIZE);
766 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; 761 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
767 762
768 // pod2g 2010-12-28: switch to interface 0 for bulk transfers then return to interface 1
769 int bytes = 0; 763 int bytes = 0;
770 while (irecv_bulk_transfer(client, 0x81, (unsigned char*) buffer, BUFFER_SIZE, &bytes, 1000) == 0) { 764 while (irecv_bulk_transfer(client, 0x81, (unsigned char*) buffer, BUFFER_SIZE, &bytes, 500) == 0) {
771 if (bytes > 0) { 765 if (bytes > 0) {
772 if (client->received_callback != NULL) { 766 if (client->received_callback != NULL) {
773 irecv_event_t event; 767 irecv_event_t event;