Home | History | Annotate | Download | only in src

Lines Matching refs:ptp_usb

88   PTP_USB *ptp_usb;
102 static void close_usb(PTP_USB* ptp_usb);
110 static void clear_stall(PTP_USB* ptp_usb);
111 static int init_ptp_usb (PTPParams* params, PTP_USB* ptp_usb, struct usb_device* dev);
114 static int usb_clear_stall_feature(PTP_USB* ptp_usb, int ep);
115 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status);
203 // Do not free() the fields (ptp_usb, params)! These are used elsewhere.
691 * @param ptp_usb the USB device to get information from.
693 void dump_usbinfo(PTP_USB *ptp_usb)
702 res = usb_get_driver_np(ptp_usb->handle, (int) ptp_usb->interface, devname, sizeof(devname));
707 dev = usb_device(ptp_usb->handle);
714 printf(" IN endpoint maxpacket: %d bytes\n", ptp_usb->inep_maxpacket);
715 printf(" OUT endpoint maxpacket: %d bytes\n", ptp_usb->outep_maxpacket);
717 printf(" Bus location: %d\n", ptp_usb->rawdevice.bus_location);
718 printf(" Device number: %d\n", ptp_usb->rawdevice.devnum);
720 printf(" Vendor: %s\n", ptp_usb->rawdevice.device_entry.vendor);
721 printf(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.vendor_id);
722 printf(" Product: %s\n", ptp_usb->rawdevice.device_entry.product);
723 printf(" Vendor id: 0x%04x\n", ptp_usb->rawdevice.device_entry.product_id);
724 printf(" Device flags: 0x%08x\n", ptp_usb->rawdevice.device_entry.device_flags);
733 * @param ptp_usb the USB device to get suggestion for.
736 const char *get_playlist_extension(PTP_USB *ptp_usb)
742 dev = usb_device(ptp_usb->handle);
814 PTP_USB *ptp_usb = (PTP_USB *)data;
835 if (readzero && FLAG_NO_ZERO_READS(ptp_usb) && toread % 64 == 0) {
854 result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, (char*)bytes, toread, ptp_usb->timeout);
885 ptp_usb->current_transfer_complete += result;
889 if (ptp_usb->callback_active) {
890 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
892 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
893 ptp_usb->callback_active = 0;
895 if (ptp_usb->current_transfer_callback != NULL) {
897 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
898 ptp_usb->current_transfer_total,
899 ptp_usb->current_transfer_callback_data);
914 !FLAG_NO_ZERO_READS(ptp_usb) &&
915 curread % ptp_usb->outep_maxpacket == 0) {
923 zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &temp, 0, ptp_usb->timeout);
938 PTP_USB *ptp_usb = (PTP_USB *)data;
956 if (towrite > ptp_usb->outep_maxpacket && towrite % ptp_usb->outep_maxpacket != 0) {
957 towrite -= towrite % ptp_usb->outep_maxpacket;
964 result = USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,((char*)bytes+usbwritten),towrite-usbwritten,ptp_usb->timeout);
978 ptp_usb->current_transfer_complete += result;
983 if (ptp_usb->callback_active) {
984 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
986 ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
987 ptp_usb->callback_active = 0;
989 if (ptp_usb->current_transfer_callback != NULL) {
991 ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
992 ptp_usb->current_transfer_total,
993 ptp_usb->current_transfer_callback_data);
1009 if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
1010 if ((towrite % ptp_usb->outep_maxpacket) == 0) {
1015 result=USB_BULK_WRITE(ptp_usb->handle,ptp_usb->outep,(char *)"x",0,ptp_usb->timeout);
1188 ((PTP_USB*)params->data)->current_transfer_complete = 0;
1189 ((PTP_USB*)params->data)->current_transfer_total = size+PTP_USB_BULK_HDR_LEN;
1266 PTP_USB *ptp_usb = (PTP_USB *) params->data;
1285 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) {
1357 } else if(!FLAG_NO_ZERO_READS(ptp_usb) &&
1386 if (FLAG_NO_ZERO_READS(ptp_usb) &&
1394 result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &byte, 1, ptp_usb->timeout);
1405 zeroresult = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &zerobyte, 0, ptp_usb->timeout);
1433 PTP_USB *ptp_usb = (PTP_USB *)(params->data);
1475 if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) {
1505 PTP_USB *ptp_usb = (PTP_USB *)(params->data);
1514 result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),ptp_usb->timeout);
1516 result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), ptp_usb->timeout);
1520 result=USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *)&usbevent,sizeof(usbevent),ptp_usb->timeout);
1522 result = USB_BULK_READ(ptp_usb->handle, ptp_usb->intep,(char *) &usbevent, sizeof(usbevent), ptp_usb->timeout);
1565 PTP_USB *ptp_usb = (PTP_USB *)(params->data);
1571 ret = usb_control_msg(ptp_usb->handle,
1573 0x64, 0x0000, 0x0000, (char *) buffer, sizeof(buffer), ptp_usb->timeout);
1579 static int init_ptp_usb (PTPParams* params, PTP_USB* ptp_usb, struct usb_device* dev)
1588 params->data=ptp_usb;
1596 ptp_usb->timeout = USB_TIMEOUT_DEFAULT;
1604 ptp_usb->handle = device_handle;
1611 if (FLAG_UNLOAD_DRIVER(ptp_usb)) {
1612 if (usb_detach_kernel_driver_np(device_handle, (int) ptp_usb->interface)) {
1625 if (usb_claim_interface(device_handle, (int) ptp_usb->interface)) {
1633 static void clear_stall(PTP_USB* ptp_usb)
1640 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->inep,&status);
1645 ret = usb_clear_stall_feature(ptp_usb,ptp_usb->inep);
1653 ret = usb_get_endpoint_status(ptp_usb,ptp_usb->outep,&status);
1658 ret = usb_clear_stall_feature(ptp_usb,ptp_usb->outep);
1664 /* TODO: do we need this for INTERRUPT (ptp_usb->intep) too? */
1667 static void clear_halt(PTP_USB* ptp_usb)
1671 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->inep);
1675 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->outep);
1679 ret = usb_clear_halt(ptp_usb->handle,ptp_usb->intep);
1685 static void close_usb(PTP_USB* ptp_usb)
1689 if (!FLAG_NO_RELEASE_INTERFACE(ptp_usb)) {
1701 clear_stall(ptp_usb);
1703 clear_halt(ptp_usb);
1707 usb_resetep(ptp_usb->handle, ptp_usb->outep);
1708 usb_release_interface(ptp_usb->handle, (int) ptp_usb->interface);
1711 usb_close(ptp_usb->handle);
1785 PTP_USB *ptp_usb;
1816 ptp_usb = (PTP_USB *) malloc(sizeof(PTP_USB));
1817 if (ptp_usb == NULL) {
1821 memset(ptp_usb, 0, sizeof(PTP_USB));
1824 memcpy(&ptp_usb->rawdevice, device, sizeof(LIBMTP_raw_device_t));
1830 if (FLAG_ALWAYS_PROBE_DESCRIPTOR(ptp_usb)) {
1838 &ptp_usb->interface,
1839 &ptp_usb->inep,
1840 &ptp_usb->inep_maxpacket,
1841 &ptp_usb->outep,
1842 &ptp_usb->outep_maxpacket,
1843 &ptp_usb->intep);
1846 if (init_ptp_usb(params, ptp_usb, libusb_device) < 0) {
1857 close_usb(ptp_usb);
1859 if(init_ptp_usb(params, ptp_usb, libusb_device) <0) {
1879 usb_release_interface(ptp_usb->handle,
1880 (int) ptp_usb->interface);
1885 *usbinfo = (void *) ptp_usb;
1890 void close_device (PTP_USB *ptp_usb, PTPParams *params)
1894 close_usb(ptp_usb);
1897 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout)
1899 ptp_usb->timeout = timeout;
1902 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout)
1904 *timeout = ptp_usb->timeout;
1907 static int usb_clear_stall_feature(PTP_USB* ptp_usb, int ep)
1910 return (usb_control_msg(ptp_usb->handle,
1912 ep, NULL, 0, ptp_usb->timeout));
1915 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status)
1917 return (usb_control_msg(ptp_usb->handle,
1919 USB_FEATURE_HALT, ep, (char *)status, 2, ptp_usb->timeout));