configure: Fix --enable-udev help text
[libusbx.git] / libusb / os / darwin_usb.h
bloba80aa8b37f3da19c5029ca7e2be60c1f7d020f61
1 /*
2 * darwin backend for libusbx 1.0
3 * Copyright © 2008-2013 Nathan Hjelm <hjelmn@users.sourceforge.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #if !defined(LIBUSB_DARWIN_H)
21 #define LIBUSB_DARWIN_H
23 #include "libusbi.h"
25 #include <IOKit/IOTypes.h>
26 #include <IOKit/IOCFBundle.h>
27 #include <IOKit/usb/IOUSBLib.h>
28 #include <IOKit/IOCFPlugIn.h>
30 /* IOUSBInterfaceInferface */
31 #if defined (kIOUSBInterfaceInterfaceID300)
33 #define usb_interface_t IOUSBInterfaceInterface300
34 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID300
35 #define InterfaceVersion 300
37 #elif defined (kIOUSBInterfaceInterfaceID245)
39 #define usb_interface_t IOUSBInterfaceInterface245
40 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID245
41 #define InterfaceVersion 245
43 #elif defined (kIOUSBInterfaceInterfaceID220)
45 #define usb_interface_t IOUSBInterfaceInterface220
46 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID220
47 #define InterfaceVersion 220
49 #elif defined (kIOUSBInterfaceInterfaceID197)
51 #define usb_interface_t IOUSBInterfaceInterface197
52 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID197
53 #define InterfaceVersion 197
55 #elif defined (kIOUSBInterfaceInterfaceID190)
57 #define usb_interface_t IOUSBInterfaceInterface190
58 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID190
59 #define InterfaceVersion 190
61 #elif defined (kIOUSBInterfaceInterfaceID182)
63 #define usb_interface_t IOUSBInterfaceInterface182
64 #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID182
65 #define InterfaceVersion 182
67 #else
69 #error "IOUSBFamily is too old. Please upgrade your OS"
71 #endif
73 /* IOUSBDeviceInterface */
74 #if defined (kIOUSBDeviceInterfaceID500)
76 #define usb_device_t IOUSBDeviceInterface500
77 #define DeviceInterfaceID kIOUSBDeviceInterfaceID500
78 #define DeviceVersion 500
80 #elif defined (kIOUSBDeviceInterfaceID320)
82 #define usb_device_t IOUSBDeviceInterface320
83 #define DeviceInterfaceID kIOUSBDeviceInterfaceID320
84 #define DeviceVersion 320
86 #elif defined (kIOUSBDeviceInterfaceID300)
88 #define usb_device_t IOUSBDeviceInterface300
89 #define DeviceInterfaceID kIOUSBDeviceInterfaceID300
90 #define DeviceVersion 300
92 #elif defined (kIOUSBDeviceInterfaceID245)
94 #define usb_device_t IOUSBDeviceInterface245
95 #define DeviceInterfaceID kIOUSBDeviceInterfaceID245
96 #define DeviceVersion 245
98 #elif defined (kIOUSBDeviceInterfaceID197)
100 #define usb_device_t IOUSBDeviceInterface197
101 #define DeviceInterfaceID kIOUSBDeviceInterfaceID197
102 #define DeviceVersion 197
104 #elif defined (kIOUSBDeviceInterfaceID187)
106 #define usb_device_t IOUSBDeviceInterface187
107 #define DeviceInterfaceID kIOUSBDeviceInterfaceID187
108 #define DeviceVersion 187
110 #elif defined (kIOUSBDeviceInterfaceID182)
112 #define usb_device_t IOUSBDeviceInterface182
113 #define DeviceInterfaceID kIOUSBDeviceInterfaceID182
114 #define DeviceVersion 182
116 #else
118 #error "IOUSBFamily is too old. Please upgrade your OS"
120 #endif
122 #if !defined(IO_OBJECT_NULL)
123 #define IO_OBJECT_NULL ((io_object_t) 0)
124 #endif
126 typedef IOCFPlugInInterface *io_cf_plugin_ref_t;
127 typedef IONotificationPortRef io_notification_port_t;
129 /* private structures */
130 struct darwin_device_priv {
131 IOUSBDeviceDescriptor dev_descriptor;
132 UInt32 location;
133 char sys_path[21];
134 usb_device_t **device;
135 int open_count;
136 UInt8 first_config, active_config;
139 struct darwin_device_handle_priv {
140 int is_open;
141 CFRunLoopSourceRef cfSource;
142 int fds[2];
144 struct darwin_interface {
145 usb_interface_t **interface;
146 uint8_t num_endpoints;
147 CFRunLoopSourceRef cfSource;
148 uint64_t frames[256];
149 uint8_t endpoint_addrs[USB_MAXENDPOINTS];
150 } interfaces[USB_MAXINTERFACES];
153 struct darwin_transfer_priv {
154 /* Isoc */
155 IOUSBIsocFrame *isoc_framelist;
156 int num_iso_packets;
158 /* Control */
159 #if !defined (LIBUSB_NO_TIMEOUT_DEVICE)
160 IOUSBDevRequestTO req;
161 #else
162 IOUSBDevRequest req;
163 #endif
165 /* Bulk */
168 /* structure for signaling io completion */
169 struct darwin_msg_async_io_complete {
170 struct usbi_transfer *itransfer;
171 IOReturn result;
172 UInt32 size;
175 #endif