components/libusb/wrapper/src/usb.h
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Wed, 29 Aug 2012 11:05:56 -0700
changeset 957 255465c5756f
parent 229 1fd565334dfc
permissions -rw-r--r--
Close of build 04.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
229
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     1
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     2
 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     3
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     4
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     5
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     6
 * Prototypes, structure definitions and macros.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     7
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     8
 * Copyright (c) 2000-2003 Johannes Erdfelt <[email protected]>
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     9
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    10
 * This file (and only this file) may alternatively be licensed under the
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    11
 * BSD license as well, read LICENSE for details.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    12
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    13
 * Redistribution and use in source and binary forms, with or without
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    14
 * modification, are permitted provided that the following conditions
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    15
 * are met:
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    16
 * 1. Redistributions of source code must retain the above copyright
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    17
 *    notice, this list of conditions and the following disclaimer.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    18
 * 2. Redistributions in binary form must reproduce the above copyright
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    19
 *    notice, this list of conditions and the following disclaimer in the
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    20
 *    documentation and/or other materials provided with the distribution.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    21
 * 3. The name of the author may not be used to endorse or promote products
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    22
 *    derived from this software without specific prior written permission.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    23
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    25
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    27
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    28
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    29
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    30
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    31
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    32
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    33
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    34
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    35
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    36
#ifndef _SYS_USB_LIBUSB_USB_H
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    37
#define	_SYS_USB_LIBUSB_USB_H
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    38
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    39
#ifdef	__cplusplus
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    40
extern "C" {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    41
#endif
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    42
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    43
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    44
#include <unistd.h>
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    45
#include <stdlib.h>
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    46
#include <limits.h>
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    47
#include <dirent.h>
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    48
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    49
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    50
 * USB spec information
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    51
 *
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    52
 * This is all stuff grabbed from various USB specs and is pretty much
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
 * not subject to change
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    54
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    55
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    56
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    57
 * Device and/or Interface Class codes
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    58
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    59
#define	USB_CLASS_PER_INTERFACE		0	/* for DeviceClass */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    60
#define	USB_CLASS_AUDIO			1
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    61
#define	USB_CLASS_COMM			2
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
#define	USB_CLASS_HID			3
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    63
#define	USB_CLASS_PRINTER		7
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    64
#define	USB_CLASS_MASS_STORAGE		8
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    65
#define	USB_CLASS_HUB			9
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
#define	USB_CLASS_DATA			10
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    67
#define	USB_CLASS_VENDOR_SPEC		0xff
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    69
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    70
 * Descriptor types
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    71
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
#define	USB_DT_DEVICE			0x01
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    73
#define	USB_DT_CONFIG			0x02
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    74
#define	USB_DT_STRING			0x03
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
#define	USB_DT_INTERFACE		0x04
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    76
#define	USB_DT_ENDPOINT			0x05
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
#define	USB_DT_HID			0x21
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
#define	USB_DT_REPORT			0x22
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    80
#define	USB_DT_PHYSICAL			0x23
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
#define	USB_DT_HUB			0x29
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    83
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
 * Descriptor sizes per descriptor type
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    85
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
#define	USB_DT_DEVICE_SIZE		18
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    87
#define	USB_DT_CONFIG_SIZE		9
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
#define	USB_DT_INTERFACE_SIZE		9
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    89
#define	USB_DT_ENDPOINT_SIZE		7
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    90
#define	USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    91
#define	USB_DT_HUB_NONVAR_SIZE		7
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    92
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
/* All standard descriptors have these 2 fields in common */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    94
struct usb_descriptor_header {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    96
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    97
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    98
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    99
/* String descriptor */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   100
struct usb_string_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   101
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   102
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   103
	uint16_t wData[1];
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   104
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   105
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   106
/* HID descriptor */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   107
struct usb_hid_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   108
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   109
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   110
	uint16_t bcdHID;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   111
	uint8_t  bCountryCode;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   112
	uint8_t  bNumDescriptors;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   113
	/* u_int8_t  bReportDescriptorType; */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   114
	/* u_int16_t wDescriptorLength; */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   115
	/* ... */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   116
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   117
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   118
/* Endpoint descriptor */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   119
#define	USB_MAXENDPOINTS	32
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   120
struct usb_endpoint_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   121
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   122
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   123
	uint8_t  bEndpointAddress;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   124
	uint8_t  bmAttributes;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   125
	uint16_t wMaxPacketSize;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   126
	uint8_t  bInterval;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   127
	uint8_t  bRefresh;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   128
	uint8_t  bSynchAddress;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   129
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   130
	unsigned char *extra;	/* Extra descriptors */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   131
	int extralen;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   132
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   133
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   134
#define	USB_ENDPOINT_ADDRESS_MASK	0x0f	/* in bEndpointAddress */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   135
#define	USB_ENDPOINT_DIR_MASK		0x80
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   136
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   137
#define	USB_ENDPOINT_TYPE_MASK		0x03	/* in bmAttributes */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   138
#define	USB_ENDPOINT_TYPE_CONTROL	0
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   139
#define	USB_ENDPOINT_TYPE_ISOCHRONOUS	1
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   140
#define	USB_ENDPOINT_TYPE_BULK		2
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   141
#define	USB_ENDPOINT_TYPE_INTERRUPT	3
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   142
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   143
/* Interface descriptor */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   144
#define	USB_MAXINTERFACES	32
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   145
struct usb_interface_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   146
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   147
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   148
	uint8_t  bInterfaceNumber;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   149
	uint8_t  bAlternateSetting;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   150
	uint8_t  bNumEndpoints;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   151
	uint8_t  bInterfaceClass;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   152
	uint8_t  bInterfaceSubClass;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   153
	uint8_t  bInterfaceProtocol;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   154
	uint8_t  iInterface;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   155
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   156
	struct usb_endpoint_descriptor *endpoint;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   157
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   158
	unsigned char *extra;	/* Extra descriptors */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   159
	int extralen;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   160
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   161
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   162
#define	USB_MAXALTSETTING	128	/* Hard limit */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   163
struct usb_interface {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   164
	struct usb_interface_descriptor *altsetting;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   165
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   166
	int num_altsetting;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   167
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   168
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   169
/* Configuration descriptor information.. */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   170
#define	USB_MAXCONFIG		8
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   171
struct usb_config_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   172
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   173
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   174
	uint16_t wTotalLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   175
	uint8_t  bNumInterfaces;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   176
	uint8_t  bConfigurationValue;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   177
	uint8_t  iConfiguration;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   178
	uint8_t  bmAttributes;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   179
	uint8_t  MaxPower;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   180
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   181
	struct usb_interface *interface; /* array of interface descriptors */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   182
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   183
	unsigned char *extra;	/* Extra descriptors */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   184
	int extralen;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   185
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   186
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   187
/* Device descriptor */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   188
struct usb_device_descriptor {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   189
	uint8_t  bLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   190
	uint8_t  bDescriptorType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   191
	uint16_t bcdUSB;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   192
	uint8_t  bDeviceClass;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   193
	uint8_t  bDeviceSubClass;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   194
	uint8_t  bDeviceProtocol;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   195
	uint8_t  bMaxPacketSize0;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   196
	uint16_t idVendor;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   197
	uint16_t idProduct;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   198
	uint16_t bcdDevice;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   199
	uint8_t  iManufacturer;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   200
	uint8_t  iProduct;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   201
	uint8_t  iSerialNumber;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   202
	uint8_t  bNumConfigurations;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   203
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   204
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   205
struct usb_ctrl_setup {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   206
	uint8_t  bRequestType;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   207
	uint8_t  bRequest;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   208
	uint16_t wValue;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   209
	uint16_t wIndex;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   210
	uint16_t wLength;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   211
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   212
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   213
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   214
 * Standard requests
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   215
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   216
#define	USB_REQ_GET_STATUS		0x00
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   217
#define	USB_REQ_CLEAR_FEATURE		0x01
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   218
/* 0x02 is reserved */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   219
#define	USB_REQ_SET_FEATURE		0x03
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   220
/* 0x04 is reserved */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   221
#define	USB_REQ_SET_ADDRESS		0x05
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   222
#define	USB_REQ_GET_DESCRIPTOR		0x06
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   223
#define	USB_REQ_SET_DESCRIPTOR		0x07
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   224
#define	USB_REQ_GET_CONFIGURATION	0x08
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   225
#define	USB_REQ_SET_CONFIGURATION	0x09
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   226
#define	USB_REQ_GET_INTERFACE		0x0A
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   227
#define	USB_REQ_SET_INTERFACE		0x0B
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   228
#define	USB_REQ_SYNCH_FRAME		0x0C
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   229
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   230
#define	USB_TYPE_STANDARD		(0x00 << 5)
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   231
#define	USB_TYPE_CLASS			(0x01 << 5)
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   232
#define	USB_TYPE_VENDOR			(0x02 << 5)
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   233
#define	USB_TYPE_RESERVED		(0x03 << 5)
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   234
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   235
#define	USB_RECIP_DEVICE		0x00
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   236
#define	USB_RECIP_INTERFACE		0x01
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   237
#define	USB_RECIP_ENDPOINT		0x02
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   238
#define	USB_RECIP_OTHER			0x03
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   239
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   240
/*
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   241
 * Various libusb API related stuff
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   242
 */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   243
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   244
#define	USB_ENDPOINT_IN			0x80
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   245
#define	USB_ENDPOINT_OUT		0x00
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   246
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   247
/* Error codes */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   248
#define	USB_ERROR_BEGIN			500000
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   249
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   250
#define	USB_LE16_TO_CPU(x) do { \
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   251
	x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); \
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   252
	} while (0)
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   253
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   254
/* Data types */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   255
struct usb_device {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   256
	struct usb_device	*next, *prev;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   257
	char			filename[PATH_MAX + 1];
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   258
	struct usb_bus		*bus;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   259
	struct usb_device_descriptor descriptor;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   260
	struct usb_config_descriptor *config;  /* array of config descriptors */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   261
	void			*dev;	/* OS specific */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   262
	uint8_t			devnum;	/* not supported */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   263
	unsigned char		num_children; /* not supported */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   264
	struct usb_device	**children; /* not supported */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   265
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   266
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   267
struct usb_bus {
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   268
	struct usb_bus		*next, *prev;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   269
	char			dirname[PATH_MAX + 1];
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   270
	struct usb_device	*devices;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   271
	uint32_t 		location;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   272
	struct usb_device	*root_dev; /* not supported */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   273
};
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   274
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   275
typedef struct usb_dev_handle usb_dev_handle;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   276
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   277
/* Variables */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   278
extern struct usb_bus *usb_busses;
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   279
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   280
/* Function prototypes */
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   281
usb_dev_handle	*usb_open(struct usb_device *dev);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   282
int		usb_close(usb_dev_handle *dev);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   283
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   284
int		usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   285
			int size, int timeout);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   286
int		usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   287
			int size, int timeout);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   288
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   289
int		usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   290
			int size, int timeout);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   291
int		usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   292
			int size, int timeout);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   293
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   294
int		usb_control_msg(usb_dev_handle *dev, int requesttype,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   295
			int request, int value, int index, char *bytes,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   296
			int size, int timeout);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   297
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   298
int		usb_set_configuration(usb_dev_handle *dev,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   299
			int configuration);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   300
