libusb-glue.h revision 0558ac5a7223633c592b05c2e10b7591e0b48db4
1eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij/* 2b02a066363ab3c9b4f8f48b227c9b7b71cf7705eLinus Walleij * libusb-glue.h 3eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij * 4eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij * Created by Richard Low on 24/12/2005. 5b02a066363ab3c9b4f8f48b227c9b7b71cf7705eLinus Walleij * Modified by Linus Walleij 6eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij * 7eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij */ 8eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij 9b02a066363ab3c9b4f8f48b227c9b7b71cf7705eLinus Walleij#include "ptp.h" 10eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#include <usb.h> 1115e344f57021b532da574b73aa74d1de3d6cdc73Linus Walleij#include "libmtp.h" 12eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij 13eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#define USB_BULK_READ usb_bulk_read 14eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#define USB_BULK_WRITE usb_bulk_write 15eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij 162d411dbbac42bec217126c9bf97f6bef9977c484Linus Walleij/** 170558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * These flags are used to indicate if some or other 180558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * device need special treatment. These should be possible 190558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * to concatenate using logical OR so please use one bit per 200558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * feature and lets pray we don't need more than 32 bits... 210558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij */ 220558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij#define DEVICE_FLAG_NONE 0x00000000 230558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij/** 240558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * This means the device supports both MTP and USB mass 250558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * storage by dynamically reconfiguring itself if it is not 260558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * used with MTP before a certain timeout. 270558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij */ 280558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij#define DEVICE_FLAG_DUALMODE 0x00000001 290558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij 300558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij/** 310558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij * Internal USB struct. 322d411dbbac42bec217126c9bf97f6bef9977c484Linus Walleij */ 332d411dbbac42bec217126c9bf97f6bef9977c484Linus Walleijtypedef struct _PTP_USB PTP_USB; 342d411dbbac42bec217126c9bf97f6bef9977c484Linus Walleijstruct _PTP_USB { 35c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij usb_dev_handle* handle; 36c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int interface; 37c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int inep; 38c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int inep_maxpacket; 39c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int outep; 40c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int outep_maxpacket; 41c6210fb655cbf972efe722328e504434dc4d171cLinus Walleij int intep; 42d214b9bae4e9b0c106a21ff3a3c24029982f9d50Linus Walleij /** File transfer callbacks and counters */ 43d214b9bae4e9b0c106a21ff3a3c24029982f9d50Linus Walleij int callback_active; 44d214b9bae4e9b0c106a21ff3a3c24029982f9d50Linus Walleij uint64_t current_transfer_total; 45d214b9bae4e9b0c106a21ff3a3c24029982f9d50Linus Walleij uint64_t current_transfer_complete; 46d214b9bae4e9b0c106a21ff3a3c24029982f9d50Linus Walleij LIBMTP_progressfunc_t current_transfer_callback; 47ee73ef2300dae31ead0bf9dd755192207b18df53Linus Walleij void const * current_transfer_callback_data; 480558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij /** Any special device flags, only used internally */ 490558ac5a7223633c592b05c2e10b7591e0b48db4Linus Walleij uint32_t device_flags; 502d411dbbac42bec217126c9bf97f6bef9977c484Linus Walleij}; 51eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij 526fd2f081a516019d7f37ec82ac9eb100cf3a17b7Linus Walleijint get_device_list(LIBMTP_device_entry_t ** const devices, int * const numdevs); 53eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleijint open_device (int busn, int devn, short force, PTP_USB *ptp_usb, PTPParams *params, struct usb_device **dev); 54c6210fb655cbf972efe722328e504434dc4d171cLinus Walleijvoid dump_usbinfo(PTP_USB *ptp_usb); 55eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleijvoid close_device (PTP_USB *ptp_usb, PTPParams *params, uint8_t interfaceNumber); 56eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleijuint16_t connect_first_device(PTPParams *params, PTP_USB *ptp_usb, uint8_t *interfaceNumber); 57eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij 58eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij/* connect_first_device return codes */ 59eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#define PTP_CD_RC_CONNECTED 0 60eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#define PTP_CD_RC_NO_DEVICES 1 61eb8c6fe031f5ba155cabcbfabcc235acffbc2fbLinus Walleij#define PTP_CD_RC_ERROR_CONNECTING 2 62