• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.hardware.usb;
18 
19 /**
20  * Contains constants for the USB protocol.
21  * These constants correspond to definitions in linux/usb/ch9.h in the linux kernel.
22  */
23 public final class UsbConstants {
24 
25     /**
26      * Bitmask used for extracting the {@link UsbEndpoint} direction from its address field.
27      * @see UsbEndpoint#getAddress
28      * @see UsbEndpoint#getDirection
29      * @see #USB_DIR_OUT
30      * @see #USB_DIR_IN
31      *
32      */
33     public static final int USB_ENDPOINT_DIR_MASK = 0x80;
34     /**
35      * Used to signify direction of data for a {@link UsbEndpoint} is OUT (host to device)
36      * @see UsbEndpoint#getDirection
37      */
38     public static final int USB_DIR_OUT = 0;
39     /**
40      * Used to signify direction of data for a {@link UsbEndpoint} is IN (device to host)
41      * @see UsbEndpoint#getDirection
42      */
43     public static final int USB_DIR_IN = 0x80;
44 
45     /**
46      * Bitmask used for extracting the {@link UsbEndpoint} number its address field.
47      * @see UsbEndpoint#getAddress
48      * @see UsbEndpoint#getEndpointNumber
49      */
50     public static final int USB_ENDPOINT_NUMBER_MASK = 0x0f;
51 
52     /**
53      * Bitmask used for extracting the {@link UsbEndpoint} type from its address field.
54      * @see UsbEndpoint#getAddress
55      * @see UsbEndpoint#getType
56      * @see #USB_ENDPOINT_XFER_CONTROL
57      * @see #USB_ENDPOINT_XFER_ISOC
58      * @see #USB_ENDPOINT_XFER_BULK
59      * @see #USB_ENDPOINT_XFER_INT
60      */
61     public static final int USB_ENDPOINT_XFERTYPE_MASK = 0x03;
62     /**
63      * Control endpoint type (endpoint zero)
64      * @see UsbEndpoint#getType
65      */
66     public static final int USB_ENDPOINT_XFER_CONTROL = 0;
67     /**
68      * Isochronous endpoint type (currently not supported)
69      * @see UsbEndpoint#getType
70      */
71     public static final int USB_ENDPOINT_XFER_ISOC = 1;
72     /**
73      * Bulk endpoint type
74      * @see UsbEndpoint#getType
75      */
76     public static final int USB_ENDPOINT_XFER_BULK = 2;
77     /**
78      * Interrupt endpoint type
79      * @see UsbEndpoint#getType
80      */
81     public static final int USB_ENDPOINT_XFER_INT = 3;
82 
83 
84     /**
85      * Bitmask used for encoding the request type for a control request on endpoint zero.
86      */
87     public static final int USB_TYPE_MASK = (0x03 << 5);
88     /**
89      * Used to specify that an endpoint zero control request is a standard request.
90      */
91     public static final int USB_TYPE_STANDARD = (0x00 << 5);
92     /**
93      * Used to specify that an endpoint zero control request is a class specific request.
94      */
95     public static final int USB_TYPE_CLASS = (0x01 << 5);
96     /**
97      * Used to specify that an endpoint zero control request is a vendor specific request.
98      */
99     public static final int USB_TYPE_VENDOR = (0x02 << 5);
100     /**
101      * Reserved endpoint zero control request type (currently unused).
102      */
103     public static final int USB_TYPE_RESERVED = (0x03 << 5);
104 
105 
106     /**
107      * USB class indicating that the class is determined on a per-interface basis.
108      */
109     public static final int USB_CLASS_PER_INTERFACE = 0;
110     /**
111      * USB class for audio devices.
112      */
113     public static final int USB_CLASS_AUDIO = 1;
114     /**
115      * USB class for communication devices.
116      */
117     public static final int USB_CLASS_COMM = 2;
118     /**
119      * USB class for human interface devices (for example, mice and keyboards).
120      */
121     public static final int USB_CLASS_HID = 3;
122     /**
123      * USB class for physical devices.
124      */
125     public static final int USB_CLASS_PHYSICA = 5;
126     /**
127      * USB class for still image devices (digital cameras).
128      */
129     public static final int USB_CLASS_STILL_IMAGE = 6;
130     /**
131      * USB class for printers.
132      */
133     public static final int USB_CLASS_PRINTER = 7;
134     /**
135      * USB class for mass storage devices.
136      */
137     public static final int USB_CLASS_MASS_STORAGE = 8;
138     /**
139      * USB class for USB hubs.
140      */
141     public static final int USB_CLASS_HUB = 9;
142     /**
143      * USB class for CDC devices (communications device class).
144      */
145     public static final int USB_CLASS_CDC_DATA = 0x0a;
146     /**
147      * USB class for content smart card devices.
148      */
149     public static final int USB_CLASS_CSCID = 0x0b;
150     /**
151      * USB class for content security devices.
152      */
153     public static final int USB_CLASS_CONTENT_SEC = 0x0d;
154     /**
155      * USB class for video devices.
156      */
157     public static final int USB_CLASS_VIDEO = 0x0e;
158     /**
159      * USB class for wireless controller devices.
160      */
161     public static final int USB_CLASS_WIRELESS_CONTROLLER = 0xe0;
162     /**
163      * USB class for wireless miscellaneous devices.
164      */
165     public static final int USB_CLASS_MISC = 0xef;
166     /**
167      * Application specific USB class.
168      */
169     public static final int USB_CLASS_APP_SPEC = 0xfe;
170     /**
171      * Vendor specific USB class.
172      */
173     public static final int USB_CLASS_VENDOR_SPEC = 0xff;
174 
175     /**
176      * Boot subclass for HID devices.
177      */
178     public static final int USB_INTERFACE_SUBCLASS_BOOT = 1;
179     /**
180      * Vendor specific USB subclass.
181      */
182     public static final int USB_SUBCLASS_VENDOR_SPEC = 0xff;
183 }
184