Home | History | Annotate | Download | only in src

Lines Matching refs:ptp_usb

57 static inline int get_timeout(PTP_USB* ptp_usb)
59 if (FLAG_LONG_TIMEOUT(ptp_usb)) {
74 PTP_USB *ptp_usb;
95 static void close_usb(PTP_USB* ptp_usb);
105 static void clear_stall(PTP_USB* ptp_usb);
107 PTP_USB* ptp_usb, libusb_device* dev);
112 static int usb_get_endpoint_status(PTP_USB* ptp_usb,
217 // Do not free() the fields (ptp_usb, params)! These are used elsewhere.
717 * @param ptp_usb the USB device to get information from.
719 void dump_usbinfo(PTP_USB *ptp_usb)
724 if (libusb_kernel_driver_active(ptp_usb->handle, ptp_usb->interface))
727 dev = libusb_get_device (ptp_usb->handle);
736 LIBMTP_INFO(" IN endpoint maxpacket: %d bytes\n", ptp_usb->inep_maxpacket);
737 LIBMTP_INFO(" OUT endpoint maxpacket: %d bytes\n", ptp_usb->outep_maxpacket);
739 LIBMTP_INFO(" Bus location: %d\n", ptp_usb->rawdevice.bus_location);
740 LIBMTP_INFO(" Device number: %d\n", ptp_usb->rawdevice.devnum);
742 LIBMTP_INFO(" Vendor: %s\n", ptp_usb->rawdevice.device_entry.vendor);
743 LIBMTP_INFO(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.vendor_id);
744 LIBMTP_INFO(" Product: %s\n", ptp_usb->rawdevice.device_entry.product);
745 LIBMTP_INFO(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.product_id);
746 LIBMTP_INFO(" Device flags: 0x%08x\n", ptp_usb->rawdevice.device_entry.device_flags);
755 * @param ptp_usb the USB device to get suggestion for.
758 const char *get_playlist_extension(PTP_USB *ptp_usb)
765 dev = libusb_get_device(ptp_usb->handle);
837 PTP_USB *ptp_usb = (PTP_USB *)data;
847 uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id;
851 usb_inep_maxpacket_size = ptp_usb->inep_maxpacket;
873 if (readzero && FLAG_NO_ZERO_READS(ptp_usb) && toread % 64 == 0) {
896 ret = USB_BULK_READ(ptp_usb->handle,
897 ptp_usb->inep,
901 ptp_usb->timeout);
926 ptp_usb->current_transfer_complete += xread;
930 if (ptp_usb->callback_active) {
931 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
933 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
934 ptp_usb->callback_active = 0;
936 if (ptp_usb->current_transfer_callback != NULL) {
938 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
939 ptp_usb->current_transfer_total,
940 ptp_usb->current_transfer_callback_data);
955 !FLAG_NO_ZERO_READS(ptp_usb) &&
956 curread % ptp_usb->outep_maxpacket == 0) {
963 zeroresult = USB_BULK_READ(ptp_usb->handle,
964 ptp_usb->inep,
968 ptp_usb->timeout);
983 PTP_USB *ptp_usb = (PTP_USB *)data;
1003 if (towrite > ptp_usb->outep_maxpacket && towrite % ptp_usb->outep_maxpacket != 0) {
1004 towrite -= towrite % ptp_usb->outep_maxpacket;
1013 ret = USB_BULK_WRITE(ptp_usb->handle,
1014 ptp_usb->outep,
1018 ptp_usb->timeout);
1029 ptp_usb->current_transfer_complete += xwritten;
1034 if (ptp_usb->callback_active) {
1035 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
1037 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
1038 ptp_usb->callback_active = 0;
1040 if (ptp_usb->current_transfer_callback != NULL) {
1042 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
1043 ptp_usb->current_transfer_total,
1044 ptp_usb->current_transfer_callback_data);
1060 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
1061 if ((towrite % ptp_usb->outep_maxpacket) == 0) {
1067 ret =USB_BULK_WRITE(ptp_usb->handle,
1068 ptp_usb->outep,
1072 ptp_usb->timeout);
1231 PTP_USB *ptp_usb = (PTP_USB *) params->data;
1233 packet_size = ptp_usb->outep_maxpacket;
1244 ((PTP_USB*)params->data)->current_transfer_complete = 0;
1245 ((PTP_USB*)params->data)->current_transfer_total = size+PTP_USB_BULK_HDR_LEN;
1297 PTP_USB *ptp_usb = (PTP_USB *) params->data;
1299 packet_size = ptp_usb->inep_maxpacket;
1327 PTP_USB *ptp_usb = (PTP_USB *) params->data;
1346 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) {
1368 if (rlen == ptp_usb->inep_maxpacket) {
1418 } else if(!FLAG_NO_ZERO_READS(ptp_usb) &&
1447 if (FLAG_NO_ZERO_READS(ptp_usb) &&
1448 len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) {
1455 result = USB_BULK_READ(ptp_usb->handle,
1456 ptp_usb->inep,
1460 ptp_usb->timeout);
1463 LIBMTP_INFO("Could not read in extra byte for %d byte long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, result);
1464 } else if (len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) {
1470 zeroresult = USB_BULK_READ(ptp_usb->handle,
1471 ptp_usb->inep,
1475 ptp_usb->timeout);
1503 PTP_USB *ptp_usb = (PTP_USB *)(params->data);
1545 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) {
1575 PTP_USB *ptp_usb;
1581 ptp_usb = (PTP_USB *)(params->data);
1586 result = USB_BULK_READ(ptp_usb->handle,
1587 ptp_usb->intep,
1593 result = USB_BULK_READ(ptp_usb->handle,
1594 ptp_usb->intep,
1602 result = USB_BULK_READ(ptp_usb->handle,
1603 ptp_usb->intep,
1607 ptp_usb->timeout);
1609 result = USB_BULK_READ(ptp_usb->handle,
1610 ptp_usb->intep,
1614 ptp_usb->timeout);
1707 PTP_USB *ptp_usb;
1739 ptp_usb = (PTP_USB *)(params->data);
1740 libusb_fill_interrupt_transfer(t, ptp_usb->handle, ptp_usb->intep,
1760 PTP_USB *ptp_usb = (PTP_USB *)(params->data);
1766 ret = libusb_control_transfer(ptp_usb->handle,
1771 ptp_usb->timeout);
1777 static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev)
1789 params->data=ptp_usb;
1797 ptp_usb->timeout = get_timeout(ptp_usb);
1804 ptp_usb->handle = device_handle;
1811 if (FLAG_UNLOAD_DRIVER(ptp_usb) &&
1812 libusb_kernel_driver_active(device_handle, ptp_usb->interface)
1814 if (LIBUSB_SUCCESS != libusb_detach_kernel_driver(device_handle, ptp_usb->interface)) {
1831 if (libusb_set_configuration(device_handle, ptp_usb->config) != LIBUSB_SUCCESS) {
1840 if (config->bConfigurationValue != ptp_usb->config) {
1842 if (libusb_set_configuration(device_handle, ptp_usb->config)) {
1859 usbresult = libusb_claim_interface(device_handle, ptp_usb->interface);
1874 ptp_usb->altsetting) {
1877 ptp_usb->interface,
1878 ptp_usb->altsetting);
1887 if (FLAG_SWITCH_MODE_BLACKBERRY(ptp_usb)) {
1929 static void clear_stall(PTP_USB* ptp_usb)
1936 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->inep,&status);
1941 ret = libusb_clear_halt (ptp_usb->handle, ptp_usb->inep);
1949 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->outep,&status);
1954 ret = libusb_clear_halt(ptp_usb->handle, ptp_usb->outep);
1960 /* TODO: do we need this for INTERRUPT (ptp_usb->intep) too? */
1963 static void close_usb(PTP_USB* ptp_usb)
1965 if (!FLAG_NO_RELEASE_INTERFACE(ptp_usb)) {
1976 clear_stall(ptp_usb);
1977 libusb_release_interface(ptp_usb->handle, (int) ptp_usb->interface);
1979 if (FLAG_FORCE_RESET_ON_CLOSE(ptp_usb)) {
1987 libusb_reset_device (ptp_usb->handle);
1989 libusb_close(ptp_usb->handle);
2091 PTP_USB *ptp_usb;
2129 ptp_usb = (PTP_USB *) malloc(sizeof(PTP_USB));
2130 if (ptp_usb == NULL) {
2135 memset(ptp_usb, 0, sizeof(PTP_USB));
2138 memcpy(&ptp_usb->rawdevice, device, sizeof(LIBMTP_raw_device_t));
2144 if (FLAG_ALWAYS_PROBE_DESCRIPTOR(ptp_usb)) {
2151 &ptp_usb->config,
2152 &ptp_usb->interface,
2153 &ptp_usb->altsetting,
2154 &ptp_usb->inep,
2155 &ptp_usb->inep_maxpacket,
2156 &ptp_usb->outep,
2157 &ptp_usb->outep_maxpacket,
2158 &ptp_usb->intep);
2162 free (ptp_usb);
2168 ptp_usb->bcdusb = desc.bcdUSB;
2171 if (init_ptp_usb(params, ptp_usb, ldevice) < 0) {
2172 free (ptp_usb);
2185 libusb_reset_device (ptp_usb->handle);
2186 close_usb(ptp_usb);
2188 if(init_ptp_usb(params, ptp_usb, ldevice) <0) {
2191 free (ptp_usb);
2199 free (ptp_usb);
2215 libusb_release_interface(ptp_usb->handle, ptp_usb->interface);
2217 free (ptp_usb);
2222 *usbinfo = (void *) ptp_usb;
2228 void close_device (PTP_USB *ptp_usb, PTPParams *params)
2232 close_usb(ptp_usb);
2235 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout)
2237 ptp_usb->timeout = timeout;
2240 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout)
2242 *timeout = ptp_usb->timeout;
2245 int guess_usb_speed(PTP_USB *ptp_usb)
2255 switch (ptp_usb->bcdusb & 0xFF00) {
2274 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status)
2276 return libusb_control_transfer(ptp_usb->handle,
2283 ptp_usb->timeout);