libmtp  1.0.6
libusb-glue.h
Go to the documentation of this file.
1 
30 #ifndef LIBUSB_GLUE_H
31 #define LIBUSB_GLUE_H
32 
33 #include "ptp.h"
34 #include <usb.h>
35 #include "libmtp.h"
36 #include "device-flags.h"
37 
38 /* Make functions available for C++ */
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 
46 #define LIBMTP_USB_DEBUG(format, args...) \
47  do { \
48  if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0) \
49  fprintf(stdout, "LIBMTP %s[%d]: " format, __FUNCTION__, __LINE__, ##args); \
50  } while (0)
51 
52 #define LIBMTP_USB_DATA(buffer, length, base) \
53  do { \
54  if ((LIBMTP_debug & LIBMTP_DEBUG_DATA) != 0) \
55  data_dump_ascii (stdout, buffer, length, base); \
56  } while (0)
57 
58 
59 #define USB_BULK_READ usb_bulk_read
60 #define USB_BULK_WRITE usb_bulk_write
61 
65 typedef struct _PTP_USB PTP_USB;
66 struct _PTP_USB {
67  PTPParams *params;
68  usb_dev_handle* handle;
69  uint8_t interface;
70  int inep;
71  int inep_maxpacket;
72  int outep;
73  int outep_maxpacket;
74  int intep;
75  int timeout;
78  uint64_t current_transfer_total;
79  uint64_t current_transfer_complete;
80  LIBMTP_progressfunc_t current_transfer_callback;
81  void const * current_transfer_callback_data;
84 };
85 
86 int open_device (int busn, int devn, short force, PTP_USB *ptp_usb, PTPParams *params, struct usb_device **dev);
87 void dump_usbinfo(PTP_USB *ptp_usb);
88 const char *get_playlist_extension(PTP_USB *ptp_usb);
89 void close_device(PTP_USB *ptp_usb, PTPParams *params);
91  PTPParams *params,
92  void **usbinfo);
93 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout);
94 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout);
95 
96 /* Flag check macros */
97 #define FLAG_BROKEN_MTPGETOBJPROPLIST_ALL(a) \
98  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL)
99 #define FLAG_UNLOAD_DRIVER(a) \
100  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNLOAD_DRIVER)
101 #define FLAG_BROKEN_MTPGETOBJPROPLIST(a) \
102  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
103 #define FLAG_NO_ZERO_READS(a) \
104  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_ZERO_READS)
105 #define FLAG_IRIVER_OGG_ALZHEIMER(a) \
106  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IRIVER_OGG_ALZHEIMER)
107 #define FLAG_ONLY_7BIT_FILENAMES(a) \
108  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ONLY_7BIT_FILENAMES)
109 #define FLAG_NO_RELEASE_INTERFACE(a) \
110  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_RELEASE_INTERFACE)
111 #define FLAG_IGNORE_HEADER_ERRORS(a) \
112  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IGNORE_HEADER_ERRORS)
113 #define FLAG_BROKEN_SET_OBJECT_PROPLIST(a) \
114  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST)
115 #define FLAG_OGG_IS_UNKNOWN(a) \
116  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_OGG_IS_UNKNOWN)
117 #define FLAG_BROKEN_SET_SAMPLE_DIMENSIONS(a) \
118  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_SAMPLE_DIMENSIONS)
119 #define FLAG_ALWAYS_PROBE_DESCRIPTOR(a) \
120  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ALWAYS_PROBE_DESCRIPTOR)
121 #define FLAG_PLAYLIST_SPL_V1(a) \
122  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V1)
123 #define FLAG_PLAYLIST_SPL_V2(a) \
124  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V2)
125 #define FLAG_PLAYLIST_SPL(a) \
126  ((a)->rawdevice.device_entry.device_flags & (DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_PLAYLIST_SPL_V2))
127 #define FLAG_CANNOT_HANDLE_DATEMODIFIED(a) \
128  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_CANNOT_HANDLE_DATEMODIFIED)
129 #define FLAG_BROKEN_SEND_OBJECT_PROPLIST(a) \
130  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST)
131 #define FLAG_BROKEN_BATTERY_LEVEL(a) \
132  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_BATTERY_LEVEL)
133 #define FLAG_FLAC_IS_UNKNOWN(a) \
134  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FLAC_IS_UNKNOWN)
135 #define FLAG_UNIQUE_FILENAMES(a) \
136  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNIQUE_FILENAMES)
137 #define FLAG_SWITCH_MODE_BLACKBERRY(a) \
138  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_SWITCH_MODE_BLACKBERRY)
139 
140 /* connect_first_device return codes */
141 #define PTP_CD_RC_CONNECTED 0
142 #define PTP_CD_RC_NO_DEVICES 1
143 #define PTP_CD_RC_ERROR_CONNECTING 2
144 
145 #ifdef __cplusplus
146 }
147 #endif /* __cplusplus */
148 
149 #endif // LIBUSB-GLUE_H
void dump_usbinfo(PTP_USB *ptp_usb)
Definition: libusb-glue.c:690
int(* LIBMTP_progressfunc_t)(uint64_t const sent, uint64_t const total, void const *const data)
Definition: libmtp.h:444
int callback_active
Definition: libusb-glue.h:77
LIBMTP_error_number_t
Definition: libmtp.h:407
const char * get_playlist_extension(PTP_USB *ptp_usb)
Definition: libusb-glue.c:733
LIBMTP_raw_device_t rawdevice
Definition: libusb-glue.h:83
Definition: ptp.h:1928
LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device, PTPParams *params, void **usbinfo)
Definition: libusb-glue.c:1833
Definition: libmtp.h:505
Definition: libusb-glue.h:66