diff options
Diffstat (limited to 'src/usb.h')
-rw-r--r-- | src/usb.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/usb.h b/src/usb.h new file mode 100644 index 0000000..4e44cce --- /dev/null +++ b/src/usb.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * usb.h | ||
3 | * | ||
4 | * Copyright (C) 2009 Hector Martin <hector@marcansoft.com> | ||
5 | * Copyright (C) 2009 Nikias Bassen <nikias@gmx.li> | ||
6 | * Copyright (C) 2009 Martin Szulecki <opensuse@sukimashita.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation, either version 2 or version 3. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | #ifndef USB_H | ||
23 | #define USB_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | #include "utils.h" | ||
27 | |||
28 | #define INTERFACE_CLASS 255 | ||
29 | #define INTERFACE_SUBCLASS 254 | ||
30 | #define INTERFACE_PROTOCOL 2 | ||
31 | |||
32 | // libusb fragments packets larger than this (usbfs limitation) | ||
33 | // on input, this creates race conditions and other issues | ||
34 | #define USB_MRU 16384 | ||
35 | |||
36 | // max transmission packet size | ||
37 | // libusb fragments these too, but doesn't send ZLPs so we're safe | ||
38 | // but we need to send a ZLP ourselves at the end (see usb-linux.c) | ||
39 | // we're using 3 * 16384 to optimize for the fragmentation | ||
40 | // this results in three URBs per full transfer, 32 USB packets each | ||
41 | // if there are ZLP issues this should make them show up easily too | ||
42 | #define USB_MTU (3 * 16384) | ||
43 | |||
44 | #define USB_PACKET_SIZE 512 | ||
45 | |||
46 | #define VID_APPLE 0x5ac | ||
47 | #define PID_RANGE_LOW 0x1290 | ||
48 | #define PID_RANGE_MAX 0x12af | ||
49 | #define PID_APPLE_T2_COPROCESSOR 0x8600 | ||
50 | #define PID_APPLE_SILICON_RESTORE_LOW 0x1901 | ||
51 | #define PID_APPLE_SILICON_RESTORE_MAX 0x1905 | ||
52 | |||
53 | #define ENV_DEVICE_MODE "USBMUXD_DEFAULT_DEVICE_MODE" | ||
54 | #define APPLE_VEND_SPECIFIC_GET_MODE 0x45 | ||
55 | #define APPLE_VEND_SPECIFIC_SET_MODE 0x52 | ||
56 | |||
57 | struct usb_device; | ||
58 | |||
59 | int usb_init(void); | ||
60 | void usb_shutdown(void); | ||
61 | const char *usb_get_serial(struct usb_device *dev); | ||
62 | uint32_t usb_get_location(struct usb_device *dev); | ||
63 | uint16_t usb_get_pid(struct usb_device *dev); | ||
64 | uint64_t usb_get_speed(struct usb_device *dev); | ||
65 | void usb_get_fds(struct fdlist *list); | ||
66 | int usb_get_timeout(void); | ||
67 | int usb_send(struct usb_device *dev, const unsigned char *buf, int length); | ||
68 | int usb_discover(void); | ||
69 | void usb_autodiscover(int enable); | ||
70 | int usb_process(void); | ||
71 | int usb_process_timeout(int msec); | ||
72 | |||
73 | #endif | ||