libusb-glue.h revision 0558ac5a7223633c592b05c2e10b7591e0b48db4
1/* 2 * libusb-glue.h 3 * 4 * Created by Richard Low on 24/12/2005. 5 * Modified by Linus Walleij 6 * 7 */ 8 9#include "ptp.h" 10#include <usb.h> 11#include "libmtp.h" 12 13#define USB_BULK_READ usb_bulk_read 14#define USB_BULK_WRITE usb_bulk_write 15 16/** 17 * These flags are used to indicate if some or other 18 * device need special treatment. These should be possible 19 * to concatenate using logical OR so please use one bit per 20 * feature and lets pray we don't need more than 32 bits... 21 */ 22#define DEVICE_FLAG_NONE 0x00000000 23/** 24 * This means the device supports both MTP and USB mass 25 * storage by dynamically reconfiguring itself if it is not 26 * used with MTP before a certain timeout. 27 */ 28#define DEVICE_FLAG_DUALMODE 0x00000001 29 30/** 31 * Internal USB struct. 32 */ 33typedef struct _PTP_USB PTP_USB; 34struct _PTP_USB { 35 usb_dev_handle* handle; 36 int interface; 37 int inep; 38 int inep_maxpacket; 39 int outep; 40 int outep_maxpacket; 41 int intep; 42 /** File transfer callbacks and counters */ 43 int callback_active; 44 uint64_t current_transfer_total; 45 uint64_t current_transfer_complete; 46 LIBMTP_progressfunc_t current_transfer_callback; 47 void const * current_transfer_callback_data; 48 /** Any special device flags, only used internally */ 49 uint32_t device_flags; 50}; 51 52int get_device_list(LIBMTP_device_entry_t ** const devices, int * const numdevs); 53int open_device (int busn, int devn, short force, PTP_USB *ptp_usb, PTPParams *params, struct usb_device **dev); 54void dump_usbinfo(PTP_USB *ptp_usb); 55void close_device (PTP_USB *ptp_usb, PTPParams *params, uint8_t interfaceNumber); 56uint16_t connect_first_device(PTPParams *params, PTP_USB *ptp_usb, uint8_t *interfaceNumber); 57 58/* connect_first_device return codes */ 59#define PTP_CD_RC_CONNECTED 0 60#define PTP_CD_RC_NO_DEVICES 1 61#define PTP_CD_RC_ERROR_CONNECTING 2 62