libmtp: /usr/obj/ports/libmtp-1.1.3/libmtp-1.1.3/src/libusb-glue.h Source File

# libusb-glue.h

Go to the documentation of this file.

    00001
    00030 #ifndef LIBUSB_GLUE_H
    00031 #define LIBUSB_GLUE_H
    00032
    00033 #include "ptp.h"
    00034 #ifdef HAVE_LIBUSB1
    00035 #include <libusb-1.0/libusb.h>
    00036 #endif
    00037 #ifdef HAVE_LIBUSB0
    00038 #include <usb.h>
    00039 #endif
    00040 #ifdef HAVE_LIBOPENUSB
    00041 #include <openusb.h>
    00042 #endif
    00043 #include "libmtp.h"
    00044 #include "device-flags.h"
    00045
    00046 /* Make functions available for C++ */
    00047 #ifdef __cplusplus
    00048 extern "C" {
    00049 #endif /* __cplusplus */
    00050
    00054 #define LIBMTP_USB_DEBUG(format, args...) \
    00055   do { \
    00056     if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0) \
    00057       fprintf(stdout, "LIBMTP %s[%d]: " format, __FUNCTION__, __LINE__, ##args); \
    00058   } while (0)
    00059
    00060 #define LIBMTP_USB_DATA(buffer, length, base) \
    00061   do { \
    00062     if ((LIBMTP_debug & LIBMTP_DEBUG_DATA) != 0) \
    00063       data_dump_ascii (stdout, buffer, length, base); \
    00064   } while (0)
    00065
    00066 #ifdef HAVE_LIBUSB1
    00067 #define USB_BULK_READ libusb_bulk_transfer
    00068 #define USB_BULK_WRITE libusb_bulk_transfer
    00069 #endif
    00070 #ifdef HAVE_LIBUSB0
    00071 #define USB_BULK_READ usb_bulk_read
    00072 #define USB_BULK_WRITE usb_bulk_write
    00073 #endif
    00074 #ifdef HAVE_LIBOPENUSB
    00075 #define USB_BULK_READ openusb_bulk_xfer
    00076 #define USB_BULK_WRITE openusb_bulk_xfer
    00077 #endif
    00078
    00082 typedef struct _PTP_USB PTP_USB;
    00083 struct _PTP_USB {
    00084   PTPParams *params;
    00085 #ifdef HAVE_LIBUSB1
    00086   libusb_device_handle* handle;
    00087 #endif
    00088 #ifdef HAVE_LIBUSB0
    00089   usb_dev_handle* handle;
    00090 #endif
    00091 #ifdef HAVE_LIBOPENUSB
    00092   openusb_dev_handle_t* handle;
    00093 #endif
    00094   uint8_t interface;
    00095   int inep;
    00096   int inep_maxpacket;
    00097   int outep;
    00098   int outep_maxpacket;
    00099   int intep;
    00101   int callback_active;
    00102   int timeout;
    00103   uint16_t bcdusb;
    00104   uint64_t current_transfer_total;
    00105   uint64_t current_transfer_complete;
    00106   LIBMTP_progressfunc_t current_transfer_callback;
    00107   void const * current_transfer_callback_data;
    00109   LIBMTP_raw_device_t rawdevice;
    00110 };
    00111
    00112 void dump_usbinfo(PTP_USB *ptp_usb);
    00113 const char *get_playlist_extension(PTP_USB *ptp_usb);
    00114 void close_device(PTP_USB *ptp_usb, PTPParams *params);
    00115 LIBMTP_error_number_t configure_usb_device(LIBMTP_raw_device_t *device,
    00116                                            PTPParams *params,
    00117                                            void **usbinfo);
    00118 void set_usb_device_timeout(PTP_USB *ptp_usb, int timeout);
    00119 void get_usb_device_timeout(PTP_USB *ptp_usb, int *timeout);
    00120 int guess_usb_speed(PTP_USB *ptp_usb);
    00121
    00122 /* Flag check macros */
    00123 #define FLAG_BROKEN_MTPGETOBJPROPLIST_ALL(a) \
    00124   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL)
    00125 #define FLAG_UNLOAD_DRIVER(a) \
    00126   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNLOAD_DRIVER)
    00127 #define FLAG_BROKEN_MTPGETOBJPROPLIST(a) \
    00128   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
    00129 #define FLAG_NO_ZERO_READS(a) \
    00130   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_ZERO_READS)
    00131 #define FLAG_IRIVER_OGG_ALZHEIMER(a) \
    00132   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IRIVER_OGG_ALZHEIMER)
    00133 #define FLAG_ONLY_7BIT_FILENAMES(a) \
    00134   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ONLY_7BIT_FILENAMES)
    00135 #define FLAG_NO_RELEASE_INTERFACE(a) \
    00136   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_NO_RELEASE_INTERFACE)
    00137 #define FLAG_IGNORE_HEADER_ERRORS(a) \
    00138   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_IGNORE_HEADER_ERRORS)
    00139 #define FLAG_BROKEN_SET_OBJECT_PROPLIST(a) \
    00140   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST)
    00141 #define FLAG_OGG_IS_UNKNOWN(a) \
    00142   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_OGG_IS_UNKNOWN)
    00143 #define FLAG_BROKEN_SET_SAMPLE_DIMENSIONS(a) \
    00144   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SET_SAMPLE_DIMENSIONS)
    00145 #define FLAG_ALWAYS_PROBE_DESCRIPTOR(a) \
    00146   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_ALWAYS_PROBE_DESCRIPTOR)
    00147 #define FLAG_PLAYLIST_SPL_V1(a) \
    00148   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V1)
    00149 #define FLAG_PLAYLIST_SPL_V2(a) \
    00150   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_PLAYLIST_SPL_V2)
    00151 #define FLAG_PLAYLIST_SPL(a) \
    00152   ((a)->rawdevice.device_entry.device_flags & (DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_PLAYLIST_SPL_V2))
    00153 #define FLAG_CANNOT_HANDLE_DATEMODIFIED(a) \
    00154   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_CANNOT_HANDLE_DATEMODIFIED)
    00155 #define FLAG_BROKEN_SEND_OBJECT_PROPLIST(a) \
    00156   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST)
    00157 #define FLAG_BROKEN_BATTERY_LEVEL(a) \
    00158   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_BATTERY_LEVEL)
    00159 #define FLAG_FLAC_IS_UNKNOWN(a) \
    00160   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FLAC_IS_UNKNOWN)
    00161 #define FLAG_UNIQUE_FILENAMES(a) \
    00162   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNIQUE_FILENAMES)
    00163 #define FLAG_SWITCH_MODE_BLACKBERRY(a) \
    00164   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_SWITCH_MODE_BLACKBERRY)
    00165 #define FLAG_LONG_TIMEOUT(a) \
    00166   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_LONG_TIMEOUT)
    00167 #define FLAG_FORCE_RESET_ON_CLOSE(a) \
    00168   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FORCE_RESET_ON_CLOSE)
    00169 #define FLAG_BROKEN_GET_OBJECT_PROPVAL(a) \
    00170   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL)
    00171
    00172 /* connect_first_device return codes */
    00173 #define PTP_CD_RC_CONNECTED     0
    00174 #define PTP_CD_RC_NO_DEVICES    1
    00175 #define PTP_CD_RC_ERROR_CONNECTING      2
    00176
    00177 #ifdef __cplusplus
    00178 }
    00179 #endif /* __cplusplus */
    00180
    00181 #endif //  LIBUSB-GLUE_H