libmtp 1.0.0
|
00001 00031 #include "ptp.h" 00032 #include <usb.h> 00033 #include "libmtp.h" 00034 #include "device-flags.h" 00035 00036 #define USB_BULK_READ usb_bulk_read 00037 #define USB_BULK_WRITE usb_bulk_write 00038 00042 typedef struct _PTP_USB PTP_USB; 00043 struct _PTP_USB { 00044 PTPParams *params; 00045 usb_dev_handle* handle; 00046 uint8_t interface; 00047 int inep; 00048 int inep_maxpacket; 00049 int outep; 00050 int outep_maxpacket; 00051 int intep; 00052 int timeout; 00054 int callback_active; 00055 uint64_t current_transfer_total; 00056 uint64_t current_transfer_complete; 00057 LIBMTP_progressfunc_t current_transfer_callback; 00058 void const * current_transfer_callback_data; 00060 LIBMTP_raw_device_t rawdevice; 00061 }; 00062 00063 int open_device (int busn, int devn, short force, PTP_USB *ptp_usb, PTPParams *params, struct usb_device **dev); 00064 void dump_usbinfo(PTP_USB *ptp_usb); 00065 const char *get_playlist_extension(PTP_USB *ptp_usb); 00066 void close_device(PTP_USB *ptp_usb, PTPParams *params); 00067 LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device, 00068 PTPParams *params, 00069 void **usbinfo); 00070 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout); 00071 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout); 00072 00073 /* Flag check macros */ 00074 #define FLAG_BROKEN_MTPGETOBJPROPLIST_ALL(a) \ 00075 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL) 00076 #define FLAG_UNLOAD_DRIVER(a) \ 00077 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNLOAD_DRIVER) 00078 #define FLAG_BROKEN_MTPGETOBJPROPLIST(a) \ 00079 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST) 00080 #define FLAG_NO_ZERO_READS(a) \ 00081 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_ZERO_READS) 00082 #define FLAG_IRIVER_OGG_ALZHEIMER(a) \ 00083 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IRIVER_OGG_ALZHEIMER) 00084 #define FLAG_ONLY_7BIT_FILENAMES(a) \ 00085 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ONLY_7BIT_FILENAMES) 00086 #define FLAG_NO_RELEASE_INTERFACE(a) \ 00087 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_RELEASE_INTERFACE) 00088 #define FLAG_IGNORE_HEADER_ERRORS(a) \ 00089 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IGNORE_HEADER_ERRORS) 00090 #define FLAG_BROKEN_SET_OBJECT_PROPLIST(a) \ 00091 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST) 00092 #define FLAG_OGG_IS_UNKNOWN(a) \ 00093 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_OGG_IS_UNKNOWN) 00094 #define FLAG_BROKEN_SET_SAMPLE_DIMENSIONS(a) \ 00095 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_SAMPLE_DIMENSIONS) 00096 #define FLAG_ALWAYS_PROBE_DESCRIPTOR(a) \ 00097 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ALWAYS_PROBE_DESCRIPTOR) 00098 #define FLAG_PLAYLIST_SPL_V1(a) \ 00099 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V1) 00100 #define FLAG_PLAYLIST_SPL_V2(a) \ 00101 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V2) 00102 #define FLAG_PLAYLIST_SPL(a) \ 00103 ((a)->rawdevice.device_entry.device_flags & (DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_PLAYLIST_SPL_V2)) 00104 #define FLAG_CANNOT_HANDLE_DATEMODIFIED(a) \ 00105 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_CANNOT_HANDLE_DATEMODIFIED) 00106 #define FLAG_BROKEN_SEND_OBJECT_PROPLIST(a) \ 00107 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST) 00108 #define FLAG_BROKEN_BATTERY_LEVEL(a) \ 00109 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_BATTERY_LEVEL) 00110 #define FLAG_FLAC_IS_UNKNOWN(a) \ 00111 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FLAC_IS_UNKNOWN) 00112 00113 /* connect_first_device return codes */ 00114 #define PTP_CD_RC_CONNECTED 0 00115 #define PTP_CD_RC_NO_DEVICES 1 00116 #define PTP_CD_RC_ERROR_CONNECTING 2