libmtp 1.1.23

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#ifdef HAVE_LIBUSB1
35#include <libusb.h>
36#endif
37#ifdef HAVE_LIBUSB0
38#include <usb.h>
39#endif
40#ifdef HAVE_LIBOPENUSB
41#include <openusb.h>
42#endif
43#include "libmtp.h"
44#include "device-flags.h"
45
46/* Make functions available for C++ */
47#ifdef __cplusplus
48 extern "C" {
49#endif /* __cplusplus */
50
54#define LIBMTP_USB_DEBUG(format, args...) \
55 do { \
56 if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0) \
57 fprintf(stdout, "LIBMTP %s[%d]: " format, __FUNCTION__, __LINE__, ##args); \
58 } while (0)
59
60#define LIBMTP_USB_DATA(buffer, length, base) \
61 do { \
62 if ((LIBMTP_debug & LIBMTP_DEBUG_DATA) != 0) \
63 data_dump_ascii (stdout, buffer, length, base); \
64 } while (0)
65
66#ifdef HAVE_LIBUSB1
67#define USB_BULK_READ libusb_bulk_transfer
68#define USB_BULK_WRITE libusb_bulk_transfer
69#endif
70#ifdef HAVE_LIBUSB0
71#define USB_BULK_READ usb_bulk_read
72#define USB_BULK_WRITE usb_bulk_write
73#endif
74#ifdef HAVE_LIBOPENUSB
75#define USB_BULK_READ openusb_bulk_xfer
76#define USB_BULK_WRITE openusb_bulk_xfer
77#endif
78
82 typedef struct _PTP_USB PTP_USB;
83 struct _PTP_USB {
84 PTPParams *params;
85#ifdef HAVE_LIBUSB1
86 libusb_device_handle* handle;
87#endif
88#ifdef HAVE_LIBUSB0
89 usb_dev_handle* handle;
90#endif
91#ifdef HAVE_LIBOPENUSB
92 openusb_dev_handle_t* handle;
93#endif
94 uint8_t config;
95 uint8_t interface;
96 uint8_t altsetting;
97 int inep;
98 int inep_maxpacket;
99 int outep;
100 int outep_maxpacket;
101 int intep;
103 int callback_active;
104 int timeout;
105 uint16_t bcdusb;
106 uint64_t current_transfer_total;
107 uint64_t current_transfer_complete;
108 LIBMTP_progressfunc_t current_transfer_callback;
109 void const * current_transfer_callback_data;
111 LIBMTP_raw_device_t rawdevice;
112};
113
114 void dump_usbinfo(PTP_USB *ptp_usb);
115 const char *get_playlist_extension(PTP_USB *ptp_usb);
116 void close_device(PTP_USB *ptp_usb, PTPParams *params);
117 LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device,
118 PTPParams *params,
119 void **usbinfo);
120 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout);
121 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout);
122 int guess_usb_speed(PTP_USB *ptp_usb);
123
124/* Flag check macros */
125#define FLAG_BROKEN_MTPGETOBJPROPLIST_ALL(a) \
126 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL)
127#define FLAG_UNLOAD_DRIVER(a) \
128 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNLOAD_DRIVER)
129#define FLAG_BROKEN_MTPGETOBJPROPLIST(a) \
130 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
131#define FLAG_NO_ZERO_READS(a) \
132 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_ZERO_READS)
133#define FLAG_IRIVER_OGG_ALZHEIMER(a) \
134 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IRIVER_OGG_ALZHEIMER)
135#define FLAG_ONLY_7BIT_FILENAMES(a) \
136 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ONLY_7BIT_FILENAMES)
137#define FLAG_NO_RELEASE_INTERFACE(a) \
138 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_RELEASE_INTERFACE)
139#define FLAG_IGNORE_HEADER_ERRORS(a) \
140 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IGNORE_HEADER_ERRORS)
141#define FLAG_BROKEN_SET_OBJECT_PROPLIST(a) \
142 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST)
143#define FLAG_OGG_IS_UNKNOWN(a) \
144 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_OGG_IS_UNKNOWN)
145#define FLAG_BROKEN_SET_SAMPLE_DIMENSIONS(a) \
146 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_SAMPLE_DIMENSIONS)
147#define FLAG_ALWAYS_PROBE_DESCRIPTOR(a) \
148 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ALWAYS_PROBE_DESCRIPTOR)
149#define FLAG_PLAYLIST_SPL_V1(a) \
150 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V1)
151#define FLAG_PLAYLIST_SPL_V2(a) \
152 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V2)
153#define FLAG_PLAYLIST_SPL(a) \
154 ((a)->rawdevice.device_entry.device_flags & (DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_PLAYLIST_SPL_V2))
155#define FLAG_CANNOT_HANDLE_DATEMODIFIED(a) \
156 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_CANNOT_HANDLE_DATEMODIFIED)
157#define FLAG_BROKEN_SEND_OBJECT_PROPLIST(a) \
158 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST)
159#define FLAG_BROKEN_BATTERY_LEVEL(a) \
160 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_BATTERY_LEVEL)
161#define FLAG_FLAC_IS_UNKNOWN(a) \
162 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FLAC_IS_UNKNOWN)
163#define FLAG_UNIQUE_FILENAMES(a) \
164 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNIQUE_FILENAMES)
165#define FLAG_SWITCH_MODE_BLACKBERRY(a) \
166 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_SWITCH_MODE_BLACKBERRY)
167#define FLAG_LONG_TIMEOUT(a) \
168 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_LONG_TIMEOUT)
169#define FLAG_FORCE_RESET_ON_CLOSE(a) \
170 ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FORCE_RESET_ON_CLOSE)
171
172/* connect_first_device return codes */
173#define PTP_CD_RC_CONNECTED 0
174#define PTP_CD_RC_NO_DEVICES 1
175#define PTP_CD_RC_ERROR_CONNECTING 2
176
177#ifdef __cplusplus
178}
179#endif /* __cplusplus */
180
181#endif // LIBUSB-GLUE_H
device-flags.h
LIBMTP_error_number_t
LIBMTP_error_number_t
Definition libmtp.h:447
LIBMTP_progressfunc_t
int(* LIBMTP_progressfunc_t)(uint64_t const sent, uint64_t const total, void const *const data)
Definition libmtp.h:483
LIBMTP_raw_device_t
struct LIBMTP_raw_device_struct LIBMTP_raw_device_t
Definition libmtp.h:460
libmtp.h
get_playlist_extension
const char * get_playlist_extension(PTP_USB *ptp_usb)
Definition libopenusb1-glue.c:716
PTP_USB
struct _PTP_USB PTP_USB
Definition libusb-glue.h:82
configure_usb_device
LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device, PTPParams *params, void **usbinfo)
Definition libopenusb1-glue.c:2070
dump_usbinfo
void dump_usbinfo(PTP_USB *ptp_usb)
Definition libopenusb1-glue.c:683
_PTP_USB
Definition libusb-glue.h:83
_PTP_USB::callback_active
int callback_active
Definition libusb-glue.h:103
_PTP_USB::rawdevice
LIBMTP_raw_device_t rawdevice
Definition libusb-glue.h:111