Home | History | Annotate | Download | only in src

Lines Matching refs:ptp_usb

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