2 * usbfs header structures
3 * Copyright © 2007 Daniel Drake <dsd@gentoo.org>
4 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef LIBUSB_USBFS_H
22 #define LIBUSB_USBFS_H
24 #include <linux/types.h>
26 #define SYSFS_DEVICE_PATH "/sys/bus/usb/devices"
28 struct usbfs_ctrltransfer
{
29 /* keep in sync with usbdevice_fs.h:usbdevfs_ctrltransfer */
30 uint8_t bmRequestType
;
36 uint32_t timeout
; /* in milliseconds */
42 struct usbfs_bulktransfer
{
43 /* keep in sync with usbdevice_fs.h:usbdevfs_bulktransfer */
46 unsigned int timeout
; /* in milliseconds */
52 struct usbfs_setinterface
{
53 /* keep in sync with usbdevice_fs.h:usbdevfs_setinterface */
54 unsigned int interface
;
55 unsigned int altsetting
;
58 #define USBFS_MAXDRIVERNAME 255
60 struct usbfs_getdriver
{
61 unsigned int interface
;
62 char driver
[USBFS_MAXDRIVERNAME
+ 1];
65 #define USBFS_URB_SHORT_NOT_OK 0x01
66 #define USBFS_URB_ISO_ASAP 0x02
67 #define USBFS_URB_BULK_CONTINUATION 0x04
68 #define USBFS_URB_QUEUE_BULK 0x10
69 #define USBFS_URB_ZERO_PACKET 0x40
72 USBFS_URB_TYPE_ISO
= 0,
73 USBFS_URB_TYPE_INTERRUPT
= 1,
74 USBFS_URB_TYPE_CONTROL
= 2,
75 USBFS_URB_TYPE_BULK
= 3,
78 struct usbfs_iso_packet_desc
{
80 unsigned int actual_length
;
84 #define MAX_ISO_BUFFER_LENGTH 32768
85 #define MAX_BULK_BUFFER_LENGTH 16384
86 #define MAX_CTRL_BUFFER_LENGTH 4096
90 unsigned char endpoint
;
97 int number_of_packets
;
101 struct usbfs_iso_packet_desc iso_frame_desc
[0];
104 struct usbfs_connectinfo
{
110 int ifno
; /* interface 0..N ; negative numbers reserved */
111 int ioctl_code
; /* MUST encode size + direction of data so the
112 * macros in <asm/ioctl.h> give correct values */
113 void *data
; /* param buffer (in, or out) */
116 struct usbfs_hub_portinfo
{
117 unsigned char numports
;
118 unsigned char port
[127]; /* port to device num mapping */
121 #define USBFS_CAP_ZERO_PACKET 0x01
122 #define USBFS_CAP_BULK_CONTINUATION 0x02
123 #define USBFS_CAP_NO_PACKET_SIZE_LIM 0x04
124 #define USBFS_CAP_BULK_SCATTER_GATHER 0x08
126 #define IOCTL_USBFS_CONTROL _IOWR('U', 0, struct usbfs_ctrltransfer)
127 #define IOCTL_USBFS_BULK _IOWR('U', 2, struct usbfs_bulktransfer)
128 #define IOCTL_USBFS_RESETEP _IOR('U', 3, unsigned int)
129 #define IOCTL_USBFS_SETINTF _IOR('U', 4, struct usbfs_setinterface)
130 #define IOCTL_USBFS_SETCONFIG _IOR('U', 5, unsigned int)
131 #define IOCTL_USBFS_GETDRIVER _IOW('U', 8, struct usbfs_getdriver)
132 #define IOCTL_USBFS_SUBMITURB _IOR('U', 10, struct usbfs_urb)
133 #define IOCTL_USBFS_DISCARDURB _IO('U', 11)
134 #define IOCTL_USBFS_REAPURB _IOW('U', 12, void *)
135 #define IOCTL_USBFS_REAPURBNDELAY _IOW('U', 13, void *)
136 #define IOCTL_USBFS_CLAIMINTF _IOR('U', 15, unsigned int)
137 #define IOCTL_USBFS_RELEASEINTF _IOR('U', 16, unsigned int)
138 #define IOCTL_USBFS_CONNECTINFO _IOW('U', 17, struct usbfs_connectinfo)
139 #define IOCTL_USBFS_IOCTL _IOWR('U', 18, struct usbfs_ioctl)
140 #define IOCTL_USBFS_HUB_PORTINFO _IOR('U', 19, struct usbfs_hub_portinfo)
141 #define IOCTL_USBFS_RESET _IO('U', 20)
142 #define IOCTL_USBFS_CLEAR_HALT _IOR('U', 21, unsigned int)
143 #define IOCTL_USBFS_DISCONNECT _IO('U', 22)
144 #define IOCTL_USBFS_CONNECT _IO('U', 23)
145 #define IOCTL_USBFS_CLAIM_PORT _IOR('U', 24, unsigned int)
146 #define IOCTL_USBFS_RELEASE_PORT _IOR('U', 25, unsigned int)
147 #define IOCTL_USBFS_GET_CAPABILITIES _IOR('U', 26, __u32)
149 #if defined(HAVE_LIBUDEV)
150 int linux_udev_start_event_monitor(void);
151 int linux_udev_stop_event_monitor(void);
152 int linux_udev_scan_devices(struct libusb_context
*ctx
);
154 int linux_netlink_start_event_monitor(void);
155 int linux_netlink_stop_event_monitor(void);
158 void linux_hotplug_enumerate(uint8_t busnum
, uint8_t devaddr
, const char *sys_name
);
159 void linux_hotplug_disconnected(uint8_t busnum
, uint8_t devaddr
, const char *sys_name
);
161 int linux_get_device_address (struct libusb_context
*ctx
, int detached
,
162 uint8_t *busnum
, uint8_t *devaddr
, const char *dev_node
,
163 const char *sys_name
);
164 int linux_enumerate_device(struct libusb_context
*ctx
,
165 uint8_t busnum
, uint8_t devaddr
, const char *sysfs_dir
);