• Home
  • Raw
  • Download

Lines Matching refs:ptp_usb

62 static inline int get_timeout(PTP_USB* ptp_usb)  in get_timeout()  argument
64 if (FLAG_LONG_TIMEOUT(ptp_usb)) { in get_timeout()
87 PTP_USB *ptp_usb; member
101 static void close_usb(PTP_USB* ptp_usb);
111 static void clear_stall(PTP_USB* ptp_usb);
112 static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, struct usb_device* dev);
115 static int usb_clear_stall_feature(PTP_USB* ptp_usb, int ep);
116 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status);
700 void dump_usbinfo(PTP_USB *ptp_usb) in dump_usbinfo() argument
709 res = usb_get_driver_np(ptp_usb->handle, (int) ptp_usb->interface, devname, sizeof(devname)); in dump_usbinfo()
714 dev = usb_device(ptp_usb->handle); in dump_usbinfo()
721 LIBMTP_INFO(" IN endpoint maxpacket: %d bytes\n", ptp_usb->inep_maxpacket); in dump_usbinfo()
722 LIBMTP_INFO(" OUT endpoint maxpacket: %d bytes\n", ptp_usb->outep_maxpacket); in dump_usbinfo()
724 LIBMTP_INFO(" Bus location: %d\n", ptp_usb->rawdevice.bus_location); in dump_usbinfo()
725 LIBMTP_INFO(" Device number: %d\n", ptp_usb->rawdevice.devnum); in dump_usbinfo()
727 LIBMTP_INFO(" Vendor: %s\n", ptp_usb->rawdevice.device_entry.vendor); in dump_usbinfo()
728 LIBMTP_INFO(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.vendor_id); in dump_usbinfo()
729 LIBMTP_INFO(" Product: %s\n", ptp_usb->rawdevice.device_entry.product); in dump_usbinfo()
730 LIBMTP_INFO(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.product_id); in dump_usbinfo()
731 LIBMTP_INFO(" Device flags: 0x%08x\n", ptp_usb->rawdevice.device_entry.device_flags); in dump_usbinfo()
743 const char *get_playlist_extension(PTP_USB *ptp_usb) in get_playlist_extension() argument
749 dev = usb_device(ptp_usb->handle); in get_playlist_extension()
822 PTP_USB *ptp_usb = (PTP_USB *)data; in ptp_read_func() local
831 uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id; in ptp_read_func()
835 usb_inep_maxpacket_size = ptp_usb->inep_maxpacket; in ptp_read_func()
858 if (readzero && FLAG_NO_ZERO_READS(ptp_usb) && toread % 64 == 0) { in ptp_read_func()
881 result = USB_BULK_READ(ptp_usb->handle, in ptp_read_func()
882 ptp_usb->inep, in ptp_read_func()
885 ptp_usb->timeout); in ptp_read_func()
911 ptp_usb->current_transfer_complete += result; in ptp_read_func()
915 if (ptp_usb->callback_active) { in ptp_read_func()
916 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) { in ptp_read_func()
918 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total; in ptp_read_func()
919 ptp_usb->callback_active = 0; in ptp_read_func()
921 if (ptp_usb->current_transfer_callback != NULL) { in ptp_read_func()
923 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete, in ptp_read_func()
924 ptp_usb->current_transfer_total, in ptp_read_func()
925 ptp_usb->current_transfer_callback_data); in ptp_read_func()
940 !FLAG_NO_ZERO_READS(ptp_usb) && in ptp_read_func()
941 curread % ptp_usb->outep_maxpacket == 0) { in ptp_read_func()
948 zeroresult = USB_BULK_READ(ptp_usb->handle, in ptp_read_func()
949 ptp_usb->inep, in ptp_read_func()
952 ptp_usb->timeout); in ptp_read_func()
967 PTP_USB *ptp_usb = (PTP_USB *)data; in ptp_write_func() local
985 if (towrite > ptp_usb->outep_maxpacket && towrite % ptp_usb->outep_maxpacket != 0) { in ptp_write_func()
986 towrite -= towrite % ptp_usb->outep_maxpacket; in ptp_write_func()
993 result = USB_BULK_WRITE(ptp_usb->handle, in ptp_write_func()
994 ptp_usb->outep, in ptp_write_func()
997 ptp_usb->timeout); in ptp_write_func()
1007 ptp_usb->current_transfer_complete += result; in ptp_write_func()
1012 if (ptp_usb->callback_active) { in ptp_write_func()
1013 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) { in ptp_write_func()
1015 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total; in ptp_write_func()
1016 ptp_usb->callback_active = 0; in ptp_write_func()
1018 if (ptp_usb->current_transfer_callback != NULL) { in ptp_write_func()
1020 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete, in ptp_write_func()
1021 ptp_usb->current_transfer_total, in ptp_write_func()
1022 ptp_usb->current_transfer_callback_data); in ptp_write_func()
1037 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) { in ptp_write_func()
1038 if ((towrite % ptp_usb->outep_maxpacket) == 0) { in ptp_write_func()
1043 result=USB_BULK_WRITE(ptp_usb->handle, in ptp_write_func()
1044 ptp_usb->outep, in ptp_write_func()
1047 ptp_usb->timeout); in ptp_write_func()
1206 PTP_USB *ptp_usb = (PTP_USB *) params->data; in ptp_usb_senddata() local
1208 packet_size = ptp_usb->inep_maxpacket; in ptp_usb_senddata()
1272 PTP_USB *ptp_usb = (PTP_USB *) params->data; in ptp_usb_getpacket() local
1274 packet_size = ptp_usb->inep_maxpacket; in ptp_usb_getpacket()
1302 PTP_USB *ptp_usb = (PTP_USB *) params->data; in ptp_usb_getdata() local
1321 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) { in ptp_usb_getdata()
1343 if (rlen == ptp_usb->inep_maxpacket) { in ptp_usb_getdata()
1393 } else if(!FLAG_NO_ZERO_READS(ptp_usb) && in ptp_usb_getdata()
1422 if (FLAG_NO_ZERO_READS(ptp_usb) && in ptp_usb_getdata()
1423 len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) { in ptp_usb_getdata()
1430 result = USB_BULK_READ(ptp_usb->handle, in ptp_usb_getdata()
1431 ptp_usb->inep, in ptp_usb_getdata()
1434 ptp_usb->timeout); in ptp_usb_getdata()
1437 …d not read in extra byte for %d bytes long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, … in ptp_usb_getdata()
1438 …} else if (len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) { in ptp_usb_getdata()
1445 zeroresult = USB_BULK_READ(ptp_usb->handle, in ptp_usb_getdata()
1446 ptp_usb->inep, in ptp_usb_getdata()
1449 ptp_usb->timeout); in ptp_usb_getdata()
1477 PTP_USB *ptp_usb = (PTP_USB *)(params->data); in ptp_usb_getresp() local
1519 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) { in ptp_usb_getresp()
1549 PTP_USB *ptp_usb = (PTP_USB *)(params->data); in ptp_usb_event() local
1558 result = USB_BULK_READ(ptp_usb->handle, in ptp_usb_event()
1559 ptp_usb->intep, in ptp_usb_event()
1564 result = USB_BULK_READ(ptp_usb->handle, in ptp_usb_event()
1565 ptp_usb->intep, in ptp_usb_event()
1572 result = USB_BULK_READ(ptp_usb->handle, in ptp_usb_event()
1573 ptp_usb->intep, in ptp_usb_event()
1576 ptp_usb->timeout); in ptp_usb_event()
1578 result = USB_BULK_READ(ptp_usb->handle, in ptp_usb_event()
1579 ptp_usb->intep, in ptp_usb_event()
1582 ptp_usb->timeout); in ptp_usb_event()
1636 PTP_USB *ptp_usb = (PTP_USB *)(params->data); in ptp_usb_control_cancel_request() local
1642 ret = usb_control_msg(ptp_usb->handle, in ptp_usb_control_cancel_request()
1647 ptp_usb->timeout); in ptp_usb_control_cancel_request()
1653 static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, struct usb_device* dev) in init_ptp_usb() argument
1664 params->data=ptp_usb; in init_ptp_usb()
1672 ptp_usb->timeout = get_timeout(ptp_usb); in init_ptp_usb()
1679 ptp_usb->handle = device_handle; in init_ptp_usb()
1687 if (FLAG_UNLOAD_DRIVER(ptp_usb)) { in init_ptp_usb()
1688 if (usb_get_driver_np(device_handle, (int) ptp_usb->interface, in init_ptp_usb()
1691 (int) ptp_usb->interface)) { in init_ptp_usb()
1704 if (dev->config->bConfigurationValue != ptp_usb->config) { in init_ptp_usb()
1715 usbresult = usb_claim_interface(device_handle, (int) ptp_usb->interface); in init_ptp_usb()
1730 ptp_usb->altsetting) { in init_ptp_usb()
1739 if (FLAG_SWITCH_MODE_BLACKBERRY(ptp_usb)) { in init_ptp_usb()
1781 static void clear_stall(PTP_USB* ptp_usb) in clear_stall() argument
1788 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->inep,&status); in clear_stall()
1793 ret = usb_clear_stall_feature(ptp_usb,ptp_usb->inep); in clear_stall()
1801 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->outep,&status); in clear_stall()
1806 ret = usb_clear_stall_feature(ptp_usb,ptp_usb->outep); in clear_stall()
1815 static void clear_halt(PTP_USB* ptp_usb) in clear_halt() argument
1819 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->inep); in clear_halt()
1823 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->outep); in clear_halt()
1827 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->intep); in clear_halt()
1833 static void close_usb(PTP_USB* ptp_usb) in close_usb() argument
1835 if (!FLAG_NO_RELEASE_INTERFACE(ptp_usb)) { in close_usb()
1846 clear_stall(ptp_usb); in close_usb()
1850 clear_halt(ptp_usb); in close_usb()
1855 usb_resetep(ptp_usb->handle, ptp_usb->outep); in close_usb()
1856 usb_release_interface(ptp_usb->handle, (int) ptp_usb->interface); in close_usb()
1858 if (FLAG_FORCE_RESET_ON_CLOSE(ptp_usb)) { in close_usb()
1866 usb_reset(ptp_usb->handle); in close_usb()
1868 usb_close(ptp_usb->handle); in close_usb()
1958 PTP_USB *ptp_usb; in configure_usb_device() local
1990 ptp_usb = (PTP_USB *) malloc(sizeof(PTP_USB)); in configure_usb_device()
1991 if (ptp_usb == NULL) { in configure_usb_device()
1995 memset(ptp_usb, 0, sizeof(PTP_USB)); in configure_usb_device()
1998 memcpy(&ptp_usb->rawdevice, device, sizeof(LIBMTP_raw_device_t)); in configure_usb_device()
2004 if (FLAG_ALWAYS_PROBE_DESCRIPTOR(ptp_usb)) { in configure_usb_device()
2011 &ptp_usb->config, in configure_usb_device()
2012 &ptp_usb->interface, in configure_usb_device()
2013 &ptp_usb->altsetting, in configure_usb_device()
2014 &ptp_usb->inep, in configure_usb_device()
2015 &ptp_usb->inep_maxpacket, in configure_usb_device()
2016 &ptp_usb->outep, in configure_usb_device()
2017 &ptp_usb->outep_maxpacket, in configure_usb_device()
2018 &ptp_usb->intep); in configure_usb_device()
2026 ptp_usb->bcdusb = libusb_device->descriptor.bcdUSB; in configure_usb_device()
2029 if (init_ptp_usb(params, ptp_usb, libusb_device) < 0) { in configure_usb_device()
2041 usb_reset(ptp_usb->handle); in configure_usb_device()
2042 close_usb(ptp_usb); in configure_usb_device()
2044 if(init_ptp_usb(params, ptp_usb, libusb_device) <0) { in configure_usb_device()
2067 usb_release_interface(ptp_usb->handle, in configure_usb_device()
2068 (int) ptp_usb->interface); in configure_usb_device()
2073 *usbinfo = (void *) ptp_usb; in configure_usb_device()
2078 void close_device (PTP_USB *ptp_usb, PTPParams *params) in close_device() argument
2082 close_usb(ptp_usb); in close_device()
2085 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout) in set_usb_device_timeout() argument
2087 ptp_usb->timeout = timeout; in set_usb_device_timeout()
2090 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout) in get_usb_device_timeout() argument
2092 *timeout = ptp_usb->timeout; in get_usb_device_timeout()
2095 int guess_usb_speed(PTP_USB *ptp_usb) in guess_usb_speed() argument
2105 switch (ptp_usb->bcdusb & 0xFF00) { in guess_usb_speed()
2124 static int usb_clear_stall_feature(PTP_USB* ptp_usb, int ep) in usb_clear_stall_feature() argument
2126 return (usb_control_msg(ptp_usb->handle, in usb_clear_stall_feature()
2133 ptp_usb->timeout)); in usb_clear_stall_feature()
2136 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status) in usb_get_endpoint_status() argument
2138 return (usb_control_msg(ptp_usb->handle, in usb_get_endpoint_status()
2145 ptp_usb->timeout)); in usb_get_endpoint_status()