int		usb_claim_interface(usb_dev_handle *dev, int interface);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   301
int		usb_release_interface(usb_dev_handle *dev, int interface);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   302
int		usb_set_altinterface(usb_dev_handle *dev, int alternate);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   303
int		usb_resetep(usb_dev_handle *dev, unsigned int ep);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   304
int		usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   305
int		usb_reset(usb_dev_handle *dev);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   306
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   307
int		usb_get_string(usb_dev_handle *dev, int index, int langid,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   308
			char *buf, size_t buflen);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   309
int		usb_get_string_simple(usb_dev_handle *dev, int index,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   310
			char *buf, size_t buflen);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   311
int		usb_get_descriptor_by_endpoint(usb_dev_handle *dev, int ep,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   312
			uchar_t type, uchar_t index, void *buf, int size);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   313
int 		usb_get_descriptor(usb_dev_handle *dev, uchar_t type,
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   314
			uchar_t index, void *buf, int size);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   315
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   316
char		*usb_strerror(void);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   317
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   318
void		usb_init(void);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   319
void		usb_set_debug(int level);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   320
int		usb_find_busses(void);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   321
int		usb_find_devices(void);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   322
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   323
struct usb_device *usb_device(usb_dev_handle *dev);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   324
struct usb_bus	*usb_get_busses(void);
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   325
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   326
#ifdef __cplusplus
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   327
}
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   328
#endif
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   329
1fd565334dfc 7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   330
#endif /* _SYS_USB_LIBUSB_USB_H */