Lines Matching refs:ptp_usb

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