Home | History | Annotate | Download | only in os
      1 /*
      2  * usbfs header structures
      3  * Copyright (C) 2007 Daniel Drake <dsd (at) gentoo.org>
      4  * Copyright (c) 2001 Johannes Erdfelt <johannes (at) erdfelt.com>
      5  *
      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.
     10  *
     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.
     15  *
     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
     19  */
     20 
     21 #ifndef LIBUSB_USBFS_H
     22 #define LIBUSB_USBFS_H
     23 
     24 #define SYSFS_DEVICE_PATH "/sys/bus/usb/devices"
     25 
     26 struct usbfs_ctrltransfer {
     27 	/* keep in sync with usbdevice_fs.h:usbdevfs_ctrltransfer */
     28 	uint8_t  bmRequestType;
     29 	uint8_t  bRequest;
     30 	uint16_t wValue;
     31 	uint16_t wIndex;
     32 	uint16_t wLength;
     33 
     34 	uint32_t timeout;	/* in milliseconds */
     35 
     36 	/* pointer to data */
     37 	void *data;
     38 };
     39 
     40 struct usbfs_bulktransfer {
     41 	/* keep in sync with usbdevice_fs.h:usbdevfs_bulktransfer */
     42 	unsigned int ep;
     43 	unsigned int len;
     44 	unsigned int timeout;	/* in milliseconds */
     45 
     46 	/* pointer to data */
     47 	void *data;
     48 };
     49 
     50 struct usbfs_setinterface {
     51 	/* keep in sync with usbdevice_fs.h:usbdevfs_setinterface */
     52 	unsigned int interface;
     53 	unsigned int altsetting;
     54 };
     55 
     56 #define USBFS_MAXDRIVERNAME 255
     57 
     58 struct usbfs_getdriver {
     59 	unsigned int interface;
     60 	char driver[USBFS_MAXDRIVERNAME + 1];
     61 };
     62 
     63 #define USBFS_URB_SHORT_NOT_OK		0x01
     64 #define USBFS_URB_ISO_ASAP			0x02
     65 #define USBFS_URB_BULK_CONTINUATION	0x04
     66 #define USBFS_URB_QUEUE_BULK		0x10
     67 #define USBFS_URB_ZERO_PACKET		0x40
     68 
     69 enum usbfs_urb_type {
     70 	USBFS_URB_TYPE_ISO = 0,
     71 	USBFS_URB_TYPE_INTERRUPT = 1,
     72 	USBFS_URB_TYPE_CONTROL = 2,
     73 	USBFS_URB_TYPE_BULK = 3,
     74 };
     75 
     76 struct usbfs_iso_packet_desc {
     77 	unsigned int length;
     78 	unsigned int actual_length;
     79 	unsigned int status;
     80 };
     81 
     82 #define MAX_ISO_BUFFER_LENGTH		32768
     83 #define MAX_BULK_BUFFER_LENGTH		16384
     84 #define MAX_CTRL_BUFFER_LENGTH		4096
     85 
     86 struct usbfs_urb {
     87 	unsigned char type;
     88 	unsigned char endpoint;
     89 	int status;
     90 	unsigned int flags;
     91 	void *buffer;
     92 	int buffer_length;
     93 	int actual_length;
     94 	int start_frame;
     95 	int number_of_packets;
     96 	int error_count;
     97 	unsigned int signr;
     98 	void *usercontext;
     99 	struct usbfs_iso_packet_desc iso_frame_desc[0];
    100 };
    101 
    102 struct usbfs_connectinfo {
    103 	unsigned int devnum;
    104 	unsigned char slow;
    105 };
    106 
    107 struct usbfs_ioctl {
    108 	int ifno;	/* interface 0..N ; negative numbers reserved */
    109 	int ioctl_code;	/* MUST encode size + direction of data so the
    110 			 * macros in <asm/ioctl.h> give correct values */
    111 	void *data;	/* param buffer (in, or out) */
    112 };
    113 
    114 struct usbfs_hub_portinfo {
    115 	unsigned char numports;
    116 	unsigned char port[127];	/* port to device num mapping */
    117 };
    118 
    119 #define IOCTL_USBFS_CONTROL	_IOWR('U', 0, struct usbfs_ctrltransfer)
    120 #define IOCTL_USBFS_BULK		_IOWR('U', 2, struct usbfs_bulktransfer)
    121 #define IOCTL_USBFS_RESETEP	_IOR('U', 3, unsigned int)
    122 #define IOCTL_USBFS_SETINTF	_IOR('U', 4, struct usbfs_setinterface)
    123 #define IOCTL_USBFS_SETCONFIG	_IOR('U', 5, unsigned int)
    124 #define IOCTL_USBFS_GETDRIVER	_IOW('U', 8, struct usbfs_getdriver)
    125 #define IOCTL_USBFS_SUBMITURB	_IOR('U', 10, struct usbfs_urb)
    126 #define IOCTL_USBFS_DISCARDURB	_IO('U', 11)
    127 #define IOCTL_USBFS_REAPURB	_IOW('U', 12, void *)
    128 #define IOCTL_USBFS_REAPURBNDELAY	_IOW('U', 13, void *)
    129 #define IOCTL_USBFS_CLAIMINTF	_IOR('U', 15, unsigned int)
    130 #define IOCTL_USBFS_RELEASEINTF	_IOR('U', 16, unsigned int)
    131 #define IOCTL_USBFS_CONNECTINFO	_IOW('U', 17, struct usbfs_connectinfo)
    132 #define IOCTL_USBFS_IOCTL         _IOWR('U', 18, struct usbfs_ioctl)
    133 #define IOCTL_USBFS_HUB_PORTINFO	_IOR('U', 19, struct usbfs_hub_portinfo)
    134 #define IOCTL_USBFS_RESET		_IO('U', 20)
    135 #define IOCTL_USBFS_CLEAR_HALT	_IOR('U', 21, unsigned int)
    136 #define IOCTL_USBFS_DISCONNECT	_IO('U', 22)
    137 #define IOCTL_USBFS_CONNECT	_IO('U', 23)
    138 
    139 #endif
    140